@dcupl/common 1.9.0 → 1.9.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.
@@ -0,0 +1,25 @@
1
+ import { ModelDefinition } from '../../model.types';
2
+ import { Workflow } from '../workflow.types';
3
+ export declare namespace _WorkflowStepDataMapping {
4
+ type WorkflowDataMappingType = 'manual' | 'model';
5
+ type WorkflowStepDataMappingAttributeMap = {
6
+ origin: string;
7
+ target: string;
8
+ };
9
+ type StepOptions = {
10
+ mappings?: WorkflowStepDataMappingAttributeMap[];
11
+ model?: ModelDefinition;
12
+ input: {
13
+ data?: any;
14
+ };
15
+ output: {
16
+ contextVariable: string;
17
+ };
18
+ };
19
+ type Step = Workflow.WorkflowStepBase & {
20
+ type: 'data-mapping';
21
+ options: StepOptions;
22
+ };
23
+ type StepResultValue = any[];
24
+ type StepResult = Workflow.StepResultValueBase<StepResultValue>;
25
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=data-mapping.types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"data-mapping.types.js","sourceRoot":"","sources":["../../../../../src/types/workflow/steps/data-mapping.types.ts"],"names":[],"mappings":""}
@@ -39,9 +39,14 @@ export declare namespace _WorkflowStepDcuplFiles {
39
39
  type: 'dcupl-files';
40
40
  options: StepOptions;
41
41
  };
42
- type StepVariableResult = {
42
+ type StepFileResult = {
43
43
  ok: boolean;
44
44
  status: number;
45
45
  data: any;
46
46
  };
47
+ type StepResultValue = {
48
+ ok: boolean;
49
+ files: StepFileResult[];
50
+ };
51
+ type StepResult = Workflow.StepResultValueBase<StepResultValue>;
47
52
  }
@@ -49,9 +49,14 @@ export declare namespace _WorkflowStepGitFiles {
49
49
  type: 'git-files';
50
50
  options: StepOptions;
51
51
  };
52
- type StepVariableResult = {
52
+ type StepFileResult = {
53
53
  ok: boolean;
54
54
  status: number;
55
55
  data: any;
56
56
  };
57
+ type StepResultValue = {
58
+ ok: boolean;
59
+ files: StepFileResult[];
60
+ };
61
+ type StepResult = Workflow.StepResultValueBase<StepResultValue>;
57
62
  }
