@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
|
@@ -11,6 +11,14 @@ import { ZapierConfigurationError, ZapierApiError } from "../../types/errors";
|
|
|
11
11
|
import { createPaginatedFunction } from "../../utils/function-utils";
|
|
12
12
|
import type { GetAppPluginProvides } from "../getApp";
|
|
13
13
|
import type { GetVersionedImplementationId } from "../manifest/schemas";
|
|
14
|
+
import {
|
|
15
|
+
appKeyResolver,
|
|
16
|
+
actionTypeResolver,
|
|
17
|
+
actionKeyResolver,
|
|
18
|
+
authenticationIdResolver,
|
|
19
|
+
inputsAllOptionalResolver,
|
|
20
|
+
} from "../../resolvers";
|
|
21
|
+
import { InputFieldItemSchema } from "../../schemas/Field";
|
|
14
22
|
|
|
15
23
|
// Enums for input field transformation
|
|
16
24
|
enum InputFieldType {
|
|
@@ -93,8 +101,8 @@ function transformNeedToInputFieldItem(need: Need): InputFieldItem {
|
|
|
93
101
|
const itemsType = getItemsTypeFromNeed(need);
|
|
94
102
|
|
|
95
103
|
return {
|
|
96
|
-
|
|
97
|
-
|
|
104
|
+
// Only the final computed/mapped fields that are in InputFieldItemSchema
|
|
105
|
+
key: need.key,
|
|
98
106
|
default_value: need.default || "",
|
|
99
107
|
depends_on: need.depends_on || [],
|
|
100
108
|
description: need.help_text || "",
|
|
@@ -200,7 +208,17 @@ export const listInputFieldsPlugin: Plugin<
|
|
|
200
208
|
meta: {
|
|
201
209
|
listInputFields: {
|
|
202
210
|
categories: ["action"],
|
|
211
|
+
type: "list",
|
|
212
|
+
itemType: "InputField",
|
|
203
213
|
inputSchema: ListInputFieldsSchema,
|
|
214
|
+
outputSchema: InputFieldItemSchema,
|
|
215
|
+
resolvers: {
|
|
216
|
+
appKey: appKeyResolver,
|
|
217
|
+
actionType: actionTypeResolver,
|
|
218
|
+
actionKey: actionKeyResolver,
|
|
219
|
+
authenticationId: authenticationIdResolver,
|
|
220
|
+
inputs: inputsAllOptionalResolver,
|
|
221
|
+
},
|
|
204
222
|
},
|
|
205
223
|
},
|
|
206
224
|
},
|
|
@@ -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:",
|
|
@@ -1,19 +1,17 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { DynamicResolver } from "../utils/schema-utils";
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
fetch: (
|
|
7
|
-
sdk: ZapierSdk,
|
|
8
|
-
resolvedParams: Record<string, any>,
|
|
9
|
-
) => Promise<any[]>;
|
|
10
|
-
prompt: (items: any[], params: Record<string, any>) => any;
|
|
3
|
+
interface ActionTypeItem {
|
|
4
|
+
key: string;
|
|
5
|
+
name: string;
|
|
11
6
|
}
|
|
12
7
|
|
|
13
|
-
export const actionTypeResolver:
|
|
8
|
+
export const actionTypeResolver: DynamicResolver<
|
|
9
|
+
ActionTypeItem,
|
|
10
|
+
{ appKey: string }
|
|
11
|
+
> = {
|
|
14
12
|
type: "dynamic",
|
|
15
13
|
depends: ["appKey"] as const,
|
|
16
|
-
fetch: async (sdk
|
|
14
|
+
fetch: async (sdk, resolvedParams) => {
|
|
17
15
|
const actionsResponse = await sdk.listActions({
|
|
18
16
|
appKey: resolvedParams.appKey,
|
|
19
17
|
});
|
|
@@ -23,7 +21,7 @@ export const actionTypeResolver: ActionTypeResolver = {
|
|
|
23
21
|
];
|
|
24
22
|
return types.map((type) => ({ key: type, name: type }));
|
|
25
23
|
},
|
|
26
|
-
prompt: (types
|
|
24
|
+
prompt: (types) => ({
|
|
27
25
|
type: "list",
|
|
28
26
|
name: "actionType",
|
|
29
27
|
message: "Select action type:",
|
package/src/resolvers/appKey.ts
CHANGED
|
@@ -1,10 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
type: "static";
|
|
3
|
-
inputType?: "text" | "password" | "email";
|
|
4
|
-
placeholder?: string;
|
|
5
|
-
}
|
|
1
|
+
import type { StaticResolver } from "../utils/schema-utils";
|
|
6
2
|
|
|
7
|
-
export const appKeyResolver:
|
|
3
|
+
export const appKeyResolver: StaticResolver = {
|
|
8
4
|
type: "static",
|
|
9
5
|
inputType: "text",
|
|
10
6
|
placeholder: "Enter app key (e.g., 'SlackCLIAPI' or slug like 'github')",
|
|
@@ -1,38 +1,38 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { DynamicResolver } from "../utils/schema-utils";
|
|
2
|
+
import type { AuthItem } from "../schemas/Auth";
|
|
2
3
|
|
|
3
|
-
|
|
4
|
-
type: "dynamic";
|
|
5
|
-
depends: readonly string[];
|
|
6
|
-
fetch: (
|
|
7
|
-
sdk: ZapierSdk,
|
|
8
|
-
resolvedParams: Record<string, any>,
|
|
9
|
-
) => Promise<any[]>;
|
|
10
|
-
prompt: (items: any[], params: Record<string, any>) => any;
|
|
11
|
-
}
|
|
4
|
+
type AuthenticationIdResolver = DynamicResolver<AuthItem, { appKey?: string }>;
|
|
12
5
|
|
|
13
6
|
export const authenticationIdResolver: AuthenticationIdResolver = {
|
|
14
7
|
type: "dynamic",
|
|
15
8
|
depends: ["appKey"] as const,
|
|
16
|
-
fetch: async (sdk
|
|
17
|
-
const
|
|
18
|
-
appKey: resolvedParams.appKey,
|
|
9
|
+
fetch: async (sdk, resolvedParams) => {
|
|
10
|
+
const listOptions: { maxItems: number; appKey?: string } = {
|
|
19
11
|
maxItems: 1000,
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
if (resolvedParams.appKey) {
|
|
15
|
+
listOptions.appKey = resolvedParams.appKey;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const myAuths = await sdk.listAuthentications({
|
|
19
|
+
...listOptions,
|
|
20
20
|
owner: "me",
|
|
21
21
|
});
|
|
22
|
-
const allAuths = await sdk.listAuthentications(
|
|
23
|
-
|
|
24
|
-
maxItems: 1000,
|
|
25
|
-
});
|
|
22
|
+
const allAuths = await sdk.listAuthentications(listOptions);
|
|
23
|
+
|
|
26
24
|
// Filter out myAuths from allAuths
|
|
27
25
|
const otherAuths = allAuths.data.filter(
|
|
28
26
|
(auth) => !myAuths.data.some((myAuth) => myAuth.id === auth.id),
|
|
29
27
|
);
|
|
30
28
|
return [...myAuths.data, ...otherAuths];
|
|
31
29
|
},
|
|
32
|
-
prompt: (auths
|
|
30
|
+
prompt: (auths, params) => ({
|
|
33
31
|
type: "list",
|
|
34
32
|
name: "authenticationId",
|
|
35
|
-
message:
|
|
33
|
+
message: params.appKey
|
|
34
|
+
? `Select authentication for ${params.appKey}:`
|
|
35
|
+
: "Select authentication:",
|
|
36
36
|
choices: [
|
|
37
37
|
...auths.map((auth) => ({
|
|
38
38
|
name: `${auth.title || auth.label || "Authentication"} (ID: ${auth.id})`,
|
|
@@ -45,3 +45,9 @@ export const authenticationIdResolver: AuthenticationIdResolver = {
|
|
|
45
45
|
],
|
|
46
46
|
}),
|
|
47
47
|
};
|
|
48
|
+
|
|
49
|
+
// Generic version without appKey dependency
|
|
50
|
+
export const authenticationIdGenericResolver: AuthenticationIdResolver = {
|
|
51
|
+
...authenticationIdResolver,
|
|
52
|
+
depends: [] as const,
|
|
53
|
+
};
|
package/src/resolvers/index.ts
CHANGED
|
@@ -1,117 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
import { actionTypeResolver } from "./actionType";
|
|
3
|
-
import { actionKeyResolver } from "./actionKey";
|
|
4
|
-
import { authenticationIdResolver } from "./authenticationId";
|
|
5
|
-
import { inputsResolver } from "./inputs";
|
|
6
|
-
|
|
7
|
-
// Centralized resolver registry
|
|
8
|
-
export const resolverRegistry = {
|
|
9
|
-
appKey: appKeyResolver,
|
|
10
|
-
actionType: actionTypeResolver,
|
|
11
|
-
actionKey: actionKeyResolver,
|
|
12
|
-
authenticationId: authenticationIdResolver,
|
|
13
|
-
inputs: inputsResolver,
|
|
14
|
-
} as const;
|
|
15
|
-
|
|
16
|
-
// Type definitions
|
|
17
|
-
export type ResolverName = keyof typeof resolverRegistry;
|
|
18
|
-
export type ResolverType = (typeof resolverRegistry)[ResolverName];
|
|
19
|
-
|
|
20
|
-
// Utility functions for working with resolvers
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* Get a resolver by name
|
|
24
|
-
*/
|
|
25
|
-
export function getResolver(name: string): ResolverType | undefined {
|
|
26
|
-
return resolverRegistry[name as ResolverName];
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* Get all resolvers for a list of missing parameters
|
|
31
|
-
*/
|
|
32
|
-
export function getResolversForMissingParams(
|
|
33
|
-
missingParams: string[],
|
|
34
|
-
): Record<string, ResolverType> {
|
|
35
|
-
const resolvers: Record<string, ResolverType> = {};
|
|
36
|
-
|
|
37
|
-
for (const param of missingParams) {
|
|
38
|
-
const resolver = resolverRegistry[param as ResolverName];
|
|
39
|
-
if (resolver) {
|
|
40
|
-
resolvers[param] = resolver;
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
return resolvers;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* Check if a parameter has a resolver
|
|
49
|
-
*/
|
|
50
|
-
export function hasResolver(paramName: string): boolean {
|
|
51
|
-
return paramName in resolverRegistry;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
* Get all parameter names that have resolvers
|
|
56
|
-
*/
|
|
57
|
-
export function getResolvableParams(): string[] {
|
|
58
|
-
return Object.keys(resolverRegistry);
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
/**
|
|
62
|
-
* Resolve dependency chain for a parameter
|
|
63
|
-
* Returns parameters in the order they need to be resolved
|
|
64
|
-
*/
|
|
65
|
-
export function getResolutionOrder(
|
|
66
|
-
paramName: string,
|
|
67
|
-
resolved: Set<string> = new Set(),
|
|
68
|
-
): string[] {
|
|
69
|
-
const resolver = getResolver(paramName);
|
|
70
|
-
if (!resolver || resolver.type === "static") {
|
|
71
|
-
return [paramName];
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
const order: string[] = [];
|
|
75
|
-
|
|
76
|
-
if ("depends" in resolver && resolver.depends) {
|
|
77
|
-
for (const dependency of resolver.depends) {
|
|
78
|
-
if (!resolved.has(dependency)) {
|
|
79
|
-
order.push(...getResolutionOrder(dependency, resolved));
|
|
80
|
-
resolved.add(dependency);
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
if (!resolved.has(paramName)) {
|
|
86
|
-
order.push(paramName);
|
|
87
|
-
resolved.add(paramName);
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
return order;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
/**
|
|
94
|
-
* Get resolution order for multiple parameters
|
|
95
|
-
*/
|
|
96
|
-
export function getResolutionOrderForParams(paramNames: string[]): string[] {
|
|
97
|
-
const resolved = new Set<string>();
|
|
98
|
-
const order: string[] = [];
|
|
99
|
-
|
|
100
|
-
for (const paramName of paramNames) {
|
|
101
|
-
const paramOrder = getResolutionOrder(paramName, resolved);
|
|
102
|
-
for (const param of paramOrder) {
|
|
103
|
-
if (!order.includes(param)) {
|
|
104
|
-
order.push(param);
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
return order;
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
// Re-export individual resolvers for direct access if needed
|
|
1
|
+
// Re-export individual resolvers for plugin use
|
|
113
2
|
export { appKeyResolver } from "./appKey";
|
|
114
3
|
export { actionTypeResolver } from "./actionType";
|
|
115
4
|
export { actionKeyResolver } from "./actionKey";
|
|
116
|
-
export {
|
|
5
|
+
export {
|
|
6
|
+
authenticationIdResolver,
|
|
7
|
+
authenticationIdGenericResolver,
|
|
8
|
+
} from "./authenticationId";
|
|
117
9
|
export { inputsResolver } from "./inputs";
|
|
10
|
+
export { inputFieldKeyResolver } from "./inputFieldKey";
|
|
11
|
+
export { inputsAllOptionalResolver } from "./inputs";
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { DynamicResolver } from "../utils/schema-utils";
|
|
2
|
+
import type { InputFieldItem } from "../schemas/Field";
|
|
3
|
+
import type { ActionTypeProperty } from "../types/properties";
|
|
4
|
+
|
|
5
|
+
export const inputFieldKeyResolver: DynamicResolver<
|
|
6
|
+
InputFieldItem,
|
|
7
|
+
{
|
|
8
|
+
appKey: string;
|
|
9
|
+
actionKey: string;
|
|
10
|
+
actionType: ActionTypeProperty;
|
|
11
|
+
authenticationId: number;
|
|
12
|
+
inputs?: Record<string, unknown>;
|
|
13
|
+
}
|
|
14
|
+
> = {
|
|
15
|
+
type: "dynamic",
|
|
16
|
+
depends: ["appKey", "actionKey", "actionType", "authenticationId"] as const,
|
|
17
|
+
fetch: async (sdk, resolvedParams) => {
|
|
18
|
+
const fieldsResponse = await sdk.listInputFields({
|
|
19
|
+
appKey: resolvedParams.appKey,
|
|
20
|
+
actionKey: resolvedParams.actionKey,
|
|
21
|
+
actionType: resolvedParams.actionType,
|
|
22
|
+
authenticationId: resolvedParams.authenticationId,
|
|
23
|
+
inputs: resolvedParams.inputs, // Pass along currently resolved inputs
|
|
24
|
+
});
|
|
25
|
+
return fieldsResponse.data;
|
|
26
|
+
},
|
|
27
|
+
prompt: (fields) => ({
|
|
28
|
+
type: "list",
|
|
29
|
+
name: "inputFieldKey",
|
|
30
|
+
message: "Select input field:",
|
|
31
|
+
choices: fields.map((field) => ({
|
|
32
|
+
name: `${field.title || field.key} - ${
|
|
33
|
+
field.value_type || "No type"
|
|
34
|
+
} ${field.is_required ? "(required)" : "(optional)"}`,
|
|
35
|
+
value: field.key,
|
|
36
|
+
})),
|
|
37
|
+
}),
|
|
38
|
+
};
|
package/src/resolvers/inputs.ts
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { FieldsResolver } from "../utils/schema-utils";
|
|
2
|
+
import type { ActionTypeProperty } from "../types/properties";
|
|
2
3
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
}
|
|
4
|
+
type InputsResolver = FieldsResolver<{
|
|
5
|
+
appKey: string;
|
|
6
|
+
actionKey: string;
|
|
7
|
+
actionType: ActionTypeProperty;
|
|
8
|
+
authenticationId: number;
|
|
9
|
+
inputs?: Record<string, unknown>;
|
|
10
|
+
}>;
|
|
11
11
|
|
|
12
12
|
export const inputsResolver: InputsResolver = {
|
|
13
13
|
type: "fields",
|
|
14
14
|
depends: ["appKey", "actionKey", "actionType", "authenticationId"] as const,
|
|
15
|
-
fetch: async (sdk
|
|
15
|
+
fetch: async (sdk, resolvedParams) => {
|
|
16
16
|
const fieldsResponse = await sdk.listInputFields({
|
|
17
17
|
appKey: resolvedParams.appKey,
|
|
18
18
|
actionKey: resolvedParams.actionKey,
|
|
@@ -23,3 +23,21 @@ export const inputsResolver: InputsResolver = {
|
|
|
23
23
|
return fieldsResponse.data;
|
|
24
24
|
},
|
|
25
25
|
};
|
|
26
|
+
|
|
27
|
+
export const inputsAllOptionalResolver: InputsResolver = {
|
|
28
|
+
type: "fields",
|
|
29
|
+
depends: ["appKey", "actionKey", "actionType", "authenticationId"] as const,
|
|
30
|
+
fetch: async (sdk, resolvedParams) => {
|
|
31
|
+
const fieldsResponse = await sdk.listInputFields({
|
|
32
|
+
appKey: resolvedParams.appKey,
|
|
33
|
+
actionKey: resolvedParams.actionKey,
|
|
34
|
+
actionType: resolvedParams.actionType,
|
|
35
|
+
authenticationId: resolvedParams.authenticationId,
|
|
36
|
+
inputs: resolvedParams.inputs, // Pass along currently resolved inputs
|
|
37
|
+
});
|
|
38
|
+
return fieldsResponse.data.map((field) => ({
|
|
39
|
+
...field,
|
|
40
|
+
is_required: false,
|
|
41
|
+
}));
|
|
42
|
+
},
|
|
43
|
+
};
|
package/src/schemas/Action.ts
CHANGED
|
@@ -27,12 +27,17 @@ export const ActionItemSchema = withFormatter(
|
|
|
27
27
|
});
|
|
28
28
|
}
|
|
29
29
|
if (item.description) {
|
|
30
|
-
details.push({
|
|
30
|
+
details.push({
|
|
31
|
+
text: item.description,
|
|
32
|
+
style: "dim" as const,
|
|
33
|
+
});
|
|
31
34
|
}
|
|
32
35
|
|
|
33
36
|
return {
|
|
34
|
-
title: item.title || item.
|
|
35
|
-
|
|
37
|
+
title: item.title || item.key,
|
|
38
|
+
id: item.id,
|
|
39
|
+
key: item.key,
|
|
40
|
+
description: item.description,
|
|
36
41
|
details,
|
|
37
42
|
};
|
|
38
43
|
},
|
package/src/schemas/App.ts
CHANGED
|
@@ -1,27 +1,25 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import { withFormatter } from "../utils/schema-utils";
|
|
3
|
+
import { ImplementationMetaSchema } from "../api/schemas";
|
|
3
4
|
|
|
4
5
|
export { FormattedItem, FormatMetadata } from "../utils/schema-utils";
|
|
5
6
|
|
|
6
7
|
// ============================================================================
|
|
7
|
-
// App Item Schema (extends
|
|
8
|
+
// App Item Schema (extends ImplementationMetaSchema with transformed fields)
|
|
8
9
|
// ============================================================================
|
|
9
10
|
|
|
10
11
|
export const AppItemSchema = withFormatter(
|
|
11
|
-
|
|
12
|
-
// Essential properties only
|
|
12
|
+
ImplementationMetaSchema.omit({ name: true, id: true }).extend({
|
|
13
13
|
title: z.string(), // Mapped from name
|
|
14
|
-
key: z.string(), //
|
|
15
|
-
|
|
16
|
-
version: z.string().optional(), // Extracted from implementation ID
|
|
17
|
-
description: z.string().optional(),
|
|
18
|
-
slug: z.string().optional(),
|
|
14
|
+
key: z.string(), // Extracted from id (base part without version)
|
|
15
|
+
implementation_id: z.string(), // Mapped from id (full versioned ID)
|
|
19
16
|
}),
|
|
20
17
|
{
|
|
21
18
|
format: (item) => {
|
|
22
19
|
return {
|
|
23
20
|
title: item.title,
|
|
24
|
-
|
|
21
|
+
key: item.key,
|
|
22
|
+
description: item.description,
|
|
25
23
|
details: [],
|
|
26
24
|
};
|
|
27
25
|
},
|