@zapier/zapier-sdk 0.18.4 → 0.19.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +35 -0
- package/README.md +43 -31
- package/dist/index.cjs +365 -64
- package/dist/index.d.mts +220 -33
- package/dist/index.d.ts +2541 -40
- package/dist/index.mjs +345 -63
- package/package.json +14 -13
- package/dist/api/auth.d.ts +0 -19
- package/dist/api/auth.d.ts.map +0 -1
- package/dist/api/auth.js +0 -70
- package/dist/api/auth.test.d.ts +0 -2
- package/dist/api/auth.test.d.ts.map +0 -1
- package/dist/api/auth.test.js +0 -220
- package/dist/api/client.d.ts +0 -9
- package/dist/api/client.d.ts.map +0 -1
- package/dist/api/client.js +0 -356
- package/dist/api/client.test.d.ts +0 -2
- package/dist/api/client.test.d.ts.map +0 -1
- package/dist/api/client.test.js +0 -96
- package/dist/api/debug.d.ts +0 -14
- package/dist/api/debug.d.ts.map +0 -1
- package/dist/api/debug.js +0 -131
- package/dist/api/debug.test.d.ts +0 -2
- package/dist/api/debug.test.d.ts.map +0 -1
- package/dist/api/debug.test.js +0 -59
- package/dist/api/index.d.ts +0 -30
- package/dist/api/index.d.ts.map +0 -1
- package/dist/api/index.js +0 -43
- package/dist/api/polling.d.ts +0 -46
- package/dist/api/polling.d.ts.map +0 -1
- package/dist/api/polling.js +0 -139
- package/dist/api/polling.test.d.ts +0 -2
- package/dist/api/polling.test.d.ts.map +0 -1
- package/dist/api/polling.test.js +0 -318
- package/dist/api/schemas.d.ts +0 -422
- package/dist/api/schemas.d.ts.map +0 -1
- package/dist/api/schemas.js +0 -322
- package/dist/api/types.d.ts +0 -83
- package/dist/api/types.d.ts.map +0 -1
- package/dist/api/types.js +0 -1
- package/dist/auth.d.ts +0 -52
- package/dist/auth.d.ts.map +0 -1
- package/dist/auth.js +0 -72
- package/dist/auth.test.d.ts +0 -2
- package/dist/auth.test.d.ts.map +0 -1
- package/dist/auth.test.js +0 -102
- package/dist/constants.d.ts +0 -14
- package/dist/constants.d.ts.map +0 -1
- package/dist/constants.js +0 -13
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -42
- package/dist/plugins/api/index.d.ts +0 -12
- package/dist/plugins/api/index.d.ts.map +0 -1
- package/dist/plugins/api/index.js +0 -24
- package/dist/plugins/apps/index.d.ts +0 -15
- package/dist/plugins/apps/index.d.ts.map +0 -1
- package/dist/plugins/apps/index.js +0 -112
- package/dist/plugins/apps/schemas.d.ts +0 -42
- package/dist/plugins/apps/schemas.d.ts.map +0 -1
- package/dist/plugins/apps/schemas.js +0 -14
- package/dist/plugins/eventEmission/builders.d.ts +0 -14
- package/dist/plugins/eventEmission/builders.d.ts.map +0 -1
- package/dist/plugins/eventEmission/builders.js +0 -109
- package/dist/plugins/eventEmission/index.d.ts +0 -38
- package/dist/plugins/eventEmission/index.d.ts.map +0 -1
- package/dist/plugins/eventEmission/index.js +0 -336
- package/dist/plugins/eventEmission/index.test.d.ts +0 -5
- package/dist/plugins/eventEmission/index.test.d.ts.map +0 -1
- package/dist/plugins/eventEmission/index.test.js +0 -581
- package/dist/plugins/eventEmission/transport.d.ts +0 -27
- package/dist/plugins/eventEmission/transport.d.ts.map +0 -1
- package/dist/plugins/eventEmission/transport.js +0 -104
- package/dist/plugins/eventEmission/transport.test.d.ts +0 -5
- package/dist/plugins/eventEmission/transport.test.d.ts.map +0 -1
- package/dist/plugins/eventEmission/transport.test.js +0 -164
- package/dist/plugins/eventEmission/types.d.ts +0 -63
- package/dist/plugins/eventEmission/types.d.ts.map +0 -1
- package/dist/plugins/eventEmission/types.js +0 -1
- package/dist/plugins/eventEmission/utils.d.ts +0 -45
- package/dist/plugins/eventEmission/utils.d.ts.map +0 -1
- package/dist/plugins/eventEmission/utils.js +0 -114
- package/dist/plugins/fetch/index.d.ts +0 -36
- package/dist/plugins/fetch/index.d.ts.map +0 -1
- package/dist/plugins/fetch/index.js +0 -62
- package/dist/plugins/fetch/schemas.d.ts +0 -19
- package/dist/plugins/fetch/schemas.d.ts.map +0 -1
- package/dist/plugins/fetch/schemas.js +0 -31
- package/dist/plugins/findFirstAuthentication/index.d.ts +0 -21
- package/dist/plugins/findFirstAuthentication/index.d.ts.map +0 -1
- package/dist/plugins/findFirstAuthentication/index.js +0 -36
- package/dist/plugins/findFirstAuthentication/index.test.d.ts +0 -2
- package/dist/plugins/findFirstAuthentication/index.test.d.ts.map +0 -1
- package/dist/plugins/findFirstAuthentication/index.test.js +0 -177
- package/dist/plugins/findFirstAuthentication/schemas.d.ts +0 -20
- package/dist/plugins/findFirstAuthentication/schemas.d.ts.map +0 -1
- package/dist/plugins/findFirstAuthentication/schemas.js +0 -18
- package/dist/plugins/findUniqueAuthentication/index.d.ts +0 -21
- package/dist/plugins/findUniqueAuthentication/index.d.ts.map +0 -1
- package/dist/plugins/findUniqueAuthentication/index.js +0 -39
- package/dist/plugins/findUniqueAuthentication/index.test.d.ts +0 -2
- package/dist/plugins/findUniqueAuthentication/index.test.d.ts.map +0 -1
- package/dist/plugins/findUniqueAuthentication/index.test.js +0 -159
- package/dist/plugins/findUniqueAuthentication/schemas.d.ts +0 -20
- package/dist/plugins/findUniqueAuthentication/schemas.d.ts.map +0 -1
- package/dist/plugins/findUniqueAuthentication/schemas.js +0 -18
- package/dist/plugins/getAction/index.d.ts +0 -25
- package/dist/plugins/getAction/index.d.ts.map +0 -1
- package/dist/plugins/getAction/index.js +0 -42
- package/dist/plugins/getAction/index.test.d.ts +0 -2
- package/dist/plugins/getAction/index.test.d.ts.map +0 -1
- package/dist/plugins/getAction/index.test.js +0 -211
- package/dist/plugins/getAction/schemas.d.ts +0 -30
- package/dist/plugins/getAction/schemas.d.ts.map +0 -1
- package/dist/plugins/getAction/schemas.js +0 -12
- package/dist/plugins/getApp/index.d.ts +0 -21
- package/dist/plugins/getApp/index.d.ts.map +0 -1
- package/dist/plugins/getApp/index.js +0 -44
- package/dist/plugins/getApp/index.test.d.ts +0 -2
- package/dist/plugins/getApp/index.test.d.ts.map +0 -1
- package/dist/plugins/getApp/index.test.js +0 -157
- package/dist/plugins/getApp/schemas.d.ts +0 -16
- package/dist/plugins/getApp/schemas.d.ts.map +0 -1
- package/dist/plugins/getApp/schemas.js +0 -8
- package/dist/plugins/getAuthentication/index.d.ts +0 -21
- package/dist/plugins/getAuthentication/index.d.ts.map +0 -1
- package/dist/plugins/getAuthentication/index.js +0 -29
- package/dist/plugins/getAuthentication/index.test.d.ts +0 -2
- package/dist/plugins/getAuthentication/index.test.d.ts.map +0 -1
- package/dist/plugins/getAuthentication/index.test.js +0 -106
- package/dist/plugins/getAuthentication/schemas.d.ts +0 -7
- package/dist/plugins/getAuthentication/schemas.d.ts.map +0 -1
- package/dist/plugins/getAuthentication/schemas.js +0 -1
- package/dist/plugins/getInputFieldsSchema/index.d.ts +0 -23
- package/dist/plugins/getInputFieldsSchema/index.d.ts.map +0 -1
- package/dist/plugins/getInputFieldsSchema/index.js +0 -53
- package/dist/plugins/getInputFieldsSchema/index.test.d.ts +0 -2
- package/dist/plugins/getInputFieldsSchema/index.test.d.ts.map +0 -1
- package/dist/plugins/getInputFieldsSchema/index.test.js +0 -291
- package/dist/plugins/getInputFieldsSchema/schemas.d.ts +0 -28
- package/dist/plugins/getInputFieldsSchema/schemas.d.ts.map +0 -1
- package/dist/plugins/getInputFieldsSchema/schemas.js +0 -13
- package/dist/plugins/getProfile/index.d.ts +0 -25
- package/dist/plugins/getProfile/index.d.ts.map +0 -1
- package/dist/plugins/getProfile/index.js +0 -39
- package/dist/plugins/getProfile/schemas.d.ts +0 -13
- package/dist/plugins/getProfile/schemas.d.ts.map +0 -1
- package/dist/plugins/getProfile/schemas.js +0 -6
- package/dist/plugins/listActions/index.d.ts +0 -30
- package/dist/plugins/listActions/index.d.ts.map +0 -1
- package/dist/plugins/listActions/index.js +0 -75
- package/dist/plugins/listActions/index.test.d.ts +0 -2
- package/dist/plugins/listActions/index.test.d.ts.map +0 -1
- package/dist/plugins/listActions/index.test.js +0 -453
- package/dist/plugins/listActions/schemas.d.ts +0 -35
- package/dist/plugins/listActions/schemas.d.ts.map +0 -1
- package/dist/plugins/listActions/schemas.js +0 -22
- package/dist/plugins/listApps/index.d.ts +0 -19
- package/dist/plugins/listApps/index.d.ts.map +0 -1
- package/dist/plugins/listApps/index.js +0 -67
- package/dist/plugins/listApps/index.test.d.ts +0 -2
- package/dist/plugins/listApps/index.test.d.ts.map +0 -1
- package/dist/plugins/listApps/index.test.js +0 -121
- package/dist/plugins/listApps/schemas.d.ts +0 -47
- package/dist/plugins/listApps/schemas.d.ts.map +0 -1
- package/dist/plugins/listApps/schemas.js +0 -49
- package/dist/plugins/listAuthentications/index.d.ts +0 -24
- package/dist/plugins/listAuthentications/index.d.ts.map +0 -1
- package/dist/plugins/listAuthentications/index.js +0 -77
- package/dist/plugins/listAuthentications/index.test.d.ts +0 -2
- package/dist/plugins/listAuthentications/index.test.d.ts.map +0 -1
- package/dist/plugins/listAuthentications/index.test.js +0 -848
- package/dist/plugins/listAuthentications/schemas.d.ts +0 -30
- package/dist/plugins/listAuthentications/schemas.d.ts.map +0 -1
- package/dist/plugins/listAuthentications/schemas.js +0 -32
- package/dist/plugins/listInputFieldChoices/index.d.ts +0 -33
- package/dist/plugins/listInputFieldChoices/index.d.ts.map +0 -1
- package/dist/plugins/listInputFieldChoices/index.js +0 -115
- package/dist/plugins/listInputFieldChoices/index.test.d.ts +0 -2
- package/dist/plugins/listInputFieldChoices/index.test.d.ts.map +0 -1
- package/dist/plugins/listInputFieldChoices/index.test.js +0 -717
- package/dist/plugins/listInputFieldChoices/schemas.d.ts +0 -43
- package/dist/plugins/listInputFieldChoices/schemas.d.ts.map +0 -1
- package/dist/plugins/listInputFieldChoices/schemas.js +0 -65
- package/dist/plugins/listInputFields/index.d.ts +0 -34
- package/dist/plugins/listInputFields/index.d.ts.map +0 -1
- package/dist/plugins/listInputFields/index.js +0 -204
- package/dist/plugins/listInputFields/index.test.d.ts +0 -2
- package/dist/plugins/listInputFields/index.test.d.ts.map +0 -1
- package/dist/plugins/listInputFields/index.test.js +0 -359
- package/dist/plugins/listInputFields/schemas.d.ts +0 -35
- package/dist/plugins/listInputFields/schemas.d.ts.map +0 -1
- package/dist/plugins/listInputFields/schemas.js +0 -23
- package/dist/plugins/manifest/index.d.ts +0 -85
- package/dist/plugins/manifest/index.d.ts.map +0 -1
- package/dist/plugins/manifest/index.js +0 -376
- package/dist/plugins/manifest/index.test.d.ts +0 -2
- package/dist/plugins/manifest/index.test.d.ts.map +0 -1
- package/dist/plugins/manifest/index.test.js +0 -1139
- package/dist/plugins/manifest/schemas.d.ts +0 -57
- package/dist/plugins/manifest/schemas.d.ts.map +0 -1
- package/dist/plugins/manifest/schemas.js +0 -50
- package/dist/plugins/registry/index.d.ts +0 -21
- package/dist/plugins/registry/index.d.ts.map +0 -1
- package/dist/plugins/registry/index.js +0 -117
- package/dist/plugins/request/index.d.ts +0 -21
- package/dist/plugins/request/index.d.ts.map +0 -1
- package/dist/plugins/request/index.js +0 -76
- package/dist/plugins/request/index.test.d.ts +0 -2
- package/dist/plugins/request/index.test.d.ts.map +0 -1
- package/dist/plugins/request/index.test.js +0 -337
- package/dist/plugins/request/schemas.d.ts +0 -54
- package/dist/plugins/request/schemas.d.ts.map +0 -1
- package/dist/plugins/request/schemas.js +0 -41
- package/dist/plugins/runAction/index.d.ts +0 -33
- package/dist/plugins/runAction/index.d.ts.map +0 -1
- package/dist/plugins/runAction/index.js +0 -108
- package/dist/plugins/runAction/index.test.d.ts +0 -2
- package/dist/plugins/runAction/index.test.d.ts.map +0 -1
- package/dist/plugins/runAction/index.test.js +0 -333
- package/dist/plugins/runAction/schemas.d.ts +0 -34
- package/dist/plugins/runAction/schemas.d.ts.map +0 -1
- package/dist/plugins/runAction/schemas.js +0 -23
- package/dist/resolvers/actionKey.d.ts +0 -15
- package/dist/resolvers/actionKey.d.ts.map +0 -1
- package/dist/resolvers/actionKey.js +0 -19
- package/dist/resolvers/actionType.d.ts +0 -10
- package/dist/resolvers/actionType.d.ts.map +0 -1
- package/dist/resolvers/actionType.js +0 -21
- package/dist/resolvers/appKey.d.ts +0 -3
- package/dist/resolvers/appKey.d.ts.map +0 -1
- package/dist/resolvers/appKey.js +0 -5
- package/dist/resolvers/authenticationId.d.ts +0 -9
- package/dist/resolvers/authenticationId.d.ts.map +0 -1
- package/dist/resolvers/authenticationId.js +0 -42
- package/dist/resolvers/index.d.ts +0 -8
- package/dist/resolvers/index.d.ts.map +0 -1
- package/dist/resolvers/index.js +0 -8
- package/dist/resolvers/inputFieldKey.d.ts +0 -11
- package/dist/resolvers/inputFieldKey.d.ts.map +0 -1
- package/dist/resolvers/inputFieldKey.js +0 -47
- package/dist/resolvers/inputs.d.ts +0 -17
- package/dist/resolvers/inputs.d.ts.map +0 -1
- package/dist/resolvers/inputs.js +0 -50
- package/dist/schemas/Action.d.ts +0 -24
- package/dist/schemas/Action.d.ts.map +0 -1
- package/dist/schemas/Action.js +0 -40
- package/dist/schemas/App.d.ts +0 -57
- package/dist/schemas/App.d.ts.map +0 -1
- package/dist/schemas/App.js +0 -26
- package/dist/schemas/Auth.d.ts +0 -55
- package/dist/schemas/Auth.d.ts.map +0 -1
- package/dist/schemas/Auth.js +0 -33
- package/dist/schemas/Field.d.ts +0 -61
- package/dist/schemas/Field.d.ts.map +0 -1
- package/dist/schemas/Field.js +0 -116
- package/dist/schemas/Run.d.ts +0 -3
- package/dist/schemas/Run.d.ts.map +0 -1
- package/dist/schemas/Run.js +0 -31
- package/dist/schemas/UserProfile.d.ts +0 -13
- package/dist/schemas/UserProfile.d.ts.map +0 -1
- package/dist/schemas/UserProfile.js +0 -32
- package/dist/sdk.d.ts +0 -146
- package/dist/sdk.d.ts.map +0 -1
- package/dist/sdk.js +0 -112
- package/dist/sdk.test.d.ts +0 -2
- package/dist/sdk.test.d.ts.map +0 -1
- package/dist/sdk.test.js +0 -258
- package/dist/services/implementations.d.ts +0 -63
- package/dist/services/implementations.d.ts.map +0 -1
- package/dist/services/implementations.js +0 -80
- package/dist/types/domain.d.ts +0 -52
- package/dist/types/domain.d.ts.map +0 -1
- package/dist/types/domain.js +0 -1
- package/dist/types/domain.test.d.ts +0 -2
- package/dist/types/domain.test.d.ts.map +0 -1
- package/dist/types/domain.test.js +0 -39
- package/dist/types/errors.d.ts +0 -143
- package/dist/types/errors.d.ts.map +0 -1
- package/dist/types/errors.js +0 -187
- package/dist/types/events.d.ts +0 -38
- package/dist/types/events.d.ts.map +0 -1
- package/dist/types/events.js +0 -7
- package/dist/types/functions.d.ts +0 -27
- package/dist/types/functions.d.ts.map +0 -1
- package/dist/types/functions.js +0 -1
- package/dist/types/plugin.d.ts +0 -75
- package/dist/types/plugin.d.ts.map +0 -1
- package/dist/types/plugin.js +0 -9
- package/dist/types/properties.d.ts +0 -33
- package/dist/types/properties.d.ts.map +0 -1
- package/dist/types/properties.js +0 -52
- package/dist/types/sdk.d.ts +0 -69
- package/dist/types/sdk.d.ts.map +0 -1
- package/dist/types/sdk.js +0 -4
- package/dist/types/telemetry-events.d.ts +0 -105
- package/dist/types/telemetry-events.d.ts.map +0 -1
- package/dist/types/telemetry-events.js +0 -8
- package/dist/utils/array-utils.d.ts +0 -31
- package/dist/utils/array-utils.d.ts.map +0 -1
- package/dist/utils/array-utils.js +0 -36
- package/dist/utils/array-utils.test.d.ts +0 -2
- package/dist/utils/array-utils.test.d.ts.map +0 -1
- package/dist/utils/array-utils.test.js +0 -107
- package/dist/utils/batch-utils.d.ts +0 -72
- package/dist/utils/batch-utils.d.ts.map +0 -1
- package/dist/utils/batch-utils.js +0 -162
- package/dist/utils/batch-utils.test.d.ts +0 -2
- package/dist/utils/batch-utils.test.d.ts.map +0 -1
- package/dist/utils/batch-utils.test.js +0 -476
- package/dist/utils/domain-utils.d.ts +0 -66
- package/dist/utils/domain-utils.d.ts.map +0 -1
- package/dist/utils/domain-utils.js +0 -164
- package/dist/utils/domain-utils.test.d.ts +0 -2
- package/dist/utils/domain-utils.test.d.ts.map +0 -1
- package/dist/utils/domain-utils.test.js +0 -346
- package/dist/utils/file-utils.d.ts +0 -4
- package/dist/utils/file-utils.d.ts.map +0 -1
- package/dist/utils/file-utils.js +0 -74
- package/dist/utils/file-utils.test.d.ts +0 -2
- package/dist/utils/file-utils.test.d.ts.map +0 -1
- package/dist/utils/file-utils.test.js +0 -51
- package/dist/utils/function-utils.d.ts +0 -73
- package/dist/utils/function-utils.d.ts.map +0 -1
- package/dist/utils/function-utils.js +0 -245
- package/dist/utils/function-utils.test.d.ts +0 -2
- package/dist/utils/function-utils.test.d.ts.map +0 -1
- package/dist/utils/function-utils.test.js +0 -110
- package/dist/utils/id-utils.d.ts +0 -13
- package/dist/utils/id-utils.d.ts.map +0 -1
- package/dist/utils/id-utils.js +0 -22
- package/dist/utils/id-utils.test.d.ts +0 -2
- package/dist/utils/id-utils.test.d.ts.map +0 -1
- package/dist/utils/id-utils.test.js +0 -22
- package/dist/utils/pagination-utils.d.ts +0 -37
- package/dist/utils/pagination-utils.d.ts.map +0 -1
- package/dist/utils/pagination-utils.js +0 -165
- package/dist/utils/pagination-utils.test.d.ts +0 -17
- package/dist/utils/pagination-utils.test.d.ts.map +0 -1
- package/dist/utils/pagination-utils.test.js +0 -461
- package/dist/utils/retry-utils.d.ts +0 -45
- package/dist/utils/retry-utils.d.ts.map +0 -1
- package/dist/utils/retry-utils.js +0 -51
- package/dist/utils/retry-utils.test.d.ts +0 -2
- package/dist/utils/retry-utils.test.d.ts.map +0 -1
- package/dist/utils/retry-utils.test.js +0 -90
- package/dist/utils/schema-utils.d.ts +0 -69
- package/dist/utils/schema-utils.d.ts.map +0 -1
- package/dist/utils/schema-utils.js +0 -72
- package/dist/utils/string-utils.d.ts +0 -40
- package/dist/utils/string-utils.d.ts.map +0 -1
- package/dist/utils/string-utils.js +0 -69
- package/dist/utils/string-utils.test.d.ts +0 -2
- package/dist/utils/string-utils.test.d.ts.map +0 -1
- package/dist/utils/string-utils.test.js +0 -59
- package/dist/utils/telemetry-utils.d.ts +0 -44
- package/dist/utils/telemetry-utils.d.ts.map +0 -1
- package/dist/utils/telemetry-utils.js +0 -55
- package/dist/utils/telemetry-utils.test.d.ts +0 -2
- package/dist/utils/telemetry-utils.test.d.ts.map +0 -1
- package/dist/utils/telemetry-utils.test.js +0 -94
- package/dist/utils/url-utils.d.ts +0 -19
- package/dist/utils/url-utils.d.ts.map +0 -1
- package/dist/utils/url-utils.js +0 -62
- package/dist/utils/url-utils.test.d.ts +0 -2
- package/dist/utils/url-utils.test.d.ts.map +0 -1
- package/dist/utils/url-utils.test.js +0 -103
- package/dist/utils/validation.d.ts +0 -4
- package/dist/utils/validation.d.ts.map +0 -1
- package/dist/utils/validation.js +0 -30
- package/dist/utils/validation.test.d.ts +0 -2
- package/dist/utils/validation.test.d.ts.map +0 -1
- package/dist/utils/validation.test.js +0 -44
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect, vi, beforeEach } from "vitest";
|
|
2
|
-
import { ZapierValidationError } from "../../types/errors";
|
|
3
|
-
import { getAuthenticationPlugin } from "./index";
|
|
4
|
-
import { createSdk } from "../../sdk";
|
|
5
|
-
import { eventEmissionPlugin } from "../eventEmission";
|
|
6
|
-
const mockAuthenticationItem = {
|
|
7
|
-
id: "123",
|
|
8
|
-
date: "2021-01-01",
|
|
9
|
-
account_id: "456",
|
|
10
|
-
implementation_id: "SlackCLIAPI@1.21.1",
|
|
11
|
-
is_invite_only: false,
|
|
12
|
-
is_private: false,
|
|
13
|
-
shared_with_all: false,
|
|
14
|
-
is_expired: "false",
|
|
15
|
-
expired_at: null,
|
|
16
|
-
label: "My Slack Workspace",
|
|
17
|
-
title: "My Slack Workspace",
|
|
18
|
-
app_key: "SlackCLIAPI",
|
|
19
|
-
app_version: "1.21.1",
|
|
20
|
-
};
|
|
21
|
-
describe("getAuthentication plugin", () => {
|
|
22
|
-
let mockApiClient;
|
|
23
|
-
beforeEach(() => {
|
|
24
|
-
vi.clearAllMocks();
|
|
25
|
-
mockApiClient = {
|
|
26
|
-
get: vi.fn().mockResolvedValue({ data: mockAuthenticationItem }),
|
|
27
|
-
};
|
|
28
|
-
});
|
|
29
|
-
const apiPlugin = () => ({
|
|
30
|
-
context: {
|
|
31
|
-
api: mockApiClient,
|
|
32
|
-
},
|
|
33
|
-
});
|
|
34
|
-
function createTestSdk() {
|
|
35
|
-
return createSdk()
|
|
36
|
-
.addPlugin(() => ({
|
|
37
|
-
context: {
|
|
38
|
-
options: {},
|
|
39
|
-
},
|
|
40
|
-
}))
|
|
41
|
-
.addPlugin(apiPlugin)
|
|
42
|
-
.addPlugin(eventEmissionPlugin)
|
|
43
|
-
.addPlugin(getAuthenticationPlugin);
|
|
44
|
-
}
|
|
45
|
-
describe("input validation", () => {
|
|
46
|
-
it("should throw validation error for missing authenticationId", async () => {
|
|
47
|
-
const sdk = createTestSdk();
|
|
48
|
-
await expect(sdk.getAuthentication({})).rejects.toThrow(ZapierValidationError);
|
|
49
|
-
});
|
|
50
|
-
it("should throw validation error for invalid authenticationId type", async () => {
|
|
51
|
-
const sdk = createTestSdk();
|
|
52
|
-
await expect(sdk.getAuthentication({
|
|
53
|
-
authenticationId: true,
|
|
54
|
-
})).rejects.toThrow(ZapierValidationError);
|
|
55
|
-
});
|
|
56
|
-
it("should accept valid authenticationId", async () => {
|
|
57
|
-
const sdk = createTestSdk();
|
|
58
|
-
const result = await sdk.getAuthentication({
|
|
59
|
-
authenticationId: "123",
|
|
60
|
-
});
|
|
61
|
-
expect(result.data).toBeDefined();
|
|
62
|
-
expect(result.data.id).toBe("123");
|
|
63
|
-
});
|
|
64
|
-
});
|
|
65
|
-
describe("SDK API endpoint routing", () => {
|
|
66
|
-
it("should call the correct SDK API endpoint with path params", async () => {
|
|
67
|
-
const sdk = createTestSdk();
|
|
68
|
-
await sdk.getAuthentication({ authenticationId: "123" });
|
|
69
|
-
expect(mockApiClient.get).toHaveBeenCalledWith("/api/v0/authentications/123");
|
|
70
|
-
});
|
|
71
|
-
it("should URI encode string authenticationId in path", async () => {
|
|
72
|
-
const sdk = createTestSdk();
|
|
73
|
-
await sdk.getAuthentication({ authenticationId: "auth/with spaces" });
|
|
74
|
-
expect(mockApiClient.get).toHaveBeenCalledWith("/api/v0/authentications/auth%2Fwith%20spaces");
|
|
75
|
-
});
|
|
76
|
-
it("should return data from API response", async () => {
|
|
77
|
-
const sdk = createTestSdk();
|
|
78
|
-
const result = await sdk.getAuthentication({ authenticationId: "123" });
|
|
79
|
-
expect(result.data).toEqual(mockAuthenticationItem);
|
|
80
|
-
});
|
|
81
|
-
});
|
|
82
|
-
describe("error propagation", () => {
|
|
83
|
-
it("should propagate errors from API client", async () => {
|
|
84
|
-
mockApiClient.get = vi.fn().mockRejectedValue(new Error("API error"));
|
|
85
|
-
const sdk = createTestSdk();
|
|
86
|
-
await expect(sdk.getAuthentication({ authenticationId: "123" })).rejects.toThrow("API error");
|
|
87
|
-
});
|
|
88
|
-
});
|
|
89
|
-
describe("plugin metadata", () => {
|
|
90
|
-
it("should provide metadata in SDK context", () => {
|
|
91
|
-
const sdk = createTestSdk();
|
|
92
|
-
const context = sdk.getContext();
|
|
93
|
-
expect(context.meta.getAuthentication).toBeDefined();
|
|
94
|
-
expect(context.meta.getAuthentication.inputSchema).toBeDefined();
|
|
95
|
-
expect(context.meta.getAuthentication.outputSchema).toBeDefined();
|
|
96
|
-
expect(context.meta.getAuthentication.type).toBe("item");
|
|
97
|
-
expect(context.meta.getAuthentication.itemType).toBe("Authentication");
|
|
98
|
-
});
|
|
99
|
-
it("should include resolvers in metadata", () => {
|
|
100
|
-
const sdk = createTestSdk();
|
|
101
|
-
const context = sdk.getContext();
|
|
102
|
-
expect(context.meta.getAuthentication.resolvers).toBeDefined();
|
|
103
|
-
expect(context.meta.getAuthentication.resolvers.authenticationId).toBeDefined();
|
|
104
|
-
});
|
|
105
|
-
});
|
|
106
|
-
});
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import type { GetAuthenticationResponse, GetAuthenticationParam } from "@zapier/zapier-sdk-core/v0/schemas/authentications";
|
|
2
|
-
import type { ZapierAuthenticationError, ZapierResourceNotFoundError, ZapierApiError, ZapierValidationError, ZapierUnknownError } from "../../types/errors";
|
|
3
|
-
export type GetAuthenticationError = ZapierAuthenticationError | ZapierResourceNotFoundError | ZapierApiError | ZapierValidationError | ZapierUnknownError;
|
|
4
|
-
export interface GetAuthenticationSdkFunction {
|
|
5
|
-
getAuthentication: (options: GetAuthenticationParam) => Promise<GetAuthenticationResponse>;
|
|
6
|
-
}
|
|
7
|
-
//# sourceMappingURL=schemas.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../../../src/plugins/getAuthentication/schemas.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,yBAAyB,EACzB,sBAAsB,EACvB,MAAM,oDAAoD,CAAC;AAE5D,OAAO,KAAK,EACV,yBAAyB,EACzB,2BAA2B,EAC3B,cAAc,EACd,qBAAqB,EACrB,kBAAkB,EACnB,MAAM,oBAAoB,CAAC;AAG5B,MAAM,MAAM,sBAAsB,GAC9B,yBAAyB,GACzB,2BAA2B,GAC3B,cAAc,GACd,qBAAqB,GACrB,kBAAkB,CAAC;AAGvB,MAAM,WAAW,4BAA4B;IAC3C,iBAAiB,EAAE,CACjB,OAAO,EAAE,sBAAsB,KAC5B,OAAO,CAAC,yBAAyB,CAAC,CAAC;CACzC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import type { Plugin, GetSdkType } from "../../types/plugin";
|
|
2
|
-
import type { ApiClient } from "../../api";
|
|
3
|
-
import { GetInputFieldsSchemaSchema, type GetInputFieldsSchemaOptions as GetInputFieldsSchemaOptions } from "./schemas";
|
|
4
|
-
import type { GetActionPluginProvides } from "../getAction";
|
|
5
|
-
import type { GetVersionedImplementationId } from "../manifest/schemas";
|
|
6
|
-
import type { EventEmissionContext } from "../eventEmission";
|
|
7
|
-
export interface GetInputFieldsSchemaPluginProvides {
|
|
8
|
-
getInputFieldsSchema: (options: GetInputFieldsSchemaOptions) => Promise<{
|
|
9
|
-
data: Record<string, unknown>;
|
|
10
|
-
}>;
|
|
11
|
-
context: {
|
|
12
|
-
meta: {
|
|
13
|
-
getInputFieldsSchema: {
|
|
14
|
-
inputSchema: typeof GetInputFieldsSchemaSchema;
|
|
15
|
-
};
|
|
16
|
-
};
|
|
17
|
-
};
|
|
18
|
-
}
|
|
19
|
-
export declare const getInputFieldsSchemaPlugin: Plugin<GetSdkType<GetActionPluginProvides>, {
|
|
20
|
-
api: ApiClient;
|
|
21
|
-
getVersionedImplementationId: GetVersionedImplementationId;
|
|
22
|
-
} & EventEmissionContext, GetInputFieldsSchemaPluginProvides>;
|
|
23
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/getInputFieldsSchema/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAC7D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,EACL,0BAA0B,EAC1B,KAAK,2BAA2B,IAAI,2BAA2B,EAChE,MAAM,WAAW,CAAC;AAGnB,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAC;AAC5D,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,qBAAqB,CAAC;AAUxE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAE7D,MAAM,WAAW,kCAAkC;IACjD,oBAAoB,EAAE,CACpB,OAAO,EAAE,2BAA2B,KACjC,OAAO,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;KAAE,CAAC,CAAC;IAChD,OAAO,EAAE;QACP,IAAI,EAAE;YACJ,oBAAoB,EAAE;gBACpB,WAAW,EAAE,OAAO,0BAA0B,CAAC;aAChD,CAAC;SACH,CAAC;KACH,CAAC;CACH;AAED,eAAO,MAAM,0BAA0B,EAAE,MAAM,CAC7C,UAAU,CAAC,uBAAuB,CAAC,EACnC;IACE,GAAG,EAAE,SAAS,CAAC;IACf,4BAA4B,EAAE,4BAA4B,CAAC;CAC5D,GAAG,oBAAoB,EACxB,kCAAkC,CAyEnC,CAAC"}
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import { GetInputFieldsSchemaSchema, } from "./schemas";
|
|
2
|
-
import { ZapierConfigurationError } from "../../types/errors";
|
|
3
|
-
import { createFunction } from "../../utils/function-utils";
|
|
4
|
-
import { appKeyResolver, actionTypeResolver, actionKeyResolver, authenticationIdResolver, inputsAllOptionalResolver, } from "../../resolvers";
|
|
5
|
-
import { fetchImplementationNeeds } from "../../services/implementations";
|
|
6
|
-
import { createTelemetryCallback } from "../../utils/telemetry-utils";
|
|
7
|
-
export const getInputFieldsSchemaPlugin = ({ sdk, context }) => {
|
|
8
|
-
async function getInputFieldsSchema(options) {
|
|
9
|
-
const { api, getVersionedImplementationId } = context;
|
|
10
|
-
const { appKey, actionKey, actionType, authenticationId = null, inputs, } = options;
|
|
11
|
-
const selectedApi = await getVersionedImplementationId(appKey);
|
|
12
|
-
if (!selectedApi) {
|
|
13
|
-
throw new ZapierConfigurationError("No current_implementation_id found for app", { configType: "current_implementation_id" });
|
|
14
|
-
}
|
|
15
|
-
const { data: action } = await sdk.getAction({
|
|
16
|
-
appKey,
|
|
17
|
-
actionType,
|
|
18
|
-
actionKey,
|
|
19
|
-
});
|
|
20
|
-
const needsData = await fetchImplementationNeeds({
|
|
21
|
-
api,
|
|
22
|
-
selectedApi,
|
|
23
|
-
action: action.key,
|
|
24
|
-
actionType,
|
|
25
|
-
authenticationId,
|
|
26
|
-
inputs,
|
|
27
|
-
});
|
|
28
|
-
return {
|
|
29
|
-
data: needsData.schema || {},
|
|
30
|
-
};
|
|
31
|
-
}
|
|
32
|
-
const getInputFieldsSchemaDefinition = createFunction(getInputFieldsSchema, GetInputFieldsSchemaSchema, createTelemetryCallback(context.eventEmission.emitMethodCalled, getInputFieldsSchema.name));
|
|
33
|
-
return {
|
|
34
|
-
getInputFieldsSchema: getInputFieldsSchemaDefinition,
|
|
35
|
-
context: {
|
|
36
|
-
meta: {
|
|
37
|
-
getInputFieldsSchema: {
|
|
38
|
-
categories: ["action"],
|
|
39
|
-
type: "item",
|
|
40
|
-
itemType: "InputSchema",
|
|
41
|
-
inputSchema: GetInputFieldsSchemaSchema,
|
|
42
|
-
resolvers: {
|
|
43
|
-
appKey: appKeyResolver,
|
|
44
|
-
actionType: actionTypeResolver,
|
|
45
|
-
actionKey: actionKeyResolver,
|
|
46
|
-
authenticationId: authenticationIdResolver,
|
|
47
|
-
inputs: inputsAllOptionalResolver,
|
|
48
|
-
},
|
|
49
|
-
},
|
|
50
|
-
},
|
|
51
|
-
},
|
|
52
|
-
};
|
|
53
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.test.d.ts","sourceRoot":"","sources":["../../../src/plugins/getInputFieldsSchema/index.test.ts"],"names":[],"mappings":""}
|
|
@@ -1,291 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect, vi, beforeEach } from "vitest";
|
|
2
|
-
import { ZapierValidationError, ZapierConfigurationError, ZapierApiError, } from "../../types/errors";
|
|
3
|
-
import { getInputFieldsSchemaPlugin } from "./index";
|
|
4
|
-
import { getActionPlugin } from "../getAction";
|
|
5
|
-
import { getAppPlugin } from "../getApp";
|
|
6
|
-
import { listActionsPlugin } from "../listActions";
|
|
7
|
-
import { listAppsPlugin } from "../listApps";
|
|
8
|
-
import { createSdk } from "../../sdk";
|
|
9
|
-
import { eventEmissionPlugin } from "../eventEmission";
|
|
10
|
-
const mockSchema = {
|
|
11
|
-
type: "object",
|
|
12
|
-
properties: {
|
|
13
|
-
message: {
|
|
14
|
-
type: "string",
|
|
15
|
-
title: "Message",
|
|
16
|
-
description: "The message to send",
|
|
17
|
-
},
|
|
18
|
-
channel: {
|
|
19
|
-
type: "string",
|
|
20
|
-
title: "Channel",
|
|
21
|
-
description: "The channel to send to",
|
|
22
|
-
},
|
|
23
|
-
tags: {
|
|
24
|
-
type: "array",
|
|
25
|
-
items: {
|
|
26
|
-
type: "string",
|
|
27
|
-
},
|
|
28
|
-
title: "Tags",
|
|
29
|
-
description: "List of tags",
|
|
30
|
-
},
|
|
31
|
-
},
|
|
32
|
-
required: ["message", "channel"],
|
|
33
|
-
};
|
|
34
|
-
const mockNeedsResponse = {
|
|
35
|
-
success: true,
|
|
36
|
-
needs: [],
|
|
37
|
-
schema: mockSchema,
|
|
38
|
-
};
|
|
39
|
-
const mockActionsResponse = {
|
|
40
|
-
results: [
|
|
41
|
-
{
|
|
42
|
-
slug: "slack",
|
|
43
|
-
selected_api: "slack",
|
|
44
|
-
actions: [
|
|
45
|
-
{
|
|
46
|
-
key: "send_message",
|
|
47
|
-
name: "Send Message",
|
|
48
|
-
description: "Send a message to a channel",
|
|
49
|
-
type_of: "write",
|
|
50
|
-
type: "write",
|
|
51
|
-
id: "core:12345",
|
|
52
|
-
},
|
|
53
|
-
],
|
|
54
|
-
},
|
|
55
|
-
],
|
|
56
|
-
meta: {
|
|
57
|
-
next_cursor: null,
|
|
58
|
-
},
|
|
59
|
-
};
|
|
60
|
-
describe("getInputFieldsSchema plugin", () => {
|
|
61
|
-
let mockApiClient;
|
|
62
|
-
let mockGetVersionedImplementationId;
|
|
63
|
-
beforeEach(() => {
|
|
64
|
-
vi.clearAllMocks();
|
|
65
|
-
mockApiClient = {
|
|
66
|
-
get: vi.fn().mockResolvedValue(mockActionsResponse),
|
|
67
|
-
post: vi.fn().mockResolvedValue(mockNeedsResponse),
|
|
68
|
-
};
|
|
69
|
-
mockGetVersionedImplementationId = vi
|
|
70
|
-
.fn()
|
|
71
|
-
.mockResolvedValue("SlackCLIAPI@1.21.1");
|
|
72
|
-
});
|
|
73
|
-
function createTestSdk() {
|
|
74
|
-
return createSdk({}, {}, {
|
|
75
|
-
api: mockApiClient,
|
|
76
|
-
meta: {},
|
|
77
|
-
options: {},
|
|
78
|
-
getVersionedImplementationId: mockGetVersionedImplementationId,
|
|
79
|
-
})
|
|
80
|
-
.addPlugin(eventEmissionPlugin)
|
|
81
|
-
.addPlugin(listAppsPlugin)
|
|
82
|
-
.addPlugin(listActionsPlugin)
|
|
83
|
-
.addPlugin(getAppPlugin)
|
|
84
|
-
.addPlugin(getActionPlugin)
|
|
85
|
-
.addPlugin(getInputFieldsSchemaPlugin);
|
|
86
|
-
}
|
|
87
|
-
describe("schema validation", () => {
|
|
88
|
-
it("should throw validation error for missing required fields", async () => {
|
|
89
|
-
const sdk = createTestSdk();
|
|
90
|
-
await expect(sdk.getInputFieldsSchema({
|
|
91
|
-
// Missing required fields
|
|
92
|
-
})).rejects.toThrow(ZapierValidationError);
|
|
93
|
-
});
|
|
94
|
-
it("should throw validation error for invalid field types", async () => {
|
|
95
|
-
const sdk = createTestSdk();
|
|
96
|
-
await expect(sdk.getInputFieldsSchema({
|
|
97
|
-
appKey: 123,
|
|
98
|
-
actionType: "write",
|
|
99
|
-
actionKey: "send_message",
|
|
100
|
-
})).rejects.toThrow(ZapierValidationError);
|
|
101
|
-
});
|
|
102
|
-
it("should pass validation with all required fields", async () => {
|
|
103
|
-
const sdk = createTestSdk();
|
|
104
|
-
const result = await sdk.getInputFieldsSchema({
|
|
105
|
-
appKey: "slack",
|
|
106
|
-
actionType: "write",
|
|
107
|
-
actionKey: "send_message",
|
|
108
|
-
});
|
|
109
|
-
expect(result.data).toBeDefined();
|
|
110
|
-
});
|
|
111
|
-
it("should pass validation with optional fields", async () => {
|
|
112
|
-
const sdk = createTestSdk();
|
|
113
|
-
const result = await sdk.getInputFieldsSchema({
|
|
114
|
-
appKey: "slack",
|
|
115
|
-
actionType: "write",
|
|
116
|
-
actionKey: "send_message",
|
|
117
|
-
authenticationId: 123,
|
|
118
|
-
inputs: { channel: "#general" },
|
|
119
|
-
});
|
|
120
|
-
expect(result.data).toBeDefined();
|
|
121
|
-
});
|
|
122
|
-
});
|
|
123
|
-
describe("API integration", () => {
|
|
124
|
-
it("should call the correct API endpoint", async () => {
|
|
125
|
-
const sdk = createTestSdk();
|
|
126
|
-
await sdk.getInputFieldsSchema({
|
|
127
|
-
appKey: "slack",
|
|
128
|
-
actionType: "write",
|
|
129
|
-
actionKey: "send_message",
|
|
130
|
-
});
|
|
131
|
-
expect(mockApiClient.post).toHaveBeenCalledWith("/zapier/api/v4/implementations/needs/", {
|
|
132
|
-
selected_api: "SlackCLIAPI@1.21.1",
|
|
133
|
-
action: "send_message",
|
|
134
|
-
type_of: "write",
|
|
135
|
-
params: {},
|
|
136
|
-
});
|
|
137
|
-
});
|
|
138
|
-
it("should include authentication_id when provided", async () => {
|
|
139
|
-
const sdk = createTestSdk();
|
|
140
|
-
await sdk.getInputFieldsSchema({
|
|
141
|
-
appKey: "slack",
|
|
142
|
-
actionType: "write",
|
|
143
|
-
actionKey: "send_message",
|
|
144
|
-
authenticationId: 123,
|
|
145
|
-
});
|
|
146
|
-
expect(mockApiClient.post).toHaveBeenCalledWith("/zapier/api/v4/implementations/needs/", {
|
|
147
|
-
selected_api: "SlackCLIAPI@1.21.1",
|
|
148
|
-
action: "send_message",
|
|
149
|
-
type_of: "write",
|
|
150
|
-
params: {},
|
|
151
|
-
authentication_id: 123,
|
|
152
|
-
});
|
|
153
|
-
});
|
|
154
|
-
it("should exclude authentication_id when null", async () => {
|
|
155
|
-
const sdk = createTestSdk();
|
|
156
|
-
await sdk.getInputFieldsSchema({
|
|
157
|
-
appKey: "slack",
|
|
158
|
-
actionType: "write",
|
|
159
|
-
actionKey: "send_message",
|
|
160
|
-
authenticationId: null,
|
|
161
|
-
});
|
|
162
|
-
expect(mockApiClient.post).toHaveBeenCalledWith("/zapier/api/v4/implementations/needs/", {
|
|
163
|
-
selected_api: "SlackCLIAPI@1.21.1",
|
|
164
|
-
action: "send_message",
|
|
165
|
-
type_of: "write",
|
|
166
|
-
params: {},
|
|
167
|
-
// No authentication_id
|
|
168
|
-
});
|
|
169
|
-
});
|
|
170
|
-
it("should include inputs when provided", async () => {
|
|
171
|
-
const sdk = createTestSdk();
|
|
172
|
-
const inputs = { channel: "#general", message: "test" };
|
|
173
|
-
await sdk.getInputFieldsSchema({
|
|
174
|
-
appKey: "slack",
|
|
175
|
-
actionType: "write",
|
|
176
|
-
actionKey: "send_message",
|
|
177
|
-
inputs,
|
|
178
|
-
});
|
|
179
|
-
expect(mockApiClient.post).toHaveBeenCalledWith("/zapier/api/v4/implementations/needs/", {
|
|
180
|
-
selected_api: "SlackCLIAPI@1.21.1",
|
|
181
|
-
action: "send_message",
|
|
182
|
-
type_of: "write",
|
|
183
|
-
params: inputs,
|
|
184
|
-
});
|
|
185
|
-
});
|
|
186
|
-
});
|
|
187
|
-
describe("data return", () => {
|
|
188
|
-
it("should return the schema object from the API response", async () => {
|
|
189
|
-
const sdk = createTestSdk();
|
|
190
|
-
const result = await sdk.getInputFieldsSchema({
|
|
191
|
-
appKey: "slack",
|
|
192
|
-
actionType: "write",
|
|
193
|
-
actionKey: "send_message",
|
|
194
|
-
});
|
|
195
|
-
expect(result.data).toEqual(mockSchema);
|
|
196
|
-
});
|
|
197
|
-
it("should return empty object when schema is not present", async () => {
|
|
198
|
-
mockApiClient.post = vi.fn().mockResolvedValue({
|
|
199
|
-
success: true,
|
|
200
|
-
needs: [],
|
|
201
|
-
// No schema field
|
|
202
|
-
});
|
|
203
|
-
const sdk = createTestSdk();
|
|
204
|
-
const result = await sdk.getInputFieldsSchema({
|
|
205
|
-
appKey: "slack",
|
|
206
|
-
actionType: "write",
|
|
207
|
-
actionKey: "send_message",
|
|
208
|
-
});
|
|
209
|
-
expect(result.data).toEqual({});
|
|
210
|
-
});
|
|
211
|
-
it("should handle complex schema structures", async () => {
|
|
212
|
-
const complexSchema = {
|
|
213
|
-
type: "object",
|
|
214
|
-
properties: {
|
|
215
|
-
user: {
|
|
216
|
-
type: "object",
|
|
217
|
-
properties: {
|
|
218
|
-
name: { type: "string" },
|
|
219
|
-
age: { type: "number" },
|
|
220
|
-
},
|
|
221
|
-
required: ["name"],
|
|
222
|
-
},
|
|
223
|
-
tags: {
|
|
224
|
-
type: "array",
|
|
225
|
-
items: { type: "string" },
|
|
226
|
-
},
|
|
227
|
-
},
|
|
228
|
-
required: ["user"],
|
|
229
|
-
};
|
|
230
|
-
mockApiClient.post = vi.fn().mockResolvedValue({
|
|
231
|
-
success: true,
|
|
232
|
-
needs: [],
|
|
233
|
-
schema: complexSchema,
|
|
234
|
-
});
|
|
235
|
-
const sdk = createTestSdk();
|
|
236
|
-
const result = await sdk.getInputFieldsSchema({
|
|
237
|
-
appKey: "slack",
|
|
238
|
-
actionType: "write",
|
|
239
|
-
actionKey: "send_message",
|
|
240
|
-
});
|
|
241
|
-
expect(result.data).toEqual(complexSchema);
|
|
242
|
-
});
|
|
243
|
-
});
|
|
244
|
-
describe("error handling", () => {
|
|
245
|
-
it("should throw ZapierConfigurationError when app has no current_implementation_id", async () => {
|
|
246
|
-
mockGetVersionedImplementationId.mockResolvedValue(null);
|
|
247
|
-
const sdk = createTestSdk();
|
|
248
|
-
await expect(sdk.getInputFieldsSchema({
|
|
249
|
-
appKey: "invalid",
|
|
250
|
-
actionType: "write",
|
|
251
|
-
actionKey: "send_message",
|
|
252
|
-
})).rejects.toThrow(ZapierConfigurationError);
|
|
253
|
-
});
|
|
254
|
-
it("should throw ZapierApiError when API response indicates failure", async () => {
|
|
255
|
-
mockApiClient.post = vi.fn().mockResolvedValue({
|
|
256
|
-
success: false,
|
|
257
|
-
errors: ["Authentication failed", "Invalid credentials"],
|
|
258
|
-
});
|
|
259
|
-
const sdk = createTestSdk();
|
|
260
|
-
await expect(sdk.getInputFieldsSchema({
|
|
261
|
-
appKey: "slack",
|
|
262
|
-
actionType: "write",
|
|
263
|
-
actionKey: "send_message",
|
|
264
|
-
})).rejects.toThrow(ZapierApiError);
|
|
265
|
-
await expect(sdk.getInputFieldsSchema({
|
|
266
|
-
appKey: "slack",
|
|
267
|
-
actionType: "write",
|
|
268
|
-
actionKey: "send_message",
|
|
269
|
-
})).rejects.toThrow("Failed to get input fields: Authentication failed, Invalid credentials");
|
|
270
|
-
});
|
|
271
|
-
it("should handle API errors gracefully", async () => {
|
|
272
|
-
mockApiClient.post = vi
|
|
273
|
-
.fn()
|
|
274
|
-
.mockRejectedValue(new Error("Network error"));
|
|
275
|
-
const sdk = createTestSdk();
|
|
276
|
-
await expect(sdk.getInputFieldsSchema({
|
|
277
|
-
appKey: "slack",
|
|
278
|
-
actionType: "write",
|
|
279
|
-
actionKey: "send_message",
|
|
280
|
-
})).rejects.toThrow("Network error");
|
|
281
|
-
});
|
|
282
|
-
});
|
|
283
|
-
describe("context and metadata", () => {
|
|
284
|
-
it("should provide context with meta information", () => {
|
|
285
|
-
const sdk = createTestSdk();
|
|
286
|
-
const context = sdk.getContext();
|
|
287
|
-
expect(context.meta.getInputFieldsSchema).toBeDefined();
|
|
288
|
-
expect(context.meta.getInputFieldsSchema.inputSchema).toBeDefined();
|
|
289
|
-
});
|
|
290
|
-
});
|
|
291
|
-
});
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
import type { ZapierConfigurationError, ZapierApiError, ZapierAuthenticationError, ZapierAppNotFoundError, ZapierValidationError, ZapierUnknownError } from "../../types/errors";
|
|
3
|
-
export declare const GetInputFieldsSchemaSchema: z.ZodObject<{
|
|
4
|
-
appKey: z.ZodString & {
|
|
5
|
-
_def: z.core.$ZodStringDef & import("../..").PositionalMetadata;
|
|
6
|
-
};
|
|
7
|
-
actionType: z.ZodEnum<{
|
|
8
|
-
search: "search";
|
|
9
|
-
filter: "filter";
|
|
10
|
-
read: "read";
|
|
11
|
-
read_bulk: "read_bulk";
|
|
12
|
-
run: "run";
|
|
13
|
-
search_and_write: "search_and_write";
|
|
14
|
-
search_or_write: "search_or_write";
|
|
15
|
-
write: "write";
|
|
16
|
-
}>;
|
|
17
|
-
actionKey: z.ZodString;
|
|
18
|
-
authenticationId: z.ZodOptional<z.ZodNullable<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>>;
|
|
19
|
-
inputs: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
20
|
-
}, z.core.$strip>;
|
|
21
|
-
export type GetInputFieldsSchemaOptions = z.infer<typeof GetInputFieldsSchemaSchema>;
|
|
22
|
-
export type GetInputFieldsSchemaError = ZapierConfigurationError | ZapierApiError | ZapierAuthenticationError | ZapierAppNotFoundError | ZapierValidationError | ZapierUnknownError;
|
|
23
|
-
export interface GetInputFieldsSchemaSdkFunction {
|
|
24
|
-
getInputFieldsSchema: (options: GetInputFieldsSchemaOptions) => Promise<{
|
|
25
|
-
data: Record<string, unknown>;
|
|
26
|
-
}>;
|
|
27
|
-
}
|
|
28
|
-
//# sourceMappingURL=schemas.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../../../src/plugins/getInputFieldsSchema/schemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAQxB,OAAO,KAAK,EACV,wBAAwB,EACxB,cAAc,EACd,yBAAyB,EACzB,sBAAsB,EACtB,qBAAqB,EACrB,kBAAkB,EACnB,MAAM,oBAAoB,CAAC;AAE5B,eAAO,MAAM,0BAA0B;;;;;;;;;;;;;;;;;iBAsBpC,CAAC;AAEJ,MAAM,MAAM,2BAA2B,GAAG,CAAC,CAAC,KAAK,CAC/C,OAAO,0BAA0B,CAClC,CAAC;AAEF,MAAM,MAAM,yBAAyB,GACjC,wBAAwB,GACxB,cAAc,GACd,yBAAyB,GACzB,sBAAsB,GACtB,qBAAqB,GACrB,kBAAkB,CAAC;AAEvB,MAAM,WAAW,+BAA+B;IAC9C,oBAAoB,EAAE,CACpB,OAAO,EAAE,2BAA2B,KACjC,OAAO,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;KAAE,CAAC,CAAC;CACjD"}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
import { AppKeyPropertySchema, ActionTypePropertySchema, ActionKeyPropertySchema, AuthenticationIdPropertySchema, InputsPropertySchema, } from "../../types/properties";
|
|
3
|
-
export const GetInputFieldsSchemaSchema = z
|
|
4
|
-
.object({
|
|
5
|
-
appKey: AppKeyPropertySchema.describe("App key (e.g., 'SlackCLIAPI' or slug like 'github') to get the input schema for"),
|
|
6
|
-
actionType: ActionTypePropertySchema.describe("Action type that matches the action's defined type"),
|
|
7
|
-
actionKey: ActionKeyPropertySchema.describe("Action key to get the input schema for"),
|
|
8
|
-
authenticationId: AuthenticationIdPropertySchema.nullable()
|
|
9
|
-
.optional()
|
|
10
|
-
.describe("Authentication ID to use when fetching the schema. Required if the action needs authentication to determine available fields."),
|
|
11
|
-
inputs: InputsPropertySchema.optional().describe("Current input values that may affect the schema (e.g., when fields depend on other field values)"),
|
|
12
|
-
})
|
|
13
|
-
.describe("Get the JSON Schema representation of input fields for an action. Returns a JSON Schema object describing the structure, types, and validation rules for the action's input parameters.");
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import type { GetProfileOptions } from "./schemas";
|
|
2
|
-
import type { ApiClient } from "../../api/types";
|
|
3
|
-
import type { Plugin } from "../../types/plugin";
|
|
4
|
-
import type { UserProfileItem } from "../../types/domain";
|
|
5
|
-
import { GetProfileSchema } from "./schemas";
|
|
6
|
-
import type { EventEmissionContext } from "../eventEmission";
|
|
7
|
-
export interface GetProfilePluginProvides {
|
|
8
|
-
getProfile: (options?: GetProfileOptions) => Promise<{
|
|
9
|
-
data: UserProfileItem;
|
|
10
|
-
}>;
|
|
11
|
-
context: {
|
|
12
|
-
meta: {
|
|
13
|
-
getProfile: {
|
|
14
|
-
inputSchema: typeof GetProfileSchema;
|
|
15
|
-
};
|
|
16
|
-
};
|
|
17
|
-
};
|
|
18
|
-
}
|
|
19
|
-
export declare const getProfilePlugin: Plugin<{}, // no SDK dependencies
|
|
20
|
-
// no SDK dependencies
|
|
21
|
-
{
|
|
22
|
-
api: ApiClient;
|
|
23
|
-
} & EventEmissionContext, // requires api and eventEmission in context
|
|
24
|
-
GetProfilePluginProvides>;
|
|
25
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/getProfile/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AACnD,OAAO,KAAK,EAAe,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE9D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAC1D,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAG7C,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAG7D,MAAM,WAAW,wBAAwB;IACvC,UAAU,EAAE,CACV,OAAO,CAAC,EAAE,iBAAiB,KACxB,OAAO,CAAC;QAAE,IAAI,EAAE,eAAe,CAAA;KAAE,CAAC,CAAC;IACxC,OAAO,EAAE;QACP,IAAI,EAAE;YACJ,UAAU,EAAE;gBACV,WAAW,EAAE,OAAO,gBAAgB,CAAC;aACtC,CAAC;SACH,CAAC;KACH,CAAC;CACH;AAGD,eAAO,MAAM,gBAAgB,EAAE,MAAM,CACnC,EAAE,EAAE,sBAAsB;AAC1B,AADI,sBAAsB;AAC1B;IAAE,GAAG,EAAE,SAAS,CAAA;CAAE,GAAG,oBAAoB,EAAE,4CAA4C;AACvF,wBAAwB,CA+CzB,CAAC"}
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { createFunction } from "../../utils/function-utils";
|
|
2
|
-
import { GetProfileSchema } from "./schemas";
|
|
3
|
-
import { UserProfileItemSchema } from "../../schemas/UserProfile";
|
|
4
|
-
import { createTelemetryCallback } from "../../utils/telemetry-utils";
|
|
5
|
-
// Direct plugin function - takes options + sdk + context in one object
|
|
6
|
-
export const getProfilePlugin = ({ context }) => {
|
|
7
|
-
async function getProfile() {
|
|
8
|
-
const profile = await context.api.get("/zapier/api/v4/profile/", {
|
|
9
|
-
authRequired: true,
|
|
10
|
-
});
|
|
11
|
-
return {
|
|
12
|
-
data: {
|
|
13
|
-
id: String(profile.id),
|
|
14
|
-
first_name: profile.first_name,
|
|
15
|
-
last_name: profile.last_name,
|
|
16
|
-
full_name: `${profile.first_name} ${profile.last_name}`,
|
|
17
|
-
email: profile.email,
|
|
18
|
-
email_confirmed: profile.email_confirmed,
|
|
19
|
-
timezone: profile.timezone,
|
|
20
|
-
},
|
|
21
|
-
};
|
|
22
|
-
}
|
|
23
|
-
const getProfileDefinition = createFunction(getProfile, GetProfileSchema, createTelemetryCallback(context.eventEmission.emitMethodCalled, getProfile.name));
|
|
24
|
-
// Return flat structure - getProfile goes directly to SDK
|
|
25
|
-
return {
|
|
26
|
-
getProfile: getProfileDefinition,
|
|
27
|
-
context: {
|
|
28
|
-
meta: {
|
|
29
|
-
getProfile: {
|
|
30
|
-
categories: ["account"],
|
|
31
|
-
type: "item",
|
|
32
|
-
itemType: "Profile",
|
|
33
|
-
inputSchema: GetProfileSchema,
|
|
34
|
-
outputSchema: UserProfileItemSchema,
|
|
35
|
-
},
|
|
36
|
-
},
|
|
37
|
-
},
|
|
38
|
-
};
|
|
39
|
-
};
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
import type { FunctionOptions } from "../../types/functions";
|
|
3
|
-
import type { UserProfileItem } from "../../types/domain";
|
|
4
|
-
import type { ZapierApiError, ZapierValidationError } from "../../types/errors";
|
|
5
|
-
export type GetProfileError = ZapierApiError | ZapierValidationError;
|
|
6
|
-
export declare const GetProfileSchema: z.ZodOptional<z.ZodObject<{}, z.core.$strip>>;
|
|
7
|
-
export type GetProfileOptions = z.infer<typeof GetProfileSchema> & FunctionOptions;
|
|
8
|
-
export interface GetProfileSdkFunction {
|
|
9
|
-
getProfile: (options?: GetProfileOptions) => Promise<{
|
|
10
|
-
data: UserProfileItem;
|
|
11
|
-
}>;
|
|
12
|
-
}
|
|
13
|
-
//# sourceMappingURL=schemas.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../../../src/plugins/getProfile/schemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAC7D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAC1D,OAAO,KAAK,EAAE,cAAc,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAGhF,MAAM,MAAM,eAAe,GAAG,cAAc,GAAG,qBAAqB,CAAC;AAGrE,eAAO,MAAM,gBAAgB,+CAGwB,CAAC;AAGtD,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,GAC9D,eAAe,CAAC;AAGlB,MAAM,WAAW,qBAAqB;IACpC,UAAU,EAAE,CACV,OAAO,CAAC,EAAE,iBAAiB,KACxB,OAAO,CAAC;QAAE,IAAI,EAAE,eAAe,CAAA;KAAE,CAAC,CAAC;CACzC"}
|