@dcupl/common 1.4.1 → 1.4.3

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,203 @@
1
+ import { DataContainerType } from '@dcupl/common';
2
+ export declare namespace AppLoaderConfiguration {
3
+ /**
4
+ * The base structure for configuration file contains all resources, evnironments and headers
5
+ * The process options define how this file is processed
6
+ *
7
+ * @defaultSnippets { "label": "Default Loader Configuration", "properties": ["applications:json:[{\"key\":\"default\", \"name\":\"My Application\"}]", "resources:json:[{\"url\":\"${baseUrl}/models/my-model.dcupl.json\", \"type\":\"model\"},{\"url\":\"${baseUrl}/data/some-data.json\", \"type\":\"data\", \"model\":\"MyModel\"}]"] }
8
+ */
9
+ export type ProjectConfiguration = {
10
+ resources: Resource[];
11
+ environments?: Environment[];
12
+ applications?: ApplicationConfiguration[];
13
+ options?: Options;
14
+ };
15
+ /**
16
+ * @defaultSnippets { "label": "Application", "properties": ["key", "name", "description", "resourceTags:array"] }
17
+ */
18
+ export type ApplicationConfiguration = {
19
+ key: string;
20
+ name?: string;
21
+ description?: string;
22
+ resourceTags?: string[];
23
+ variables?: Variable[];
24
+ };
25
+ export type ProcessOptions = {
26
+ applicationKey?: string;
27
+ environmentKeys?: string[];
28
+ resourceTags?: string[];
29
+ variables?: Variable[];
30
+ options?: Options;
31
+ };
32
+ export type FetchOptions = {
33
+ baseUrl?: string;
34
+ loaderFileName?: string;
35
+ headers?: AppLoaderConfiguration.AppLoaderConfigHeader[];
36
+ skipApply?: boolean;
37
+ };
38
+ export type Options = {
39
+ defaultDataContainerUpdateType?: DataContainerType;
40
+ csvParserOptions?: CsvParserOptions;
41
+ missingModelHandling?: {
42
+ autoGenerateProperties?: boolean;
43
+ };
44
+ };
45
+ export type CsvParserOptions = {
46
+ delimiter?: string;
47
+ quoteChar?: string;
48
+ escapeChar?: string;
49
+ };
50
+ export type TransformerType = 'rawFileTransformer' | 'parsedFileTransformer';
51
+ /**
52
+ * @defaultSnippets { "label": "Environment", "properties": ["key", "description", "variables:array", "headers:array", "queryParams:array"] }
53
+ */
54
+ export type Environment = {
55
+ key: string;
56
+ description?: string;
57
+ variables?: Variable[];
58
+ headers?: HttpHeaderConfiguration[];
59
+ queryParams?: HttpQueryParamConfiguration[];
60
+ };
61
+ /**
62
+ * @defaultSnippets { "label": "Variable", "properties": ["key", "description", "value:string"] }
63
+ */
64
+ export type Variable<T = string> = {
65
+ key: T;
66
+ description?: string;
67
+ value: string | undefined;
68
+ };
69
+ export type EnvironmentVariableAsObject = Record<string, any>;
70
+ /**
71
+ * @defaultSnippets { "label": "Query Parameter Configuration", "properties": ["key", "description", "value:string", "tags:array"] }
72
+ */
73
+ export type HttpQueryParamConfiguration = {
74
+ key: string;
75
+ description?: string;
76
+ value: string;
77
+ tags?: string[];
78
+ condition?: {
79
+ applyIfVariableHasValue?: string;
80
+ };
81
+ };
82
+ /**
83
+ * @defaultSnippets { "label": "Header Configuration", "properties": ["key", "description", "value:string", "tags:array"] }
84
+ */
85
+ export type HttpHeaderConfiguration = {
86
+ key: string;
87
+ description?: string;
88
+ value: string;
89
+ tags?: string[];
90
+ condition?: {
91
+ applyIfVariableHasValue?: string;
92
+ };
93
+ };
94
+ export type HttpHeaderAsObject = {
95
+ [key: string]: string;
96
+ };
97
+ type ResourceType = 'model' | 'data' | 'transformer' | 'operator' | 'script';
98
+ type ResourceBase = {
99
+ key?: string;
100
+ url: string;
101
+ type: ResourceType;
102
+ tags?: string[];
103
+ };
104
+ /**
105
+ * A model describes a real world object of your applicatoin like a customer, a product or a sales order.
106
+ *
107
+ * @defaultSnippets { "label": "Model", "properties": ["url:string:${baseUrl}/models/my-model.dcupl.json", "type:model", "tags:array"] }
108
+ */
109
+ export type ModelResource = ResourceBase & {
110
+ type: 'model';
111
+ };
112
+ /**
113
+ * A data resource contains data for a model.
114
+ *
115
+ * @defaultSnippets { "label": "Data", "properties": ["url:string:${baseUrl}/data/my-data.json", "type:data", "model", "tags:array"] }
116
+ */
117
+ export type DataResource = ResourceBase & {
118
+ type: 'data';
119
+ model: string;
120
+ options?: DataResourceOptions;
121
+ };
122
+ /**
123
+ * A transformer resource points to a javascript file that can be used to transform the data of a data resource.
124
+ *
125
+ * @defaultSnippets { "label": "Transformer", "properties": ["url:string:${baseUrl}/transformers/my-transformer.js", "type:transformer", "applyTo:array", "tags:array"] }
126
+ */
127
+ export type TransformerResource = ResourceBase & {
128
+ type: 'transformer';
129
+ /**
130
+ * The tags the transformer applies to
131
+ */
132
+ applyTo?: string[];
133
+ /**
134
+ * The transformer type
135
+ * rawFileTransformer: The transformer is applied to the raw file
136
+ * parsedFileTransformer: The transformer is applied to the parsed file
137
+ * default: rawFileTransformer
138
+ */
139
+ transformerType?: TransformerType;
140
+ };
141
+ /**
142
+ * A script resource.
143
+ *
144
+ * @defaultSnippets { "label": "Query Operator", "properties": ["url:string:${baseUrl}/models/my-operator.js", "type:operator", "operator:my_operator", "tags:array"] }
145
+ */
146
+ export type CustomScriptResource = ResourceBase & {
147
+ type: 'script';
148
+ /**
149
+ * The operator name that can be used in a query
150
+ */
151
+ scriptKey: string;
152
+ };
153
+ /**
154
+ * A query operator resource points to a javascript file that defines a custom query operator.
155
+ *
156
+ * @defaultSnippets { "label": "Query Operator", "properties": ["url:string:${baseUrl}/models/my-operator.js", "type:operator", "operator:my_operator", "tags:array"] }
157
+ */
158
+ export type CustomOperatorResource = ResourceBase & {
159
+ type: 'operator';
160
+ /**
161
+ * The operator name that can be used in a query
162
+ */
163
+ operator: string;
164
+ };
165
+ export type DataResourceOptions = {
166
+ updateType?: DataContainerType;
167
+ autoGenerateProperties?: boolean;
168
+ autoGenerateKey?: boolean;
169
+ keyProperty?: string;
170
+ csvParserOptions?: CsvParserOptions;
171
+ };
172
+ export type Resource = ModelResource | DataResource | TransformerResource | CustomOperatorResource | CustomScriptResource;
173
+ export type AppLoaderConfigHeader = {
174
+ key: string;
175
+ value: string;
176
+ };
177
+ export {};
178
+ }
179
+ export type FilesApiStatusResponse = {
180
+ changedAt: number;
181
+ };
182
+ /**
183
+ * The input type is depending on the resource type (csv/json) and if it's a raw or parsed transformer
184
+ * Shuld return the transformed data
185
+ */
186
+ export type AppLoaderTransformerFunction = (item: AppLoaderConfiguration.Resource, input: any) => any;
187
+ export declare namespace AppLoaderProgress {
188
+ type ResourceItem = AppLoaderConfiguration.Resource;
189
+ type ProgressItem = {
190
+ total: number;
191
+ processed: number;
192
+ remaining: number;
193
+ progress: number;
194
+ context: string;
195
+ currentItem: ResourceItem;
196
+ totalItems: ResourceItem[];
197
+ processedItems: ResourceItem[];
198
+ downloadedItems: ResourceItem[];
199
+ failedItems: ResourceItem[];
200
+ remainingItems: ResourceItem[];
201
+ };
202
+ type CallbackFunction = (item: ProgressItem) => void;
203
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=app-loader.types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"app-loader.types.js","sourceRoot":"","sources":["../../../src/types/app-loader.types.ts"],"names":[],"mappings":""}
@@ -1,3 +1,4 @@
1
+ export * from './app-loader.types';
1
2
  export * from './aggregation.types';
