@zapier/zapier-sdk 0.4.1 → 0.5.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 +7 -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
package/src/constants.ts
ADDED
package/src/index.ts
CHANGED
|
@@ -1,11 +1,31 @@
|
|
|
1
1
|
// Export everything from types and plugins
|
|
2
2
|
export * from "./types/domain";
|
|
3
|
+
export * from "./types/functions";
|
|
3
4
|
export * from "./types/properties";
|
|
5
|
+
export * from "./types/errors";
|
|
4
6
|
export * from "./plugins/apps";
|
|
5
7
|
export * from "./plugins/fetch";
|
|
6
8
|
|
|
9
|
+
// Export API types directly (no longer re-exported from domain)
|
|
10
|
+
export type {
|
|
11
|
+
Action,
|
|
12
|
+
App,
|
|
13
|
+
Need,
|
|
14
|
+
Field,
|
|
15
|
+
Choice,
|
|
16
|
+
ActionExecutionResult,
|
|
17
|
+
ActionField,
|
|
18
|
+
ActionFieldChoice,
|
|
19
|
+
NeedsRequest,
|
|
20
|
+
NeedsResponse,
|
|
21
|
+
Authentication,
|
|
22
|
+
AuthenticationsResponse,
|
|
23
|
+
UserProfile,
|
|
24
|
+
} from "./api/types";
|
|
25
|
+
|
|
7
26
|
// Export schema utilities for CLI
|
|
8
|
-
export { isPositional } from "./schema-utils";
|
|
27
|
+
export { isPositional } from "./utils/schema-utils";
|
|
28
|
+
export { hasResolver } from "./resolvers";
|
|
9
29
|
|
|
10
30
|
// Export auth utilities for CLI use
|
|
11
31
|
export * from "./auth";
|
|
@@ -15,27 +35,28 @@ export * from "./resolvers";
|
|
|
15
35
|
|
|
16
36
|
// Note: SdkSchemas is now available via SDK.__registry
|
|
17
37
|
|
|
18
|
-
//
|
|
19
|
-
|
|
20
|
-
export { getAuthentication } from "./functions/getAuthentication";
|
|
21
|
-
export { findFirstAuthentication } from "./functions/findFirstAuthentication";
|
|
22
|
-
export { findUniqueAuthentication } from "./functions/findUniqueAuthentication";
|
|
23
|
-
export { listApps } from "./functions/listApps";
|
|
24
|
-
export { getApp } from "./functions/getApp";
|
|
25
|
-
export { listActions } from "./functions/listActions";
|
|
26
|
-
export { getAction } from "./functions/getAction";
|
|
27
|
-
export { runAction } from "./functions/runAction";
|
|
28
|
-
export { listFields } from "./functions/listFields";
|
|
29
|
-
export { generateTypes } from "./functions/generateTypes";
|
|
30
|
-
export { bundleCode } from "./functions/bundleCode";
|
|
31
|
-
export { request, relayFetch } from "./functions/request";
|
|
38
|
+
// All functions now available through the plugin system via createZapierSdk()
|
|
39
|
+
// Export plugin schemas for external use
|
|
32
40
|
export {
|
|
33
41
|
RelayRequestSchema,
|
|
34
42
|
RelayFetchSchema,
|
|
35
|
-
} from "./
|
|
43
|
+
} from "./plugins/request/schemas";
|
|
36
44
|
|
|
37
|
-
// Export the main combined SDK
|
|
38
|
-
export { createZapierSdk, ZapierSdkOptions } from "./sdk";
|
|
45
|
+
// Export the main combined SDK and new flexible SDK creator
|
|
46
|
+
export { createZapierSdk, createSdk, ZapierSdkOptions } from "./sdk";
|
|
39
47
|
|
|
40
48
|
// Export SDK types from types (not sdk.ts to avoid circular imports)
|
|
41
|
-
export type {
|
|
49
|
+
export type { FunctionRegistryEntry } from "./types/sdk";
|
|
50
|
+
|
|
51
|
+
// Export plugin utilities and SDK types
|
|
52
|
+
export type {
|
|
53
|
+
Plugin,
|
|
54
|
+
PluginProvides,
|
|
55
|
+
PluginDependencies,
|
|
56
|
+
PluginOptions,
|
|
57
|
+
GetSdkType,
|
|
58
|
+
Sdk,
|
|
59
|
+
} from "./types/plugin";
|
|
60
|
+
|
|
61
|
+
// Export ZapierSdk from sdk.ts (it's now ReturnType<typeof createZapierSdk>)
|
|
62
|
+
export type { ZapierSdk } from "./types/sdk";
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { createZapierApi } from "../../api";
|
|
2
|
+
import type { ApiClient } from "../../api/types";
|
|
3
|
+
import type { BaseSdkOptions } from "../../types/sdk";
|
|
4
|
+
import type { Plugin } from "../../types/plugin";
|
|
5
|
+
|
|
6
|
+
export interface ApiPluginOptions extends BaseSdkOptions {}
|
|
7
|
+
|
|
8
|
+
// API plugin only provides context, no SDK methods
|
|
9
|
+
export interface ApiPluginProvides {
|
|
10
|
+
context: {
|
|
11
|
+
api: ApiClient;
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
// API plugin requires no context and provides api in context
|
|
16
|
+
export const apiPlugin: Plugin<
|
|
17
|
+
{}, // no SDK dependencies
|
|
18
|
+
{}, // requires no context
|
|
19
|
+
ApiPluginProvides
|
|
20
|
+
> = (params) => {
|
|
21
|
+
// Extract all options - everything passed to the plugin
|
|
22
|
+
const {
|
|
23
|
+
fetch: customFetch = globalThis.fetch,
|
|
24
|
+
baseUrl = "https://zapier.com",
|
|
25
|
+
token,
|
|
26
|
+
getToken,
|
|
27
|
+
onEvent,
|
|
28
|
+
debug = false,
|
|
29
|
+
} = params as any;
|
|
30
|
+
|
|
31
|
+
// Create the API client - it will handle token resolution internally
|
|
32
|
+
const api = createZapierApi({
|
|
33
|
+
baseUrl,
|
|
34
|
+
token,
|
|
35
|
+
getToken,
|
|
36
|
+
debug,
|
|
37
|
+
fetch: customFetch,
|
|
38
|
+
onEvent,
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
// Return flat structure with context only
|
|
42
|
+
return {
|
|
43
|
+
context: {
|
|
44
|
+
api, // Provide API client in context for other plugins to use
|
|
45
|
+
},
|
|
46
|
+
};
|
|
47
|
+
};
|
|
@@ -1,12 +1,16 @@
|
|
|
1
|
-
import {
|
|
2
|
-
ActionExecutionOptions,
|
|
3
|
-
ActionExecutionResult,
|
|
4
|
-
} from "../../types/domain";
|
|
1
|
+
import { ActionExecutionOptions } from "./types";
|
|
5
2
|
import type { ActionProxy } from "./types";
|
|
6
|
-
import
|
|
3
|
+
import { ZapierValidationError } from "../../types/errors";
|
|
4
|
+
import type { Plugin, GetSdkType } from "../../types/plugin";
|
|
5
|
+
import type { FetchPluginProvides } from "../fetch/index";
|
|
6
|
+
import type { RunActionPluginProvides } from "../runAction/index";
|
|
7
7
|
|
|
8
|
-
export interface
|
|
9
|
-
|
|
8
|
+
export interface AppsPluginProvides {
|
|
9
|
+
apps: ActionProxy;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
interface AppsPluginOptions {
|
|
13
|
+
sdk: GetSdkType<FetchPluginProvides & RunActionPluginProvides>;
|
|
10
14
|
}
|
|
11
15
|
|
|
12
16
|
interface AppFactoryOptions {
|
|
@@ -20,9 +24,7 @@ function createActionFunction(
|
|
|
20
24
|
options: AppsPluginOptions,
|
|
21
25
|
pinnedAuthId?: number,
|
|
22
26
|
) {
|
|
23
|
-
return
|
|
24
|
-
actionOptions: ActionExecutionOptions = {},
|
|
25
|
-
): Promise<ActionExecutionResult> => {
|
|
27
|
+
return (actionOptions: ActionExecutionOptions = {}): any => {
|
|
26
28
|
const { sdk } = options;
|
|
27
29
|
const { inputs, authenticationId: providedAuthenticationId } =
|
|
28
30
|
actionOptions;
|
|
@@ -31,7 +33,7 @@ function createActionFunction(
|
|
|
31
33
|
const authenticationId = pinnedAuthId || providedAuthenticationId;
|
|
32
34
|
|
|
33
35
|
if (!authenticationId) {
|
|
34
|
-
throw new
|
|
36
|
+
throw new ZapierValidationError(
|
|
35
37
|
`Authentication ID is required. Either use the factory pattern: sdk.apps.${appKey}({ authenticationId }) or provide authenticationId in the action call.`,
|
|
36
38
|
);
|
|
37
39
|
}
|
|
@@ -69,7 +71,7 @@ function createActionTypeProxy(
|
|
|
69
71
|
const authenticationId = pinnedAuthId || init?.authenticationId;
|
|
70
72
|
|
|
71
73
|
if (!authenticationId) {
|
|
72
|
-
throw new
|
|
74
|
+
throw new ZapierValidationError(
|
|
73
75
|
`Authentication ID is required for fetch. Either use the factory pattern: sdk.apps.${appKey}({ authenticationId }).fetch(...) or provide authenticationId in the fetch call.`,
|
|
74
76
|
);
|
|
75
77
|
}
|
|
@@ -160,10 +162,14 @@ function createAppsProxy(options: AppsPluginOptions): ActionProxy {
|
|
|
160
162
|
return appsProxy;
|
|
161
163
|
}
|
|
162
164
|
|
|
163
|
-
//
|
|
164
|
-
export
|
|
165
|
-
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
165
|
+
// Direct plugin function - takes options + sdk + context in one object
|
|
166
|
+
export const appsPlugin: Plugin<
|
|
167
|
+
GetSdkType<FetchPluginProvides & RunActionPluginProvides>, // requires fetch + runAction in SDK
|
|
168
|
+
{}, // no context requirements
|
|
169
|
+
AppsPluginProvides
|
|
170
|
+
> = ({ sdk }) => {
|
|
171
|
+
// Return flat structure - apps goes directly to SDK
|
|
172
|
+
return {
|
|
173
|
+
apps: createAppsProxy({ sdk }),
|
|
174
|
+
};
|
|
175
|
+
};
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
// Apps plugin-specific execution options
|
|
2
|
+
export interface ActionExecutionOptions {
|
|
3
|
+
inputs?: Record<string, any>;
|
|
4
|
+
authenticationId?: number;
|
|
5
|
+
}
|
|
5
6
|
|
|
6
7
|
interface AppFactoryOptions {
|
|
7
8
|
authenticationId: number;
|
|
@@ -9,9 +10,7 @@ interface AppFactoryOptions {
|
|
|
9
10
|
|
|
10
11
|
// Base action type proxy for regular actions
|
|
11
12
|
interface BaseActionTypeProxy {
|
|
12
|
-
[action: string]: (
|
|
13
|
-
options?: ActionExecutionOptions,
|
|
14
|
-
) => Promise<ActionExecutionResult>;
|
|
13
|
+
[action: string]: (options?: ActionExecutionOptions) => any;
|
|
15
14
|
}
|
|
16
15
|
|
|
17
16
|
// Special fetch function type
|
|
@@ -44,7 +43,4 @@ export interface ActionProxy {
|
|
|
44
43
|
[app: string]: AppProxyWithFactory;
|
|
45
44
|
}
|
|
46
45
|
|
|
47
|
-
//
|
|
48
|
-
export interface AppsPluginSdkExtension {
|
|
49
|
-
apps: ActionProxy;
|
|
50
|
-
}
|
|
46
|
+
// Note: AppsPluginSdkExtension removed - now using AppsPluginProvides in index.ts
|
|
@@ -1,44 +1,8 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { RelayRequestOptions } from "../request/schemas";
|
|
2
|
+
import type { Plugin, GetSdkType } from "../../types/plugin";
|
|
3
|
+
import type { RequestPluginProvides } from "../request";
|
|
2
4
|
|
|
3
|
-
export interface
|
|
4
|
-
sdk: ZapierSdk;
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Creates a fetch function with standard fetch signature that delegates to sdk.request
|
|
9
|
-
*/
|
|
10
|
-
export function createFetchPlugin(options: FetchPluginOptions) {
|
|
11
|
-
const { sdk } = options;
|
|
12
|
-
|
|
13
|
-
return async function fetch(
|
|
14
|
-
url: string | URL,
|
|
15
|
-
init?: RequestInit & {
|
|
16
|
-
authenticationId?: number;
|
|
17
|
-
callbackUrl?: string;
|
|
18
|
-
authenticationTemplate?: string;
|
|
19
|
-
},
|
|
20
|
-
): Promise<Response> {
|
|
21
|
-
const {
|
|
22
|
-
authenticationId,
|
|
23
|
-
callbackUrl,
|
|
24
|
-
authenticationTemplate,
|
|
25
|
-
...fetchInit
|
|
26
|
-
} = init || {};
|
|
27
|
-
|
|
28
|
-
return sdk.request({
|
|
29
|
-
url: url.toString(),
|
|
30
|
-
method: fetchInit.method as any,
|
|
31
|
-
body: fetchInit.body as any,
|
|
32
|
-
headers: fetchInit.headers as any,
|
|
33
|
-
authenticationId,
|
|
34
|
-
callbackUrl,
|
|
35
|
-
authenticationTemplate,
|
|
36
|
-
});
|
|
37
|
-
};
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
// Export types for TypeScript
|
|
41
|
-
export interface FetchPluginSdkExtension {
|
|
5
|
+
export interface FetchPluginProvides {
|
|
42
6
|
fetch: (
|
|
43
7
|
url: string | URL,
|
|
44
8
|
init?: RequestInit & {
|
|
@@ -48,3 +12,47 @@ export interface FetchPluginSdkExtension {
|
|
|
48
12
|
},
|
|
49
13
|
) => Promise<Response>;
|
|
50
14
|
}
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Direct plugin function - takes options + sdk + context in one object
|
|
18
|
+
*/
|
|
19
|
+
export const fetchPlugin: Plugin<
|
|
20
|
+
GetSdkType<RequestPluginProvides>, // requires request in SDK
|
|
21
|
+
{}, // requires no context (uses SDK methods)
|
|
22
|
+
FetchPluginProvides
|
|
23
|
+
> = ({ sdk }) => {
|
|
24
|
+
// Return flat structure - fetch goes directly to SDK
|
|
25
|
+
return {
|
|
26
|
+
fetch: async function fetch(
|
|
27
|
+
url: string | URL,
|
|
28
|
+
init?: RequestInit & {
|
|
29
|
+
authenticationId?: number;
|
|
30
|
+
callbackUrl?: string;
|
|
31
|
+
authenticationTemplate?: string;
|
|
32
|
+
},
|
|
33
|
+
): Promise<Response> {
|
|
34
|
+
const {
|
|
35
|
+
authenticationId,
|
|
36
|
+
callbackUrl,
|
|
37
|
+
authenticationTemplate,
|
|
38
|
+
...fetchInit
|
|
39
|
+
} = init || {};
|
|
40
|
+
|
|
41
|
+
return sdk.request({
|
|
42
|
+
url: url.toString(),
|
|
43
|
+
method: fetchInit.method as RelayRequestOptions["method"],
|
|
44
|
+
body: fetchInit.body,
|
|
45
|
+
headers: fetchInit.headers,
|
|
46
|
+
authenticationId,
|
|
47
|
+
callbackUrl,
|
|
48
|
+
authenticationTemplate,
|
|
49
|
+
});
|
|
50
|
+
},
|
|
51
|
+
};
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
export type ZapierFetchInitOptions = RequestInit & {
|
|
55
|
+
authenticationId?: number;
|
|
56
|
+
callbackUrl?: string;
|
|
57
|
+
authenticationTemplate?: string;
|
|
58
|
+
};
|
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
import { describe, it, expect, vi, beforeEach } from "vitest";
|
|
2
|
+
import { ZapierValidationError } from "../../types/errors";
|
|
3
|
+
import { findFirstAuthenticationPlugin } from "./index";
|
|
4
|
+
import { createSdk } from "../../sdk";
|
|
5
|
+
import type { AuthenticationItem } from "../../types/domain";
|
|
6
|
+
import { ListAuthenticationsSchema } from "../listAuthentications/schemas";
|
|
7
|
+
|
|
8
|
+
const mockAuthentications: AuthenticationItem[] = [
|
|
9
|
+
{
|
|
10
|
+
id: 123,
|
|
11
|
+
title: "My Slack",
|
|
12
|
+
date: "2021-01-01",
|
|
13
|
+
account_id: 123,
|
|
14
|
+
implementation_id: "api_123",
|
|
15
|
+
is_expired: "false",
|
|
16
|
+
expired_at: null,
|
|
17
|
+
is_invite_only: false,
|
|
18
|
+
is_private: false,
|
|
19
|
+
shared_with_all: false,
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
id: 456,
|
|
23
|
+
title: "Slack Workspace 2",
|
|
24
|
+
is_expired: "false",
|
|
25
|
+
expired_at: null,
|
|
26
|
+
date: "2021-01-01",
|
|
27
|
+
account_id: 123,
|
|
28
|
+
implementation_id: "api_123",
|
|
29
|
+
is_invite_only: false,
|
|
30
|
+
is_private: false,
|
|
31
|
+
shared_with_all: false,
|
|
32
|
+
},
|
|
33
|
+
];
|
|
34
|
+
|
|
35
|
+
describe("findFirstAuthentication plugin", () => {
|
|
36
|
+
let mockListAuthentications: any;
|
|
37
|
+
|
|
38
|
+
beforeEach(() => {
|
|
39
|
+
vi.clearAllMocks();
|
|
40
|
+
mockListAuthentications = vi.fn().mockResolvedValue({
|
|
41
|
+
data: mockAuthentications,
|
|
42
|
+
});
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
function createTestSdk() {
|
|
46
|
+
// Create a proper plugin chain: first add a mock listAuthentications plugin, then add findFirstAuthentication
|
|
47
|
+
const mockListAuthenticationsPlugin = () => ({
|
|
48
|
+
listAuthentications: mockListAuthentications,
|
|
49
|
+
context: {
|
|
50
|
+
meta: {
|
|
51
|
+
listAuthentications: {
|
|
52
|
+
inputSchema: ListAuthenticationsSchema,
|
|
53
|
+
},
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
// Build SDK with proper plugin composition
|
|
59
|
+
return createSdk()
|
|
60
|
+
.addPlugin(mockListAuthenticationsPlugin)
|
|
61
|
+
.addPlugin(findFirstAuthenticationPlugin);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
describe("schema validation", () => {
|
|
65
|
+
it("should pass validation with empty options", async () => {
|
|
66
|
+
const sdk = createTestSdk();
|
|
67
|
+
const result = await sdk.findFirstAuthentication({});
|
|
68
|
+
expect(result.data).toBeDefined();
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
it("should pass validation with undefined options", async () => {
|
|
72
|
+
const sdk = createTestSdk();
|
|
73
|
+
const result = await sdk.findFirstAuthentication();
|
|
74
|
+
expect(result.data).toBeDefined();
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
it("should throw validation error for invalid appKey type", async () => {
|
|
78
|
+
const sdk = createTestSdk();
|
|
79
|
+
await expect(
|
|
80
|
+
sdk.findFirstAuthentication({
|
|
81
|
+
appKey: 123 as any, // intentionally wrong type for testing
|
|
82
|
+
}),
|
|
83
|
+
).rejects.toThrow(ZapierValidationError);
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
it("should throw validation error for invalid search type", async () => {
|
|
87
|
+
const sdk = createTestSdk();
|
|
88
|
+
await expect(
|
|
89
|
+
sdk.findFirstAuthentication({
|
|
90
|
+
search: 123 as any,
|
|
91
|
+
}),
|
|
92
|
+
).rejects.toThrow(ZapierValidationError);
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
it("should throw validation error for invalid parameter types", async () => {
|
|
96
|
+
const sdk = createTestSdk();
|
|
97
|
+
await expect(
|
|
98
|
+
sdk.findFirstAuthentication({
|
|
99
|
+
title: 123 as any,
|
|
100
|
+
account_id: 456 as any,
|
|
101
|
+
owner: true as any,
|
|
102
|
+
}),
|
|
103
|
+
).rejects.toThrow(ZapierValidationError);
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
it("should pass validation with all valid fields", async () => {
|
|
107
|
+
const sdk = createTestSdk();
|
|
108
|
+
const result = await sdk.findFirstAuthentication({
|
|
109
|
+
appKey: "slack",
|
|
110
|
+
search: "workspace",
|
|
111
|
+
title: "My Slack Workspace",
|
|
112
|
+
account_id: "acc_123",
|
|
113
|
+
owner: "me",
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
expect(result.data).toBeDefined();
|
|
117
|
+
});
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
describe("business logic", () => {
|
|
121
|
+
it("should return first authentication when found", async () => {
|
|
122
|
+
const mockAuth = mockAuthentications[0];
|
|
123
|
+
mockListAuthentications.mockResolvedValue({
|
|
124
|
+
data: [mockAuth],
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
const sdk = createTestSdk();
|
|
128
|
+
const result = await sdk.findFirstAuthentication({
|
|
129
|
+
appKey: "slack",
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
expect(result.data).toEqual(mockAuth);
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
it("should return null when no authentications found", async () => {
|
|
136
|
+
mockListAuthentications.mockResolvedValue({
|
|
137
|
+
data: [],
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
const sdk = createTestSdk();
|
|
141
|
+
const result = await sdk.findFirstAuthentication({
|
|
142
|
+
appKey: "nonexistent",
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
expect(result.data).toBeNull();
|
|
146
|
+
});
|
|
147
|
+
|
|
148
|
+
it("should return first authentication when multiple found", async () => {
|
|
149
|
+
const mockAuth = mockAuthentications[0];
|
|
150
|
+
mockListAuthentications.mockResolvedValue({
|
|
151
|
+
data: [mockAuth, mockAuthentications[1]],
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
const sdk = createTestSdk();
|
|
155
|
+
const result = await sdk.findFirstAuthentication({
|
|
156
|
+
search: "Slack",
|
|
157
|
+
});
|
|
158
|
+
|
|
159
|
+
expect(result.data).toEqual(mockAuth);
|
|
160
|
+
});
|
|
161
|
+
});
|
|
162
|
+
|
|
163
|
+
describe("options forwarding", () => {
|
|
164
|
+
it("should forward all options to listAuthentications", async () => {
|
|
165
|
+
const sdk = createTestSdk();
|
|
166
|
+
const options = {
|
|
167
|
+
appKey: "slack",
|
|
168
|
+
search: "workspace",
|
|
169
|
+
title: "My Slack Workspace",
|
|
170
|
+
account_id: "acc_123",
|
|
171
|
+
owner: "me",
|
|
172
|
+
};
|
|
173
|
+
|
|
174
|
+
await sdk.findFirstAuthentication(options);
|
|
175
|
+
|
|
176
|
+
expect(mockListAuthentications).toHaveBeenCalledWith({
|
|
177
|
+
...options,
|
|
178
|
+
maxItems: 1,
|
|
179
|
+
});
|
|
180
|
+
});
|
|
181
|
+
});
|
|
182
|
+
|
|
183
|
+
describe("limit enforcement", () => {
|
|
184
|
+
it("should automatically set maxItems to 1", async () => {
|
|
185
|
+
const sdk = createTestSdk();
|
|
186
|
+
await sdk.findFirstAuthentication({
|
|
187
|
+
appKey: "slack",
|
|
188
|
+
});
|
|
189
|
+
|
|
190
|
+
expect(mockListAuthentications).toHaveBeenCalledWith({
|
|
191
|
+
appKey: "slack",
|
|
192
|
+
maxItems: 1,
|
|
193
|
+
});
|
|
194
|
+
});
|
|
195
|
+
});
|
|
196
|
+
|
|
197
|
+
describe("context and metadata", () => {
|
|
198
|
+
it("should provide context with meta information", () => {
|
|
199
|
+
const sdk = createTestSdk();
|
|
200
|
+
const context = sdk.getContext();
|
|
201
|
+
|
|
202
|
+
expect(context.meta.findFirstAuthentication).toBeDefined();
|
|
203
|
+
expect(context.meta.findFirstAuthentication.inputSchema).toBeDefined();
|
|
204
|
+
});
|
|
205
|
+
});
|
|
206
|
+
});
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import type { Plugin, GetSdkType } from "../../types/plugin";
|
|
2
|
+
import type { AuthenticationItem } from "../../types/domain";
|
|
3
|
+
import {
|
|
4
|
+
FindFirstAuthenticationSchema,
|
|
5
|
+
type FindFirstAuthenticationOptions,
|
|
6
|
+
} from "./schemas";
|
|
7
|
+
import { createFunction } from "../../utils/function-utils";
|
|
8
|
+
import type { ListAuthenticationsPluginProvides } from "../listAuthentications";
|
|
9
|
+
|
|
10
|
+
export interface FindFirstAuthenticationPluginProvides {
|
|
11
|
+
findFirstAuthentication: (
|
|
12
|
+
options?: FindFirstAuthenticationOptions,
|
|
13
|
+
) => Promise<{ data: AuthenticationItem | null }>;
|
|
14
|
+
context: {
|
|
15
|
+
meta: {
|
|
16
|
+
findFirstAuthentication: {
|
|
17
|
+
inputSchema: typeof FindFirstAuthenticationSchema;
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export const findFirstAuthenticationPlugin: Plugin<
|
|
24
|
+
GetSdkType<ListAuthenticationsPluginProvides>, // requires listAuthentications in SDK
|
|
25
|
+
{}, // no context requirements
|
|
26
|
+
FindFirstAuthenticationPluginProvides
|
|
27
|
+
> = ({ sdk }) => {
|
|
28
|
+
const findFirstAuthentication = createFunction(
|
|
29
|
+
async function findFirstAuthentication(
|
|
30
|
+
options: FindFirstAuthenticationOptions = {},
|
|
31
|
+
) {
|
|
32
|
+
// Use listAuthentications with maxItems 1 to get the first result
|
|
33
|
+
const authsResponse = await sdk.listAuthentications({
|
|
34
|
+
...options,
|
|
35
|
+
maxItems: 1,
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
return {
|
|
39
|
+
data: authsResponse.data.length > 0 ? authsResponse.data[0] : null,
|
|
40
|
+
};
|
|
41
|
+
},
|
|
42
|
+
FindFirstAuthenticationSchema,
|
|
43
|
+
);
|
|
44
|
+
|
|
45
|
+
return {
|
|
46
|
+
findFirstAuthentication,
|
|
47
|
+
context: {
|
|
48
|
+
meta: {
|
|
49
|
+
findFirstAuthentication: {
|
|
50
|
+
inputSchema: FindFirstAuthenticationSchema,
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
},
|
|
54
|
+
};
|
|
55
|
+
};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { AppKeyPropertySchema } from "../../types/properties";
|
|
3
|
+
import type { AuthenticationItem } from "../../types/domain";
|
|
4
|
+
|
|
5
|
+
// Pure Zod schema - no resolver metadata!
|
|
6
|
+
export const FindFirstAuthenticationSchema = z
|
|
7
|
+
.object({
|
|
8
|
+
appKey: AppKeyPropertySchema.optional().describe(
|
|
9
|
+
"App key of authentication to find (e.g., 'SlackCLIAPI')",
|
|
10
|
+
),
|
|
11
|
+
search: z
|
|
12
|
+
.string()
|
|
13
|
+
.optional()
|
|
14
|
+
.describe("Search term to filter authentications by title"),
|
|
15
|
+
title: z
|
|
16
|
+
.string()
|
|
17
|
+
.optional()
|
|
18
|
+
.describe("Filter authentications by exact title match"),
|
|
19
|
+
account_id: z.string().optional().describe("Filter by account ID"),
|
|
20
|
+
owner: z.string().optional().describe("Filter by owner"),
|
|
21
|
+
})
|
|
22
|
+
.describe("Find the first authentication matching the criteria");
|
|
23
|
+
|
|
24
|
+
// Type inferred from schema
|
|
25
|
+
export type FindFirstAuthenticationOptions = z.infer<
|
|
26
|
+
typeof FindFirstAuthenticationSchema
|
|
27
|
+
>;
|
|
28
|
+
|
|
29
|
+
// Error union for this function (inherits from listAuthenticationsSafe)
|
|
30
|
+
export type FindFirstAuthenticationError =
|
|
31
|
+
| import("../../types/errors").ZapierAuthenticationError
|
|
32
|
+
| import("../../types/errors").ZapierApiError
|
|
33
|
+
| import("../../types/errors").ZapierValidationError
|
|
34
|
+
| import("../../types/errors").ZapierUnknownError;
|
|
35
|
+
|
|
36
|
+
// SDK function interface
|
|
37
|
+
export interface FindFirstAuthenticationSdkFunction {
|
|
38
|
+
findFirstAuthentication: (
|
|
39
|
+
options?: FindFirstAuthenticationOptions,
|
|
40
|
+
) => Promise<{ data: AuthenticationItem | null }>;
|
|
41
|
+
}
|