@mettlecast/domain-runtime 0.2.34 → 0.2.35

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.
@@ -1,4 +1,4 @@
1
- export type FlowStepType = 'domain-action' | 'domain-api' | 'domain-event' | 'flow-control';
1
+ export type FlowStepType = 'domain-action' | 'domain-api' | 'domain-event' | 'flow-control' | 'domain-query' | 'aws-service';
2
2
  export interface DomainActionStep {
3
3
  type: 'domain-action';
4
4
  name: string;
@@ -24,6 +24,130 @@ export interface DomainEventStep {
24
24
  version: number;
25
25
  next?: string;
26
26
  }
27
+ export interface DomainQueryDynamoGetItemStep {
28
+ type: 'domain-query';
29
+ queryType: 'dynamodb-get-item';
30
+ name: string;
31
+ domainId: string;
32
+ key: {
33
+ PK: string;
34
+ SK: string;
35
+ };
36
+ resultPath?: string;
37
+ next?: string;
38
+ }
39
+ export interface DomainQueryDynamoQueryStep {
40
+ type: 'domain-query';
41
+ queryType: 'dynamodb-query';
42
+ name: string;
43
+ domainId: string;
44
+ keyConditionExpression: string;
45
+ expressionAttributeValues: Record<string, {
46
+ type: 'S' | 'N' | 'B';
47
+ value: string;
48
+ }>;
49
+ expressionAttributeNames?: Record<string, string>;
50
+ filterExpression?: string;
51
+ indexName?: string;
52
+ limit?: number;
53
+ scanIndexForward?: boolean;
54
+ resultPath?: string;
55
+ next?: string;
56
+ }
57
+ export interface DomainQueryS3GetObjectStep {
58
+ type: 'domain-query';
59
+ queryType: 's3-get-object';
60
+ name: string;
61
+ domainId: string;
62
+ key: string;
63
+ resultPath?: string;
64
+ next?: string;
65
+ }
66
+ export type DomainQueryStep = DomainQueryDynamoGetItemStep | DomainQueryDynamoQueryStep | DomainQueryS3GetObjectStep;
67
+ export interface AwsServiceSnsPublishStep {
68
+ type: 'aws-service';
69
+ serviceAction: 'sns-publish';
70
+ name: string;
71
+ topicArn: string;
72
+ message: string;
73
+ subject?: string;
74
+ messageAttributes?: Record<string, {
75
+ dataType: string;
76
+ stringValue: string;
77
+ }>;
78
+ resultPath?: string;
79
+ next?: string;
80
+ }
81
+ export interface AwsServiceGlueStartJobRunStep {
82
+ type: 'aws-service';
83
+ serviceAction: 'glue-start-job-run';
84
+ name: string;
85
+ jobName: string;
86
+ arguments?: Record<string, string>;
87
+ timeout?: number;
88
+ workerType?: 'Standard' | 'G.1X' | 'G.2X';
89
+ numberOfWorkers?: number;
90
+ resultPath?: string;
91
+ next?: string;
92
+ }
93
+ export interface AwsServiceBatchSubmitJobStep {
94
+ type: 'aws-service';
95
+ serviceAction: 'batch-submit-job';
96
+ name: string;
97
+ batchJobName: string;
98
+ jobQueue: string;
99
+ jobDefinition: string;
100
+ parameters?: Record<string, string>;
101
+ resultPath?: string;
102
+ next?: string;
103
+ }
104
+ export interface AwsServiceStepFunctionsStartExecutionStep {
105
+ type: 'aws-service';
106
+ serviceAction: 'step-functions-start-execution';
107
+ name: string;
108
+ stateMachineArn: string;
109
+ input?: Record<string, unknown>;
110
+ executionName?: string;
111
+ resultPath?: string;
112
+ next?: string;
113
+ }
114
+ export interface AwsServiceHttpsCallStep {
115
+ type: 'aws-service';
116
+ serviceAction: 'https-call';
117
+ name: string;
118
+ endpoint: string;
119
+ method: 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
120
+ headers?: Record<string, string>;
121
+ body?: unknown;
122
+ resultPath?: string;
123
+ next?: string;
124
+ }
125
+ export interface AwsServiceSqsSendMessageStep {
126
+ type: 'aws-service';
127
+ serviceAction: 'sqs-send-message';
128
+ name: string;
129
+ queueUrl: string;
130
+ messageBody: string;
131
+ delaySeconds?: number;
132
+ messageAttributes?: Record<string, {
133
+ dataType: string;
134
+ stringValue: string;
135
+ }>;
136
+ resultPath?: string;
137
+ next?: string;
138
+ }
139
+ export interface AwsServiceAthenaStartQueryStep {
140
+ type: 'aws-service';
141
+ serviceAction: 'athena-start-query';
142
+ name: string;
143
+ queryString: string;
144
+ database: string;
145
+ outputLocation: string;
146
+ workGroup?: string;
147
+ resultPath?: string;
148
+ next?: string;
149
+ }
150
+ export type AwsServiceStep = AwsServiceSnsPublishStep | AwsServiceGlueStartJobRunStep | AwsServiceBatchSubmitJobStep | AwsServiceStepFunctionsStartExecutionStep | AwsServiceHttpsCallStep | AwsServiceSqsSendMessageStep | AwsServiceAthenaStartQueryStep;
27
151
  export type FlowControlStep = {
28
152
  type: 'flow-control';
29
153
  control: 'choice';
@@ -39,6 +163,14 @@ export type FlowControlStep = {
39
163
  name: string;
40
164
  branches: FlowStep[][];
41
165
  next?: string;
166
+ } | {
167
+ type: 'flow-control';
168
+ control: 'map';
169
+ name: string;
170
+ iterator: FlowStep[];
171
+ itemsPath?: string;
172
+ maxConcurrency?: number;
173
+ next?: string;
42
174
  } | {
43
175
  type: 'flow-control';
44
176
  control: 'wait';
@@ -62,7 +194,7 @@ export type FlowControlStep = {
62
194
  result?: unknown;
63
195
  next?: string;
64
196
  };
65
- export type FlowStep = DomainActionStep | DomainApiStep | DomainEventStep | FlowControlStep;
197
+ export type FlowStep = DomainActionStep | DomainApiStep | DomainEventStep | DomainQueryStep | AwsServiceStep | FlowControlStep;
66
198
  export interface FlowTrigger {
67
199
  type: 'event';
68
200
  eventId: string;
@@ -24,6 +24,132 @@ const DomainEventStepSchema = z.object({
24
24
  version: z.number().int().positive(),
25
25
  next: z.string().optional(),
26
26
  });
27
+ const DynamoAttributeValueSchema = z.object({ type: z.enum(['S', 'N', 'B']), value: z.string() });
28
+ const DomainQueryDynamoGetItemStepSchema = z.object({
29
+ type: z.literal('domain-query'),
30
+ queryType: z.literal('dynamodb-get-item'),
31
+ name: z.string().min(1),
32
+ domainId: z.string().regex(/^[a-z][a-z0-9-]*$/),
33
+ key: z.object({ PK: z.string(), SK: z.string() }),
34
+ resultPath: z.string().optional(),
35
+ next: z.string().optional(),
36
+ });
37
+ const DomainQueryDynamoQueryStepSchema = z.object({
38
+ type: z.literal('domain-query'),
39
+ queryType: z.literal('dynamodb-query'),
40
+ name: z.string().min(1),
41
+ domainId: z.string().regex(/^[a-z][a-z0-9-]*$/),
42
+ keyConditionExpression: z.string().min(1),
43
+ expressionAttributeValues: z.record(z.string(), DynamoAttributeValueSchema),
44
+ expressionAttributeNames: z.record(z.string(), z.string()).optional(),
45
+ filterExpression: z.string().optional(),
46
+ indexName: z.string().optional(),
47
+ limit: z.number().int().positive().optional(),
48
+ scanIndexForward: z.boolean().optional(),
49
+ resultPath: z.string().optional(),
50
+ next: z.string().optional(),
51
+ });
52
+ const DomainQueryS3GetObjectStepSchema = z.object({
53
+ type: z.literal('domain-query'),
54
+ queryType: z.literal('s3-get-object'),
55
+ name: z.string().min(1),
56
+ domainId: z.string().regex(/^[a-z][a-z0-9-]*$/),
57
+ key: z.string().min(1),
58
+ resultPath: z.string().optional(),
59
+ next: z.string().optional(),
60
+ });
61
+ const DomainQueryStepSchema = z.union([
62
+ DomainQueryDynamoGetItemStepSchema,
63
+ DomainQueryDynamoQueryStepSchema,
64
+ DomainQueryS3GetObjectStepSchema,
65
+ ]);
66
+ const SnsMessageAttributeSchema = z.object({ dataType: z.string(), stringValue: z.string() });
67
+ const AwsServiceSnsPublishStepSchema = z.object({
68
+ type: z.literal('aws-service'),
69
+ serviceAction: z.literal('sns-publish'),
70
+ name: z.string().min(1),
71
+ topicArn: z.string().min(1),
72
+ message: z.string().min(1),
73
+ subject: z.string().optional(),
74
+ messageAttributes: z.record(z.string(), SnsMessageAttributeSchema).optional(),
75
+ resultPath: z.string().optional(),
76
+ next: z.string().optional(),
77
+ });
78
+ const AwsServiceGlueStartJobRunStepSchema = z.object({
79
+ type: z.literal('aws-service'),
80
+ serviceAction: z.literal('glue-start-job-run'),
81
+ name: z.string().min(1),
82
+ jobName: z.string().min(1),
83
+ arguments: z.record(z.string(), z.string()).optional(),
84
+ timeout: z.number().int().positive().optional(),
85
+ workerType: z.enum(['Standard', 'G.1X', 'G.2X']).optional(),
86
+ numberOfWorkers: z.number().int().positive().optional(),
87
+ resultPath: z.string().optional(),
88
+ next: z.string().optional(),
89
+ });
90
+ const AwsServiceBatchSubmitJobStepSchema = z.object({
91
+ type: z.literal('aws-service'),
92
+ serviceAction: z.literal('batch-submit-job'),
93
+ name: z.string().min(1),
94
+ batchJobName: z.string().min(1),
95
+ jobQueue: z.string().min(1),
96
+ jobDefinition: z.string().min(1),
97
+ parameters: z.record(z.string(), z.string()).optional(),
98
+ resultPath: z.string().optional(),
99
+ next: z.string().optional(),
100
+ });
101
+ const AwsServiceStepFunctionsStartExecutionStepSchema = z.object({
102
+ type: z.literal('aws-service'),
103
+ serviceAction: z.literal('step-functions-start-execution'),
104
+ name: z.string().min(1),
105
+ stateMachineArn: z.string().min(1),
106
+ input: z.record(z.string(), z.unknown()).optional(),
107
+ executionName: z.string().optional(),
108
+ resultPath: z.string().optional(),
109
+ next: z.string().optional(),
110
+ });
111
+ const AwsServiceHttpsCallStepSchema = z.object({
112
+ type: z.literal('aws-service'),
113
+ serviceAction: z.literal('https-call'),
114
+ name: z.string().min(1),
115
+ endpoint: z.string().min(1),
116
+ method: z.enum(['GET', 'POST', 'PUT', 'PATCH', 'DELETE']),
117
+ headers: z.record(z.string(), z.string()).optional(),
118
+ body: z.unknown().optional(),
119
+ resultPath: z.string().optional(),
120
+ next: z.string().optional(),
121
+ });
122
+ const AwsServiceSqsSendMessageStepSchema = z.object({
123
+ type: z.literal('aws-service'),
124
+ serviceAction: z.literal('sqs-send-message'),
125
+ name: z.string().min(1),
126
+ queueUrl: z.string().min(1),
127
+ messageBody: z.string().min(1),
128
+ delaySeconds: z.number().int().nonnegative().optional(),
129
+ messageAttributes: z.record(z.string(), SnsMessageAttributeSchema).optional(),
130
+ resultPath: z.string().optional(),
131
+ next: z.string().optional(),
132
+ });
133
+ const AwsServiceAthenaStartQueryStepSchema = z.object({
134
+ type: z.literal('aws-service'),
135
+ serviceAction: z.literal('athena-start-query'),
136
+ name: z.string().min(1),
137
+ queryString: z.string().min(1),
138
+ database: z.string().min(1),
139
+ outputLocation: z.string().min(1),
140
+ workGroup: z.string().optional(),
141
+ resultPath: z.string().optional(),
142
+ next: z.string().optional(),
143
+ });
144
+ const AwsServiceStepSchema = z.union([
145
+ AwsServiceSnsPublishStepSchema,
146
+ AwsServiceGlueStartJobRunStepSchema,
147
+ AwsServiceBatchSubmitJobStepSchema,
148
+ AwsServiceStepFunctionsStartExecutionStepSchema,
149
+ AwsServiceHttpsCallStepSchema,
150
+ AwsServiceSqsSendMessageStepSchema,
151
+ AwsServiceAthenaStartQueryStepSchema,
152
+ ]);
27
153
  const ChoiceStepSchema = z.object({
28
154
  type: z.literal('flow-control'),
29
155
  control: z.literal('choice'),
@@ -38,6 +164,15 @@ const ParallelStepSchema = z.object({
38
164
  branches: z.array(z.array(z.unknown())),
39
165
  next: z.string().optional(),
40
166
  });
167
+ const MapStepSchema = z.object({
168
+ type: z.literal('flow-control'),
169
+ control: z.literal('map'),
170
+ name: z.string(),
171
+ iterator: z.array(z.unknown()).min(1),
172
+ itemsPath: z.string().optional(),
173
+ maxConcurrency: z.number().int().nonnegative().optional(),
174
+ next: z.string().optional(),
175
+ });
41
176
  const WaitStepSchema = z.object({
42
177
  type: z.literal('flow-control'),
43
178
  control: z.literal('wait'),
@@ -67,6 +202,7 @@ const PassStepSchema = z.object({
67
202
  const FlowControlStepSchema = z.union([
68
203
  ChoiceStepSchema,
69
204
  ParallelStepSchema,
205
+ MapStepSchema,
70
206
  WaitStepSchema,
71
207
  SucceedStepSchema,
72
208
  FailStepSchema,
@@ -76,6 +212,8 @@ const FlowStepSchema = z.union([
76
212
  DomainActionStepSchema,
77
213
  DomainApiStepSchema,
78
214
  DomainEventStepSchema,
215
+ DomainQueryStepSchema,
216
+ AwsServiceStepSchema,
79
217
  FlowControlStepSchema,
80
218
  ]);
81
219
  const FlowConfigSchema = z.object({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mettlecast/domain-runtime",
3
- "version": "0.2.34",
3
+ "version": "0.2.35",
4
4
  "type": "module",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org",