@zapier/zapier-sdk 0.99.0 → 0.101.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.
@@ -1,5 +1,5 @@
1
- import { defineMethod, DEFAULT_PAGE_SIZE, apiPluginRef, workflowIdResolver, openEnum, durableRunIdResolver, defineResolver, ZapierConflictError, extractErrorDetail, workflowVersionIdResolver, workflowDraftIdResolver, ZapierApiError, workflowRunIdResolver, definePlugin, zapierSdkPlugin, ZapierValidationError, ZapierConfigurationError, createSdk, zapierCoreOptions, CORE_OPTIONS_ID, SDK_OPTIONS_ID } from './chunk-VXVMVORI.mjs';
2
- export { ACTION_RUNS_PATH, API_ID, ActionKeyPropertySchema, ActionPropertySchema, ActionTimeoutMillisecondsPropertySchema, ActionTimeoutSecondsPropertySchema, ActionTypePropertySchema, AppKeyPropertySchema, AppPropertySchema, AppsPropertySchema, AuthMechanism, AuthenticationIdPropertySchema, BaseSdkOptionsSchema, CONNECTIONS_ID, CONTEXT, CONTEXT_CACHE_MAX_SIZE, CONTEXT_CACHE_TTL_MILLISECONDS, CORE_ERROR_SYMBOL, CORE_OPTIONS_ID, CORE_SIGNAL_SYMBOL, ClientCredentialsObjectSchema, ConnectionEntrySchema, ConnectionIdPropertySchema, ConnectionPropertySchema, ConnectionsMapSchema, ConnectionsPropertySchema, CoreCancelledSignal, CoreDisposeError, CoreErrorCode, CoreSignal, CredentialsFunctionSchema, CredentialsObjectSchema, CredentialsSchema, DEFAULT_ACTION_TIMEOUT_MILLISECONDS, DEFAULT_APPROVAL_TIMEOUT_MILLISECONDS, DEFAULT_CONFIG_PATH, DEFAULT_MAX_APPROVAL_RETRIES, DEFAULT_PAGE_SIZE, DEPRECATION_NOTICE_EVENT, DebugPropertySchema, DrainTriggerInboxSchema, EVENT_EMISSION_ID, FieldsPropertySchema, InputFieldPropertySchema, InputsPropertySchema, LeaseLimitPropertySchema, LeasePropertySchema, LeaseSecondsPropertySchema, LimitPropertySchema, MANIFEST_ID, MAX_CONCURRENCY_LIMIT, MAX_PAGE_LIMIT, OffsetPropertySchema, OutputPropertySchema, ParamsPropertySchema, PkceCredentialsObjectSchema, RESOLVE_CREDENTIALS_ID, RecordPropertySchema, RecordsPropertySchema, RelayFetchSchema, RelayRequestSchema, ResolvedCredentialsSchema, SDK_OPTIONS_ID, TablePropertySchema, TablesPropertySchema, TriggerInboxKeyPropertySchema, TriggerInboxNamePropertySchema, TriggerInboxPropertySchema, WatchTriggerInboxSchema, ZAPIER_BASE_URL, ZAPIER_MAX_CONCURRENT_REQUESTS, ZAPIER_MAX_NETWORK_RETRIES, ZAPIER_MAX_NETWORK_RETRY_DELAY_MILLISECONDS, ZapierAbortDrainSignal, ZapierActionError, ZapierApiError, ZapierAppNotFoundError, ZapierApprovalError, ZapierAuthenticationError, ZapierBundleError, ZapierConfigurationError, ZapierConflictError, ZapierError, ZapierNotFoundError, ZapierRateLimitError, ZapierRelayError, ZapierReleaseTriggerMessageSignal, ZapierResourceNotFoundError, ZapierSignal, ZapierTimeoutError, ZapierUnknownError, ZapierValidationError, actionKeyResolver, actionTypeResolver, addPlugin, apiPlugin, apiPluginRef, appKeyResolver, appsPlugin, batch, buildApplicationLifecycleEvent, buildCapabilityMessage, buildErrorEvent, buildErrorEventWithContext, buildMethodCalledEvent, cleanupEventListeners, clearTokenCache, clientCredentialsNameResolver, clientIdResolver, composePlugins, connectionIdGenericResolver, connectionIdResolver, connectionsPlugin, connectionsPluginRef, createActionRunPlugin, createBaseEvent, createClientCredentialsPlugin, createController, createCorePlugin, createFunction, createMemoryCache, createPaginatedFunction, createPaginatedPluginMethod, createPluginMethod, createPluginStack, createSdk, createTableFieldsPlugin, createTablePlugin, createTableRecordsPlugin, createZapierApi, createZapierSdkWithoutRegistry, declareMethod, declareOptionalProperty, declarePlugin, declareProperty, defineFormatter, defineLegacyMerge, defineMethod, defineMethodOverride, defineOverride, definePlugin, defineProperty, defineResolver, deleteClientCredentialsPlugin, deleteTableFieldsPlugin, deleteTablePlugin, deleteTableRecordsPlugin, disposeSdk, durableRunIdResolver, eventEmissionHookPlugin, eventEmissionPlugin, eventEmissionPluginRef, fetchPlugin, findFirstConnectionPlugin, findManifestEntry, findUniqueConnectionPlugin, formatErrorMessage, fromFunctionPlugin, generateEventId, getActionInputFieldsSchemaPlugin, getActionPlugin, getActionRunPlugin, getAgent, getAppPlugin, getBaseUrlFromCredentials, getCallerContext, getCiPlatform, getClientIdFromCredentials, getConnectionPlugin, getContext, getCoreErrorCause, getCoreErrorCode, getCpuTime, getCurrentTimestamp, getMemoryUsage, getNegatable, getOrCreateApiClient, getOsInfo, getPlatformVersions, getPreferredManifestEntryKey, getProfilePlugin, getRegistryPlugin, getReleaseId, getTablePlugin, getTableRecordPlugin, getTokenFromCliLogin, getTtyContext, getZapierApprovalMode, getZapierDefaultApprovalMode, getZapierOpenAutoModeApprovalsInBrowser, getZapierSdkService, injectCliLogin, inputFieldKeyResolver, inputsAllOptionalResolver, inputsResolver, invalidateCachedToken, invalidateCredentialsToken, isCi, isCliLoginAvailable, isClientCredentials, isCoreCancelledSignal, isCoreError, isCoreSignal, isCredentialsFunction, isCredentialsObject, isPermanentHttpError, isPkceCredentials, isPositional, isZapierAbortDrainSignal, isZapierActionError, isZapierAppNotFoundError, isZapierApprovalError, isZapierAuthenticationError, isZapierBundleError, isZapierConflictError, isZapierError, isZapierNotFoundError, isZapierRateLimitError, isZapierReleaseTriggerMessageSignal, isZapierResourceNotFoundError, isZapierSignal, isZapierTimeoutError, isZapierValidationError, listActionInputFieldChoicesPlugin, listActionInputFieldsPlugin, listActionsPlugin, listAppsPlugin, listClientCredentialsPlugin, listConnectionsPlugin, listTableFieldsPlugin, listTableRecordsPlugin, listTablesPlugin, logDeprecation, manifestPlugin, manifestPluginRef, omitExports, operationAnnotatorPlugin, parseConcurrencyEnvVar, readManifestFromFile, registryPlugin, requestPlugin, resetDeprecationWarnings, resolveAuth, resolveAuthToken, resolveCredentials, resolveCredentialsFromEnv, resolveCredentialsPlugin, resolveCredentialsPluginRef, resolvePlugin, runActionPlugin, runInMethodScope, runWithCallerContext, runWithTelemetryContext, sdkOptionsPluginRef, selectExports, tableFieldIdsResolver, tableFieldsResolver, tableFiltersResolver, tableIdResolver, tableNameResolver, tableRecordIdResolver, tableRecordIdsResolver, tableRecordsResolver, tableSortResolver, tableUpdateRecordsResolver, toSnakeCase, toTitleCase, triggerInboxResolver, triggerMessagesResolver, updateTableRecordsPlugin, workflowDraftIdResolver, workflowIdResolver, workflowRunIdResolver, workflowVersionIdResolver, zapierAdaptError, zapierCoreOptions, zapierSdkPlugin } from './chunk-VXVMVORI.mjs';
1
+ import { defineMethod, DEFAULT_PAGE_SIZE, apiPluginRef, workflowIdResolver, extractErrorDetail, ZapierApiError, openEnum, durableRunIdResolver, defineResolver, ZapierConflictError, workflowVersionIdResolver, workflowDraftIdResolver, workflowRunIdResolver, definePlugin, zapierSdkPlugin, ZapierValidationError, ZapierConfigurationError, createSdk, zapierCoreOptions, CORE_OPTIONS_ID, SDK_OPTIONS_ID } from './chunk-R6U6HNVF.mjs';
2
+ export { ACTION_RUNS_PATH, API_ID, ActionKeyPropertySchema, ActionPropertySchema, ActionTimeoutMillisecondsPropertySchema, ActionTimeoutSecondsPropertySchema, ActionTypePropertySchema, AppKeyPropertySchema, AppPropertySchema, AppsPropertySchema, AuthMechanism, AuthenticationIdPropertySchema, BaseSdkOptionsSchema, CONNECTIONS_ID, CONTEXT, CONTEXT_CACHE_MAX_SIZE, CONTEXT_CACHE_TTL_MILLISECONDS, CORE_ERROR_SYMBOL, CORE_OPTIONS_ID, CORE_SIGNAL_SYMBOL, ClientCredentialsObjectSchema, ConnectionEntrySchema, ConnectionIdPropertySchema, ConnectionPropertySchema, ConnectionsMapSchema, ConnectionsPropertySchema, CoreCancelledSignal, CoreDisposeError, CoreErrorCode, CoreSignal, CredentialsFunctionSchema, CredentialsObjectSchema, CredentialsSchema, DEFAULT_ACTION_TIMEOUT_MILLISECONDS, DEFAULT_APPROVAL_TIMEOUT_MILLISECONDS, DEFAULT_CONFIG_PATH, DEFAULT_MAX_APPROVAL_RETRIES, DEFAULT_PAGE_SIZE, DEPRECATION_NOTICE_EVENT, DebugPropertySchema, DrainTriggerInboxSchema, EVENT_EMISSION_ID, FieldsPropertySchema, InputFieldPropertySchema, InputsPropertySchema, LeaseLimitPropertySchema, LeasePropertySchema, LeaseSecondsPropertySchema, LimitPropertySchema, MANIFEST_ID, MAX_CONCURRENCY_LIMIT, MAX_PAGE_LIMIT, OffsetPropertySchema, OutputPropertySchema, ParamsPropertySchema, PkceCredentialsObjectSchema, RESOLVE_CREDENTIALS_ID, RecordPropertySchema, RecordsPropertySchema, RelayFetchSchema, RelayRequestSchema, ResolvedCredentialsSchema, SDK_OPTIONS_ID, TablePropertySchema, TablesPropertySchema, TriggerInboxKeyPropertySchema, TriggerInboxNamePropertySchema, TriggerInboxPropertySchema, WatchTriggerInboxSchema, ZAPIER_BASE_URL, ZAPIER_MAX_CONCURRENT_REQUESTS, ZAPIER_MAX_NETWORK_RETRIES, ZAPIER_MAX_NETWORK_RETRY_DELAY_MILLISECONDS, ZapierAbortDrainSignal, ZapierActionError, ZapierApiError, ZapierAppNotFoundError, ZapierApprovalError, ZapierAuthenticationError, ZapierBundleError, ZapierConfigurationError, ZapierConflictError, ZapierError, ZapierNotFoundError, ZapierRateLimitError, ZapierRelayError, ZapierReleaseTriggerMessageSignal, ZapierResourceNotFoundError, ZapierSignal, ZapierTimeoutError, ZapierUnknownError, ZapierValidationError, actionKeyResolver, actionTypeResolver, addPlugin, apiPlugin, apiPluginRef, appKeyResolver, appsPlugin, batch, buildApplicationLifecycleEvent, buildCapabilityMessage, buildErrorEvent, buildErrorEventWithContext, buildMethodCalledEvent, cleanupEventListeners, clearTokenCache, clientCredentialsNameResolver, clientIdResolver, composePlugins, connectionIdGenericResolver, connectionIdResolver, connectionsPlugin, connectionsPluginRef, createActionRunPlugin, createBaseEvent, createClientCredentialsPlugin, createController, createCorePlugin, createFunction, createMemoryCache, createPaginatedFunction, createPaginatedPluginMethod, createPluginMethod, createPluginStack, createSdk, createTableFieldsPlugin, createTablePlugin, createTableRecordsPlugin, createZapierApi, createZapierSdkWithoutRegistry, declareMethod, declareOptionalProperty, declarePlugin, declareProperty, defineFormatter, defineLegacyMerge, defineMethod, defineMethodOverride, defineOverride, definePlugin, defineProperty, defineResolver, deleteClientCredentialsPlugin, deleteTableFieldsPlugin, deleteTablePlugin, deleteTableRecordsPlugin, disposeSdk, durableRunIdResolver, eventEmissionHookPlugin, eventEmissionPlugin, eventEmissionPluginRef, fetchPlugin, findFirstConnectionPlugin, findManifestEntry, findUniqueConnectionPlugin, formatErrorMessage, fromFunctionPlugin, generateEventId, getActionInputFieldsSchemaPlugin, getActionPlugin, getActionRunPlugin, getAgent, getAppPlugin, getBaseUrlFromCredentials, getCallerContext, getCiPlatform, getClientIdFromCredentials, getConnectionPlugin, getContext, getCoreErrorCause, getCoreErrorCode, getCpuTime, getCurrentTimestamp, getMemoryUsage, getNegatable, getOrCreateApiClient, getOsInfo, getPlatformVersions, getPreferredManifestEntryKey, getProfilePlugin, getRegistryPlugin, getReleaseId, getTablePlugin, getTableRecordPlugin, getTokenFromCliLogin, getTtyContext, getZapierApprovalMode, getZapierDefaultApprovalMode, getZapierOpenAutoModeApprovalsInBrowser, getZapierSdkService, injectCliLogin, inputFieldKeyResolver, inputsAllOptionalResolver, inputsResolver, invalidateCachedToken, invalidateCredentialsToken, isCi, isCliLoginAvailable, isClientCredentials, isCoreCancelledSignal, isCoreError, isCoreSignal, isCredentialsFunction, isCredentialsObject, isPermanentHttpError, isPkceCredentials, isPositional, isZapierAbortDrainSignal, isZapierActionError, isZapierAppNotFoundError, isZapierApprovalError, isZapierAuthenticationError, isZapierBundleError, isZapierConflictError, isZapierError, isZapierNotFoundError, isZapierRateLimitError, isZapierReleaseTriggerMessageSignal, isZapierResourceNotFoundError, isZapierSignal, isZapierTimeoutError, isZapierValidationError, listActionInputFieldChoicesPlugin, listActionInputFieldsPlugin, listActionsPlugin, listAppsPlugin, listClientCredentialsPlugin, listConnectionsPlugin, listTableFieldsPlugin, listTableRecordsPlugin, listTablesPlugin, logDeprecation, manifestPlugin, manifestPluginRef, omitExports, operationAnnotatorPlugin, parseConcurrencyEnvVar, readManifestFromFile, registryPlugin, requestPlugin, resetDeprecationWarnings, resolveAuth, resolveAuthToken, resolveCredentials, resolveCredentialsFromEnv, resolveCredentialsPlugin, resolveCredentialsPluginRef, resolvePlugin, runActionPlugin, runInMethodScope, runWithCallerContext, runWithTelemetryContext, sdkOptionsPluginRef, selectExports, tableFieldIdsResolver, tableFieldsResolver, tableFiltersResolver, tableIdResolver, tableNameResolver, tableRecordIdResolver, tableRecordIdsResolver, tableRecordsResolver, tableSortResolver, tableUpdateRecordsResolver, toSnakeCase, toTitleCase, triggerInboxResolver, triggerMessagesResolver, updateTableRecordsPlugin, workflowDraftIdResolver, workflowIdResolver, workflowRunIdResolver, workflowVersionIdResolver, zapierAdaptError, zapierCoreOptions, zapierSdkPlugin } from './chunk-R6U6HNVF.mjs';
3
3
  import './chunk-Y6FXYEAI.mjs';
