arvo-core 1.1.21 → 1.2.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.
@@ -4,33 +4,85 @@ import { ArvoOrchestratorVersion, ArvoOrchestrationSubjectContent } from './type
4
4
  */
5
5
  export default class ArvoOrchestrationSubject {
6
6
  /**
7
- * Creates a new Arvo orchestration subject.
7
+ * Represents a wildcard version number used when version matching is not required.
8
+ * Format follows semantic versioning pattern.
9
+ */
10
+ static readonly WildCardMachineVersion: ArvoOrchestratorVersion;
11
+ /**
12
+ * Creates a new Arvo orchestration subject with basic required parameters.
13
+ * This is a convenience method that wraps the more detailed {@link create} method.
14
+ *
15
+ * @param param - Configuration object for the orchestration subject
16
+ * @param param.orchestator - Name identifier of the orchestrator
17
+ * @param param.version - Version of the orchestrator. If null, defaults to {@link WildCardMachineVersion}
18
+ * @param param.initiator - Identifier of the entity initiating the orchestration
19
+ * @param param.meta - Optional metadata key-value pairs for additional orchestration context
20
+ * @returns A base64 encoded string containing the compressed orchestration subject data
21
+ * @throws Error if the provided parameters result in invalid subject content
8
22
  *
9
- * @param param - Parameters for creating the subject
10
- * @param param.orchestrator - Name of the orchestrator
11
- * @param param.version - Version of the orchestrator
12
- * @param param.initiator - Initiator of the orchestration
13
- * @returns A base64 encoded string representing the orchestration subject
23
+ * @example
24
+ * ```typescript
25
+ * const subject = ArvoOrchestrationSubject.new({
26
+ * orchestator: "mainProcess",
27
+ * version: "1.0.0",
28
+ * initiator: "systemA"
29
+ * });
30
+ *
31
+ * // With metadata
32
+ * const subjectWithMeta = ArvoOrchestrationSubject.new({
33
+ * orchestator: "com.company.mainProcess",
34
+ * version: "1.0.0",
35
+ * initiator: "com.company.systemA",
36
+ * meta: {
37
+ * priority: "high",
38
+ * environment: "production"
39
+ * }
40
+ * });
41
+ * ```
14
42
  */
15
43
  static new(param: {
16
44
  orchestator: string;
17
- version: ArvoOrchestratorVersion;
45
+ version: ArvoOrchestratorVersion | null;
18
46
  initiator: string;
47
+ meta?: Record<string, string>;
19
48
  }): string;
20
49
  /**
21
- * Creates an Arvo orchestration subject from the provided content.
50
+ * Creates an Arvo orchestration subject from detailed content parameters.
51
+ * The content is validated, compressed using zlib, and encoded in base64 format.
52
+ *
53
+ * @param param - Detailed orchestration subject content following the {@link ArvoOrchestrationSubjectContent} structure
54
+ * @returns A base64 encoded string containing the compressed orchestration subject data
55
+ * @throws Error if validation fails or compression encounters an error
22
56
  *
23
- * @param param - The orchestration subject content
24
- * @returns A base64 encoded string representing the orchestration subject
25
- * @throws Error if the provided content is invalid or if compression fails
57
+ * @example
58
+ * ```typescript
59
+ * const subject = ArvoOrchestrationSubject.create({
60
+ * orchestrator: {
61
+ * name: "mainProcess",
62
+ * version: "1.0.0"
63
+ * },
64
+ * execution: {
65
+ * id: "550e8400-e29b-41d4-a716-446655440000",
66
+ * initiator: "systemA"
67
+ * }
68
+ * });
69
+ * ```
26
70
  */
27
71
  static create(param: ArvoOrchestrationSubjectContent): string;
28
72
  /**
29
- * Parses a base64 encoded Arvo orchestration subject string.
73
+ * Parses a base64 encoded orchestration subject string back into its structured content form.
74
+ * Performs decompression, JSON parsing, and validation of the subject content.
75
+ *
76
+ * @param subject - Base64 encoded string representing the compressed orchestration subject
77
+ * @returns The decoded and validated {@link ArvoOrchestrationSubjectContent}
78
+ * @throws Error if decompression, parsing, or validation fails
30
79
  *
31
- * @param subject - The base64 encoded subject string to parse
32
- * @returns The parsed ArvoOrchestrationSubjectContent
33
- * @throws Error if parsing or validation fails
80
+ * @example
81
+ * ```typescript
82
+ * const content = ArvoOrchestrationSubject.parse(encodedSubject);
83
+ * console.log(content.orchestrator.name);
84
+ * console.log(content.execution.id);
85
+ * ```
34
86
  */
35
87
  static parse(subject: string): ArvoOrchestrationSubjectContent;
36
88
  }
