@mcma/core 0.16.17 → 0.16.18

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 (81) hide show
  1. package/dist/index.d.ts +1 -1
  2. package/dist/index.js +17 -17
  3. package/dist/lib/config-variables.d.ts +12 -12
  4. package/dist/lib/config-variables.js +49 -49
  5. package/dist/lib/index.d.ts +5 -5
  6. package/dist/lib/index.js +21 -21
  7. package/dist/lib/logging/console-logger-provider.d.ts +8 -8
  8. package/dist/lib/logging/console-logger-provider.js +14 -14
  9. package/dist/lib/logging/console-logger.d.ts +7 -7
  10. package/dist/lib/logging/console-logger.js +24 -24
  11. package/dist/lib/logging/index.d.ts +5 -5
  12. package/dist/lib/logging/index.js +21 -21
  13. package/dist/lib/logging/log-event.d.ts +15 -15
  14. package/dist/lib/logging/log-event.js +75 -75
  15. package/dist/lib/logging/logger-provider.d.ts +5 -5
  16. package/dist/lib/logging/logger-provider.js +2 -2
  17. package/dist/lib/logging/logger.d.ts +41 -41
  18. package/dist/lib/logging/logger.js +87 -87
  19. package/dist/lib/mcma-exception.d.ts +8 -8
  20. package/dist/lib/mcma-exception.js +44 -44
  21. package/dist/lib/model/index.d.ts +19 -19
  22. package/dist/lib/model/index.js +35 -35
  23. package/dist/lib/model/job-assignment.d.ts +14 -14
  24. package/dist/lib/model/job-assignment.js +26 -26
  25. package/dist/lib/model/job-base.d.ts +17 -17
  26. package/dist/lib/model/job-base.js +27 -27
  27. package/dist/lib/model/job-execution.d.ts +14 -14
  28. package/dist/lib/model/job-execution.js +21 -21
  29. package/dist/lib/model/job-parameter-bag.d.ts +10 -10
  30. package/dist/lib/model/job-parameter-bag.js +12 -12
  31. package/dist/lib/model/job-parameter.d.ts +10 -10
  32. package/dist/lib/model/job-parameter.js +17 -17
  33. package/dist/lib/model/job-profile.d.ts +15 -15
  34. package/dist/lib/model/job-profile.js +24 -24
  35. package/dist/lib/model/job-status.d.ts +11 -11
  36. package/dist/lib/model/job-status.js +15 -15
  37. package/dist/lib/model/jobs/ai-job.d.ts +4 -4
  38. package/dist/lib/model/jobs/ai-job.js +10 -10
  39. package/dist/lib/model/jobs/ame-job.d.ts +4 -4
  40. package/dist/lib/model/jobs/ame-job.js +10 -10
  41. package/dist/lib/model/jobs/capture-job.d.ts +4 -4
  42. package/dist/lib/model/jobs/capture-job.js +10 -10
  43. package/dist/lib/model/jobs/distribution-job.d.ts +4 -4
  44. package/dist/lib/model/jobs/distribution-job.js +10 -10
  45. package/dist/lib/model/jobs/index.d.ts +9 -9
  46. package/dist/lib/model/jobs/index.js +25 -25
  47. package/dist/lib/model/jobs/job.d.ts +23 -23
  48. package/dist/lib/model/jobs/job.js +38 -38
  49. package/dist/lib/model/jobs/qa-job.d.ts +4 -4
  50. package/dist/lib/model/jobs/qa-job.js +10 -10
  51. package/dist/lib/model/jobs/storage-job.d.ts +4 -4
  52. package/dist/lib/model/jobs/storage-job.js +10 -10
  53. package/dist/lib/model/jobs/transform-job.d.ts +4 -4
  54. package/dist/lib/model/jobs/transform-job.js +10 -10
  55. package/dist/lib/model/jobs/workflow-job.d.ts +4 -4
  56. package/dist/lib/model/jobs/workflow-job.js +10 -10
  57. package/dist/lib/model/locator-status.d.ts +6 -6
  58. package/dist/lib/model/locator-status.js +10 -10
  59. package/dist/lib/model/locator.d.ts +12 -12
  60. package/dist/lib/model/locator.js +21 -21
  61. package/dist/lib/model/mcma-object.d.ts +7 -7
  62. package/dist/lib/model/mcma-object.js +10 -10
  63. package/dist/lib/model/mcma-resource-type.d.ts +6 -6
  64. package/dist/lib/model/mcma-resource-type.js +2 -2
  65. package/dist/lib/model/mcma-resource.d.ts +20 -20
  66. package/dist/lib/model/mcma-resource.js +34 -34
  67. package/dist/lib/model/mcma-tracker.d.ts +16 -16
  68. package/dist/lib/model/mcma-tracker.js +22 -22
  69. package/dist/lib/model/notification-endpoint.d.ts +8 -8
  70. package/dist/lib/model/notification-endpoint.js +14 -14
  71. package/dist/lib/model/notification.d.ts +10 -10
  72. package/dist/lib/model/notification.js +17 -17
  73. package/dist/lib/model/problem-detail.d.ts +16 -16
  74. package/dist/lib/model/problem-detail.js +24 -24
  75. package/dist/lib/model/resource-endpoint.d.ts +12 -12
  76. package/dist/lib/model/resource-endpoint.js +20 -20
  77. package/dist/lib/model/service.d.ts +17 -17
  78. package/dist/lib/model/service.js +29 -29
  79. package/dist/lib/utils.d.ts +23 -23
  80. package/dist/lib/utils.js +128 -128
  81. package/package.json +5 -5
