@zapier/zapier-sdk 0.77.0 → 0.77.2
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 +26 -0
- package/dist/experimental.cjs +4 -3
- package/dist/experimental.d.mts +2 -3
- package/dist/experimental.d.ts +918 -934
- package/dist/experimental.mjs +4 -3
- package/dist/{index-BZShISEr.d.mts → index-kC0bJpsG.d.mts} +25 -3
- package/dist/{index-BZShISEr.d.ts → index-kC0bJpsG.d.ts} +25 -3
- package/dist/index.cjs +4 -3
- package/dist/index.d.mts +1 -2
- package/dist/index.d.ts +6 -81
- package/dist/index.mjs +4 -3
- package/package.json +3 -3
- package/dist/api/approval-review-stream.d.ts +0 -25
- package/dist/api/approval-review-stream.d.ts.map +0 -1
- package/dist/api/approval-review-stream.js +0 -104
- package/dist/api/auth.d.ts +0 -14
- package/dist/api/auth.d.ts.map +0 -1
- package/dist/api/auth.js +0 -77
- package/dist/api/client.d.ts +0 -9
- package/dist/api/client.d.ts.map +0 -1
- package/dist/api/client.js +0 -1232
- package/dist/api/concurrency.d.ts +0 -28
- package/dist/api/concurrency.d.ts.map +0 -1
- package/dist/api/concurrency.js +0 -90
- package/dist/api/debug.d.ts +0 -14
- package/dist/api/debug.d.ts.map +0 -1
- package/dist/api/debug.js +0 -133
- package/dist/api/error-classification.d.ts +0 -19
- package/dist/api/error-classification.d.ts.map +0 -1
- package/dist/api/error-classification.js +0 -31
- package/dist/api/index.d.ts +0 -33
- package/dist/api/index.d.ts.map +0 -1
- package/dist/api/index.js +0 -44
- package/dist/api/polling.d.ts +0 -64
- package/dist/api/polling.d.ts.map +0 -1
- package/dist/api/polling.js +0 -180
- package/dist/api/schemas.d.ts +0 -423
- package/dist/api/schemas.d.ts.map +0 -1
- package/dist/api/schemas.js +0 -323
- package/dist/api/sse-parser.d.ts +0 -51
- package/dist/api/sse-parser.d.ts.map +0 -1
- package/dist/api/sse-parser.js +0 -95
- package/dist/api/types.d.ts +0 -215
- package/dist/api/types.d.ts.map +0 -1
- package/dist/api/types.js +0 -1
- package/dist/auth.d.ts +0 -149
- package/dist/auth.d.ts.map +0 -1
- package/dist/auth.js +0 -526
- package/dist/cache.d.ts +0 -50
- package/dist/cache.d.ts.map +0 -1
- package/dist/cache.js +0 -47
- package/dist/constants.d.ts +0 -84
- package/dist/constants.d.ts.map +0 -1
- package/dist/constants.js +0 -122
- package/dist/core-stack.d.ts +0 -24
- package/dist/core-stack.d.ts.map +0 -1
- package/dist/core-stack.js +0 -32
- package/dist/credentials.d.ts +0 -57
- package/dist/credentials.d.ts.map +0 -1
- package/dist/credentials.js +0 -184
- package/dist/define/apps-entrypoint.d.ts +0 -3
- package/dist/define/apps-entrypoint.d.ts.map +0 -1
- package/dist/define/apps-entrypoint.js +0 -1
- package/dist/define/apps-registry-keys.d.ts +0 -2
- package/dist/define/apps-registry-keys.d.ts.map +0 -1
- package/dist/define/apps-registry-keys.js +0 -2
- package/dist/define/apps-registry.d.ts +0 -13
- package/dist/define/apps-registry.d.ts.map +0 -1
- package/dist/define/apps-registry.js +0 -31
- package/dist/define/apps-registry.json +0 -9010
- package/dist/define/apps.d.ts +0 -11
- package/dist/define/apps.d.ts.map +0 -1
- package/dist/define/apps.js +0 -2
- package/dist/define/define.d.ts +0 -13
- package/dist/define/define.d.ts.map +0 -1
- package/dist/define/define.js +0 -93
- package/dist/define/helpers.d.ts +0 -8
- package/dist/define/helpers.d.ts.map +0 -1
- package/dist/define/helpers.js +0 -6
- package/dist/define/index.d.ts +0 -5
- package/dist/define/index.d.ts.map +0 -1
- package/dist/define/index.js +0 -2
- package/dist/define/types.d.ts +0 -246
- package/dist/define/types.d.ts.map +0 -1
- package/dist/define/types.js +0 -1
- package/dist/experimental.d.ts.map +0 -1
- package/dist/experimental.js +0 -232
- package/dist/formatters/action.d.ts +0 -4
- package/dist/formatters/action.d.ts.map +0 -1
- package/dist/formatters/action.js +0 -18
- package/dist/formatters/actionResult.d.ts +0 -3
- package/dist/formatters/actionResult.d.ts.map +0 -1
- package/dist/formatters/actionResult.js +0 -25
- package/dist/formatters/app.d.ts +0 -4
- package/dist/formatters/app.d.ts.map +0 -1
- package/dist/formatters/app.js +0 -10
- package/dist/formatters/clientCredentials.d.ts +0 -5
- package/dist/formatters/clientCredentials.d.ts.map +0 -1
- package/dist/formatters/clientCredentials.js +0 -27
- package/dist/formatters/connection.d.ts +0 -4
- package/dist/formatters/connection.d.ts.map +0 -1
- package/dist/formatters/connection.js +0 -26
- package/dist/formatters/field.d.ts +0 -4
- package/dist/formatters/field.d.ts.map +0 -1
- package/dist/formatters/field.js +0 -51
- package/dist/formatters/index.d.ts +0 -2
- package/dist/formatters/index.d.ts.map +0 -1
- package/dist/formatters/index.js +0 -1
- package/dist/formatters/inputFieldChoice.d.ts +0 -4
- package/dist/formatters/inputFieldChoice.d.ts.map +0 -1
- package/dist/formatters/inputFieldChoice.js +0 -16
- package/dist/formatters/tableField.d.ts +0 -4
- package/dist/formatters/tableField.d.ts.map +0 -1
- package/dist/formatters/tableField.js +0 -7
- package/dist/formatters/tableRecord.d.ts +0 -8
- package/dist/formatters/tableRecord.d.ts.map +0 -1
- package/dist/formatters/tableRecord.js +0 -24
- package/dist/formatters/triggerInbox.d.ts +0 -4
- package/dist/formatters/triggerInbox.d.ts.map +0 -1
- package/dist/formatters/triggerInbox.js +0 -31
- package/dist/formatters/triggerMessage.d.ts +0 -5
- package/dist/formatters/triggerMessage.d.ts.map +0 -1
- package/dist/formatters/triggerMessage.js +0 -34
- package/dist/formatters/userProfile.d.ts +0 -4
- package/dist/formatters/userProfile.d.ts.map +0 -1
- package/dist/formatters/userProfile.js +0 -19
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -94
- package/dist/plugins/api/index.d.ts +0 -30
- package/dist/plugins/api/index.d.ts.map +0 -1
- package/dist/plugins/api/index.js +0 -35
- package/dist/plugins/apps/index.d.ts +0 -118
- package/dist/plugins/apps/index.d.ts.map +0 -1
- package/dist/plugins/apps/index.js +0 -156
- package/dist/plugins/apps/schemas.d.ts +0 -50
- package/dist/plugins/apps/schemas.d.ts.map +0 -1
- package/dist/plugins/apps/schemas.js +0 -37
- package/dist/plugins/capabilities/index.d.ts +0 -27
- package/dist/plugins/capabilities/index.d.ts.map +0 -1
- package/dist/plugins/capabilities/index.js +0 -75
- package/dist/plugins/codeSubstrate/cancelDurableRun/index.d.ts +0 -70
- package/dist/plugins/codeSubstrate/cancelDurableRun/index.d.ts.map +0 -1
- package/dist/plugins/codeSubstrate/cancelDurableRun/index.js +0 -28
- package/dist/plugins/codeSubstrate/cancelDurableRun/schemas.d.ts +0 -11
- package/dist/plugins/codeSubstrate/cancelDurableRun/schemas.d.ts.map +0 -1
- package/dist/plugins/codeSubstrate/cancelDurableRun/schemas.js +0 -12
- package/dist/plugins/codeSubstrate/createWorkflow/index.d.ts +0 -49
- package/dist/plugins/codeSubstrate/createWorkflow/index.d.ts.map +0 -1
- package/dist/plugins/codeSubstrate/createWorkflow/index.js +0 -24
- package/dist/plugins/codeSubstrate/createWorkflow/schemas.d.ts +0 -20
- package/dist/plugins/codeSubstrate/createWorkflow/schemas.d.ts.map +0 -1
- package/dist/plugins/codeSubstrate/createWorkflow/schemas.js +0 -42
- package/dist/plugins/codeSubstrate/deleteWorkflow/index.d.ts +0 -75
- package/dist/plugins/codeSubstrate/deleteWorkflow/index.d.ts.map +0 -1
- package/dist/plugins/codeSubstrate/deleteWorkflow/index.js +0 -28
- package/dist/plugins/codeSubstrate/deleteWorkflow/schemas.d.ts +0 -10
- package/dist/plugins/codeSubstrate/deleteWorkflow/schemas.d.ts.map +0 -1
- package/dist/plugins/codeSubstrate/deleteWorkflow/schemas.js +0 -13
- package/dist/plugins/codeSubstrate/disableWorkflow/index.d.ts +0 -76
- package/dist/plugins/codeSubstrate/disableWorkflow/index.d.ts.map +0 -1
- package/dist/plugins/codeSubstrate/disableWorkflow/index.js +0 -21
- package/dist/plugins/codeSubstrate/disableWorkflow/schemas.d.ts +0 -11
- package/dist/plugins/codeSubstrate/disableWorkflow/schemas.d.ts.map +0 -1
- package/dist/plugins/codeSubstrate/disableWorkflow/schemas.js +0 -12
- package/dist/plugins/codeSubstrate/enableWorkflow/index.d.ts +0 -76
- package/dist/plugins/codeSubstrate/enableWorkflow/index.d.ts.map +0 -1
- package/dist/plugins/codeSubstrate/enableWorkflow/index.js +0 -21
- package/dist/plugins/codeSubstrate/enableWorkflow/schemas.d.ts +0 -11
- package/dist/plugins/codeSubstrate/enableWorkflow/schemas.d.ts.map +0 -1
- package/dist/plugins/codeSubstrate/enableWorkflow/schemas.js +0 -12
- package/dist/plugins/codeSubstrate/getDurableRun/index.d.ts +0 -119
- package/dist/plugins/codeSubstrate/getDurableRun/index.d.ts.map +0 -1
- package/dist/plugins/codeSubstrate/getDurableRun/index.js +0 -21
- package/dist/plugins/codeSubstrate/getDurableRun/schemas.d.ts +0 -178
- package/dist/plugins/codeSubstrate/getDurableRun/schemas.d.ts.map +0 -1
- package/dist/plugins/codeSubstrate/getDurableRun/schemas.js +0 -126
- package/dist/plugins/codeSubstrate/getTriggerRun/index.d.ts +0 -47
- package/dist/plugins/codeSubstrate/getTriggerRun/index.d.ts.map +0 -1
- package/dist/plugins/codeSubstrate/getTriggerRun/index.js +0 -23
- package/dist/plugins/codeSubstrate/getTriggerRun/schemas.d.ts +0 -24
- package/dist/plugins/codeSubstrate/getTriggerRun/schemas.d.ts.map +0 -1
- package/dist/plugins/codeSubstrate/getTriggerRun/schemas.js +0 -30
- package/dist/plugins/codeSubstrate/getWorkflow/index.d.ts +0 -114
- package/dist/plugins/codeSubstrate/getWorkflow/index.d.ts.map +0 -1
- package/dist/plugins/codeSubstrate/getWorkflow/index.js +0 -21
- package/dist/plugins/codeSubstrate/getWorkflow/schemas.d.ts +0 -81
- package/dist/plugins/codeSubstrate/getWorkflow/schemas.d.ts.map +0 -1
- package/dist/plugins/codeSubstrate/getWorkflow/schemas.js +0 -71
- package/dist/plugins/codeSubstrate/getWorkflowRun/index.d.ts +0 -112
- package/dist/plugins/codeSubstrate/getWorkflowRun/index.d.ts.map +0 -1
- package/dist/plugins/codeSubstrate/getWorkflowRun/index.js +0 -25
- package/dist/plugins/codeSubstrate/getWorkflowRun/schemas.d.ts +0 -26
- package/dist/plugins/codeSubstrate/getWorkflowRun/schemas.d.ts.map +0 -1
- package/dist/plugins/codeSubstrate/getWorkflowRun/schemas.js +0 -43
- package/dist/plugins/codeSubstrate/getWorkflowVersion/index.d.ts +0 -132
- package/dist/plugins/codeSubstrate/getWorkflowVersion/index.d.ts.map +0 -1
- package/dist/plugins/codeSubstrate/getWorkflowVersion/index.js +0 -25
- package/dist/plugins/codeSubstrate/getWorkflowVersion/schemas.d.ts +0 -30
- package/dist/plugins/codeSubstrate/getWorkflowVersion/schemas.d.ts.map +0 -1
- package/dist/plugins/codeSubstrate/getWorkflowVersion/schemas.js +0 -35
- package/dist/plugins/codeSubstrate/listDurableRuns/index.d.ts +0 -55
- package/dist/plugins/codeSubstrate/listDurableRuns/index.d.ts.map +0 -1
- package/dist/plugins/codeSubstrate/listDurableRuns/index.js +0 -31
- package/dist/plugins/codeSubstrate/listDurableRuns/schemas.d.ts +0 -73
- package/dist/plugins/codeSubstrate/listDurableRuns/schemas.d.ts.map +0 -1
- package/dist/plugins/codeSubstrate/listDurableRuns/schemas.js +0 -58
- package/dist/plugins/codeSubstrate/listWorkflowRuns/index.d.ts +0 -88
- package/dist/plugins/codeSubstrate/listWorkflowRuns/index.d.ts.map +0 -1
- package/dist/plugins/codeSubstrate/listWorkflowRuns/index.js +0 -34
- package/dist/plugins/codeSubstrate/listWorkflowRuns/schemas.d.ts +0 -63
- package/dist/plugins/codeSubstrate/listWorkflowRuns/schemas.d.ts.map +0 -1
- package/dist/plugins/codeSubstrate/listWorkflowRuns/schemas.js +0 -69
- package/dist/plugins/codeSubstrate/listWorkflowVersions/index.d.ts +0 -98
- package/dist/plugins/codeSubstrate/listWorkflowVersions/index.d.ts.map +0 -1
- package/dist/plugins/codeSubstrate/listWorkflowVersions/index.js +0 -34
- package/dist/plugins/codeSubstrate/listWorkflowVersions/schemas.d.ts +0 -63
- package/dist/plugins/codeSubstrate/listWorkflowVersions/schemas.d.ts.map +0 -1
- package/dist/plugins/codeSubstrate/listWorkflowVersions/schemas.js +0 -58
- package/dist/plugins/codeSubstrate/listWorkflows/index.d.ts +0 -61
- package/dist/plugins/codeSubstrate/listWorkflows/index.d.ts.map +0 -1
- package/dist/plugins/codeSubstrate/listWorkflows/index.js +0 -28
- package/dist/plugins/codeSubstrate/listWorkflows/schemas.d.ts +0 -86
- package/dist/plugins/codeSubstrate/listWorkflows/schemas.d.ts.map +0 -1
- package/dist/plugins/codeSubstrate/listWorkflows/schemas.js +0 -79
- package/dist/plugins/codeSubstrate/publishWorkflowVersion/index.d.ts +0 -150
- package/dist/plugins/codeSubstrate/publishWorkflowVersion/index.d.ts.map +0 -1
- package/dist/plugins/codeSubstrate/publishWorkflowVersion/index.js +0 -80
- package/dist/plugins/codeSubstrate/publishWorkflowVersion/schemas.d.ts +0 -158
- package/dist/plugins/codeSubstrate/publishWorkflowVersion/schemas.d.ts.map +0 -1
- package/dist/plugins/codeSubstrate/publishWorkflowVersion/schemas.js +0 -124
- package/dist/plugins/codeSubstrate/runDurable/index.d.ts +0 -94
- package/dist/plugins/codeSubstrate/runDurable/index.d.ts.map +0 -1
- package/dist/plugins/codeSubstrate/runDurable/index.js +0 -41
- package/dist/plugins/codeSubstrate/runDurable/schemas.d.ts +0 -149
- package/dist/plugins/codeSubstrate/runDurable/schemas.d.ts.map +0 -1
- package/dist/plugins/codeSubstrate/runDurable/schemas.js +0 -95
- package/dist/plugins/codeSubstrate/shared-schemas.d.ts +0 -41
- package/dist/plugins/codeSubstrate/shared-schemas.d.ts.map +0 -1
- package/dist/plugins/codeSubstrate/shared-schemas.js +0 -83
- package/dist/plugins/codeSubstrate/shared.d.ts +0 -72
- package/dist/plugins/codeSubstrate/shared.d.ts.map +0 -1
- package/dist/plugins/codeSubstrate/shared.js +0 -115
- package/dist/plugins/codeSubstrate/triggerWorkflow/index.d.ts +0 -78
- package/dist/plugins/codeSubstrate/triggerWorkflow/index.d.ts.map +0 -1
- package/dist/plugins/codeSubstrate/triggerWorkflow/index.js +0 -40
- package/dist/plugins/codeSubstrate/triggerWorkflow/schemas.d.ts +0 -16
- package/dist/plugins/codeSubstrate/triggerWorkflow/schemas.d.ts.map +0 -1
- package/dist/plugins/codeSubstrate/triggerWorkflow/schemas.js +0 -26
- package/dist/plugins/codeSubstrate/updateWorkflow/index.d.ts +0 -85
- package/dist/plugins/codeSubstrate/updateWorkflow/index.d.ts.map +0 -1
- package/dist/plugins/codeSubstrate/updateWorkflow/index.js +0 -28
- package/dist/plugins/codeSubstrate/updateWorkflow/schemas.d.ts +0 -20
- package/dist/plugins/codeSubstrate/updateWorkflow/schemas.d.ts.map +0 -1
- package/dist/plugins/codeSubstrate/updateWorkflow/schemas.js +0 -37
- package/dist/plugins/connections/index.d.ts +0 -19
- package/dist/plugins/connections/index.d.ts.map +0 -1
- package/dist/plugins/connections/index.js +0 -21
- package/dist/plugins/createClientCredentials/index.d.ts +0 -32
- package/dist/plugins/createClientCredentials/index.d.ts.map +0 -1
- package/dist/plugins/createClientCredentials/index.js +0 -29
- package/dist/plugins/createClientCredentials/schemas.d.ts +0 -18
- package/dist/plugins/createClientCredentials/schemas.d.ts.map +0 -1
- package/dist/plugins/createClientCredentials/schemas.js +0 -16
- package/dist/plugins/createConnection/index.d.ts +0 -189
- package/dist/plugins/createConnection/index.d.ts.map +0 -1
- package/dist/plugins/createConnection/index.js +0 -71
- package/dist/plugins/createConnection/schemas.d.ts +0 -21
- package/dist/plugins/createConnection/schemas.d.ts.map +0 -1
- package/dist/plugins/createConnection/schemas.js +0 -38
- package/dist/plugins/deleteClientCredentials/index.d.ts +0 -48
- package/dist/plugins/deleteClientCredentials/index.d.ts.map +0 -1
- package/dist/plugins/deleteClientCredentials/index.js +0 -21
- package/dist/plugins/deleteClientCredentials/schemas.d.ts +0 -12
- package/dist/plugins/deleteClientCredentials/schemas.d.ts.map +0 -1
- package/dist/plugins/deleteClientCredentials/schemas.js +0 -8
- package/dist/plugins/deprecated/authentications.d.ts +0 -763
- package/dist/plugins/deprecated/authentications.d.ts.map +0 -1
- package/dist/plugins/deprecated/authentications.js +0 -100
- package/dist/plugins/deprecated/inputFields.d.ts +0 -503
- package/dist/plugins/deprecated/inputFields.d.ts.map +0 -1
- package/dist/plugins/deprecated/inputFields.js +0 -81
- package/dist/plugins/eventEmission/builders.d.ts +0 -14
- package/dist/plugins/eventEmission/builders.d.ts.map +0 -1
- package/dist/plugins/eventEmission/builders.js +0 -117
- package/dist/plugins/eventEmission/event-emission-hook.d.ts +0 -10
- package/dist/plugins/eventEmission/event-emission-hook.d.ts.map +0 -1
- package/dist/plugins/eventEmission/event-emission-hook.js +0 -47
- package/dist/plugins/eventEmission/index.d.ts +0 -50
- package/dist/plugins/eventEmission/index.d.ts.map +0 -1
- package/dist/plugins/eventEmission/index.js +0 -398
- package/dist/plugins/eventEmission/method-metadata.d.ts +0 -16
- package/dist/plugins/eventEmission/method-metadata.d.ts.map +0 -1
- package/dist/plugins/eventEmission/method-metadata.js +0 -20
- package/dist/plugins/eventEmission/transport.d.ts +0 -27
- package/dist/plugins/eventEmission/transport.d.ts.map +0 -1
- package/dist/plugins/eventEmission/transport.js +0 -105
- package/dist/plugins/eventEmission/types.d.ts +0 -67
- package/dist/plugins/eventEmission/types.d.ts.map +0 -1
- package/dist/plugins/eventEmission/types.js +0 -1
- package/dist/plugins/eventEmission/utils.d.ts +0 -56
- package/dist/plugins/eventEmission/utils.d.ts.map +0 -1
- package/dist/plugins/eventEmission/utils.js +0 -142
- package/dist/plugins/fetch/index.d.ts +0 -72
- package/dist/plugins/fetch/index.d.ts.map +0 -1
- package/dist/plugins/fetch/index.js +0 -238
- package/dist/plugins/fetch/schemas.d.ts +0 -28
- package/dist/plugins/fetch/schemas.d.ts.map +0 -1
- package/dist/plugins/fetch/schemas.js +0 -52
- package/dist/plugins/findFirstConnection/index.d.ts +0 -115
- package/dist/plugins/findFirstConnection/index.d.ts.map +0 -1
- package/dist/plugins/findFirstConnection/index.js +0 -25
- package/dist/plugins/findFirstConnection/schemas.d.ts +0 -25
- package/dist/plugins/findFirstConnection/schemas.d.ts.map +0 -1
- package/dist/plugins/findFirstConnection/schemas.js +0 -9
- package/dist/plugins/findUniqueConnection/index.d.ts +0 -115
- package/dist/plugins/findUniqueConnection/index.d.ts.map +0 -1
- package/dist/plugins/findUniqueConnection/index.js +0 -28
- package/dist/plugins/findUniqueConnection/schemas.d.ts +0 -25
- package/dist/plugins/findUniqueConnection/schemas.d.ts.map +0 -1
- package/dist/plugins/findUniqueConnection/schemas.js +0 -9
- package/dist/plugins/getAction/index.d.ts +0 -215
- package/dist/plugins/getAction/index.d.ts.map +0 -1
- package/dist/plugins/getAction/index.js +0 -41
- package/dist/plugins/getAction/schemas.d.ts +0 -82
- package/dist/plugins/getAction/schemas.d.ts.map +0 -1
- package/dist/plugins/getAction/schemas.js +0 -22
- package/dist/plugins/getActionInputFieldsSchema/index.d.ts +0 -301
- package/dist/plugins/getActionInputFieldsSchema/index.d.ts.map +0 -1
- package/dist/plugins/getActionInputFieldsSchema/index.js +0 -57
- package/dist/plugins/getActionInputFieldsSchema/schemas.d.ts +0 -97
- package/dist/plugins/getActionInputFieldsSchema/schemas.d.ts.map +0 -1
- package/dist/plugins/getActionInputFieldsSchema/schemas.js +0 -49
- package/dist/plugins/getApp/index.d.ts +0 -146
- package/dist/plugins/getApp/index.d.ts.map +0 -1
- package/dist/plugins/getApp/index.js +0 -24
- package/dist/plugins/getApp/schemas.d.ts +0 -32
- package/dist/plugins/getApp/schemas.d.ts.map +0 -1
- package/dist/plugins/getApp/schemas.js +0 -18
- package/dist/plugins/getConnection/index.d.ts +0 -179
- package/dist/plugins/getConnection/index.d.ts.map +0 -1
- package/dist/plugins/getConnection/index.js +0 -33
- package/dist/plugins/getConnection/schemas.d.ts +0 -12
- package/dist/plugins/getConnection/schemas.d.ts.map +0 -1
- package/dist/plugins/getConnection/schemas.js +0 -14
- package/dist/plugins/getConnectionStartUrl/index.d.ts +0 -206
- package/dist/plugins/getConnectionStartUrl/index.d.ts.map +0 -1
- package/dist/plugins/getConnectionStartUrl/index.js +0 -39
- package/dist/plugins/getConnectionStartUrl/schemas.d.ts +0 -15
- package/dist/plugins/getConnectionStartUrl/schemas.d.ts.map +0 -1
- package/dist/plugins/getConnectionStartUrl/schemas.js +0 -23
- package/dist/plugins/getProfile/index.d.ts +0 -32
- package/dist/plugins/getProfile/index.d.ts.map +0 -1
- package/dist/plugins/getProfile/index.js +0 -28
- package/dist/plugins/getProfile/schemas.d.ts +0 -4
- package/dist/plugins/getProfile/schemas.d.ts.map +0 -1
- package/dist/plugins/getProfile/schemas.js +0 -5
- package/dist/plugins/listActionInputFieldChoices/index.d.ts +0 -372
- package/dist/plugins/listActionInputFieldChoices/index.d.ts.map +0 -1
- package/dist/plugins/listActionInputFieldChoices/index.js +0 -110
- package/dist/plugins/listActionInputFieldChoices/schemas.d.ts +0 -133
- package/dist/plugins/listActionInputFieldChoices/schemas.d.ts.map +0 -1
- package/dist/plugins/listActionInputFieldChoices/schemas.js +0 -75
- package/dist/plugins/listActionInputFields/index.d.ts +0 -330
- package/dist/plugins/listActionInputFields/index.d.ts.map +0 -1
- package/dist/plugins/listActionInputFields/index.js +0 -208
- package/dist/plugins/listActionInputFields/schemas.d.ts +0 -113
- package/dist/plugins/listActionInputFields/schemas.d.ts.map +0 -1
- package/dist/plugins/listActionInputFields/schemas.js +0 -56
- package/dist/plugins/listActions/index.d.ts +0 -219
- package/dist/plugins/listActions/index.d.ts.map +0 -1
- package/dist/plugins/listActions/index.js +0 -60
- package/dist/plugins/listActions/schemas.d.ts +0 -78
- package/dist/plugins/listActions/schemas.d.ts.map +0 -1
- package/dist/plugins/listActions/schemas.js +0 -33
- package/dist/plugins/listApps/index.d.ts +0 -127
- package/dist/plugins/listApps/index.d.ts.map +0 -1
- package/dist/plugins/listApps/index.js +0 -63
- package/dist/plugins/listApps/schemas.d.ts +0 -43
- package/dist/plugins/listApps/schemas.d.ts.map +0 -1
- package/dist/plugins/listApps/schemas.js +0 -54
- package/dist/plugins/listClientCredentials/index.d.ts +0 -36
- package/dist/plugins/listClientCredentials/index.d.ts.map +0 -1
- package/dist/plugins/listClientCredentials/index.js +0 -32
- package/dist/plugins/listClientCredentials/schemas.d.ts +0 -17
- package/dist/plugins/listClientCredentials/schemas.d.ts.map +0 -1
- package/dist/plugins/listClientCredentials/schemas.js +0 -23
- package/dist/plugins/listConnections/index.d.ts +0 -243
- package/dist/plugins/listConnections/index.d.ts.map +0 -1
- package/dist/plugins/listConnections/index.js +0 -97
- package/dist/plugins/listConnections/schemas.d.ts +0 -34
- package/dist/plugins/listConnections/schemas.d.ts.map +0 -1
- package/dist/plugins/listConnections/schemas.js +0 -74
- package/dist/plugins/manifest/index.d.ts +0 -97
- package/dist/plugins/manifest/index.d.ts.map +0 -1
- package/dist/plugins/manifest/index.js +0 -395
- package/dist/plugins/manifest/schemas.d.ts +0 -88
- package/dist/plugins/manifest/schemas.d.ts.map +0 -1
- package/dist/plugins/manifest/schemas.js +0 -61
- package/dist/plugins/registry/index.d.ts +0 -17
- package/dist/plugins/registry/index.d.ts.map +0 -1
- package/dist/plugins/registry/index.js +0 -11
- package/dist/plugins/request/index.d.ts +0 -70
- package/dist/plugins/request/index.d.ts.map +0 -1
- package/dist/plugins/request/index.js +0 -28
- package/dist/plugins/request/schemas.d.ts +0 -46
- package/dist/plugins/request/schemas.d.ts.map +0 -1
- package/dist/plugins/request/schemas.js +0 -42
- package/dist/plugins/runAction/index.d.ts +0 -313
- package/dist/plugins/runAction/index.d.ts.map +0 -1
- package/dist/plugins/runAction/index.js +0 -189
- package/dist/plugins/runAction/schemas.d.ts +0 -108
- package/dist/plugins/runAction/schemas.d.ts.map +0 -1
- package/dist/plugins/runAction/schemas.js +0 -53
- package/dist/plugins/tables/createTable/index.d.ts +0 -48
- package/dist/plugins/tables/createTable/index.d.ts.map +0 -1
- package/dist/plugins/tables/createTable/index.js +0 -20
- package/dist/plugins/tables/createTable/schemas.d.ts +0 -36
- package/dist/plugins/tables/createTable/schemas.d.ts.map +0 -1
- package/dist/plugins/tables/createTable/schemas.js +0 -16
- package/dist/plugins/tables/createTableFields/index.d.ts +0 -92
- package/dist/plugins/tables/createTableFields/index.d.ts.map +0 -1
- package/dist/plugins/tables/createTableFields/index.js +0 -29
- package/dist/plugins/tables/createTableFields/schemas.d.ts +0 -317
- package/dist/plugins/tables/createTableFields/schemas.d.ts.map +0 -1
- package/dist/plugins/tables/createTableFields/schemas.js +0 -62
- package/dist/plugins/tables/createTableRecords/index.d.ts +0 -114
- package/dist/plugins/tables/createTableRecords/index.d.ts.map +0 -1
- package/dist/plugins/tables/createTableRecords/index.js +0 -43
- package/dist/plugins/tables/createTableRecords/schemas.d.ts +0 -92
- package/dist/plugins/tables/createTableRecords/schemas.d.ts.map +0 -1
- package/dist/plugins/tables/createTableRecords/schemas.js +0 -55
- package/dist/plugins/tables/deleteTable/index.d.ts +0 -74
- package/dist/plugins/tables/deleteTable/index.d.ts.map +0 -1
- package/dist/plugins/tables/deleteTable/index.js +0 -23
- package/dist/plugins/tables/deleteTable/schemas.d.ts +0 -28
- package/dist/plugins/tables/deleteTable/schemas.d.ts.map +0 -1
- package/dist/plugins/tables/deleteTable/schemas.js +0 -21
- package/dist/plugins/tables/deleteTableFields/index.d.ts +0 -102
- package/dist/plugins/tables/deleteTableFields/index.d.ts.map +0 -1
- package/dist/plugins/tables/deleteTableFields/index.js +0 -30
- package/dist/plugins/tables/deleteTableFields/schemas.d.ts +0 -34
- package/dist/plugins/tables/deleteTableFields/schemas.d.ts.map +0 -1
- package/dist/plugins/tables/deleteTableFields/schemas.js +0 -29
- package/dist/plugins/tables/deleteTableRecords/index.d.ts +0 -123
- package/dist/plugins/tables/deleteTableRecords/index.d.ts.map +0 -1
- package/dist/plugins/tables/deleteTableRecords/index.js +0 -23
- package/dist/plugins/tables/deleteTableRecords/schemas.d.ts +0 -34
- package/dist/plugins/tables/deleteTableRecords/schemas.d.ts.map +0 -1
- package/dist/plugins/tables/deleteTableRecords/schemas.js +0 -30
- package/dist/plugins/tables/getTable/index.d.ts +0 -81
- package/dist/plugins/tables/getTable/index.d.ts.map +0 -1
- package/dist/plugins/tables/getTable/index.js +0 -24
- package/dist/plugins/tables/getTable/schemas.d.ts +0 -49
- package/dist/plugins/tables/getTable/schemas.d.ts.map +0 -1
- package/dist/plugins/tables/getTable/schemas.js +0 -27
- package/dist/plugins/tables/getTableRecord/index.d.ts +0 -131
- package/dist/plugins/tables/getTableRecord/index.d.ts.map +0 -1
- package/dist/plugins/tables/getTableRecord/index.js +0 -38
- package/dist/plugins/tables/getTableRecord/schemas.d.ts +0 -88
- package/dist/plugins/tables/getTableRecord/schemas.d.ts.map +0 -1
- package/dist/plugins/tables/getTableRecord/schemas.js +0 -56
- package/dist/plugins/tables/listTableFields/index.d.ts +0 -86
- package/dist/plugins/tables/listTableFields/index.d.ts.map +0 -1
- package/dist/plugins/tables/listTableFields/index.js +0 -41
- package/dist/plugins/tables/listTableFields/schemas.d.ts +0 -225
- package/dist/plugins/tables/listTableFields/schemas.d.ts.map +0 -1
- package/dist/plugins/tables/listTableFields/schemas.js +0 -93
- package/dist/plugins/tables/listTableRecords/index.d.ts +0 -136
- package/dist/plugins/tables/listTableRecords/index.d.ts.map +0 -1
- package/dist/plugins/tables/listTableRecords/index.js +0 -81
- package/dist/plugins/tables/listTableRecords/schemas.d.ts +0 -256
- package/dist/plugins/tables/listTableRecords/schemas.d.ts.map +0 -1
- package/dist/plugins/tables/listTableRecords/schemas.js +0 -95
- package/dist/plugins/tables/listTables/index.d.ts +0 -60
- package/dist/plugins/tables/listTables/index.d.ts.map +0 -1
- package/dist/plugins/tables/listTables/index.js +0 -67
- package/dist/plugins/tables/listTables/schemas.d.ts +0 -85
- package/dist/plugins/tables/listTables/schemas.d.ts.map +0 -1
- package/dist/plugins/tables/listTables/schemas.js +0 -72
- package/dist/plugins/tables/shared.d.ts +0 -10
- package/dist/plugins/tables/shared.d.ts.map +0 -1
- package/dist/plugins/tables/shared.js +0 -9
- package/dist/plugins/tables/updateTableRecords/index.d.ts +0 -116
- package/dist/plugins/tables/updateTableRecords/index.d.ts.map +0 -1
- package/dist/plugins/tables/updateTableRecords/index.js +0 -47
- package/dist/plugins/tables/updateTableRecords/schemas.d.ts +0 -97
- package/dist/plugins/tables/updateTableRecords/schemas.d.ts.map +0 -1
- package/dist/plugins/tables/updateTableRecords/schemas.js +0 -55
- package/dist/plugins/tables/utils.d.ts +0 -69
- package/dist/plugins/tables/utils.d.ts.map +0 -1
- package/dist/plugins/tables/utils.js +0 -270
- package/dist/plugins/triggers/ackTriggerInboxMessages/index.d.ts +0 -108
- package/dist/plugins/triggers/ackTriggerInboxMessages/index.d.ts.map +0 -1
- package/dist/plugins/triggers/ackTriggerInboxMessages/index.js +0 -36
- package/dist/plugins/triggers/ackTriggerInboxMessages/schemas.d.ts +0 -34
- package/dist/plugins/triggers/ackTriggerInboxMessages/schemas.d.ts.map +0 -1
- package/dist/plugins/triggers/ackTriggerInboxMessages/schemas.js +0 -17
- package/dist/plugins/triggers/createTriggerInbox/index.d.ts +0 -292
- package/dist/plugins/triggers/createTriggerInbox/index.d.ts.map +0 -1
- package/dist/plugins/triggers/createTriggerInbox/index.js +0 -68
- package/dist/plugins/triggers/createTriggerInbox/schemas.d.ts +0 -20
- package/dist/plugins/triggers/createTriggerInbox/schemas.d.ts.map +0 -1
- package/dist/plugins/triggers/createTriggerInbox/schemas.js +0 -21
- package/dist/plugins/triggers/deleteTriggerInbox/index.d.ts +0 -81
- package/dist/plugins/triggers/deleteTriggerInbox/index.d.ts.map +0 -1
- package/dist/plugins/triggers/deleteTriggerInbox/index.js +0 -29
- package/dist/plugins/triggers/deleteTriggerInbox/schemas.d.ts +0 -13
- package/dist/plugins/triggers/deleteTriggerInbox/schemas.d.ts.map +0 -1
- package/dist/plugins/triggers/deleteTriggerInbox/schemas.js +0 -9
- package/dist/plugins/triggers/drainTriggerInbox/index.d.ts +0 -277
- package/dist/plugins/triggers/drainTriggerInbox/index.d.ts.map +0 -1
- package/dist/plugins/triggers/drainTriggerInbox/index.js +0 -260
- package/dist/plugins/triggers/drainTriggerInbox/pipeline.d.ts +0 -56
- package/dist/plugins/triggers/drainTriggerInbox/pipeline.d.ts.map +0 -1
- package/dist/plugins/triggers/drainTriggerInbox/pipeline.js +0 -225
- package/dist/plugins/triggers/drainTriggerInbox/schemas.d.ts +0 -104
- package/dist/plugins/triggers/drainTriggerInbox/schemas.d.ts.map +0 -1
- package/dist/plugins/triggers/drainTriggerInbox/schemas.js +0 -102
- package/dist/plugins/triggers/ensureTriggerInbox/index.d.ts +0 -292
- package/dist/plugins/triggers/ensureTriggerInbox/index.d.ts.map +0 -1
- package/dist/plugins/triggers/ensureTriggerInbox/index.js +0 -65
- package/dist/plugins/triggers/ensureTriggerInbox/schemas.d.ts +0 -20
- package/dist/plugins/triggers/ensureTriggerInbox/schemas.d.ts.map +0 -1
- package/dist/plugins/triggers/ensureTriggerInbox/schemas.js +0 -21
- package/dist/plugins/triggers/getTriggerInbox/index.d.ts +0 -81
- package/dist/plugins/triggers/getTriggerInbox/index.d.ts.map +0 -1
- package/dist/plugins/triggers/getTriggerInbox/index.js +0 -28
- package/dist/plugins/triggers/getTriggerInbox/schemas.d.ts +0 -13
- package/dist/plugins/triggers/getTriggerInbox/schemas.d.ts.map +0 -1
- package/dist/plugins/triggers/getTriggerInbox/schemas.js +0 -9
- package/dist/plugins/triggers/getTriggerInputFieldsSchema/index.d.ts +0 -277
- package/dist/plugins/triggers/getTriggerInputFieldsSchema/index.d.ts.map +0 -1
- package/dist/plugins/triggers/getTriggerInputFieldsSchema/index.js +0 -23
- package/dist/plugins/triggers/getTriggerInputFieldsSchema/schemas.d.ts +0 -13
- package/dist/plugins/triggers/getTriggerInputFieldsSchema/schemas.d.ts.map +0 -1
- package/dist/plugins/triggers/getTriggerInputFieldsSchema/schemas.js +0 -10
- package/dist/plugins/triggers/leaseTriggerInboxMessages/index.d.ts +0 -89
- package/dist/plugins/triggers/leaseTriggerInboxMessages/index.d.ts.map +0 -1
- package/dist/plugins/triggers/leaseTriggerInboxMessages/index.js +0 -74
- package/dist/plugins/triggers/leaseTriggerInboxMessages/schemas.d.ts +0 -57
- package/dist/plugins/triggers/leaseTriggerInboxMessages/schemas.d.ts.map +0 -1
- package/dist/plugins/triggers/leaseTriggerInboxMessages/schemas.js +0 -25
- package/dist/plugins/triggers/listTriggerInboxMessages/index.d.ts +0 -82
- package/dist/plugins/triggers/listTriggerInboxMessages/index.d.ts.map +0 -1
- package/dist/plugins/triggers/listTriggerInboxMessages/index.js +0 -40
- package/dist/plugins/triggers/listTriggerInboxMessages/schemas.d.ts +0 -37
- package/dist/plugins/triggers/listTriggerInboxMessages/schemas.d.ts.map +0 -1
- package/dist/plugins/triggers/listTriggerInboxMessages/schemas.js +0 -27
- package/dist/plugins/triggers/listTriggerInboxes/index.d.ts +0 -56
- package/dist/plugins/triggers/listTriggerInboxes/index.d.ts.map +0 -1
- package/dist/plugins/triggers/listTriggerInboxes/index.js +0 -42
- package/dist/plugins/triggers/listTriggerInboxes/schemas.d.ts +0 -58
- package/dist/plugins/triggers/listTriggerInboxes/schemas.d.ts.map +0 -1
- package/dist/plugins/triggers/listTriggerInboxes/schemas.js +0 -35
- package/dist/plugins/triggers/listTriggerInputFieldChoices/index.d.ts +0 -360
- package/dist/plugins/triggers/listTriggerInputFieldChoices/index.d.ts.map +0 -1
- package/dist/plugins/triggers/listTriggerInputFieldChoices/index.js +0 -32
- package/dist/plugins/triggers/listTriggerInputFieldChoices/schemas.d.ts +0 -20
- package/dist/plugins/triggers/listTriggerInputFieldChoices/schemas.d.ts.map +0 -1
- package/dist/plugins/triggers/listTriggerInputFieldChoices/schemas.js +0 -28
- package/dist/plugins/triggers/listTriggerInputFields/index.d.ts +0 -330
- package/dist/plugins/triggers/listTriggerInputFields/index.d.ts.map +0 -1
- package/dist/plugins/triggers/listTriggerInputFields/index.js +0 -34
- package/dist/plugins/triggers/listTriggerInputFields/schemas.d.ts +0 -16
- package/dist/plugins/triggers/listTriggerInputFields/schemas.d.ts.map +0 -1
- package/dist/plugins/triggers/listTriggerInputFields/schemas.js +0 -21
- package/dist/plugins/triggers/listTriggers/index.d.ts +0 -207
- package/dist/plugins/triggers/listTriggers/index.d.ts.map +0 -1
- package/dist/plugins/triggers/listTriggers/index.js +0 -26
- package/dist/plugins/triggers/listTriggers/schemas.d.ts +0 -11
- package/dist/plugins/triggers/listTriggers/schemas.d.ts.map +0 -1
- package/dist/plugins/triggers/listTriggers/schemas.js +0 -18
- package/dist/plugins/triggers/pauseTriggerInbox/index.d.ts +0 -81
- package/dist/plugins/triggers/pauseTriggerInbox/index.d.ts.map +0 -1
- package/dist/plugins/triggers/pauseTriggerInbox/index.js +0 -28
- package/dist/plugins/triggers/pauseTriggerInbox/schemas.d.ts +0 -13
- package/dist/plugins/triggers/pauseTriggerInbox/schemas.d.ts.map +0 -1
- package/dist/plugins/triggers/pauseTriggerInbox/schemas.js +0 -9
- package/dist/plugins/triggers/releaseTriggerInboxMessages/index.d.ts +0 -108
- package/dist/plugins/triggers/releaseTriggerInboxMessages/index.d.ts.map +0 -1
- package/dist/plugins/triggers/releaseTriggerInboxMessages/index.js +0 -38
- package/dist/plugins/triggers/releaseTriggerInboxMessages/schemas.d.ts +0 -34
- package/dist/plugins/triggers/releaseTriggerInboxMessages/schemas.d.ts.map +0 -1
- package/dist/plugins/triggers/releaseTriggerInboxMessages/schemas.js +0 -17
- package/dist/plugins/triggers/resumeTriggerInbox/index.d.ts +0 -81
- package/dist/plugins/triggers/resumeTriggerInbox/index.d.ts.map +0 -1
- package/dist/plugins/triggers/resumeTriggerInbox/index.js +0 -28
- package/dist/plugins/triggers/resumeTriggerInbox/schemas.d.ts +0 -13
- package/dist/plugins/triggers/resumeTriggerInbox/schemas.d.ts.map +0 -1
- package/dist/plugins/triggers/resumeTriggerInbox/schemas.js +0 -9
- package/dist/plugins/triggers/shared.d.ts +0 -17
- package/dist/plugins/triggers/shared.d.ts.map +0 -1
- package/dist/plugins/triggers/shared.js +0 -16
- package/dist/plugins/triggers/updateTriggerInbox/index.d.ts +0 -82
- package/dist/plugins/triggers/updateTriggerInbox/index.d.ts.map +0 -1
- package/dist/plugins/triggers/updateTriggerInbox/index.js +0 -32
- package/dist/plugins/triggers/updateTriggerInbox/schemas.d.ts +0 -14
- package/dist/plugins/triggers/updateTriggerInbox/schemas.d.ts.map +0 -1
- package/dist/plugins/triggers/updateTriggerInbox/schemas.js +0 -15
- package/dist/plugins/triggers/utils.d.ts +0 -23
- package/dist/plugins/triggers/utils.d.ts.map +0 -1
- package/dist/plugins/triggers/utils.js +0 -45
- package/dist/plugins/triggers/watchTriggerInbox/index.d.ts +0 -221
- package/dist/plugins/triggers/watchTriggerInbox/index.d.ts.map +0 -1
- package/dist/plugins/triggers/watchTriggerInbox/index.js +0 -402
- package/dist/plugins/triggers/watchTriggerInbox/sse.d.ts +0 -32
- package/dist/plugins/triggers/watchTriggerInbox/sse.d.ts.map +0 -1
- package/dist/plugins/triggers/watchTriggerInbox/sse.js +0 -36
- package/dist/plugins/waitForNewConnection/index.d.ts +0 -209
- package/dist/plugins/waitForNewConnection/index.d.ts.map +0 -1
- package/dist/plugins/waitForNewConnection/index.js +0 -75
- package/dist/plugins/waitForNewConnection/schemas.d.ts +0 -17
- package/dist/plugins/waitForNewConnection/schemas.d.ts.map +0 -1
- package/dist/plugins/waitForNewConnection/schemas.js +0 -39
- package/dist/resolvers/actionKey.d.ts +0 -16
- package/dist/resolvers/actionKey.d.ts.map +0 -1
- package/dist/resolvers/actionKey.js +0 -20
- package/dist/resolvers/actionType.d.ts +0 -14
- package/dist/resolvers/actionType.d.ts.map +0 -1
- package/dist/resolvers/actionType.js +0 -24
- package/dist/resolvers/appKey.d.ts +0 -13
- package/dist/resolvers/appKey.d.ts.map +0 -1
- package/dist/resolvers/appKey.js +0 -50
- package/dist/resolvers/clientCredentialsName.d.ts +0 -3
- package/dist/resolvers/clientCredentialsName.d.ts.map +0 -1
- package/dist/resolvers/clientCredentialsName.js +0 -5
- package/dist/resolvers/clientId.d.ts +0 -5
- package/dist/resolvers/clientId.d.ts.map +0 -1
- package/dist/resolvers/clientId.js +0 -14
- package/dist/resolvers/connectionId.d.ts +0 -12
- package/dist/resolvers/connectionId.d.ts.map +0 -1
- package/dist/resolvers/connectionId.js +0 -52
- package/dist/resolvers/durableRunId.d.ts +0 -5
- package/dist/resolvers/durableRunId.d.ts.map +0 -1
- package/dist/resolvers/durableRunId.js +0 -15
- package/dist/resolvers/index.d.ts +0 -27
- package/dist/resolvers/index.d.ts.map +0 -1
- package/dist/resolvers/index.js +0 -28
- package/dist/resolvers/inputFieldKey.d.ts +0 -12
- package/dist/resolvers/inputFieldKey.d.ts.map +0 -1
- package/dist/resolvers/inputFieldKey.js +0 -51
- package/dist/resolvers/inputs.d.ts +0 -17
- package/dist/resolvers/inputs.d.ts.map +0 -1
- package/dist/resolvers/inputs.js +0 -50
- package/dist/resolvers/tableFieldIds.d.ts +0 -7
- package/dist/resolvers/tableFieldIds.d.ts.map +0 -1
- package/dist/resolvers/tableFieldIds.js +0 -20
- package/dist/resolvers/tableFields.d.ts +0 -3
- package/dist/resolvers/tableFields.d.ts.map +0 -1
- package/dist/resolvers/tableFields.js +0 -31
- package/dist/resolvers/tableFilters.d.ts +0 -6
- package/dist/resolvers/tableFilters.d.ts.map +0 -1
- package/dist/resolvers/tableFilters.js +0 -74
- package/dist/resolvers/tableId.d.ts +0 -5
- package/dist/resolvers/tableId.d.ts.map +0 -1
- package/dist/resolvers/tableId.js +0 -30
- package/dist/resolvers/tableName.d.ts +0 -3
- package/dist/resolvers/tableName.d.ts.map +0 -1
- package/dist/resolvers/tableName.js +0 -5
- package/dist/resolvers/tableRecordId.d.ts +0 -10
- package/dist/resolvers/tableRecordId.d.ts.map +0 -1
- package/dist/resolvers/tableRecordId.js +0 -49
- package/dist/resolvers/tableRecords.d.ts +0 -9
- package/dist/resolvers/tableRecords.d.ts.map +0 -1
- package/dist/resolvers/tableRecords.js +0 -77
- package/dist/resolvers/tableSort.d.ts +0 -6
- package/dist/resolvers/tableSort.d.ts.map +0 -1
- package/dist/resolvers/tableSort.js +0 -43
- package/dist/resolvers/triggerInbox.d.ts +0 -5
- package/dist/resolvers/triggerInbox.d.ts.map +0 -1
- package/dist/resolvers/triggerInbox.js +0 -19
- package/dist/resolvers/triggerMessages.d.ts +0 -7
- package/dist/resolvers/triggerMessages.d.ts.map +0 -1
- package/dist/resolvers/triggerMessages.js +0 -21
- package/dist/resolvers/workflowId.d.ts +0 -5
- package/dist/resolvers/workflowId.d.ts.map +0 -1
- package/dist/resolvers/workflowId.js +0 -15
- package/dist/resolvers/workflowRunId.d.ts +0 -7
- package/dist/resolvers/workflowRunId.d.ts.map +0 -1
- package/dist/resolvers/workflowRunId.js +0 -20
- package/dist/resolvers/workflowVersionId.d.ts +0 -7
- package/dist/resolvers/workflowVersionId.d.ts.map +0 -1
- package/dist/resolvers/workflowVersionId.js +0 -20
- package/dist/schemas/Action.d.ts +0 -24
- package/dist/schemas/Action.d.ts.map +0 -1
- package/dist/schemas/Action.js +0 -16
- package/dist/schemas/App.d.ts +0 -56
- package/dist/schemas/App.d.ts.map +0 -1
- package/dist/schemas/App.js +0 -5
- package/dist/schemas/ClientCredentials.d.ts +0 -19
- package/dist/schemas/ClientCredentials.d.ts.map +0 -1
- package/dist/schemas/ClientCredentials.js +0 -6
- package/dist/schemas/Connection.d.ts +0 -32
- package/dist/schemas/Connection.d.ts.map +0 -1
- package/dist/schemas/Connection.js +0 -5
- package/dist/schemas/Field.d.ts +0 -61
- package/dist/schemas/Field.d.ts.map +0 -1
- package/dist/schemas/Field.js +0 -49
- package/dist/schemas/Run.d.ts +0 -3
- package/dist/schemas/Run.d.ts.map +0 -1
- package/dist/schemas/Run.js +0 -5
- package/dist/schemas/TriggerInbox.d.ts +0 -59
- package/dist/schemas/TriggerInbox.d.ts.map +0 -1
- package/dist/schemas/TriggerInbox.js +0 -49
- package/dist/schemas/TriggerMessage.d.ts +0 -48
- package/dist/schemas/TriggerMessage.d.ts.map +0 -1
- package/dist/schemas/TriggerMessage.js +0 -21
- package/dist/schemas/UserProfile.d.ts +0 -12
- package/dist/schemas/UserProfile.d.ts.map +0 -1
- package/dist/schemas/UserProfile.js +0 -13
- package/dist/sdk-version.d.ts +0 -28
- package/dist/sdk-version.d.ts.map +0 -1
- package/dist/sdk-version.js +0 -29
- package/dist/sdk.d.ts +0 -6065
- package/dist/sdk.d.ts.map +0 -1
- package/dist/sdk.js +0 -173
- package/dist/services/implementations.d.ts +0 -63
- package/dist/services/implementations.d.ts.map +0 -1
- package/dist/services/implementations.js +0 -79
- package/dist/types/connections.d.ts +0 -19
- package/dist/types/connections.d.ts.map +0 -1
- package/dist/types/connections.js +0 -20
- package/dist/types/credentials.d.ts +0 -186
- package/dist/types/credentials.d.ts.map +0 -1
- package/dist/types/credentials.js +0 -123
- package/dist/types/domain.d.ts +0 -52
- package/dist/types/domain.d.ts.map +0 -1
- package/dist/types/domain.js +0 -1
- package/dist/types/errors.d.ts +0 -254
- package/dist/types/errors.d.ts.map +0 -1
- package/dist/types/errors.js +0 -336
- package/dist/types/events.d.ts +0 -38
- package/dist/types/events.d.ts.map +0 -1
- package/dist/types/events.js +0 -7
- package/dist/types/functions.d.ts +0 -2
- package/dist/types/functions.d.ts.map +0 -1
- package/dist/types/functions.js +0 -1
- package/dist/types/properties.d.ts +0 -83
- package/dist/types/properties.d.ts.map +0 -1
- package/dist/types/properties.js +0 -120
- package/dist/types/sdk.d.ts +0 -97
- package/dist/types/sdk.d.ts.map +0 -1
- package/dist/types/sdk.js +0 -114
- package/dist/types/signals.d.ts +0 -20
- package/dist/types/signals.d.ts.map +0 -1
- package/dist/types/signals.js +0 -21
- package/dist/types/telemetry-events.d.ts +0 -114
- package/dist/types/telemetry-events.d.ts.map +0 -1
- package/dist/types/telemetry-events.js +0 -10
- package/dist/utils/abort-utils.d.ts +0 -77
- package/dist/utils/abort-utils.d.ts.map +0 -1
- package/dist/utils/abort-utils.js +0 -122
- package/dist/utils/agent.d.ts +0 -44
- package/dist/utils/agent.d.ts.map +0 -1
- package/dist/utils/agent.js +0 -76
- package/dist/utils/array-utils.d.ts +0 -31
- package/dist/utils/array-utils.d.ts.map +0 -1
- package/dist/utils/array-utils.js +0 -36
- package/dist/utils/batch-utils.d.ts +0 -72
- package/dist/utils/batch-utils.d.ts.map +0 -1
- package/dist/utils/batch-utils.js +0 -161
- package/dist/utils/caller-context.d.ts +0 -21
- package/dist/utils/caller-context.d.ts.map +0 -1
- package/dist/utils/caller-context.js +0 -35
- package/dist/utils/domain-utils.d.ts +0 -96
- package/dist/utils/domain-utils.d.ts.map +0 -1
- package/dist/utils/domain-utils.js +0 -248
- package/dist/utils/file-utils.d.ts +0 -4
- package/dist/utils/file-utils.d.ts.map +0 -1
- package/dist/utils/file-utils.js +0 -74
- package/dist/utils/id-utils.d.ts +0 -15
- package/dist/utils/id-utils.d.ts.map +0 -1
- package/dist/utils/id-utils.js +0 -24
- package/dist/utils/logging.d.ts +0 -2
- package/dist/utils/logging.d.ts.map +0 -1
- package/dist/utils/logging.js +0 -2
- package/dist/utils/open-approval.d.ts +0 -2
- package/dist/utils/open-approval.d.ts.map +0 -1
- package/dist/utils/open-approval.js +0 -13
- package/dist/utils/open-url.d.ts +0 -3
- package/dist/utils/open-url.d.ts.map +0 -1
- package/dist/utils/open-url.js +0 -79
- package/dist/utils/pagination.d.ts +0 -38
- package/dist/utils/pagination.d.ts.map +0 -1
- package/dist/utils/pagination.js +0 -53
- package/dist/utils/retry-utils.d.ts +0 -70
- package/dist/utils/retry-utils.d.ts.map +0 -1
- package/dist/utils/retry-utils.js +0 -97
- package/dist/utils/should-open-browser.d.ts +0 -24
- package/dist/utils/should-open-browser.d.ts.map +0 -1
- package/dist/utils/should-open-browser.js +0 -55
- package/dist/utils/telemetry.d.ts +0 -11
- package/dist/utils/telemetry.d.ts.map +0 -1
- package/dist/utils/telemetry.js +0 -19
- package/dist/utils/type-guard-utils.d.ts +0 -7
- package/dist/utils/type-guard-utils.d.ts.map +0 -1
- package/dist/utils/type-guard-utils.js +0 -11
- package/dist/utils/url-utils.d.ts +0 -25
- package/dist/utils/url-utils.d.ts.map +0 -1
- package/dist/utils/url-utils.js +0 -79
package/dist/api/client.js
DELETED
|
@@ -1,1232 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* API Client Implementation
|
|
3
|
-
*
|
|
4
|
-
* This module contains the core API client implementation, including
|
|
5
|
-
* HTTP method handlers, response processing, and client factory functions.
|
|
6
|
-
*/
|
|
7
|
-
import { getAuthorizationHeader } from "./auth";
|
|
8
|
-
import { createSemaphore } from "./concurrency";
|
|
9
|
-
import { createDebugLogger, createDebugFetch } from "./debug";
|
|
10
|
-
import { pollUntilComplete } from "./polling";
|
|
11
|
-
import { resolveAuthToken, invalidateCredentialsToken, isCliLoginAvailable, } from "../auth";
|
|
12
|
-
import { getZapierBaseUrl, isLocalhostBaseUrl } from "../utils/url-utils";
|
|
13
|
-
import { sleep, calculateExponentialBackoffMs } from "../utils/retry-utils";
|
|
14
|
-
import { isPlainObject } from "../utils/type-guard-utils";
|
|
15
|
-
import { isAbortError } from "../utils/abort-utils";
|
|
16
|
-
import { getCallerContext } from "../utils/caller-context";
|
|
17
|
-
import { getAgent } from "../utils/agent";
|
|
18
|
-
import { createSseParserStream, jsonFrames, } from "./sse-parser";
|
|
19
|
-
import { consumeApprovalReviewStream } from "./approval-review-stream";
|
|
20
|
-
import { ZapierApiError, ZapierApprovalError, ZapierAuthenticationError, ZapierConfigurationError, ZapierTimeoutError, ZapierValidationError, ZapierResourceNotFoundError, ZapierRateLimitError, } from "../types/errors";
|
|
21
|
-
import { MAX_CONCURRENCY_LIMIT, ZAPIER_MAX_CONCURRENT_REQUESTS, ZAPIER_MAX_NETWORK_RETRIES, ZAPIER_MAX_NETWORK_RETRY_DELAY_MS, getZapierApprovalMode, getZapierDefaultApprovalMode, getZapierOpenAutoModeApprovalsInBrowser, getZapierSdkService, DEFAULT_APPROVAL_TIMEOUT_MS, DEFAULT_MAX_APPROVAL_RETRIES, } from "../constants";
|
|
22
|
-
import { SDK_VERSION } from "../sdk-version";
|
|
23
|
-
import { openApproval } from "../utils/open-approval";
|
|
24
|
-
import { z } from "zod";
|
|
25
|
-
const ApprovalStatusSchema = z.enum([
|
|
26
|
-
"pending_approval",
|
|
27
|
-
"approved",
|
|
28
|
-
"denied",
|
|
29
|
-
"failed",
|
|
30
|
-
]);
|
|
31
|
-
const ApprovalModeSchema = z.enum(["manual", "auto"]);
|
|
32
|
-
const CreateApprovalResponseSchema = z
|
|
33
|
-
.object({
|
|
34
|
-
id: z.string().optional(),
|
|
35
|
-
status: ApprovalStatusSchema,
|
|
36
|
-
approval_id: z.string().optional(),
|
|
37
|
-
mode: ApprovalModeSchema,
|
|
38
|
-
approval_url: z.string().url(),
|
|
39
|
-
poll_url: z.string().url(),
|
|
40
|
-
stream_url: z.string().url().optional(),
|
|
41
|
-
reason: z.string().optional(),
|
|
42
|
-
})
|
|
43
|
-
.transform((approval, ctx) => {
|
|
44
|
-
const id = approval.id ?? approval.approval_id;
|
|
45
|
-
if (!id) {
|
|
46
|
-
ctx.addIssue({
|
|
47
|
-
code: "custom",
|
|
48
|
-
message: "Approval response must include id",
|
|
49
|
-
});
|
|
50
|
-
return z.NEVER;
|
|
51
|
-
}
|
|
52
|
-
return { ...approval, id };
|
|
53
|
-
});
|
|
54
|
-
const PollApprovalResponseSchema = z.object({
|
|
55
|
-
id: z.string().optional(),
|
|
56
|
-
status: ApprovalStatusSchema,
|
|
57
|
-
approval_id: z.string().optional(),
|
|
58
|
-
mode: ApprovalModeSchema.optional(),
|
|
59
|
-
reason: z.string().optional(),
|
|
60
|
-
});
|
|
61
|
-
const APPROVAL_MAX_POLLING_INTERVAL_MS = 5000;
|
|
62
|
-
/**
|
|
63
|
-
* Parse rate limit information from response headers
|
|
64
|
-
*/
|
|
65
|
-
function parseRateLimitHeaders(response) {
|
|
66
|
-
const info = {};
|
|
67
|
-
// Parse Retry-After header (can be seconds or HTTP date)
|
|
68
|
-
const retryAfter = response.headers.get("retry-after");
|
|
69
|
-
if (retryAfter) {
|
|
70
|
-
const seconds = parseInt(retryAfter, 10);
|
|
71
|
-
if (!isNaN(seconds)) {
|
|
72
|
-
info.retryAfterMs = seconds * 1000;
|
|
73
|
-
}
|
|
74
|
-
else {
|
|
75
|
-
// Try parsing as HTTP date
|
|
76
|
-
const date = Date.parse(retryAfter);
|
|
77
|
-
if (!isNaN(date)) {
|
|
78
|
-
info.retryAfterMs = Math.max(0, date - Date.now());
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
// Parse X-RateLimit-Reset (Unix timestamp)
|
|
83
|
-
const reset = response.headers.get("x-ratelimit-reset");
|
|
84
|
-
if (reset) {
|
|
85
|
-
const resetTimestamp = parseInt(reset, 10);
|
|
86
|
-
if (!isNaN(resetTimestamp)) {
|
|
87
|
-
// Convert to ms (timestamps are usually in seconds)
|
|
88
|
-
info.resetMs = resetTimestamp * 1000;
|
|
89
|
-
// If no Retry-After, calculate wait time from reset
|
|
90
|
-
if (info.retryAfterMs === undefined) {
|
|
91
|
-
info.retryAfterMs = Math.max(0, info.resetMs - Date.now());
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
// Parse X-RateLimit-Limit
|
|
96
|
-
const limit = response.headers.get("x-ratelimit-limit");
|
|
97
|
-
if (limit) {
|
|
98
|
-
const limitNum = parseInt(limit, 10);
|
|
99
|
-
if (!isNaN(limitNum)) {
|
|
100
|
-
info.limit = limitNum;
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
// Parse X-RateLimit-Remaining
|
|
104
|
-
const remaining = response.headers.get("x-ratelimit-remaining");
|
|
105
|
-
if (remaining) {
|
|
106
|
-
const remainingNum = parseInt(remaining, 10);
|
|
107
|
-
if (!isNaN(remainingNum)) {
|
|
108
|
-
info.remaining = remainingNum;
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
return info;
|
|
112
|
-
}
|
|
113
|
-
// Configuration for paths
|
|
114
|
-
const pathConfig = {
|
|
115
|
-
// e.g. /relay -> https://sdkapi.zapier.com/api/v0/sdk/relay/...
|
|
116
|
-
"/relay": {
|
|
117
|
-
authHeader: "X-Relay-Authorization",
|
|
118
|
-
pathPrefix: "/api/v0/sdk/relay",
|
|
119
|
-
},
|
|
120
|
-
// e.g. /zapier -> https://sdkapi.zapier.com/api/v0/sdk/zapier/...
|
|
121
|
-
"/zapier": {
|
|
122
|
-
authHeader: "Authorization",
|
|
123
|
-
pathPrefix: "/api/v0/sdk/zapier",
|
|
124
|
-
},
|
|
125
|
-
// e.g. /tables -> https://sdkapi.zapier.com/api/v0/sdk/tables/...
|
|
126
|
-
"/tables": {
|
|
127
|
-
authHeader: "Authorization",
|
|
128
|
-
pathPrefix: "/api/v0/sdk/tables",
|
|
129
|
-
},
|
|
130
|
-
// e.g. /trigger-inbox -> https://sdkapi.zapier.com/api/v0/sdk/trigger-inbox/...
|
|
131
|
-
"/trigger-inbox": {
|
|
132
|
-
authHeader: "Authorization",
|
|
133
|
-
pathPrefix: "/api/v0/sdk/trigger-inbox",
|
|
134
|
-
},
|
|
135
|
-
// e.g. /sdkdurableapi -> https://sdkapi.zapier.com/api/v0/sdk/sdkdurableapi/...
|
|
136
|
-
// sdkapi proxies to the sdkdurableapi backend.
|
|
137
|
-
"/sdkdurableapi": {
|
|
138
|
-
authHeader: "Authorization",
|
|
139
|
-
pathPrefix: "/api/v0/sdk/sdkdurableapi",
|
|
140
|
-
},
|
|
141
|
-
// e.g. /durableworkflowzaps -> https://sdkapi.zapier.com/api/v0/sdk/durableworkflowzaps/...
|
|
142
|
-
// sdkapi proxies to the durableworkflowzaps backend.
|
|
143
|
-
"/durableworkflowzaps": {
|
|
144
|
-
authHeader: "Authorization",
|
|
145
|
-
pathPrefix: "/api/v0/sdk/durableworkflowzaps",
|
|
146
|
-
},
|
|
147
|
-
};
|
|
148
|
-
class ZapierApiClient {
|
|
149
|
-
constructor(options) {
|
|
150
|
-
this.options = options;
|
|
151
|
-
/**
|
|
152
|
-
* Perform a request against an already-resolved URL.
|
|
153
|
-
*
|
|
154
|
-
* Does auth, header merging, and 429 retry — all the cross-cutting
|
|
155
|
-
* concerns that every Zapier-bound HTTP call needs. Callers that have a
|
|
156
|
-
* path (e.g. `/relay/...`) should use `rawFetch` instead, which does
|
|
157
|
-
* path → URL resolution and delegates here.
|
|
158
|
-
*
|
|
159
|
-
* Exposed as a separate helper so call sites with a server-supplied
|
|
160
|
-
* absolute URL (e.g. an approval poll URL) can still share the same
|
|
161
|
-
* auth/retry pipeline instead of reaching for `this.options.fetch`
|
|
162
|
-
* directly and drifting.
|
|
163
|
-
*/
|
|
164
|
-
this.rawFetchUrl = async (url, init, pathConfig) => {
|
|
165
|
-
if (init?.body && (isPlainObject(init.body) || Array.isArray(init.body))) {
|
|
166
|
-
init.body = JSON.stringify(init.body);
|
|
167
|
-
}
|
|
168
|
-
const builtHeaders = await this.buildHeaders(init, pathConfig);
|
|
169
|
-
const inputHeaders = new Headers(init?.headers ?? {});
|
|
170
|
-
const mergedHeaders = new Headers();
|
|
171
|
-
builtHeaders.forEach((value, key) => {
|
|
172
|
-
mergedHeaders.set(key, value);
|
|
173
|
-
});
|
|
174
|
-
inputHeaders.forEach((value, key) => {
|
|
175
|
-
mergedHeaders.set(key, value);
|
|
176
|
-
});
|
|
177
|
-
this.applyTelemetryHeaders(mergedHeaders);
|
|
178
|
-
let retries = 0;
|
|
179
|
-
// Retry loop for rate limiting (429)
|
|
180
|
-
while (true) {
|
|
181
|
-
const response = await this.options.fetch(url, {
|
|
182
|
-
...init,
|
|
183
|
-
headers: mergedHeaders,
|
|
184
|
-
});
|
|
185
|
-
if (response.status !== 429) {
|
|
186
|
-
return response;
|
|
187
|
-
}
|
|
188
|
-
// Calculate delay: prefer Retry-After/X-RateLimit-Reset, fall back to exponential backoff
|
|
189
|
-
const rateLimitInfo = parseRateLimitHeaders(response);
|
|
190
|
-
const delayMs = rateLimitInfo.retryAfterMs ??
|
|
191
|
-
calculateExponentialBackoffMs(retries + 1);
|
|
192
|
-
// If delay exceeds maxNetworkRetryDelayMs or retries exhausted, throw immediately
|
|
193
|
-
if (delayMs > this.maxNetworkRetryDelayMs ||
|
|
194
|
-
retries >= this.maxNetworkRetries) {
|
|
195
|
-
throw new ZapierRateLimitError("Rate limited", {
|
|
196
|
-
statusCode: 429,
|
|
197
|
-
rateLimit: rateLimitInfo,
|
|
198
|
-
retries,
|
|
199
|
-
});
|
|
200
|
-
}
|
|
201
|
-
retries++;
|
|
202
|
-
// Emit retry event
|
|
203
|
-
this.emitEvent("api:rate_limit_retry", {
|
|
204
|
-
retry: retries,
|
|
205
|
-
maxNetworkRetries: this.maxNetworkRetries,
|
|
206
|
-
delayMs,
|
|
207
|
-
path: url,
|
|
208
|
-
method: init?.method ?? "GET",
|
|
209
|
-
rateLimit: rateLimitInfo,
|
|
210
|
-
});
|
|
211
|
-
// Pass the caller's signal into sleep so an abort during the
|
|
212
|
-
// backoff stops the wait — the next fetch in the loop then
|
|
213
|
-
// surfaces the abort, and `withSemaphore`'s finally releases the
|
|
214
|
-
// permit. Without this, an aborted request keeps holding its
|
|
215
|
-
// slot for the full Retry-After interval and blocks every queued
|
|
216
|
-
// waiter behind it.
|
|
217
|
-
await sleep(delayMs, init?.signal ?? undefined);
|
|
218
|
-
}
|
|
219
|
-
};
|
|
220
|
-
/**
|
|
221
|
-
* Wrap an outbound HTTP call with the concurrency semaphore. Used by both
|
|
222
|
-
* `rawFetch` (path-based) and the approval-poll path (absolute URL); each
|
|
223
|
-
* caller acquires per-attempt, so 429 retry sleep is held but the gap
|
|
224
|
-
* between approval polls and the human-approval wait are not.
|
|
225
|
-
*
|
|
226
|
-
* The release is registered in a finally that wraps the entire post-
|
|
227
|
-
* acquire flow — including the `wait_end` event emission — so a throwing
|
|
228
|
-
* `onEvent` handler can never leak a permit.
|
|
229
|
-
*
|
|
230
|
-
* Slot lifetime is intentionally tied to "fetch resolves" (headers
|
|
231
|
-
* received), NOT to "response body fully consumed". WHATWG `fetch()`
|
|
232
|
-
* resolves once headers are in; the body is still streaming. We rely on
|
|
233
|
-
* that boundary so streaming responses (SSE, long-running chunked reads)
|
|
234
|
-
* don't pin a permit for the lifetime of the stream — a single SSE
|
|
235
|
-
* consumer would otherwise hold one of N slots for as long as the
|
|
236
|
-
* connection stays open. Do not move the release into a path that awaits
|
|
237
|
-
* body consumption (e.g. `parseResult` / `response.text()`); doing so
|
|
238
|
-
* would silently break streaming consumers without failing any of the
|
|
239
|
-
* short-request tests.
|
|
240
|
-
*/
|
|
241
|
-
this.withSemaphore = async (context, fn) => {
|
|
242
|
-
const fastRelease = this.semaphore.tryAcquire();
|
|
243
|
-
let waitStart = null;
|
|
244
|
-
let release = fastRelease;
|
|
245
|
-
if (release === null) {
|
|
246
|
-
waitStart = Date.now();
|
|
247
|
-
this.emitEvent("api:concurrency_wait_start", {
|
|
248
|
-
url: context.url,
|
|
249
|
-
method: context.method,
|
|
250
|
-
});
|
|
251
|
-
release = await this.semaphore.acquire(context.signal ?? undefined);
|
|
252
|
-
}
|
|
253
|
-
const acquiredRelease = release;
|
|
254
|
-
try {
|
|
255
|
-
if (waitStart !== null) {
|
|
256
|
-
this.emitEvent("api:concurrency_wait_end", {
|
|
257
|
-
url: context.url,
|
|
258
|
-
method: context.method,
|
|
259
|
-
waitedMs: Date.now() - waitStart,
|
|
260
|
-
});
|
|
261
|
-
}
|
|
262
|
-
return await fn();
|
|
263
|
-
}
|
|
264
|
-
finally {
|
|
265
|
-
acquiredRelease();
|
|
266
|
-
}
|
|
267
|
-
};
|
|
268
|
-
/**
|
|
269
|
-
* Perform a request with auth, header merging, and rate-limit (429) retries.
|
|
270
|
-
* Does NOT handle 403 approval_required — that's routed by `fetch`.
|
|
271
|
-
*
|
|
272
|
-
* Concurrency: a semaphore slot is held across the entire call, including
|
|
273
|
-
* the 429 retry sleep inside `rawFetchUrl`. That keeps backpressure
|
|
274
|
-
* coherent — when the server is rate-limiting us, we don't dump more
|
|
275
|
-
* parallelism into the queue.
|
|
276
|
-
*/
|
|
277
|
-
this.rawFetch = async (path, init) => {
|
|
278
|
-
if (!path.startsWith("/")) {
|
|
279
|
-
throw new ZapierValidationError(`fetch expects a path starting with '/', got: ${path}`);
|
|
280
|
-
}
|
|
281
|
-
const { url, pathConfig } = this.buildUrl(path, init?.searchParams);
|
|
282
|
-
return this.withSemaphore({ url, method: init?.method ?? "GET", signal: init?.signal }, () => this.rawFetchUrl(url, init, pathConfig));
|
|
283
|
-
};
|
|
284
|
-
/**
|
|
285
|
-
* Approval-aware HTTP fetch.
|
|
286
|
-
*
|
|
287
|
-
* Wraps `rawFetch` with the backend's just-in-time approval protocol. The
|
|
288
|
-
* backend signals approval state via a 403 response with an
|
|
289
|
-
* `x-zapier-error-type` header:
|
|
290
|
-
*
|
|
291
|
-
* - `request_denied_by_policy` → a policy rule permanently blocks the
|
|
292
|
-
* request; no human can approve it. Throw.
|
|
293
|
-
* - `approval_required` → the request needs human approval; the
|
|
294
|
-
* SDK creates an approval, opens the URL
|
|
295
|
-
* (poll mode), waits for resolution, and
|
|
296
|
-
* retries the original request.
|
|
297
|
-
* - anything else → not our concern, pass through.
|
|
298
|
-
*
|
|
299
|
-
* The retry loop exists because a single user action can legitimately
|
|
300
|
-
* require multiple sequential approvals (e.g. policies that approve one
|
|
301
|
-
* step at a time). Each iteration is either a first attempt or a post-
|
|
302
|
-
* approval retry; `maxApprovalRetries` bounds the loop as a runaway-loop
|
|
303
|
-
* safeguard.
|
|
304
|
-
*
|
|
305
|
-
* Loop accounting: `attempt` counts rawFetch calls, not approval rounds.
|
|
306
|
-
* With `maxRetries = N` we perform up to `N + 1` rawFetch calls and at
|
|
307
|
-
* most `N` approval rounds. The `attempt === maxRetries` guard ensures we
|
|
308
|
-
* don't run an (N+1)th approval round we'll never consume — if the final
|
|
309
|
-
* retry still returns `approval_required`, we break out and throw
|
|
310
|
-
* `max_retries_exceeded` instead.
|
|
311
|
-
*/
|
|
312
|
-
this.fetch = async (path, init) => {
|
|
313
|
-
const maxRetries = this.options.maxApprovalRetries ?? DEFAULT_MAX_APPROVAL_RETRIES;
|
|
314
|
-
// `<= maxRetries` gives us one initial attempt plus `maxRetries` post-
|
|
315
|
-
// approval retries. See "Loop accounting" in the jsdoc above.
|
|
316
|
-
for (let attempt = 0; attempt <= maxRetries; attempt++) {
|
|
317
|
-
const response = await this.rawFetch(path, init);
|
|
318
|
-
// Happy path and non-403 errors: hand the response back untouched. Any
|
|
319
|
-
// other error handling (e.g. 4xx envelope parsing) lives downstream.
|
|
320
|
-
if (response.status !== 403)
|
|
321
|
-
return response;
|
|
322
|
-
// All approval-related responses are 403 + a typed header. Classify the
|
|
323
|
-
// kind of 403 we got exactly once, here — no other call site should be
|
|
324
|
-
// reading `x-zapier-error-type`.
|
|
325
|
-
const errorType = response.headers.get("x-zapier-error-type");
|
|
326
|
-
// Terminal policy denial: a rule blocked the request and no approval
|
|
327
|
-
// can unblock it. Bubble the server-provided detail message so callers
|
|
328
|
-
// surface the actual reason ("Spend over $X requires finance approval",
|
|
329
|
-
// etc.) rather than a generic one.
|
|
330
|
-
if (errorType === "request_denied_by_policy") {
|
|
331
|
-
const { data } = await this.parseResult(response);
|
|
332
|
-
const { message, errors } = this.parseErrorResponse({
|
|
333
|
-
status: response.status,
|
|
334
|
-
statusText: response.statusText,
|
|
335
|
-
data,
|
|
336
|
-
});
|
|
337
|
-
throw new ZapierApprovalError(message || "Request explicitly denied by policy", {
|
|
338
|
-
status: "policy_denied",
|
|
339
|
-
statusCode: response.status,
|
|
340
|
-
errors,
|
|
341
|
-
});
|
|
342
|
-
}
|
|
343
|
-
// 403 with no `approval_required` header isn't part of the approval
|
|
344
|
-
// protocol — could be auth scope, per-endpoint perms, etc. Pass it
|
|
345
|
-
// through so the caller's normal error handling sees it.
|
|
346
|
-
if (errorType !== "approval_required")
|
|
347
|
-
return response;
|
|
348
|
-
// We got `approval_required`. If this was our last scheduled attempt,
|
|
349
|
-
// don't start an approval round we can't retry — fall out of the loop
|
|
350
|
-
// and throw `max_retries_exceeded` below.
|
|
351
|
-
if (attempt === maxRetries)
|
|
352
|
-
break;
|
|
353
|
-
// Resolve the mode: explicit option > env var > TTY-based default.
|
|
354
|
-
const mode = this.options.approvalMode ??
|
|
355
|
-
getZapierApprovalMode() ??
|
|
356
|
-
getZapierDefaultApprovalMode();
|
|
357
|
-
if (mode === "disabled") {
|
|
358
|
-
throw new ZapierApprovalError("Approvals are disabled. Set approvalMode to 'poll' or 'throw' (or ZAPIER_APPROVAL_MODE) to enable.", { status: "approval_required" });
|
|
359
|
-
}
|
|
360
|
-
// `approvalContext` is a builder, not a value, because the SDK may
|
|
361
|
-
// retry the same request across multiple approval rounds and each POST
|
|
362
|
-
// to /approvals needs a freshly-built context (timestamps, etc.).
|
|
363
|
-
// Missing context is a programmer error — this code path is only
|
|
364
|
-
// reachable for callers that opted into approval-capable requests.
|
|
365
|
-
if (!init?.approvalContext) {
|
|
366
|
-
throw new ZapierApiError(`Received 403 approval_required for ${path}, but the caller did not provide an approvalContext builder. Every approval-capable request must pass approvalContext so the SDK can create the approval with the correct policy context.`, { statusCode: 403 });
|
|
367
|
-
}
|
|
368
|
-
// Create the approval, open the URL (poll mode) or throw with the URL
|
|
369
|
-
// attached (throw mode), and wait for terminal resolution. Returns only
|
|
370
|
-
// on "approved" — every other outcome throws from inside the helper.
|
|
371
|
-
// On return, loop back to retry the original request.
|
|
372
|
-
await this.runOneApprovalRound(init.approvalContext, mode, init.signal ?? undefined);
|
|
373
|
-
}
|
|
374
|
-
// Only reachable when the final attempt returned `approval_required`
|
|
375
|
-
// (see the `break` above). Every other terminal outcome throws inline.
|
|
376
|
-
throw new ZapierApprovalError(`Exceeded maximum approval retries (${maxRetries}) for ${path}`, { status: "max_retries_exceeded" });
|
|
377
|
-
};
|
|
378
|
-
/**
|
|
379
|
-
* Streaming counterpart to `fetch`. Opens a Server-Sent Events connection
|
|
380
|
-
* through the same pipeline (auth, base URL, 429 retry, approval flow,
|
|
381
|
-
* concurrency) and yields parsed `{ data }` frames. On a non-ok response it
|
|
382
|
-
* throws the same `ZapierError` subclasses as the JSON path — callers
|
|
383
|
-
* classify errors off `statusCode` instead of hand-rolling the mapping.
|
|
384
|
-
*
|
|
385
|
-
* The concurrency permit is released when the underlying `fetch` resolves
|
|
386
|
-
* (headers received), not when the body finishes, so a long-lived stream
|
|
387
|
-
* never pins a slot — see `withSemaphore`.
|
|
388
|
-
*/
|
|
389
|
-
this.fetchStream = (path, init) => this.streamSse(path, init);
|
|
390
|
-
/**
|
|
391
|
-
* Like `fetchStream`, but parses each frame's `data` as JSON. Diverges from
|
|
392
|
-
* `fetchJson` deliberately: that throws on invalid JSON, but a long-lived
|
|
393
|
-
* stream must survive a single malformed frame, so a parse failure is yielded
|
|
394
|
-
* as `{ parsed: false, data: null, raw }` rather than thrown. A non-ok
|
|
395
|
-
* response still throws the shared `ZapierError` (from `fetchStream`, before
|
|
396
|
-
* any frame), so transport / auth failures surface as usual.
|
|
397
|
-
*/
|
|
398
|
-
this.fetchJsonStream = (path, init) => jsonFrames(this.fetchStream(path, init));
|
|
399
|
-
this.streamTrustedJsonUrl = (url, init) => jsonFrames(this.streamTrustedSseUrl(url, init));
|
|
400
|
-
this.get = async (path, options = {}) => {
|
|
401
|
-
return this.fetchJson("GET", path, undefined, options);
|
|
402
|
-
};
|
|
403
|
-
this.post = async (path, data, options = {}) => {
|
|
404
|
-
return this.fetchJson("POST", path, data, options);
|
|
405
|
-
};
|
|
406
|
-
this.put = async (path, data, options = {}) => {
|
|
407
|
-
return this.fetchJson("PUT", path, data, options);
|
|
408
|
-
};
|
|
409
|
-
this.patch = async (path, data, options = {}) => {
|
|
410
|
-
return this.fetchJson("PATCH", path, data, options);
|
|
411
|
-
};
|
|
412
|
-
this.delete = async (path, data, options = {}) => {
|
|
413
|
-
return this.fetchJson("DELETE", path, data, options);
|
|
414
|
-
};
|
|
415
|
-
this.poll = async (path, options = {}) => {
|
|
416
|
-
return pollUntilComplete({
|
|
417
|
-
fetchPoll: () => this.fetch(path, {
|
|
418
|
-
method: "GET",
|
|
419
|
-
searchParams: options.searchParams,
|
|
420
|
-
authRequired: options.authRequired,
|
|
421
|
-
signal: options.signal,
|
|
422
|
-
}),
|
|
423
|
-
initialDelay: options.initialDelay,
|
|
424
|
-
timeoutMs: options.timeoutMs,
|
|
425
|
-
successStatus: options.successStatus,
|
|
426
|
-
pendingStatus: options.pendingStatus,
|
|
427
|
-
isPending: options.isPending,
|
|
428
|
-
resultExtractor: options.resultExtractor,
|
|
429
|
-
signal: options.signal,
|
|
430
|
-
});
|
|
431
|
-
};
|
|
432
|
-
this.maxNetworkRetries =
|
|
433
|
-
options.maxNetworkRetries ?? ZAPIER_MAX_NETWORK_RETRIES;
|
|
434
|
-
this.maxNetworkRetryDelayMs =
|
|
435
|
-
options.maxNetworkRetryDelayMs ?? ZAPIER_MAX_NETWORK_RETRY_DELAY_MS;
|
|
436
|
-
// NaN coerces to the default rather than throwing so a CLI flag with a
|
|
437
|
-
// garbage value (parseInt produces NaN) falls back instead of crashing
|
|
438
|
-
// SDK construction. Other invalid values (0, negatives, non-integers,
|
|
439
|
-
// over-cap) still throw so a misconfigured programmatic caller gets a
|
|
440
|
-
// clear error. Peer numeric options like maxNetworkRetries don't coerce
|
|
441
|
-
// NaN — they let it flow into comparisons that misbehave silently. The
|
|
442
|
-
// asymmetry is deliberate.
|
|
443
|
-
const requested = options.maxConcurrentRequests;
|
|
444
|
-
const limit = requested === undefined || Number.isNaN(requested)
|
|
445
|
-
? ZAPIER_MAX_CONCURRENT_REQUESTS
|
|
446
|
-
: requested;
|
|
447
|
-
if (limit !== Infinity &&
|
|
448
|
-
(!Number.isInteger(limit) || limit < 1 || limit > MAX_CONCURRENCY_LIMIT)) {
|
|
449
|
-
throw new ZapierConfigurationError(`Invalid maxConcurrentRequests: ${limit} (expected positive integer 1-${MAX_CONCURRENCY_LIMIT} or Infinity)`, { configType: "maxConcurrentRequests" });
|
|
450
|
-
}
|
|
451
|
-
this.semaphore = createSemaphore(limit);
|
|
452
|
-
}
|
|
453
|
-
// Emit an event if onEvent handler is configured
|
|
454
|
-
emitEvent(type, payload) {
|
|
455
|
-
if (this.options.onEvent) {
|
|
456
|
-
this.options.onEvent({ type, payload, timestamp: Date.now() });
|
|
457
|
-
}
|
|
458
|
-
}
|
|
459
|
-
// Helper to parse response data
|
|
460
|
-
async parseResult(response) {
|
|
461
|
-
// Read as text first to avoid "Body has already been read" errors
|
|
462
|
-
// if json() fails partway through parsing
|
|
463
|
-
const text = await response.text();
|
|
464
|
-
try {
|
|
465
|
-
return { type: "json", data: JSON.parse(text) };
|
|
466
|
-
}
|
|
467
|
-
catch {
|
|
468
|
-
return { type: "text", data: text };
|
|
469
|
-
}
|
|
470
|
-
}
|
|
471
|
-
// Helper to get a token from the different places it could be gotten
|
|
472
|
-
async getAuthToken(options) {
|
|
473
|
-
return resolveAuthToken({
|
|
474
|
-
credentials: this.options.credentials,
|
|
475
|
-
token: this.options.token,
|
|
476
|
-
onEvent: this.options.onEvent,
|
|
477
|
-
fetch: this.options.fetch,
|
|
478
|
-
baseUrl: this.options.baseUrl,
|
|
479
|
-
requiredScopes: options?.requiredScopes,
|
|
480
|
-
debug: this.options.debug,
|
|
481
|
-
cache: this.options.cache,
|
|
482
|
-
});
|
|
483
|
-
}
|
|
484
|
-
// Helper to handle responses
|
|
485
|
-
async handleResponse(params) {
|
|
486
|
-
const { data: responseData } = await this.parseResult(params.response);
|
|
487
|
-
if (params.response.ok) {
|
|
488
|
-
return responseData;
|
|
489
|
-
}
|
|
490
|
-
// Returns Promise<never> (every branch throws); returning it satisfies
|
|
491
|
-
// this method's type without an unreachable fall-through.
|
|
492
|
-
return this.throwForErrorResponse({ ...params, responseData });
|
|
493
|
-
}
|
|
494
|
-
/**
|
|
495
|
-
* Maps a non-ok response to the appropriate ZapierError subclass and throws.
|
|
496
|
-
* Takes the already-parsed body so a streaming caller (`fetchStream`) gets
|
|
497
|
-
* the exact same status→error classification as the JSON path without
|
|
498
|
-
* re-reading — or reading on the success path, which would consume the
|
|
499
|
-
* stream — the response body.
|
|
500
|
-
*/
|
|
501
|
-
async throwForErrorResponse(params) {
|
|
502
|
-
const { response, responseData, customErrorHandler, resource, wasMissingAuthToken, requiredScopes, } = params;
|
|
503
|
-
const errorInfo = {
|
|
504
|
-
status: response.status,
|
|
505
|
-
statusText: response.statusText,
|
|
506
|
-
data: responseData,
|
|
507
|
-
};
|
|
508
|
-
// Precedence: customErrorHandler runs first; if it returns an Error,
|
|
509
|
-
// throw it. If it returns undefined (or wasn't provided), fall through
|
|
510
|
-
// to the resource-enriched / bare defaults below.
|
|
511
|
-
if (customErrorHandler) {
|
|
512
|
-
const customError = customErrorHandler(errorInfo);
|
|
513
|
-
if (customError) {
|
|
514
|
-
// javascript may not respect customErrorHandler return type, so we need to throw a proper error if it's not an Error
|
|
515
|
-
if (customError instanceof Error) {
|
|
516
|
-
throw customError;
|
|
517
|
-
}
|
|
518
|
-
else {
|
|
519
|
-
throw new Error(`customErrorHandler returned a non-Error: ${JSON.stringify(customError)}`);
|
|
520
|
-
}
|
|
521
|
-
}
|
|
522
|
-
}
|
|
523
|
-
// Parse the error response
|
|
524
|
-
const { message, errors } = this.parseErrorResponse(errorInfo);
|
|
525
|
-
const errorOptions = {
|
|
526
|
-
statusCode: response.status,
|
|
527
|
-
errors,
|
|
528
|
-
};
|
|
529
|
-
// 404: always throw ZapierResourceNotFoundError (subclass of
|
|
530
|
-
// ZapierNotFoundError, so existing instanceof checks still pass).
|
|
531
|
-
// resourceType/resourceId are populated when the caller passed a
|
|
532
|
-
// `resource` hint, otherwise left undefined. The message is the
|
|
533
|
-
// server's detail verbatim; formatErrorMessage surfaces the resource
|
|
534
|
-
// hint separately (Type: ..., ID: ...) so we don't duplicate it here.
|
|
535
|
-
if (response.status === 404) {
|
|
536
|
-
throw new ZapierResourceNotFoundError(message, {
|
|
537
|
-
...errorOptions,
|
|
538
|
-
resourceType: resource?.type,
|
|
539
|
-
resourceId: resource?.id !== undefined ? String(resource.id) : undefined,
|
|
540
|
-
});
|
|
541
|
-
}
|
|
542
|
-
if (response.status === 401 || response.status === 403) {
|
|
543
|
-
// If we get a 401/403 error and no auth token was provided, give helpful message
|
|
544
|
-
if (wasMissingAuthToken) {
|
|
545
|
-
throw new ZapierAuthenticationError(`Authentication required (HTTP ${response.status}). Please provide credentials in options or set ZAPIER_CREDENTIALS environment variable.`, errorOptions);
|
|
546
|
-
}
|
|
547
|
-
// On 401, invalidate the cached token so the next request fires
|
|
548
|
-
// a fresh exchange. Passing baseUrl + cache explicitly so the
|
|
549
|
-
// invalidation targets the same cache key the token was stored
|
|
550
|
-
// under (both are part of the key identity).
|
|
551
|
-
if (response.status === 401) {
|
|
552
|
-
await invalidateCredentialsToken({
|
|
553
|
-
credentials: this.options.credentials,
|
|
554
|
-
token: this.options.token,
|
|
555
|
-
baseUrl: this.options.baseUrl,
|
|
556
|
-
requiredScopes,
|
|
557
|
-
cache: this.options.cache,
|
|
558
|
-
});
|
|
559
|
-
}
|
|
560
|
-
throw new ZapierAuthenticationError(message, errorOptions);
|
|
561
|
-
}
|
|
562
|
-
if (response.status === 400) {
|
|
563
|
-
throw new ZapierValidationError(message, errorOptions);
|
|
564
|
-
}
|
|
565
|
-
// Generic API error for other status codes
|
|
566
|
-
throw new ZapierApiError(message, errorOptions);
|
|
567
|
-
}
|
|
568
|
-
hasErrorArray(data) {
|
|
569
|
-
return (typeof data === "object" &&
|
|
570
|
-
data !== null &&
|
|
571
|
-
"errors" in data &&
|
|
572
|
-
Array.isArray(data.errors));
|
|
573
|
-
}
|
|
574
|
-
// Helper to check if data has API errors
|
|
575
|
-
isApiErrorArray(dataArray) {
|
|
576
|
-
const data = dataArray[0];
|
|
577
|
-
return (typeof data === "object" &&
|
|
578
|
-
data !== null &&
|
|
579
|
-
"code" in data &&
|
|
580
|
-
"title" in data &&
|
|
581
|
-
"detail" in data);
|
|
582
|
-
}
|
|
583
|
-
// Do our best to extract an error message from the response data
|
|
584
|
-
extractErrorMessage(data) {
|
|
585
|
-
if (typeof data === "string") {
|
|
586
|
-
return data;
|
|
587
|
-
}
|
|
588
|
-
if (typeof data === "object" && data !== null) {
|
|
589
|
-
if ("message" in data && typeof data.message === "string") {
|
|
590
|
-
return data.message;
|
|
591
|
-
}
|
|
592
|
-
if ("error" in data) {
|
|
593
|
-
if (typeof data.error === "string") {
|
|
594
|
-
return data.error;
|
|
595
|
-
}
|
|
596
|
-
if (typeof data.error === "object" && data.error !== null) {
|
|
597
|
-
if ("message" in data.error &&
|
|
598
|
-
typeof data.error.message === "string") {
|
|
599
|
-
return data.error.message;
|
|
600
|
-
}
|
|
601
|
-
}
|
|
602
|
-
try {
|
|
603
|
-
return JSON.stringify(data.error);
|
|
604
|
-
}
|
|
605
|
-
catch {
|
|
606
|
-
/* defend against circular objects, even though they shouldn't be coming back from the wire */
|
|
607
|
-
}
|
|
608
|
-
}
|
|
609
|
-
if ("errors" in data && Array.isArray(data.errors)) {
|
|
610
|
-
if (this.isApiErrorArray(data.errors)) {
|
|
611
|
-
return data.errors[0].detail || data.errors[0].title;
|
|
612
|
-
}
|
|
613
|
-
else if (data.errors.length > 0) {
|
|
614
|
-
// Handle simple string errors array
|
|
615
|
-
const firstError = data.errors[0];
|
|
616
|
-
if (typeof firstError === "string") {
|
|
617
|
-
return firstError;
|
|
618
|
-
}
|
|
619
|
-
// For non-string errors, stringify them
|
|
620
|
-
try {
|
|
621
|
-
return JSON.stringify(firstError);
|
|
622
|
-
}
|
|
623
|
-
catch {
|
|
624
|
-
return String(firstError);
|
|
625
|
-
}
|
|
626
|
-
}
|
|
627
|
-
}
|
|
628
|
-
}
|
|
629
|
-
return undefined;
|
|
630
|
-
}
|
|
631
|
-
// Helper to parse API error response
|
|
632
|
-
parseErrorResponse(errorInfo) {
|
|
633
|
-
// If we can't parse data, use status text
|
|
634
|
-
const fallbackMessage = `HTTP ${errorInfo.status}: ${errorInfo.statusText}`;
|
|
635
|
-
try {
|
|
636
|
-
// Check if the response has the standard error format
|
|
637
|
-
if (typeof errorInfo.data === "string") {
|
|
638
|
-
return { message: `${fallbackMessage}: ${errorInfo.data}` };
|
|
639
|
-
}
|
|
640
|
-
const errorMessage = this.extractErrorMessage(errorInfo.data) || fallbackMessage;
|
|
641
|
-
if (this.hasErrorArray(errorInfo.data)) {
|
|
642
|
-
if (this.isApiErrorArray(errorInfo.data.errors)) {
|
|
643
|
-
return {
|
|
644
|
-
message: errorMessage,
|
|
645
|
-
errors: errorInfo.data.errors,
|
|
646
|
-
};
|
|
647
|
-
}
|
|
648
|
-
else {
|
|
649
|
-
return {
|
|
650
|
-
message: errorMessage,
|
|
651
|
-
errors: errorInfo.data.errors.map((e) => ({
|
|
652
|
-
status: errorInfo.status,
|
|
653
|
-
code: String(errorInfo.status),
|
|
654
|
-
title: errorInfo.statusText,
|
|
655
|
-
detail: JSON.stringify(e),
|
|
656
|
-
})),
|
|
657
|
-
};
|
|
658
|
-
}
|
|
659
|
-
}
|
|
660
|
-
return { message: errorMessage };
|
|
661
|
-
}
|
|
662
|
-
catch {
|
|
663
|
-
return { message: fallbackMessage };
|
|
664
|
-
}
|
|
665
|
-
}
|
|
666
|
-
// Apply any special routing logic for configured paths.
|
|
667
|
-
applyPathConfiguration(path) {
|
|
668
|
-
// Find matching path configuration.
|
|
669
|
-
const matchingPathKey = Object.keys(pathConfig).find((configPath) => path === configPath || path.startsWith(configPath + "/"));
|
|
670
|
-
const config = matchingPathKey ? pathConfig[matchingPathKey] : undefined;
|
|
671
|
-
// Apply pathPrefix if there's a matching config with pathPrefix.
|
|
672
|
-
let finalPath = path;
|
|
673
|
-
if (config &&
|
|
674
|
-
"pathPrefix" in config &&
|
|
675
|
-
config.pathPrefix &&
|
|
676
|
-
matchingPathKey) {
|
|
677
|
-
// Strip the matching path key, and use the pathPrefix instead.
|
|
678
|
-
const pathWithoutPrefix = path.slice(matchingPathKey.length) || "/";
|
|
679
|
-
finalPath = `${config.pathPrefix}${pathWithoutPrefix}`;
|
|
680
|
-
}
|
|
681
|
-
// Check if baseUrl is a Zapier-inferred base URL.
|
|
682
|
-
const zapierBaseUrl = getZapierBaseUrl(this.options.baseUrl);
|
|
683
|
-
// Let's remain compatible with a base URL that is set to a Zapier-inferred
|
|
684
|
-
// domain, rather than requiring the base URL to go to our proxy. Later, the
|
|
685
|
-
// proxy will be removed, so this should make that transition easier.
|
|
686
|
-
if (zapierBaseUrl === this.options.baseUrl.replace(/\/$/, "")) {
|
|
687
|
-
// If baseUrl is already the Zapier base URL, use sdkapi subdomain.
|
|
688
|
-
const originalBaseUrl = new URL(this.options.baseUrl);
|
|
689
|
-
const finalBaseUrl = `https://sdkapi.${originalBaseUrl.hostname}`;
|
|
690
|
-
return {
|
|
691
|
-
url: new URL(finalPath, finalBaseUrl),
|
|
692
|
-
pathConfig: config,
|
|
693
|
-
};
|
|
694
|
-
}
|
|
695
|
-
// For a base URL that isn't a Zapier-inferred domain (e.g., localhost),
|
|
696
|
-
// preserve any path from the base URL and append the final path.
|
|
697
|
-
const baseUrl = new URL(this.options.baseUrl);
|
|
698
|
-
const basePath = baseUrl.pathname.replace(/\/$/, "");
|
|
699
|
-
return {
|
|
700
|
-
url: new URL(basePath + finalPath, baseUrl.origin),
|
|
701
|
-
pathConfig: config,
|
|
702
|
-
};
|
|
703
|
-
}
|
|
704
|
-
// Helper to build full URLs and return routing info
|
|
705
|
-
buildUrl(path, searchParams) {
|
|
706
|
-
const { url, pathConfig: config } = this.applyPathConfiguration(path);
|
|
707
|
-
if (searchParams) {
|
|
708
|
-
Object.entries(searchParams).forEach(([key, value]) => {
|
|
709
|
-
url.searchParams.set(key, value);
|
|
710
|
-
});
|
|
711
|
-
}
|
|
712
|
-
return { url: url.toString(), pathConfig: config };
|
|
713
|
-
}
|
|
714
|
-
// Helper to build headers
|
|
715
|
-
async buildHeaders(options = {}, pathConfig) {
|
|
716
|
-
const headers = new Headers(options.headers ?? {});
|
|
717
|
-
// Even if auth is not required, we still want to add it in case it adds
|
|
718
|
-
// useful context to the API. The session is a good example of this. Auth
|
|
719
|
-
// is not required, but if we don't add auth, then we won't get the user's
|
|
720
|
-
// session!
|
|
721
|
-
const authToken = await this.getAuthToken({
|
|
722
|
-
requiredScopes: options.requiredScopes,
|
|
723
|
-
});
|
|
724
|
-
if (authToken) {
|
|
725
|
-
const authHeaderName = pathConfig && pathConfig.authHeader
|
|
726
|
-
? pathConfig.authHeader
|
|
727
|
-
: "Authorization";
|
|
728
|
-
headers.set(authHeaderName, getAuthorizationHeader(authToken));
|
|
729
|
-
}
|
|
730
|
-
// If we know auth is required, and we don't have a token, throw an error
|
|
731
|
-
// before we even make a request.
|
|
732
|
-
if (options.authRequired) {
|
|
733
|
-
const authHeaderName = pathConfig?.authHeader ?? "Authorization";
|
|
734
|
-
if (headers.get(authHeaderName) == null && authToken == null) {
|
|
735
|
-
const message = isCliLoginAvailable() === false
|
|
736
|
-
? "Authentication required but no credentials available. " +
|
|
737
|
-
"To use CLI login, install the CLI as a dev dependency " +
|
|
738
|
-
"(e.g. `npm install -D @zapier/zapier-sdk-cli`) and " +
|
|
739
|
-
"log in (e.g. `npx zapier-sdk login`). " +
|
|
740
|
-
"Alternatively, set the ZAPIER_CREDENTIALS environment variable " +
|
|
741
|
-
"or ZAPIER_CREDENTIALS_CLIENT_ID and " +
|
|
742
|
-
"ZAPIER_CREDENTIALS_CLIENT_SECRET environment variables."
|
|
743
|
-
: "Authentication required but no credentials available. " +
|
|
744
|
-
"Please log in (e.g. `npx zapier-sdk login`) or set the " +
|
|
745
|
-
"ZAPIER_CREDENTIALS environment variable or " +
|
|
746
|
-
"ZAPIER_CREDENTIALS_CLIENT_ID and " +
|
|
747
|
-
"ZAPIER_CREDENTIALS_CLIENT_SECRET environment variables.";
|
|
748
|
-
throw new ZapierAuthenticationError(message);
|
|
749
|
-
}
|
|
750
|
-
}
|
|
751
|
-
return headers;
|
|
752
|
-
}
|
|
753
|
-
// Telemetry headers consumed by sdkapi's ApiRequestCompletedEvent.
|
|
754
|
-
// Applied at the outbound layer (after caller-supplied header merging) so
|
|
755
|
-
// they always reflect the SDK's actual identity and can't be spoofed via
|
|
756
|
-
// options.headers.
|
|
757
|
-
//
|
|
758
|
-
// We emit both the standard `zapier-*` names (per the API header guidance the
|
|
759
|
-
// gateway now expects) and the legacy `x-zapier-*` names. The legacy names are
|
|
760
|
-
// kept for backward compatibility with consumers that haven't migrated yet;
|
|
761
|
-
// they can be removed once nothing reads them.
|
|
762
|
-
applyTelemetryHeaders(headers) {
|
|
763
|
-
headers.set("zapier-sdk-version", SDK_VERSION);
|
|
764
|
-
headers.set("x-zapier-sdk-version", SDK_VERSION);
|
|
765
|
-
const sdkService = getZapierSdkService();
|
|
766
|
-
if (sdkService) {
|
|
767
|
-
headers.set("zapier-service", sdkService);
|
|
768
|
-
headers.set("x-zapier-service", sdkService);
|
|
769
|
-
}
|
|
770
|
-
const agent = getAgent();
|
|
771
|
-
if (agent) {
|
|
772
|
-
headers.set("zapier-sdk-agent", agent);
|
|
773
|
-
}
|
|
774
|
-
const callerPackage = this.options.callerPackage;
|
|
775
|
-
if (callerPackage) {
|
|
776
|
-
headers.set("zapier-sdk-package", callerPackage.name);
|
|
777
|
-
headers.set("x-zapier-sdk-package", callerPackage.name);
|
|
778
|
-
headers.set("zapier-sdk-package-version", callerPackage.version);
|
|
779
|
-
headers.set("x-zapier-sdk-package-version", callerPackage.version);
|
|
780
|
-
const { packageOperation } = getCallerContext();
|
|
781
|
-
if (packageOperation) {
|
|
782
|
-
headers.set("zapier-sdk-package-operation", packageOperation);
|
|
783
|
-
}
|
|
784
|
-
}
|
|
785
|
-
}
|
|
786
|
-
// Helper to perform HTTP requests with JSON handling
|
|
787
|
-
async fetchJson(method, path, data, options = {}) {
|
|
788
|
-
const headers = { ...options.headers };
|
|
789
|
-
// Add Content-Type for JSON requests with body data
|
|
790
|
-
if (data && typeof data === "object") {
|
|
791
|
-
headers["Content-Type"] = "application/json";
|
|
792
|
-
}
|
|
793
|
-
// Check if we have an auth token available
|
|
794
|
-
const wasMissingAuthToken = options.authRequired &&
|
|
795
|
-
(await this.getAuthToken({
|
|
796
|
-
requiredScopes: options.requiredScopes,
|
|
797
|
-
})) == null;
|
|
798
|
-
const response = await this.fetch(path, {
|
|
799
|
-
...options,
|
|
800
|
-
method,
|
|
801
|
-
body: data != null ? JSON.stringify(data) : undefined,
|
|
802
|
-
headers,
|
|
803
|
-
});
|
|
804
|
-
const result = await this.handleResponse({
|
|
805
|
-
response,
|
|
806
|
-
customErrorHandler: options.customErrorHandler,
|
|
807
|
-
resource: options.resource,
|
|
808
|
-
wasMissingAuthToken,
|
|
809
|
-
requiredScopes: options.requiredScopes,
|
|
810
|
-
});
|
|
811
|
-
// Allow empty responses for DELETE or 204 No Content
|
|
812
|
-
if (typeof result === "string") {
|
|
813
|
-
if (result === "" && (method === "DELETE" || response.status === 204)) {
|
|
814
|
-
return undefined;
|
|
815
|
-
}
|
|
816
|
-
throw new ZapierValidationError(`Response could not be parsed as JSON: ${result}`);
|
|
817
|
-
}
|
|
818
|
-
return result;
|
|
819
|
-
}
|
|
820
|
-
// The generator body for `fetchStream`. Kept as a prototype method (not an
|
|
821
|
-
// arrow class field, which can't be a generator) and exposed through the
|
|
822
|
-
// bound `fetchStream` arrow above for parity with the other client methods.
|
|
823
|
-
async *streamSse(path, init) {
|
|
824
|
-
const { onOpen, headers: initHeaders, ...fetchInit } = init ?? {};
|
|
825
|
-
const signal = fetchInit.signal ?? undefined;
|
|
826
|
-
if (signal?.aborted)
|
|
827
|
-
return;
|
|
828
|
-
// Mirror fetchJson: when auth was required but no token resolved, a 401/403
|
|
829
|
-
// should surface the "Authentication required" message rather than a bare
|
|
830
|
-
// auth error.
|
|
831
|
-
const wasMissingAuthToken = fetchInit.authRequired === true &&
|
|
832
|
-
(await this.getAuthToken({
|
|
833
|
-
requiredScopes: fetchInit.requiredScopes,
|
|
834
|
-
})) == null;
|
|
835
|
-
const headers = new Headers(initHeaders);
|
|
836
|
-
if (!headers.has("Accept"))
|
|
837
|
-
headers.set("Accept", "text/event-stream");
|
|
838
|
-
let response;
|
|
839
|
-
try {
|
|
840
|
-
response = await this.fetch(path, {
|
|
841
|
-
...fetchInit,
|
|
842
|
-
method: fetchInit.method ?? "GET",
|
|
843
|
-
headers,
|
|
844
|
-
});
|
|
845
|
-
}
|
|
846
|
-
catch (err) {
|
|
847
|
-
// Aborts unwind quietly; everything else (including a ZapierApprovalError
|
|
848
|
-
// from a policy-denied stream) propagates so the caller can classify it.
|
|
849
|
-
if (signal?.aborted || isAbortError(err))
|
|
850
|
-
return;
|
|
851
|
-
throw err;
|
|
852
|
-
}
|
|
853
|
-
yield* this.readSseResponse({
|
|
854
|
-
response,
|
|
855
|
-
signal,
|
|
856
|
-
onOpen,
|
|
857
|
-
wasMissingAuthToken,
|
|
858
|
-
requiredScopes: fetchInit.requiredScopes,
|
|
859
|
-
});
|
|
860
|
-
}
|
|
861
|
-
// Approval `stream_url` is server-supplied and origin-pinned before use, like
|
|
862
|
-
// `poll_url`; keep absolute-URL streaming private rather than widening the
|
|
863
|
-
// public path-based `fetchStream` API.
|
|
864
|
-
async *streamTrustedSseUrl(url, init) {
|
|
865
|
-
const { onOpen, headers: initHeaders, ...fetchInit } = init ?? {};
|
|
866
|
-
const signal = fetchInit.signal ?? undefined;
|
|
867
|
-
if (signal?.aborted)
|
|
868
|
-
return;
|
|
869
|
-
const wasMissingAuthToken = fetchInit.authRequired === true &&
|
|
870
|
-
(await this.getAuthToken({
|
|
871
|
-
requiredScopes: fetchInit.requiredScopes,
|
|
872
|
-
})) == null;
|
|
873
|
-
const headers = new Headers(initHeaders);
|
|
874
|
-
if (!headers.has("Accept"))
|
|
875
|
-
headers.set("Accept", "text/event-stream");
|
|
876
|
-
let response;
|
|
877
|
-
try {
|
|
878
|
-
response = await this.withSemaphore({ url, method: fetchInit.method ?? "GET", signal }, () => this.rawFetchUrl(url, {
|
|
879
|
-
...fetchInit,
|
|
880
|
-
method: fetchInit.method ?? "GET",
|
|
881
|
-
headers,
|
|
882
|
-
}));
|
|
883
|
-
}
|
|
884
|
-
catch (err) {
|
|
885
|
-
if (signal?.aborted || isAbortError(err))
|
|
886
|
-
return;
|
|
887
|
-
throw err;
|
|
888
|
-
}
|
|
889
|
-
yield* this.readSseResponse({
|
|
890
|
-
response,
|
|
891
|
-
signal,
|
|
892
|
-
onOpen,
|
|
893
|
-
wasMissingAuthToken,
|
|
894
|
-
requiredScopes: fetchInit.requiredScopes,
|
|
895
|
-
});
|
|
896
|
-
}
|
|
897
|
-
async *readSseResponse({ response, signal, onOpen, wasMissingAuthToken, requiredScopes, }) {
|
|
898
|
-
if (!response.ok) {
|
|
899
|
-
// Parse the error body only on this non-ok branch — reading it on the ok
|
|
900
|
-
// path would consume the stream. Map it exactly like the JSON path does.
|
|
901
|
-
const { data } = await this.parseResult(response);
|
|
902
|
-
await this.throwForErrorResponse({
|
|
903
|
-
response,
|
|
904
|
-
responseData: data,
|
|
905
|
-
wasMissingAuthToken,
|
|
906
|
-
requiredScopes,
|
|
907
|
-
});
|
|
908
|
-
}
|
|
909
|
-
if (!response.body)
|
|
910
|
-
return;
|
|
911
|
-
const reader = response.body
|
|
912
|
-
.pipeThrough(new TextDecoderStream())
|
|
913
|
-
.pipeThrough(createSseParserStream())
|
|
914
|
-
.getReader();
|
|
915
|
-
// Cancelling the reader resolves any pending read() with {done: true},
|
|
916
|
-
// which unblocks the loop below on abort.
|
|
917
|
-
const onAbort = () => {
|
|
918
|
-
reader.cancel().catch(() => { });
|
|
919
|
-
};
|
|
920
|
-
try {
|
|
921
|
-
// Connection is live; fire onOpen before the first read so the caller can
|
|
922
|
-
// run any catch-up work. Inside the try so a throwing onOpen is still
|
|
923
|
-
// followed by the finally's cancel() — the socket never leaks. Reached
|
|
924
|
-
// only after the ok + body checks, so it never fires on a non-ok response
|
|
925
|
-
// or an empty body.
|
|
926
|
-
onOpen?.();
|
|
927
|
-
signal?.addEventListener("abort", onAbort, { once: true });
|
|
928
|
-
while (!signal?.aborted) {
|
|
929
|
-
const { done, value } = await reader.read();
|
|
930
|
-
if (done || signal?.aborted)
|
|
931
|
-
return;
|
|
932
|
-
yield value;
|
|
933
|
-
}
|
|
934
|
-
}
|
|
935
|
-
finally {
|
|
936
|
-
signal?.removeEventListener("abort", onAbort);
|
|
937
|
-
// cancel() (not just releaseLock) so the underlying HTTP connection
|
|
938
|
-
// closes on every unwind path — abort, clean end, throw, throwing onOpen,
|
|
939
|
-
// or the consumer calling .return(). A leaked socket would outlive the
|
|
940
|
-
// stream.
|
|
941
|
-
await reader.cancel().catch(() => { });
|
|
942
|
-
}
|
|
943
|
-
}
|
|
944
|
-
/**
|
|
945
|
-
* Run a single approval round: create the approval, open the URL (poll mode)
|
|
946
|
-
* or throw (throw mode), poll until resolved, and emit events. Throws on
|
|
947
|
-
* denied/failed/timeout/unexpected status. Returns on approved.
|
|
948
|
-
*
|
|
949
|
-
* Caller is responsible for passing a non-"disabled" mode; this method
|
|
950
|
-
* unconditionally creates an approval.
|
|
951
|
-
*/
|
|
952
|
-
async runOneApprovalRound(buildContext, mode, signal) {
|
|
953
|
-
const context = buildContext();
|
|
954
|
-
// Route through rawFetch so the approval POST shares auth + 429 retry.
|
|
955
|
-
let approvalResponse;
|
|
956
|
-
try {
|
|
957
|
-
approvalResponse = await this.rawFetch("/api/v0/approvals", {
|
|
958
|
-
method: "POST",
|
|
959
|
-
headers: {
|
|
960
|
-
"Content-Type": "application/json",
|
|
961
|
-
Accept: "application/json",
|
|
962
|
-
},
|
|
963
|
-
body: JSON.stringify({ context }),
|
|
964
|
-
signal,
|
|
965
|
-
});
|
|
966
|
-
}
|
|
967
|
-
catch (err) {
|
|
968
|
-
if (isAbortError(err))
|
|
969
|
-
throw err;
|
|
970
|
-
throw new ZapierApiError("Failed to create approval request", {
|
|
971
|
-
statusCode: 0,
|
|
972
|
-
cause: err,
|
|
973
|
-
});
|
|
974
|
-
}
|
|
975
|
-
if (!approvalResponse.ok) {
|
|
976
|
-
const body = await approvalResponse.text().catch(() => undefined);
|
|
977
|
-
throw new ZapierApiError(`Failed to create approval request: ${approvalResponse.status}`, { statusCode: approvalResponse.status, response: body });
|
|
978
|
-
}
|
|
979
|
-
let body;
|
|
980
|
-
try {
|
|
981
|
-
body = await approvalResponse.text();
|
|
982
|
-
}
|
|
983
|
-
catch (err) {
|
|
984
|
-
throw new ZapierApiError("Failed to read approval response body", {
|
|
985
|
-
statusCode: approvalResponse.status,
|
|
986
|
-
cause: err,
|
|
987
|
-
});
|
|
988
|
-
}
|
|
989
|
-
let approval;
|
|
990
|
-
try {
|
|
991
|
-
approval = CreateApprovalResponseSchema.parse(JSON.parse(body));
|
|
992
|
-
}
|
|
993
|
-
catch (err) {
|
|
994
|
-
throw new ZapierApiError(`Failed to parse approval response: ${body}`, {
|
|
995
|
-
statusCode: approvalResponse.status,
|
|
996
|
-
cause: err,
|
|
997
|
-
response: body,
|
|
998
|
-
});
|
|
999
|
-
}
|
|
1000
|
-
// Origin-pin server-supplied URLs before we attach the bearer token
|
|
1001
|
-
// (poll_url) or open them in the user's browser (approval_url). Without
|
|
1002
|
-
// this, a compromised or buggy sdkapi response could redirect the SDK to
|
|
1003
|
-
// an attacker-controlled host and leak the auth token.
|
|
1004
|
-
const sdkapiOrigin = new URL(this.buildUrl("/api/v0/approvals").url).origin;
|
|
1005
|
-
const browserOrigin = getZapierBaseUrl(this.options.baseUrl) ?? sdkapiOrigin;
|
|
1006
|
-
const assertApprovalOrigin = (url, expectedOrigin, label) => {
|
|
1007
|
-
let parsed;
|
|
1008
|
-
try {
|
|
1009
|
-
parsed = new URL(url);
|
|
1010
|
-
}
|
|
1011
|
-
catch {
|
|
1012
|
-
throw new ZapierApiError(`Invalid approval ${label}: ${url}`, {
|
|
1013
|
-
statusCode: approvalResponse.status,
|
|
1014
|
-
response: body,
|
|
1015
|
-
});
|
|
1016
|
-
}
|
|
1017
|
-
if (parsed.origin !== expectedOrigin) {
|
|
1018
|
-
throw new ZapierApiError(`Approval ${label} origin ${parsed.origin} does not match expected ${expectedOrigin}`, { statusCode: approvalResponse.status, response: body });
|
|
1019
|
-
}
|
|
1020
|
-
};
|
|
1021
|
-
// In local dev the SDK API, approvalsapi, and approval frontend run on
|
|
1022
|
-
// different localhost ports, so neither origin can match. The check
|
|
1023
|
-
// exists to stop a compromised sdkapi from redirecting bearer-token
|
|
1024
|
-
// traffic to an attacker host — that threat model doesn't apply when
|
|
1025
|
-
// the dev owns every service on the machine.
|
|
1026
|
-
if (!isLocalhostBaseUrl(this.options.baseUrl)) {
|
|
1027
|
-
assertApprovalOrigin(approval.poll_url, sdkapiOrigin, "poll_url");
|
|
1028
|
-
if (approval.stream_url) {
|
|
1029
|
-
assertApprovalOrigin(approval.stream_url, sdkapiOrigin, "stream_url");
|
|
1030
|
-
}
|
|
1031
|
-
assertApprovalOrigin(approval.approval_url, browserOrigin, "approval_url");
|
|
1032
|
-
}
|
|
1033
|
-
this.emitEvent("approval:required", {
|
|
1034
|
-
approvalId: approval.id,
|
|
1035
|
-
approvalUrl: approval.approval_url,
|
|
1036
|
-
mode: approval.mode,
|
|
1037
|
-
...(approval.stream_url ? { streamUrl: approval.stream_url } : {}),
|
|
1038
|
-
});
|
|
1039
|
-
const shouldOpenAutoModeApproval = this.options.openAutoModeApprovalsInBrowser ??
|
|
1040
|
-
getZapierOpenAutoModeApprovalsInBrowser() ??
|
|
1041
|
-
false;
|
|
1042
|
-
if (approval.mode === "auto") {
|
|
1043
|
-
if (shouldOpenAutoModeApproval) {
|
|
1044
|
-
await openApproval(approval.approval_url);
|
|
1045
|
-
}
|
|
1046
|
-
if (approval.status === "approved") {
|
|
1047
|
-
this.emitEvent("approval:approved", {
|
|
1048
|
-
approvalId: approval.id,
|
|
1049
|
-
});
|
|
1050
|
-
return;
|
|
1051
|
-
}
|
|
1052
|
-
if (approval.status === "denied") {
|
|
1053
|
-
this.emitEvent("approval:denied", {
|
|
1054
|
-
approvalId: approval.id,
|
|
1055
|
-
...(approval.reason ? { reason: approval.reason } : {}),
|
|
1056
|
-
});
|
|
1057
|
-
throw new ZapierApprovalError(approval.reason
|
|
1058
|
-
? `Request denied: ${approval.reason}`
|
|
1059
|
-
: "Request denied by user", {
|
|
1060
|
-
approvalId: approval.id,
|
|
1061
|
-
status: "denied",
|
|
1062
|
-
reason: approval.reason,
|
|
1063
|
-
});
|
|
1064
|
-
}
|
|
1065
|
-
if (approval.status === "failed") {
|
|
1066
|
-
this.throwApprovalFailed({
|
|
1067
|
-
approvalId: approval.id,
|
|
1068
|
-
approvalUrl: approval.approval_url,
|
|
1069
|
-
pollUrl: approval.poll_url,
|
|
1070
|
-
streamUrl: approval.stream_url,
|
|
1071
|
-
reason: approval.reason,
|
|
1072
|
-
});
|
|
1073
|
-
}
|
|
1074
|
-
}
|
|
1075
|
-
else {
|
|
1076
|
-
if (mode === "throw") {
|
|
1077
|
-
throw new ZapierApprovalError("This request requires approval.", {
|
|
1078
|
-
approvalId: approval.id,
|
|
1079
|
-
approvalUrl: approval.approval_url,
|
|
1080
|
-
pollUrl: approval.poll_url,
|
|
1081
|
-
streamUrl: approval.stream_url,
|
|
1082
|
-
status: "pending",
|
|
1083
|
-
});
|
|
1084
|
-
}
|
|
1085
|
-
// mode === "poll", manual approval — open browser and poll
|
|
1086
|
-
await openApproval(approval.approval_url);
|
|
1087
|
-
}
|
|
1088
|
-
const timeoutMs = this.options.approvalTimeoutMs ?? DEFAULT_APPROVAL_TIMEOUT_MS;
|
|
1089
|
-
let streamAbortController;
|
|
1090
|
-
let streamPromise;
|
|
1091
|
-
let removeStreamAbortListener;
|
|
1092
|
-
if (approval.mode === "auto" && approval.stream_url) {
|
|
1093
|
-
const streamUrl = approval.stream_url;
|
|
1094
|
-
streamAbortController = new AbortController();
|
|
1095
|
-
const abortStream = () => streamAbortController?.abort();
|
|
1096
|
-
if (signal?.aborted) {
|
|
1097
|
-
abortStream();
|
|
1098
|
-
}
|
|
1099
|
-
else if (signal) {
|
|
1100
|
-
signal.addEventListener("abort", abortStream, { once: true });
|
|
1101
|
-
removeStreamAbortListener = () => signal.removeEventListener("abort", abortStream);
|
|
1102
|
-
}
|
|
1103
|
-
streamPromise = consumeApprovalReviewStream({
|
|
1104
|
-
approvalId: approval.id,
|
|
1105
|
-
streamUrl,
|
|
1106
|
-
signal: streamAbortController.signal,
|
|
1107
|
-
stream: (url, streamInit) => this.streamTrustedJsonUrl(url, streamInit),
|
|
1108
|
-
emitEvent: (type, payload) => this.emitEvent(type, payload),
|
|
1109
|
-
});
|
|
1110
|
-
}
|
|
1111
|
-
let rawPollResult;
|
|
1112
|
-
try {
|
|
1113
|
-
rawPollResult = await pollUntilComplete({
|
|
1114
|
-
// poll_url is an absolute URL supplied by the server, so we use
|
|
1115
|
-
// rawFetchUrl directly (skipping path resolution) but still share
|
|
1116
|
-
// auth + interactive-header + 429-retry with the rest of the SDK.
|
|
1117
|
-
// Each individual poll request goes through the concurrency
|
|
1118
|
-
// semaphore — but we deliberately do not hold a slot across the
|
|
1119
|
-
// sleep between polls or across the human-approval wait.
|
|
1120
|
-
fetchPoll: () => this.withSemaphore({ url: approval.poll_url, method: "GET", signal }, () => this.rawFetchUrl(approval.poll_url, {
|
|
1121
|
-
method: "GET",
|
|
1122
|
-
headers: { Accept: "application/json" },
|
|
1123
|
-
signal,
|
|
1124
|
-
})),
|
|
1125
|
-
timeoutMs,
|
|
1126
|
-
maxPollingIntervalMs: APPROVAL_MAX_POLLING_INTERVAL_MS,
|
|
1127
|
-
signal,
|
|
1128
|
-
isPending: (body) => {
|
|
1129
|
-
const parsed = PollApprovalResponseSchema.safeParse(body);
|
|
1130
|
-
return parsed.success && parsed.data.status === "pending_approval";
|
|
1131
|
-
},
|
|
1132
|
-
});
|
|
1133
|
-
}
|
|
1134
|
-
catch (err) {
|
|
1135
|
-
if (!(err instanceof ZapierTimeoutError)) {
|
|
1136
|
-
this.emitEvent("approval:error", {
|
|
1137
|
-
approvalId: approval.id,
|
|
1138
|
-
message: err instanceof Error ? err.message : String(err),
|
|
1139
|
-
});
|
|
1140
|
-
throw err;
|
|
1141
|
-
}
|
|
1142
|
-
this.emitEvent("approval:timeout", {
|
|
1143
|
-
approvalId: approval.id,
|
|
1144
|
-
});
|
|
1145
|
-
throw new ZapierApprovalError(`Approval timed out after ${timeoutMs / 1000} seconds`, {
|
|
1146
|
-
approvalId: approval.id,
|
|
1147
|
-
approvalUrl: approval.approval_url,
|
|
1148
|
-
pollUrl: approval.poll_url,
|
|
1149
|
-
streamUrl: approval.stream_url,
|
|
1150
|
-
status: "timeout",
|
|
1151
|
-
cause: err,
|
|
1152
|
-
});
|
|
1153
|
-
}
|
|
1154
|
-
finally {
|
|
1155
|
-
removeStreamAbortListener?.();
|
|
1156
|
-
streamAbortController?.abort();
|
|
1157
|
-
await streamPromise;
|
|
1158
|
-
}
|
|
1159
|
-
const pollParse = PollApprovalResponseSchema.safeParse(rawPollResult);
|
|
1160
|
-
if (!pollParse.success) {
|
|
1161
|
-
const bodyPreview = typeof rawPollResult === "string"
|
|
1162
|
-
? rawPollResult
|
|
1163
|
-
: JSON.stringify(rawPollResult);
|
|
1164
|
-
this.emitEvent("approval:error", {
|
|
1165
|
-
approvalId: approval.id,
|
|
1166
|
-
message: `Failed to parse approval poll response: ${bodyPreview}`,
|
|
1167
|
-
});
|
|
1168
|
-
throw new ZapierApiError(`Failed to parse approval poll response: ${bodyPreview}`, {
|
|
1169
|
-
statusCode: 0,
|
|
1170
|
-
cause: pollParse.error,
|
|
1171
|
-
response: rawPollResult,
|
|
1172
|
-
});
|
|
1173
|
-
}
|
|
1174
|
-
const pollResult = pollParse.data;
|
|
1175
|
-
if (pollResult.status === "denied") {
|
|
1176
|
-
this.emitEvent("approval:denied", {
|
|
1177
|
-
approvalId: approval.id,
|
|
1178
|
-
...(pollResult.reason ? { reason: pollResult.reason } : {}),
|
|
1179
|
-
});
|
|
1180
|
-
throw new ZapierApprovalError(pollResult.reason
|
|
1181
|
-
? `Request denied: ${pollResult.reason}`
|
|
1182
|
-
: "Request denied by user", {
|
|
1183
|
-
approvalId: approval.id,
|
|
1184
|
-
status: "denied",
|
|
1185
|
-
reason: pollResult.reason,
|
|
1186
|
-
});
|
|
1187
|
-
}
|
|
1188
|
-
if (pollResult.status === "failed") {
|
|
1189
|
-
this.throwApprovalFailed({
|
|
1190
|
-
approvalId: approval.id,
|
|
1191
|
-
approvalUrl: approval.approval_url,
|
|
1192
|
-
pollUrl: approval.poll_url,
|
|
1193
|
-
streamUrl: approval.stream_url,
|
|
1194
|
-
reason: pollResult.reason,
|
|
1195
|
-
});
|
|
1196
|
-
}
|
|
1197
|
-
if (pollResult.status !== "approved") {
|
|
1198
|
-
this.emitEvent("approval:error", {
|
|
1199
|
-
approvalId: approval.id,
|
|
1200
|
-
message: `Unexpected approval status received: ${pollResult.status}`,
|
|
1201
|
-
});
|
|
1202
|
-
throw new ZapierApiError(`Unexpected approval status received: ${pollResult.status}`);
|
|
1203
|
-
}
|
|
1204
|
-
this.emitEvent("approval:approved", {
|
|
1205
|
-
approvalId: approval.id,
|
|
1206
|
-
});
|
|
1207
|
-
}
|
|
1208
|
-
throwApprovalFailed({ approvalId, approvalUrl, pollUrl, streamUrl, reason, }) {
|
|
1209
|
-
this.emitEvent("approval:failed", {
|
|
1210
|
-
approvalId,
|
|
1211
|
-
...(reason ? { reason } : {}),
|
|
1212
|
-
});
|
|
1213
|
-
throw new ZapierApprovalError(reason ? `Approval failed: ${reason}` : "Approval failed", {
|
|
1214
|
-
approvalId,
|
|
1215
|
-
approvalUrl,
|
|
1216
|
-
pollUrl,
|
|
1217
|
-
streamUrl,
|
|
1218
|
-
status: "failed",
|
|
1219
|
-
reason,
|
|
1220
|
-
});
|
|
1221
|
-
}
|
|
1222
|
-
}
|
|
1223
|
-
export const createZapierApi = (options) => {
|
|
1224
|
-
const { debug = false, fetch: originalFetch = globalThis.fetch } = options;
|
|
1225
|
-
const debugLog = createDebugLogger(debug);
|
|
1226
|
-
const debugFetch = createDebugFetch({ originalFetch, debugLog });
|
|
1227
|
-
return new ZapierApiClient({
|
|
1228
|
-
...options,
|
|
1229
|
-
debug,
|
|
1230
|
-
fetch: debugFetch,
|
|
1231
|
-
});
|
|
1232
|
-
};
|