@zapier/zapier-sdk-cli 0.13.4 → 0.13.6

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.
Files changed (45) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/README.md +39 -0
  3. package/dist/cli.cjs +354 -71
  4. package/dist/cli.mjs +355 -72
  5. package/dist/index.cjs +353 -70
  6. package/dist/index.d.mts +154 -2
  7. package/dist/index.d.ts +154 -2
  8. package/dist/index.mjs +354 -71
  9. package/dist/package.json +2 -2
  10. package/dist/src/plugins/add/index.d.ts +4 -2
  11. package/dist/src/plugins/add/index.js +89 -98
  12. package/dist/src/plugins/buildManifest/index.d.ts +13 -0
  13. package/dist/src/plugins/buildManifest/index.js +81 -0
  14. package/dist/src/plugins/buildManifest/schemas.d.ts +57 -0
  15. package/dist/src/plugins/buildManifest/schemas.js +17 -0
  16. package/dist/src/plugins/generateAppTypes/index.d.ts +13 -0
  17. package/dist/src/plugins/generateAppTypes/index.js +169 -0
  18. package/dist/src/plugins/generateAppTypes/schemas.d.ts +72 -0
  19. package/dist/src/plugins/generateAppTypes/schemas.js +21 -0
  20. package/dist/src/plugins/index.d.ts +2 -0
  21. package/dist/src/plugins/index.js +2 -0
  22. package/dist/src/sdk.d.ts +2 -2
  23. package/dist/src/sdk.js +16 -14
  24. package/dist/src/types/sdk.d.ts +5 -0
  25. package/dist/src/types/sdk.js +1 -0
  26. package/dist/src/utils/directory-detection.d.ts +5 -0
  27. package/dist/src/utils/directory-detection.js +21 -0
  28. package/dist/src/utils/manifest-helpers.d.ts +13 -0
  29. package/dist/src/utils/manifest-helpers.js +19 -0
  30. package/dist/tsconfig.tsbuildinfo +1 -1
  31. package/package.json +5 -5
  32. package/src/plugins/add/index.ts +123 -125
  33. package/src/plugins/buildManifest/index.test.ts +612 -0
  34. package/src/plugins/buildManifest/index.ts +128 -0
  35. package/src/plugins/buildManifest/schemas.ts +61 -0
  36. package/src/plugins/generateAppTypes/index.ts +235 -0
  37. package/src/plugins/generateAppTypes/schemas.ts +65 -0
  38. package/src/plugins/index.ts +2 -0
  39. package/src/sdk.ts +23 -20
  40. package/src/types/sdk.ts +8 -0
  41. package/src/utils/directory-detection.ts +23 -0
  42. package/src/utils/manifest-helpers.ts +28 -0
  43. /package/dist/src/{plugins/add → generators}/ast-generator.d.ts +0 -0
  44. /package/dist/src/{plugins/add → generators}/ast-generator.js +0 -0
  45. /package/src/{plugins/add → generators}/ast-generator.ts +0 -0
@@ -4,3 +4,5 @@ export { mcpPlugin } from "./mcp";
4
4
  export { bundleCodePlugin } from "./bundleCode";
5
5
  export { getLoginConfigPathPlugin } from "./getLoginConfigPath";
6
6
  export { addPlugin } from "./add";
7
+ export { generateAppTypesPlugin } from "./generateAppTypes";
8
+ export { buildManifestPlugin } from "./buildManifest";
@@ -4,3 +4,5 @@ export { mcpPlugin } from "./mcp";
4
4
  export { bundleCodePlugin } from "./bundleCode";
5
5
  export { getLoginConfigPathPlugin } from "./getLoginConfigPath";
6
6
  export { addPlugin } from "./add";
