@qoretechnologies/ts-toolkit 0.4.0

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 (67) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +74 -0
  3. package/dist/QorusAuthenticator.d.ts +181 -0
  4. package/dist/QorusAuthenticator.d.ts.map +1 -0
  5. package/dist/QorusAuthenticator.js +386 -0
  6. package/dist/QorusAuthenticator.js.map +1 -0
  7. package/dist/QorusConfigItems.d.ts +13 -0
  8. package/dist/QorusConfigItems.d.ts.map +1 -0
  9. package/dist/QorusConfigItems.js +41 -0
  10. package/dist/QorusConfigItems.js.map +1 -0
  11. package/dist/QorusDataProvider.d.ts +206 -0
  12. package/dist/QorusDataProvider.d.ts.map +1 -0
  13. package/dist/QorusDataProvider.js +262 -0
  14. package/dist/QorusDataProvider.js.map +1 -0
  15. package/dist/QorusOptions.d.ts +108 -0
  16. package/dist/QorusOptions.d.ts.map +1 -0
  17. package/dist/QorusOptions.js +181 -0
  18. package/dist/QorusOptions.js.map +1 -0
  19. package/dist/QorusRequest.d.ts +91 -0
  20. package/dist/QorusRequest.d.ts.map +1 -0
  21. package/dist/QorusRequest.js +103 -0
  22. package/dist/QorusRequest.js.map +1 -0
  23. package/dist/QorusValidator.d.ts +33 -0
  24. package/dist/QorusValidator.d.ts.map +1 -0
  25. package/dist/QorusValidator.js +385 -0
  26. package/dist/QorusValidator.js.map +1 -0
  27. package/dist/index.d.ts +21 -0
  28. package/dist/index.d.ts.map +1 -0
  29. package/dist/index.js +43 -0
  30. package/dist/index.js.map +1 -0
  31. package/dist/managers/LocalStorage.d.ts +24 -0
  32. package/dist/managers/LocalStorage.d.ts.map +1 -0
  33. package/dist/managers/LocalStorage.js +46 -0
  34. package/dist/managers/LocalStorage.js.map +1 -0
  35. package/dist/managers/error/Error.d.ts +7 -0
  36. package/dist/managers/error/Error.d.ts.map +1 -0
  37. package/dist/managers/error/Error.js +16 -0
  38. package/dist/managers/error/Error.js.map +1 -0
  39. package/dist/managers/error/ErrorInternal.d.ts +6 -0
  40. package/dist/managers/error/ErrorInternal.d.ts.map +1 -0
  41. package/dist/managers/error/ErrorInternal.js +14 -0
  42. package/dist/managers/error/ErrorInternal.js.map +1 -0
  43. package/dist/managers/error/ErrorQorusRequest.d.ts +11 -0
  44. package/dist/managers/error/ErrorQorusRequest.d.ts.map +1 -0
  45. package/dist/managers/error/ErrorQorusRequest.js +22 -0
  46. package/dist/managers/error/ErrorQorusRequest.js.map +1 -0
  47. package/dist/managers/error/errorCodes.d.ts +8 -0
  48. package/dist/managers/error/errorCodes.d.ts.map +1 -0
  49. package/dist/managers/error/errorCodes.js +30 -0
  50. package/dist/managers/error/errorCodes.js.map +1 -0
  51. package/dist/managers/logger.d.ts +11 -0
  52. package/dist/managers/logger.d.ts.map +1 -0
  53. package/dist/managers/logger.js +22 -0
  54. package/dist/managers/logger.js.map +1 -0
  55. package/dist/utils/apiPaths.d.ts +63 -0
  56. package/dist/utils/apiPaths.d.ts.map +1 -0
  57. package/dist/utils/apiPaths.js +37 -0
  58. package/dist/utils/apiPaths.js.map +1 -0
  59. package/dist/utils/index.d.ts +3 -0
  60. package/dist/utils/index.d.ts.map +1 -0
  61. package/dist/utils/index.js +27 -0
  62. package/dist/utils/index.js.map +1 -0
  63. package/dist/utils/validation.d.ts +107 -0
  64. package/dist/utils/validation.d.ts.map +1 -0
  65. package/dist/utils/validation.js +108 -0
  66. package/dist/utils/validation.js.map +1 -0
  67. package/package.json +113 -0
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const Error_1 = __importDefault(require("./Error"));
7
+ const errorCodes_1 = require("./errorCodes");
8
+ class ErrorQorusRequest extends Error_1.default {
9
+ constructor(error) {
10
+ if (typeof error === 'string') {
11
+ super(error, true, errorCodes_1.errorCodes.INTERNAL.name, undefined);
12
+ }
13
+ else if (typeof error.desc === 'undefined') {
14
+ super(`${JSON.stringify(error)}`, true, errorCodes_1.errorCodes.INTERNAL.name, undefined);
15
+ }
16
+ else {
17
+ super(error.desc, true, error.err, error.status);
18
+ }
19
+ }
20
+ }
21
+ exports.default = ErrorQorusRequest;
22
+ //# sourceMappingURL=ErrorQorusRequest.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ErrorQorusRequest.js","sourceRoot":"","sources":["../../../src/managers/error/ErrorQorusRequest.ts"],"names":[],"mappings":";;;;;AAAA,oDAAgC;AAChC,6CAA0C;AAE1C,MAAM,iBAAkB,SAAQ,eAAS;IACvC,YAAY,KAAwC;QAClD,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE;YAC7B,KAAK,CAAC,KAAK,EAAE,IAAI,EAAE,uBAAU,CAAC,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;SACzD;aAAM,IAAI,OAAO,KAAK,CAAC,IAAI,KAAK,WAAW,EAAE;YAC5C,KAAK,CAAC,GAAG,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE,EAAE,IAAI,EAAE,uBAAU,CAAC,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;SAC9E;aAAM;YACL,KAAK,CAAC,KAAK,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,CAAC,GAAG,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;SAClD;IACH,CAAC;CACF;AAQD,kBAAe,iBAAiB,CAAC"}
@@ -0,0 +1,8 @@
1
+ export declare const errorCodes: TErrorCodes;
2
+ type TErrorCodes = Record<string, IErrorCode>;
3
+ export interface IErrorCode {
4
+ code?: number;
5
+ name?: string;
6
+ }
7
+ export {};
8
+ //# sourceMappingURL=errorCodes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errorCodes.d.ts","sourceRoot":"","sources":["../../../src/managers/error/errorCodes.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,UAAU,EAAE,WAyBxB,CAAC;AAEF,KAAK,WAAW,GAAG,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;AAE9C,MAAM,WAAW,UAAU;IACzB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;CACf"}
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.errorCodes = void 0;
4
+ exports.errorCodes = {
5
+ AUTHENTICATION: {
6
+ code: 401,
7
+ name: 'AUTHENTICATION-ERROR',
8
+ },
9
+ BAD_REQUEST: {
10
+ code: 400,
11
+ name: 'ERROR-BAD-REQUEST',
12
+ },
13
+ NOT_FOUND: {
14
+ code: 404,
15
+ name: 'NOT-FOUND-ERROR',
16
+ },
17
+ INTERNAL_SERVER: {
18
+ code: 500,
19
+ name: 'INTERNAL-SERVER-ERROR',
20
+ },
21
+ GENERAL: {
22
+ code: undefined,
23
+ name: 'ERROR',
24
+ },
25
+ INTERNAL: {
26
+ code: undefined,
27
+ name: 'INTERNAL-ERROR',
28
+ },
29
+ };
30
+ //# sourceMappingURL=errorCodes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errorCodes.js","sourceRoot":"","sources":["../../../src/managers/error/errorCodes.ts"],"names":[],"mappings":";;;AAAa,QAAA,UAAU,GAAgB;IACrC,cAAc,EAAE;QACd,IAAI,EAAE,GAAG;QACT,IAAI,EAAE,sBAAsB;KAC7B;IACD,WAAW,EAAE;QACX,IAAI,EAAE,GAAG;QACT,IAAI,EAAE,mBAAmB;KAC1B;IACD,SAAS,EAAE;QACT,IAAI,EAAE,GAAG;QACT,IAAI,EAAE,iBAAiB;KACxB;IACD,eAAe,EAAE;QACf,IAAI,EAAE,GAAG;QACT,IAAI,EAAE,uBAAuB;KAC9B;IACD,OAAO,EAAE;QACP,IAAI,EAAE,SAAS;QACf,IAAI,EAAE,OAAO;KACd;IACD,QAAQ,EAAE;QACR,IAAI,EAAE,SAAS;QACf,IAAI,EAAE,gBAAgB;KACvB;CACF,CAAC"}
@@ -0,0 +1,11 @@
1
+ declare const _default: {
2
+ error: (message: any) => void;
3
+ log: (message: any) => void;
4
+ };
5
+ export default _default;
6
+ export declare const errorTypes: {
7
+ authenticationError: string;
8
+ generalAuthenticatorError: string;
9
+ invalidAuthenticationToken: string;
10
+ };
11
+ //# sourceMappingURL=logger.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../src/managers/logger.ts"],"names":[],"mappings":";;;;AAaA,wBAAwB;AAExB,eAAO,MAAM,UAAU;;;;CAItB,CAAC"}
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.errorTypes = void 0;
4
+ const logger = () => {
5
+ const error = (message) => {
6
+ console.error(message);
7
+ };
8
+ const log = (message) => {
9
+ console.log(message);
10
+ };
11
+ return {
12
+ error,
13
+ log,
14
+ };
15
+ };
16
+ exports.default = logger();
17
+ exports.errorTypes = {
18
+ authenticationError: 'Authentication Error',
19
+ generalAuthenticatorError: 'General Authenticator Error',
20
+ invalidAuthenticationToken: 'Invalid Authentication Token',
21
+ };
22
+ //# sourceMappingURL=logger.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logger.js","sourceRoot":"","sources":["../../src/managers/logger.ts"],"names":[],"mappings":";;;AAAA,MAAM,MAAM,GAAG,GAAG,EAAE;IAClB,MAAM,KAAK,GAAG,CAAC,OAAY,EAAE,EAAE;QAC7B,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IACzB,CAAC,CAAC;IACF,MAAM,GAAG,GAAG,CAAC,OAAY,EAAE,EAAE;QAC3B,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;IACvB,CAAC,CAAC;IACF,OAAO;QACL,KAAK;QACL,GAAG;KACJ,CAAC;AACJ,CAAC,CAAC;AAEF,kBAAe,MAAM,EAAE,CAAC;AAEX,QAAA,UAAU,GAAG;IACxB,mBAAmB,EAAE,sBAAsB;IAC3C,yBAAyB,EAAE,6BAA6B;IACxD,0BAA0B,EAAE,8BAA8B;CAC3D,CAAC"}
@@ -0,0 +1,63 @@
1
+ export interface IApiPaths {
2
+ /**
3
+ * Api paths for the QorusAuthenticator
4
+ */
5
+ authenticator: IAuthenticatorApiPaths;
6
+ /**
7
+ * Api paths for the QorusDataProvider
8
+ */
9
+ dataProviders: IDataProviderApiPaths;
10
+ /**
11
+ * Api paths for the QorusJobs
12
+ */
13
+ jobs?: IJobsApiPaths;
14
+ }
15
+ export interface IJobsApiPaths {
16
+ /**
17
+ * Path to browse Jobs for a QorusServer endpoint
18
+ */
19
+ browse: string;
20
+ }
21
+ export interface IDataProviderApiPaths {
22
+ /**
23
+ * Path to DataProvider browse for a QorusServer endpoint
24
+ */
25
+ browse: string;
26
+ }
27
+ export interface IAuthenticatorApiPaths {
28
+ /**
29
+ * Path to authenticate the user for a Qorus server endpoint
30
+ */
31
+ login: string;
32
+ /**
33
+ * Path to logout the user for a Qorus server endpoint
34
+ */
35
+ logout: string;
36
+ /**
37
+ * Path to validate a authentication token for a user for the Qorus server endpoint
38
+ */
39
+ validateToken: string;
40
+ /**
41
+ * Path to identify if no-auth is enabled for the user for a Qorus server endpoint
42
+ */
43
+ validateNoAuth: string;
44
+ }
45
+ /**
46
+ * Allowed types of version for the Qorus server api
47
+ */
48
+ export type TVersion = 1 | 2 | 3 | 4 | 5 | 6 | 'latest';
49
+ export interface IWithEndpointVersion {
50
+ /**
51
+ * Version for the server api
52
+ */
53
+ version?: TVersion;
54
+ }
55
+ /**Initial api routes */
56
+ export declare const apiPathsInitial: IApiPaths;
57
+ /**
58
+ * Utility function to create api routes
59
+ * @param props optional version can be supplied to target the api with a specific version
60
+ * @returns object with all the api endpoints
61
+ */
62
+ export declare const createApiPaths: (props: IWithEndpointVersion) => IApiPaths;
63
+ //# sourceMappingURL=apiPaths.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"apiPaths.d.ts","sourceRoot":"","sources":["../../src/utils/apiPaths.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,SAAS;IACxB;;OAEG;IACH,aAAa,EAAE,sBAAsB,CAAC;IACtC;;OAEG;IACH,aAAa,EAAE,qBAAqB,CAAC;IACrC;;OAEG;IACH,IAAI,CAAC,EAAE,aAAa,CAAC;CACtB;AAED,MAAM,WAAW,aAAa;IAC5B;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,qBAAqB;IACpC;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,sBAAsB;IACrC;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IACd;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC;IACf;;OAEG;IACH,aAAa,EAAE,MAAM,CAAC;IACtB;;OAEG;IACH,cAAc,EAAE,MAAM,CAAC;CACxB;AAED;;GAEG;AACH,MAAM,MAAM,QAAQ,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,QAAQ,CAAC;AACxD,MAAM,WAAW,oBAAoB;IACnC;;OAEG;IACH,OAAO,CAAC,EAAE,QAAQ,CAAC;CACpB;AAED,wBAAwB;AACxB,eAAO,MAAM,eAAe,EAAE,SAU7B,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,cAAc,UAAW,oBAAoB,KAAG,SAe5D,CAAC"}
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createApiPaths = exports.apiPathsInitial = void 0;
4
+ /**Initial api routes */
5
+ exports.apiPathsInitial = {
6
+ authenticator: {
7
+ login: `/api/latest/public/login`,
8
+ logout: `/api/latest/logout`,
9
+ validateToken: `/api/latest/system?action=validateWsToken`,
10
+ validateNoAuth: `/api/latest/public/info`,
11
+ },
12
+ dataProviders: {
13
+ browse: '/api/latest/dataprovider/browse',
14
+ },
15
+ };
16
+ /**
17
+ * Utility function to create api routes
18
+ * @param props optional version can be supplied to target the api with a specific version
19
+ * @returns object with all the api endpoints
20
+ */
21
+ const createApiPaths = (props) => {
22
+ const { version } = props;
23
+ const V = version && version !== 'latest' ? `v${version}` : 'latest';
24
+ return {
25
+ authenticator: {
26
+ login: `/api/${V}/public/login`,
27
+ logout: `/api/${V}/logout`,
28
+ validateToken: `/api/${V}/system?action=validateWsToken`,
29
+ validateNoAuth: `/api/${V}/public/info`,
30
+ },
31
+ dataProviders: {
32
+ browse: `/api/${V}/dataprovider/browse`,
33
+ },
34
+ };
35
+ };
36
+ exports.createApiPaths = createApiPaths;
37
+ //# sourceMappingURL=apiPaths.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"apiPaths.js","sourceRoot":"","sources":["../../src/utils/apiPaths.ts"],"names":[],"mappings":";;;AA2DA,wBAAwB;AACX,QAAA,eAAe,GAAc;IACxC,aAAa,EAAE;QACb,KAAK,EAAE,0BAA0B;QACjC,MAAM,EAAE,oBAAoB;QAC5B,aAAa,EAAE,2CAA2C;QAC1D,cAAc,EAAE,yBAAyB;KAC1C;IACD,aAAa,EAAE;QACb,MAAM,EAAE,iCAAiC;KAC1C;CACF,CAAC;AAEF;;;;GAIG;AACI,MAAM,cAAc,GAAG,CAAC,KAA2B,EAAa,EAAE;IACvE,MAAM,EAAE,OAAO,EAAE,GAAG,KAAK,CAAC;IAC1B,MAAM,CAAC,GAAG,OAAO,IAAI,OAAO,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,OAAO,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC;IAErE,OAAO;QACL,aAAa,EAAE;YACb,KAAK,EAAE,QAAQ,CAAC,eAAe;YAC/B,MAAM,EAAE,QAAQ,CAAC,SAAS;YAC1B,aAAa,EAAE,QAAQ,CAAC,gCAAgC;YACxD,cAAc,EAAE,QAAQ,CAAC,cAAc;SACxC;QACD,aAAa,EAAE;YACb,MAAM,EAAE,QAAQ,CAAC,sBAAsB;SACxC;KACF,CAAC;AACJ,CAAC,CAAC;AAfW,QAAA,cAAc,kBAezB"}
@@ -0,0 +1,3 @@
1
+ export declare const isValidString: (value?: string | null) => boolean;
2
+ export declare const isValidStringArray: (value?: any[]) => boolean;
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,aAAa,WAAY,MAAM,GAAG,IAAI,YAIlD,CAAC;AAEF,eAAO,MAAM,kBAAkB,WAAY,GAAG,EAAE,YAW/C,CAAC"}
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isValidStringArray = exports.isValidString = void 0;
4
+ const isValidString = (value) => {
5
+ if (value && typeof value === 'string' && value !== '') {
6
+ return true;
7
+ }
8
+ else
9
+ return false;
10
+ };
11
+ exports.isValidString = isValidString;
12
+ const isValidStringArray = (value) => {
13
+ if (Array.isArray(value)) {
14
+ let result = true;
15
+ value.forEach((val) => {
16
+ const valid = (0, exports.isValidString)(val);
17
+ if (valid === false) {
18
+ result = valid;
19
+ }
20
+ });
21
+ return result;
22
+ }
23
+ else
24
+ return false;
25
+ };
26
+ exports.isValidStringArray = isValidStringArray;
27
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":";;;AAAO,MAAM,aAAa,GAAG,CAAC,KAAqB,EAAE,EAAE;IACrD,IAAI,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,EAAE,EAAE;QACtD,OAAO,IAAI,CAAC;KACb;;QAAM,OAAO,KAAK,CAAC;AACtB,CAAC,CAAC;AAJW,QAAA,aAAa,iBAIxB;AAEK,MAAM,kBAAkB,GAAG,CAAC,KAAa,EAAE,EAAE;IAClD,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE;QACxB,IAAI,MAAM,GAAG,IAAI,CAAC;QAClB,KAAK,CAAC,OAAO,CAAC,CAAC,GAA8B,EAAE,EAAE;YAC/C,MAAM,KAAK,GAAG,IAAA,qBAAa,EAAC,GAAG,CAAC,CAAC;YACjC,IAAI,KAAK,KAAK,KAAK,EAAE;gBACnB,MAAM,GAAG,KAAK,CAAC;aAChB;QACH,CAAC,CAAC,CAAC;QACH,OAAO,MAAM,CAAC;KACf;;QAAM,OAAO,KAAK,CAAC;AACtB,CAAC,CAAC;AAXW,QAAA,kBAAkB,sBAW7B"}
@@ -0,0 +1,107 @@
1
+ /**
2
+ * Function to trimmed address for a url
3
+ * @param v address url
4
+ * @returns address without https://
5
+ */
6
+ export declare const getAddress: (v: string) => string;
7
+ /**
8
+ * Function to convert operator to array if not
9
+ * @param operator operator, can be string or string[]
10
+ * @returns array of strings
11
+ */
12
+ export declare const fixOperatorValue: (operator: TOperatorValue) => string | TOperatorValue[] | null | undefined;
13
+ export declare const templatesList: string[];
14
+ export type TValueTemplate = any;
15
+ /**
16
+ * Function to verify if the value is a Template string
17
+ * @param value value for the property
18
+ * @returns true if value is a template string
19
+ */
20
+ export declare const isValueTemplate: (value?: TValueTemplate) => boolean;
21
+ /**
22
+ * Function to return protocol address
23
+ * @param v string with protocol address
24
+ * @returns trimmed protocol string with https://
25
+ */
26
+ export declare const getProtocol: (v: string) => string;
27
+ /**
28
+ * Function to return template value
29
+ * @param value value for the template
30
+ * @returns string containing template value
31
+ */
32
+ export declare const getTemplateValue: (value?: string) => string | null;
33
+ /**
34
+ * Function to return key for the template value
35
+ * @param value template string
36
+ * @returns key for the template property
37
+ */
38
+ export declare const getTemplateKey: (value?: string) => string | null;
39
+ export type TTrigger = {
40
+ class?: string;
41
+ connector?: string;
42
+ method?: string;
43
+ };
44
+ /**
45
+ * Splits the size string in bytes and size
46
+ * @param value string with bytes and size 32MB
47
+ * @returns array with [byte, size]
48
+ */
49
+ export declare const splitByteSize: (value: string) => [number, string] | null;
50
+ export type TOption = {
51
+ type: TQorusType;
52
+ value: any;
53
+ op?: TOperatorValue;
54
+ };
55
+ export type TOperatorValue = string | string[] | undefined | null;
56
+ export type TQorusType = 'string' | 'int' | 'list' | 'bool' | 'float' | 'binary' | 'hash' | 'date' | 'any' | 'auto' | 'mapper' | 'workflow' | 'service' | 'job' | 'select-string' | 'data-provider' | 'file-as-string' | 'number';
57
+ type TOptions = {
58
+ [optionName: string]: TOption;
59
+ } | undefined;
60
+ export interface IOptionsSchemaArg {
61
+ type: TQorusType | TQorusType[];
62
+ default_value?: any;
63
+ required?: boolean;
64
+ allowed_values?: any[];
65
+ sensitive?: boolean;
66
+ desc?: string;
67
+ arg_schema?: IOptionsSchema;
68
+ }
69
+ export interface IOptionsSchema {
70
+ [optionName: string]: IOptionsSchemaArg;
71
+ }
72
+ export type TRecordType = 'search' | 'search-single' | 'create' | 'update' | 'delete';
73
+ export type TRealRecordType = 'read' | 'create' | 'update' | 'delete';
74
+ export type TProviderTypeSupports = {
75
+ [key in `supports_${TRealRecordType}`]?: boolean;
76
+ };
77
+ export type TProviderTypeArgs = {
78
+ [key in `${TRecordType}_args`]?: TOptions | TOptions[];
79
+ };
80
+ export interface IProviderType extends TProviderTypeSupports, TProviderTypeArgs {
81
+ type: string;
82
+ name: string;
83
+ path?: string;
84
+ options?: TOptions;
85
+ subtype?: 'request' | 'response';
86
+ hasApiContext?: boolean;
87
+ optionsChanged?: boolean;
88
+ desc?: string;
89
+ use_args?: boolean;
90
+ args?: any;
91
+ supports_request?: boolean;
92
+ is_api_call?: boolean;
93
+ search_options?: TOptions;
94
+ descriptions?: {
95
+ [key: string]: string;
96
+ };
97
+ }
98
+ export type TApiManagerFactory = 'swagger' | 'soap';
99
+ export type TApiManagerEndpointType = 'fsm' | 'method';
100
+ export type TApiManagerOptions = TOptions;
101
+ export type TApiManagerEndpoint = {
102
+ endpoint: string;
103
+ type?: TApiManagerEndpointType;
104
+ value?: string;
105
+ };
106
+ export {};
107
+ //# sourceMappingURL=validation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validation.d.ts","sourceRoot":"","sources":["../../src/utils/validation.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,eAAO,MAAM,UAAU,MAAO,MAAM,WAEnC,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,aAAc,cAAc,KAAG,MAAM,GAAG,cAAc,EAAE,GAAG,IAAI,GAAG,SAE9F,CAAC;AAEF,eAAO,MAAM,aAAa,UAmBzB,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG,GAAG,CAAC;AAEjC;;;;GAIG;AACH,eAAO,MAAM,eAAe,WAAY,cAAc,YAQrD,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,WAAW,MAAO,MAAM,WAEpC,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,WAAY,MAAM,kBAK9C,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,cAAc,WAAY,MAAM,kBAM5C,CAAC;AACF,MAAM,MAAM,QAAQ,GAAG;IAAE,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAE/E;;;;GAIG;AACH,eAAO,MAAM,aAAa,UAAW,MAAM,KAAG,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,IAKhE,CAAC;AAEF,MAAM,MAAM,OAAO,GAAG;IACpB,IAAI,EAAE,UAAU,CAAC;IACjB,KAAK,EAAE,GAAG,CAAC;IACX,EAAE,CAAC,EAAE,cAAc,CAAC;CACrB,CAAC;AACF,MAAM,MAAM,cAAc,GAAG,MAAM,GAAG,MAAM,EAAE,GAAG,SAAS,GAAG,IAAI,CAAC;AAElE,MAAM,MAAM,UAAU,GAClB,QAAQ,GACR,KAAK,GACL,MAAM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AE,QAAQ,CAAC;IACnB,OAAO,CAAC,EAAE,SAAS,GAAG,UAAU,CAAC;IACjC,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,IAAI,CAAC,EAAE,GAAG,CAAC;IACX,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,cAAc,CAAC,EAAE,QAAQ,CAAC;IAC1B,YAAY,CAAC,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,CAAC;CAC1C;AAED,MAAM,MAAM,kBAAkB,GAAG,SAAS,GAAG,MAAM,CAAC;AACpD,MAAM,MAAM,uBAAuB,GAAG,KAAK,GAAG,QAAQ,CAAC;AACvD,MAAM,MAAM,kBAAkB,GAAG,QAAQ,CAAC;AAC1C,MAAM,MAAM,mBAAmB,GAAG;IAChC,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,CAAC,EAAE,uBAAuB,CAAC;IAC/B,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC"}
@@ -0,0 +1,108 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.splitByteSize = exports.getTemplateKey = exports.getTemplateValue = exports.getProtocol = exports.isValueTemplate = exports.templatesList = exports.fixOperatorValue = exports.getAddress = void 0;
4
+ const lodash_1 = require("lodash");
5
+ /**
6
+ * Function to trimmed address for a url
7
+ * @param v address url
8
+ * @returns address without https://
9
+ */
10
+ const getAddress = (v) => {
11
+ var _a;
12
+ return ((_a = v === null || v === void 0 ? void 0 : v.split('://')) === null || _a === void 0 ? void 0 : _a[1]) || '';
13
+ };
14
+ exports.getAddress = getAddress;
15
+ /**
16
+ * Function to convert operator to array if not
17
+ * @param operator operator, can be string or string[]
18
+ * @returns array of strings
19
+ */
20
+ const fixOperatorValue = (operator) => {
21
+ return (0, lodash_1.isArray)(operator) ? operator : [operator];
22
+ };
23
+ exports.fixOperatorValue = fixOperatorValue;
24
+ exports.templatesList = [
25
+ 'local',
26
+ 'timestamp',
27
+ 'rest',
28
+ 'qore-expr',
29
+ 'static',
30
+ 'dynamic',
31
+ 'sensitive',
32
+ 'sensitive-alias',
33
+ 'temp',
34
+ 'step',
35
+ 'keys',
36
+ 'transient',
37
+ 'config',
38
+ 'info',
39
+ 'parse-value',
40
+ 'pstate',
41
+ 'state',
42
+ 'qore-expr-value',
43
+ ];
44
+ /**
45
+ * Function to verify if the value is a Template string
46
+ * @param value value for the property
47
+ * @returns true if value is a template string
48
+ */
49
+ const isValueTemplate = (value) => {
50
+ if (typeof value !== 'string' || !(value === null || value === void 0 ? void 0 : value.startsWith('$')) || !(value === null || value === void 0 ? void 0 : value.includes(':'))) {
51
+ return false;
52
+ }
53
+ // Get everything between first $ and first colon
54
+ const template = value.substring(value.indexOf('$') + 1, value.indexOf(':'));
55
+ // Check if the template matches a template from the list
56
+ return exports.templatesList.includes(template);
57
+ };
58
+ exports.isValueTemplate = isValueTemplate;
59
+ /**
60
+ * Function to return protocol address
61
+ * @param v string with protocol address
62
+ * @returns trimmed protocol string with https://
63
+ */
64
+ const getProtocol = (v) => {
65
+ var _a;
66
+ return ((_a = v === null || v === void 0 ? void 0 : v.split('://')) === null || _a === void 0 ? void 0 : _a[0]) || '';
67
+ };
68
+ exports.getProtocol = getProtocol;
69
+ /**
70
+ * Function to return template value
71
+ * @param value value for the template
72
+ * @returns string containing template value
73
+ */
74
+ const getTemplateValue = (value) => {
75
+ if (value && (0, exports.isValueTemplate)(value)) {
76
+ return value.substring(value.indexOf(':') + 1);
77
+ }
78
+ return null;
79
+ };
80
+ exports.getTemplateValue = getTemplateValue;
81
+ /**
82
+ * Function to return key for the template value
83
+ * @param value template string
84
+ * @returns key for the template property
85
+ */
86
+ const getTemplateKey = (value) => {
87
+ if (value && (0, exports.isValueTemplate)(value)) {
88
+ return value.substring(value.indexOf('$') + 1, value.indexOf(':'));
89
+ }
90
+ return null;
91
+ };
92
+ exports.getTemplateKey = getTemplateKey;
93
+ /**
94
+ * Splits the size string in bytes and size
95
+ * @param value string with bytes and size 32MB
96
+ * @returns array with [byte, size]
97
+ */
98
+ const splitByteSize = (value) => {
99
+ var _a, _b;
100
+ const bytes = (value || '').match(/\d+/g);
101
+ const size = (value || '').match(/[a-zA-Z]+/g);
102
+ if (size)
103
+ return [Number((_a = bytes === null || bytes === void 0 ? void 0 : bytes[0]) !== null && _a !== void 0 ? _a : null), (_b = size === null || size === void 0 ? void 0 : size[0]) !== null && _b !== void 0 ? _b : null];
104
+ else
105
+ return null;
106
+ };
107
+ exports.splitByteSize = splitByteSize;
108
+ //# sourceMappingURL=validation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validation.js","sourceRoot":"","sources":["../../src/utils/validation.ts"],"names":[],"mappings":";;;AAAA,mCAAiC;AAEjC;;;;GAIG;AACI,MAAM,UAAU,GAAG,CAAC,CAAS,EAAE,EAAE;;IACtC,OAAO,CAAA,MAAA,CAAC,aAAD,CAAC,uBAAD,CAAC,CAAE,KAAK,CAAC,KAAK,CAAC,0CAAG,CAAC,CAAC,KAAI,EAAE,CAAC;AACpC,CAAC,CAAC;AAFW,QAAA,UAAU,cAErB;AAEF;;;;GAIG;AACI,MAAM,gBAAgB,GAAG,CAAC,QAAwB,EAAgD,EAAE;IACzG,OAAO,IAAA,gBAAO,EAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC;AACnD,CAAC,CAAC;AAFW,QAAA,gBAAgB,oBAE3B;AAEW,QAAA,aAAa,GAAG;IAC3B,OAAO;IACP,WAAW;IACX,MAAM;IACN,WAAW;IACX,QAAQ;IACR,SAAS;IACT,WAAW;IACX,iBAAiB;IACjB,MAAM;IACN,MAAM;IACN,MAAM;IACN,WAAW;IACX,QA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AAC,KAAc,EAAE,EAAE;IAC/C,IAAI,KAAK,IAAI,IAAA,uBAAe,EAAC,KAAK,CAAC,EAAE;QACnC,OAAO,KAAK,CAAC,SAAS,CAAC,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC;KACpE;IAED,OAAO,IAAI,CAAC;AACd,CAAC,CAAC;AANW,QAAA,cAAc,kBAMzB;AAGF;;;;GAIG;AACI,MAAM,aAAa,GAAG,CAAC,KAAa,EAA2B,EAAE;;IACtE,MAAM,KAAK,GAAoB,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;IAC3D,MAAM,IAAI,GAAoB,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC;IAChE,IAAI,IAAI;QAAE,OAAO,CAAC,MAAM,CAAC,MAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAG,CAAC,CAAC,mCAAI,IAAI,CAAC,EAAE,MAAA,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAG,CAAC,CAAC,mCAAI,IAAI,CAAC,CAAC;;QAC5D,OAAO,IAAI,CAAC;AACnB,CAAC,CAAC;AALW,QAAA,aAAa,iBAKxB"}
package/package.json ADDED
@@ -0,0 +1,113 @@
1
+ {
2
+ "name": "@qoretechnologies/ts-toolkit",
3
+ "version": "0.4.0",
4
+ "description": "Utility library to interact with Qorus Integration Engine & Qore Language",
5
+ "keywords": [
6
+ "qoretechnologies",
7
+ "qorus-authenticator"
8
+ ],
9
+ "main": "dist/index.js",
10
+ "typings": "dist/index.d.ts",
11
+ "files": [
12
+ "dist/**/*"
13
+ ],
14
+ "jest": {
15
+ "preset": "ts-jest",
16
+ "coverageReporters": [
17
+ "json-summary",
18
+ "text",
19
+ "lcov"
20
+ ],
21
+ "testTimeout": 60000
22
+ },
23
+ "pre-commit": [
24
+ "updatePullRequestVersion"
25
+ ],
26
+ "pre-push": [
27
+ "test"
28
+ ],
29
+ "scripts": {
30
+ "typedoc": "typedoc",
31
+ "test": "./node_modules/.bin/jest --json --outputFile=tests.json",
32
+ "test:coverage": "npm test -- --coverage",
33
+ "test:badges": "npm run test:coverage && jest-coverage-badges",
34
+ "build": "npx tsc --p ./tsconfig.prod.json",
35
+ "build:test": "npx tsc --p ./tsconfig.prod.json --noEmit",
36
+ "format": "prettier --write \"src/**/*.ts\"",
37
+ "lint": "eslint . --ext .ts",
38
+ "docs": "typedoc && ts-node ./DocGenerator.ts",
39
+ "docs:watch": "npm run css & typedoc --watch",
40
+ "prepublishOnly": "npm test && npm run lint",
41
+ "updatePullRequestVersion": "chmod +x prePush.sh && ./prePush.sh",
42
+ "storybook": "yarn docs && start-storybook -p 6006 --no-dll",
43
+ "build-storybook": "build-storybook",
44
+ "prepare": "npm run build",
45
+ "chromatic": "npx chromatic --project-token=59cd7005d0f1",
46
+ "update-reqore": "yarn add -D @qoretechnologies/reqore@beta"
47
+ },
48
+ "repository": {
49
+ "type": "git",
50
+ "url": "git+https://github.com/qoretechnologies/ts-toolkit.git"
51
+ },
52
+ "author": "",
53
+ "license": "ISC",
54
+ "bugs": {
55
+ "url": "https://github.com/qoretechnologies/ts-toolkit/issues"
56
+ },
57
+ "homepage": "https://github.com/qoretechnologies/ts-toolkit#readme",
58
+ "devDependencies": {
59
+ "@babel/core": "^7.20.2",
60
+ "@qoretechnologies/reqore": "^0.30.16",
61
+ "@storybook/addon-actions": "^6.5.13",
62
+ "@storybook/addon-essentials": "^6.5.13",
63
+ "@storybook/addon-interactions": "^6.5.13",
64
+ "@storybook/addon-jest": "^6.5.13",
65
+ "@storybook/addon-links": "^6.5.13",
66
+ "@storybook/addon-storysource": "^6.5.13",
67
+ "@storybook/builder-webpack5": "^6.5.14",
68
+ "@storybook/manager-webpack5": "^6.5.14",
69
+ "@storybook/react": "^6.5.13",
70
+ "@storybook/testing-library": "^0.0.13",
71
+ "@tsconfig/node16": "^1.0.3",
72
+ "@types/jest": "^28.1.7",
73
+ "@types/node": "^18.7.11",
74
+ "@types/react": "^18.0.25",
75
+ "@types/react-dom": "^18.0.8",
76
+ "@typescript-eslint/eslint-plugin": "^5.35.1",
77
+ "@typescript-eslint/parser": "^5.42.1",
78
+ "chromatic": "^6.12.0",
79
+ "dotenv": "^16.0.2",
80
+ "eslint": "^8.22.0",
81
+ "eslint-config-airbnb-typescript": "^17.0.0",
82
+ "eslint-config-prettier": "^8.5.0",
83
+ "eslint-plugin-import": "^2.26.0",
84
+ "eslint-plugin-prettier": "^4.2.1",
85
+ "jest": "^29.3.1",
86
+ "jest-coverage-badges": "^1.0.0",
87
+ "pre-commit": "^1.2.2",
88
+ "pre-push": "^0.1.3",
89
+ "prettier": "^2.7.1",
90
+ "react": "18.2.0",
91
+ "react-dom": "^18.2.0",
92
+ "react-runkit": "^0.9.0",
93
+ "react-syntax-highlighter": "^15.5.0",
94
+ "sass": "^1.55.0",
95
+ "storybook-addon-outline": "^1.4.2",
96
+ "storybook-dark-mode": "^1.1.2",
97
+ "ts-file-parser": "^0.0.21",
98
+ "ts-jest": "^28.0.8",
99
+ "ts-node": "^10.9.1",
100
+ "typedoc": "^0.23.10",
101
+ "typedoc-json-parser": "^7.0.2",
102
+ "typescript": "^4.7.4"
103
+ },
104
+ "dependencies": {
105
+ "async": "^3.2.4",
106
+ "colors": "^1.4.0",
107
+ "cron-validator": "^1.3.1",
108
+ "js-yaml": "^4.1.0",
109
+ "lodash": "^4.17.21",
110
+ "node-fetch": "2",
111
+ "react-markdown": "^8.0.4"
112
+ }
113
+ }