@zapier/zapier-sdk 0.60.0 → 0.62.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/CHANGELOG.md +24 -0
- package/README.md +229 -1
- package/dist/experimental.cjs +384 -10
- package/dist/experimental.d.mts +182 -2
- package/dist/experimental.d.ts +180 -0
- package/dist/experimental.d.ts.map +1 -1
- package/dist/experimental.js +14 -0
- package/dist/experimental.mjs +384 -11
- package/dist/{index-iKbnOz6r.d.mts → index-3fBEDEsp.d.mts} +25 -1
- package/dist/{index-iKbnOz6r.d.ts → index-3fBEDEsp.d.ts} +25 -1
- package/dist/index.cjs +19 -9
- package/dist/index.d.mts +1 -1
- package/dist/index.mjs +19 -10
- package/dist/plugins/codeSubstrate/createWorkflow/index.d.ts +45 -0
- package/dist/plugins/codeSubstrate/createWorkflow/index.d.ts.map +1 -0
- package/dist/plugins/codeSubstrate/createWorkflow/index.js +19 -0
- package/dist/plugins/codeSubstrate/createWorkflow/schemas.d.ts +16 -0
- package/dist/plugins/codeSubstrate/createWorkflow/schemas.d.ts.map +1 -0
- package/dist/plugins/codeSubstrate/createWorkflow/schemas.js +25 -0
- package/dist/plugins/codeSubstrate/deleteWorkflow/index.d.ts +39 -0
- package/dist/plugins/codeSubstrate/deleteWorkflow/index.d.ts.map +1 -0
- package/dist/plugins/codeSubstrate/deleteWorkflow/index.js +27 -0
- package/dist/plugins/codeSubstrate/deleteWorkflow/schemas.d.ts +6 -0
- package/dist/plugins/codeSubstrate/deleteWorkflow/schemas.d.ts.map +1 -0
- package/dist/plugins/codeSubstrate/deleteWorkflow/schemas.js +6 -0
- package/dist/plugins/codeSubstrate/disableWorkflow/index.d.ts +40 -0
- package/dist/plugins/codeSubstrate/disableWorkflow/index.d.ts.map +1 -0
- package/dist/plugins/codeSubstrate/disableWorkflow/index.js +20 -0
- package/dist/plugins/codeSubstrate/disableWorkflow/schemas.d.ts +11 -0
- package/dist/plugins/codeSubstrate/disableWorkflow/schemas.d.ts.map +1 -0
- package/dist/plugins/codeSubstrate/disableWorkflow/schemas.js +12 -0
- package/dist/plugins/codeSubstrate/enableWorkflow/index.d.ts +40 -0
- package/dist/plugins/codeSubstrate/enableWorkflow/index.d.ts.map +1 -0
- package/dist/plugins/codeSubstrate/enableWorkflow/index.js +20 -0
- package/dist/plugins/codeSubstrate/enableWorkflow/schemas.d.ts +11 -0
- package/dist/plugins/codeSubstrate/enableWorkflow/schemas.d.ts.map +1 -0
- package/dist/plugins/codeSubstrate/enableWorkflow/schemas.js +12 -0
- package/dist/plugins/codeSubstrate/getDurableRun/index.d.ts +89 -0
- package/dist/plugins/codeSubstrate/getDurableRun/index.d.ts.map +1 -0
- package/dist/plugins/codeSubstrate/getDurableRun/index.js +20 -0
- package/dist/plugins/codeSubstrate/getDurableRun/schemas.d.ts +178 -0
- package/dist/plugins/codeSubstrate/getDurableRun/schemas.d.ts.map +1 -0
- package/dist/plugins/codeSubstrate/getDurableRun/schemas.js +130 -0
- package/dist/plugins/codeSubstrate/listDurableRuns/index.d.ts +55 -0
- package/dist/plugins/codeSubstrate/listDurableRuns/index.d.ts.map +1 -0
- package/dist/plugins/codeSubstrate/listDurableRuns/index.js +27 -0
- package/dist/plugins/codeSubstrate/listDurableRuns/schemas.d.ts +73 -0
- package/dist/plugins/codeSubstrate/listDurableRuns/schemas.d.ts.map +1 -0
- package/dist/plugins/codeSubstrate/listDurableRuns/schemas.js +59 -0
- package/dist/plugins/codeSubstrate/updateWorkflow/index.d.ts +47 -0
- package/dist/plugins/codeSubstrate/updateWorkflow/index.d.ts.map +1 -0
- package/dist/plugins/codeSubstrate/updateWorkflow/index.js +27 -0
- package/dist/plugins/codeSubstrate/updateWorkflow/schemas.d.ts +18 -0
- package/dist/plugins/codeSubstrate/updateWorkflow/schemas.d.ts.map +1 -0
- package/dist/plugins/codeSubstrate/updateWorkflow/schemas.js +30 -0
- package/dist/plugins/deleteClientCredentials/index.d.ts.map +1 -1
- package/dist/plugins/deleteClientCredentials/index.js +1 -4
- package/dist/resolvers/clientId.d.ts.map +1 -1
- package/dist/resolvers/clientId.js +2 -4
- package/dist/resolvers/durableRunId.d.ts +4 -0
- package/dist/resolvers/durableRunId.d.ts.map +1 -0
- package/dist/resolvers/durableRunId.js +14 -0
- package/dist/resolvers/index.d.ts +1 -0
- package/dist/resolvers/index.d.ts.map +1 -1
- package/dist/resolvers/index.js +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
export declare const getDurableRunPlugin: (sdk: {
|
|
2
|
+
context: {
|
|
3
|
+
api: import("../../..").ApiClient;
|
|
4
|
+
resolveCredentials: () => Promise<string | {
|
|
5
|
+
clientId: string;
|
|
6
|
+
clientSecret: string;
|
|
7
|
+
type?: "client_credentials" | undefined;
|
|
8
|
+
baseUrl?: string | undefined;
|
|
9
|
+
scope?: string | undefined;
|
|
10
|
+
} | {
|
|
11
|
+
clientId: string;
|
|
12
|
+
type?: "pkce" | undefined;
|
|
13
|
+
baseUrl?: string | undefined;
|
|
14
|
+
scope?: string | undefined;
|
|
15
|
+
} | undefined>;
|
|
16
|
+
};
|
|
17
|
+
} & {
|
|
18
|
+
context: import("../../eventEmission").EventEmissionContext;
|
|
19
|
+
} & {
|
|
20
|
+
context: {
|
|
21
|
+
meta: Record<string, import("../../..").PluginMeta>;
|
|
22
|
+
};
|
|
23
|
+
}) => {
|
|
24
|
+
getDurableRun: (options?: {
|
|
25
|
+
run: string;
|
|
26
|
+
} | undefined) => Promise<{
|
|
27
|
+
data: {
|
|
28
|
+
id: string;
|
|
29
|
+
status: "initialized" | "started" | "finished" | "failed" | "cancelled";
|
|
30
|
+
input: unknown;
|
|
31
|
+
output: unknown;
|
|
32
|
+
error: {
|
|
33
|
+
[x: string]: unknown;
|
|
34
|
+
code: string;
|
|
35
|
+
message: string;
|
|
36
|
+
} | null;
|
|
37
|
+
execution: {
|
|
38
|
+
id: string;
|
|
39
|
+
name: string;
|
|
40
|
+
status: "failed" | "waiting" | "completed" | "running";
|
|
41
|
+
input: unknown;
|
|
42
|
+
created_at: string;
|
|
43
|
+
output?: unknown;
|
|
44
|
+
error?: unknown;
|
|
45
|
+
metadata?: Record<string, unknown> | undefined;
|
|
46
|
+
summary?: {
|
|
47
|
+
[x: string]: unknown;
|
|
48
|
+
total_attempts: number;
|
|
49
|
+
last_error?: {
|
|
50
|
+
[x: string]: unknown;
|
|
51
|
+
code: string;
|
|
52
|
+
title: string;
|
|
53
|
+
detail?: string | null | undefined;
|
|
54
|
+
} | undefined;
|
|
55
|
+
} | null | undefined;
|
|
56
|
+
operations?: {
|
|
57
|
+
id: string;
|
|
58
|
+
execution_id: string;
|
|
59
|
+
name: string;
|
|
60
|
+
type: "step" | "wait" | "callback";
|
|
61
|
+
status: "pending" | "failed" | "exhausted" | "completed";
|
|
62
|
+
retry_count: number;
|
|
63
|
+
created_at: string;
|
|
64
|
+
result?: unknown;
|
|
65
|
+
error?: unknown;
|
|
66
|
+
max_attempts?: number | undefined;
|
|
67
|
+
next_retry_at?: string | undefined;
|
|
68
|
+
resume_at?: string | undefined;
|
|
69
|
+
callback_token?: string | null | undefined;
|
|
70
|
+
payload_schema?: unknown;
|
|
71
|
+
payload?: unknown;
|
|
72
|
+
expires_at?: string | undefined;
|
|
73
|
+
completed_at?: string | undefined;
|
|
74
|
+
}[] | undefined;
|
|
75
|
+
} | null;
|
|
76
|
+
is_private: boolean;
|
|
77
|
+
created_at: string;
|
|
78
|
+
updated_at: string;
|
|
79
|
+
};
|
|
80
|
+
}>;
|
|
81
|
+
} & {
|
|
82
|
+
context: {
|
|
83
|
+
meta: {
|
|
84
|
+
getDurableRun: import("../../..").PluginMeta;
|
|
85
|
+
};
|
|
86
|
+
};
|
|
87
|
+
};
|
|
88
|
+
export type GetDurableRunPluginProvides = ReturnType<typeof getDurableRunPlugin>;
|
|
89
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/plugins/codeSubstrate/getDurableRun/index.ts"],"names":[],"mappings":"AAWA,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAqB/B,CAAC;AAEF,MAAM,MAAM,2BAA2B,GAAG,UAAU,CAClD,OAAO,mBAAmB,CAC3B,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { definePlugin, createPluginMethod } from "../../../utils/plugin-utils";
|
|
2
|
+
import { durableRunIdResolver } from "../../../resolvers/durableRunId";
|
|
3
|
+
import { codeSubstrateDefaults } from "../shared";
|
|
4
|
+
import { GetDurableRunOptionsSchema, GetDurableRunResponseSchema, } from "./schemas";
|
|
5
|
+
export const getDurableRunPlugin = definePlugin((sdk) => createPluginMethod(sdk, {
|
|
6
|
+
...codeSubstrateDefaults,
|
|
7
|
+
name: "getDurableRun",
|
|
8
|
+
type: "item",
|
|
9
|
+
itemType: "DurableRun",
|
|
10
|
+
inputSchema: GetDurableRunOptionsSchema,
|
|
11
|
+
outputSchema: GetDurableRunResponseSchema,
|
|
12
|
+
resolvers: { run: durableRunIdResolver },
|
|
13
|
+
handler: async ({ sdk, options }) => {
|
|
14
|
+
const data = await sdk.context.api.get(`/sdkdurableapi/api/v0/runs/${encodeURIComponent(options.run)}`, {
|
|
15
|
+
authRequired: true,
|
|
16
|
+
resource: { type: "run", id: options.run },
|
|
17
|
+
});
|
|
18
|
+
return { data };
|
|
19
|
+
},
|
|
20
|
+
}));
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare const OperationTypeSchema: z.ZodEnum<{
|
|
3
|
+
step: "step";
|
|
4
|
+
wait: "wait";
|
|
5
|
+
callback: "callback";
|
|
6
|
+
}>;
|
|
7
|
+
export type OperationType = z.infer<typeof OperationTypeSchema>;
|
|
8
|
+
export declare const OperationStatusSchema: z.ZodEnum<{
|
|
9
|
+
pending: "pending";
|
|
10
|
+
failed: "failed";
|
|
11
|
+
exhausted: "exhausted";
|
|
12
|
+
completed: "completed";
|
|
13
|
+
}>;
|
|
14
|
+
export type OperationStatus = z.infer<typeof OperationStatusSchema>;
|
|
15
|
+
export declare const OperationSchema: z.ZodObject<{
|
|
16
|
+
id: z.ZodString;
|
|
17
|
+
execution_id: z.ZodString;
|
|
18
|
+
name: z.ZodString;
|
|
19
|
+
type: z.ZodEnum<{
|
|
20
|
+
step: "step";
|
|
21
|
+
wait: "wait";
|
|
22
|
+
callback: "callback";
|
|
23
|
+
}>;
|
|
24
|
+
status: z.ZodEnum<{
|
|
25
|
+
pending: "pending";
|
|
26
|
+
failed: "failed";
|
|
27
|
+
exhausted: "exhausted";
|
|
28
|
+
completed: "completed";
|
|
29
|
+
}>;
|
|
30
|
+
result: z.ZodOptional<z.ZodUnknown>;
|
|
31
|
+
error: z.ZodOptional<z.ZodUnknown>;
|
|
32
|
+
retry_count: z.ZodNumber;
|
|
33
|
+
max_attempts: z.ZodOptional<z.ZodNumber>;
|
|
34
|
+
next_retry_at: z.ZodOptional<z.ZodString>;
|
|
35
|
+
resume_at: z.ZodOptional<z.ZodString>;
|
|
36
|
+
callback_token: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
37
|
+
payload_schema: z.ZodOptional<z.ZodUnknown>;
|
|
38
|
+
payload: z.ZodOptional<z.ZodUnknown>;
|
|
39
|
+
expires_at: z.ZodOptional<z.ZodString>;
|
|
40
|
+
completed_at: z.ZodOptional<z.ZodString>;
|
|
41
|
+
created_at: z.ZodString;
|
|
42
|
+
}, z.core.$strip>;
|
|
43
|
+
export type Operation = z.infer<typeof OperationSchema>;
|
|
44
|
+
export declare const ExecutionStatusSchema: z.ZodEnum<{
|
|
45
|
+
failed: "failed";
|
|
46
|
+
waiting: "waiting";
|
|
47
|
+
completed: "completed";
|
|
48
|
+
running: "running";
|
|
49
|
+
}>;
|
|
50
|
+
export type ExecutionStatus = z.infer<typeof ExecutionStatusSchema>;
|
|
51
|
+
export declare const ExecutionSummarySchema: z.ZodObject<{
|
|
52
|
+
id: z.ZodString;
|
|
53
|
+
name: z.ZodString;
|
|
54
|
+
status: z.ZodEnum<{
|
|
55
|
+
failed: "failed";
|
|
56
|
+
waiting: "waiting";
|
|
57
|
+
completed: "completed";
|
|
58
|
+
running: "running";
|
|
59
|
+
}>;
|
|
60
|
+
input: z.ZodUnknown;
|
|
61
|
+
output: z.ZodOptional<z.ZodUnknown>;
|
|
62
|
+
error: z.ZodOptional<z.ZodUnknown>;
|
|
63
|
+
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
64
|
+
created_at: z.ZodString;
|
|
65
|
+
summary: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
66
|
+
total_attempts: z.ZodNumber;
|
|
67
|
+
last_error: z.ZodOptional<z.ZodObject<{
|
|
68
|
+
code: z.ZodString;
|
|
69
|
+
title: z.ZodString;
|
|
70
|
+
detail: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
71
|
+
}, z.core.$loose>>;
|
|
72
|
+
}, z.core.$loose>>>;
|
|
73
|
+
operations: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
74
|
+
id: z.ZodString;
|
|
75
|
+
execution_id: z.ZodString;
|
|
76
|
+
name: z.ZodString;
|
|
77
|
+
type: z.ZodEnum<{
|
|
78
|
+
step: "step";
|
|
79
|
+
wait: "wait";
|
|
80
|
+
callback: "callback";
|
|
81
|
+
}>;
|
|
82
|
+
status: z.ZodEnum<{
|
|
83
|
+
pending: "pending";
|
|
84
|
+
failed: "failed";
|
|
85
|
+
exhausted: "exhausted";
|
|
86
|
+
completed: "completed";
|
|
87
|
+
}>;
|
|
88
|
+
result: z.ZodOptional<z.ZodUnknown>;
|
|
89
|
+
error: z.ZodOptional<z.ZodUnknown>;
|
|
90
|
+
retry_count: z.ZodNumber;
|
|
91
|
+
max_attempts: z.ZodOptional<z.ZodNumber>;
|
|
92
|
+
next_retry_at: z.ZodOptional<z.ZodString>;
|
|
93
|
+
resume_at: z.ZodOptional<z.ZodString>;
|
|
94
|
+
callback_token: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
95
|
+
payload_schema: z.ZodOptional<z.ZodUnknown>;
|
|
96
|
+
payload: z.ZodOptional<z.ZodUnknown>;
|
|
97
|
+
expires_at: z.ZodOptional<z.ZodString>;
|
|
98
|
+
completed_at: z.ZodOptional<z.ZodString>;
|
|
99
|
+
created_at: z.ZodString;
|
|
100
|
+
}, z.core.$strip>>>;
|
|
101
|
+
}, z.core.$strip>;
|
|
102
|
+
export type ExecutionSummary = z.infer<typeof ExecutionSummarySchema>;
|
|
103
|
+
export declare const GetDurableRunOptionsSchema: z.ZodObject<{
|
|
104
|
+
run: z.ZodString;
|
|
105
|
+
}, z.core.$strip>;
|
|
106
|
+
export type GetDurableRunOptions = z.infer<typeof GetDurableRunOptionsSchema>;
|
|
107
|
+
export declare const GetDurableRunResponseSchema: z.ZodObject<{
|
|
108
|
+
id: z.ZodString;
|
|
109
|
+
status: z.ZodEnum<{
|
|
110
|
+
initialized: "initialized";
|
|
111
|
+
started: "started";
|
|
112
|
+
finished: "finished";
|
|
113
|
+
failed: "failed";
|
|
114
|
+
cancelled: "cancelled";
|
|
115
|
+
}>;
|
|
116
|
+
input: z.ZodUnknown;
|
|
117
|
+
output: z.ZodNullable<z.ZodUnknown>;
|
|
118
|
+
error: z.ZodNullable<z.ZodObject<{
|
|
119
|
+
code: z.ZodString;
|
|
120
|
+
message: z.ZodString;
|
|
121
|
+
}, z.core.$loose>>;
|
|
122
|
+
execution: z.ZodNullable<z.ZodObject<{
|
|
123
|
+
id: z.ZodString;
|
|
124
|
+
name: z.ZodString;
|
|
125
|
+
status: z.ZodEnum<{
|
|
126
|
+
failed: "failed";
|
|
127
|
+
waiting: "waiting";
|
|
128
|
+
completed: "completed";
|
|
129
|
+
running: "running";
|
|
130
|
+
}>;
|
|
131
|
+
input: z.ZodUnknown;
|
|
132
|
+
output: z.ZodOptional<z.ZodUnknown>;
|
|
133
|
+
error: z.ZodOptional<z.ZodUnknown>;
|
|
134
|
+
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
135
|
+
created_at: z.ZodString;
|
|
136
|
+
summary: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
137
|
+
total_attempts: z.ZodNumber;
|
|
138
|
+
last_error: z.ZodOptional<z.ZodObject<{
|
|
139
|
+
code: z.ZodString;
|
|
140
|
+
title: z.ZodString;
|
|
141
|
+
detail: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
142
|
+
}, z.core.$loose>>;
|
|
143
|
+
}, z.core.$loose>>>;
|
|
144
|
+
operations: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
145
|
+
id: z.ZodString;
|
|
146
|
+
execution_id: z.ZodString;
|
|
147
|
+
name: z.ZodString;
|
|
148
|
+
type: z.ZodEnum<{
|
|
149
|
+
step: "step";
|
|
150
|
+
wait: "wait";
|
|
151
|
+
callback: "callback";
|
|
152
|
+
}>;
|
|
153
|
+
status: z.ZodEnum<{
|
|
154
|
+
pending: "pending";
|
|
155
|
+
failed: "failed";
|
|
156
|
+
exhausted: "exhausted";
|
|
157
|
+
completed: "completed";
|
|
158
|
+
}>;
|
|
159
|
+
result: z.ZodOptional<z.ZodUnknown>;
|
|
160
|
+
error: z.ZodOptional<z.ZodUnknown>;
|
|
161
|
+
retry_count: z.ZodNumber;
|
|
162
|
+
max_attempts: z.ZodOptional<z.ZodNumber>;
|
|
163
|
+
next_retry_at: z.ZodOptional<z.ZodString>;
|
|
164
|
+
resume_at: z.ZodOptional<z.ZodString>;
|
|
165
|
+
callback_token: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
166
|
+
payload_schema: z.ZodOptional<z.ZodUnknown>;
|
|
167
|
+
payload: z.ZodOptional<z.ZodUnknown>;
|
|
168
|
+
expires_at: z.ZodOptional<z.ZodString>;
|
|
169
|
+
completed_at: z.ZodOptional<z.ZodString>;
|
|
170
|
+
created_at: z.ZodString;
|
|
171
|
+
}, z.core.$strip>>>;
|
|
172
|
+
}, z.core.$strip>>;
|
|
173
|
+
is_private: z.ZodBoolean;
|
|
174
|
+
created_at: z.ZodString;
|
|
175
|
+
updated_at: z.ZodString;
|
|
176
|
+
}, z.core.$strip>;
|
|
177
|
+
export type GetDurableRunResponse = z.infer<typeof GetDurableRunResponseSchema>;
|
|
178
|
+
//# sourceMappingURL=schemas.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../../../../src/plugins/codeSubstrate/getDurableRun/schemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,eAAO,MAAM,mBAAmB;;;;EAI7B,CAAC;AAEJ,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAC;AAEhE,eAAO,MAAM,qBAAqB;;;;;EAI/B,CAAC;AAEJ,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAC;AAEpE,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAyD1B,CAAC;AAEH,MAAM,MAAM,SAAS,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,eAAe,CAAC,CAAC;AAExD,eAAO,MAAM,qBAAqB;;;;;EAI/B,CAAC;AAEJ,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAC;AAEpE,eAAO,MAAM,sBAAsB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAqDjC,CAAC;AAEH,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,sBAAsB,CAAC,CAAC;AAEtE,eAAO,MAAM,0BAA0B;;iBAMpC,CAAC;AAEJ,MAAM,MAAM,oBAAoB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,0BAA0B,CAAC,CAAC;AAE9E,eAAO,MAAM,2BAA2B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAqBtC,CAAC;AAEH,MAAM,MAAM,qBAAqB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,2BAA2B,CAAC,CAAC"}
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { RunErrorSchema, RunStatusSchema } from "../listDurableRuns/schemas";
|
|
3
|
+
export const OperationTypeSchema = z
|
|
4
|
+
.enum(["step", "wait", "callback"])
|
|
5
|
+
.describe("Operation kind: `step` is a journaled function call; `wait` is a time-based suspension; `callback` is a wait on an external callback.");
|
|
6
|
+
export const OperationStatusSchema = z
|
|
7
|
+
.enum(["pending", "completed", "failed", "exhausted"])
|
|
8
|
+
.describe("Operation lifecycle status. `exhausted` means retries were exceeded.");
|
|
9
|
+
export const OperationSchema = z.object({
|
|
10
|
+
id: z.string().describe("Operation ID (UUID)"),
|
|
11
|
+
execution_id: z.string().describe("Parent execution ID"),
|
|
12
|
+
name: z
|
|
13
|
+
.string()
|
|
14
|
+
.describe("Operation name as declared by the workflow author"),
|
|
15
|
+
type: OperationTypeSchema,
|
|
16
|
+
status: OperationStatusSchema,
|
|
17
|
+
result: z
|
|
18
|
+
.unknown()
|
|
19
|
+
.optional()
|
|
20
|
+
.describe("Result value when the operation completed"),
|
|
21
|
+
error: z
|
|
22
|
+
.unknown()
|
|
23
|
+
.optional()
|
|
24
|
+
.describe("Error payload when the operation failed"),
|
|
25
|
+
retry_count: z.number().describe("Number of retry attempts so far"),
|
|
26
|
+
max_attempts: z
|
|
27
|
+
.number()
|
|
28
|
+
.optional()
|
|
29
|
+
.describe("Cap on total attempts for this operation. Absent if no cap applies."),
|
|
30
|
+
next_retry_at: z
|
|
31
|
+
.string()
|
|
32
|
+
.optional()
|
|
33
|
+
.describe("When the next retry will be attempted (ISO-8601)"),
|
|
34
|
+
resume_at: z
|
|
35
|
+
.string()
|
|
36
|
+
.optional()
|
|
37
|
+
.describe("When a `wait` operation resumes (ISO-8601). Set only for type=wait."),
|
|
38
|
+
callback_token: z
|
|
39
|
+
.string()
|
|
40
|
+
.nullable()
|
|
41
|
+
.optional()
|
|
42
|
+
.describe("Token for delivering a callback. Set only for type=callback; null until the callback URL is materialized."),
|
|
43
|
+
payload_schema: z
|
|
44
|
+
.unknown()
|
|
45
|
+
.optional()
|
|
46
|
+
.describe("JSON Schema describing the expected callback payload"),
|
|
47
|
+
payload: z
|
|
48
|
+
.unknown()
|
|
49
|
+
.optional()
|
|
50
|
+
.describe("Payload delivered to a callback operation, when received"),
|
|
51
|
+
expires_at: z
|
|
52
|
+
.string()
|
|
53
|
+
.optional()
|
|
54
|
+
.describe("When a callback or wait operation expires (ISO-8601)"),
|
|
55
|
+
completed_at: z
|
|
56
|
+
.string()
|
|
57
|
+
.optional()
|
|
58
|
+
.describe("When the operation reached a terminal state (ISO-8601)"),
|
|
59
|
+
created_at: z.string().describe("When the operation was created (ISO-8601)"),
|
|
60
|
+
});
|
|
61
|
+
export const ExecutionStatusSchema = z
|
|
62
|
+
.enum(["running", "waiting", "completed", "failed"])
|
|
63
|
+
.describe("Execution lifecycle status. `waiting` means blocked on a wait or callback operation.");
|
|
64
|
+
export const ExecutionSummarySchema = z.object({
|
|
65
|
+
id: z.string().describe("Execution ID (UUID)"),
|
|
66
|
+
name: z.string().describe("Durable function name"),
|
|
67
|
+
status: ExecutionStatusSchema,
|
|
68
|
+
input: z.unknown().describe("Input passed when the execution was created"),
|
|
69
|
+
output: z
|
|
70
|
+
.unknown()
|
|
71
|
+
.optional()
|
|
72
|
+
.describe("Return value when status is `completed`"),
|
|
73
|
+
error: z
|
|
74
|
+
.unknown()
|
|
75
|
+
.optional()
|
|
76
|
+
.describe("Error details when status is `failed`"),
|
|
77
|
+
metadata: z
|
|
78
|
+
.record(z.string(), z.unknown())
|
|
79
|
+
.optional()
|
|
80
|
+
.describe("Caller-supplied tags (Zap ID, Step ID, Agent ID, etc.) carried alongside the execution"),
|
|
81
|
+
created_at: z.string().describe("When the execution was created (ISO-8601)"),
|
|
82
|
+
summary: z
|
|
83
|
+
.object({
|
|
84
|
+
total_attempts: z
|
|
85
|
+
.number()
|
|
86
|
+
.describe("Total ticks attempted against this execution across all retries"),
|
|
87
|
+
last_error: z
|
|
88
|
+
.object({
|
|
89
|
+
code: z.string().describe("Machine-readable error category"),
|
|
90
|
+
title: z.string().describe("Short error label"),
|
|
91
|
+
detail: z
|
|
92
|
+
.string()
|
|
93
|
+
.nullable()
|
|
94
|
+
.optional()
|
|
95
|
+
.describe("Longer-form error detail, when provided"),
|
|
96
|
+
})
|
|
97
|
+
.passthrough()
|
|
98
|
+
.optional()
|
|
99
|
+
.describe("The most recent error, if the execution has failed once"),
|
|
100
|
+
})
|
|
101
|
+
.passthrough()
|
|
102
|
+
.nullable()
|
|
103
|
+
.optional()
|
|
104
|
+
.describe("Aggregate health summary. Null when no attempts have been recorded yet."),
|
|
105
|
+
operations: z
|
|
106
|
+
.array(OperationSchema)
|
|
107
|
+
.optional()
|
|
108
|
+
.describe("Operations journal — append-only record of every step/wait/callback the execution made"),
|
|
109
|
+
});
|
|
110
|
+
export const GetDurableRunOptionsSchema = z
|
|
111
|
+
.object({
|
|
112
|
+
run: z.string().uuid().describe("Durable run ID"),
|
|
113
|
+
})
|
|
114
|
+
.describe("Get the full state of a run-once durable run, including its operations journal");
|
|
115
|
+
export const GetDurableRunResponseSchema = z.object({
|
|
116
|
+
id: z.string().describe("Run ID (UUID)"),
|
|
117
|
+
status: RunStatusSchema,
|
|
118
|
+
input: z.unknown().describe("Input data passed to the run"),
|
|
119
|
+
output: z
|
|
120
|
+
.unknown()
|
|
121
|
+
.nullable()
|
|
122
|
+
.describe("Return value, present when status is `finished`"),
|
|
123
|
+
error: RunErrorSchema.nullable().describe("Structured error details when the run failed (null otherwise)"),
|
|
124
|
+
execution: ExecutionSummarySchema.nullable().describe("Linked execution, including the operations journal. Null while the run is still in `initialized` state."),
|
|
125
|
+
is_private: z
|
|
126
|
+
.boolean()
|
|
127
|
+
.describe("When true, the run is visible only to the creating user; otherwise visible across the account."),
|
|
128
|
+
created_at: z.string().describe("When the run was created (ISO-8601)"),
|
|
129
|
+
updated_at: z.string().describe("When the run was last updated (ISO-8601)"),
|
|
130
|
+
});
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
export declare const listDurableRunsPlugin: (sdk: {
|
|
2
|
+
context: {
|
|
3
|
+
api: import("../../..").ApiClient;
|
|
4
|
+
resolveCredentials: () => Promise<string | {
|
|
5
|
+
clientId: string;
|
|
6
|
+
clientSecret: string;
|
|
7
|
+
type?: "client_credentials" | undefined;
|
|
8
|
+
baseUrl?: string | undefined;
|
|
9
|
+
scope?: string | undefined;
|
|
10
|
+
} | {
|
|
11
|
+
clientId: string;
|
|
12
|
+
type?: "pkce" | undefined;
|
|
13
|
+
baseUrl?: string | undefined;
|
|
14
|
+
scope?: string | undefined;
|
|
15
|
+
} | undefined>;
|
|
16
|
+
};
|
|
17
|
+
} & {
|
|
18
|
+
context: import("../../eventEmission").EventEmissionContext;
|
|
19
|
+
} & {
|
|
20
|
+
context: {
|
|
21
|
+
meta: Record<string, import("../../..").PluginMeta>;
|
|
22
|
+
};
|
|
23
|
+
}) => {
|
|
24
|
+
listDurableRuns: (options?: ({
|
|
25
|
+
pageSize?: number | undefined;
|
|
26
|
+
cursor?: string | undefined;
|
|
27
|
+
maxItems?: number | undefined;
|
|
28
|
+
} & {
|
|
29
|
+
cursor?: string;
|
|
30
|
+
pageSize?: number;
|
|
31
|
+
maxItems?: number;
|
|
32
|
+
}) | undefined) => import("../../..").PaginatedSdkResult<{
|
|
33
|
+
id: string;
|
|
34
|
+
status: "initialized" | "started" | "finished" | "failed" | "cancelled";
|
|
35
|
+
input: unknown;
|
|
36
|
+
output: unknown;
|
|
37
|
+
error: {
|
|
38
|
+
[x: string]: unknown;
|
|
39
|
+
code: string;
|
|
40
|
+
message: string;
|
|
41
|
+
} | null;
|
|
42
|
+
execution_id: string | null;
|
|
43
|
+
is_private: boolean;
|
|
44
|
+
created_at: string;
|
|
45
|
+
updated_at: string;
|
|
46
|
+
}>;
|
|
47
|
+
} & {
|
|
48
|
+
context: {
|
|
49
|
+
meta: {
|
|
50
|
+
listDurableRuns: import("../../..").PluginMeta;
|
|
51
|
+
};
|
|
52
|
+
};
|
|
53
|
+
};
|
|
54
|
+
export type ListDurableRunsPluginProvides = ReturnType<typeof listDurableRunsPlugin>;
|
|
55
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/plugins/codeSubstrate/listDurableRuns/index.ts"],"names":[],"mappings":"AAcA,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA6BjC,CAAC;AAEF,MAAM,MAAM,6BAA6B,GAAG,UAAU,CACpD,OAAO,qBAAqB,CAC7B,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { definePlugin, createPaginatedPluginMethod, } from "../../../utils/plugin-utils";
|
|
2
|
+
import { DEFAULT_PAGE_SIZE } from "../../../constants";
|
|
3
|
+
import { codeSubstrateDefaults } from "../shared";
|
|
4
|
+
import { ListDurableRunsOptionsSchema, RunItemSchema, } from "./schemas";
|
|
5
|
+
export const listDurableRunsPlugin = definePlugin((sdk) => createPaginatedPluginMethod(sdk, {
|
|
6
|
+
...codeSubstrateDefaults,
|
|
7
|
+
name: "listDurableRuns",
|
|
8
|
+
type: "list",
|
|
9
|
+
itemType: "DurableRun",
|
|
10
|
+
inputSchema: ListDurableRunsOptionsSchema,
|
|
11
|
+
outputSchema: RunItemSchema,
|
|
12
|
+
defaultPageSize: DEFAULT_PAGE_SIZE,
|
|
13
|
+
handler: async ({ sdk, options }) => {
|
|
14
|
+
const searchParams = {};
|
|
15
|
+
if (options.pageSize !== undefined) {
|
|
16
|
+
searchParams.limit = options.pageSize.toString();
|
|
17
|
+
}
|
|
18
|
+
if (options.cursor) {
|
|
19
|
+
searchParams.cursor = options.cursor;
|
|
20
|
+
}
|
|
21
|
+
const response = await sdk.context.api.get("/sdkdurableapi/api/v0/runs", { searchParams, authRequired: true });
|
|
22
|
+
return {
|
|
23
|
+
data: response.results,
|
|
24
|
+
nextCursor: response.meta.next_cursor ?? undefined,
|
|
25
|
+
};
|
|
26
|
+
},
|
|
27
|
+
}));
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare const RunStatusSchema: z.ZodEnum<{
|
|
3
|
+
initialized: "initialized";
|
|
4
|
+
started: "started";
|
|
5
|
+
finished: "finished";
|
|
6
|
+
failed: "failed";
|
|
7
|
+
cancelled: "cancelled";
|
|
8
|
+
}>;
|
|
9
|
+
export type RunStatus = z.infer<typeof RunStatusSchema>;
|
|
10
|
+
export declare const RunErrorSchema: z.ZodObject<{
|
|
11
|
+
code: z.ZodString;
|
|
12
|
+
message: z.ZodString;
|
|
13
|
+
}, z.core.$loose>;
|
|
14
|
+
export type RunError = z.infer<typeof RunErrorSchema>;
|
|
15
|
+
export declare const RunItemSchema: z.ZodObject<{
|
|
16
|
+
id: z.ZodString;
|
|
17
|
+
status: z.ZodEnum<{
|
|
18
|
+
initialized: "initialized";
|
|
19
|
+
started: "started";
|
|
20
|
+
finished: "finished";
|
|
21
|
+
failed: "failed";
|
|
22
|
+
cancelled: "cancelled";
|
|
23
|
+
}>;
|
|
24
|
+
input: z.ZodUnknown;
|
|
25
|
+
output: z.ZodNullable<z.ZodUnknown>;
|
|
26
|
+
error: z.ZodNullable<z.ZodObject<{
|
|
27
|
+
code: z.ZodString;
|
|
28
|
+
message: z.ZodString;
|
|
29
|
+
}, z.core.$loose>>;
|
|
30
|
+
execution_id: z.ZodNullable<z.ZodString>;
|
|
31
|
+
is_private: z.ZodBoolean;
|
|
32
|
+
created_at: z.ZodString;
|
|
33
|
+
updated_at: z.ZodString;
|
|
34
|
+
}, z.core.$strip>;
|
|
35
|
+
export type RunItem = z.infer<typeof RunItemSchema>;
|
|
36
|
+
export declare const ListDurableRunsOptionsSchema: z.ZodObject<{
|
|
37
|
+
pageSize: z.ZodOptional<z.ZodNumber>;
|
|
38
|
+
cursor: z.ZodOptional<z.ZodString>;
|
|
39
|
+
maxItems: z.ZodOptional<z.ZodNumber>;
|
|
40
|
+
}, z.core.$strip>;
|
|
41
|
+
export type ListDurableRunsOptions = z.infer<typeof ListDurableRunsOptionsSchema>;
|
|
42
|
+
export declare const ListDurableRunsApiResponseSchema: z.ZodObject<{
|
|
43
|
+
results: z.ZodArray<z.ZodObject<{
|
|
44
|
+
id: z.ZodString;
|
|
45
|
+
status: z.ZodEnum<{
|
|
46
|
+
initialized: "initialized";
|
|
47
|
+
started: "started";
|
|
48
|
+
finished: "finished";
|
|
49
|
+
failed: "failed";
|
|
50
|
+
cancelled: "cancelled";
|
|
51
|
+
}>;
|
|
52
|
+
input: z.ZodUnknown;
|
|
53
|
+
output: z.ZodNullable<z.ZodUnknown>;
|
|
54
|
+
error: z.ZodNullable<z.ZodObject<{
|
|
55
|
+
code: z.ZodString;
|
|
56
|
+
message: z.ZodString;
|
|
57
|
+
}, z.core.$loose>>;
|
|
58
|
+
execution_id: z.ZodNullable<z.ZodString>;
|
|
59
|
+
is_private: z.ZodBoolean;
|
|
60
|
+
created_at: z.ZodString;
|
|
61
|
+
updated_at: z.ZodString;
|
|
62
|
+
}, z.core.$strip>>;
|
|
63
|
+
meta: z.ZodObject<{
|
|
64
|
+
limit: z.ZodNumber;
|
|
65
|
+
cursor: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
66
|
+
next_cursor: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
67
|
+
}, z.core.$strip>;
|
|
68
|
+
links: z.ZodOptional<z.ZodObject<{
|
|
69
|
+
next: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
70
|
+
}, z.core.$strip>>;
|
|
71
|
+
}, z.core.$strip>;
|
|
72
|
+
export type ListDurableRunsApiResponse = z.infer<typeof ListDurableRunsApiResponseSchema>;
|
|
73
|
+
//# sourceMappingURL=schemas.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../../../../src/plugins/codeSubstrate/listDurableRuns/schemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,eAAO,MAAM,eAAe;;;;;;EAIzB,CAAC;AAEJ,MAAM,MAAM,SAAS,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,eAAe,CAAC,CAAC;AAExD,eAAO,MAAM,cAAc;;;iBAQxB,CAAC;AAEJ,MAAM,MAAM,QAAQ,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,cAAc,CAAC,CAAC;AAEtD,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;iBAwBxB,CAAC;AAEH,MAAM,MAAM,OAAO,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,aAAa,CAAC,CAAC;AAEpD,eAAO,MAAM,4BAA4B;;;;iBAiBtC,CAAC;AAEJ,MAAM,MAAM,sBAAsB,GAAG,CAAC,CAAC,KAAK,CAC1C,OAAO,4BAA4B,CACpC,CAAC;AAEF,eAAO,MAAM,gCAAgC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAY3C,CAAC;AAEH,MAAM,MAAM,0BAA0B,GAAG,CAAC,CAAC,KAAK,CAC9C,OAAO,gCAAgC,CACxC,CAAC"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export const RunStatusSchema = z
|
|
3
|
+
.enum(["initialized", "started", "finished", "failed", "cancelled"])
|
|
4
|
+
.describe("Run lifecycle status. `finished` / `failed` / `cancelled` are terminal.");
|
|
5
|
+
export const RunErrorSchema = z
|
|
6
|
+
.object({
|
|
7
|
+
code: z.string().describe("Machine-readable error category"),
|
|
8
|
+
message: z.string().describe("Human-readable error summary"),
|
|
9
|
+
})
|
|
10
|
+
.passthrough()
|
|
11
|
+
.describe("Structured run error. Always carries `code` and `message`; additional keys may appear depending on the error type.");
|
|
12
|
+
export const RunItemSchema = z.object({
|
|
13
|
+
id: z.string().describe("Run ID (UUID)"),
|
|
14
|
+
status: RunStatusSchema,
|
|
15
|
+
input: z.unknown().describe("Input data passed to the run"),
|
|
16
|
+
output: z
|
|
17
|
+
.unknown()
|
|
18
|
+
.nullable()
|
|
19
|
+
.describe("Return value, present when status is `finished`"),
|
|
20
|
+
error: RunErrorSchema.nullable().describe("Structured error details when the run failed (null otherwise)"),
|
|
21
|
+
execution_id: z
|
|
22
|
+
.string()
|
|
23
|
+
.nullable()
|
|
24
|
+
.describe("Linked execution ID. Null until the run leaves the `initialized` state."),
|
|
25
|
+
is_private: z
|
|
26
|
+
.boolean()
|
|
27
|
+
.describe("When true, the run is visible only to the creating user; otherwise visible across the account."),
|
|
28
|
+
created_at: z.string().describe("When the run was created (ISO-8601)"),
|
|
29
|
+
updated_at: z.string().describe("When the run was last updated (ISO-8601)"),
|
|
30
|
+
});
|
|
31
|
+
export const ListDurableRunsOptionsSchema = z
|
|
32
|
+
.object({
|
|
33
|
+
pageSize: z
|
|
34
|
+
.number()
|
|
35
|
+
.min(1)
|
|
36
|
+
.max(100)
|
|
37
|
+
.optional()
|
|
38
|
+
.describe("Number of runs per page (max 100)"),
|
|
39
|
+
cursor: z.string().optional().describe("Pagination cursor"),
|
|
40
|
+
maxItems: z
|
|
41
|
+
.number()
|
|
42
|
+
.min(1)
|
|
43
|
+
.optional()
|
|
44
|
+
.describe("Maximum total items to return across all pages"),
|
|
45
|
+
})
|
|
46
|
+
.describe("List run-once durable runs for the authenticated account, newest first");
|
|
47
|
+
export const ListDurableRunsApiResponseSchema = z.object({
|
|
48
|
+
results: z.array(RunItemSchema),
|
|
49
|
+
meta: z.object({
|
|
50
|
+
limit: z.number(),
|
|
51
|
+
cursor: z.string().nullable().optional(),
|
|
52
|
+
next_cursor: z.string().nullable().optional(),
|
|
53
|
+
}),
|
|
54
|
+
links: z
|
|
55
|
+
.object({
|
|
56
|
+
next: z.string().nullable().optional(),
|
|
57
|
+
})
|
|
58
|
+
.optional(),
|
|
59
|
+
});
|