@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
|
@@ -8,15 +8,45 @@ export type ManifestEntry = {
|
|
|
8
8
|
};
|
|
9
9
|
export type GetVersionedImplementationId = (appKey: string) => Promise<string | null>;
|
|
10
10
|
export type GetImplementation = (appKey: string) => Promise<AppItem | null>;
|
|
11
|
+
/**
|
|
12
|
+
* Action entry for storing saved action configurations
|
|
13
|
+
* The key in the actions record IS the user-provided name
|
|
14
|
+
*/
|
|
15
|
+
export declare const ActionEntrySchema: z.ZodObject<{
|
|
16
|
+
appKey: z.ZodString;
|
|
17
|
+
actionKey: z.ZodString;
|
|
18
|
+
actionType: z.ZodString;
|
|
19
|
+
authenticationId: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
20
|
+
inputs: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
21
|
+
schema: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
22
|
+
createdAt: z.ZodString;
|
|
23
|
+
}, "strip", z.ZodTypeAny, {
|
|
24
|
+
schema: Record<string, unknown>;
|
|
25
|
+
appKey: string;
|
|
26
|
+
actionKey: string;
|
|
27
|
+
actionType: string;
|
|
28
|
+
createdAt: string;
|
|
29
|
+
authenticationId?: number | null | undefined;
|
|
30
|
+
inputs?: Record<string, unknown> | undefined;
|
|
31
|
+
}, {
|
|
32
|
+
schema: Record<string, unknown>;
|
|
33
|
+
appKey: string;
|
|
34
|
+
actionKey: string;
|
|
35
|
+
actionType: string;
|
|
36
|
+
createdAt: string;
|
|
37
|
+
authenticationId?: number | null | undefined;
|
|
38
|
+
inputs?: Record<string, unknown> | undefined;
|
|
39
|
+
}>;
|
|
40
|
+
export type ActionEntry = z.infer<typeof ActionEntrySchema>;
|
|
11
41
|
export type Manifest = {
|
|
12
42
|
apps: Record<string, ManifestEntry>;
|
|
43
|
+
actions?: Record<string, ActionEntry>;
|
|
13
44
|
};
|
|
14
45
|
export type ResolveAppKeys = ({ appKeys, }: {
|
|
15
46
|
appKeys: string[];
|
|
16
47
|
}) => Promise<ResolvedAppLocator[]>;
|
|
17
48
|
/**
|
|
18
|
-
* Manifest schema for version locking
|
|
19
|
-
* Maps app keys to their locked version information
|
|
49
|
+
* Manifest schema for version locking and saved action configurations
|
|
20
50
|
*/
|
|
21
51
|
export declare const ManifestSchema: z.ZodObject<{
|
|
22
52
|
apps: z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
@@ -29,16 +59,59 @@ export declare const ManifestSchema: z.ZodObject<{
|
|
|
29
59
|
version: string;
|
|
30
60
|
implementationName: string;
|
|
31
61
|
}>>;
|
|
62
|
+
actions: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
63
|
+
appKey: z.ZodString;
|
|
64
|
+
actionKey: z.ZodString;
|
|
65
|
+
actionType: z.ZodString;
|
|
66
|
+
authenticationId: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
67
|
+
inputs: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
68
|
+
schema: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
69
|
+
createdAt: z.ZodString;
|
|
70
|
+
}, "strip", z.ZodTypeAny, {
|
|
71
|
+
schema: Record<string, unknown>;
|
|
72
|
+
appKey: string;
|
|
73
|
+
actionKey: string;
|
|
74
|
+
actionType: string;
|
|
75
|
+
createdAt: string;
|
|
76
|
+
authenticationId?: number | null | undefined;
|
|
77
|
+
inputs?: Record<string, unknown> | undefined;
|
|
78
|
+
}, {
|
|
79
|
+
schema: Record<string, unknown>;
|
|
80
|
+
appKey: string;
|
|
81
|
+
actionKey: string;
|
|
82
|
+
actionType: string;
|
|
83
|
+
createdAt: string;
|
|
84
|
+
authenticationId?: number | null | undefined;
|
|
85
|
+
inputs?: Record<string, unknown> | undefined;
|
|
86
|
+
}>>>;
|
|
32
87
|
}, "strip", z.ZodTypeAny, {
|
|
33
88
|
apps: Record<string, {
|
|
34
89
|
version: string;
|
|
35
90
|
implementationName: string;
|
|
36
91
|
}>;
|
|
92
|
+
actions?: Record<string, {
|
|
93
|
+
schema: Record<string, unknown>;
|
|
94
|
+
appKey: string;
|
|
95
|
+
actionKey: string;
|
|
96
|
+
actionType: string;
|
|
97
|
+
createdAt: string;
|
|
98
|
+
authenticationId?: number | null | undefined;
|
|
99
|
+
inputs?: Record<string, unknown> | undefined;
|
|
100
|
+
}> | undefined;
|
|
37
101
|
}, {
|
|
38
102
|
apps: Record<string, {
|
|
39
103
|
version: string;
|
|
40
104
|
implementationName: string;
|
|
41
105
|
}>;
|
|
106
|
+
actions?: Record<string, {
|
|
107
|
+
schema: Record<string, unknown>;
|
|
108
|
+
appKey: string;
|
|
109
|
+
actionKey: string;
|
|
110
|
+
actionType: string;
|
|
111
|
+
createdAt: string;
|
|
112
|
+
authenticationId?: number | null | undefined;
|
|
113
|
+
inputs?: Record<string, unknown> | undefined;
|
|
114
|
+
}> | undefined;
|
|
42
115
|
}>;
|
|
43
116
|
export declare const ManifestPluginOptionsSchema: z.ZodObject<{
|
|
44
117
|
manifestPath: z.ZodOptional<z.ZodString>;
|
|
@@ -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;AAElD,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,MAAM,MAAM,QAAQ,GAAG;IACrB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"schemas.d.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;;;;;;;;;;;;;;;;EAYtC,CAAC"}
|
|
@@ -1,8 +1,28 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
export const DEFAULT_CONFIG_PATH = ".zapierrc";
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
5
|
-
*
|
|
4
|
+
* Action entry for storing saved action configurations
|
|
5
|
+
* The key in the actions record IS the user-provided name
|
|
6
|
+
*/
|
|
7
|
+
export const ActionEntrySchema = z.object({
|
|
8
|
+
appKey: z.string().describe("App key (slug or implementation name)"),
|
|
9
|
+
actionKey: z.string().describe("Action key identifier"),
|
|
10
|
+
actionType: z
|
|
11
|
+
.string()
|
|
12
|
+
.describe("Action type (e.g., 'read', 'write', 'search')"),
|
|
13
|
+
authenticationId: z
|
|
14
|
+
.number()
|
|
15
|
+
.nullable()
|
|
16
|
+
.optional()
|
|
17
|
+
.describe("Authentication ID used"),
|
|
18
|
+
inputs: z.record(z.unknown()).optional().describe("Resolved input values"),
|
|
19
|
+
schema: z
|
|
20
|
+
.record(z.unknown())
|
|
21
|
+
.describe("Complete JSON Schema from getInputFieldsSchema (includes $schema, type, properties, required, etc.)"),
|
|
22
|
+
createdAt: z.string().describe("ISO 8601 timestamp when created"),
|
|
23
|
+
});
|
|
24
|
+
/**
|
|
25
|
+
* Manifest schema for version locking and saved action configurations
|
|
6
26
|
*/
|
|
7
27
|
export const ManifestSchema = z
|
|
8
28
|
.object({
|
|
@@ -12,8 +32,12 @@ export const ManifestSchema = z
|
|
|
12
32
|
.describe("Base implementation name without version (e.g., 'SlackCLIAPI')"),
|
|
13
33
|
version: z.string().describe("Version string (e.g., '1.21.1')"),
|
|
14
34
|
})),
|
|
35
|
+
actions: z
|
|
36
|
+
.record(z.string(), ActionEntrySchema)
|
|
37
|
+
.optional()
|
|
38
|
+
.describe("Saved action configurations with their schemas"),
|
|
15
39
|
})
|
|
16
|
-
.describe("Manifest
|
|
40
|
+
.describe("Manifest for app version locking and action configurations");
|
|
17
41
|
export const ManifestPluginOptionsSchema = z.object({
|
|
18
42
|
manifestPath: z.string().optional().describe("Path to manifest file"),
|
|
19
43
|
manifest: z
|
|
@@ -13,18 +13,18 @@ export declare const RelayRequestSchema: z.ZodObject<{
|
|
|
13
13
|
}, "strip", z.ZodTypeAny, {
|
|
14
14
|
url: string;
|
|
15
15
|
method?: "POST" | "GET" | "PUT" | "DELETE" | "PATCH" | "HEAD" | "OPTIONS" | undefined;
|
|
16
|
+
authenticationId?: number | undefined;
|
|
16
17
|
headers?: Record<string, string> | [string, string][] | Headers | undefined;
|
|
17
18
|
body?: any;
|
|
18
|
-
authenticationId?: number | undefined;
|
|
19
19
|
callbackUrl?: string | undefined;
|
|
20
20
|
authenticationTemplate?: string | undefined;
|
|
21
21
|
relayBaseUrl?: string | undefined;
|
|
22
22
|
}, {
|
|
23
23
|
url: string;
|
|
24
24
|
method?: "POST" | "GET" | "PUT" | "DELETE" | "PATCH" | "HEAD" | "OPTIONS" | undefined;
|
|
25
|
+
authenticationId?: number | undefined;
|
|
25
26
|
headers?: Record<string, string> | [string, string][] | Headers | undefined;
|
|
26
27
|
body?: any;
|
|
27
|
-
authenticationId?: number | undefined;
|
|
28
28
|
callbackUrl?: string | undefined;
|
|
29
29
|
authenticationTemplate?: string | undefined;
|
|
30
30
|
relayBaseUrl?: string | undefined;
|
|
@@ -47,18 +47,18 @@ export declare const RelayFetchSchema: z.ZodObject<{
|
|
|
47
47
|
}, "strip", z.ZodTypeAny, {
|
|
48
48
|
url: string;
|
|
49
49
|
method?: "POST" | "GET" | "PUT" | "DELETE" | "PATCH" | "HEAD" | "OPTIONS" | undefined;
|
|
50
|
+
authenticationId?: number | undefined;
|
|
50
51
|
headers?: Record<string, string> | [string, string][] | Headers | undefined;
|
|
51
52
|
body?: any;
|
|
52
|
-
authenticationId?: number | undefined;
|
|
53
53
|
callbackUrl?: string | undefined;
|
|
54
54
|
authenticationTemplate?: string | undefined;
|
|
55
55
|
relayBaseUrl?: string | undefined;
|
|
56
56
|
}, {
|
|
57
57
|
url: string;
|
|
58
58
|
method?: "POST" | "GET" | "PUT" | "DELETE" | "PATCH" | "HEAD" | "OPTIONS" | undefined;
|
|
59
|
+
authenticationId?: number | undefined;
|
|
59
60
|
headers?: Record<string, string> | [string, string][] | Headers | undefined;
|
|
60
61
|
body?: any;
|
|
61
|
-
authenticationId?: number | undefined;
|
|
62
62
|
callbackUrl?: string | undefined;
|
|
63
63
|
authenticationTemplate?: string | undefined;
|
|
64
64
|
relayBaseUrl?: string | undefined;
|
|
@@ -14,22 +14,22 @@ export declare const RunActionSchema: z.ZodObject<{
|
|
|
14
14
|
cursor: z.ZodOptional<z.ZodString>;
|
|
15
15
|
}, "strip", z.ZodTypeAny, {
|
|
16
16
|
appKey: string;
|
|
17
|
-
actionType: "search" | "filter" | "read" | "read_bulk" | "run" | "search_and_write" | "search_or_write" | "write";
|
|
18
17
|
actionKey: string;
|
|
19
|
-
|
|
20
|
-
maxItems?: number | undefined;
|
|
21
|
-
pageSize?: number | undefined;
|
|
18
|
+
actionType: "search" | "filter" | "read" | "read_bulk" | "run" | "search_and_write" | "search_or_write" | "write";
|
|
22
19
|
authenticationId?: number | null | undefined;
|
|
23
20
|
inputs?: Record<string, unknown> | undefined;
|
|
21
|
+
pageSize?: number | undefined;
|
|
22
|
+
maxItems?: number | undefined;
|
|
23
|
+
cursor?: string | undefined;
|
|
24
24
|
}, {
|
|
25
25
|
appKey: string;
|
|
26
|
-
actionType: "search" | "filter" | "read" | "read_bulk" | "run" | "search_and_write" | "search_or_write" | "write";
|
|
27
26
|
actionKey: string;
|
|
28
|
-
|
|
29
|
-
maxItems?: number | undefined;
|
|
30
|
-
pageSize?: number | undefined;
|
|
27
|
+
actionType: "search" | "filter" | "read" | "read_bulk" | "run" | "search_and_write" | "search_or_write" | "write";
|
|
31
28
|
authenticationId?: number | null | undefined;
|
|
32
29
|
inputs?: Record<string, unknown> | undefined;
|
|
30
|
+
pageSize?: number | undefined;
|
|
31
|
+
maxItems?: number | undefined;
|
|
32
|
+
cursor?: string | undefined;
|
|
33
33
|
}>;
|
|
34
34
|
export type RunActionOptions = z.infer<typeof RunActionSchema>;
|
|
35
35
|
export interface RunActionPage {
|
package/dist/sdk.d.ts
CHANGED
|
@@ -20,11 +20,33 @@ export declare function createZapierSdkWithoutRegistry(options?: ZapierSdkOption
|
|
|
20
20
|
} & {
|
|
21
21
|
getVersionedImplementationId: import("./plugins/manifest/schemas").GetVersionedImplementationId;
|
|
22
22
|
resolveAppKeys: import("./plugins/manifest/schemas").ResolveAppKeys;
|
|
23
|
-
updateManifestEntry: (options: import(".").UpdateManifestEntryOptions) => Promise<
|
|
23
|
+
updateManifestEntry: (options: import(".").UpdateManifestEntryOptions) => Promise<import(".").UpdateManifestEntryResult>;
|
|
24
|
+
addActionEntry: (options: import(".").AddActionEntryOptions) => Promise<import(".").AddActionEntryResult>;
|
|
25
|
+
findActionEntry: (options: {
|
|
26
|
+
name: string;
|
|
27
|
+
manifest: import(".").Manifest;
|
|
28
|
+
}) => import(".").ActionEntry | null;
|
|
29
|
+
listActionEntries: (options?: {
|
|
30
|
+
configPath?: string;
|
|
31
|
+
}) => Promise<Array<[string, import(".").ActionEntry]>>;
|
|
32
|
+
deleteActionEntry: (options: {
|
|
33
|
+
name: string;
|
|
34
|
+
configPath?: string;
|
|
35
|
+
skipWrite?: boolean;
|
|
36
|
+
}) => Promise<import(".").Manifest>;
|
|
37
|
+
hasActionEntry: (options: {
|
|
38
|
+
name: string;
|
|
39
|
+
manifest: import(".").Manifest;
|
|
40
|
+
}) => boolean;
|
|
41
|
+
findManifestEntry: (options: {
|
|
42
|
+
appKey: string;
|
|
43
|
+
manifest: import(".").Manifest;
|
|
44
|
+
}) => [string, import(".").ManifestEntry] | null;
|
|
45
|
+
readManifestFromFile: (filePath: string) => Promise<import(".").Manifest | null>;
|
|
24
46
|
} & {
|
|
25
47
|
meta: {
|
|
26
48
|
listApps: {
|
|
27
|
-
inputSchema: typeof import("./
|
|
49
|
+
inputSchema: typeof import("./temporary-internal-core").ListAppsOptionsSchema;
|
|
28
50
|
};
|
|
29
51
|
};
|
|
30
52
|
} & {
|
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;AA2BxB,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
|
|
1
|
+
{"version":3,"file":"sdk.d.ts","sourceRoot":"","sources":["../src/sdk.ts"],"names":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AG,SAAS,CAMzE"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Handler for listApps operation
|
|
3
|
+
*
|
|
4
|
+
* This handler will become an SDK API endpoint handler.
|
|
5
|
+
* It encapsulates the business logic for listing apps, including:
|
|
6
|
+
* - Search augmentation (merging search results with specified apps)
|
|
7
|
+
* - API calls to internal services
|
|
8
|
+
* - Response transformation
|
|
9
|
+
* - Pagination with latest_only support
|
|
10
|
+
*
|
|
11
|
+
* Note: App key resolution (slugs → implementation IDs) happens in the SDK plugin.
|
|
12
|
+
* The handler receives pre-resolved implementation IDs and performs search augmentation.
|
|
13
|
+
*/
|
|
14
|
+
import type { Handler, HandlerDeps } from "../types";
|
|
15
|
+
import { type ListAppsHandlerRequest, type ListAppsResponse } from "../schemas/apps";
|
|
16
|
+
/**
|
|
17
|
+
* Simple HTTP client interface for calling internal APIs
|
|
18
|
+
*
|
|
19
|
+
* Why pass this as a dependency instead of importing directly?
|
|
20
|
+
*
|
|
21
|
+
* 1. **Different implementations in different contexts:**
|
|
22
|
+
* - In the SDK: Uses the ApiClient wrapper (adds auth, error handling, etc.)
|
|
23
|
+
* - In the SDK API: Would use internal HTTP client or direct service calls
|
|
24
|
+
*
|
|
25
|
+
* 2. **Testability:**
|
|
26
|
+
* - Can mock httpClient in tests without complex setup
|
|
27
|
+
* - Can verify API calls and responses in isolation
|
|
28
|
+
*
|
|
29
|
+
* 3. **No hard coupling:**
|
|
30
|
+
* - Handler doesn't know/care how HTTP calls are made
|
|
31
|
+
* - Makes migration to SDK API easier (just swap implementation)
|
|
32
|
+
*/
|
|
33
|
+
export interface HttpClient {
|
|
34
|
+
get<T = unknown>(path: string, options?: {
|
|
35
|
+
searchParams?: Record<string, string>;
|
|
36
|
+
}): Promise<T>;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Dependencies required by the listApps handler
|
|
40
|
+
*
|
|
41
|
+
* Passed as a parameter (dependency injection) rather than imported directly
|
|
42
|
+
* to allow different implementations in different environments:
|
|
43
|
+
* - SDK plugin injects: { httpClient: api } (SDK's ApiClient)
|
|
44
|
+
* - SDK API would inject: { httpClient: internalHttpClient } (direct internal calls)
|
|
45
|
+
* - Tests inject: { httpClient: mockHttpClient } (mocked responses)
|
|
46
|
+
*
|
|
47
|
+
* Extends HandlerDeps to ensure compatibility with the Handler interface.
|
|
48
|
+
*/
|
|
49
|
+
export interface ListAppsHandlerDeps extends HandlerDeps {
|
|
50
|
+
httpClient: HttpClient;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Handles listApps operation
|
|
54
|
+
*
|
|
55
|
+
* Conforms to the Handler<TRequest, TResponse, TDeps> interface contract.
|
|
56
|
+
* Validates and normalizes the request at the handler boundary before processing.
|
|
57
|
+
*
|
|
58
|
+
* Accepts flexible input types (via schema):
|
|
59
|
+
* - implementationIds: string (comma-separated) or string[]
|
|
60
|
+
* - pageSize: string or number
|
|
61
|
+
*
|
|
62
|
+
* @param request - The request with pre-resolved implementation IDs (handler performs search augmentation)
|
|
63
|
+
* @param deps - Dependencies injected by the caller (see ListAppsHandlerDeps for why we use DI)
|
|
64
|
+
* @returns Paginated list of apps with normalized data
|
|
65
|
+
*/
|
|
66
|
+
export declare const handleListApps: Handler<ListAppsHandlerRequest, ListAppsResponse, ListAppsHandlerDeps>;
|
|
67
|
+
//# sourceMappingURL=listApps.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"listApps.d.ts","sourceRoot":"","sources":["../../../src/temporary-internal-core/handlers/listApps.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AACrD,OAAO,EAEL,KAAK,sBAAsB,EAC3B,KAAK,gBAAgB,EACtB,MAAM,iBAAiB,CAAC;AAkBzB;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,WAAW,UAAU;IACzB,GAAG,CAAC,CAAC,GAAG,OAAO,EACb,IAAI,EAAE,MAAM,EACZ,OAAO,CAAC,EAAE;QAAE,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;KAAE,GAClD,OAAO,CAAC,CAAC,CAAC,CAAC;CACf;AAED;;;;;;;;;;GAUG;AACH,MAAM,WAAW,mBAAoB,SAAQ,WAAW;IACtD,UAAU,EAAE,UAAU,CAAC;CACxB;AAwDD;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,cAAc,EAAE,OAAO,CAClC,sBAAsB,EACtB,gBAAgB,EAChB,mBAAmB,CA+EpB,CAAC"}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Handler for listApps operation
|
|
3
|
+
*
|
|
4
|
+
* This handler will become an SDK API endpoint handler.
|
|
5
|
+
* It encapsulates the business logic for listing apps, including:
|
|
6
|
+
* - Search augmentation (merging search results with specified apps)
|
|
7
|
+
* - API calls to internal services
|
|
8
|
+
* - Response transformation
|
|
9
|
+
* - Pagination with latest_only support
|
|
10
|
+
*
|
|
11
|
+
* Note: App key resolution (slugs → implementation IDs) happens in the SDK plugin.
|
|
12
|
+
* The handler receives pre-resolved implementation IDs and performs search augmentation.
|
|
13
|
+
*/
|
|
14
|
+
import { ListAppsHandlerRequestSchema, } from "../schemas/apps";
|
|
15
|
+
import { splitVersionedKey } from "../utils/app-locators";
|
|
16
|
+
import { transformImplementationMetaToAppItem, extractPaginationCursor, } from "../utils/transformations";
|
|
17
|
+
// ============================================================================
|
|
18
|
+
// Constants
|
|
19
|
+
// ============================================================================
|
|
20
|
+
const DEFAULT_PAGE_SIZE = 20;
|
|
21
|
+
// ============================================================================
|
|
22
|
+
// Business Logic Helpers
|
|
23
|
+
// ============================================================================
|
|
24
|
+
/**
|
|
25
|
+
* Augments implementation IDs with search results
|
|
26
|
+
*
|
|
27
|
+
* Calls the search endpoint and merges results with existing implementation IDs,
|
|
28
|
+
* deduplicating by implementation name (without version).
|
|
29
|
+
*/
|
|
30
|
+
async function augmentWithSearchResults({ searchTerm, implementationIds, httpClient, }) {
|
|
31
|
+
const searchResponse = await httpClient.get("/zapier/api/v4/implementations-meta/search/", {
|
|
32
|
+
searchParams: { term: searchTerm },
|
|
33
|
+
});
|
|
34
|
+
const searchResults = searchResponse.results.map(transformImplementationMetaToAppItem);
|
|
35
|
+
const implementationNameSet = new Set(implementationIds.map((id) => {
|
|
36
|
+
const [name] = splitVersionedKey(id);
|
|
37
|
+
return name;
|
|
38
|
+
}));
|
|
39
|
+
const additionalIds = [];
|
|
40
|
+
for (const result of searchResults) {
|
|
41
|
+
const [implementationName] = splitVersionedKey(result.key);
|
|
42
|
+
if (!implementationNameSet.has(implementationName)) {
|
|
43
|
+
implementationNameSet.add(implementationName);
|
|
44
|
+
// Use the full implementation_id from the result
|
|
45
|
+
additionalIds.push(result.implementation_id);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
return [...implementationIds, ...additionalIds];
|
|
49
|
+
}
|
|
50
|
+
// ============================================================================
|
|
51
|
+
// Main Handler
|
|
52
|
+
// ============================================================================
|
|
53
|
+
/**
|
|
54
|
+
* Handles listApps operation
|
|
55
|
+
*
|
|
56
|
+
* Conforms to the Handler<TRequest, TResponse, TDeps> interface contract.
|
|
57
|
+
* Validates and normalizes the request at the handler boundary before processing.
|
|
58
|
+
*
|
|
59
|
+
* Accepts flexible input types (via schema):
|
|
60
|
+
* - implementationIds: string (comma-separated) or string[]
|
|
61
|
+
* - pageSize: string or number
|
|
62
|
+
*
|
|
63
|
+
* @param request - The request with pre-resolved implementation IDs (handler performs search augmentation)
|
|
64
|
+
* @param deps - Dependencies injected by the caller (see ListAppsHandlerDeps for why we use DI)
|
|
65
|
+
* @returns Paginated list of apps with normalized data
|
|
66
|
+
*/
|
|
67
|
+
export const handleListApps = async ({ request, deps }) => {
|
|
68
|
+
// Validate and normalize request at handler boundary
|
|
69
|
+
// Schema automatically normalizes:
|
|
70
|
+
// - implementationIds: string → string[]
|
|
71
|
+
// - pageSize: string → number
|
|
72
|
+
const validatedRequest = ListAppsHandlerRequestSchema.parse(request);
|
|
73
|
+
const { httpClient } = deps;
|
|
74
|
+
let { implementationIds } = validatedRequest;
|
|
75
|
+
const pageSize = validatedRequest.pageSize ?? DEFAULT_PAGE_SIZE;
|
|
76
|
+
if (validatedRequest.search) {
|
|
77
|
+
implementationIds = await augmentWithSearchResults({
|
|
78
|
+
searchTerm: validatedRequest.search,
|
|
79
|
+
implementationIds,
|
|
80
|
+
httpClient,
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
if (implementationIds.length === 0) {
|
|
84
|
+
// If search was provided but found nothing, return empty (bug fix)
|
|
85
|
+
if (validatedRequest.search) {
|
|
86
|
+
return {
|
|
87
|
+
data: [],
|
|
88
|
+
nextCursor: undefined,
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
const searchParams = {
|
|
92
|
+
latest_only: "true",
|
|
93
|
+
selected_apis: "",
|
|
94
|
+
limit: pageSize.toString(),
|
|
95
|
+
};
|
|
96
|
+
if (validatedRequest.cursor) {
|
|
97
|
+
searchParams.offset = validatedRequest.cursor;
|
|
98
|
+
}
|
|
99
|
+
const implementationsResponse = await httpClient.get("/zapier/api/v4/implementations-meta/lookup/", {
|
|
100
|
+
searchParams,
|
|
101
|
+
});
|
|
102
|
+
return {
|
|
103
|
+
data: implementationsResponse.results.map(transformImplementationMetaToAppItem),
|
|
104
|
+
nextCursor: extractPaginationCursor(implementationsResponse),
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
const searchParams = {
|
|
108
|
+
selected_apis: implementationIds.join(","),
|
|
109
|
+
limit: pageSize.toString(),
|
|
110
|
+
};
|
|
111
|
+
if (validatedRequest.cursor) {
|
|
112
|
+
searchParams.offset = validatedRequest.cursor;
|
|
113
|
+
}
|
|
114
|
+
const implementationsResponse = await httpClient.get("/zapier/api/v4/implementations-meta/lookup/", {
|
|
115
|
+
searchParams,
|
|
116
|
+
});
|
|
117
|
+
return {
|
|
118
|
+
data: implementationsResponse.results.map(transformImplementationMetaToAppItem),
|
|
119
|
+
nextCursor: extractPaginationCursor(implementationsResponse),
|
|
120
|
+
};
|
|
121
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"listApps.test.d.ts","sourceRoot":"","sources":["../../../src/temporary-internal-core/handlers/listApps.test.ts"],"names":[],"mappings":""}
|