@zapier/zapier-sdk 0.72.0 → 0.73.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.
- package/CHANGELOG.md +12 -0
- package/README.md +32 -32
- package/dist/api/client.d.ts.map +1 -1
- package/dist/api/client.js +9 -0
- package/dist/api/types.d.ts +5 -4
- package/dist/api/types.d.ts.map +1 -1
- package/dist/experimental.cjs +175 -65
- package/dist/experimental.d.mts +160 -12
- package/dist/experimental.d.ts +158 -10
- package/dist/experimental.d.ts.map +1 -1
- package/dist/experimental.mjs +175 -65
- package/dist/{index-B43uST61.d.mts → index-D1O7Pcex.d.mts} +5 -4
- package/dist/{index-B43uST61.d.ts → index-D1O7Pcex.d.ts} +5 -4
- package/dist/index.cjs +10 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.mjs +10 -1
- package/dist/plugins/codeSubstrate/publishWorkflowVersion/index.d.ts +42 -3
- package/dist/plugins/codeSubstrate/publishWorkflowVersion/index.d.ts.map +1 -1
- package/dist/plugins/codeSubstrate/publishWorkflowVersion/index.js +49 -11
- package/dist/plugins/codeSubstrate/publishWorkflowVersion/schemas.d.ts +117 -5
- package/dist/plugins/codeSubstrate/publishWorkflowVersion/schemas.d.ts.map +1 -1
- package/dist/plugins/codeSubstrate/publishWorkflowVersion/schemas.js +77 -14
- package/dist/plugins/codeSubstrate/runDurable/index.d.ts +37 -2
- package/dist/plugins/codeSubstrate/runDurable/index.d.ts.map +1 -1
- package/dist/plugins/codeSubstrate/runDurable/index.js +10 -9
- package/dist/plugins/codeSubstrate/runDurable/schemas.d.ts +117 -4
- package/dist/plugins/codeSubstrate/runDurable/schemas.d.ts.map +1 -1
- package/dist/plugins/codeSubstrate/runDurable/schemas.js +38 -37
- package/dist/plugins/codeSubstrate/shared.d.ts +56 -0
- package/dist/plugins/codeSubstrate/shared.d.ts.map +1 -1
- package/dist/plugins/codeSubstrate/shared.js +100 -0
- package/package.json +1 -1
|
@@ -1,26 +1,5 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
|
|
3
|
-
// `.min(1)` on implementation_name at the input boundary. The shared schema
|
|
4
|
-
// is response-side and intentionally looser.
|
|
5
|
-
const ConnectionMapEntrySchema = z.object({
|
|
6
|
-
connection_id: z
|
|
7
|
-
.union([
|
|
8
|
-
z.string().regex(/^[1-9][0-9]*$/, "must be a positive integer string"),
|
|
9
|
-
z.string().uuid("must be a UUID"),
|
|
10
|
-
z.number().int().positive(),
|
|
11
|
-
])
|
|
12
|
-
.describe("Zapier connection ID. Accepts a positive integer (legacy) or a UUID string (newer connections)."),
|
|
13
|
-
});
|
|
14
|
-
const AppVersionMapEntrySchema = z.object({
|
|
15
|
-
implementation_name: z
|
|
16
|
-
.string()
|
|
17
|
-
.min(1)
|
|
18
|
-
.describe("Zapier app implementation name (e.g. `SlackCLIAPI`)"),
|
|
19
|
-
version: z
|
|
20
|
-
.string()
|
|
21
|
-
.optional()
|
|
22
|
-
.describe("Pinned app version (e.g. `1.27.1`). Latest if omitted."),
|
|
23
|
-
});
|
|
2
|
+
import { AppVersionBindingSchema, ConnectionBindingSchema, SourceFilesSchema, } from "../shared";
|
|
24
3
|
const RunNotificationEventSchema = z
|
|
25
4
|
.enum(["started", "progress", "completed", "error", "cancelled"])
|
|
26
5
|
.describe("Run lifecycle event this notification subscribes to");
|
|
@@ -47,31 +26,33 @@ const RunNotificationSchema = z
|
|
|
47
26
|
.describe("One or more lifecycle events to subscribe this URL to."),
|
|
48
27
|
})
|
|
49
28
|
.describe("Webhook subscriber for run lifecycle events. Server POSTs `{run_id, event}` on each subscribed transition.");
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
.record(z.string(), z.string())
|
|
54
|
-
.refine((files) => Object.keys(files).length > 0, {
|
|
55
|
-
message: "source_files must contain at least one file",
|
|
56
|
-
})
|
|
57
|
-
.describe("Source files keyed by filename → contents"),
|
|
29
|
+
// Shared, non-renamed properties. Lives in its own object so the canonical
|
|
30
|
+
// and deprecated `sourceFiles` variants can merge it without repetition.
|
|
31
|
+
const RunDurableBaseSchema = z.object({
|
|
58
32
|
input: z.unknown().optional().describe("Input data passed to the run"),
|
|
59
33
|
dependencies: z
|
|
60
34
|
.record(z.string(), z.string())
|
|
61
35
|
.optional()
|
|
62
36
|
.describe("Optional npm package dependencies"),
|
|
63
|
-
|
|
37
|
+
zapierDurableVersion: z
|
|
64
38
|
.string()
|
|
65
39
|
.optional()
|
|
66
40
|
.describe('Exact semver of @zapier/zapier-durable to use (e.g. "1.2.3"). Defaults to server-configured version if omitted.'),
|
|
41
|
+
/** @deprecated Use `zapierDurableVersion` instead. */
|
|
42
|
+
zapier_durable_version: z.string().optional().meta({ deprecated: true }),
|
|
67
43
|
connections: z
|
|
68
|
-
.record(z.string(),
|
|
44
|
+
.record(z.string(), ConnectionBindingSchema)
|
|
69
45
|
.optional()
|
|
70
|
-
.describe('Named connection aliases. Maps each alias to an object holding its Zapier connection ID, e.g. `{ "slack": { "
|
|
71
|
-
|
|
72
|
-
.record(z.string(),
|
|
46
|
+
.describe('Named connection aliases. Maps each alias to an object holding its Zapier connection ID, e.g. `{ "slack": { "connectionId": "123" } }`.'),
|
|
47
|
+
appVersions: z
|
|
48
|
+
.record(z.string(), AppVersionBindingSchema)
|
|
73
49
|
.optional()
|
|
74
50
|
.describe("Pinned app versions. Maps app keys (slugs) to implementation names and versions."),
|
|
51
|
+
/** @deprecated Use `appVersions` instead. */
|
|
52
|
+
app_versions: z
|
|
53
|
+
.record(z.string(), AppVersionBindingSchema)
|
|
54
|
+
.optional()
|
|
55
|
+
.meta({ deprecated: true }),
|
|
75
56
|
private: z
|
|
76
57
|
.boolean()
|
|
77
58
|
.optional()
|
|
@@ -80,8 +61,28 @@ export const RunDurableOptionsSchema = z
|
|
|
80
61
|
.array(RunNotificationSchema)
|
|
81
62
|
.optional()
|
|
82
63
|
.describe("Webhook subscribers for run lifecycle events. Each entry specifies a URL and the events it subscribes to."),
|
|
83
|
-
})
|
|
84
|
-
|
|
64
|
+
});
|
|
65
|
+
const RunDurableDescription = "Run a workflow source file as a run-once durable run on sdkdurableapi (no deployed workflow required). Returns the run ID immediately; poll via getDurableRun for terminal status.";
|
|
66
|
+
// Canonical schema (new names only) — drives docs, CLI help, and the registry.
|
|
67
|
+
export const RunDurableSchema = z
|
|
68
|
+
.object({ sourceFiles: SourceFilesSchema })
|
|
69
|
+
.merge(RunDurableBaseSchema)
|
|
70
|
+
.describe(RunDurableDescription)
|
|
71
|
+
.meta({
|
|
72
|
+
aliases: {
|
|
73
|
+
source_files: "sourceFiles",
|
|
74
|
+
zapier_durable_version: "zapierDurableVersion",
|
|
75
|
+
app_versions: "appVersions",
|
|
76
|
+
},
|
|
77
|
+
});
|
|
78
|
+
// Deprecated schema (backward compat) — keeps the old `source_files` name valid.
|
|
79
|
+
const RunDurableSchemaDeprecated = z
|
|
80
|
+
.object({ source_files: SourceFilesSchema })
|
|
81
|
+
.merge(RunDurableBaseSchema);
|
|
82
|
+
// Union for runtime validation: accepts either the canonical or the old name.
|
|
83
|
+
export const RunDurableOptionsSchema = z
|
|
84
|
+
.union([RunDurableSchema, RunDurableSchemaDeprecated])
|
|
85
|
+
.describe(RunDurableDescription);
|
|
85
86
|
export const RunDurableResponseSchema = z.object({
|
|
86
87
|
id: z.string().describe("Run ID (UUID) — server-generated, time-sortable"),
|
|
87
88
|
status: z
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
1
2
|
/**
|
|
2
3
|
* Method-meta defaults shared across every workflow plugin. Each plugin
|
|
3
4
|
* spreads `...codeSubstrateDefaults` into its `createPluginMethod` /
|
|
@@ -13,4 +14,59 @@ export declare const codeSubstrateDefaults: {
|
|
|
13
14
|
categories: string[];
|
|
14
15
|
experimental: true;
|
|
15
16
|
};
|
|
17
|
+
/**
|
|
18
|
+
* Source files map, shared by `runDurable` and `publishWorkflowVersion`.
|
|
19
|
+
* Both require at least one file.
|
|
20
|
+
*/
|
|
21
|
+
export declare const SourceFilesSchema: z.ZodRecord<z.ZodString, z.ZodString>;
|
|
22
|
+
/**
|
|
23
|
+
* A Zapier connection ID accepted on the wire: a positive integer (legacy)
|
|
24
|
+
* or a UUID string (newer connections). Split into three union members so a
|
|
25
|
+
* bad value produces a precise message at the input boundary.
|
|
26
|
+
*/
|
|
27
|
+
export declare const ConnectionIdValueSchema: z.ZodUnion<readonly [z.ZodString, z.ZodString, z.ZodNumber]>;
|
|
28
|
+
/**
|
|
29
|
+
* Connection binding: maps a single alias to a concrete connection. The
|
|
30
|
+
* locator is camelCase (`connectionId`) per SDK convention; the snake_case
|
|
31
|
+
* `connection_id` is a deprecated alias. Both are optional in the schema so
|
|
32
|
+
* `.shape` stays introspectable for docs — the wire mapper enforces that one
|
|
33
|
+
* is present (see {@link toWireConnections}).
|
|
34
|
+
*/
|
|
35
|
+
export declare const ConnectionBindingSchema: z.ZodObject<{
|
|
36
|
+
connectionId: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodString, z.ZodNumber]>>;
|
|
37
|
+
connection_id: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodString, z.ZodNumber]>>;
|
|
38
|
+
}, z.core.$strip>;
|
|
39
|
+
/**
|
|
40
|
+
* App-version binding: maps an app key to a pinned implementation/version.
|
|
41
|
+
* `implementationName` is the camelCase locator; `implementation_name` is a
|
|
42
|
+
* deprecated alias. Required-ness of the name is enforced by the wire mapper
|
|
43
|
+
* (see {@link toWireAppVersions}).
|
|
44
|
+
*/
|
|
45
|
+
export declare const AppVersionBindingSchema: z.ZodObject<{
|
|
46
|
+
implementationName: z.ZodOptional<z.ZodString>;
|
|
47
|
+
implementation_name: z.ZodOptional<z.ZodString>;
|
|
48
|
+
version: z.ZodOptional<z.ZodString>;
|
|
49
|
+
}, z.core.$strip>;
|
|
50
|
+
type ConnectionEntryInput = z.infer<typeof ConnectionBindingSchema>;
|
|
51
|
+
type AppVersionEntryInput = z.infer<typeof AppVersionBindingSchema>;
|
|
52
|
+
/**
|
|
53
|
+
* Reshape a caller's `connections` map into the wire body. The nested
|
|
54
|
+
* locator is camelCase (`connectionId`) per SDK convention but the API
|
|
55
|
+
* expects `connection_id`; the deprecated snake_case alias is still
|
|
56
|
+
* accepted. The connection ID itself is required, so a missing one is a
|
|
57
|
+
* client-side validation error rather than a malformed request.
|
|
58
|
+
*/
|
|
59
|
+
export declare function toWireConnections(connections: Record<string, ConnectionEntryInput>): Record<string, {
|
|
60
|
+
connection_id: string | number;
|
|
61
|
+
}>;
|
|
62
|
+
/**
|
|
63
|
+
* Reshape a caller's `appVersions` map into the wire body, mapping the
|
|
64
|
+
* camelCase `implementationName` locator (and its deprecated snake_case
|
|
65
|
+
* alias) onto the API's `implementation_name`.
|
|
66
|
+
*/
|
|
67
|
+
export declare function toWireAppVersions(appVersions: Record<string, AppVersionEntryInput>): Record<string, {
|
|
68
|
+
implementation_name: string;
|
|
69
|
+
version?: string;
|
|
70
|
+
}>;
|
|
71
|
+
export {};
|
|
16
72
|
//# sourceMappingURL=shared.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shared.d.ts","sourceRoot":"","sources":["../../../src/plugins/codeSubstrate/shared.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"shared.d.ts","sourceRoot":"","sources":["../../../src/plugins/codeSubstrate/shared.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB;;;;;;;;;;GAUG;AACH,eAAO,MAAM,qBAAqB;;;CAGH,CAAC;AAEhC;;;GAGG;AACH,eAAO,MAAM,iBAAiB,uCAK0B,CAAC;AAYzD;;;;GAIG;AACH,eAAO,MAAM,uBAAuB,8DAQjC,CAAC;AAEJ;;;;;;GAMG;AACH,eAAO,MAAM,uBAAuB;;;iBAIlC,CAAC;AAEH;;;;;GAKG;AACH,eAAO,MAAM,uBAAuB;;;;iBAYlC,CAAC;AAEH,KAAK,oBAAoB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,uBAAuB,CAAC,CAAC;AACpE,KAAK,oBAAoB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,uBAAuB,CAAC,CAAC;AAEpE;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAC/B,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,oBAAoB,CAAC,GAChD,MAAM,CAAC,MAAM,EAAE;IAAE,aAAa,EAAE,MAAM,GAAG,MAAM,CAAA;CAAE,CAAC,CAYpD;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAC/B,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,oBAAoB,CAAC,GAChD,MAAM,CAAC,MAAM,EAAE;IAAE,mBAAmB,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC,CAmBnE"}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { ZapierValidationError } from "../../types/errors";
|
|
1
3
|
/**
|
|
2
4
|
* Method-meta defaults shared across every workflow plugin. Each plugin
|
|
3
5
|
* spreads `...codeSubstrateDefaults` into its `createPluginMethod` /
|
|
@@ -13,3 +15,101 @@ export const codeSubstrateDefaults = {
|
|
|
13
15
|
categories: ["code-workflow"],
|
|
14
16
|
experimental: true,
|
|
15
17
|
};
|
|
18
|
+
/**
|
|
19
|
+
* Source files map, shared by `runDurable` and `publishWorkflowVersion`.
|
|
20
|
+
* Both require at least one file.
|
|
21
|
+
*/
|
|
22
|
+
export const SourceFilesSchema = z
|
|
23
|
+
.record(z.string(), z.string())
|
|
24
|
+
.refine((files) => Object.keys(files).length > 0, {
|
|
25
|
+
message: "sourceFiles must contain at least one file",
|
|
26
|
+
})
|
|
27
|
+
.describe("Source files keyed by filename → contents");
|
|
28
|
+
// Structural UUID match (8-4-4-4-12 hex), not `z.uuid()`. Both backends
|
|
29
|
+
// validate `connection_id` with this same structural regex and intentionally
|
|
30
|
+
// do NOT enforce RFC version/variant nibbles:
|
|
31
|
+
// - durableworkflowzaps `CreateWorkflowVersionRequest` (publishWorkflowVersion)
|
|
32
|
+
// - sdkdurableapi `StartRunRequest` (runDurable)
|
|
33
|
+
// `z.uuid()` is stricter — it rejects non-RFC variants — so it would reject IDs
|
|
34
|
+
// these backends accept. The SDK boundary must not be stricter than the wire.
|
|
35
|
+
const UUID_PATTERN = /^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$/;
|
|
36
|
+
/**
|
|
37
|
+
* A Zapier connection ID accepted on the wire: a positive integer (legacy)
|
|
38
|
+
* or a UUID string (newer connections). Split into three union members so a
|
|
39
|
+
* bad value produces a precise message at the input boundary.
|
|
40
|
+
*/
|
|
41
|
+
export const ConnectionIdValueSchema = z
|
|
42
|
+
.union([
|
|
43
|
+
z.string().regex(/^[1-9][0-9]*$/, "must be a positive integer string"),
|
|
44
|
+
z.string().regex(UUID_PATTERN, "must be a UUID"),
|
|
45
|
+
z.number().int().positive(),
|
|
46
|
+
])
|
|
47
|
+
.describe("Zapier connection ID. Accepts a positive integer (legacy) or a UUID string (newer connections).");
|
|
48
|
+
/**
|
|
49
|
+
* Connection binding: maps a single alias to a concrete connection. The
|
|
50
|
+
* locator is camelCase (`connectionId`) per SDK convention; the snake_case
|
|
51
|
+
* `connection_id` is a deprecated alias. Both are optional in the schema so
|
|
52
|
+
* `.shape` stays introspectable for docs — the wire mapper enforces that one
|
|
53
|
+
* is present (see {@link toWireConnections}).
|
|
54
|
+
*/
|
|
55
|
+
export const ConnectionBindingSchema = z.object({
|
|
56
|
+
connectionId: ConnectionIdValueSchema.optional(),
|
|
57
|
+
/** @deprecated Use `connectionId` instead. */
|
|
58
|
+
connection_id: ConnectionIdValueSchema.optional().meta({ deprecated: true }),
|
|
59
|
+
});
|
|
60
|
+
/**
|
|
61
|
+
* App-version binding: maps an app key to a pinned implementation/version.
|
|
62
|
+
* `implementationName` is the camelCase locator; `implementation_name` is a
|
|
63
|
+
* deprecated alias. Required-ness of the name is enforced by the wire mapper
|
|
64
|
+
* (see {@link toWireAppVersions}).
|
|
65
|
+
*/
|
|
66
|
+
export const AppVersionBindingSchema = z.object({
|
|
67
|
+
implementationName: z
|
|
68
|
+
.string()
|
|
69
|
+
.min(1)
|
|
70
|
+
.optional()
|
|
71
|
+
.describe("Zapier app implementation name (e.g. `SlackCLIAPI`)"),
|
|
72
|
+
/** @deprecated Use `implementationName` instead. */
|
|
73
|
+
implementation_name: z.string().min(1).optional().meta({ deprecated: true }),
|
|
74
|
+
version: z
|
|
75
|
+
.string()
|
|
76
|
+
.optional()
|
|
77
|
+
.describe("Pinned app version (e.g. `1.27.1`). Latest if omitted."),
|
|
78
|
+
});
|
|
79
|
+
/**
|
|
80
|
+
* Reshape a caller's `connections` map into the wire body. The nested
|
|
81
|
+
* locator is camelCase (`connectionId`) per SDK convention but the API
|
|
82
|
+
* expects `connection_id`; the deprecated snake_case alias is still
|
|
83
|
+
* accepted. The connection ID itself is required, so a missing one is a
|
|
84
|
+
* client-side validation error rather than a malformed request.
|
|
85
|
+
*/
|
|
86
|
+
export function toWireConnections(connections) {
|
|
87
|
+
const wire = {};
|
|
88
|
+
for (const [alias, entry] of Object.entries(connections)) {
|
|
89
|
+
const connectionId = entry.connectionId ?? entry.connection_id;
|
|
90
|
+
if (connectionId === undefined) {
|
|
91
|
+
throw new ZapierValidationError(`connections["${alias}"] is missing connectionId`);
|
|
92
|
+
}
|
|
93
|
+
wire[alias] = { connection_id: connectionId };
|
|
94
|
+
}
|
|
95
|
+
return wire;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Reshape a caller's `appVersions` map into the wire body, mapping the
|
|
99
|
+
* camelCase `implementationName` locator (and its deprecated snake_case
|
|
100
|
+
* alias) onto the API's `implementation_name`.
|
|
101
|
+
*/
|
|
102
|
+
export function toWireAppVersions(appVersions) {
|
|
103
|
+
const wire = {};
|
|
104
|
+
for (const [key, entry] of Object.entries(appVersions)) {
|
|
105
|
+
const implementationName = entry.implementationName ?? entry.implementation_name;
|
|
106
|
+
if (implementationName === undefined) {
|
|
107
|
+
throw new ZapierValidationError(`appVersions["${key}"] is missing implementationName`);
|
|
108
|
+
}
|
|
109
|
+
wire[key] = {
|
|
110
|
+
implementation_name: implementationName,
|
|
111
|
+
...(entry.version !== undefined ? { version: entry.version } : {}),
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
return wire;
|
|
115
|
+
}
|