@zapier/zapier-sdk 0.9.0 → 0.10.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 +12 -0
- package/README.md +7 -7
- package/dist/api/client.d.ts.map +1 -1
- package/dist/api/client.js +14 -0
- package/dist/api/debug.d.ts +1 -0
- package/dist/api/debug.d.ts.map +1 -1
- package/dist/api/debug.js +42 -1
- package/dist/api/debug.test.d.ts +2 -0
- package/dist/api/debug.test.d.ts.map +1 -0
- package/dist/api/debug.test.js +59 -0
- package/dist/api/schemas.d.ts +451 -251
- package/dist/api/schemas.d.ts.map +1 -1
- package/dist/api/schemas.js +51 -29
- package/dist/index.cjs +834 -563
- package/dist/index.d.mts +2287 -2085
- package/dist/index.d.ts +2 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -3
- package/dist/index.mjs +832 -557
- package/dist/plugins/findFirstAuthentication/index.d.ts +1 -1
- package/dist/plugins/findFirstAuthentication/index.d.ts.map +1 -1
- package/dist/plugins/findFirstAuthentication/index.js +9 -1
- package/dist/plugins/findFirstAuthentication/index.test.js +3 -4
- package/dist/plugins/findFirstAuthentication/schemas.d.ts +5 -3
- package/dist/plugins/findFirstAuthentication/schemas.d.ts.map +1 -1
- package/dist/plugins/findUniqueAuthentication/index.d.ts.map +1 -1
- package/dist/plugins/findUniqueAuthentication/index.js +4 -0
- package/dist/plugins/findUniqueAuthentication/schemas.d.ts +5 -3
- package/dist/plugins/findUniqueAuthentication/schemas.d.ts.map +1 -1
- package/dist/plugins/getAction/index.d.ts.map +1 -1
- package/dist/plugins/getAction/index.js +10 -0
- package/dist/plugins/getAction/schemas.d.ts +5 -3
- package/dist/plugins/getAction/schemas.d.ts.map +1 -1
- package/dist/plugins/getApp/index.d.ts.map +1 -1
- package/dist/plugins/getApp/index.js +8 -0
- package/dist/plugins/getApp/index.test.js +2 -2
- package/dist/plugins/getApp/schemas.d.ts +3 -1
- package/dist/plugins/getApp/schemas.d.ts.map +1 -1
- package/dist/plugins/getApp/schemas.js +2 -4
- package/dist/plugins/getAuthentication/index.d.ts.map +1 -1
- package/dist/plugins/getAuthentication/index.js +8 -0
- package/dist/plugins/getProfile/index.d.ts.map +1 -1
- package/dist/plugins/getProfile/index.js +4 -0
- package/dist/plugins/getProfile/schemas.d.ts.map +1 -1
- package/dist/plugins/getProfile/schemas.js +4 -3
- package/dist/plugins/listActions/index.d.ts.map +1 -1
- package/dist/plugins/listActions/index.js +9 -0
- package/dist/plugins/listActions/schemas.d.ts +5 -3
- package/dist/plugins/listActions/schemas.d.ts.map +1 -1
- package/dist/plugins/listActions/schemas.js +2 -4
- package/dist/plugins/listApps/index.d.ts.map +1 -1
- package/dist/plugins/listApps/index.js +4 -0
- package/dist/plugins/listApps/index.test.js +1 -1
- package/dist/plugins/listApps/schemas.d.ts.map +1 -1
- package/dist/plugins/listApps/schemas.js +3 -9
- package/dist/plugins/listAuthentications/index.d.ts.map +1 -1
- package/dist/plugins/listAuthentications/index.js +8 -0
- package/dist/plugins/listAuthentications/schemas.d.ts +5 -3
- package/dist/plugins/listAuthentications/schemas.d.ts.map +1 -1
- package/dist/plugins/listInputFieldChoices/index.d.ts.map +1 -1
- package/dist/plugins/listInputFieldChoices/index.js +14 -2
- package/dist/plugins/listInputFieldChoices/schemas.d.ts +5 -3
- package/dist/plugins/listInputFieldChoices/schemas.d.ts.map +1 -1
- package/dist/plugins/listInputFieldChoices/schemas.js +10 -19
- package/dist/plugins/listInputFields/index.d.ts.map +1 -1
- package/dist/plugins/listInputFields/index.js +14 -2
- package/dist/plugins/listInputFields/index.test.js +5 -9
- package/dist/plugins/listInputFields/schemas.d.ts +5 -3
- package/dist/plugins/listInputFields/schemas.d.ts.map +1 -1
- package/dist/plugins/registry/index.d.ts.map +1 -1
- package/dist/plugins/registry/index.js +8 -2
- package/dist/plugins/request/index.d.ts.map +1 -1
- package/dist/plugins/request/index.js +1 -0
- package/dist/plugins/runAction/index.d.ts.map +1 -1
- package/dist/plugins/runAction/index.js +12 -0
- package/dist/plugins/runAction/schemas.d.ts +5 -3
- package/dist/plugins/runAction/schemas.d.ts.map +1 -1
- package/dist/resolvers/actionKey.d.ts +13 -7
- package/dist/resolvers/actionKey.d.ts.map +1 -1
- package/dist/resolvers/actionType.d.ts +8 -7
- package/dist/resolvers/actionType.d.ts.map +1 -1
- package/dist/resolvers/appKey.d.ts +2 -6
- package/dist/resolvers/appKey.d.ts.map +1 -1
- package/dist/resolvers/authenticationId.d.ts +7 -7
- package/dist/resolvers/authenticationId.d.ts.map +1 -1
- package/dist/resolvers/authenticationId.js +16 -7
- package/dist/resolvers/index.d.ts +3 -35
- package/dist/resolvers/index.d.ts.map +1 -1
- package/dist/resolvers/index.js +4 -87
- package/dist/resolvers/inputFieldKey.d.ts +11 -0
- package/dist/resolvers/inputFieldKey.d.ts.map +1 -0
- package/dist/resolvers/inputFieldKey.js +23 -0
- package/dist/resolvers/inputs.d.ts +11 -6
- package/dist/resolvers/inputs.d.ts.map +1 -1
- package/dist/resolvers/inputs.js +17 -0
- package/dist/schemas/Action.d.ts +8 -8
- package/dist/schemas/Action.d.ts.map +1 -1
- package/dist/schemas/Action.js +8 -3
- package/dist/schemas/App.d.ts +183 -11
- package/dist/schemas/App.d.ts.map +1 -1
- package/dist/schemas/App.js +7 -9
- package/dist/schemas/Auth.d.ts +12 -12
- package/dist/schemas/Auth.js +1 -1
- package/dist/schemas/Field.d.ts +5 -98
- package/dist/schemas/Field.d.ts.map +1 -1
- package/dist/schemas/Field.js +24 -52
- package/dist/schemas/Run.d.ts +3 -0
- package/dist/schemas/Run.d.ts.map +1 -0
- package/dist/schemas/Run.js +31 -0
- package/dist/schemas/UserProfile.d.ts +11 -11
- package/dist/schemas/UserProfile.d.ts.map +1 -1
- package/dist/schemas/UserProfile.js +21 -7
- package/dist/sdk.d.ts +11 -4
- package/dist/sdk.d.ts.map +1 -1
- package/dist/types/plugin.d.ts +5 -0
- package/dist/types/plugin.d.ts.map +1 -1
- package/dist/types/properties.d.ts +3 -1
- package/dist/types/properties.d.ts.map +1 -1
- package/dist/types/sdk.d.ts +5 -0
- package/dist/types/sdk.d.ts.map +1 -1
- package/dist/utils/domain-utils.d.ts +1 -16
- package/dist/utils/domain-utils.d.ts.map +1 -1
- package/dist/utils/domain-utils.js +7 -51
- package/dist/utils/schema-utils.d.ts +44 -21
- package/dist/utils/schema-utils.d.ts.map +1 -1
- package/dist/utils/schema-utils.js +17 -11
- package/package.json +1 -1
- package/src/api/client.ts +12 -0
- package/src/api/debug.test.ts +76 -0
- package/src/api/debug.ts +46 -2
- package/src/api/schemas.ts +51 -29
- package/src/index.ts +4 -5
- package/src/plugins/findFirstAuthentication/index.test.ts +8 -5
- package/src/plugins/findFirstAuthentication/index.ts +14 -2
- package/src/plugins/findUniqueAuthentication/index.ts +4 -0
- package/src/plugins/getAction/index.ts +14 -0
- package/src/plugins/getApp/index.test.ts +2 -2
- package/src/plugins/getApp/index.ts +8 -0
- package/src/plugins/getApp/schemas.ts +7 -12
- package/src/plugins/getAuthentication/index.ts +8 -0
- package/src/plugins/getProfile/index.ts +4 -0
- package/src/plugins/getProfile/schemas.ts +4 -6
- package/src/plugins/listActions/index.ts +9 -0
- package/src/plugins/listActions/schemas.ts +20 -25
- package/src/plugins/listApps/index.test.ts +1 -1
- package/src/plugins/listApps/index.ts +4 -0
- package/src/plugins/listApps/schemas.ts +17 -26
- package/src/plugins/listAuthentications/index.ts +8 -0
- package/src/plugins/listInputFieldChoices/index.ts +21 -1
- package/src/plugins/listInputFieldChoices/schemas.ts +61 -76
- package/src/plugins/listInputFields/index.test.ts +5 -9
- package/src/plugins/listInputFields/index.ts +20 -2
- package/src/plugins/registry/index.ts +8 -2
- package/src/plugins/request/index.ts +1 -0
- package/src/plugins/runAction/index.ts +18 -0
- package/src/resolvers/actionKey.ts +15 -13
- package/src/resolvers/actionType.ts +10 -12
- package/src/resolvers/appKey.ts +2 -6
- package/src/resolvers/authenticationId.ts +25 -19
- package/src/resolvers/index.ts +7 -113
- package/src/resolvers/inputFieldKey.ts +38 -0
- package/src/resolvers/inputs.ts +28 -10
- package/src/schemas/Action.ts +8 -3
- package/src/schemas/App.ts +7 -9
- package/src/schemas/Auth.ts +1 -1
- package/src/schemas/Field.ts +24 -57
- package/src/schemas/Run.ts +40 -0
- package/src/schemas/UserProfile.ts +24 -7
- package/src/sdk.ts +17 -7
- package/src/types/plugin.ts +5 -0
- package/src/types/sdk.ts +5 -0
- package/src/utils/domain-utils.ts +9 -67
- package/src/utils/schema-utils.ts +96 -44
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -5,6 +5,12 @@ import { GetActionSchema, type GetActionOptions } from "./schemas";
|
|
|
5
5
|
import { ZapierResourceNotFoundError } from "../../types/errors";
|
|
6
6
|
import { createFunction } from "../../utils/function-utils";
|
|
7
7
|
import type { ListActionsPluginProvides } from "../listActions";
|
|
8
|
+
import {
|
|
9
|
+
appKeyResolver,
|
|
10
|
+
actionTypeResolver,
|
|
11
|
+
actionKeyResolver,
|
|
12
|
+
} from "../../resolvers";
|
|
13
|
+
import { ActionItemSchema } from "../../schemas/Action";
|
|
8
14
|
|
|
9
15
|
export interface GetActionPluginProvides {
|
|
10
16
|
getAction: (options: GetActionOptions) => Promise<{ data: ActionItem }>;
|
|
@@ -50,7 +56,15 @@ export const getActionPlugin: Plugin<
|
|
|
50
56
|
meta: {
|
|
51
57
|
getAction: {
|
|
52
58
|
categories: ["action"],
|
|
59
|
+
type: "item",
|
|
60
|
+
itemType: "Action",
|
|
53
61
|
inputSchema: GetActionSchema,
|
|
62
|
+
outputSchema: ActionItemSchema,
|
|
63
|
+
resolvers: {
|
|
64
|
+
appKey: appKeyResolver,
|
|
65
|
+
actionType: actionTypeResolver,
|
|
66
|
+
actionKey: actionKeyResolver,
|
|
67
|
+
},
|
|
54
68
|
},
|
|
55
69
|
},
|
|
56
70
|
},
|
|
@@ -72,7 +72,7 @@ describe("getApp plugin", () => {
|
|
|
72
72
|
|
|
73
73
|
expect(result.data.title).toBe("Slack");
|
|
74
74
|
expect(result.data.key).toBe("SlackCLIAPI");
|
|
75
|
-
expect(result.data.
|
|
75
|
+
expect(result.data.implementation_id).toBe("SlackCLIAPI@1.0.0");
|
|
76
76
|
expect(result.data.version).toBe("1.0.0");
|
|
77
77
|
});
|
|
78
78
|
});
|
|
@@ -121,7 +121,7 @@ describe("getApp plugin", () => {
|
|
|
121
121
|
|
|
122
122
|
expect(result.data.title).toBeDefined();
|
|
123
123
|
expect(result.data.key).toBeDefined();
|
|
124
|
-
expect(result.data.
|
|
124
|
+
expect(result.data.implementation_id).toBeDefined();
|
|
125
125
|
expect(result.data.title).toBe("Test App");
|
|
126
126
|
expect(result.data.key).toBe("TestCLIAPI");
|
|
127
127
|
});
|
|
@@ -3,9 +3,11 @@ import { createFunction } from "../../utils/function-utils";
|
|
|
3
3
|
import { GetAppSchema } from "./schemas";
|
|
4
4
|
import type { GetAppOptions } from "./schemas";
|
|
5
5
|
import type { AppItem } from "../../types/domain";
|
|
6
|
+
import { AppItemSchema } from "../../schemas/App";
|
|
6
7
|
import { ZapierAppNotFoundError } from "../../types/errors";
|
|
7
8
|
import type { GetSdkType } from "../../types/plugin";
|
|
8
9
|
import type { ListAppsPluginProvides } from "../listApps";
|
|
10
|
+
import { appKeyResolver } from "../../resolvers";
|
|
9
11
|
|
|
10
12
|
// GetApp plugin provides interface - getApp goes directly to SDK root
|
|
11
13
|
export interface GetAppPluginProvides {
|
|
@@ -44,7 +46,13 @@ export const getAppPlugin: Plugin<
|
|
|
44
46
|
meta: {
|
|
45
47
|
getApp: {
|
|
46
48
|
categories: ["app"],
|
|
49
|
+
type: "item",
|
|
50
|
+
itemType: "App",
|
|
47
51
|
inputSchema: GetAppSchema,
|
|
52
|
+
outputSchema: AppItemSchema,
|
|
53
|
+
resolvers: {
|
|
54
|
+
appKey: appKeyResolver,
|
|
55
|
+
},
|
|
48
56
|
},
|
|
49
57
|
},
|
|
50
58
|
},
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import { AppKeyPropertySchema } from "../../types/properties";
|
|
3
|
-
import { withOutputSchema } from "../../utils/schema-utils";
|
|
4
|
-
import { AppItemSchema } from "../../schemas/App";
|
|
5
3
|
import type { AppItem } from "../../types/domain";
|
|
6
4
|
import type {
|
|
7
5
|
ZapierApiError,
|
|
@@ -18,16 +16,13 @@ export type GetAppError =
|
|
|
18
16
|
| ZapierValidationError;
|
|
19
17
|
|
|
20
18
|
// Pure Zod schema - no resolver metadata!
|
|
21
|
-
export const GetAppSchema =
|
|
22
|
-
|
|
23
|
-
.
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
.describe("Get detailed information about a specific app"),
|
|
29
|
-
AppItemSchema,
|
|
30
|
-
);
|
|
19
|
+
export const GetAppSchema = z
|
|
20
|
+
.object({
|
|
21
|
+
appKey: AppKeyPropertySchema.describe(
|
|
22
|
+
"App key of app to fetch (e.g., 'SlackCLIAPI')",
|
|
23
|
+
),
|
|
24
|
+
})
|
|
25
|
+
.describe("Get detailed information about a specific app");
|
|
31
26
|
|
|
32
27
|
// Type inferred from schema
|
|
33
28
|
export type GetAppOptions = z.infer<typeof GetAppSchema>;
|
|
@@ -12,6 +12,8 @@ import {
|
|
|
12
12
|
} from "../../types/errors";
|
|
13
13
|
import { createFunction } from "../../utils/function-utils";
|
|
14
14
|
import { normalizeAuthenticationItem } from "../../utils/domain-utils";
|
|
15
|
+
import { authenticationIdGenericResolver } from "../../resolvers";
|
|
16
|
+
import { AuthenticationItemSchema } from "../../schemas/Auth";
|
|
15
17
|
|
|
16
18
|
export interface GetAuthenticationPluginProvides {
|
|
17
19
|
getAuthentication: (
|
|
@@ -79,7 +81,13 @@ export const getAuthenticationPlugin: Plugin<
|
|
|
79
81
|
meta: {
|
|
80
82
|
getAuthentication: {
|
|
81
83
|
categories: ["authentication"],
|
|
84
|
+
type: "item",
|
|
85
|
+
itemType: "Authentication",
|
|
82
86
|
inputSchema: GetAuthenticationSchema,
|
|
87
|
+
outputSchema: AuthenticationItemSchema,
|
|
88
|
+
resolvers: {
|
|
89
|
+
authenticationId: authenticationIdGenericResolver,
|
|
90
|
+
},
|
|
83
91
|
},
|
|
84
92
|
},
|
|
85
93
|
},
|
|
@@ -4,6 +4,7 @@ import { createFunction } from "../../utils/function-utils";
|
|
|
4
4
|
import type { Plugin } from "../../types/plugin";
|
|
5
5
|
import type { UserProfileItem } from "../../types/domain";
|
|
6
6
|
import { GetProfileSchema } from "./schemas";
|
|
7
|
+
import { UserProfileItemSchema } from "../../schemas/UserProfile";
|
|
7
8
|
|
|
8
9
|
// GetProfile plugin provides interface - getProfile goes directly to SDK root
|
|
9
10
|
export interface GetProfilePluginProvides {
|
|
@@ -48,7 +49,10 @@ export const getProfilePlugin: Plugin<
|
|
|
48
49
|
meta: {
|
|
49
50
|
getProfile: {
|
|
50
51
|
categories: ["account"],
|
|
52
|
+
type: "item",
|
|
53
|
+
itemType: "Profile",
|
|
51
54
|
inputSchema: GetProfileSchema,
|
|
55
|
+
outputSchema: UserProfileItemSchema,
|
|
52
56
|
},
|
|
53
57
|
},
|
|
54
58
|
},
|
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
import { withOutputSchema } from "../../utils/schema-utils";
|
|
3
|
-
import { UserProfileItemSchema } from "../../schemas/UserProfile";
|
|
4
2
|
import type { FunctionOptions } from "../../types/functions";
|
|
5
3
|
import type { UserProfileItem } from "../../types/domain";
|
|
6
4
|
import type { ZapierApiError, ZapierValidationError } from "../../types/errors";
|
|
@@ -9,10 +7,10 @@ import type { ZapierApiError, ZapierValidationError } from "../../types/errors";
|
|
|
9
7
|
export type GetProfileError = ZapierApiError | ZapierValidationError;
|
|
10
8
|
|
|
11
9
|
// Pure Zod schema - no resolver metadata!
|
|
12
|
-
export const GetProfileSchema =
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
);
|
|
10
|
+
export const GetProfileSchema = z
|
|
11
|
+
.object({})
|
|
12
|
+
.optional()
|
|
13
|
+
.describe("Get current user's profile information");
|
|
16
14
|
|
|
17
15
|
// Type inferred from schema + function config
|
|
18
16
|
export type GetProfileOptions = z.infer<typeof GetProfileSchema> &
|
|
@@ -7,6 +7,7 @@ import {
|
|
|
7
7
|
type ListActionsOptions,
|
|
8
8
|
type ListActionsPage,
|
|
9
9
|
} from "./schemas";
|
|
10
|
+
import { ActionItemSchema } from "../../schemas/Action";
|
|
10
11
|
import {
|
|
11
12
|
ZapierConfigurationError,
|
|
12
13
|
ZapierAuthenticationError,
|
|
@@ -14,6 +15,7 @@ import {
|
|
|
14
15
|
import { createPaginatedFunction } from "../../utils/function-utils";
|
|
15
16
|
import type { ManifestPluginProvides } from "../manifest";
|
|
16
17
|
import type { GetVersionedImplementationId } from "../manifest/schemas";
|
|
18
|
+
import { appKeyResolver, actionTypeResolver } from "../../resolvers";
|
|
17
19
|
|
|
18
20
|
export interface ListActionsPluginProvides {
|
|
19
21
|
listActions: (options?: ListActionsOptions) => Promise<{
|
|
@@ -114,7 +116,14 @@ export const listActionsPlugin: Plugin<
|
|
|
114
116
|
meta: {
|
|
115
117
|
listActions: {
|
|
116
118
|
categories: ["action"],
|
|
119
|
+
type: "list",
|
|
120
|
+
itemType: "Action",
|
|
117
121
|
inputSchema: ListActionsSchema,
|
|
122
|
+
outputSchema: ActionItemSchema,
|
|
123
|
+
resolvers: {
|
|
124
|
+
appKey: appKeyResolver,
|
|
125
|
+
actionType: actionTypeResolver,
|
|
126
|
+
},
|
|
118
127
|
},
|
|
119
128
|
},
|
|
120
129
|
},
|
|
@@ -3,8 +3,6 @@ import {
|
|
|
3
3
|
AppKeyPropertySchema,
|
|
4
4
|
ActionTypePropertySchema,
|
|
5
5
|
} from "../../types/properties";
|
|
6
|
-
import { withOutputSchema } from "../../utils/schema-utils";
|
|
7
|
-
import { ActionItemSchema } from "../../schemas/Action";
|
|
8
6
|
import type { ActionItem } from "../../types/domain";
|
|
9
7
|
import type { PaginatedSdkFunction } from "../../types/functions";
|
|
10
8
|
import type {
|
|
@@ -14,29 +12,26 @@ import type {
|
|
|
14
12
|
} from "../../types/errors";
|
|
15
13
|
|
|
16
14
|
// Pure Zod schema - no resolver metadata!
|
|
17
|
-
export const ListActionsSchema =
|
|
18
|
-
|
|
19
|
-
.
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
.describe("List all actions for a specific app"),
|
|
38
|
-
ActionItemSchema,
|
|
39
|
-
);
|
|
15
|
+
export const ListActionsSchema = z
|
|
16
|
+
.object({
|
|
17
|
+
appKey: AppKeyPropertySchema.describe(
|
|
18
|
+
"App key of actions to list (e.g., 'SlackCLIAPI')",
|
|
19
|
+
),
|
|
20
|
+
actionType: ActionTypePropertySchema.optional().describe(
|
|
21
|
+
"Filter actions by type",
|
|
22
|
+
),
|
|
23
|
+
pageSize: z
|
|
24
|
+
.number()
|
|
25
|
+
.min(1)
|
|
26
|
+
.optional()
|
|
27
|
+
.describe("Number of actions per page"),
|
|
28
|
+
maxItems: z
|
|
29
|
+
.number()
|
|
30
|
+
.min(1)
|
|
31
|
+
.optional()
|
|
32
|
+
.describe("Maximum total items to return across all pages"),
|
|
33
|
+
})
|
|
34
|
+
.describe("List all actions for a specific app");
|
|
40
35
|
|
|
41
36
|
// Type inferred from schema
|
|
42
37
|
export type ListActionsOptions = z.infer<typeof ListActionsSchema>;
|
|
@@ -228,7 +228,7 @@ describe("listApps plugin", () => {
|
|
|
228
228
|
|
|
229
229
|
expect(result.data[0]).toHaveProperty("title");
|
|
230
230
|
expect(result.data[0]).toHaveProperty("key");
|
|
231
|
-
expect(result.data[0]).toHaveProperty("
|
|
231
|
+
expect(result.data[0]).toHaveProperty("implementation_id");
|
|
232
232
|
// Version is optional
|
|
233
233
|
expect(result.data[0]).toHaveProperty("version");
|
|
234
234
|
});
|
|
@@ -3,6 +3,7 @@ import { createPaginatedFunction } from "../../utils/function-utils";
|
|
|
3
3
|
import { ListAppsSchema } from "./schemas";
|
|
4
4
|
import type { ListAppsOptions, ListAppsPage } from "./schemas";
|
|
5
5
|
import type { AppItem } from "../../types/domain";
|
|
6
|
+
import { AppItemSchema } from "../../schemas/App";
|
|
6
7
|
import type { ResolvedAppLocator } from "../../utils/domain-utils";
|
|
7
8
|
import {
|
|
8
9
|
normalizeImplementationMetaToAppItem,
|
|
@@ -135,7 +136,10 @@ export const listAppsPlugin: Plugin<
|
|
|
135
136
|
meta: {
|
|
136
137
|
listApps: {
|
|
137
138
|
categories: ["app"],
|
|
139
|
+
type: "list",
|
|
140
|
+
itemType: "App",
|
|
138
141
|
inputSchema: ListAppsSchema,
|
|
142
|
+
outputSchema: AppItemSchema,
|
|
139
143
|
},
|
|
140
144
|
},
|
|
141
145
|
},
|
|
@@ -2,8 +2,6 @@ import { z } from "zod";
|
|
|
2
2
|
import type { AppItem } from "../../types/domain";
|
|
3
3
|
import type { PaginatedSdkFunction } from "../../types/functions";
|
|
4
4
|
import type { ZapierApiError, ZapierValidationError } from "../../types/errors";
|
|
5
|
-
import { AppItemSchema } from "../../schemas/App";
|
|
6
|
-
import { withOutputSchema } from "../../utils/schema-utils";
|
|
7
5
|
|
|
8
6
|
// Union of all possible errors for listApps
|
|
9
7
|
export type ListAppsError = ZapierApiError | ZapierValidationError;
|
|
@@ -15,30 +13,23 @@ export interface ListAppsPage {
|
|
|
15
13
|
}
|
|
16
14
|
|
|
17
15
|
// Pure Zod schema - no pagination metadata exposed
|
|
18
|
-
export const ListAppsSchema =
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
.
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
.min(1)
|
|
36
|
-
.optional()
|
|
37
|
-
.describe("Maximum total items to return across all pages"),
|
|
38
|
-
})
|
|
39
|
-
.describe("List all available apps with optional filtering"),
|
|
40
|
-
AppItemSchema,
|
|
41
|
-
);
|
|
16
|
+
export const ListAppsSchema = z
|
|
17
|
+
.object({
|
|
18
|
+
appKeys: z
|
|
19
|
+
.array(z.string())
|
|
20
|
+
.optional()
|
|
21
|
+
.describe(
|
|
22
|
+
"Filter apps by app keys (e.g., 'SlackCLIAPI' or slug like 'github')",
|
|
23
|
+
),
|
|
24
|
+
search: z.string().optional().describe("Search for apps by name"),
|
|
25
|
+
pageSize: z.number().min(1).optional().describe("Number of apps per page"),
|
|
26
|
+
maxItems: z
|
|
27
|
+
.number()
|
|
28
|
+
.min(1)
|
|
29
|
+
.optional()
|
|
30
|
+
.describe("Maximum total items to return across all pages"),
|
|
31
|
+
})
|
|
32
|
+
.describe("List all available apps with optional filtering");
|
|
42
33
|
|
|
43
34
|
// Type inferred from schema
|
|
44
35
|
export type ListAppsOptions = z.infer<typeof ListAppsSchema>;
|
|
@@ -18,6 +18,8 @@ import {
|
|
|
18
18
|
} from "../../utils/function-utils";
|
|
19
19
|
import type { GetVersionedImplementationId } from "../manifest/schemas";
|
|
20
20
|
import type { ManifestPluginProvides } from "../manifest";
|
|
21
|
+
import { appKeyResolver } from "../../resolvers";
|
|
22
|
+
import { AuthenticationItemSchema } from "../../schemas/Auth";
|
|
21
23
|
|
|
22
24
|
export interface ListAuthenticationsPluginProvides {
|
|
23
25
|
listAuthentications: (options?: ListAuthenticationsOptions) => Promise<{
|
|
@@ -135,7 +137,13 @@ export const listAuthenticationsPlugin: Plugin<
|
|
|
135
137
|
meta: {
|
|
136
138
|
listAuthentications: {
|
|
137
139
|
categories: ["authentication"],
|
|
140
|
+
type: "list",
|
|
141
|
+
itemType: "Authentication",
|
|
138
142
|
inputSchema: ListAuthenticationsSchema,
|
|
143
|
+
outputSchema: AuthenticationItemSchema,
|
|
144
|
+
resolvers: {
|
|
145
|
+
appKey: appKeyResolver,
|
|
146
|
+
},
|
|
139
147
|
},
|
|
140
148
|
},
|
|
141
149
|
},
|
|
@@ -10,10 +10,19 @@ import {
|
|
|
10
10
|
ListInputFieldChoicesSchema,
|
|
11
11
|
type ListInputFieldChoicesOptions,
|
|
12
12
|
type ListInputFieldChoicesPage,
|
|
13
|
+
InputFieldChoiceItemSchema,
|
|
13
14
|
} from "./schemas";
|
|
14
15
|
import { ZapierApiError } from "../../types/errors";
|
|
15
16
|
import { createPaginatedFunction } from "../../utils/function-utils";
|
|
16
17
|
import type { GetActionPluginProvides } from "../getAction";
|
|
18
|
+
import {
|
|
19
|
+
appKeyResolver,
|
|
20
|
+
actionTypeResolver,
|
|
21
|
+
actionKeyResolver,
|
|
22
|
+
authenticationIdResolver,
|
|
23
|
+
inputFieldKeyResolver,
|
|
24
|
+
inputsAllOptionalResolver,
|
|
25
|
+
} from "../../resolvers";
|
|
17
26
|
|
|
18
27
|
// Transform NeedChoices to InputFieldChoiceItem
|
|
19
28
|
function transformNeedChoicesToInputFieldChoiceItem(
|
|
@@ -116,7 +125,7 @@ export const listInputFieldChoicesPlugin: Plugin<
|
|
|
116
125
|
|
|
117
126
|
// Handle pagination
|
|
118
127
|
let nextCursor: string | undefined;
|
|
119
|
-
if (choicesData.next_page
|
|
128
|
+
if (choicesData.next_page != null) {
|
|
120
129
|
nextCursor = choicesData.next_page.toString();
|
|
121
130
|
} else if (choicesData.links?.next) {
|
|
122
131
|
// Extract page from next URL for external actions
|
|
@@ -144,7 +153,18 @@ export const listInputFieldChoicesPlugin: Plugin<
|
|
|
144
153
|
meta: {
|
|
145
154
|
listInputFieldChoices: {
|
|
146
155
|
categories: ["action"],
|
|
156
|
+
type: "list",
|
|
157
|
+
itemType: "InputFieldChoice",
|
|
147
158
|
inputSchema: ListInputFieldChoicesSchema,
|
|
159
|
+
outputSchema: InputFieldChoiceItemSchema,
|
|
160
|
+
resolvers: {
|
|
161
|
+
appKey: appKeyResolver,
|
|
162
|
+
actionType: actionTypeResolver,
|
|
163
|
+
actionKey: actionKeyResolver,
|
|
164
|
+
authenticationId: authenticationIdResolver,
|
|
165
|
+
inputFieldKey: inputFieldKeyResolver,
|
|
166
|
+
inputs: inputsAllOptionalResolver,
|
|
167
|
+
},
|
|
148
168
|
},
|
|
149
169
|
},
|
|
150
170
|
},
|
|
@@ -6,7 +6,8 @@ import {
|
|
|
6
6
|
ActionKeyPropertySchema,
|
|
7
7
|
InputsPropertySchema,
|
|
8
8
|
} from "../../types/properties";
|
|
9
|
-
import { withFormatter
|
|
9
|
+
import { withFormatter } from "../../utils/schema-utils";
|
|
10
|
+
import { NeedChoicesSchema } from "../../api/schemas";
|
|
10
11
|
import type { PaginatedSdkFunction } from "../../types/functions";
|
|
11
12
|
import type {
|
|
12
13
|
ZapierConfigurationError,
|
|
@@ -21,46 +22,33 @@ import type {
|
|
|
21
22
|
// Input Field Choice Item Schema
|
|
22
23
|
// ============================================================================
|
|
23
24
|
|
|
24
|
-
export const InputFieldChoiceItemSchema = withFormatter(
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
.
|
|
35
|
-
|
|
36
|
-
}),
|
|
37
|
-
{
|
|
38
|
-
format: (item) => {
|
|
39
|
-
const title = item.label || item.key || "Choice";
|
|
40
|
-
const subtitle =
|
|
41
|
-
item.label && item.key && item.label !== item.key
|
|
42
|
-
? `(${item.key})`
|
|
43
|
-
: undefined;
|
|
44
|
-
const details: Array<{
|
|
45
|
-
text: string;
|
|
46
|
-
style: "success" | "dim" | "normal" | "accent" | "warning";
|
|
47
|
-
}> = [];
|
|
25
|
+
export const InputFieldChoiceItemSchema = withFormatter(NeedChoicesSchema, {
|
|
26
|
+
format: (item) => {
|
|
27
|
+
const title = item.label || item.key || "Choice";
|
|
28
|
+
const details: Array<{
|
|
29
|
+
text: string;
|
|
30
|
+
style: "success" | "dim" | "normal" | "accent" | "warning";
|
|
31
|
+
}> = [];
|
|
32
|
+
|
|
33
|
+
// Show key as detail if different from label
|
|
34
|
+
if (item.label && item.key && item.label !== item.key) {
|
|
35
|
+
details.push({ text: `Key: ${item.key}`, style: "dim" });
|
|
36
|
+
}
|
|
48
37
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
38
|
+
if (item.sample && item.sample !== item.key) {
|
|
39
|
+
details.push({ text: `Sample: ${item.sample}`, style: "dim" });
|
|
40
|
+
}
|
|
41
|
+
if (item.value && item.value !== item.key) {
|
|
42
|
+
details.push({ text: `Value: ${item.value}`, style: "normal" });
|
|
43
|
+
}
|
|
55
44
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
},
|
|
45
|
+
return {
|
|
46
|
+
title,
|
|
47
|
+
key: item.key,
|
|
48
|
+
details,
|
|
49
|
+
};
|
|
62
50
|
},
|
|
63
|
-
);
|
|
51
|
+
});
|
|
64
52
|
|
|
65
53
|
export type InputFieldChoiceItem = z.infer<typeof InputFieldChoiceItemSchema>;
|
|
66
54
|
|
|
@@ -68,47 +56,44 @@ export type InputFieldChoiceItem = z.infer<typeof InputFieldChoiceItemSchema>;
|
|
|
68
56
|
// Plugin Schema Definition
|
|
69
57
|
// ============================================================================
|
|
70
58
|
|
|
71
|
-
export const ListInputFieldChoicesSchema =
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
actionKey: ActionKeyPropertySchema,
|
|
59
|
+
export const ListInputFieldChoicesSchema = z
|
|
60
|
+
.object({
|
|
61
|
+
// Required action identification
|
|
62
|
+
appKey: AppKeyPropertySchema,
|
|
63
|
+
actionType: ActionTypePropertySchema,
|
|
64
|
+
actionKey: ActionKeyPropertySchema,
|
|
78
65
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
66
|
+
// Input field specification
|
|
67
|
+
inputFieldKey: z
|
|
68
|
+
.string()
|
|
69
|
+
.min(1)
|
|
70
|
+
.describe("Input field key to get choices for."),
|
|
84
71
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
72
|
+
// Common parameters
|
|
73
|
+
authenticationId: AuthenticationIdPropertySchema.nullable().optional(),
|
|
74
|
+
inputs: InputsPropertySchema.optional().describe(
|
|
75
|
+
"Current input values that may affect available choices",
|
|
76
|
+
),
|
|
77
|
+
page: z
|
|
78
|
+
.number()
|
|
79
|
+
.int()
|
|
80
|
+
.min(0)
|
|
81
|
+
.optional()
|
|
82
|
+
.describe("Page number for paginated results"),
|
|
96
83
|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
InputFieldChoiceItemSchema,
|
|
111
|
-
);
|
|
84
|
+
// Pagination options (SDK-level)
|
|
85
|
+
pageSize: z
|
|
86
|
+
.number()
|
|
87
|
+
.min(1)
|
|
88
|
+
.optional()
|
|
89
|
+
.describe("Number of choices per page"),
|
|
90
|
+
maxItems: z
|
|
91
|
+
.number()
|
|
92
|
+
.min(1)
|
|
93
|
+
.optional()
|
|
94
|
+
.describe("Maximum total items to return across all pages"),
|
|
95
|
+
})
|
|
96
|
+
.describe("Get the available choices for a dynamic dropdown input field");
|
|
112
97
|
|
|
113
98
|
// Type inferred from schema
|
|
114
99
|
export type ListInputFieldChoicesOptions = z.infer<
|
|
@@ -217,7 +217,7 @@ describe("listInputFields plugin", () => {
|
|
|
217
217
|
// Check message field transformation
|
|
218
218
|
expect(result.data[0]).toEqual(
|
|
219
219
|
expect.objectContaining({
|
|
220
|
-
|
|
220
|
+
key: "message",
|
|
221
221
|
title: "Message",
|
|
222
222
|
description: "The message to send",
|
|
223
223
|
is_required: true,
|
|
@@ -227,26 +227,22 @@ describe("listInputFields plugin", () => {
|
|
|
227
227
|
}),
|
|
228
228
|
);
|
|
229
229
|
|
|
230
|
-
// Check channel field with
|
|
230
|
+
// Check channel field with SELECT format
|
|
231
231
|
expect(result.data[1]).toEqual(
|
|
232
232
|
expect.objectContaining({
|
|
233
|
-
|
|
233
|
+
key: "channel",
|
|
234
234
|
title: "Channel",
|
|
235
235
|
description: "The channel to send to",
|
|
236
236
|
is_required: true,
|
|
237
237
|
value_type: "STRING",
|
|
238
238
|
format: "SELECT",
|
|
239
|
-
choices: [
|
|
240
|
-
{ value: "#general", label: "General", sample: "#general" },
|
|
241
|
-
{ value: "#random", label: "Random", sample: "#random" },
|
|
242
|
-
],
|
|
243
239
|
}),
|
|
244
240
|
);
|
|
245
241
|
|
|
246
242
|
// Check array field
|
|
247
243
|
expect(result.data[2]).toEqual(
|
|
248
244
|
expect.objectContaining({
|
|
249
|
-
|
|
245
|
+
key: "tags",
|
|
250
246
|
title: "Tags",
|
|
251
247
|
description: "List of tags",
|
|
252
248
|
value_type: "ARRAY",
|
|
@@ -405,7 +401,7 @@ describe("listInputFields plugin", () => {
|
|
|
405
401
|
}
|
|
406
402
|
|
|
407
403
|
expect(items).toHaveLength(3);
|
|
408
|
-
expect(items[0].
|
|
404
|
+
expect(items[0].key).toBe("message");
|
|
409
405
|
});
|
|
410
406
|
});
|
|
411
407
|
});
|