How to use jQuery.Deferred method in Cypress

Best JavaScript code snippet using cypress

ibm-mobilefirst.js

Source:ibm-mobilefirst.js Github

copy

Full Screen

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}...

Full Screen

Full Screen

RestApi.js

Source:RestApi.js Github

copy

Full Screen

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 }...

Full Screen

Full Screen

NodeRepository.js

Source:NodeRepository.js Github

copy

Full Screen

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;...

Full Screen

Full Screen

AbstractNodeDBDriver.js

Source:AbstractNodeDBDriver.js Github

copy

Full Screen

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;...

Full Screen

Full Screen

unit.js

Source:unit.js Github

copy

Full Screen

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 ...

Full Screen

Full Screen

SelectorImage.js

Source:SelectorImage.js Github

copy

Full Screen

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}...

Full Screen

Full Screen

ContentScript.js

Source:ContentScript.js Github

copy

Full Screen

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}...

Full Screen

Full Screen

BackgroundScript.js

Source:BackgroundScript.js Github

copy

Full Screen

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}...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

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('

Full Screen

Using AI Code Generation

copy

Full Screen

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

Full Screen

Using AI Code Generation

copy

Full Screen

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");

Full Screen

Using AI Code Generation

copy

Full Screen

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});

Full Screen

Using AI Code Generation

copy

Full Screen

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})

Full Screen

Using AI Code Generation

copy

Full Screen

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("

Full Screen

Cypress Tutorial

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.

Chapters:

  1. What is Cypress? -
  2. Why Cypress? - Learn why Cypress might be a good choice for testing your web applications.
  3. Features of Cypress Testing - Learn about features that make Cypress a powerful and flexible tool for testing web applications.
  4. Cypress Drawbacks - Although Cypress has many strengths, it has a few limitations that you should be aware of.
  5. Cypress Architecture - Learn more about Cypress architecture and how it is designed to be run directly in the browser, i.e., it does not have any additional servers.
  6. Browsers Supported by Cypress - Cypress is built on top of the Electron browser, supporting all modern web browsers. Learn browsers that support Cypress.
  7. Selenium vs Cypress: A Detailed Comparison - Compare and explore some key differences in terms of their design and features.
  8. Cypress Learning: Best Practices - Take a deep dive into some of the best practices you should use to avoid anti-patterns in your automation tests.
  9. How To Run Cypress Tests on LambdaTest? - Set up a LambdaTest account, and now you are all set to learn how to run Cypress tests.

Certification

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.

YouTube

Watch this 3 hours of complete tutorial to learn the basics of Cypress and various Cypress commands with the Cypress testing at LambdaTest.

Run Cypress automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful