@zapier/zapier-sdk 0.5.2 → 0.6.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 +11 -0
- package/README.md +107 -83
- package/dist/index.cjs +320 -50
- package/dist/index.d.mts +409 -340
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +0 -1
- package/dist/index.mjs +320 -50
- package/dist/plugins/api/index.js +1 -1
- package/dist/plugins/findFirstAuthentication/index.d.ts.map +1 -1
- package/dist/plugins/findFirstAuthentication/index.js +1 -0
- package/dist/plugins/findUniqueAuthentication/index.d.ts.map +1 -1
- package/dist/plugins/findUniqueAuthentication/index.js +1 -0
- package/dist/plugins/getAction/index.d.ts.map +1 -1
- package/dist/plugins/getAction/index.js +1 -0
- package/dist/plugins/getAction/index.test.js +1 -1
- package/dist/plugins/getApp/index.d.ts +6 -3
- package/dist/plugins/getApp/index.d.ts.map +1 -1
- package/dist/plugins/getApp/index.js +8 -18
- package/dist/plugins/getApp/index.test.js +2 -0
- package/dist/plugins/getAuthentication/index.d.ts.map +1 -1
- package/dist/plugins/getAuthentication/index.js +1 -0
- package/dist/plugins/getAuthentication/index.test.js +12 -1
- package/dist/plugins/getProfile/index.d.ts.map +1 -1
- package/dist/plugins/getProfile/index.js +1 -0
- package/dist/plugins/listActions/index.d.ts +5 -3
- package/dist/plugins/listActions/index.d.ts.map +1 -1
- package/dist/plugins/listActions/index.js +6 -6
- package/dist/plugins/listActions/index.test.js +26 -74
- package/dist/plugins/listActions/schemas.d.ts +4 -4
- package/dist/plugins/listApps/index.d.ts.map +1 -1
- package/dist/plugins/listApps/index.js +1 -0
- package/dist/plugins/listApps/schemas.d.ts +2 -2
- package/dist/plugins/listAuthentications/index.d.ts +4 -2
- package/dist/plugins/listAuthentications/index.d.ts.map +1 -1
- package/dist/plugins/listAuthentications/index.js +9 -12
- package/dist/plugins/listAuthentications/index.test.js +33 -40
- package/dist/plugins/listAuthentications/schemas.d.ts +4 -4
- package/dist/plugins/listInputFields/index.d.ts +3 -1
- package/dist/plugins/listInputFields/index.d.ts.map +1 -1
- package/dist/plugins/listInputFields/index.js +5 -5
- package/dist/plugins/listInputFields/index.test.js +10 -8
- package/dist/plugins/listInputFields/schemas.d.ts +4 -4
- package/dist/plugins/lockVersion/index.d.ts +24 -0
- package/dist/plugins/lockVersion/index.d.ts.map +1 -0
- package/dist/plugins/lockVersion/index.js +72 -0
- package/dist/plugins/lockVersion/index.test.d.ts +2 -0
- package/dist/plugins/lockVersion/index.test.d.ts.map +1 -0
- package/dist/plugins/lockVersion/index.test.js +129 -0
- package/dist/plugins/lockVersion/schemas.d.ts +10 -0
- package/dist/plugins/lockVersion/schemas.d.ts.map +1 -0
- package/dist/plugins/lockVersion/schemas.js +6 -0
- package/dist/plugins/manifest/index.d.ts +24 -0
- package/dist/plugins/manifest/index.d.ts.map +1 -0
- package/dist/plugins/manifest/index.js +119 -0
- package/dist/plugins/manifest/index.test.d.ts +2 -0
- package/dist/plugins/manifest/index.test.d.ts.map +1 -0
- package/dist/plugins/manifest/index.test.js +331 -0
- package/dist/plugins/manifest/schemas.d.ts +64 -0
- package/dist/plugins/manifest/schemas.d.ts.map +1 -0
- package/dist/plugins/manifest/schemas.js +25 -0
- package/dist/plugins/registry/index.d.ts +9 -1
- package/dist/plugins/registry/index.d.ts.map +1 -1
- package/dist/plugins/registry/index.js +68 -3
- package/dist/plugins/request/index.d.ts.map +1 -1
- package/dist/plugins/request/index.js +1 -0
- package/dist/plugins/request/index.test.js +6 -1
- package/dist/plugins/request/schemas.d.ts +4 -4
- package/dist/plugins/runAction/index.d.ts +2 -0
- package/dist/plugins/runAction/index.d.ts.map +1 -1
- package/dist/plugins/runAction/index.js +5 -5
- package/dist/plugins/runAction/index.test.js +9 -8
- package/dist/plugins/runAction/schemas.d.ts +4 -4
- package/dist/sdk.d.ts +3 -3
- package/dist/sdk.d.ts.map +1 -1
- package/dist/sdk.js +18 -7
- package/dist/sdk.test.js +1 -1
- package/dist/types/plugin.d.ts +10 -2
- package/dist/types/plugin.d.ts.map +1 -1
- package/dist/types/sdk.d.ts +13 -2
- package/dist/types/sdk.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/index.ts +0 -2
- package/src/plugins/api/index.ts +1 -1
- package/src/plugins/findFirstAuthentication/index.ts +1 -0
- package/src/plugins/findUniqueAuthentication/index.ts +1 -0
- package/src/plugins/getAction/index.test.ts +1 -1
- package/src/plugins/getAction/index.ts +1 -0
- package/src/plugins/getApp/index.test.ts +2 -0
- package/src/plugins/getApp/index.ts +12 -24
- package/src/plugins/getAuthentication/index.test.ts +13 -3
- package/src/plugins/getAuthentication/index.ts +1 -0
- package/src/plugins/getProfile/index.ts +1 -0
- package/src/plugins/listActions/index.test.ts +30 -89
- package/src/plugins/listActions/index.ts +13 -9
- package/src/plugins/listApps/index.ts +1 -0
- package/src/plugins/listAuthentications/index.test.ts +38 -47
- package/src/plugins/listAuthentications/index.ts +21 -18
- package/src/plugins/listInputFields/index.test.ts +12 -9
- package/src/plugins/listInputFields/index.ts +10 -6
- package/src/plugins/lockVersion/index.test.ts +176 -0
- package/src/plugins/lockVersion/index.ts +112 -0
- package/src/plugins/lockVersion/schemas.ts +9 -0
- package/src/plugins/manifest/index.test.ts +439 -0
- package/src/plugins/manifest/index.ts +171 -0
- package/src/plugins/manifest/schemas.ts +53 -0
- package/src/plugins/registry/index.ts +89 -8
- package/src/plugins/request/index.test.ts +8 -4
- package/src/plugins/request/index.ts +1 -0
- package/src/plugins/runAction/index.test.ts +9 -8
- package/src/plugins/runAction/index.ts +13 -7
- package/src/sdk.test.ts +1 -1
- package/src/sdk.ts +22 -7
- package/src/types/plugin.ts +14 -2
- package/src/types/sdk.ts +15 -1
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -36,13 +36,14 @@ describe("runAction plugin", () => {
|
|
|
36
36
|
mockGetAction = vi.fn().mockResolvedValue({
|
|
37
37
|
data: mockAction,
|
|
38
38
|
});
|
|
39
|
-
mockGetApp = vi.fn().mockResolvedValue({
|
|
40
|
-
data: { current_implementation_id: "SlackCLIAPI" },
|
|
41
|
-
});
|
|
42
39
|
});
|
|
43
40
|
function createTestSdk() {
|
|
44
|
-
return createSdk({ getAction: mockGetAction, getApp: mockGetApp }, // Provide getAction and getApp in SDK
|
|
45
|
-
{
|
|
41
|
+
return createSdk({}, { getAction: mockGetAction, getApp: mockGetApp }, // Provide getAction and getApp in SDK
|
|
42
|
+
{
|
|
43
|
+
api: mockApiClient,
|
|
44
|
+
meta: {},
|
|
45
|
+
getVersionedImplementationId: () => "SlackCLIAPI@1.21.1",
|
|
46
|
+
}).addPlugin(runActionPlugin);
|
|
46
47
|
}
|
|
47
48
|
describe("schema validation", () => {
|
|
48
49
|
it("should throw validation error for missing appKey", () => {
|
|
@@ -126,7 +127,7 @@ describe("runAction plugin", () => {
|
|
|
126
127
|
});
|
|
127
128
|
expect(mockApiClient.post).toHaveBeenCalledWith("/api/actions/v1/runs", {
|
|
128
129
|
data: {
|
|
129
|
-
selected_api: "SlackCLIAPI",
|
|
130
|
+
selected_api: "SlackCLIAPI@1.21.1",
|
|
130
131
|
action_key: "send_message",
|
|
131
132
|
action_type: "write",
|
|
132
133
|
inputs: { message: "Hello", channel: "#general" },
|
|
@@ -149,7 +150,7 @@ describe("runAction plugin", () => {
|
|
|
149
150
|
});
|
|
150
151
|
expect(mockApiClient.post).toHaveBeenCalledWith("/api/actions/v1/runs", {
|
|
151
152
|
data: {
|
|
152
|
-
selected_api: "SlackCLIAPI",
|
|
153
|
+
selected_api: "SlackCLIAPI@1.21.1",
|
|
153
154
|
action_key: "send_message",
|
|
154
155
|
action_type: "write",
|
|
155
156
|
inputs: { message: "Hello" },
|
|
@@ -170,7 +171,7 @@ describe("runAction plugin", () => {
|
|
|
170
171
|
expect(mockApiClient.post).toHaveBeenCalledWith("/api/actions/v1/runs", expect.objectContaining({
|
|
171
172
|
data: expect.objectContaining({
|
|
172
173
|
inputs: { message: "Hello" },
|
|
173
|
-
selected_api: "SlackCLIAPI",
|
|
174
|
+
selected_api: "SlackCLIAPI@1.21.1",
|
|
174
175
|
action_key: "send_message",
|
|
175
176
|
action_type: "write",
|
|
176
177
|
}),
|
|
@@ -13,17 +13,17 @@ export declare const RunActionSchema: z.ZodObject<{
|
|
|
13
13
|
actionType: "filter" | "read" | "read_bulk" | "run" | "search" | "search_and_write" | "search_or_write" | "write";
|
|
14
14
|
actionKey: string;
|
|
15
15
|
authenticationId?: number | null | undefined;
|
|
16
|
-
maxItems?: number | undefined;
|
|
17
|
-
pageSize?: number | undefined;
|
|
18
16
|
inputs?: Record<string, any> | undefined;
|
|
17
|
+
pageSize?: number | undefined;
|
|
18
|
+
maxItems?: number | undefined;
|
|
19
19
|
}, {
|
|
20
20
|
appKey: string;
|
|
21
21
|
actionType: "filter" | "read" | "read_bulk" | "run" | "search" | "search_and_write" | "search_or_write" | "write";
|
|
22
22
|
actionKey: string;
|
|
23
23
|
authenticationId?: number | null | undefined;
|
|
24
|
-
maxItems?: number | undefined;
|
|
25
|
-
pageSize?: number | undefined;
|
|
26
24
|
inputs?: Record<string, any> | undefined;
|
|
25
|
+
pageSize?: number | undefined;
|
|
26
|
+
maxItems?: number | undefined;
|
|
27
27
|
}>;
|
|
28
28
|
export type RunActionOptions = z.infer<typeof RunActionSchema>;
|
|
29
29
|
export interface RunActionPage {
|
package/dist/sdk.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { BaseSdkOptions } from "./types/sdk";
|
|
2
2
|
import type { ZapierSdk } from "./types/sdk";
|
|
3
|
-
import type { Sdk } from "./types/plugin";
|
|
3
|
+
import type { Sdk, PluginMeta } from "./types/plugin";
|
|
4
4
|
export interface ZapierSdkOptions extends BaseSdkOptions {
|
|
5
5
|
}
|
|
6
6
|
export declare function createSdk<TCurrentSdk = {}, TCurrentContext = {
|
|
7
|
-
meta: Record<string,
|
|
8
|
-
}>(initialSdk?: TCurrentSdk, initialContext?: TCurrentContext): Sdk<TCurrentSdk, TCurrentContext>;
|
|
7
|
+
meta: Record<string, PluginMeta>;
|
|
8
|
+
}>(options?: ZapierSdkOptions, initialSdk?: TCurrentSdk, initialContext?: TCurrentContext): Sdk<TCurrentSdk, TCurrentContext>;
|
|
9
9
|
export declare function createZapierSdk(options?: ZapierSdkOptions): ZapierSdk;
|
|
10
10
|
//# sourceMappingURL=sdk.d.ts.map
|
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,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAM7C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,KAAK,EACV,GAAG,
|
|
1
|
+
{"version":3,"file":"sdk.d.ts","sourceRoot":"","sources":["../src/sdk.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAM7C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,KAAK,EACV,GAAG,EAIH,UAAU,EACX,MAAM,gBAAgB,CAAC;AAyBxB,MAAM,WAAW,gBAAiB,SAAQ,cAAc;CAAG;AAG3D,wBAAgB,SAAS,CACvB,WAAW,GAAG,EAAE,EAChB,eAAe,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,CAAA;CAAE,EAEtD,OAAO,GAAE,gBAAqB,EAC9B,UAAU,GAAE,WAA+B,EAC3C,cAAc,GAAE,eAAiD,GAChE,GAAG,CAAC,WAAW,EAAE,eAAe,CAAC,CAqEnC;AAED,wBAAgB,eAAe,CAAC,OAAO,GAAE,gBAAqB,GAAG,SAAS,CAyCzE"}
|
package/dist/sdk.js
CHANGED
|
@@ -15,12 +15,14 @@ import { findFirstAuthenticationPlugin } from "./plugins/findFirstAuthentication
|
|
|
15
15
|
import { findUniqueAuthenticationPlugin } from "./plugins/findUniqueAuthentication";
|
|
16
16
|
import { listInputFieldsPlugin } from "./plugins/listInputFields";
|
|
17
17
|
import { requestPlugin } from "./plugins/request";
|
|
18
|
+
import { manifestPlugin } from "./plugins/manifest";
|
|
19
|
+
import { lockVersionPlugin } from "./plugins/lockVersion";
|
|
18
20
|
// Create SDK that supports flat plugins - returns an SDK, not a builder
|
|
19
|
-
export function createSdk(initialSdk = {}, initialContext = { meta: {} }) {
|
|
21
|
+
export function createSdk(options = {}, initialSdk = {}, initialContext = { meta: {} }) {
|
|
20
22
|
return {
|
|
21
23
|
...initialSdk,
|
|
22
24
|
getContext: () => initialContext,
|
|
23
|
-
addPlugin(plugin,
|
|
25
|
+
addPlugin(plugin, addPluginOptions = {}) {
|
|
24
26
|
// Create SDK with getContext method for plugins to use
|
|
25
27
|
const currentSdkWithContext = {
|
|
26
28
|
...initialSdk,
|
|
@@ -29,8 +31,12 @@ export function createSdk(initialSdk = {}, initialContext = { meta: {} }) {
|
|
|
29
31
|
// Apply the plugin with options merged in
|
|
30
32
|
const pluginResult = plugin({
|
|
31
33
|
sdk: currentSdkWithContext,
|
|
32
|
-
context:
|
|
33
|
-
|
|
34
|
+
context: {
|
|
35
|
+
...initialContext,
|
|
36
|
+
// Add the options that createSdk was called with to context
|
|
37
|
+
options,
|
|
38
|
+
},
|
|
39
|
+
...addPluginOptions,
|
|
34
40
|
});
|
|
35
41
|
// Extract context from plugin result if present
|
|
36
42
|
const { context: pluginContext, ...sdkProperties } = pluginResult;
|
|
@@ -40,6 +46,7 @@ export function createSdk(initialSdk = {}, initialContext = { meta: {} }) {
|
|
|
40
46
|
// Ensure meta is always present, starting with existing or empty object
|
|
41
47
|
let newContext = {
|
|
42
48
|
...initialContext,
|
|
49
|
+
...addPluginOptions,
|
|
43
50
|
meta: initialContext.meta || {},
|
|
44
51
|
};
|
|
45
52
|
if (pluginContext) {
|
|
@@ -61,22 +68,26 @@ export function createSdk(initialSdk = {}, initialContext = { meta: {} }) {
|
|
|
61
68
|
}
|
|
62
69
|
}
|
|
63
70
|
// Recursively create new SDK with updated properties
|
|
64
|
-
return createSdk(newSdk, newContext);
|
|
71
|
+
return createSdk(options, newSdk, newContext);
|
|
65
72
|
},
|
|
66
73
|
};
|
|
67
74
|
}
|
|
68
75
|
export function createZapierSdk(options = {}) {
|
|
69
|
-
return (createSdk()
|
|
76
|
+
return (createSdk(options)
|
|
70
77
|
// Provides the API client in context
|
|
71
|
-
.addPlugin(apiPlugin
|
|
78
|
+
.addPlugin(apiPlugin)
|
|
79
|
+
// Manifest plugin (provides version locking context)
|
|
72
80
|
// Apps/actions/fields
|
|
73
81
|
.addPlugin(listAppsPlugin)
|
|
82
|
+
.addPlugin(manifestPlugin)
|
|
74
83
|
.addPlugin(getAppPlugin)
|
|
75
84
|
.addPlugin(listActionsPlugin)
|
|
76
85
|
.addPlugin(getActionPlugin)
|
|
77
86
|
.addPlugin(listInputFieldsPlugin)
|
|
78
87
|
// Run action
|
|
79
88
|
.addPlugin(runActionPlugin)
|
|
89
|
+
// Version locking
|
|
90
|
+
.addPlugin(lockVersionPlugin)
|
|
80
91
|
// Authentications
|
|
81
92
|
.addPlugin(listAuthenticationsPlugin)
|
|
82
93
|
.addPlugin(getAuthenticationPlugin)
|
package/dist/sdk.test.js
CHANGED
|
@@ -113,7 +113,7 @@ describe("Flat Plugin System", () => {
|
|
|
113
113
|
});
|
|
114
114
|
const baseSdk = { existingMethod: () => "base" };
|
|
115
115
|
const baseContext = { customContext: "custom", meta: {} };
|
|
116
|
-
const sdk = createSdk(baseSdk, baseContext).addPlugin(pluginWithHelper);
|
|
116
|
+
const sdk = createSdk({}, baseSdk, baseContext).addPlugin(pluginWithHelper);
|
|
117
117
|
expect(sdk.helperMethod()).toBe("Helper: base + custom");
|
|
118
118
|
expect(sdk.existingMethod()).toBe("base"); // Original method still works
|
|
119
119
|
});
|
package/dist/types/plugin.d.ts
CHANGED
|
@@ -6,6 +6,8 @@
|
|
|
6
6
|
* This system makes context dependencies explicit to restore TypeScript's
|
|
7
7
|
* ability to catch missing context at compile time.
|
|
8
8
|
*/
|
|
9
|
+
import type { z } from "zod";
|
|
10
|
+
import { BaseSdkOptions } from "./sdk";
|
|
9
11
|
export interface PluginDependencies<TSdk = {}, TContext = {}> {
|
|
10
12
|
sdk: TSdk;
|
|
11
13
|
context: TContext;
|
|
@@ -13,6 +15,11 @@ export interface PluginDependencies<TSdk = {}, TContext = {}> {
|
|
|
13
15
|
export interface PluginProvides extends Record<string, any> {
|
|
14
16
|
context?: Record<string, any>;
|
|
15
17
|
}
|
|
18
|
+
export interface PluginMeta {
|
|
19
|
+
categories: string[];
|
|
20
|
+
inputSchema: z.ZodSchema;
|
|
21
|
+
[key: string]: any;
|
|
22
|
+
}
|
|
16
23
|
export type ExtractSdkProperties<T extends Record<string, any>> = Omit<T, "context">;
|
|
17
24
|
export type ExtractContextProperties<T extends PluginProvides> = T["context"];
|
|
18
25
|
export type GetSdkType<TPluginProvides extends PluginProvides> = ExtractSdkProperties<TPluginProvides> & {
|
|
@@ -35,7 +42,8 @@ export interface Plugin<TSdk = {}, TRequiresContext = {}, TProvides extends Plug
|
|
|
35
42
|
(params: {
|
|
36
43
|
sdk: TSdk;
|
|
37
44
|
context: TRequiresContext & {
|
|
38
|
-
meta: Record<string,
|
|
45
|
+
meta: Record<string, PluginMeta>;
|
|
46
|
+
options: BaseSdkOptions;
|
|
39
47
|
};
|
|
40
48
|
}): TProvides;
|
|
41
49
|
}
|
|
@@ -50,7 +58,7 @@ type ContextError<TRequired, TCurrent> = MissingContextKeys<TRequired, TCurrent>
|
|
|
50
58
|
* If not, TypeScript will emit a detailed error showing missing properties.
|
|
51
59
|
*/
|
|
52
60
|
export type Sdk<TCurrentSdk = {}, TCurrentContext = {
|
|
53
|
-
meta: Record<string,
|
|
61
|
+
meta: Record<string, PluginMeta>;
|
|
54
62
|
}> = TCurrentSdk & {
|
|
55
63
|
addPlugin<TRequiresContext, TProvides extends PluginProvides>(plugin: Plugin<TCurrentSdk & {
|
|
56
64
|
getContext(): TCurrentContext;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../src/types/plugin.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,MAAM,WAAW,kBAAkB,CAAC,IAAI,GAAG,EAAE,EAAE,QAAQ,GAAG,EAAE;IAC1D,GAAG,EAAE,IAAI,CAAC;IACV,OAAO,EAAE,QAAQ,CAAC;CACnB;AAGD,MAAM,WAAW,cAAe,SAAQ,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;IACzD,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CAC/B;AAGD,MAAM,MAAM,oBAAoB,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,IAAI,IAAI,CACpE,CAAC,EACD,SAAS,CACV,CAAC;AAGF,MAAM,MAAM,wBAAwB,CAAC,CAAC,SAAS,cAAc,IAAI,CAAC,CAAC,SAAS,CAAC,CAAC;AAG9E,MAAM,MAAM,UAAU,CAAC,eAAe,SAAS,cAAc,IAC3D,oBAAoB,CAAC,eAAe,CAAC,GAAG;IACtC,UAAU,IAAI,WAAW,CAAC,wBAAwB,CAAC,eAAe,CAAC,CAAC,CAAC;CACtE,CAAC;AAGJ,MAAM,MAAM,aAAa,CAAC,IAAI,GAAG,EAAE,EAAE,QAAQ,GAAG,EAAE,IAAI;IACpD,GAAG,EAAE,IAAI,CAAC;IACV,OAAO,EAAE,QAAQ,GAAG;QAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;KAAE,CAAC;CACnD,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,WAAW,MAAM,CACrB,IAAI,GAAG,EAAE,EACT,gBAAgB,GAAG,EAAE,EACrB,SAAS,SAAS,cAAc,GAAG,cAAc;IAEjD,CAAC,MAAM,EAAE;QACP,GA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EAChB,eAAe,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,CAAA;CAAE,IACpD,WAAW,GAAG;IAChB,SAAS,CAAC,gBAAgB,EAAE,SAAS,SAAS,cAAc,EAC1D,MAAM,EAAE,MAAM,CACZ,WAAW,GAAG;QAAE,UAAU,IAAI,eAAe,CAAA;KAAE,EAC/C,gBAAgB,EAChB,SAAS,CACV,EACD,OAAO,CAAC,EAAE,GAAG,GACZ,eAAe,SAAS,gBAAgB,GACvC,GAAG,CACD,WAAW,GAAG,oBAAoB,CAAC,SAAS,CAAC,EAC7C,eAAe,GAAG,WAAW,CAAC,wBAAwB,CAAC,SAAS,CAAC,CAAC,CACnE,GACD,YAAY,CAAC,gBAAgB,EAAE,eAAe,CAAC,CAAC;IACpD,UAAU,IAAI,eAAe,CAAC;CAC/B,CAAC"}
|
package/dist/types/sdk.d.ts
CHANGED
|
@@ -9,12 +9,22 @@ export interface BaseSdkOptions {
|
|
|
9
9
|
fetch?: typeof fetch;
|
|
10
10
|
baseUrl?: string;
|
|
11
11
|
debug?: boolean;
|
|
12
|
+
manifestPath?: string;
|
|
13
|
+
manifest?: {
|
|
14
|
+
apps: {
|
|
15
|
+
[appKey: string]: {
|
|
16
|
+
implementationName: string;
|
|
17
|
+
version?: string;
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
};
|
|
12
21
|
}
|
|
13
22
|
import type { ListInputFieldsSdkFunction } from "../plugins/listInputFields/schemas";
|
|
14
23
|
import type { GetAuthenticationSdkFunction } from "../plugins/getAuthentication/schemas";
|
|
15
24
|
import type { FindFirstAuthenticationSdkFunction } from "../plugins/findFirstAuthentication/schemas";
|
|
16
25
|
import type { FindUniqueAuthenticationSdkFunction } from "../plugins/findUniqueAuthentication/schemas";
|
|
17
26
|
import type { RelayRequestSdkFunction } from "../plugins/request/schemas";
|
|
27
|
+
import type { LockVersionPluginProvides } from "../plugins/lockVersion";
|
|
18
28
|
import type { z } from "zod";
|
|
19
29
|
import { RegistryPluginProvides } from "../plugins/registry";
|
|
20
30
|
import { GetProfilePluginProvides } from "../plugins/getProfile";
|
|
@@ -32,12 +42,13 @@ import { FindUniqueAuthenticationPluginProvides } from "../plugins/findUniqueAut
|
|
|
32
42
|
import { ListInputFieldsPluginProvides } from "../plugins/listInputFields";
|
|
33
43
|
import { RequestPluginProvides } from "../plugins/request";
|
|
34
44
|
import { GetSdkType } from "./plugin";
|
|
45
|
+
import { ManifestPluginProvides } from "../plugins/manifest";
|
|
35
46
|
export interface FunctionRegistryEntry {
|
|
36
47
|
name: string;
|
|
37
48
|
inputSchema: z.ZodSchema;
|
|
38
|
-
|
|
49
|
+
categories: string[];
|
|
39
50
|
}
|
|
40
51
|
export interface ZapierSdkFunctions extends ListInputFieldsSdkFunction, GetAuthenticationSdkFunction, FindFirstAuthenticationSdkFunction, FindUniqueAuthenticationSdkFunction, RelayRequestSdkFunction {
|
|
41
52
|
}
|
|
42
|
-
export type ZapierSdk = GetSdkType<RegistryPluginProvides & FetchPluginProvides & AppsPluginProvides & ListAppsPluginProvides & GetAppPluginProvides & ListActionsPluginProvides & GetActionPluginProvides & RunActionPluginProvides & ListAuthenticationsPluginProvides & GetAuthenticationPluginProvides & FindFirstAuthenticationPluginProvides & FindUniqueAuthenticationPluginProvides & ListInputFieldsPluginProvides & RequestPluginProvides & GetProfilePluginProvides>;
|
|
53
|
+
export type ZapierSdk = GetSdkType<RegistryPluginProvides & FetchPluginProvides & AppsPluginProvides & ListAppsPluginProvides & ManifestPluginProvides & GetAppPluginProvides & ListActionsPluginProvides & GetActionPluginProvides & RunActionPluginProvides & LockVersionPluginProvides & ListAuthenticationsPluginProvides & GetAuthenticationPluginProvides & FindFirstAuthenticationPluginProvides & FindUniqueAuthenticationPluginProvides & ListInputFieldsPluginProvides & RequestPluginProvides & GetProfilePluginProvides>;
|
|
43
54
|
//# sourceMappingURL=sdk.d.ts.map
|
package/dist/types/sdk.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sdk.d.ts","sourceRoot":"","sources":["../../src/types/sdk.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAG9C,MAAM,WAAW,cAAc;IAC7B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAAC;IAC7C,OAAO,CAAC,EAAE,aAAa,CAAC;IACxB,KAAK,CAAC,EAAE,OAAO,KAAK,CAAC;IACrB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"sdk.d.ts","sourceRoot":"","sources":["../../src/types/sdk.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAG9C,MAAM,WAAW,cAAc;IAC7B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAAC;IAC7C,OAAO,CAAC,EAAE,aAAa,CAAC;IACxB,KAAK,CAAC,EAAE,OAAO,KAAK,CAAC;IACrB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,EAAE;QACT,IAAI,EAAE;YACJ,CAAC,MAAM,EAAE,MAAM,GAAG;gBAChB,kBAAkB,EAAE,MAAM,CAAC;gBAC3B,OAAO,CAAC,EAAE,MAAM,CAAC;aAClB,CAAC;SACH,CAAC;KACH,CAAC;CACH;AAGD,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,oCAAoC,CAAC;AACrF,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,sCAAsC,CAAC;AACzF,OAAO,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MAAM,CAAC;IACb,WAAW,EAAE,CAAC,CAAC,SAAS,CAAC;IACzB,UAAU,EAAE,MAAM,EAAE,CAAC;CACtB;AAGD,MAAM,WAAW,kBACf,SAAQ,0BAA0B,EAChC,4BAA4B,EAC5B,kCAAkC,EAClC,mCAAmC,EACnC,uBAAuB;CAE1B;AAUD,MAAM,MAAM,SAAS,GAAG,UAAU,CAChC,sBAAsB,GACpB,mBAAmB,GACnB,kBAAkB,GAClB,sBAAsB,GACtB,sBAAsB,GACtB,oBAAoB,GACpB,yBAAyB,GACzB,uBAAuB,GACvB,uBAAuB,GACvB,yBAAyB,GACzB,iCAAiC,GACjC,+BAA+B,GAC/B,qCAAqC,GACrC,sCAAsC,GACtC,6BAA6B,GAC7B,qBAAqB,GACrB,wBAAwB,CAC3B,CAAC"}
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -33,8 +33,6 @@ export * from "./auth";
|
|
|
33
33
|
// Export resolvers for CLI use
|
|
34
34
|
export * from "./resolvers";
|
|
35
35
|
|
|
36
|
-
// Note: SdkSchemas is now available via SDK.__registry
|
|
37
|
-
|
|
38
36
|
// All functions now available through the plugin system via createZapierSdk()
|
|
39
37
|
// Export plugin schemas for external use
|
|
40
38
|
export {
|
package/src/plugins/api/index.ts
CHANGED
|
@@ -63,7 +63,7 @@ describe("getAction plugin", () => {
|
|
|
63
63
|
});
|
|
64
64
|
|
|
65
65
|
// Build SDK with proper plugin composition, providing API in initial context
|
|
66
|
-
return createSdk({}, { api: mockApiClient, meta: {} })
|
|
66
|
+
return createSdk({}, {}, { api: mockApiClient, meta: {} })
|
|
67
67
|
.addPlugin(mockListActionsPlugin)
|
|
68
68
|
.addPlugin(getActionPlugin);
|
|
69
69
|
}
|
|
@@ -7,11 +7,13 @@ import { getAppPlugin } from "./index";
|
|
|
7
7
|
import { createSdk } from "../../sdk";
|
|
8
8
|
import { apiPlugin } from "../api/index";
|
|
9
9
|
import { listAppsPlugin } from "../listApps";
|
|
10
|
+
import { manifestPlugin } from "../manifest";
|
|
10
11
|
|
|
11
12
|
function createTestSdk() {
|
|
12
13
|
return createSdk()
|
|
13
14
|
.addPlugin(apiPlugin, { fetch: global.fetch })
|
|
14
15
|
.addPlugin(listAppsPlugin)
|
|
16
|
+
.addPlugin(manifestPlugin)
|
|
15
17
|
.addPlugin(getAppPlugin);
|
|
16
18
|
}
|
|
17
19
|
|
|
@@ -4,8 +4,9 @@ import { GetAppSchema } from "./schemas";
|
|
|
4
4
|
import type { GetAppOptions } from "./schemas";
|
|
5
5
|
import type { AppItem } from "../../types/domain";
|
|
6
6
|
import { ZapierAppNotFoundError } from "../../types/errors";
|
|
7
|
-
import type { ListAppsPluginProvides } from "../listApps";
|
|
8
7
|
import type { GetSdkType } from "../../types/plugin";
|
|
8
|
+
import { GetImplementation } from "../manifest/schemas";
|
|
9
|
+
import { ManifestPluginProvides } from "../manifest";
|
|
9
10
|
|
|
10
11
|
// GetApp plugin provides interface - getApp goes directly to SDK root
|
|
11
12
|
export interface GetAppPluginProvides {
|
|
@@ -21,34 +22,20 @@ export interface GetAppPluginProvides {
|
|
|
21
22
|
|
|
22
23
|
// GetApp plugin depends on listApps SDK function
|
|
23
24
|
export const getAppPlugin: Plugin<
|
|
24
|
-
GetSdkType<
|
|
25
|
-
{}, //
|
|
25
|
+
GetSdkType<ManifestPluginProvides>, // depends on manifest plugin with getImplementation in context
|
|
26
|
+
{ getImplementation: GetImplementation }, //
|
|
26
27
|
GetAppPluginProvides
|
|
27
|
-
> = ({
|
|
28
|
+
> = ({ context }) => {
|
|
28
29
|
const getApp = createFunction(async function getApp(options: GetAppOptions) {
|
|
29
|
-
const
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
...options,
|
|
35
|
-
appKeys: [appKey],
|
|
36
|
-
})
|
|
37
|
-
.items();
|
|
38
|
-
|
|
39
|
-
// Get the first (and should be only) result
|
|
40
|
-
const apps = [];
|
|
41
|
-
for await (const app of appsIterator) {
|
|
42
|
-
apps.push(app);
|
|
43
|
-
break; // Only need the first result
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
if (apps.length === 0) {
|
|
47
|
-
throw new ZapierAppNotFoundError(appKey);
|
|
30
|
+
const app = await context.getImplementation(options.appKey);
|
|
31
|
+
if (!app) {
|
|
32
|
+
throw new ZapierAppNotFoundError("App not found", {
|
|
33
|
+
appKey: options.appKey,
|
|
34
|
+
});
|
|
48
35
|
}
|
|
49
36
|
|
|
50
37
|
return {
|
|
51
|
-
data:
|
|
38
|
+
data: app,
|
|
52
39
|
};
|
|
53
40
|
}, GetAppSchema);
|
|
54
41
|
|
|
@@ -58,6 +45,7 @@ export const getAppPlugin: Plugin<
|
|
|
58
45
|
context: {
|
|
59
46
|
meta: {
|
|
60
47
|
getApp: {
|
|
48
|
+
categories: ["app"],
|
|
61
49
|
inputSchema: GetAppSchema,
|
|
62
50
|
},
|
|
63
51
|
},
|
|
@@ -9,6 +9,8 @@ import { createSdk } from "../../sdk";
|
|
|
9
9
|
import type { ApiClient } from "../../api";
|
|
10
10
|
import type { GetAuthenticationOptions } from "./schemas";
|
|
11
11
|
import type { Authentication } from "../../api/types";
|
|
12
|
+
import { manifestPlugin } from "../manifest";
|
|
13
|
+
import { listAppsPlugin } from "../listApps";
|
|
12
14
|
|
|
13
15
|
const mockAuthenticationResponse: Authentication = {
|
|
14
16
|
id: 123,
|
|
@@ -34,10 +36,18 @@ describe("getAuthentication plugin", () => {
|
|
|
34
36
|
} as Partial<ApiClient> as ApiClient;
|
|
35
37
|
});
|
|
36
38
|
|
|
39
|
+
const apiPlugin = () => ({
|
|
40
|
+
context: {
|
|
41
|
+
api: mockApiClient,
|
|
42
|
+
},
|
|
43
|
+
});
|
|
44
|
+
|
|
37
45
|
function createTestSdk() {
|
|
38
|
-
return createSdk(
|
|
39
|
-
|
|
40
|
-
|
|
46
|
+
return createSdk()
|
|
47
|
+
.addPlugin(apiPlugin)
|
|
48
|
+
.addPlugin(listAppsPlugin)
|
|
49
|
+
.addPlugin(manifestPlugin)
|
|
50
|
+
.addPlugin(getAuthenticationPlugin);
|
|
41
51
|
}
|
|
42
52
|
|
|
43
53
|
describe("schema validation", () => {
|
|
@@ -8,19 +8,8 @@ import { listActionsPlugin } from "./index";
|
|
|
8
8
|
import { createSdk } from "../../sdk";
|
|
9
9
|
import type { ApiClient } from "../../api";
|
|
10
10
|
import type { ListActionsOptions } from "./schemas";
|
|
11
|
-
|
|
12
|
-
import {
|
|
13
|
-
|
|
14
|
-
const mockAppResponse = {
|
|
15
|
-
data: {
|
|
16
|
-
slug: "slack",
|
|
17
|
-
name: "Slack",
|
|
18
|
-
current_implementation_id: "SlackCLIAPI@1.20.0",
|
|
19
|
-
key: "slack",
|
|
20
|
-
title: "Slack",
|
|
21
|
-
hex_color: "#4A154B",
|
|
22
|
-
} as Partial<App> as App & { key: string; title: string; hex_color: string },
|
|
23
|
-
};
|
|
11
|
+
|
|
12
|
+
import { listAppsPlugin } from "../listApps";
|
|
24
13
|
|
|
25
14
|
const mockImplementationsResponse = {
|
|
26
15
|
results: [
|
|
@@ -66,7 +55,7 @@ const mockEmptyImplementationsResponse = {
|
|
|
66
55
|
|
|
67
56
|
describe("listActions plugin", () => {
|
|
68
57
|
let mockApiClient: ApiClient;
|
|
69
|
-
let
|
|
58
|
+
let mockGetVersionedImplementationId: any;
|
|
70
59
|
|
|
71
60
|
beforeEach(() => {
|
|
72
61
|
vi.clearAllMocks();
|
|
@@ -74,25 +63,31 @@ describe("listActions plugin", () => {
|
|
|
74
63
|
get: vi.fn().mockResolvedValue(mockImplementationsResponse),
|
|
75
64
|
} as Partial<ApiClient> as ApiClient;
|
|
76
65
|
|
|
77
|
-
|
|
66
|
+
mockGetVersionedImplementationId = vi
|
|
67
|
+
.fn()
|
|
68
|
+
.mockResolvedValue("SlackCLIAPI@1.21.1");
|
|
78
69
|
});
|
|
79
70
|
|
|
80
71
|
function createTestSdk() {
|
|
81
72
|
// Create a proper plugin chain with context dependencies
|
|
82
|
-
const mockGetAppPlugin = () => ({
|
|
83
|
-
getApp: mockGetApp,
|
|
84
|
-
context: {
|
|
85
|
-
meta: {
|
|
86
|
-
getApp: {
|
|
87
|
-
inputSchema: GetAppSchema,
|
|
88
|
-
},
|
|
89
|
-
},
|
|
90
|
-
},
|
|
91
|
-
});
|
|
92
73
|
|
|
93
74
|
// Build SDK with proper plugin composition, providing API in initial context
|
|
94
|
-
return createSdk(
|
|
95
|
-
.addPlugin(
|
|
75
|
+
return createSdk()
|
|
76
|
+
.addPlugin(() => ({
|
|
77
|
+
context: {
|
|
78
|
+
api: mockApiClient,
|
|
79
|
+
getVersionedImplementationId: mockGetVersionedImplementationId,
|
|
80
|
+
},
|
|
81
|
+
}))
|
|
82
|
+
.addPlugin(listAppsPlugin)
|
|
83
|
+
.addPlugin(() => ({
|
|
84
|
+
context: {
|
|
85
|
+
manifest: null,
|
|
86
|
+
getManifestEntry: () => null,
|
|
87
|
+
getVersionedImplementationId: mockGetVersionedImplementationId,
|
|
88
|
+
getImplementation: () => Promise.resolve(null),
|
|
89
|
+
},
|
|
90
|
+
}))
|
|
96
91
|
.addPlugin(listActionsPlugin);
|
|
97
92
|
}
|
|
98
93
|
|
|
@@ -401,9 +396,7 @@ describe("listActions plugin", () => {
|
|
|
401
396
|
const sdk = createTestSdk();
|
|
402
397
|
await sdk.listActions({ appKey: "slack" });
|
|
403
398
|
|
|
404
|
-
expect(
|
|
405
|
-
appKey: "slack",
|
|
406
|
-
});
|
|
399
|
+
expect(mockGetVersionedImplementationId).toHaveBeenCalledWith("slack");
|
|
407
400
|
});
|
|
408
401
|
|
|
409
402
|
it("should pass correct search parameters to implementations API", async () => {
|
|
@@ -416,7 +409,7 @@ describe("listActions plugin", () => {
|
|
|
416
409
|
searchParams: expect.objectContaining({
|
|
417
410
|
global: "true",
|
|
418
411
|
public_only: "true",
|
|
419
|
-
selected_apis: "SlackCLIAPI",
|
|
412
|
+
selected_apis: "SlackCLIAPI@1.21.1",
|
|
420
413
|
}),
|
|
421
414
|
}),
|
|
422
415
|
);
|
|
@@ -425,12 +418,7 @@ describe("listActions plugin", () => {
|
|
|
425
418
|
|
|
426
419
|
describe("error handling", () => {
|
|
427
420
|
it("should throw ZapierConfigurationError when app has no current_implementation_id", async () => {
|
|
428
|
-
|
|
429
|
-
data: {
|
|
430
|
-
...mockAppResponse.data,
|
|
431
|
-
current_implementation_id: undefined, // Missing implementation ID
|
|
432
|
-
},
|
|
433
|
-
});
|
|
421
|
+
mockGetVersionedImplementationId.mockResolvedValue(null);
|
|
434
422
|
|
|
435
423
|
const sdk = createTestSdk();
|
|
436
424
|
await expect(sdk.listActions({ appKey: "slack" })).rejects.toThrow(
|
|
@@ -439,12 +427,7 @@ describe("listActions plugin", () => {
|
|
|
439
427
|
});
|
|
440
428
|
|
|
441
429
|
it("should throw ZapierConfigurationError when current_implementation_id is empty", async () => {
|
|
442
|
-
|
|
443
|
-
data: {
|
|
444
|
-
...mockAppResponse.data,
|
|
445
|
-
current_implementation_id: "", // Empty implementation ID
|
|
446
|
-
},
|
|
447
|
-
});
|
|
430
|
+
mockGetVersionedImplementationId.mockResolvedValue("");
|
|
448
431
|
|
|
449
432
|
const sdk = createTestSdk();
|
|
450
433
|
await expect(sdk.listActions({ appKey: "slack" })).rejects.toThrow(
|
|
@@ -516,8 +499,10 @@ describe("listActions plugin", () => {
|
|
|
516
499
|
expect(result.data).toHaveLength(0);
|
|
517
500
|
});
|
|
518
501
|
|
|
519
|
-
it("should propagate
|
|
520
|
-
|
|
502
|
+
it("should propagate getVersionedImplementationId errors", async () => {
|
|
503
|
+
mockGetVersionedImplementationId.mockRejectedValue(
|
|
504
|
+
new Error("App not found"),
|
|
505
|
+
);
|
|
521
506
|
|
|
522
507
|
const sdk = createTestSdk();
|
|
523
508
|
await expect(sdk.listActions({ appKey: "nonexistent" })).rejects.toThrow(
|
|
@@ -526,50 +511,6 @@ describe("listActions plugin", () => {
|
|
|
526
511
|
});
|
|
527
512
|
});
|
|
528
513
|
|
|
529
|
-
describe("implementation ID extraction", () => {
|
|
530
|
-
it("should extract implementation name from versioned ID", async () => {
|
|
531
|
-
mockGetApp.mockResolvedValue({
|
|
532
|
-
data: {
|
|
533
|
-
...mockAppResponse.data,
|
|
534
|
-
current_implementation_id: "CustomAPIName@2.5.0",
|
|
535
|
-
},
|
|
536
|
-
});
|
|
537
|
-
|
|
538
|
-
const sdk = createTestSdk();
|
|
539
|
-
await sdk.listActions({ appKey: "slack" });
|
|
540
|
-
|
|
541
|
-
expect(mockApiClient.get).toHaveBeenCalledWith(
|
|
542
|
-
"/api/v4/implementations/",
|
|
543
|
-
expect.objectContaining({
|
|
544
|
-
searchParams: expect.objectContaining({
|
|
545
|
-
selected_apis: "CustomAPIName", // Extracted name without version
|
|
546
|
-
}),
|
|
547
|
-
}),
|
|
548
|
-
);
|
|
549
|
-
});
|
|
550
|
-
|
|
551
|
-
it("should handle implementation ID without version", async () => {
|
|
552
|
-
mockGetApp.mockResolvedValue({
|
|
553
|
-
data: {
|
|
554
|
-
...mockAppResponse.data,
|
|
555
|
-
current_implementation_id: "PlainAPIName",
|
|
556
|
-
},
|
|
557
|
-
});
|
|
558
|
-
|
|
559
|
-
const sdk = createTestSdk();
|
|
560
|
-
await sdk.listActions({ appKey: "slack" });
|
|
561
|
-
|
|
562
|
-
expect(mockApiClient.get).toHaveBeenCalledWith(
|
|
563
|
-
"/api/v4/implementations/",
|
|
564
|
-
expect.objectContaining({
|
|
565
|
-
searchParams: expect.objectContaining({
|
|
566
|
-
selected_apis: "PlainAPIName", // Used as-is
|
|
567
|
-
}),
|
|
568
|
-
}),
|
|
569
|
-
);
|
|
570
|
-
});
|
|
571
|
-
});
|
|
572
|
-
|
|
573
514
|
describe("context and metadata", () => {
|
|
574
515
|
it("should provide context with meta information", () => {
|
|
575
516
|
const sdk = createTestSdk();
|