@zapier/zapier-sdk-cli 0.21.0 → 0.22.1
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 +16 -0
- package/dist/cli.cjs +2 -2
- package/dist/cli.mjs +2 -2
- package/dist/index.cjs +1 -1
- package/dist/index.mjs +1 -1
- package/dist/package.json +78 -0
- package/dist/src/cli.d.ts +2 -0
- package/dist/src/cli.js +105 -0
- package/dist/src/generators/ast-generator.d.ts +41 -0
- package/dist/src/generators/ast-generator.js +409 -0
- package/dist/src/index.d.ts +4 -0
- package/dist/src/index.js +4 -0
- package/dist/src/plugins/add/index.d.ts +15 -0
- package/dist/src/plugins/add/index.js +103 -0
- package/dist/src/plugins/add/schemas.d.ts +8 -0
- package/dist/src/plugins/add/schemas.js +22 -0
- package/dist/src/plugins/buildManifest/index.d.ts +13 -0
- package/dist/src/plugins/buildManifest/index.js +81 -0
- package/dist/src/plugins/buildManifest/schemas.d.ts +44 -0
- package/dist/src/plugins/buildManifest/schemas.js +17 -0
- package/dist/src/plugins/bundleCode/index.d.ts +15 -0
- package/dist/src/plugins/bundleCode/index.js +80 -0
- package/dist/src/plugins/bundleCode/schemas.d.ts +10 -0
- package/dist/src/plugins/bundleCode/schemas.js +19 -0
- package/dist/src/plugins/generateAppTypes/index.d.ts +13 -0
- package/dist/src/plugins/generateAppTypes/index.js +157 -0
- package/dist/src/plugins/generateAppTypes/schemas.d.ts +58 -0
- package/dist/src/plugins/generateAppTypes/schemas.js +21 -0
- package/dist/src/plugins/getLoginConfigPath/index.d.ts +15 -0
- package/dist/src/plugins/getLoginConfigPath/index.js +19 -0
- package/dist/src/plugins/getLoginConfigPath/schemas.d.ts +3 -0
- package/dist/src/plugins/getLoginConfigPath/schemas.js +5 -0
- package/dist/src/plugins/index.d.ts +8 -0
- package/dist/src/plugins/index.js +8 -0
- package/dist/src/plugins/login/index.d.ts +23 -0
- package/dist/src/plugins/login/index.js +95 -0
- package/dist/src/plugins/login/schemas.d.ts +5 -0
- package/dist/src/plugins/login/schemas.js +10 -0
- package/dist/src/plugins/logout/index.d.ts +15 -0
- package/dist/src/plugins/logout/index.js +18 -0
- package/dist/src/plugins/logout/schemas.d.ts +3 -0
- package/dist/src/plugins/logout/schemas.js +5 -0
- package/dist/src/plugins/mcp/index.d.ts +15 -0
- package/dist/src/plugins/mcp/index.js +24 -0
- package/dist/src/plugins/mcp/schemas.d.ts +5 -0
- package/dist/src/plugins/mcp/schemas.js +10 -0
- package/dist/src/sdk.d.ts +9 -0
- package/dist/src/sdk.js +24 -0
- package/dist/src/telemetry/builders.d.ts +42 -0
- package/dist/src/telemetry/builders.js +55 -0
- package/dist/src/telemetry/events.d.ts +37 -0
- package/dist/src/telemetry/events.js +4 -0
- package/dist/src/types/sdk.d.ts +5 -0
- package/dist/src/types/sdk.js +1 -0
- package/dist/src/utils/api/client.d.ts +15 -0
- package/dist/src/utils/api/client.js +27 -0
- package/dist/src/utils/auth/login.d.ts +7 -0
- package/dist/src/utils/auth/login.js +154 -0
- package/dist/src/utils/cli-generator-utils.d.ts +14 -0
- package/dist/src/utils/cli-generator-utils.js +122 -0
- package/dist/src/utils/cli-generator.d.ts +3 -0
- package/dist/src/utils/cli-generator.js +555 -0
- package/dist/src/utils/constants.d.ts +3 -0
- package/dist/src/utils/constants.js +5 -0
- package/dist/src/utils/directory-detection.d.ts +5 -0
- package/dist/src/utils/directory-detection.js +21 -0
- package/dist/src/utils/errors.d.ts +16 -0
- package/dist/src/utils/errors.js +19 -0
- package/dist/src/utils/getCallablePromise.d.ts +6 -0
- package/dist/src/utils/getCallablePromise.js +14 -0
- package/dist/src/utils/log.d.ts +8 -0
- package/dist/src/utils/log.js +21 -0
- package/dist/src/utils/manifest-helpers.d.ts +10 -0
- package/dist/src/utils/manifest-helpers.js +19 -0
- package/dist/src/utils/package-manager-detector.d.ts +16 -0
- package/dist/src/utils/package-manager-detector.js +77 -0
- package/dist/src/utils/parameter-resolver.d.ts +42 -0
- package/dist/src/utils/parameter-resolver.js +699 -0
- package/dist/src/utils/schema-formatter.d.ts +6 -0
- package/dist/src/utils/schema-formatter.js +115 -0
- package/dist/src/utils/serializeAsync.d.ts +2 -0
- package/dist/src/utils/serializeAsync.js +16 -0
- package/dist/src/utils/spinner.d.ts +1 -0
- package/dist/src/utils/spinner.js +21 -0
- package/dist/src/utils/version-checker.d.ts +17 -0
- package/dist/src/utils/version-checker.js +156 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# @zapier/zapier-sdk-cli
|
|
2
2
|
|
|
3
|
+
## 0.22.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [7bd3c5c]
|
|
8
|
+
- @zapier/zapier-sdk@0.20.1
|
|
9
|
+
- @zapier/zapier-sdk-mcp@0.5.1
|
|
10
|
+
|
|
11
|
+
## 0.22.0
|
|
12
|
+
|
|
13
|
+
- Fix 0.21.0 saying to update to 0.21.0.
|
|
14
|
+
|
|
15
|
+
## 0.21.0
|
|
16
|
+
|
|
17
|
+
- Update dependency to @zapier/zapier-sdk@0.20.0 after accidentally publishing a major version update.
|
|
18
|
+
|
|
3
19
|
## 0.19.0
|
|
4
20
|
|
|
5
21
|
### Minor Changes
|
package/dist/cli.cjs
CHANGED
|
@@ -1656,7 +1656,7 @@ var LoginSchema = zod.z.object({
|
|
|
1656
1656
|
|
|
1657
1657
|
// package.json
|
|
1658
1658
|
var package_default = {
|
|
1659
|
-
version: "0.
|
|
1659
|
+
version: "0.22.1"};
|
|
1660
1660
|
|
|
1661
1661
|
// src/telemetry/builders.ts
|
|
1662
1662
|
function createCliBaseEvent(context = {}) {
|
|
@@ -2937,7 +2937,7 @@ function createZapierCliSdk(options = {}) {
|
|
|
2937
2937
|
// package.json with { type: 'json' }
|
|
2938
2938
|
var package_default2 = {
|
|
2939
2939
|
name: "@zapier/zapier-sdk-cli",
|
|
2940
|
-
version: "0.
|
|
2940
|
+
version: "0.22.1"};
|
|
2941
2941
|
function detectPackageManager(cwd = process.cwd()) {
|
|
2942
2942
|
const ua = process.env.npm_config_user_agent;
|
|
2943
2943
|
if (ua) {
|
package/dist/cli.mjs
CHANGED
|
@@ -1620,7 +1620,7 @@ var LoginSchema = z.object({
|
|
|
1620
1620
|
|
|
1621
1621
|
// package.json
|
|
1622
1622
|
var package_default = {
|
|
1623
|
-
version: "0.
|
|
1623
|
+
version: "0.22.1"};
|
|
1624
1624
|
|
|
1625
1625
|
// src/telemetry/builders.ts
|
|
1626
1626
|
function createCliBaseEvent(context = {}) {
|
|
@@ -2901,7 +2901,7 @@ function createZapierCliSdk(options = {}) {
|
|
|
2901
2901
|
// package.json with { type: 'json' }
|
|
2902
2902
|
var package_default2 = {
|
|
2903
2903
|
name: "@zapier/zapier-sdk-cli",
|
|
2904
|
-
version: "0.
|
|
2904
|
+
version: "0.22.1"};
|
|
2905
2905
|
function detectPackageManager(cwd = process.cwd()) {
|
|
2906
2906
|
const ua = process.env.npm_config_user_agent;
|
|
2907
2907
|
if (ua) {
|
package/dist/index.cjs
CHANGED
package/dist/index.mjs
CHANGED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@zapier/zapier-sdk-cli",
|
|
3
|
+
"version": "0.22.1",
|
|
4
|
+
"description": "Command line interface for Zapier SDK",
|
|
5
|
+
"main": "dist/index.cjs",
|
|
6
|
+
"module": "dist/index.mjs",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"require": {
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"default": "./dist/index.cjs"
|
|
13
|
+
},
|
|
14
|
+
"import": {
|
|
15
|
+
"types": "./dist/index.d.mts",
|
|
16
|
+
"default": "./dist/index.mjs"
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
"bin": {
|
|
21
|
+
"zapier-sdk": "./bin/zapier-sdk.mjs"
|
|
22
|
+
},
|
|
23
|
+
"scripts": {
|
|
24
|
+
"test": "vitest",
|
|
25
|
+
"build": "tsup",
|
|
26
|
+
"clean": "rm -rf dist",
|
|
27
|
+
"rebuild": "pnpm clean && pnpm build",
|
|
28
|
+
"dev": "tsx src/cli.ts",
|
|
29
|
+
"typecheck": "tsc --project tsconfig.build.json --noEmit",
|
|
30
|
+
"prepublishOnly": "node ../../scripts/check-version.js"
|
|
31
|
+
},
|
|
32
|
+
"keywords": [
|
|
33
|
+
"zapier",
|
|
34
|
+
"cli",
|
|
35
|
+
"sdk"
|
|
36
|
+
],
|
|
37
|
+
"author": "",
|
|
38
|
+
"license": "SEE LICENSE IN LICENSE",
|
|
39
|
+
"files": [
|
|
40
|
+
"dist",
|
|
41
|
+
"bin",
|
|
42
|
+
"README.md",
|
|
43
|
+
"CHANGELOG.md"
|
|
44
|
+
],
|
|
45
|
+
"publishConfig": {
|
|
46
|
+
"access": "public"
|
|
47
|
+
},
|
|
48
|
+
"dependencies": {
|
|
49
|
+
"@zapier/zapier-sdk": "workspace:*",
|
|
50
|
+
"@zapier/zapier-sdk-cli-login": "workspace:*",
|
|
51
|
+
"@zapier/zapier-sdk-mcp": "workspace:*",
|
|
52
|
+
"chalk": "^5.3.0",
|
|
53
|
+
"cli-table3": "^0.6.5",
|
|
54
|
+
"commander": "^12.0.0",
|
|
55
|
+
"conf": "^14.0.0",
|
|
56
|
+
"esbuild": "^0.25.5",
|
|
57
|
+
"express": "^5.1.0",
|
|
58
|
+
"inquirer": "^12.6.3",
|
|
59
|
+
"is-installed-globally": "^1.0.0",
|
|
60
|
+
"jsonwebtoken": "^9.0.2",
|
|
61
|
+
"open": "^10.2.0",
|
|
62
|
+
"ora": "^8.2.0",
|
|
63
|
+
"package-json": "^10.0.1",
|
|
64
|
+
"pkce-challenge": "^5.0.0",
|
|
65
|
+
"semver": "^7.7.3",
|
|
66
|
+
"typescript": "^5.8.3",
|
|
67
|
+
"zod": "4.2.1"
|
|
68
|
+
},
|
|
69
|
+
"devDependencies": {
|
|
70
|
+
"@types/express": "^5.0.3",
|
|
71
|
+
"@types/inquirer": "^9.0.8",
|
|
72
|
+
"@types/jsonwebtoken": "^9.0.10",
|
|
73
|
+
"@types/node": "^24.0.1",
|
|
74
|
+
"@types/semver": "^7.7.1",
|
|
75
|
+
"tsup": "^8.5.0",
|
|
76
|
+
"vitest": "^3.2.3"
|
|
77
|
+
}
|
|
78
|
+
}
|
package/dist/src/cli.js
ADDED
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { Command, CommanderError } from "commander";
|
|
3
|
+
import { generateCliCommands } from "./utils/cli-generator";
|
|
4
|
+
import { createZapierCliSdk } from "./sdk";
|
|
5
|
+
import packageJson from "../package.json" with { type: "json" };
|
|
6
|
+
import { ZapierCliError } from "./utils/errors";
|
|
7
|
+
import { checkAndNotifyUpdates } from "./utils/version-checker";
|
|
8
|
+
const program = new Command();
|
|
9
|
+
program
|
|
10
|
+
.name("zapier-sdk")
|
|
11
|
+
.description("CLI for Zapier SDK")
|
|
12
|
+
.version(packageJson.version, "-v, --version", "display version number")
|
|
13
|
+
.option("--debug", "Enable debug logging")
|
|
14
|
+
.option("--base-url <url>", "Base URL for Zapier API endpoints")
|
|
15
|
+
.option("--credentials <token>", "Authentication token")
|
|
16
|
+
.option("--credentials-client-id <id>", "OAuth client ID for authentication")
|
|
17
|
+
.option("--credentials-client-secret <secret>", "OAuth client secret for authentication")
|
|
18
|
+
.option("--credentials-base-url <url>", "Base URL for authentication endpoints")
|
|
19
|
+
.option("--tracking-base-url <url>", "Base URL for Zapier tracking endpoints");
|
|
20
|
+
// Check for debug flag early (support both flag and env var)
|
|
21
|
+
const isDebugMode = process.env.DEBUG === "true" || process.argv.includes("--debug");
|
|
22
|
+
// Helper to get flag value from argv
|
|
23
|
+
function getFlagValue(flagName) {
|
|
24
|
+
const index = process.argv.indexOf(flagName);
|
|
25
|
+
return index !== -1 ? process.argv[index + 1] : undefined;
|
|
26
|
+
}
|
|
27
|
+
// Extract options from process.argv for early SDK creation
|
|
28
|
+
// We need to create the SDK before parsing to generate commands from schemas
|
|
29
|
+
const baseUrl = getFlagValue("--base-url");
|
|
30
|
+
const credentialsToken = getFlagValue("--credentials");
|
|
31
|
+
const credentialsClientId = getFlagValue("--credentials-client-id");
|
|
32
|
+
const credentialsClientSecret = getFlagValue("--credentials-client-secret");
|
|
33
|
+
const credentialsBaseUrl = getFlagValue("--credentials-base-url");
|
|
34
|
+
const trackingBaseUrl = getFlagValue("--tracking-base-url");
|
|
35
|
+
// Build credentials object from flags
|
|
36
|
+
function buildCredentialsFromFlags() {
|
|
37
|
+
// If a direct token is provided, use it
|
|
38
|
+
if (credentialsToken) {
|
|
39
|
+
return credentialsToken;
|
|
40
|
+
}
|
|
41
|
+
// If client ID is provided, build a credentials object
|
|
42
|
+
if (credentialsClientId) {
|
|
43
|
+
if (credentialsClientSecret) {
|
|
44
|
+
// Client credentials flow
|
|
45
|
+
return {
|
|
46
|
+
type: "client_credentials",
|
|
47
|
+
clientId: credentialsClientId,
|
|
48
|
+
clientSecret: credentialsClientSecret,
|
|
49
|
+
baseUrl: credentialsBaseUrl,
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
53
|
+
// PKCE flow (no secret)
|
|
54
|
+
return {
|
|
55
|
+
type: "pkce",
|
|
56
|
+
clientId: credentialsClientId,
|
|
57
|
+
baseUrl: credentialsBaseUrl,
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
// No credentials from flags - will fall back to env vars or stored login
|
|
62
|
+
return undefined;
|
|
63
|
+
}
|
|
64
|
+
const credentials = buildCredentialsFromFlags();
|
|
65
|
+
// Create CLI SDK instance with all plugins and URL options
|
|
66
|
+
const sdk = createZapierCliSdk({
|
|
67
|
+
debug: isDebugMode,
|
|
68
|
+
credentials,
|
|
69
|
+
baseUrl,
|
|
70
|
+
trackingBaseUrl,
|
|
71
|
+
});
|
|
72
|
+
// Auth commands now handled by plugins
|
|
73
|
+
// Generate CLI commands from SDK schemas (including CLI plugins)
|
|
74
|
+
generateCliCommands(program, sdk);
|
|
75
|
+
// MCP command now handled by plugin
|
|
76
|
+
// Override Commander's default exit behavior to handle our custom errors
|
|
77
|
+
program.exitOverride();
|
|
78
|
+
(async () => {
|
|
79
|
+
let exitCode = 0;
|
|
80
|
+
// Start version checking non-blocking
|
|
81
|
+
const versionCheckPromise = checkAndNotifyUpdates({
|
|
82
|
+
packageName: packageJson.name,
|
|
83
|
+
currentVersion: packageJson.version,
|
|
84
|
+
});
|
|
85
|
+
try {
|
|
86
|
+
await program.parseAsync();
|
|
87
|
+
}
|
|
88
|
+
catch (error) {
|
|
89
|
+
if (error instanceof ZapierCliError) {
|
|
90
|
+
exitCode = error.exitCode;
|
|
91
|
+
}
|
|
92
|
+
else if (error instanceof CommanderError) {
|
|
93
|
+
exitCode = error.exitCode;
|
|
94
|
+
}
|
|
95
|
+
else {
|
|
96
|
+
// For any other unexpected errors, exit with code 1
|
|
97
|
+
console.error("Unexpected error:", error);
|
|
98
|
+
exitCode = 1;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
// Wait for version checking to complete
|
|
102
|
+
await versionCheckPromise;
|
|
103
|
+
// Use exitCode instead of exit() to allow stdout to flush when piped
|
|
104
|
+
process.exitCode = exitCode;
|
|
105
|
+
})();
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { GetSdkType, ListActionsPluginProvides, ListInputFieldsPluginProvides, ManifestPluginProvides, AppItem } from "@zapier/zapier-sdk";
|
|
2
|
+
interface GenerateTypesOptions {
|
|
3
|
+
app: AppItem;
|
|
4
|
+
authenticationId?: string | number;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* AST-based TypeScript type generator using the TypeScript Compiler API
|
|
8
|
+
*/
|
|
9
|
+
export declare class AstTypeGenerator {
|
|
10
|
+
private readonly factory;
|
|
11
|
+
private readonly printer;
|
|
12
|
+
/**
|
|
13
|
+
* Generate TypeScript types using AST for a specific app
|
|
14
|
+
*/
|
|
15
|
+
generateTypes(options: GenerateTypesOptions & {
|
|
16
|
+
sdk: GetSdkType<ListActionsPluginProvides & ListInputFieldsPluginProvides & ManifestPluginProvides>;
|
|
17
|
+
}): Promise<string>;
|
|
18
|
+
private createSourceFile;
|
|
19
|
+
private createImportStatement;
|
|
20
|
+
private createTypeImportStatement;
|
|
21
|
+
private groupActionsByType;
|
|
22
|
+
private createInputInterface;
|
|
23
|
+
private createActionInterface;
|
|
24
|
+
private createAppProxyInterface;
|
|
25
|
+
private createFetchMethodProperty;
|
|
26
|
+
private createAppFactoryInterface;
|
|
27
|
+
private createAppWithFactoryType;
|
|
28
|
+
private createModuleAugmentation;
|
|
29
|
+
private mapFieldTypeToTypeNode;
|
|
30
|
+
private capitalize;
|
|
31
|
+
private sanitizeActionName;
|
|
32
|
+
private sanitizeFieldName;
|
|
33
|
+
private escapeComment;
|
|
34
|
+
private createPropertyName;
|
|
35
|
+
private isValidIdentifier;
|
|
36
|
+
private getPreferredProgrammaticKey;
|
|
37
|
+
private getPreferredAppName;
|
|
38
|
+
private sanitizeToIdentifier;
|
|
39
|
+
private getAllKeys;
|
|
40
|
+
}
|
|
41
|
+
export {};
|