@zapier/zapier-sdk 0.120.0 → 0.122.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 +34 -0
- package/README.md +65 -47
- package/dist/beta.cjs +287 -287
- package/dist/beta.d.mts +244 -116
- package/dist/beta.d.ts +244 -116
- package/dist/beta.mjs +2 -2
- package/dist/{chunk-VLYXR2T6.cjs → chunk-5H5J5AKU.cjs} +1 -1
- package/dist/{chunk-CYPVUHGJ.cjs → chunk-AUBIZWYI.cjs} +237 -109
- package/dist/{chunk-ZSALKPF6.mjs → chunk-FYLZ2LZO.mjs} +1 -1
- package/dist/{chunk-CKZGXKRK.mjs → chunk-PHEZB6T2.mjs} +150 -22
- package/dist/experimental.cjs +321 -321
- package/dist/experimental.d.mts +256 -128
- package/dist/experimental.d.ts +256 -128
- package/dist/experimental.mjs +7 -7
- package/dist/{index-CThNTXl2.d.mts → index-BnMxdUcw.d.mts} +2 -2
- package/dist/{index-CThNTXl2.d.ts → index-BnMxdUcw.d.ts} +2 -2
- package/dist/index.cjs +281 -281
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.mjs +1 -1
- package/package.json +3 -3
|
@@ -2842,7 +2842,7 @@ function logRouteOverride({
|
|
|
2842
2842
|
}
|
|
2843
2843
|
|
|
2844
2844
|
// src/sdk-version.ts
|
|
2845
|
-
var SDK_VERSION = (typeof process !== "undefined" && process.env ? "0.
|
|
2845
|
+
var SDK_VERSION = (typeof process !== "undefined" && process.env ? "0.122.0" : void 0) || "unknown";
|
|
2846
2846
|
|
|
2847
2847
|
// src/utils/open-url.ts
|
|
2848
2848
|
var nodePrefix = "node:";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { taxonomy, DEFAULT_PAGE_SIZE, apiPluginRef, workflowIdResolver, extractErrorDetail, ZapierApiError, durableRunIdResolver, ZapierConflictError, workflowVersionIdResolver, workflowDraftIdResolver, workflowRunIdResolver, workflowDraftRevisionResolver, isZapierNotFoundError, ZapierTimeoutError, zapierSdkPlugin, SDK_VERSION, ZapierValidationError, sleep, zapierCoreOptions, SDK_OPTIONS_ID } from './chunk-
|
|
1
|
+
import { taxonomy, DEFAULT_PAGE_SIZE, apiPluginRef, workflowIdResolver, extractErrorDetail, ZapierApiError, durableRunIdResolver, ZapierConflictError, workflowVersionIdResolver, workflowDraftIdResolver, workflowRunIdResolver, workflowDraftRevisionResolver, isZapierNotFoundError, ZapierTimeoutError, zapierSdkPlugin, SDK_VERSION, ZapierValidationError, sleep, zapierCoreOptions, SDK_OPTIONS_ID } from './chunk-FYLZ2LZO.mjs';
|
|
2
2
|
import { defineMethod, openEnum, defineResolver, definePlugin, createSdk, CORE_OPTIONS_ID } from '@zapier/kitcore';
|
|
3
3
|
import { z } from 'zod';
|
|
4
4
|
|
|
@@ -787,8 +787,8 @@ var RunErrorSchema = z.object({
|
|
|
787
787
|
var RunItemSchema = z.object({
|
|
788
788
|
id: z.string().describe("Run ID (UUID)"),
|
|
789
789
|
status: RunStatusSchema,
|
|
790
|
-
input: z.unknown().describe("Input data passed to the run"),
|
|
791
|
-
output: z.unknown().nullable().describe("Return value, present when status is `finished`"),
|
|
790
|
+
input: z.unknown().optional().describe("Input data passed to the run"),
|
|
791
|
+
output: z.unknown().nullable().optional().describe("Return value, present when status is `finished`"),
|
|
792
792
|
error: RunErrorSchema.nullable().describe(
|
|
793
793
|
"Structured error details when the run failed (null otherwise)"
|
|
794
794
|
),
|
|
@@ -901,7 +901,7 @@ var ExecutionSummarySchema = z.object({
|
|
|
901
901
|
id: z.string().describe("Execution ID (UUID)"),
|
|
902
902
|
name: z.string().describe("Durable function name"),
|
|
903
903
|
status: ExecutionStatusSchema,
|
|
904
|
-
input: z.unknown().describe("Input passed when the execution was created"),
|
|
904
|
+
input: z.unknown().optional().describe("Input passed when the execution was created"),
|
|
905
905
|
output: z.unknown().optional().describe("Return value when status is `completed`"),
|
|
906
906
|
error: z.unknown().optional().describe("Error details when status is `failed`"),
|
|
907
907
|
metadata: z.record(z.string(), z.unknown()).optional().describe(
|
|
@@ -934,8 +934,8 @@ var GetDurableRunOptionsSchema = z.object({
|
|
|
934
934
|
var GetDurableRunResponseSchema = z.object({
|
|
935
935
|
id: z.string().describe("Run ID (UUID)"),
|
|
936
936
|
status: RunStatusSchema,
|
|
937
|
-
input: z.unknown().describe("Input data passed to the run"),
|
|
938
|
-
output: z.unknown().nullable().describe("Return value, present when status is `finished`"),
|
|
937
|
+
input: z.unknown().optional().describe("Input data passed to the run"),
|
|
938
|
+
output: z.unknown().nullable().optional().describe("Return value, present when status is `finished`"),
|
|
939
939
|
error: RunErrorSchema.nullable().describe(
|
|
940
940
|
"Structured error details when the run failed (null otherwise)"
|
|
941
941
|
),
|
|
@@ -1892,8 +1892,8 @@ var workflowRunListItemBase = z.object({
|
|
|
1892
1892
|
"Linked code-substrate-runner run ID. Null until the durable run is created."
|
|
1893
1893
|
),
|
|
1894
1894
|
status: WorkflowRunStatusSchema,
|
|
1895
|
-
input: z.unknown().describe("Input passed to the run"),
|
|
1896
|
-
error: z.unknown().nullable().describe("Error payload when status is `failed` (null otherwise)"),
|
|
1895
|
+
input: z.unknown().optional().describe("Input passed to the run"),
|
|
1896
|
+
error: z.unknown().nullable().optional().describe("Error payload when status is `failed` (null otherwise)"),
|
|
1897
1897
|
created_at: z.string().describe("When the run was created (ISO-8601)"),
|
|
1898
1898
|
updated_at: z.string().describe("When the run was last updated (ISO-8601)")
|
|
1899
1899
|
});
|
|
@@ -1959,9 +1959,9 @@ var workflowRunBase = z.object({
|
|
|
1959
1959
|
"Linked code-substrate-runner run ID. Null until the durable run is created."
|
|
1960
1960
|
),
|
|
1961
1961
|
status: WorkflowRunStatusSchema,
|
|
1962
|
-
input: z.unknown().describe("Input passed to the run"),
|
|
1963
|
-
output: z.unknown().nullable().describe("Return value, present when status is `finished`"),
|
|
1964
|
-
error: z.unknown().nullable().describe("Error payload when status is `failed` (null otherwise)"),
|
|
1962
|
+
input: z.unknown().optional().describe("Input passed to the run"),
|
|
1963
|
+
output: z.unknown().nullable().optional().describe("Return value, present when status is `finished`"),
|
|
1964
|
+
error: z.unknown().nullable().optional().describe("Error payload when status is `failed` (null otherwise)"),
|
|
1965
1965
|
created_at: z.string().describe("When the run was created (ISO-8601)"),
|
|
1966
1966
|
updated_at: z.string().describe("When the run was last updated (ISO-8601)")
|
|
1967
1967
|
});
|
|
@@ -2045,9 +2045,9 @@ var RunWorkflowDraftResponseSchema = z.object({
|
|
|
2045
2045
|
),
|
|
2046
2046
|
draft_revision: z.number().int().describe("The draft's revision at the moment this run was created."),
|
|
2047
2047
|
status: WorkflowRunStatusSchema,
|
|
2048
|
-
input: z.unknown().describe("Input passed to the run"),
|
|
2049
|
-
output: z.unknown().nullable().describe("Return value, present when status is `finished`"),
|
|
2050
|
-
error: z.unknown().nullable().describe("Error payload when status is `failed` (null otherwise)"),
|
|
2048
|
+
input: z.unknown().optional().describe("Input passed to the run"),
|
|
2049
|
+
output: z.unknown().nullable().optional().describe("Return value, present when status is `finished`"),
|
|
2050
|
+
error: z.unknown().nullable().optional().describe("Error payload when status is `failed` (null otherwise)"),
|
|
2051
2051
|
created_at: z.string().describe("When the run was created (ISO-8601)"),
|
|
2052
2052
|
updated_at: z.string().describe("When the run was last updated (ISO-8601)")
|
|
2053
2053
|
});
|
|
@@ -2164,9 +2164,9 @@ var GetTriggerRunResponseSchema = z.object({
|
|
|
2164
2164
|
),
|
|
2165
2165
|
workflow_version_id: z.string().nullable().describe("Workflow version the run is bound to"),
|
|
2166
2166
|
status: WorkflowRunStatusSchema,
|
|
2167
|
-
input: z.unknown().describe("Input passed to the run"),
|
|
2168
|
-
output: z.unknown().nullable().describe("Return value, present when status is `finished`"),
|
|
2169
|
-
error: z.unknown().nullable().describe("Error payload when status is `failed` (null otherwise)"),
|
|
2167
|
+
input: z.unknown().optional().describe("Input passed to the run"),
|
|
2168
|
+
output: z.unknown().nullable().optional().describe("Return value, present when status is `finished`"),
|
|
2169
|
+
error: z.unknown().nullable().optional().describe("Error payload when status is `failed` (null otherwise)"),
|
|
2170
2170
|
created_at: z.string().describe("When the run was created (ISO-8601)"),
|
|
2171
2171
|
updated_at: z.string().describe("When the run was last updated (ISO-8601)")
|
|
2172
2172
|
});
|
|
@@ -2315,7 +2315,10 @@ var runWorkflowPlugin = defineMethod({
|
|
|
2315
2315
|
});
|
|
2316
2316
|
var MAX_SOURCE_FILES_COUNT = 50;
|
|
2317
2317
|
var MAX_SOURCE_FILE_LENGTH = 2e5;
|
|
2318
|
+
var MAX_TRIGGER_CONFIGURATIONS_COUNT = 20;
|
|
2319
|
+
var MAX_CONNECTIONS_COUNT = 100;
|
|
2318
2320
|
var DEFAULT_ENTRYPOINT_FILE = "/workflow.ts";
|
|
2321
|
+
var TRIGGER_NODE_ID_PATTERN = /^workflow-trigger-[0-9]+$/;
|
|
2319
2322
|
var EXAMPLE_SOURCE_FILES = {
|
|
2320
2323
|
[DEFAULT_ENTRYPOINT_FILE]: 'import { defineDurable } from "@zapier/zapier-durable"; export default defineDurable({ name: "hello-world", run: async (ctx) => { return ctx.step("greet", async () => "Hello, world!"); } });'
|
|
2321
2324
|
};
|
|
@@ -2327,10 +2330,65 @@ var WorkflowValidationSourceFilesSchema = z.record(
|
|
|
2327
2330
|
}).refine((files) => Object.keys(files).length <= MAX_SOURCE_FILES_COUNT, {
|
|
2328
2331
|
message: `sourceFiles must contain at most ${MAX_SOURCE_FILES_COUNT} files`
|
|
2329
2332
|
}).describe("Exact TypeScript sources keyed by absolute logical path.").meta({ example: EXAMPLE_SOURCE_FILES });
|
|
2333
|
+
var WorkflowCheckGroupSchema = z.enum(["source", "access"]).describe(
|
|
2334
|
+
"`source` runs checks that read only the request. `access` looks up the app, action, connection, and trigger references against Zapier and the caller's account."
|
|
2335
|
+
);
|
|
2336
|
+
var WorkflowIssueSeveritySchema = z.enum(["error", "warning", "info", "hint"]).describe("Diagnostic severity.");
|
|
2337
|
+
var WorkflowValidationTriggerSchema = z.object({
|
|
2338
|
+
selectedApi: z.string().optional().describe(
|
|
2339
|
+
"Zapier implementation id the trigger is published with, e.g. `ScheduleCLIAPI@1.6.0`. Checked for a version pin and, with `action`, that the trigger exists."
|
|
2340
|
+
),
|
|
2341
|
+
app: z.string().optional().describe("Key of the app the trigger belongs to."),
|
|
2342
|
+
appTitle: z.string().optional().describe("Display name of the app the trigger belongs to."),
|
|
2343
|
+
action: z.string().optional().describe("Trigger action key on the app."),
|
|
2344
|
+
actionTitle: z.string().optional().describe("Display name of the trigger action."),
|
|
2345
|
+
params: z.record(z.string(), z.unknown()).optional().describe(
|
|
2346
|
+
"Trigger settings keyed by field key. When set, checked against the trigger's fields."
|
|
2347
|
+
)
|
|
2348
|
+
}).describe("Trigger configuration for one trigger node.");
|
|
2330
2349
|
var ValidateWorkflowOptionsSchema = z.object({
|
|
2331
2350
|
sourceFiles: WorkflowValidationSourceFilesSchema,
|
|
2332
2351
|
entrypointFile: z.string().regex(/^\//, "entrypointFile must start with /").optional().describe(
|
|
2333
2352
|
"Absolute logical path of the entry file in sourceFiles. Defaults to /workflow.ts."
|
|
2353
|
+
),
|
|
2354
|
+
zapierDurableVersion: z.string().min(1).optional().describe(
|
|
2355
|
+
'Version of @zapier/zapier-durable the workflow will run on, e.g. "1.2.3". Version checks are skipped when omitted or "latest".'
|
|
2356
|
+
),
|
|
2357
|
+
dependencies: z.record(z.string(), z.string()).optional().describe(
|
|
2358
|
+
"npm package dependencies keyed by package name. Dependency checks are skipped when omitted."
|
|
2359
|
+
),
|
|
2360
|
+
checkGroups: z.array(WorkflowCheckGroupSchema).min(1).refine((groups) => new Set(groups).size === groups.length, {
|
|
2361
|
+
message: "checkGroups must not repeat a group"
|
|
2362
|
+
}).optional().describe(
|
|
2363
|
+
"Check groups to run. Runs every group when omitted. Pass only `source` to skip the account lookups, e.g. while code is being edited."
|
|
2364
|
+
),
|
|
2365
|
+
severity: WorkflowIssueSeveritySchema.optional().describe(
|
|
2366
|
+
"Return only issues with exactly this severity, and skip checks that only report other severities. Returns every issue when omitted."
|
|
2367
|
+
),
|
|
2368
|
+
triggerConfigurations: z.record(z.string(), WorkflowValidationTriggerSchema).superRefine((triggers, ctx) => {
|
|
2369
|
+
for (const key of Object.keys(triggers)) {
|
|
2370
|
+
if (!TRIGGER_NODE_ID_PATTERN.test(key)) {
|
|
2371
|
+
ctx.addIssue({
|
|
2372
|
+
code: "custom",
|
|
2373
|
+
message: `triggerConfigurations keys must be trigger node ids like workflow-trigger-0; got '${key}'`
|
|
2374
|
+
});
|
|
2375
|
+
}
|
|
2376
|
+
}
|
|
2377
|
+
}).refine(
|
|
2378
|
+
(triggers) => Object.keys(triggers).length <= MAX_TRIGGER_CONFIGURATIONS_COUNT,
|
|
2379
|
+
{
|
|
2380
|
+
message: `triggerConfigurations must contain at most ${MAX_TRIGGER_CONFIGURATIONS_COUNT} triggers`
|
|
2381
|
+
}
|
|
2382
|
+
).optional().describe(
|
|
2383
|
+
'Trigger configurations keyed by trigger node id (`workflow-trigger-{i}`). The trigger isn\'t in the source, so it\'s only checked when sent, e.g. `{ "workflow-trigger-0": { "selectedApi": "ScheduleCLIAPI@1.6.0", "action": "everyDay" } }`.'
|
|
2384
|
+
),
|
|
2385
|
+
connections: z.record(z.string(), ConnectionBindingSchema).refine(
|
|
2386
|
+
(connections) => Object.keys(connections).length <= MAX_CONNECTIONS_COUNT,
|
|
2387
|
+
{
|
|
2388
|
+
message: `connections must contain at most ${MAX_CONNECTIONS_COUNT} aliases`
|
|
2389
|
+
}
|
|
2390
|
+
).optional().describe(
|
|
2391
|
+
'Named connection aliases the source uses. Maps each alias to its Zapier connection ID, e.g. `{ "slack": { "connectionId": 123 } }`. Aliases are only checked when sent.'
|
|
2334
2392
|
)
|
|
2335
2393
|
}).refine(
|
|
2336
2394
|
({ sourceFiles, entrypointFile }) => (entrypointFile ?? DEFAULT_ENTRYPOINT_FILE) in sourceFiles,
|
|
@@ -2353,11 +2411,29 @@ var WorkflowValidationIssueSchema = z.object({
|
|
|
2353
2411
|
"Extensible diagnostic category; clients must accept unfamiliar values."
|
|
2354
2412
|
),
|
|
2355
2413
|
message: z.string().describe("Safe human-readable explanation."),
|
|
2356
|
-
|
|
2357
|
-
|
|
2358
|
-
|
|
2359
|
-
severity:
|
|
2414
|
+
title: z.string().optional().describe(
|
|
2415
|
+
"Short label for the issue, safe to show in place of `message` where space is short. Omitted for kinds with no title yet; fall back to `message`."
|
|
2416
|
+
),
|
|
2417
|
+
severity: WorkflowIssueSeveritySchema,
|
|
2360
2418
|
suggestion: z.string().optional().describe("Actionable fix hint."),
|
|
2419
|
+
fix: z.string().optional().describe(
|
|
2420
|
+
"Extensible: what resolves the issue. Known values are `agent` (change the source), `upgrade` (change the account's plan) and `retry` (a lookup failed; validate again). Omitted or unknown means `agent`."
|
|
2421
|
+
),
|
|
2422
|
+
incomplete: z.boolean().optional().describe(
|
|
2423
|
+
"`true` when the issue means the workflow isn't finished yet rather than wrong, e.g. no steps yet. Still blocks publish."
|
|
2424
|
+
),
|
|
2425
|
+
app_key: z.string().optional().describe(
|
|
2426
|
+
"Implementation id of the app the issue is about, e.g. `SlackCLIAPI`. Set on `admin-restricted-app`."
|
|
2427
|
+
),
|
|
2428
|
+
connection_id: z.string().optional().describe(
|
|
2429
|
+
"Zapier connection id the issue is about, as a string. Set on connection issues."
|
|
2430
|
+
),
|
|
2431
|
+
connection_alias: z.string().optional().describe(
|
|
2432
|
+
"Connection alias the source used, a key of the request's `connections`. Set on connection issues when the source named the connection by alias."
|
|
2433
|
+
),
|
|
2434
|
+
unchecked_kind: z.string().optional().describe(
|
|
2435
|
+
"On `check-unavailable`, the issue kind whose check couldn't run because a lookup failed. Validating again retries it."
|
|
2436
|
+
),
|
|
2361
2437
|
source: WorkflowValidationSourceLocationSchema.optional().describe(
|
|
2362
2438
|
"Affected source location."
|
|
2363
2439
|
),
|
|
@@ -2366,6 +2442,19 @@ var WorkflowValidationIssueSchema = z.object({
|
|
|
2366
2442
|
),
|
|
2367
2443
|
syntax_kind: z.string().optional().describe(
|
|
2368
2444
|
"TypeScript AST node kind the diagnostic was raised against (e.g. `CallExpression`)."
|
|
2445
|
+
),
|
|
2446
|
+
state_path: z.string().optional().describe("Workflow state path the issue is about."),
|
|
2447
|
+
projection_node_id: z.string().optional().describe(
|
|
2448
|
+
"Diagram node the issue is about. Validation sets it only on trigger issues, to the trigger node id (`workflow-trigger-{i}`)."
|
|
2449
|
+
),
|
|
2450
|
+
configuration_id: z.string().optional().describe(
|
|
2451
|
+
"Canonical configuration reference. Validation currently leaves it unset."
|
|
2452
|
+
),
|
|
2453
|
+
operation_id: z.string().optional().describe(
|
|
2454
|
+
"Canonical operation that owns the issue, when unambiguous. Match against diagram nodes' `operation_ids` for the same source."
|
|
2455
|
+
),
|
|
2456
|
+
region_id: z.string().optional().describe(
|
|
2457
|
+
"Immediate canonical parent region of the owning operation. May have no visible container in the diagram."
|
|
2369
2458
|
)
|
|
2370
2459
|
});
|
|
2371
2460
|
var ValidateWorkflowResponseSchema = z.object({
|
|
@@ -2373,6 +2462,24 @@ var ValidateWorkflowResponseSchema = z.object({
|
|
|
2373
2462
|
});
|
|
2374
2463
|
|
|
2375
2464
|
// src/plugins/codeSubstrate/validateWorkflow/index.ts
|
|
2465
|
+
function toWireTriggerConfigurations(triggers) {
|
|
2466
|
+
return Object.fromEntries(
|
|
2467
|
+
Object.entries(triggers).map(([nodeId, trigger]) => {
|
|
2468
|
+
const wire = {};
|
|
2469
|
+
if (trigger.selectedApi !== void 0) {
|
|
2470
|
+
wire.selected_api = trigger.selectedApi;
|
|
2471
|
+
}
|
|
2472
|
+
if (trigger.app !== void 0) wire.app_key = trigger.app;
|
|
2473
|
+
if (trigger.appTitle !== void 0) wire.app_title = trigger.appTitle;
|
|
2474
|
+
if (trigger.action !== void 0) wire.action_key = trigger.action;
|
|
2475
|
+
if (trigger.actionTitle !== void 0) {
|
|
2476
|
+
wire.action_title = trigger.actionTitle;
|
|
2477
|
+
}
|
|
2478
|
+
if (trigger.params !== void 0) wire.params = trigger.params;
|
|
2479
|
+
return [nodeId, wire];
|
|
2480
|
+
})
|
|
2481
|
+
);
|
|
2482
|
+
}
|
|
2376
2483
|
var validateWorkflowPlugin = defineMethod({
|
|
2377
2484
|
...codeSubstrateDefaults,
|
|
2378
2485
|
name: "validateWorkflow",
|
|
@@ -2390,10 +2497,31 @@ var validateWorkflowPlugin = defineMethod({
|
|
|
2390
2497
|
if (input.entrypointFile !== void 0) {
|
|
2391
2498
|
body.entrypoint_file = input.entrypointFile;
|
|
2392
2499
|
}
|
|
2500
|
+
if (input.zapierDurableVersion !== void 0) {
|
|
2501
|
+
body.zapier_durable_version = input.zapierDurableVersion;
|
|
2502
|
+
}
|
|
2503
|
+
if (input.dependencies !== void 0) {
|
|
2504
|
+
body.dependencies = input.dependencies;
|
|
2505
|
+
}
|
|
2506
|
+
if (input.checkGroups !== void 0) {
|
|
2507
|
+
body.check_groups = input.checkGroups;
|
|
2508
|
+
}
|
|
2509
|
+
if (input.triggerConfigurations !== void 0) {
|
|
2510
|
+
body.trigger_configurations = toWireTriggerConfigurations(
|
|
2511
|
+
input.triggerConfigurations
|
|
2512
|
+
);
|
|
2513
|
+
}
|
|
2514
|
+
if (input.connections !== void 0) {
|
|
2515
|
+
body.connections = toWireConnections(input.connections);
|
|
2516
|
+
}
|
|
2393
2517
|
const raw = await imports.api.post(
|
|
2394
2518
|
`${CODE_SUBSTRATE_ANALYZER_API}/validations`,
|
|
2395
2519
|
body,
|
|
2396
|
-
{
|
|
2520
|
+
{
|
|
2521
|
+
authRequired: true,
|
|
2522
|
+
// The analyzer rejects `severity` in the body; it is a query parameter.
|
|
2523
|
+
...input.severity === void 0 ? {} : { searchParams: { severity: input.severity } }
|
|
2524
|
+
}
|
|
2397
2525
|
);
|
|
2398
2526
|
return { data: ValidateWorkflowResponseSchema.parse(raw) };
|
|
2399
2527
|
}
|