@contrail/util 1.0.48 → 1.0.50

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 (30) hide show
  1. package/README.md +1 -1
  2. package/lib/app-util/app-util.d.ts +25 -25
  3. package/lib/app-util/app-util.js +72 -72
  4. package/lib/date-util/date-util.d.ts +4 -4
  5. package/lib/date-util/date-util.js +8 -8
  6. package/lib/date-util/getIsoDatePart/getIsoDatePart.d.ts +1 -1
  7. package/lib/date-util/getIsoDatePart/getIsoDatePart.js +17 -17
  8. package/lib/index.d.ts +6 -5
  9. package/lib/index.js +22 -21
  10. package/lib/map-util/map-util.d.ts +3 -3
  11. package/lib/map-util/map-util.js +18 -18
  12. package/lib/object-util/applyChangesIfEqual/applyChangesIfEqual.d.ts +4 -4
  13. package/lib/object-util/applyChangesIfEqual/applyChangesIfEqual.js +84 -84
  14. package/lib/object-util/cloneDeep/cloneDeep.d.ts +1 -1
  15. package/lib/object-util/cloneDeep/cloneDeep.js +10 -10
  16. package/lib/object-util/compareDeep/compareDeep.d.ts +7 -7
  17. package/lib/object-util/compareDeep/compareDeep.js +96 -96
  18. package/lib/object-util/compareDeep/mockData.d.ts +88 -88
  19. package/lib/object-util/compareDeep/mockData.js +91 -91
  20. package/lib/object-util/isObject/isObject.d.ts +1 -1
  21. package/lib/object-util/isObject/isObject.js +7 -7
  22. package/lib/object-util/mergeDeep/mergeDeep.d.ts +1 -1
  23. package/lib/object-util/mergeDeep/mergeDeep.js +26 -26
  24. package/lib/object-util/object-util.d.ts +17 -17
  25. package/lib/object-util/object-util.js +41 -41
  26. package/lib/string-util/string-util.d.ts +8 -8
  27. package/lib/string-util/string-util.js +71 -71
  28. package/lib/timer-util/timer-util.d.ts +16 -0
  29. package/lib/timer-util/timer-util.js +65 -0
  30. package/package.json +43 -43
