jd_platform_sdk 0.0.2

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.
Files changed (62) hide show
  1. package/dist/extensions/extensions.d.ts +1 -0
  2. package/dist/extensions/extensions.d.ts.map +1 -0
  3. package/dist/extensions/extensions.js +31 -0
  4. package/dist/globals.d.ts +7 -0
  5. package/dist/globals.d.ts.map +1 -0
  6. package/dist/globals.js +1 -0
  7. package/dist/index.d.ts +13 -0
  8. package/dist/index.d.ts.map +1 -0
  9. package/dist/index.js +14 -0
  10. package/dist/sdk/configs/dpConfig.d.ts +15 -0
  11. package/dist/sdk/configs/dpConfig.d.ts.map +1 -0
  12. package/dist/sdk/configs/dpConfig.js +49 -0
  13. package/dist/sdk/configs/jdConfig.d.ts +8 -0
  14. package/dist/sdk/configs/jdConfig.d.ts.map +1 -0
  15. package/dist/sdk/configs/jdConfig.js +40 -0
  16. package/dist/sdk/extensions/extensions.d.ts +2 -0
  17. package/dist/sdk/extensions/extensions.d.ts.map +1 -0
  18. package/dist/sdk/extensions/extensions.js +23 -0
  19. package/dist/sdk/jdConnector.d.ts +24 -0
  20. package/dist/sdk/jdConnector.d.ts.map +1 -0
  21. package/dist/sdk/jdConnector.js +141 -0
  22. package/dist/sdk/jdSdk.d.ts +6 -0
  23. package/dist/sdk/jdSdk.d.ts.map +1 -0
  24. package/dist/sdk/jdSdk.js +18 -0
  25. package/dist/sdk/models/jdApplication.d.ts +21 -0
  26. package/dist/sdk/models/jdApplication.d.ts.map +1 -0
  27. package/dist/sdk/models/jdApplication.js +60 -0
  28. package/dist/sdk/models/jdResource.d.ts +43 -0
  29. package/dist/sdk/models/jdResource.d.ts.map +1 -0
  30. package/dist/sdk/models/jdResource.js +149 -0
  31. package/dist/sdk/models/modules/karaoke/jdKtvShop.d.ts +8 -0
  32. package/dist/sdk/models/modules/karaoke/jdKtvShop.d.ts.map +1 -0
  33. package/dist/sdk/models/modules/karaoke/jdKtvShop.js +37 -0
  34. package/dist/sdk/utilities/browserUtils.d.ts +5 -0
  35. package/dist/sdk/utilities/browserUtils.d.ts.map +1 -0
  36. package/dist/sdk/utilities/browserUtils.js +26 -0
  37. package/dist/sdk/utilities/cryptoUtils.d.ts +5 -0
  38. package/dist/sdk/utilities/cryptoUtils.d.ts.map +1 -0
  39. package/dist/sdk/utilities/cryptoUtils.js +25 -0
  40. package/dist/sdk/utilities/crypto_utils.d.ts +5 -0
  41. package/dist/sdk/utilities/crypto_utils.d.ts.map +1 -0
  42. package/dist/sdk/utilities/crypto_utils.js +26 -0
  43. package/dist/sdk/utilities/dateUtils.d.ts +6 -0
  44. package/dist/sdk/utilities/dateUtils.d.ts.map +1 -0
  45. package/dist/sdk/utilities/dateUtils.js +49 -0
  46. package/dist/sdk/utilities/globalEventHandler.d.ts +10 -0
  47. package/dist/sdk/utilities/globalEventHandler.d.ts.map +1 -0
  48. package/dist/sdk/utilities/globalEventHandler.js +34 -0
  49. package/dist/sdk/utilities/stringUtils.d.ts +3 -0
  50. package/dist/sdk/utilities/stringUtils.d.ts.map +1 -0
  51. package/dist/sdk/utilities/stringUtils.js +6 -0
  52. package/dist/sdk/utilities/utils.d.ts +31 -0
  53. package/dist/sdk/utilities/utils.d.ts.map +1 -0
  54. package/dist/sdk/utilities/utils.js +133 -0
  55. package/dist/stringUtils.d.ts +3 -0
  56. package/dist/stringUtils.d.ts.map +1 -0
  57. package/dist/stringUtils.js +6 -0
  58. package/dist/unit_tests.d.ts +2 -0
  59. package/dist/unit_tests.d.ts.map +1 -0
  60. package/dist/unit_tests.js +7 -0
  61. package/package.json +33 -0
  62. package/readme.md +40 -0
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=extensions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"extensions.d.ts","sourceRoot":"","sources":["../../src/extensions/extensions.ts"],"names":[],"mappings":""}
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+ // import './extensions.d.ts';
3
+ //
4
+ // // @ts-ignore
5
+ // String.prototype.isset = function (): boolean {
6
+ // return this != null && this !== "";
7
+ // };
8
+ // String.prototype.extractNumbers = function (): number {
9
+ // const num = this.match(/\d/g);
10
+ // return num ? parseInt(num.join(""), 10) : NaN;
11
+ // };
12
+ //
13
+ // Number.prototype.format = function (): string {
14
+ // return this.toLocaleString("en-US");
15
+ // };
16
+ //
17
+ // // Number.prototype.formatDecimals = function (decimals: number = 2): string {
18
+ // // return this.toFixed(decimals);
19
+ // // };
20
+ //
21
+ // Object.prototype.isset = function (): boolean {
22
+ // return this != null && Object.keys(this).length > 0;
23
+ // };
24
+ //
25
+ // Object.prototype.isEmpty = function (): boolean {
26
+ // return this == null || Object.keys(this).length <= 0;
27
+ // };
28
+ //
29
+ // Array.prototype.shuffle = function <T>(this: T[]): T[] {
30
+ // return this.sort(() => Math.random() - 0.5);
31
+ // };
@@ -0,0 +1,7 @@
1
+ export {};
2
+ declare global {
3
+ let curApplicationId: string;
4
+ let curAppKey: string;
5
+ let curAppSecret: string;
6
+ }
7
+ //# sourceMappingURL=globals.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"globals.d.ts","sourceRoot":"","sources":["../src/globals.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC;AAEV,OAAO,CAAC,MAAM,CAAC;IACX,IAAI,gBAAgB,EAAE,MAAM,CAAC;IAC7B,IAAI,SAAS,EAAE,MAAM,CAAC;IACtB,IAAI,YAAY,EAAE,MAAM,CAAC;CAC5B"}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,13 @@
1
+ export * from "./sdk/jdConnector";
2
+ export * from "./sdk/jdSdk";
3
+ export * from "./sdk/configs/jdConfig";
4
+ export * from "./sdk/utilities/browserUtils";
5
+ export * from "./sdk/utilities/cryptoUtils";
6
+ export * from "./sdk/utilities/dateUtils";
7
+ export * from "./sdk/utilities/globalEventHandler";
8
+ export * from "./sdk/utilities/stringUtils";
9
+ export * from "./sdk/utilities/utils";
10
+ export * from "./sdk/models/jdResource";
11
+ export * from "./sdk/models/jdApplication";
12
+ export * from "./sdk/models/modules/karaoke/jdKtvShop";
13
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,aAAa,CAAC;AAC5B,cAAc,wBAAwB,CAAC;AAGvC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,oCAAoC,CAAC;AACnD,cAAc,6BAA6B,CAAC;AAC5C,cAAc,uBAAuB,CAAC;AAGtC,cAAc,yBAAyB,CAAC;AACxC,cAAc,4BAA4B,CAAC;AAE3C,cAAc,wCAAwC,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,14 @@
1
+ export * from "./sdk/jdConnector";
2
+ export * from "./sdk/jdSdk";
3
+ export * from "./sdk/configs/jdConfig";
4
+ // export * from "./sdk/extensions/extensions";
5
+ export * from "./sdk/utilities/browserUtils";
6
+ export * from "./sdk/utilities/cryptoUtils";
7
+ export * from "./sdk/utilities/dateUtils";
8
+ export * from "./sdk/utilities/globalEventHandler";
9
+ export * from "./sdk/utilities/stringUtils";
10
+ export * from "./sdk/utilities/utils";
11
+ // Generic Models for different possible modules for all platforms
12
+ export * from "./sdk/models/jdResource";
13
+ export * from "./sdk/models/jdApplication";
14
+ export * from "./sdk/models/modules/karaoke/jdKtvShop";
@@ -0,0 +1,15 @@
1
+ export default class JDConfig {
2
+ private static _instance;
3
+ cdnHost: string;
4
+ private _localHost;
5
+ private _localVersion;
6
+ private _sandboxHost;
7
+ private _sandboxVersion;
8
+ private _productionHost;
9
+ private _productionVersion;
10
+ private constructor();
11
+ static get instance(): JDConfig;
12
+ static getAPIHost(): string;
13
+ static getAPIHostOnly(): string;
14
+ }
15
+ //# sourceMappingURL=dpConfig.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dpConfig.d.ts","sourceRoot":"","sources":["../../../src/sdk/configs/dpConfig.ts"],"names":[],"mappings":"AACA,MAAM,CAAC,OAAO,OAAO,QAAQ;IAC5B,OAAO,CAAC,MAAM,CAAC,SAAS,CAAW;IAEnC,OAAO,SAAuC;IAC9C,OAAO,CAAC,UAAU,CAA4B;IAC9C,OAAO,CAAC,aAAa,CAAQ;IAC7B,OAAO,CAAC,YAAY,CAAqC;IACzD,OAAO,CAAC,eAAe,CAAQ;IAC/B,OAAO,CAAC,eAAe,CAAkC;IACzD,OAAO,CAAC,kBAAkB,CAAQ;IAIlC,OAAO;IAEP,WAAkB,QAAQ,IAAI,QAAQ,CAMrC;IAED,MAAM,CAAC,UAAU;IAajB,MAAM,CAAC,cAAc;CAYrB"}
@@ -0,0 +1,49 @@
1
+ // Singleton class to be able to called from everywhere with minify compatible
2
+ export default class JDConfig {
3
+ //Singleton constructor shouldn't be called directly and use JDConfig.instance
4
+ // eslint-disable-next-line @typescript-eslint/no-empty-function
5
+ constructor() {
6
+ this.cdnHost = 'https://deskprox-public.b-cdn.net';
7
+ this._localHost = 'http://localhost:8080/';
8
+ this._localVersion = 'v1';
9
+ this._sandboxHost = 'https://api-sb.karaokeprox.com/';
10
+ this._sandboxVersion = 'v1';
11
+ this._productionHost = 'https://api.karaokeprox.com/';
12
+ this._productionVersion = 'v1';
13
+ }
14
+ static get instance() {
15
+ if (!JDConfig._instance) {
16
+ console.log('JDConfig: No instance found and creating new one');
17
+ JDConfig._instance = new JDConfig();
18
+ }
19
+ return JDConfig._instance;
20
+ }
21
+ static getAPIHost() {
22
+ const prConfig = JDConfig.instance;
23
+ if (globalThis.bLocalHost) {
24
+ return prConfig._localHost + prConfig._localVersion;
25
+ }
26
+ else {
27
+ if (globalThis.bSandboxApi) {
28
+ return prConfig._sandboxHost + prConfig._sandboxVersion;
29
+ }
30
+ else {
31
+ return prConfig._productionHost + prConfig._productionVersion;
32
+ }
33
+ }
34
+ }
35
+ static getAPIHostOnly() {
36
+ const prConfig = JDConfig.instance;
37
+ if (globalThis.bLocalHost) {
38
+ return prConfig._localHost;
39
+ }
40
+ else {
41
+ if (globalThis.bSandboxApi) {
42
+ return prConfig._sandboxHost;
43
+ }
44
+ else {
45
+ return prConfig._productionHost;
46
+ }
47
+ }
48
+ }
49
+ }
@@ -0,0 +1,8 @@
1
+ export default class JDConfig {
2
+ private static _instance;
3
+ private constructor();
4
+ static get instance(): JDConfig;
5
+ static getAPIHost(): string;
6
+ static getAPIHostOnly(): string;
7
+ }
8
+ //# sourceMappingURL=jdConfig.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"jdConfig.d.ts","sourceRoot":"","sources":["../../../src/sdk/configs/jdConfig.ts"],"names":[],"mappings":"AACA,MAAM,CAAC,OAAO,OAAO,QAAQ;IAC5B,OAAO,CAAC,MAAM,CAAC,SAAS,CAAW;IAGnC,OAAO;IAEP,WAAkB,QAAQ,IAAI,QAAQ,CAMrC;IAED,MAAM,CAAC,UAAU;IAajB,MAAM,CAAC,cAAc;CAYrB"}
@@ -0,0 +1,40 @@
1
+ // Singleton class to be able to call from everywhere with minified compatible
2
+ export default class JDConfig {
3
+ //Singleton constructor shouldn't be called directly and use JDConfig.instance
4
+ constructor() { }
5
+ static get instance() {
6
+ if (!JDConfig._instance) {
7
+ console.log('JDConfig: No instance found and creating new one');
8
+ JDConfig._instance = new JDConfig();
9
+ }
10
+ return JDConfig._instance;
11
+ }
12
+ static getAPIHost() {
13
+ const prConfig = JDConfig.instance;
14
+ if (globalThis.bLocalHost) {
15
+ return globalThis.apiEndPointLocalhost + globalThis.apiVersion;
16
+ }
17
+ else {
18
+ if (globalThis.bSandboxApi) {
19
+ return globalThis.apiEndPointSandbox + globalThis.apiVersion;
20
+ }
21
+ else {
22
+ return globalThis.apiEndPoint + globalThis.apiVersion;
23
+ }
24
+ }
25
+ }
26
+ static getAPIHostOnly() {
27
+ const prConfig = JDConfig.instance;
28
+ if (globalThis.bLocalHost) {
29
+ return globalThis.apiEndPointLocalhost;
30
+ }
31
+ else {
32
+ if (globalThis.bSandboxApi) {
33
+ return globalThis.apiEndPointSandbox;
34
+ }
35
+ else {
36
+ return globalThis.apiEndPoint;
37
+ }
38
+ }
39
+ }
40
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=extensions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"extensions.d.ts","sourceRoot":"","sources":["../../../src/sdk/extensions/extensions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC"}
@@ -0,0 +1,23 @@
1
+ String.prototype.isset = function () {
2
+ return this != null && this !== "";
3
+ };
4
+ String.prototype.extractNumbers = function () {
5
+ const num = this.match(/\d/g);
6
+ return num ? parseInt(num.join(""), 10) : NaN;
7
+ };
8
+ Number.prototype.format = function () {
9
+ return this.toLocaleString("en-US");
10
+ };
11
+ // Number.prototype.formatDecimals = function (decimals: number = 2): string {
12
+ // return this.toFixed(decimals);
13
+ // };
14
+ Object.prototype.isset = function () {
15
+ return this != null && Object.keys(this).length > 0;
16
+ };
17
+ Object.prototype.isEmpty = function () {
18
+ return this == null || Object.keys(this).length <= 0;
19
+ };
20
+ Array.prototype.shuffle = function () {
21
+ return this.sort(() => Math.random() - 0.5);
22
+ };
23
+ export {};
@@ -0,0 +1,24 @@
1
+ export declare const enum JDHttpType {
2
+ GET = 0,
3
+ POST = 1,
4
+ PUT = 2,
5
+ DELETE = 3
6
+ }
7
+ export declare class SimpleResponse {
8
+ body: string;
9
+ statusCode: number;
10
+ constructor(body: string, statusCode: number);
11
+ isEmpty(): boolean;
12
+ }
13
+ export declare class JDConnector {
14
+ httpGetDirectAsync(url: string, headers: any, params: any, bShowErrorMessage: boolean, bForceRefresh?: boolean, bAutoHideBusyIndicator?: boolean, overrideVersion?: string): Promise<SimpleResponse>;
15
+ httpPostDirectAsync(url: string, headers: any, body: any, bShowErrorMessage: boolean, bAutoHideBusyIndicator?: boolean, overrideVersion?: string): Promise<SimpleResponse>;
16
+ httpGetRelativeAsync(url: string, headers: any, params: any, bShowErrorMessage: boolean, bForceRefresh?: boolean, bAutoHideBusyIndicator?: boolean, overrideVersion?: string): Promise<SimpleResponse>;
17
+ httpPostRelativeAsync(url: string, headers: any, body: any, bShowErrorMessage: boolean, bAutoHideBusyIndicator?: boolean, overrideVersion?: string): Promise<SimpleResponse>;
18
+ httpASyncCallDirect(httpType: any, url: string, params: any, headers: any, body: any, bShowErrorMessage: boolean, bBuildParams: boolean, bRelativeURL?: boolean, bForceRefresh?: boolean, bAutoHideBusyIndicator?: boolean, overrideVersion?: string): Promise<SimpleResponse>;
19
+ getDirectURL(baseURL: string, params: any, bRelativeURL?: boolean): string;
20
+ buildParams(params: Record<string, any>): string;
21
+ private buildURL;
22
+ buildDirectURL(httpType: any, url: string, data: Record<string, any>): string;
23
+ }
24
+ //# sourceMappingURL=jdConnector.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"jdConnector.d.ts","sourceRoot":"","sources":["../../src/sdk/jdConnector.ts"],"names":[],"mappings":"AAIA,0BAAkB,UAAU;IAC3B,GAAG,IAAA;IACH,IAAI,IAAA;IACJ,GAAG,IAAA;IACH,MAAM,IAAA;CACN;AAED,qBAAa,cAAc;IACxB,IAAI,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;gBACP,IAAI,EAAC,MAAM,EAAE,UAAU,EAAC,MAAM;IAKzC,OAAO;CAGR;AAED,qBAAa,WAAW;IACjB,kBAAkB,CAAC,GAAG,EAAC,MAAM,EAAE,OAAO,EAAC,GAAG,EAAE,MAAM,EAAC,GAAG,EAAE,iBAAiB,EAAE,OAAO,EAAE,aAAa,UAAO,EAAE,sBAAsB,UAAO,EAAE,eAAe,SAAK;IAI7J,mBAAmB,CAAC,GAAG,EAAC,MAAM,EAAE,OAAO,EAAC,GAAG,EAAE,IAAI,EAAC,GAAG,EAAE,iBAAiB,EAAC,OAAO,EAAE,sBAAsB,UAAO,EAAE,eAAe,SAAK;IAIrI,oBAAoB,CAAC,GAAG,EAAC,MAAM,EAAE,OAAO,EAAC,GAAG,EAAE,MAAM,EAAC,GAAG,EAAE,iBAAiB,EAAC,OAAO,EAAE,aAAa,UAAQ,EAAE,sBAAsB,UAAO,EAAE,eAAe,SAAK;IAG/J,qBAAqB,CAAC,GAAG,EAAC,MAAM,EAAE,OAAO,EAAC,GAAG,EAAE,IAAI,EAAC,GAAG,EAAE,iBAAiB,EAAC,OAAO,EAAE,sBAAsB,UAAO,EAAE,eAAe,SAAK;IAIvI,mBAAmB,CAAC,QAAQ,EAAC,GAAG,EAAE,GAAG,EAAC,MAAM,EAAE,MAAM,EAAC,GAAG,EAAE,OAAO,EAAC,GAAG,EAAE,IAAI,EAAC,GAAG,EAAE,iBAAiB,EAAC,OAAO,EAAE,YAAY,EAAC,OAAO,EAAE,YAAY,UAAO,EAAE,aAAa,UAAO,EAAE,sBAAsB,UAAO,EAAE,eAAe,SAAK;IAgDtO,YAAY,CAAC,OAAO,EAAC,MAAM,EAAE,MAAM,EAAC,GAAG,EAAE,YAAY,UAAQ;IAK7D,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,MAAM;IAmBhD,OAAO,CAAC,QAAQ;IAsBhB,cAAc,CAAC,QAAQ,EAAC,GAAG,EAAE,GAAG,EAAC,MAAM,EAAE,IAAI,EAAC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;CAejE"}
@@ -0,0 +1,141 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ import { globalEventEmitter } from "./utilities/globalEventHandler";
11
+ import { Utils } from "./utilities/utils";
12
+ import JDConfig from "./configs/jdConfig";
13
+ export class SimpleResponse {
14
+ constructor(body, statusCode) {
15
+ this.body = body;
16
+ this.statusCode = statusCode;
17
+ }
18
+ isEmpty() {
19
+ return this.body == '' || this.statusCode == -1;
20
+ }
21
+ }
22
+ export class JDConnector {
23
+ httpGetDirectAsync(url_1, headers_1, params_1, bShowErrorMessage_1) {
24
+ return __awaiter(this, arguments, void 0, function* (url, headers, params, bShowErrorMessage, bForceRefresh = true, bAutoHideBusyIndicator = true, overrideVersion = '') {
25
+ return yield this.httpASyncCallDirect(0 /* JDHttpType.GET */, url, params, headers, {}, bShowErrorMessage, true, false, bForceRefresh, bAutoHideBusyIndicator, overrideVersion);
26
+ });
27
+ }
28
+ httpPostDirectAsync(url_1, headers_1, body_1, bShowErrorMessage_1) {
29
+ return __awaiter(this, arguments, void 0, function* (url, headers, body, bShowErrorMessage, bAutoHideBusyIndicator = true, overrideVersion = '') {
30
+ return yield this.httpASyncCallDirect(1 /* JDHttpType.POST */, url, {}, headers, body, bShowErrorMessage, true, false, true, bAutoHideBusyIndicator, overrideVersion);
31
+ });
32
+ }
33
+ httpGetRelativeAsync(url_1, headers_1, params_1, bShowErrorMessage_1) {
34
+ return __awaiter(this, arguments, void 0, function* (url, headers, params, bShowErrorMessage, bForceRefresh = false, bAutoHideBusyIndicator = true, overrideVersion = '') {
35
+ return yield this.httpASyncCallDirect(0 /* JDHttpType.GET */, url, params, headers, {}, bShowErrorMessage, false, true, bForceRefresh, bAutoHideBusyIndicator, overrideVersion);
36
+ });
37
+ }
38
+ httpPostRelativeAsync(url_1, headers_1, body_1, bShowErrorMessage_1) {
39
+ return __awaiter(this, arguments, void 0, function* (url, headers, body, bShowErrorMessage, bAutoHideBusyIndicator = true, overrideVersion = '') {
40
+ return yield this.httpASyncCallDirect(1 /* JDHttpType.POST */, url, {}, headers, body, bShowErrorMessage, false, true, false, bAutoHideBusyIndicator, overrideVersion);
41
+ });
42
+ }
43
+ httpASyncCallDirect(httpType_1, url_1, params_1, headers_1, body_1, bShowErrorMessage_1, bBuildParams_1) {
44
+ return __awaiter(this, arguments, void 0, function* (httpType, url, params, headers, body, bShowErrorMessage, bBuildParams, bRelativeURL = true, bForceRefresh = true, bAutoHideBusyIndicator = true, overrideVersion = '') {
45
+ const finalURL = this.buildURL(httpType, url, params, true, bRelativeURL);
46
+ // console.log(bRelativeURL);
47
+ // console.log(finalURL);
48
+ //Only for debugging purposes only
49
+ if (globalThis.bForceRefreshGetRequests) {
50
+ bForceRefresh = true;
51
+ }
52
+ let finalResponse = new SimpleResponse('failed', 400);
53
+ try {
54
+ if (httpType == 1 /* JDHttpType.POST */) {
55
+ const response = yield fetch(finalURL, {
56
+ method: 'POST',
57
+ body: JSON.stringify(body), // string or object
58
+ headers: headers
59
+ });
60
+ const responseText = yield response.text();
61
+ finalResponse = new SimpleResponse(responseText, response.status);
62
+ }
63
+ else {
64
+ //Request with GET/HEAD method cannot have body.
65
+ const response = yield fetch(finalURL, {
66
+ method: 'GET',
67
+ headers: headers
68
+ });
69
+ const responseText = yield response.text();
70
+ finalResponse = new SimpleResponse(responseText, response.status);
71
+ }
72
+ }
73
+ catch (ex) {
74
+ console.log(ex);
75
+ finalResponse = new SimpleResponse(finalURL, 403);
76
+ }
77
+ if (bShowErrorMessage && finalResponse.statusCode != 200) {
78
+ //Emit event so that the client can listen and show the actual dialog
79
+ globalEventEmitter.emit("show_alert_dialog", { type: "error", message: finalResponse.body });
80
+ }
81
+ // console.log(finalResponse);
82
+ return finalResponse;
83
+ });
84
+ }
85
+ // ////////////////////////////////////////////////////////////////////////////////////////////////
86
+ // ////////////////////////// Connector Utilities Functions //////////////////////////
87
+ // ////////////////////////////////////////////////////////////////////////////////////////////////
88
+ getDirectURL(baseURL, params, bRelativeURL = false) {
89
+ return this.buildURL(0 /* JDHttpType.GET */, baseURL, params, true, bRelativeURL);
90
+ }
91
+ // Build a query parameters from a Map type to URL encoded string like ?event=test&type=001
92
+ buildParams(params) {
93
+ let finalParams = "";
94
+ if (Utils.isset(params)) {
95
+ let index = 0;
96
+ for (const key in params) {
97
+ const val = params[key];
98
+ if (index === 0) {
99
+ finalParams += `?${key}=${encodeURIComponent(val)}`;
100
+ }
101
+ else {
102
+ finalParams += `&${key}=${encodeURIComponent(val)}`;
103
+ }
104
+ index++;
105
+ }
106
+ }
107
+ return finalParams;
108
+ }
109
+ //bBuildParams - Whether or not the parameters will be embedded in URL
110
+ //TODO: version should be able to override
111
+ buildURL(httpType, baseUrl, params, bBuildParams = false, bRelativeURL = true, overrideVersion = '') {
112
+ const strHost = JDConfig.getAPIHost();
113
+ let url = strHost + baseUrl;
114
+ if (!bRelativeURL) {
115
+ url = baseUrl;
116
+ }
117
+ // //Add hashtable form values for GET request
118
+ if (httpType == 0 /* JDHttpType.GET */) {
119
+ if (!params.isEmpty() && bBuildParams) {
120
+ url += this.buildParams(params);
121
+ }
122
+ }
123
+ // Replace all instances of "\r\n" with "\n"
124
+ url = url.replace(/\r\n/g, "\n");
125
+ // Encode the URL and replace "#" with "%23"
126
+ url = encodeURI(url).replace(/#/g, "%23");
127
+ return url;
128
+ }
129
+ buildDirectURL(httpType, url, data) {
130
+ //Add hashtable form values for GET request
131
+ if (httpType == 0 /* JDHttpType.GET */) {
132
+ if (!data.isEmpty())
133
+ url += this.buildParams(data);
134
+ }
135
+ // Replace all instances of "\r\n" with "\n"
136
+ url = url.replace(/\r\n/g, "\n");
137
+ // Encode the URL and replace "#" with "%23"
138
+ url = encodeURI(url).replace(/#/g, "%23");
139
+ return url;
140
+ }
141
+ }
@@ -0,0 +1,6 @@
1
+ export declare class JDSdk {
2
+ static initialiseApp(applicationId: string, appId: string, appKey: string, appSecret: string): void;
3
+ static updateConfigs(apiEndPoint: string, apiEndPointSandbox: string, apiEndPointLocalhost: string, bLocalHost: boolean, bSandboxApi: boolean): void;
4
+ static updateUserId(userId: string): void;
5
+ }
6
+ //# sourceMappingURL=jdSdk.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"jdSdk.d.ts","sourceRoot":"","sources":["../../src/sdk/jdSdk.ts"],"names":[],"mappings":"AAAA,qBAAa,KAAK;IACjB,MAAM,CAAC,aAAa,CAAC,aAAa,EAAC,MAAM,EAAE,KAAK,EAAC,MAAM,EAAE,MAAM,EAAC,MAAM,EAAE,SAAS,EAAC,MAAM;IAOxF,MAAM,CAAC,aAAa,CAAC,WAAW,EAAE,MAAM,EAAE,kBAAkB,EAAE,MAAM,EAAE,oBAAoB,EAAE,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,WAAW,EAAE,OAAO;IAQ7I,MAAM,CAAC,YAAY,CAAC,MAAM,EAAC,MAAM;CAGjC"}
@@ -0,0 +1,18 @@
1
+ export class JDSdk {
2
+ static initialiseApp(applicationId, appId, appKey, appSecret) {
3
+ globalThis.applicationId = applicationId;
4
+ globalThis.appId = appId;
5
+ globalThis.appKey = appKey;
6
+ globalThis.appSecret = appSecret;
7
+ }
8
+ static updateConfigs(apiEndPoint, apiEndPointSandbox, apiEndPointLocalhost, bLocalHost, bSandboxApi) {
9
+ globalThis.apiEndPoint = apiEndPoint;
10
+ globalThis.apiEndPointSandbox = apiEndPointSandbox;
11
+ globalThis.apiEndPointLocalhost = apiEndPointLocalhost;
12
+ globalThis.bLocalHost = bLocalHost;
13
+ globalThis.bSandboxApi = bSandboxApi;
14
+ }
15
+ static updateUserId(userId) {
16
+ globalThis.userId = userId;
17
+ }
18
+ }
@@ -0,0 +1,21 @@
1
+ import JDResource from "./jdResource";
2
+ export default class JDApplication extends JDResource {
3
+ appId: string;
4
+ appKey: string;
5
+ appSecret: string;
6
+ storeLinks: object;
7
+ urls: object;
8
+ orientation: string;
9
+ version: string;
10
+ versionCode: number;
11
+ bundleCodeAndroid: number;
12
+ bundleCodeIos: number;
13
+ constructor(data: object);
14
+ setData(data: object): void;
15
+ static getApplications(orderBy: string | undefined, order: string | undefined, pageIndex: number | undefined, countPerPage: number | undefined, fields: string | undefined, { isSandbox, isFeatured, }: {
16
+ isSandbox?: boolean | undefined;
17
+ isFeatured?: boolean | undefined;
18
+ }): Promise<import("../jdConnector").SimpleResponse>;
19
+ static getInfo(id: string): Promise<import("../jdConnector").SimpleResponse>;
20
+ }
21
+ //# sourceMappingURL=jdApplication.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"jdApplication.d.ts","sourceRoot":"","sources":["../../../src/sdk/models/jdApplication.ts"],"names":[],"mappings":"AACA,OAAO,UAAU,MAAM,cAAc,CAAC;AAEtC,MAAM,CAAC,OAAO,OAAO,aAAc,SAAQ,UAAU;IACpD,KAAK,SAAM;IACX,MAAM,SAAM;IACZ,SAAS,SAAM;IACf,UAAU,EAAE,MAAM,CAAM;IACxB,IAAI,EAAE,MAAM,CAAM;IAClB,WAAW,SAAM;IACjB,OAAO,SAAM;IACb,WAAW,SAAK;IAChB,iBAAiB,SAAK;IACtB,aAAa,SAAK;gBAEN,IAAI,EAAC,MAAM;IAKvB,OAAO,CAAC,IAAI,EAAC,MAAM;WAeN,eAAe,CAAC,OAAO,oBAAe,EAAE,KAAK,oBAAS,EAAE,SAAS,oBAAI,EAAE,YAAY,oBAAK,EAAE,MAAM,oBAAK,EAAE,EAAC,SAAiB,EAAE,UAAkB,GAAE;;;KAAA;WAe/I,OAAO,CAAC,EAAE,EAAC,MAAM;CAI9B"}
@@ -0,0 +1,60 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ import { Utils } from "../utilities/utils";
11
+ import JDResource from "./jdResource";
12
+ export default class JDApplication extends JDResource {
13
+ constructor(data) {
14
+ super(data);
15
+ this.appId = '';
16
+ this.appKey = '';
17
+ this.appSecret = '';
18
+ this.storeLinks = {};
19
+ this.urls = {};
20
+ this.orientation = '';
21
+ this.version = '';
22
+ this.versionCode = 0;
23
+ this.bundleCodeAndroid = 0;
24
+ this.bundleCodeIos = 0;
25
+ this.setData(data);
26
+ }
27
+ setData(data) {
28
+ super.setData(data);
29
+ this.appId = Utils.getString(data, 'app_id');
30
+ this.appKey = Utils.getString(data, 'app_key');
31
+ this.appSecret = Utils.getString(data, 'app_secret');
32
+ this.orientation = Utils.getString(data, 'orientation');
33
+ this.version = Utils.getString(data, 'version');
34
+ this.storeLinks = Utils.getObject(data, 'store_links');
35
+ this.urls = Utils.getObject(data, 'urls');
36
+ this.versionCode = Utils.getInteger(data, 'version_code');
37
+ this.bundleCodeAndroid = Utils.getInteger(data, 'bundle_code_android');
38
+ this.bundleCodeIos = Utils.getInteger(data, 'bundle_code_ios');
39
+ }
40
+ static getApplications() {
41
+ return __awaiter(this, arguments, void 0, function* (orderBy = 'updated_at', order = 'desc', pageIndex = 0, countPerPage = 20, fields = '', { isSandbox = false, isFeatured = false, }) {
42
+ const params = JDResource.getSortParameters(orderBy, order, pageIndex, countPerPage, fields);
43
+ if (Utils.isset(isSandbox)) {
44
+ params['sandbox'] = isSandbox ? 'true' : 'false';
45
+ }
46
+ if (Utils.isset(isFeatured)) {
47
+ params['featured'] = isFeatured ? 'true' : 'false';
48
+ }
49
+ // console.log(params);
50
+ const response = yield JDResource.getRelative('/applications', params);
51
+ return response;
52
+ });
53
+ }
54
+ static getInfo(id) {
55
+ return __awaiter(this, void 0, void 0, function* () {
56
+ const response = yield JDResource.getRelative(`/applications/${id}`, {});
57
+ return response;
58
+ });
59
+ }
60
+ }
@@ -0,0 +1,43 @@
1
+ import { SimpleResponse } from "../jdConnector";
2
+ export default class JDResource {
3
+ myId: string;
4
+ slug: string;
5
+ index: number;
6
+ title: object;
7
+ description: object;
8
+ images: object;
9
+ createdAt: Date;
10
+ updatedAt: Date;
11
+ placeholderIconURL: string;
12
+ get localisedTitle(): string;
13
+ get localisedDescription(): string;
14
+ get titleEN(): string;
15
+ get titleMM(): string;
16
+ get descriptionEN(): string;
17
+ get descriptionMM(): string;
18
+ private get iconURL();
19
+ private get iconURL100();
20
+ private get iconURL300();
21
+ get cdnIconURL(): string;
22
+ get cdnIconURL100(): string;
23
+ get cdnIconURL300(): string;
24
+ private get bannerURL();
25
+ private get bannerURL500();
26
+ private get bannerURL800();
27
+ get cdnBannerURL(): string;
28
+ get cdnBannerURL500(): string;
29
+ get cdnBannerURL800(): string;
30
+ getFacebookIconURL(fbId: string): string;
31
+ constructor(data: Record<string, any>);
32
+ setData(data: object): void;
33
+ static getHashBody(remark?: string): Promise<Record<string, any>>;
34
+ static getDefaultHeaders(headers?: {}): Record<string, any>;
35
+ static addDefaultParams(params: any): Promise<void>;
36
+ static getSortParameters(orderBy: string, order: string, pageIndex: number, countPerPage: number, fields: string): Promise<Record<string, any>>;
37
+ static getFieldParameters(fields: string): Promise<Record<string, any>>;
38
+ static getRelative(relativeUrl: string, params: object, bShowErrorToast?: boolean, bForceRefresh?: boolean, overrideVersion?: string, headers?: {}): Promise<SimpleResponse>;
39
+ static postRelative(relativeUrl: string, body: object, bShowErrorToast?: boolean, overrideVersion?: string): Promise<SimpleResponse>;
40
+ static getDirect(directUrl: string, params: object, bShowErrorToast?: boolean, bForceRefresh?: boolean, overrideVersion?: string): Promise<SimpleResponse>;
41
+ static postDirect(directUrl: string, body: object, bShowErrorToast?: boolean, overrideVersion?: string): Promise<SimpleResponse>;
42
+ }
43
+ //# sourceMappingURL=jdResource.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"jdResource.d.ts","sourceRoot":"","sources":["../../../src/sdk/models/jdResource.ts"],"names":[],"mappings":"AAGA,OAAO,EAAc,cAAc,EAAC,MAAM,gBAAgB,CAAC;AAE3D,MAAM,CAAC,OAAO,OAAO,UAAU;IAC9B,IAAI,SAAM;IACP,IAAI,SAAM;IACV,KAAK,SAAK;IACb,KAAK,EAAE,MAAM,CAAM;IAChB,WAAW,EAAE,MAAM,CAAM;IACzB,MAAM,EAAE,MAAM,CAAM;IACpB,SAAS,EAAC,IAAI,CAAc;IAC5B,SAAS,EAAC,IAAI,CAAc;IAC5B,kBAAkB,SAA2E;IAQhG,IAAI,cAAc,IAAG,MAAM,CAAsE;IACjG,IAAI,oBAAoB,IAAG,MAAM,CAAkF;IACnH,IAAI,OAAO,IAAG,MAAM,CAA8C;IAClE,IAAI,OAAO,IAAG,MAAM,CAA6C;IACjE,IAAI,aAAa,IAAG,MAAM,CAAmD;IAC7E,IAAI,aAAa,IAAG,MAAM,CAAmD;IAE7E,OAAO,KAAK,OAAO,GAA6D;IAChF,OAAO,KAAK,UAAU,GAAiE;IACvF,OAAO,KAAK,UAAU,GAAiE;IAEvF,IAAI,UAAU,IAAG,MAAM,CAA4F;IACnH,IAAI,aAAa,IAAG,MAAM,CAAqG;IAC/H,IAAI,aAAa,IAAG,MAAM,CAAgG;IAE1H,OAAO,KAAK,SAAS,GAA+D;IACpF,OAAO,KAAK,YAAY,GAAmE;IAC3F,OAAO,KAAK,YAAY,GAAmE;IAE3F,IAAI,YAAY,IAAG,MAAM,CAAkG;IAC3H,IAAI,eAAe,IAAG,MAAM,CAA2G;IACvI,IAAI,eAAe,IAAG,MAAM,CAA2G;IAEvI,kBAAkB,CAAC,IAAI,EAAC,MAAM;gBAElB,IAAI,EAAC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;IAIpC,OAAO,CAAC,IAAI,EAAC,MAAM;WAiBN,WAAW,CAAC,MAAM,SAAK;IAWpC,MAAM,CAAC,iBAAiB,CAAC,OAAO,KAAK;WAaxB,gBAAgB,CAAC,MAAM,EAAC,GAAG;WAM3B,iBAAiB,CAAC,OAAO,EAAC,MAAM,EAAE,KAAK,EAAC,MAAM,EAAE,SAAS,EAAC,MAAM,EAAE,YAAY,EAAC,MAAM,EAAE,MAAM,EAAC,MAAM;WAkBpG,kBAAkB,CAAC,MAAM,EAAC,MAAM;WAOhC,WAAW,CAAC,WAAW,EAAC,MAAM,EAAE,MAAM,EAAC,MAAM,EAAE,eAAe,UAAO,EAAE,aAAa,UAAQ,EAAE,eAAe,SAAK,EAAE,OAAO,KAAK;WAOhI,YAAY,CAAC,WAAW,EAAC,MAAM,EAAE,IAAI,EAAC,MAAM,EAAG,eAAe,UAAO,EAAE,eAAe,SAAK;WAQ3F,SAAS,CAAC,SAAS,EAAC,MAAM,EAAE,MAAM,EAAC,MAAM,EAAG,eAAe,UAAO,EAAE,aAAa,UAAQ,EAAE,eAAe,SAAK;WAK/G,UAAU,CAAC,SAAS,EAAC,MAAM,EAAE,IAAI,EAAC,MAAM,EAAE,eAAe,UAAO,EAAG,eAAe,SAAK;CAYpG"}