@zapier/zapier-sdk 0.12.0 → 0.12.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/CHANGELOG.md +6 -0
- package/README.md +207 -60
- package/dist/index.cjs +66 -27
- package/dist/index.d.mts +19 -7
- package/dist/index.mjs +66 -27
- package/dist/plugins/apps/index.d.ts +2 -2
- package/dist/plugins/apps/index.d.ts.map +1 -1
- package/dist/plugins/apps/index.js +21 -0
- package/dist/plugins/apps/schemas.d.ts +43 -0
- package/dist/plugins/apps/schemas.d.ts.map +1 -0
- package/dist/plugins/apps/schemas.js +13 -0
- package/dist/plugins/registry/index.d.ts.map +1 -1
- package/dist/plugins/registry/index.js +12 -1
- package/dist/types/sdk.d.ts +1 -1
- package/dist/types/sdk.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/plugins/apps/index.ts +28 -7
- package/src/plugins/apps/{types.ts → schemas.ts} +20 -8
- package/src/plugins/registry/index.ts +12 -1
- package/src/types/sdk.ts +1 -1
- package/tsconfig.tsbuildinfo +1 -1
- package/dist/plugins/apps/types.d.ts +0 -30
- package/dist/plugins/apps/types.d.ts.map +0 -1
- package/dist/plugins/apps/types.js +0 -2
package/dist/index.mjs
CHANGED
|
@@ -190,6 +190,40 @@ HTTP Status: ${error.statusCode}`;
|
|
|
190
190
|
}
|
|
191
191
|
return message;
|
|
192
192
|
}
|
|
193
|
+
var ActionExecutionInputSchema = z.object({
|
|
194
|
+
inputs: z.record(z.unknown()).optional(),
|
|
195
|
+
authenticationId: z.number().optional()
|
|
196
|
+
}).describe(
|
|
197
|
+
"Execute an action with the given inputs for the bound app, as an alternative to runAction"
|
|
198
|
+
);
|
|
199
|
+
var AppFactoryInputSchema = z.object({
|
|
200
|
+
authenticationId: z.number()
|
|
201
|
+
}).describe("Bind an authentication ID to an app");
|
|
202
|
+
function getStringProperty(obj, key) {
|
|
203
|
+
if (typeof obj === "object" && obj !== null && key in obj) {
|
|
204
|
+
const value = obj[key];
|
|
205
|
+
return typeof value === "string" ? value : void 0;
|
|
206
|
+
}
|
|
207
|
+
return void 0;
|
|
208
|
+
}
|
|
209
|
+
function formatActionResult(item) {
|
|
210
|
+
const obj = typeof item === "object" && item !== null ? item : {};
|
|
211
|
+
const title = getStringProperty(obj, "title") || getStringProperty(obj, "name") || getStringProperty(obj, "label") || getStringProperty(obj, "subject") || "Action Result";
|
|
212
|
+
return {
|
|
213
|
+
title,
|
|
214
|
+
id: getStringProperty(obj, "id"),
|
|
215
|
+
key: getStringProperty(obj, "key"),
|
|
216
|
+
description: getStringProperty(obj, "description"),
|
|
217
|
+
data: item,
|
|
218
|
+
// Let formatJsonOutput handle the JSON rendering
|
|
219
|
+
details: []
|
|
220
|
+
// Not used when data is provided
|
|
221
|
+
};
|
|
222
|
+
}
|
|
223
|
+
var ActionResultItemSchema = withFormatter(
|
|
224
|
+
z.unknown().describe("Action execution result"),
|
|
225
|
+
{ format: formatActionResult }
|
|
226
|
+
);
|
|
193
227
|
|
|
194
228
|
// src/plugins/apps/index.ts
|
|
195
229
|
function createActionFunction(appKey, actionType, actionKey, options, pinnedAuthId) {
|
|
@@ -293,7 +327,26 @@ function createAppsProxy(options) {
|
|
|
293
327
|
}
|
|
294
328
|
var appsPlugin = ({ sdk }) => {
|
|
295
329
|
return {
|
|
296
|
-
apps: createAppsProxy({ sdk })
|
|
330
|
+
apps: createAppsProxy({ sdk }),
|
|
331
|
+
context: {
|
|
332
|
+
meta: {
|
|
333
|
+
"apps.{appKey}": {
|
|
334
|
+
categories: ["app"],
|
|
335
|
+
packages: ["sdk"],
|
|
336
|
+
type: "function",
|
|
337
|
+
inputSchema: AppFactoryInputSchema,
|
|
338
|
+
returnType: "AppProxy"
|
|
339
|
+
},
|
|
340
|
+
"apps.{appKey}.{actionType}.{actionKey}": {
|
|
341
|
+
categories: ["app"],
|
|
342
|
+
packages: ["sdk"],
|
|
343
|
+
type: "list",
|
|
344
|
+
inputSchema: ActionExecutionInputSchema,
|
|
345
|
+
itemType: "ActionResult",
|
|
346
|
+
outputSchema: ActionResultItemSchema
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
}
|
|
297
350
|
};
|
|
298
351
|
};
|
|
299
352
|
var FetchUrlSchema = z.union([z.string(), z.instanceof(URL)]).describe("The URL to fetch");
|
|
@@ -2259,31 +2312,6 @@ var RunActionSchema = z.object({
|
|
|
2259
2312
|
pageSize: z.number().min(1).optional().describe("Number of results per page"),
|
|
2260
2313
|
maxItems: z.number().min(1).optional().describe("Maximum total items to return across all pages")
|
|
2261
2314
|
}).describe("Execute an action with the given inputs");
|
|
2262
|
-
function getStringProperty(obj, key) {
|
|
2263
|
-
if (typeof obj === "object" && obj !== null && key in obj) {
|
|
2264
|
-
const value = obj[key];
|
|
2265
|
-
return typeof value === "string" ? value : void 0;
|
|
2266
|
-
}
|
|
2267
|
-
return void 0;
|
|
2268
|
-
}
|
|
2269
|
-
function formatActionResult(item) {
|
|
2270
|
-
const obj = typeof item === "object" && item !== null ? item : {};
|
|
2271
|
-
const title = getStringProperty(obj, "title") || getStringProperty(obj, "name") || getStringProperty(obj, "label") || getStringProperty(obj, "subject") || "Action Result";
|
|
2272
|
-
return {
|
|
2273
|
-
title,
|
|
2274
|
-
id: getStringProperty(obj, "id"),
|
|
2275
|
-
key: getStringProperty(obj, "key"),
|
|
2276
|
-
description: getStringProperty(obj, "description"),
|
|
2277
|
-
data: item,
|
|
2278
|
-
// Let formatJsonOutput handle the JSON rendering
|
|
2279
|
-
details: []
|
|
2280
|
-
// Not used when data is provided
|
|
2281
|
-
};
|
|
2282
|
-
}
|
|
2283
|
-
var ActionResultItemSchema = withFormatter(
|
|
2284
|
-
z.unknown().describe("Action execution result"),
|
|
2285
|
-
{ format: formatActionResult }
|
|
2286
|
-
);
|
|
2287
2315
|
|
|
2288
2316
|
// src/plugins/runAction/index.ts
|
|
2289
2317
|
async function executeAction(actionOptions) {
|
|
@@ -3515,7 +3543,18 @@ var registryPlugin = ({ sdk, context }) => {
|
|
|
3515
3543
|
title: "Other"
|
|
3516
3544
|
}
|
|
3517
3545
|
};
|
|
3518
|
-
const functions = metaKeys.filter((key) =>
|
|
3546
|
+
const functions = metaKeys.filter((key) => {
|
|
3547
|
+
const property = sdk[key];
|
|
3548
|
+
if (typeof property === "function") {
|
|
3549
|
+
return true;
|
|
3550
|
+
}
|
|
3551
|
+
const [rootKey] = key.split(".");
|
|
3552
|
+
const rootProperty = sdk[rootKey];
|
|
3553
|
+
if (typeof rootProperty === "object" && rootProperty !== null) {
|
|
3554
|
+
return true;
|
|
3555
|
+
}
|
|
3556
|
+
return false;
|
|
3557
|
+
}).map((key) => {
|
|
3519
3558
|
const meta = context.meta[key];
|
|
3520
3559
|
return {
|
|
3521
3560
|
name: key,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ActionProxy } from "./
|
|
1
|
+
import type { ActionProxy } from "./schemas";
|
|
2
2
|
import type { Plugin, GetSdkType } from "../../types/plugin";
|
|
3
3
|
import type { FetchPluginProvides } from "../fetch/index";
|
|
4
4
|
import type { RunActionPluginProvides } from "../runAction/index";
|
|
@@ -8,7 +8,7 @@ export interface AppsPluginProvides {
|
|
|
8
8
|
export declare const appsPlugin: Plugin<GetSdkType<FetchPluginProvides & RunActionPluginProvides>, // requires fetch + runAction in SDK
|
|
9
9
|
{}, // no context requirements
|
|
10
10
|
AppsPluginProvides>;
|
|
11
|
-
export type { ActionExecutionOptions } from "./
|
|
11
|
+
export type { ActionExecutionOptions } from "./schemas";
|
|
12
12
|
export type { ActionExecutionResult } from "../../api/types";
|
|
13
13
|
export interface ZapierSdkApps {
|
|
14
14
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/apps/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/apps/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,WAAW,EAEZ,MAAM,WAAW,CAAC;AAGnB,OAAO,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAC7D,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAC1D,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,oBAAoB,CAAC;AAGlE,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,WAAW,CAAC;CACnB;AAwJD,eAAO,MAAM,UAAU,EAAE,MAAM,CAC7B,UAAU,CAAC,mBAAmB,GAAG,uBAAuB,CAAC,EAAE,oCAAoC;AAC/F,EAAE,EAAE,0BAA0B;AAC9B,kBAAkB,CAyBnB,CAAC;AAGF,YAAY,EAAE,sBAAsB,EAAE,MAAM,WAAW,CAAC;AACxD,YAAY,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AAI7D,MAAM,WAAW,aAAa;CAAG"}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
import { ActionExecutionInputSchema, AppFactoryInputSchema } from "./schemas";
|
|
1
2
|
import { ZapierValidationError } from "../../types/errors";
|
|
3
|
+
import { ActionResultItemSchema } from "../../schemas/Run";
|
|
2
4
|
function createActionFunction(appKey, actionType, actionKey, options, pinnedAuthId) {
|
|
3
5
|
return (actionOptions = {}) => {
|
|
4
6
|
const { sdk } = options;
|
|
@@ -87,5 +89,24 @@ export const appsPlugin = ({ sdk }) => {
|
|
|
87
89
|
// Return flat structure - apps goes directly to SDK
|
|
88
90
|
return {
|
|
89
91
|
apps: createAppsProxy({ sdk }),
|
|
92
|
+
context: {
|
|
93
|
+
meta: {
|
|
94
|
+
"apps.{appKey}": {
|
|
95
|
+
categories: ["app"],
|
|
96
|
+
packages: ["sdk"],
|
|
97
|
+
type: "function",
|
|
98
|
+
inputSchema: AppFactoryInputSchema,
|
|
99
|
+
returnType: "AppProxy",
|
|
100
|
+
},
|
|
101
|
+
"apps.{appKey}.{actionType}.{actionKey}": {
|
|
102
|
+
categories: ["app"],
|
|
103
|
+
packages: ["sdk"],
|
|
104
|
+
type: "list",
|
|
105
|
+
inputSchema: ActionExecutionInputSchema,
|
|
106
|
+
itemType: "ActionResult",
|
|
107
|
+
outputSchema: ActionResultItemSchema,
|
|
108
|
+
},
|
|
109
|
+
},
|
|
110
|
+
},
|
|
90
111
|
};
|
|
91
112
|
};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare const ActionExecutionInputSchema: z.ZodObject<{
|
|
3
|
+
inputs: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
4
|
+
authenticationId: z.ZodOptional<z.ZodNumber>;
|
|
5
|
+
}, "strip", z.ZodTypeAny, {
|
|
6
|
+
authenticationId?: number | undefined;
|
|
7
|
+
inputs?: Record<string, unknown> | undefined;
|
|
8
|
+
}, {
|
|
9
|
+
authenticationId?: number | undefined;
|
|
10
|
+
inputs?: Record<string, unknown> | undefined;
|
|
11
|
+
}>;
|
|
12
|
+
export type ActionExecutionOptions = z.infer<typeof ActionExecutionInputSchema>;
|
|
13
|
+
export declare const AppFactoryInputSchema: z.ZodObject<{
|
|
14
|
+
authenticationId: z.ZodNumber;
|
|
15
|
+
}, "strip", z.ZodTypeAny, {
|
|
16
|
+
authenticationId: number;
|
|
17
|
+
}, {
|
|
18
|
+
authenticationId: number;
|
|
19
|
+
}>;
|
|
20
|
+
export type AppFactoryInput = z.infer<typeof AppFactoryInputSchema>;
|
|
21
|
+
interface BaseActionTypeProxy {
|
|
22
|
+
[action: string]: (options?: ActionExecutionOptions) => unknown;
|
|
23
|
+
}
|
|
24
|
+
interface FetchActionType {
|
|
25
|
+
fetch: (url: string | URL, init?: RequestInit & {
|
|
26
|
+
authenticationId?: number;
|
|
27
|
+
callbackUrl?: string;
|
|
28
|
+
authenticationTemplate?: string;
|
|
29
|
+
}) => Promise<Response>;
|
|
30
|
+
}
|
|
31
|
+
type ActionTypeProxy = BaseActionTypeProxy & Partial<FetchActionType>;
|
|
32
|
+
interface AppProxy {
|
|
33
|
+
[type: string]: ActionTypeProxy;
|
|
34
|
+
}
|
|
35
|
+
interface AppFactory {
|
|
36
|
+
(options: AppFactoryInput): AppProxy;
|
|
37
|
+
}
|
|
38
|
+
type AppProxyWithFactory = AppFactory & AppProxy;
|
|
39
|
+
export interface ActionProxy {
|
|
40
|
+
[app: string]: AppProxyWithFactory;
|
|
41
|
+
}
|
|
42
|
+
export {};
|
|
43
|
+
//# sourceMappingURL=schemas.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../../../src/plugins/apps/schemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,eAAO,MAAM,0BAA0B;;;;;;;;;EAOpC,CAAC;AAGJ,MAAM,MAAM,sBAAsB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,0BAA0B,CAAC,CAAC;AAEhF,eAAO,MAAM,qBAAqB;;;;;;EAIgB,CAAC;AAEnD,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAC;AAGpE,UAAU,mBAAmB;IAC3B,CAAC,MAAM,EAAE,MAAM,GAAG,CAAC,OAAO,CAAC,EAAE,sBAAsB,KAAK,OAAO,CAAC;CACjE;AAGD,UAAU,eAAe;IACvB,KAAK,EAAE,CACL,GAAG,EAAE,MAAM,GAAG,GAAG,EACjB,IAAI,CAAC,EAAE,WAAW,GAAG;QACnB,gBAAgB,CAAC,EAAE,MAAM,CAAC;QAC1B,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,sBAAsB,CAAC,EAAE,MAAM,CAAC;KACjC,KACE,OAAO,CAAC,QAAQ,CAAC,CAAC;CACxB;AAGD,KAAK,eAAe,GAAG,mBAAmB,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC;AAEtE,UAAU,QAAQ;IAChB,CAAC,IAAI,EAAE,MAAM,GAAG,eAAe,CAAC;CACjC;AAED,UAAU,UAAU;IAClB,CAAC,OAAO,EAAE,eAAe,GAAG,QAAQ,CAAC;CACtC;AAGD,KAAK,mBAAmB,GAAG,UAAU,GAAG,QAAQ,CAAC;AAEjD,MAAM,WAAW,WAAW;IAC1B,CAAC,GAAG,EAAE,MAAM,GAAG,mBAAmB,CAAC;CACpC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export const ActionExecutionInputSchema = z
|
|
3
|
+
.object({
|
|
4
|
+
inputs: z.record(z.unknown()).optional(),
|
|
5
|
+
authenticationId: z.number().optional(),
|
|
6
|
+
})
|
|
7
|
+
.describe("Execute an action with the given inputs for the bound app, as an alternative to runAction");
|
|
8
|
+
export const AppFactoryInputSchema = z
|
|
9
|
+
.object({
|
|
10
|
+
authenticationId: z.number(),
|
|
11
|
+
})
|
|
12
|
+
.describe("Bind an authentication ID to an app");
|
|
13
|
+
// Note: AppsPluginSdkExtension removed - now using AppsPluginProvides in index.ts
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/registry/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AAE7D,MAAM,WAAW,6BAA6B;CAAG;AAEjD,MAAM,WAAW,sBAAsB;IACrC,WAAW,EAAE,CAAC,OAAO,CAAC,EAAE;QAAE,OAAO,CAAC,EAAE,MAAM,CAAA;KAAE,KAAK;QAC/C,SAAS,EAAE,qBAAqB,EAAE,CAAC;QACnC,UAAU,EAAE;YACV,GAAG,EAAE,MAAM,CAAC;YACZ,KAAK,EAAE,MAAM,CAAC;YACd,WAAW,EAAE,MAAM,CAAC;YACpB,SAAS,EAAE,MAAM,EAAE,CAAC;SACrB,EAAE,CAAC;KACL,CAAC;CACH;AAGD,eAAO,MAAM,cAAc,EAAE,MAAM,CACjC,EAAE,EAAE,wBAAwB;AAC5B,EAAE,EAAE,sBAAsB;AAC1B,sBAAsB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/registry/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AAE7D,MAAM,WAAW,6BAA6B;CAAG;AAEjD,MAAM,WAAW,sBAAsB;IACrC,WAAW,EAAE,CAAC,OAAO,CAAC,EAAE;QAAE,OAAO,CAAC,EAAE,MAAM,CAAA;KAAE,KAAK;QAC/C,SAAS,EAAE,qBAAqB,EAAE,CAAC;QACnC,UAAU,EAAE;YACV,GAAG,EAAE,MAAM,CAAC;YACZ,KAAK,EAAE,MAAM,CAAC;YACd,WAAW,EAAE,MAAM,CAAC;YACpB,SAAS,EAAE,MAAM,EAAE,CAAC;SACrB,EAAE,CAAC;KACL,CAAC;CACH;AAGD,eAAO,MAAM,cAAc,EAAE,MAAM,CACjC,EAAE,EAAE,wBAAwB;AAC5B,EAAE,EAAE,sBAAsB;AAC1B,sBAAsB,CA0IvB,CAAC"}
|
|
@@ -27,7 +27,18 @@ export const registryPlugin = ({ sdk, context }) => {
|
|
|
27
27
|
},
|
|
28
28
|
};
|
|
29
29
|
const functions = metaKeys
|
|
30
|
-
.filter((key) =>
|
|
30
|
+
.filter((key) => {
|
|
31
|
+
const property = sdk[key];
|
|
32
|
+
if (typeof property === "function") {
|
|
33
|
+
return true;
|
|
34
|
+
}
|
|
35
|
+
const [rootKey] = key.split(".");
|
|
36
|
+
const rootProperty = sdk[rootKey];
|
|
37
|
+
if (typeof rootProperty === "object" && rootProperty !== null) {
|
|
38
|
+
return true;
|
|
39
|
+
}
|
|
40
|
+
return false;
|
|
41
|
+
})
|
|
31
42
|
.map((key) => {
|
|
32
43
|
const meta = context.meta[key];
|
|
33
44
|
return {
|
package/dist/types/sdk.d.ts
CHANGED
|
@@ -28,7 +28,7 @@ import type { z } from "zod";
|
|
|
28
28
|
import type { RegistryPluginProvides } from "../plugins/registry";
|
|
29
29
|
import type { GetProfilePluginProvides } from "../plugins/getProfile";
|
|
30
30
|
import type { AppsPluginProvides, ZapierSdkApps } from "../plugins/apps";
|
|
31
|
-
import type { ActionProxy } from "../plugins/apps/
|
|
31
|
+
import type { ActionProxy } from "../plugins/apps/schemas";
|
|
32
32
|
import type { FetchPluginProvides } from "../plugins/fetch";
|
|
33
33
|
import type { ListAppsPluginProvides } from "../plugins/listApps";
|
|
34
34
|
import type { GetAppPluginProvides } from "../plugins/getApp";
|
package/dist/types/sdk.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sdk.d.ts","sourceRoot":"","sources":["../../src/types/sdk.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAG9C,MAAM,WAAW,cAAc;IAC7B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAAC;IAC7C,OAAO,CAAC,EAAE,aAAa,CAAC;IACxB,KAAK,CAAC,EAAE,OAAO,KAAK,CAAC;IACrB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,EAAE;QACT,IAAI,EAAE;YACJ,CAAC,MAAM,EAAE,MAAM,GAAG;gBAChB,kBAAkB,EAAE,MAAM,CAAC;gBAC3B,OAAO,CAAC,EAAE,MAAM,CAAC;aAClB,CAAC;SACH,CAAC;KACH,CAAC;CACH;AAGD,OAAO,KAAK,EAAE,0BAA0B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|
package/package.json
CHANGED
|
@@ -1,8 +1,14 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type {
|
|
2
|
+
ActionExecutionOptions,
|
|
3
|
+
ActionProxy,
|
|
4
|
+
AppFactoryInput,
|
|
5
|
+
} from "./schemas";
|
|
6
|
+
import { ActionExecutionInputSchema, AppFactoryInputSchema } from "./schemas";
|
|
2
7
|
import { ZapierValidationError } from "../../types/errors";
|
|
3
8
|
import type { Plugin, GetSdkType } from "../../types/plugin";
|
|
4
9
|
import type { FetchPluginProvides } from "../fetch/index";
|
|
5
10
|
import type { RunActionPluginProvides } from "../runAction/index";
|
|
11
|
+
import { ActionResultItemSchema } from "../../schemas/Run";
|
|
6
12
|
|
|
7
13
|
export interface AppsPluginProvides {
|
|
8
14
|
apps: ActionProxy;
|
|
@@ -12,10 +18,6 @@ interface AppsPluginOptions {
|
|
|
12
18
|
sdk: GetSdkType<FetchPluginProvides & RunActionPluginProvides>;
|
|
13
19
|
}
|
|
14
20
|
|
|
15
|
-
interface AppFactoryOptions {
|
|
16
|
-
authenticationId: number;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
21
|
function createActionFunction(
|
|
20
22
|
appKey: string,
|
|
21
23
|
actionType: string,
|
|
@@ -127,7 +129,7 @@ function createPinnedAppProxy(
|
|
|
127
129
|
|
|
128
130
|
function createAppProxy(appKey: string, options: AppsPluginOptions) {
|
|
129
131
|
// Create the factory function that returns a pinned version
|
|
130
|
-
const appFactory = (factoryOptions:
|
|
132
|
+
const appFactory = (factoryOptions: AppFactoryInput) => {
|
|
131
133
|
return createPinnedAppProxy(
|
|
132
134
|
appKey,
|
|
133
135
|
options,
|
|
@@ -170,11 +172,30 @@ export const appsPlugin: Plugin<
|
|
|
170
172
|
// Return flat structure - apps goes directly to SDK
|
|
171
173
|
return {
|
|
172
174
|
apps: createAppsProxy({ sdk }),
|
|
175
|
+
context: {
|
|
176
|
+
meta: {
|
|
177
|
+
"apps.{appKey}": {
|
|
178
|
+
categories: ["app"],
|
|
179
|
+
packages: ["sdk"],
|
|
180
|
+
type: "function",
|
|
181
|
+
inputSchema: AppFactoryInputSchema,
|
|
182
|
+
returnType: "AppProxy",
|
|
183
|
+
},
|
|
184
|
+
"apps.{appKey}.{actionType}.{actionKey}": {
|
|
185
|
+
categories: ["app"],
|
|
186
|
+
packages: ["sdk"],
|
|
187
|
+
type: "list",
|
|
188
|
+
inputSchema: ActionExecutionInputSchema,
|
|
189
|
+
itemType: "ActionResult",
|
|
190
|
+
outputSchema: ActionResultItemSchema,
|
|
191
|
+
},
|
|
192
|
+
},
|
|
193
|
+
},
|
|
173
194
|
};
|
|
174
195
|
};
|
|
175
196
|
|
|
176
197
|
// Export types for use in generated code
|
|
177
|
-
export type { ActionExecutionOptions } from "./
|
|
198
|
+
export type { ActionExecutionOptions } from "./schemas";
|
|
178
199
|
export type { ActionExecutionResult } from "../../api/types";
|
|
179
200
|
|
|
180
201
|
// Interface for generated apps - will be augmented by generated .d.ts files
|
|
@@ -1,12 +1,24 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
|
|
3
|
+
export const ActionExecutionInputSchema = z
|
|
4
|
+
.object({
|
|
5
|
+
inputs: z.record(z.unknown()).optional(),
|
|
6
|
+
authenticationId: z.number().optional(),
|
|
7
|
+
})
|
|
8
|
+
.describe(
|
|
9
|
+
"Execute an action with the given inputs for the bound app, as an alternative to runAction",
|
|
10
|
+
);
|
|
11
|
+
|
|
1
12
|
// Apps plugin-specific execution options
|
|
2
|
-
export
|
|
3
|
-
inputs?: Record<string, any>;
|
|
4
|
-
authenticationId?: number;
|
|
5
|
-
}
|
|
13
|
+
export type ActionExecutionOptions = z.infer<typeof ActionExecutionInputSchema>;
|
|
6
14
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
15
|
+
export const AppFactoryInputSchema = z
|
|
16
|
+
.object({
|
|
17
|
+
authenticationId: z.number(),
|
|
18
|
+
})
|
|
19
|
+
.describe("Bind an authentication ID to an app");
|
|
20
|
+
|
|
21
|
+
export type AppFactoryInput = z.infer<typeof AppFactoryInputSchema>;
|
|
10
22
|
|
|
11
23
|
// Base action type proxy for regular actions
|
|
12
24
|
interface BaseActionTypeProxy {
|
|
@@ -33,7 +45,7 @@ interface AppProxy {
|
|
|
33
45
|
}
|
|
34
46
|
|
|
35
47
|
interface AppFactory {
|
|
36
|
-
(options:
|
|
48
|
+
(options: AppFactoryInput): AppProxy;
|
|
37
49
|
}
|
|
38
50
|
|
|
39
51
|
// An app can be both a factory function and have properties for direct access
|
|
@@ -53,7 +53,18 @@ export const registryPlugin: Plugin<
|
|
|
53
53
|
};
|
|
54
54
|
|
|
55
55
|
const functions = metaKeys
|
|
56
|
-
.filter((key) =>
|
|
56
|
+
.filter((key) => {
|
|
57
|
+
const property = sdk[key as keyof typeof sdk];
|
|
58
|
+
if (typeof property === "function") {
|
|
59
|
+
return true;
|
|
60
|
+
}
|
|
61
|
+
const [rootKey] = key.split(".");
|
|
62
|
+
const rootProperty = sdk[rootKey as keyof typeof sdk];
|
|
63
|
+
if (typeof rootProperty === "object" && rootProperty !== null) {
|
|
64
|
+
return true;
|
|
65
|
+
}
|
|
66
|
+
return false;
|
|
67
|
+
})
|
|
57
68
|
.map((key) => {
|
|
58
69
|
const meta = context.meta[key];
|
|
59
70
|
return {
|
package/src/types/sdk.ts
CHANGED
|
@@ -34,7 +34,7 @@ import type { z } from "zod";
|
|
|
34
34
|
import type { RegistryPluginProvides } from "../plugins/registry";
|
|
35
35
|
import type { GetProfilePluginProvides } from "../plugins/getProfile";
|
|
36
36
|
import type { AppsPluginProvides, ZapierSdkApps } from "../plugins/apps";
|
|
37
|
-
import type { ActionProxy } from "../plugins/apps/
|
|
37
|
+
import type { ActionProxy } from "../plugins/apps/schemas";
|
|
38
38
|
import type { FetchPluginProvides } from "../plugins/fetch";
|
|
39
39
|
import type { ListAppsPluginProvides } from "../plugins/listApps";
|
|
40
40
|
import type { GetAppPluginProvides } from "../plugins/getApp";
|