@zapier/zapier-sdk 0.13.6 → 0.13.7
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 +7 -0
- package/dist/index.cjs +1 -1
- package/dist/index.mjs +1 -1
- package/package.json +7 -2
- package/src/api/auth.ts +0 -28
- package/src/api/client.ts +0 -491
- package/src/api/debug.test.ts +0 -76
- package/src/api/debug.ts +0 -154
- package/src/api/index.ts +0 -90
- package/src/api/polling.test.ts +0 -405
- package/src/api/polling.ts +0 -253
- package/src/api/schemas.ts +0 -465
- package/src/api/types.ts +0 -152
- package/src/auth.ts +0 -72
- package/src/constants.ts +0 -16
- package/src/index.ts +0 -111
- package/src/plugins/api/index.ts +0 -43
- package/src/plugins/apps/index.ts +0 -203
- package/src/plugins/apps/schemas.ts +0 -64
- package/src/plugins/eventEmission/builders.ts +0 -115
- package/src/plugins/eventEmission/index.test.ts +0 -169
- package/src/plugins/eventEmission/index.ts +0 -294
- package/src/plugins/eventEmission/transport.test.ts +0 -214
- package/src/plugins/eventEmission/transport.ts +0 -135
- package/src/plugins/eventEmission/types.ts +0 -58
- package/src/plugins/eventEmission/utils.ts +0 -121
- package/src/plugins/fetch/index.ts +0 -83
- package/src/plugins/fetch/schemas.ts +0 -37
- package/src/plugins/findFirstAuthentication/index.test.ts +0 -209
- package/src/plugins/findFirstAuthentication/index.ts +0 -68
- package/src/plugins/findFirstAuthentication/schemas.ts +0 -47
- package/src/plugins/findUniqueAuthentication/index.test.ts +0 -197
- package/src/plugins/findUniqueAuthentication/index.ts +0 -77
- package/src/plugins/findUniqueAuthentication/schemas.ts +0 -49
- package/src/plugins/getAction/index.test.ts +0 -239
- package/src/plugins/getAction/index.ts +0 -75
- package/src/plugins/getAction/schemas.ts +0 -41
- package/src/plugins/getApp/index.test.ts +0 -181
- package/src/plugins/getApp/index.ts +0 -60
- package/src/plugins/getApp/schemas.ts +0 -33
- package/src/plugins/getAuthentication/index.test.ts +0 -294
- package/src/plugins/getAuthentication/index.ts +0 -95
- package/src/plugins/getAuthentication/schemas.ts +0 -38
- package/src/plugins/getProfile/index.ts +0 -60
- package/src/plugins/getProfile/schemas.ts +0 -24
- package/src/plugins/listActions/index.test.ts +0 -526
- package/src/plugins/listActions/index.ts +0 -132
- package/src/plugins/listActions/schemas.ts +0 -55
- package/src/plugins/listApps/index.test.ts +0 -378
- package/src/plugins/listApps/index.ts +0 -159
- package/src/plugins/listApps/schemas.ts +0 -41
- package/src/plugins/listAuthentications/index.test.ts +0 -739
- package/src/plugins/listAuthentications/index.ts +0 -152
- package/src/plugins/listAuthentications/schemas.ts +0 -77
- package/src/plugins/listInputFieldChoices/index.test.ts +0 -653
- package/src/plugins/listInputFieldChoices/index.ts +0 -173
- package/src/plugins/listInputFieldChoices/schemas.ts +0 -125
- package/src/plugins/listInputFields/index.test.ts +0 -439
- package/src/plugins/listInputFields/index.ts +0 -294
- package/src/plugins/listInputFields/schemas.ts +0 -68
- package/src/plugins/manifest/index.test.ts +0 -776
- package/src/plugins/manifest/index.ts +0 -461
- package/src/plugins/manifest/schemas.ts +0 -60
- package/src/plugins/registry/index.ts +0 -160
- package/src/plugins/request/index.test.ts +0 -333
- package/src/plugins/request/index.ts +0 -105
- package/src/plugins/request/schemas.ts +0 -69
- package/src/plugins/runAction/index.test.ts +0 -388
- package/src/plugins/runAction/index.ts +0 -215
- package/src/plugins/runAction/schemas.ts +0 -60
- package/src/resolvers/actionKey.ts +0 -37
- package/src/resolvers/actionType.ts +0 -34
- package/src/resolvers/appKey.ts +0 -7
- package/src/resolvers/authenticationId.ts +0 -54
- package/src/resolvers/index.ts +0 -11
- package/src/resolvers/inputFieldKey.ts +0 -70
- package/src/resolvers/inputs.ts +0 -69
- package/src/schemas/Action.ts +0 -52
- package/src/schemas/App.ts +0 -45
- package/src/schemas/Auth.ts +0 -59
- package/src/schemas/Field.ts +0 -169
- package/src/schemas/Run.ts +0 -40
- package/src/schemas/UserProfile.ts +0 -60
- package/src/sdk.test.ts +0 -212
- package/src/sdk.ts +0 -178
- package/src/types/domain.test.ts +0 -50
- package/src/types/domain.ts +0 -66
- package/src/types/errors.ts +0 -278
- package/src/types/events.ts +0 -43
- package/src/types/functions.ts +0 -28
- package/src/types/optional-zapier-sdk-cli-login.d.ts +0 -37
- package/src/types/plugin.ts +0 -125
- package/src/types/properties.ts +0 -80
- package/src/types/sdk.ts +0 -111
- package/src/types/telemetry-events.ts +0 -85
- package/src/utils/array-utils.test.ts +0 -131
- package/src/utils/array-utils.ts +0 -41
- package/src/utils/domain-utils.test.ts +0 -433
- package/src/utils/domain-utils.ts +0 -267
- package/src/utils/file-utils.test.ts +0 -73
- package/src/utils/file-utils.ts +0 -94
- package/src/utils/function-utils.test.ts +0 -141
- package/src/utils/function-utils.ts +0 -245
- package/src/utils/pagination-utils.test.ts +0 -620
- package/src/utils/pagination-utils.ts +0 -242
- package/src/utils/schema-utils.ts +0 -207
- package/src/utils/string-utils.test.ts +0 -45
- package/src/utils/string-utils.ts +0 -54
- package/src/utils/validation.test.ts +0 -51
- package/src/utils/validation.ts +0 -44
- package/tsconfig.build.json +0 -18
- package/tsconfig.json +0 -20
- package/tsconfig.tsbuildinfo +0 -1
- package/tsup.config.ts +0 -23
package/src/sdk.test.ts
DELETED
|
@@ -1,212 +0,0 @@
|
|
|
1
|
-
// Test the flat plugin system
|
|
2
|
-
import { describe, it, expect } from "vitest";
|
|
3
|
-
import { createZapierSdk, createSdk } from "./sdk";
|
|
4
|
-
import type { Plugin } from "./types/plugin";
|
|
5
|
-
|
|
6
|
-
describe("Flat Plugin System", () => {
|
|
7
|
-
it("should create SDK with all expected methods", () => {
|
|
8
|
-
const sdk = createZapierSdk();
|
|
9
|
-
|
|
10
|
-
// Test that all core methods are available
|
|
11
|
-
expect(sdk.listApps).toBeDefined();
|
|
12
|
-
expect(sdk.listAuthentications).toBeDefined();
|
|
13
|
-
expect(sdk.getAuthentication).toBeDefined();
|
|
14
|
-
expect(sdk.runAction).toBeDefined();
|
|
15
|
-
expect(sdk.request).toBeDefined();
|
|
16
|
-
|
|
17
|
-
// Test that plugin methods are available
|
|
18
|
-
expect(sdk.fetch).toBeDefined();
|
|
19
|
-
expect(sdk.apps).toBeDefined();
|
|
20
|
-
expect(sdk.getProfile).toBeDefined();
|
|
21
|
-
|
|
22
|
-
// Test that getContext method is available
|
|
23
|
-
expect(sdk.getContext).toBeDefined();
|
|
24
|
-
expect(typeof sdk.getContext).toBe("function");
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
it("should have getContext method that returns context", () => {
|
|
28
|
-
const sdk = createZapierSdk();
|
|
29
|
-
const context = sdk.getContext() as any; // Type assertion to work around complex context inference
|
|
30
|
-
|
|
31
|
-
// Context should be an object
|
|
32
|
-
expect(typeof context).toBe("object");
|
|
33
|
-
expect(context).not.toBeNull();
|
|
34
|
-
|
|
35
|
-
// Context should have some properties (specific properties depend on plugin composition)
|
|
36
|
-
expect(Object.keys(context).length).toBeGreaterThan(0);
|
|
37
|
-
|
|
38
|
-
// Should have meta object
|
|
39
|
-
expect(context.meta).toBeDefined();
|
|
40
|
-
expect(typeof context.meta).toBe("object");
|
|
41
|
-
|
|
42
|
-
// Should have getProfile metadata from the plugin (verify it exists in meta)
|
|
43
|
-
expect("getProfile" in context.meta).toBe(true);
|
|
44
|
-
expect(context.meta.getProfile).toBeDefined();
|
|
45
|
-
expect(context.meta.getProfile.inputSchema).toBeDefined();
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
it("should have plugins return flat structure", () => {
|
|
49
|
-
const sdk = createZapierSdk();
|
|
50
|
-
|
|
51
|
-
// fetch should be directly available (not sdk.plugins.fetch or sdk.fetch.fetch)
|
|
52
|
-
expect(typeof sdk.fetch).toBe("function");
|
|
53
|
-
|
|
54
|
-
// apps should be directly available
|
|
55
|
-
expect(typeof sdk.apps).toBe("object");
|
|
56
|
-
|
|
57
|
-
// getProfile should be directly available
|
|
58
|
-
expect(typeof sdk.getProfile).toBe("function");
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
it("should support fluent plugin chaining with createSdk", () => {
|
|
62
|
-
// Test that createSdk().addPlugin().addPlugin() works and returns properly typed SDK
|
|
63
|
-
const testPlugin: Plugin<
|
|
64
|
-
{}, // no SDK dependencies
|
|
65
|
-
{}, // no context requirements
|
|
66
|
-
{ testMethod: () => string }
|
|
67
|
-
> = () => ({
|
|
68
|
-
testMethod: () => "test result",
|
|
69
|
-
});
|
|
70
|
-
|
|
71
|
-
const sdk = createSdk().addPlugin(testPlugin);
|
|
72
|
-
|
|
73
|
-
// Should have getContext method
|
|
74
|
-
expect(typeof sdk.getContext).toBe("function");
|
|
75
|
-
|
|
76
|
-
// Should have addPlugin method for further chaining
|
|
77
|
-
expect(typeof sdk.addPlugin).toBe("function");
|
|
78
|
-
|
|
79
|
-
// Should have the plugin method
|
|
80
|
-
expect(typeof sdk.testMethod).toBe("function");
|
|
81
|
-
expect(sdk.testMethod()).toBe("test result");
|
|
82
|
-
});
|
|
83
|
-
|
|
84
|
-
it("should support fluent plugin chaining without .getSdk()", () => {
|
|
85
|
-
// This demonstrates the simplified API - no .getSdk() needed!
|
|
86
|
-
const plugin1: Plugin<
|
|
87
|
-
{}, // no SDK dependencies
|
|
88
|
-
{}, // no context requirements
|
|
89
|
-
{ method1: () => string }
|
|
90
|
-
> = () => ({ method1: () => "method1" });
|
|
91
|
-
|
|
92
|
-
const plugin2: Plugin<
|
|
93
|
-
{ method1: () => string }, // depends on method1 in SDK
|
|
94
|
-
{}, // no context requirements
|
|
95
|
-
{ method2: () => string }
|
|
96
|
-
> = () => ({ method2: () => "method2" });
|
|
97
|
-
|
|
98
|
-
// Fluent chaining - each addPlugin returns a new SDK
|
|
99
|
-
const sdk = createSdk().addPlugin(plugin1).addPlugin(plugin2);
|
|
100
|
-
|
|
101
|
-
expect(sdk.method1()).toBe("method1");
|
|
102
|
-
expect(sdk.method2()).toBe("method2");
|
|
103
|
-
expect(typeof sdk.getContext).toBe("function");
|
|
104
|
-
expect(typeof sdk.addPlugin).toBe("function"); // Can still add more plugins!
|
|
105
|
-
});
|
|
106
|
-
|
|
107
|
-
it("should support plugins with options", () => {
|
|
108
|
-
// Test that addPlugin(pluginFn, options) works correctly
|
|
109
|
-
const pluginWithOptions: Plugin<
|
|
110
|
-
{}, // no SDK dependencies
|
|
111
|
-
{}, // no context requirements
|
|
112
|
-
{ getMessage: () => string }
|
|
113
|
-
> = (params) => ({
|
|
114
|
-
getMessage: () => (params as any).message,
|
|
115
|
-
});
|
|
116
|
-
|
|
117
|
-
const sdk = createSdk().addPlugin(pluginWithOptions, {
|
|
118
|
-
message: "Hello from options!",
|
|
119
|
-
});
|
|
120
|
-
|
|
121
|
-
expect(typeof sdk.getMessage).toBe("function");
|
|
122
|
-
expect(sdk.getMessage()).toBe("Hello from options!");
|
|
123
|
-
});
|
|
124
|
-
|
|
125
|
-
it("should merge context.meta from multiple plugins", () => {
|
|
126
|
-
// Test that multiple plugins can provide meta without overwriting each other
|
|
127
|
-
const plugin1: Plugin<
|
|
128
|
-
{}, // no SDK dependencies
|
|
129
|
-
{}, // no context requirements
|
|
130
|
-
{
|
|
131
|
-
method1: () => string;
|
|
132
|
-
context: { meta: { plugin1: { info: string } } };
|
|
133
|
-
}
|
|
134
|
-
> = () => ({
|
|
135
|
-
method1: () => "method1",
|
|
136
|
-
context: {
|
|
137
|
-
meta: {
|
|
138
|
-
plugin1: { info: "Plugin 1 metadata" },
|
|
139
|
-
},
|
|
140
|
-
},
|
|
141
|
-
});
|
|
142
|
-
|
|
143
|
-
const plugin2: Plugin<
|
|
144
|
-
{ method1: () => string }, // depends on method1 in SDK
|
|
145
|
-
{}, // no context requirements
|
|
146
|
-
{
|
|
147
|
-
method2: () => string;
|
|
148
|
-
context: { meta: { plugin2: { info: string } } };
|
|
149
|
-
}
|
|
150
|
-
> = () => ({
|
|
151
|
-
method2: () => "method2",
|
|
152
|
-
context: {
|
|
153
|
-
meta: {
|
|
154
|
-
plugin2: { info: "Plugin 2 metadata" },
|
|
155
|
-
},
|
|
156
|
-
},
|
|
157
|
-
});
|
|
158
|
-
|
|
159
|
-
const sdk = createSdk().addPlugin(plugin1).addPlugin(plugin2);
|
|
160
|
-
const context = sdk.getContext();
|
|
161
|
-
|
|
162
|
-
// Both plugins should have their meta preserved
|
|
163
|
-
expect(context.meta.plugin1.info).toBe("Plugin 1 metadata");
|
|
164
|
-
expect(context.meta.plugin2.info).toBe("Plugin 2 metadata");
|
|
165
|
-
|
|
166
|
-
// Both methods should work
|
|
167
|
-
expect(sdk.method1()).toBe("method1");
|
|
168
|
-
expect(sdk.method2()).toBe("method2");
|
|
169
|
-
});
|
|
170
|
-
|
|
171
|
-
it("should support context requirements for cleaner plugin definitions", () => {
|
|
172
|
-
// Test context requirements work correctly
|
|
173
|
-
const pluginWithHelper: Plugin<
|
|
174
|
-
{ existingMethod: () => string }, // requires existingMethod in SDK
|
|
175
|
-
{ customContext: string }, // requires customContext in context
|
|
176
|
-
{ helperMethod: () => string }
|
|
177
|
-
> = ({ sdk, context }) => ({
|
|
178
|
-
helperMethod: () =>
|
|
179
|
-
`Helper: ${sdk.existingMethod()} + ${context.customContext}`,
|
|
180
|
-
});
|
|
181
|
-
|
|
182
|
-
const baseSdk = { existingMethod: () => "base" };
|
|
183
|
-
const baseContext = { customContext: "custom", meta: {} };
|
|
184
|
-
const sdk = createSdk({}, baseSdk, baseContext).addPlugin(pluginWithHelper);
|
|
185
|
-
|
|
186
|
-
expect(sdk.helperMethod()).toBe("Helper: base + custom");
|
|
187
|
-
expect(sdk.existingMethod()).toBe("base"); // Original method still works
|
|
188
|
-
});
|
|
189
|
-
|
|
190
|
-
it("should ensure context.meta is always available", () => {
|
|
191
|
-
// Test that context.meta is always at least an empty object, even without explicit initialization
|
|
192
|
-
const plugin: Plugin<
|
|
193
|
-
{}, // no SDK dependencies
|
|
194
|
-
{}, // no context requirements (meta is always guaranteed)
|
|
195
|
-
{ testMethod: () => string }
|
|
196
|
-
> = ({ context }) => ({
|
|
197
|
-
testMethod: () => `Meta keys: ${Object.keys(context.meta).length}`,
|
|
198
|
-
});
|
|
199
|
-
|
|
200
|
-
// Create SDK without explicitly providing meta
|
|
201
|
-
const sdk = createSdk({}).addPlugin(plugin);
|
|
202
|
-
|
|
203
|
-
// Should work without error - meta should be at least an empty object
|
|
204
|
-
expect(sdk.testMethod()).toBe("Meta keys: 0");
|
|
205
|
-
|
|
206
|
-
// getContext() should also provide meta
|
|
207
|
-
const context = sdk.getContext();
|
|
208
|
-
expect(context.meta).toBeDefined();
|
|
209
|
-
expect(typeof context.meta).toBe("object");
|
|
210
|
-
expect(context.meta).not.toBeNull();
|
|
211
|
-
});
|
|
212
|
-
});
|
package/src/sdk.ts
DELETED
|
@@ -1,178 +0,0 @@
|
|
|
1
|
-
import type { BaseSdkOptions } from "./types/sdk";
|
|
2
|
-
// All function implementations now provided by plugins
|
|
3
|
-
|
|
4
|
-
// All CLI registry info now provided by plugins
|
|
5
|
-
|
|
6
|
-
// Import the properly typed SDK interfaces
|
|
7
|
-
import type { ZapierSdk } from "./types/sdk";
|
|
8
|
-
import type {
|
|
9
|
-
Sdk,
|
|
10
|
-
Plugin,
|
|
11
|
-
ExtractContextProperties,
|
|
12
|
-
ExtractSdkProperties,
|
|
13
|
-
PluginProvides,
|
|
14
|
-
PluginMeta,
|
|
15
|
-
} from "./types/plugin";
|
|
16
|
-
|
|
17
|
-
// Import plugin functions
|
|
18
|
-
import { appsPlugin } from "./plugins/apps/index";
|
|
19
|
-
import { fetchPlugin } from "./plugins/fetch/index";
|
|
20
|
-
import { registryPlugin } from "./plugins/registry/index";
|
|
21
|
-
import { apiPlugin } from "./plugins/api/index";
|
|
22
|
-
import { getProfilePlugin } from "./plugins/getProfile";
|
|
23
|
-
import { listAppsPlugin } from "./plugins/listApps";
|
|
24
|
-
import { getAppPlugin } from "./plugins/getApp";
|
|
25
|
-
import { listActionsPlugin } from "./plugins/listActions";
|
|
26
|
-
import { getActionPlugin } from "./plugins/getAction";
|
|
27
|
-
import { runActionPlugin } from "./plugins/runAction";
|
|
28
|
-
import { listAuthenticationsPlugin } from "./plugins/listAuthentications";
|
|
29
|
-
import { getAuthenticationPlugin } from "./plugins/getAuthentication";
|
|
30
|
-
import { findFirstAuthenticationPlugin } from "./plugins/findFirstAuthentication";
|
|
31
|
-
import { findUniqueAuthenticationPlugin } from "./plugins/findUniqueAuthentication";
|
|
32
|
-
import { listInputFieldsPlugin } from "./plugins/listInputFields";
|
|
33
|
-
import { listInputFieldChoicesPlugin } from "./plugins/listInputFieldChoices";
|
|
34
|
-
import { requestPlugin } from "./plugins/request";
|
|
35
|
-
import { manifestPlugin } from "./plugins/manifest";
|
|
36
|
-
import { eventEmissionPlugin } from "./plugins/eventEmission";
|
|
37
|
-
|
|
38
|
-
// Full SDK interface with plugins applied
|
|
39
|
-
// Note: ZapierSdk is now defined as ReturnType<typeof createZapierSdk> at the bottom of this file
|
|
40
|
-
|
|
41
|
-
export interface ZapierSdkOptions extends BaseSdkOptions {}
|
|
42
|
-
|
|
43
|
-
// Create SDK that supports flat plugins - returns an SDK, not a builder
|
|
44
|
-
export function createSdk<
|
|
45
|
-
TCurrentSdk = {},
|
|
46
|
-
TCurrentContext extends { meta: Record<string, PluginMeta> } = {
|
|
47
|
-
meta: Record<string, PluginMeta>;
|
|
48
|
-
},
|
|
49
|
-
>(
|
|
50
|
-
options: ZapierSdkOptions = {},
|
|
51
|
-
initialSdk: TCurrentSdk = {} as TCurrentSdk,
|
|
52
|
-
initialContext: TCurrentContext = { meta: {} } as TCurrentContext,
|
|
53
|
-
) {
|
|
54
|
-
return {
|
|
55
|
-
...initialSdk,
|
|
56
|
-
getContext: () => initialContext,
|
|
57
|
-
addPlugin<TRequiresContext, TProvides extends PluginProvides>(
|
|
58
|
-
plugin: Plugin<
|
|
59
|
-
TCurrentSdk & { getContext(): TCurrentContext },
|
|
60
|
-
TRequiresContext,
|
|
61
|
-
TProvides
|
|
62
|
-
>,
|
|
63
|
-
addPluginOptions: Record<string, unknown> = {},
|
|
64
|
-
): Sdk<
|
|
65
|
-
TCurrentSdk & ExtractSdkProperties<TProvides>,
|
|
66
|
-
TCurrentContext & NonNullable<ExtractContextProperties<TProvides>>
|
|
67
|
-
> {
|
|
68
|
-
// Create SDK with getContext method for plugins to use
|
|
69
|
-
const currentSdkWithContext = {
|
|
70
|
-
...initialSdk,
|
|
71
|
-
getContext: () => initialContext,
|
|
72
|
-
} as TCurrentSdk & { getContext(): TCurrentContext };
|
|
73
|
-
|
|
74
|
-
// Apply the plugin with options merged in
|
|
75
|
-
const pluginResult = plugin({
|
|
76
|
-
sdk: currentSdkWithContext,
|
|
77
|
-
context: {
|
|
78
|
-
...initialContext,
|
|
79
|
-
// Add the options that createSdk was called with to context
|
|
80
|
-
options,
|
|
81
|
-
} as TCurrentContext & { options: ZapierSdkOptions } & TRequiresContext,
|
|
82
|
-
...addPluginOptions,
|
|
83
|
-
});
|
|
84
|
-
|
|
85
|
-
// Extract context from plugin result if present
|
|
86
|
-
const { context: pluginContext, ...sdkProperties } = pluginResult;
|
|
87
|
-
|
|
88
|
-
// Merge SDK properties directly (flat structure)
|
|
89
|
-
const newSdk = { ...initialSdk, ...sdkProperties };
|
|
90
|
-
|
|
91
|
-
// Merge context additions if plugin returned any
|
|
92
|
-
// Ensure meta is always present, starting with existing or empty object
|
|
93
|
-
let newContext = {
|
|
94
|
-
...initialContext,
|
|
95
|
-
...addPluginOptions,
|
|
96
|
-
meta:
|
|
97
|
-
(initialContext as { meta?: Record<string, PluginMeta> }).meta || {},
|
|
98
|
-
} as TCurrentContext & NonNullable<ExtractContextProperties<TProvides>>;
|
|
99
|
-
|
|
100
|
-
if (pluginContext) {
|
|
101
|
-
// Extract meta from plugin context for special merging
|
|
102
|
-
const { meta: pluginMeta, ...otherPluginContext } = pluginContext;
|
|
103
|
-
|
|
104
|
-
newContext = {
|
|
105
|
-
...newContext,
|
|
106
|
-
...otherPluginContext,
|
|
107
|
-
} as TCurrentContext & NonNullable<ExtractContextProperties<TProvides>>;
|
|
108
|
-
|
|
109
|
-
// Merge meta separately to avoid overwriting
|
|
110
|
-
if (pluginMeta) {
|
|
111
|
-
newContext = {
|
|
112
|
-
...newContext,
|
|
113
|
-
meta: {
|
|
114
|
-
...newContext.meta, // Existing meta (now guaranteed to exist)
|
|
115
|
-
...pluginMeta, // New meta from plugin
|
|
116
|
-
},
|
|
117
|
-
} as TCurrentContext &
|
|
118
|
-
NonNullable<ExtractContextProperties<TProvides>>;
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
// Recursively create new SDK with updated properties
|
|
123
|
-
return createSdk(options, newSdk, newContext) as Sdk<
|
|
124
|
-
TCurrentSdk & ExtractSdkProperties<TProvides>,
|
|
125
|
-
TCurrentContext & NonNullable<ExtractContextProperties<TProvides>>
|
|
126
|
-
>;
|
|
127
|
-
},
|
|
128
|
-
};
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
export function createZapierSdkWithoutRegistry(options: ZapierSdkOptions = {}) {
|
|
132
|
-
return (
|
|
133
|
-
createSdk(options)
|
|
134
|
-
// Event emission (must be first to be available to other plugins)
|
|
135
|
-
.addPlugin(eventEmissionPlugin)
|
|
136
|
-
|
|
137
|
-
// Provides the API client in context
|
|
138
|
-
.addPlugin(apiPlugin)
|
|
139
|
-
|
|
140
|
-
// Manifest plugin (provides version locking context) - must come after apiPlugin
|
|
141
|
-
.addPlugin(manifestPlugin)
|
|
142
|
-
|
|
143
|
-
// Apps/actions/fields
|
|
144
|
-
.addPlugin(listAppsPlugin)
|
|
145
|
-
.addPlugin(getAppPlugin)
|
|
146
|
-
.addPlugin(listActionsPlugin)
|
|
147
|
-
.addPlugin(getActionPlugin)
|
|
148
|
-
.addPlugin(listInputFieldsPlugin)
|
|
149
|
-
.addPlugin(listInputFieldChoicesPlugin)
|
|
150
|
-
|
|
151
|
-
// Run action
|
|
152
|
-
.addPlugin(runActionPlugin)
|
|
153
|
-
|
|
154
|
-
// Authentications
|
|
155
|
-
.addPlugin(listAuthenticationsPlugin)
|
|
156
|
-
.addPlugin(getAuthenticationPlugin)
|
|
157
|
-
.addPlugin(findFirstAuthenticationPlugin)
|
|
158
|
-
.addPlugin(findUniqueAuthenticationPlugin)
|
|
159
|
-
|
|
160
|
-
// Relay fetching
|
|
161
|
-
.addPlugin(requestPlugin)
|
|
162
|
-
.addPlugin(fetchPlugin)
|
|
163
|
-
|
|
164
|
-
// Magic apps plugin
|
|
165
|
-
.addPlugin(appsPlugin)
|
|
166
|
-
|
|
167
|
-
// Profile
|
|
168
|
-
.addPlugin(getProfilePlugin)
|
|
169
|
-
);
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
export function createZapierSdk(options: ZapierSdkOptions = {}): ZapierSdk {
|
|
173
|
-
return (
|
|
174
|
-
createZapierSdkWithoutRegistry(options)
|
|
175
|
-
// Register plugins for CLI/MCP metadata
|
|
176
|
-
.addPlugin(registryPlugin)
|
|
177
|
-
);
|
|
178
|
-
}
|
package/src/types/domain.test.ts
DELETED
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect } from "vitest";
|
|
2
|
-
import { splitVersionedKey } from "../utils/domain-utils";
|
|
3
|
-
|
|
4
|
-
describe("splitVersionedKey", () => {
|
|
5
|
-
it("should split versioned key with version", () => {
|
|
6
|
-
const [baseKey, version] = splitVersionedKey("SlackCLIAPI@1.21.1");
|
|
7
|
-
expect(baseKey).toBe("SlackCLIAPI");
|
|
8
|
-
expect(version).toBe("1.21.1");
|
|
9
|
-
});
|
|
10
|
-
|
|
11
|
-
it("should split versioned key with complex version", () => {
|
|
12
|
-
const [baseKey, version] = splitVersionedKey(
|
|
13
|
-
"GoogleSheetsAPI@2.5.0-beta.1",
|
|
14
|
-
);
|
|
15
|
-
expect(baseKey).toBe("GoogleSheetsAPI");
|
|
16
|
-
expect(version).toBe("2.5.0-beta.1");
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
it("should handle versioned key without version", () => {
|
|
20
|
-
const [baseKey, version] = splitVersionedKey("SomeAPI");
|
|
21
|
-
expect(baseKey).toBe("SomeAPI");
|
|
22
|
-
expect(version).toBeUndefined();
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
it("should handle versioned key with multiple @ symbols", () => {
|
|
26
|
-
const [baseKey, version] = splitVersionedKey("ComplexAPI@1.0.0@beta");
|
|
27
|
-
expect(baseKey).toBe("ComplexAPI");
|
|
28
|
-
expect(version).toBe("1.0.0@beta");
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
it("should handle edge case with many @ symbols", () => {
|
|
32
|
-
const [baseKey, version] = splitVersionedKey(
|
|
33
|
-
"API@with@multiple@at@symbols@1.2.3",
|
|
34
|
-
);
|
|
35
|
-
expect(baseKey).toBe("API");
|
|
36
|
-
expect(version).toBe("with@multiple@at@symbols@1.2.3");
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
it("should handle empty string", () => {
|
|
40
|
-
const [baseKey, version] = splitVersionedKey("");
|
|
41
|
-
expect(baseKey).toBe("");
|
|
42
|
-
expect(version).toBeUndefined();
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
it("should handle string that starts with @", () => {
|
|
46
|
-
const [baseKey, version] = splitVersionedKey("@version");
|
|
47
|
-
expect(baseKey).toBe("");
|
|
48
|
-
expect(version).toBe("version");
|
|
49
|
-
});
|
|
50
|
-
});
|
package/src/types/domain.ts
DELETED
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
import type { z } from "zod";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Domain model types - representing business entities returned by SDK functions
|
|
5
|
-
* These types are inferred from Item schemas and represent transformed/formatted data.
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
// Import schemas to infer types from
|
|
9
|
-
import type { AppItemSchema } from "../schemas/App";
|
|
10
|
-
import type { AuthenticationItemSchema } from "../schemas/Auth";
|
|
11
|
-
import type { ActionItemSchema } from "../schemas/Action";
|
|
12
|
-
import type {
|
|
13
|
-
InputFieldItemSchema,
|
|
14
|
-
InfoFieldItemSchema,
|
|
15
|
-
RootFieldItemSchema,
|
|
16
|
-
} from "../schemas/Field";
|
|
17
|
-
import type { UserProfileItemSchema } from "../schemas/UserProfile";
|
|
18
|
-
import type { FieldsetItem } from "../schemas/Field";
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* Represents an app item returned by getApp and listApps functions
|
|
22
|
-
* Inferred from AppItemSchema which extends the base App API schema
|
|
23
|
-
*/
|
|
24
|
-
export type AppItem = z.infer<typeof AppItemSchema>;
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* Represents an authentication item returned by listAuthentications functions
|
|
28
|
-
* Inferred from AuthenticationItemSchema which extends the base Authentication API schema
|
|
29
|
-
*/
|
|
30
|
-
export type AuthenticationItem = z.infer<typeof AuthenticationItemSchema>;
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* Represents an action item returned by listActions functions
|
|
34
|
-
* Inferred from ActionItemSchema which extends the base Action API schema
|
|
35
|
-
*/
|
|
36
|
-
export type ActionItem = z.infer<typeof ActionItemSchema>;
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* Represents an input field item returned by listInputFields functions
|
|
40
|
-
* Inferred from InputFieldItemSchema which extends the base Need API schema
|
|
41
|
-
*/
|
|
42
|
-
export type InputFieldItem = z.infer<typeof InputFieldItemSchema>;
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* Represents an info field item (help text/copy) returned by listInputFields functions
|
|
46
|
-
* Inferred from InfoFieldItemSchema
|
|
47
|
-
*/
|
|
48
|
-
export type InfoFieldItem = z.infer<typeof InfoFieldItemSchema>;
|
|
49
|
-
|
|
50
|
-
/**
|
|
51
|
-
* Represents a fieldset (group of fields) returned by listInputFields functions
|
|
52
|
-
* This is defined as an interface rather than inferred due to recursive nature
|
|
53
|
-
*/
|
|
54
|
-
export type { FieldsetItem };
|
|
55
|
-
|
|
56
|
-
/**
|
|
57
|
-
* Represents a root field item (any field/fieldset type) returned by listInputFields
|
|
58
|
-
* Inferred from RootFieldItemSchema - use as RootFieldItem[]
|
|
59
|
-
*/
|
|
60
|
-
export type RootFieldItem = z.infer<typeof RootFieldItemSchema>;
|
|
61
|
-
|
|
62
|
-
/**
|
|
63
|
-
* Represents a user profile item returned by getProfile function
|
|
64
|
-
* Inferred from UserProfileItemSchema which extends the base UserProfile API schema
|
|
65
|
-
*/
|
|
66
|
-
export type UserProfileItem = z.infer<typeof UserProfileItemSchema>;
|