@zapier/zapier-sdk 0.120.0 → 0.121.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 +20 -0
- package/README.md +39 -21
- package/dist/beta.cjs +287 -287
- package/dist/beta.d.mts +128 -0
- package/dist/beta.d.ts +128 -0
- package/dist/beta.mjs +2 -2
- package/dist/{chunk-VLYXR2T6.cjs → chunk-C7DJO3NC.cjs} +1 -1
- package/dist/{chunk-ZSALKPF6.mjs → chunk-FEGI2THT.mjs} +1 -1
- package/dist/{chunk-CYPVUHGJ.cjs → chunk-KHOLWDHF.cjs} +221 -93
- package/dist/{chunk-CKZGXKRK.mjs → chunk-UGG7545M.mjs} +134 -6
- package/dist/experimental.cjs +318 -318
- package/dist/experimental.d.mts +170 -42
- package/dist/experimental.d.ts +170 -42
- package/dist/experimental.mjs +4 -4
- package/dist/index.cjs +281 -281
- package/dist/index.mjs +1 -1
- package/package.json +1 -1
|
@@ -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-FEGI2THT.mjs';
|
|
2
2
|
import { defineMethod, openEnum, defineResolver, definePlugin, createSdk, CORE_OPTIONS_ID } from '@zapier/kitcore';
|
|
3
3
|
import { z } from 'zod';
|
|
4
4
|
|
|
@@ -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
|
}
|