Best JavaScript code snippet using cypress
ibm-mobilefirst.js
Source:ibm-mobilefirst.js
1declare module 'ibm-mobilefirst' {2 declare var WL: typeof npm$namespace$WL;3 declare var npm$namespace$WL: {4 5 Logger: typeof WL$Logger,6ClientMessages: typeof WL$ClientMessages,7 8 ResponseBase: typeof WL$ResponseBase,9FailureResponse: typeof WL$FailureResponse,10Response: typeof WL$Response,11BusyIndicator: typeof WL$BusyIndicator,12Item: typeof WL$Item,13LoggerObject: typeof WL$LoggerObject,14LogInstance: typeof WL$LogInstance,15TabBarItem: typeof WL$TabBarItem,16 Events: typeof npm$namespace$WL$Events,17AppProperty: typeof npm$namespace$WL$AppProperty,18Environment: typeof npm$namespace$WL$Environment,19Analytics: typeof npm$namespace$WL$Analytics,20App: typeof npm$namespace$WL$App,21Badge: typeof npm$namespace$WL$Badge,22Client: typeof npm$namespace$WL$Client,23Device: typeof npm$namespace$WL$Device,24EncryptedCache: typeof npm$namespace$WL$EncryptedCache,25Geo: typeof npm$namespace$WL$Geo,26JSONStore: typeof npm$namespace$WL$JSONStore,27LocalStorage: typeof npm$namespace$WL$LocalStorage,28NativePage: typeof npm$namespace$WL$NativePage,29SecurityUtils: typeof npm$namespace$WL$SecurityUtils,30SimpleDialog: typeof npm$namespace$WL$SimpleDialog,31TabBar: typeof npm$namespace$WL$TabBar,32Toast: typeof npm$namespace$WL$Toast,33Trusteer: typeof npm$namespace$WL$Trusteer,34UserAuth: typeof npm$namespace$WL$UserAuth,35 }36 declare var npm$namespace$WL$Events: {37 38 WORKLIGHT_IS_CONNECTED: typeof WL$Events$WORKLIGHT_IS_CONNECTED,39WORKLIGHT_IS_DISCONNECTED: typeof WL$Events$WORKLIGHT_IS_DISCONNECTED,40 41 42 43 }44declare var WL$Events$WORKLIGHT_IS_CONNECTED: string;45declare var WL$Events$WORKLIGHT_IS_DISCONNECTED: string;46 declare var npm$namespace$WL$AppProperty: {47 48 AIR_ICON_16x16_PATH: typeof WL$AppProperty$AIR_ICON_16x16_PATH,49AIR_ICON_128x128_PATH: typeof WL$AppProperty$AIR_ICON_128x128_PATH,50DOWNLOAD_APP_LINK: typeof WL$AppProperty$DOWNLOAD_APP_LINK,51APP_DISPLAY_NAME: typeof WL$AppProperty$APP_DISPLAY_NAME,52APP_LOGIN_TYPE: typeof WL$AppProperty$APP_LOGIN_TYPE,53APP_VERSION: typeof WL$AppProperty$APP_VERSION,54LATEST_VERSION: typeof WL$AppProperty$LATEST_VERSION,55MAIN_FILE_PATH: typeof WL$AppProperty$MAIN_FILE_PATH,56SHOW_IN_TASKBAR: typeof WL$AppProperty$SHOW_IN_TASKBAR,57THUMBNAIL_IMAGE_URL: typeof WL$AppProperty$THUMBNAIL_IMAGE_URL,58 59 60 61 }62declare var WL$AppProperty$AIR_ICON_16x16_PATH: string;63declare var WL$AppProperty$AIR_ICON_128x128_PATH: string;64declare var WL$AppProperty$DOWNLOAD_APP_LINK: string;65declare var WL$AppProperty$APP_DISPLAY_NAME: string;66declare var WL$AppProperty$APP_LOGIN_TYPE: string;67declare var WL$AppProperty$APP_VERSION: string;68declare var WL$AppProperty$LATEST_VERSION: string;69declare var WL$AppProperty$MAIN_FILE_PATH: string;70declare var WL$AppProperty$SHOW_IN_TASKBAR: string;71declare var WL$AppProperty$THUMBNAIL_IMAGE_URL: string;72 declare var npm$namespace$WL$Environment: {73 74 ADOBE_AIR: typeof WL$Environment$ADOBE_AIR,75ANDROID: typeof WL$Environment$ANDROID,76EMBEDDED: typeof WL$Environment$EMBEDDED,77IPAD: typeof WL$Environment$IPAD,78IPHONE: typeof WL$Environment$IPHONE,79MOBILE_WEB: typeof WL$Environment$MOBILE_WEB,80PREVIEW: typeof WL$Environment$PREVIEW,81WINDOWS_PHONE_8: typeof WL$Environment$WINDOWS_PHONE_8,82WINDOWS8: typeof WL$Environment$WINDOWS8,83 84 85 86 }87declare var WL$Environment$ADOBE_AIR: string;88declare var WL$Environment$ANDROID: string;89declare var WL$Environment$EMBEDDED: string;90declare var WL$Environment$IPAD: string;91declare var WL$Environment$IPHONE: string;92declare var WL$Environment$MOBILE_WEB: string;93declare var WL$Environment$PREVIEW: string;94declare var WL$Environment$WINDOWS_PHONE_8: string;95declare var WL$Environment$WINDOWS8: string;96declare interface WL$IResponse {97invocationContext?: any98} 99declare interface WL$Headers {100[key: string]: string101} 102declare class WL$ResponseBase {103invocationContext: any;104headerJSON: {105[key: string]: any106};107readyState: number;108request: any;109responseJSON: {110[key: string]: any111};112responseText: string;113responseXML: string;114status: number;115statusText: string;116errorCode: number;117errorMsg: string118}119declare class WL$FailureResponse mixins WL$ResponseBase {}120declare class WL$Response mixins WL$ResponseBase {121getHeaderNames(): string[];122getAllHeaders(): WL$Headers;123getHeader(name: any): string124}125declare interface WL$Options {126onSuccess?: (response: WL$IResponse) => void,127onFailure?: (response: WL$IResponse) => void,128invocationContext?: any129} 130declare interface WL$ResponseHandler<T> {131(response: T): void132} 133 declare var npm$namespace$WL$Analytics: {134 disable: typeof WL$Analytics$disable,135enable: typeof WL$Analytics$enable,136log: typeof WL$Analytics$log,137restart: typeof WL$Analytics$restart,138send: typeof WL$Analytics$send,139state: typeof WL$Analytics$state,140 141 142 143 144 }145declare function WL$Analytics$disable(): void146declare function WL$Analytics$enable(): void147declare function WL$Analytics$log(message: string, name: string): void148/โ**149 * @deprecated since version 6.2. WL.Analytics.restart is now a NOP.150 */โ151declare function WL$Analytics$restart(): void152declare function WL$Analytics$send(): void153declare function WL$Analytics$state(): void154 declare var npm$namespace$WL$App: {155 addActionReceiver: typeof WL$App$addActionReceiver,156close: typeof WL$App$close,157copyToClipboard: typeof WL$App$copyToClipboard,158getDeviceLanguage: typeof WL$App$getDeviceLanguage,159getDeviceLocale: typeof WL$App$getDeviceLocale,160getErrorMessage: typeof WL$App$getErrorMessage,161hideSplashScreen: typeof WL$App$hideSplashScreen,162openURL: typeof WL$App$openURL,163overrideBackButton: typeof WL$App$overrideBackButton,164removeActionReceiver: typeof WL$App$removeActionReceiver,165resetBackButton: typeof WL$App$resetBackButton,166sendActionToNative: typeof WL$App$sendActionToNative,167setKeepAliveInBackground: typeof WL$App$setKeepAliveInBackground,168showSplashScreen: typeof WL$App$showSplashScreen,169 170 171 172 BackgroundHandler: typeof npm$namespace$WL$App$BackgroundHandler,173 }174declare interface WL$App$ActionReceiverCallback {175(action: any): void176} 177declare interface WL$App$Callback {178(): void179} 180declare interface WL$App$OpenURLOptions {181status?: number,182toolbar?: number,183location?: number,184menubar?: number,185directories?: number,186resizable?: number,187scrollbars?: number188} 189declare interface WL$App$Data {} 190declare interface WL$App$KeepAliveInBackgroundOptions {191tickerText?: string,192contentTitle?: string,193contentTextText?: string,194icon?: string,195notificationId?: number,196className?: string197} 198declare function WL$App$addActionReceiver(id: string, callback: WL$App$ActionReceiverCallback): void199/โ**200 * @deprecate Deprecated.201 */โ202declare function WL$App$close(): void203declare function WL$App$copyToClipboard(stringToCopy: string, callback?: WL$App$Callback): void204declare function WL$App$getDeviceLanguage(): string205declare function WL$App$getDeviceLocale(): string206/โ**207 * TODO: declare exception type. (Exceptions that are thrown by the IBMรยฎ Worklightรยฎ client runtime framework)208 */โ209declare function WL$App$getErrorMessage(exception: any): string210declare function WL$App$hideSplashScreen(): void211declare function WL$App$openURL(url: string, target?: string, options?: WL$App$OpenURLOptions): void212declare function WL$App$overrideBackButton(callback: WL$App$Callback): void213declare function WL$App$removeActionReceiver(id: string): void214/โ**215 * @deprecated since version 6.0.0216 */โ217declare function WL$App$resetBackButton(): void218declare function WL$App$sendActionToNative(action: string, data?: WL$App$Data): void219declare function WL$App$setKeepAliveInBackground(enabled: boolean, options?: WL$App$KeepAliveInBackgroundOptions): void220declare function WL$App$showSplashScreen(): void221 declare var npm$namespace$WL$App$BackgroundHandler: {222 setOnAppEnteringBackground: typeof WL$App$BackgroundHandler$setOnAppEnteringBackground,223 hideView: typeof WL$App$BackgroundHandler$hideView,224defaultIOSBehavior: typeof WL$App$BackgroundHandler$defaultIOSBehavior,225hideElements: typeof WL$App$BackgroundHandler$hideElements,226 227 228 229 }230declare interface WL$App$BackgroundHandler$Handler {231(): void232} 233declare function WL$App$BackgroundHandler$setOnAppEnteringBackground(handler: WL$App$BackgroundHandler$Handler): void234declare var WL$App$BackgroundHandler$hideView: WL$App$BackgroundHandler$Handler;235declare var WL$App$BackgroundHandler$defaultIOSBehavior: WL$App$BackgroundHandler$Handler;236/โ**237 * @deprecated since version 6.0.0238 */โ239declare var WL$App$BackgroundHandler$hideElements: WL$App$BackgroundHandler$Handler;240 declare var npm$namespace$WL$Badge: {241 setNumber: typeof WL$Badge$setNumber,242 243 244 245 246 }247declare function WL$Badge$setNumber(badgeNumber: number): void248declare interface WL$BusyIndicatorOptions {249tickerText?: string,250contentTitle?: string,251contentTextText?: string,252icon?: string,253notificationId?: number,254className?: string255} 256declare class WL$BusyIndicator {257constructor(containerId?: string, options?: WL$BusyIndicator): this;258hide(): void;259show(): void260}261 declare var npm$namespace$WL$Client: {262 addGlobalHeader: typeof WL$Client$addGlobalHeader,263checkForDirectUpdate: typeof WL$Client$checkForDirectUpdate,264clearSharedToken: typeof WL$Client$clearSharedToken,265close: typeof WL$Client$close,266connect: typeof WL$Client$connect,267createChallengeHandler: typeof WL$Client$createChallengeHandler,268createProvisioningChallengeHandler: typeof WL$Client$createProvisioningChallengeHandler,269createWLChallengeHandler: typeof WL$Client$createWLChallengeHandler,270deleteUserPref: typeof WL$Client$deleteUserPref,271getAppProperty: typeof WL$Client$getAppProperty,272getEnvironment: typeof WL$Client$getEnvironment,273getLanguage: typeof WL$Client$getLanguage,274getLastAccessToken: typeof WL$Client$getLastAccessToken,275getLoginName: typeof WL$Client$getLoginName,276getRequiredAccessTokenScope: typeof WL$Client$getRequiredAccessTokenScope,277getSharedToken: typeof WL$Client$getSharedToken,278getUserInfo: typeof WL$Client$getUserInfo,279getUserName: typeof WL$Client$getUserName,280getUserPref: typeof WL$Client$getUserPref,281hasUserPref: typeof WL$Client$hasUserPref,282init: typeof WL$Client$init,283invokeProcedure: typeof WL$Client$invokeProcedure,284isConnected: typeof WL$Client$isConnected,285isUserAuthenticated: typeof WL$Client$isUserAuthenticated,286logActivity: typeof WL$Client$logActivity,287login: typeof WL$Client$login,288logout: typeof WL$Client$logout,289minimize: typeof WL$Client$minimize,290obtainAccessToken: typeof WL$Client$obtainAccessToken,291purgeEventTransmissionBuffer: typeof WL$Client$purgeEventTransmissionBuffer,292reloadApp: typeof WL$Client$reloadApp,293removeGlobalHeader: typeof WL$Client$removeGlobalHeader,294setEventTransmissionPolicy: typeof WL$Client$setEventTransmissionPolicy,295setHeartBeatInterval: typeof WL$Client$setHeartBeatInterval,296setSharedToken: typeof WL$Client$setSharedToken,297setUserPref: typeof WL$Client$setUserPref,298setUserPrefs: typeof WL$Client$setUserPrefs,299transmitEvent: typeof WL$Client$transmitEvent,300updateUserInfo: typeof WL$Client$updateUserInfo,301 302 303 AbstractChallengeHandler: typeof WL$Client$AbstractChallengeHandler,304 305 }306declare interface WL$Client$SharedTokenObject {307key: string308} 309declare interface WL$Client$ConnectOptions {310onSuccess: (response: WL$ResponseBase) => void,311onFailure: (response: WL$FailureResponse) => void,312timeout?: number313} 314declare interface WL$Client$ChallengehandlerInvocationData {315adapter: string,316procedure: string,317parameters: any[]318} 319declare interface WL$Client$ChallengeHandlerAuthenticationOptions {} 320declare interface WL$Client$ChallengeHandlerSubmitLoginFormOptions {321timeout?: number,322headers?: Object,323parameters?: Object324} 325declare class WL$Client$AbstractChallengeHandler {326handleChallenge(challenge: any): boolean;327isCustomResponse(transport: any): boolean;328submitAdapterAuthentication(329invocationData: WL$Client$ChallengehandlerInvocationData,330options: WL$Client$ChallengeHandlerAuthenticationOptions): void;331submitFailure(error: string): void;332submitLoginForm(333reqURL: string,334options: WL$Client$ChallengeHandlerSubmitLoginFormOptions,335submitLoginFormCallback: (transport: any) => void): void;336submitSuccess(): void337}338declare type WL$Client$InitOptions = {339timeout?: number,340/โ**341 * @deprecated since version 6.2. Use WL.Logger.config function with an object specifying the level instead.342 */โ343enableLogger?: boolean,344messages?: string,345authenticator?: Object,346heartBeatIntervalInSecs?: number,347/โ**348 * @deprecated . If you would like your application to connect to the Worklight Server, use WL.Client.connect().349 */โ350connectOnStartup?: boolean,351onConnectionFailure?: (response: WL$FailureResponse) => void,352onUnsupportedVersion?: (response: WL$FailureResponse) => void,353onRequestTimeout?: (response: WL$FailureResponse) => void,354onUnsupportedBrowser?: (response: WL$FailureResponse) => void,355onDisabledCookies?: (response: WL$FailureResponse) => void,356onUserInstanceAccessViolation?: (response: WL$FailureResponse) => void,357onErrorRemoteDisableDenial?: (response: WL$FailureResponse) => void,358/โ**359 * @deprecated since version 5.0.6. Instead, use onErrorRemoteDisableDenial.360 */โ361onErrorAppVersionAccessDenial?: (response: WL$FailureResponse) => void,362validateArguments?: boolean,363autoHideSplash?: boolean,364onGetCustomDeviceProvisioningProperties: (resumeDeviceProvisioningProcess: (data: any) => void) => void365} & WL$Options366declare interface WL$Client$ProcedureInvocationData {367adapter: string,368procedure: string,369parameters?: any[],370compressResponse?: boolean371} 372declare interface WL$Client$ProcedureInvocationResult {373isSuccessful: boolean,374errors?: string[]375} 376declare type WL$Client$ProcedureResponse = {377invocationResult?: WL$Client$ProcedureInvocationResult,378parameters?: any[]379} & WL$ResponseBase380declare type WL$Client$ProcedureInvocationOptions = {381timeout: number,382onSuccess: (response: WL$Client$ProcedureResponse) => void383} & WL$Options384declare function WL$Client$addGlobalHeader(headerName: string, headerValue: string): void385declare function WL$Client$checkForDirectUpdate(options: WL$Options): void386declare function WL$Client$clearSharedToken(object: WL$Client$SharedTokenObject): JQueryDeferred<any>387declare function WL$Client$close(): void388declare function WL$Client$connect(options?: WL$Client$ConnectOptions): void389declare function WL$Client$createChallengeHandler(realmName: string): WL$Client$AbstractChallengeHandler390declare function WL$Client$createProvisioningChallengeHandler(realmName: string): WL$Client$AbstractChallengeHandler391declare function WL$Client$createWLChallengeHandler(realName: string): WL$Client$AbstractChallengeHandler392declare function WL$Client$deleteUserPref(key: string, options?: WL$Options): void393/โ**394 * See WL.AppProperty for possible results395 */โ396declare function WL$Client$getAppProperty(property: any): any397/โ**398 * See WL.Environment for possible results399 */โ400declare function WL$Client$getEnvironment(): string401declare function WL$Client$getLanguage(): string402declare function WL$Client$getLastAccessToken(scope?: string): string403declare function WL$Client$getLoginName(realmName: string): string404/โ**405 * @deprecated since version 7.0406 */โ407declare function WL$Client$getRequiredAccessTokenScope(status: number, header: string): string408declare function WL$Client$getSharedToken(object: WL$Client$SharedTokenObject): JQueryDeferred<any>409declare function WL$Client$getUserInfo(realm: string, key: string): any410declare function WL$Client$getUserName(realm: any): string411declare function WL$Client$getUserPref(key: any): any412declare function WL$Client$hasUserPref(key: any): boolean413declare function WL$Client$init(options: WL$Client$InitOptions): void414declare function WL$Client$invokeProcedure(415invocationData: WL$Client$ProcedureInvocationData,416options?: WL$Client$ProcedureInvocationOptions): JQueryDeferred<WL$Response>417/โ**418 * @deprecated since version 4.1.3. Use WL.Device.getNetworkInfo instead.419 */โ420declare function WL$Client$isConnected(): void421declare function WL$Client$isUserAuthenticated(realm: string): boolean422/โ**423 * @deprecated since version 7.0. Use WL.Logger instead.424 */โ425declare function WL$Client$logActivity(activityType: string): void426declare function WL$Client$login(realm: string, options?: WL$Options): void427declare function WL$Client$logout(realm: string, options?: WL$Options): void428declare function WL$Client$minimize(): void429/โ**430 * @deprecated since version 7.0431 */โ432declare function WL$Client$obtainAccessToken(433scope: string,434onSuccess: WL$ResponseHandler<WL$Response>,435onFailure: WL$ResponseHandler<WL$FailureResponse>): void436declare function WL$Client$purgeEventTransmissionBuffer(): void437declare function WL$Client$reloadApp(): void438declare function WL$Client$removeGlobalHeader(headerName: string): void439declare interface WL$Client$EventTransmissionPolicy {440eventStorageEnabled?: boolean,441interval?: number442} 443declare function WL$Client$setEventTransmissionPolicy(policy: WL$Client$EventTransmissionPolicy): void444declare function WL$Client$setHeartBeatInterval(interval: number): void445declare function WL$Client$setSharedToken(token: WL$Client$SharedTokenObject): void446declare function WL$Client$setUserPref(key: string, value: string, options?: WL$Options): void447declare interface WL$Client$UserPreferences {448[key: string]: string449} 450declare function WL$Client$setUserPrefs(userPrefsHash: WL$Client$UserPreferences, options?: WL$Options): void451declare function WL$Client$transmitEvent(event: any, immediate?: boolean): void452declare function WL$Client$updateUserInfo(options: WL$Options): void453 declare var npm$namespace$WL$Device: {454 getNetworkInfo: typeof WL$Device$getNetworkInfo,455 456 457 458 459 }460declare interface WL$Device$AddressPair {461wifiAddress: string,462"3GAddress": string463} 464declare interface WL$Device$NetworkInfo {465isNetworkConnected?: boolean,466isAirplaneMode?: boolean,467isRoaming?: boolean,468networkConnectionType?: string,469wifiName?: string,470telephonyNetworkType?: string,471carrierName?: string,472ipAddress?: string,473Ipv4Addresses?: WL$Device$AddressPair[],474Ipv6Addresses?: WL$Device$AddressPair[]475} 476declare function WL$Device$getNetworkInfo(callback: (networkInfo: WL$Device$NetworkInfo) => void): void477 declare var npm$namespace$WL$EncryptedCache: {478 close: typeof WL$EncryptedCache$close,479destroy: typeof WL$EncryptedCache$destroy,480open: typeof WL$EncryptedCache$open,481read: typeof WL$EncryptedCache$read,482remove: typeof WL$EncryptedCache$remove,483write: typeof WL$EncryptedCache$write,484 OK: typeof WL$EncryptedCache$OK,485ERROR_COULD_NOT_GENERATE_KEY: typeof WL$EncryptedCache$ERROR_COULD_NOT_GENERATE_KEY,486ERROR_CREDENTIALS_MISMATCH: typeof WL$EncryptedCache$ERROR_CREDENTIALS_MISMATCH,487ERROR_EOC_CLOSED: typeof WL$EncryptedCache$ERROR_EOC_CLOSED,488ERROR_EOC_DELETED: typeof WL$EncryptedCache$ERROR_EOC_DELETED,489ERROR_EOC_TO_BE_DELETED: typeof WL$EncryptedCache$ERROR_EOC_TO_BE_DELETED,490ERROR_INVALID_PARAMETER: typeof WL$EncryptedCache$ERROR_INVALID_PARAMETER,491ERROR_KEY_CREATION_IN_PROGRESS: typeof WL$EncryptedCache$ERROR_KEY_CREATION_IN_PROGRESS,492ERROR_LOCAL_STORAGE_NOT_SUPPORTED: typeof WL$EncryptedCache$ERROR_LOCAL_STORAGE_NOT_SUPPORTED,493ERROR_MIGRATION: typeof WL$EncryptedCache$ERROR_MIGRATION,494ERROR_NO_EOC: typeof WL$EncryptedCache$ERROR_NO_EOC,495ERROR_NO_SUCH_KEY: typeof WL$EncryptedCache$ERROR_NO_SUCH_KEY,496ERROR_SECURE_RANDOM_GENERATOR_UNAVAILABLE: typeof WL$EncryptedCache$ERROR_SECURE_RANDOM_GENERATOR_UNAVAILABLE,497ERROR_UNKNOWN: typeof WL$EncryptedCache$ERROR_UNKNOWN,498ERROR_UNSAFE_CREDENTIALS: typeof WL$EncryptedCache$ERROR_UNSAFE_CREDENTIALS,499 500 501 502 }503declare var WL$EncryptedCache$OK: number;504declare var WL$EncryptedCache$ERROR_COULD_NOT_GENERATE_KEY: number;505declare var WL$EncryptedCache$ERROR_CREDENTIALS_MISMATCH: number;506declare var WL$EncryptedCache$ERROR_EOC_CLOSED: number;507declare var WL$EncryptedCache$ERROR_EOC_DELETED: number;508declare var WL$EncryptedCache$ERROR_EOC_TO_BE_DELETED: number;509declare var WL$EncryptedCache$ERROR_INVALID_PARAMETER: number;510declare var WL$EncryptedCache$ERROR_KEY_CREATION_IN_PROGRESS: number;511declare var WL$EncryptedCache$ERROR_LOCAL_STORAGE_NOT_SUPPORTED: number;512declare var WL$EncryptedCache$ERROR_MIGRATION: number;513declare var WL$EncryptedCache$ERROR_NO_EOC: number;514declare var WL$EncryptedCache$ERROR_NO_SUCH_KEY: number;515declare var WL$EncryptedCache$ERROR_SECURE_RANDOM_GENERATOR_UNAVAILABLE: number;516declare var WL$EncryptedCache$ERROR_UNKNOWN: number;517declare var WL$EncryptedCache$ERROR_UNSAFE_CREDENTIALS: number;518/โ**519 * See above statuses for possible values520 */โ521declare interface WL$EncryptedCache$StatusHandler {522(status: number): void523} 524declare function WL$EncryptedCache$close(525successHandler: WL$EncryptedCache$StatusHandler,526failureHandler: WL$EncryptedCache$StatusHandler): void527declare function WL$EncryptedCache$destroy(528successHandler: WL$EncryptedCache$StatusHandler,529failureHandler: WL$EncryptedCache$StatusHandler): void530declare function WL$EncryptedCache$open(531credentials: string,532createIfNone: boolean,533successHandler: WL$EncryptedCache$StatusHandler,534failureHandler: WL$EncryptedCache$StatusHandler): void535declare function WL$EncryptedCache$read(536key: string,537successHandler: WL$EncryptedCache$StatusHandler,538failureHandler: WL$EncryptedCache$StatusHandler): void539declare function WL$EncryptedCache$remove(540key: string,541successHandler: WL$EncryptedCache$StatusHandler,542failureHandler: WL$EncryptedCache$StatusHandler): void543declare function WL$EncryptedCache$write(544key: string,545value: string,546successHandler: WL$EncryptedCache$StatusHandler,547failureHandler: WL$EncryptedCache$StatusHandler): void548 declare var npm$namespace$WL$Geo: {549 getDistanceBetweenCoordinates: typeof WL$Geo$getDistanceBetweenCoordinates,550getDistanceToCircle: typeof WL$Geo$getDistanceToCircle,551getDistanceToPolygon: typeof WL$Geo$getDistanceToPolygon,552isInsideCircle: typeof WL$Geo$isInsideCircle,553isInsidePolygon: typeof WL$Geo$isInsidePolygon,554isOutsideCircle: typeof WL$Geo$isOutsideCircle,555isOutsidePolygon: typeof WL$Geo$isOutsidePolygon,556 557 558 559 560 }561declare interface WL$Geo$Coordinate {562latitute: number,563longitude: number564} 565declare type WL$Geo$Circle = {566radius: number567} & WL$Geo$Coordinate568declare interface WL$Geo$DistanceOptions {569bufferZoneWidth: number570} 571declare interface WL$Geo$InsideOutsideOptions {572/โ**573 * confidenceLevel can be 'low', 'medium', 'high'574 */โ575confidenceLevel: string576} 577declare function WL$Geo$getDistanceBetweenCoordinates(coordinate1: WL$Geo$Coordinate, coordinate2: WL$Geo$Coordinate): number578declare function WL$Geo$getDistanceToCircle(579coordinate: WL$Geo$Coordinate,580circle: WL$Geo$Circle,581options: WL$Geo$DistanceOptions): number582declare function WL$Geo$getDistanceToPolygon(583coordinate: WL$Geo$Coordinate,584polygon: WL$Geo$Coordinate[],585options: WL$Geo$DistanceOptions): number586declare function WL$Geo$isInsideCircle(587coordinate: WL$Geo$Coordinate,588circle: WL$Geo$Circle,589options: WL$Geo$InsideOutsideOptions): boolean590declare function WL$Geo$isInsidePolygon(591coordinate: WL$Geo$Coordinate,592polygon: WL$Geo$Coordinate[],593options: WL$Geo$InsideOutsideOptions): boolean594declare function WL$Geo$isOutsideCircle(595coordinate: WL$Geo$Coordinate,596circle: WL$Geo$Circle,597options: WL$Geo$InsideOutsideOptions): boolean598declare function WL$Geo$isOutsidePolygon(599coordinate: WL$Geo$Coordinate,600polygon: WL$Geo$Coordinate[],601options: WL$Geo$InsideOutsideOptions): boolean602declare class WL$Item {603setEnabled(isEnable: string): void;604setImagePath(imagePath: string): void;605setTitle(title: string): void606}607 declare var npm$namespace$WL$JSONStore: {608 changePassword: typeof WL$JSONStore$changePassword,609clearPassword: typeof WL$JSONStore$clearPassword,610closeAll: typeof WL$JSONStore$closeAll,611commitTransaction: typeof WL$JSONStore$commitTransaction,612destroy: typeof WL$JSONStore$destroy,613documentify: typeof WL$JSONStore$documentify,614fileInfo: typeof WL$JSONStore$fileInfo,615get: typeof WL$JSONStore$get,616getErrorMessage: typeof WL$JSONStore$getErrorMessage,617init: typeof WL$JSONStore$init,618initCollection: typeof WL$JSONStore$initCollection,619QueryPart: typeof WL$JSONStore$QueryPart,620rollbackTransaction: typeof WL$JSONStore$rollbackTransaction,621startTransaction: typeof WL$JSONStore$startTransaction,622usePassword: typeof WL$JSONStore$usePassword,623 624 625 JSONStoreInstance: typeof WL$JSONStore$JSONStoreInstance,626QueryPartObj: typeof WL$JSONStore$QueryPartObj,627 628 }629/โ**630 * Changes the password for the internal storage. You must have an initialized collection before calling WL.JSONStore.changePassword.631 */โ632declare function WL$JSONStore$changePassword(633oldPassword: string,634newPassword: string,635username: string,636options: WL$Options): JQueryDeferred<any>637/โ**638 * @deprecated since version 5.0.6, it is no longer needed if you use WL.JSONStore.init639 */โ640declare function WL$JSONStore$clearPassword(): boolean641/โ**642 * Locks access to all the collections until WL.JSONStore.init is called.643 */โ644declare function WL$JSONStore$closeAll(options?: WL$Options): JQueryDeferred<any>645/โ**646 * Commit a transaction.647 */โ648declare function WL$JSONStore$commitTransaction(): JQueryDeferred<number>649/โ**650 * Completely wipes data for all users, destroys the internal storage, and clears security artifacts.651 * @parameters options is652 * @deprecated653 */โ654declare function WL$JSONStore$destroy(username: string, options?: WL$Options): JQueryDeferred<number>655/โ**656 * @deprecated since version 6.2.0.657 */โ658declare function WL$JSONStore$documentify(id: number, data: any): any659/โ**660 * Returns information about the file that is used to persist data in the store. The following key value pairs are returned:661 * name - name of the store662 * size - the total size, in bytes, of the store663 * isEncrypted - boolean that is true when encrypted and false otherwise.664 */โ665declare function WL$JSONStore$fileInfo(): JQueryDeferred<any>666/โ**667 * Provides an accessor to the collection if the collection exists, otherwise it returns undefined.668 */โ669declare function WL$JSONStore$get(collectionName: string): WL$JSONStore$JSONStoreInstance670/โ**671 * Returns the message that is associated with a JSONStore error code.672 */โ673declare function WL$JSONStore$getErrorMessage(errorCode: number): string674declare interface WL$JSONStore$InitOptions {675username?: string,676password?: string,677clear?: boolean,678localKeyGen?: boolean,679analytics?: boolean680} 681declare function WL$JSONStore$init(collections: any, options?: WL$JSONStore$InitOptions): JQueryDeferred<any>682/โ**683 * @deprecated since version 5.0.6, it is no longer needed if you use WL.JSONStore.init684 */โ685declare function WL$JSONStore$initCollection(686name: string,687searchFields: any,688options?: WL$JSONStore$InitOptions): WL$JSONStore$JSONStoreInstance689/โ**690 * Creates a query for advanced find. See WL.JSONStore.QueryPart for more information.691 */โ692declare function WL$JSONStore$QueryPart(): WL$JSONStore$QueryPartObj693/โ**694 * Roll back a transaction695 */โ696declare function WL$JSONStore$rollbackTransaction(): JQueryDeferred<number>697/โ**698 * Initiates a transaction699 */โ700declare function WL$JSONStore$startTransaction(): JQueryDeferred<number>701/โ**702 * Sets the password that is used to generate keys to encrypt data that is stored locally on the device.703 * @deprecated since version 5.0.6, it is no longer needed if you use WL.JSONStore.init704 */โ705declare function WL$JSONStore$usePassword(pwd: string): boolean706declare type WL$JSONStore$AddOptions = {707additionalSearchFields?: any,708markDirty?: boolean,709/โ**710 * @deprecated711 */โ712push?: boolean713} & WL$Options714declare type WL$JSONStore$BasicFindOptions = {715filter?: string[],716sort?: string[]717} & WL$Options718declare type WL$JSONStore$AdvancedFindOptions = {719limit?: number,720offset?: number721} & WL$JSONStore$BasicFindOptions722declare type WL$JSONStore$FindOptions = {723exact?: boolean,724limit?: number,725offset?: number726} & WL$JSONStore$BasicFindOptions727declare type WL$JSONStore$EraseOptions = {728push?: boolean729} & WL$Options730declare type WL$JSONStore$RefreshOptions = {731push: boolean732} & WL$Options733declare type WL$JSONStore$ChangeOptions = {734addNew?: boolean,735markDirty?: boolean,736replaceCriteria?: string[]737} & WL$Options738declare type WL$JSONStore$RemoveOptions = {739markDirty?: boolean,740/โ**741 * @deprecated742 */โ743push?: boolean,744exact?: boolean745} & WL$Options746declare type WL$JSONStore$ReplaceOptions = {747markDirty?: boolean,748/โ**749 * @deprecated750 */โ751push?: boolean752} & WL$Options753declare type WL$JSONStore$StoreOptions = {754additionalSearchFields?: Object,755push?: boolean756} & WL$Options757declare class WL$JSONStore$JSONStoreInstance {758add(data: any, options?: WL$JSONStore$AddOptions): JQueryDeferred<any>;759advancedFind(query: any[], options?: WL$JSONStore$AdvancedFindOptions): JQueryDeferred<any>;760change(data: any, options?: WL$JSONStore$ChangeOptions): JQueryDeferred<any>;761clear(options?: WL$Options): JQueryDeferred<any>;762count(query?: any, options?: WL$Options): JQueryDeferred<any>;763countAllDirty(options?: WL$Options): JQueryDeferred<any>;764enhance(name: string, fn: Function): number;765/โ**766 * @deprecated since version 5.0.6, it is no longer needed if you use WL.JSONStore.JSONStoreInstance.remove with {push: false}.767 */โ768erase(doc: any, options?: WL$JSONStore$EraseOptions): void;769find(770query: Object | Object[],771options?: WL$JSONStore$FindOptions): JQueryDeferred<any>;772findAll(options?: WL$JSONStore$BasicFindOptions): JQueryDeferred<any>;773findById(options?: WL$Options): JQueryDeferred<any>;774isDirty(doc: any, options?: WL$Options): JQueryDeferred<boolean>;775/โ**776 * @deprecated since version 6.2.0.777 */โ778load(options?: WL$Options): JQueryDeferred<any>;779markClean(docs: any[], options?: WL$Options): JQueryDeferred<any>;780/โ**781 * @deprecated since version 6.2.0.782 */โ783push(options?: any): JQueryDeferred<any>;784/โ**785 * @deprecated since version 5.0.6, it is no longer needed if you use WL.JSONStore.JSONStoreInstance.push.786 */โ787pushSelected(doc: any, options?: WL$Options): JQueryDeferred<any>;788/โ**789 * @deprecated since version 5.0.6. It is no longer needed if you use WL.JSONStore.JSONStoreInstance.replace with {push: false}.790 */โ791refresh(doc: any, options?: WL$JSONStore$RefreshOptions): JQueryDeferred<any>;792remove(doc: any, options?: WL$JSONStore$RemoveOptions): JQueryDeferred<any>;793/โ**794 * Deletes all the documents that are stored inside a collection.795 */โ796removeCollection(options?: WL$Options): JQueryDeferred<any>;797replace(798doc: Object | Object[],799options?: WL$JSONStore$ReplaceOptions): JQueryDeferred<any>;800/โ**801 * Writes data to a collection.802 * @deprecated since version 5.0.6, it is no longer needed if you use WL.JSONStore.JSONStoreInstance.add with {push: false}.803 */โ804store(data: Object | Object[], options?: WL$JSONStore$StoreOptions): void;805toString(limit?: number, offset?: number): JQueryDeferred<number>806}807declare class WL$JSONStore$QueryPartObj {808/โ**809 * Add a between clause to a query for advanced find.810 */โ811between(searchField: any, value: any): any[];812/โ**813 * Add an equal to clause to a query for advanced find.814 */โ815equal(searchField: any, value: any): any[];816/โ**817 * Add a greater or equal thanclause to a query for advanced find.818 */โ819greaterOrEqualThan(searchField: any, value: any): any[];820/โ**821 * Add a greater than clause to a query for advanced find.822 */โ823greaterThan(searchField: any, value: any): any[];824/โ**825 * Add an in clause to a query for advanced find.826 */โ827inside(searchField: any, value: any): any[];828/โ**829 * Add a left clause to a query for advanced find.830 */โ831leftLike(searchField: any, value: any): any[];832/โ**833 * Add a less or equal than clause to a query for advanced find.834 */โ835lessOrEqualThan(searchField: any, value: any): any[];836/โ**837 * Add a less than clause to a query for advanced find.838 */โ839lessThan(searchField: any, value: any): any[];840/โ**841 * Add a like clause to a query for advanced find.842 */โ843like(searchField: any, value: any): any[];844/โ**845 * Add a not between clause to a query for advanced find.846 */โ847notBetween(searchField: any, value: any): any[];848/โ**849 * Add a not equal to clause to a query for advanced find.850 */โ851notEqual(searchField: any, value: any): any[];852/โ**853 * Add a not in clause to a query for advanced find.854 */โ855notInside(searchField: any, value: any): any[];856/โ**857 * Add a not left clause to a query for advanced find.858 */โ859notLeftLike(searchField: any, value: any): any[];860/โ**861 * Add a not like clause to a query for advanced find.862 */โ863notLike(searchField: any, value: any): any[];864/โ**865 * Add a not right clause to a query for advanced find.866 */โ867notRightLike(searchField: any, value: any): any[];868/โ**869 * Add a right clause to a query for advanced find.870 */โ871rightLike(searchField: any, value: any): any[]872}873 declare var npm$namespace$WL$LocalStorage: {874 getValue: typeof WL$LocalStorage$getValue,875setValue: typeof WL$LocalStorage$setValue,876clear: typeof WL$LocalStorage$clear,877clearAll: typeof WL$LocalStorage$clearAll,878 879 880 881 882 }883declare function WL$LocalStorage$getValue(key: string): string884declare function WL$LocalStorage$setValue(key: string, value: string): void885declare function WL$LocalStorage$clear(key: string): void886declare function WL$LocalStorage$clearAll(): void887declare var WL$Logger: WL$LoggerObject;888declare interface WL$LoggerCallback {889(message: string | string[], level: string, package: string): void890} 891declare interface WL$Tag {892level?: boolean,893tag?: boolean894} 895declare interface WL$Filter {896[name: string]: string897} 898declare interface WL$LoggerOptions {899stringify?: boolean,900pretty?: boolean,901stacktrace?: boolean,902callback?: WL$LoggerCallback,903pkg?: string,904tag?: WL$Tag,905/โ**906 * @deprecated since version 6.2. use filters instead.907 */โ908whitelist?: string[],909/โ**910 * @deprecated since version 6.2. use filters instead.911 */โ912blacklist?: string[],913filters?: WL$Filter,914capture?: boolean,915autoSendLogs?: boolean,916maxFileSize?: number,917level?: string[] | string | number918} 919declare interface WL$NativeOptions {920maxFileSize?: number,921level?: string,922capture?: boolean,923autoSendLogs?: boolean,924autoUpdateConfig?: boolean,925filters?: WL$Filter926} 927/โ**928 * Artifact to allow chaining of Logger class as: WL.Logger.ctx({pkg: 'something'}).debug('Hello world');929 */โ930declare class WL$LoggerObject {931/โ**932 * Configures the logger globally.933 */โ934config(options?: WL$LoggerOptions): WL$LoggerObject;935/โ**936 * Creates an instance of a logger with its own context (also called status or state).937 */โ938create(options?: WL$LoggerOptions): WL$LogInstance;939/โ**940 * Updates the state (also called context or status) of the logger.941 */โ942ctx(options?: WL$LoggerOptions): WL$LoggerObject;943/โ**944 * Prints arguments to the console.945 */โ946debug(message: string): void;947/โ**948 * Prints arguments to the console.949 */โ950error(message: string): void;951/โ**952 * Prints arguments to the console.953 */โ954fatal(message: string): void;955/โ**956 * Prints arguments to the console.957 */โ958info(message: string): void;959/โ**960 * Prints arguments to the console.961 */โ962log(message: string): void;963/โ**964 * Attach additional metadata to the next logger instance call.965 */โ966metadata(options: any): WL$LoggerObject;967/โ**968 * @deprecated since version 6.2. WL.Logger.on is now a no-op. WL.Logger is always enabled. Use WL.Logger.config with {'level': 'FATAL'} to reduce verbosity.969 */โ970off(): WL$LoggerObject;971/โ**972 * @deprecated since version 6.2. WL.Logger.on is now a no-op. WL.Logger is always enabled. Use WL.Logger.config with {'level': 'FATAL'} to reduce verbosity.973 */โ974on(options: any): WL$LoggerObject;975/โ**976 * Send any logs collected up to this point to the IBMรยฎ Worklightรยฎ server.977 */โ978send(): JQueryDeferred<any>;979/โ**980 * @deprecated since version 6.2. Use WL.Logger.config instead. Sets options in native application layer (iOS and Android only)981 */โ982setNativeOptions(options?: WL$NativeOptions): void;983/โ**984 * Shows the status (current configuration) of the logger.985 */โ986status(): JQueryDeferred<any>;987/โ**988 * Prints arguments to the console.989 */โ990trace(message: string): void;991/โ**992 * Retrieves and applies any matching configuration profile from the IBMรยฎ Worklightรยฎ Server.993 */โ994updateConfigFromServer(): JQueryDeferred<any>;995/โ**996 * Prints arguments to the console.997 */โ998warn(message: string): void999}1000/โ**1001 * Class which defines instances created via: WL.Logger.create({pkg: 'something'});1002 * Actual definition is outside of WL namespace. For easier d.ts file compiling it is here1003 */โ1004declare class WL$LogInstance {1005debug(message: string): void;1006error(message: string): void;1007fatal(message: string): void;1008info(message: string): void;1009trace(message: string): void;1010warn(message: string): void1011}1012 declare var npm$namespace$WL$NativePage: {1013 show: typeof WL$NativePage$show,1014 1015 1016 1017 1018 }1019declare function WL$NativePage$show(className: string, callback: (data: any) => void, data: any): void1020 declare var npm$namespace$WL$SecurityUtils: {1021 base64Decode: typeof WL$SecurityUtils$base64Decode,1022base64Encode: typeof WL$SecurityUtils$base64Encode,1023decrypt: typeof WL$SecurityUtils$decrypt,1024encrypt: typeof WL$SecurityUtils$encrypt,1025keygen: typeof WL$SecurityUtils$keygen,1026localRandomString: typeof WL$SecurityUtils$localRandomString,1027remoteRandomString: typeof WL$SecurityUtils$remoteRandomString,1028 1029 1030 1031 1032 }1033declare interface WL$SecurityUtils$DecryptOptions {1034key: string,1035ct: string,1036lv: string,1037src: string,1038v: string1039} 1040declare interface WL$SecurityUtils$EncryptOptions {1041key: string,1042text: string1043} 1044declare interface WL$SecurityUtils$KeygenOptions {1045password: string,1046salt: string,1047iterations: number1048} 1049declare function WL$SecurityUtils$base64Decode(input: string): JQueryDeferred<string>1050declare function WL$SecurityUtils$base64Encode(input: string): JQueryDeferred<string>1051declare function WL$SecurityUtils$decrypt(options: WL$SecurityUtils$DecryptOptions): JQueryDeferred<string>1052declare function WL$SecurityUtils$encrypt(options: WL$SecurityUtils$EncryptOptions): JQueryDeferred<string>1053declare function WL$SecurityUtils$keygen(options: WL$SecurityUtils$KeygenOptions): JQueryDeferred<string>1054declare function WL$SecurityUtils$localRandomString(bytes?: number): JQueryDeferred<string>1055declare function WL$SecurityUtils$remoteRandomString(bytes?: number): JQueryDeferred<string>1056 declare var npm$namespace$WL$SimpleDialog: {1057 show: typeof WL$SimpleDialog$show,1058 1059 1060 1061 1062 }1063declare interface WL$SimpleDialog$Button {1064text: string,1065handler?: Function1066} 1067declare interface WL$SimpleDialog$Options {1068title: string,1069text: string1070} 1071declare function WL$SimpleDialog$show(1072title: string,1073text: string,1074buttons: WL$SimpleDialog$Button[],1075options?: WL$SimpleDialog$Options): void1076 declare var npm$namespace$WL$TabBar: {1077 addItem: typeof WL$TabBar$addItem,1078init: typeof WL$TabBar$init,1079isVisible: typeof WL$TabBar$isVisible,1080RemoveAllItems: typeof WL$TabBar$RemoveAllItems,1081setEnabled: typeof WL$TabBar$setEnabled,1082setParentDivId: typeof WL$TabBar$setParentDivId,1083setSelectedItem: typeof WL$TabBar$setSelectedItem,1084setVisible: typeof WL$TabBar$setVisible,1085 1086 1087 1088 1089 }1090declare interface WL$TabBar$ItemOptions {1091image: string,1092badge?: string,1093imageSelected?: string1094} 1095declare function WL$TabBar$addItem(1096id: string,1097callback: Function,1098title: string,1099options: WL$TabBar$ItemOptions): WL$TabBarItem1100declare function WL$TabBar$init(): void1101declare function WL$TabBar$isVisible(): boolean1102declare function WL$TabBar$RemoveAllItems(): void1103declare function WL$TabBar$setEnabled(isEnabled: boolean): void1104/โ**1105 * @deprecated1106 */โ1107declare function WL$TabBar$setParentDivId(parentId: string): void1108declare function WL$TabBar$setSelectedItem(id: string): void1109declare function WL$TabBar$setVisible(isVisible: boolean): void1110declare class WL$TabBarItem {1111setEnabled(isEnabled: boolean): void;1112updateBadge(badge?: string): void1113}1114 declare var npm$namespace$WL$Toast: {1115 show: typeof WL$Toast$show,1116 1117 1118 1119 1120 }1121declare function WL$Toast$show(): void1122 declare var npm$namespace$WL$Trusteer: {1123 getRiskAssessment: typeof WL$Trusteer$getRiskAssessment,1124 1125 1126 1127 1128 }1129declare interface WL$Trusteer$AssesmentRisk {1130value: number,1131additionalData: string,1132lastCalculated: number,1133name: string1134} 1135declare interface WL$Trusteer$AssetmentRisks {1136device_key: string,1137"malware.any"?: WL$Trusteer$AssesmentRisk,1138"network.wifi"?: WL$Trusteer$AssesmentRisk,1139"os.rooted"?: WL$Trusteer$AssesmentRisk,1140"os.rooted.native"?: WL$Trusteer$AssesmentRisk,1141"os.rooted.hiders"?: WL$Trusteer$AssesmentRisk,1142"os.ver_up_to_date"?: WL$Trusteer$AssesmentRisk,1143"plat.android.dumpsys"?: WL$Trusteer$AssesmentRisk,1144"plat.android.apprestrict"?: WL$Trusteer$AssesmentRisk,1145"total.risk.generic"?: WL$Trusteer$AssesmentRisk,1146"tas.config_update"?: WL$Trusteer$AssesmentRisk1147} 1148declare function WL$Trusteer$getRiskAssessment(1149onSuccess: WL$ResponseHandler<WL$Response>,1150onFailure: WL$ResponseHandler<WL$FailureResponse>): WL$Trusteer$AssetmentRisks1151 declare var npm$namespace$WL$UserAuth: {1152 deleteCertificate: typeof WL$UserAuth$deleteCertificate,1153 1154 1155 1156 1157 }1158declare function WL$UserAuth$deleteCertificate(provisioningEntity?: string): JQueryDeferred<void>1159declare var WL$ClientMessages: {1160[name: string]: string1161};1162 declare var WLAuthorizationManager: typeof npm$namespace$WLAuthorizationManager;1163 declare var npm$namespace$WLAuthorizationManager: {1164 addCachedAuthorizationHeader: typeof WLAuthorizationManager$addCachedAuthorizationHeader,1165getAppIdentity: typeof WLAuthorizationManager$getAppIdentity,1166getAuthorizationScope: typeof WLAuthorizationManager$getAuthorizationScope,1167getCachedAuthorizationHeader: typeof WLAuthorizationManager$getCachedAuthorizationHeader,1168getDeviceIdentity: typeof WLAuthorizationManager$getDeviceIdentity,1169getUserIdentity: typeof WLAuthorizationManager$getUserIdentity,1170isAuthorizationRequired: typeof WLAuthorizationManager$isAuthorizationRequired,1171obtainAuthorizationHeader: typeof WLAuthorizationManager$obtainAuthorizationHeader,1172setAuthorizationPersistencePolicy: typeof WLAuthorizationManager$setAuthorizationPersistencePolicy,1173 ALWAYS: typeof WLAuthorizationManager$ALWAYS,1174NEVER: typeof WLAuthorizationManager$NEVER,1175 1176 1177 1178 }1179/โ**1180 * AuthorizationPersistencePolicy possible values1181 */โ1182declare var WLAuthorizationManager$ALWAYS: string;1183declare var WLAuthorizationManager$NEVER: string;1184declare interface WLAuthorizationManager$RequestObject {1185setRequestHeader: (header: string, value: string) => void1186} 1187declare function WLAuthorizationManager$addCachedAuthorizationHeader(1188request: WLAuthorizationManager$RequestObject): JQueryDeferred<WLAuthorizationManager$RequestObject>1189declare function WLAuthorizationManager$getAppIdentity(): JQueryDeferred<any>1190declare function WLAuthorizationManager$getAuthorizationScope(responseAuthenticationHeader: string): string1191/โ**1192 * TODO: Set Promise types. Should be something like: JQueryDeferred<data, error>()1193 */โ1194declare function WLAuthorizationManager$getCachedAuthorizationHeader(): JQueryDeferred<any>1195/โ**1196 * TODO: Set Promise types. Should be something like: JQueryDeferred<data, error>()1197 */โ1198declare function WLAuthorizationManager$getDeviceIdentity(): JQueryDeferred<any>1199/โ**1200 * TODO: Set Promise types. Should be something like: JQueryDeferred<data, error>()1201 */โ1202declare function WLAuthorizationManager$getUserIdentity(): JQueryDeferred<any>1203declare function WLAuthorizationManager$isAuthorizationRequired(responseStatus: number, responseAuthenticationHeader: string): boolean1204/โ**1205 * TODO: Set Promise types. Should be something like: JQueryDeferred<header, error>()1206 */โ1207declare function WLAuthorizationManager$obtainAuthorizationHeader(scope: string): JQueryDeferred<any>1208/โ**1209 * See WLAuthorizarionManager.NEVER and WLAuthorizarionManager.ALWAYS1210 */โ1211declare function WLAuthorizationManager$setAuthorizationPersistencePolicy(authorizationPersistencePolicy: string): void1212 declare class WLResourceRequest {1213constructor(url: string, method: string, timeout?: number): this;1214addHeader(name: string, value: string | number | boolean): void;1215getHeader(name: string): string;1216getHeaderNames(): string[];1217getHeaders(name: string): string[];1218getMethod(): string;1219getQueryParameters(): any;1220getTimeout(): number;1221getUrl(): string;1222send(content?: any): JQueryDeferred<any>;1223sendFormParameters(json: Object): JQueryDeferred<any>;1224setHeader(name: string, value: string | number | boolean): void;1225setHeaders(requestHeaders?: {1226[name: string]: string | string[]1227}): void;1228setQueryParameter(name: string, value: string | number | boolean | Object): void;1229setQueryParameters(parameters?: {1230[name: string]: string | number | boolean | Object1231}): void;1232setTimeout(requestTimeout: number): void;1233static GET: string;1234static POST: string;1235static PUT: string;1236static DELETE: string;1237static HEAD: string;1238static OPTIONS: string;1239static TRACE: string;1240static CONNECT: string1241}...
RestApi.js
Source:RestApi.js
1Class.define('app.views.medications.RestApi', 'tm.jquery.Object', {2 statics: {3 SERVLET_PATH_MEDICATION_DATA: '/โmedicationdata',4 SERVLET_PATH_FIND_MEDICATIONS: '/โfindmedications',5 SERVLET_PATH_FIND_MEDICATION_PRODUCTS: '/โfindMedicationProducts',6 SERVLET_PATH_FIND_SIMILAR_MEDICATIONS: '/โfindSimilarMedications',7 SERVLET_PATH_SAVE_MEDICATIONS_ORDER: '/โsaveMedicationsOrder',8 SERVLET_PATH_MODIFY_THERAPY: '/โmodifyTherapy',9 SERVLET_PATH_GET_THERAPY_CHANGE_TYPE: '/โgetTherapyChangeTypes',10 SERVLET_PATH_CREATE_ADMINISTRATION_TASK: '/โcreateAdministrationTask',11 SERVLET_PATH_CONFIRM_THERAPY_ADMINISTRATION: '/โconfirmTherapyAdministration',12 SERVLET_PATH_GET_MEDICATION_DATA_FOR_MULTIPLE_IDS: '/โmedicationDataForMultipleIds',13 SERVLET_PATH_RESCHEDULE_TASKS: '/โrescheduleTasks',14 SERVLET_PATH_RESCHEDULE_TASK: '/โrescheduleTask',15 SERVLET_PATH_GET_THERAPY_AUDIT_TRAIL: '/โgetTherapyAuditTrail',16 SERVLET_PATH_SET_ADMINISTRATION_TITRATION_DOSE: '/โsetAdministrationTitratedDose',17 SERVLET_PATH_GET_THERAPY: '/โgetTherapy',18 SERVLET_PATH_GET_UNLICENSED_MEDICATION_WARNING: '/โgetUnlicensedMedicationWarning',19 SERVLET_PATH_SET_ADMINISTRATION_DOCTORS_COMMENT: '/โsetAdministrationDoctorsComment',20 SERVLET_PATH_GET_TEMPLATES: '/โgetTherapyTemplates',21 SERVLET_PATH_GET_MEDICATION_ID_FOR_BARCODE: '/โgetMedicationIdForBarcode',22 SERVLET_PATH_GET_ADMINISTRATION_TASK_FOR_BARCODE: '/โgetAdministrationTaskForBarcode',23 SERVLET_PATH_GET_ORIGINAL_THERAPY_ID: '/โgetOriginalTherapyId'24 },25 view: null,26 /โ** constructor */โ27 Constructor: function(config)28 {29 this.callSuper(config);30 },31 /โ**32 * Helper with conditional execution for less code.33 * @param {Boolean} prevent34 * @private35 */โ36 _showLoaderMask: function(prevent)37 {38 if (!prevent)39 {40 this.getView().showLoaderMask();41 }42 },43 /โ**44 * Helper with conditional execution for less code.45 * @param {Boolean} prevent46 * @private47 */โ48 _hideLoaderMask: function(prevent)49 {50 if (!prevent)51 {52 this.getView().hideLoaderMask();53 }54 },55 /โ**56 * @param medicationId57 * @param {Boolean} [preventMask=false]58 * @returns {tm.jquery.Promise}59 */โ60 loadMedicationData: function(medicationId, preventMask)61 {62 var view = this.getView();63 var self = this;64 var medicationDataUrl = view.getViewModuleUrl() + app.views.medications.RestApi.SERVLET_PATH_MEDICATION_DATA;65 var params = {medicationId: medicationId};66 var deferred = tm.jquery.Deferred.create();67 this._showLoaderMask(preventMask);68 view.loadViewData(medicationDataUrl, params, null, function(data)69 {70 self._hideLoaderMask(preventMask);71 var medicationData = !tm.jquery.Utils.isEmpty(data) ?72 app.views.medications.common.dto.MedicationData.fromJson(data) : null;73 deferred.resolve(medicationData);74 },75 function()76 {77 self._hideLoaderMask(preventMask);78 deferred.reject();79 });80 return deferred.promise();81 },82 /โ**83 * @param {Array<String>} ids84 * @param {Boolean} [preventMask=false]85 * @returns {tm.jquery.Deferred}86 */โ87 loadMedicationDataForMultipleIds: function(ids, preventMask)88 {89 var view = this.getView();90 var self = this;91 var deferred = new tm.jquery.Deferred;92 var restUrl = view.getViewModuleUrl() + app.views.medications.RestApi.SERVLET_PATH_GET_MEDICATION_DATA_FOR_MULTIPLE_IDS;93 var params = {medicationIds: JSON.stringify(ids)};94 this._showLoaderMask(preventMask);95 view.loadViewData(restUrl, params, null, function(data)96 {97 self._hideLoaderMask(preventMask);98 if (!tm.jquery.Utils.isArray(data)) data = [data];99 var medicationData = data.map(function(item)100 {101 return app.views.medications.common.dto.MedicationData.fromJson(item);102 });103 deferred.resolve(medicationData);104 },105 function()106 {107 self._hideLoaderMask(preventMask);108 deferred.reject();109 });110 return deferred;111 },112 /โ**113 * @param {String} searchQuery114 * @param {Array<String>|null} [additionalFilters=null]115 * @param {Boolean} [preventMask=false]116 * @returns {tm.jquery.Promise}117 */โ118 loadMedications: function(searchQuery, additionalFilters, preventMask)119 {120 var view = this.getView();121 var self = this;122 var url = view.getViewModuleUrl() + app.views.medications.RestApi.SERVLET_PATH_FIND_MEDICATIONS;123 var params = {124 searchQuery: searchQuery,125 careProviderId: view.getCareProviderId()126 };127 if (additionalFilters)128 {129 params.additionalFilters = JSON.stringify(additionalFilters);130 }131 var deferred = tm.jquery.Deferred.create();132 this._showLoaderMask(preventMask);133 view.loadViewData(url, params, null, function(data)134 {135 self._hideLoaderMask(preventMask);136 deferred.resolve(data);137 },138 function()139 {140 self._hideLoaderMask(preventMask);141 deferred.reject();142 });143 return deferred.promise();144 },145 /โ**146 * @param {String} medicationId147 * @param {Array<Object>} routes148 * @param {String} routes.id149 * @param {Boolean} [preventMask=false]150 * @returns {tm.jquery.Promise}151 */โ152 loadSimilarMedications: function(medicationId, routes, preventMask) /โ/โSimilar medications have same generic and route153 {154 var view = this.getView();155 var self = this;156 var url = view.getViewModuleUrl() + app.views.medications.RestApi.SERVLET_PATH_FIND_SIMILAR_MEDICATIONS;157 var routeIds = routes ? routes.map(function(route)158 {159 return route.id;160 }) : null;161 var params = {162 medicationId: medicationId,163 routeIds: routeIds164 };165 var deferred = tm.jquery.Deferred.create();166 this._showLoaderMask(preventMask);167 view.loadViewData(url, params, null, function(data)168 {169 self._hideLoaderMask(preventMask);170 deferred.resolve(data);171 },172 function()173 {174 self._hideLoaderMask(preventMask);175 deferred.reject();176 });177 return deferred.promise();178 },179 /โ**180 * @param {string} medicationId181 * @param {Array<number>} [routes=null]182 * @param {boolean} [preventMask=false]183 * @returns {tm.jquery.Promise}184 */โ185 loadMedicationProducts: function(medicationId, routes, preventMask)186 {187 var view = this.getView();188 var self = this;189 var url = view.getViewModuleUrl() + app.views.medications.RestApi.SERVLET_PATH_FIND_MEDICATION_PRODUCTS;190 var routeIds = routes ? routes.map(function(route)191 {192 return route.id;193 }) : null;194 var params = {195 medicationId: medicationId,196 routeIds: routeIds197 };198 var deferred = tm.jquery.Deferred.create();199 this._showLoaderMask(preventMask);200 view.loadViewData(url, params, null, function(data)201 {202 self._hideLoaderMask(preventMask);203 data = data.map(function convert(item)204 {205 return new app.views.medications.common.dto.Medication(item);206 });207 deferred.resolve(data);208 },209 function()210 {211 self._hideLoaderMask(preventMask);212 deferred.reject();213 });214 return deferred.promise();215 },216 /โ**217 * @param {Array<app.views.medications.common.dto.SaveMedicationOrder>} medicationOrders218 * @param {Object} prescriber219 * @param {Date|null} saveDateTime220 * @param {String|null} lastLinkName221 * @param {Boolean} preventMask222 * @returns {tm.jquery.Promise}223 */โ224 saveMedicationsOrder: function(medicationOrders, prescriber, saveDateTime, lastLinkName, preventMask)225 {226 var self = this;227 var view = this.getView();228 var viewHubNotifier = view.getHubNotifier();229 var hubAction = tm.views.medications.TherapyView.THERAPY_SAVE_HUB;230 var url = view.getViewModuleUrl() + app.views.medications.RestApi.SERVLET_PATH_SAVE_MEDICATIONS_ORDER;231 var centralCaseData = view.getCentralCaseData();232 var params = {233 patientId: view.getPatientId(),234 medicationOrders: JSON.stringify(medicationOrders),235 centralCaseId: centralCaseData ? centralCaseData.centralCaseId : null,236 hospitalizationStart: view.getHospitalizationStart(),237 careProviderId: view.getCareProviderId(),238 prescriber: JSON.stringify(prescriber),239 lastLinkName: lastLinkName,240 saveDateTime: saveDateTime ? JSON.stringify(saveDateTime) : null,241 language: view.getViewLanguage()242 };243 var deferred = tm.jquery.Deferred.create();244 this._showLoaderMask(preventMask);245 viewHubNotifier.actionStarted(hubAction);246 view.loadPostViewData(url, params, null,247 function()248 {249 self._hideLoaderMask(preventMask);250 viewHubNotifier.actionEnded(hubAction);251 deferred.resolve();252 },253 function()254 {255 self._hideLoaderMask(preventMask);256 viewHubNotifier.actionFailed(hubAction);257 deferred.reject();258 },259 true);260 return deferred.promise();261 },262 /โ**263 * @param {Boolean} preventMask264 * @returns {tm.jquery.Promise}265 */โ266 loadTherapyChangeReasonTypeMap: function(preventMask)267 {268 var self = this;269 var view = this.getView();270 var url = view.getViewModuleUrl() + app.views.medications.RestApi.SERVLET_PATH_GET_THERAPY_CHANGE_TYPE;271 var params = {272 language: view.getViewLanguage()273 };274 var deferred = tm.jquery.Deferred.create();275 this._showLoaderMask(preventMask);276 view.loadViewData(url, params, null,277 function(data)278 {279 self._hideLoaderMask(preventMask);280 if (data)281 {282 /โ/โ append suspend on admission reasons to suspend reasons so they can be used under one key in the suspend dialog283 /โ/โ then simply check if it belongs to one but not the other group284 var orderEnums = app.views.medications.TherapyEnums.actionReasonTypeEnum;285 if (data.hasOwnProperty(orderEnums.SUSPEND_ADMISSION) &&286 tm.jquery.Utils.isArray(data[orderEnums.SUSPEND_ADMISSION]))287 {288 if (!data.hasOwnProperty(orderEnums.SUSPEND))289 {290 data[orderEnums.SUSPEND] = [];291 }292 data[orderEnums.SUSPEND] = data[orderEnums.SUSPEND].concat(data[orderEnums.SUSPEND_ADMISSION]);293 }294 }295 else296 {297 data = {};298 }299 deferred.resolve(data);300 },301 function()302 {303 self._hideLoaderMask(preventMask);304 deferred.reject();305 },306 true);307 return deferred.promise();308 },309 /โ**310 * @param {app.views.medications.common.dto.Therapy} therapy311 * @param {app.views.medications.common.dto.TherapyChangeReason} changeReason312 * @param {Object} prescriber313 * @param {Boolean} hasStarted314 * @param {Date} saveDateTime315 * @param {Boolean} preventMask316 * @returns {tm.jquery.Promise}317 */โ318 modifyTherapy: function(therapy, changeReason, prescriber, hasStarted, saveDateTime, preventMask)319 {320 var self = this;321 var view = this.getView();322 var viewHubNotifier = view.getHubNotifier();323 var hubAction = tm.views.medications.TherapyView.THERAPY_SAVE_HUB;324 var url = view.getViewModuleUrl() + app.views.medications.RestApi.SERVLET_PATH_MODIFY_THERAPY;325 var params = {326 patientId: view.getPatientId(),327 therapy: JSON.stringify(therapy),328 changeReason: changeReason ? JSON.stringify(changeReason) : null,329 centralCaseId: view.getCentralCaseData() ? view.getCentralCaseData().centralCaseId : null,330 careProviderId: view.getCareProviderId(),331 prescriber: JSON.stringify(prescriber),332 therapyAlreadyStarted: hasStarted === true,333 saveDateTime: saveDateTime ? JSON.stringify(saveDateTime) : null334 };335 var deferred = tm.jquery.Deferred.create();336 this._showLoaderMask(preventMask);337 viewHubNotifier.actionStarted(hubAction);338 view.loadPostViewData(url, params, null,339 function()340 {341 self._hideLoaderMask(preventMask);342 viewHubNotifier.actionEnded(hubAction);343 deferred.resolve();344 },345 function()346 {347 self._hideLoaderMask(preventMask);348 viewHubNotifier.actionFailed(hubAction);349 deferred.reject();350 },351 true);352 return deferred.promise();353 },354 /โ**355 * @param {app.views.medications.common.dto.Therapy} therapy356 * @param {Object} administration357 * @param {Boolean} requestSupply358 * @param {Boolean} preventMask359 * @returns {tm.jquery.Promise}360 */โ361 createAdministrationTask: function(therapy, administration, requestSupply, preventMask)362 {363 var self = this;364 var view = this.getView();365 var viewHubNotifier = view.getHubNotifier();366 var hubAction = tm.views.medications.TherapyView.THERAPY_CONFIRM_ADMINISTRATION_HUB;367 var url = view.getViewModuleUrl() + app.views.medications.RestApi.SERVLET_PATH_CREATE_ADMINISTRATION_TASK;368 var params = {369 therapyCompositionUid: therapy.getCompositionUid(),370 ehrOrderName: therapy.getEhrOrderName(),371 patientId: view.getPatientId(),372 administration: JSON.stringify(administration),373 requestSupply: requestSupply === true374 };375 var deferred = tm.jquery.Deferred.create();376 this._showLoaderMask(preventMask);377 viewHubNotifier.actionStarted(hubAction);378 view.loadPostViewData(url, params, null,379 function()380 {381 self._hideLoaderMask(preventMask);382 viewHubNotifier.actionEnded(hubAction);383 deferred.resolve();384 },385 function()386 {387 self._hideLoaderMask(preventMask);388 viewHubNotifier.actionFailed(hubAction);389 deferred.reject();390 },391 true);392 return deferred.promise();393 },394 /โ**395 * @param {app.views.medications.common.dto.Therapy} therapy396 * @param {Object} administration397 * @param {Boolean} editMode398 * @param {Boolean} requestSupply399 * @param {Boolean} preventMask400 * @returns {tm.jquery.Promise}401 */โ402 confirmAdministrationTask: function(therapy, administration, editMode, requestSupply, preventMask)403 {404 var self = this;405 var view = this.getView();406 var viewHubNotifier = view.getHubNotifier();407 var hubAction = tm.views.medications.TherapyView.THERAPY_CONFIRM_ADMINISTRATION_HUB;408 var url = view.getViewModuleUrl() + app.views.medications.RestApi.SERVLET_PATH_CONFIRM_THERAPY_ADMINISTRATION;409 var centralCaseData = view.getCentralCaseData();410 var params = {411 therapyCompositionUid: therapy.getCompositionUid(),412 ehrOrderName: therapy.getEhrOrderName(),413 patientId: view.getPatientId(),414 editMode: editMode,415 administration: JSON.stringify(administration),416 centralCaseId: centralCaseData ? centralCaseData.centralCaseId : null,417 careProviderId: view.getCareProviderId(),418 requestSupply: requestSupply === true419 };420 var deferred = tm.jquery.Deferred.create();421 this._showLoaderMask(preventMask);422 viewHubNotifier.actionStarted(hubAction);423 view.loadPostViewData(url, params, null,424 function()425 {426 self._hideLoaderMask(preventMask);427 viewHubNotifier.actionEnded(hubAction);428 deferred.resolve();429 },430 function()431 {432 self._hideLoaderMask(preventMask);433 viewHubNotifier.actionFailed(hubAction);434 deferred.reject();435 },436 true);437 return deferred.promise();438 },439 /โ**440 * @param {string} taskId441 * @param {Date} selectedTimestamp442 * @param {string} therapyId443 * @param {Boolean} moveSingle444 * @param {Boolean} preventMask445 * @returns {tm.jquery.Promise}446 */โ447 rescheduleTasks: function(taskId, selectedTimestamp, therapyId, moveSingle, preventMask)448 {449 var self = this;450 var deferred = tm.jquery.Deferred.create();451 var view = this.getView();452 var viewHubNotifier = this.view.getHubNotifier();453 var hubAction = tm.views.medications.TherapyView.THERAPY_MOVE_ADMINISTRATION_HUB;454 viewHubNotifier.actionStarted(hubAction);455 var params = {456 patientId: view.getPatientId(),457 taskId: taskId,458 newTime: JSON.stringify(selectedTimestamp),459 therapyId: therapyId460 };461 var url = this.view.getViewModuleUrl() + (moveSingle === true ?462 app.views.medications.RestApi.SERVLET_PATH_RESCHEDULE_TASK :463 app.views.medications.RestApi.SERVLET_PATH_RESCHEDULE_TASKS);464 this._showLoaderMask(preventMask);465 this.view.loadPostViewData(url, params, null,466 function()467 {468 self._hideLoaderMask(preventMask);469 viewHubNotifier.actionEnded(hubAction);470 deferred.resolve()471 },472 function()473 {474 self._hideLoaderMask(preventMask);475 viewHubNotifier.actionFailed(hubAction);476 deferred.reject()477 },478 true);479 return deferred.promise();480 },481 /โ**482 * @param {app.views.medications.common.dto.Therapy} therapy483 * @param {boolean} [preventMask=false]484 * @returns {tm.jquery.Deferred}485 */โ486 loadAuditTrailData: function(therapy, preventMask)487 {488 var self = this;489 var view = this.getView();490 var deferred = tm.jquery.Deferred.create();491 var auditTrailUrl =492 view.getViewModuleUrl() + app.views.medications.RestApi.SERVLET_PATH_GET_THERAPY_AUDIT_TRAIL;493 var params = {494 patientId: view.getPatientId(),495 compositionId: therapy.getCompositionUid(),496 ehrOrderName: therapy.getEhrOrderName(),497 language: view.getViewLanguage()498 };499 if (view.getPatientHeightInCm())500 {501 params.patientHeight = view.getPatientHeightInCm();502 }503 this._showLoaderMask(preventMask);504 view.loadViewData(auditTrailUrl, params, null, function(auditTrailData)505 {506 self._hideLoaderMask(preventMask);507 var therapyAuditTrail = app.views.medications.common.dto.TherapyAuditTrail.fromJson(auditTrailData);508 deferred.resolve(therapyAuditTrail);509 },510 function()511 {512 self._hideLoaderMask(preventMask);513 deferred.reject();514 });515 return deferred.promise();516 },517 /โ**518 * @param {string} latestTherapyId519 * @param {object} administration520 * @param {boolean} markGiven521 * @param {date|null} until522 * @param {boolean} [preventMask=false]523 * @returns {tm.jquery.Deferred}524 */โ525 setAdministrationTitrationDose: function(latestTherapyId, administration, markGiven, until, preventMask)526 {527 var self = this;528 var view = this.getView();529 var deferred = tm.jquery.Deferred.create();530 var setTitratedDoseUrl = view.getViewModuleUrl()531 + app.views.medications.RestApi.SERVLET_PATH_SET_ADMINISTRATION_TITRATION_DOSE;532 var params = {533 patientId: view.getPatientId(),534 latestTherapyId: latestTherapyId,535 taskId: administration.taskId,536 administration: JSON.stringify(administration),537 confirmAdministration: markGiven,538 until: until ? JSON.stringify(until) : null,539 centralCaseId: view.getCentralCaseData() && view.getCentralCaseData().centralCaseId ?540 view.getCentralCaseData().centralCaseId : null,541 careProviderId: view.getCareProviderId()542 };543 this._showLoaderMask(preventMask);544 view.loadPostViewData(setTitratedDoseUrl, params, null,545 function()546 {547 self._hideLoaderMask(preventMask);548 deferred.resolve();549 },550 function()551 {552 self._hideLoaderMask(preventMask);553 deferred.reject();554 },555 true);556 return deferred.promise();557 },558 /โ**559 * @param {String} id560 * @param {boolean} [preventMask=false]561 * @returns {tm.jquery.Deferred}562 */โ563 loadTherapy: function(id, preventMask)564 {565 var self = this;566 var view = this.getView();567 var deferred = tm.jquery.Deferred.create();568 var getTherapyUrl = view.getViewModuleUrl()569 + app.views.medications.RestApi.SERVLET_PATH_GET_THERAPY;570 var params = {571 patientId: view.getPatientId(),572 therapyId: id573 };574 this._showLoaderMask(preventMask);575 view.loadViewData(getTherapyUrl, params, null, function(data)576 {577 self._hideLoaderMask(preventMask);578 var therapy = !tm.jquery.Utils.isEmpty(data) ?579 app.views.medications.common.TherapyJsonConverter.convert(data) : null;580 deferred.resolve(therapy);581 },582 function()583 {584 self._hideLoaderMask(preventMask);585 deferred.reject();586 });587 return deferred.promise();588 },589 /โ**590 * @param {String} [templateMode=null] Additional filter for the type of templates you want to get ('OUTPATIENT').591 * @param {Boolean} [preventMask=false]592 * @returns {tm.jquery.Deferred}593 */โ594 loadOrderingTemplates: function(templateMode, preventMask)595 {596 var self = this;597 var view = this.getView();598 var deferred = tm.jquery.Deferred.create();599 var getTemplatesUrl =600 view.getViewModuleUrl() + app.views.medications.RestApi.SERVLET_PATH_GET_TEMPLATES;601 var params = {602 patientId: view.getPatientId(),603 templateMode: templateMode,604 careProviderId: view.getCareProviderId(),605 referenceWeight: view.getReferenceWeight(),606 patientHeight: view.getPatientHeightInCm()607 };608 this._showLoaderMask(preventMask);609 view.loadViewData(getTemplatesUrl, params, null,610 function onSuccess(data)611 {612 self._hideLoaderMask(preventMask);613 data.organizationTemplates.forEach(function(template)614 {615 template.templateElements = template.templateElements.map(function(element)616 {617 return app.views.medications.common.dto.TherapyTemplateElement.fromJson(element);618 });619 });620 data.patientTemplates.forEach(function(template)621 {622 template.templateElements = template.templateElements.map(function(element)623 {624 return app.views.medications.common.dto.TherapyTemplateElement.fromJson(element);625 });626 });627 data.userTemplates.forEach(function(template)628 {629 template.templateElements = template.templateElements.map(function(element)630 {631 return app.views.medications.common.dto.TherapyTemplateElement.fromJson(element);632 });633 });634 deferred.resolve(data);635 },636 function onFailure()637 {638 self._hideLoaderMask(preventMask);639 deferred.reject();640 });641 return deferred.promise();642 },643 /โ**644 * @returns {tm.jquery.Deferred}645 * @param {boolean} [preventMask=false]646 */โ647 loadUnlicensedMedicationWarning: function(preventMask)648 {649 var self = this;650 var view = this.getView();651 var deferred = tm.jquery.Deferred.create();652 var getTherapyUrl = view.getViewModuleUrl()653 + app.views.medications.RestApi.SERVLET_PATH_GET_UNLICENSED_MEDICATION_WARNING;654 var params = {language: view.getViewLanguage()};655 this._showLoaderMask(preventMask);656 view.loadViewData(getTherapyUrl, params, null, function(data)657 {658 self._hideLoaderMask(preventMask);659 deferred.resolve(data);660 },661 function()662 {663 self._hideLoaderMask(preventMask);664 deferred.reject();665 });666 return deferred.promise();667 },668 /โ**669 * @param {string} taskId670 * @param {string} doctorsComment671 * @param {boolean} [preventMask=false]672 */โ673 setAdministrationDoctorsComment: function(taskId, doctorsComment, preventMask)674 {675 var self = this;676 var view = this.getView();677 var deferred = tm.jquery.Deferred.create();678 var setAdministrationDoctorsCommentUrl = view.getViewModuleUrl()679 + app.views.medications.RestApi.SERVLET_PATH_SET_ADMINISTRATION_DOCTORS_COMMENT;680 var params = {681 taskId: taskId,682 doctorsComment: doctorsComment683 };684 this._showLoaderMask(preventMask);685 view.sendPostRequest(setAdministrationDoctorsCommentUrl, params, function()686 {687 self._hideLoaderMask(preventMask);688 deferred.resolve();689 },690 function()691 {692 self._hideLoaderMask(preventMask);693 deferred.reject();694 });695 return deferred.promise();696 },697 /โ**698 * @param {String} barcode699 * @param {Boolean} [preventMask=false]700 * @returns {tm.jquery.Deferred}701 */โ702 getMedicationIdForBarcode: function(barcode, preventMask)703 {704 var self = this;705 var view = this.getView();706 var deferred = tm.jquery.Deferred.create();707 var getMedicationIdForBarcodeUrl = view.getViewModuleUrl()708 + app.views.medications.RestApi.SERVLET_PATH_GET_MEDICATION_ID_FOR_BARCODE;709 var params = {710 barcode: barcode711 };712 this._showLoaderMask(preventMask);713 view.loadViewData(getMedicationIdForBarcodeUrl, params, null, function(medicationId)714 {715 self._hideLoaderMask(preventMask);716 deferred.resolve(medicationId);717 },718 function()719 {720 self._hideLoaderMask(preventMask);721 deferred.reject();722 });723 return deferred.promise();724 },725 /โ**726 * @param {String} medicationBarcode727 * @param {Boolean} [preventMask=false]728 * @returns {tm.jquery.Deferred}729 */โ730 getAdministrationTaskForBarcode: function(medicationBarcode, preventMask)731 {732 var self = this;733 var view = this.getView();734 var deferred = tm.jquery.Deferred.create();735 var getAdministrationTaskForBarcodeUrl = view.getViewModuleUrl()736 + app.views.medications.RestApi.SERVLET_PATH_GET_ADMINISTRATION_TASK_FOR_BARCODE;737 var params = {738 patientId: view.getPatientId(),739 medicationBarcode: medicationBarcode740 };741 this._showLoaderMask(preventMask);742 view.loadViewData(getAdministrationTaskForBarcodeUrl, params, null, function(barcodeTaskSearch)743 {744 self._hideLoaderMask(preventMask);745 deferred.resolve(new app.views.medications.common.dto.BarcodeTaskSearch(barcodeTaskSearch));746 },747 function()748 {749 self._hideLoaderMask(preventMask);750 deferred.reject();751 });752 return deferred.promise();753 },754 /โ**755 * @param {String} therapyId756 * @param {Boolean} [preventMask=false]757 * @returns {tm.jquery.Deferred}758 */โ759 getOriginalTherapyId: function(therapyId, preventMask)760 {761 var self = this;762 var view = this.getView();763 var deferred = tm.jquery.Deferred.create();764 var getOriginalTherapyIdUrl = view.getViewModuleUrl() +765 app.views.medications.RestApi.SERVLET_PATH_GET_ORIGINAL_THERAPY_ID;766 var params = {767 patientId: view.getPatientId(),768 therapyId: therapyId769 };770 this._showLoaderMask(preventMask);771 view.loadViewData(getOriginalTherapyIdUrl, params, null,772 function(originalTherapyId)773 {774 self._hideLoaderMask(preventMask);775 deferred.resolve(originalTherapyId);776 },777 function()778 {779 self._hideLoaderMask(preventMask);780 deferred.reject();781 });782 return deferred.promise();783 },784 /โ**785 * @returns {app.views.common.AppView}786 */โ787 getView: function()788 {789 return this.view;790 }...
NodeRepository.js
Source:NodeRepository.js
1/โ** 2 * software for projectmanagement and documentation3 * 4 * @FeatureDomain Collaboration 5 * @author Michael Schreiner <michael.schreiner@your-it-fellow.de>6 * @category collaboration7 * @copyright Copyright (c) 2014, Michael Schreiner8 * @license http:/โ/โmozilla.org/โMPL/โ2.0/โ Mozilla Public License 2.09 *10 * This Source Code Form is subject to the terms of the Mozilla Public11 * License, v. 2.0. If a copy of the MPL was not distributed with this12 * file, You can obtain one at http:/โ/โmozilla.org/โMPL/โ2.0/โ.13 */โ14/โ**15 * service-functions to connect/โload/โsave... to current node-datasource16 * @param {YaioAppBase} appBase the appbase to get other services17 * @param {JsHelferlein.ConfigBase} config config to use18 * @param {JsHelferlein.ConfigBase} defaultConfig default to merge with config19 * @returns {Yaio.NodeRepository} an service-instance20 * @augments JsHelferlein.ServiceBase21 * @constructor22 */โ23Yaio.NodeRepository = function(appBase, config, defaultConfig) {24 'use strict';25 /โ/โ my own instance26 var me = JsHelferlein.ServiceBase(appBase, config, defaultConfig);27 /โ**28 * initialize the object29 */โ30 me._init = function() {31 me.AccessManager = null;32 };33 /โ**34 * return the accessmanager for this service35 * @returns {Yaio.AccessManager} instance of Yaio.AccessManager36 */โ37 me.getAccessManager = function() {38 return me.appBase.YaioDataSourceManager.getCurrentConnection().getAccessManager();39 };40 41 /โ**42 * load the data of the node (own, parent, children)43 * use promise as described on https:/โ/โgithub.com/โmar10/โfancytree/โwiki/โTutorialLoadData#user-content-use-a-deferred-promise44 * @param {String} nodeId id of the node to load data for45 * @returns {JQueryPromise<T>|JQueryPromise<*>|Object} Object or JQueryPromise for FancyTree46 */โ47 me.loadNodeData = function(nodeId) {48 return me.appBase.YaioDataSourceManager.getCurrentConnection().loadNodeData(nodeId);49 };50 /โ**51 * connect the dataservice52 * @returns {JQueryPromise<T>|JQueryPromise<*>} promise if connect succeed or failed53 */โ54 me.connectService = function() {55 return me.appBase.YaioDataSourceManager.getCurrentConnection().connectService();56 };57 /โ**58 * update my config (this instance of NodeDataConfig)59 * @param {Object} yaioCommonApiConfig Common Api Config from yaio-server60 */โ61 me.configureDataService = function(yaioCommonApiConfig) {62 return me.appBase.YaioDataSourceManager.getCurrentConnection().configureDataService(yaioCommonApiConfig);63 };64 /โ**65 * update appBase-config (plantUmlBaseUrl, masterSysUId, excludeNodePraefix) with my config (this instance of NodeDataConfig)66 */โ67 me.reconfigureBaseApp = function() {68 return me.appBase.YaioDataSourceManager.getCurrentConnection().reconfigureBaseApp();69 };70 /โ**71 * read all available templates from configured parents accessmanager.systemTemplateId, accessmanager.ownTemplateId72 * @return {Promise} with obj { systemTemplates: [], ownTemplates: [] }73 */โ74 me.getAvailableTemplates = function() {75 var msg = 'getAvailableTemplates';76 console.log(msg + ' START');77 var promiseHelper = me.appBase.get('YaioPromiseHelper').createAngularPromiseHelper();78 var ajaxCall = function () {79 return promiseHelper.getHttpPromiseMock();80 };81 var angularResponse = {82 data: {systemTemplates: [], ownTemplates: []}83 };84 var systemTemplateId = me.getAccessManager().getAvailiableNodeAction('systemTemplateId'); 85 var ownTemplateId = me.getAccessManager().getAvailiableNodeAction('ownTemplateId');86 if (systemTemplateId) {87 me.getNodeById(systemTemplateId, {})88 .then(function sucess(systemAngularResponse) {89 /โ/โ handle success: systemTemplates90 angularResponse.data = {systemTemplates: systemAngularResponse.data.childNodes, ownTemplates: []};91 if (! ownTemplateId) {92 /โ/โ return only mine93 console.log(msg + ' response:', angularResponse);94 promiseHelper.resolve(angularResponse);95 }96 97 /โ/โ load own templates98 me.getNodeById(ownTemplateId, {})99 .then(function sucess(ownAngularResponse) {100 /โ/โ handle success: ownTemplates101 angularResponse.data = {systemTemplates: systemAngularResponse.data.childNodes, 102 ownTemplates: ownAngularResponse.data.childNodes};103 console.log(msg + ' response:', angularResponse);104 promiseHelper.resolve(angularResponse);105 }, function error() {106 console.log(msg + 'error response:', angularResponse);107 promiseHelper.resolve(angularResponse);108 });109 }, function error() {110 console.log(msg + 'error response:', angularResponse);111 promiseHelper.resolve(angularResponse);112 });113 } else {114 /โ/โ no templates configured115 promiseHelper.resolve(angularResponse);116 }117 return ajaxCall();118 };119 /โ**120 * get symlinked nodedata for basenode121 * @param {Object} basenode node-data to get symlink-data122 * @returns {JQueryPromise<T>|JQueryDeferred<T>|any} promise if read succeed or failed with parameters { yaioNodeActionResponse, textStatus, jqXhr}123 */โ124 me.getNodeForSymLink = function(basenode) {125 var msg = 'getNodeForSymLink for node:' + basenode.sysUID + ' symlink:' + basenode.symLinkRef;126 console.log(msg + ' START');127 return me._getNodeForSymLink(basenode);128 };129 /โ**130 * update node with values in json131 * @param {String} nodeId nodeId to update132 * @param {String} json json with the update-values133 * @returns {JQueryPromise<T>|JQueryDeferred<T>|any} promise if update succeed or failed { yaioNodeActionResponse, textStatus, jqXhr}134 */โ135 me.updateNode = function(nodeId, json) {136 var msg = 'updateNode for nodeId:' + nodeId;137 console.log(msg + ' START');138 return me._updateNode(nodeId, json);139 };140 /โ**141 * move node to newParentKey at position newPos142 * @param {String} nodeId nodeId to move143 * @param {String} newParentKey nodeId of the new parent144 * @param {int} newPos sort-position in parents childList145 * @returns {JQueryPromise<T>|JQueryDeferred<T>|any} promise if update succeed or failed { yaioNodeActionResponse, textStatus, jqXhr}146 */โ147 me.moveNode = function(nodeId, newParentKey, newPos) {148 var msg = 'moveNode for nodeId:' + nodeId + ' newParentKey:' + newParentKey + ' newPos:' + newPos;149 console.log(msg + ' START');150 return me._moveNode(nodeId, newParentKey, newPos);151 };152 /โ**153 * copy node to newParentKey154 * @param {String} nodeId nodeId to copy155 * @param {String} newParentKey nodeId of the new parent156 * @returns {JQueryPromise<T>|JQueryDeferred<T>|any} promise if update succeed or failed { yaioNodeActionResponse, textStatus, jqXhr}157 */โ158 me.copyNode = function(nodeId, newParentKey) {159 var msg = 'copyNode for nodeId:' + nodeId + ' newParentKey:' + newParentKey;160 console.log(msg + ' START');161 return me._copyNode(nodeId, newParentKey);162 };163 /โ**164 * delete node165 * @param {String} nodeId nodeId to delete166 * @returns {JQueryPromise<T>|JQueryDeferred<T>|any} promise if delete succeed or failed { yaioNodeActionResponse, textStatus, jqXhr}167 */โ168 me.deleteNode = function(nodeId) {169 var msg = 'deleteNode for nodeId:' + nodeId;170 console.log(msg + ' START');171 return me._deleteNode(nodeId);172 };173 /โ**174 * save (create/โupdate) node175 * @param {Object} nodeObj node with values to save176 * @param {Object} options options177 * @returns {JQueryPromise<T>|JQueryDeferred<T>|any} promise if save succeed or failed178 */โ179 me.saveNode = function(nodeObj, options) {180 var msg = 'saveNode for node:' + nodeObj.sysUID;181 console.log(msg + ' START');182 return me._saveNode(nodeObj, options);183 };184 /โ**185 * read node186 * @param {String} nodeId nodeId to read187 * @param {Object} options options188 * @returns {JQueryPromise<T>|JQueryDeferred<T>|any} promise if read succeed or failed189 */โ190 me.getNodeById = function(nodeId, options) {191 var msg = 'getNodeById for node:' + nodeId;192 console.log(msg + ' START');193 return me._getNodeById(nodeId, options);194 };195 /โ**196 * search node197 * @param {Object} searchOptions filters and sorts...198 * @returns {JQueryPromise<T>|JQueryDeferred<T>|any} promise if search succeed or failed199 */โ200 me.searchNode = function(searchOptions) {201 var msg = 'searchNode for searchOptions:' + searchOptions;202 console.log(msg + ' START');203 return me._searchNode(searchOptions);204 };205 /โ**206 * call statistics207 * @param {String} statisticName name of the statisticfunction208 * @param {Object} searchOptions filters209 * @returns {JQueryPromise<T>|JQueryDeferred<T>|any} promise if call succeed or failed210 */โ211 me.callStatistics = function(statisticName, start, end, searchOptions) {212 var msg = 'callStatistics ' + statisticName + 'for searchOptions:' + searchOptions;213 console.log(msg + ' START');214 return me._callStatistics(statisticName, start, end, searchOptions);215 };216 /โ**217 * implementation of: get symlinked nodedata for basenode218 * @param {Object} basenode node-data to get symlink-data219 * @returns {JQueryPromise<T>|JQueryDeferred<T>|any} promise if read succeed or failed with parameters { yaioNodeActionResponse, textStatus, jqXhr}220 */โ221 me._getNodeForSymLink = function(basenode) {222 return me.appBase.YaioDataSourceManager.getCurrentConnection().getNodeForSymLink(basenode);223 };224 /โ**225 * implementation of: update node with values in json226 * @param {String} nodeId nodeId to update227 * @param {String} json json with the update-values228 * @returns {JQueryPromise<T>|JQueryDeferred<T>|any} promise if update succeed or failed { yaioNodeActionResponse, textStatus, jqXhr}229 */โ230 me._updateNode = function(nodeId, json) {231 return me.appBase.YaioDataSourceManager.getCurrentConnection().updateNode(nodeId, json);232 };233 /โ**234 * implementation of: move node to newParentKey at position newPos235 * @param {String} nodeId nodeId to move236 * @param {String} newParentKey nodeId of the new parent237 * @param {int} newPos sort-position in parents childList238 * @returns {JQueryPromise<T>|JQueryDeferred<T>|any} promise if update succeed or failed { yaioNodeActionResponse, textStatus, jqXhr}239 */โ240 me._moveNode = function(nodeId, newParentKey, newPos) {241 return me.appBase.YaioDataSourceManager.getCurrentConnection().moveNode(nodeId, newParentKey, newPos);242 };243 /โ**244 * implementation of: copy node to newParentKey245 * @param {String} nodeId nodeId to copy246 * @param {String} newParentKey nodeId of the new parent247 * @returns {JQueryPromise<T>|JQueryDeferred<T>|any} promise if update succeed or failed { yaioNodeActionResponse, textStatus, jqXhr}248 */โ249 me._copyNode = function(nodeId, newParentKey) {250 return me.appBase.YaioDataSourceManager.getCurrentConnection().copyNode(nodeId, newParentKey);251 };252 /โ**253 * implementation of: patch node254 * @param {String} nodeId nodeId to copy255 * @param {String} url url to call256 * @param {String} json json to submit257 * @returns {JQueryPromise<T>|JQueryDeferred<T>|any} promise if update succeed or failed { yaioNodeActionResponse, textStatus, jqXhr}258 */โ259 me._patchNode = function(nodeId, url, json) {260 return me.appBase.YaioDataSourceManager.getCurrentConnection().patchNode(nodeId, url, json);261 };262 /โ**263 * implementation of delete node264 * @param {String} nodeId nodeId to delete265 * @returns {JQueryPromise<T>|JQueryDeferred<T>|any} promise if delete succeed or failed { yaioNodeActionResponse, textStatus, jqXhr}266 */โ267 me._deleteNode = function(nodeId) {268 return me.appBase.YaioDataSourceManager.getCurrentConnection().deleteNode(nodeId);269 };270 /โ**271 * implementation of: save (create/โupdate) node272 * @param {Object} nodeObj node with values to save273 * @param {Object} options options274 * @returns {JQueryPromise<T>|JQueryDeferred<T>|any} promise if save succeed or failed275 */โ276 me._saveNode = function(nodeObj, options) {277 return me.appBase.YaioDataSourceManager.getCurrentConnection().saveNode(nodeObj, options);278 };279 /โ**280 * implementation of: read node281 * @param {String} nodeId nodeId to read282 * @param {Object} options options283 * @returns {JQueryPromise<T>|JQueryDeferred<T>|any} promise if read succeed or failed284 */โ285 me._getNodeById = function(nodeId, options) {286 return me.appBase.YaioDataSourceManager.getCurrentConnection().getNodeById(nodeId, options);287 };288 /โ**289 * implementation of: search node290 * @param {Object} searchOptions filters and sorts...291 * @returns {JQueryPromise<T>|JQueryDeferred<T>|any} promise if search succeed or failed292 */โ293 me._searchNode = function(searchOptions) {294 return me.appBase.YaioDataSourceManager.getCurrentConnection().searchNode(searchOptions);295 };296 /โ**297 * implementation of: callStatistics298 * @param {String} statisticName name of the statisticfunction299 * @param {Object} searchOptions filters300 * @returns {JQueryPromise<T>|JQueryDeferred<T>|any} promise if call succeed or failed301 */โ302 me._callStatistics = function(statisticName, start, end, searchOptions) {303 return me.appBase.YaioDataSourceManager.getCurrentConnection().callStatistics(statisticName, start, end, searchOptions);304 };305 me._init();306 307 return me;...
AbstractNodeDBDriver.js
Source:AbstractNodeDBDriver.js
1/โ** 2 * software for projectmanagement and documentation3 * 4 * @FeatureDomain Collaboration 5 * @author Michael Schreiner <michael.schreiner@your-it-fellow.de>6 * @category collaboration7 * @copyright Copyright (c) 2014, Michael Schreiner8 * @license http:/โ/โmozilla.org/โMPL/โ2.0/โ Mozilla Public License 2.09 *10 * This Source Code Form is subject to the terms of the Mozilla Public11 * License, v. 2.0. If a copy of the MPL was not distributed with this12 * file, You can obtain one at http:/โ/โmozilla.org/โMPL/โ2.0/โ.13 */โ14/โ**15 * abstract service-functions connect/โsave/โretrieve data from datasource16 * @param {YaioAppBase} appBase the appbase to get other services17 * @param {JsHelferlein.ConfigBase} config config to use18 * @param {JsHelferlein.ConfigBase} defaultConfig default to merge with config19 * @returns {Yaio.AbstractNodeDBDriver} an service-instance20 * @augments JsHelferlein.ServiceBase21 * @constructor22 */โ23Yaio.AbstractNodeDBDriver = function(appBase, config, defaultConfig) {24 'use strict';25 /โ/โ my own instance26 var me = JsHelferlein.ServiceBase(appBase, config, defaultConfig);27 /โ**28 * initialize the object29 */โ30 me._init = function() {31 me.connectPromise = undefined;32 me.AccessManager = null;33 };34 /โ**35 * return the accessmanager for this service36 * @returns {Yaio.AccessManager} instance of Yaio.AccessManager37 */โ38 me.getAccessManager = function() {39 if (! me.AccessManager) {40 me.AccessManager = me._createAccessManager();41 }42 return me.AccessManager;43 };44 /โ**45 * load the data of the node (own, parent, children)46 * use promise as described on https:/โ/โgithub.com/โmar10/โfancytree/โwiki/โTutorialLoadData#user-content-use-a-deferred-promise47 * @abstract48 * @param {String} nodeId id of the node to load data for49 * @returns {JQueryPromise<T>|JQueryPromise<*>|Object} Object or JQueryPromise for FancyTree50 */โ51 me.loadNodeData = function(nodeId) {52 me.logNotImplemented();53 };54 /โ**55 * connect the dataservice56 * @abstract57 * @returns {JQueryPromise<T>|JQueryPromise<*>} promise if connect succeed or failed58 */โ59 me.connectService = function() {60 me.logNotImplemented();61 };62 /โ**63 * update my config (this instance of NodeDataConfig)64 * @param {Object} yaioCommonApiConfig Common Api Config from yaio-server65 */โ66 me.configureDataService = function(yaioCommonApiConfig) {67 me.logNotImplemented();68 };69 /โ**70 * update appBase-config (plantUmlBaseUrl, masterSysUId, excludeNodePraefix) with my config (this instance of NodeDataConfig)71 */โ72 me.reconfigureBaseApp = function() {73 var msg = 'reconfigureBaseApp';74 console.log(msg + ' with:', me.config);75 if (me.config.plantUmlBaseUrl) {76 me.appBase.config.plantUmlBaseUrl = me.config.plantUmlBaseUrl;77 }78 if (me.config.masterSysUId) {79 me.appBase.config.masterSysUId = me.config.masterSysUId;80 }81 if (me.config.excludeNodePraefix) {82 me.appBase.config.excludeNodePraefix = me.config.excludeNodePraefix;83 }84 console.log(msg + ' to:', me.appBase.config);85 };86 /โ**87 * implementation of: get symlinked nodedata for basenode88 * @abstract89 * @param {Object} basenode node-data to get symlink-data90 * @returns {JQueryPromise<T>|JQueryDeferred<T>|any} promise if read succeed or failed with parameters { yaioNodeActionResponse, textStatus, jqXhr}91 */โ92 me.getNodeForSymLink = function(basenode) {93 me.logNotImplemented();94 };95 /โ**96 * implementation of: update node with values in json97 * @abstract98 * @param {String} nodeId nodeId to update99 * @param {String} json json with the update-values100 * @returns {JQueryPromise<T>|JQueryDeferred<T>|any} promise if update succeed or failed { yaioNodeActionResponse, textStatus, jqXhr}101 */โ102 me.updateNode = function(nodeId, json) {103 me.logNotImplemented();104 };105 /โ**106 * implementation of: move node to newParentKey at position newPos107 * @abstract108 * @param {String} nodeId nodeId to move109 * @param {String} newParentKey nodeId of the new parent110 * @param {int} newPos sort-position in parents childList111 * @returns {JQueryPromise<T>|JQueryDeferred<T>|any} promise if update succeed or failed { yaioNodeActionResponse, textStatus, jqXhr}112 */โ113 me.moveNode = function(nodeId, newParentKey, newPos) {114 me.logNotImplemented();115 };116 /โ**117 * implementation of: copy node to newParentKey118 * @abstract119 * @param {String} nodeId nodeId to copy120 * @param {String} newParentKey nodeId of the new parent121 * @returns {JQueryPromise<T>|JQueryDeferred<T>|any} promise if update succeed or failed { yaioNodeActionResponse, textStatus, jqXhr}122 */โ123 me.copyNode = function(nodeId, newParentKey) {124 me.logNotImplemented();125 };126 /โ**127 * implementation of: patch node128 * @abstract129 * @param {String} nodeId nodeId to copy130 * @param {String} url url to call131 * @param {String} json json to submit132 * @returns {JQueryPromise<T>|JQueryDeferred<T>|any} promise if update succeed or failed { yaioNodeActionResponse, textStatus, jqXhr}133 */โ134 me.patchNode = function(nodeId, url, json) {135 me.logNotImplemented();136 };137 /โ**138 * implementation of delete node139 * @abstract140 * @param {String} nodeId nodeId to delete141 * @returns {JQueryPromise<T>|JQueryDeferred<T>|any} promise if delete succeed or failed { yaioNodeActionResponse, textStatus, jqXhr}142 */โ143 me.deleteNode = function(nodeId) {144 me.logNotImplemented();145 };146 /โ**147 * implementation of: save (create/โupdate) node148 * @abstract149 * @param {Object} nodeObj node with values to save150 * @param {Object} options options151 * @returns {JQueryPromise<T>|JQueryDeferred<T>|any} promise if save succeed or failed152 */โ153 me.saveNode = function(nodeObj, options) {154 me.logNotImplemented();155 };156 /โ**157 * implementation of: read node158 * @abstract159 * @param {String} nodeId nodeId to read160 * @param {Object} options options161 * @returns {JQueryPromise<T>|JQueryDeferred<T>|any} promise if read succeed or failed162 */โ163 me.getNodeById = function(nodeId, options) {164 me.logNotImplemented();165 };166 /โ**167 * implementation of: search node168 * @abstract169 * @param {Object} searchOptions filters and sorts...170 * @returns {JQueryPromise<T>|JQueryDeferred<T>|any} promise if search succeed or failed171 */โ172 me.searchNode = function(searchOptions) {173 me.logNotImplemented();174 };175 /โ**176 * implementation of: call statistics177 * @abstract178 * @param {String} statisticName name of the statisticfunction179 * @param {Object} searchOptions filters...180 * @returns {JQueryPromise<T>|JQueryDeferred<T>|any} promise if call succeed or failed181 */โ182 me.callStatistics = function(statisticName, start, end, searchOptions) {183 me.logNotImplemented();184 };185 /โ**186 * implementation of: login to service187 * @abstract188 * @param {Object} credentials credentials to login with189 * @returns {JQueryPromise<T>|JQueryDeferred<T>|any} promise if login succeed or failed190 */โ191 me.loginToService = function(credentials) {192 me.logNotImplemented();193 };194 /โ**195 * mplementation of: logout from service196 * @abstract197 * @param {Object} session session to logout198 * @returns {JQueryPromise<T>|JQueryDeferred<T>|any} promise if logout succeed or failed199 */โ200 me.logoutFromService = function(session) {201 me.logNotImplemented();202 };203 /โ**204 * implementation of: check current session of service205 * @abstract206 * @param {Object} session session to check207 * @returns {JQueryPromise<T>|JQueryDeferred<T>|any} promise if check succeed or failed returns { data: 'OK' }208 */โ209 me.checkSession = function(session) {210 me.logNotImplemented();211 };212 me.getConnectPromise = function () {213 return me.connectPromise;214 };215 me.createConnectPromise = function () {216 me.connectPromise = new $.Deferred();217 return me.getConnectPromise();218 };219 /โ**220 * implementation of: create an accessmanager for this service221 * @abstract222 * @returns {Yaio.AccessManager} instance of Yaio.AccessManager223 */โ224 me._createAccessManager = function() {225 me.logNotImplemented();226 };227 me._init();228 229 return me;...
unit.js
Source:unit.js
1"use strict";23var path = require( "path" );45var exec = ( function() {67 var exec = require( "child_process" ).exec;89 return function( command, callback ) {1011 exec( command, function( error, stdout ) {1213 if ( error ) {14 throw error;15 }1617 callback( stdout );18 } );1920 };2122} )();2324var execGruntTask = ( function() {2526 var grunt = require( "grunt" );2728 grunt.task.init = function() {};2930 grunt.initConfig( {31 "update_submodules": {32 default: {33 options: {34 /โ/โ default command line parameters will be used: --init --recursive35 }36 },37 withCustomParameters: {38 options: {39 params: "--force" /โ/โ specifies your own command-line parameters40 }41 },42 withNoParameter: {43 options: {44 params: false /โ/โ blanks command-line parameters45 }46 }47 }48 } );4950 /โ/โ Load tasks51 grunt.loadTasks( path.resolve( __dirname, "../โtasks" ) );5253 /โ/โgrunt.registerTask( "default", "update_submodules" );54 /โ/โgrunt.registerTask( "withCustomParameters", "update_submodules:withCustomParameters" );55 /โ/โgrunt.registerTask( "withNoParameter", "update_submodules:withNoParameter" );5657 return function( task, callback ) {58 var stdout = "";59 var oldWrite = process.stdout.write;60 process.stdout.write = function( string ) {61 stdout += string;62 };63 grunt.tasks( [ task ], {64 verbose: true,65 color: false66 }, function() {67 process.stdout.write = oldWrite;68 callback( stdout );69 } );70 };71} )();7273function createGitDir( dir, submodules, test ) {7475 var wrench = require( "wrench" );7677 dir = path.resolve( __dirname, dir );7879 wrench.rmdirSyncRecursive( dir, true );80 wrench.mkdirSyncRecursive( dir );8182 var oldDir = process.cwd();83 process.chdir( dir );8485 exec( "git init", function() {8687 var submodulesCommands = submodules.map( function( data ) {88 return "git submodule add " + data.url + " " + data.folder;89 } );9091 ( function next() {9293 var submoduleCommand = submodulesCommands.shift();9495 if ( submoduleCommand ) {9697 exec( submoduleCommand, next );9899 } else {100101 submodules.forEach( function( data ) {102 wrench.rmdirSyncRecursive( path.join( dir, data.folder ), true );103 } );104105 test( function() {106 /โ/โ Get back to the previous dir107 process.chdir( oldDir );108 /โ/โ Delete the newly created dir109 wrench.rmdirSyncRecursive( dir, true );110 } );111112 }113114 } )();115116 } );117118}119120module.exports = {121122 "test with a single submodule": function( _ ) {123124 _.expect( 3 );125126 var expectedCommand = "\ngit submodule update --init --recursive";127128 createGitDir( "single", [ {129130 folder: "grunt-update-submodules",131 url: "https:/โ/โgithub.com/โjaubourg/โgrunt-update-submodules.git"132133 } ], function( done ) {134135 execGruntTask( "update_submodules", function( stdout ) {136137 _.ok( stdout.indexOf( expectedCommand + "\n" ) > 0, "Command with no merge" );138139 execGruntTask( "update_submodules", function( stdout ) {140141 _.ok( stdout.indexOf( expectedCommand + " --merge\n" ) > 0, "Command with merge" );142143 _.strictEqual(144 require( path.resolve( __dirname, "single/โgrunt-update-submodules/โpackage.json" ) ).name,145 "grunt-update-submodules",146 "Files pulled"147 );148149 done();150 _.done();151 } );152 } );153154 } );155 },156157 "test with a couple submodules": function( _ ) {158159 _.expect( 4 );160161 var expectedCommand = "\ngit submodule update --init --recursive";162163 createGitDir( "couple", [ {164165 folder: "grunt-update-submodules",166 url: "https:/โ/โgithub.com/โjaubourg/โgrunt-update-submodules.git"167168 }, {169170 folder: "jquery-deferred-for-node",171 url: "https:/โ/โgithub.com/โjaubourg/โjquery-deferred-for-node.git"172173 } ], function( done ) {174175 execGruntTask( "update_submodules", function( stdout ) {176177 _.ok( stdout.indexOf( expectedCommand + "\n" ) > 0, "Command with no merge" );178179 execGruntTask( "update_submodules", function( stdout ) {180181 _.ok( stdout.indexOf( expectedCommand + " --merge\n" ) > 0, "Command with merge" );182183 _.strictEqual(184 require( path.resolve( __dirname, "couple/โgrunt-update-submodules/โpackage.json" ) ).name,185 "grunt-update-submodules",186 "Files pulled for grunt-update-submodules"187 );188189 _.strictEqual(190 require( path.resolve( __dirname, "couple/โjquery-deferred-for-node/โpackage.json" ) ).name,191 "JQDeferredGenerator",192 "Files pulled for jquery-deferred-for-node"193 );194195 done();196 _.done();197 } );198 } );199200 } );201 },202203 "test with custom parameters": function( _ ) {204205 _.expect( 1 );206207 var expectedCommand = "\ngit submodule update --force";208209 createGitDir( "withCustomParameters", [ {210211 folder: "grunt-update-submodules",212 url: "https:/โ/โgithub.com/โjaubourg/โgrunt-update-submodules.git"213214 }, {215216 folder: "jquery-deferred-for-node",217 url: "https:/โ/โgithub.com/โjaubourg/โjquery-deferred-for-node.git"218219 } ], function( done ) {220221 execGruntTask( "update_submodules:withCustomParameters", function( stdout ) {222223 _.ok( stdout.indexOf( expectedCommand + "\n" ) > 0, "Command with custom parameters" );224225 done();226 _.done();227 } );228229 } );230 },231232 "test with no parameter": function( _ ) {233234 _.expect( 1 );235236 var expectedCommand = "\ngit submodule update";237238 createGitDir( "withNoParameter", [ {239240 folder: "grunt-update-submodules",241 url: "https:/โ/โgithub.com/โjaubourg/โgrunt-update-submodules.git"242243 }, {244245 folder: "jquery-deferred-for-node",246 url: "https:/โ/โgithub.com/โjaubourg/โjquery-deferred-for-node.git"247248 } ], function( done ) {249250 execGruntTask( "update_submodules:withNoParameter", function( stdout ) {251252 _.ok( stdout.indexOf( expectedCommand + "\n" ) > 0, "Command with no parameter" );253254 done();255 _.done();256 } );257258 } );259 }260
...
SelectorImage.js
Source:SelectorImage.js
1var jquery = require('jquery-deferred')2var whenCallSequentially = require('../โ../โassets/โjquery.whencallsequentially')3var Base64 = require('../โ../โassets/โbase64')4var SelectorImage = {5 canReturnMultipleRecords: function () {6 return true7 },8 canHaveChildSelectors: function () {9 return false10 },11 canHaveLocalChildSelectors: function () {12 return false13 },14 canCreateNewJobs: function () {15 return false16 },17 willReturnElements: function () {18 return false19 },20 _getData: function (parentElement) {21 var dfd = jquery.Deferred()22 var elements = this.getDataElements(parentElement)23 var deferredDataCalls = []24 this.$(elements).each(function (i, element) {25 deferredDataCalls.push(function () {26 var deferredData = jquery.Deferred()27 var data = {}28 data[this.id + '-src'] = element.src29 /โ/โ download image if required30 if (!this.downloadImage) {31 deferredData.resolve(data)32 } else {33 var deferredImageBase64 = this.downloadImageBase64(element.src)34 deferredImageBase64.done(function (imageResponse) {35 data['_imageBase64-' + this.id] = imageResponse.imageBase6436 data['_imageMimeType-' + this.id] = imageResponse.mimeType37 deferredData.resolve(data)38 }.bind(this)).fail(function () {39 /โ/โ failed to download image continue.40 /โ/โ @TODO handle errror41 deferredData.resolve(data)42 })43 }44 return deferredData.promise()45 }.bind(this))46 }.bind(this))47 whenCallSequentially(deferredDataCalls).done(function (dataResults) {48 if (this.multiple === false && elements.length === 0) {49 var data = {}50 data[this.id + '-src'] = null51 dataResults.push(data)52 }53 dfd.resolve(dataResults)54 })55 return dfd.promise()56 },57 downloadFileAsBlob: function (url) {58 var window = this.window59 var deferredResponse = jquery.Deferred()60 var xhr = new window.XMLHttpRequest()61 xhr.onreadystatechange = function () {62 if (this.readyState == 4) {63 if (this.status == 200) {64 var blob = this.response65 deferredResponse.resolve(blob)66 } else {67 deferredResponse.reject(xhr.statusText)68 }69 }70 }71 xhr.open('GET', url)72 xhr.responseType = 'blob'73 xhr.send()74 return deferredResponse.promise()75 },76 downloadImageBase64: function (url) {77 var deferredResponse = jquery.Deferred()78 var deferredDownload = this.downloadFileAsBlob(url)79 deferredDownload.done(function (blob) {80 var mimeType = blob.type81 var deferredBlob = Base64.blobToBase64(blob)82 deferredBlob.done(function (imageBase64) {83 deferredResponse.resolve({84 mimeType: mimeType,85 imageBase64: imageBase6486 })87 })88 }).fail(deferredResponse.fail)89 return deferredResponse.promise()90 },91 getDataColumns: function () {92 return [this.id + '-src']93 },94 getFeatures: function () {95 return ['multiple', 'delay', 'downloadImage']96 },97 getItemCSSSelector: function () {98 return 'img'99 }100}...
ContentScript.js
Source:ContentScript.js
1var ContentSelector = require('./โContentSelector')2var jquery = require('jquery-deferred')3const debug = require('debug')('web-scraper-headless:content-script')4/โ**5 * ContentScript that can be called from anywhere within the extension6 */โ7var ContentScript = {8 /โ**9 * Fetch10 * @param request.CSSSelector css selector as string11 * @returns jquery.Deferred()12 */โ13 getHTML: function (request, options) {14 var $ = options.$15 var deferredHTML = jquery.Deferred()16 var html = $(request.CSSSelector).clone().wrap('<p>').parent().html()17 deferredHTML.resolve(html)18 debug('Send html', html)19 return deferredHTML.promise()20 },21 /โ**22 * Removes current content selector if is in use within the page23 * @returns jquery.Deferred()24 */โ25 removeCurrentContentSelector: function () {26 var deferredResponse = jquery.Deferred()27 var contentSelector = window.cs28 if (contentSelector === undefined) {29 deferredResponse.resolve()30 } else {31 contentSelector.removeGUI()32 window.cs = undefined33 deferredResponse.resolve()34 }35 return deferredResponse.promise()36 },37 /โ**38 * Select elements within the page39 * @param request.parentCSSSelector40 * @param request.allowedElements41 */โ42 selectSelector: function (request, options) {43 var $ = options.$44 var deferredResponse = jquery.Deferred()45 this.removeCurrentContentSelector().done(function () {46 var contentSelector = new ContentSelector({47 parentCSSSelector: request.parentCSSSelector,48 allowedElements: request.allowedElements49 }, {$, document, window})50 window.cs = contentSelector51 var deferredCSSSelector = contentSelector.getCSSSelector()52 deferredCSSSelector.done(function (response) {53 this.removeCurrentContentSelector().done(function () {54 deferredResponse.resolve(response)55 window.cs = undefined56 })57 }.bind(this)).fail(function (message) {58 deferredResponse.reject(message)59 window.cs = undefined60 })61 }.bind(this))62 return deferredResponse.promise()63 },64 /โ**65 * Preview elements66 * @param request.parentCSSSelector67 * @param request.elementCSSSelector68 */โ69 previewSelector: function (request, options) {70 var $ = options.$71 var deferredResponse = jquery.Deferred()72 this.removeCurrentContentSelector().done(function () {73 var contentSelector = new ContentSelector({74 parentCSSSelector: request.parentCSSSelector75 }, {$, document, window})76 window.cs = contentSelector77 var deferredSelectorPreview = contentSelector.previewSelector(request.elementCSSSelector)78 deferredSelectorPreview.done(function () {79 deferredResponse.resolve()80 }).fail(function (message) {81 deferredResponse.reject(message)82 window.cs = undefined83 })84 })85 return deferredResponse86 }87}...
BackgroundScript.js
Source:BackgroundScript.js
1var jquery = require('jquery-deferred')2const debug = require('debug')('web-scraper-headless:background-script')3/โ**4 * ContentScript that can be called from anywhere within the extension5 */โ6var BackgroundScript = {7 dummy: function () {8 return jquery.Deferred().resolve('dummy').promise()9 },10 /โ**11 * Returns the id of the tab that is visible to user12 * @returns jquery.Deferred() integer13 */โ14 getActiveTabId: function () {15 var deferredResponse = jquery.Deferred()16 chrome.tabs.query({17 active: true,18 currentWindow: true19 }, function (tabs) {20 if (tabs.length < 1) {21 debug('There seems to be no active tab in the current window. Let us try only active')22 chrome.tabs.query({23 active: true,24 windowType: 'normal'25 }, function (tabs) {26 if (tabs.length < 1) {27 debug('Could not find tab')28 deferredResponse.reject("couldn't find the active tab")29 } else {30 const tabId = tabs[0].id31 deferredResponse.resolve(tabId)32 }33 })34 /โ/โ @TODO must be running within popup. maybe find another active window?35 } else {36 var tabId = tabs[0].id37 deferredResponse.resolve(tabId)38 }39 })40 return deferredResponse.promise()41 },42 /โ**43 * Execute a function within the active tab within content script44 * @param request.fn function to call45 * @param request.request request that will be passed to the function46 */โ47 executeContentScript: function (request) {48 var reqToContentScript = {49 contentScriptCall: true,50 fn: request.fn,51 request: request.request52 }53 var deferredResponse = jquery.Deferred()54 var deferredActiveTabId = this.getActiveTabId()55 deferredActiveTabId.done(function (tabId) {56 chrome.tabs.sendMessage(tabId, reqToContentScript, function (response) {57 deferredResponse.resolve(response)58 })59 })60 return deferredResponse61 }62}...
Using AI Code Generation
1describe('My First Test', () => {2 it('Does not do much!', () => {3 cy.contains('type').click()4 cy.url().should('include', '/โcommands/โactions')5 cy.get('.action-email')6 .type('
Using AI Code Generation
1cy.get('button').click()2cy.get('button').then(($btn) => {3 return new Cypress.Promise((resolve, reject) => {4 setTimeout(() => {5 resolve($btn)6 }, 5000)7 })8}).click()9cy.get('button').click()10cy.get('button').then(($btn) => {11 return new Cypress.Promise((resolve, reject) => {12 setTimeout(() => {13 resolve($btn)14 }, 5000)15 })16}).click()17cy.get('button').click()18cy.get('button').then(($btn) => {19 return new Cypress.Promise((resolve, reject) => {20 setTimeout(() => {21 resolve($btn)22 }, 5000)23 })24}).click()25cy.get('button').click()26cy.get('button').then(($btn) => {27 return new Cypress.Promise((resolve, reject) => {28 setTimeout(() => {29 resolve($btn)30 }, 5000)31 })32}).click()33cy.get('button').click()34cy.get('button').then(($btn) => {35 return new Cypress.Promise((resolve, reject) => {36 setTimeout(() => {37 resolve($btn)38 }, 5000)39 })40}).click()41cy.get('button').click()42cy.get('button').then(($btn) => {43 return new Cypress.Promise((resolve, reject) => {44 setTimeout(() => {45 resolve($btn)46 }, 5000)47 })48}).click()49cy.get('button').click()50cy.get('button').then(($btn) => {51 return new Cypress.Promise((resolve, reject) => {52 setTimeout(() => {53 resolve($btn)54 }, 5000)55 })56}).click()57cy.get('button').click()58cy.get('button').then(($btn) => {59 return new Cypress.Promise((resolve, reject) => {60 setTimeout(() => {61 resolve($btn)62 }, 5000)63 })64}).click()65cy.get('button').click()66cy.get('button
Using AI Code Generation
1Cypress.Commands.add("getDeferred", (selector, timeout) => {2 .window()3 .then({ timeout }, win =>4 Cypress.$.Deferred()5 .resolve(win.jQuery(selector))6 .promise()7 );8});9Cypress.Commands.add("getDeferred", (selector, timeout) => {10 .window()11 .then({ timeout }, win =>12 Cypress.$.Deferred()13 .resolve(win.jQuery(selector))14 .promise()15 );16});17cy.get("#myButton").click();18cy.get("#myElement", { timeout: 10000 }).should("be.visible");19cy.get("#myButton").click();20cy.get("#myElement", { timeout: 10000 }).should("be.visible");21cy.get("#myButton").click();22cy.get("#myElement", { timeout: 10000 }).should("be.visible");23cy.get("#myButton").click();24cy.get("#myElement", { timeout: 10000 }).should("be.visible");
Using AI Code Generation
1Cypress.Commands.add('getByTestId', (testId, options) => {2 return cy.defer(() => {3 return cy.get(`[data-testid="${testId}"]`, options);4 });5});6Cypress.Commands.add('getByTestId', (testId, options) => {7 return cy.defer(() => {8 return cy.get(`[data-testid="${testId}"]`, options);9 });10});11Cypress.Commands.add('getByTestId', (testId, options) => {12 return cy.defer(() => {13 return cy.get(`[data-testid="${testId}"]`, options);14 });15});
Using AI Code Generation
1describe('My First Test', function() {2 it('Does not do much!', function() {3 cy.get('input#input').type('hello')4 cy.get('button#submit').click()5 cy.get('h2#output').should('contain', 'hello')6 })7})8describe('My Second Test', function() {9 it('Does not do much!', function() {10 cy.get('input#input').type('hello')11 cy.get('button#submit').click()12 expect(response.body).to.have.property('echo', 'hello')13 })14 })15})16describe('My First Test', function() {17 it('Does not do much!', function() {18 cy.get('input#input').type('hello')19 cy.get('button#submit').click()20 cy.get('h2#output').should('contain', 'hello')21 })22})23describe('My Second Test', function() {24 it('Does not do much!', function() {25 cy.get('input#input').type('hello')26 cy.get('button#submit').click()27 expect(response.body).to.have.property('echo', 'hello')28 })29 })30})
Using AI Code Generation
1describe("My First Test", function () {2 it("Does not do much!", function () {3 expect(true).to.equal(true);4 });5});6describe("My Second Test", function () {7 it("Visits the Kitchen Sink", function () {8 });9});10describe("My Third Test", function () {11 it("Finds an element", function () {12 cy.contains("type");13 });14});15describe("My Fourth Test", function () {16 it("Clicks an element", function () {17 cy.contains("type").click();18 });19});20describe("My Fifth Test", function () {21 it("Gets, types and asserts", function () {22 cy.contains("type").click();23 cy.url().should("include", "/โcommands/โactions");24 cy.get(".action-email")25 .type("
Cypress is a renowned Javascript-based open-source, easy-to-use end-to-end testing framework primarily used for testing web applications. Cypress is a relatively new player in the automation testing space and has been gaining much traction lately, as evidenced by the number of Forks (2.7K) and Stars (42.1K) for the project. LambdaTestโs Cypress Tutorial covers step-by-step guides that will help you learn from the basics till you run automation tests on LambdaTest.
You can elevate your expertise with end-to-end testing using the Cypress automation framework and stay one step ahead in your career by earning a Cypress certification. Check out our Cypress 101 Certification.
Watch this 3 hours of complete tutorial to learn the basics of Cypress and various Cypress commands with the Cypress testing at LambdaTest.
Get 100 minutes of automation test minutes FREE!!