@zapier/zapier-sdk-cli 0.16.1 → 0.16.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 +18 -0
- package/dist/cli.cjs +7 -7
- package/dist/cli.mjs +7 -7
- package/dist/index.cjs +1 -1
- package/dist/index.mjs +1 -1
- package/dist/package.json +8 -2
- package/dist/src/cli.js +2 -1
- package/dist/src/utils/cli-generator.js +8 -7
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +11 -5
- package/src/cli.test.ts +0 -28
- package/src/cli.ts +0 -96
- package/src/generators/ast-generator.test.ts +0 -908
- package/src/generators/ast-generator.ts +0 -774
- package/src/index.ts +0 -12
- package/src/plugins/add/index.test.ts +0 -58
- package/src/plugins/add/index.ts +0 -177
- package/src/plugins/add/schemas.ts +0 -35
- package/src/plugins/buildManifest/index.test.ts +0 -679
- package/src/plugins/buildManifest/index.ts +0 -131
- package/src/plugins/buildManifest/schemas.ts +0 -55
- package/src/plugins/bundleCode/index.ts +0 -128
- package/src/plugins/bundleCode/schemas.ts +0 -24
- package/src/plugins/generateAppTypes/index.test.ts +0 -679
- package/src/plugins/generateAppTypes/index.ts +0 -227
- package/src/plugins/generateAppTypes/schemas.ts +0 -61
- package/src/plugins/getLoginConfigPath/index.ts +0 -45
- package/src/plugins/getLoginConfigPath/schemas.ts +0 -10
- package/src/plugins/index.ts +0 -8
- package/src/plugins/login/index.ts +0 -135
- package/src/plugins/login/schemas.ts +0 -13
- package/src/plugins/logout/index.ts +0 -37
- package/src/plugins/logout/schemas.ts +0 -8
- package/src/plugins/mcp/index.ts +0 -43
- package/src/plugins/mcp/schemas.ts +0 -13
- package/src/sdk.ts +0 -45
- package/src/telemetry/builders.ts +0 -113
- package/src/telemetry/events.ts +0 -39
- package/src/types/sdk.ts +0 -8
- package/src/utils/api/client.ts +0 -44
- package/src/utils/auth/login.ts +0 -214
- package/src/utils/cli-generator-utils.ts +0 -169
- package/src/utils/cli-generator.test.ts +0 -347
- package/src/utils/cli-generator.ts +0 -807
- package/src/utils/constants.ts +0 -9
- package/src/utils/directory-detection.ts +0 -23
- package/src/utils/errors.ts +0 -26
- package/src/utils/getCallablePromise.ts +0 -21
- package/src/utils/log.ts +0 -23
- package/src/utils/manifest-helpers.ts +0 -25
- package/src/utils/package-manager-detector.ts +0 -83
- package/src/utils/parameter-resolver.ts +0 -1075
- package/src/utils/schema-formatter.ts +0 -153
- package/src/utils/serializeAsync.ts +0 -26
- package/src/utils/spinner.ts +0 -23
- package/src/utils/version-checker.test.ts +0 -239
- package/src/utils/version-checker.ts +0 -237
- package/tsconfig.build.json +0 -18
- package/tsconfig.json +0 -19
- package/tsup.config.ts +0 -23
package/src/index.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
// Main exports for the CLI package
|
|
2
|
-
export { createZapierCliSdk, type ZapierCliSdkOptions } from "./sdk";
|
|
3
|
-
|
|
4
|
-
// Export CLI telemetry builders and types
|
|
5
|
-
export type {
|
|
6
|
-
CliEventContext,
|
|
7
|
-
CliCommandExecutedEventData,
|
|
8
|
-
} from "./telemetry/builders";
|
|
9
|
-
export { buildCliCommandExecutedEvent } from "./telemetry/builders";
|
|
10
|
-
export type { CliCommandExecutedEvent } from "./telemetry/events";
|
|
11
|
-
|
|
12
|
-
// All CLI functionality is now schema-driven via generateCLICommands
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect } from "vitest";
|
|
2
|
-
import { AddSchema } from "./schemas";
|
|
3
|
-
import { DEFAULT_CONFIG_PATH } from "@zapier/zapier-sdk";
|
|
4
|
-
|
|
5
|
-
describe("Add plugin", () => {
|
|
6
|
-
describe("schema validation", () => {
|
|
7
|
-
it("should accept valid options with authenticationIds", () => {
|
|
8
|
-
const result = AddSchema.safeParse({
|
|
9
|
-
appKeys: ["slack", "gmail"],
|
|
10
|
-
authenticationIds: ["123", "456"],
|
|
11
|
-
configPath: DEFAULT_CONFIG_PATH,
|
|
12
|
-
typesOutput: "src/types",
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
expect(result.success).toBe(true);
|
|
16
|
-
if (result.success) {
|
|
17
|
-
expect(result.data.authenticationIds).toEqual(["123", "456"]);
|
|
18
|
-
}
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
it("should accept options without authenticationIds", () => {
|
|
22
|
-
const result = AddSchema.safeParse({
|
|
23
|
-
appKeys: ["slack"],
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
expect(result.success).toBe(true);
|
|
27
|
-
if (result.success) {
|
|
28
|
-
expect(result.data.authenticationIds).toBeUndefined();
|
|
29
|
-
}
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
it("should reject invalid authenticationIds type", () => {
|
|
33
|
-
const result = AddSchema.safeParse({
|
|
34
|
-
appKeys: ["slack"],
|
|
35
|
-
authenticationIds: "123", // Should be array
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
expect(result.success).toBe(false);
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
it("should reject authenticationIds with non-string items", () => {
|
|
42
|
-
const result = AddSchema.safeParse({
|
|
43
|
-
appKeys: ["slack"],
|
|
44
|
-
authenticationIds: [123, 456], // Should be strings
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
expect(result.success).toBe(false);
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
it("should require at least one appKey", () => {
|
|
51
|
-
const result = AddSchema.safeParse({
|
|
52
|
-
appKeys: [],
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
expect(result.success).toBe(false);
|
|
56
|
-
});
|
|
57
|
-
});
|
|
58
|
-
});
|
package/src/plugins/add/index.ts
DELETED
|
@@ -1,177 +0,0 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
Plugin,
|
|
3
|
-
GetSdkType,
|
|
4
|
-
ListActionsPluginProvides,
|
|
5
|
-
ListAppsPluginProvides,
|
|
6
|
-
ListInputFieldsPluginProvides,
|
|
7
|
-
ListAuthenticationsPluginProvides,
|
|
8
|
-
} from "@zapier/zapier-sdk";
|
|
9
|
-
import { createFunction } from "@zapier/zapier-sdk";
|
|
10
|
-
import { AddSchema, type AddOptions } from "./schemas";
|
|
11
|
-
|
|
12
|
-
import { type GenerateAppTypesPluginProvides } from "../generateAppTypes";
|
|
13
|
-
import { type AppTypesProgressEvent } from "../generateAppTypes/schemas";
|
|
14
|
-
import { type BuildManifestPluginProvides } from "../buildManifest";
|
|
15
|
-
import { type ManifestBuildProgressEvent } from "../buildManifest/schemas";
|
|
16
|
-
|
|
17
|
-
import { detectTypesOutputDirectory } from "../../utils/directory-detection";
|
|
18
|
-
|
|
19
|
-
import { resolve } from "path";
|
|
20
|
-
export interface AddPluginProvides {
|
|
21
|
-
add: (options: AddOptions) => Promise<void>;
|
|
22
|
-
context: {
|
|
23
|
-
meta: {
|
|
24
|
-
add: {
|
|
25
|
-
inputSchema: typeof AddSchema;
|
|
26
|
-
};
|
|
27
|
-
};
|
|
28
|
-
};
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
export const addPlugin: Plugin<
|
|
32
|
-
GetSdkType<
|
|
33
|
-
ListAppsPluginProvides &
|
|
34
|
-
ListActionsPluginProvides &
|
|
35
|
-
ListInputFieldsPluginProvides &
|
|
36
|
-
ListAuthenticationsPluginProvides &
|
|
37
|
-
BuildManifestPluginProvides &
|
|
38
|
-
GenerateAppTypesPluginProvides
|
|
39
|
-
>,
|
|
40
|
-
{},
|
|
41
|
-
AddPluginProvides
|
|
42
|
-
> = ({ sdk }) => {
|
|
43
|
-
const add = createFunction(async function add(options: AddOptions) {
|
|
44
|
-
const {
|
|
45
|
-
appKeys,
|
|
46
|
-
authenticationIds,
|
|
47
|
-
configPath,
|
|
48
|
-
typesOutput = await detectTypesOutputDirectory(),
|
|
49
|
-
} = options;
|
|
50
|
-
const resolvedTypesOutput = resolve(typesOutput);
|
|
51
|
-
|
|
52
|
-
console.log(`📦 Adding ${appKeys.length} app(s)...`);
|
|
53
|
-
|
|
54
|
-
// Track app names for better console output
|
|
55
|
-
const appSlugAndKeyMap = new Map<string, string>();
|
|
56
|
-
|
|
57
|
-
// Define progress handler for manifest building
|
|
58
|
-
const handleManifestProgress = (event: ManifestBuildProgressEvent) => {
|
|
59
|
-
switch (event.type) {
|
|
60
|
-
case "apps_lookup_start":
|
|
61
|
-
console.log(`📦 Looking up ${event.count} app(s)...`);
|
|
62
|
-
break;
|
|
63
|
-
|
|
64
|
-
case "app_found":
|
|
65
|
-
// Store the app display name for later use
|
|
66
|
-
const displayName = event.app.slug
|
|
67
|
-
? `${event.app.slug} (${event.app.key})`
|
|
68
|
-
: event.app.key;
|
|
69
|
-
appSlugAndKeyMap.set(event.app.key, displayName);
|
|
70
|
-
break;
|
|
71
|
-
|
|
72
|
-
case "apps_lookup_complete":
|
|
73
|
-
if (event.count === 0) {
|
|
74
|
-
console.warn("⚠️ No apps found");
|
|
75
|
-
}
|
|
76
|
-
break;
|
|
77
|
-
|
|
78
|
-
case "app_processing_start":
|
|
79
|
-
const appName = event.slug
|
|
80
|
-
? `${event.slug} (${event.appKey})`
|
|
81
|
-
: event.appKey;
|
|
82
|
-
console.log(`📦 Adding ${appName}...`);
|
|
83
|
-
break;
|
|
84
|
-
|
|
85
|
-
case "manifest_updated":
|
|
86
|
-
const appDisplay = appSlugAndKeyMap.get(event.appKey) || event.appKey;
|
|
87
|
-
console.log(
|
|
88
|
-
`📝 Locked ${appDisplay} to ${event.appKey}@${event.version} using key '${event.manifestKey}'`,
|
|
89
|
-
);
|
|
90
|
-
break;
|
|
91
|
-
|
|
92
|
-
case "app_processing_error":
|
|
93
|
-
const errorApp = appSlugAndKeyMap.get(event.appKey) || event.appKey;
|
|
94
|
-
console.warn(`⚠️ ${event.error} for ${errorApp}`);
|
|
95
|
-
break;
|
|
96
|
-
}
|
|
97
|
-
};
|
|
98
|
-
|
|
99
|
-
// Define progress handler for type generation
|
|
100
|
-
const handleTypesProgress = (event: AppTypesProgressEvent) => {
|
|
101
|
-
switch (event.type) {
|
|
102
|
-
case "authentications_lookup_start":
|
|
103
|
-
console.log(`🔐 Looking up ${event.count} authentication(s)...`);
|
|
104
|
-
break;
|
|
105
|
-
|
|
106
|
-
case "authentications_lookup_complete":
|
|
107
|
-
console.log(`🔐 Found ${event.count} authentication(s)`);
|
|
108
|
-
break;
|
|
109
|
-
|
|
110
|
-
case "authentication_matched":
|
|
111
|
-
const appWithAuth =
|
|
112
|
-
appSlugAndKeyMap.get(event.appKey) || event.appKey;
|
|
113
|
-
console.log(
|
|
114
|
-
`🔐 Using authentication ${event.authenticationId} (${event.authenticationTitle}) for ${appWithAuth}`,
|
|
115
|
-
);
|
|
116
|
-
break;
|
|
117
|
-
|
|
118
|
-
case "authentication_not_matched":
|
|
119
|
-
const appWithoutAuth =
|
|
120
|
-
appSlugAndKeyMap.get(event.appKey) || event.appKey;
|
|
121
|
-
console.warn(
|
|
122
|
-
`⚠️ No matching authentication found for ${appWithoutAuth}`,
|
|
123
|
-
);
|
|
124
|
-
break;
|
|
125
|
-
|
|
126
|
-
case "file_written":
|
|
127
|
-
console.log(
|
|
128
|
-
`🔧 Generated types for ${event.manifestKey} at ${event.filePath}`,
|
|
129
|
-
);
|
|
130
|
-
break;
|
|
131
|
-
|
|
132
|
-
case "app_processing_error":
|
|
133
|
-
const errorApp = appSlugAndKeyMap.get(event.appKey) || event.appKey;
|
|
134
|
-
console.warn(`⚠️ ${event.error} for ${errorApp}`);
|
|
135
|
-
break;
|
|
136
|
-
}
|
|
137
|
-
};
|
|
138
|
-
|
|
139
|
-
const manifestResult = await sdk.buildManifest({
|
|
140
|
-
appKeys,
|
|
141
|
-
skipWrite: false,
|
|
142
|
-
configPath,
|
|
143
|
-
onProgress: handleManifestProgress,
|
|
144
|
-
});
|
|
145
|
-
|
|
146
|
-
const typesResult = await sdk.generateAppTypes({
|
|
147
|
-
appKeys,
|
|
148
|
-
authenticationIds,
|
|
149
|
-
skipWrite: false,
|
|
150
|
-
typesOutputDirectory: resolvedTypesOutput,
|
|
151
|
-
onProgress: handleTypesProgress,
|
|
152
|
-
});
|
|
153
|
-
|
|
154
|
-
const results = manifestResult.manifest?.apps || {};
|
|
155
|
-
|
|
156
|
-
// Final summary
|
|
157
|
-
const successfulApps = Object.keys(results).filter(
|
|
158
|
-
(manifestKey) => typesResult.writtenFiles?.[manifestKey],
|
|
159
|
-
);
|
|
160
|
-
|
|
161
|
-
if (successfulApps.length > 0) {
|
|
162
|
-
console.log(`✅ Added ${successfulApps.length} app(s) to manifest`);
|
|
163
|
-
}
|
|
164
|
-
}, AddSchema);
|
|
165
|
-
|
|
166
|
-
return {
|
|
167
|
-
add,
|
|
168
|
-
context: {
|
|
169
|
-
meta: {
|
|
170
|
-
add: {
|
|
171
|
-
categories: ["utility"],
|
|
172
|
-
inputSchema: AddSchema,
|
|
173
|
-
},
|
|
174
|
-
},
|
|
175
|
-
},
|
|
176
|
-
};
|
|
177
|
-
};
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
import { DEFAULT_CONFIG_PATH } from "@zapier/zapier-sdk";
|
|
3
|
-
|
|
4
|
-
export const AddSchema = z
|
|
5
|
-
.object({
|
|
6
|
-
appKeys: z
|
|
7
|
-
.array(z.string().min(1, "App key cannot be empty"))
|
|
8
|
-
.min(1, "At least one app key is required")
|
|
9
|
-
.describe(
|
|
10
|
-
"One or more app keys to add (e.g., 'slack', 'github', 'trello')",
|
|
11
|
-
),
|
|
12
|
-
authenticationIds: z
|
|
13
|
-
.array(z.string())
|
|
14
|
-
.optional()
|
|
15
|
-
.describe(
|
|
16
|
-
"Authentication IDs to use for type generation (e.g., ['123', '456'])",
|
|
17
|
-
),
|
|
18
|
-
configPath: z
|
|
19
|
-
.string()
|
|
20
|
-
.optional()
|
|
21
|
-
.describe(
|
|
22
|
-
`Path to Zapier config file (defaults to '${DEFAULT_CONFIG_PATH}', e.g., './custom/.zapierrc')`,
|
|
23
|
-
),
|
|
24
|
-
typesOutput: z
|
|
25
|
-
.string()
|
|
26
|
-
.optional()
|
|
27
|
-
.describe(
|
|
28
|
-
"Directory for TypeScript type files (defaults to (src/lib/.)/zapier/apps/, e.g., './src/types/zapier/')",
|
|
29
|
-
),
|
|
30
|
-
})
|
|
31
|
-
.describe(
|
|
32
|
-
"Add apps with manifest locking and TypeScript type generation - updates .zapierrc with app versions and generates TypeScript definition files",
|
|
33
|
-
);
|
|
34
|
-
|
|
35
|
-
export type AddOptions = z.infer<typeof AddSchema>;
|