@fsai-flow/workflow 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc.json +33 -0
- package/README.md +11 -0
- package/dist/README.md +11 -0
- package/dist/package.json +42 -0
- package/dist/src/index.d.ts +21 -0
- package/dist/src/index.js +33 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/lib/Constants.d.ts +68 -0
- package/dist/src/lib/Constants.js +106 -0
- package/dist/src/lib/Constants.js.map +1 -0
- package/dist/src/lib/DeferredPromise.d.ts +6 -0
- package/dist/src/lib/DeferredPromise.js +11 -0
- package/dist/src/lib/DeferredPromise.js.map +1 -0
- package/dist/src/lib/Expression.d.ts +65 -0
- package/dist/src/lib/Expression.js +215 -0
- package/dist/src/lib/Expression.js.map +1 -0
- package/dist/src/lib/Interfaces.d.ts +1569 -0
- package/dist/src/lib/Interfaces.js +44 -0
- package/dist/src/lib/Interfaces.js.map +1 -0
- package/dist/src/lib/LoggerProxy.d.ts +9 -0
- package/dist/src/lib/LoggerProxy.js +40 -0
- package/dist/src/lib/LoggerProxy.js.map +1 -0
- package/dist/src/lib/MetadataUtils.d.ts +4 -0
- package/dist/src/lib/MetadataUtils.js +27 -0
- package/dist/src/lib/MetadataUtils.js.map +1 -0
- package/dist/src/lib/NodeErrors.d.ts +82 -0
- package/dist/src/lib/NodeErrors.js +289 -0
- package/dist/src/lib/NodeErrors.js.map +1 -0
- package/dist/src/lib/NodeHelpers.d.ts +198 -0
- package/dist/src/lib/NodeHelpers.js +1348 -0
- package/dist/src/lib/NodeHelpers.js.map +1 -0
- package/dist/src/lib/ObservableObject.d.ts +5 -0
- package/dist/src/lib/ObservableObject.js +61 -0
- package/dist/src/lib/ObservableObject.js.map +1 -0
- package/dist/src/lib/RoutingNode.d.ts +18 -0
- package/dist/src/lib/RoutingNode.js +508 -0
- package/dist/src/lib/RoutingNode.js.map +1 -0
- package/dist/src/lib/TelemetryHelpers.d.ts +3 -0
- package/dist/src/lib/TelemetryHelpers.js +69 -0
- package/dist/src/lib/TelemetryHelpers.js.map +1 -0
- package/dist/src/lib/TypeValidation.d.ts +21 -0
- package/dist/src/lib/TypeValidation.js +385 -0
- package/dist/src/lib/TypeValidation.js.map +1 -0
- package/dist/src/lib/VersionedNodeType.d.ts +9 -0
- package/dist/src/lib/VersionedNodeType.js +26 -0
- package/dist/src/lib/VersionedNodeType.js.map +1 -0
- package/dist/src/lib/Workflow.d.ts +248 -0
- package/dist/src/lib/Workflow.js +901 -0
- package/dist/src/lib/Workflow.js.map +1 -0
- package/dist/src/lib/WorkflowDataProxy.d.ts +87 -0
- package/dist/src/lib/WorkflowDataProxy.js +556 -0
- package/dist/src/lib/WorkflowDataProxy.js.map +1 -0
- package/dist/src/lib/WorkflowErrors.d.ts +9 -0
- package/dist/src/lib/WorkflowErrors.js +18 -0
- package/dist/src/lib/WorkflowErrors.js.map +1 -0
- package/dist/src/lib/WorkflowHooks.d.ts +11 -0
- package/dist/src/lib/WorkflowHooks.js +34 -0
- package/dist/src/lib/WorkflowHooks.js.map +1 -0
- package/dist/src/lib/errors/base/base.error.d.ts +30 -0
- package/dist/src/lib/errors/base/base.error.js +45 -0
- package/dist/src/lib/errors/base/base.error.js.map +1 -0
- package/dist/src/lib/errors/base/operational.error.d.ts +15 -0
- package/dist/src/lib/errors/base/operational.error.js +19 -0
- package/dist/src/lib/errors/base/operational.error.js.map +1 -0
- package/dist/src/lib/errors/error.types.d.ts +11 -0
- package/dist/src/lib/errors/error.types.js +3 -0
- package/dist/src/lib/errors/error.types.js.map +1 -0
- package/dist/src/lib/errors/index.d.ts +1 -0
- package/dist/src/lib/errors/index.js +6 -0
- package/dist/src/lib/errors/index.js.map +1 -0
- package/dist/src/lib/result.d.ts +19 -0
- package/dist/src/lib/result.js +36 -0
- package/dist/src/lib/result.js.map +1 -0
- package/dist/src/lib/utils.d.ts +50 -0
- package/dist/src/lib/utils.js +110 -0
- package/dist/src/lib/utils.js.map +1 -0
- package/eslint.config.js +19 -0
- package/jest.config.ts +10 -0
- package/package.json +40 -0
- package/project.json +19 -0
- package/src/index.ts +33 -0
- package/src/lib/Constants.ts +124 -0
- package/src/lib/DeferredPromise.ts +14 -0
- package/src/lib/Expression.ts +375 -0
- package/src/lib/Interfaces.ts +2229 -0
- package/src/lib/LoggerProxy.ts +43 -0
- package/src/lib/MetadataUtils.ts +34 -0
- package/src/lib/NodeErrors.ts +332 -0
- package/src/lib/NodeHelpers.ts +1666 -0
- package/src/lib/ObservableObject.ts +77 -0
- package/src/lib/RoutingNode.ts +862 -0
- package/src/lib/TelemetryHelpers.ts +86 -0
- package/src/lib/TypeValidation.ts +431 -0
- package/src/lib/VersionedNodeType.ts +30 -0
- package/src/lib/Workflow.ts +1266 -0
- package/src/lib/WorkflowDataProxy.ts +708 -0
- package/src/lib/WorkflowErrors.ts +18 -0
- package/src/lib/WorkflowHooks.ts +51 -0
- package/src/lib/errors/base/base.error.ts +68 -0
- package/src/lib/errors/base/operational.error.ts +21 -0
- package/src/lib/errors/error.types.ts +14 -0
- package/src/lib/errors/index.ts +1 -0
- package/src/lib/result.ts +34 -0
- package/src/lib/utils.ts +132 -0
- package/tests/Helpers.ts +667 -0
- package/tests/NodeHelpers.test.ts +3053 -0
- package/tests/ObservableObject.test.ts +171 -0
- package/tests/RoutingNode.test.ts +1680 -0
- package/tests/Workflow.test.ts +1284 -0
- package/tests/WorkflowDataProxy.test.ts +199 -0
- package/tsconfig.json +27 -0
- package/tsconfig.lib.json +11 -0
- package/tsconfig.spec.json +14 -0
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-unsafe-return */
|
|
2
|
+
/* eslint-disable @typescript-eslint/no-shadow */
|
|
3
|
+
/* eslint-disable no-param-reassign */
|
|
4
|
+
/* eslint-disable no-underscore-dangle */
|
|
5
|
+
// eslint-disable-next-line import/no-cycle
|
|
6
|
+
import { IDataObject, IObservableObject } from '..';
|
|
7
|
+
|
|
8
|
+
export interface IObservableOptions {
|
|
9
|
+
ignoreEmptyOnFirstChild?: boolean;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export function create(
|
|
13
|
+
target: IDataObject,
|
|
14
|
+
parent?: IObservableObject,
|
|
15
|
+
option?: IObservableOptions,
|
|
16
|
+
depth?: number,
|
|
17
|
+
): IDataObject {
|
|
18
|
+
// eslint-disable-next-line no-param-reassign, @typescript-eslint/prefer-nullish-coalescing
|
|
19
|
+
depth = depth || 0;
|
|
20
|
+
|
|
21
|
+
// Make all the children of target also observeable
|
|
22
|
+
// eslint-disable-next-line no-restricted-syntax
|
|
23
|
+
for (const key in target) {
|
|
24
|
+
if (typeof target[key] === 'object' && target[key] !== null) {
|
|
25
|
+
// eslint-disable-next-line no-param-reassign
|
|
26
|
+
target[key] = create(
|
|
27
|
+
target[key] as IDataObject,
|
|
28
|
+
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
|
|
29
|
+
(parent || target) as IObservableObject,
|
|
30
|
+
option,
|
|
31
|
+
depth + 1,
|
|
32
|
+
);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
Object.defineProperty(target, '__dataChanged', {
|
|
37
|
+
value: false,
|
|
38
|
+
writable: true,
|
|
39
|
+
});
|
|
40
|
+
return new Proxy(target, {
|
|
41
|
+
// eslint-disable-next-line @typescript-eslint/no-shadow
|
|
42
|
+
deleteProperty(target, name) {
|
|
43
|
+
if (parent === undefined) {
|
|
44
|
+
// If no parent is given mark current data as changed
|
|
45
|
+
(target as IObservableObject).__dataChanged = true;
|
|
46
|
+
} else {
|
|
47
|
+
// If parent is given mark the parent data as changed
|
|
48
|
+
parent.__dataChanged = true;
|
|
49
|
+
}
|
|
50
|
+
return Reflect.deleteProperty(target, name);
|
|
51
|
+
},
|
|
52
|
+
get(target, name, receiver) {
|
|
53
|
+
return Reflect.get(target, name, receiver);
|
|
54
|
+
},
|
|
55
|
+
set(target, name, value) {
|
|
56
|
+
if (parent === undefined) {
|
|
57
|
+
// If no parent is given mark current data as changed
|
|
58
|
+
if (
|
|
59
|
+
option !== undefined &&
|
|
60
|
+
option.ignoreEmptyOnFirstChild === true &&
|
|
61
|
+
depth === 0 &&
|
|
62
|
+
target[name.toString()] === undefined &&
|
|
63
|
+
typeof value === 'object' &&
|
|
64
|
+
Object.keys(value).length === 0
|
|
65
|
+
// eslint-disable-next-line no-empty
|
|
66
|
+
) {
|
|
67
|
+
} else {
|
|
68
|
+
(target as IObservableObject).__dataChanged = true;
|
|
69
|
+
}
|
|
70
|
+
} else {
|
|
71
|
+
// If parent is given mark the parent data as changed
|
|
72
|
+
parent.__dataChanged = true;
|
|
73
|
+
}
|
|
74
|
+
return Reflect.set(target, name, value);
|
|
75
|
+
},
|
|
76
|
+
});
|
|
77
|
+
}
|