@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.
Files changed (113) hide show
  1. package/.eslintrc.json +33 -0
  2. package/README.md +11 -0
  3. package/dist/README.md +11 -0
  4. package/dist/package.json +42 -0
  5. package/dist/src/index.d.ts +21 -0
  6. package/dist/src/index.js +33 -0
  7. package/dist/src/index.js.map +1 -0
  8. package/dist/src/lib/Constants.d.ts +68 -0
  9. package/dist/src/lib/Constants.js +106 -0
  10. package/dist/src/lib/Constants.js.map +1 -0
  11. package/dist/src/lib/DeferredPromise.d.ts +6 -0
  12. package/dist/src/lib/DeferredPromise.js +11 -0
  13. package/dist/src/lib/DeferredPromise.js.map +1 -0
  14. package/dist/src/lib/Expression.d.ts +65 -0
  15. package/dist/src/lib/Expression.js +215 -0
  16. package/dist/src/lib/Expression.js.map +1 -0
  17. package/dist/src/lib/Interfaces.d.ts +1569 -0
  18. package/dist/src/lib/Interfaces.js +44 -0
  19. package/dist/src/lib/Interfaces.js.map +1 -0
  20. package/dist/src/lib/LoggerProxy.d.ts +9 -0
  21. package/dist/src/lib/LoggerProxy.js +40 -0
  22. package/dist/src/lib/LoggerProxy.js.map +1 -0
  23. package/dist/src/lib/MetadataUtils.d.ts +4 -0
  24. package/dist/src/lib/MetadataUtils.js +27 -0
  25. package/dist/src/lib/MetadataUtils.js.map +1 -0
  26. package/dist/src/lib/NodeErrors.d.ts +82 -0
  27. package/dist/src/lib/NodeErrors.js +289 -0
  28. package/dist/src/lib/NodeErrors.js.map +1 -0
  29. package/dist/src/lib/NodeHelpers.d.ts +198 -0
  30. package/dist/src/lib/NodeHelpers.js +1348 -0
  31. package/dist/src/lib/NodeHelpers.js.map +1 -0
  32. package/dist/src/lib/ObservableObject.d.ts +5 -0
  33. package/dist/src/lib/ObservableObject.js +61 -0
  34. package/dist/src/lib/ObservableObject.js.map +1 -0
  35. package/dist/src/lib/RoutingNode.d.ts +18 -0
  36. package/dist/src/lib/RoutingNode.js +508 -0
  37. package/dist/src/lib/RoutingNode.js.map +1 -0
  38. package/dist/src/lib/TelemetryHelpers.d.ts +3 -0
  39. package/dist/src/lib/TelemetryHelpers.js +69 -0
  40. package/dist/src/lib/TelemetryHelpers.js.map +1 -0
  41. package/dist/src/lib/TypeValidation.d.ts +21 -0
  42. package/dist/src/lib/TypeValidation.js +385 -0
  43. package/dist/src/lib/TypeValidation.js.map +1 -0
  44. package/dist/src/lib/VersionedNodeType.d.ts +9 -0
  45. package/dist/src/lib/VersionedNodeType.js +26 -0
  46. package/dist/src/lib/VersionedNodeType.js.map +1 -0
  47. package/dist/src/lib/Workflow.d.ts +248 -0
  48. package/dist/src/lib/Workflow.js +901 -0
  49. package/dist/src/lib/Workflow.js.map +1 -0
  50. package/dist/src/lib/WorkflowDataProxy.d.ts +87 -0
  51. package/dist/src/lib/WorkflowDataProxy.js +556 -0
  52. package/dist/src/lib/WorkflowDataProxy.js.map +1 -0
  53. package/dist/src/lib/WorkflowErrors.d.ts +9 -0
  54. package/dist/src/lib/WorkflowErrors.js +18 -0
  55. package/dist/src/lib/WorkflowErrors.js.map +1 -0
  56. package/dist/src/lib/WorkflowHooks.d.ts +11 -0
  57. package/dist/src/lib/WorkflowHooks.js +34 -0
  58. package/dist/src/lib/WorkflowHooks.js.map +1 -0
  59. package/dist/src/lib/errors/base/base.error.d.ts +30 -0
  60. package/dist/src/lib/errors/base/base.error.js +45 -0
  61. package/dist/src/lib/errors/base/base.error.js.map +1 -0
  62. package/dist/src/lib/errors/base/operational.error.d.ts +15 -0
  63. package/dist/src/lib/errors/base/operational.error.js +19 -0
  64. package/dist/src/lib/errors/base/operational.error.js.map +1 -0
  65. package/dist/src/lib/errors/error.types.d.ts +11 -0
  66. package/dist/src/lib/errors/error.types.js +3 -0
  67. package/dist/src/lib/errors/error.types.js.map +1 -0
  68. package/dist/src/lib/errors/index.d.ts +1 -0
  69. package/dist/src/lib/errors/index.js +6 -0
  70. package/dist/src/lib/errors/index.js.map +1 -0
  71. package/dist/src/lib/result.d.ts +19 -0
  72. package/dist/src/lib/result.js +36 -0
  73. package/dist/src/lib/result.js.map +1 -0
  74. package/dist/src/lib/utils.d.ts +50 -0
  75. package/dist/src/lib/utils.js +110 -0
  76. package/dist/src/lib/utils.js.map +1 -0
  77. package/eslint.config.js +19 -0
  78. package/jest.config.ts +10 -0
  79. package/package.json +40 -0
  80. package/project.json +19 -0
  81. package/src/index.ts +33 -0
  82. package/src/lib/Constants.ts +124 -0
  83. package/src/lib/DeferredPromise.ts +14 -0
  84. package/src/lib/Expression.ts +375 -0
  85. package/src/lib/Interfaces.ts +2229 -0
  86. package/src/lib/LoggerProxy.ts +43 -0
  87. package/src/lib/MetadataUtils.ts +34 -0
  88. package/src/lib/NodeErrors.ts +332 -0
  89. package/src/lib/NodeHelpers.ts +1666 -0
  90. package/src/lib/ObservableObject.ts +77 -0
  91. package/src/lib/RoutingNode.ts +862 -0
  92. package/src/lib/TelemetryHelpers.ts +86 -0
  93. package/src/lib/TypeValidation.ts +431 -0
  94. package/src/lib/VersionedNodeType.ts +30 -0
  95. package/src/lib/Workflow.ts +1266 -0
  96. package/src/lib/WorkflowDataProxy.ts +708 -0
  97. package/src/lib/WorkflowErrors.ts +18 -0
  98. package/src/lib/WorkflowHooks.ts +51 -0
  99. package/src/lib/errors/base/base.error.ts +68 -0
  100. package/src/lib/errors/base/operational.error.ts +21 -0
  101. package/src/lib/errors/error.types.ts +14 -0
  102. package/src/lib/errors/index.ts +1 -0
  103. package/src/lib/result.ts +34 -0
  104. package/src/lib/utils.ts +132 -0
  105. package/tests/Helpers.ts +667 -0
  106. package/tests/NodeHelpers.test.ts +3053 -0
  107. package/tests/ObservableObject.test.ts +171 -0
  108. package/tests/RoutingNode.test.ts +1680 -0
  109. package/tests/Workflow.test.ts +1284 -0
  110. package/tests/WorkflowDataProxy.test.ts +199 -0
  111. package/tsconfig.json +27 -0
  112. package/tsconfig.lib.json +11 -0
  113. package/tsconfig.spec.json +14 -0
