@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
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
import type { BundleCodeOptions } from "./schemas";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Bundle TypeScript code into executable JavaScript
|
|
5
|
-
*
|
|
6
|
-
* This function can be used standalone without instantiating a full SDK,
|
|
7
|
-
* which enables better tree-shaking in applications that only need this functionality.
|
|
8
|
-
*
|
|
9
|
-
* @param options - Bundling configuration options
|
|
10
|
-
* @returns Promise<string> - Bundled JavaScript code
|
|
11
|
-
*/
|
|
12
|
-
export async function bundleCode(options: BundleCodeOptions): Promise<string> {
|
|
13
|
-
const {
|
|
14
|
-
input,
|
|
15
|
-
output,
|
|
16
|
-
target = "es2020",
|
|
17
|
-
cjs = false,
|
|
18
|
-
minify = false,
|
|
19
|
-
string: returnString = false,
|
|
20
|
-
} = options;
|
|
21
|
-
|
|
22
|
-
// Dynamically import esbuild
|
|
23
|
-
const { buildSync } = await import("esbuild");
|
|
24
|
-
const fs = await import("fs");
|
|
25
|
-
const path = await import("path");
|
|
26
|
-
|
|
27
|
-
// Resolve input path
|
|
28
|
-
const resolvedInput = path.resolve(process.cwd(), input);
|
|
29
|
-
|
|
30
|
-
try {
|
|
31
|
-
// Bundle with esbuild
|
|
32
|
-
const result = buildSync({
|
|
33
|
-
entryPoints: [resolvedInput],
|
|
34
|
-
bundle: true,
|
|
35
|
-
platform: "node",
|
|
36
|
-
target: target,
|
|
37
|
-
format: cjs ? "cjs" : "esm",
|
|
38
|
-
minify: minify,
|
|
39
|
-
write: false,
|
|
40
|
-
external: [], // Bundle everything
|
|
41
|
-
banner: {
|
|
42
|
-
js: "#!/usr/bin/env node",
|
|
43
|
-
},
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
if (result.errors.length > 0) {
|
|
47
|
-
throw new Error(
|
|
48
|
-
`Bundle failed: ${result.errors.map((e) => e.text).join(", ")}`,
|
|
49
|
-
);
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
const bundledCode = result.outputFiles?.[0]?.text;
|
|
53
|
-
if (!bundledCode) {
|
|
54
|
-
throw new Error("No output generated");
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
let finalOutput = bundledCode;
|
|
58
|
-
|
|
59
|
-
if (returnString) {
|
|
60
|
-
// Output as quoted string for node -e using JSON.stringify
|
|
61
|
-
finalOutput = JSON.stringify(bundledCode);
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
// Write to file if output path specified
|
|
65
|
-
if (output) {
|
|
66
|
-
fs.mkdirSync(path.dirname(output), { recursive: true });
|
|
67
|
-
fs.writeFileSync(output, finalOutput, "utf8");
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
return finalOutput;
|
|
71
|
-
} catch (error) {
|
|
72
|
-
throw new Error(
|
|
73
|
-
`Bundle failed: ${
|
|
74
|
-
error instanceof Error ? error.message : "Unknown error"
|
|
75
|
-
}`,
|
|
76
|
-
);
|
|
77
|
-
}
|
|
78
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { bundleCode } from "./index";
|
|
2
|
-
import { BundleCodeSchema } from "./schemas";
|
|
3
|
-
|
|
4
|
-
// Function registry info - imports both function and schema
|
|
5
|
-
export const bundleCodeInfo = {
|
|
6
|
-
name: bundleCode.name,
|
|
7
|
-
inputSchema: BundleCodeSchema,
|
|
8
|
-
implementation: bundleCode,
|
|
9
|
-
};
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
import { OutputPropertySchema } from "../../types/properties";
|
|
3
|
-
|
|
4
|
-
// Pure Zod schema - no resolver metadata!
|
|
5
|
-
export const BundleCodeSchema = z
|
|
6
|
-
.object({
|
|
7
|
-
input: z.string().min(1).describe("Input TypeScript file path to bundle"),
|
|
8
|
-
output: OutputPropertySchema.optional().describe(
|
|
9
|
-
"Output file path (defaults to input with .js extension)",
|
|
10
|
-
),
|
|
11
|
-
string: z
|
|
12
|
-
.boolean()
|
|
13
|
-
.default(false)
|
|
14
|
-
.describe("Return bundled code as string instead of writing to file"),
|
|
15
|
-
minify: z.boolean().default(false).describe("Minify the bundled output"),
|
|
16
|
-
target: z.string().default("es2017").describe("ECMAScript target version"),
|
|
17
|
-
cjs: z
|
|
18
|
-
.boolean()
|
|
19
|
-
.default(false)
|
|
20
|
-
.describe("Output CommonJS format instead of ESM"),
|
|
21
|
-
})
|
|
22
|
-
.describe("Bundle TypeScript code into executable JavaScript");
|
|
23
|
-
|
|
24
|
-
// Type inferred from schema (no additional function config needed for bundleCode)
|
|
25
|
-
export type BundleCodeOptions = z.infer<typeof BundleCodeSchema>;
|
|
26
|
-
|
|
27
|
-
// SDK function interface - ready to be mixed into main SDK interface
|
|
28
|
-
export interface BundleCodeSdkFunction {
|
|
29
|
-
bundleCode: (options: BundleCodeOptions) => Promise<string>;
|
|
30
|
-
}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import type { Authentication } from "../../types/domain";
|
|
2
|
-
import { listAuthentications } from "../listAuthentications";
|
|
3
|
-
import type { FindFirstAuthenticationOptions } from "./schemas";
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Find the first authentication matching the given criteria
|
|
7
|
-
*
|
|
8
|
-
* This function can be used standalone without instantiating a full SDK,
|
|
9
|
-
* which enables better tree-shaking in applications that only need this functionality.
|
|
10
|
-
*
|
|
11
|
-
* @param options - Filtering and API configuration options
|
|
12
|
-
* @returns Promise<Authentication | null> - First matching authentication or null if not found
|
|
13
|
-
*/
|
|
14
|
-
export async function findFirstAuthentication(
|
|
15
|
-
options: Partial<FindFirstAuthenticationOptions> = {},
|
|
16
|
-
): Promise<Authentication | null> {
|
|
17
|
-
// Use listAuthentications with limit 1 to get the first result
|
|
18
|
-
const auths = await listAuthentications({
|
|
19
|
-
...options,
|
|
20
|
-
limit: 1,
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
return auths.length > 0 ? auths[0] : null;
|
|
24
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { findFirstAuthentication } from "./index";
|
|
2
|
-
import { FindFirstAuthenticationSchema } from "./schemas";
|
|
3
|
-
|
|
4
|
-
// Function registry info - imports both function and schema
|
|
5
|
-
export const findFirstAuthenticationInfo = {
|
|
6
|
-
name: findFirstAuthentication.name,
|
|
7
|
-
inputSchema: FindFirstAuthenticationSchema,
|
|
8
|
-
implementation: findFirstAuthentication,
|
|
9
|
-
};
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
import {
|
|
3
|
-
AppKeyPropertySchema,
|
|
4
|
-
LimitPropertySchema,
|
|
5
|
-
OffsetPropertySchema,
|
|
6
|
-
} from "../../types/properties";
|
|
7
|
-
import { withOutputSchema } from "../../schema-utils";
|
|
8
|
-
import { AuthItemSchema } from "../../schemas/Auth";
|
|
9
|
-
import type { Authentication, FunctionOptions } from "../../types/domain";
|
|
10
|
-
|
|
11
|
-
// Pure Zod schema - no resolver metadata!
|
|
12
|
-
export const FindFirstAuthenticationSchema = withOutputSchema(
|
|
13
|
-
z
|
|
14
|
-
.object({
|
|
15
|
-
appKey: AppKeyPropertySchema.optional().describe(
|
|
16
|
-
"App slug to get authentications for (e.g., 'slack', 'github')",
|
|
17
|
-
),
|
|
18
|
-
search: z
|
|
19
|
-
.string()
|
|
20
|
-
.optional()
|
|
21
|
-
.describe("Search term to filter authentications by title"),
|
|
22
|
-
title: z
|
|
23
|
-
.string()
|
|
24
|
-
.optional()
|
|
25
|
-
.describe("Filter authentications by exact title match"),
|
|
26
|
-
account_id: z.string().optional().describe("Filter by account ID"),
|
|
27
|
-
owner: z.string().optional().describe("Filter by owner"),
|
|
28
|
-
limit: LimitPropertySchema.optional().describe(
|
|
29
|
-
"Maximum number of items to return (1-200)",
|
|
30
|
-
),
|
|
31
|
-
offset: OffsetPropertySchema.optional().describe(
|
|
32
|
-
"Number of items to skip for pagination",
|
|
33
|
-
),
|
|
34
|
-
})
|
|
35
|
-
.describe("Find the first authentication matching the criteria"),
|
|
36
|
-
AuthItemSchema,
|
|
37
|
-
);
|
|
38
|
-
|
|
39
|
-
// Type inferred from schema + function config
|
|
40
|
-
export type FindFirstAuthenticationOptions = z.infer<
|
|
41
|
-
typeof FindFirstAuthenticationSchema
|
|
42
|
-
> &
|
|
43
|
-
FunctionOptions;
|
|
44
|
-
|
|
45
|
-
// SDK function interface - ready to be mixed into main SDK interface
|
|
46
|
-
export interface FindFirstAuthenticationSdkFunction {
|
|
47
|
-
findFirstAuthentication: (
|
|
48
|
-
options?: Partial<FindFirstAuthenticationOptions>,
|
|
49
|
-
) => Promise<Authentication | null>;
|
|
50
|
-
}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import type { Authentication } from "../../types/domain";
|
|
2
|
-
import { listAuthentications } from "../listAuthentications";
|
|
3
|
-
import type { FindUniqueAuthenticationOptions } from "./schemas";
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Find a unique authentication matching the given criteria
|
|
7
|
-
*
|
|
8
|
-
* This function can be used standalone without instantiating a full SDK,
|
|
9
|
-
* which enables better tree-shaking in applications that only need this functionality.
|
|
10
|
-
*
|
|
11
|
-
* @param options - Filtering and API configuration options
|
|
12
|
-
* @returns Promise<Authentication> - The unique matching authentication
|
|
13
|
-
* @throws Error if no authentication found or multiple authentications found
|
|
14
|
-
*/
|
|
15
|
-
export async function findUniqueAuthentication(
|
|
16
|
-
options: Partial<FindUniqueAuthenticationOptions> = {},
|
|
17
|
-
): Promise<Authentication> {
|
|
18
|
-
// Use listAuthentications with a reasonable limit to check for uniqueness
|
|
19
|
-
const auths = await listAuthentications({
|
|
20
|
-
...options,
|
|
21
|
-
limit: 2, // Get up to 2 to check for uniqueness
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
if (auths.length === 0) {
|
|
25
|
-
throw new Error("No authentication found matching the specified criteria");
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
if (auths.length > 1) {
|
|
29
|
-
throw new Error(
|
|
30
|
-
"Multiple authentications found matching the specified criteria. Expected exactly one.",
|
|
31
|
-
);
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
return auths[0];
|
|
35
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { findUniqueAuthentication } from "./index";
|
|
2
|
-
import { FindUniqueAuthenticationSchema } from "./schemas";
|
|
3
|
-
|
|
4
|
-
// Function registry info - imports both function and schema
|
|
5
|
-
export const findUniqueAuthenticationInfo = {
|
|
6
|
-
name: findUniqueAuthentication.name,
|
|
7
|
-
inputSchema: FindUniqueAuthenticationSchema,
|
|
8
|
-
implementation: findUniqueAuthentication,
|
|
9
|
-
};
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
import {
|
|
3
|
-
AppKeyPropertySchema,
|
|
4
|
-
LimitPropertySchema,
|
|
5
|
-
OffsetPropertySchema,
|
|
6
|
-
} from "../../types/properties";
|
|
7
|
-
import { withOutputSchema } from "../../schema-utils";
|
|
8
|
-
import { AuthItemSchema } from "../../schemas/Auth";
|
|
9
|
-
import type { Authentication, FunctionOptions } from "../../types/domain";
|
|
10
|
-
|
|
11
|
-
// Pure Zod schema - no resolver metadata!
|
|
12
|
-
export const FindUniqueAuthenticationSchema = withOutputSchema(
|
|
13
|
-
z
|
|
14
|
-
.object({
|
|
15
|
-
appKey: AppKeyPropertySchema.optional().describe(
|
|
16
|
-
"App slug to get authentications for (e.g., 'slack', 'github')",
|
|
17
|
-
),
|
|
18
|
-
search: z
|
|
19
|
-
.string()
|
|
20
|
-
.optional()
|
|
21
|
-
.describe("Search term to filter authentications by title"),
|
|
22
|
-
title: z
|
|
23
|
-
.string()
|
|
24
|
-
.optional()
|
|
25
|
-
.describe("Filter authentications by exact title match"),
|
|
26
|
-
account_id: z.string().optional().describe("Filter by account ID"),
|
|
27
|
-
owner: z.string().optional().describe("Filter by owner"),
|
|
28
|
-
limit: LimitPropertySchema.optional().describe(
|
|
29
|
-
"Maximum number of items to return (1-200)",
|
|
30
|
-
),
|
|
31
|
-
offset: OffsetPropertySchema.optional().describe(
|
|
32
|
-
"Number of items to skip for pagination",
|
|
33
|
-
),
|
|
34
|
-
})
|
|
35
|
-
.describe("Find a unique authentication matching the criteria"),
|
|
36
|
-
AuthItemSchema,
|
|
37
|
-
);
|
|
38
|
-
|
|
39
|
-
// Type inferred from schema + function config
|
|
40
|
-
export type FindUniqueAuthenticationOptions = z.infer<
|
|
41
|
-
typeof FindUniqueAuthenticationSchema
|
|
42
|
-
> &
|
|
43
|
-
FunctionOptions;
|
|
44
|
-
|
|
45
|
-
// SDK function interface - ready to be mixed into main SDK interface
|
|
46
|
-
export interface FindUniqueAuthenticationSdkFunction {
|
|
47
|
-
findUniqueAuthentication: (
|
|
48
|
-
options?: Partial<FindUniqueAuthenticationOptions>,
|
|
49
|
-
) => Promise<Authentication>;
|
|
50
|
-
}
|
|
@@ -1,363 +0,0 @@
|
|
|
1
|
-
import type { Action, ActionField } from "../../types/domain";
|
|
2
|
-
import { listActions } from "../listActions";
|
|
3
|
-
import { listFields } from "../listFields";
|
|
4
|
-
import type { GenerateTypesOptions } from "./schemas";
|
|
5
|
-
|
|
6
|
-
interface ActionWithActionFields extends Omit<Action, "inputFields"> {
|
|
7
|
-
inputFields: ActionField[];
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Generate the fetch method signature for app proxies
|
|
12
|
-
*/
|
|
13
|
-
function generateFetchMethodSignature(): string {
|
|
14
|
-
return ` /** Make authenticated HTTP requests through Zapier's Relay service */
|
|
15
|
-
fetch: (options: Omit<z.infer<typeof RelayFetchSchema>, 'authenticationId'>) => Promise<Response>`;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* Generate TypeScript types for a specific app
|
|
20
|
-
*
|
|
21
|
-
* This function can be used standalone without instantiating a full SDK,
|
|
22
|
-
* which enables better tree-shaking in applications that only need this functionality.
|
|
23
|
-
*
|
|
24
|
-
* @param options - App key, authentication ID, output path, and API configuration options
|
|
25
|
-
* @returns Promise<string> - Generated TypeScript code
|
|
26
|
-
*/
|
|
27
|
-
export async function generateTypes(
|
|
28
|
-
options: GenerateTypesOptions,
|
|
29
|
-
): Promise<string> {
|
|
30
|
-
const {
|
|
31
|
-
appKey,
|
|
32
|
-
authenticationId,
|
|
33
|
-
output = `./types/${appKey}.d.ts`,
|
|
34
|
-
} = options;
|
|
35
|
-
|
|
36
|
-
// Parse app identifier (support app@version format)
|
|
37
|
-
const { app, version } = parseAppIdentifier(appKey);
|
|
38
|
-
|
|
39
|
-
// Fetch all actions for the app
|
|
40
|
-
const actions = await listActions({
|
|
41
|
-
...options,
|
|
42
|
-
appKey: app,
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
if (actions.length === 0) {
|
|
46
|
-
const typeDefinitions = generateEmptyTypesFile(app, version);
|
|
47
|
-
|
|
48
|
-
if (output) {
|
|
49
|
-
const fs = await import("fs");
|
|
50
|
-
const path = await import("path");
|
|
51
|
-
fs.mkdirSync(path.dirname(output), { recursive: true });
|
|
52
|
-
fs.writeFileSync(output, typeDefinitions, "utf8");
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
return typeDefinitions;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
// Fetch input fields for each action
|
|
59
|
-
const actionsWithFields: ActionWithActionFields[] = [];
|
|
60
|
-
|
|
61
|
-
if (authenticationId) {
|
|
62
|
-
for (const action of actions) {
|
|
63
|
-
try {
|
|
64
|
-
const fields = await listFields({
|
|
65
|
-
...options,
|
|
66
|
-
appKey: action.appKey,
|
|
67
|
-
actionKey: action.key,
|
|
68
|
-
actionType: action.type,
|
|
69
|
-
authenticationId: authenticationId,
|
|
70
|
-
});
|
|
71
|
-
actionsWithFields.push({ ...action, inputFields: fields });
|
|
72
|
-
} catch {
|
|
73
|
-
// If we can't get fields for an action, include it without fields
|
|
74
|
-
actionsWithFields.push({ ...action, inputFields: [] });
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
} else {
|
|
78
|
-
// Convert actions to have empty input fields (will generate generic types)
|
|
79
|
-
actions.forEach((action) => {
|
|
80
|
-
actionsWithFields.push({ ...action, inputFields: [] });
|
|
81
|
-
});
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
// Generate TypeScript types
|
|
85
|
-
const typeDefinitions = generateTypeDefinitions(
|
|
86
|
-
app,
|
|
87
|
-
actionsWithFields,
|
|
88
|
-
version,
|
|
89
|
-
);
|
|
90
|
-
|
|
91
|
-
// Write to file if output path specified
|
|
92
|
-
if (output) {
|
|
93
|
-
const fs = await import("fs");
|
|
94
|
-
const path = await import("path");
|
|
95
|
-
fs.mkdirSync(path.dirname(output), { recursive: true });
|
|
96
|
-
fs.writeFileSync(output, typeDefinitions, "utf8");
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
return typeDefinitions;
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
function parseAppIdentifier(identifier: string): {
|
|
103
|
-
app: string;
|
|
104
|
-
version?: string;
|
|
105
|
-
} {
|
|
106
|
-
const parts = identifier.split("@");
|
|
107
|
-
return {
|
|
108
|
-
app: parts[0],
|
|
109
|
-
version: parts[1],
|
|
110
|
-
};
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
function generateTypeDefinitions(
|
|
114
|
-
appKey: string,
|
|
115
|
-
actions: ActionWithActionFields[],
|
|
116
|
-
version?: string,
|
|
117
|
-
): string {
|
|
118
|
-
// Handle empty actions
|
|
119
|
-
if (actions.length === 0) {
|
|
120
|
-
return generateEmptyTypesFile(appKey, version);
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
// Group actions by type
|
|
124
|
-
const actionsByType = actions.reduce(
|
|
125
|
-
(acc, action) => {
|
|
126
|
-
if (!acc[action.type]) {
|
|
127
|
-
acc[action.type] = [];
|
|
128
|
-
}
|
|
129
|
-
acc[action.type].push(action);
|
|
130
|
-
return acc;
|
|
131
|
-
},
|
|
132
|
-
{} as Record<string, ActionWithActionFields[]>,
|
|
133
|
-
);
|
|
134
|
-
|
|
135
|
-
const appName = capitalize(appKey);
|
|
136
|
-
const versionComment = version
|
|
137
|
-
? ` * Generated for ${appKey}@${version}`
|
|
138
|
-
: ` * Generated for ${appKey}`;
|
|
139
|
-
|
|
140
|
-
let output = `/* eslint-disable @typescript-eslint/naming-convention */
|
|
141
|
-
/**
|
|
142
|
-
* Auto-generated TypeScript types for Zapier ${appKey} actions
|
|
143
|
-
${versionComment}
|
|
144
|
-
* Generated on: ${new Date().toISOString()}
|
|
145
|
-
*
|
|
146
|
-
* Usage:
|
|
147
|
-
* import type { ${appName}Sdk } from './path/to/this/file'
|
|
148
|
-
* const sdk = createZapierSdk() as unknown as ${appName}Sdk
|
|
149
|
-
*
|
|
150
|
-
* // Direct usage (per-call auth):
|
|
151
|
-
* await sdk.apps.${appKey}.search.user_by_email({ authenticationId: 123, inputs: { email } })
|
|
152
|
-
*
|
|
153
|
-
* // Factory usage (pinned auth):
|
|
154
|
-
* const my${appName} = sdk.apps.${appKey}({ authenticationId: 123 })
|
|
155
|
-
* await my${appName}.search.user_by_email({ inputs: { email } })
|
|
156
|
-
*/
|
|
157
|
-
|
|
158
|
-
import type { ActionExecutionOptions, ActionExecutionResult } from '@zapier/zapier-sdk'
|
|
159
|
-
import { z } from 'zod'
|
|
160
|
-
import { RelayFetchSchema } from '@zapier/zapier-sdk'
|
|
161
|
-
|
|
162
|
-
`;
|
|
163
|
-
|
|
164
|
-
// Generate input types for each action
|
|
165
|
-
actions.forEach((action) => {
|
|
166
|
-
if (action.inputFields.length > 0) {
|
|
167
|
-
const inputTypeName = `${appName}${capitalize(action.type)}${capitalize(
|
|
168
|
-
sanitizeActionName(action.key),
|
|
169
|
-
)}Inputs`;
|
|
170
|
-
|
|
171
|
-
output += `interface ${inputTypeName} {\n`;
|
|
172
|
-
|
|
173
|
-
action.inputFields.forEach((field) => {
|
|
174
|
-
const isOptional = !field.required;
|
|
175
|
-
const fieldType = mapFieldTypeToTypeScript(field);
|
|
176
|
-
const description = field.helpText
|
|
177
|
-
? ` /** ${escapeComment(field.helpText)} */\n`
|
|
178
|
-
: "";
|
|
179
|
-
|
|
180
|
-
output += `${description} ${sanitizeFieldName(field.key)}${
|
|
181
|
-
isOptional ? "?" : ""
|
|
182
|
-
}: ${fieldType}\n`;
|
|
183
|
-
});
|
|
184
|
-
|
|
185
|
-
output += `}\n\n`;
|
|
186
|
-
}
|
|
187
|
-
});
|
|
188
|
-
|
|
189
|
-
// Generate action type interfaces for each action type
|
|
190
|
-
Object.entries(actionsByType).forEach(([actionType, typeActions]) => {
|
|
191
|
-
const typeName = `${appName}${capitalize(actionType)}Actions`;
|
|
192
|
-
|
|
193
|
-
output += `interface ${typeName} {\n`;
|
|
194
|
-
|
|
195
|
-
typeActions.forEach((action: ActionWithActionFields) => {
|
|
196
|
-
const actionName = sanitizeActionName(action.key);
|
|
197
|
-
const description = action.description
|
|
198
|
-
? ` /** ${escapeComment(action.description)} */\n`
|
|
199
|
-
: "";
|
|
200
|
-
|
|
201
|
-
// Generate type-safe action method signature
|
|
202
|
-
if (action.inputFields.length > 0) {
|
|
203
|
-
const inputTypeName = `${appName}${capitalize(action.type)}${capitalize(
|
|
204
|
-
sanitizeActionName(action.key),
|
|
205
|
-
)}Inputs`;
|
|
206
|
-
output += `${description} ${actionName}: (options: { inputs: ${inputTypeName} } & Omit<ActionExecutionOptions, 'inputs'>) => Promise<ActionExecutionResult>\n`;
|
|
207
|
-
} else {
|
|
208
|
-
// No specific input fields available - use generic Record<string, any> for inputs
|
|
209
|
-
output += `${description} ${actionName}: (options?: { inputs?: Record<string, any> } & ActionExecutionOptions) => Promise<ActionExecutionResult>\n`;
|
|
210
|
-
}
|
|
211
|
-
});
|
|
212
|
-
|
|
213
|
-
output += `}\n\n`;
|
|
214
|
-
});
|
|
215
|
-
|
|
216
|
-
// Generate the main app SDK interface with factory pattern support
|
|
217
|
-
|
|
218
|
-
// Generate the app proxy interface (actions grouped by type)
|
|
219
|
-
output += `interface ${appName}AppProxy {\n`;
|
|
220
|
-
Object.keys(actionsByType).forEach((actionType) => {
|
|
221
|
-
const typeName = `${appName}${capitalize(actionType)}Actions`;
|
|
222
|
-
output += ` ${actionType}: ${typeName}\n`;
|
|
223
|
-
});
|
|
224
|
-
// Always include fetch method for authenticated HTTP requests
|
|
225
|
-
output += generateFetchMethodSignature() + "\n";
|
|
226
|
-
output += `}\n\n`;
|
|
227
|
-
|
|
228
|
-
// Generate the factory function interface
|
|
229
|
-
output += `interface ${appName}AppFactory {\n`;
|
|
230
|
-
output += ` (options: { authenticationId: number }): ${appName}AppProxy\n`;
|
|
231
|
-
output += `}\n\n`;
|
|
232
|
-
|
|
233
|
-
// Combine factory and direct access
|
|
234
|
-
output += `type ${appName}AppWithFactory = ${appName}AppFactory & ${appName}AppProxy\n\n`;
|
|
235
|
-
|
|
236
|
-
// Generate the main SDK interface
|
|
237
|
-
output += `export interface ${appName}Sdk {\n`;
|
|
238
|
-
output += ` apps: {\n`;
|
|
239
|
-
output += ` ${appKey}: ${appName}AppWithFactory\n`;
|
|
240
|
-
output += ` }\n`;
|
|
241
|
-
output += `}\n`;
|
|
242
|
-
|
|
243
|
-
return output;
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
function generateEmptyTypesFile(appKey: string, version?: string): string {
|
|
247
|
-
const appName = capitalize(appKey);
|
|
248
|
-
const versionComment = version
|
|
249
|
-
? ` * Generated for ${appKey}@${version}`
|
|
250
|
-
: ` * Generated for ${appKey}`;
|
|
251
|
-
|
|
252
|
-
return `/* eslint-disable @typescript-eslint/naming-convention */
|
|
253
|
-
/**
|
|
254
|
-
* Auto-generated TypeScript types for Zapier ${appKey} actions
|
|
255
|
-
${versionComment}
|
|
256
|
-
* Generated on: ${new Date().toISOString()}
|
|
257
|
-
*
|
|
258
|
-
* No actions found for this app.
|
|
259
|
-
*/
|
|
260
|
-
|
|
261
|
-
import type { ActionExecutionOptions, ActionExecutionResult } from '@zapier/zapier-sdk'
|
|
262
|
-
import { z } from 'zod'
|
|
263
|
-
import { RelayFetchSchema } from '@zapier/zapier-sdk'
|
|
264
|
-
|
|
265
|
-
interface ${appName}AppProxy {
|
|
266
|
-
// No actions available
|
|
267
|
-
${generateFetchMethodSignature()}
|
|
268
|
-
}
|
|
269
|
-
|
|
270
|
-
interface ${appName}AppFactory {
|
|
271
|
-
(options: { authenticationId: number }): ${appName}AppProxy
|
|
272
|
-
}
|
|
273
|
-
|
|
274
|
-
type ${appName}AppWithFactory = ${appName}AppFactory & ${appName}AppProxy
|
|
275
|
-
|
|
276
|
-
export interface ${appName}Sdk {
|
|
277
|
-
apps: {
|
|
278
|
-
${appKey}: ${appName}AppWithFactory
|
|
279
|
-
}
|
|
280
|
-
}
|
|
281
|
-
`;
|
|
282
|
-
}
|
|
283
|
-
|
|
284
|
-
function capitalize(str: string): string {
|
|
285
|
-
return str.charAt(0).toUpperCase() + str.slice(1).replace(/[-_]/g, "");
|
|
286
|
-
}
|
|
287
|
-
|
|
288
|
-
function sanitizeActionName(actionKey: string): string {
|
|
289
|
-
// Ensure the action name is a valid TypeScript identifier
|
|
290
|
-
let sanitized = actionKey.replace(/[^a-zA-Z0-9_$]/g, "_");
|
|
291
|
-
|
|
292
|
-
// If it starts with a number, prepend an underscore
|
|
293
|
-
if (/^[0-9]/.test(sanitized)) {
|
|
294
|
-
sanitized = "_" + sanitized;
|
|
295
|
-
}
|
|
296
|
-
|
|
297
|
-
return sanitized;
|
|
298
|
-
}
|
|
299
|
-
|
|
300
|
-
function sanitizeFieldName(fieldKey: string): string {
|
|
301
|
-
// Ensure the field name is a valid TypeScript identifier
|
|
302
|
-
let sanitized = fieldKey.replace(/[^a-zA-Z0-9_$]/g, "_");
|
|
303
|
-
|
|
304
|
-
// If it starts with a number, prepend an underscore
|
|
305
|
-
if (/^[0-9]/.test(sanitized)) {
|
|
306
|
-
sanitized = "_" + sanitized;
|
|
307
|
-
}
|
|
308
|
-
|
|
309
|
-
return sanitized;
|
|
310
|
-
}
|
|
311
|
-
|
|
312
|
-
function escapeComment(comment: string): string {
|
|
313
|
-
// Escape comment text to prevent breaking the JSDoc comment
|
|
314
|
-
return comment.replace(/\*\//g, "*\\/").replace(/\r?\n/g, " ");
|
|
315
|
-
}
|
|
316
|
-
|
|
317
|
-
function mapFieldTypeToTypeScript(field: ActionField): string {
|
|
318
|
-
// Handle choices (enum-like fields)
|
|
319
|
-
if (field.choices && field.choices.length > 0) {
|
|
320
|
-
const choiceValues = field.choices
|
|
321
|
-
.filter(
|
|
322
|
-
(choice) =>
|
|
323
|
-
choice.value !== undefined &&
|
|
324
|
-
choice.value !== null &&
|
|
325
|
-
choice.value !== "",
|
|
326
|
-
)
|
|
327
|
-
.map((choice) =>
|
|
328
|
-
typeof choice.value === "string" ? `"${choice.value}"` : choice.value,
|
|
329
|
-
);
|
|
330
|
-
|
|
331
|
-
if (choiceValues.length > 0) {
|
|
332
|
-
return choiceValues.join(" | ");
|
|
333
|
-
}
|
|
334
|
-
// If all choices were filtered out, fall through to default type handling
|
|
335
|
-
}
|
|
336
|
-
|
|
337
|
-
// Map Zapier field types to TypeScript types
|
|
338
|
-
switch (field.type?.toLowerCase()) {
|
|
339
|
-
case "string":
|
|
340
|
-
case "text":
|
|
341
|
-
case "email":
|
|
342
|
-
case "url":
|
|
343
|
-
case "password":
|
|
344
|
-
return "string";
|
|
345
|
-
case "integer":
|
|
346
|
-
case "number":
|
|
347
|
-
return "number";
|
|
348
|
-
case "boolean":
|
|
349
|
-
return "boolean";
|
|
350
|
-
case "datetime":
|
|
351
|
-
case "date":
|
|
352
|
-
return "string"; // ISO date strings
|
|
353
|
-
case "file":
|
|
354
|
-
return "string"; // File URL or content
|
|
355
|
-
case "array":
|
|
356
|
-
return "any[]";
|
|
357
|
-
case "object":
|
|
358
|
-
return "Record<string, any>";
|
|
359
|
-
default:
|
|
360
|
-
// Default to string for unknown types, with union for common cases
|
|
361
|
-
return "string | number | boolean";
|
|
362
|
-
}
|
|
363
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { generateTypes } from "./index";
|
|
2
|
-
import { GenerateTypesSchema } from "./schemas";
|
|
3
|
-
|
|
4
|
-
// Function registry info - imports both function and schema
|
|
5
|
-
export const generateTypesInfo = {
|
|
6
|
-
name: generateTypes.name,
|
|
7
|
-
inputSchema: GenerateTypesSchema,
|
|
8
|
-
implementation: generateTypes,
|
|
9
|
-
};
|