@automate.ax/api-contract 0.44.0 → 0.46.0

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/dist/runtime.js CHANGED
@@ -7,7 +7,187 @@ const SIGNAL_FAILURE_SCHEMA = z.object({
7
7
  message: z.string(),
8
8
  name: z.string(),
9
9
  });
10
- const TERMINAL_ACTION_STATUS_SCHEMA = z.enum(["closed", "failed", "succeeded"]);
10
+ const OUTCOME_SEQUENCE_SCHEMA = z.number().int().positive();
11
+ const ACTION_INVOCATION_BASE_SCHEMA = z.object({
12
+ actionDependencyIds: z.string().array(),
13
+ description: z.string().nullable(),
14
+ eventDependencyIds: z.string().array(),
15
+ inputHash: z.string(),
16
+ name: z.string(),
17
+ signalDependencyIds: z.string().array(),
18
+ slot: z.number().int().nonnegative(),
19
+ });
20
+ const ACTION_INVOCATION_SCHEMA = z.union([
21
+ ACTION_INVOCATION_BASE_SCHEMA.extend({ status: z.literal("pending") }),
22
+ ACTION_INVOCATION_BASE_SCHEMA.extend({
23
+ reason: z.literal("closed-dependency"),
24
+ status: z.literal("skipped"),
25
+ }),
26
+ ACTION_INVOCATION_BASE_SCHEMA.extend({
27
+ failure: SIGNAL_FAILURE_SCHEMA,
28
+ reason: z.literal("failed-dependency"),
29
+ status: z.literal("skipped"),
30
+ }),
31
+ ]);
32
+ const ACTION_RUN_INVOCATION_BASE_SCHEMA = ACTION_INVOCATION_BASE_SCHEMA.extend({
33
+ actionInvocationId: z.string(),
34
+ });
35
+ const ACTION_RUN_INVOCATION_SCHEMA = z.union([
36
+ ACTION_RUN_INVOCATION_BASE_SCHEMA.extend({ status: z.literal("pending") }),
37
+ ACTION_RUN_INVOCATION_BASE_SCHEMA.extend({
38
+ failure: SIGNAL_FAILURE_SCHEMA,
39
+ outcomeSeq: OUTCOME_SEQUENCE_SCHEMA,
40
+ status: z.literal("failed"),
41
+ }),
42
+ ACTION_RUN_INVOCATION_BASE_SCHEMA.extend({
43
+ outcomeSeq: OUTCOME_SEQUENCE_SCHEMA,
44
+ reason: z.literal("closed-dependency"),
45
+ status: z.literal("skipped"),
46
+ }),
47
+ ACTION_RUN_INVOCATION_BASE_SCHEMA.extend({
48
+ failure: SIGNAL_FAILURE_SCHEMA,
49
+ outcomeSeq: OUTCOME_SEQUENCE_SCHEMA,
50
+ reason: z.literal("failed-dependency"),
51
+ status: z.literal("skipped"),
52
+ }),
53
+ ACTION_RUN_INVOCATION_BASE_SCHEMA.extend({
54
+ outcomeSeq: OUTCOME_SEQUENCE_SCHEMA,
55
+ status: z.literal("succeeded"),
56
+ }),
57
+ ]);
58
+ const SIGNAL_INVOCATION_DEPENDENCIES_SCHEMA = z.object({
59
+ actionDependencyIds: z.string().array(),
60
+ eventDependencyIds: z.string().array(),
61
+ signalDependencyIds: z.string().array(),
62
+ slot: z.number().int().nonnegative(),
63
+ });
64
+ const CORRELATION_ENTRY_SCHEMA = SIGNAL_INVOCATION_DEPENDENCIES_SCHEMA.extend({
65
+ key: encodableSchema,
66
+ outcomeSeq: OUTCOME_SEQUENCE_SCHEMA,
67
+ streamName: z.string().min(1),
68
+ streamNames: z.string().min(1).array().min(2),
69
+ value: encodableSchema,
70
+ });
71
+ const SIGNAL_INVOCATION_SCHEMA = z.union([
72
+ SIGNAL_INVOCATION_DEPENDENCIES_SCHEMA.extend({
73
+ outcomeSeq: OUTCOME_SEQUENCE_SCHEMA.optional(),
74
+ status: z.literal("closed"),
75
+ }),
76
+ SIGNAL_INVOCATION_DEPENDENCIES_SCHEMA.extend({
77
+ failure: SIGNAL_FAILURE_SCHEMA,
78
+ status: z.literal("failed"),
79
+ }),
80
+ SIGNAL_INVOCATION_DEPENDENCIES_SCHEMA.extend({
81
+ outcomeSeq: OUTCOME_SEQUENCE_SCHEMA.optional(),
82
+ selectedIndex: z.number().int().nonnegative().optional(),
83
+ status: z.literal("open"),
84
+ }),
85
+ ]);
86
+ const SIGNAL_BATCH_OUTCOME_BASE_SCHEMA = SIGNAL_INVOCATION_DEPENDENCIES_SCHEMA.extend({
87
+ outcomeSeq: OUTCOME_SEQUENCE_SCHEMA,
88
+ signalInvocationId: z.string(),
89
+ });
90
+ const SIGNAL_BATCH_OUTCOME_SCHEMA = z.union([
91
+ SIGNAL_BATCH_OUTCOME_BASE_SCHEMA.extend({
92
+ selectedIndex: z.number().int().nonnegative().optional(),
93
+ status: z.literal("open"),
94
+ }),
95
+ SIGNAL_BATCH_OUTCOME_BASE_SCHEMA.extend({ status: z.literal("closed") }),
96
+ SIGNAL_BATCH_OUTCOME_BASE_SCHEMA.extend({
97
+ failure: SIGNAL_FAILURE_SCHEMA,
98
+ status: z.literal("failed"),
99
+ }),
100
+ SIGNAL_BATCH_OUTCOME_BASE_SCHEMA.extend({ status: z.literal("succeeded") }),
101
+ ]);
102
+ const ACTION_VALUE_OUTCOME_SCHEMA = z.union([
103
+ z.object({
104
+ actionInvocationId: z.string(),
105
+ outcomeSeq: OUTCOME_SEQUENCE_SCHEMA,
106
+ slot: z.number().int(),
107
+ status: z.literal("failed"),
108
+ failure: SIGNAL_FAILURE_SCHEMA,
109
+ }),
110
+ z.object({
111
+ actionInvocationId: z.string(),
112
+ outcomeSeq: OUTCOME_SEQUENCE_SCHEMA,
113
+ reason: z.literal("closed-dependency"),
114
+ slot: z.number().int(),
115
+ status: z.literal("skipped"),
116
+ }),
117
+ z.object({
118
+ actionInvocationId: z.string(),
119
+ failure: SIGNAL_FAILURE_SCHEMA,
120
+ outcomeSeq: OUTCOME_SEQUENCE_SCHEMA,
121
+ reason: z.literal("failed-dependency"),
122
+ slot: z.number().int(),
123
+ status: z.literal("skipped"),
124
+ }),
125
+ z.object({
126
+ actionInvocationId: z.string(),
127
+ outcomeSeq: OUTCOME_SEQUENCE_SCHEMA,
128
+ output: encodableSchema,
129
+ slot: z.number().int(),
130
+ status: z.literal("succeeded"),
131
+ }),
132
+ ]);
133
+ const SIGNAL_VALUE_OUTCOME_BASE_SCHEMA = z.object({
134
+ outcomeSeq: OUTCOME_SEQUENCE_SCHEMA,
135
+ signalInvocationId: z.string(),
136
+ slot: z.number().int(),
137
+ });
138
+ const SIGNAL_VALUE_OUTCOME_SCHEMA = z.union([
139
+ SIGNAL_VALUE_OUTCOME_BASE_SCHEMA.extend({
140
+ selectedIndex: z.number().int().nonnegative().optional(),
141
+ status: z.literal("open"),
142
+ }),
143
+ SIGNAL_VALUE_OUTCOME_BASE_SCHEMA.extend({ status: z.literal("closed") }),
144
+ SIGNAL_VALUE_OUTCOME_BASE_SCHEMA.extend({
145
+ failure: SIGNAL_FAILURE_SCHEMA,
146
+ status: z.literal("failed"),
147
+ }),
148
+ SIGNAL_VALUE_OUTCOME_BASE_SCHEMA.extend({
149
+ output: encodableSchema,
150
+ status: z.literal("succeeded"),
151
+ }),
152
+ ]);
153
+ const RUNTIME_VALUE_CONTEXT_SCHEMA = z.object({
154
+ actionOutputs: ACTION_VALUE_OUTCOME_SCHEMA.array(),
155
+ contextId: z.string(),
156
+ events: z
157
+ .object({
158
+ automationEventId: z.string(),
159
+ outcomeSeq: OUTCOME_SEQUENCE_SCHEMA,
160
+ payload: encodableSchema,
161
+ slot: z.number().int(),
162
+ })
163
+ .array(),
164
+ signalOutputs: SIGNAL_VALUE_OUTCOME_SCHEMA.array(),
165
+ });
166
+ const RUNTIME_RUN_CONTEXT_SCHEMA = z.object({
167
+ actions: ACTION_RUN_INVOCATION_SCHEMA.array(),
168
+ contextId: z.string(),
169
+ events: z
170
+ .object({
171
+ automationEventId: z.string(),
172
+ outcomeSeq: OUTCOME_SEQUENCE_SCHEMA,
173
+ slot: z.number().int(),
174
+ })
175
+ .array(),
176
+ signalOutputs: SIGNAL_BATCH_OUTCOME_SCHEMA.array(),
177
+ });
178
+ const TARGET_ACTION_SCHEMA = z.union([
179
+ z.object({
180
+ context: RUNTIME_VALUE_CONTEXT_SCHEMA,
181
+ id: z.string(),
182
+ slot: z.number().int(),
183
+ status: z.literal("pending"),
184
+ }),
185
+ z.object({
186
+ id: z.string(),
187
+ slot: z.number().int(),
188
+ status: z.enum(["failed", "skipped", "succeeded"]),
189
+ }),
190
+ ]);
11
191
  const GENERATION_WARNING_SCHEMA = z.discriminatedUnion("type", [
12
192
  z.object({
13
193
  details: z.string().optional(),
@@ -126,22 +306,23 @@ const RUNTIME_GENERATION_INPUT_SCHEMA = z.union([
126
306
  export const runtimeContract = {
127
307
  commit: oc
128
308
  .input(z.object({
129
- actionInvocations: z
130
- .object({
131
- actionDependencyIds: z.string().array(),
132
- description: z.string().nullable(),
133
- eventDependencyIds: z.string().array(),
134
- inputHash: z.string(),
135
- name: z.string(),
136
- slot: z.number().int().nonnegative(),
137
- })
138
- .array()
139
- .default([]),
309
+ actionInvocations: ACTION_INVOCATION_SCHEMA.array().default([]),
310
+ correlationEntries: CORRELATION_ENTRY_SCHEMA.array().default([]),
311
+ settled: z.boolean().default(true),
312
+ signalInvocations: SIGNAL_INVOCATION_SCHEMA.array().default([]),
140
313
  }))
141
314
  .output(z.void()),
142
- completeInvocation: oc
143
- .input(z.discriminatedUnion("status", [
144
- z.object({ status: z.literal("closed") }),
315
+ completeAction: oc
316
+ .input(z.union([
317
+ z.object({
318
+ reason: z.literal("closed-dependency"),
319
+ status: z.literal("skipped"),
320
+ }),
321
+ z.object({
322
+ failure: SIGNAL_FAILURE_SCHEMA,
323
+ reason: z.literal("failed-dependency"),
324
+ status: z.literal("skipped"),
325
+ }),
145
326
  z.object({
146
327
  failure: SIGNAL_FAILURE_SCHEMA,
147
328
  status: z.literal("failed"),
@@ -155,63 +336,14 @@ export const runtimeContract = {
155
336
  generate: oc
156
337
  .input(RUNTIME_GENERATION_INPUT_SCHEMA)
157
338
  .output(generationResultSchema),
158
- loadInvocation: oc.output(z.object({
159
- context: z.object({
160
- actionOutputs: z
161
- .discriminatedUnion("status", [
162
- z.object({
163
- actionInvocationId: z.string(),
164
- slot: z.number().int(),
165
- status: z.literal("closed"),
166
- }),
167
- z.object({
168
- actionInvocationId: z.string(),
169
- failure: SIGNAL_FAILURE_SCHEMA,
170
- slot: z.number().int(),
171
- status: z.literal("failed"),
172
- }),
173
- z.object({
174
- actionInvocationId: z.string(),
175
- output: encodableSchema,
176
- slot: z.number().int(),
177
- status: z.literal("succeeded"),
178
- }),
179
- ])
180
- .array(),
181
- contextId: z.string(),
182
- events: z
183
- .object({
184
- automationEventId: z.string(),
185
- payload: encodableSchema,
186
- slot: z.number().int(),
187
- })
188
- .array(),
189
- }),
190
- id: z.string(),
191
- slot: z.number().int(),
192
- })),
193
- nextBatch: oc.output(z.object({
194
- context: z.object({
195
- actionOutputs: z
196
- .object({
197
- actionDependencyIds: z.string().array(),
198
- actionInvocationId: z.string(),
199
- eventDependencyIds: z.string().array(),
200
- inputHash: z.string(),
201
- name: z.string(),
202
- slot: z.number().int(),
203
- status: TERMINAL_ACTION_STATUS_SCHEMA,
204
- })
205
- .array(),
206
- contextId: z.string(),
207
- events: z
208
- .object({
209
- automationEventId: z.string(),
210
- slot: z.number().int(),
211
- })
212
- .array(),
213
- }),
339
+ load: oc.output(z.object({
340
+ context: RUNTIME_RUN_CONTEXT_SCHEMA,
341
+ finalAttempt: z.boolean(),
342
+ targetAction: TARGET_ACTION_SCHEMA.optional(),
214
343
  })),
344
+ loadValues: oc
345
+ .input(SIGNAL_INVOCATION_DEPENDENCIES_SCHEMA.omit({ slot: true }))
346
+ .output(RUNTIME_VALUE_CONTEXT_SCHEMA),
215
347
  resolveAccountInput: oc
216
348
  .input(z.strictObject({
217
349
  binding: z.string().min(1),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@automate.ax/api-contract",
3
- "version": "0.44.0",
3
+ "version": "0.46.0",
4
4
  "description": "Public oRPC contract for the Automate.ax API.",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -27,7 +27,7 @@
27
27
  },
28
28
  "dependencies": {
29
29
  "@ai-sdk/gateway": "^4.0.46",
30
- "@automate.ax/codec": "0.44.0",
30
+ "@automate.ax/codec": "0.46.0",
31
31
  "@orpc/contract": "1.13.14",
32
32
  "zod": "^4.3.6"
33
33
  },
@@ -0,0 +1,108 @@
1
+ import { encodableSchema } from "@automate.ax/codec"
2
+ import { oc } from "@orpc/contract"
3
+ import { z } from "zod"
4
+ import { deploymentTriggerInfoSchema } from "./deployment"
5
+
6
+ export const automationExecutionStatusSchema = z.enum([
7
+ "running",
8
+ "completed",
9
+ "failed",
10
+ ])
11
+
12
+ const EXECUTION_FAILURE_SCHEMA = z.object({
13
+ message: z.string(),
14
+ name: z.string(),
15
+ })
16
+
17
+ const EXECUTION_SUMMARY_SCHEMA = z.object({
18
+ completedAt: z.date().nullable(),
19
+ createdAt: z.date(),
20
+ eventTypes: z.string().array(),
21
+ failure: EXECUTION_FAILURE_SCHEMA.nullable(),
22
+ id: z.string(),
23
+ status: automationExecutionStatusSchema,
24
+ })
25
+
26
+ export const automationContract = {
27
+ get: oc
28
+ .input(
29
+ z.object({
30
+ automationId: z.string(),
31
+ projectId: z.string(),
32
+ }),
33
+ )
34
+ .output(
35
+ z.object({
36
+ activeDeployment: z.object({
37
+ createdAt: z.date(),
38
+ git: z
39
+ .object({
40
+ commitSha: z.string(),
41
+ dirty: z.boolean(),
42
+ repositoryUrl: z.string(),
43
+ })
44
+ .nullable(),
45
+ id: z.string(),
46
+ }),
47
+ createdAt: z.date(),
48
+ description: z.string(),
49
+ id: z.string(),
50
+ identityKey: z.string(),
51
+ triggers: deploymentTriggerInfoSchema.array(),
52
+ updatedAt: z.date(),
53
+ }),
54
+ ),
55
+ getExecution: oc
56
+ .input(
57
+ z.object({
58
+ automationId: z.string(),
59
+ executionId: z.string(),
60
+ projectId: z.string(),
61
+ }),
62
+ )
63
+ .output(
64
+ EXECUTION_SUMMARY_SCHEMA.omit({ eventTypes: true }).extend({
65
+ actions: z
66
+ .object({
67
+ completedAt: z.date().nullable(),
68
+ createdAt: z.date(),
69
+ description: z.string().nullable(),
70
+ failure: EXECUTION_FAILURE_SCHEMA.nullable(),
71
+ hasOutput: z.boolean(),
72
+ id: z.string(),
73
+ name: z.string(),
74
+ output: encodableSchema,
75
+ slot: z.number().int().nonnegative(),
76
+ status: z.enum(["pending", "succeeded", "skipped", "failed"]),
77
+ })
78
+ .array(),
79
+ events: z
80
+ .object({
81
+ createdAt: z.date(),
82
+ id: z.string(),
83
+ payload: encodableSchema,
84
+ type: z.string(),
85
+ })
86
+ .array(),
87
+ outputs: z
88
+ .object({
89
+ actionInvocationId: z.string(),
90
+ createdAt: z.date(),
91
+ data: encodableSchema,
92
+ id: z.string(),
93
+ outputIndex: z.number().int().nonnegative(),
94
+ type: z.string(),
95
+ })
96
+ .array(),
97
+ }),
98
+ ),
99
+ listExecutions: oc
100
+ .input(
101
+ z.object({
102
+ automationId: z.string(),
103
+ limit: z.number().int().min(1).max(100).default(50),
104
+ projectId: z.string(),
105
+ }),
106
+ )
107
+ .output(EXECUTION_SUMMARY_SCHEMA.array()),
108
+ }
package/src/deployment.ts CHANGED
@@ -95,10 +95,12 @@ export const deploymentContract = {
95
95
  automations: z
96
96
  .object({
97
97
  description: z.string(),
98
+ id: z.string(),
98
99
  identityKey: z.string(),
99
100
  triggers: deploymentTriggerInfoSchema.array(),
100
101
  })
101
102
  .array(),
103
+ createdAt: z.date(),
102
104
  id: z.string(),
103
105
  git: GIT_SOURCE_SCHEMA.nullable(),
104
106
  job: z
package/src/index.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import { accountContract } from "./account"
2
+ import { automationContract } from "./automation"
2
3
  import { apiKeyContract } from "./api-key"
3
4
  import { authContract } from "./auth"
4
5
  import { authorizationContract } from "./authorization"
@@ -8,6 +9,7 @@ import { orgContract } from "./org"
8
9
  import { projectContract } from "./project"
9
10
  import { runtimeContract } from "./runtime"
10
11
 
12
+ export { automationExecutionStatusSchema } from "./automation"
11
13
  export {
12
14
  AUTOMATION_SDK_VERSION,
13
15
  deploymentTriggerInfoSchema,
@@ -84,6 +86,7 @@ export const publicContract = {
84
86
  export const firstPartyContract = {
85
87
  ...publicContract,
86
88
  account: accountContract,
89
+ automation: automationContract,
87
90
  authorization: {
88
91
  beginConnection: authorizationContract.beginConnection,
89
92
  get: authorizationContract.get,
package/src/project.ts CHANGED
@@ -3,6 +3,7 @@ import { z } from "zod"
3
3
  import { reasonableNameSchema } from "./schemas"
4
4
 
5
5
  export const projectOutputSchema = z.object({
6
+ activeDeploymentId: z.string().nullable(),
6
7
  id: z.string(),
7
8
  name: z.string(),
8
9
  organizationId: z.string(),
@@ -15,6 +16,7 @@ export const projectOutputSchema = z.object({
15
16
  activeAutomations: z
16
17
  .object({
17
18
  description: z.string(),
19
+ id: z.string(),
18
20
  identityKey: z.string(),
19
21
  })
20
22
  .array(),