@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,1139 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect, vi, beforeEach, afterEach } from "vitest";
|
|
2
|
-
import { manifestPlugin, readManifestFromFile, findManifestEntry, getPreferredManifestEntryKey, } from "./index";
|
|
3
|
-
import { createSdk } from "../../sdk";
|
|
4
|
-
import { eventEmissionPlugin } from "../eventEmission";
|
|
5
|
-
// Mock file-utils module
|
|
6
|
-
vi.mock("../../utils/file-utils", () => ({
|
|
7
|
-
readFile: vi.fn(),
|
|
8
|
-
writeFile: vi.fn(),
|
|
9
|
-
resolve: vi.fn((path) => Promise.resolve(`/resolved/${path}`)),
|
|
10
|
-
}));
|
|
11
|
-
import { readFile, resolve } from "../../utils/file-utils";
|
|
12
|
-
const mockReadFile = vi.mocked(readFile);
|
|
13
|
-
const mockResolve = vi.mocked(resolve);
|
|
14
|
-
const mockResolveAppKeys = vi.fn();
|
|
15
|
-
describe("manifestPlugin", () => {
|
|
16
|
-
const mockManifest = {
|
|
17
|
-
apps: {
|
|
18
|
-
slack: {
|
|
19
|
-
implementationName: "SlackCLIAPI",
|
|
20
|
-
version: "1.21.1",
|
|
21
|
-
},
|
|
22
|
-
"google-sheets": {
|
|
23
|
-
implementationName: "GoogleSheetsCLIAPI",
|
|
24
|
-
version: "2.0.0",
|
|
25
|
-
},
|
|
26
|
-
},
|
|
27
|
-
};
|
|
28
|
-
const mockManifestContent = JSON.stringify(mockManifest);
|
|
29
|
-
let mockApiClient;
|
|
30
|
-
let mockSdk;
|
|
31
|
-
beforeEach(() => {
|
|
32
|
-
vi.clearAllMocks();
|
|
33
|
-
vi.spyOn(console, "warn").mockImplementation(() => { });
|
|
34
|
-
mockApiClient = {
|
|
35
|
-
get: vi.fn().mockImplementation((url, options) => {
|
|
36
|
-
if (url === "/zapier/api/v4/implementations/") {
|
|
37
|
-
// Mock for manifest entries (versioned)
|
|
38
|
-
return Promise.resolve({
|
|
39
|
-
count: 1,
|
|
40
|
-
next: null,
|
|
41
|
-
previous: null,
|
|
42
|
-
results: [
|
|
43
|
-
{
|
|
44
|
-
selected_api: "SlackCLIAPI@1.29.0",
|
|
45
|
-
app_id: null,
|
|
46
|
-
service_id: null,
|
|
47
|
-
auth_type: "oauth",
|
|
48
|
-
auth_fields: [
|
|
49
|
-
{
|
|
50
|
-
key: "access_token",
|
|
51
|
-
required: true,
|
|
52
|
-
type: "unicode",
|
|
53
|
-
computed: true,
|
|
54
|
-
},
|
|
55
|
-
],
|
|
56
|
-
is_deprecated: false,
|
|
57
|
-
is_private_only: false,
|
|
58
|
-
is_invite_only: false,
|
|
59
|
-
is_beta: false,
|
|
60
|
-
is_premium: false,
|
|
61
|
-
is_hidden: false,
|
|
62
|
-
name: "Slack (1.29.0)",
|
|
63
|
-
name_clean: "Slack",
|
|
64
|
-
version: "1.29.0",
|
|
65
|
-
slug: null,
|
|
66
|
-
images: {
|
|
67
|
-
url_16x16: "https://zapier-images.imgix.net/storage/services/6cf3f5a461feadfba7abc93c4c395b33_2.png?auto=format%2Ccompress&fit=crop&h=16&ixlib=python-3.0.0&q=50&w=16",
|
|
68
|
-
url_32x32: "https://zapier-images.imgix.net/storage/services/6cf3f5a461feadfba7abc93c4c395b33_2.png?auto=format%2Ccompress&fit=crop&h=32&ixlib=python-3.0.0&q=50&w=32",
|
|
69
|
-
url_64x64: "https://zapier-images.imgix.net/storage/services/6cf3f5a461feadfba7abc93c4c395b33_2.png?auto=format%2Ccompress&fit=crop&h=64&ixlib=python-3.0.0&q=50&w=64",
|
|
70
|
-
url_128x128: "https://zapier-images.imgix.net/storage/services/6cf3f5a461feadfba7abc93c4c395b33_2.png?auto=format%2Ccompress&fit=crop&h=128&ixlib=python-3.0.0&q=50&w=128",
|
|
71
|
-
},
|
|
72
|
-
primary_color: null,
|
|
73
|
-
secondary_color: null,
|
|
74
|
-
classification: "third-party",
|
|
75
|
-
current_implementation: "SlackCLIAPI@1.30.0",
|
|
76
|
-
is_adoptable: true,
|
|
77
|
-
is_usable: true,
|
|
78
|
-
update_cta_level: "info",
|
|
79
|
-
update_cta_message: "This version is legacy. Consider updating to the latest version for better support.",
|
|
80
|
-
badges: [
|
|
81
|
-
{
|
|
82
|
-
label: "Legacy",
|
|
83
|
-
color: "primary",
|
|
84
|
-
tooltip_markdown: "This version is legacy. Consider updating to the latest version for better support.",
|
|
85
|
-
},
|
|
86
|
-
],
|
|
87
|
-
},
|
|
88
|
-
],
|
|
89
|
-
});
|
|
90
|
-
}
|
|
91
|
-
else if (url === "/zapier/api/v4/implementations-meta/lookup/") {
|
|
92
|
-
// Mock for implementations-meta/lookup fallback
|
|
93
|
-
const searchParams = options?.searchParams || {};
|
|
94
|
-
// Check if we're looking for a nonexistent app
|
|
95
|
-
if (searchParams.slugs?.includes("nonexistent") ||
|
|
96
|
-
searchParams.selected_apis?.includes("nonexistent")) {
|
|
97
|
-
return Promise.resolve({
|
|
98
|
-
count: 0,
|
|
99
|
-
next: null,
|
|
100
|
-
previous: null,
|
|
101
|
-
results: [],
|
|
102
|
-
});
|
|
103
|
-
}
|
|
104
|
-
// Return successful response for known apps (like slack)
|
|
105
|
-
return Promise.resolve({
|
|
106
|
-
count: 1,
|
|
107
|
-
next: null,
|
|
108
|
-
previous: null,
|
|
109
|
-
results: [
|
|
110
|
-
{
|
|
111
|
-
id: "SlackCLIAPI@1.30.0",
|
|
112
|
-
name: "Slack",
|
|
113
|
-
slug: "slack",
|
|
114
|
-
images: {},
|
|
115
|
-
},
|
|
116
|
-
],
|
|
117
|
-
});
|
|
118
|
-
}
|
|
119
|
-
return Promise.resolve({ count: 0, results: [] });
|
|
120
|
-
}),
|
|
121
|
-
};
|
|
122
|
-
mockSdk = {
|
|
123
|
-
listApps: vi.fn().mockReturnValue({
|
|
124
|
-
items: vi.fn().mockReturnValue([
|
|
125
|
-
{
|
|
126
|
-
title: "Slack",
|
|
127
|
-
key: "slack",
|
|
128
|
-
current_implementation_id: "SlackCLIAPI@1.30.0",
|
|
129
|
-
description: "Team communication platform",
|
|
130
|
-
},
|
|
131
|
-
][Symbol.iterator]()),
|
|
132
|
-
}),
|
|
133
|
-
};
|
|
134
|
-
});
|
|
135
|
-
afterEach(() => {
|
|
136
|
-
vi.restoreAllMocks();
|
|
137
|
-
});
|
|
138
|
-
const apiPlugin = () => ({
|
|
139
|
-
context: {
|
|
140
|
-
api: mockApiClient,
|
|
141
|
-
},
|
|
142
|
-
});
|
|
143
|
-
const listAppsMockPlugin = () => ({
|
|
144
|
-
listApps: mockSdk.listApps,
|
|
145
|
-
context: {
|
|
146
|
-
meta: {
|
|
147
|
-
listApps: {
|
|
148
|
-
inputSchema: {},
|
|
149
|
-
},
|
|
150
|
-
},
|
|
151
|
-
},
|
|
152
|
-
});
|
|
153
|
-
function createTestSdk(options = {}) {
|
|
154
|
-
return createSdk(options)
|
|
155
|
-
.addPlugin(() => ({
|
|
156
|
-
context: {
|
|
157
|
-
options: {},
|
|
158
|
-
},
|
|
159
|
-
}))
|
|
160
|
-
.addPlugin(apiPlugin)
|
|
161
|
-
.addPlugin(eventEmissionPlugin)
|
|
162
|
-
.addPlugin(manifestPlugin);
|
|
163
|
-
}
|
|
164
|
-
describe("plugin initialization", () => {
|
|
165
|
-
it("should provide helper functions with direct manifest", () => {
|
|
166
|
-
const sdk = createTestSdk({ manifest: mockManifest });
|
|
167
|
-
const context = sdk.getContext();
|
|
168
|
-
expect(context.getVersionedImplementationId).toBeInstanceOf(Function);
|
|
169
|
-
});
|
|
170
|
-
it("should provide helper functions with manifestPath", async () => {
|
|
171
|
-
mockReadFile.mockResolvedValue(mockManifestContent);
|
|
172
|
-
const sdk = createTestSdk({ manifestPath: "manifest.json" });
|
|
173
|
-
const context = sdk.getContext();
|
|
174
|
-
expect(context.getVersionedImplementationId).toBeInstanceOf(Function);
|
|
175
|
-
// Verify file operations happen when functions are called
|
|
176
|
-
await context.getVersionedImplementationId("slack");
|
|
177
|
-
expect(mockResolve).toHaveBeenCalledWith("manifest.json");
|
|
178
|
-
expect(mockReadFile).toHaveBeenCalledWith("/resolved/manifest.json");
|
|
179
|
-
});
|
|
180
|
-
it("should provide helper functions when no manifest or path provided", () => {
|
|
181
|
-
const sdk = createTestSdk();
|
|
182
|
-
const context = sdk.getContext();
|
|
183
|
-
expect(context.getVersionedImplementationId).toBeInstanceOf(Function);
|
|
184
|
-
// Manifest functions are available even when no manifest is provided
|
|
185
|
-
});
|
|
186
|
-
it("should prioritize direct manifest over manifestPath", () => {
|
|
187
|
-
mockReadFile.mockResolvedValue('{"apps": {"other": {"implementationName": "Other", "version": "1.0.0"}}}');
|
|
188
|
-
createTestSdk({
|
|
189
|
-
manifest: mockManifest,
|
|
190
|
-
manifestPath: "manifest.json",
|
|
191
|
-
});
|
|
192
|
-
// Verify that direct manifest is used and file loading is not needed
|
|
193
|
-
expect(mockReadFile).not.toHaveBeenCalled();
|
|
194
|
-
});
|
|
195
|
-
});
|
|
196
|
-
describe("getVersionedImplementationId function", () => {
|
|
197
|
-
it("should return versioned implementation ID when app exists in manifest", async () => {
|
|
198
|
-
const sdk = createTestSdk({ manifest: mockManifest });
|
|
199
|
-
const context = sdk.getContext();
|
|
200
|
-
const result = await context.getVersionedImplementationId("slack");
|
|
201
|
-
expect(result).toBe("SlackCLIAPI@1.21.1");
|
|
202
|
-
});
|
|
203
|
-
it("should fetch and return versioned implementation ID when app not in manifest", async () => {
|
|
204
|
-
const sdk = createTestSdk();
|
|
205
|
-
const context = sdk.getContext();
|
|
206
|
-
const result = await context.getVersionedImplementationId("slack");
|
|
207
|
-
expect(result).toBe("SlackCLIAPI@1.30.0");
|
|
208
|
-
});
|
|
209
|
-
it("should return null when app does not exist", async () => {
|
|
210
|
-
mockSdk.listApps = vi.fn().mockReturnValue({
|
|
211
|
-
items: vi.fn().mockReturnValue([][Symbol.iterator]()),
|
|
212
|
-
});
|
|
213
|
-
const sdk = createTestSdk();
|
|
214
|
-
const context = sdk.getContext();
|
|
215
|
-
const result = await context.getVersionedImplementationId("nonexistent");
|
|
216
|
-
expect(result).toBeNull();
|
|
217
|
-
});
|
|
218
|
-
});
|
|
219
|
-
describe("manifest parsing", () => {
|
|
220
|
-
it("should parse valid manifest content", () => {
|
|
221
|
-
createTestSdk({ manifest: mockManifest });
|
|
222
|
-
// Verify manifest is parsed correctly for other functions to use
|
|
223
|
-
});
|
|
224
|
-
it("should handle manifest with missing version", () => {
|
|
225
|
-
const manifestWithoutVersion = {
|
|
226
|
-
apps: {
|
|
227
|
-
slack: {
|
|
228
|
-
implementationName: "SlackCLIAPI",
|
|
229
|
-
},
|
|
230
|
-
},
|
|
231
|
-
};
|
|
232
|
-
createTestSdk({ manifest: manifestWithoutVersion });
|
|
233
|
-
// Verify manifest with missing version is handled correctly
|
|
234
|
-
});
|
|
235
|
-
it("should handle empty manifest", () => {
|
|
236
|
-
createTestSdk({ manifest: {} });
|
|
237
|
-
// Verify empty manifest is handled correctly
|
|
238
|
-
});
|
|
239
|
-
});
|
|
240
|
-
describe("file loading", () => {
|
|
241
|
-
it("should load manifest from file successfully", async () => {
|
|
242
|
-
mockReadFile.mockResolvedValue(mockManifestContent);
|
|
243
|
-
const sdk = createTestSdk({ manifestPath: "manifest.json" });
|
|
244
|
-
const context = sdk.getContext();
|
|
245
|
-
// Verify that file operations happen when functions are called
|
|
246
|
-
await context.getVersionedImplementationId("slack");
|
|
247
|
-
expect(mockResolve).toHaveBeenCalledWith("manifest.json");
|
|
248
|
-
expect(mockReadFile).toHaveBeenCalledWith("/resolved/manifest.json");
|
|
249
|
-
});
|
|
250
|
-
it("should handle file read errors gracefully", async () => {
|
|
251
|
-
mockReadFile.mockRejectedValue(new Error("File not found"));
|
|
252
|
-
const sdk = createTestSdk({ manifestPath: "nonexistent.json" });
|
|
253
|
-
const context = sdk.getContext();
|
|
254
|
-
// Trigger file loading by calling a function
|
|
255
|
-
await context.getVersionedImplementationId("slack");
|
|
256
|
-
// Verify file loading errors are handled gracefully
|
|
257
|
-
expect(console.warn).toHaveBeenCalledWith(expect.stringContaining("Failed to read manifest from nonexistent.json"));
|
|
258
|
-
});
|
|
259
|
-
it("should handle invalid JSON gracefully", async () => {
|
|
260
|
-
mockReadFile.mockResolvedValue("invalid json content");
|
|
261
|
-
const sdk = createTestSdk({ manifestPath: "invalid.json" });
|
|
262
|
-
const context = sdk.getContext();
|
|
263
|
-
// Trigger file loading by calling a function
|
|
264
|
-
await context.getVersionedImplementationId("slack");
|
|
265
|
-
// Verify JSON parsing errors are handled gracefully
|
|
266
|
-
expect(console.warn).toHaveBeenCalledWith(expect.stringContaining("Failed to parse manifest from /resolved/invalid.json"), expect.any(SyntaxError));
|
|
267
|
-
});
|
|
268
|
-
it("should handle JSON without apps property", () => {
|
|
269
|
-
mockReadFile.mockResolvedValue('{"other": "data"}');
|
|
270
|
-
createTestSdk({ manifestPath: "no-apps.json" });
|
|
271
|
-
// Verify missing apps property is handled correctly
|
|
272
|
-
});
|
|
273
|
-
it("should handle JSON with invalid apps format", () => {
|
|
274
|
-
mockReadFile.mockResolvedValue('{"apps": "not an object"}');
|
|
275
|
-
createTestSdk({ manifestPath: "invalid-apps.json" });
|
|
276
|
-
// Verify invalid apps format is handled correctly
|
|
277
|
-
});
|
|
278
|
-
});
|
|
279
|
-
describe("integration with SDK", () => {
|
|
280
|
-
it("should work with createSdk", async () => {
|
|
281
|
-
const sdk = createSdk({ manifest: mockManifest })
|
|
282
|
-
.addPlugin(apiPlugin)
|
|
283
|
-
.addPlugin(listAppsMockPlugin)
|
|
284
|
-
.addPlugin(manifestPlugin);
|
|
285
|
-
const context = sdk.getContext();
|
|
286
|
-
// Verify that the manifest data is used correctly by other functions
|
|
287
|
-
const versionedId = await context.getVersionedImplementationId("slack");
|
|
288
|
-
expect(versionedId).toBe("SlackCLIAPI@1.21.1");
|
|
289
|
-
});
|
|
290
|
-
});
|
|
291
|
-
describe("findManifestEntry function", () => {
|
|
292
|
-
it("should find entry by direct key match", () => {
|
|
293
|
-
const manifest = {
|
|
294
|
-
apps: {
|
|
295
|
-
slack: { implementationName: "SlackCLIAPI", version: "1.21.1" },
|
|
296
|
-
gmail: { implementationName: "GmailCLIAPI", version: "2.0.0" },
|
|
297
|
-
},
|
|
298
|
-
};
|
|
299
|
-
const result = findManifestEntry({ appKey: "slack", manifest });
|
|
300
|
-
expect(result).toEqual([
|
|
301
|
-
"slack",
|
|
302
|
-
{ implementationName: "SlackCLIAPI", version: "1.21.1" },
|
|
303
|
-
]);
|
|
304
|
-
});
|
|
305
|
-
it("should find entry by implementation name match", () => {
|
|
306
|
-
const manifest = {
|
|
307
|
-
apps: {
|
|
308
|
-
SlackCLIAPI: { implementationName: "SlackCLIAPI", version: "1.21.1" },
|
|
309
|
-
GmailCLIAPI: { implementationName: "GmailCLIAPI", version: "2.0.0" },
|
|
310
|
-
},
|
|
311
|
-
};
|
|
312
|
-
const result = findManifestEntry({ appKey: "SlackCLIAPI", manifest });
|
|
313
|
-
expect(result).toEqual([
|
|
314
|
-
"SlackCLIAPI",
|
|
315
|
-
{ implementationName: "SlackCLIAPI", version: "1.21.1" },
|
|
316
|
-
]);
|
|
317
|
-
});
|
|
318
|
-
it("should find existing key when searching by implementation name", () => {
|
|
319
|
-
const manifest = {
|
|
320
|
-
apps: {
|
|
321
|
-
SlackCLIAPI: { implementationName: "SlackCLIAPI", version: "1.21.1" },
|
|
322
|
-
},
|
|
323
|
-
};
|
|
324
|
-
// This is the key test: searching by implementation name should find existing entry
|
|
325
|
-
const result = findManifestEntry({ appKey: "SlackCLIAPI", manifest });
|
|
326
|
-
expect(result).toEqual([
|
|
327
|
-
"SlackCLIAPI",
|
|
328
|
-
{ implementationName: "SlackCLIAPI", version: "1.21.1" },
|
|
329
|
-
]);
|
|
330
|
-
});
|
|
331
|
-
it("should return null when no match found", () => {
|
|
332
|
-
const manifest = {
|
|
333
|
-
apps: {
|
|
334
|
-
gmail: { implementationName: "GmailCLIAPI", version: "2.0.0" },
|
|
335
|
-
},
|
|
336
|
-
};
|
|
337
|
-
const result = findManifestEntry({ appKey: "slack", manifest });
|
|
338
|
-
expect(result).toBeNull();
|
|
339
|
-
});
|
|
340
|
-
it("should handle snake-cased slugs", () => {
|
|
341
|
-
const manifest = {
|
|
342
|
-
apps: {
|
|
343
|
-
"google-sheets": {
|
|
344
|
-
implementationName: "GoogleSheetsCLIAPI",
|
|
345
|
-
version: "1.0.0",
|
|
346
|
-
},
|
|
347
|
-
},
|
|
348
|
-
};
|
|
349
|
-
const result = findManifestEntry({ appKey: "google_sheets", manifest });
|
|
350
|
-
expect(result).toEqual([
|
|
351
|
-
"google-sheets",
|
|
352
|
-
{ implementationName: "GoogleSheetsCLIAPI", version: "1.0.0" },
|
|
353
|
-
]);
|
|
354
|
-
});
|
|
355
|
-
it("should NOT find entry when searching slug against implementation name key (current limitation)", () => {
|
|
356
|
-
const manifest = {
|
|
357
|
-
apps: {
|
|
358
|
-
SlackCLIAPI: { implementationName: "SlackCLIAPI", version: "1.21.1" },
|
|
359
|
-
},
|
|
360
|
-
};
|
|
361
|
-
// This will fail - we search by "slack" but can't find "SlackCLIAPI" entry
|
|
362
|
-
// This is the core issue we need to solve
|
|
363
|
-
const result = findManifestEntry({ appKey: "slack", manifest });
|
|
364
|
-
expect(result).toBeNull(); // Current behavior - doesn't find it
|
|
365
|
-
// We need to fix this so it CAN find existing implementation name entries
|
|
366
|
-
});
|
|
367
|
-
});
|
|
368
|
-
describe("updateManifestEntry with slug-to-implementation matching", () => {
|
|
369
|
-
it("should find existing implementation name entry when input is slug", async () => {
|
|
370
|
-
// Mock existing manifest with implementation name as key
|
|
371
|
-
mockReadFile.mockResolvedValue(JSON.stringify({
|
|
372
|
-
apps: {
|
|
373
|
-
SlackCLIAPI: {
|
|
374
|
-
implementationName: "SlackCLIAPI",
|
|
375
|
-
version: "1.21.1",
|
|
376
|
-
},
|
|
377
|
-
},
|
|
378
|
-
}));
|
|
379
|
-
// Mock resolveAppKeys to resolve "slack" to "SlackCLIAPI"
|
|
380
|
-
mockResolveAppKeys.mockResolvedValue([
|
|
381
|
-
{
|
|
382
|
-
slug: "slack",
|
|
383
|
-
implementationName: "SlackCLIAPI",
|
|
384
|
-
version: "1.30.0",
|
|
385
|
-
lookupAppKey: "slack",
|
|
386
|
-
},
|
|
387
|
-
]);
|
|
388
|
-
const sdk = createTestSdk();
|
|
389
|
-
const context = sdk.getContext();
|
|
390
|
-
// This should now find the existing "SlackCLIAPI" entry
|
|
391
|
-
const { key: manifestKey } = await context.updateManifestEntry({
|
|
392
|
-
appKey: "slack", // Input is slug
|
|
393
|
-
entry: { implementationName: "SlackCLIAPI", version: "1.30.0" },
|
|
394
|
-
});
|
|
395
|
-
// Should return the existing key, not create a new one
|
|
396
|
-
expect(manifestKey).toBe("SlackCLIAPI");
|
|
397
|
-
});
|
|
398
|
-
});
|
|
399
|
-
describe("resolveAppKeys function", () => {
|
|
400
|
-
it("should resolve slug to manifest entry even when manifest uses implementation name as key", async () => {
|
|
401
|
-
const manifest = {
|
|
402
|
-
apps: {
|
|
403
|
-
SlackCLIAPI: { implementationName: "SlackCLIAPI", version: "1.21.1" },
|
|
404
|
-
},
|
|
405
|
-
};
|
|
406
|
-
// Mock API to return slack app data when looking up "slack"
|
|
407
|
-
mockApiClient.get = vi.fn().mockResolvedValue({
|
|
408
|
-
count: 1,
|
|
409
|
-
next: null,
|
|
410
|
-
previous: null,
|
|
411
|
-
results: [
|
|
412
|
-
{
|
|
413
|
-
id: "SlackCLIAPI@1.30.0",
|
|
414
|
-
name: "Slack",
|
|
415
|
-
slug: "slack",
|
|
416
|
-
key: "SlackCLIAPI", // This is the implementation name
|
|
417
|
-
version: "1.30.0",
|
|
418
|
-
},
|
|
419
|
-
],
|
|
420
|
-
});
|
|
421
|
-
// Test resolveAppKeys directly using the manifest plugin
|
|
422
|
-
const sdk = createSdk({ manifest })
|
|
423
|
-
.addPlugin(apiPlugin)
|
|
424
|
-
.addPlugin(manifestPlugin);
|
|
425
|
-
const context = sdk.getContext();
|
|
426
|
-
const resolved = await context.resolveAppKeys({ appKeys: ["slack"] });
|
|
427
|
-
// Should find the manifest entry and use its version (1.21.1) instead of latest (1.30.0)
|
|
428
|
-
expect(resolved).toHaveLength(1);
|
|
429
|
-
expect(resolved[0]).toEqual({
|
|
430
|
-
slug: "slack",
|
|
431
|
-
implementationName: "SlackCLIAPI",
|
|
432
|
-
version: "1.21.1", // Should use manifest version, not API version
|
|
433
|
-
lookupAppKey: "slack",
|
|
434
|
-
});
|
|
435
|
-
});
|
|
436
|
-
it("should fall back to API version when no manifest entry found", async () => {
|
|
437
|
-
const manifest = { apps: {} }; // Empty manifest
|
|
438
|
-
// Mock API to return slack app data
|
|
439
|
-
mockApiClient.get = vi.fn().mockResolvedValue({
|
|
440
|
-
count: 1,
|
|
441
|
-
next: null,
|
|
442
|
-
previous: null,
|
|
443
|
-
results: [
|
|
444
|
-
{
|
|
445
|
-
id: "SlackCLIAPI@1.30.0",
|
|
446
|
-
name: "Slack",
|
|
447
|
-
slug: "slack",
|
|
448
|
-
key: "SlackCLIAPI",
|
|
449
|
-
version: "1.30.0",
|
|
450
|
-
},
|
|
451
|
-
],
|
|
452
|
-
});
|
|
453
|
-
const sdk = createSdk({ manifest })
|
|
454
|
-
.addPlugin(apiPlugin)
|
|
455
|
-
.addPlugin(manifestPlugin);
|
|
456
|
-
const context = sdk.getContext();
|
|
457
|
-
const resolved = await context.resolveAppKeys({ appKeys: ["slack"] });
|
|
458
|
-
// Should use API version since no manifest entry found
|
|
459
|
-
expect(resolved).toHaveLength(1);
|
|
460
|
-
expect(resolved[0]).toEqual({
|
|
461
|
-
slug: "slack",
|
|
462
|
-
implementationName: "SlackCLIAPI",
|
|
463
|
-
version: "1.30.0", // Should use API version
|
|
464
|
-
lookupAppKey: "slack",
|
|
465
|
-
});
|
|
466
|
-
});
|
|
467
|
-
it("should always use version from input when specified (slug@version)", async () => {
|
|
468
|
-
const manifest = {
|
|
469
|
-
apps: {
|
|
470
|
-
SlackCLIAPI: { implementationName: "SlackCLIAPI", version: "1.21.1" },
|
|
471
|
-
},
|
|
472
|
-
};
|
|
473
|
-
// Mock API to return slack app data
|
|
474
|
-
mockApiClient.get = vi.fn().mockResolvedValue({
|
|
475
|
-
count: 1,
|
|
476
|
-
next: null,
|
|
477
|
-
previous: null,
|
|
478
|
-
results: [
|
|
479
|
-
{
|
|
480
|
-
id: "SlackCLIAPI@1.30.0",
|
|
481
|
-
name: "Slack",
|
|
482
|
-
slug: "slack",
|
|
483
|
-
key: "SlackCLIAPI",
|
|
484
|
-
version: "1.30.0",
|
|
485
|
-
},
|
|
486
|
-
],
|
|
487
|
-
});
|
|
488
|
-
const sdk = createSdk({ manifest })
|
|
489
|
-
.addPlugin(apiPlugin)
|
|
490
|
-
.addPlugin(manifestPlugin);
|
|
491
|
-
const context = sdk.getContext();
|
|
492
|
-
// Input version should take precedence over both manifest (1.21.1) and API (1.30.0)
|
|
493
|
-
const resolved = await context.resolveAppKeys({
|
|
494
|
-
appKeys: ["slack@1.2.3"],
|
|
495
|
-
});
|
|
496
|
-
expect(resolved).toHaveLength(1);
|
|
497
|
-
expect(resolved[0]).toEqual({
|
|
498
|
-
slug: "slack",
|
|
499
|
-
implementationName: "SlackCLIAPI",
|
|
500
|
-
version: "1.2.3", // Should use input version, not manifest or API
|
|
501
|
-
lookupAppKey: "slack",
|
|
502
|
-
});
|
|
503
|
-
});
|
|
504
|
-
it("should always use version from input when specified (implementationName@version)", async () => {
|
|
505
|
-
const manifest = {
|
|
506
|
-
apps: {
|
|
507
|
-
SlackCLIAPI: { implementationName: "SlackCLIAPI", version: "1.21.1" },
|
|
508
|
-
},
|
|
509
|
-
};
|
|
510
|
-
const sdk = createSdk({ manifest })
|
|
511
|
-
.addPlugin(apiPlugin)
|
|
512
|
-
.addPlugin(manifestPlugin);
|
|
513
|
-
const context = sdk.getContext();
|
|
514
|
-
// Input version should take precedence over manifest version
|
|
515
|
-
const resolved = await context.resolveAppKeys({
|
|
516
|
-
appKeys: ["SlackCLIAPI@1.2.3"],
|
|
517
|
-
});
|
|
518
|
-
expect(resolved).toHaveLength(1);
|
|
519
|
-
expect(resolved[0]).toEqual({
|
|
520
|
-
implementationName: "SlackCLIAPI",
|
|
521
|
-
version: "1.2.3", // Should use input version, not manifest version
|
|
522
|
-
lookupAppKey: "SlackCLIAPI",
|
|
523
|
-
});
|
|
524
|
-
});
|
|
525
|
-
});
|
|
526
|
-
});
|
|
527
|
-
describe("readManifestFromFile", () => {
|
|
528
|
-
const mockManifestContent = JSON.stringify({
|
|
529
|
-
apps: {
|
|
530
|
-
slack: {
|
|
531
|
-
implementationName: "SlackCLIAPI",
|
|
532
|
-
version: "1.21.1",
|
|
533
|
-
},
|
|
534
|
-
"google-sheets": {
|
|
535
|
-
implementationName: "GoogleSheetsCLIAPI",
|
|
536
|
-
version: "2.0.0",
|
|
537
|
-
},
|
|
538
|
-
},
|
|
539
|
-
});
|
|
540
|
-
beforeEach(() => {
|
|
541
|
-
vi.clearAllMocks();
|
|
542
|
-
});
|
|
543
|
-
it("should read and parse manifest from file", async () => {
|
|
544
|
-
mockReadFile.mockResolvedValue(mockManifestContent);
|
|
545
|
-
const result = await readManifestFromFile("manifest.json");
|
|
546
|
-
expect(mockResolve).toHaveBeenCalledWith("manifest.json");
|
|
547
|
-
expect(mockReadFile).toHaveBeenCalledWith("/resolved/manifest.json");
|
|
548
|
-
expect(result).toEqual({
|
|
549
|
-
apps: {
|
|
550
|
-
slack: {
|
|
551
|
-
implementationName: "SlackCLIAPI",
|
|
552
|
-
version: "1.21.1",
|
|
553
|
-
},
|
|
554
|
-
"google-sheets": {
|
|
555
|
-
implementationName: "GoogleSheetsCLIAPI",
|
|
556
|
-
version: "2.0.0",
|
|
557
|
-
},
|
|
558
|
-
},
|
|
559
|
-
});
|
|
560
|
-
});
|
|
561
|
-
it("should handle file read errors", async () => {
|
|
562
|
-
mockReadFile.mockRejectedValue(new Error("File not found"));
|
|
563
|
-
const result = await readManifestFromFile("nonexistent.json");
|
|
564
|
-
expect(result).toBeNull();
|
|
565
|
-
});
|
|
566
|
-
it("should handle invalid JSON content", async () => {
|
|
567
|
-
mockReadFile.mockResolvedValue("invalid json");
|
|
568
|
-
const result = await readManifestFromFile("invalid.json");
|
|
569
|
-
expect(result).toBeNull();
|
|
570
|
-
});
|
|
571
|
-
describe("getPreferredManifestEntryKey", () => {
|
|
572
|
-
let mockApi;
|
|
573
|
-
beforeEach(() => {
|
|
574
|
-
mockApi = {
|
|
575
|
-
get: vi.fn(),
|
|
576
|
-
};
|
|
577
|
-
});
|
|
578
|
-
it("should prefer slug when available", async () => {
|
|
579
|
-
const result = await getPreferredManifestEntryKey({
|
|
580
|
-
appKey: "slack",
|
|
581
|
-
api: mockApi,
|
|
582
|
-
});
|
|
583
|
-
expect(result).toBe("slack");
|
|
584
|
-
});
|
|
585
|
-
it("should look up slug for implementation name", async () => {
|
|
586
|
-
// Mock API response for implementation name lookup
|
|
587
|
-
mockApi.get = vi.fn().mockResolvedValueOnce({
|
|
588
|
-
results: [
|
|
589
|
-
{
|
|
590
|
-
key: "SlackCLIAPI",
|
|
591
|
-
slug: "slack",
|
|
592
|
-
version: "1.0.0",
|
|
593
|
-
current_implementation_id: "SlackCLIAPI@1.0.0",
|
|
594
|
-
},
|
|
595
|
-
],
|
|
596
|
-
next: null,
|
|
597
|
-
});
|
|
598
|
-
const result = await getPreferredManifestEntryKey({
|
|
599
|
-
appKey: "SlackCLIAPI",
|
|
600
|
-
api: mockApi,
|
|
601
|
-
});
|
|
602
|
-
expect(result).toBe("slack");
|
|
603
|
-
expect(mockApi.get).toHaveBeenCalledWith("/zapier/api/v4/implementations-meta/lookup/", {
|
|
604
|
-
searchParams: { selected_apis: "SlackCLIAPI" },
|
|
605
|
-
});
|
|
606
|
-
});
|
|
607
|
-
it("should fall back to implementation name if slug lookup fails", async () => {
|
|
608
|
-
// Mock API to return empty results
|
|
609
|
-
mockApi.get = vi.fn().mockResolvedValueOnce({
|
|
610
|
-
results: [],
|
|
611
|
-
next: null,
|
|
612
|
-
});
|
|
613
|
-
const result = await getPreferredManifestEntryKey({
|
|
614
|
-
appKey: "SlackCLIAPI",
|
|
615
|
-
api: mockApi,
|
|
616
|
-
});
|
|
617
|
-
expect(result).toBe("SlackCLIAPI");
|
|
618
|
-
});
|
|
619
|
-
it("should fall back to original key if no slug or implementation name", async () => {
|
|
620
|
-
const result = await getPreferredManifestEntryKey({
|
|
621
|
-
appKey: "some-random-key",
|
|
622
|
-
api: mockApi,
|
|
623
|
-
});
|
|
624
|
-
expect(result).toBe("some-random-key");
|
|
625
|
-
});
|
|
626
|
-
});
|
|
627
|
-
describe("Action management", () => {
|
|
628
|
-
const mockManifest = {
|
|
629
|
-
apps: {
|
|
630
|
-
slack: {
|
|
631
|
-
implementationName: "SlackCLIAPI",
|
|
632
|
-
version: "1.21.1",
|
|
633
|
-
},
|
|
634
|
-
},
|
|
635
|
-
};
|
|
636
|
-
let mockApiClient;
|
|
637
|
-
beforeEach(() => {
|
|
638
|
-
vi.clearAllMocks();
|
|
639
|
-
vi.spyOn(console, "warn").mockImplementation(() => { });
|
|
640
|
-
mockApiClient = {
|
|
641
|
-
get: vi.fn(),
|
|
642
|
-
};
|
|
643
|
-
});
|
|
644
|
-
afterEach(() => {
|
|
645
|
-
vi.restoreAllMocks();
|
|
646
|
-
});
|
|
647
|
-
const apiPlugin = () => ({
|
|
648
|
-
context: {
|
|
649
|
-
api: mockApiClient,
|
|
650
|
-
},
|
|
651
|
-
});
|
|
652
|
-
function createTestSdk(options = {}) {
|
|
653
|
-
return createSdk(options).addPlugin(apiPlugin).addPlugin(manifestPlugin);
|
|
654
|
-
}
|
|
655
|
-
describe("findActionEntry", () => {
|
|
656
|
-
it("should find an existing action by name", () => {
|
|
657
|
-
const manifest = {
|
|
658
|
-
apps: mockManifest.apps,
|
|
659
|
-
actions: {
|
|
660
|
-
"weekly-report": {
|
|
661
|
-
appKey: "slack",
|
|
662
|
-
actionKey: "post_message",
|
|
663
|
-
actionType: "write",
|
|
664
|
-
authenticationId: 123,
|
|
665
|
-
inputs: { channel: "#general" },
|
|
666
|
-
schema: {},
|
|
667
|
-
createdAt: "2025-11-18T12:00:00.000Z",
|
|
668
|
-
},
|
|
669
|
-
},
|
|
670
|
-
};
|
|
671
|
-
const sdk = createTestSdk({ manifest });
|
|
672
|
-
const context = sdk.getContext();
|
|
673
|
-
const action = context.findActionEntry({
|
|
674
|
-
name: "weekly-report",
|
|
675
|
-
manifest,
|
|
676
|
-
});
|
|
677
|
-
expect(action).toEqual({
|
|
678
|
-
appKey: "slack",
|
|
679
|
-
actionKey: "post_message",
|
|
680
|
-
actionType: "write",
|
|
681
|
-
authenticationId: 123,
|
|
682
|
-
inputs: { channel: "#general" },
|
|
683
|
-
schema: {},
|
|
684
|
-
createdAt: "2025-11-18T12:00:00.000Z",
|
|
685
|
-
});
|
|
686
|
-
});
|
|
687
|
-
it("should return null for non-existent action", () => {
|
|
688
|
-
const manifest = {
|
|
689
|
-
apps: mockManifest.apps,
|
|
690
|
-
actions: {},
|
|
691
|
-
};
|
|
692
|
-
const sdk = createTestSdk({ manifest });
|
|
693
|
-
const context = sdk.getContext();
|
|
694
|
-
const action = context.findActionEntry({
|
|
695
|
-
name: "non-existent",
|
|
696
|
-
manifest,
|
|
697
|
-
});
|
|
698
|
-
expect(action).toBeNull();
|
|
699
|
-
});
|
|
700
|
-
it("should return null when manifest has no actions section", () => {
|
|
701
|
-
const manifest = {
|
|
702
|
-
apps: mockManifest.apps,
|
|
703
|
-
};
|
|
704
|
-
const sdk = createTestSdk({ manifest });
|
|
705
|
-
const context = sdk.getContext();
|
|
706
|
-
const action = context.findActionEntry({
|
|
707
|
-
name: "any-action",
|
|
708
|
-
manifest,
|
|
709
|
-
});
|
|
710
|
-
expect(action).toBeNull();
|
|
711
|
-
});
|
|
712
|
-
});
|
|
713
|
-
describe("hasActionEntry", () => {
|
|
714
|
-
it("should return true for existing action", () => {
|
|
715
|
-
const manifest = {
|
|
716
|
-
apps: mockManifest.apps,
|
|
717
|
-
actions: {
|
|
718
|
-
"weekly-report": {
|
|
719
|
-
appKey: "slack",
|
|
720
|
-
actionKey: "post_message",
|
|
721
|
-
actionType: "write",
|
|
722
|
-
authenticationId: 123,
|
|
723
|
-
inputs: {},
|
|
724
|
-
schema: {},
|
|
725
|
-
createdAt: "2025-11-18T12:00:00.000Z",
|
|
726
|
-
},
|
|
727
|
-
},
|
|
728
|
-
};
|
|
729
|
-
const sdk = createTestSdk({ manifest });
|
|
730
|
-
const context = sdk.getContext();
|
|
731
|
-
const exists = context.hasActionEntry({
|
|
732
|
-
name: "weekly-report",
|
|
733
|
-
manifest,
|
|
734
|
-
});
|
|
735
|
-
expect(exists).toBe(true);
|
|
736
|
-
});
|
|
737
|
-
it("should return false for non-existent action", () => {
|
|
738
|
-
const manifest = {
|
|
739
|
-
apps: mockManifest.apps,
|
|
740
|
-
actions: {},
|
|
741
|
-
};
|
|
742
|
-
const sdk = createTestSdk({ manifest });
|
|
743
|
-
const context = sdk.getContext();
|
|
744
|
-
const exists = context.hasActionEntry({
|
|
745
|
-
name: "non-existent",
|
|
746
|
-
manifest,
|
|
747
|
-
});
|
|
748
|
-
expect(exists).toBe(false);
|
|
749
|
-
});
|
|
750
|
-
it("should return false when manifest has no actions section", () => {
|
|
751
|
-
const manifest = {
|
|
752
|
-
apps: mockManifest.apps,
|
|
753
|
-
};
|
|
754
|
-
const sdk = createTestSdk({ manifest });
|
|
755
|
-
const context = sdk.getContext();
|
|
756
|
-
const exists = context.hasActionEntry({ name: "any-action", manifest });
|
|
757
|
-
expect(exists).toBe(false);
|
|
758
|
-
});
|
|
759
|
-
});
|
|
760
|
-
describe("listActionEntries", () => {
|
|
761
|
-
it("should return all actions as [name, entry] tuples", async () => {
|
|
762
|
-
const mockManifestContent = JSON.stringify({
|
|
763
|
-
apps: mockManifest.apps,
|
|
764
|
-
actions: {
|
|
765
|
-
"weekly-report": {
|
|
766
|
-
appKey: "slack",
|
|
767
|
-
actionKey: "post_message",
|
|
768
|
-
actionType: "write",
|
|
769
|
-
authenticationId: 123,
|
|
770
|
-
inputs: { channel: "#general" },
|
|
771
|
-
schema: {},
|
|
772
|
-
createdAt: "2025-11-18T12:00:00.000Z",
|
|
773
|
-
},
|
|
774
|
-
"daily-summary": {
|
|
775
|
-
appKey: "slack",
|
|
776
|
-
actionKey: "post_message",
|
|
777
|
-
actionType: "write",
|
|
778
|
-
authenticationId: 123,
|
|
779
|
-
inputs: { channel: "#daily" },
|
|
780
|
-
schema: {},
|
|
781
|
-
createdAt: "2025-11-18T13:00:00.000Z",
|
|
782
|
-
},
|
|
783
|
-
},
|
|
784
|
-
});
|
|
785
|
-
mockReadFile.mockResolvedValue(mockManifestContent);
|
|
786
|
-
const sdk = createTestSdk({ manifestPath: ".zapierrc" });
|
|
787
|
-
const context = sdk.getContext();
|
|
788
|
-
const actions = await context.listActionEntries({
|
|
789
|
-
configPath: ".zapierrc",
|
|
790
|
-
});
|
|
791
|
-
expect(actions).toHaveLength(2);
|
|
792
|
-
expect(actions).toEqual([
|
|
793
|
-
[
|
|
794
|
-
"weekly-report",
|
|
795
|
-
{
|
|
796
|
-
appKey: "slack",
|
|
797
|
-
actionKey: "post_message",
|
|
798
|
-
actionType: "write",
|
|
799
|
-
authenticationId: 123,
|
|
800
|
-
inputs: { channel: "#general" },
|
|
801
|
-
schema: {},
|
|
802
|
-
createdAt: "2025-11-18T12:00:00.000Z",
|
|
803
|
-
},
|
|
804
|
-
],
|
|
805
|
-
[
|
|
806
|
-
"daily-summary",
|
|
807
|
-
{
|
|
808
|
-
appKey: "slack",
|
|
809
|
-
actionKey: "post_message",
|
|
810
|
-
actionType: "write",
|
|
811
|
-
authenticationId: 123,
|
|
812
|
-
inputs: { channel: "#daily" },
|
|
813
|
-
schema: {},
|
|
814
|
-
createdAt: "2025-11-18T13:00:00.000Z",
|
|
815
|
-
},
|
|
816
|
-
],
|
|
817
|
-
]);
|
|
818
|
-
});
|
|
819
|
-
it("should return empty array when no actions exist", async () => {
|
|
820
|
-
const mockManifestContent = JSON.stringify({
|
|
821
|
-
apps: mockManifest.apps,
|
|
822
|
-
});
|
|
823
|
-
mockReadFile.mockResolvedValue(mockManifestContent);
|
|
824
|
-
const sdk = createTestSdk({ manifestPath: ".zapierrc" });
|
|
825
|
-
const context = sdk.getContext();
|
|
826
|
-
const actions = await context.listActionEntries({
|
|
827
|
-
configPath: ".zapierrc",
|
|
828
|
-
});
|
|
829
|
-
expect(actions).toEqual([]);
|
|
830
|
-
});
|
|
831
|
-
it("should use default configPath when not provided", async () => {
|
|
832
|
-
const mockManifestContent = JSON.stringify({
|
|
833
|
-
apps: mockManifest.apps,
|
|
834
|
-
actions: {},
|
|
835
|
-
});
|
|
836
|
-
mockReadFile.mockResolvedValue(mockManifestContent);
|
|
837
|
-
const sdk = createTestSdk();
|
|
838
|
-
const context = sdk.getContext();
|
|
839
|
-
await context.listActionEntries();
|
|
840
|
-
expect(mockResolve).toHaveBeenCalledWith(".zapierrc");
|
|
841
|
-
});
|
|
842
|
-
});
|
|
843
|
-
describe("addActionEntry", () => {
|
|
844
|
-
it("should successfully add a new action", async () => {
|
|
845
|
-
const mockManifestContent = JSON.stringify({
|
|
846
|
-
apps: mockManifest.apps,
|
|
847
|
-
});
|
|
848
|
-
mockReadFile.mockResolvedValue(mockManifestContent);
|
|
849
|
-
const sdk = createTestSdk({ manifestPath: ".zapierrc" });
|
|
850
|
-
const context = sdk.getContext();
|
|
851
|
-
const entry = {
|
|
852
|
-
appKey: "slack",
|
|
853
|
-
actionKey: "post_message",
|
|
854
|
-
actionType: "write",
|
|
855
|
-
authenticationId: 123,
|
|
856
|
-
inputs: { channel: "#general" },
|
|
857
|
-
schema: { type: "object" },
|
|
858
|
-
createdAt: "2025-11-18T12:00:00.000Z",
|
|
859
|
-
};
|
|
860
|
-
const { name, entry: returnedEntry, manifest: updatedManifest, } = await context.addActionEntry({
|
|
861
|
-
name: "weekly-report",
|
|
862
|
-
entry,
|
|
863
|
-
configPath: ".zapierrc",
|
|
864
|
-
});
|
|
865
|
-
expect(name).toBe("weekly-report");
|
|
866
|
-
expect(returnedEntry).toEqual(entry);
|
|
867
|
-
expect(updatedManifest.actions).toEqual({
|
|
868
|
-
"weekly-report": entry,
|
|
869
|
-
});
|
|
870
|
-
});
|
|
871
|
-
it("should throw error when action name already exists", async () => {
|
|
872
|
-
const mockManifestContent = JSON.stringify({
|
|
873
|
-
apps: mockManifest.apps,
|
|
874
|
-
actions: {
|
|
875
|
-
"weekly-report": {
|
|
876
|
-
appKey: "slack",
|
|
877
|
-
actionKey: "post_message",
|
|
878
|
-
actionType: "write",
|
|
879
|
-
authenticationId: 123,
|
|
880
|
-
inputs: {},
|
|
881
|
-
schema: {},
|
|
882
|
-
createdAt: "2025-11-18T12:00:00.000Z",
|
|
883
|
-
},
|
|
884
|
-
},
|
|
885
|
-
});
|
|
886
|
-
mockReadFile.mockResolvedValue(mockManifestContent);
|
|
887
|
-
const sdk = createTestSdk({ manifestPath: ".zapierrc" });
|
|
888
|
-
const context = sdk.getContext();
|
|
889
|
-
const entry = {
|
|
890
|
-
appKey: "slack",
|
|
891
|
-
actionKey: "post_message",
|
|
892
|
-
actionType: "write",
|
|
893
|
-
authenticationId: 123,
|
|
894
|
-
inputs: {},
|
|
895
|
-
schema: {},
|
|
896
|
-
createdAt: "2025-11-18T13:00:00.000Z",
|
|
897
|
-
};
|
|
898
|
-
await expect(context.addActionEntry({
|
|
899
|
-
name: "weekly-report",
|
|
900
|
-
entry,
|
|
901
|
-
configPath: ".zapierrc",
|
|
902
|
-
})).rejects.toThrow('Action "weekly-report" already exists. Please choose a different name or remove the existing action first.');
|
|
903
|
-
});
|
|
904
|
-
it("should allow duplicate name with skipWrite option", async () => {
|
|
905
|
-
const mockManifestContent = JSON.stringify({
|
|
906
|
-
apps: mockManifest.apps,
|
|
907
|
-
actions: {
|
|
908
|
-
"weekly-report": {
|
|
909
|
-
appKey: "slack",
|
|
910
|
-
actionKey: "post_message",
|
|
911
|
-
actionType: "write",
|
|
912
|
-
authenticationId: 123,
|
|
913
|
-
inputs: {},
|
|
914
|
-
schema: {},
|
|
915
|
-
createdAt: "2025-11-18T12:00:00.000Z",
|
|
916
|
-
},
|
|
917
|
-
},
|
|
918
|
-
});
|
|
919
|
-
mockReadFile.mockResolvedValue(mockManifestContent);
|
|
920
|
-
const sdk = createTestSdk({ manifestPath: ".zapierrc" });
|
|
921
|
-
const context = sdk.getContext();
|
|
922
|
-
const entry = {
|
|
923
|
-
appKey: "slack",
|
|
924
|
-
actionKey: "post_message",
|
|
925
|
-
actionType: "write",
|
|
926
|
-
authenticationId: 456,
|
|
927
|
-
inputs: {},
|
|
928
|
-
schema: {},
|
|
929
|
-
createdAt: "2025-11-18T13:00:00.000Z",
|
|
930
|
-
};
|
|
931
|
-
const { name, entry: returnedEntry } = await context.addActionEntry({
|
|
932
|
-
name: "weekly-report",
|
|
933
|
-
entry,
|
|
934
|
-
configPath: ".zapierrc",
|
|
935
|
-
skipWrite: true,
|
|
936
|
-
});
|
|
937
|
-
expect(name).toBe("weekly-report");
|
|
938
|
-
expect(returnedEntry).toEqual(entry);
|
|
939
|
-
});
|
|
940
|
-
it("should create actions section if it doesn't exist", async () => {
|
|
941
|
-
const mockManifestContent = JSON.stringify({
|
|
942
|
-
apps: mockManifest.apps,
|
|
943
|
-
});
|
|
944
|
-
mockReadFile.mockResolvedValue(mockManifestContent);
|
|
945
|
-
const sdk = createTestSdk({ manifestPath: ".zapierrc" });
|
|
946
|
-
const context = sdk.getContext();
|
|
947
|
-
const entry = {
|
|
948
|
-
appKey: "slack",
|
|
949
|
-
actionKey: "post_message",
|
|
950
|
-
actionType: "write",
|
|
951
|
-
authenticationId: 123,
|
|
952
|
-
inputs: {},
|
|
953
|
-
schema: {},
|
|
954
|
-
createdAt: "2025-11-18T12:00:00.000Z",
|
|
955
|
-
};
|
|
956
|
-
const { manifest: updatedManifest } = await context.addActionEntry({
|
|
957
|
-
name: "first-action",
|
|
958
|
-
entry,
|
|
959
|
-
configPath: ".zapierrc",
|
|
960
|
-
});
|
|
961
|
-
expect(updatedManifest.actions).toBeDefined();
|
|
962
|
-
expect(updatedManifest.actions).toEqual({
|
|
963
|
-
"first-action": entry,
|
|
964
|
-
});
|
|
965
|
-
});
|
|
966
|
-
});
|
|
967
|
-
describe("deleteActionEntry", () => {
|
|
968
|
-
it("should successfully delete an existing action", async () => {
|
|
969
|
-
const mockManifestContent = JSON.stringify({
|
|
970
|
-
apps: mockManifest.apps,
|
|
971
|
-
actions: {
|
|
972
|
-
"weekly-report": {
|
|
973
|
-
appKey: "slack",
|
|
974
|
-
actionKey: "post_message",
|
|
975
|
-
actionType: "write",
|
|
976
|
-
authenticationId: 123,
|
|
977
|
-
inputs: {},
|
|
978
|
-
schema: {},
|
|
979
|
-
createdAt: "2025-11-18T12:00:00.000Z",
|
|
980
|
-
},
|
|
981
|
-
"daily-summary": {
|
|
982
|
-
appKey: "slack",
|
|
983
|
-
actionKey: "post_message",
|
|
984
|
-
actionType: "write",
|
|
985
|
-
authenticationId: 123,
|
|
986
|
-
inputs: {},
|
|
987
|
-
schema: {},
|
|
988
|
-
createdAt: "2025-11-18T13:00:00.000Z",
|
|
989
|
-
},
|
|
990
|
-
},
|
|
991
|
-
});
|
|
992
|
-
mockReadFile.mockResolvedValue(mockManifestContent);
|
|
993
|
-
const sdk = createTestSdk({ manifestPath: ".zapierrc" });
|
|
994
|
-
const context = sdk.getContext();
|
|
995
|
-
const updatedManifest = await context.deleteActionEntry({
|
|
996
|
-
name: "weekly-report",
|
|
997
|
-
configPath: ".zapierrc",
|
|
998
|
-
});
|
|
999
|
-
expect(updatedManifest.actions).toEqual({
|
|
1000
|
-
"daily-summary": {
|
|
1001
|
-
appKey: "slack",
|
|
1002
|
-
actionKey: "post_message",
|
|
1003
|
-
actionType: "write",
|
|
1004
|
-
authenticationId: 123,
|
|
1005
|
-
inputs: {},
|
|
1006
|
-
schema: {},
|
|
1007
|
-
createdAt: "2025-11-18T13:00:00.000Z",
|
|
1008
|
-
},
|
|
1009
|
-
});
|
|
1010
|
-
expect(updatedManifest.actions?.["weekly-report"]).toBeUndefined();
|
|
1011
|
-
});
|
|
1012
|
-
it("should throw error when action does not exist", async () => {
|
|
1013
|
-
const mockManifestContent = JSON.stringify({
|
|
1014
|
-
apps: mockManifest.apps,
|
|
1015
|
-
actions: {},
|
|
1016
|
-
});
|
|
1017
|
-
mockReadFile.mockResolvedValue(mockManifestContent);
|
|
1018
|
-
const sdk = createTestSdk({ manifestPath: ".zapierrc" });
|
|
1019
|
-
const context = sdk.getContext();
|
|
1020
|
-
await expect(context.deleteActionEntry({
|
|
1021
|
-
name: "non-existent",
|
|
1022
|
-
configPath: ".zapierrc",
|
|
1023
|
-
})).rejects.toThrow('Action "non-existent" does not exist.');
|
|
1024
|
-
});
|
|
1025
|
-
it("should work with skipWrite option", async () => {
|
|
1026
|
-
const mockManifestContent = JSON.stringify({
|
|
1027
|
-
apps: mockManifest.apps,
|
|
1028
|
-
actions: {
|
|
1029
|
-
"weekly-report": {
|
|
1030
|
-
appKey: "slack",
|
|
1031
|
-
actionKey: "post_message",
|
|
1032
|
-
actionType: "write",
|
|
1033
|
-
authenticationId: 123,
|
|
1034
|
-
inputs: {},
|
|
1035
|
-
schema: {},
|
|
1036
|
-
createdAt: "2025-11-18T12:00:00.000Z",
|
|
1037
|
-
},
|
|
1038
|
-
},
|
|
1039
|
-
});
|
|
1040
|
-
mockReadFile.mockResolvedValue(mockManifestContent);
|
|
1041
|
-
const sdk = createTestSdk({ manifestPath: ".zapierrc" });
|
|
1042
|
-
const context = sdk.getContext();
|
|
1043
|
-
const updatedManifest = await context.deleteActionEntry({
|
|
1044
|
-
name: "weekly-report",
|
|
1045
|
-
configPath: ".zapierrc",
|
|
1046
|
-
skipWrite: true,
|
|
1047
|
-
});
|
|
1048
|
-
expect(updatedManifest.actions).toEqual({});
|
|
1049
|
-
});
|
|
1050
|
-
it("should handle deleting the last action", async () => {
|
|
1051
|
-
const mockManifestContent = JSON.stringify({
|
|
1052
|
-
apps: mockManifest.apps,
|
|
1053
|
-
actions: {
|
|
1054
|
-
"only-action": {
|
|
1055
|
-
appKey: "slack",
|
|
1056
|
-
actionKey: "post_message",
|
|
1057
|
-
actionType: "write",
|
|
1058
|
-
authenticationId: 123,
|
|
1059
|
-
inputs: {},
|
|
1060
|
-
schema: {},
|
|
1061
|
-
createdAt: "2025-11-18T12:00:00.000Z",
|
|
1062
|
-
},
|
|
1063
|
-
},
|
|
1064
|
-
});
|
|
1065
|
-
mockReadFile.mockResolvedValue(mockManifestContent);
|
|
1066
|
-
const sdk = createTestSdk({ manifestPath: ".zapierrc" });
|
|
1067
|
-
const context = sdk.getContext();
|
|
1068
|
-
const updatedManifest = await context.deleteActionEntry({
|
|
1069
|
-
name: "only-action",
|
|
1070
|
-
configPath: ".zapierrc",
|
|
1071
|
-
});
|
|
1072
|
-
expect(updatedManifest.actions).toEqual({});
|
|
1073
|
-
});
|
|
1074
|
-
});
|
|
1075
|
-
describe("action CRUD integration", () => {
|
|
1076
|
-
it("should support full CRUD workflow", async () => {
|
|
1077
|
-
const mockManifestContent = JSON.stringify({
|
|
1078
|
-
apps: mockManifest.apps,
|
|
1079
|
-
});
|
|
1080
|
-
mockReadFile.mockResolvedValue(mockManifestContent);
|
|
1081
|
-
const sdk = createTestSdk({ manifestPath: ".zapierrc" });
|
|
1082
|
-
const context = sdk.getContext();
|
|
1083
|
-
// Create first action
|
|
1084
|
-
const entry1 = {
|
|
1085
|
-
appKey: "slack",
|
|
1086
|
-
actionKey: "post_message",
|
|
1087
|
-
actionType: "write",
|
|
1088
|
-
authenticationId: 123,
|
|
1089
|
-
inputs: { channel: "#general" },
|
|
1090
|
-
schema: {},
|
|
1091
|
-
createdAt: "2025-11-18T12:00:00.000Z",
|
|
1092
|
-
};
|
|
1093
|
-
const { manifest: manifest1 } = await context.addActionEntry({
|
|
1094
|
-
name: "action-1",
|
|
1095
|
-
entry: entry1,
|
|
1096
|
-
skipWrite: true,
|
|
1097
|
-
});
|
|
1098
|
-
// Create second action
|
|
1099
|
-
const entry2 = {
|
|
1100
|
-
appKey: "slack",
|
|
1101
|
-
actionKey: "post_message",
|
|
1102
|
-
actionType: "write",
|
|
1103
|
-
authenticationId: 123,
|
|
1104
|
-
inputs: { channel: "#daily" },
|
|
1105
|
-
schema: {},
|
|
1106
|
-
createdAt: "2025-11-18T13:00:00.000Z",
|
|
1107
|
-
};
|
|
1108
|
-
const { manifest: manifest2 } = await context.addActionEntry({
|
|
1109
|
-
name: "action-2",
|
|
1110
|
-
entry: entry2,
|
|
1111
|
-
manifest: manifest1,
|
|
1112
|
-
skipWrite: true,
|
|
1113
|
-
});
|
|
1114
|
-
// Verify both actions exist
|
|
1115
|
-
expect(context.hasActionEntry({ name: "action-1", manifest: manifest2 })).toBe(true);
|
|
1116
|
-
expect(context.hasActionEntry({ name: "action-2", manifest: manifest2 })).toBe(true);
|
|
1117
|
-
// Find action
|
|
1118
|
-
const foundAction = context.findActionEntry({
|
|
1119
|
-
name: "action-1",
|
|
1120
|
-
manifest: manifest2,
|
|
1121
|
-
});
|
|
1122
|
-
expect(foundAction).toEqual(entry1);
|
|
1123
|
-
// List actions
|
|
1124
|
-
mockReadFile.mockResolvedValue(JSON.stringify(manifest2));
|
|
1125
|
-
const actions = await context.listActionEntries({
|
|
1126
|
-
configPath: ".zapierrc",
|
|
1127
|
-
});
|
|
1128
|
-
expect(actions).toHaveLength(2);
|
|
1129
|
-
// Delete action
|
|
1130
|
-
const manifest3 = await context.deleteActionEntry({
|
|
1131
|
-
name: "action-1",
|
|
1132
|
-
skipWrite: true,
|
|
1133
|
-
});
|
|
1134
|
-
expect(context.hasActionEntry({ name: "action-1", manifest: manifest3 })).toBe(false);
|
|
1135
|
-
expect(context.hasActionEntry({ name: "action-2", manifest: manifest3 })).toBe(true);
|
|
1136
|
-
});
|
|
1137
|
-
});
|
|
1138
|
-
});
|
|
1139
|
-
});
|