@@ -0,0 +1,199 @@
1
+ import { Workflow, WorkflowDataProxy } from '..';
2
+ import * as Helpers from './Helpers';
3
+ import {
4
+ IConnections,
5
+ INode,
6
+ INodeExecutionData,
7
+ IRunExecutionData,
8
+ } from '../src/lib/Interfaces';
9
+
10
+ describe('WorkflowDataProxy', () => {
11
+ describe('test data proxy', () => {
12
+ const nodes: INode[] = [
13
+ {
14
+ parameters: {},
15
+ name: 'Start',
16
+ type: 'test.set',
17
+ typeVersion: 1,
18
+ position: [100, 200],
19
+ },
20
+ {
21
+ parameters: {
22
+ functionCode:
23
+ '// Code here will run only once, no matter how many input items there are.\n// More info and help: https://docs.n8n.io/nodes/n8n-nodes-base.function\nconst { DateTime, Duration, Interval } = require("luxon");\n\nconst data = [\n {\n "length": 105\n },\n {\n "length": 160\n },\n {\n "length": 121\n },\n {\n "length": 275\n },\n {\n "length": 950\n },\n];\n\nreturn data.map(fact => ({json: fact}));',
24
+ },
25
+ name: 'Function',
26
+ type: 'test.set',
27
+ typeVersion: 1,
28
+ position: [280, 200],
29
+ },
30
+ {
31
+ parameters: {
32
+ keys: {
33
+ key: [
34
+ {
35
+ currentKey: 'length',
36
+ newKey: 'data',
37
+ },
38
+ ],
39
+ },
40
+ },
41
+ name: 'Rename',
42
+ type: 'test.set',
43
+ typeVersion: 1,
44
+ position: [460, 200],
45
+ },
46
+ ];
47
+
48
+ const connections: IConnections = {
49
+ Start: {
50
+ main: [
51
+ [
52
+ {
53
+ node: 'Function',
54
+ type: 'main',
55
+ index: 0,
56
+ },
57
+ ],
58
+ ],
59
+ },
60
+ Function: {
61
+ main: [
62
+ [
63
+ {
64
+ node: 'Rename',
65
+ type: 'main',
66
+ index: 0,
67
+ },
68
+ ],
69
+ ],
70
+ },
71
+ };
72
+
73
+ const runExecutionData: IRunExecutionData = {
74
+ resultData: {
75
+ runData: {
76
+ Function: [
77
+ {
78
+ startTime: 1,
79
+ executionTime: 1,
80
+ data: {
81
+ main: [
82
+ [
83
+ {
84
+ json: { length: 105 },
85
+ },
86
+ {
87
+ json: { length: 160 },
88
+ },
89
+ {
90
+ json: { length: 121 },
91
+ },
92
+ {
93
+ json: { length: 275 },
94
+ },
95
+ {
96
+ json: { length: 950 },
97
+ },
98
+ ],
99
+ ],
100
+ },
101
+ },
102
+ ],
103
+ Rename: [
104
+ {
105
+ startTime: 1,
106
+ executionTime: 1,
107
+ data: {
108
+ main: [
109
+ [
110
+ {
111
+ json: { data: 105 },
112
+ },
113
+ {
114
+ json: { data: 160 },
115
+ },
116
+ {
117
+ json: { data: 121 },
118
+ },
119
+ {
120
+ json: { data: 275 },
121
+ },
122
+ {
123
+ json: { data: 950 },
124
+ },
125
+ ],
126
+ ],
127
+ },
128
+ },
129
+ ],
130
+ },
131
+ },
132
+ };
133
+
134
+ const renameNodeConnectionInputData: INodeExecutionData[] = [
135
+ { json: { length: 105 } },
136
+ { json: { length: 160 } },
137
+ { json: { length: 121 } },
138
+ { json: { length: 275 } },
139
+ { json: { length: 950 } }
140
+ ]
141
+
142
+ const nodeTypes = Helpers.NodeTypes();
143
+ const workflow = new Workflow({ nodes, connections, active: false, nodeTypes });
144
+
145
+ const dataProxy = new WorkflowDataProxy(
146
+ workflow,
147
+ runExecutionData,
148
+ 0,
149
+ 0,
150
+ 'Rename',
151
+ renameNodeConnectionInputData || [],
152
+ {},
153
+ 'manual',
154
+ {},
155
+ );
156
+ const proxy = dataProxy.getDataProxy();
157
+
158
+ test('test $("NodeName").all()', () => {
159
+ expect(proxy.$('Rename').all()[1].json.data).toEqual(160);
160
+ });
161
+ test('test $("NodeName").all() length', () => {
162
+ expect(proxy.$('Rename').all().length).toEqual(5);
163
+ });
164
+ test('test $("NodeName").item()', () => {
165
+ expect(proxy.$('Rename').item().json.data).toEqual(105);
166
+ });
167
+ test('test $("NodeName").item(2)', () => {
168
+ expect(proxy.$('Rename').item(2).json.data).toEqual(121);
169
+ });
170
+ test('test $("NodeName").first()', () => {
171
+ expect(proxy.$('Rename').first().json.data).toEqual(105);
172
+ });
173
+ test('test $("NodeName").last()', () => {
174
+ expect(proxy.$('Rename').last().json.data).toEqual(950);
175
+ });
176
+
177
+ test('test $input.all()', () => {
178
+ expect(proxy.$input.all()[1].json.length).toEqual(160);
179
+ });
180
+ test('test $input.all() length', () => {
181
+ expect(proxy.$input.all().length).toEqual(5);
182
+ });
183
+ test('test $input.item()', () => {
184
+ expect(proxy.$input.item().json.length).toEqual(105);
185
+ });
186
+ test('test $thisItem', () => {
187
+ expect(proxy.$thisItem.json.length).toEqual(105);
188
+ });
189
+ test('test $input.item(2)', () => {
190
+ expect(proxy.$input.item(2).json.length).toEqual(121);
191
+ });
192
+ test('test $input.first()', () => {
193
+ expect(proxy.$input.first().json.length).toEqual(105);
194
+ });
195
+ test('test $input.last()', () => {
196
+ expect(proxy.$input.last().json.length).toEqual(950);
197
+ });
198
+ });
199
+ });
package/tsconfig.json ADDED
@@ -0,0 +1,27 @@
1
+ {
2
+ "extends": "../../tsconfig.base.json",
3
+ "compilerOptions": {
4
+ "module": "commonjs",
5
+ "moduleResolution": "node",
6
+ "forceConsistentCasingInFileNames": true,
7
+ "strict": true,
8
+ "noImplicitOverride": true,
9
+ "noImplicitReturns": true,
10
+ "noFallthroughCasesInSwitch": true,
11
+ "noPropertyAccessFromIndexSignature": true,
12
+ "esModuleInterop": true,
13
+ "skipLibCheck": true,
14
+ "allowSyntheticDefaultImports": true,
15
+ "target": "ESNext",
16
+ },
17
+ "files": [],
18
+ "include": [],
19
+ "references": [
20
+ {
21
+ "path": "./tsconfig.lib.json"
22
+ },
23
+ {
24
+ "path": "./tsconfig.spec.json"
25
+ }
26
+ ]
27
+ }
@@ -0,0 +1,11 @@
1
+ {
2
+ "extends": "./tsconfig.json",
3
+ "compilerOptions": {
4
+ "outDir": "../../dist/out-tsc",
5
+ "declaration": true,
6
+ "types": ["node"],
7
+ "composite": true
8
+ },
9
+ "include": ["src/**/*.ts"],
10
+ "exclude": ["jest.config.ts", "src/**/*.spec.ts", "src/**/*.test.ts"]
11
+ }
@@ -0,0 +1,14 @@
1
+ {
2
+ "extends": "./tsconfig.json",
3
+ "compilerOptions": {
4
+ "outDir": "../../dist/out-tsc",
5
+ "module": "commonjs",
6
+ "types": ["jest", "node"]
7
+ },
8
+ "include": [
9
+ "jest.config.ts",
10
+ "src/**/*.test.ts",
11
+ "src/**/*.spec.ts",
12
+ "src/**/*.d.ts"
13
+ ]
14
+ }