@zapier/zapier-sdk 0.65.0 → 0.68.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +48 -0
- package/README.md +64 -34
- package/dist/api/client.d.ts.map +1 -1
- package/dist/api/client.js +2 -0
- package/dist/api/debug.d.ts.map +1 -1
- package/dist/api/debug.js +6 -4
- package/dist/api/polling.d.ts +2 -0
- package/dist/api/polling.d.ts.map +1 -1
- package/dist/api/polling.js +10 -2
- package/dist/auth.d.ts.map +1 -1
- package/dist/auth.js +8 -5
- package/dist/core-stack.d.ts +24 -0
- package/dist/core-stack.d.ts.map +1 -0
- package/dist/core-stack.js +32 -0
- package/dist/experimental.cjs +1598 -1323
- package/dist/experimental.d.mts +3476 -224
- package/dist/experimental.d.ts +3508 -256
- package/dist/experimental.d.ts.map +1 -1
- package/dist/experimental.js +117 -87
- package/dist/experimental.mjs +1585 -1322
- package/dist/formatters/action.d.ts +4 -0
- package/dist/formatters/action.d.ts.map +1 -0
- package/dist/formatters/action.js +18 -0
- package/dist/formatters/actionResult.d.ts +3 -0
- package/dist/formatters/actionResult.d.ts.map +1 -0
- package/dist/formatters/actionResult.js +25 -0
- package/dist/formatters/app.d.ts +4 -0
- package/dist/formatters/app.d.ts.map +1 -0
- package/dist/formatters/app.js +10 -0
- package/dist/formatters/clientCredentials.d.ts +5 -0
- package/dist/formatters/clientCredentials.d.ts.map +1 -0
- package/dist/formatters/clientCredentials.js +27 -0
- package/dist/formatters/connection.d.ts +4 -0
- package/dist/formatters/connection.d.ts.map +1 -0
- package/dist/formatters/connection.js +26 -0
- package/dist/formatters/field.d.ts +4 -0
- package/dist/formatters/field.d.ts.map +1 -0
- package/dist/formatters/field.js +51 -0
- package/dist/formatters/inputFieldChoice.d.ts +4 -0
- package/dist/formatters/inputFieldChoice.d.ts.map +1 -0
- package/dist/formatters/inputFieldChoice.js +16 -0
- package/dist/formatters/tableField.d.ts +4 -0
- package/dist/formatters/tableField.d.ts.map +1 -0
- package/dist/formatters/tableField.js +7 -0
- package/dist/formatters/tableRecord.d.ts +5 -3
- package/dist/formatters/tableRecord.d.ts.map +1 -1
- package/dist/formatters/tableRecord.js +4 -3
- package/dist/formatters/triggerInbox.d.ts +4 -0
- package/dist/formatters/triggerInbox.d.ts.map +1 -0
- package/dist/formatters/triggerInbox.js +31 -0
- package/dist/formatters/triggerMessage.d.ts +5 -0
- package/dist/formatters/triggerMessage.d.ts.map +1 -0
- package/dist/formatters/triggerMessage.js +34 -0
- package/dist/formatters/userProfile.d.ts +4 -0
- package/dist/formatters/userProfile.d.ts.map +1 -0
- package/dist/formatters/userProfile.js +19 -0
- package/dist/{index-JhNxS_mq.d.mts → index-oRnHsPn5.d.mts} +12906 -7603
- package/dist/{index-JhNxS_mq.d.ts → index-oRnHsPn5.d.ts} +12906 -7603
- package/dist/index.cjs +1729 -1469
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +12 -9
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +21 -7
- package/dist/index.mjs +1716 -1468
- package/dist/plugins/api/index.d.ts +1 -1
- package/dist/plugins/api/index.js +1 -1
- package/dist/plugins/apps/index.d.ts +8 -5
- package/dist/plugins/apps/index.d.ts.map +1 -1
- package/dist/plugins/apps/index.js +1 -1
- package/dist/plugins/capabilities/index.d.ts +1 -1
- package/dist/plugins/capabilities/index.js +1 -1
- package/dist/plugins/codeSubstrate/cancelDurableRun/index.d.ts +32 -2
- package/dist/plugins/codeSubstrate/cancelDurableRun/index.d.ts.map +1 -1
- package/dist/plugins/codeSubstrate/cancelDurableRun/index.js +1 -1
- package/dist/plugins/codeSubstrate/createWorkflow/index.d.ts +2 -2
- package/dist/plugins/codeSubstrate/createWorkflow/index.js +1 -1
- package/dist/plugins/codeSubstrate/deleteWorkflow/index.d.ts +27 -2
- package/dist/plugins/codeSubstrate/deleteWorkflow/index.d.ts.map +1 -1
- package/dist/plugins/codeSubstrate/deleteWorkflow/index.js +1 -1
- package/dist/plugins/codeSubstrate/disableWorkflow/index.d.ts +27 -2
- package/dist/plugins/codeSubstrate/disableWorkflow/index.d.ts.map +1 -1
- package/dist/plugins/codeSubstrate/disableWorkflow/index.js +1 -1
- package/dist/plugins/codeSubstrate/enableWorkflow/index.d.ts +27 -2
- package/dist/plugins/codeSubstrate/enableWorkflow/index.d.ts.map +1 -1
- package/dist/plugins/codeSubstrate/enableWorkflow/index.js +1 -1
- package/dist/plugins/codeSubstrate/getDurableRun/index.d.ts +32 -2
- package/dist/plugins/codeSubstrate/getDurableRun/index.d.ts.map +1 -1
- package/dist/plugins/codeSubstrate/getDurableRun/index.js +1 -1
- package/dist/plugins/codeSubstrate/getTriggerRun/index.d.ts +2 -2
- package/dist/plugins/codeSubstrate/getTriggerRun/index.js +1 -1
- package/dist/plugins/codeSubstrate/getWorkflow/index.d.ts +27 -2
- package/dist/plugins/codeSubstrate/getWorkflow/index.d.ts.map +1 -1
- package/dist/plugins/codeSubstrate/getWorkflow/index.js +1 -1
- package/dist/plugins/codeSubstrate/getWorkflowRun/index.d.ts +55 -2
- package/dist/plugins/codeSubstrate/getWorkflowRun/index.d.ts.map +1 -1
- package/dist/plugins/codeSubstrate/getWorkflowRun/index.js +1 -1
- package/dist/plugins/codeSubstrate/getWorkflowVersion/index.d.ts +51 -2
- package/dist/plugins/codeSubstrate/getWorkflowVersion/index.d.ts.map +1 -1
- package/dist/plugins/codeSubstrate/getWorkflowVersion/index.js +1 -1
- package/dist/plugins/codeSubstrate/listDurableRuns/index.d.ts +3 -3
- package/dist/plugins/codeSubstrate/listDurableRuns/index.d.ts.map +1 -1
- package/dist/plugins/codeSubstrate/listDurableRuns/index.js +1 -1
- package/dist/plugins/codeSubstrate/listWorkflowRuns/index.d.ts +28 -3
- package/dist/plugins/codeSubstrate/listWorkflowRuns/index.d.ts.map +1 -1
- package/dist/plugins/codeSubstrate/listWorkflowRuns/index.js +1 -1
- package/dist/plugins/codeSubstrate/listWorkflowVersions/index.d.ts +28 -3
- package/dist/plugins/codeSubstrate/listWorkflowVersions/index.d.ts.map +1 -1
- package/dist/plugins/codeSubstrate/listWorkflowVersions/index.js +1 -1
- package/dist/plugins/codeSubstrate/listWorkflows/index.d.ts +3 -3
- package/dist/plugins/codeSubstrate/listWorkflows/index.d.ts.map +1 -1
- package/dist/plugins/codeSubstrate/listWorkflows/index.js +2 -3
- package/dist/plugins/codeSubstrate/publishWorkflowVersion/index.d.ts +27 -2
- package/dist/plugins/codeSubstrate/publishWorkflowVersion/index.d.ts.map +1 -1
- package/dist/plugins/codeSubstrate/publishWorkflowVersion/index.js +1 -1
- package/dist/plugins/codeSubstrate/runDurable/index.d.ts +2 -2
- package/dist/plugins/codeSubstrate/runDurable/index.js +1 -1
- package/dist/plugins/codeSubstrate/triggerWorkflow/index.d.ts +73 -0
- package/dist/plugins/codeSubstrate/triggerWorkflow/index.d.ts.map +1 -0
- package/dist/plugins/codeSubstrate/triggerWorkflow/index.js +52 -0
- package/dist/plugins/codeSubstrate/triggerWorkflow/schemas.d.ts +16 -0
- package/dist/plugins/codeSubstrate/triggerWorkflow/schemas.d.ts.map +1 -0
- package/dist/plugins/codeSubstrate/triggerWorkflow/schemas.js +31 -0
- package/dist/plugins/codeSubstrate/updateWorkflow/index.d.ts +27 -2
- package/dist/plugins/codeSubstrate/updateWorkflow/index.d.ts.map +1 -1
- package/dist/plugins/codeSubstrate/updateWorkflow/index.js +1 -1
- package/dist/plugins/connections/index.d.ts +1 -1
- package/dist/plugins/connections/index.js +1 -1
- package/dist/plugins/createClientCredentials/index.d.ts +2 -2
- package/dist/plugins/createClientCredentials/index.d.ts.map +1 -1
- package/dist/plugins/createClientCredentials/index.js +4 -2
- package/dist/plugins/createClientCredentials/schemas.d.ts +1 -2
- package/dist/plugins/createClientCredentials/schemas.d.ts.map +1 -1
- package/dist/plugins/deleteClientCredentials/index.d.ts +24 -2
- package/dist/plugins/deleteClientCredentials/index.d.ts.map +1 -1
- package/dist/plugins/deleteClientCredentials/index.js +2 -2
- package/dist/plugins/deleteClientCredentials/schemas.d.ts +1 -2
- package/dist/plugins/deleteClientCredentials/schemas.d.ts.map +1 -1
- package/dist/plugins/deprecated/authentications.d.ts +144 -16
- package/dist/plugins/deprecated/authentications.d.ts.map +1 -1
- package/dist/plugins/deprecated/authentications.js +14 -5
- package/dist/plugins/deprecated/inputFields.d.ts +58 -23
- package/dist/plugins/deprecated/inputFields.d.ts.map +1 -1
- package/dist/plugins/deprecated/inputFields.js +15 -7
- package/dist/plugins/eventEmission/event-emission-hook.d.ts +10 -0
- package/dist/plugins/eventEmission/event-emission-hook.d.ts.map +1 -0
- package/dist/plugins/eventEmission/event-emission-hook.js +47 -0
- package/dist/plugins/eventEmission/index.d.ts +5 -3
- package/dist/plugins/eventEmission/index.d.ts.map +1 -1
- package/dist/plugins/eventEmission/index.js +16 -9
- package/dist/plugins/eventEmission/method-metadata.d.ts +16 -0
- package/dist/plugins/eventEmission/method-metadata.d.ts.map +1 -0
- package/dist/plugins/eventEmission/method-metadata.js +20 -0
- package/dist/plugins/eventEmission/transport.d.ts.map +1 -1
- package/dist/plugins/eventEmission/transport.js +2 -1
- package/dist/plugins/eventEmission/types.d.ts +1 -1
- package/dist/plugins/eventEmission/types.d.ts.map +1 -1
- package/dist/plugins/fetch/index.d.ts +11 -5
- package/dist/plugins/fetch/index.d.ts.map +1 -1
- package/dist/plugins/fetch/index.js +42 -32
- package/dist/plugins/fetch/schemas.d.ts +1 -1
- package/dist/plugins/findFirstConnection/index.d.ts +4 -4
- package/dist/plugins/findFirstConnection/index.d.ts.map +1 -1
- package/dist/plugins/findFirstConnection/index.js +4 -2
- package/dist/plugins/findFirstConnection/schemas.d.ts +2 -2
- package/dist/plugins/findUniqueConnection/index.d.ts +4 -4
- package/dist/plugins/findUniqueConnection/index.d.ts.map +1 -1
- package/dist/plugins/findUniqueConnection/index.js +4 -2
- package/dist/plugins/findUniqueConnection/schemas.d.ts +2 -2
- package/dist/plugins/getAction/index.d.ts +141 -4
- package/dist/plugins/getAction/index.d.ts.map +1 -1
- package/dist/plugins/getAction/index.js +5 -3
- package/dist/plugins/getAction/schemas.d.ts +6 -6
- package/dist/plugins/getActionInputFieldsSchema/index.d.ts +232 -3
- package/dist/plugins/getActionInputFieldsSchema/index.d.ts.map +1 -1
- package/dist/plugins/getActionInputFieldsSchema/index.js +3 -3
- package/dist/plugins/getActionInputFieldsSchema/schemas.d.ts +6 -6
- package/dist/plugins/getApp/index.d.ts +4 -4
- package/dist/plugins/getApp/index.d.ts.map +1 -1
- package/dist/plugins/getApp/index.js +3 -1
- package/dist/plugins/getApp/schemas.d.ts +4 -4
- package/dist/plugins/getConnection/index.d.ts +125 -2
- package/dist/plugins/getConnection/index.d.ts.map +1 -1
- package/dist/plugins/getConnection/index.js +4 -2
- package/dist/plugins/getProfile/index.d.ts +2 -2
- package/dist/plugins/getProfile/index.d.ts.map +1 -1
- package/dist/plugins/getProfile/index.js +4 -2
- package/dist/plugins/getProfile/schemas.d.ts +1 -2
- package/dist/plugins/getProfile/schemas.d.ts.map +1 -1
- package/dist/plugins/listActionInputFieldChoices/index.d.ts +287 -4
- package/dist/plugins/listActionInputFieldChoices/index.d.ts.map +1 -1
- package/dist/plugins/listActionInputFieldChoices/index.js +6 -4
- package/dist/plugins/listActionInputFieldChoices/schemas.d.ts +8 -8
- package/dist/plugins/listActionInputFieldChoices/schemas.d.ts.map +1 -1
- package/dist/plugins/listActionInputFieldChoices/schemas.js +1 -22
- package/dist/plugins/listActionInputFields/index.d.ts +168 -5
- package/dist/plugins/listActionInputFields/index.d.ts.map +1 -1
- package/dist/plugins/listActionInputFields/index.js +7 -5
- package/dist/plugins/listActionInputFields/schemas.d.ts +6 -6
- package/dist/plugins/listActions/index.d.ts +140 -3
- package/dist/plugins/listActions/index.d.ts.map +1 -1
- package/dist/plugins/listActions/index.js +6 -4
- package/dist/plugins/listActions/schemas.d.ts +4 -4
- package/dist/plugins/listApps/index.d.ts +3 -3
- package/dist/plugins/listApps/index.d.ts.map +1 -1
- package/dist/plugins/listApps/index.js +6 -4
- package/dist/plugins/listClientCredentials/index.d.ts +3 -3
- package/dist/plugins/listClientCredentials/index.d.ts.map +1 -1
- package/dist/plugins/listClientCredentials/index.js +6 -4
- package/dist/plugins/listConnections/index.d.ts +140 -3
- package/dist/plugins/listConnections/index.d.ts.map +1 -1
- package/dist/plugins/listConnections/index.js +7 -5
- package/dist/plugins/listConnections/schemas.d.ts +2 -2
- package/dist/plugins/manifest/index.d.ts +1 -1
- package/dist/plugins/manifest/index.d.ts.map +1 -1
- package/dist/plugins/manifest/index.js +6 -4
- package/dist/plugins/registry/index.d.ts +1 -1
- package/dist/plugins/registry/index.js +1 -1
- package/dist/plugins/request/index.d.ts +8 -5
- package/dist/plugins/request/index.d.ts.map +1 -1
- package/dist/plugins/request/index.js +4 -3
- package/dist/plugins/request/schemas.d.ts +2 -2
- package/dist/plugins/runAction/index.d.ts +168 -5
- package/dist/plugins/runAction/index.d.ts.map +1 -1
- package/dist/plugins/runAction/index.js +9 -5
- package/dist/plugins/runAction/schemas.d.ts +6 -6
- package/dist/plugins/tables/createTable/index.d.ts +2 -2
- package/dist/plugins/tables/createTable/index.js +2 -2
- package/dist/plugins/tables/createTable/schemas.d.ts +1 -2
- package/dist/plugins/tables/createTable/schemas.d.ts.map +1 -1
- package/dist/plugins/tables/createTableFields/index.d.ts +34 -2
- package/dist/plugins/tables/createTableFields/index.d.ts.map +1 -1
- package/dist/plugins/tables/createTableFields/index.js +4 -2
- package/dist/plugins/tables/createTableFields/schemas.d.ts +3 -4
- package/dist/plugins/tables/createTableFields/schemas.d.ts.map +1 -1
- package/dist/plugins/tables/createTableRecords/index.d.ts +63 -2
- package/dist/plugins/tables/createTableRecords/index.d.ts.map +1 -1
- package/dist/plugins/tables/createTableRecords/index.js +2 -2
- package/dist/plugins/tables/createTableRecords/schemas.d.ts +3 -4
- package/dist/plugins/tables/createTableRecords/schemas.d.ts.map +1 -1
- package/dist/plugins/tables/deleteTable/index.d.ts +34 -2
- package/dist/plugins/tables/deleteTable/index.d.ts.map +1 -1
- package/dist/plugins/tables/deleteTable/index.js +2 -2
- package/dist/plugins/tables/deleteTable/schemas.d.ts +3 -4
- package/dist/plugins/tables/deleteTable/schemas.d.ts.map +1 -1
- package/dist/plugins/tables/deleteTableFields/index.d.ts +63 -2
- package/dist/plugins/tables/deleteTableFields/index.d.ts.map +1 -1
- package/dist/plugins/tables/deleteTableFields/index.js +2 -2
- package/dist/plugins/tables/deleteTableFields/schemas.d.ts +4 -5
- package/dist/plugins/tables/deleteTableFields/schemas.d.ts.map +1 -1
- package/dist/plugins/tables/deleteTableRecords/index.d.ts +84 -2
- package/dist/plugins/tables/deleteTableRecords/index.d.ts.map +1 -1
- package/dist/plugins/tables/deleteTableRecords/index.js +2 -2
- package/dist/plugins/tables/deleteTableRecords/schemas.d.ts +4 -5
- package/dist/plugins/tables/deleteTableRecords/schemas.d.ts.map +1 -1
- package/dist/plugins/tables/getTable/index.d.ts +34 -2
- package/dist/plugins/tables/getTable/index.d.ts.map +1 -1
- package/dist/plugins/tables/getTable/index.js +2 -2
- package/dist/plugins/tables/getTable/schemas.d.ts +2 -2
- package/dist/plugins/tables/getTableRecord/index.d.ts +84 -2
- package/dist/plugins/tables/getTableRecord/index.d.ts.map +1 -1
- package/dist/plugins/tables/getTableRecord/index.js +2 -2
- package/dist/plugins/tables/getTableRecord/schemas.d.ts +6 -7
- package/dist/plugins/tables/getTableRecord/schemas.d.ts.map +1 -1
- package/dist/plugins/tables/getTableRecord/schemas.js +1 -10
- package/dist/plugins/tables/listTableFields/index.d.ts +34 -2
- package/dist/plugins/tables/listTableFields/index.d.ts.map +1 -1
- package/dist/plugins/tables/listTableFields/index.js +4 -2
- package/dist/plugins/tables/listTableFields/schemas.d.ts +4 -5
- package/dist/plugins/tables/listTableFields/schemas.d.ts.map +1 -1
- package/dist/plugins/tables/listTableFields/schemas.js +1 -9
- package/dist/plugins/tables/listTableRecords/index.d.ts +65 -4
- package/dist/plugins/tables/listTableRecords/index.d.ts.map +1 -1
- package/dist/plugins/tables/listTableRecords/index.js +3 -3
- package/dist/plugins/tables/listTableRecords/schemas.d.ts +2 -2
- package/dist/plugins/tables/listTables/index.d.ts +3 -3
- package/dist/plugins/tables/listTables/index.d.ts.map +1 -1
- package/dist/plugins/tables/listTables/index.js +4 -4
- package/dist/plugins/tables/updateTableRecords/index.d.ts +63 -2
- package/dist/plugins/tables/updateTableRecords/index.d.ts.map +1 -1
- package/dist/plugins/tables/updateTableRecords/index.js +2 -2
- package/dist/plugins/tables/updateTableRecords/schemas.d.ts +3 -4
- package/dist/plugins/tables/updateTableRecords/schemas.d.ts.map +1 -1
- package/dist/plugins/triggers/ackTriggerInboxMessages/index.d.ts +59 -2
- package/dist/plugins/triggers/ackTriggerInboxMessages/index.d.ts.map +1 -1
- package/dist/plugins/triggers/ackTriggerInboxMessages/index.js +1 -1
- package/dist/plugins/triggers/ackTriggerInboxMessages/schemas.d.ts +1 -1
- package/dist/plugins/triggers/createTriggerInbox/index.d.ts +231 -2
- package/dist/plugins/triggers/createTriggerInbox/index.d.ts.map +1 -1
- package/dist/plugins/triggers/createTriggerInbox/index.js +3 -1
- package/dist/plugins/triggers/createTriggerInbox/schemas.d.ts +3 -4
- package/dist/plugins/triggers/createTriggerInbox/schemas.d.ts.map +1 -1
- package/dist/plugins/triggers/deleteTriggerInbox/index.d.ts +33 -2
- package/dist/plugins/triggers/deleteTriggerInbox/index.d.ts.map +1 -1
- package/dist/plugins/triggers/deleteTriggerInbox/index.js +3 -1
- package/dist/plugins/triggers/deleteTriggerInbox/schemas.d.ts +2 -3
- package/dist/plugins/triggers/deleteTriggerInbox/schemas.d.ts.map +1 -1
- package/dist/plugins/triggers/drainTriggerInbox/index.d.ts +68 -6
- package/dist/plugins/triggers/drainTriggerInbox/index.d.ts.map +1 -1
- package/dist/plugins/triggers/drainTriggerInbox/index.js +1 -1
- package/dist/plugins/triggers/drainTriggerInbox/schemas.d.ts +2 -2
- package/dist/plugins/triggers/ensureTriggerInbox/index.d.ts +231 -2
- package/dist/plugins/triggers/ensureTriggerInbox/index.d.ts.map +1 -1
- package/dist/plugins/triggers/ensureTriggerInbox/index.js +3 -1
- package/dist/plugins/triggers/ensureTriggerInbox/schemas.d.ts +3 -4
- package/dist/plugins/triggers/ensureTriggerInbox/schemas.d.ts.map +1 -1
- package/dist/plugins/triggers/getTriggerInbox/index.d.ts +33 -2
- package/dist/plugins/triggers/getTriggerInbox/index.d.ts.map +1 -1
- package/dist/plugins/triggers/getTriggerInbox/index.js +3 -1
- package/dist/plugins/triggers/getTriggerInbox/schemas.d.ts +2 -3
- package/dist/plugins/triggers/getTriggerInbox/schemas.d.ts.map +1 -1
- package/dist/plugins/triggers/getTriggerInputFieldsSchema/index.d.ts +232 -3
- package/dist/plugins/triggers/getTriggerInputFieldsSchema/index.d.ts.map +1 -1
- package/dist/plugins/triggers/getTriggerInputFieldsSchema/index.js +1 -1
- package/dist/plugins/triggers/getTriggerInputFieldsSchema/schemas.d.ts +2 -2
- package/dist/plugins/triggers/leaseTriggerInboxMessages/index.d.ts +33 -2
- package/dist/plugins/triggers/leaseTriggerInboxMessages/index.d.ts.map +1 -1
- package/dist/plugins/triggers/leaseTriggerInboxMessages/index.js +1 -1
- package/dist/plugins/triggers/leaseTriggerInboxMessages/schemas.d.ts +1 -1
- package/dist/plugins/triggers/listTriggerInboxMessages/index.d.ts +34 -3
- package/dist/plugins/triggers/listTriggerInboxMessages/index.d.ts.map +1 -1
- package/dist/plugins/triggers/listTriggerInboxMessages/index.js +5 -13
- package/dist/plugins/triggers/listTriggerInboxMessages/schemas.d.ts +1 -1
- package/dist/plugins/triggers/listTriggerInboxes/index.d.ts +3 -3
- package/dist/plugins/triggers/listTriggerInboxes/index.d.ts.map +1 -1
- package/dist/plugins/triggers/listTriggerInboxes/index.js +5 -14
- package/dist/plugins/triggers/listTriggerInputFieldChoices/index.d.ts +288 -5
- package/dist/plugins/triggers/listTriggerInputFieldChoices/index.d.ts.map +1 -1
- package/dist/plugins/triggers/listTriggerInputFieldChoices/index.js +7 -5
- package/dist/plugins/triggers/listTriggerInputFieldChoices/schemas.d.ts +3 -3
- package/dist/plugins/triggers/listTriggerInputFields/index.d.ts +234 -5
- package/dist/plugins/triggers/listTriggerInputFields/index.d.ts.map +1 -1
- package/dist/plugins/triggers/listTriggerInputFields/index.js +6 -5
- package/dist/plugins/triggers/listTriggerInputFields/schemas.d.ts +2 -2
- package/dist/plugins/triggers/listTriggers/index.d.ts +142 -5
- package/dist/plugins/triggers/listTriggers/index.d.ts.map +1 -1
- package/dist/plugins/triggers/listTriggers/index.js +6 -5
- package/dist/plugins/triggers/listTriggers/schemas.d.ts +1 -1
- package/dist/plugins/triggers/pauseTriggerInbox/index.d.ts +33 -2
- package/dist/plugins/triggers/pauseTriggerInbox/index.d.ts.map +1 -1
- package/dist/plugins/triggers/pauseTriggerInbox/index.js +3 -1
- package/dist/plugins/triggers/pauseTriggerInbox/schemas.d.ts +2 -3
- package/dist/plugins/triggers/pauseTriggerInbox/schemas.d.ts.map +1 -1
- package/dist/plugins/triggers/releaseTriggerInboxMessages/index.d.ts +59 -2
- package/dist/plugins/triggers/releaseTriggerInboxMessages/index.d.ts.map +1 -1
- package/dist/plugins/triggers/releaseTriggerInboxMessages/index.js +1 -1
- package/dist/plugins/triggers/releaseTriggerInboxMessages/schemas.d.ts +1 -1
- package/dist/plugins/triggers/resumeTriggerInbox/index.d.ts +33 -2
- package/dist/plugins/triggers/resumeTriggerInbox/index.d.ts.map +1 -1
- package/dist/plugins/triggers/resumeTriggerInbox/index.js +3 -1
- package/dist/plugins/triggers/resumeTriggerInbox/schemas.d.ts +2 -3
- package/dist/plugins/triggers/resumeTriggerInbox/schemas.d.ts.map +1 -1
- package/dist/plugins/triggers/updateTriggerInbox/index.d.ts +33 -2
- package/dist/plugins/triggers/updateTriggerInbox/index.d.ts.map +1 -1
- package/dist/plugins/triggers/updateTriggerInbox/index.js +3 -1
- package/dist/plugins/triggers/updateTriggerInbox/schemas.d.ts +2 -3
- package/dist/plugins/triggers/updateTriggerInbox/schemas.d.ts.map +1 -1
- package/dist/plugins/triggers/watchTriggerInbox/index.d.ts +37 -6
- package/dist/plugins/triggers/watchTriggerInbox/index.d.ts.map +1 -1
- package/dist/plugins/triggers/watchTriggerInbox/index.js +1 -1
- package/dist/resolvers/actionKey.d.ts +3 -2
- package/dist/resolvers/actionKey.d.ts.map +1 -1
- package/dist/resolvers/actionType.d.ts +7 -2
- package/dist/resolvers/actionType.d.ts.map +1 -1
- package/dist/resolvers/actionType.js +3 -0
- package/dist/resolvers/appKey.d.ts +10 -5
- package/dist/resolvers/appKey.d.ts.map +1 -1
- package/dist/resolvers/appKey.js +3 -0
- package/dist/resolvers/clientCredentialsName.d.ts +1 -1
- package/dist/resolvers/clientCredentialsName.d.ts.map +1 -1
- package/dist/resolvers/clientId.d.ts +3 -2
- package/dist/resolvers/clientId.d.ts.map +1 -1
- package/dist/resolvers/clientId.js +1 -1
- package/dist/resolvers/connectionId.d.ts +5 -2
- package/dist/resolvers/connectionId.d.ts.map +1 -1
- package/dist/resolvers/connectionId.js +1 -1
- package/dist/resolvers/durableRunId.d.ts +3 -2
- package/dist/resolvers/durableRunId.d.ts.map +1 -1
- package/dist/resolvers/durableRunId.js +3 -2
- package/dist/resolvers/inputFieldKey.d.ts +3 -2
- package/dist/resolvers/inputFieldKey.d.ts.map +1 -1
- package/dist/resolvers/inputFieldKey.js +1 -1
- package/dist/resolvers/tableFieldIds.d.ts +3 -2
- package/dist/resolvers/tableFieldIds.d.ts.map +1 -1
- package/dist/resolvers/tableFields.d.ts +2 -2
- package/dist/resolvers/tableFields.d.ts.map +1 -1
- package/dist/resolvers/tableFilters.d.ts +3 -2
- package/dist/resolvers/tableFilters.d.ts.map +1 -1
- package/dist/resolvers/tableId.d.ts +3 -2
- package/dist/resolvers/tableId.d.ts.map +1 -1
- package/dist/resolvers/tableId.js +1 -1
- package/dist/resolvers/tableName.d.ts +1 -1
- package/dist/resolvers/tableName.d.ts.map +1 -1
- package/dist/resolvers/tableRecordId.d.ts +4 -3
- package/dist/resolvers/tableRecordId.d.ts.map +1 -1
- package/dist/resolvers/tableRecords.d.ts +4 -3
- package/dist/resolvers/tableRecords.d.ts.map +1 -1
- package/dist/resolvers/tableSort.d.ts +3 -2
- package/dist/resolvers/tableSort.d.ts.map +1 -1
- package/dist/resolvers/triggerInbox.d.ts +3 -2
- package/dist/resolvers/triggerInbox.d.ts.map +1 -1
- package/dist/resolvers/triggerInbox.js +1 -1
- package/dist/resolvers/triggerMessages.d.ts +3 -2
- package/dist/resolvers/triggerMessages.d.ts.map +1 -1
- package/dist/resolvers/triggerMessages.js +2 -4
- package/dist/resolvers/workflowId.d.ts +3 -2
- package/dist/resolvers/workflowId.d.ts.map +1 -1
- package/dist/resolvers/workflowId.js +3 -2
- package/dist/resolvers/workflowRunId.d.ts +3 -2
- package/dist/resolvers/workflowRunId.d.ts.map +1 -1
- package/dist/resolvers/workflowRunId.js +5 -5
- package/dist/resolvers/workflowVersionId.d.ts +3 -2
- package/dist/resolvers/workflowVersionId.d.ts.map +1 -1
- package/dist/resolvers/workflowVersionId.js +7 -7
- package/dist/schemas/Action.d.ts.map +1 -1
- package/dist/schemas/Action.js +6 -30
- package/dist/schemas/App.d.ts +0 -1
- package/dist/schemas/App.d.ts.map +1 -1
- package/dist/schemas/App.js +2 -14
- package/dist/schemas/ClientCredentials.d.ts.map +1 -1
- package/dist/schemas/ClientCredentials.js +3 -41
- package/dist/schemas/Connection.d.ts.map +1 -1
- package/dist/schemas/Connection.js +2 -28
- package/dist/schemas/Field.d.ts.map +1 -1
- package/dist/schemas/Field.js +3 -70
- package/dist/schemas/Run.d.ts.map +1 -1
- package/dist/schemas/Run.js +3 -29
- package/dist/schemas/TriggerInbox.d.ts.map +1 -1
- package/dist/schemas/TriggerInbox.js +1 -33
- package/dist/schemas/TriggerMessage.d.ts.map +1 -1
- package/dist/schemas/TriggerMessage.js +2 -60
- package/dist/schemas/UserProfile.d.ts +0 -1
- package/dist/schemas/UserProfile.d.ts.map +1 -1
- package/dist/schemas/UserProfile.js +1 -20
- package/dist/sdk.d.ts +2761 -441
- package/dist/sdk.d.ts.map +1 -1
- package/dist/sdk.js +93 -129
- package/dist/types/errors.d.ts +44 -42
- package/dist/types/errors.d.ts.map +1 -1
- package/dist/types/errors.js +79 -33
- package/dist/types/functions.d.ts +1 -41
- package/dist/types/functions.d.ts.map +1 -1
- package/dist/types/properties.d.ts +7 -7
- package/dist/types/properties.js +1 -1
- package/dist/types/sdk.d.ts +1 -1
- package/dist/types/sdk.d.ts.map +1 -1
- package/dist/types/telemetry-events.d.ts +1 -1
- package/dist/types/telemetry-events.d.ts.map +1 -1
- package/dist/utils/domain-utils.js +1 -1
- package/dist/utils/logging.d.ts +1 -12
- package/dist/utils/logging.d.ts.map +1 -1
- package/dist/utils/logging.js +2 -20
- package/dist/utils/pagination.d.ts +38 -0
- package/dist/utils/pagination.d.ts.map +1 -0
- package/dist/utils/pagination.js +53 -0
- package/package.json +3 -2
- package/dist/registry.d.ts +0 -9
- package/dist/registry.d.ts.map +0 -1
- package/dist/registry.js +0 -103
- package/dist/types/meta.d.ts +0 -9
- package/dist/types/meta.d.ts.map +0 -1
- package/dist/types/meta.js +0 -3
- package/dist/types/plugin.d.ts +0 -84
- package/dist/types/plugin.d.ts.map +0 -1
- package/dist/types/plugin.js +0 -13
- package/dist/types/registry.d.ts +0 -54
- package/dist/types/registry.d.ts.map +0 -1
- package/dist/types/registry.js +0 -1
- package/dist/utils/function-utils.d.ts +0 -59
- package/dist/utils/function-utils.d.ts.map +0 -1
- package/dist/utils/function-utils.js +0 -245
- package/dist/utils/pagination-utils.d.ts +0 -73
- package/dist/utils/pagination-utils.d.ts.map +0 -1
- package/dist/utils/pagination-utils.js +0 -308
- package/dist/utils/plugin-utils.d.ts +0 -245
- package/dist/utils/plugin-utils.d.ts.map +0 -1
- package/dist/utils/plugin-utils.js +0 -234
- package/dist/utils/schema-utils.d.ts +0 -211
- package/dist/utils/schema-utils.d.ts.map +0 -1
- package/dist/utils/schema-utils.js +0 -72
- package/dist/utils/string-utils.d.ts +0 -40
- package/dist/utils/string-utils.d.ts.map +0 -1
- package/dist/utils/string-utils.js +0 -69
- package/dist/utils/telemetry-context.d.ts +0 -15
- package/dist/utils/telemetry-context.d.ts.map +0 -1
- package/dist/utils/telemetry-context.js +0 -48
- package/dist/utils/telemetry-utils.d.ts +0 -44
- package/dist/utils/telemetry-utils.d.ts.map +0 -1
- package/dist/utils/telemetry-utils.js +0 -60
- package/dist/utils/validation.d.ts +0 -4
- package/dist/utils/validation.d.ts.map +0 -1
- package/dist/utils/validation.js +0 -30
package/dist/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;
|
|
743
1276
|
}
|
|
744
|
-
return result.data;
|
|
745
1277
|
};
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
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;
|
|
1287
|
+
}
|
|
753
1288
|
};
|
|
754
|
-
var
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
function isTelemetryNested() {
|
|
760
|
-
if (!telemetryStore) return true;
|
|
761
|
-
const store = telemetryStore.getStore();
|
|
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;
|
|
1289
|
+
var ZapierRelayError = class extends ZapierError {
|
|
1290
|
+
constructor(message, options = {}) {
|
|
1291
|
+
super(message, options);
|
|
1292
|
+
this.name = "ZapierRelayError";
|
|
1293
|
+
this.code = "ZAPIER_RELAY_ERROR";
|
|
784
1294
|
}
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
1295
|
+
};
|
|
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
|
+
}
|
|
791
1304
|
}
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
return error;
|
|
1305
|
+
if (error instanceof ZapierAppNotFoundError && error.appKey) {
|
|
1306
|
+
message += `
|
|
1307
|
+
App key: ${error.appKey}`;
|
|
796
1308
|
}
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
if (error.
|
|
801
|
-
|
|
802
|
-
|
|
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(", ")}`;
|
|
803
1315
|
}
|
|
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
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
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
|
-
}
|
|
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(", ")}`;
|
|
1322
|
+
}
|
|
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
|
-
style: "normal"
|
|
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" });
|
|
2272
2587
|
}
|
|
2588
|
+
if (item.description) {
|
|
2589
|
+
details.push({ text: item.description, style: "dim" });
|
|
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",
|
|
@@ -2629,11 +2952,7 @@ var workflowVersionIdResolver = {
|
|
|
2629
2952
|
var workflowRunIdResolver = {
|
|
2630
2953
|
type: "dynamic",
|
|
2631
2954
|
depends: ["workflow"],
|
|
2632
|
-
fetch: async (sdk, params) => toIterable(
|
|
2633
|
-
sdk.listWorkflowRuns({
|
|
2634
|
-
workflow: params.workflow
|
|
2635
|
-
})
|
|
2636
|
-
),
|
|
2955
|
+
fetch: async (sdk, params) => toIterable(sdk.listWorkflowRuns({ workflow: params.workflow })),
|
|
2637
2956
|
prompt: (runs) => ({
|
|
2638
2957
|
type: "list",
|
|
2639
2958
|
name: "run",
|
|
@@ -2649,11 +2968,7 @@ var workflowRunIdResolver = {
|
|
|
2649
2968
|
var triggerMessagesResolver = {
|
|
2650
2969
|
type: "dynamic",
|
|
2651
2970
|
depends: ["inbox"],
|
|
2652
|
-
fetch: async (sdk, params) => toIterable(
|
|
2653
|
-
sdk.listTriggerInboxMessages({
|
|
2654
|
-
inbox: params.inbox
|
|
2655
|
-
})
|
|
2656
|
-
),
|
|
2971
|
+
fetch: async (sdk, params) => toIterable(sdk.listTriggerInboxMessages({ inbox: params.inbox })),
|
|
2657
2972
|
prompt: (messages) => ({
|
|
2658
2973
|
type: "checkbox",
|
|
2659
2974
|
name: "messages",
|
|
@@ -3027,7 +3342,7 @@ var FieldApiItemSchema = zod.z.object({
|
|
|
3027
3342
|
var ListTableFieldsApiResponseSchema = zod.z.object({
|
|
3028
3343
|
data: zod.z.array(FieldApiItemSchema)
|
|
3029
3344
|
});
|
|
3030
|
-
var
|
|
3345
|
+
var FieldItemSchema = zod.z.object({
|
|
3031
3346
|
id: zod.z.string(),
|
|
3032
3347
|
type: FieldTypeSchema,
|
|
3033
3348
|
name: zod.z.string(),
|
|
@@ -3037,13 +3352,6 @@ var FieldItemSchemaBase = zod.z.object({
|
|
|
3037
3352
|
config: zod.z.record(zod.z.string(), zod.z.unknown()).optional(),
|
|
3038
3353
|
deleted_at: zod.z.string().nullable().optional()
|
|
3039
3354
|
});
|
|
3040
|
-
var FieldItemSchema = withFormatter(FieldItemSchemaBase, {
|
|
3041
|
-
format: (item) => ({
|
|
3042
|
-
title: item.name,
|
|
3043
|
-
id: item.id,
|
|
3044
|
-
details: [{ text: `Type: ${item.type}`, style: "dim" }]
|
|
3045
|
-
})
|
|
3046
|
-
});
|
|
3047
3355
|
var ListTableFieldsDescription = "List fields for a table";
|
|
3048
3356
|
var ListTableFieldsOptionsBaseSchema = zod.z.object({
|
|
3049
3357
|
fields: FieldsPropertySchema.optional(),
|
|
@@ -3290,6 +3598,18 @@ var tableSortResolver = {
|
|
|
3290
3598
|
}
|
|
3291
3599
|
};
|
|
3292
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
|
+
|
|
3293
3613
|
// src/plugins/listActions/index.ts
|
|
3294
3614
|
var listActionsPlugin = definePlugin(
|
|
3295
3615
|
(sdk) => createPaginatedPluginMethod(sdk, {
|
|
@@ -3299,12 +3619,10 @@ var listActionsPlugin = definePlugin(
|
|
|
3299
3619
|
itemType: "Action",
|
|
3300
3620
|
inputSchema: ListActionsInputSchema,
|
|
3301
3621
|
outputSchema: ActionItemSchema,
|
|
3622
|
+
formatter: actionItemFormatter,
|
|
3302
3623
|
defaultPageSize: DEFAULT_PAGE_SIZE,
|
|
3303
3624
|
resolvers: { app: appKeyResolver, actionType: actionTypeResolver },
|
|
3304
|
-
handler: async ({
|
|
3305
|
-
sdk: sdk2,
|
|
3306
|
-
options
|
|
3307
|
-
}) => {
|
|
3625
|
+
handler: async ({ sdk: sdk2, options }) => {
|
|
3308
3626
|
const { api, getVersionedImplementationId } = sdk2.context;
|
|
3309
3627
|
const appKey = "app" in options ? options.app : options.appKey;
|
|
3310
3628
|
const selectedApi = await getVersionedImplementationId(appKey);
|
|
@@ -3391,99 +3709,36 @@ var BaseFieldItemSchema = zod.z.object({
|
|
|
3391
3709
|
key: zod.z.string()
|
|
3392
3710
|
// From need.key
|
|
3393
3711
|
});
|
|
3394
|
-
var InputFieldItemSchema =
|
|
3395
|
-
|
|
3396
|
-
|
|
3397
|
-
|
|
3398
|
-
|
|
3399
|
-
|
|
3400
|
-
|
|
3401
|
-
|
|
3402
|
-
|
|
3403
|
-
|
|
3404
|
-
|
|
3405
|
-
|
|
3406
|
-
|
|
3407
|
-
|
|
3408
|
-
|
|
3409
|
-
|
|
3410
|
-
|
|
3411
|
-
|
|
3412
|
-
|
|
3413
|
-
|
|
3414
|
-
|
|
3415
|
-
|
|
3416
|
-
|
|
3417
|
-
|
|
3418
|
-
|
|
3419
|
-
|
|
3420
|
-
|
|
3421
|
-
|
|
3422
|
-
|
|
3423
|
-
|
|
3424
|
-
].filter(Boolean).join(" | ");
|
|
3425
|
-
if (typeInfo) {
|
|
3426
|
-
details.push({ text: typeInfo, style: "dim" });
|
|
3427
|
-
}
|
|
3428
|
-
if (item.description) {
|
|
3429
|
-
details.push({
|
|
3430
|
-
text: item.description,
|
|
3431
|
-
style: "normal"
|
|
3432
|
-
});
|
|
3433
|
-
}
|
|
3434
|
-
if (item.default_value) {
|
|
3435
|
-
details.push({
|
|
3436
|
-
text: `Default: ${item.default_value}`,
|
|
3437
|
-
style: "accent"
|
|
3438
|
-
});
|
|
3439
|
-
}
|
|
3440
|
-
if (item.placeholder) {
|
|
3441
|
-
details.push({
|
|
3442
|
-
text: `Placeholder: ${item.placeholder}`,
|
|
3443
|
-
style: "dim"
|
|
3444
|
-
});
|
|
3445
|
-
}
|
|
3446
|
-
if (item.depends_on && item.depends_on.length > 0) {
|
|
3447
|
-
details.push({
|
|
3448
|
-
text: `Depends on: ${item.depends_on.join(", ")}`,
|
|
3449
|
-
style: "warning"
|
|
3450
|
-
});
|
|
3451
|
-
}
|
|
3452
|
-
if (item.format) {
|
|
3453
|
-
details.push({ text: `Format: ${item.format}`, style: "dim" });
|
|
3454
|
-
}
|
|
3455
|
-
if (item.items) {
|
|
3456
|
-
details.push({
|
|
3457
|
-
text: `Items type: ${item.items.type}`,
|
|
3458
|
-
style: "dim"
|
|
3459
|
-
});
|
|
3460
|
-
}
|
|
3461
|
-
return {
|
|
3462
|
-
title: item.title || item.key,
|
|
3463
|
-
key: item.key,
|
|
3464
|
-
description: item.description,
|
|
3465
|
-
details
|
|
3466
|
-
};
|
|
3467
|
-
}
|
|
3468
|
-
}
|
|
3469
|
-
);
|
|
3470
|
-
var InfoFieldItemSchema = withFormatter(
|
|
3471
|
-
BaseFieldItemSchema.extend({
|
|
3472
|
-
type: zod.z.literal("info_field"),
|
|
3473
|
-
description: zod.z.string(),
|
|
3474
|
-
// From need.help_text
|
|
3475
|
-
title: zod.z.string().optional()
|
|
3476
|
-
// Optional title
|
|
3477
|
-
}),
|
|
3478
|
-
{
|
|
3479
|
-
format: (item) => ({
|
|
3480
|
-
title: item.title || "Info",
|
|
3481
|
-
key: item.key,
|
|
3482
|
-
description: item.description,
|
|
3483
|
-
details: [{ text: item.description, style: "normal" }]
|
|
3484
|
-
})
|
|
3485
|
-
}
|
|
3486
|
-
);
|
|
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
|
+
});
|
|
3487
3742
|
var FieldsetItemSchema = BaseFieldItemSchema.extend({
|
|
3488
3743
|
type: zod.z.literal("fieldset"),
|
|
3489
3744
|
title: zod.z.string(),
|
|
@@ -3503,6 +3758,53 @@ var RootFieldItemSchema = zod.z.union([
|
|
|
3503
3758
|
FieldsetItemSchema
|
|
3504
3759
|
]);
|
|
3505
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
|
+
|
|
3506
3808
|
// src/services/implementations.ts
|
|
3507
3809
|
async function fetchImplementationNeeds({
|
|
3508
3810
|
api,
|
|
@@ -3668,6 +3970,7 @@ var listActionInputFieldsPlugin = definePlugin(
|
|
|
3668
3970
|
itemType: "RootField",
|
|
3669
3971
|
inputSchema: ListActionInputFieldsInputSchema,
|
|
3670
3972
|
outputSchema: RootFieldItemSchema,
|
|
3973
|
+
formatter: rootFieldItemFormatter,
|
|
3671
3974
|
defaultPageSize: DEFAULT_PAGE_SIZE,
|
|
3672
3975
|
resolvers: {
|
|
3673
3976
|
app: appKeyResolver,
|
|
@@ -3676,10 +3979,7 @@ var listActionInputFieldsPlugin = definePlugin(
|
|
|
3676
3979
|
connection: connectionIdResolver,
|
|
3677
3980
|
inputs: inputsAllOptionalResolver
|
|
3678
3981
|
},
|
|
3679
|
-
handler: async ({
|
|
3680
|
-
sdk: sdk2,
|
|
3681
|
-
options
|
|
3682
|
-
}) => {
|
|
3982
|
+
handler: async ({ sdk: sdk2, options }) => {
|
|
3683
3983
|
const { api, getVersionedImplementationId } = sdk2.context;
|
|
3684
3984
|
const appKey = "app" in options ? options.app : options.appKey;
|
|
3685
3985
|
const actionKey = "action" in options ? options.action : options.actionKey;
|
|
@@ -3727,26 +4027,7 @@ var listActionInputFieldsPlugin = definePlugin(
|
|
|
3727
4027
|
}
|
|
3728
4028
|
})
|
|
3729
4029
|
);
|
|
3730
|
-
var InputFieldChoiceItemSchema =
|
|
3731
|
-
format: (item) => {
|
|
3732
|
-
const title = item.label || item.key || "Choice";
|
|
3733
|
-
const details = [];
|
|
3734
|
-
if (item.label && item.key && item.label !== item.key) {
|
|
3735
|
-
details.push({ text: `Key: ${item.key}`, style: "dim" });
|
|
3736
|
-
}
|
|
3737
|
-
if (item.sample && item.sample !== item.key) {
|
|
3738
|
-
details.push({ text: `Sample: ${item.sample}`, style: "dim" });
|
|
3739
|
-
}
|
|
3740
|
-
if (item.value && item.value !== item.key) {
|
|
3741
|
-
details.push({ text: `Value: ${item.value}`, style: "normal" });
|
|
3742
|
-
}
|
|
3743
|
-
return {
|
|
3744
|
-
title,
|
|
3745
|
-
key: item.key,
|
|
3746
|
-
details
|
|
3747
|
-
};
|
|
3748
|
-
}
|
|
3749
|
-
});
|
|
4030
|
+
var InputFieldChoiceItemSchema = NeedChoicesSchema;
|
|
3750
4031
|
var ListActionInputFieldChoicesDescription = "Get the available choices for a dynamic dropdown input field";
|
|
3751
4032
|
var ListActionInputFieldChoicesBaseSchema = zod.z.object({
|
|
3752
4033
|
connection: ConnectionPropertySchema.optional().describe(
|
|
@@ -3790,6 +4071,24 @@ var ListActionInputFieldChoicesInputSchema = zod.z.union([
|
|
|
3790
4071
|
ListActionInputFieldChoicesSchemaDeprecated
|
|
3791
4072
|
]).describe(ListActionInputFieldChoicesDescription);
|
|
3792
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
|
+
|
|
3793
4092
|
// src/plugins/listActionInputFieldChoices/index.ts
|
|
3794
4093
|
function transformNeedChoicesToInputFieldChoiceItem(choice) {
|
|
3795
4094
|
return {
|
|
@@ -3807,6 +4106,7 @@ var listActionInputFieldChoicesPlugin = definePlugin(
|
|
|
3807
4106
|
itemType: "InputFieldChoice",
|
|
3808
4107
|
inputSchema: ListActionInputFieldChoicesInputSchema,
|
|
3809
4108
|
outputSchema: InputFieldChoiceItemSchema,
|
|
4109
|
+
formatter: inputFieldChoiceItemFormatter,
|
|
3810
4110
|
defaultPageSize: DEFAULT_PAGE_SIZE,
|
|
3811
4111
|
resolvers: {
|
|
3812
4112
|
app: appKeyResolver,
|
|
@@ -3816,10 +4116,7 @@ var listActionInputFieldChoicesPlugin = definePlugin(
|
|
|
3816
4116
|
inputField: inputFieldKeyResolver,
|
|
3817
4117
|
inputs: inputsAllOptionalResolver
|
|
3818
4118
|
},
|
|
3819
|
-
handler: async ({
|
|
3820
|
-
sdk: sdk2,
|
|
3821
|
-
options
|
|
3822
|
-
}) => {
|
|
4119
|
+
handler: async ({ sdk: sdk2, options }) => {
|
|
3823
4120
|
const { api, getVersionedImplementationId } = sdk2.context;
|
|
3824
4121
|
const appKey = "app" in options ? options.app : options.appKey;
|
|
3825
4122
|
const actionKey = "action" in options ? options.action : options.actionKey;
|
|
@@ -4071,7 +4368,10 @@ var ListConnectionsQuerySchema = connections.ListConnectionsQuerySchema.omit({
|
|
|
4071
4368
|
// SDK specific property for pagination/iterable helpers
|
|
4072
4369
|
cursor: zod.z.string().optional().describe("Cursor to start from")
|
|
4073
4370
|
}).describe("List available connections with optional filtering");
|
|
4074
|
-
var ConnectionItemSchema =
|
|
4371
|
+
var ConnectionItemSchema = connections.ConnectionItemSchema;
|
|
4372
|
+
|
|
4373
|
+
// src/formatters/connection.ts
|
|
4374
|
+
var connectionItemFormatter = {
|
|
4075
4375
|
format: (item) => {
|
|
4076
4376
|
const details = [];
|
|
4077
4377
|
if (item.identifier) {
|
|
@@ -4096,17 +4396,19 @@ var ConnectionItemSchema = withFormatter(connections.ConnectionItemSchema, {
|
|
|
4096
4396
|
details
|
|
4097
4397
|
};
|
|
4098
4398
|
}
|
|
4099
|
-
}
|
|
4399
|
+
};
|
|
4100
4400
|
|
|
4101
4401
|
// src/plugins/listConnections/index.ts
|
|
4102
4402
|
var listConnectionsPlugin = definePlugin(
|
|
4103
4403
|
(sdk) => createPaginatedPluginMethod(sdk, {
|
|
4404
|
+
...zapierPagination,
|
|
4104
4405
|
name: "listConnections",
|
|
4105
4406
|
categories: ["connection"],
|
|
4106
4407
|
type: "list",
|
|
4107
4408
|
itemType: "Connection",
|
|
4108
4409
|
inputSchema: ListConnectionsQuerySchema,
|
|
4109
4410
|
outputSchema: ConnectionItemSchema,
|
|
4411
|
+
formatter: connectionItemFormatter,
|
|
4110
4412
|
defaultPageSize: DEFAULT_PAGE_SIZE,
|
|
4111
4413
|
resolvers: { app: appKeyResolver },
|
|
4112
4414
|
handler: async ({ sdk: sdk2, options }) => {
|
|
@@ -4179,8 +4481,7 @@ var listConnectionsPlugin = definePlugin(
|
|
|
4179
4481
|
...response,
|
|
4180
4482
|
data: response.data.map(transformConnectionItem)
|
|
4181
4483
|
};
|
|
4182
|
-
}
|
|
4183
|
-
extractCursor: (response) => extractCursor(response.links)
|
|
4484
|
+
}
|
|
4184
4485
|
})
|
|
4185
4486
|
);
|
|
4186
4487
|
var ListClientCredentialsQuerySchema = clientCredentials.ListClientCredentialsQuerySchema.omit({
|
|
@@ -4194,58 +4495,49 @@ var ListClientCredentialsQuerySchema = clientCredentials.ListClientCredentialsQu
|
|
|
4194
4495
|
// SDK specific property for pagination/iterable helpers
|
|
4195
4496
|
cursor: zod.z.string().optional().describe("Cursor to start from")
|
|
4196
4497
|
}).describe("List client credentials for the authenticated user");
|
|
4197
|
-
var ClientCredentialsItemSchema =
|
|
4198
|
-
|
|
4199
|
-
|
|
4200
|
-
|
|
4201
|
-
|
|
4202
|
-
|
|
4203
|
-
|
|
4204
|
-
|
|
4205
|
-
|
|
4206
|
-
}
|
|
4207
|
-
|
|
4208
|
-
|
|
4209
|
-
details.push({
|
|
4210
|
-
text: `Created: ${new Date(item.created_at).toLocaleDateString()}`,
|
|
4211
|
-
style: "dim"
|
|
4212
|
-
});
|
|
4213
|
-
}
|
|
4214
|
-
return {
|
|
4215
|
-
title: item.name,
|
|
4216
|
-
id: item.client_id,
|
|
4217
|
-
details
|
|
4218
|
-
};
|
|
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
|
+
});
|
|
4219
4510
|
}
|
|
4220
|
-
|
|
4221
|
-
|
|
4222
|
-
|
|
4223
|
-
|
|
4224
|
-
|
|
4225
|
-
format: (item) => {
|
|
4226
|
-
return {
|
|
4227
|
-
title: item.name,
|
|
4228
|
-
id: item.client_id,
|
|
4229
|
-
details: [
|
|
4230
|
-
{
|
|
4231
|
-
text: `Client Secret: ${item.client_secret}`,
|
|
4232
|
-
style: "accent"
|
|
4233
|
-
}
|
|
4234
|
-
]
|
|
4235
|
-
};
|
|
4511
|
+
if (item.created_at) {
|
|
4512
|
+
details.push({
|
|
4513
|
+
text: `Created: ${new Date(item.created_at).toLocaleDateString()}`,
|
|
4514
|
+
style: "dim"
|
|
4515
|
+
});
|
|
4236
4516
|
}
|
|
4517
|
+
return { title: item.name, id: item.client_id, details };
|
|
4237
4518
|
}
|
|
4238
|
-
|
|
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
|
+
};
|
|
4239
4529
|
|
|
4240
4530
|
// src/plugins/listClientCredentials/index.ts
|
|
4241
4531
|
var listClientCredentialsPlugin = definePlugin(
|
|
4242
4532
|
(sdk) => createPaginatedPluginMethod(sdk, {
|
|
4533
|
+
...zapierPagination,
|
|
4243
4534
|
name: "listClientCredentials",
|
|
4244
4535
|
categories: ["client-credentials"],
|
|
4245
4536
|
type: "list",
|
|
4246
4537
|
itemType: "ClientCredentials",
|
|
4247
4538
|
inputSchema: ListClientCredentialsQuerySchema,
|
|
4248
4539
|
outputSchema: ClientCredentialsItemSchema,
|
|
4540
|
+
formatter: clientCredentialsItemFormatter,
|
|
4249
4541
|
defaultPageSize: DEFAULT_PAGE_SIZE,
|
|
4250
4542
|
handler: async ({
|
|
4251
4543
|
sdk: sdk2,
|
|
@@ -4266,8 +4558,7 @@ var listClientCredentialsPlugin = definePlugin(
|
|
|
4266
4558
|
requiredScopes: ["credentials"]
|
|
4267
4559
|
}
|
|
4268
4560
|
);
|
|
4269
|
-
}
|
|
4270
|
-
extractCursor: (response) => extractCursor(response.links)
|
|
4561
|
+
}
|
|
4271
4562
|
})
|
|
4272
4563
|
);
|
|
4273
4564
|
var CreateClientCredentialsSchema = clientCredentials.CreateClientCredentialsRequestSchema.omit({ allowed_scopes: true }).extend({
|
|
@@ -4285,6 +4576,7 @@ var createClientCredentialsPlugin = definePlugin(
|
|
|
4285
4576
|
itemType: "ClientCredentials",
|
|
4286
4577
|
inputSchema: CreateClientCredentialsSchema,
|
|
4287
4578
|
outputSchema: ClientCredentialsCreatedItemSchema,
|
|
4579
|
+
formatter: clientCredentialsCreatedItemFormatter,
|
|
4288
4580
|
confirm: "create-secret",
|
|
4289
4581
|
resolvers: { name: clientCredentialsNameResolver },
|
|
4290
4582
|
handler: async ({ sdk: sdk2, options }) => {
|
|
@@ -4351,6 +4643,7 @@ var getAppPlugin = definePlugin(
|
|
|
4351
4643
|
itemType: "App",
|
|
4352
4644
|
inputSchema: GetAppInputSchema,
|
|
4353
4645
|
outputSchema: AppItemSchema,
|
|
4646
|
+
formatter: appItemFormatter,
|
|
4354
4647
|
resolvers: { app: appKeyResolver },
|
|
4355
4648
|
handler: async ({ sdk: sdk2, options }) => {
|
|
4356
4649
|
const appKey = "app" in options ? options.app : options.appKey;
|
|
@@ -4384,6 +4677,7 @@ var getActionPlugin = definePlugin(
|
|
|
4384
4677
|
itemType: "Action",
|
|
4385
4678
|
inputSchema: GetActionInputSchema,
|
|
4386
4679
|
outputSchema: ActionItemSchema,
|
|
4680
|
+
formatter: actionItemFormatter,
|
|
4387
4681
|
resolvers: {
|
|
4388
4682
|
app: appKeyResolver,
|
|
4389
4683
|
actionType: actionTypeResolver,
|
|
@@ -4430,6 +4724,7 @@ var getConnectionPlugin = definePlugin(
|
|
|
4430
4724
|
itemType: "Connection",
|
|
4431
4725
|
inputSchema: GetConnectionParamSchema,
|
|
4432
4726
|
outputSchema: ConnectionItemSchema,
|
|
4727
|
+
formatter: connectionItemFormatter,
|
|
4433
4728
|
resolvers: { connection: connectionIdGenericResolver },
|
|
4434
4729
|
handler: async ({ sdk: sdk2, options }) => {
|
|
4435
4730
|
const { api } = sdk2.context;
|
|
@@ -4470,6 +4765,7 @@ var findFirstConnectionPlugin = definePlugin(
|
|
|
4470
4765
|
itemType: "Connection",
|
|
4471
4766
|
inputSchema: FindFirstConnectionSchema,
|
|
4472
4767
|
outputSchema: ConnectionItemSchema,
|
|
4768
|
+
formatter: connectionItemFormatter,
|
|
4473
4769
|
handler: async ({ sdk: sdk2, options = {} }) => {
|
|
4474
4770
|
const connectionsResponse = await sdk2.listConnections({
|
|
4475
4771
|
...options,
|
|
@@ -4505,6 +4801,7 @@ var findUniqueConnectionPlugin = definePlugin(
|
|
|
4505
4801
|
itemType: "Connection",
|
|
4506
4802
|
inputSchema: FindUniqueConnectionSchema,
|
|
4507
4803
|
outputSchema: ConnectionItemSchema,
|
|
4804
|
+
formatter: connectionItemFormatter,
|
|
4508
4805
|
handler: async ({ sdk: sdk2, options = {} }) => {
|
|
4509
4806
|
const connectionsResponse = await sdk2.listConnections({
|
|
4510
4807
|
...options,
|
|
@@ -4562,6 +4859,29 @@ var RunActionSchemaDeprecated = zod.z.object({
|
|
|
4562
4859
|
actionKey: ActionKeyPropertySchema
|
|
4563
4860
|
}).merge(RunActionBaseSchema);
|
|
4564
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
|
+
};
|
|
4565
4885
|
async function executeAction(actionOptions) {
|
|
4566
4886
|
const {
|
|
4567
4887
|
api,
|
|
@@ -4691,6 +5011,7 @@ var runActionPlugin = definePlugin(
|
|
|
4691
5011
|
itemType: "ActionResult",
|
|
4692
5012
|
inputSchema: RunActionInputSchema,
|
|
4693
5013
|
outputSchema: ActionResultItemSchema,
|
|
5014
|
+
formatter: actionResultItemFormatter,
|
|
4694
5015
|
resolvers: {
|
|
4695
5016
|
app: appKeyResolver,
|
|
4696
5017
|
actionType: actionTypeResolver,
|
|
@@ -4698,10 +5019,7 @@ var runActionPlugin = definePlugin(
|
|
|
4698
5019
|
connection: connectionIdResolver,
|
|
4699
5020
|
inputs: inputsResolver
|
|
4700
5021
|
},
|
|
4701
|
-
handler: async ({
|
|
4702
|
-
sdk: sdk2,
|
|
4703
|
-
options
|
|
4704
|
-
}) => {
|
|
5022
|
+
handler: async ({ sdk: sdk2, options }) => {
|
|
4705
5023
|
const { api } = sdk2.context;
|
|
4706
5024
|
const appKey = "app" in options ? options.app : options.appKey;
|
|
4707
5025
|
const actionKey = "action" in options ? options.action : options.actionKey;
|
|
@@ -4754,7 +5072,9 @@ var runActionPlugin = definePlugin(
|
|
|
4754
5072
|
}
|
|
4755
5073
|
return {
|
|
4756
5074
|
data: result.results || [],
|
|
4757
|
-
|
|
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
|
|
4758
5078
|
};
|
|
4759
5079
|
}
|
|
4760
5080
|
});
|
|
@@ -4784,26 +5104,19 @@ var RelayRequestSchema = zod.z.object({
|
|
|
4784
5104
|
var RelayFetchSchema = RelayRequestSchema;
|
|
4785
5105
|
|
|
4786
5106
|
// src/utils/logging.ts
|
|
4787
|
-
var
|
|
4788
|
-
function logDeprecation(message) {
|
|
4789
|
-
if (loggedDeprecations.has(message)) return;
|
|
4790
|
-
loggedDeprecations.add(message);
|
|
4791
|
-
console.warn(`[zapier-sdk] Deprecation: ${message}`);
|
|
4792
|
-
}
|
|
4793
|
-
function resetDeprecationWarnings() {
|
|
4794
|
-
loggedDeprecations.clear();
|
|
4795
|
-
}
|
|
5107
|
+
var { logDeprecation: logDeprecation2, resetDeprecationWarnings: resetDeprecationWarnings2 } = createDeprecationLogger("zapier-sdk");
|
|
4796
5108
|
|
|
4797
5109
|
// src/plugins/request/index.ts
|
|
4798
5110
|
var requestPlugin = definePlugin(
|
|
4799
5111
|
(sdk) => createPluginMethod(sdk, {
|
|
4800
5112
|
name: "request",
|
|
4801
5113
|
packages: ["cli", "mcp"],
|
|
4802
|
-
categories: ["http"
|
|
5114
|
+
categories: ["http"],
|
|
5115
|
+
deprecation: { message: "Use fetch() instead." },
|
|
4803
5116
|
returnType: "Response",
|
|
4804
5117
|
inputSchema: RelayRequestSchema,
|
|
4805
5118
|
handler: async ({ sdk: sdk2, options }) => {
|
|
4806
|
-
|
|
5119
|
+
logDeprecation2("request() is deprecated. Use fetch() instead.");
|
|
4807
5120
|
const {
|
|
4808
5121
|
url,
|
|
4809
5122
|
method,
|
|
@@ -5023,7 +5336,7 @@ async function listAppsForSlugsPage({
|
|
|
5023
5336
|
data: implementationsEnvelope.results.map(
|
|
5024
5337
|
normalizeImplementationMetaToAppItem
|
|
5025
5338
|
),
|
|
5026
|
-
nextCursor:
|
|
5339
|
+
nextCursor: implementationsEnvelope.next ? extractCursorFromUrl(implementationsEnvelope.next) : void 0
|
|
5027
5340
|
};
|
|
5028
5341
|
}
|
|
5029
5342
|
function findManifestEntry({
|
|
@@ -5301,36 +5614,36 @@ var manifestPlugin = definePlugin(
|
|
|
5301
5614
|
}
|
|
5302
5615
|
);
|
|
5303
5616
|
var GetProfileSchema = zod.z.object({}).optional().describe("Get current user's profile information");
|
|
5304
|
-
var UserProfileItemSchema =
|
|
5305
|
-
zod.z.
|
|
5306
|
-
|
|
5307
|
-
|
|
5308
|
-
|
|
5309
|
-
|
|
5310
|
-
|
|
5311
|
-
|
|
5312
|
-
|
|
5313
|
-
|
|
5314
|
-
|
|
5315
|
-
|
|
5316
|
-
|
|
5317
|
-
|
|
5318
|
-
|
|
5319
|
-
}
|
|
5320
|
-
|
|
5321
|
-
|
|
5322
|
-
|
|
5323
|
-
|
|
5324
|
-
|
|
5325
|
-
}
|
|
5326
|
-
return {
|
|
5327
|
-
title: item.full_name,
|
|
5328
|
-
id: item.id,
|
|
5329
|
-
details
|
|
5330
|
-
};
|
|
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
|
+
});
|
|
5331
5639
|
}
|
|
5640
|
+
return {
|
|
5641
|
+
title: item.full_name,
|
|
5642
|
+
id: item.id,
|
|
5643
|
+
details
|
|
5644
|
+
};
|
|
5332
5645
|
}
|
|
5333
|
-
|
|
5646
|
+
};
|
|
5334
5647
|
|
|
5335
5648
|
// src/plugins/getProfile/index.ts
|
|
5336
5649
|
var getProfilePlugin = definePlugin(
|
|
@@ -5341,6 +5654,7 @@ var getProfilePlugin = definePlugin(
|
|
|
5341
5654
|
itemType: "Profile",
|
|
5342
5655
|
inputSchema: GetProfileSchema,
|
|
5343
5656
|
outputSchema: UserProfileItemSchema,
|
|
5657
|
+
formatter: userProfileItemFormatter,
|
|
5344
5658
|
handler: async ({ sdk: sdk2 }) => {
|
|
5345
5659
|
const profile = await sdk2.context.api.get(
|
|
5346
5660
|
"/zapier/api/v4/profile/",
|
|
@@ -5437,7 +5751,7 @@ function createDebugLogger(enabled) {
|
|
|
5437
5751
|
}
|
|
5438
5752
|
return (message, data) => {
|
|
5439
5753
|
if (data === void 0 || data === "") {
|
|
5440
|
-
console.
|
|
5754
|
+
console.error(`[Zapier SDK] ${message}`);
|
|
5441
5755
|
return;
|
|
5442
5756
|
}
|
|
5443
5757
|
if (utilModule) {
|
|
@@ -5446,9 +5760,9 @@ function createDebugLogger(enabled) {
|
|
|
5446
5760
|
depth: null,
|
|
5447
5761
|
breakLength: 80
|
|
5448
5762
|
});
|
|
5449
|
-
console.
|
|
5763
|
+
console.error(`[Zapier SDK] ${message}`, formatted);
|
|
5450
5764
|
} else {
|
|
5451
|
-
console.
|
|
5765
|
+
console.error(`[Zapier SDK] ${message}`, data);
|
|
5452
5766
|
}
|
|
5453
5767
|
};
|
|
5454
5768
|
}
|
|
@@ -5647,7 +5961,8 @@ async function pollUntilComplete(options) {
|
|
|
5647
5961
|
pendingStatus = DEFAULT_PENDING_STATUS,
|
|
5648
5962
|
isPending,
|
|
5649
5963
|
resultExtractor = (response) => response,
|
|
5650
|
-
signal
|
|
5964
|
+
signal,
|
|
5965
|
+
maxPollingIntervalMs
|
|
5651
5966
|
} = options;
|
|
5652
5967
|
if (timeoutMs <= 0) {
|
|
5653
5968
|
throw new ZapierValidationError("Timeout must be greater than 0", {
|
|
@@ -5659,6 +5974,14 @@ async function pollUntilComplete(options) {
|
|
|
5659
5974
|
details: { initialDelay }
|
|
5660
5975
|
});
|
|
5661
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
|
+
}
|
|
5662
5985
|
if (signal?.aborted) throw makeAbortError();
|
|
5663
5986
|
const startTime = Date.now();
|
|
5664
5987
|
let attempts = 0;
|
|
@@ -5681,7 +6004,8 @@ async function pollUntilComplete(options) {
|
|
|
5681
6004
|
if (attempts > 0) {
|
|
5682
6005
|
const interval = getPollingInterval(elapsedTime);
|
|
5683
6006
|
const waitTime = calculateErrorBackoffMs(interval, errorCount);
|
|
5684
|
-
|
|
6007
|
+
const cappedWaitTime = maxPollingIntervalMs === void 0 ? waitTime : Math.min(waitTime, maxPollingIntervalMs);
|
|
6008
|
+
await sleep(cappedWaitTime, signal);
|
|
5685
6009
|
if (signal?.aborted) throw makeAbortError();
|
|
5686
6010
|
}
|
|
5687
6011
|
attempts++;
|
|
@@ -5964,17 +6288,17 @@ function resolveCredentialsFromEnv(sdkBaseUrl) {
|
|
|
5964
6288
|
}
|
|
5965
6289
|
}
|
|
5966
6290
|
if (globalThis.process?.env?.ZAPIER_TOKEN) {
|
|
5967
|
-
|
|
6291
|
+
logDeprecation2(
|
|
5968
6292
|
"ZAPIER_TOKEN is deprecated. Use ZAPIER_CREDENTIALS instead."
|
|
5969
6293
|
);
|
|
5970
6294
|
return globalThis.process?.env?.ZAPIER_TOKEN;
|
|
5971
6295
|
}
|
|
5972
6296
|
if (globalThis.process?.env?.ZAPIER_AUTH_CLIENT_ID) {
|
|
5973
|
-
|
|
6297
|
+
logDeprecation2(
|
|
5974
6298
|
"ZAPIER_AUTH_CLIENT_ID is deprecated. Use ZAPIER_CREDENTIALS_CLIENT_ID instead."
|
|
5975
6299
|
);
|
|
5976
6300
|
if (globalThis.process?.env?.ZAPIER_AUTH_BASE_URL) {
|
|
5977
|
-
|
|
6301
|
+
logDeprecation2(
|
|
5978
6302
|
"ZAPIER_AUTH_BASE_URL is deprecated. Use ZAPIER_CREDENTIALS_BASE_URL instead."
|
|
5979
6303
|
);
|
|
5980
6304
|
}
|
|
@@ -6008,7 +6332,7 @@ async function resolveCredentials(options = {}) {
|
|
|
6008
6332
|
return options.credentials;
|
|
6009
6333
|
}
|
|
6010
6334
|
if (options.token !== void 0) {
|
|
6011
|
-
|
|
6335
|
+
logDeprecation2(
|
|
6012
6336
|
"The `token` option is deprecated. Use `credentials` instead."
|
|
6013
6337
|
);
|
|
6014
6338
|
return options.token;
|
|
@@ -6250,7 +6574,7 @@ async function tryStoredClientCredentialToken(options) {
|
|
|
6250
6574
|
const cached = await readCachedToken(cacheKey, cache);
|
|
6251
6575
|
if (cached !== void 0) {
|
|
6252
6576
|
if (options.debug)
|
|
6253
|
-
console.
|
|
6577
|
+
console.error(
|
|
6254
6578
|
`[auth] Using cached token (clientId: ${activeCredential.clientId})`
|
|
6255
6579
|
);
|
|
6256
6580
|
emitAuthResolved(options.onEvent, "client_credentials");
|
|
@@ -6269,7 +6593,7 @@ async function tryStoredClientCredentialToken(options) {
|
|
|
6269
6593
|
);
|
|
6270
6594
|
}
|
|
6271
6595
|
if (options.debug)
|
|
6272
|
-
console.
|
|
6596
|
+
console.error(
|
|
6273
6597
|
`[auth] Using stored client credential (clientId: ${storedCredential.clientId})`
|
|
6274
6598
|
);
|
|
6275
6599
|
const token = await resolveAuthTokenFromCredentials(
|
|
@@ -6291,7 +6615,7 @@ async function resolveAuthToken(options = {}) {
|
|
|
6291
6615
|
const storedToken = await tryStoredClientCredentialToken(options);
|
|
6292
6616
|
if (storedToken !== void 0) return storedToken;
|
|
6293
6617
|
if (options.debug) {
|
|
6294
|
-
console.
|
|
6618
|
+
console.error("[auth] Using JWT (no stored client credential found)");
|
|
6295
6619
|
}
|
|
6296
6620
|
const jwtToken = await getTokenFromCliLogin({
|
|
6297
6621
|
onEvent: options.onEvent,
|
|
@@ -6321,7 +6645,7 @@ async function resolveAuthTokenFromCredentials(credentials, options) {
|
|
|
6321
6645
|
const cached = await readCachedToken(cacheKey, cache);
|
|
6322
6646
|
if (cached !== void 0) {
|
|
6323
6647
|
if (options.debug) {
|
|
6324
|
-
console.
|
|
6648
|
+
console.error(`[auth] Using cached token (clientId: ${clientId})`);
|
|
6325
6649
|
}
|
|
6326
6650
|
return cached;
|
|
6327
6651
|
}
|
|
@@ -6331,7 +6655,7 @@ async function resolveAuthTokenFromCredentials(credentials, options) {
|
|
|
6331
6655
|
const recheck = await readCachedToken(cacheKey, cache);
|
|
6332
6656
|
if (recheck !== void 0) {
|
|
6333
6657
|
if (options.debug) {
|
|
6334
|
-
console.
|
|
6658
|
+
console.error(
|
|
6335
6659
|
`[auth] Using cached token (clientId: ${clientId}, locked recheck)`
|
|
6336
6660
|
);
|
|
6337
6661
|
}
|
|
@@ -6394,7 +6718,7 @@ async function invalidateCredentialsToken(options) {
|
|
|
6394
6718
|
}
|
|
6395
6719
|
|
|
6396
6720
|
// src/sdk-version.ts
|
|
6397
|
-
var SDK_VERSION = (typeof process !== "undefined" && process.env ? "0.
|
|
6721
|
+
var SDK_VERSION = (typeof process !== "undefined" && process.env ? "0.68.0" : void 0) || "unknown";
|
|
6398
6722
|
|
|
6399
6723
|
// src/utils/open-url.ts
|
|
6400
6724
|
var nodePrefix = "node:";
|
|
@@ -6479,6 +6803,7 @@ var PollApprovalResponseSchema = zod.z.object({
|
|
|
6479
6803
|
status: ApprovalStatusSchema,
|
|
6480
6804
|
approval_id: zod.z.string()
|
|
6481
6805
|
});
|
|
6806
|
+
var APPROVAL_MAX_POLLING_INTERVAL_MS = 5e3;
|
|
6482
6807
|
function parseRateLimitHeaders(response) {
|
|
6483
6808
|
const info = {};
|
|
6484
6809
|
const retryAfter = response.headers.get("retry-after");
|
|
@@ -7187,6 +7512,7 @@ var ZapierApiClient = class {
|
|
|
7187
7512
|
})
|
|
7188
7513
|
),
|
|
7189
7514
|
timeoutMs,
|
|
7515
|
+
maxPollingIntervalMs: APPROVAL_MAX_POLLING_INTERVAL_MS,
|
|
7190
7516
|
isPending: (body2) => {
|
|
7191
7517
|
const parsed = PollApprovalResponseSchema.safeParse(body2);
|
|
7192
7518
|
return parsed.success && parsed.data.status === "pending_approval";
|
|
@@ -7554,6 +7880,7 @@ var tablesDefaults = {
|
|
|
7554
7880
|
var listTablesPlugin = definePlugin(
|
|
7555
7881
|
(sdk) => createPaginatedPluginMethod(sdk, {
|
|
7556
7882
|
...tablesDefaults,
|
|
7883
|
+
...zapierPagination,
|
|
7557
7884
|
name: "listTables",
|
|
7558
7885
|
type: "list",
|
|
7559
7886
|
itemType: "Table",
|
|
@@ -7609,8 +7936,7 @@ var listTablesPlugin = definePlugin(
|
|
|
7609
7936
|
data: response.data.map(transformTableItem),
|
|
7610
7937
|
links: response.links
|
|
7611
7938
|
};
|
|
7612
|
-
}
|
|
7613
|
-
extractCursor: (response) => extractCursor(response.links)
|
|
7939
|
+
}
|
|
7614
7940
|
})
|
|
7615
7941
|
);
|
|
7616
7942
|
var GetTableApiResponseSchema = zod.z.object({
|
|
@@ -7713,6 +8039,15 @@ var deleteTablePlugin = definePlugin(
|
|
|
7713
8039
|
})
|
|
7714
8040
|
);
|
|
7715
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
|
+
|
|
7716
8051
|
// src/plugins/tables/listTableFields/index.ts
|
|
7717
8052
|
var listTableFieldsPlugin = definePlugin(
|
|
7718
8053
|
(sdk) => createPluginMethod(sdk, {
|
|
@@ -7722,6 +8057,7 @@ var listTableFieldsPlugin = definePlugin(
|
|
|
7722
8057
|
itemType: "Field",
|
|
7723
8058
|
inputSchema: ListTableFieldsOptionsInputSchema,
|
|
7724
8059
|
outputSchema: FieldItemSchema,
|
|
8060
|
+
formatter: tableFieldItemFormatter,
|
|
7725
8061
|
resolvers: { table: tableIdResolver },
|
|
7726
8062
|
handler: async ({ sdk: sdk2, options }) => {
|
|
7727
8063
|
const { api } = sdk2.context;
|
|
@@ -7794,6 +8130,7 @@ var createTableFieldsPlugin = definePlugin(
|
|
|
7794
8130
|
returnType: "FieldItem[]",
|
|
7795
8131
|
inputSchema: CreateTableFieldsOptionsInputSchema,
|
|
7796
8132
|
outputSchema: FieldItemSchema,
|
|
8133
|
+
formatter: tableFieldItemFormatter,
|
|
7797
8134
|
resolvers: { table: tableIdResolver, fields: tableFieldsResolver },
|
|
7798
8135
|
handler: async ({ sdk: sdk2, options }) => {
|
|
7799
8136
|
const tableId = "table" in options ? options.table : options.tableId;
|
|
@@ -7872,21 +8209,13 @@ var RecordApiItemSchema = zod.z.object({
|
|
|
7872
8209
|
is_source_record: zod.z.boolean().nullable().optional(),
|
|
7873
8210
|
deleted_at: zod.z.string().nullable().optional()
|
|
7874
8211
|
});
|
|
7875
|
-
var
|
|
8212
|
+
var RecordItemSchema = zod.z.object({
|
|
7876
8213
|
id: zod.z.string(),
|
|
7877
8214
|
data: zod.z.record(zod.z.string(), zod.z.unknown()),
|
|
7878
8215
|
created_at: zod.z.string(),
|
|
7879
8216
|
edited_at: zod.z.string(),
|
|
7880
8217
|
deleted_at: zod.z.string().nullable().optional()
|
|
7881
8218
|
});
|
|
7882
|
-
var RecordItemSchema = withFormatter(RecordItemSchemaBase, {
|
|
7883
|
-
format: (item) => ({
|
|
7884
|
-
title: `Record ${item.id}`,
|
|
7885
|
-
id: item.id,
|
|
7886
|
-
data: item.data,
|
|
7887
|
-
details: []
|
|
7888
|
-
})
|
|
7889
|
-
});
|
|
7890
8219
|
var GetTableRecordApiResponseSchema = zod.z.object({
|
|
7891
8220
|
data: RecordApiItemSchema
|
|
7892
8221
|
});
|
|
@@ -7910,9 +8239,9 @@ var tableRecordFormatter = {
|
|
|
7910
8239
|
if (context) return context;
|
|
7911
8240
|
const hasFieldIds = Object.keys(item.data).some(isFieldId);
|
|
7912
8241
|
if (!hasFieldIds) return {};
|
|
7913
|
-
const
|
|
7914
|
-
|
|
7915
|
-
});
|
|
8242
|
+
const table = params.table ?? params.tableId;
|
|
8243
|
+
if (!table) return {};
|
|
8244
|
+
const { data: fields } = await sdk.listTableFields({ table });
|
|
7916
8245
|
return Object.fromEntries(fields.map((f) => [f.id, f.name]));
|
|
7917
8246
|
},
|
|
7918
8247
|
format: (item, fieldLabels) => ({
|
|
@@ -8037,10 +8366,7 @@ var listTableRecordsPlugin = definePlugin(
|
|
|
8037
8366
|
sort: tableSortResolver
|
|
8038
8367
|
},
|
|
8039
8368
|
formatter: tableRecordFormatter,
|
|
8040
|
-
handler: async ({
|
|
8041
|
-
sdk: sdk2,
|
|
8042
|
-
options
|
|
8043
|
-
}) => {
|
|
8369
|
+
handler: async ({ sdk: sdk2, options }) => {
|
|
8044
8370
|
const { api } = sdk2.context;
|
|
8045
8371
|
const tableId = "table" in options ? options.table : options.tableId;
|
|
8046
8372
|
const translator = await createFieldKeyTranslator({
|
|
@@ -8290,85 +8616,13 @@ var updateTableRecordsPlugin = definePlugin(
|
|
|
8290
8616
|
}
|
|
8291
8617
|
})
|
|
8292
8618
|
);
|
|
8293
|
-
|
|
8294
|
-
|
|
8295
|
-
|
|
8296
|
-
|
|
8297
|
-
|
|
8298
|
-
|
|
8299
|
-
|
|
8300
|
-
account: { title: "Account" },
|
|
8301
|
-
app: { title: "App", titlePlural: "Apps" },
|
|
8302
|
-
connection: { title: "Connection" },
|
|
8303
|
-
action: { title: "Action" },
|
|
8304
|
-
"client-credentials": {
|
|
8305
|
-
title: "Client Credentials",
|
|
8306
|
-
titlePlural: "Client Credentials"
|
|
8307
|
-
},
|
|
8308
|
-
table: { title: "Table" },
|
|
8309
|
-
trigger: { title: "Trigger" },
|
|
8310
|
-
"code-workflow": {
|
|
8311
|
-
title: "Code Workflow",
|
|
8312
|
-
titlePlural: "Code Workflows"
|
|
8313
|
-
},
|
|
8314
|
-
http: { title: "HTTP Request" },
|
|
8315
|
-
utility: { title: "Utility", titlePlural: "Utilities" },
|
|
8316
|
-
other: { title: "Other" }
|
|
8317
|
-
};
|
|
8318
|
-
var knownCategories = Object.keys(categoryDefinitions);
|
|
8319
|
-
function buildRegistry({
|
|
8320
|
-
sdk,
|
|
8321
|
-
meta,
|
|
8322
|
-
packageFilter
|
|
8323
|
-
}) {
|
|
8324
|
-
const functions = Object.keys(meta).filter((key) => {
|
|
8325
|
-
const property = sdk[key];
|
|
8326
|
-
if (typeof property === "function") return true;
|
|
8327
|
-
const [rootKey] = key.split(".");
|
|
8328
|
-
const rootProperty = sdk[rootKey];
|
|
8329
|
-
return typeof rootProperty === "object" && rootProperty !== null;
|
|
8330
|
-
}).map((key) => {
|
|
8331
|
-
const m = meta[key];
|
|
8332
|
-
return {
|
|
8333
|
-
name: key,
|
|
8334
|
-
description: m.description,
|
|
8335
|
-
type: m.type,
|
|
8336
|
-
itemType: m.itemType,
|
|
8337
|
-
returnType: m.returnType,
|
|
8338
|
-
inputSchema: canonicalInputSchema(m.inputSchema),
|
|
8339
|
-
inputParameters: m.inputParameters,
|
|
8340
|
-
outputSchema: m.outputSchema,
|
|
8341
|
-
categories: m.categories || [],
|
|
8342
|
-
resolvers: m.resolvers,
|
|
8343
|
-
formatter: m.formatter,
|
|
8344
|
-
experimental: m.experimental,
|
|
8345
|
-
packages: m.packages,
|
|
8346
|
-
confirm: m.confirm ?? (m.type === "delete" ? "delete" : void 0),
|
|
8347
|
-
deprecation: m.deprecation,
|
|
8348
|
-
aliases: m.aliases,
|
|
8349
|
-
supportsJsonOutput: m.supportsJsonOutput ?? true
|
|
8350
|
-
};
|
|
8351
|
-
}).sort((a, b) => a.name.localeCompare(b.name));
|
|
8352
|
-
const filteredFunctions = packageFilter ? functions.filter((f) => !f.packages || f.packages.includes(packageFilter)) : functions;
|
|
8353
|
-
const filteredCategories = knownCategories.slice().sort((a, b) => {
|
|
8354
|
-
if (a === "other") return 1;
|
|
8355
|
-
if (b === "other") return -1;
|
|
8356
|
-
return categoryDefinitions[a].title.localeCompare(
|
|
8357
|
-
categoryDefinitions[b].title
|
|
8358
|
-
);
|
|
8359
|
-
}).map((categoryKey) => {
|
|
8360
|
-
const categoryFunctions = filteredFunctions.filter(
|
|
8361
|
-
(f) => f.categories.includes(categoryKey) || categoryKey === "other" && !f.categories.some((c) => knownCategories.includes(c))
|
|
8362
|
-
).map((f) => f.name).sort();
|
|
8363
|
-
const definition = categoryDefinitions[categoryKey];
|
|
8364
|
-
return {
|
|
8365
|
-
key: categoryKey,
|
|
8366
|
-
title: definition.title,
|
|
8367
|
-
titlePlural: definition.titlePlural ?? `${definition.title}s`,
|
|
8368
|
-
functions: categoryFunctions
|
|
8369
|
-
};
|
|
8370
|
-
}).filter((category) => category.functions.length > 0);
|
|
8371
|
-
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);
|
|
8372
8626
|
}
|
|
8373
8627
|
|
|
8374
8628
|
// src/plugins/deprecated/authentications.ts
|
|
@@ -8379,11 +8633,13 @@ var listAuthenticationsPlugin = definePlugin(
|
|
|
8379
8633
|
meta: {
|
|
8380
8634
|
listAuthentications: {
|
|
8381
8635
|
packages: ["cli", "mcp"],
|
|
8382
|
-
categories: ["connection"
|
|
8636
|
+
categories: ["connection"],
|
|
8637
|
+
deprecation: { message: "Use listConnections instead." },
|
|
8383
8638
|
type: "list",
|
|
8384
8639
|
itemType: "Connection",
|
|
8385
8640
|
inputSchema: ListConnectionsQuerySchema,
|
|
8386
|
-
outputSchema: ConnectionItemSchema
|
|
8641
|
+
outputSchema: ConnectionItemSchema,
|
|
8642
|
+
formatter: connectionItemFormatter
|
|
8387
8643
|
}
|
|
8388
8644
|
}
|
|
8389
8645
|
}
|
|
@@ -8396,11 +8652,13 @@ var getAuthenticationPlugin = definePlugin(
|
|
|
8396
8652
|
meta: {
|
|
8397
8653
|
getAuthentication: {
|
|
8398
8654
|
packages: ["cli", "mcp"],
|
|
8399
|
-
categories: ["connection"
|
|
8655
|
+
categories: ["connection"],
|
|
8656
|
+
deprecation: { message: "Use getConnection instead." },
|
|
8400
8657
|
type: "item",
|
|
8401
8658
|
itemType: "Connection",
|
|
8402
8659
|
inputSchema: GetConnectionParamSchema,
|
|
8403
|
-
outputSchema: ConnectionItemSchema
|
|
8660
|
+
outputSchema: ConnectionItemSchema,
|
|
8661
|
+
formatter: connectionItemFormatter
|
|
8404
8662
|
}
|
|
8405
8663
|
}
|
|
8406
8664
|
}
|
|
@@ -8413,11 +8671,13 @@ var findFirstAuthenticationPlugin = definePlugin(
|
|
|
8413
8671
|
meta: {
|
|
8414
8672
|
findFirstAuthentication: {
|
|
8415
8673
|
packages: ["cli", "mcp"],
|
|
8416
|
-
categories: ["connection"
|
|
8674
|
+
categories: ["connection"],
|
|
8675
|
+
deprecation: { message: "Use findFirstConnection instead." },
|
|
8417
8676
|
type: "item",
|
|
8418
8677
|
itemType: "Connection",
|
|
8419
8678
|
inputSchema: FindFirstConnectionSchema,
|
|
8420
|
-
outputSchema: ConnectionItemSchema
|
|
8679
|
+
outputSchema: ConnectionItemSchema,
|
|
8680
|
+
formatter: connectionItemFormatter
|
|
8421
8681
|
}
|
|
8422
8682
|
}
|
|
8423
8683
|
}
|
|
@@ -8430,11 +8690,13 @@ var findUniqueAuthenticationPlugin = definePlugin(
|
|
|
8430
8690
|
meta: {
|
|
8431
8691
|
findUniqueAuthentication: {
|
|
8432
8692
|
packages: ["cli", "mcp"],
|
|
8433
|
-
categories: ["connection"
|
|
8693
|
+
categories: ["connection"],
|
|
8694
|
+
deprecation: { message: "Use findUniqueConnection instead." },
|
|
8434
8695
|
type: "item",
|
|
8435
8696
|
itemType: "Connection",
|
|
8436
8697
|
inputSchema: FindUniqueConnectionSchema,
|
|
8437
|
-
outputSchema: ConnectionItemSchema
|
|
8698
|
+
outputSchema: ConnectionItemSchema,
|
|
8699
|
+
formatter: connectionItemFormatter
|
|
8438
8700
|
}
|
|
8439
8701
|
}
|
|
8440
8702
|
}
|
|
@@ -8448,11 +8710,13 @@ var listInputFieldsDeprecatedPlugin = definePlugin(
|
|
|
8448
8710
|
context: {
|
|
8449
8711
|
meta: {
|
|
8450
8712
|
listInputFields: {
|
|
8451
|
-
categories: ["action"
|
|
8713
|
+
categories: ["action"],
|
|
8714
|
+
deprecation: { message: "Use listActionInputFields instead." },
|
|
8452
8715
|
type: "list",
|
|
8453
8716
|
itemType: "RootField",
|
|
8454
8717
|
inputSchema: ListActionInputFieldsInputSchema,
|
|
8455
8718
|
outputSchema: RootFieldItemSchema,
|
|
8719
|
+
formatter: rootFieldItemFormatter,
|
|
8456
8720
|
defaultPageSize: DEFAULT_PAGE_SIZE
|
|
8457
8721
|
}
|
|
8458
8722
|
}
|
|
@@ -8465,11 +8729,15 @@ var listInputFieldChoicesDeprecatedPlugin = definePlugin(
|
|
|
8465
8729
|
context: {
|
|
8466
8730
|
meta: {
|
|
8467
8731
|
listInputFieldChoices: {
|
|
8468
|
-
categories: ["action"
|
|
8732
|
+
categories: ["action"],
|
|
8733
|
+
deprecation: {
|
|
8734
|
+
message: "Use listActionInputFieldChoices instead."
|
|
8735
|
+
},
|
|
8469
8736
|
type: "list",
|
|
8470
8737
|
itemType: "InputFieldChoiceItem",
|
|
8471
8738
|
inputSchema: ListActionInputFieldChoicesInputSchema,
|
|
8472
8739
|
outputSchema: InputFieldChoiceItemSchema,
|
|
8740
|
+
formatter: inputFieldChoiceItemFormatter,
|
|
8473
8741
|
defaultPageSize: DEFAULT_PAGE_SIZE
|
|
8474
8742
|
}
|
|
8475
8743
|
}
|
|
@@ -8482,7 +8750,8 @@ var getInputFieldsSchemaDeprecatedPlugin = definePlugin(
|
|
|
8482
8750
|
context: {
|
|
8483
8751
|
meta: {
|
|
8484
8752
|
getInputFieldsSchema: {
|
|
8485
|
-
categories: ["action"
|
|
8753
|
+
categories: ["action"],
|
|
8754
|
+
deprecation: { message: "Use getActionInputFieldsSchema instead." },
|
|
8486
8755
|
type: "function",
|
|
8487
8756
|
inputSchema: GetActionInputFieldsSchemaInputSchema
|
|
8488
8757
|
}
|
|
@@ -8546,7 +8815,7 @@ function createConsoleTransport() {
|
|
|
8546
8815
|
return {
|
|
8547
8816
|
async emit(subject, event) {
|
|
8548
8817
|
try {
|
|
8549
|
-
console.
|
|
8818
|
+
console.error(
|
|
8550
8819
|
"[SDK Telemetry]",
|
|
8551
8820
|
JSON.stringify({ subject, properties: event }, null, 2)
|
|
8552
8821
|
);
|
|
@@ -8755,6 +9024,35 @@ function buildMethodCalledEvent(data, context = {}) {
|
|
|
8755
9024
|
};
|
|
8756
9025
|
}
|
|
8757
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
|
+
|
|
8758
9056
|
// src/plugins/eventEmission/index.ts
|
|
8759
9057
|
var TELEMETRY_EMIT_TIMEOUT_MS = 300;
|
|
8760
9058
|
var registeredListeners = {};
|
|
@@ -8885,6 +9183,8 @@ var eventEmissionPlugin = definePlugin(
|
|
|
8885
9183
|
}
|
|
8886
9184
|
}
|
|
8887
9185
|
if (!config.enabled) {
|
|
9186
|
+
const noopEmitMethodCalled = () => {
|
|
9187
|
+
};
|
|
8888
9188
|
return {
|
|
8889
9189
|
context: {
|
|
8890
9190
|
eventEmission: {
|
|
@@ -8902,12 +9202,13 @@ var eventEmissionPlugin = definePlugin(
|
|
|
8902
9202
|
visitor_id: null,
|
|
8903
9203
|
correlation_id: null
|
|
8904
9204
|
}),
|
|
8905
|
-
emitMethodCalled: () => {
|
|
8906
|
-
},
|
|
8907
9205
|
flush: async () => {
|
|
8908
9206
|
},
|
|
8909
9207
|
close: async () => {
|
|
8910
9208
|
}
|
|
9209
|
+
},
|
|
9210
|
+
hooks: {
|
|
9211
|
+
onMethodEnd: makeMethodEndHook(noopEmitMethodCalled)
|
|
8911
9212
|
}
|
|
8912
9213
|
}
|
|
8913
9214
|
};
|
|
@@ -9078,6 +9379,20 @@ var eventEmissionPlugin = definePlugin(
|
|
|
9078
9379
|
);
|
|
9079
9380
|
removeExistingListeners();
|
|
9080
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
|
+
};
|
|
9081
9396
|
return {
|
|
9082
9397
|
context: {
|
|
9083
9398
|
eventEmission: {
|
|
@@ -9089,22 +9404,11 @@ var eventEmissionPlugin = definePlugin(
|
|
|
9089
9404
|
);
|
|
9090
9405
|
},
|
|
9091
9406
|
createBaseEvent: createBaseEventHelper,
|
|
9092
|
-
emitMethodCalled: (data) => {
|
|
9093
|
-
const event = {
|
|
9094
|
-
...buildMethodCalledEvent(data),
|
|
9095
|
-
call_context: config.callContext ?? "sdk"
|
|
9096
|
-
};
|
|
9097
|
-
trackEmission(
|
|
9098
|
-
silentEmit(
|
|
9099
|
-
transport,
|
|
9100
|
-
METHOD_CALLED_EVENT_SUBJECT,
|
|
9101
|
-
event,
|
|
9102
|
-
getUserContext
|
|
9103
|
-
)
|
|
9104
|
-
);
|
|
9105
|
-
},
|
|
9106
9407
|
flush,
|
|
9107
9408
|
close
|
|
9409
|
+
},
|
|
9410
|
+
hooks: {
|
|
9411
|
+
onMethodEnd: makeMethodEndHook(emitMethodCalled)
|
|
9108
9412
|
}
|
|
9109
9413
|
}
|
|
9110
9414
|
};
|
|
@@ -9116,78 +9420,22 @@ function createOptionsPlugin(options) {
|
|
|
9116
9420
|
return () => ({ context: { options } });
|
|
9117
9421
|
}
|
|
9118
9422
|
function createSdk() {
|
|
9119
|
-
|
|
9120
|
-
|
|
9121
|
-
|
|
9122
|
-
|
|
9123
|
-
const registryCache = /* @__PURE__ */ new Map();
|
|
9124
|
-
const sdk = {
|
|
9125
|
-
...properties,
|
|
9126
|
-
get context() {
|
|
9127
|
-
return frozenContext;
|
|
9128
|
-
},
|
|
9129
|
-
getContext: () => frozenContext,
|
|
9130
|
-
// runtime compat shim, not in types
|
|
9131
|
-
getRegistry(options) {
|
|
9132
|
-
const cacheKey = options?.package ?? "__all__";
|
|
9133
|
-
if (!registryCache.has(cacheKey)) {
|
|
9134
|
-
registryCache.set(
|
|
9135
|
-
cacheKey,
|
|
9136
|
-
buildRegistry({
|
|
9137
|
-
sdk,
|
|
9138
|
-
meta: frozenContext.meta,
|
|
9139
|
-
packageFilter: options?.package
|
|
9140
|
-
})
|
|
9141
|
-
);
|
|
9142
|
-
}
|
|
9143
|
-
return registryCache.get(cacheKey);
|
|
9144
|
-
},
|
|
9145
|
-
addPlugin(plugin, options) {
|
|
9146
|
-
const pluginResult = plugin({
|
|
9147
|
-
...properties,
|
|
9148
|
-
context: frozenContext
|
|
9149
|
-
});
|
|
9150
|
-
const { context: pluginContext, ...pluginProperties } = pluginResult;
|
|
9151
|
-
const { meta: pluginMeta, ...pluginContextRest } = pluginContext ?? {};
|
|
9152
|
-
const existingProperties = properties;
|
|
9153
|
-
const existingContext = context;
|
|
9154
|
-
const existingMeta = context.meta ?? {};
|
|
9155
|
-
const collisions = [];
|
|
9156
|
-
for (const key of Object.keys(pluginProperties)) {
|
|
9157
|
-
if (key in existingProperties) collisions.push(`method "${key}"`);
|
|
9158
|
-
}
|
|
9159
|
-
for (const key of Object.keys(pluginContextRest)) {
|
|
9160
|
-
if (key in existingContext) collisions.push(`context.${key}`);
|
|
9161
|
-
}
|
|
9162
|
-
if (collisions.length > 0 && !options?.override) {
|
|
9163
|
-
const name = plugin.name || "anonymous plugin";
|
|
9164
|
-
console.warn(
|
|
9165
|
-
`[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.`
|
|
9166
|
-
);
|
|
9167
|
-
return buildSdk(properties, context);
|
|
9168
|
-
}
|
|
9169
|
-
const mergedProperties = { ...properties, ...pluginProperties };
|
|
9170
|
-
const mergedContext = {
|
|
9171
|
-
...context,
|
|
9172
|
-
...pluginContextRest,
|
|
9173
|
-
meta: { ...existingMeta, ...pluginMeta ?? {} }
|
|
9174
|
-
};
|
|
9175
|
-
return buildSdk(
|
|
9176
|
-
mergedProperties,
|
|
9177
|
-
mergedContext
|
|
9178
|
-
);
|
|
9179
|
-
}
|
|
9180
|
-
};
|
|
9181
|
-
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());
|
|
9182
9427
|
}
|
|
9183
9428
|
function createZapierSdkWithoutRegistry(options = {}) {
|
|
9184
|
-
|
|
9429
|
+
logDeprecation2(
|
|
9185
9430
|
"createZapierSdkWithoutRegistry is deprecated; use createZapierSdk instead. getRegistry is now available on every sdk."
|
|
9186
9431
|
);
|
|
9187
9432
|
return createZapierSdk(options);
|
|
9188
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
|
+
}
|
|
9189
9437
|
function createZapierSdk(options = {}) {
|
|
9190
|
-
return
|
|
9438
|
+
return withDeprecatedAddPlugin(createZapierSdkStack(options).toSdk());
|
|
9191
9439
|
}
|
|
9192
9440
|
var BaseSdkOptionsSchema = zod.z.object({
|
|
9193
9441
|
credentials: CredentialsSchema.optional().describe(
|
|
@@ -9250,7 +9498,7 @@ var BaseSdkOptionsSchema = zod.z.object({
|
|
|
9250
9498
|
|
|
9251
9499
|
// src/plugins/registry/index.ts
|
|
9252
9500
|
var registryPlugin = definePlugin((_sdk) => {
|
|
9253
|
-
|
|
9501
|
+
logDeprecation2(
|
|
9254
9502
|
"registryPlugin is deprecated and a no-op; getRegistry is now built into every sdk. Remove .addPlugin(registryPlugin)."
|
|
9255
9503
|
);
|
|
9256
9504
|
return {};
|
|
@@ -9267,12 +9515,14 @@ exports.AuthenticationIdPropertySchema = AuthenticationIdPropertySchema;
|
|
|
9267
9515
|
exports.BaseSdkOptionsSchema = BaseSdkOptionsSchema;
|
|
9268
9516
|
exports.CONTEXT_CACHE_MAX_SIZE = CONTEXT_CACHE_MAX_SIZE;
|
|
9269
9517
|
exports.CONTEXT_CACHE_TTL_MS = CONTEXT_CACHE_TTL_MS;
|
|
9518
|
+
exports.CORE_ERROR_SYMBOL = CORE_ERROR_SYMBOL;
|
|
9270
9519
|
exports.ClientCredentialsObjectSchema = ClientCredentialsObjectSchema;
|
|
9271
9520
|
exports.ConnectionEntrySchema = ConnectionEntrySchema;
|
|
9272
9521
|
exports.ConnectionIdPropertySchema = ConnectionIdPropertySchema;
|
|
9273
9522
|
exports.ConnectionPropertySchema = ConnectionPropertySchema;
|
|
9274
9523
|
exports.ConnectionsMapSchema = ConnectionsMapSchema;
|
|
9275
9524
|
exports.ConnectionsPropertySchema = ConnectionsPropertySchema;
|
|
9525
|
+
exports.CoreErrorCode = CoreErrorCode;
|
|
9276
9526
|
exports.CredentialsFunctionSchema = CredentialsFunctionSchema;
|
|
9277
9527
|
exports.CredentialsObjectSchema = CredentialsObjectSchema;
|
|
9278
9528
|
exports.CredentialsSchema = CredentialsSchema;
|
|
@@ -9329,6 +9579,7 @@ exports.ZapierUnknownError = ZapierUnknownError;
|
|
|
9329
9579
|
exports.ZapierValidationError = ZapierValidationError;
|
|
9330
9580
|
exports.actionKeyResolver = actionKeyResolver;
|
|
9331
9581
|
exports.actionTypeResolver = actionTypeResolver;
|
|
9582
|
+
exports.addPlugin = addPlugin;
|
|
9332
9583
|
exports.apiPlugin = apiPlugin;
|
|
9333
9584
|
exports.appKeyResolver = appKeyResolver;
|
|
9334
9585
|
exports.appsPlugin = appsPlugin;
|
|
@@ -9350,17 +9601,21 @@ exports.connectionIdResolver = connectionIdResolver;
|
|
|
9350
9601
|
exports.connectionsPlugin = connectionsPlugin;
|
|
9351
9602
|
exports.createBaseEvent = createBaseEvent;
|
|
9352
9603
|
exports.createClientCredentialsPlugin = createClientCredentialsPlugin;
|
|
9604
|
+
exports.createCorePlugin = createCorePlugin;
|
|
9353
9605
|
exports.createFunction = createFunction;
|
|
9354
9606
|
exports.createMemoryCache = createMemoryCache;
|
|
9355
9607
|
exports.createOptionsPlugin = createOptionsPlugin;
|
|
9356
9608
|
exports.createPaginatedPluginMethod = createPaginatedPluginMethod;
|
|
9357
9609
|
exports.createPluginMethod = createPluginMethod;
|
|
9610
|
+
exports.createPluginStack = createPluginStack;
|
|
9358
9611
|
exports.createSdk = createSdk;
|
|
9359
9612
|
exports.createTableFieldsPlugin = createTableFieldsPlugin;
|
|
9360
9613
|
exports.createTablePlugin = createTablePlugin;
|
|
9361
9614
|
exports.createTableRecordsPlugin = createTableRecordsPlugin;
|
|
9362
9615
|
exports.createZapierApi = createZapierApi;
|
|
9616
|
+
exports.createZapierCoreStack = createZapierCoreStack;
|
|
9363
9617
|
exports.createZapierSdk = createZapierSdk;
|
|
9618
|
+
exports.createZapierSdkStack = createZapierSdkStack;
|
|
9364
9619
|
exports.createZapierSdkWithoutRegistry = createZapierSdkWithoutRegistry;
|
|
9365
9620
|
exports.definePlugin = definePlugin;
|
|
9366
9621
|
exports.deleteClientCredentialsPlugin = deleteClientCredentialsPlugin;
|
|
@@ -9382,6 +9637,8 @@ exports.getBaseUrlFromCredentials = getBaseUrlFromCredentials;
|
|
|
9382
9637
|
exports.getCiPlatform = getCiPlatform;
|
|
9383
9638
|
exports.getClientIdFromCredentials = getClientIdFromCredentials;
|
|
9384
9639
|
exports.getConnectionPlugin = getConnectionPlugin;
|
|
9640
|
+
exports.getCoreErrorCause = getCoreErrorCause;
|
|
9641
|
+
exports.getCoreErrorCode = getCoreErrorCode;
|
|
9385
9642
|
exports.getCpuTime = getCpuTime;
|
|
9386
9643
|
exports.getCurrentTimestamp = getCurrentTimestamp;
|
|
9387
9644
|
exports.getMemoryUsage = getMemoryUsage;
|
|
@@ -9406,6 +9663,7 @@ exports.invalidateCredentialsToken = invalidateCredentialsToken;
|
|
|
9406
9663
|
exports.isCi = isCi;
|
|
9407
9664
|
exports.isCliLoginAvailable = isCliLoginAvailable;
|
|
9408
9665
|
exports.isClientCredentials = isClientCredentials;
|
|
9666
|
+
exports.isCoreError = isCoreError;
|
|
9409
9667
|
exports.isCredentialsFunction = isCredentialsFunction;
|
|
9410
9668
|
exports.isCredentialsObject = isCredentialsObject;
|
|
9411
9669
|
exports.isPkceCredentials = isPkceCredentials;
|
|
@@ -9419,17 +9677,18 @@ exports.listConnectionsPlugin = listConnectionsPlugin;
|
|
|
9419
9677
|
exports.listTableFieldsPlugin = listTableFieldsPlugin;
|
|
9420
9678
|
exports.listTableRecordsPlugin = listTableRecordsPlugin;
|
|
9421
9679
|
exports.listTablesPlugin = listTablesPlugin;
|
|
9422
|
-
exports.logDeprecation =
|
|
9680
|
+
exports.logDeprecation = logDeprecation2;
|
|
9423
9681
|
exports.manifestPlugin = manifestPlugin;
|
|
9424
9682
|
exports.parseConcurrencyEnvVar = parseConcurrencyEnvVar;
|
|
9425
9683
|
exports.readManifestFromFile = readManifestFromFile;
|
|
9426
9684
|
exports.registryPlugin = registryPlugin;
|
|
9427
9685
|
exports.requestPlugin = requestPlugin;
|
|
9428
|
-
exports.resetDeprecationWarnings =
|
|
9686
|
+
exports.resetDeprecationWarnings = resetDeprecationWarnings2;
|
|
9429
9687
|
exports.resolveAuthToken = resolveAuthToken;
|
|
9430
9688
|
exports.resolveCredentials = resolveCredentials;
|
|
9431
9689
|
exports.resolveCredentialsFromEnv = resolveCredentialsFromEnv;
|
|
9432
9690
|
exports.runActionPlugin = runActionPlugin;
|
|
9691
|
+
exports.runInMethodScope = runInMethodScope;
|
|
9433
9692
|
exports.runWithTelemetryContext = runWithTelemetryContext;
|
|
9434
9693
|
exports.tableFieldIdsResolver = tableFieldIdsResolver;
|
|
9435
9694
|
exports.tableFieldsResolver = tableFieldsResolver;
|
|
@@ -9449,3 +9708,4 @@ exports.updateTableRecordsPlugin = updateTableRecordsPlugin;
|
|
|
9449
9708
|
exports.workflowIdResolver = workflowIdResolver;
|
|
9450
9709
|
exports.workflowRunIdResolver = workflowRunIdResolver;
|
|
9451
9710
|
exports.workflowVersionIdResolver = workflowVersionIdResolver;
|
|
9711
|
+
exports.zapierAdaptError = zapierAdaptError;
|