arvo-core 1.2.0 → 1.2.2
Sign up to get free protection for your applications and to get access to all the features.
@@ -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.
|
@@ -58,10 +58,10 @@ import ArvoOrchestratorContract from '.';
|
|
58
58
|
* In this example, the actual init schema will be an intersection of the provided schema
|
59
59
|
* and the OrchestrationInitEventBaseSchema, ensuring all necessary fields are included.
|
60
60
|
*/
|
61
|
-
export declare const createArvoOrchestratorContract: <TUri extends string, TName extends string, TInit extends z.
|
61
|
+
export declare const createArvoOrchestratorContract: <TUri extends string, TName extends string, TInit extends z.AnyZodObject, TComplete extends z.AnyZodObject>(param: ICreateArvoOrchestratorContract<TUri, TName, TInit, TComplete>) => ArvoOrchestratorContract<TUri, `arvo.orc.${TName}`, z.ZodObject<z.objectUtil.extendShape<{
|
62
62
|
parentSubject$$: z.ZodNullable<z.ZodString>;
|
63
|
-
}, "
|
64
|
-
parentSubject$$:
|
65
|
-
}, {
|
66
|
-
parentSubject$$:
|
67
|
-
}
|
63
|
+
}, TInit["shape"]>, TInit["_def"]["unknownKeys"], TInit["_def"]["catchall"], z.objectOutputType<z.objectUtil.extendShape<{
|
64
|
+
parentSubject$$: z.ZodNullable<z.ZodString>;
|
65
|
+
}, TInit["shape"]>, TInit["_def"]["catchall"], TInit["_def"]["unknownKeys"]>, z.objectInputType<z.objectUtil.extendShape<{
|
66
|
+
parentSubject$$: z.ZodNullable<z.ZodString>;
|
67
|
+
}, TInit["shape"]>, TInit["_def"]["catchall"], TInit["_def"]["unknownKeys"]>>, `arvo.orc.${TName}.done`, TComplete>;
|
@@ -4,7 +4,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
4
4
|
};
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
6
6
|
exports.createArvoOrchestratorContract = void 0;
|
7
|
-
var zod_1 = require("zod");
|
8
7
|
var _1 = __importDefault(require("."));
|
9
8
|
var typegen_1 = require("./typegen");
|
10
9
|
var schema_1 = require("./schema");
|
@@ -86,11 +85,12 @@ var createArvoOrchestratorContract = function (param) {
|
|
86
85
|
if (!isLowerAlphanumeric(param.name)) {
|
87
86
|
throw new Error("Invalid 'name' = '".concat(param.name, "'. The 'name' must only contain alphanumeric characters. e.g. test.orchestrator"));
|
88
87
|
}
|
88
|
+
var mergedSchema = schema_1.OrchestrationInitEventBaseSchema.merge(param.schema.init);
|
89
89
|
return new _1.default({
|
90
90
|
uri: param.uri,
|
91
91
|
init: {
|
92
92
|
type: typegen_1.ArvoOrchestratorEventTypeGen.init(param.name),
|
93
|
-
schema:
|
93
|
+
schema: mergedSchema,
|
94
94
|
},
|
95
95
|
complete: {
|
96
96
|
type: typegen_1.ArvoOrchestratorEventTypeGen.complete(param.name),
|