@@ -0,0 +1,23 @@
1
+ import { AppLoaderConfiguration } from '../../app-loader.types';
2
+ import { DataContainer } from '../../data.types';
3
+ import { DcuplInitOptions } from '../../dcupl.types';
4
+ import { ModelDefinition } from '../../model.types';
5
+ import { Workflow } from '../workflow.types';
6
+ export declare namespace _WorkflowStepInstance {
7
+ type WorkflowDataContainer = Omit<DataContainer, 'data'> & {
8
+ data: any;
9
+ };
10
+ type StepOptions = {
11
+ processOptions?: AppLoaderConfiguration.ProcessOptions;
12
+ initOptions?: DcuplInitOptions;
13
+ loaderFetchOptions?: AppLoaderConfiguration.FetchOptions;
14
+ dataContainers?: WorkflowDataContainer[];
15
+ models?: ModelDefinition[] | string[];
16
+ script: string;
17
+ };
18
+ type Step = Workflow.WorkflowStepBase & {
19
+ type: 'dcupl-instance';
20
+ options: StepOptions;
21
+ };
22
+ type StepResult = Workflow.StepResultContextBase;
23
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=instance.types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"instance.types.js","sourceRoot":"","sources":["../../../../../src/types/workflow/steps/instance.types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,21 @@
1
+ import { Workflow } from '../workflow.types';
2
+ export declare namespace _WorkflowStepRequest {
3
+ type RequestMethod = 'GET' | 'POST' | 'PUT' | 'DELETE';
4
+ type StepOptions = {
5
+ url: string;
6
+ method: RequestMethod;
7
+ headers?: Record<string, string>;
8
+ body?: any;
9
+ contextVariable?: string;
10
+ };
11
+ type Step = Workflow.WorkflowStepBase & {
12
+ type: 'request';
13
+ options: StepOptions;
14
+ };
15
+ type StepResultValue = {
16
+ ok: boolean;
17
+ status: number;
18
+ data: any;
19
+ };
20
+ type StepResult = Workflow.StepResultValueBase<StepResultValue>;
21
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=request.types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"request.types.js","sourceRoot":"","sources":["../../../../../src/types/workflow/steps/request.types.ts"],"names":[],"mappings":""}
@@ -41,9 +41,14 @@ export declare namespace _WorkflowStepS3Files {
41
41
  type: 's3-files';
42
42
  options: StepOptions;
43
43
  };
44
- type StepVariableResult = {
44
+ type StepFileResult = {
45
45
  ok: boolean;
46
46
  status: number;
47
47
  data: any;
48
48
  };
49
+ type StepResultValue = {
50
+ ok: boolean;
51
+ files: StepFileResult[];
52
+ };
53
+ type StepResult = Workflow.StepResultValueBase<StepResultValue>;
49
54
  }
@@ -0,0 +1,11 @@
1
+ import { Workflow } from '../workflow.types';
2
+ export declare namespace _WorkflowStepScript {
3
+ type StepOptions = {
4
+ script: string;
5
+ };
6
+ type Step = Workflow.WorkflowStepBase & {
7
+ type: 'script';
8
+ options: StepOptions;
9
+ };
10
+ type StepResult = Workflow.StepResultContextBase;
11
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=script.types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"script.types.js","sourceRoot":"","sources":["../../../../../src/types/workflow/steps/script.types.ts"],"names":[],"mappings":""}
@@ -1,10 +1,10 @@
1
- import { DataContainer } from '../data.types';
2
- import { ModelDefinition } from '../model.types';
3
- import { AppLoaderConfiguration } from '../app-loader.types';
4
- import { ListItem } from '../data.types';
5
1
  import { _WorkflowStepDcuplFiles } from './steps/dcupl-files.types';
6
2
  import { _WorkflowStepS3Files } from './steps/s3-files.types';
7
3
  import { _WorkflowStepGitFiles } from './steps/git-files.types';
4
+ import { _WorkflowStepScript } from './steps/script.types';
5
+ import { _WorkflowStepRequest } from './steps/request.types';
6
+ import { _WorkflowStepInstance } from './steps/instance.types';
7
+ import { _WorkflowStepDataMapping } from './steps/data-mapping.types';
8
8
  export declare namespace Workflow {
9
9
  type Template = {
10
10
  key: string;
@@ -27,11 +27,13 @@ export declare namespace Workflow {
27
27
  type WorkflowResponseType = 'script' | 'status' | 'debug';
28
28
  type WorkflowResponseConfigBase = {
29
29
  type: WorkflowResponseType;
30
- headers?: Record<string, string>;
31
30
  };
32
31
  type WorkflowResponseScript = WorkflowResponseConfigBase & {
33
32
  type: 'script';
34
- script: string;
33
+ options: {
34
+ script: string;
35
+ headers?: Record<string, string>;
36
+ };
35
37
  };
36
38
  type WorkflowResponseStatus = WorkflowResponseConfigBase & {
37
39
  type: 'status';
@@ -91,214 +93,24 @@ export declare namespace Workflow {
91
93
  * Step
92
94
  *
93
95
  */
94
- type WorflowStepType = 'request' | 'script' | 'git-push' | 'git-pull' | 'git-files' | 'dcupl-files' | 'files-read' | 'files-write' | 's3-files' | 's3-read' | 's3-write' | 'data-mapping' | 'dcupl-instance';
96
+ type WorflowStepType = 'request' | 'script' | 'git-files' | 'dcupl-files' | 's3-files' | 'data-mapping' | 'dcupl-instance';
95
97
  type WorkflowStepBase = {
96
98
  key: string;
97
99
  name?: string;
98
100
  description?: string;
99
101
  skip?: boolean;
100
102
  };
101
- /**
102
- * Request
103
- */
104
- type WorkflowRequestMethod = 'GET' | 'POST' | 'PUT' | 'DELETE';
105
- type WorkflowStepRequestOptions = {
106
- url: string;
107
- method: WorkflowRequestMethod;
108
- body?: any;
109
- headers?: Record<string, string>;
110
- };
111
- type WorkflowStepRequest = WorkflowStepBase & {
112
- type: 'request';
113
- options: WorkflowStepRequestOptions;
114
- scripts?: {
115
- error?: string;
116
- success?: string;
117
- };
118
- };
119
- /**
120
- * Script
121
- */
122
- type WorkflowStepScript = WorkflowStepBase & {
123
- type: 'script';
124
- script: string;
125
- };
126
103
  /**
127
104
  * Dcupl Instance
128
105
  */
129
- type WorkflowStepDcuplInstanceDataContainer = Omit<DataContainer, 'data'> & {
130
- data: string | ListItem[];
131
- };
132
- type WorkflowStepDcuplInstance = WorkflowStepBase & {
133
- type: 'dcupl-instance';
134
- apiKey: string;
135
- processOptions: AppLoaderConfiguration.ProcessOptions;
136
- fetchOptions?: AppLoaderConfiguration.FetchOptions;
137
- dataContainers?: WorkflowStepDcuplInstanceDataContainer[];
138
- models?: ModelDefinition[];
139
- loaderConfig?: AppLoaderConfiguration.ProjectConfiguration;
140
- scriptName?: string;
141
- script?: string;
142
- };
143
- /**
144
- * Git Push
145
- */
146
- type WorkflowGitPushStepFile = {
147
- path: string;
148
- content: string;
149
- message?: string;
150
- };
151
- type WorkflowGitPushStepOptions = {
152
- auth: {
153
- user: string;
154
- token: string;
155
- };
156
- repository: {
157
- user: string;
158
- repo: string;
159
- /**
160
- * default: main
161
- */
162
- branch?: string;
163
- };
164
- message?: string;
165
- files: WorkflowGitPushStepFile[];
166
- };
167
- type WorkflowStepGitPush = WorkflowStepBase & {
168
- type: 'git-push';
169
- options: WorkflowGitPushStepOptions;
170
- };
171
- /**
172
- * Git Pull
173
- */
174
- type WorkflowGitPullStepFile = {
175
- key: string;
176
- path: string;
177
- };
178
- type WorkflowGitPullStepOptions = {
179
- auth: {
180
- user: string;
181
- token: string;
182
- };
183
- repository: {
184
- user: string;
185
- repo: string;
186
- /**
187
- * default: main
188
- */
189
- branch?: string;
190
- };
191
- files: WorkflowGitPullStepFile[];
192
- };
193
- type WorkflowStepGitPull = WorkflowStepBase & {
194
- type: 'git-pull';
195
- options: WorkflowGitPullStepOptions;
196
- };
197
- /**
198
- * CDN Files Step
199
- */
200
- /**
201
- * Files Write
202
- */
203
- type WorkflowFilesWriteFile = {
204
- path: string;
205
- content: string;
206
- };
207
- type WorkflowFilesWriteStepOptions = {
208
- apiKey: string;
209
- version: string;
210
- files: WorkflowFilesWriteFile[];
211
- };
212
- type WorkflowStepFilesWrite = WorkflowStepBase & {
213
- type: 'files-write';
214
- options: WorkflowFilesWriteStepOptions;
215
- };
216
- /**
217
- * Files Read
218
- */
219
- type WorkflowFilesReadFile = {
220
- key: string;
221
- path: string;
222
- };
223
- type WorkflowFilesReadStepOptions = {
224
- apiKey: string;
225
- version: string;
226
- files: WorkflowFilesReadFile[];
227
- };
228
- type WorkflowStepFilesRead = WorkflowStepBase & {
229
- type: 'files-read';
230
- options: WorkflowFilesReadStepOptions;
231
- };
232
- /**
233
- * S3 Read
234
- */
235
- type WorkflowS3ReadFile = {
236
- key: string;
237
- path: string;
238
- };
239
- type WorkflowS3StepAuth = {
240
- accessKeyId: string;
241
- secretAccessKey: string;
242
- region: string;
243
- };
244
- type WorkflowS3ReadStepOptions = {
245
- auth: WorkflowS3StepAuth;
246
- bucket: string;
247
- files: WorkflowS3ReadFile[];
248
- };
249
- type WorkflowStepS3Read = WorkflowStepBase & {
250
- type: 's3-read';
251
- options: WorkflowS3ReadStepOptions;
252
- };
253
- /**
254
- * S3 Write
255
- */
256
- type WorkflowS3WriteFile = {
257
- path: string;
258
- content: string;
259
- };
260
- type WorkflowS3WriteStepOptions = {
261
- auth: WorkflowS3StepAuth;
262
- bucket: string;
263
- files: WorkflowS3WriteFile[];
264
- };
265
- type WorkflowStepS3Write = WorkflowStepBase & {
266
- type: 's3-write';
267
- options: WorkflowS3WriteStepOptions;
268
- };
269
- /**
270
- * Data Mapping Step
271
- */
272
- type WorkflowDataMappingType = 'manual' | 'model';
273
- type WorkflowStepDataMappingAttributeMap = {
274
- origin: string;
275
- target: string;
276
- };
277
- type WorkflowStepDataMappingOptionBase = {
278
- input: {
279
- data: any[];
280
- };
281
- output: {
282
- variable: string;
283
- };
284
- };
285
- type WorkflowStepDataMappingManual = WorkflowStepDataMappingOptionBase & {
286
- type: 'manual';
287
- mappings: WorkflowStepDataMappingAttributeMap[];
288
- };
289
- type WorkflowStepDataMappingModel = WorkflowStepDataMappingOptionBase & {
290
- type: 'model';
291
- model: ModelDefinition;
292
- };
293
- type WorkflowStepDataMappingOptions = WorkflowStepDataMappingModel | WorkflowStepDataMappingManual;
294
- type WorkflowStepDataMapping = WorkflowStepBase & {
295
- type: 'data-mapping';
296
- options: WorkflowStepDataMappingOptions;
297
- };
298
106
  export import StepDcuplFiles = _WorkflowStepDcuplFiles;
299
107
  export import StepS3Files = _WorkflowStepS3Files;
300
108
  export import StepGitFiles = _WorkflowStepGitFiles;
301
- type WorkflowStep = StepDcuplFiles.Step | StepS3Files.Step | StepGitFiles.Step | WorkflowStepRequest | WorkflowStepScript | WorkflowStepGitPush | WorkflowStepGitPull | WorkflowStepDcuplInstance | WorkflowStepFilesWrite | WorkflowStepFilesRead | WorkflowStepS3Read | WorkflowStepDataMapping | WorkflowStepS3Write;
109
+ export import StepScript = _WorkflowStepScript;
110
+ export import StepRequest = _WorkflowStepRequest;
111
+ export import StepInstance = _WorkflowStepInstance;
112
+ export import StepDataMapping = _WorkflowStepDataMapping;
113
+ type WorkflowStep = StepDcuplFiles.Step | StepS3Files.Step | StepGitFiles.Step | StepScript.Step | StepRequest.Step | StepInstance.Step | StepDataMapping.Step;
302
114
  /**
303
115
  * Server Config
304
116
  */
@@ -321,13 +133,28 @@ export declare namespace Workflow {
321
133
  scriptWorkers: number;
322
134
  workflowWorkers: number;
323
135
  };
136
+ type StepResultType = 'value' | 'context';
137
+ type StepResultBase = {
138
+ error?: string;
139
+ };
140
+ type StepResultValueBase<T = any> = StepResultBase & {
141
+ type: 'value';
142
+ value?: T;
143
+ };
144
+ type StepResultContextBase = StepResultBase & {
145
+ type: 'context';
146
+ context?: RunContext;
147
+ };
148
+ type StepResult = StepResultValueBase | StepResultContextBase;
324
149
  type WorkflowStepResultStatus = 'processing' | 'success' | 'error';
325
- type WorkflowStepResult = {
150
+ type WorkflowStepResult<Result = any> = {
326
151
  key: string;
327
152
  status: WorkflowStepResultStatus;
328
- result: any;
153
+ result?: Result;
154
+ error: any;
329
155
  start: number;
330
156
  end: number;
157
+ duration: number;
331
158
  };
332
159
  type WorkflowContext = {
333
160
  runContext: RunContext;
@@ -341,7 +168,9 @@ export declare namespace Workflow {
341
168
  headers: any;
342
169
  };
343
170
  type RunContext = {
344
- runId: string;
171
+ run: {
172
+ id: string;
173
+ };
345
174
  workflow: Workflow.Workflow;
346
175
  request: SimpleRequestObject;
347
176
  variables: Record<string, any>;
@@ -1 +1 @@
1
- {"version":3,"file":"workflow.types.js","sourceRoot":"","sources":["../../../../src/types/workflow/workflow.types.ts"],"names":[],"mappings":"AAQA,MAAM,KAAW,QAAQ,CA+jBxB;AA/jBD,WAAiB,QAAQ;AA+jBzB,CAAC,EA/jBgB,QAAQ,KAAR,QAAQ,QA+jBxB"}
1
+ {"version":3,"file":"workflow.types.js","sourceRoot":"","sources":["../../../../src/types/workflow/workflow.types.ts"],"names":[],"mappings":"AAQA,MAAM,KAAW,QAAQ,CA8VxB;AA9VD,WAAiB,QAAQ;AA8VzB,CAAC,EA9VgB,QAAQ,KAAR,QAAQ,QA8VxB"}