@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,581 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Tests for Event Emission Plugin
|
|
3
|
-
*/
|
|
4
|
-
import { describe, it, expect, vi, beforeEach } from "vitest";
|
|
5
|
-
import { eventEmissionPlugin } from "./index";
|
|
6
|
-
import { createTransport } from "./transport";
|
|
7
|
-
// Mock transport for testing
|
|
8
|
-
const mockTransport = {
|
|
9
|
-
emit: vi.fn().mockResolvedValue(undefined),
|
|
10
|
-
close: vi.fn().mockResolvedValue(undefined),
|
|
11
|
-
};
|
|
12
|
-
vi.mock("./transport", () => ({
|
|
13
|
-
createTransport: vi.fn(() => mockTransport),
|
|
14
|
-
}));
|
|
15
|
-
// Mock CLI login package - default to returning null context
|
|
16
|
-
const mockGetToken = vi.fn().mockResolvedValue(undefined);
|
|
17
|
-
vi.mock("@zapier/zapier-sdk-cli-login", () => ({
|
|
18
|
-
getToken: mockGetToken,
|
|
19
|
-
}));
|
|
20
|
-
describe("eventEmissionPlugin", () => {
|
|
21
|
-
beforeEach(() => {
|
|
22
|
-
vi.clearAllMocks();
|
|
23
|
-
// Reset to default behavior - no token available
|
|
24
|
-
mockGetToken.mockResolvedValue(undefined);
|
|
25
|
-
});
|
|
26
|
-
it("should create plugin with default configuration", () => {
|
|
27
|
-
const plugin = eventEmissionPlugin({
|
|
28
|
-
sdk: {},
|
|
29
|
-
context: {
|
|
30
|
-
meta: {},
|
|
31
|
-
options: {},
|
|
32
|
-
},
|
|
33
|
-
});
|
|
34
|
-
expect(plugin.context.eventEmission).toBeDefined();
|
|
35
|
-
expect(plugin.context.eventEmission.emit).toBeDefined();
|
|
36
|
-
expect(plugin.context.eventEmission.transport).toBeDefined();
|
|
37
|
-
expect(plugin.context.eventEmission.config).toBeDefined();
|
|
38
|
-
});
|
|
39
|
-
it("should create noop implementations when disabled", () => {
|
|
40
|
-
const config = { enabled: false };
|
|
41
|
-
const plugin = eventEmissionPlugin({
|
|
42
|
-
sdk: {},
|
|
43
|
-
context: {
|
|
44
|
-
meta: {},
|
|
45
|
-
options: { eventEmission: config },
|
|
46
|
-
},
|
|
47
|
-
});
|
|
48
|
-
// Should not emit any events when disabled
|
|
49
|
-
plugin.context.eventEmission.emit("platform.sdk.TestEvent", {
|
|
50
|
-
test_event: "data",
|
|
51
|
-
});
|
|
52
|
-
expect(mockTransport.emit).not.toHaveBeenCalled();
|
|
53
|
-
});
|
|
54
|
-
it("should emit events using generic emit method", async () => {
|
|
55
|
-
const plugin = eventEmissionPlugin({
|
|
56
|
-
sdk: {},
|
|
57
|
-
context: {
|
|
58
|
-
meta: {},
|
|
59
|
-
options: {
|
|
60
|
-
eventEmission: {
|
|
61
|
-
enabled: true,
|
|
62
|
-
transport: { type: "console" },
|
|
63
|
-
},
|
|
64
|
-
},
|
|
65
|
-
},
|
|
66
|
-
});
|
|
67
|
-
const testEvent = {
|
|
68
|
-
test_data: "example",
|
|
69
|
-
value: 123,
|
|
70
|
-
};
|
|
71
|
-
const testSubject = "test.event.TestEvent";
|
|
72
|
-
plugin.context.eventEmission.emit(testSubject, testEvent);
|
|
73
|
-
// Give async emission time to complete
|
|
74
|
-
await new Promise((resolve) => setTimeout(resolve, 50));
|
|
75
|
-
// The event will be enriched with user context (null values)
|
|
76
|
-
expect(mockTransport.emit).toHaveBeenCalledWith(testSubject, {
|
|
77
|
-
...testEvent,
|
|
78
|
-
customuser_id: null,
|
|
79
|
-
account_id: null,
|
|
80
|
-
});
|
|
81
|
-
});
|
|
82
|
-
it("should handle transport creation failures silently", () => {
|
|
83
|
-
// Mock createTransport to throw an error
|
|
84
|
-
vi.mocked(createTransport).mockImplementationOnce(() => {
|
|
85
|
-
throw new Error("Transport creation failed");
|
|
86
|
-
});
|
|
87
|
-
expect(() => {
|
|
88
|
-
eventEmissionPlugin({
|
|
89
|
-
sdk: {},
|
|
90
|
-
context: {
|
|
91
|
-
meta: {},
|
|
92
|
-
options: {
|
|
93
|
-
eventEmission: {
|
|
94
|
-
enabled: true,
|
|
95
|
-
transport: { type: "http", endpoint: "invalid-url" },
|
|
96
|
-
},
|
|
97
|
-
},
|
|
98
|
-
},
|
|
99
|
-
});
|
|
100
|
-
}).not.toThrow();
|
|
101
|
-
});
|
|
102
|
-
it("should handle event emission failures silently", async () => {
|
|
103
|
-
// Mock transport to throw error
|
|
104
|
-
const failingTransport = {
|
|
105
|
-
emit: vi.fn().mockRejectedValue(new Error("Network error")),
|
|
106
|
-
close: vi.fn().mockResolvedValue(undefined),
|
|
107
|
-
};
|
|
108
|
-
vi.mocked(createTransport).mockReturnValueOnce(failingTransport);
|
|
109
|
-
const plugin = eventEmissionPlugin({
|
|
110
|
-
sdk: {},
|
|
111
|
-
context: {
|
|
112
|
-
meta: {},
|
|
113
|
-
options: {
|
|
114
|
-
eventEmission: {
|
|
115
|
-
enabled: true,
|
|
116
|
-
transport: {
|
|
117
|
-
type: "http",
|
|
118
|
-
endpoint: "https://example.com",
|
|
119
|
-
},
|
|
120
|
-
},
|
|
121
|
-
},
|
|
122
|
-
},
|
|
123
|
-
});
|
|
124
|
-
// Should not throw even if transport fails
|
|
125
|
-
expect(() => {
|
|
126
|
-
plugin.context.eventEmission.emit("test.event.TestEvent", {
|
|
127
|
-
test_event: "data",
|
|
128
|
-
});
|
|
129
|
-
}).not.toThrow();
|
|
130
|
-
// Give async emission time to complete
|
|
131
|
-
await new Promise((resolve) => setTimeout(resolve, 10));
|
|
132
|
-
expect(failingTransport.emit).toHaveBeenCalled();
|
|
133
|
-
});
|
|
134
|
-
it("should log tracking failure only on first occurrence", async () => {
|
|
135
|
-
// Mock console.warn to track logging calls
|
|
136
|
-
const mockConsoleWarn = vi
|
|
137
|
-
.spyOn(console, "warn")
|
|
138
|
-
.mockImplementation(() => { });
|
|
139
|
-
// Mock transport to throw error
|
|
140
|
-
const failingTransport = {
|
|
141
|
-
emit: vi.fn().mockRejectedValue(new Error("Network error")),
|
|
142
|
-
close: vi.fn().mockResolvedValue(undefined),
|
|
143
|
-
};
|
|
144
|
-
vi.mocked(createTransport).mockReturnValueOnce(failingTransport);
|
|
145
|
-
const plugin = eventEmissionPlugin({
|
|
146
|
-
sdk: {},
|
|
147
|
-
context: {
|
|
148
|
-
meta: {},
|
|
149
|
-
options: {
|
|
150
|
-
eventEmission: {
|
|
151
|
-
enabled: true,
|
|
152
|
-
transport: {
|
|
153
|
-
type: "http",
|
|
154
|
-
endpoint: "https://example.com",
|
|
155
|
-
},
|
|
156
|
-
},
|
|
157
|
-
},
|
|
158
|
-
},
|
|
159
|
-
});
|
|
160
|
-
// First event should trigger logging
|
|
161
|
-
plugin.context.eventEmission.emit("test.event.FirstEvent", {
|
|
162
|
-
data: "first",
|
|
163
|
-
});
|
|
164
|
-
await new Promise((resolve) => setTimeout(resolve, 10));
|
|
165
|
-
// Verify logging occurred
|
|
166
|
-
const initialLogCount = mockConsoleWarn.mock.calls.length;
|
|
167
|
-
expect(initialLogCount).toBeGreaterThan(0);
|
|
168
|
-
// Second and third events should not trigger additional logging
|
|
169
|
-
plugin.context.eventEmission.emit("test.event.SecondEvent", {
|
|
170
|
-
data: "second",
|
|
171
|
-
});
|
|
172
|
-
plugin.context.eventEmission.emit("test.event.ThirdEvent", {
|
|
173
|
-
data: "third",
|
|
174
|
-
});
|
|
175
|
-
await new Promise((resolve) => setTimeout(resolve, 10));
|
|
176
|
-
// Verify no additional logging occurred
|
|
177
|
-
expect(mockConsoleWarn).toHaveBeenCalledTimes(initialLogCount);
|
|
178
|
-
mockConsoleWarn.mockRestore();
|
|
179
|
-
});
|
|
180
|
-
it("should not log failures after a successful emit", async () => {
|
|
181
|
-
// Mock console.warn to track logging calls
|
|
182
|
-
const mockConsoleWarn = vi
|
|
183
|
-
.spyOn(console, "warn")
|
|
184
|
-
.mockImplementation(() => { });
|
|
185
|
-
// Mock transport that succeeds first, then fails
|
|
186
|
-
let callCount = 0;
|
|
187
|
-
const mixedTransport = {
|
|
188
|
-
emit: vi.fn().mockImplementation(() => {
|
|
189
|
-
callCount++;
|
|
190
|
-
if (callCount === 1) {
|
|
191
|
-
return Promise.resolve(); // First call succeeds
|
|
192
|
-
}
|
|
193
|
-
else {
|
|
194
|
-
return Promise.reject(new Error("Network error")); // Subsequent calls fail
|
|
195
|
-
}
|
|
196
|
-
}),
|
|
197
|
-
close: vi.fn().mockResolvedValue(undefined),
|
|
198
|
-
};
|
|
199
|
-
vi.mocked(createTransport).mockReturnValueOnce(mixedTransport);
|
|
200
|
-
const plugin = eventEmissionPlugin({
|
|
201
|
-
sdk: {},
|
|
202
|
-
context: {
|
|
203
|
-
meta: {},
|
|
204
|
-
options: {
|
|
205
|
-
eventEmission: {
|
|
206
|
-
enabled: true,
|
|
207
|
-
transport: {
|
|
208
|
-
type: "http",
|
|
209
|
-
endpoint: "https://example.com",
|
|
210
|
-
},
|
|
211
|
-
},
|
|
212
|
-
},
|
|
213
|
-
},
|
|
214
|
-
});
|
|
215
|
-
// First emit should succeed
|
|
216
|
-
plugin.context.eventEmission.emit("test.event.SuccessfulEvent", {
|
|
217
|
-
data: "success",
|
|
218
|
-
});
|
|
219
|
-
// Give time for success to be recorded
|
|
220
|
-
await new Promise((resolve) => setTimeout(resolve, 10));
|
|
221
|
-
// Subsequent emits should fail but not log
|
|
222
|
-
plugin.context.eventEmission.emit("test.event.FailingEvent1", {
|
|
223
|
-
data: "fail1",
|
|
224
|
-
});
|
|
225
|
-
plugin.context.eventEmission.emit("test.event.FailingEvent2", {
|
|
226
|
-
data: "fail2",
|
|
227
|
-
});
|
|
228
|
-
// Give async emissions time to complete
|
|
229
|
-
await new Promise((resolve) => setTimeout(resolve, 20));
|
|
230
|
-
// Should not have logged any warnings because tracking worked initially
|
|
231
|
-
expect(mockConsoleWarn).toHaveBeenCalledTimes(0);
|
|
232
|
-
mockConsoleWarn.mockRestore();
|
|
233
|
-
});
|
|
234
|
-
it("should merge options with defaults", () => {
|
|
235
|
-
// Override env var to ensure proper transport is used
|
|
236
|
-
vi.stubEnv("ZAPIER_SDK_TELEMETRY_TRANSPORT", undefined);
|
|
237
|
-
const plugin = eventEmissionPlugin({
|
|
238
|
-
sdk: {},
|
|
239
|
-
context: {
|
|
240
|
-
meta: {},
|
|
241
|
-
options: {
|
|
242
|
-
eventEmission: {
|
|
243
|
-
transport: {
|
|
244
|
-
type: "http",
|
|
245
|
-
endpoint: "https://example.com",
|
|
246
|
-
},
|
|
247
|
-
},
|
|
248
|
-
},
|
|
249
|
-
},
|
|
250
|
-
});
|
|
251
|
-
expect(plugin.context.eventEmission.config.enabled).toBe(true);
|
|
252
|
-
expect(plugin.context.eventEmission.config.transport).toEqual({
|
|
253
|
-
type: "http",
|
|
254
|
-
endpoint: "https://example.com",
|
|
255
|
-
});
|
|
256
|
-
vi.unstubAllEnvs();
|
|
257
|
-
});
|
|
258
|
-
it("should extract user IDs from JWT token and include in events", async () => {
|
|
259
|
-
// Create a test JWT token with user data
|
|
260
|
-
// JWT format: header.payload.signature
|
|
261
|
-
const header = { alg: "HS256", typ: "JWT" };
|
|
262
|
-
const payload = {
|
|
263
|
-
"zap:acc": "12345",
|
|
264
|
-
sub: "67890",
|
|
265
|
-
sub_type: "customuser",
|
|
266
|
-
"zap:uname": "test@example.com",
|
|
267
|
-
};
|
|
268
|
-
const encodedHeader = Buffer.from(JSON.stringify(header)).toString("base64url");
|
|
269
|
-
const encodedPayload = Buffer.from(JSON.stringify(payload)).toString("base64url");
|
|
270
|
-
const testJwt = `${encodedHeader}.${encodedPayload}.fake-signature`;
|
|
271
|
-
// Mock getToken to return the JWT
|
|
272
|
-
mockGetToken.mockResolvedValue(testJwt);
|
|
273
|
-
const plugin = eventEmissionPlugin({
|
|
274
|
-
sdk: {},
|
|
275
|
-
context: {
|
|
276
|
-
meta: {},
|
|
277
|
-
options: {
|
|
278
|
-
eventEmission: {
|
|
279
|
-
enabled: true,
|
|
280
|
-
transport: { type: "console" },
|
|
281
|
-
},
|
|
282
|
-
},
|
|
283
|
-
},
|
|
284
|
-
});
|
|
285
|
-
// Test that createBaseEvent includes the extracted user IDs
|
|
286
|
-
const baseEvent = await plugin.context.eventEmission.createBaseEvent();
|
|
287
|
-
expect(baseEvent.customuser_id).toBe(67890);
|
|
288
|
-
expect(baseEvent.account_id).toBe(12345);
|
|
289
|
-
});
|
|
290
|
-
it("should handle service tokens with nested JWT", async () => {
|
|
291
|
-
// Create a nested JWT for service token testing
|
|
292
|
-
const nestedHeader = { alg: "HS256", typ: "JWT" };
|
|
293
|
-
const nestedPayload = {
|
|
294
|
-
"zap:acc": "99999",
|
|
295
|
-
sub: "88888",
|
|
296
|
-
sub_type: "customuser",
|
|
297
|
-
};
|
|
298
|
-
const nestedEncodedHeader = Buffer.from(JSON.stringify(nestedHeader)).toString("base64url");
|
|
299
|
-
const nestedEncodedPayload = Buffer.from(JSON.stringify(nestedPayload)).toString("base64url");
|
|
300
|
-
const nestedJwt = `${nestedEncodedHeader}.${nestedEncodedPayload}.nested-signature`;
|
|
301
|
-
// Create the service token that wraps the nested JWT
|
|
302
|
-
const serviceHeader = { alg: "HS256", typ: "JWT" };
|
|
303
|
-
const servicePayload = {
|
|
304
|
-
"zap:acc": "11111",
|
|
305
|
-
sub: "22222",
|
|
306
|
-
sub_type: "service",
|
|
307
|
-
njwt: nestedJwt,
|
|
308
|
-
};
|
|
309
|
-
const serviceEncodedHeader = Buffer.from(JSON.stringify(serviceHeader)).toString("base64url");
|
|
310
|
-
const serviceEncodedPayload = Buffer.from(JSON.stringify(servicePayload)).toString("base64url");
|
|
311
|
-
const serviceJwt = `${serviceEncodedHeader}.${serviceEncodedPayload}.service-signature`;
|
|
312
|
-
// Mock getToken to return the service JWT
|
|
313
|
-
mockGetToken.mockResolvedValue(serviceJwt);
|
|
314
|
-
const plugin = eventEmissionPlugin({
|
|
315
|
-
sdk: {},
|
|
316
|
-
context: {
|
|
317
|
-
meta: {},
|
|
318
|
-
options: {
|
|
319
|
-
eventEmission: {
|
|
320
|
-
enabled: true,
|
|
321
|
-
transport: { type: "console" },
|
|
322
|
-
},
|
|
323
|
-
},
|
|
324
|
-
},
|
|
325
|
-
});
|
|
326
|
-
const baseEvent = await plugin.context.eventEmission.createBaseEvent();
|
|
327
|
-
// Should extract from nested JWT, not the service token
|
|
328
|
-
expect(baseEvent.customuser_id).toBe(88888);
|
|
329
|
-
expect(baseEvent.account_id).toBe(99999);
|
|
330
|
-
});
|
|
331
|
-
it("should handle invalid JWT tokens gracefully", async () => {
|
|
332
|
-
// Mock getToken to return an invalid JWT
|
|
333
|
-
mockGetToken.mockResolvedValue("not-a-valid-jwt-token");
|
|
334
|
-
const plugin = eventEmissionPlugin({
|
|
335
|
-
sdk: {},
|
|
336
|
-
context: {
|
|
337
|
-
meta: {},
|
|
338
|
-
options: {
|
|
339
|
-
eventEmission: {
|
|
340
|
-
enabled: true,
|
|
341
|
-
transport: { type: "console" },
|
|
342
|
-
},
|
|
343
|
-
},
|
|
344
|
-
},
|
|
345
|
-
});
|
|
346
|
-
const baseEvent = await plugin.context.eventEmission.createBaseEvent();
|
|
347
|
-
// Should default to null when JWT is invalid
|
|
348
|
-
expect(baseEvent.customuser_id).toBe(null);
|
|
349
|
-
expect(baseEvent.account_id).toBe(null);
|
|
350
|
-
});
|
|
351
|
-
it("should handle missing token gracefully", async () => {
|
|
352
|
-
// mockGetToken defaults to returning undefined (no token)
|
|
353
|
-
const plugin = eventEmissionPlugin({
|
|
354
|
-
sdk: {},
|
|
355
|
-
context: {
|
|
356
|
-
meta: {},
|
|
357
|
-
options: {
|
|
358
|
-
eventEmission: {
|
|
359
|
-
enabled: true,
|
|
360
|
-
transport: { type: "console" },
|
|
361
|
-
},
|
|
362
|
-
},
|
|
363
|
-
},
|
|
364
|
-
});
|
|
365
|
-
const baseEvent = await plugin.context.eventEmission.createBaseEvent();
|
|
366
|
-
// Should default to null when no token is provided
|
|
367
|
-
expect(baseEvent.customuser_id).toBe(null);
|
|
368
|
-
expect(baseEvent.account_id).toBe(null);
|
|
369
|
-
});
|
|
370
|
-
it("should extract user IDs when getToken returns valid JWT", async () => {
|
|
371
|
-
// Create a test JWT token
|
|
372
|
-
const header = { alg: "HS256", typ: "JWT" };
|
|
373
|
-
const payload = {
|
|
374
|
-
"zap:acc": "98765",
|
|
375
|
-
sub: "54321",
|
|
376
|
-
sub_type: "customuser",
|
|
377
|
-
};
|
|
378
|
-
const encodedHeader = Buffer.from(JSON.stringify(header)).toString("base64url");
|
|
379
|
-
const encodedPayload = Buffer.from(JSON.stringify(payload)).toString("base64url");
|
|
380
|
-
const testJwt = `${encodedHeader}.${encodedPayload}.test-signature`;
|
|
381
|
-
// Mock getToken to return the JWT
|
|
382
|
-
mockGetToken.mockResolvedValue(testJwt);
|
|
383
|
-
const plugin = eventEmissionPlugin({
|
|
384
|
-
sdk: {},
|
|
385
|
-
context: {
|
|
386
|
-
meta: {},
|
|
387
|
-
options: {
|
|
388
|
-
eventEmission: {
|
|
389
|
-
enabled: true,
|
|
390
|
-
transport: { type: "console" },
|
|
391
|
-
},
|
|
392
|
-
},
|
|
393
|
-
},
|
|
394
|
-
});
|
|
395
|
-
// Test that createBaseEvent includes the extracted user IDs
|
|
396
|
-
const baseEvent = await plugin.context.eventEmission.createBaseEvent();
|
|
397
|
-
expect(baseEvent.customuser_id).toBe(54321);
|
|
398
|
-
expect(baseEvent.account_id).toBe(98765);
|
|
399
|
-
});
|
|
400
|
-
it("should handle getToken failures gracefully", async () => {
|
|
401
|
-
// Mock getToken to reject/throw
|
|
402
|
-
mockGetToken.mockRejectedValue(new Error("Token fetch failed"));
|
|
403
|
-
const plugin = eventEmissionPlugin({
|
|
404
|
-
sdk: {},
|
|
405
|
-
context: {
|
|
406
|
-
meta: {},
|
|
407
|
-
options: {
|
|
408
|
-
eventEmission: {
|
|
409
|
-
enabled: true,
|
|
410
|
-
transport: { type: "console" },
|
|
411
|
-
},
|
|
412
|
-
},
|
|
413
|
-
},
|
|
414
|
-
});
|
|
415
|
-
const baseEvent = await plugin.context.eventEmission.createBaseEvent();
|
|
416
|
-
// Should gracefully fall back to null context
|
|
417
|
-
expect(baseEvent.customuser_id).toBe(null);
|
|
418
|
-
expect(baseEvent.account_id).toBe(null);
|
|
419
|
-
});
|
|
420
|
-
it("should extract user IDs from static token in SDK options", async () => {
|
|
421
|
-
// Create a test JWT token
|
|
422
|
-
const header = { alg: "HS256", typ: "JWT" };
|
|
423
|
-
const payload = {
|
|
424
|
-
"zap:acc": "11111",
|
|
425
|
-
sub: "22222",
|
|
426
|
-
sub_type: "customuser",
|
|
427
|
-
};
|
|
428
|
-
const encodedHeader = Buffer.from(JSON.stringify(header)).toString("base64url");
|
|
429
|
-
const encodedPayload = Buffer.from(JSON.stringify(payload)).toString("base64url");
|
|
430
|
-
const testJwt = `${encodedHeader}.${encodedPayload}.static-signature`;
|
|
431
|
-
const plugin = eventEmissionPlugin({
|
|
432
|
-
sdk: {},
|
|
433
|
-
context: {
|
|
434
|
-
meta: {},
|
|
435
|
-
options: {
|
|
436
|
-
token: testJwt,
|
|
437
|
-
eventEmission: {
|
|
438
|
-
enabled: true,
|
|
439
|
-
transport: { type: "console" },
|
|
440
|
-
},
|
|
441
|
-
},
|
|
442
|
-
},
|
|
443
|
-
});
|
|
444
|
-
const baseEvent = await plugin.context.eventEmission.createBaseEvent();
|
|
445
|
-
// Should extract from static token in options
|
|
446
|
-
expect(baseEvent.customuser_id).toBe(22222);
|
|
447
|
-
expect(baseEvent.account_id).toBe(11111);
|
|
448
|
-
// CLI login package should not be called when token is in options
|
|
449
|
-
expect(mockGetToken).not.toHaveBeenCalled();
|
|
450
|
-
});
|
|
451
|
-
it("should extract user IDs from getToken function in SDK options", async () => {
|
|
452
|
-
// Create a test JWT token
|
|
453
|
-
const header = { alg: "HS256", typ: "JWT" };
|
|
454
|
-
const payload = {
|
|
455
|
-
"zap:acc": "33333",
|
|
456
|
-
sub: "44444",
|
|
457
|
-
sub_type: "customuser",
|
|
458
|
-
};
|
|
459
|
-
const encodedHeader = Buffer.from(JSON.stringify(header)).toString("base64url");
|
|
460
|
-
const encodedPayload = Buffer.from(JSON.stringify(payload)).toString("base64url");
|
|
461
|
-
const testJwt = `${encodedHeader}.${encodedPayload}.custom-signature`;
|
|
462
|
-
const customGetToken = vi.fn().mockResolvedValue(testJwt);
|
|
463
|
-
const plugin = eventEmissionPlugin({
|
|
464
|
-
sdk: {},
|
|
465
|
-
context: {
|
|
466
|
-
meta: {},
|
|
467
|
-
options: {
|
|
468
|
-
getToken: customGetToken,
|
|
469
|
-
eventEmission: {
|
|
470
|
-
enabled: true,
|
|
471
|
-
transport: { type: "console" },
|
|
472
|
-
},
|
|
473
|
-
},
|
|
474
|
-
},
|
|
475
|
-
});
|
|
476
|
-
const baseEvent = await plugin.context.eventEmission.createBaseEvent();
|
|
477
|
-
// Should extract from custom getToken function
|
|
478
|
-
expect(baseEvent.customuser_id).toBe(44444);
|
|
479
|
-
expect(baseEvent.account_id).toBe(33333);
|
|
480
|
-
expect(customGetToken).toHaveBeenCalled();
|
|
481
|
-
// CLI login package should not be called when getToken is in options
|
|
482
|
-
expect(mockGetToken).not.toHaveBeenCalled();
|
|
483
|
-
});
|
|
484
|
-
it("should prioritize static token over getToken function", async () => {
|
|
485
|
-
// Create test JWT tokens
|
|
486
|
-
const staticHeader = { alg: "HS256", typ: "JWT" };
|
|
487
|
-
const staticPayload = {
|
|
488
|
-
"zap:acc": "55555",
|
|
489
|
-
sub: "66666",
|
|
490
|
-
sub_type: "customuser",
|
|
491
|
-
};
|
|
492
|
-
const staticEncodedHeader = Buffer.from(JSON.stringify(staticHeader)).toString("base64url");
|
|
493
|
-
const staticEncodedPayload = Buffer.from(JSON.stringify(staticPayload)).toString("base64url");
|
|
494
|
-
const staticJwt = `${staticEncodedHeader}.${staticEncodedPayload}.static-sig`;
|
|
495
|
-
const customGetToken = vi.fn().mockResolvedValue("should-not-be-used");
|
|
496
|
-
const plugin = eventEmissionPlugin({
|
|
497
|
-
sdk: {},
|
|
498
|
-
context: {
|
|
499
|
-
meta: {},
|
|
500
|
-
options: {
|
|
501
|
-
token: staticJwt,
|
|
502
|
-
getToken: customGetToken,
|
|
503
|
-
eventEmission: {
|
|
504
|
-
enabled: true,
|
|
505
|
-
transport: { type: "console" },
|
|
506
|
-
},
|
|
507
|
-
},
|
|
508
|
-
},
|
|
509
|
-
});
|
|
510
|
-
const baseEvent = await plugin.context.eventEmission.createBaseEvent();
|
|
511
|
-
// Should use static token, not getToken
|
|
512
|
-
expect(baseEvent.customuser_id).toBe(66666);
|
|
513
|
-
expect(baseEvent.account_id).toBe(55555);
|
|
514
|
-
expect(customGetToken).not.toHaveBeenCalled();
|
|
515
|
-
expect(mockGetToken).not.toHaveBeenCalled();
|
|
516
|
-
});
|
|
517
|
-
it("should fall back to CLI login when SDK options have no token", async () => {
|
|
518
|
-
// Create a test JWT token for CLI login
|
|
519
|
-
const header = { alg: "HS256", typ: "JWT" };
|
|
520
|
-
const payload = {
|
|
521
|
-
"zap:acc": "77777",
|
|
522
|
-
sub: "88888",
|
|
523
|
-
sub_type: "customuser",
|
|
524
|
-
};
|
|
525
|
-
const encodedHeader = Buffer.from(JSON.stringify(header)).toString("base64url");
|
|
526
|
-
const encodedPayload = Buffer.from(JSON.stringify(payload)).toString("base64url");
|
|
527
|
-
const testJwt = `${encodedHeader}.${encodedPayload}.cli-signature`;
|
|
528
|
-
mockGetToken.mockResolvedValue(testJwt);
|
|
529
|
-
const plugin = eventEmissionPlugin({
|
|
530
|
-
sdk: {},
|
|
531
|
-
context: {
|
|
532
|
-
meta: {},
|
|
533
|
-
options: {
|
|
534
|
-
// No token or getToken in options
|
|
535
|
-
eventEmission: {
|
|
536
|
-
enabled: true,
|
|
537
|
-
transport: { type: "console" },
|
|
538
|
-
},
|
|
539
|
-
},
|
|
540
|
-
},
|
|
541
|
-
});
|
|
542
|
-
const baseEvent = await plugin.context.eventEmission.createBaseEvent();
|
|
543
|
-
// Should fall back to CLI login package
|
|
544
|
-
expect(baseEvent.customuser_id).toBe(88888);
|
|
545
|
-
expect(baseEvent.account_id).toBe(77777);
|
|
546
|
-
expect(mockGetToken).toHaveBeenCalled();
|
|
547
|
-
});
|
|
548
|
-
it("should handle custom getToken returning undefined", async () => {
|
|
549
|
-
const customGetToken = vi.fn().mockResolvedValue(undefined);
|
|
550
|
-
// Also mock CLI login to return a token
|
|
551
|
-
const header = { alg: "HS256", typ: "JWT" };
|
|
552
|
-
const payload = {
|
|
553
|
-
"zap:acc": "99999",
|
|
554
|
-
sub: "10101",
|
|
555
|
-
sub_type: "customuser",
|
|
556
|
-
};
|
|
557
|
-
const encodedHeader = Buffer.from(JSON.stringify(header)).toString("base64url");
|
|
558
|
-
const encodedPayload = Buffer.from(JSON.stringify(payload)).toString("base64url");
|
|
559
|
-
const testJwt = `${encodedHeader}.${encodedPayload}.fallback-signature`;
|
|
560
|
-
mockGetToken.mockResolvedValue(testJwt);
|
|
561
|
-
const plugin = eventEmissionPlugin({
|
|
562
|
-
sdk: {},
|
|
563
|
-
context: {
|
|
564
|
-
meta: {},
|
|
565
|
-
options: {
|
|
566
|
-
getToken: customGetToken,
|
|
567
|
-
eventEmission: {
|
|
568
|
-
enabled: true,
|
|
569
|
-
transport: { type: "console" },
|
|
570
|
-
},
|
|
571
|
-
},
|
|
572
|
-
},
|
|
573
|
-
});
|
|
574
|
-
const baseEvent = await plugin.context.eventEmission.createBaseEvent();
|
|
575
|
-
// Should fall back to CLI login when custom getToken returns undefined
|
|
576
|
-
expect(baseEvent.customuser_id).toBe(10101);
|
|
577
|
-
expect(baseEvent.account_id).toBe(99999);
|
|
578
|
-
expect(customGetToken).toHaveBeenCalled();
|
|
579
|
-
expect(mockGetToken).toHaveBeenCalled();
|
|
580
|
-
});
|
|
581
|
-
});
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Transport abstraction layer for event emission
|
|
3
|
-
*
|
|
4
|
-
* Provides configurable transport mechanisms for emitting telemetry events.
|
|
5
|
-
* All transports implement silent failure to prevent SDK disruption.
|
|
6
|
-
*/
|
|
7
|
-
export interface EventTransport {
|
|
8
|
-
emit<T extends any>(subject: string, event: T): Promise<void>;
|
|
9
|
-
close?(): Promise<void>;
|
|
10
|
-
}
|
|
11
|
-
export interface TransportConfig {
|
|
12
|
-
type: "http" | "console" | "noop";
|
|
13
|
-
endpoint?: string;
|
|
14
|
-
headers?: Record<string, string>;
|
|
15
|
-
retryAttempts?: number;
|
|
16
|
-
retryDelayMs?: number;
|
|
17
|
-
}
|
|
18
|
-
export declare function createHttpTransport(config: {
|
|
19
|
-
endpoint: string;
|
|
20
|
-
headers?: Record<string, string>;
|
|
21
|
-
retryAttempts?: number;
|
|
22
|
-
retryDelayMs?: number;
|
|
23
|
-
}): EventTransport;
|
|
24
|
-
export declare function createConsoleTransport(): EventTransport;
|
|
25
|
-
export declare function createNoopTransport(): EventTransport;
|
|
26
|
-
export declare function createTransport(config: TransportConfig): EventTransport;
|
|
27
|
-
//# sourceMappingURL=transport.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"transport.d.ts","sourceRoot":"","sources":["../../../src/plugins/eventEmission/transport.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAOH,MAAM,WAAW,cAAc;IAC7B,IAAI,CAAC,CAAC,SAAS,GAAG,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC9D,KAAK,CAAC,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CACzB;AAGD,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,CAAC;IAClC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAGD,wBAAgB,mBAAmB,CAAC,MAAM,EAAE;IAC1C,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,GAAG,cAAc,CAwDjB;AAGD,wBAAgB,sBAAsB,IAAI,cAAc,CAavD;AAGD,wBAAgB,mBAAmB,IAAI,cAAc,CAMpD;AAGD,wBAAgB,eAAe,CAAC,MAAM,EAAE,eAAe,GAAG,cAAc,CAyBvE"}
|