@zapier/zapier-sdk 0.64.0 → 0.67.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 +47 -0
- package/README.md +165 -6
- 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 +1803 -1332
- package/dist/experimental.d.mts +3508 -182
- package/dist/experimental.d.ts +3578 -252
- package/dist/experimental.d.ts.map +1 -1
- package/dist/experimental.js +120 -84
- package/dist/experimental.mjs +1789 -1331
- 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-Bfvj0KLi.d.mts → index-Dh0b5NAY.d.mts} +13058 -7731
- package/dist/{index-Bfvj0KLi.d.ts → index-Dh0b5NAY.d.ts} +13058 -7731
- package/dist/index.cjs +1745 -1464
- 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 +1731 -1463
- 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 +47 -0
- package/dist/plugins/codeSubstrate/getTriggerRun/index.d.ts.map +1 -0
- package/dist/plugins/codeSubstrate/getTriggerRun/index.js +23 -0
- package/dist/plugins/codeSubstrate/getTriggerRun/schemas.d.ts +24 -0
- package/dist/plugins/codeSubstrate/getTriggerRun/schemas.d.ts.map +1 -0
- package/dist/plugins/codeSubstrate/getTriggerRun/schemas.js +30 -0
- 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 +102 -0
- package/dist/plugins/codeSubstrate/getWorkflowRun/index.d.ts.map +1 -0
- package/dist/plugins/codeSubstrate/getWorkflowRun/index.js +25 -0
- package/dist/plugins/codeSubstrate/getWorkflowRun/schemas.d.ts +26 -0
- package/dist/plugins/codeSubstrate/getWorkflowRun/schemas.d.ts.map +1 -0
- package/dist/plugins/codeSubstrate/getWorkflowRun/schemas.js +43 -0
- 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 +78 -0
- package/dist/plugins/codeSubstrate/listWorkflowRuns/index.d.ts.map +1 -0
- package/dist/plugins/codeSubstrate/listWorkflowRuns/index.js +34 -0
- package/dist/plugins/codeSubstrate/listWorkflowRuns/schemas.d.ts +65 -0
- package/dist/plugins/codeSubstrate/listWorkflowRuns/schemas.d.ts.map +1 -0
- package/dist/plugins/codeSubstrate/listWorkflowRuns/schemas.js +69 -0
- 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/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/index.d.ts +1 -0
- package/dist/resolvers/index.d.ts.map +1 -1
- package/dist/resolvers/index.js +1 -0
- 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 +7 -0
- package/dist/resolvers/workflowRunId.d.ts.map +1 -0
- package/dist/resolvers/workflowRunId.js +20 -0
- 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/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.mjs
CHANGED
|
@@ -11,37 +11,64 @@ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require
|
|
|
11
11
|
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
12
12
|
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
13
13
|
});
|
|
14
|
+
function toTitleCase(input) {
|
|
15
|
+
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(" ");
|
|
16
|
+
}
|
|
17
|
+
function toSnakeCase(input) {
|
|
18
|
+
let result = input.replace(/([a-z0-9])([A-Z])/g, "$1_$2").replace(/[\s\-]+/g, "_").replace(/_+/g, "_").replace(/^_|_$/g, "").toLowerCase();
|
|
19
|
+
if (/^[0-9]/.test(result)) {
|
|
20
|
+
result = "_" + result;
|
|
21
|
+
}
|
|
22
|
+
return result;
|
|
23
|
+
}
|
|
24
|
+
function pluralize(word) {
|
|
25
|
+
if (/s$/i.test(word)) return word;
|
|
26
|
+
if (/[bcdfghjklmnpqrstvwxz]y$/i.test(word)) {
|
|
27
|
+
return word.slice(0, -1) + "ies";
|
|
28
|
+
}
|
|
29
|
+
return word + "s";
|
|
30
|
+
}
|
|
31
|
+
function pluralizeLastWord(title) {
|
|
32
|
+
const words = title.split(" ");
|
|
33
|
+
return [...words.slice(0, -1), pluralize(words[words.length - 1])].join(" ");
|
|
34
|
+
}
|
|
35
|
+
function resolveCategoryDefinition(ref) {
|
|
36
|
+
const def = typeof ref === "string" ? { key: ref } : ref;
|
|
37
|
+
const title = def.title ?? toTitleCase(def.key);
|
|
38
|
+
return {
|
|
39
|
+
key: def.key,
|
|
40
|
+
title,
|
|
41
|
+
titlePlural: def.titlePlural ?? pluralizeLastWord(title)
|
|
42
|
+
};
|
|
43
|
+
}
|
|
14
44
|
function canonicalInputSchema(schema) {
|
|
15
45
|
if (schema instanceof z.ZodUnion) {
|
|
16
46
|
return schema.options[0];
|
|
17
47
|
}
|
|
18
48
|
return schema;
|
|
19
49
|
}
|
|
20
|
-
var categoryDefinitions = {
|
|
21
|
-
account: { title: "Account" },
|
|
22
|
-
app: { title: "App", titlePlural: "Apps" },
|
|
23
|
-
connection: { title: "Connection" },
|
|
24
|
-
action: { title: "Action" },
|
|
25
|
-
"client-credentials": {
|
|
26
|
-
title: "Client Credentials",
|
|
27
|
-
titlePlural: "Client Credentials"
|
|
28
|
-
},
|
|
29
|
-
table: { title: "Table" },
|
|
30
|
-
trigger: { title: "Trigger" },
|
|
31
|
-
"code-workflow": {
|
|
32
|
-
title: "Code Workflow",
|
|
33
|
-
titlePlural: "Code Workflows"
|
|
34
|
-
},
|
|
35
|
-
http: { title: "HTTP Request" },
|
|
36
|
-
utility: { title: "Utility", titlePlural: "Utilities" },
|
|
37
|
-
other: { title: "Other" }
|
|
38
|
-
};
|
|
39
|
-
var knownCategories = Object.keys(categoryDefinitions);
|
|
40
50
|
function buildRegistry({
|
|
41
51
|
sdk,
|
|
42
52
|
meta,
|
|
43
53
|
packageFilter
|
|
44
54
|
}) {
|
|
55
|
+
const definitionsByKey = /* @__PURE__ */ new Map();
|
|
56
|
+
const objectDeclaredKeys = /* @__PURE__ */ new Set();
|
|
57
|
+
for (const m of Object.values(meta)) {
|
|
58
|
+
for (const ref of m.categories ?? []) {
|
|
59
|
+
const key = typeof ref === "string" ? ref : ref.key;
|
|
60
|
+
if (typeof ref === "object") {
|
|
61
|
+
objectDeclaredKeys.add(key);
|
|
62
|
+
definitionsByKey.set(key, resolveCategoryDefinition(ref));
|
|
63
|
+
} else if (!objectDeclaredKeys.has(key)) {
|
|
64
|
+
definitionsByKey.set(key, resolveCategoryDefinition(ref));
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
if (!definitionsByKey.has("other")) {
|
|
69
|
+
definitionsByKey.set("other", resolveCategoryDefinition("other"));
|
|
70
|
+
}
|
|
71
|
+
const knownCategories = Array.from(definitionsByKey.keys());
|
|
45
72
|
const functions = Object.keys(meta).filter((key) => {
|
|
46
73
|
const property = sdk[key];
|
|
47
74
|
if (typeof property === "function") return true;
|
|
@@ -59,7 +86,9 @@ function buildRegistry({
|
|
|
59
86
|
inputSchema: canonicalInputSchema(m.inputSchema),
|
|
60
87
|
inputParameters: m.inputParameters,
|
|
61
88
|
outputSchema: m.outputSchema,
|
|
62
|
-
categories: m.categories
|
|
89
|
+
categories: (m.categories ?? []).map(
|
|
90
|
+
(c) => typeof c === "string" ? c : c.key
|
|
91
|
+
),
|
|
63
92
|
resolvers: m.resolvers,
|
|
64
93
|
formatter: m.formatter,
|
|
65
94
|
experimental: m.experimental,
|
|
@@ -74,471 +103,134 @@ function buildRegistry({
|
|
|
74
103
|
const filteredCategories = knownCategories.slice().sort((a, b) => {
|
|
75
104
|
if (a === "other") return 1;
|
|
76
105
|
if (b === "other") return -1;
|
|
77
|
-
return
|
|
78
|
-
categoryDefinitions[b].title
|
|
79
|
-
);
|
|
106
|
+
return definitionsByKey.get(a).title.localeCompare(definitionsByKey.get(b).title);
|
|
80
107
|
}).map((categoryKey) => {
|
|
81
108
|
const categoryFunctions = filteredFunctions.filter(
|
|
82
109
|
(f) => f.categories.includes(categoryKey) || categoryKey === "other" && !f.categories.some((c) => knownCategories.includes(c))
|
|
83
110
|
).map((f) => f.name).sort();
|
|
84
|
-
const
|
|
111
|
+
const def = definitionsByKey.get(categoryKey);
|
|
85
112
|
return {
|
|
86
113
|
key: categoryKey,
|
|
87
|
-
title:
|
|
88
|
-
titlePlural:
|
|
114
|
+
title: def.title,
|
|
115
|
+
titlePlural: def.titlePlural,
|
|
89
116
|
functions: categoryFunctions
|
|
90
117
|
};
|
|
91
118
|
}).filter((category) => category.functions.length > 0);
|
|
92
119
|
return { functions: filteredFunctions, categories: filteredCategories };
|
|
93
120
|
}
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
121
|
+
function composeVoid(existing, added) {
|
|
122
|
+
if (!existing) return added;
|
|
123
|
+
if (!added) return existing;
|
|
124
|
+
return (ctx) => {
|
|
125
|
+
existing(ctx);
|
|
126
|
+
added(ctx);
|
|
127
|
+
};
|
|
101
128
|
}
|
|
102
|
-
function
|
|
103
|
-
|
|
129
|
+
function buildHooks(existing, added) {
|
|
130
|
+
const result = {};
|
|
131
|
+
const start = composeVoid(existing.onMethodStart, added.onMethodStart);
|
|
132
|
+
if (start) result.onMethodStart = start;
|
|
133
|
+
const end = composeVoid(existing.onMethodEnd, added.onMethodEnd);
|
|
134
|
+
if (end) result.onMethodEnd = end;
|
|
135
|
+
return result;
|
|
104
136
|
}
|
|
105
|
-
function
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
137
|
+
function createDeprecationLogger(tag) {
|
|
138
|
+
const loggedDeprecations = /* @__PURE__ */ new Set();
|
|
139
|
+
return {
|
|
140
|
+
logDeprecation(message) {
|
|
141
|
+
if (loggedDeprecations.has(message)) return;
|
|
142
|
+
loggedDeprecations.add(message);
|
|
143
|
+
console.warn(`[${tag}] Deprecation: ${message}`);
|
|
144
|
+
},
|
|
145
|
+
resetDeprecationWarnings() {
|
|
146
|
+
loggedDeprecations.clear();
|
|
147
|
+
}
|
|
148
|
+
};
|
|
110
149
|
}
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
150
|
+
var { logDeprecation} = createDeprecationLogger("core");
|
|
151
|
+
var CORE_ERROR_SYMBOL = Symbol.for("kitcore.error");
|
|
152
|
+
var CoreErrorCode = {
|
|
153
|
+
Validation: "VALIDATION_ERROR",
|
|
154
|
+
Unknown: "UNKNOWN_ERROR"
|
|
155
|
+
};
|
|
156
|
+
var CoreError = class extends Error {
|
|
157
|
+
constructor(message, options = {}) {
|
|
158
|
+
super(message);
|
|
159
|
+
this.name = "CoreError";
|
|
160
|
+
if (options.statusCode !== void 0) this.statusCode = options.statusCode;
|
|
161
|
+
if (options.errors !== void 0) this.errors = options.errors;
|
|
162
|
+
if (options.cause !== void 0) this.cause = options.cause;
|
|
163
|
+
if (options.response !== void 0) this.response = options.response;
|
|
164
|
+
Object.setPrototypeOf(this, new.target.prototype);
|
|
165
|
+
}
|
|
166
|
+
};
|
|
167
|
+
function createCoreError(options, adaptError) {
|
|
168
|
+
const error = adaptError?.(options) ?? new CoreError(options.message, { cause: options.cause });
|
|
169
|
+
Object.defineProperty(error, CORE_ERROR_SYMBOL, {
|
|
170
|
+
value: true,
|
|
171
|
+
enumerable: false,
|
|
172
|
+
configurable: true,
|
|
173
|
+
writable: false
|
|
114
174
|
});
|
|
115
|
-
|
|
175
|
+
Object.defineProperty(error, "coreCode", {
|
|
176
|
+
value: options.code,
|
|
177
|
+
enumerable: false,
|
|
178
|
+
configurable: true,
|
|
179
|
+
writable: false
|
|
180
|
+
});
|
|
181
|
+
return error;
|
|
116
182
|
}
|
|
117
|
-
function
|
|
118
|
-
return
|
|
183
|
+
function isCoreError(value) {
|
|
184
|
+
return Boolean(
|
|
185
|
+
value && typeof value === "object" && value[CORE_ERROR_SYMBOL] === true
|
|
186
|
+
);
|
|
119
187
|
}
|
|
120
|
-
function
|
|
121
|
-
if (
|
|
122
|
-
|
|
123
|
-
}
|
|
124
|
-
if (schema instanceof z.ZodOptional) {
|
|
125
|
-
return isPositional(schema._zod.def.innerType);
|
|
126
|
-
}
|
|
127
|
-
if (schema instanceof z.ZodDefault) {
|
|
128
|
-
return isPositional(schema._zod.def.innerType);
|
|
129
|
-
}
|
|
130
|
-
return false;
|
|
188
|
+
function getCoreErrorCode(value) {
|
|
189
|
+
if (!isCoreError(value)) return void 0;
|
|
190
|
+
return value.coreCode;
|
|
131
191
|
}
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
function getZapierSdkService() {
|
|
136
|
-
return globalThis.process?.env?.ZAPIER_SDK_SERVICE;
|
|
192
|
+
function getCoreErrorCause(value) {
|
|
193
|
+
if (!isCoreError(value)) return void 0;
|
|
194
|
+
return value.cause;
|
|
137
195
|
}
|
|
138
|
-
var
|
|
139
|
-
var
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
)
|
|
149
|
-
|
|
150
|
-
}
|
|
151
|
-
return parsed;
|
|
196
|
+
var CURSOR_VERSION = 1;
|
|
197
|
+
var CURSOR_SOURCE = {
|
|
198
|
+
API: "api",
|
|
199
|
+
SDK: "sdk"
|
|
200
|
+
};
|
|
201
|
+
function encodeBase64(str) {
|
|
202
|
+
return btoa(
|
|
203
|
+
Array.from(
|
|
204
|
+
new TextEncoder().encode(str),
|
|
205
|
+
(b) => String.fromCharCode(b)
|
|
206
|
+
).join("")
|
|
207
|
+
);
|
|
152
208
|
}
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
function parseConcurrencyEnvVar(name) {
|
|
157
|
-
const value = globalThis.process?.env?.[name];
|
|
158
|
-
if (!value) return void 0;
|
|
159
|
-
if (value === "Infinity") return Infinity;
|
|
160
|
-
if (/^[1-9]\d*$/.test(value)) {
|
|
161
|
-
const parsed = parseInt(value, 10);
|
|
162
|
-
if (parsed <= MAX_CONCURRENCY_LIMIT) return parsed;
|
|
163
|
-
}
|
|
164
|
-
console.warn(
|
|
165
|
-
`[zapier-sdk] Invalid value for ${name}: "${value}" (expected positive integer 1-${MAX_CONCURRENCY_LIMIT} or "Infinity")`
|
|
209
|
+
function decodeBase64(str) {
|
|
210
|
+
return new TextDecoder().decode(
|
|
211
|
+
Uint8Array.from(atob(str), (c) => c.charCodeAt(0))
|
|
166
212
|
);
|
|
167
|
-
return void 0;
|
|
168
213
|
}
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
214
|
+
function encodeApiCursor(cursor) {
|
|
215
|
+
const envelope = {
|
|
216
|
+
v: CURSOR_VERSION,
|
|
217
|
+
source: CURSOR_SOURCE.API,
|
|
218
|
+
cursor
|
|
219
|
+
};
|
|
220
|
+
return encodeBase64(JSON.stringify(envelope));
|
|
175
221
|
}
|
|
176
|
-
function
|
|
177
|
-
const
|
|
178
|
-
|
|
222
|
+
function encodeSdkCursor(offset, cursor) {
|
|
223
|
+
const envelope = {
|
|
224
|
+
v: CURSOR_VERSION,
|
|
225
|
+
source: CURSOR_SOURCE.SDK,
|
|
226
|
+
cursor,
|
|
227
|
+
offset
|
|
228
|
+
};
|
|
229
|
+
return encodeBase64(JSON.stringify(envelope));
|
|
179
230
|
}
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
// src/types/properties.ts
|
|
184
|
-
var AppKeyPropertySchema = withPositional(
|
|
185
|
-
z.string().min(1).describe("App key (e.g., 'SlackCLIAPI' or slug like 'github')")
|
|
186
|
-
);
|
|
187
|
-
var AppPropertySchema = withPositional(
|
|
188
|
-
z.string().min(1).describe(
|
|
189
|
-
"App slug (e.g., 'github'), implementation name (e.g., 'SlackCLIAPI'), or versioned ID (e.g., 'github@1.2.3')"
|
|
190
|
-
)
|
|
191
|
-
);
|
|
192
|
-
var ActionTypePropertySchema = z.enum([
|
|
193
|
-
"read",
|
|
194
|
-
"read_bulk",
|
|
195
|
-
"write",
|
|
196
|
-
"run",
|
|
197
|
-
"search",
|
|
198
|
-
"search_or_write",
|
|
199
|
-
"search_and_write",
|
|
200
|
-
"filter"
|
|
201
|
-
]).describe("Action type that matches the action's defined type");
|
|
202
|
-
var ActionKeyPropertySchema = z.string().min(1).describe("Action key to execute");
|
|
203
|
-
var ActionPropertySchema = withPositional(
|
|
204
|
-
z.string().min(1).describe("Action key (e.g., 'send_message' or 'find_row')")
|
|
205
|
-
);
|
|
206
|
-
var InputFieldPropertySchema = withPositional(
|
|
207
|
-
z.string().min(1).describe("Input field key to get choices for")
|
|
208
|
-
);
|
|
209
|
-
var ConnectionIdPropertySchema = z.union([z.string(), z.number().int().positive()]).describe("Connection ID to use for this action");
|
|
210
|
-
var AuthenticationIdPropertySchema = ConnectionIdPropertySchema.meta({
|
|
211
|
-
deprecated: true
|
|
212
|
-
});
|
|
213
|
-
var ConnectionPropertySchema = z.union([z.string(), z.number().int().positive()]).describe(
|
|
214
|
-
"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."
|
|
215
|
-
);
|
|
216
|
-
var InputsPropertySchema = z.record(z.string(), z.unknown()).describe("Input parameters for the action");
|
|
217
|
-
var LimitPropertySchema = z.number().int().min(1).max(MAX_PAGE_LIMIT).default(50).describe("Maximum number of items to return");
|
|
218
|
-
var OffsetPropertySchema = z.number().int().min(0).default(0).describe("Number of items to skip for pagination");
|
|
219
|
-
var OutputPropertySchema = z.string().describe("Output file path");
|
|
220
|
-
var DebugPropertySchema = z.boolean().default(false).describe("Enable debug logging");
|
|
221
|
-
var ParamsPropertySchema = z.record(z.string(), z.unknown()).describe("Additional parameters");
|
|
222
|
-
var ActionTimeoutMsPropertySchema = z.number().min(1e3).optional().describe(
|
|
223
|
-
`Maximum time to wait for action completion in milliseconds (default: ${DEFAULT_ACTION_TIMEOUT_MS})`
|
|
224
|
-
);
|
|
225
|
-
var TablePropertySchema = withPositional(
|
|
226
|
-
z.string().regex(/^[A-Z0-9]{26}$/, "Table ID must be a valid ULID").describe("The unique identifier of the table")
|
|
227
|
-
);
|
|
228
|
-
var RecordPropertySchema = withPositional(
|
|
229
|
-
z.string().regex(/^[A-Z0-9]{26}$/, "Record ID must be a valid ULID").describe("The unique identifier of the record")
|
|
230
|
-
);
|
|
231
|
-
var RecordsPropertySchema = z.array(z.string().regex(/^[A-Z0-9]{26}$/, "Record ID must be a valid ULID")).min(1).max(100).describe("Record IDs to operate on");
|
|
232
|
-
var FieldsPropertySchema = z.array(z.union([z.string(), z.number()])).describe(
|
|
233
|
-
'Fields to operate on. Accepts field names (e.g., "Email") or IDs (e.g., "f6", "6", or 6).'
|
|
234
|
-
);
|
|
235
|
-
var AppsPropertySchema = z.array(z.string()).describe("Filter by app keys (e.g., 'SlackCLIAPI' or slug like 'github')");
|
|
236
|
-
var TablesPropertySchema = z.array(z.string()).describe("Filter by specific table IDs");
|
|
237
|
-
var ConnectionsPropertySchema = z.array(z.string()).describe("List of connection IDs to filter by");
|
|
238
|
-
var TriggerInboxPropertySchema = withPositional(
|
|
239
|
-
z.string().min(1).describe(
|
|
240
|
-
"Trigger inbox identifier \u2014 UUID or name. Non-UUID values are resolved by name via the inbox list endpoint."
|
|
241
|
-
)
|
|
242
|
-
);
|
|
243
|
-
var TriggerInboxNamePropertySchema = z.string().min(1).max(100).describe(
|
|
244
|
-
"Inbox name; unique per (user, account). Enables get-or-create on createTriggerInbox."
|
|
245
|
-
);
|
|
246
|
-
var LeasePropertySchema = z.string().min(1).describe("Lease ID returned from leaseTriggerInboxMessages");
|
|
247
|
-
var LeaseSecondsPropertySchema = z.number().int().min(1).max(3600).describe(
|
|
248
|
-
"Seconds until the lease expires; messages return to available if not acked. API default is 300 (5 minutes)."
|
|
249
|
-
);
|
|
250
|
-
var LeaseLimitPropertySchema = z.number().int().min(1).max(100).describe("Maximum messages to lease in a single batch (1-100)");
|
|
251
|
-
|
|
252
|
-
// src/plugins/apps/schemas.ts
|
|
253
|
-
var ActionExecutionInputSchema = z.object({
|
|
254
|
-
inputs: z.record(z.string(), z.unknown()).optional(),
|
|
255
|
-
/** @deprecated Use `connection` instead. */
|
|
256
|
-
connectionId: ConnectionIdPropertySchema.optional().meta({
|
|
257
|
-
deprecated: true
|
|
258
|
-
}),
|
|
259
|
-
connection: ConnectionPropertySchema.optional(),
|
|
260
|
-
/** @deprecated Use connection instead */
|
|
261
|
-
authenticationId: AuthenticationIdPropertySchema.optional().meta({
|
|
262
|
-
deprecated: true
|
|
263
|
-
}),
|
|
264
|
-
timeoutMs: ActionTimeoutMsPropertySchema
|
|
265
|
-
}).describe(
|
|
266
|
-
"Execute an action with the given inputs for the bound app, as an alternative to runAction"
|
|
267
|
-
).meta({
|
|
268
|
-
aliases: { connectionId: "connection", authenticationId: "connection" }
|
|
269
|
-
});
|
|
270
|
-
var AppFactoryInputSchema = z.object({
|
|
271
|
-
/** @deprecated Use `connection` instead. */
|
|
272
|
-
connectionId: ConnectionIdPropertySchema.optional().meta({
|
|
273
|
-
deprecated: true
|
|
274
|
-
}),
|
|
275
|
-
connection: ConnectionPropertySchema.optional(),
|
|
276
|
-
/** @deprecated Use connection instead */
|
|
277
|
-
authenticationId: AuthenticationIdPropertySchema.optional().meta({
|
|
278
|
-
deprecated: true
|
|
279
|
-
})
|
|
280
|
-
}).describe("Bind a connection alias or numeric connectionId to an app").meta({
|
|
281
|
-
aliases: { connectionId: "connection", authenticationId: "connection" }
|
|
282
|
-
});
|
|
283
|
-
|
|
284
|
-
// src/types/errors.ts
|
|
285
|
-
var ZapierError = class extends Error {
|
|
286
|
-
constructor(message, options = {}) {
|
|
287
|
-
super(message);
|
|
288
|
-
this.statusCode = options.statusCode;
|
|
289
|
-
this.errors = options.errors;
|
|
290
|
-
this.cause = options.cause;
|
|
291
|
-
this.response = options.response;
|
|
292
|
-
Object.setPrototypeOf(this, new.target.prototype);
|
|
293
|
-
}
|
|
294
|
-
};
|
|
295
|
-
var ZapierApiError = class extends ZapierError {
|
|
296
|
-
constructor(message, options = {}) {
|
|
297
|
-
super(message, options);
|
|
298
|
-
this.name = "ZapierApiError";
|
|
299
|
-
this.code = "ZAPIER_API_ERROR";
|
|
300
|
-
}
|
|
301
|
-
};
|
|
302
|
-
var ZapierAppNotFoundError = class extends ZapierError {
|
|
303
|
-
constructor(message, options = {}) {
|
|
304
|
-
super(message, options);
|
|
305
|
-
this.name = "ZapierAppNotFoundError";
|
|
306
|
-
this.code = "ZAPIER_APP_NOT_FOUND_ERROR";
|
|
307
|
-
this.appKey = options.appKey;
|
|
308
|
-
}
|
|
309
|
-
};
|
|
310
|
-
var ZapierValidationError = class extends ZapierError {
|
|
311
|
-
constructor(message, options = {}) {
|
|
312
|
-
super(message, options);
|
|
313
|
-
this.name = "ZapierValidationError";
|
|
314
|
-
this.code = "ZAPIER_VALIDATION_ERROR";
|
|
315
|
-
this.details = options.details;
|
|
316
|
-
}
|
|
317
|
-
};
|
|
318
|
-
var ZapierUnknownError = class extends ZapierError {
|
|
319
|
-
constructor(message, options = {}) {
|
|
320
|
-
super(message, options);
|
|
321
|
-
this.name = "ZapierUnknownError";
|
|
322
|
-
this.code = "ZAPIER_UNKNOWN_ERROR";
|
|
323
|
-
}
|
|
324
|
-
};
|
|
325
|
-
var ZapierAuthenticationError = class extends ZapierError {
|
|
326
|
-
constructor(message, options = {}) {
|
|
327
|
-
super(message, options);
|
|
328
|
-
this.name = "ZapierAuthenticationError";
|
|
329
|
-
this.code = "ZAPIER_AUTHENTICATION_ERROR";
|
|
330
|
-
}
|
|
331
|
-
};
|
|
332
|
-
var ZapierNotFoundError = class extends ZapierError {
|
|
333
|
-
constructor(message, options = {}) {
|
|
334
|
-
super(message, options);
|
|
335
|
-
this.name = "ZapierNotFoundError";
|
|
336
|
-
this.code = "ZAPIER_NOT_FOUND_ERROR";
|
|
337
|
-
}
|
|
338
|
-
};
|
|
339
|
-
var ZapierResourceNotFoundError = class extends ZapierNotFoundError {
|
|
340
|
-
constructor(message, options = {}) {
|
|
341
|
-
super(message, options);
|
|
342
|
-
this.name = "ZapierResourceNotFoundError";
|
|
343
|
-
this.code = "ZAPIER_RESOURCE_NOT_FOUND_ERROR";
|
|
344
|
-
this.resourceType = options.resourceType;
|
|
345
|
-
this.resourceId = options.resourceId;
|
|
346
|
-
}
|
|
347
|
-
};
|
|
348
|
-
var ZapierConfigurationError = class extends ZapierError {
|
|
349
|
-
constructor(message, options = {}) {
|
|
350
|
-
super(message, options);
|
|
351
|
-
this.name = "ZapierConfigurationError";
|
|
352
|
-
this.code = "ZAPIER_CONFIGURATION_ERROR";
|
|
353
|
-
this.configType = options.configType;
|
|
354
|
-
}
|
|
355
|
-
};
|
|
356
|
-
var ZapierBundleError = class extends ZapierError {
|
|
357
|
-
constructor(message, options = {}) {
|
|
358
|
-
super(message, options);
|
|
359
|
-
this.name = "ZapierBundleError";
|
|
360
|
-
this.code = "ZAPIER_BUNDLE_ERROR";
|
|
361
|
-
this.buildErrors = options.buildErrors;
|
|
362
|
-
}
|
|
363
|
-
};
|
|
364
|
-
var ZapierTimeoutError = class extends ZapierError {
|
|
365
|
-
constructor(message, options = {}) {
|
|
366
|
-
super(message, options);
|
|
367
|
-
this.name = "ZapierTimeoutError";
|
|
368
|
-
this.code = "ZAPIER_TIMEOUT_ERROR";
|
|
369
|
-
this.attempts = options.attempts;
|
|
370
|
-
this.maxAttempts = options.maxAttempts;
|
|
371
|
-
}
|
|
372
|
-
};
|
|
373
|
-
var ZapierActionError = class extends ZapierError {
|
|
374
|
-
constructor(message, options = {}) {
|
|
375
|
-
super(message, options);
|
|
376
|
-
this.name = "ZapierActionError";
|
|
377
|
-
this.code = "ZAPIER_ACTION_ERROR";
|
|
378
|
-
this.appKey = options.appKey;
|
|
379
|
-
this.actionKey = options.actionKey;
|
|
380
|
-
}
|
|
381
|
-
// Legacy accessor for backward compatibility
|
|
382
|
-
get actionErrors() {
|
|
383
|
-
return this.errors;
|
|
384
|
-
}
|
|
385
|
-
};
|
|
386
|
-
var ZapierConflictError = class extends ZapierError {
|
|
387
|
-
constructor(message, options = {}) {
|
|
388
|
-
super(message, options);
|
|
389
|
-
this.name = "ZapierConflictError";
|
|
390
|
-
this.code = "ZAPIER_CONFLICT_ERROR";
|
|
391
|
-
this.resourceType = options.resourceType;
|
|
392
|
-
}
|
|
393
|
-
};
|
|
394
|
-
var ZapierRateLimitError = class extends ZapierError {
|
|
395
|
-
constructor(message, options = {}) {
|
|
396
|
-
super(message, options);
|
|
397
|
-
this.name = "ZapierRateLimitError";
|
|
398
|
-
this.code = "ZAPIER_RATE_LIMIT_ERROR";
|
|
399
|
-
this.rateLimit = options.rateLimit ?? {};
|
|
400
|
-
this.retries = options.retries ?? 0;
|
|
401
|
-
}
|
|
402
|
-
};
|
|
403
|
-
var ZapierApprovalError = class extends ZapierError {
|
|
404
|
-
constructor(message, options = {}) {
|
|
405
|
-
super(message, options);
|
|
406
|
-
this.name = "ZapierApprovalError";
|
|
407
|
-
this.code = "ZAPIER_APPROVAL_ERROR";
|
|
408
|
-
this.approvalId = options.approvalId;
|
|
409
|
-
this.approvalStatus = options.status;
|
|
410
|
-
this.approvalUrl = options.approvalUrl;
|
|
411
|
-
this.pollUrl = options.pollUrl;
|
|
412
|
-
}
|
|
413
|
-
};
|
|
414
|
-
var ZapierRelayError = class extends ZapierError {
|
|
415
|
-
constructor(message, options = {}) {
|
|
416
|
-
super(message, options);
|
|
417
|
-
this.name = "ZapierRelayError";
|
|
418
|
-
this.code = "ZAPIER_RELAY_ERROR";
|
|
419
|
-
}
|
|
420
|
-
};
|
|
421
|
-
function formatErrorMessage(error) {
|
|
422
|
-
let message = error.message;
|
|
423
|
-
if (error.errors && error.errors.length > 0) {
|
|
424
|
-
const additionalErrors = error.errors.slice(1);
|
|
425
|
-
if (additionalErrors.length > 0) {
|
|
426
|
-
const errorDetails = additionalErrors.map((err) => ` \u2022 ${err.detail || err.title || err.code}`).join("\n");
|
|
427
|
-
message += "\n\nAdditional errors:\n" + errorDetails;
|
|
428
|
-
}
|
|
429
|
-
}
|
|
430
|
-
if (error instanceof ZapierAppNotFoundError && error.appKey) {
|
|
431
|
-
message += `
|
|
432
|
-
App key: ${error.appKey}`;
|
|
433
|
-
}
|
|
434
|
-
if (error instanceof ZapierActionError && (error.appKey || error.actionKey)) {
|
|
435
|
-
const context = [];
|
|
436
|
-
if (error.appKey) context.push(`App: ${error.appKey}`);
|
|
437
|
-
if (error.actionKey) context.push(`Action: ${error.actionKey}`);
|
|
438
|
-
message += `
|
|
439
|
-
${context.join(", ")}`;
|
|
440
|
-
}
|
|
441
|
-
if (error instanceof ZapierResourceNotFoundError && (error.resourceType || error.resourceId)) {
|
|
442
|
-
const context = [];
|
|
443
|
-
if (error.resourceType) context.push(`Type: ${error.resourceType}`);
|
|
444
|
-
if (error.resourceId) context.push(`ID: ${error.resourceId}`);
|
|
445
|
-
message += `
|
|
446
|
-
${context.join(", ")}`;
|
|
447
|
-
}
|
|
448
|
-
if (error instanceof ZapierConflictError && error.resourceType) {
|
|
449
|
-
message += `
|
|
450
|
-
Type: ${error.resourceType}`;
|
|
451
|
-
}
|
|
452
|
-
if (error instanceof ZapierTimeoutError && (error.attempts || error.maxAttempts)) {
|
|
453
|
-
const context = [];
|
|
454
|
-
if (error.attempts) context.push(`Attempts: ${error.attempts}`);
|
|
455
|
-
if (error.maxAttempts) context.push(`Max attempts: ${error.maxAttempts}`);
|
|
456
|
-
message += `
|
|
457
|
-
${context.join(", ")}`;
|
|
458
|
-
}
|
|
459
|
-
if (error instanceof ZapierBundleError && error.buildErrors && error.buildErrors.length > 0) {
|
|
460
|
-
message += "\n\nBuild errors:\n" + error.buildErrors.map((err) => ` \u2022 ${err}`).join("\n");
|
|
461
|
-
}
|
|
462
|
-
if (error instanceof ZapierApprovalError && error.approvalUrl) {
|
|
463
|
-
message += `
|
|
464
|
-
Approval URL: ${error.approvalUrl}`;
|
|
465
|
-
}
|
|
466
|
-
if (error instanceof ZapierRateLimitError) {
|
|
467
|
-
const { limit, remaining, retryAfterMs } = error.rateLimit;
|
|
468
|
-
const parts = [];
|
|
469
|
-
if (limit !== void 0) {
|
|
470
|
-
const used = remaining !== void 0 ? limit - remaining : limit;
|
|
471
|
-
parts.push(`${used}/${limit} used`);
|
|
472
|
-
}
|
|
473
|
-
if (retryAfterMs !== void 0 && retryAfterMs > 0) {
|
|
474
|
-
parts.push(`retry in ${formatDuration(retryAfterMs)}`);
|
|
475
|
-
}
|
|
476
|
-
if (error.retries > 0) {
|
|
477
|
-
parts.push(
|
|
478
|
-
`after ${error.retries} retr${error.retries === 1 ? "y" : "ies"}`
|
|
479
|
-
);
|
|
480
|
-
}
|
|
481
|
-
if (parts.length > 0) {
|
|
482
|
-
message += `
|
|
483
|
-
${parts.join(", ")}`;
|
|
484
|
-
}
|
|
485
|
-
}
|
|
486
|
-
if (error.statusCode && !message.includes(`${error.statusCode}`)) {
|
|
487
|
-
message += `
|
|
488
|
-
HTTP Status: ${error.statusCode}`;
|
|
489
|
-
}
|
|
490
|
-
return message;
|
|
491
|
-
}
|
|
492
|
-
function formatDuration(ms) {
|
|
493
|
-
const seconds = Math.round(ms / 1e3);
|
|
494
|
-
if (seconds < 60) return `${seconds}s`;
|
|
495
|
-
const minutes = Math.round(seconds / 60);
|
|
496
|
-
if (minutes < 60) return `${minutes}m`;
|
|
497
|
-
const hours = Math.round(minutes / 60);
|
|
498
|
-
if (hours < 24) return `${hours}h`;
|
|
499
|
-
const days = Math.round(hours / 24);
|
|
500
|
-
return `${days}d`;
|
|
501
|
-
}
|
|
502
|
-
|
|
503
|
-
// src/utils/pagination-utils.ts
|
|
504
|
-
var CURSOR_VERSION = 1;
|
|
505
|
-
var CURSOR_SOURCE = {
|
|
506
|
-
API: "api",
|
|
507
|
-
SDK: "sdk"
|
|
508
|
-
};
|
|
509
|
-
function encodeBase64(str) {
|
|
510
|
-
return btoa(
|
|
511
|
-
Array.from(
|
|
512
|
-
new TextEncoder().encode(str),
|
|
513
|
-
(b) => String.fromCharCode(b)
|
|
514
|
-
).join("")
|
|
515
|
-
);
|
|
516
|
-
}
|
|
517
|
-
function decodeBase64(str) {
|
|
518
|
-
return new TextDecoder().decode(
|
|
519
|
-
Uint8Array.from(atob(str), (c) => c.charCodeAt(0))
|
|
520
|
-
);
|
|
521
|
-
}
|
|
522
|
-
function encodeApiCursor(cursor) {
|
|
523
|
-
const envelope = {
|
|
524
|
-
v: CURSOR_VERSION,
|
|
525
|
-
source: CURSOR_SOURCE.API,
|
|
526
|
-
cursor
|
|
527
|
-
};
|
|
528
|
-
return encodeBase64(JSON.stringify(envelope));
|
|
529
|
-
}
|
|
530
|
-
function encodeSdkCursor(offset, cursor) {
|
|
531
|
-
const envelope = {
|
|
532
|
-
v: CURSOR_VERSION,
|
|
533
|
-
source: CURSOR_SOURCE.SDK,
|
|
534
|
-
cursor,
|
|
535
|
-
offset
|
|
536
|
-
};
|
|
537
|
-
return encodeBase64(JSON.stringify(envelope));
|
|
538
|
-
}
|
|
539
|
-
function decodeIncomingCursor(incoming) {
|
|
540
|
-
if (!incoming) {
|
|
541
|
-
return { offset: 0, cursor: void 0 };
|
|
231
|
+
function decodeIncomingCursor(incoming) {
|
|
232
|
+
if (!incoming) {
|
|
233
|
+
return { offset: 0, cursor: void 0 };
|
|
542
234
|
}
|
|
543
235
|
try {
|
|
544
236
|
const decoded = decodeBase64(incoming);
|
|
@@ -753,144 +445,117 @@ function concatPaginated({
|
|
|
753
445
|
function toIterable(source) {
|
|
754
446
|
return { [Symbol.asyncIterator]: () => source[Symbol.asyncIterator]() };
|
|
755
447
|
}
|
|
756
|
-
|
|
757
|
-
// src/utils/validation.ts
|
|
758
|
-
var validate = (schema, input) => {
|
|
448
|
+
var parseOrThrow = (schema, input, { adaptError } = {}) => {
|
|
759
449
|
const result = schema.safeParse(input);
|
|
760
450
|
if (!result.success) {
|
|
761
|
-
const errorMessages = result.error.issues.map((
|
|
762
|
-
const path =
|
|
763
|
-
return `${path}: ${
|
|
764
|
-
});
|
|
765
|
-
const message = `Validation failed:
|
|
766
|
-
${errorMessages.join("\n ")}`;
|
|
767
|
-
throw new ZapierValidationError(message, {
|
|
768
|
-
details: {
|
|
769
|
-
zodErrors: result.error.issues,
|
|
770
|
-
input
|
|
771
|
-
}
|
|
451
|
+
const errorMessages = result.error.issues.map((issue) => {
|
|
452
|
+
const path = issue.path.length > 0 ? issue.path.join(".") : "input";
|
|
453
|
+
return `${path}: ${issue.message}`;
|
|
772
454
|
});
|
|
455
|
+
throw createCoreError(
|
|
456
|
+
{
|
|
457
|
+
code: CoreErrorCode.Validation,
|
|
458
|
+
message: `Validation failed:
|
|
459
|
+
${errorMessages.join("\n ")}`,
|
|
460
|
+
details: {
|
|
461
|
+
zodErrors: result.error.issues,
|
|
462
|
+
input
|
|
463
|
+
}
|
|
464
|
+
},
|
|
465
|
+
adaptError
|
|
466
|
+
);
|
|
773
467
|
}
|
|
774
468
|
return result.data;
|
|
775
469
|
};
|
|
776
|
-
function createValidator(schema) {
|
|
470
|
+
function createValidator(schema, { adaptError } = {}) {
|
|
777
471
|
return function validateFn(input) {
|
|
778
|
-
return
|
|
472
|
+
return parseOrThrow(schema, input, { adaptError });
|
|
779
473
|
};
|
|
780
474
|
}
|
|
781
|
-
var validateOptions = (schema, options) => {
|
|
782
|
-
|
|
783
|
-
};
|
|
784
|
-
var telemetryStore = null;
|
|
475
|
+
var validateOptions = (schema, options, { adaptError } = {}) => parseOrThrow(schema, options, { adaptError });
|
|
476
|
+
var scopeStore = null;
|
|
785
477
|
try {
|
|
786
|
-
|
|
478
|
+
scopeStore = new AsyncLocalStorage();
|
|
787
479
|
} catch {
|
|
788
480
|
}
|
|
789
|
-
function
|
|
790
|
-
if (!
|
|
791
|
-
|
|
792
|
-
return store !== void 0 && store.depth > 0;
|
|
481
|
+
function getCurrentScope() {
|
|
482
|
+
if (!scopeStore) return void 0;
|
|
483
|
+
return scopeStore.getStore();
|
|
793
484
|
}
|
|
794
|
-
function
|
|
795
|
-
|
|
796
|
-
const currentDepth = telemetryStore.getStore()?.depth ?? -1;
|
|
797
|
-
return telemetryStore.run({ depth: currentDepth + 1 }, fn);
|
|
485
|
+
function getCurrentDepth() {
|
|
486
|
+
return getCurrentScope()?.depth ?? 0;
|
|
798
487
|
}
|
|
799
|
-
function
|
|
800
|
-
if (!
|
|
801
|
-
const
|
|
802
|
-
|
|
803
|
-
store.methodMetadata = { ...store.methodMetadata, ...metadata };
|
|
488
|
+
function runInMethodScope(fn) {
|
|
489
|
+
if (!scopeStore) return fn();
|
|
490
|
+
const currentDepth = scopeStore.getStore()?.depth ?? -1;
|
|
491
|
+
return scopeStore.run({ depth: currentDepth + 1 }, fn);
|
|
804
492
|
}
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
493
|
+
var runWithTelemetryContext = runInMethodScope;
|
|
494
|
+
function normalizeError(error, adaptError) {
|
|
495
|
+
if (error instanceof Error) return error;
|
|
496
|
+
const message = typeof error === "object" && error !== null && "message" in error && typeof error.message === "string" ? error.message : String(error);
|
|
497
|
+
return createCoreError(
|
|
498
|
+
{
|
|
499
|
+
code: CoreErrorCode.Unknown,
|
|
500
|
+
message,
|
|
501
|
+
cause: error
|
|
502
|
+
},
|
|
503
|
+
adaptError
|
|
504
|
+
);
|
|
808
505
|
}
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
function extractCursor(data) {
|
|
812
|
-
if (!data?.next) {
|
|
813
|
-
return void 0;
|
|
814
|
-
}
|
|
815
|
-
try {
|
|
816
|
-
const urlObj = new URL(data.next);
|
|
817
|
-
const offset = urlObj.searchParams.get("offset");
|
|
818
|
-
return offset || void 0;
|
|
819
|
-
} catch {
|
|
820
|
-
return void 0;
|
|
821
|
-
}
|
|
822
|
-
}
|
|
823
|
-
function normalizeError(error) {
|
|
824
|
-
if (error instanceof ZapierError) {
|
|
825
|
-
return error;
|
|
826
|
-
}
|
|
827
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
828
|
-
const cause = error instanceof Error ? error : void 0;
|
|
829
|
-
if (error instanceof Error) {
|
|
830
|
-
if (error.name === "ZapierAuthenticationError") {
|
|
831
|
-
return new ZapierAuthenticationError(message, { cause });
|
|
832
|
-
}
|
|
833
|
-
}
|
|
834
|
-
return new ZapierUnknownError(message, { cause });
|
|
835
|
-
}
|
|
836
|
-
function createFunction(coreFn, schema, telemetry) {
|
|
506
|
+
function createFunction(coreFn, options) {
|
|
507
|
+
const { sdk, schema } = options;
|
|
837
508
|
const functionName = coreFn.name;
|
|
838
509
|
const namedFunctions = {
|
|
839
|
-
[functionName]: async function(
|
|
840
|
-
return
|
|
510
|
+
[functionName]: async function(callOptions) {
|
|
511
|
+
return runInMethodScope(async () => {
|
|
841
512
|
const startTime = Date.now();
|
|
842
|
-
const normalizedOptions =
|
|
843
|
-
const
|
|
513
|
+
const normalizedOptions = callOptions ?? {};
|
|
514
|
+
const args = [normalizedOptions];
|
|
515
|
+
const depth = getCurrentDepth();
|
|
516
|
+
const hooks = sdk.context.hooks;
|
|
517
|
+
const adaptError = sdk.context.core?.adaptError;
|
|
518
|
+
hooks?.onMethodStart?.({
|
|
519
|
+
methodName: functionName,
|
|
520
|
+
args,
|
|
521
|
+
isPaginated: false,
|
|
522
|
+
depth
|
|
523
|
+
});
|
|
844
524
|
try {
|
|
525
|
+
let result;
|
|
845
526
|
if (schema) {
|
|
846
|
-
const validatedOptions = validateOptions(
|
|
847
|
-
|
|
527
|
+
const validatedOptions = validateOptions(
|
|
528
|
+
schema,
|
|
529
|
+
normalizedOptions,
|
|
530
|
+
{
|
|
531
|
+
adaptError
|
|
532
|
+
}
|
|
533
|
+
);
|
|
534
|
+
result = await coreFn({
|
|
848
535
|
...normalizedOptions,
|
|
849
536
|
...validatedOptions
|
|
850
537
|
});
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
normalizedOptions
|
|
854
|
-
).length;
|
|
855
|
-
telemetry.onMethodCalled({
|
|
856
|
-
methodName: functionName,
|
|
857
|
-
durationMs: Date.now() - startTime,
|
|
858
|
-
success: true,
|
|
859
|
-
argumentCount,
|
|
860
|
-
isPaginated: false
|
|
861
|
-
});
|
|
862
|
-
}
|
|
863
|
-
return result2;
|
|
864
|
-
}
|
|
865
|
-
const result = await coreFn(normalizedOptions);
|
|
866
|
-
if (!isNested && telemetry?.onMethodCalled) {
|
|
867
|
-
const argumentCount = Object.keys(
|
|
868
|
-
normalizedOptions
|
|
869
|
-
).length;
|
|
870
|
-
telemetry.onMethodCalled({
|
|
871
|
-
methodName: functionName,
|
|
872
|
-
durationMs: Date.now() - startTime,
|
|
873
|
-
success: true,
|
|
874
|
-
argumentCount,
|
|
875
|
-
isPaginated: false
|
|
876
|
-
});
|
|
538
|
+
} else {
|
|
539
|
+
result = await coreFn(normalizedOptions);
|
|
877
540
|
}
|
|
541
|
+
hooks?.onMethodEnd?.({
|
|
542
|
+
methodName: functionName,
|
|
543
|
+
args,
|
|
544
|
+
isPaginated: false,
|
|
545
|
+
depth,
|
|
546
|
+
durationMs: Date.now() - startTime
|
|
547
|
+
});
|
|
878
548
|
return result;
|
|
879
549
|
} catch (error) {
|
|
880
|
-
const normalizedError = normalizeError(error);
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
error: normalizedError,
|
|
890
|
-
argumentCount,
|
|
891
|
-
isPaginated: false
|
|
892
|
-
});
|
|
893
|
-
}
|
|
550
|
+
const normalizedError = normalizeError(error, adaptError);
|
|
551
|
+
hooks?.onMethodEnd?.({
|
|
552
|
+
methodName: functionName,
|
|
553
|
+
args,
|
|
554
|
+
isPaginated: false,
|
|
555
|
+
depth,
|
|
556
|
+
durationMs: Date.now() - startTime,
|
|
557
|
+
error: normalizedError
|
|
558
|
+
});
|
|
894
559
|
throw normalizedError;
|
|
895
560
|
}
|
|
896
561
|
});
|
|
@@ -898,49 +563,63 @@ function createFunction(coreFn, schema, telemetry) {
|
|
|
898
563
|
};
|
|
899
564
|
return namedFunctions[functionName];
|
|
900
565
|
}
|
|
901
|
-
function
|
|
566
|
+
function isSdkPage(value) {
|
|
567
|
+
if (typeof value !== "object" || value === null) return false;
|
|
568
|
+
const page = value;
|
|
569
|
+
if (!Array.isArray(page.data)) return false;
|
|
570
|
+
if (page.nextCursor !== void 0 && typeof page.nextCursor !== "string") {
|
|
571
|
+
return false;
|
|
572
|
+
}
|
|
573
|
+
return Object.keys(page).every((k) => k === "data" || k === "nextCursor");
|
|
574
|
+
}
|
|
575
|
+
function createPageFunction(coreFn, {
|
|
576
|
+
sdk,
|
|
577
|
+
adaptPage
|
|
578
|
+
}) {
|
|
902
579
|
const functionName = coreFn.name + "Page";
|
|
903
580
|
const namedFunctions = {
|
|
904
581
|
[functionName]: async function(options) {
|
|
905
582
|
try {
|
|
906
|
-
const
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
} else if (paginatedResult.links?.next) {
|
|
913
|
-
nextCursor = extractCursor({ next: paginatedResult.links.next });
|
|
914
|
-
}
|
|
915
|
-
return {
|
|
916
|
-
data: Array.isArray(paginatedResult.data) ? paginatedResult.data : [paginatedResult.data],
|
|
917
|
-
nextCursor
|
|
918
|
-
};
|
|
919
|
-
}
|
|
920
|
-
if (Array.isArray(result)) {
|
|
921
|
-
return { data: result };
|
|
583
|
+
const response = await coreFn(options);
|
|
584
|
+
const page = adaptPage ? adaptPage(response) : response;
|
|
585
|
+
if (!isSdkPage(page)) {
|
|
586
|
+
throw new Error(
|
|
587
|
+
`${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\`.`
|
|
588
|
+
);
|
|
922
589
|
}
|
|
923
|
-
return
|
|
590
|
+
return page;
|
|
924
591
|
} catch (error) {
|
|
925
|
-
throw normalizeError(
|
|
592
|
+
throw normalizeError(
|
|
593
|
+
error,
|
|
594
|
+
sdk.context.core?.adaptError
|
|
595
|
+
);
|
|
926
596
|
}
|
|
927
597
|
}
|
|
928
598
|
};
|
|
929
599
|
return namedFunctions[functionName];
|
|
930
600
|
}
|
|
931
|
-
function createPaginatedFunction(coreFn,
|
|
932
|
-
const
|
|
933
|
-
const
|
|
934
|
-
const
|
|
601
|
+
function createPaginatedFunction(coreFn, options) {
|
|
602
|
+
const { sdk, schema, name, defaultPageSize, adaptPage } = options;
|
|
603
|
+
const pageFunction = createPageFunction(coreFn, { sdk, adaptPage });
|
|
604
|
+
const functionName = name || coreFn.name;
|
|
935
605
|
const namedFunctions = {
|
|
936
|
-
[functionName]: function(
|
|
937
|
-
return
|
|
606
|
+
[functionName]: function(callOptions) {
|
|
607
|
+
return runInMethodScope(() => {
|
|
938
608
|
const startTime = Date.now();
|
|
939
|
-
const normalizedOptions =
|
|
940
|
-
const
|
|
609
|
+
const normalizedOptions = callOptions ?? {};
|
|
610
|
+
const args = [normalizedOptions];
|
|
611
|
+
const depth = getCurrentDepth();
|
|
612
|
+
const hooks = sdk.context.hooks;
|
|
613
|
+
const adaptError = sdk.context.core?.adaptError;
|
|
614
|
+
hooks?.onMethodStart?.({
|
|
615
|
+
methodName: functionName,
|
|
616
|
+
args,
|
|
617
|
+
isPaginated: true,
|
|
618
|
+
depth
|
|
619
|
+
});
|
|
941
620
|
const validatedOptions = {
|
|
942
621
|
...normalizedOptions,
|
|
943
|
-
...
|
|
622
|
+
...schema ? createValidator(schema, { adaptError })(normalizedOptions) : normalizedOptions
|
|
944
623
|
};
|
|
945
624
|
const pageSize = validatedOptions.pageSize ?? defaultPageSize;
|
|
946
625
|
const optimizedOptions = {
|
|
@@ -954,29 +633,23 @@ function createPaginatedFunction(coreFn, schema, telemetry, explicitFunctionName
|
|
|
954
633
|
}
|
|
955
634
|
return result.value;
|
|
956
635
|
});
|
|
957
|
-
if (
|
|
636
|
+
if (hooks?.onMethodEnd) {
|
|
958
637
|
firstPagePromise.then(() => {
|
|
959
|
-
|
|
960
|
-
normalizedOptions
|
|
961
|
-
).length;
|
|
962
|
-
telemetry.onMethodCalled({
|
|
638
|
+
hooks.onMethodEnd({
|
|
963
639
|
methodName: functionName,
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
640
|
+
args,
|
|
641
|
+
isPaginated: true,
|
|
642
|
+
depth,
|
|
643
|
+
durationMs: Date.now() - startTime
|
|
968
644
|
});
|
|
969
645
|
}).catch((error) => {
|
|
970
|
-
|
|
971
|
-
normalizedOptions
|
|
972
|
-
).length;
|
|
973
|
-
telemetry.onMethodCalled({
|
|
646
|
+
hooks.onMethodEnd({
|
|
974
647
|
methodName: functionName,
|
|
648
|
+
args,
|
|
649
|
+
isPaginated: true,
|
|
650
|
+
depth,
|
|
975
651
|
durationMs: Date.now() - startTime,
|
|
976
|
-
|
|
977
|
-
error: error instanceof Error ? error : new Error(String(error)),
|
|
978
|
-
argumentCount,
|
|
979
|
-
isPaginated: true
|
|
652
|
+
error: error instanceof Error ? error : new Error(String(error))
|
|
980
653
|
});
|
|
981
654
|
});
|
|
982
655
|
}
|
|
@@ -1008,37 +681,9 @@ function createPaginatedFunction(coreFn, schema, telemetry, explicitFunctionName
|
|
|
1008
681
|
};
|
|
1009
682
|
return namedFunctions[functionName];
|
|
1010
683
|
}
|
|
1011
|
-
|
|
1012
|
-
// src/utils/telemetry-utils.ts
|
|
1013
|
-
function createTelemetryCallback(emitMethodCalled, methodName) {
|
|
1014
|
-
return {
|
|
1015
|
-
onMethodCalled: (data) => {
|
|
1016
|
-
const metadata = getMethodMetadata();
|
|
1017
|
-
emitMethodCalled({
|
|
1018
|
-
method_name: methodName,
|
|
1019
|
-
execution_duration_ms: data.durationMs,
|
|
1020
|
-
success_flag: data.success,
|
|
1021
|
-
error_message: data.error?.message ?? null,
|
|
1022
|
-
error_type: data.error?.constructor.name ?? null,
|
|
1023
|
-
argument_count: data.argumentCount,
|
|
1024
|
-
is_paginated: data.isPaginated,
|
|
1025
|
-
selected_api: metadata?.selectedApi ?? null,
|
|
1026
|
-
operation_type: metadata?.operationType ?? null,
|
|
1027
|
-
operation_key: metadata?.operationKey ?? null
|
|
1028
|
-
});
|
|
1029
|
-
}
|
|
1030
|
-
};
|
|
1031
|
-
}
|
|
1032
|
-
|
|
1033
|
-
// src/utils/plugin-utils.ts
|
|
1034
684
|
function definePlugin(fn) {
|
|
1035
685
|
return fn;
|
|
1036
686
|
}
|
|
1037
|
-
function maybeTelemetry(sdk, name) {
|
|
1038
|
-
const ctx = sdk.context;
|
|
1039
|
-
if (!ctx.eventEmission) return void 0;
|
|
1040
|
-
return createTelemetryCallback(ctx.eventEmission.emitMethodCalled, name);
|
|
1041
|
-
}
|
|
1042
687
|
function createPluginMethod(sdk, config) {
|
|
1043
688
|
const { name, inputSchema, handler, ...metaFields } = config;
|
|
1044
689
|
const namedHandlers = {
|
|
@@ -1046,11 +691,10 @@ function createPluginMethod(sdk, config) {
|
|
|
1046
691
|
return handler({ sdk, options });
|
|
1047
692
|
}
|
|
1048
693
|
};
|
|
1049
|
-
const wrappedFn = createFunction(
|
|
1050
|
-
|
|
1051
|
-
inputSchema
|
|
1052
|
-
|
|
1053
|
-
);
|
|
694
|
+
const wrappedFn = createFunction(namedHandlers[name], {
|
|
695
|
+
sdk,
|
|
696
|
+
schema: inputSchema
|
|
697
|
+
});
|
|
1054
698
|
return {
|
|
1055
699
|
[name]: wrappedFn,
|
|
1056
700
|
context: {
|
|
@@ -1068,29 +712,22 @@ function createPaginatedPluginMethod(sdk, config) {
|
|
|
1068
712
|
name,
|
|
1069
713
|
inputSchema,
|
|
1070
714
|
handler,
|
|
1071
|
-
|
|
715
|
+
adaptPage,
|
|
1072
716
|
defaultPageSize,
|
|
1073
717
|
...metaFields
|
|
1074
718
|
} = config;
|
|
1075
|
-
const
|
|
1076
|
-
[name]:
|
|
1077
|
-
|
|
1078
|
-
if (extractCursorFn) {
|
|
1079
|
-
const extracted = extractCursorFn(response);
|
|
1080
|
-
if (extracted !== void 0) {
|
|
1081
|
-
return { data: response.data, nextCursor: extracted };
|
|
1082
|
-
}
|
|
1083
|
-
}
|
|
1084
|
-
return response;
|
|
719
|
+
const namedHandlers = {
|
|
720
|
+
[name]: function(options) {
|
|
721
|
+
return handler({ sdk, options });
|
|
1085
722
|
}
|
|
1086
723
|
};
|
|
1087
|
-
const wrappedFn = createPaginatedFunction(
|
|
1088
|
-
|
|
1089
|
-
inputSchema,
|
|
1090
|
-
maybeTelemetry(sdk, name),
|
|
724
|
+
const wrappedFn = createPaginatedFunction(namedHandlers[name], {
|
|
725
|
+
sdk,
|
|
726
|
+
schema: inputSchema,
|
|
1091
727
|
name,
|
|
1092
|
-
defaultPageSize
|
|
1093
|
-
|
|
728
|
+
defaultPageSize,
|
|
729
|
+
adaptPage
|
|
730
|
+
});
|
|
1094
731
|
return {
|
|
1095
732
|
[name]: wrappedFn,
|
|
1096
733
|
context: {
|
|
@@ -1101,90 +738,684 @@ function createPaginatedPluginMethod(sdk, config) {
|
|
|
1101
738
|
}
|
|
1102
739
|
}
|
|
1103
740
|
}
|
|
1104
|
-
};
|
|
1105
|
-
}
|
|
1106
|
-
function
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
741
|
+
};
|
|
742
|
+
}
|
|
743
|
+
function splitPluginContribution(result) {
|
|
744
|
+
const { context, ...rootKeys } = result;
|
|
745
|
+
const { meta, hooks, ...contextRest } = context ?? {};
|
|
746
|
+
return {
|
|
747
|
+
rootKeys,
|
|
748
|
+
meta: meta ?? {},
|
|
749
|
+
hooks: hooks ?? {},
|
|
750
|
+
contextRest
|
|
751
|
+
};
|
|
752
|
+
}
|
|
753
|
+
var RESERVED_ROOT_KEYS = /* @__PURE__ */ new Set([
|
|
754
|
+
"context",
|
|
755
|
+
"getRegistry",
|
|
756
|
+
"addPlugin"
|
|
757
|
+
]);
|
|
758
|
+
function hasOwn(obj, key) {
|
|
759
|
+
return Object.prototype.hasOwnProperty.call(obj, key);
|
|
760
|
+
}
|
|
761
|
+
function setOwn(target, key, value) {
|
|
762
|
+
Object.defineProperty(target, key, {
|
|
763
|
+
value,
|
|
764
|
+
enumerable: true,
|
|
765
|
+
configurable: true,
|
|
766
|
+
writable: true
|
|
767
|
+
});
|
|
768
|
+
}
|
|
769
|
+
function checkCollisions(target, source, kind, callerLabel, override) {
|
|
770
|
+
for (const key of Object.keys(source)) {
|
|
771
|
+
if (kind === "root key" && RESERVED_ROOT_KEYS.has(key)) {
|
|
772
|
+
throw new Error(
|
|
773
|
+
`${callerLabel}: plugin attempted to register reserved root key "${key}". The SDK uses this key for its own accessor; rename the plugin's method.`
|
|
774
|
+
);
|
|
775
|
+
}
|
|
776
|
+
if (!override && hasOwn(target, key)) {
|
|
777
|
+
throw new Error(
|
|
778
|
+
`${callerLabel}: duplicate ${kind} "${key}". If the override is intentional, pass { override: true } in the options.`
|
|
779
|
+
);
|
|
780
|
+
}
|
|
781
|
+
}
|
|
782
|
+
}
|
|
783
|
+
function applyOwnProperties(target, source) {
|
|
784
|
+
for (const key of Object.keys(source)) {
|
|
785
|
+
setOwn(target, key, source[key]);
|
|
786
|
+
}
|
|
787
|
+
}
|
|
788
|
+
function createPluginAccumulator(initialProperties = {}, initialContext = {}) {
|
|
789
|
+
const initialMeta = initialContext.meta ?? {};
|
|
790
|
+
const initialHooks = initialContext.hooks ?? {};
|
|
791
|
+
const context = {
|
|
792
|
+
...initialContext,
|
|
793
|
+
meta: { ...initialMeta },
|
|
794
|
+
hooks: { ...initialHooks }
|
|
795
|
+
};
|
|
796
|
+
const view = { ...initialProperties, context };
|
|
797
|
+
return { view, context };
|
|
798
|
+
}
|
|
799
|
+
function mergeContribution(propertiesTarget, contextTarget, contribution, options) {
|
|
800
|
+
checkCollisions(
|
|
801
|
+
propertiesTarget,
|
|
802
|
+
contribution.rootKeys,
|
|
803
|
+
"root key",
|
|
804
|
+
options.callerLabel,
|
|
805
|
+
options.override
|
|
806
|
+
);
|
|
807
|
+
checkCollisions(
|
|
808
|
+
contextTarget.meta,
|
|
809
|
+
contribution.meta,
|
|
810
|
+
"context.meta key",
|
|
811
|
+
options.callerLabel,
|
|
812
|
+
options.override
|
|
813
|
+
);
|
|
814
|
+
checkCollisions(
|
|
815
|
+
contextTarget,
|
|
816
|
+
contribution.contextRest,
|
|
817
|
+
"context key",
|
|
818
|
+
options.callerLabel,
|
|
819
|
+
options.override
|
|
820
|
+
);
|
|
821
|
+
applyOwnProperties(propertiesTarget, contribution.rootKeys);
|
|
822
|
+
applyOwnProperties(contextTarget.meta, contribution.meta);
|
|
823
|
+
applyOwnProperties(contextTarget, contribution.contextRest);
|
|
824
|
+
contextTarget.hooks = buildHooks(contextTarget.hooks, contribution.hooks);
|
|
825
|
+
}
|
|
826
|
+
function applyPluginContribution(acc, contribution, options) {
|
|
827
|
+
mergeContribution(acc.view, acc.context, contribution, options);
|
|
828
|
+
}
|
|
829
|
+
function wrapAsSdk(properties, context, opts) {
|
|
830
|
+
const sdk = {
|
|
831
|
+
...properties,
|
|
832
|
+
context,
|
|
833
|
+
getRegistry(qopts) {
|
|
834
|
+
return buildRegistry({
|
|
835
|
+
sdk,
|
|
836
|
+
meta: context.meta,
|
|
837
|
+
packageFilter: qopts?.package
|
|
838
|
+
});
|
|
839
|
+
}
|
|
840
|
+
};
|
|
841
|
+
if (opts?.addPlugin !== void 0) {
|
|
842
|
+
sdk.addPlugin = opts.addPlugin;
|
|
843
|
+
}
|
|
844
|
+
return sdk;
|
|
845
|
+
}
|
|
846
|
+
function wrapAccumulatorAsSdk(acc) {
|
|
847
|
+
const { context: _ctx, ...rootKeys } = acc.view;
|
|
848
|
+
return wrapAsSdk(
|
|
849
|
+
rootKeys,
|
|
850
|
+
acc.context
|
|
851
|
+
);
|
|
852
|
+
}
|
|
853
|
+
function applyPluginToSdk(sdk, plugin, options) {
|
|
854
|
+
const context = sdk.context;
|
|
855
|
+
const contribution = splitPluginContribution(
|
|
856
|
+
plugin(sdk)
|
|
857
|
+
);
|
|
858
|
+
mergeContribution(sdk, context, contribution, {
|
|
859
|
+
callerLabel: "addPlugin",
|
|
860
|
+
override: options.override === true
|
|
861
|
+
});
|
|
862
|
+
}
|
|
863
|
+
function buildStackAccumulator(head, callerLabel) {
|
|
864
|
+
const ordered = [];
|
|
865
|
+
let node = head;
|
|
866
|
+
while (node) {
|
|
867
|
+
ordered.unshift(node);
|
|
868
|
+
node = node.prev;
|
|
869
|
+
}
|
|
870
|
+
const acc = createPluginAccumulator();
|
|
871
|
+
for (const { plugin, override } of ordered) {
|
|
872
|
+
const contribution = splitPluginContribution(
|
|
873
|
+
plugin(acc.view)
|
|
874
|
+
);
|
|
875
|
+
applyPluginContribution(acc, contribution, { callerLabel, override });
|
|
876
|
+
}
|
|
877
|
+
return acc;
|
|
878
|
+
}
|
|
879
|
+
function addPlugin(sdk, plugin, options) {
|
|
880
|
+
applyPluginToSdk(
|
|
881
|
+
sdk,
|
|
882
|
+
plugin,
|
|
883
|
+
options ?? {}
|
|
884
|
+
);
|
|
885
|
+
}
|
|
886
|
+
function buildSdk(properties, context) {
|
|
887
|
+
const addPlugin2 = (plugin, options) => {
|
|
888
|
+
logDeprecation(
|
|
889
|
+
"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."
|
|
890
|
+
);
|
|
891
|
+
const contribution = splitPluginContribution(
|
|
892
|
+
plugin({ ...properties, context })
|
|
893
|
+
);
|
|
894
|
+
const mergedProperties = { ...properties };
|
|
895
|
+
const mergedContext = {
|
|
896
|
+
...context,
|
|
897
|
+
meta: { ...context.meta },
|
|
898
|
+
hooks: { ...context.hooks }
|
|
899
|
+
};
|
|
900
|
+
mergeContribution(mergedProperties, mergedContext, contribution, {
|
|
901
|
+
callerLabel: "addPlugin",
|
|
902
|
+
override: options?.override === true
|
|
903
|
+
});
|
|
904
|
+
return buildSdk(
|
|
905
|
+
mergedProperties,
|
|
906
|
+
mergedContext
|
|
907
|
+
);
|
|
908
|
+
};
|
|
909
|
+
return wrapAsSdk(properties, context, { addPlugin: addPlugin2 });
|
|
910
|
+
}
|
|
911
|
+
function withDeprecatedAddPlugin(sdk) {
|
|
912
|
+
const initialProperties = {};
|
|
913
|
+
for (const key of Object.keys(sdk)) {
|
|
914
|
+
if (key === "context" || key === "getRegistry" || key === "addPlugin") {
|
|
915
|
+
continue;
|
|
916
|
+
}
|
|
917
|
+
initialProperties[key] = sdk[key];
|
|
918
|
+
}
|
|
919
|
+
const initialContext = sdk.context;
|
|
920
|
+
return buildSdk(
|
|
921
|
+
initialProperties,
|
|
922
|
+
initialContext
|
|
923
|
+
);
|
|
924
|
+
}
|
|
925
|
+
function composePlugins(...plugins) {
|
|
926
|
+
logDeprecation(
|
|
927
|
+
"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."
|
|
928
|
+
);
|
|
929
|
+
let stack = buildPluginStack(
|
|
930
|
+
null,
|
|
931
|
+
"composePlugins"
|
|
932
|
+
);
|
|
933
|
+
for (const plugin of plugins) {
|
|
934
|
+
stack = stack.use(plugin);
|
|
935
|
+
}
|
|
936
|
+
return stack.toPlugin();
|
|
937
|
+
}
|
|
938
|
+
function createPluginStack() {
|
|
939
|
+
return buildPluginStack(null, "createPluginStack");
|
|
940
|
+
}
|
|
941
|
+
function buildPluginStack(head, callerLabel) {
|
|
942
|
+
return {
|
|
943
|
+
use(plugin, options) {
|
|
944
|
+
const next = {
|
|
945
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
946
|
+
plugin,
|
|
947
|
+
override: options?.override === true,
|
|
948
|
+
prev: head
|
|
949
|
+
};
|
|
950
|
+
return buildPluginStack(next, callerLabel);
|
|
951
|
+
},
|
|
952
|
+
toPlugin() {
|
|
953
|
+
const ordered = [];
|
|
954
|
+
let node = head;
|
|
955
|
+
while (node) {
|
|
956
|
+
ordered.unshift(node);
|
|
957
|
+
node = node.prev;
|
|
958
|
+
}
|
|
959
|
+
return (outerSdk) => {
|
|
960
|
+
const { context: outerContext, ...outerProperties } = outerSdk ?? {};
|
|
961
|
+
const viewAcc = createPluginAccumulator(outerProperties, outerContext);
|
|
962
|
+
const contribsAcc = createPluginAccumulator();
|
|
963
|
+
for (const { plugin: subPlugin, override } of ordered) {
|
|
964
|
+
const contribution = splitPluginContribution(
|
|
965
|
+
subPlugin(viewAcc.view)
|
|
966
|
+
);
|
|
967
|
+
applyPluginContribution(viewAcc, contribution, {
|
|
968
|
+
callerLabel,
|
|
969
|
+
override
|
|
970
|
+
});
|
|
971
|
+
applyPluginContribution(contribsAcc, contribution, {
|
|
972
|
+
callerLabel,
|
|
973
|
+
override
|
|
974
|
+
});
|
|
975
|
+
}
|
|
976
|
+
const { context: _ignored, ...contributedRoot } = contribsAcc.view;
|
|
977
|
+
return {
|
|
978
|
+
...contributedRoot,
|
|
979
|
+
context: contribsAcc.context
|
|
980
|
+
};
|
|
981
|
+
};
|
|
982
|
+
},
|
|
983
|
+
toSdk() {
|
|
984
|
+
return wrapAccumulatorAsSdk(
|
|
985
|
+
buildStackAccumulator(head, callerLabel)
|
|
986
|
+
);
|
|
987
|
+
}
|
|
988
|
+
};
|
|
989
|
+
}
|
|
990
|
+
function createCorePlugin(options) {
|
|
991
|
+
return () => ({
|
|
992
|
+
context: {
|
|
993
|
+
core: options
|
|
994
|
+
}
|
|
995
|
+
});
|
|
996
|
+
}
|
|
997
|
+
function withPositional(schema) {
|
|
998
|
+
Object.assign(schema._zod.def, {
|
|
999
|
+
positionalMeta: { positional: true }
|
|
1000
|
+
});
|
|
1001
|
+
return schema;
|
|
1002
|
+
}
|
|
1003
|
+
function schemaHasPositionalMeta(schema) {
|
|
1004
|
+
return "positionalMeta" in schema._zod.def;
|
|
1005
|
+
}
|
|
1006
|
+
function isPositional(schema) {
|
|
1007
|
+
if (schemaHasPositionalMeta(schema) && schema._zod.def.positionalMeta?.positional) {
|
|
1008
|
+
return true;
|
|
1009
|
+
}
|
|
1010
|
+
if (schema instanceof z.ZodOptional) {
|
|
1011
|
+
return isPositional(schema._zod.def.innerType);
|
|
1012
|
+
}
|
|
1013
|
+
if (schema instanceof z.ZodDefault) {
|
|
1014
|
+
return isPositional(schema._zod.def.innerType);
|
|
1015
|
+
}
|
|
1016
|
+
return false;
|
|
1017
|
+
}
|
|
1018
|
+
|
|
1019
|
+
// src/utils/logging.ts
|
|
1020
|
+
var { logDeprecation: logDeprecation2, resetDeprecationWarnings: resetDeprecationWarnings2 } = createDeprecationLogger("zapier-sdk");
|
|
1021
|
+
|
|
1022
|
+
// src/types/errors.ts
|
|
1023
|
+
var _a, _b;
|
|
1024
|
+
var ZapierError = class extends (_b = Error, _a = CORE_ERROR_SYMBOL, _b) {
|
|
1025
|
+
constructor(message, options = {}) {
|
|
1026
|
+
super(message);
|
|
1027
|
+
this[_a] = true;
|
|
1028
|
+
this.name = "ZapierError";
|
|
1029
|
+
this.code = "ZAPIER_ERROR";
|
|
1030
|
+
if (options.statusCode !== void 0) this.statusCode = options.statusCode;
|
|
1031
|
+
if (options.errors !== void 0) this.errors = options.errors;
|
|
1032
|
+
if (options.cause !== void 0) this.cause = options.cause;
|
|
1033
|
+
if (options.response !== void 0) this.response = options.response;
|
|
1034
|
+
Object.setPrototypeOf(this, new.target.prototype);
|
|
1035
|
+
}
|
|
1036
|
+
};
|
|
1037
|
+
var ZapierValidationError = class extends ZapierError {
|
|
1038
|
+
constructor(message, options = {}) {
|
|
1039
|
+
super(message, options);
|
|
1040
|
+
this.name = "ZapierValidationError";
|
|
1041
|
+
this.code = "ZAPIER_VALIDATION_ERROR";
|
|
1042
|
+
this.details = options.details;
|
|
1043
|
+
}
|
|
1044
|
+
};
|
|
1045
|
+
var ZapierUnknownError = class extends ZapierError {
|
|
1046
|
+
constructor() {
|
|
1047
|
+
super(...arguments);
|
|
1048
|
+
this.name = "ZapierUnknownError";
|
|
1049
|
+
this.code = "ZAPIER_UNKNOWN_ERROR";
|
|
1050
|
+
}
|
|
1051
|
+
};
|
|
1052
|
+
var ZapierAuthenticationError = class extends ZapierError {
|
|
1053
|
+
constructor() {
|
|
1054
|
+
super(...arguments);
|
|
1055
|
+
this.name = "ZapierAuthenticationError";
|
|
1056
|
+
this.code = "ZAPIER_AUTHENTICATION_ERROR";
|
|
1057
|
+
}
|
|
1058
|
+
};
|
|
1059
|
+
var zapierAdaptError = (options) => {
|
|
1060
|
+
switch (options.code) {
|
|
1061
|
+
case CoreErrorCode.Validation:
|
|
1062
|
+
return new ZapierValidationError(options.message, {
|
|
1063
|
+
cause: options.cause,
|
|
1064
|
+
details: options.details
|
|
1065
|
+
});
|
|
1066
|
+
case CoreErrorCode.Unknown:
|
|
1067
|
+
return new ZapierUnknownError(options.message, {
|
|
1068
|
+
cause: options.cause
|
|
1069
|
+
});
|
|
1070
|
+
default:
|
|
1071
|
+
return new ZapierError(options.message, { cause: options.cause });
|
|
1072
|
+
}
|
|
1073
|
+
};
|
|
1074
|
+
var ZapierApiError = class extends ZapierError {
|
|
1075
|
+
constructor(message, options = {}) {
|
|
1076
|
+
super(message, options);
|
|
1077
|
+
this.name = "ZapierApiError";
|
|
1078
|
+
this.code = "ZAPIER_API_ERROR";
|
|
1079
|
+
}
|
|
1080
|
+
};
|
|
1081
|
+
var ZapierAppNotFoundError = class extends ZapierError {
|
|
1082
|
+
constructor(message, options = {}) {
|
|
1083
|
+
super(message, options);
|
|
1084
|
+
this.name = "ZapierAppNotFoundError";
|
|
1085
|
+
this.code = "ZAPIER_APP_NOT_FOUND_ERROR";
|
|
1086
|
+
this.appKey = options.appKey;
|
|
1087
|
+
}
|
|
1088
|
+
};
|
|
1089
|
+
var ZapierNotFoundError = class extends ZapierError {
|
|
1090
|
+
constructor(message, options = {}) {
|
|
1091
|
+
super(message, options);
|
|
1092
|
+
this.name = "ZapierNotFoundError";
|
|
1093
|
+
this.code = "ZAPIER_NOT_FOUND_ERROR";
|
|
1094
|
+
}
|
|
1095
|
+
};
|
|
1096
|
+
var ZapierResourceNotFoundError = class extends ZapierNotFoundError {
|
|
1097
|
+
constructor(message, options = {}) {
|
|
1098
|
+
super(message, options);
|
|
1099
|
+
this.name = "ZapierResourceNotFoundError";
|
|
1100
|
+
this.code = "ZAPIER_RESOURCE_NOT_FOUND_ERROR";
|
|
1101
|
+
this.resourceType = options.resourceType;
|
|
1102
|
+
this.resourceId = options.resourceId;
|
|
1103
|
+
}
|
|
1104
|
+
};
|
|
1105
|
+
var ZapierConfigurationError = class extends ZapierError {
|
|
1106
|
+
constructor(message, options = {}) {
|
|
1107
|
+
super(message, options);
|
|
1108
|
+
this.name = "ZapierConfigurationError";
|
|
1109
|
+
this.code = "ZAPIER_CONFIGURATION_ERROR";
|
|
1110
|
+
this.configType = options.configType;
|
|
1111
|
+
}
|
|
1112
|
+
};
|
|
1113
|
+
var ZapierBundleError = class extends ZapierError {
|
|
1114
|
+
constructor(message, options = {}) {
|
|
1115
|
+
super(message, options);
|
|
1116
|
+
this.name = "ZapierBundleError";
|
|
1117
|
+
this.code = "ZAPIER_BUNDLE_ERROR";
|
|
1118
|
+
this.buildErrors = options.buildErrors;
|
|
1119
|
+
}
|
|
1120
|
+
};
|
|
1121
|
+
var ZapierTimeoutError = class extends ZapierError {
|
|
1122
|
+
constructor(message, options = {}) {
|
|
1123
|
+
super(message, options);
|
|
1124
|
+
this.name = "ZapierTimeoutError";
|
|
1125
|
+
this.code = "ZAPIER_TIMEOUT_ERROR";
|
|
1126
|
+
this.attempts = options.attempts;
|
|
1127
|
+
this.maxAttempts = options.maxAttempts;
|
|
1128
|
+
}
|
|
1129
|
+
};
|
|
1130
|
+
var ZapierActionError = class extends ZapierError {
|
|
1131
|
+
constructor(message, options = {}) {
|
|
1132
|
+
super(message, options);
|
|
1133
|
+
this.name = "ZapierActionError";
|
|
1134
|
+
this.code = "ZAPIER_ACTION_ERROR";
|
|
1135
|
+
this.appKey = options.appKey;
|
|
1136
|
+
this.actionKey = options.actionKey;
|
|
1137
|
+
}
|
|
1138
|
+
// Legacy accessor for backward compatibility
|
|
1139
|
+
get actionErrors() {
|
|
1140
|
+
return this.errors;
|
|
1141
|
+
}
|
|
1142
|
+
};
|
|
1143
|
+
var ZapierConflictError = class extends ZapierError {
|
|
1144
|
+
constructor(message, options = {}) {
|
|
1145
|
+
super(message, options);
|
|
1146
|
+
this.name = "ZapierConflictError";
|
|
1147
|
+
this.code = "ZAPIER_CONFLICT_ERROR";
|
|
1148
|
+
this.resourceType = options.resourceType;
|
|
1149
|
+
}
|
|
1150
|
+
};
|
|
1151
|
+
var ZapierRateLimitError = class extends ZapierError {
|
|
1152
|
+
constructor(message, options = {}) {
|
|
1153
|
+
super(message, options);
|
|
1154
|
+
this.name = "ZapierRateLimitError";
|
|
1155
|
+
this.code = "ZAPIER_RATE_LIMIT_ERROR";
|
|
1156
|
+
this.rateLimit = options.rateLimit ?? {};
|
|
1157
|
+
this.retries = options.retries ?? 0;
|
|
1158
|
+
}
|
|
1159
|
+
};
|
|
1160
|
+
var ZapierApprovalError = class extends ZapierError {
|
|
1161
|
+
constructor(message, options = {}) {
|
|
1162
|
+
super(message, options);
|
|
1163
|
+
this.name = "ZapierApprovalError";
|
|
1164
|
+
this.code = "ZAPIER_APPROVAL_ERROR";
|
|
1165
|
+
this.approvalId = options.approvalId;
|
|
1166
|
+
this.approvalStatus = options.status;
|
|
1167
|
+
this.approvalUrl = options.approvalUrl;
|
|
1168
|
+
this.pollUrl = options.pollUrl;
|
|
1169
|
+
}
|
|
1170
|
+
};
|
|
1171
|
+
var ZapierRelayError = class extends ZapierError {
|
|
1172
|
+
constructor(message, options = {}) {
|
|
1173
|
+
super(message, options);
|
|
1174
|
+
this.name = "ZapierRelayError";
|
|
1175
|
+
this.code = "ZAPIER_RELAY_ERROR";
|
|
1176
|
+
}
|
|
1177
|
+
};
|
|
1178
|
+
function formatErrorMessage(error) {
|
|
1179
|
+
let message = error.message;
|
|
1180
|
+
if (error.errors && error.errors.length > 0) {
|
|
1181
|
+
const additionalErrors = error.errors.slice(1);
|
|
1182
|
+
if (additionalErrors.length > 0) {
|
|
1183
|
+
const errorDetails = additionalErrors.map((err) => ` \u2022 ${err.detail || err.title || err.code}`).join("\n");
|
|
1184
|
+
message += "\n\nAdditional errors:\n" + errorDetails;
|
|
1185
|
+
}
|
|
1186
|
+
}
|
|
1187
|
+
if (error instanceof ZapierAppNotFoundError && error.appKey) {
|
|
1188
|
+
message += `
|
|
1189
|
+
App key: ${error.appKey}`;
|
|
1190
|
+
}
|
|
1191
|
+
if (error instanceof ZapierActionError && (error.appKey || error.actionKey)) {
|
|
1192
|
+
const context = [];
|
|
1193
|
+
if (error.appKey) context.push(`App: ${error.appKey}`);
|
|
1194
|
+
if (error.actionKey) context.push(`Action: ${error.actionKey}`);
|
|
1195
|
+
message += `
|
|
1196
|
+
${context.join(", ")}`;
|
|
1197
|
+
}
|
|
1198
|
+
if (error instanceof ZapierResourceNotFoundError && (error.resourceType || error.resourceId)) {
|
|
1199
|
+
const context = [];
|
|
1200
|
+
if (error.resourceType) context.push(`Type: ${error.resourceType}`);
|
|
1201
|
+
if (error.resourceId) context.push(`ID: ${error.resourceId}`);
|
|
1202
|
+
message += `
|
|
1203
|
+
${context.join(", ")}`;
|
|
1204
|
+
}
|
|
1205
|
+
if (error instanceof ZapierConflictError && error.resourceType) {
|
|
1206
|
+
message += `
|
|
1207
|
+
Type: ${error.resourceType}`;
|
|
1208
|
+
}
|
|
1209
|
+
if (error instanceof ZapierTimeoutError && (error.attempts || error.maxAttempts)) {
|
|
1210
|
+
const context = [];
|
|
1211
|
+
if (error.attempts) context.push(`Attempts: ${error.attempts}`);
|
|
1212
|
+
if (error.maxAttempts) context.push(`Max attempts: ${error.maxAttempts}`);
|
|
1213
|
+
message += `
|
|
1214
|
+
${context.join(", ")}`;
|
|
1215
|
+
}
|
|
1216
|
+
if (error instanceof ZapierBundleError && error.buildErrors && error.buildErrors.length > 0) {
|
|
1217
|
+
message += "\n\nBuild errors:\n" + error.buildErrors.map((err) => ` \u2022 ${err}`).join("\n");
|
|
1218
|
+
}
|
|
1219
|
+
if (error instanceof ZapierApprovalError && error.approvalUrl) {
|
|
1220
|
+
message += `
|
|
1221
|
+
Approval URL: ${error.approvalUrl}`;
|
|
1222
|
+
}
|
|
1223
|
+
if (error instanceof ZapierRateLimitError) {
|
|
1224
|
+
const { limit, remaining, retryAfterMs } = error.rateLimit;
|
|
1225
|
+
const parts = [];
|
|
1226
|
+
if (limit !== void 0) {
|
|
1227
|
+
const used = remaining !== void 0 ? limit - remaining : limit;
|
|
1228
|
+
parts.push(`${used}/${limit} used`);
|
|
1229
|
+
}
|
|
1230
|
+
if (retryAfterMs !== void 0 && retryAfterMs > 0) {
|
|
1231
|
+
parts.push(`retry in ${formatDuration(retryAfterMs)}`);
|
|
1112
1232
|
}
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
}
|
|
1117
|
-
function mergeMetaKeysWithCollisionCheck(target, source, seen) {
|
|
1118
|
-
for (const key of Object.keys(source)) {
|
|
1119
|
-
if (seen.has(key)) {
|
|
1120
|
-
throw new Error(
|
|
1121
|
-
`composePlugins: duplicate context.meta key "${key}". Two sub-plugins registered metadata for the same name.`
|
|
1233
|
+
if (error.retries > 0) {
|
|
1234
|
+
parts.push(
|
|
1235
|
+
`after ${error.retries} retr${error.retries === 1 ? "y" : "ies"}`
|
|
1122
1236
|
);
|
|
1123
1237
|
}
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
}
|
|
1128
|
-
function mergeContextKeysWithCollisionCheck(target, source, seen) {
|
|
1129
|
-
for (const key of Object.keys(source)) {
|
|
1130
|
-
if (seen.has(key)) {
|
|
1131
|
-
throw new Error(
|
|
1132
|
-
`composePlugins: duplicate context key "${key}". Two sub-plugins contributed the same context.${key} field.`
|
|
1133
|
-
);
|
|
1238
|
+
if (parts.length > 0) {
|
|
1239
|
+
message += `
|
|
1240
|
+
${parts.join(", ")}`;
|
|
1134
1241
|
}
|
|
1135
|
-
seen.add(key);
|
|
1136
|
-
target[key] = source[key];
|
|
1137
1242
|
}
|
|
1243
|
+
if (error.statusCode && !message.includes(`${error.statusCode}`)) {
|
|
1244
|
+
message += `
|
|
1245
|
+
HTTP Status: ${error.statusCode}`;
|
|
1246
|
+
}
|
|
1247
|
+
return message;
|
|
1138
1248
|
}
|
|
1139
|
-
function
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
if (context) {
|
|
1149
|
-
const { meta, ...nonMetaContext } = context;
|
|
1150
|
-
if (meta) {
|
|
1151
|
-
mergeMetaKeysWithCollisionCheck(merged.context.meta, meta, seenMeta);
|
|
1152
|
-
}
|
|
1153
|
-
mergeContextKeysWithCollisionCheck(
|
|
1154
|
-
merged.context,
|
|
1155
|
-
nonMetaContext,
|
|
1156
|
-
seenContext
|
|
1157
|
-
);
|
|
1158
|
-
}
|
|
1159
|
-
}
|
|
1160
|
-
return merged;
|
|
1161
|
-
};
|
|
1249
|
+
function formatDuration(ms) {
|
|
1250
|
+
const seconds = Math.round(ms / 1e3);
|
|
1251
|
+
if (seconds < 60) return `${seconds}s`;
|
|
1252
|
+
const minutes = Math.round(seconds / 60);
|
|
1253
|
+
if (minutes < 60) return `${minutes}m`;
|
|
1254
|
+
const hours = Math.round(minutes / 60);
|
|
1255
|
+
if (hours < 24) return `${hours}h`;
|
|
1256
|
+
const days = Math.round(hours / 24);
|
|
1257
|
+
return `${days}d`;
|
|
1162
1258
|
}
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1259
|
+
|
|
1260
|
+
// src/core-stack.ts
|
|
1261
|
+
var zapierCorePlugin = createCorePlugin({
|
|
1262
|
+
adaptError: zapierAdaptError
|
|
1263
|
+
});
|
|
1264
|
+
function createZapierCoreStack() {
|
|
1265
|
+
return createPluginStack().use(zapierCorePlugin);
|
|
1266
|
+
}
|
|
1267
|
+
|
|
1268
|
+
// src/constants.ts
|
|
1269
|
+
var ZAPIER_BASE_URL = globalThis.process?.env?.ZAPIER_BASE_URL || "https://zapier.com";
|
|
1270
|
+
function getZapierSdkService() {
|
|
1271
|
+
return globalThis.process?.env?.ZAPIER_SDK_SERVICE;
|
|
1272
|
+
}
|
|
1273
|
+
var MAX_PAGE_LIMIT = 1e4;
|
|
1274
|
+
var DEFAULT_PAGE_SIZE = 100;
|
|
1275
|
+
var DEFAULT_ACTION_TIMEOUT_MS = 18e4;
|
|
1276
|
+
function parseIntEnvVar(name) {
|
|
1277
|
+
const value = globalThis.process?.env?.[name];
|
|
1278
|
+
if (value === void 0) return void 0;
|
|
1279
|
+
const parsed = parseInt(value, 10);
|
|
1280
|
+
if (isNaN(parsed)) {
|
|
1281
|
+
console.warn(
|
|
1282
|
+
`[zapier-sdk] Invalid value for ${name}: "${value}" (expected integer)`
|
|
1283
|
+
);
|
|
1284
|
+
return void 0;
|
|
1285
|
+
}
|
|
1286
|
+
return parsed;
|
|
1287
|
+
}
|
|
1288
|
+
var ZAPIER_MAX_NETWORK_RETRIES = parseIntEnvVar("ZAPIER_MAX_NETWORK_RETRIES") ?? 3;
|
|
1289
|
+
var ZAPIER_MAX_NETWORK_RETRY_DELAY_MS = parseIntEnvVar("ZAPIER_MAX_NETWORK_RETRY_DELAY_MS") ?? 6e4;
|
|
1290
|
+
var MAX_CONCURRENCY_LIMIT = 1e4;
|
|
1291
|
+
function parseConcurrencyEnvVar(name) {
|
|
1292
|
+
const value = globalThis.process?.env?.[name];
|
|
1293
|
+
if (!value) return void 0;
|
|
1294
|
+
if (value === "Infinity") return Infinity;
|
|
1295
|
+
if (/^[1-9]\d*$/.test(value)) {
|
|
1296
|
+
const parsed = parseInt(value, 10);
|
|
1297
|
+
if (parsed <= MAX_CONCURRENCY_LIMIT) return parsed;
|
|
1167
1298
|
}
|
|
1299
|
+
console.warn(
|
|
1300
|
+
`[zapier-sdk] Invalid value for ${name}: "${value}" (expected positive integer 1-${MAX_CONCURRENCY_LIMIT} or "Infinity")`
|
|
1301
|
+
);
|
|
1168
1302
|
return void 0;
|
|
1169
1303
|
}
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
const
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
details: []
|
|
1181
|
-
// Not used when data is provided
|
|
1182
|
-
};
|
|
1304
|
+
var ZAPIER_MAX_CONCURRENT_REQUESTS = parseConcurrencyEnvVar("ZAPIER_MAX_CONCURRENT_REQUESTS") ?? 200;
|
|
1305
|
+
function getZapierApprovalMode() {
|
|
1306
|
+
const value = globalThis.process?.env?.ZAPIER_APPROVAL_MODE;
|
|
1307
|
+
if (value === "disabled" || value === "poll" || value === "throw")
|
|
1308
|
+
return value;
|
|
1309
|
+
return void 0;
|
|
1310
|
+
}
|
|
1311
|
+
function getZapierDefaultApprovalMode() {
|
|
1312
|
+
const isInteractive = !!globalThis.process?.stdin?.isTTY && !!globalThis.process?.stdout?.isTTY;
|
|
1313
|
+
return isInteractive ? "poll" : "throw";
|
|
1183
1314
|
}
|
|
1184
|
-
var
|
|
1185
|
-
|
|
1186
|
-
|
|
1315
|
+
var DEFAULT_APPROVAL_TIMEOUT_MS = 10 * 60 * 1e3;
|
|
1316
|
+
var DEFAULT_MAX_APPROVAL_RETRIES = 2;
|
|
1317
|
+
|
|
1318
|
+
// src/types/properties.ts
|
|
1319
|
+
var AppKeyPropertySchema = withPositional(
|
|
1320
|
+
z.string().min(1).describe("App key (e.g., 'SlackCLIAPI' or slug like 'github')")
|
|
1321
|
+
);
|
|
1322
|
+
var AppPropertySchema = withPositional(
|
|
1323
|
+
z.string().min(1).describe(
|
|
1324
|
+
"App slug (e.g., 'github'), implementation name (e.g., 'SlackCLIAPI'), or versioned ID (e.g., 'github@1.2.3')"
|
|
1325
|
+
)
|
|
1326
|
+
);
|
|
1327
|
+
var ActionTypePropertySchema = z.enum([
|
|
1328
|
+
"read",
|
|
1329
|
+
"read_bulk",
|
|
1330
|
+
"write",
|
|
1331
|
+
"run",
|
|
1332
|
+
"search",
|
|
1333
|
+
"search_or_write",
|
|
1334
|
+
"search_and_write",
|
|
1335
|
+
"filter"
|
|
1336
|
+
]).describe("Action type that matches the action's defined type");
|
|
1337
|
+
var ActionKeyPropertySchema = z.string().min(1).describe("Action key to execute");
|
|
1338
|
+
var ActionPropertySchema = withPositional(
|
|
1339
|
+
z.string().min(1).describe("Action key (e.g., 'send_message' or 'find_row')")
|
|
1340
|
+
);
|
|
1341
|
+
var InputFieldPropertySchema = withPositional(
|
|
1342
|
+
z.string().min(1).describe("Input field key to get choices for")
|
|
1343
|
+
);
|
|
1344
|
+
var ConnectionIdPropertySchema = z.union([z.string(), z.number().int().positive()]).describe("Connection ID to use for this action");
|
|
1345
|
+
var AuthenticationIdPropertySchema = ConnectionIdPropertySchema.meta({
|
|
1346
|
+
deprecated: true
|
|
1347
|
+
});
|
|
1348
|
+
var ConnectionPropertySchema = z.union([z.string(), z.number().int().positive()]).describe(
|
|
1349
|
+
"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."
|
|
1350
|
+
);
|
|
1351
|
+
var InputsPropertySchema = z.record(z.string(), z.unknown()).describe("Input parameters for the action");
|
|
1352
|
+
var LimitPropertySchema = z.number().int().min(1).max(MAX_PAGE_LIMIT).default(50).describe("Maximum number of items to return");
|
|
1353
|
+
var OffsetPropertySchema = z.number().int().min(0).default(0).describe("Number of items to skip for pagination");
|
|
1354
|
+
var OutputPropertySchema = z.string().describe("Output file path");
|
|
1355
|
+
var DebugPropertySchema = z.boolean().default(false).describe("Enable debug logging");
|
|
1356
|
+
var ParamsPropertySchema = z.record(z.string(), z.unknown()).describe("Additional parameters");
|
|
1357
|
+
var ActionTimeoutMsPropertySchema = z.number().min(1e3).optional().describe(
|
|
1358
|
+
`Maximum time to wait for action completion in milliseconds (default: ${DEFAULT_ACTION_TIMEOUT_MS})`
|
|
1359
|
+
);
|
|
1360
|
+
var TablePropertySchema = withPositional(
|
|
1361
|
+
z.string().regex(/^[A-Z0-9]{26}$/, "Table ID must be a valid ULID").describe("The unique identifier of the table")
|
|
1362
|
+
);
|
|
1363
|
+
var RecordPropertySchema = withPositional(
|
|
1364
|
+
z.string().regex(/^[A-Z0-9]{26}$/, "Record ID must be a valid ULID").describe("The unique identifier of the record")
|
|
1365
|
+
);
|
|
1366
|
+
var RecordsPropertySchema = z.array(z.string().regex(/^[A-Z0-9]{26}$/, "Record ID must be a valid ULID")).min(1).max(100).describe("Record IDs to operate on");
|
|
1367
|
+
var FieldsPropertySchema = z.array(z.union([z.string(), z.number()])).describe(
|
|
1368
|
+
'Fields to operate on. Accepts field names (e.g., "Email") or IDs (e.g., "f6", "6", or 6).'
|
|
1369
|
+
);
|
|
1370
|
+
var AppsPropertySchema = z.array(z.string()).describe("Filter by app keys (e.g., 'SlackCLIAPI' or slug like 'github')");
|
|
1371
|
+
var TablesPropertySchema = z.array(z.string()).describe("Filter by specific table IDs");
|
|
1372
|
+
var ConnectionsPropertySchema = z.array(z.string()).describe("List of connection IDs to filter by");
|
|
1373
|
+
var TriggerInboxPropertySchema = withPositional(
|
|
1374
|
+
z.string().min(1).describe(
|
|
1375
|
+
"Trigger inbox identifier \u2014 UUID or name. Non-UUID values are resolved by name via the inbox list endpoint."
|
|
1376
|
+
)
|
|
1377
|
+
);
|
|
1378
|
+
var TriggerInboxNamePropertySchema = z.string().min(1).max(100).describe(
|
|
1379
|
+
"Inbox name; unique per (user, account). Enables get-or-create on createTriggerInbox."
|
|
1380
|
+
);
|
|
1381
|
+
var LeasePropertySchema = z.string().min(1).describe("Lease ID returned from leaseTriggerInboxMessages");
|
|
1382
|
+
var LeaseSecondsPropertySchema = z.number().int().min(1).max(3600).describe(
|
|
1383
|
+
"Seconds until the lease expires; messages return to available if not acked. API default is 300 (5 minutes)."
|
|
1187
1384
|
);
|
|
1385
|
+
var LeaseLimitPropertySchema = z.number().int().min(1).max(100).describe("Maximum messages to lease in a single batch (1-100)");
|
|
1386
|
+
|
|
1387
|
+
// src/plugins/apps/schemas.ts
|
|
1388
|
+
var ActionExecutionInputSchema = z.object({
|
|
1389
|
+
inputs: z.record(z.string(), z.unknown()).optional(),
|
|
1390
|
+
/** @deprecated Use `connection` instead. */
|
|
1391
|
+
connectionId: ConnectionIdPropertySchema.optional().meta({
|
|
1392
|
+
deprecated: true
|
|
1393
|
+
}),
|
|
1394
|
+
connection: ConnectionPropertySchema.optional(),
|
|
1395
|
+
/** @deprecated Use connection instead */
|
|
1396
|
+
authenticationId: AuthenticationIdPropertySchema.optional().meta({
|
|
1397
|
+
deprecated: true
|
|
1398
|
+
}),
|
|
1399
|
+
timeoutMs: ActionTimeoutMsPropertySchema
|
|
1400
|
+
}).describe(
|
|
1401
|
+
"Execute an action with the given inputs for the bound app, as an alternative to runAction"
|
|
1402
|
+
).meta({
|
|
1403
|
+
aliases: { connectionId: "connection", authenticationId: "connection" }
|
|
1404
|
+
});
|
|
1405
|
+
var AppFactoryInputSchema = z.object({
|
|
1406
|
+
/** @deprecated Use `connection` instead. */
|
|
1407
|
+
connectionId: ConnectionIdPropertySchema.optional().meta({
|
|
1408
|
+
deprecated: true
|
|
1409
|
+
}),
|
|
1410
|
+
connection: ConnectionPropertySchema.optional(),
|
|
1411
|
+
/** @deprecated Use connection instead */
|
|
1412
|
+
authenticationId: AuthenticationIdPropertySchema.optional().meta({
|
|
1413
|
+
deprecated: true
|
|
1414
|
+
})
|
|
1415
|
+
}).describe("Bind a connection alias or numeric connectionId to an app").meta({
|
|
1416
|
+
aliases: { connectionId: "connection", authenticationId: "connection" }
|
|
1417
|
+
});
|
|
1418
|
+
var ActionResultItemSchema = z.unknown().describe("Action execution result");
|
|
1188
1419
|
|
|
1189
1420
|
// src/plugins/apps/index.ts
|
|
1190
1421
|
function resolveProxyConnection({
|
|
@@ -1405,18 +1636,6 @@ var FetchInitSchema = z.object({
|
|
|
1405
1636
|
aliases: { connectionId: "connection", authenticationId: "connection" }
|
|
1406
1637
|
});
|
|
1407
1638
|
|
|
1408
|
-
// src/utils/string-utils.ts
|
|
1409
|
-
function toTitleCase(input) {
|
|
1410
|
-
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(" ");
|
|
1411
|
-
}
|
|
1412
|
-
function toSnakeCase(input) {
|
|
1413
|
-
let result = input.replace(/([a-z0-9])([A-Z])/g, "$1_$2").replace(/[\s\-]+/g, "_").replace(/_+/g, "_").replace(/^_|_$/g, "").toLowerCase();
|
|
1414
|
-
if (/^[0-9]/.test(result)) {
|
|
1415
|
-
result = "_" + result;
|
|
1416
|
-
}
|
|
1417
|
-
return result;
|
|
1418
|
-
}
|
|
1419
|
-
|
|
1420
1639
|
// src/utils/domain-utils.ts
|
|
1421
1640
|
function isConnectionId(value) {
|
|
1422
1641
|
return /^\d+$/.test(value) || isUuid(value);
|
|
@@ -1719,15 +1938,25 @@ function buildAbortHandle({
|
|
|
1719
1938
|
return combineAbortSignals({ handles });
|
|
1720
1939
|
}
|
|
1721
1940
|
var FetchInitSdkValidationSchema = z.looseObject(FetchInitZapierFieldsSchema.shape).optional();
|
|
1722
|
-
var validateFetchInit = createValidator(FetchInitSdkValidationSchema);
|
|
1723
1941
|
var fetchPlugin = definePlugin(
|
|
1724
1942
|
(sdk) => {
|
|
1943
|
+
const validateFetchInit = createValidator(FetchInitSdkValidationSchema, {
|
|
1944
|
+
adaptError: sdk.context.core?.adaptError
|
|
1945
|
+
});
|
|
1725
1946
|
return {
|
|
1726
1947
|
fetch: async function fetch2(url, init) {
|
|
1727
|
-
return
|
|
1948
|
+
return runInMethodScope(async () => {
|
|
1728
1949
|
const { api } = sdk.context;
|
|
1950
|
+
const { onMethodStart, onMethodEnd } = sdk.context.hooks;
|
|
1729
1951
|
const startTime = Date.now();
|
|
1730
|
-
const
|
|
1952
|
+
const depth = getCurrentDepth();
|
|
1953
|
+
const args = init === void 0 ? [url] : [url, init];
|
|
1954
|
+
onMethodStart?.({
|
|
1955
|
+
methodName: "fetch",
|
|
1956
|
+
args,
|
|
1957
|
+
isPaginated: false,
|
|
1958
|
+
depth
|
|
1959
|
+
});
|
|
1731
1960
|
try {
|
|
1732
1961
|
if (init) {
|
|
1733
1962
|
validateFetchInit(init);
|
|
@@ -1799,17 +2028,13 @@ var fetchPlugin = definePlugin(
|
|
|
1799
2028
|
statusCode: result.status
|
|
1800
2029
|
});
|
|
1801
2030
|
}
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
argument_count: init ? 2 : 1,
|
|
1810
|
-
is_paginated: false
|
|
1811
|
-
});
|
|
1812
|
-
}
|
|
2031
|
+
onMethodEnd?.({
|
|
2032
|
+
methodName: "fetch",
|
|
2033
|
+
args,
|
|
2034
|
+
isPaginated: false,
|
|
2035
|
+
depth,
|
|
2036
|
+
durationMs: Date.now() - startTime
|
|
2037
|
+
});
|
|
1813
2038
|
return result;
|
|
1814
2039
|
} catch (error) {
|
|
1815
2040
|
throw rewrapIfMaxTimeTimeout({
|
|
@@ -1821,17 +2046,14 @@ var fetchPlugin = definePlugin(
|
|
|
1821
2046
|
abortHandle?.dispose();
|
|
1822
2047
|
}
|
|
1823
2048
|
} catch (error) {
|
|
1824
|
-
|
|
1825
|
-
|
|
1826
|
-
|
|
1827
|
-
|
|
1828
|
-
|
|
1829
|
-
|
|
1830
|
-
|
|
1831
|
-
|
|
1832
|
-
is_paginated: false
|
|
1833
|
-
});
|
|
1834
|
-
}
|
|
2049
|
+
onMethodEnd?.({
|
|
2050
|
+
methodName: "fetch",
|
|
2051
|
+
args,
|
|
2052
|
+
isPaginated: false,
|
|
2053
|
+
depth,
|
|
2054
|
+
durationMs: Date.now() - startTime,
|
|
2055
|
+
error: error instanceof Error ? error : new Error(String(error))
|
|
2056
|
+
});
|
|
1835
2057
|
throw error;
|
|
1836
2058
|
}
|
|
1837
2059
|
});
|
|
@@ -1841,7 +2063,11 @@ var fetchPlugin = definePlugin(
|
|
|
1841
2063
|
fetch: {
|
|
1842
2064
|
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.",
|
|
1843
2065
|
packages: ["sdk", "cli", "mcp"],
|
|
1844
|
-
|
|
2066
|
+
// Auto-derive would produce "Http"/"Https" from the key alone;
|
|
2067
|
+
// declare the title explicitly here so the registry renders
|
|
2068
|
+
// "HTTP Request". Other plugins in this category use the bare
|
|
2069
|
+
// string "http"; the object form wins regardless of order.
|
|
2070
|
+
categories: [{ key: "http", title: "HTTP Request" }],
|
|
1845
2071
|
returnType: "Response",
|
|
1846
2072
|
inputParameters: [
|
|
1847
2073
|
{ name: "url", schema: FetchUrlSchema },
|
|
@@ -1930,7 +2156,7 @@ function createDebugLogger(enabled) {
|
|
|
1930
2156
|
}
|
|
1931
2157
|
return (message, data) => {
|
|
1932
2158
|
if (data === void 0 || data === "") {
|
|
1933
|
-
console.
|
|
2159
|
+
console.error(`[Zapier SDK] ${message}`);
|
|
1934
2160
|
return;
|
|
1935
2161
|
}
|
|
1936
2162
|
if (utilModule) {
|
|
@@ -1939,9 +2165,9 @@ function createDebugLogger(enabled) {
|
|
|
1939
2165
|
depth: null,
|
|
1940
2166
|
breakLength: 80
|
|
1941
2167
|
});
|
|
1942
|
-
console.
|
|
2168
|
+
console.error(`[Zapier SDK] ${message}`, formatted);
|
|
1943
2169
|
} else {
|
|
1944
|
-
console.
|
|
2170
|
+
console.error(`[Zapier SDK] ${message}`, data);
|
|
1945
2171
|
}
|
|
1946
2172
|
};
|
|
1947
2173
|
}
|
|
@@ -2140,7 +2366,8 @@ async function pollUntilComplete(options) {
|
|
|
2140
2366
|
pendingStatus = DEFAULT_PENDING_STATUS,
|
|
2141
2367
|
isPending,
|
|
2142
2368
|
resultExtractor = (response) => response,
|
|
2143
|
-
signal
|
|
2369
|
+
signal,
|
|
2370
|
+
maxPollingIntervalMs
|
|
2144
2371
|
} = options;
|
|
2145
2372
|
if (timeoutMs <= 0) {
|
|
2146
2373
|
throw new ZapierValidationError("Timeout must be greater than 0", {
|
|
@@ -2152,6 +2379,14 @@ async function pollUntilComplete(options) {
|
|
|
2152
2379
|
details: { initialDelay }
|
|
2153
2380
|
});
|
|
2154
2381
|
}
|
|
2382
|
+
if (maxPollingIntervalMs !== void 0 && maxPollingIntervalMs <= 0) {
|
|
2383
|
+
throw new ZapierValidationError(
|
|
2384
|
+
"Max polling interval must be greater than 0",
|
|
2385
|
+
{
|
|
2386
|
+
details: { maxPollingIntervalMs }
|
|
2387
|
+
}
|
|
2388
|
+
);
|
|
2389
|
+
}
|
|
2155
2390
|
if (signal?.aborted) throw makeAbortError();
|
|
2156
2391
|
const startTime = Date.now();
|
|
2157
2392
|
let attempts = 0;
|
|
@@ -2174,7 +2409,8 @@ async function pollUntilComplete(options) {
|
|
|
2174
2409
|
if (attempts > 0) {
|
|
2175
2410
|
const interval = getPollingInterval(elapsedTime);
|
|
2176
2411
|
const waitTime = calculateErrorBackoffMs(interval, errorCount);
|
|
2177
|
-
|
|
2412
|
+
const cappedWaitTime = maxPollingIntervalMs === void 0 ? waitTime : Math.min(waitTime, maxPollingIntervalMs);
|
|
2413
|
+
await sleep(cappedWaitTime, signal);
|
|
2178
2414
|
if (signal?.aborted) throw makeAbortError();
|
|
2179
2415
|
}
|
|
2180
2416
|
attempts++;
|
|
@@ -2457,17 +2693,17 @@ function resolveCredentialsFromEnv(sdkBaseUrl) {
|
|
|
2457
2693
|
}
|
|
2458
2694
|
}
|
|
2459
2695
|
if (globalThis.process?.env?.ZAPIER_TOKEN) {
|
|
2460
|
-
|
|
2696
|
+
logDeprecation2(
|
|
2461
2697
|
"ZAPIER_TOKEN is deprecated. Use ZAPIER_CREDENTIALS instead."
|
|
2462
2698
|
);
|
|
2463
2699
|
return globalThis.process?.env?.ZAPIER_TOKEN;
|
|
2464
2700
|
}
|
|
2465
2701
|
if (globalThis.process?.env?.ZAPIER_AUTH_CLIENT_ID) {
|
|
2466
|
-
|
|
2702
|
+
logDeprecation2(
|
|
2467
2703
|
"ZAPIER_AUTH_CLIENT_ID is deprecated. Use ZAPIER_CREDENTIALS_CLIENT_ID instead."
|
|
2468
2704
|
);
|
|
2469
2705
|
if (globalThis.process?.env?.ZAPIER_AUTH_BASE_URL) {
|
|
2470
|
-
|
|
2706
|
+
logDeprecation2(
|
|
2471
2707
|
"ZAPIER_AUTH_BASE_URL is deprecated. Use ZAPIER_CREDENTIALS_BASE_URL instead."
|
|
2472
2708
|
);
|
|
2473
2709
|
}
|
|
@@ -2501,7 +2737,7 @@ async function resolveCredentials(options = {}) {
|
|
|
2501
2737
|
return options.credentials;
|
|
2502
2738
|
}
|
|
2503
2739
|
if (options.token !== void 0) {
|
|
2504
|
-
|
|
2740
|
+
logDeprecation2(
|
|
2505
2741
|
"The `token` option is deprecated. Use `credentials` instead."
|
|
2506
2742
|
);
|
|
2507
2743
|
return options.token;
|
|
@@ -2743,7 +2979,7 @@ async function tryStoredClientCredentialToken(options) {
|
|
|
2743
2979
|
const cached = await readCachedToken(cacheKey, cache);
|
|
2744
2980
|
if (cached !== void 0) {
|
|
2745
2981
|
if (options.debug)
|
|
2746
|
-
console.
|
|
2982
|
+
console.error(
|
|
2747
2983
|
`[auth] Using cached token (clientId: ${activeCredential.clientId})`
|
|
2748
2984
|
);
|
|
2749
2985
|
emitAuthResolved(options.onEvent, "client_credentials");
|
|
@@ -2762,7 +2998,7 @@ async function tryStoredClientCredentialToken(options) {
|
|
|
2762
2998
|
);
|
|
2763
2999
|
}
|
|
2764
3000
|
if (options.debug)
|
|
2765
|
-
console.
|
|
3001
|
+
console.error(
|
|
2766
3002
|
`[auth] Using stored client credential (clientId: ${storedCredential.clientId})`
|
|
2767
3003
|
);
|
|
2768
3004
|
const token = await resolveAuthTokenFromCredentials(
|
|
@@ -2784,7 +3020,7 @@ async function resolveAuthToken(options = {}) {
|
|
|
2784
3020
|
const storedToken = await tryStoredClientCredentialToken(options);
|
|
2785
3021
|
if (storedToken !== void 0) return storedToken;
|
|
2786
3022
|
if (options.debug) {
|
|
2787
|
-
console.
|
|
3023
|
+
console.error("[auth] Using JWT (no stored client credential found)");
|
|
2788
3024
|
}
|
|
2789
3025
|
const jwtToken = await getTokenFromCliLogin({
|
|
2790
3026
|
onEvent: options.onEvent,
|
|
@@ -2814,7 +3050,7 @@ async function resolveAuthTokenFromCredentials(credentials, options) {
|
|
|
2814
3050
|
const cached = await readCachedToken(cacheKey, cache);
|
|
2815
3051
|
if (cached !== void 0) {
|
|
2816
3052
|
if (options.debug) {
|
|
2817
|
-
console.
|
|
3053
|
+
console.error(`[auth] Using cached token (clientId: ${clientId})`);
|
|
2818
3054
|
}
|
|
2819
3055
|
return cached;
|
|
2820
3056
|
}
|
|
@@ -2824,7 +3060,7 @@ async function resolveAuthTokenFromCredentials(credentials, options) {
|
|
|
2824
3060
|
const recheck = await readCachedToken(cacheKey, cache);
|
|
2825
3061
|
if (recheck !== void 0) {
|
|
2826
3062
|
if (options.debug) {
|
|
2827
|
-
console.
|
|
3063
|
+
console.error(
|
|
2828
3064
|
`[auth] Using cached token (clientId: ${clientId}, locked recheck)`
|
|
2829
3065
|
);
|
|
2830
3066
|
}
|
|
@@ -2887,7 +3123,7 @@ async function invalidateCredentialsToken(options) {
|
|
|
2887
3123
|
}
|
|
2888
3124
|
|
|
2889
3125
|
// src/sdk-version.ts
|
|
2890
|
-
var SDK_VERSION = (typeof process !== "undefined" && process.env ? "0.
|
|
3126
|
+
var SDK_VERSION = (typeof process !== "undefined" && process.env ? "0.67.0" : void 0) || "unknown";
|
|
2891
3127
|
|
|
2892
3128
|
// src/utils/open-url.ts
|
|
2893
3129
|
var nodePrefix = "node:";
|
|
@@ -2972,6 +3208,7 @@ var PollApprovalResponseSchema = z.object({
|
|
|
2972
3208
|
status: ApprovalStatusSchema,
|
|
2973
3209
|
approval_id: z.string()
|
|
2974
3210
|
});
|
|
3211
|
+
var APPROVAL_MAX_POLLING_INTERVAL_MS = 5e3;
|
|
2975
3212
|
function parseRateLimitHeaders(response) {
|
|
2976
3213
|
const info = {};
|
|
2977
3214
|
const retryAfter = response.headers.get("retry-after");
|
|
@@ -3680,6 +3917,7 @@ var ZapierApiClient = class {
|
|
|
3680
3917
|
})
|
|
3681
3918
|
),
|
|
3682
3919
|
timeoutMs,
|
|
3920
|
+
maxPollingIntervalMs: APPROVAL_MAX_POLLING_INTERVAL_MS,
|
|
3683
3921
|
isPending: (body2) => {
|
|
3684
3922
|
const parsed = PollApprovalResponseSchema.safeParse(body2);
|
|
3685
3923
|
return parsed.success && parsed.data.status === "pending_approval";
|
|
@@ -3814,36 +4052,36 @@ var apiPlugin = definePlugin(
|
|
|
3814
4052
|
}
|
|
3815
4053
|
);
|
|
3816
4054
|
var GetProfileSchema = z.object({}).optional().describe("Get current user's profile information");
|
|
3817
|
-
var UserProfileItemSchema =
|
|
3818
|
-
z.
|
|
3819
|
-
|
|
3820
|
-
|
|
3821
|
-
|
|
3822
|
-
|
|
3823
|
-
|
|
3824
|
-
|
|
3825
|
-
|
|
3826
|
-
|
|
3827
|
-
|
|
3828
|
-
|
|
3829
|
-
|
|
3830
|
-
|
|
3831
|
-
|
|
3832
|
-
}
|
|
3833
|
-
|
|
3834
|
-
|
|
3835
|
-
|
|
3836
|
-
|
|
3837
|
-
|
|
3838
|
-
}
|
|
3839
|
-
return {
|
|
3840
|
-
title: item.full_name,
|
|
3841
|
-
id: item.id,
|
|
3842
|
-
details
|
|
3843
|
-
};
|
|
4055
|
+
var UserProfileItemSchema = z.object({
|
|
4056
|
+
id: z.string(),
|
|
4057
|
+
first_name: z.string(),
|
|
4058
|
+
last_name: z.string(),
|
|
4059
|
+
full_name: z.string(),
|
|
4060
|
+
email: z.string(),
|
|
4061
|
+
email_confirmed: z.boolean(),
|
|
4062
|
+
timezone: z.string()
|
|
4063
|
+
});
|
|
4064
|
+
|
|
4065
|
+
// src/formatters/userProfile.ts
|
|
4066
|
+
var userProfileItemFormatter = {
|
|
4067
|
+
format: (item) => {
|
|
4068
|
+
const details = [];
|
|
4069
|
+
if (item.email) {
|
|
4070
|
+
details.push({ text: item.email, style: "dim" });
|
|
4071
|
+
}
|
|
4072
|
+
if (item.timezone) {
|
|
4073
|
+
details.push({
|
|
4074
|
+
text: `Timezone: ${item.timezone}`,
|
|
4075
|
+
style: "accent"
|
|
4076
|
+
});
|
|
3844
4077
|
}
|
|
4078
|
+
return {
|
|
4079
|
+
title: item.full_name,
|
|
4080
|
+
id: item.id,
|
|
4081
|
+
details
|
|
4082
|
+
};
|
|
3845
4083
|
}
|
|
3846
|
-
|
|
4084
|
+
};
|
|
3847
4085
|
|
|
3848
4086
|
// src/plugins/getProfile/index.ts
|
|
3849
4087
|
var getProfilePlugin = definePlugin(
|
|
@@ -3854,6 +4092,7 @@ var getProfilePlugin = definePlugin(
|
|
|
3854
4092
|
itemType: "Profile",
|
|
3855
4093
|
inputSchema: GetProfileSchema,
|
|
3856
4094
|
outputSchema: UserProfileItemSchema,
|
|
4095
|
+
formatter: userProfileItemFormatter,
|
|
3857
4096
|
handler: async ({ sdk: sdk2 }) => {
|
|
3858
4097
|
const profile = await sdk2.context.api.get(
|
|
3859
4098
|
"/zapier/api/v4/profile/",
|
|
@@ -3873,6 +4112,29 @@ var getProfilePlugin = definePlugin(
|
|
|
3873
4112
|
}
|
|
3874
4113
|
})
|
|
3875
4114
|
);
|
|
4115
|
+
|
|
4116
|
+
// src/utils/pagination.ts
|
|
4117
|
+
function extractCursorFromUrl(url) {
|
|
4118
|
+
try {
|
|
4119
|
+
const params = new URL(url).searchParams;
|
|
4120
|
+
return params.get("offset") ?? params.get("cursor") ?? void 0;
|
|
4121
|
+
} catch {
|
|
4122
|
+
return void 0;
|
|
4123
|
+
}
|
|
4124
|
+
}
|
|
4125
|
+
function adaptZapierPage(response) {
|
|
4126
|
+
const r = response ?? {};
|
|
4127
|
+
const data = r.data;
|
|
4128
|
+
const linksNext = r.links?.next;
|
|
4129
|
+
if (typeof linksNext === "string") {
|
|
4130
|
+
return { data, nextCursor: extractCursorFromUrl(linksNext) };
|
|
4131
|
+
}
|
|
4132
|
+
if (typeof r.next === "string") {
|
|
4133
|
+
return { data, nextCursor: extractCursorFromUrl(r.next) };
|
|
4134
|
+
}
|
|
4135
|
+
return { data };
|
|
4136
|
+
}
|
|
4137
|
+
var zapierPagination = { adaptPage: adaptZapierPage };
|
|
3876
4138
|
var ListAppsSchema = ListAppsQuerySchema.omit({
|
|
3877
4139
|
offset: true,
|
|
3878
4140
|
app_keys: true,
|
|
@@ -3894,27 +4156,30 @@ var ListAppsSchema = ListAppsQuerySchema.omit({
|
|
|
3894
4156
|
// SDK specific property for pagination/iterable helpers
|
|
3895
4157
|
cursor: z.string().optional().describe("Cursor to start from")
|
|
3896
4158
|
}).describe("List all available apps with optional filtering");
|
|
3897
|
-
var AppItemSchema =
|
|
3898
|
-
|
|
3899
|
-
|
|
3900
|
-
|
|
3901
|
-
|
|
3902
|
-
|
|
3903
|
-
|
|
3904
|
-
|
|
3905
|
-
|
|
3906
|
-
|
|
3907
|
-
})
|
|
4159
|
+
var AppItemSchema = AppItemSchema$1;
|
|
4160
|
+
|
|
4161
|
+
// src/formatters/app.ts
|
|
4162
|
+
var appItemFormatter = {
|
|
4163
|
+
format: (item) => ({
|
|
4164
|
+
title: item.title,
|
|
4165
|
+
key: item.key,
|
|
4166
|
+
keys: getAppKeyList(item),
|
|
4167
|
+
description: item.description,
|
|
4168
|
+
details: []
|
|
4169
|
+
})
|
|
4170
|
+
};
|
|
3908
4171
|
|
|
3909
4172
|
// src/plugins/listApps/index.ts
|
|
3910
4173
|
var listAppsPlugin = definePlugin(
|
|
3911
4174
|
(sdk) => createPaginatedPluginMethod(sdk, {
|
|
4175
|
+
...zapierPagination,
|
|
3912
4176
|
name: "listApps",
|
|
3913
4177
|
categories: ["app"],
|
|
3914
4178
|
type: "list",
|
|
3915
4179
|
itemType: "App",
|
|
3916
4180
|
inputSchema: ListAppsSchema,
|
|
3917
4181
|
outputSchema: AppItemSchema,
|
|
4182
|
+
formatter: appItemFormatter,
|
|
3918
4183
|
defaultPageSize: DEFAULT_PAGE_SIZE,
|
|
3919
4184
|
handler: async ({ sdk: sdk2, options }) => {
|
|
3920
4185
|
const { api, resolveAppKeys: resolveAppKeys2 } = sdk2.context;
|
|
@@ -3954,8 +4219,7 @@ var listAppsPlugin = definePlugin(
|
|
|
3954
4219
|
...options.cursor && { offset: options.cursor }
|
|
3955
4220
|
}
|
|
3956
4221
|
});
|
|
3957
|
-
}
|
|
3958
|
-
extractCursor: (response) => extractCursor(response.links)
|
|
4222
|
+
}
|
|
3959
4223
|
})
|
|
3960
4224
|
);
|
|
3961
4225
|
var GetAppDescription = "Get detailed information about a specific app";
|
|
@@ -4172,7 +4436,7 @@ var inputFieldKeyResolver = {
|
|
|
4172
4436
|
type: "dynamic",
|
|
4173
4437
|
depends: ["app", "action", "actionType", "connection"],
|
|
4174
4438
|
fetch: async (sdk, resolvedParams) => {
|
|
4175
|
-
const fieldsResponse = await sdk.
|
|
4439
|
+
const fieldsResponse = await sdk.listActionInputFields({
|
|
4176
4440
|
app: resolvedParams.app,
|
|
4177
4441
|
action: resolvedParams.action,
|
|
4178
4442
|
actionType: resolvedParams.actionType,
|
|
@@ -4278,7 +4542,8 @@ var workflowIdResolver = {
|
|
|
4278
4542
|
name: "workflow",
|
|
4279
4543
|
message: "Select a workflow:",
|
|
4280
4544
|
choices: workflows.map((workflow) => ({
|
|
4281
|
-
name: workflow.
|
|
4545
|
+
name: workflow.name,
|
|
4546
|
+
hint: workflow.enabled ? void 0 : [workflow.id, "disabled"],
|
|
4282
4547
|
value: workflow.id
|
|
4283
4548
|
}))
|
|
4284
4549
|
})
|
|
@@ -4293,7 +4558,8 @@ var durableRunIdResolver = {
|
|
|
4293
4558
|
name: "run",
|
|
4294
4559
|
message: "Select a run:",
|
|
4295
4560
|
choices: runs.map((run) => ({
|
|
4296
|
-
name:
|
|
4561
|
+
name: run.id,
|
|
4562
|
+
hint: run.status,
|
|
4297
4563
|
value: run.id
|
|
4298
4564
|
}))
|
|
4299
4565
|
})
|
|
@@ -4303,11 +4569,7 @@ var durableRunIdResolver = {
|
|
|
4303
4569
|
var workflowVersionIdResolver = {
|
|
4304
4570
|
type: "dynamic",
|
|
4305
4571
|
depends: ["workflow"],
|
|
4306
|
-
fetch: async (sdk, params) => toIterable(
|
|
4307
|
-
sdk.listWorkflowVersions({
|
|
4308
|
-
workflow: params.workflow
|
|
4309
|
-
})
|
|
4310
|
-
),
|
|
4572
|
+
fetch: async (sdk, params) => toIterable(sdk.listWorkflowVersions({ workflow: params.workflow })),
|
|
4311
4573
|
prompt: (versions) => ({
|
|
4312
4574
|
type: "list",
|
|
4313
4575
|
name: "version",
|
|
@@ -4319,15 +4581,27 @@ var workflowVersionIdResolver = {
|
|
|
4319
4581
|
})
|
|
4320
4582
|
};
|
|
4321
4583
|
|
|
4584
|
+
// src/resolvers/workflowRunId.ts
|
|
4585
|
+
var workflowRunIdResolver = {
|
|
4586
|
+
type: "dynamic",
|
|
4587
|
+
depends: ["workflow"],
|
|
4588
|
+
fetch: async (sdk, params) => toIterable(sdk.listWorkflowRuns({ workflow: params.workflow })),
|
|
4589
|
+
prompt: (runs) => ({
|
|
4590
|
+
type: "list",
|
|
4591
|
+
name: "run",
|
|
4592
|
+
message: "Select a workflow run:",
|
|
4593
|
+
choices: runs.map((r) => ({
|
|
4594
|
+
name: `${r.id} \u2014 ${r.status}`,
|
|
4595
|
+
value: r.id
|
|
4596
|
+
}))
|
|
4597
|
+
})
|
|
4598
|
+
};
|
|
4599
|
+
|
|
4322
4600
|
// src/resolvers/triggerMessages.ts
|
|
4323
4601
|
var triggerMessagesResolver = {
|
|
4324
4602
|
type: "dynamic",
|
|
4325
4603
|
depends: ["inbox"],
|
|
4326
|
-
fetch: async (sdk, params) => toIterable(
|
|
4327
|
-
sdk.listTriggerInboxMessages({
|
|
4328
|
-
inbox: params.inbox
|
|
4329
|
-
})
|
|
4330
|
-
),
|
|
4604
|
+
fetch: async (sdk, params) => toIterable(sdk.listTriggerInboxMessages({ inbox: params.inbox })),
|
|
4331
4605
|
prompt: (messages) => ({
|
|
4332
4606
|
type: "checkbox",
|
|
4333
4607
|
name: "messages",
|
|
@@ -4701,7 +4975,7 @@ var FieldApiItemSchema = z.object({
|
|
|
4701
4975
|
var ListTableFieldsApiResponseSchema = z.object({
|
|
4702
4976
|
data: z.array(FieldApiItemSchema)
|
|
4703
4977
|
});
|
|
4704
|
-
var
|
|
4978
|
+
var FieldItemSchema = z.object({
|
|
4705
4979
|
id: z.string(),
|
|
4706
4980
|
type: FieldTypeSchema,
|
|
4707
4981
|
name: z.string(),
|
|
@@ -4711,13 +4985,6 @@ var FieldItemSchemaBase = z.object({
|
|
|
4711
4985
|
config: z.record(z.string(), z.unknown()).optional(),
|
|
4712
4986
|
deleted_at: z.string().nullable().optional()
|
|
4713
4987
|
});
|
|
4714
|
-
var FieldItemSchema = withFormatter(FieldItemSchemaBase, {
|
|
4715
|
-
format: (item) => ({
|
|
4716
|
-
title: item.name,
|
|
4717
|
-
id: item.id,
|
|
4718
|
-
details: [{ text: `Type: ${item.type}`, style: "dim" }]
|
|
4719
|
-
})
|
|
4720
|
-
});
|
|
4721
4988
|
var ListTableFieldsDescription = "List fields for a table";
|
|
4722
4989
|
var ListTableFieldsOptionsBaseSchema = z.object({
|
|
4723
4990
|
fields: FieldsPropertySchema.optional(),
|
|
@@ -4973,6 +5240,7 @@ var getAppPlugin = definePlugin(
|
|
|
4973
5240
|
itemType: "App",
|
|
4974
5241
|
inputSchema: GetAppInputSchema,
|
|
4975
5242
|
outputSchema: AppItemSchema,
|
|
5243
|
+
formatter: appItemFormatter,
|
|
4976
5244
|
resolvers: { app: appKeyResolver },
|
|
4977
5245
|
handler: async ({ sdk: sdk2, options }) => {
|
|
4978
5246
|
const appKey = "app" in options ? options.app : options.appKey;
|
|
@@ -5306,48 +5574,54 @@ z.object({
|
|
|
5306
5574
|
});
|
|
5307
5575
|
|
|
5308
5576
|
// src/schemas/Action.ts
|
|
5309
|
-
var ActionItemSchema =
|
|
5310
|
-
|
|
5311
|
-
|
|
5312
|
-
|
|
5313
|
-
|
|
5314
|
-
|
|
5315
|
-
|
|
5316
|
-
|
|
5317
|
-
|
|
5318
|
-
|
|
5319
|
-
|
|
5320
|
-
|
|
5321
|
-
|
|
5322
|
-
|
|
5323
|
-
|
|
5324
|
-
|
|
5325
|
-
|
|
5326
|
-
|
|
5327
|
-
|
|
5328
|
-
|
|
5329
|
-
|
|
5330
|
-
|
|
5331
|
-
|
|
5332
|
-
style: "normal"
|
|
5333
|
-
});
|
|
5334
|
-
}
|
|
5335
|
-
if (item.description) {
|
|
5336
|
-
details.push({
|
|
5337
|
-
text: item.description,
|
|
5338
|
-
style: "dim"
|
|
5339
|
-
});
|
|
5340
|
-
}
|
|
5341
|
-
return {
|
|
5342
|
-
title: item.title || item.key,
|
|
5343
|
-
id: item.id,
|
|
5344
|
-
key: item.key,
|
|
5345
|
-
description: item.description,
|
|
5346
|
-
details
|
|
5347
|
-
};
|
|
5577
|
+
var ActionItemSchema = ActionSchema.omit({
|
|
5578
|
+
type: true,
|
|
5579
|
+
name: true,
|
|
5580
|
+
selected_api: true
|
|
5581
|
+
}).extend({
|
|
5582
|
+
app_key: z.string(),
|
|
5583
|
+
// App key without version (extracted from selected_api)
|
|
5584
|
+
app_version: z.string().optional(),
|
|
5585
|
+
// Version extracted from selected_api
|
|
5586
|
+
action_type: ActionSchema.shape.type,
|
|
5587
|
+
// Mapped from original 'type' field
|
|
5588
|
+
title: z.string(),
|
|
5589
|
+
// Mapped from original 'name' field
|
|
5590
|
+
type: z.literal("action")
|
|
5591
|
+
// Fixed type identifier
|
|
5592
|
+
});
|
|
5593
|
+
|
|
5594
|
+
// src/formatters/action.ts
|
|
5595
|
+
var actionItemFormatter = {
|
|
5596
|
+
format: (item) => {
|
|
5597
|
+
const details = [{ text: `Type: ${item.action_type}`, style: "accent" }];
|
|
5598
|
+
if (item.app_key) {
|
|
5599
|
+
details.push({ text: `App: ${item.app_key}`, style: "normal" });
|
|
5348
5600
|
}
|
|
5601
|
+
if (item.description) {
|
|
5602
|
+
details.push({ text: item.description, style: "dim" });
|
|
5603
|
+
}
|
|
5604
|
+
return {
|
|
5605
|
+
title: item.title || item.key,
|
|
5606
|
+
id: item.id,
|
|
5607
|
+
key: item.key,
|
|
5608
|
+
description: item.description,
|
|
5609
|
+
details
|
|
5610
|
+
};
|
|
5349
5611
|
}
|
|
5350
|
-
|
|
5612
|
+
};
|
|
5613
|
+
|
|
5614
|
+
// src/plugins/eventEmission/method-metadata.ts
|
|
5615
|
+
var SCOPE_KEY = "methodMetadata";
|
|
5616
|
+
function setMethodMetadata(metadata) {
|
|
5617
|
+
const scope = getCurrentScope();
|
|
5618
|
+
if (!scope) return;
|
|
5619
|
+
const existing = scope[SCOPE_KEY];
|
|
5620
|
+
scope[SCOPE_KEY] = { ...existing, ...metadata };
|
|
5621
|
+
}
|
|
5622
|
+
function getMethodMetadata() {
|
|
5623
|
+
return getCurrentScope()?.[SCOPE_KEY];
|
|
5624
|
+
}
|
|
5351
5625
|
|
|
5352
5626
|
// src/plugins/listActions/index.ts
|
|
5353
5627
|
var listActionsPlugin = definePlugin(
|
|
@@ -5358,12 +5632,10 @@ var listActionsPlugin = definePlugin(
|
|
|
5358
5632
|
itemType: "Action",
|
|
5359
5633
|
inputSchema: ListActionsInputSchema,
|
|
5360
5634
|
outputSchema: ActionItemSchema,
|
|
5635
|
+
formatter: actionItemFormatter,
|
|
5361
5636
|
defaultPageSize: DEFAULT_PAGE_SIZE,
|
|
5362
5637
|
resolvers: { app: appKeyResolver, actionType: actionTypeResolver },
|
|
5363
|
-
handler: async ({
|
|
5364
|
-
sdk: sdk2,
|
|
5365
|
-
options
|
|
5366
|
-
}) => {
|
|
5638
|
+
handler: async ({ sdk: sdk2, options }) => {
|
|
5367
5639
|
const { api, getVersionedImplementationId } = sdk2.context;
|
|
5368
5640
|
const appKey = "app" in options ? options.app : options.appKey;
|
|
5369
5641
|
const selectedApi = await getVersionedImplementationId(appKey);
|
|
@@ -5431,6 +5703,7 @@ var getActionPlugin = definePlugin(
|
|
|
5431
5703
|
itemType: "Action",
|
|
5432
5704
|
inputSchema: GetActionInputSchema,
|
|
5433
5705
|
outputSchema: ActionItemSchema,
|
|
5706
|
+
formatter: actionItemFormatter,
|
|
5434
5707
|
resolvers: {
|
|
5435
5708
|
app: appKeyResolver,
|
|
5436
5709
|
actionType: actionTypeResolver,
|
|
@@ -5492,6 +5765,29 @@ var RunActionSchemaDeprecated = z.object({
|
|
|
5492
5765
|
actionKey: ActionKeyPropertySchema
|
|
5493
5766
|
}).merge(RunActionBaseSchema);
|
|
5494
5767
|
var RunActionInputSchema = z.union([RunActionSchema, RunActionSchemaDeprecated]).describe(RunActionDescription);
|
|
5768
|
+
|
|
5769
|
+
// src/formatters/actionResult.ts
|
|
5770
|
+
function getStringProperty(obj, key) {
|
|
5771
|
+
if (typeof obj === "object" && obj !== null && key in obj) {
|
|
5772
|
+
const value = obj[key];
|
|
5773
|
+
return typeof value === "string" ? value : void 0;
|
|
5774
|
+
}
|
|
5775
|
+
return void 0;
|
|
5776
|
+
}
|
|
5777
|
+
var actionResultItemFormatter = {
|
|
5778
|
+
format: (item) => {
|
|
5779
|
+
const obj = typeof item === "object" && item !== null ? item : {};
|
|
5780
|
+
const title = getStringProperty(obj, "title") || getStringProperty(obj, "name") || getStringProperty(obj, "label") || getStringProperty(obj, "subject") || "Action Result";
|
|
5781
|
+
return {
|
|
5782
|
+
title,
|
|
5783
|
+
id: getStringProperty(obj, "id"),
|
|
5784
|
+
key: getStringProperty(obj, "key"),
|
|
5785
|
+
description: getStringProperty(obj, "description"),
|
|
5786
|
+
data: item,
|
|
5787
|
+
details: []
|
|
5788
|
+
};
|
|
5789
|
+
}
|
|
5790
|
+
};
|
|
5495
5791
|
async function executeAction(actionOptions) {
|
|
5496
5792
|
const {
|
|
5497
5793
|
api,
|
|
@@ -5621,6 +5917,7 @@ var runActionPlugin = definePlugin(
|
|
|
5621
5917
|
itemType: "ActionResult",
|
|
5622
5918
|
inputSchema: RunActionInputSchema,
|
|
5623
5919
|
outputSchema: ActionResultItemSchema,
|
|
5920
|
+
formatter: actionResultItemFormatter,
|
|
5624
5921
|
resolvers: {
|
|
5625
5922
|
app: appKeyResolver,
|
|
5626
5923
|
actionType: actionTypeResolver,
|
|
@@ -5628,10 +5925,7 @@ var runActionPlugin = definePlugin(
|
|
|
5628
5925
|
connection: connectionIdResolver,
|
|
5629
5926
|
inputs: inputsResolver
|
|
5630
5927
|
},
|
|
5631
|
-
handler: async ({
|
|
5632
|
-
sdk: sdk2,
|
|
5633
|
-
options
|
|
5634
|
-
}) => {
|
|
5928
|
+
handler: async ({ sdk: sdk2, options }) => {
|
|
5635
5929
|
const { api } = sdk2.context;
|
|
5636
5930
|
const appKey = "app" in options ? options.app : options.appKey;
|
|
5637
5931
|
const actionKey = "action" in options ? options.action : options.actionKey;
|
|
@@ -5684,7 +5978,9 @@ var runActionPlugin = definePlugin(
|
|
|
5684
5978
|
}
|
|
5685
5979
|
return {
|
|
5686
5980
|
data: result.results || [],
|
|
5687
|
-
|
|
5981
|
+
// Coerce to a string: the API returns a numeric page index, but
|
|
5982
|
+
// `SdkPage.nextCursor` is a string (and the page guard enforces it).
|
|
5983
|
+
nextCursor: result.next_page != null ? String(result.next_page) : void 0
|
|
5688
5984
|
};
|
|
5689
5985
|
}
|
|
5690
5986
|
});
|
|
@@ -5739,7 +6035,10 @@ var ListConnectionsQuerySchema = ListConnectionsQuerySchema$1.omit({
|
|
|
5739
6035
|
// SDK specific property for pagination/iterable helpers
|
|
5740
6036
|
cursor: z.string().optional().describe("Cursor to start from")
|
|
5741
6037
|
}).describe("List available connections with optional filtering");
|
|
5742
|
-
var ConnectionItemSchema =
|
|
6038
|
+
var ConnectionItemSchema = ConnectionItemSchema$1;
|
|
6039
|
+
|
|
6040
|
+
// src/formatters/connection.ts
|
|
6041
|
+
var connectionItemFormatter = {
|
|
5743
6042
|
format: (item) => {
|
|
5744
6043
|
const details = [];
|
|
5745
6044
|
if (item.identifier) {
|
|
@@ -5764,17 +6063,19 @@ var ConnectionItemSchema = withFormatter(ConnectionItemSchema$1, {
|
|
|
5764
6063
|
details
|
|
5765
6064
|
};
|
|
5766
6065
|
}
|
|
5767
|
-
}
|
|
6066
|
+
};
|
|
5768
6067
|
|
|
5769
6068
|
// src/plugins/listConnections/index.ts
|
|
5770
6069
|
var listConnectionsPlugin = definePlugin(
|
|
5771
6070
|
(sdk) => createPaginatedPluginMethod(sdk, {
|
|
6071
|
+
...zapierPagination,
|
|
5772
6072
|
name: "listConnections",
|
|
5773
6073
|
categories: ["connection"],
|
|
5774
6074
|
type: "list",
|
|
5775
6075
|
itemType: "Connection",
|
|
5776
6076
|
inputSchema: ListConnectionsQuerySchema,
|
|
5777
6077
|
outputSchema: ConnectionItemSchema,
|
|
6078
|
+
formatter: connectionItemFormatter,
|
|
5778
6079
|
defaultPageSize: DEFAULT_PAGE_SIZE,
|
|
5779
6080
|
resolvers: { app: appKeyResolver },
|
|
5780
6081
|
handler: async ({ sdk: sdk2, options }) => {
|
|
@@ -5847,8 +6148,7 @@ var listConnectionsPlugin = definePlugin(
|
|
|
5847
6148
|
...response,
|
|
5848
6149
|
data: response.data.map(transformConnectionItem)
|
|
5849
6150
|
};
|
|
5850
|
-
}
|
|
5851
|
-
extractCursor: (response) => extractCursor(response.links)
|
|
6151
|
+
}
|
|
5852
6152
|
})
|
|
5853
6153
|
);
|
|
5854
6154
|
var GetConnectionParamSchema = z.object({
|
|
@@ -5872,6 +6172,7 @@ var getConnectionPlugin = definePlugin(
|
|
|
5872
6172
|
itemType: "Connection",
|
|
5873
6173
|
inputSchema: GetConnectionParamSchema,
|
|
5874
6174
|
outputSchema: ConnectionItemSchema,
|
|
6175
|
+
formatter: connectionItemFormatter,
|
|
5875
6176
|
resolvers: { connection: connectionIdGenericResolver },
|
|
5876
6177
|
handler: async ({ sdk: sdk2, options }) => {
|
|
5877
6178
|
const { api } = sdk2.context;
|
|
@@ -5912,6 +6213,7 @@ var findFirstConnectionPlugin = definePlugin(
|
|
|
5912
6213
|
itemType: "Connection",
|
|
5913
6214
|
inputSchema: FindFirstConnectionSchema,
|
|
5914
6215
|
outputSchema: ConnectionItemSchema,
|
|
6216
|
+
formatter: connectionItemFormatter,
|
|
5915
6217
|
handler: async ({ sdk: sdk2, options = {} }) => {
|
|
5916
6218
|
const connectionsResponse = await sdk2.listConnections({
|
|
5917
6219
|
...options,
|
|
@@ -5947,6 +6249,7 @@ var findUniqueConnectionPlugin = definePlugin(
|
|
|
5947
6249
|
itemType: "Connection",
|
|
5948
6250
|
inputSchema: FindUniqueConnectionSchema,
|
|
5949
6251
|
outputSchema: ConnectionItemSchema,
|
|
6252
|
+
formatter: connectionItemFormatter,
|
|
5950
6253
|
handler: async ({ sdk: sdk2, options = {} }) => {
|
|
5951
6254
|
const connectionsResponse = await sdk2.listConnections({
|
|
5952
6255
|
...options,
|
|
@@ -5977,11 +6280,13 @@ var listAuthenticationsPlugin = definePlugin(
|
|
|
5977
6280
|
meta: {
|
|
5978
6281
|
listAuthentications: {
|
|
5979
6282
|
packages: ["cli", "mcp"],
|
|
5980
|
-
categories: ["connection"
|
|
6283
|
+
categories: ["connection"],
|
|
6284
|
+
deprecation: { message: "Use listConnections instead." },
|
|
5981
6285
|
type: "list",
|
|
5982
6286
|
itemType: "Connection",
|
|
5983
6287
|
inputSchema: ListConnectionsQuerySchema,
|
|
5984
|
-
outputSchema: ConnectionItemSchema
|
|
6288
|
+
outputSchema: ConnectionItemSchema,
|
|
6289
|
+
formatter: connectionItemFormatter
|
|
5985
6290
|
}
|
|
5986
6291
|
}
|
|
5987
6292
|
}
|
|
@@ -5994,11 +6299,13 @@ var getAuthenticationPlugin = definePlugin(
|
|
|
5994
6299
|
meta: {
|
|
5995
6300
|
getAuthentication: {
|
|
5996
6301
|
packages: ["cli", "mcp"],
|
|
5997
|
-
categories: ["connection"
|
|
6302
|
+
categories: ["connection"],
|
|
6303
|
+
deprecation: { message: "Use getConnection instead." },
|
|
5998
6304
|
type: "item",
|
|
5999
6305
|
itemType: "Connection",
|
|
6000
6306
|
inputSchema: GetConnectionParamSchema,
|
|
6001
|
-
outputSchema: ConnectionItemSchema
|
|
6307
|
+
outputSchema: ConnectionItemSchema,
|
|
6308
|
+
formatter: connectionItemFormatter
|
|
6002
6309
|
}
|
|
6003
6310
|
}
|
|
6004
6311
|
}
|
|
@@ -6011,11 +6318,13 @@ var findFirstAuthenticationPlugin = definePlugin(
|
|
|
6011
6318
|
meta: {
|
|
6012
6319
|
findFirstAuthentication: {
|
|
6013
6320
|
packages: ["cli", "mcp"],
|
|
6014
|
-
categories: ["connection"
|
|
6321
|
+
categories: ["connection"],
|
|
6322
|
+
deprecation: { message: "Use findFirstConnection instead." },
|
|
6015
6323
|
type: "item",
|
|
6016
6324
|
itemType: "Connection",
|
|
6017
6325
|
inputSchema: FindFirstConnectionSchema,
|
|
6018
|
-
outputSchema: ConnectionItemSchema
|
|
6326
|
+
outputSchema: ConnectionItemSchema,
|
|
6327
|
+
formatter: connectionItemFormatter
|
|
6019
6328
|
}
|
|
6020
6329
|
}
|
|
6021
6330
|
}
|
|
@@ -6028,11 +6337,13 @@ var findUniqueAuthenticationPlugin = definePlugin(
|
|
|
6028
6337
|
meta: {
|
|
6029
6338
|
findUniqueAuthentication: {
|
|
6030
6339
|
packages: ["cli", "mcp"],
|
|
6031
|
-
categories: ["connection"
|
|
6340
|
+
categories: ["connection"],
|
|
6341
|
+
deprecation: { message: "Use findUniqueConnection instead." },
|
|
6032
6342
|
type: "item",
|
|
6033
6343
|
itemType: "Connection",
|
|
6034
6344
|
inputSchema: FindUniqueConnectionSchema,
|
|
6035
|
-
outputSchema: ConnectionItemSchema
|
|
6345
|
+
outputSchema: ConnectionItemSchema,
|
|
6346
|
+
formatter: connectionItemFormatter
|
|
6036
6347
|
}
|
|
6037
6348
|
}
|
|
6038
6349
|
}
|
|
@@ -6049,58 +6360,49 @@ var ListClientCredentialsQuerySchema = ListClientCredentialsQuerySchema$1.omit({
|
|
|
6049
6360
|
// SDK specific property for pagination/iterable helpers
|
|
6050
6361
|
cursor: z.string().optional().describe("Cursor to start from")
|
|
6051
6362
|
}).describe("List client credentials for the authenticated user");
|
|
6052
|
-
var ClientCredentialsItemSchema =
|
|
6053
|
-
|
|
6054
|
-
|
|
6055
|
-
|
|
6056
|
-
|
|
6057
|
-
|
|
6058
|
-
|
|
6059
|
-
|
|
6060
|
-
|
|
6061
|
-
}
|
|
6062
|
-
|
|
6063
|
-
|
|
6064
|
-
details.push({
|
|
6065
|
-
text: `Created: ${new Date(item.created_at).toLocaleDateString()}`,
|
|
6066
|
-
style: "dim"
|
|
6067
|
-
});
|
|
6068
|
-
}
|
|
6069
|
-
return {
|
|
6070
|
-
title: item.name,
|
|
6071
|
-
id: item.client_id,
|
|
6072
|
-
details
|
|
6073
|
-
};
|
|
6363
|
+
var ClientCredentialsItemSchema = ClientCredentialsItemSchema$1;
|
|
6364
|
+
var ClientCredentialsCreatedItemSchema = ClientCredentialsCreatedItemSchema$1;
|
|
6365
|
+
|
|
6366
|
+
// src/formatters/clientCredentials.ts
|
|
6367
|
+
var clientCredentialsItemFormatter = {
|
|
6368
|
+
format: (item) => {
|
|
6369
|
+
const details = [];
|
|
6370
|
+
if (item.allowed_scopes && item.allowed_scopes.length > 0) {
|
|
6371
|
+
details.push({
|
|
6372
|
+
text: `Scopes: ${item.allowed_scopes.join(", ")}`,
|
|
6373
|
+
style: "accent"
|
|
6374
|
+
});
|
|
6074
6375
|
}
|
|
6075
|
-
|
|
6076
|
-
|
|
6077
|
-
|
|
6078
|
-
|
|
6079
|
-
|
|
6080
|
-
format: (item) => {
|
|
6081
|
-
return {
|
|
6082
|
-
title: item.name,
|
|
6083
|
-
id: item.client_id,
|
|
6084
|
-
details: [
|
|
6085
|
-
{
|
|
6086
|
-
text: `Client Secret: ${item.client_secret}`,
|
|
6087
|
-
style: "accent"
|
|
6088
|
-
}
|
|
6089
|
-
]
|
|
6090
|
-
};
|
|
6376
|
+
if (item.created_at) {
|
|
6377
|
+
details.push({
|
|
6378
|
+
text: `Created: ${new Date(item.created_at).toLocaleDateString()}`,
|
|
6379
|
+
style: "dim"
|
|
6380
|
+
});
|
|
6091
6381
|
}
|
|
6382
|
+
return { title: item.name, id: item.client_id, details };
|
|
6092
6383
|
}
|
|
6093
|
-
|
|
6384
|
+
};
|
|
6385
|
+
var clientCredentialsCreatedItemFormatter = {
|
|
6386
|
+
format: (item) => ({
|
|
6387
|
+
title: item.name,
|
|
6388
|
+
id: item.client_id,
|
|
6389
|
+
details: [
|
|
6390
|
+
{ text: `Client Secret: ${item.client_secret}`, style: "accent" }
|
|
6391
|
+
]
|
|
6392
|
+
})
|
|
6393
|
+
};
|
|
6094
6394
|
|
|
6095
6395
|
// src/plugins/listClientCredentials/index.ts
|
|
6096
6396
|
var listClientCredentialsPlugin = definePlugin(
|
|
6097
6397
|
(sdk) => createPaginatedPluginMethod(sdk, {
|
|
6398
|
+
...zapierPagination,
|
|
6098
6399
|
name: "listClientCredentials",
|
|
6099
6400
|
categories: ["client-credentials"],
|
|
6100
6401
|
type: "list",
|
|
6101
6402
|
itemType: "ClientCredentials",
|
|
6102
6403
|
inputSchema: ListClientCredentialsQuerySchema,
|
|
6103
6404
|
outputSchema: ClientCredentialsItemSchema,
|
|
6405
|
+
formatter: clientCredentialsItemFormatter,
|
|
6104
6406
|
defaultPageSize: DEFAULT_PAGE_SIZE,
|
|
6105
6407
|
handler: async ({
|
|
6106
6408
|
sdk: sdk2,
|
|
@@ -6121,8 +6423,7 @@ var listClientCredentialsPlugin = definePlugin(
|
|
|
6121
6423
|
requiredScopes: ["credentials"]
|
|
6122
6424
|
}
|
|
6123
6425
|
);
|
|
6124
|
-
}
|
|
6125
|
-
extractCursor: (response) => extractCursor(response.links)
|
|
6426
|
+
}
|
|
6126
6427
|
})
|
|
6127
6428
|
);
|
|
6128
6429
|
var CreateClientCredentialsSchema = CreateClientCredentialsRequestSchema.omit({ allowed_scopes: true }).extend({
|
|
@@ -6140,6 +6441,7 @@ var createClientCredentialsPlugin = definePlugin(
|
|
|
6140
6441
|
itemType: "ClientCredentials",
|
|
6141
6442
|
inputSchema: CreateClientCredentialsSchema,
|
|
6142
6443
|
outputSchema: ClientCredentialsCreatedItemSchema,
|
|
6444
|
+
formatter: clientCredentialsCreatedItemFormatter,
|
|
6143
6445
|
confirm: "create-secret",
|
|
6144
6446
|
resolvers: { name: clientCredentialsNameResolver },
|
|
6145
6447
|
handler: async ({ sdk: sdk2, options }) => {
|
|
@@ -6229,99 +6531,36 @@ var BaseFieldItemSchema = z.object({
|
|
|
6229
6531
|
key: z.string()
|
|
6230
6532
|
// From need.key
|
|
6231
6533
|
});
|
|
6232
|
-
var InputFieldItemSchema =
|
|
6233
|
-
|
|
6234
|
-
|
|
6235
|
-
|
|
6236
|
-
|
|
6237
|
-
|
|
6238
|
-
|
|
6239
|
-
|
|
6240
|
-
|
|
6241
|
-
|
|
6242
|
-
|
|
6243
|
-
|
|
6244
|
-
|
|
6245
|
-
|
|
6246
|
-
|
|
6247
|
-
|
|
6248
|
-
|
|
6249
|
-
|
|
6250
|
-
|
|
6251
|
-
|
|
6252
|
-
|
|
6253
|
-
|
|
6254
|
-
|
|
6255
|
-
|
|
6256
|
-
|
|
6257
|
-
|
|
6258
|
-
|
|
6259
|
-
|
|
6260
|
-
|
|
6261
|
-
|
|
6262
|
-
].filter(Boolean).join(" | ");
|
|
6263
|
-
if (typeInfo) {
|
|
6264
|
-
details.push({ text: typeInfo, style: "dim" });
|
|
6265
|
-
}
|
|
6266
|
-
if (item.description) {
|
|
6267
|
-
details.push({
|
|
6268
|
-
text: item.description,
|
|
6269
|
-
style: "normal"
|
|
6270
|
-
});
|
|
6271
|
-
}
|
|
6272
|
-
if (item.default_value) {
|
|
6273
|
-
details.push({
|
|
6274
|
-
text: `Default: ${item.default_value}`,
|
|
6275
|
-
style: "accent"
|
|
6276
|
-
});
|
|
6277
|
-
}
|
|
6278
|
-
if (item.placeholder) {
|
|
6279
|
-
details.push({
|
|
6280
|
-
text: `Placeholder: ${item.placeholder}`,
|
|
6281
|
-
style: "dim"
|
|
6282
|
-
});
|
|
6283
|
-
}
|
|
6284
|
-
if (item.depends_on && item.depends_on.length > 0) {
|
|
6285
|
-
details.push({
|
|
6286
|
-
text: `Depends on: ${item.depends_on.join(", ")}`,
|
|
6287
|
-
style: "warning"
|
|
6288
|
-
});
|
|
6289
|
-
}
|
|
6290
|
-
if (item.format) {
|
|
6291
|
-
details.push({ text: `Format: ${item.format}`, style: "dim" });
|
|
6292
|
-
}
|
|
6293
|
-
if (item.items) {
|
|
6294
|
-
details.push({
|
|
6295
|
-
text: `Items type: ${item.items.type}`,
|
|
6296
|
-
style: "dim"
|
|
6297
|
-
});
|
|
6298
|
-
}
|
|
6299
|
-
return {
|
|
6300
|
-
title: item.title || item.key,
|
|
6301
|
-
key: item.key,
|
|
6302
|
-
description: item.description,
|
|
6303
|
-
details
|
|
6304
|
-
};
|
|
6305
|
-
}
|
|
6306
|
-
}
|
|
6307
|
-
);
|
|
6308
|
-
var InfoFieldItemSchema = withFormatter(
|
|
6309
|
-
BaseFieldItemSchema.extend({
|
|
6310
|
-
type: z.literal("info_field"),
|
|
6311
|
-
description: z.string(),
|
|
6312
|
-
// From need.help_text
|
|
6313
|
-
title: z.string().optional()
|
|
6314
|
-
// Optional title
|
|
6315
|
-
}),
|
|
6316
|
-
{
|
|
6317
|
-
format: (item) => ({
|
|
6318
|
-
title: item.title || "Info",
|
|
6319
|
-
key: item.key,
|
|
6320
|
-
description: item.description,
|
|
6321
|
-
details: [{ text: item.description, style: "normal" }]
|
|
6322
|
-
})
|
|
6323
|
-
}
|
|
6324
|
-
);
|
|
6534
|
+
var InputFieldItemSchema = BaseFieldItemSchema.extend({
|
|
6535
|
+
type: z.literal("input_field"),
|
|
6536
|
+
default_value: z.string(),
|
|
6537
|
+
// Mapped from 'default' with fallback to ""
|
|
6538
|
+
depends_on: z.array(z.string()),
|
|
6539
|
+
// Mapped from 'depends_on' with fallback to []
|
|
6540
|
+
description: z.string(),
|
|
6541
|
+
// Mapped from 'help_text' with fallback to ""
|
|
6542
|
+
invalidates_input_fields: z.boolean(),
|
|
6543
|
+
// Mapped from 'alters_custom_fields' with fallback to false
|
|
6544
|
+
is_required: z.boolean(),
|
|
6545
|
+
// Mapped from 'required' with fallback to false
|
|
6546
|
+
placeholder: z.string(),
|
|
6547
|
+
// Mapped from 'placeholder' with fallback to ""
|
|
6548
|
+
title: z.string(),
|
|
6549
|
+
// Mapped from 'label' with fallback to ""
|
|
6550
|
+
value_type: z.string(),
|
|
6551
|
+
// Computed from InputFieldType enum
|
|
6552
|
+
format: z.string().optional(),
|
|
6553
|
+
// Computed from InputFieldFormat enum (optional)
|
|
6554
|
+
items: z.object({ type: z.string() }).optional()
|
|
6555
|
+
// Computed from ItemsType enum (optional, only for arrays)
|
|
6556
|
+
});
|
|
6557
|
+
var InfoFieldItemSchema = BaseFieldItemSchema.extend({
|
|
6558
|
+
type: z.literal("info_field"),
|
|
6559
|
+
description: z.string(),
|
|
6560
|
+
// From need.help_text
|
|
6561
|
+
title: z.string().optional()
|
|
6562
|
+
// Optional title
|
|
6563
|
+
});
|
|
6325
6564
|
var FieldsetItemSchema = BaseFieldItemSchema.extend({
|
|
6326
6565
|
type: z.literal("fieldset"),
|
|
6327
6566
|
title: z.string(),
|
|
@@ -6341,6 +6580,53 @@ var RootFieldItemSchema = z.union([
|
|
|
6341
6580
|
FieldsetItemSchema
|
|
6342
6581
|
]);
|
|
6343
6582
|
|
|
6583
|
+
// src/formatters/field.ts
|
|
6584
|
+
function formatInputField(item) {
|
|
6585
|
+
const details = [];
|
|
6586
|
+
const typeInfo = [
|
|
6587
|
+
item.value_type && `Type: ${item.value_type}`,
|
|
6588
|
+
`Required: ${item.is_required ? "Yes" : "No"}`
|
|
6589
|
+
].filter(Boolean).join(" | ");
|
|
6590
|
+
if (typeInfo) details.push({ text: typeInfo, style: "dim" });
|
|
6591
|
+
if (item.description)
|
|
6592
|
+
details.push({ text: item.description, style: "normal" });
|
|
6593
|
+
if (item.default_value)
|
|
6594
|
+
details.push({ text: `Default: ${item.default_value}`, style: "accent" });
|
|
6595
|
+
if (item.placeholder)
|
|
6596
|
+
details.push({ text: `Placeholder: ${item.placeholder}`, style: "dim" });
|
|
6597
|
+
if (item.depends_on && item.depends_on.length > 0) {
|
|
6598
|
+
details.push({
|
|
6599
|
+
text: `Depends on: ${item.depends_on.join(", ")}`,
|
|
6600
|
+
style: "warning"
|
|
6601
|
+
});
|
|
6602
|
+
}
|
|
6603
|
+
if (item.format)
|
|
6604
|
+
details.push({ text: `Format: ${item.format}`, style: "dim" });
|
|
6605
|
+
if (item.items)
|
|
6606
|
+
details.push({ text: `Items type: ${item.items.type}`, style: "dim" });
|
|
6607
|
+
return {
|
|
6608
|
+
title: item.title || item.key,
|
|
6609
|
+
key: item.key,
|
|
6610
|
+
description: item.description,
|
|
6611
|
+
details
|
|
6612
|
+
};
|
|
6613
|
+
}
|
|
6614
|
+
function formatInfoField(item) {
|
|
6615
|
+
return {
|
|
6616
|
+
title: item.title || "Info",
|
|
6617
|
+
key: item.key,
|
|
6618
|
+
description: item.description,
|
|
6619
|
+
details: [{ text: item.description, style: "normal" }]
|
|
6620
|
+
};
|
|
6621
|
+
}
|
|
6622
|
+
var rootFieldItemFormatter = {
|
|
6623
|
+
format: (item) => {
|
|
6624
|
+
if (item.type === "input_field") return formatInputField(item);
|
|
6625
|
+
if (item.type === "info_field") return formatInfoField(item);
|
|
6626
|
+
return { title: item.title || item.key, key: item.key, details: [] };
|
|
6627
|
+
}
|
|
6628
|
+
};
|
|
6629
|
+
|
|
6344
6630
|
// src/services/implementations.ts
|
|
6345
6631
|
async function fetchImplementationNeeds({
|
|
6346
6632
|
api,
|
|
@@ -6506,6 +6792,7 @@ var listActionInputFieldsPlugin = definePlugin(
|
|
|
6506
6792
|
itemType: "RootField",
|
|
6507
6793
|
inputSchema: ListActionInputFieldsInputSchema,
|
|
6508
6794
|
outputSchema: RootFieldItemSchema,
|
|
6795
|
+
formatter: rootFieldItemFormatter,
|
|
6509
6796
|
defaultPageSize: DEFAULT_PAGE_SIZE,
|
|
6510
6797
|
resolvers: {
|
|
6511
6798
|
app: appKeyResolver,
|
|
@@ -6514,10 +6801,7 @@ var listActionInputFieldsPlugin = definePlugin(
|
|
|
6514
6801
|
connection: connectionIdResolver,
|
|
6515
6802
|
inputs: inputsAllOptionalResolver
|
|
6516
6803
|
},
|
|
6517
|
-
handler: async ({
|
|
6518
|
-
sdk: sdk2,
|
|
6519
|
-
options
|
|
6520
|
-
}) => {
|
|
6804
|
+
handler: async ({ sdk: sdk2, options }) => {
|
|
6521
6805
|
const { api, getVersionedImplementationId } = sdk2.context;
|
|
6522
6806
|
const appKey = "app" in options ? options.app : options.appKey;
|
|
6523
6807
|
const actionKey = "action" in options ? options.action : options.actionKey;
|
|
@@ -6679,26 +6963,7 @@ var getActionInputFieldsSchemaPlugin = definePlugin(
|
|
|
6679
6963
|
}
|
|
6680
6964
|
})
|
|
6681
6965
|
);
|
|
6682
|
-
var InputFieldChoiceItemSchema =
|
|
6683
|
-
format: (item) => {
|
|
6684
|
-
const title = item.label || item.key || "Choice";
|
|
6685
|
-
const details = [];
|
|
6686
|
-
if (item.label && item.key && item.label !== item.key) {
|
|
6687
|
-
details.push({ text: `Key: ${item.key}`, style: "dim" });
|
|
6688
|
-
}
|
|
6689
|
-
if (item.sample && item.sample !== item.key) {
|
|
6690
|
-
details.push({ text: `Sample: ${item.sample}`, style: "dim" });
|
|
6691
|
-
}
|
|
6692
|
-
if (item.value && item.value !== item.key) {
|
|
6693
|
-
details.push({ text: `Value: ${item.value}`, style: "normal" });
|
|
6694
|
-
}
|
|
6695
|
-
return {
|
|
6696
|
-
title,
|
|
6697
|
-
key: item.key,
|
|
6698
|
-
details
|
|
6699
|
-
};
|
|
6700
|
-
}
|
|
6701
|
-
});
|
|
6966
|
+
var InputFieldChoiceItemSchema = NeedChoicesSchema;
|
|
6702
6967
|
var ListActionInputFieldChoicesDescription = "Get the available choices for a dynamic dropdown input field";
|
|
6703
6968
|
var ListActionInputFieldChoicesBaseSchema = z.object({
|
|
6704
6969
|
connection: ConnectionPropertySchema.optional().describe(
|
|
@@ -6742,6 +7007,24 @@ var ListActionInputFieldChoicesInputSchema = z.union([
|
|
|
6742
7007
|
ListActionInputFieldChoicesSchemaDeprecated
|
|
6743
7008
|
]).describe(ListActionInputFieldChoicesDescription);
|
|
6744
7009
|
|
|
7010
|
+
// src/formatters/inputFieldChoice.ts
|
|
7011
|
+
var inputFieldChoiceItemFormatter = {
|
|
7012
|
+
format: (item) => {
|
|
7013
|
+
const title = item.label || item.key || "Choice";
|
|
7014
|
+
const details = [];
|
|
7015
|
+
if (item.label && item.key && item.label !== item.key) {
|
|
7016
|
+
details.push({ text: `Key: ${item.key}`, style: "dim" });
|
|
7017
|
+
}
|
|
7018
|
+
if (item.sample && item.sample !== item.key) {
|
|
7019
|
+
details.push({ text: `Sample: ${item.sample}`, style: "dim" });
|
|
7020
|
+
}
|
|
7021
|
+
if (item.value && item.value !== item.key) {
|
|
7022
|
+
details.push({ text: `Value: ${item.value}`, style: "normal" });
|
|
7023
|
+
}
|
|
7024
|
+
return { title, key: item.key, details };
|
|
7025
|
+
}
|
|
7026
|
+
};
|
|
7027
|
+
|
|
6745
7028
|
// src/plugins/listActionInputFieldChoices/index.ts
|
|
6746
7029
|
function transformNeedChoicesToInputFieldChoiceItem(choice) {
|
|
6747
7030
|
return {
|
|
@@ -6759,6 +7042,7 @@ var listActionInputFieldChoicesPlugin = definePlugin(
|
|
|
6759
7042
|
itemType: "InputFieldChoice",
|
|
6760
7043
|
inputSchema: ListActionInputFieldChoicesInputSchema,
|
|
6761
7044
|
outputSchema: InputFieldChoiceItemSchema,
|
|
7045
|
+
formatter: inputFieldChoiceItemFormatter,
|
|
6762
7046
|
defaultPageSize: DEFAULT_PAGE_SIZE,
|
|
6763
7047
|
resolvers: {
|
|
6764
7048
|
app: appKeyResolver,
|
|
@@ -6768,10 +7052,7 @@ var listActionInputFieldChoicesPlugin = definePlugin(
|
|
|
6768
7052
|
inputField: inputFieldKeyResolver,
|
|
6769
7053
|
inputs: inputsAllOptionalResolver
|
|
6770
7054
|
},
|
|
6771
|
-
handler: async ({
|
|
6772
|
-
sdk: sdk2,
|
|
6773
|
-
options
|
|
6774
|
-
}) => {
|
|
7055
|
+
handler: async ({ sdk: sdk2, options }) => {
|
|
6775
7056
|
const { api, getVersionedImplementationId } = sdk2.context;
|
|
6776
7057
|
const appKey = "app" in options ? options.app : options.appKey;
|
|
6777
7058
|
const actionKey = "action" in options ? options.action : options.actionKey;
|
|
@@ -6868,11 +7149,13 @@ var listInputFieldsDeprecatedPlugin = definePlugin(
|
|
|
6868
7149
|
context: {
|
|
6869
7150
|
meta: {
|
|
6870
7151
|
listInputFields: {
|
|
6871
|
-
categories: ["action"
|
|
7152
|
+
categories: ["action"],
|
|
7153
|
+
deprecation: { message: "Use listActionInputFields instead." },
|
|
6872
7154
|
type: "list",
|
|
6873
7155
|
itemType: "RootField",
|
|
6874
7156
|
inputSchema: ListActionInputFieldsInputSchema,
|
|
6875
7157
|
outputSchema: RootFieldItemSchema,
|
|
7158
|
+
formatter: rootFieldItemFormatter,
|
|
6876
7159
|
defaultPageSize: DEFAULT_PAGE_SIZE
|
|
6877
7160
|
}
|
|
6878
7161
|
}
|
|
@@ -6885,11 +7168,15 @@ var listInputFieldChoicesDeprecatedPlugin = definePlugin(
|
|
|
6885
7168
|
context: {
|
|
6886
7169
|
meta: {
|
|
6887
7170
|
listInputFieldChoices: {
|
|
6888
|
-
categories: ["action"
|
|
7171
|
+
categories: ["action"],
|
|
7172
|
+
deprecation: {
|
|
7173
|
+
message: "Use listActionInputFieldChoices instead."
|
|
7174
|
+
},
|
|
6889
7175
|
type: "list",
|
|
6890
7176
|
itemType: "InputFieldChoiceItem",
|
|
6891
7177
|
inputSchema: ListActionInputFieldChoicesInputSchema,
|
|
6892
7178
|
outputSchema: InputFieldChoiceItemSchema,
|
|
7179
|
+
formatter: inputFieldChoiceItemFormatter,
|
|
6893
7180
|
defaultPageSize: DEFAULT_PAGE_SIZE
|
|
6894
7181
|
}
|
|
6895
7182
|
}
|
|
@@ -6902,7 +7189,8 @@ var getInputFieldsSchemaDeprecatedPlugin = definePlugin(
|
|
|
6902
7189
|
context: {
|
|
6903
7190
|
meta: {
|
|
6904
7191
|
getInputFieldsSchema: {
|
|
6905
|
-
categories: ["action"
|
|
7192
|
+
categories: ["action"],
|
|
7193
|
+
deprecation: { message: "Use getActionInputFieldsSchema instead." },
|
|
6906
7194
|
type: "function",
|
|
6907
7195
|
inputSchema: GetActionInputFieldsSchemaInputSchema
|
|
6908
7196
|
}
|
|
@@ -6966,6 +7254,7 @@ var tablesDefaults = {
|
|
|
6966
7254
|
var listTablesPlugin = definePlugin(
|
|
6967
7255
|
(sdk) => createPaginatedPluginMethod(sdk, {
|
|
6968
7256
|
...tablesDefaults,
|
|
7257
|
+
...zapierPagination,
|
|
6969
7258
|
name: "listTables",
|
|
6970
7259
|
type: "list",
|
|
6971
7260
|
itemType: "Table",
|
|
@@ -7021,8 +7310,7 @@ var listTablesPlugin = definePlugin(
|
|
|
7021
7310
|
data: response.data.map(transformTableItem),
|
|
7022
7311
|
links: response.links
|
|
7023
7312
|
};
|
|
7024
|
-
}
|
|
7025
|
-
extractCursor: (response) => extractCursor(response.links)
|
|
7313
|
+
}
|
|
7026
7314
|
})
|
|
7027
7315
|
);
|
|
7028
7316
|
var GetTableApiResponseSchema = z.object({
|
|
@@ -7125,6 +7413,15 @@ var createTablePlugin = definePlugin(
|
|
|
7125
7413
|
})
|
|
7126
7414
|
);
|
|
7127
7415
|
|
|
7416
|
+
// src/formatters/tableField.ts
|
|
7417
|
+
var tableFieldItemFormatter = {
|
|
7418
|
+
format: (item) => ({
|
|
7419
|
+
title: item.name,
|
|
7420
|
+
id: item.id,
|
|
7421
|
+
details: [{ text: `Type: ${item.type}`, style: "dim" }]
|
|
7422
|
+
})
|
|
7423
|
+
};
|
|
7424
|
+
|
|
7128
7425
|
// src/plugins/tables/listTableFields/index.ts
|
|
7129
7426
|
var listTableFieldsPlugin = definePlugin(
|
|
7130
7427
|
(sdk) => createPluginMethod(sdk, {
|
|
@@ -7134,6 +7431,7 @@ var listTableFieldsPlugin = definePlugin(
|
|
|
7134
7431
|
itemType: "Field",
|
|
7135
7432
|
inputSchema: ListTableFieldsOptionsInputSchema,
|
|
7136
7433
|
outputSchema: FieldItemSchema,
|
|
7434
|
+
formatter: tableFieldItemFormatter,
|
|
7137
7435
|
resolvers: { table: tableIdResolver },
|
|
7138
7436
|
handler: async ({ sdk: sdk2, options }) => {
|
|
7139
7437
|
const { api } = sdk2.context;
|
|
@@ -7206,6 +7504,7 @@ var createTableFieldsPlugin = definePlugin(
|
|
|
7206
7504
|
returnType: "FieldItem[]",
|
|
7207
7505
|
inputSchema: CreateTableFieldsOptionsInputSchema,
|
|
7208
7506
|
outputSchema: FieldItemSchema,
|
|
7507
|
+
formatter: tableFieldItemFormatter,
|
|
7209
7508
|
resolvers: { table: tableIdResolver, fields: tableFieldsResolver },
|
|
7210
7509
|
handler: async ({ sdk: sdk2, options }) => {
|
|
7211
7510
|
const tableId = "table" in options ? options.table : options.tableId;
|
|
@@ -7284,21 +7583,13 @@ var RecordApiItemSchema = z.object({
|
|
|
7284
7583
|
is_source_record: z.boolean().nullable().optional(),
|
|
7285
7584
|
deleted_at: z.string().nullable().optional()
|
|
7286
7585
|
});
|
|
7287
|
-
var
|
|
7586
|
+
var RecordItemSchema = z.object({
|
|
7288
7587
|
id: z.string(),
|
|
7289
7588
|
data: z.record(z.string(), z.unknown()),
|
|
7290
7589
|
created_at: z.string(),
|
|
7291
7590
|
edited_at: z.string(),
|
|
7292
7591
|
deleted_at: z.string().nullable().optional()
|
|
7293
7592
|
});
|
|
7294
|
-
var RecordItemSchema = withFormatter(RecordItemSchemaBase, {
|
|
7295
|
-
format: (item) => ({
|
|
7296
|
-
title: `Record ${item.id}`,
|
|
7297
|
-
id: item.id,
|
|
7298
|
-
data: item.data,
|
|
7299
|
-
details: []
|
|
7300
|
-
})
|
|
7301
|
-
});
|
|
7302
7593
|
var GetTableRecordApiResponseSchema = z.object({
|
|
7303
7594
|
data: RecordApiItemSchema
|
|
7304
7595
|
});
|
|
@@ -7322,9 +7613,9 @@ var tableRecordFormatter = {
|
|
|
7322
7613
|
if (context) return context;
|
|
7323
7614
|
const hasFieldIds = Object.keys(item.data).some(isFieldId);
|
|
7324
7615
|
if (!hasFieldIds) return {};
|
|
7325
|
-
const
|
|
7326
|
-
|
|
7327
|
-
});
|
|
7616
|
+
const table = params.table ?? params.tableId;
|
|
7617
|
+
if (!table) return {};
|
|
7618
|
+
const { data: fields } = await sdk.listTableFields({ table });
|
|
7328
7619
|
return Object.fromEntries(fields.map((f) => [f.id, f.name]));
|
|
7329
7620
|
},
|
|
7330
7621
|
format: (item, fieldLabels) => ({
|
|
@@ -7449,10 +7740,7 @@ var listTableRecordsPlugin = definePlugin(
|
|
|
7449
7740
|
sort: tableSortResolver
|
|
7450
7741
|
},
|
|
7451
7742
|
formatter: tableRecordFormatter,
|
|
7452
|
-
handler: async ({
|
|
7453
|
-
sdk: sdk2,
|
|
7454
|
-
options
|
|
7455
|
-
}) => {
|
|
7743
|
+
handler: async ({ sdk: sdk2, options }) => {
|
|
7456
7744
|
const { api } = sdk2.context;
|
|
7457
7745
|
const tableId = "table" in options ? options.table : options.tableId;
|
|
7458
7746
|
const translator = await createFieldKeyTranslator({
|
|
@@ -7730,11 +8018,12 @@ var requestPlugin = definePlugin(
|
|
|
7730
8018
|
(sdk) => createPluginMethod(sdk, {
|
|
7731
8019
|
name: "request",
|
|
7732
8020
|
packages: ["cli", "mcp"],
|
|
7733
|
-
categories: ["http"
|
|
8021
|
+
categories: ["http"],
|
|
8022
|
+
deprecation: { message: "Use fetch() instead." },
|
|
7734
8023
|
returnType: "Response",
|
|
7735
8024
|
inputSchema: RelayRequestSchema,
|
|
7736
8025
|
handler: async ({ sdk: sdk2, options }) => {
|
|
7737
|
-
|
|
8026
|
+
logDeprecation2("request() is deprecated. Use fetch() instead.");
|
|
7738
8027
|
const {
|
|
7739
8028
|
url,
|
|
7740
8029
|
method,
|
|
@@ -7954,7 +8243,7 @@ async function listAppsForSlugsPage({
|
|
|
7954
8243
|
data: implementationsEnvelope.results.map(
|
|
7955
8244
|
normalizeImplementationMetaToAppItem
|
|
7956
8245
|
),
|
|
7957
|
-
nextCursor:
|
|
8246
|
+
nextCursor: implementationsEnvelope.next ? extractCursorFromUrl(implementationsEnvelope.next) : void 0
|
|
7958
8247
|
};
|
|
7959
8248
|
}
|
|
7960
8249
|
function findManifestEntry({
|
|
@@ -8375,7 +8664,7 @@ function createConsoleTransport() {
|
|
|
8375
8664
|
return {
|
|
8376
8665
|
async emit(subject, event) {
|
|
8377
8666
|
try {
|
|
8378
|
-
console.
|
|
8667
|
+
console.error(
|
|
8379
8668
|
"[SDK Telemetry]",
|
|
8380
8669
|
JSON.stringify({ subject, properties: event }, null, 2)
|
|
8381
8670
|
);
|
|
@@ -8584,6 +8873,35 @@ function buildMethodCalledEvent(data, context = {}) {
|
|
|
8584
8873
|
};
|
|
8585
8874
|
}
|
|
8586
8875
|
|
|
8876
|
+
// src/plugins/eventEmission/event-emission-hook.ts
|
|
8877
|
+
function computeArgumentCount(args) {
|
|
8878
|
+
if (args.length === 1) {
|
|
8879
|
+
const arg0 = args[0];
|
|
8880
|
+
if (arg0 !== null && typeof arg0 === "object" && !Array.isArray(arg0) && Object.getPrototypeOf(arg0) === Object.prototype) {
|
|
8881
|
+
return Object.keys(arg0).length;
|
|
8882
|
+
}
|
|
8883
|
+
}
|
|
8884
|
+
return args.filter((a) => a !== void 0).length;
|
|
8885
|
+
}
|
|
8886
|
+
function makeMethodEndHook(emitMethodCalled) {
|
|
8887
|
+
return ({ methodName, args, isPaginated, depth, durationMs, error }) => {
|
|
8888
|
+
if (depth > 0) return;
|
|
8889
|
+
const metadata = getMethodMetadata();
|
|
8890
|
+
emitMethodCalled({
|
|
8891
|
+
method_name: methodName,
|
|
8892
|
+
execution_duration_ms: durationMs,
|
|
8893
|
+
success_flag: !error,
|
|
8894
|
+
error_message: error?.message ?? null,
|
|
8895
|
+
error_type: error?.constructor.name ?? null,
|
|
8896
|
+
argument_count: computeArgumentCount(args),
|
|
8897
|
+
is_paginated: isPaginated,
|
|
8898
|
+
selected_api: metadata?.selectedApi ?? null,
|
|
8899
|
+
operation_type: metadata?.operationType ?? null,
|
|
8900
|
+
operation_key: metadata?.operationKey ?? null
|
|
8901
|
+
});
|
|
8902
|
+
};
|
|
8903
|
+
}
|
|
8904
|
+
|
|
8587
8905
|
// src/plugins/eventEmission/index.ts
|
|
8588
8906
|
var TELEMETRY_EMIT_TIMEOUT_MS = 300;
|
|
8589
8907
|
var registeredListeners = {};
|
|
@@ -8714,6 +9032,8 @@ var eventEmissionPlugin = definePlugin(
|
|
|
8714
9032
|
}
|
|
8715
9033
|
}
|
|
8716
9034
|
if (!config.enabled) {
|
|
9035
|
+
const noopEmitMethodCalled = () => {
|
|
9036
|
+
};
|
|
8717
9037
|
return {
|
|
8718
9038
|
context: {
|
|
8719
9039
|
eventEmission: {
|
|
@@ -8731,12 +9051,13 @@ var eventEmissionPlugin = definePlugin(
|
|
|
8731
9051
|
visitor_id: null,
|
|
8732
9052
|
correlation_id: null
|
|
8733
9053
|
}),
|
|
8734
|
-
emitMethodCalled: () => {
|
|
8735
|
-
},
|
|
8736
9054
|
flush: async () => {
|
|
8737
9055
|
},
|
|
8738
9056
|
close: async () => {
|
|
8739
9057
|
}
|
|
9058
|
+
},
|
|
9059
|
+
hooks: {
|
|
9060
|
+
onMethodEnd: makeMethodEndHook(noopEmitMethodCalled)
|
|
8740
9061
|
}
|
|
8741
9062
|
}
|
|
8742
9063
|
};
|
|
@@ -8905,7 +9226,21 @@ var eventEmissionPlugin = definePlugin(
|
|
|
8905
9226
|
APPLICATION_LIFECYCLE_EVENT_SUBJECT,
|
|
8906
9227
|
exitEvent
|
|
8907
9228
|
);
|
|
8908
|
-
removeExistingListeners();
|
|
9229
|
+
removeExistingListeners();
|
|
9230
|
+
};
|
|
9231
|
+
const emitMethodCalled = (data) => {
|
|
9232
|
+
const event = {
|
|
9233
|
+
...buildMethodCalledEvent(data),
|
|
9234
|
+
call_context: config.callContext ?? "sdk"
|
|
9235
|
+
};
|
|
9236
|
+
trackEmission(
|
|
9237
|
+
silentEmit(
|
|
9238
|
+
transport,
|
|
9239
|
+
METHOD_CALLED_EVENT_SUBJECT,
|
|
9240
|
+
event,
|
|
9241
|
+
getUserContext
|
|
9242
|
+
)
|
|
9243
|
+
);
|
|
8909
9244
|
};
|
|
8910
9245
|
return {
|
|
8911
9246
|
context: {
|
|
@@ -8918,22 +9253,11 @@ var eventEmissionPlugin = definePlugin(
|
|
|
8918
9253
|
);
|
|
8919
9254
|
},
|
|
8920
9255
|
createBaseEvent: createBaseEventHelper,
|
|
8921
|
-
emitMethodCalled: (data) => {
|
|
8922
|
-
const event = {
|
|
8923
|
-
...buildMethodCalledEvent(data),
|
|
8924
|
-
call_context: config.callContext ?? "sdk"
|
|
8925
|
-
};
|
|
8926
|
-
trackEmission(
|
|
8927
|
-
silentEmit(
|
|
8928
|
-
transport,
|
|
8929
|
-
METHOD_CALLED_EVENT_SUBJECT,
|
|
8930
|
-
event,
|
|
8931
|
-
getUserContext
|
|
8932
|
-
)
|
|
8933
|
-
);
|
|
8934
|
-
},
|
|
8935
9256
|
flush,
|
|
8936
9257
|
close
|
|
9258
|
+
},
|
|
9259
|
+
hooks: {
|
|
9260
|
+
onMethodEnd: makeMethodEndHook(emitMethodCalled)
|
|
8937
9261
|
}
|
|
8938
9262
|
}
|
|
8939
9263
|
};
|
|
@@ -8945,78 +9269,22 @@ function createOptionsPlugin(options) {
|
|
|
8945
9269
|
return () => ({ context: { options } });
|
|
8946
9270
|
}
|
|
8947
9271
|
function createSdk() {
|
|
8948
|
-
|
|
8949
|
-
|
|
8950
|
-
|
|
8951
|
-
|
|
8952
|
-
const registryCache = /* @__PURE__ */ new Map();
|
|
8953
|
-
const sdk = {
|
|
8954
|
-
...properties,
|
|
8955
|
-
get context() {
|
|
8956
|
-
return frozenContext;
|
|
8957
|
-
},
|
|
8958
|
-
getContext: () => frozenContext,
|
|
8959
|
-
// runtime compat shim, not in types
|
|
8960
|
-
getRegistry(options) {
|
|
8961
|
-
const cacheKey = options?.package ?? "__all__";
|
|
8962
|
-
if (!registryCache.has(cacheKey)) {
|
|
8963
|
-
registryCache.set(
|
|
8964
|
-
cacheKey,
|
|
8965
|
-
buildRegistry({
|
|
8966
|
-
sdk,
|
|
8967
|
-
meta: frozenContext.meta,
|
|
8968
|
-
packageFilter: options?.package
|
|
8969
|
-
})
|
|
8970
|
-
);
|
|
8971
|
-
}
|
|
8972
|
-
return registryCache.get(cacheKey);
|
|
8973
|
-
},
|
|
8974
|
-
addPlugin(plugin, options) {
|
|
8975
|
-
const pluginResult = plugin({
|
|
8976
|
-
...properties,
|
|
8977
|
-
context: frozenContext
|
|
8978
|
-
});
|
|
8979
|
-
const { context: pluginContext, ...pluginProperties } = pluginResult;
|
|
8980
|
-
const { meta: pluginMeta, ...pluginContextRest } = pluginContext ?? {};
|
|
8981
|
-
const existingProperties = properties;
|
|
8982
|
-
const existingContext = context;
|
|
8983
|
-
const existingMeta = context.meta ?? {};
|
|
8984
|
-
const collisions = [];
|
|
8985
|
-
for (const key of Object.keys(pluginProperties)) {
|
|
8986
|
-
if (key in existingProperties) collisions.push(`method "${key}"`);
|
|
8987
|
-
}
|
|
8988
|
-
for (const key of Object.keys(pluginContextRest)) {
|
|
8989
|
-
if (key in existingContext) collisions.push(`context.${key}`);
|
|
8990
|
-
}
|
|
8991
|
-
if (collisions.length > 0 && !options?.override) {
|
|
8992
|
-
const name = plugin.name || "anonymous plugin";
|
|
8993
|
-
console.warn(
|
|
8994
|
-
`[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.`
|
|
8995
|
-
);
|
|
8996
|
-
return buildSdk(properties, context);
|
|
8997
|
-
}
|
|
8998
|
-
const mergedProperties = { ...properties, ...pluginProperties };
|
|
8999
|
-
const mergedContext = {
|
|
9000
|
-
...context,
|
|
9001
|
-
...pluginContextRest,
|
|
9002
|
-
meta: { ...existingMeta, ...pluginMeta ?? {} }
|
|
9003
|
-
};
|
|
9004
|
-
return buildSdk(
|
|
9005
|
-
mergedProperties,
|
|
9006
|
-
mergedContext
|
|
9007
|
-
);
|
|
9008
|
-
}
|
|
9009
|
-
};
|
|
9010
|
-
return sdk;
|
|
9272
|
+
logDeprecation2(
|
|
9273
|
+
"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."
|
|
9274
|
+
);
|
|
9275
|
+
return withDeprecatedAddPlugin(createZapierCoreStack().toSdk());
|
|
9011
9276
|
}
|
|
9012
9277
|
function createZapierSdkWithoutRegistry(options = {}) {
|
|
9013
|
-
|
|
9278
|
+
logDeprecation2(
|
|
9014
9279
|
"createZapierSdkWithoutRegistry is deprecated; use createZapierSdk instead. getRegistry is now available on every sdk."
|
|
9015
9280
|
);
|
|
9016
9281
|
return createZapierSdk(options);
|
|
9017
9282
|
}
|
|
9283
|
+
function createZapierSdkStack(options = {}) {
|
|
9284
|
+
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);
|
|
9285
|
+
}
|
|
9018
9286
|
function createZapierSdk(options = {}) {
|
|
9019
|
-
return
|
|
9287
|
+
return withDeprecatedAddPlugin(createZapierSdkStack(options).toSdk());
|
|
9020
9288
|
}
|
|
9021
9289
|
var TriggerInboxStatusSchema = z.union([
|
|
9022
9290
|
z.enum([
|
|
@@ -9048,7 +9316,7 @@ var TriggerSubscriptionApiSchema = z.object({
|
|
|
9048
9316
|
action_key: z.string(),
|
|
9049
9317
|
inputs: z.record(z.string(), z.unknown())
|
|
9050
9318
|
});
|
|
9051
|
-
var
|
|
9319
|
+
var TriggerInboxItemSchema = z.object({
|
|
9052
9320
|
id: z.string(),
|
|
9053
9321
|
created_at: z.string(),
|
|
9054
9322
|
name: z.string().nullable(),
|
|
@@ -9057,40 +9325,6 @@ var TriggerInboxItemSchemaBase = z.object({
|
|
|
9057
9325
|
notification_url: z.string().nullable(),
|
|
9058
9326
|
subscription: TriggerSubscriptionApiSchema
|
|
9059
9327
|
});
|
|
9060
|
-
var TriggerInboxItemSchema = withFormatter(
|
|
9061
|
-
TriggerInboxItemSchemaBase,
|
|
9062
|
-
{
|
|
9063
|
-
format: (item) => {
|
|
9064
|
-
const details = [
|
|
9065
|
-
{
|
|
9066
|
-
text: `Status: ${item.status}`,
|
|
9067
|
-
style: item.status === "active" ? "accent" : "dim"
|
|
9068
|
-
},
|
|
9069
|
-
{
|
|
9070
|
-
text: `Subscription: ${item.subscription.app_key} / ${item.subscription.action_key}`,
|
|
9071
|
-
style: "dim"
|
|
9072
|
-
}
|
|
9073
|
-
];
|
|
9074
|
-
if (item.paused_reason) {
|
|
9075
|
-
details.push({
|
|
9076
|
-
text: `Paused reason: ${item.paused_reason}`,
|
|
9077
|
-
style: "warning"
|
|
9078
|
-
});
|
|
9079
|
-
}
|
|
9080
|
-
if (item.notification_url) {
|
|
9081
|
-
details.push({
|
|
9082
|
-
text: `Notify: ${item.notification_url}`,
|
|
9083
|
-
style: "dim"
|
|
9084
|
-
});
|
|
9085
|
-
}
|
|
9086
|
-
return {
|
|
9087
|
-
title: item.name ?? `Trigger Inbox ${item.id}`,
|
|
9088
|
-
id: item.id,
|
|
9089
|
-
details
|
|
9090
|
-
};
|
|
9091
|
-
}
|
|
9092
|
-
}
|
|
9093
|
-
);
|
|
9094
9328
|
|
|
9095
9329
|
// src/plugins/triggers/createTriggerInbox/schemas.ts
|
|
9096
9330
|
var CreateTriggerInboxDescription = "Create a new trigger inbox subscription. Always creates a new inbox; use ensureTriggerInbox for get-or-create on a stable name.";
|
|
@@ -9109,6 +9343,39 @@ var CreateTriggerInboxSchema = z.object({
|
|
|
9109
9343
|
notificationUrl: z.string().url().optional().describe("Webhook URL to POST to when new messages arrive")
|
|
9110
9344
|
}).describe(CreateTriggerInboxDescription);
|
|
9111
9345
|
|
|
9346
|
+
// src/formatters/triggerInbox.ts
|
|
9347
|
+
var triggerInboxItemFormatter = {
|
|
9348
|
+
format: (item) => {
|
|
9349
|
+
const details = [
|
|
9350
|
+
{
|
|
9351
|
+
text: `Status: ${item.status}`,
|
|
9352
|
+
style: item.status === "active" ? "accent" : "dim"
|
|
9353
|
+
},
|
|
9354
|
+
{
|
|
9355
|
+
text: `Subscription: ${item.subscription.app_key} / ${item.subscription.action_key}`,
|
|
9356
|
+
style: "dim"
|
|
9357
|
+
}
|
|
9358
|
+
];
|
|
9359
|
+
if (item.paused_reason) {
|
|
9360
|
+
details.push({
|
|
9361
|
+
text: `Paused reason: ${item.paused_reason}`,
|
|
9362
|
+
style: "warning"
|
|
9363
|
+
});
|
|
9364
|
+
}
|
|
9365
|
+
if (item.notification_url) {
|
|
9366
|
+
details.push({
|
|
9367
|
+
text: `Notify: ${item.notification_url}`,
|
|
9368
|
+
style: "dim"
|
|
9369
|
+
});
|
|
9370
|
+
}
|
|
9371
|
+
return {
|
|
9372
|
+
title: item.name ?? `Trigger Inbox ${item.id}`,
|
|
9373
|
+
id: item.id,
|
|
9374
|
+
details
|
|
9375
|
+
};
|
|
9376
|
+
}
|
|
9377
|
+
};
|
|
9378
|
+
|
|
9112
9379
|
// src/plugins/triggers/shared.ts
|
|
9113
9380
|
var triggersDefaults = {
|
|
9114
9381
|
categories: ["trigger"],
|
|
@@ -9157,6 +9424,7 @@ var createTriggerInboxPlugin = definePlugin(
|
|
|
9157
9424
|
itemType: "TriggerInbox",
|
|
9158
9425
|
inputSchema: CreateTriggerInboxSchema,
|
|
9159
9426
|
outputSchema: TriggerInboxItemSchema,
|
|
9427
|
+
formatter: triggerInboxItemFormatter,
|
|
9160
9428
|
// actionKeyResolver and inputsResolver depend on actionType, which is
|
|
9161
9429
|
// always "read" for triggers. Pin it as a constant resolver so it's
|
|
9162
9430
|
// seeded into resolvedParams without polluting the user-facing schema
|
|
@@ -9250,6 +9518,7 @@ var ensureTriggerInboxPlugin = definePlugin(
|
|
|
9250
9518
|
itemType: "TriggerInbox",
|
|
9251
9519
|
inputSchema: EnsureTriggerInboxSchema,
|
|
9252
9520
|
outputSchema: TriggerInboxItemSchema,
|
|
9521
|
+
formatter: triggerInboxItemFormatter,
|
|
9253
9522
|
// actionKeyResolver and inputsResolver depend on actionType, which is
|
|
9254
9523
|
// always "read" for triggers. Pin it as a constant resolver so it's
|
|
9255
9524
|
// seeded into resolvedParams without polluting the user-facing schema.
|
|
@@ -9334,24 +9603,16 @@ var ListTriggerInboxesApiResponseSchema = z.object({
|
|
|
9334
9603
|
});
|
|
9335
9604
|
|
|
9336
9605
|
// src/plugins/triggers/listTriggerInboxes/index.ts
|
|
9337
|
-
function extractNextOffset(next) {
|
|
9338
|
-
if (!next) return void 0;
|
|
9339
|
-
try {
|
|
9340
|
-
const url = new URL(next);
|
|
9341
|
-
const offset = url.searchParams.get("offset");
|
|
9342
|
-
return offset || void 0;
|
|
9343
|
-
} catch {
|
|
9344
|
-
return void 0;
|
|
9345
|
-
}
|
|
9346
|
-
}
|
|
9347
9606
|
var listTriggerInboxesPlugin = definePlugin(
|
|
9348
9607
|
(sdk) => createPaginatedPluginMethod(sdk, {
|
|
9349
9608
|
...triggersDefaults,
|
|
9609
|
+
...zapierPagination,
|
|
9350
9610
|
name: "listTriggerInboxes",
|
|
9351
9611
|
type: "list",
|
|
9352
9612
|
itemType: "TriggerInbox",
|
|
9353
9613
|
inputSchema: ListTriggerInboxesSchema,
|
|
9354
9614
|
outputSchema: TriggerInboxItemSchema,
|
|
9615
|
+
formatter: triggerInboxItemFormatter,
|
|
9355
9616
|
defaultPageSize: DEFAULT_PAGE_SIZE,
|
|
9356
9617
|
handler: async ({ sdk: sdk2, options }) => {
|
|
9357
9618
|
const { api } = sdk2.context;
|
|
@@ -9377,8 +9638,7 @@ var listTriggerInboxesPlugin = definePlugin(
|
|
|
9377
9638
|
data: response.results,
|
|
9378
9639
|
next: response.next ?? null
|
|
9379
9640
|
};
|
|
9380
|
-
}
|
|
9381
|
-
extractCursor: (response) => extractNextOffset(response.next)
|
|
9641
|
+
}
|
|
9382
9642
|
})
|
|
9383
9643
|
);
|
|
9384
9644
|
var GetTriggerInboxSchema = z.object({
|
|
@@ -9394,6 +9654,7 @@ var getTriggerInboxPlugin = definePlugin(
|
|
|
9394
9654
|
itemType: "TriggerInbox",
|
|
9395
9655
|
inputSchema: GetTriggerInboxSchema,
|
|
9396
9656
|
outputSchema: TriggerInboxItemSchema,
|
|
9657
|
+
formatter: triggerInboxItemFormatter,
|
|
9397
9658
|
resolvers: { inbox: triggerInboxResolver },
|
|
9398
9659
|
handler: async ({ sdk: sdk2, options }) => {
|
|
9399
9660
|
const { inbox } = options;
|
|
@@ -9428,6 +9689,7 @@ var updateTriggerInboxPlugin = definePlugin(
|
|
|
9428
9689
|
itemType: "TriggerInbox",
|
|
9429
9690
|
inputSchema: UpdateTriggerInboxSchema,
|
|
9430
9691
|
outputSchema: TriggerInboxItemSchema,
|
|
9692
|
+
formatter: triggerInboxItemFormatter,
|
|
9431
9693
|
resolvers: { inbox: triggerInboxResolver },
|
|
9432
9694
|
handler: async ({ sdk: sdk2, options }) => {
|
|
9433
9695
|
const { inbox, notificationUrl } = options;
|
|
@@ -9464,6 +9726,7 @@ var deleteTriggerInboxPlugin = definePlugin(
|
|
|
9464
9726
|
itemType: "TriggerInbox",
|
|
9465
9727
|
inputSchema: DeleteTriggerInboxSchema,
|
|
9466
9728
|
outputSchema: TriggerInboxItemSchema,
|
|
9729
|
+
formatter: triggerInboxItemFormatter,
|
|
9467
9730
|
resolvers: { inbox: triggerInboxResolver },
|
|
9468
9731
|
confirm: "delete",
|
|
9469
9732
|
handler: async ({ sdk: sdk2, options }) => {
|
|
@@ -9497,6 +9760,7 @@ var pauseTriggerInboxPlugin = definePlugin(
|
|
|
9497
9760
|
itemType: "TriggerInbox",
|
|
9498
9761
|
inputSchema: PauseTriggerInboxSchema,
|
|
9499
9762
|
outputSchema: TriggerInboxItemSchema,
|
|
9763
|
+
formatter: triggerInboxItemFormatter,
|
|
9500
9764
|
resolvers: { inbox: triggerInboxResolver },
|
|
9501
9765
|
handler: async ({ sdk: sdk2, options }) => {
|
|
9502
9766
|
const { inbox } = options;
|
|
@@ -9529,6 +9793,7 @@ var resumeTriggerInboxPlugin = definePlugin(
|
|
|
9529
9793
|
itemType: "TriggerInbox",
|
|
9530
9794
|
inputSchema: ResumeTriggerInboxSchema,
|
|
9531
9795
|
outputSchema: TriggerInboxItemSchema,
|
|
9796
|
+
formatter: triggerInboxItemFormatter,
|
|
9532
9797
|
resolvers: { inbox: triggerInboxResolver },
|
|
9533
9798
|
handler: async ({ sdk: sdk2, options }) => {
|
|
9534
9799
|
const { inbox } = options;
|
|
@@ -9554,78 +9819,15 @@ var TriggerMessageAttributesSchema = z.object({
|
|
|
9554
9819
|
error_message: z.string().nullable(),
|
|
9555
9820
|
possible_duplicate_data: z.boolean()
|
|
9556
9821
|
});
|
|
9557
|
-
var
|
|
9822
|
+
var TriggerMessageItemSchema = z.object({
|
|
9558
9823
|
id: z.string(),
|
|
9559
9824
|
created_at: z.string(),
|
|
9560
9825
|
status: TriggerMessageStatusSchema,
|
|
9561
9826
|
message_attributes: TriggerMessageAttributesSchema
|
|
9562
9827
|
});
|
|
9563
|
-
var
|
|
9564
|
-
TriggerMessageItemSchemaBase,
|
|
9565
|
-
{
|
|
9566
|
-
format: (item) => {
|
|
9567
|
-
const details = [
|
|
9568
|
-
{ text: `Status: ${item.status}`, style: "dim" },
|
|
9569
|
-
{
|
|
9570
|
-
text: `Lease count: ${item.message_attributes.lease_count}`,
|
|
9571
|
-
style: "dim"
|
|
9572
|
-
}
|
|
9573
|
-
];
|
|
9574
|
-
if (item.message_attributes.error_message) {
|
|
9575
|
-
details.push({
|
|
9576
|
-
text: `Error: ${item.message_attributes.error_message}`,
|
|
9577
|
-
style: "warning"
|
|
9578
|
-
});
|
|
9579
|
-
}
|
|
9580
|
-
if (item.message_attributes.possible_duplicate_data) {
|
|
9581
|
-
details.push({
|
|
9582
|
-
text: "Possible duplicate data",
|
|
9583
|
-
style: "warning"
|
|
9584
|
-
});
|
|
9585
|
-
}
|
|
9586
|
-
return {
|
|
9587
|
-
title: `Message ${item.id}`,
|
|
9588
|
-
id: item.id,
|
|
9589
|
-
details
|
|
9590
|
-
};
|
|
9591
|
-
}
|
|
9592
|
-
}
|
|
9593
|
-
);
|
|
9594
|
-
var LeasedTriggerMessageItemSchemaBase = TriggerMessageItemSchemaBase.extend({
|
|
9828
|
+
var LeasedTriggerMessageItemSchema = TriggerMessageItemSchema.extend({
|
|
9595
9829
|
payload: z.record(z.string(), z.unknown())
|
|
9596
9830
|
});
|
|
9597
|
-
var LeasedTriggerMessageItemSchema = withFormatter(
|
|
9598
|
-
LeasedTriggerMessageItemSchemaBase,
|
|
9599
|
-
{
|
|
9600
|
-
format: (item) => {
|
|
9601
|
-
const details = [
|
|
9602
|
-
{ text: `Status: ${item.status}`, style: "dim" },
|
|
9603
|
-
{
|
|
9604
|
-
text: `Lease count: ${item.message_attributes.lease_count}`,
|
|
9605
|
-
style: "dim"
|
|
9606
|
-
}
|
|
9607
|
-
];
|
|
9608
|
-
if (item.message_attributes.error_message) {
|
|
9609
|
-
details.push({
|
|
9610
|
-
text: `Error: ${item.message_attributes.error_message}`,
|
|
9611
|
-
style: "warning"
|
|
9612
|
-
});
|
|
9613
|
-
}
|
|
9614
|
-
if (item.message_attributes.possible_duplicate_data) {
|
|
9615
|
-
details.push({
|
|
9616
|
-
text: "Possible duplicate data",
|
|
9617
|
-
style: "warning"
|
|
9618
|
-
});
|
|
9619
|
-
}
|
|
9620
|
-
return {
|
|
9621
|
-
title: `Message ${item.id}`,
|
|
9622
|
-
id: item.id,
|
|
9623
|
-
data: item.payload,
|
|
9624
|
-
details
|
|
9625
|
-
};
|
|
9626
|
-
}
|
|
9627
|
-
}
|
|
9628
|
-
);
|
|
9629
9831
|
|
|
9630
9832
|
// src/plugins/triggers/listTriggerInboxMessages/schemas.ts
|
|
9631
9833
|
var ListTriggerInboxMessagesSchema = z.object({
|
|
@@ -9640,24 +9842,45 @@ var ListTriggerInboxMessagesApiResponseSchema = z.object({
|
|
|
9640
9842
|
results: z.array(TriggerMessageItemSchema)
|
|
9641
9843
|
});
|
|
9642
9844
|
|
|
9643
|
-
// src/
|
|
9644
|
-
function
|
|
9645
|
-
|
|
9646
|
-
|
|
9647
|
-
|
|
9648
|
-
|
|
9649
|
-
|
|
9650
|
-
|
|
9845
|
+
// src/formatters/triggerMessage.ts
|
|
9846
|
+
function buildBaseDetails(item) {
|
|
9847
|
+
const details = [
|
|
9848
|
+
{ text: `Status: ${item.status}`, style: "dim" },
|
|
9849
|
+
{
|
|
9850
|
+
text: `Lease count: ${item.message_attributes.lease_count}`,
|
|
9851
|
+
style: "dim"
|
|
9852
|
+
}
|
|
9853
|
+
];
|
|
9854
|
+
if (item.message_attributes.error_message) {
|
|
9855
|
+
details.push({
|
|
9856
|
+
text: `Error: ${item.message_attributes.error_message}`,
|
|
9857
|
+
style: "warning"
|
|
9858
|
+
});
|
|
9859
|
+
}
|
|
9860
|
+
if (item.message_attributes.possible_duplicate_data) {
|
|
9861
|
+
details.push({ text: "Possible duplicate data", style: "warning" });
|
|
9651
9862
|
}
|
|
9863
|
+
return details;
|
|
9652
9864
|
}
|
|
9865
|
+
var triggerMessageItemFormatter = {
|
|
9866
|
+
format: (item) => ({
|
|
9867
|
+
title: `Message ${item.id}`,
|
|
9868
|
+
id: item.id,
|
|
9869
|
+
details: buildBaseDetails(item)
|
|
9870
|
+
})
|
|
9871
|
+
};
|
|
9872
|
+
|
|
9873
|
+
// src/plugins/triggers/listTriggerInboxMessages/index.ts
|
|
9653
9874
|
var listTriggerInboxMessagesPlugin = definePlugin(
|
|
9654
9875
|
(sdk) => createPaginatedPluginMethod(sdk, {
|
|
9655
9876
|
...triggersDefaults,
|
|
9877
|
+
...zapierPagination,
|
|
9656
9878
|
name: "listTriggerInboxMessages",
|
|
9657
9879
|
type: "list",
|
|
9658
9880
|
itemType: "TriggerMessage",
|
|
9659
9881
|
inputSchema: ListTriggerInboxMessagesSchema,
|
|
9660
9882
|
outputSchema: TriggerMessageItemSchema,
|
|
9883
|
+
formatter: triggerMessageItemFormatter,
|
|
9661
9884
|
defaultPageSize: DEFAULT_PAGE_SIZE,
|
|
9662
9885
|
resolvers: { inbox: triggerInboxResolver },
|
|
9663
9886
|
handler: async ({ sdk: sdk2, options }) => {
|
|
@@ -9682,8 +9905,7 @@ var listTriggerInboxMessagesPlugin = definePlugin(
|
|
|
9682
9905
|
data: response.results,
|
|
9683
9906
|
next: response.next ?? null
|
|
9684
9907
|
};
|
|
9685
|
-
}
|
|
9686
|
-
extractCursor: (response) => extractNextCursor(response.next)
|
|
9908
|
+
}
|
|
9687
9909
|
})
|
|
9688
9910
|
);
|
|
9689
9911
|
var LeaseTriggerInboxMessagesSchema = z.object({
|
|
@@ -10406,17 +10628,14 @@ var listTriggersPlugin = definePlugin(
|
|
|
10406
10628
|
itemType: "Action",
|
|
10407
10629
|
inputSchema: ListTriggersSchema,
|
|
10408
10630
|
outputSchema: ActionItemSchema,
|
|
10631
|
+
formatter: actionItemFormatter,
|
|
10409
10632
|
defaultPageSize: DEFAULT_PAGE_SIZE,
|
|
10410
10633
|
resolvers: { app: appKeyResolver },
|
|
10411
|
-
handler: async ({
|
|
10412
|
-
|
|
10413
|
-
options
|
|
10414
|
-
}) => {
|
|
10415
|
-
const result = await sdk2.listActions({
|
|
10634
|
+
handler: async ({ sdk: sdk2, options }) => {
|
|
10635
|
+
return await sdk2.listActions({
|
|
10416
10636
|
...options,
|
|
10417
10637
|
actionType: "read"
|
|
10418
10638
|
});
|
|
10419
|
-
return { data: result.data, nextCursor: result.nextCursor };
|
|
10420
10639
|
}
|
|
10421
10640
|
})
|
|
10422
10641
|
);
|
|
@@ -10443,6 +10662,7 @@ var listTriggerInputFieldsPlugin = definePlugin(
|
|
|
10443
10662
|
itemType: "RootField",
|
|
10444
10663
|
inputSchema: ListTriggerInputFieldsSchema,
|
|
10445
10664
|
outputSchema: RootFieldItemSchema,
|
|
10665
|
+
formatter: rootFieldItemFormatter,
|
|
10446
10666
|
defaultPageSize: DEFAULT_PAGE_SIZE,
|
|
10447
10667
|
// actionKeyResolver and inputsAllOptionalResolver depend on actionType.
|
|
10448
10668
|
// Pin it to "read" so they resolve correctly without the user setting it.
|
|
@@ -10453,15 +10673,11 @@ var listTriggerInputFieldsPlugin = definePlugin(
|
|
|
10453
10673
|
inputs: inputsAllOptionalResolver,
|
|
10454
10674
|
actionType: { type: "constant", value: "read" }
|
|
10455
10675
|
},
|
|
10456
|
-
handler: async ({
|
|
10457
|
-
|
|
10458
|
-
options
|
|
10459
|
-
}) => {
|
|
10460
|
-
const result = await sdk2.listActionInputFields({
|
|
10676
|
+
handler: async ({ sdk: sdk2, options }) => {
|
|
10677
|
+
return await sdk2.listActionInputFields({
|
|
10461
10678
|
...options,
|
|
10462
10679
|
actionType: "read"
|
|
10463
10680
|
});
|
|
10464
|
-
return { data: result.data, nextCursor: result.nextCursor };
|
|
10465
10681
|
}
|
|
10466
10682
|
})
|
|
10467
10683
|
);
|
|
@@ -10492,6 +10708,7 @@ var listTriggerInputFieldChoicesPlugin = definePlugin(
|
|
|
10492
10708
|
itemType: "InputFieldChoice",
|
|
10493
10709
|
inputSchema: ListTriggerInputFieldChoicesSchema,
|
|
10494
10710
|
outputSchema: InputFieldChoiceItemSchema,
|
|
10711
|
+
formatter: inputFieldChoiceItemFormatter,
|
|
10495
10712
|
defaultPageSize: DEFAULT_PAGE_SIZE,
|
|
10496
10713
|
resolvers: {
|
|
10497
10714
|
app: appKeyResolver,
|
|
@@ -10501,15 +10718,11 @@ var listTriggerInputFieldChoicesPlugin = definePlugin(
|
|
|
10501
10718
|
inputs: inputsAllOptionalResolver,
|
|
10502
10719
|
actionType: { type: "constant", value: "read" }
|
|
10503
10720
|
},
|
|
10504
|
-
handler: async ({
|
|
10505
|
-
|
|
10506
|
-
options
|
|
10507
|
-
}) => {
|
|
10508
|
-
const result = await sdk2.listActionInputFieldChoices({
|
|
10721
|
+
handler: async ({ sdk: sdk2, options }) => {
|
|
10722
|
+
return await sdk2.listActionInputFieldChoices({
|
|
10509
10723
|
...options,
|
|
10510
10724
|
actionType: "read"
|
|
10511
10725
|
});
|
|
10512
|
-
return { data: result.data, nextCursor: result.nextCursor };
|
|
10513
10726
|
}
|
|
10514
10727
|
})
|
|
10515
10728
|
);
|
|
@@ -10611,10 +10824,9 @@ var listWorkflowsPlugin = definePlugin(
|
|
|
10611
10824
|
const response = ListWorkflowsApiResponseSchema.parse(raw);
|
|
10612
10825
|
return {
|
|
10613
10826
|
data: response.workflows,
|
|
10614
|
-
|
|
10827
|
+
nextCursor: response.next_cursor ?? void 0
|
|
10615
10828
|
};
|
|
10616
|
-
}
|
|
10617
|
-
extractCursor: (response) => response.next ?? void 0
|
|
10829
|
+
}
|
|
10618
10830
|
})
|
|
10619
10831
|
);
|
|
10620
10832
|
var WorkflowVersionSchema = z.object({
|
|
@@ -11324,6 +11536,249 @@ var getWorkflowVersionPlugin = definePlugin(
|
|
|
11324
11536
|
}
|
|
11325
11537
|
})
|
|
11326
11538
|
);
|
|
11539
|
+
var WorkflowRunStatusSchema = z.union([
|
|
11540
|
+
z.enum(["initialized", "started", "finished", "failed", "cancelled"]),
|
|
11541
|
+
z.string()
|
|
11542
|
+
]).describe(
|
|
11543
|
+
"Workflow run lifecycle status. `finished` / `failed` / `cancelled` are terminal."
|
|
11544
|
+
);
|
|
11545
|
+
var WorkflowRunListItemSchema = z.object({
|
|
11546
|
+
id: z.string().describe("Workflow run ID (UUID)"),
|
|
11547
|
+
trigger_id: z.string().nullable().describe(
|
|
11548
|
+
"ID of the trigger that fired this run, if any. Null for runs created without a trigger."
|
|
11549
|
+
),
|
|
11550
|
+
durable_run_id: z.string().nullable().describe(
|
|
11551
|
+
"Linked sdkdurableapi run ID. Null until the durable run is created."
|
|
11552
|
+
),
|
|
11553
|
+
workflow_version_id: z.string().nullable().describe("Workflow version the run is bound to. Null in rare edge cases."),
|
|
11554
|
+
status: WorkflowRunStatusSchema,
|
|
11555
|
+
input: z.unknown().describe("Input passed to the run"),
|
|
11556
|
+
output: z.unknown().nullable().describe("Return value, present when status is `finished`"),
|
|
11557
|
+
error: z.unknown().nullable().describe("Error payload when status is `failed` (null otherwise)"),
|
|
11558
|
+
created_at: z.string().describe("When the run was created (ISO-8601)"),
|
|
11559
|
+
updated_at: z.string().describe("When the run was last updated (ISO-8601)")
|
|
11560
|
+
});
|
|
11561
|
+
var ListWorkflowRunsOptionsSchema = z.object({
|
|
11562
|
+
workflow: z.string().uuid().describe("Durable workflow ID"),
|
|
11563
|
+
pageSize: z.number().int().min(1).max(100).optional().describe("Number of runs per page (max 100)"),
|
|
11564
|
+
cursor: z.string().optional().describe("Pagination cursor"),
|
|
11565
|
+
maxItems: z.number().int().min(1).optional().describe("Maximum total runs to return across all pages")
|
|
11566
|
+
}).describe(
|
|
11567
|
+
"List workflow runs (triggered executions) for a specific deployed workflow, newest first"
|
|
11568
|
+
);
|
|
11569
|
+
var ListWorkflowRunsApiResponseSchema = z.object({
|
|
11570
|
+
results: z.array(WorkflowRunListItemSchema),
|
|
11571
|
+
meta: z.object({
|
|
11572
|
+
limit: z.number(),
|
|
11573
|
+
cursor: z.string().nullable().optional(),
|
|
11574
|
+
next_cursor: z.string().nullable().optional()
|
|
11575
|
+
}),
|
|
11576
|
+
links: z.object({
|
|
11577
|
+
next: z.string().nullable().optional()
|
|
11578
|
+
}).optional()
|
|
11579
|
+
});
|
|
11580
|
+
|
|
11581
|
+
// src/plugins/codeSubstrate/listWorkflowRuns/index.ts
|
|
11582
|
+
var listWorkflowRunsPlugin = definePlugin(
|
|
11583
|
+
(sdk) => createPaginatedPluginMethod(sdk, {
|
|
11584
|
+
...codeSubstrateDefaults,
|
|
11585
|
+
name: "listWorkflowRuns",
|
|
11586
|
+
type: "list",
|
|
11587
|
+
itemType: "WorkflowRun",
|
|
11588
|
+
inputSchema: ListWorkflowRunsOptionsSchema,
|
|
11589
|
+
outputSchema: WorkflowRunListItemSchema,
|
|
11590
|
+
defaultPageSize: DEFAULT_PAGE_SIZE,
|
|
11591
|
+
resolvers: { workflow: workflowIdResolver },
|
|
11592
|
+
handler: async ({ sdk: sdk2, options }) => {
|
|
11593
|
+
const searchParams = {};
|
|
11594
|
+
if (options.pageSize !== void 0) {
|
|
11595
|
+
searchParams.limit = options.pageSize.toString();
|
|
11596
|
+
}
|
|
11597
|
+
if (options.cursor) {
|
|
11598
|
+
searchParams.cursor = options.cursor;
|
|
11599
|
+
}
|
|
11600
|
+
const raw = await sdk2.context.api.get(
|
|
11601
|
+
`/durableworkflowzaps/api/v0/workflows/${encodeURIComponent(options.workflow)}/runs`,
|
|
11602
|
+
{
|
|
11603
|
+
searchParams,
|
|
11604
|
+
authRequired: true,
|
|
11605
|
+
resource: { type: "workflow", id: options.workflow }
|
|
11606
|
+
}
|
|
11607
|
+
);
|
|
11608
|
+
const response = ListWorkflowRunsApiResponseSchema.parse(raw);
|
|
11609
|
+
return {
|
|
11610
|
+
data: response.results,
|
|
11611
|
+
nextCursor: response.meta.next_cursor ?? void 0
|
|
11612
|
+
};
|
|
11613
|
+
}
|
|
11614
|
+
})
|
|
11615
|
+
);
|
|
11616
|
+
var GetWorkflowRunOptionsSchema = z.object({
|
|
11617
|
+
// Picker-only field — the API endpoint is /workflows/runs/:id and
|
|
11618
|
+
// does not take a workflow id, but the run-id picker is scoped to a
|
|
11619
|
+
// parent workflow so the user can browse runs without enumerating
|
|
11620
|
+
// every run across every workflow on the account.
|
|
11621
|
+
workflow: z.string().uuid().optional().describe(
|
|
11622
|
+
"Parent workflow ID \u2014 used only to scope the CLI run-id picker; ignored by the API call."
|
|
11623
|
+
),
|
|
11624
|
+
run: z.string().uuid().describe("Workflow run ID")
|
|
11625
|
+
}).describe(
|
|
11626
|
+
"Get the current state of a workflow run (a triggered execution of a deployed workflow)"
|
|
11627
|
+
);
|
|
11628
|
+
var GetWorkflowRunResponseSchema = z.object({
|
|
11629
|
+
id: z.string().describe("Workflow run ID (UUID)"),
|
|
11630
|
+
trigger_id: z.string().nullable().describe("ID of the trigger that fired this run, if any"),
|
|
11631
|
+
durable_run_id: z.string().nullable().describe(
|
|
11632
|
+
"Linked sdkdurableapi run ID. Null until the durable run is created."
|
|
11633
|
+
),
|
|
11634
|
+
workflow_version_id: z.string().nullable().describe("Workflow version the run is bound to"),
|
|
11635
|
+
status: WorkflowRunStatusSchema,
|
|
11636
|
+
input: z.unknown().describe("Input passed to the run"),
|
|
11637
|
+
output: z.unknown().nullable().describe("Return value, present when status is `finished`"),
|
|
11638
|
+
error: z.unknown().nullable().describe("Error payload when status is `failed` (null otherwise)"),
|
|
11639
|
+
created_at: z.string().describe("When the run was created (ISO-8601)"),
|
|
11640
|
+
updated_at: z.string().describe("When the run was last updated (ISO-8601)")
|
|
11641
|
+
});
|
|
11642
|
+
|
|
11643
|
+
// src/plugins/codeSubstrate/getWorkflowRun/index.ts
|
|
11644
|
+
var getWorkflowRunPlugin = definePlugin(
|
|
11645
|
+
(sdk) => createPluginMethod(sdk, {
|
|
11646
|
+
...codeSubstrateDefaults,
|
|
11647
|
+
name: "getWorkflowRun",
|
|
11648
|
+
type: "item",
|
|
11649
|
+
itemType: "WorkflowRun",
|
|
11650
|
+
inputSchema: GetWorkflowRunOptionsSchema,
|
|
11651
|
+
outputSchema: GetWorkflowRunResponseSchema,
|
|
11652
|
+
resolvers: {
|
|
11653
|
+
workflow: workflowIdResolver,
|
|
11654
|
+
run: workflowRunIdResolver
|
|
11655
|
+
},
|
|
11656
|
+
handler: async ({ sdk: sdk2, options }) => {
|
|
11657
|
+
const raw = await sdk2.context.api.get(
|
|
11658
|
+
`/durableworkflowzaps/api/v0/workflows/runs/${encodeURIComponent(options.run)}`,
|
|
11659
|
+
{
|
|
11660
|
+
authRequired: true,
|
|
11661
|
+
resource: { type: "workflow-run", id: options.run }
|
|
11662
|
+
}
|
|
11663
|
+
);
|
|
11664
|
+
const data = GetWorkflowRunResponseSchema.parse(raw);
|
|
11665
|
+
return { data };
|
|
11666
|
+
}
|
|
11667
|
+
})
|
|
11668
|
+
);
|
|
11669
|
+
var GetTriggerRunOptionsSchema = z.object({
|
|
11670
|
+
trigger: z.string().uuid().describe("Workflow trigger ID")
|
|
11671
|
+
}).describe(
|
|
11672
|
+
"Get the workflow run associated with a deployed workflow's trigger. Useful immediately after firing a trigger, when you have the trigger ID but not yet the run ID."
|
|
11673
|
+
);
|
|
11674
|
+
var GetTriggerRunResponseSchema = z.object({
|
|
11675
|
+
id: z.string().describe("Workflow run ID (UUID)"),
|
|
11676
|
+
durable_run_id: z.string().nullable().describe(
|
|
11677
|
+
"Linked sdkdurableapi run ID. Null until the durable run is created."
|
|
11678
|
+
),
|
|
11679
|
+
workflow_version_id: z.string().nullable().describe("Workflow version the run is bound to"),
|
|
11680
|
+
status: WorkflowRunStatusSchema,
|
|
11681
|
+
input: z.unknown().describe("Input passed to the run"),
|
|
11682
|
+
output: z.unknown().nullable().describe("Return value, present when status is `finished`"),
|
|
11683
|
+
error: z.unknown().nullable().describe("Error payload when status is `failed` (null otherwise)"),
|
|
11684
|
+
created_at: z.string().describe("When the run was created (ISO-8601)"),
|
|
11685
|
+
updated_at: z.string().describe("When the run was last updated (ISO-8601)")
|
|
11686
|
+
});
|
|
11687
|
+
|
|
11688
|
+
// src/plugins/codeSubstrate/getTriggerRun/index.ts
|
|
11689
|
+
var getTriggerRunPlugin = definePlugin(
|
|
11690
|
+
(sdk) => createPluginMethod(sdk, {
|
|
11691
|
+
...codeSubstrateDefaults,
|
|
11692
|
+
name: "getTriggerRun",
|
|
11693
|
+
type: "item",
|
|
11694
|
+
itemType: "WorkflowRun",
|
|
11695
|
+
inputSchema: GetTriggerRunOptionsSchema,
|
|
11696
|
+
outputSchema: GetTriggerRunResponseSchema,
|
|
11697
|
+
// No resolver for `trigger` — users typically have the trigger id
|
|
11698
|
+
// from a recent trigger fire and pass it directly. Authoring a
|
|
11699
|
+
// picker would require listing triggers across all workflows,
|
|
11700
|
+
// which has no clean entry point today.
|
|
11701
|
+
handler: async ({ sdk: sdk2, options }) => {
|
|
11702
|
+
const raw = await sdk2.context.api.get(
|
|
11703
|
+
`/durableworkflowzaps/api/v0/workflows/triggers/${encodeURIComponent(options.trigger)}/run`,
|
|
11704
|
+
{
|
|
11705
|
+
authRequired: true,
|
|
11706
|
+
resource: { type: "workflow-trigger", id: options.trigger }
|
|
11707
|
+
}
|
|
11708
|
+
);
|
|
11709
|
+
const data = GetTriggerRunResponseSchema.parse(raw);
|
|
11710
|
+
return { data };
|
|
11711
|
+
}
|
|
11712
|
+
})
|
|
11713
|
+
);
|
|
11714
|
+
var TriggerWorkflowLookupResponseSchema = z.object({
|
|
11715
|
+
trigger_url: z.string()
|
|
11716
|
+
}).passthrough();
|
|
11717
|
+
var TriggerWorkflowOptionsSchema = z.object({
|
|
11718
|
+
workflow: z.string().uuid().describe("Durable workflow ID"),
|
|
11719
|
+
input: z.unknown().optional().describe(
|
|
11720
|
+
"JSON payload delivered as the trigger body. Sent as `application/json`; omit to fire with an empty body."
|
|
11721
|
+
)
|
|
11722
|
+
}).describe(
|
|
11723
|
+
"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."
|
|
11724
|
+
);
|
|
11725
|
+
var TriggerWorkflowResponseSchema = z.object({
|
|
11726
|
+
workflow: z.string().describe("The workflow ID that was triggered"),
|
|
11727
|
+
status: z.number().int().describe("HTTP status returned by the trigger endpoint"),
|
|
11728
|
+
body: z.unknown().describe(
|
|
11729
|
+
"Response body from the trigger endpoint. Parsed as JSON when the response body parses, otherwise returned as the raw response text."
|
|
11730
|
+
)
|
|
11731
|
+
});
|
|
11732
|
+
|
|
11733
|
+
// src/plugins/codeSubstrate/triggerWorkflow/index.ts
|
|
11734
|
+
var triggerWorkflowPlugin = definePlugin(
|
|
11735
|
+
(sdk) => createPluginMethod(sdk, {
|
|
11736
|
+
...codeSubstrateDefaults,
|
|
11737
|
+
name: "triggerWorkflow",
|
|
11738
|
+
type: "create",
|
|
11739
|
+
itemType: "WorkflowRun",
|
|
11740
|
+
inputSchema: TriggerWorkflowOptionsSchema,
|
|
11741
|
+
outputSchema: TriggerWorkflowResponseSchema,
|
|
11742
|
+
resolvers: { workflow: workflowIdResolver },
|
|
11743
|
+
handler: async ({ sdk: sdk2, options }) => {
|
|
11744
|
+
const rawWorkflow = await sdk2.context.api.get(
|
|
11745
|
+
`/durableworkflowzaps/api/v0/workflows/${encodeURIComponent(options.workflow)}`,
|
|
11746
|
+
{
|
|
11747
|
+
authRequired: true,
|
|
11748
|
+
resource: { type: "workflow", id: options.workflow }
|
|
11749
|
+
}
|
|
11750
|
+
);
|
|
11751
|
+
const workflow = TriggerWorkflowLookupResponseSchema.parse(rawWorkflow);
|
|
11752
|
+
const fetch2 = sdk2.context.options.fetch ?? globalThis.fetch;
|
|
11753
|
+
const response = await fetch2(workflow.trigger_url, {
|
|
11754
|
+
method: "POST",
|
|
11755
|
+
headers: { "Content-Type": "application/json" },
|
|
11756
|
+
body: options.input === void 0 ? void 0 : JSON.stringify(options.input)
|
|
11757
|
+
});
|
|
11758
|
+
const text = await response.text().catch(() => "");
|
|
11759
|
+
let body = text;
|
|
11760
|
+
if (text) {
|
|
11761
|
+
try {
|
|
11762
|
+
body = JSON.parse(text);
|
|
11763
|
+
} catch {
|
|
11764
|
+
body = text;
|
|
11765
|
+
}
|
|
11766
|
+
}
|
|
11767
|
+
if (!response.ok) {
|
|
11768
|
+
throw new ZapierApiError(
|
|
11769
|
+
`Trigger failed: ${response.status} ${response.statusText}: ${text || "(empty body)"}`,
|
|
11770
|
+
{ statusCode: response.status, response: body }
|
|
11771
|
+
);
|
|
11772
|
+
}
|
|
11773
|
+
const data = {
|
|
11774
|
+
workflow: options.workflow,
|
|
11775
|
+
status: response.status,
|
|
11776
|
+
body
|
|
11777
|
+
};
|
|
11778
|
+
return { data };
|
|
11779
|
+
}
|
|
11780
|
+
})
|
|
11781
|
+
);
|
|
11327
11782
|
|
|
11328
11783
|
// src/utils/batch-utils.ts
|
|
11329
11784
|
var DEFAULT_CONCURRENCY = 10;
|
|
@@ -11475,15 +11930,18 @@ var BaseSdkOptionsSchema = z.object({
|
|
|
11475
11930
|
|
|
11476
11931
|
// src/plugins/registry/index.ts
|
|
11477
11932
|
var registryPlugin = definePlugin((_sdk) => {
|
|
11478
|
-
|
|
11933
|
+
logDeprecation2(
|
|
11479
11934
|
"registryPlugin is deprecated and a no-op; getRegistry is now built into every sdk. Remove .addPlugin(registryPlugin)."
|
|
11480
11935
|
);
|
|
11481
11936
|
return {};
|
|
11482
11937
|
});
|
|
11483
11938
|
|
|
11484
11939
|
// src/experimental.ts
|
|
11940
|
+
function createZapierSdkStack2(options = {}) {
|
|
11941
|
+
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);
|
|
11942
|
+
}
|
|
11485
11943
|
function createZapierSdk2(options = {}) {
|
|
11486
|
-
return
|
|
11944
|
+
return withDeprecatedAddPlugin(createZapierSdkStack2(options).toSdk());
|
|
11487
11945
|
}
|
|
11488
11946
|
|
|
11489
|
-
export { ActionKeyPropertySchema, ActionPropertySchema, ActionTimeoutMsPropertySchema, ActionTypePropertySchema, AppKeyPropertySchema, AppPropertySchema, AppsPropertySchema, AuthenticationIdPropertySchema, BaseSdkOptionsSchema, CONTEXT_CACHE_MAX_SIZE, CONTEXT_CACHE_TTL_MS, ClientCredentialsObjectSchema, ConnectionEntrySchema, ConnectionIdPropertySchema, ConnectionPropertySchema, ConnectionsMapSchema, ConnectionsPropertySchema, CredentialsFunctionSchema, CredentialsObjectSchema, CredentialsSchema, DEFAULT_ACTION_TIMEOUT_MS, DEFAULT_APPROVAL_TIMEOUT_MS, DEFAULT_CONFIG_PATH, DEFAULT_MAX_APPROVAL_RETRIES, DEFAULT_PAGE_SIZE, DebugPropertySchema, FieldsPropertySchema, InputFieldPropertySchema, InputsPropertySchema, LeaseLimitPropertySchema, LeasePropertySchema, LeaseSecondsPropertySchema, LimitPropertySchema, MAX_CONCURRENCY_LIMIT, MAX_PAGE_LIMIT, OffsetPropertySchema, OutputPropertySchema, ParamsPropertySchema, PkceCredentialsObjectSchema, RecordPropertySchema, RecordsPropertySchema, RelayFetchSchema, RelayRequestSchema, ResolvedCredentialsSchema, TablePropertySchema, TablesPropertySchema, TriggerInboxNamePropertySchema, TriggerInboxPropertySchema, ZAPIER_BASE_URL, ZAPIER_MAX_CONCURRENT_REQUESTS, ZAPIER_MAX_NETWORK_RETRIES, ZAPIER_MAX_NETWORK_RETRY_DELAY_MS, ZapierAbortDrainSignal, ZapierActionError, ZapierApiError, ZapierAppNotFoundError, ZapierApprovalError, ZapierAuthenticationError, ZapierBundleError, ZapierConfigurationError, ZapierConflictError, ZapierError, ZapierNotFoundError, ZapierRateLimitError, ZapierRelayError, ZapierReleaseTriggerMessageSignal, ZapierResourceNotFoundError, ZapierSignal, ZapierTimeoutError, ZapierUnknownError, ZapierValidationError, actionKeyResolver, actionTypeResolver, apiPlugin, appKeyResolver, appsPlugin, connectionIdGenericResolver as authenticationIdGenericResolver, connectionIdResolver as authenticationIdResolver, batch, buildApplicationLifecycleEvent, buildCapabilityMessage, buildErrorEvent, buildErrorEventWithContext, buildMethodCalledEvent, cleanupEventListeners, clearTokenCache, clientCredentialsNameResolver, clientIdResolver, composePlugins, connectionIdGenericResolver, connectionIdResolver, connectionsPlugin, createBaseEvent, createClientCredentialsPlugin, createFunction, createMemoryCache, createOptionsPlugin, createPaginatedPluginMethod, createPluginMethod, createSdk, createTableFieldsPlugin, createTablePlugin, createTableRecordsPlugin, createZapierApi, createZapierSdk2 as createZapierSdk, createZapierSdkWithoutRegistry, definePlugin, deleteClientCredentialsPlugin, deleteTableFieldsPlugin, deleteTablePlugin, deleteTableRecordsPlugin, durableRunIdResolver, eventEmissionPlugin, fetchPlugin, findFirstConnectionPlugin, findManifestEntry, findUniqueConnectionPlugin, formatErrorMessage, generateEventId, getActionInputFieldsSchemaPlugin, getActionPlugin, getAppPlugin, getBaseUrlFromCredentials, getCiPlatform, getClientIdFromCredentials, getConnectionPlugin, getCpuTime, getCurrentTimestamp, getMemoryUsage, getOrCreateApiClient, getOsInfo, getPlatformVersions, getPreferredManifestEntryKey, getProfilePlugin, getReleaseId, getTablePlugin, getTableRecordPlugin, getTokenFromCliLogin, getZapierApprovalMode, getZapierDefaultApprovalMode, getZapierSdkService, injectCliLogin, inputFieldKeyResolver, inputsAllOptionalResolver, inputsResolver, invalidateCachedToken, invalidateCredentialsToken, isCi, isCliLoginAvailable, isClientCredentials, isCredentialsFunction, isCredentialsObject, isPkceCredentials, isPositional, listActionInputFieldChoicesPlugin, listActionInputFieldsPlugin, listActionsPlugin, listAppsPlugin, listClientCredentialsPlugin, listConnectionsPlugin, listTableFieldsPlugin, listTableRecordsPlugin, listTablesPlugin, logDeprecation, manifestPlugin, parseConcurrencyEnvVar, readManifestFromFile, registryPlugin, requestPlugin, resetDeprecationWarnings, resolveAuthToken, resolveCredentials, resolveCredentialsFromEnv, runActionPlugin, runWithTelemetryContext, tableFieldIdsResolver, tableFieldsResolver, tableFiltersResolver, tableIdResolver, tableNameResolver, tableRecordIdResolver, tableRecordIdsResolver, tableRecordsResolver, tableSortResolver, tableUpdateRecordsResolver, toSnakeCase, toTitleCase, triggerInboxResolver, triggerMessagesResolver, updateTableRecordsPlugin, workflowIdResolver, workflowVersionIdResolver };
|
|
11947
|
+
export { ActionKeyPropertySchema, ActionPropertySchema, ActionTimeoutMsPropertySchema, ActionTypePropertySchema, AppKeyPropertySchema, AppPropertySchema, AppsPropertySchema, AuthenticationIdPropertySchema, BaseSdkOptionsSchema, CONTEXT_CACHE_MAX_SIZE, CONTEXT_CACHE_TTL_MS, CORE_ERROR_SYMBOL, ClientCredentialsObjectSchema, ConnectionEntrySchema, ConnectionIdPropertySchema, ConnectionPropertySchema, ConnectionsMapSchema, ConnectionsPropertySchema, CoreErrorCode, CredentialsFunctionSchema, CredentialsObjectSchema, CredentialsSchema, DEFAULT_ACTION_TIMEOUT_MS, DEFAULT_APPROVAL_TIMEOUT_MS, DEFAULT_CONFIG_PATH, DEFAULT_MAX_APPROVAL_RETRIES, DEFAULT_PAGE_SIZE, DebugPropertySchema, FieldsPropertySchema, InputFieldPropertySchema, InputsPropertySchema, LeaseLimitPropertySchema, LeasePropertySchema, LeaseSecondsPropertySchema, LimitPropertySchema, MAX_CONCURRENCY_LIMIT, MAX_PAGE_LIMIT, OffsetPropertySchema, OutputPropertySchema, ParamsPropertySchema, PkceCredentialsObjectSchema, RecordPropertySchema, RecordsPropertySchema, RelayFetchSchema, RelayRequestSchema, ResolvedCredentialsSchema, TablePropertySchema, TablesPropertySchema, TriggerInboxNamePropertySchema, TriggerInboxPropertySchema, ZAPIER_BASE_URL, ZAPIER_MAX_CONCURRENT_REQUESTS, ZAPIER_MAX_NETWORK_RETRIES, ZAPIER_MAX_NETWORK_RETRY_DELAY_MS, ZapierAbortDrainSignal, ZapierActionError, ZapierApiError, ZapierAppNotFoundError, ZapierApprovalError, ZapierAuthenticationError, ZapierBundleError, ZapierConfigurationError, ZapierConflictError, ZapierError, ZapierNotFoundError, ZapierRateLimitError, ZapierRelayError, ZapierReleaseTriggerMessageSignal, ZapierResourceNotFoundError, ZapierSignal, ZapierTimeoutError, ZapierUnknownError, ZapierValidationError, actionKeyResolver, actionTypeResolver, addPlugin, apiPlugin, appKeyResolver, appsPlugin, connectionIdGenericResolver as authenticationIdGenericResolver, connectionIdResolver as authenticationIdResolver, batch, buildApplicationLifecycleEvent, buildCapabilityMessage, buildErrorEvent, buildErrorEventWithContext, buildMethodCalledEvent, cleanupEventListeners, clearTokenCache, clientCredentialsNameResolver, clientIdResolver, composePlugins, connectionIdGenericResolver, connectionIdResolver, connectionsPlugin, createBaseEvent, createClientCredentialsPlugin, createCorePlugin, createFunction, createMemoryCache, createOptionsPlugin, createPaginatedPluginMethod, createPluginMethod, createPluginStack, createSdk, createTableFieldsPlugin, createTablePlugin, createTableRecordsPlugin, createZapierApi, createZapierCoreStack, createZapierSdk2 as createZapierSdk, createZapierSdkStack2 as createZapierSdkStack, createZapierSdkWithoutRegistry, definePlugin, deleteClientCredentialsPlugin, deleteTableFieldsPlugin, deleteTablePlugin, deleteTableRecordsPlugin, durableRunIdResolver, eventEmissionPlugin, fetchPlugin, findFirstConnectionPlugin, findManifestEntry, findUniqueConnectionPlugin, formatErrorMessage, generateEventId, getActionInputFieldsSchemaPlugin, getActionPlugin, getAppPlugin, getBaseUrlFromCredentials, getCiPlatform, getClientIdFromCredentials, getConnectionPlugin, getCoreErrorCause, getCoreErrorCode, getCpuTime, getCurrentTimestamp, getMemoryUsage, getOrCreateApiClient, getOsInfo, getPlatformVersions, getPreferredManifestEntryKey, getProfilePlugin, getReleaseId, getTablePlugin, getTableRecordPlugin, getTokenFromCliLogin, getZapierApprovalMode, getZapierDefaultApprovalMode, getZapierSdkService, injectCliLogin, inputFieldKeyResolver, inputsAllOptionalResolver, inputsResolver, invalidateCachedToken, invalidateCredentialsToken, isCi, isCliLoginAvailable, isClientCredentials, isCoreError, isCredentialsFunction, isCredentialsObject, isPkceCredentials, isPositional, listActionInputFieldChoicesPlugin, listActionInputFieldsPlugin, listActionsPlugin, listAppsPlugin, listClientCredentialsPlugin, listConnectionsPlugin, listTableFieldsPlugin, listTableRecordsPlugin, listTablesPlugin, logDeprecation2 as logDeprecation, manifestPlugin, parseConcurrencyEnvVar, readManifestFromFile, registryPlugin, requestPlugin, resetDeprecationWarnings2 as resetDeprecationWarnings, resolveAuthToken, resolveCredentials, resolveCredentialsFromEnv, runActionPlugin, runInMethodScope, runWithTelemetryContext, tableFieldIdsResolver, tableFieldsResolver, tableFiltersResolver, tableIdResolver, tableNameResolver, tableRecordIdResolver, tableRecordIdsResolver, tableRecordsResolver, tableSortResolver, tableUpdateRecordsResolver, toSnakeCase, toTitleCase, triggerInboxResolver, triggerMessagesResolver, updateTableRecordsPlugin, workflowIdResolver, workflowRunIdResolver, workflowVersionIdResolver, zapierAdaptError };
|