@zapier/zapier-sdk 0.65.0 → 0.68.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +48 -0
- package/README.md +64 -34
- package/dist/api/client.d.ts.map +1 -1
- package/dist/api/client.js +2 -0
- package/dist/api/debug.d.ts.map +1 -1
- package/dist/api/debug.js +6 -4
- package/dist/api/polling.d.ts +2 -0
- package/dist/api/polling.d.ts.map +1 -1
- package/dist/api/polling.js +10 -2
- package/dist/auth.d.ts.map +1 -1
- package/dist/auth.js +8 -5
- package/dist/core-stack.d.ts +24 -0
- package/dist/core-stack.d.ts.map +1 -0
- package/dist/core-stack.js +32 -0
- package/dist/experimental.cjs +1598 -1323
- package/dist/experimental.d.mts +3476 -224
- package/dist/experimental.d.ts +3508 -256
- package/dist/experimental.d.ts.map +1 -1
- package/dist/experimental.js +117 -87
- package/dist/experimental.mjs +1585 -1322
- package/dist/formatters/action.d.ts +4 -0
- package/dist/formatters/action.d.ts.map +1 -0
- package/dist/formatters/action.js +18 -0
- package/dist/formatters/actionResult.d.ts +3 -0
- package/dist/formatters/actionResult.d.ts.map +1 -0
- package/dist/formatters/actionResult.js +25 -0
- package/dist/formatters/app.d.ts +4 -0
- package/dist/formatters/app.d.ts.map +1 -0
- package/dist/formatters/app.js +10 -0
- package/dist/formatters/clientCredentials.d.ts +5 -0
- package/dist/formatters/clientCredentials.d.ts.map +1 -0
- package/dist/formatters/clientCredentials.js +27 -0
- package/dist/formatters/connection.d.ts +4 -0
- package/dist/formatters/connection.d.ts.map +1 -0
- package/dist/formatters/connection.js +26 -0
- package/dist/formatters/field.d.ts +4 -0
- package/dist/formatters/field.d.ts.map +1 -0
- package/dist/formatters/field.js +51 -0
- package/dist/formatters/inputFieldChoice.d.ts +4 -0
- package/dist/formatters/inputFieldChoice.d.ts.map +1 -0
- package/dist/formatters/inputFieldChoice.js +16 -0
- package/dist/formatters/tableField.d.ts +4 -0
- package/dist/formatters/tableField.d.ts.map +1 -0
- package/dist/formatters/tableField.js +7 -0
- package/dist/formatters/tableRecord.d.ts +5 -3
- package/dist/formatters/tableRecord.d.ts.map +1 -1
- package/dist/formatters/tableRecord.js +4 -3
- package/dist/formatters/triggerInbox.d.ts +4 -0
- package/dist/formatters/triggerInbox.d.ts.map +1 -0
- package/dist/formatters/triggerInbox.js +31 -0
- package/dist/formatters/triggerMessage.d.ts +5 -0
- package/dist/formatters/triggerMessage.d.ts.map +1 -0
- package/dist/formatters/triggerMessage.js +34 -0
- package/dist/formatters/userProfile.d.ts +4 -0
- package/dist/formatters/userProfile.d.ts.map +1 -0
- package/dist/formatters/userProfile.js +19 -0
- package/dist/{index-JhNxS_mq.d.mts → index-oRnHsPn5.d.mts} +12906 -7603
- package/dist/{index-JhNxS_mq.d.ts → index-oRnHsPn5.d.ts} +12906 -7603
- package/dist/index.cjs +1729 -1469
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +12 -9
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +21 -7
- package/dist/index.mjs +1716 -1468
- package/dist/plugins/api/index.d.ts +1 -1
- package/dist/plugins/api/index.js +1 -1
- package/dist/plugins/apps/index.d.ts +8 -5
- package/dist/plugins/apps/index.d.ts.map +1 -1
- package/dist/plugins/apps/index.js +1 -1
- package/dist/plugins/capabilities/index.d.ts +1 -1
- package/dist/plugins/capabilities/index.js +1 -1
- package/dist/plugins/codeSubstrate/cancelDurableRun/index.d.ts +32 -2
- package/dist/plugins/codeSubstrate/cancelDurableRun/index.d.ts.map +1 -1
- package/dist/plugins/codeSubstrate/cancelDurableRun/index.js +1 -1
- package/dist/plugins/codeSubstrate/createWorkflow/index.d.ts +2 -2
- package/dist/plugins/codeSubstrate/createWorkflow/index.js +1 -1
- package/dist/plugins/codeSubstrate/deleteWorkflow/index.d.ts +27 -2
- package/dist/plugins/codeSubstrate/deleteWorkflow/index.d.ts.map +1 -1
- package/dist/plugins/codeSubstrate/deleteWorkflow/index.js +1 -1
- package/dist/plugins/codeSubstrate/disableWorkflow/index.d.ts +27 -2
- package/dist/plugins/codeSubstrate/disableWorkflow/index.d.ts.map +1 -1
- package/dist/plugins/codeSubstrate/disableWorkflow/index.js +1 -1
- package/dist/plugins/codeSubstrate/enableWorkflow/index.d.ts +27 -2
- package/dist/plugins/codeSubstrate/enableWorkflow/index.d.ts.map +1 -1
- package/dist/plugins/codeSubstrate/enableWorkflow/index.js +1 -1
- package/dist/plugins/codeSubstrate/getDurableRun/index.d.ts +32 -2
- package/dist/plugins/codeSubstrate/getDurableRun/index.d.ts.map +1 -1
- package/dist/plugins/codeSubstrate/getDurableRun/index.js +1 -1
- package/dist/plugins/codeSubstrate/getTriggerRun/index.d.ts +2 -2
- package/dist/plugins/codeSubstrate/getTriggerRun/index.js +1 -1
- package/dist/plugins/codeSubstrate/getWorkflow/index.d.ts +27 -2
- package/dist/plugins/codeSubstrate/getWorkflow/index.d.ts.map +1 -1
- package/dist/plugins/codeSubstrate/getWorkflow/index.js +1 -1
- package/dist/plugins/codeSubstrate/getWorkflowRun/index.d.ts +55 -2
- package/dist/plugins/codeSubstrate/getWorkflowRun/index.d.ts.map +1 -1
- package/dist/plugins/codeSubstrate/getWorkflowRun/index.js +1 -1
- package/dist/plugins/codeSubstrate/getWorkflowVersion/index.d.ts +51 -2
- package/dist/plugins/codeSubstrate/getWorkflowVersion/index.d.ts.map +1 -1
- package/dist/plugins/codeSubstrate/getWorkflowVersion/index.js +1 -1
- package/dist/plugins/codeSubstrate/listDurableRuns/index.d.ts +3 -3
- package/dist/plugins/codeSubstrate/listDurableRuns/index.d.ts.map +1 -1
- package/dist/plugins/codeSubstrate/listDurableRuns/index.js +1 -1
- package/dist/plugins/codeSubstrate/listWorkflowRuns/index.d.ts +28 -3
- package/dist/plugins/codeSubstrate/listWorkflowRuns/index.d.ts.map +1 -1
- package/dist/plugins/codeSubstrate/listWorkflowRuns/index.js +1 -1
- package/dist/plugins/codeSubstrate/listWorkflowVersions/index.d.ts +28 -3
- package/dist/plugins/codeSubstrate/listWorkflowVersions/index.d.ts.map +1 -1
- package/dist/plugins/codeSubstrate/listWorkflowVersions/index.js +1 -1
- package/dist/plugins/codeSubstrate/listWorkflows/index.d.ts +3 -3
- package/dist/plugins/codeSubstrate/listWorkflows/index.d.ts.map +1 -1
- package/dist/plugins/codeSubstrate/listWorkflows/index.js +2 -3
- package/dist/plugins/codeSubstrate/publishWorkflowVersion/index.d.ts +27 -2
- package/dist/plugins/codeSubstrate/publishWorkflowVersion/index.d.ts.map +1 -1
- package/dist/plugins/codeSubstrate/publishWorkflowVersion/index.js +1 -1
- package/dist/plugins/codeSubstrate/runDurable/index.d.ts +2 -2
- package/dist/plugins/codeSubstrate/runDurable/index.js +1 -1
- package/dist/plugins/codeSubstrate/triggerWorkflow/index.d.ts +73 -0
- package/dist/plugins/codeSubstrate/triggerWorkflow/index.d.ts.map +1 -0
- package/dist/plugins/codeSubstrate/triggerWorkflow/index.js +52 -0
- package/dist/plugins/codeSubstrate/triggerWorkflow/schemas.d.ts +16 -0
- package/dist/plugins/codeSubstrate/triggerWorkflow/schemas.d.ts.map +1 -0
- package/dist/plugins/codeSubstrate/triggerWorkflow/schemas.js +31 -0
- package/dist/plugins/codeSubstrate/updateWorkflow/index.d.ts +27 -2
- package/dist/plugins/codeSubstrate/updateWorkflow/index.d.ts.map +1 -1
- package/dist/plugins/codeSubstrate/updateWorkflow/index.js +1 -1
- package/dist/plugins/connections/index.d.ts +1 -1
- package/dist/plugins/connections/index.js +1 -1
- package/dist/plugins/createClientCredentials/index.d.ts +2 -2
- package/dist/plugins/createClientCredentials/index.d.ts.map +1 -1
- package/dist/plugins/createClientCredentials/index.js +4 -2
- package/dist/plugins/createClientCredentials/schemas.d.ts +1 -2
- package/dist/plugins/createClientCredentials/schemas.d.ts.map +1 -1
- package/dist/plugins/deleteClientCredentials/index.d.ts +24 -2
- package/dist/plugins/deleteClientCredentials/index.d.ts.map +1 -1
- package/dist/plugins/deleteClientCredentials/index.js +2 -2
- package/dist/plugins/deleteClientCredentials/schemas.d.ts +1 -2
- package/dist/plugins/deleteClientCredentials/schemas.d.ts.map +1 -1
- package/dist/plugins/deprecated/authentications.d.ts +144 -16
- package/dist/plugins/deprecated/authentications.d.ts.map +1 -1
- package/dist/plugins/deprecated/authentications.js +14 -5
- package/dist/plugins/deprecated/inputFields.d.ts +58 -23
- package/dist/plugins/deprecated/inputFields.d.ts.map +1 -1
- package/dist/plugins/deprecated/inputFields.js +15 -7
- package/dist/plugins/eventEmission/event-emission-hook.d.ts +10 -0
- package/dist/plugins/eventEmission/event-emission-hook.d.ts.map +1 -0
- package/dist/plugins/eventEmission/event-emission-hook.js +47 -0
- package/dist/plugins/eventEmission/index.d.ts +5 -3
- package/dist/plugins/eventEmission/index.d.ts.map +1 -1
- package/dist/plugins/eventEmission/index.js +16 -9
- package/dist/plugins/eventEmission/method-metadata.d.ts +16 -0
- package/dist/plugins/eventEmission/method-metadata.d.ts.map +1 -0
- package/dist/plugins/eventEmission/method-metadata.js +20 -0
- package/dist/plugins/eventEmission/transport.d.ts.map +1 -1
- package/dist/plugins/eventEmission/transport.js +2 -1
- package/dist/plugins/eventEmission/types.d.ts +1 -1
- package/dist/plugins/eventEmission/types.d.ts.map +1 -1
- package/dist/plugins/fetch/index.d.ts +11 -5
- package/dist/plugins/fetch/index.d.ts.map +1 -1
- package/dist/plugins/fetch/index.js +42 -32
- package/dist/plugins/fetch/schemas.d.ts +1 -1
- package/dist/plugins/findFirstConnection/index.d.ts +4 -4
- package/dist/plugins/findFirstConnection/index.d.ts.map +1 -1
- package/dist/plugins/findFirstConnection/index.js +4 -2
- package/dist/plugins/findFirstConnection/schemas.d.ts +2 -2
- package/dist/plugins/findUniqueConnection/index.d.ts +4 -4
- package/dist/plugins/findUniqueConnection/index.d.ts.map +1 -1
- package/dist/plugins/findUniqueConnection/index.js +4 -2
- package/dist/plugins/findUniqueConnection/schemas.d.ts +2 -2
- package/dist/plugins/getAction/index.d.ts +141 -4
- package/dist/plugins/getAction/index.d.ts.map +1 -1
- package/dist/plugins/getAction/index.js +5 -3
- package/dist/plugins/getAction/schemas.d.ts +6 -6
- package/dist/plugins/getActionInputFieldsSchema/index.d.ts +232 -3
- package/dist/plugins/getActionInputFieldsSchema/index.d.ts.map +1 -1
- package/dist/plugins/getActionInputFieldsSchema/index.js +3 -3
- package/dist/plugins/getActionInputFieldsSchema/schemas.d.ts +6 -6
- package/dist/plugins/getApp/index.d.ts +4 -4
- package/dist/plugins/getApp/index.d.ts.map +1 -1
- package/dist/plugins/getApp/index.js +3 -1
- package/dist/plugins/getApp/schemas.d.ts +4 -4
- package/dist/plugins/getConnection/index.d.ts +125 -2
- package/dist/plugins/getConnection/index.d.ts.map +1 -1
- package/dist/plugins/getConnection/index.js +4 -2
- package/dist/plugins/getProfile/index.d.ts +2 -2
- package/dist/plugins/getProfile/index.d.ts.map +1 -1
- package/dist/plugins/getProfile/index.js +4 -2
- package/dist/plugins/getProfile/schemas.d.ts +1 -2
- package/dist/plugins/getProfile/schemas.d.ts.map +1 -1
- package/dist/plugins/listActionInputFieldChoices/index.d.ts +287 -4
- package/dist/plugins/listActionInputFieldChoices/index.d.ts.map +1 -1
- package/dist/plugins/listActionInputFieldChoices/index.js +6 -4
- package/dist/plugins/listActionInputFieldChoices/schemas.d.ts +8 -8
- package/dist/plugins/listActionInputFieldChoices/schemas.d.ts.map +1 -1
- package/dist/plugins/listActionInputFieldChoices/schemas.js +1 -22
- package/dist/plugins/listActionInputFields/index.d.ts +168 -5
- package/dist/plugins/listActionInputFields/index.d.ts.map +1 -1
- package/dist/plugins/listActionInputFields/index.js +7 -5
- package/dist/plugins/listActionInputFields/schemas.d.ts +6 -6
- package/dist/plugins/listActions/index.d.ts +140 -3
- package/dist/plugins/listActions/index.d.ts.map +1 -1
- package/dist/plugins/listActions/index.js +6 -4
- package/dist/plugins/listActions/schemas.d.ts +4 -4
- package/dist/plugins/listApps/index.d.ts +3 -3
- package/dist/plugins/listApps/index.d.ts.map +1 -1
- package/dist/plugins/listApps/index.js +6 -4
- package/dist/plugins/listClientCredentials/index.d.ts +3 -3
- package/dist/plugins/listClientCredentials/index.d.ts.map +1 -1
- package/dist/plugins/listClientCredentials/index.js +6 -4
- package/dist/plugins/listConnections/index.d.ts +140 -3
- package/dist/plugins/listConnections/index.d.ts.map +1 -1
- package/dist/plugins/listConnections/index.js +7 -5
- package/dist/plugins/listConnections/schemas.d.ts +2 -2
- package/dist/plugins/manifest/index.d.ts +1 -1
- package/dist/plugins/manifest/index.d.ts.map +1 -1
- package/dist/plugins/manifest/index.js +6 -4
- package/dist/plugins/registry/index.d.ts +1 -1
- package/dist/plugins/registry/index.js +1 -1
- package/dist/plugins/request/index.d.ts +8 -5
- package/dist/plugins/request/index.d.ts.map +1 -1
- package/dist/plugins/request/index.js +4 -3
- package/dist/plugins/request/schemas.d.ts +2 -2
- package/dist/plugins/runAction/index.d.ts +168 -5
- package/dist/plugins/runAction/index.d.ts.map +1 -1
- package/dist/plugins/runAction/index.js +9 -5
- package/dist/plugins/runAction/schemas.d.ts +6 -6
- package/dist/plugins/tables/createTable/index.d.ts +2 -2
- package/dist/plugins/tables/createTable/index.js +2 -2
- package/dist/plugins/tables/createTable/schemas.d.ts +1 -2
- package/dist/plugins/tables/createTable/schemas.d.ts.map +1 -1
- package/dist/plugins/tables/createTableFields/index.d.ts +34 -2
- package/dist/plugins/tables/createTableFields/index.d.ts.map +1 -1
- package/dist/plugins/tables/createTableFields/index.js +4 -2
- package/dist/plugins/tables/createTableFields/schemas.d.ts +3 -4
- package/dist/plugins/tables/createTableFields/schemas.d.ts.map +1 -1
- package/dist/plugins/tables/createTableRecords/index.d.ts +63 -2
- package/dist/plugins/tables/createTableRecords/index.d.ts.map +1 -1
- package/dist/plugins/tables/createTableRecords/index.js +2 -2
- package/dist/plugins/tables/createTableRecords/schemas.d.ts +3 -4
- package/dist/plugins/tables/createTableRecords/schemas.d.ts.map +1 -1
- package/dist/plugins/tables/deleteTable/index.d.ts +34 -2
- package/dist/plugins/tables/deleteTable/index.d.ts.map +1 -1
- package/dist/plugins/tables/deleteTable/index.js +2 -2
- package/dist/plugins/tables/deleteTable/schemas.d.ts +3 -4
- package/dist/plugins/tables/deleteTable/schemas.d.ts.map +1 -1
- package/dist/plugins/tables/deleteTableFields/index.d.ts +63 -2
- package/dist/plugins/tables/deleteTableFields/index.d.ts.map +1 -1
- package/dist/plugins/tables/deleteTableFields/index.js +2 -2
- package/dist/plugins/tables/deleteTableFields/schemas.d.ts +4 -5
- package/dist/plugins/tables/deleteTableFields/schemas.d.ts.map +1 -1
- package/dist/plugins/tables/deleteTableRecords/index.d.ts +84 -2
- package/dist/plugins/tables/deleteTableRecords/index.d.ts.map +1 -1
- package/dist/plugins/tables/deleteTableRecords/index.js +2 -2
- package/dist/plugins/tables/deleteTableRecords/schemas.d.ts +4 -5
- package/dist/plugins/tables/deleteTableRecords/schemas.d.ts.map +1 -1
- package/dist/plugins/tables/getTable/index.d.ts +34 -2
- package/dist/plugins/tables/getTable/index.d.ts.map +1 -1
- package/dist/plugins/tables/getTable/index.js +2 -2
- package/dist/plugins/tables/getTable/schemas.d.ts +2 -2
- package/dist/plugins/tables/getTableRecord/index.d.ts +84 -2
- package/dist/plugins/tables/getTableRecord/index.d.ts.map +1 -1
- package/dist/plugins/tables/getTableRecord/index.js +2 -2
- package/dist/plugins/tables/getTableRecord/schemas.d.ts +6 -7
- package/dist/plugins/tables/getTableRecord/schemas.d.ts.map +1 -1
- package/dist/plugins/tables/getTableRecord/schemas.js +1 -10
- package/dist/plugins/tables/listTableFields/index.d.ts +34 -2
- package/dist/plugins/tables/listTableFields/index.d.ts.map +1 -1
- package/dist/plugins/tables/listTableFields/index.js +4 -2
- package/dist/plugins/tables/listTableFields/schemas.d.ts +4 -5
- package/dist/plugins/tables/listTableFields/schemas.d.ts.map +1 -1
- package/dist/plugins/tables/listTableFields/schemas.js +1 -9
- package/dist/plugins/tables/listTableRecords/index.d.ts +65 -4
- package/dist/plugins/tables/listTableRecords/index.d.ts.map +1 -1
- package/dist/plugins/tables/listTableRecords/index.js +3 -3
- package/dist/plugins/tables/listTableRecords/schemas.d.ts +2 -2
- package/dist/plugins/tables/listTables/index.d.ts +3 -3
- package/dist/plugins/tables/listTables/index.d.ts.map +1 -1
- package/dist/plugins/tables/listTables/index.js +4 -4
- package/dist/plugins/tables/updateTableRecords/index.d.ts +63 -2
- package/dist/plugins/tables/updateTableRecords/index.d.ts.map +1 -1
- package/dist/plugins/tables/updateTableRecords/index.js +2 -2
- package/dist/plugins/tables/updateTableRecords/schemas.d.ts +3 -4
- package/dist/plugins/tables/updateTableRecords/schemas.d.ts.map +1 -1
- package/dist/plugins/triggers/ackTriggerInboxMessages/index.d.ts +59 -2
- package/dist/plugins/triggers/ackTriggerInboxMessages/index.d.ts.map +1 -1
- package/dist/plugins/triggers/ackTriggerInboxMessages/index.js +1 -1
- package/dist/plugins/triggers/ackTriggerInboxMessages/schemas.d.ts +1 -1
- package/dist/plugins/triggers/createTriggerInbox/index.d.ts +231 -2
- package/dist/plugins/triggers/createTriggerInbox/index.d.ts.map +1 -1
- package/dist/plugins/triggers/createTriggerInbox/index.js +3 -1
- package/dist/plugins/triggers/createTriggerInbox/schemas.d.ts +3 -4
- package/dist/plugins/triggers/createTriggerInbox/schemas.d.ts.map +1 -1
- package/dist/plugins/triggers/deleteTriggerInbox/index.d.ts +33 -2
- package/dist/plugins/triggers/deleteTriggerInbox/index.d.ts.map +1 -1
- package/dist/plugins/triggers/deleteTriggerInbox/index.js +3 -1
- package/dist/plugins/triggers/deleteTriggerInbox/schemas.d.ts +2 -3
- package/dist/plugins/triggers/deleteTriggerInbox/schemas.d.ts.map +1 -1
- package/dist/plugins/triggers/drainTriggerInbox/index.d.ts +68 -6
- package/dist/plugins/triggers/drainTriggerInbox/index.d.ts.map +1 -1
- package/dist/plugins/triggers/drainTriggerInbox/index.js +1 -1
- package/dist/plugins/triggers/drainTriggerInbox/schemas.d.ts +2 -2
- package/dist/plugins/triggers/ensureTriggerInbox/index.d.ts +231 -2
- package/dist/plugins/triggers/ensureTriggerInbox/index.d.ts.map +1 -1
- package/dist/plugins/triggers/ensureTriggerInbox/index.js +3 -1
- package/dist/plugins/triggers/ensureTriggerInbox/schemas.d.ts +3 -4
- package/dist/plugins/triggers/ensureTriggerInbox/schemas.d.ts.map +1 -1
- package/dist/plugins/triggers/getTriggerInbox/index.d.ts +33 -2
- package/dist/plugins/triggers/getTriggerInbox/index.d.ts.map +1 -1
- package/dist/plugins/triggers/getTriggerInbox/index.js +3 -1
- package/dist/plugins/triggers/getTriggerInbox/schemas.d.ts +2 -3
- package/dist/plugins/triggers/getTriggerInbox/schemas.d.ts.map +1 -1
- package/dist/plugins/triggers/getTriggerInputFieldsSchema/index.d.ts +232 -3
- package/dist/plugins/triggers/getTriggerInputFieldsSchema/index.d.ts.map +1 -1
- package/dist/plugins/triggers/getTriggerInputFieldsSchema/index.js +1 -1
- package/dist/plugins/triggers/getTriggerInputFieldsSchema/schemas.d.ts +2 -2
- package/dist/plugins/triggers/leaseTriggerInboxMessages/index.d.ts +33 -2
- package/dist/plugins/triggers/leaseTriggerInboxMessages/index.d.ts.map +1 -1
- package/dist/plugins/triggers/leaseTriggerInboxMessages/index.js +1 -1
- package/dist/plugins/triggers/leaseTriggerInboxMessages/schemas.d.ts +1 -1
- package/dist/plugins/triggers/listTriggerInboxMessages/index.d.ts +34 -3
- package/dist/plugins/triggers/listTriggerInboxMessages/index.d.ts.map +1 -1
- package/dist/plugins/triggers/listTriggerInboxMessages/index.js +5 -13
- package/dist/plugins/triggers/listTriggerInboxMessages/schemas.d.ts +1 -1
- package/dist/plugins/triggers/listTriggerInboxes/index.d.ts +3 -3
- package/dist/plugins/triggers/listTriggerInboxes/index.d.ts.map +1 -1
- package/dist/plugins/triggers/listTriggerInboxes/index.js +5 -14
- package/dist/plugins/triggers/listTriggerInputFieldChoices/index.d.ts +288 -5
- package/dist/plugins/triggers/listTriggerInputFieldChoices/index.d.ts.map +1 -1
- package/dist/plugins/triggers/listTriggerInputFieldChoices/index.js +7 -5
- package/dist/plugins/triggers/listTriggerInputFieldChoices/schemas.d.ts +3 -3
- package/dist/plugins/triggers/listTriggerInputFields/index.d.ts +234 -5
- package/dist/plugins/triggers/listTriggerInputFields/index.d.ts.map +1 -1
- package/dist/plugins/triggers/listTriggerInputFields/index.js +6 -5
- package/dist/plugins/triggers/listTriggerInputFields/schemas.d.ts +2 -2
- package/dist/plugins/triggers/listTriggers/index.d.ts +142 -5
- package/dist/plugins/triggers/listTriggers/index.d.ts.map +1 -1
- package/dist/plugins/triggers/listTriggers/index.js +6 -5
- package/dist/plugins/triggers/listTriggers/schemas.d.ts +1 -1
- package/dist/plugins/triggers/pauseTriggerInbox/index.d.ts +33 -2
- package/dist/plugins/triggers/pauseTriggerInbox/index.d.ts.map +1 -1
- package/dist/plugins/triggers/pauseTriggerInbox/index.js +3 -1
- package/dist/plugins/triggers/pauseTriggerInbox/schemas.d.ts +2 -3
- package/dist/plugins/triggers/pauseTriggerInbox/schemas.d.ts.map +1 -1
- package/dist/plugins/triggers/releaseTriggerInboxMessages/index.d.ts +59 -2
- package/dist/plugins/triggers/releaseTriggerInboxMessages/index.d.ts.map +1 -1
- package/dist/plugins/triggers/releaseTriggerInboxMessages/index.js +1 -1
- package/dist/plugins/triggers/releaseTriggerInboxMessages/schemas.d.ts +1 -1
- package/dist/plugins/triggers/resumeTriggerInbox/index.d.ts +33 -2
- package/dist/plugins/triggers/resumeTriggerInbox/index.d.ts.map +1 -1
- package/dist/plugins/triggers/resumeTriggerInbox/index.js +3 -1
- package/dist/plugins/triggers/resumeTriggerInbox/schemas.d.ts +2 -3
- package/dist/plugins/triggers/resumeTriggerInbox/schemas.d.ts.map +1 -1
- package/dist/plugins/triggers/updateTriggerInbox/index.d.ts +33 -2
- package/dist/plugins/triggers/updateTriggerInbox/index.d.ts.map +1 -1
- package/dist/plugins/triggers/updateTriggerInbox/index.js +3 -1
- package/dist/plugins/triggers/updateTriggerInbox/schemas.d.ts +2 -3
- package/dist/plugins/triggers/updateTriggerInbox/schemas.d.ts.map +1 -1
- package/dist/plugins/triggers/watchTriggerInbox/index.d.ts +37 -6
- package/dist/plugins/triggers/watchTriggerInbox/index.d.ts.map +1 -1
- package/dist/plugins/triggers/watchTriggerInbox/index.js +1 -1
- package/dist/resolvers/actionKey.d.ts +3 -2
- package/dist/resolvers/actionKey.d.ts.map +1 -1
- package/dist/resolvers/actionType.d.ts +7 -2
- package/dist/resolvers/actionType.d.ts.map +1 -1
- package/dist/resolvers/actionType.js +3 -0
- package/dist/resolvers/appKey.d.ts +10 -5
- package/dist/resolvers/appKey.d.ts.map +1 -1
- package/dist/resolvers/appKey.js +3 -0
- package/dist/resolvers/clientCredentialsName.d.ts +1 -1
- package/dist/resolvers/clientCredentialsName.d.ts.map +1 -1
- package/dist/resolvers/clientId.d.ts +3 -2
- package/dist/resolvers/clientId.d.ts.map +1 -1
- package/dist/resolvers/clientId.js +1 -1
- package/dist/resolvers/connectionId.d.ts +5 -2
- package/dist/resolvers/connectionId.d.ts.map +1 -1
- package/dist/resolvers/connectionId.js +1 -1
- package/dist/resolvers/durableRunId.d.ts +3 -2
- package/dist/resolvers/durableRunId.d.ts.map +1 -1
- package/dist/resolvers/durableRunId.js +3 -2
- package/dist/resolvers/inputFieldKey.d.ts +3 -2
- package/dist/resolvers/inputFieldKey.d.ts.map +1 -1
- package/dist/resolvers/inputFieldKey.js +1 -1
- package/dist/resolvers/tableFieldIds.d.ts +3 -2
- package/dist/resolvers/tableFieldIds.d.ts.map +1 -1
- package/dist/resolvers/tableFields.d.ts +2 -2
- package/dist/resolvers/tableFields.d.ts.map +1 -1
- package/dist/resolvers/tableFilters.d.ts +3 -2
- package/dist/resolvers/tableFilters.d.ts.map +1 -1
- package/dist/resolvers/tableId.d.ts +3 -2
- package/dist/resolvers/tableId.d.ts.map +1 -1
- package/dist/resolvers/tableId.js +1 -1
- package/dist/resolvers/tableName.d.ts +1 -1
- package/dist/resolvers/tableName.d.ts.map +1 -1
- package/dist/resolvers/tableRecordId.d.ts +4 -3
- package/dist/resolvers/tableRecordId.d.ts.map +1 -1
- package/dist/resolvers/tableRecords.d.ts +4 -3
- package/dist/resolvers/tableRecords.d.ts.map +1 -1
- package/dist/resolvers/tableSort.d.ts +3 -2
- package/dist/resolvers/tableSort.d.ts.map +1 -1
- package/dist/resolvers/triggerInbox.d.ts +3 -2
- package/dist/resolvers/triggerInbox.d.ts.map +1 -1
- package/dist/resolvers/triggerInbox.js +1 -1
- package/dist/resolvers/triggerMessages.d.ts +3 -2
- package/dist/resolvers/triggerMessages.d.ts.map +1 -1
- package/dist/resolvers/triggerMessages.js +2 -4
- package/dist/resolvers/workflowId.d.ts +3 -2
- package/dist/resolvers/workflowId.d.ts.map +1 -1
- package/dist/resolvers/workflowId.js +3 -2
- package/dist/resolvers/workflowRunId.d.ts +3 -2
- package/dist/resolvers/workflowRunId.d.ts.map +1 -1
- package/dist/resolvers/workflowRunId.js +5 -5
- package/dist/resolvers/workflowVersionId.d.ts +3 -2
- package/dist/resolvers/workflowVersionId.d.ts.map +1 -1
- package/dist/resolvers/workflowVersionId.js +7 -7
- package/dist/schemas/Action.d.ts.map +1 -1
- package/dist/schemas/Action.js +6 -30
- package/dist/schemas/App.d.ts +0 -1
- package/dist/schemas/App.d.ts.map +1 -1
- package/dist/schemas/App.js +2 -14
- package/dist/schemas/ClientCredentials.d.ts.map +1 -1
- package/dist/schemas/ClientCredentials.js +3 -41
- package/dist/schemas/Connection.d.ts.map +1 -1
- package/dist/schemas/Connection.js +2 -28
- package/dist/schemas/Field.d.ts.map +1 -1
- package/dist/schemas/Field.js +3 -70
- package/dist/schemas/Run.d.ts.map +1 -1
- package/dist/schemas/Run.js +3 -29
- package/dist/schemas/TriggerInbox.d.ts.map +1 -1
- package/dist/schemas/TriggerInbox.js +1 -33
- package/dist/schemas/TriggerMessage.d.ts.map +1 -1
- package/dist/schemas/TriggerMessage.js +2 -60
- package/dist/schemas/UserProfile.d.ts +0 -1
- package/dist/schemas/UserProfile.d.ts.map +1 -1
- package/dist/schemas/UserProfile.js +1 -20
- package/dist/sdk.d.ts +2761 -441
- package/dist/sdk.d.ts.map +1 -1
- package/dist/sdk.js +93 -129
- package/dist/types/errors.d.ts +44 -42
- package/dist/types/errors.d.ts.map +1 -1
- package/dist/types/errors.js +79 -33
- package/dist/types/functions.d.ts +1 -41
- package/dist/types/functions.d.ts.map +1 -1
- package/dist/types/properties.d.ts +7 -7
- package/dist/types/properties.js +1 -1
- package/dist/types/sdk.d.ts +1 -1
- package/dist/types/sdk.d.ts.map +1 -1
- package/dist/types/telemetry-events.d.ts +1 -1
- package/dist/types/telemetry-events.d.ts.map +1 -1
- package/dist/utils/domain-utils.js +1 -1
- package/dist/utils/logging.d.ts +1 -12
- package/dist/utils/logging.d.ts.map +1 -1
- package/dist/utils/logging.js +2 -20
- package/dist/utils/pagination.d.ts +38 -0
- package/dist/utils/pagination.d.ts.map +1 -0
- package/dist/utils/pagination.js +53 -0
- package/package.json +3 -2
- package/dist/registry.d.ts +0 -9
- package/dist/registry.d.ts.map +0 -1
- package/dist/registry.js +0 -103
- package/dist/types/meta.d.ts +0 -9
- package/dist/types/meta.d.ts.map +0 -1
- package/dist/types/meta.js +0 -3
- package/dist/types/plugin.d.ts +0 -84
- package/dist/types/plugin.d.ts.map +0 -1
- package/dist/types/plugin.js +0 -13
- package/dist/types/registry.d.ts +0 -54
- package/dist/types/registry.d.ts.map +0 -1
- package/dist/types/registry.js +0 -1
- package/dist/utils/function-utils.d.ts +0 -59
- package/dist/utils/function-utils.d.ts.map +0 -1
- package/dist/utils/function-utils.js +0 -245
- package/dist/utils/pagination-utils.d.ts +0 -73
- package/dist/utils/pagination-utils.d.ts.map +0 -1
- package/dist/utils/pagination-utils.js +0 -308
- package/dist/utils/plugin-utils.d.ts +0 -245
- package/dist/utils/plugin-utils.d.ts.map +0 -1
- package/dist/utils/plugin-utils.js +0 -234
- package/dist/utils/schema-utils.d.ts +0 -211
- package/dist/utils/schema-utils.d.ts.map +0 -1
- package/dist/utils/schema-utils.js +0 -72
- package/dist/utils/string-utils.d.ts +0 -40
- package/dist/utils/string-utils.d.ts.map +0 -1
- package/dist/utils/string-utils.js +0 -69
- package/dist/utils/telemetry-context.d.ts +0 -15
- package/dist/utils/telemetry-context.d.ts.map +0 -1
- package/dist/utils/telemetry-context.js +0 -48
- package/dist/utils/telemetry-utils.d.ts +0 -44
- package/dist/utils/telemetry-utils.d.ts.map +0 -1
- package/dist/utils/telemetry-utils.js +0 -60
- package/dist/utils/validation.d.ts +0 -4
- package/dist/utils/validation.d.ts.map +0 -1
- package/dist/utils/validation.js +0 -30
package/dist/experimental.cjs
CHANGED
|
@@ -13,37 +13,64 @@ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require
|
|
|
13
13
|
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
14
14
|
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
15
15
|
});
|
|
16
|
+
function toTitleCase(input) {
|
|
17
|
+
return input.replace(/([a-z0-9])([A-Z])/g, "$1 $2").replace(/[_\-]+/g, " ").replace(/\s+/g, " ").trim().split(" ").map((word) => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase()).join(" ");
|
|
18
|
+
}
|
|
19
|
+
function toSnakeCase(input) {
|
|
20
|
+
let result = input.replace(/([a-z0-9])([A-Z])/g, "$1_$2").replace(/[\s\-]+/g, "_").replace(/_+/g, "_").replace(/^_|_$/g, "").toLowerCase();
|
|
21
|
+
if (/^[0-9]/.test(result)) {
|
|
22
|
+
result = "_" + result;
|
|
23
|
+
}
|
|
24
|
+
return result;
|
|
25
|
+
}
|
|
26
|
+
function pluralize(word) {
|
|
27
|
+
if (/s$/i.test(word)) return word;
|
|
28
|
+
if (/[bcdfghjklmnpqrstvwxz]y$/i.test(word)) {
|
|
29
|
+
return word.slice(0, -1) + "ies";
|
|
30
|
+
}
|
|
31
|
+
return word + "s";
|
|
32
|
+
}
|
|
33
|
+
function pluralizeLastWord(title) {
|
|
34
|
+
const words = title.split(" ");
|
|
35
|
+
return [...words.slice(0, -1), pluralize(words[words.length - 1])].join(" ");
|
|
36
|
+
}
|
|
37
|
+
function resolveCategoryDefinition(ref) {
|
|
38
|
+
const def = typeof ref === "string" ? { key: ref } : ref;
|
|
39
|
+
const title = def.title ?? toTitleCase(def.key);
|
|
40
|
+
return {
|
|
41
|
+
key: def.key,
|
|
42
|
+
title,
|
|
43
|
+
titlePlural: def.titlePlural ?? pluralizeLastWord(title)
|
|
44
|
+
};
|
|
45
|
+
}
|
|
16
46
|
function canonicalInputSchema(schema) {
|
|
17
47
|
if (schema instanceof zod.z.ZodUnion) {
|
|
18
48
|
return schema.options[0];
|
|
19
49
|
}
|
|
20
50
|
return schema;
|
|
21
51
|
}
|
|
22
|
-
var categoryDefinitions = {
|
|
23
|
-
account: { title: "Account" },
|
|
24
|
-
app: { title: "App", titlePlural: "Apps" },
|
|
25
|
-
connection: { title: "Connection" },
|
|
26
|
-
action: { title: "Action" },
|
|
27
|
-
"client-credentials": {
|
|
28
|
-
title: "Client Credentials",
|
|
29
|
-
titlePlural: "Client Credentials"
|
|
30
|
-
},
|
|
31
|
-
table: { title: "Table" },
|
|
32
|
-
trigger: { title: "Trigger" },
|
|
33
|
-
"code-workflow": {
|
|
34
|
-
title: "Code Workflow",
|
|
35
|
-
titlePlural: "Code Workflows"
|
|
36
|
-
},
|
|
37
|
-
http: { title: "HTTP Request" },
|
|
38
|
-
utility: { title: "Utility", titlePlural: "Utilities" },
|
|
39
|
-
other: { title: "Other" }
|
|
40
|
-
};
|
|
41
|
-
var knownCategories = Object.keys(categoryDefinitions);
|
|
42
52
|
function buildRegistry({
|
|
43
53
|
sdk,
|
|
44
54
|
meta,
|
|
45
55
|
packageFilter
|
|
46
56
|
}) {
|
|
57
|
+
const definitionsByKey = /* @__PURE__ */ new Map();
|
|
58
|
+
const objectDeclaredKeys = /* @__PURE__ */ new Set();
|
|
59
|
+
for (const m of Object.values(meta)) {
|
|
60
|
+
for (const ref of m.categories ?? []) {
|
|
61
|
+
const key = typeof ref === "string" ? ref : ref.key;
|
|
62
|
+
if (typeof ref === "object") {
|
|
63
|
+
objectDeclaredKeys.add(key);
|
|
64
|
+
definitionsByKey.set(key, resolveCategoryDefinition(ref));
|
|
65
|
+
} else if (!objectDeclaredKeys.has(key)) {
|
|
66
|
+
definitionsByKey.set(key, resolveCategoryDefinition(ref));
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
if (!definitionsByKey.has("other")) {
|
|
71
|
+
definitionsByKey.set("other", resolveCategoryDefinition("other"));
|
|
72
|
+
}
|
|
73
|
+
const knownCategories = Array.from(definitionsByKey.keys());
|
|
47
74
|
const functions = Object.keys(meta).filter((key) => {
|
|
48
75
|
const property = sdk[key];
|
|
49
76
|
if (typeof property === "function") return true;
|
|
@@ -61,7 +88,9 @@ function buildRegistry({
|
|
|
61
88
|
inputSchema: canonicalInputSchema(m.inputSchema),
|
|
62
89
|
inputParameters: m.inputParameters,
|
|
63
90
|
outputSchema: m.outputSchema,
|
|
64
|
-
categories: m.categories
|
|
91
|
+
categories: (m.categories ?? []).map(
|
|
92
|
+
(c) => typeof c === "string" ? c : c.key
|
|
93
|
+
),
|
|
65
94
|
resolvers: m.resolvers,
|
|
66
95
|
formatter: m.formatter,
|
|
67
96
|
experimental: m.experimental,
|
|
@@ -76,471 +105,134 @@ function buildRegistry({
|
|
|
76
105
|
const filteredCategories = knownCategories.slice().sort((a, b) => {
|
|
77
106
|
if (a === "other") return 1;
|
|
78
107
|
if (b === "other") return -1;
|
|
79
|
-
return
|
|
80
|
-
categoryDefinitions[b].title
|
|
81
|
-
);
|
|
108
|
+
return definitionsByKey.get(a).title.localeCompare(definitionsByKey.get(b).title);
|
|
82
109
|
}).map((categoryKey) => {
|
|
83
110
|
const categoryFunctions = filteredFunctions.filter(
|
|
84
111
|
(f) => f.categories.includes(categoryKey) || categoryKey === "other" && !f.categories.some((c) => knownCategories.includes(c))
|
|
85
112
|
).map((f) => f.name).sort();
|
|
86
|
-
const
|
|
113
|
+
const def = definitionsByKey.get(categoryKey);
|
|
87
114
|
return {
|
|
88
115
|
key: categoryKey,
|
|
89
|
-
title:
|
|
90
|
-
titlePlural:
|
|
116
|
+
title: def.title,
|
|
117
|
+
titlePlural: def.titlePlural,
|
|
91
118
|
functions: categoryFunctions
|
|
92
119
|
};
|
|
93
120
|
}).filter((category) => category.functions.length > 0);
|
|
94
121
|
return { functions: filteredFunctions, categories: filteredCategories };
|
|
95
122
|
}
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
123
|
+
function composeVoid(existing, added) {
|
|
124
|
+
if (!existing) return added;
|
|
125
|
+
if (!added) return existing;
|
|
126
|
+
return (ctx) => {
|
|
127
|
+
existing(ctx);
|
|
128
|
+
added(ctx);
|
|
129
|
+
};
|
|
103
130
|
}
|
|
104
|
-
function
|
|
105
|
-
|
|
131
|
+
function buildHooks(existing, added) {
|
|
132
|
+
const result = {};
|
|
133
|
+
const start = composeVoid(existing.onMethodStart, added.onMethodStart);
|
|
134
|
+
if (start) result.onMethodStart = start;
|
|
135
|
+
const end = composeVoid(existing.onMethodEnd, added.onMethodEnd);
|
|
136
|
+
if (end) result.onMethodEnd = end;
|
|
137
|
+
return result;
|
|
106
138
|
}
|
|
107
|
-
function
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
139
|
+
function createDeprecationLogger(tag) {
|
|
140
|
+
const loggedDeprecations = /* @__PURE__ */ new Set();
|
|
141
|
+
return {
|
|
142
|
+
logDeprecation(message) {
|
|
143
|
+
if (loggedDeprecations.has(message)) return;
|
|
144
|
+
loggedDeprecations.add(message);
|
|
145
|
+
console.warn(`[${tag}] Deprecation: ${message}`);
|
|
146
|
+
},
|
|
147
|
+
resetDeprecationWarnings() {
|
|
148
|
+
loggedDeprecations.clear();
|
|
149
|
+
}
|
|
150
|
+
};
|
|
112
151
|
}
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
152
|
+
var { logDeprecation} = createDeprecationLogger("core");
|
|
153
|
+
var CORE_ERROR_SYMBOL = Symbol.for("kitcore.error");
|
|
154
|
+
var CoreErrorCode = {
|
|
155
|
+
Validation: "VALIDATION_ERROR",
|
|
156
|
+
Unknown: "UNKNOWN_ERROR"
|
|
157
|
+
};
|
|
158
|
+
var CoreError = class extends Error {
|
|
159
|
+
constructor(message, options = {}) {
|
|
160
|
+
super(message);
|
|
161
|
+
this.name = "CoreError";
|
|
162
|
+
if (options.statusCode !== void 0) this.statusCode = options.statusCode;
|
|
163
|
+
if (options.errors !== void 0) this.errors = options.errors;
|
|
164
|
+
if (options.cause !== void 0) this.cause = options.cause;
|
|
165
|
+
if (options.response !== void 0) this.response = options.response;
|
|
166
|
+
Object.setPrototypeOf(this, new.target.prototype);
|
|
167
|
+
}
|
|
168
|
+
};
|
|
169
|
+
function createCoreError(options, adaptError) {
|
|
170
|
+
const error = adaptError?.(options) ?? new CoreError(options.message, { cause: options.cause });
|
|
171
|
+
Object.defineProperty(error, CORE_ERROR_SYMBOL, {
|
|
172
|
+
value: true,
|
|
173
|
+
enumerable: false,
|
|
174
|
+
configurable: true,
|
|
175
|
+
writable: false
|
|
116
176
|
});
|
|
117
|
-
|
|
177
|
+
Object.defineProperty(error, "coreCode", {
|
|
178
|
+
value: options.code,
|
|
179
|
+
enumerable: false,
|
|
180
|
+
configurable: true,
|
|
181
|
+
writable: false
|
|
182
|
+
});
|
|
183
|
+
return error;
|
|
118
184
|
}
|
|
119
|
-
function
|
|
120
|
-
return
|
|
185
|
+
function isCoreError(value) {
|
|
186
|
+
return Boolean(
|
|
187
|
+
value && typeof value === "object" && value[CORE_ERROR_SYMBOL] === true
|
|
188
|
+
);
|
|
121
189
|
}
|
|
122
|
-
function
|
|
123
|
-
if (
|
|
124
|
-
|
|
125
|
-
}
|
|
126
|
-
if (schema instanceof zod.z.ZodOptional) {
|
|
127
|
-
return isPositional(schema._zod.def.innerType);
|
|
128
|
-
}
|
|
129
|
-
if (schema instanceof zod.z.ZodDefault) {
|
|
130
|
-
return isPositional(schema._zod.def.innerType);
|
|
131
|
-
}
|
|
132
|
-
return false;
|
|
190
|
+
function getCoreErrorCode(value) {
|
|
191
|
+
if (!isCoreError(value)) return void 0;
|
|
192
|
+
return value.coreCode;
|
|
133
193
|
}
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
function getZapierSdkService() {
|
|
138
|
-
return globalThis.process?.env?.ZAPIER_SDK_SERVICE;
|
|
194
|
+
function getCoreErrorCause(value) {
|
|
195
|
+
if (!isCoreError(value)) return void 0;
|
|
196
|
+
return value.cause;
|
|
139
197
|
}
|
|
140
|
-
var
|
|
141
|
-
var
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
)
|
|
151
|
-
|
|
152
|
-
}
|
|
153
|
-
return parsed;
|
|
198
|
+
var CURSOR_VERSION = 1;
|
|
199
|
+
var CURSOR_SOURCE = {
|
|
200
|
+
API: "api",
|
|
201
|
+
SDK: "sdk"
|
|
202
|
+
};
|
|
203
|
+
function encodeBase64(str) {
|
|
204
|
+
return btoa(
|
|
205
|
+
Array.from(
|
|
206
|
+
new TextEncoder().encode(str),
|
|
207
|
+
(b) => String.fromCharCode(b)
|
|
208
|
+
).join("")
|
|
209
|
+
);
|
|
154
210
|
}
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
function parseConcurrencyEnvVar(name) {
|
|
159
|
-
const value = globalThis.process?.env?.[name];
|
|
160
|
-
if (!value) return void 0;
|
|
161
|
-
if (value === "Infinity") return Infinity;
|
|
162
|
-
if (/^[1-9]\d*$/.test(value)) {
|
|
163
|
-
const parsed = parseInt(value, 10);
|
|
164
|
-
if (parsed <= MAX_CONCURRENCY_LIMIT) return parsed;
|
|
165
|
-
}
|
|
166
|
-
console.warn(
|
|
167
|
-
`[zapier-sdk] Invalid value for ${name}: "${value}" (expected positive integer 1-${MAX_CONCURRENCY_LIMIT} or "Infinity")`
|
|
211
|
+
function decodeBase64(str) {
|
|
212
|
+
return new TextDecoder().decode(
|
|
213
|
+
Uint8Array.from(atob(str), (c) => c.charCodeAt(0))
|
|
168
214
|
);
|
|
169
|
-
return void 0;
|
|
170
215
|
}
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
216
|
+
function encodeApiCursor(cursor) {
|
|
217
|
+
const envelope = {
|
|
218
|
+
v: CURSOR_VERSION,
|
|
219
|
+
source: CURSOR_SOURCE.API,
|
|
220
|
+
cursor
|
|
221
|
+
};
|
|
222
|
+
return encodeBase64(JSON.stringify(envelope));
|
|
177
223
|
}
|
|
178
|
-
function
|
|
179
|
-
const
|
|
180
|
-
|
|
224
|
+
function encodeSdkCursor(offset, cursor) {
|
|
225
|
+
const envelope = {
|
|
226
|
+
v: CURSOR_VERSION,
|
|
227
|
+
source: CURSOR_SOURCE.SDK,
|
|
228
|
+
cursor,
|
|
229
|
+
offset
|
|
230
|
+
};
|
|
231
|
+
return encodeBase64(JSON.stringify(envelope));
|
|
181
232
|
}
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
// src/types/properties.ts
|
|
186
|
-
var AppKeyPropertySchema = withPositional(
|
|
187
|
-
zod.z.string().min(1).describe("App key (e.g., 'SlackCLIAPI' or slug like 'github')")
|
|
188
|
-
);
|
|
189
|
-
var AppPropertySchema = withPositional(
|
|
190
|
-
zod.z.string().min(1).describe(
|
|
191
|
-
"App slug (e.g., 'github'), implementation name (e.g., 'SlackCLIAPI'), or versioned ID (e.g., 'github@1.2.3')"
|
|
192
|
-
)
|
|
193
|
-
);
|
|
194
|
-
var ActionTypePropertySchema = zod.z.enum([
|
|
195
|
-
"read",
|
|
196
|
-
"read_bulk",
|
|
197
|
-
"write",
|
|
198
|
-
"run",
|
|
199
|
-
"search",
|
|
200
|
-
"search_or_write",
|
|
201
|
-
"search_and_write",
|
|
202
|
-
"filter"
|
|
203
|
-
]).describe("Action type that matches the action's defined type");
|
|
204
|
-
var ActionKeyPropertySchema = zod.z.string().min(1).describe("Action key to execute");
|
|
205
|
-
var ActionPropertySchema = withPositional(
|
|
206
|
-
zod.z.string().min(1).describe("Action key (e.g., 'send_message' or 'find_row')")
|
|
207
|
-
);
|
|
208
|
-
var InputFieldPropertySchema = withPositional(
|
|
209
|
-
zod.z.string().min(1).describe("Input field key to get choices for")
|
|
210
|
-
);
|
|
211
|
-
var ConnectionIdPropertySchema = zod.z.union([zod.z.string(), zod.z.number().int().positive()]).describe("Connection ID to use for this action");
|
|
212
|
-
var AuthenticationIdPropertySchema = ConnectionIdPropertySchema.meta({
|
|
213
|
-
deprecated: true
|
|
214
|
-
});
|
|
215
|
-
var ConnectionPropertySchema = zod.z.union([zod.z.string(), zod.z.number().int().positive()]).describe(
|
|
216
|
-
"Connection alias or connection ID (UUID or positive integer). Strings that match a key in the connections map are resolved against it; otherwise the value is used as a connection ID directly."
|
|
217
|
-
);
|
|
218
|
-
var InputsPropertySchema = zod.z.record(zod.z.string(), zod.z.unknown()).describe("Input parameters for the action");
|
|
219
|
-
var LimitPropertySchema = zod.z.number().int().min(1).max(MAX_PAGE_LIMIT).default(50).describe("Maximum number of items to return");
|
|
220
|
-
var OffsetPropertySchema = zod.z.number().int().min(0).default(0).describe("Number of items to skip for pagination");
|
|
221
|
-
var OutputPropertySchema = zod.z.string().describe("Output file path");
|
|
222
|
-
var DebugPropertySchema = zod.z.boolean().default(false).describe("Enable debug logging");
|
|
223
|
-
var ParamsPropertySchema = zod.z.record(zod.z.string(), zod.z.unknown()).describe("Additional parameters");
|
|
224
|
-
var ActionTimeoutMsPropertySchema = zod.z.number().min(1e3).optional().describe(
|
|
225
|
-
`Maximum time to wait for action completion in milliseconds (default: ${DEFAULT_ACTION_TIMEOUT_MS})`
|
|
226
|
-
);
|
|
227
|
-
var TablePropertySchema = withPositional(
|
|
228
|
-
zod.z.string().regex(/^[A-Z0-9]{26}$/, "Table ID must be a valid ULID").describe("The unique identifier of the table")
|
|
229
|
-
);
|
|
230
|
-
var RecordPropertySchema = withPositional(
|
|
231
|
-
zod.z.string().regex(/^[A-Z0-9]{26}$/, "Record ID must be a valid ULID").describe("The unique identifier of the record")
|
|
232
|
-
);
|
|
233
|
-
var RecordsPropertySchema = zod.z.array(zod.z.string().regex(/^[A-Z0-9]{26}$/, "Record ID must be a valid ULID")).min(1).max(100).describe("Record IDs to operate on");
|
|
234
|
-
var FieldsPropertySchema = zod.z.array(zod.z.union([zod.z.string(), zod.z.number()])).describe(
|
|
235
|
-
'Fields to operate on. Accepts field names (e.g., "Email") or IDs (e.g., "f6", "6", or 6).'
|
|
236
|
-
);
|
|
237
|
-
var AppsPropertySchema = zod.z.array(zod.z.string()).describe("Filter by app keys (e.g., 'SlackCLIAPI' or slug like 'github')");
|
|
238
|
-
var TablesPropertySchema = zod.z.array(zod.z.string()).describe("Filter by specific table IDs");
|
|
239
|
-
var ConnectionsPropertySchema = zod.z.array(zod.z.string()).describe("List of connection IDs to filter by");
|
|
240
|
-
var TriggerInboxPropertySchema = withPositional(
|
|
241
|
-
zod.z.string().min(1).describe(
|
|
242
|
-
"Trigger inbox identifier \u2014 UUID or name. Non-UUID values are resolved by name via the inbox list endpoint."
|
|
243
|
-
)
|
|
244
|
-
);
|
|
245
|
-
var TriggerInboxNamePropertySchema = zod.z.string().min(1).max(100).describe(
|
|
246
|
-
"Inbox name; unique per (user, account). Enables get-or-create on createTriggerInbox."
|
|
247
|
-
);
|
|
248
|
-
var LeasePropertySchema = zod.z.string().min(1).describe("Lease ID returned from leaseTriggerInboxMessages");
|
|
249
|
-
var LeaseSecondsPropertySchema = zod.z.number().int().min(1).max(3600).describe(
|
|
250
|
-
"Seconds until the lease expires; messages return to available if not acked. API default is 300 (5 minutes)."
|
|
251
|
-
);
|
|
252
|
-
var LeaseLimitPropertySchema = zod.z.number().int().min(1).max(100).describe("Maximum messages to lease in a single batch (1-100)");
|
|
253
|
-
|
|
254
|
-
// src/plugins/apps/schemas.ts
|
|
255
|
-
var ActionExecutionInputSchema = zod.z.object({
|
|
256
|
-
inputs: zod.z.record(zod.z.string(), zod.z.unknown()).optional(),
|
|
257
|
-
/** @deprecated Use `connection` instead. */
|
|
258
|
-
connectionId: ConnectionIdPropertySchema.optional().meta({
|
|
259
|
-
deprecated: true
|
|
260
|
-
}),
|
|
261
|
-
connection: ConnectionPropertySchema.optional(),
|
|
262
|
-
/** @deprecated Use connection instead */
|
|
263
|
-
authenticationId: AuthenticationIdPropertySchema.optional().meta({
|
|
264
|
-
deprecated: true
|
|
265
|
-
}),
|
|
266
|
-
timeoutMs: ActionTimeoutMsPropertySchema
|
|
267
|
-
}).describe(
|
|
268
|
-
"Execute an action with the given inputs for the bound app, as an alternative to runAction"
|
|
269
|
-
).meta({
|
|
270
|
-
aliases: { connectionId: "connection", authenticationId: "connection" }
|
|
271
|
-
});
|
|
272
|
-
var AppFactoryInputSchema = zod.z.object({
|
|
273
|
-
/** @deprecated Use `connection` instead. */
|
|
274
|
-
connectionId: ConnectionIdPropertySchema.optional().meta({
|
|
275
|
-
deprecated: true
|
|
276
|
-
}),
|
|
277
|
-
connection: ConnectionPropertySchema.optional(),
|
|
278
|
-
/** @deprecated Use connection instead */
|
|
279
|
-
authenticationId: AuthenticationIdPropertySchema.optional().meta({
|
|
280
|
-
deprecated: true
|
|
281
|
-
})
|
|
282
|
-
}).describe("Bind a connection alias or numeric connectionId to an app").meta({
|
|
283
|
-
aliases: { connectionId: "connection", authenticationId: "connection" }
|
|
284
|
-
});
|
|
285
|
-
|
|
286
|
-
// src/types/errors.ts
|
|
287
|
-
var ZapierError = class extends Error {
|
|
288
|
-
constructor(message, options = {}) {
|
|
289
|
-
super(message);
|
|
290
|
-
this.statusCode = options.statusCode;
|
|
291
|
-
this.errors = options.errors;
|
|
292
|
-
this.cause = options.cause;
|
|
293
|
-
this.response = options.response;
|
|
294
|
-
Object.setPrototypeOf(this, new.target.prototype);
|
|
295
|
-
}
|
|
296
|
-
};
|
|
297
|
-
var ZapierApiError = class extends ZapierError {
|
|
298
|
-
constructor(message, options = {}) {
|
|
299
|
-
super(message, options);
|
|
300
|
-
this.name = "ZapierApiError";
|
|
301
|
-
this.code = "ZAPIER_API_ERROR";
|
|
302
|
-
}
|
|
303
|
-
};
|
|
304
|
-
var ZapierAppNotFoundError = class extends ZapierError {
|
|
305
|
-
constructor(message, options = {}) {
|
|
306
|
-
super(message, options);
|
|
307
|
-
this.name = "ZapierAppNotFoundError";
|
|
308
|
-
this.code = "ZAPIER_APP_NOT_FOUND_ERROR";
|
|
309
|
-
this.appKey = options.appKey;
|
|
310
|
-
}
|
|
311
|
-
};
|
|
312
|
-
var ZapierValidationError = class extends ZapierError {
|
|
313
|
-
constructor(message, options = {}) {
|
|
314
|
-
super(message, options);
|
|
315
|
-
this.name = "ZapierValidationError";
|
|
316
|
-
this.code = "ZAPIER_VALIDATION_ERROR";
|
|
317
|
-
this.details = options.details;
|
|
318
|
-
}
|
|
319
|
-
};
|
|
320
|
-
var ZapierUnknownError = class extends ZapierError {
|
|
321
|
-
constructor(message, options = {}) {
|
|
322
|
-
super(message, options);
|
|
323
|
-
this.name = "ZapierUnknownError";
|
|
324
|
-
this.code = "ZAPIER_UNKNOWN_ERROR";
|
|
325
|
-
}
|
|
326
|
-
};
|
|
327
|
-
var ZapierAuthenticationError = class extends ZapierError {
|
|
328
|
-
constructor(message, options = {}) {
|
|
329
|
-
super(message, options);
|
|
330
|
-
this.name = "ZapierAuthenticationError";
|
|
331
|
-
this.code = "ZAPIER_AUTHENTICATION_ERROR";
|
|
332
|
-
}
|
|
333
|
-
};
|
|
334
|
-
var ZapierNotFoundError = class extends ZapierError {
|
|
335
|
-
constructor(message, options = {}) {
|
|
336
|
-
super(message, options);
|
|
337
|
-
this.name = "ZapierNotFoundError";
|
|
338
|
-
this.code = "ZAPIER_NOT_FOUND_ERROR";
|
|
339
|
-
}
|
|
340
|
-
};
|
|
341
|
-
var ZapierResourceNotFoundError = class extends ZapierNotFoundError {
|
|
342
|
-
constructor(message, options = {}) {
|
|
343
|
-
super(message, options);
|
|
344
|
-
this.name = "ZapierResourceNotFoundError";
|
|
345
|
-
this.code = "ZAPIER_RESOURCE_NOT_FOUND_ERROR";
|
|
346
|
-
this.resourceType = options.resourceType;
|
|
347
|
-
this.resourceId = options.resourceId;
|
|
348
|
-
}
|
|
349
|
-
};
|
|
350
|
-
var ZapierConfigurationError = class extends ZapierError {
|
|
351
|
-
constructor(message, options = {}) {
|
|
352
|
-
super(message, options);
|
|
353
|
-
this.name = "ZapierConfigurationError";
|
|
354
|
-
this.code = "ZAPIER_CONFIGURATION_ERROR";
|
|
355
|
-
this.configType = options.configType;
|
|
356
|
-
}
|
|
357
|
-
};
|
|
358
|
-
var ZapierBundleError = class extends ZapierError {
|
|
359
|
-
constructor(message, options = {}) {
|
|
360
|
-
super(message, options);
|
|
361
|
-
this.name = "ZapierBundleError";
|
|
362
|
-
this.code = "ZAPIER_BUNDLE_ERROR";
|
|
363
|
-
this.buildErrors = options.buildErrors;
|
|
364
|
-
}
|
|
365
|
-
};
|
|
366
|
-
var ZapierTimeoutError = class extends ZapierError {
|
|
367
|
-
constructor(message, options = {}) {
|
|
368
|
-
super(message, options);
|
|
369
|
-
this.name = "ZapierTimeoutError";
|
|
370
|
-
this.code = "ZAPIER_TIMEOUT_ERROR";
|
|
371
|
-
this.attempts = options.attempts;
|
|
372
|
-
this.maxAttempts = options.maxAttempts;
|
|
373
|
-
}
|
|
374
|
-
};
|
|
375
|
-
var ZapierActionError = class extends ZapierError {
|
|
376
|
-
constructor(message, options = {}) {
|
|
377
|
-
super(message, options);
|
|
378
|
-
this.name = "ZapierActionError";
|
|
379
|
-
this.code = "ZAPIER_ACTION_ERROR";
|
|
380
|
-
this.appKey = options.appKey;
|
|
381
|
-
this.actionKey = options.actionKey;
|
|
382
|
-
}
|
|
383
|
-
// Legacy accessor for backward compatibility
|
|
384
|
-
get actionErrors() {
|
|
385
|
-
return this.errors;
|
|
386
|
-
}
|
|
387
|
-
};
|
|
388
|
-
var ZapierConflictError = class extends ZapierError {
|
|
389
|
-
constructor(message, options = {}) {
|
|
390
|
-
super(message, options);
|
|
391
|
-
this.name = "ZapierConflictError";
|
|
392
|
-
this.code = "ZAPIER_CONFLICT_ERROR";
|
|
393
|
-
this.resourceType = options.resourceType;
|
|
394
|
-
}
|
|
395
|
-
};
|
|
396
|
-
var ZapierRateLimitError = class extends ZapierError {
|
|
397
|
-
constructor(message, options = {}) {
|
|
398
|
-
super(message, options);
|
|
399
|
-
this.name = "ZapierRateLimitError";
|
|
400
|
-
this.code = "ZAPIER_RATE_LIMIT_ERROR";
|
|
401
|
-
this.rateLimit = options.rateLimit ?? {};
|
|
402
|
-
this.retries = options.retries ?? 0;
|
|
403
|
-
}
|
|
404
|
-
};
|
|
405
|
-
var ZapierApprovalError = class extends ZapierError {
|
|
406
|
-
constructor(message, options = {}) {
|
|
407
|
-
super(message, options);
|
|
408
|
-
this.name = "ZapierApprovalError";
|
|
409
|
-
this.code = "ZAPIER_APPROVAL_ERROR";
|
|
410
|
-
this.approvalId = options.approvalId;
|
|
411
|
-
this.approvalStatus = options.status;
|
|
412
|
-
this.approvalUrl = options.approvalUrl;
|
|
413
|
-
this.pollUrl = options.pollUrl;
|
|
414
|
-
}
|
|
415
|
-
};
|
|
416
|
-
var ZapierRelayError = class extends ZapierError {
|
|
417
|
-
constructor(message, options = {}) {
|
|
418
|
-
super(message, options);
|
|
419
|
-
this.name = "ZapierRelayError";
|
|
420
|
-
this.code = "ZAPIER_RELAY_ERROR";
|
|
421
|
-
}
|
|
422
|
-
};
|
|
423
|
-
function formatErrorMessage(error) {
|
|
424
|
-
let message = error.message;
|
|
425
|
-
if (error.errors && error.errors.length > 0) {
|
|
426
|
-
const additionalErrors = error.errors.slice(1);
|
|
427
|
-
if (additionalErrors.length > 0) {
|
|
428
|
-
const errorDetails = additionalErrors.map((err) => ` \u2022 ${err.detail || err.title || err.code}`).join("\n");
|
|
429
|
-
message += "\n\nAdditional errors:\n" + errorDetails;
|
|
430
|
-
}
|
|
431
|
-
}
|
|
432
|
-
if (error instanceof ZapierAppNotFoundError && error.appKey) {
|
|
433
|
-
message += `
|
|
434
|
-
App key: ${error.appKey}`;
|
|
435
|
-
}
|
|
436
|
-
if (error instanceof ZapierActionError && (error.appKey || error.actionKey)) {
|
|
437
|
-
const context = [];
|
|
438
|
-
if (error.appKey) context.push(`App: ${error.appKey}`);
|
|
439
|
-
if (error.actionKey) context.push(`Action: ${error.actionKey}`);
|
|
440
|
-
message += `
|
|
441
|
-
${context.join(", ")}`;
|
|
442
|
-
}
|
|
443
|
-
if (error instanceof ZapierResourceNotFoundError && (error.resourceType || error.resourceId)) {
|
|
444
|
-
const context = [];
|
|
445
|
-
if (error.resourceType) context.push(`Type: ${error.resourceType}`);
|
|
446
|
-
if (error.resourceId) context.push(`ID: ${error.resourceId}`);
|
|
447
|
-
message += `
|
|
448
|
-
${context.join(", ")}`;
|
|
449
|
-
}
|
|
450
|
-
if (error instanceof ZapierConflictError && error.resourceType) {
|
|
451
|
-
message += `
|
|
452
|
-
Type: ${error.resourceType}`;
|
|
453
|
-
}
|
|
454
|
-
if (error instanceof ZapierTimeoutError && (error.attempts || error.maxAttempts)) {
|
|
455
|
-
const context = [];
|
|
456
|
-
if (error.attempts) context.push(`Attempts: ${error.attempts}`);
|
|
457
|
-
if (error.maxAttempts) context.push(`Max attempts: ${error.maxAttempts}`);
|
|
458
|
-
message += `
|
|
459
|
-
${context.join(", ")}`;
|
|
460
|
-
}
|
|
461
|
-
if (error instanceof ZapierBundleError && error.buildErrors && error.buildErrors.length > 0) {
|
|
462
|
-
message += "\n\nBuild errors:\n" + error.buildErrors.map((err) => ` \u2022 ${err}`).join("\n");
|
|
463
|
-
}
|
|
464
|
-
if (error instanceof ZapierApprovalError && error.approvalUrl) {
|
|
465
|
-
message += `
|
|
466
|
-
Approval URL: ${error.approvalUrl}`;
|
|
467
|
-
}
|
|
468
|
-
if (error instanceof ZapierRateLimitError) {
|
|
469
|
-
const { limit, remaining, retryAfterMs } = error.rateLimit;
|
|
470
|
-
const parts = [];
|
|
471
|
-
if (limit !== void 0) {
|
|
472
|
-
const used = remaining !== void 0 ? limit - remaining : limit;
|
|
473
|
-
parts.push(`${used}/${limit} used`);
|
|
474
|
-
}
|
|
475
|
-
if (retryAfterMs !== void 0 && retryAfterMs > 0) {
|
|
476
|
-
parts.push(`retry in ${formatDuration(retryAfterMs)}`);
|
|
477
|
-
}
|
|
478
|
-
if (error.retries > 0) {
|
|
479
|
-
parts.push(
|
|
480
|
-
`after ${error.retries} retr${error.retries === 1 ? "y" : "ies"}`
|
|
481
|
-
);
|
|
482
|
-
}
|
|
483
|
-
if (parts.length > 0) {
|
|
484
|
-
message += `
|
|
485
|
-
${parts.join(", ")}`;
|
|
486
|
-
}
|
|
487
|
-
}
|
|
488
|
-
if (error.statusCode && !message.includes(`${error.statusCode}`)) {
|
|
489
|
-
message += `
|
|
490
|
-
HTTP Status: ${error.statusCode}`;
|
|
491
|
-
}
|
|
492
|
-
return message;
|
|
493
|
-
}
|
|
494
|
-
function formatDuration(ms) {
|
|
495
|
-
const seconds = Math.round(ms / 1e3);
|
|
496
|
-
if (seconds < 60) return `${seconds}s`;
|
|
497
|
-
const minutes = Math.round(seconds / 60);
|
|
498
|
-
if (minutes < 60) return `${minutes}m`;
|
|
499
|
-
const hours = Math.round(minutes / 60);
|
|
500
|
-
if (hours < 24) return `${hours}h`;
|
|
501
|
-
const days = Math.round(hours / 24);
|
|
502
|
-
return `${days}d`;
|
|
503
|
-
}
|
|
504
|
-
|
|
505
|
-
// src/utils/pagination-utils.ts
|
|
506
|
-
var CURSOR_VERSION = 1;
|
|
507
|
-
var CURSOR_SOURCE = {
|
|
508
|
-
API: "api",
|
|
509
|
-
SDK: "sdk"
|
|
510
|
-
};
|
|
511
|
-
function encodeBase64(str) {
|
|
512
|
-
return btoa(
|
|
513
|
-
Array.from(
|
|
514
|
-
new TextEncoder().encode(str),
|
|
515
|
-
(b) => String.fromCharCode(b)
|
|
516
|
-
).join("")
|
|
517
|
-
);
|
|
518
|
-
}
|
|
519
|
-
function decodeBase64(str) {
|
|
520
|
-
return new TextDecoder().decode(
|
|
521
|
-
Uint8Array.from(atob(str), (c) => c.charCodeAt(0))
|
|
522
|
-
);
|
|
523
|
-
}
|
|
524
|
-
function encodeApiCursor(cursor) {
|
|
525
|
-
const envelope = {
|
|
526
|
-
v: CURSOR_VERSION,
|
|
527
|
-
source: CURSOR_SOURCE.API,
|
|
528
|
-
cursor
|
|
529
|
-
};
|
|
530
|
-
return encodeBase64(JSON.stringify(envelope));
|
|
531
|
-
}
|
|
532
|
-
function encodeSdkCursor(offset, cursor) {
|
|
533
|
-
const envelope = {
|
|
534
|
-
v: CURSOR_VERSION,
|
|
535
|
-
source: CURSOR_SOURCE.SDK,
|
|
536
|
-
cursor,
|
|
537
|
-
offset
|
|
538
|
-
};
|
|
539
|
-
return encodeBase64(JSON.stringify(envelope));
|
|
540
|
-
}
|
|
541
|
-
function decodeIncomingCursor(incoming) {
|
|
542
|
-
if (!incoming) {
|
|
543
|
-
return { offset: 0, cursor: void 0 };
|
|
233
|
+
function decodeIncomingCursor(incoming) {
|
|
234
|
+
if (!incoming) {
|
|
235
|
+
return { offset: 0, cursor: void 0 };
|
|
544
236
|
}
|
|
545
237
|
try {
|
|
546
238
|
const decoded = decodeBase64(incoming);
|
|
@@ -755,144 +447,117 @@ function concatPaginated({
|
|
|
755
447
|
function toIterable(source) {
|
|
756
448
|
return { [Symbol.asyncIterator]: () => source[Symbol.asyncIterator]() };
|
|
757
449
|
}
|
|
758
|
-
|
|
759
|
-
// src/utils/validation.ts
|
|
760
|
-
var validate = (schema, input) => {
|
|
450
|
+
var parseOrThrow = (schema, input, { adaptError } = {}) => {
|
|
761
451
|
const result = schema.safeParse(input);
|
|
762
452
|
if (!result.success) {
|
|
763
|
-
const errorMessages = result.error.issues.map((
|
|
764
|
-
const path =
|
|
765
|
-
return `${path}: ${
|
|
766
|
-
});
|
|
767
|
-
const message = `Validation failed:
|
|
768
|
-
${errorMessages.join("\n ")}`;
|
|
769
|
-
throw new ZapierValidationError(message, {
|
|
770
|
-
details: {
|
|
771
|
-
zodErrors: result.error.issues,
|
|
772
|
-
input
|
|
773
|
-
}
|
|
453
|
+
const errorMessages = result.error.issues.map((issue) => {
|
|
454
|
+
const path = issue.path.length > 0 ? issue.path.join(".") : "input";
|
|
455
|
+
return `${path}: ${issue.message}`;
|
|
774
456
|
});
|
|
457
|
+
throw createCoreError(
|
|
458
|
+
{
|
|
459
|
+
code: CoreErrorCode.Validation,
|
|
460
|
+
message: `Validation failed:
|
|
461
|
+
${errorMessages.join("\n ")}`,
|
|
462
|
+
details: {
|
|
463
|
+
zodErrors: result.error.issues,
|
|
464
|
+
input
|
|
465
|
+
}
|
|
466
|
+
},
|
|
467
|
+
adaptError
|
|
468
|
+
);
|
|
775
469
|
}
|
|
776
470
|
return result.data;
|
|
777
471
|
};
|
|
778
|
-
function createValidator(schema) {
|
|
472
|
+
function createValidator(schema, { adaptError } = {}) {
|
|
779
473
|
return function validateFn(input) {
|
|
780
|
-
return
|
|
474
|
+
return parseOrThrow(schema, input, { adaptError });
|
|
781
475
|
};
|
|
782
476
|
}
|
|
783
|
-
var validateOptions = (schema, options) => {
|
|
784
|
-
|
|
785
|
-
};
|
|
786
|
-
var telemetryStore = null;
|
|
477
|
+
var validateOptions = (schema, options, { adaptError } = {}) => parseOrThrow(schema, options, { adaptError });
|
|
478
|
+
var scopeStore = null;
|
|
787
479
|
try {
|
|
788
|
-
|
|
480
|
+
scopeStore = new async_hooks.AsyncLocalStorage();
|
|
789
481
|
} catch {
|
|
790
482
|
}
|
|
791
|
-
function
|
|
792
|
-
if (!
|
|
793
|
-
|
|
794
|
-
return store !== void 0 && store.depth > 0;
|
|
483
|
+
function getCurrentScope() {
|
|
484
|
+
if (!scopeStore) return void 0;
|
|
485
|
+
return scopeStore.getStore();
|
|
795
486
|
}
|
|
796
|
-
function
|
|
797
|
-
|
|
798
|
-
const currentDepth = telemetryStore.getStore()?.depth ?? -1;
|
|
799
|
-
return telemetryStore.run({ depth: currentDepth + 1 }, fn);
|
|
487
|
+
function getCurrentDepth() {
|
|
488
|
+
return getCurrentScope()?.depth ?? 0;
|
|
800
489
|
}
|
|
801
|
-
function
|
|
802
|
-
if (!
|
|
803
|
-
const
|
|
804
|
-
|
|
805
|
-
store.methodMetadata = { ...store.methodMetadata, ...metadata };
|
|
490
|
+
function runInMethodScope(fn) {
|
|
491
|
+
if (!scopeStore) return fn();
|
|
492
|
+
const currentDepth = scopeStore.getStore()?.depth ?? -1;
|
|
493
|
+
return scopeStore.run({ depth: currentDepth + 1 }, fn);
|
|
806
494
|
}
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
495
|
+
var runWithTelemetryContext = runInMethodScope;
|
|
496
|
+
function normalizeError(error, adaptError) {
|
|
497
|
+
if (error instanceof Error) return error;
|
|
498
|
+
const message = typeof error === "object" && error !== null && "message" in error && typeof error.message === "string" ? error.message : String(error);
|
|
499
|
+
return createCoreError(
|
|
500
|
+
{
|
|
501
|
+
code: CoreErrorCode.Unknown,
|
|
502
|
+
message,
|
|
503
|
+
cause: error
|
|
504
|
+
},
|
|
505
|
+
adaptError
|
|
506
|
+
);
|
|
810
507
|
}
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
function extractCursor(data) {
|
|
814
|
-
if (!data?.next) {
|
|
815
|
-
return void 0;
|
|
816
|
-
}
|
|
817
|
-
try {
|
|
818
|
-
const urlObj = new URL(data.next);
|
|
819
|
-
const offset = urlObj.searchParams.get("offset");
|
|
820
|
-
return offset || void 0;
|
|
821
|
-
} catch {
|
|
822
|
-
return void 0;
|
|
823
|
-
}
|
|
824
|
-
}
|
|
825
|
-
function normalizeError(error) {
|
|
826
|
-
if (error instanceof ZapierError) {
|
|
827
|
-
return error;
|
|
828
|
-
}
|
|
829
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
830
|
-
const cause = error instanceof Error ? error : void 0;
|
|
831
|
-
if (error instanceof Error) {
|
|
832
|
-
if (error.name === "ZapierAuthenticationError") {
|
|
833
|
-
return new ZapierAuthenticationError(message, { cause });
|
|
834
|
-
}
|
|
835
|
-
}
|
|
836
|
-
return new ZapierUnknownError(message, { cause });
|
|
837
|
-
}
|
|
838
|
-
function createFunction(coreFn, schema, telemetry) {
|
|
508
|
+
function createFunction(coreFn, options) {
|
|
509
|
+
const { sdk, schema } = options;
|
|
839
510
|
const functionName = coreFn.name;
|
|
840
511
|
const namedFunctions = {
|
|
841
|
-
[functionName]: async function(
|
|
842
|
-
return
|
|
512
|
+
[functionName]: async function(callOptions) {
|
|
513
|
+
return runInMethodScope(async () => {
|
|
843
514
|
const startTime = Date.now();
|
|
844
|
-
const normalizedOptions =
|
|
845
|
-
const
|
|
515
|
+
const normalizedOptions = callOptions ?? {};
|
|
516
|
+
const args = [normalizedOptions];
|
|
517
|
+
const depth = getCurrentDepth();
|
|
518
|
+
const hooks = sdk.context.hooks;
|
|
519
|
+
const adaptError = sdk.context.core?.adaptError;
|
|
520
|
+
hooks?.onMethodStart?.({
|
|
521
|
+
methodName: functionName,
|
|
522
|
+
args,
|
|
523
|
+
isPaginated: false,
|
|
524
|
+
depth
|
|
525
|
+
});
|
|
846
526
|
try {
|
|
527
|
+
let result;
|
|
847
528
|
if (schema) {
|
|
848
|
-
const validatedOptions = validateOptions(
|
|
849
|
-
|
|
529
|
+
const validatedOptions = validateOptions(
|
|
530
|
+
schema,
|
|
531
|
+
normalizedOptions,
|
|
532
|
+
{
|
|
533
|
+
adaptError
|
|
534
|
+
}
|
|
535
|
+
);
|
|
536
|
+
result = await coreFn({
|
|
850
537
|
...normalizedOptions,
|
|
851
538
|
...validatedOptions
|
|
852
539
|
});
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
normalizedOptions
|
|
856
|
-
).length;
|
|
857
|
-
telemetry.onMethodCalled({
|
|
858
|
-
methodName: functionName,
|
|
859
|
-
durationMs: Date.now() - startTime,
|
|
860
|
-
success: true,
|
|
861
|
-
argumentCount,
|
|
862
|
-
isPaginated: false
|
|
863
|
-
});
|
|
864
|
-
}
|
|
865
|
-
return result2;
|
|
866
|
-
}
|
|
867
|
-
const result = await coreFn(normalizedOptions);
|
|
868
|
-
if (!isNested && telemetry?.onMethodCalled) {
|
|
869
|
-
const argumentCount = Object.keys(
|
|
870
|
-
normalizedOptions
|
|
871
|
-
).length;
|
|
872
|
-
telemetry.onMethodCalled({
|
|
873
|
-
methodName: functionName,
|
|
874
|
-
durationMs: Date.now() - startTime,
|
|
875
|
-
success: true,
|
|
876
|
-
argumentCount,
|
|
877
|
-
isPaginated: false
|
|
878
|
-
});
|
|
540
|
+
} else {
|
|
541
|
+
result = await coreFn(normalizedOptions);
|
|
879
542
|
}
|
|
543
|
+
hooks?.onMethodEnd?.({
|
|
544
|
+
methodName: functionName,
|
|
545
|
+
args,
|
|
546
|
+
isPaginated: false,
|
|
547
|
+
depth,
|
|
548
|
+
durationMs: Date.now() - startTime
|
|
549
|
+
});
|
|
880
550
|
return result;
|
|
881
551
|
} catch (error) {
|
|
882
|
-
const normalizedError = normalizeError(error);
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
error: normalizedError,
|
|
892
|
-
argumentCount,
|
|
893
|
-
isPaginated: false
|
|
894
|
-
});
|
|
895
|
-
}
|
|
552
|
+
const normalizedError = normalizeError(error, adaptError);
|
|
553
|
+
hooks?.onMethodEnd?.({
|
|
554
|
+
methodName: functionName,
|
|
555
|
+
args,
|
|
556
|
+
isPaginated: false,
|
|
557
|
+
depth,
|
|
558
|
+
durationMs: Date.now() - startTime,
|
|
559
|
+
error: normalizedError
|
|
560
|
+
});
|
|
896
561
|
throw normalizedError;
|
|
897
562
|
}
|
|
898
563
|
});
|
|
@@ -900,49 +565,63 @@ function createFunction(coreFn, schema, telemetry) {
|
|
|
900
565
|
};
|
|
901
566
|
return namedFunctions[functionName];
|
|
902
567
|
}
|
|
903
|
-
function
|
|
568
|
+
function isSdkPage(value) {
|
|
569
|
+
if (typeof value !== "object" || value === null) return false;
|
|
570
|
+
const page = value;
|
|
571
|
+
if (!Array.isArray(page.data)) return false;
|
|
572
|
+
if (page.nextCursor !== void 0 && typeof page.nextCursor !== "string") {
|
|
573
|
+
return false;
|
|
574
|
+
}
|
|
575
|
+
return Object.keys(page).every((k) => k === "data" || k === "nextCursor");
|
|
576
|
+
}
|
|
577
|
+
function createPageFunction(coreFn, {
|
|
578
|
+
sdk,
|
|
579
|
+
adaptPage
|
|
580
|
+
}) {
|
|
904
581
|
const functionName = coreFn.name + "Page";
|
|
905
582
|
const namedFunctions = {
|
|
906
583
|
[functionName]: async function(options) {
|
|
907
584
|
try {
|
|
908
|
-
const
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
} else if (paginatedResult.links?.next) {
|
|
915
|
-
nextCursor = extractCursor({ next: paginatedResult.links.next });
|
|
916
|
-
}
|
|
917
|
-
return {
|
|
918
|
-
data: Array.isArray(paginatedResult.data) ? paginatedResult.data : [paginatedResult.data],
|
|
919
|
-
nextCursor
|
|
920
|
-
};
|
|
921
|
-
}
|
|
922
|
-
if (Array.isArray(result)) {
|
|
923
|
-
return { data: result };
|
|
585
|
+
const response = await coreFn(options);
|
|
586
|
+
const page = adaptPage ? adaptPage(response) : response;
|
|
587
|
+
if (!isSdkPage(page)) {
|
|
588
|
+
throw new Error(
|
|
589
|
+
`${functionName}: paginated result must be exactly { data: TItem[], nextCursor? } (produced by the handler or its \`adaptPage\`); got keys [${page && typeof page === "object" ? Object.keys(page).join(", ") : typeof page}]. If the handler returns a raw shape, set \`adaptPage\` to translate it; if \`adaptPage\` already runs, it must return only \`data\`/\`nextCursor\`.`
|
|
590
|
+
);
|
|
924
591
|
}
|
|
925
|
-
return
|
|
592
|
+
return page;
|
|
926
593
|
} catch (error) {
|
|
927
|
-
throw normalizeError(
|
|
594
|
+
throw normalizeError(
|
|
595
|
+
error,
|
|
596
|
+
sdk.context.core?.adaptError
|
|
597
|
+
);
|
|
928
598
|
}
|
|
929
599
|
}
|
|
930
600
|
};
|
|
931
601
|
return namedFunctions[functionName];
|
|
932
602
|
}
|
|
933
|
-
function createPaginatedFunction(coreFn,
|
|
934
|
-
const
|
|
935
|
-
const
|
|
936
|
-
const
|
|
603
|
+
function createPaginatedFunction(coreFn, options) {
|
|
604
|
+
const { sdk, schema, name, defaultPageSize, adaptPage } = options;
|
|
605
|
+
const pageFunction = createPageFunction(coreFn, { sdk, adaptPage });
|
|
606
|
+
const functionName = name || coreFn.name;
|
|
937
607
|
const namedFunctions = {
|
|
938
|
-
[functionName]: function(
|
|
939
|
-
return
|
|
608
|
+
[functionName]: function(callOptions) {
|
|
609
|
+
return runInMethodScope(() => {
|
|
940
610
|
const startTime = Date.now();
|
|
941
|
-
const normalizedOptions =
|
|
942
|
-
const
|
|
611
|
+
const normalizedOptions = callOptions ?? {};
|
|
612
|
+
const args = [normalizedOptions];
|
|
613
|
+
const depth = getCurrentDepth();
|
|
614
|
+
const hooks = sdk.context.hooks;
|
|
615
|
+
const adaptError = sdk.context.core?.adaptError;
|
|
616
|
+
hooks?.onMethodStart?.({
|
|
617
|
+
methodName: functionName,
|
|
618
|
+
args,
|
|
619
|
+
isPaginated: true,
|
|
620
|
+
depth
|
|
621
|
+
});
|
|
943
622
|
const validatedOptions = {
|
|
944
623
|
...normalizedOptions,
|
|
945
|
-
...
|
|
624
|
+
...schema ? createValidator(schema, { adaptError })(normalizedOptions) : normalizedOptions
|
|
946
625
|
};
|
|
947
626
|
const pageSize = validatedOptions.pageSize ?? defaultPageSize;
|
|
948
627
|
const optimizedOptions = {
|
|
@@ -956,29 +635,23 @@ function createPaginatedFunction(coreFn, schema, telemetry, explicitFunctionName
|
|
|
956
635
|
}
|
|
957
636
|
return result.value;
|
|
958
637
|
});
|
|
959
|
-
if (
|
|
638
|
+
if (hooks?.onMethodEnd) {
|
|
960
639
|
firstPagePromise.then(() => {
|
|
961
|
-
|
|
962
|
-
normalizedOptions
|
|
963
|
-
).length;
|
|
964
|
-
telemetry.onMethodCalled({
|
|
640
|
+
hooks.onMethodEnd({
|
|
965
641
|
methodName: functionName,
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
642
|
+
args,
|
|
643
|
+
isPaginated: true,
|
|
644
|
+
depth,
|
|
645
|
+
durationMs: Date.now() - startTime
|
|
970
646
|
});
|
|
971
647
|
}).catch((error) => {
|
|
972
|
-
|
|
973
|
-
normalizedOptions
|
|
974
|
-
).length;
|
|
975
|
-
telemetry.onMethodCalled({
|
|
648
|
+
hooks.onMethodEnd({
|
|
976
649
|
methodName: functionName,
|
|
650
|
+
args,
|
|
651
|
+
isPaginated: true,
|
|
652
|
+
depth,
|
|
977
653
|
durationMs: Date.now() - startTime,
|
|
978
|
-
|
|
979
|
-
error: error instanceof Error ? error : new Error(String(error)),
|
|
980
|
-
argumentCount,
|
|
981
|
-
isPaginated: true
|
|
654
|
+
error: error instanceof Error ? error : new Error(String(error))
|
|
982
655
|
});
|
|
983
656
|
});
|
|
984
657
|
}
|
|
@@ -1010,37 +683,9 @@ function createPaginatedFunction(coreFn, schema, telemetry, explicitFunctionName
|
|
|
1010
683
|
};
|
|
1011
684
|
return namedFunctions[functionName];
|
|
1012
685
|
}
|
|
1013
|
-
|
|
1014
|
-
// src/utils/telemetry-utils.ts
|
|
1015
|
-
function createTelemetryCallback(emitMethodCalled, methodName) {
|
|
1016
|
-
return {
|
|
1017
|
-
onMethodCalled: (data) => {
|
|
1018
|
-
const metadata = getMethodMetadata();
|
|
1019
|
-
emitMethodCalled({
|
|
1020
|
-
method_name: methodName,
|
|
1021
|
-
execution_duration_ms: data.durationMs,
|
|
1022
|
-
success_flag: data.success,
|
|
1023
|
-
error_message: data.error?.message ?? null,
|
|
1024
|
-
error_type: data.error?.constructor.name ?? null,
|
|
1025
|
-
argument_count: data.argumentCount,
|
|
1026
|
-
is_paginated: data.isPaginated,
|
|
1027
|
-
selected_api: metadata?.selectedApi ?? null,
|
|
1028
|
-
operation_type: metadata?.operationType ?? null,
|
|
1029
|
-
operation_key: metadata?.operationKey ?? null
|
|
1030
|
-
});
|
|
1031
|
-
}
|
|
1032
|
-
};
|
|
1033
|
-
}
|
|
1034
|
-
|
|
1035
|
-
// src/utils/plugin-utils.ts
|
|
1036
686
|
function definePlugin(fn) {
|
|
1037
687
|
return fn;
|
|
1038
688
|
}
|
|
1039
|
-
function maybeTelemetry(sdk, name) {
|
|
1040
|
-
const ctx = sdk.context;
|
|
1041
|
-
if (!ctx.eventEmission) return void 0;
|
|
1042
|
-
return createTelemetryCallback(ctx.eventEmission.emitMethodCalled, name);
|
|
1043
|
-
}
|
|
1044
689
|
function createPluginMethod(sdk, config) {
|
|
1045
690
|
const { name, inputSchema, handler, ...metaFields } = config;
|
|
1046
691
|
const namedHandlers = {
|
|
@@ -1048,11 +693,10 @@ function createPluginMethod(sdk, config) {
|
|
|
1048
693
|
return handler({ sdk, options });
|
|
1049
694
|
}
|
|
1050
695
|
};
|
|
1051
|
-
const wrappedFn = createFunction(
|
|
1052
|
-
|
|
1053
|
-
inputSchema
|
|
1054
|
-
|
|
1055
|
-
);
|
|
696
|
+
const wrappedFn = createFunction(namedHandlers[name], {
|
|
697
|
+
sdk,
|
|
698
|
+
schema: inputSchema
|
|
699
|
+
});
|
|
1056
700
|
return {
|
|
1057
701
|
[name]: wrappedFn,
|
|
1058
702
|
context: {
|
|
@@ -1070,29 +714,22 @@ function createPaginatedPluginMethod(sdk, config) {
|
|
|
1070
714
|
name,
|
|
1071
715
|
inputSchema,
|
|
1072
716
|
handler,
|
|
1073
|
-
|
|
717
|
+
adaptPage,
|
|
1074
718
|
defaultPageSize,
|
|
1075
719
|
...metaFields
|
|
1076
720
|
} = config;
|
|
1077
|
-
const
|
|
1078
|
-
[name]:
|
|
1079
|
-
|
|
1080
|
-
if (extractCursorFn) {
|
|
1081
|
-
const extracted = extractCursorFn(response);
|
|
1082
|
-
if (extracted !== void 0) {
|
|
1083
|
-
return { data: response.data, nextCursor: extracted };
|
|
1084
|
-
}
|
|
1085
|
-
}
|
|
1086
|
-
return response;
|
|
721
|
+
const namedHandlers = {
|
|
722
|
+
[name]: function(options) {
|
|
723
|
+
return handler({ sdk, options });
|
|
1087
724
|
}
|
|
1088
725
|
};
|
|
1089
|
-
const wrappedFn = createPaginatedFunction(
|
|
1090
|
-
|
|
1091
|
-
inputSchema,
|
|
1092
|
-
maybeTelemetry(sdk, name),
|
|
726
|
+
const wrappedFn = createPaginatedFunction(namedHandlers[name], {
|
|
727
|
+
sdk,
|
|
728
|
+
schema: inputSchema,
|
|
1093
729
|
name,
|
|
1094
|
-
defaultPageSize
|
|
1095
|
-
|
|
730
|
+
defaultPageSize,
|
|
731
|
+
adaptPage
|
|
732
|
+
});
|
|
1096
733
|
return {
|
|
1097
734
|
[name]: wrappedFn,
|
|
1098
735
|
context: {
|
|
@@ -1105,88 +742,682 @@ function createPaginatedPluginMethod(sdk, config) {
|
|
|
1105
742
|
}
|
|
1106
743
|
};
|
|
1107
744
|
}
|
|
1108
|
-
function
|
|
745
|
+
function splitPluginContribution(result) {
|
|
746
|
+
const { context, ...rootKeys } = result;
|
|
747
|
+
const { meta, hooks, ...contextRest } = context ?? {};
|
|
748
|
+
return {
|
|
749
|
+
rootKeys,
|
|
750
|
+
meta: meta ?? {},
|
|
751
|
+
hooks: hooks ?? {},
|
|
752
|
+
contextRest
|
|
753
|
+
};
|
|
754
|
+
}
|
|
755
|
+
var RESERVED_ROOT_KEYS = /* @__PURE__ */ new Set([
|
|
756
|
+
"context",
|
|
757
|
+
"getRegistry",
|
|
758
|
+
"addPlugin"
|
|
759
|
+
]);
|
|
760
|
+
function hasOwn(obj, key) {
|
|
761
|
+
return Object.prototype.hasOwnProperty.call(obj, key);
|
|
762
|
+
}
|
|
763
|
+
function setOwn(target, key, value) {
|
|
764
|
+
Object.defineProperty(target, key, {
|
|
765
|
+
value,
|
|
766
|
+
enumerable: true,
|
|
767
|
+
configurable: true,
|
|
768
|
+
writable: true
|
|
769
|
+
});
|
|
770
|
+
}
|
|
771
|
+
function checkCollisions(target, source, kind, callerLabel, override) {
|
|
1109
772
|
for (const key of Object.keys(source)) {
|
|
1110
|
-
if (
|
|
773
|
+
if (kind === "root key" && RESERVED_ROOT_KEYS.has(key)) {
|
|
1111
774
|
throw new Error(
|
|
1112
|
-
|
|
775
|
+
`${callerLabel}: plugin attempted to register reserved root key "${key}". The SDK uses this key for its own accessor; rename the plugin's method.`
|
|
1113
776
|
);
|
|
1114
777
|
}
|
|
1115
|
-
|
|
1116
|
-
target[key] = source[key];
|
|
1117
|
-
}
|
|
1118
|
-
}
|
|
1119
|
-
function mergeMetaKeysWithCollisionCheck(target, source, seen) {
|
|
1120
|
-
for (const key of Object.keys(source)) {
|
|
1121
|
-
if (seen.has(key)) {
|
|
778
|
+
if (!override && hasOwn(target, key)) {
|
|
1122
779
|
throw new Error(
|
|
1123
|
-
|
|
780
|
+
`${callerLabel}: duplicate ${kind} "${key}". If the override is intentional, pass { override: true } in the options.`
|
|
1124
781
|
);
|
|
1125
782
|
}
|
|
1126
|
-
seen.add(key);
|
|
1127
|
-
target[key] = source[key];
|
|
1128
783
|
}
|
|
1129
784
|
}
|
|
1130
|
-
function
|
|
785
|
+
function applyOwnProperties(target, source) {
|
|
1131
786
|
for (const key of Object.keys(source)) {
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
787
|
+
setOwn(target, key, source[key]);
|
|
788
|
+
}
|
|
789
|
+
}
|
|
790
|
+
function createPluginAccumulator(initialProperties = {}, initialContext = {}) {
|
|
791
|
+
const initialMeta = initialContext.meta ?? {};
|
|
792
|
+
const initialHooks = initialContext.hooks ?? {};
|
|
793
|
+
const context = {
|
|
794
|
+
...initialContext,
|
|
795
|
+
meta: { ...initialMeta },
|
|
796
|
+
hooks: { ...initialHooks }
|
|
797
|
+
};
|
|
798
|
+
const view = { ...initialProperties, context };
|
|
799
|
+
return { view, context };
|
|
800
|
+
}
|
|
801
|
+
function mergeContribution(propertiesTarget, contextTarget, contribution, options) {
|
|
802
|
+
checkCollisions(
|
|
803
|
+
propertiesTarget,
|
|
804
|
+
contribution.rootKeys,
|
|
805
|
+
"root key",
|
|
806
|
+
options.callerLabel,
|
|
807
|
+
options.override
|
|
808
|
+
);
|
|
809
|
+
checkCollisions(
|
|
810
|
+
contextTarget.meta,
|
|
811
|
+
contribution.meta,
|
|
812
|
+
"context.meta key",
|
|
813
|
+
options.callerLabel,
|
|
814
|
+
options.override
|
|
815
|
+
);
|
|
816
|
+
checkCollisions(
|
|
817
|
+
contextTarget,
|
|
818
|
+
contribution.contextRest,
|
|
819
|
+
"context key",
|
|
820
|
+
options.callerLabel,
|
|
821
|
+
options.override
|
|
822
|
+
);
|
|
823
|
+
applyOwnProperties(propertiesTarget, contribution.rootKeys);
|
|
824
|
+
applyOwnProperties(contextTarget.meta, contribution.meta);
|
|
825
|
+
applyOwnProperties(contextTarget, contribution.contextRest);
|
|
826
|
+
contextTarget.hooks = buildHooks(contextTarget.hooks, contribution.hooks);
|
|
827
|
+
}
|
|
828
|
+
function applyPluginContribution(acc, contribution, options) {
|
|
829
|
+
mergeContribution(acc.view, acc.context, contribution, options);
|
|
830
|
+
}
|
|
831
|
+
function wrapAsSdk(properties, context, opts) {
|
|
832
|
+
const sdk = {
|
|
833
|
+
...properties,
|
|
834
|
+
context,
|
|
835
|
+
getRegistry(qopts) {
|
|
836
|
+
return buildRegistry({
|
|
837
|
+
sdk,
|
|
838
|
+
meta: context.meta,
|
|
839
|
+
packageFilter: qopts?.package
|
|
840
|
+
});
|
|
841
|
+
}
|
|
842
|
+
};
|
|
843
|
+
if (opts?.addPlugin !== void 0) {
|
|
844
|
+
sdk.addPlugin = opts.addPlugin;
|
|
845
|
+
}
|
|
846
|
+
return sdk;
|
|
847
|
+
}
|
|
848
|
+
function wrapAccumulatorAsSdk(acc) {
|
|
849
|
+
const { context: _ctx, ...rootKeys } = acc.view;
|
|
850
|
+
return wrapAsSdk(
|
|
851
|
+
rootKeys,
|
|
852
|
+
acc.context
|
|
853
|
+
);
|
|
854
|
+
}
|
|
855
|
+
function applyPluginToSdk(sdk, plugin, options) {
|
|
856
|
+
const context = sdk.context;
|
|
857
|
+
const contribution = splitPluginContribution(
|
|
858
|
+
plugin(sdk)
|
|
859
|
+
);
|
|
860
|
+
mergeContribution(sdk, context, contribution, {
|
|
861
|
+
callerLabel: "addPlugin",
|
|
862
|
+
override: options.override === true
|
|
863
|
+
});
|
|
864
|
+
}
|
|
865
|
+
function buildStackAccumulator(head, callerLabel) {
|
|
866
|
+
const ordered = [];
|
|
867
|
+
let node = head;
|
|
868
|
+
while (node) {
|
|
869
|
+
ordered.unshift(node);
|
|
870
|
+
node = node.prev;
|
|
871
|
+
}
|
|
872
|
+
const acc = createPluginAccumulator();
|
|
873
|
+
for (const { plugin, override } of ordered) {
|
|
874
|
+
const contribution = splitPluginContribution(
|
|
875
|
+
plugin(acc.view)
|
|
876
|
+
);
|
|
877
|
+
applyPluginContribution(acc, contribution, { callerLabel, override });
|
|
878
|
+
}
|
|
879
|
+
return acc;
|
|
880
|
+
}
|
|
881
|
+
function addPlugin(sdk, plugin, options) {
|
|
882
|
+
applyPluginToSdk(
|
|
883
|
+
sdk,
|
|
884
|
+
plugin,
|
|
885
|
+
options ?? {}
|
|
886
|
+
);
|
|
887
|
+
}
|
|
888
|
+
function buildSdk(properties, context) {
|
|
889
|
+
const addPlugin2 = (plugin, options) => {
|
|
890
|
+
logDeprecation(
|
|
891
|
+
"sdk.addPlugin(plugin) (the chain-style extension) is deprecated. Build the SDK in one pass with createPluginStack().use(...).toSdk() instead \u2014 each .toSdk() produces fresh plugin closures and avoids the closure-sharing semantics that caused this to be deprecated."
|
|
892
|
+
);
|
|
893
|
+
const contribution = splitPluginContribution(
|
|
894
|
+
plugin({ ...properties, context })
|
|
895
|
+
);
|
|
896
|
+
const mergedProperties = { ...properties };
|
|
897
|
+
const mergedContext = {
|
|
898
|
+
...context,
|
|
899
|
+
meta: { ...context.meta },
|
|
900
|
+
hooks: { ...context.hooks }
|
|
901
|
+
};
|
|
902
|
+
mergeContribution(mergedProperties, mergedContext, contribution, {
|
|
903
|
+
callerLabel: "addPlugin",
|
|
904
|
+
override: options?.override === true
|
|
905
|
+
});
|
|
906
|
+
return buildSdk(
|
|
907
|
+
mergedProperties,
|
|
908
|
+
mergedContext
|
|
909
|
+
);
|
|
910
|
+
};
|
|
911
|
+
return wrapAsSdk(properties, context, { addPlugin: addPlugin2 });
|
|
912
|
+
}
|
|
913
|
+
function withDeprecatedAddPlugin(sdk) {
|
|
914
|
+
const initialProperties = {};
|
|
915
|
+
for (const key of Object.keys(sdk)) {
|
|
916
|
+
if (key === "context" || key === "getRegistry" || key === "addPlugin") {
|
|
917
|
+
continue;
|
|
1136
918
|
}
|
|
1137
|
-
|
|
1138
|
-
target[key] = source[key];
|
|
919
|
+
initialProperties[key] = sdk[key];
|
|
1139
920
|
}
|
|
921
|
+
const initialContext = sdk.context;
|
|
922
|
+
return buildSdk(
|
|
923
|
+
initialProperties,
|
|
924
|
+
initialContext
|
|
925
|
+
);
|
|
1140
926
|
}
|
|
1141
927
|
function composePlugins(...plugins) {
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
928
|
+
logDeprecation(
|
|
929
|
+
"composePlugins(...) is deprecated. Use createPluginStack().use(a).use(b).use(c).toPlugin() instead. The stack carries the same collision-detection and hook-composition behavior, supports per-step { override: true } for intentional duplicates, and progressively narrows types so dependency mistakes surface at the specific .use call."
|
|
930
|
+
);
|
|
931
|
+
let stack = buildPluginStack(
|
|
932
|
+
null,
|
|
933
|
+
"composePlugins"
|
|
934
|
+
);
|
|
935
|
+
for (const plugin of plugins) {
|
|
936
|
+
stack = stack.use(plugin);
|
|
937
|
+
}
|
|
938
|
+
return stack.toPlugin();
|
|
939
|
+
}
|
|
940
|
+
function createPluginStack() {
|
|
941
|
+
return buildPluginStack(null, "createPluginStack");
|
|
942
|
+
}
|
|
943
|
+
function buildPluginStack(head, callerLabel) {
|
|
944
|
+
return {
|
|
945
|
+
use(plugin, options) {
|
|
946
|
+
const next = {
|
|
947
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
948
|
+
plugin,
|
|
949
|
+
override: options?.override === true,
|
|
950
|
+
prev: head
|
|
951
|
+
};
|
|
952
|
+
return buildPluginStack(next, callerLabel);
|
|
953
|
+
},
|
|
954
|
+
toPlugin() {
|
|
955
|
+
const ordered = [];
|
|
956
|
+
let node = head;
|
|
957
|
+
while (node) {
|
|
958
|
+
ordered.unshift(node);
|
|
959
|
+
node = node.prev;
|
|
960
|
+
}
|
|
961
|
+
return (outerSdk) => {
|
|
962
|
+
const { context: outerContext, ...outerProperties } = outerSdk ?? {};
|
|
963
|
+
const viewAcc = createPluginAccumulator(outerProperties, outerContext);
|
|
964
|
+
const contribsAcc = createPluginAccumulator();
|
|
965
|
+
for (const { plugin: subPlugin, override } of ordered) {
|
|
966
|
+
const contribution = splitPluginContribution(
|
|
967
|
+
subPlugin(viewAcc.view)
|
|
968
|
+
);
|
|
969
|
+
applyPluginContribution(viewAcc, contribution, {
|
|
970
|
+
callerLabel,
|
|
971
|
+
override
|
|
972
|
+
});
|
|
973
|
+
applyPluginContribution(contribsAcc, contribution, {
|
|
974
|
+
callerLabel,
|
|
975
|
+
override
|
|
976
|
+
});
|
|
1154
977
|
}
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
}
|
|
978
|
+
const { context: _ignored, ...contributedRoot } = contribsAcc.view;
|
|
979
|
+
return {
|
|
980
|
+
...contributedRoot,
|
|
981
|
+
context: contribsAcc.context
|
|
982
|
+
};
|
|
983
|
+
};
|
|
984
|
+
},
|
|
985
|
+
toSdk() {
|
|
986
|
+
return wrapAccumulatorAsSdk(
|
|
987
|
+
buildStackAccumulator(head, callerLabel)
|
|
988
|
+
);
|
|
1161
989
|
}
|
|
1162
|
-
return merged;
|
|
1163
990
|
};
|
|
1164
991
|
}
|
|
1165
|
-
function
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
992
|
+
function createCorePlugin(options) {
|
|
993
|
+
return () => ({
|
|
994
|
+
context: {
|
|
995
|
+
core: options
|
|
996
|
+
}
|
|
997
|
+
});
|
|
998
|
+
}
|
|
999
|
+
function withPositional(schema) {
|
|
1000
|
+
Object.assign(schema._zod.def, {
|
|
1001
|
+
positionalMeta: { positional: true }
|
|
1002
|
+
});
|
|
1003
|
+
return schema;
|
|
1004
|
+
}
|
|
1005
|
+
function schemaHasPositionalMeta(schema) {
|
|
1006
|
+
return "positionalMeta" in schema._zod.def;
|
|
1007
|
+
}
|
|
1008
|
+
function isPositional(schema) {
|
|
1009
|
+
if (schemaHasPositionalMeta(schema) && schema._zod.def.positionalMeta?.positional) {
|
|
1010
|
+
return true;
|
|
1011
|
+
}
|
|
1012
|
+
if (schema instanceof zod.z.ZodOptional) {
|
|
1013
|
+
return isPositional(schema._zod.def.innerType);
|
|
1014
|
+
}
|
|
1015
|
+
if (schema instanceof zod.z.ZodDefault) {
|
|
1016
|
+
return isPositional(schema._zod.def.innerType);
|
|
1017
|
+
}
|
|
1018
|
+
return false;
|
|
1019
|
+
}
|
|
1020
|
+
|
|
1021
|
+
// src/utils/logging.ts
|
|
1022
|
+
var { logDeprecation: logDeprecation2, resetDeprecationWarnings: resetDeprecationWarnings2 } = createDeprecationLogger("zapier-sdk");
|
|
1023
|
+
|
|
1024
|
+
// src/types/errors.ts
|
|
1025
|
+
var _a, _b;
|
|
1026
|
+
var ZapierError = class extends (_b = Error, _a = CORE_ERROR_SYMBOL, _b) {
|
|
1027
|
+
constructor(message, options = {}) {
|
|
1028
|
+
super(message);
|
|
1029
|
+
this[_a] = true;
|
|
1030
|
+
this.name = "ZapierError";
|
|
1031
|
+
this.code = "ZAPIER_ERROR";
|
|
1032
|
+
if (options.statusCode !== void 0) this.statusCode = options.statusCode;
|
|
1033
|
+
if (options.errors !== void 0) this.errors = options.errors;
|
|
1034
|
+
if (options.cause !== void 0) this.cause = options.cause;
|
|
1035
|
+
if (options.response !== void 0) this.response = options.response;
|
|
1036
|
+
Object.setPrototypeOf(this, new.target.prototype);
|
|
1037
|
+
}
|
|
1038
|
+
};
|
|
1039
|
+
var ZapierValidationError = class extends ZapierError {
|
|
1040
|
+
constructor(message, options = {}) {
|
|
1041
|
+
super(message, options);
|
|
1042
|
+
this.name = "ZapierValidationError";
|
|
1043
|
+
this.code = "ZAPIER_VALIDATION_ERROR";
|
|
1044
|
+
this.details = options.details;
|
|
1045
|
+
}
|
|
1046
|
+
};
|
|
1047
|
+
var ZapierUnknownError = class extends ZapierError {
|
|
1048
|
+
constructor() {
|
|
1049
|
+
super(...arguments);
|
|
1050
|
+
this.name = "ZapierUnknownError";
|
|
1051
|
+
this.code = "ZAPIER_UNKNOWN_ERROR";
|
|
1052
|
+
}
|
|
1053
|
+
};
|
|
1054
|
+
var ZapierAuthenticationError = class extends ZapierError {
|
|
1055
|
+
constructor() {
|
|
1056
|
+
super(...arguments);
|
|
1057
|
+
this.name = "ZapierAuthenticationError";
|
|
1058
|
+
this.code = "ZAPIER_AUTHENTICATION_ERROR";
|
|
1059
|
+
}
|
|
1060
|
+
};
|
|
1061
|
+
var zapierAdaptError = (options) => {
|
|
1062
|
+
switch (options.code) {
|
|
1063
|
+
case CoreErrorCode.Validation:
|
|
1064
|
+
return new ZapierValidationError(options.message, {
|
|
1065
|
+
cause: options.cause,
|
|
1066
|
+
details: options.details
|
|
1067
|
+
});
|
|
1068
|
+
case CoreErrorCode.Unknown:
|
|
1069
|
+
return new ZapierUnknownError(options.message, {
|
|
1070
|
+
cause: options.cause
|
|
1071
|
+
});
|
|
1072
|
+
default:
|
|
1073
|
+
return new ZapierError(options.message, { cause: options.cause });
|
|
1074
|
+
}
|
|
1075
|
+
};
|
|
1076
|
+
var ZapierApiError = class extends ZapierError {
|
|
1077
|
+
constructor(message, options = {}) {
|
|
1078
|
+
super(message, options);
|
|
1079
|
+
this.name = "ZapierApiError";
|
|
1080
|
+
this.code = "ZAPIER_API_ERROR";
|
|
1081
|
+
}
|
|
1082
|
+
};
|
|
1083
|
+
var ZapierAppNotFoundError = class extends ZapierError {
|
|
1084
|
+
constructor(message, options = {}) {
|
|
1085
|
+
super(message, options);
|
|
1086
|
+
this.name = "ZapierAppNotFoundError";
|
|
1087
|
+
this.code = "ZAPIER_APP_NOT_FOUND_ERROR";
|
|
1088
|
+
this.appKey = options.appKey;
|
|
1089
|
+
}
|
|
1090
|
+
};
|
|
1091
|
+
var ZapierNotFoundError = class extends ZapierError {
|
|
1092
|
+
constructor(message, options = {}) {
|
|
1093
|
+
super(message, options);
|
|
1094
|
+
this.name = "ZapierNotFoundError";
|
|
1095
|
+
this.code = "ZAPIER_NOT_FOUND_ERROR";
|
|
1096
|
+
}
|
|
1097
|
+
};
|
|
1098
|
+
var ZapierResourceNotFoundError = class extends ZapierNotFoundError {
|
|
1099
|
+
constructor(message, options = {}) {
|
|
1100
|
+
super(message, options);
|
|
1101
|
+
this.name = "ZapierResourceNotFoundError";
|
|
1102
|
+
this.code = "ZAPIER_RESOURCE_NOT_FOUND_ERROR";
|
|
1103
|
+
this.resourceType = options.resourceType;
|
|
1104
|
+
this.resourceId = options.resourceId;
|
|
1105
|
+
}
|
|
1106
|
+
};
|
|
1107
|
+
var ZapierConfigurationError = class extends ZapierError {
|
|
1108
|
+
constructor(message, options = {}) {
|
|
1109
|
+
super(message, options);
|
|
1110
|
+
this.name = "ZapierConfigurationError";
|
|
1111
|
+
this.code = "ZAPIER_CONFIGURATION_ERROR";
|
|
1112
|
+
this.configType = options.configType;
|
|
1113
|
+
}
|
|
1114
|
+
};
|
|
1115
|
+
var ZapierBundleError = class extends ZapierError {
|
|
1116
|
+
constructor(message, options = {}) {
|
|
1117
|
+
super(message, options);
|
|
1118
|
+
this.name = "ZapierBundleError";
|
|
1119
|
+
this.code = "ZAPIER_BUNDLE_ERROR";
|
|
1120
|
+
this.buildErrors = options.buildErrors;
|
|
1121
|
+
}
|
|
1122
|
+
};
|
|
1123
|
+
var ZapierTimeoutError = class extends ZapierError {
|
|
1124
|
+
constructor(message, options = {}) {
|
|
1125
|
+
super(message, options);
|
|
1126
|
+
this.name = "ZapierTimeoutError";
|
|
1127
|
+
this.code = "ZAPIER_TIMEOUT_ERROR";
|
|
1128
|
+
this.attempts = options.attempts;
|
|
1129
|
+
this.maxAttempts = options.maxAttempts;
|
|
1130
|
+
}
|
|
1131
|
+
};
|
|
1132
|
+
var ZapierActionError = class extends ZapierError {
|
|
1133
|
+
constructor(message, options = {}) {
|
|
1134
|
+
super(message, options);
|
|
1135
|
+
this.name = "ZapierActionError";
|
|
1136
|
+
this.code = "ZAPIER_ACTION_ERROR";
|
|
1137
|
+
this.appKey = options.appKey;
|
|
1138
|
+
this.actionKey = options.actionKey;
|
|
1139
|
+
}
|
|
1140
|
+
// Legacy accessor for backward compatibility
|
|
1141
|
+
get actionErrors() {
|
|
1142
|
+
return this.errors;
|
|
1143
|
+
}
|
|
1144
|
+
};
|
|
1145
|
+
var ZapierConflictError = class extends ZapierError {
|
|
1146
|
+
constructor(message, options = {}) {
|
|
1147
|
+
super(message, options);
|
|
1148
|
+
this.name = "ZapierConflictError";
|
|
1149
|
+
this.code = "ZAPIER_CONFLICT_ERROR";
|
|
1150
|
+
this.resourceType = options.resourceType;
|
|
1151
|
+
}
|
|
1152
|
+
};
|
|
1153
|
+
var ZapierRateLimitError = class extends ZapierError {
|
|
1154
|
+
constructor(message, options = {}) {
|
|
1155
|
+
super(message, options);
|
|
1156
|
+
this.name = "ZapierRateLimitError";
|
|
1157
|
+
this.code = "ZAPIER_RATE_LIMIT_ERROR";
|
|
1158
|
+
this.rateLimit = options.rateLimit ?? {};
|
|
1159
|
+
this.retries = options.retries ?? 0;
|
|
1160
|
+
}
|
|
1161
|
+
};
|
|
1162
|
+
var ZapierApprovalError = class extends ZapierError {
|
|
1163
|
+
constructor(message, options = {}) {
|
|
1164
|
+
super(message, options);
|
|
1165
|
+
this.name = "ZapierApprovalError";
|
|
1166
|
+
this.code = "ZAPIER_APPROVAL_ERROR";
|
|
1167
|
+
this.approvalId = options.approvalId;
|
|
1168
|
+
this.approvalStatus = options.status;
|
|
1169
|
+
this.approvalUrl = options.approvalUrl;
|
|
1170
|
+
this.pollUrl = options.pollUrl;
|
|
1171
|
+
}
|
|
1172
|
+
};
|
|
1173
|
+
var ZapierRelayError = class extends ZapierError {
|
|
1174
|
+
constructor(message, options = {}) {
|
|
1175
|
+
super(message, options);
|
|
1176
|
+
this.name = "ZapierRelayError";
|
|
1177
|
+
this.code = "ZAPIER_RELAY_ERROR";
|
|
1178
|
+
}
|
|
1179
|
+
};
|
|
1180
|
+
function formatErrorMessage(error) {
|
|
1181
|
+
let message = error.message;
|
|
1182
|
+
if (error.errors && error.errors.length > 0) {
|
|
1183
|
+
const additionalErrors = error.errors.slice(1);
|
|
1184
|
+
if (additionalErrors.length > 0) {
|
|
1185
|
+
const errorDetails = additionalErrors.map((err) => ` \u2022 ${err.detail || err.title || err.code}`).join("\n");
|
|
1186
|
+
message += "\n\nAdditional errors:\n" + errorDetails;
|
|
1187
|
+
}
|
|
1188
|
+
}
|
|
1189
|
+
if (error instanceof ZapierAppNotFoundError && error.appKey) {
|
|
1190
|
+
message += `
|
|
1191
|
+
App key: ${error.appKey}`;
|
|
1192
|
+
}
|
|
1193
|
+
if (error instanceof ZapierActionError && (error.appKey || error.actionKey)) {
|
|
1194
|
+
const context = [];
|
|
1195
|
+
if (error.appKey) context.push(`App: ${error.appKey}`);
|
|
1196
|
+
if (error.actionKey) context.push(`Action: ${error.actionKey}`);
|
|
1197
|
+
message += `
|
|
1198
|
+
${context.join(", ")}`;
|
|
1199
|
+
}
|
|
1200
|
+
if (error instanceof ZapierResourceNotFoundError && (error.resourceType || error.resourceId)) {
|
|
1201
|
+
const context = [];
|
|
1202
|
+
if (error.resourceType) context.push(`Type: ${error.resourceType}`);
|
|
1203
|
+
if (error.resourceId) context.push(`ID: ${error.resourceId}`);
|
|
1204
|
+
message += `
|
|
1205
|
+
${context.join(", ")}`;
|
|
1206
|
+
}
|
|
1207
|
+
if (error instanceof ZapierConflictError && error.resourceType) {
|
|
1208
|
+
message += `
|
|
1209
|
+
Type: ${error.resourceType}`;
|
|
1210
|
+
}
|
|
1211
|
+
if (error instanceof ZapierTimeoutError && (error.attempts || error.maxAttempts)) {
|
|
1212
|
+
const context = [];
|
|
1213
|
+
if (error.attempts) context.push(`Attempts: ${error.attempts}`);
|
|
1214
|
+
if (error.maxAttempts) context.push(`Max attempts: ${error.maxAttempts}`);
|
|
1215
|
+
message += `
|
|
1216
|
+
${context.join(", ")}`;
|
|
1217
|
+
}
|
|
1218
|
+
if (error instanceof ZapierBundleError && error.buildErrors && error.buildErrors.length > 0) {
|
|
1219
|
+
message += "\n\nBuild errors:\n" + error.buildErrors.map((err) => ` \u2022 ${err}`).join("\n");
|
|
1220
|
+
}
|
|
1221
|
+
if (error instanceof ZapierApprovalError && error.approvalUrl) {
|
|
1222
|
+
message += `
|
|
1223
|
+
Approval URL: ${error.approvalUrl}`;
|
|
1224
|
+
}
|
|
1225
|
+
if (error instanceof ZapierRateLimitError) {
|
|
1226
|
+
const { limit, remaining, retryAfterMs } = error.rateLimit;
|
|
1227
|
+
const parts = [];
|
|
1228
|
+
if (limit !== void 0) {
|
|
1229
|
+
const used = remaining !== void 0 ? limit - remaining : limit;
|
|
1230
|
+
parts.push(`${used}/${limit} used`);
|
|
1231
|
+
}
|
|
1232
|
+
if (retryAfterMs !== void 0 && retryAfterMs > 0) {
|
|
1233
|
+
parts.push(`retry in ${formatDuration(retryAfterMs)}`);
|
|
1234
|
+
}
|
|
1235
|
+
if (error.retries > 0) {
|
|
1236
|
+
parts.push(
|
|
1237
|
+
`after ${error.retries} retr${error.retries === 1 ? "y" : "ies"}`
|
|
1238
|
+
);
|
|
1239
|
+
}
|
|
1240
|
+
if (parts.length > 0) {
|
|
1241
|
+
message += `
|
|
1242
|
+
${parts.join(", ")}`;
|
|
1243
|
+
}
|
|
1244
|
+
}
|
|
1245
|
+
if (error.statusCode && !message.includes(`${error.statusCode}`)) {
|
|
1246
|
+
message += `
|
|
1247
|
+
HTTP Status: ${error.statusCode}`;
|
|
1248
|
+
}
|
|
1249
|
+
return message;
|
|
1250
|
+
}
|
|
1251
|
+
function formatDuration(ms) {
|
|
1252
|
+
const seconds = Math.round(ms / 1e3);
|
|
1253
|
+
if (seconds < 60) return `${seconds}s`;
|
|
1254
|
+
const minutes = Math.round(seconds / 60);
|
|
1255
|
+
if (minutes < 60) return `${minutes}m`;
|
|
1256
|
+
const hours = Math.round(minutes / 60);
|
|
1257
|
+
if (hours < 24) return `${hours}h`;
|
|
1258
|
+
const days = Math.round(hours / 24);
|
|
1259
|
+
return `${days}d`;
|
|
1260
|
+
}
|
|
1261
|
+
|
|
1262
|
+
// src/core-stack.ts
|
|
1263
|
+
var zapierCorePlugin = createCorePlugin({
|
|
1264
|
+
adaptError: zapierAdaptError
|
|
1265
|
+
});
|
|
1266
|
+
function createZapierCoreStack() {
|
|
1267
|
+
return createPluginStack().use(zapierCorePlugin);
|
|
1268
|
+
}
|
|
1269
|
+
|
|
1270
|
+
// src/constants.ts
|
|
1271
|
+
var ZAPIER_BASE_URL = globalThis.process?.env?.ZAPIER_BASE_URL || "https://zapier.com";
|
|
1272
|
+
function getZapierSdkService() {
|
|
1273
|
+
return globalThis.process?.env?.ZAPIER_SDK_SERVICE;
|
|
1274
|
+
}
|
|
1275
|
+
var MAX_PAGE_LIMIT = 1e4;
|
|
1276
|
+
var DEFAULT_PAGE_SIZE = 100;
|
|
1277
|
+
var DEFAULT_ACTION_TIMEOUT_MS = 18e4;
|
|
1278
|
+
function parseIntEnvVar(name) {
|
|
1279
|
+
const value = globalThis.process?.env?.[name];
|
|
1280
|
+
if (value === void 0) return void 0;
|
|
1281
|
+
const parsed = parseInt(value, 10);
|
|
1282
|
+
if (isNaN(parsed)) {
|
|
1283
|
+
console.warn(
|
|
1284
|
+
`[zapier-sdk] Invalid value for ${name}: "${value}" (expected integer)`
|
|
1285
|
+
);
|
|
1286
|
+
return void 0;
|
|
1287
|
+
}
|
|
1288
|
+
return parsed;
|
|
1289
|
+
}
|
|
1290
|
+
var ZAPIER_MAX_NETWORK_RETRIES = parseIntEnvVar("ZAPIER_MAX_NETWORK_RETRIES") ?? 3;
|
|
1291
|
+
var ZAPIER_MAX_NETWORK_RETRY_DELAY_MS = parseIntEnvVar("ZAPIER_MAX_NETWORK_RETRY_DELAY_MS") ?? 6e4;
|
|
1292
|
+
var MAX_CONCURRENCY_LIMIT = 1e4;
|
|
1293
|
+
function parseConcurrencyEnvVar(name) {
|
|
1294
|
+
const value = globalThis.process?.env?.[name];
|
|
1295
|
+
if (!value) return void 0;
|
|
1296
|
+
if (value === "Infinity") return Infinity;
|
|
1297
|
+
if (/^[1-9]\d*$/.test(value)) {
|
|
1298
|
+
const parsed = parseInt(value, 10);
|
|
1299
|
+
if (parsed <= MAX_CONCURRENCY_LIMIT) return parsed;
|
|
1169
1300
|
}
|
|
1301
|
+
console.warn(
|
|
1302
|
+
`[zapier-sdk] Invalid value for ${name}: "${value}" (expected positive integer 1-${MAX_CONCURRENCY_LIMIT} or "Infinity")`
|
|
1303
|
+
);
|
|
1170
1304
|
return void 0;
|
|
1171
1305
|
}
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
const
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
key: getStringProperty(obj, "key"),
|
|
1179
|
-
description: getStringProperty(obj, "description"),
|
|
1180
|
-
data: item,
|
|
1181
|
-
// Let formatJsonOutput handle the JSON rendering
|
|
1182
|
-
details: []
|
|
1183
|
-
// Not used when data is provided
|
|
1184
|
-
};
|
|
1306
|
+
var ZAPIER_MAX_CONCURRENT_REQUESTS = parseConcurrencyEnvVar("ZAPIER_MAX_CONCURRENT_REQUESTS") ?? 200;
|
|
1307
|
+
function getZapierApprovalMode() {
|
|
1308
|
+
const value = globalThis.process?.env?.ZAPIER_APPROVAL_MODE;
|
|
1309
|
+
if (value === "disabled" || value === "poll" || value === "throw")
|
|
1310
|
+
return value;
|
|
1311
|
+
return void 0;
|
|
1185
1312
|
}
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1313
|
+
function getZapierDefaultApprovalMode() {
|
|
1314
|
+
const isInteractive = !!globalThis.process?.stdin?.isTTY && !!globalThis.process?.stdout?.isTTY;
|
|
1315
|
+
return isInteractive ? "poll" : "throw";
|
|
1316
|
+
}
|
|
1317
|
+
var DEFAULT_APPROVAL_TIMEOUT_MS = 10 * 60 * 1e3;
|
|
1318
|
+
var DEFAULT_MAX_APPROVAL_RETRIES = 2;
|
|
1319
|
+
|
|
1320
|
+
// src/types/properties.ts
|
|
1321
|
+
var AppKeyPropertySchema = withPositional(
|
|
1322
|
+
zod.z.string().min(1).describe("App key (e.g., 'SlackCLIAPI' or slug like 'github')")
|
|
1323
|
+
);
|
|
1324
|
+
var AppPropertySchema = withPositional(
|
|
1325
|
+
zod.z.string().min(1).describe(
|
|
1326
|
+
"App slug (e.g., 'github'), implementation name (e.g., 'SlackCLIAPI'), or versioned ID (e.g., 'github@1.2.3')"
|
|
1327
|
+
)
|
|
1328
|
+
);
|
|
1329
|
+
var ActionTypePropertySchema = zod.z.enum([
|
|
1330
|
+
"read",
|
|
1331
|
+
"read_bulk",
|
|
1332
|
+
"write",
|
|
1333
|
+
"run",
|
|
1334
|
+
"search",
|
|
1335
|
+
"search_or_write",
|
|
1336
|
+
"search_and_write",
|
|
1337
|
+
"filter"
|
|
1338
|
+
]).describe("Action type that matches the action's defined type");
|
|
1339
|
+
var ActionKeyPropertySchema = zod.z.string().min(1).describe("Action key to execute");
|
|
1340
|
+
var ActionPropertySchema = withPositional(
|
|
1341
|
+
zod.z.string().min(1).describe("Action key (e.g., 'send_message' or 'find_row')")
|
|
1342
|
+
);
|
|
1343
|
+
var InputFieldPropertySchema = withPositional(
|
|
1344
|
+
zod.z.string().min(1).describe("Input field key to get choices for")
|
|
1345
|
+
);
|
|
1346
|
+
var ConnectionIdPropertySchema = zod.z.union([zod.z.string(), zod.z.number().int().positive()]).describe("Connection ID to use for this action");
|
|
1347
|
+
var AuthenticationIdPropertySchema = ConnectionIdPropertySchema.meta({
|
|
1348
|
+
deprecated: true
|
|
1349
|
+
});
|
|
1350
|
+
var ConnectionPropertySchema = zod.z.union([zod.z.string(), zod.z.number().int().positive()]).describe(
|
|
1351
|
+
"Connection alias or connection ID (UUID or positive integer). Strings that match a key in the connections map are resolved against it; otherwise the value is used as a connection ID directly."
|
|
1352
|
+
);
|
|
1353
|
+
var InputsPropertySchema = zod.z.record(zod.z.string(), zod.z.unknown()).describe("Input parameters for the action");
|
|
1354
|
+
var LimitPropertySchema = zod.z.number().int().min(1).max(MAX_PAGE_LIMIT).default(50).describe("Maximum number of items to return");
|
|
1355
|
+
var OffsetPropertySchema = zod.z.number().int().min(0).default(0).describe("Number of items to skip for pagination");
|
|
1356
|
+
var OutputPropertySchema = zod.z.string().describe("Output file path");
|
|
1357
|
+
var DebugPropertySchema = zod.z.boolean().default(false).describe("Enable debug logging");
|
|
1358
|
+
var ParamsPropertySchema = zod.z.record(zod.z.string(), zod.z.unknown()).describe("Additional parameters");
|
|
1359
|
+
var ActionTimeoutMsPropertySchema = zod.z.number().min(1e3).optional().describe(
|
|
1360
|
+
`Maximum time to wait for action completion in milliseconds (default: ${DEFAULT_ACTION_TIMEOUT_MS})`
|
|
1361
|
+
);
|
|
1362
|
+
var TablePropertySchema = withPositional(
|
|
1363
|
+
zod.z.string().regex(/^[A-Z0-9]{26}$/, "Table ID must be a valid ULID").describe("The unique identifier of the table")
|
|
1364
|
+
);
|
|
1365
|
+
var RecordPropertySchema = withPositional(
|
|
1366
|
+
zod.z.string().regex(/^[A-Z0-9]{26}$/, "Record ID must be a valid ULID").describe("The unique identifier of the record")
|
|
1367
|
+
);
|
|
1368
|
+
var RecordsPropertySchema = zod.z.array(zod.z.string().regex(/^[A-Z0-9]{26}$/, "Record ID must be a valid ULID")).min(1).max(100).describe("Record IDs to operate on");
|
|
1369
|
+
var FieldsPropertySchema = zod.z.array(zod.z.union([zod.z.string(), zod.z.number()])).describe(
|
|
1370
|
+
'Fields to operate on. Accepts field names (e.g., "Email") or IDs (e.g., "f6", "6", or 6).'
|
|
1371
|
+
);
|
|
1372
|
+
var AppsPropertySchema = zod.z.array(zod.z.string()).describe("Filter by app keys (e.g., 'SlackCLIAPI' or slug like 'github')");
|
|
1373
|
+
var TablesPropertySchema = zod.z.array(zod.z.string()).describe("Filter by specific table IDs");
|
|
1374
|
+
var ConnectionsPropertySchema = zod.z.array(zod.z.string()).describe("List of connection IDs to filter by");
|
|
1375
|
+
var TriggerInboxPropertySchema = withPositional(
|
|
1376
|
+
zod.z.string().min(1).describe(
|
|
1377
|
+
"Trigger inbox identifier \u2014 UUID or name. Non-UUID values are resolved by name via the inbox list endpoint."
|
|
1378
|
+
)
|
|
1379
|
+
);
|
|
1380
|
+
var TriggerInboxNamePropertySchema = zod.z.string().min(1).max(100).describe(
|
|
1381
|
+
"Inbox name; unique per (user, account). Enables get-or-create on createTriggerInbox."
|
|
1382
|
+
);
|
|
1383
|
+
var LeasePropertySchema = zod.z.string().min(1).describe("Lease ID returned from leaseTriggerInboxMessages");
|
|
1384
|
+
var LeaseSecondsPropertySchema = zod.z.number().int().min(1).max(3600).describe(
|
|
1385
|
+
"Seconds until the lease expires; messages return to available if not acked. API default is 300 (5 minutes)."
|
|
1189
1386
|
);
|
|
1387
|
+
var LeaseLimitPropertySchema = zod.z.number().int().min(1).max(100).describe("Maximum messages to lease in a single batch (1-100)");
|
|
1388
|
+
|
|
1389
|
+
// src/plugins/apps/schemas.ts
|
|
1390
|
+
var ActionExecutionInputSchema = zod.z.object({
|
|
1391
|
+
inputs: zod.z.record(zod.z.string(), zod.z.unknown()).optional(),
|
|
1392
|
+
/** @deprecated Use `connection` instead. */
|
|
1393
|
+
connectionId: ConnectionIdPropertySchema.optional().meta({
|
|
1394
|
+
deprecated: true
|
|
1395
|
+
}),
|
|
1396
|
+
connection: ConnectionPropertySchema.optional(),
|
|
1397
|
+
/** @deprecated Use connection instead */
|
|
1398
|
+
authenticationId: AuthenticationIdPropertySchema.optional().meta({
|
|
1399
|
+
deprecated: true
|
|
1400
|
+
}),
|
|
1401
|
+
timeoutMs: ActionTimeoutMsPropertySchema
|
|
1402
|
+
}).describe(
|
|
1403
|
+
"Execute an action with the given inputs for the bound app, as an alternative to runAction"
|
|
1404
|
+
).meta({
|
|
1405
|
+
aliases: { connectionId: "connection", authenticationId: "connection" }
|
|
1406
|
+
});
|
|
1407
|
+
var AppFactoryInputSchema = zod.z.object({
|
|
1408
|
+
/** @deprecated Use `connection` instead. */
|
|
1409
|
+
connectionId: ConnectionIdPropertySchema.optional().meta({
|
|
1410
|
+
deprecated: true
|
|
1411
|
+
}),
|
|
1412
|
+
connection: ConnectionPropertySchema.optional(),
|
|
1413
|
+
/** @deprecated Use connection instead */
|
|
1414
|
+
authenticationId: AuthenticationIdPropertySchema.optional().meta({
|
|
1415
|
+
deprecated: true
|
|
1416
|
+
})
|
|
1417
|
+
}).describe("Bind a connection alias or numeric connectionId to an app").meta({
|
|
1418
|
+
aliases: { connectionId: "connection", authenticationId: "connection" }
|
|
1419
|
+
});
|
|
1420
|
+
var ActionResultItemSchema = zod.z.unknown().describe("Action execution result");
|
|
1190
1421
|
|
|
1191
1422
|
// src/plugins/apps/index.ts
|
|
1192
1423
|
function resolveProxyConnection({
|
|
@@ -1407,18 +1638,6 @@ var FetchInitSchema = zod.z.object({
|
|
|
1407
1638
|
aliases: { connectionId: "connection", authenticationId: "connection" }
|
|
1408
1639
|
});
|
|
1409
1640
|
|
|
1410
|
-
// src/utils/string-utils.ts
|
|
1411
|
-
function toTitleCase(input) {
|
|
1412
|
-
return input.replace(/([a-z0-9])([A-Z])/g, "$1 $2").replace(/[_\-]+/g, " ").replace(/\s+/g, " ").trim().split(" ").map((word) => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase()).join(" ");
|
|
1413
|
-
}
|
|
1414
|
-
function toSnakeCase(input) {
|
|
1415
|
-
let result = input.replace(/([a-z0-9])([A-Z])/g, "$1_$2").replace(/[\s\-]+/g, "_").replace(/_+/g, "_").replace(/^_|_$/g, "").toLowerCase();
|
|
1416
|
-
if (/^[0-9]/.test(result)) {
|
|
1417
|
-
result = "_" + result;
|
|
1418
|
-
}
|
|
1419
|
-
return result;
|
|
1420
|
-
}
|
|
1421
|
-
|
|
1422
1641
|
// src/utils/domain-utils.ts
|
|
1423
1642
|
function isConnectionId(value) {
|
|
1424
1643
|
return /^\d+$/.test(value) || isUuid(value);
|
|
@@ -1721,15 +1940,25 @@ function buildAbortHandle({
|
|
|
1721
1940
|
return combineAbortSignals({ handles });
|
|
1722
1941
|
}
|
|
1723
1942
|
var FetchInitSdkValidationSchema = zod.z.looseObject(FetchInitZapierFieldsSchema.shape).optional();
|
|
1724
|
-
var validateFetchInit = createValidator(FetchInitSdkValidationSchema);
|
|
1725
1943
|
var fetchPlugin = definePlugin(
|
|
1726
1944
|
(sdk) => {
|
|
1945
|
+
const validateFetchInit = createValidator(FetchInitSdkValidationSchema, {
|
|
1946
|
+
adaptError: sdk.context.core?.adaptError
|
|
1947
|
+
});
|
|
1727
1948
|
return {
|
|
1728
1949
|
fetch: async function fetch2(url, init) {
|
|
1729
|
-
return
|
|
1950
|
+
return runInMethodScope(async () => {
|
|
1730
1951
|
const { api } = sdk.context;
|
|
1952
|
+
const { onMethodStart, onMethodEnd } = sdk.context.hooks;
|
|
1731
1953
|
const startTime = Date.now();
|
|
1732
|
-
const
|
|
1954
|
+
const depth = getCurrentDepth();
|
|
1955
|
+
const args = init === void 0 ? [url] : [url, init];
|
|
1956
|
+
onMethodStart?.({
|
|
1957
|
+
methodName: "fetch",
|
|
1958
|
+
args,
|
|
1959
|
+
isPaginated: false,
|
|
1960
|
+
depth
|
|
1961
|
+
});
|
|
1733
1962
|
try {
|
|
1734
1963
|
if (init) {
|
|
1735
1964
|
validateFetchInit(init);
|
|
@@ -1801,17 +2030,13 @@ var fetchPlugin = definePlugin(
|
|
|
1801
2030
|
statusCode: result.status
|
|
1802
2031
|
});
|
|
1803
2032
|
}
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
argument_count: init ? 2 : 1,
|
|
1812
|
-
is_paginated: false
|
|
1813
|
-
});
|
|
1814
|
-
}
|
|
2033
|
+
onMethodEnd?.({
|
|
2034
|
+
methodName: "fetch",
|
|
2035
|
+
args,
|
|
2036
|
+
isPaginated: false,
|
|
2037
|
+
depth,
|
|
2038
|
+
durationMs: Date.now() - startTime
|
|
2039
|
+
});
|
|
1815
2040
|
return result;
|
|
1816
2041
|
} catch (error) {
|
|
1817
2042
|
throw rewrapIfMaxTimeTimeout({
|
|
@@ -1823,17 +2048,14 @@ var fetchPlugin = definePlugin(
|
|
|
1823
2048
|
abortHandle?.dispose();
|
|
1824
2049
|
}
|
|
1825
2050
|
} catch (error) {
|
|
1826
|
-
|
|
1827
|
-
|
|
1828
|
-
|
|
1829
|
-
|
|
1830
|
-
|
|
1831
|
-
|
|
1832
|
-
|
|
1833
|
-
|
|
1834
|
-
is_paginated: false
|
|
1835
|
-
});
|
|
1836
|
-
}
|
|
2051
|
+
onMethodEnd?.({
|
|
2052
|
+
methodName: "fetch",
|
|
2053
|
+
args,
|
|
2054
|
+
isPaginated: false,
|
|
2055
|
+
depth,
|
|
2056
|
+
durationMs: Date.now() - startTime,
|
|
2057
|
+
error: error instanceof Error ? error : new Error(String(error))
|
|
2058
|
+
});
|
|
1837
2059
|
throw error;
|
|
1838
2060
|
}
|
|
1839
2061
|
});
|
|
@@ -1843,7 +2065,11 @@ var fetchPlugin = definePlugin(
|
|
|
1843
2065
|
fetch: {
|
|
1844
2066
|
description: "Make authenticated HTTP requests to any API through Zapier. Pass a connectionId to automatically inject the user's stored credentials (OAuth tokens, API keys, etc.) into the outgoing request. Mirrors the native fetch(url, init?) signature with additional Zapier-specific options.",
|
|
1845
2067
|
packages: ["sdk", "cli", "mcp"],
|
|
1846
|
-
|
|
2068
|
+
// Auto-derive would produce "Http"/"Https" from the key alone;
|
|
2069
|
+
// declare the title explicitly here so the registry renders
|
|
2070
|
+
// "HTTP Request". Other plugins in this category use the bare
|
|
2071
|
+
// string "http"; the object form wins regardless of order.
|
|
2072
|
+
categories: [{ key: "http", title: "HTTP Request" }],
|
|
1847
2073
|
returnType: "Response",
|
|
1848
2074
|
inputParameters: [
|
|
1849
2075
|
{ name: "url", schema: FetchUrlSchema },
|
|
@@ -1932,7 +2158,7 @@ function createDebugLogger(enabled) {
|
|
|
1932
2158
|
}
|
|
1933
2159
|
return (message, data) => {
|
|
1934
2160
|
if (data === void 0 || data === "") {
|
|
1935
|
-
console.
|
|
2161
|
+
console.error(`[Zapier SDK] ${message}`);
|
|
1936
2162
|
return;
|
|
1937
2163
|
}
|
|
1938
2164
|
if (utilModule) {
|
|
@@ -1941,9 +2167,9 @@ function createDebugLogger(enabled) {
|
|
|
1941
2167
|
depth: null,
|
|
1942
2168
|
breakLength: 80
|
|
1943
2169
|
});
|
|
1944
|
-
console.
|
|
2170
|
+
console.error(`[Zapier SDK] ${message}`, formatted);
|
|
1945
2171
|
} else {
|
|
1946
|
-
console.
|
|
2172
|
+
console.error(`[Zapier SDK] ${message}`, data);
|
|
1947
2173
|
}
|
|
1948
2174
|
};
|
|
1949
2175
|
}
|
|
@@ -2142,7 +2368,8 @@ async function pollUntilComplete(options) {
|
|
|
2142
2368
|
pendingStatus = DEFAULT_PENDING_STATUS,
|
|
2143
2369
|
isPending,
|
|
2144
2370
|
resultExtractor = (response) => response,
|
|
2145
|
-
signal
|
|
2371
|
+
signal,
|
|
2372
|
+
maxPollingIntervalMs
|
|
2146
2373
|
} = options;
|
|
2147
2374
|
if (timeoutMs <= 0) {
|
|
2148
2375
|
throw new ZapierValidationError("Timeout must be greater than 0", {
|
|
@@ -2154,6 +2381,14 @@ async function pollUntilComplete(options) {
|
|
|
2154
2381
|
details: { initialDelay }
|
|
2155
2382
|
});
|
|
2156
2383
|
}
|
|
2384
|
+
if (maxPollingIntervalMs !== void 0 && maxPollingIntervalMs <= 0) {
|
|
2385
|
+
throw new ZapierValidationError(
|
|
2386
|
+
"Max polling interval must be greater than 0",
|
|
2387
|
+
{
|
|
2388
|
+
details: { maxPollingIntervalMs }
|
|
2389
|
+
}
|
|
2390
|
+
);
|
|
2391
|
+
}
|
|
2157
2392
|
if (signal?.aborted) throw makeAbortError();
|
|
2158
2393
|
const startTime = Date.now();
|
|
2159
2394
|
let attempts = 0;
|
|
@@ -2176,7 +2411,8 @@ async function pollUntilComplete(options) {
|
|
|
2176
2411
|
if (attempts > 0) {
|
|
2177
2412
|
const interval = getPollingInterval(elapsedTime);
|
|
2178
2413
|
const waitTime = calculateErrorBackoffMs(interval, errorCount);
|
|
2179
|
-
|
|
2414
|
+
const cappedWaitTime = maxPollingIntervalMs === void 0 ? waitTime : Math.min(waitTime, maxPollingIntervalMs);
|
|
2415
|
+
await sleep(cappedWaitTime, signal);
|
|
2180
2416
|
if (signal?.aborted) throw makeAbortError();
|
|
2181
2417
|
}
|
|
2182
2418
|
attempts++;
|
|
@@ -2459,17 +2695,17 @@ function resolveCredentialsFromEnv(sdkBaseUrl) {
|
|
|
2459
2695
|
}
|
|
2460
2696
|
}
|
|
2461
2697
|
if (globalThis.process?.env?.ZAPIER_TOKEN) {
|
|
2462
|
-
|
|
2698
|
+
logDeprecation2(
|
|
2463
2699
|
"ZAPIER_TOKEN is deprecated. Use ZAPIER_CREDENTIALS instead."
|
|
2464
2700
|
);
|
|
2465
2701
|
return globalThis.process?.env?.ZAPIER_TOKEN;
|
|
2466
2702
|
}
|
|
2467
2703
|
if (globalThis.process?.env?.ZAPIER_AUTH_CLIENT_ID) {
|
|
2468
|
-
|
|
2704
|
+
logDeprecation2(
|
|
2469
2705
|
"ZAPIER_AUTH_CLIENT_ID is deprecated. Use ZAPIER_CREDENTIALS_CLIENT_ID instead."
|
|
2470
2706
|
);
|
|
2471
2707
|
if (globalThis.process?.env?.ZAPIER_AUTH_BASE_URL) {
|
|
2472
|
-
|
|
2708
|
+
logDeprecation2(
|
|
2473
2709
|
"ZAPIER_AUTH_BASE_URL is deprecated. Use ZAPIER_CREDENTIALS_BASE_URL instead."
|
|
2474
2710
|
);
|
|
2475
2711
|
}
|
|
@@ -2503,7 +2739,7 @@ async function resolveCredentials(options = {}) {
|
|
|
2503
2739
|
return options.credentials;
|
|
2504
2740
|
}
|
|
2505
2741
|
if (options.token !== void 0) {
|
|
2506
|
-
|
|
2742
|
+
logDeprecation2(
|
|
2507
2743
|
"The `token` option is deprecated. Use `credentials` instead."
|
|
2508
2744
|
);
|
|
2509
2745
|
return options.token;
|
|
@@ -2745,7 +2981,7 @@ async function tryStoredClientCredentialToken(options) {
|
|
|
2745
2981
|
const cached = await readCachedToken(cacheKey, cache);
|
|
2746
2982
|
if (cached !== void 0) {
|
|
2747
2983
|
if (options.debug)
|
|
2748
|
-
console.
|
|
2984
|
+
console.error(
|
|
2749
2985
|
`[auth] Using cached token (clientId: ${activeCredential.clientId})`
|
|
2750
2986
|
);
|
|
2751
2987
|
emitAuthResolved(options.onEvent, "client_credentials");
|
|
@@ -2764,7 +3000,7 @@ async function tryStoredClientCredentialToken(options) {
|
|
|
2764
3000
|
);
|
|
2765
3001
|
}
|
|
2766
3002
|
if (options.debug)
|
|
2767
|
-
console.
|
|
3003
|
+
console.error(
|
|
2768
3004
|
`[auth] Using stored client credential (clientId: ${storedCredential.clientId})`
|
|
2769
3005
|
);
|
|
2770
3006
|
const token = await resolveAuthTokenFromCredentials(
|
|
@@ -2786,7 +3022,7 @@ async function resolveAuthToken(options = {}) {
|
|
|
2786
3022
|
const storedToken = await tryStoredClientCredentialToken(options);
|
|
2787
3023
|
if (storedToken !== void 0) return storedToken;
|
|
2788
3024
|
if (options.debug) {
|
|
2789
|
-
console.
|
|
3025
|
+
console.error("[auth] Using JWT (no stored client credential found)");
|
|
2790
3026
|
}
|
|
2791
3027
|
const jwtToken = await getTokenFromCliLogin({
|
|
2792
3028
|
onEvent: options.onEvent,
|
|
@@ -2816,7 +3052,7 @@ async function resolveAuthTokenFromCredentials(credentials, options) {
|
|
|
2816
3052
|
const cached = await readCachedToken(cacheKey, cache);
|
|
2817
3053
|
if (cached !== void 0) {
|
|
2818
3054
|
if (options.debug) {
|
|
2819
|
-
console.
|
|
3055
|
+
console.error(`[auth] Using cached token (clientId: ${clientId})`);
|
|
2820
3056
|
}
|
|
2821
3057
|
return cached;
|
|
2822
3058
|
}
|
|
@@ -2826,7 +3062,7 @@ async function resolveAuthTokenFromCredentials(credentials, options) {
|
|
|
2826
3062
|
const recheck = await readCachedToken(cacheKey, cache);
|
|
2827
3063
|
if (recheck !== void 0) {
|
|
2828
3064
|
if (options.debug) {
|
|
2829
|
-
console.
|
|
3065
|
+
console.error(
|
|
2830
3066
|
`[auth] Using cached token (clientId: ${clientId}, locked recheck)`
|
|
2831
3067
|
);
|
|
2832
3068
|
}
|
|
@@ -2889,7 +3125,7 @@ async function invalidateCredentialsToken(options) {
|
|
|
2889
3125
|
}
|
|
2890
3126
|
|
|
2891
3127
|
// src/sdk-version.ts
|
|
2892
|
-
var SDK_VERSION = (typeof process !== "undefined" && process.env ? "0.
|
|
3128
|
+
var SDK_VERSION = (typeof process !== "undefined" && process.env ? "0.68.0" : void 0) || "unknown";
|
|
2893
3129
|
|
|
2894
3130
|
// src/utils/open-url.ts
|
|
2895
3131
|
var nodePrefix = "node:";
|
|
@@ -2974,6 +3210,7 @@ var PollApprovalResponseSchema = zod.z.object({
|
|
|
2974
3210
|
status: ApprovalStatusSchema,
|
|
2975
3211
|
approval_id: zod.z.string()
|
|
2976
3212
|
});
|
|
3213
|
+
var APPROVAL_MAX_POLLING_INTERVAL_MS = 5e3;
|
|
2977
3214
|
function parseRateLimitHeaders(response) {
|
|
2978
3215
|
const info = {};
|
|
2979
3216
|
const retryAfter = response.headers.get("retry-after");
|
|
@@ -3682,6 +3919,7 @@ var ZapierApiClient = class {
|
|
|
3682
3919
|
})
|
|
3683
3920
|
),
|
|
3684
3921
|
timeoutMs,
|
|
3922
|
+
maxPollingIntervalMs: APPROVAL_MAX_POLLING_INTERVAL_MS,
|
|
3685
3923
|
isPending: (body2) => {
|
|
3686
3924
|
const parsed = PollApprovalResponseSchema.safeParse(body2);
|
|
3687
3925
|
return parsed.success && parsed.data.status === "pending_approval";
|
|
@@ -3816,36 +4054,36 @@ var apiPlugin = definePlugin(
|
|
|
3816
4054
|
}
|
|
3817
4055
|
);
|
|
3818
4056
|
var GetProfileSchema = zod.z.object({}).optional().describe("Get current user's profile information");
|
|
3819
|
-
var UserProfileItemSchema =
|
|
3820
|
-
zod.z.
|
|
3821
|
-
|
|
3822
|
-
|
|
3823
|
-
|
|
3824
|
-
|
|
3825
|
-
|
|
3826
|
-
|
|
3827
|
-
|
|
3828
|
-
|
|
3829
|
-
|
|
3830
|
-
|
|
3831
|
-
|
|
3832
|
-
|
|
3833
|
-
|
|
3834
|
-
}
|
|
3835
|
-
|
|
3836
|
-
|
|
3837
|
-
|
|
3838
|
-
|
|
3839
|
-
|
|
3840
|
-
}
|
|
3841
|
-
return {
|
|
3842
|
-
title: item.full_name,
|
|
3843
|
-
id: item.id,
|
|
3844
|
-
details
|
|
3845
|
-
};
|
|
4057
|
+
var UserProfileItemSchema = zod.z.object({
|
|
4058
|
+
id: zod.z.string(),
|
|
4059
|
+
first_name: zod.z.string(),
|
|
4060
|
+
last_name: zod.z.string(),
|
|
4061
|
+
full_name: zod.z.string(),
|
|
4062
|
+
email: zod.z.string(),
|
|
4063
|
+
email_confirmed: zod.z.boolean(),
|
|
4064
|
+
timezone: zod.z.string()
|
|
4065
|
+
});
|
|
4066
|
+
|
|
4067
|
+
// src/formatters/userProfile.ts
|
|
4068
|
+
var userProfileItemFormatter = {
|
|
4069
|
+
format: (item) => {
|
|
4070
|
+
const details = [];
|
|
4071
|
+
if (item.email) {
|
|
4072
|
+
details.push({ text: item.email, style: "dim" });
|
|
4073
|
+
}
|
|
4074
|
+
if (item.timezone) {
|
|
4075
|
+
details.push({
|
|
4076
|
+
text: `Timezone: ${item.timezone}`,
|
|
4077
|
+
style: "accent"
|
|
4078
|
+
});
|
|
3846
4079
|
}
|
|
4080
|
+
return {
|
|
4081
|
+
title: item.full_name,
|
|
4082
|
+
id: item.id,
|
|
4083
|
+
details
|
|
4084
|
+
};
|
|
3847
4085
|
}
|
|
3848
|
-
|
|
4086
|
+
};
|
|
3849
4087
|
|
|
3850
4088
|
// src/plugins/getProfile/index.ts
|
|
3851
4089
|
var getProfilePlugin = definePlugin(
|
|
@@ -3856,6 +4094,7 @@ var getProfilePlugin = definePlugin(
|
|
|
3856
4094
|
itemType: "Profile",
|
|
3857
4095
|
inputSchema: GetProfileSchema,
|
|
3858
4096
|
outputSchema: UserProfileItemSchema,
|
|
4097
|
+
formatter: userProfileItemFormatter,
|
|
3859
4098
|
handler: async ({ sdk: sdk2 }) => {
|
|
3860
4099
|
const profile = await sdk2.context.api.get(
|
|
3861
4100
|
"/zapier/api/v4/profile/",
|
|
@@ -3875,6 +4114,29 @@ var getProfilePlugin = definePlugin(
|
|
|
3875
4114
|
}
|
|
3876
4115
|
})
|
|
3877
4116
|
);
|
|
4117
|
+
|
|
4118
|
+
// src/utils/pagination.ts
|
|
4119
|
+
function extractCursorFromUrl(url) {
|
|
4120
|
+
try {
|
|
4121
|
+
const params = new URL(url).searchParams;
|
|
4122
|
+
return params.get("offset") ?? params.get("cursor") ?? void 0;
|
|
4123
|
+
} catch {
|
|
4124
|
+
return void 0;
|
|
4125
|
+
}
|
|
4126
|
+
}
|
|
4127
|
+
function adaptZapierPage(response) {
|
|
4128
|
+
const r = response ?? {};
|
|
4129
|
+
const data = r.data;
|
|
4130
|
+
const linksNext = r.links?.next;
|
|
4131
|
+
if (typeof linksNext === "string") {
|
|
4132
|
+
return { data, nextCursor: extractCursorFromUrl(linksNext) };
|
|
4133
|
+
}
|
|
4134
|
+
if (typeof r.next === "string") {
|
|
4135
|
+
return { data, nextCursor: extractCursorFromUrl(r.next) };
|
|
4136
|
+
}
|
|
4137
|
+
return { data };
|
|
4138
|
+
}
|
|
4139
|
+
var zapierPagination = { adaptPage: adaptZapierPage };
|
|
3878
4140
|
var ListAppsSchema = apps.ListAppsQuerySchema.omit({
|
|
3879
4141
|
offset: true,
|
|
3880
4142
|
app_keys: true,
|
|
@@ -3896,27 +4158,30 @@ var ListAppsSchema = apps.ListAppsQuerySchema.omit({
|
|
|
3896
4158
|
// SDK specific property for pagination/iterable helpers
|
|
3897
4159
|
cursor: zod.z.string().optional().describe("Cursor to start from")
|
|
3898
4160
|
}).describe("List all available apps with optional filtering");
|
|
3899
|
-
var AppItemSchema =
|
|
3900
|
-
|
|
3901
|
-
|
|
3902
|
-
|
|
3903
|
-
|
|
3904
|
-
|
|
3905
|
-
|
|
3906
|
-
|
|
3907
|
-
|
|
3908
|
-
|
|
3909
|
-
})
|
|
4161
|
+
var AppItemSchema = apps.AppItemSchema;
|
|
4162
|
+
|
|
4163
|
+
// src/formatters/app.ts
|
|
4164
|
+
var appItemFormatter = {
|
|
4165
|
+
format: (item) => ({
|
|
4166
|
+
title: item.title,
|
|
4167
|
+
key: item.key,
|
|
4168
|
+
keys: getAppKeyList(item),
|
|
4169
|
+
description: item.description,
|
|
4170
|
+
details: []
|
|
4171
|
+
})
|
|
4172
|
+
};
|
|
3910
4173
|
|
|
3911
4174
|
// src/plugins/listApps/index.ts
|
|
3912
4175
|
var listAppsPlugin = definePlugin(
|
|
3913
4176
|
(sdk) => createPaginatedPluginMethod(sdk, {
|
|
4177
|
+
...zapierPagination,
|
|
3914
4178
|
name: "listApps",
|
|
3915
4179
|
categories: ["app"],
|
|
3916
4180
|
type: "list",
|
|
3917
4181
|
itemType: "App",
|
|
3918
4182
|
inputSchema: ListAppsSchema,
|
|
3919
4183
|
outputSchema: AppItemSchema,
|
|
4184
|
+
formatter: appItemFormatter,
|
|
3920
4185
|
defaultPageSize: DEFAULT_PAGE_SIZE,
|
|
3921
4186
|
handler: async ({ sdk: sdk2, options }) => {
|
|
3922
4187
|
const { api, resolveAppKeys: resolveAppKeys2 } = sdk2.context;
|
|
@@ -3956,8 +4221,7 @@ var listAppsPlugin = definePlugin(
|
|
|
3956
4221
|
...options.cursor && { offset: options.cursor }
|
|
3957
4222
|
}
|
|
3958
4223
|
});
|
|
3959
|
-
}
|
|
3960
|
-
extractCursor: (response) => extractCursor(response.links)
|
|
4224
|
+
}
|
|
3961
4225
|
})
|
|
3962
4226
|
);
|
|
3963
4227
|
var GetAppDescription = "Get detailed information about a specific app";
|
|
@@ -4174,7 +4438,7 @@ var inputFieldKeyResolver = {
|
|
|
4174
4438
|
type: "dynamic",
|
|
4175
4439
|
depends: ["app", "action", "actionType", "connection"],
|
|
4176
4440
|
fetch: async (sdk, resolvedParams) => {
|
|
4177
|
-
const fieldsResponse = await sdk.
|
|
4441
|
+
const fieldsResponse = await sdk.listActionInputFields({
|
|
4178
4442
|
app: resolvedParams.app,
|
|
4179
4443
|
action: resolvedParams.action,
|
|
4180
4444
|
actionType: resolvedParams.actionType,
|
|
@@ -4280,7 +4544,8 @@ var workflowIdResolver = {
|
|
|
4280
4544
|
name: "workflow",
|
|
4281
4545
|
message: "Select a workflow:",
|
|
4282
4546
|
choices: workflows.map((workflow) => ({
|
|
4283
|
-
name: workflow.
|
|
4547
|
+
name: workflow.name,
|
|
4548
|
+
hint: workflow.enabled ? void 0 : [workflow.id, "disabled"],
|
|
4284
4549
|
value: workflow.id
|
|
4285
4550
|
}))
|
|
4286
4551
|
})
|
|
@@ -4295,7 +4560,8 @@ var durableRunIdResolver = {
|
|
|
4295
4560
|
name: "run",
|
|
4296
4561
|
message: "Select a run:",
|
|
4297
4562
|
choices: runs.map((run) => ({
|
|
4298
|
-
name:
|
|
4563
|
+
name: run.id,
|
|
4564
|
+
hint: run.status,
|
|
4299
4565
|
value: run.id
|
|
4300
4566
|
}))
|
|
4301
4567
|
})
|
|
@@ -4305,11 +4571,7 @@ var durableRunIdResolver = {
|
|
|
4305
4571
|
var workflowVersionIdResolver = {
|
|
4306
4572
|
type: "dynamic",
|
|
4307
4573
|
depends: ["workflow"],
|
|
4308
|
-
fetch: async (sdk, params) => toIterable(
|
|
4309
|
-
sdk.listWorkflowVersions({
|
|
4310
|
-
workflow: params.workflow
|
|
4311
|
-
})
|
|
4312
|
-
),
|
|
4574
|
+
fetch: async (sdk, params) => toIterable(sdk.listWorkflowVersions({ workflow: params.workflow })),
|
|
4313
4575
|
prompt: (versions) => ({
|
|
4314
4576
|
type: "list",
|
|
4315
4577
|
name: "version",
|
|
@@ -4325,11 +4587,7 @@ var workflowVersionIdResolver = {
|
|
|
4325
4587
|
var workflowRunIdResolver = {
|
|
4326
4588
|
type: "dynamic",
|
|
4327
4589
|
depends: ["workflow"],
|
|
4328
|
-
fetch: async (sdk, params) => toIterable(
|
|
4329
|
-
sdk.listWorkflowRuns({
|
|
4330
|
-
workflow: params.workflow
|
|
4331
|
-
})
|
|
4332
|
-
),
|
|
4590
|
+
fetch: async (sdk, params) => toIterable(sdk.listWorkflowRuns({ workflow: params.workflow })),
|
|
4333
4591
|
prompt: (runs) => ({
|
|
4334
4592
|
type: "list",
|
|
4335
4593
|
name: "run",
|
|
@@ -4345,11 +4603,7 @@ var workflowRunIdResolver = {
|
|
|
4345
4603
|
var triggerMessagesResolver = {
|
|
4346
4604
|
type: "dynamic",
|
|
4347
4605
|
depends: ["inbox"],
|
|
4348
|
-
fetch: async (sdk, params) => toIterable(
|
|
4349
|
-
sdk.listTriggerInboxMessages({
|
|
4350
|
-
inbox: params.inbox
|
|
4351
|
-
})
|
|
4352
|
-
),
|
|
4606
|
+
fetch: async (sdk, params) => toIterable(sdk.listTriggerInboxMessages({ inbox: params.inbox })),
|
|
4353
4607
|
prompt: (messages) => ({
|
|
4354
4608
|
type: "checkbox",
|
|
4355
4609
|
name: "messages",
|
|
@@ -4723,7 +4977,7 @@ var FieldApiItemSchema = zod.z.object({
|
|
|
4723
4977
|
var ListTableFieldsApiResponseSchema = zod.z.object({
|
|
4724
4978
|
data: zod.z.array(FieldApiItemSchema)
|
|
4725
4979
|
});
|
|
4726
|
-
var
|
|
4980
|
+
var FieldItemSchema = zod.z.object({
|
|
4727
4981
|
id: zod.z.string(),
|
|
4728
4982
|
type: FieldTypeSchema,
|
|
4729
4983
|
name: zod.z.string(),
|
|
@@ -4733,13 +4987,6 @@ var FieldItemSchemaBase = zod.z.object({
|
|
|
4733
4987
|
config: zod.z.record(zod.z.string(), zod.z.unknown()).optional(),
|
|
4734
4988
|
deleted_at: zod.z.string().nullable().optional()
|
|
4735
4989
|
});
|
|
4736
|
-
var FieldItemSchema = withFormatter(FieldItemSchemaBase, {
|
|
4737
|
-
format: (item) => ({
|
|
4738
|
-
title: item.name,
|
|
4739
|
-
id: item.id,
|
|
4740
|
-
details: [{ text: `Type: ${item.type}`, style: "dim" }]
|
|
4741
|
-
})
|
|
4742
|
-
});
|
|
4743
4990
|
var ListTableFieldsDescription = "List fields for a table";
|
|
4744
4991
|
var ListTableFieldsOptionsBaseSchema = zod.z.object({
|
|
4745
4992
|
fields: FieldsPropertySchema.optional(),
|
|
@@ -4995,6 +5242,7 @@ var getAppPlugin = definePlugin(
|
|
|
4995
5242
|
itemType: "App",
|
|
4996
5243
|
inputSchema: GetAppInputSchema,
|
|
4997
5244
|
outputSchema: AppItemSchema,
|
|
5245
|
+
formatter: appItemFormatter,
|
|
4998
5246
|
resolvers: { app: appKeyResolver },
|
|
4999
5247
|
handler: async ({ sdk: sdk2, options }) => {
|
|
5000
5248
|
const appKey = "app" in options ? options.app : options.appKey;
|
|
@@ -5328,48 +5576,54 @@ zod.z.object({
|
|
|
5328
5576
|
});
|
|
5329
5577
|
|
|
5330
5578
|
// src/schemas/Action.ts
|
|
5331
|
-
var ActionItemSchema =
|
|
5332
|
-
|
|
5333
|
-
|
|
5334
|
-
|
|
5335
|
-
|
|
5336
|
-
|
|
5337
|
-
|
|
5338
|
-
|
|
5339
|
-
|
|
5340
|
-
|
|
5341
|
-
|
|
5342
|
-
|
|
5343
|
-
|
|
5344
|
-
|
|
5345
|
-
|
|
5346
|
-
|
|
5347
|
-
|
|
5348
|
-
|
|
5349
|
-
|
|
5350
|
-
|
|
5351
|
-
|
|
5352
|
-
|
|
5353
|
-
|
|
5354
|
-
style: "normal"
|
|
5355
|
-
});
|
|
5356
|
-
}
|
|
5357
|
-
if (item.description) {
|
|
5358
|
-
details.push({
|
|
5359
|
-
text: item.description,
|
|
5360
|
-
style: "dim"
|
|
5361
|
-
});
|
|
5362
|
-
}
|
|
5363
|
-
return {
|
|
5364
|
-
title: item.title || item.key,
|
|
5365
|
-
id: item.id,
|
|
5366
|
-
key: item.key,
|
|
5367
|
-
description: item.description,
|
|
5368
|
-
details
|
|
5369
|
-
};
|
|
5579
|
+
var ActionItemSchema = ActionSchema.omit({
|
|
5580
|
+
type: true,
|
|
5581
|
+
name: true,
|
|
5582
|
+
selected_api: true
|
|
5583
|
+
}).extend({
|
|
5584
|
+
app_key: zod.z.string(),
|
|
5585
|
+
// App key without version (extracted from selected_api)
|
|
5586
|
+
app_version: zod.z.string().optional(),
|
|
5587
|
+
// Version extracted from selected_api
|
|
5588
|
+
action_type: ActionSchema.shape.type,
|
|
5589
|
+
// Mapped from original 'type' field
|
|
5590
|
+
title: zod.z.string(),
|
|
5591
|
+
// Mapped from original 'name' field
|
|
5592
|
+
type: zod.z.literal("action")
|
|
5593
|
+
// Fixed type identifier
|
|
5594
|
+
});
|
|
5595
|
+
|
|
5596
|
+
// src/formatters/action.ts
|
|
5597
|
+
var actionItemFormatter = {
|
|
5598
|
+
format: (item) => {
|
|
5599
|
+
const details = [{ text: `Type: ${item.action_type}`, style: "accent" }];
|
|
5600
|
+
if (item.app_key) {
|
|
5601
|
+
details.push({ text: `App: ${item.app_key}`, style: "normal" });
|
|
5370
5602
|
}
|
|
5603
|
+
if (item.description) {
|
|
5604
|
+
details.push({ text: item.description, style: "dim" });
|
|
5605
|
+
}
|
|
5606
|
+
return {
|
|
5607
|
+
title: item.title || item.key,
|
|
5608
|
+
id: item.id,
|
|
5609
|
+
key: item.key,
|
|
5610
|
+
description: item.description,
|
|
5611
|
+
details
|
|
5612
|
+
};
|
|
5371
5613
|
}
|
|
5372
|
-
|
|
5614
|
+
};
|
|
5615
|
+
|
|
5616
|
+
// src/plugins/eventEmission/method-metadata.ts
|
|
5617
|
+
var SCOPE_KEY = "methodMetadata";
|
|
5618
|
+
function setMethodMetadata(metadata) {
|
|
5619
|
+
const scope = getCurrentScope();
|
|
5620
|
+
if (!scope) return;
|
|
5621
|
+
const existing = scope[SCOPE_KEY];
|
|
5622
|
+
scope[SCOPE_KEY] = { ...existing, ...metadata };
|
|
5623
|
+
}
|
|
5624
|
+
function getMethodMetadata() {
|
|
5625
|
+
return getCurrentScope()?.[SCOPE_KEY];
|
|
5626
|
+
}
|
|
5373
5627
|
|
|
5374
5628
|
// src/plugins/listActions/index.ts
|
|
5375
5629
|
var listActionsPlugin = definePlugin(
|
|
@@ -5380,12 +5634,10 @@ var listActionsPlugin = definePlugin(
|
|
|
5380
5634
|
itemType: "Action",
|
|
5381
5635
|
inputSchema: ListActionsInputSchema,
|
|
5382
5636
|
outputSchema: ActionItemSchema,
|
|
5637
|
+
formatter: actionItemFormatter,
|
|
5383
5638
|
defaultPageSize: DEFAULT_PAGE_SIZE,
|
|
5384
5639
|
resolvers: { app: appKeyResolver, actionType: actionTypeResolver },
|
|
5385
|
-
handler: async ({
|
|
5386
|
-
sdk: sdk2,
|
|
5387
|
-
options
|
|
5388
|
-
}) => {
|
|
5640
|
+
handler: async ({ sdk: sdk2, options }) => {
|
|
5389
5641
|
const { api, getVersionedImplementationId } = sdk2.context;
|
|
5390
5642
|
const appKey = "app" in options ? options.app : options.appKey;
|
|
5391
5643
|
const selectedApi = await getVersionedImplementationId(appKey);
|
|
@@ -5453,6 +5705,7 @@ var getActionPlugin = definePlugin(
|
|
|
5453
5705
|
itemType: "Action",
|
|
5454
5706
|
inputSchema: GetActionInputSchema,
|
|
5455
5707
|
outputSchema: ActionItemSchema,
|
|
5708
|
+
formatter: actionItemFormatter,
|
|
5456
5709
|
resolvers: {
|
|
5457
5710
|
app: appKeyResolver,
|
|
5458
5711
|
actionType: actionTypeResolver,
|
|
@@ -5514,6 +5767,29 @@ var RunActionSchemaDeprecated = zod.z.object({
|
|
|
5514
5767
|
actionKey: ActionKeyPropertySchema
|
|
5515
5768
|
}).merge(RunActionBaseSchema);
|
|
5516
5769
|
var RunActionInputSchema = zod.z.union([RunActionSchema, RunActionSchemaDeprecated]).describe(RunActionDescription);
|
|
5770
|
+
|
|
5771
|
+
// src/formatters/actionResult.ts
|
|
5772
|
+
function getStringProperty(obj, key) {
|
|
5773
|
+
if (typeof obj === "object" && obj !== null && key in obj) {
|
|
5774
|
+
const value = obj[key];
|
|
5775
|
+
return typeof value === "string" ? value : void 0;
|
|
5776
|
+
}
|
|
5777
|
+
return void 0;
|
|
5778
|
+
}
|
|
5779
|
+
var actionResultItemFormatter = {
|
|
5780
|
+
format: (item) => {
|
|
5781
|
+
const obj = typeof item === "object" && item !== null ? item : {};
|
|
5782
|
+
const title = getStringProperty(obj, "title") || getStringProperty(obj, "name") || getStringProperty(obj, "label") || getStringProperty(obj, "subject") || "Action Result";
|
|
5783
|
+
return {
|
|
5784
|
+
title,
|
|
5785
|
+
id: getStringProperty(obj, "id"),
|
|
5786
|
+
key: getStringProperty(obj, "key"),
|
|
5787
|
+
description: getStringProperty(obj, "description"),
|
|
5788
|
+
data: item,
|
|
5789
|
+
details: []
|
|
5790
|
+
};
|
|
5791
|
+
}
|
|
5792
|
+
};
|
|
5517
5793
|
async function executeAction(actionOptions) {
|
|
5518
5794
|
const {
|
|
5519
5795
|
api,
|
|
@@ -5643,6 +5919,7 @@ var runActionPlugin = definePlugin(
|
|
|
5643
5919
|
itemType: "ActionResult",
|
|
5644
5920
|
inputSchema: RunActionInputSchema,
|
|
5645
5921
|
outputSchema: ActionResultItemSchema,
|
|
5922
|
+
formatter: actionResultItemFormatter,
|
|
5646
5923
|
resolvers: {
|
|
5647
5924
|
app: appKeyResolver,
|
|
5648
5925
|
actionType: actionTypeResolver,
|
|
@@ -5650,10 +5927,7 @@ var runActionPlugin = definePlugin(
|
|
|
5650
5927
|
connection: connectionIdResolver,
|
|
5651
5928
|
inputs: inputsResolver
|
|
5652
5929
|
},
|
|
5653
|
-
handler: async ({
|
|
5654
|
-
sdk: sdk2,
|
|
5655
|
-
options
|
|
5656
|
-
}) => {
|
|
5930
|
+
handler: async ({ sdk: sdk2, options }) => {
|
|
5657
5931
|
const { api } = sdk2.context;
|
|
5658
5932
|
const appKey = "app" in options ? options.app : options.appKey;
|
|
5659
5933
|
const actionKey = "action" in options ? options.action : options.actionKey;
|
|
@@ -5706,7 +5980,9 @@ var runActionPlugin = definePlugin(
|
|
|
5706
5980
|
}
|
|
5707
5981
|
return {
|
|
5708
5982
|
data: result.results || [],
|
|
5709
|
-
|
|
5983
|
+
// Coerce to a string: the API returns a numeric page index, but
|
|
5984
|
+
// `SdkPage.nextCursor` is a string (and the page guard enforces it).
|
|
5985
|
+
nextCursor: result.next_page != null ? String(result.next_page) : void 0
|
|
5710
5986
|
};
|
|
5711
5987
|
}
|
|
5712
5988
|
});
|
|
@@ -5761,7 +6037,10 @@ var ListConnectionsQuerySchema = connections.ListConnectionsQuerySchema.omit({
|
|
|
5761
6037
|
// SDK specific property for pagination/iterable helpers
|
|
5762
6038
|
cursor: zod.z.string().optional().describe("Cursor to start from")
|
|
5763
6039
|
}).describe("List available connections with optional filtering");
|
|
5764
|
-
var ConnectionItemSchema =
|
|
6040
|
+
var ConnectionItemSchema = connections.ConnectionItemSchema;
|
|
6041
|
+
|
|
6042
|
+
// src/formatters/connection.ts
|
|
6043
|
+
var connectionItemFormatter = {
|
|
5765
6044
|
format: (item) => {
|
|
5766
6045
|
const details = [];
|
|
5767
6046
|
if (item.identifier) {
|
|
@@ -5786,17 +6065,19 @@ var ConnectionItemSchema = withFormatter(connections.ConnectionItemSchema, {
|
|
|
5786
6065
|
details
|
|
5787
6066
|
};
|
|
5788
6067
|
}
|
|
5789
|
-
}
|
|
6068
|
+
};
|
|
5790
6069
|
|
|
5791
6070
|
// src/plugins/listConnections/index.ts
|
|
5792
6071
|
var listConnectionsPlugin = definePlugin(
|
|
5793
6072
|
(sdk) => createPaginatedPluginMethod(sdk, {
|
|
6073
|
+
...zapierPagination,
|
|
5794
6074
|
name: "listConnections",
|
|
5795
6075
|
categories: ["connection"],
|
|
5796
6076
|
type: "list",
|
|
5797
6077
|
itemType: "Connection",
|
|
5798
6078
|
inputSchema: ListConnectionsQuerySchema,
|
|
5799
6079
|
outputSchema: ConnectionItemSchema,
|
|
6080
|
+
formatter: connectionItemFormatter,
|
|
5800
6081
|
defaultPageSize: DEFAULT_PAGE_SIZE,
|
|
5801
6082
|
resolvers: { app: appKeyResolver },
|
|
5802
6083
|
handler: async ({ sdk: sdk2, options }) => {
|
|
@@ -5869,8 +6150,7 @@ var listConnectionsPlugin = definePlugin(
|
|
|
5869
6150
|
...response,
|
|
5870
6151
|
data: response.data.map(transformConnectionItem)
|
|
5871
6152
|
};
|
|
5872
|
-
}
|
|
5873
|
-
extractCursor: (response) => extractCursor(response.links)
|
|
6153
|
+
}
|
|
5874
6154
|
})
|
|
5875
6155
|
);
|
|
5876
6156
|
var GetConnectionParamSchema = zod.z.object({
|
|
@@ -5894,6 +6174,7 @@ var getConnectionPlugin = definePlugin(
|
|
|
5894
6174
|
itemType: "Connection",
|
|
5895
6175
|
inputSchema: GetConnectionParamSchema,
|
|
5896
6176
|
outputSchema: ConnectionItemSchema,
|
|
6177
|
+
formatter: connectionItemFormatter,
|
|
5897
6178
|
resolvers: { connection: connectionIdGenericResolver },
|
|
5898
6179
|
handler: async ({ sdk: sdk2, options }) => {
|
|
5899
6180
|
const { api } = sdk2.context;
|
|
@@ -5934,6 +6215,7 @@ var findFirstConnectionPlugin = definePlugin(
|
|
|
5934
6215
|
itemType: "Connection",
|
|
5935
6216
|
inputSchema: FindFirstConnectionSchema,
|
|
5936
6217
|
outputSchema: ConnectionItemSchema,
|
|
6218
|
+
formatter: connectionItemFormatter,
|
|
5937
6219
|
handler: async ({ sdk: sdk2, options = {} }) => {
|
|
5938
6220
|
const connectionsResponse = await sdk2.listConnections({
|
|
5939
6221
|
...options,
|
|
@@ -5969,6 +6251,7 @@ var findUniqueConnectionPlugin = definePlugin(
|
|
|
5969
6251
|
itemType: "Connection",
|
|
5970
6252
|
inputSchema: FindUniqueConnectionSchema,
|
|
5971
6253
|
outputSchema: ConnectionItemSchema,
|
|
6254
|
+
formatter: connectionItemFormatter,
|
|
5972
6255
|
handler: async ({ sdk: sdk2, options = {} }) => {
|
|
5973
6256
|
const connectionsResponse = await sdk2.listConnections({
|
|
5974
6257
|
...options,
|
|
@@ -5999,11 +6282,13 @@ var listAuthenticationsPlugin = definePlugin(
|
|
|
5999
6282
|
meta: {
|
|
6000
6283
|
listAuthentications: {
|
|
6001
6284
|
packages: ["cli", "mcp"],
|
|
6002
|
-
categories: ["connection"
|
|
6285
|
+
categories: ["connection"],
|
|
6286
|
+
deprecation: { message: "Use listConnections instead." },
|
|
6003
6287
|
type: "list",
|
|
6004
6288
|
itemType: "Connection",
|
|
6005
6289
|
inputSchema: ListConnectionsQuerySchema,
|
|
6006
|
-
outputSchema: ConnectionItemSchema
|
|
6290
|
+
outputSchema: ConnectionItemSchema,
|
|
6291
|
+
formatter: connectionItemFormatter
|
|
6007
6292
|
}
|
|
6008
6293
|
}
|
|
6009
6294
|
}
|
|
@@ -6016,11 +6301,13 @@ var getAuthenticationPlugin = definePlugin(
|
|
|
6016
6301
|
meta: {
|
|
6017
6302
|
getAuthentication: {
|
|
6018
6303
|
packages: ["cli", "mcp"],
|
|
6019
|
-
categories: ["connection"
|
|
6304
|
+
categories: ["connection"],
|
|
6305
|
+
deprecation: { message: "Use getConnection instead." },
|
|
6020
6306
|
type: "item",
|
|
6021
6307
|
itemType: "Connection",
|
|
6022
6308
|
inputSchema: GetConnectionParamSchema,
|
|
6023
|
-
outputSchema: ConnectionItemSchema
|
|
6309
|
+
outputSchema: ConnectionItemSchema,
|
|
6310
|
+
formatter: connectionItemFormatter
|
|
6024
6311
|
}
|
|
6025
6312
|
}
|
|
6026
6313
|
}
|
|
@@ -6033,11 +6320,13 @@ var findFirstAuthenticationPlugin = definePlugin(
|
|
|
6033
6320
|
meta: {
|
|
6034
6321
|
findFirstAuthentication: {
|
|
6035
6322
|
packages: ["cli", "mcp"],
|
|
6036
|
-
categories: ["connection"
|
|
6323
|
+
categories: ["connection"],
|
|
6324
|
+
deprecation: { message: "Use findFirstConnection instead." },
|
|
6037
6325
|
type: "item",
|
|
6038
6326
|
itemType: "Connection",
|
|
6039
6327
|
inputSchema: FindFirstConnectionSchema,
|
|
6040
|
-
outputSchema: ConnectionItemSchema
|
|
6328
|
+
outputSchema: ConnectionItemSchema,
|
|
6329
|
+
formatter: connectionItemFormatter
|
|
6041
6330
|
}
|
|
6042
6331
|
}
|
|
6043
6332
|
}
|
|
@@ -6050,11 +6339,13 @@ var findUniqueAuthenticationPlugin = definePlugin(
|
|
|
6050
6339
|
meta: {
|
|
6051
6340
|
findUniqueAuthentication: {
|
|
6052
6341
|
packages: ["cli", "mcp"],
|
|
6053
|
-
categories: ["connection"
|
|
6342
|
+
categories: ["connection"],
|
|
6343
|
+
deprecation: { message: "Use findUniqueConnection instead." },
|
|
6054
6344
|
type: "item",
|
|
6055
6345
|
itemType: "Connection",
|
|
6056
6346
|
inputSchema: FindUniqueConnectionSchema,
|
|
6057
|
-
outputSchema: ConnectionItemSchema
|
|
6347
|
+
outputSchema: ConnectionItemSchema,
|
|
6348
|
+
formatter: connectionItemFormatter
|
|
6058
6349
|
}
|
|
6059
6350
|
}
|
|
6060
6351
|
}
|
|
@@ -6071,58 +6362,49 @@ var ListClientCredentialsQuerySchema = clientCredentials.ListClientCredentialsQu
|
|
|
6071
6362
|
// SDK specific property for pagination/iterable helpers
|
|
6072
6363
|
cursor: zod.z.string().optional().describe("Cursor to start from")
|
|
6073
6364
|
}).describe("List client credentials for the authenticated user");
|
|
6074
|
-
var ClientCredentialsItemSchema =
|
|
6075
|
-
|
|
6076
|
-
|
|
6077
|
-
|
|
6078
|
-
|
|
6079
|
-
|
|
6080
|
-
|
|
6081
|
-
|
|
6082
|
-
|
|
6083
|
-
}
|
|
6084
|
-
|
|
6085
|
-
|
|
6086
|
-
details.push({
|
|
6087
|
-
text: `Created: ${new Date(item.created_at).toLocaleDateString()}`,
|
|
6088
|
-
style: "dim"
|
|
6089
|
-
});
|
|
6090
|
-
}
|
|
6091
|
-
return {
|
|
6092
|
-
title: item.name,
|
|
6093
|
-
id: item.client_id,
|
|
6094
|
-
details
|
|
6095
|
-
};
|
|
6365
|
+
var ClientCredentialsItemSchema = clientCredentials.ClientCredentialsItemSchema;
|
|
6366
|
+
var ClientCredentialsCreatedItemSchema = clientCredentials.ClientCredentialsCreatedItemSchema;
|
|
6367
|
+
|
|
6368
|
+
// src/formatters/clientCredentials.ts
|
|
6369
|
+
var clientCredentialsItemFormatter = {
|
|
6370
|
+
format: (item) => {
|
|
6371
|
+
const details = [];
|
|
6372
|
+
if (item.allowed_scopes && item.allowed_scopes.length > 0) {
|
|
6373
|
+
details.push({
|
|
6374
|
+
text: `Scopes: ${item.allowed_scopes.join(", ")}`,
|
|
6375
|
+
style: "accent"
|
|
6376
|
+
});
|
|
6096
6377
|
}
|
|
6097
|
-
|
|
6098
|
-
|
|
6099
|
-
|
|
6100
|
-
|
|
6101
|
-
|
|
6102
|
-
format: (item) => {
|
|
6103
|
-
return {
|
|
6104
|
-
title: item.name,
|
|
6105
|
-
id: item.client_id,
|
|
6106
|
-
details: [
|
|
6107
|
-
{
|
|
6108
|
-
text: `Client Secret: ${item.client_secret}`,
|
|
6109
|
-
style: "accent"
|
|
6110
|
-
}
|
|
6111
|
-
]
|
|
6112
|
-
};
|
|
6378
|
+
if (item.created_at) {
|
|
6379
|
+
details.push({
|
|
6380
|
+
text: `Created: ${new Date(item.created_at).toLocaleDateString()}`,
|
|
6381
|
+
style: "dim"
|
|
6382
|
+
});
|
|
6113
6383
|
}
|
|
6384
|
+
return { title: item.name, id: item.client_id, details };
|
|
6114
6385
|
}
|
|
6115
|
-
|
|
6386
|
+
};
|
|
6387
|
+
var clientCredentialsCreatedItemFormatter = {
|
|
6388
|
+
format: (item) => ({
|
|
6389
|
+
title: item.name,
|
|
6390
|
+
id: item.client_id,
|
|
6391
|
+
details: [
|
|
6392
|
+
{ text: `Client Secret: ${item.client_secret}`, style: "accent" }
|
|
6393
|
+
]
|
|
6394
|
+
})
|
|
6395
|
+
};
|
|
6116
6396
|
|
|
6117
6397
|
// src/plugins/listClientCredentials/index.ts
|
|
6118
6398
|
var listClientCredentialsPlugin = definePlugin(
|
|
6119
6399
|
(sdk) => createPaginatedPluginMethod(sdk, {
|
|
6400
|
+
...zapierPagination,
|
|
6120
6401
|
name: "listClientCredentials",
|
|
6121
6402
|
categories: ["client-credentials"],
|
|
6122
6403
|
type: "list",
|
|
6123
6404
|
itemType: "ClientCredentials",
|
|
6124
6405
|
inputSchema: ListClientCredentialsQuerySchema,
|
|
6125
6406
|
outputSchema: ClientCredentialsItemSchema,
|
|
6407
|
+
formatter: clientCredentialsItemFormatter,
|
|
6126
6408
|
defaultPageSize: DEFAULT_PAGE_SIZE,
|
|
6127
6409
|
handler: async ({
|
|
6128
6410
|
sdk: sdk2,
|
|
@@ -6143,8 +6425,7 @@ var listClientCredentialsPlugin = definePlugin(
|
|
|
6143
6425
|
requiredScopes: ["credentials"]
|
|
6144
6426
|
}
|
|
6145
6427
|
);
|
|
6146
|
-
}
|
|
6147
|
-
extractCursor: (response) => extractCursor(response.links)
|
|
6428
|
+
}
|
|
6148
6429
|
})
|
|
6149
6430
|
);
|
|
6150
6431
|
var CreateClientCredentialsSchema = clientCredentials.CreateClientCredentialsRequestSchema.omit({ allowed_scopes: true }).extend({
|
|
@@ -6162,6 +6443,7 @@ var createClientCredentialsPlugin = definePlugin(
|
|
|
6162
6443
|
itemType: "ClientCredentials",
|
|
6163
6444
|
inputSchema: CreateClientCredentialsSchema,
|
|
6164
6445
|
outputSchema: ClientCredentialsCreatedItemSchema,
|
|
6446
|
+
formatter: clientCredentialsCreatedItemFormatter,
|
|
6165
6447
|
confirm: "create-secret",
|
|
6166
6448
|
resolvers: { name: clientCredentialsNameResolver },
|
|
6167
6449
|
handler: async ({ sdk: sdk2, options }) => {
|
|
@@ -6251,99 +6533,36 @@ var BaseFieldItemSchema = zod.z.object({
|
|
|
6251
6533
|
key: zod.z.string()
|
|
6252
6534
|
// From need.key
|
|
6253
6535
|
});
|
|
6254
|
-
var InputFieldItemSchema =
|
|
6255
|
-
|
|
6256
|
-
|
|
6257
|
-
|
|
6258
|
-
|
|
6259
|
-
|
|
6260
|
-
|
|
6261
|
-
|
|
6262
|
-
|
|
6263
|
-
|
|
6264
|
-
|
|
6265
|
-
|
|
6266
|
-
|
|
6267
|
-
|
|
6268
|
-
|
|
6269
|
-
|
|
6270
|
-
|
|
6271
|
-
|
|
6272
|
-
|
|
6273
|
-
|
|
6274
|
-
|
|
6275
|
-
|
|
6276
|
-
|
|
6277
|
-
|
|
6278
|
-
|
|
6279
|
-
|
|
6280
|
-
|
|
6281
|
-
|
|
6282
|
-
|
|
6283
|
-
|
|
6284
|
-
].filter(Boolean).join(" | ");
|
|
6285
|
-
if (typeInfo) {
|
|
6286
|
-
details.push({ text: typeInfo, style: "dim" });
|
|
6287
|
-
}
|
|
6288
|
-
if (item.description) {
|
|
6289
|
-
details.push({
|
|
6290
|
-
text: item.description,
|
|
6291
|
-
style: "normal"
|
|
6292
|
-
});
|
|
6293
|
-
}
|
|
6294
|
-
if (item.default_value) {
|
|
6295
|
-
details.push({
|
|
6296
|
-
text: `Default: ${item.default_value}`,
|
|
6297
|
-
style: "accent"
|
|
6298
|
-
});
|
|
6299
|
-
}
|
|
6300
|
-
if (item.placeholder) {
|
|
6301
|
-
details.push({
|
|
6302
|
-
text: `Placeholder: ${item.placeholder}`,
|
|
6303
|
-
style: "dim"
|
|
6304
|
-
});
|
|
6305
|
-
}
|
|
6306
|
-
if (item.depends_on && item.depends_on.length > 0) {
|
|
6307
|
-
details.push({
|
|
6308
|
-
text: `Depends on: ${item.depends_on.join(", ")}`,
|
|
6309
|
-
style: "warning"
|
|
6310
|
-
});
|
|
6311
|
-
}
|
|
6312
|
-
if (item.format) {
|
|
6313
|
-
details.push({ text: `Format: ${item.format}`, style: "dim" });
|
|
6314
|
-
}
|
|
6315
|
-
if (item.items) {
|
|
6316
|
-
details.push({
|
|
6317
|
-
text: `Items type: ${item.items.type}`,
|
|
6318
|
-
style: "dim"
|
|
6319
|
-
});
|
|
6320
|
-
}
|
|
6321
|
-
return {
|
|
6322
|
-
title: item.title || item.key,
|
|
6323
|
-
key: item.key,
|
|
6324
|
-
description: item.description,
|
|
6325
|
-
details
|
|
6326
|
-
};
|
|
6327
|
-
}
|
|
6328
|
-
}
|
|
6329
|
-
);
|
|
6330
|
-
var InfoFieldItemSchema = withFormatter(
|
|
6331
|
-
BaseFieldItemSchema.extend({
|
|
6332
|
-
type: zod.z.literal("info_field"),
|
|
6333
|
-
description: zod.z.string(),
|
|
6334
|
-
// From need.help_text
|
|
6335
|
-
title: zod.z.string().optional()
|
|
6336
|
-
// Optional title
|
|
6337
|
-
}),
|
|
6338
|
-
{
|
|
6339
|
-
format: (item) => ({
|
|
6340
|
-
title: item.title || "Info",
|
|
6341
|
-
key: item.key,
|
|
6342
|
-
description: item.description,
|
|
6343
|
-
details: [{ text: item.description, style: "normal" }]
|
|
6344
|
-
})
|
|
6345
|
-
}
|
|
6346
|
-
);
|
|
6536
|
+
var InputFieldItemSchema = BaseFieldItemSchema.extend({
|
|
6537
|
+
type: zod.z.literal("input_field"),
|
|
6538
|
+
default_value: zod.z.string(),
|
|
6539
|
+
// Mapped from 'default' with fallback to ""
|
|
6540
|
+
depends_on: zod.z.array(zod.z.string()),
|
|
6541
|
+
// Mapped from 'depends_on' with fallback to []
|
|
6542
|
+
description: zod.z.string(),
|
|
6543
|
+
// Mapped from 'help_text' with fallback to ""
|
|
6544
|
+
invalidates_input_fields: zod.z.boolean(),
|
|
6545
|
+
// Mapped from 'alters_custom_fields' with fallback to false
|
|
6546
|
+
is_required: zod.z.boolean(),
|
|
6547
|
+
// Mapped from 'required' with fallback to false
|
|
6548
|
+
placeholder: zod.z.string(),
|
|
6549
|
+
// Mapped from 'placeholder' with fallback to ""
|
|
6550
|
+
title: zod.z.string(),
|
|
6551
|
+
// Mapped from 'label' with fallback to ""
|
|
6552
|
+
value_type: zod.z.string(),
|
|
6553
|
+
// Computed from InputFieldType enum
|
|
6554
|
+
format: zod.z.string().optional(),
|
|
6555
|
+
// Computed from InputFieldFormat enum (optional)
|
|
6556
|
+
items: zod.z.object({ type: zod.z.string() }).optional()
|
|
6557
|
+
// Computed from ItemsType enum (optional, only for arrays)
|
|
6558
|
+
});
|
|
6559
|
+
var InfoFieldItemSchema = BaseFieldItemSchema.extend({
|
|
6560
|
+
type: zod.z.literal("info_field"),
|
|
6561
|
+
description: zod.z.string(),
|
|
6562
|
+
// From need.help_text
|
|
6563
|
+
title: zod.z.string().optional()
|
|
6564
|
+
// Optional title
|
|
6565
|
+
});
|
|
6347
6566
|
var FieldsetItemSchema = BaseFieldItemSchema.extend({
|
|
6348
6567
|
type: zod.z.literal("fieldset"),
|
|
6349
6568
|
title: zod.z.string(),
|
|
@@ -6363,6 +6582,53 @@ var RootFieldItemSchema = zod.z.union([
|
|
|
6363
6582
|
FieldsetItemSchema
|
|
6364
6583
|
]);
|
|
6365
6584
|
|
|
6585
|
+
// src/formatters/field.ts
|
|
6586
|
+
function formatInputField(item) {
|
|
6587
|
+
const details = [];
|
|
6588
|
+
const typeInfo = [
|
|
6589
|
+
item.value_type && `Type: ${item.value_type}`,
|
|
6590
|
+
`Required: ${item.is_required ? "Yes" : "No"}`
|
|
6591
|
+
].filter(Boolean).join(" | ");
|
|
6592
|
+
if (typeInfo) details.push({ text: typeInfo, style: "dim" });
|
|
6593
|
+
if (item.description)
|
|
6594
|
+
details.push({ text: item.description, style: "normal" });
|
|
6595
|
+
if (item.default_value)
|
|
6596
|
+
details.push({ text: `Default: ${item.default_value}`, style: "accent" });
|
|
6597
|
+
if (item.placeholder)
|
|
6598
|
+
details.push({ text: `Placeholder: ${item.placeholder}`, style: "dim" });
|
|
6599
|
+
if (item.depends_on && item.depends_on.length > 0) {
|
|
6600
|
+
details.push({
|
|
6601
|
+
text: `Depends on: ${item.depends_on.join(", ")}`,
|
|
6602
|
+
style: "warning"
|
|
6603
|
+
});
|
|
6604
|
+
}
|
|
6605
|
+
if (item.format)
|
|
6606
|
+
details.push({ text: `Format: ${item.format}`, style: "dim" });
|
|
6607
|
+
if (item.items)
|
|
6608
|
+
details.push({ text: `Items type: ${item.items.type}`, style: "dim" });
|
|
6609
|
+
return {
|
|
6610
|
+
title: item.title || item.key,
|
|
6611
|
+
key: item.key,
|
|
6612
|
+
description: item.description,
|
|
6613
|
+
details
|
|
6614
|
+
};
|
|
6615
|
+
}
|
|
6616
|
+
function formatInfoField(item) {
|
|
6617
|
+
return {
|
|
6618
|
+
title: item.title || "Info",
|
|
6619
|
+
key: item.key,
|
|
6620
|
+
description: item.description,
|
|
6621
|
+
details: [{ text: item.description, style: "normal" }]
|
|
6622
|
+
};
|
|
6623
|
+
}
|
|
6624
|
+
var rootFieldItemFormatter = {
|
|
6625
|
+
format: (item) => {
|
|
6626
|
+
if (item.type === "input_field") return formatInputField(item);
|
|
6627
|
+
if (item.type === "info_field") return formatInfoField(item);
|
|
6628
|
+
return { title: item.title || item.key, key: item.key, details: [] };
|
|
6629
|
+
}
|
|
6630
|
+
};
|
|
6631
|
+
|
|
6366
6632
|
// src/services/implementations.ts
|
|
6367
6633
|
async function fetchImplementationNeeds({
|
|
6368
6634
|
api,
|
|
@@ -6528,6 +6794,7 @@ var listActionInputFieldsPlugin = definePlugin(
|
|
|
6528
6794
|
itemType: "RootField",
|
|
6529
6795
|
inputSchema: ListActionInputFieldsInputSchema,
|
|
6530
6796
|
outputSchema: RootFieldItemSchema,
|
|
6797
|
+
formatter: rootFieldItemFormatter,
|
|
6531
6798
|
defaultPageSize: DEFAULT_PAGE_SIZE,
|
|
6532
6799
|
resolvers: {
|
|
6533
6800
|
app: appKeyResolver,
|
|
@@ -6536,10 +6803,7 @@ var listActionInputFieldsPlugin = definePlugin(
|
|
|
6536
6803
|
connection: connectionIdResolver,
|
|
6537
6804
|
inputs: inputsAllOptionalResolver
|
|
6538
6805
|
},
|
|
6539
|
-
handler: async ({
|
|
6540
|
-
sdk: sdk2,
|
|
6541
|
-
options
|
|
6542
|
-
}) => {
|
|
6806
|
+
handler: async ({ sdk: sdk2, options }) => {
|
|
6543
6807
|
const { api, getVersionedImplementationId } = sdk2.context;
|
|
6544
6808
|
const appKey = "app" in options ? options.app : options.appKey;
|
|
6545
6809
|
const actionKey = "action" in options ? options.action : options.actionKey;
|
|
@@ -6701,26 +6965,7 @@ var getActionInputFieldsSchemaPlugin = definePlugin(
|
|
|
6701
6965
|
}
|
|
6702
6966
|
})
|
|
6703
6967
|
);
|
|
6704
|
-
var InputFieldChoiceItemSchema =
|
|
6705
|
-
format: (item) => {
|
|
6706
|
-
const title = item.label || item.key || "Choice";
|
|
6707
|
-
const details = [];
|
|
6708
|
-
if (item.label && item.key && item.label !== item.key) {
|
|
6709
|
-
details.push({ text: `Key: ${item.key}`, style: "dim" });
|
|
6710
|
-
}
|
|
6711
|
-
if (item.sample && item.sample !== item.key) {
|
|
6712
|
-
details.push({ text: `Sample: ${item.sample}`, style: "dim" });
|
|
6713
|
-
}
|
|
6714
|
-
if (item.value && item.value !== item.key) {
|
|
6715
|
-
details.push({ text: `Value: ${item.value}`, style: "normal" });
|
|
6716
|
-
}
|
|
6717
|
-
return {
|
|
6718
|
-
title,
|
|
6719
|
-
key: item.key,
|
|
6720
|
-
details
|
|
6721
|
-
};
|
|
6722
|
-
}
|
|
6723
|
-
});
|
|
6968
|
+
var InputFieldChoiceItemSchema = NeedChoicesSchema;
|
|
6724
6969
|
var ListActionInputFieldChoicesDescription = "Get the available choices for a dynamic dropdown input field";
|
|
6725
6970
|
var ListActionInputFieldChoicesBaseSchema = zod.z.object({
|
|
6726
6971
|
connection: ConnectionPropertySchema.optional().describe(
|
|
@@ -6764,6 +7009,24 @@ var ListActionInputFieldChoicesInputSchema = zod.z.union([
|
|
|
6764
7009
|
ListActionInputFieldChoicesSchemaDeprecated
|
|
6765
7010
|
]).describe(ListActionInputFieldChoicesDescription);
|
|
6766
7011
|
|
|
7012
|
+
// src/formatters/inputFieldChoice.ts
|
|
7013
|
+
var inputFieldChoiceItemFormatter = {
|
|
7014
|
+
format: (item) => {
|
|
7015
|
+
const title = item.label || item.key || "Choice";
|
|
7016
|
+
const details = [];
|
|
7017
|
+
if (item.label && item.key && item.label !== item.key) {
|
|
7018
|
+
details.push({ text: `Key: ${item.key}`, style: "dim" });
|
|
7019
|
+
}
|
|
7020
|
+
if (item.sample && item.sample !== item.key) {
|
|
7021
|
+
details.push({ text: `Sample: ${item.sample}`, style: "dim" });
|
|
7022
|
+
}
|
|
7023
|
+
if (item.value && item.value !== item.key) {
|
|
7024
|
+
details.push({ text: `Value: ${item.value}`, style: "normal" });
|
|
7025
|
+
}
|
|
7026
|
+
return { title, key: item.key, details };
|
|
7027
|
+
}
|
|
7028
|
+
};
|
|
7029
|
+
|
|
6767
7030
|
// src/plugins/listActionInputFieldChoices/index.ts
|
|
6768
7031
|
function transformNeedChoicesToInputFieldChoiceItem(choice) {
|
|
6769
7032
|
return {
|
|
@@ -6781,6 +7044,7 @@ var listActionInputFieldChoicesPlugin = definePlugin(
|
|
|
6781
7044
|
itemType: "InputFieldChoice",
|
|
6782
7045
|
inputSchema: ListActionInputFieldChoicesInputSchema,
|
|
6783
7046
|
outputSchema: InputFieldChoiceItemSchema,
|
|
7047
|
+
formatter: inputFieldChoiceItemFormatter,
|
|
6784
7048
|
defaultPageSize: DEFAULT_PAGE_SIZE,
|
|
6785
7049
|
resolvers: {
|
|
6786
7050
|
app: appKeyResolver,
|
|
@@ -6790,10 +7054,7 @@ var listActionInputFieldChoicesPlugin = definePlugin(
|
|
|
6790
7054
|
inputField: inputFieldKeyResolver,
|
|
6791
7055
|
inputs: inputsAllOptionalResolver
|
|
6792
7056
|
},
|
|
6793
|
-
handler: async ({
|
|
6794
|
-
sdk: sdk2,
|
|
6795
|
-
options
|
|
6796
|
-
}) => {
|
|
7057
|
+
handler: async ({ sdk: sdk2, options }) => {
|
|
6797
7058
|
const { api, getVersionedImplementationId } = sdk2.context;
|
|
6798
7059
|
const appKey = "app" in options ? options.app : options.appKey;
|
|
6799
7060
|
const actionKey = "action" in options ? options.action : options.actionKey;
|
|
@@ -6890,11 +7151,13 @@ var listInputFieldsDeprecatedPlugin = definePlugin(
|
|
|
6890
7151
|
context: {
|
|
6891
7152
|
meta: {
|
|
6892
7153
|
listInputFields: {
|
|
6893
|
-
categories: ["action"
|
|
7154
|
+
categories: ["action"],
|
|
7155
|
+
deprecation: { message: "Use listActionInputFields instead." },
|
|
6894
7156
|
type: "list",
|
|
6895
7157
|
itemType: "RootField",
|
|
6896
7158
|
inputSchema: ListActionInputFieldsInputSchema,
|
|
6897
7159
|
outputSchema: RootFieldItemSchema,
|
|
7160
|
+
formatter: rootFieldItemFormatter,
|
|
6898
7161
|
defaultPageSize: DEFAULT_PAGE_SIZE
|
|
6899
7162
|
}
|
|
6900
7163
|
}
|
|
@@ -6907,11 +7170,15 @@ var listInputFieldChoicesDeprecatedPlugin = definePlugin(
|
|
|
6907
7170
|
context: {
|
|
6908
7171
|
meta: {
|
|
6909
7172
|
listInputFieldChoices: {
|
|
6910
|
-
categories: ["action"
|
|
7173
|
+
categories: ["action"],
|
|
7174
|
+
deprecation: {
|
|
7175
|
+
message: "Use listActionInputFieldChoices instead."
|
|
7176
|
+
},
|
|
6911
7177
|
type: "list",
|
|
6912
7178
|
itemType: "InputFieldChoiceItem",
|
|
6913
7179
|
inputSchema: ListActionInputFieldChoicesInputSchema,
|
|
6914
7180
|
outputSchema: InputFieldChoiceItemSchema,
|
|
7181
|
+
formatter: inputFieldChoiceItemFormatter,
|
|
6915
7182
|
defaultPageSize: DEFAULT_PAGE_SIZE
|
|
6916
7183
|
}
|
|
6917
7184
|
}
|
|
@@ -6924,7 +7191,8 @@ var getInputFieldsSchemaDeprecatedPlugin = definePlugin(
|
|
|
6924
7191
|
context: {
|
|
6925
7192
|
meta: {
|
|
6926
7193
|
getInputFieldsSchema: {
|
|
6927
|
-
categories: ["action"
|
|
7194
|
+
categories: ["action"],
|
|
7195
|
+
deprecation: { message: "Use getActionInputFieldsSchema instead." },
|
|
6928
7196
|
type: "function",
|
|
6929
7197
|
inputSchema: GetActionInputFieldsSchemaInputSchema
|
|
6930
7198
|
}
|
|
@@ -6988,6 +7256,7 @@ var tablesDefaults = {
|
|
|
6988
7256
|
var listTablesPlugin = definePlugin(
|
|
6989
7257
|
(sdk) => createPaginatedPluginMethod(sdk, {
|
|
6990
7258
|
...tablesDefaults,
|
|
7259
|
+
...zapierPagination,
|
|
6991
7260
|
name: "listTables",
|
|
6992
7261
|
type: "list",
|
|
6993
7262
|
itemType: "Table",
|
|
@@ -7043,8 +7312,7 @@ var listTablesPlugin = definePlugin(
|
|
|
7043
7312
|
data: response.data.map(transformTableItem),
|
|
7044
7313
|
links: response.links
|
|
7045
7314
|
};
|
|
7046
|
-
}
|
|
7047
|
-
extractCursor: (response) => extractCursor(response.links)
|
|
7315
|
+
}
|
|
7048
7316
|
})
|
|
7049
7317
|
);
|
|
7050
7318
|
var GetTableApiResponseSchema = zod.z.object({
|
|
@@ -7147,6 +7415,15 @@ var createTablePlugin = definePlugin(
|
|
|
7147
7415
|
})
|
|
7148
7416
|
);
|
|
7149
7417
|
|
|
7418
|
+
// src/formatters/tableField.ts
|
|
7419
|
+
var tableFieldItemFormatter = {
|
|
7420
|
+
format: (item) => ({
|
|
7421
|
+
title: item.name,
|
|
7422
|
+
id: item.id,
|
|
7423
|
+
details: [{ text: `Type: ${item.type}`, style: "dim" }]
|
|
7424
|
+
})
|
|
7425
|
+
};
|
|
7426
|
+
|
|
7150
7427
|
// src/plugins/tables/listTableFields/index.ts
|
|
7151
7428
|
var listTableFieldsPlugin = definePlugin(
|
|
7152
7429
|
(sdk) => createPluginMethod(sdk, {
|
|
@@ -7156,6 +7433,7 @@ var listTableFieldsPlugin = definePlugin(
|
|
|
7156
7433
|
itemType: "Field",
|
|
7157
7434
|
inputSchema: ListTableFieldsOptionsInputSchema,
|
|
7158
7435
|
outputSchema: FieldItemSchema,
|
|
7436
|
+
formatter: tableFieldItemFormatter,
|
|
7159
7437
|
resolvers: { table: tableIdResolver },
|
|
7160
7438
|
handler: async ({ sdk: sdk2, options }) => {
|
|
7161
7439
|
const { api } = sdk2.context;
|
|
@@ -7228,6 +7506,7 @@ var createTableFieldsPlugin = definePlugin(
|
|
|
7228
7506
|
returnType: "FieldItem[]",
|
|
7229
7507
|
inputSchema: CreateTableFieldsOptionsInputSchema,
|
|
7230
7508
|
outputSchema: FieldItemSchema,
|
|
7509
|
+
formatter: tableFieldItemFormatter,
|
|
7231
7510
|
resolvers: { table: tableIdResolver, fields: tableFieldsResolver },
|
|
7232
7511
|
handler: async ({ sdk: sdk2, options }) => {
|
|
7233
7512
|
const tableId = "table" in options ? options.table : options.tableId;
|
|
@@ -7306,21 +7585,13 @@ var RecordApiItemSchema = zod.z.object({
|
|
|
7306
7585
|
is_source_record: zod.z.boolean().nullable().optional(),
|
|
7307
7586
|
deleted_at: zod.z.string().nullable().optional()
|
|
7308
7587
|
});
|
|
7309
|
-
var
|
|
7588
|
+
var RecordItemSchema = zod.z.object({
|
|
7310
7589
|
id: zod.z.string(),
|
|
7311
7590
|
data: zod.z.record(zod.z.string(), zod.z.unknown()),
|
|
7312
7591
|
created_at: zod.z.string(),
|
|
7313
7592
|
edited_at: zod.z.string(),
|
|
7314
7593
|
deleted_at: zod.z.string().nullable().optional()
|
|
7315
7594
|
});
|
|
7316
|
-
var RecordItemSchema = withFormatter(RecordItemSchemaBase, {
|
|
7317
|
-
format: (item) => ({
|
|
7318
|
-
title: `Record ${item.id}`,
|
|
7319
|
-
id: item.id,
|
|
7320
|
-
data: item.data,
|
|
7321
|
-
details: []
|
|
7322
|
-
})
|
|
7323
|
-
});
|
|
7324
7595
|
var GetTableRecordApiResponseSchema = zod.z.object({
|
|
7325
7596
|
data: RecordApiItemSchema
|
|
7326
7597
|
});
|
|
@@ -7344,9 +7615,9 @@ var tableRecordFormatter = {
|
|
|
7344
7615
|
if (context) return context;
|
|
7345
7616
|
const hasFieldIds = Object.keys(item.data).some(isFieldId);
|
|
7346
7617
|
if (!hasFieldIds) return {};
|
|
7347
|
-
const
|
|
7348
|
-
|
|
7349
|
-
});
|
|
7618
|
+
const table = params.table ?? params.tableId;
|
|
7619
|
+
if (!table) return {};
|
|
7620
|
+
const { data: fields } = await sdk.listTableFields({ table });
|
|
7350
7621
|
return Object.fromEntries(fields.map((f) => [f.id, f.name]));
|
|
7351
7622
|
},
|
|
7352
7623
|
format: (item, fieldLabels) => ({
|
|
@@ -7471,10 +7742,7 @@ var listTableRecordsPlugin = definePlugin(
|
|
|
7471
7742
|
sort: tableSortResolver
|
|
7472
7743
|
},
|
|
7473
7744
|
formatter: tableRecordFormatter,
|
|
7474
|
-
handler: async ({
|
|
7475
|
-
sdk: sdk2,
|
|
7476
|
-
options
|
|
7477
|
-
}) => {
|
|
7745
|
+
handler: async ({ sdk: sdk2, options }) => {
|
|
7478
7746
|
const { api } = sdk2.context;
|
|
7479
7747
|
const tableId = "table" in options ? options.table : options.tableId;
|
|
7480
7748
|
const translator = await createFieldKeyTranslator({
|
|
@@ -7752,11 +8020,12 @@ var requestPlugin = definePlugin(
|
|
|
7752
8020
|
(sdk) => createPluginMethod(sdk, {
|
|
7753
8021
|
name: "request",
|
|
7754
8022
|
packages: ["cli", "mcp"],
|
|
7755
|
-
categories: ["http"
|
|
8023
|
+
categories: ["http"],
|
|
8024
|
+
deprecation: { message: "Use fetch() instead." },
|
|
7756
8025
|
returnType: "Response",
|
|
7757
8026
|
inputSchema: RelayRequestSchema,
|
|
7758
8027
|
handler: async ({ sdk: sdk2, options }) => {
|
|
7759
|
-
|
|
8028
|
+
logDeprecation2("request() is deprecated. Use fetch() instead.");
|
|
7760
8029
|
const {
|
|
7761
8030
|
url,
|
|
7762
8031
|
method,
|
|
@@ -7976,7 +8245,7 @@ async function listAppsForSlugsPage({
|
|
|
7976
8245
|
data: implementationsEnvelope.results.map(
|
|
7977
8246
|
normalizeImplementationMetaToAppItem
|
|
7978
8247
|
),
|
|
7979
|
-
nextCursor:
|
|
8248
|
+
nextCursor: implementationsEnvelope.next ? extractCursorFromUrl(implementationsEnvelope.next) : void 0
|
|
7980
8249
|
};
|
|
7981
8250
|
}
|
|
7982
8251
|
function findManifestEntry({
|
|
@@ -8397,7 +8666,7 @@ function createConsoleTransport() {
|
|
|
8397
8666
|
return {
|
|
8398
8667
|
async emit(subject, event) {
|
|
8399
8668
|
try {
|
|
8400
|
-
console.
|
|
8669
|
+
console.error(
|
|
8401
8670
|
"[SDK Telemetry]",
|
|
8402
8671
|
JSON.stringify({ subject, properties: event }, null, 2)
|
|
8403
8672
|
);
|
|
@@ -8606,6 +8875,35 @@ function buildMethodCalledEvent(data, context = {}) {
|
|
|
8606
8875
|
};
|
|
8607
8876
|
}
|
|
8608
8877
|
|
|
8878
|
+
// src/plugins/eventEmission/event-emission-hook.ts
|
|
8879
|
+
function computeArgumentCount(args) {
|
|
8880
|
+
if (args.length === 1) {
|
|
8881
|
+
const arg0 = args[0];
|
|
8882
|
+
if (arg0 !== null && typeof arg0 === "object" && !Array.isArray(arg0) && Object.getPrototypeOf(arg0) === Object.prototype) {
|
|
8883
|
+
return Object.keys(arg0).length;
|
|
8884
|
+
}
|
|
8885
|
+
}
|
|
8886
|
+
return args.filter((a) => a !== void 0).length;
|
|
8887
|
+
}
|
|
8888
|
+
function makeMethodEndHook(emitMethodCalled) {
|
|
8889
|
+
return ({ methodName, args, isPaginated, depth, durationMs, error }) => {
|
|
8890
|
+
if (depth > 0) return;
|
|
8891
|
+
const metadata = getMethodMetadata();
|
|
8892
|
+
emitMethodCalled({
|
|
8893
|
+
method_name: methodName,
|
|
8894
|
+
execution_duration_ms: durationMs,
|
|
8895
|
+
success_flag: !error,
|
|
8896
|
+
error_message: error?.message ?? null,
|
|
8897
|
+
error_type: error?.constructor.name ?? null,
|
|
8898
|
+
argument_count: computeArgumentCount(args),
|
|
8899
|
+
is_paginated: isPaginated,
|
|
8900
|
+
selected_api: metadata?.selectedApi ?? null,
|
|
8901
|
+
operation_type: metadata?.operationType ?? null,
|
|
8902
|
+
operation_key: metadata?.operationKey ?? null
|
|
8903
|
+
});
|
|
8904
|
+
};
|
|
8905
|
+
}
|
|
8906
|
+
|
|
8609
8907
|
// src/plugins/eventEmission/index.ts
|
|
8610
8908
|
var TELEMETRY_EMIT_TIMEOUT_MS = 300;
|
|
8611
8909
|
var registeredListeners = {};
|
|
@@ -8736,6 +9034,8 @@ var eventEmissionPlugin = definePlugin(
|
|
|
8736
9034
|
}
|
|
8737
9035
|
}
|
|
8738
9036
|
if (!config.enabled) {
|
|
9037
|
+
const noopEmitMethodCalled = () => {
|
|
9038
|
+
};
|
|
8739
9039
|
return {
|
|
8740
9040
|
context: {
|
|
8741
9041
|
eventEmission: {
|
|
@@ -8753,12 +9053,13 @@ var eventEmissionPlugin = definePlugin(
|
|
|
8753
9053
|
visitor_id: null,
|
|
8754
9054
|
correlation_id: null
|
|
8755
9055
|
}),
|
|
8756
|
-
emitMethodCalled: () => {
|
|
8757
|
-
},
|
|
8758
9056
|
flush: async () => {
|
|
8759
9057
|
},
|
|
8760
9058
|
close: async () => {
|
|
8761
9059
|
}
|
|
9060
|
+
},
|
|
9061
|
+
hooks: {
|
|
9062
|
+
onMethodEnd: makeMethodEndHook(noopEmitMethodCalled)
|
|
8762
9063
|
}
|
|
8763
9064
|
}
|
|
8764
9065
|
};
|
|
@@ -8929,6 +9230,20 @@ var eventEmissionPlugin = definePlugin(
|
|
|
8929
9230
|
);
|
|
8930
9231
|
removeExistingListeners();
|
|
8931
9232
|
};
|
|
9233
|
+
const emitMethodCalled = (data) => {
|
|
9234
|
+
const event = {
|
|
9235
|
+
...buildMethodCalledEvent(data),
|
|
9236
|
+
call_context: config.callContext ?? "sdk"
|
|
9237
|
+
};
|
|
9238
|
+
trackEmission(
|
|
9239
|
+
silentEmit(
|
|
9240
|
+
transport,
|
|
9241
|
+
METHOD_CALLED_EVENT_SUBJECT,
|
|
9242
|
+
event,
|
|
9243
|
+
getUserContext
|
|
9244
|
+
)
|
|
9245
|
+
);
|
|
9246
|
+
};
|
|
8932
9247
|
return {
|
|
8933
9248
|
context: {
|
|
8934
9249
|
eventEmission: {
|
|
@@ -8940,22 +9255,11 @@ var eventEmissionPlugin = definePlugin(
|
|
|
8940
9255
|
);
|
|
8941
9256
|
},
|
|
8942
9257
|
createBaseEvent: createBaseEventHelper,
|
|
8943
|
-
emitMethodCalled: (data) => {
|
|
8944
|
-
const event = {
|
|
8945
|
-
...buildMethodCalledEvent(data),
|
|
8946
|
-
call_context: config.callContext ?? "sdk"
|
|
8947
|
-
};
|
|
8948
|
-
trackEmission(
|
|
8949
|
-
silentEmit(
|
|
8950
|
-
transport,
|
|
8951
|
-
METHOD_CALLED_EVENT_SUBJECT,
|
|
8952
|
-
event,
|
|
8953
|
-
getUserContext
|
|
8954
|
-
)
|
|
8955
|
-
);
|
|
8956
|
-
},
|
|
8957
9258
|
flush,
|
|
8958
9259
|
close
|
|
9260
|
+
},
|
|
9261
|
+
hooks: {
|
|
9262
|
+
onMethodEnd: makeMethodEndHook(emitMethodCalled)
|
|
8959
9263
|
}
|
|
8960
9264
|
}
|
|
8961
9265
|
};
|
|
@@ -8967,78 +9271,22 @@ function createOptionsPlugin(options) {
|
|
|
8967
9271
|
return () => ({ context: { options } });
|
|
8968
9272
|
}
|
|
8969
9273
|
function createSdk() {
|
|
8970
|
-
|
|
8971
|
-
|
|
8972
|
-
|
|
8973
|
-
|
|
8974
|
-
const registryCache = /* @__PURE__ */ new Map();
|
|
8975
|
-
const sdk = {
|
|
8976
|
-
...properties,
|
|
8977
|
-
get context() {
|
|
8978
|
-
return frozenContext;
|
|
8979
|
-
},
|
|
8980
|
-
getContext: () => frozenContext,
|
|
8981
|
-
// runtime compat shim, not in types
|
|
8982
|
-
getRegistry(options) {
|
|
8983
|
-
const cacheKey = options?.package ?? "__all__";
|
|
8984
|
-
if (!registryCache.has(cacheKey)) {
|
|
8985
|
-
registryCache.set(
|
|
8986
|
-
cacheKey,
|
|
8987
|
-
buildRegistry({
|
|
8988
|
-
sdk,
|
|
8989
|
-
meta: frozenContext.meta,
|
|
8990
|
-
packageFilter: options?.package
|
|
8991
|
-
})
|
|
8992
|
-
);
|
|
8993
|
-
}
|
|
8994
|
-
return registryCache.get(cacheKey);
|
|
8995
|
-
},
|
|
8996
|
-
addPlugin(plugin, options) {
|
|
8997
|
-
const pluginResult = plugin({
|
|
8998
|
-
...properties,
|
|
8999
|
-
context: frozenContext
|
|
9000
|
-
});
|
|
9001
|
-
const { context: pluginContext, ...pluginProperties } = pluginResult;
|
|
9002
|
-
const { meta: pluginMeta, ...pluginContextRest } = pluginContext ?? {};
|
|
9003
|
-
const existingProperties = properties;
|
|
9004
|
-
const existingContext = context;
|
|
9005
|
-
const existingMeta = context.meta ?? {};
|
|
9006
|
-
const collisions = [];
|
|
9007
|
-
for (const key of Object.keys(pluginProperties)) {
|
|
9008
|
-
if (key in existingProperties) collisions.push(`method "${key}"`);
|
|
9009
|
-
}
|
|
9010
|
-
for (const key of Object.keys(pluginContextRest)) {
|
|
9011
|
-
if (key in existingContext) collisions.push(`context.${key}`);
|
|
9012
|
-
}
|
|
9013
|
-
if (collisions.length > 0 && !options?.override) {
|
|
9014
|
-
const name = plugin.name || "anonymous plugin";
|
|
9015
|
-
console.warn(
|
|
9016
|
-
`[zapier-sdk] Skipping "${name}" \u2014 duplicate registration of: ${collisions.join(", ")}. If the duplicate is intentional, pass { override: true } to addPlugin or wrap with composePlugins(...). Otherwise rename the method or remove the duplicate.`
|
|
9017
|
-
);
|
|
9018
|
-
return buildSdk(properties, context);
|
|
9019
|
-
}
|
|
9020
|
-
const mergedProperties = { ...properties, ...pluginProperties };
|
|
9021
|
-
const mergedContext = {
|
|
9022
|
-
...context,
|
|
9023
|
-
...pluginContextRest,
|
|
9024
|
-
meta: { ...existingMeta, ...pluginMeta ?? {} }
|
|
9025
|
-
};
|
|
9026
|
-
return buildSdk(
|
|
9027
|
-
mergedProperties,
|
|
9028
|
-
mergedContext
|
|
9029
|
-
);
|
|
9030
|
-
}
|
|
9031
|
-
};
|
|
9032
|
-
return sdk;
|
|
9274
|
+
logDeprecation2(
|
|
9275
|
+
"createSdk() is deprecated. Build SDKs with createPluginStack().use(...).toSdk() instead. The chain pattern shares plugin closures (and their state) across derived SDKs in ways that are rarely what callers expect; stacks produce fresh closures per .toSdk() call."
|
|
9276
|
+
);
|
|
9277
|
+
return withDeprecatedAddPlugin(createZapierCoreStack().toSdk());
|
|
9033
9278
|
}
|
|
9034
9279
|
function createZapierSdkWithoutRegistry(options = {}) {
|
|
9035
|
-
|
|
9280
|
+
logDeprecation2(
|
|
9036
9281
|
"createZapierSdkWithoutRegistry is deprecated; use createZapierSdk instead. getRegistry is now available on every sdk."
|
|
9037
9282
|
);
|
|
9038
9283
|
return createZapierSdk(options);
|
|
9039
9284
|
}
|
|
9285
|
+
function createZapierSdkStack(options = {}) {
|
|
9286
|
+
return createZapierCoreStack().use(createOptionsPlugin(options)).use(eventEmissionPlugin).use(apiPlugin).use(manifestPlugin).use(capabilitiesPlugin).use(connectionsPlugin).use(listAppsPlugin).use(getAppPlugin).use(listConnectionsPlugin).use(getConnectionPlugin).use(findFirstConnectionPlugin).use(findUniqueConnectionPlugin).use(listActionsPlugin).use(getActionPlugin).use(listActionInputFieldsPlugin).use(getActionInputFieldsSchemaPlugin).use(listActionInputFieldChoicesPlugin).use(listInputFieldsDeprecatedPlugin).use(getInputFieldsSchemaDeprecatedPlugin).use(listInputFieldChoicesDeprecatedPlugin).use(runActionPlugin).use(listAuthenticationsPlugin).use(getAuthenticationPlugin).use(findFirstAuthenticationPlugin).use(findUniqueAuthenticationPlugin).use(listClientCredentialsPlugin).use(createClientCredentialsPlugin).use(deleteClientCredentialsPlugin).use(fetchPlugin).use(requestPlugin).use(listTablesPlugin).use(getTablePlugin).use(deleteTablePlugin).use(createTablePlugin).use(listTableFieldsPlugin).use(createTableFieldsPlugin).use(deleteTableFieldsPlugin).use(listTableRecordsPlugin).use(getTableRecordPlugin).use(createTableRecordsPlugin).use(deleteTableRecordsPlugin).use(updateTableRecordsPlugin).use(appsPlugin).use(getProfilePlugin);
|
|
9287
|
+
}
|
|
9040
9288
|
function createZapierSdk(options = {}) {
|
|
9041
|
-
return
|
|
9289
|
+
return withDeprecatedAddPlugin(createZapierSdkStack(options).toSdk());
|
|
9042
9290
|
}
|
|
9043
9291
|
var TriggerInboxStatusSchema = zod.z.union([
|
|
9044
9292
|
zod.z.enum([
|
|
@@ -9070,7 +9318,7 @@ var TriggerSubscriptionApiSchema = zod.z.object({
|
|
|
9070
9318
|
action_key: zod.z.string(),
|
|
9071
9319
|
inputs: zod.z.record(zod.z.string(), zod.z.unknown())
|
|
9072
9320
|
});
|
|
9073
|
-
var
|
|
9321
|
+
var TriggerInboxItemSchema = zod.z.object({
|
|
9074
9322
|
id: zod.z.string(),
|
|
9075
9323
|
created_at: zod.z.string(),
|
|
9076
9324
|
name: zod.z.string().nullable(),
|
|
@@ -9079,40 +9327,6 @@ var TriggerInboxItemSchemaBase = zod.z.object({
|
|
|
9079
9327
|
notification_url: zod.z.string().nullable(),
|
|
9080
9328
|
subscription: TriggerSubscriptionApiSchema
|
|
9081
9329
|
});
|
|
9082
|
-
var TriggerInboxItemSchema = withFormatter(
|
|
9083
|
-
TriggerInboxItemSchemaBase,
|
|
9084
|
-
{
|
|
9085
|
-
format: (item) => {
|
|
9086
|
-
const details = [
|
|
9087
|
-
{
|
|
9088
|
-
text: `Status: ${item.status}`,
|
|
9089
|
-
style: item.status === "active" ? "accent" : "dim"
|
|
9090
|
-
},
|
|
9091
|
-
{
|
|
9092
|
-
text: `Subscription: ${item.subscription.app_key} / ${item.subscription.action_key}`,
|
|
9093
|
-
style: "dim"
|
|
9094
|
-
}
|
|
9095
|
-
];
|
|
9096
|
-
if (item.paused_reason) {
|
|
9097
|
-
details.push({
|
|
9098
|
-
text: `Paused reason: ${item.paused_reason}`,
|
|
9099
|
-
style: "warning"
|
|
9100
|
-
});
|
|
9101
|
-
}
|
|
9102
|
-
if (item.notification_url) {
|
|
9103
|
-
details.push({
|
|
9104
|
-
text: `Notify: ${item.notification_url}`,
|
|
9105
|
-
style: "dim"
|
|
9106
|
-
});
|
|
9107
|
-
}
|
|
9108
|
-
return {
|
|
9109
|
-
title: item.name ?? `Trigger Inbox ${item.id}`,
|
|
9110
|
-
id: item.id,
|
|
9111
|
-
details
|
|
9112
|
-
};
|
|
9113
|
-
}
|
|
9114
|
-
}
|
|
9115
|
-
);
|
|
9116
9330
|
|
|
9117
9331
|
// src/plugins/triggers/createTriggerInbox/schemas.ts
|
|
9118
9332
|
var CreateTriggerInboxDescription = "Create a new trigger inbox subscription. Always creates a new inbox; use ensureTriggerInbox for get-or-create on a stable name.";
|
|
@@ -9131,6 +9345,39 @@ var CreateTriggerInboxSchema = zod.z.object({
|
|
|
9131
9345
|
notificationUrl: zod.z.string().url().optional().describe("Webhook URL to POST to when new messages arrive")
|
|
9132
9346
|
}).describe(CreateTriggerInboxDescription);
|
|
9133
9347
|
|
|
9348
|
+
// src/formatters/triggerInbox.ts
|
|
9349
|
+
var triggerInboxItemFormatter = {
|
|
9350
|
+
format: (item) => {
|
|
9351
|
+
const details = [
|
|
9352
|
+
{
|
|
9353
|
+
text: `Status: ${item.status}`,
|
|
9354
|
+
style: item.status === "active" ? "accent" : "dim"
|
|
9355
|
+
},
|
|
9356
|
+
{
|
|
9357
|
+
text: `Subscription: ${item.subscription.app_key} / ${item.subscription.action_key}`,
|
|
9358
|
+
style: "dim"
|
|
9359
|
+
}
|
|
9360
|
+
];
|
|
9361
|
+
if (item.paused_reason) {
|
|
9362
|
+
details.push({
|
|
9363
|
+
text: `Paused reason: ${item.paused_reason}`,
|
|
9364
|
+
style: "warning"
|
|
9365
|
+
});
|
|
9366
|
+
}
|
|
9367
|
+
if (item.notification_url) {
|
|
9368
|
+
details.push({
|
|
9369
|
+
text: `Notify: ${item.notification_url}`,
|
|
9370
|
+
style: "dim"
|
|
9371
|
+
});
|
|
9372
|
+
}
|
|
9373
|
+
return {
|
|
9374
|
+
title: item.name ?? `Trigger Inbox ${item.id}`,
|
|
9375
|
+
id: item.id,
|
|
9376
|
+
details
|
|
9377
|
+
};
|
|
9378
|
+
}
|
|
9379
|
+
};
|
|
9380
|
+
|
|
9134
9381
|
// src/plugins/triggers/shared.ts
|
|
9135
9382
|
var triggersDefaults = {
|
|
9136
9383
|
categories: ["trigger"],
|
|
@@ -9179,6 +9426,7 @@ var createTriggerInboxPlugin = definePlugin(
|
|
|
9179
9426
|
itemType: "TriggerInbox",
|
|
9180
9427
|
inputSchema: CreateTriggerInboxSchema,
|
|
9181
9428
|
outputSchema: TriggerInboxItemSchema,
|
|
9429
|
+
formatter: triggerInboxItemFormatter,
|
|
9182
9430
|
// actionKeyResolver and inputsResolver depend on actionType, which is
|
|
9183
9431
|
// always "read" for triggers. Pin it as a constant resolver so it's
|
|
9184
9432
|
// seeded into resolvedParams without polluting the user-facing schema
|
|
@@ -9272,6 +9520,7 @@ var ensureTriggerInboxPlugin = definePlugin(
|
|
|
9272
9520
|
itemType: "TriggerInbox",
|
|
9273
9521
|
inputSchema: EnsureTriggerInboxSchema,
|
|
9274
9522
|
outputSchema: TriggerInboxItemSchema,
|
|
9523
|
+
formatter: triggerInboxItemFormatter,
|
|
9275
9524
|
// actionKeyResolver and inputsResolver depend on actionType, which is
|
|
9276
9525
|
// always "read" for triggers. Pin it as a constant resolver so it's
|
|
9277
9526
|
// seeded into resolvedParams without polluting the user-facing schema.
|
|
@@ -9356,24 +9605,16 @@ var ListTriggerInboxesApiResponseSchema = zod.z.object({
|
|
|
9356
9605
|
});
|
|
9357
9606
|
|
|
9358
9607
|
// src/plugins/triggers/listTriggerInboxes/index.ts
|
|
9359
|
-
function extractNextOffset(next) {
|
|
9360
|
-
if (!next) return void 0;
|
|
9361
|
-
try {
|
|
9362
|
-
const url = new URL(next);
|
|
9363
|
-
const offset = url.searchParams.get("offset");
|
|
9364
|
-
return offset || void 0;
|
|
9365
|
-
} catch {
|
|
9366
|
-
return void 0;
|
|
9367
|
-
}
|
|
9368
|
-
}
|
|
9369
9608
|
var listTriggerInboxesPlugin = definePlugin(
|
|
9370
9609
|
(sdk) => createPaginatedPluginMethod(sdk, {
|
|
9371
9610
|
...triggersDefaults,
|
|
9611
|
+
...zapierPagination,
|
|
9372
9612
|
name: "listTriggerInboxes",
|
|
9373
9613
|
type: "list",
|
|
9374
9614
|
itemType: "TriggerInbox",
|
|
9375
9615
|
inputSchema: ListTriggerInboxesSchema,
|
|
9376
9616
|
outputSchema: TriggerInboxItemSchema,
|
|
9617
|
+
formatter: triggerInboxItemFormatter,
|
|
9377
9618
|
defaultPageSize: DEFAULT_PAGE_SIZE,
|
|
9378
9619
|
handler: async ({ sdk: sdk2, options }) => {
|
|
9379
9620
|
const { api } = sdk2.context;
|
|
@@ -9399,8 +9640,7 @@ var listTriggerInboxesPlugin = definePlugin(
|
|
|
9399
9640
|
data: response.results,
|
|
9400
9641
|
next: response.next ?? null
|
|
9401
9642
|
};
|
|
9402
|
-
}
|
|
9403
|
-
extractCursor: (response) => extractNextOffset(response.next)
|
|
9643
|
+
}
|
|
9404
9644
|
})
|
|
9405
9645
|
);
|
|
9406
9646
|
var GetTriggerInboxSchema = zod.z.object({
|
|
@@ -9416,6 +9656,7 @@ var getTriggerInboxPlugin = definePlugin(
|
|
|
9416
9656
|
itemType: "TriggerInbox",
|
|
9417
9657
|
inputSchema: GetTriggerInboxSchema,
|
|
9418
9658
|
outputSchema: TriggerInboxItemSchema,
|
|
9659
|
+
formatter: triggerInboxItemFormatter,
|
|
9419
9660
|
resolvers: { inbox: triggerInboxResolver },
|
|
9420
9661
|
handler: async ({ sdk: sdk2, options }) => {
|
|
9421
9662
|
const { inbox } = options;
|
|
@@ -9450,6 +9691,7 @@ var updateTriggerInboxPlugin = definePlugin(
|
|
|
9450
9691
|
itemType: "TriggerInbox",
|
|
9451
9692
|
inputSchema: UpdateTriggerInboxSchema,
|
|
9452
9693
|
outputSchema: TriggerInboxItemSchema,
|
|
9694
|
+
formatter: triggerInboxItemFormatter,
|
|
9453
9695
|
resolvers: { inbox: triggerInboxResolver },
|
|
9454
9696
|
handler: async ({ sdk: sdk2, options }) => {
|
|
9455
9697
|
const { inbox, notificationUrl } = options;
|
|
@@ -9486,6 +9728,7 @@ var deleteTriggerInboxPlugin = definePlugin(
|
|
|
9486
9728
|
itemType: "TriggerInbox",
|
|
9487
9729
|
inputSchema: DeleteTriggerInboxSchema,
|
|
9488
9730
|
outputSchema: TriggerInboxItemSchema,
|
|
9731
|
+
formatter: triggerInboxItemFormatter,
|
|
9489
9732
|
resolvers: { inbox: triggerInboxResolver },
|
|
9490
9733
|
confirm: "delete",
|
|
9491
9734
|
handler: async ({ sdk: sdk2, options }) => {
|
|
@@ -9519,6 +9762,7 @@ var pauseTriggerInboxPlugin = definePlugin(
|
|
|
9519
9762
|
itemType: "TriggerInbox",
|
|
9520
9763
|
inputSchema: PauseTriggerInboxSchema,
|
|
9521
9764
|
outputSchema: TriggerInboxItemSchema,
|
|
9765
|
+
formatter: triggerInboxItemFormatter,
|
|
9522
9766
|
resolvers: { inbox: triggerInboxResolver },
|
|
9523
9767
|
handler: async ({ sdk: sdk2, options }) => {
|
|
9524
9768
|
const { inbox } = options;
|
|
@@ -9551,6 +9795,7 @@ var resumeTriggerInboxPlugin = definePlugin(
|
|
|
9551
9795
|
itemType: "TriggerInbox",
|
|
9552
9796
|
inputSchema: ResumeTriggerInboxSchema,
|
|
9553
9797
|
outputSchema: TriggerInboxItemSchema,
|
|
9798
|
+
formatter: triggerInboxItemFormatter,
|
|
9554
9799
|
resolvers: { inbox: triggerInboxResolver },
|
|
9555
9800
|
handler: async ({ sdk: sdk2, options }) => {
|
|
9556
9801
|
const { inbox } = options;
|
|
@@ -9576,78 +9821,15 @@ var TriggerMessageAttributesSchema = zod.z.object({
|
|
|
9576
9821
|
error_message: zod.z.string().nullable(),
|
|
9577
9822
|
possible_duplicate_data: zod.z.boolean()
|
|
9578
9823
|
});
|
|
9579
|
-
var
|
|
9824
|
+
var TriggerMessageItemSchema = zod.z.object({
|
|
9580
9825
|
id: zod.z.string(),
|
|
9581
9826
|
created_at: zod.z.string(),
|
|
9582
9827
|
status: TriggerMessageStatusSchema,
|
|
9583
9828
|
message_attributes: TriggerMessageAttributesSchema
|
|
9584
9829
|
});
|
|
9585
|
-
var
|
|
9586
|
-
TriggerMessageItemSchemaBase,
|
|
9587
|
-
{
|
|
9588
|
-
format: (item) => {
|
|
9589
|
-
const details = [
|
|
9590
|
-
{ text: `Status: ${item.status}`, style: "dim" },
|
|
9591
|
-
{
|
|
9592
|
-
text: `Lease count: ${item.message_attributes.lease_count}`,
|
|
9593
|
-
style: "dim"
|
|
9594
|
-
}
|
|
9595
|
-
];
|
|
9596
|
-
if (item.message_attributes.error_message) {
|
|
9597
|
-
details.push({
|
|
9598
|
-
text: `Error: ${item.message_attributes.error_message}`,
|
|
9599
|
-
style: "warning"
|
|
9600
|
-
});
|
|
9601
|
-
}
|
|
9602
|
-
if (item.message_attributes.possible_duplicate_data) {
|
|
9603
|
-
details.push({
|
|
9604
|
-
text: "Possible duplicate data",
|
|
9605
|
-
style: "warning"
|
|
9606
|
-
});
|
|
9607
|
-
}
|
|
9608
|
-
return {
|
|
9609
|
-
title: `Message ${item.id}`,
|
|
9610
|
-
id: item.id,
|
|
9611
|
-
details
|
|
9612
|
-
};
|
|
9613
|
-
}
|
|
9614
|
-
}
|
|
9615
|
-
);
|
|
9616
|
-
var LeasedTriggerMessageItemSchemaBase = TriggerMessageItemSchemaBase.extend({
|
|
9830
|
+
var LeasedTriggerMessageItemSchema = TriggerMessageItemSchema.extend({
|
|
9617
9831
|
payload: zod.z.record(zod.z.string(), zod.z.unknown())
|
|
9618
9832
|
});
|
|
9619
|
-
var LeasedTriggerMessageItemSchema = withFormatter(
|
|
9620
|
-
LeasedTriggerMessageItemSchemaBase,
|
|
9621
|
-
{
|
|
9622
|
-
format: (item) => {
|
|
9623
|
-
const details = [
|
|
9624
|
-
{ text: `Status: ${item.status}`, style: "dim" },
|
|
9625
|
-
{
|
|
9626
|
-
text: `Lease count: ${item.message_attributes.lease_count}`,
|
|
9627
|
-
style: "dim"
|
|
9628
|
-
}
|
|
9629
|
-
];
|
|
9630
|
-
if (item.message_attributes.error_message) {
|
|
9631
|
-
details.push({
|
|
9632
|
-
text: `Error: ${item.message_attributes.error_message}`,
|
|
9633
|
-
style: "warning"
|
|
9634
|
-
});
|
|
9635
|
-
}
|
|
9636
|
-
if (item.message_attributes.possible_duplicate_data) {
|
|
9637
|
-
details.push({
|
|
9638
|
-
text: "Possible duplicate data",
|
|
9639
|
-
style: "warning"
|
|
9640
|
-
});
|
|
9641
|
-
}
|
|
9642
|
-
return {
|
|
9643
|
-
title: `Message ${item.id}`,
|
|
9644
|
-
id: item.id,
|
|
9645
|
-
data: item.payload,
|
|
9646
|
-
details
|
|
9647
|
-
};
|
|
9648
|
-
}
|
|
9649
|
-
}
|
|
9650
|
-
);
|
|
9651
9833
|
|
|
9652
9834
|
// src/plugins/triggers/listTriggerInboxMessages/schemas.ts
|
|
9653
9835
|
var ListTriggerInboxMessagesSchema = zod.z.object({
|
|
@@ -9662,24 +9844,45 @@ var ListTriggerInboxMessagesApiResponseSchema = zod.z.object({
|
|
|
9662
9844
|
results: zod.z.array(TriggerMessageItemSchema)
|
|
9663
9845
|
});
|
|
9664
9846
|
|
|
9665
|
-
// src/
|
|
9666
|
-
function
|
|
9667
|
-
|
|
9668
|
-
|
|
9669
|
-
|
|
9670
|
-
|
|
9671
|
-
|
|
9672
|
-
|
|
9847
|
+
// src/formatters/triggerMessage.ts
|
|
9848
|
+
function buildBaseDetails(item) {
|
|
9849
|
+
const details = [
|
|
9850
|
+
{ text: `Status: ${item.status}`, style: "dim" },
|
|
9851
|
+
{
|
|
9852
|
+
text: `Lease count: ${item.message_attributes.lease_count}`,
|
|
9853
|
+
style: "dim"
|
|
9854
|
+
}
|
|
9855
|
+
];
|
|
9856
|
+
if (item.message_attributes.error_message) {
|
|
9857
|
+
details.push({
|
|
9858
|
+
text: `Error: ${item.message_attributes.error_message}`,
|
|
9859
|
+
style: "warning"
|
|
9860
|
+
});
|
|
9861
|
+
}
|
|
9862
|
+
if (item.message_attributes.possible_duplicate_data) {
|
|
9863
|
+
details.push({ text: "Possible duplicate data", style: "warning" });
|
|
9673
9864
|
}
|
|
9865
|
+
return details;
|
|
9674
9866
|
}
|
|
9867
|
+
var triggerMessageItemFormatter = {
|
|
9868
|
+
format: (item) => ({
|
|
9869
|
+
title: `Message ${item.id}`,
|
|
9870
|
+
id: item.id,
|
|
9871
|
+
details: buildBaseDetails(item)
|
|
9872
|
+
})
|
|
9873
|
+
};
|
|
9874
|
+
|
|
9875
|
+
// src/plugins/triggers/listTriggerInboxMessages/index.ts
|
|
9675
9876
|
var listTriggerInboxMessagesPlugin = definePlugin(
|
|
9676
9877
|
(sdk) => createPaginatedPluginMethod(sdk, {
|
|
9677
9878
|
...triggersDefaults,
|
|
9879
|
+
...zapierPagination,
|
|
9678
9880
|
name: "listTriggerInboxMessages",
|
|
9679
9881
|
type: "list",
|
|
9680
9882
|
itemType: "TriggerMessage",
|
|
9681
9883
|
inputSchema: ListTriggerInboxMessagesSchema,
|
|
9682
9884
|
outputSchema: TriggerMessageItemSchema,
|
|
9885
|
+
formatter: triggerMessageItemFormatter,
|
|
9683
9886
|
defaultPageSize: DEFAULT_PAGE_SIZE,
|
|
9684
9887
|
resolvers: { inbox: triggerInboxResolver },
|
|
9685
9888
|
handler: async ({ sdk: sdk2, options }) => {
|
|
@@ -9704,8 +9907,7 @@ var listTriggerInboxMessagesPlugin = definePlugin(
|
|
|
9704
9907
|
data: response.results,
|
|
9705
9908
|
next: response.next ?? null
|
|
9706
9909
|
};
|
|
9707
|
-
}
|
|
9708
|
-
extractCursor: (response) => extractNextCursor(response.next)
|
|
9910
|
+
}
|
|
9709
9911
|
})
|
|
9710
9912
|
);
|
|
9711
9913
|
var LeaseTriggerInboxMessagesSchema = zod.z.object({
|
|
@@ -10428,17 +10630,14 @@ var listTriggersPlugin = definePlugin(
|
|
|
10428
10630
|
itemType: "Action",
|
|
10429
10631
|
inputSchema: ListTriggersSchema,
|
|
10430
10632
|
outputSchema: ActionItemSchema,
|
|
10633
|
+
formatter: actionItemFormatter,
|
|
10431
10634
|
defaultPageSize: DEFAULT_PAGE_SIZE,
|
|
10432
10635
|
resolvers: { app: appKeyResolver },
|
|
10433
|
-
handler: async ({
|
|
10434
|
-
|
|
10435
|
-
options
|
|
10436
|
-
}) => {
|
|
10437
|
-
const result = await sdk2.listActions({
|
|
10636
|
+
handler: async ({ sdk: sdk2, options }) => {
|
|
10637
|
+
return await sdk2.listActions({
|
|
10438
10638
|
...options,
|
|
10439
10639
|
actionType: "read"
|
|
10440
10640
|
});
|
|
10441
|
-
return { data: result.data, nextCursor: result.nextCursor };
|
|
10442
10641
|
}
|
|
10443
10642
|
})
|
|
10444
10643
|
);
|
|
@@ -10465,6 +10664,7 @@ var listTriggerInputFieldsPlugin = definePlugin(
|
|
|
10465
10664
|
itemType: "RootField",
|
|
10466
10665
|
inputSchema: ListTriggerInputFieldsSchema,
|
|
10467
10666
|
outputSchema: RootFieldItemSchema,
|
|
10667
|
+
formatter: rootFieldItemFormatter,
|
|
10468
10668
|
defaultPageSize: DEFAULT_PAGE_SIZE,
|
|
10469
10669
|
// actionKeyResolver and inputsAllOptionalResolver depend on actionType.
|
|
10470
10670
|
// Pin it to "read" so they resolve correctly without the user setting it.
|
|
@@ -10475,15 +10675,11 @@ var listTriggerInputFieldsPlugin = definePlugin(
|
|
|
10475
10675
|
inputs: inputsAllOptionalResolver,
|
|
10476
10676
|
actionType: { type: "constant", value: "read" }
|
|
10477
10677
|
},
|
|
10478
|
-
handler: async ({
|
|
10479
|
-
|
|
10480
|
-
options
|
|
10481
|
-
}) => {
|
|
10482
|
-
const result = await sdk2.listActionInputFields({
|
|
10678
|
+
handler: async ({ sdk: sdk2, options }) => {
|
|
10679
|
+
return await sdk2.listActionInputFields({
|
|
10483
10680
|
...options,
|
|
10484
10681
|
actionType: "read"
|
|
10485
10682
|
});
|
|
10486
|
-
return { data: result.data, nextCursor: result.nextCursor };
|
|
10487
10683
|
}
|
|
10488
10684
|
})
|
|
10489
10685
|
);
|
|
@@ -10514,6 +10710,7 @@ var listTriggerInputFieldChoicesPlugin = definePlugin(
|
|
|
10514
10710
|
itemType: "InputFieldChoice",
|
|
10515
10711
|
inputSchema: ListTriggerInputFieldChoicesSchema,
|
|
10516
10712
|
outputSchema: InputFieldChoiceItemSchema,
|
|
10713
|
+
formatter: inputFieldChoiceItemFormatter,
|
|
10517
10714
|
defaultPageSize: DEFAULT_PAGE_SIZE,
|
|
10518
10715
|
resolvers: {
|
|
10519
10716
|
app: appKeyResolver,
|
|
@@ -10523,15 +10720,11 @@ var listTriggerInputFieldChoicesPlugin = definePlugin(
|
|
|
10523
10720
|
inputs: inputsAllOptionalResolver,
|
|
10524
10721
|
actionType: { type: "constant", value: "read" }
|
|
10525
10722
|
},
|
|
10526
|
-
handler: async ({
|
|
10527
|
-
|
|
10528
|
-
options
|
|
10529
|
-
}) => {
|
|
10530
|
-
const result = await sdk2.listActionInputFieldChoices({
|
|
10723
|
+
handler: async ({ sdk: sdk2, options }) => {
|
|
10724
|
+
return await sdk2.listActionInputFieldChoices({
|
|
10531
10725
|
...options,
|
|
10532
10726
|
actionType: "read"
|
|
10533
10727
|
});
|
|
10534
|
-
return { data: result.data, nextCursor: result.nextCursor };
|
|
10535
10728
|
}
|
|
10536
10729
|
})
|
|
10537
10730
|
);
|
|
@@ -10633,10 +10826,9 @@ var listWorkflowsPlugin = definePlugin(
|
|
|
10633
10826
|
const response = ListWorkflowsApiResponseSchema.parse(raw);
|
|
10634
10827
|
return {
|
|
10635
10828
|
data: response.workflows,
|
|
10636
|
-
|
|
10829
|
+
nextCursor: response.next_cursor ?? void 0
|
|
10637
10830
|
};
|
|
10638
|
-
}
|
|
10639
|
-
extractCursor: (response) => response.next ?? void 0
|
|
10831
|
+
}
|
|
10640
10832
|
})
|
|
10641
10833
|
);
|
|
10642
10834
|
var WorkflowVersionSchema = zod.z.object({
|
|
@@ -11521,6 +11713,74 @@ var getTriggerRunPlugin = definePlugin(
|
|
|
11521
11713
|
}
|
|
11522
11714
|
})
|
|
11523
11715
|
);
|
|
11716
|
+
var TriggerWorkflowLookupResponseSchema = zod.z.object({
|
|
11717
|
+
trigger_url: zod.z.string()
|
|
11718
|
+
}).passthrough();
|
|
11719
|
+
var TriggerWorkflowOptionsSchema = zod.z.object({
|
|
11720
|
+
workflow: zod.z.string().uuid().describe("Durable workflow ID"),
|
|
11721
|
+
input: zod.z.unknown().optional().describe(
|
|
11722
|
+
"JSON payload delivered as the trigger body. Sent as `application/json`; omit to fire with an empty body."
|
|
11723
|
+
)
|
|
11724
|
+
}).describe(
|
|
11725
|
+
"Look up a workflow's trigger URL and fire it manually. The trigger endpoint is tokenized (the URL contains a secret) and takes no auth header, so the SDK uses a raw fetch rather than the api plugin."
|
|
11726
|
+
);
|
|
11727
|
+
var TriggerWorkflowResponseSchema = zod.z.object({
|
|
11728
|
+
workflow: zod.z.string().describe("The workflow ID that was triggered"),
|
|
11729
|
+
status: zod.z.number().int().describe("HTTP status returned by the trigger endpoint"),
|
|
11730
|
+
body: zod.z.unknown().describe(
|
|
11731
|
+
"Response body from the trigger endpoint. Parsed as JSON when the response body parses, otherwise returned as the raw response text."
|
|
11732
|
+
)
|
|
11733
|
+
});
|
|
11734
|
+
|
|
11735
|
+
// src/plugins/codeSubstrate/triggerWorkflow/index.ts
|
|
11736
|
+
var triggerWorkflowPlugin = definePlugin(
|
|
11737
|
+
(sdk) => createPluginMethod(sdk, {
|
|
11738
|
+
...codeSubstrateDefaults,
|
|
11739
|
+
name: "triggerWorkflow",
|
|
11740
|
+
type: "create",
|
|
11741
|
+
itemType: "WorkflowRun",
|
|
11742
|
+
inputSchema: TriggerWorkflowOptionsSchema,
|
|
11743
|
+
outputSchema: TriggerWorkflowResponseSchema,
|
|
11744
|
+
resolvers: { workflow: workflowIdResolver },
|
|
11745
|
+
handler: async ({ sdk: sdk2, options }) => {
|
|
11746
|
+
const rawWorkflow = await sdk2.context.api.get(
|
|
11747
|
+
`/durableworkflowzaps/api/v0/workflows/${encodeURIComponent(options.workflow)}`,
|
|
11748
|
+
{
|
|
11749
|
+
authRequired: true,
|
|
11750
|
+
resource: { type: "workflow", id: options.workflow }
|
|
11751
|
+
}
|
|
11752
|
+
);
|
|
11753
|
+
const workflow = TriggerWorkflowLookupResponseSchema.parse(rawWorkflow);
|
|
11754
|
+
const fetch2 = sdk2.context.options.fetch ?? globalThis.fetch;
|
|
11755
|
+
const response = await fetch2(workflow.trigger_url, {
|
|
11756
|
+
method: "POST",
|
|
11757
|
+
headers: { "Content-Type": "application/json" },
|
|
11758
|
+
body: options.input === void 0 ? void 0 : JSON.stringify(options.input)
|
|
11759
|
+
});
|
|
11760
|
+
const text = await response.text().catch(() => "");
|
|
11761
|
+
let body = text;
|
|
11762
|
+
if (text) {
|
|
11763
|
+
try {
|
|
11764
|
+
body = JSON.parse(text);
|
|
11765
|
+
} catch {
|
|
11766
|
+
body = text;
|
|
11767
|
+
}
|
|
11768
|
+
}
|
|
11769
|
+
if (!response.ok) {
|
|
11770
|
+
throw new ZapierApiError(
|
|
11771
|
+
`Trigger failed: ${response.status} ${response.statusText}: ${text || "(empty body)"}`,
|
|
11772
|
+
{ statusCode: response.status, response: body }
|
|
11773
|
+
);
|
|
11774
|
+
}
|
|
11775
|
+
const data = {
|
|
11776
|
+
workflow: options.workflow,
|
|
11777
|
+
status: response.status,
|
|
11778
|
+
body
|
|
11779
|
+
};
|
|
11780
|
+
return { data };
|
|
11781
|
+
}
|
|
11782
|
+
})
|
|
11783
|
+
);
|
|
11524
11784
|
|
|
11525
11785
|
// src/utils/batch-utils.ts
|
|
11526
11786
|
var DEFAULT_CONCURRENCY = 10;
|
|
@@ -11672,15 +11932,18 @@ var BaseSdkOptionsSchema = zod.z.object({
|
|
|
11672
11932
|
|
|
11673
11933
|
// src/plugins/registry/index.ts
|
|
11674
11934
|
var registryPlugin = definePlugin((_sdk) => {
|
|
11675
|
-
|
|
11935
|
+
logDeprecation2(
|
|
11676
11936
|
"registryPlugin is deprecated and a no-op; getRegistry is now built into every sdk. Remove .addPlugin(registryPlugin)."
|
|
11677
11937
|
);
|
|
11678
11938
|
return {};
|
|
11679
11939
|
});
|
|
11680
11940
|
|
|
11681
11941
|
// src/experimental.ts
|
|
11942
|
+
function createZapierSdkStack2(options = {}) {
|
|
11943
|
+
return createZapierCoreStack().use(createOptionsPlugin(options)).use(eventEmissionPlugin).use(apiPlugin).use(manifestPlugin).use(capabilitiesPlugin).use(connectionsPlugin).use(listAppsPlugin).use(getAppPlugin).use(listConnectionsPlugin).use(getConnectionPlugin).use(findFirstConnectionPlugin).use(findUniqueConnectionPlugin).use(listActionsPlugin).use(getActionPlugin).use(listActionInputFieldsPlugin).use(getActionInputFieldsSchemaPlugin).use(listActionInputFieldChoicesPlugin).use(listInputFieldsDeprecatedPlugin).use(getInputFieldsSchemaDeprecatedPlugin).use(listInputFieldChoicesDeprecatedPlugin).use(runActionPlugin).use(listAuthenticationsPlugin).use(getAuthenticationPlugin).use(findFirstAuthenticationPlugin).use(findUniqueAuthenticationPlugin).use(listClientCredentialsPlugin).use(createClientCredentialsPlugin).use(deleteClientCredentialsPlugin).use(fetchPlugin).use(requestPlugin).use(listTriggerInboxesPlugin).use(createTriggerInboxPlugin).use(ensureTriggerInboxPlugin).use(getTriggerInboxPlugin).use(updateTriggerInboxPlugin).use(deleteTriggerInboxPlugin).use(pauseTriggerInboxPlugin).use(resumeTriggerInboxPlugin).use(listTriggerInboxMessagesPlugin).use(leaseTriggerInboxMessagesPlugin).use(ackTriggerInboxMessagesPlugin).use(releaseTriggerInboxMessagesPlugin).use(drainTriggerInboxPlugin).use(watchTriggerInboxPlugin).use(listTriggersPlugin).use(listTriggerInputFieldsPlugin).use(listTriggerInputFieldChoicesPlugin).use(getTriggerInputFieldsSchemaPlugin).use(listTablesPlugin).use(getTablePlugin).use(deleteTablePlugin).use(createTablePlugin).use(listTableFieldsPlugin).use(createTableFieldsPlugin).use(deleteTableFieldsPlugin).use(listTableRecordsPlugin).use(getTableRecordPlugin).use(createTableRecordsPlugin).use(deleteTableRecordsPlugin).use(updateTableRecordsPlugin).use(listWorkflowsPlugin).use(getWorkflowPlugin).use(createWorkflowPlugin).use(updateWorkflowPlugin).use(enableWorkflowPlugin).use(disableWorkflowPlugin).use(deleteWorkflowPlugin).use(listDurableRunsPlugin).use(getDurableRunPlugin).use(runDurablePlugin).use(cancelDurableRunPlugin).use(publishWorkflowVersionPlugin).use(listWorkflowVersionsPlugin).use(getWorkflowVersionPlugin).use(listWorkflowRunsPlugin).use(getWorkflowRunPlugin).use(getTriggerRunPlugin).use(triggerWorkflowPlugin).use(appsPlugin).use(getProfilePlugin);
|
|
11944
|
+
}
|
|
11682
11945
|
function createZapierSdk2(options = {}) {
|
|
11683
|
-
return
|
|
11946
|
+
return withDeprecatedAddPlugin(createZapierSdkStack2(options).toSdk());
|
|
11684
11947
|
}
|
|
11685
11948
|
|
|
11686
11949
|
exports.ActionKeyPropertySchema = ActionKeyPropertySchema;
|
|
@@ -11694,12 +11957,14 @@ exports.AuthenticationIdPropertySchema = AuthenticationIdPropertySchema;
|
|
|
11694
11957
|
exports.BaseSdkOptionsSchema = BaseSdkOptionsSchema;
|
|
11695
11958
|
exports.CONTEXT_CACHE_MAX_SIZE = CONTEXT_CACHE_MAX_SIZE;
|
|
11696
11959
|
exports.CONTEXT_CACHE_TTL_MS = CONTEXT_CACHE_TTL_MS;
|
|
11960
|
+
exports.CORE_ERROR_SYMBOL = CORE_ERROR_SYMBOL;
|
|
11697
11961
|
exports.ClientCredentialsObjectSchema = ClientCredentialsObjectSchema;
|
|
11698
11962
|
exports.ConnectionEntrySchema = ConnectionEntrySchema;
|
|
11699
11963
|
exports.ConnectionIdPropertySchema = ConnectionIdPropertySchema;
|
|
11700
11964
|
exports.ConnectionPropertySchema = ConnectionPropertySchema;
|
|
11701
11965
|
exports.ConnectionsMapSchema = ConnectionsMapSchema;
|
|
11702
11966
|
exports.ConnectionsPropertySchema = ConnectionsPropertySchema;
|
|
11967
|
+
exports.CoreErrorCode = CoreErrorCode;
|
|
11703
11968
|
exports.CredentialsFunctionSchema = CredentialsFunctionSchema;
|
|
11704
11969
|
exports.CredentialsObjectSchema = CredentialsObjectSchema;
|
|
11705
11970
|
exports.CredentialsSchema = CredentialsSchema;
|
|
@@ -11756,6 +12021,7 @@ exports.ZapierUnknownError = ZapierUnknownError;
|
|
|
11756
12021
|
exports.ZapierValidationError = ZapierValidationError;
|
|
11757
12022
|
exports.actionKeyResolver = actionKeyResolver;
|
|
11758
12023
|
exports.actionTypeResolver = actionTypeResolver;
|
|
12024
|
+
exports.addPlugin = addPlugin;
|
|
11759
12025
|
exports.apiPlugin = apiPlugin;
|
|
11760
12026
|
exports.appKeyResolver = appKeyResolver;
|
|
11761
12027
|
exports.appsPlugin = appsPlugin;
|
|
@@ -11777,17 +12043,21 @@ exports.connectionIdResolver = connectionIdResolver;
|
|
|
11777
12043
|
exports.connectionsPlugin = connectionsPlugin;
|
|
11778
12044
|
exports.createBaseEvent = createBaseEvent;
|
|
11779
12045
|
exports.createClientCredentialsPlugin = createClientCredentialsPlugin;
|
|
12046
|
+
exports.createCorePlugin = createCorePlugin;
|
|
11780
12047
|
exports.createFunction = createFunction;
|
|
11781
12048
|
exports.createMemoryCache = createMemoryCache;
|
|
11782
12049
|
exports.createOptionsPlugin = createOptionsPlugin;
|
|
11783
12050
|
exports.createPaginatedPluginMethod = createPaginatedPluginMethod;
|
|
11784
12051
|
exports.createPluginMethod = createPluginMethod;
|
|
12052
|
+
exports.createPluginStack = createPluginStack;
|
|
11785
12053
|
exports.createSdk = createSdk;
|
|
11786
12054
|
exports.createTableFieldsPlugin = createTableFieldsPlugin;
|
|
11787
12055
|
exports.createTablePlugin = createTablePlugin;
|
|
11788
12056
|
exports.createTableRecordsPlugin = createTableRecordsPlugin;
|
|
11789
12057
|
exports.createZapierApi = createZapierApi;
|
|
12058
|
+
exports.createZapierCoreStack = createZapierCoreStack;
|
|
11790
12059
|
exports.createZapierSdk = createZapierSdk2;
|
|
12060
|
+
exports.createZapierSdkStack = createZapierSdkStack2;
|
|
11791
12061
|
exports.createZapierSdkWithoutRegistry = createZapierSdkWithoutRegistry;
|
|
11792
12062
|
exports.definePlugin = definePlugin;
|
|
11793
12063
|
exports.deleteClientCredentialsPlugin = deleteClientCredentialsPlugin;
|
|
@@ -11809,6 +12079,8 @@ exports.getBaseUrlFromCredentials = getBaseUrlFromCredentials;
|
|
|
11809
12079
|
exports.getCiPlatform = getCiPlatform;
|
|
11810
12080
|
exports.getClientIdFromCredentials = getClientIdFromCredentials;
|
|
11811
12081
|
exports.getConnectionPlugin = getConnectionPlugin;
|
|
12082
|
+
exports.getCoreErrorCause = getCoreErrorCause;
|
|
12083
|
+
exports.getCoreErrorCode = getCoreErrorCode;
|
|
11812
12084
|
exports.getCpuTime = getCpuTime;
|
|
11813
12085
|
exports.getCurrentTimestamp = getCurrentTimestamp;
|
|
11814
12086
|
exports.getMemoryUsage = getMemoryUsage;
|
|
@@ -11833,6 +12105,7 @@ exports.invalidateCredentialsToken = invalidateCredentialsToken;
|
|
|
11833
12105
|
exports.isCi = isCi;
|
|
11834
12106
|
exports.isCliLoginAvailable = isCliLoginAvailable;
|
|
11835
12107
|
exports.isClientCredentials = isClientCredentials;
|
|
12108
|
+
exports.isCoreError = isCoreError;
|
|
11836
12109
|
exports.isCredentialsFunction = isCredentialsFunction;
|
|
11837
12110
|
exports.isCredentialsObject = isCredentialsObject;
|
|
11838
12111
|
exports.isPkceCredentials = isPkceCredentials;
|
|
@@ -11846,17 +12119,18 @@ exports.listConnectionsPlugin = listConnectionsPlugin;
|
|
|
11846
12119
|
exports.listTableFieldsPlugin = listTableFieldsPlugin;
|
|
11847
12120
|
exports.listTableRecordsPlugin = listTableRecordsPlugin;
|
|
11848
12121
|
exports.listTablesPlugin = listTablesPlugin;
|
|
11849
|
-
exports.logDeprecation =
|
|
12122
|
+
exports.logDeprecation = logDeprecation2;
|
|
11850
12123
|
exports.manifestPlugin = manifestPlugin;
|
|
11851
12124
|
exports.parseConcurrencyEnvVar = parseConcurrencyEnvVar;
|
|
11852
12125
|
exports.readManifestFromFile = readManifestFromFile;
|
|
11853
12126
|
exports.registryPlugin = registryPlugin;
|
|
11854
12127
|
exports.requestPlugin = requestPlugin;
|
|
11855
|
-
exports.resetDeprecationWarnings =
|
|
12128
|
+
exports.resetDeprecationWarnings = resetDeprecationWarnings2;
|
|
11856
12129
|
exports.resolveAuthToken = resolveAuthToken;
|
|
11857
12130
|
exports.resolveCredentials = resolveCredentials;
|
|
11858
12131
|
exports.resolveCredentialsFromEnv = resolveCredentialsFromEnv;
|
|
11859
12132
|
exports.runActionPlugin = runActionPlugin;
|
|
12133
|
+
exports.runInMethodScope = runInMethodScope;
|
|
11860
12134
|
exports.runWithTelemetryContext = runWithTelemetryContext;
|
|
11861
12135
|
exports.tableFieldIdsResolver = tableFieldIdsResolver;
|
|
11862
12136
|
exports.tableFieldsResolver = tableFieldsResolver;
|
|
@@ -11876,3 +12150,4 @@ exports.updateTableRecordsPlugin = updateTableRecordsPlugin;
|
|
|
11876
12150
|
exports.workflowIdResolver = workflowIdResolver;
|
|
11877
12151
|
exports.workflowRunIdResolver = workflowRunIdResolver;
|
|
11878
12152
|
exports.workflowVersionIdResolver = workflowVersionIdResolver;
|
|
12153
|
+
exports.zapierAdaptError = zapierAdaptError;
|