@zapier/zapier-sdk 0.11.2 → 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 +12 -0
- package/README.md +285 -82
- package/dist/index.cjs +69 -28
- package/dist/index.d.mts +20 -8
- package/dist/index.mjs +69 -28
- 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/listAuthentications/schemas.d.ts +1 -1
- package/dist/plugins/listAuthentications/schemas.d.ts.map +1 -1
- package/dist/plugins/listAuthentications/schemas.js +4 -1
- 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/listAuthentications/schemas.ts +6 -1
- 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.cjs
CHANGED
|
@@ -192,6 +192,40 @@ HTTP Status: ${error.statusCode}`;
|
|
|
192
192
|
}
|
|
193
193
|
return message;
|
|
194
194
|
}
|
|
195
|
+
var ActionExecutionInputSchema = zod.z.object({
|
|
196
|
+
inputs: zod.z.record(zod.z.unknown()).optional(),
|
|
197
|
+
authenticationId: zod.z.number().optional()
|
|
198
|
+
}).describe(
|
|
199
|
+
"Execute an action with the given inputs for the bound app, as an alternative to runAction"
|
|
200
|
+
);
|
|
201
|
+
var AppFactoryInputSchema = zod.z.object({
|
|
202
|
+
authenticationId: zod.z.number()
|
|
203
|
+
}).describe("Bind an authentication ID to an app");
|
|
204
|
+
function getStringProperty(obj, key) {
|
|
205
|
+
if (typeof obj === "object" && obj !== null && key in obj) {
|
|
206
|
+
const value = obj[key];
|
|
207
|
+
return typeof value === "string" ? value : void 0;
|
|
208
|
+
}
|
|
209
|
+
return void 0;
|
|
210
|
+
}
|
|
211
|
+
function formatActionResult(item) {
|
|
212
|
+
const obj = typeof item === "object" && item !== null ? item : {};
|
|
213
|
+
const title = getStringProperty(obj, "title") || getStringProperty(obj, "name") || getStringProperty(obj, "label") || getStringProperty(obj, "subject") || "Action Result";
|
|
214
|
+
return {
|
|
215
|
+
title,
|
|
216
|
+
id: getStringProperty(obj, "id"),
|
|
217
|
+
key: getStringProperty(obj, "key"),
|
|
218
|
+
description: getStringProperty(obj, "description"),
|
|
219
|
+
data: item,
|
|
220
|
+
// Let formatJsonOutput handle the JSON rendering
|
|
221
|
+
details: []
|
|
222
|
+
// Not used when data is provided
|
|
223
|
+
};
|
|
224
|
+
}
|
|
225
|
+
var ActionResultItemSchema = withFormatter(
|
|
226
|
+
zod.z.unknown().describe("Action execution result"),
|
|
227
|
+
{ format: formatActionResult }
|
|
228
|
+
);
|
|
195
229
|
|
|
196
230
|
// src/plugins/apps/index.ts
|
|
197
231
|
function createActionFunction(appKey, actionType, actionKey, options, pinnedAuthId) {
|
|
@@ -295,7 +329,26 @@ function createAppsProxy(options) {
|
|
|
295
329
|
}
|
|
296
330
|
var appsPlugin = ({ sdk }) => {
|
|
297
331
|
return {
|
|
298
|
-
apps: createAppsProxy({ sdk })
|
|
332
|
+
apps: createAppsProxy({ sdk }),
|
|
333
|
+
context: {
|
|
334
|
+
meta: {
|
|
335
|
+
"apps.{appKey}": {
|
|
336
|
+
categories: ["app"],
|
|
337
|
+
packages: ["sdk"],
|
|
338
|
+
type: "function",
|
|
339
|
+
inputSchema: AppFactoryInputSchema,
|
|
340
|
+
returnType: "AppProxy"
|
|
341
|
+
},
|
|
342
|
+
"apps.{appKey}.{actionType}.{actionKey}": {
|
|
343
|
+
categories: ["app"],
|
|
344
|
+
packages: ["sdk"],
|
|
345
|
+
type: "list",
|
|
346
|
+
inputSchema: ActionExecutionInputSchema,
|
|
347
|
+
itemType: "ActionResult",
|
|
348
|
+
outputSchema: ActionResultItemSchema
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
}
|
|
299
352
|
};
|
|
300
353
|
};
|
|
301
354
|
var FetchUrlSchema = zod.z.union([zod.z.string(), zod.z.instanceof(URL)]).describe("The URL to fetch");
|
|
@@ -1879,7 +1932,9 @@ var ListAuthenticationsSchema = zod.z.object({
|
|
|
1879
1932
|
search: zod.z.string().optional().describe("Search term to filter authentications by title"),
|
|
1880
1933
|
title: zod.z.string().optional().describe("Filter authentications by exact title match"),
|
|
1881
1934
|
accountId: zod.z.string().optional().describe("Filter by account ID"),
|
|
1882
|
-
owner: zod.z.string().optional().describe(
|
|
1935
|
+
owner: zod.z.union([zod.z.string(), zod.z.literal("me")]).optional().describe(
|
|
1936
|
+
"Filter by owner, 'me' for your own authentications or a specific user ID"
|
|
1937
|
+
),
|
|
1883
1938
|
pageSize: zod.z.number().min(1).optional().describe("Number of authentications per page"),
|
|
1884
1939
|
maxItems: zod.z.number().min(1).optional().describe("Maximum total items to return across all pages")
|
|
1885
1940
|
}).describe("List available authentications with optional filtering");
|
|
@@ -2259,31 +2314,6 @@ var RunActionSchema = zod.z.object({
|
|
|
2259
2314
|
pageSize: zod.z.number().min(1).optional().describe("Number of results per page"),
|
|
2260
2315
|
maxItems: zod.z.number().min(1).optional().describe("Maximum total items to return across all pages")
|
|
2261
2316
|
}).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
|
-
zod.z.unknown().describe("Action execution result"),
|
|
2285
|
-
{ format: formatActionResult }
|
|
2286
|
-
);
|
|
2287
2317
|
|
|
2288
2318
|
// src/plugins/runAction/index.ts
|
|
2289
2319
|
async function executeAction(actionOptions) {
|
|
@@ -3515,7 +3545,18 @@ var registryPlugin = ({ sdk, context }) => {
|
|
|
3515
3545
|
title: "Other"
|
|
3516
3546
|
}
|
|
3517
3547
|
};
|
|
3518
|
-
const functions = metaKeys.filter((key) =>
|
|
3548
|
+
const functions = metaKeys.filter((key) => {
|
|
3549
|
+
const property = sdk[key];
|
|
3550
|
+
if (typeof property === "function") {
|
|
3551
|
+
return true;
|
|
3552
|
+
}
|
|
3553
|
+
const [rootKey] = key.split(".");
|
|
3554
|
+
const rootProperty = sdk[rootKey];
|
|
3555
|
+
if (typeof rootProperty === "object" && rootProperty !== null) {
|
|
3556
|
+
return true;
|
|
3557
|
+
}
|
|
3558
|
+
return false;
|
|
3559
|
+
}).map((key) => {
|
|
3519
3560
|
const meta = context.meta[key];
|
|
3520
3561
|
return {
|
|
3521
3562
|
name: key,
|
package/dist/index.d.mts
CHANGED
|
@@ -1613,13 +1613,25 @@ declare const getProfilePlugin: Plugin<{}, // no SDK dependencies
|
|
|
1613
1613
|
}, // requires api in context
|
|
1614
1614
|
GetProfilePluginProvides>;
|
|
1615
1615
|
|
|
1616
|
-
|
|
1617
|
-
inputs
|
|
1618
|
-
authenticationId
|
|
1619
|
-
}
|
|
1620
|
-
|
|
1616
|
+
declare const ActionExecutionInputSchema: z.ZodObject<{
|
|
1617
|
+
inputs: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
1618
|
+
authenticationId: z.ZodOptional<z.ZodNumber>;
|
|
1619
|
+
}, "strip", z.ZodTypeAny, {
|
|
1620
|
+
authenticationId?: number | undefined;
|
|
1621
|
+
inputs?: Record<string, unknown> | undefined;
|
|
1622
|
+
}, {
|
|
1623
|
+
authenticationId?: number | undefined;
|
|
1624
|
+
inputs?: Record<string, unknown> | undefined;
|
|
1625
|
+
}>;
|
|
1626
|
+
type ActionExecutionOptions = z.infer<typeof ActionExecutionInputSchema>;
|
|
1627
|
+
declare const AppFactoryInputSchema: z.ZodObject<{
|
|
1628
|
+
authenticationId: z.ZodNumber;
|
|
1629
|
+
}, "strip", z.ZodTypeAny, {
|
|
1621
1630
|
authenticationId: number;
|
|
1622
|
-
}
|
|
1631
|
+
}, {
|
|
1632
|
+
authenticationId: number;
|
|
1633
|
+
}>;
|
|
1634
|
+
type AppFactoryInput = z.infer<typeof AppFactoryInputSchema>;
|
|
1623
1635
|
interface BaseActionTypeProxy {
|
|
1624
1636
|
[action: string]: (options?: ActionExecutionOptions) => unknown;
|
|
1625
1637
|
}
|
|
@@ -1635,7 +1647,7 @@ interface AppProxy {
|
|
|
1635
1647
|
[type: string]: ActionTypeProxy;
|
|
1636
1648
|
}
|
|
1637
1649
|
interface AppFactory {
|
|
1638
|
-
(options:
|
|
1650
|
+
(options: AppFactoryInput): AppProxy;
|
|
1639
1651
|
}
|
|
1640
1652
|
type AppProxyWithFactory = AppFactory & AppProxy;
|
|
1641
1653
|
interface ActionProxy {
|
|
@@ -1997,7 +2009,7 @@ declare const ListAuthenticationsSchema: z.ZodObject<{
|
|
|
1997
2009
|
search: z.ZodOptional<z.ZodString>;
|
|
1998
2010
|
title: z.ZodOptional<z.ZodString>;
|
|
1999
2011
|
accountId: z.ZodOptional<z.ZodString>;
|
|
2000
|
-
owner: z.ZodOptional<z.ZodString
|
|
2012
|
+
owner: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodLiteral<"me">]>>;
|
|
2001
2013
|
pageSize: z.ZodOptional<z.ZodNumber>;
|
|
2002
2014
|
maxItems: z.ZodOptional<z.ZodNumber>;
|
|
2003
2015
|
}, "strip", z.ZodTypeAny, {
|
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");
|
|
@@ -1877,7 +1930,9 @@ var ListAuthenticationsSchema = z.object({
|
|
|
1877
1930
|
search: z.string().optional().describe("Search term to filter authentications by title"),
|
|
1878
1931
|
title: z.string().optional().describe("Filter authentications by exact title match"),
|
|
1879
1932
|
accountId: z.string().optional().describe("Filter by account ID"),
|
|
1880
|
-
owner: z.string().optional().describe(
|
|
1933
|
+
owner: z.union([z.string(), z.literal("me")]).optional().describe(
|
|
1934
|
+
"Filter by owner, 'me' for your own authentications or a specific user ID"
|
|
1935
|
+
),
|
|
1881
1936
|
pageSize: z.number().min(1).optional().describe("Number of authentications per page"),
|
|
1882
1937
|
maxItems: z.number().min(1).optional().describe("Maximum total items to return across all pages")
|
|
1883
1938
|
}).describe("List available authentications with optional filtering");
|
|
@@ -2257,31 +2312,6 @@ var RunActionSchema = z.object({
|
|
|
2257
2312
|
pageSize: z.number().min(1).optional().describe("Number of results per page"),
|
|
2258
2313
|
maxItems: z.number().min(1).optional().describe("Maximum total items to return across all pages")
|
|
2259
2314
|
}).describe("Execute an action with the given inputs");
|
|
2260
|
-
function getStringProperty(obj, key) {
|
|
2261
|
-
if (typeof obj === "object" && obj !== null && key in obj) {
|
|
2262
|
-
const value = obj[key];
|
|
2263
|
-
return typeof value === "string" ? value : void 0;
|
|
2264
|
-
}
|
|
2265
|
-
return void 0;
|
|
2266
|
-
}
|
|
2267
|
-
function formatActionResult(item) {
|
|
2268
|
-
const obj = typeof item === "object" && item !== null ? item : {};
|
|
2269
|
-
const title = getStringProperty(obj, "title") || getStringProperty(obj, "name") || getStringProperty(obj, "label") || getStringProperty(obj, "subject") || "Action Result";
|
|
2270
|
-
return {
|
|
2271
|
-
title,
|
|
2272
|
-
id: getStringProperty(obj, "id"),
|
|
2273
|
-
key: getStringProperty(obj, "key"),
|
|
2274
|
-
description: getStringProperty(obj, "description"),
|
|
2275
|
-
data: item,
|
|
2276
|
-
// Let formatJsonOutput handle the JSON rendering
|
|
2277
|
-
details: []
|
|
2278
|
-
// Not used when data is provided
|
|
2279
|
-
};
|
|
2280
|
-
}
|
|
2281
|
-
var ActionResultItemSchema = withFormatter(
|
|
2282
|
-
z.unknown().describe("Action execution result"),
|
|
2283
|
-
{ format: formatActionResult }
|
|
2284
|
-
);
|
|
2285
2315
|
|
|
2286
2316
|
// src/plugins/runAction/index.ts
|
|
2287
2317
|
async function executeAction(actionOptions) {
|
|
@@ -3513,7 +3543,18 @@ var registryPlugin = ({ sdk, context }) => {
|
|
|
3513
3543
|
title: "Other"
|
|
3514
3544
|
}
|
|
3515
3545
|
};
|
|
3516
|
-
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) => {
|
|
3517
3558
|
const meta = context.meta[key];
|
|
3518
3559
|
return {
|
|
3519
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
|
|
@@ -10,7 +10,7 @@ export declare const ListAuthenticationsSchema: z.ZodObject<{
|
|
|
10
10
|
search: z.ZodOptional<z.ZodString>;
|
|
11
11
|
title: z.ZodOptional<z.ZodString>;
|
|
12
12
|
accountId: z.ZodOptional<z.ZodString>;
|
|
13
|
-
owner: z.ZodOptional<z.ZodString
|
|
13
|
+
owner: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodLiteral<"me">]>>;
|
|
14
14
|
pageSize: z.ZodOptional<z.ZodNumber>;
|
|
15
15
|
maxItems: z.ZodOptional<z.ZodNumber>;
|
|
16
16
|
}, "strip", z.ZodTypeAny, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../../../src/plugins/listAuthentications/schemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAClE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAC7D,OAAO,KAAK,EACV,yBAAyB,EACzB,cAAc,EACd,sBAAsB,EACtB,qBAAqB,EACrB,kBAAkB,EACnB,MAAM,oBAAoB,CAAC;AAG5B,eAAO,MAAM,yBAAyB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../../../src/plugins/listAuthentications/schemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAClE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAC7D,OAAO,KAAK,EACV,yBAAyB,EACzB,cAAc,EACd,sBAAsB,EACtB,qBAAqB,EACrB,kBAAkB,EACnB,MAAM,oBAAoB,CAAC;AAG5B,eAAO,MAAM,yBAAyB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAmC+B,CAAC;AAGtE,MAAM,MAAM,0BAA0B,GAAG,CAAC,CAAC,KAAK,CAC9C,OAAO,yBAAyB,CACjC,CAAC;AAGF,MAAM,WAAW,uBAAuB;IACtC,IAAI,EAAE,kBAAkB,EAAE,CAAC;IAC3B,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAGD,MAAM,MAAM,wBAAwB,GAChC,yBAAyB,GACzB,cAAc,GACd,sBAAsB,GACtB,qBAAqB,GACrB,kBAAkB,CAAC;AAGvB,MAAM,WAAW,8BAA8B;IAC7C,mBAAmB,EAAE,oBAAoB,CACvC,0BAA0B,EAC1B,kBAAkB,CACnB,CAAC;CACH"}
|
|
@@ -17,7 +17,10 @@ export const ListAuthenticationsSchema = z
|
|
|
17
17
|
.optional()
|
|
18
18
|
.describe("Filter authentications by exact title match"),
|
|
19
19
|
accountId: z.string().optional().describe("Filter by account ID"),
|
|
20
|
-
owner: z
|
|
20
|
+
owner: z
|
|
21
|
+
.union([z.string(), z.literal("me")])
|
|
22
|
+
.optional()
|
|
23
|
+
.describe("Filter by owner, 'me' for your own authentications or a specific user ID"),
|
|
21
24
|
pageSize: z
|
|
22
25
|
.number()
|
|
23
26
|
.min(1)
|
|
@@ -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,EAAE,MAAM,oCAAoC,CAAC;AACrF,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,sCAAsC,CAAC;AACzF,OAAO,KAAK,EAAE,kCAAkC,EAAE,MAAM,4CAA4C,CAAC;AACrG,OAAO,KAAK,EAAE,mCAAmC,EAAE,MAAM,6CAA6C,CAAC;AACvG,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,4BAA4B,CAAC;AAE1E,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAC7B,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAClE,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,uBAAuB,CAAC;AACtE,OAAO,KAAK,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AACzE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"sdk.d.ts","sourceRoot":"","sources":["../../src/types/sdk.ts"],"names":[],"mappings":"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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
|
|
@@ -29,7 +29,12 @@ export const ListAuthenticationsSchema = z
|
|
|
29
29
|
.optional()
|
|
30
30
|
.describe("Filter authentications by exact title match"),
|
|
31
31
|
accountId: z.string().optional().describe("Filter by account ID"),
|
|
32
|
-
owner: z
|
|
32
|
+
owner: z
|
|
33
|
+
.union([z.string(), z.literal("me")])
|
|
34
|
+
.optional()
|
|
35
|
+
.describe(
|
|
36
|
+
"Filter by owner, 'me' for your own authentications or a specific user ID",
|
|
37
|
+
),
|
|
33
38
|
pageSize: z
|
|
34
39
|
.number()
|
|
35
40
|
.min(1)
|