@zapier/zapier-sdk 0.93.0 → 0.94.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.
@@ -4219,6 +4219,7 @@ function getZapierSdkService() {
4219
4219
  var MAX_PAGE_LIMIT = 1e4;
4220
4220
  var DEFAULT_PAGE_SIZE = 100;
4221
4221
  var DEFAULT_ACTION_TIMEOUT_MILLISECONDS = 18e4;
4222
+ var ACTION_RUNS_PATH = "/zapier/api/actions/v1/runs";
4222
4223
  function parseIntEnvVar(name) {
4223
4224
  const value = globalThis.process?.env?.[name];
4224
4225
  if (value === void 0) return void 0;
@@ -6192,7 +6193,7 @@ function parseDeprecationDate(value) {
6192
6193
  }
6193
6194
 
6194
6195
  // src/sdk-version.ts
6195
- var SDK_VERSION = (typeof process !== "undefined" && process.env ? "0.93.0" : void 0) || "unknown";
6196
+ var SDK_VERSION = (typeof process !== "undefined" && process.env ? "0.94.0" : void 0) || "unknown";
6196
6197
 
6197
6198
  // src/utils/open-url.ts
6198
6199
  var nodePrefix = "node:";
@@ -7064,7 +7065,7 @@ var ZapierApiClient = class {
7064
7065
  requiredScopes: options.requiredScopes
7065
7066
  });
7066
7067
  if (typeof result === "string") {
7067
- if (result === "" && (method === "DELETE" || response.status === 204)) {
7068
+ if (result === "" && (method === "DELETE" || response.status === 204 || response.status === 202)) {
7068
7069
  return void 0;
7069
7070
  }
7070
7071
  throw new ZapierValidationError(
@@ -8538,378 +8539,6 @@ var actionResultItemFormatter = defineFormatter({
8538
8539
  };
8539
8540
  }
8540
8541
  });
8541
- var GetActionDescription = "Get detailed information about a specific action";
8542
- var GetActionSchema = zod.z.object({
8543
- app: AppPropertySchema,
8544
- actionType: ActionTypePropertySchema,
8545
- action: ActionPropertySchema
8546
- }).describe(GetActionDescription).meta({ aliases: { appKey: "app", actionKey: "action" } });
8547
- var GetActionSchemaDeprecated = zod.z.object({
8548
- appKey: AppKeyPropertySchema,
8549
- actionType: ActionTypePropertySchema,
8550
- actionKey: ActionKeyPropertySchema
8551
- });
8552
- var GetActionInputSchema = zod.z.union([GetActionSchema, GetActionSchemaDeprecated]).describe(GetActionDescription);
8553
- var ListActionsDescription = "List all actions for a specific app";
8554
- var ListActionsBaseSchema = zod.z.object({
8555
- pageSize: zod.z.number().min(1).optional().describe("Number of actions per page"),
8556
- maxItems: zod.z.number().min(1).optional().describe("Maximum total items to return across all pages"),
8557
- cursor: zod.z.string().optional().describe("Cursor to start from")
8558
- });
8559
- var ListActionsSchema = zod.z.object({
8560
- app: AppPropertySchema.describe(
8561
- "App key of actions to list (e.g., 'SlackCLIAPI' or slug like 'github')"
8562
- ),
8563
- actionType: ActionTypePropertySchema.optional().describe(
8564
- "Filter actions by type"
8565
- )
8566
- }).merge(ListActionsBaseSchema).describe(ListActionsDescription).meta({ aliases: { appKey: "app" } });
8567
- var ListActionsSchemaDeprecated = zod.z.object({
8568
- appKey: AppKeyPropertySchema.describe(
8569
- "App key of actions to list (e.g., 'SlackCLIAPI' or slug like 'github')"
8570
- ),
8571
- actionType: ActionTypePropertySchema.optional().describe(
8572
- "Filter actions by type"
8573
- )
8574
- }).merge(ListActionsBaseSchema);
8575
- var ListActionsInputSchema = zod.z.union([ListActionsSchema, ListActionsSchemaDeprecated]).describe(ListActionsDescription);
8576
- var NeedChoicesSchema = zod.z.object({
8577
- key: zod.z.string().optional(),
8578
- label: zod.z.string().optional(),
8579
- sample: zod.z.string().optional(),
8580
- value: zod.z.string().optional()
8581
- });
8582
- var NeedSchema = zod.z.object({
8583
- key: zod.z.string(),
8584
- alters_custom_fields: zod.z.boolean().nullable().optional(),
8585
- capabilities: zod.z.array(zod.z.string()).optional(),
8586
- choices: zod.z.array(NeedChoicesSchema).optional(),
8587
- computed: zod.z.boolean().nullable().optional(),
8588
- custom_field: zod.z.boolean().optional(),
8589
- default: zod.z.string().optional(),
8590
- depends_on: zod.z.array(zod.z.string()).optional(),
8591
- format: zod.z.literal("SELECT").optional(),
8592
- from_search: zod.z.boolean().optional(),
8593
- from_write: zod.z.boolean().optional(),
8594
- help_text: zod.z.string().optional(),
8595
- help_text_html: zod.z.string().optional(),
8596
- input_format: zod.z.array(zod.z.string()).optional(),
8597
- label: zod.z.string().optional(),
8598
- language: zod.z.string().optional(),
8599
- parent_key: zod.z.string().optional(),
8600
- placeholder: zod.z.string().optional(),
8601
- prefill: zod.z.string().optional(),
8602
- required: zod.z.boolean().optional(),
8603
- searchfill: zod.z.string().optional(),
8604
- send_in_json: zod.z.boolean().optional(),
8605
- regex: zod.z.string().optional(),
8606
- type: zod.z.enum([
8607
- "integer",
8608
- "string",
8609
- "text",
8610
- "datetime",
8611
- "boolean",
8612
- "file",
8613
- "decimal",
8614
- "copy",
8615
- "password",
8616
- "dict",
8617
- "code",
8618
- "filter",
8619
- "json"
8620
- ]).optional(),
8621
- list: zod.z.boolean().optional()
8622
- });
8623
- zod.z.object({
8624
- action_url: zod.z.string().optional()
8625
- });
8626
- zod.z.object({
8627
- can_use: zod.z.boolean().optional()
8628
- });
8629
- var ActionSchema = zod.z.object({
8630
- id: zod.z.string().optional(),
8631
- type: zod.z.enum([
8632
- "filter",
8633
- "read",
8634
- "read_bulk",
8635
- "run",
8636
- "search",
8637
- "search_and_write",
8638
- "search_or_write",
8639
- "write"
8640
- ]),
8641
- key: zod.z.string(),
8642
- name: zod.z.string(),
8643
- description: zod.z.string(),
8644
- is_important: zod.z.boolean().optional(),
8645
- is_hidden: zod.z.boolean().optional(),
8646
- selected_api: zod.z.string().optional()
8647
- });
8648
- var ChoiceSchema = zod.z.object({
8649
- value: zod.z.union([zod.z.string(), zod.z.number()]),
8650
- label: zod.z.string()
8651
- });
8652
- zod.z.object({
8653
- key: zod.z.string(),
8654
- label: zod.z.string(),
8655
- type: zod.z.enum([
8656
- "string",
8657
- "number",
8658
- "boolean",
8659
- "datetime",
8660
- "file",
8661
- "object",
8662
- "array"
8663
- ]),
8664
- required: zod.z.boolean(),
8665
- description: zod.z.string().optional(),
8666
- choices: zod.z.array(ChoiceSchema).optional()
8667
- });
8668
- zod.z.object({
8669
- data: zod.z.array(zod.z.unknown())
8670
- });
8671
- var ActionFieldChoiceSchema = zod.z.object({
8672
- value: zod.z.union([zod.z.string(), zod.z.number()]),
8673
- label: zod.z.string()
8674
- });
8675
- zod.z.object({
8676
- key: zod.z.string(),
8677
- label: zod.z.string().optional(),
8678
- required: zod.z.boolean(),
8679
- type: zod.z.string().optional(),
8680
- helpText: zod.z.string().optional(),
8681
- helpTextHtml: zod.z.string().optional(),
8682
- choices: zod.z.array(ActionFieldChoiceSchema).optional(),
8683
- default: zod.z.string().optional(),
8684
- placeholder: zod.z.string().optional(),
8685
- computed: zod.z.boolean().optional(),
8686
- customField: zod.z.boolean().optional(),
8687
- dependsOn: zod.z.array(zod.z.string()).optional(),
8688
- format: zod.z.string().optional(),
8689
- inputFormat: zod.z.array(zod.z.string()).optional()
8690
- });
8691
- zod.z.object({
8692
- id: zod.z.number(),
8693
- public_id: zod.z.string().optional(),
8694
- code: zod.z.string(),
8695
- user_id: zod.z.number(),
8696
- auto_provisioned: zod.z.boolean(),
8697
- first_name: zod.z.string(),
8698
- last_name: zod.z.string(),
8699
- username: zod.z.string(),
8700
- personas: zod.z.string(),
8701
- user_generated_personas: zod.z.string(),
8702
- last_login: zod.z.string(),
8703
- email: zod.z.string(),
8704
- email_hash: zod.z.string(),
8705
- email_confirmed: zod.z.boolean(),
8706
- timezone: zod.z.string(),
8707
- photo_url: zod.z.string(),
8708
- has_seen_notifications: zod.z.record(zod.z.string(), zod.z.boolean().nullable()),
8709
- signup: zod.z.string(),
8710
- since_signup: zod.z.string(),
8711
- has_activated: zod.z.boolean(),
8712
- enable_gz_creator: zod.z.boolean(),
8713
- should_see_nps_survey: zod.z.boolean(),
8714
- is_developer: zod.z.boolean(),
8715
- is_expert: zod.z.boolean(),
8716
- tos_agreement: zod.z.boolean(),
8717
- should_renew_tos: zod.z.boolean(),
8718
- is_gdpr_consented: zod.z.boolean(),
8719
- disable_ssl_check: zod.z.boolean(),
8720
- identity: zod.z.number(),
8721
- summary_schedule: zod.z.string(),
8722
- alert_triggers: zod.z.string(),
8723
- alert_actions: zod.z.string(),
8724
- is_staff: zod.z.boolean(),
8725
- is_zt_reviewer: zod.z.boolean(),
8726
- is_high_value: zod.z.boolean(),
8727
- is_temporary: zod.z.boolean(),
8728
- banner_message: zod.z.string(),
8729
- enable_totp_2fa: zod.z.boolean(),
8730
- viewed_help: zod.z.record(zod.z.string(), zod.z.boolean()),
8731
- show_editor_migration_mesaging: zod.z.boolean(),
8732
- switches: zod.z.record(zod.z.string(), zod.z.unknown()),
8733
- organizations: zod.z.array(zod.z.record(zod.z.string(), zod.z.unknown()).nullable()),
8734
- primary_organization: zod.z.record(zod.z.string(), zod.z.unknown()).nullable(),
8735
- has_active_zaps: zod.z.boolean(),
8736
- has_google_sso: zod.z.boolean(),
8737
- auth_realm: zod.z.string(),
8738
- roles: zod.z.array(
8739
- zod.z.object({
8740
- account_id: zod.z.number(),
8741
- role: zod.z.string()
8742
- })
8743
- )
8744
- });
8745
- zod.z.object({
8746
- age_in_days: zod.z.string().optional(),
8747
- api_docs_url: zod.z.string().nullable().optional(),
8748
- app_profile_url: zod.z.string(),
8749
- banner: zod.z.string().optional(),
8750
- categories: zod.z.array(zod.z.string()).optional(),
8751
- // Service category names
8752
- canonical_id: zod.z.string().optional(),
8753
- current_implementation_id: zod.z.string(),
8754
- days_since_last_update: zod.z.string().optional(),
8755
- description: zod.z.string(),
8756
- external_url: zod.z.string(),
8757
- hashtag: zod.z.string().optional(),
8758
- id: zod.z.number().optional(),
8759
- image: zod.z.string().optional(),
8760
- images: zod.z.string().optional(),
8761
- integration_overview_html: zod.z.string().nullable().optional(),
8762
- internal_id: zod.z.string(),
8763
- invite_url: zod.z.string().nullable().optional(),
8764
- is_beta: zod.z.string().optional(),
8765
- is_built_in: zod.z.string().optional(),
8766
- is_featured: zod.z.string().optional(),
8767
- is_premium: zod.z.boolean().optional(),
8768
- is_public: zod.z.string().optional(),
8769
- is_upcoming: zod.z.string().optional(),
8770
- learn_more_url: zod.z.string(),
8771
- name: zod.z.string(),
8772
- popularity: zod.z.number(),
8773
- primary_color: zod.z.string(),
8774
- request_count: zod.z.string().optional(),
8775
- slug: zod.z.string(),
8776
- zap_usage_count: zod.z.number().nullable().optional()
8777
- });
8778
- var ServiceSchema = zod.z.object({
8779
- id: zod.z.number().optional(),
8780
- canonical_id: zod.z.string().optional(),
8781
- current_implementation_id: zod.z.string(),
8782
- name: zod.z.string(),
8783
- slug: zod.z.string(),
8784
- app_url: zod.z.string().optional(),
8785
- learn_more_url: zod.z.string().optional(),
8786
- description: zod.z.string(),
8787
- primary_color: zod.z.string(),
8788
- popularity: zod.z.number(),
8789
- image: zod.z.string().optional(),
8790
- images: zod.z.string().optional()
8791
- });
8792
- zod.z.object({
8793
- results: zod.z.array(ServiceSchema),
8794
- next: zod.z.string().nullable().optional(),
8795
- previous: zod.z.string().nullable().optional()
8796
- });
8797
- zod.z.object({
8798
- selected_api: zod.z.string(),
8799
- action: zod.z.string(),
8800
- type_of: zod.z.string(),
8801
- authentication_id: zod.z.union([zod.z.string(), zod.z.number()]).optional(),
8802
- params: zod.z.record(zod.z.string(), zod.z.unknown()).optional()
8803
- });
8804
- zod.z.object({
8805
- success: zod.z.boolean(),
8806
- needs: zod.z.array(NeedSchema).optional(),
8807
- errors: zod.z.array(zod.z.string()).optional(),
8808
- last_fetched_at: zod.z.string().optional(),
8809
- schema: zod.z.record(zod.z.string(), zod.z.unknown()).optional()
8810
- });
8811
- var ImplementationSchema = zod.z.object({
8812
- selected_api: zod.z.string(),
8813
- app_id: zod.z.number().optional(),
8814
- auth_type: zod.z.string().optional(),
8815
- auth_fields: zod.z.string().optional(),
8816
- actions: zod.z.array(ActionSchema).optional(),
8817
- is_deprecated: zod.z.boolean().optional(),
8818
- is_private_only: zod.z.boolean().optional(),
8819
- is_invite_only: zod.z.boolean().optional(),
8820
- is_beta: zod.z.boolean().optional().default(false),
8821
- is_premium: zod.z.boolean().optional().default(false),
8822
- is_hidden: zod.z.string().optional(),
8823
- name: zod.z.string().optional(),
8824
- slug: zod.z.string().optional(),
8825
- images: zod.z.record(zod.z.string(), zod.z.string().nullable()).optional(),
8826
- primary_color: zod.z.string().optional(),
8827
- secondary_color: zod.z.string().optional(),
8828
- current_implementation: zod.z.string().optional(),
8829
- other_implementations: zod.z.string().optional()
8830
- });
8831
- zod.z.object({
8832
- count: zod.z.number(),
8833
- next: zod.z.string().nullable().optional(),
8834
- previous: zod.z.string().nullable().optional(),
8835
- results: zod.z.array(ImplementationSchema)
8836
- });
8837
- var NeedChoicesResponseMetaSchema = zod.z.object({
8838
- page: zod.z.string().nullable().optional()
8839
- });
8840
- var NeedChoicesResponseLinksSchema = zod.z.object({
8841
- next: zod.z.string().nullable().optional(),
8842
- prev: zod.z.string().nullable().optional()
8843
- });
8844
- zod.z.object({
8845
- selected_api: zod.z.string().optional().describe(
8846
- "Something like `SlackAPI` (for Python apps) or `SplitwiseCLIAPI@1.0.0` (for CLI apps). Non-public apps are fine as long as the authed user can access them."
8847
- ),
8848
- authentication_id: zod.z.union([zod.z.string(), zod.z.number()]).optional().describe(
8849
- "If the app needs auth, provide an `authentication_id` that has the `selected_api` of the app you want to run. Can be any auth visible to the user (including shared)."
8850
- ),
8851
- params: zod.z.record(zod.z.string(), zod.z.unknown()).optional().describe(
8852
- "Object that matches the input the node would normally get. Has all the same keys/types as the `needs` of the action."
8853
- ),
8854
- page: zod.z.number().optional().default(0),
8855
- prefill: zod.z.string().optional().describe(
8856
- "The prefill string to indicate what we're fetching choices for. Likely something like `spreadsheet.id.title`. Must be provided alongside `selected_api` if both `action_id` and `input_field_id` are not."
8857
- ),
8858
- action_id: zod.z.string().optional().describe(
8859
- "The id that will be used to lookup the Action for prefill lookup. If provided, `input_field_id` is required, else `prefill` must be provided."
8860
- ),
8861
- input_field_id: zod.z.string().optional().describe(
8862
- "The id (key) of the input field (Need) that dynamic choices are being retrieved for. If provided, `action_id` is required, else `prefill` must be provided."
8863
- )
8864
- });
8865
- zod.z.object({
8866
- success: zod.z.boolean(),
8867
- choices: zod.z.array(NeedChoicesSchema).optional(),
8868
- next_page: zod.z.number().optional(),
8869
- errors: zod.z.array(zod.z.string()).optional(),
8870
- meta: NeedChoicesResponseMetaSchema.optional(),
8871
- links: NeedChoicesResponseLinksSchema.optional()
8872
- });
8873
-
8874
- // src/schemas/Action.ts
8875
- var ActionItemSchema = ActionSchema.omit({
8876
- type: true,
8877
- name: true,
8878
- selected_api: true
8879
- }).extend({
8880
- app_key: zod.z.string(),
8881
- // App key without version (extracted from selected_api)
8882
- app_version: zod.z.string().optional(),
8883
- // Version extracted from selected_api
8884
- action_type: ActionSchema.shape.type,
8885
- // Mapped from original 'type' field
8886
- title: zod.z.string(),
8887
- // Mapped from original 'name' field
8888
- type: zod.z.literal("action")
8889
- // Fixed type identifier
8890
- });
8891
-
8892
- // src/formatters/action.ts
8893
- function formatActionItem(item) {
8894
- const details = [{ text: `Type: ${item.action_type}`, style: "accent" }];
8895
- if (item.app_key) {
8896
- details.push({ text: `App: ${item.app_key}`, style: "normal" });
8897
- }
8898
- if (item.description) {
8899
- details.push({ text: item.description, style: "dim" });
8900
- }
8901
- return {
8902
- title: item.title || item.key,
8903
- // `hint` is the dumb secondary string shown after the title (the action key
8904
- // and, when present, its id). Replaces the deprecated `key`/`id` fields.
8905
- hint: [item.key, item.id].filter((v) => Boolean(v)),
8906
- description: item.description,
8907
- details
8908
- };
8909
- }
8910
- var actionItemFormatter = defineFormatter({
8911
- format: ({ item }) => formatActionItem(item)
8912
- });
8913
8542
 
8914
8543
  // src/resolvers/appKey.ts
8915
8544
  var getAppRef = declareMethod({ id: "getApp" });
@@ -9753,396 +9382,768 @@ async function createFieldKeyTranslator({
9753
9382
  }
9754
9383
  }
9755
9384
  }
9756
- return key;
9385
+ return key;
9386
+ }
9387
+ };
9388
+ }
9389
+
9390
+ // src/resolvers/tableRecordId.ts
9391
+ var listTableRecordsRef = declareMethod({ id: "listTableRecords" });
9392
+ function summarizeRecord(record) {
9393
+ const values = Object.values(record.data);
9394
+ const preview = values.slice(0, 3).map((v) => formatFieldValue(v).replace(/\s+/g, " ").trim()).filter((s) => s.length > 0).join(", ");
9395
+ if (!preview) return void 0;
9396
+ return preview.length > 60 ? preview.slice(0, 57) + "..." : preview;
9397
+ }
9398
+ function recordChoices(records) {
9399
+ return records.map((record) => ({
9400
+ label: summarizeRecord(record) || record.id,
9401
+ value: record.id
9402
+ }));
9403
+ }
9404
+ var tableRecordIdResolver = defineResolver({
9405
+ imports: [listTableRecordsRef],
9406
+ requireParameters: ["table"],
9407
+ listItems: ({ imports, input, cursor }) => imports.listTableRecords({
9408
+ table: input.table,
9409
+ keyMode: "names",
9410
+ cursor
9411
+ }),
9412
+ prompt: ({ items }) => ({
9413
+ type: "list",
9414
+ message: "Select a record:",
9415
+ choices: recordChoices(items)
9416
+ })
9417
+ });
9418
+ var tableRecordIdsResolver = defineResolver({
9419
+ imports: [listTableRecordsRef],
9420
+ requireParameters: ["table"],
9421
+ listItems: ({ imports, input, cursor }) => imports.listTableRecords({
9422
+ table: input.table,
9423
+ keyMode: "names",
9424
+ cursor
9425
+ }),
9426
+ prompt: ({ items }) => ({
9427
+ type: "checkbox",
9428
+ message: "Select records to delete:",
9429
+ choices: recordChoices(items)
9430
+ }),
9431
+ validate: ({ value }) => Array.isArray(value) && value.length > 0 ? true : "Select at least one record"
9432
+ });
9433
+
9434
+ // src/resolvers/tableFieldIds.ts
9435
+ var listTableFieldsRef = declareMethod({ id: "listTableFields" });
9436
+ var tableFieldIdsResolver = defineResolver({
9437
+ imports: [listTableFieldsRef],
9438
+ requireParameters: ["table"],
9439
+ // No cursor forwarding: the fields API is unpaginated (no cursor on the
9440
+ // response), so the listing is always exhausted after one page.
9441
+ listItems: ({ imports, input }) => imports.listTableFields({ table: input.table }),
9442
+ prompt: ({ items }) => ({
9443
+ type: "checkbox",
9444
+ message: "Select fields:",
9445
+ choices: items.map((field) => ({
9446
+ label: field.name,
9447
+ hint: [field.id, field.type],
9448
+ value: field.id
9449
+ }))
9450
+ }),
9451
+ validate: ({ value }) => Array.isArray(value) && value.length > 0 ? true : "Select at least one field"
9452
+ });
9453
+
9454
+ // src/resolvers/tableName.ts
9455
+ var tableNameResolver = defineResolver({
9456
+ type: "static",
9457
+ inputType: "text",
9458
+ placeholder: "Enter a name for the table"
9459
+ });
9460
+ var FieldTypeSchema = zod.z.enum([
9461
+ "string",
9462
+ "multiple_string",
9463
+ "labeled_string",
9464
+ "multiple_labeled_string",
9465
+ "text",
9466
+ "multiple_text",
9467
+ "boolean",
9468
+ "multiple_boolean",
9469
+ "number",
9470
+ "multiple_number",
9471
+ "decimal",
9472
+ "multiple_decimal",
9473
+ "datetime",
9474
+ "multiple_datetime",
9475
+ "uuid",
9476
+ "multiple_uuid",
9477
+ "json",
9478
+ "multiple_json",
9479
+ "formula",
9480
+ "button_trigger_zap",
9481
+ "button_continue_zap",
9482
+ "email",
9483
+ "multiple_email",
9484
+ "link",
9485
+ "multiple_link",
9486
+ "currency",
9487
+ "phone_number",
9488
+ "ai_formula",
9489
+ "linked_record",
9490
+ "multiple_linked_record"
9491
+ ]);
9492
+ var FieldApiItemSchema = zod.z.object({
9493
+ id: zod.z.number(),
9494
+ type: FieldTypeSchema,
9495
+ name: zod.z.string(),
9496
+ created_at: zod.z.string().optional(),
9497
+ edited_at: zod.z.string().optional(),
9498
+ options: zod.z.record(zod.z.string(), zod.z.unknown()).optional(),
9499
+ config: zod.z.record(zod.z.string(), zod.z.unknown()).optional(),
9500
+ is_order_field: zod.z.boolean().optional(),
9501
+ is_filter_field: zod.z.boolean().optional(),
9502
+ is_selected_field: zod.z.boolean().optional(),
9503
+ deleted_at: zod.z.string().nullable().optional()
9504
+ });
9505
+ var ListTableFieldsApiResponseSchema = zod.z.object({
9506
+ data: zod.z.array(FieldApiItemSchema)
9507
+ });
9508
+ var FieldItemSchema = zod.z.object({
9509
+ id: zod.z.string(),
9510
+ type: FieldTypeSchema,
9511
+ name: zod.z.string(),
9512
+ created_at: zod.z.string().optional(),
9513
+ edited_at: zod.z.string().optional(),
9514
+ options: zod.z.record(zod.z.string(), zod.z.unknown()).optional(),
9515
+ config: zod.z.record(zod.z.string(), zod.z.unknown()).optional(),
9516
+ deleted_at: zod.z.string().nullable().optional()
9517
+ });
9518
+ var ListTableFieldsDescription = "List fields for a table";
9519
+ var ListTableFieldsOptionsBaseSchema = zod.z.object({
9520
+ fields: FieldsPropertySchema.optional(),
9521
+ fieldKeys: zod.z.array(zod.z.union([zod.z.string(), zod.z.number()])).optional().describe(
9522
+ 'Filter by specific fields. Accepts field names (e.g., "Email") or IDs (e.g., "f6", "6", or 6).'
9523
+ ).meta({ deprecated: true }),
9524
+ trash: TrashSchema
9525
+ });
9526
+ var ListTableFieldsOptionsSchema = zod.z.object({
9527
+ table: TablePropertySchema
9528
+ }).merge(ListTableFieldsOptionsBaseSchema).describe(ListTableFieldsDescription).meta({ aliases: { tableId: "table", fieldKeys: "fields" } });
9529
+ var ListTableFieldsOptionsSchemaDeprecated = zod.z.object({
9530
+ tableId: zod.z.string().regex(/^[A-Z0-9]{26}$/, "Table ID must be a valid ULID").describe("The unique identifier of the table")
9531
+ }).merge(ListTableFieldsOptionsBaseSchema);
9532
+ var ListTableFieldsOptionsInputSchema = zod.z.union([ListTableFieldsOptionsSchema, ListTableFieldsOptionsSchemaDeprecated]).describe(ListTableFieldsDescription);
9533
+
9534
+ // src/resolvers/tableFields.ts
9535
+ var fieldTypeChoices = FieldTypeSchema.options.map((type) => ({
9536
+ label: type,
9537
+ value: type
9538
+ }));
9539
+ var singleFieldResolver = defineResolver({
9540
+ type: "object",
9541
+ properties: {
9542
+ type: {
9543
+ label: "Field type",
9544
+ required: true,
9545
+ resolver: defineResolver({
9546
+ listItems: () => ({ data: fieldTypeChoices }),
9547
+ prompt: ({ items }) => ({
9548
+ type: "list",
9549
+ message: "Select field type:",
9550
+ choices: items
9551
+ })
9552
+ })
9553
+ },
9554
+ name: {
9555
+ label: "Field name",
9556
+ required: true,
9557
+ resolver: defineResolver({ type: "static", inputType: "text" })
9558
+ }
9559
+ }
9560
+ });
9561
+ var tableFieldsResolver = defineResolver({
9562
+ type: "array",
9563
+ items: singleFieldResolver,
9564
+ minItems: 1
9565
+ });
9566
+
9567
+ // src/resolvers/tableRecords.ts
9568
+ var listTableFieldsRef2 = declareMethod({ id: "listTableFields" });
9569
+ function tableFieldValueType(fieldType) {
9570
+ if (fieldType.startsWith("multiple_")) return "array";
9571
+ switch (fieldType) {
9572
+ case "number":
9573
+ case "decimal":
9574
+ case "currency":
9575
+ return "number";
9576
+ case "boolean":
9577
+ return "boolean";
9578
+ default:
9579
+ return void 0;
9580
+ }
9581
+ }
9582
+ function buildDataFields(fields) {
9583
+ const props = {};
9584
+ for (const field of fields) {
9585
+ const valueType = tableFieldValueType(field.type);
9586
+ props[field.id] = {
9587
+ label: field.name,
9588
+ required: false,
9589
+ ...valueType ? { valueType } : {},
9590
+ resolver: { type: "static", inputType: "text" }
9591
+ };
9592
+ }
9593
+ return props;
9594
+ }
9595
+ function makeRecordsResolver(includeRecordId) {
9596
+ const singleRecordResolver = defineResolver({
9597
+ type: "object",
9598
+ imports: [listTableFieldsRef2],
9599
+ requireParameters: ["table"],
9600
+ // The record-id resolver is import-bearing, so it lives in `definitions` and
9601
+ // is reached by `{ ref }` from the built `id` field (updates only).
9602
+ definitions: includeRecordId ? { recordId: tableRecordIdResolver } : {},
9603
+ getProperties: async ({ imports, input }) => {
9604
+ const { data: fields } = await imports.listTableFields({
9605
+ table: input.table
9606
+ });
9607
+ const props = {
9608
+ data: {
9609
+ label: "Field values",
9610
+ resolver: { type: "object", properties: buildDataFields(fields) }
9611
+ }
9612
+ };
9613
+ if (includeRecordId) {
9614
+ props.id = {
9615
+ label: "Record",
9616
+ required: true,
9617
+ resolver: { ref: "recordId" }
9618
+ };
9619
+ }
9620
+ return props;
9757
9621
  }
9758
- };
9622
+ });
9623
+ return defineResolver({
9624
+ type: "array",
9625
+ requireParameters: ["table"],
9626
+ minItems: 1,
9627
+ items: singleRecordResolver
9628
+ });
9759
9629
  }
