@zapier/zapier-sdk 0.36.0 → 0.38.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/CLAUDE.md +50 -0
- package/README.md +147 -81
- package/dist/index.cjs +417 -166
- package/dist/index.d.mts +99 -13
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -0
- package/dist/index.mjs +413 -167
- package/dist/plugins/apps/index.d.ts.map +1 -1
- package/dist/plugins/apps/index.js +61 -24
- package/dist/plugins/apps/schemas.d.ts +4 -1
- package/dist/plugins/apps/schemas.d.ts.map +1 -1
- package/dist/plugins/apps/schemas.js +4 -2
- package/dist/plugins/capabilities/index.d.ts +22 -0
- package/dist/plugins/capabilities/index.d.ts.map +1 -0
- package/dist/plugins/capabilities/index.js +76 -0
- package/dist/plugins/connections/index.d.ts +11 -0
- package/dist/plugins/connections/index.d.ts.map +1 -0
- package/dist/plugins/connections/index.js +21 -0
- package/dist/plugins/fetch/index.d.ts +4 -1
- package/dist/plugins/fetch/index.d.ts.map +1 -1
- package/dist/plugins/fetch/index.js +9 -3
- package/dist/plugins/fetch/schemas.d.ts +1 -0
- package/dist/plugins/fetch/schemas.d.ts.map +1 -1
- package/dist/plugins/fetch/schemas.js +2 -1
- package/dist/plugins/findFirstConnection/schemas.d.ts +1 -0
- package/dist/plugins/findFirstConnection/schemas.d.ts.map +1 -1
- package/dist/plugins/findUniqueConnection/schemas.d.ts +1 -0
- package/dist/plugins/findUniqueConnection/schemas.d.ts.map +1 -1
- package/dist/plugins/listConnections/index.d.ts +2 -1
- package/dist/plugins/listConnections/index.d.ts.map +1 -1
- package/dist/plugins/listConnections/index.js +10 -3
- package/dist/plugins/listConnections/schemas.d.ts +1 -0
- package/dist/plugins/listConnections/schemas.d.ts.map +1 -1
- package/dist/plugins/listConnections/schemas.js +5 -0
- package/dist/plugins/manifest/index.d.ts +3 -0
- package/dist/plugins/manifest/index.d.ts.map +1 -1
- package/dist/plugins/manifest/index.js +15 -6
- package/dist/plugins/manifest/schemas.d.ts +36 -7
- package/dist/plugins/manifest/schemas.d.ts.map +1 -1
- package/dist/plugins/manifest/schemas.js +17 -10
- package/dist/plugins/runAction/index.d.ts +2 -1
- package/dist/plugins/runAction/index.d.ts.map +1 -1
- package/dist/plugins/runAction/index.js +8 -3
- package/dist/plugins/runAction/schemas.d.ts +1 -0
- package/dist/plugins/runAction/schemas.d.ts.map +1 -1
- package/dist/plugins/runAction/schemas.js +2 -1
- package/dist/plugins/tables/deleteTable/index.d.ts +2 -1
- package/dist/plugins/tables/deleteTable/index.d.ts.map +1 -1
- package/dist/plugins/tables/deleteTable/index.js +1 -0
- package/dist/plugins/tables/listTables/index.d.ts +2 -1
- package/dist/plugins/tables/listTables/index.d.ts.map +1 -1
- package/dist/plugins/tables/listTables/index.js +14 -6
- package/dist/plugins/tables/listTables/schemas.d.ts +1 -0
- package/dist/plugins/tables/listTables/schemas.d.ts.map +1 -1
- package/dist/plugins/tables/listTables/schemas.js +5 -1
- package/dist/resolvers/connectionId.d.ts.map +1 -1
- package/dist/resolvers/connectionId.js +13 -23
- package/dist/resolvers/tableId.d.ts.map +1 -1
- package/dist/resolvers/tableId.js +17 -6
- package/dist/sdk.d.ts +6 -1
- package/dist/sdk.d.ts.map +1 -1
- package/dist/sdk.js +6 -0
- package/dist/types/connections.d.ts +19 -0
- package/dist/types/connections.d.ts.map +1 -0
- package/dist/types/connections.js +18 -0
- package/dist/types/properties.d.ts +2 -0
- package/dist/types/properties.d.ts.map +1 -1
- package/dist/types/properties.js +3 -0
- package/dist/types/sdk.d.ts +3 -0
- package/dist/types/sdk.d.ts.map +1 -1
- package/dist/types/sdk.js +9 -0
- package/dist/utils/domain-utils.d.ts +15 -0
- package/dist/utils/domain-utils.d.ts.map +1 -1
- package/dist/utils/domain-utils.js +30 -0
- package/dist/utils/pagination-utils.d.ts +6 -0
- package/dist/utils/pagination-utils.d.ts.map +1 -1
- package/dist/utils/pagination-utils.js +8 -0
- package/dist/utils/schema-utils.d.ts +6 -1
- package/dist/utils/schema-utils.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -10,13 +10,14 @@ import { toArrayFromAsync } from "../../utils/array-utils";
|
|
|
10
10
|
function parseManifestContent(content, source) {
|
|
11
11
|
try {
|
|
12
12
|
const parsed = JSON.parse(content);
|
|
13
|
-
if (parsed
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
13
|
+
if (parsed == null || typeof parsed !== "object") {
|
|
14
|
+
return null;
|
|
15
|
+
}
|
|
16
|
+
const result = ManifestSchema.safeParse(parsed);
|
|
17
|
+
if (result.success) {
|
|
18
|
+
return result.data;
|
|
19
19
|
}
|
|
20
|
+
console.warn(`⚠️ Invalid manifest format in ${source}: ${result.error}`);
|
|
20
21
|
return null;
|
|
21
22
|
}
|
|
22
23
|
catch (error) {
|
|
@@ -108,6 +109,9 @@ async function listAppsForSlugsPage({ slugs, cursor, api, }) {
|
|
|
108
109
|
* Find a manifest entry by any app key (implementation name, slug, etc.).
|
|
109
110
|
*/
|
|
110
111
|
export function findManifestEntry({ appKey, manifest, }) {
|
|
112
|
+
if (!manifest.apps) {
|
|
113
|
+
return null;
|
|
114
|
+
}
|
|
111
115
|
const [appKeyWithoutVersion] = splitVersionedKey(appKey);
|
|
112
116
|
// Direct match by key
|
|
113
117
|
if (manifest.apps[appKeyWithoutVersion]) {
|
|
@@ -365,6 +369,7 @@ export const manifestPlugin = (params) => {
|
|
|
365
369
|
};
|
|
366
370
|
return {
|
|
367
371
|
context: {
|
|
372
|
+
getResolvedManifest,
|
|
368
373
|
getVersionedImplementationId,
|
|
369
374
|
resolveAppKeys: async ({ appKeys }) => resolveAppKeys({
|
|
370
375
|
appKeys,
|
|
@@ -379,6 +384,10 @@ export const manifestPlugin = (params) => {
|
|
|
379
384
|
hasActionEntry,
|
|
380
385
|
findManifestEntry,
|
|
381
386
|
readManifestFromFile,
|
|
387
|
+
getManifestConnections: async () => {
|
|
388
|
+
const manifest = await getResolvedManifest();
|
|
389
|
+
return manifest?.connections ?? null;
|
|
390
|
+
},
|
|
382
391
|
},
|
|
383
392
|
};
|
|
384
393
|
};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import type { ResolvedAppLocator } from "../../utils/domain-utils";
|
|
3
3
|
import type { AppItem } from "../../types/domain";
|
|
4
|
+
import { type ConnectionsMap } from "../../types/connections";
|
|
4
5
|
export declare const DEFAULT_CONFIG_PATH: ".zapierrc";
|
|
5
6
|
export type ManifestEntry = {
|
|
6
7
|
implementationName: string;
|
|
@@ -24,8 +25,12 @@ export declare const ActionEntrySchema: z.ZodObject<{
|
|
|
24
25
|
}, z.core.$strip>;
|
|
25
26
|
export type ActionEntry = z.infer<typeof ActionEntrySchema>;
|
|
26
27
|
export type Manifest = {
|
|
27
|
-
apps
|
|
28
|
+
apps?: Record<string, ManifestEntry>;
|
|
28
29
|
actions?: Record<string, ActionEntry>;
|
|
30
|
+
canIncludeSharedConnections?: boolean;
|
|
31
|
+
canIncludeSharedTables?: boolean;
|
|
32
|
+
canDeleteTables?: boolean;
|
|
33
|
+
connections?: ConnectionsMap;
|
|
29
34
|
};
|
|
30
35
|
export type ResolveAppKeys = ({ appKeys, }: {
|
|
31
36
|
appKeys: string[];
|
|
@@ -34,10 +39,10 @@ export type ResolveAppKeys = ({ appKeys, }: {
|
|
|
34
39
|
* Manifest schema for version locking and saved action configurations
|
|
35
40
|
*/
|
|
36
41
|
export declare const ManifestSchema: z.ZodObject<{
|
|
37
|
-
apps: z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
42
|
+
apps: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
38
43
|
implementationName: z.ZodString;
|
|
39
44
|
version: z.ZodString;
|
|
40
|
-
}, z.core.$strip
|
|
45
|
+
}, z.core.$strip>>>;
|
|
41
46
|
actions: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
42
47
|
appKey: z.ZodString;
|
|
43
48
|
actionKey: z.ZodString;
|
|
@@ -48,12 +53,36 @@ export declare const ManifestSchema: z.ZodObject<{
|
|
|
48
53
|
schema: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
49
54
|
createdAt: z.ZodString;
|
|
50
55
|
}, z.core.$strip>>>;
|
|
56
|
+
canIncludeSharedConnections: z.ZodOptional<z.ZodBoolean>;
|
|
57
|
+
canIncludeSharedTables: z.ZodOptional<z.ZodBoolean>;
|
|
58
|
+
canDeleteTables: z.ZodOptional<z.ZodBoolean>;
|
|
59
|
+
connections: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
60
|
+
connectionId: z.ZodNumber;
|
|
61
|
+
}, z.core.$strip>>>;
|
|
51
62
|
}, z.core.$strip>;
|
|
52
63
|
export declare const ManifestPluginOptionsSchema: z.ZodObject<{
|
|
53
64
|
manifestPath: z.ZodOptional<z.ZodString>;
|
|
54
|
-
manifest: z.ZodOptional<z.
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
65
|
+
manifest: z.ZodOptional<z.ZodObject<{
|
|
66
|
+
apps: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
67
|
+
implementationName: z.ZodString;
|
|
68
|
+
version: z.ZodString;
|
|
69
|
+
}, z.core.$strip>>>;
|
|
70
|
+
actions: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
71
|
+
appKey: z.ZodString;
|
|
72
|
+
actionKey: z.ZodString;
|
|
73
|
+
actionType: z.ZodString;
|
|
74
|
+
connectionId: z.ZodOptional<z.ZodNullable<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>>;
|
|
75
|
+
authenticationId: z.ZodOptional<z.ZodNullable<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>>;
|
|
76
|
+
inputs: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
77
|
+
schema: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
78
|
+
createdAt: z.ZodString;
|
|
79
|
+
}, z.core.$strip>>>;
|
|
80
|
+
canIncludeSharedConnections: z.ZodOptional<z.ZodBoolean>;
|
|
81
|
+
canIncludeSharedTables: z.ZodOptional<z.ZodBoolean>;
|
|
82
|
+
canDeleteTables: z.ZodOptional<z.ZodBoolean>;
|
|
83
|
+
connections: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
84
|
+
connectionId: z.ZodNumber;
|
|
85
|
+
}, z.core.$strip>>>;
|
|
86
|
+
}, z.core.$strip>>;
|
|
58
87
|
}, z.core.$strip>;
|
|
59
88
|
//# sourceMappingURL=schemas.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../../../src/plugins/manifest/schemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AACnE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../../../src/plugins/manifest/schemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AACnE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAKlD,OAAO,EAEL,KAAK,cAAc,EACpB,MAAM,yBAAyB,CAAC;AAEjC,eAAO,MAAM,mBAAmB,EAAG,WAAoB,CAAC;AAExD,MAAM,MAAM,aAAa,GAAG;IAC1B,kBAAkB,EAAE,MAAM,CAAC;IAC3B,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,MAAM,MAAM,4BAA4B,GAAG,CACzC,MAAM,EAAE,MAAM,KACX,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;AAE5B,MAAM,MAAM,iBAAiB,GAAG,CAAC,MAAM,EAAE,MAAM,KAAK,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC,CAAC;AAE5E;;;GAGG;AACH,eAAO,MAAM,iBAAiB;;;;;;;;;iBAmB5B,CAAC;AAEH,MAAM,MAAM,WAAW,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,iBAAiB,CAAC,CAAC;AAE5D,MAAM,MAAM,QAAQ,GAAG;IACrB,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;IACrC,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;IACtC,2BAA2B,CAAC,EAAE,OAAO,CAAC;IACtC,sBAAsB,CAAC,EAAE,OAAO,CAAC;IACjC,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,WAAW,CAAC,EAAE,cAAc,CAAC;CAC9B,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG,CAAC,EAC5B,OAAO,GACR,EAAE;IACD,OAAO,EAAE,MAAM,EAAE,CAAC;CACnB,KAAK,OAAO,CAAC,kBAAkB,EAAE,CAAC,CAAC;AAEpC;;GAEG;AACH,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;iBAkCxB,CAAC;AAEJ,eAAO,MAAM,2BAA2B;;;;;;;;;;;;;;;;;;;;;;;;iBAGtC,CAAC"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import { ConnectionIdPropertySchema, AuthenticationIdPropertySchema, } from "../../types/properties";
|
|
3
|
+
import { ConnectionsMapSchema, } from "../../types/connections";
|
|
3
4
|
export const DEFAULT_CONFIG_PATH = ".zapierrc";
|
|
4
5
|
/**
|
|
5
6
|
* Action entry for storing saved action configurations
|
|
@@ -28,25 +29,31 @@ export const ActionEntrySchema = z.object({
|
|
|
28
29
|
*/
|
|
29
30
|
export const ManifestSchema = z
|
|
30
31
|
.object({
|
|
31
|
-
apps: z
|
|
32
|
+
apps: z
|
|
33
|
+
.record(z.string(), z.object({
|
|
32
34
|
implementationName: z
|
|
33
35
|
.string()
|
|
34
36
|
.describe("Base implementation name without version (e.g., 'SlackCLIAPI')"),
|
|
35
37
|
version: z.string().describe("Version string (e.g., '1.21.1')"),
|
|
36
|
-
}))
|
|
38
|
+
}))
|
|
39
|
+
.optional(),
|
|
37
40
|
actions: z
|
|
38
41
|
.record(z.string(), ActionEntrySchema)
|
|
39
42
|
.optional()
|
|
40
43
|
.describe("Saved action configurations with their schemas"),
|
|
44
|
+
canIncludeSharedConnections: z
|
|
45
|
+
.boolean()
|
|
46
|
+
.optional()
|
|
47
|
+
.describe("Allow listing shared connections"),
|
|
48
|
+
canIncludeSharedTables: z
|
|
49
|
+
.boolean()
|
|
50
|
+
.optional()
|
|
51
|
+
.describe("Allow listing shared tables"),
|
|
52
|
+
canDeleteTables: z.boolean().optional().describe("Allow deleting tables"),
|
|
53
|
+
connections: ConnectionsMapSchema.optional().describe("Named connections map. Keys are connection names, values contain a connectionId."),
|
|
41
54
|
})
|
|
42
|
-
.describe("Manifest for app version locking and
|
|
55
|
+
.describe("Manifest for app version locking, action configurations, and named connections");
|
|
43
56
|
export const ManifestPluginOptionsSchema = z.object({
|
|
44
57
|
manifestPath: z.string().optional().describe("Path to manifest file"),
|
|
45
|
-
manifest:
|
|
46
|
-
.record(z.string(), z.object({
|
|
47
|
-
implementationName: z.string(),
|
|
48
|
-
version: z.string().optional(),
|
|
49
|
-
}))
|
|
50
|
-
.optional()
|
|
51
|
-
.describe("Direct manifest object"),
|
|
58
|
+
manifest: ManifestSchema.optional().describe("Direct manifest object"),
|
|
52
59
|
});
|
|
@@ -4,6 +4,7 @@ import { RunActionSchema, type RunActionOptions } from "./schemas";
|
|
|
4
4
|
import type { GetActionPluginProvides } from "../getAction";
|
|
5
5
|
import type { GetAppPluginProvides } from "../getApp";
|
|
6
6
|
import type { GetVersionedImplementationId } from "../manifest/schemas";
|
|
7
|
+
import type { ConnectionsPluginProvides } from "../connections";
|
|
7
8
|
import type { EventEmissionContext } from "../eventEmission";
|
|
8
9
|
export interface RunActionPluginProvides {
|
|
9
10
|
runAction: (options?: RunActionOptions) => Promise<{
|
|
@@ -30,6 +31,6 @@ export declare const runActionPlugin: Plugin<GetSdkType<GetActionPluginProvides
|
|
|
30
31
|
{
|
|
31
32
|
api: ApiClient;
|
|
32
33
|
getVersionedImplementationId: GetVersionedImplementationId;
|
|
33
|
-
} & EventEmissionContext, // requires api and eventEmission in context
|
|
34
|
+
} & ConnectionsPluginProvides["context"] & EventEmissionContext, // requires api, connections, and eventEmission in context
|
|
34
35
|
RunActionPluginProvides>;
|
|
35
36
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/runAction/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAC7D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,EACL,eAAe,EACf,KAAK,gBAAgB,EAEtB,MAAM,WAAW,CAAC;AAQnB,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAC;AAC5D,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAC;AAQtD,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/runAction/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAC7D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,EACL,eAAe,EACf,KAAK,gBAAgB,EAEtB,MAAM,WAAW,CAAC;AAQnB,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAC;AAC5D,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAC;AAQtD,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,qBAAqB,CAAC;AACxE,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,gBAAgB,CAAC;AAEhE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAM7D,MAAM,WAAW,uBAAuB;IACtC,SAAS,EAAE,CAAC,OAAO,CAAC,EAAE,gBAAgB,KAAK,OAAO,CAAC;QACjD,IAAI,EAAE,GAAG,EAAE,CAAC;QACZ,UAAU,CAAC,EAAE,MAAM,CAAC;KACrB,CAAC,GACA,aAAa,CAAC;QAAE,IAAI,EAAE,GAAG,EAAE,CAAC;QAAC,UAAU,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,GAAG;QACpD,KAAK,IAAI,aAAa,CAAC,GAAG,CAAC,CAAC;KAC7B,CAAC;IACJ,OAAO,EAAE;QACP,IAAI,EAAE;YACJ,SAAS,EAAE;gBACT,WAAW,EAAE,OAAO,eAAe,CAAC;aACrC,CAAC;SACH,CAAC;KACH,CAAC;CACH;AAsFD,eAAO,MAAM,oBAAoB,QAAS,CAAC;AAC3C,eAAO,MAAM,sBAAsB,MAAM,CAAC;AAE1C,eAAO,MAAM,eAAe,EAAE,MAAM,CAClC,UAAU,CAAC,uBAAuB,GAAG,oBAAoB,CAAC,EAAE,uCAAuC;AACnG,AAD4D,uCAAuC;AACnG;IACE,GAAG,EAAE,SAAS,CAAC;IACf,4BAA4B,EAAE,4BAA4B,CAAC;CAC5D,GAAG,yBAAyB,CAAC,SAAS,CAAC,GACtC,oBAAoB,EAAE,0DAA0D;AAClF,uBAAuB,CA8LxB,CAAC"}
|
|
@@ -4,6 +4,7 @@ import { ZapierValidationError, ZapierConfigurationError, ZapierActionError, } f
|
|
|
4
4
|
import { createPaginatedFunction } from "../../utils/function-utils";
|
|
5
5
|
import { appKeyResolver, actionTypeResolver, actionKeyResolver, connectionIdResolver, inputsResolver, } from "../../resolvers";
|
|
6
6
|
import { createTelemetryCallback } from "../../utils/telemetry-utils";
|
|
7
|
+
import { resolveConnectionId } from "../../utils/domain-utils";
|
|
7
8
|
import { stripPageSuffix } from "../../utils/string-utils";
|
|
8
9
|
import { DEFAULT_ACTION_TIMEOUT_MS } from "../../constants";
|
|
9
10
|
import { setMethodMetadata } from "../../utils/telemetry-context";
|
|
@@ -112,9 +113,13 @@ export const runActionPlugin = ({ sdk, context }) => {
|
|
|
112
113
|
}
|
|
113
114
|
async function runActionPage(options) {
|
|
114
115
|
const { api } = context;
|
|
115
|
-
const { appKey, actionKey, actionType, connectionId, authenticationId, inputs = {}, cursor, timeoutMs, } = options;
|
|
116
|
-
|
|
117
|
-
|
|
116
|
+
const { appKey, actionKey, actionType, connectionId, connection, authenticationId, inputs = {}, cursor, timeoutMs, } = options;
|
|
117
|
+
const resolvedConnectionId = await resolveConnectionId({
|
|
118
|
+
connectionId,
|
|
119
|
+
connection,
|
|
120
|
+
authenticationId,
|
|
121
|
+
resolveConnection: context.resolveConnection,
|
|
122
|
+
});
|
|
118
123
|
const { selectedApi, actionId } = await getRunActionContext(options);
|
|
119
124
|
setMethodMetadata({
|
|
120
125
|
selectedApi,
|
|
@@ -17,6 +17,7 @@ export declare const RunActionSchema: z.ZodObject<{
|
|
|
17
17
|
}>;
|
|
18
18
|
actionKey: z.ZodString;
|
|
19
19
|
connectionId: z.ZodOptional<z.ZodNullable<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>>;
|
|
20
|
+
connection: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
|
|
20
21
|
authenticationId: z.ZodOptional<z.ZodNullable<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>>;
|
|
21
22
|
inputs: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
22
23
|
timeoutMs: z.ZodOptional<z.ZodNumber>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../../../src/plugins/runAction/schemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;
|
|
1
|
+
{"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../../../src/plugins/runAction/schemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAUxB,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAClE,OAAO,KAAK,EACV,iBAAiB,EACjB,qBAAqB,EACrB,wBAAwB,EACxB,kBAAkB,EACnB,MAAM,oBAAoB,CAAC;AAG5B,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;iBA+B0B,CAAC;AAGvD,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,eAAe,CAAC,CAAC;AAG/D,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,OAAO,EAAE,CAAC;IAChB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAGD,MAAM,MAAM,cAAc,GACtB,iBAAiB,GACjB,qBAAqB,GACrB,wBAAwB,GACxB,kBAAkB,CAAC;AAGvB,MAAM,WAAW,oBAAoB;IACnC,SAAS,EAAE,oBAAoB,CAAC,gBAAgB,EAAE,OAAO,CAAC,CAAC;CAC5D"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
import { AppKeyPropertySchema, ActionTypePropertySchema, ActionKeyPropertySchema, ConnectionIdPropertySchema, InputsPropertySchema, ActionTimeoutMsPropertySchema, } from "../../types/properties";
|
|
2
|
+
import { AppKeyPropertySchema, ActionTypePropertySchema, ActionKeyPropertySchema, ConnectionIdPropertySchema, ConnectionPropertySchema, InputsPropertySchema, ActionTimeoutMsPropertySchema, } from "../../types/properties";
|
|
3
3
|
// Pure Zod schema - no resolver metadata!
|
|
4
4
|
export const RunActionSchema = z
|
|
5
5
|
.object({
|
|
@@ -9,6 +9,7 @@ export const RunActionSchema = z
|
|
|
9
9
|
connectionId: ConnectionIdPropertySchema.nullable()
|
|
10
10
|
.optional()
|
|
11
11
|
.describe("Connection ID to use when running the action. Required if the action needs a connection to authenticate and interact with the service."),
|
|
12
|
+
connection: ConnectionPropertySchema.optional().describe("Connection alias (string) or numeric connectionId. Strings are resolved from the connections map; numbers are used directly. Mutually exclusive with connectionId."),
|
|
12
13
|
/** @deprecated Use connectionId instead */
|
|
13
14
|
authenticationId: ConnectionIdPropertySchema.nullable().optional(),
|
|
14
15
|
inputs: InputsPropertySchema.optional().describe("Input parameters for the action"),
|
|
@@ -2,6 +2,7 @@ import type { Plugin } from "../../../types/plugin";
|
|
|
2
2
|
import type { ApiClient } from "../../../api";
|
|
3
3
|
import { DeleteTableOptionsSchema, type DeleteTableOptions, type DeleteTableResult } from "./schemas";
|
|
4
4
|
import type { EventEmissionContext } from "../../eventEmission";
|
|
5
|
+
import type { CapabilitiesContext } from "../../capabilities";
|
|
5
6
|
export interface DeleteTablePluginProvides {
|
|
6
7
|
deleteTable: (options: DeleteTableOptions) => Promise<DeleteTableResult>;
|
|
7
8
|
context: {
|
|
@@ -14,5 +15,5 @@ export interface DeleteTablePluginProvides {
|
|
|
14
15
|
}
|
|
15
16
|
export declare const deleteTablePlugin: Plugin<{}, {
|
|
16
17
|
api: ApiClient;
|
|
17
|
-
} & EventEmissionContext, DeleteTablePluginProvides>;
|
|
18
|
+
} & EventEmissionContext & CapabilitiesContext, DeleteTablePluginProvides>;
|
|
18
19
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/plugins/tables/deleteTable/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAE9C,OAAO,EACL,wBAAwB,EACxB,KAAK,kBAAkB,EACvB,KAAK,iBAAiB,EACvB,MAAM,WAAW,CAAC;AACnB,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/plugins/tables/deleteTable/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAE9C,OAAO,EACL,wBAAwB,EACxB,KAAK,kBAAkB,EACvB,KAAK,iBAAiB,EACvB,MAAM,WAAW,CAAC;AACnB,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAChE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAK9D,MAAM,WAAW,yBAAyB;IACxC,WAAW,EAAE,CAAC,OAAO,EAAE,kBAAkB,KAAK,OAAO,CAAC,iBAAiB,CAAC,CAAC;IACzE,OAAO,EAAE;QACP,IAAI,EAAE;YACJ,WAAW,EAAE;gBACX,WAAW,EAAE,OAAO,wBAAwB,CAAC;aAC9C,CAAC;SACH,CAAC;KACH,CAAC;CACH;AAED,eAAO,MAAM,iBAAiB,EAAE,MAAM,CACpC,EAAE,EACF;IAAE,GAAG,EAAE,SAAS,CAAA;CAAE,GAAG,oBAAoB,GAAG,mBAAmB,EAC/D,yBAAyB,CA0D1B,CAAC"}
|
|
@@ -5,6 +5,7 @@ import { ZapierAuthenticationError } from "../../../types/errors";
|
|
|
5
5
|
import { tableIdResolver } from "../../../resolvers";
|
|
6
6
|
export const deleteTablePlugin = ({ context }) => {
|
|
7
7
|
async function deleteTable(options) {
|
|
8
|
+
await context.checkCapability("canDeleteTables");
|
|
8
9
|
const { api } = context;
|
|
9
10
|
await api.delete(`/tables/api/v1/tables/${options.tableId}`, undefined, {
|
|
10
11
|
customErrorHandler: ({ status }) => {
|
|
@@ -2,6 +2,7 @@ import type { GetContextType, Plugin } from "../../../types/plugin";
|
|
|
2
2
|
import { ListTablesOptionsSchema, type ListTablesOptions, type TableItem } from "./schemas";
|
|
3
3
|
import type { ApiPluginProvides } from "../../api";
|
|
4
4
|
import type { EventEmissionContext } from "../../eventEmission";
|
|
5
|
+
import type { CapabilitiesContext } from "../../capabilities";
|
|
5
6
|
export interface ListTablesPluginProvides {
|
|
6
7
|
listTables: (options?: ListTablesOptions) => Promise<{
|
|
7
8
|
data: TableItem[];
|
|
@@ -20,5 +21,5 @@ export interface ListTablesPluginProvides {
|
|
|
20
21
|
};
|
|
21
22
|
};
|
|
22
23
|
}
|
|
23
|
-
export declare const listTablesPlugin: Plugin<{}, GetContextType<ApiPluginProvides> & EventEmissionContext, ListTablesPluginProvides>;
|
|
24
|
+
export declare const listTablesPlugin: Plugin<{}, GetContextType<ApiPluginProvides> & EventEmissionContext & CapabilitiesContext, ListTablesPluginProvides>;
|
|
24
25
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/plugins/tables/listTables/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAEpE,OAAO,EAEL,uBAAuB,EAEvB,KAAK,iBAAiB,EACtB,KAAK,SAAS,EACf,MAAM,WAAW,CAAC;AACnB,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AACnD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/plugins/tables/listTables/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAEpE,OAAO,EAEL,uBAAuB,EAEvB,KAAK,iBAAiB,EACtB,KAAK,SAAS,EACf,MAAM,WAAW,CAAC;AACnB,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AACnD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAOhE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAmB9D,MAAM,WAAW,wBAAwB;IACvC,UAAU,EAAE,CAAC,OAAO,CAAC,EAAE,iBAAiB,KAAK,OAAO,CAAC;QACnD,IAAI,EAAE,SAAS,EAAE,CAAC;QAClB,UAAU,CAAC,EAAE,MAAM,CAAC;KACrB,CAAC,GACA,aAAa,CAAC;QAAE,IAAI,EAAE,SAAS,EAAE,CAAC;QAAC,UAAU,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,GAAG;QAC1D,KAAK,IAAI,aAAa,CAAC,SAAS,CAAC,CAAC;KACnC,CAAC;IACJ,OAAO,EAAE;QACP,IAAI,EAAE;YACJ,UAAU,EAAE;gBACV,WAAW,EAAE,OAAO,uBAAuB,CAAC;aAC7C,CAAC;SACH,CAAC;KACH,CAAC;CACH;AAED,eAAO,MAAM,gBAAgB,EAAE,MAAM,CACnC,EAAE,EACF,cAAc,CAAC,iBAAiB,CAAC,GAC/B,oBAAoB,GACpB,mBAAmB,EACrB,wBAAwB,CAiGzB,CAAC"}
|
|
@@ -2,7 +2,7 @@ import { createPaginatedFunction } from "../../../utils/function-utils";
|
|
|
2
2
|
import { ListTablesApiResponseSchema, ListTablesOptionsSchema, TableItemSchema, } from "./schemas";
|
|
3
3
|
import { createTelemetryCallback } from "../../../utils/telemetry-utils";
|
|
4
4
|
import { stripPageSuffix } from "../../../utils/string-utils";
|
|
5
|
-
import { ZapierAuthenticationError } from "../../../types/errors";
|
|
5
|
+
import { ZapierAuthenticationError, ZapierValidationError, } from "../../../types/errors";
|
|
6
6
|
import { transformTableItem } from "../utils";
|
|
7
7
|
import { DEFAULT_PAGE_SIZE } from "../../../constants";
|
|
8
8
|
function extractNextCursor(links) {
|
|
@@ -20,6 +20,9 @@ function extractNextCursor(links) {
|
|
|
20
20
|
}
|
|
21
21
|
export const listTablesPlugin = ({ context }) => {
|
|
22
22
|
async function listTablesPage(options) {
|
|
23
|
+
if (options.includeShared) {
|
|
24
|
+
await context.checkCapability("canIncludeSharedTables");
|
|
25
|
+
}
|
|
23
26
|
const { api } = context;
|
|
24
27
|
const searchParams = {};
|
|
25
28
|
if (options.pageSize !== undefined) {
|
|
@@ -34,15 +37,20 @@ export const listTablesPlugin = ({ context }) => {
|
|
|
34
37
|
if (options?.search) {
|
|
35
38
|
searchParams.q = options.search;
|
|
36
39
|
}
|
|
37
|
-
if (options?.owner) {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
+
if (options?.owner && options.owner !== "me" && !options.includeShared) {
|
|
41
|
+
throw new ZapierValidationError('The "owner" option requires "includeShared" to be true. Without includeShared, only your own tables are returned.');
|
|
42
|
+
}
|
|
43
|
+
const owner = options.includeShared ? options.owner : "me";
|
|
44
|
+
if (owner) {
|
|
45
|
+
if (owner === "me") {
|
|
40
46
|
const profile = await api.get("/zapier/api/v4/profile/", {
|
|
41
47
|
authRequired: true,
|
|
42
48
|
});
|
|
43
|
-
|
|
49
|
+
searchParams.owner_customuser_id = String(profile.id);
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
searchParams.owner_customuser_id = owner;
|
|
44
53
|
}
|
|
45
|
-
searchParams.owner_customuser_id = ownerId;
|
|
46
54
|
}
|
|
47
55
|
if (options.cursor) {
|
|
48
56
|
searchParams.offset = options.cursor;
|
|
@@ -62,6 +62,7 @@ export declare const ListTablesOptionsSchema: z.ZodObject<{
|
|
|
62
62
|
}>>;
|
|
63
63
|
search: z.ZodOptional<z.ZodString>;
|
|
64
64
|
owner: z.ZodOptional<z.ZodString>;
|
|
65
|
+
includeShared: z.ZodOptional<z.ZodBoolean>;
|
|
65
66
|
pageSize: z.ZodOptional<z.ZodNumber>;
|
|
66
67
|
maxItems: z.ZodOptional<z.ZodNumber>;
|
|
67
68
|
cursor: z.ZodOptional<z.ZodString>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../../../../src/plugins/tables/listTables/schemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AACrE,OAAO,KAAK,EACV,yBAAyB,EACzB,cAAc,EACd,qBAAqB,EACrB,kBAAkB,EACnB,MAAM,uBAAuB,CAAC;AAE/B,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;iBAW7B,CAAC;AAEH,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAC;AAE9D,eAAO,MAAM,2BAA2B;;;;;;;;;;;;;;;;;;;iBAOtC,CAAC;AAEH,MAAM,MAAM,qBAAqB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,2BAA2B,CAAC,CAAC;AAEhF,eAAO,MAAM,eAAe;;;;;;;;;;;;;iBAU1B,CAAC;AAEH,MAAM,MAAM,SAAS,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,eAAe,CAAC,CAAC;AAExD,eAAO,MAAM,uBAAuB
|
|
1
|
+
{"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../../../../src/plugins/tables/listTables/schemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AACrE,OAAO,KAAK,EACV,yBAAyB,EACzB,cAAc,EACd,qBAAqB,EACrB,kBAAkB,EACnB,MAAM,uBAAuB,CAAC;AAE/B,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;iBAW7B,CAAC;AAEH,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAC;AAE9D,eAAO,MAAM,2BAA2B;;;;;;;;;;;;;;;;;;;iBAOtC,CAAC;AAEH,MAAM,MAAM,qBAAqB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,2BAA2B,CAAC,CAAC;AAEhF,eAAO,MAAM,eAAe;;;;;;;;;;;;;iBAU1B,CAAC;AAEH,MAAM,MAAM,SAAS,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,eAAe,CAAC,CAAC;AAExD,eAAO,MAAM,uBAAuB;;;;;;;;;;;;;iBAsC0B,CAAC;AAE/D,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,uBAAuB,CAAC,CAAC;AAGxE,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,SAAS,EAAE,CAAC;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAGD,MAAM,MAAM,eAAe,GACvB,yBAAyB,GACzB,cAAc,GACd,qBAAqB,GACrB,kBAAkB,CAAC;AAGvB,MAAM,WAAW,qBAAqB;IACpC,UAAU,EAAE,oBAAoB,CAAC,iBAAiB,EAAE,SAAS,CAAC,CAAC;CAChE"}
|
|
@@ -47,7 +47,11 @@ export const ListTablesOptionsSchema = z
|
|
|
47
47
|
owner: z
|
|
48
48
|
.string()
|
|
49
49
|
.optional()
|
|
50
|
-
.describe('Filter by table owner. Use "me" for the current user, or a numeric user ID.'),
|
|
50
|
+
.describe('Filter by table owner. Use "me" for the current user, or a numeric user ID. Requires includeShared to be true.'),
|
|
51
|
+
includeShared: z
|
|
52
|
+
.boolean()
|
|
53
|
+
.optional()
|
|
54
|
+
.describe("Include tables shared with you. Without this, only your own tables are returned."),
|
|
51
55
|
pageSize: z
|
|
52
56
|
.number()
|
|
53
57
|
.min(1)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"connectionId.d.ts","sourceRoot":"","sources":["../../src/resolvers/connectionId.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAE7D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"connectionId.d.ts","sourceRoot":"","sources":["../../src/resolvers/connectionId.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAE7D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAI5D,KAAK,oBAAoB,GAAG,eAAe,CACzC,cAAc,EACd;IAAE,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,CACpB,CAAC;AAoCF,eAAO,MAAM,oBAAoB,EAAE,oBAkBlC,CAAC;AAIF,eAAO,MAAM,2BAA2B,EAAE,oBAMzC,CAAC"}
|
|
@@ -1,17 +1,11 @@
|
|
|
1
|
+
import { toIterable } from "../utils/pagination-utils";
|
|
1
2
|
async function fetchConnections(sdk, resolvedParams) {
|
|
2
|
-
const
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
}
|
|
8
|
-
const myConnections = await sdk.listConnections({
|
|
9
|
-
...listOptions,
|
|
10
|
-
owner: "me",
|
|
11
|
-
});
|
|
12
|
-
const allConnections = await sdk.listConnections(listOptions);
|
|
13
|
-
const otherConnections = allConnections.data.filter((connection) => !myConnections.data.some((myConnection) => myConnection.id === connection.id));
|
|
14
|
-
return [...myConnections.data, ...otherConnections];
|
|
3
|
+
const context = sdk.getContext();
|
|
4
|
+
const includeShared = await context.hasCapability?.("canIncludeSharedConnections");
|
|
5
|
+
return toIterable(sdk.listConnections({
|
|
6
|
+
appKey: resolvedParams.appKey,
|
|
7
|
+
includeShared: includeShared || undefined,
|
|
8
|
+
}));
|
|
15
9
|
}
|
|
16
10
|
function promptForConnection(connections, params) {
|
|
17
11
|
return {
|
|
@@ -20,21 +14,16 @@ function promptForConnection(connections, params) {
|
|
|
20
14
|
message: params.appKey
|
|
21
15
|
? `Select connection for ${params.appKey}:`
|
|
22
16
|
: "Select connection:",
|
|
23
|
-
choices:
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
})),
|
|
28
|
-
{
|
|
29
|
-
name: "-> Skip connection (may fail)",
|
|
30
|
-
value: null,
|
|
31
|
-
},
|
|
32
|
-
],
|
|
17
|
+
choices: connections.map((connection) => ({
|
|
18
|
+
name: `${connection.title || connection.label || "Connection"} (ID: ${connection.id})`,
|
|
19
|
+
value: connection.id,
|
|
20
|
+
})),
|
|
33
21
|
};
|
|
34
22
|
}
|
|
35
23
|
export const connectionIdResolver = {
|
|
36
24
|
type: "dynamic",
|
|
37
25
|
depends: ["appKey"],
|
|
26
|
+
requireCapabilities: ["canIncludeSharedConnections"],
|
|
38
27
|
tryResolveWithoutPrompt: async (sdk, params) => {
|
|
39
28
|
if (!params.appKey)
|
|
40
29
|
return null;
|
|
@@ -57,6 +46,7 @@ export const connectionIdResolver = {
|
|
|
57
46
|
export const connectionIdGenericResolver = {
|
|
58
47
|
type: "dynamic",
|
|
59
48
|
depends: [],
|
|
49
|
+
requireCapabilities: ["canIncludeSharedConnections"],
|
|
60
50
|
fetch: fetchConnections,
|
|
61
51
|
prompt: promptForConnection,
|
|
62
52
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tableId.d.ts","sourceRoot":"","sources":["../../src/resolvers/tableId.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAC7D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,sCAAsC,CAAC;
|
|
1
|
+
{"version":3,"file":"tableId.d.ts","sourceRoot":"","sources":["../../src/resolvers/tableId.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAC7D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,sCAAsC,CAAC;AAItE,eAAO,MAAM,eAAe,EAAE,eAAe,CAAC,SAAS,EAAE,EAAE,CAkC1D,CAAC"}
|
|
@@ -1,11 +1,22 @@
|
|
|
1
|
-
import { concatPaginated } from "../utils/pagination-utils";
|
|
1
|
+
import { concatPaginated, toIterable } from "../utils/pagination-utils";
|
|
2
2
|
export const tableIdResolver = {
|
|
3
3
|
type: "dynamic",
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
4
|
+
requireCapabilities: ["canIncludeSharedTables"],
|
|
5
|
+
fetch: async (sdk) => {
|
|
6
|
+
const context = sdk.getContext();
|
|
7
|
+
const includeShared = await context.hasCapability?.("canIncludeSharedTables");
|
|
8
|
+
// Unlike connections, the tables API does not return personal tables
|
|
9
|
+
// first, so we use concatPaginated to hoist own tables above shared.
|
|
10
|
+
if (includeShared) {
|
|
11
|
+
return toIterable(concatPaginated({
|
|
12
|
+
sources: [
|
|
13
|
+
() => sdk.listTables(),
|
|
14
|
+
() => sdk.listTables({ includeShared: true }),
|
|
15
|
+
],
|
|
16
|
+
dedupe: (table) => table.id,
|
|
17
|
+
}));
|
|
18
|
+
}
|
|
19
|
+
return toIterable(sdk.listTables());
|
|
9
20
|
},
|
|
10
21
|
prompt: (tables) => ({
|
|
11
22
|
type: "list",
|
package/dist/sdk.d.ts
CHANGED
|
@@ -13,14 +13,16 @@ export declare function createSdk<TCurrentSdk = {}, TCurrentContext extends {
|
|
|
13
13
|
getContext(): TCurrentContext;
|
|
14
14
|
}, TRequiresContext, TProvides>, addPluginOptions?: Record<string, unknown>): Sdk<TCurrentSdk & ExtractSdkProperties<TProvides>, TCurrentContext & NonNullable<ExtractContextProperties<TProvides>>>;
|
|
15
15
|
};
|
|
16
|
-
export declare function createZapierSdkWithoutRegistry(options?: ZapierSdkOptions): Sdk<ExtractSdkProperties<import("./plugins/eventEmission").EventEmissionProvides> & ExtractSdkProperties<import(".").ApiPluginProvides> & ExtractSdkProperties<import(".").ManifestPluginProvides> & ExtractSdkProperties<import(".").ListAppsPluginProvides> & ExtractSdkProperties<import(".").GetAppPluginProvides> & ExtractSdkProperties<import(".").ListActionsPluginProvides> & ExtractSdkProperties<import(".").GetActionPluginProvides> & ExtractSdkProperties<import(".").ListInputFieldsPluginProvides> & ExtractSdkProperties<import("./plugins/getInputFieldsSchema").GetInputFieldsSchemaPluginProvides> & ExtractSdkProperties<import("./plugins/listInputFieldChoices").ListInputFieldChoicesPluginProvides> & ExtractSdkProperties<import(".").RunActionPluginProvides> & ExtractSdkProperties<import(".").ListConnectionsPluginProvides> & ExtractSdkProperties<import(".").GetConnectionPluginProvides> & ExtractSdkProperties<import(".").FindFirstConnectionPluginProvides> & ExtractSdkProperties<import(".").FindUniqueConnectionPluginProvides> & ExtractSdkProperties<import(".").ListAuthenticationsPluginProvides> & ExtractSdkProperties<import(".").GetAuthenticationPluginProvides> & ExtractSdkProperties<import(".").FindFirstAuthenticationPluginProvides> & ExtractSdkProperties<import(".").FindUniqueAuthenticationPluginProvides> & ExtractSdkProperties<import(".").ListClientCredentialsPluginProvides> & ExtractSdkProperties<import(".").CreateClientCredentialsPluginProvides> & ExtractSdkProperties<import(".").DeleteClientCredentialsPluginProvides> & ExtractSdkProperties<import(".").FetchPluginProvides> & ExtractSdkProperties<import(".").RequestPluginProvides> & ExtractSdkProperties<import(".").ListTablesPluginProvides> & ExtractSdkProperties<import(".").GetTablePluginProvides> & ExtractSdkProperties<import(".").DeleteTablePluginProvides> & ExtractSdkProperties<import(".").CreateTablePluginProvides> & ExtractSdkProperties<import(".").ListTableFieldsPluginProvides> & ExtractSdkProperties<import(".").CreateTableFieldsPluginProvides> & ExtractSdkProperties<import(".").DeleteTableFieldsPluginProvides> & ExtractSdkProperties<import(".").GetTableRecordPluginProvides> & ExtractSdkProperties<import(".").ListTableRecordsPluginProvides> & ExtractSdkProperties<import(".").CreateTableRecordsPluginProvides> & ExtractSdkProperties<import(".").DeleteTableRecordsPluginProvides> & ExtractSdkProperties<import(".").UpdateTableRecordsPluginProvides> & ExtractSdkProperties<import(".").AppsPluginProvides> & ExtractSdkProperties<import(".").GetProfilePluginProvides>, {
|
|
16
|
+
export declare function createZapierSdkWithoutRegistry(options?: ZapierSdkOptions): Sdk<ExtractSdkProperties<import("./plugins/eventEmission").EventEmissionProvides> & ExtractSdkProperties<import(".").ApiPluginProvides> & ExtractSdkProperties<import(".").ManifestPluginProvides> & ExtractSdkProperties<import("./plugins/capabilities").CapabilitiesPluginProvides> & ExtractSdkProperties<import(".").ConnectionsPluginProvides> & ExtractSdkProperties<import(".").ListAppsPluginProvides> & ExtractSdkProperties<import(".").GetAppPluginProvides> & ExtractSdkProperties<import(".").ListActionsPluginProvides> & ExtractSdkProperties<import(".").GetActionPluginProvides> & ExtractSdkProperties<import(".").ListInputFieldsPluginProvides> & ExtractSdkProperties<import("./plugins/getInputFieldsSchema").GetInputFieldsSchemaPluginProvides> & ExtractSdkProperties<import("./plugins/listInputFieldChoices").ListInputFieldChoicesPluginProvides> & ExtractSdkProperties<import(".").RunActionPluginProvides> & ExtractSdkProperties<import(".").ListConnectionsPluginProvides> & ExtractSdkProperties<import(".").GetConnectionPluginProvides> & ExtractSdkProperties<import(".").FindFirstConnectionPluginProvides> & ExtractSdkProperties<import(".").FindUniqueConnectionPluginProvides> & ExtractSdkProperties<import(".").ListAuthenticationsPluginProvides> & ExtractSdkProperties<import(".").GetAuthenticationPluginProvides> & ExtractSdkProperties<import(".").FindFirstAuthenticationPluginProvides> & ExtractSdkProperties<import(".").FindUniqueAuthenticationPluginProvides> & ExtractSdkProperties<import(".").ListClientCredentialsPluginProvides> & ExtractSdkProperties<import(".").CreateClientCredentialsPluginProvides> & ExtractSdkProperties<import(".").DeleteClientCredentialsPluginProvides> & ExtractSdkProperties<import(".").FetchPluginProvides> & ExtractSdkProperties<import(".").RequestPluginProvides> & ExtractSdkProperties<import(".").ListTablesPluginProvides> & ExtractSdkProperties<import(".").GetTablePluginProvides> & ExtractSdkProperties<import(".").DeleteTablePluginProvides> & ExtractSdkProperties<import(".").CreateTablePluginProvides> & ExtractSdkProperties<import(".").ListTableFieldsPluginProvides> & ExtractSdkProperties<import(".").CreateTableFieldsPluginProvides> & ExtractSdkProperties<import(".").DeleteTableFieldsPluginProvides> & ExtractSdkProperties<import(".").GetTableRecordPluginProvides> & ExtractSdkProperties<import(".").ListTableRecordsPluginProvides> & ExtractSdkProperties<import(".").CreateTableRecordsPluginProvides> & ExtractSdkProperties<import(".").DeleteTableRecordsPluginProvides> & ExtractSdkProperties<import(".").UpdateTableRecordsPluginProvides> & ExtractSdkProperties<import(".").AppsPluginProvides> & ExtractSdkProperties<import(".").GetProfilePluginProvides>, {
|
|
17
17
|
meta: Record<string, PluginMeta>;
|
|
18
18
|
} & import(".").EventEmissionContext & {
|
|
19
19
|
api: import("./api").ApiClient;
|
|
20
20
|
resolveCredentials: () => Promise<import("./auth").ResolvedCredentials | undefined>;
|
|
21
21
|
} & {
|
|
22
|
+
getResolvedManifest: () => Promise<import(".").Manifest | null>;
|
|
22
23
|
getVersionedImplementationId: import("./plugins/manifest/schemas").GetVersionedImplementationId;
|
|
23
24
|
resolveAppKeys: import("./plugins/manifest/schemas").ResolveAppKeys;
|
|
25
|
+
getManifestConnections: () => Promise<import(".").ConnectionsMap | null>;
|
|
24
26
|
updateManifestEntry: (options: import(".").UpdateManifestEntryOptions) => Promise<import(".").UpdateManifestEntryResult>;
|
|
25
27
|
addActionEntry: (options: import(".").AddActionEntryOptions) => Promise<import(".").AddActionEntryResult>;
|
|
26
28
|
findActionEntry: (options: {
|
|
@@ -44,6 +46,9 @@ export declare function createZapierSdkWithoutRegistry(options?: ZapierSdkOption
|
|
|
44
46
|
manifest: import(".").Manifest;
|
|
45
47
|
}) => [string, import(".").ManifestEntry] | null;
|
|
46
48
|
readManifestFromFile: (filePath: string) => Promise<import(".").Manifest | null>;
|
|
49
|
+
} & import("./plugins/capabilities").CapabilitiesContext & {
|
|
50
|
+
resolveConnection: (name: string) => Promise<import(".").ConnectionEntry | undefined>;
|
|
51
|
+
getConnectionsMap: () => Promise<import(".").ConnectionsMap | null>;
|
|
47
52
|
} & {
|
|
48
53
|
meta: {
|
|
49
54
|
listApps: {
|
package/dist/sdk.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sdk.d.ts","sourceRoot":"","sources":["../src/sdk.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAMlD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,KAAK,EACV,GAAG,EACH,MAAM,EACN,wBAAwB,EACxB,oBAAoB,EACpB,cAAc,EACd,UAAU,EACX,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"sdk.d.ts","sourceRoot":"","sources":["../src/sdk.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAMlD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,KAAK,EACV,GAAG,EACH,MAAM,EACN,wBAAwB,EACxB,oBAAoB,EACpB,cAAc,EACd,UAAU,EACX,MAAM,gBAAgB,CAAC;AAoDxB,MAAM,WAAW,gBAAiB,SAAQ,cAAc;CAAG;AAG3D,wBAAgB,SAAS,CACvB,WAAW,GAAG,EAAE,EAChB,eAAe,SAAS;IAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,CAAA;CAAE,GAAG;IAC7D,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;CAClC,EAED,OAAO,GAAE,gBAAqB,EAC9B,UAAU,GAAE,WAA+B,EAC3C,cAAc,GAAE,eAAiD;;cAKrD,gBAAgB,EAAE,SAAS,SAAS,cAAc,UAClD,MAAM,CACZ,WAAW,GAAG;QAAE,UAAU,IAAI,eAAe,CAAA;KAAE,EAC/C,gBAAgB,EAChB,SAAS,CACV,qBACiB,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GACxC,GAAG,CACJ,WAAW,GAAG,oBAAoB,CAAC,SAAS,CAAC,EAC7C,eAAe,GAAG,WAAW,CAAC,wBAAwB,CAAC,SAAS,CAAC,CAAC,CACnE;EA8DJ;AAED,wBAAgB,8BAA8B,CAAC,OAAO,GAAE,gBAAqB;UApFnE,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC;;;;;;;;;;;;;;;+BAxBvB,CAAC;kBAAoB,CAAC;;;;kBAEtB,CAAC;iBAA0B,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiLvC;AAED,wBAAgB,eAAe,CAAC,OAAO,GAAE,gBAAqB,GAAG,SAAS,CAMzE"}
|
package/dist/sdk.js
CHANGED
|
@@ -35,6 +35,8 @@ import { deleteTableRecordsPlugin } from "./plugins/tables/deleteTableRecords";
|
|
|
35
35
|
import { updateTableRecordsPlugin } from "./plugins/tables/updateTableRecords";
|
|
36
36
|
import { requestPlugin } from "./plugins/request";
|
|
37
37
|
import { manifestPlugin } from "./plugins/manifest";
|
|
38
|
+
import { capabilitiesPlugin } from "./plugins/capabilities";
|
|
39
|
+
import { connectionsPlugin } from "./plugins/connections";
|
|
38
40
|
import { eventEmissionPlugin } from "./plugins/eventEmission";
|
|
39
41
|
// Create SDK that supports flat plugins - returns an SDK, not a builder
|
|
40
42
|
export function createSdk(options = {}, initialSdk = {}, initialContext = { meta: {} }) {
|
|
@@ -99,6 +101,10 @@ export function createZapierSdkWithoutRegistry(options = {}) {
|
|
|
99
101
|
.addPlugin(apiPlugin)
|
|
100
102
|
// Manifest plugin (provides version locking context) - must come after apiPlugin
|
|
101
103
|
.addPlugin(manifestPlugin)
|
|
104
|
+
// Capabilities gates (must come after manifestPlugin for config access)
|
|
105
|
+
.addPlugin(capabilitiesPlugin)
|
|
106
|
+
// Named connections resolution
|
|
107
|
+
.addPlugin(connectionsPlugin)
|
|
102
108
|
// Apps/actions/fields
|
|
103
109
|
.addPlugin(listAppsPlugin)
|
|
104
110
|
.addPlugin(getAppPlugin)
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
/**
|
|
3
|
+
* A single connection entry in the connections map.
|
|
4
|
+
* Provides a connectionId that maps a named connection alias to a Zapier connection.
|
|
5
|
+
*/
|
|
6
|
+
export declare const ConnectionEntrySchema: z.ZodObject<{
|
|
7
|
+
connectionId: z.ZodNumber;
|
|
8
|
+
}, z.core.$strip>;
|
|
9
|
+
export type ConnectionEntry = z.infer<typeof ConnectionEntrySchema>;
|
|
10
|
+
/**
|
|
11
|
+
* A map of named connections. Keys are user-defined connection aliases
|
|
12
|
+
* (e.g. "slack_work", "slack_private") that can be referenced via the
|
|
13
|
+
* `connection` parameter on action calls.
|
|
14
|
+
*/
|
|
15
|
+
export declare const ConnectionsMapSchema: z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
16
|
+
connectionId: z.ZodNumber;
|
|
17
|
+
}, z.core.$strip>>;
|
|
18
|
+
export type ConnectionsMap = z.infer<typeof ConnectionsMapSchema>;
|
|
19
|
+
//# sourceMappingURL=connections.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"connections.d.ts","sourceRoot":"","sources":["../../src/types/connections.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;;GAGG;AACH,eAAO,MAAM,qBAAqB;;iBAMhC,CAAC;AAEH,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAC;AAEpE;;;;GAIG;AACH,eAAO,MAAM,oBAAoB;;kBAA8C,CAAC;AAEhF,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
/**
|
|
3
|
+
* A single connection entry in the connections map.
|
|
4
|
+
* Provides a connectionId that maps a named connection alias to a Zapier connection.
|
|
5
|
+
*/
|
|
6
|
+
export const ConnectionEntrySchema = z.object({
|
|
7
|
+
connectionId: z
|
|
8
|
+
.number()
|
|
9
|
+
.int()
|
|
10
|
+
.positive()
|
|
11
|
+
.describe("Zapier connection ID for the third-party service."),
|
|
12
|
+
});
|
|
13
|
+
/**
|
|
14
|
+
* A map of named connections. Keys are user-defined connection aliases
|
|
15
|
+
* (e.g. "slack_work", "slack_private") that can be referenced via the
|
|
16
|
+
* `connection` parameter on action calls.
|
|
17
|
+
*/
|
|
18
|
+
export const ConnectionsMapSchema = z.record(z.string(), ConnectionEntrySchema);
|