2
3
  export * from './data.types';
3
4
  export * from './dcupl.types';
@@ -12,3 +13,4 @@ export * from './query.types';
12
13
  export * from './section.types';
13
14
  export * from './suggestion.types';
14
15
  export * from './testing.types';
16
+ export * from './workflow.types';
@@ -1,3 +1,4 @@
1
+ export * from './app-loader.types';
1
2
  export * from './aggregation.types';
2
3
  export * from './data.types';
3
4
  export * from './dcupl.types';
@@ -12,4 +13,5 @@ export * from './query.types';
12
13
  export * from './section.types';
13
14
  export * from './suggestion.types';
14
15
  export * from './testing.types';
16
+ export * from './workflow.types';
15
17
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC;AACpC,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC;AACjC,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,oBAAoB,CAAC;AACnC,cAAc,eAAe,CAAC;AAC9B,cAAc,iBAAiB,CAAC;AAChC,cAAc,oBAAoB,CAAC;AACnC,cAAc,iBAAiB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC;AACjC,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,oBAAoB,CAAC;AACnC,cAAc,eAAe,CAAC;AAC9B,cAAc,iBAAiB,CAAC;AAChC,cAAc,oBAAoB,CAAC;AACnC,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC"}
@@ -0,0 +1,154 @@
1
+ import { DataContainer } from '@dcupl/common';
2
+ import { AppLoaderConfiguration } from './app-loader.types';
3
+ import { ModelDefinition } from '@dcupl/common';
4
+ export declare namespace Workflow {
5
+ type Workflow = {
6
+ key: string;
7
+ projectId: string;
8
+ config: WorkflowConfig;
9
+ apiKey?: string;
10
+ name?: string;
11
+ description?: string;
12
+ runtime?: WorkflowRuntime;
13
+ variables?: Record<string, string>;
14
+ };
15
+ type WorkflowRuntime = {
16
+ workflowTimeout: number;
17
+ scriptTimeout: number;
18
+ };
19
+ /**
20
+ *
21
+ * Response
22
+ *
23
+ */
24
+ type WorkflowResponseType = 'script' | 'status' | 'debug';
25
+ type WorkflowResponseConfigBase = {
26
+ type: WorkflowResponseType;
27
+ headers?: any;
28
+ };
29
+ type WorkflowResponseScript = WorkflowResponseConfigBase & {
30
+ type: 'script';
31
+ script: string;
32
+ };
33
+ type WorkflowResponseStatus = WorkflowResponseConfigBase & {
34
+ type: 'status';
35
+ };
36
+ type WorkflowResponseDebug = WorkflowResponseConfigBase & {
37
+ type: 'debug';
38
+ };
39
+ type WorkflowResponseConfig = WorkflowResponseScript | WorkflowResponseStatus | WorkflowResponseDebug;
40
+ type WorkflowConfig = {
41
+ trigger: Trigger[];
42
+ steps: WorkflowStep[];
43
+ catch?: WorkflowStep;
44
+ response: WorkflowResponseConfig;
45
+ };
46
+ /**
47
+ *
48
+ * Trigger
49
+ *
50
+ */
51
+ type TriggerType = 'request' | 'manual' | 'cron';
52
+ type TriggerBase = {
53
+ key: string;
54
+ type: TriggerType;
55
+ };
56
+ type TriggerRequestMethod = 'GET' | 'POST';
57
+ type TriggerRequest = TriggerBase & {
58
+ type: 'request';
59
+ path: string;
60
+ methods: TriggerRequestMethod[];
61
+ scripts?: {
62
+ success?: string;
63
+ };
64
+ };
65
+ type TriggerManual = TriggerBase & {
66
+ type: 'manual';
67
+ };
68
+ type TriggerCron = TriggerBase & {
69
+ type: 'cron';
70
+ /**
71
+ * Cron expression
72
+ * second 0-59
73
+ * minute 0-59
74
+ * hour 0-23
75
+ * day of month 1-31
76
+ * month 1-12 (or names, see below)
77
+ * day of week 0-7 (0 or 7 is Sunday, or use names)
78
+ *
79
+ * @example '0 0 1 * *' // every day at 1am
80
+ * @example \*\/5 * * * * *' -> star slash 5 means every 5 seconds
81
+ */
82
+ cronTime: string;
83
+ timezone?: string;
84
+ };
85
+ type Trigger = TriggerRequest | TriggerManual | TriggerCron;
86
+ /**
87
+ *
88
+ * Step
89
+ *
90
+ */
91
+ type WorflowStepType = 'request' | 'script' | 'git-push' | 'dcupl-instance';
92
+ type WorkflowStepBase = {
93
+ key: string;
94
+ type: WorflowStepType;
95
+ name?: string;
96
+ description?: string;
97
+ skip?: boolean;
98
+ };
99
+ type WorkflowRequestMethod = 'GET' | 'POST' | 'PUT' | 'DELETE';
100
+ type WorkflowStepRequestOptions = {
101
+ url: string;
102
+ method: WorkflowRequestMethod;
103
+ body?: any;
104
+ headers?: any;
105
+ };
106
+ type WorkflowStepRequest = WorkflowStepBase & {
107
+ type: 'request';
108
+ options: WorkflowStepRequestOptions;
109
+ scripts?: {
110
+ prepare?: string;
111
+ response?: string;
112
+ error?: string;
113
+ success?: string;
114
+ };
115
+ };
116
+ type WorkflowStepScript = WorkflowStepBase & {
117
+ type: 'script';
118
+ script: string;
119
+ };
120
+ type WorkflowStepDcuplInstanceDataContainer = DataContainer & {
121
+ data: string;
122
+ };
123
+ type WorkflowStepDcuplInstance = WorkflowStepBase & {
124
+ type: 'dcupl-instance';
125
+ processOptions: AppLoaderConfiguration.ProcessOptions;
126
+ fetchOptions?: AppLoaderConfiguration.FetchOptions;
127
+ dataContainers?: WorkflowStepDcuplInstanceDataContainer[];
128
+ models?: ModelDefinition[];
129
+ loaderConfig?: AppLoaderConfiguration.ProjectConfiguration;
130
+ scriptName?: string;
131
+ script?: string;
132
+ };
133
+ type WorkflowGitPushStepFile = {
134
+ path: string;
135
+ value: string;
136
+ commitMessage?: string;
137
+ };
138
+ type WorkflowGitPushStepOptions = {
139
+ auth: {
140
+ user: string;
141
+ token: string;
142
+ };
143
+ repository: {
144
+ user: string;
145
+ repo: string;
146
+ };
147
+ files: WorkflowGitPushStepFile[];
148
+ };
149
+ type WorkflowStepGit = WorkflowStepBase & {
150
+ type: 'git-push';
151
+ options: WorkflowGitPushStepOptions;
152
+ };
153
+ type WorkflowStep = WorkflowStepRequest | WorkflowStepScript | WorkflowStepGit | WorkflowStepDcuplInstance;
154
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=workflow.types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"workflow.types.js","sourceRoot":"","sources":["../../../src/types/workflow.types.ts"],"names":[],"mappings":""}