arvo-core 1.2.0 → 1.2.1

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.
@@ -46,6 +46,45 @@ export default class ArvoOrchestrationSubject {
46
46
  initiator: string;
47
47
  meta?: Record<string, string>;
48
48
  }): string;
49
+ /**
50
+ * Creates a new orchestration subject string from an existing parent subject.
51
+ * This method parses the parent subject, merges its metadata with new metadata (if available),
52
+ * and creates a new subject with updated orchestrator information while maintaining
53
+ * the relationship to the parent context.
54
+ *
55
+ * @param param - Configuration object for creating a new subject from a parent
56
+ * @param param.orchestator - Name identifier of the new orchestrator
57
+ * @param param.version - Version of the new orchestrator. If null, defaults to {@link WildCardMachineVersion}
58
+ * @param param.subject - Base64 encoded string of the parent orchestration subject
59
+ * @param param.meta - Optional additional metadata to merge with the parent's metadata
60
+ * @returns A new base64 encoded string containing the compressed orchestration subject data
61
+ * @throws Error if the parent subject is invalid or if the new parameters result in invalid subject content
62
+ *
63
+ * @example
64
+ * ```typescript
65
+ * // Create a parent subject
66
+ * const parentSubject = ArvoOrchestrationSubject.new({
67
+ * orchestator: "parentProcess",
68
+ * version: "1.0.0",
69
+ * initiator: "systemA",
70
+ * meta: { environment: "production" }
71
+ * });
72
+ *
73
+ * // Create a new subject from the parent
74
+ * const childSubject = ArvoOrchestrationSubject.from({
75
+ * orchestator: "childProcess",
76
+ * version: "2.0.0",
77
+ * subject: parentSubject,
78
+ * meta: { step: "processing" } // Will be merged with parent's metadata
79
+ * });
80
+ * ```
81
+ */
82
+ static from(param: {
83
+ orchestator: string;
84
+ version: ArvoOrchestratorVersion | null;
85
+ subject: string;
86
+ meta?: Record<string, string>;
87
+ }): string;
49
88
  /**
50
89
  * Creates an Arvo orchestration subject from detailed content parameters.
51
90
  * The content is validated, compressed using zlib, and encoded in base64 format.
@@ -1,4 +1,15 @@
1
1
  "use strict";
2
+ var __assign = (this && this.__assign) || function () {
3
+ __assign = Object.assign || function(t) {
4
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
5
+ s = arguments[i];
6
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
+ t[p] = s[p];
8
+ }
9
+ return t;
10
+ };
11
+ return __assign.apply(this, arguments);
12
+ };
2
13
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
14
  if (k2 === undefined) k2 = k;
4
15
  var desc = Object.getOwnPropertyDescriptor(m, k);
@@ -79,6 +90,49 @@ var ArvoOrchestrationSubject = /** @class */ (function () {
79
90
  meta: (_b = param.meta) !== null && _b !== void 0 ? _b : {}
80
91
  });
81
92
  };
93
+ /**
94
+ * Creates a new orchestration subject string from an existing parent subject.
95
+ * This method parses the parent subject, merges its metadata with new metadata (if available),
96
+ * and creates a new subject with updated orchestrator information while maintaining
97
+ * the relationship to the parent context.
98
+ *
99
+ * @param param - Configuration object for creating a new subject from a parent
100
+ * @param param.orchestator - Name identifier of the new orchestrator
101
+ * @param param.version - Version of the new orchestrator. If null, defaults to {@link WildCardMachineVersion}
102
+ * @param param.subject - Base64 encoded string of the parent orchestration subject
103
+ * @param param.meta - Optional additional metadata to merge with the parent's metadata
104
+ * @returns A new base64 encoded string containing the compressed orchestration subject data
105
+ * @throws Error if the parent subject is invalid or if the new parameters result in invalid subject content
106
+ *
107
+ * @example
108
+ * ```typescript
109
+ * // Create a parent subject
110
+ * const parentSubject = ArvoOrchestrationSubject.new({
111
+ * orchestator: "parentProcess",
112
+ * version: "1.0.0",
113
+ * initiator: "systemA",
114
+ * meta: { environment: "production" }
115
+ * });
116
+ *
117
+ * // Create a new subject from the parent
118
+ * const childSubject = ArvoOrchestrationSubject.from({
119
+ * orchestator: "childProcess",
120
+ * version: "2.0.0",
121
+ * subject: parentSubject,
122
+ * meta: { step: "processing" } // Will be merged with parent's metadata
123
+ * });
124
+ * ```
125
+ */
126
+ ArvoOrchestrationSubject.from = function (param) {
127
+ var _a, _b, _c;
128
+ var parsedSubject = ArvoOrchestrationSubject.parse(param.subject);
129
+ return ArvoOrchestrationSubject.new({
130
+ initiator: parsedSubject.orchestrator.name,
131
+ version: (_a = param.version) !== null && _a !== void 0 ? _a : ArvoOrchestrationSubject.WildCardMachineVersion,
132
+ orchestator: param.orchestator,
133
+ meta: __assign(__assign({}, ((_b = parsedSubject.meta) !== null && _b !== void 0 ? _b : {})), ((_c = param.meta) !== null && _c !== void 0 ? _c : {}))
134
+ });
135
+ };
82
136
  /**
83
137
  * Creates an Arvo orchestration subject from detailed content parameters.
84
138
  * The content is validated, compressed using zlib, and encoded in base64 format.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "arvo-core",
3
- "version": "1.2.0",
3
+ "version": "1.2.1",
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": {