9630
+ var tableRecordsResolver = makeRecordsResolver(false);
9631
+ var tableUpdateRecordsResolver = makeRecordsResolver(true);
9760
9632
 
9761
- // src/resolvers/tableRecordId.ts
9762
- var listTableRecordsRef = declareMethod({ id: "listTableRecords" });
9763
- function summarizeRecord(record) {
9764
- const values = Object.values(record.data);
9765
- const preview = values.slice(0, 3).map((v) => formatFieldValue(v).replace(/\s+/g, " ").trim()).filter((s) => s.length > 0).join(", ");
9766
- if (!preview) return void 0;
9767
- return preview.length > 60 ? preview.slice(0, 57) + "..." : preview;
9633
+ // src/resolvers/tableFilters.ts
9634
+ var listTableFieldsRef3 = declareMethod({ id: "listTableFields" });
9635
+ var FILTER_OPERATORS = [
9636
+ { label: "equals", value: "exact" },
9637
+ { label: "not equals", value: "different" },
9638
+ { label: "contains", value: "contains" },
9639
+ { label: "contains (case-insensitive)", value: "icontains" },
9640
+ { label: "starts with", value: "startswith" },
9641
+ { label: "search", value: "search" },
9642
+ { label: "greater than", value: "gt" },
9643
+ { label: "greater than or equal", value: "gte" },
9644
+ { label: "less than", value: "lt" },
9645
+ { label: "less than or equal", value: "lte" },
9646
+ { label: "in range", value: "range" },
9647
+ { label: "in list", value: "in" },
9648
+ { label: "is empty", value: "isnull" },
9649
+ { label: "is within (date)", value: "is_within" }
9650
+ ];
9651
+ function fieldKeyChoices(fields) {
9652
+ return fields.flatMap((field) => {
9653
+ const components = NESTED_COMPONENTS[field.type];
9654
+ if (components && components.size > 1) {
9655
+ return [...components].map((component) => ({
9656
+ label: `${field.name}__${component} (${field.id}, ${field.type})`,
9657
+ value: `${field.name}__${component}`
9658
+ }));
9659
+ }
9660
+ return {
9661
+ label: `${field.name} (${field.id}${components ? `, ${field.type}` : ""})`,
9662
+ value: components ? `${field.name}__${[...components][0]}` : field.name
9663
+ };
9664
+ });
9768
9665
  }
9769
- function recordChoices(records) {
9770
- return records.map((record) => ({
9771
- label: summarizeRecord(record) || record.id,
9772
- value: record.id
9773
- }));
9666
+ var singleFilterResolver = defineResolver({
9667
+ type: "object",
9668
+ imports: [listTableFieldsRef3],
9669
+ requireParameters: ["table"],
9670
+ getProperties: async ({ imports, input }) => {
9671
+ const { data: fields } = await imports.listTableFields({
9672
+ table: input.table
9673
+ });
9674
+ const choices = fieldKeyChoices(fields);
9675
+ const props = {
9676
+ fieldKey: {
9677
+ label: "Field",
9678
+ required: true,
9679
+ resolver: {
9680
+ type: "dynamic",
9681
+ listItems: () => ({ data: choices }),
9682
+ prompt: () => ({
9683
+ type: "list",
9684
+ message: "Select field:",
9685
+ choices
9686
+ })
9687
+ }
9688
+ },
9689
+ operator: {
9690
+ label: "Operator",
9691
+ required: true,
9692
+ resolver: {
9693
+ type: "dynamic",
9694
+ listItems: () => ({ data: FILTER_OPERATORS }),
9695
+ prompt: () => ({
9696
+ type: "list",
9697
+ message: "Select operator:",
9698
+ choices: FILTER_OPERATORS
9699
+ })
9700
+ }
9701
+ },
9702
+ value: {
9703
+ label: "Value",
9704
+ required: false,
9705
+ resolver: { type: "static", inputType: "text" }
9706
+ }
9707
+ };
9708
+ return props;
9709
+ }
9710
+ });
9711
+ var tableFiltersResolver = defineResolver({
9712
+ type: "array",
9713
+ requireParameters: ["table"],
9714
+ minItems: 0,
9715
+ items: singleFilterResolver
9716
+ });
9717
+
9718
+ // src/resolvers/tableSort.ts
9719
+ var listTableFieldsRef4 = declareMethod({ id: "listTableFields" });
9720
+ function fieldKeyChoices2(fields) {
9721
+ return fields.flatMap((field) => {
9722
+ const components = NESTED_COMPONENTS[field.type];
9723
+ if (components) {
9724
+ return [...components].map((component) => ({
9725
+ label: `${field.name}__${component} (${field.id}, ${field.type})`,
9726
+ value: `${field.name}__${component}`
9727
+ }));
9728
+ }
9729
+ return { label: `${field.name} (${field.id})`, value: field.name };
9730
+ });
9774
9731
  }
9775
- var tableRecordIdResolver = defineResolver({
9776
- imports: [listTableRecordsRef],
9732
+ var DIRECTION_CHOICES = [
9733
+ { label: "Ascending", value: "asc" },
9734
+ { label: "Descending", value: "desc" }
9735
+ ];
9736
+ var tableSortResolver = defineResolver({
9737
+ type: "object",
9738
+ imports: [listTableFieldsRef4],
9777
9739
  requireParameters: ["table"],
9778
- listItems: ({ imports, input, cursor }) => imports.listTableRecords({
9779
- table: input.table,
9780
- keyMode: "names",
9781
- cursor
9782
- }),
9783
- prompt: ({ items }) => ({
9784
- type: "list",
9785
- message: "Select a record:",
9786
- choices: recordChoices(items)
9787
- })
9740
+ getProperties: async ({ imports, input }) => {
9741
+ const { data: fields } = await imports.listTableFields({
9742
+ table: input.table
9743
+ });
9744
+ const choices = fieldKeyChoices2(fields);
9745
+ const props = {
9746
+ fieldKey: {
9747
+ label: "Field",
9748
+ required: true,
9749
+ resolver: {
9750
+ type: "dynamic",
9751
+ listItems: () => ({ data: choices }),
9752
+ prompt: () => ({
9753
+ type: "list",
9754
+ message: "Select field:",
9755
+ choices
9756
+ })
9757
+ }
9758
+ },
9759
+ direction: {
9760
+ label: "Direction",
9761
+ required: true,
9762
+ resolver: {
9763
+ type: "dynamic",
9764
+ listItems: () => ({ data: DIRECTION_CHOICES }),
9765
+ prompt: () => ({
9766
+ type: "list",
9767
+ message: "Select direction:",
9768
+ choices: DIRECTION_CHOICES
9769
+ })
9770
+ }
9771
+ }
9772
+ };
9773
+ return props;
9774
+ }
9775
+ });
9776
+ var GetActionDescription = "Get detailed information about a specific action";
9777
+ var GetActionSchema = zod.z.object({
9778
+ app: AppPropertySchema,
9779
+ actionType: ActionTypePropertySchema,
9780
+ action: ActionPropertySchema
9781
+ }).describe(GetActionDescription).meta({ aliases: { appKey: "app", actionKey: "action" } });
9782
+ var GetActionSchemaDeprecated = zod.z.object({
9783
+ appKey: AppKeyPropertySchema,
9784
+ actionType: ActionTypePropertySchema,
9785
+ actionKey: ActionKeyPropertySchema
9786
+ });
9787
+ var GetActionInputSchema = zod.z.union([GetActionSchema, GetActionSchemaDeprecated]).describe(GetActionDescription);
9788
+ var ListActionsDescription = "List all actions for a specific app";
9789
+ var ListActionsBaseSchema = zod.z.object({
9790
+ pageSize: zod.z.number().min(1).optional().describe("Number of actions per page"),
9791
+ maxItems: zod.z.number().min(1).optional().describe("Maximum total items to return across all pages"),
9792
+ cursor: zod.z.string().optional().describe("Cursor to start from")
9793
+ });
9794
+ var ListActionsSchema = zod.z.object({
9795
+ app: AppPropertySchema.describe(
9796
+ "App key of actions to list (e.g., 'SlackCLIAPI' or slug like 'github')"
9797
+ ),
9798
+ actionType: ActionTypePropertySchema.optional().describe(
9799
+ "Filter actions by type"
9800
+ )
9801
+ }).merge(ListActionsBaseSchema).describe(ListActionsDescription).meta({ aliases: { appKey: "app" } });
9802
+ var ListActionsSchemaDeprecated = zod.z.object({
9803
+ appKey: AppKeyPropertySchema.describe(
9804
+ "App key of actions to list (e.g., 'SlackCLIAPI' or slug like 'github')"
9805
+ ),
9806
+ actionType: ActionTypePropertySchema.optional().describe(
9807
+ "Filter actions by type"
9808
+ )
9809
+ }).merge(ListActionsBaseSchema);
9810
+ var ListActionsInputSchema = zod.z.union([ListActionsSchema, ListActionsSchemaDeprecated]).describe(ListActionsDescription);
9811
+ var NeedChoicesSchema = zod.z.object({
9812
+ key: zod.z.string().optional(),
9813
+ label: zod.z.string().optional(),
9814
+ sample: zod.z.string().optional(),
9815
+ value: zod.z.string().optional()
9816
+ });
9817
+ var NeedSchema = zod.z.object({
9818
+ key: zod.z.string(),
9819
+ alters_custom_fields: zod.z.boolean().nullable().optional(),
9820
+ capabilities: zod.z.array(zod.z.string()).optional(),
9821
+ choices: zod.z.array(NeedChoicesSchema).optional(),
9822
+ computed: zod.z.boolean().nullable().optional(),
9823
+ custom_field: zod.z.boolean().optional(),
9824
+ default: zod.z.string().optional(),
9825
+ depends_on: zod.z.array(zod.z.string()).optional(),
9826
+ format: zod.z.literal("SELECT").optional(),
9827
+ from_search: zod.z.boolean().optional(),
9828
+ from_write: zod.z.boolean().optional(),
9829
+ help_text: zod.z.string().optional(),
9830
+ help_text_html: zod.z.string().optional(),
9831
+ input_format: zod.z.array(zod.z.string()).optional(),
9832
+ label: zod.z.string().optional(),
9833
+ language: zod.z.string().optional(),
9834
+ parent_key: zod.z.string().optional(),
9835
+ placeholder: zod.z.string().optional(),
9836
+ prefill: zod.z.string().optional(),
9837
+ required: zod.z.boolean().optional(),
9838
+ searchfill: zod.z.string().optional(),
9839
+ send_in_json: zod.z.boolean().optional(),
9840
+ regex: zod.z.string().optional(),
9841
+ type: zod.z.enum([
9842
+ "integer",
9843
+ "string",
9844
+ "text",
9845
+ "datetime",
9846
+ "boolean",
9847
+ "file",
9848
+ "decimal",
9849
+ "copy",
9850
+ "password",
9851
+ "dict",
9852
+ "code",
9853
+ "filter",
9854
+ "json"
9855
+ ]).optional(),
9856
+ list: zod.z.boolean().optional()
9788
9857
  });
9789
- var tableRecordIdsResolver = defineResolver({
9790
- imports: [listTableRecordsRef],
9791
- requireParameters: ["table"],
9792
- listItems: ({ imports, input, cursor }) => imports.listTableRecords({
9793
- table: input.table,
9794
- keyMode: "names",
9795
- cursor
9796
- }),
9797
- prompt: ({ items }) => ({
9798
- type: "checkbox",
9799
- message: "Select records to delete:",
9800
- choices: recordChoices(items)
9801
- }),
9802
- validate: ({ value }) => Array.isArray(value) && value.length > 0 ? true : "Select at least one record"
9858
+ zod.z.object({
9859
+ action_url: zod.z.string().optional()
9803
9860
  });
9804
-
9805
- // src/resolvers/tableFieldIds.ts
9806
- var listTableFieldsRef = declareMethod({ id: "listTableFields" });
9807
- var tableFieldIdsResolver = defineResolver({
9808
- imports: [listTableFieldsRef],
9809
- requireParameters: ["table"],
9810
- // No cursor forwarding: the fields API is unpaginated (no cursor on the
9811
- // response), so the listing is always exhausted after one page.
9812
- listItems: ({ imports, input }) => imports.listTableFields({ table: input.table }),
9813
- prompt: ({ items }) => ({
9814
- type: "checkbox",
9815
- message: "Select fields:",
9816
- choices: items.map((field) => ({
9817
- label: field.name,
9818
- hint: [field.id, field.type],
9819
- value: field.id
9820
- }))
9821
- }),
9822
- validate: ({ value }) => Array.isArray(value) && value.length > 0 ? true : "Select at least one field"
9861
+ zod.z.object({
9862
+ can_use: zod.z.boolean().optional()
9823
9863
  });
9824
-
9825
- // src/resolvers/tableName.ts
9826
- var tableNameResolver = defineResolver({
9827
- type: "static",
9828
- inputType: "text",
9829
- placeholder: "Enter a name for the table"
9864
+ var ActionSchema = zod.z.object({
9865
+ id: zod.z.string().optional(),
9866
+ type: zod.z.enum([
9867
+ "filter",
9868
+ "read",
9869
+ "read_bulk",
9870
+ "run",
9871
+ "search",
9872
+ "search_and_write",
9873
+ "search_or_write",
9874
+ "write"
9875
+ ]),
9876
+ key: zod.z.string(),
9877
+ name: zod.z.string(),
9878
+ description: zod.z.string(),
9879
+ is_important: zod.z.boolean().optional(),
9880
+ is_hidden: zod.z.boolean().optional(),
9881
+ selected_api: zod.z.string().optional()
9830
9882
  });
9831
- var FieldTypeSchema = zod.z.enum([
9832
- "string",
9833
- "multiple_string",
9834
- "labeled_string",
9835
- "multiple_labeled_string",
9836
- "text",
9837
- "multiple_text",
9838
- "boolean",
9839
- "multiple_boolean",
9840
- "number",
9841
- "multiple_number",
9842
- "decimal",
9843
- "multiple_decimal",
9844
- "datetime",
9845
- "multiple_datetime",
9846
- "uuid",
9847
- "multiple_uuid",
9848
- "json",
9849
- "multiple_json",
9850
- "formula",
9851
- "button_trigger_zap",
9852
- "button_continue_zap",
9853
- "email",
9854
- "multiple_email",
9855
- "link",
9856
- "multiple_link",
9857
- "currency",
9858
- "phone_number",
9859
- "ai_formula",
9860
- "linked_record",
9861
- "multiple_linked_record"
9862
- ]);
9863
- var FieldApiItemSchema = zod.z.object({
9883
+ var ChoiceSchema = zod.z.object({
9884
+ value: zod.z.union([zod.z.string(), zod.z.number()]),
9885
+ label: zod.z.string()
9886
+ });
9887
+ zod.z.object({
9888
+ key: zod.z.string(),
9889
+ label: zod.z.string(),
9890
+ type: zod.z.enum([
9891
+ "string",
9892
+ "number",
9893
+ "boolean",
9894
+ "datetime",
9895
+ "file",
9896
+ "object",
9897
+ "array"
9898
+ ]),
9899
+ required: zod.z.boolean(),
9900
+ description: zod.z.string().optional(),
9901
+ choices: zod.z.array(ChoiceSchema).optional()
9902
+ });
9903
+ zod.z.object({
9904
+ data: zod.z.array(zod.z.unknown())
9905
+ });
9906
+ var ActionFieldChoiceSchema = zod.z.object({
9907
+ value: zod.z.union([zod.z.string(), zod.z.number()]),
9908
+ label: zod.z.string()
9909
+ });
9910
+ zod.z.object({
9911
+ key: zod.z.string(),
9912
+ label: zod.z.string().optional(),
9913
+ required: zod.z.boolean(),
9914
+ type: zod.z.string().optional(),
9915
+ helpText: zod.z.string().optional(),
9916
+ helpTextHtml: zod.z.string().optional(),
9917
+ choices: zod.z.array(ActionFieldChoiceSchema).optional(),
9918
+ default: zod.z.string().optional(),
9919
+ placeholder: zod.z.string().optional(),
9920
+ computed: zod.z.boolean().optional(),
9921
+ customField: zod.z.boolean().optional(),
9922
+ dependsOn: zod.z.array(zod.z.string()).optional(),
9923
+ format: zod.z.string().optional(),
9924
+ inputFormat: zod.z.array(zod.z.string()).optional()
9925
+ });
9926
+ zod.z.object({
9864
9927
  id: zod.z.number(),
9865
- type: FieldTypeSchema,
9928
+ public_id: zod.z.string().optional(),
9929
+ code: zod.z.string(),
9930
+ user_id: zod.z.number(),
9931
+ auto_provisioned: zod.z.boolean(),
9932
+ first_name: zod.z.string(),
9933
+ last_name: zod.z.string(),
9934
+ username: zod.z.string(),
9935
+ personas: zod.z.string(),
9936
+ user_generated_personas: zod.z.string(),
9937
+ last_login: zod.z.string(),
9938
+ email: zod.z.string(),
9939
+ email_hash: zod.z.string(),
9940
+ email_confirmed: zod.z.boolean(),
9941
+ timezone: zod.z.string(),
9942
+ photo_url: zod.z.string(),
9943
+ has_seen_notifications: zod.z.record(zod.z.string(), zod.z.boolean().nullable()),
9944
+ signup: zod.z.string(),
9945
+ since_signup: zod.z.string(),
9946
+ has_activated: zod.z.boolean(),
9947
+ enable_gz_creator: zod.z.boolean(),
9948
+ should_see_nps_survey: zod.z.boolean(),
9949
+ is_developer: zod.z.boolean(),
9950
+ is_expert: zod.z.boolean(),
9951
+ tos_agreement: zod.z.boolean(),
9952
+ should_renew_tos: zod.z.boolean(),
9953
+ is_gdpr_consented: zod.z.boolean(),
9954
+ disable_ssl_check: zod.z.boolean(),
9955
+ identity: zod.z.number(),
9956
+ summary_schedule: zod.z.string(),
9957
+ alert_triggers: zod.z.string(),
9958
+ alert_actions: zod.z.string(),
9959
+ is_staff: zod.z.boolean(),
9960
+ is_zt_reviewer: zod.z.boolean(),
9961
+ is_high_value: zod.z.boolean(),
9962
+ is_temporary: zod.z.boolean(),
9963
+ banner_message: zod.z.string(),
9964
+ enable_totp_2fa: zod.z.boolean(),
9965
+ viewed_help: zod.z.record(zod.z.string(), zod.z.boolean()),
9966
+ show_editor_migration_mesaging: zod.z.boolean(),
9967
+ switches: zod.z.record(zod.z.string(), zod.z.unknown()),
9968
+ organizations: zod.z.array(zod.z.record(zod.z.string(), zod.z.unknown()).nullable()),
9969
+ primary_organization: zod.z.record(zod.z.string(), zod.z.unknown()).nullable(),
9970
+ has_active_zaps: zod.z.boolean(),
9971
+ has_google_sso: zod.z.boolean(),
9972
+ auth_realm: zod.z.string(),
9973
+ roles: zod.z.array(
9974
+ zod.z.object({
9975
+ account_id: zod.z.number(),
9976
+ role: zod.z.string()
9977
+ })
9978
+ )
9979
+ });
9980
+ zod.z.object({
9981
+ age_in_days: zod.z.string().optional(),
9982
+ api_docs_url: zod.z.string().nullable().optional(),
9983
+ app_profile_url: zod.z.string(),
9984
+ banner: zod.z.string().optional(),
9985
+ categories: zod.z.array(zod.z.string()).optional(),
9986
+ // Service category names
9987
+ canonical_id: zod.z.string().optional(),
9988
+ current_implementation_id: zod.z.string(),
9989
+ days_since_last_update: zod.z.string().optional(),
9990
+ description: zod.z.string(),
9991
+ external_url: zod.z.string(),
9992
+ hashtag: zod.z.string().optional(),
9993
+ id: zod.z.number().optional(),
9994
+ image: zod.z.string().optional(),
9995
+ images: zod.z.string().optional(),
9996
+ integration_overview_html: zod.z.string().nullable().optional(),
9997
+ internal_id: zod.z.string(),
9998
+ invite_url: zod.z.string().nullable().optional(),
9999
+ is_beta: zod.z.string().optional(),
10000
+ is_built_in: zod.z.string().optional(),
10001
+ is_featured: zod.z.string().optional(),
10002
+ is_premium: zod.z.boolean().optional(),
10003
+ is_public: zod.z.string().optional(),
10004
+ is_upcoming: zod.z.string().optional(),
10005
+ learn_more_url: zod.z.string(),
9866
10006
  name: zod.z.string(),
9867
- created_at: zod.z.string().optional(),
9868
- edited_at: zod.z.string().optional(),
9869
- options: zod.z.record(zod.z.string(), zod.z.unknown()).optional(),
9870
- config: zod.z.record(zod.z.string(), zod.z.unknown()).optional(),
9871
- is_order_field: zod.z.boolean().optional(),
9872
- is_filter_field: zod.z.boolean().optional(),
9873
- is_selected_field: zod.z.boolean().optional(),
9874
- deleted_at: zod.z.string().nullable().optional()
10007
+ popularity: zod.z.number(),
10008
+ primary_color: zod.z.string(),
10009
+ request_count: zod.z.string().optional(),
10010
+ slug: zod.z.string(),
10011
+ zap_usage_count: zod.z.number().nullable().optional()
10012
+ });
10013
+ var ServiceSchema = zod.z.object({
10014
+ id: zod.z.number().optional(),
10015
+ canonical_id: zod.z.string().optional(),
10016
+ current_implementation_id: zod.z.string(),
10017
+ name: zod.z.string(),
10018
+ slug: zod.z.string(),
10019
+ app_url: zod.z.string().optional(),
10020
+ learn_more_url: zod.z.string().optional(),
10021
+ description: zod.z.string(),
10022
+ primary_color: zod.z.string(),
10023
+ popularity: zod.z.number(),
10024
+ image: zod.z.string().optional(),
10025
+ images: zod.z.string().optional()
9875
10026
  });
9876
- var ListTableFieldsApiResponseSchema = zod.z.object({
9877
- data: zod.z.array(FieldApiItemSchema)
10027
+ zod.z.object({
10028
+ results: zod.z.array(ServiceSchema),
10029
+ next: zod.z.string().nullable().optional(),
10030
+ previous: zod.z.string().nullable().optional()
9878
10031
  });
9879
- var FieldItemSchema = zod.z.object({
9880
- id: zod.z.string(),
9881
- type: FieldTypeSchema,
9882
- name: zod.z.string(),
9883
- created_at: zod.z.string().optional(),
9884
- edited_at: zod.z.string().optional(),
9885
- options: zod.z.record(zod.z.string(), zod.z.unknown()).optional(),
9886
- config: zod.z.record(zod.z.string(), zod.z.unknown()).optional(),
9887
- deleted_at: zod.z.string().nullable().optional()
10032
+ zod.z.object({
10033
+ selected_api: zod.z.string(),
10034
+ action: zod.z.string(),
10035
+ type_of: zod.z.string(),
10036
+ authentication_id: zod.z.union([zod.z.string(), zod.z.number()]).optional(),
10037
+ params: zod.z.record(zod.z.string(), zod.z.unknown()).optional()
9888
10038
  });
9889
- var ListTableFieldsDescription = "List fields for a table";
9890
- var ListTableFieldsOptionsBaseSchema = zod.z.object({
9891
- fields: FieldsPropertySchema.optional(),
9892
- fieldKeys: zod.z.array(zod.z.union([zod.z.string(), zod.z.number()])).optional().describe(
9893
- 'Filter by specific fields. Accepts field names (e.g., "Email") or IDs (e.g., "f6", "6", or 6).'
9894
- ).meta({ deprecated: true }),
9895
- trash: TrashSchema
10039
+ zod.z.object({
10040
+ success: zod.z.boolean(),
10041
+ needs: zod.z.array(NeedSchema).optional(),
10042
+ errors: zod.z.array(zod.z.string()).optional(),
10043
+ last_fetched_at: zod.z.string().optional(),
10044
+ schema: zod.z.record(zod.z.string(), zod.z.unknown()).optional()
9896
10045
  });
9897
- var ListTableFieldsOptionsSchema = zod.z.object({
9898
- table: TablePropertySchema
9899
- }).merge(ListTableFieldsOptionsBaseSchema).describe(ListTableFieldsDescription).meta({ aliases: { tableId: "table", fieldKeys: "fields" } });
9900
- var ListTableFieldsOptionsSchemaDeprecated = zod.z.object({
9901
- tableId: zod.z.string().regex(/^[A-Z0-9]{26}$/, "Table ID must be a valid ULID").describe("The unique identifier of the table")
9902
- }).merge(ListTableFieldsOptionsBaseSchema);
9903
- var ListTableFieldsOptionsInputSchema = zod.z.union([ListTableFieldsOptionsSchema, ListTableFieldsOptionsSchemaDeprecated]).describe(ListTableFieldsDescription);
9904
-
9905
- // src/resolvers/tableFields.ts
9906
- var fieldTypeChoices = FieldTypeSchema.options.map((type) => ({
9907
- label: type,
9908
- value: type
9909
- }));
9910
- var singleFieldResolver = defineResolver({
9911
- type: "object",
9912
- properties: {
9913
- type: {
9914
- label: "Field type",
9915
- required: true,
9916
- resolver: defineResolver({
9917
- listItems: () => ({ data: fieldTypeChoices }),
9918
- prompt: ({ items }) => ({
9919
- type: "list",
9920
- message: "Select field type:",
9921
- choices: items
9922
- })
9923
- })
9924
- },
9925
- name: {
9926
- label: "Field name",
9927
- required: true,
9928
- resolver: defineResolver({ type: "static", inputType: "text" })
9929
- }
9930
- }
10046
+ var ImplementationSchema = zod.z.object({
10047
+ selected_api: zod.z.string(),
10048
+ app_id: zod.z.number().optional(),
10049
+ auth_type: zod.z.string().optional(),
10050
+ auth_fields: zod.z.string().optional(),
10051
+ actions: zod.z.array(ActionSchema).optional(),
10052
+ is_deprecated: zod.z.boolean().optional(),
10053
+ is_private_only: zod.z.boolean().optional(),
10054
+ is_invite_only: zod.z.boolean().optional(),
10055
+ is_beta: zod.z.boolean().optional().default(false),
10056
+ is_premium: zod.z.boolean().optional().default(false),
10057
+ is_hidden: zod.z.string().optional(),
10058
+ name: zod.z.string().optional(),
10059
+ slug: zod.z.string().optional(),
10060
+ images: zod.z.record(zod.z.string(), zod.z.string().nullable()).optional(),
10061
+ primary_color: zod.z.string().optional(),
10062
+ secondary_color: zod.z.string().optional(),
10063
+ current_implementation: zod.z.string().optional(),
10064
+ other_implementations: zod.z.string().optional()
9931
10065
  });
9932
- var tableFieldsResolver = defineResolver({
9933
- type: "array",
9934
- items: singleFieldResolver,
9935
- minItems: 1
10066
+ zod.z.object({
10067
+ count: zod.z.number(),
10068
+ next: zod.z.string().nullable().optional(),
10069
+ previous: zod.z.string().nullable().optional(),
10070
+ results: zod.z.array(ImplementationSchema)
9936
10071
  });
9937
-
9938
- // src/resolvers/tableRecords.ts
9939
- var listTableFieldsRef2 = declareMethod({ id: "listTableFields" });
9940
- function tableFieldValueType(fieldType) {
9941
- if (fieldType.startsWith("multiple_")) return "array";
9942
- switch (fieldType) {
9943
- case "number":
9944
- case "decimal":
9945
- case "currency":
9946
- return "number";
9947
- case "boolean":
9948
- return "boolean";
9949
- default:
9950
- return void 0;
9951
- }
9952
- }
9953
- function buildDataFields(fields) {
9954
- const props = {};
9955
- for (const field of fields) {
9956
- const valueType = tableFieldValueType(field.type);
9957
- props[field.id] = {
9958
- label: field.name,
9959
- required: false,
9960
- ...valueType ? { valueType } : {},
9961
- resolver: { type: "static", inputType: "text" }
9962
- };
9963
- }
9964
- return props;
9965
- }
9966
- function makeRecordsResolver(includeRecordId) {
9967
- const singleRecordResolver = defineResolver({
9968
- type: "object",
9969
- imports: [listTableFieldsRef2],
9970
- requireParameters: ["table"],
9971
- // The record-id resolver is import-bearing, so it lives in `definitions` and
9972
- // is reached by `{ ref }` from the built `id` field (updates only).
9973
- definitions: includeRecordId ? { recordId: tableRecordIdResolver } : {},
9974
- getProperties: async ({ imports, input }) => {
9975
- const { data: fields } = await imports.listTableFields({
9976
- table: input.table
9977
- });
9978
- const props = {
9979
- data: {
9980
- label: "Field values",
9981
- resolver: { type: "object", properties: buildDataFields(fields) }
9982
- }
9983
- };
9984
- if (includeRecordId) {
9985
- props.id = {
9986
- label: "Record",
9987
- required: true,
9988
- resolver: { ref: "recordId" }
9989
- };
9990
- }
9991
- return props;
9992
- }
9993
- });
9994
- return defineResolver({
9995
- type: "array",
9996
- requireParameters: ["table"],
9997
- minItems: 1,
9998
- items: singleRecordResolver
9999
- });
10000
- }
10001
- var tableRecordsResolver = makeRecordsResolver(false);
10002
- var tableUpdateRecordsResolver = makeRecordsResolver(true);
10003
-
10004
- // src/resolvers/tableFilters.ts
10005
- var listTableFieldsRef3 = declareMethod({ id: "listTableFields" });
10006
- var FILTER_OPERATORS = [
10007
- { label: "equals", value: "exact" },
10008
- { label: "not equals", value: "different" },
10009
- { label: "contains", value: "contains" },
10010
- { label: "contains (case-insensitive)", value: "icontains" },
10011
- { label: "starts with", value: "startswith" },
10012
- { label: "search", value: "search" },
10013
- { label: "greater than", value: "gt" },
10014
- { label: "greater than or equal", value: "gte" },
10015
- { label: "less than", value: "lt" },
10016
- { label: "less than or equal", value: "lte" },
10017
- { label: "in range", value: "range" },
10018
- { label: "in list", value: "in" },
10019
- { label: "is empty", value: "isnull" },
10020
- { label: "is within (date)", value: "is_within" }
10021
- ];
10022
- function fieldKeyChoices(fields) {
10023
- return fields.flatMap((field) => {
10024
- const components = NESTED_COMPONENTS[field.type];
10025
- if (components && components.size > 1) {
10026
- return [...components].map((component) => ({
10027
- label: `${field.name}__${component} (${field.id}, ${field.type})`,
10028
- value: `${field.name}__${component}`
10029
- }));
10030
- }
10031
- return {
10032
- label: `${field.name} (${field.id}${components ? `, ${field.type}` : ""})`,
10033
- value: components ? `${field.name}__${[...components][0]}` : field.name
10034
- };
10035
- });
10036
- }
10037
- var singleFilterResolver = defineResolver({
10038
- type: "object",
10039
- imports: [listTableFieldsRef3],
10040
- requireParameters: ["table"],
10041
- getProperties: async ({ imports, input }) => {
10042
- const { data: fields } = await imports.listTableFields({
10043
- table: input.table
10044
- });
10045
- const choices = fieldKeyChoices(fields);
10046
- const props = {
10047
- fieldKey: {
10048
- label: "Field",
10049
- required: true,
10050
- resolver: {
10051
- type: "dynamic",
10052
- listItems: () => ({ data: choices }),
10053
- prompt: () => ({
10054
- type: "list",
10055
- message: "Select field:",
10056
- choices
10057
- })
10058
- }
10059
- },
10060
- operator: {
10061
- label: "Operator",
10062
- required: true,
10063
- resolver: {
10064
- type: "dynamic",
10065
- listItems: () => ({ data: FILTER_OPERATORS }),
10066
- prompt: () => ({
10067
- type: "list",
10068
- message: "Select operator:",
10069
- choices: FILTER_OPERATORS
10070
- })
10071
- }
10072
- },
10073
- value: {
10074
- label: "Value",
10075
- required: false,
10076
- resolver: { type: "static", inputType: "text" }
10077
- }
10078
- };
10079
- return props;
10080
- }
10072
+ var NeedChoicesResponseMetaSchema = zod.z.object({
10073
+ page: zod.z.string().nullable().optional()
10074
+ });
10075
+ var NeedChoicesResponseLinksSchema = zod.z.object({
10076
+ next: zod.z.string().nullable().optional(),
10077
+ prev: zod.z.string().nullable().optional()
10078
+ });
10079
+ zod.z.object({
10080
+ selected_api: zod.z.string().optional().describe(
10081
+ "Something like `SlackAPI` (for Python apps) or `SplitwiseCLIAPI@1.0.0` (for CLI apps). Non-public apps are fine as long as the authed user can access them."
10082
+ ),
10083
+ authentication_id: zod.z.union([zod.z.string(), zod.z.number()]).optional().describe(
10084
+ "If the app needs auth, provide an `authentication_id` that has the `selected_api` of the app you want to run. Can be any auth visible to the user (including shared)."
10085
+ ),
10086
+ params: zod.z.record(zod.z.string(), zod.z.unknown()).optional().describe(
10087
+ "Object that matches the input the node would normally get. Has all the same keys/types as the `needs` of the action."
10088
+ ),
10089
+ page: zod.z.number().optional().default(0),
10090
+ prefill: zod.z.string().optional().describe(
10091
+ "The prefill string to indicate what we're fetching choices for. Likely something like `spreadsheet.id.title`. Must be provided alongside `selected_api` if both `action_id` and `input_field_id` are not."
10092
+ ),
10093
+ action_id: zod.z.string().optional().describe(
10094
+ "The id that will be used to lookup the Action for prefill lookup. If provided, `input_field_id` is required, else `prefill` must be provided."
10095
+ ),
10096
+ input_field_id: zod.z.string().optional().describe(
10097
+ "The id (key) of the input field (Need) that dynamic choices are being retrieved for. If provided, `action_id` is required, else `prefill` must be provided."
10098
+ )
10081
10099
  });
10082
- var tableFiltersResolver = defineResolver({
10083
- type: "array",
10084
- requireParameters: ["table"],
10085
- minItems: 0,
10086
- items: singleFilterResolver
10100
+ zod.z.object({
10101
+ success: zod.z.boolean(),
10102
+ choices: zod.z.array(NeedChoicesSchema).optional(),
10103
+ next_page: zod.z.number().optional(),
10104
+ errors: zod.z.array(zod.z.string()).optional(),
10105
+ meta: NeedChoicesResponseMetaSchema.optional(),
10106
+ links: NeedChoicesResponseLinksSchema.optional()
10087
10107
  });
10088
10108
 
10089
- // src/resolvers/tableSort.ts
10090
- var listTableFieldsRef4 = declareMethod({ id: "listTableFields" });
10091
- function fieldKeyChoices2(fields) {
10092
- return fields.flatMap((field) => {
10093
- const components = NESTED_COMPONENTS[field.type];
10094
- if (components) {
10095
- return [...components].map((component) => ({
10096
- label: `${field.name}__${component} (${field.id}, ${field.type})`,
10097
- value: `${field.name}__${component}`
10098
- }));
10099
- }
10100
- return { label: `${field.name} (${field.id})`, value: field.name };
10101
- });
10102
- }
10103
- var DIRECTION_CHOICES = [
10104
- { label: "Ascending", value: "asc" },
10105
- { label: "Descending", value: "desc" }
10106
- ];
10107
- var tableSortResolver = defineResolver({
10108
- type: "object",
10109
- imports: [listTableFieldsRef4],
10110
- requireParameters: ["table"],
10111
- getProperties: async ({ imports, input }) => {
10112
- const { data: fields } = await imports.listTableFields({
10113
- table: input.table
10114
- });
10115
- const choices = fieldKeyChoices2(fields);
10116
- const props = {
10117
- fieldKey: {
10118
- label: "Field",
10119
- required: true,
10120
- resolver: {
10121
- type: "dynamic",
10122
- listItems: () => ({ data: choices }),
10123
- prompt: () => ({
10124
- type: "list",
10125
- message: "Select field:",
10126
- choices
10127
- })
10128
- }
10129
- },
10130
- direction: {
10131
- label: "Direction",
10132
- required: true,
10133
- resolver: {
10134
- type: "dynamic",
10135
- listItems: () => ({ data: DIRECTION_CHOICES }),
10136
- prompt: () => ({
10137
- type: "list",
10138
- message: "Select direction:",
10139
- choices: DIRECTION_CHOICES
10140
- })
10141
- }
10142
- }
10143
- };
10144
- return props;
10109
+ // src/schemas/Action.ts
10110
+ var ActionItemSchema = ActionSchema.omit({
10111
+ type: true,
10112
+ name: true,
10113
+ selected_api: true
10114
+ }).extend({
10115
+ app_key: zod.z.string(),
10116
+ // App key without version (extracted from selected_api)
10117
+ app_version: zod.z.string().optional(),
10118
+ // Version extracted from selected_api
10119
+ action_type: ActionSchema.shape.type,
10120
+ // Mapped from original 'type' field
10121
+ title: zod.z.string(),
10122
+ // Mapped from original 'name' field
10123
+ type: zod.z.literal("action")
10124
+ // Fixed type identifier
10125
+ });
10126
+
10127
+ // src/formatters/action.ts
10128
+ function formatActionItem(item) {
10129
+ const details = [{ text: `Type: ${item.action_type}`, style: "accent" }];
10130
+ if (item.app_key) {
10131
+ details.push({ text: `App: ${item.app_key}`, style: "normal" });
10132
+ }
10133
+ if (item.description) {
10134
+ details.push({ text: item.description, style: "dim" });
10145
10135
  }
10136
+ return {
10137
+ title: item.title || item.key,
10138
+ // `hint` is the dumb secondary string shown after the title (the action key
10139
+ // and, when present, its id). Replaces the deprecated `key`/`id` fields.
10140
+ hint: [item.key, item.id].filter((v) => Boolean(v)),
10141
+ description: item.description,
10142
+ details
10143
+ };
10144
+ }
10145
+ var actionItemFormatter = defineFormatter({
10146
+ format: ({ item }) => formatActionItem(item)
10146
10147
  });
10147
10148
 
10148
10149
  // src/plugins/listActions/index.ts
@@ -10241,65 +10242,37 @@ var getActionPlugin = defineMethod({
10241
10242
  );
10242
10243
  }
10243
10244
  });
10244
- async function executeAction(actionOptions) {
10245
- const {
10246
- api,
10247
- selectedApi,
10248
- actionId,
10249
- actionKey,
10250
- actionType,
10251
- executionOptions,
10252
- cursor,
10253
- connectionId,
10254
- timeoutMilliseconds
10255
- } = actionOptions;
10256
- const runRequestData = {
10257
- selected_api: selectedApi,
10258
- action_id: actionId,
10259
- action_key: actionKey,
10260
- action_type: actionType,
10261
- inputs: executionOptions.inputs || {}
10262
- };
10263
- if (connectionId !== null && connectionId !== void 0) {
10264
- runRequestData.authentication_id = connectionId;
10265
- }
10266
- if (cursor) {
10267
- runRequestData.page = cursor;
10268
- }
10269
- const runRequest = { data: runRequestData };
10270
- const runData = await api.post(
10271
- "/zapier/api/actions/v1/runs",
10272
- runRequest,
10273
- {
10274
- approvalContext: () => policyContext.buildActionRunContext({
10275
- selected_api: selectedApi,
10276
- action_type: actionType,
10277
- action_key: actionKey,
10278
- connection_id: connectionId != null ? String(connectionId) : void 0,
10279
- // Cast: inputs is Record<string, unknown> at the SDK surface;
10280
- // buildActionRunContext validates it as JSON at runtime via zod
10281
- // (non-JSON values like Date/undefined are rejected there).
10282
- inputs: executionOptions.inputs ?? {}
10283
- })
10284
- }
10285
- );
10286
- const runId = runData.data.id;
10287
- return await api.poll(`/zapier/api/actions/v1/runs/${runId}`, {
10288
- successStatus: 200,
10289
- pendingStatus: 202,
10290
- timeoutMilliseconds: timeoutMilliseconds ?? DEFAULT_ACTION_TIMEOUT_MILLISECONDS,
10291
- resource: { type: "run", id: runId },
10292
- isPending: (result) => {
10293
- const data = result?.data;
10294
- return data?.status === "waiting";
10295
- },
10296
- resultExtractor: (result) => result.data
10297
- });
10298
- }
10245
+ var CreateActionRunSchema = zod.z.object({
10246
+ app: AppPropertySchema,
10247
+ actionType: ActionTypePropertySchema,
10248
+ action: ActionPropertySchema,
10249
+ connection: ConnectionPropertySchema.optional().describe(
10250
+ "Connection alias or connection ID (UUID or positive integer). Required if the action needs a connection to authenticate and interact with the service. Strings that match a key in the connections map are resolved against it; otherwise the value is used as a connection ID directly."
10251
+ ),
10252
+ inputs: InputsPropertySchema.optional().describe(
10253
+ "Input parameters for the action"
10254
+ ),
10255
+ page: zod.z.string().optional().describe(
10256
+ "Page to fetch for bulk read actions. Pass the `next_page` a previous run returned to fetch the following page."
10257
+ ),
10258
+ callbackUrl: zod.z.string().url().optional().describe(
10259
+ "URL Zapier posts the finished run to, so you do not have to poll for it. Must use HTTPS and resolve to a public host, so a local receiver needs a tunnel. The body matches what `getActionRun` returns. Verify the `Zapier-Callback-Signature` header, and expect the same run to arrive more than once."
10260
+ ).meta({ valueHint: "url" })
10261
+ }).describe(
10262
+ "Start an action run and return its ID without waiting for the result. Running an action is asynchronous: this hands back a run ID immediately, and `getActionRun` fetches the outcome. Reach for this pair when you want to start work and collect it later (fan out many runs, hand the ID to another process, survive a restart). `runAction` is the one-call form that starts a run and waits for its result."
10263
+ );
10264
+ var ActionRunStartedItemSchema = zod.z.object({
10265
+ id: zod.z.string().describe(
10266
+ "Action run ID. Pass it as the `run` for `getActionRun` to fetch the run's result."
10267
+ ),
10268
+ implementation_id: zod.z.string().describe(
10269
+ "Versioned implementation ID the run was started against (e.g. 'SlackCLIAPI@1.21.1'). The versionless app key is the part before the `@`."
10270
+ )
10271
+ });
10299
10272
  var CONTEXT_CACHE_TTL_MILLISECONDS = 6e4;
10300
10273
  var CONTEXT_CACHE_MAX_SIZE = 500;
10301
- var runActionPlugin = defineMethod({
10302
- name: "runAction",
10274
+ var createActionRunPlugin = defineMethod({
10275
+ name: "createActionRun",
10303
10276
  imports: [
10304
10277
  connectionsPluginRef,
10305
10278
  manifestPluginRef,
@@ -10307,14 +10280,11 @@ var runActionPlugin = defineMethod({
10307
10280
  getActionPlugin
10308
10281
  ],
10309
10282
  categories: ["action"],
10310
- itemType: "ActionResult",
10311
- inputSchema: RunActionInputSchema,
10312
- outputSchema: ActionResultItemSchema,
10313
- skipOutputValidation: true,
10314
- formatter: actionResultItemFormatter,
10315
- // No defaultPageSize — leave the default to the Actions API rather than
10316
- // eagerly running more actions than the user intends (avoids app rate limits).
10317
- output: "list",
10283
+ type: "create",
10284
+ itemType: "StartedActionRun",
10285
+ inputSchema: CreateActionRunSchema,
10286
+ outputSchema: ActionRunStartedItemSchema,
10287
+ output: "item",
10318
10288
  resolvers: {
10319
10289
  app: appKeyResolver,
10320
10290
  actionType: actionTypeResolver,
@@ -10322,14 +10292,12 @@ var runActionPlugin = defineMethod({
10322
10292
  connection: connectionIdResolver,
10323
10293
  inputs: inputsResolver
10324
10294
  },
10325
- // A per-SDK-instance TTL cache of resolved (selectedApi, actionId), built once
10326
- // in setup so it persists across calls. The imports it resolves through
10327
- // (`manifest.getVersionedImplementationId`, `getAction`) are threaded in per
10328
- // call from `run`, not captured here.
10329
10295
  setup: () => {
10330
10296
  const cache = /* @__PURE__ */ new Map();
10331
10297
  function evictIfNeeded() {
10332
- if (cache.size < CONTEXT_CACHE_MAX_SIZE) return;
10298
+ if (cache.size < CONTEXT_CACHE_MAX_SIZE) {
10299
+ return;
10300
+ }
10333
10301
  const now = Date.now();
10334
10302
  let oldestKey;
10335
10303
  let oldestExpiry = Infinity;
@@ -10343,13 +10311,15 @@ var runActionPlugin = defineMethod({
10343
10311
  oldestKey = key;
10344
10312
  }
10345
10313
  }
10346
- if (!evictedAny && oldestKey) cache.delete(oldestKey);
10314
+ if (!evictedAny && oldestKey) {
10315
+ cache.delete(oldestKey);
10316
+ }
10347
10317
  }
10348
- async function resolveRunActionContext(options) {
10318
+ async function resolveActionRunContext(options) {
10349
10319
  const { imports, appKey, actionKey, actionType } = options;
10350
10320
  const getVersionedImplementationId = imports.manifest.getVersionedImplementationId;
10351
- const selectedApi = await getVersionedImplementationId(appKey);
10352
- if (!selectedApi) {
10321
+ const implementationId = await getVersionedImplementationId(appKey);
10322
+ if (!implementationId) {
10353
10323
  throw new ZapierConfigurationError(
10354
10324
  "No current_implementation_id found for app",
10355
10325
  { configType: "current_implementation_id" }
@@ -10365,15 +10335,19 @@ var runActionPlugin = defineMethod({
10365
10335
  `Action type mismatch: expected ${actionType}, got ${actionData.data.action_type}`
10366
10336
  );
10367
10337
  }
10368
- return { selectedApi, actionId: actionData.data.id };
10338
+ return { implementationId, actionId: actionData.data.id };
10369
10339
  }
10370
- function getRunActionContext(options) {
10340
+ function getActionRunContext(options) {
10371
10341
  const contextKey = `${options.appKey}:${options.actionKey}:${options.actionType}`;
10372
10342
  const cached = cache.get(contextKey);
10373
- if (cached && Date.now() < cached.expiresAt) return cached.promise;
10374
- const pending = resolveRunActionContext(options).catch((error) => {
10343
+ if (cached && Date.now() < cached.expiresAt) {
10344
+ return cached.promise;
10345
+ }
10346
+ const pending = resolveActionRunContext(options).catch((error) => {
10375
10347
  const current = cache.get(contextKey);
10376
- if (current?.promise === pending) cache.delete(contextKey);
10348
+ if (current?.promise === pending) {
10349
+ cache.delete(contextKey);
10350
+ }
10377
10351
  throw error;
10378
10352
  });
10379
10353
  evictIfNeeded();
@@ -10383,11 +10357,105 @@ var runActionPlugin = defineMethod({
10383
10357
  });
10384
10358
  return pending;
10385
10359
  }
10386
- return { getRunActionContext };
10360
+ return { getActionRunContext };
10387
10361
  },
10388
10362
  run: async ({ imports, input, state, annotate }) => {
10389
10363
  const api = imports.api;
10390
- const resolveConnection = imports.connections.resolveConnection;
10364
+ const {
10365
+ app: appKey,
10366
+ action: actionKey,
10367
+ actionType,
10368
+ connection,
10369
+ inputs = {},
10370
+ page,
10371
+ callbackUrl
10372
+ } = input;
10373
+ const connectionId = await resolveConnectionId({
10374
+ connection,
10375
+ resolveConnection: imports.connections.resolveConnection
10376
+ });
10377
+ const { implementationId, actionId } = await state.getActionRunContext({
10378
+ imports,
10379
+ appKey,
10380
+ actionKey,
10381
+ actionType
10382
+ });
10383
+ annotate({ selectedApi: implementationId });
10384
+ const runRequestData = {
10385
+ selected_api: implementationId,
10386
+ // Some actions require the action ID, but it's not guaranteed available
10387
+ // at retrieval time (legacy), so pass everything through.
10388
+ action_id: actionId,
10389
+ action_key: actionKey,
10390
+ action_type: actionType,
10391
+ inputs
10392
+ };
10393
+ if (connectionId != null) {
10394
+ runRequestData.authentication_id = connectionId;
10395
+ }
10396
+ if (page) {
10397
+ runRequestData.page = page;
10398
+ }
10399
+ if (callbackUrl) {
10400
+ runRequestData.callback_url = callbackUrl;
10401
+ }
10402
+ const runData = await api.post(
10403
+ ACTION_RUNS_PATH,
10404
+ { data: runRequestData },
10405
+ {
10406
+ approvalContext: () => policyContext.buildActionRunContext({
10407
+ selected_api: implementationId,
10408
+ action_type: actionType,
10409
+ action_key: actionKey,
10410
+ connection_id: connectionId != null ? String(connectionId) : void 0,
10411
+ // `inputs` is `Record<string, unknown>` at the SDK surface;
10412
+ // buildActionRunContext validates it as JSON at runtime via zod
10413
+ // (non-JSON values like Date/undefined are rejected there).
10414
+ inputs
10415
+ })
10416
+ }
10417
+ );
10418
+ return {
10419
+ data: {
10420
+ id: runData.data.id,
10421
+ implementation_id: implementationId
10422
+ }
10423
+ };
10424
+ }
10425
+ });
10426
+
10427
+ // src/utils/action-run-wire.ts
10428
+ function actionRunPath(run) {
10429
+ return `${ACTION_RUNS_PATH}/${encodeURIComponent(run)}`;
10430
+ }
10431
+ function actionRunPayload(body) {
10432
+ return body?.data;
10433
+ }
10434
+ function isActionRunPending(body) {
10435
+ return actionRunPayload(body)?.status === "waiting";
10436
+ }
10437
+
10438
+ // src/plugins/runAction/index.ts
10439
+ var runActionPlugin = defineMethod({
10440
+ name: "runAction",
10441
+ imports: [apiPluginRef, connectionsPluginRef, createActionRunPlugin],
10442
+ categories: ["action"],
10443
+ itemType: "ActionResult",
10444
+ inputSchema: RunActionInputSchema,
10445
+ outputSchema: ActionResultItemSchema,
10446
+ skipOutputValidation: true,
10447
+ formatter: actionResultItemFormatter,
10448
+ // No defaultPageSize — leave the default to the Actions API rather than
10449
+ // eagerly running more actions than the user intends (avoids app rate limits).
10450
+ output: "list",
10451
+ resolvers: {
10452
+ app: appKeyResolver,
10453
+ actionType: actionTypeResolver,
10454
+ action: actionKeyResolver,
10455
+ connection: connectionIdResolver,
10456
+ inputs: inputsResolver
10457
+ },
10458
+ run: async ({ imports, input, annotate }) => {
10391
10459
  const appKey = "app" in input ? input.app : input.appKey;
10392
10460
  const actionKey = "action" in input ? input.action : input.actionKey;
10393
10461
  const {
@@ -10398,39 +10466,40 @@ var runActionPlugin = defineMethod({
10398
10466
  inputs = {},
10399
10467
  cursor
10400
10468
  } = input;
10401
- const timeoutMilliseconds = input.timeoutSeconds != null ? input.timeoutSeconds * 1e3 : input.timeoutMs;
10469
+ const timeoutMilliseconds = (input.timeoutSeconds != null ? input.timeoutSeconds * 1e3 : input.timeoutMs) ?? DEFAULT_ACTION_TIMEOUT_MILLISECONDS;
10402
10470
  const resolvedConnectionId = await resolveConnectionId({
10403
10471
  connectionId,
10404
10472
  connection,
10405
10473
  authenticationId,
10406
- resolveConnection
10407
- });
10408
- const { selectedApi, actionId } = await state.getRunActionContext({
10409
- imports,
10410
- appKey,
10411
- actionKey,
10412
- actionType
10474
+ resolveConnection: imports.connections.resolveConnection
10413
10475
  });
10414
- annotate({ selectedApi });
10415
- const result = await executeAction({
10416
- api,
10417
- selectedApi,
10418
- // Some actions require the action ID, but it's not guaranteed available at
10419
- // retrieval time (legacy), so pass everything through.
10420
- actionId,
10421
- actionKey,
10476
+ const { data: started } = await imports.createActionRun({
10477
+ app: appKey,
10422
10478
  actionType,
10423
- executionOptions: { inputs },
10424
- cursor,
10425
- connectionId: resolvedConnectionId,
10426
- timeoutMilliseconds
10479
+ action: actionKey,
10480
+ connection: resolvedConnectionId,
10481
+ inputs,
10482
+ page: cursor
10427
10483
  });
10428
- if (result.errors && result.errors.length > 0) {
10429
- const errorMessage2 = result.errors.map((error) => error.detail || error.title || "Unknown error").join("; ");
10484
+ annotate({ selectedApi: started.implementation_id });
10485
+ const run = await imports.api.poll(
10486
+ actionRunPath(started.id),
10487
+ {
10488
+ resource: { type: "run", id: started.id },
10489
+ successStatus: 200,
10490
+ pendingStatus: 202,
10491
+ timeoutMilliseconds,
10492
+ isPending: isActionRunPending,
10493
+ resultExtractor: (body) => actionRunPayload(body) ?? {}
10494
+ }
10495
+ );
10496
+ const errors = run.errors ?? [];
10497
+ if (errors.length > 0) {
10498
+ const errorMessage2 = errors.map((error) => error.detail || error.title || "Unknown error").join("; ");
10430
10499
  throw new ZapierActionError(`Action execution failed: ${errorMessage2}`, {
10431
10500
  appKey,
10432
10501
  actionKey,
10433
- errors: result.errors.map(
10502
+ errors: errors.map(
10434
10503
  (error) => ({
10435
10504
  status: 200,
10436
10505
  code: error.code ?? "unknown",
@@ -10441,10 +10510,10 @@ var runActionPlugin = defineMethod({
10441
10510
  });
10442
10511
  }
10443
10512
  return {
10444
- data: result.results || [],
10513
+ data: run.results ?? [],
10445
10514
  // Coerce to a string: the API returns a numeric page index, but
10446
10515
  // `SdkPage.nextCursor` is a string (and the page guard enforces it).
10447
- nextCursor: result.next_page != null ? String(result.next_page) : void 0
10516
+ nextCursor: run.next_page != null ? String(run.next_page) : void 0
10448
10517
  };
10449
10518
  }
10450
10519
  });
@@ -11875,6 +11944,65 @@ var findUniqueConnectionPlugin = defineMethod({
11875
11944
  return { data: connectionsResponse.data[0] };
11876
11945
  }
11877
11946
  });
11947
+ var GetActionRunSchema = zod.z.object({
11948
+ run: zod.z.string().min(1).describe("Action run ID returned by `createActionRun`")
11949
+ }).describe(
11950
+ "Fetch the current state of an action run started by `createActionRun`. This is a point-in-time read that returns immediately: a run Zapier has not finished executing comes back with status `waiting`, so call again to check for a result. `runAction` starts a run and waits for its result in one call. Results are stored for seven days after the run was created."
11951
+ );
11952
+ var ActionRunStatusSchema = openEnum(
11953
+ ["waiting", "success", "error", "unknown"],
11954
+ "Where the run is in its lifecycle. `waiting` means Zapier is still executing it; `error` means the app returned a failure (details in `errors`). `unknown` means the response carried no status, so the outcome could not be determined \u2014 treat it as inconclusive rather than as success."
11955
+ );
11956
+ var ActionRunErrorSchema = zod.z.object({
11957
+ code: zod.z.string().optional().describe("Machine-readable error category"),
11958
+ title: zod.z.string().nullable().optional().describe("Short error label"),
11959
+ detail: zod.z.string().optional().describe("Human-readable error detail")
11960
+ });
11961
+ var ActionRunItemSchema = zod.z.object({
11962
+ id: zod.z.string().describe("Action run ID"),
11963
+ status: ActionRunStatusSchema,
11964
+ results: zod.z.array(zod.z.unknown()).describe(
11965
+ "Records the action produced. Can be empty even on a successful run."
11966
+ ),
11967
+ next_page: zod.z.string().optional().describe(
11968
+ "For bulk read actions, the following page. Pass it back as the `page` for `createActionRun` to fetch that page."
11969
+ ),
11970
+ errors: zod.z.array(ActionRunErrorSchema).describe("Errors the app returned while running the action")
11971
+ });
11972
+
11973
+ // src/plugins/getActionRun/index.ts
11974
+ function toActionRun(runId, payload) {
11975
+ if (!payload) {
11976
+ return { id: runId, status: "waiting", results: [], errors: [] };
11977
+ }
11978
+ return {
11979
+ id: payload.id ?? runId,
11980
+ // Never infer success from an absent status.
11981
+ status: payload.status ?? "unknown",
11982
+ results: payload.results ?? [],
11983
+ // The API answers with either a page token or a numeric page index, but
11984
+ // `createActionRun` takes `page` as a string, so normalize to one type the
11985
+ // caller can hand straight back.
11986
+ ...payload.next_page != null ? { next_page: String(payload.next_page) } : {},
11987
+ errors: payload.errors ?? []
11988
+ };
11989
+ }
11990
+ var getActionRunPlugin = defineMethod({
11991
+ name: "getActionRun",
11992
+ imports: [apiPluginRef],
11993
+ categories: ["action"],
11994
+ itemType: "ActionRun",
11995
+ inputSchema: GetActionRunSchema,
11996
+ outputSchema: ActionRunItemSchema,
11997
+ output: "item",
11998
+ run: async ({ imports, input }) => {
11999
+ const body = await imports.api.get(
12000
+ actionRunPath(input.run),
12001
+ { resource: { type: "run", id: input.run } }
12002
+ );
12003
+ return { data: toActionRun(input.run, actionRunPayload(body)) };
12004
+ }
12005
+ });
11878
12006
  var RelayRequestSchema = zod.z.object({
11879
12007
  url: zod.z.string().url().describe("The URL to request (will be proxied through Relay)"),
11880
12008
  method: zod.z.enum(["GET", "POST", "PUT", "DELETE", "PATCH", "HEAD", "OPTIONS"]).optional().describe("HTTP method"),
@@ -15701,6 +15829,8 @@ var zapierSdkPlugin = definePlugin({
15701
15829
  listInputFieldsDeprecatedPlugin,
15702
15830
  getInputFieldsSchemaDeprecatedPlugin,
15703
15831
  listInputFieldChoicesDeprecatedPlugin,
15832
+ createActionRunPlugin,
15833
+ getActionRunPlugin,
15704
15834
  runActionPlugin,
15705
15835
  fetchPlugin,
15706
15836
  requestPlugin,
@@ -15915,6 +16045,7 @@ var registryPlugin = (_sdk) => {
15915
16045
  return {};
15916
16046
  };
15917
16047
 
16048
+ exports.ACTION_RUNS_PATH = ACTION_RUNS_PATH;
15918
16049
  exports.API_ID = API_ID;
15919
16050
  exports.ActionKeyPropertySchema = ActionKeyPropertySchema;
15920
16051
  exports.ActionPropertySchema = ActionPropertySchema;
@@ -16028,6 +16159,7 @@ exports.connectionIdGenericResolver = connectionIdGenericResolver;
16028
16159
  exports.connectionIdResolver = connectionIdResolver;
16029
16160
  exports.connectionsPlugin = connectionsPlugin;
16030
16161
  exports.connectionsPluginRef = connectionsPluginRef;
16162
+ exports.createActionRunPlugin = createActionRunPlugin;
16031
16163
  exports.createBaseEvent = createBaseEvent;
16032
16164
  exports.createClientCredentialsPlugin = createClientCredentialsPlugin;
16033
16165
  exports.createController = createController;
@@ -16075,6 +16207,7 @@ exports.fromFunctionPlugin = fromFunctionPlugin;
16075
16207
  exports.generateEventId = generateEventId;
16076
16208
  exports.getActionInputFieldsSchemaPlugin = getActionInputFieldsSchemaPlugin;
16077
16209
  exports.getActionPlugin = getActionPlugin;
16210
+ exports.getActionRunPlugin = getActionRunPlugin;
16078
16211
  exports.getAgent = getAgent;
16079
16212
  exports.getAppPlugin = getAppPlugin;
16080
16213
  exports.getBaseUrlFromCredentials = getBaseUrlFromCredentials;