@zapier/zapier-sdk 0.9.0 → 0.11.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 +18 -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 +968 -582
- package/dist/index.d.mts +2537 -2229
- 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 +966 -576
- 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 +4 -4
- package/dist/plugins/listInputFields/index.d.ts.map +1 -1
- package/dist/plugins/listInputFields/index.js +71 -5
- package/dist/plugins/listInputFields/index.test.js +5 -9
- package/dist/plugins/listInputFields/schemas.d.ts +8 -6
- 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 +47 -0
- package/dist/resolvers/inputs.d.ts +13 -4
- package/dist/resolvers/inputs.d.ts.map +1 -1
- package/dist/resolvers/inputs.js +36 -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 +112 -97
- package/dist/schemas/Field.d.ts.map +1 -1
- package/dist/schemas/Field.js +63 -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/domain.d.ts +17 -1
- package/dist/types/domain.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/dist/utils/string-utils.d.ts +12 -0
- package/dist/utils/string-utils.d.ts.map +1 -0
- package/dist/utils/string-utils.js +23 -0
- package/dist/utils/string-utils.test.d.ts +2 -0
- package/dist/utils/string-utils.test.d.ts.map +1 -0
- package/dist/utils/string-utils.test.js +36 -0
- 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 +89 -11
- package/src/plugins/listInputFields/schemas.ts +6 -3
- 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 +70 -0
- package/src/resolvers/inputs.ts +51 -7
- 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 +97 -60
- package/src/schemas/Run.ts +40 -0
- package/src/schemas/UserProfile.ts +24 -7
- package/src/sdk.ts +17 -7
- package/src/types/domain.ts +24 -1
- 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/src/utils/string-utils.test.ts +45 -0
- package/src/utils/string-utils.ts +26 -0
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -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
|
});
|
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
import type { Plugin, GetSdkType } from "../../types/plugin";
|
|
2
2
|
import type { ApiClient } from "../../api";
|
|
3
3
|
import type { NeedsRequest, NeedsResponse, Need } from "../../api/types";
|
|
4
|
-
import type {
|
|
4
|
+
import type {
|
|
5
|
+
InputFieldItem,
|
|
6
|
+
InfoFieldItem,
|
|
7
|
+
FieldsetItem,
|
|
8
|
+
RootFieldItem,
|
|
9
|
+
} from "../../types/domain";
|
|
5
10
|
import {
|
|
6
11
|
ListInputFieldsSchema,
|
|
7
12
|
type ListInputFieldsOptions,
|
|
@@ -11,6 +16,15 @@ import { ZapierConfigurationError, ZapierApiError } from "../../types/errors";
|
|
|
11
16
|
import { createPaginatedFunction } from "../../utils/function-utils";
|
|
12
17
|
import type { GetAppPluginProvides } from "../getApp";
|
|
13
18
|
import type { GetVersionedImplementationId } from "../manifest/schemas";
|
|
19
|
+
import {
|
|
20
|
+
appKeyResolver,
|
|
21
|
+
actionTypeResolver,
|
|
22
|
+
actionKeyResolver,
|
|
23
|
+
authenticationIdResolver,
|
|
24
|
+
inputsAllOptionalResolver,
|
|
25
|
+
} from "../../resolvers";
|
|
26
|
+
import { RootFieldItemSchema } from "../../schemas/Field";
|
|
27
|
+
import { toTitleCase } from "../../utils/string-utils";
|
|
14
28
|
|
|
15
29
|
// Enums for input field transformation
|
|
16
30
|
enum InputFieldType {
|
|
@@ -93,8 +107,8 @@ function transformNeedToInputFieldItem(need: Need): InputFieldItem {
|
|
|
93
107
|
const itemsType = getItemsTypeFromNeed(need);
|
|
94
108
|
|
|
95
109
|
return {
|
|
96
|
-
|
|
97
|
-
|
|
110
|
+
type: "input_field",
|
|
111
|
+
key: need.key,
|
|
98
112
|
default_value: need.default || "",
|
|
99
113
|
depends_on: need.depends_on || [],
|
|
100
114
|
description: need.help_text || "",
|
|
@@ -108,12 +122,68 @@ function transformNeedToInputFieldItem(need: Need): InputFieldItem {
|
|
|
108
122
|
};
|
|
109
123
|
}
|
|
110
124
|
|
|
125
|
+
// Transform Need to InfoFieldItem (for copy fields)
|
|
126
|
+
function transformNeedToInfoFieldItem(need: Need): InfoFieldItem {
|
|
127
|
+
return {
|
|
128
|
+
type: "info_field",
|
|
129
|
+
key: need.key,
|
|
130
|
+
description: need.help_text || "",
|
|
131
|
+
title: need.label,
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
// Transform needs to fields (similar to partnerapi compute_root_fieldset_from_needs)
|
|
136
|
+
function transformNeedsToFields(needs: Need[]): RootFieldItem[] {
|
|
137
|
+
const rootFields: (InputFieldItem | InfoFieldItem | FieldsetItem)[] = [];
|
|
138
|
+
const fieldsetMap = new Map<string, FieldsetItem>();
|
|
139
|
+
|
|
140
|
+
for (const need of needs) {
|
|
141
|
+
if (need.computed) {
|
|
142
|
+
// Computed needs (i.e zap_id for CodeAPI steps) are not shown by the
|
|
143
|
+
// editor, hide them here too.
|
|
144
|
+
continue;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
// If parent_key is set, we need to ensure that a corresponding
|
|
148
|
+
// fieldset exists, since we'll be adding this need to that fieldset
|
|
149
|
+
if (need.parent_key) {
|
|
150
|
+
let fieldset = fieldsetMap.get(need.parent_key);
|
|
151
|
+
if (!fieldset) {
|
|
152
|
+
fieldset = {
|
|
153
|
+
type: "fieldset",
|
|
154
|
+
key: need.parent_key,
|
|
155
|
+
title: toTitleCase(need.parent_key),
|
|
156
|
+
fields: [],
|
|
157
|
+
};
|
|
158
|
+
fieldsetMap.set(need.parent_key, fieldset);
|
|
159
|
+
rootFields.push(fieldset);
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
// Add field to fieldset
|
|
163
|
+
if (need.type === "copy" && need.help_text) {
|
|
164
|
+
fieldset.fields.push(transformNeedToInfoFieldItem(need));
|
|
165
|
+
} else {
|
|
166
|
+
fieldset.fields.push(transformNeedToInputFieldItem(need));
|
|
167
|
+
}
|
|
168
|
+
} else {
|
|
169
|
+
// Add field to root
|
|
170
|
+
if (need.type === "copy" && need.help_text) {
|
|
171
|
+
rootFields.push(transformNeedToInfoFieldItem(need));
|
|
172
|
+
} else {
|
|
173
|
+
rootFields.push(transformNeedToInputFieldItem(need));
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
return rootFields;
|
|
179
|
+
}
|
|
180
|
+
|
|
111
181
|
export interface ListInputFieldsPluginProvides {
|
|
112
182
|
listInputFields: (options?: ListInputFieldsOptions) => Promise<{
|
|
113
|
-
data:
|
|
183
|
+
data: RootFieldItem[];
|
|
114
184
|
}> &
|
|
115
|
-
AsyncIterable<{ data:
|
|
116
|
-
items(): AsyncIterable<InputFieldItem>;
|
|
185
|
+
AsyncIterable<{ data: RootFieldItem[]; nextCursor?: string }> & {
|
|
186
|
+
items(): AsyncIterable<InputFieldItem | InfoFieldItem | FieldsetItem>;
|
|
117
187
|
};
|
|
118
188
|
context: {
|
|
119
189
|
meta: {
|
|
@@ -181,13 +251,11 @@ export const listInputFieldsPlugin: Plugin<
|
|
|
181
251
|
);
|
|
182
252
|
}
|
|
183
253
|
|
|
184
|
-
// Transform Need objects to
|
|
185
|
-
const
|
|
186
|
-
transformNeedToInputFieldItem,
|
|
187
|
-
);
|
|
254
|
+
// Transform Need objects to Root Fieldset with proper nesting
|
|
255
|
+
const rootFieldset = transformNeedsToFields(needsData.needs || []);
|
|
188
256
|
|
|
189
257
|
return {
|
|
190
|
-
data:
|
|
258
|
+
data: rootFieldset,
|
|
191
259
|
nextCursor: undefined, // No pagination needed since we return all input fields
|
|
192
260
|
};
|
|
193
261
|
},
|
|
@@ -200,7 +268,17 @@ export const listInputFieldsPlugin: Plugin<
|
|
|
200
268
|
meta: {
|
|
201
269
|
listInputFields: {
|
|
202
270
|
categories: ["action"],
|
|
271
|
+
type: "list",
|
|
272
|
+
itemType: "RootFieldItem",
|
|
203
273
|
inputSchema: ListInputFieldsSchema,
|
|
274
|
+
outputSchema: RootFieldItemSchema,
|
|
275
|
+
resolvers: {
|
|
276
|
+
appKey: appKeyResolver,
|
|
277
|
+
actionType: actionTypeResolver,
|
|
278
|
+
actionKey: actionKeyResolver,
|
|
279
|
+
authenticationId: authenticationIdResolver,
|
|
280
|
+
inputs: inputsAllOptionalResolver,
|
|
281
|
+
},
|
|
204
282
|
},
|
|
205
283
|
},
|
|
206
284
|
},
|
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
AuthenticationIdPropertySchema,
|
|
7
7
|
InputsPropertySchema,
|
|
8
8
|
} from "../../types/properties";
|
|
9
|
-
import type {
|
|
9
|
+
import type { RootFieldItem } from "../../types/domain";
|
|
10
10
|
import type { PaginatedSdkFunction } from "../../types/functions";
|
|
11
11
|
import type {
|
|
12
12
|
ZapierConfigurationError,
|
|
@@ -54,11 +54,14 @@ export type ListInputFieldsError =
|
|
|
54
54
|
|
|
55
55
|
// Page result structure
|
|
56
56
|
export interface ListInputFieldsPage {
|
|
57
|
-
data:
|
|
57
|
+
data: RootFieldItem[];
|
|
58
58
|
nextCursor?: string;
|
|
59
59
|
}
|
|
60
60
|
|
|
61
61
|
// SDK function interface
|
|
62
62
|
export interface ListInputFieldsSdkFunction {
|
|
63
|
-
listInputFields: PaginatedSdkFunction<
|
|
63
|
+
listInputFields: PaginatedSdkFunction<
|
|
64
|
+
ListInputFieldsOptions,
|
|
65
|
+
RootFieldItem[]
|
|
66
|
+
>;
|
|
64
67
|
}
|
|
@@ -55,10 +55,16 @@ export const registryPlugin: Plugin<
|
|
|
55
55
|
const functions = metaKeys
|
|
56
56
|
.filter((key) => typeof sdk[key as keyof typeof sdk] === "function")
|
|
57
57
|
.map((key) => {
|
|
58
|
+
const meta = context.meta[key];
|
|
58
59
|
return {
|
|
59
|
-
...context.meta[key],
|
|
60
|
-
categories: context.meta[key].categories || [],
|
|
61
60
|
name: key,
|
|
61
|
+
type: meta.type,
|
|
62
|
+
itemType: meta.itemType,
|
|
63
|
+
returnType: meta.returnType,
|
|
64
|
+
inputSchema: meta.inputSchema,
|
|
65
|
+
outputSchema: meta.outputSchema,
|
|
66
|
+
categories: meta.categories || [],
|
|
67
|
+
resolvers: meta.resolvers,
|
|
62
68
|
};
|
|
63
69
|
})
|
|
64
70
|
.sort((a, b) => a.name.localeCompare(b.name));
|
|
@@ -5,6 +5,7 @@ import {
|
|
|
5
5
|
type RunActionOptions,
|
|
6
6
|
type RunActionPage,
|
|
7
7
|
} from "./schemas";
|
|
8
|
+
import { ActionResultItemSchema } from "../../schemas/Run";
|
|
8
9
|
import {
|
|
9
10
|
ZapierValidationError,
|
|
10
11
|
ZapierConfigurationError,
|
|
@@ -13,6 +14,13 @@ import {
|
|
|
13
14
|
import { createPaginatedFunction } from "../../utils/function-utils";
|
|
14
15
|
import type { GetActionPluginProvides } from "../getAction";
|
|
15
16
|
import type { GetAppPluginProvides } from "../getApp";
|
|
17
|
+
import {
|
|
18
|
+
appKeyResolver,
|
|
19
|
+
actionTypeResolver,
|
|
20
|
+
actionKeyResolver,
|
|
21
|
+
authenticationIdResolver,
|
|
22
|
+
inputsResolver,
|
|
23
|
+
} from "../../resolvers";
|
|
16
24
|
import type { GetVersionedImplementationId } from "../manifest/schemas";
|
|
17
25
|
|
|
18
26
|
export interface RunActionPluginProvides {
|
|
@@ -177,7 +185,17 @@ export const runActionPlugin: Plugin<
|
|
|
177
185
|
meta: {
|
|
178
186
|
runAction: {
|
|
179
187
|
categories: ["action"],
|
|
188
|
+
type: "list",
|
|
189
|
+
itemType: "ActionResult",
|
|
180
190
|
inputSchema: RunActionSchema,
|
|
191
|
+
outputSchema: ActionResultItemSchema,
|
|
192
|
+
resolvers: {
|
|
193
|
+
appKey: appKeyResolver,
|
|
194
|
+
actionType: actionTypeResolver,
|
|
195
|
+
actionKey: actionKeyResolver,
|
|
196
|
+
authenticationId: authenticationIdResolver,
|
|
197
|
+
inputs: inputsResolver,
|
|
198
|
+
},
|
|
181
199
|
},
|
|
182
200
|
},
|
|
183
201
|
},
|
|
@@ -1,27 +1,29 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { DynamicResolver } from "../utils/schema-utils";
|
|
2
|
+
import type { ActionTypeProperty } from "../types/properties";
|
|
2
3
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
) => Promise<any[]>;
|
|
10
|
-
prompt: (items: any[], params: Record<string, any>) => any;
|
|
4
|
+
interface ActionItem {
|
|
5
|
+
key: string;
|
|
6
|
+
title?: string;
|
|
7
|
+
name?: string;
|
|
8
|
+
description?: string;
|
|
9
|
+
action_type: string;
|
|
11
10
|
}
|
|
12
11
|
|
|
13
|
-
export const actionKeyResolver:
|
|
12
|
+
export const actionKeyResolver: DynamicResolver<
|
|
13
|
+
ActionItem,
|
|
14
|
+
{ appKey: string; actionType: ActionTypeProperty }
|
|
15
|
+
> = {
|
|
14
16
|
type: "dynamic",
|
|
15
17
|
depends: ["appKey", "actionType"] as const,
|
|
16
|
-
fetch: async (sdk
|
|
18
|
+
fetch: async (sdk, resolvedParams) => {
|
|
17
19
|
const actionsResponse = await sdk.listActions({
|
|
18
20
|
appKey: resolvedParams.appKey,
|
|
19
21
|
});
|
|
20
22
|
return actionsResponse.data.filter(
|
|
21
|
-
(action:
|
|
23
|
+
(action: ActionItem) => action.action_type === resolvedParams.actionType,
|
|
22
24
|
);
|
|
23
25
|
},
|
|
24
|
-
prompt: (actions
|
|
26
|
+
prompt: (actions) => ({
|
|
25
27
|
type: "list",
|
|
26
28
|
name: "actionKey",
|
|
27
29
|
message: "Select action:",
|