7
+ export { generateAppTypesPlugin } from "./generateAppTypes";
8
+ export { buildManifestPlugin } from "./buildManifest";
package/dist/src/sdk.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { type ZapierSdk } from "@zapier/zapier-sdk";
1
+ import type { ZapierSdkCli } from "./types/sdk";
2
2
  export interface ZapierCliSdkOptions {
3
3
  debug?: boolean;
4
4
  eventEmission?: {
@@ -14,4 +14,4 @@ export interface ZapierCliSdkOptions {
14
14
  * Create a Zapier SDK instance configured specifically for the CLI
15
15
  * Includes all CLI-specific plugins in addition to the standard SDK functionality
16
16
  */
17
- export declare function createZapierCliSdk(options?: ZapierCliSdkOptions): ZapierSdk;
17
+ export declare function createZapierCliSdk(options?: ZapierCliSdkOptions): ZapierSdkCli;
package/dist/src/sdk.js CHANGED
@@ -1,23 +1,25 @@
1
1
  import { createZapierSdkWithoutRegistry, registryPlugin, } from "@zapier/zapier-sdk";
2
- import { loginPlugin, logoutPlugin, mcpPlugin, bundleCodePlugin, getLoginConfigPathPlugin, addPlugin, } from "./plugins/index";
2
+ import { loginPlugin, logoutPlugin, mcpPlugin, bundleCodePlugin, getLoginConfigPathPlugin, addPlugin, generateAppTypesPlugin, buildManifestPlugin, } from "./plugins/index";
3
3
  /**
4
4
  * Create a Zapier SDK instance configured specifically for the CLI
5
5
  * Includes all CLI-specific plugins in addition to the standard SDK functionality
6
6
  */
7
7
  export function createZapierCliSdk(options = {}) {
8
- // Create SDK instance without registry
9
- let sdk = createZapierSdkWithoutRegistry({
8
+ // Create SDK instance and chain all plugins
9
+ // Chaining prevents type widening that occurs with let reassignment
10
+ return (createZapierSdkWithoutRegistry({
10
11
  debug: options.debug,
11
12
  eventEmission: options.eventEmission,
12
- });
13
- // Add CLI-specific plugins before registry
14
- sdk = sdk.addPlugin(bundleCodePlugin);
15
- sdk = sdk.addPlugin(getLoginConfigPathPlugin);
16
- sdk = sdk.addPlugin(addPlugin);
17
- sdk = sdk.addPlugin(mcpPlugin);
18
- sdk = sdk.addPlugin(loginPlugin);
19
- sdk = sdk.addPlugin(logoutPlugin);
20
- // Add registry plugin to finalize SDK
21
- const finalSdk = sdk.addPlugin(registryPlugin);
22
- return finalSdk;
13
+ })
14
+ // Add CLI-specific plugins before registry
15
+ .addPlugin(generateAppTypesPlugin)
16
+ .addPlugin(buildManifestPlugin)
17
+ .addPlugin(bundleCodePlugin)
18
+ .addPlugin(getLoginConfigPathPlugin)
19
+ .addPlugin(addPlugin)
20
+ .addPlugin(mcpPlugin)
21
+ .addPlugin(loginPlugin)
22
+ .addPlugin(logoutPlugin)
23
+ // Add registry plugin to finalize SDK
24
+ .addPlugin(registryPlugin));
23
25
  }
@@ -0,0 +1,5 @@
1
+ import type { GetSdkType, ZapierSdk } from "@zapier/zapier-sdk";
2
+ import type { BuildManifestPluginProvides } from "../plugins/buildManifest";
3
+ import type { GenerateAppTypesPluginProvides } from "../plugins/generateAppTypes";
4
+ export interface ZapierSdkCli extends GetSdkType<ZapierSdk & BuildManifestPluginProvides & GenerateAppTypesPluginProvides> {
5
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Detect the best default directory for TypeScript types
3
+ * Looks for src or lib directories, falls back to current directory
4
+ */
5
+ export declare function detectTypesOutputDirectory(): Promise<string>;
@@ -0,0 +1,21 @@
1
+ import { access } from "fs/promises";
2
+ import { join } from "path";
3
+ /**
4
+ * Detect the best default directory for TypeScript types
5
+ * Looks for src or lib directories, falls back to current directory
6
+ */
7
+ export async function detectTypesOutputDirectory() {
8
+ // Check for common source directories in priority order
9
+ const candidates = ["src", "lib"];
10
+ for (const candidate of candidates) {
11
+ try {
12
+ await access(candidate);
13
+ return join(candidate, "zapier", "apps");
14
+ }
15
+ catch {
16
+ // Directory doesn't exist, continue to next candidate
17
+ }
18
+ }
19
+ // Fall back to current directory
20
+ return "./zapier/apps/";
21
+ }
@@ -0,0 +1,13 @@
1
+ import type { AppItem } from "@zapier/zapier-sdk";
2
+ /**
3
+ * Get the preferred key for a manifest entry
4
+ * Prefers slug over implementation name
5
+ */
6
+ export declare function getManifestKey(app: AppItem): string;
7
+ /**
8
+ * Create a manifest entry from an app
9
+ */
10
+ export declare function createManifestEntry(app: AppItem): {
11
+ implementationName: string;
12
+ version: string;
13
+ };
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Get the preferred key for a manifest entry
3
+ * Prefers slug over implementation name
4
+ */
5
+ export function getManifestKey(app) {
6
+ return app.slug || app.key;
7
+ }
8
+ /**
9
+ * Create a manifest entry from an app
10
+ */
11
+ export function createManifestEntry(app) {
12
+ if (!app.version) {
13
+ throw new Error(`App ${app.key} does not have a version. Implementation ID: ${app.implementation_id}`);
14
+ }
15
+ return {
16
+ implementationName: app.key,
17
+ version: app.version,
18
+ };
19
+ }