@@ -34,32 +34,72 @@ var ArvoOrchestrationSubject = /** @class */ (function () {
34
34
  function ArvoOrchestrationSubject() {
35
35
  }
36
36
  /**
37
- * Creates a new Arvo orchestration subject.
37
+ * Creates a new Arvo orchestration subject with basic required parameters.
38
+ * This is a convenience method that wraps the more detailed {@link create} method.
38
39
  *
39
- * @param param - Parameters for creating the subject
40
- * @param param.orchestrator - Name of the orchestrator
41
- * @param param.version - Version of the orchestrator
42
- * @param param.initiator - Initiator of the orchestration
43
- * @returns A base64 encoded string representing the orchestration subject
40
+ * @param param - Configuration object for the orchestration subject
41
+ * @param param.orchestator - Name identifier of the orchestrator
42
+ * @param param.version - Version of the orchestrator. If null, defaults to {@link WildCardMachineVersion}
43
+ * @param param.initiator - Identifier of the entity initiating the orchestration
44
+ * @param param.meta - Optional metadata key-value pairs for additional orchestration context
45
+ * @returns A base64 encoded string containing the compressed orchestration subject data
46
+ * @throws Error if the provided parameters result in invalid subject content
47
+ *
48
+ * @example
49
+ * ```typescript
50
+ * const subject = ArvoOrchestrationSubject.new({
51
+ * orchestator: "mainProcess",
52
+ * version: "1.0.0",
53
+ * initiator: "systemA"
54
+ * });
55
+ *
56
+ * // With metadata
57
+ * const subjectWithMeta = ArvoOrchestrationSubject.new({
58
+ * orchestator: "com.company.mainProcess",
59
+ * version: "1.0.0",
60
+ * initiator: "com.company.systemA",
61
+ * meta: {
62
+ * priority: "high",
63
+ * environment: "production"
64
+ * }
65
+ * });
66
+ * ```
44
67
  */
45
68
  ArvoOrchestrationSubject.new = function (param) {
69
+ var _a, _b;
46
70
  return ArvoOrchestrationSubject.create({
47
71
  orchestrator: {
48
72
  name: param.orchestator,
49
- version: param.version,
73
+ version: (_a = param.version) !== null && _a !== void 0 ? _a : ArvoOrchestrationSubject.WildCardMachineVersion,
50
74
  },
51
75
  execution: {
52
76
  id: (0, uuid_1.v4)(),
53
77
  initiator: param.initiator,
54
78
  },
79
+ meta: (_b = param.meta) !== null && _b !== void 0 ? _b : {}
55
80
  });
56
81
  };
57
82
  /**
58
- * Creates an Arvo orchestration subject from the provided content.
83
+ * Creates an Arvo orchestration subject from detailed content parameters.
84
+ * The content is validated, compressed using zlib, and encoded in base64 format.
85
+ *
86
+ * @param param - Detailed orchestration subject content following the {@link ArvoOrchestrationSubjectContent} structure
87
+ * @returns A base64 encoded string containing the compressed orchestration subject data
88
+ * @throws Error if validation fails or compression encounters an error
59
89
  *
60
- * @param param - The orchestration subject content
61
- * @returns A base64 encoded string representing the orchestration subject
62
- * @throws Error if the provided content is invalid or if compression fails
90
+ * @example
91
+ * ```typescript
92
+ * const subject = ArvoOrchestrationSubject.create({
93
+ * orchestrator: {
94
+ * name: "mainProcess",
95
+ * version: "1.0.0"
96
+ * },
97
+ * execution: {
98
+ * id: "550e8400-e29b-41d4-a716-446655440000",
99
+ * initiator: "systemA"
100
+ * }
101
+ * });
102
+ * ```
63
103
  */
64
104
  ArvoOrchestrationSubject.create = function (param) {
65
105
  try {
@@ -76,11 +116,19 @@ var ArvoOrchestrationSubject = /** @class */ (function () {
76
116
  }
77
117
  };
78
118
  /**
79
- * Parses a base64 encoded Arvo orchestration subject string.
119
+ * Parses a base64 encoded orchestration subject string back into its structured content form.
120
+ * Performs decompression, JSON parsing, and validation of the subject content.
80
121
  *
81
- * @param subject - The base64 encoded subject string to parse
82
- * @returns The parsed ArvoOrchestrationSubjectContent
83
- * @throws Error if parsing or validation fails
122
+ * @param subject - Base64 encoded string representing the compressed orchestration subject
123
+ * @returns The decoded and validated {@link ArvoOrchestrationSubjectContent}
124
+ * @throws Error if decompression, parsing, or validation fails
125
+ *
126
+ * @example
127
+ * ```typescript
128
+ * const content = ArvoOrchestrationSubject.parse(encodedSubject);
129
+ * console.log(content.orchestrator.name);
130
+ * console.log(content.execution.id);
131
+ * ```
84
132
  */
85
133
  ArvoOrchestrationSubject.parse = function (subject) {
86
134
  try {
@@ -97,6 +145,11 @@ var ArvoOrchestrationSubject = /** @class */ (function () {
97
145
  throw new Error((0, utils_1.cleanString)("\n Error parsing orchestration subject string to the context. \n Error -> ".concat(e.message, " \n subject -> ").concat(subject, "\n ")));
98
146
  }
99
147
  };
148
+ /**
149
+ * Represents a wildcard version number used when version matching is not required.
150
+ * Format follows semantic versioning pattern.
151
+ */
152
+ ArvoOrchestrationSubject.WildCardMachineVersion = '0.0.0';
100
153
  return ArvoOrchestrationSubject;
101
154
  }());
102
155
  exports.default = ArvoOrchestrationSubject;
@@ -21,6 +21,7 @@ export declare const ArvoOrchestrationSubjectContentSchema: z.ZodObject<{
21
21
  id: string;
22
22
  initiator: string;
23
23
  }>;
24
+ meta: z.ZodRecord<z.ZodString, z.ZodString>;
24
25
  }, "strip", z.ZodTypeAny, {
25
26
  orchestrator: {
26
27
  name: string;
@@ -30,6 +31,7 @@ export declare const ArvoOrchestrationSubjectContentSchema: z.ZodObject<{
30
31
  id: string;
31
32
  initiator: string;
32
33
  };
34
+ meta: Record<string, string>;
33
35
  }, {
34
36
  orchestrator: {
35
37
  name: string;
@@ -39,4 +41,5 @@ export declare const ArvoOrchestrationSubjectContentSchema: z.ZodObject<{
39
41
  id: string;
40
42
  initiator: string;
41
43
  };
44
+ meta: Record<string, string>;
42
45
  }>;
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ArvoOrchestrationSubjectContentSchema = exports.ArvoOrchestratorVersionSchema = void 0;
4
4
  var zod_1 = require("zod");
5
+ var utils_1 = require("../utils");
5
6
  // Zod schema for ArvoOchestratorVersion
6
7
  exports.ArvoOrchestratorVersionSchema = zod_1.z
7
8
  .string()
@@ -35,5 +36,8 @@ exports.ArvoOrchestrationSubjectContentSchema = zod_1.z
35
36
  .describe('Entity or process that initiated the execution'),
36
37
  })
37
38
  .describe('Details about the current execution'),
39
+ meta: zod_1.z
40
+ .record(zod_1.z.string(), zod_1.z.string())
41
+ .describe((0, utils_1.cleanString)("\n Additional metadata for the orchestration process. Store essential key-value pairs \n that provide context or configuration details necessary for the orchestration. \n Use selectively to maintain clarity and avoid storing unnecessary information. \n "))
38
42
  })
39
43
  .describe('Context information for Arvo orchestration');
@@ -62,4 +62,10 @@ export type ArvoOrchestrationSubjectContent = {
62
62
  */
63
63
  initiator: string;
64
64
  };
65
+ /**
66
+ * Additional metadata for the orchestration process. Store essential key-value pairs
67
+ * that provide context or configuration details necessary for the orchestration.
68
+ * Use selectively to maintain clarity and avoid storing unnecessary information.
69
+ */
70
+ meta: Record<string, string>;
65
71
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "arvo-core",
3
- "version": "1.1.21",
3
+ "version": "1.2.0",
4
4
  "description": "This core package contains all the core classes and components of the Arvo Event Driven System",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {