chayns-api 1.0.69 → 1.0.71

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -241,11 +241,13 @@ const storageSetItem = (...args) => _moduleWrapper.moduleWrapper.current.functio
241
241
  */
242
242
  exports.storageSetItem = storageSetItem;
243
243
  const vibrate = (...args) => _moduleWrapper.moduleWrapper.current.functions.vibrate(...args);
244
+
244
245
  /**
245
246
  * This method creates a dialog
246
247
  */
248
+ // @ts-ignore
247
249
  exports.vibrate = vibrate;
248
- const createDialog = (...args) => _moduleWrapper.moduleWrapper.current.functions.createDialog(...args);
250
+ const createDialog = config => _moduleWrapper.moduleWrapper.current.functions.createDialog(config);
249
251
  /**
250
252
  * Displays an overlay
251
253
  */
@@ -578,12 +578,14 @@ class AppWrapper {
578
578
  this.values = this.mapOldApiToNew(await this.appCall(18));
579
579
  this.appCall(66, {
580
580
  enabled: true,
581
- callback: value => {
582
- if ('tobitAccessToken' in value) {
583
- this.accessToken = value.tobitAccessToken;
584
- } else {
585
- this.mapOldApiToNew(value);
586
- }
581
+ callback: async () => {
582
+ this.values = this.mapOldApiToNew(await this.appCall(18));
583
+ document.dispatchEvent(new CustomEvent('chayns_api_data', {
584
+ detail: {
585
+ type: 'user',
586
+ value: this.values.user
587
+ }
588
+ }));
587
589
  }
588
590
  });
589
591
  return undefined;
@@ -282,12 +282,12 @@ export const storageSetItem = function () {
282
282
  export const vibrate = function () {
283
283
  return moduleWrapper.current.functions.vibrate(...arguments);
284
284
  };
285
+
285
286
  /**
286
287
  * This method creates a dialog
287
288
  */
288
- export const createDialog = function () {
289
- return moduleWrapper.current.functions.createDialog(...arguments);
290
- };
289
+ // @ts-ignore
290
+ export const createDialog = config => moduleWrapper.current.functions.createDialog(config);
291
291
  /**
292
292
  * Displays an overlay
293
293
  */
@@ -576,12 +576,14 @@ export class AppWrapper {
576
576
  this.values = this.mapOldApiToNew(await this.appCall(18));
577
577
  this.appCall(66, {
578
578
  enabled: true,
579
- callback: value => {
580
- if ('tobitAccessToken' in value) {
581
- this.accessToken = value.tobitAccessToken;
582
- } else {
583
- this.mapOldApiToNew(value);
584
- }
579
+ callback: async () => {
580
+ this.values = this.mapOldApiToNew(await this.appCall(18));
581
+ document.dispatchEvent(new CustomEvent('chayns_api_data', {
582
+ detail: {
583
+ type: 'user',
584
+ value: this.values.user
585
+ }
586
+ }));
585
587
  }
586
588
  });
587
589
  return undefined;
@@ -200,7 +200,7 @@ export declare const vibrate: (value: import("../types/IChaynsReact").Vibrate) =
200
200
  /**
201
201
  * This method creates a dialog
202
202
  */
203
- export declare const createDialog: (config: import("../types/IChaynsReact").Dialog) => import("..").DialogHandler;
203
+ export declare const createDialog: ChaynsReactFunctions["createDialog"];
204
204
  /**
205
205
  * Displays an overlay
206
206
  */
@@ -233,9 +233,7 @@ export declare const getParameters: () => {
233
233
  export declare const getPages: () => import("../types/IChaynsReact").Page[];
234
234
  export declare const getEnvironment: () => {
235
235
  buildEnvironment: import("../types/IChaynsReact").Environment;
236
- runtimeEnvironment: string | import("../types/IChaynsReact").RuntimeEnviroment; /**
237
- * Refresh accesstoken, should only be used when user object changes, not when token is invalid
238
- */
236
+ runtimeEnvironment: string | import("../types/IChaynsReact").RuntimeEnviroment;
239
237
  };
240
238
  export declare const user: UserInfo;
241
239
  export declare const site: ChaynsApiSite;
@@ -253,7 +251,5 @@ export declare const parameters: {
253
251
  export declare const pages: import("../types/IChaynsReact").Page[];
254
252
  export declare const environment: {
255
253
  buildEnvironment: import("../types/IChaynsReact").Environment;
256
- runtimeEnvironment: string | import("../types/IChaynsReact").RuntimeEnviroment; /**
257
- * Refresh accesstoken, should only be used when user object changes, not when token is invalid
258
- */
254
+ runtimeEnvironment: string | import("../types/IChaynsReact").RuntimeEnviroment;
259
255
  };
@@ -1,4 +1,4 @@
1
- export default class DialogHandler {
1
+ export default class DialogHandler<S = void, T extends any = void> {
2
2
  private dialogId;
3
3
  private isOpen;
4
4
  private result;
@@ -9,10 +9,13 @@ export default class DialogHandler {
9
9
  private readonly _addDataListener;
10
10
  private readonly listeners;
11
11
  constructor(config: any, open: any, close: any, dispatchEvent: any, addDataListener: any);
12
- open(): Promise<unknown>;
12
+ open(): Promise<{
13
+ buttonType: number;
14
+ value: T extends undefined ? S : T;
15
+ }>;
13
16
  close(buttonType: any, data: any): void;
14
17
  dispatchEvent(data: object): void;
15
18
  addDataListener(listener: (data: any) => void): void;
16
19
  removeDataListener(listener: (data: any) => void): void;
17
- getResult(): any;
20
+ getResult(): T;
18
21
  }
@@ -61,23 +61,25 @@ export interface BaseDialog {
61
61
  config?: any;
62
62
  };
63
63
  }
64
- export type Dialog = BaseDialog & (DialogAlert | DialogConfirm | DialogInput | DialogModule | DialogIFrame | DialogSelect | DialogDate | DialogToast | DialogFileSelect | DialogSignature);
64
+ export type Dialog<T extends any = object> = BaseDialog & (DialogAlert | DialogConfirm | DialogInput | DialogModule<T> | DialogIFrame<T> | DialogSelect | DialogDate | DialogToast);
65
65
  export interface DialogSignature {
66
66
  type: DialogType.SIGNATURE;
67
67
  }
68
- export interface DialogModule {
68
+ export interface DialogModule<T extends any = object> {
69
69
  type: DialogType.MODULE;
70
70
  system: {
71
71
  url: string;
72
72
  module: string;
73
73
  scope: string;
74
74
  };
75
- dialogInput: object;
75
+ dialogInput?: T;
76
+ backgroundColor?: string;
76
77
  }
77
- export interface DialogIFrame {
78
+ export interface DialogIFrame<T extends any = object> {
78
79
  type: DialogType.IFRAME;
79
80
  url: string;
80
- dialogInput: object;
81
+ dialogInput?: T;
82
+ backgroundColor?: string;
81
83
  }
82
84
  export declare enum DialogInputType {
83
85
  NUMBER = "number",
@@ -88,8 +90,8 @@ export declare enum DialogInputType {
88
90
  }
89
91
  export interface DialogInput {
90
92
  type: DialogType.INPUT;
91
- placeholder: string;
92
- inputType: DialogInputType;
93
+ placeholder?: string;
94
+ inputType?: DialogInputType;
93
95
  defaultValue?: string;
94
96
  formatter?: (input: string) => string;
95
97
  }
@@ -216,6 +218,30 @@ export interface ChaynsReactValues {
216
218
  isClosingRequested: boolean;
217
219
  };
218
220
  }
221
+ export interface DialogResultFile {
222
+ blockDownload?: boolean;
223
+ contentType: string;
224
+ filename: string;
225
+ id: number;
226
+ key: string;
227
+ modifyTime: string;
228
+ personId: string;
229
+ protected?: boolean;
230
+ size: number;
231
+ url: string;
232
+ }
233
+ type DialogResultValue<T> = {
234
+ [DialogType.INPUT]: string;
235
+ [DialogType.SELECT]: number[];
236
+ [DialogType.CONFIRM]: void;
237
+ [DialogType.ALERT]: void;
238
+ [DialogType.DATE]: Date;
239
+ [DialogType.FILE_SELECT]: DialogResultFile[];
240
+ [DialogType.IFRAME]: T;
241
+ [DialogType.MODULE]: T;
242
+ [DialogType.SIGNATURE]: string;
243
+ [DialogType.TOAST]: void;
244
+ };
219
245
  /**
220
246
  * @ignore
221
247
  */
@@ -275,7 +301,7 @@ export interface ChaynsReactFunctions {
275
301
  vibrate: (value: Vibrate) => Promise<void>;
276
302
  scrollByY: (position: number, duration?: number) => Promise<void>;
277
303
  setOverlay: (value: ShowOverlay, callback: () => void) => Promise<void>;
278
- createDialog: (config: Dialog) => DialogHandler;
304
+ createDialog: <I extends any = undefined, T extends any = undefined, Z extends Dialog<I> = Dialog<I>>(config: Z) => DialogHandler<DialogResultValue<T>[Z["type"]], T>;
279
305
  openDialog: (value: any, callback: (data: any) => any) => Promise<any>;
280
306
  closeDialog: (dialogId: number) => Promise<void>;
281
307
  setDialogResult: (buttonType: DialogButtonType, result: any) => Promise<void>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "chayns-api",
3
- "version": "1.0.69",
3
+ "version": "1.0.71",
4
4
  "description": "new chayns api",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",