@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/index.cjs
CHANGED
|
@@ -13,547 +13,271 @@ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require
|
|
|
13
13
|
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
14
14
|
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
15
15
|
});
|
|
16
|
-
function
|
|
17
|
-
|
|
18
|
-
formatMeta
|
|
19
|
-
});
|
|
20
|
-
return schema;
|
|
21
|
-
}
|
|
22
|
-
function withPositional(schema) {
|
|
23
|
-
Object.assign(schema._zod.def, {
|
|
24
|
-
positionalMeta: { positional: true }
|
|
25
|
-
});
|
|
26
|
-
return schema;
|
|
27
|
-
}
|
|
28
|
-
function schemaHasPositionalMeta(schema) {
|
|
29
|
-
return "positionalMeta" in schema._zod.def;
|
|
16
|
+
function toTitleCase(input) {
|
|
17
|
+
return input.replace(/([a-z0-9])([A-Z])/g, "$1 $2").replace(/[_\-]+/g, " ").replace(/\s+/g, " ").trim().split(" ").map((word) => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase()).join(" ");
|
|
30
18
|
}
|
|
31
|
-
function
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
if (schema instanceof zod.z.ZodOptional) {
|
|
36
|
-
return isPositional(schema._zod.def.innerType);
|
|
19
|
+
function toSnakeCase(input) {
|
|
20
|
+
let result = input.replace(/([a-z0-9])([A-Z])/g, "$1_$2").replace(/[\s\-]+/g, "_").replace(/_+/g, "_").replace(/^_|_$/g, "").toLowerCase();
|
|
21
|
+
if (/^[0-9]/.test(result)) {
|
|
22
|
+
result = "_" + result;
|
|
37
23
|
}
|
|
38
|
-
|
|
39
|
-
|
|
24
|
+
return result;
|
|
25
|
+
}
|
|
26
|
+
function pluralize(word) {
|
|
27
|
+
if (/s$/i.test(word)) return word;
|
|
28
|
+
if (/[bcdfghjklmnpqrstvwxz]y$/i.test(word)) {
|
|
29
|
+
return word.slice(0, -1) + "ies";
|
|
40
30
|
}
|
|
41
|
-
return
|
|
31
|
+
return word + "s";
|
|
42
32
|
}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
function getZapierSdkService() {
|
|
47
|
-
return globalThis.process?.env?.ZAPIER_SDK_SERVICE;
|
|
33
|
+
function pluralizeLastWord(title) {
|
|
34
|
+
const words = title.split(" ");
|
|
35
|
+
return [...words.slice(0, -1), pluralize(words[words.length - 1])].join(" ");
|
|
48
36
|
}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
return
|
|
37
|
+
function resolveCategoryDefinition(ref) {
|
|
38
|
+
const def = typeof ref === "string" ? { key: ref } : ref;
|
|
39
|
+
const title = def.title ?? toTitleCase(def.key);
|
|
40
|
+
return {
|
|
41
|
+
key: def.key,
|
|
42
|
+
title,
|
|
43
|
+
titlePlural: def.titlePlural ?? pluralizeLastWord(title)
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
function canonicalInputSchema(schema) {
|
|
47
|
+
if (schema instanceof zod.z.ZodUnion) {
|
|
48
|
+
return schema.options[0];
|
|
61
49
|
}
|
|
62
|
-
return
|
|
50
|
+
return schema;
|
|
63
51
|
}
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
const
|
|
73
|
-
|
|
52
|
+
function buildRegistry({
|
|
53
|
+
sdk,
|
|
54
|
+
meta,
|
|
55
|
+
packageFilter
|
|
56
|
+
}) {
|
|
57
|
+
const definitionsByKey = /* @__PURE__ */ new Map();
|
|
58
|
+
const objectDeclaredKeys = /* @__PURE__ */ new Set();
|
|
59
|
+
for (const m of Object.values(meta)) {
|
|
60
|
+
for (const ref of m.categories ?? []) {
|
|
61
|
+
const key = typeof ref === "string" ? ref : ref.key;
|
|
62
|
+
if (typeof ref === "object") {
|
|
63
|
+
objectDeclaredKeys.add(key);
|
|
64
|
+
definitionsByKey.set(key, resolveCategoryDefinition(ref));
|
|
65
|
+
} else if (!objectDeclaredKeys.has(key)) {
|
|
66
|
+
definitionsByKey.set(key, resolveCategoryDefinition(ref));
|
|
67
|
+
}
|
|
68
|
+
}
|
|
74
69
|
}
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
70
|
+
if (!definitionsByKey.has("other")) {
|
|
71
|
+
definitionsByKey.set("other", resolveCategoryDefinition("other"));
|
|
72
|
+
}
|
|
73
|
+
const knownCategories = Array.from(definitionsByKey.keys());
|
|
74
|
+
const functions = Object.keys(meta).filter((key) => {
|
|
75
|
+
const property = sdk[key];
|
|
76
|
+
if (typeof property === "function") return true;
|
|
77
|
+
const [rootKey] = key.split(".");
|
|
78
|
+
const rootProperty = sdk[rootKey];
|
|
79
|
+
return typeof rootProperty === "object" && rootProperty !== null;
|
|
80
|
+
}).map((key) => {
|
|
81
|
+
const m = meta[key];
|
|
82
|
+
return {
|
|
83
|
+
name: key,
|
|
84
|
+
description: m.description,
|
|
85
|
+
type: m.type,
|
|
86
|
+
itemType: m.itemType,
|
|
87
|
+
returnType: m.returnType,
|
|
88
|
+
inputSchema: canonicalInputSchema(m.inputSchema),
|
|
89
|
+
inputParameters: m.inputParameters,
|
|
90
|
+
outputSchema: m.outputSchema,
|
|
91
|
+
categories: (m.categories ?? []).map(
|
|
92
|
+
(c) => typeof c === "string" ? c : c.key
|
|
93
|
+
),
|
|
94
|
+
resolvers: m.resolvers,
|
|
95
|
+
formatter: m.formatter,
|
|
96
|
+
experimental: m.experimental,
|
|
97
|
+
packages: m.packages,
|
|
98
|
+
confirm: m.confirm ?? (m.type === "delete" ? "delete" : void 0),
|
|
99
|
+
deprecation: m.deprecation,
|
|
100
|
+
aliases: m.aliases,
|
|
101
|
+
supportsJsonOutput: m.supportsJsonOutput ?? true
|
|
102
|
+
};
|
|
103
|
+
}).sort((a, b) => a.name.localeCompare(b.name));
|
|
104
|
+
const filteredFunctions = packageFilter ? functions.filter((f) => !f.packages || f.packages.includes(packageFilter)) : functions;
|
|
105
|
+
const filteredCategories = knownCategories.slice().sort((a, b) => {
|
|
106
|
+
if (a === "other") return 1;
|
|
107
|
+
if (b === "other") return -1;
|
|
108
|
+
return definitionsByKey.get(a).title.localeCompare(definitionsByKey.get(b).title);
|
|
109
|
+
}).map((categoryKey) => {
|
|
110
|
+
const categoryFunctions = filteredFunctions.filter(
|
|
111
|
+
(f) => f.categories.includes(categoryKey) || categoryKey === "other" && !f.categories.some((c) => knownCategories.includes(c))
|
|
112
|
+
).map((f) => f.name).sort();
|
|
113
|
+
const def = definitionsByKey.get(categoryKey);
|
|
114
|
+
return {
|
|
115
|
+
key: categoryKey,
|
|
116
|
+
title: def.title,
|
|
117
|
+
titlePlural: def.titlePlural,
|
|
118
|
+
functions: categoryFunctions
|
|
119
|
+
};
|
|
120
|
+
}).filter((category) => category.functions.length > 0);
|
|
121
|
+
return { functions: filteredFunctions, categories: filteredCategories };
|
|
79
122
|
}
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
123
|
+
function composeVoid(existing, added) {
|
|
124
|
+
if (!existing) return added;
|
|
125
|
+
if (!added) return existing;
|
|
126
|
+
return (ctx) => {
|
|
127
|
+
existing(ctx);
|
|
128
|
+
added(ctx);
|
|
129
|
+
};
|
|
86
130
|
}
|
|
87
|
-
function
|
|
88
|
-
const
|
|
89
|
-
|
|
131
|
+
function buildHooks(existing, added) {
|
|
132
|
+
const result = {};
|
|
133
|
+
const start = composeVoid(existing.onMethodStart, added.onMethodStart);
|
|
134
|
+
if (start) result.onMethodStart = start;
|
|
135
|
+
const end = composeVoid(existing.onMethodEnd, added.onMethodEnd);
|
|
136
|
+
if (end) result.onMethodEnd = end;
|
|
137
|
+
return result;
|
|
90
138
|
}
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
);
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
"
|
|
108
|
-
"
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
"filter"
|
|
112
|
-
]).describe("Action type that matches the action's defined type");
|
|
113
|
-
var ActionKeyPropertySchema = zod.z.string().min(1).describe("Action key to execute");
|
|
114
|
-
var ActionPropertySchema = withPositional(
|
|
115
|
-
zod.z.string().min(1).describe("Action key (e.g., 'send_message' or 'find_row')")
|
|
116
|
-
);
|
|
117
|
-
var InputFieldPropertySchema = withPositional(
|
|
118
|
-
zod.z.string().min(1).describe("Input field key to get choices for")
|
|
119
|
-
);
|
|
120
|
-
var ConnectionIdPropertySchema = zod.z.union([zod.z.string(), zod.z.number().int().positive()]).describe("Connection ID to use for this action");
|
|
121
|
-
var AuthenticationIdPropertySchema = ConnectionIdPropertySchema.meta({
|
|
122
|
-
deprecated: true
|
|
123
|
-
});
|
|
124
|
-
var ConnectionPropertySchema = zod.z.union([zod.z.string(), zod.z.number().int().positive()]).describe(
|
|
125
|
-
"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."
|
|
126
|
-
);
|
|
127
|
-
var InputsPropertySchema = zod.z.record(zod.z.string(), zod.z.unknown()).describe("Input parameters for the action");
|
|
128
|
-
var LimitPropertySchema = zod.z.number().int().min(1).max(MAX_PAGE_LIMIT).default(50).describe("Maximum number of items to return");
|
|
129
|
-
var OffsetPropertySchema = zod.z.number().int().min(0).default(0).describe("Number of items to skip for pagination");
|
|
130
|
-
var OutputPropertySchema = zod.z.string().describe("Output file path");
|
|
131
|
-
var DebugPropertySchema = zod.z.boolean().default(false).describe("Enable debug logging");
|
|
132
|
-
var ParamsPropertySchema = zod.z.record(zod.z.string(), zod.z.unknown()).describe("Additional parameters");
|
|
133
|
-
var ActionTimeoutMsPropertySchema = zod.z.number().min(1e3).optional().describe(
|
|
134
|
-
`Maximum time to wait for action completion in milliseconds (default: ${DEFAULT_ACTION_TIMEOUT_MS})`
|
|
135
|
-
);
|
|
136
|
-
var TablePropertySchema = withPositional(
|
|
137
|
-
zod.z.string().regex(/^[A-Z0-9]{26}$/, "Table ID must be a valid ULID").describe("The unique identifier of the table")
|
|
138
|
-
);
|
|
139
|
-
var RecordPropertySchema = withPositional(
|
|
140
|
-
zod.z.string().regex(/^[A-Z0-9]{26}$/, "Record ID must be a valid ULID").describe("The unique identifier of the record")
|
|
141
|
-
);
|
|
142
|
-
var RecordsPropertySchema = zod.z.array(zod.z.string().regex(/^[A-Z0-9]{26}$/, "Record ID must be a valid ULID")).min(1).max(100).describe("Record IDs to operate on");
|
|
143
|
-
var FieldsPropertySchema = zod.z.array(zod.z.union([zod.z.string(), zod.z.number()])).describe(
|
|
144
|
-
'Fields to operate on. Accepts field names (e.g., "Email") or IDs (e.g., "f6", "6", or 6).'
|
|
145
|
-
);
|
|
146
|
-
var AppsPropertySchema = zod.z.array(zod.z.string()).describe("Filter by app keys (e.g., 'SlackCLIAPI' or slug like 'github')");
|
|
147
|
-
var TablesPropertySchema = zod.z.array(zod.z.string()).describe("Filter by specific table IDs");
|
|
148
|
-
var ConnectionsPropertySchema = zod.z.array(zod.z.string()).describe("List of connection IDs to filter by");
|
|
149
|
-
var TriggerInboxPropertySchema = withPositional(
|
|
150
|
-
zod.z.string().min(1).describe(
|
|
151
|
-
"Trigger inbox identifier \u2014 UUID or name. Non-UUID values are resolved by name via the inbox list endpoint."
|
|
152
|
-
)
|
|
153
|
-
);
|
|
154
|
-
var TriggerInboxNamePropertySchema = zod.z.string().min(1).max(100).describe(
|
|
155
|
-
"Inbox name; unique per (user, account). Enables get-or-create on createTriggerInbox."
|
|
156
|
-
);
|
|
157
|
-
var LeasePropertySchema = zod.z.string().min(1).describe("Lease ID returned from leaseTriggerInboxMessages");
|
|
158
|
-
var LeaseSecondsPropertySchema = zod.z.number().int().min(1).max(3600).describe(
|
|
159
|
-
"Seconds until the lease expires; messages return to available if not acked. API default is 300 (5 minutes)."
|
|
160
|
-
);
|
|
161
|
-
var LeaseLimitPropertySchema = zod.z.number().int().min(1).max(100).describe("Maximum messages to lease in a single batch (1-100)");
|
|
162
|
-
|
|
163
|
-
// src/types/errors.ts
|
|
164
|
-
var ZapierError = class extends Error {
|
|
139
|
+
function createDeprecationLogger(tag) {
|
|
140
|
+
const loggedDeprecations = /* @__PURE__ */ new Set();
|
|
141
|
+
return {
|
|
142
|
+
logDeprecation(message) {
|
|
143
|
+
if (loggedDeprecations.has(message)) return;
|
|
144
|
+
loggedDeprecations.add(message);
|
|
145
|
+
console.warn(`[${tag}] Deprecation: ${message}`);
|
|
146
|
+
},
|
|
147
|
+
resetDeprecationWarnings() {
|
|
148
|
+
loggedDeprecations.clear();
|
|
149
|
+
}
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
var { logDeprecation} = createDeprecationLogger("core");
|
|
153
|
+
var CORE_ERROR_SYMBOL = Symbol.for("kitcore.error");
|
|
154
|
+
var CoreErrorCode = {
|
|
155
|
+
Validation: "VALIDATION_ERROR",
|
|
156
|
+
Unknown: "UNKNOWN_ERROR"
|
|
157
|
+
};
|
|
158
|
+
var CoreError = class extends Error {
|
|
165
159
|
constructor(message, options = {}) {
|
|
166
160
|
super(message);
|
|
167
|
-
this.
|
|
168
|
-
this.
|
|
169
|
-
this.
|
|
170
|
-
this.
|
|
161
|
+
this.name = "CoreError";
|
|
162
|
+
if (options.statusCode !== void 0) this.statusCode = options.statusCode;
|
|
163
|
+
if (options.errors !== void 0) this.errors = options.errors;
|
|
164
|
+
if (options.cause !== void 0) this.cause = options.cause;
|
|
165
|
+
if (options.response !== void 0) this.response = options.response;
|
|
171
166
|
Object.setPrototypeOf(this, new.target.prototype);
|
|
172
167
|
}
|
|
173
168
|
};
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
169
|
+
function createCoreError(options, adaptError) {
|
|
170
|
+
const error = adaptError?.(options) ?? new CoreError(options.message, { cause: options.cause });
|
|
171
|
+
Object.defineProperty(error, CORE_ERROR_SYMBOL, {
|
|
172
|
+
value: true,
|
|
173
|
+
enumerable: false,
|
|
174
|
+
configurable: true,
|
|
175
|
+
writable: false
|
|
176
|
+
});
|
|
177
|
+
Object.defineProperty(error, "coreCode", {
|
|
178
|
+
value: options.code,
|
|
179
|
+
enumerable: false,
|
|
180
|
+
configurable: true,
|
|
181
|
+
writable: false
|
|
182
|
+
});
|
|
183
|
+
return error;
|
|
184
|
+
}
|
|
185
|
+
function isCoreError(value) {
|
|
186
|
+
return Boolean(
|
|
187
|
+
value && typeof value === "object" && value[CORE_ERROR_SYMBOL] === true
|
|
188
|
+
);
|
|
189
|
+
}
|
|
190
|
+
function getCoreErrorCode(value) {
|
|
191
|
+
if (!isCoreError(value)) return void 0;
|
|
192
|
+
return value.coreCode;
|
|
193
|
+
}
|
|
194
|
+
function getCoreErrorCause(value) {
|
|
195
|
+
if (!isCoreError(value)) return void 0;
|
|
196
|
+
return value.cause;
|
|
197
|
+
}
|
|
198
|
+
var CURSOR_VERSION = 1;
|
|
199
|
+
var CURSOR_SOURCE = {
|
|
200
|
+
API: "api",
|
|
201
|
+
SDK: "sdk"
|
|
203
202
|
};
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
super(message, options);
|
|
238
|
-
this.name = "ZapierBundleError";
|
|
239
|
-
this.code = "ZAPIER_BUNDLE_ERROR";
|
|
240
|
-
this.buildErrors = options.buildErrors;
|
|
241
|
-
}
|
|
242
|
-
};
|
|
243
|
-
var ZapierTimeoutError = class extends ZapierError {
|
|
244
|
-
constructor(message, options = {}) {
|
|
245
|
-
super(message, options);
|
|
246
|
-
this.name = "ZapierTimeoutError";
|
|
247
|
-
this.code = "ZAPIER_TIMEOUT_ERROR";
|
|
248
|
-
this.attempts = options.attempts;
|
|
249
|
-
this.maxAttempts = options.maxAttempts;
|
|
250
|
-
}
|
|
251
|
-
};
|
|
252
|
-
var ZapierActionError = class extends ZapierError {
|
|
253
|
-
constructor(message, options = {}) {
|
|
254
|
-
super(message, options);
|
|
255
|
-
this.name = "ZapierActionError";
|
|
256
|
-
this.code = "ZAPIER_ACTION_ERROR";
|
|
257
|
-
this.appKey = options.appKey;
|
|
258
|
-
this.actionKey = options.actionKey;
|
|
259
|
-
}
|
|
260
|
-
// Legacy accessor for backward compatibility
|
|
261
|
-
get actionErrors() {
|
|
262
|
-
return this.errors;
|
|
263
|
-
}
|
|
264
|
-
};
|
|
265
|
-
var ZapierConflictError = class extends ZapierError {
|
|
266
|
-
constructor(message, options = {}) {
|
|
267
|
-
super(message, options);
|
|
268
|
-
this.name = "ZapierConflictError";
|
|
269
|
-
this.code = "ZAPIER_CONFLICT_ERROR";
|
|
270
|
-
this.resourceType = options.resourceType;
|
|
271
|
-
}
|
|
272
|
-
};
|
|
273
|
-
var ZapierRateLimitError = class extends ZapierError {
|
|
274
|
-
constructor(message, options = {}) {
|
|
275
|
-
super(message, options);
|
|
276
|
-
this.name = "ZapierRateLimitError";
|
|
277
|
-
this.code = "ZAPIER_RATE_LIMIT_ERROR";
|
|
278
|
-
this.rateLimit = options.rateLimit ?? {};
|
|
279
|
-
this.retries = options.retries ?? 0;
|
|
280
|
-
}
|
|
281
|
-
};
|
|
282
|
-
var ZapierApprovalError = class extends ZapierError {
|
|
283
|
-
constructor(message, options = {}) {
|
|
284
|
-
super(message, options);
|
|
285
|
-
this.name = "ZapierApprovalError";
|
|
286
|
-
this.code = "ZAPIER_APPROVAL_ERROR";
|
|
287
|
-
this.approvalId = options.approvalId;
|
|
288
|
-
this.approvalStatus = options.status;
|
|
289
|
-
this.approvalUrl = options.approvalUrl;
|
|
290
|
-
this.pollUrl = options.pollUrl;
|
|
291
|
-
}
|
|
292
|
-
};
|
|
293
|
-
var ZapierRelayError = class extends ZapierError {
|
|
294
|
-
constructor(message, options = {}) {
|
|
295
|
-
super(message, options);
|
|
296
|
-
this.name = "ZapierRelayError";
|
|
297
|
-
this.code = "ZAPIER_RELAY_ERROR";
|
|
298
|
-
}
|
|
299
|
-
};
|
|
300
|
-
function formatErrorMessage(error) {
|
|
301
|
-
let message = error.message;
|
|
302
|
-
if (error.errors && error.errors.length > 0) {
|
|
303
|
-
const additionalErrors = error.errors.slice(1);
|
|
304
|
-
if (additionalErrors.length > 0) {
|
|
305
|
-
const errorDetails = additionalErrors.map((err) => ` \u2022 ${err.detail || err.title || err.code}`).join("\n");
|
|
306
|
-
message += "\n\nAdditional errors:\n" + errorDetails;
|
|
307
|
-
}
|
|
308
|
-
}
|
|
309
|
-
if (error instanceof ZapierAppNotFoundError && error.appKey) {
|
|
310
|
-
message += `
|
|
311
|
-
App key: ${error.appKey}`;
|
|
312
|
-
}
|
|
313
|
-
if (error instanceof ZapierActionError && (error.appKey || error.actionKey)) {
|
|
314
|
-
const context = [];
|
|
315
|
-
if (error.appKey) context.push(`App: ${error.appKey}`);
|
|
316
|
-
if (error.actionKey) context.push(`Action: ${error.actionKey}`);
|
|
317
|
-
message += `
|
|
318
|
-
${context.join(", ")}`;
|
|
319
|
-
}
|
|
320
|
-
if (error instanceof ZapierResourceNotFoundError && (error.resourceType || error.resourceId)) {
|
|
321
|
-
const context = [];
|
|
322
|
-
if (error.resourceType) context.push(`Type: ${error.resourceType}`);
|
|
323
|
-
if (error.resourceId) context.push(`ID: ${error.resourceId}`);
|
|
324
|
-
message += `
|
|
325
|
-
${context.join(", ")}`;
|
|
326
|
-
}
|
|
327
|
-
if (error instanceof ZapierConflictError && error.resourceType) {
|
|
328
|
-
message += `
|
|
329
|
-
Type: ${error.resourceType}`;
|
|
330
|
-
}
|
|
331
|
-
if (error instanceof ZapierTimeoutError && (error.attempts || error.maxAttempts)) {
|
|
332
|
-
const context = [];
|
|
333
|
-
if (error.attempts) context.push(`Attempts: ${error.attempts}`);
|
|
334
|
-
if (error.maxAttempts) context.push(`Max attempts: ${error.maxAttempts}`);
|
|
335
|
-
message += `
|
|
336
|
-
${context.join(", ")}`;
|
|
337
|
-
}
|
|
338
|
-
if (error instanceof ZapierBundleError && error.buildErrors && error.buildErrors.length > 0) {
|
|
339
|
-
message += "\n\nBuild errors:\n" + error.buildErrors.map((err) => ` \u2022 ${err}`).join("\n");
|
|
340
|
-
}
|
|
341
|
-
if (error instanceof ZapierApprovalError && error.approvalUrl) {
|
|
342
|
-
message += `
|
|
343
|
-
Approval URL: ${error.approvalUrl}`;
|
|
203
|
+
function encodeBase64(str) {
|
|
204
|
+
return btoa(
|
|
205
|
+
Array.from(
|
|
206
|
+
new TextEncoder().encode(str),
|
|
207
|
+
(b) => String.fromCharCode(b)
|
|
208
|
+
).join("")
|
|
209
|
+
);
|
|
210
|
+
}
|
|
211
|
+
function decodeBase64(str) {
|
|
212
|
+
return new TextDecoder().decode(
|
|
213
|
+
Uint8Array.from(atob(str), (c) => c.charCodeAt(0))
|
|
214
|
+
);
|
|
215
|
+
}
|
|
216
|
+
function encodeApiCursor(cursor) {
|
|
217
|
+
const envelope = {
|
|
218
|
+
v: CURSOR_VERSION,
|
|
219
|
+
source: CURSOR_SOURCE.API,
|
|
220
|
+
cursor
|
|
221
|
+
};
|
|
222
|
+
return encodeBase64(JSON.stringify(envelope));
|
|
223
|
+
}
|
|
224
|
+
function encodeSdkCursor(offset, cursor) {
|
|
225
|
+
const envelope = {
|
|
226
|
+
v: CURSOR_VERSION,
|
|
227
|
+
source: CURSOR_SOURCE.SDK,
|
|
228
|
+
cursor,
|
|
229
|
+
offset
|
|
230
|
+
};
|
|
231
|
+
return encodeBase64(JSON.stringify(envelope));
|
|
232
|
+
}
|
|
233
|
+
function decodeIncomingCursor(incoming) {
|
|
234
|
+
if (!incoming) {
|
|
235
|
+
return { offset: 0, cursor: void 0 };
|
|
344
236
|
}
|
|
345
|
-
|
|
346
|
-
const
|
|
347
|
-
const
|
|
348
|
-
if (
|
|
349
|
-
|
|
350
|
-
parts.push(`${used}/${limit} used`);
|
|
351
|
-
}
|
|
352
|
-
if (retryAfterMs !== void 0 && retryAfterMs > 0) {
|
|
353
|
-
parts.push(`retry in ${formatDuration(retryAfterMs)}`);
|
|
237
|
+
try {
|
|
238
|
+
const decoded = decodeBase64(incoming);
|
|
239
|
+
const envelope = JSON.parse(decoded);
|
|
240
|
+
if (envelope.v !== CURSOR_VERSION) {
|
|
241
|
+
return { offset: 0, cursor: incoming };
|
|
354
242
|
}
|
|
355
|
-
if (
|
|
356
|
-
|
|
357
|
-
`after ${error.retries} retr${error.retries === 1 ? "y" : "ies"}`
|
|
358
|
-
);
|
|
243
|
+
if (envelope.source === CURSOR_SOURCE.SDK) {
|
|
244
|
+
return { offset: envelope.offset ?? 0, cursor: envelope.cursor };
|
|
359
245
|
}
|
|
360
|
-
if (
|
|
361
|
-
|
|
362
|
-
${parts.join(", ")}`;
|
|
246
|
+
if (envelope.source === CURSOR_SOURCE.API) {
|
|
247
|
+
return { offset: 0, cursor: envelope.cursor };
|
|
363
248
|
}
|
|
249
|
+
return { offset: 0, cursor: incoming };
|
|
250
|
+
} catch {
|
|
251
|
+
return { offset: 0, cursor: incoming };
|
|
364
252
|
}
|
|
365
|
-
if (error.statusCode && !message.includes(`${error.statusCode}`)) {
|
|
366
|
-
message += `
|
|
367
|
-
HTTP Status: ${error.statusCode}`;
|
|
368
|
-
}
|
|
369
|
-
return message;
|
|
370
253
|
}
|
|
371
|
-
function
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
const
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
super(...arguments);
|
|
399
|
-
this.name = "ZapierAbortDrainSignal";
|
|
400
|
-
this.code = "ZAPIER_ABORT_DRAIN_SIGNAL";
|
|
401
|
-
}
|
|
402
|
-
};
|
|
403
|
-
var TriggerInboxCommandBaseSchema = zod.z.object({
|
|
404
|
-
inbox: TriggerInboxPropertySchema,
|
|
405
|
-
onMessage: zod.z.function().optional().meta({ exampleRequired: true }).describe(
|
|
406
|
-
"Per-message handler. Resolves to ack; rejects to release-or-leave per `releaseOnError`. Throw `ZapierReleaseTriggerMessageSignal` to release explicitly, or `ZapierAbortDrainSignal` to stop after the current batch."
|
|
407
|
-
),
|
|
408
|
-
concurrency: zod.z.number().int().min(1).optional().describe(
|
|
409
|
-
"Per-message handler workers running in parallel. Defaults to `leaseLimit`, or 1 if neither is set."
|
|
410
|
-
),
|
|
411
|
-
leaseLimit: zod.z.number().int().min(1).max(100).optional().describe(
|
|
412
|
-
"Per-lease HTTP batch size. Defaults to `concurrency`, or 1 if neither is set."
|
|
413
|
-
),
|
|
414
|
-
leaseSeconds: LeaseSecondsPropertySchema.optional(),
|
|
415
|
-
releaseOnError: zod.z.boolean().optional().describe(
|
|
416
|
-
"If true, errors release the message when the drain finishes. If false (default), errors leave it leased until the lease timeout. `ZapierReleaseTriggerMessageSignal` always releases regardless."
|
|
417
|
-
),
|
|
418
|
-
continueOnError: zod.z.boolean().optional().describe(
|
|
419
|
-
"If false (default, fail-fast), the first handler error rejects and stops the drain. If true, handler errors are observed via `onError` and the drain continues. SDK-level errors (lease / ack / release) reject regardless."
|
|
420
|
-
),
|
|
421
|
-
onError: zod.z.function().optional().describe(
|
|
422
|
-
"Per-message error observer for `continueOnError: true`. Called with the failure and the message; control-flow signals are filtered out. Throws from `onError` are swallowed."
|
|
423
|
-
),
|
|
424
|
-
signal: zod.z.custom((v) => v instanceof AbortSignal).optional().describe(
|
|
425
|
-
"Abort signal. Aborting cancels in-flight HTTP, releases unprocessed messages, and resolves cleanly. Errors during shutdown still reject."
|
|
426
|
-
)
|
|
427
|
-
});
|
|
428
|
-
TriggerInboxCommandBaseSchema.extend({
|
|
429
|
-
maxMessages: zod.z.number().int().min(1).optional().describe(
|
|
430
|
-
"Cap total messages drained. Defaults to draining the inbox until empty."
|
|
431
|
-
)
|
|
432
|
-
}).describe(
|
|
433
|
-
"Drain an existing trigger inbox: lease currently-available messages and process them via onMessage. Returns when the inbox is empty, maxMessages is reached, the abort signal fires, or a fatal error rejects."
|
|
434
|
-
);
|
|
435
|
-
TriggerInboxCommandBaseSchema.extend({
|
|
436
|
-
maxDrainIntervalSeconds: zod.z.number().int().min(1).optional().describe(
|
|
437
|
-
"Maximum seconds between empty-inbox poll attempts (default: 60). Caps the back-off cadence."
|
|
438
|
-
)
|
|
439
|
-
}).describe(
|
|
440
|
-
"Continuously consume a trigger inbox: drain currently-available messages, then poll with backoff for new arrivals, until aborted. Stop via the `signal` AbortSignal or by throwing `ZapierAbortDrainSignal` from a handler. Resolves cleanly on abort; rejects on a fatal error or a fail-fast handler error."
|
|
441
|
-
);
|
|
442
|
-
var ActionExecutionInputSchema = zod.z.object({
|
|
443
|
-
inputs: zod.z.record(zod.z.string(), zod.z.unknown()).optional(),
|
|
444
|
-
/** @deprecated Use `connection` instead. */
|
|
445
|
-
connectionId: ConnectionIdPropertySchema.optional().meta({
|
|
446
|
-
deprecated: true
|
|
447
|
-
}),
|
|
448
|
-
connection: ConnectionPropertySchema.optional(),
|
|
449
|
-
/** @deprecated Use connection instead */
|
|
450
|
-
authenticationId: AuthenticationIdPropertySchema.optional().meta({
|
|
451
|
-
deprecated: true
|
|
452
|
-
}),
|
|
453
|
-
timeoutMs: ActionTimeoutMsPropertySchema
|
|
454
|
-
}).describe(
|
|
455
|
-
"Execute an action with the given inputs for the bound app, as an alternative to runAction"
|
|
456
|
-
).meta({
|
|
457
|
-
aliases: { connectionId: "connection", authenticationId: "connection" }
|
|
458
|
-
});
|
|
459
|
-
var AppFactoryInputSchema = zod.z.object({
|
|
460
|
-
/** @deprecated Use `connection` instead. */
|
|
461
|
-
connectionId: ConnectionIdPropertySchema.optional().meta({
|
|
462
|
-
deprecated: true
|
|
463
|
-
}),
|
|
464
|
-
connection: ConnectionPropertySchema.optional(),
|
|
465
|
-
/** @deprecated Use connection instead */
|
|
466
|
-
authenticationId: AuthenticationIdPropertySchema.optional().meta({
|
|
467
|
-
deprecated: true
|
|
468
|
-
})
|
|
469
|
-
}).describe("Bind a connection alias or numeric connectionId to an app").meta({
|
|
470
|
-
aliases: { connectionId: "connection", authenticationId: "connection" }
|
|
471
|
-
});
|
|
472
|
-
|
|
473
|
-
// src/utils/pagination-utils.ts
|
|
474
|
-
var CURSOR_VERSION = 1;
|
|
475
|
-
var CURSOR_SOURCE = {
|
|
476
|
-
API: "api",
|
|
477
|
-
SDK: "sdk"
|
|
478
|
-
};
|
|
479
|
-
function encodeBase64(str) {
|
|
480
|
-
return btoa(
|
|
481
|
-
Array.from(
|
|
482
|
-
new TextEncoder().encode(str),
|
|
483
|
-
(b) => String.fromCharCode(b)
|
|
484
|
-
).join("")
|
|
485
|
-
);
|
|
486
|
-
}
|
|
487
|
-
function decodeBase64(str) {
|
|
488
|
-
return new TextDecoder().decode(
|
|
489
|
-
Uint8Array.from(atob(str), (c) => c.charCodeAt(0))
|
|
490
|
-
);
|
|
491
|
-
}
|
|
492
|
-
function encodeApiCursor(cursor) {
|
|
493
|
-
const envelope = {
|
|
494
|
-
v: CURSOR_VERSION,
|
|
495
|
-
source: CURSOR_SOURCE.API,
|
|
496
|
-
cursor
|
|
497
|
-
};
|
|
498
|
-
return encodeBase64(JSON.stringify(envelope));
|
|
499
|
-
}
|
|
500
|
-
function encodeSdkCursor(offset, cursor) {
|
|
501
|
-
const envelope = {
|
|
502
|
-
v: CURSOR_VERSION,
|
|
503
|
-
source: CURSOR_SOURCE.SDK,
|
|
504
|
-
cursor,
|
|
505
|
-
offset
|
|
506
|
-
};
|
|
507
|
-
return encodeBase64(JSON.stringify(envelope));
|
|
508
|
-
}
|
|
509
|
-
function decodeIncomingCursor(incoming) {
|
|
510
|
-
if (!incoming) {
|
|
511
|
-
return { offset: 0, cursor: void 0 };
|
|
512
|
-
}
|
|
513
|
-
try {
|
|
514
|
-
const decoded = decodeBase64(incoming);
|
|
515
|
-
const envelope = JSON.parse(decoded);
|
|
516
|
-
if (envelope.v !== CURSOR_VERSION) {
|
|
517
|
-
return { offset: 0, cursor: incoming };
|
|
518
|
-
}
|
|
519
|
-
if (envelope.source === CURSOR_SOURCE.SDK) {
|
|
520
|
-
return { offset: envelope.offset ?? 0, cursor: envelope.cursor };
|
|
521
|
-
}
|
|
522
|
-
if (envelope.source === CURSOR_SOURCE.API) {
|
|
523
|
-
return { offset: 0, cursor: envelope.cursor };
|
|
524
|
-
}
|
|
525
|
-
return { offset: 0, cursor: incoming };
|
|
526
|
-
} catch {
|
|
527
|
-
return { offset: 0, cursor: incoming };
|
|
528
|
-
}
|
|
529
|
-
}
|
|
530
|
-
async function* paginateMaxItemsWithUnencodedCursor(pageFunction, pageOptions) {
|
|
531
|
-
let cursor = pageOptions?.cursor;
|
|
532
|
-
let totalItemsYielded = 0;
|
|
533
|
-
const maxItems = pageOptions?.maxItems;
|
|
534
|
-
const pageSize = pageOptions?.pageSize;
|
|
535
|
-
do {
|
|
536
|
-
const options = {
|
|
537
|
-
...pageOptions || {},
|
|
538
|
-
cursor,
|
|
539
|
-
pageSize: maxItems !== void 0 && pageSize !== void 0 ? Math.min(pageSize, maxItems) : pageSize
|
|
540
|
-
};
|
|
541
|
-
const page = await pageFunction(options);
|
|
542
|
-
if (maxItems !== void 0) {
|
|
543
|
-
const remainingItems = maxItems - totalItemsYielded;
|
|
544
|
-
if (page.data.length >= remainingItems) {
|
|
545
|
-
yield {
|
|
546
|
-
...page,
|
|
547
|
-
data: page.data.slice(0, remainingItems),
|
|
548
|
-
nextCursor: void 0
|
|
549
|
-
};
|
|
550
|
-
break;
|
|
551
|
-
}
|
|
552
|
-
}
|
|
553
|
-
yield page;
|
|
554
|
-
totalItemsYielded += page.data.length;
|
|
555
|
-
cursor = page.nextCursor;
|
|
556
|
-
} while (cursor);
|
|
254
|
+
async function* paginateMaxItemsWithUnencodedCursor(pageFunction, pageOptions) {
|
|
255
|
+
let cursor = pageOptions?.cursor;
|
|
256
|
+
let totalItemsYielded = 0;
|
|
257
|
+
const maxItems = pageOptions?.maxItems;
|
|
258
|
+
const pageSize = pageOptions?.pageSize;
|
|
259
|
+
do {
|
|
260
|
+
const options = {
|
|
261
|
+
...pageOptions || {},
|
|
262
|
+
cursor,
|
|
263
|
+
pageSize: maxItems !== void 0 && pageSize !== void 0 ? Math.min(pageSize, maxItems) : pageSize
|
|
264
|
+
};
|
|
265
|
+
const page = await pageFunction(options);
|
|
266
|
+
if (maxItems !== void 0) {
|
|
267
|
+
const remainingItems = maxItems - totalItemsYielded;
|
|
268
|
+
if (page.data.length >= remainingItems) {
|
|
269
|
+
yield {
|
|
270
|
+
...page,
|
|
271
|
+
data: page.data.slice(0, remainingItems),
|
|
272
|
+
nextCursor: void 0
|
|
273
|
+
};
|
|
274
|
+
break;
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
yield page;
|
|
278
|
+
totalItemsYielded += page.data.length;
|
|
279
|
+
cursor = page.nextCursor;
|
|
280
|
+
} while (cursor);
|
|
557
281
|
}
|
|
558
282
|
async function* paginateBuffered(pageFunction, pageOptions) {
|
|
559
283
|
const pageSize = pageOptions?.pageSize;
|
|
@@ -723,438 +447,1025 @@ function concatPaginated({
|
|
|
723
447
|
function toIterable(source) {
|
|
724
448
|
return { [Symbol.asyncIterator]: () => source[Symbol.asyncIterator]() };
|
|
725
449
|
}
|
|
726
|
-
|
|
727
|
-
// src/utils/validation.ts
|
|
728
|
-
var validate = (schema, input) => {
|
|
450
|
+
var parseOrThrow = (schema, input, { adaptError } = {}) => {
|
|
729
451
|
const result = schema.safeParse(input);
|
|
730
452
|
if (!result.success) {
|
|
731
|
-
const errorMessages = result.error.issues.map((
|
|
732
|
-
const path =
|
|
733
|
-
return `${path}: ${
|
|
453
|
+
const errorMessages = result.error.issues.map((issue) => {
|
|
454
|
+
const path = issue.path.length > 0 ? issue.path.join(".") : "input";
|
|
455
|
+
return `${path}: ${issue.message}`;
|
|
734
456
|
});
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
457
|
+
throw createCoreError(
|
|
458
|
+
{
|
|
459
|
+
code: CoreErrorCode.Validation,
|
|
460
|
+
message: `Validation failed:
|
|
461
|
+
${errorMessages.join("\n ")}`,
|
|
462
|
+
details: {
|
|
463
|
+
zodErrors: result.error.issues,
|
|
464
|
+
input
|
|
465
|
+
}
|
|
466
|
+
},
|
|
467
|
+
adaptError
|
|
468
|
+
);
|
|
469
|
+
}
|
|
470
|
+
return result.data;
|
|
471
|
+
};
|
|
472
|
+
function createValidator(schema, { adaptError } = {}) {
|
|
473
|
+
return function validateFn(input) {
|
|
474
|
+
return parseOrThrow(schema, input, { adaptError });
|
|
475
|
+
};
|
|
476
|
+
}
|
|
477
|
+
var validateOptions = (schema, options, { adaptError } = {}) => parseOrThrow(schema, options, { adaptError });
|
|
478
|
+
var scopeStore = null;
|
|
479
|
+
try {
|
|
480
|
+
scopeStore = new async_hooks.AsyncLocalStorage();
|
|
481
|
+
} catch {
|
|
482
|
+
}
|
|
483
|
+
function getCurrentScope() {
|
|
484
|
+
if (!scopeStore) return void 0;
|
|
485
|
+
return scopeStore.getStore();
|
|
486
|
+
}
|
|
487
|
+
function getCurrentDepth() {
|
|
488
|
+
return getCurrentScope()?.depth ?? 0;
|
|
489
|
+
}
|
|
490
|
+
function runInMethodScope(fn) {
|
|
491
|
+
if (!scopeStore) return fn();
|
|
492
|
+
const currentDepth = scopeStore.getStore()?.depth ?? -1;
|
|
493
|
+
return scopeStore.run({ depth: currentDepth + 1 }, fn);
|
|
494
|
+
}
|
|
495
|
+
var runWithTelemetryContext = runInMethodScope;
|
|
496
|
+
function normalizeError(error, adaptError) {
|
|
497
|
+
if (error instanceof Error) return error;
|
|
498
|
+
const message = typeof error === "object" && error !== null && "message" in error && typeof error.message === "string" ? error.message : String(error);
|
|
499
|
+
return createCoreError(
|
|
500
|
+
{
|
|
501
|
+
code: CoreErrorCode.Unknown,
|
|
502
|
+
message,
|
|
503
|
+
cause: error
|
|
504
|
+
},
|
|
505
|
+
adaptError
|
|
506
|
+
);
|
|
507
|
+
}
|
|
508
|
+
function createFunction(coreFn, options) {
|
|
509
|
+
const { sdk, schema } = options;
|
|
510
|
+
const functionName = coreFn.name;
|
|
511
|
+
const namedFunctions = {
|
|
512
|
+
[functionName]: async function(callOptions) {
|
|
513
|
+
return runInMethodScope(async () => {
|
|
514
|
+
const startTime = Date.now();
|
|
515
|
+
const normalizedOptions = callOptions ?? {};
|
|
516
|
+
const args = [normalizedOptions];
|
|
517
|
+
const depth = getCurrentDepth();
|
|
518
|
+
const hooks = sdk.context.hooks;
|
|
519
|
+
const adaptError = sdk.context.core?.adaptError;
|
|
520
|
+
hooks?.onMethodStart?.({
|
|
521
|
+
methodName: functionName,
|
|
522
|
+
args,
|
|
523
|
+
isPaginated: false,
|
|
524
|
+
depth
|
|
525
|
+
});
|
|
526
|
+
try {
|
|
527
|
+
let result;
|
|
528
|
+
if (schema) {
|
|
529
|
+
const validatedOptions = validateOptions(
|
|
530
|
+
schema,
|
|
531
|
+
normalizedOptions,
|
|
532
|
+
{
|
|
533
|
+
adaptError
|
|
534
|
+
}
|
|
535
|
+
);
|
|
536
|
+
result = await coreFn({
|
|
537
|
+
...normalizedOptions,
|
|
538
|
+
...validatedOptions
|
|
539
|
+
});
|
|
540
|
+
} else {
|
|
541
|
+
result = await coreFn(normalizedOptions);
|
|
542
|
+
}
|
|
543
|
+
hooks?.onMethodEnd?.({
|
|
544
|
+
methodName: functionName,
|
|
545
|
+
args,
|
|
546
|
+
isPaginated: false,
|
|
547
|
+
depth,
|
|
548
|
+
durationMs: Date.now() - startTime
|
|
549
|
+
});
|
|
550
|
+
return result;
|
|
551
|
+
} catch (error) {
|
|
552
|
+
const normalizedError = normalizeError(error, adaptError);
|
|
553
|
+
hooks?.onMethodEnd?.({
|
|
554
|
+
methodName: functionName,
|
|
555
|
+
args,
|
|
556
|
+
isPaginated: false,
|
|
557
|
+
depth,
|
|
558
|
+
durationMs: Date.now() - startTime,
|
|
559
|
+
error: normalizedError
|
|
560
|
+
});
|
|
561
|
+
throw normalizedError;
|
|
562
|
+
}
|
|
563
|
+
});
|
|
564
|
+
}
|
|
565
|
+
};
|
|
566
|
+
return namedFunctions[functionName];
|
|
567
|
+
}
|
|
568
|
+
function isSdkPage(value) {
|
|
569
|
+
if (typeof value !== "object" || value === null) return false;
|
|
570
|
+
const page = value;
|
|
571
|
+
if (!Array.isArray(page.data)) return false;
|
|
572
|
+
if (page.nextCursor !== void 0 && typeof page.nextCursor !== "string") {
|
|
573
|
+
return false;
|
|
574
|
+
}
|
|
575
|
+
return Object.keys(page).every((k) => k === "data" || k === "nextCursor");
|
|
576
|
+
}
|
|
577
|
+
function createPageFunction(coreFn, {
|
|
578
|
+
sdk,
|
|
579
|
+
adaptPage
|
|
580
|
+
}) {
|
|
581
|
+
const functionName = coreFn.name + "Page";
|
|
582
|
+
const namedFunctions = {
|
|
583
|
+
[functionName]: async function(options) {
|
|
584
|
+
try {
|
|
585
|
+
const response = await coreFn(options);
|
|
586
|
+
const page = adaptPage ? adaptPage(response) : response;
|
|
587
|
+
if (!isSdkPage(page)) {
|
|
588
|
+
throw new Error(
|
|
589
|
+
`${functionName}: paginated result must be exactly { data: TItem[], nextCursor? } (produced by the handler or its \`adaptPage\`); got keys [${page && typeof page === "object" ? Object.keys(page).join(", ") : typeof page}]. If the handler returns a raw shape, set \`adaptPage\` to translate it; if \`adaptPage\` already runs, it must return only \`data\`/\`nextCursor\`.`
|
|
590
|
+
);
|
|
591
|
+
}
|
|
592
|
+
return page;
|
|
593
|
+
} catch (error) {
|
|
594
|
+
throw normalizeError(
|
|
595
|
+
error,
|
|
596
|
+
sdk.context.core?.adaptError
|
|
597
|
+
);
|
|
741
598
|
}
|
|
742
|
-
}
|
|
599
|
+
}
|
|
600
|
+
};
|
|
601
|
+
return namedFunctions[functionName];
|
|
602
|
+
}
|
|
603
|
+
function createPaginatedFunction(coreFn, options) {
|
|
604
|
+
const { sdk, schema, name, defaultPageSize, adaptPage } = options;
|
|
605
|
+
const pageFunction = createPageFunction(coreFn, { sdk, adaptPage });
|
|
606
|
+
const functionName = name || coreFn.name;
|
|
607
|
+
const namedFunctions = {
|
|
608
|
+
[functionName]: function(callOptions) {
|
|
609
|
+
return runInMethodScope(() => {
|
|
610
|
+
const startTime = Date.now();
|
|
611
|
+
const normalizedOptions = callOptions ?? {};
|
|
612
|
+
const args = [normalizedOptions];
|
|
613
|
+
const depth = getCurrentDepth();
|
|
614
|
+
const hooks = sdk.context.hooks;
|
|
615
|
+
const adaptError = sdk.context.core?.adaptError;
|
|
616
|
+
hooks?.onMethodStart?.({
|
|
617
|
+
methodName: functionName,
|
|
618
|
+
args,
|
|
619
|
+
isPaginated: true,
|
|
620
|
+
depth
|
|
621
|
+
});
|
|
622
|
+
const validatedOptions = {
|
|
623
|
+
...normalizedOptions,
|
|
624
|
+
...schema ? createValidator(schema, { adaptError })(normalizedOptions) : normalizedOptions
|
|
625
|
+
};
|
|
626
|
+
const pageSize = validatedOptions.pageSize ?? defaultPageSize;
|
|
627
|
+
const optimizedOptions = {
|
|
628
|
+
...validatedOptions,
|
|
629
|
+
pageSize
|
|
630
|
+
};
|
|
631
|
+
const iterator = paginate(pageFunction, optimizedOptions);
|
|
632
|
+
const firstPagePromise = iterator.next().then((result) => {
|
|
633
|
+
if (result.done) {
|
|
634
|
+
throw new Error("Paginate should always iterate at least once");
|
|
635
|
+
}
|
|
636
|
+
return result.value;
|
|
637
|
+
});
|
|
638
|
+
if (hooks?.onMethodEnd) {
|
|
639
|
+
firstPagePromise.then(() => {
|
|
640
|
+
hooks.onMethodEnd({
|
|
641
|
+
methodName: functionName,
|
|
642
|
+
args,
|
|
643
|
+
isPaginated: true,
|
|
644
|
+
depth,
|
|
645
|
+
durationMs: Date.now() - startTime
|
|
646
|
+
});
|
|
647
|
+
}).catch((error) => {
|
|
648
|
+
hooks.onMethodEnd({
|
|
649
|
+
methodName: functionName,
|
|
650
|
+
args,
|
|
651
|
+
isPaginated: true,
|
|
652
|
+
depth,
|
|
653
|
+
durationMs: Date.now() - startTime,
|
|
654
|
+
error: error instanceof Error ? error : new Error(String(error))
|
|
655
|
+
});
|
|
656
|
+
});
|
|
657
|
+
}
|
|
658
|
+
return Object.assign(firstPagePromise, {
|
|
659
|
+
[Symbol.asyncIterator]: async function* () {
|
|
660
|
+
yield await firstPagePromise;
|
|
661
|
+
for await (const page of iterator) {
|
|
662
|
+
yield page;
|
|
663
|
+
}
|
|
664
|
+
},
|
|
665
|
+
items: function() {
|
|
666
|
+
return {
|
|
667
|
+
[Symbol.asyncIterator]: async function* () {
|
|
668
|
+
const firstPage = await firstPagePromise;
|
|
669
|
+
for (const item of firstPage.data) {
|
|
670
|
+
yield item;
|
|
671
|
+
}
|
|
672
|
+
for await (const page of iterator) {
|
|
673
|
+
for (const item of page.data) {
|
|
674
|
+
yield item;
|
|
675
|
+
}
|
|
676
|
+
}
|
|
677
|
+
}
|
|
678
|
+
};
|
|
679
|
+
}
|
|
680
|
+
});
|
|
681
|
+
});
|
|
682
|
+
}
|
|
683
|
+
};
|
|
684
|
+
return namedFunctions[functionName];
|
|
685
|
+
}
|
|
686
|
+
function definePlugin(fn) {
|
|
687
|
+
return fn;
|
|
688
|
+
}
|
|
689
|
+
function createPluginMethod(sdk, config) {
|
|
690
|
+
const { name, inputSchema, handler, ...metaFields } = config;
|
|
691
|
+
const namedHandlers = {
|
|
692
|
+
[name]: async function(options) {
|
|
693
|
+
return handler({ sdk, options });
|
|
694
|
+
}
|
|
695
|
+
};
|
|
696
|
+
const wrappedFn = createFunction(namedHandlers[name], {
|
|
697
|
+
sdk,
|
|
698
|
+
schema: inputSchema
|
|
699
|
+
});
|
|
700
|
+
return {
|
|
701
|
+
[name]: wrappedFn,
|
|
702
|
+
context: {
|
|
703
|
+
meta: {
|
|
704
|
+
[name]: {
|
|
705
|
+
...metaFields,
|
|
706
|
+
...inputSchema ? { inputSchema } : {}
|
|
707
|
+
}
|
|
708
|
+
}
|
|
709
|
+
}
|
|
710
|
+
};
|
|
711
|
+
}
|
|
712
|
+
function createPaginatedPluginMethod(sdk, config) {
|
|
713
|
+
const {
|
|
714
|
+
name,
|
|
715
|
+
inputSchema,
|
|
716
|
+
handler,
|
|
717
|
+
adaptPage,
|
|
718
|
+
defaultPageSize,
|
|
719
|
+
...metaFields
|
|
720
|
+
} = config;
|
|
721
|
+
const namedHandlers = {
|
|
722
|
+
[name]: function(options) {
|
|
723
|
+
return handler({ sdk, options });
|
|
724
|
+
}
|
|
725
|
+
};
|
|
726
|
+
const wrappedFn = createPaginatedFunction(namedHandlers[name], {
|
|
727
|
+
sdk,
|
|
728
|
+
schema: inputSchema,
|
|
729
|
+
name,
|
|
730
|
+
defaultPageSize,
|
|
731
|
+
adaptPage
|
|
732
|
+
});
|
|
733
|
+
return {
|
|
734
|
+
[name]: wrappedFn,
|
|
735
|
+
context: {
|
|
736
|
+
meta: {
|
|
737
|
+
[name]: {
|
|
738
|
+
...metaFields,
|
|
739
|
+
...inputSchema ? { inputSchema } : {}
|
|
740
|
+
}
|
|
741
|
+
}
|
|
742
|
+
}
|
|
743
|
+
};
|
|
744
|
+
}
|
|
745
|
+
function splitPluginContribution(result) {
|
|
746
|
+
const { context, ...rootKeys } = result;
|
|
747
|
+
const { meta, hooks, ...contextRest } = context ?? {};
|
|
748
|
+
return {
|
|
749
|
+
rootKeys,
|
|
750
|
+
meta: meta ?? {},
|
|
751
|
+
hooks: hooks ?? {},
|
|
752
|
+
contextRest
|
|
753
|
+
};
|
|
754
|
+
}
|
|
755
|
+
var RESERVED_ROOT_KEYS = /* @__PURE__ */ new Set([
|
|
756
|
+
"context",
|
|
757
|
+
"getRegistry",
|
|
758
|
+
"addPlugin"
|
|
759
|
+
]);
|
|
760
|
+
function hasOwn(obj, key) {
|
|
761
|
+
return Object.prototype.hasOwnProperty.call(obj, key);
|
|
762
|
+
}
|
|
763
|
+
function setOwn(target, key, value) {
|
|
764
|
+
Object.defineProperty(target, key, {
|
|
765
|
+
value,
|
|
766
|
+
enumerable: true,
|
|
767
|
+
configurable: true,
|
|
768
|
+
writable: true
|
|
769
|
+
});
|
|
770
|
+
}
|
|
771
|
+
function checkCollisions(target, source, kind, callerLabel, override) {
|
|
772
|
+
for (const key of Object.keys(source)) {
|
|
773
|
+
if (kind === "root key" && RESERVED_ROOT_KEYS.has(key)) {
|
|
774
|
+
throw new Error(
|
|
775
|
+
`${callerLabel}: plugin attempted to register reserved root key "${key}". The SDK uses this key for its own accessor; rename the plugin's method.`
|
|
776
|
+
);
|
|
777
|
+
}
|
|
778
|
+
if (!override && hasOwn(target, key)) {
|
|
779
|
+
throw new Error(
|
|
780
|
+
`${callerLabel}: duplicate ${kind} "${key}". If the override is intentional, pass { override: true } in the options.`
|
|
781
|
+
);
|
|
782
|
+
}
|
|
783
|
+
}
|
|
784
|
+
}
|
|
785
|
+
function applyOwnProperties(target, source) {
|
|
786
|
+
for (const key of Object.keys(source)) {
|
|
787
|
+
setOwn(target, key, source[key]);
|
|
788
|
+
}
|
|
789
|
+
}
|
|
790
|
+
function createPluginAccumulator(initialProperties = {}, initialContext = {}) {
|
|
791
|
+
const initialMeta = initialContext.meta ?? {};
|
|
792
|
+
const initialHooks = initialContext.hooks ?? {};
|
|
793
|
+
const context = {
|
|
794
|
+
...initialContext,
|
|
795
|
+
meta: { ...initialMeta },
|
|
796
|
+
hooks: { ...initialHooks }
|
|
797
|
+
};
|
|
798
|
+
const view = { ...initialProperties, context };
|
|
799
|
+
return { view, context };
|
|
800
|
+
}
|
|
801
|
+
function mergeContribution(propertiesTarget, contextTarget, contribution, options) {
|
|
802
|
+
checkCollisions(
|
|
803
|
+
propertiesTarget,
|
|
804
|
+
contribution.rootKeys,
|
|
805
|
+
"root key",
|
|
806
|
+
options.callerLabel,
|
|
807
|
+
options.override
|
|
808
|
+
);
|
|
809
|
+
checkCollisions(
|
|
810
|
+
contextTarget.meta,
|
|
811
|
+
contribution.meta,
|
|
812
|
+
"context.meta key",
|
|
813
|
+
options.callerLabel,
|
|
814
|
+
options.override
|
|
815
|
+
);
|
|
816
|
+
checkCollisions(
|
|
817
|
+
contextTarget,
|
|
818
|
+
contribution.contextRest,
|
|
819
|
+
"context key",
|
|
820
|
+
options.callerLabel,
|
|
821
|
+
options.override
|
|
822
|
+
);
|
|
823
|
+
applyOwnProperties(propertiesTarget, contribution.rootKeys);
|
|
824
|
+
applyOwnProperties(contextTarget.meta, contribution.meta);
|
|
825
|
+
applyOwnProperties(contextTarget, contribution.contextRest);
|
|
826
|
+
contextTarget.hooks = buildHooks(contextTarget.hooks, contribution.hooks);
|
|
827
|
+
}
|
|
828
|
+
function applyPluginContribution(acc, contribution, options) {
|
|
829
|
+
mergeContribution(acc.view, acc.context, contribution, options);
|
|
830
|
+
}
|
|
831
|
+
function wrapAsSdk(properties, context, opts) {
|
|
832
|
+
const sdk = {
|
|
833
|
+
...properties,
|
|
834
|
+
context,
|
|
835
|
+
getRegistry(qopts) {
|
|
836
|
+
return buildRegistry({
|
|
837
|
+
sdk,
|
|
838
|
+
meta: context.meta,
|
|
839
|
+
packageFilter: qopts?.package
|
|
840
|
+
});
|
|
841
|
+
}
|
|
842
|
+
};
|
|
843
|
+
if (opts?.addPlugin !== void 0) {
|
|
844
|
+
sdk.addPlugin = opts.addPlugin;
|
|
845
|
+
}
|
|
846
|
+
return sdk;
|
|
847
|
+
}
|
|
848
|
+
function wrapAccumulatorAsSdk(acc) {
|
|
849
|
+
const { context: _ctx, ...rootKeys } = acc.view;
|
|
850
|
+
return wrapAsSdk(
|
|
851
|
+
rootKeys,
|
|
852
|
+
acc.context
|
|
853
|
+
);
|
|
854
|
+
}
|
|
855
|
+
function applyPluginToSdk(sdk, plugin, options) {
|
|
856
|
+
const context = sdk.context;
|
|
857
|
+
const contribution = splitPluginContribution(
|
|
858
|
+
plugin(sdk)
|
|
859
|
+
);
|
|
860
|
+
mergeContribution(sdk, context, contribution, {
|
|
861
|
+
callerLabel: "addPlugin",
|
|
862
|
+
override: options.override === true
|
|
863
|
+
});
|
|
864
|
+
}
|
|
865
|
+
function buildStackAccumulator(head, callerLabel) {
|
|
866
|
+
const ordered = [];
|
|
867
|
+
let node = head;
|
|
868
|
+
while (node) {
|
|
869
|
+
ordered.unshift(node);
|
|
870
|
+
node = node.prev;
|
|
871
|
+
}
|
|
872
|
+
const acc = createPluginAccumulator();
|
|
873
|
+
for (const { plugin, override } of ordered) {
|
|
874
|
+
const contribution = splitPluginContribution(
|
|
875
|
+
plugin(acc.view)
|
|
876
|
+
);
|
|
877
|
+
applyPluginContribution(acc, contribution, { callerLabel, override });
|
|
878
|
+
}
|
|
879
|
+
return acc;
|
|
880
|
+
}
|
|
881
|
+
function addPlugin(sdk, plugin, options) {
|
|
882
|
+
applyPluginToSdk(
|
|
883
|
+
sdk,
|
|
884
|
+
plugin,
|
|
885
|
+
options ?? {}
|
|
886
|
+
);
|
|
887
|
+
}
|
|
888
|
+
function buildSdk(properties, context) {
|
|
889
|
+
const addPlugin2 = (plugin, options) => {
|
|
890
|
+
logDeprecation(
|
|
891
|
+
"sdk.addPlugin(plugin) (the chain-style extension) is deprecated. Build the SDK in one pass with createPluginStack().use(...).toSdk() instead \u2014 each .toSdk() produces fresh plugin closures and avoids the closure-sharing semantics that caused this to be deprecated."
|
|
892
|
+
);
|
|
893
|
+
const contribution = splitPluginContribution(
|
|
894
|
+
plugin({ ...properties, context })
|
|
895
|
+
);
|
|
896
|
+
const mergedProperties = { ...properties };
|
|
897
|
+
const mergedContext = {
|
|
898
|
+
...context,
|
|
899
|
+
meta: { ...context.meta },
|
|
900
|
+
hooks: { ...context.hooks }
|
|
901
|
+
};
|
|
902
|
+
mergeContribution(mergedProperties, mergedContext, contribution, {
|
|
903
|
+
callerLabel: "addPlugin",
|
|
904
|
+
override: options?.override === true
|
|
905
|
+
});
|
|
906
|
+
return buildSdk(
|
|
907
|
+
mergedProperties,
|
|
908
|
+
mergedContext
|
|
909
|
+
);
|
|
910
|
+
};
|
|
911
|
+
return wrapAsSdk(properties, context, { addPlugin: addPlugin2 });
|
|
912
|
+
}
|
|
913
|
+
function withDeprecatedAddPlugin(sdk) {
|
|
914
|
+
const initialProperties = {};
|
|
915
|
+
for (const key of Object.keys(sdk)) {
|
|
916
|
+
if (key === "context" || key === "getRegistry" || key === "addPlugin") {
|
|
917
|
+
continue;
|
|
918
|
+
}
|
|
919
|
+
initialProperties[key] = sdk[key];
|
|
920
|
+
}
|
|
921
|
+
const initialContext = sdk.context;
|
|
922
|
+
return buildSdk(
|
|
923
|
+
initialProperties,
|
|
924
|
+
initialContext
|
|
925
|
+
);
|
|
926
|
+
}
|
|
927
|
+
function composePlugins(...plugins) {
|
|
928
|
+
logDeprecation(
|
|
929
|
+
"composePlugins(...) is deprecated. Use createPluginStack().use(a).use(b).use(c).toPlugin() instead. The stack carries the same collision-detection and hook-composition behavior, supports per-step { override: true } for intentional duplicates, and progressively narrows types so dependency mistakes surface at the specific .use call."
|
|
930
|
+
);
|
|
931
|
+
let stack = buildPluginStack(
|
|
932
|
+
null,
|
|
933
|
+
"composePlugins"
|
|
934
|
+
);
|
|
935
|
+
for (const plugin of plugins) {
|
|
936
|
+
stack = stack.use(plugin);
|
|
937
|
+
}
|
|
938
|
+
return stack.toPlugin();
|
|
939
|
+
}
|
|
940
|
+
function createPluginStack() {
|
|
941
|
+
return buildPluginStack(null, "createPluginStack");
|
|
942
|
+
}
|
|
943
|
+
function buildPluginStack(head, callerLabel) {
|
|
944
|
+
return {
|
|
945
|
+
use(plugin, options) {
|
|
946
|
+
const next = {
|
|
947
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
948
|
+
plugin,
|
|
949
|
+
override: options?.override === true,
|
|
950
|
+
prev: head
|
|
951
|
+
};
|
|
952
|
+
return buildPluginStack(next, callerLabel);
|
|
953
|
+
},
|
|
954
|
+
toPlugin() {
|
|
955
|
+
const ordered = [];
|
|
956
|
+
let node = head;
|
|
957
|
+
while (node) {
|
|
958
|
+
ordered.unshift(node);
|
|
959
|
+
node = node.prev;
|
|
960
|
+
}
|
|
961
|
+
return (outerSdk) => {
|
|
962
|
+
const { context: outerContext, ...outerProperties } = outerSdk ?? {};
|
|
963
|
+
const viewAcc = createPluginAccumulator(outerProperties, outerContext);
|
|
964
|
+
const contribsAcc = createPluginAccumulator();
|
|
965
|
+
for (const { plugin: subPlugin, override } of ordered) {
|
|
966
|
+
const contribution = splitPluginContribution(
|
|
967
|
+
subPlugin(viewAcc.view)
|
|
968
|
+
);
|
|
969
|
+
applyPluginContribution(viewAcc, contribution, {
|
|
970
|
+
callerLabel,
|
|
971
|
+
override
|
|
972
|
+
});
|
|
973
|
+
applyPluginContribution(contribsAcc, contribution, {
|
|
974
|
+
callerLabel,
|
|
975
|
+
override
|
|
976
|
+
});
|
|
977
|
+
}
|
|
978
|
+
const { context: _ignored, ...contributedRoot } = contribsAcc.view;
|
|
979
|
+
return {
|
|
980
|
+
...contributedRoot,
|
|
981
|
+
context: contribsAcc.context
|
|
982
|
+
};
|
|
983
|
+
};
|
|
984
|
+
},
|
|
985
|
+
toSdk() {
|
|
986
|
+
return wrapAccumulatorAsSdk(
|
|
987
|
+
buildStackAccumulator(head, callerLabel)
|
|
988
|
+
);
|
|
989
|
+
}
|
|
990
|
+
};
|
|
991
|
+
}
|
|
992
|
+
function createCorePlugin(options) {
|
|
993
|
+
return () => ({
|
|
994
|
+
context: {
|
|
995
|
+
core: options
|
|
996
|
+
}
|
|
997
|
+
});
|
|
998
|
+
}
|
|
999
|
+
function withPositional(schema) {
|
|
1000
|
+
Object.assign(schema._zod.def, {
|
|
1001
|
+
positionalMeta: { positional: true }
|
|
1002
|
+
});
|
|
1003
|
+
return schema;
|
|
1004
|
+
}
|
|
1005
|
+
function schemaHasPositionalMeta(schema) {
|
|
1006
|
+
return "positionalMeta" in schema._zod.def;
|
|
1007
|
+
}
|
|
1008
|
+
function isPositional(schema) {
|
|
1009
|
+
if (schemaHasPositionalMeta(schema) && schema._zod.def.positionalMeta?.positional) {
|
|
1010
|
+
return true;
|
|
1011
|
+
}
|
|
1012
|
+
if (schema instanceof zod.z.ZodOptional) {
|
|
1013
|
+
return isPositional(schema._zod.def.innerType);
|
|
1014
|
+
}
|
|
1015
|
+
if (schema instanceof zod.z.ZodDefault) {
|
|
1016
|
+
return isPositional(schema._zod.def.innerType);
|
|
1017
|
+
}
|
|
1018
|
+
return false;
|
|
1019
|
+
}
|
|
1020
|
+
|
|
1021
|
+
// src/constants.ts
|
|
1022
|
+
var ZAPIER_BASE_URL = globalThis.process?.env?.ZAPIER_BASE_URL || "https://zapier.com";
|
|
1023
|
+
function getZapierSdkService() {
|
|
1024
|
+
return globalThis.process?.env?.ZAPIER_SDK_SERVICE;
|
|
1025
|
+
}
|
|
1026
|
+
var MAX_PAGE_LIMIT = 1e4;
|
|
1027
|
+
var DEFAULT_PAGE_SIZE = 100;
|
|
1028
|
+
var DEFAULT_ACTION_TIMEOUT_MS = 18e4;
|
|
1029
|
+
function parseIntEnvVar(name) {
|
|
1030
|
+
const value = globalThis.process?.env?.[name];
|
|
1031
|
+
if (value === void 0) return void 0;
|
|
1032
|
+
const parsed = parseInt(value, 10);
|
|
1033
|
+
if (isNaN(parsed)) {
|
|
1034
|
+
console.warn(
|
|
1035
|
+
`[zapier-sdk] Invalid value for ${name}: "${value}" (expected integer)`
|
|
1036
|
+
);
|
|
1037
|
+
return void 0;
|
|
1038
|
+
}
|
|
1039
|
+
return parsed;
|
|
1040
|
+
}
|
|
1041
|
+
var ZAPIER_MAX_NETWORK_RETRIES = parseIntEnvVar("ZAPIER_MAX_NETWORK_RETRIES") ?? 3;
|
|
1042
|
+
var ZAPIER_MAX_NETWORK_RETRY_DELAY_MS = parseIntEnvVar("ZAPIER_MAX_NETWORK_RETRY_DELAY_MS") ?? 6e4;
|
|
1043
|
+
var MAX_CONCURRENCY_LIMIT = 1e4;
|
|
1044
|
+
function parseConcurrencyEnvVar(name) {
|
|
1045
|
+
const value = globalThis.process?.env?.[name];
|
|
1046
|
+
if (!value) return void 0;
|
|
1047
|
+
if (value === "Infinity") return Infinity;
|
|
1048
|
+
if (/^[1-9]\d*$/.test(value)) {
|
|
1049
|
+
const parsed = parseInt(value, 10);
|
|
1050
|
+
if (parsed <= MAX_CONCURRENCY_LIMIT) return parsed;
|
|
1051
|
+
}
|
|
1052
|
+
console.warn(
|
|
1053
|
+
`[zapier-sdk] Invalid value for ${name}: "${value}" (expected positive integer 1-${MAX_CONCURRENCY_LIMIT} or "Infinity")`
|
|
1054
|
+
);
|
|
1055
|
+
return void 0;
|
|
1056
|
+
}
|
|
1057
|
+
var ZAPIER_MAX_CONCURRENT_REQUESTS = parseConcurrencyEnvVar("ZAPIER_MAX_CONCURRENT_REQUESTS") ?? 200;
|
|
1058
|
+
function getZapierApprovalMode() {
|
|
1059
|
+
const value = globalThis.process?.env?.ZAPIER_APPROVAL_MODE;
|
|
1060
|
+
if (value === "disabled" || value === "poll" || value === "throw")
|
|
1061
|
+
return value;
|
|
1062
|
+
return void 0;
|
|
1063
|
+
}
|
|
1064
|
+
function getZapierDefaultApprovalMode() {
|
|
1065
|
+
const isInteractive = !!globalThis.process?.stdin?.isTTY && !!globalThis.process?.stdout?.isTTY;
|
|
1066
|
+
return isInteractive ? "poll" : "throw";
|
|
1067
|
+
}
|
|
1068
|
+
var DEFAULT_APPROVAL_TIMEOUT_MS = 10 * 60 * 1e3;
|
|
1069
|
+
var DEFAULT_MAX_APPROVAL_RETRIES = 2;
|
|
1070
|
+
|
|
1071
|
+
// src/types/properties.ts
|
|
1072
|
+
var AppKeyPropertySchema = withPositional(
|
|
1073
|
+
zod.z.string().min(1).describe("App key (e.g., 'SlackCLIAPI' or slug like 'github')")
|
|
1074
|
+
);
|
|
1075
|
+
var AppPropertySchema = withPositional(
|
|
1076
|
+
zod.z.string().min(1).describe(
|
|
1077
|
+
"App slug (e.g., 'github'), implementation name (e.g., 'SlackCLIAPI'), or versioned ID (e.g., 'github@1.2.3')"
|
|
1078
|
+
)
|
|
1079
|
+
);
|
|
1080
|
+
var ActionTypePropertySchema = zod.z.enum([
|
|
1081
|
+
"read",
|
|
1082
|
+
"read_bulk",
|
|
1083
|
+
"write",
|
|
1084
|
+
"run",
|
|
1085
|
+
"search",
|
|
1086
|
+
"search_or_write",
|
|
1087
|
+
"search_and_write",
|
|
1088
|
+
"filter"
|
|
1089
|
+
]).describe("Action type that matches the action's defined type");
|
|
1090
|
+
var ActionKeyPropertySchema = zod.z.string().min(1).describe("Action key to execute");
|
|
1091
|
+
var ActionPropertySchema = withPositional(
|
|
1092
|
+
zod.z.string().min(1).describe("Action key (e.g., 'send_message' or 'find_row')")
|
|
1093
|
+
);
|
|
1094
|
+
var InputFieldPropertySchema = withPositional(
|
|
1095
|
+
zod.z.string().min(1).describe("Input field key to get choices for")
|
|
1096
|
+
);
|
|
1097
|
+
var ConnectionIdPropertySchema = zod.z.union([zod.z.string(), zod.z.number().int().positive()]).describe("Connection ID to use for this action");
|
|
1098
|
+
var AuthenticationIdPropertySchema = ConnectionIdPropertySchema.meta({
|
|
1099
|
+
deprecated: true
|
|
1100
|
+
});
|
|
1101
|
+
var ConnectionPropertySchema = zod.z.union([zod.z.string(), zod.z.number().int().positive()]).describe(
|
|
1102
|
+
"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."
|
|
1103
|
+
);
|
|
1104
|
+
var InputsPropertySchema = zod.z.record(zod.z.string(), zod.z.unknown()).describe("Input parameters for the action");
|
|
1105
|
+
var LimitPropertySchema = zod.z.number().int().min(1).max(MAX_PAGE_LIMIT).default(50).describe("Maximum number of items to return");
|
|
1106
|
+
var OffsetPropertySchema = zod.z.number().int().min(0).default(0).describe("Number of items to skip for pagination");
|
|
1107
|
+
var OutputPropertySchema = zod.z.string().describe("Output file path");
|
|
1108
|
+
var DebugPropertySchema = zod.z.boolean().default(false).describe("Enable debug logging");
|
|
1109
|
+
var ParamsPropertySchema = zod.z.record(zod.z.string(), zod.z.unknown()).describe("Additional parameters");
|
|
1110
|
+
var ActionTimeoutMsPropertySchema = zod.z.number().min(1e3).optional().describe(
|
|
1111
|
+
`Maximum time to wait for action completion in milliseconds (default: ${DEFAULT_ACTION_TIMEOUT_MS})`
|
|
1112
|
+
);
|
|
1113
|
+
var TablePropertySchema = withPositional(
|
|
1114
|
+
zod.z.string().regex(/^[A-Z0-9]{26}$/, "Table ID must be a valid ULID").describe("The unique identifier of the table")
|
|
1115
|
+
);
|
|
1116
|
+
var RecordPropertySchema = withPositional(
|
|
1117
|
+
zod.z.string().regex(/^[A-Z0-9]{26}$/, "Record ID must be a valid ULID").describe("The unique identifier of the record")
|
|
1118
|
+
);
|
|
1119
|
+
var RecordsPropertySchema = zod.z.array(zod.z.string().regex(/^[A-Z0-9]{26}$/, "Record ID must be a valid ULID")).min(1).max(100).describe("Record IDs to operate on");
|
|
1120
|
+
var FieldsPropertySchema = zod.z.array(zod.z.union([zod.z.string(), zod.z.number()])).describe(
|
|
1121
|
+
'Fields to operate on. Accepts field names (e.g., "Email") or IDs (e.g., "f6", "6", or 6).'
|
|
1122
|
+
);
|
|
1123
|
+
var AppsPropertySchema = zod.z.array(zod.z.string()).describe("Filter by app keys (e.g., 'SlackCLIAPI' or slug like 'github')");
|
|
1124
|
+
var TablesPropertySchema = zod.z.array(zod.z.string()).describe("Filter by specific table IDs");
|
|
1125
|
+
var ConnectionsPropertySchema = zod.z.array(zod.z.string()).describe("List of connection IDs to filter by");
|
|
1126
|
+
var TriggerInboxPropertySchema = withPositional(
|
|
1127
|
+
zod.z.string().min(1).describe(
|
|
1128
|
+
"Trigger inbox identifier \u2014 UUID or name. Non-UUID values are resolved by name via the inbox list endpoint."
|
|
1129
|
+
)
|
|
1130
|
+
);
|
|
1131
|
+
var TriggerInboxNamePropertySchema = zod.z.string().min(1).max(100).describe(
|
|
1132
|
+
"Inbox name; unique per (user, account). Enables get-or-create on createTriggerInbox."
|
|
1133
|
+
);
|
|
1134
|
+
var LeasePropertySchema = zod.z.string().min(1).describe("Lease ID returned from leaseTriggerInboxMessages");
|
|
1135
|
+
var LeaseSecondsPropertySchema = zod.z.number().int().min(1).max(3600).describe(
|
|
1136
|
+
"Seconds until the lease expires; messages return to available if not acked. API default is 300 (5 minutes)."
|
|
1137
|
+
);
|
|
1138
|
+
var LeaseLimitPropertySchema = zod.z.number().int().min(1).max(100).describe("Maximum messages to lease in a single batch (1-100)");
|
|
1139
|
+
|
|
1140
|
+
// src/types/errors.ts
|
|
1141
|
+
var _a, _b;
|
|
1142
|
+
var ZapierError = class extends (_b = Error, _a = CORE_ERROR_SYMBOL, _b) {
|
|
1143
|
+
constructor(message, options = {}) {
|
|
1144
|
+
super(message);
|
|
1145
|
+
this[_a] = true;
|
|
1146
|
+
this.name = "ZapierError";
|
|
1147
|
+
this.code = "ZAPIER_ERROR";
|
|
1148
|
+
if (options.statusCode !== void 0) this.statusCode = options.statusCode;
|
|
1149
|
+
if (options.errors !== void 0) this.errors = options.errors;
|
|
1150
|
+
if (options.cause !== void 0) this.cause = options.cause;
|
|
1151
|
+
if (options.response !== void 0) this.response = options.response;
|
|
1152
|
+
Object.setPrototypeOf(this, new.target.prototype);
|
|
1153
|
+
}
|
|
1154
|
+
};
|
|
1155
|
+
var ZapierValidationError = class extends ZapierError {
|
|
1156
|
+
constructor(message, options = {}) {
|
|
1157
|
+
super(message, options);
|
|
1158
|
+
this.name = "ZapierValidationError";
|
|
1159
|
+
this.code = "ZAPIER_VALIDATION_ERROR";
|
|
1160
|
+
this.details = options.details;
|
|
1161
|
+
}
|
|
1162
|
+
};
|
|
1163
|
+
var ZapierUnknownError = class extends ZapierError {
|
|
1164
|
+
constructor() {
|
|
1165
|
+
super(...arguments);
|
|
1166
|
+
this.name = "ZapierUnknownError";
|
|
1167
|
+
this.code = "ZAPIER_UNKNOWN_ERROR";
|
|
1168
|
+
}
|
|
1169
|
+
};
|
|
1170
|
+
var ZapierAuthenticationError = class extends ZapierError {
|
|
1171
|
+
constructor() {
|
|
1172
|
+
super(...arguments);
|
|
1173
|
+
this.name = "ZapierAuthenticationError";
|
|
1174
|
+
this.code = "ZAPIER_AUTHENTICATION_ERROR";
|
|
1175
|
+
}
|
|
1176
|
+
};
|
|
1177
|
+
var zapierAdaptError = (options) => {
|
|
1178
|
+
switch (options.code) {
|
|
1179
|
+
case CoreErrorCode.Validation:
|
|
1180
|
+
return new ZapierValidationError(options.message, {
|
|
1181
|
+
cause: options.cause,
|
|
1182
|
+
details: options.details
|
|
1183
|
+
});
|
|
1184
|
+
case CoreErrorCode.Unknown:
|
|
1185
|
+
return new ZapierUnknownError(options.message, {
|
|
1186
|
+
cause: options.cause
|
|
1187
|
+
});
|
|
1188
|
+
default:
|
|
1189
|
+
return new ZapierError(options.message, { cause: options.cause });
|
|
1190
|
+
}
|
|
1191
|
+
};
|
|
1192
|
+
var ZapierApiError = class extends ZapierError {
|
|
1193
|
+
constructor(message, options = {}) {
|
|
1194
|
+
super(message, options);
|
|
1195
|
+
this.name = "ZapierApiError";
|
|
1196
|
+
this.code = "ZAPIER_API_ERROR";
|
|
1197
|
+
}
|
|
1198
|
+
};
|
|
1199
|
+
var ZapierAppNotFoundError = class extends ZapierError {
|
|
1200
|
+
constructor(message, options = {}) {
|
|
1201
|
+
super(message, options);
|
|
1202
|
+
this.name = "ZapierAppNotFoundError";
|
|
1203
|
+
this.code = "ZAPIER_APP_NOT_FOUND_ERROR";
|
|
1204
|
+
this.appKey = options.appKey;
|
|
1205
|
+
}
|
|
1206
|
+
};
|
|
1207
|
+
var ZapierNotFoundError = class extends ZapierError {
|
|
1208
|
+
constructor(message, options = {}) {
|
|
1209
|
+
super(message, options);
|
|
1210
|
+
this.name = "ZapierNotFoundError";
|
|
1211
|
+
this.code = "ZAPIER_NOT_FOUND_ERROR";
|
|
1212
|
+
}
|
|
1213
|
+
};
|
|
1214
|
+
var ZapierResourceNotFoundError = class extends ZapierNotFoundError {
|
|
1215
|
+
constructor(message, options = {}) {
|
|
1216
|
+
super(message, options);
|
|
1217
|
+
this.name = "ZapierResourceNotFoundError";
|
|
1218
|
+
this.code = "ZAPIER_RESOURCE_NOT_FOUND_ERROR";
|
|
1219
|
+
this.resourceType = options.resourceType;
|
|
1220
|
+
this.resourceId = options.resourceId;
|
|
1221
|
+
}
|
|
1222
|
+
};
|
|
1223
|
+
var ZapierConfigurationError = class extends ZapierError {
|
|
1224
|
+
constructor(message, options = {}) {
|
|
1225
|
+
super(message, options);
|
|
1226
|
+
this.name = "ZapierConfigurationError";
|
|
1227
|
+
this.code = "ZAPIER_CONFIGURATION_ERROR";
|
|
1228
|
+
this.configType = options.configType;
|
|
1229
|
+
}
|
|
1230
|
+
};
|
|
1231
|
+
var ZapierBundleError = class extends ZapierError {
|
|
1232
|
+
constructor(message, options = {}) {
|
|
1233
|
+
super(message, options);
|
|
1234
|
+
this.name = "ZapierBundleError";
|
|
1235
|
+
this.code = "ZAPIER_BUNDLE_ERROR";
|
|
1236
|
+
this.buildErrors = options.buildErrors;
|
|
1237
|
+
}
|
|
1238
|
+
};
|
|
1239
|
+
var ZapierTimeoutError = class extends ZapierError {
|
|
1240
|
+
constructor(message, options = {}) {
|
|
1241
|
+
super(message, options);
|
|
1242
|
+
this.name = "ZapierTimeoutError";
|
|
1243
|
+
this.code = "ZAPIER_TIMEOUT_ERROR";
|
|
1244
|
+
this.attempts = options.attempts;
|
|
1245
|
+
this.maxAttempts = options.maxAttempts;
|
|
1246
|
+
}
|
|
1247
|
+
};
|
|
1248
|
+
var ZapierActionError = class extends ZapierError {
|
|
1249
|
+
constructor(message, options = {}) {
|
|
1250
|
+
super(message, options);
|
|
1251
|
+
this.name = "ZapierActionError";
|
|
1252
|
+
this.code = "ZAPIER_ACTION_ERROR";
|
|
1253
|
+
this.appKey = options.appKey;
|
|
1254
|
+
this.actionKey = options.actionKey;
|
|
1255
|
+
}
|
|
1256
|
+
// Legacy accessor for backward compatibility
|
|
1257
|
+
get actionErrors() {
|
|
1258
|
+
return this.errors;
|
|
1259
|
+
}
|
|
1260
|
+
};
|
|
1261
|
+
var ZapierConflictError = class extends ZapierError {
|
|
1262
|
+
constructor(message, options = {}) {
|
|
1263
|
+
super(message, options);
|
|
1264
|
+
this.name = "ZapierConflictError";
|
|
1265
|
+
this.code = "ZAPIER_CONFLICT_ERROR";
|
|
1266
|
+
this.resourceType = options.resourceType;
|
|
1267
|
+
}
|
|
1268
|
+
};
|
|
1269
|
+
var ZapierRateLimitError = class extends ZapierError {
|
|
1270
|
+
constructor(message, options = {}) {
|
|
1271
|
+
super(message, options);
|
|
1272
|
+
this.name = "ZapierRateLimitError";
|
|
1273
|
+
this.code = "ZAPIER_RATE_LIMIT_ERROR";
|
|
1274
|
+
this.rateLimit = options.rateLimit ?? {};
|
|
1275
|
+
this.retries = options.retries ?? 0;
|
|
1276
|
+
}
|
|
1277
|
+
};
|
|
1278
|
+
var ZapierApprovalError = class extends ZapierError {
|
|
1279
|
+
constructor(message, options = {}) {
|
|
1280
|
+
super(message, options);
|
|
1281
|
+
this.name = "ZapierApprovalError";
|
|
1282
|
+
this.code = "ZAPIER_APPROVAL_ERROR";
|
|
1283
|
+
this.approvalId = options.approvalId;
|
|
1284
|
+
this.approvalStatus = options.status;
|
|
1285
|
+
this.approvalUrl = options.approvalUrl;
|
|
1286
|
+
this.pollUrl = options.pollUrl;
|
|
743
1287
|
}
|
|
744
|
-
return result.data;
|
|
745
1288
|
};
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
return validate(schema, options);
|
|
1289
|
+
var ZapierRelayError = class extends ZapierError {
|
|
1290
|
+
constructor(message, options = {}) {
|
|
1291
|
+
super(message, options);
|
|
1292
|
+
this.name = "ZapierRelayError";
|
|
1293
|
+
this.code = "ZAPIER_RELAY_ERROR";
|
|
1294
|
+
}
|
|
753
1295
|
};
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
return store !== void 0 && store.depth > 0;
|
|
763
|
-
}
|
|
764
|
-
function runWithTelemetryContext(fn) {
|
|
765
|
-
if (!telemetryStore) return fn();
|
|
766
|
-
const currentDepth = telemetryStore.getStore()?.depth ?? -1;
|
|
767
|
-
return telemetryStore.run({ depth: currentDepth + 1 }, fn);
|
|
768
|
-
}
|
|
769
|
-
function setMethodMetadata(metadata) {
|
|
770
|
-
if (!telemetryStore) return;
|
|
771
|
-
const store = telemetryStore.getStore();
|
|
772
|
-
if (!store) return;
|
|
773
|
-
store.methodMetadata = { ...store.methodMetadata, ...metadata };
|
|
774
|
-
}
|
|
775
|
-
function getMethodMetadata() {
|
|
776
|
-
if (!telemetryStore) return void 0;
|
|
777
|
-
return telemetryStore.getStore()?.methodMetadata;
|
|
778
|
-
}
|
|
779
|
-
|
|
780
|
-
// src/utils/function-utils.ts
|
|
781
|
-
function extractCursor(data) {
|
|
782
|
-
if (!data?.next) {
|
|
783
|
-
return void 0;
|
|
1296
|
+
function formatErrorMessage(error) {
|
|
1297
|
+
let message = error.message;
|
|
1298
|
+
if (error.errors && error.errors.length > 0) {
|
|
1299
|
+
const additionalErrors = error.errors.slice(1);
|
|
1300
|
+
if (additionalErrors.length > 0) {
|
|
1301
|
+
const errorDetails = additionalErrors.map((err) => ` \u2022 ${err.detail || err.title || err.code}`).join("\n");
|
|
1302
|
+
message += "\n\nAdditional errors:\n" + errorDetails;
|
|
1303
|
+
}
|
|
784
1304
|
}
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
return offset || void 0;
|
|
789
|
-
} catch {
|
|
790
|
-
return void 0;
|
|
1305
|
+
if (error instanceof ZapierAppNotFoundError && error.appKey) {
|
|
1306
|
+
message += `
|
|
1307
|
+
App key: ${error.appKey}`;
|
|
791
1308
|
}
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
1309
|
+
if (error instanceof ZapierActionError && (error.appKey || error.actionKey)) {
|
|
1310
|
+
const context = [];
|
|
1311
|
+
if (error.appKey) context.push(`App: ${error.appKey}`);
|
|
1312
|
+
if (error.actionKey) context.push(`Action: ${error.actionKey}`);
|
|
1313
|
+
message += `
|
|
1314
|
+
${context.join(", ")}`;
|
|
796
1315
|
}
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
if (error.
|
|
801
|
-
|
|
802
|
-
|
|
1316
|
+
if (error instanceof ZapierResourceNotFoundError && (error.resourceType || error.resourceId)) {
|
|
1317
|
+
const context = [];
|
|
1318
|
+
if (error.resourceType) context.push(`Type: ${error.resourceType}`);
|
|
1319
|
+
if (error.resourceId) context.push(`ID: ${error.resourceId}`);
|
|
1320
|
+
message += `
|
|
1321
|
+
${context.join(", ")}`;
|
|
803
1322
|
}
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
success: true,
|
|
829
|
-
argumentCount,
|
|
830
|
-
isPaginated: false
|
|
831
|
-
});
|
|
832
|
-
}
|
|
833
|
-
return result2;
|
|
834
|
-
}
|
|
835
|
-
const result = await coreFn(normalizedOptions);
|
|
836
|
-
if (!isNested && telemetry?.onMethodCalled) {
|
|
837
|
-
const argumentCount = Object.keys(
|
|
838
|
-
normalizedOptions
|
|
839
|
-
).length;
|
|
840
|
-
telemetry.onMethodCalled({
|
|
841
|
-
methodName: functionName,
|
|
842
|
-
durationMs: Date.now() - startTime,
|
|
843
|
-
success: true,
|
|
844
|
-
argumentCount,
|
|
845
|
-
isPaginated: false
|
|
846
|
-
});
|
|
847
|
-
}
|
|
848
|
-
return result;
|
|
849
|
-
} catch (error) {
|
|
850
|
-
const normalizedError = normalizeError(error);
|
|
851
|
-
if (!isNested && telemetry?.onMethodCalled) {
|
|
852
|
-
const argumentCount = Object.keys(
|
|
853
|
-
normalizedOptions
|
|
854
|
-
).length;
|
|
855
|
-
telemetry.onMethodCalled({
|
|
856
|
-
methodName: functionName,
|
|
857
|
-
durationMs: Date.now() - startTime,
|
|
858
|
-
success: false,
|
|
859
|
-
error: normalizedError,
|
|
860
|
-
argumentCount,
|
|
861
|
-
isPaginated: false
|
|
862
|
-
});
|
|
863
|
-
}
|
|
864
|
-
throw normalizedError;
|
|
865
|
-
}
|
|
866
|
-
});
|
|
867
|
-
}
|
|
868
|
-
};
|
|
869
|
-
return namedFunctions[functionName];
|
|
870
|
-
}
|
|
871
|
-
function createPageFunction(coreFn) {
|
|
872
|
-
const functionName = coreFn.name + "Page";
|
|
873
|
-
const namedFunctions = {
|
|
874
|
-
[functionName]: async function(options) {
|
|
875
|
-
try {
|
|
876
|
-
const result = await coreFn(options);
|
|
877
|
-
if (result && typeof result === "object" && "data" in result) {
|
|
878
|
-
const paginatedResult = result;
|
|
879
|
-
let nextCursor;
|
|
880
|
-
if (paginatedResult.nextCursor) {
|
|
881
|
-
nextCursor = paginatedResult.nextCursor;
|
|
882
|
-
} else if (paginatedResult.links?.next) {
|
|
883
|
-
nextCursor = extractCursor({ next: paginatedResult.links.next });
|
|
884
|
-
}
|
|
885
|
-
return {
|
|
886
|
-
data: Array.isArray(paginatedResult.data) ? paginatedResult.data : [paginatedResult.data],
|
|
887
|
-
nextCursor
|
|
888
|
-
};
|
|
889
|
-
}
|
|
890
|
-
if (Array.isArray(result)) {
|
|
891
|
-
return { data: result };
|
|
892
|
-
}
|
|
893
|
-
return { data: [result] };
|
|
894
|
-
} catch (error) {
|
|
895
|
-
throw normalizeError(error);
|
|
896
|
-
}
|
|
897
|
-
}
|
|
898
|
-
};
|
|
899
|
-
return namedFunctions[functionName];
|
|
900
|
-
}
|
|
901
|
-
function createPaginatedFunction(coreFn, schema, telemetry, explicitFunctionName, defaultPageSize) {
|
|
902
|
-
const pageFunction = createPageFunction(coreFn);
|
|
903
|
-
const functionName = explicitFunctionName || coreFn.name;
|
|
904
|
-
const validator = schema ? createValidator(schema) : null;
|
|
905
|
-
const namedFunctions = {
|
|
906
|
-
[functionName]: function(options) {
|
|
907
|
-
return runWithTelemetryContext(() => {
|
|
908
|
-
const startTime = Date.now();
|
|
909
|
-
const normalizedOptions = options ?? {};
|
|
910
|
-
const isNested = isTelemetryNested();
|
|
911
|
-
const validatedOptions = {
|
|
912
|
-
...normalizedOptions,
|
|
913
|
-
...validator ? validator(normalizedOptions) : normalizedOptions
|
|
914
|
-
};
|
|
915
|
-
const pageSize = validatedOptions.pageSize ?? defaultPageSize;
|
|
916
|
-
const optimizedOptions = {
|
|
917
|
-
...validatedOptions,
|
|
918
|
-
pageSize
|
|
919
|
-
};
|
|
920
|
-
const iterator = paginate(pageFunction, optimizedOptions);
|
|
921
|
-
const firstPagePromise = iterator.next().then((result) => {
|
|
922
|
-
if (result.done) {
|
|
923
|
-
throw new Error("Paginate should always iterate at least once");
|
|
924
|
-
}
|
|
925
|
-
return result.value;
|
|
926
|
-
});
|
|
927
|
-
if (!isNested && telemetry?.onMethodCalled) {
|
|
928
|
-
firstPagePromise.then(() => {
|
|
929
|
-
const argumentCount = Object.keys(
|
|
930
|
-
normalizedOptions
|
|
931
|
-
).length;
|
|
932
|
-
telemetry.onMethodCalled({
|
|
933
|
-
methodName: functionName,
|
|
934
|
-
durationMs: Date.now() - startTime,
|
|
935
|
-
success: true,
|
|
936
|
-
argumentCount,
|
|
937
|
-
isPaginated: true
|
|
938
|
-
});
|
|
939
|
-
}).catch((error) => {
|
|
940
|
-
const argumentCount = Object.keys(
|
|
941
|
-
normalizedOptions
|
|
942
|
-
).length;
|
|
943
|
-
telemetry.onMethodCalled({
|
|
944
|
-
methodName: functionName,
|
|
945
|
-
durationMs: Date.now() - startTime,
|
|
946
|
-
success: false,
|
|
947
|
-
error: error instanceof Error ? error : new Error(String(error)),
|
|
948
|
-
argumentCount,
|
|
949
|
-
isPaginated: true
|
|
950
|
-
});
|
|
951
|
-
});
|
|
952
|
-
}
|
|
953
|
-
return Object.assign(firstPagePromise, {
|
|
954
|
-
[Symbol.asyncIterator]: async function* () {
|
|
955
|
-
yield await firstPagePromise;
|
|
956
|
-
for await (const page of iterator) {
|
|
957
|
-
yield page;
|
|
958
|
-
}
|
|
959
|
-
},
|
|
960
|
-
items: function() {
|
|
961
|
-
return {
|
|
962
|
-
[Symbol.asyncIterator]: async function* () {
|
|
963
|
-
const firstPage = await firstPagePromise;
|
|
964
|
-
for (const item of firstPage.data) {
|
|
965
|
-
yield item;
|
|
966
|
-
}
|
|
967
|
-
for await (const page of iterator) {
|
|
968
|
-
for (const item of page.data) {
|
|
969
|
-
yield item;
|
|
970
|
-
}
|
|
971
|
-
}
|
|
972
|
-
}
|
|
973
|
-
};
|
|
974
|
-
}
|
|
975
|
-
});
|
|
976
|
-
});
|
|
977
|
-
}
|
|
978
|
-
};
|
|
979
|
-
return namedFunctions[functionName];
|
|
980
|
-
}
|
|
981
|
-
|
|
982
|
-
// src/utils/telemetry-utils.ts
|
|
983
|
-
function createTelemetryCallback(emitMethodCalled, methodName) {
|
|
984
|
-
return {
|
|
985
|
-
onMethodCalled: (data) => {
|
|
986
|
-
const metadata = getMethodMetadata();
|
|
987
|
-
emitMethodCalled({
|
|
988
|
-
method_name: methodName,
|
|
989
|
-
execution_duration_ms: data.durationMs,
|
|
990
|
-
success_flag: data.success,
|
|
991
|
-
error_message: data.error?.message ?? null,
|
|
992
|
-
error_type: data.error?.constructor.name ?? null,
|
|
993
|
-
argument_count: data.argumentCount,
|
|
994
|
-
is_paginated: data.isPaginated,
|
|
995
|
-
selected_api: metadata?.selectedApi ?? null,
|
|
996
|
-
operation_type: metadata?.operationType ?? null,
|
|
997
|
-
operation_key: metadata?.operationKey ?? null
|
|
998
|
-
});
|
|
999
|
-
}
|
|
1000
|
-
};
|
|
1001
|
-
}
|
|
1002
|
-
|
|
1003
|
-
// src/utils/plugin-utils.ts
|
|
1004
|
-
function definePlugin(fn) {
|
|
1005
|
-
return fn;
|
|
1006
|
-
}
|
|
1007
|
-
function maybeTelemetry(sdk, name) {
|
|
1008
|
-
const ctx = sdk.context;
|
|
1009
|
-
if (!ctx.eventEmission) return void 0;
|
|
1010
|
-
return createTelemetryCallback(ctx.eventEmission.emitMethodCalled, name);
|
|
1011
|
-
}
|
|
1012
|
-
function createPluginMethod(sdk, config) {
|
|
1013
|
-
const { name, inputSchema, handler, ...metaFields } = config;
|
|
1014
|
-
const namedHandlers = {
|
|
1015
|
-
[name]: async function(options) {
|
|
1016
|
-
return handler({ sdk, options });
|
|
1017
|
-
}
|
|
1018
|
-
};
|
|
1019
|
-
const wrappedFn = createFunction(
|
|
1020
|
-
namedHandlers[name],
|
|
1021
|
-
inputSchema,
|
|
1022
|
-
maybeTelemetry(sdk, name)
|
|
1023
|
-
);
|
|
1024
|
-
return {
|
|
1025
|
-
[name]: wrappedFn,
|
|
1026
|
-
context: {
|
|
1027
|
-
meta: {
|
|
1028
|
-
[name]: {
|
|
1029
|
-
...metaFields,
|
|
1030
|
-
...inputSchema ? { inputSchema } : {}
|
|
1031
|
-
}
|
|
1032
|
-
}
|
|
1033
|
-
}
|
|
1034
|
-
};
|
|
1035
|
-
}
|
|
1036
|
-
function createPaginatedPluginMethod(sdk, config) {
|
|
1037
|
-
const {
|
|
1038
|
-
name,
|
|
1039
|
-
inputSchema,
|
|
1040
|
-
handler,
|
|
1041
|
-
extractCursor: extractCursorFn,
|
|
1042
|
-
defaultPageSize,
|
|
1043
|
-
...metaFields
|
|
1044
|
-
} = config;
|
|
1045
|
-
const namedPageHandlers = {
|
|
1046
|
-
[name]: async function(options) {
|
|
1047
|
-
const response = await handler({ sdk, options });
|
|
1048
|
-
if (extractCursorFn) {
|
|
1049
|
-
const extracted = extractCursorFn(response);
|
|
1050
|
-
if (extracted !== void 0) {
|
|
1051
|
-
return { data: response.data, nextCursor: extracted };
|
|
1052
|
-
}
|
|
1053
|
-
}
|
|
1054
|
-
return response;
|
|
1055
|
-
}
|
|
1056
|
-
};
|
|
1057
|
-
const wrappedFn = createPaginatedFunction(
|
|
1058
|
-
namedPageHandlers[name],
|
|
1059
|
-
inputSchema,
|
|
1060
|
-
maybeTelemetry(sdk, name),
|
|
1061
|
-
name,
|
|
1062
|
-
defaultPageSize
|
|
1063
|
-
);
|
|
1064
|
-
return {
|
|
1065
|
-
[name]: wrappedFn,
|
|
1066
|
-
context: {
|
|
1067
|
-
meta: {
|
|
1068
|
-
[name]: {
|
|
1069
|
-
...metaFields,
|
|
1070
|
-
...inputSchema ? { inputSchema } : {}
|
|
1071
|
-
}
|
|
1072
|
-
}
|
|
1323
|
+
if (error instanceof ZapierConflictError && error.resourceType) {
|
|
1324
|
+
message += `
|
|
1325
|
+
Type: ${error.resourceType}`;
|
|
1326
|
+
}
|
|
1327
|
+
if (error instanceof ZapierTimeoutError && (error.attempts || error.maxAttempts)) {
|
|
1328
|
+
const context = [];
|
|
1329
|
+
if (error.attempts) context.push(`Attempts: ${error.attempts}`);
|
|
1330
|
+
if (error.maxAttempts) context.push(`Max attempts: ${error.maxAttempts}`);
|
|
1331
|
+
message += `
|
|
1332
|
+
${context.join(", ")}`;
|
|
1333
|
+
}
|
|
1334
|
+
if (error instanceof ZapierBundleError && error.buildErrors && error.buildErrors.length > 0) {
|
|
1335
|
+
message += "\n\nBuild errors:\n" + error.buildErrors.map((err) => ` \u2022 ${err}`).join("\n");
|
|
1336
|
+
}
|
|
1337
|
+
if (error instanceof ZapierApprovalError && error.approvalUrl) {
|
|
1338
|
+
message += `
|
|
1339
|
+
Approval URL: ${error.approvalUrl}`;
|
|
1340
|
+
}
|
|
1341
|
+
if (error instanceof ZapierRateLimitError) {
|
|
1342
|
+
const { limit, remaining, retryAfterMs } = error.rateLimit;
|
|
1343
|
+
const parts = [];
|
|
1344
|
+
if (limit !== void 0) {
|
|
1345
|
+
const used = remaining !== void 0 ? limit - remaining : limit;
|
|
1346
|
+
parts.push(`${used}/${limit} used`);
|
|
1073
1347
|
}
|
|
1074
|
-
|
|
1075
|
-
}
|
|
1076
|
-
function mergeRootKeysWithCollisionCheck(target, source, seen) {
|
|
1077
|
-
for (const key of Object.keys(source)) {
|
|
1078
|
-
if (seen.has(key)) {
|
|
1079
|
-
throw new Error(
|
|
1080
|
-
`composePlugins: duplicate root key "${key}". Plugins composed in the same call must register distinct method names.`
|
|
1081
|
-
);
|
|
1348
|
+
if (retryAfterMs !== void 0 && retryAfterMs > 0) {
|
|
1349
|
+
parts.push(`retry in ${formatDuration(retryAfterMs)}`);
|
|
1082
1350
|
}
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
}
|
|
1087
|
-
function mergeMetaKeysWithCollisionCheck(target, source, seen) {
|
|
1088
|
-
for (const key of Object.keys(source)) {
|
|
1089
|
-
if (seen.has(key)) {
|
|
1090
|
-
throw new Error(
|
|
1091
|
-
`composePlugins: duplicate context.meta key "${key}". Two sub-plugins registered metadata for the same name.`
|
|
1351
|
+
if (error.retries > 0) {
|
|
1352
|
+
parts.push(
|
|
1353
|
+
`after ${error.retries} retr${error.retries === 1 ? "y" : "ies"}`
|
|
1092
1354
|
);
|
|
1093
1355
|
}
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
}
|
|
1098
|
-
function mergeContextKeysWithCollisionCheck(target, source, seen) {
|
|
1099
|
-
for (const key of Object.keys(source)) {
|
|
1100
|
-
if (seen.has(key)) {
|
|
1101
|
-
throw new Error(
|
|
1102
|
-
`composePlugins: duplicate context key "${key}". Two sub-plugins contributed the same context.${key} field.`
|
|
1103
|
-
);
|
|
1356
|
+
if (parts.length > 0) {
|
|
1357
|
+
message += `
|
|
1358
|
+
${parts.join(", ")}`;
|
|
1104
1359
|
}
|
|
1105
|
-
seen.add(key);
|
|
1106
|
-
target[key] = source[key];
|
|
1107
1360
|
}
|
|
1108
|
-
}
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
const merged = { context: { meta: {} } };
|
|
1112
|
-
const seenRoot = /* @__PURE__ */ new Set();
|
|
1113
|
-
const seenMeta = /* @__PURE__ */ new Set();
|
|
1114
|
-
const seenContext = /* @__PURE__ */ new Set();
|
|
1115
|
-
for (const plugin of plugins) {
|
|
1116
|
-
const { context, ...rootKeys } = plugin(sdk);
|
|
1117
|
-
mergeRootKeysWithCollisionCheck(merged, rootKeys, seenRoot);
|
|
1118
|
-
if (context) {
|
|
1119
|
-
const { meta, ...nonMetaContext } = context;
|
|
1120
|
-
if (meta) {
|
|
1121
|
-
mergeMetaKeysWithCollisionCheck(merged.context.meta, meta, seenMeta);
|
|
1122
|
-
}
|
|
1123
|
-
mergeContextKeysWithCollisionCheck(
|
|
1124
|
-
merged.context,
|
|
1125
|
-
nonMetaContext,
|
|
1126
|
-
seenContext
|
|
1127
|
-
);
|
|
1128
|
-
}
|
|
1129
|
-
}
|
|
1130
|
-
return merged;
|
|
1131
|
-
};
|
|
1132
|
-
}
|
|
1133
|
-
function getStringProperty(obj, key) {
|
|
1134
|
-
if (typeof obj === "object" && obj !== null && key in obj) {
|
|
1135
|
-
const value = obj[key];
|
|
1136
|
-
return typeof value === "string" ? value : void 0;
|
|
1361
|
+
if (error.statusCode && !message.includes(`${error.statusCode}`)) {
|
|
1362
|
+
message += `
|
|
1363
|
+
HTTP Status: ${error.statusCode}`;
|
|
1137
1364
|
}
|
|
1138
|
-
return
|
|
1365
|
+
return message;
|
|
1139
1366
|
}
|
|
1140
|
-
function
|
|
1141
|
-
const
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
// Let formatJsonOutput handle the JSON rendering
|
|
1150
|
-
details: []
|
|
1151
|
-
// Not used when data is provided
|
|
1152
|
-
};
|
|
1367
|
+
function formatDuration(ms) {
|
|
1368
|
+
const seconds = Math.round(ms / 1e3);
|
|
1369
|
+
if (seconds < 60) return `${seconds}s`;
|
|
1370
|
+
const minutes = Math.round(seconds / 60);
|
|
1371
|
+
if (minutes < 60) return `${minutes}m`;
|
|
1372
|
+
const hours = Math.round(minutes / 60);
|
|
1373
|
+
if (hours < 24) return `${hours}h`;
|
|
1374
|
+
const days = Math.round(hours / 24);
|
|
1375
|
+
return `${days}d`;
|
|
1153
1376
|
}
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1377
|
+
|
|
1378
|
+
// src/types/signals.ts
|
|
1379
|
+
var ZapierSignal = class extends Error {
|
|
1380
|
+
constructor(message) {
|
|
1381
|
+
super(message);
|
|
1382
|
+
Object.setPrototypeOf(this, new.target.prototype);
|
|
1383
|
+
}
|
|
1384
|
+
};
|
|
1385
|
+
var ZapierReleaseTriggerMessageSignal = class extends ZapierSignal {
|
|
1386
|
+
constructor() {
|
|
1387
|
+
super(...arguments);
|
|
1388
|
+
this.name = "ZapierReleaseTriggerMessageSignal";
|
|
1389
|
+
this.code = "ZAPIER_RELEASE_TRIGGER_MESSAGE_SIGNAL";
|
|
1390
|
+
}
|
|
1391
|
+
};
|
|
1392
|
+
var ZapierAbortDrainSignal = class extends ZapierSignal {
|
|
1393
|
+
constructor() {
|
|
1394
|
+
super(...arguments);
|
|
1395
|
+
this.name = "ZapierAbortDrainSignal";
|
|
1396
|
+
this.code = "ZAPIER_ABORT_DRAIN_SIGNAL";
|
|
1397
|
+
}
|
|
1398
|
+
};
|
|
1399
|
+
var TriggerInboxCommandBaseSchema = zod.z.object({
|
|
1400
|
+
inbox: TriggerInboxPropertySchema,
|
|
1401
|
+
onMessage: zod.z.function().optional().meta({ exampleRequired: true }).describe(
|
|
1402
|
+
"Per-message handler. Resolves to ack; rejects to release-or-leave per `releaseOnError`. Throw `ZapierReleaseTriggerMessageSignal` to release explicitly, or `ZapierAbortDrainSignal` to stop after the current batch."
|
|
1403
|
+
),
|
|
1404
|
+
concurrency: zod.z.number().int().min(1).optional().describe(
|
|
1405
|
+
"Per-message handler workers running in parallel. Defaults to `leaseLimit`, or 1 if neither is set."
|
|
1406
|
+
),
|
|
1407
|
+
leaseLimit: zod.z.number().int().min(1).max(100).optional().describe(
|
|
1408
|
+
"Per-lease HTTP batch size. Defaults to `concurrency`, or 1 if neither is set."
|
|
1409
|
+
),
|
|
1410
|
+
leaseSeconds: LeaseSecondsPropertySchema.optional(),
|
|
1411
|
+
releaseOnError: zod.z.boolean().optional().describe(
|
|
1412
|
+
"If true, errors release the message when the drain finishes. If false (default), errors leave it leased until the lease timeout. `ZapierReleaseTriggerMessageSignal` always releases regardless."
|
|
1413
|
+
),
|
|
1414
|
+
continueOnError: zod.z.boolean().optional().describe(
|
|
1415
|
+
"If false (default, fail-fast), the first handler error rejects and stops the drain. If true, handler errors are observed via `onError` and the drain continues. SDK-level errors (lease / ack / release) reject regardless."
|
|
1416
|
+
),
|
|
1417
|
+
onError: zod.z.function().optional().describe(
|
|
1418
|
+
"Per-message error observer for `continueOnError: true`. Called with the failure and the message; control-flow signals are filtered out. Throws from `onError` are swallowed."
|
|
1419
|
+
),
|
|
1420
|
+
signal: zod.z.custom((v) => v instanceof AbortSignal).optional().describe(
|
|
1421
|
+
"Abort signal. Aborting cancels in-flight HTTP, releases unprocessed messages, and resolves cleanly. Errors during shutdown still reject."
|
|
1422
|
+
)
|
|
1423
|
+
});
|
|
1424
|
+
TriggerInboxCommandBaseSchema.extend({
|
|
1425
|
+
maxMessages: zod.z.number().int().min(1).optional().describe(
|
|
1426
|
+
"Cap total messages drained. Defaults to draining the inbox until empty."
|
|
1427
|
+
)
|
|
1428
|
+
}).describe(
|
|
1429
|
+
"Drain an existing trigger inbox: lease currently-available messages and process them via onMessage. Returns when the inbox is empty, maxMessages is reached, the abort signal fires, or a fatal error rejects."
|
|
1430
|
+
);
|
|
1431
|
+
TriggerInboxCommandBaseSchema.extend({
|
|
1432
|
+
maxDrainIntervalSeconds: zod.z.number().int().min(1).optional().describe(
|
|
1433
|
+
"Maximum seconds between empty-inbox poll attempts (default: 60). Caps the back-off cadence."
|
|
1434
|
+
)
|
|
1435
|
+
}).describe(
|
|
1436
|
+
"Continuously consume a trigger inbox: drain currently-available messages, then poll with backoff for new arrivals, until aborted. Stop via the `signal` AbortSignal or by throwing `ZapierAbortDrainSignal` from a handler. Resolves cleanly on abort; rejects on a fatal error or a fail-fast handler error."
|
|
1157
1437
|
);
|
|
1438
|
+
var ActionExecutionInputSchema = zod.z.object({
|
|
1439
|
+
inputs: zod.z.record(zod.z.string(), zod.z.unknown()).optional(),
|
|
1440
|
+
/** @deprecated Use `connection` instead. */
|
|
1441
|
+
connectionId: ConnectionIdPropertySchema.optional().meta({
|
|
1442
|
+
deprecated: true
|
|
1443
|
+
}),
|
|
1444
|
+
connection: ConnectionPropertySchema.optional(),
|
|
1445
|
+
/** @deprecated Use connection instead */
|
|
1446
|
+
authenticationId: AuthenticationIdPropertySchema.optional().meta({
|
|
1447
|
+
deprecated: true
|
|
1448
|
+
}),
|
|
1449
|
+
timeoutMs: ActionTimeoutMsPropertySchema
|
|
1450
|
+
}).describe(
|
|
1451
|
+
"Execute an action with the given inputs for the bound app, as an alternative to runAction"
|
|
1452
|
+
).meta({
|
|
1453
|
+
aliases: { connectionId: "connection", authenticationId: "connection" }
|
|
1454
|
+
});
|
|
1455
|
+
var AppFactoryInputSchema = zod.z.object({
|
|
1456
|
+
/** @deprecated Use `connection` instead. */
|
|
1457
|
+
connectionId: ConnectionIdPropertySchema.optional().meta({
|
|
1458
|
+
deprecated: true
|
|
1459
|
+
}),
|
|
1460
|
+
connection: ConnectionPropertySchema.optional(),
|
|
1461
|
+
/** @deprecated Use connection instead */
|
|
1462
|
+
authenticationId: AuthenticationIdPropertySchema.optional().meta({
|
|
1463
|
+
deprecated: true
|
|
1464
|
+
})
|
|
1465
|
+
}).describe("Bind a connection alias or numeric connectionId to an app").meta({
|
|
1466
|
+
aliases: { connectionId: "connection", authenticationId: "connection" }
|
|
1467
|
+
});
|
|
1468
|
+
var ActionResultItemSchema = zod.z.unknown().describe("Action execution result");
|
|
1158
1469
|
|
|
1159
1470
|
// src/plugins/apps/index.ts
|
|
1160
1471
|
function resolveProxyConnection({
|
|
@@ -1375,18 +1686,6 @@ var FetchInitSchema = zod.z.object({
|
|
|
1375
1686
|
aliases: { connectionId: "connection", authenticationId: "connection" }
|
|
1376
1687
|
});
|
|
1377
1688
|
|
|
1378
|
-
// src/utils/string-utils.ts
|
|
1379
|
-
function toTitleCase(input) {
|
|
1380
|
-
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(" ");
|
|
1381
|
-
}
|
|
1382
|
-
function toSnakeCase(input) {
|
|
1383
|
-
let result = input.replace(/([a-z0-9])([A-Z])/g, "$1_$2").replace(/[\s\-]+/g, "_").replace(/_+/g, "_").replace(/^_|_$/g, "").toLowerCase();
|
|
1384
|
-
if (/^[0-9]/.test(result)) {
|
|
1385
|
-
result = "_" + result;
|
|
1386
|
-
}
|
|
1387
|
-
return result;
|
|
1388
|
-
}
|
|
1389
|
-
|
|
1390
1689
|
// src/utils/domain-utils.ts
|
|
1391
1690
|
function isConnectionId(value) {
|
|
1392
1691
|
return /^\d+$/.test(value) || isUuid(value);
|
|
@@ -1689,15 +1988,25 @@ function buildAbortHandle({
|
|
|
1689
1988
|
return combineAbortSignals({ handles });
|
|
1690
1989
|
}
|
|
1691
1990
|
var FetchInitSdkValidationSchema = zod.z.looseObject(FetchInitZapierFieldsSchema.shape).optional();
|
|
1692
|
-
var validateFetchInit = createValidator(FetchInitSdkValidationSchema);
|
|
1693
1991
|
var fetchPlugin = definePlugin(
|
|
1694
1992
|
(sdk) => {
|
|
1993
|
+
const validateFetchInit = createValidator(FetchInitSdkValidationSchema, {
|
|
1994
|
+
adaptError: sdk.context.core?.adaptError
|
|
1995
|
+
});
|
|
1695
1996
|
return {
|
|
1696
1997
|
fetch: async function fetch2(url, init) {
|
|
1697
|
-
return
|
|
1998
|
+
return runInMethodScope(async () => {
|
|
1698
1999
|
const { api } = sdk.context;
|
|
2000
|
+
const { onMethodStart, onMethodEnd } = sdk.context.hooks;
|
|
1699
2001
|
const startTime = Date.now();
|
|
1700
|
-
const
|
|
2002
|
+
const depth = getCurrentDepth();
|
|
2003
|
+
const args = init === void 0 ? [url] : [url, init];
|
|
2004
|
+
onMethodStart?.({
|
|
2005
|
+
methodName: "fetch",
|
|
2006
|
+
args,
|
|
2007
|
+
isPaginated: false,
|
|
2008
|
+
depth
|
|
2009
|
+
});
|
|
1701
2010
|
try {
|
|
1702
2011
|
if (init) {
|
|
1703
2012
|
validateFetchInit(init);
|
|
@@ -1769,17 +2078,13 @@ var fetchPlugin = definePlugin(
|
|
|
1769
2078
|
statusCode: result.status
|
|
1770
2079
|
});
|
|
1771
2080
|
}
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
argument_count: init ? 2 : 1,
|
|
1780
|
-
is_paginated: false
|
|
1781
|
-
});
|
|
1782
|
-
}
|
|
2081
|
+
onMethodEnd?.({
|
|
2082
|
+
methodName: "fetch",
|
|
2083
|
+
args,
|
|
2084
|
+
isPaginated: false,
|
|
2085
|
+
depth,
|
|
2086
|
+
durationMs: Date.now() - startTime
|
|
2087
|
+
});
|
|
1783
2088
|
return result;
|
|
1784
2089
|
} catch (error) {
|
|
1785
2090
|
throw rewrapIfMaxTimeTimeout({
|
|
@@ -1791,17 +2096,14 @@ var fetchPlugin = definePlugin(
|
|
|
1791
2096
|
abortHandle?.dispose();
|
|
1792
2097
|
}
|
|
1793
2098
|
} catch (error) {
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
is_paginated: false
|
|
1803
|
-
});
|
|
1804
|
-
}
|
|
2099
|
+
onMethodEnd?.({
|
|
2100
|
+
methodName: "fetch",
|
|
2101
|
+
args,
|
|
2102
|
+
isPaginated: false,
|
|
2103
|
+
depth,
|
|
2104
|
+
durationMs: Date.now() - startTime,
|
|
2105
|
+
error: error instanceof Error ? error : new Error(String(error))
|
|
2106
|
+
});
|
|
1805
2107
|
throw error;
|
|
1806
2108
|
}
|
|
1807
2109
|
});
|
|
@@ -1811,7 +2113,11 @@ var fetchPlugin = definePlugin(
|
|
|
1811
2113
|
fetch: {
|
|
1812
2114
|
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.",
|
|
1813
2115
|
packages: ["sdk", "cli", "mcp"],
|
|
1814
|
-
|
|
2116
|
+
// Auto-derive would produce "Http"/"Https" from the key alone;
|
|
2117
|
+
// declare the title explicitly here so the registry renders
|
|
2118
|
+
// "HTTP Request". Other plugins in this category use the bare
|
|
2119
|
+
// string "http"; the object form wins regardless of order.
|
|
2120
|
+
categories: [{ key: "http", title: "HTTP Request" }],
|
|
1815
2121
|
returnType: "Response",
|
|
1816
2122
|
inputParameters: [
|
|
1817
2123
|
{ name: "url", schema: FetchUrlSchema },
|
|
@@ -1823,6 +2129,29 @@ var fetchPlugin = definePlugin(
|
|
|
1823
2129
|
};
|
|
1824
2130
|
}
|
|
1825
2131
|
);
|
|
2132
|
+
|
|
2133
|
+
// src/utils/pagination.ts
|
|
2134
|
+
function extractCursorFromUrl(url) {
|
|
2135
|
+
try {
|
|
2136
|
+
const params = new URL(url).searchParams;
|
|
2137
|
+
return params.get("offset") ?? params.get("cursor") ?? void 0;
|
|
2138
|
+
} catch {
|
|
2139
|
+
return void 0;
|
|
2140
|
+
}
|
|
2141
|
+
}
|
|
2142
|
+
function adaptZapierPage(response) {
|
|
2143
|
+
const r = response ?? {};
|
|
2144
|
+
const data = r.data;
|
|
2145
|
+
const linksNext = r.links?.next;
|
|
2146
|
+
if (typeof linksNext === "string") {
|
|
2147
|
+
return { data, nextCursor: extractCursorFromUrl(linksNext) };
|
|
2148
|
+
}
|
|
2149
|
+
if (typeof r.next === "string") {
|
|
2150
|
+
return { data, nextCursor: extractCursorFromUrl(r.next) };
|
|
2151
|
+
}
|
|
2152
|
+
return { data };
|
|
2153
|
+
}
|
|
2154
|
+
var zapierPagination = { adaptPage: adaptZapierPage };
|
|
1826
2155
|
var ListAppsSchema = apps.ListAppsQuerySchema.omit({
|
|
1827
2156
|
offset: true,
|
|
1828
2157
|
app_keys: true,
|
|
@@ -1844,27 +2173,30 @@ var ListAppsSchema = apps.ListAppsQuerySchema.omit({
|
|
|
1844
2173
|
// SDK specific property for pagination/iterable helpers
|
|
1845
2174
|
cursor: zod.z.string().optional().describe("Cursor to start from")
|
|
1846
2175
|
}).describe("List all available apps with optional filtering");
|
|
1847
|
-
var AppItemSchema =
|
|
1848
|
-
|
|
1849
|
-
|
|
1850
|
-
|
|
1851
|
-
|
|
1852
|
-
|
|
1853
|
-
|
|
1854
|
-
|
|
1855
|
-
|
|
1856
|
-
|
|
1857
|
-
})
|
|
2176
|
+
var AppItemSchema = apps.AppItemSchema;
|
|
2177
|
+
|
|
2178
|
+
// src/formatters/app.ts
|
|
2179
|
+
var appItemFormatter = {
|
|
2180
|
+
format: (item) => ({
|
|
2181
|
+
title: item.title,
|
|
2182
|
+
key: item.key,
|
|
2183
|
+
keys: getAppKeyList(item),
|
|
2184
|
+
description: item.description,
|
|
2185
|
+
details: []
|
|
2186
|
+
})
|
|
2187
|
+
};
|
|
1858
2188
|
|
|
1859
2189
|
// src/plugins/listApps/index.ts
|
|
1860
2190
|
var listAppsPlugin = definePlugin(
|
|
1861
2191
|
(sdk) => createPaginatedPluginMethod(sdk, {
|
|
2192
|
+
...zapierPagination,
|
|
1862
2193
|
name: "listApps",
|
|
1863
2194
|
categories: ["app"],
|
|
1864
2195
|
type: "list",
|
|
1865
2196
|
itemType: "App",
|
|
1866
2197
|
inputSchema: ListAppsSchema,
|
|
1867
2198
|
outputSchema: AppItemSchema,
|
|
2199
|
+
formatter: appItemFormatter,
|
|
1868
2200
|
defaultPageSize: DEFAULT_PAGE_SIZE,
|
|
1869
2201
|
handler: async ({ sdk: sdk2, options }) => {
|
|
1870
2202
|
const { api, resolveAppKeys: resolveAppKeys2 } = sdk2.context;
|
|
@@ -1904,8 +2236,7 @@ var listAppsPlugin = definePlugin(
|
|
|
1904
2236
|
...options.cursor && { offset: options.cursor }
|
|
1905
2237
|
}
|
|
1906
2238
|
});
|
|
1907
|
-
}
|
|
1908
|
-
extractCursor: (response) => extractCursor(response.links)
|
|
2239
|
+
}
|
|
1909
2240
|
})
|
|
1910
2241
|
);
|
|
1911
2242
|
var ListActionsDescription = "List all actions for a specific app";
|
|
@@ -2230,48 +2561,42 @@ zod.z.object({
|
|
|
2230
2561
|
});
|
|
2231
2562
|
|
|
2232
2563
|
// src/schemas/Action.ts
|
|
2233
|
-
var ActionItemSchema =
|
|
2234
|
-
|
|
2235
|
-
|
|
2236
|
-
|
|
2237
|
-
|
|
2238
|
-
|
|
2239
|
-
|
|
2240
|
-
|
|
2241
|
-
|
|
2242
|
-
|
|
2243
|
-
|
|
2244
|
-
|
|
2245
|
-
|
|
2246
|
-
|
|
2247
|
-
|
|
2248
|
-
|
|
2249
|
-
|
|
2250
|
-
|
|
2251
|
-
|
|
2252
|
-
|
|
2253
|
-
|
|
2254
|
-
|
|
2255
|
-
|
|
2256
|
-
|
|
2257
|
-
|
|
2258
|
-
}
|
|
2259
|
-
if (item.description) {
|
|
2260
|
-
details.push({
|
|
2261
|
-
text: item.description,
|
|
2262
|
-
style: "dim"
|
|
2263
|
-
});
|
|
2264
|
-
}
|
|
2265
|
-
return {
|
|
2266
|
-
title: item.title || item.key,
|
|
2267
|
-
id: item.id,
|
|
2268
|
-
key: item.key,
|
|
2269
|
-
description: item.description,
|
|
2270
|
-
details
|
|
2271
|
-
};
|
|
2564
|
+
var ActionItemSchema = ActionSchema.omit({
|
|
2565
|
+
type: true,
|
|
2566
|
+
name: true,
|
|
2567
|
+
selected_api: true
|
|
2568
|
+
}).extend({
|
|
2569
|
+
app_key: zod.z.string(),
|
|
2570
|
+
// App key without version (extracted from selected_api)
|
|
2571
|
+
app_version: zod.z.string().optional(),
|
|
2572
|
+
// Version extracted from selected_api
|
|
2573
|
+
action_type: ActionSchema.shape.type,
|
|
2574
|
+
// Mapped from original 'type' field
|
|
2575
|
+
title: zod.z.string(),
|
|
2576
|
+
// Mapped from original 'name' field
|
|
2577
|
+
type: zod.z.literal("action")
|
|
2578
|
+
// Fixed type identifier
|
|
2579
|
+
});
|
|
2580
|
+
|
|
2581
|
+
// src/formatters/action.ts
|
|
2582
|
+
var actionItemFormatter = {
|
|
2583
|
+
format: (item) => {
|
|
2584
|
+
const details = [{ text: `Type: ${item.action_type}`, style: "accent" }];
|
|
2585
|
+
if (item.app_key) {
|
|
2586
|
+
details.push({ text: `App: ${item.app_key}`, style: "normal" });
|
|
2587
|
+
}
|
|
2588
|
+
if (item.description) {
|
|
2589
|
+
details.push({ text: item.description, style: "dim" });
|
|
2272
2590
|
}
|
|
2591
|
+
return {
|
|
2592
|
+
title: item.title || item.key,
|
|
2593
|
+
id: item.id,
|
|
2594
|
+
key: item.key,
|
|
2595
|
+
description: item.description,
|
|
2596
|
+
details
|
|
2597
|
+
};
|
|
2273
2598
|
}
|
|
2274
|
-
|
|
2599
|
+
};
|
|
2275
2600
|
|
|
2276
2601
|
// src/resolvers/appKey.ts
|
|
2277
2602
|
var appKeyResolver = {
|
|
@@ -2478,7 +2803,7 @@ var inputFieldKeyResolver = {
|
|
|
2478
2803
|
type: "dynamic",
|
|
2479
2804
|
depends: ["app", "action", "actionType", "connection"],
|
|
2480
2805
|
fetch: async (sdk, resolvedParams) => {
|
|
2481
|
-
const fieldsResponse = await sdk.
|
|
2806
|
+
const fieldsResponse = await sdk.listActionInputFields({
|
|
2482
2807
|
app: resolvedParams.app,
|
|
2483
2808
|
action: resolvedParams.action,
|
|
2484
2809
|
actionType: resolvedParams.actionType,
|
|
@@ -2584,7 +2909,8 @@ var workflowIdResolver = {
|
|
|
2584
2909
|
name: "workflow",
|
|
2585
2910
|
message: "Select a workflow:",
|
|
2586
2911
|
choices: workflows.map((workflow) => ({
|
|
2587
|
-
name: workflow.
|
|
2912
|
+
name: workflow.name,
|
|
2913
|
+
hint: workflow.enabled ? void 0 : [workflow.id, "disabled"],
|
|
2588
2914
|
value: workflow.id
|
|
2589
2915
|
}))
|
|
2590
2916
|
})
|
|
@@ -2599,7 +2925,8 @@ var durableRunIdResolver = {
|
|
|
2599
2925
|
name: "run",
|
|
2600
2926
|
message: "Select a run:",
|
|
2601
2927
|
choices: runs.map((run) => ({
|
|
2602
|
-
name:
|
|
2928
|
+
name: run.id,
|
|
2929
|
+
hint: run.status,
|
|
2603
2930
|
value: run.id
|
|
2604
2931
|
}))
|
|
2605
2932
|
})
|
|
@@ -2609,11 +2936,7 @@ var durableRunIdResolver = {
|
|
|
2609
2936
|
var workflowVersionIdResolver = {
|
|
2610
2937
|
type: "dynamic",
|
|
2611
2938
|
depends: ["workflow"],
|
|
2612
|
-
fetch: async (sdk, params) => toIterable(
|
|
2613
|
-
sdk.listWorkflowVersions({
|
|
2614
|
-
workflow: params.workflow
|
|
2615
|
-
})
|
|
2616
|
-
),
|
|
2939
|
+
fetch: async (sdk, params) => toIterable(sdk.listWorkflowVersions({ workflow: params.workflow })),
|
|
2617
2940
|
prompt: (versions) => ({
|
|
2618
2941
|
type: "list",
|
|
2619
2942
|
name: "version",
|
|
@@ -2625,15 +2948,27 @@ var workflowVersionIdResolver = {
|
|
|
2625
2948
|
})
|
|
2626
2949
|
};
|
|
2627
2950
|
|
|
2951
|
+
// src/resolvers/workflowRunId.ts
|
|
2952
|
+
var workflowRunIdResolver = {
|
|
2953
|
+
type: "dynamic",
|
|
2954
|
+
depends: ["workflow"],
|
|
2955
|
+
fetch: async (sdk, params) => toIterable(sdk.listWorkflowRuns({ workflow: params.workflow })),
|
|
2956
|
+
prompt: (runs) => ({
|
|
2957
|
+
type: "list",
|
|
2958
|
+
name: "run",
|
|
2959
|
+
message: "Select a workflow run:",
|
|
2960
|
+
choices: runs.map((r) => ({
|
|
2961
|
+
name: `${r.id} \u2014 ${r.status}`,
|
|
2962
|
+
value: r.id
|
|
2963
|
+
}))
|
|
2964
|
+
})
|
|
2965
|
+
};
|
|
2966
|
+
|
|
2628
2967
|
// src/resolvers/triggerMessages.ts
|
|
2629
2968
|
var triggerMessagesResolver = {
|
|
2630
2969
|
type: "dynamic",
|
|
2631
2970
|
depends: ["inbox"],
|
|
2632
|
-
fetch: async (sdk, params) => toIterable(
|
|
2633
|
-
sdk.listTriggerInboxMessages({
|
|
2634
|
-
inbox: params.inbox
|
|
2635
|
-
})
|
|
2636
|
-
),
|
|
2971
|
+
fetch: async (sdk, params) => toIterable(sdk.listTriggerInboxMessages({ inbox: params.inbox })),
|
|
2637
2972
|
prompt: (messages) => ({
|
|
2638
2973
|
type: "checkbox",
|
|
2639
2974
|
name: "messages",
|
|
@@ -3007,7 +3342,7 @@ var FieldApiItemSchema = zod.z.object({
|
|
|
3007
3342
|
var ListTableFieldsApiResponseSchema = zod.z.object({
|
|
3008
3343
|
data: zod.z.array(FieldApiItemSchema)
|
|
3009
3344
|
});
|
|
3010
|
-
var
|
|
3345
|
+
var FieldItemSchema = zod.z.object({
|
|
3011
3346
|
id: zod.z.string(),
|
|
3012
3347
|
type: FieldTypeSchema,
|
|
3013
3348
|
name: zod.z.string(),
|
|
@@ -3017,13 +3352,6 @@ var FieldItemSchemaBase = zod.z.object({
|
|
|
3017
3352
|
config: zod.z.record(zod.z.string(), zod.z.unknown()).optional(),
|
|
3018
3353
|
deleted_at: zod.z.string().nullable().optional()
|
|
3019
3354
|
});
|
|
3020
|
-
var FieldItemSchema = withFormatter(FieldItemSchemaBase, {
|
|
3021
|
-
format: (item) => ({
|
|
3022
|
-
title: item.name,
|
|
3023
|
-
id: item.id,
|
|
3024
|
-
details: [{ text: `Type: ${item.type}`, style: "dim" }]
|
|
3025
|
-
})
|
|
3026
|
-
});
|
|
3027
3355
|
var ListTableFieldsDescription = "List fields for a table";
|
|
3028
3356
|
var ListTableFieldsOptionsBaseSchema = zod.z.object({
|
|
3029
3357
|
fields: FieldsPropertySchema.optional(),
|
|
@@ -3270,6 +3598,18 @@ var tableSortResolver = {
|
|
|
3270
3598
|
}
|
|
3271
3599
|
};
|
|
3272
3600
|
|
|
3601
|
+
// src/plugins/eventEmission/method-metadata.ts
|
|
3602
|
+
var SCOPE_KEY = "methodMetadata";
|
|
3603
|
+
function setMethodMetadata(metadata) {
|
|
3604
|
+
const scope = getCurrentScope();
|
|
3605
|
+
if (!scope) return;
|
|
3606
|
+
const existing = scope[SCOPE_KEY];
|
|
3607
|
+
scope[SCOPE_KEY] = { ...existing, ...metadata };
|
|
3608
|
+
}
|
|
3609
|
+
function getMethodMetadata() {
|
|
3610
|
+
return getCurrentScope()?.[SCOPE_KEY];
|
|
3611
|
+
}
|
|
3612
|
+
|
|
3273
3613
|
// src/plugins/listActions/index.ts
|
|
3274
3614
|
var listActionsPlugin = definePlugin(
|
|
3275
3615
|
(sdk) => createPaginatedPluginMethod(sdk, {
|
|
@@ -3279,12 +3619,10 @@ var listActionsPlugin = definePlugin(
|
|
|
3279
3619
|
itemType: "Action",
|
|
3280
3620
|
inputSchema: ListActionsInputSchema,
|
|
3281
3621
|
outputSchema: ActionItemSchema,
|
|
3622
|
+
formatter: actionItemFormatter,
|
|
3282
3623
|
defaultPageSize: DEFAULT_PAGE_SIZE,
|
|
3283
3624
|
resolvers: { app: appKeyResolver, actionType: actionTypeResolver },
|
|
3284
|
-
handler: async ({
|
|
3285
|
-
sdk: sdk2,
|
|
3286
|
-
options
|
|
3287
|
-
}) => {
|
|
3625
|
+
handler: async ({ sdk: sdk2, options }) => {
|
|
3288
3626
|
const { api, getVersionedImplementationId } = sdk2.context;
|
|
3289
3627
|
const appKey = "app" in options ? options.app : options.appKey;
|
|
3290
3628
|
const selectedApi = await getVersionedImplementationId(appKey);
|
|
@@ -3371,99 +3709,36 @@ var BaseFieldItemSchema = zod.z.object({
|
|
|
3371
3709
|
key: zod.z.string()
|
|
3372
3710
|
// From need.key
|
|
3373
3711
|
});
|
|
3374
|
-
var InputFieldItemSchema =
|
|
3375
|
-
|
|
3376
|
-
|
|
3377
|
-
|
|
3378
|
-
|
|
3379
|
-
|
|
3380
|
-
|
|
3381
|
-
|
|
3382
|
-
|
|
3383
|
-
|
|
3384
|
-
|
|
3385
|
-
|
|
3386
|
-
|
|
3387
|
-
|
|
3388
|
-
|
|
3389
|
-
|
|
3390
|
-
|
|
3391
|
-
|
|
3392
|
-
|
|
3393
|
-
|
|
3394
|
-
|
|
3395
|
-
|
|
3396
|
-
|
|
3397
|
-
|
|
3398
|
-
|
|
3399
|
-
|
|
3400
|
-
|
|
3401
|
-
|
|
3402
|
-
|
|
3403
|
-
|
|
3404
|
-
].filter(Boolean).join(" | ");
|
|
3405
|
-
if (typeInfo) {
|
|
3406
|
-
details.push({ text: typeInfo, style: "dim" });
|
|
3407
|
-
}
|
|
3408
|
-
if (item.description) {
|
|
3409
|
-
details.push({
|
|
3410
|
-
text: item.description,
|
|
3411
|
-
style: "normal"
|
|
3412
|
-
});
|
|
3413
|
-
}
|
|
3414
|
-
if (item.default_value) {
|
|
3415
|
-
details.push({
|
|
3416
|
-
text: `Default: ${item.default_value}`,
|
|
3417
|
-
style: "accent"
|
|
3418
|
-
});
|
|
3419
|
-
}
|
|
3420
|
-
if (item.placeholder) {
|
|
3421
|
-
details.push({
|
|
3422
|
-
text: `Placeholder: ${item.placeholder}`,
|
|
3423
|
-
style: "dim"
|
|
3424
|
-
});
|
|
3425
|
-
}
|
|
3426
|
-
if (item.depends_on && item.depends_on.length > 0) {
|
|
3427
|
-
details.push({
|
|
3428
|
-
text: `Depends on: ${item.depends_on.join(", ")}`,
|
|
3429
|
-
style: "warning"
|
|
3430
|
-
});
|
|
3431
|
-
}
|
|
3432
|
-
if (item.format) {
|
|
3433
|
-
details.push({ text: `Format: ${item.format}`, style: "dim" });
|
|
3434
|
-
}
|
|
3435
|
-
if (item.items) {
|
|
3436
|
-
details.push({
|
|
3437
|
-
text: `Items type: ${item.items.type}`,
|
|
3438
|
-
style: "dim"
|
|
3439
|
-
});
|
|
3440
|
-
}
|
|
3441
|
-
return {
|
|
3442
|
-
title: item.title || item.key,
|
|
3443
|
-
key: item.key,
|
|
3444
|
-
description: item.description,
|
|
3445
|
-
details
|
|
3446
|
-
};
|
|
3447
|
-
}
|
|
3448
|
-
}
|
|
3449
|
-
);
|
|
3450
|
-
var InfoFieldItemSchema = withFormatter(
|
|
3451
|
-
BaseFieldItemSchema.extend({
|
|
3452
|
-
type: zod.z.literal("info_field"),
|
|
3453
|
-
description: zod.z.string(),
|
|
3454
|
-
// From need.help_text
|
|
3455
|
-
title: zod.z.string().optional()
|
|
3456
|
-
// Optional title
|
|
3457
|
-
}),
|
|
3458
|
-
{
|
|
3459
|
-
format: (item) => ({
|
|
3460
|
-
title: item.title || "Info",
|
|
3461
|
-
key: item.key,
|
|
3462
|
-
description: item.description,
|
|
3463
|
-
details: [{ text: item.description, style: "normal" }]
|
|
3464
|
-
})
|
|
3465
|
-
}
|
|
3466
|
-
);
|
|
3712
|
+
var InputFieldItemSchema = BaseFieldItemSchema.extend({
|
|
3713
|
+
type: zod.z.literal("input_field"),
|
|
3714
|
+
default_value: zod.z.string(),
|
|
3715
|
+
// Mapped from 'default' with fallback to ""
|
|
3716
|
+
depends_on: zod.z.array(zod.z.string()),
|
|
3717
|
+
// Mapped from 'depends_on' with fallback to []
|
|
3718
|
+
description: zod.z.string(),
|
|
3719
|
+
// Mapped from 'help_text' with fallback to ""
|
|
3720
|
+
invalidates_input_fields: zod.z.boolean(),
|
|
3721
|
+
// Mapped from 'alters_custom_fields' with fallback to false
|
|
3722
|
+
is_required: zod.z.boolean(),
|
|
3723
|
+
// Mapped from 'required' with fallback to false
|
|
3724
|
+
placeholder: zod.z.string(),
|
|
3725
|
+
// Mapped from 'placeholder' with fallback to ""
|
|
3726
|
+
title: zod.z.string(),
|
|
3727
|
+
// Mapped from 'label' with fallback to ""
|
|
3728
|
+
value_type: zod.z.string(),
|
|
3729
|
+
// Computed from InputFieldType enum
|
|
3730
|
+
format: zod.z.string().optional(),
|
|
3731
|
+
// Computed from InputFieldFormat enum (optional)
|
|
3732
|
+
items: zod.z.object({ type: zod.z.string() }).optional()
|
|
3733
|
+
// Computed from ItemsType enum (optional, only for arrays)
|
|
3734
|
+
});
|
|
3735
|
+
var InfoFieldItemSchema = BaseFieldItemSchema.extend({
|
|
3736
|
+
type: zod.z.literal("info_field"),
|
|
3737
|
+
description: zod.z.string(),
|
|
3738
|
+
// From need.help_text
|
|
3739
|
+
title: zod.z.string().optional()
|
|
3740
|
+
// Optional title
|
|
3741
|
+
});
|
|
3467
3742
|
var FieldsetItemSchema = BaseFieldItemSchema.extend({
|
|
3468
3743
|
type: zod.z.literal("fieldset"),
|
|
3469
3744
|
title: zod.z.string(),
|
|
@@ -3483,6 +3758,53 @@ var RootFieldItemSchema = zod.z.union([
|
|
|
3483
3758
|
FieldsetItemSchema
|
|
3484
3759
|
]);
|
|
3485
3760
|
|
|
3761
|
+
// src/formatters/field.ts
|
|
3762
|
+
function formatInputField(item) {
|
|
3763
|
+
const details = [];
|
|
3764
|
+
const typeInfo = [
|
|
3765
|
+
item.value_type && `Type: ${item.value_type}`,
|
|
3766
|
+
`Required: ${item.is_required ? "Yes" : "No"}`
|
|
3767
|
+
].filter(Boolean).join(" | ");
|
|
3768
|
+
if (typeInfo) details.push({ text: typeInfo, style: "dim" });
|
|
3769
|
+
if (item.description)
|
|
3770
|
+
details.push({ text: item.description, style: "normal" });
|
|
3771
|
+
if (item.default_value)
|
|
3772
|
+
details.push({ text: `Default: ${item.default_value}`, style: "accent" });
|
|
3773
|
+
if (item.placeholder)
|
|
3774
|
+
details.push({ text: `Placeholder: ${item.placeholder}`, style: "dim" });
|
|
3775
|
+
if (item.depends_on && item.depends_on.length > 0) {
|
|
3776
|
+
details.push({
|
|
3777
|
+
text: `Depends on: ${item.depends_on.join(", ")}`,
|
|
3778
|
+
style: "warning"
|
|
3779
|
+
});
|
|
3780
|
+
}
|
|
3781
|
+
if (item.format)
|
|
3782
|
+
details.push({ text: `Format: ${item.format}`, style: "dim" });
|
|
3783
|
+
if (item.items)
|
|
3784
|
+
details.push({ text: `Items type: ${item.items.type}`, style: "dim" });
|
|
3785
|
+
return {
|
|
3786
|
+
title: item.title || item.key,
|
|
3787
|
+
key: item.key,
|
|
3788
|
+
description: item.description,
|
|
3789
|
+
details
|
|
3790
|
+
};
|
|
3791
|
+
}
|
|
3792
|
+
function formatInfoField(item) {
|
|
3793
|
+
return {
|
|
3794
|
+
title: item.title || "Info",
|
|
3795
|
+
key: item.key,
|
|
3796
|
+
description: item.description,
|
|
3797
|
+
details: [{ text: item.description, style: "normal" }]
|
|
3798
|
+
};
|
|
3799
|
+
}
|
|
3800
|
+
var rootFieldItemFormatter = {
|
|
3801
|
+
format: (item) => {
|
|
3802
|
+
if (item.type === "input_field") return formatInputField(item);
|
|
3803
|
+
if (item.type === "info_field") return formatInfoField(item);
|
|
3804
|
+
return { title: item.title || item.key, key: item.key, details: [] };
|
|
3805
|
+
}
|
|
3806
|
+
};
|
|
3807
|
+
|
|
3486
3808
|
// src/services/implementations.ts
|
|
3487
3809
|
async function fetchImplementationNeeds({
|
|
3488
3810
|
api,
|
|
@@ -3648,6 +3970,7 @@ var listActionInputFieldsPlugin = definePlugin(
|
|
|
3648
3970
|
itemType: "RootField",
|
|
3649
3971
|
inputSchema: ListActionInputFieldsInputSchema,
|
|
3650
3972
|
outputSchema: RootFieldItemSchema,
|
|
3973
|
+
formatter: rootFieldItemFormatter,
|
|
3651
3974
|
defaultPageSize: DEFAULT_PAGE_SIZE,
|
|
3652
3975
|
resolvers: {
|
|
3653
3976
|
app: appKeyResolver,
|
|
@@ -3656,10 +3979,7 @@ var listActionInputFieldsPlugin = definePlugin(
|
|
|
3656
3979
|
connection: connectionIdResolver,
|
|
3657
3980
|
inputs: inputsAllOptionalResolver
|
|
3658
3981
|
},
|
|
3659
|
-
handler: async ({
|
|
3660
|
-
sdk: sdk2,
|
|
3661
|
-
options
|
|
3662
|
-
}) => {
|
|
3982
|
+
handler: async ({ sdk: sdk2, options }) => {
|
|
3663
3983
|
const { api, getVersionedImplementationId } = sdk2.context;
|
|
3664
3984
|
const appKey = "app" in options ? options.app : options.appKey;
|
|
3665
3985
|
const actionKey = "action" in options ? options.action : options.actionKey;
|
|
@@ -3707,26 +4027,7 @@ var listActionInputFieldsPlugin = definePlugin(
|
|
|
3707
4027
|
}
|
|
3708
4028
|
})
|
|
3709
4029
|
);
|
|
3710
|
-
var InputFieldChoiceItemSchema =
|
|
3711
|
-
format: (item) => {
|
|
3712
|
-
const title = item.label || item.key || "Choice";
|
|
3713
|
-
const details = [];
|
|
3714
|
-
if (item.label && item.key && item.label !== item.key) {
|
|
3715
|
-
details.push({ text: `Key: ${item.key}`, style: "dim" });
|
|
3716
|
-
}
|
|
3717
|
-
if (item.sample && item.sample !== item.key) {
|
|
3718
|
-
details.push({ text: `Sample: ${item.sample}`, style: "dim" });
|
|
3719
|
-
}
|
|
3720
|
-
if (item.value && item.value !== item.key) {
|
|
3721
|
-
details.push({ text: `Value: ${item.value}`, style: "normal" });
|
|
3722
|
-
}
|
|
3723
|
-
return {
|
|
3724
|
-
title,
|
|
3725
|
-
key: item.key,
|
|
3726
|
-
details
|
|
3727
|
-
};
|
|
3728
|
-
}
|
|
3729
|
-
});
|
|
4030
|
+
var InputFieldChoiceItemSchema = NeedChoicesSchema;
|
|
3730
4031
|
var ListActionInputFieldChoicesDescription = "Get the available choices for a dynamic dropdown input field";
|
|
3731
4032
|
var ListActionInputFieldChoicesBaseSchema = zod.z.object({
|
|
3732
4033
|
connection: ConnectionPropertySchema.optional().describe(
|
|
@@ -3770,6 +4071,24 @@ var ListActionInputFieldChoicesInputSchema = zod.z.union([
|
|
|
3770
4071
|
ListActionInputFieldChoicesSchemaDeprecated
|
|
3771
4072
|
]).describe(ListActionInputFieldChoicesDescription);
|
|
3772
4073
|
|
|
4074
|
+
// src/formatters/inputFieldChoice.ts
|
|
4075
|
+
var inputFieldChoiceItemFormatter = {
|
|
4076
|
+
format: (item) => {
|
|
4077
|
+
const title = item.label || item.key || "Choice";
|
|
4078
|
+
const details = [];
|
|
4079
|
+
if (item.label && item.key && item.label !== item.key) {
|
|
4080
|
+
details.push({ text: `Key: ${item.key}`, style: "dim" });
|
|
4081
|
+
}
|
|
4082
|
+
if (item.sample && item.sample !== item.key) {
|
|
4083
|
+
details.push({ text: `Sample: ${item.sample}`, style: "dim" });
|
|
4084
|
+
}
|
|
4085
|
+
if (item.value && item.value !== item.key) {
|
|
4086
|
+
details.push({ text: `Value: ${item.value}`, style: "normal" });
|
|
4087
|
+
}
|
|
4088
|
+
return { title, key: item.key, details };
|
|
4089
|
+
}
|
|
4090
|
+
};
|
|
4091
|
+
|
|
3773
4092
|
// src/plugins/listActionInputFieldChoices/index.ts
|
|
3774
4093
|
function transformNeedChoicesToInputFieldChoiceItem(choice) {
|
|
3775
4094
|
return {
|
|
@@ -3787,6 +4106,7 @@ var listActionInputFieldChoicesPlugin = definePlugin(
|
|
|
3787
4106
|
itemType: "InputFieldChoice",
|
|
3788
4107
|
inputSchema: ListActionInputFieldChoicesInputSchema,
|
|
3789
4108
|
outputSchema: InputFieldChoiceItemSchema,
|
|
4109
|
+
formatter: inputFieldChoiceItemFormatter,
|
|
3790
4110
|
defaultPageSize: DEFAULT_PAGE_SIZE,
|
|
3791
4111
|
resolvers: {
|
|
3792
4112
|
app: appKeyResolver,
|
|
@@ -3796,10 +4116,7 @@ var listActionInputFieldChoicesPlugin = definePlugin(
|
|
|
3796
4116
|
inputField: inputFieldKeyResolver,
|
|
3797
4117
|
inputs: inputsAllOptionalResolver
|
|
3798
4118
|
},
|
|
3799
|
-
handler: async ({
|
|
3800
|
-
sdk: sdk2,
|
|
3801
|
-
options
|
|
3802
|
-
}) => {
|
|
4119
|
+
handler: async ({ sdk: sdk2, options }) => {
|
|
3803
4120
|
const { api, getVersionedImplementationId } = sdk2.context;
|
|
3804
4121
|
const appKey = "app" in options ? options.app : options.appKey;
|
|
3805
4122
|
const actionKey = "action" in options ? options.action : options.actionKey;
|
|
@@ -4051,7 +4368,10 @@ var ListConnectionsQuerySchema = connections.ListConnectionsQuerySchema.omit({
|
|
|
4051
4368
|
// SDK specific property for pagination/iterable helpers
|
|
4052
4369
|
cursor: zod.z.string().optional().describe("Cursor to start from")
|
|
4053
4370
|
}).describe("List available connections with optional filtering");
|
|
4054
|
-
var ConnectionItemSchema =
|
|
4371
|
+
var ConnectionItemSchema = connections.ConnectionItemSchema;
|
|
4372
|
+
|
|
4373
|
+
// src/formatters/connection.ts
|
|
4374
|
+
var connectionItemFormatter = {
|
|
4055
4375
|
format: (item) => {
|
|
4056
4376
|
const details = [];
|
|
4057
4377
|
if (item.identifier) {
|
|
@@ -4076,17 +4396,19 @@ var ConnectionItemSchema = withFormatter(connections.ConnectionItemSchema, {
|
|
|
4076
4396
|
details
|
|
4077
4397
|
};
|
|
4078
4398
|
}
|
|
4079
|
-
}
|
|
4399
|
+
};
|
|
4080
4400
|
|
|
4081
4401
|
// src/plugins/listConnections/index.ts
|
|
4082
4402
|
var listConnectionsPlugin = definePlugin(
|
|
4083
4403
|
(sdk) => createPaginatedPluginMethod(sdk, {
|
|
4404
|
+
...zapierPagination,
|
|
4084
4405
|
name: "listConnections",
|
|
4085
4406
|
categories: ["connection"],
|
|
4086
4407
|
type: "list",
|
|
4087
4408
|
itemType: "Connection",
|
|
4088
4409
|
inputSchema: ListConnectionsQuerySchema,
|
|
4089
4410
|
outputSchema: ConnectionItemSchema,
|
|
4411
|
+
formatter: connectionItemFormatter,
|
|
4090
4412
|
defaultPageSize: DEFAULT_PAGE_SIZE,
|
|
4091
4413
|
resolvers: { app: appKeyResolver },
|
|
4092
4414
|
handler: async ({ sdk: sdk2, options }) => {
|
|
@@ -4159,8 +4481,7 @@ var listConnectionsPlugin = definePlugin(
|
|
|
4159
4481
|
...response,
|
|
4160
4482
|
data: response.data.map(transformConnectionItem)
|
|
4161
4483
|
};
|
|
4162
|
-
}
|
|
4163
|
-
extractCursor: (response) => extractCursor(response.links)
|
|
4484
|
+
}
|
|
4164
4485
|
})
|
|
4165
4486
|
);
|
|
4166
4487
|
var ListClientCredentialsQuerySchema = clientCredentials.ListClientCredentialsQuerySchema.omit({
|
|
@@ -4174,58 +4495,49 @@ var ListClientCredentialsQuerySchema = clientCredentials.ListClientCredentialsQu
|
|
|
4174
4495
|
// SDK specific property for pagination/iterable helpers
|
|
4175
4496
|
cursor: zod.z.string().optional().describe("Cursor to start from")
|
|
4176
4497
|
}).describe("List client credentials for the authenticated user");
|
|
4177
|
-
var ClientCredentialsItemSchema =
|
|
4178
|
-
|
|
4179
|
-
|
|
4180
|
-
|
|
4181
|
-
|
|
4182
|
-
|
|
4183
|
-
|
|
4184
|
-
|
|
4185
|
-
|
|
4186
|
-
}
|
|
4187
|
-
|
|
4188
|
-
|
|
4189
|
-
details.push({
|
|
4190
|
-
text: `Created: ${new Date(item.created_at).toLocaleDateString()}`,
|
|
4191
|
-
style: "dim"
|
|
4192
|
-
});
|
|
4193
|
-
}
|
|
4194
|
-
return {
|
|
4195
|
-
title: item.name,
|
|
4196
|
-
id: item.client_id,
|
|
4197
|
-
details
|
|
4198
|
-
};
|
|
4498
|
+
var ClientCredentialsItemSchema = clientCredentials.ClientCredentialsItemSchema;
|
|
4499
|
+
var ClientCredentialsCreatedItemSchema = clientCredentials.ClientCredentialsCreatedItemSchema;
|
|
4500
|
+
|
|
4501
|
+
// src/formatters/clientCredentials.ts
|
|
4502
|
+
var clientCredentialsItemFormatter = {
|
|
4503
|
+
format: (item) => {
|
|
4504
|
+
const details = [];
|
|
4505
|
+
if (item.allowed_scopes && item.allowed_scopes.length > 0) {
|
|
4506
|
+
details.push({
|
|
4507
|
+
text: `Scopes: ${item.allowed_scopes.join(", ")}`,
|
|
4508
|
+
style: "accent"
|
|
4509
|
+
});
|
|
4199
4510
|
}
|
|
4200
|
-
|
|
4201
|
-
|
|
4202
|
-
|
|
4203
|
-
|
|
4204
|
-
|
|
4205
|
-
format: (item) => {
|
|
4206
|
-
return {
|
|
4207
|
-
title: item.name,
|
|
4208
|
-
id: item.client_id,
|
|
4209
|
-
details: [
|
|
4210
|
-
{
|
|
4211
|
-
text: `Client Secret: ${item.client_secret}`,
|
|
4212
|
-
style: "accent"
|
|
4213
|
-
}
|
|
4214
|
-
]
|
|
4215
|
-
};
|
|
4511
|
+
if (item.created_at) {
|
|
4512
|
+
details.push({
|
|
4513
|
+
text: `Created: ${new Date(item.created_at).toLocaleDateString()}`,
|
|
4514
|
+
style: "dim"
|
|
4515
|
+
});
|
|
4216
4516
|
}
|
|
4517
|
+
return { title: item.name, id: item.client_id, details };
|
|
4217
4518
|
}
|
|
4218
|
-
|
|
4519
|
+
};
|
|
4520
|
+
var clientCredentialsCreatedItemFormatter = {
|
|
4521
|
+
format: (item) => ({
|
|
4522
|
+
title: item.name,
|
|
4523
|
+
id: item.client_id,
|
|
4524
|
+
details: [
|
|
4525
|
+
{ text: `Client Secret: ${item.client_secret}`, style: "accent" }
|
|
4526
|
+
]
|
|
4527
|
+
})
|
|
4528
|
+
};
|
|
4219
4529
|
|
|
4220
4530
|
// src/plugins/listClientCredentials/index.ts
|
|
4221
4531
|
var listClientCredentialsPlugin = definePlugin(
|
|
4222
4532
|
(sdk) => createPaginatedPluginMethod(sdk, {
|
|
4533
|
+
...zapierPagination,
|
|
4223
4534
|
name: "listClientCredentials",
|
|
4224
4535
|
categories: ["client-credentials"],
|
|
4225
4536
|
type: "list",
|
|
4226
4537
|
itemType: "ClientCredentials",
|
|
4227
4538
|
inputSchema: ListClientCredentialsQuerySchema,
|
|
4228
4539
|
outputSchema: ClientCredentialsItemSchema,
|
|
4540
|
+
formatter: clientCredentialsItemFormatter,
|
|
4229
4541
|
defaultPageSize: DEFAULT_PAGE_SIZE,
|
|
4230
4542
|
handler: async ({
|
|
4231
4543
|
sdk: sdk2,
|
|
@@ -4246,8 +4558,7 @@ var listClientCredentialsPlugin = definePlugin(
|
|
|
4246
4558
|
requiredScopes: ["credentials"]
|
|
4247
4559
|
}
|
|
4248
4560
|
);
|
|
4249
|
-
}
|
|
4250
|
-
extractCursor: (response) => extractCursor(response.links)
|
|
4561
|
+
}
|
|
4251
4562
|
})
|
|
4252
4563
|
);
|
|
4253
4564
|
var CreateClientCredentialsSchema = clientCredentials.CreateClientCredentialsRequestSchema.omit({ allowed_scopes: true }).extend({
|
|
@@ -4265,6 +4576,7 @@ var createClientCredentialsPlugin = definePlugin(
|
|
|
4265
4576
|
itemType: "ClientCredentials",
|
|
4266
4577
|
inputSchema: CreateClientCredentialsSchema,
|
|
4267
4578
|
outputSchema: ClientCredentialsCreatedItemSchema,
|
|
4579
|
+
formatter: clientCredentialsCreatedItemFormatter,
|
|
4268
4580
|
confirm: "create-secret",
|
|
4269
4581
|
resolvers: { name: clientCredentialsNameResolver },
|
|
4270
4582
|
handler: async ({ sdk: sdk2, options }) => {
|
|
@@ -4331,6 +4643,7 @@ var getAppPlugin = definePlugin(
|
|
|
4331
4643
|
itemType: "App",
|
|
4332
4644
|
inputSchema: GetAppInputSchema,
|
|
4333
4645
|
outputSchema: AppItemSchema,
|
|
4646
|
+
formatter: appItemFormatter,
|
|
4334
4647
|
resolvers: { app: appKeyResolver },
|
|
4335
4648
|
handler: async ({ sdk: sdk2, options }) => {
|
|
4336
4649
|
const appKey = "app" in options ? options.app : options.appKey;
|
|
@@ -4364,6 +4677,7 @@ var getActionPlugin = definePlugin(
|
|
|
4364
4677
|
itemType: "Action",
|
|
4365
4678
|
inputSchema: GetActionInputSchema,
|
|
4366
4679
|
outputSchema: ActionItemSchema,
|
|
4680
|
+
formatter: actionItemFormatter,
|
|
4367
4681
|
resolvers: {
|
|
4368
4682
|
app: appKeyResolver,
|
|
4369
4683
|
actionType: actionTypeResolver,
|
|
@@ -4410,6 +4724,7 @@ var getConnectionPlugin = definePlugin(
|
|
|
4410
4724
|
itemType: "Connection",
|
|
4411
4725
|
inputSchema: GetConnectionParamSchema,
|
|
4412
4726
|
outputSchema: ConnectionItemSchema,
|
|
4727
|
+
formatter: connectionItemFormatter,
|
|
4413
4728
|
resolvers: { connection: connectionIdGenericResolver },
|
|
4414
4729
|
handler: async ({ sdk: sdk2, options }) => {
|
|
4415
4730
|
const { api } = sdk2.context;
|
|
@@ -4450,6 +4765,7 @@ var findFirstConnectionPlugin = definePlugin(
|
|
|
4450
4765
|
itemType: "Connection",
|
|
4451
4766
|
inputSchema: FindFirstConnectionSchema,
|
|
4452
4767
|
outputSchema: ConnectionItemSchema,
|
|
4768
|
+
formatter: connectionItemFormatter,
|
|
4453
4769
|
handler: async ({ sdk: sdk2, options = {} }) => {
|
|
4454
4770
|
const connectionsResponse = await sdk2.listConnections({
|
|
4455
4771
|
...options,
|
|
@@ -4485,6 +4801,7 @@ var findUniqueConnectionPlugin = definePlugin(
|
|
|
4485
4801
|
itemType: "Connection",
|
|
4486
4802
|
inputSchema: FindUniqueConnectionSchema,
|
|
4487
4803
|
outputSchema: ConnectionItemSchema,
|
|
4804
|
+
formatter: connectionItemFormatter,
|
|
4488
4805
|
handler: async ({ sdk: sdk2, options = {} }) => {
|
|
4489
4806
|
const connectionsResponse = await sdk2.listConnections({
|
|
4490
4807
|
...options,
|
|
@@ -4542,6 +4859,29 @@ var RunActionSchemaDeprecated = zod.z.object({
|
|
|
4542
4859
|
actionKey: ActionKeyPropertySchema
|
|
4543
4860
|
}).merge(RunActionBaseSchema);
|
|
4544
4861
|
var RunActionInputSchema = zod.z.union([RunActionSchema, RunActionSchemaDeprecated]).describe(RunActionDescription);
|
|
4862
|
+
|
|
4863
|
+
// src/formatters/actionResult.ts
|
|
4864
|
+
function getStringProperty(obj, key) {
|
|
4865
|
+
if (typeof obj === "object" && obj !== null && key in obj) {
|
|
4866
|
+
const value = obj[key];
|
|
4867
|
+
return typeof value === "string" ? value : void 0;
|
|
4868
|
+
}
|
|
4869
|
+
return void 0;
|
|
4870
|
+
}
|
|
4871
|
+
var actionResultItemFormatter = {
|
|
4872
|
+
format: (item) => {
|
|
4873
|
+
const obj = typeof item === "object" && item !== null ? item : {};
|
|
4874
|
+
const title = getStringProperty(obj, "title") || getStringProperty(obj, "name") || getStringProperty(obj, "label") || getStringProperty(obj, "subject") || "Action Result";
|
|
4875
|
+
return {
|
|
4876
|
+
title,
|
|
4877
|
+
id: getStringProperty(obj, "id"),
|
|
4878
|
+
key: getStringProperty(obj, "key"),
|
|
4879
|
+
description: getStringProperty(obj, "description"),
|
|
4880
|
+
data: item,
|
|
4881
|
+
details: []
|
|
4882
|
+
};
|
|
4883
|
+
}
|
|
4884
|
+
};
|
|
4545
4885
|
async function executeAction(actionOptions) {
|
|
4546
4886
|
const {
|
|
4547
4887
|
api,
|
|
@@ -4671,6 +5011,7 @@ var runActionPlugin = definePlugin(
|
|
|
4671
5011
|
itemType: "ActionResult",
|
|
4672
5012
|
inputSchema: RunActionInputSchema,
|
|
4673
5013
|
outputSchema: ActionResultItemSchema,
|
|
5014
|
+
formatter: actionResultItemFormatter,
|
|
4674
5015
|
resolvers: {
|
|
4675
5016
|
app: appKeyResolver,
|
|
4676
5017
|
actionType: actionTypeResolver,
|
|
@@ -4678,10 +5019,7 @@ var runActionPlugin = definePlugin(
|
|
|
4678
5019
|
connection: connectionIdResolver,
|
|
4679
5020
|
inputs: inputsResolver
|
|
4680
5021
|
},
|
|
4681
|
-
handler: async ({
|
|
4682
|
-
sdk: sdk2,
|
|
4683
|
-
options
|
|
4684
|
-
}) => {
|
|
5022
|
+
handler: async ({ sdk: sdk2, options }) => {
|
|
4685
5023
|
const { api } = sdk2.context;
|
|
4686
5024
|
const appKey = "app" in options ? options.app : options.appKey;
|
|
4687
5025
|
const actionKey = "action" in options ? options.action : options.actionKey;
|
|
@@ -4734,7 +5072,9 @@ var runActionPlugin = definePlugin(
|
|
|
4734
5072
|
}
|
|
4735
5073
|
return {
|
|
4736
5074
|
data: result.results || [],
|
|
4737
|
-
|
|
5075
|
+
// Coerce to a string: the API returns a numeric page index, but
|
|
5076
|
+
// `SdkPage.nextCursor` is a string (and the page guard enforces it).
|
|
5077
|
+
nextCursor: result.next_page != null ? String(result.next_page) : void 0
|
|
4738
5078
|
};
|
|
4739
5079
|
}
|
|
4740
5080
|
});
|
|
@@ -4764,26 +5104,19 @@ var RelayRequestSchema = zod.z.object({
|
|
|
4764
5104
|
var RelayFetchSchema = RelayRequestSchema;
|
|
4765
5105
|
|
|
4766
5106
|
// src/utils/logging.ts
|
|
4767
|
-
var
|
|
4768
|
-
function logDeprecation(message) {
|
|
4769
|
-
if (loggedDeprecations.has(message)) return;
|
|
4770
|
-
loggedDeprecations.add(message);
|
|
4771
|
-
console.warn(`[zapier-sdk] Deprecation: ${message}`);
|
|
4772
|
-
}
|
|
4773
|
-
function resetDeprecationWarnings() {
|
|
4774
|
-
loggedDeprecations.clear();
|
|
4775
|
-
}
|
|
5107
|
+
var { logDeprecation: logDeprecation2, resetDeprecationWarnings: resetDeprecationWarnings2 } = createDeprecationLogger("zapier-sdk");
|
|
4776
5108
|
|
|
4777
5109
|
// src/plugins/request/index.ts
|
|
4778
5110
|
var requestPlugin = definePlugin(
|
|
4779
5111
|
(sdk) => createPluginMethod(sdk, {
|
|
4780
5112
|
name: "request",
|
|
4781
5113
|
packages: ["cli", "mcp"],
|
|
4782
|
-
categories: ["http"
|
|
5114
|
+
categories: ["http"],
|
|
5115
|
+
deprecation: { message: "Use fetch() instead." },
|
|
4783
5116
|
returnType: "Response",
|
|
4784
5117
|
inputSchema: RelayRequestSchema,
|
|
4785
5118
|
handler: async ({ sdk: sdk2, options }) => {
|
|
4786
|
-
|
|
5119
|
+
logDeprecation2("request() is deprecated. Use fetch() instead.");
|
|
4787
5120
|
const {
|
|
4788
5121
|
url,
|
|
4789
5122
|
method,
|
|
@@ -5003,7 +5336,7 @@ async function listAppsForSlugsPage({
|
|
|
5003
5336
|
data: implementationsEnvelope.results.map(
|
|
5004
5337
|
normalizeImplementationMetaToAppItem
|
|
5005
5338
|
),
|
|
5006
|
-
nextCursor:
|
|
5339
|
+
nextCursor: implementationsEnvelope.next ? extractCursorFromUrl(implementationsEnvelope.next) : void 0
|
|
5007
5340
|
};
|
|
5008
5341
|
}
|
|
5009
5342
|
function findManifestEntry({
|
|
@@ -5281,36 +5614,36 @@ var manifestPlugin = definePlugin(
|
|
|
5281
5614
|
}
|
|
5282
5615
|
);
|
|
5283
5616
|
var GetProfileSchema = zod.z.object({}).optional().describe("Get current user's profile information");
|
|
5284
|
-
var UserProfileItemSchema =
|
|
5285
|
-
zod.z.
|
|
5286
|
-
|
|
5287
|
-
|
|
5288
|
-
|
|
5289
|
-
|
|
5290
|
-
|
|
5291
|
-
|
|
5292
|
-
|
|
5293
|
-
|
|
5294
|
-
|
|
5295
|
-
|
|
5296
|
-
|
|
5297
|
-
|
|
5298
|
-
|
|
5299
|
-
}
|
|
5300
|
-
|
|
5301
|
-
|
|
5302
|
-
|
|
5303
|
-
|
|
5304
|
-
|
|
5305
|
-
}
|
|
5306
|
-
return {
|
|
5307
|
-
title: item.full_name,
|
|
5308
|
-
id: item.id,
|
|
5309
|
-
details
|
|
5310
|
-
};
|
|
5617
|
+
var UserProfileItemSchema = zod.z.object({
|
|
5618
|
+
id: zod.z.string(),
|
|
5619
|
+
first_name: zod.z.string(),
|
|
5620
|
+
last_name: zod.z.string(),
|
|
5621
|
+
full_name: zod.z.string(),
|
|
5622
|
+
email: zod.z.string(),
|
|
5623
|
+
email_confirmed: zod.z.boolean(),
|
|
5624
|
+
timezone: zod.z.string()
|
|
5625
|
+
});
|
|
5626
|
+
|
|
5627
|
+
// src/formatters/userProfile.ts
|
|
5628
|
+
var userProfileItemFormatter = {
|
|
5629
|
+
format: (item) => {
|
|
5630
|
+
const details = [];
|
|
5631
|
+
if (item.email) {
|
|
5632
|
+
details.push({ text: item.email, style: "dim" });
|
|
5633
|
+
}
|
|
5634
|
+
if (item.timezone) {
|
|
5635
|
+
details.push({
|
|
5636
|
+
text: `Timezone: ${item.timezone}`,
|
|
5637
|
+
style: "accent"
|
|
5638
|
+
});
|
|
5311
5639
|
}
|
|
5640
|
+
return {
|
|
5641
|
+
title: item.full_name,
|
|
5642
|
+
id: item.id,
|
|
5643
|
+
details
|
|
5644
|
+
};
|
|
5312
5645
|
}
|
|
5313
|
-
|
|
5646
|
+
};
|
|
5314
5647
|
|
|
5315
5648
|
// src/plugins/getProfile/index.ts
|
|
5316
5649
|
var getProfilePlugin = definePlugin(
|
|
@@ -5321,6 +5654,7 @@ var getProfilePlugin = definePlugin(
|
|
|
5321
5654
|
itemType: "Profile",
|
|
5322
5655
|
inputSchema: GetProfileSchema,
|
|
5323
5656
|
outputSchema: UserProfileItemSchema,
|
|
5657
|
+
formatter: userProfileItemFormatter,
|
|
5324
5658
|
handler: async ({ sdk: sdk2 }) => {
|
|
5325
5659
|
const profile = await sdk2.context.api.get(
|
|
5326
5660
|
"/zapier/api/v4/profile/",
|
|
@@ -5417,7 +5751,7 @@ function createDebugLogger(enabled) {
|
|
|
5417
5751
|
}
|
|
5418
5752
|
return (message, data) => {
|
|
5419
5753
|
if (data === void 0 || data === "") {
|
|
5420
|
-
console.
|
|
5754
|
+
console.error(`[Zapier SDK] ${message}`);
|
|
5421
5755
|
return;
|
|
5422
5756
|
}
|
|
5423
5757
|
if (utilModule) {
|
|
@@ -5426,9 +5760,9 @@ function createDebugLogger(enabled) {
|
|
|
5426
5760
|
depth: null,
|
|
5427
5761
|
breakLength: 80
|
|
5428
5762
|
});
|
|
5429
|
-
console.
|
|
5763
|
+
console.error(`[Zapier SDK] ${message}`, formatted);
|
|
5430
5764
|
} else {
|
|
5431
|
-
console.
|
|
5765
|
+
console.error(`[Zapier SDK] ${message}`, data);
|
|
5432
5766
|
}
|
|
5433
5767
|
};
|
|
5434
5768
|
}
|
|
@@ -5627,7 +5961,8 @@ async function pollUntilComplete(options) {
|
|
|
5627
5961
|
pendingStatus = DEFAULT_PENDING_STATUS,
|
|
5628
5962
|
isPending,
|
|
5629
5963
|
resultExtractor = (response) => response,
|
|
5630
|
-
signal
|
|
5964
|
+
signal,
|
|
5965
|
+
maxPollingIntervalMs
|
|
5631
5966
|
} = options;
|
|
5632
5967
|
if (timeoutMs <= 0) {
|
|
5633
5968
|
throw new ZapierValidationError("Timeout must be greater than 0", {
|
|
@@ -5639,6 +5974,14 @@ async function pollUntilComplete(options) {
|
|
|
5639
5974
|
details: { initialDelay }
|
|
5640
5975
|
});
|
|
5641
5976
|
}
|
|
5977
|
+
if (maxPollingIntervalMs !== void 0 && maxPollingIntervalMs <= 0) {
|
|
5978
|
+
throw new ZapierValidationError(
|
|
5979
|
+
"Max polling interval must be greater than 0",
|
|
5980
|
+
{
|
|
5981
|
+
details: { maxPollingIntervalMs }
|
|
5982
|
+
}
|
|
5983
|
+
);
|
|
5984
|
+
}
|
|
5642
5985
|
if (signal?.aborted) throw makeAbortError();
|
|
5643
5986
|
const startTime = Date.now();
|
|
5644
5987
|
let attempts = 0;
|
|
@@ -5661,7 +6004,8 @@ async function pollUntilComplete(options) {
|
|
|
5661
6004
|
if (attempts > 0) {
|
|
5662
6005
|
const interval = getPollingInterval(elapsedTime);
|
|
5663
6006
|
const waitTime = calculateErrorBackoffMs(interval, errorCount);
|
|
5664
|
-
|
|
6007
|
+
const cappedWaitTime = maxPollingIntervalMs === void 0 ? waitTime : Math.min(waitTime, maxPollingIntervalMs);
|
|
6008
|
+
await sleep(cappedWaitTime, signal);
|
|
5665
6009
|
if (signal?.aborted) throw makeAbortError();
|
|
5666
6010
|
}
|
|
5667
6011
|
attempts++;
|
|
@@ -5944,17 +6288,17 @@ function resolveCredentialsFromEnv(sdkBaseUrl) {
|
|
|
5944
6288
|
}
|
|
5945
6289
|
}
|
|
5946
6290
|
if (globalThis.process?.env?.ZAPIER_TOKEN) {
|
|
5947
|
-
|
|
6291
|
+
logDeprecation2(
|
|
5948
6292
|
"ZAPIER_TOKEN is deprecated. Use ZAPIER_CREDENTIALS instead."
|
|
5949
6293
|
);
|
|
5950
6294
|
return globalThis.process?.env?.ZAPIER_TOKEN;
|
|
5951
6295
|
}
|
|
5952
6296
|
if (globalThis.process?.env?.ZAPIER_AUTH_CLIENT_ID) {
|
|
5953
|
-
|
|
6297
|
+
logDeprecation2(
|
|
5954
6298
|
"ZAPIER_AUTH_CLIENT_ID is deprecated. Use ZAPIER_CREDENTIALS_CLIENT_ID instead."
|
|
5955
6299
|
);
|
|
5956
6300
|
if (globalThis.process?.env?.ZAPIER_AUTH_BASE_URL) {
|
|
5957
|
-
|
|
6301
|
+
logDeprecation2(
|
|
5958
6302
|
"ZAPIER_AUTH_BASE_URL is deprecated. Use ZAPIER_CREDENTIALS_BASE_URL instead."
|
|
5959
6303
|
);
|
|
5960
6304
|
}
|
|
@@ -5988,7 +6332,7 @@ async function resolveCredentials(options = {}) {
|
|
|
5988
6332
|
return options.credentials;
|
|
5989
6333
|
}
|
|
5990
6334
|
if (options.token !== void 0) {
|
|
5991
|
-
|
|
6335
|
+
logDeprecation2(
|
|
5992
6336
|
"The `token` option is deprecated. Use `credentials` instead."
|
|
5993
6337
|
);
|
|
5994
6338
|
return options.token;
|
|
@@ -6230,7 +6574,7 @@ async function tryStoredClientCredentialToken(options) {
|
|
|
6230
6574
|
const cached = await readCachedToken(cacheKey, cache);
|
|
6231
6575
|
if (cached !== void 0) {
|
|
6232
6576
|
if (options.debug)
|
|
6233
|
-
console.
|
|
6577
|
+
console.error(
|
|
6234
6578
|
`[auth] Using cached token (clientId: ${activeCredential.clientId})`
|
|
6235
6579
|
);
|
|
6236
6580
|
emitAuthResolved(options.onEvent, "client_credentials");
|
|
@@ -6249,7 +6593,7 @@ async function tryStoredClientCredentialToken(options) {
|
|
|
6249
6593
|
);
|
|
6250
6594
|
}
|
|
6251
6595
|
if (options.debug)
|
|
6252
|
-
console.
|
|
6596
|
+
console.error(
|
|
6253
6597
|
`[auth] Using stored client credential (clientId: ${storedCredential.clientId})`
|
|
6254
6598
|
);
|
|
6255
6599
|
const token = await resolveAuthTokenFromCredentials(
|
|
@@ -6271,7 +6615,7 @@ async function resolveAuthToken(options = {}) {
|
|
|
6271
6615
|
const storedToken = await tryStoredClientCredentialToken(options);
|
|
6272
6616
|
if (storedToken !== void 0) return storedToken;
|
|
6273
6617
|
if (options.debug) {
|
|
6274
|
-
console.
|
|
6618
|
+
console.error("[auth] Using JWT (no stored client credential found)");
|
|
6275
6619
|
}
|
|
6276
6620
|
const jwtToken = await getTokenFromCliLogin({
|
|
6277
6621
|
onEvent: options.onEvent,
|
|
@@ -6301,7 +6645,7 @@ async function resolveAuthTokenFromCredentials(credentials, options) {
|
|
|
6301
6645
|
const cached = await readCachedToken(cacheKey, cache);
|
|
6302
6646
|
if (cached !== void 0) {
|
|
6303
6647
|
if (options.debug) {
|
|
6304
|
-
console.
|
|
6648
|
+
console.error(`[auth] Using cached token (clientId: ${clientId})`);
|
|
6305
6649
|
}
|
|
6306
6650
|
return cached;
|
|
6307
6651
|
}
|
|
@@ -6311,7 +6655,7 @@ async function resolveAuthTokenFromCredentials(credentials, options) {
|
|
|
6311
6655
|
const recheck = await readCachedToken(cacheKey, cache);
|
|
6312
6656
|
if (recheck !== void 0) {
|
|
6313
6657
|
if (options.debug) {
|
|
6314
|
-
console.
|
|
6658
|
+
console.error(
|
|
6315
6659
|
`[auth] Using cached token (clientId: ${clientId}, locked recheck)`
|
|
6316
6660
|
);
|
|
6317
6661
|
}
|
|
@@ -6374,7 +6718,7 @@ async function invalidateCredentialsToken(options) {
|
|
|
6374
6718
|
}
|
|
6375
6719
|
|
|
6376
6720
|
// src/sdk-version.ts
|
|
6377
|
-
var SDK_VERSION = (typeof process !== "undefined" && process.env ? "0.
|
|
6721
|
+
var SDK_VERSION = (typeof process !== "undefined" && process.env ? "0.67.0" : void 0) || "unknown";
|
|
6378
6722
|
|
|
6379
6723
|
// src/utils/open-url.ts
|
|
6380
6724
|
var nodePrefix = "node:";
|
|
@@ -6459,6 +6803,7 @@ var PollApprovalResponseSchema = zod.z.object({
|
|
|
6459
6803
|
status: ApprovalStatusSchema,
|
|
6460
6804
|
approval_id: zod.z.string()
|
|
6461
6805
|
});
|
|
6806
|
+
var APPROVAL_MAX_POLLING_INTERVAL_MS = 5e3;
|
|
6462
6807
|
function parseRateLimitHeaders(response) {
|
|
6463
6808
|
const info = {};
|
|
6464
6809
|
const retryAfter = response.headers.get("retry-after");
|
|
@@ -7167,6 +7512,7 @@ var ZapierApiClient = class {
|
|
|
7167
7512
|
})
|
|
7168
7513
|
),
|
|
7169
7514
|
timeoutMs,
|
|
7515
|
+
maxPollingIntervalMs: APPROVAL_MAX_POLLING_INTERVAL_MS,
|
|
7170
7516
|
isPending: (body2) => {
|
|
7171
7517
|
const parsed = PollApprovalResponseSchema.safeParse(body2);
|
|
7172
7518
|
return parsed.success && parsed.data.status === "pending_approval";
|
|
@@ -7534,6 +7880,7 @@ var tablesDefaults = {
|
|
|
7534
7880
|
var listTablesPlugin = definePlugin(
|
|
7535
7881
|
(sdk) => createPaginatedPluginMethod(sdk, {
|
|
7536
7882
|
...tablesDefaults,
|
|
7883
|
+
...zapierPagination,
|
|
7537
7884
|
name: "listTables",
|
|
7538
7885
|
type: "list",
|
|
7539
7886
|
itemType: "Table",
|
|
@@ -7589,8 +7936,7 @@ var listTablesPlugin = definePlugin(
|
|
|
7589
7936
|
data: response.data.map(transformTableItem),
|
|
7590
7937
|
links: response.links
|
|
7591
7938
|
};
|
|
7592
|
-
}
|
|
7593
|
-
extractCursor: (response) => extractCursor(response.links)
|
|
7939
|
+
}
|
|
7594
7940
|
})
|
|
7595
7941
|
);
|
|
7596
7942
|
var GetTableApiResponseSchema = zod.z.object({
|
|
@@ -7693,6 +8039,15 @@ var deleteTablePlugin = definePlugin(
|
|
|
7693
8039
|
})
|
|
7694
8040
|
);
|
|
7695
8041
|
|
|
8042
|
+
// src/formatters/tableField.ts
|
|
8043
|
+
var tableFieldItemFormatter = {
|
|
8044
|
+
format: (item) => ({
|
|
8045
|
+
title: item.name,
|
|
8046
|
+
id: item.id,
|
|
8047
|
+
details: [{ text: `Type: ${item.type}`, style: "dim" }]
|
|
8048
|
+
})
|
|
8049
|
+
};
|
|
8050
|
+
|
|
7696
8051
|
// src/plugins/tables/listTableFields/index.ts
|
|
7697
8052
|
var listTableFieldsPlugin = definePlugin(
|
|
7698
8053
|
(sdk) => createPluginMethod(sdk, {
|
|
@@ -7702,6 +8057,7 @@ var listTableFieldsPlugin = definePlugin(
|
|
|
7702
8057
|
itemType: "Field",
|
|
7703
8058
|
inputSchema: ListTableFieldsOptionsInputSchema,
|
|
7704
8059
|
outputSchema: FieldItemSchema,
|
|
8060
|
+
formatter: tableFieldItemFormatter,
|
|
7705
8061
|
resolvers: { table: tableIdResolver },
|
|
7706
8062
|
handler: async ({ sdk: sdk2, options }) => {
|
|
7707
8063
|
const { api } = sdk2.context;
|
|
@@ -7774,6 +8130,7 @@ var createTableFieldsPlugin = definePlugin(
|
|
|
7774
8130
|
returnType: "FieldItem[]",
|
|
7775
8131
|
inputSchema: CreateTableFieldsOptionsInputSchema,
|
|
7776
8132
|
outputSchema: FieldItemSchema,
|
|
8133
|
+
formatter: tableFieldItemFormatter,
|
|
7777
8134
|
resolvers: { table: tableIdResolver, fields: tableFieldsResolver },
|
|
7778
8135
|
handler: async ({ sdk: sdk2, options }) => {
|
|
7779
8136
|
const tableId = "table" in options ? options.table : options.tableId;
|
|
@@ -7852,21 +8209,13 @@ var RecordApiItemSchema = zod.z.object({
|
|
|
7852
8209
|
is_source_record: zod.z.boolean().nullable().optional(),
|
|
7853
8210
|
deleted_at: zod.z.string().nullable().optional()
|
|
7854
8211
|
});
|
|
7855
|
-
var
|
|
8212
|
+
var RecordItemSchema = zod.z.object({
|
|
7856
8213
|
id: zod.z.string(),
|
|
7857
8214
|
data: zod.z.record(zod.z.string(), zod.z.unknown()),
|
|
7858
8215
|
created_at: zod.z.string(),
|
|
7859
8216
|
edited_at: zod.z.string(),
|
|
7860
8217
|
deleted_at: zod.z.string().nullable().optional()
|
|
7861
8218
|
});
|
|
7862
|
-
var RecordItemSchema = withFormatter(RecordItemSchemaBase, {
|
|
7863
|
-
format: (item) => ({
|
|
7864
|
-
title: `Record ${item.id}`,
|
|
7865
|
-
id: item.id,
|
|
7866
|
-
data: item.data,
|
|
7867
|
-
details: []
|
|
7868
|
-
})
|
|
7869
|
-
});
|
|
7870
8219
|
var GetTableRecordApiResponseSchema = zod.z.object({
|
|
7871
8220
|
data: RecordApiItemSchema
|
|
7872
8221
|
});
|
|
@@ -7890,9 +8239,9 @@ var tableRecordFormatter = {
|
|
|
7890
8239
|
if (context) return context;
|
|
7891
8240
|
const hasFieldIds = Object.keys(item.data).some(isFieldId);
|
|
7892
8241
|
if (!hasFieldIds) return {};
|
|
7893
|
-
const
|
|
7894
|
-
|
|
7895
|
-
});
|
|
8242
|
+
const table = params.table ?? params.tableId;
|
|
8243
|
+
if (!table) return {};
|
|
8244
|
+
const { data: fields } = await sdk.listTableFields({ table });
|
|
7896
8245
|
return Object.fromEntries(fields.map((f) => [f.id, f.name]));
|
|
7897
8246
|
},
|
|
7898
8247
|
format: (item, fieldLabels) => ({
|
|
@@ -8017,10 +8366,7 @@ var listTableRecordsPlugin = definePlugin(
|
|
|
8017
8366
|
sort: tableSortResolver
|
|
8018
8367
|
},
|
|
8019
8368
|
formatter: tableRecordFormatter,
|
|
8020
|
-
handler: async ({
|
|
8021
|
-
sdk: sdk2,
|
|
8022
|
-
options
|
|
8023
|
-
}) => {
|
|
8369
|
+
handler: async ({ sdk: sdk2, options }) => {
|
|
8024
8370
|
const { api } = sdk2.context;
|
|
8025
8371
|
const tableId = "table" in options ? options.table : options.tableId;
|
|
8026
8372
|
const translator = await createFieldKeyTranslator({
|
|
@@ -8270,85 +8616,13 @@ var updateTableRecordsPlugin = definePlugin(
|
|
|
8270
8616
|
}
|
|
8271
8617
|
})
|
|
8272
8618
|
);
|
|
8273
|
-
|
|
8274
|
-
|
|
8275
|
-
|
|
8276
|
-
|
|
8277
|
-
|
|
8278
|
-
|
|
8279
|
-
|
|
8280
|
-
account: { title: "Account" },
|
|
8281
|
-
app: { title: "App", titlePlural: "Apps" },
|
|
8282
|
-
connection: { title: "Connection" },
|
|
8283
|
-
action: { title: "Action" },
|
|
8284
|
-
"client-credentials": {
|
|
8285
|
-
title: "Client Credentials",
|
|
8286
|
-
titlePlural: "Client Credentials"
|
|
8287
|
-
},
|
|
8288
|
-
table: { title: "Table" },
|
|
8289
|
-
trigger: { title: "Trigger" },
|
|
8290
|
-
"code-workflow": {
|
|
8291
|
-
title: "Code Workflow",
|
|
8292
|
-
titlePlural: "Code Workflows"
|
|
8293
|
-
},
|
|
8294
|
-
http: { title: "HTTP Request" },
|
|
8295
|
-
utility: { title: "Utility", titlePlural: "Utilities" },
|
|
8296
|
-
other: { title: "Other" }
|
|
8297
|
-
};
|
|
8298
|
-
var knownCategories = Object.keys(categoryDefinitions);
|
|
8299
|
-
function buildRegistry({
|
|
8300
|
-
sdk,
|
|
8301
|
-
meta,
|
|
8302
|
-
packageFilter
|
|
8303
|
-
}) {
|
|
8304
|
-
const functions = Object.keys(meta).filter((key) => {
|
|
8305
|
-
const property = sdk[key];
|
|
8306
|
-
if (typeof property === "function") return true;
|
|
8307
|
-
const [rootKey] = key.split(".");
|
|
8308
|
-
const rootProperty = sdk[rootKey];
|
|
8309
|
-
return typeof rootProperty === "object" && rootProperty !== null;
|
|
8310
|
-
}).map((key) => {
|
|
8311
|
-
const m = meta[key];
|
|
8312
|
-
return {
|
|
8313
|
-
name: key,
|
|
8314
|
-
description: m.description,
|
|
8315
|
-
type: m.type,
|
|
8316
|
-
itemType: m.itemType,
|
|
8317
|
-
returnType: m.returnType,
|
|
8318
|
-
inputSchema: canonicalInputSchema(m.inputSchema),
|
|
8319
|
-
inputParameters: m.inputParameters,
|
|
8320
|
-
outputSchema: m.outputSchema,
|
|
8321
|
-
categories: m.categories || [],
|
|
8322
|
-
resolvers: m.resolvers,
|
|
8323
|
-
formatter: m.formatter,
|
|
8324
|
-
experimental: m.experimental,
|
|
8325
|
-
packages: m.packages,
|
|
8326
|
-
confirm: m.confirm ?? (m.type === "delete" ? "delete" : void 0),
|
|
8327
|
-
deprecation: m.deprecation,
|
|
8328
|
-
aliases: m.aliases,
|
|
8329
|
-
supportsJsonOutput: m.supportsJsonOutput ?? true
|
|
8330
|
-
};
|
|
8331
|
-
}).sort((a, b) => a.name.localeCompare(b.name));
|
|
8332
|
-
const filteredFunctions = packageFilter ? functions.filter((f) => !f.packages || f.packages.includes(packageFilter)) : functions;
|
|
8333
|
-
const filteredCategories = knownCategories.slice().sort((a, b) => {
|
|
8334
|
-
if (a === "other") return 1;
|
|
8335
|
-
if (b === "other") return -1;
|
|
8336
|
-
return categoryDefinitions[a].title.localeCompare(
|
|
8337
|
-
categoryDefinitions[b].title
|
|
8338
|
-
);
|
|
8339
|
-
}).map((categoryKey) => {
|
|
8340
|
-
const categoryFunctions = filteredFunctions.filter(
|
|
8341
|
-
(f) => f.categories.includes(categoryKey) || categoryKey === "other" && !f.categories.some((c) => knownCategories.includes(c))
|
|
8342
|
-
).map((f) => f.name).sort();
|
|
8343
|
-
const definition = categoryDefinitions[categoryKey];
|
|
8344
|
-
return {
|
|
8345
|
-
key: categoryKey,
|
|
8346
|
-
title: definition.title,
|
|
8347
|
-
titlePlural: definition.titlePlural ?? `${definition.title}s`,
|
|
8348
|
-
functions: categoryFunctions
|
|
8349
|
-
};
|
|
8350
|
-
}).filter((category) => category.functions.length > 0);
|
|
8351
|
-
return { functions: filteredFunctions, categories: filteredCategories };
|
|
8619
|
+
|
|
8620
|
+
// src/core-stack.ts
|
|
8621
|
+
var zapierCorePlugin = createCorePlugin({
|
|
8622
|
+
adaptError: zapierAdaptError
|
|
8623
|
+
});
|
|
8624
|
+
function createZapierCoreStack() {
|
|
8625
|
+
return createPluginStack().use(zapierCorePlugin);
|
|
8352
8626
|
}
|
|
8353
8627
|
|
|
8354
8628
|
// src/plugins/deprecated/authentications.ts
|
|
@@ -8359,11 +8633,13 @@ var listAuthenticationsPlugin = definePlugin(
|
|
|
8359
8633
|
meta: {
|
|
8360
8634
|
listAuthentications: {
|
|
8361
8635
|
packages: ["cli", "mcp"],
|
|
8362
|
-
categories: ["connection"
|
|
8636
|
+
categories: ["connection"],
|
|
8637
|
+
deprecation: { message: "Use listConnections instead." },
|
|
8363
8638
|
type: "list",
|
|
8364
8639
|
itemType: "Connection",
|
|
8365
8640
|
inputSchema: ListConnectionsQuerySchema,
|
|
8366
|
-
outputSchema: ConnectionItemSchema
|
|
8641
|
+
outputSchema: ConnectionItemSchema,
|
|
8642
|
+
formatter: connectionItemFormatter
|
|
8367
8643
|
}
|
|
8368
8644
|
}
|
|
8369
8645
|
}
|
|
@@ -8376,11 +8652,13 @@ var getAuthenticationPlugin = definePlugin(
|
|
|
8376
8652
|
meta: {
|
|
8377
8653
|
getAuthentication: {
|
|
8378
8654
|
packages: ["cli", "mcp"],
|
|
8379
|
-
categories: ["connection"
|
|
8655
|
+
categories: ["connection"],
|
|
8656
|
+
deprecation: { message: "Use getConnection instead." },
|
|
8380
8657
|
type: "item",
|
|
8381
8658
|
itemType: "Connection",
|
|
8382
8659
|
inputSchema: GetConnectionParamSchema,
|
|
8383
|
-
outputSchema: ConnectionItemSchema
|
|
8660
|
+
outputSchema: ConnectionItemSchema,
|
|
8661
|
+
formatter: connectionItemFormatter
|
|
8384
8662
|
}
|
|
8385
8663
|
}
|
|
8386
8664
|
}
|
|
@@ -8393,11 +8671,13 @@ var findFirstAuthenticationPlugin = definePlugin(
|
|
|
8393
8671
|
meta: {
|
|
8394
8672
|
findFirstAuthentication: {
|
|
8395
8673
|
packages: ["cli", "mcp"],
|
|
8396
|
-
categories: ["connection"
|
|
8674
|
+
categories: ["connection"],
|
|
8675
|
+
deprecation: { message: "Use findFirstConnection instead." },
|
|
8397
8676
|
type: "item",
|
|
8398
8677
|
itemType: "Connection",
|
|
8399
8678
|
inputSchema: FindFirstConnectionSchema,
|
|
8400
|
-
outputSchema: ConnectionItemSchema
|
|
8679
|
+
outputSchema: ConnectionItemSchema,
|
|
8680
|
+
formatter: connectionItemFormatter
|
|
8401
8681
|
}
|
|
8402
8682
|
}
|
|
8403
8683
|
}
|
|
@@ -8410,11 +8690,13 @@ var findUniqueAuthenticationPlugin = definePlugin(
|
|
|
8410
8690
|
meta: {
|
|
8411
8691
|
findUniqueAuthentication: {
|
|
8412
8692
|
packages: ["cli", "mcp"],
|
|
8413
|
-
categories: ["connection"
|
|
8693
|
+
categories: ["connection"],
|
|
8694
|
+
deprecation: { message: "Use findUniqueConnection instead." },
|
|
8414
8695
|
type: "item",
|
|
8415
8696
|
itemType: "Connection",
|
|
8416
8697
|
inputSchema: FindUniqueConnectionSchema,
|
|
8417
|
-
outputSchema: ConnectionItemSchema
|
|
8698
|
+
outputSchema: ConnectionItemSchema,
|
|
8699
|
+
formatter: connectionItemFormatter
|
|
8418
8700
|
}
|
|
8419
8701
|
}
|
|
8420
8702
|
}
|
|
@@ -8428,11 +8710,13 @@ var listInputFieldsDeprecatedPlugin = definePlugin(
|
|
|
8428
8710
|
context: {
|
|
8429
8711
|
meta: {
|
|
8430
8712
|
listInputFields: {
|
|
8431
|
-
categories: ["action"
|
|
8713
|
+
categories: ["action"],
|
|
8714
|
+
deprecation: { message: "Use listActionInputFields instead." },
|
|
8432
8715
|
type: "list",
|
|
8433
8716
|
itemType: "RootField",
|
|
8434
8717
|
inputSchema: ListActionInputFieldsInputSchema,
|
|
8435
8718
|
outputSchema: RootFieldItemSchema,
|
|
8719
|
+
formatter: rootFieldItemFormatter,
|
|
8436
8720
|
defaultPageSize: DEFAULT_PAGE_SIZE
|
|
8437
8721
|
}
|
|
8438
8722
|
}
|
|
@@ -8445,11 +8729,15 @@ var listInputFieldChoicesDeprecatedPlugin = definePlugin(
|
|
|
8445
8729
|
context: {
|
|
8446
8730
|
meta: {
|
|
8447
8731
|
listInputFieldChoices: {
|
|
8448
|
-
categories: ["action"
|
|
8732
|
+
categories: ["action"],
|
|
8733
|
+
deprecation: {
|
|
8734
|
+
message: "Use listActionInputFieldChoices instead."
|
|
8735
|
+
},
|
|
8449
8736
|
type: "list",
|
|
8450
8737
|
itemType: "InputFieldChoiceItem",
|
|
8451
8738
|
inputSchema: ListActionInputFieldChoicesInputSchema,
|
|
8452
8739
|
outputSchema: InputFieldChoiceItemSchema,
|
|
8740
|
+
formatter: inputFieldChoiceItemFormatter,
|
|
8453
8741
|
defaultPageSize: DEFAULT_PAGE_SIZE
|
|
8454
8742
|
}
|
|
8455
8743
|
}
|
|
@@ -8462,7 +8750,8 @@ var getInputFieldsSchemaDeprecatedPlugin = definePlugin(
|
|
|
8462
8750
|
context: {
|
|
8463
8751
|
meta: {
|
|
8464
8752
|
getInputFieldsSchema: {
|
|
8465
|
-
categories: ["action"
|
|
8753
|
+
categories: ["action"],
|
|
8754
|
+
deprecation: { message: "Use getActionInputFieldsSchema instead." },
|
|
8466
8755
|
type: "function",
|
|
8467
8756
|
inputSchema: GetActionInputFieldsSchemaInputSchema
|
|
8468
8757
|
}
|
|
@@ -8526,7 +8815,7 @@ function createConsoleTransport() {
|
|
|
8526
8815
|
return {
|
|
8527
8816
|
async emit(subject, event) {
|
|
8528
8817
|
try {
|
|
8529
|
-
console.
|
|
8818
|
+
console.error(
|
|
8530
8819
|
"[SDK Telemetry]",
|
|
8531
8820
|
JSON.stringify({ subject, properties: event }, null, 2)
|
|
8532
8821
|
);
|
|
@@ -8735,6 +9024,35 @@ function buildMethodCalledEvent(data, context = {}) {
|
|
|
8735
9024
|
};
|
|
8736
9025
|
}
|
|
8737
9026
|
|
|
9027
|
+
// src/plugins/eventEmission/event-emission-hook.ts
|
|
9028
|
+
function computeArgumentCount(args) {
|
|
9029
|
+
if (args.length === 1) {
|
|
9030
|
+
const arg0 = args[0];
|
|
9031
|
+
if (arg0 !== null && typeof arg0 === "object" && !Array.isArray(arg0) && Object.getPrototypeOf(arg0) === Object.prototype) {
|
|
9032
|
+
return Object.keys(arg0).length;
|
|
9033
|
+
}
|
|
9034
|
+
}
|
|
9035
|
+
return args.filter((a) => a !== void 0).length;
|
|
9036
|
+
}
|
|
9037
|
+
function makeMethodEndHook(emitMethodCalled) {
|
|
9038
|
+
return ({ methodName, args, isPaginated, depth, durationMs, error }) => {
|
|
9039
|
+
if (depth > 0) return;
|
|
9040
|
+
const metadata = getMethodMetadata();
|
|
9041
|
+
emitMethodCalled({
|
|
9042
|
+
method_name: methodName,
|
|
9043
|
+
execution_duration_ms: durationMs,
|
|
9044
|
+
success_flag: !error,
|
|
9045
|
+
error_message: error?.message ?? null,
|
|
9046
|
+
error_type: error?.constructor.name ?? null,
|
|
9047
|
+
argument_count: computeArgumentCount(args),
|
|
9048
|
+
is_paginated: isPaginated,
|
|
9049
|
+
selected_api: metadata?.selectedApi ?? null,
|
|
9050
|
+
operation_type: metadata?.operationType ?? null,
|
|
9051
|
+
operation_key: metadata?.operationKey ?? null
|
|
9052
|
+
});
|
|
9053
|
+
};
|
|
9054
|
+
}
|
|
9055
|
+
|
|
8738
9056
|
// src/plugins/eventEmission/index.ts
|
|
8739
9057
|
var TELEMETRY_EMIT_TIMEOUT_MS = 300;
|
|
8740
9058
|
var registeredListeners = {};
|
|
@@ -8865,6 +9183,8 @@ var eventEmissionPlugin = definePlugin(
|
|
|
8865
9183
|
}
|
|
8866
9184
|
}
|
|
8867
9185
|
if (!config.enabled) {
|
|
9186
|
+
const noopEmitMethodCalled = () => {
|
|
9187
|
+
};
|
|
8868
9188
|
return {
|
|
8869
9189
|
context: {
|
|
8870
9190
|
eventEmission: {
|
|
@@ -8882,12 +9202,13 @@ var eventEmissionPlugin = definePlugin(
|
|
|
8882
9202
|
visitor_id: null,
|
|
8883
9203
|
correlation_id: null
|
|
8884
9204
|
}),
|
|
8885
|
-
emitMethodCalled: () => {
|
|
8886
|
-
},
|
|
8887
9205
|
flush: async () => {
|
|
8888
9206
|
},
|
|
8889
9207
|
close: async () => {
|
|
8890
9208
|
}
|
|
9209
|
+
},
|
|
9210
|
+
hooks: {
|
|
9211
|
+
onMethodEnd: makeMethodEndHook(noopEmitMethodCalled)
|
|
8891
9212
|
}
|
|
8892
9213
|
}
|
|
8893
9214
|
};
|
|
@@ -9058,6 +9379,20 @@ var eventEmissionPlugin = definePlugin(
|
|
|
9058
9379
|
);
|
|
9059
9380
|
removeExistingListeners();
|
|
9060
9381
|
};
|
|
9382
|
+
const emitMethodCalled = (data) => {
|
|
9383
|
+
const event = {
|
|
9384
|
+
...buildMethodCalledEvent(data),
|
|
9385
|
+
call_context: config.callContext ?? "sdk"
|
|
9386
|
+
};
|
|
9387
|
+
trackEmission(
|
|
9388
|
+
silentEmit(
|
|
9389
|
+
transport,
|
|
9390
|
+
METHOD_CALLED_EVENT_SUBJECT,
|
|
9391
|
+
event,
|
|
9392
|
+
getUserContext
|
|
9393
|
+
)
|
|
9394
|
+
);
|
|
9395
|
+
};
|
|
9061
9396
|
return {
|
|
9062
9397
|
context: {
|
|
9063
9398
|
eventEmission: {
|
|
@@ -9069,22 +9404,11 @@ var eventEmissionPlugin = definePlugin(
|
|
|
9069
9404
|
);
|
|
9070
9405
|
},
|
|
9071
9406
|
createBaseEvent: createBaseEventHelper,
|
|
9072
|
-
emitMethodCalled: (data) => {
|
|
9073
|
-
const event = {
|
|
9074
|
-
...buildMethodCalledEvent(data),
|
|
9075
|
-
call_context: config.callContext ?? "sdk"
|
|
9076
|
-
};
|
|
9077
|
-
trackEmission(
|
|
9078
|
-
silentEmit(
|
|
9079
|
-
transport,
|
|
9080
|
-
METHOD_CALLED_EVENT_SUBJECT,
|
|
9081
|
-
event,
|
|
9082
|
-
getUserContext
|
|
9083
|
-
)
|
|
9084
|
-
);
|
|
9085
|
-
},
|
|
9086
9407
|
flush,
|
|
9087
9408
|
close
|
|
9409
|
+
},
|
|
9410
|
+
hooks: {
|
|
9411
|
+
onMethodEnd: makeMethodEndHook(emitMethodCalled)
|
|
9088
9412
|
}
|
|
9089
9413
|
}
|
|
9090
9414
|
};
|
|
@@ -9096,78 +9420,22 @@ function createOptionsPlugin(options) {
|
|
|
9096
9420
|
return () => ({ context: { options } });
|
|
9097
9421
|
}
|
|
9098
9422
|
function createSdk() {
|
|
9099
|
-
|
|
9100
|
-
|
|
9101
|
-
|
|
9102
|
-
|
|
9103
|
-
const registryCache = /* @__PURE__ */ new Map();
|
|
9104
|
-
const sdk = {
|
|
9105
|
-
...properties,
|
|
9106
|
-
get context() {
|
|
9107
|
-
return frozenContext;
|
|
9108
|
-
},
|
|
9109
|
-
getContext: () => frozenContext,
|
|
9110
|
-
// runtime compat shim, not in types
|
|
9111
|
-
getRegistry(options) {
|
|
9112
|
-
const cacheKey = options?.package ?? "__all__";
|
|
9113
|
-
if (!registryCache.has(cacheKey)) {
|
|
9114
|
-
registryCache.set(
|
|
9115
|
-
cacheKey,
|
|
9116
|
-
buildRegistry({
|
|
9117
|
-
sdk,
|
|
9118
|
-
meta: frozenContext.meta,
|
|
9119
|
-
packageFilter: options?.package
|
|
9120
|
-
})
|
|
9121
|
-
);
|
|
9122
|
-
}
|
|
9123
|
-
return registryCache.get(cacheKey);
|
|
9124
|
-
},
|
|
9125
|
-
addPlugin(plugin, options) {
|
|
9126
|
-
const pluginResult = plugin({
|
|
9127
|
-
...properties,
|
|
9128
|
-
context: frozenContext
|
|
9129
|
-
});
|
|
9130
|
-
const { context: pluginContext, ...pluginProperties } = pluginResult;
|
|
9131
|
-
const { meta: pluginMeta, ...pluginContextRest } = pluginContext ?? {};
|
|
9132
|
-
const existingProperties = properties;
|
|
9133
|
-
const existingContext = context;
|
|
9134
|
-
const existingMeta = context.meta ?? {};
|
|
9135
|
-
const collisions = [];
|
|
9136
|
-
for (const key of Object.keys(pluginProperties)) {
|
|
9137
|
-
if (key in existingProperties) collisions.push(`method "${key}"`);
|
|
9138
|
-
}
|
|
9139
|
-
for (const key of Object.keys(pluginContextRest)) {
|
|
9140
|
-
if (key in existingContext) collisions.push(`context.${key}`);
|
|
9141
|
-
}
|
|
9142
|
-
if (collisions.length > 0 && !options?.override) {
|
|
9143
|
-
const name = plugin.name || "anonymous plugin";
|
|
9144
|
-
console.warn(
|
|
9145
|
-
`[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.`
|
|
9146
|
-
);
|
|
9147
|
-
return buildSdk(properties, context);
|
|
9148
|
-
}
|
|
9149
|
-
const mergedProperties = { ...properties, ...pluginProperties };
|
|
9150
|
-
const mergedContext = {
|
|
9151
|
-
...context,
|
|
9152
|
-
...pluginContextRest,
|
|
9153
|
-
meta: { ...existingMeta, ...pluginMeta ?? {} }
|
|
9154
|
-
};
|
|
9155
|
-
return buildSdk(
|
|
9156
|
-
mergedProperties,
|
|
9157
|
-
mergedContext
|
|
9158
|
-
);
|
|
9159
|
-
}
|
|
9160
|
-
};
|
|
9161
|
-
return sdk;
|
|
9423
|
+
logDeprecation2(
|
|
9424
|
+
"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."
|
|
9425
|
+
);
|
|
9426
|
+
return withDeprecatedAddPlugin(createZapierCoreStack().toSdk());
|
|
9162
9427
|
}
|
|
9163
9428
|
function createZapierSdkWithoutRegistry(options = {}) {
|
|
9164
|
-
|
|
9429
|
+
logDeprecation2(
|
|
9165
9430
|
"createZapierSdkWithoutRegistry is deprecated; use createZapierSdk instead. getRegistry is now available on every sdk."
|
|
9166
9431
|
);
|
|
9167
9432
|
return createZapierSdk(options);
|
|
9168
9433
|
}
|
|
9434
|
+
function createZapierSdkStack(options = {}) {
|
|
9435
|
+
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);
|
|
9436
|
+
}
|
|
9169
9437
|
function createZapierSdk(options = {}) {
|
|
9170
|
-
return
|
|
9438
|
+
return withDeprecatedAddPlugin(createZapierSdkStack(options).toSdk());
|
|
9171
9439
|
}
|
|
9172
9440
|
var BaseSdkOptionsSchema = zod.z.object({
|
|
9173
9441
|
credentials: CredentialsSchema.optional().describe(
|
|
@@ -9230,7 +9498,7 @@ var BaseSdkOptionsSchema = zod.z.object({
|
|
|
9230
9498
|
|
|
9231
9499
|
// src/plugins/registry/index.ts
|
|
9232
9500
|
var registryPlugin = definePlugin((_sdk) => {
|
|
9233
|
-
|
|
9501
|
+
logDeprecation2(
|
|
9234
9502
|
"registryPlugin is deprecated and a no-op; getRegistry is now built into every sdk. Remove .addPlugin(registryPlugin)."
|
|
9235
9503
|
);
|
|
9236
9504
|
return {};
|
|
@@ -9247,12 +9515,14 @@ exports.AuthenticationIdPropertySchema = AuthenticationIdPropertySchema;
|
|
|
9247
9515
|
exports.BaseSdkOptionsSchema = BaseSdkOptionsSchema;
|
|
9248
9516
|
exports.CONTEXT_CACHE_MAX_SIZE = CONTEXT_CACHE_MAX_SIZE;
|
|
9249
9517
|
exports.CONTEXT_CACHE_TTL_MS = CONTEXT_CACHE_TTL_MS;
|
|
9518
|
+
exports.CORE_ERROR_SYMBOL = CORE_ERROR_SYMBOL;
|
|
9250
9519
|
exports.ClientCredentialsObjectSchema = ClientCredentialsObjectSchema;
|
|
9251
9520
|
exports.ConnectionEntrySchema = ConnectionEntrySchema;
|
|
9252
9521
|
exports.ConnectionIdPropertySchema = ConnectionIdPropertySchema;
|
|
9253
9522
|
exports.ConnectionPropertySchema = ConnectionPropertySchema;
|
|
9254
9523
|
exports.ConnectionsMapSchema = ConnectionsMapSchema;
|
|
9255
9524
|
exports.ConnectionsPropertySchema = ConnectionsPropertySchema;
|
|
9525
|
+
exports.CoreErrorCode = CoreErrorCode;
|
|
9256
9526
|
exports.CredentialsFunctionSchema = CredentialsFunctionSchema;
|
|
9257
9527
|
exports.CredentialsObjectSchema = CredentialsObjectSchema;
|
|
9258
9528
|
exports.CredentialsSchema = CredentialsSchema;
|
|
@@ -9309,6 +9579,7 @@ exports.ZapierUnknownError = ZapierUnknownError;
|
|
|
9309
9579
|
exports.ZapierValidationError = ZapierValidationError;
|
|
9310
9580
|
exports.actionKeyResolver = actionKeyResolver;
|
|
9311
9581
|
exports.actionTypeResolver = actionTypeResolver;
|
|
9582
|
+
exports.addPlugin = addPlugin;
|
|
9312
9583
|
exports.apiPlugin = apiPlugin;
|
|
9313
9584
|
exports.appKeyResolver = appKeyResolver;
|
|
9314
9585
|
exports.appsPlugin = appsPlugin;
|
|
@@ -9330,17 +9601,21 @@ exports.connectionIdResolver = connectionIdResolver;
|
|
|
9330
9601
|
exports.connectionsPlugin = connectionsPlugin;
|
|
9331
9602
|
exports.createBaseEvent = createBaseEvent;
|
|
9332
9603
|
exports.createClientCredentialsPlugin = createClientCredentialsPlugin;
|
|
9604
|
+
exports.createCorePlugin = createCorePlugin;
|
|
9333
9605
|
exports.createFunction = createFunction;
|
|
9334
9606
|
exports.createMemoryCache = createMemoryCache;
|
|
9335
9607
|
exports.createOptionsPlugin = createOptionsPlugin;
|
|
9336
9608
|
exports.createPaginatedPluginMethod = createPaginatedPluginMethod;
|
|
9337
9609
|
exports.createPluginMethod = createPluginMethod;
|
|
9610
|
+
exports.createPluginStack = createPluginStack;
|
|
9338
9611
|
exports.createSdk = createSdk;
|
|
9339
9612
|
exports.createTableFieldsPlugin = createTableFieldsPlugin;
|
|
9340
9613
|
exports.createTablePlugin = createTablePlugin;
|
|
9341
9614
|
exports.createTableRecordsPlugin = createTableRecordsPlugin;
|
|
9342
9615
|
exports.createZapierApi = createZapierApi;
|
|
9616
|
+
exports.createZapierCoreStack = createZapierCoreStack;
|
|
9343
9617
|
exports.createZapierSdk = createZapierSdk;
|
|
9618
|
+
exports.createZapierSdkStack = createZapierSdkStack;
|
|
9344
9619
|
exports.createZapierSdkWithoutRegistry = createZapierSdkWithoutRegistry;
|
|
9345
9620
|
exports.definePlugin = definePlugin;
|
|
9346
9621
|
exports.deleteClientCredentialsPlugin = deleteClientCredentialsPlugin;
|
|
@@ -9362,6 +9637,8 @@ exports.getBaseUrlFromCredentials = getBaseUrlFromCredentials;
|
|
|
9362
9637
|
exports.getCiPlatform = getCiPlatform;
|
|
9363
9638
|
exports.getClientIdFromCredentials = getClientIdFromCredentials;
|
|
9364
9639
|
exports.getConnectionPlugin = getConnectionPlugin;
|
|
9640
|
+
exports.getCoreErrorCause = getCoreErrorCause;
|
|
9641
|
+
exports.getCoreErrorCode = getCoreErrorCode;
|
|
9365
9642
|
exports.getCpuTime = getCpuTime;
|
|
9366
9643
|
exports.getCurrentTimestamp = getCurrentTimestamp;
|
|
9367
9644
|
exports.getMemoryUsage = getMemoryUsage;
|
|
@@ -9386,6 +9663,7 @@ exports.invalidateCredentialsToken = invalidateCredentialsToken;
|
|
|
9386
9663
|
exports.isCi = isCi;
|
|
9387
9664
|
exports.isCliLoginAvailable = isCliLoginAvailable;
|
|
9388
9665
|
exports.isClientCredentials = isClientCredentials;
|
|
9666
|
+
exports.isCoreError = isCoreError;
|
|
9389
9667
|
exports.isCredentialsFunction = isCredentialsFunction;
|
|
9390
9668
|
exports.isCredentialsObject = isCredentialsObject;
|
|
9391
9669
|
exports.isPkceCredentials = isPkceCredentials;
|
|
@@ -9399,17 +9677,18 @@ exports.listConnectionsPlugin = listConnectionsPlugin;
|
|
|
9399
9677
|
exports.listTableFieldsPlugin = listTableFieldsPlugin;
|
|
9400
9678
|
exports.listTableRecordsPlugin = listTableRecordsPlugin;
|
|
9401
9679
|
exports.listTablesPlugin = listTablesPlugin;
|
|
9402
|
-
exports.logDeprecation =
|
|
9680
|
+
exports.logDeprecation = logDeprecation2;
|
|
9403
9681
|
exports.manifestPlugin = manifestPlugin;
|
|
9404
9682
|
exports.parseConcurrencyEnvVar = parseConcurrencyEnvVar;
|
|
9405
9683
|
exports.readManifestFromFile = readManifestFromFile;
|
|
9406
9684
|
exports.registryPlugin = registryPlugin;
|
|
9407
9685
|
exports.requestPlugin = requestPlugin;
|
|
9408
|
-
exports.resetDeprecationWarnings =
|
|
9686
|
+
exports.resetDeprecationWarnings = resetDeprecationWarnings2;
|
|
9409
9687
|
exports.resolveAuthToken = resolveAuthToken;
|
|
9410
9688
|
exports.resolveCredentials = resolveCredentials;
|
|
9411
9689
|
exports.resolveCredentialsFromEnv = resolveCredentialsFromEnv;
|
|
9412
9690
|
exports.runActionPlugin = runActionPlugin;
|
|
9691
|
+
exports.runInMethodScope = runInMethodScope;
|
|
9413
9692
|
exports.runWithTelemetryContext = runWithTelemetryContext;
|
|
9414
9693
|
exports.tableFieldIdsResolver = tableFieldIdsResolver;
|
|
9415
9694
|
exports.tableFieldsResolver = tableFieldsResolver;
|
|
@@ -9427,4 +9706,6 @@ exports.triggerInboxResolver = triggerInboxResolver;
|
|
|
9427
9706
|
exports.triggerMessagesResolver = triggerMessagesResolver;
|
|
9428
9707
|
exports.updateTableRecordsPlugin = updateTableRecordsPlugin;
|
|
9429
9708
|
exports.workflowIdResolver = workflowIdResolver;
|
|
9709
|
+
exports.workflowRunIdResolver = workflowRunIdResolver;
|
|
9430
9710
|
exports.workflowVersionIdResolver = workflowVersionIdResolver;
|
|
9711
|
+
exports.zapierAdaptError = zapierAdaptError;
|