@mcma/core 0.13.26 → 0.14.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.
@@ -14,13 +14,22 @@ class LogEvent {
14
14
  }
15
15
  flatten() {
16
16
  var _a, _b, _c, _d, _e;
17
+ let message = this.message;
18
+ if (message instanceof Error) {
19
+ if (this.message.stack) {
20
+ message = this.message.stack;
21
+ }
22
+ else {
23
+ message = this.message.toString();
24
+ }
25
+ }
17
26
  const logEventEntry = {
18
27
  type: this.type,
19
28
  level: this.level,
20
29
  source: this.source,
21
30
  requestId: this.requestId,
22
31
  timestamp: this.timestamp,
23
- message: this.message,
32
+ message,
24
33
  trackerId: (_a = this.tracker) === null || _a === void 0 ? void 0 : _a.id,
25
34
  trackerLabel: (_b = this.tracker) === null || _b === void 0 ? void 0 : _b.label,
26
35
  };
@@ -46,11 +55,11 @@ class LogEvent {
46
55
  try {
47
56
  return JSON.stringify(logEventEntry, null, 2);
48
57
  }
49
- catch (_a) {
58
+ catch {
50
59
  try {
51
60
  logEventEntry.message = util.inspect(logEventEntry.message);
52
61
  }
53
- catch (_b) {
62
+ catch {
54
63
  logEventEntry.message = logEventEntry.message + "";
55
64
  }
56
65
  }
@@ -3,5 +3,5 @@ export declare class McmaException extends Error {
3
3
  cause?: McmaException;
4
4
  context?: any;
5
5
  constructor(message: string, cause?: McmaException, context?: any);
6
- toString(): string;
6
+ toString(includeDetails?: boolean): string;
7
7
  }
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.McmaException = void 0;
4
+ const os_1 = require("os");
4
5
  class McmaException extends Error {
5
6
  constructor(message, cause, context) {
6
7
  super(message);
@@ -9,24 +10,25 @@ class McmaException extends Error {
9
10
  this.context = context;
10
11
  this.cause = cause;
11
12
  this.context = context;
13
+ this.stack = this.toString(true);
12
14
  }
13
- toString() {
15
+ toString(includeDetails = false) {
14
16
  var _a;
15
17
  let ret = "";
16
18
  let c = this;
17
19
  while (c) {
18
- if (c.stack) {
20
+ if (includeDetails && c.stack) {
19
21
  ret += c.stack;
20
22
  }
21
23
  else {
22
24
  ret += "Error: " + ((_a = c.message) !== null && _a !== void 0 ? _a : c);
23
25
  }
24
- if (c.context) {
25
- ret += "\nContext:\n" + JSON.stringify(c.context, null, 2);
26
+ if (includeDetails && c.context) {
27
+ ret += os_1.EOL + "Context:" + os_1.EOL + JSON.stringify(c.context, null, 2);
26
28
  }
27
29
  c = c.cause;
28
30
  if (c) {
29
- ret += "\nCaused by:\n";
31
+ ret += os_1.EOL + "Caused by: " + os_1.EOL;
30
32
  }
31
33
  }
32
34
  return ret;
@@ -1,11 +1,11 @@
1
- import { JobParameterBag } from "./job-parameter-bag";
1
+ import { JobParameterBag, JobParameterBagProperties } from "./job-parameter-bag";
2
2
  import { McmaResource, McmaResourceProperties } from "./mcma-resource";
3
3
  import { ProblemDetail, ProblemDetailProperties } from "./problem-detail";
4
4
  import { JobStatus } from "./job-status";
5
5
  export interface JobBaseProperties extends McmaResourceProperties {
6
6
  status?: JobStatus;
7
7
  error?: ProblemDetailProperties;
8
- jobOutput?: JobParameterBag;
8
+ jobOutput?: JobParameterBagProperties;
9
9
  progress?: number;
10
10
  }
11
11
  export declare abstract class JobBase<T extends JobBaseProperties> extends McmaResource implements JobBaseProperties {
@@ -1,5 +1,8 @@
1
- import { McmaObject } from "./mcma-object";
2
- export declare class JobParameterBag extends McmaObject {
1
+ import { McmaObject, McmaObjectProperties } from "./mcma-object";
2
+ export interface JobParameterBagProperties extends McmaObjectProperties {
3
+ [key: string]: any;
4
+ }
5
+ export declare class JobParameterBag extends McmaObject implements JobParameterBagProperties {
3
6
  [key: string]: any;
4
7
  constructor(properties?: {
5
8
  [key: string]: any;
@@ -1,10 +1,10 @@
1
1
  import { McmaResource, McmaResourceProperties } from "./mcma-resource";
2
- import { JobParameter } from "./job-parameter";
2
+ import { JobParameter, JobParameterProperties } from "./job-parameter";
3
3
  export interface JobProfileProperties extends McmaResourceProperties {
4
4
  name: string;
5
- inputParameters?: JobParameter[];
6
- outputParameters?: JobParameter[];
7
- optionalInputParameters?: JobParameter[];
5
+ inputParameters?: JobParameterProperties[];
6
+ outputParameters?: JobParameterProperties[];
7
+ optionalInputParameters?: JobParameterProperties[];
8
8
  }
9
9
  export declare class JobProfile extends McmaResource implements JobProfileProperties {
10
10
  name: string;
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.JobProfile = void 0;
4
4
  const mcma_resource_1 = require("./mcma-resource");
5
+ const job_parameter_1 = require("./job-parameter");
5
6
  class JobProfile extends mcma_resource_1.McmaResource {
6
7
  constructor(properties) {
7
8
  super("JobProfile", properties);
@@ -9,7 +10,15 @@ class JobProfile extends mcma_resource_1.McmaResource {
9
10
  this.checkProperty("inputParameters", "Array", false);
10
11
  this.checkProperty("outputParameters", "Array", false);
11
12
  this.checkProperty("optionalInputParameters", "Array", false);
12
- this.checkProperty("customProperties", "object", false);
13
+ if (Array.isArray(this.inputParameters)) {
14
+ this.inputParameters = this.inputParameters.map(ip => new job_parameter_1.JobParameter(ip));
15
+ }
16
+ if (Array.isArray(this.optionalInputParameters)) {
17
+ this.optionalInputParameters = this.optionalInputParameters.map(ip => new job_parameter_1.JobParameter(ip));
18
+ }
19
+ if (Array.isArray(this.outputParameters)) {
20
+ this.outputParameters = this.outputParameters.map(ip => new job_parameter_1.JobParameter(ip));
21
+ }
13
22
  }
14
23
  }
15
24
  exports.JobProfile = JobProfile;
@@ -1,11 +1,11 @@
1
1
  import { JobBase, JobBaseProperties } from "../job-base";
2
- import { JobParameterBag } from "../job-parameter-bag";
2
+ import { JobParameterBag, JobParameterBagProperties } from "../job-parameter-bag";
3
3
  import { McmaTracker, McmaTrackerProperties } from "../mcma-tracker";
4
4
  import { NotificationEndpoint, NotificationEndpointProperties } from "../notification-endpoint";
5
5
  export interface JobProperties extends JobBaseProperties {
6
6
  parentId?: string;
7
7
  jobProfileId: string;
8
- jobInput?: JobParameterBag;
8
+ jobInput?: JobParameterBagProperties;
9
9
  timeout?: number;
10
10
  deadline?: Date | string;
11
11
  tracker?: McmaTrackerProperties;
@@ -1,6 +1,8 @@
1
1
  import { McmaObject, McmaObjectProperties } from "./mcma-object";
2
2
  export interface LocatorProperties extends McmaObjectProperties {
3
+ url: string;
3
4
  }
4
5
  export declare abstract class Locator extends McmaObject implements LocatorProperties {
6
+ url: string;
5
7
  protected constructor(type: string, properties?: LocatorProperties);
6
8
  }
@@ -5,6 +5,7 @@ const mcma_object_1 = require("./mcma-object");
5
5
  class Locator extends mcma_object_1.McmaObject {
6
6
  constructor(type, properties) {
7
7
  super(type, properties);
8
+ this.checkProperty("url", "string", true);
8
9
  }
9
10
  }
10
11
  exports.Locator = Locator;
@@ -16,7 +16,7 @@ class Service extends mcma_resource_1.McmaResource {
16
16
  try {
17
17
  this.authContext = JSON.parse(properties.authContext);
18
18
  }
19
- catch (_a) {
19
+ catch {
20
20
  this.authContext = properties.authContext;
21
21
  }
22
22
  }
package/dist/lib/utils.js CHANGED
@@ -2,15 +2,14 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Utils = void 0;
4
4
  const mcma_exception_1 = require("./mcma-exception");
5
- const validUrl = new RegExp("^(https?:\\/\\/)?" + // protocol
6
- "((([a-z\\d]([a-z\\d-]*[a-z\\d])*)\\.)+[a-z]{2,}|" + // domain name
7
- "((\\d{1,3}\\.){3}\\d{1,3}))" + // OR ip (v4) address
8
- "(\\:\\d+)?(\\/[-a-z\\d%_.~+]*)*" + // port and path
9
- "(\\?[;&a-z\\d%_.~+=-]*)?" + // query string
10
- "(\\#[-a-z\\d_]*)?$", "i" // fragment locator
11
- );
12
5
  function isValidUrl(url) {
13
- return validUrl.test(url);
6
+ try {
7
+ new URL(url);
8
+ return true;
9
+ }
10
+ catch (error) {
11
+ return false;
12
+ }
14
13
  }
15
14
  function getTypeName(type) {
16
15
  if (typeof type === "function") {
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "@mcma/core",
3
- "version": "0.13.26",
3
+ "version": "0.14.0",
4
4
  "description": "Node module with type definitions and helper utils for the EBU MCMA framework",
5
5
  "engines": {
6
- "node": "^12.19.0"
6
+ "node": "^14.17.0"
7
7
  },
8
8
  "type": "commonjs",
9
9
  "main": "dist/index.js",
@@ -32,7 +32,7 @@
32
32
  "uuid": "^7.0.3"
33
33
  },
34
34
  "devDependencies": {
35
- "@types/node": "^13.13.26",
35
+ "@types/node": "^14.17.22",
36
36
  "@types/uuid": "^7.0.4",
37
37
  "jasmine": "^3.4.0"
38
38
  }