@zapier/zapier-sdk 0.15.1 → 0.15.3
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/dist/api/client.d.ts.map +1 -1
- package/dist/api/client.integration.test.d.ts +5 -0
- package/dist/api/client.integration.test.d.ts.map +1 -0
- package/dist/api/client.integration.test.js +318 -0
- package/dist/api/client.js +31 -1
- package/dist/index.cjs +401 -108
- package/dist/index.d.mts +360 -56
- package/dist/index.mjs +401 -108
- package/dist/plugins/fetch/schemas.d.ts +2 -2
- package/dist/plugins/getAction/schemas.d.ts +2 -2
- package/dist/plugins/getApp/index.test.js +17 -21
- package/dist/plugins/getInputFieldsSchema/schemas.d.ts +2 -2
- package/dist/plugins/listActions/index.test.js +25 -0
- package/dist/plugins/listActions/schemas.d.ts +6 -6
- package/dist/plugins/listApps/index.d.ts +1 -3
- package/dist/plugins/listApps/index.d.ts.map +1 -1
- package/dist/plugins/listApps/index.js +18 -44
- package/dist/plugins/listApps/index.test.js +89 -288
- package/dist/plugins/listApps/schemas.d.ts +19 -26
- package/dist/plugins/listApps/schemas.d.ts.map +1 -1
- package/dist/plugins/listApps/schemas.js +19 -18
- package/dist/plugins/listAuthentications/index.test.js +20 -0
- package/dist/plugins/listAuthentications/schemas.d.ts +4 -4
- package/dist/plugins/listInputFieldChoices/schemas.d.ts +8 -8
- package/dist/plugins/listInputFields/schemas.d.ts +8 -8
- package/dist/plugins/manifest/index.d.ts +42 -3
- package/dist/plugins/manifest/index.d.ts.map +1 -1
- package/dist/plugins/manifest/index.js +68 -1
- package/dist/plugins/manifest/index.test.js +513 -1
- package/dist/plugins/manifest/schemas.d.ts +75 -2
- package/dist/plugins/manifest/schemas.d.ts.map +1 -1
- package/dist/plugins/manifest/schemas.js +27 -3
- package/dist/plugins/request/schemas.d.ts +4 -4
- package/dist/plugins/runAction/schemas.d.ts +8 -8
- package/dist/sdk.d.ts +24 -2
- package/dist/sdk.d.ts.map +1 -1
- package/dist/temporary-internal-core/handlers/listApps.d.ts +67 -0
- package/dist/temporary-internal-core/handlers/listApps.d.ts.map +1 -0
- package/dist/temporary-internal-core/handlers/listApps.js +121 -0
- package/dist/temporary-internal-core/handlers/listApps.test.d.ts +2 -0
- package/dist/temporary-internal-core/handlers/listApps.test.d.ts.map +1 -0
- package/dist/temporary-internal-core/handlers/listApps.test.js +328 -0
- package/dist/temporary-internal-core/index.d.ts +4 -0
- package/dist/temporary-internal-core/index.d.ts.map +1 -1
- package/dist/temporary-internal-core/index.js +5 -1
- package/dist/temporary-internal-core/schemas/apps/index.d.ts +582 -0
- package/dist/temporary-internal-core/schemas/apps/index.d.ts.map +1 -0
- package/dist/temporary-internal-core/schemas/apps/index.js +95 -0
- package/dist/temporary-internal-core/schemas/implementations/index.d.ts +511 -0
- package/dist/temporary-internal-core/schemas/implementations/index.d.ts.map +1 -0
- package/dist/temporary-internal-core/schemas/implementations/index.js +79 -0
- package/dist/temporary-internal-core/types/handler.d.ts +51 -0
- package/dist/temporary-internal-core/types/handler.d.ts.map +1 -0
- package/dist/temporary-internal-core/types/handler.js +8 -0
- package/dist/temporary-internal-core/types/index.d.ts +5 -0
- package/dist/temporary-internal-core/types/index.d.ts.map +1 -0
- package/dist/temporary-internal-core/types/index.js +4 -0
- package/dist/temporary-internal-core/utils/app-locators.d.ts +54 -0
- package/dist/temporary-internal-core/utils/app-locators.d.ts.map +1 -0
- package/dist/temporary-internal-core/utils/app-locators.js +83 -0
- package/dist/temporary-internal-core/utils/transformations.d.ts +18 -0
- package/dist/temporary-internal-core/utils/transformations.d.ts.map +1 -0
- package/dist/temporary-internal-core/utils/transformations.js +36 -0
- package/package.json +1 -1
|
@@ -39,7 +39,7 @@ describe("getApp plugin", () => {
|
|
|
39
39
|
// Mock the API client to handle both resolveAppKeys and listApps calls
|
|
40
40
|
context.api.get = vi
|
|
41
41
|
.fn()
|
|
42
|
-
// First call: resolveAppKeys
|
|
42
|
+
// First call: resolveAppKeys calls listAppsForSlugsPage which expects raw API format
|
|
43
43
|
.mockResolvedValueOnce({
|
|
44
44
|
results: [
|
|
45
45
|
{
|
|
@@ -49,27 +49,25 @@ describe("getApp plugin", () => {
|
|
|
49
49
|
primary_color: "#4A154B",
|
|
50
50
|
categories: ["communication"],
|
|
51
51
|
slug: "slack",
|
|
52
|
-
key: "SlackCLIAPI",
|
|
53
|
-
version: "1.0.0",
|
|
54
52
|
},
|
|
55
53
|
],
|
|
56
54
|
next: null,
|
|
57
55
|
})
|
|
58
|
-
// Second call: listApps
|
|
56
|
+
// Second call: listApps goes through handler which returns transformed format
|
|
59
57
|
.mockResolvedValueOnce({
|
|
60
|
-
|
|
58
|
+
data: [
|
|
61
59
|
{
|
|
62
|
-
|
|
63
|
-
|
|
60
|
+
title: "Slack",
|
|
61
|
+
key: "SlackCLIAPI",
|
|
62
|
+
implementation_id: "SlackCLIAPI@1.0.0",
|
|
64
63
|
description: "Team communication",
|
|
65
64
|
primary_color: "#4A154B",
|
|
66
65
|
categories: ["communication"],
|
|
67
66
|
slug: "slack",
|
|
68
|
-
key: "SlackCLIAPI",
|
|
69
67
|
version: "1.0.0",
|
|
70
68
|
},
|
|
71
69
|
],
|
|
72
|
-
|
|
70
|
+
nextCursor: undefined,
|
|
73
71
|
});
|
|
74
72
|
const result = await sdk.getApp({
|
|
75
73
|
appKey: "slack",
|
|
@@ -92,10 +90,10 @@ describe("getApp plugin", () => {
|
|
|
92
90
|
results: [],
|
|
93
91
|
next: null,
|
|
94
92
|
})
|
|
95
|
-
// Second call: listApps main API call
|
|
93
|
+
// Second call: listApps main API call (returns transformed format)
|
|
96
94
|
.mockResolvedValueOnce({
|
|
97
|
-
|
|
98
|
-
|
|
95
|
+
data: [],
|
|
96
|
+
nextCursor: undefined,
|
|
99
97
|
});
|
|
100
98
|
await expect(sdk.getApp({
|
|
101
99
|
appKey: "nonexistent-app",
|
|
@@ -109,7 +107,7 @@ describe("getApp plugin", () => {
|
|
|
109
107
|
// Mock the API client to handle both resolveAppKeys and listApps calls
|
|
110
108
|
context.api.get = vi
|
|
111
109
|
.fn()
|
|
112
|
-
// First call: resolveAppKeys
|
|
110
|
+
// First call: resolveAppKeys calls listAppsForSlugsPage which expects raw API format
|
|
113
111
|
.mockResolvedValueOnce({
|
|
114
112
|
results: [
|
|
115
113
|
{
|
|
@@ -119,27 +117,25 @@ describe("getApp plugin", () => {
|
|
|
119
117
|
primary_color: "#FF0000",
|
|
120
118
|
categories: ["testing"],
|
|
121
119
|
slug: "test",
|
|
122
|
-
key: "TestCLIAPI",
|
|
123
|
-
version: "1.0.0",
|
|
124
120
|
},
|
|
125
121
|
],
|
|
126
122
|
next: null,
|
|
127
123
|
})
|
|
128
|
-
// Second call: listApps
|
|
124
|
+
// Second call: listApps goes through handler which returns transformed format
|
|
129
125
|
.mockResolvedValueOnce({
|
|
130
|
-
|
|
126
|
+
data: [
|
|
131
127
|
{
|
|
132
|
-
|
|
133
|
-
|
|
128
|
+
title: "Test App",
|
|
129
|
+
key: "TestCLIAPI",
|
|
130
|
+
implementation_id: "TestCLIAPI@1.0.0",
|
|
134
131
|
description: "Test description",
|
|
135
132
|
primary_color: "#FF0000",
|
|
136
133
|
categories: ["testing"],
|
|
137
134
|
slug: "test",
|
|
138
|
-
key: "TestCLIAPI",
|
|
139
135
|
version: "1.0.0",
|
|
140
136
|
},
|
|
141
137
|
],
|
|
142
|
-
|
|
138
|
+
nextCursor: undefined,
|
|
143
139
|
});
|
|
144
140
|
const result = await sdk.getApp({
|
|
145
141
|
appKey: "test",
|
|
@@ -10,14 +10,14 @@ export declare const GetInputFieldsSchemaSchema: z.ZodObject<{
|
|
|
10
10
|
inputs: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
11
11
|
}, "strip", z.ZodTypeAny, {
|
|
12
12
|
appKey: string;
|
|
13
|
-
actionType: "search" | "filter" | "read" | "read_bulk" | "run" | "search_and_write" | "search_or_write" | "write";
|
|
14
13
|
actionKey: string;
|
|
14
|
+
actionType: "search" | "filter" | "read" | "read_bulk" | "run" | "search_and_write" | "search_or_write" | "write";
|
|
15
15
|
authenticationId?: number | null | undefined;
|
|
16
16
|
inputs?: Record<string, unknown> | undefined;
|
|
17
17
|
}, {
|
|
18
18
|
appKey: string;
|
|
19
|
-
actionType: "search" | "filter" | "read" | "read_bulk" | "run" | "search_and_write" | "search_or_write" | "write";
|
|
20
19
|
actionKey: string;
|
|
20
|
+
actionType: "search" | "filter" | "read" | "read_bulk" | "run" | "search_and_write" | "search_or_write" | "write";
|
|
21
21
|
authenticationId?: number | null | undefined;
|
|
22
22
|
inputs?: Record<string, unknown> | undefined;
|
|
23
23
|
}>;
|
|
@@ -73,6 +73,31 @@ describe("listActions plugin", () => {
|
|
|
73
73
|
updateManifestEntry: vi
|
|
74
74
|
.fn()
|
|
75
75
|
.mockResolvedValue(["test-key", {}, { apps: {} }]),
|
|
76
|
+
addActionEntry: vi
|
|
77
|
+
.fn()
|
|
78
|
+
.mockResolvedValue(["test-key", {}, { apps: {} }]),
|
|
79
|
+
findActionEntry: vi.fn().mockResolvedValue({
|
|
80
|
+
key: "test-key",
|
|
81
|
+
entry: {},
|
|
82
|
+
manifest: { apps: {} },
|
|
83
|
+
}),
|
|
84
|
+
hasActionEntry: vi.fn().mockResolvedValue(true),
|
|
85
|
+
listActionEntries: vi
|
|
86
|
+
.fn()
|
|
87
|
+
.mockResolvedValue([
|
|
88
|
+
[
|
|
89
|
+
"test-key",
|
|
90
|
+
{ key: "test-key", entry: {}, manifest: { apps: {} } },
|
|
91
|
+
],
|
|
92
|
+
]),
|
|
93
|
+
deleteActionEntry: vi.fn().mockResolvedValue({ apps: {} }),
|
|
94
|
+
findManifestEntry: vi
|
|
95
|
+
.fn()
|
|
96
|
+
.mockResolvedValue([
|
|
97
|
+
"test-key",
|
|
98
|
+
{ key: "test-key", entry: {}, manifest: { apps: {} } },
|
|
99
|
+
]),
|
|
100
|
+
readManifestFromFile: vi.fn().mockResolvedValue({ apps: {} }),
|
|
76
101
|
},
|
|
77
102
|
}))
|
|
78
103
|
.addPlugin(listAppsPlugin)
|
|
@@ -12,16 +12,16 @@ export declare const ListActionsSchema: z.ZodObject<{
|
|
|
12
12
|
cursor: z.ZodOptional<z.ZodString>;
|
|
13
13
|
}, "strip", z.ZodTypeAny, {
|
|
14
14
|
appKey: string;
|
|
15
|
-
cursor?: string | undefined;
|
|
16
|
-
maxItems?: number | undefined;
|
|
17
|
-
pageSize?: number | undefined;
|
|
18
15
|
actionType?: "search" | "filter" | "read" | "read_bulk" | "run" | "search_and_write" | "search_or_write" | "write" | undefined;
|
|
16
|
+
pageSize?: number | undefined;
|
|
17
|
+
maxItems?: number | undefined;
|
|
18
|
+
cursor?: string | undefined;
|
|
19
19
|
}, {
|
|
20
20
|
appKey: string;
|
|
21
|
-
cursor?: string | undefined;
|
|
22
|
-
maxItems?: number | undefined;
|
|
23
|
-
pageSize?: number | undefined;
|
|
24
21
|
actionType?: "search" | "filter" | "read" | "read_bulk" | "run" | "search_and_write" | "search_or_write" | "write" | undefined;
|
|
22
|
+
pageSize?: number | undefined;
|
|
23
|
+
maxItems?: number | undefined;
|
|
24
|
+
cursor?: string | undefined;
|
|
25
25
|
}>;
|
|
26
26
|
export type ListActionsOptions = z.infer<typeof ListActionsSchema>;
|
|
27
27
|
export interface ListActionsPage {
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import type { GetContextType, Plugin } from "../../types/plugin";
|
|
2
|
-
import { ListAppsSchema } from "./schemas";
|
|
3
|
-
import type { ListAppsOptions } from "./schemas";
|
|
4
|
-
import type { AppItem } from "../../types/domain";
|
|
2
|
+
import { ListAppsSchema, type ListAppsOptions, type AppItem } from "./schemas";
|
|
5
3
|
import type { ManifestPluginProvides } from "../manifest";
|
|
6
4
|
import type { ApiPluginProvides } from "../api";
|
|
7
5
|
export interface ListAppsPluginProvides {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/listApps/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAEjE,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/listApps/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAEjE,OAAO,EACL,cAAc,EACd,KAAK,eAAe,EAEpB,KAAK,OAAO,EACb,MAAM,WAAW,CAAC;AAEnB,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AAC1D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,QAAQ,CAAC;AAEhD,MAAM,WAAW,sBAAsB;IACrC,QAAQ,EAAE,CAAC,OAAO,CAAC,EAAE,eAAe,KAAK,OAAO,CAAC;QAC/C,IAAI,EAAE,OAAO,EAAE,CAAC;QAChB,UAAU,CAAC,EAAE,MAAM,CAAC;KACrB,CAAC,GACA,aAAa,CAAC;QAAE,IAAI,EAAE,OAAO,EAAE,CAAC;QAAC,UAAU,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,GAAG;QACxD,KAAK,IAAI,aAAa,CAAC,OAAO,CAAC,CAAC;KACjC,CAAC;IACJ,OAAO,EAAE;QACP,IAAI,EAAE;YACJ,QAAQ,EAAE;gBACR,WAAW,EAAE,OAAO,cAAc,CAAC;aACpC,CAAC;SACH,CAAC;KACH,CAAC;CACH;AAED,eAAO,MAAM,cAAc,EAAE,MAAM,CACjC,EAAE,EACF,cAAc,CAAC,iBAAiB,GAAG,sBAAsB,CAAC,EAC1D,sBAAsB,CAwEvB,CAAC"}
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import { createPaginatedFunction } from "../../utils/function-utils";
|
|
2
|
-
import { ListAppsSchema } from "./schemas";
|
|
2
|
+
import { ListAppsSchema, } from "./schemas";
|
|
3
3
|
import { AppItemSchema } from "../../schemas/App";
|
|
4
|
-
import { normalizeImplementationMetaToAppItem, splitVersionedKey, toAppLocator, toImplementationId, } from "../../utils/domain-utils";
|
|
5
|
-
import { extractCursor } from "../../utils/function-utils";
|
|
6
4
|
export const listAppsPlugin = ({ context }) => {
|
|
7
5
|
const listApps = createPaginatedFunction(async function listAppsPage(options) {
|
|
8
6
|
const { api, resolveAppKeys } = context;
|
|
@@ -25,53 +23,29 @@ export const listAppsPlugin = ({ context }) => {
|
|
|
25
23
|
if (duplicatedLookupAppKeys.length > 0) {
|
|
26
24
|
throw new Error(`Duplicate lookup app keys found: ${duplicatedLookupAppKeys.join(", ")}`);
|
|
27
25
|
}
|
|
28
|
-
if
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
searchParams,
|
|
33
|
-
});
|
|
34
|
-
const implementations = searchEnvelope.results.map(normalizeImplementationMetaToAppItem);
|
|
35
|
-
const implementationNameSet = new Set(appLocators.map((locator) => locator.implementationName));
|
|
36
|
-
for (const implementation of implementations) {
|
|
37
|
-
const [implementationName] = splitVersionedKey(implementation.key);
|
|
38
|
-
if (!implementationNameSet.has(implementationName)) {
|
|
39
|
-
implementationNameSet.add(implementationName);
|
|
40
|
-
appLocators.push({
|
|
41
|
-
...toAppLocator(implementation.key),
|
|
42
|
-
implementationName,
|
|
43
|
-
});
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
const searchParams = {};
|
|
48
|
-
if (options.pageSize) {
|
|
49
|
-
searchParams.limit = options.pageSize.toString();
|
|
50
|
-
}
|
|
51
|
-
if (appLocators.length === 0) {
|
|
52
|
-
searchParams.latest_only = "true";
|
|
53
|
-
}
|
|
54
|
-
if (options.cursor) {
|
|
55
|
-
searchParams.offset = options.cursor;
|
|
56
|
-
}
|
|
57
|
-
searchParams.selected_apis = appLocators
|
|
58
|
-
.map((locator) => toImplementationId(locator))
|
|
59
|
-
.join(",");
|
|
60
|
-
// If we have app keys, but they resolved to an empty list, then we need to short-circuit and return an empty list.
|
|
61
|
-
// Otherwise, the API will return all apps, since no selected_apis are provided.
|
|
62
|
-
if (appKeys.length > 0 && appLocators.length === 0) {
|
|
26
|
+
// Step 2: Early return if user provided appKeys but they resolved to nothing AND no search
|
|
27
|
+
// This prevents the handler from returning all apps when the user explicitly filtered
|
|
28
|
+
// If search is provided, let the handler augment with search results
|
|
29
|
+
if (appKeys.length > 0 && appLocators.length === 0 && !options.search) {
|
|
63
30
|
return {
|
|
64
31
|
data: [],
|
|
65
32
|
nextCursor: undefined,
|
|
66
33
|
};
|
|
67
34
|
}
|
|
68
|
-
const
|
|
69
|
-
|
|
35
|
+
const implementationIds = appLocators.map((locator) => {
|
|
36
|
+
const version = locator.version || "latest";
|
|
37
|
+
return `${locator.implementationName}@${version}`;
|
|
38
|
+
});
|
|
39
|
+
// Call the API, which will be routed to the handler via handlerOverride in pathConfig.
|
|
40
|
+
// When the handler is migrated to sdkapi, this same API call will go over the network.
|
|
41
|
+
return await api.get("/api/v0/apps", {
|
|
42
|
+
searchParams: {
|
|
43
|
+
implementationIds: implementationIds.join(","),
|
|
44
|
+
...(options.search && { search: options.search }),
|
|
45
|
+
pageSize: options.pageSize.toString(),
|
|
46
|
+
...(options.cursor && { cursor: options.cursor }),
|
|
47
|
+
},
|
|
70
48
|
});
|
|
71
|
-
return {
|
|
72
|
-
data: implementationsEnvelope.results.map(normalizeImplementationMetaToAppItem),
|
|
73
|
-
nextCursor: extractCursor(implementationsEnvelope),
|
|
74
|
-
};
|
|
75
49
|
}, ListAppsSchema);
|
|
76
50
|
// Return flat structure - listApps goes directly to SDK
|
|
77
51
|
return {
|