@zapier/zapier-sdk 0.64.0 → 0.67.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +47 -0
- package/README.md +165 -6
- package/dist/api/client.d.ts.map +1 -1
- package/dist/api/client.js +2 -0
- package/dist/api/debug.d.ts.map +1 -1
- package/dist/api/debug.js +6 -4
- package/dist/api/polling.d.ts +2 -0
- package/dist/api/polling.d.ts.map +1 -1
- package/dist/api/polling.js +10 -2
- package/dist/auth.d.ts.map +1 -1
- package/dist/auth.js +8 -5
- package/dist/core-stack.d.ts +24 -0
- package/dist/core-stack.d.ts.map +1 -0
- package/dist/core-stack.js +32 -0
- package/dist/experimental.cjs +1803 -1332
- package/dist/experimental.d.mts +3508 -182
- package/dist/experimental.d.ts +3578 -252
- package/dist/experimental.d.ts.map +1 -1
- package/dist/experimental.js +120 -84
- package/dist/experimental.mjs +1789 -1331
- package/dist/formatters/action.d.ts +4 -0
- package/dist/formatters/action.d.ts.map +1 -0
- package/dist/formatters/action.js +18 -0
- package/dist/formatters/actionResult.d.ts +3 -0
- package/dist/formatters/actionResult.d.ts.map +1 -0
- package/dist/formatters/actionResult.js +25 -0
- package/dist/formatters/app.d.ts +4 -0
- package/dist/formatters/app.d.ts.map +1 -0
- package/dist/formatters/app.js +10 -0
- package/dist/formatters/clientCredentials.d.ts +5 -0
- package/dist/formatters/clientCredentials.d.ts.map +1 -0
- package/dist/formatters/clientCredentials.js +27 -0
- package/dist/formatters/connection.d.ts +4 -0
- package/dist/formatters/connection.d.ts.map +1 -0
- package/dist/formatters/connection.js +26 -0
- package/dist/formatters/field.d.ts +4 -0
- package/dist/formatters/field.d.ts.map +1 -0
- package/dist/formatters/field.js +51 -0
- package/dist/formatters/inputFieldChoice.d.ts +4 -0
- package/dist/formatters/inputFieldChoice.d.ts.map +1 -0
- package/dist/formatters/inputFieldChoice.js +16 -0
- package/dist/formatters/tableField.d.ts +4 -0
- package/dist/formatters/tableField.d.ts.map +1 -0
- package/dist/formatters/tableField.js +7 -0
- package/dist/formatters/tableRecord.d.ts +5 -3
- package/dist/formatters/tableRecord.d.ts.map +1 -1
- package/dist/formatters/tableRecord.js +4 -3
- package/dist/formatters/triggerInbox.d.ts +4 -0
- package/dist/formatters/triggerInbox.d.ts.map +1 -0
- package/dist/formatters/triggerInbox.js +31 -0
- package/dist/formatters/triggerMessage.d.ts +5 -0
- package/dist/formatters/triggerMessage.d.ts.map +1 -0
- package/dist/formatters/triggerMessage.js +34 -0
- package/dist/formatters/userProfile.d.ts +4 -0
- package/dist/formatters/userProfile.d.ts.map +1 -0
- package/dist/formatters/userProfile.js +19 -0
- package/dist/{index-Bfvj0KLi.d.mts → index-Dh0b5NAY.d.mts} +13058 -7731
- package/dist/{index-Bfvj0KLi.d.ts → index-Dh0b5NAY.d.ts} +13058 -7731
- package/dist/index.cjs +1745 -1464
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +12 -9
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +21 -7
- package/dist/index.mjs +1731 -1463
- package/dist/plugins/api/index.d.ts +1 -1
- package/dist/plugins/api/index.js +1 -1
- package/dist/plugins/apps/index.d.ts +8 -5
- package/dist/plugins/apps/index.d.ts.map +1 -1
- package/dist/plugins/apps/index.js +1 -1
- package/dist/plugins/capabilities/index.d.ts +1 -1
- package/dist/plugins/capabilities/index.js +1 -1
- package/dist/plugins/codeSubstrate/cancelDurableRun/index.d.ts +32 -2
- package/dist/plugins/codeSubstrate/cancelDurableRun/index.d.ts.map +1 -1
- package/dist/plugins/codeSubstrate/cancelDurableRun/index.js +1 -1
- package/dist/plugins/codeSubstrate/createWorkflow/index.d.ts +2 -2
- package/dist/plugins/codeSubstrate/createWorkflow/index.js +1 -1
- package/dist/plugins/codeSubstrate/deleteWorkflow/index.d.ts +27 -2
- package/dist/plugins/codeSubstrate/deleteWorkflow/index.d.ts.map +1 -1
- package/dist/plugins/codeSubstrate/deleteWorkflow/index.js +1 -1
- package/dist/plugins/codeSubstrate/disableWorkflow/index.d.ts +27 -2
- package/dist/plugins/codeSubstrate/disableWorkflow/index.d.ts.map +1 -1
- package/dist/plugins/codeSubstrate/disableWorkflow/index.js +1 -1
- package/dist/plugins/codeSubstrate/enableWorkflow/index.d.ts +27 -2
- package/dist/plugins/codeSubstrate/enableWorkflow/index.d.ts.map +1 -1
- package/dist/plugins/codeSubstrate/enableWorkflow/index.js +1 -1
- package/dist/plugins/codeSubstrate/getDurableRun/index.d.ts +32 -2
- package/dist/plugins/codeSubstrate/getDurableRun/index.d.ts.map +1 -1
- package/dist/plugins/codeSubstrate/getDurableRun/index.js +1 -1
- package/dist/plugins/codeSubstrate/getTriggerRun/index.d.ts +47 -0
- package/dist/plugins/codeSubstrate/getTriggerRun/index.d.ts.map +1 -0
- package/dist/plugins/codeSubstrate/getTriggerRun/index.js +23 -0
- package/dist/plugins/codeSubstrate/getTriggerRun/schemas.d.ts +24 -0
- package/dist/plugins/codeSubstrate/getTriggerRun/schemas.d.ts.map +1 -0
- package/dist/plugins/codeSubstrate/getTriggerRun/schemas.js +30 -0
- package/dist/plugins/codeSubstrate/getWorkflow/index.d.ts +27 -2
- package/dist/plugins/codeSubstrate/getWorkflow/index.d.ts.map +1 -1
- package/dist/plugins/codeSubstrate/getWorkflow/index.js +1 -1
- package/dist/plugins/codeSubstrate/getWorkflowRun/index.d.ts +102 -0
- package/dist/plugins/codeSubstrate/getWorkflowRun/index.d.ts.map +1 -0
- package/dist/plugins/codeSubstrate/getWorkflowRun/index.js +25 -0
- package/dist/plugins/codeSubstrate/getWorkflowRun/schemas.d.ts +26 -0
- package/dist/plugins/codeSubstrate/getWorkflowRun/schemas.d.ts.map +1 -0
- package/dist/plugins/codeSubstrate/getWorkflowRun/schemas.js +43 -0
- package/dist/plugins/codeSubstrate/getWorkflowVersion/index.d.ts +51 -2
- package/dist/plugins/codeSubstrate/getWorkflowVersion/index.d.ts.map +1 -1
- package/dist/plugins/codeSubstrate/getWorkflowVersion/index.js +1 -1
- package/dist/plugins/codeSubstrate/listDurableRuns/index.d.ts +3 -3
- package/dist/plugins/codeSubstrate/listDurableRuns/index.d.ts.map +1 -1
- package/dist/plugins/codeSubstrate/listDurableRuns/index.js +1 -1
- package/dist/plugins/codeSubstrate/listWorkflowRuns/index.d.ts +78 -0
- package/dist/plugins/codeSubstrate/listWorkflowRuns/index.d.ts.map +1 -0
- package/dist/plugins/codeSubstrate/listWorkflowRuns/index.js +34 -0
- package/dist/plugins/codeSubstrate/listWorkflowRuns/schemas.d.ts +65 -0
- package/dist/plugins/codeSubstrate/listWorkflowRuns/schemas.d.ts.map +1 -0
- package/dist/plugins/codeSubstrate/listWorkflowRuns/schemas.js +69 -0
- package/dist/plugins/codeSubstrate/listWorkflowVersions/index.d.ts +28 -3
- package/dist/plugins/codeSubstrate/listWorkflowVersions/index.d.ts.map +1 -1
- package/dist/plugins/codeSubstrate/listWorkflowVersions/index.js +1 -1
- package/dist/plugins/codeSubstrate/listWorkflows/index.d.ts +3 -3
- package/dist/plugins/codeSubstrate/listWorkflows/index.d.ts.map +1 -1
- package/dist/plugins/codeSubstrate/listWorkflows/index.js +2 -3
- package/dist/plugins/codeSubstrate/publishWorkflowVersion/index.d.ts +27 -2
- package/dist/plugins/codeSubstrate/publishWorkflowVersion/index.d.ts.map +1 -1
- package/dist/plugins/codeSubstrate/publishWorkflowVersion/index.js +1 -1
- package/dist/plugins/codeSubstrate/runDurable/index.d.ts +2 -2
- package/dist/plugins/codeSubstrate/runDurable/index.js +1 -1
- package/dist/plugins/codeSubstrate/triggerWorkflow/index.d.ts +73 -0
- package/dist/plugins/codeSubstrate/triggerWorkflow/index.d.ts.map +1 -0
- package/dist/plugins/codeSubstrate/triggerWorkflow/index.js +52 -0
- package/dist/plugins/codeSubstrate/triggerWorkflow/schemas.d.ts +16 -0
- package/dist/plugins/codeSubstrate/triggerWorkflow/schemas.d.ts.map +1 -0
- package/dist/plugins/codeSubstrate/triggerWorkflow/schemas.js +31 -0
- package/dist/plugins/codeSubstrate/updateWorkflow/index.d.ts +27 -2
- package/dist/plugins/codeSubstrate/updateWorkflow/index.d.ts.map +1 -1
- package/dist/plugins/codeSubstrate/updateWorkflow/index.js +1 -1
- package/dist/plugins/connections/index.d.ts +1 -1
- package/dist/plugins/connections/index.js +1 -1
- package/dist/plugins/createClientCredentials/index.d.ts +2 -2
- package/dist/plugins/createClientCredentials/index.d.ts.map +1 -1
- package/dist/plugins/createClientCredentials/index.js +4 -2
- package/dist/plugins/createClientCredentials/schemas.d.ts +1 -2
- package/dist/plugins/createClientCredentials/schemas.d.ts.map +1 -1
- package/dist/plugins/deleteClientCredentials/index.d.ts +24 -2
- package/dist/plugins/deleteClientCredentials/index.d.ts.map +1 -1
- package/dist/plugins/deleteClientCredentials/index.js +2 -2
- package/dist/plugins/deleteClientCredentials/schemas.d.ts +1 -2
- package/dist/plugins/deleteClientCredentials/schemas.d.ts.map +1 -1
- package/dist/plugins/deprecated/authentications.d.ts +144 -16
- package/dist/plugins/deprecated/authentications.d.ts.map +1 -1
- package/dist/plugins/deprecated/authentications.js +14 -5
- package/dist/plugins/deprecated/inputFields.d.ts +58 -23
- package/dist/plugins/deprecated/inputFields.d.ts.map +1 -1
- package/dist/plugins/deprecated/inputFields.js +15 -7
- package/dist/plugins/eventEmission/event-emission-hook.d.ts +10 -0
- package/dist/plugins/eventEmission/event-emission-hook.d.ts.map +1 -0
- package/dist/plugins/eventEmission/event-emission-hook.js +47 -0
- package/dist/plugins/eventEmission/index.d.ts +5 -3
- package/dist/plugins/eventEmission/index.d.ts.map +1 -1
- package/dist/plugins/eventEmission/index.js +16 -9
- package/dist/plugins/eventEmission/method-metadata.d.ts +16 -0
- package/dist/plugins/eventEmission/method-metadata.d.ts.map +1 -0
- package/dist/plugins/eventEmission/method-metadata.js +20 -0
- package/dist/plugins/eventEmission/transport.d.ts.map +1 -1
- package/dist/plugins/eventEmission/transport.js +2 -1
- package/dist/plugins/fetch/index.d.ts +11 -5
- package/dist/plugins/fetch/index.d.ts.map +1 -1
- package/dist/plugins/fetch/index.js +42 -32
- package/dist/plugins/fetch/schemas.d.ts +1 -1
- package/dist/plugins/findFirstConnection/index.d.ts +4 -4
- package/dist/plugins/findFirstConnection/index.d.ts.map +1 -1
- package/dist/plugins/findFirstConnection/index.js +4 -2
- package/dist/plugins/findFirstConnection/schemas.d.ts +2 -2
- package/dist/plugins/findUniqueConnection/index.d.ts +4 -4
- package/dist/plugins/findUniqueConnection/index.d.ts.map +1 -1
- package/dist/plugins/findUniqueConnection/index.js +4 -2
- package/dist/plugins/findUniqueConnection/schemas.d.ts +2 -2
- package/dist/plugins/getAction/index.d.ts +141 -4
- package/dist/plugins/getAction/index.d.ts.map +1 -1
- package/dist/plugins/getAction/index.js +5 -3
- package/dist/plugins/getAction/schemas.d.ts +6 -6
- package/dist/plugins/getActionInputFieldsSchema/index.d.ts +232 -3
- package/dist/plugins/getActionInputFieldsSchema/index.d.ts.map +1 -1
- package/dist/plugins/getActionInputFieldsSchema/index.js +3 -3
- package/dist/plugins/getActionInputFieldsSchema/schemas.d.ts +6 -6
- package/dist/plugins/getApp/index.d.ts +4 -4
- package/dist/plugins/getApp/index.d.ts.map +1 -1
- package/dist/plugins/getApp/index.js +3 -1
- package/dist/plugins/getApp/schemas.d.ts +4 -4
- package/dist/plugins/getConnection/index.d.ts +125 -2
- package/dist/plugins/getConnection/index.d.ts.map +1 -1
- package/dist/plugins/getConnection/index.js +4 -2
- package/dist/plugins/getProfile/index.d.ts +2 -2
- package/dist/plugins/getProfile/index.d.ts.map +1 -1
- package/dist/plugins/getProfile/index.js +4 -2
- package/dist/plugins/getProfile/schemas.d.ts +1 -2
- package/dist/plugins/getProfile/schemas.d.ts.map +1 -1
- package/dist/plugins/listActionInputFieldChoices/index.d.ts +287 -4
- package/dist/plugins/listActionInputFieldChoices/index.d.ts.map +1 -1
- package/dist/plugins/listActionInputFieldChoices/index.js +6 -4
- package/dist/plugins/listActionInputFieldChoices/schemas.d.ts +8 -8
- package/dist/plugins/listActionInputFieldChoices/schemas.d.ts.map +1 -1
- package/dist/plugins/listActionInputFieldChoices/schemas.js +1 -22
- package/dist/plugins/listActionInputFields/index.d.ts +168 -5
- package/dist/plugins/listActionInputFields/index.d.ts.map +1 -1
- package/dist/plugins/listActionInputFields/index.js +7 -5
- package/dist/plugins/listActionInputFields/schemas.d.ts +6 -6
- package/dist/plugins/listActions/index.d.ts +140 -3
- package/dist/plugins/listActions/index.d.ts.map +1 -1
- package/dist/plugins/listActions/index.js +6 -4
- package/dist/plugins/listActions/schemas.d.ts +4 -4
- package/dist/plugins/listApps/index.d.ts +3 -3
- package/dist/plugins/listApps/index.d.ts.map +1 -1
- package/dist/plugins/listApps/index.js +6 -4
- package/dist/plugins/listClientCredentials/index.d.ts +3 -3
- package/dist/plugins/listClientCredentials/index.d.ts.map +1 -1
- package/dist/plugins/listClientCredentials/index.js +6 -4
- package/dist/plugins/listConnections/index.d.ts +140 -3
- package/dist/plugins/listConnections/index.d.ts.map +1 -1
- package/dist/plugins/listConnections/index.js +7 -5
- package/dist/plugins/listConnections/schemas.d.ts +2 -2
- package/dist/plugins/manifest/index.d.ts +1 -1
- package/dist/plugins/manifest/index.d.ts.map +1 -1
- package/dist/plugins/manifest/index.js +6 -4
- package/dist/plugins/registry/index.d.ts +1 -1
- package/dist/plugins/registry/index.js +1 -1
- package/dist/plugins/request/index.d.ts +8 -5
- package/dist/plugins/request/index.d.ts.map +1 -1
- package/dist/plugins/request/index.js +4 -3
- package/dist/plugins/request/schemas.d.ts +2 -2
- package/dist/plugins/runAction/index.d.ts +168 -5
- package/dist/plugins/runAction/index.d.ts.map +1 -1
- package/dist/plugins/runAction/index.js +9 -5
- package/dist/plugins/runAction/schemas.d.ts +6 -6
- package/dist/plugins/tables/createTable/index.d.ts +2 -2
- package/dist/plugins/tables/createTable/index.js +2 -2
- package/dist/plugins/tables/createTable/schemas.d.ts +1 -2
- package/dist/plugins/tables/createTable/schemas.d.ts.map +1 -1
- package/dist/plugins/tables/createTableFields/index.d.ts +34 -2
- package/dist/plugins/tables/createTableFields/index.d.ts.map +1 -1
- package/dist/plugins/tables/createTableFields/index.js +4 -2
- package/dist/plugins/tables/createTableFields/schemas.d.ts +3 -4
- package/dist/plugins/tables/createTableFields/schemas.d.ts.map +1 -1
- package/dist/plugins/tables/createTableRecords/index.d.ts +63 -2
- package/dist/plugins/tables/createTableRecords/index.d.ts.map +1 -1
- package/dist/plugins/tables/createTableRecords/index.js +2 -2
- package/dist/plugins/tables/createTableRecords/schemas.d.ts +3 -4
- package/dist/plugins/tables/createTableRecords/schemas.d.ts.map +1 -1
- package/dist/plugins/tables/deleteTable/index.d.ts +34 -2
- package/dist/plugins/tables/deleteTable/index.d.ts.map +1 -1
- package/dist/plugins/tables/deleteTable/index.js +2 -2
- package/dist/plugins/tables/deleteTable/schemas.d.ts +3 -4
- package/dist/plugins/tables/deleteTable/schemas.d.ts.map +1 -1
- package/dist/plugins/tables/deleteTableFields/index.d.ts +63 -2
- package/dist/plugins/tables/deleteTableFields/index.d.ts.map +1 -1
- package/dist/plugins/tables/deleteTableFields/index.js +2 -2
- package/dist/plugins/tables/deleteTableFields/schemas.d.ts +4 -5
- package/dist/plugins/tables/deleteTableFields/schemas.d.ts.map +1 -1
- package/dist/plugins/tables/deleteTableRecords/index.d.ts +84 -2
- package/dist/plugins/tables/deleteTableRecords/index.d.ts.map +1 -1
- package/dist/plugins/tables/deleteTableRecords/index.js +2 -2
- package/dist/plugins/tables/deleteTableRecords/schemas.d.ts +4 -5
- package/dist/plugins/tables/deleteTableRecords/schemas.d.ts.map +1 -1
- package/dist/plugins/tables/getTable/index.d.ts +34 -2
- package/dist/plugins/tables/getTable/index.d.ts.map +1 -1
- package/dist/plugins/tables/getTable/index.js +2 -2
- package/dist/plugins/tables/getTable/schemas.d.ts +2 -2
- package/dist/plugins/tables/getTableRecord/index.d.ts +84 -2
- package/dist/plugins/tables/getTableRecord/index.d.ts.map +1 -1
- package/dist/plugins/tables/getTableRecord/index.js +2 -2
- package/dist/plugins/tables/getTableRecord/schemas.d.ts +6 -7
- package/dist/plugins/tables/getTableRecord/schemas.d.ts.map +1 -1
- package/dist/plugins/tables/getTableRecord/schemas.js +1 -10
- package/dist/plugins/tables/listTableFields/index.d.ts +34 -2
- package/dist/plugins/tables/listTableFields/index.d.ts.map +1 -1
- package/dist/plugins/tables/listTableFields/index.js +4 -2
- package/dist/plugins/tables/listTableFields/schemas.d.ts +4 -5
- package/dist/plugins/tables/listTableFields/schemas.d.ts.map +1 -1
- package/dist/plugins/tables/listTableFields/schemas.js +1 -9
- package/dist/plugins/tables/listTableRecords/index.d.ts +65 -4
- package/dist/plugins/tables/listTableRecords/index.d.ts.map +1 -1
- package/dist/plugins/tables/listTableRecords/index.js +3 -3
- package/dist/plugins/tables/listTableRecords/schemas.d.ts +2 -2
- package/dist/plugins/tables/listTables/index.d.ts +3 -3
- package/dist/plugins/tables/listTables/index.d.ts.map +1 -1
- package/dist/plugins/tables/listTables/index.js +4 -4
- package/dist/plugins/tables/updateTableRecords/index.d.ts +63 -2
- package/dist/plugins/tables/updateTableRecords/index.d.ts.map +1 -1
- package/dist/plugins/tables/updateTableRecords/index.js +2 -2
- package/dist/plugins/tables/updateTableRecords/schemas.d.ts +3 -4
- package/dist/plugins/tables/updateTableRecords/schemas.d.ts.map +1 -1
- package/dist/plugins/triggers/ackTriggerInboxMessages/index.d.ts +59 -2
- package/dist/plugins/triggers/ackTriggerInboxMessages/index.d.ts.map +1 -1
- package/dist/plugins/triggers/ackTriggerInboxMessages/index.js +1 -1
- package/dist/plugins/triggers/ackTriggerInboxMessages/schemas.d.ts +1 -1
- package/dist/plugins/triggers/createTriggerInbox/index.d.ts +231 -2
- package/dist/plugins/triggers/createTriggerInbox/index.d.ts.map +1 -1
- package/dist/plugins/triggers/createTriggerInbox/index.js +3 -1
- package/dist/plugins/triggers/createTriggerInbox/schemas.d.ts +3 -4
- package/dist/plugins/triggers/createTriggerInbox/schemas.d.ts.map +1 -1
- package/dist/plugins/triggers/deleteTriggerInbox/index.d.ts +33 -2
- package/dist/plugins/triggers/deleteTriggerInbox/index.d.ts.map +1 -1
- package/dist/plugins/triggers/deleteTriggerInbox/index.js +3 -1
- package/dist/plugins/triggers/deleteTriggerInbox/schemas.d.ts +2 -3
- package/dist/plugins/triggers/deleteTriggerInbox/schemas.d.ts.map +1 -1
- package/dist/plugins/triggers/drainTriggerInbox/index.d.ts +68 -6
- package/dist/plugins/triggers/drainTriggerInbox/index.d.ts.map +1 -1
- package/dist/plugins/triggers/drainTriggerInbox/index.js +1 -1
- package/dist/plugins/triggers/drainTriggerInbox/schemas.d.ts +2 -2
- package/dist/plugins/triggers/ensureTriggerInbox/index.d.ts +231 -2
- package/dist/plugins/triggers/ensureTriggerInbox/index.d.ts.map +1 -1
- package/dist/plugins/triggers/ensureTriggerInbox/index.js +3 -1
- package/dist/plugins/triggers/ensureTriggerInbox/schemas.d.ts +3 -4
- package/dist/plugins/triggers/ensureTriggerInbox/schemas.d.ts.map +1 -1
- package/dist/plugins/triggers/getTriggerInbox/index.d.ts +33 -2
- package/dist/plugins/triggers/getTriggerInbox/index.d.ts.map +1 -1
- package/dist/plugins/triggers/getTriggerInbox/index.js +3 -1
- package/dist/plugins/triggers/getTriggerInbox/schemas.d.ts +2 -3
- package/dist/plugins/triggers/getTriggerInbox/schemas.d.ts.map +1 -1
- package/dist/plugins/triggers/getTriggerInputFieldsSchema/index.d.ts +232 -3
- package/dist/plugins/triggers/getTriggerInputFieldsSchema/index.d.ts.map +1 -1
- package/dist/plugins/triggers/getTriggerInputFieldsSchema/index.js +1 -1
- package/dist/plugins/triggers/getTriggerInputFieldsSchema/schemas.d.ts +2 -2
- package/dist/plugins/triggers/leaseTriggerInboxMessages/index.d.ts +33 -2
- package/dist/plugins/triggers/leaseTriggerInboxMessages/index.d.ts.map +1 -1
- package/dist/plugins/triggers/leaseTriggerInboxMessages/index.js +1 -1
- package/dist/plugins/triggers/leaseTriggerInboxMessages/schemas.d.ts +1 -1
- package/dist/plugins/triggers/listTriggerInboxMessages/index.d.ts +34 -3
- package/dist/plugins/triggers/listTriggerInboxMessages/index.d.ts.map +1 -1
- package/dist/plugins/triggers/listTriggerInboxMessages/index.js +5 -13
- package/dist/plugins/triggers/listTriggerInboxMessages/schemas.d.ts +1 -1
- package/dist/plugins/triggers/listTriggerInboxes/index.d.ts +3 -3
- package/dist/plugins/triggers/listTriggerInboxes/index.d.ts.map +1 -1
- package/dist/plugins/triggers/listTriggerInboxes/index.js +5 -14
- package/dist/plugins/triggers/listTriggerInputFieldChoices/index.d.ts +288 -5
- package/dist/plugins/triggers/listTriggerInputFieldChoices/index.d.ts.map +1 -1
- package/dist/plugins/triggers/listTriggerInputFieldChoices/index.js +7 -5
- package/dist/plugins/triggers/listTriggerInputFieldChoices/schemas.d.ts +3 -3
- package/dist/plugins/triggers/listTriggerInputFields/index.d.ts +234 -5
- package/dist/plugins/triggers/listTriggerInputFields/index.d.ts.map +1 -1
- package/dist/plugins/triggers/listTriggerInputFields/index.js +6 -5
- package/dist/plugins/triggers/listTriggerInputFields/schemas.d.ts +2 -2
- package/dist/plugins/triggers/listTriggers/index.d.ts +142 -5
- package/dist/plugins/triggers/listTriggers/index.d.ts.map +1 -1
- package/dist/plugins/triggers/listTriggers/index.js +6 -5
- package/dist/plugins/triggers/listTriggers/schemas.d.ts +1 -1
- package/dist/plugins/triggers/pauseTriggerInbox/index.d.ts +33 -2
- package/dist/plugins/triggers/pauseTriggerInbox/index.d.ts.map +1 -1
- package/dist/plugins/triggers/pauseTriggerInbox/index.js +3 -1
- package/dist/plugins/triggers/pauseTriggerInbox/schemas.d.ts +2 -3
- package/dist/plugins/triggers/pauseTriggerInbox/schemas.d.ts.map +1 -1
- package/dist/plugins/triggers/releaseTriggerInboxMessages/index.d.ts +59 -2
- package/dist/plugins/triggers/releaseTriggerInboxMessages/index.d.ts.map +1 -1
- package/dist/plugins/triggers/releaseTriggerInboxMessages/index.js +1 -1
- package/dist/plugins/triggers/releaseTriggerInboxMessages/schemas.d.ts +1 -1
- package/dist/plugins/triggers/resumeTriggerInbox/index.d.ts +33 -2
- package/dist/plugins/triggers/resumeTriggerInbox/index.d.ts.map +1 -1
- package/dist/plugins/triggers/resumeTriggerInbox/index.js +3 -1
- package/dist/plugins/triggers/resumeTriggerInbox/schemas.d.ts +2 -3
- package/dist/plugins/triggers/resumeTriggerInbox/schemas.d.ts.map +1 -1
- package/dist/plugins/triggers/updateTriggerInbox/index.d.ts +33 -2
- package/dist/plugins/triggers/updateTriggerInbox/index.d.ts.map +1 -1
- package/dist/plugins/triggers/updateTriggerInbox/index.js +3 -1
- package/dist/plugins/triggers/updateTriggerInbox/schemas.d.ts +2 -3
- package/dist/plugins/triggers/updateTriggerInbox/schemas.d.ts.map +1 -1
- package/dist/plugins/triggers/watchTriggerInbox/index.d.ts +37 -6
- package/dist/plugins/triggers/watchTriggerInbox/index.d.ts.map +1 -1
- package/dist/plugins/triggers/watchTriggerInbox/index.js +1 -1
- package/dist/resolvers/actionKey.d.ts +3 -2
- package/dist/resolvers/actionKey.d.ts.map +1 -1
- package/dist/resolvers/actionType.d.ts +7 -2
- package/dist/resolvers/actionType.d.ts.map +1 -1
- package/dist/resolvers/actionType.js +3 -0
- package/dist/resolvers/appKey.d.ts +10 -5
- package/dist/resolvers/appKey.d.ts.map +1 -1
- package/dist/resolvers/appKey.js +3 -0
- package/dist/resolvers/clientCredentialsName.d.ts +1 -1
- package/dist/resolvers/clientCredentialsName.d.ts.map +1 -1
- package/dist/resolvers/clientId.d.ts +3 -2
- package/dist/resolvers/clientId.d.ts.map +1 -1
- package/dist/resolvers/clientId.js +1 -1
- package/dist/resolvers/connectionId.d.ts +5 -2
- package/dist/resolvers/connectionId.d.ts.map +1 -1
- package/dist/resolvers/connectionId.js +1 -1
- package/dist/resolvers/durableRunId.d.ts +3 -2
- package/dist/resolvers/durableRunId.d.ts.map +1 -1
- package/dist/resolvers/durableRunId.js +3 -2
- package/dist/resolvers/index.d.ts +1 -0
- package/dist/resolvers/index.d.ts.map +1 -1
- package/dist/resolvers/index.js +1 -0
- package/dist/resolvers/inputFieldKey.d.ts +3 -2
- package/dist/resolvers/inputFieldKey.d.ts.map +1 -1
- package/dist/resolvers/inputFieldKey.js +1 -1
- package/dist/resolvers/tableFieldIds.d.ts +3 -2
- package/dist/resolvers/tableFieldIds.d.ts.map +1 -1
- package/dist/resolvers/tableFields.d.ts +2 -2
- package/dist/resolvers/tableFields.d.ts.map +1 -1
- package/dist/resolvers/tableFilters.d.ts +3 -2
- package/dist/resolvers/tableFilters.d.ts.map +1 -1
- package/dist/resolvers/tableId.d.ts +3 -2
- package/dist/resolvers/tableId.d.ts.map +1 -1
- package/dist/resolvers/tableId.js +1 -1
- package/dist/resolvers/tableName.d.ts +1 -1
- package/dist/resolvers/tableName.d.ts.map +1 -1
- package/dist/resolvers/tableRecordId.d.ts +4 -3
- package/dist/resolvers/tableRecordId.d.ts.map +1 -1
- package/dist/resolvers/tableRecords.d.ts +4 -3
- package/dist/resolvers/tableRecords.d.ts.map +1 -1
- package/dist/resolvers/tableSort.d.ts +3 -2
- package/dist/resolvers/tableSort.d.ts.map +1 -1
- package/dist/resolvers/triggerInbox.d.ts +3 -2
- package/dist/resolvers/triggerInbox.d.ts.map +1 -1
- package/dist/resolvers/triggerInbox.js +1 -1
- package/dist/resolvers/triggerMessages.d.ts +3 -2
- package/dist/resolvers/triggerMessages.d.ts.map +1 -1
- package/dist/resolvers/triggerMessages.js +2 -4
- package/dist/resolvers/workflowId.d.ts +3 -2
- package/dist/resolvers/workflowId.d.ts.map +1 -1
- package/dist/resolvers/workflowId.js +3 -2
- package/dist/resolvers/workflowRunId.d.ts +7 -0
- package/dist/resolvers/workflowRunId.d.ts.map +1 -0
- package/dist/resolvers/workflowRunId.js +20 -0
- package/dist/resolvers/workflowVersionId.d.ts +3 -2
- package/dist/resolvers/workflowVersionId.d.ts.map +1 -1
- package/dist/resolvers/workflowVersionId.js +7 -7
- package/dist/schemas/Action.d.ts.map +1 -1
- package/dist/schemas/Action.js +6 -30
- package/dist/schemas/App.d.ts +0 -1
- package/dist/schemas/App.d.ts.map +1 -1
- package/dist/schemas/App.js +2 -14
- package/dist/schemas/ClientCredentials.d.ts.map +1 -1
- package/dist/schemas/ClientCredentials.js +3 -41
- package/dist/schemas/Connection.d.ts.map +1 -1
- package/dist/schemas/Connection.js +2 -28
- package/dist/schemas/Field.d.ts.map +1 -1
- package/dist/schemas/Field.js +3 -70
- package/dist/schemas/Run.d.ts.map +1 -1
- package/dist/schemas/Run.js +3 -29
- package/dist/schemas/TriggerInbox.d.ts.map +1 -1
- package/dist/schemas/TriggerInbox.js +1 -33
- package/dist/schemas/TriggerMessage.d.ts.map +1 -1
- package/dist/schemas/TriggerMessage.js +2 -60
- package/dist/schemas/UserProfile.d.ts +0 -1
- package/dist/schemas/UserProfile.d.ts.map +1 -1
- package/dist/schemas/UserProfile.js +1 -20
- package/dist/sdk.d.ts +2761 -441
- package/dist/sdk.d.ts.map +1 -1
- package/dist/sdk.js +93 -129
- package/dist/types/errors.d.ts +44 -42
- package/dist/types/errors.d.ts.map +1 -1
- package/dist/types/errors.js +79 -33
- package/dist/types/functions.d.ts +1 -41
- package/dist/types/functions.d.ts.map +1 -1
- package/dist/types/properties.d.ts +7 -7
- package/dist/types/properties.js +1 -1
- package/dist/types/sdk.d.ts +1 -1
- package/dist/types/sdk.d.ts.map +1 -1
- package/dist/utils/domain-utils.js +1 -1
- package/dist/utils/logging.d.ts +1 -12
- package/dist/utils/logging.d.ts.map +1 -1
- package/dist/utils/logging.js +2 -20
- package/dist/utils/pagination.d.ts +38 -0
- package/dist/utils/pagination.d.ts.map +1 -0
- package/dist/utils/pagination.js +53 -0
- package/package.json +3 -2
- package/dist/registry.d.ts +0 -9
- package/dist/registry.d.ts.map +0 -1
- package/dist/registry.js +0 -103
- package/dist/types/meta.d.ts +0 -9
- package/dist/types/meta.d.ts.map +0 -1
- package/dist/types/meta.js +0 -3
- package/dist/types/plugin.d.ts +0 -84
- package/dist/types/plugin.d.ts.map +0 -1
- package/dist/types/plugin.js +0 -13
- package/dist/types/registry.d.ts +0 -54
- package/dist/types/registry.d.ts.map +0 -1
- package/dist/types/registry.js +0 -1
- package/dist/utils/function-utils.d.ts +0 -59
- package/dist/utils/function-utils.d.ts.map +0 -1
- package/dist/utils/function-utils.js +0 -245
- package/dist/utils/pagination-utils.d.ts +0 -73
- package/dist/utils/pagination-utils.d.ts.map +0 -1
- package/dist/utils/pagination-utils.js +0 -308
- package/dist/utils/plugin-utils.d.ts +0 -245
- package/dist/utils/plugin-utils.d.ts.map +0 -1
- package/dist/utils/plugin-utils.js +0 -234
- package/dist/utils/schema-utils.d.ts +0 -211
- package/dist/utils/schema-utils.d.ts.map +0 -1
- package/dist/utils/schema-utils.js +0 -72
- package/dist/utils/string-utils.d.ts +0 -40
- package/dist/utils/string-utils.d.ts.map +0 -1
- package/dist/utils/string-utils.js +0 -69
- package/dist/utils/telemetry-context.d.ts +0 -15
- package/dist/utils/telemetry-context.d.ts.map +0 -1
- package/dist/utils/telemetry-context.js +0 -48
- package/dist/utils/telemetry-utils.d.ts +0 -44
- package/dist/utils/telemetry-utils.d.ts.map +0 -1
- package/dist/utils/telemetry-utils.js +0 -60
- package/dist/utils/validation.d.ts +0 -4
- package/dist/utils/validation.d.ts.map +0 -1
- package/dist/utils/validation.js +0 -30
|
@@ -1,245 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* ------------------------------
|
|
3
|
-
* Plugin authoring helpers
|
|
4
|
-
* ------------------------------
|
|
5
|
-
*
|
|
6
|
-
* - `definePlugin`: identity wrapper that constrains a plugin's return to
|
|
7
|
-
* `PluginProvides` while preserving the narrow inferred shape, so callers
|
|
8
|
-
* can derive their `*PluginProvides` type via `ReturnType<typeof plugin>`
|
|
9
|
-
* instead of declaring it by hand.
|
|
10
|
-
* - `createPluginMethod` / `createPaginatedPluginMethod`: per-method
|
|
11
|
-
* primitives that sit inside a `definePlugin` callback and build the
|
|
12
|
-
*
|
|
13
|
-
* { [name]: wrappedFn, context: { meta: { [name]: meta } } }
|
|
14
|
-
*
|
|
15
|
-
* fragment a plugin returns for a single method, wiring up
|
|
16
|
-
* `createFunction` / `createPaginatedFunction`, the telemetry callback,
|
|
17
|
-
* and the doubled `name` (function key + meta key) in one place.
|
|
18
|
-
*
|
|
19
|
-
* Two method helpers (rather than one with a `paginated: true` discriminant)
|
|
20
|
-
* because the handler signature changes shape across pagination, and
|
|
21
|
-
* discriminated unions on optional booleans produce noisy TS errors.
|
|
22
|
-
*/
|
|
23
|
-
import type { z } from "zod";
|
|
24
|
-
import type { PaginatedSdkResult } from "../types/functions";
|
|
25
|
-
import type { Plugin, PluginMeta, PluginProvides } from "../types/plugin";
|
|
26
|
-
/**
|
|
27
|
-
* Identity helper that preserves the narrow inferred return type of a plugin.
|
|
28
|
-
*
|
|
29
|
-
* Wrapping a plugin function with `definePlugin(...)` lets callers derive the
|
|
30
|
-
* plugin's contribution via `ReturnType<typeof plugin>` instead of declaring a
|
|
31
|
-
* matching `*PluginProvides` interface by hand. The constraint
|
|
32
|
-
* `TProvides extends PluginProvides` enforces the structural floor (must
|
|
33
|
-
* return a valid plugin output); beyond that the inferred shape flows through.
|
|
34
|
-
*/
|
|
35
|
-
export declare function definePlugin<TSdk, TProvides extends PluginProvides>(fn: (sdk: TSdk & {
|
|
36
|
-
context: {
|
|
37
|
-
meta: Record<string, PluginMeta>;
|
|
38
|
-
};
|
|
39
|
-
}) => TProvides): (sdk: TSdk & {
|
|
40
|
-
context: {
|
|
41
|
-
meta: Record<string, PluginMeta>;
|
|
42
|
-
};
|
|
43
|
-
}) => TProvides;
|
|
44
|
-
/**
|
|
45
|
-
* Method-level meta fields. Mirrors `PluginMeta` minus `inputSchema`, which is
|
|
46
|
-
* passed at the top level alongside the handler and merged into the meta by
|
|
47
|
-
* the helpers themselves.
|
|
48
|
-
*/
|
|
49
|
-
type MethodMeta = Omit<PluginMeta, "inputSchema">;
|
|
50
|
-
interface PluginMethodConfig<TSdk, TInput, TResult, TName extends string> extends MethodMeta {
|
|
51
|
-
name: TName;
|
|
52
|
-
/**
|
|
53
|
-
* Schema for runtime input validation; drives the handler's `options`
|
|
54
|
-
* type. For plugins that accept deprecated parameter aliases this is a
|
|
55
|
-
* `z.union([CanonicalSchema, DeprecatedSchema])` — the registry
|
|
56
|
-
* unwraps unions and exposes only the first variant (canonical) to
|
|
57
|
-
* docs, CLI help, and MCP tool definitions.
|
|
58
|
-
*/
|
|
59
|
-
inputSchema?: z.ZodSchema<TInput>;
|
|
60
|
-
handler: (args: {
|
|
61
|
-
sdk: TSdk;
|
|
62
|
-
options: TInput;
|
|
63
|
-
}) => Promise<TResult>;
|
|
64
|
-
}
|
|
65
|
-
type PluginMethodReturn<TName extends string, TInput, TResult> = {
|
|
66
|
-
[K in TName]: (options?: TInput) => Promise<TResult>;
|
|
67
|
-
} & {
|
|
68
|
-
context: {
|
|
69
|
-
meta: {
|
|
70
|
-
[K in TName]: PluginMeta;
|
|
71
|
-
};
|
|
72
|
-
};
|
|
73
|
-
};
|
|
74
|
-
/**
|
|
75
|
-
* Build the method fragment for a non-paginated SDK method. Used inside a
|
|
76
|
-
* `definePlugin(...)` callback:
|
|
77
|
-
*
|
|
78
|
-
* export const getProfilePlugin = definePlugin(
|
|
79
|
-
* (sdk: ApiPluginProvides & EventEmissionProvides) =>
|
|
80
|
-
* createPluginMethod(sdk, {
|
|
81
|
-
* name: "getProfile",
|
|
82
|
-
* categories: ["account"],
|
|
83
|
-
* inputSchema: GetProfileSchema,
|
|
84
|
-
* handler: async ({ sdk }) => { ... },
|
|
85
|
-
* }),
|
|
86
|
-
* );
|
|
87
|
-
*/
|
|
88
|
-
export declare function createPluginMethod<const TName extends string, TSdk extends {
|
|
89
|
-
context: unknown;
|
|
90
|
-
}, TInput, TResult>(sdk: TSdk, config: PluginMethodConfig<TSdk, TInput, TResult, TName>): PluginMethodReturn<TName, TInput, TResult>;
|
|
91
|
-
interface PaginatedPluginMethodConfig<TSdk, TInput, TResponse extends {
|
|
92
|
-
data: unknown[];
|
|
93
|
-
}, TName extends string> extends MethodMeta {
|
|
94
|
-
name: TName;
|
|
95
|
-
/** Same semantics as `createPluginMethod`'s `inputSchema`. */
|
|
96
|
-
inputSchema?: z.ZodSchema<TInput>;
|
|
97
|
-
/**
|
|
98
|
-
* Optional default page size when the caller doesn't pass one. Mirrors
|
|
99
|
-
* `createPaginatedFunction`'s `defaultPageSize` arg.
|
|
100
|
-
*/
|
|
101
|
-
defaultPageSize?: number;
|
|
102
|
-
/**
|
|
103
|
-
* Page handler. Returns whatever shape the upstream API gives back, as
|
|
104
|
-
* long as it has a `data: TItem[]` field. JSON:API envelopes
|
|
105
|
-
* (`{ data, links, meta }`) work directly: pair them with
|
|
106
|
-
* `extractCursor` below to pull the next-page cursor out of the response.
|
|
107
|
-
*/
|
|
108
|
-
handler: (args: {
|
|
109
|
-
sdk: TSdk;
|
|
110
|
-
options: TInput & {
|
|
111
|
-
cursor?: string;
|
|
112
|
-
pageSize?: number;
|
|
113
|
-
};
|
|
114
|
-
}) => Promise<TResponse>;
|
|
115
|
-
/**
|
|
116
|
-
* Pull the next-page cursor out of the handler's response. Most JSON:API
|
|
117
|
-
* endpoints will use `(response) => extractCursor(response.links)` from
|
|
118
|
-
* `function-utils`. Provide a custom extractor for non-standard shapes
|
|
119
|
-
* (e.g. `(response) => response.meta?.pagination?.end_cursor`).
|
|
120
|
-
*
|
|
121
|
-
* If omitted, the runtime falls back to its built-in detection
|
|
122
|
-
* (`response.nextCursor` or `response.links?.next` URL parsing) — i.e.
|
|
123
|
-
* the same auto-detection that worked before this helper existed. New
|
|
124
|
-
* plugins should set `extractCursor` explicitly so the pagination shape
|
|
125
|
-
* is visible at the call site.
|
|
126
|
-
*/
|
|
127
|
-
extractCursor?: (response: TResponse) => string | undefined;
|
|
128
|
-
}
|
|
129
|
-
type ItemOf<TResponse extends {
|
|
130
|
-
data: unknown[];
|
|
131
|
-
}> = TResponse extends {
|
|
132
|
-
data: readonly (infer TItem)[];
|
|
133
|
-
} ? TItem : never;
|
|
134
|
-
type PaginatedPluginMethodReturn<TName extends string, TInput, TItem> = {
|
|
135
|
-
[K in TName]: (options?: TInput & {
|
|
136
|
-
cursor?: string;
|
|
137
|
-
pageSize?: number;
|
|
138
|
-
maxItems?: number;
|
|
139
|
-
}) => PaginatedSdkResult<TItem>;
|
|
140
|
-
} & {
|
|
141
|
-
context: {
|
|
142
|
-
meta: {
|
|
143
|
-
[K in TName]: PluginMeta;
|
|
144
|
-
};
|
|
145
|
-
};
|
|
146
|
-
};
|
|
147
|
-
/**
|
|
148
|
-
* Paginated variant of `createPluginMethod`. The handler receives
|
|
149
|
-
* `{ cursor?, pageSize? }` in `options` and returns whatever shape the
|
|
150
|
-
* upstream API gives back, as long as it has a `data: TItem[]` field.
|
|
151
|
-
* Pair JSON:API responses with `extractCursor` to make the cursor
|
|
152
|
-
* extraction visible at the call site:
|
|
153
|
-
*
|
|
154
|
-
* createPaginatedPluginMethod(sdk, {
|
|
155
|
-
* name: "listApps",
|
|
156
|
-
* inputSchema: ListAppsSchema,
|
|
157
|
-
* handler: ({ sdk, options }) =>
|
|
158
|
-
* sdk.context.api.get<ListAppsResponse>("/api/v0/apps", {...}),
|
|
159
|
-
* extractCursor: (response) => extractCursor(response.links),
|
|
160
|
-
* });
|
|
161
|
-
*/
|
|
162
|
-
export declare function createPaginatedPluginMethod<const TName extends string, TSdk extends {
|
|
163
|
-
context: unknown;
|
|
164
|
-
}, TInput, TResponse extends {
|
|
165
|
-
data: unknown[];
|
|
166
|
-
}>(sdk: TSdk, config: PaginatedPluginMethodConfig<TSdk, TInput, TResponse, TName>): PaginatedPluginMethodReturn<TName, TInput, ItemOf<TResponse>>;
|
|
167
|
-
/**
|
|
168
|
-
* Maps a tuple of plugins to a tuple of their TSdk requirement types.
|
|
169
|
-
*
|
|
170
|
-
* SdkRequirementsOf<[Plugin<{ api }, _>, Plugin<{ options }, _>]>
|
|
171
|
-
* = [{ api }, { options }]
|
|
172
|
-
*/
|
|
173
|
-
type SdkRequirementsOf<T extends readonly Plugin<any, any>[]> = {
|
|
174
|
-
[K in keyof T]: T[K] extends Plugin<infer Sdk, any> ? Sdk : never;
|
|
175
|
-
};
|
|
176
|
-
/**
|
|
177
|
-
* Maps a tuple of plugins to a tuple of their TProvides output types.
|
|
178
|
-
*
|
|
179
|
-
* ProvidesOf<[Plugin<_, { hello }>, Plugin<_, { goodbye }>]>
|
|
180
|
-
* = [{ hello }, { goodbye }]
|
|
181
|
-
*/
|
|
182
|
-
type ProvidesOf<T extends readonly Plugin<any, any>[]> = {
|
|
183
|
-
[K in keyof T]: T[K] extends Plugin<any, infer Provides> ? Provides : never;
|
|
184
|
-
};
|
|
185
|
-
/**
|
|
186
|
-
* Intersects every member of a tuple into a single combined type. The
|
|
187
|
-
* result is an object that has every property of every member at once.
|
|
188
|
-
*
|
|
189
|
-
* IntersectAll<[{ api }, { options }]> = { api } & { options }
|
|
190
|
-
* IntersectAll<[]> = {}
|
|
191
|
-
*
|
|
192
|
-
* Walks recursively: head & IntersectAll<tail>, base case is the empty
|
|
193
|
-
* tuple. Why intersection (`&`) and not union (`|`): the composed plugin
|
|
194
|
-
* must require ALL of the sub-plugins' needs at once — an SDK that has
|
|
195
|
-
* both `api` AND `options` — not "either api or options."
|
|
196
|
-
*/
|
|
197
|
-
type IntersectAll<T extends readonly unknown[]> = T extends readonly [
|
|
198
|
-
infer Head,
|
|
199
|
-
...infer Tail
|
|
200
|
-
] ? Head & IntersectAll<Tail> : {};
|
|
201
|
-
/**
|
|
202
|
-
* The TSdk a composed plugin requires: every sub-plugin's TSdk requirement,
|
|
203
|
-
* all at once. Composing a plugin that needs `{ api }` with one that needs
|
|
204
|
-
* `{ options }` yields a composed plugin that needs `{ api } & { options }`.
|
|
205
|
-
*/
|
|
206
|
-
type ComposeSdk<T extends readonly Plugin<any, any>[]> = IntersectAll<SdkRequirementsOf<T>>;
|
|
207
|
-
/**
|
|
208
|
-
* What a composed plugin provides: every sub-plugin's TProvides combined.
|
|
209
|
-
* Composing a plugin that provides `{ hello }` with one that provides
|
|
210
|
-
* `{ goodbye }` yields `{ hello } & { goodbye }`.
|
|
211
|
-
*/
|
|
212
|
-
type ComposeProvides<T extends readonly Plugin<any, any>[]> = IntersectAll<ProvidesOf<T>>;
|
|
213
|
-
/**
|
|
214
|
-
* Bundle N plugins into a single plugin so a consumer can call
|
|
215
|
-
* `addPlugin(combined)` once. Use this when an extension package wants to
|
|
216
|
-
* expose granular sub-plugins for tree-shaking *and* a one-call convenience
|
|
217
|
-
* entry point.
|
|
218
|
-
*
|
|
219
|
-
* Three commitments (per the boilerplate-reduction design):
|
|
220
|
-
* 1. **Bag mode.** Sub-plugins must not depend on each other; order is
|
|
221
|
-
* irrelevant. If you need pipeline composition (later sub-plugins
|
|
222
|
-
* reading earlier sub-plugins' outputs), use a regular `definePlugin`
|
|
223
|
-
* callback that calls each `createPluginMethod` in turn.
|
|
224
|
-
* 2. **Over-approximation of TSdk.** The composed plugin requires the
|
|
225
|
-
* intersection of every sub-plugin's requirements (all of them, all at
|
|
226
|
-
* once). Works fine for homogeneous-deps groups; widens slightly for
|
|
227
|
-
* heterogeneous ones, which keeps the variadic types tractable.
|
|
228
|
-
* 3. **Collision detection.** Throws on duplicate root keys, duplicate
|
|
229
|
-
* `context.meta` keys, and duplicate non-meta `context.*` keys
|
|
230
|
-
* *inside* a single `composePlugins(...)` call. Cross-`addPlugin`
|
|
231
|
-
* collisions are handled separately by `addPlugin` itself, which
|
|
232
|
-
* warns-and-skips the colliding plugin (the first registration
|
|
233
|
-
* wins). Pure meta-only overrides (e.g. `cliOverridesPlugin`
|
|
234
|
-
* patching `meta.fetch.deprecated` without re-registering `fetch`)
|
|
235
|
-
* stay legitimate in both code paths.
|
|
236
|
-
*
|
|
237
|
-
* Why prefer this over an `addPlugin([...])` array overload: TypeScript's
|
|
238
|
-
* overload resolution interacts badly with arrays carrying a mix of
|
|
239
|
-
* `TProvides` shapes — chained inference downstream of `addPlugin([...])`
|
|
240
|
-
* tends to widen and lose individual method types. A single composed
|
|
241
|
-
* plugin flows through the existing single-plugin `addPlugin` cleanly.
|
|
242
|
-
*/
|
|
243
|
-
export declare function composePlugins<const Ts extends readonly Plugin<any, any>[]>(...plugins: Ts): Plugin<ComposeSdk<Ts>, ComposeProvides<Ts>>;
|
|
244
|
-
export {};
|
|
245
|
-
//# sourceMappingURL=plugin-utils.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"plugin-utils.d.ts","sourceRoot":"","sources":["../../src/utils/plugin-utils.ts"],"names":[],"mappings":"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"}
|
|
@@ -1,234 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* ------------------------------
|
|
3
|
-
* Plugin authoring helpers
|
|
4
|
-
* ------------------------------
|
|
5
|
-
*
|
|
6
|
-
* - `definePlugin`: identity wrapper that constrains a plugin's return to
|
|
7
|
-
* `PluginProvides` while preserving the narrow inferred shape, so callers
|
|
8
|
-
* can derive their `*PluginProvides` type via `ReturnType<typeof plugin>`
|
|
9
|
-
* instead of declaring it by hand.
|
|
10
|
-
* - `createPluginMethod` / `createPaginatedPluginMethod`: per-method
|
|
11
|
-
* primitives that sit inside a `definePlugin` callback and build the
|
|
12
|
-
*
|
|
13
|
-
* { [name]: wrappedFn, context: { meta: { [name]: meta } } }
|
|
14
|
-
*
|
|
15
|
-
* fragment a plugin returns for a single method, wiring up
|
|
16
|
-
* `createFunction` / `createPaginatedFunction`, the telemetry callback,
|
|
17
|
-
* and the doubled `name` (function key + meta key) in one place.
|
|
18
|
-
*
|
|
19
|
-
* Two method helpers (rather than one with a `paginated: true` discriminant)
|
|
20
|
-
* because the handler signature changes shape across pagination, and
|
|
21
|
-
* discriminated unions on optional booleans produce noisy TS errors.
|
|
22
|
-
*/
|
|
23
|
-
import { createFunction, createPaginatedFunction } from "./function-utils";
|
|
24
|
-
import { createTelemetryCallback } from "./telemetry-utils";
|
|
25
|
-
/**
|
|
26
|
-
* Identity helper that preserves the narrow inferred return type of a plugin.
|
|
27
|
-
*
|
|
28
|
-
* Wrapping a plugin function with `definePlugin(...)` lets callers derive the
|
|
29
|
-
* plugin's contribution via `ReturnType<typeof plugin>` instead of declaring a
|
|
30
|
-
* matching `*PluginProvides` interface by hand. The constraint
|
|
31
|
-
* `TProvides extends PluginProvides` enforces the structural floor (must
|
|
32
|
-
* return a valid plugin output); beyond that the inferred shape flows through.
|
|
33
|
-
*/
|
|
34
|
-
export function definePlugin(fn) {
|
|
35
|
-
return fn;
|
|
36
|
-
}
|
|
37
|
-
/**
|
|
38
|
-
* Build a telemetry callback only when the SDK actually has eventEmission
|
|
39
|
-
* wired up. Plugin tests sometimes assemble a minimal SDK without the
|
|
40
|
-
* eventEmission plugin; in that case telemetry is silently skipped, matching
|
|
41
|
-
* the legacy `createFunction` behavior of accepting an undefined telemetry
|
|
42
|
-
* arg.
|
|
43
|
-
*/
|
|
44
|
-
function maybeTelemetry(sdk, name) {
|
|
45
|
-
const ctx = sdk.context;
|
|
46
|
-
if (!ctx.eventEmission)
|
|
47
|
-
return undefined;
|
|
48
|
-
return createTelemetryCallback(ctx.eventEmission.emitMethodCalled, name);
|
|
49
|
-
}
|
|
50
|
-
/**
|
|
51
|
-
* Build the method fragment for a non-paginated SDK method. Used inside a
|
|
52
|
-
* `definePlugin(...)` callback:
|
|
53
|
-
*
|
|
54
|
-
* export const getProfilePlugin = definePlugin(
|
|
55
|
-
* (sdk: ApiPluginProvides & EventEmissionProvides) =>
|
|
56
|
-
* createPluginMethod(sdk, {
|
|
57
|
-
* name: "getProfile",
|
|
58
|
-
* categories: ["account"],
|
|
59
|
-
* inputSchema: GetProfileSchema,
|
|
60
|
-
* handler: async ({ sdk }) => { ... },
|
|
61
|
-
* }),
|
|
62
|
-
* );
|
|
63
|
-
*/
|
|
64
|
-
export function createPluginMethod(sdk, config) {
|
|
65
|
-
const { name, inputSchema, handler, ...metaFields } = config;
|
|
66
|
-
// Preserve the method name on the inner function so telemetry and any
|
|
67
|
-
// `function.name`-based diagnostics see the right value.
|
|
68
|
-
const namedHandlers = {
|
|
69
|
-
[name]: async function (options) {
|
|
70
|
-
return handler({ sdk, options });
|
|
71
|
-
},
|
|
72
|
-
};
|
|
73
|
-
const wrappedFn = createFunction(namedHandlers[name], inputSchema, maybeTelemetry(sdk, name));
|
|
74
|
-
return {
|
|
75
|
-
[name]: wrappedFn,
|
|
76
|
-
context: {
|
|
77
|
-
meta: {
|
|
78
|
-
[name]: {
|
|
79
|
-
...metaFields,
|
|
80
|
-
...(inputSchema ? { inputSchema } : {}),
|
|
81
|
-
},
|
|
82
|
-
},
|
|
83
|
-
},
|
|
84
|
-
};
|
|
85
|
-
}
|
|
86
|
-
/**
|
|
87
|
-
* Paginated variant of `createPluginMethod`. The handler receives
|
|
88
|
-
* `{ cursor?, pageSize? }` in `options` and returns whatever shape the
|
|
89
|
-
* upstream API gives back, as long as it has a `data: TItem[]` field.
|
|
90
|
-
* Pair JSON:API responses with `extractCursor` to make the cursor
|
|
91
|
-
* extraction visible at the call site:
|
|
92
|
-
*
|
|
93
|
-
* createPaginatedPluginMethod(sdk, {
|
|
94
|
-
* name: "listApps",
|
|
95
|
-
* inputSchema: ListAppsSchema,
|
|
96
|
-
* handler: ({ sdk, options }) =>
|
|
97
|
-
* sdk.context.api.get<ListAppsResponse>("/api/v0/apps", {...}),
|
|
98
|
-
* extractCursor: (response) => extractCursor(response.links),
|
|
99
|
-
* });
|
|
100
|
-
*/
|
|
101
|
-
export function createPaginatedPluginMethod(sdk, config) {
|
|
102
|
-
const { name, inputSchema, handler, extractCursor: extractCursorFn, defaultPageSize, ...metaFields } = config;
|
|
103
|
-
const namedPageHandlers = {
|
|
104
|
-
[name]: async function (options) {
|
|
105
|
-
const response = await handler({ sdk, options });
|
|
106
|
-
if (extractCursorFn) {
|
|
107
|
-
const extracted = extractCursorFn(response);
|
|
108
|
-
// Pass through the original response when the extractor doesn't
|
|
109
|
-
// produce a cursor — that way the runtime in `createPageFunction`
|
|
110
|
-
// can still auto-detect `nextCursor` or JSON:API `links.next` if
|
|
111
|
-
// they're present (e.g. from test mocks that don't go through the
|
|
112
|
-
// real API envelope).
|
|
113
|
-
if (extracted !== undefined) {
|
|
114
|
-
return { data: response.data, nextCursor: extracted };
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
return response;
|
|
118
|
-
},
|
|
119
|
-
};
|
|
120
|
-
const wrappedFn = createPaginatedFunction(namedPageHandlers[name], inputSchema, maybeTelemetry(sdk, name), name, defaultPageSize);
|
|
121
|
-
return {
|
|
122
|
-
[name]: wrappedFn,
|
|
123
|
-
context: {
|
|
124
|
-
meta: {
|
|
125
|
-
[name]: {
|
|
126
|
-
...metaFields,
|
|
127
|
-
...(inputSchema ? { inputSchema } : {}),
|
|
128
|
-
},
|
|
129
|
-
},
|
|
130
|
-
},
|
|
131
|
-
};
|
|
132
|
-
}
|
|
133
|
-
// ----------------------------------------------------------------------------
|
|
134
|
-
// composePlugins — runtime merge helpers
|
|
135
|
-
// ----------------------------------------------------------------------------
|
|
136
|
-
// Three merge rules, one per shape of key the function deals with. Each is
|
|
137
|
-
// a small, single-purpose helper so the main loop reads top-to-bottom.
|
|
138
|
-
/**
|
|
139
|
-
* Merge root-level keys (the SDK methods a plugin contributes) into the
|
|
140
|
-
* accumulator. Throws on collision: composePlugins is bag-mode, so two
|
|
141
|
-
* sub-plugins registering the same method name is a programmer error.
|
|
142
|
-
*/
|
|
143
|
-
function mergeRootKeysWithCollisionCheck(target, source, seen) {
|
|
144
|
-
for (const key of Object.keys(source)) {
|
|
145
|
-
if (seen.has(key)) {
|
|
146
|
-
throw new Error(`composePlugins: duplicate root key "${key}". Plugins composed in the same call must register distinct method names.`);
|
|
147
|
-
}
|
|
148
|
-
seen.add(key);
|
|
149
|
-
target[key] = source[key];
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
/**
|
|
153
|
-
* Merge per-method metadata (the registry view of input/output schemas,
|
|
154
|
-
* categories, etc.) with the same collision rule as root keys. Even when
|
|
155
|
-
* two sub-plugins' root method keys differ, registry-level shadowing
|
|
156
|
-
* is dangerous, so silent overwrites aren't allowed.
|
|
157
|
-
*/
|
|
158
|
-
function mergeMetaKeysWithCollisionCheck(target, source, seen) {
|
|
159
|
-
for (const key of Object.keys(source)) {
|
|
160
|
-
if (seen.has(key)) {
|
|
161
|
-
throw new Error(`composePlugins: duplicate context.meta key "${key}". Two sub-plugins registered metadata for the same name.`);
|
|
162
|
-
}
|
|
163
|
-
seen.add(key);
|
|
164
|
-
target[key] = source[key];
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
/**
|
|
168
|
-
* Merge non-meta context keys (everything under `context.*` that isn't
|
|
169
|
-
* `meta`) into the accumulator. Throws on collision — bag mode says
|
|
170
|
-
* sub-plugins shouldn't be re-providing shared infrastructure like
|
|
171
|
-
* `context.api`, so two of them claiming the same context slot is a
|
|
172
|
-
* programmer error. Note that this only applies *inside* a single
|
|
173
|
-
* `composePlugins(...)` call; cross-`addPlugin` overrides go through
|
|
174
|
-
* `addPlugin`'s last-write-wins merge, which is unaffected by this check.
|
|
175
|
-
*/
|
|
176
|
-
function mergeContextKeysWithCollisionCheck(target, source, seen) {
|
|
177
|
-
for (const key of Object.keys(source)) {
|
|
178
|
-
if (seen.has(key)) {
|
|
179
|
-
throw new Error(`composePlugins: duplicate context key "${key}". Two sub-plugins contributed the same context.${key} field.`);
|
|
180
|
-
}
|
|
181
|
-
seen.add(key);
|
|
182
|
-
target[key] = source[key];
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
/**
|
|
186
|
-
* Bundle N plugins into a single plugin so a consumer can call
|
|
187
|
-
* `addPlugin(combined)` once. Use this when an extension package wants to
|
|
188
|
-
* expose granular sub-plugins for tree-shaking *and* a one-call convenience
|
|
189
|
-
* entry point.
|
|
190
|
-
*
|
|
191
|
-
* Three commitments (per the boilerplate-reduction design):
|
|
192
|
-
* 1. **Bag mode.** Sub-plugins must not depend on each other; order is
|
|
193
|
-
* irrelevant. If you need pipeline composition (later sub-plugins
|
|
194
|
-
* reading earlier sub-plugins' outputs), use a regular `definePlugin`
|
|
195
|
-
* callback that calls each `createPluginMethod` in turn.
|
|
196
|
-
* 2. **Over-approximation of TSdk.** The composed plugin requires the
|
|
197
|
-
* intersection of every sub-plugin's requirements (all of them, all at
|
|
198
|
-
* once). Works fine for homogeneous-deps groups; widens slightly for
|
|
199
|
-
* heterogeneous ones, which keeps the variadic types tractable.
|
|
200
|
-
* 3. **Collision detection.** Throws on duplicate root keys, duplicate
|
|
201
|
-
* `context.meta` keys, and duplicate non-meta `context.*` keys
|
|
202
|
-
* *inside* a single `composePlugins(...)` call. Cross-`addPlugin`
|
|
203
|
-
* collisions are handled separately by `addPlugin` itself, which
|
|
204
|
-
* warns-and-skips the colliding plugin (the first registration
|
|
205
|
-
* wins). Pure meta-only overrides (e.g. `cliOverridesPlugin`
|
|
206
|
-
* patching `meta.fetch.deprecated` without re-registering `fetch`)
|
|
207
|
-
* stay legitimate in both code paths.
|
|
208
|
-
*
|
|
209
|
-
* Why prefer this over an `addPlugin([...])` array overload: TypeScript's
|
|
210
|
-
* overload resolution interacts badly with arrays carrying a mix of
|
|
211
|
-
* `TProvides` shapes — chained inference downstream of `addPlugin([...])`
|
|
212
|
-
* tends to widen and lose individual method types. A single composed
|
|
213
|
-
* plugin flows through the existing single-plugin `addPlugin` cleanly.
|
|
214
|
-
*/
|
|
215
|
-
export function composePlugins(...plugins) {
|
|
216
|
-
return ((sdk) => {
|
|
217
|
-
const merged = { context: { meta: {} } };
|
|
218
|
-
const seenRoot = new Set();
|
|
219
|
-
const seenMeta = new Set();
|
|
220
|
-
const seenContext = new Set();
|
|
221
|
-
for (const plugin of plugins) {
|
|
222
|
-
const { context, ...rootKeys } = plugin(sdk);
|
|
223
|
-
mergeRootKeysWithCollisionCheck(merged, rootKeys, seenRoot);
|
|
224
|
-
if (context) {
|
|
225
|
-
const { meta, ...nonMetaContext } = context;
|
|
226
|
-
if (meta) {
|
|
227
|
-
mergeMetaKeysWithCollisionCheck(merged.context.meta, meta, seenMeta);
|
|
228
|
-
}
|
|
229
|
-
mergeContextKeysWithCollisionCheck(merged.context, nonMetaContext, seenContext);
|
|
230
|
-
}
|
|
231
|
-
}
|
|
232
|
-
return merged;
|
|
233
|
-
});
|
|
234
|
-
}
|