4
4
  import { z } from 'zod';
5
5
 
@@ -7,6 +7,7 @@ var codeSubstrateDefaults = {
7
7
  categories: ["code-workflow"],
8
8
  experimental: true
9
9
  };
10
+ var CODE_SUBSTRATE_ANALYZER_API = "/code-substrate-analyzer";
10
11
  var CODE_SUBSTRATE_RUNNER_API = "/code-substrate-runner/api/v0";
11
12
  var CODE_SUBSTRATE_WORKFLOWS_API = "/code-substrate-workflows/api/v0";
12
13
  var JsonPayloadSchema = z.preprocess((val) => {
@@ -424,6 +425,111 @@ var createWorkflowPlugin = defineMethod({
424
425
  return { data: CreateWorkflowResponseSchema.parse(raw) };
425
426
  }
426
427
  });
428
+ var ImportWorkflowOptionsSchema = z.object({
429
+ zap: z.string().min(1).max(128).describe(
430
+ "ID of the Zap to import. Must be owned by the requesting user. Recorded on the created workflow as source_zap_id."
431
+ ),
432
+ name: z.string().optional().describe(
433
+ `Name for the created workflow. Defaults to a kebab-cased form of the Zap's title, or "imported-workflow" when the Zap has no title.`
434
+ ),
435
+ private: z.boolean().optional().describe(
436
+ "Restrict the created workflow to the creating user. Defaults to false, which makes it account-visible."
437
+ )
438
+ }).describe(
439
+ "Convert an existing Zap into a durable workflow. Transforms the Zap's latest published version (falling back to its draft only when the Zap has never been published) and puts the resulting source in an open draft. The workflow is created disabled with no published version, so publish the draft to make it live. The original Zap is untouched and keeps running."
440
+ );
441
+ var TranslationIssueSchema = z.object({
442
+ line: z.number().int().describe(
443
+ "1-based line in the generated source the issue relates to, or 0 when not line-specific."
444
+ ),
445
+ column: z.number().int().describe("1-based column, or 0 when not column-specific."),
446
+ node_kind: z.string().describe(
447
+ 'Category of the issue, used to group and message them, e.g. "invalid-connection-id", "DelayStep", "app-version-conflict".'
448
+ ),
449
+ step_name: z.string().optional().describe("ZDL step id or name the issue originated from, when known."),
450
+ message: z.string().describe("Human-readable description of the issue."),
451
+ blocking: z.boolean().describe(
452
+ "Whether the issue must be resolved before the draft can be published. Computed server-side, so callers do not re-derive it. A blocking issue does not prevent the draft being created."
453
+ )
454
+ });
455
+ var ImportedWorkflowSchema = z.object({
456
+ id: z.string().describe("Workflow ID (UUID)"),
457
+ name: z.string().describe("Workflow name"),
458
+ description: z.string().nullable().optional().describe("Optional workflow description (null if unset)"),
459
+ trigger_url: WorkflowTriggerUrlSchema,
460
+ enabled: z.boolean().describe(
461
+ "Whether the workflow accepts triggers. An import always lands disabled."
462
+ ),
463
+ disabled_reason: WorkflowDisabledReasonSchema.nullable().optional().describe("Why the workflow is off, when system-disabled."),
464
+ is_private: z.boolean().describe(
465
+ "Whether the workflow is private to the creating user. False means account-visible."
466
+ ),
467
+ source_zap_id: z.string().nullable().optional().describe("The Zap this workflow was imported from."),
468
+ created_by_user_id: z.string(),
469
+ updated_by_user_id: z.string().nullable().optional(),
470
+ current_version_id: z.string().nullable().optional().describe("Null on a fresh import, which has no published version yet."),
471
+ triggers: z.array(WorkflowTriggerSchema).describe("Empty on a fresh import, which has no published version yet."),
472
+ created_at: z.string(),
473
+ updated_at: z.string().optional()
474
+ });
475
+ var ImportWorkflowResponseSchema = z.object({
476
+ workflow: ImportedWorkflowSchema.describe(
477
+ "The created workflow. Disabled, with no published version, and source_zap_id set to the imported Zap."
478
+ ),
479
+ draft: WorkflowDraftSchema.describe(
480
+ "The open draft holding the transformed source."
481
+ ),
482
+ issues: z.array(TranslationIssueSchema).describe(
483
+ "Blocking and non-blocking translation issues from the transform, passed through unchanged. Blocking issues do not prevent draft creation; they must be resolved before the draft will publish."
484
+ )
485
+ });
486
+
487
+ // src/plugins/codeSubstrate/importWorkflow/index.ts
488
+ var importWorkflowPlugin = defineMethod({
489
+ ...codeSubstrateDefaults,
490
+ name: "importWorkflow",
491
+ imports: [apiPluginRef],
492
+ type: "create",
493
+ itemType: "Workflow",
494
+ // The response is the composite `{ workflow, draft, issues }`, not the bare
495
+ // `WorkflowItem` the docs generator derives from itemType.
496
+ returnType: "ImportWorkflowResponse",
497
+ inputSchema: ImportWorkflowOptionsSchema,
498
+ outputSchema: ImportWorkflowResponseSchema,
499
+ skipOutputValidation: true,
500
+ output: "item",
501
+ run: async ({ imports, input }) => {
502
+ const api = imports.api;
503
+ const body = { zap_id: input.zap };
504
+ if (input.name !== void 0) {
505
+ body.name = input.name;
506
+ }
507
+ if (input.private !== void 0) {
508
+ body.is_private = input.private;
509
+ }
510
+ const raw = await api.post(
511
+ `${CODE_SUBSTRATE_WORKFLOWS_API}/workflows/import`,
512
+ body,
513
+ {
514
+ authRequired: true,
515
+ // Import is owner-gated upstream: the endpoint refuses a Zap the
516
+ // requesting user does not own. A bare 403 tells the caller nothing
517
+ // about which gate they hit or what to do, so name both.
518
+ customErrorHandler: ({ status, data }) => {
519
+ if (status === 403) {
520
+ const detail = extractErrorDetail(data);
521
+ return new ZapierApiError(
522
+ `${detail ?? "Zap import forbidden"} \u2014 only Zaps owned by the requesting user can be imported. Check the Zap ID belongs to this user, or ask its owner to run the import. Retrying will not help.`,
523
+ { statusCode: status }
524
+ );
525
+ }
526
+ return void 0;
527
+ }
528
+ }
529
+ );
530
+ return { data: ImportWorkflowResponseSchema.parse(raw) };
531
+ }
532
+ });
427
533
  var UpdateWorkflowOptionsSchema = z.object({
428
534
  workflow: z.string().uuid().describe("Durable workflow ID"),
429
535
  name: z.string().min(1).optional().describe("New name for the workflow"),
@@ -1844,6 +1950,91 @@ var triggerWorkflowPlugin = defineMethod({
1844
1950
  return { data: TriggerWorkflowResponseSchema.parse(raw) };
1845
1951
  }
1846
1952
  });
1953
+ var MAX_SOURCE_FILES_COUNT = 50;
1954
+ var MAX_SOURCE_FILE_LENGTH = 2e5;
1955
+ var DEFAULT_ENTRYPOINT_FILE = "/workflow.ts";
1956
+ var EXAMPLE_SOURCE_FILES = {
1957
+ [DEFAULT_ENTRYPOINT_FILE]: 'import { defineDurable } from "@zapier/zapier-durable"; export default defineDurable("hello-world", async (ctx, input) => { return ctx.step("greet", async () => "Hello, world!"); });'
1958
+ };
1959
+ var WorkflowValidationSourceFilesSchema = z.record(
1960
+ z.string().regex(/^\//, "source file paths must start with /"),
1961
+ z.string().max(MAX_SOURCE_FILE_LENGTH)
1962
+ ).refine((files) => Object.keys(files).length > 0, {
1963
+ message: "sourceFiles must contain at least one file"
1964
+ }).refine((files) => Object.keys(files).length <= MAX_SOURCE_FILES_COUNT, {
1965
+ message: `sourceFiles must contain at most ${MAX_SOURCE_FILES_COUNT} files`
1966
+ }).describe("Exact TypeScript sources keyed by absolute logical path.").meta({ example: EXAMPLE_SOURCE_FILES });
1967
+ var ValidateWorkflowOptionsSchema = z.object({
1968
+ sourceFiles: WorkflowValidationSourceFilesSchema,
1969
+ entrypointFile: z.string().regex(/^\//, "entrypointFile must start with /").optional().describe(
1970
+ "Absolute logical path of the entry file in sourceFiles. Defaults to /workflow.ts."
1971
+ )
1972
+ }).refine(
1973
+ ({ sourceFiles, entrypointFile }) => (entrypointFile ?? DEFAULT_ENTRYPOINT_FILE) in sourceFiles,
1974
+ {
1975
+ path: ["entrypointFile"],
1976
+ message: "entrypointFile must identify a file in sourceFiles"
1977
+ }
1978
+ ).describe(
1979
+ "Validate durable workflow source without publishing it. Returns source diagnostics; issue kinds are extensible and may be unfamiliar to the client."
1980
+ );
1981
+ var WorkflowValidationSourceLocationSchema = z.object({
1982
+ file_id: z.string().describe("Source file containing the diagnostic."),
1983
+ start_line: z.number().int().positive().describe("Inclusive 1-based start line."),
1984
+ start_column: z.number().int().positive().describe("Inclusive 1-based start column."),
1985
+ end_line: z.number().int().positive().describe("Inclusive 1-based end line."),
1986
+ end_column: z.number().int().positive().describe("Inclusive 1-based end column.")
1987
+ }).describe("1-based source coordinates within a single sourceFiles entry.");
1988
+ var WorkflowValidationIssueSchema = z.object({
1989
+ kind: z.string().describe(
1990
+ "Extensible diagnostic category; clients must accept unfamiliar values."
1991
+ ),
1992
+ message: z.string().describe("Safe human-readable explanation."),
1993
+ // Unlike `kind`, severity is a closed vocabulary on the analyzer side: a
1994
+ // new value requires a new API version, and every issue carries one, so
1995
+ // callers can rank findings without a missing-severity branch.
1996
+ severity: z.enum(["error", "warning", "info", "hint"]).describe("Diagnostic severity."),
1997
+ suggestion: z.string().optional().describe("Actionable fix hint."),
1998
+ source: WorkflowValidationSourceLocationSchema.optional().describe(
1999
+ "Affected source location."
2000
+ ),
2001
+ source_excerpt: z.string().optional().describe(
2002
+ "Source text the diagnostic was raised against, truncated to 240 characters."
2003
+ ),
2004
+ syntax_kind: z.string().optional().describe(
2005
+ "TypeScript AST node kind the diagnostic was raised against (e.g. `CallExpression`)."
2006
+ )
2007
+ });
2008
+ var ValidateWorkflowResponseSchema = z.object({
2009
+ issues: z.array(WorkflowValidationIssueSchema).describe("Source diagnostics, or an empty array when validation passes.")
2010
+ });
2011
+
2012
+ // src/plugins/codeSubstrate/validateWorkflow/index.ts
2013
+ var validateWorkflowPlugin = defineMethod({
2014
+ ...codeSubstrateDefaults,
2015
+ name: "validateWorkflow",
2016
+ imports: [apiPluginRef],
2017
+ itemType: "WorkflowValidation",
2018
+ inputSchema: ValidateWorkflowOptionsSchema,
2019
+ outputSchema: ValidateWorkflowResponseSchema,
2020
+ skipOutputValidation: true,
2021
+ output: "item",
2022
+ resolvers: { sourceFiles: sourceFilesResolver },
2023
+ run: async ({ imports, input }) => {
2024
+ const body = {
2025
+ source_files: input.sourceFiles
2026
+ };
2027
+ if (input.entrypointFile !== void 0) {
2028
+ body.entrypoint_file = input.entrypointFile;
2029
+ }
2030
+ const raw = await imports.api.post(
2031
+ `${CODE_SUBSTRATE_ANALYZER_API}/validations`,
2032
+ body,
2033
+ { authRequired: true }
2034
+ );
2035
+ return { data: ValidateWorkflowResponseSchema.parse(raw) };
2036
+ }
2037
+ });
1847
2038
 
1848
2039
  // src/plugins/humanInput/shared.ts
1849
2040
  var humanInputDefaults = {
@@ -2192,6 +2383,7 @@ var zapierExperimentalSdkPlugin = definePlugin({
2192
2383
  listWorkflowsPlugin,
2193
2384
  getWorkflowPlugin,
2194
2385
  createWorkflowPlugin,
2386
+ importWorkflowPlugin,
2195
2387
  updateWorkflowPlugin,
2196
2388
  enableWorkflowPlugin,
2197
2389
  disableWorkflowPlugin,
@@ -2213,6 +2405,7 @@ var zapierExperimentalSdkPlugin = definePlugin({
2213
2405
  cancelDurableRunPlugin,
2214
2406
  triggerWorkflowPlugin,
2215
2407
  getTriggerRunPlugin,
2408
+ validateWorkflowPlugin,
2216
2409
  // Human input (experimental). Routed through the Public API Gateway
2217
2410
  // rather than the sdkapi proxy — see the `/forms` entry in api/client.ts.
2218
2411
  createFormPlugin