@zapier/zapier-sdk 0.18.4 → 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 +35 -0
- package/README.md +43 -31
- package/dist/index.cjs +365 -64
- package/dist/index.d.mts +220 -33
- package/dist/index.d.ts +2541 -40
- package/dist/index.mjs +345 -63
- 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.js +0 -356
- 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/schemas.d.ts +0 -422
- package/dist/api/schemas.d.ts.map +0 -1
- package/dist/api/schemas.js +0 -322
- package/dist/api/types.d.ts +0 -83
- 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 -19
- package/dist/plugins/listApps/index.d.ts.map +0 -1
- package/dist/plugins/listApps/index.js +0 -67
- 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 -121
- package/dist/plugins/listApps/schemas.d.ts +0 -47
- package/dist/plugins/listApps/schemas.d.ts.map +0 -1
- package/dist/plugins/listApps/schemas.js +0 -49
- 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 -848
- 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 -26
- 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 -258
- 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/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 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"retry-utils.d.ts","sourceRoot":"","sources":["../../src/utils/retry-utils.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;;GAGG;AACH,eAAO,MAAM,sBAAsB,IAAI,CAAC;AAExC;;;GAGG;AACH,eAAO,MAAM,qBAAqB,OAAQ,CAAC;AAE3C;;;;GAIG;AACH,eAAO,MAAM,aAAa,MAAM,CAAC;AAEjC;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,iBAAiB,CAC/B,YAAY,EAAE,MAAM,EACpB,UAAU,EAAE,MAAM,GACjB,MAAM,CAYR"}
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Retry and Backoff Utilities
|
|
3
|
-
*
|
|
4
|
-
* Shared utilities for implementing resilient retry logic with exponential backoff
|
|
5
|
-
* and jitter. Used by both polling and batch operations.
|
|
6
|
-
*/
|
|
7
|
-
/**
|
|
8
|
-
* Maximum number of consecutive errors before giving up
|
|
9
|
-
* Prevents infinite retry loops when the API is consistently failing
|
|
10
|
-
*/
|
|
11
|
-
export const MAX_CONSECUTIVE_ERRORS = 3;
|
|
12
|
-
/**
|
|
13
|
-
* Base delay for error backoff in milliseconds
|
|
14
|
-
* Each error adds this amount (with scaling) to the wait time
|
|
15
|
-
*/
|
|
16
|
-
export const BASE_ERROR_BACKOFF_MS = 1000;
|
|
17
|
-
/**
|
|
18
|
-
* Jitter factor (0.0 to 1.0) for randomizing wait times
|
|
19
|
-
* Prevents thundering herd problem when many clients retry simultaneously
|
|
20
|
-
* A factor of 0.5 means we add 0-50% random variance to the base interval
|
|
21
|
-
*/
|
|
22
|
-
export const JITTER_FACTOR = 0.5;
|
|
23
|
-
/**
|
|
24
|
-
* Calculate wait time with jitter and error backoff
|
|
25
|
-
*
|
|
26
|
-
* This implements two key reliability patterns:
|
|
27
|
-
* 1. Jitter - Adds randomness to prevent synchronized retries across clients
|
|
28
|
-
* 2. Error backoff - Increases wait time when errors occur, giving the API time to recover
|
|
29
|
-
*
|
|
30
|
-
* @param baseInterval - The base wait time in milliseconds
|
|
31
|
-
* @param errorCount - Number of consecutive errors (0 if no errors)
|
|
32
|
-
* @returns Wait time in milliseconds with jitter and error backoff applied
|
|
33
|
-
*
|
|
34
|
-
* @example
|
|
35
|
-
* // No errors: returns 1000-1500ms (1000 + 0-500ms jitter)
|
|
36
|
-
* calculateWaitTime(1000, 0);
|
|
37
|
-
*
|
|
38
|
-
* // 2 errors: returns 1000-1500ms base + up to 1000ms error backoff = 1000-2500ms
|
|
39
|
-
* calculateWaitTime(1000, 2);
|
|
40
|
-
*
|
|
41
|
-
* // 6 errors: returns 1000-1500ms base + 2000ms capped backoff = 3000-3500ms
|
|
42
|
-
* calculateWaitTime(1000, 6);
|
|
43
|
-
*/
|
|
44
|
-
export function calculateWaitTime(baseInterval, errorCount) {
|
|
45
|
-
// Jitter to avoid thundering herd (multiple clients retrying at exact same time)
|
|
46
|
-
const jitter = Math.random() * JITTER_FACTOR * baseInterval;
|
|
47
|
-
// Exponential backoff scaled by error count, but capped at 2x base interval
|
|
48
|
-
// This prevents wait times from growing unboundedly
|
|
49
|
-
const errorBackoff = Math.min(BASE_ERROR_BACKOFF_MS * (errorCount / 2), baseInterval * 2);
|
|
50
|
-
return Math.floor(baseInterval + jitter + errorBackoff);
|
|
51
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"retry-utils.test.d.ts","sourceRoot":"","sources":["../../src/utils/retry-utils.test.ts"],"names":[],"mappings":""}
|
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect, vi, beforeEach, afterEach } from "vitest";
|
|
2
|
-
import { calculateWaitTime, MAX_CONSECUTIVE_ERRORS, BASE_ERROR_BACKOFF_MS, JITTER_FACTOR, } from "./retry-utils";
|
|
3
|
-
describe("retry-utils", () => {
|
|
4
|
-
describe("calculateWaitTime", () => {
|
|
5
|
-
beforeEach(() => {
|
|
6
|
-
// Seed random for consistent testing
|
|
7
|
-
vi.spyOn(Math, "random");
|
|
8
|
-
});
|
|
9
|
-
afterEach(() => {
|
|
10
|
-
vi.restoreAllMocks();
|
|
11
|
-
});
|
|
12
|
-
it("should return base interval with jitter when no errors", () => {
|
|
13
|
-
vi.spyOn(Math, "random").mockReturnValue(0.5); // Middle of jitter range
|
|
14
|
-
const baseInterval = 1000;
|
|
15
|
-
const waitTime = calculateWaitTime(baseInterval, 0);
|
|
16
|
-
// With 0.5 random and JITTER_FACTOR 0.5:
|
|
17
|
-
// jitter = 0.5 * 0.5 * 1000 = 250ms
|
|
18
|
-
// errorBackoff = 0 (no errors)
|
|
19
|
-
// total = 1000 + 250 + 0 = 1250ms
|
|
20
|
-
expect(waitTime).toBe(1250);
|
|
21
|
-
});
|
|
22
|
-
it("should add error backoff for consecutive errors", () => {
|
|
23
|
-
vi.spyOn(Math, "random").mockReturnValue(0); // No jitter for simpler math
|
|
24
|
-
const baseInterval = 1000;
|
|
25
|
-
const errorCount = 2;
|
|
26
|
-
const waitTime = calculateWaitTime(baseInterval, errorCount);
|
|
27
|
-
// jitter = 0 (random is 0)
|
|
28
|
-
// errorBackoff = BASE_ERROR_BACKOFF_MS * (errorCount / 2) = 1000 * (2/2) = 1000ms
|
|
29
|
-
// total = 1000 + 0 + 1000 = 2000ms
|
|
30
|
-
expect(waitTime).toBe(2000);
|
|
31
|
-
});
|
|
32
|
-
it("should cap error backoff at 2x base interval", () => {
|
|
33
|
-
vi.spyOn(Math, "random").mockReturnValue(0); // No jitter
|
|
34
|
-
const baseInterval = 1000;
|
|
35
|
-
const errorCount = 10; // Large error count
|
|
36
|
-
const waitTime = calculateWaitTime(baseInterval, errorCount);
|
|
37
|
-
// errorBackoff would be 1000 * (10/2) = 5000ms
|
|
38
|
-
// but it's capped at 2x base = 2000ms
|
|
39
|
-
// total = 1000 + 0 + 2000 = 3000ms
|
|
40
|
-
expect(waitTime).toBe(3000);
|
|
41
|
-
});
|
|
42
|
-
it("should add random jitter to prevent thundering herd", () => {
|
|
43
|
-
const baseInterval = 1000;
|
|
44
|
-
const results = new Set();
|
|
45
|
-
// Run multiple times with real random to ensure jitter varies
|
|
46
|
-
vi.spyOn(Math, "random").mockRestore(); // Use real random
|
|
47
|
-
for (let i = 0; i < 10; i++) {
|
|
48
|
-
const waitTime = calculateWaitTime(baseInterval, 0);
|
|
49
|
-
results.add(waitTime);
|
|
50
|
-
}
|
|
51
|
-
// Should have multiple different values due to jitter
|
|
52
|
-
expect(results.size).toBeGreaterThan(1);
|
|
53
|
-
// All values should be in expected range
|
|
54
|
-
// baseInterval (1000) + jitter (0 to JITTER_FACTOR * baseInterval)
|
|
55
|
-
// = 1000 to 1500ms
|
|
56
|
-
for (const result of results) {
|
|
57
|
-
expect(result).toBeGreaterThanOrEqual(1000);
|
|
58
|
-
expect(result).toBeLessThanOrEqual(1500);
|
|
59
|
-
}
|
|
60
|
-
});
|
|
61
|
-
it("should combine jitter and error backoff", () => {
|
|
62
|
-
vi.spyOn(Math, "random").mockReturnValue(0.5);
|
|
63
|
-
const baseInterval = 1000;
|
|
64
|
-
const errorCount = 2;
|
|
65
|
-
const waitTime = calculateWaitTime(baseInterval, errorCount);
|
|
66
|
-
// jitter = 0.5 * 0.5 * 1000 = 250ms
|
|
67
|
-
// errorBackoff = 1000 * (2/2) = 1000ms
|
|
68
|
-
// total = 1000 + 250 + 1000 = 2250ms
|
|
69
|
-
expect(waitTime).toBe(2250);
|
|
70
|
-
});
|
|
71
|
-
it("should return integer wait time", () => {
|
|
72
|
-
vi.spyOn(Math, "random").mockReturnValue(0.333);
|
|
73
|
-
const baseInterval = 1000;
|
|
74
|
-
const waitTime = calculateWaitTime(baseInterval, 1);
|
|
75
|
-
// Result should be floored integer
|
|
76
|
-
expect(Number.isInteger(waitTime)).toBe(true);
|
|
77
|
-
});
|
|
78
|
-
});
|
|
79
|
-
describe("constants", () => {
|
|
80
|
-
it("should export MAX_CONSECUTIVE_ERRORS", () => {
|
|
81
|
-
expect(MAX_CONSECUTIVE_ERRORS).toBe(3);
|
|
82
|
-
});
|
|
83
|
-
it("should export BASE_ERROR_BACKOFF_MS", () => {
|
|
84
|
-
expect(BASE_ERROR_BACKOFF_MS).toBe(1000);
|
|
85
|
-
});
|
|
86
|
-
it("should export JITTER_FACTOR", () => {
|
|
87
|
-
expect(JITTER_FACTOR).toBe(0.5);
|
|
88
|
-
});
|
|
89
|
-
});
|
|
90
|
-
});
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
import type { ZapierSdk } from "../types/sdk";
|
|
3
|
-
import type { InputFieldItem } from "../schemas/Field";
|
|
4
|
-
export interface FormattedItem {
|
|
5
|
-
title: string;
|
|
6
|
-
id?: string;
|
|
7
|
-
key?: string;
|
|
8
|
-
keys?: string[];
|
|
9
|
-
description?: string;
|
|
10
|
-
data?: unknown;
|
|
11
|
-
details: Array<{
|
|
12
|
-
text: string;
|
|
13
|
-
style: "normal" | "dim" | "accent" | "warning" | "success";
|
|
14
|
-
}>;
|
|
15
|
-
}
|
|
16
|
-
export interface FormatMetadata<TItem = unknown> {
|
|
17
|
-
format: (item: TItem) => FormattedItem;
|
|
18
|
-
}
|
|
19
|
-
export declare function withFormatter<T extends z.ZodType>(schema: T, formatMeta: FormatMetadata<z.infer<T>>): T;
|
|
20
|
-
export declare function getOutputSchema(inputSchema: z.ZodType): z.ZodType | undefined;
|
|
21
|
-
export declare function withOutputSchema<T extends z.ZodType>(inputSchema: T, outputSchema: z.ZodType): T & {
|
|
22
|
-
_def: T["_def"] & {
|
|
23
|
-
outputSchema: z.ZodType;
|
|
24
|
-
};
|
|
25
|
-
};
|
|
26
|
-
export interface PromptConfig {
|
|
27
|
-
type: "list";
|
|
28
|
-
name: string;
|
|
29
|
-
message: string;
|
|
30
|
-
choices: Array<{
|
|
31
|
-
name: string;
|
|
32
|
-
value: unknown;
|
|
33
|
-
}>;
|
|
34
|
-
}
|
|
35
|
-
export interface Resolver {
|
|
36
|
-
type: string;
|
|
37
|
-
depends?: readonly string[] | string[];
|
|
38
|
-
}
|
|
39
|
-
export interface StaticResolver extends Resolver {
|
|
40
|
-
type: "static";
|
|
41
|
-
inputType?: "text" | "password" | "email";
|
|
42
|
-
placeholder?: string;
|
|
43
|
-
}
|
|
44
|
-
export interface DynamicResolver<TItem = unknown, TParams = Record<string, unknown>> extends Resolver {
|
|
45
|
-
type: "dynamic";
|
|
46
|
-
fetch: (sdk: ZapierSdk, resolvedParams: TParams) => Promise<TItem[]>;
|
|
47
|
-
prompt: (items: TItem[], params: TParams) => PromptConfig;
|
|
48
|
-
}
|
|
49
|
-
export interface FieldsResolver<TParams = Record<string, unknown>> extends Resolver {
|
|
50
|
-
type: "fields";
|
|
51
|
-
fetch: (sdk: ZapierSdk, resolvedParams: TParams) => Promise<InputFieldItem[]>;
|
|
52
|
-
}
|
|
53
|
-
export type ResolverMetadata<TItem = unknown, TParams = Record<string, unknown>> = StaticResolver | DynamicResolver<TItem, TParams> | FieldsResolver<TParams>;
|
|
54
|
-
export interface ResolverConfig<TItem = unknown, TParams = Record<string, unknown>> {
|
|
55
|
-
resolver: ResolverMetadata<TItem, TParams>;
|
|
56
|
-
}
|
|
57
|
-
export declare function withResolver<T extends z.ZodType, TItem = unknown, TParams = Record<string, unknown>>(schema: T, config: ResolverConfig<TItem, TParams>): T;
|
|
58
|
-
export declare function getSchemaDescription(schema: z.ZodSchema): string | undefined;
|
|
59
|
-
export declare function getFieldDescriptions(schema: z.ZodObject<z.ZodRawShape>): Record<string, string>;
|
|
60
|
-
export interface PositionalMetadata {
|
|
61
|
-
positionalMeta: {
|
|
62
|
-
positional: true;
|
|
63
|
-
};
|
|
64
|
-
}
|
|
65
|
-
export declare function withPositional<T extends z.ZodType>(schema: T): T & {
|
|
66
|
-
_def: T["_def"] & PositionalMetadata;
|
|
67
|
-
};
|
|
68
|
-
export declare function isPositional(schema: z.ZodType): boolean;
|
|
69
|
-
//# sourceMappingURL=schema-utils.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"schema-utils.d.ts","sourceRoot":"","sources":["../../src/utils/schema-utils.ts"],"names":[],"mappings":"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"}
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
// Helper function to add format metadata to schemas
|
|
3
|
-
export function withFormatter(schema, formatMeta) {
|
|
4
|
-
// Store format metadata on the schema definition
|
|
5
|
-
Object.assign(schema._zod.def, {
|
|
6
|
-
formatMeta: formatMeta,
|
|
7
|
-
});
|
|
8
|
-
return schema;
|
|
9
|
-
}
|
|
10
|
-
// Helper function to get output schema from an input schema
|
|
11
|
-
export function getOutputSchema(inputSchema) {
|
|
12
|
-
return inputSchema._zod.def.outputSchema;
|
|
13
|
-
}
|
|
14
|
-
// Helper function to link input schemas to output schemas
|
|
15
|
-
export function withOutputSchema(inputSchema, outputSchema) {
|
|
16
|
-
// Store output schema reference on the input schema
|
|
17
|
-
Object.assign(inputSchema._zod.def, {
|
|
18
|
-
outputSchema,
|
|
19
|
-
});
|
|
20
|
-
return inputSchema;
|
|
21
|
-
}
|
|
22
|
-
// Helper function to add resolver metadata to schemas
|
|
23
|
-
export function withResolver(schema, config) {
|
|
24
|
-
// Store resolver metadata on the schema definition
|
|
25
|
-
schema._zod.def.resolverMeta = config;
|
|
26
|
-
return schema;
|
|
27
|
-
}
|
|
28
|
-
// ============================================================================
|
|
29
|
-
// Schema Description Utilities
|
|
30
|
-
// ============================================================================
|
|
31
|
-
export function getSchemaDescription(schema) {
|
|
32
|
-
return schema.description;
|
|
33
|
-
}
|
|
34
|
-
export function getFieldDescriptions(schema) {
|
|
35
|
-
const descriptions = {};
|
|
36
|
-
const shape = schema.shape;
|
|
37
|
-
for (const [key, fieldSchema] of Object.entries(shape)) {
|
|
38
|
-
if (fieldSchema instanceof z.ZodType && fieldSchema.description) {
|
|
39
|
-
descriptions[key] = fieldSchema.description;
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
return descriptions;
|
|
43
|
-
}
|
|
44
|
-
// Helper function to mark a parameter as positional for CLI
|
|
45
|
-
export function withPositional(schema) {
|
|
46
|
-
// Store positional metadata on the schema definition
|
|
47
|
-
Object.assign(schema._zod.def, {
|
|
48
|
-
positionalMeta: { positional: true },
|
|
49
|
-
});
|
|
50
|
-
return schema;
|
|
51
|
-
}
|
|
52
|
-
function schemaHasPositionalMeta(schema) {
|
|
53
|
-
return "positionalMeta" in schema._zod.def;
|
|
54
|
-
}
|
|
55
|
-
// Helper function to check if a parameter should be positional
|
|
56
|
-
export function isPositional(schema) {
|
|
57
|
-
// Check the current schema first
|
|
58
|
-
if (schemaHasPositionalMeta(schema) &&
|
|
59
|
-
schema._zod.def
|
|
60
|
-
.positionalMeta?.positional) {
|
|
61
|
-
return true;
|
|
62
|
-
}
|
|
63
|
-
// If this is a ZodOptional, check the inner type
|
|
64
|
-
if (schema instanceof z.ZodOptional) {
|
|
65
|
-
return isPositional(schema._zod.def.innerType);
|
|
66
|
-
}
|
|
67
|
-
// If this is a ZodDefault, check the inner type
|
|
68
|
-
if (schema instanceof z.ZodDefault) {
|
|
69
|
-
return isPositional(schema._zod.def.innerType);
|
|
70
|
-
}
|
|
71
|
-
return false;
|
|
72
|
-
}
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* String utility functions for the Zapier SDK
|
|
3
|
-
*/
|
|
4
|
-
/**
|
|
5
|
-
* Converts a string to title case, handling various input formats:
|
|
6
|
-
* - camelCase: "firstName" → "First Name"
|
|
7
|
-
* - snake_case: "first_name" → "First Name"
|
|
8
|
-
* - kebab-case: "first-name" → "First Name"
|
|
9
|
-
* - mixed formats: "first_name-value" → "First Name Value"
|
|
10
|
-
*/
|
|
11
|
-
export declare function toTitleCase(input: string): string;
|
|
12
|
-
/**
|
|
13
|
-
* Converts a string to snake_case, handling various input formats:
|
|
14
|
-
* - camelCase: "firstName" → "first_name"
|
|
15
|
-
* - kebab-case: "first-name" → "first_name"
|
|
16
|
-
* - title case: "First Name" → "first_name"
|
|
17
|
-
* - mixed formats: "first-Name Value" → "first_name_value"
|
|
18
|
-
* - starts with number: "123abc" → "_123abc"
|
|
19
|
-
*/
|
|
20
|
-
export declare function toSnakeCase(input: string): string;
|
|
21
|
-
/**
|
|
22
|
-
* Strips the "Page" suffix from a function name, used for deriving method names
|
|
23
|
-
* from paginated function implementations.
|
|
24
|
-
*
|
|
25
|
-
* This is commonly used with `createPaginatedFunction` where the internal function
|
|
26
|
-
* has a "Page" suffix (e.g., "listAppsPage") but the public method name should not
|
|
27
|
-
* (e.g., "listApps").
|
|
28
|
-
*
|
|
29
|
-
* @param functionName - The function name, typically from `function.name`
|
|
30
|
-
* @returns The function name with "Page" suffix removed, or original if no suffix
|
|
31
|
-
*
|
|
32
|
-
* @example
|
|
33
|
-
* ```typescript
|
|
34
|
-
* stripPageSuffix("listAppsPage") // "listApps"
|
|
35
|
-
* stripPageSuffix("listApps") // "listApps" (no change)
|
|
36
|
-
* stripPageSuffix("myPageFunction") // "myPageFunction" (only strips from end)
|
|
37
|
-
* ```
|
|
38
|
-
*/
|
|
39
|
-
export declare function stripPageSuffix(functionName: string): string;
|
|
40
|
-
//# sourceMappingURL=string-utils.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"string-utils.d.ts","sourceRoot":"","sources":["../../src/utils/string-utils.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;;;;;GAMG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAcjD;AAED;;;;;;;GAOG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAkBjD;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,eAAe,CAAC,YAAY,EAAE,MAAM,GAAG,MAAM,CAE5D"}
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* String utility functions for the Zapier SDK
|
|
3
|
-
*/
|
|
4
|
-
/**
|
|
5
|
-
* Converts a string to title case, handling various input formats:
|
|
6
|
-
* - camelCase: "firstName" → "First Name"
|
|
7
|
-
* - snake_case: "first_name" → "First Name"
|
|
8
|
-
* - kebab-case: "first-name" → "First Name"
|
|
9
|
-
* - mixed formats: "first_name-value" → "First Name Value"
|
|
10
|
-
*/
|
|
11
|
-
export function toTitleCase(input) {
|
|
12
|
-
return (input
|
|
13
|
-
// insert a space before capital letters (handles camelCase)
|
|
14
|
-
.replace(/([a-z0-9])([A-Z])/g, "$1 $2")
|
|
15
|
-
// replace delimiters (underscore, dash, multiple spaces) with single space
|
|
16
|
-
.replace(/[_\-]+/g, " ")
|
|
17
|
-
.replace(/\s+/g, " ")
|
|
18
|
-
.trim()
|
|
19
|
-
// split and capitalize each word
|
|
20
|
-
.split(" ")
|
|
21
|
-
.map((word) => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase())
|
|
22
|
-
.join(" "));
|
|
23
|
-
}
|
|
24
|
-
/**
|
|
25
|
-
* Converts a string to snake_case, handling various input formats:
|
|
26
|
-
* - camelCase: "firstName" → "first_name"
|
|
27
|
-
* - kebab-case: "first-name" → "first_name"
|
|
28
|
-
* - title case: "First Name" → "first_name"
|
|
29
|
-
* - mixed formats: "first-Name Value" → "first_name_value"
|
|
30
|
-
* - starts with number: "123abc" → "_123abc"
|
|
31
|
-
*/
|
|
32
|
-
export function toSnakeCase(input) {
|
|
33
|
-
let result = input
|
|
34
|
-
// insert underscore before capital letters (handles camelCase)
|
|
35
|
-
.replace(/([a-z0-9])([A-Z])/g, "$1_$2")
|
|
36
|
-
// replace spaces and dashes with underscores
|
|
37
|
-
.replace(/[\s\-]+/g, "_")
|
|
38
|
-
// replace multiple underscores with single underscore
|
|
39
|
-
.replace(/_+/g, "_")
|
|
40
|
-
// remove leading/trailing underscores and convert to lowercase
|
|
41
|
-
.replace(/^_|_$/g, "")
|
|
42
|
-
.toLowerCase();
|
|
43
|
-
// If the result starts with a number, prefix with underscore
|
|
44
|
-
if (/^[0-9]/.test(result)) {
|
|
45
|
-
result = "_" + result;
|
|
46
|
-
}
|
|
47
|
-
return result;
|
|
48
|
-
}
|
|
49
|
-
/**
|
|
50
|
-
* Strips the "Page" suffix from a function name, used for deriving method names
|
|
51
|
-
* from paginated function implementations.
|
|
52
|
-
*
|
|
53
|
-
* This is commonly used with `createPaginatedFunction` where the internal function
|
|
54
|
-
* has a "Page" suffix (e.g., "listAppsPage") but the public method name should not
|
|
55
|
-
* (e.g., "listApps").
|
|
56
|
-
*
|
|
57
|
-
* @param functionName - The function name, typically from `function.name`
|
|
58
|
-
* @returns The function name with "Page" suffix removed, or original if no suffix
|
|
59
|
-
*
|
|
60
|
-
* @example
|
|
61
|
-
* ```typescript
|
|
62
|
-
* stripPageSuffix("listAppsPage") // "listApps"
|
|
63
|
-
* stripPageSuffix("listApps") // "listApps" (no change)
|
|
64
|
-
* stripPageSuffix("myPageFunction") // "myPageFunction" (only strips from end)
|
|
65
|
-
* ```
|
|
66
|
-
*/
|
|
67
|
-
export function stripPageSuffix(functionName) {
|
|
68
|
-
return functionName.replace(/Page$/, "");
|
|
69
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"string-utils.test.d.ts","sourceRoot":"","sources":["../../src/utils/string-utils.test.ts"],"names":[],"mappings":""}
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect } from "vitest";
|
|
2
|
-
import { toTitleCase, stripPageSuffix } from "./string-utils";
|
|
3
|
-
describe("toTitleCase", () => {
|
|
4
|
-
it("converts snake_case to title case", () => {
|
|
5
|
-
expect(toTitleCase("first_name")).toBe("First Name");
|
|
6
|
-
expect(toTitleCase("sender_settings")).toBe("Sender Settings");
|
|
7
|
-
expect(toTitleCase("api_key_config")).toBe("Api Key Config");
|
|
8
|
-
});
|
|
9
|
-
it("converts camelCase to title case", () => {
|
|
10
|
-
expect(toTitleCase("firstName")).toBe("First Name");
|
|
11
|
-
expect(toTitleCase("senderSettings")).toBe("Sender Settings");
|
|
12
|
-
expect(toTitleCase("apiKeyConfig")).toBe("Api Key Config");
|
|
13
|
-
});
|
|
14
|
-
it("converts kebab-case to title case", () => {
|
|
15
|
-
expect(toTitleCase("first-name")).toBe("First Name");
|
|
16
|
-
expect(toTitleCase("sender-settings")).toBe("Sender Settings");
|
|
17
|
-
expect(toTitleCase("api-key-config")).toBe("Api Key Config");
|
|
18
|
-
});
|
|
19
|
-
it("handles mixed formats", () => {
|
|
20
|
-
expect(toTitleCase("first_name-value")).toBe("First Name Value");
|
|
21
|
-
expect(toTitleCase("sender_settings-config")).toBe("Sender Settings Config");
|
|
22
|
-
});
|
|
23
|
-
it("handles single words", () => {
|
|
24
|
-
expect(toTitleCase("name")).toBe("Name");
|
|
25
|
-
expect(toTitleCase("settings")).toBe("Settings");
|
|
26
|
-
});
|
|
27
|
-
it("handles multiple spaces and trims", () => {
|
|
28
|
-
expect(toTitleCase(" first name ")).toBe("First Name");
|
|
29
|
-
expect(toTitleCase("sender__settings")).toBe("Sender Settings");
|
|
30
|
-
});
|
|
31
|
-
it("handles empty and edge cases", () => {
|
|
32
|
-
expect(toTitleCase("")).toBe("");
|
|
33
|
-
expect(toTitleCase("a")).toBe("A");
|
|
34
|
-
expect(toTitleCase("_")).toBe("");
|
|
35
|
-
});
|
|
36
|
-
});
|
|
37
|
-
describe("stripPageSuffix", () => {
|
|
38
|
-
it("strips Page suffix from function names", () => {
|
|
39
|
-
expect(stripPageSuffix("listAppsPage")).toBe("listApps");
|
|
40
|
-
expect(stripPageSuffix("listActionsPage")).toBe("listActions");
|
|
41
|
-
expect(stripPageSuffix("runActionPage")).toBe("runAction");
|
|
42
|
-
expect(stripPageSuffix("listAuthenticationsPage")).toBe("listAuthentications");
|
|
43
|
-
});
|
|
44
|
-
it("leaves names without Page suffix unchanged", () => {
|
|
45
|
-
expect(stripPageSuffix("listApps")).toBe("listApps");
|
|
46
|
-
expect(stripPageSuffix("getProfile")).toBe("getProfile");
|
|
47
|
-
expect(stripPageSuffix("request")).toBe("request");
|
|
48
|
-
});
|
|
49
|
-
it("only strips Page from the end", () => {
|
|
50
|
-
expect(stripPageSuffix("myPageFunction")).toBe("myPageFunction");
|
|
51
|
-
expect(stripPageSuffix("PageList")).toBe("PageList");
|
|
52
|
-
expect(stripPageSuffix("getPageData")).toBe("getPageData");
|
|
53
|
-
});
|
|
54
|
-
it("handles edge cases", () => {
|
|
55
|
-
expect(stripPageSuffix("Page")).toBe("");
|
|
56
|
-
expect(stripPageSuffix("")).toBe("");
|
|
57
|
-
expect(stripPageSuffix("p")).toBe("p");
|
|
58
|
-
});
|
|
59
|
-
});
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import type { TelemetryCallbacks } from "./function-utils";
|
|
2
|
-
import type { EventEmissionContext } from "../plugins/eventEmission";
|
|
3
|
-
/**
|
|
4
|
-
* Creates a standardized telemetry callback for SDK method invocations.
|
|
5
|
-
*
|
|
6
|
-
* This factory eliminates boilerplate by providing a consistent implementation
|
|
7
|
-
* of the onMethodCalled callback used by createFunction and createPaginatedFunction.
|
|
8
|
-
*
|
|
9
|
-
* @param emitMethodCalled - The event emission function from EventEmissionContext
|
|
10
|
-
* @param methodName - The method name to report in telemetry. Use `function.name` to derive
|
|
11
|
-
* this automatically from the function declaration, ensuring DRY principles and making
|
|
12
|
-
* refactoring easier. Function names are preserved through bundling.
|
|
13
|
-
* @returns TelemetryCallbacks object with standardized onMethodCalled implementation
|
|
14
|
-
*
|
|
15
|
-
* @example
|
|
16
|
-
* Basic usage with createFunction:
|
|
17
|
-
* ```typescript
|
|
18
|
-
* async function listApps(options: ListAppsOptions) { ... }
|
|
19
|
-
*
|
|
20
|
-
* const listAppsDefinition = createFunction(
|
|
21
|
-
* listApps,
|
|
22
|
-
* ListAppsSchema,
|
|
23
|
-
* createTelemetryCallback(context.eventEmission.emitMethodCalled, listApps.name),
|
|
24
|
-
* );
|
|
25
|
-
* ```
|
|
26
|
-
*
|
|
27
|
-
* @example
|
|
28
|
-
* For paginated functions, use stripPageSuffix to remove the "Page" suffix:
|
|
29
|
-
* ```typescript
|
|
30
|
-
* import { stripPageSuffix } from "./string-utils";
|
|
31
|
-
*
|
|
32
|
-
* async function listAppsPage(options: ListAppsOptions & { pageSize: number }) { ... }
|
|
33
|
-
*
|
|
34
|
-
* const methodName = stripPageSuffix(listAppsPage.name);
|
|
35
|
-
* const listAppsDefinition = createPaginatedFunction(
|
|
36
|
-
* listAppsPage,
|
|
37
|
-
* ListAppsSchema,
|
|
38
|
-
* createTelemetryCallback(context.eventEmission.emitMethodCalled, methodName),
|
|
39
|
-
* methodName,
|
|
40
|
-
* );
|
|
41
|
-
* ```
|
|
42
|
-
*/
|
|
43
|
-
export declare function createTelemetryCallback(emitMethodCalled: EventEmissionContext["eventEmission"]["emitMethodCalled"], methodName: string): TelemetryCallbacks;
|
|
44
|
-
//# sourceMappingURL=telemetry-utils.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"telemetry-utils.d.ts","sourceRoot":"","sources":["../../src/utils/telemetry-utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAC3D,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAErE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AACH,wBAAgB,uBAAuB,CACrC,gBAAgB,EAAE,oBAAoB,CAAC,eAAe,CAAC,CAAC,kBAAkB,CAAC,EAC3E,UAAU,EAAE,MAAM,GACjB,kBAAkB,CAcpB"}
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Creates a standardized telemetry callback for SDK method invocations.
|
|
3
|
-
*
|
|
4
|
-
* This factory eliminates boilerplate by providing a consistent implementation
|
|
5
|
-
* of the onMethodCalled callback used by createFunction and createPaginatedFunction.
|
|
6
|
-
*
|
|
7
|
-
* @param emitMethodCalled - The event emission function from EventEmissionContext
|
|
8
|
-
* @param methodName - The method name to report in telemetry. Use `function.name` to derive
|
|
9
|
-
* this automatically from the function declaration, ensuring DRY principles and making
|
|
10
|
-
* refactoring easier. Function names are preserved through bundling.
|
|
11
|
-
* @returns TelemetryCallbacks object with standardized onMethodCalled implementation
|
|
12
|
-
*
|
|
13
|
-
* @example
|
|
14
|
-
* Basic usage with createFunction:
|
|
15
|
-
* ```typescript
|
|
16
|
-
* async function listApps(options: ListAppsOptions) { ... }
|
|
17
|
-
*
|
|
18
|
-
* const listAppsDefinition = createFunction(
|
|
19
|
-
* listApps,
|
|
20
|
-
* ListAppsSchema,
|
|
21
|
-
* createTelemetryCallback(context.eventEmission.emitMethodCalled, listApps.name),
|
|
22
|
-
* );
|
|
23
|
-
* ```
|
|
24
|
-
*
|
|
25
|
-
* @example
|
|
26
|
-
* For paginated functions, use stripPageSuffix to remove the "Page" suffix:
|
|
27
|
-
* ```typescript
|
|
28
|
-
* import { stripPageSuffix } from "./string-utils";
|
|
29
|
-
*
|
|
30
|
-
* async function listAppsPage(options: ListAppsOptions & { pageSize: number }) { ... }
|
|
31
|
-
*
|
|
32
|
-
* const methodName = stripPageSuffix(listAppsPage.name);
|
|
33
|
-
* const listAppsDefinition = createPaginatedFunction(
|
|
34
|
-
* listAppsPage,
|
|
35
|
-
* ListAppsSchema,
|
|
36
|
-
* createTelemetryCallback(context.eventEmission.emitMethodCalled, methodName),
|
|
37
|
-
* methodName,
|
|
38
|
-
* );
|
|
39
|
-
* ```
|
|
40
|
-
*/
|
|
41
|
-
export function createTelemetryCallback(emitMethodCalled, methodName) {
|
|
42
|
-
return {
|
|
43
|
-
onMethodCalled: (data) => {
|
|
44
|
-
emitMethodCalled({
|
|
45
|
-
method_name: methodName,
|
|
46
|
-
execution_duration_ms: data.durationMs,
|
|
47
|
-
success_flag: data.success,
|
|
48
|
-
error_message: data.error?.message ?? null,
|
|
49
|
-
error_type: data.error?.constructor.name ?? null,
|
|
50
|
-
argument_count: data.argumentCount,
|
|
51
|
-
is_paginated: data.isPaginated,
|
|
52
|
-
});
|
|
53
|
-
},
|
|
54
|
-
};
|
|
55
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"telemetry-utils.test.d.ts","sourceRoot":"","sources":["../../src/utils/telemetry-utils.test.ts"],"names":[],"mappings":""}
|