@@ -1,24 +1,24 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ProblemDetail = void 0;
4
- const mcma_object_1 = require("./mcma-object");
5
- const utils_1 = require("../utils");
6
- class ProblemDetail extends mcma_object_1.McmaObject {
7
- type;
8
- title;
9
- detail;
10
- instance;
11
- constructor(properties) {
12
- super("ProblemDetail");
13
- this.type = properties.type;
14
- this.title = properties.title;
15
- this.detail = properties.detail;
16
- this.instance = properties.instance;
17
- Object.assign(this, properties);
18
- utils_1.Utils.checkProperty(this, "type", "string", true);
19
- utils_1.Utils.checkProperty(this, "title", "string", true);
20
- utils_1.Utils.checkProperty(this, "detail", "string", false);
21
- utils_1.Utils.checkProperty(this, "instance", "string", false);
22
- }
23
- }
24
- exports.ProblemDetail = ProblemDetail;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ProblemDetail = void 0;
4
+ const mcma_object_1 = require("./mcma-object");
5
+ const utils_1 = require("../utils");
6
+ class ProblemDetail extends mcma_object_1.McmaObject {
7
+ type;
8
+ title;
9
+ detail;
10
+ instance;
11
+ constructor(properties) {
12
+ super("ProblemDetail");
13
+ this.type = properties.type;
14
+ this.title = properties.title;
15
+ this.detail = properties.detail;
16
+ this.instance = properties.instance;
17
+ Object.assign(this, properties);
18
+ utils_1.Utils.checkProperty(this, "type", "string", true);
19
+ utils_1.Utils.checkProperty(this, "title", "string", true);
20
+ utils_1.Utils.checkProperty(this, "detail", "string", false);
21
+ utils_1.Utils.checkProperty(this, "instance", "string", false);
22
+ }
23
+ }
24
+ exports.ProblemDetail = ProblemDetail;
@@ -1,12 +1,12 @@
1
- import { McmaObject, McmaObjectProperties } from "./mcma-object";
2
- export interface ResourceEndpointProperties extends McmaObjectProperties {
3
- resourceType: string;
4
- httpEndpoint: string;
5
- authType?: string;
6
- }
7
- export declare class ResourceEndpoint extends McmaObject implements ResourceEndpointProperties {
8
- resourceType: string;
9
- httpEndpoint: string;
10
- authType?: string;
11
- constructor(properties: ResourceEndpointProperties);
12
- }
1
+ import { McmaObject, McmaObjectProperties } from "./mcma-object";
2
+ export interface ResourceEndpointProperties extends McmaObjectProperties {
3
+ resourceType: string;
4
+ httpEndpoint: string;
5
+ authType?: string;
6
+ }
7
+ export declare class ResourceEndpoint extends McmaObject implements ResourceEndpointProperties {
8
+ resourceType: string;
9
+ httpEndpoint: string;
10
+ authType?: string;
11
+ constructor(properties: ResourceEndpointProperties);
12
+ }
@@ -1,20 +1,20 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ResourceEndpoint = void 0;
4
- const mcma_object_1 = require("./mcma-object");
5
- const utils_1 = require("../utils");
6
- class ResourceEndpoint extends mcma_object_1.McmaObject {
7
- resourceType;
8
- httpEndpoint;
9
- authType;
10
- constructor(properties) {
11
- super("ResourceEndpoint");
12
- this.resourceType = properties.resourceType;
13
- this.httpEndpoint = properties.httpEndpoint;
14
- this.authType = properties.authType;
15
- utils_1.Utils.checkProperty(this, "resourceType", "string", true);
16
- utils_1.Utils.checkProperty(this, "httpEndpoint", "url", true);
17
- utils_1.Utils.checkProperty(this, "authType", "string", false);
18
- }
19
- }
20
- exports.ResourceEndpoint = ResourceEndpoint;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ResourceEndpoint = void 0;
4
+ const mcma_object_1 = require("./mcma-object");
5
+ const utils_1 = require("../utils");
6
+ class ResourceEndpoint extends mcma_object_1.McmaObject {
7
+ resourceType;
8
+ httpEndpoint;
9
+ authType;
10
+ constructor(properties) {
11
+ super("ResourceEndpoint");
12
+ this.resourceType = properties.resourceType;
13
+ this.httpEndpoint = properties.httpEndpoint;
14
+ this.authType = properties.authType;
15
+ utils_1.Utils.checkProperty(this, "resourceType", "string", true);
16
+ utils_1.Utils.checkProperty(this, "httpEndpoint", "url", true);
17
+ utils_1.Utils.checkProperty(this, "authType", "string", false);
18
+ }
19
+ }
20
+ exports.ResourceEndpoint = ResourceEndpoint;
@@ -1,17 +1,17 @@
1
- import { McmaResource, McmaResourceProperties } from "./mcma-resource";
2
- import { ResourceEndpoint, ResourceEndpointProperties } from "./resource-endpoint";
3
- export interface ServiceProperties extends McmaResourceProperties {
4
- name: string;
5
- resources: ResourceEndpointProperties[];
6
- authType?: string;
7
- jobType?: string;
8
- jobProfileIds?: string[];
9
- }
10
- export declare class Service extends McmaResource implements ServiceProperties {
11
- name: string;
12
- resources: ResourceEndpoint[];
13
- authType?: string;
14
- jobType?: string;
15
- jobProfileIds?: string[];
16
- constructor(properties: ServiceProperties);
17
- }
1
+ import { McmaResource, McmaResourceProperties } from "./mcma-resource";
2
+ import { ResourceEndpoint, ResourceEndpointProperties } from "./resource-endpoint";
3
+ export interface ServiceProperties extends McmaResourceProperties {
4
+ name: string;
5
+ resources: ResourceEndpointProperties[];
6
+ authType?: string;
7
+ jobType?: string;
8
+ jobProfileIds?: string[];
9
+ }
10
+ export declare class Service extends McmaResource implements ServiceProperties {
11
+ name: string;
12
+ resources: ResourceEndpoint[];
13
+ authType?: string;
14
+ jobType?: string;
15
+ jobProfileIds?: string[];
16
+ constructor(properties: ServiceProperties);
17
+ }
@@ -1,29 +1,29 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Service = void 0;
4
- const mcma_resource_1 = require("./mcma-resource");
5
- const resource_endpoint_1 = require("./resource-endpoint");
6
- const utils_1 = require("../utils");
7
- class Service extends mcma_resource_1.McmaResource {
8
- name;
9
- resources;
10
- authType;
11
- jobType;
12
- jobProfileIds;
13
- constructor(properties) {
14
- super("Service", properties);
15
- this.name = properties.name;
16
- this.resources = properties.resources?.map(re => new resource_endpoint_1.ResourceEndpoint(re));
17
- this.authType = properties.authType;
18
- this.jobType = properties.jobType;
19
- if (Array.isArray(properties.jobProfileIds)) {
20
- this.jobProfileIds = [...properties.jobProfileIds];
21
- }
22
- utils_1.Utils.checkProperty(this, "name", "string", true);
23
- utils_1.Utils.checkProperty(this, "resources", "Array", true);
24
- utils_1.Utils.checkProperty(this, "authType", "string", false);
25
- utils_1.Utils.checkProperty(this, "jobType", "string", false);
26
- utils_1.Utils.checkProperty(this, "jobProfileIds", "Array", false);
27
- }
28
- }
29
- exports.Service = Service;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Service = void 0;
4
+ const mcma_resource_1 = require("./mcma-resource");
5
+ const resource_endpoint_1 = require("./resource-endpoint");
6
+ const utils_1 = require("../utils");
7
+ class Service extends mcma_resource_1.McmaResource {
8
+ name;
9
+ resources;
10
+ authType;
11
+ jobType;
12
+ jobProfileIds;
13
+ constructor(properties) {
14
+ super("Service", properties);
15
+ this.name = properties.name;
16
+ this.resources = properties.resources?.map(re => new resource_endpoint_1.ResourceEndpoint(re));
17
+ this.authType = properties.authType;
18
+ this.jobType = properties.jobType;
19
+ if (Array.isArray(properties.jobProfileIds)) {
20
+ this.jobProfileIds = [...properties.jobProfileIds];
21
+ }
22
+ utils_1.Utils.checkProperty(this, "name", "string", true);
23
+ utils_1.Utils.checkProperty(this, "resources", "Array", true);
24
+ utils_1.Utils.checkProperty(this, "authType", "string", false);
25
+ utils_1.Utils.checkProperty(this, "jobType", "string", false);
26
+ utils_1.Utils.checkProperty(this, "jobProfileIds", "Array", false);
27
+ }
28
+ }
29
+ exports.Service = Service;
@@ -1,23 +1,23 @@
1
- declare function isValidUrl(url: string): boolean;
2
- declare function getTypeName(type: string | object | Function): string;
3
- declare function toBase64(text: string): string;
4
- declare function fromBase64(base64Text: string): string;
5
- declare function sleep(timeout: number): Promise<void>;
6
- declare function isValidDateString(value: any): boolean;
7
- declare function reviver(this: any, key: string, value: any): any;
8
- declare function ensureValidDateOrUndefined(maybeDate: any): Date | undefined;
9
- declare function stringify(obj: any): string;
10
- declare function checkProperty(object: any, propertyName: string, expectedType: string, required?: boolean): void;
11
- export declare const Utils: {
12
- isValidUrl: typeof isValidUrl;
13
- getTypeName: typeof getTypeName;
14
- toBase64: typeof toBase64;
15
- fromBase64: typeof fromBase64;
16
- sleep: typeof sleep;
17
- isValidDateString: typeof isValidDateString;
18
- reviver: typeof reviver;
19
- ensureValidDateOrUndefined: typeof ensureValidDateOrUndefined;
20
- stringify: typeof stringify;
21
- checkProperty: typeof checkProperty;
22
- };
23
- export {};
1
+ declare function isValidUrl(url: string): boolean;
2
+ declare function getTypeName(type: string | object | Function): string;
3
+ declare function toBase64(text: string): string;
4
+ declare function fromBase64(base64Text: string): string;
5
+ declare function sleep(timeout: number): Promise<void>;
6
+ declare function isValidDateString(value: any): boolean;
7
+ declare function reviver(this: any, key: string, value: any): any;
8
+ declare function ensureValidDateOrUndefined(maybeDate: any): Date | undefined;
9
+ declare function stringify(obj: any): string;
10
+ declare function checkProperty(object: any, propertyName: string, expectedType: string, required?: boolean): void;
11
+ export declare const Utils: {
12
+ isValidUrl: typeof isValidUrl;
13
+ getTypeName: typeof getTypeName;
14
+ toBase64: typeof toBase64;
15
+ fromBase64: typeof fromBase64;
16
+ sleep: typeof sleep;
17
+ isValidDateString: typeof isValidDateString;
18
+ reviver: typeof reviver;
19
+ ensureValidDateOrUndefined: typeof ensureValidDateOrUndefined;
20
+ stringify: typeof stringify;
21
+ checkProperty: typeof checkProperty;
22
+ };
23
+ export {};
package/dist/lib/utils.js CHANGED
@@ -1,128 +1,128 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Utils = void 0;
4
- const mcma_exception_1 = require("./mcma-exception");
5
- function isValidUrl(url) {
6
- try {
7
- new URL(url);
8
- return true;
9
- }
10
- catch (error) {
11
- return false;
12
- }
13
- }
14
- function getTypeName(type) {
15
- if (typeof type === "function") {
16
- type = type.name;
17
- }
18
- else if (typeof type === "object") {
19
- type = type.constructor.name;
20
- }
21
- else if (typeof type !== "string") {
22
- throw new mcma_exception_1.McmaException("Invalid type");
23
- }
24
- return type;
25
- }
26
- function toBase64(text) {
27
- // check for browser function for base64
28
- if (typeof btoa !== "undefined") {
29
- return btoa(text);
30
- }
31
- // check for Node.js Buffer class for converting
32
- if (typeof Buffer !== "undefined" && typeof Buffer.from !== "undefined") {
33
- return Buffer.from(text).toString("base64");
34
- }
35
- // not sure what platform we're on - throw an error to indicate this is not supported
36
- throw new mcma_exception_1.McmaException("Unable to convert from plain text to base64 string. Neither the function 'btoa' nor the class 'Buffer' are defined on this platform.");
37
- }
38
- function fromBase64(base64Text) {
39
- // check for browser function for base64
40
- if (typeof atob !== "undefined") {
41
- return atob(base64Text);
42
- }
43
- // check for Node.js Buffer class for converting
44
- if (typeof Buffer !== "undefined" && typeof Buffer.from !== "undefined") {
45
- return Buffer.from(base64Text, "base64").toString();
46
- }
47
- // not sure what platform we're on - throw an error to indicate this is not supported
48
- throw new mcma_exception_1.McmaException("Unable to convert to plain text from base64 string. Neither the function 'atob' nor the class 'Buffer' are defined on this platform.");
49
- }
50
- async function sleep(timeout) {
51
- return new Promise((resolve) => setTimeout(() => resolve(), timeout));
52
- }
53
- const dateFormat = /^(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d\.\d+([+-][0-2]\d:[0-5]\d|Z))$|^(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d([+-][0-2]\d:[0-5]\d|Z))$|^(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d([+-][0-2]\d:[0-5]\d|Z))$/;
54
- function isValidDateString(value) {
55
- return typeof value === "string" && dateFormat.test(value);
56
- }
57
- function reviver(key, value) {
58
- if (isValidDateString(value)) {
59
- return new Date(value);
60
- }
61
- return value;
62
- }
63
- function ensureValidDateOrUndefined(maybeDate) {
64
- if (maybeDate === undefined || maybeDate === null) {
65
- return undefined;
66
- }
67
- const date = new Date(maybeDate);
68
- if (isNaN(date.getTime())) {
69
- return undefined;
70
- }
71
- return date;
72
- }
73
- function stringify(obj) {
74
- let cache = [];
75
- return JSON.stringify(obj, function (key, value) {
76
- if (typeof value === "object" && value !== null) {
77
- if (cache.indexOf(value) !== -1) {
78
- // Circular reference found, discard key
79
- return;
80
- }
81
- // Store value in our collection
82
- cache.push(value);
83
- }
84
- return value;
85
- }, 2);
86
- }
87
- function checkProperty(object, propertyName, expectedType, required) {
88
- const propertyValue = object[propertyName];
89
- const propertyType = typeof propertyValue;
90
- if (propertyValue === undefined || propertyValue === null) {
91
- if (required) {
92
- throw new mcma_exception_1.McmaException("Resource of type '" + object["@type"] + "' requires property '" + propertyName + "' to be defined", null, object);
93
- }
94
- return;
95
- }
96
- if (expectedType === "url") {
97
- if (propertyType !== "string" || !exports.Utils.isValidUrl(propertyValue)) {
98
- throw new mcma_exception_1.McmaException("Resource of type '" + object["@type"] + "' requires property '" + propertyName + "' to have a valid URL", null, object);
99
- }
100
- }
101
- else if (expectedType === "Array") {
102
- if (!Array.isArray(propertyValue)) {
103
- throw new mcma_exception_1.McmaException("Resource of type '" + object["@type"] + "' requires property '" + propertyName + "' to have type Array", null, object);
104
- }
105
- }
106
- else if (expectedType === "object") {
107
- if (propertyType !== "object" || Array.isArray(propertyValue)) {
108
- throw new mcma_exception_1.McmaException("Resource of type '" + object["@type"] + "' requires property '" + propertyName + "' to have type object", null, object);
109
- }
110
- }
111
- else {
112
- if (expectedType !== propertyType) {
113
- throw new mcma_exception_1.McmaException("Resource of type '" + object["@type"] + "' requires property '" + propertyName + "' to have type " + expectedType, null, object);
114
- }
115
- }
116
- }
117
- exports.Utils = {
118
- isValidUrl,
119
- getTypeName,
120
- toBase64,
121
- fromBase64,
122
- sleep,
123
- isValidDateString,
124
- reviver,
125
- ensureValidDateOrUndefined,
126
- stringify,
127
- checkProperty,
128
- };
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Utils = void 0;
4
+ const mcma_exception_1 = require("./mcma-exception");
5
+ function isValidUrl(url) {
6
+ try {
7
+ new URL(url);
8
+ return true;
9
+ }
10
+ catch (error) {
11
+ return false;
12
+ }
13
+ }
14
+ function getTypeName(type) {
15
+ if (typeof type === "function") {
16
+ type = type.name;
17
+ }
18
+ else if (typeof type === "object") {
19
+ type = type.constructor.name;
20
+ }
21
+ else if (typeof type !== "string") {
22
+ throw new mcma_exception_1.McmaException("Invalid type");
23
+ }
24
+ return type;
25
+ }
26
+ function toBase64(text) {
27
+ // check for browser function for base64
28
+ if (typeof btoa !== "undefined") {
29
+ return btoa(text);
30
+ }
31
+ // check for Node.js Buffer class for converting
32
+ if (typeof Buffer !== "undefined" && typeof Buffer.from !== "undefined") {
33
+ return Buffer.from(text).toString("base64");
34
+ }
35
+ // not sure what platform we're on - throw an error to indicate this is not supported
36
+ throw new mcma_exception_1.McmaException("Unable to convert from plain text to base64 string. Neither the function 'btoa' nor the class 'Buffer' are defined on this platform.");
37
+ }
38
+ function fromBase64(base64Text) {
39
+ // check for browser function for base64
40
+ if (typeof atob !== "undefined") {
41
+ return atob(base64Text);
42
+ }
43
+ // check for Node.js Buffer class for converting
44
+ if (typeof Buffer !== "undefined" && typeof Buffer.from !== "undefined") {
45
+ return Buffer.from(base64Text, "base64").toString();
46
+ }
47
+ // not sure what platform we're on - throw an error to indicate this is not supported
48
+ throw new mcma_exception_1.McmaException("Unable to convert to plain text from base64 string. Neither the function 'atob' nor the class 'Buffer' are defined on this platform.");
49
+ }
50
+ async function sleep(timeout) {
51
+ return new Promise((resolve) => setTimeout(() => resolve(), timeout));
52
+ }
53
+ const dateFormat = /^(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d\.\d+([+-][0-2]\d:[0-5]\d|Z))$|^(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d([+-][0-2]\d:[0-5]\d|Z))$|^(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d([+-][0-2]\d:[0-5]\d|Z))$/;
54
+ function isValidDateString(value) {
55
+ return typeof value === "string" && dateFormat.test(value);
56
+ }
57
+ function reviver(key, value) {
58
+ if (isValidDateString(value)) {
59
+ return new Date(value);
60
+ }
61
+ return value;
62
+ }
63
+ function ensureValidDateOrUndefined(maybeDate) {
64
+ if (maybeDate === undefined || maybeDate === null) {
65
+ return undefined;
66
+ }
67
+ const date = new Date(maybeDate);
68
+ if (isNaN(date.getTime())) {
69
+ return undefined;
70
+ }
71
+ return date;
72
+ }
73
+ function stringify(obj) {
74
+ let cache = [];
75
+ return JSON.stringify(obj, function (key, value) {
76
+ if (typeof value === "object" && value !== null) {
77
+ if (cache.indexOf(value) !== -1) {
78
+ // Circular reference found, discard key
79
+ return;
80
+ }
81
+ // Store value in our collection
82
+ cache.push(value);
83
+ }
84
+ return value;
85
+ }, 2);
86
+ }
87
+ function checkProperty(object, propertyName, expectedType, required) {
88
+ const propertyValue = object[propertyName];
89
+ const propertyType = typeof propertyValue;
90
+ if (propertyValue === undefined || propertyValue === null) {
91
+ if (required) {
92
+ throw new mcma_exception_1.McmaException("Resource of type '" + object["@type"] + "' requires property '" + propertyName + "' to be defined", null, object);
93
+ }
94
+ return;
95
+ }
96
+ if (expectedType === "url") {
97
+ if (propertyType !== "string" || !exports.Utils.isValidUrl(propertyValue)) {
98
+ throw new mcma_exception_1.McmaException("Resource of type '" + object["@type"] + "' requires property '" + propertyName + "' to have a valid URL", null, object);
99
+ }
100
+ }
101
+ else if (expectedType === "Array") {
102
+ if (!Array.isArray(propertyValue)) {
103
+ throw new mcma_exception_1.McmaException("Resource of type '" + object["@type"] + "' requires property '" + propertyName + "' to have type Array", null, object);
104
+ }
105
+ }
106
+ else if (expectedType === "object") {
107
+ if (propertyType !== "object" || Array.isArray(propertyValue)) {
108
+ throw new mcma_exception_1.McmaException("Resource of type '" + object["@type"] + "' requires property '" + propertyName + "' to have type object", null, object);
109
+ }
110
+ }
111
+ else {
112
+ if (expectedType !== propertyType) {
113
+ throw new mcma_exception_1.McmaException("Resource of type '" + object["@type"] + "' requires property '" + propertyName + "' to have type " + expectedType, null, object);
114
+ }
115
+ }
116
+ }
117
+ exports.Utils = {
118
+ isValidUrl,
119
+ getTypeName,
120
+ toBase64,
121
+ fromBase64,
122
+ sleep,
123
+ isValidDateString,
124
+ reviver,
125
+ ensureValidDateOrUndefined,
126
+ stringify,
127
+ checkProperty,
128
+ };
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "@mcma/core",
3
- "version": "0.16.17",
3
+ "version": "0.16.18",
4
4
  "description": "Node module with type definitions and helper utils for the EBU MCMA framework",
5
5
  "engines": {
6
- "node": "^18.0.0"
6
+ "node": ">=18.0.0"
7
7
  },
8
8
  "type": "commonjs",
9
9
  "main": "dist/index.js",
@@ -29,11 +29,11 @@
29
29
  },
30
30
  "homepage": "https://github.com/ebu/mcma-libraries/mcma-core-nodejs#readme",
31
31
  "dependencies": {
32
- "uuid": "^9.0.0"
32
+ "uuid": "^9.0.1"
33
33
  },
34
34
  "devDependencies": {
35
- "@types/node": "^18.15.10",
36
- "@types/uuid": "^9.0.1",
35
+ "@types/node": "^18.19.34",
36
+ "@types/uuid": "^9.0.8",
37
37
  "jasmine": "^3.4.0"
38
38
  }
39
39
  }