package/README.md CHANGED
@@ -1 +1 @@
1
- Authentication libraries for contrail/vibe platform.
1
+ Authentication libraries for contrail/vibe platform.
@@ -1,25 +1,25 @@
1
- export interface ActionDefinitionIdentifierParts {
2
- appIdentifier: string;
3
- versionId: string;
4
- actionNameIdentifier: string;
5
- }
6
- export interface ExtensionIdentifierParts {
7
- appIdentifier: string;
8
- extensionIdentifier: string;
9
- }
10
- export declare const ACTION_IDENTIFIER_VALIDATION_NO_IDENTIFIER = "Action definition has no identifier. An identifier is required.";
11
- export declare const ACTION_IDENTIFIER_VALIDATION_START_WITH_AT = "Invalid action identifier. Action definition identifier must conform with '@appIdentifier@versionId:actionIdentifier'";
12
- export declare const ACTION_IDENTIFIER_VALIDATION_INCORRECT_PATTERN = "Invalid action definition identifier. Please use the format: '@appIdentifier@versionId:actionIdentifier'. Action definitions must only contain alphanumeric characters and special characters '/' '-' '_' and conform to the regex ^@([_-/A-Za-z0-9]+)@([_-/A-Za-z0-9])+:([_-/A-Za-z0-9])+";
13
- export declare const ACTION_IDENTIFIER_VALIDATION_BAD_CHARACTERS = "Invalid action definitions identifier. Please use the format: '@appIdentifier@versionId:actionIdentifier'. 'appIdentifier', 'versionId', and 'actionIdentifier' must only contain alphanumeric characters and special characters '/' '-' '_' and conform to the regex ^@([_-/A-Za-z0-9]+)@([_-/A-Za-z0-9])+:([_-/A-Za-z0-9])+.";
14
- export declare const EXTENSION_IDENTIFIER_VALIDATION_NO_IDENTIFIER = "Extension definition has no identifier. An identifier is required.";
15
- export declare const EXTENSION_IDENTIFIER_VALIDATION_START_WITH_AT = "Invalid extension identifier. Extension identifier must conform with '@appIdentifier:extensionIdentifier'";
16
- export declare const EXTENSION_IDENTIFIER_VALIDATION_INCORRECT_PATTERN = "Invalid extension identifier. Please use the format: '@appIdentifier:extensionIdentifier'. Extension definitions must only contain alphanumeric characters and special characters '/' '-' '_' and conform to the regex ^@([_-/A-Za-z0-9]+)@([_-/A-Za-z0-9])+:([_-/A-Za-z0-9])+";
17
- export declare const EXTENSION_IDENTIFIER_VALIDATION_BAD_CHARACTERS = "Invalid extension identifier. Please use the format: '@appIdentifier:extensionIdentifier'. 'appIdentifier' and 'extensionIdentifier' must only contain alphanumeric characters and special characters '/' '-' '_' '.' and conform to the regex ^@([_.-/A-Za-z0-9]+)@([_.-/A-Za-z0-9])+:([_.-/A-Za-z0-9])+.";
18
- export declare class BadIdentifierException extends Error {
19
- }
20
- export declare class AppUtil {
21
- static parseActionIdentifier(actionIdentifier: string): ActionDefinitionIdentifierParts;
22
- static createActionIdentifier(actionDefinitionParts: ActionDefinitionIdentifierParts): string;
23
- static parseExtensionIdentifier(extensionIdentifier: string): ExtensionIdentifierParts;
24
- static createExtensionIdentifier(extensionDefinitionParts: ExtensionIdentifierParts): string;
25
- }
1
+ export interface ActionDefinitionIdentifierParts {
2
+ appIdentifier: string;
3
+ versionId: string;
4
+ actionNameIdentifier: string;
5
+ }
6
+ export interface ExtensionIdentifierParts {
7
+ appIdentifier: string;
8
+ extensionIdentifier: string;
9
+ }
10
+ export declare const ACTION_IDENTIFIER_VALIDATION_NO_IDENTIFIER = "Action definition has no identifier. An identifier is required.";
11
+ export declare const ACTION_IDENTIFIER_VALIDATION_START_WITH_AT = "Invalid action identifier. Action definition identifier must conform with '@appIdentifier@versionId:actionIdentifier'";
12
+ export declare const ACTION_IDENTIFIER_VALIDATION_INCORRECT_PATTERN = "Invalid action definition identifier. Please use the format: '@appIdentifier@versionId:actionIdentifier'. Action definitions must only contain alphanumeric characters and special characters '/' '-' '_' and conform to the regex ^@([_-/A-Za-z0-9]+)@([_-/A-Za-z0-9])+:([_-/A-Za-z0-9])+";
13
+ export declare const ACTION_IDENTIFIER_VALIDATION_BAD_CHARACTERS = "Invalid action definitions identifier. Please use the format: '@appIdentifier@versionId:actionIdentifier'. 'appIdentifier', 'versionId', and 'actionIdentifier' must only contain alphanumeric characters and special characters '/' '-' '_' and conform to the regex ^@([_-/A-Za-z0-9]+)@([_-/A-Za-z0-9])+:([_-/A-Za-z0-9])+.";
14
+ export declare const EXTENSION_IDENTIFIER_VALIDATION_NO_IDENTIFIER = "Extension definition has no identifier. An identifier is required.";
15
+ export declare const EXTENSION_IDENTIFIER_VALIDATION_START_WITH_AT = "Invalid extension identifier. Extension identifier must conform with '@appIdentifier:extensionIdentifier'";
16
+ export declare const EXTENSION_IDENTIFIER_VALIDATION_INCORRECT_PATTERN = "Invalid extension identifier. Please use the format: '@appIdentifier:extensionIdentifier'. Extension definitions must only contain alphanumeric characters and special characters '/' '-' '_' and conform to the regex ^@([_-/A-Za-z0-9]+)@([_-/A-Za-z0-9])+:([_-/A-Za-z0-9])+";
17
+ export declare const EXTENSION_IDENTIFIER_VALIDATION_BAD_CHARACTERS = "Invalid extension identifier. Please use the format: '@appIdentifier:extensionIdentifier'. 'appIdentifier' and 'extensionIdentifier' must only contain alphanumeric characters and special characters '/' '-' '_' '.' and conform to the regex ^@([_.-/A-Za-z0-9]+)@([_.-/A-Za-z0-9])+:([_.-/A-Za-z0-9])+.";
18
+ export declare class BadIdentifierException extends Error {
19
+ }
20
+ export declare class AppUtil {
21
+ static parseActionIdentifier(actionIdentifier: string): ActionDefinitionIdentifierParts;
22
+ static createActionIdentifier(actionDefinitionParts: ActionDefinitionIdentifierParts): string;
23
+ static parseExtensionIdentifier(extensionIdentifier: string): ExtensionIdentifierParts;
24
+ static createExtensionIdentifier(extensionDefinitionParts: ExtensionIdentifierParts): string;
25
+ }
@@ -1,72 +1,72 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.AppUtil = exports.BadIdentifierException = exports.EXTENSION_IDENTIFIER_VALIDATION_BAD_CHARACTERS = exports.EXTENSION_IDENTIFIER_VALIDATION_INCORRECT_PATTERN = exports.EXTENSION_IDENTIFIER_VALIDATION_START_WITH_AT = exports.EXTENSION_IDENTIFIER_VALIDATION_NO_IDENTIFIER = exports.ACTION_IDENTIFIER_VALIDATION_BAD_CHARACTERS = exports.ACTION_IDENTIFIER_VALIDATION_INCORRECT_PATTERN = exports.ACTION_IDENTIFIER_VALIDATION_START_WITH_AT = exports.ACTION_IDENTIFIER_VALIDATION_NO_IDENTIFIER = void 0;
4
- exports.ACTION_IDENTIFIER_VALIDATION_NO_IDENTIFIER = 'Action definition has no identifier. An identifier is required.';
5
- exports.ACTION_IDENTIFIER_VALIDATION_START_WITH_AT = `Invalid action identifier. Action definition identifier must conform with '@appIdentifier@versionId:actionIdentifier'`;
6
- exports.ACTION_IDENTIFIER_VALIDATION_INCORRECT_PATTERN = `Invalid action definition identifier. Please use the format: '@appIdentifier@versionId:actionIdentifier'. Action definitions must only contain alphanumeric characters and special characters '/' '-' '_' and conform to the regex ^@([_\-\/A-Za-z0-9]+)@([_\-\/A-Za-z0-9])+:([_\-\/A-Za-z0-9])+`;
7
- exports.ACTION_IDENTIFIER_VALIDATION_BAD_CHARACTERS = `Invalid action definitions identifier. Please use the format: '@appIdentifier@versionId:actionIdentifier'. 'appIdentifier', 'versionId', and 'actionIdentifier' must only contain alphanumeric characters and special characters '/' '-' '_' and conform to the regex ^@([_\-\/A-Za-z0-9]+)@([_\-\/A-Za-z0-9])+:([_\-\/A-Za-z0-9])+.`;
8
- exports.EXTENSION_IDENTIFIER_VALIDATION_NO_IDENTIFIER = 'Extension definition has no identifier. An identifier is required.';
9
- exports.EXTENSION_IDENTIFIER_VALIDATION_START_WITH_AT = `Invalid extension identifier. Extension identifier must conform with '@appIdentifier:extensionIdentifier'`;
10
- exports.EXTENSION_IDENTIFIER_VALIDATION_INCORRECT_PATTERN = `Invalid extension identifier. Please use the format: '@appIdentifier:extensionIdentifier'. Extension definitions must only contain alphanumeric characters and special characters '/' '-' '_' and conform to the regex ^@([_\-\/A-Za-z0-9]+)@([_\-\/A-Za-z0-9])+:([_\-\/A-Za-z0-9])+`;
11
- exports.EXTENSION_IDENTIFIER_VALIDATION_BAD_CHARACTERS = `Invalid extension identifier. Please use the format: '@appIdentifier:extensionIdentifier'. 'appIdentifier' and 'extensionIdentifier' must only contain alphanumeric characters and special characters '/' '-' '_' '.' and conform to the regex ^@([_\.\-\/A-Za-z0-9]+)@([_\.\-\/A-Za-z0-9])+:([_\.\-\/A-Za-z0-9])+.`;
12
- class BadIdentifierException extends Error {
13
- }
14
- exports.BadIdentifierException = BadIdentifierException;
15
- class AppUtil {
16
- static parseActionIdentifier(actionIdentifier) {
17
- {
18
- if (!actionIdentifier) {
19
- throw new BadIdentifierException(exports.ACTION_IDENTIFIER_VALIDATION_NO_IDENTIFIER);
20
- }
21
- if (!actionIdentifier.startsWith('@')) {
22
- throw new BadIdentifierException(exports.ACTION_IDENTIFIER_VALIDATION_START_WITH_AT);
23
- }
24
- const identifierParts = actionIdentifier.split(/[@:]/);
25
- if (identifierParts.length !== 4) {
26
- throw new BadIdentifierException(exports.ACTION_IDENTIFIER_VALIDATION_INCORRECT_PATTERN);
27
- }
28
- for (const appVersionPart of identifierParts.slice(1)) {
29
- const badCharacters = appVersionPart.match(/[^@_.\-\/A-Za-z0-9]/g);
30
- if (badCharacters === null || badCharacters === void 0 ? void 0 : badCharacters.length) {
31
- throw new BadIdentifierException(exports.ACTION_IDENTIFIER_VALIDATION_BAD_CHARACTERS);
32
- }
33
- }
34
- return {
35
- appIdentifier: `@${identifierParts[1]}`,
36
- versionId: identifierParts[2],
37
- actionNameIdentifier: identifierParts[3],
38
- };
39
- }
40
- }
41
- static createActionIdentifier(actionDefinitionParts) {
42
- return `${actionDefinitionParts.appIdentifier}@${actionDefinitionParts.versionId}:${actionDefinitionParts.actionNameIdentifier}`;
43
- }
44
- static parseExtensionIdentifier(extensionIdentifier) {
45
- {
46
- if (!extensionIdentifier) {
47
- throw new BadIdentifierException(exports.EXTENSION_IDENTIFIER_VALIDATION_NO_IDENTIFIER);
48
- }
49
- if (!extensionIdentifier.startsWith('@')) {
50
- throw new BadIdentifierException(exports.EXTENSION_IDENTIFIER_VALIDATION_START_WITH_AT);
51
- }
52
- const identifierParts = extensionIdentifier.split(/[@:]/);
53
- if (identifierParts.length !== 3) {
54
- throw new BadIdentifierException(exports.EXTENSION_IDENTIFIER_VALIDATION_INCORRECT_PATTERN);
55
- }
56
- for (const appVersionPart of identifierParts.slice(1)) {
57
- const badCharacters = appVersionPart.match(/[^@_.\-\/A-Za-z0-9]/g);
58
- if (badCharacters === null || badCharacters === void 0 ? void 0 : badCharacters.length) {
59
- throw new BadIdentifierException(exports.EXTENSION_IDENTIFIER_VALIDATION_BAD_CHARACTERS);
60
- }
61
- }
62
- return {
63
- appIdentifier: `@${identifierParts[1]}`,
64
- extensionIdentifier: identifierParts[2],
65
- };
66
- }
67
- }
68
- static createExtensionIdentifier(extensionDefinitionParts) {
69
- return `${extensionDefinitionParts.appIdentifier}:${extensionDefinitionParts.extensionIdentifier}`;
70
- }
71
- }
72
- exports.AppUtil = AppUtil;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AppUtil = exports.BadIdentifierException = exports.EXTENSION_IDENTIFIER_VALIDATION_BAD_CHARACTERS = exports.EXTENSION_IDENTIFIER_VALIDATION_INCORRECT_PATTERN = exports.EXTENSION_IDENTIFIER_VALIDATION_START_WITH_AT = exports.EXTENSION_IDENTIFIER_VALIDATION_NO_IDENTIFIER = exports.ACTION_IDENTIFIER_VALIDATION_BAD_CHARACTERS = exports.ACTION_IDENTIFIER_VALIDATION_INCORRECT_PATTERN = exports.ACTION_IDENTIFIER_VALIDATION_START_WITH_AT = exports.ACTION_IDENTIFIER_VALIDATION_NO_IDENTIFIER = void 0;
4
+ exports.ACTION_IDENTIFIER_VALIDATION_NO_IDENTIFIER = 'Action definition has no identifier. An identifier is required.';
5
+ exports.ACTION_IDENTIFIER_VALIDATION_START_WITH_AT = `Invalid action identifier. Action definition identifier must conform with '@appIdentifier@versionId:actionIdentifier'`;
6
+ exports.ACTION_IDENTIFIER_VALIDATION_INCORRECT_PATTERN = `Invalid action definition identifier. Please use the format: '@appIdentifier@versionId:actionIdentifier'. Action definitions must only contain alphanumeric characters and special characters '/' '-' '_' and conform to the regex ^@([_\-\/A-Za-z0-9]+)@([_\-\/A-Za-z0-9])+:([_\-\/A-Za-z0-9])+`;
7
+ exports.ACTION_IDENTIFIER_VALIDATION_BAD_CHARACTERS = `Invalid action definitions identifier. Please use the format: '@appIdentifier@versionId:actionIdentifier'. 'appIdentifier', 'versionId', and 'actionIdentifier' must only contain alphanumeric characters and special characters '/' '-' '_' and conform to the regex ^@([_\-\/A-Za-z0-9]+)@([_\-\/A-Za-z0-9])+:([_\-\/A-Za-z0-9])+.`;
8
+ exports.EXTENSION_IDENTIFIER_VALIDATION_NO_IDENTIFIER = 'Extension definition has no identifier. An identifier is required.';
9
+ exports.EXTENSION_IDENTIFIER_VALIDATION_START_WITH_AT = `Invalid extension identifier. Extension identifier must conform with '@appIdentifier:extensionIdentifier'`;
10
+ exports.EXTENSION_IDENTIFIER_VALIDATION_INCORRECT_PATTERN = `Invalid extension identifier. Please use the format: '@appIdentifier:extensionIdentifier'. Extension definitions must only contain alphanumeric characters and special characters '/' '-' '_' and conform to the regex ^@([_\-\/A-Za-z0-9]+)@([_\-\/A-Za-z0-9])+:([_\-\/A-Za-z0-9])+`;
11
+ exports.EXTENSION_IDENTIFIER_VALIDATION_BAD_CHARACTERS = `Invalid extension identifier. Please use the format: '@appIdentifier:extensionIdentifier'. 'appIdentifier' and 'extensionIdentifier' must only contain alphanumeric characters and special characters '/' '-' '_' '.' and conform to the regex ^@([_\.\-\/A-Za-z0-9]+)@([_\.\-\/A-Za-z0-9])+:([_\.\-\/A-Za-z0-9])+.`;
12
+ class BadIdentifierException extends Error {
13
+ }
14
+ exports.BadIdentifierException = BadIdentifierException;
15
+ class AppUtil {
16
+ static parseActionIdentifier(actionIdentifier) {
17
+ {
18
+ if (!actionIdentifier) {
19
+ throw new BadIdentifierException(exports.ACTION_IDENTIFIER_VALIDATION_NO_IDENTIFIER);
20
+ }
21
+ if (!actionIdentifier.startsWith('@')) {
22
+ throw new BadIdentifierException(exports.ACTION_IDENTIFIER_VALIDATION_START_WITH_AT);
23
+ }
24
+ const identifierParts = actionIdentifier.split(/[@:]/);
25
+ if (identifierParts.length !== 4) {
26
+ throw new BadIdentifierException(exports.ACTION_IDENTIFIER_VALIDATION_INCORRECT_PATTERN);
27
+ }
28
+ for (const appVersionPart of identifierParts.slice(1)) {
29
+ const badCharacters = appVersionPart.match(/[^@_.\-\/A-Za-z0-9]/g);
30
+ if (badCharacters === null || badCharacters === void 0 ? void 0 : badCharacters.length) {
31
+ throw new BadIdentifierException(exports.ACTION_IDENTIFIER_VALIDATION_BAD_CHARACTERS);
32
+ }
33
+ }
34
+ return {
35
+ appIdentifier: `@${identifierParts[1]}`,
36
+ versionId: identifierParts[2],
37
+ actionNameIdentifier: identifierParts[3],
38
+ };
39
+ }
40
+ }
41
+ static createActionIdentifier(actionDefinitionParts) {
42
+ return `${actionDefinitionParts.appIdentifier}@${actionDefinitionParts.versionId}:${actionDefinitionParts.actionNameIdentifier}`;
43
+ }
44
+ static parseExtensionIdentifier(extensionIdentifier) {
45
+ {
46
+ if (!extensionIdentifier) {
47
+ throw new BadIdentifierException(exports.EXTENSION_IDENTIFIER_VALIDATION_NO_IDENTIFIER);
48
+ }
49
+ if (!extensionIdentifier.startsWith('@')) {
50
+ throw new BadIdentifierException(exports.EXTENSION_IDENTIFIER_VALIDATION_START_WITH_AT);
51
+ }
52
+ const identifierParts = extensionIdentifier.split(/[@:]/);
53
+ if (identifierParts.length !== 3) {
54
+ throw new BadIdentifierException(exports.EXTENSION_IDENTIFIER_VALIDATION_INCORRECT_PATTERN);
55
+ }
56
+ for (const appVersionPart of identifierParts.slice(1)) {
57
+ const badCharacters = appVersionPart.match(/[^@_.\-\/A-Za-z0-9]/g);
58
+ if (badCharacters === null || badCharacters === void 0 ? void 0 : badCharacters.length) {
59
+ throw new BadIdentifierException(exports.EXTENSION_IDENTIFIER_VALIDATION_BAD_CHARACTERS);
60
+ }
61
+ }
62
+ return {
63
+ appIdentifier: `@${identifierParts[1]}`,
64
+ extensionIdentifier: identifierParts[2],
65
+ };
66
+ }
67
+ }
68
+ static createExtensionIdentifier(extensionDefinitionParts) {
69
+ return `${extensionDefinitionParts.appIdentifier}:${extensionDefinitionParts.extensionIdentifier}`;
70
+ }
71
+ }
72
+ exports.AppUtil = AppUtil;
@@ -1,4 +1,4 @@
1
- import { getIsoDatePart } from './getIsoDatePart/getIsoDatePart';
2
- export declare class DateUtil {
3
- static getIsoDatePart: typeof getIsoDatePart;
4
- }
1
+ import { getIsoDatePart } from './getIsoDatePart/getIsoDatePart';
2
+ export declare class DateUtil {
3
+ static getIsoDatePart: typeof getIsoDatePart;
4
+ }
@@ -1,8 +1,8 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.DateUtil = void 0;
4
- const getIsoDatePart_1 = require("./getIsoDatePart/getIsoDatePart");
5
- class DateUtil {
6
- }
7
- exports.DateUtil = DateUtil;
8
- DateUtil.getIsoDatePart = getIsoDatePart_1.getIsoDatePart;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DateUtil = void 0;
4
+ const getIsoDatePart_1 = require("./getIsoDatePart/getIsoDatePart");
5
+ class DateUtil {
6
+ }
7
+ exports.DateUtil = DateUtil;
8
+ DateUtil.getIsoDatePart = getIsoDatePart_1.getIsoDatePart;
@@ -1 +1 @@
1
- export declare function getIsoDatePart(date: Date): string;
1
+ export declare function getIsoDatePart(date: Date): string;
@@ -1,17 +1,17 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getIsoDatePart = void 0;
4
- function getIsoDatePart(date) {
5
- console.log('date 1: ', date.toISOString(), '\n\n\n\n\n\n\n\n');
6
- let d = new Date(date);
7
- console.log('date 2: ', d.toISOString(), '\n\n\n\n\n\n\n\n');
8
- let month = '' + (d.getMonth() + 1), day = '' + d.getDate(), year = d.getFullYear();
9
- if (month.length < 2) {
10
- month = '0' + month;
11
- }
12
- if (day.length < 2) {
13
- day = '0' + day;
14
- }
15
- return [year, month, day].join('-');
16
- }
17
- exports.getIsoDatePart = getIsoDatePart;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getIsoDatePart = void 0;
4
+ function getIsoDatePart(date) {
5
+ console.log('date 1: ', date.toISOString(), '\n\n\n\n\n\n\n\n');
6
+ let d = new Date(date);
7
+ console.log('date 2: ', d.toISOString(), '\n\n\n\n\n\n\n\n');
8
+ let month = '' + (d.getMonth() + 1), day = '' + d.getDate(), year = d.getFullYear();
9
+ if (month.length < 2) {
10
+ month = '0' + month;
11
+ }
12
+ if (day.length < 2) {
13
+ day = '0' + day;
14
+ }
15
+ return [year, month, day].join('-');
16
+ }
17
+ exports.getIsoDatePart = getIsoDatePart;
package/lib/index.d.ts CHANGED
@@ -1,5 +1,6 @@
1
- export * from './object-util/object-util';
2
- export * from './string-util/string-util';
3
- export * from './date-util/date-util';
4
- export * from './map-util/map-util';
5
- export * from './app-util/app-util';
1
+ export * from './object-util/object-util';
2
+ export * from './string-util/string-util';
3
+ export * from './date-util/date-util';
4
+ export * from './map-util/map-util';
5
+ export * from './app-util/app-util';
6
+ export * from './timer-util/timer-util';
package/lib/index.js CHANGED
@@ -1,21 +1,22 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./object-util/object-util"), exports);
18
- __exportStar(require("./string-util/string-util"), exports);
19
- __exportStar(require("./date-util/date-util"), exports);
20
- __exportStar(require("./map-util/map-util"), exports);
21
- __exportStar(require("./app-util/app-util"), exports);
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./object-util/object-util"), exports);
18
+ __exportStar(require("./string-util/string-util"), exports);
19
+ __exportStar(require("./date-util/date-util"), exports);
20
+ __exportStar(require("./map-util/map-util"), exports);
21
+ __exportStar(require("./app-util/app-util"), exports);
22
+ __exportStar(require("./timer-util/timer-util"), exports);
@@ -1,3 +1,3 @@
1
- export declare class MapUtil {
2
- static keyBy(array: any[], variableString: any): {};
3
- }
1
+ export declare class MapUtil {
2
+ static keyBy(array: any[], variableString: any): {};
3
+ }
@@ -1,18 +1,18 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.MapUtil = void 0;
4
- const string_util_1 = require("../string-util/string-util");
5
- class MapUtil {
6
- static keyBy(array, variableString) {
7
- if (variableString.charAt(0) !== '{') {
8
- variableString = `{${variableString}}`;
9
- }
10
- const map = {};
11
- for (const obj of array) {
12
- const value = string_util_1.StringUtil.parseVariables(variableString, obj);
13
- map[value] = obj;
14
- }
15
- return map;
16
- }
17
- }
18
- exports.MapUtil = MapUtil;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MapUtil = void 0;
4
+ const string_util_1 = require("../string-util/string-util");
5
+ class MapUtil {
6
+ static keyBy(array, variableString) {
7
+ if (variableString.charAt(0) !== '{') {
8
+ variableString = `{${variableString}}`;
9
+ }
10
+ const map = {};
11
+ for (const obj of array) {
12
+ const value = string_util_1.StringUtil.parseVariables(variableString, obj);
13
+ map[value] = obj;
14
+ }
15
+ return map;
16
+ }
17
+ }
18
+ exports.MapUtil = MapUtil;
@@ -1,4 +1,4 @@
1
- import { TypeProperty } from '@contrail/types';
2
- export declare function applyChangesIfEqual(target: any, priorSourceValues: any, newSourceValues: any, properties: any): void;
3
- export declare function determineChangesIfEqual(target: any, priorSourceValues: any, newSourceValues: any, properties: any): any;
4
- export declare function areItemPropertyValuesEqual(property: TypeProperty, itemOne: any, itemTwo: any): boolean;
1
+ import { TypeProperty } from '@contrail/types';
2
+ export declare function applyChangesIfEqual(target: any, priorSourceValues: any, newSourceValues: any, properties: any): void;
3
+ export declare function determineChangesIfEqual(target: any, priorSourceValues: any, newSourceValues: any, properties: any): any;
4
+ export declare function areItemPropertyValuesEqual(property: TypeProperty, itemOne: any, itemTwo: any): boolean;
@@ -1,84 +1,84 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.areItemPropertyValuesEqual = exports.determineChangesIfEqual = exports.applyChangesIfEqual = void 0;
4
- const types_1 = require("@contrail/types");
5
- const compareDeep_1 = require("../compareDeep/compareDeep");
6
- function applyChangesIfEqual(target, priorSourceValues, newSourceValues, properties) {
7
- const changes = determineChangesIfEqual(target, priorSourceValues, newSourceValues, properties);
8
- if (changes) {
9
- Object.assign(target, changes);
10
- }
11
- }
12
- exports.applyChangesIfEqual = applyChangesIfEqual;
13
- function determineChangesIfEqual(target, priorSourceValues, newSourceValues, properties) {
14
- const changes = {};
15
- for (const property of properties) {
16
- const propertyKey = getPropertyKey(property);
17
- if (newSourceValues[propertyKey] === undefined) {
18
- continue;
19
- }
20
- if (areItemPropertyValuesEqual(property, priorSourceValues, target)) {
21
- changes[propertyKey] = newSourceValues[propertyKey];
22
- if ([types_1.PropertyType.ObjectReference, types_1.PropertyType.UserList, types_1.PropertyType.TypeReference].includes(property.propertyType)) {
23
- changes[property.slug] = newSourceValues[property.slug];
24
- }
25
- }
26
- }
27
- return changes;
28
- }
29
- exports.determineChangesIfEqual = determineChangesIfEqual;
30
- function areItemPropertyValuesEqual(property, itemOne, itemTwo) {
31
- var _a, _b;
32
- const propertyKey = getPropertyKey(property);
33
- const propertyValueOne = itemOne[propertyKey];
34
- const propertyValueTwo = itemTwo[propertyKey];
35
- if (property.propertyType === types_1.PropertyType.MultiSelect) {
36
- const propertyValueOneAsArray = getMultiSelectValueAsArray(propertyValueOne);
37
- const propertyValueTwoAsArray = getMultiSelectValueAsArray(propertyValueTwo);
38
- return areArraysEqualIgnoreOrder(propertyValueOneAsArray, propertyValueTwoAsArray);
39
- }
40
- if (property.propertyType === types_1.PropertyType.SizeRange) {
41
- const isOfSameSizeRangeTemplate = ((_a = itemOne === null || itemOne === void 0 ? void 0 : itemOne.sizeRangeTemplate) === null || _a === void 0 ? void 0 : _a.id) === ((_b = itemTwo === null || itemTwo === void 0 ? void 0 : itemTwo.sizeRangeTemplate) === null || _b === void 0 ? void 0 : _b.id);
42
- if (!isOfSameSizeRangeTemplate)
43
- return false;
44
- return areSizeRangesEqual(propertyValueOne, propertyValueTwo);
45
- }
46
- return propertyValueOne === propertyValueTwo;
47
- }
48
- exports.areItemPropertyValuesEqual = areItemPropertyValuesEqual;
49
- function areSizeRangesEqual(sizeRangeOne, sizeRangeTwo) {
50
- var _a, _b;
51
- if (!sizeRangeOne && !sizeRangeTwo) {
52
- return true;
53
- }
54
- if (!sizeRangeOne || !sizeRangeTwo || ((_a = sizeRangeOne.sizes) === null || _a === void 0 ? void 0 : _a.length) !== ((_b = sizeRangeTwo.sizes) === null || _b === void 0 ? void 0 : _b.length)) {
55
- return false;
56
- }
57
- const result = (0, compareDeep_1.getObjectDiffs)(sizeRangeOne, sizeRangeTwo, '');
58
- return result.length === 0;
59
- }
60
- function areArraysEqualIgnoreOrder(arrayOne, arrayTwo) {
61
- if (arrayOne.length !== arrayTwo.length) {
62
- return false;
63
- }
64
- const sortedArray1 = arrayOne.slice().sort();
65
- const sortedArray2 = arrayTwo.slice().sort();
66
- const areArraysEqual = sortedArray1.every((element, index) => element === sortedArray2[index]);
67
- return areArraysEqual;
68
- }
69
- function getPropertyKey(property) {
70
- if ([types_1.PropertyType.ObjectReference, types_1.PropertyType.UserList, types_1.PropertyType.TypeReference].includes(property.propertyType)) {
71
- return property.slug + 'Id';
72
- }
73
- return property.slug;
74
- }
75
- function getMultiSelectValueAsArray(multiSelectValue) {
76
- if (!multiSelectValue)
77
- return [];
78
- if (typeof multiSelectValue === 'string') {
79
- if (multiSelectValue.trim().length === 0)
80
- return [];
81
- return multiSelectValue.split(',');
82
- }
83
- return multiSelectValue;
84
- }
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.areItemPropertyValuesEqual = exports.determineChangesIfEqual = exports.applyChangesIfEqual = void 0;
4
+ const types_1 = require("@contrail/types");
5
+ const compareDeep_1 = require("../compareDeep/compareDeep");
6
+ function applyChangesIfEqual(target, priorSourceValues, newSourceValues, properties) {
7
+ const changes = determineChangesIfEqual(target, priorSourceValues, newSourceValues, properties);
8
+ if (changes) {
9
+ Object.assign(target, changes);
10
+ }
11
+ }
12
+ exports.applyChangesIfEqual = applyChangesIfEqual;
13
+ function determineChangesIfEqual(target, priorSourceValues, newSourceValues, properties) {
14
+ const changes = {};
15
+ for (const property of properties) {
16
+ const propertyKey = getPropertyKey(property);
17
+ if (newSourceValues[propertyKey] === undefined) {
18
+ continue;
19
+ }
20
+ if (areItemPropertyValuesEqual(property, priorSourceValues, target)) {
21
+ changes[propertyKey] = newSourceValues[propertyKey];
22
+ if ([types_1.PropertyType.ObjectReference, types_1.PropertyType.UserList, types_1.PropertyType.TypeReference].includes(property.propertyType)) {
23
+ changes[property.slug] = newSourceValues[property.slug];
24
+ }
25
+ }
26
+ }
27
+ return changes;
28
+ }
29
+ exports.determineChangesIfEqual = determineChangesIfEqual;
30
+ function areItemPropertyValuesEqual(property, itemOne, itemTwo) {
31
+ var _a, _b;
32
+ const propertyKey = getPropertyKey(property);
33
+ const propertyValueOne = itemOne[propertyKey];
34
+ const propertyValueTwo = itemTwo[propertyKey];
35
+ if (property.propertyType === types_1.PropertyType.MultiSelect) {
36
+ const propertyValueOneAsArray = getMultiSelectValueAsArray(propertyValueOne);
37
+ const propertyValueTwoAsArray = getMultiSelectValueAsArray(propertyValueTwo);
38
+ return areArraysEqualIgnoreOrder(propertyValueOneAsArray, propertyValueTwoAsArray);
39
+ }
40
+ if (property.propertyType === types_1.PropertyType.SizeRange) {
41
+ const isOfSameSizeRangeTemplate = ((_a = itemOne === null || itemOne === void 0 ? void 0 : itemOne.sizeRangeTemplate) === null || _a === void 0 ? void 0 : _a.id) === ((_b = itemTwo === null || itemTwo === void 0 ? void 0 : itemTwo.sizeRangeTemplate) === null || _b === void 0 ? void 0 : _b.id);
42
+ if (!isOfSameSizeRangeTemplate)
43
+ return false;
44
+ return areSizeRangesEqual(propertyValueOne, propertyValueTwo);
45
+ }
46
+ return propertyValueOne === propertyValueTwo;
47
+ }
48
+ exports.areItemPropertyValuesEqual = areItemPropertyValuesEqual;
49
+ function areSizeRangesEqual(sizeRangeOne, sizeRangeTwo) {
50
+ var _a, _b;
51
+ if (!sizeRangeOne && !sizeRangeTwo) {
52
+ return true;
53
+ }
54
+ if (!sizeRangeOne || !sizeRangeTwo || ((_a = sizeRangeOne.sizes) === null || _a === void 0 ? void 0 : _a.length) !== ((_b = sizeRangeTwo.sizes) === null || _b === void 0 ? void 0 : _b.length)) {
55
+ return false;
56
+ }
57
+ const result = (0, compareDeep_1.getObjectDiffs)(sizeRangeOne, sizeRangeTwo, '');
58
+ return result.length === 0;
59
+ }
60
+ function areArraysEqualIgnoreOrder(arrayOne, arrayTwo) {
61
+ if (arrayOne.length !== arrayTwo.length) {
62
+ return false;
63
+ }
64
+ const sortedArray1 = arrayOne.slice().sort();
65
+ const sortedArray2 = arrayTwo.slice().sort();
66
+ const areArraysEqual = sortedArray1.every((element, index) => element === sortedArray2[index]);
67
+ return areArraysEqual;
68
+ }
69
+ function getPropertyKey(property) {
70
+ if ([types_1.PropertyType.ObjectReference, types_1.PropertyType.UserList, types_1.PropertyType.TypeReference].includes(property.propertyType)) {
71
+ return property.slug + 'Id';
72
+ }
73
+ return property.slug;
74
+ }
75
+ function getMultiSelectValueAsArray(multiSelectValue) {
76
+ if (!multiSelectValue)
77
+ return [];
78
+ if (typeof multiSelectValue === 'string') {
79
+ if (multiSelectValue.trim().length === 0)
80
+ return [];
81
+ return multiSelectValue.split(',');
82
+ }
83
+ return multiSelectValue;
84
+ }
@@ -1 +1 @@
1
- export declare function cloneDeep(obj: any): any;
1
+ export declare function cloneDeep(obj: any): any;
@@ -1,10 +1,10 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.cloneDeep = void 0;
4
- function cloneDeep(obj) {
5
- if (!obj) {
6
- return null;
7
- }
8
- return JSON.parse(JSON.stringify(obj));
9
- }
10
- exports.cloneDeep = cloneDeep;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.cloneDeep = void 0;
4
+ function cloneDeep(obj) {
5
+ if (!obj) {
6
+ return null;
7
+ }
8
+ return JSON.parse(JSON.stringify(obj));
9
+ }
10
+ exports.cloneDeep = cloneDeep;
@@ -1,7 +1,7 @@
1
- export interface ObjectDiff {
2
- propertyName: string;
3
- oldValue: any;
4
- newValue: any;
5
- }
6
- export declare function getObjectDiffs(before: any, after: any, prefix: string): ObjectDiff[];
7
- export declare function getObjectDiff(before: any, after: any, name: any): ObjectDiff;
1
+ export interface ObjectDiff {
2
+ propertyName: string;
3
+ oldValue: any;
4
+ newValue: any;
5
+ }
6
+ export declare function getObjectDiffs(before: any, after: any, prefix: string): ObjectDiff[];
7
+ export declare function getObjectDiff(before: any, after: any, name: any): ObjectDiff;