@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
|
@@ -0,0 +1,313 @@
|
|
|
1
|
+
import { describe, it, expect, vi, beforeEach } from "vitest";
|
|
2
|
+
import { ZapierValidationError } from "../../types/errors";
|
|
3
|
+
import { listAppsPlugin } from "./index";
|
|
4
|
+
import { createSdk } from "../../sdk";
|
|
5
|
+
import { apiPlugin } from "../api/index";
|
|
6
|
+
const mockAppsResponse = {
|
|
7
|
+
results: [
|
|
8
|
+
{
|
|
9
|
+
id: "SlackCLIAPI@1.0.0",
|
|
10
|
+
slug: "slack",
|
|
11
|
+
name: "Slack",
|
|
12
|
+
description: "Team communication",
|
|
13
|
+
primary_color: "#4A154B",
|
|
14
|
+
categories: ["communication"],
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
id: "GoogleSheetsCLIAPI@1.0.0",
|
|
18
|
+
slug: "google-sheets",
|
|
19
|
+
name: "Google Sheets",
|
|
20
|
+
description: "Online spreadsheets",
|
|
21
|
+
primary_color: "#34A853",
|
|
22
|
+
categories: ["productivity"],
|
|
23
|
+
},
|
|
24
|
+
],
|
|
25
|
+
meta: {
|
|
26
|
+
next_cursor: null,
|
|
27
|
+
},
|
|
28
|
+
};
|
|
29
|
+
function createTestSdk() {
|
|
30
|
+
return createSdk()
|
|
31
|
+
.addPlugin(apiPlugin, { fetch: global.fetch })
|
|
32
|
+
.addPlugin(listAppsPlugin);
|
|
33
|
+
}
|
|
34
|
+
describe("listApps plugin", () => {
|
|
35
|
+
beforeEach(() => {
|
|
36
|
+
vi.clearAllMocks();
|
|
37
|
+
});
|
|
38
|
+
describe("schema validation", () => {
|
|
39
|
+
it("should pass validation with empty options", async () => {
|
|
40
|
+
const mockServicesResponse = {
|
|
41
|
+
results: [
|
|
42
|
+
{
|
|
43
|
+
id: "slack_service_id",
|
|
44
|
+
slug: "slack",
|
|
45
|
+
name: "Slack",
|
|
46
|
+
description: "Team communication",
|
|
47
|
+
current_implementation_id: "SlackCLIAPI@1.0.0",
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
id: "sheets_service_id",
|
|
51
|
+
slug: "google-sheets",
|
|
52
|
+
name: "Google Sheets",
|
|
53
|
+
description: "Online spreadsheets",
|
|
54
|
+
current_implementation_id: "GoogleSheetsCLIAPI@1.0.0",
|
|
55
|
+
},
|
|
56
|
+
],
|
|
57
|
+
next: null,
|
|
58
|
+
};
|
|
59
|
+
const sdk = createTestSdk();
|
|
60
|
+
const context = sdk.getContext();
|
|
61
|
+
// Mock the API client in context
|
|
62
|
+
context.api.get = vi
|
|
63
|
+
.fn()
|
|
64
|
+
.mockResolvedValue(mockServicesResponse);
|
|
65
|
+
const result = await sdk.listApps({});
|
|
66
|
+
expect(result.data).toHaveLength(2);
|
|
67
|
+
});
|
|
68
|
+
it("should handle undefined options by converting to empty object", async () => {
|
|
69
|
+
const sdk = createTestSdk();
|
|
70
|
+
const context = sdk.getContext();
|
|
71
|
+
// Mock the API client in context
|
|
72
|
+
context.api.get = vi.fn().mockResolvedValueOnce({
|
|
73
|
+
results: [
|
|
74
|
+
{
|
|
75
|
+
id: "SlackCLIAPI@1.0.0",
|
|
76
|
+
name: "Slack",
|
|
77
|
+
description: "Team communication",
|
|
78
|
+
primary_color: "#4A154B",
|
|
79
|
+
categories: ["communication"],
|
|
80
|
+
},
|
|
81
|
+
],
|
|
82
|
+
next: null,
|
|
83
|
+
});
|
|
84
|
+
const result = await sdk.listApps(undefined);
|
|
85
|
+
expect(result.data).toHaveLength(1);
|
|
86
|
+
expect(result.data[0]).toMatchObject({
|
|
87
|
+
key: "SlackCLIAPI",
|
|
88
|
+
title: "Slack",
|
|
89
|
+
});
|
|
90
|
+
expect(context.api.get).toHaveBeenCalledWith("/api/v4/implementations-meta/lookup/", {
|
|
91
|
+
searchParams: { latest_only: "true", limit: "100" },
|
|
92
|
+
});
|
|
93
|
+
});
|
|
94
|
+
it("should throw validation error for invalid pageSize", () => {
|
|
95
|
+
const sdk = createTestSdk();
|
|
96
|
+
expect(() => {
|
|
97
|
+
sdk.listApps({
|
|
98
|
+
pageSize: 0, // Should be >= 1
|
|
99
|
+
});
|
|
100
|
+
}).toThrow(ZapierValidationError);
|
|
101
|
+
expect(() => {
|
|
102
|
+
sdk.listApps({
|
|
103
|
+
pageSize: -5, // Should be >= 1
|
|
104
|
+
});
|
|
105
|
+
}).toThrow(ZapierValidationError);
|
|
106
|
+
});
|
|
107
|
+
it("should throw validation error for invalid maxItems", () => {
|
|
108
|
+
const sdk = createTestSdk();
|
|
109
|
+
expect(() => {
|
|
110
|
+
sdk.listApps({
|
|
111
|
+
maxItems: 0, // Should be >= 1
|
|
112
|
+
});
|
|
113
|
+
}).toThrow(ZapierValidationError);
|
|
114
|
+
expect(() => {
|
|
115
|
+
sdk.listApps({
|
|
116
|
+
maxItems: -10, // Should be >= 1
|
|
117
|
+
});
|
|
118
|
+
}).toThrow(ZapierValidationError);
|
|
119
|
+
});
|
|
120
|
+
it("should throw validation error for invalid appKeys type", () => {
|
|
121
|
+
const sdk = createTestSdk();
|
|
122
|
+
expect(() => {
|
|
123
|
+
sdk.listApps({
|
|
124
|
+
appKeys: 123,
|
|
125
|
+
});
|
|
126
|
+
}).toThrow(ZapierValidationError);
|
|
127
|
+
});
|
|
128
|
+
it("should pass validation with all valid fields", async () => {
|
|
129
|
+
const sdk = createTestSdk();
|
|
130
|
+
const context = sdk.getContext();
|
|
131
|
+
// Mock the API client in context
|
|
132
|
+
context.api.get = vi.fn().mockResolvedValueOnce({
|
|
133
|
+
results: [
|
|
134
|
+
{
|
|
135
|
+
id: "SlackCLIAPI@1.0.0",
|
|
136
|
+
name: "Slack",
|
|
137
|
+
description: "Team communication",
|
|
138
|
+
primary_color: "#4A154B",
|
|
139
|
+
categories: ["communication"],
|
|
140
|
+
},
|
|
141
|
+
{
|
|
142
|
+
id: "GitHubCLIAPI@1.0.0",
|
|
143
|
+
name: "GitHub",
|
|
144
|
+
description: "Code repository hosting",
|
|
145
|
+
primary_color: "#24292e",
|
|
146
|
+
categories: ["developer-tools"],
|
|
147
|
+
},
|
|
148
|
+
],
|
|
149
|
+
next: null,
|
|
150
|
+
});
|
|
151
|
+
const result = await sdk.listApps({
|
|
152
|
+
appKeys: ["SlackCLIAPI", "GitHubCLIAPI"],
|
|
153
|
+
pageSize: 10,
|
|
154
|
+
maxItems: 50,
|
|
155
|
+
});
|
|
156
|
+
expect(result.data).toHaveLength(2);
|
|
157
|
+
expect(result.data[0].key).toBe("SlackCLIAPI");
|
|
158
|
+
expect(result.data[1].key).toBe("GitHubCLIAPI");
|
|
159
|
+
});
|
|
160
|
+
});
|
|
161
|
+
describe("data mapping", () => {
|
|
162
|
+
it("should return essential app properties", async () => {
|
|
163
|
+
const mockServicesResponse = {
|
|
164
|
+
results: [
|
|
165
|
+
{
|
|
166
|
+
id: "slack_service_id",
|
|
167
|
+
slug: "slack",
|
|
168
|
+
name: "Slack",
|
|
169
|
+
description: "Team communication",
|
|
170
|
+
current_implementation_id: "SlackCLIAPI@1.0.0",
|
|
171
|
+
},
|
|
172
|
+
],
|
|
173
|
+
next: null,
|
|
174
|
+
};
|
|
175
|
+
const sdk = createTestSdk();
|
|
176
|
+
const context = sdk.getContext();
|
|
177
|
+
// Mock the API client in context
|
|
178
|
+
context.api.get = vi
|
|
179
|
+
.fn()
|
|
180
|
+
.mockResolvedValue(mockServicesResponse);
|
|
181
|
+
const result = await sdk.listApps({});
|
|
182
|
+
expect(result.data[0]).toHaveProperty("title");
|
|
183
|
+
expect(result.data[0]).toHaveProperty("key");
|
|
184
|
+
expect(result.data[0]).toHaveProperty("current_implementation_id");
|
|
185
|
+
// Version is optional
|
|
186
|
+
expect(result.data[0]).toHaveProperty("version");
|
|
187
|
+
});
|
|
188
|
+
});
|
|
189
|
+
describe("pagination", () => {
|
|
190
|
+
it("should handle pagination with maxItems", async () => {
|
|
191
|
+
const mockServicesResponse = {
|
|
192
|
+
results: [
|
|
193
|
+
{
|
|
194
|
+
id: "slack_service_id",
|
|
195
|
+
slug: "slack",
|
|
196
|
+
name: "Slack",
|
|
197
|
+
description: "Team communication",
|
|
198
|
+
current_implementation_id: "SlackCLIAPI@1.0.0",
|
|
199
|
+
},
|
|
200
|
+
{
|
|
201
|
+
id: "sheets_service_id",
|
|
202
|
+
slug: "google-sheets",
|
|
203
|
+
name: "Google Sheets",
|
|
204
|
+
description: "Online spreadsheets",
|
|
205
|
+
current_implementation_id: "GoogleSheetsCLIAPI@1.0.0",
|
|
206
|
+
},
|
|
207
|
+
],
|
|
208
|
+
next: null,
|
|
209
|
+
};
|
|
210
|
+
const sdk = createTestSdk();
|
|
211
|
+
const context = sdk.getContext();
|
|
212
|
+
const mockGet = vi.fn().mockResolvedValue(mockServicesResponse);
|
|
213
|
+
context.api.get = mockGet;
|
|
214
|
+
const result = await sdk.listApps({ maxItems: 5 });
|
|
215
|
+
// Should return all items since maxItems (5) is greater than available items (2)
|
|
216
|
+
expect(result.data).toHaveLength(2);
|
|
217
|
+
expect(mockGet).toHaveBeenCalledTimes(1);
|
|
218
|
+
});
|
|
219
|
+
it("should support async iteration over pages", async () => {
|
|
220
|
+
const sdk = createTestSdk();
|
|
221
|
+
const context = sdk.getContext();
|
|
222
|
+
const mockGet = vi
|
|
223
|
+
.fn()
|
|
224
|
+
.mockResolvedValueOnce({
|
|
225
|
+
results: [
|
|
226
|
+
{
|
|
227
|
+
id: "SlackCLIAPI@1.0.0",
|
|
228
|
+
slug: "slack",
|
|
229
|
+
name: "Slack",
|
|
230
|
+
description: "Team communication",
|
|
231
|
+
},
|
|
232
|
+
],
|
|
233
|
+
next: "https://zapier.com/api/v4/services/?offset=cursor-page-2",
|
|
234
|
+
})
|
|
235
|
+
.mockResolvedValueOnce({
|
|
236
|
+
results: [
|
|
237
|
+
{
|
|
238
|
+
id: "GoogleSheetsCLIAPI@1.0.0",
|
|
239
|
+
slug: "google-sheets",
|
|
240
|
+
name: "Google Sheets",
|
|
241
|
+
description: "Online spreadsheets",
|
|
242
|
+
},
|
|
243
|
+
],
|
|
244
|
+
next: null,
|
|
245
|
+
});
|
|
246
|
+
context.api.get = mockGet;
|
|
247
|
+
const pages = [];
|
|
248
|
+
for await (const page of sdk.listApps({ pageSize: 1 })) {
|
|
249
|
+
pages.push(page);
|
|
250
|
+
if (pages.length >= 2)
|
|
251
|
+
break;
|
|
252
|
+
}
|
|
253
|
+
expect(pages).toHaveLength(2);
|
|
254
|
+
expect(pages[0].data).toHaveLength(1);
|
|
255
|
+
expect(pages[1].data).toHaveLength(1);
|
|
256
|
+
expect(pages[0].data[0].key).toBe("SlackCLIAPI");
|
|
257
|
+
expect(pages[1].data[0].key).toBe("GoogleSheetsCLIAPI");
|
|
258
|
+
});
|
|
259
|
+
it("should support async iteration over individual items", async () => {
|
|
260
|
+
const mockServicesResponse = {
|
|
261
|
+
results: [
|
|
262
|
+
{
|
|
263
|
+
id: "SlackCLIAPI@1.0.0",
|
|
264
|
+
slug: "slack",
|
|
265
|
+
name: "Slack",
|
|
266
|
+
description: "Team communication",
|
|
267
|
+
},
|
|
268
|
+
{
|
|
269
|
+
id: "GoogleSheetsCLIAPI@1.0.0",
|
|
270
|
+
slug: "google-sheets",
|
|
271
|
+
name: "Google Sheets",
|
|
272
|
+
description: "Online spreadsheets",
|
|
273
|
+
},
|
|
274
|
+
],
|
|
275
|
+
next: null,
|
|
276
|
+
};
|
|
277
|
+
const sdk = createTestSdk();
|
|
278
|
+
const context = sdk.getContext();
|
|
279
|
+
context.api.get = vi
|
|
280
|
+
.fn()
|
|
281
|
+
.mockResolvedValue(mockServicesResponse);
|
|
282
|
+
const items = [];
|
|
283
|
+
for await (const item of sdk.listApps({ maxItems: 2 }).items()) {
|
|
284
|
+
items.push(item);
|
|
285
|
+
}
|
|
286
|
+
expect(items).toHaveLength(2);
|
|
287
|
+
expect(items[0].key).toBe("SlackCLIAPI");
|
|
288
|
+
expect(items[1].key).toBe("GoogleSheetsCLIAPI");
|
|
289
|
+
});
|
|
290
|
+
});
|
|
291
|
+
describe("API integration", () => {
|
|
292
|
+
it("should pass appKeys filter to API", async () => {
|
|
293
|
+
const sdk = createTestSdk();
|
|
294
|
+
const context = sdk.getContext();
|
|
295
|
+
const mockGet = vi.fn().mockResolvedValue(mockAppsResponse);
|
|
296
|
+
context.api.get = mockGet;
|
|
297
|
+
await sdk.listApps({ appKeys: ["SlackCLIAPI", "GitHubCLIAPI"] });
|
|
298
|
+
expect(mockGet).toHaveBeenCalledWith(expect.stringContaining("implementations-meta"), expect.objectContaining({
|
|
299
|
+
searchParams: expect.objectContaining({
|
|
300
|
+
selected_apis: "SlackCLIAPI,GitHubCLIAPI",
|
|
301
|
+
}),
|
|
302
|
+
}));
|
|
303
|
+
});
|
|
304
|
+
});
|
|
305
|
+
describe("plugin integration", () => {
|
|
306
|
+
it("should provide metadata in context", () => {
|
|
307
|
+
const sdk = createTestSdk();
|
|
308
|
+
const context = sdk.getContext();
|
|
309
|
+
expect(context.meta.listApps).toBeDefined();
|
|
310
|
+
expect(context.meta.listApps.inputSchema).toBeDefined();
|
|
311
|
+
});
|
|
312
|
+
});
|
|
313
|
+
});
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import type { AppItem } from "../../types/domain";
|
|
3
|
+
import type { PaginatedSdkFunction } from "../../types/functions";
|
|
4
|
+
import { ZapierApiError, ZapierValidationError } from "../../types/errors";
|
|
5
|
+
export type ListAppsError = ZapierApiError | ZapierValidationError;
|
|
6
|
+
export interface ListAppsPage {
|
|
7
|
+
data: AppItem[];
|
|
8
|
+
nextCursor?: string;
|
|
9
|
+
}
|
|
10
|
+
export declare const ListAppsSchema: z.ZodObject<{
|
|
11
|
+
appKeys: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
12
|
+
search: z.ZodOptional<z.ZodString>;
|
|
13
|
+
pageSize: z.ZodOptional<z.ZodNumber>;
|
|
14
|
+
maxItems: z.ZodOptional<z.ZodNumber>;
|
|
15
|
+
}, "strip", z.ZodTypeAny, {
|
|
16
|
+
search?: string | undefined;
|
|
17
|
+
maxItems?: number | undefined;
|
|
18
|
+
pageSize?: number | undefined;
|
|
19
|
+
appKeys?: string[] | undefined;
|
|
20
|
+
}, {
|
|
21
|
+
search?: string | undefined;
|
|
22
|
+
maxItems?: number | undefined;
|
|
23
|
+
pageSize?: number | undefined;
|
|
24
|
+
appKeys?: string[] | undefined;
|
|
25
|
+
}>;
|
|
26
|
+
export type ListAppsOptions = z.infer<typeof ListAppsSchema>;
|
|
27
|
+
export interface ListAppsSdkFunction {
|
|
28
|
+
listApps: PaginatedSdkFunction<ListAppsOptions | undefined, AppItem>;
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=schemas.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../../../src/plugins/listApps/schemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAClE,OAAO,EAAE,cAAc,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAK3E,MAAM,MAAM,aAAa,GAAG,cAAc,GAAG,qBAAqB,CAAC;AAGnE,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,OAAO,EAAE,CAAC;IAChB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAGD,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;EAuB1B,CAAC;AAGF,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,cAAc,CAAC,CAAC;AAG7D,MAAM,WAAW,mBAAmB;IAClC,QAAQ,EAAE,oBAAoB,CAAC,eAAe,GAAG,SAAS,EAAE,OAAO,CAAC,CAAC;CACtE"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { AppItemSchema } from "../../schemas/App";
|
|
3
|
+
import { withOutputSchema } from "../../utils/schema-utils";
|
|
4
|
+
// Pure Zod schema - no pagination metadata exposed
|
|
5
|
+
export const ListAppsSchema = withOutputSchema(z
|
|
6
|
+
.object({
|
|
7
|
+
appKeys: z
|
|
8
|
+
.array(z.string())
|
|
9
|
+
.optional()
|
|
10
|
+
.describe("Filter apps by app keys (e.g., 'SlackCLIAPI' or slug like 'github')"),
|
|
11
|
+
search: z.string().optional().describe("Search for apps by name"),
|
|
12
|
+
pageSize: z
|
|
13
|
+
.number()
|
|
14
|
+
.min(1)
|
|
15
|
+
.optional()
|
|
16
|
+
.describe("Number of apps per page"),
|
|
17
|
+
maxItems: z
|
|
18
|
+
.number()
|
|
19
|
+
.min(1)
|
|
20
|
+
.optional()
|
|
21
|
+
.describe("Maximum total items to return across all pages"),
|
|
22
|
+
})
|
|
23
|
+
.describe("List all available apps with optional filtering"), AppItemSchema);
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { Plugin, GetSdkType } from "../../types/plugin";
|
|
2
|
+
import type { ApiClient } from "../../api";
|
|
3
|
+
import type { AuthenticationItem } from "../../types/domain";
|
|
4
|
+
import { ListAuthenticationsSchema, type ListAuthenticationsOptions } from "./schemas";
|
|
5
|
+
import type { GetAppPluginProvides } from "../getApp";
|
|
6
|
+
export interface ListAuthenticationsPluginProvides {
|
|
7
|
+
listAuthentications: (options?: ListAuthenticationsOptions) => Promise<{
|
|
8
|
+
data: AuthenticationItem[];
|
|
9
|
+
}> & AsyncIterable<{
|
|
10
|
+
data: AuthenticationItem[];
|
|
11
|
+
nextCursor?: string;
|
|
12
|
+
}> & {
|
|
13
|
+
items(): AsyncIterable<AuthenticationItem>;
|
|
14
|
+
};
|
|
15
|
+
context: {
|
|
16
|
+
meta: {
|
|
17
|
+
listAuthentications: {
|
|
18
|
+
inputSchema: typeof ListAuthenticationsSchema;
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
export declare const listAuthenticationsPlugin: Plugin<GetSdkType<GetAppPluginProvides>, // requires getApp in SDK
|
|
24
|
+
{
|
|
25
|
+
api: ApiClient;
|
|
26
|
+
}, // requires api in context
|
|
27
|
+
ListAuthenticationsPluginProvides>;
|
|
28
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/listAuthentications/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAC7D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAE3C,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAC7D,OAAO,EACL,yBAAyB,EACzB,KAAK,0BAA0B,EAEhC,MAAM,WAAW,CAAC;AAOnB,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAC;AAEtD,MAAM,WAAW,iCAAiC;IAChD,mBAAmB,EAAE,CAAC,OAAO,CAAC,EAAE,0BAA0B,KAAK,OAAO,CAAC;QACrE,IAAI,EAAE,kBAAkB,EAAE,CAAC;KAC5B,CAAC,GACA,aAAa,CAAC;QAAE,IAAI,EAAE,kBAAkB,EAAE,CAAC;QAAC,UAAU,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,GAAG;QACnE,KAAK,IAAI,aAAa,CAAC,kBAAkB,CAAC,CAAC;KAC5C,CAAC;IACJ,OAAO,EAAE;QACP,IAAI,EAAE;YACJ,mBAAmB,EAAE;gBACnB,WAAW,EAAE,OAAO,yBAAyB,CAAC;aAC/C,CAAC;SACH,CAAC;KACH,CAAC;CACH;AAED,eAAO,MAAM,yBAAyB,EAAE,MAAM,CAC5C,UAAU,CAAC,oBAAoB,CAAC,EAAE,yBAAyB;AAC3D;IAAE,GAAG,EAAE,SAAS,CAAA;CAAE,EAAE,0BAA0B;AAC9C,iCAAiC,CAmGlC,CAAC"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { ListAuthenticationsSchema, } from "./schemas";
|
|
2
|
+
import { normalizeAuthenticationItem } from "../../utils/domain-utils";
|
|
3
|
+
import { ZapierAuthenticationError } from "../../types/errors";
|
|
4
|
+
import { createPaginatedFunction, extractCursor, } from "../../utils/function-utils";
|
|
5
|
+
export const listAuthenticationsPlugin = ({ sdk, context }) => {
|
|
6
|
+
const listAuthentications = createPaginatedFunction(async function listAuthenticationsPage(options) {
|
|
7
|
+
const { api } = context;
|
|
8
|
+
// Build search parameters
|
|
9
|
+
const searchParams = {};
|
|
10
|
+
// Handle appKey filtering by getting the selected_api first
|
|
11
|
+
if (options.appKey) {
|
|
12
|
+
const app = await sdk.getApp({
|
|
13
|
+
appKey: options.appKey,
|
|
14
|
+
});
|
|
15
|
+
const selectedApi = app.data.current_implementation_id;
|
|
16
|
+
if (selectedApi) {
|
|
17
|
+
// Use versionless_selected_api to find auths across all app versions
|
|
18
|
+
// Extract the base name without the version (e.g., "SlackCLIAPI" from "SlackCLIAPI@1.21.1")
|
|
19
|
+
const versionlessApi = selectedApi.split("@")[0];
|
|
20
|
+
searchParams.versionless_selected_api = versionlessApi;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
// Add other query parameters if provided
|
|
24
|
+
// Use title as search if no explicit search provided
|
|
25
|
+
if (options.search) {
|
|
26
|
+
searchParams.search = options.search;
|
|
27
|
+
}
|
|
28
|
+
else if (options.title) {
|
|
29
|
+
searchParams.search = options.title;
|
|
30
|
+
}
|
|
31
|
+
if (options.account_id) {
|
|
32
|
+
searchParams.account_id = options.account_id;
|
|
33
|
+
}
|
|
34
|
+
if (options.owner) {
|
|
35
|
+
searchParams.owner = options.owner;
|
|
36
|
+
}
|
|
37
|
+
// pageSize is now guaranteed to be set by the higher-order function
|
|
38
|
+
searchParams.limit = options.pageSize.toString();
|
|
39
|
+
if (options.cursor) {
|
|
40
|
+
// Convert cursor back to offset for the API
|
|
41
|
+
searchParams.offset = options.cursor;
|
|
42
|
+
}
|
|
43
|
+
const data = await api.get("/api/v4/authentications/", {
|
|
44
|
+
searchParams,
|
|
45
|
+
customErrorHandler: ({ status }) => {
|
|
46
|
+
if (status === 401) {
|
|
47
|
+
return new ZapierAuthenticationError(`Authentication failed. Your token may not have permission to access authentications or may be expired. (HTTP ${status})`, { statusCode: status });
|
|
48
|
+
}
|
|
49
|
+
if (status === 403) {
|
|
50
|
+
return new ZapierAuthenticationError(`Access forbidden. Your token may not have the required scopes to list authentications. (HTTP ${status})`, { statusCode: status });
|
|
51
|
+
}
|
|
52
|
+
return undefined;
|
|
53
|
+
},
|
|
54
|
+
authRequired: true,
|
|
55
|
+
});
|
|
56
|
+
// Transform API response and filter by exact title match if specified
|
|
57
|
+
let auths = (data.results || []).map((auth) => normalizeAuthenticationItem(auth));
|
|
58
|
+
// Filter by exact title match if specified
|
|
59
|
+
if (options.title) {
|
|
60
|
+
auths = auths.filter((auth) => auth.title === options.title);
|
|
61
|
+
}
|
|
62
|
+
return {
|
|
63
|
+
data: auths,
|
|
64
|
+
nextCursor: extractCursor(data),
|
|
65
|
+
};
|
|
66
|
+
}, ListAuthenticationsSchema);
|
|
67
|
+
return {
|
|
68
|
+
listAuthentications,
|
|
69
|
+
context: {
|
|
70
|
+
meta: {
|
|
71
|
+
listAuthentications: {
|
|
72
|
+
inputSchema: ListAuthenticationsSchema,
|
|
73
|
+
},
|
|
74
|
+
},
|
|
75
|
+
},
|
|
76
|
+
};
|
|
77
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.test.d.ts","sourceRoot":"","sources":["../../../src/plugins/listAuthentications/index.test.ts"],"names":[],"mappings":""}
|