@fractal_cloud/sdk 0.1.1 → 1.0.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.
- package/README.md +68 -28
- package/dist/index.cjs +2070 -0
- package/dist/index.d.cts +1625 -0
- package/dist/index.d.mts +1625 -0
- package/dist/index.mjs +2029 -0
- package/package.json +3 -2
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,2029 @@
|
|
|
1
|
+
import superagent from "superagent";
|
|
2
|
+
|
|
3
|
+
//#region src/values/kebab_case_string.ts
|
|
4
|
+
/**
|
|
5
|
+
* A constant variable representing a default kebab-case string.
|
|
6
|
+
*
|
|
7
|
+
* The `DEFAULT_KEBAB_CASE_STRING` is initialized with a `value` key,
|
|
8
|
+
* containing an empty string as its default value.
|
|
9
|
+
*
|
|
10
|
+
* This variable is declared as a constant to prevent modification
|
|
11
|
+
* and is designed to not pass validation checks.
|
|
12
|
+
*
|
|
13
|
+
* @type {KebabCaseString}
|
|
14
|
+
*/
|
|
15
|
+
const DEFAULT_KEBAB_CASE_STRING = {
|
|
16
|
+
_type: "kebab",
|
|
17
|
+
value: "",
|
|
18
|
+
equals: () => false,
|
|
19
|
+
toString: () => ""
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* Validates whether a given string follows the kebab-case format.
|
|
23
|
+
*
|
|
24
|
+
* A string is considered as valid kebab-case if it:
|
|
25
|
+
* - Starts with a lowercase letter.
|
|
26
|
+
* - Contains only lowercase letters, numbers, and hyphens.
|
|
27
|
+
* - Does not have consecutive hyphens.
|
|
28
|
+
* - Does not end or begin with a hyphen.
|
|
29
|
+
*
|
|
30
|
+
* @param {string} value - The string to validate.
|
|
31
|
+
* @returns {string[]} - An empty array if the string is valid, otherwise an array containing an error message.
|
|
32
|
+
*/
|
|
33
|
+
const isValidKebabCaseString = (value) => {
|
|
34
|
+
if (!/^[a-z][a-z0-9]*(-[a-z][a-z0-9]*)*$/.test(value)) return [` Value '${value}' must be in kebab-case`];
|
|
35
|
+
return [];
|
|
36
|
+
};
|
|
37
|
+
/**
|
|
38
|
+
* Creates a builder for constructing a KebabCaseString object. The builder enforces Kebab case formatting and ensures
|
|
39
|
+
* a valid string is set before building. Once built, the KebabCaseString object becomes immutable.
|
|
40
|
+
*
|
|
41
|
+
* @function getKebabCaseStringBuilder
|
|
42
|
+
* @returns {Object} A builder object with the following methods:
|
|
43
|
+
* - `withValue(value: string): Object` – Sets the value of the KebabCaseString. Throws a `RangeError` if the input is not in Kebab case format (e.g., "example-string").
|
|
44
|
+
* - `reset(): void` – Resets the builder to its default state, clearing the current value.
|
|
45
|
+
* - `build(): KebabCaseString` – Constructs and returns a KebabCaseString object based on the current state. Throws a `SyntaxError` if no value has been set before building.
|
|
46
|
+
*/
|
|
47
|
+
const getKebabCaseStringBuilder = () => {
|
|
48
|
+
const internalState = { ...DEFAULT_KEBAB_CASE_STRING };
|
|
49
|
+
const builder = {
|
|
50
|
+
withValue: (value) => {
|
|
51
|
+
internalState.value = value;
|
|
52
|
+
return builder;
|
|
53
|
+
},
|
|
54
|
+
reset: () => {
|
|
55
|
+
internalState.value = DEFAULT_KEBAB_CASE_STRING.value;
|
|
56
|
+
return builder;
|
|
57
|
+
},
|
|
58
|
+
build: () => {
|
|
59
|
+
const validationErrors = isValidKebabCaseString(internalState.value);
|
|
60
|
+
if (validationErrors.length > 0) throw new SyntaxError(validationErrors.join("\n"));
|
|
61
|
+
return {
|
|
62
|
+
...internalState,
|
|
63
|
+
equals: (other) => internalState.value === other.value,
|
|
64
|
+
toString: () => internalState.value
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
return builder;
|
|
69
|
+
};
|
|
70
|
+
let KebabCaseString$1;
|
|
71
|
+
(function(_KebabCaseString) {
|
|
72
|
+
_KebabCaseString.getBuilder = getKebabCaseStringBuilder;
|
|
73
|
+
})(KebabCaseString$1 || (KebabCaseString$1 = {}));
|
|
74
|
+
|
|
75
|
+
//#endregion
|
|
76
|
+
//#region src/values/version.ts
|
|
77
|
+
const equals$4 = (a, b) => a.major === b.major && a.minor === b.minor && a.patch === b.patch;
|
|
78
|
+
const toString$2 = (version) => `v${version.major}.${version.minor}.${version.patch}`;
|
|
79
|
+
/**
|
|
80
|
+
* Represents the default version for an application or library.
|
|
81
|
+
*
|
|
82
|
+
* This variable is declared as a constant to prevent modification
|
|
83
|
+
* and is designed to not pass validation checks.
|
|
84
|
+
*/
|
|
85
|
+
const DEFAULT_VERSION = {
|
|
86
|
+
major: 0,
|
|
87
|
+
minor: 0,
|
|
88
|
+
patch: 0,
|
|
89
|
+
equals: (other) => equals$4(DEFAULT_VERSION, other)
|
|
90
|
+
};
|
|
91
|
+
/**
|
|
92
|
+
* Validates if the provided version object is properly initialized or equivalent to the default version.
|
|
93
|
+
*
|
|
94
|
+
* @param {Version} version - The version object to be validated.
|
|
95
|
+
* @returns {string[]} An array of error messages. If the version is equivalent to the default version, it returns
|
|
96
|
+
* an array containing one error message. Otherwise, it returns an empty array.
|
|
97
|
+
*/
|
|
98
|
+
const isValidVersion = (version) => {
|
|
99
|
+
if (equals$4(version, DEFAULT_VERSION)) return [" Version must be initialized"];
|
|
100
|
+
return [];
|
|
101
|
+
};
|
|
102
|
+
/**
|
|
103
|
+
* Creates a builder object for constructing and managing version objects.
|
|
104
|
+
* The builder allows for setting major, minor, and patch versions, resetting to defaults,
|
|
105
|
+
* and building the final version object. The default version is considered uninitialized and
|
|
106
|
+
* an error is thrown if build is called without initializing the version.
|
|
107
|
+
*
|
|
108
|
+
* @function getVersionBuilder
|
|
109
|
+
* @returns {VersionBuilder} Returns a builder object with methods to define and construct a version.
|
|
110
|
+
*
|
|
111
|
+
* - `withMajor(major: number): builder`
|
|
112
|
+
* Sets the major version number and returns the builder.
|
|
113
|
+
*
|
|
114
|
+
* - `withMinor(minor: number): builder`
|
|
115
|
+
* Sets the minor version number and returns the builder.
|
|
116
|
+
*
|
|
117
|
+
* - `withPatch(patch: number): builder`
|
|
118
|
+
* Sets the patch version number and returns the builder.
|
|
119
|
+
*
|
|
120
|
+
* - `reset(): builder`
|
|
121
|
+
* Resets the version to the default values (major: 0, minor: 0, patch: 0) and returns the builder.
|
|
122
|
+
*
|
|
123
|
+
* - `build(): Version`
|
|
124
|
+
* Constructs and returns the final version object. Throws a `SyntaxError` if the version
|
|
125
|
+
* is not initialized (when it matches the default version).
|
|
126
|
+
*/
|
|
127
|
+
const getVersionBuilder = () => {
|
|
128
|
+
const internalState = { ...DEFAULT_VERSION };
|
|
129
|
+
const builder = {
|
|
130
|
+
withMajor: (major) => {
|
|
131
|
+
internalState.major = major;
|
|
132
|
+
if (major < 0) throw new RangeError("Major version must be non-negative");
|
|
133
|
+
return builder;
|
|
134
|
+
},
|
|
135
|
+
withMinor: (minor) => {
|
|
136
|
+
if (minor < 0) throw new RangeError("Minor version must be non-negative");
|
|
137
|
+
internalState.minor = minor;
|
|
138
|
+
return builder;
|
|
139
|
+
},
|
|
140
|
+
withPatch: (patch) => {
|
|
141
|
+
if (patch < 0) throw new RangeError("Patch version must be non-negative");
|
|
142
|
+
internalState.patch = patch;
|
|
143
|
+
return builder;
|
|
144
|
+
},
|
|
145
|
+
reset: () => {
|
|
146
|
+
internalState.major = DEFAULT_VERSION.major;
|
|
147
|
+
internalState.minor = DEFAULT_VERSION.minor;
|
|
148
|
+
internalState.patch = DEFAULT_VERSION.patch;
|
|
149
|
+
return builder;
|
|
150
|
+
},
|
|
151
|
+
build: () => {
|
|
152
|
+
const validationErrors = isValidVersion(internalState);
|
|
153
|
+
if (validationErrors.length > 0) throw new SyntaxError(validationErrors.join("\n"));
|
|
154
|
+
const builtVersion = {
|
|
155
|
+
...internalState,
|
|
156
|
+
equals: (other) => equals$4(builtVersion, other),
|
|
157
|
+
toString: () => toString$2(builtVersion)
|
|
158
|
+
};
|
|
159
|
+
return builtVersion;
|
|
160
|
+
}
|
|
161
|
+
};
|
|
162
|
+
return builder;
|
|
163
|
+
};
|
|
164
|
+
let Version$1;
|
|
165
|
+
(function(_Version) {
|
|
166
|
+
_Version.getBuilder = getVersionBuilder;
|
|
167
|
+
})(Version$1 || (Version$1 = {}));
|
|
168
|
+
|
|
169
|
+
//#endregion
|
|
170
|
+
//#region src/values/owner_type.ts
|
|
171
|
+
/**
|
|
172
|
+
* Enum representing the type of ownership for an entity.
|
|
173
|
+
*
|
|
174
|
+
* This enumeration can be used to differentiate between entities owned by individuals
|
|
175
|
+
* and those owned by organizations.
|
|
176
|
+
*
|
|
177
|
+
* @enum {string}
|
|
178
|
+
* @readonly
|
|
179
|
+
* @property {string} Personal - Represents ownership by an individual person.
|
|
180
|
+
* @property {string} Organizational - Represents ownership by an organization or group.
|
|
181
|
+
*/
|
|
182
|
+
let OwnerType$1 = /* @__PURE__ */ function(OwnerType) {
|
|
183
|
+
OwnerType["Personal"] = "Personal";
|
|
184
|
+
OwnerType["Organizational"] = "Organizational";
|
|
185
|
+
return OwnerType;
|
|
186
|
+
}({});
|
|
187
|
+
|
|
188
|
+
//#endregion
|
|
189
|
+
//#region src/values/guid.ts
|
|
190
|
+
const isValidUuid = (value) => {
|
|
191
|
+
if (!/^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$/.test(value)) return [` Value '${value}' must be a valid uuid`];
|
|
192
|
+
return [];
|
|
193
|
+
};
|
|
194
|
+
|
|
195
|
+
//#endregion
|
|
196
|
+
//#region src/values/owner_id.ts
|
|
197
|
+
/**
|
|
198
|
+
* A constant variable representing the default owner ID.
|
|
199
|
+
*
|
|
200
|
+
* This variable is declared as a constant to prevent modification
|
|
201
|
+
* and is designed to not pass validation checks.
|
|
202
|
+
*/
|
|
203
|
+
const DEFAULT_OWNER_ID = {
|
|
204
|
+
_type: "ownerId",
|
|
205
|
+
value: "",
|
|
206
|
+
toString: () => ""
|
|
207
|
+
};
|
|
208
|
+
/**
|
|
209
|
+
* Validates whether the given string value is a valid UUID.
|
|
210
|
+
*
|
|
211
|
+
* This function checks if the provided `value` conforms to the UUID format.
|
|
212
|
+
* If the validation fails, an array containing an error message will be returned.
|
|
213
|
+
* If the validation passes, an empty array is returned.
|
|
214
|
+
*
|
|
215
|
+
* @param {string} value - The string value to be validated.
|
|
216
|
+
* @returns {string[]} An array containing error messages if invalid, or an empty array if valid.
|
|
217
|
+
*/
|
|
218
|
+
const isValidOwnerId = (value) => {
|
|
219
|
+
if (!value || !value.value) return ["[Owner Id] Value must be a non-empty string"];
|
|
220
|
+
return addContextToErrors$8(value, isValidUuid(value.value));
|
|
221
|
+
};
|
|
222
|
+
const addContextToErrors$8 = (value, errors) => {
|
|
223
|
+
return errors.map((error) => `[Owner Id: ${value.toString()}]${error}`);
|
|
224
|
+
};
|
|
225
|
+
/**
|
|
226
|
+
* Creates a builder for constructing a OwnerId object. The builder enforces uuid case formatting and ensures
|
|
227
|
+
* a valid string is set before building. Once built, the OwnerId object becomes immutable.
|
|
228
|
+
*
|
|
229
|
+
* @function getOwnerIdBuilder
|
|
230
|
+
* @returns {Object} A builder object with the following methods:
|
|
231
|
+
* - `withValue(value: string): Object` – Sets the value of the OwnerId. Throws a `RangeError` if the input is not in uuid format (e.g., "550e8400-e29b-41d4-a716-446655440000").
|
|
232
|
+
* - `reset(): void` – Resets the builder to its default state, clearing the current value.
|
|
233
|
+
* - `build(): OwnerId` – Constructs and returns a OwnerId object based on the current state. Throws a `SyntaxError` if no value has been set before building.
|
|
234
|
+
*/
|
|
235
|
+
const getOwnerIdBuilder = () => {
|
|
236
|
+
const internalState = { ...DEFAULT_OWNER_ID };
|
|
237
|
+
const builder = {
|
|
238
|
+
withValue: (value) => {
|
|
239
|
+
internalState.value = value;
|
|
240
|
+
return builder;
|
|
241
|
+
},
|
|
242
|
+
reset: () => {
|
|
243
|
+
internalState.value = DEFAULT_OWNER_ID.value;
|
|
244
|
+
return builder;
|
|
245
|
+
},
|
|
246
|
+
build: () => {
|
|
247
|
+
const validationErrors = isValidOwnerId(internalState);
|
|
248
|
+
if (validationErrors.length > 0) throw new SyntaxError(validationErrors.join("\n"));
|
|
249
|
+
return {
|
|
250
|
+
...internalState,
|
|
251
|
+
toString: () => internalState.value
|
|
252
|
+
};
|
|
253
|
+
}
|
|
254
|
+
};
|
|
255
|
+
return builder;
|
|
256
|
+
};
|
|
257
|
+
let OwnerId$1;
|
|
258
|
+
(function(_OwnerId) {
|
|
259
|
+
_OwnerId.getBuilder = getOwnerIdBuilder;
|
|
260
|
+
})(OwnerId$1 || (OwnerId$1 = {}));
|
|
261
|
+
|
|
262
|
+
//#endregion
|
|
263
|
+
//#region src/bounded_context/id.ts
|
|
264
|
+
const equals$3 = (a, b) => a.ownerType === b.ownerType && a.ownerId.value === b.ownerId.value && a.name.value === b.name.value;
|
|
265
|
+
/**
|
|
266
|
+
* A default value for the bounded context identifier used in the system.
|
|
267
|
+
* It contains values that will not pass validation checks.
|
|
268
|
+
*/
|
|
269
|
+
const DEFAULT_BOUNDED_CONTEXT_ID = {
|
|
270
|
+
_type: "bounded_context",
|
|
271
|
+
ownerType: OwnerType$1.Personal,
|
|
272
|
+
ownerId: DEFAULT_OWNER_ID,
|
|
273
|
+
name: DEFAULT_KEBAB_CASE_STRING,
|
|
274
|
+
equals: () => false,
|
|
275
|
+
toString: () => ""
|
|
276
|
+
};
|
|
277
|
+
/**
|
|
278
|
+
* Determines whether the given value is a valid Id.
|
|
279
|
+
*
|
|
280
|
+
* @param {BoundedContextId} value - The Id to validate.
|
|
281
|
+
* @returns {boolean} True if the Id is valid; otherwise, false.
|
|
282
|
+
*
|
|
283
|
+
* A Id is considered valid if:
|
|
284
|
+
* - The `ownerId` component of the value is a valid owner identifier, as verified
|
|
285
|
+
* by the `isValidOwnerId` function.
|
|
286
|
+
* - The `name` component of the value is in kebab-case format, as verified by
|
|
287
|
+
* the `isValidKebabCaseString` function.
|
|
288
|
+
*/
|
|
289
|
+
const isValidBoundedContextId = (value) => {
|
|
290
|
+
const ownerIdErrors = addContextToErrors$7(value, isValidOwnerId(value.ownerId));
|
|
291
|
+
const nameErrors = addContextToErrors$7(value, isValidKebabCaseString(value.name.value));
|
|
292
|
+
return [...ownerIdErrors, ...nameErrors];
|
|
293
|
+
};
|
|
294
|
+
const addContextToErrors$7 = (bcId, errors) => {
|
|
295
|
+
return errors.map((error) => `[Bounded Context Id: ${bcId.toString()}]${error}`);
|
|
296
|
+
};
|
|
297
|
+
const boundedContextIdToString = (id) => `${id.ownerType.toString()}/${id.ownerId.value}/${id.name.value}`;
|
|
298
|
+
/**
|
|
299
|
+
* Creates and returns a builder for constructing a `Id` object.
|
|
300
|
+
*
|
|
301
|
+
* The builder allows customization of the `Id` properties such as `ownerType`,
|
|
302
|
+
* while also enforcing constraints during the construction process, ensuring the resulting object is valid.
|
|
303
|
+
* The builder is stateful and provides a method to reset to default values if needed.
|
|
304
|
+
*
|
|
305
|
+
* @returns {BoundedContextIdBuilder} A builder object that provides methods for modifying and constructing a `Id`.
|
|
306
|
+
*
|
|
307
|
+
* @throws {SyntaxError} Throws an error if the resulting `Id` is invalid when the `build` method is invoked.
|
|
308
|
+
*/
|
|
309
|
+
const getBoundedContextIdBuilder = () => {
|
|
310
|
+
const internalState = { ...DEFAULT_BOUNDED_CONTEXT_ID };
|
|
311
|
+
const builder = {
|
|
312
|
+
withOwnerType: (ownerType) => {
|
|
313
|
+
internalState.ownerType = ownerType;
|
|
314
|
+
return builder;
|
|
315
|
+
},
|
|
316
|
+
withOwnerId: (ownerId) => {
|
|
317
|
+
internalState.ownerId = ownerId;
|
|
318
|
+
return builder;
|
|
319
|
+
},
|
|
320
|
+
withName: (name) => {
|
|
321
|
+
internalState.name = name;
|
|
322
|
+
return builder;
|
|
323
|
+
},
|
|
324
|
+
reset: () => {
|
|
325
|
+
internalState.ownerType = DEFAULT_BOUNDED_CONTEXT_ID.ownerType;
|
|
326
|
+
internalState.ownerId = DEFAULT_BOUNDED_CONTEXT_ID.ownerId;
|
|
327
|
+
internalState.name = DEFAULT_BOUNDED_CONTEXT_ID.name;
|
|
328
|
+
return builder;
|
|
329
|
+
},
|
|
330
|
+
build: () => {
|
|
331
|
+
const validationErrors = isValidBoundedContextId(internalState);
|
|
332
|
+
if (validationErrors.length > 0) throw new SyntaxError(validationErrors.join("\n"));
|
|
333
|
+
const builtId = {
|
|
334
|
+
...internalState,
|
|
335
|
+
equals: (other) => equals$3(builtId, other),
|
|
336
|
+
toString: () => boundedContextIdToString(builtId)
|
|
337
|
+
};
|
|
338
|
+
return builtId;
|
|
339
|
+
}
|
|
340
|
+
};
|
|
341
|
+
return builder;
|
|
342
|
+
};
|
|
343
|
+
|
|
344
|
+
//#endregion
|
|
345
|
+
//#region src/fractal/id.ts
|
|
346
|
+
const equals$2 = (a, b) => a.boundedContextId.equals(b.boundedContextId) && a.name.equals(b.name) && a.version.equals(b.version);
|
|
347
|
+
const toString$1 = (id) => `${id.boundedContextId.toString()}/${id.name.toString()}:${id.version.toString()}`;
|
|
348
|
+
/**
|
|
349
|
+
* Validates a given Fractal ID and returns a list of error messages if any validation fails.
|
|
350
|
+
* The validation process includes checking the bounded context ID, the name, and the version of the Fractal ID.
|
|
351
|
+
*
|
|
352
|
+
* @param {FractalId} id - The Fractal ID to validate.
|
|
353
|
+
* @returns {string[]} An array of error messages. Each error message indicates the specific issue with the bounded context ID, name, or version of the Fractal ID.
|
|
354
|
+
*/
|
|
355
|
+
const isValidFractalId = (id) => {
|
|
356
|
+
const boundedContextIdErrors = addContextToErrors$6(id, isValidBoundedContextId(id.boundedContextId));
|
|
357
|
+
const nameErrors = addContextToErrors$6(id, isValidKebabCaseString(id.name.value));
|
|
358
|
+
const versionErrors = addContextToErrors$6(id, isValidVersion(id.version));
|
|
359
|
+
return [
|
|
360
|
+
...boundedContextIdErrors,
|
|
361
|
+
...nameErrors,
|
|
362
|
+
...versionErrors
|
|
363
|
+
];
|
|
364
|
+
};
|
|
365
|
+
const addContextToErrors$6 = (value, errors) => {
|
|
366
|
+
return errors.map((error) => `[Fractal Id: ${toString$1(value)}]${error}`);
|
|
367
|
+
};
|
|
368
|
+
/**
|
|
369
|
+
* Represents the default identifier for a fractal instance.
|
|
370
|
+
*
|
|
371
|
+
* This constant holds a predefined FractalId object used as a default configuration
|
|
372
|
+
* in systems where fractal identification is required. The FractalId includes
|
|
373
|
+
* properties such as the bounded context ID, name, and version.
|
|
374
|
+
*
|
|
375
|
+
* The `boundedContextId` corresponds to the default bounded context identifier.
|
|
376
|
+
* The `name` is represented as a default kebab-case string format.
|
|
377
|
+
* The `version` reflects the defined default version of the fractal.
|
|
378
|
+
*
|
|
379
|
+
* DEFAULT_FRACTAL_ID can be used as a fallback or initial value in scenarios
|
|
380
|
+
* where no specific fractal identifier is provided.
|
|
381
|
+
*
|
|
382
|
+
* @constant {FractalId} DEFAULT_FRACTAL_ID
|
|
383
|
+
*/
|
|
384
|
+
const DEFAULT_FRACTAL_ID = {
|
|
385
|
+
boundedContextId: DEFAULT_BOUNDED_CONTEXT_ID,
|
|
386
|
+
name: DEFAULT_KEBAB_CASE_STRING,
|
|
387
|
+
version: DEFAULT_VERSION,
|
|
388
|
+
equals: () => false,
|
|
389
|
+
toString: () => ""
|
|
390
|
+
};
|
|
391
|
+
/**
|
|
392
|
+
* Provides a builder for constructing a `FractalId` object.
|
|
393
|
+
* This builder allows incremental creation of the ID through a fluent API
|
|
394
|
+
* with methods for specifying bounded context ID, name, and version, as well as
|
|
395
|
+
* resetting and building the final object.
|
|
396
|
+
*
|
|
397
|
+
* @returns {FractalIdBuilder} A builder object with methods for constructing a `FractalId`.
|
|
398
|
+
*
|
|
399
|
+
* Methods available on the builder:
|
|
400
|
+
* - `withBoundedContextId(value: BoundedContext.Id)`: Sets the bounded context ID for the `FractalId`.
|
|
401
|
+
* - `withName(value: KebabCaseString)`: Sets the name for the `FractalId`.
|
|
402
|
+
* - `withVersion(value: Version)`: Sets the version for the `FractalId`.
|
|
403
|
+
* - `reset()`: Resets the builder's internal state to default values.
|
|
404
|
+
* - `build()`: Validates and constructs the final `FractalId` object. Throws a `SyntaxError` if validation fails.
|
|
405
|
+
*/
|
|
406
|
+
const getFractalIdBuilder = () => {
|
|
407
|
+
const internalState = { ...DEFAULT_FRACTAL_ID };
|
|
408
|
+
const builder = {
|
|
409
|
+
withBoundedContextId: (value) => {
|
|
410
|
+
internalState.boundedContextId = value;
|
|
411
|
+
return builder;
|
|
412
|
+
},
|
|
413
|
+
withName: (value) => {
|
|
414
|
+
internalState.name = value;
|
|
415
|
+
return builder;
|
|
416
|
+
},
|
|
417
|
+
withVersion: (value) => {
|
|
418
|
+
internalState.version = value;
|
|
419
|
+
return builder;
|
|
420
|
+
},
|
|
421
|
+
reset: () => {
|
|
422
|
+
internalState.boundedContextId = DEFAULT_FRACTAL_ID.boundedContextId;
|
|
423
|
+
internalState.name = DEFAULT_FRACTAL_ID.name;
|
|
424
|
+
internalState.version = DEFAULT_FRACTAL_ID.version;
|
|
425
|
+
return builder;
|
|
426
|
+
},
|
|
427
|
+
build: () => {
|
|
428
|
+
const validationErrors = isValidFractalId(internalState);
|
|
429
|
+
if (validationErrors.length > 0) throw new SyntaxError(validationErrors.join("\n"));
|
|
430
|
+
const builtId = {
|
|
431
|
+
...internalState,
|
|
432
|
+
equals: (other) => equals$2(builtId, other),
|
|
433
|
+
toString: () => toString$1(builtId)
|
|
434
|
+
};
|
|
435
|
+
return builtId;
|
|
436
|
+
}
|
|
437
|
+
};
|
|
438
|
+
return builder;
|
|
439
|
+
};
|
|
440
|
+
|
|
441
|
+
//#endregion
|
|
442
|
+
//#region src/values/service_delivery_model.ts
|
|
443
|
+
/**
|
|
444
|
+
* Enum representing the different types of service delivery models in cloud computing.
|
|
445
|
+
*
|
|
446
|
+
* @enum {string}
|
|
447
|
+
* @readonly
|
|
448
|
+
* @property {string} IaaS Infrastructure as a Service - A model that provides virtualized computing infrastructure over the internet.
|
|
449
|
+
* @property {string} CaaS Container as a Service - A model focused on deploying and managing containers as a service.
|
|
450
|
+
* @property {string} PaaS Platform as a Service - A cloud model that provides a platform allowing users to develop, run, and manage applications without dealing with the underlying infrastructure.
|
|
451
|
+
* @property {string} FaaS Function as a Service - A serverless model where cloud functions are executed in response to events.
|
|
452
|
+
* @property {string} SaaS Software as a Service - A model in which software applications are delivered over the internet on a subscription basis.
|
|
453
|
+
*/
|
|
454
|
+
let ServiceDeliveryModel$1 = /* @__PURE__ */ function(ServiceDeliveryModel) {
|
|
455
|
+
ServiceDeliveryModel["IaaS"] = "IaaS";
|
|
456
|
+
ServiceDeliveryModel["CaaS"] = "CaaS";
|
|
457
|
+
ServiceDeliveryModel["PaaS"] = "PaaS";
|
|
458
|
+
ServiceDeliveryModel["FaaS"] = "FaaS";
|
|
459
|
+
ServiceDeliveryModel["SaaS"] = "SaaS";
|
|
460
|
+
return ServiceDeliveryModel;
|
|
461
|
+
}({});
|
|
462
|
+
|
|
463
|
+
//#endregion
|
|
464
|
+
//#region src/values/pascal_case_string.ts
|
|
465
|
+
/**
|
|
466
|
+
* Validates whether a given string is in PascalCase format.
|
|
467
|
+
* A PascalCase string must start with an uppercase letter and contain
|
|
468
|
+
* only alphabetic characters.
|
|
469
|
+
*
|
|
470
|
+
* @param {string} value - The string to validate.
|
|
471
|
+
* @returns {string[]} An array containing an error message if the string
|
|
472
|
+
* does not conform to PascalCase, or an empty array
|
|
473
|
+
* if the string is valid.
|
|
474
|
+
*/
|
|
475
|
+
const isValidPascalCaseString = (value) => {
|
|
476
|
+
if (!/^[A-Z][a-zA-Z]*$/.test(value)) return [` Value '${value}' must be in PascalCase`];
|
|
477
|
+
return [];
|
|
478
|
+
};
|
|
479
|
+
/**
|
|
480
|
+
* A constant object representing a default PascalCase formatted string.
|
|
481
|
+
*
|
|
482
|
+
* This variable is declared as a constant to prevent modification
|
|
483
|
+
* and is designed to not pass validation checks.
|
|
484
|
+
*/
|
|
485
|
+
const DEFAULT_PASCAL_CASE_STRING = {
|
|
486
|
+
_type: "pascal",
|
|
487
|
+
value: "",
|
|
488
|
+
equals: () => false,
|
|
489
|
+
toString: () => ""
|
|
490
|
+
};
|
|
491
|
+
/**
|
|
492
|
+
* Creates a builder for constructing a PascalCaseString object. The builder enforces Pascal case formatting and ensures
|
|
493
|
+
* a valid string is set before building. Once built, the PascalCaseString object becomes immutable.
|
|
494
|
+
*
|
|
495
|
+
* @function getPascalCaseStringBuilder
|
|
496
|
+
* @returns {Object} A builder object with the following methods:
|
|
497
|
+
* - `withValue(value: string): Object` – Sets the value of the PascalCaseString. Throws a `RangeError` if the input is not in Pascal case format (e.g., "ExampleString").
|
|
498
|
+
* - `reset(): void` – Resets the builder to its default state, clearing the current value.
|
|
499
|
+
* - `build(): PascalCaseString` – Constructs and returns a PascalCaseString object based on the current state. Throws a `SyntaxError` if no value has been set before building.
|
|
500
|
+
*/
|
|
501
|
+
const getPascalCaseStringBuilder = () => {
|
|
502
|
+
const internalState = { ...DEFAULT_PASCAL_CASE_STRING };
|
|
503
|
+
const builder = {
|
|
504
|
+
withValue: (value) => {
|
|
505
|
+
internalState.value = value;
|
|
506
|
+
return builder;
|
|
507
|
+
},
|
|
508
|
+
reset: () => {
|
|
509
|
+
internalState.value = DEFAULT_PASCAL_CASE_STRING.value;
|
|
510
|
+
return builder;
|
|
511
|
+
},
|
|
512
|
+
build: () => {
|
|
513
|
+
const validationErrors = isValidPascalCaseString(internalState.value);
|
|
514
|
+
if (validationErrors.length > 0) throw new SyntaxError(validationErrors.join("\n"));
|
|
515
|
+
return {
|
|
516
|
+
...internalState,
|
|
517
|
+
equals: (other) => internalState.value === other.value,
|
|
518
|
+
toString: () => internalState.value
|
|
519
|
+
};
|
|
520
|
+
}
|
|
521
|
+
};
|
|
522
|
+
return builder;
|
|
523
|
+
};
|
|
524
|
+
let PascalCaseString$1;
|
|
525
|
+
(function(_PascalCaseString) {
|
|
526
|
+
_PascalCaseString.getBuilder = getPascalCaseStringBuilder;
|
|
527
|
+
})(PascalCaseString$1 || (PascalCaseString$1 = {}));
|
|
528
|
+
|
|
529
|
+
//#endregion
|
|
530
|
+
//#region src/values/infrastructure_domain.ts
|
|
531
|
+
/**
|
|
532
|
+
* Enumeration representing various infrastructure domains.
|
|
533
|
+
* These domains categorize components or services
|
|
534
|
+
* within an infrastructure system.
|
|
535
|
+
*
|
|
536
|
+
* @enum {string}
|
|
537
|
+
* @property {string} ApiManagement - Represents API management-related components.
|
|
538
|
+
* @property {string} NetworkAndCompute - Represents network and compute components.
|
|
539
|
+
* @property {string} CustomWorkloads - Represents custom workload components.
|
|
540
|
+
* @property {string} Messaging - Represents messaging and communication components.
|
|
541
|
+
* @property {string} Storage - Represents data storage components.
|
|
542
|
+
* @property {string} Observability - Represents observability tools and monitoring components.
|
|
543
|
+
* @property {string} Security - Represents security-focused components.
|
|
544
|
+
*/
|
|
545
|
+
let InfrastructureDomain$1 = /* @__PURE__ */ function(InfrastructureDomain) {
|
|
546
|
+
InfrastructureDomain["ApiManagement"] = "APIManagement";
|
|
547
|
+
InfrastructureDomain["NetworkAndCompute"] = "NetworkAndCompute";
|
|
548
|
+
InfrastructureDomain["CustomWorkloads"] = "CustomWorkloads";
|
|
549
|
+
InfrastructureDomain["Messaging"] = "Messaging";
|
|
550
|
+
InfrastructureDomain["Storage"] = "Storage";
|
|
551
|
+
InfrastructureDomain["Observability"] = "Observability";
|
|
552
|
+
InfrastructureDomain["Security"] = "Security";
|
|
553
|
+
return InfrastructureDomain;
|
|
554
|
+
}({});
|
|
555
|
+
|
|
556
|
+
//#endregion
|
|
557
|
+
//#region src/component/type.ts
|
|
558
|
+
/**
|
|
559
|
+
* Represents the default type configuration for a component.
|
|
560
|
+
*
|
|
561
|
+
* This variable is declared as a constant to prevent modification
|
|
562
|
+
* and is designed to not pass validation checks.
|
|
563
|
+
*/
|
|
564
|
+
const DEFAULT_COMPONENT_TYPE = {
|
|
565
|
+
domain: InfrastructureDomain$1.ApiManagement,
|
|
566
|
+
name: DEFAULT_PASCAL_CASE_STRING
|
|
567
|
+
};
|
|
568
|
+
/**
|
|
569
|
+
* Validates the provided component type and checks for errors in the type's name.
|
|
570
|
+
*
|
|
571
|
+
* The validation ensures that the name of the component type follows the PascalCase string format.
|
|
572
|
+
* If any violations are detected, it returns an array of error messages. Each error message is
|
|
573
|
+
* formatted to include the component type's name and a descriptive error message.
|
|
574
|
+
*
|
|
575
|
+
* @param {ComponentType} type - The component type object to be validated.
|
|
576
|
+
* @returns {string[]} An array of error messages if validation fails; an empty array if the name is valid.
|
|
577
|
+
*/
|
|
578
|
+
const isValidComponentType = (type) => {
|
|
579
|
+
const nameError = isValidPascalCaseString(type.name.value);
|
|
580
|
+
if (nameError.length > 0) return nameError.map((x) => `[Component Type: ${type.name.value}][Name]${x}`);
|
|
581
|
+
return [];
|
|
582
|
+
};
|
|
583
|
+
/**
|
|
584
|
+
* Creates and returns a builder for constructing a `TypeBuilder` instance.
|
|
585
|
+
*
|
|
586
|
+
* This builder provides methods to configure and customize the properties
|
|
587
|
+
* of a `ComponentType` object before it is finalized and built.
|
|
588
|
+
*
|
|
589
|
+
* @returns {ComponentTypeBuilder} A builder instance for constructing a `ComponentType`.
|
|
590
|
+
*
|
|
591
|
+
* @property {Function} withInfrastructureDomain - Sets the `domain` property
|
|
592
|
+
* of the internal state with the provided `InfrastructureDomain` value.
|
|
593
|
+
*
|
|
594
|
+
* @property {Function} withName - Sets the `name` property of the internal
|
|
595
|
+
* state with the provided `PascalCaseString` value.
|
|
596
|
+
*
|
|
597
|
+
* @property {Function} reset - Resets the internal state of the builder to
|
|
598
|
+
* the default `ComponentType` values.
|
|
599
|
+
*
|
|
600
|
+
* @property {Function} build - Validates the internal state of the builder
|
|
601
|
+
* and returns a finalized `ComponentType` object. Throws a `SyntaxError` if
|
|
602
|
+
* validation fails.
|
|
603
|
+
*/
|
|
604
|
+
const getComponentTypeBuilder = () => {
|
|
605
|
+
const internalState = { ...DEFAULT_COMPONENT_TYPE };
|
|
606
|
+
const builder = {
|
|
607
|
+
withInfrastructureDomain: (domain) => {
|
|
608
|
+
internalState.domain = domain;
|
|
609
|
+
return builder;
|
|
610
|
+
},
|
|
611
|
+
withName: (name) => {
|
|
612
|
+
internalState.name = name;
|
|
613
|
+
return builder;
|
|
614
|
+
},
|
|
615
|
+
reset: () => {
|
|
616
|
+
internalState.domain = DEFAULT_COMPONENT_TYPE.domain;
|
|
617
|
+
internalState.name = DEFAULT_COMPONENT_TYPE.name;
|
|
618
|
+
return builder;
|
|
619
|
+
},
|
|
620
|
+
build: () => {
|
|
621
|
+
const validationErrors = isValidComponentType(internalState);
|
|
622
|
+
if (validationErrors.length > 0) throw new SyntaxError(validationErrors.join("\n"));
|
|
623
|
+
return { ...internalState };
|
|
624
|
+
}
|
|
625
|
+
};
|
|
626
|
+
return builder;
|
|
627
|
+
};
|
|
628
|
+
|
|
629
|
+
//#endregion
|
|
630
|
+
//#region src/fractal/component/type.ts
|
|
631
|
+
/**
|
|
632
|
+
*/
|
|
633
|
+
const DEFAULT_BLUEPRINT_COMPONENT_TYPE = {
|
|
634
|
+
...DEFAULT_COMPONENT_TYPE,
|
|
635
|
+
serviceDeliveryModel: ServiceDeliveryModel$1.SaaS
|
|
636
|
+
};
|
|
637
|
+
/**
|
|
638
|
+
* Validates the provided component type and checks for errors in the type's name.
|
|
639
|
+
*
|
|
640
|
+
* The validation ensures that the name of the component type follows the PascalCase string format.
|
|
641
|
+
* If any violations are detected, it returns an array of error messages. Each error message is
|
|
642
|
+
* formatted to include the component type's name and a descriptive error message.
|
|
643
|
+
*
|
|
644
|
+
* @param {BlueprintComponentType} type - The component type object to be validated.
|
|
645
|
+
* @returns {string[]} An array of error messages if validation fails; an empty array if the name is valid.
|
|
646
|
+
*/
|
|
647
|
+
const isValidBlueprintComponentType = (type) => isValidComponentType(type);
|
|
648
|
+
/**
|
|
649
|
+
* Creates and returns a builder for constructing a `TypeBuilder` instance.
|
|
650
|
+
*
|
|
651
|
+
* This builder provides methods to configure and customize the properties
|
|
652
|
+
* of a `ComponentType` object before it is finalized and built.
|
|
653
|
+
*
|
|
654
|
+
* @returns {BlueprintComponentTypeBuilder} A builder instance for constructing a `ComponentType`.
|
|
655
|
+
*
|
|
656
|
+
* @property {Function} withInfrastructureDomain - Sets the `domain` property
|
|
657
|
+
* of the internal state with the provided `InfrastructureDomain` value.
|
|
658
|
+
*
|
|
659
|
+
* @property {Function} withName - Sets the `name` property of the internal
|
|
660
|
+
* state with the provided `PascalCaseString` value.
|
|
661
|
+
*
|
|
662
|
+
* @property {Function} reset - Resets the internal state of the builder to
|
|
663
|
+
* the default `ComponentType` values.
|
|
664
|
+
*
|
|
665
|
+
* @property {Function} build - Validates the internal state of the builder
|
|
666
|
+
* and returns a finalized `ComponentType` object. Throws a `SyntaxError` if
|
|
667
|
+
* validation fails.
|
|
668
|
+
*/
|
|
669
|
+
const getBlueprintComponentTypeBuilder = () => {
|
|
670
|
+
const internalState = { ...DEFAULT_BLUEPRINT_COMPONENT_TYPE };
|
|
671
|
+
const builder = {
|
|
672
|
+
withInfrastructureDomain: (domain) => {
|
|
673
|
+
internalState.domain = domain;
|
|
674
|
+
return builder;
|
|
675
|
+
},
|
|
676
|
+
withServiceDeliveryModel: (serviceDeliveryModel) => {
|
|
677
|
+
internalState.serviceDeliveryModel = serviceDeliveryModel;
|
|
678
|
+
return builder;
|
|
679
|
+
},
|
|
680
|
+
withName: (name) => {
|
|
681
|
+
internalState.name = name;
|
|
682
|
+
return builder;
|
|
683
|
+
},
|
|
684
|
+
reset: () => {
|
|
685
|
+
internalState.domain = DEFAULT_BLUEPRINT_COMPONENT_TYPE.domain;
|
|
686
|
+
internalState.serviceDeliveryModel = DEFAULT_BLUEPRINT_COMPONENT_TYPE.serviceDeliveryModel;
|
|
687
|
+
internalState.name = DEFAULT_BLUEPRINT_COMPONENT_TYPE.name;
|
|
688
|
+
return builder;
|
|
689
|
+
},
|
|
690
|
+
build: () => {
|
|
691
|
+
const validationErrors = isValidBlueprintComponentType(internalState);
|
|
692
|
+
if (validationErrors.length > 0) throw new SyntaxError(validationErrors.join("\n"));
|
|
693
|
+
return {
|
|
694
|
+
...internalState,
|
|
695
|
+
toString: () => `${internalState.domain}.${internalState.serviceDeliveryModel}.${internalState.name}`
|
|
696
|
+
};
|
|
697
|
+
}
|
|
698
|
+
};
|
|
699
|
+
return builder;
|
|
700
|
+
};
|
|
701
|
+
|
|
702
|
+
//#endregion
|
|
703
|
+
//#region src/values/generic_parameters.ts
|
|
704
|
+
/**
|
|
705
|
+
* Provides a mechanism to manage and retrieve named fields from an internal container.
|
|
706
|
+
*
|
|
707
|
+
* This function returns an object with methods to access required and optional fields by name.
|
|
708
|
+
* It utilizes an internal container to store field data, enabling controlled retrieval of fields.
|
|
709
|
+
*
|
|
710
|
+
* @returns {GenericParameters} An object containing methods for field retrieval:
|
|
711
|
+
* - `getRequiredFieldByName`: Retrieves a specified field by name. Throws an error if the field is not defined.
|
|
712
|
+
* - `getOptionalFieldByName`: Retrieves a specified field by name. Returns null if the field is not defined.
|
|
713
|
+
*/
|
|
714
|
+
const getParametersInstance = () => {
|
|
715
|
+
const container = {};
|
|
716
|
+
return {
|
|
717
|
+
getRequiredFieldByName: (name) => {
|
|
718
|
+
if (typeof container[name] === "undefined" || container[name] === null) throw new Error(`Required field ${name} is not defined`);
|
|
719
|
+
return container[name];
|
|
720
|
+
},
|
|
721
|
+
getOptionalFieldByName: (name) => container[name] ?? null,
|
|
722
|
+
getAllFieldNames: () => Object.keys(container),
|
|
723
|
+
push: (key, value) => container[key] = value,
|
|
724
|
+
remove: (key) => delete container[key],
|
|
725
|
+
toMap: () => ({ ...container })
|
|
726
|
+
};
|
|
727
|
+
};
|
|
728
|
+
|
|
729
|
+
//#endregion
|
|
730
|
+
//#region src/component/id.ts
|
|
731
|
+
/**
|
|
732
|
+
* Validates whether the given identifier is in a valid kebab-case format.
|
|
733
|
+
*
|
|
734
|
+
* @param {ComponentId} id - The identifier object to validate, containing the value to check.
|
|
735
|
+
* @returns {boolean} - Returns true if the identifier is in a valid kebab-case format, false otherwise.
|
|
736
|
+
*/
|
|
737
|
+
const isValidId = (id) => {
|
|
738
|
+
return isValidKebabCaseString(id.value.toString()).map((x) => `[Component Id: ${id.value.toString()}]${x}`);
|
|
739
|
+
};
|
|
740
|
+
const equals$1 = (a, b) => a.value === b.value;
|
|
741
|
+
/**
|
|
742
|
+
* Represents the default identifier used in the application.
|
|
743
|
+
* It is initialized with a value that will not pass validation.
|
|
744
|
+
*/
|
|
745
|
+
const DEFAULT_COMPONENT_ID = {
|
|
746
|
+
value: DEFAULT_KEBAB_CASE_STRING,
|
|
747
|
+
equals: (other) => equals$1(DEFAULT_COMPONENT_ID, other),
|
|
748
|
+
toString: () => ""
|
|
749
|
+
};
|
|
750
|
+
/**
|
|
751
|
+
* Creates and returns a builder for constructing a `ComponentId` object.
|
|
752
|
+
*
|
|
753
|
+
* The builder provides methods to set properties of the `ComponentId`, reset them to default
|
|
754
|
+
* values, and validate and build the final object. The `build` method performs validation before
|
|
755
|
+
* creating the `ComponentId`, and throws an error if any validation rules are violated.
|
|
756
|
+
*
|
|
757
|
+
* @returns {ComponentIdBuilder} A builder with methods to configure and build a `ComponentId`.
|
|
758
|
+
*/
|
|
759
|
+
const getComponentIdBuilder = () => {
|
|
760
|
+
const internalState = { ...DEFAULT_COMPONENT_ID };
|
|
761
|
+
const builder = {
|
|
762
|
+
withValue: (value) => {
|
|
763
|
+
internalState.value = value;
|
|
764
|
+
return builder;
|
|
765
|
+
},
|
|
766
|
+
reset: () => {
|
|
767
|
+
internalState.value = DEFAULT_COMPONENT_ID.value;
|
|
768
|
+
internalState.equals = DEFAULT_COMPONENT_ID.equals;
|
|
769
|
+
return builder;
|
|
770
|
+
},
|
|
771
|
+
build: () => {
|
|
772
|
+
const validationErrors = isValidId(internalState);
|
|
773
|
+
if (validationErrors.length > 0) throw new SyntaxError(validationErrors.join("\n"));
|
|
774
|
+
const builtId = {
|
|
775
|
+
...internalState,
|
|
776
|
+
equals: (other) => equals$1(builtId, other),
|
|
777
|
+
toString: () => builtId.value.toString()
|
|
778
|
+
};
|
|
779
|
+
return builtId;
|
|
780
|
+
}
|
|
781
|
+
};
|
|
782
|
+
return builder;
|
|
783
|
+
};
|
|
784
|
+
|
|
785
|
+
//#endregion
|
|
786
|
+
//#region src/component/link.ts
|
|
787
|
+
/**
|
|
788
|
+
* A function to determine if a given ComponentLink is valid.
|
|
789
|
+
*
|
|
790
|
+
* This function checks the validity of a ComponentLink object by verifying
|
|
791
|
+
* the validity of its `id` and `type` properties.
|
|
792
|
+
*
|
|
793
|
+
* @param {ComponentLink} link - The ComponentLink object to validate.
|
|
794
|
+
* @returns {boolean} - Returns true if the link's `id` is valid and its `type` is valid; otherwise, returns false.
|
|
795
|
+
*/
|
|
796
|
+
const isValidLink = (link) => {
|
|
797
|
+
const idErrors = isValidId(link.id);
|
|
798
|
+
const typeErrors = isValidComponentType(link.type);
|
|
799
|
+
return [...idErrors.map((x) => `[Link: ${link.id.value}] Id error: ${x}`), ...typeErrors.map((x) => `[Link: ${link.id.value}] Type error: ${x}`)];
|
|
800
|
+
};
|
|
801
|
+
const DEFAULT_LINK = {
|
|
802
|
+
id: DEFAULT_COMPONENT_ID,
|
|
803
|
+
type: DEFAULT_COMPONENT_TYPE,
|
|
804
|
+
parameters: getParametersInstance()
|
|
805
|
+
};
|
|
806
|
+
/**
|
|
807
|
+
* Creates and returns a builder for constructing `ComponentLink` objects.
|
|
808
|
+
*
|
|
809
|
+
* The `getLinkBuilder` function provides a fluent interface for configuring a `ComponentLink` instance.
|
|
810
|
+
* It allows setting properties such as `id`, `type`, and `parameters`. The builder maintains an internal
|
|
811
|
+
* state to incrementally configure the `ComponentLink` object.
|
|
812
|
+
*
|
|
813
|
+
* Functions exposed by the builder:
|
|
814
|
+
*
|
|
815
|
+
* - `withId(id: ComponentId): LinkBuilder`: Assigns the provided `id` to the `ComponentLink`.
|
|
816
|
+
* - `withType(type: ComponentType): LinkBuilder`: Assigns the provided `type` to the `ComponentLink`.
|
|
817
|
+
* - `withParameters(parameters: LinkParameters): LinkBuilder`: Assigns the provided `parameters` to the `ComponentLink`.
|
|
818
|
+
* - `reset(): LinkBuilder`: Resets the builder state to its default values.
|
|
819
|
+
* - `build(): ComponentLink`: Validates the internal state and constructs an immutable `ComponentLink` instance.
|
|
820
|
+
*
|
|
821
|
+
* Throws:
|
|
822
|
+
* - `SyntaxError` if the internal state is invalid when invoking `build()`.
|
|
823
|
+
*
|
|
824
|
+
* @returns {LinkBuilder} The builder object to configure and construct `ComponentLink` instances.
|
|
825
|
+
*/
|
|
826
|
+
const getLinkBuilder = () => {
|
|
827
|
+
const internalState = { ...DEFAULT_LINK };
|
|
828
|
+
const builder = {
|
|
829
|
+
withId: (id) => {
|
|
830
|
+
internalState.id = id;
|
|
831
|
+
return builder;
|
|
832
|
+
},
|
|
833
|
+
withType: (type) => {
|
|
834
|
+
internalState.type = type;
|
|
835
|
+
return builder;
|
|
836
|
+
},
|
|
837
|
+
withParameters: (parameters) => {
|
|
838
|
+
internalState.parameters = parameters;
|
|
839
|
+
return builder;
|
|
840
|
+
},
|
|
841
|
+
reset: () => {
|
|
842
|
+
internalState.id = DEFAULT_LINK.id;
|
|
843
|
+
internalState.type = DEFAULT_LINK.type;
|
|
844
|
+
internalState.parameters = DEFAULT_LINK.parameters;
|
|
845
|
+
return builder;
|
|
846
|
+
},
|
|
847
|
+
build: () => {
|
|
848
|
+
const validationErrors = isValidLink(internalState);
|
|
849
|
+
if (validationErrors.length > 0) throw new SyntaxError(validationErrors.join("\n"));
|
|
850
|
+
return { ...internalState };
|
|
851
|
+
}
|
|
852
|
+
};
|
|
853
|
+
return builder;
|
|
854
|
+
};
|
|
855
|
+
|
|
856
|
+
//#endregion
|
|
857
|
+
//#region src/values/helpers.ts
|
|
858
|
+
const isNonEmptyString = (value) => typeof value === "string" && value.trim() !== "";
|
|
859
|
+
|
|
860
|
+
//#endregion
|
|
861
|
+
//#region src/component/entity.ts
|
|
862
|
+
/**
|
|
863
|
+
* Represents the default configuration for a component within the system.
|
|
864
|
+
* This constant can be used as a template or fallback value when no specific component configuration is available.
|
|
865
|
+
*
|
|
866
|
+
* Properties of this constant include:
|
|
867
|
+
* - `type`: The default component type identifier.
|
|
868
|
+
* - `id`: The unique identifier for the default component.
|
|
869
|
+
* - `version`: The version of the default component.
|
|
870
|
+
* - `displayName`: An empty string representing a placeholder for the display name.
|
|
871
|
+
* - `description`: An empty string serving as a placeholder for the component description.
|
|
872
|
+
* - `parameters`: Default parameters for the component, retrieved from a predefined instance.
|
|
873
|
+
* - `outputFields`: The default output fields structure with a nested empty object under `value`.
|
|
874
|
+
* - `links`: An empty array indicating no predefined links for the default configuration.
|
|
875
|
+
* - `dependencies`: An empty array representing no external dependencies.
|
|
876
|
+
*/
|
|
877
|
+
const DEFAULT_COMPONENT = {
|
|
878
|
+
type: DEFAULT_COMPONENT_TYPE,
|
|
879
|
+
id: DEFAULT_COMPONENT_ID,
|
|
880
|
+
version: DEFAULT_VERSION,
|
|
881
|
+
displayName: "",
|
|
882
|
+
description: "",
|
|
883
|
+
parameters: getParametersInstance(),
|
|
884
|
+
outputFields: { value: {} },
|
|
885
|
+
links: [],
|
|
886
|
+
dependencies: []
|
|
887
|
+
};
|
|
888
|
+
/**
|
|
889
|
+
* Validates a given component object and returns a list of error messages if any validations fail.
|
|
890
|
+
*
|
|
891
|
+
* The function checks the following properties of the `component`:
|
|
892
|
+
* - `id`: Assessed using the `isValidId` function.
|
|
893
|
+
* - `type`: Assessed using the `isValidComponentType` function.
|
|
894
|
+
* - `version`: Assessed using the `isValidVersion` function.
|
|
895
|
+
* - `displayName`: Validated to ensure it is a non-empty string.
|
|
896
|
+
*
|
|
897
|
+
* Validation errors are returned as strings formatted with the component's ID for easy identification.
|
|
898
|
+
*
|
|
899
|
+
* @param {Component} component - The component object to validate. Must include the fields `id`, `type`, `version`, and `displayName`.
|
|
900
|
+
* @returns {string[]} An array of error messages, each describing a specific validation failure. If no errors are found, the array will be empty.
|
|
901
|
+
*/
|
|
902
|
+
const isValidComponent = (component) => {
|
|
903
|
+
const idErrors = addContextToErrors$5(component.id, isValidId(component.id));
|
|
904
|
+
const typeErrors = addContextToErrors$5(component.id, isValidComponentType(component.type));
|
|
905
|
+
const versionErrors = addContextToErrors$5(component.id, isValidVersion(component.version));
|
|
906
|
+
const displayNameErrors = addContextToErrors$5(component.id, isNonEmptyString(component.displayName) ? [] : ["Display name must be a non-empty string"]);
|
|
907
|
+
return [
|
|
908
|
+
...idErrors,
|
|
909
|
+
...typeErrors,
|
|
910
|
+
...versionErrors,
|
|
911
|
+
...typeErrors,
|
|
912
|
+
...displayNameErrors
|
|
913
|
+
];
|
|
914
|
+
};
|
|
915
|
+
const addContextToErrors$5 = (componentId, errors) => {
|
|
916
|
+
return errors.map((error) => `[Component: ${componentId.toString()}]${error}`);
|
|
917
|
+
};
|
|
918
|
+
/**
|
|
919
|
+
* Creates and returns a builder for constructing `Component` objects.
|
|
920
|
+
*
|
|
921
|
+
* The `getComponentBuilder` function provides a fluent interface for configuring a `Component` instance.
|
|
922
|
+
* It allows setting properties such as `type`, `id`, `version`, `displayName`, `description`, `parameters`,
|
|
923
|
+
* `links`, and `dependencies`. The builder maintains an internal state to incrementally configure the `Component` object.
|
|
924
|
+
*
|
|
925
|
+
* Functions exposed by the builder:
|
|
926
|
+
*
|
|
927
|
+
* - `withType(type: ComponentType): ComponentBuilder`: Assigns the provided `type` to the `Component`.
|
|
928
|
+
* - `withId(id: ComponentId): ComponentBuilder`: Assigns the provided `id` to the `Component`.
|
|
929
|
+
* - `withVersion(version: Version): ComponentBuilder`: Assigns the provided `version` to the `Component`.
|
|
930
|
+
* - `withDisplayName(displayName: string): ComponentBuilder`: Assigns the provided `displayName` to the `Component`.
|
|
931
|
+
* - `withDescription(description: string): ComponentBuilder`: Assigns the provided `description` to the `Component`.
|
|
932
|
+
* - `withParameters(parameters: ComponentParameters): ComponentBuilder`: Assigns the provided `parameters` to the `Component`.
|
|
933
|
+
* - `withLinks(links: ComponentLink[]): ComponentBuilder`: Assigns the provided `links` to the `Component`.
|
|
934
|
+
* - `withDependencies(dependencies: Dependency[]): ComponentBuilder`: Assigns the provided `dependencies` to the `Component`.
|
|
935
|
+
* - `reset(): ComponentBuilder`: Resets the builder state to its default values.
|
|
936
|
+
* - `build(): Component`: Validates the internal state and constructs an immutable `Component` instance.
|
|
937
|
+
*
|
|
938
|
+
* Throws:
|
|
939
|
+
* - `SyntaxError` if the internal state is invalid when invoking `build()`.
|
|
940
|
+
*
|
|
941
|
+
* @returns {ComponentBuilder} The builder object to configure and construct `Component` instances.
|
|
942
|
+
*/
|
|
943
|
+
const getComponentBuilder = () => {
|
|
944
|
+
const internalState = { ...DEFAULT_COMPONENT };
|
|
945
|
+
const builder = {
|
|
946
|
+
withType: (type) => {
|
|
947
|
+
internalState.type = type;
|
|
948
|
+
return builder;
|
|
949
|
+
},
|
|
950
|
+
withId: (id) => {
|
|
951
|
+
internalState.id = id;
|
|
952
|
+
return builder;
|
|
953
|
+
},
|
|
954
|
+
withVersion: (version) => {
|
|
955
|
+
internalState.version = version;
|
|
956
|
+
return builder;
|
|
957
|
+
},
|
|
958
|
+
withDisplayName: (displayName) => {
|
|
959
|
+
internalState.displayName = displayName;
|
|
960
|
+
return builder;
|
|
961
|
+
},
|
|
962
|
+
withDescription: (description) => {
|
|
963
|
+
internalState.description = description;
|
|
964
|
+
return builder;
|
|
965
|
+
},
|
|
966
|
+
withParameters: (parameters) => {
|
|
967
|
+
internalState.parameters = parameters;
|
|
968
|
+
return builder;
|
|
969
|
+
},
|
|
970
|
+
withLinks: (links) => {
|
|
971
|
+
internalState.links = links;
|
|
972
|
+
return builder;
|
|
973
|
+
},
|
|
974
|
+
withDependencies: (dependencies) => {
|
|
975
|
+
internalState.dependencies = dependencies;
|
|
976
|
+
return builder;
|
|
977
|
+
},
|
|
978
|
+
reset: () => {
|
|
979
|
+
internalState.type = DEFAULT_COMPONENT.type;
|
|
980
|
+
internalState.id = DEFAULT_COMPONENT.id;
|
|
981
|
+
internalState.version = DEFAULT_COMPONENT.version;
|
|
982
|
+
internalState.displayName = DEFAULT_COMPONENT.displayName;
|
|
983
|
+
internalState.description = DEFAULT_COMPONENT.description;
|
|
984
|
+
internalState.parameters = DEFAULT_COMPONENT.parameters;
|
|
985
|
+
internalState.links = DEFAULT_COMPONENT.links;
|
|
986
|
+
internalState.dependencies = DEFAULT_COMPONENT.dependencies;
|
|
987
|
+
return builder;
|
|
988
|
+
},
|
|
989
|
+
build: () => {
|
|
990
|
+
const validationErrors = isValidComponent(internalState);
|
|
991
|
+
if (validationErrors.length > 0) throw new SyntaxError(validationErrors.join("\n"));
|
|
992
|
+
return { ...internalState };
|
|
993
|
+
}
|
|
994
|
+
};
|
|
995
|
+
return builder;
|
|
996
|
+
};
|
|
997
|
+
|
|
998
|
+
//#endregion
|
|
999
|
+
//#region src/component/index.ts
|
|
1000
|
+
let Component;
|
|
1001
|
+
(function(_Component) {
|
|
1002
|
+
let Type;
|
|
1003
|
+
(function(_Type) {
|
|
1004
|
+
_Type.getBuilder = getComponentTypeBuilder;
|
|
1005
|
+
})(Type || (Type = _Component.Type || (_Component.Type = {})));
|
|
1006
|
+
let Parameters;
|
|
1007
|
+
(function(_Parameters) {
|
|
1008
|
+
_Parameters.getInstance = getParametersInstance;
|
|
1009
|
+
})(Parameters || (Parameters = _Component.Parameters || (_Component.Parameters = {})));
|
|
1010
|
+
let Link;
|
|
1011
|
+
(function(_Link) {
|
|
1012
|
+
let Parameters;
|
|
1013
|
+
(function(_Parameters2) {
|
|
1014
|
+
_Parameters2.getInstance = getParametersInstance;
|
|
1015
|
+
})(Parameters || (Parameters = _Link.Parameters || (_Link.Parameters = {})));
|
|
1016
|
+
_Link.getBuilder = getLinkBuilder;
|
|
1017
|
+
})(Link || (Link = _Component.Link || (_Component.Link = {})));
|
|
1018
|
+
let Id;
|
|
1019
|
+
(function(_Id) {
|
|
1020
|
+
_Id.getBuilder = getComponentIdBuilder;
|
|
1021
|
+
})(Id || (Id = _Component.Id || (_Component.Id = {})));
|
|
1022
|
+
_Component.getBuilder = getComponentBuilder;
|
|
1023
|
+
})(Component || (Component = {}));
|
|
1024
|
+
|
|
1025
|
+
//#endregion
|
|
1026
|
+
//#region src/fractal/component/entity.ts
|
|
1027
|
+
const DEFAULT_BLUEPRINT_COMPONENT = {
|
|
1028
|
+
...DEFAULT_COMPONENT,
|
|
1029
|
+
type: DEFAULT_BLUEPRINT_COMPONENT_TYPE,
|
|
1030
|
+
dependencies: [],
|
|
1031
|
+
isLocked: false,
|
|
1032
|
+
recreateOnFailure: false
|
|
1033
|
+
};
|
|
1034
|
+
const isValidBlueprintComponent = (component) => {
|
|
1035
|
+
return isValidComponent({
|
|
1036
|
+
...component,
|
|
1037
|
+
dependencies: []
|
|
1038
|
+
});
|
|
1039
|
+
};
|
|
1040
|
+
/**
|
|
1041
|
+
* Creates and returns a builder for constructing `BlueprintComponent` instances.
|
|
1042
|
+
*
|
|
1043
|
+
* The builder provides a fluent API for setting various properties of a `BlueprintComponent`
|
|
1044
|
+
* and performs validation upon calling the `build` method to ensure the resulting object
|
|
1045
|
+
* is valid. If validation fails, an error is thrown.
|
|
1046
|
+
*
|
|
1047
|
+
* @returns {BlueprintComponentBuilder} An object with methods to configure and build a `BlueprintComponent`.
|
|
1048
|
+
*
|
|
1049
|
+
* Methods available on the builder:
|
|
1050
|
+
* - `withType(type: BlueprintComponentType)`: Sets the type of the component.
|
|
1051
|
+
* - `withId(id: ComponentId)`: Sets the unique identifier for the component.
|
|
1052
|
+
* - `withVersion(version: Version)`: Sets the version of the component.
|
|
1053
|
+
* - `withDisplayName(displayName: string)`: Sets the display name for the component.
|
|
1054
|
+
* - `withDescription(description: string)`: Sets a description for the component.
|
|
1055
|
+
* - `withParameters(parameters: Component.Parameters)`: Sets the parameters associated with the component.
|
|
1056
|
+
* - `withLinks(links: ComponentLink[])`: Sets the links associated with the component.
|
|
1057
|
+
* - `withDependencies(dependencies: BlueprintComponentDependency[])`: Sets the dependencies of the component.
|
|
1058
|
+
* - `reset()`: Resets all properties of the component to their default values based on `DEFAULT_BLUEPRINT_COMPONENT`.
|
|
1059
|
+
* - `build()`: Validates and constructs the `BlueprintComponent` object. Throws an error if validation fails.
|
|
1060
|
+
*/
|
|
1061
|
+
const getBlueprintComponentBuilder = () => {
|
|
1062
|
+
const internalState = { ...DEFAULT_BLUEPRINT_COMPONENT };
|
|
1063
|
+
const builder = {
|
|
1064
|
+
withType: (type) => {
|
|
1065
|
+
internalState.type = type;
|
|
1066
|
+
return builder;
|
|
1067
|
+
},
|
|
1068
|
+
withId: (id) => {
|
|
1069
|
+
internalState.id = id;
|
|
1070
|
+
return builder;
|
|
1071
|
+
},
|
|
1072
|
+
withVersion: (version) => {
|
|
1073
|
+
internalState.version = version;
|
|
1074
|
+
return builder;
|
|
1075
|
+
},
|
|
1076
|
+
withIsLocked: (value) => {
|
|
1077
|
+
internalState.isLocked = value;
|
|
1078
|
+
return builder;
|
|
1079
|
+
},
|
|
1080
|
+
withRecreateOnFailure: (value) => {
|
|
1081
|
+
internalState.recreateOnFailure = value;
|
|
1082
|
+
return builder;
|
|
1083
|
+
},
|
|
1084
|
+
withDisplayName: (displayName) => {
|
|
1085
|
+
internalState.displayName = displayName;
|
|
1086
|
+
return builder;
|
|
1087
|
+
},
|
|
1088
|
+
withDescription: (description) => {
|
|
1089
|
+
internalState.description = description;
|
|
1090
|
+
return builder;
|
|
1091
|
+
},
|
|
1092
|
+
withParameters: (parameters) => {
|
|
1093
|
+
internalState.parameters = parameters;
|
|
1094
|
+
return builder;
|
|
1095
|
+
},
|
|
1096
|
+
withLinks: (links) => {
|
|
1097
|
+
internalState.links = links;
|
|
1098
|
+
return builder;
|
|
1099
|
+
},
|
|
1100
|
+
withDependencies: (dependencies) => {
|
|
1101
|
+
internalState.dependencies = dependencies;
|
|
1102
|
+
return builder;
|
|
1103
|
+
},
|
|
1104
|
+
reset: () => {
|
|
1105
|
+
internalState.type = DEFAULT_BLUEPRINT_COMPONENT.type;
|
|
1106
|
+
internalState.id = DEFAULT_BLUEPRINT_COMPONENT.id;
|
|
1107
|
+
internalState.version = DEFAULT_BLUEPRINT_COMPONENT.version;
|
|
1108
|
+
internalState.displayName = DEFAULT_BLUEPRINT_COMPONENT.displayName;
|
|
1109
|
+
internalState.description = DEFAULT_BLUEPRINT_COMPONENT.description;
|
|
1110
|
+
internalState.parameters = DEFAULT_BLUEPRINT_COMPONENT.parameters;
|
|
1111
|
+
internalState.links = DEFAULT_BLUEPRINT_COMPONENT.links;
|
|
1112
|
+
internalState.dependencies = DEFAULT_BLUEPRINT_COMPONENT.dependencies;
|
|
1113
|
+
internalState.isLocked = DEFAULT_BLUEPRINT_COMPONENT.isLocked;
|
|
1114
|
+
internalState.recreateOnFailure = DEFAULT_BLUEPRINT_COMPONENT.recreateOnFailure;
|
|
1115
|
+
return builder;
|
|
1116
|
+
},
|
|
1117
|
+
build: () => {
|
|
1118
|
+
const validationErrors = isValidBlueprintComponent(internalState);
|
|
1119
|
+
if (validationErrors.length > 0) throw new SyntaxError(validationErrors.join("\n"));
|
|
1120
|
+
return { ...internalState };
|
|
1121
|
+
}
|
|
1122
|
+
};
|
|
1123
|
+
return builder;
|
|
1124
|
+
};
|
|
1125
|
+
|
|
1126
|
+
//#endregion
|
|
1127
|
+
//#region src/fractal/component/index.ts
|
|
1128
|
+
let BlueprintComponent;
|
|
1129
|
+
(function(_BlueprintComponent) {
|
|
1130
|
+
let Type;
|
|
1131
|
+
(function(_Type) {
|
|
1132
|
+
_Type.getBuilder = getBlueprintComponentTypeBuilder;
|
|
1133
|
+
})(Type || (Type = _BlueprintComponent.Type || (_BlueprintComponent.Type = {})));
|
|
1134
|
+
let Id;
|
|
1135
|
+
(function(_Id) {
|
|
1136
|
+
_Id.getBuilder = Component.Id.getBuilder;
|
|
1137
|
+
})(Id || (Id = _BlueprintComponent.Id || (_BlueprintComponent.Id = {})));
|
|
1138
|
+
_BlueprintComponent.getBuilder = getBlueprintComponentBuilder;
|
|
1139
|
+
})(BlueprintComponent || (BlueprintComponent = {}));
|
|
1140
|
+
|
|
1141
|
+
//#endregion
|
|
1142
|
+
//#region src/fractal/service.ts
|
|
1143
|
+
const CLIENT_ID_HEADER$1 = "X-ClientID";
|
|
1144
|
+
const CLIENT_SECRET_HEADER$1 = "X-ClientSecret";
|
|
1145
|
+
const FRACTAL_API_URL$1 = "https://api.fractal.cloud";
|
|
1146
|
+
const deployFractal = async (credentials, fractal) => {
|
|
1147
|
+
const fractalUrl = `${FRACTAL_API_URL$1}/blueprints/${fractal.id.toString().replace(":", "/")}`;
|
|
1148
|
+
((await superagent.get(fractalUrl).set(CLIENT_ID_HEADER$1, credentials.id.serviceAccountIdValue).set(CLIENT_SECRET_HEADER$1, credentials.secret).send()).status === 200 ? superagent.put(fractalUrl) : superagent.post(fractalUrl)).set(CLIENT_ID_HEADER$1, credentials.id.serviceAccountIdValue).set(CLIENT_SECRET_HEADER$1, credentials.secret).send({
|
|
1149
|
+
description: fractal.description,
|
|
1150
|
+
isPrivate: fractal.isPrivate,
|
|
1151
|
+
components: fractal.components.map((c) => ({
|
|
1152
|
+
...c,
|
|
1153
|
+
type: c.type.toString(),
|
|
1154
|
+
id: c.id.value.toString(),
|
|
1155
|
+
version: c.version.toString(),
|
|
1156
|
+
parameters: c.parameters.toMap(),
|
|
1157
|
+
dependencies: c.dependencies.map((d) => d.id.value.toString()),
|
|
1158
|
+
links: c.links.map((l) => ({
|
|
1159
|
+
componentId: l.id.value.toString(),
|
|
1160
|
+
settings: l.parameters.toMap()
|
|
1161
|
+
})),
|
|
1162
|
+
outputFields: Object.keys(c.outputFields.value)
|
|
1163
|
+
}))
|
|
1164
|
+
}).catch((e) => console.error(e.message, e.response.text));
|
|
1165
|
+
};
|
|
1166
|
+
const destroyFractal = async (credentials, id) => {
|
|
1167
|
+
await superagent.delete(`${FRACTAL_API_URL$1}/blueprints/${id.toString().replace(":", "/")}`).set(CLIENT_ID_HEADER$1, credentials.id.serviceAccountIdValue).set(CLIENT_SECRET_HEADER$1, credentials.secret);
|
|
1168
|
+
};
|
|
1169
|
+
let FractalService;
|
|
1170
|
+
(function(_FractalService) {
|
|
1171
|
+
_FractalService.deploy = deployFractal;
|
|
1172
|
+
_FractalService.destroy = destroyFractal;
|
|
1173
|
+
})(FractalService || (FractalService = {}));
|
|
1174
|
+
|
|
1175
|
+
//#endregion
|
|
1176
|
+
//#region src/fractal/entity.ts
|
|
1177
|
+
/**
|
|
1178
|
+
* Represents the default configuration for a fractal object.
|
|
1179
|
+
* This variable initializes a fractal with predefined values and
|
|
1180
|
+
* provides default methods for deployment and destruction.
|
|
1181
|
+
*
|
|
1182
|
+
* @constant {Fractal} DEFAULT_FRACTAL
|
|
1183
|
+
* @property {string} id - The unique identifier of the fractal.
|
|
1184
|
+
* @property {boolean} isPrivate - Determines if the fractal is private.
|
|
1185
|
+
* @property {string} description - A brief description of the fractal.
|
|
1186
|
+
* @property {Array} components - A collection of components associated with the fractal.
|
|
1187
|
+
* @property {function} deploy - A method to deploy the fractal.
|
|
1188
|
+
* @property {function} destroy - A method to clean up or destroy the fractal.
|
|
1189
|
+
*/
|
|
1190
|
+
const DEFAULT_FRACTAL = {
|
|
1191
|
+
id: DEFAULT_FRACTAL_ID,
|
|
1192
|
+
isPrivate: false,
|
|
1193
|
+
description: "",
|
|
1194
|
+
components: [],
|
|
1195
|
+
deploy: () => Promise.reject(),
|
|
1196
|
+
destroy: () => Promise.reject()
|
|
1197
|
+
};
|
|
1198
|
+
/**
|
|
1199
|
+
* Validates a given fractal object and returns a list of error messages if any issues are found.
|
|
1200
|
+
*
|
|
1201
|
+
* This function checks the following:
|
|
1202
|
+
* 1. Validity of the fractal's ID through the `isValidFractalId` function.
|
|
1203
|
+
* 2. Presence and validity of the fractal's components through the `isValidBlueprintComponent` function.
|
|
1204
|
+
*
|
|
1205
|
+
* If the fractal has:
|
|
1206
|
+
* - An invalid ID: Any errors related to the ID are added to the error list.
|
|
1207
|
+
* - No components or an empty components array: Adds an error indicating components must not be empty.
|
|
1208
|
+
* - Invalid components: Errors from validating each component are appended to the error list.
|
|
1209
|
+
*
|
|
1210
|
+
* @param {Fractal} fractal - The fractal object to validate. Must include an ID and an array of components.
|
|
1211
|
+
* @returns {string[]} An array of error messages describing any validation issues with the fractal.
|
|
1212
|
+
*/
|
|
1213
|
+
const isValidFractal = (fractal) => {
|
|
1214
|
+
const idErrors = addContextToErrors$4(fractal.id, isValidFractalId(fractal.id));
|
|
1215
|
+
const componentsErrors = addContextToErrors$4(fractal.id, !fractal.components || fractal.components.length === 0 ? ["[Components] Components must not be empty"] : fractal.components.reduce((acc, x) => {
|
|
1216
|
+
acc.push(...isValidBlueprintComponent(x));
|
|
1217
|
+
return acc;
|
|
1218
|
+
}, []));
|
|
1219
|
+
return [...idErrors, ...componentsErrors];
|
|
1220
|
+
};
|
|
1221
|
+
const addContextToErrors$4 = (value, errors) => {
|
|
1222
|
+
return errors.map((error) => `[Fractal: ${value.toString()}]${error}`);
|
|
1223
|
+
};
|
|
1224
|
+
/**
|
|
1225
|
+
* Creates and returns a builder object for constructing Fractal objects.
|
|
1226
|
+
*
|
|
1227
|
+
* This builder provides a fluent interface for setting various properties of a Fractal
|
|
1228
|
+
* and includes methods for validation, resetting to defaults, and final construction.
|
|
1229
|
+
*
|
|
1230
|
+
* @returns {FractalBuilder} A builder object for incrementally building a Fractal.
|
|
1231
|
+
*
|
|
1232
|
+
* The builder object supports the following methods:
|
|
1233
|
+
* - `withId(value: FractalId): FractalBuilder` - Sets the ID of the Fractal.
|
|
1234
|
+
* - `withIsPrivate(value: boolean): FractalBuilder` - Sets the privacy status of the Fractal.
|
|
1235
|
+
* - `withDescription(value: string): FractalBuilder` - Sets the description of the Fractal.
|
|
1236
|
+
* - `withComponents(value: BlueprintComponent[]): FractalBuilder` - Appends a list of components to the Fractal.
|
|
1237
|
+
* - `withComponent(value: BlueprintComponent): FractalBuilder` - Appends a single component to the Fractal.
|
|
1238
|
+
* - `reset(): FractalBuilder` - Resets the builder’s state to the default Fractal properties.
|
|
1239
|
+
* - `build(): Fractal` - Validates and constructs a Fractal object.
|
|
1240
|
+
*
|
|
1241
|
+
* Throws:
|
|
1242
|
+
* - `SyntaxError` - If the constructed Fractal object is invalid during the build process.
|
|
1243
|
+
*/
|
|
1244
|
+
const getFractalBuilder = () => {
|
|
1245
|
+
const internalState = { ...DEFAULT_FRACTAL };
|
|
1246
|
+
const builder = {
|
|
1247
|
+
withId: (value) => {
|
|
1248
|
+
internalState.id = value;
|
|
1249
|
+
return builder;
|
|
1250
|
+
},
|
|
1251
|
+
withIsPrivate: (value) => {
|
|
1252
|
+
internalState.isPrivate = value;
|
|
1253
|
+
return builder;
|
|
1254
|
+
},
|
|
1255
|
+
withDescription: (value) => {
|
|
1256
|
+
internalState.description = value;
|
|
1257
|
+
return builder;
|
|
1258
|
+
},
|
|
1259
|
+
withComponents: (value) => {
|
|
1260
|
+
if (!internalState.components) internalState.components = [];
|
|
1261
|
+
internalState.components.push(...value);
|
|
1262
|
+
return builder;
|
|
1263
|
+
},
|
|
1264
|
+
withComponent: (value) => {
|
|
1265
|
+
if (!internalState.components) internalState.components = [];
|
|
1266
|
+
internalState.components.push(value);
|
|
1267
|
+
return builder;
|
|
1268
|
+
},
|
|
1269
|
+
reset: () => {
|
|
1270
|
+
internalState.id = DEFAULT_FRACTAL.id;
|
|
1271
|
+
internalState.isPrivate = DEFAULT_FRACTAL.isPrivate;
|
|
1272
|
+
internalState.description = DEFAULT_FRACTAL.description;
|
|
1273
|
+
internalState.components = DEFAULT_FRACTAL.components;
|
|
1274
|
+
return builder;
|
|
1275
|
+
},
|
|
1276
|
+
build: () => {
|
|
1277
|
+
const validationErrors = isValidFractal(internalState);
|
|
1278
|
+
if (validationErrors.length > 0) throw new SyntaxError(validationErrors.join("\n"));
|
|
1279
|
+
return {
|
|
1280
|
+
...internalState,
|
|
1281
|
+
deploy: (credentials) => FractalService.deploy(credentials, internalState),
|
|
1282
|
+
destroy: (credentials) => FractalService.destroy(credentials, internalState.id)
|
|
1283
|
+
};
|
|
1284
|
+
}
|
|
1285
|
+
};
|
|
1286
|
+
return builder;
|
|
1287
|
+
};
|
|
1288
|
+
|
|
1289
|
+
//#endregion
|
|
1290
|
+
//#region src/fractal/index.ts
|
|
1291
|
+
let Fractal$1;
|
|
1292
|
+
(function(_Fractal) {
|
|
1293
|
+
let Id;
|
|
1294
|
+
(function(_Id) {
|
|
1295
|
+
_Id.getBuilder = getFractalIdBuilder;
|
|
1296
|
+
})(Id || (Id = _Fractal.Id || (_Fractal.Id = {})));
|
|
1297
|
+
let Component;
|
|
1298
|
+
(function(_Component) {
|
|
1299
|
+
_Component.getBuilder = getBlueprintComponentBuilder;
|
|
1300
|
+
let Type;
|
|
1301
|
+
(function(_Type) {
|
|
1302
|
+
_Type.getBuilder = getBlueprintComponentTypeBuilder;
|
|
1303
|
+
})(Type || (Type = _Component.Type || (_Component.Type = {})));
|
|
1304
|
+
let Id;
|
|
1305
|
+
(function(_Id2) {
|
|
1306
|
+
_Id2.getBuilder = BlueprintComponent.Id.getBuilder;
|
|
1307
|
+
})(Id || (Id = _Component.Id || (_Component.Id = {})));
|
|
1308
|
+
})(Component || (Component = _Fractal.Component || (_Fractal.Component = {})));
|
|
1309
|
+
_Fractal.getBuilder = getFractalBuilder;
|
|
1310
|
+
})(Fractal$1 || (Fractal$1 = {}));
|
|
1311
|
+
|
|
1312
|
+
//#endregion
|
|
1313
|
+
//#region src/bounded_context/entity.ts
|
|
1314
|
+
const DEFAULT = {
|
|
1315
|
+
id: DEFAULT_BOUNDED_CONTEXT_ID,
|
|
1316
|
+
displayName: ""
|
|
1317
|
+
};
|
|
1318
|
+
/**
|
|
1319
|
+
* Determines whether the given bounded context object is valid.
|
|
1320
|
+
*
|
|
1321
|
+
* The validation checks if the bounded context contains:
|
|
1322
|
+
* - A valid bounded context ID, verified through the `isValidBoundedContextId` function.
|
|
1323
|
+
* - A non-empty string as the display name, verified through the `isNonEmptyString` function.
|
|
1324
|
+
*
|
|
1325
|
+
* @param {BoundedContext} value - The bounded context object to be validated.
|
|
1326
|
+
* @returns {boolean} Returns true if the bounded context is valid; otherwise, returns false.
|
|
1327
|
+
*/
|
|
1328
|
+
const isValidBoundedContext = (value) => {
|
|
1329
|
+
const idErrors = addContextToErrors$3(value.id, isValidBoundedContextId(value.id));
|
|
1330
|
+
const displayNameErrors = addContextToErrors$3(value.id, isNonEmptyString(value.displayName) ? [] : ["Display name must be a non-empty string"]);
|
|
1331
|
+
return [...idErrors, ...displayNameErrors];
|
|
1332
|
+
};
|
|
1333
|
+
const addContextToErrors$3 = (bcId, errors) => {
|
|
1334
|
+
return errors.map((error) => `[Bounded Context: ${bcId.toString()}]${error}`);
|
|
1335
|
+
};
|
|
1336
|
+
/**
|
|
1337
|
+
* Creates a builder for constructing a BoundedContext object with a fluid API.
|
|
1338
|
+
*
|
|
1339
|
+
* The `getBoundedContextBuilder` function returns an object with methods that allow incremental construction
|
|
1340
|
+
* of a `BoundedContext` instance. It ensures validation at the `build()` step and supports resets
|
|
1341
|
+
* to default values.
|
|
1342
|
+
*
|
|
1343
|
+
* @function
|
|
1344
|
+
* @returns {BoundedContextBuilder} A builder object for creating a `BoundedContext` instance.
|
|
1345
|
+
*
|
|
1346
|
+
* @throws {SyntaxError} Thrown when attempting to build a `BoundedContext` instance
|
|
1347
|
+
* that is invalid, such as when required fields are not initialized.
|
|
1348
|
+
*/
|
|
1349
|
+
const getBoundedContextBuilder = () => {
|
|
1350
|
+
const internalState = { ...DEFAULT };
|
|
1351
|
+
const builder = {
|
|
1352
|
+
withId: (id) => {
|
|
1353
|
+
internalState.id = id;
|
|
1354
|
+
return builder;
|
|
1355
|
+
},
|
|
1356
|
+
withDisplayName: (displayName) => {
|
|
1357
|
+
internalState.displayName = displayName;
|
|
1358
|
+
return builder;
|
|
1359
|
+
},
|
|
1360
|
+
withDescription: (description) => {
|
|
1361
|
+
internalState.description = description;
|
|
1362
|
+
return builder;
|
|
1363
|
+
},
|
|
1364
|
+
reset: () => {
|
|
1365
|
+
internalState.id = DEFAULT.id;
|
|
1366
|
+
internalState.displayName = DEFAULT.displayName;
|
|
1367
|
+
internalState.description = DEFAULT.description;
|
|
1368
|
+
return builder;
|
|
1369
|
+
},
|
|
1370
|
+
build: () => {
|
|
1371
|
+
const validationErrors = isValidBoundedContext(internalState);
|
|
1372
|
+
if (validationErrors.length > 0) throw new SyntaxError(validationErrors.join("\n"));
|
|
1373
|
+
return { ...internalState };
|
|
1374
|
+
}
|
|
1375
|
+
};
|
|
1376
|
+
return builder;
|
|
1377
|
+
};
|
|
1378
|
+
|
|
1379
|
+
//#endregion
|
|
1380
|
+
//#region src/bounded_context/index.ts
|
|
1381
|
+
let BoundedContext$1;
|
|
1382
|
+
(function(_BoundedContext) {
|
|
1383
|
+
let Id;
|
|
1384
|
+
(function(_Id) {
|
|
1385
|
+
_Id.getBuilder = getBoundedContextIdBuilder;
|
|
1386
|
+
})(Id || (Id = _BoundedContext.Id || (_BoundedContext.Id = {})));
|
|
1387
|
+
_BoundedContext.getBuilder = getBoundedContextBuilder;
|
|
1388
|
+
})(BoundedContext$1 || (BoundedContext$1 = {}));
|
|
1389
|
+
|
|
1390
|
+
//#endregion
|
|
1391
|
+
//#region src/values/service_account_id.ts
|
|
1392
|
+
/**
|
|
1393
|
+
* Represents the default service account identifier used in the application.
|
|
1394
|
+
* This value is typically utilized to associate operations or resources with the
|
|
1395
|
+
* default service account when no specific account is provided.
|
|
1396
|
+
*
|
|
1397
|
+
* @constant {ServiceAccountId}
|
|
1398
|
+
*/
|
|
1399
|
+
const DEFAULT_SERVICE_ACCOUNT_ID = { serviceAccountIdValue: "" };
|
|
1400
|
+
/**
|
|
1401
|
+
* Validates whether the provided value is a valid service account ID.
|
|
1402
|
+
*
|
|
1403
|
+
* The function determines validity by checking if the given value is a valid UUID.
|
|
1404
|
+
* It returns an array of validation error messages if the value is invalid;
|
|
1405
|
+
* otherwise, it returns an empty array.
|
|
1406
|
+
*
|
|
1407
|
+
* @param {string} value - The value to be validated as a service account ID.
|
|
1408
|
+
* @returns {string[]} An array of validation errors, or an empty array if valid.
|
|
1409
|
+
*/
|
|
1410
|
+
const isValidServiceAccountId = (value) => {
|
|
1411
|
+
if (!value || !value.serviceAccountIdValue) return ["Value must be a non-empty string"];
|
|
1412
|
+
return isValidUuid(value.serviceAccountIdValue);
|
|
1413
|
+
};
|
|
1414
|
+
/**
|
|
1415
|
+
* Creates and returns a builder object for constructing a ServiceAccountId.
|
|
1416
|
+
*
|
|
1417
|
+
* The builder provides methods to configure and build a ServiceAccountId, ensuring
|
|
1418
|
+
* that the resulting object adheres to the required validation rules.
|
|
1419
|
+
*
|
|
1420
|
+
* @returns {ServiceAccountIdBuilder} A builder instance used to configure and construct
|
|
1421
|
+
* a ServiceAccountId object.
|
|
1422
|
+
*
|
|
1423
|
+
* The builder provides the following functionalities:
|
|
1424
|
+
* - `withValue(value: string)`: Sets the `value` for the ServiceAccountId. The provided
|
|
1425
|
+
* value must be a valid UUID; otherwise, a `RangeError` is thrown.
|
|
1426
|
+
* - `reset()`: Resets the `value` to the default value specified by `DEFAULT_SERVICE_ACCOUNT_ID`.
|
|
1427
|
+
* - `build()`: Constructs the ServiceAccountId object. If the current state contains
|
|
1428
|
+
* validation errors, a `SyntaxError` is thrown with the list of validation messages.
|
|
1429
|
+
*
|
|
1430
|
+
* The builder maintains an internal mutable state that is used to apply configurations
|
|
1431
|
+
* incrementally until `build()` is called to produce the final ServiceAccountId object.
|
|
1432
|
+
*/
|
|
1433
|
+
const getServiceAccountIdBuilder = () => {
|
|
1434
|
+
const internalState = { ...DEFAULT_SERVICE_ACCOUNT_ID };
|
|
1435
|
+
const builder = {
|
|
1436
|
+
withValue: (value) => {
|
|
1437
|
+
internalState.serviceAccountIdValue = value;
|
|
1438
|
+
return builder;
|
|
1439
|
+
},
|
|
1440
|
+
reset: () => {
|
|
1441
|
+
internalState.serviceAccountIdValue = DEFAULT_SERVICE_ACCOUNT_ID.serviceAccountIdValue;
|
|
1442
|
+
return builder;
|
|
1443
|
+
},
|
|
1444
|
+
build: () => {
|
|
1445
|
+
const validationErrors = isValidServiceAccountId(internalState);
|
|
1446
|
+
if (validationErrors.length > 0) throw new SyntaxError(validationErrors.join("\n"));
|
|
1447
|
+
return { ...internalState };
|
|
1448
|
+
}
|
|
1449
|
+
};
|
|
1450
|
+
return builder;
|
|
1451
|
+
};
|
|
1452
|
+
let ServiceAccountId$1;
|
|
1453
|
+
(function(_ServiceAccountId) {
|
|
1454
|
+
_ServiceAccountId.getBuilder = getServiceAccountIdBuilder;
|
|
1455
|
+
})(ServiceAccountId$1 || (ServiceAccountId$1 = {}));
|
|
1456
|
+
|
|
1457
|
+
//#endregion
|
|
1458
|
+
//#region src/values/service_account_credentials.ts
|
|
1459
|
+
const DEFAULT_SERVICE_ACCOUNT_CREDENTIALS = {
|
|
1460
|
+
id: DEFAULT_SERVICE_ACCOUNT_ID,
|
|
1461
|
+
secret: ""
|
|
1462
|
+
};
|
|
1463
|
+
/**
|
|
1464
|
+
* Validates the provided service account credentials and returns a list of validation errors.
|
|
1465
|
+
*
|
|
1466
|
+
* @param {ServiceAccountCredentials} value - The service account credentials to validate.
|
|
1467
|
+
* @returns {string[]} - An array of error messages, where each message describes a validation issue.
|
|
1468
|
+
* If the credentials are valid, the array is empty.
|
|
1469
|
+
*/
|
|
1470
|
+
const isValidServiceAccountCredentials = (value) => {
|
|
1471
|
+
const idErrors = isValidServiceAccountId(value.id);
|
|
1472
|
+
const secretErrors = value.secret ? [] : ["Secret must be a non-empty string"];
|
|
1473
|
+
return [...idErrors, ...secretErrors];
|
|
1474
|
+
};
|
|
1475
|
+
/**
|
|
1476
|
+
* Creates and returns a builder for constructing service account credentials.
|
|
1477
|
+
*
|
|
1478
|
+
* The builder provides methods to configure and validate a `ServiceAccountCredentials` object.
|
|
1479
|
+
* It includes support for setting the `id` and `secret`, resetting to default values,
|
|
1480
|
+
* and finalizing the construction by ensuring the credentials are valid.
|
|
1481
|
+
*
|
|
1482
|
+
* @returns {ServiceAccountCredentialsBuilder} A builder object to construct `ServiceAccountCredentials`.
|
|
1483
|
+
*/
|
|
1484
|
+
const getServiceAccountCredentialsBuilder = () => {
|
|
1485
|
+
const internalState = { ...DEFAULT_SERVICE_ACCOUNT_CREDENTIALS };
|
|
1486
|
+
const builder = {
|
|
1487
|
+
withId: (value) => {
|
|
1488
|
+
internalState.id = value;
|
|
1489
|
+
return builder;
|
|
1490
|
+
},
|
|
1491
|
+
withSecret: (value) => {
|
|
1492
|
+
internalState.secret = value;
|
|
1493
|
+
return builder;
|
|
1494
|
+
},
|
|
1495
|
+
reset: () => {
|
|
1496
|
+
internalState.id = DEFAULT_SERVICE_ACCOUNT_CREDENTIALS.id;
|
|
1497
|
+
internalState.secret = DEFAULT_SERVICE_ACCOUNT_CREDENTIALS.secret;
|
|
1498
|
+
return builder;
|
|
1499
|
+
},
|
|
1500
|
+
build: () => {
|
|
1501
|
+
const validationErrors = isValidServiceAccountCredentials(internalState);
|
|
1502
|
+
if (validationErrors.length > 0) throw new SyntaxError(validationErrors.join("\n"));
|
|
1503
|
+
return { ...internalState };
|
|
1504
|
+
}
|
|
1505
|
+
};
|
|
1506
|
+
return builder;
|
|
1507
|
+
};
|
|
1508
|
+
let ServiceAccountCredentials$1;
|
|
1509
|
+
(function(_ServiceAccountCredentials) {
|
|
1510
|
+
_ServiceAccountCredentials.getBuilder = getServiceAccountCredentialsBuilder;
|
|
1511
|
+
})(ServiceAccountCredentials$1 || (ServiceAccountCredentials$1 = {}));
|
|
1512
|
+
|
|
1513
|
+
//#endregion
|
|
1514
|
+
//#region src/environment/id.ts
|
|
1515
|
+
const equals = (a, b) => a.ownerType === b.ownerType && a.ownerId.value === b.ownerId.value && a.name.value === b.name.value;
|
|
1516
|
+
/**
|
|
1517
|
+
* Represents the default environment identifier used within the system.
|
|
1518
|
+
* The variable holds a constant, immutable object reflecting the default
|
|
1519
|
+
* properties and metadata of an environment.
|
|
1520
|
+
*
|
|
1521
|
+
* Properties:
|
|
1522
|
+
* - `ownerType`: An enumeration value specifying the type of owner (e.g., personal).
|
|
1523
|
+
* - `ownerId`: A constant value representing the default owner identifier.
|
|
1524
|
+
* - `name`: A default kebab-case formatted string for the environment name.
|
|
1525
|
+
* - `equals`: A function that always returns `false`, used to compare equality with another environment.
|
|
1526
|
+
* - `toString`: A function returning an empty string representation of the environment.
|
|
1527
|
+
*
|
|
1528
|
+
* The object is defined as `const` to ensure its immutability and integrity throughout its usage.
|
|
1529
|
+
*/
|
|
1530
|
+
const DEFAULT_ENVIRONMENT_ID = {
|
|
1531
|
+
_type: "environment",
|
|
1532
|
+
ownerType: OwnerType$1.Personal,
|
|
1533
|
+
ownerId: DEFAULT_OWNER_ID,
|
|
1534
|
+
name: DEFAULT_KEBAB_CASE_STRING,
|
|
1535
|
+
equals: () => false,
|
|
1536
|
+
toString: () => ""
|
|
1537
|
+
};
|
|
1538
|
+
/**
|
|
1539
|
+
* Validates whether the given environment ID is valid by checking its owner ID and name.
|
|
1540
|
+
*
|
|
1541
|
+
* @param {EnvironmentId} value - The environment ID to validate, which consists of an owner ID and a name.
|
|
1542
|
+
* @returns {string[]} An array of error messages, where each message describes a specific validation failure
|
|
1543
|
+
* for either the owner ID or the name. If no errors are present, the array is empty.
|
|
1544
|
+
*/
|
|
1545
|
+
const isValidEnvironmentId = (value) => {
|
|
1546
|
+
const ownerIdErrors = addContextToErrors$2(value, isValidOwnerId(value.ownerId));
|
|
1547
|
+
const nameErrors = addContextToErrors$2(value, isValidKebabCaseString(value.name.toString()));
|
|
1548
|
+
return [...ownerIdErrors, ...nameErrors];
|
|
1549
|
+
};
|
|
1550
|
+
const addContextToErrors$2 = (value, errors) => {
|
|
1551
|
+
return errors.map((error) => `[Environment Id: ${environmentIdToString(value)}]${error}`);
|
|
1552
|
+
};
|
|
1553
|
+
const environmentIdToString = (id) => `${id.ownerType.toString()}/${id.ownerId.value}/${id.name.value}`;
|
|
1554
|
+
/**
|
|
1555
|
+
* Creates and returns a builder for constructing a `Id` object.
|
|
1556
|
+
*
|
|
1557
|
+
* The builder allows customization of the `Id` properties such as `ownerType`,
|
|
1558
|
+
* while also enforcing constraints during the construction process, ensuring the resulting object is valid.
|
|
1559
|
+
* The builder is stateful and provides a method to reset to default values if needed.
|
|
1560
|
+
*
|
|
1561
|
+
* @returns {EnvironmentIdBuilder} A builder object that provides methods for modifying and constructing a `Id`.
|
|
1562
|
+
*
|
|
1563
|
+
* @throws {SyntaxError} Throws an error if the resulting `Id` is invalid when the `build` method is invoked.
|
|
1564
|
+
*/
|
|
1565
|
+
const getEnvironmentIdBuilder = () => {
|
|
1566
|
+
const internalState = { ...DEFAULT_ENVIRONMENT_ID };
|
|
1567
|
+
const builder = {
|
|
1568
|
+
withOwnerType: (ownerType) => {
|
|
1569
|
+
internalState.ownerType = ownerType;
|
|
1570
|
+
return builder;
|
|
1571
|
+
},
|
|
1572
|
+
withOwnerId: (ownerId) => {
|
|
1573
|
+
internalState.ownerId = ownerId;
|
|
1574
|
+
return builder;
|
|
1575
|
+
},
|
|
1576
|
+
withName: (name) => {
|
|
1577
|
+
internalState.name = name;
|
|
1578
|
+
return builder;
|
|
1579
|
+
},
|
|
1580
|
+
reset: () => {
|
|
1581
|
+
internalState.ownerType = DEFAULT_ENVIRONMENT_ID.ownerType;
|
|
1582
|
+
internalState.ownerId = DEFAULT_ENVIRONMENT_ID.ownerId;
|
|
1583
|
+
internalState.name = DEFAULT_ENVIRONMENT_ID.name;
|
|
1584
|
+
return builder;
|
|
1585
|
+
},
|
|
1586
|
+
build: () => {
|
|
1587
|
+
const validationErrors = isValidEnvironmentId(internalState);
|
|
1588
|
+
if (validationErrors.length > 0) throw new SyntaxError(validationErrors.join("\n"));
|
|
1589
|
+
const builtId = {
|
|
1590
|
+
...internalState,
|
|
1591
|
+
equals: (other) => equals(builtId, other),
|
|
1592
|
+
toString: () => environmentIdToString(builtId)
|
|
1593
|
+
};
|
|
1594
|
+
return builtId;
|
|
1595
|
+
}
|
|
1596
|
+
};
|
|
1597
|
+
return builder;
|
|
1598
|
+
};
|
|
1599
|
+
|
|
1600
|
+
//#endregion
|
|
1601
|
+
//#region src/environment/entity.ts
|
|
1602
|
+
const DEFAULT_ENVIRONMENT = {
|
|
1603
|
+
id: DEFAULT_ENVIRONMENT_ID,
|
|
1604
|
+
parameters: getParametersInstance()
|
|
1605
|
+
};
|
|
1606
|
+
const isValidEnvironment = (environment) => addContextToErrors$1(environment.id, isValidEnvironmentId(environment.id));
|
|
1607
|
+
const addContextToErrors$1 = (environmentId, errors) => {
|
|
1608
|
+
return errors.map((error) => `[Environment: ${environmentId.toString()}]${error}`);
|
|
1609
|
+
};
|
|
1610
|
+
const getEnvironmentBuilder = () => {
|
|
1611
|
+
const internalState = { ...DEFAULT_ENVIRONMENT };
|
|
1612
|
+
const builder = {
|
|
1613
|
+
withId: (id) => {
|
|
1614
|
+
internalState.id = id;
|
|
1615
|
+
return builder;
|
|
1616
|
+
},
|
|
1617
|
+
withParameters: (parameters) => {
|
|
1618
|
+
internalState.parameters = parameters;
|
|
1619
|
+
return builder;
|
|
1620
|
+
},
|
|
1621
|
+
reset: () => {
|
|
1622
|
+
internalState.id = DEFAULT_ENVIRONMENT.id;
|
|
1623
|
+
internalState.parameters = DEFAULT_ENVIRONMENT.parameters;
|
|
1624
|
+
return builder;
|
|
1625
|
+
},
|
|
1626
|
+
build: () => {
|
|
1627
|
+
const validationErrors = isValidEnvironment(internalState);
|
|
1628
|
+
if (validationErrors.length > 0) throw new SyntaxError(validationErrors.join("\n"));
|
|
1629
|
+
return { ...internalState };
|
|
1630
|
+
}
|
|
1631
|
+
};
|
|
1632
|
+
return builder;
|
|
1633
|
+
};
|
|
1634
|
+
|
|
1635
|
+
//#endregion
|
|
1636
|
+
//#region src/environment/index.ts
|
|
1637
|
+
let Environment$1;
|
|
1638
|
+
(function(_Environment) {
|
|
1639
|
+
let Id;
|
|
1640
|
+
(function(_Id) {
|
|
1641
|
+
_Id.getBuilder = getEnvironmentIdBuilder;
|
|
1642
|
+
})(Id || (Id = _Environment.Id || (_Environment.Id = {})));
|
|
1643
|
+
_Environment.getBuilder = getEnvironmentBuilder;
|
|
1644
|
+
})(Environment$1 || (Environment$1 = {}));
|
|
1645
|
+
|
|
1646
|
+
//#endregion
|
|
1647
|
+
//#region src/live_system/id.ts
|
|
1648
|
+
const toString = (id) => `${id.boundedContextId.toString()}/${id.name.value}`;
|
|
1649
|
+
/**
|
|
1650
|
+
* Validates the specified LiveSystemId and returns a list of error messages.
|
|
1651
|
+
*
|
|
1652
|
+
* The validation process includes checking the validity of the bounded context ID
|
|
1653
|
+
* and the name associated with the LiveSystemId.
|
|
1654
|
+
*
|
|
1655
|
+
* @param {LiveSystemId} id - The LiveSystemId object to be validated. It contains
|
|
1656
|
+
* a bounded context ID and a name in kebab-case format.
|
|
1657
|
+
* @returns {string[]} An array of error messages generated during validation. Each error message
|
|
1658
|
+
* is prepended with the string representation of the provided LiveSystemId for context.
|
|
1659
|
+
*/
|
|
1660
|
+
const isValidLiveSystemId = (id) => {
|
|
1661
|
+
const boundedContextIdErrors = isValidBoundedContextId(id.boundedContextId);
|
|
1662
|
+
const nameErrors = isValidKebabCaseString(id.name.value);
|
|
1663
|
+
return [...boundedContextIdErrors.map((x) => `[Live System Id: ${id.toString()}] Bounded Context Id error: ${x}`), ...nameErrors.map((x) => `[Live System Id: ${id.toString()}] Name errors: ${x}`)];
|
|
1664
|
+
};
|
|
1665
|
+
/**
|
|
1666
|
+
* Represents the default identifier for a live system within a bounded context.
|
|
1667
|
+
*
|
|
1668
|
+
* This constant is used to define the default configuration for a live system by associating a
|
|
1669
|
+
* predefined bounded context identifier with a default name in kebab-case format.
|
|
1670
|
+
*
|
|
1671
|
+
* Fields:
|
|
1672
|
+
* - `boundedContextId`: Identifies the default bounded context to which the live system belongs.
|
|
1673
|
+
* - `name`: Specifies the default name of the live system in a standardized kebab-case string format.
|
|
1674
|
+
*/
|
|
1675
|
+
const DEFAULT_LIVE_SYSTEM_ID = {
|
|
1676
|
+
boundedContextId: DEFAULT_BOUNDED_CONTEXT_ID,
|
|
1677
|
+
name: DEFAULT_KEBAB_CASE_STRING
|
|
1678
|
+
};
|
|
1679
|
+
/**
|
|
1680
|
+
* Creates and returns a `LiveSystemIdBuilder` to construct and validate `LiveSystemId` objects.
|
|
1681
|
+
*
|
|
1682
|
+
* The builder provides a fluent API for setting properties and validating the resulting `LiveSystemId`.
|
|
1683
|
+
*
|
|
1684
|
+
* @returns {LiveSystemIdBuilder} A builder object with methods to configure, reset, and build a `LiveSystemId`.
|
|
1685
|
+
*
|
|
1686
|
+
* Methods available in the builder:
|
|
1687
|
+
* - `withBoundedContextId(value: BoundedContext.Id)`: Sets the bounded context ID for the `LiveSystemId`.
|
|
1688
|
+
* - `withName(value: KebabCaseString)`: Sets the name for the `LiveSystemId`.
|
|
1689
|
+
* - `reset()`: Resets all properties to their default values as defined in `DEFAULT_LIVE_SYSTEM_ID`.
|
|
1690
|
+
* - `build()`: Validates the current state of the builder and constructs a `LiveSystemId` object. Throws a `SyntaxError` if validation fails.
|
|
1691
|
+
*/
|
|
1692
|
+
const getLiveSystemIdBuilder = () => {
|
|
1693
|
+
const internalState = { ...DEFAULT_LIVE_SYSTEM_ID };
|
|
1694
|
+
const builder = {
|
|
1695
|
+
withBoundedContextId: (value) => {
|
|
1696
|
+
internalState.boundedContextId = value;
|
|
1697
|
+
return builder;
|
|
1698
|
+
},
|
|
1699
|
+
withName: (value) => {
|
|
1700
|
+
internalState.name = value;
|
|
1701
|
+
return builder;
|
|
1702
|
+
},
|
|
1703
|
+
reset: () => {
|
|
1704
|
+
internalState.boundedContextId = DEFAULT_LIVE_SYSTEM_ID.boundedContextId;
|
|
1705
|
+
internalState.name = DEFAULT_LIVE_SYSTEM_ID.name;
|
|
1706
|
+
return builder;
|
|
1707
|
+
},
|
|
1708
|
+
build: () => {
|
|
1709
|
+
const validationErrors = isValidLiveSystemId(internalState);
|
|
1710
|
+
if (validationErrors.length > 0) throw new SyntaxError(validationErrors.join("\n"));
|
|
1711
|
+
const builtId = {
|
|
1712
|
+
...internalState,
|
|
1713
|
+
toString: () => toString(builtId)
|
|
1714
|
+
};
|
|
1715
|
+
return builtId;
|
|
1716
|
+
}
|
|
1717
|
+
};
|
|
1718
|
+
return builder;
|
|
1719
|
+
};
|
|
1720
|
+
|
|
1721
|
+
//#endregion
|
|
1722
|
+
//#region src/live_system/component/entity.ts
|
|
1723
|
+
const DEFAULT_LIVE_SYSTEM_COMPONENT = {
|
|
1724
|
+
...DEFAULT_BLUEPRINT_COMPONENT,
|
|
1725
|
+
status: "Instantiating",
|
|
1726
|
+
lastUpdated: /* @__PURE__ */ new Date(0),
|
|
1727
|
+
lastOperationRetried: -1,
|
|
1728
|
+
provider: "Unknown",
|
|
1729
|
+
lastOperationStatusMessage: "",
|
|
1730
|
+
errorCode: ""
|
|
1731
|
+
};
|
|
1732
|
+
const isValidLiveSystemComponent = (component) => isValidBlueprintComponent(component);
|
|
1733
|
+
const getLiveSystemComponentBuilder = () => {
|
|
1734
|
+
const internalState = { ...DEFAULT_LIVE_SYSTEM_COMPONENT };
|
|
1735
|
+
const builder = {
|
|
1736
|
+
withType: (type) => {
|
|
1737
|
+
internalState.type = type;
|
|
1738
|
+
return builder;
|
|
1739
|
+
},
|
|
1740
|
+
withId: (id) => {
|
|
1741
|
+
internalState.id = id;
|
|
1742
|
+
return builder;
|
|
1743
|
+
},
|
|
1744
|
+
withVersion: (version) => {
|
|
1745
|
+
internalState.version = version;
|
|
1746
|
+
return builder;
|
|
1747
|
+
},
|
|
1748
|
+
withIsLocked: (value) => {
|
|
1749
|
+
internalState.isLocked = value;
|
|
1750
|
+
return builder;
|
|
1751
|
+
},
|
|
1752
|
+
withRecreateOnFailure: (value) => {
|
|
1753
|
+
internalState.recreateOnFailure = value;
|
|
1754
|
+
return builder;
|
|
1755
|
+
},
|
|
1756
|
+
withProvider: (value) => {
|
|
1757
|
+
internalState.provider = value;
|
|
1758
|
+
return builder;
|
|
1759
|
+
},
|
|
1760
|
+
withDisplayName: (displayName) => {
|
|
1761
|
+
internalState.displayName = displayName;
|
|
1762
|
+
return builder;
|
|
1763
|
+
},
|
|
1764
|
+
withDescription: (description) => {
|
|
1765
|
+
internalState.description = description;
|
|
1766
|
+
return builder;
|
|
1767
|
+
},
|
|
1768
|
+
withParameters: (parameters) => {
|
|
1769
|
+
internalState.parameters = parameters;
|
|
1770
|
+
return builder;
|
|
1771
|
+
},
|
|
1772
|
+
withLinks: (links) => {
|
|
1773
|
+
internalState.links = links;
|
|
1774
|
+
return builder;
|
|
1775
|
+
},
|
|
1776
|
+
withDependencies: (dependencies) => {
|
|
1777
|
+
internalState.dependencies = dependencies;
|
|
1778
|
+
return builder;
|
|
1779
|
+
},
|
|
1780
|
+
reset: () => {
|
|
1781
|
+
internalState.type = DEFAULT_LIVE_SYSTEM_COMPONENT.type;
|
|
1782
|
+
internalState.id = DEFAULT_LIVE_SYSTEM_COMPONENT.id;
|
|
1783
|
+
internalState.version = DEFAULT_LIVE_SYSTEM_COMPONENT.version;
|
|
1784
|
+
internalState.displayName = DEFAULT_LIVE_SYSTEM_COMPONENT.displayName;
|
|
1785
|
+
internalState.description = DEFAULT_LIVE_SYSTEM_COMPONENT.description;
|
|
1786
|
+
internalState.parameters = DEFAULT_LIVE_SYSTEM_COMPONENT.parameters;
|
|
1787
|
+
internalState.links = DEFAULT_LIVE_SYSTEM_COMPONENT.links;
|
|
1788
|
+
internalState.dependencies = DEFAULT_LIVE_SYSTEM_COMPONENT.dependencies;
|
|
1789
|
+
internalState.isLocked = DEFAULT_LIVE_SYSTEM_COMPONENT.isLocked;
|
|
1790
|
+
internalState.provider = DEFAULT_LIVE_SYSTEM_COMPONENT.provider;
|
|
1791
|
+
internalState.recreateOnFailure = DEFAULT_LIVE_SYSTEM_COMPONENT.recreateOnFailure;
|
|
1792
|
+
return builder;
|
|
1793
|
+
},
|
|
1794
|
+
build: () => {
|
|
1795
|
+
const validationErrors = isValidLiveSystemComponent(internalState);
|
|
1796
|
+
if (validationErrors.length > 0) throw new SyntaxError(validationErrors.join("\n"));
|
|
1797
|
+
return { ...internalState };
|
|
1798
|
+
}
|
|
1799
|
+
};
|
|
1800
|
+
return builder;
|
|
1801
|
+
};
|
|
1802
|
+
|
|
1803
|
+
//#endregion
|
|
1804
|
+
//#region src/live_system/service.ts
|
|
1805
|
+
const CLIENT_ID_HEADER = "X-ClientID";
|
|
1806
|
+
const CLIENT_SECRET_HEADER = "X-ClientSecret";
|
|
1807
|
+
const FRACTAL_API_URL = "https://api.fractal.cloud";
|
|
1808
|
+
const deployLiveSystem = async (credentials, liveSystem) => {
|
|
1809
|
+
const body = {
|
|
1810
|
+
liveSystemId: liveSystem.id.toString(),
|
|
1811
|
+
fractalId: liveSystem.fractalId.toString(),
|
|
1812
|
+
description: liveSystem.description,
|
|
1813
|
+
provider: liveSystem.genericProvider,
|
|
1814
|
+
blueprintMap: liveSystem.components.reduce((acc, c) => {
|
|
1815
|
+
acc[c.id.value.toString()] = {
|
|
1816
|
+
...c,
|
|
1817
|
+
type: c.type.toString(),
|
|
1818
|
+
id: c.id.value.toString(),
|
|
1819
|
+
version: c.version.toString(),
|
|
1820
|
+
parameters: c.parameters.toMap(),
|
|
1821
|
+
dependencies: c.dependencies.map((d) => d.id.value.toString()),
|
|
1822
|
+
links: c.links.map((l) => ({
|
|
1823
|
+
componentId: l.id.value.toString(),
|
|
1824
|
+
settings: l.parameters.toMap()
|
|
1825
|
+
})),
|
|
1826
|
+
outputFields: c.outputFields.value
|
|
1827
|
+
};
|
|
1828
|
+
return acc;
|
|
1829
|
+
}, {}),
|
|
1830
|
+
parameters: liveSystem.parameters.toMap(),
|
|
1831
|
+
environment: {
|
|
1832
|
+
id: {
|
|
1833
|
+
type: liveSystem.environment.id.ownerType,
|
|
1834
|
+
ownerId: liveSystem.environment.id.ownerId.toString(),
|
|
1835
|
+
shortName: liveSystem.environment.id.name.toString()
|
|
1836
|
+
},
|
|
1837
|
+
parameters: liveSystem.environment.parameters.toMap()
|
|
1838
|
+
}
|
|
1839
|
+
};
|
|
1840
|
+
const liveSystemUrl = `${FRACTAL_API_URL}/livesystems/${liveSystem.id.toString()}`;
|
|
1841
|
+
((await superagent.get(liveSystemUrl).set(CLIENT_ID_HEADER, credentials.id.serviceAccountIdValue).set(CLIENT_SECRET_HEADER, credentials.secret).send()).status === 200 ? superagent.put(liveSystemUrl) : superagent.post(`${FRACTAL_API_URL}/livesystems`)).set(CLIENT_ID_HEADER, credentials.id.serviceAccountIdValue).set(CLIENT_SECRET_HEADER, credentials.secret).send(body).catch((e) => console.error(e.message, e.response.text));
|
|
1842
|
+
};
|
|
1843
|
+
const destroyLiveSystem = async (credentials, id) => {
|
|
1844
|
+
await superagent.delete(`${FRACTAL_API_URL}/livesystems/${id.toString()}`).set(CLIENT_ID_HEADER, credentials.id.serviceAccountIdValue).set(CLIENT_SECRET_HEADER, credentials.secret);
|
|
1845
|
+
};
|
|
1846
|
+
let LiveSystemService;
|
|
1847
|
+
(function(_LiveSystemService) {
|
|
1848
|
+
_LiveSystemService.deploy = deployLiveSystem;
|
|
1849
|
+
_LiveSystemService.destroy = destroyLiveSystem;
|
|
1850
|
+
})(LiveSystemService || (LiveSystemService = {}));
|
|
1851
|
+
|
|
1852
|
+
//#endregion
|
|
1853
|
+
//#region src/live_system/entity.ts
|
|
1854
|
+
const DEFAULT_LIVE_SYSTEM = {
|
|
1855
|
+
id: DEFAULT_LIVE_SYSTEM_ID,
|
|
1856
|
+
requesterId: "",
|
|
1857
|
+
fractalId: DEFAULT_FRACTAL_ID,
|
|
1858
|
+
description: "",
|
|
1859
|
+
status: "Unknown",
|
|
1860
|
+
statusMessage: "",
|
|
1861
|
+
components: [],
|
|
1862
|
+
genericProvider: "Unknown",
|
|
1863
|
+
parameters: getParametersInstance(),
|
|
1864
|
+
createdAt: /* @__PURE__ */ new Date(),
|
|
1865
|
+
updatedAt: /* @__PURE__ */ new Date(),
|
|
1866
|
+
environment: DEFAULT_ENVIRONMENT,
|
|
1867
|
+
deploy: () => Promise.reject(),
|
|
1868
|
+
destroy: () => Promise.reject()
|
|
1869
|
+
};
|
|
1870
|
+
/**
|
|
1871
|
+
* Validates a given live system and returns a list of error messages if any validation fails.
|
|
1872
|
+
*
|
|
1873
|
+
* This function verifies the following:
|
|
1874
|
+
* - The `id` of the live system is valid.
|
|
1875
|
+
* - The `fractalId` of the live system is valid.
|
|
1876
|
+
* - The `components` field is not empty and all its components pass validation.
|
|
1877
|
+
*
|
|
1878
|
+
* @param {LiveSystem} liveSystem - The live system object to be validated.
|
|
1879
|
+
* @returns {string[]} An array of error messages. If validation passes, this array will be empty.
|
|
1880
|
+
*/
|
|
1881
|
+
const isValidLiveSystem = (liveSystem) => {
|
|
1882
|
+
const idErrors = addContextToErrors(liveSystem.id, isValidLiveSystemId(liveSystem.id));
|
|
1883
|
+
const fractalIdErrors = addContextToErrors(liveSystem.id, isValidFractalId(liveSystem.fractalId));
|
|
1884
|
+
const environmentErrors = addContextToErrors(liveSystem.id, isValidEnvironment(liveSystem.environment));
|
|
1885
|
+
const componentsErrors = addContextToErrors(liveSystem.id, !liveSystem.components || liveSystem.components.length === 0 ? ["[Components] Components must not be empty"] : liveSystem.components.reduce((acc, x) => {
|
|
1886
|
+
acc.push(...isValidLiveSystemComponent(x));
|
|
1887
|
+
return acc;
|
|
1888
|
+
}, []));
|
|
1889
|
+
return [
|
|
1890
|
+
...idErrors,
|
|
1891
|
+
...fractalIdErrors,
|
|
1892
|
+
...componentsErrors,
|
|
1893
|
+
...environmentErrors
|
|
1894
|
+
];
|
|
1895
|
+
};
|
|
1896
|
+
const addContextToErrors = (liveSystemId, errors) => {
|
|
1897
|
+
return errors.map((error) => `[Live System: ${liveSystemId.toString()}]${error}`);
|
|
1898
|
+
};
|
|
1899
|
+
/**
|
|
1900
|
+
* Creates and returns a builder for constructing LiveSystem objects.
|
|
1901
|
+
* The builder allows the user to configure various properties of a LiveSystem
|
|
1902
|
+
* instance through a fluent API.
|
|
1903
|
+
*
|
|
1904
|
+
* @returns {LiveSystemBuilder} An object providing methods to configure and build a LiveSystem instance.
|
|
1905
|
+
*
|
|
1906
|
+
* @description
|
|
1907
|
+
* The `getLiveSystemBuilder` function initializes a builder object for constructing LiveSystem instances.
|
|
1908
|
+
* The builder maintains an internal state that gets updated through its methods. When the `build` method
|
|
1909
|
+
* is invoked, the internal state is validated and returned as a fully formed LiveSystem object.
|
|
1910
|
+
*
|
|
1911
|
+
* The builder provides the following configuration methods:
|
|
1912
|
+
* - `withId(value: LiveSystemId)`: Sets the `id` property of the LiveSystem.
|
|
1913
|
+
* - `withDescription(value: string)`: Sets the `description` property of the LiveSystem.
|
|
1914
|
+
* - `withFractalId(value: Fractal.Id)`: Sets the `fractalId` property of the LiveSystem.
|
|
1915
|
+
* - `withComponents(value: LiveSystemComponent[])`: Adds an array of components to the LiveSystem.
|
|
1916
|
+
* - `withComponent(value: LiveSystemComponent)`: Adds a single component to the LiveSystem.
|
|
1917
|
+
* - `withGenericProvider(value: LiveSystemComponent.Provider)`: Sets the `genericProvider` property of the LiveSystem.
|
|
1918
|
+
* - `withParameters(parameters: ComponentParameters): Assigns the provided `parameters` to the `LiveSystem`.
|
|
1919
|
+
*
|
|
1920
|
+
* Additional builder methods:
|
|
1921
|
+
* - `reset()`: Resets the internal state to the default LiveSystem configuration.
|
|
1922
|
+
* - `build()`: Validates the internal state and returns a LiveSystem instance. If validation fails, an error is thrown.
|
|
1923
|
+
*
|
|
1924
|
+
* Validation:
|
|
1925
|
+
* The `build` method performs validation on the internal state using the `isValidLiveSystem` function. If validation
|
|
1926
|
+
* errors are detected, a `SyntaxError` is thrown containing the list of errors.
|
|
1927
|
+
*
|
|
1928
|
+
* Lifecycle Operations:
|
|
1929
|
+
* The constructed LiveSystem object includes the `deploy` and `destroy` methods:
|
|
1930
|
+
* - `deploy(credentials)`: Deploys the LiveSystem using the given credentials.
|
|
1931
|
+
* - `destroy(credentials)`: Destroys the LiveSystem using the given credentials and its `id`.
|
|
1932
|
+
*/
|
|
1933
|
+
const getLiveSystemBuilder = () => {
|
|
1934
|
+
const internalState = { ...DEFAULT_LIVE_SYSTEM };
|
|
1935
|
+
const builder = {
|
|
1936
|
+
withId: (value) => {
|
|
1937
|
+
internalState.id = value;
|
|
1938
|
+
return builder;
|
|
1939
|
+
},
|
|
1940
|
+
withFractalId: (value) => {
|
|
1941
|
+
internalState.fractalId = value;
|
|
1942
|
+
return builder;
|
|
1943
|
+
},
|
|
1944
|
+
withDescription: (value) => {
|
|
1945
|
+
internalState.description = value;
|
|
1946
|
+
return builder;
|
|
1947
|
+
},
|
|
1948
|
+
withComponents: (value) => {
|
|
1949
|
+
if (!internalState.components) internalState.components = [];
|
|
1950
|
+
internalState.components.push(...value);
|
|
1951
|
+
return builder;
|
|
1952
|
+
},
|
|
1953
|
+
withComponent: (value) => {
|
|
1954
|
+
if (!internalState.components) internalState.components = [];
|
|
1955
|
+
internalState.components.push(value);
|
|
1956
|
+
return builder;
|
|
1957
|
+
},
|
|
1958
|
+
withGenericProvider: (value) => {
|
|
1959
|
+
internalState.genericProvider = value;
|
|
1960
|
+
return builder;
|
|
1961
|
+
},
|
|
1962
|
+
withParameters: (parameters) => {
|
|
1963
|
+
internalState.parameters = parameters;
|
|
1964
|
+
return builder;
|
|
1965
|
+
},
|
|
1966
|
+
withEnvironment: (environment) => {
|
|
1967
|
+
internalState.environment = environment;
|
|
1968
|
+
return builder;
|
|
1969
|
+
},
|
|
1970
|
+
reset: () => {
|
|
1971
|
+
internalState.id = DEFAULT_LIVE_SYSTEM.id;
|
|
1972
|
+
internalState.requesterId = DEFAULT_LIVE_SYSTEM.requesterId;
|
|
1973
|
+
internalState.fractalId = DEFAULT_LIVE_SYSTEM.fractalId;
|
|
1974
|
+
internalState.description = DEFAULT_LIVE_SYSTEM.description;
|
|
1975
|
+
internalState.status = DEFAULT_LIVE_SYSTEM.status;
|
|
1976
|
+
internalState.statusMessage = DEFAULT_LIVE_SYSTEM.statusMessage;
|
|
1977
|
+
internalState.components = DEFAULT_LIVE_SYSTEM.components;
|
|
1978
|
+
internalState.genericProvider = DEFAULT_LIVE_SYSTEM.genericProvider;
|
|
1979
|
+
internalState.environment = DEFAULT_LIVE_SYSTEM.environment;
|
|
1980
|
+
internalState.createdAt = DEFAULT_LIVE_SYSTEM.createdAt;
|
|
1981
|
+
internalState.updatedAt = DEFAULT_LIVE_SYSTEM.updatedAt;
|
|
1982
|
+
return builder;
|
|
1983
|
+
},
|
|
1984
|
+
build: () => {
|
|
1985
|
+
const validationErrors = isValidLiveSystem(internalState);
|
|
1986
|
+
if (validationErrors.length > 0) throw new SyntaxError(validationErrors.join("\n"));
|
|
1987
|
+
return {
|
|
1988
|
+
...internalState,
|
|
1989
|
+
deploy: (credentials) => LiveSystemService.deploy(credentials, internalState),
|
|
1990
|
+
destroy: (credentials) => LiveSystemService.destroy(credentials, internalState.id)
|
|
1991
|
+
};
|
|
1992
|
+
}
|
|
1993
|
+
};
|
|
1994
|
+
return builder;
|
|
1995
|
+
};
|
|
1996
|
+
|
|
1997
|
+
//#endregion
|
|
1998
|
+
//#region src/live_system/index.ts
|
|
1999
|
+
let LiveSystem$1;
|
|
2000
|
+
(function(_LiveSystem) {
|
|
2001
|
+
let Id;
|
|
2002
|
+
(function(_Id) {
|
|
2003
|
+
_Id.getBuilder = getLiveSystemIdBuilder;
|
|
2004
|
+
})(Id || (Id = _LiveSystem.Id || (_LiveSystem.Id = {})));
|
|
2005
|
+
let Component;
|
|
2006
|
+
(function(_Component) {
|
|
2007
|
+
_Component.getBuilder = getLiveSystemComponentBuilder;
|
|
2008
|
+
})(Component || (Component = _LiveSystem.Component || (_LiveSystem.Component = {})));
|
|
2009
|
+
_LiveSystem.getBuilder = getLiveSystemBuilder;
|
|
2010
|
+
})(LiveSystem$1 || (LiveSystem$1 = {}));
|
|
2011
|
+
|
|
2012
|
+
//#endregion
|
|
2013
|
+
//#region src/index.ts
|
|
2014
|
+
const BoundedContext = BoundedContext$1;
|
|
2015
|
+
const Fractal = Fractal$1;
|
|
2016
|
+
const InfrastructureDomain = InfrastructureDomain$1;
|
|
2017
|
+
const KebabCaseString = KebabCaseString$1;
|
|
2018
|
+
const OwnerId = OwnerId$1;
|
|
2019
|
+
const OwnerType = OwnerType$1;
|
|
2020
|
+
const PascalCaseString = PascalCaseString$1;
|
|
2021
|
+
const ServiceAccountCredentials = ServiceAccountCredentials$1;
|
|
2022
|
+
const ServiceAccountId = ServiceAccountId$1;
|
|
2023
|
+
const ServiceDeliveryModel = ServiceDeliveryModel$1;
|
|
2024
|
+
const Version = Version$1;
|
|
2025
|
+
const Environment = Environment$1;
|
|
2026
|
+
const LiveSystem = LiveSystem$1;
|
|
2027
|
+
|
|
2028
|
+
//#endregion
|
|
2029
|
+
export { BoundedContext, Environment, Fractal, InfrastructureDomain, KebabCaseString, LiveSystem, OwnerId, OwnerType, PascalCaseString, ServiceAccountCredentials, ServiceAccountId, ServiceDeliveryModel, Version };
|