@zapier/zapier-sdk 0.73.0 → 0.74.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 +12 -0
- package/README.md +32 -32
- package/dist/api/client.d.ts.map +1 -1
- package/dist/api/client.js +5 -0
- package/dist/experimental.cjs +218 -80
- 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 +217 -81
- package/dist/{index-D1O7Pcex.d.mts → index-WMit6fkJ.d.mts} +22 -1
- package/dist/{index-D1O7Pcex.d.ts → index-WMit6fkJ.d.ts} +22 -1
- package/dist/index.cjs +53 -16
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.mjs +52 -17
- 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/dist/utils/caller-context.d.ts +21 -0
- package/dist/utils/caller-context.d.ts.map +1 -0
- package/dist/utils/caller-context.js +35 -0
- package/package.json +2 -2
|
@@ -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
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export interface CallerContext {
|
|
2
|
+
packageOperation?: string;
|
|
3
|
+
}
|
|
4
|
+
/**
|
|
5
|
+
* Run `fn` with the given caller context merged onto any parent context, so
|
|
6
|
+
* the operation that initiated the call (e.g. a CLI command or MCP tool) stays
|
|
7
|
+
* observable through every SDK call it makes.
|
|
8
|
+
*
|
|
9
|
+
* Caller context is telemetry-only: reading the parent scope is wrapped so a
|
|
10
|
+
* broken ALS store can never crash the wrapped command. Errors thrown by `fn`
|
|
11
|
+
* itself are intentionally NOT caught — they propagate.
|
|
12
|
+
*/
|
|
13
|
+
export declare function runWithCallerContext<T>(context: CallerContext, fn: () => T): T;
|
|
14
|
+
/**
|
|
15
|
+
* Read the active caller context, or an empty object outside any caller scope.
|
|
16
|
+
*
|
|
17
|
+
* Read on the outbound HTTP path to set a telemetry header, so a failure here
|
|
18
|
+
* must never break the request — it falls back to an empty context.
|
|
19
|
+
*/
|
|
20
|
+
export declare function getCallerContext(): CallerContext;
|
|
21
|
+
//# sourceMappingURL=caller-context.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"caller-context.d.ts","sourceRoot":"","sources":["../../src/utils/caller-context.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,aAAa;IAC5B,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B;AAID;;;;;;;;GAQG;AACH,wBAAgB,oBAAoB,CAAC,CAAC,EACpC,OAAO,EAAE,aAAa,EACtB,EAAE,EAAE,MAAM,CAAC,GACV,CAAC,CAQH;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,IAAI,aAAa,CAMhD"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { createAsyncContext } from "kitcore";
|
|
2
|
+
const callerContext = createAsyncContext();
|
|
3
|
+
/**
|
|
4
|
+
* Run `fn` with the given caller context merged onto any parent context, so
|
|
5
|
+
* the operation that initiated the call (e.g. a CLI command or MCP tool) stays
|
|
6
|
+
* observable through every SDK call it makes.
|
|
7
|
+
*
|
|
8
|
+
* Caller context is telemetry-only: reading the parent scope is wrapped so a
|
|
9
|
+
* broken ALS store can never crash the wrapped command. Errors thrown by `fn`
|
|
10
|
+
* itself are intentionally NOT caught — they propagate.
|
|
11
|
+
*/
|
|
12
|
+
export function runWithCallerContext(context, fn) {
|
|
13
|
+
let parent;
|
|
14
|
+
try {
|
|
15
|
+
parent = callerContext.get() ?? {};
|
|
16
|
+
}
|
|
17
|
+
catch {
|
|
18
|
+
return fn();
|
|
19
|
+
}
|
|
20
|
+
return callerContext.run({ ...parent, ...context }, fn);
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Read the active caller context, or an empty object outside any caller scope.
|
|
24
|
+
*
|
|
25
|
+
* Read on the outbound HTTP path to set a telemetry header, so a failure here
|
|
26
|
+
* must never break the request — it falls back to an empty context.
|
|
27
|
+
*/
|
|
28
|
+
export function getCallerContext() {
|
|
29
|
+
try {
|
|
30
|
+
return callerContext.get() ?? {};
|
|
31
|
+
}
|
|
32
|
+
catch {
|
|
33
|
+
return {};
|
|
34
|
+
}
|
|
35
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zapier/zapier-sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.74.0",
|
|
4
4
|
"description": "Complete Zapier SDK - combines all Zapier SDK packages",
|
|
5
5
|
"main": "dist/index.cjs",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -95,7 +95,7 @@
|
|
|
95
95
|
"tsup": "^8.5.0",
|
|
96
96
|
"typescript": "^5.8.3",
|
|
97
97
|
"vitest": "^4.1.4",
|
|
98
|
-
"kitcore": "0.0
|
|
98
|
+
"kitcore": "0.1.0"
|
|
99
99
|
},
|
|
100
100
|
"scripts": {
|
|
101
101
|
"build": "tsup",
|