@zapier/zapier-sdk 0.4.1 → 0.5.1
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 +13 -0
- package/README.md +343 -0
- package/dist/api/auth.d.ts +9 -0
- package/dist/api/auth.d.ts.map +1 -0
- package/dist/api/auth.js +25 -0
- package/dist/api/client.d.ts +9 -0
- package/dist/api/client.d.ts.map +1 -0
- package/dist/api/client.js +322 -0
- package/dist/api/debug.d.ts +13 -0
- package/dist/api/debug.d.ts.map +1 -0
- package/dist/api/debug.js +55 -0
- package/dist/api/index.d.ts +29 -0
- package/dist/api/index.d.ts.map +1 -0
- package/dist/api/index.js +41 -0
- package/dist/api/polling.d.ts +16 -0
- package/dist/api/polling.d.ts.map +1 -0
- package/dist/api/polling.js +45 -0
- package/dist/api/schemas.d.ts +2473 -0
- package/dist/api/schemas.d.ts.map +1 -0
- package/dist/api/schemas.js +355 -0
- package/dist/api/types.d.ts +75 -0
- package/dist/api/types.d.ts.map +1 -0
- package/dist/api/types.js +11 -0
- package/dist/auth.d.ts +34 -0
- package/dist/auth.d.ts.map +1 -0
- package/dist/auth.js +47 -0
- package/dist/constants.d.ts +10 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/constants.js +9 -0
- package/dist/index.cjs +2108 -1379
- package/dist/index.d.mts +2440 -620
- package/dist/index.d.ts +17 -892
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +20 -0
- package/dist/index.mjs +2093 -1362
- package/dist/plugins/api/index.d.ts +14 -0
- package/dist/plugins/api/index.d.ts.map +1 -0
- package/dist/plugins/api/index.js +21 -0
- package/dist/plugins/apps/index.d.ts +11 -0
- package/dist/plugins/apps/index.d.ts.map +1 -0
- package/dist/plugins/apps/index.js +91 -0
- package/dist/plugins/apps/types.d.ts +30 -0
- package/dist/plugins/apps/types.d.ts.map +1 -0
- package/dist/plugins/apps/types.js +2 -0
- package/dist/plugins/fetch/index.d.ts +21 -0
- package/dist/plugins/fetch/index.d.ts.map +1 -0
- package/dist/plugins/fetch/index.js +20 -0
- package/dist/plugins/findFirstAuthentication/index.d.ts +20 -0
- package/dist/plugins/findFirstAuthentication/index.d.ts.map +1 -0
- package/dist/plugins/findFirstAuthentication/index.js +24 -0
- package/dist/plugins/findFirstAuthentication/index.test.d.ts +2 -0
- package/dist/plugins/findFirstAuthentication/index.test.d.ts.map +1 -0
- package/dist/plugins/findFirstAuthentication/index.test.js +171 -0
- package/dist/plugins/findFirstAuthentication/schemas.d.ts +29 -0
- package/dist/plugins/findFirstAuthentication/schemas.d.ts.map +1 -0
- package/dist/plugins/findFirstAuthentication/schemas.js +18 -0
- package/dist/plugins/findUniqueAuthentication/index.d.ts +20 -0
- package/dist/plugins/findUniqueAuthentication/index.d.ts.map +1 -0
- package/dist/plugins/findUniqueAuthentication/index.js +31 -0
- package/dist/plugins/findUniqueAuthentication/index.test.d.ts +2 -0
- package/dist/plugins/findUniqueAuthentication/index.test.d.ts.map +1 -0
- package/dist/plugins/findUniqueAuthentication/index.test.js +152 -0
- package/dist/plugins/findUniqueAuthentication/schemas.d.ts +29 -0
- package/dist/plugins/findUniqueAuthentication/schemas.d.ts.map +1 -0
- package/dist/plugins/findUniqueAuthentication/schemas.js +18 -0
- package/dist/plugins/getAction/index.d.ts +23 -0
- package/dist/plugins/getAction/index.d.ts.map +1 -0
- package/dist/plugins/getAction/index.js +28 -0
- package/dist/plugins/getAction/index.test.d.ts +2 -0
- package/dist/plugins/getAction/index.test.d.ts.map +1 -0
- package/dist/plugins/getAction/index.test.js +186 -0
- package/dist/plugins/getAction/schemas.d.ts +23 -0
- package/dist/plugins/getAction/schemas.d.ts.map +1 -0
- package/dist/plugins/getAction/schemas.js +10 -0
- package/dist/plugins/getApp/index.d.ts +22 -0
- package/dist/plugins/getApp/index.d.ts.map +1 -0
- package/dist/plugins/getApp/index.js +39 -0
- package/dist/plugins/getApp/index.test.d.ts +2 -0
- package/dist/plugins/getApp/index.test.d.ts.map +1 -0
- package/dist/plugins/getApp/index.test.js +100 -0
- package/dist/plugins/getApp/schemas.d.ts +18 -0
- package/dist/plugins/getApp/schemas.d.ts.map +1 -0
- package/dist/plugins/getApp/schemas.js +10 -0
- package/dist/plugins/getAuthentication/index.d.ts +22 -0
- package/dist/plugins/getAuthentication/index.d.ts.map +1 -0
- package/dist/plugins/getAuthentication/index.js +41 -0
- package/dist/plugins/getAuthentication/index.test.d.ts +2 -0
- package/dist/plugins/getAuthentication/index.test.d.ts.map +1 -0
- package/dist/plugins/getAuthentication/index.test.js +205 -0
- package/dist/plugins/getAuthentication/schemas.d.ts +17 -0
- package/dist/plugins/getAuthentication/schemas.d.ts.map +1 -0
- package/dist/plugins/getAuthentication/schemas.js +11 -0
- package/dist/plugins/getProfile/index.d.ts +23 -0
- package/dist/plugins/getProfile/index.d.ts.map +1 -0
- package/dist/plugins/getProfile/index.js +29 -0
- package/dist/plugins/getProfile/schemas.d.ts +13 -0
- package/dist/plugins/getProfile/schemas.d.ts.map +1 -0
- package/dist/plugins/getProfile/schemas.js +5 -0
- package/dist/plugins/listActions/index.d.ts +28 -0
- package/dist/plugins/listActions/index.d.ts.map +1 -0
- package/dist/plugins/listActions/index.js +61 -0
- package/dist/plugins/listActions/index.test.d.ts +2 -0
- package/dist/plugins/listActions/index.test.d.ts.map +1 -0
- package/dist/plugins/listActions/index.test.js +467 -0
- package/dist/plugins/listActions/schemas.d.ts +29 -0
- package/dist/plugins/listActions/schemas.d.ts.map +1 -0
- package/dist/plugins/listActions/schemas.js +21 -0
- package/dist/plugins/listApps/index.d.ts +28 -0
- package/dist/plugins/listApps/index.d.ts.map +1 -0
- package/dist/plugins/listApps/index.js +62 -0
- package/dist/plugins/listApps/index.test.d.ts +2 -0
- package/dist/plugins/listApps/index.test.d.ts.map +1 -0
- package/dist/plugins/listApps/index.test.js +313 -0
- package/dist/plugins/listApps/schemas.d.ts +30 -0
- package/dist/plugins/listApps/schemas.d.ts.map +1 -0
- package/dist/plugins/listApps/schemas.js +23 -0
- package/dist/plugins/listAuthentications/index.d.ts +28 -0
- package/dist/plugins/listAuthentications/index.d.ts.map +1 -0
- package/dist/plugins/listAuthentications/index.js +77 -0
- package/dist/plugins/listAuthentications/index.test.d.ts +2 -0
- package/dist/plugins/listAuthentications/index.test.d.ts.map +1 -0
- package/dist/plugins/listAuthentications/index.test.js +564 -0
- package/dist/plugins/listAuthentications/schemas.d.ts +38 -0
- package/dist/plugins/listAuthentications/schemas.d.ts.map +1 -0
- package/dist/plugins/listAuthentications/schemas.js +28 -0
- package/dist/plugins/listInputFields/index.d.ts +28 -0
- package/dist/plugins/listInputFields/index.d.ts.map +1 -0
- package/dist/plugins/listInputFields/index.js +133 -0
- package/dist/plugins/listInputFields/index.test.d.ts +2 -0
- package/dist/plugins/listInputFields/index.test.d.ts.map +1 -0
- package/dist/plugins/listInputFields/index.test.js +325 -0
- package/dist/plugins/listInputFields/schemas.d.ts +38 -0
- package/dist/plugins/listInputFields/schemas.d.ts.map +1 -0
- package/dist/plugins/listInputFields/schemas.js +22 -0
- package/dist/plugins/registry/index.d.ts +11 -0
- package/dist/plugins/registry/index.d.ts.map +1 -0
- package/dist/plugins/registry/index.js +14 -0
- package/dist/plugins/request/index.d.ts +19 -0
- package/dist/plugins/request/index.d.ts.map +1 -0
- package/dist/plugins/request/index.js +62 -0
- package/dist/plugins/request/index.test.d.ts +2 -0
- package/dist/plugins/request/index.test.d.ts.map +1 -0
- package/dist/plugins/request/index.test.js +256 -0
- package/dist/plugins/request/schemas.d.ts +69 -0
- package/dist/plugins/request/schemas.d.ts.map +1 -0
- package/dist/plugins/request/schemas.js +42 -0
- package/dist/plugins/runAction/index.d.ts +28 -0
- package/dist/plugins/runAction/index.d.ts.map +1 -0
- package/dist/plugins/runAction/index.js +86 -0
- package/dist/plugins/runAction/index.test.d.ts +2 -0
- package/dist/plugins/runAction/index.test.d.ts.map +1 -0
- package/dist/plugins/runAction/index.test.js +320 -0
- package/dist/plugins/runAction/schemas.d.ts +37 -0
- package/dist/plugins/runAction/schemas.d.ts.map +1 -0
- package/dist/plugins/runAction/schemas.js +22 -0
- package/dist/resolvers/actionKey.d.ts +9 -0
- package/dist/resolvers/actionKey.d.ts.map +1 -0
- package/dist/resolvers/actionKey.js +19 -0
- package/dist/resolvers/actionType.d.ts +9 -0
- package/dist/resolvers/actionType.d.ts.map +1 -0
- package/dist/resolvers/actionType.js +22 -0
- package/dist/resolvers/appKey.d.ts +7 -0
- package/dist/resolvers/appKey.d.ts.map +1 -0
- package/dist/resolvers/appKey.js +5 -0
- package/dist/resolvers/authenticationId.d.ts +9 -0
- package/dist/resolvers/authenticationId.d.ts.map +1 -0
- package/dist/resolvers/authenticationId.js +33 -0
- package/dist/resolvers/index.d.ts +40 -0
- package/dist/resolvers/index.d.ts.map +1 -0
- package/dist/resolvers/index.js +91 -0
- package/dist/resolvers/inputs.d.ts +8 -0
- package/dist/resolvers/inputs.d.ts.map +1 -0
- package/dist/resolvers/inputs.js +14 -0
- package/dist/schemas/Action.d.ts +243 -0
- package/dist/schemas/Action.d.ts.map +1 -0
- package/dist/schemas/Action.js +34 -0
- package/dist/schemas/App.d.ts +26 -0
- package/dist/schemas/App.d.ts.map +1 -0
- package/dist/schemas/App.js +22 -0
- package/dist/schemas/Auth.d.ts +161 -0
- package/dist/schemas/Auth.d.ts.map +1 -0
- package/dist/schemas/Auth.js +41 -0
- package/dist/schemas/Field.d.ts +144 -0
- package/dist/schemas/Field.d.ts.map +1 -0
- package/dist/schemas/Field.js +105 -0
- package/dist/schemas/UserProfile.d.ts +163 -0
- package/dist/schemas/UserProfile.d.ts.map +1 -0
- package/dist/schemas/UserProfile.js +29 -0
- package/dist/sdk.d.ts +10 -0
- package/dist/sdk.d.ts.map +1 -0
- package/dist/sdk.js +94 -0
- package/dist/sdk.test.d.ts +2 -0
- package/dist/sdk.test.d.ts.map +1 -0
- package/dist/sdk.test.js +135 -0
- package/dist/types/domain.d.ts +36 -0
- package/dist/types/domain.d.ts.map +1 -0
- package/dist/types/domain.js +1 -0
- package/dist/types/domain.test.d.ts +2 -0
- package/dist/types/domain.test.d.ts.map +1 -0
- package/dist/types/domain.test.js +39 -0
- package/dist/types/errors.d.ts +143 -0
- package/dist/types/errors.d.ts.map +1 -0
- package/dist/types/errors.js +187 -0
- package/dist/types/events.d.ts +38 -0
- package/dist/types/events.d.ts.map +1 -0
- package/dist/types/events.js +7 -0
- package/dist/types/functions.d.ts +26 -0
- package/dist/types/functions.d.ts.map +1 -0
- package/dist/types/functions.js +4 -0
- package/dist/types/plugin.d.ts +61 -0
- package/dist/types/plugin.d.ts.map +1 -0
- package/dist/types/plugin.js +9 -0
- package/dist/types/properties.d.ts +22 -0
- package/dist/types/properties.d.ts.map +1 -0
- package/dist/types/properties.js +50 -0
- package/dist/types/sdk.d.ts +43 -0
- package/dist/types/sdk.d.ts.map +1 -0
- package/dist/types/sdk.js +4 -0
- package/dist/utils/array-utils.d.ts +31 -0
- package/dist/utils/array-utils.d.ts.map +1 -0
- package/dist/utils/array-utils.js +36 -0
- package/dist/utils/array-utils.test.d.ts +2 -0
- package/dist/utils/array-utils.test.d.ts.map +1 -0
- package/dist/utils/array-utils.test.js +107 -0
- package/dist/utils/domain-utils.d.ts +78 -0
- package/dist/utils/domain-utils.d.ts.map +1 -0
- package/dist/utils/domain-utils.js +218 -0
- package/dist/utils/domain-utils.test.d.ts +2 -0
- package/dist/utils/domain-utils.test.d.ts.map +1 -0
- package/dist/utils/domain-utils.test.js +192 -0
- package/dist/utils/function-utils.d.ts +45 -0
- package/dist/utils/function-utils.d.ts.map +1 -0
- package/dist/utils/function-utils.js +158 -0
- package/dist/utils/function-utils.test.d.ts +2 -0
- package/dist/utils/function-utils.test.d.ts.map +1 -0
- package/dist/utils/function-utils.test.js +110 -0
- package/dist/utils/pagination-utils.d.ts +37 -0
- package/dist/utils/pagination-utils.d.ts.map +1 -0
- package/dist/utils/pagination-utils.js +165 -0
- package/dist/utils/pagination-utils.test.d.ts +17 -0
- package/dist/utils/pagination-utils.test.d.ts.map +1 -0
- package/dist/utils/pagination-utils.test.js +461 -0
- package/dist/utils/schema-utils.d.ts +45 -0
- package/dist/utils/schema-utils.d.ts.map +1 -0
- package/dist/utils/schema-utils.js +65 -0
- package/dist/utils/validation.d.ts +4 -0
- package/dist/utils/validation.d.ts.map +1 -0
- package/dist/utils/validation.js +30 -0
- package/dist/utils/validation.test.d.ts +2 -0
- package/dist/utils/validation.test.d.ts.map +1 -0
- package/dist/utils/validation.test.js +43 -0
- package/package.json +12 -3
- package/src/api/client.ts +394 -171
- package/src/api/debug.ts +10 -1
- package/src/api/index.ts +0 -2
- package/src/api/polling.ts +28 -7
- package/src/api/schemas.ts +387 -0
- package/src/api/types.ts +72 -136
- package/src/constants.ts +10 -0
- package/src/index.ts +40 -19
- package/src/plugins/api/index.ts +47 -0
- package/src/plugins/apps/index.ts +25 -19
- package/src/plugins/apps/types.ts +7 -11
- package/src/plugins/fetch/index.ts +48 -40
- package/src/plugins/findFirstAuthentication/index.test.ts +206 -0
- package/src/plugins/findFirstAuthentication/index.ts +55 -0
- package/src/plugins/findFirstAuthentication/schemas.ts +41 -0
- package/src/plugins/findUniqueAuthentication/index.test.ts +197 -0
- package/src/plugins/findUniqueAuthentication/index.ts +72 -0
- package/src/plugins/findUniqueAuthentication/schemas.ts +42 -0
- package/src/plugins/getAction/index.test.ts +239 -0
- package/src/plugins/getAction/index.ts +57 -0
- package/src/plugins/getAction/schemas.ts +33 -0
- package/src/plugins/getApp/index.test.ts +127 -0
- package/src/plugins/getApp/index.ts +66 -0
- package/src/plugins/getApp/schemas.ts +38 -0
- package/src/plugins/getAuthentication/index.test.ts +284 -0
- package/src/plugins/getAuthentication/index.ts +86 -0
- package/src/plugins/getAuthentication/schemas.ts +31 -0
- package/src/plugins/getProfile/index.ts +55 -0
- package/src/plugins/getProfile/schemas.ts +26 -0
- package/src/plugins/listActions/index.test.ts +582 -0
- package/src/plugins/listActions/index.ts +115 -0
- package/src/plugins/listActions/schemas.ts +54 -0
- package/src/plugins/listApps/index.test.ts +357 -0
- package/src/plugins/listApps/index.ts +121 -0
- package/src/plugins/listApps/schemas.ts +49 -0
- package/src/plugins/listAuthentications/index.test.ts +709 -0
- package/src/plugins/listAuthentications/index.ts +136 -0
- package/src/plugins/listAuthentications/schemas.ts +60 -0
- package/src/plugins/listInputFields/index.test.ts +408 -0
- package/src/plugins/listInputFields/index.ts +204 -0
- package/src/plugins/listInputFields/schemas.ts +56 -0
- package/src/plugins/registry/index.ts +30 -0
- package/src/plugins/request/index.test.ts +329 -0
- package/src/plugins/request/index.ts +103 -0
- package/src/{functions → plugins}/request/schemas.ts +20 -9
- package/src/plugins/runAction/index.test.ts +387 -0
- package/src/plugins/runAction/index.ts +176 -0
- package/src/plugins/runAction/schemas.ts +53 -0
- package/src/resolvers/actionKey.ts +6 -4
- package/src/resolvers/actionType.ts +7 -2
- package/src/resolvers/appKey.ts +1 -1
- package/src/resolvers/authenticationId.ts +12 -3
- package/src/resolvers/inputs.ts +3 -1
- package/src/schemas/Action.ts +18 -12
- package/src/schemas/App.ts +11 -19
- package/src/schemas/Auth.ts +18 -13
- package/src/schemas/Field.ts +106 -11
- package/src/schemas/UserProfile.ts +43 -0
- package/src/sdk.test.ts +212 -0
- package/src/sdk.ts +132 -102
- package/src/types/domain.test.ts +50 -0
- package/src/types/domain.ts +43 -75
- package/src/types/errors.ts +275 -0
- package/src/types/functions.ts +27 -0
- package/src/types/optional-zapier-sdk-cli-login.d.ts +37 -0
- package/src/types/plugin.ts +105 -0
- package/src/types/properties.ts +4 -3
- package/src/types/sdk.ts +70 -48
- package/src/utils/array-utils.test.ts +131 -0
- package/src/utils/array-utils.ts +41 -0
- package/src/utils/domain-utils.test.ts +239 -0
- package/src/utils/domain-utils.ts +283 -0
- package/src/utils/function-utils.test.ts +141 -0
- package/src/utils/function-utils.ts +245 -0
- package/src/utils/pagination-utils.test.ts +620 -0
- package/src/utils/pagination-utils.ts +242 -0
- package/src/utils/validation.test.ts +50 -0
- package/src/utils/validation.ts +44 -0
- package/tsconfig.build.json +16 -2
- package/tsconfig.json +3 -1
- package/tsconfig.tsbuildinfo +1 -0
- package/tsup.config.ts +2 -0
- package/src/functions/bundleCode/index.ts +0 -78
- package/src/functions/bundleCode/info.ts +0 -9
- package/src/functions/bundleCode/schemas.ts +0 -30
- package/src/functions/findFirstAuthentication/index.ts +0 -24
- package/src/functions/findFirstAuthentication/info.ts +0 -9
- package/src/functions/findFirstAuthentication/schemas.ts +0 -50
- package/src/functions/findUniqueAuthentication/index.ts +0 -35
- package/src/functions/findUniqueAuthentication/info.ts +0 -9
- package/src/functions/findUniqueAuthentication/schemas.ts +0 -50
- package/src/functions/generateTypes/index.ts +0 -363
- package/src/functions/generateTypes/info.ts +0 -9
- package/src/functions/generateTypes/schemas.ts +0 -31
- package/src/functions/getAction/index.ts +0 -33
- package/src/functions/getAction/info.ts +0 -9
- package/src/functions/getAction/schemas.ts +0 -25
- package/src/functions/getApp/index.ts +0 -41
- package/src/functions/getApp/info.ts +0 -9
- package/src/functions/getApp/schemas.ts +0 -20
- package/src/functions/getAuthentication/index.ts +0 -50
- package/src/functions/getAuthentication/info.ts +0 -9
- package/src/functions/getAuthentication/schemas.ts +0 -29
- package/src/functions/listActions/index.ts +0 -149
- package/src/functions/listActions/info.ts +0 -9
- package/src/functions/listActions/schemas.ts +0 -30
- package/src/functions/listApps/index.ts +0 -60
- package/src/functions/listApps/info.ts +0 -9
- package/src/functions/listApps/schemas.ts +0 -32
- package/src/functions/listAuthentications/index.ts +0 -162
- package/src/functions/listAuthentications/info.ts +0 -9
- package/src/functions/listAuthentications/schemas.ts +0 -50
- package/src/functions/listFields/index.ts +0 -86
- package/src/functions/listFields/info.ts +0 -9
- package/src/functions/listFields/schemas.ts +0 -36
- package/src/functions/request/index.ts +0 -150
- package/src/functions/request/info.ts +0 -11
- package/src/functions/runAction/index.ts +0 -127
- package/src/functions/runAction/info.ts +0 -9
- package/src/functions/runAction/schemas.ts +0 -34
- package/src/plugins/apps/info.ts +0 -12
- package/src/plugins/fetch/types.ts +0 -2
- /package/src/{schema-utils.ts → utils/schema-utils.ts} +0 -0
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ------------------------------
|
|
3
|
+
* Plugin Type System with Explicit Context Dependencies
|
|
4
|
+
* ------------------------------
|
|
5
|
+
*
|
|
6
|
+
* This system makes context dependencies explicit to restore TypeScript's
|
|
7
|
+
* ability to catch missing context at compile time.
|
|
8
|
+
*/
|
|
9
|
+
export interface PluginDependencies<TSdk = {}, TContext = {}> {
|
|
10
|
+
sdk: TSdk;
|
|
11
|
+
context: TContext;
|
|
12
|
+
}
|
|
13
|
+
export interface PluginProvides extends Record<string, any> {
|
|
14
|
+
context?: Record<string, any>;
|
|
15
|
+
}
|
|
16
|
+
export type ExtractSdkProperties<T extends Record<string, any>> = Omit<T, "context">;
|
|
17
|
+
export type ExtractContextProperties<T extends PluginProvides> = T["context"];
|
|
18
|
+
export type GetSdkType<TPluginProvides extends PluginProvides> = ExtractSdkProperties<TPluginProvides> & {
|
|
19
|
+
getContext(): NonNullable<ExtractContextProperties<TPluginProvides>>;
|
|
20
|
+
};
|
|
21
|
+
export type PluginOptions<TSdk = {}, TContext = {}> = {
|
|
22
|
+
sdk: TSdk;
|
|
23
|
+
context: TContext & {
|
|
24
|
+
meta: Record<string, any>;
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* Plugin interface — now has 3 type params:
|
|
29
|
+
*
|
|
30
|
+
* TRequiresContext = what this plugin *needs* in context
|
|
31
|
+
* TProvides = what this plugin *returns* (sdk + context)
|
|
32
|
+
* TSdk = current sdk shape when plugin runs
|
|
33
|
+
*/
|
|
34
|
+
export interface Plugin<TSdk = {}, TRequiresContext = {}, TProvides extends PluginProvides = PluginProvides> {
|
|
35
|
+
(params: {
|
|
36
|
+
sdk: TSdk;
|
|
37
|
+
context: TRequiresContext & {
|
|
38
|
+
meta: Record<string, any>;
|
|
39
|
+
};
|
|
40
|
+
}): TProvides;
|
|
41
|
+
}
|
|
42
|
+
type MissingContextKeys<TRequired, TCurrent> = TRequired extends Record<string, any> ? TCurrent extends Record<string, any> ? {
|
|
43
|
+
[K in keyof TRequired]: K extends keyof TCurrent ? never : K;
|
|
44
|
+
}[keyof TRequired] : keyof TRequired : never;
|
|
45
|
+
type ContextError<TRequired, TCurrent> = MissingContextKeys<TRequired, TCurrent> extends never ? never : MissingContextKeys<TRequired, TCurrent> extends infer Missing ? Missing extends string ? `❌ Missing required context: { ${Missing}: any }` : Missing extends number ? `❌ Missing required context: { ${Missing}: any }` : `❌ Missing required context properties. Required: ${keyof TRequired extends string ? keyof TRequired : "unknown"}, Available: ${keyof TCurrent extends string ? keyof TCurrent : "unknown"}` : "❌ Context requirement not satisfied";
|
|
46
|
+
/**
|
|
47
|
+
* SDK interface — result of createSdk()
|
|
48
|
+
*
|
|
49
|
+
* addPlugin now enforces that TRequiresContext is assignable to TCurrentContext.
|
|
50
|
+
* If not, TypeScript will emit a detailed error showing missing properties.
|
|
51
|
+
*/
|
|
52
|
+
export type Sdk<TCurrentSdk = {}, TCurrentContext = {
|
|
53
|
+
meta: Record<string, any>;
|
|
54
|
+
}> = TCurrentSdk & {
|
|
55
|
+
addPlugin<TRequiresContext, TProvides extends PluginProvides>(plugin: Plugin<TCurrentSdk & {
|
|
56
|
+
getContext(): TCurrentContext;
|
|
57
|
+
}, TRequiresContext, TProvides>, options?: any): TCurrentContext extends TRequiresContext ? Sdk<TCurrentSdk & ExtractSdkProperties<TProvides>, TCurrentContext & NonNullable<ExtractContextProperties<TProvides>>> : ContextError<TRequiresContext, TCurrentContext>;
|
|
58
|
+
getContext(): TCurrentContext;
|
|
59
|
+
};
|
|
60
|
+
export {};
|
|
61
|
+
//# sourceMappingURL=plugin.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../src/types/plugin.ts"],"names":[],"m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AC,SAAS,CAAC,CAAC,CACnE,GACD,YAAY,CAAC,gBAAgB,EAAE,eAAe,CAAC,CAAC;IACpD,UAAU,IAAI,eAAe,CAAC;CAC/B,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ------------------------------
|
|
3
|
+
* Plugin Type System with Explicit Context Dependencies
|
|
4
|
+
* ------------------------------
|
|
5
|
+
*
|
|
6
|
+
* This system makes context dependencies explicit to restore TypeScript's
|
|
7
|
+
* ability to catch missing context at compile time.
|
|
8
|
+
*/
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare const AppKeyPropertySchema: z.ZodString;
|
|
3
|
+
export declare const ActionTypePropertySchema: z.ZodEnum<["read", "read_bulk", "write", "run", "search", "search_or_write", "search_and_write", "filter"]>;
|
|
4
|
+
export declare const ActionKeyPropertySchema: z.ZodString;
|
|
5
|
+
export declare const AuthenticationIdPropertySchema: z.ZodNumber;
|
|
6
|
+
export declare const InputsPropertySchema: z.ZodRecord<z.ZodString, z.ZodAny>;
|
|
7
|
+
export declare const LimitPropertySchema: z.ZodDefault<z.ZodNumber>;
|
|
8
|
+
export declare const OffsetPropertySchema: z.ZodDefault<z.ZodNumber>;
|
|
9
|
+
export declare const OutputPropertySchema: z.ZodString;
|
|
10
|
+
export declare const DebugPropertySchema: z.ZodDefault<z.ZodBoolean>;
|
|
11
|
+
export declare const ParamsPropertySchema: z.ZodRecord<z.ZodString, z.ZodAny>;
|
|
12
|
+
export type AppKeyProperty = z.infer<typeof AppKeyPropertySchema>;
|
|
13
|
+
export type ActionTypeProperty = z.infer<typeof ActionTypePropertySchema>;
|
|
14
|
+
export type ActionKeyProperty = z.infer<typeof ActionKeyPropertySchema>;
|
|
15
|
+
export type AuthenticationIdProperty = z.infer<typeof AuthenticationIdPropertySchema>;
|
|
16
|
+
export type InputsProperty = z.infer<typeof InputsPropertySchema>;
|
|
17
|
+
export type LimitProperty = z.infer<typeof LimitPropertySchema>;
|
|
18
|
+
export type OffsetProperty = z.infer<typeof OffsetPropertySchema>;
|
|
19
|
+
export type OutputProperty = z.infer<typeof OutputPropertySchema>;
|
|
20
|
+
export type DebugProperty = z.infer<typeof DebugPropertySchema>;
|
|
21
|
+
export type ParamsProperty = z.infer<typeof ParamsPropertySchema>;
|
|
22
|
+
//# sourceMappingURL=properties.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"properties.d.ts","sourceRoot":"","sources":["../../src/types/properties.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAOxB,eAAO,MAAM,oBAAoB,aAEhC,CAAC;AAEF,eAAO,MAAM,wBAAwB,6GAW4B,CAAC;AAElE,eAAO,MAAM,uBAAuB,aAGA,CAAC;AAErC,eAAO,MAAM,8BAA8B,aAGY,CAAC;AAExD,eAAO,MAAM,oBAAoB,oCAEa,CAAC;AAE/C,eAAO,MAAM,mBAAmB,2BAMgB,CAAC;AAEjD,eAAO,MAAM,oBAAoB,2BAKoB,CAAC;AAEtD,eAAO,MAAM,oBAAoB,aAA0C,CAAC;AAE5E,eAAO,MAAM,mBAAmB,4BAGG,CAAC;AAEpC,eAAO,MAAM,oBAAoB,oCAEG,CAAC;AAGrC,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAC;AAClE,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,wBAAwB,CAAC,CAAC;AAC1E,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,uBAAuB,CAAC,CAAC;AACxE,MAAM,MAAM,wBAAwB,GAAG,CAAC,CAAC,KAAK,CAC5C,OAAO,8BAA8B,CACtC,CAAC;AACF,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAC;AAClE,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAC;AAChE,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAC;AAClE,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAC;AAClE,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAC;AAChE,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAC"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { withPositional } from "../utils/schema-utils";
|
|
3
|
+
import { MAX_PAGE_LIMIT } from "../constants";
|
|
4
|
+
// Shared property definitions for common parameters across functions
|
|
5
|
+
// These can be reused in function schemas without duplication
|
|
6
|
+
export const AppKeyPropertySchema = withPositional(z.string().min(1).describe("App key (e.g., 'SlackCLIAPI')"));
|
|
7
|
+
export const ActionTypePropertySchema = z
|
|
8
|
+
.enum([
|
|
9
|
+
"read",
|
|
10
|
+
"read_bulk",
|
|
11
|
+
"write",
|
|
12
|
+
"run",
|
|
13
|
+
"search",
|
|
14
|
+
"search_or_write",
|
|
15
|
+
"search_and_write",
|
|
16
|
+
"filter",
|
|
17
|
+
])
|
|
18
|
+
.describe("Action type that matches the action's defined type");
|
|
19
|
+
export const ActionKeyPropertySchema = z
|
|
20
|
+
.string()
|
|
21
|
+
.min(1)
|
|
22
|
+
.describe("Action key to execute");
|
|
23
|
+
export const AuthenticationIdPropertySchema = z
|
|
24
|
+
.number()
|
|
25
|
+
.int()
|
|
26
|
+
.describe("Authentication ID to use for this action");
|
|
27
|
+
export const InputsPropertySchema = z
|
|
28
|
+
.record(z.any())
|
|
29
|
+
.describe("Input parameters for the action");
|
|
30
|
+
export const LimitPropertySchema = z
|
|
31
|
+
.number()
|
|
32
|
+
.int()
|
|
33
|
+
.min(1)
|
|
34
|
+
.max(MAX_PAGE_LIMIT)
|
|
35
|
+
.default(50)
|
|
36
|
+
.describe("Maximum number of items to return");
|
|
37
|
+
export const OffsetPropertySchema = z
|
|
38
|
+
.number()
|
|
39
|
+
.int()
|
|
40
|
+
.min(0)
|
|
41
|
+
.default(0)
|
|
42
|
+
.describe("Number of items to skip for pagination");
|
|
43
|
+
export const OutputPropertySchema = z.string().describe("Output file path");
|
|
44
|
+
export const DebugPropertySchema = z
|
|
45
|
+
.boolean()
|
|
46
|
+
.default(false)
|
|
47
|
+
.describe("Enable debug logging");
|
|
48
|
+
export const ParamsPropertySchema = z
|
|
49
|
+
.record(z.any())
|
|
50
|
+
.describe("Additional parameters");
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SDK-related types and interfaces
|
|
3
|
+
*/
|
|
4
|
+
import type { EventCallback } from "./events";
|
|
5
|
+
export interface BaseSdkOptions {
|
|
6
|
+
token?: string;
|
|
7
|
+
getToken?: () => Promise<string | undefined>;
|
|
8
|
+
onEvent?: EventCallback;
|
|
9
|
+
fetch?: typeof fetch;
|
|
10
|
+
baseUrl?: string;
|
|
11
|
+
debug?: boolean;
|
|
12
|
+
}
|
|
13
|
+
import type { ListInputFieldsSdkFunction } from "../plugins/listInputFields/schemas";
|
|
14
|
+
import type { GetAuthenticationSdkFunction } from "../plugins/getAuthentication/schemas";
|
|
15
|
+
import type { FindFirstAuthenticationSdkFunction } from "../plugins/findFirstAuthentication/schemas";
|
|
16
|
+
import type { FindUniqueAuthenticationSdkFunction } from "../plugins/findUniqueAuthentication/schemas";
|
|
17
|
+
import type { RelayRequestSdkFunction } from "../plugins/request/schemas";
|
|
18
|
+
import type { z } from "zod";
|
|
19
|
+
import { RegistryPluginProvides } from "../plugins/registry";
|
|
20
|
+
import { GetProfilePluginProvides } from "../plugins/getProfile";
|
|
21
|
+
import { AppsPluginProvides } from "../plugins/apps";
|
|
22
|
+
import { FetchPluginProvides } from "../plugins/fetch";
|
|
23
|
+
import { ListAppsPluginProvides } from "../plugins/listApps";
|
|
24
|
+
import { GetAppPluginProvides } from "../plugins/getApp";
|
|
25
|
+
import { ListActionsPluginProvides } from "../plugins/listActions";
|
|
26
|
+
import { GetActionPluginProvides } from "../plugins/getAction";
|
|
27
|
+
import { RunActionPluginProvides } from "../plugins/runAction";
|
|
28
|
+
import { ListAuthenticationsPluginProvides } from "../plugins/listAuthentications";
|
|
29
|
+
import { GetAuthenticationPluginProvides } from "../plugins/getAuthentication";
|
|
30
|
+
import { FindFirstAuthenticationPluginProvides } from "../plugins/findFirstAuthentication";
|
|
31
|
+
import { FindUniqueAuthenticationPluginProvides } from "../plugins/findUniqueAuthentication";
|
|
32
|
+
import { ListInputFieldsPluginProvides } from "../plugins/listInputFields";
|
|
33
|
+
import { RequestPluginProvides } from "../plugins/request";
|
|
34
|
+
import { GetSdkType } from "./plugin";
|
|
35
|
+
export interface FunctionRegistryEntry {
|
|
36
|
+
name: string;
|
|
37
|
+
inputSchema: z.ZodSchema;
|
|
38
|
+
implementation: Function;
|
|
39
|
+
}
|
|
40
|
+
export interface ZapierSdkFunctions extends ListInputFieldsSdkFunction, GetAuthenticationSdkFunction, FindFirstAuthenticationSdkFunction, FindUniqueAuthenticationSdkFunction, RelayRequestSdkFunction {
|
|
41
|
+
}
|
|
42
|
+
export type ZapierSdk = GetSdkType<RegistryPluginProvides & FetchPluginProvides & AppsPluginProvides & ListAppsPluginProvides & GetAppPluginProvides & ListActionsPluginProvides & GetActionPluginProvides & RunActionPluginProvides & ListAuthenticationsPluginProvides & GetAuthenticationPluginProvides & FindFirstAuthenticationPluginProvides & FindUniqueAuthenticationPluginProvides & ListInputFieldsPluginProvides & RequestPluginProvides & GetProfilePluginProvides>;
|
|
43
|
+
//# sourceMappingURL=sdk.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sdk.d.ts","sourceRoot":"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D,OAAO,EAAE,iCAAiC,EAAE,MAAM,gCAAgC,CAAC;AACnF,OAAO,EAAE,+BAA+B,EAAE,MAAM,8BAA8B,CAAC;AAC/E,OAAO,EAAE,qCAAqC,EAAE,MAAM,oCAAoC,CAAC;AAC3F,OAAO,EAAE,sCAAsC,EAAE,MAAM,qCAAqC,CAAC;AAC7F,OAAO,EAAE,6BAA6B,EAAE,MAAM,4BAA4B,CAAC;AAC3E,OAAO,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAC3D,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAMtC,MAAM,WAAW,qBAAqB;IACpC,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,CAAC,CAAC,SAAS,CAAC;IACzB,cAAc,EAAE,QAAQ,CAAC;CAC1B;AAGD,MAAM,WAAW,kBACf,SAAQ,0BAA0B,EAChC,4BAA4B,EAC5B,kCAAkC,EAClC,mCAAmC,EACnC,uBAAuB;CAE1B;AAUD,MAAM,MAAM,SAAS,GAAG,UAAU,CAChC,sBAAsB,GACpB,mBAAmB,GACnB,kBAAkB,GAClB,sBAAsB,GACtB,oBAAoB,GACpB,yBAAyB,GACzB,uBAAuB,GACvB,uBAAuB,GACvB,iCAAiC,GACjC,+BAA+B,GAC/B,qCAAqC,GACrC,sCAAsC,GACtC,6BAA6B,GAC7B,qBAAqB,GACrB,wBAAwB,CAC3B,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Array utility functions for working with async iterators and arrays
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Creates an array from an async iterable, similar to Array.from() but for async iterables
|
|
6
|
+
*
|
|
7
|
+
* @param asyncIterable - An async iterable to convert to an array
|
|
8
|
+
* @returns Promise that resolves to an array containing all items from the async iterable
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* async function* generateNumbers() {
|
|
12
|
+
* yield 1;
|
|
13
|
+
* yield 2;
|
|
14
|
+
* yield 3;
|
|
15
|
+
* }
|
|
16
|
+
*
|
|
17
|
+
* const numbers = await fromAsync(generateNumbers()); // [1, 2, 3]
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* // With async generator that fetches data
|
|
21
|
+
* async function* fetchUsers() {
|
|
22
|
+
* for (let page = 1; page <= 3; page++) {
|
|
23
|
+
* const users = await fetchUsersPage(page);
|
|
24
|
+
* yield* users;
|
|
25
|
+
* }
|
|
26
|
+
* }
|
|
27
|
+
*
|
|
28
|
+
* const allUsers = await fromAsync(fetchUsers());
|
|
29
|
+
*/
|
|
30
|
+
export declare function toArrayFromAsync<T>(asyncIterable: AsyncIterable<T>): Promise<T[]>;
|
|
31
|
+
//# sourceMappingURL=array-utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"array-utils.d.ts","sourceRoot":"","sources":["../../src/utils/array-utils.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAsB,gBAAgB,CAAC,CAAC,EACtC,aAAa,EAAE,aAAa,CAAC,CAAC,CAAC,GAC9B,OAAO,CAAC,CAAC,EAAE,CAAC,CAQd"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Array utility functions for working with async iterators and arrays
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Creates an array from an async iterable, similar to Array.from() but for async iterables
|
|
6
|
+
*
|
|
7
|
+
* @param asyncIterable - An async iterable to convert to an array
|
|
8
|
+
* @returns Promise that resolves to an array containing all items from the async iterable
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* async function* generateNumbers() {
|
|
12
|
+
* yield 1;
|
|
13
|
+
* yield 2;
|
|
14
|
+
* yield 3;
|
|
15
|
+
* }
|
|
16
|
+
*
|
|
17
|
+
* const numbers = await fromAsync(generateNumbers()); // [1, 2, 3]
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* // With async generator that fetches data
|
|
21
|
+
* async function* fetchUsers() {
|
|
22
|
+
* for (let page = 1; page <= 3; page++) {
|
|
23
|
+
* const users = await fetchUsersPage(page);
|
|
24
|
+
* yield* users;
|
|
25
|
+
* }
|
|
26
|
+
* }
|
|
27
|
+
*
|
|
28
|
+
* const allUsers = await fromAsync(fetchUsers());
|
|
29
|
+
*/
|
|
30
|
+
export async function toArrayFromAsync(asyncIterable) {
|
|
31
|
+
const result = [];
|
|
32
|
+
for await (const item of asyncIterable) {
|
|
33
|
+
result.push(item);
|
|
34
|
+
}
|
|
35
|
+
return result;
|
|
36
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"array-utils.test.d.ts","sourceRoot":"","sources":["../../src/utils/array-utils.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { describe, it, expect } from "vitest";
|
|
2
|
+
import { toArrayFromAsync } from "./array-utils";
|
|
3
|
+
describe("array-utils", () => {
|
|
4
|
+
describe("fromAsync", () => {
|
|
5
|
+
it("should convert async generator to array", async () => {
|
|
6
|
+
async function* generateNumbers() {
|
|
7
|
+
yield 1;
|
|
8
|
+
yield 2;
|
|
9
|
+
yield 3;
|
|
10
|
+
}
|
|
11
|
+
const result = await toArrayFromAsync(generateNumbers());
|
|
12
|
+
expect(result).toEqual([1, 2, 3]);
|
|
13
|
+
});
|
|
14
|
+
it("should handle empty async generator", async () => {
|
|
15
|
+
async function* generateNothing() {
|
|
16
|
+
// yield nothing
|
|
17
|
+
}
|
|
18
|
+
const result = await toArrayFromAsync(generateNothing());
|
|
19
|
+
expect(result).toEqual([]);
|
|
20
|
+
});
|
|
21
|
+
it("should handle async generator with async operations", async () => {
|
|
22
|
+
async function* generateWithDelay() {
|
|
23
|
+
for (let i = 1; i <= 3; i++) {
|
|
24
|
+
await new Promise((resolve) => setTimeout(resolve, 1)); // Small delay
|
|
25
|
+
yield i * 10;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
const result = await toArrayFromAsync(generateWithDelay());
|
|
29
|
+
expect(result).toEqual([10, 20, 30]);
|
|
30
|
+
});
|
|
31
|
+
it("should handle async generator that yields different types", async () => {
|
|
32
|
+
async function* generateMixed() {
|
|
33
|
+
yield "hello";
|
|
34
|
+
yield 42;
|
|
35
|
+
yield { name: "test" };
|
|
36
|
+
yield [1, 2, 3];
|
|
37
|
+
}
|
|
38
|
+
const result = await toArrayFromAsync(generateMixed());
|
|
39
|
+
expect(result).toEqual(["hello", 42, { name: "test" }, [1, 2, 3]]);
|
|
40
|
+
});
|
|
41
|
+
it("should handle async generator with error", async () => {
|
|
42
|
+
async function* generateWithError() {
|
|
43
|
+
yield 1;
|
|
44
|
+
yield 2;
|
|
45
|
+
throw new Error("Test error");
|
|
46
|
+
}
|
|
47
|
+
await expect(toArrayFromAsync(generateWithError())).rejects.toThrow("Test error");
|
|
48
|
+
});
|
|
49
|
+
it("should handle async iterable from array with Symbol.asyncIterator", async () => {
|
|
50
|
+
const asyncIterable = {
|
|
51
|
+
async *[Symbol.asyncIterator]() {
|
|
52
|
+
for (const item of ["a", "b", "c"]) {
|
|
53
|
+
yield item;
|
|
54
|
+
}
|
|
55
|
+
},
|
|
56
|
+
};
|
|
57
|
+
const result = await toArrayFromAsync(asyncIterable);
|
|
58
|
+
expect(result).toEqual(["a", "b", "c"]);
|
|
59
|
+
});
|
|
60
|
+
it("should handle large async generator efficiently", async () => {
|
|
61
|
+
async function* generateLargeSequence() {
|
|
62
|
+
for (let i = 0; i < 1000; i++) {
|
|
63
|
+
yield i;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
const result = await toArrayFromAsync(generateLargeSequence());
|
|
67
|
+
expect(result).toHaveLength(1000);
|
|
68
|
+
expect(result[0]).toBe(0);
|
|
69
|
+
expect(result[999]).toBe(999);
|
|
70
|
+
});
|
|
71
|
+
it("should handle async generator that yields promises (promises are auto-awaited)", async () => {
|
|
72
|
+
async function* generatePromises() {
|
|
73
|
+
yield Promise.resolve("first");
|
|
74
|
+
yield Promise.resolve("second");
|
|
75
|
+
}
|
|
76
|
+
const result = await toArrayFromAsync(generatePromises());
|
|
77
|
+
// for await automatically awaits promises, so we get resolved values
|
|
78
|
+
expect(result).toEqual(["first", "second"]);
|
|
79
|
+
});
|
|
80
|
+
it("should handle async generator that yields already resolved values", async () => {
|
|
81
|
+
async function* generateResolvedValues() {
|
|
82
|
+
yield await Promise.resolve("first");
|
|
83
|
+
yield await Promise.resolve("second");
|
|
84
|
+
}
|
|
85
|
+
const result = await toArrayFromAsync(generateResolvedValues());
|
|
86
|
+
// The resolved values are yielded directly
|
|
87
|
+
expect(result).toEqual(["first", "second"]);
|
|
88
|
+
});
|
|
89
|
+
it("should maintain order of async generator items", async () => {
|
|
90
|
+
async function* generateInOrder() {
|
|
91
|
+
for (let i = 1; i <= 5; i++) {
|
|
92
|
+
// Simulate varying delays
|
|
93
|
+
await new Promise((resolve) => setTimeout(resolve, Math.random() * 10));
|
|
94
|
+
yield `item-${i}`;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
const result = await toArrayFromAsync(generateInOrder());
|
|
98
|
+
expect(result).toEqual([
|
|
99
|
+
"item-1",
|
|
100
|
+
"item-2",
|
|
101
|
+
"item-3",
|
|
102
|
+
"item-4",
|
|
103
|
+
"item-5",
|
|
104
|
+
]);
|
|
105
|
+
});
|
|
106
|
+
});
|
|
107
|
+
});
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Domain utility functions for working with app identifiers and data normalization
|
|
3
|
+
*/
|
|
4
|
+
import type { Action, App, Authentication, Implementation, ImplementationMeta, Service } from "../api/types";
|
|
5
|
+
import type { ActionItem, AppItem, AuthenticationItem } from "../types/domain";
|
|
6
|
+
/**
|
|
7
|
+
* Splits a versioned key to extract the base key and version
|
|
8
|
+
*
|
|
9
|
+
* @param versionedKey - Versioned key in format "KeyName@version" (e.g., "SlackCLIAPI@1.21.1")
|
|
10
|
+
* @returns Tuple of [baseKey, version] or [versionedKey, undefined] if no @ symbol
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* splitVersionedKey("SlackCLIAPI@1.21.1") // ["SlackCLIAPI", "1.21.1"]
|
|
14
|
+
* splitVersionedKey("SomeAPI") // ["SomeAPI", undefined]
|
|
15
|
+
*/
|
|
16
|
+
export declare function splitVersionedKey(versionedKey: string): [string, string | undefined];
|
|
17
|
+
/**
|
|
18
|
+
* Converts an API App to an AppItem with normalized field names
|
|
19
|
+
*
|
|
20
|
+
* @param app - Raw App from API
|
|
21
|
+
* @returns Normalized AppItem
|
|
22
|
+
*/
|
|
23
|
+
export declare function normalizeAppItem(app: App): AppItem;
|
|
24
|
+
/**
|
|
25
|
+
* Converts an Implementation to an AppItem with normalized field names
|
|
26
|
+
*
|
|
27
|
+
* @param implementation - Raw Implementation from API
|
|
28
|
+
* @returns Normalized AppItem
|
|
29
|
+
*/
|
|
30
|
+
export declare function normalizeImplementationToAppItem(implementation: Implementation): AppItem;
|
|
31
|
+
/**
|
|
32
|
+
* Converts a lightweight ImplementationMeta to a slimmed AppItem
|
|
33
|
+
*
|
|
34
|
+
* @param implementationMeta - Raw ImplementationMeta from API
|
|
35
|
+
* @returns Normalized AppItem with essential fields only
|
|
36
|
+
*/
|
|
37
|
+
export declare function normalizeImplementationMetaToAppItem(implementationMeta: ImplementationMeta): AppItem;
|
|
38
|
+
export declare function normalizeServiceToAppItem(service: Service): AppItem;
|
|
39
|
+
/**
|
|
40
|
+
* Converts an API Authentication to an AuthenticationItem with normalized field names
|
|
41
|
+
*
|
|
42
|
+
* @param auth - Raw Authentication from API
|
|
43
|
+
* @param options - Additional fields to include
|
|
44
|
+
* @param options.app_key - selected_api from implementations endpoint
|
|
45
|
+
* @param options.version - Version extracted from selected_api
|
|
46
|
+
* @returns Normalized AuthenticationItem
|
|
47
|
+
*/
|
|
48
|
+
export declare function normalizeAuthenticationItem(auth: Authentication, options?: {
|
|
49
|
+
app_key?: string;
|
|
50
|
+
version?: string;
|
|
51
|
+
}): AuthenticationItem;
|
|
52
|
+
export declare function normalizeActionItem(action: Action): ActionItem;
|
|
53
|
+
/**
|
|
54
|
+
* Groups app keys by their type based on format patterns
|
|
55
|
+
*
|
|
56
|
+
* @param appKeys Array of app key strings to categorize
|
|
57
|
+
* @returns Object with arrays of keys grouped by type: selectedApi (CLI APIs), slug (everything else)
|
|
58
|
+
*
|
|
59
|
+
* @example
|
|
60
|
+
* groupVersionedAppKeysByType([
|
|
61
|
+
* 'FormatterCLIAPI@1.0.0',
|
|
62
|
+
* 'slack',
|
|
63
|
+
* 'AnotherAPI'
|
|
64
|
+
* ])
|
|
65
|
+
* // Returns: {
|
|
66
|
+
* // selectedApi: ['FormatterCLIAPI@1.0.0', 'AnotherAPI'],
|
|
67
|
+
* // slug: ['slack']
|
|
68
|
+
* // }
|
|
69
|
+
*/
|
|
70
|
+
export declare function groupVersionedAppKeysByType(appKeys: string[]): {
|
|
71
|
+
selectedApi: string[];
|
|
72
|
+
slug: string[];
|
|
73
|
+
};
|
|
74
|
+
export declare function groupAppKeysByType(appKeys: string[]): {
|
|
75
|
+
selectedApi: string[];
|
|
76
|
+
slug: string[];
|
|
77
|
+
};
|
|
78
|
+
//# sourceMappingURL=domain-utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"domain-utils.d.ts","sourceRoot":"","sources":["../../src/utils/domain-utils.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EACV,MAAM,EACN,GAAG,EACH,cAAc,EACd,cAAc,EACd,kBAAkB,EAClB,OAAO,EACR,MAAM,cAAc,CAAC;AACtB,OAAO,KAAK,EAAE,UAAU,EAAE,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAE/E;;;;;;;;;GASG;AACH,wBAAgB,iBAAiB,CAC/B,YAAY,EAAE,MAAM,GACnB,CAAC,MAAM,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