@zapier/zapier-sdk 0.0.3 → 0.1.1
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/dist/api/auth.d.ts +8 -0
- package/dist/api/auth.js +29 -0
- package/dist/api/client.d.ts +8 -0
- package/dist/api/client.js +102 -0
- package/dist/api/debug.d.ts +12 -0
- package/dist/api/debug.js +50 -0
- package/dist/api/index.d.ts +26 -0
- package/dist/api/index.js +51 -0
- package/dist/api/polling.d.ts +17 -0
- package/dist/api/polling.js +34 -0
- package/dist/{types.d.ts → api/types.d.ts} +37 -88
- package/dist/api/types.js +9 -0
- package/dist/functions/{bundleCode.d.ts → bundleCode/index.d.ts} +1 -8
- package/dist/functions/bundleCode/info.d.ts +27 -0
- package/dist/functions/bundleCode/info.js +11 -0
- package/dist/functions/bundleCode/schemas.d.ts +27 -0
- package/dist/functions/bundleCode/schemas.js +22 -0
- package/dist/functions/findFirstAuthentication/index.d.ts +12 -0
- package/dist/functions/findFirstAuthentication/index.js +21 -0
- package/dist/functions/findFirstAuthentication/info.d.ts +30 -0
- package/dist/functions/findFirstAuthentication/info.js +11 -0
- package/dist/functions/findFirstAuthentication/schemas.d.ts +42 -0
- package/dist/functions/findFirstAuthentication/schemas.js +25 -0
- package/dist/functions/findUniqueAuthentication/index.d.ts +13 -0
- package/dist/functions/findUniqueAuthentication/index.js +28 -0
- package/dist/functions/findUniqueAuthentication/info.d.ts +30 -0
- package/dist/functions/findUniqueAuthentication/info.js +11 -0
- package/dist/functions/findUniqueAuthentication/schemas.d.ts +42 -0
- package/dist/functions/findUniqueAuthentication/schemas.js +25 -0
- package/dist/functions/{generateTypes.d.ts → generateTypes/index.d.ts} +2 -7
- package/dist/functions/{generateTypes.js → generateTypes/index.js} +58 -24
- package/dist/functions/generateTypes/info.d.ts +21 -0
- package/dist/functions/generateTypes/info.js +11 -0
- package/dist/functions/generateTypes/schemas.d.ts +30 -0
- package/dist/functions/generateTypes/schemas.js +14 -0
- package/dist/functions/{getAction.d.ts → getAction/index.d.ts} +2 -6
- package/dist/functions/{getAction.js → getAction/index.js} +6 -5
- package/dist/functions/getAction/info.d.ts +18 -0
- package/dist/functions/getAction/info.js +11 -0
- package/dist/functions/getAction/schemas.d.ts +30 -0
- package/dist/functions/getAction/schemas.js +13 -0
- package/dist/functions/{getApp.d.ts → getApp/index.d.ts} +2 -4
- package/dist/functions/{getApp.js → getApp/index.js} +6 -10
- package/dist/functions/getApp/info.d.ts +12 -0
- package/dist/functions/getApp/info.js +11 -0
- package/dist/functions/getApp/schemas.d.ts +24 -0
- package/dist/functions/getApp/schemas.js +11 -0
- package/dist/functions/{listActions.d.ts → listActions/index.d.ts} +3 -6
- package/dist/functions/{listActions.js → listActions/index.js} +4 -3
- package/dist/functions/listActions/info.d.ts +15 -0
- package/dist/functions/listActions/info.js +11 -0
- package/dist/functions/listActions/schemas.d.ts +27 -0
- package/dist/functions/listActions/schemas.js +14 -0
- package/dist/functions/{listApps.d.ts → listApps/index.d.ts} +2 -6
- package/dist/functions/{listApps.js → listApps/index.js} +1 -1
- package/dist/functions/listApps/info.d.ts +18 -0
- package/dist/functions/listApps/info.js +11 -0
- package/dist/functions/listApps/schemas.d.ts +30 -0
- package/dist/functions/listApps/schemas.js +15 -0
- package/dist/functions/{listAuths.d.ts → listAuthentications/index.d.ts} +3 -9
- package/dist/functions/{listAuths.js → listAuthentications/index.js} +28 -12
- package/dist/functions/listAuthentications/info.d.ts +30 -0
- package/dist/functions/listAuthentications/info.js +11 -0
- package/dist/functions/listAuthentications/schemas.d.ts +42 -0
- package/dist/functions/listAuthentications/schemas.js +25 -0
- package/dist/functions/{listFields.d.ts → listFields/index.d.ts} +3 -9
- package/dist/functions/{listFields.js → listFields/index.js} +8 -10
- package/dist/functions/listFields/info.d.ts +24 -0
- package/dist/functions/listFields/info.js +11 -0
- package/dist/functions/listFields/schemas.d.ts +36 -0
- package/dist/functions/listFields/schemas.js +17 -0
- package/dist/functions/{runAction.d.ts → runAction/index.d.ts} +2 -8
- package/dist/functions/{runAction.js → runAction/index.js} +15 -14
- package/dist/functions/runAction/info.d.ts +24 -0
- package/dist/functions/runAction/info.js +11 -0
- package/dist/functions/runAction/schemas.d.ts +36 -0
- package/dist/functions/runAction/schemas.js +15 -0
- package/dist/index.d.ts +10 -4
- package/dist/index.js +17 -6
- package/dist/plugins/apps/index.d.ts +8 -0
- package/dist/plugins/apps/index.js +77 -0
- package/dist/plugins/apps/info.d.ts +6 -0
- package/dist/plugins/apps/info.js +13 -0
- package/dist/plugins/apps/types.d.ts +21 -0
- package/dist/plugins/apps/types.js +2 -0
- package/dist/resolvers/actionKey.d.ts +8 -0
- package/dist/resolvers/actionKey.js +20 -0
- package/dist/resolvers/actionType.d.ts +8 -0
- package/dist/resolvers/actionType.js +21 -0
- package/dist/resolvers/appKey.d.ts +6 -0
- package/dist/resolvers/appKey.js +8 -0
- package/dist/resolvers/authenticationId.d.ts +8 -0
- package/dist/resolvers/authenticationId.js +29 -0
- package/dist/resolvers/index.d.ts +39 -0
- package/dist/resolvers/index.js +105 -0
- package/dist/resolvers/inputs.d.ts +7 -0
- package/dist/resolvers/inputs.js +15 -0
- package/dist/schema-utils.d.ts +44 -0
- package/dist/schema-utils.js +76 -0
- package/dist/schemas/Action.d.ts +21 -0
- package/dist/schemas/Action.js +31 -0
- package/dist/schemas/App.d.ts +19 -0
- package/dist/schemas/App.js +32 -0
- package/dist/schemas/Auth.d.ts +27 -0
- package/dist/schemas/Auth.js +42 -0
- package/dist/schemas/Field.d.ts +15 -0
- package/dist/schemas/Field.js +25 -0
- package/dist/sdk.d.ts +3 -4
- package/dist/sdk.js +104 -11
- package/dist/types/domain.d.ts +22 -0
- package/dist/types/domain.js +21 -0
- package/dist/types/properties.d.ts +21 -0
- package/dist/types/properties.js +43 -0
- package/dist/types/sdk.d.ts +23 -0
- package/dist/types/sdk.js +2 -0
- package/package.json +4 -2
- package/src/api/auth.ts +28 -0
- package/src/api/client.ts +148 -0
- package/src/api/debug.ts +58 -0
- package/src/api/index.ts +83 -0
- package/src/api/polling.ts +56 -0
- package/src/api/types.ts +177 -0
- package/src/functions/{bundleCode.ts → bundleCode/index.ts} +1 -8
- package/src/functions/bundleCode/info.ts +9 -0
- package/src/functions/bundleCode/schemas.ts +30 -0
- package/src/functions/findFirstAuthentication/index.ts +24 -0
- package/src/functions/findFirstAuthentication/info.ts +9 -0
- package/src/functions/findFirstAuthentication/schemas.ts +60 -0
- package/src/functions/findUniqueAuthentication/index.ts +35 -0
- package/src/functions/findUniqueAuthentication/info.ts +9 -0
- package/src/functions/findUniqueAuthentication/schemas.ts +60 -0
- package/src/functions/{generateTypes.ts → generateTypes/index.ts} +70 -31
- package/src/functions/generateTypes/info.ts +9 -0
- package/src/functions/generateTypes/schemas.ts +38 -0
- package/src/functions/{getAction.ts → getAction/index.ts} +11 -12
- package/src/functions/getAction/info.ts +9 -0
- package/src/functions/getAction/schemas.ts +35 -0
- package/src/functions/{getApp.ts → getApp/index.ts} +9 -15
- package/src/functions/getApp/info.ts +9 -0
- package/src/functions/getApp/schemas.ts +31 -0
- package/src/functions/{listActions.ts → listActions/index.ts} +8 -10
- package/src/functions/listActions/info.ts +9 -0
- package/src/functions/listActions/schemas.ts +40 -0
- package/src/functions/{listApps.ts → listApps/index.ts} +3 -8
- package/src/functions/listApps/info.ts +9 -0
- package/src/functions/listApps/schemas.ts +43 -0
- package/src/functions/{listAuths.ts → listAuthentications/index.ts} +32 -23
- package/src/functions/listAuthentications/info.ts +9 -0
- package/src/functions/listAuthentications/schemas.ts +60 -0
- package/src/functions/{listFields.ts → listFields/index.ts} +11 -20
- package/src/functions/listFields/info.ts +9 -0
- package/src/functions/listFields/schemas.ts +46 -0
- package/src/functions/{runAction.ts → runAction/index.ts} +25 -23
- package/src/functions/runAction/info.ts +9 -0
- package/src/functions/runAction/schemas.ts +41 -0
- package/src/index.ts +19 -5
- package/src/plugins/apps/index.ts +144 -0
- package/src/plugins/apps/info.ts +12 -0
- package/src/plugins/apps/types.ts +34 -0
- package/src/resolvers/actionKey.ts +33 -0
- package/src/resolvers/actionType.ts +30 -0
- package/src/resolvers/appKey.ts +11 -0
- package/src/resolvers/authenticationId.ts +38 -0
- package/src/resolvers/index.ts +117 -0
- package/src/resolvers/inputs.ts +23 -0
- package/src/schema-utils.ts +154 -0
- package/src/schemas/Action.ts +40 -0
- package/src/schemas/App.ts +43 -0
- package/src/schemas/Auth.ts +54 -0
- package/src/schemas/Field.ts +34 -0
- package/src/sdk.ts +165 -19
- package/src/types/domain.ts +54 -0
- package/src/types/properties.ts +67 -0
- package/src/types/sdk.ts +46 -0
- package/dist/actions-sdk.d.ts +0 -47
- package/dist/actions-sdk.js +0 -208
- package/dist/api.d.ts +0 -62
- package/dist/api.js +0 -227
- package/dist/output-schemas.d.ts +0 -95
- package/dist/output-schemas.js +0 -138
- package/dist/schemas.d.ts +0 -338
- package/dist/schemas.js +0 -336
- package/dist/types.js +0 -41
- package/src/actions-sdk.ts +0 -356
- package/src/api.ts +0 -361
- package/src/output-schemas.ts +0 -196
- package/src/schemas.ts +0 -467
- package/src/types.ts +0 -257
- /package/dist/functions/{bundleCode.js → bundleCode/index.js} +0 -0
package/src/output-schemas.ts
DELETED
|
@@ -1,196 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
|
|
3
|
-
// ============================================================================
|
|
4
|
-
// Format Metadata Types
|
|
5
|
-
// ============================================================================
|
|
6
|
-
|
|
7
|
-
export interface FormattedItem {
|
|
8
|
-
title: string;
|
|
9
|
-
subtitle?: string;
|
|
10
|
-
details: Array<{
|
|
11
|
-
text: string;
|
|
12
|
-
style: "normal" | "dim" | "accent" | "warning" | "success";
|
|
13
|
-
}>;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export interface FormatMetadata {
|
|
17
|
-
format: (item: any) => FormattedItem;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
// ============================================================================
|
|
21
|
-
// Schema Enhancement Helpers
|
|
22
|
-
// ============================================================================
|
|
23
|
-
|
|
24
|
-
// Helper function to add format metadata to schemas
|
|
25
|
-
function withFormatter<T extends z.ZodType>(
|
|
26
|
-
schema: T,
|
|
27
|
-
formatMeta: FormatMetadata,
|
|
28
|
-
): T {
|
|
29
|
-
// Store format metadata on the schema definition
|
|
30
|
-
(schema._def as any).formatMeta = formatMeta;
|
|
31
|
-
return schema;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
// Helper function to link input schemas to output schemas
|
|
35
|
-
export function withOutputSchema<T extends z.ZodType>(
|
|
36
|
-
inputSchema: T,
|
|
37
|
-
outputSchema: z.ZodType,
|
|
38
|
-
): T {
|
|
39
|
-
// Store output schema reference on the input schema
|
|
40
|
-
(inputSchema._def as any).outputSchema = outputSchema;
|
|
41
|
-
return inputSchema;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
// Helper function to get format metadata from a schema
|
|
45
|
-
export function getFormatMetadata(
|
|
46
|
-
schema: z.ZodType,
|
|
47
|
-
): FormatMetadata | undefined {
|
|
48
|
-
return (schema._def as any).formatMeta;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
// Helper function to get output schema from an input schema
|
|
52
|
-
export function getOutputSchema(inputSchema: z.ZodType): z.ZodType | undefined {
|
|
53
|
-
return (inputSchema._def as any).outputSchema;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
// ============================================================================
|
|
57
|
-
// Output Item Schemas
|
|
58
|
-
// ============================================================================
|
|
59
|
-
|
|
60
|
-
export const AppItemSchema = withFormatter(
|
|
61
|
-
z.object({
|
|
62
|
-
key: z.string(),
|
|
63
|
-
name: z.string().optional(),
|
|
64
|
-
description: z.string().optional(),
|
|
65
|
-
category: z.string().optional(),
|
|
66
|
-
}),
|
|
67
|
-
{
|
|
68
|
-
format: (item) => {
|
|
69
|
-
const details = [];
|
|
70
|
-
if (item.description) {
|
|
71
|
-
details.push({ text: item.description, style: "dim" as const });
|
|
72
|
-
}
|
|
73
|
-
if (item.category) {
|
|
74
|
-
details.push({
|
|
75
|
-
text: `Category: ${item.category}`,
|
|
76
|
-
style: "accent" as const,
|
|
77
|
-
});
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
return {
|
|
81
|
-
title: item.name || item.key,
|
|
82
|
-
subtitle: `(${item.key})`,
|
|
83
|
-
details,
|
|
84
|
-
};
|
|
85
|
-
},
|
|
86
|
-
},
|
|
87
|
-
);
|
|
88
|
-
|
|
89
|
-
export const ActionItemSchema = withFormatter(
|
|
90
|
-
z.object({
|
|
91
|
-
key: z.string(),
|
|
92
|
-
name: z.string().optional(),
|
|
93
|
-
type: z.string(),
|
|
94
|
-
appKey: z.string().optional(),
|
|
95
|
-
description: z.string().optional(),
|
|
96
|
-
}),
|
|
97
|
-
{
|
|
98
|
-
format: (item) => {
|
|
99
|
-
const details = [];
|
|
100
|
-
details.push({ text: `Type: ${item.type}`, style: "accent" as const });
|
|
101
|
-
if (item.appKey) {
|
|
102
|
-
details.push({ text: `App: ${item.appKey}`, style: "normal" as const });
|
|
103
|
-
}
|
|
104
|
-
if (item.description) {
|
|
105
|
-
details.push({ text: item.description, style: "dim" as const });
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
return {
|
|
109
|
-
title: item.name || item.key,
|
|
110
|
-
subtitle: `(${item.key})`,
|
|
111
|
-
details,
|
|
112
|
-
};
|
|
113
|
-
},
|
|
114
|
-
},
|
|
115
|
-
);
|
|
116
|
-
|
|
117
|
-
export const AuthItemSchema = withFormatter(
|
|
118
|
-
z.object({
|
|
119
|
-
id: z.number(),
|
|
120
|
-
title: z.string().optional(),
|
|
121
|
-
label: z.string().optional(),
|
|
122
|
-
identifier: z.string().optional(),
|
|
123
|
-
account_id: z.string().optional(),
|
|
124
|
-
is_private: z.boolean().optional(),
|
|
125
|
-
shared_with_all: z.boolean().optional(),
|
|
126
|
-
marked_stale_at: z.string().optional(),
|
|
127
|
-
}),
|
|
128
|
-
{
|
|
129
|
-
format: (item) => {
|
|
130
|
-
const details = [];
|
|
131
|
-
|
|
132
|
-
if (item.identifier) {
|
|
133
|
-
details.push({
|
|
134
|
-
text: `Identifier: ${item.identifier}`,
|
|
135
|
-
style: "accent" as const,
|
|
136
|
-
});
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
if (item.label && item.title && item.label !== item.title) {
|
|
140
|
-
details.push({
|
|
141
|
-
text: `Label: ${item.label}`,
|
|
142
|
-
style: "normal" as const,
|
|
143
|
-
});
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
details.push({
|
|
147
|
-
text: `Account: ${item.account_id || "unknown"} | Private: ${item.is_private || false} | Shared: ${item.shared_with_all || false}`,
|
|
148
|
-
style: "dim" as const,
|
|
149
|
-
});
|
|
150
|
-
|
|
151
|
-
if (item.marked_stale_at) {
|
|
152
|
-
details.push({
|
|
153
|
-
text: `⚠️ Marked stale: ${new Date(item.marked_stale_at).toLocaleDateString()}`,
|
|
154
|
-
style: "warning" as const,
|
|
155
|
-
});
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
return {
|
|
159
|
-
title: item.title || item.label || `Authentication ${item.id}`,
|
|
160
|
-
subtitle: `(ID: ${item.id})`,
|
|
161
|
-
details,
|
|
162
|
-
};
|
|
163
|
-
},
|
|
164
|
-
},
|
|
165
|
-
);
|
|
166
|
-
|
|
167
|
-
export const FieldItemSchema = withFormatter(
|
|
168
|
-
z.object({
|
|
169
|
-
key: z.string(),
|
|
170
|
-
name: z.string().optional(),
|
|
171
|
-
description: z.string().optional(),
|
|
172
|
-
}),
|
|
173
|
-
{
|
|
174
|
-
format: (item) => {
|
|
175
|
-
const details = [];
|
|
176
|
-
if (item.description) {
|
|
177
|
-
details.push({ text: item.description, style: "dim" as const });
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
return {
|
|
181
|
-
title: item.name || item.key,
|
|
182
|
-
subtitle: `(${item.key})`,
|
|
183
|
-
details,
|
|
184
|
-
};
|
|
185
|
-
},
|
|
186
|
-
},
|
|
187
|
-
);
|
|
188
|
-
|
|
189
|
-
// ============================================================================
|
|
190
|
-
// Type Exports
|
|
191
|
-
// ============================================================================
|
|
192
|
-
|
|
193
|
-
export type AppItem = z.infer<typeof AppItemSchema>;
|
|
194
|
-
export type ActionItem = z.infer<typeof ActionItemSchema>;
|
|
195
|
-
export type AuthItem = z.infer<typeof AuthItemSchema>;
|
|
196
|
-
export type FieldItem = z.infer<typeof FieldItemSchema>;
|
package/src/schemas.ts
DELETED
|
@@ -1,467 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
import {
|
|
3
|
-
withOutputSchema,
|
|
4
|
-
AppItemSchema,
|
|
5
|
-
ActionItemSchema,
|
|
6
|
-
AuthItemSchema,
|
|
7
|
-
FieldItemSchema,
|
|
8
|
-
} from "./output-schemas";
|
|
9
|
-
|
|
10
|
-
// ============================================================================
|
|
11
|
-
// Resolution Metadata Types
|
|
12
|
-
// ============================================================================
|
|
13
|
-
|
|
14
|
-
export interface StaticResolver {
|
|
15
|
-
type: "static";
|
|
16
|
-
inputType?: "input" | "password" | "editor";
|
|
17
|
-
placeholder?: string;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export interface DynamicResolver {
|
|
21
|
-
type: "dynamic";
|
|
22
|
-
fetch: (sdk: any, resolvedParams: any) => Promise<any[]>; // Function to fetch data using SDK
|
|
23
|
-
prompt: (items: any[], params: any) => any;
|
|
24
|
-
depends?: string[]; // Parameters this resolver depends on
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export interface FieldsResolver {
|
|
28
|
-
type: "fields";
|
|
29
|
-
fetch: (sdk: any, resolvedParams: any) => Promise<any[]>; // Function to fetch field definitions using sdk.fields.list
|
|
30
|
-
depends?: string[]; // Parameters this resolver depends on
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
export interface ResolverMetadata {
|
|
34
|
-
resolver?: StaticResolver | DynamicResolver | FieldsResolver;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
// Helper function to add resolver metadata to schemas
|
|
38
|
-
function withResolver<T extends z.ZodType>(
|
|
39
|
-
schema: T,
|
|
40
|
-
meta: ResolverMetadata,
|
|
41
|
-
): T {
|
|
42
|
-
// Store resolver metadata on the schema definition
|
|
43
|
-
(schema._def as any).resolverMeta = meta;
|
|
44
|
-
return schema;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
// ============================================================================
|
|
48
|
-
// Base Schemas
|
|
49
|
-
// ============================================================================
|
|
50
|
-
|
|
51
|
-
const PaginationSchema = z.object({
|
|
52
|
-
limit: z
|
|
53
|
-
.number()
|
|
54
|
-
.int()
|
|
55
|
-
.min(1)
|
|
56
|
-
.max(200)
|
|
57
|
-
.optional()
|
|
58
|
-
.describe("Maximum number of items to return (1-200)"),
|
|
59
|
-
offset: z
|
|
60
|
-
.number()
|
|
61
|
-
.int()
|
|
62
|
-
.min(0)
|
|
63
|
-
.optional()
|
|
64
|
-
.describe("Number of items to skip for pagination"),
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
// ============================================================================
|
|
68
|
-
// Apps Service Schemas
|
|
69
|
-
// ============================================================================
|
|
70
|
-
|
|
71
|
-
export const AppsListSchema = withOutputSchema(
|
|
72
|
-
z
|
|
73
|
-
.object({
|
|
74
|
-
category: z
|
|
75
|
-
.string()
|
|
76
|
-
.optional()
|
|
77
|
-
.describe(
|
|
78
|
-
"Filter apps by category (e.g., 'productivity', 'crm', 'hr')",
|
|
79
|
-
),
|
|
80
|
-
...PaginationSchema.shape,
|
|
81
|
-
})
|
|
82
|
-
.describe("List available apps with optional filtering"),
|
|
83
|
-
AppItemSchema,
|
|
84
|
-
);
|
|
85
|
-
|
|
86
|
-
export const AppsGetSchema = z
|
|
87
|
-
.object({
|
|
88
|
-
key: z
|
|
89
|
-
.string()
|
|
90
|
-
.min(1)
|
|
91
|
-
.describe(
|
|
92
|
-
"The unique app key/slug (e.g., 'slack', 'github', '100hires-ats')",
|
|
93
|
-
),
|
|
94
|
-
})
|
|
95
|
-
.describe("Get detailed information about a specific app");
|
|
96
|
-
|
|
97
|
-
// ============================================================================
|
|
98
|
-
// Shared Parameter Schemas
|
|
99
|
-
// ============================================================================
|
|
100
|
-
|
|
101
|
-
// Shared app parameter with resolver
|
|
102
|
-
const AppParameterSchema = withResolver(
|
|
103
|
-
z.string().min(1).describe("App slug (e.g., 'slack', 'github')"),
|
|
104
|
-
{
|
|
105
|
-
resolver: {
|
|
106
|
-
type: "static",
|
|
107
|
-
},
|
|
108
|
-
},
|
|
109
|
-
);
|
|
110
|
-
|
|
111
|
-
// Shared type parameter with resolver that depends on app
|
|
112
|
-
const ActionTypeParameterSchema = withResolver(
|
|
113
|
-
z
|
|
114
|
-
.enum(["read", "write", "search", "create", "update", "delete"])
|
|
115
|
-
.describe("Action type that matches the action's defined type"),
|
|
116
|
-
{
|
|
117
|
-
resolver: {
|
|
118
|
-
type: "dynamic",
|
|
119
|
-
depends: ["app"],
|
|
120
|
-
fetch: async (sdk: any, resolvedParams: any) => {
|
|
121
|
-
const actions = await sdk.actions.list({ appKey: resolvedParams.app });
|
|
122
|
-
const types = [...new Set(actions.map((action: any) => action.type))];
|
|
123
|
-
return types.map((type) => ({ key: type, name: type }));
|
|
124
|
-
},
|
|
125
|
-
prompt: (types: any[]) => ({
|
|
126
|
-
type: "list",
|
|
127
|
-
name: "type",
|
|
128
|
-
message: "Select action type:",
|
|
129
|
-
choices: types.map((type) => ({
|
|
130
|
-
name: type.name,
|
|
131
|
-
value: type.key,
|
|
132
|
-
})),
|
|
133
|
-
}),
|
|
134
|
-
},
|
|
135
|
-
},
|
|
136
|
-
);
|
|
137
|
-
|
|
138
|
-
// Shared action parameter with resolver that depends on app and type
|
|
139
|
-
const ActionParameterSchema = withResolver(
|
|
140
|
-
z.string().min(1).describe("Action key to execute"),
|
|
141
|
-
{
|
|
142
|
-
resolver: {
|
|
143
|
-
type: "dynamic",
|
|
144
|
-
depends: ["app", "type"],
|
|
145
|
-
fetch: async (sdk: any, resolvedParams: any) => {
|
|
146
|
-
const actions = await sdk.actions.list({ appKey: resolvedParams.app });
|
|
147
|
-
return actions.filter(
|
|
148
|
-
(action: any) => action.type === resolvedParams.type,
|
|
149
|
-
);
|
|
150
|
-
},
|
|
151
|
-
prompt: (actions: any[]) => ({
|
|
152
|
-
type: "list",
|
|
153
|
-
name: "action",
|
|
154
|
-
message: "Select action:",
|
|
155
|
-
choices: actions.map((action) => ({
|
|
156
|
-
name: `${action.name || action.key} - ${
|
|
157
|
-
action.description || "No description"
|
|
158
|
-
}`,
|
|
159
|
-
value: action.key,
|
|
160
|
-
})),
|
|
161
|
-
}),
|
|
162
|
-
},
|
|
163
|
-
},
|
|
164
|
-
);
|
|
165
|
-
|
|
166
|
-
// Shared authId parameter with resolver that depends on app
|
|
167
|
-
const AuthIdParameterSchema = withResolver(
|
|
168
|
-
z
|
|
169
|
-
.number()
|
|
170
|
-
.int()
|
|
171
|
-
.optional()
|
|
172
|
-
.describe("Authentication ID to use for this action"),
|
|
173
|
-
{
|
|
174
|
-
resolver: {
|
|
175
|
-
type: "dynamic",
|
|
176
|
-
depends: ["app"],
|
|
177
|
-
fetch: async (sdk: any, resolvedParams: any) => {
|
|
178
|
-
// Get auths for the specific app (owned auths will be prioritized automatically)
|
|
179
|
-
return await sdk.auths.list({
|
|
180
|
-
appKey: resolvedParams.app,
|
|
181
|
-
limit: 1000,
|
|
182
|
-
});
|
|
183
|
-
},
|
|
184
|
-
prompt: (auths: any[], params: any) => ({
|
|
185
|
-
type: "list",
|
|
186
|
-
name: "authId",
|
|
187
|
-
message: `Select authentication for ${params.app}:`,
|
|
188
|
-
choices: [
|
|
189
|
-
...auths.map((auth) => ({
|
|
190
|
-
name: `${auth.title || auth.label || "Authentication"} (ID: ${auth.id})`,
|
|
191
|
-
value: auth.id,
|
|
192
|
-
})),
|
|
193
|
-
{
|
|
194
|
-
name: "↗ Skip authentication (may fail)",
|
|
195
|
-
value: null,
|
|
196
|
-
},
|
|
197
|
-
],
|
|
198
|
-
}),
|
|
199
|
-
},
|
|
200
|
-
},
|
|
201
|
-
);
|
|
202
|
-
|
|
203
|
-
// ============================================================================
|
|
204
|
-
// Fields Service Schemas
|
|
205
|
-
// ============================================================================
|
|
206
|
-
|
|
207
|
-
export const FieldsListSchema = withOutputSchema(
|
|
208
|
-
z
|
|
209
|
-
.object({
|
|
210
|
-
app: AppParameterSchema,
|
|
211
|
-
type: ActionTypeParameterSchema,
|
|
212
|
-
action: ActionParameterSchema,
|
|
213
|
-
authId: AuthIdParameterSchema,
|
|
214
|
-
params: z
|
|
215
|
-
.record(z.any())
|
|
216
|
-
.optional()
|
|
217
|
-
.describe("Additional parameters that may affect available fields"),
|
|
218
|
-
})
|
|
219
|
-
.describe("Get the input fields required for a specific action"),
|
|
220
|
-
FieldItemSchema,
|
|
221
|
-
);
|
|
222
|
-
|
|
223
|
-
// ============================================================================
|
|
224
|
-
// Actions Service Schemas
|
|
225
|
-
// ============================================================================
|
|
226
|
-
|
|
227
|
-
export const ActionsListSchema = withOutputSchema(
|
|
228
|
-
z
|
|
229
|
-
.object({
|
|
230
|
-
appKey: withResolver(
|
|
231
|
-
z
|
|
232
|
-
.string()
|
|
233
|
-
.min(1)
|
|
234
|
-
.describe("App slug to get actions for (e.g., 'slack', 'github')"),
|
|
235
|
-
{
|
|
236
|
-
resolver: {
|
|
237
|
-
type: "static",
|
|
238
|
-
},
|
|
239
|
-
},
|
|
240
|
-
),
|
|
241
|
-
type: z
|
|
242
|
-
.enum(["read", "write", "search", "create", "update", "delete"])
|
|
243
|
-
.optional()
|
|
244
|
-
.describe("Filter actions by type"),
|
|
245
|
-
})
|
|
246
|
-
.describe("List all actions for a specific app"),
|
|
247
|
-
ActionItemSchema,
|
|
248
|
-
);
|
|
249
|
-
|
|
250
|
-
export const ActionsGetSchema = z
|
|
251
|
-
.object({
|
|
252
|
-
app: AppParameterSchema,
|
|
253
|
-
type: ActionTypeParameterSchema,
|
|
254
|
-
action: ActionParameterSchema,
|
|
255
|
-
})
|
|
256
|
-
.describe("Get detailed information about a specific action");
|
|
257
|
-
|
|
258
|
-
export const ActionsRunSchema = z
|
|
259
|
-
.object({
|
|
260
|
-
app: AppParameterSchema,
|
|
261
|
-
type: ActionTypeParameterSchema,
|
|
262
|
-
action: ActionParameterSchema,
|
|
263
|
-
inputs: withResolver(
|
|
264
|
-
z
|
|
265
|
-
.record(z.any())
|
|
266
|
-
.optional()
|
|
267
|
-
.describe("Input parameters for the action as key-value pairs"),
|
|
268
|
-
{
|
|
269
|
-
resolver: {
|
|
270
|
-
type: "fields",
|
|
271
|
-
depends: ["app", "action", "type", "authId"],
|
|
272
|
-
fetch: async (sdk: any, resolvedParams: any) => {
|
|
273
|
-
return await sdk.fields.list({
|
|
274
|
-
app: resolvedParams.app,
|
|
275
|
-
action: resolvedParams.action,
|
|
276
|
-
type: resolvedParams.type,
|
|
277
|
-
authId: resolvedParams.authId,
|
|
278
|
-
});
|
|
279
|
-
},
|
|
280
|
-
},
|
|
281
|
-
},
|
|
282
|
-
),
|
|
283
|
-
authId: AuthIdParameterSchema,
|
|
284
|
-
})
|
|
285
|
-
.describe("Execute an action on a specific app");
|
|
286
|
-
|
|
287
|
-
// ============================================================================
|
|
288
|
-
// Auths Service Schemas
|
|
289
|
-
// ============================================================================
|
|
290
|
-
|
|
291
|
-
export const AuthsListSchema = withOutputSchema(
|
|
292
|
-
z
|
|
293
|
-
.object({
|
|
294
|
-
appKey: withResolver(
|
|
295
|
-
z
|
|
296
|
-
.string()
|
|
297
|
-
.min(1)
|
|
298
|
-
.describe(
|
|
299
|
-
"App slug to get authentications for (e.g., 'slack', 'github')",
|
|
300
|
-
),
|
|
301
|
-
{
|
|
302
|
-
resolver: {
|
|
303
|
-
type: "static",
|
|
304
|
-
},
|
|
305
|
-
},
|
|
306
|
-
),
|
|
307
|
-
account_id: z.string().optional().describe("Filter by account ID"),
|
|
308
|
-
owner: z.string().optional().describe("Filter by owner"),
|
|
309
|
-
...PaginationSchema.shape,
|
|
310
|
-
})
|
|
311
|
-
.describe("List available authentications with optional filtering"),
|
|
312
|
-
AuthItemSchema,
|
|
313
|
-
);
|
|
314
|
-
|
|
315
|
-
export const AuthsFindSchema = z
|
|
316
|
-
.object({
|
|
317
|
-
appKey: z.string().min(1).describe("App key to find authentication for"),
|
|
318
|
-
})
|
|
319
|
-
.describe("Find the authentication ID for a specific app");
|
|
320
|
-
|
|
321
|
-
// ============================================================================
|
|
322
|
-
// Root Tools Schemas
|
|
323
|
-
// ============================================================================
|
|
324
|
-
|
|
325
|
-
export const GenerateSchema = z
|
|
326
|
-
.object({
|
|
327
|
-
appKey: withResolver(
|
|
328
|
-
z.string().min(1).describe("App key to generate SDK code for"),
|
|
329
|
-
{
|
|
330
|
-
resolver: {
|
|
331
|
-
type: "static",
|
|
332
|
-
},
|
|
333
|
-
},
|
|
334
|
-
),
|
|
335
|
-
token: z
|
|
336
|
-
.string()
|
|
337
|
-
.optional()
|
|
338
|
-
.describe("Zapier API token (defaults to ZAPIER_TOKEN env var)"),
|
|
339
|
-
authId: withResolver(
|
|
340
|
-
z.number().int().optional().describe("Authentication ID to use"),
|
|
341
|
-
{
|
|
342
|
-
resolver: {
|
|
343
|
-
type: "dynamic",
|
|
344
|
-
depends: ["appKey"],
|
|
345
|
-
fetch: async (sdk: any, resolvedParams: any) => {
|
|
346
|
-
// Get auths for the specific app (owned auths will be prioritized automatically)
|
|
347
|
-
return await sdk.auths.list({
|
|
348
|
-
appKey: resolvedParams.appKey,
|
|
349
|
-
limit: 1000,
|
|
350
|
-
});
|
|
351
|
-
},
|
|
352
|
-
prompt: (auths: any[], params: any) => ({
|
|
353
|
-
type: "list",
|
|
354
|
-
name: "authId",
|
|
355
|
-
message: `Select authentication for ${params.appKey}:`,
|
|
356
|
-
choices: [
|
|
357
|
-
...auths.map((auth) => ({
|
|
358
|
-
name: `${auth.title || auth.label || "Authentication"} (ID: ${auth.id})`,
|
|
359
|
-
value: auth.id,
|
|
360
|
-
})),
|
|
361
|
-
{
|
|
362
|
-
name: "↗ Skip authentication (may fail)",
|
|
363
|
-
value: null,
|
|
364
|
-
},
|
|
365
|
-
],
|
|
366
|
-
}),
|
|
367
|
-
},
|
|
368
|
-
},
|
|
369
|
-
),
|
|
370
|
-
output: z
|
|
371
|
-
.string()
|
|
372
|
-
.optional()
|
|
373
|
-
.describe("Output file path (defaults to generated/<appKey>.ts)"),
|
|
374
|
-
debug: z
|
|
375
|
-
.boolean()
|
|
376
|
-
.default(false)
|
|
377
|
-
.describe("Enable debug logging during generation"),
|
|
378
|
-
})
|
|
379
|
-
.describe("Generate TypeScript SDK code for a specific app");
|
|
380
|
-
|
|
381
|
-
export const BundleSchema = z
|
|
382
|
-
.object({
|
|
383
|
-
input: z.string().min(1).describe("Input TypeScript file path to bundle"),
|
|
384
|
-
output: z
|
|
385
|
-
.string()
|
|
386
|
-
.optional()
|
|
387
|
-
.describe("Output file path (defaults to input with .js extension)"),
|
|
388
|
-
string: z
|
|
389
|
-
.boolean()
|
|
390
|
-
.default(false)
|
|
391
|
-
.describe("Return bundled code as string instead of writing to file"),
|
|
392
|
-
minify: z.boolean().default(false).describe("Minify the bundled output"),
|
|
393
|
-
target: z.string().default("es2020").describe("ECMAScript target version"),
|
|
394
|
-
cjs: z
|
|
395
|
-
.boolean()
|
|
396
|
-
.default(false)
|
|
397
|
-
.describe("Output CommonJS format instead of ESM"),
|
|
398
|
-
})
|
|
399
|
-
.describe("Bundle TypeScript code into executable JavaScript");
|
|
400
|
-
|
|
401
|
-
// ============================================================================
|
|
402
|
-
// SDK Schema Collection
|
|
403
|
-
// ============================================================================
|
|
404
|
-
|
|
405
|
-
export const SdkSchemas = {
|
|
406
|
-
apps: {
|
|
407
|
-
list: AppsListSchema,
|
|
408
|
-
get: AppsGetSchema,
|
|
409
|
-
},
|
|
410
|
-
actions: {
|
|
411
|
-
list: ActionsListSchema,
|
|
412
|
-
get: ActionsGetSchema,
|
|
413
|
-
run: ActionsRunSchema,
|
|
414
|
-
},
|
|
415
|
-
auths: {
|
|
416
|
-
list: AuthsListSchema,
|
|
417
|
-
find: AuthsFindSchema,
|
|
418
|
-
},
|
|
419
|
-
fields: {
|
|
420
|
-
list: FieldsListSchema,
|
|
421
|
-
},
|
|
422
|
-
// Root namespace tools
|
|
423
|
-
generate: GenerateSchema,
|
|
424
|
-
bundle: BundleSchema,
|
|
425
|
-
} as const;
|
|
426
|
-
|
|
427
|
-
// ============================================================================
|
|
428
|
-
// Inferred Types
|
|
429
|
-
// ============================================================================
|
|
430
|
-
|
|
431
|
-
export type AppsListOptions = z.infer<typeof AppsListSchema>;
|
|
432
|
-
export type AppsGetOptions = z.infer<typeof AppsGetSchema>;
|
|
433
|
-
|
|
434
|
-
export type ActionsListOptions = z.infer<typeof ActionsListSchema>;
|
|
435
|
-
export type ActionsGetOptions = z.infer<typeof ActionsGetSchema>;
|
|
436
|
-
export type ActionsRunOptions = z.infer<typeof ActionsRunSchema>;
|
|
437
|
-
|
|
438
|
-
export type AuthsListOptions = z.infer<typeof AuthsListSchema>;
|
|
439
|
-
export type AuthsFindOptions = z.infer<typeof AuthsFindSchema>;
|
|
440
|
-
|
|
441
|
-
export type FieldsListOptions = z.infer<typeof FieldsListSchema>;
|
|
442
|
-
|
|
443
|
-
export type GenerateOptions = z.infer<typeof GenerateSchema>;
|
|
444
|
-
export type BundleOptions = z.infer<typeof BundleSchema>;
|
|
445
|
-
|
|
446
|
-
// ============================================================================
|
|
447
|
-
// Schema Utilities
|
|
448
|
-
// ============================================================================
|
|
449
|
-
|
|
450
|
-
export function getSchemaDescription(schema: z.ZodSchema): string | undefined {
|
|
451
|
-
return schema.description;
|
|
452
|
-
}
|
|
453
|
-
|
|
454
|
-
export function getFieldDescriptions(
|
|
455
|
-
schema: z.ZodObject<any>,
|
|
456
|
-
): Record<string, string> {
|
|
457
|
-
const descriptions: Record<string, string> = {};
|
|
458
|
-
const shape = schema.shape;
|
|
459
|
-
|
|
460
|
-
for (const [key, fieldSchema] of Object.entries(shape)) {
|
|
461
|
-
if (fieldSchema instanceof z.ZodType && fieldSchema.description) {
|
|
462
|
-
descriptions[key] = fieldSchema.description;
|
|
463
|
-
}
|
|
464
|
-
}
|
|
465
|
-
|
|
466
|
-
return descriptions;
|
|
467
|
-
}
|