@zapier/zapier-sdk 0.18.3 → 0.19.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 +41 -0
- package/README.md +44 -32
- package/dist/index.cjs +658 -693
- package/dist/index.d.mts +272 -138
- package/dist/index.d.ts +2541 -40
- package/dist/index.mjs +638 -692
- package/package.json +14 -13
- package/dist/api/auth.d.ts +0 -19
- package/dist/api/auth.d.ts.map +0 -1
- package/dist/api/auth.js +0 -70
- package/dist/api/auth.test.d.ts +0 -2
- package/dist/api/auth.test.d.ts.map +0 -1
- package/dist/api/auth.test.js +0 -220
- package/dist/api/client.d.ts +0 -9
- package/dist/api/client.d.ts.map +0 -1
- package/dist/api/client.integration.test.d.ts +0 -5
- package/dist/api/client.integration.test.d.ts.map +0 -1
- package/dist/api/client.integration.test.js +0 -318
- package/dist/api/client.js +0 -374
- package/dist/api/client.methods.test.d.ts +0 -2
- package/dist/api/client.methods.test.d.ts.map +0 -1
- package/dist/api/client.methods.test.js +0 -158
- package/dist/api/client.test.d.ts +0 -2
- package/dist/api/client.test.d.ts.map +0 -1
- package/dist/api/client.test.js +0 -96
- package/dist/api/debug.d.ts +0 -14
- package/dist/api/debug.d.ts.map +0 -1
- package/dist/api/debug.js +0 -131
- package/dist/api/debug.test.d.ts +0 -2
- package/dist/api/debug.test.d.ts.map +0 -1
- package/dist/api/debug.test.js +0 -59
- package/dist/api/index.d.ts +0 -30
- package/dist/api/index.d.ts.map +0 -1
- package/dist/api/index.js +0 -43
- package/dist/api/polling.d.ts +0 -46
- package/dist/api/polling.d.ts.map +0 -1
- package/dist/api/polling.js +0 -139
- package/dist/api/polling.test.d.ts +0 -2
- package/dist/api/polling.test.d.ts.map +0 -1
- package/dist/api/polling.test.js +0 -318
- package/dist/api/router.d.ts +0 -16
- package/dist/api/router.d.ts.map +0 -1
- package/dist/api/router.js +0 -31
- package/dist/api/router.test.d.ts +0 -2
- package/dist/api/router.test.d.ts.map +0 -1
- package/dist/api/router.test.js +0 -103
- package/dist/api/schemas.d.ts +0 -531
- package/dist/api/schemas.d.ts.map +0 -1
- package/dist/api/schemas.js +0 -389
- package/dist/api/types.d.ts +0 -82
- package/dist/api/types.d.ts.map +0 -1
- package/dist/api/types.js +0 -1
- package/dist/auth.d.ts +0 -52
- package/dist/auth.d.ts.map +0 -1
- package/dist/auth.js +0 -72
- package/dist/auth.test.d.ts +0 -2
- package/dist/auth.test.d.ts.map +0 -1
- package/dist/auth.test.js +0 -102
- package/dist/constants.d.ts +0 -14
- package/dist/constants.d.ts.map +0 -1
- package/dist/constants.js +0 -13
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -42
- package/dist/plugins/api/index.d.ts +0 -12
- package/dist/plugins/api/index.d.ts.map +0 -1
- package/dist/plugins/api/index.js +0 -24
- package/dist/plugins/apps/index.d.ts +0 -15
- package/dist/plugins/apps/index.d.ts.map +0 -1
- package/dist/plugins/apps/index.js +0 -112
- package/dist/plugins/apps/schemas.d.ts +0 -42
- package/dist/plugins/apps/schemas.d.ts.map +0 -1
- package/dist/plugins/apps/schemas.js +0 -14
- 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 -109
- package/dist/plugins/eventEmission/index.d.ts +0 -38
- package/dist/plugins/eventEmission/index.d.ts.map +0 -1
- package/dist/plugins/eventEmission/index.js +0 -336
- package/dist/plugins/eventEmission/index.test.d.ts +0 -5
- package/dist/plugins/eventEmission/index.test.d.ts.map +0 -1
- package/dist/plugins/eventEmission/index.test.js +0 -581
- 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 -104
- package/dist/plugins/eventEmission/transport.test.d.ts +0 -5
- package/dist/plugins/eventEmission/transport.test.d.ts.map +0 -1
- package/dist/plugins/eventEmission/transport.test.js +0 -164
- package/dist/plugins/eventEmission/types.d.ts +0 -63
- 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 -45
- package/dist/plugins/eventEmission/utils.d.ts.map +0 -1
- package/dist/plugins/eventEmission/utils.js +0 -114
- package/dist/plugins/fetch/index.d.ts +0 -36
- package/dist/plugins/fetch/index.d.ts.map +0 -1
- package/dist/plugins/fetch/index.js +0 -62
- package/dist/plugins/fetch/schemas.d.ts +0 -19
- package/dist/plugins/fetch/schemas.d.ts.map +0 -1
- package/dist/plugins/fetch/schemas.js +0 -31
- package/dist/plugins/findFirstAuthentication/index.d.ts +0 -21
- package/dist/plugins/findFirstAuthentication/index.d.ts.map +0 -1
- package/dist/plugins/findFirstAuthentication/index.js +0 -36
- package/dist/plugins/findFirstAuthentication/index.test.d.ts +0 -2
- package/dist/plugins/findFirstAuthentication/index.test.d.ts.map +0 -1
- package/dist/plugins/findFirstAuthentication/index.test.js +0 -177
- package/dist/plugins/findFirstAuthentication/schemas.d.ts +0 -20
- package/dist/plugins/findFirstAuthentication/schemas.d.ts.map +0 -1
- package/dist/plugins/findFirstAuthentication/schemas.js +0 -18
- package/dist/plugins/findUniqueAuthentication/index.d.ts +0 -21
- package/dist/plugins/findUniqueAuthentication/index.d.ts.map +0 -1
- package/dist/plugins/findUniqueAuthentication/index.js +0 -39
- package/dist/plugins/findUniqueAuthentication/index.test.d.ts +0 -2
- package/dist/plugins/findUniqueAuthentication/index.test.d.ts.map +0 -1
- package/dist/plugins/findUniqueAuthentication/index.test.js +0 -159
- package/dist/plugins/findUniqueAuthentication/schemas.d.ts +0 -20
- package/dist/plugins/findUniqueAuthentication/schemas.d.ts.map +0 -1
- package/dist/plugins/findUniqueAuthentication/schemas.js +0 -18
- package/dist/plugins/getAction/index.d.ts +0 -25
- package/dist/plugins/getAction/index.d.ts.map +0 -1
- package/dist/plugins/getAction/index.js +0 -42
- package/dist/plugins/getAction/index.test.d.ts +0 -2
- package/dist/plugins/getAction/index.test.d.ts.map +0 -1
- package/dist/plugins/getAction/index.test.js +0 -211
- package/dist/plugins/getAction/schemas.d.ts +0 -30
- package/dist/plugins/getAction/schemas.d.ts.map +0 -1
- package/dist/plugins/getAction/schemas.js +0 -12
- package/dist/plugins/getApp/index.d.ts +0 -21
- package/dist/plugins/getApp/index.d.ts.map +0 -1
- package/dist/plugins/getApp/index.js +0 -44
- package/dist/plugins/getApp/index.test.d.ts +0 -2
- package/dist/plugins/getApp/index.test.d.ts.map +0 -1
- package/dist/plugins/getApp/index.test.js +0 -157
- package/dist/plugins/getApp/schemas.d.ts +0 -16
- package/dist/plugins/getApp/schemas.d.ts.map +0 -1
- package/dist/plugins/getApp/schemas.js +0 -8
- package/dist/plugins/getAuthentication/index.d.ts +0 -21
- package/dist/plugins/getAuthentication/index.d.ts.map +0 -1
- package/dist/plugins/getAuthentication/index.js +0 -29
- package/dist/plugins/getAuthentication/index.test.d.ts +0 -2
- package/dist/plugins/getAuthentication/index.test.d.ts.map +0 -1
- package/dist/plugins/getAuthentication/index.test.js +0 -106
- package/dist/plugins/getAuthentication/schemas.d.ts +0 -7
- package/dist/plugins/getAuthentication/schemas.d.ts.map +0 -1
- package/dist/plugins/getAuthentication/schemas.js +0 -1
- package/dist/plugins/getInputFieldsSchema/index.d.ts +0 -23
- package/dist/plugins/getInputFieldsSchema/index.d.ts.map +0 -1
- package/dist/plugins/getInputFieldsSchema/index.js +0 -53
- package/dist/plugins/getInputFieldsSchema/index.test.d.ts +0 -2
- package/dist/plugins/getInputFieldsSchema/index.test.d.ts.map +0 -1
- package/dist/plugins/getInputFieldsSchema/index.test.js +0 -291
- package/dist/plugins/getInputFieldsSchema/schemas.d.ts +0 -28
- package/dist/plugins/getInputFieldsSchema/schemas.d.ts.map +0 -1
- package/dist/plugins/getInputFieldsSchema/schemas.js +0 -13
- package/dist/plugins/getProfile/index.d.ts +0 -25
- package/dist/plugins/getProfile/index.d.ts.map +0 -1
- package/dist/plugins/getProfile/index.js +0 -39
- package/dist/plugins/getProfile/schemas.d.ts +0 -13
- package/dist/plugins/getProfile/schemas.d.ts.map +0 -1
- package/dist/plugins/getProfile/schemas.js +0 -6
- package/dist/plugins/listActions/index.d.ts +0 -30
- package/dist/plugins/listActions/index.d.ts.map +0 -1
- package/dist/plugins/listActions/index.js +0 -75
- package/dist/plugins/listActions/index.test.d.ts +0 -2
- package/dist/plugins/listActions/index.test.d.ts.map +0 -1
- package/dist/plugins/listActions/index.test.js +0 -453
- package/dist/plugins/listActions/schemas.d.ts +0 -35
- package/dist/plugins/listActions/schemas.d.ts.map +0 -1
- package/dist/plugins/listActions/schemas.js +0 -22
- package/dist/plugins/listApps/index.d.ts +0 -25
- package/dist/plugins/listApps/index.d.ts.map +0 -1
- package/dist/plugins/listApps/index.js +0 -69
- package/dist/plugins/listApps/index.test.d.ts +0 -2
- package/dist/plugins/listApps/index.test.d.ts.map +0 -1
- package/dist/plugins/listApps/index.test.js +0 -141
- package/dist/plugins/listApps/schemas.d.ts +0 -26
- package/dist/plugins/listApps/schemas.d.ts.map +0 -1
- package/dist/plugins/listApps/schemas.js +0 -19
- package/dist/plugins/listAuthentications/index.d.ts +0 -24
- package/dist/plugins/listAuthentications/index.d.ts.map +0 -1
- package/dist/plugins/listAuthentications/index.js +0 -77
- package/dist/plugins/listAuthentications/index.test.d.ts +0 -2
- package/dist/plugins/listAuthentications/index.test.d.ts.map +0 -1
- package/dist/plugins/listAuthentications/index.test.js +0 -832
- package/dist/plugins/listAuthentications/schemas.d.ts +0 -30
- package/dist/plugins/listAuthentications/schemas.d.ts.map +0 -1
- package/dist/plugins/listAuthentications/schemas.js +0 -32
- package/dist/plugins/listInputFieldChoices/index.d.ts +0 -33
- package/dist/plugins/listInputFieldChoices/index.d.ts.map +0 -1
- package/dist/plugins/listInputFieldChoices/index.js +0 -115
- package/dist/plugins/listInputFieldChoices/index.test.d.ts +0 -2
- package/dist/plugins/listInputFieldChoices/index.test.d.ts.map +0 -1
- package/dist/plugins/listInputFieldChoices/index.test.js +0 -717
- package/dist/plugins/listInputFieldChoices/schemas.d.ts +0 -43
- package/dist/plugins/listInputFieldChoices/schemas.d.ts.map +0 -1
- package/dist/plugins/listInputFieldChoices/schemas.js +0 -65
- package/dist/plugins/listInputFields/index.d.ts +0 -34
- package/dist/plugins/listInputFields/index.d.ts.map +0 -1
- package/dist/plugins/listInputFields/index.js +0 -204
- package/dist/plugins/listInputFields/index.test.d.ts +0 -2
- package/dist/plugins/listInputFields/index.test.d.ts.map +0 -1
- package/dist/plugins/listInputFields/index.test.js +0 -359
- package/dist/plugins/listInputFields/schemas.d.ts +0 -35
- package/dist/plugins/listInputFields/schemas.d.ts.map +0 -1
- package/dist/plugins/listInputFields/schemas.js +0 -23
- package/dist/plugins/manifest/index.d.ts +0 -85
- package/dist/plugins/manifest/index.d.ts.map +0 -1
- package/dist/plugins/manifest/index.js +0 -376
- package/dist/plugins/manifest/index.test.d.ts +0 -2
- package/dist/plugins/manifest/index.test.d.ts.map +0 -1
- package/dist/plugins/manifest/index.test.js +0 -1139
- package/dist/plugins/manifest/schemas.d.ts +0 -57
- package/dist/plugins/manifest/schemas.d.ts.map +0 -1
- package/dist/plugins/manifest/schemas.js +0 -50
- package/dist/plugins/registry/index.d.ts +0 -21
- package/dist/plugins/registry/index.d.ts.map +0 -1
- package/dist/plugins/registry/index.js +0 -117
- package/dist/plugins/request/index.d.ts +0 -21
- package/dist/plugins/request/index.d.ts.map +0 -1
- package/dist/plugins/request/index.js +0 -76
- package/dist/plugins/request/index.test.d.ts +0 -2
- package/dist/plugins/request/index.test.d.ts.map +0 -1
- package/dist/plugins/request/index.test.js +0 -337
- package/dist/plugins/request/schemas.d.ts +0 -54
- package/dist/plugins/request/schemas.d.ts.map +0 -1
- package/dist/plugins/request/schemas.js +0 -41
- package/dist/plugins/runAction/index.d.ts +0 -33
- package/dist/plugins/runAction/index.d.ts.map +0 -1
- package/dist/plugins/runAction/index.js +0 -108
- package/dist/plugins/runAction/index.test.d.ts +0 -2
- package/dist/plugins/runAction/index.test.d.ts.map +0 -1
- package/dist/plugins/runAction/index.test.js +0 -333
- package/dist/plugins/runAction/schemas.d.ts +0 -34
- package/dist/plugins/runAction/schemas.d.ts.map +0 -1
- package/dist/plugins/runAction/schemas.js +0 -23
- package/dist/resolvers/actionKey.d.ts +0 -15
- package/dist/resolvers/actionKey.d.ts.map +0 -1
- package/dist/resolvers/actionKey.js +0 -19
- package/dist/resolvers/actionType.d.ts +0 -10
- package/dist/resolvers/actionType.d.ts.map +0 -1
- package/dist/resolvers/actionType.js +0 -21
- package/dist/resolvers/appKey.d.ts +0 -3
- package/dist/resolvers/appKey.d.ts.map +0 -1
- package/dist/resolvers/appKey.js +0 -5
- package/dist/resolvers/authenticationId.d.ts +0 -9
- package/dist/resolvers/authenticationId.d.ts.map +0 -1
- package/dist/resolvers/authenticationId.js +0 -42
- package/dist/resolvers/index.d.ts +0 -8
- package/dist/resolvers/index.d.ts.map +0 -1
- package/dist/resolvers/index.js +0 -8
- package/dist/resolvers/inputFieldKey.d.ts +0 -11
- package/dist/resolvers/inputFieldKey.d.ts.map +0 -1
- package/dist/resolvers/inputFieldKey.js +0 -47
- 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/schemas/Action.d.ts +0 -24
- package/dist/schemas/Action.d.ts.map +0 -1
- package/dist/schemas/Action.js +0 -40
- package/dist/schemas/App.d.ts +0 -57
- package/dist/schemas/App.d.ts.map +0 -1
- package/dist/schemas/App.js +0 -31
- package/dist/schemas/Auth.d.ts +0 -55
- package/dist/schemas/Auth.d.ts.map +0 -1
- package/dist/schemas/Auth.js +0 -33
- package/dist/schemas/Field.d.ts +0 -61
- package/dist/schemas/Field.d.ts.map +0 -1
- package/dist/schemas/Field.js +0 -116
- package/dist/schemas/Run.d.ts +0 -3
- package/dist/schemas/Run.d.ts.map +0 -1
- package/dist/schemas/Run.js +0 -31
- package/dist/schemas/UserProfile.d.ts +0 -13
- package/dist/schemas/UserProfile.d.ts.map +0 -1
- package/dist/schemas/UserProfile.js +0 -32
- package/dist/sdk.d.ts +0 -146
- package/dist/sdk.d.ts.map +0 -1
- package/dist/sdk.js +0 -112
- package/dist/sdk.test.d.ts +0 -2
- package/dist/sdk.test.d.ts.map +0 -1
- package/dist/sdk.test.js +0 -255
- package/dist/services/implementations.d.ts +0 -63
- package/dist/services/implementations.d.ts.map +0 -1
- package/dist/services/implementations.js +0 -80
- package/dist/temporary-internal-core/handlers/listApps.d.ts +0 -67
- package/dist/temporary-internal-core/handlers/listApps.d.ts.map +0 -1
- package/dist/temporary-internal-core/handlers/listApps.js +0 -134
- package/dist/temporary-internal-core/handlers/listApps.test.d.ts +0 -2
- package/dist/temporary-internal-core/handlers/listApps.test.d.ts.map +0 -1
- package/dist/temporary-internal-core/handlers/listApps.test.js +0 -367
- package/dist/temporary-internal-core/index.d.ts +0 -18
- package/dist/temporary-internal-core/index.d.ts.map +0 -1
- package/dist/temporary-internal-core/index.js +0 -18
- package/dist/temporary-internal-core/schemas/apps/index.d.ts +0 -175
- package/dist/temporary-internal-core/schemas/apps/index.d.ts.map +0 -1
- package/dist/temporary-internal-core/schemas/apps/index.js +0 -97
- package/dist/temporary-internal-core/schemas/errors/index.d.ts +0 -139
- package/dist/temporary-internal-core/schemas/errors/index.d.ts.map +0 -1
- package/dist/temporary-internal-core/schemas/errors/index.js +0 -129
- package/dist/temporary-internal-core/schemas/implementations/index.d.ts +0 -127
- package/dist/temporary-internal-core/schemas/implementations/index.d.ts.map +0 -1
- package/dist/temporary-internal-core/schemas/implementations/index.js +0 -79
- package/dist/temporary-internal-core/types/handler.d.ts +0 -51
- package/dist/temporary-internal-core/types/handler.d.ts.map +0 -1
- package/dist/temporary-internal-core/types/handler.js +0 -8
- package/dist/temporary-internal-core/types/index.d.ts +0 -5
- package/dist/temporary-internal-core/types/index.d.ts.map +0 -1
- package/dist/temporary-internal-core/types/index.js +0 -4
- package/dist/temporary-internal-core/utils/app-locators.d.ts +0 -34
- package/dist/temporary-internal-core/utils/app-locators.d.ts.map +0 -1
- package/dist/temporary-internal-core/utils/app-locators.js +0 -39
- package/dist/temporary-internal-core/utils/string-utils.d.ts +0 -28
- package/dist/temporary-internal-core/utils/string-utils.d.ts.map +0 -1
- package/dist/temporary-internal-core/utils/string-utils.js +0 -52
- package/dist/temporary-internal-core/utils/transformations.d.ts +0 -18
- package/dist/temporary-internal-core/utils/transformations.d.ts.map +0 -1
- package/dist/temporary-internal-core/utils/transformations.js +0 -36
- 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/domain.test.d.ts +0 -2
- package/dist/types/domain.test.d.ts.map +0 -1
- package/dist/types/domain.test.js +0 -39
- package/dist/types/errors.d.ts +0 -143
- package/dist/types/errors.d.ts.map +0 -1
- package/dist/types/errors.js +0 -187
- 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 -27
- package/dist/types/functions.d.ts.map +0 -1
- package/dist/types/functions.js +0 -1
- package/dist/types/plugin.d.ts +0 -75
- package/dist/types/plugin.d.ts.map +0 -1
- package/dist/types/plugin.js +0 -9
- package/dist/types/properties.d.ts +0 -33
- package/dist/types/properties.d.ts.map +0 -1
- package/dist/types/properties.js +0 -52
- package/dist/types/sdk.d.ts +0 -69
- package/dist/types/sdk.d.ts.map +0 -1
- package/dist/types/sdk.js +0 -4
- package/dist/types/telemetry-events.d.ts +0 -105
- package/dist/types/telemetry-events.d.ts.map +0 -1
- package/dist/types/telemetry-events.js +0 -8
- 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/array-utils.test.d.ts +0 -2
- package/dist/utils/array-utils.test.d.ts.map +0 -1
- package/dist/utils/array-utils.test.js +0 -107
- 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 -162
- package/dist/utils/batch-utils.test.d.ts +0 -2
- package/dist/utils/batch-utils.test.d.ts.map +0 -1
- package/dist/utils/batch-utils.test.js +0 -476
- package/dist/utils/domain-utils.d.ts +0 -66
- package/dist/utils/domain-utils.d.ts.map +0 -1
- package/dist/utils/domain-utils.js +0 -164
- package/dist/utils/domain-utils.test.d.ts +0 -2
- package/dist/utils/domain-utils.test.d.ts.map +0 -1
- package/dist/utils/domain-utils.test.js +0 -346
- 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/file-utils.test.d.ts +0 -2
- package/dist/utils/file-utils.test.d.ts.map +0 -1
- package/dist/utils/file-utils.test.js +0 -51
- package/dist/utils/function-utils.d.ts +0 -73
- package/dist/utils/function-utils.d.ts.map +0 -1
- package/dist/utils/function-utils.js +0 -245
- package/dist/utils/function-utils.test.d.ts +0 -2
- package/dist/utils/function-utils.test.d.ts.map +0 -1
- package/dist/utils/function-utils.test.js +0 -110
- package/dist/utils/id-utils.d.ts +0 -13
- package/dist/utils/id-utils.d.ts.map +0 -1
- package/dist/utils/id-utils.js +0 -22
- package/dist/utils/id-utils.test.d.ts +0 -2
- package/dist/utils/id-utils.test.d.ts.map +0 -1
- package/dist/utils/id-utils.test.js +0 -22
- package/dist/utils/pagination-utils.d.ts +0 -37
- package/dist/utils/pagination-utils.d.ts.map +0 -1
- package/dist/utils/pagination-utils.js +0 -165
- package/dist/utils/pagination-utils.test.d.ts +0 -17
- package/dist/utils/pagination-utils.test.d.ts.map +0 -1
- package/dist/utils/pagination-utils.test.js +0 -461
- package/dist/utils/retry-utils.d.ts +0 -45
- package/dist/utils/retry-utils.d.ts.map +0 -1
- package/dist/utils/retry-utils.js +0 -51
- package/dist/utils/retry-utils.test.d.ts +0 -2
- package/dist/utils/retry-utils.test.d.ts.map +0 -1
- package/dist/utils/retry-utils.test.js +0 -90
- package/dist/utils/schema-utils.d.ts +0 -69
- 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/string-utils.test.d.ts +0 -2
- package/dist/utils/string-utils.test.d.ts.map +0 -1
- package/dist/utils/string-utils.test.js +0 -59
- 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 -55
- package/dist/utils/telemetry-utils.test.d.ts +0 -2
- package/dist/utils/telemetry-utils.test.d.ts.map +0 -1
- package/dist/utils/telemetry-utils.test.js +0 -94
- package/dist/utils/url-utils.d.ts +0 -19
- package/dist/utils/url-utils.d.ts.map +0 -1
- package/dist/utils/url-utils.js +0 -62
- package/dist/utils/url-utils.test.d.ts +0 -2
- package/dist/utils/url-utils.test.d.ts.map +0 -1
- package/dist/utils/url-utils.test.js +0 -103
- package/dist/utils/validation.d.ts +0 -4
- package/dist/utils/validation.d.ts.map +0 -1
- package/dist/utils/validation.js +0 -30
- package/dist/utils/validation.test.d.ts +0 -2
- package/dist/utils/validation.test.d.ts.map +0 -1
- package/dist/utils/validation.test.js +0 -44
|
@@ -1,717 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect, vi, beforeEach } from "vitest";
|
|
2
|
-
import { ZapierValidationError, ZapierApiError } from "../../types/errors";
|
|
3
|
-
import { listInputFieldChoicesPlugin } from "./index";
|
|
4
|
-
import { createSdk } from "../../sdk";
|
|
5
|
-
import { GetActionSchema } from "../getAction/schemas";
|
|
6
|
-
import { eventEmissionPlugin } from "../eventEmission";
|
|
7
|
-
const mockChoices = [
|
|
8
|
-
{
|
|
9
|
-
key: "general",
|
|
10
|
-
label: "General Channel",
|
|
11
|
-
sample: "#general",
|
|
12
|
-
value: "general",
|
|
13
|
-
},
|
|
14
|
-
{
|
|
15
|
-
key: "random",
|
|
16
|
-
label: "Random Channel",
|
|
17
|
-
sample: "#random",
|
|
18
|
-
value: "random",
|
|
19
|
-
},
|
|
20
|
-
{
|
|
21
|
-
key: "dev",
|
|
22
|
-
label: "Development Channel",
|
|
23
|
-
sample: "#dev",
|
|
24
|
-
value: "dev",
|
|
25
|
-
},
|
|
26
|
-
];
|
|
27
|
-
const mockChoicesResponse = {
|
|
28
|
-
success: true,
|
|
29
|
-
choices: mockChoices,
|
|
30
|
-
};
|
|
31
|
-
const mockPaginatedChoicesResponse = {
|
|
32
|
-
success: true,
|
|
33
|
-
choices: mockChoices.slice(0, 2),
|
|
34
|
-
next_page: 1,
|
|
35
|
-
};
|
|
36
|
-
const mockExternalChoicesResponse = {
|
|
37
|
-
success: true,
|
|
38
|
-
choices: mockChoices,
|
|
39
|
-
meta: { page: "0" },
|
|
40
|
-
links: {
|
|
41
|
-
next: "https://api.zapier.com/api/v4/implementations/choices/?page=1",
|
|
42
|
-
prev: null,
|
|
43
|
-
},
|
|
44
|
-
};
|
|
45
|
-
// Mock needs data for static choices
|
|
46
|
-
const mockNeedsWithStaticChoices = [
|
|
47
|
-
{
|
|
48
|
-
key: "priority",
|
|
49
|
-
label: "Priority",
|
|
50
|
-
help_text: "Select priority",
|
|
51
|
-
required: true,
|
|
52
|
-
type: "string",
|
|
53
|
-
choices: [
|
|
54
|
-
{
|
|
55
|
-
key: "high",
|
|
56
|
-
sample: "high",
|
|
57
|
-
label: "High Priority",
|
|
58
|
-
value: "high",
|
|
59
|
-
},
|
|
60
|
-
{
|
|
61
|
-
key: "medium",
|
|
62
|
-
sample: "medium",
|
|
63
|
-
label: "Medium Priority",
|
|
64
|
-
value: "medium",
|
|
65
|
-
},
|
|
66
|
-
],
|
|
67
|
-
},
|
|
68
|
-
];
|
|
69
|
-
const mockNeedsWithoutChoices = [
|
|
70
|
-
{
|
|
71
|
-
key: "channel",
|
|
72
|
-
label: "Channel",
|
|
73
|
-
help_text: "Select a channel",
|
|
74
|
-
required: true,
|
|
75
|
-
type: "string",
|
|
76
|
-
choices: [], // Empty choices
|
|
77
|
-
},
|
|
78
|
-
];
|
|
79
|
-
const mockNeedsResponse = {
|
|
80
|
-
success: true,
|
|
81
|
-
needs: mockNeedsWithoutChoices,
|
|
82
|
-
};
|
|
83
|
-
const mockNeedsResponseWithStaticChoices = {
|
|
84
|
-
success: true,
|
|
85
|
-
needs: mockNeedsWithStaticChoices,
|
|
86
|
-
};
|
|
87
|
-
describe("listInputFieldChoices plugin", () => {
|
|
88
|
-
let mockApiClient;
|
|
89
|
-
let mockGetAction;
|
|
90
|
-
let mockGetVersionedImplementationId;
|
|
91
|
-
beforeEach(() => {
|
|
92
|
-
vi.clearAllMocks();
|
|
93
|
-
// Mock api.post to handle both endpoints
|
|
94
|
-
const mockPost = vi.fn().mockImplementation((path) => {
|
|
95
|
-
if (path === "/zapier/api/v4/implementations/needs/") {
|
|
96
|
-
return Promise.resolve(mockNeedsResponse);
|
|
97
|
-
}
|
|
98
|
-
else if (path === "/zapier/api/v4/implementations/choices/") {
|
|
99
|
-
return Promise.resolve(mockChoicesResponse);
|
|
100
|
-
}
|
|
101
|
-
return Promise.reject(new Error(`Unexpected endpoint: ${path}`));
|
|
102
|
-
});
|
|
103
|
-
mockApiClient = {
|
|
104
|
-
post: mockPost,
|
|
105
|
-
};
|
|
106
|
-
mockGetAction = vi.fn().mockResolvedValue({
|
|
107
|
-
data: { id: "core:123", key: "send_message", action_type: "read" },
|
|
108
|
-
});
|
|
109
|
-
mockGetVersionedImplementationId = vi
|
|
110
|
-
.fn()
|
|
111
|
-
.mockResolvedValue("SlackCLIAPI@1.21.1");
|
|
112
|
-
});
|
|
113
|
-
function createTestSdk() {
|
|
114
|
-
// Create a mock getAction plugin
|
|
115
|
-
const mockGetActionPlugin = () => ({
|
|
116
|
-
getAction: mockGetAction,
|
|
117
|
-
context: {
|
|
118
|
-
meta: {
|
|
119
|
-
getAction: {
|
|
120
|
-
inputSchema: GetActionSchema,
|
|
121
|
-
},
|
|
122
|
-
},
|
|
123
|
-
},
|
|
124
|
-
});
|
|
125
|
-
// Build SDK with proper plugin composition
|
|
126
|
-
return createSdk({}, {}, {
|
|
127
|
-
api: mockApiClient,
|
|
128
|
-
meta: {},
|
|
129
|
-
options: {},
|
|
130
|
-
getVersionedImplementationId: mockGetVersionedImplementationId,
|
|
131
|
-
})
|
|
132
|
-
.addPlugin(eventEmissionPlugin)
|
|
133
|
-
.addPlugin(mockGetActionPlugin)
|
|
134
|
-
.addPlugin(listInputFieldChoicesPlugin);
|
|
135
|
-
}
|
|
136
|
-
describe("schema validation", () => {
|
|
137
|
-
it("should throw validation error for missing inputFieldKey", async () => {
|
|
138
|
-
const sdk = createTestSdk();
|
|
139
|
-
try {
|
|
140
|
-
await sdk.listInputFieldChoices({
|
|
141
|
-
appKey: "slack",
|
|
142
|
-
actionType: "read",
|
|
143
|
-
actionKey: "send_message",
|
|
144
|
-
// Missing inputFieldKey
|
|
145
|
-
});
|
|
146
|
-
expect.fail("Expected ZapierValidationError to be thrown");
|
|
147
|
-
}
|
|
148
|
-
catch (error) {
|
|
149
|
-
expect(error).toBeInstanceOf(ZapierValidationError);
|
|
150
|
-
}
|
|
151
|
-
});
|
|
152
|
-
it("should throw validation error for missing actionKey", async () => {
|
|
153
|
-
const sdk = createTestSdk();
|
|
154
|
-
try {
|
|
155
|
-
await sdk.listInputFieldChoices({
|
|
156
|
-
appKey: "slack",
|
|
157
|
-
actionType: "read",
|
|
158
|
-
inputFieldKey: "channel",
|
|
159
|
-
// Missing actionKey
|
|
160
|
-
});
|
|
161
|
-
expect.fail("Expected ZapierValidationError to be thrown");
|
|
162
|
-
}
|
|
163
|
-
catch (error) {
|
|
164
|
-
expect(error).toBeInstanceOf(ZapierValidationError);
|
|
165
|
-
}
|
|
166
|
-
});
|
|
167
|
-
it("should pass validation with action method", async () => {
|
|
168
|
-
const sdk = createTestSdk();
|
|
169
|
-
const result = await sdk.listInputFieldChoices({
|
|
170
|
-
appKey: "slack",
|
|
171
|
-
actionType: "read",
|
|
172
|
-
actionKey: "send_message",
|
|
173
|
-
inputFieldKey: "channel",
|
|
174
|
-
});
|
|
175
|
-
expect(result.data).toBeDefined();
|
|
176
|
-
});
|
|
177
|
-
it("should pass validation with optional fields", async () => {
|
|
178
|
-
const sdk = createTestSdk();
|
|
179
|
-
const result = await sdk.listInputFieldChoices({
|
|
180
|
-
appKey: "slack",
|
|
181
|
-
actionType: "read",
|
|
182
|
-
actionKey: "send_message",
|
|
183
|
-
inputFieldKey: "channel",
|
|
184
|
-
authenticationId: 456,
|
|
185
|
-
inputs: { workspace: "my-team" },
|
|
186
|
-
page: 0,
|
|
187
|
-
});
|
|
188
|
-
expect(result.data).toBeDefined();
|
|
189
|
-
});
|
|
190
|
-
it("should throw validation error for empty string actionKey", async () => {
|
|
191
|
-
const sdk = createTestSdk();
|
|
192
|
-
try {
|
|
193
|
-
await sdk.listInputFieldChoices({
|
|
194
|
-
appKey: "slack",
|
|
195
|
-
actionType: "read",
|
|
196
|
-
actionKey: "", // Empty string
|
|
197
|
-
inputFieldKey: "channel",
|
|
198
|
-
});
|
|
199
|
-
expect.fail("Expected ZapierValidationError to be thrown");
|
|
200
|
-
}
|
|
201
|
-
catch (error) {
|
|
202
|
-
expect(error).toBeInstanceOf(ZapierValidationError);
|
|
203
|
-
}
|
|
204
|
-
});
|
|
205
|
-
it("should throw validation error for empty string inputFieldKey", async () => {
|
|
206
|
-
const sdk = createTestSdk();
|
|
207
|
-
try {
|
|
208
|
-
await sdk.listInputFieldChoices({
|
|
209
|
-
appKey: "slack",
|
|
210
|
-
actionType: "read",
|
|
211
|
-
actionKey: "send_message",
|
|
212
|
-
inputFieldKey: "", // Empty string
|
|
213
|
-
});
|
|
214
|
-
expect.fail("Expected ZapierValidationError to be thrown");
|
|
215
|
-
}
|
|
216
|
-
catch (error) {
|
|
217
|
-
expect(error).toBeInstanceOf(ZapierValidationError);
|
|
218
|
-
}
|
|
219
|
-
});
|
|
220
|
-
});
|
|
221
|
-
describe("static choices from needs endpoint", () => {
|
|
222
|
-
it("should return static choices when field has them", async () => {
|
|
223
|
-
// Mock api.post to return needs with static choices
|
|
224
|
-
const mockPost = vi.fn().mockImplementation((path) => {
|
|
225
|
-
if (path === "/zapier/api/v4/implementations/needs/") {
|
|
226
|
-
return Promise.resolve(mockNeedsResponseWithStaticChoices);
|
|
227
|
-
}
|
|
228
|
-
else if (path === "/zapier/api/v4/implementations/choices/") {
|
|
229
|
-
return Promise.resolve(mockChoicesResponse);
|
|
230
|
-
}
|
|
231
|
-
return Promise.reject(new Error(`Unexpected endpoint: ${path}`));
|
|
232
|
-
});
|
|
233
|
-
mockApiClient.post = mockPost;
|
|
234
|
-
const sdk = createTestSdk();
|
|
235
|
-
const result = await sdk.listInputFieldChoices({
|
|
236
|
-
appKey: "slack",
|
|
237
|
-
actionType: "read",
|
|
238
|
-
actionKey: "send_message",
|
|
239
|
-
inputFieldKey: "priority",
|
|
240
|
-
});
|
|
241
|
-
// Should return static choices
|
|
242
|
-
expect(result.data).toHaveLength(2);
|
|
243
|
-
expect(result.data[0]).toEqual({
|
|
244
|
-
key: "high",
|
|
245
|
-
label: "High Priority",
|
|
246
|
-
sample: "high",
|
|
247
|
-
value: "high",
|
|
248
|
-
});
|
|
249
|
-
expect(result.data[1]).toEqual({
|
|
250
|
-
key: "medium",
|
|
251
|
-
label: "Medium Priority",
|
|
252
|
-
sample: "medium",
|
|
253
|
-
value: "medium",
|
|
254
|
-
});
|
|
255
|
-
// Should have called needs endpoint to check for static choices
|
|
256
|
-
expect(mockApiClient.post).toHaveBeenCalledWith("/zapier/api/v4/implementations/needs/", {
|
|
257
|
-
selected_api: "SlackCLIAPI@1.21.1",
|
|
258
|
-
action: "send_message",
|
|
259
|
-
type_of: "read",
|
|
260
|
-
params: {},
|
|
261
|
-
});
|
|
262
|
-
// Should not call choices endpoint since static choices were found
|
|
263
|
-
expect(mockApiClient.post).not.toHaveBeenCalledWith("/zapier/api/v4/implementations/choices/", expect.anything());
|
|
264
|
-
});
|
|
265
|
-
it("should fall back to dynamic choices when field has empty choices array", async () => {
|
|
266
|
-
// Mock api.post - needs endpoint returns field with empty choices
|
|
267
|
-
const mockPost = vi.fn().mockImplementation((path) => {
|
|
268
|
-
if (path === "/zapier/api/v4/implementations/needs/") {
|
|
269
|
-
return Promise.resolve(mockNeedsResponse); // Has empty choices
|
|
270
|
-
}
|
|
271
|
-
else if (path === "/zapier/api/v4/implementations/choices/") {
|
|
272
|
-
return Promise.resolve(mockChoicesResponse);
|
|
273
|
-
}
|
|
274
|
-
return Promise.reject(new Error(`Unexpected endpoint: ${path}`));
|
|
275
|
-
});
|
|
276
|
-
mockApiClient.post = mockPost;
|
|
277
|
-
const sdk = createTestSdk();
|
|
278
|
-
const result = await sdk.listInputFieldChoices({
|
|
279
|
-
appKey: "slack",
|
|
280
|
-
actionType: "read",
|
|
281
|
-
actionKey: "send_message",
|
|
282
|
-
inputFieldKey: "channel",
|
|
283
|
-
});
|
|
284
|
-
// Should first call needs endpoint
|
|
285
|
-
expect(mockApiClient.post).toHaveBeenCalledWith("/zapier/api/v4/implementations/needs/", {
|
|
286
|
-
selected_api: "SlackCLIAPI@1.21.1",
|
|
287
|
-
action: "send_message",
|
|
288
|
-
type_of: "read",
|
|
289
|
-
params: {},
|
|
290
|
-
});
|
|
291
|
-
// Should then call choices endpoint for dynamic choices
|
|
292
|
-
expect(mockApiClient.post).toHaveBeenCalledWith("/zapier/api/v4/implementations/choices/", expect.objectContaining({
|
|
293
|
-
action_id: "core:123",
|
|
294
|
-
input_field_id: "channel",
|
|
295
|
-
}));
|
|
296
|
-
// Should return dynamic choices
|
|
297
|
-
expect(result.data).toHaveLength(3);
|
|
298
|
-
});
|
|
299
|
-
it("should fall back to dynamic choices when field is not found", async () => {
|
|
300
|
-
// Mock api.post - needs endpoint returns different field
|
|
301
|
-
const mockNeedsWithOtherField = {
|
|
302
|
-
success: true,
|
|
303
|
-
needs: [
|
|
304
|
-
{
|
|
305
|
-
key: "other_field",
|
|
306
|
-
label: "Other Field",
|
|
307
|
-
help_text: "Some other field",
|
|
308
|
-
required: false,
|
|
309
|
-
type: "string",
|
|
310
|
-
choices: [],
|
|
311
|
-
},
|
|
312
|
-
],
|
|
313
|
-
};
|
|
314
|
-
const mockPost = vi.fn().mockImplementation((path) => {
|
|
315
|
-
if (path === "/zapier/api/v4/implementations/needs/") {
|
|
316
|
-
return Promise.resolve(mockNeedsWithOtherField);
|
|
317
|
-
}
|
|
318
|
-
else if (path === "/zapier/api/v4/implementations/choices/") {
|
|
319
|
-
return Promise.resolve(mockChoicesResponse);
|
|
320
|
-
}
|
|
321
|
-
return Promise.reject(new Error(`Unexpected endpoint: ${path}`));
|
|
322
|
-
});
|
|
323
|
-
mockApiClient.post = mockPost;
|
|
324
|
-
const sdk = createTestSdk();
|
|
325
|
-
await sdk.listInputFieldChoices({
|
|
326
|
-
appKey: "slack",
|
|
327
|
-
actionType: "read",
|
|
328
|
-
actionKey: "send_message",
|
|
329
|
-
inputFieldKey: "channel",
|
|
330
|
-
});
|
|
331
|
-
// Should call needs endpoint first
|
|
332
|
-
expect(mockApiClient.post).toHaveBeenCalledWith("/zapier/api/v4/implementations/needs/", expect.anything());
|
|
333
|
-
// Should call choices endpoint since field was not found in needs
|
|
334
|
-
expect(mockApiClient.post).toHaveBeenCalledWith("/zapier/api/v4/implementations/choices/", expect.anything());
|
|
335
|
-
});
|
|
336
|
-
});
|
|
337
|
-
describe("API integration - action method", () => {
|
|
338
|
-
it("should call the correct API endpoint with action method", async () => {
|
|
339
|
-
const sdk = createTestSdk();
|
|
340
|
-
await sdk.listInputFieldChoices({
|
|
341
|
-
appKey: "slack",
|
|
342
|
-
actionType: "read",
|
|
343
|
-
actionKey: "send_message",
|
|
344
|
-
inputFieldKey: "channel",
|
|
345
|
-
});
|
|
346
|
-
expect(mockGetAction).toHaveBeenCalledWith(expect.objectContaining({
|
|
347
|
-
appKey: "slack",
|
|
348
|
-
actionType: "read",
|
|
349
|
-
actionKey: "send_message",
|
|
350
|
-
}));
|
|
351
|
-
expect(mockApiClient.post).toHaveBeenCalledWith("/zapier/api/v4/implementations/choices/", {
|
|
352
|
-
action_id: "core:123",
|
|
353
|
-
input_field_id: "channel",
|
|
354
|
-
page: 0,
|
|
355
|
-
params: {},
|
|
356
|
-
});
|
|
357
|
-
});
|
|
358
|
-
it("should include authentication_id when provided", async () => {
|
|
359
|
-
const sdk = createTestSdk();
|
|
360
|
-
await sdk.listInputFieldChoices({
|
|
361
|
-
appKey: "slack",
|
|
362
|
-
actionType: "read",
|
|
363
|
-
actionKey: "send_message",
|
|
364
|
-
inputFieldKey: "channel",
|
|
365
|
-
authenticationId: 456,
|
|
366
|
-
});
|
|
367
|
-
expect(mockApiClient.post).toHaveBeenCalledWith("/zapier/api/v4/implementations/choices/", {
|
|
368
|
-
action_id: "core:123",
|
|
369
|
-
input_field_id: "channel",
|
|
370
|
-
authentication_id: 456,
|
|
371
|
-
page: 0,
|
|
372
|
-
params: {},
|
|
373
|
-
});
|
|
374
|
-
});
|
|
375
|
-
it("should exclude authentication_id when null", async () => {
|
|
376
|
-
const sdk = createTestSdk();
|
|
377
|
-
await sdk.listInputFieldChoices({
|
|
378
|
-
appKey: "slack",
|
|
379
|
-
actionType: "read",
|
|
380
|
-
actionKey: "send_message",
|
|
381
|
-
inputFieldKey: "channel",
|
|
382
|
-
authenticationId: null,
|
|
383
|
-
});
|
|
384
|
-
expect(mockApiClient.post).toHaveBeenCalledWith("/zapier/api/v4/implementations/choices/", {
|
|
385
|
-
action_id: "core:123",
|
|
386
|
-
input_field_id: "channel",
|
|
387
|
-
page: 0,
|
|
388
|
-
params: {},
|
|
389
|
-
// No authentication_id
|
|
390
|
-
});
|
|
391
|
-
});
|
|
392
|
-
it("should include inputs when provided", async () => {
|
|
393
|
-
const sdk = createTestSdk();
|
|
394
|
-
const inputs = { workspace: "my-team", board: "project" };
|
|
395
|
-
await sdk.listInputFieldChoices({
|
|
396
|
-
appKey: "slack",
|
|
397
|
-
actionType: "read",
|
|
398
|
-
actionKey: "send_message",
|
|
399
|
-
inputFieldKey: "channel",
|
|
400
|
-
inputs,
|
|
401
|
-
});
|
|
402
|
-
expect(mockApiClient.post).toHaveBeenCalledWith("/zapier/api/v4/implementations/choices/", {
|
|
403
|
-
action_id: "core:123",
|
|
404
|
-
input_field_id: "channel",
|
|
405
|
-
page: 0,
|
|
406
|
-
params: inputs,
|
|
407
|
-
});
|
|
408
|
-
});
|
|
409
|
-
it("should include page when provided", async () => {
|
|
410
|
-
const sdk = createTestSdk();
|
|
411
|
-
await sdk.listInputFieldChoices({
|
|
412
|
-
appKey: "slack",
|
|
413
|
-
actionType: "read",
|
|
414
|
-
actionKey: "send_message",
|
|
415
|
-
inputFieldKey: "channel",
|
|
416
|
-
page: 2,
|
|
417
|
-
});
|
|
418
|
-
expect(mockApiClient.post).toHaveBeenCalledWith("/zapier/api/v4/implementations/choices/", {
|
|
419
|
-
action_id: "core:123",
|
|
420
|
-
input_field_id: "channel",
|
|
421
|
-
page: 2,
|
|
422
|
-
params: {},
|
|
423
|
-
});
|
|
424
|
-
});
|
|
425
|
-
});
|
|
426
|
-
describe("data transformation", () => {
|
|
427
|
-
it("should transform choices to input field choice items correctly", async () => {
|
|
428
|
-
const sdk = createTestSdk();
|
|
429
|
-
const result = await sdk.listInputFieldChoices({
|
|
430
|
-
appKey: "slack",
|
|
431
|
-
actionType: "read",
|
|
432
|
-
actionKey: "send_message",
|
|
433
|
-
inputFieldKey: "channel",
|
|
434
|
-
});
|
|
435
|
-
expect(result.data).toHaveLength(3);
|
|
436
|
-
// Check first choice transformation
|
|
437
|
-
expect(result.data[0]).toEqual({
|
|
438
|
-
key: "general",
|
|
439
|
-
label: "General Channel",
|
|
440
|
-
sample: "#general",
|
|
441
|
-
value: "general",
|
|
442
|
-
});
|
|
443
|
-
// Check second choice transformation
|
|
444
|
-
expect(result.data[1]).toEqual({
|
|
445
|
-
key: "random",
|
|
446
|
-
label: "Random Channel",
|
|
447
|
-
sample: "#random",
|
|
448
|
-
value: "random",
|
|
449
|
-
});
|
|
450
|
-
});
|
|
451
|
-
it("should handle choices with missing fields gracefully", async () => {
|
|
452
|
-
const sparseChoices = [
|
|
453
|
-
{ key: "item1", label: "Item 1" },
|
|
454
|
-
{ value: "item2", sample: "item2" },
|
|
455
|
-
{ label: "Item 3" },
|
|
456
|
-
];
|
|
457
|
-
mockApiClient.post = vi.fn().mockResolvedValue({
|
|
458
|
-
success: true,
|
|
459
|
-
choices: sparseChoices,
|
|
460
|
-
});
|
|
461
|
-
const sdk = createTestSdk();
|
|
462
|
-
const result = await sdk.listInputFieldChoices({
|
|
463
|
-
appKey: "slack",
|
|
464
|
-
actionType: "read",
|
|
465
|
-
actionKey: "send_message",
|
|
466
|
-
inputFieldKey: "item",
|
|
467
|
-
});
|
|
468
|
-
expect(result.data).toHaveLength(3);
|
|
469
|
-
expect(result.data[0]).toEqual({
|
|
470
|
-
key: "item1",
|
|
471
|
-
label: "Item 1",
|
|
472
|
-
sample: undefined,
|
|
473
|
-
value: undefined,
|
|
474
|
-
});
|
|
475
|
-
expect(result.data[1]).toEqual({
|
|
476
|
-
key: undefined,
|
|
477
|
-
label: undefined,
|
|
478
|
-
sample: "item2",
|
|
479
|
-
value: "item2",
|
|
480
|
-
});
|
|
481
|
-
});
|
|
482
|
-
});
|
|
483
|
-
describe("pagination handling", () => {
|
|
484
|
-
it("should handle next_page pagination correctly in the plugin", async () => {
|
|
485
|
-
mockApiClient.post = vi
|
|
486
|
-
.fn()
|
|
487
|
-
.mockResolvedValue(mockPaginatedChoicesResponse);
|
|
488
|
-
const sdk = createTestSdk();
|
|
489
|
-
// Test that the plugin correctly sets nextCursor when next_page is present
|
|
490
|
-
const listChoicesResult = sdk.listInputFieldChoices({
|
|
491
|
-
appKey: "slack",
|
|
492
|
-
actionType: "read",
|
|
493
|
-
actionKey: "send_message",
|
|
494
|
-
inputFieldKey: "channel",
|
|
495
|
-
pageSize: 2, // Set a small page size to test pagination behavior
|
|
496
|
-
});
|
|
497
|
-
const pages = [];
|
|
498
|
-
for await (const page of listChoicesResult) {
|
|
499
|
-
pages.push(page);
|
|
500
|
-
break; // Just get first page for testing
|
|
501
|
-
}
|
|
502
|
-
expect(pages).toHaveLength(1);
|
|
503
|
-
expect(pages[0].nextCursor).toBe("1");
|
|
504
|
-
});
|
|
505
|
-
it("should handle external action link-based pagination correctly in the plugin", async () => {
|
|
506
|
-
mockApiClient.post = vi
|
|
507
|
-
.fn()
|
|
508
|
-
.mockResolvedValue(mockExternalChoicesResponse);
|
|
509
|
-
const sdk = createTestSdk();
|
|
510
|
-
// Test that the plugin correctly extracts cursor from links.next
|
|
511
|
-
const listChoicesResult = sdk.listInputFieldChoices({
|
|
512
|
-
appKey: "slack",
|
|
513
|
-
actionType: "read",
|
|
514
|
-
actionKey: "send_message",
|
|
515
|
-
inputFieldKey: "option",
|
|
516
|
-
pageSize: 3, // Set a small page size to test pagination behavior
|
|
517
|
-
});
|
|
518
|
-
const pages = [];
|
|
519
|
-
for await (const page of listChoicesResult) {
|
|
520
|
-
pages.push(page);
|
|
521
|
-
break; // Just get first page for testing
|
|
522
|
-
}
|
|
523
|
-
expect(pages).toHaveLength(1);
|
|
524
|
-
expect(pages[0].nextCursor).toBe("1"); // Extracted from links.next URL
|
|
525
|
-
});
|
|
526
|
-
it("should handle no pagination", async () => {
|
|
527
|
-
const sdk = createTestSdk();
|
|
528
|
-
const listChoicesResult = sdk.listInputFieldChoices({
|
|
529
|
-
appKey: "slack",
|
|
530
|
-
actionType: "read",
|
|
531
|
-
actionKey: "send_message",
|
|
532
|
-
inputFieldKey: "channel",
|
|
533
|
-
});
|
|
534
|
-
const pages = [];
|
|
535
|
-
for await (const page of listChoicesResult) {
|
|
536
|
-
pages.push(page);
|
|
537
|
-
break; // Just get first page for testing
|
|
538
|
-
}
|
|
539
|
-
expect(pages).toHaveLength(1);
|
|
540
|
-
expect(pages[0].nextCursor).toBeUndefined();
|
|
541
|
-
});
|
|
542
|
-
it("should support async iteration over individual items", async () => {
|
|
543
|
-
const sdk = createTestSdk();
|
|
544
|
-
const listChoicesResult = sdk.listInputFieldChoices({
|
|
545
|
-
appKey: "slack",
|
|
546
|
-
actionType: "read",
|
|
547
|
-
actionKey: "send_message",
|
|
548
|
-
inputFieldKey: "channel",
|
|
549
|
-
});
|
|
550
|
-
const items = [];
|
|
551
|
-
for await (const item of listChoicesResult.items()) {
|
|
552
|
-
items.push(item);
|
|
553
|
-
}
|
|
554
|
-
expect(items).toHaveLength(3);
|
|
555
|
-
expect(items[0].key).toBe("general");
|
|
556
|
-
});
|
|
557
|
-
it("should handle malformed links.next URL gracefully", async () => {
|
|
558
|
-
const malformedExternalResponse = {
|
|
559
|
-
success: true,
|
|
560
|
-
choices: mockChoices,
|
|
561
|
-
links: {
|
|
562
|
-
next: "invalid-url-format", // Malformed URL
|
|
563
|
-
prev: null,
|
|
564
|
-
},
|
|
565
|
-
};
|
|
566
|
-
mockApiClient.post = vi.fn().mockResolvedValue(malformedExternalResponse);
|
|
567
|
-
const sdk = createTestSdk();
|
|
568
|
-
const listChoicesResult = sdk.listInputFieldChoices({
|
|
569
|
-
appKey: "slack",
|
|
570
|
-
actionType: "read",
|
|
571
|
-
actionKey: "send_message",
|
|
572
|
-
inputFieldKey: "option",
|
|
573
|
-
});
|
|
574
|
-
const pages = [];
|
|
575
|
-
for await (const page of listChoicesResult) {
|
|
576
|
-
pages.push(page);
|
|
577
|
-
break;
|
|
578
|
-
}
|
|
579
|
-
expect(pages).toHaveLength(1);
|
|
580
|
-
expect(pages[0].nextCursor).toBeUndefined(); // Should handle gracefully
|
|
581
|
-
});
|
|
582
|
-
it("should handle links.next URL without page parameter", async () => {
|
|
583
|
-
const noPageResponse = {
|
|
584
|
-
success: true,
|
|
585
|
-
choices: mockChoices,
|
|
586
|
-
links: {
|
|
587
|
-
next: "https://api.zapier.com/api/v4/implementations/choices/", // No page param
|
|
588
|
-
prev: null,
|
|
589
|
-
},
|
|
590
|
-
};
|
|
591
|
-
mockApiClient.post = vi.fn().mockResolvedValue(noPageResponse);
|
|
592
|
-
const sdk = createTestSdk();
|
|
593
|
-
const listChoicesResult = sdk.listInputFieldChoices({
|
|
594
|
-
appKey: "slack",
|
|
595
|
-
actionType: "read",
|
|
596
|
-
actionKey: "send_message",
|
|
597
|
-
inputFieldKey: "option",
|
|
598
|
-
});
|
|
599
|
-
const pages = [];
|
|
600
|
-
for await (const page of listChoicesResult) {
|
|
601
|
-
pages.push(page);
|
|
602
|
-
break;
|
|
603
|
-
}
|
|
604
|
-
expect(pages).toHaveLength(1);
|
|
605
|
-
expect(pages[0].nextCursor).toBeUndefined();
|
|
606
|
-
});
|
|
607
|
-
});
|
|
608
|
-
describe("error handling", () => {
|
|
609
|
-
it("should throw ZapierApiError when API response indicates failure", async () => {
|
|
610
|
-
mockApiClient.post = vi.fn().mockResolvedValue({
|
|
611
|
-
success: false,
|
|
612
|
-
errors: ["Invalid field", "Missing authentication"],
|
|
613
|
-
});
|
|
614
|
-
const sdk = createTestSdk();
|
|
615
|
-
await expect(sdk.listInputFieldChoices({
|
|
616
|
-
appKey: "slack",
|
|
617
|
-
actionType: "read",
|
|
618
|
-
actionKey: "send_message",
|
|
619
|
-
inputFieldKey: "invalid_field",
|
|
620
|
-
})).rejects.toThrow(ZapierApiError);
|
|
621
|
-
// Error comes from needs endpoint (first call) with user-friendly message
|
|
622
|
-
await expect(sdk.listInputFieldChoices({
|
|
623
|
-
appKey: "slack",
|
|
624
|
-
actionType: "read",
|
|
625
|
-
actionKey: "send_message",
|
|
626
|
-
inputFieldKey: "invalid_field",
|
|
627
|
-
})).rejects.toThrow("Failed to get input fields: Invalid field, Missing authentication");
|
|
628
|
-
});
|
|
629
|
-
it("should handle API errors gracefully", async () => {
|
|
630
|
-
mockApiClient.post = vi
|
|
631
|
-
.fn()
|
|
632
|
-
.mockRejectedValue(new Error("Network error"));
|
|
633
|
-
const sdk = createTestSdk();
|
|
634
|
-
await expect(sdk.listInputFieldChoices({
|
|
635
|
-
appKey: "slack",
|
|
636
|
-
actionType: "read",
|
|
637
|
-
actionKey: "send_message",
|
|
638
|
-
inputFieldKey: "channel",
|
|
639
|
-
})).rejects.toThrow("Network error");
|
|
640
|
-
});
|
|
641
|
-
it("should handle empty choices array response", async () => {
|
|
642
|
-
mockApiClient.post = vi.fn().mockResolvedValue({
|
|
643
|
-
success: true,
|
|
644
|
-
choices: [], // Empty choices
|
|
645
|
-
});
|
|
646
|
-
const sdk = createTestSdk();
|
|
647
|
-
const result = await sdk.listInputFieldChoices({
|
|
648
|
-
appKey: "slack",
|
|
649
|
-
actionType: "read",
|
|
650
|
-
actionKey: "send_message",
|
|
651
|
-
inputFieldKey: "channel",
|
|
652
|
-
});
|
|
653
|
-
expect(result.data).toEqual([]);
|
|
654
|
-
});
|
|
655
|
-
it("should handle missing choices field in response", async () => {
|
|
656
|
-
mockApiClient.post = vi.fn().mockResolvedValue({
|
|
657
|
-
success: true,
|
|
658
|
-
// Missing choices field
|
|
659
|
-
});
|
|
660
|
-
const sdk = createTestSdk();
|
|
661
|
-
const result = await sdk.listInputFieldChoices({
|
|
662
|
-
appKey: "slack",
|
|
663
|
-
actionType: "read",
|
|
664
|
-
actionKey: "send_message",
|
|
665
|
-
inputFieldKey: "channel",
|
|
666
|
-
});
|
|
667
|
-
expect(result.data).toEqual([]);
|
|
668
|
-
});
|
|
669
|
-
it("should treat missing success field as failure", async () => {
|
|
670
|
-
mockApiClient.post = vi.fn().mockResolvedValue({
|
|
671
|
-
// Missing success field (undefined)
|
|
672
|
-
choices: mockChoices,
|
|
673
|
-
});
|
|
674
|
-
const sdk = createTestSdk();
|
|
675
|
-
await expect(sdk.listInputFieldChoices({
|
|
676
|
-
appKey: "slack",
|
|
677
|
-
actionType: "read",
|
|
678
|
-
actionKey: "send_message",
|
|
679
|
-
inputFieldKey: "channel",
|
|
680
|
-
})).rejects.toThrow("Failed to get input fields: Unknown error");
|
|
681
|
-
});
|
|
682
|
-
it("should handle API response with errors but no error messages", async () => {
|
|
683
|
-
mockApiClient.post = vi.fn().mockResolvedValue({
|
|
684
|
-
success: false,
|
|
685
|
-
// Missing errors field
|
|
686
|
-
});
|
|
687
|
-
const sdk = createTestSdk();
|
|
688
|
-
await expect(sdk.listInputFieldChoices({
|
|
689
|
-
appKey: "slack",
|
|
690
|
-
actionType: "read",
|
|
691
|
-
actionKey: "send_message",
|
|
692
|
-
inputFieldKey: "channel",
|
|
693
|
-
})).rejects.toThrow("Failed to get input fields: Unknown error");
|
|
694
|
-
});
|
|
695
|
-
it("should handle API response with empty errors array", async () => {
|
|
696
|
-
mockApiClient.post = vi.fn().mockResolvedValue({
|
|
697
|
-
success: false,
|
|
698
|
-
errors: [], // Empty errors array
|
|
699
|
-
});
|
|
700
|
-
const sdk = createTestSdk();
|
|
701
|
-
await expect(sdk.listInputFieldChoices({
|
|
702
|
-
appKey: "slack",
|
|
703
|
-
actionType: "read",
|
|
704
|
-
actionKey: "send_message",
|
|
705
|
-
inputFieldKey: "channel",
|
|
706
|
-
})).rejects.toThrow("Failed to get input fields: Unknown error");
|
|
707
|
-
});
|
|
708
|
-
});
|
|
709
|
-
describe("context and metadata", () => {
|
|
710
|
-
it("should provide context with meta information", () => {
|
|
711
|
-
const sdk = createTestSdk();
|
|
712
|
-
const context = sdk.getContext();
|
|
713
|
-
expect(context.meta.listInputFieldChoices).toBeDefined();
|
|
714
|
-
expect(context.meta.listInputFieldChoices.inputSchema).toBeDefined();
|
|
715
|
-
});
|
|
716
|
-
});
|
|
717
|
-
});
|