@zapier/zapier-sdk-cli 0.52.10 → 0.53.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.
Files changed (71) hide show
  1. package/CHANGELOG.md +56 -0
  2. package/README.md +39 -1
  3. package/dist/cli.cjs +972 -473
  4. package/dist/cli.mjs +973 -474
  5. package/dist/experimental.cjs +914 -424
  6. package/dist/experimental.d.mts +1 -1
  7. package/dist/experimental.d.ts +1 -1
  8. package/dist/experimental.mjs +910 -420
  9. package/dist/index.cjs +914 -424
  10. package/dist/index.d.mts +1 -1
  11. package/dist/index.d.ts +1 -1
  12. package/dist/index.mjs +910 -420
  13. package/dist/login.cjs +8 -10
  14. package/dist/login.d.mts +2 -10
  15. package/dist/login.d.ts +2 -10
  16. package/dist/login.mjs +5 -9
  17. package/dist/package.json +1 -1
  18. package/dist/{sdk-B3nKAZdN.d.mts → sdk-SOLizjno.d.mts} +54 -16
  19. package/dist/{sdk-B3nKAZdN.d.ts → sdk-SOLizjno.d.ts} +54 -16
  20. package/dist/src/experimental.js +30 -27
  21. package/dist/src/login/index.d.ts +1 -9
  22. package/dist/src/login/index.js +12 -14
  23. package/dist/src/plugins/add/index.d.ts +15 -15
  24. package/dist/src/plugins/add/index.js +1 -1
  25. package/dist/src/plugins/buildManifest/index.d.ts +2 -2
  26. package/dist/src/plugins/bundleCode/index.d.ts +1 -1
  27. package/dist/src/plugins/bundleCode/index.js +2 -1
  28. package/dist/src/plugins/cliOverrides/index.d.ts +5 -10
  29. package/dist/src/plugins/cliOverrides/index.js +2 -6
  30. package/dist/src/plugins/curl/index.d.ts +2 -2
  31. package/dist/src/plugins/curl/schemas.d.ts +2 -2
  32. package/dist/src/plugins/feedback/index.d.ts +1 -1
  33. package/dist/src/plugins/generateAppTypes/index.d.ts +11 -11
  34. package/dist/src/plugins/getLoginConfigPath/index.d.ts +1 -1
  35. package/dist/src/plugins/index.d.ts +2 -1
  36. package/dist/src/plugins/index.js +2 -1
  37. package/dist/src/plugins/init/index.d.ts +1 -1
  38. package/dist/src/plugins/login/index.d.ts +3 -16
  39. package/dist/src/plugins/login/index.js +3 -191
  40. package/dist/src/plugins/logout/index.d.ts +1 -1
  41. package/dist/src/plugins/mcp/index.d.ts +1 -1
  42. package/dist/src/plugins/signup/index.d.ts +25 -0
  43. package/dist/src/plugins/signup/index.js +12 -0
  44. package/dist/src/plugins/signup/schemas.d.ts +9 -0
  45. package/dist/src/plugins/signup/schemas.js +26 -0
  46. package/dist/src/plugins/signup/test-harness.d.ts +34 -0
  47. package/dist/src/plugins/signup/test-harness.js +74 -0
  48. package/dist/src/sdk.js +32 -20
  49. package/dist/src/types/sdk.d.ts +2 -1
  50. package/dist/src/utils/auth/account-auth.d.ts +32 -0
  51. package/dist/src/utils/auth/account-auth.js +265 -0
  52. package/dist/src/utils/auth/oauth-callback.d.ts +6 -0
  53. package/dist/src/utils/auth/oauth-callback.js +28 -0
  54. package/dist/src/utils/auth/oauth-errors.d.ts +2 -0
  55. package/dist/src/utils/auth/oauth-errors.js +39 -0
  56. package/dist/src/utils/auth/oauth-flow.d.ts +31 -6
  57. package/dist/src/utils/auth/oauth-flow.js +258 -106
  58. package/dist/src/utils/auth/oauth-transaction.d.ts +35 -0
  59. package/dist/src/utils/auth/oauth-transaction.js +69 -0
  60. package/dist/src/utils/cli-generator.js +14 -7
  61. package/dist/src/utils/cli-renderer.d.ts +13 -3
  62. package/dist/src/utils/cli-renderer.js +27 -20
  63. package/dist/src/utils/log.js +9 -4
  64. package/dist/src/utils/non-interactive.d.ts +5 -4
  65. package/dist/src/utils/non-interactive.js +6 -5
  66. package/dist/src/utils/parameter-resolver.js +3 -1
  67. package/dist/src/utils/schema-formatter.d.ts +2 -2
  68. package/dist/src/utils/schema-formatter.js +4 -30
  69. package/dist/src/utils/version-checker.js +8 -3
  70. package/dist/tsconfig.tsbuildinfo +1 -1
  71. package/package.json +3 -3
package/dist/login.cjs CHANGED
@@ -7,6 +7,7 @@ var fs = require('fs');
7
7
  var crypto = require('crypto');
8
8
  var path = require('path');
9
9
  var lockfile = require('proper-lockfile');
10
+ var zapierSdk = require('@zapier/zapier-sdk');
10
11
  var zod = require('zod');
11
12
 
12
13
  function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
@@ -319,12 +320,6 @@ async function getStoredClientCredentials(options) {
319
320
  }
320
321
 
321
322
  // src/login/index.ts
322
- var ZapierAuthenticationError = class extends Error {
323
- constructor(message) {
324
- super(message);
325
- this.name = "ZapierAuthenticationError";
326
- }
327
- };
328
323
  var DEFAULT_AUTH_CLIENT_ID = "grwWZD5hUWGvb4V8ODBuOtXer3h0DBEZ2HR8aay6";
329
324
  var TOKEN_REFRESH_BUFFER_MS = 5 * 60 * 1e3;
330
325
  function createDebugLog(enabled) {
@@ -334,9 +329,9 @@ function createDebugLog(enabled) {
334
329
  }
335
330
  return (message, data) => {
336
331
  if (data === void 0) {
337
- console.log(`[Zapier SDK CLI Login] ${message}`);
332
+ console.error(`[Zapier SDK CLI Login] ${message}`);
338
333
  } else {
339
- console.log(`[Zapier SDK CLI Login] ${message}`, data);
334
+ console.error(`[Zapier SDK CLI Login] ${message}`, data);
340
335
  }
341
336
  };
342
337
  }
@@ -582,7 +577,7 @@ async function getToken(options = {}) {
582
577
  return await resolveOrRefreshToken(options);
583
578
  } catch (error) {
584
579
  const message = error instanceof Error ? error.message : "Token refresh failed";
585
- throw new ZapierAuthenticationError(
580
+ throw new zapierSdk.ZapierAuthenticationError(
586
581
  `${message}
587
582
  Please run 'login' to authenticate again.`
588
583
  );
@@ -653,9 +648,12 @@ function getConfigPath() {
653
648
  return cfg.path;
654
649
  }
655
650
 
651
+ Object.defineProperty(exports, "ZapierAuthenticationError", {
652
+ enumerable: true,
653
+ get: function () { return zapierSdk.ZapierAuthenticationError; }
654
+ });
656
655
  exports.AUTH_MODE_HEADER = AUTH_MODE_HEADER;
657
656
  exports.DEFAULT_AUTH_BASE_URL = DEFAULT_AUTH_BASE_URL;
658
- exports.ZapierAuthenticationError = ZapierAuthenticationError;
659
657
  exports.clearTokensFromKeychain = clearTokensFromKeychain;
660
658
  exports.createCache = createCache;
661
659
  exports.getActiveCredentials = getActiveCredentials;
package/dist/login.d.mts CHANGED
@@ -1,5 +1,6 @@
1
1
  import Conf from 'conf';
2
2
  import { ClientCredentialsObject } from '@zapier/zapier-sdk';
3
+ export { ZapierAuthenticationError } from '@zapier/zapier-sdk';
3
4
  import { z } from 'zod';
4
5
 
5
6
  declare const DEFAULT_AUTH_BASE_URL = "https://zapier.com";
@@ -59,15 +60,6 @@ declare function clearTokensFromKeychain({ debugLog, }?: {
59
60
  * Provides getToken function that can be optionally imported by zapier-sdk.
60
61
  */
61
62
 
62
- /**
63
- * Authentication error for token refresh failures.
64
- * This is a standalone clone of ZapierAuthenticationError from the SDK.
65
- * We can't import from SDK because cli-login must remain a standalone package
66
- * with no SDK dependencies. The SDK recognizes this error by name.
67
- */
68
- declare class ZapierAuthenticationError extends Error {
69
- constructor(message: string);
70
- }
71
63
  interface PkceCredentials {
72
64
  type: "pkce";
73
65
  clientId: string;
@@ -168,4 +160,4 @@ declare function logout(options?: Pick<AuthOptions, "onEvent">): Promise<void>;
168
160
  */
169
161
  declare function getConfigPath(): string;
170
162
 
171
- export { AUTH_MODE_HEADER, type AuthOptions, DEFAULT_AUTH_BASE_URL, type LoginData, type LoginStorageMode, type PkceCredentials, type PkceLoginConfig, ZapierAuthenticationError, clearTokensFromKeychain, createCache, getActiveCredentials, getAuthAuthorizeUrl, getAuthTokenUrl, getConfig, getConfigPath, getLoggedInUser, getLoginStorageMode, getPkceLoginConfig, getStoredClientCredentials, getToken, logout, unloadConfig, updateLogin };
163
+ export { AUTH_MODE_HEADER, type AuthOptions, DEFAULT_AUTH_BASE_URL, type LoginData, type LoginStorageMode, type PkceCredentials, type PkceLoginConfig, clearTokensFromKeychain, createCache, getActiveCredentials, getAuthAuthorizeUrl, getAuthTokenUrl, getConfig, getConfigPath, getLoggedInUser, getLoginStorageMode, getPkceLoginConfig, getStoredClientCredentials, getToken, logout, unloadConfig, updateLogin };
package/dist/login.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import Conf from 'conf';
2
2
  import { ClientCredentialsObject } from '@zapier/zapier-sdk';
3
+ export { ZapierAuthenticationError } from '@zapier/zapier-sdk';
3
4
  import { z } from 'zod';
4
5
 
5
6
  declare const DEFAULT_AUTH_BASE_URL = "https://zapier.com";
@@ -59,15 +60,6 @@ declare function clearTokensFromKeychain({ debugLog, }?: {
59
60
  * Provides getToken function that can be optionally imported by zapier-sdk.
60
61
  */
61
62
 
62
- /**
63
- * Authentication error for token refresh failures.
64
- * This is a standalone clone of ZapierAuthenticationError from the SDK.
65
- * We can't import from SDK because cli-login must remain a standalone package
66
- * with no SDK dependencies. The SDK recognizes this error by name.
67
- */
68
- declare class ZapierAuthenticationError extends Error {
69
- constructor(message: string);
70
- }
71
63
  interface PkceCredentials {
72
64
  type: "pkce";
73
65
  clientId: string;
@@ -168,4 +160,4 @@ declare function logout(options?: Pick<AuthOptions, "onEvent">): Promise<void>;
168
160
  */
169
161
  declare function getConfigPath(): string;
170
162
 
171
- export { AUTH_MODE_HEADER, type AuthOptions, DEFAULT_AUTH_BASE_URL, type LoginData, type LoginStorageMode, type PkceCredentials, type PkceLoginConfig, ZapierAuthenticationError, clearTokensFromKeychain, createCache, getActiveCredentials, getAuthAuthorizeUrl, getAuthTokenUrl, getConfig, getConfigPath, getLoggedInUser, getLoginStorageMode, getPkceLoginConfig, getStoredClientCredentials, getToken, logout, unloadConfig, updateLogin };
163
+ export { AUTH_MODE_HEADER, type AuthOptions, DEFAULT_AUTH_BASE_URL, type LoginData, type LoginStorageMode, type PkceCredentials, type PkceLoginConfig, clearTokensFromKeychain, createCache, getActiveCredentials, getAuthAuthorizeUrl, getAuthTokenUrl, getConfig, getConfigPath, getLoggedInUser, getLoginStorageMode, getPkceLoginConfig, getStoredClientCredentials, getToken, logout, unloadConfig, updateLogin };
package/dist/login.mjs CHANGED
@@ -5,6 +5,8 @@ import { existsSync, mkdirSync, writeFileSync } from 'fs';
5
5
  import { createHash } from 'crypto';
6
6
  import { dirname } from 'path';
7
7
  import * as lockfile from 'proper-lockfile';
8
+ import { ZapierAuthenticationError } from '@zapier/zapier-sdk';
9
+ export { ZapierAuthenticationError } from '@zapier/zapier-sdk';
8
10
  import { z } from 'zod';
9
11
 
10
12
  // src/login/index.ts
@@ -293,12 +295,6 @@ async function getStoredClientCredentials(options) {
293
295
  }
294
296
 
295
297
  // src/login/index.ts
296
- var ZapierAuthenticationError = class extends Error {
297
- constructor(message) {
298
- super(message);
299
- this.name = "ZapierAuthenticationError";
300
- }
301
- };
302
298
  var DEFAULT_AUTH_CLIENT_ID = "grwWZD5hUWGvb4V8ODBuOtXer3h0DBEZ2HR8aay6";
303
299
  var TOKEN_REFRESH_BUFFER_MS = 5 * 60 * 1e3;
304
300
  function createDebugLog(enabled) {
@@ -308,9 +304,9 @@ function createDebugLog(enabled) {
308
304
  }
309
305
  return (message, data) => {
310
306
  if (data === void 0) {
311
- console.log(`[Zapier SDK CLI Login] ${message}`);
307
+ console.error(`[Zapier SDK CLI Login] ${message}`);
312
308
  } else {
313
- console.log(`[Zapier SDK CLI Login] ${message}`, data);
309
+ console.error(`[Zapier SDK CLI Login] ${message}`, data);
314
310
  }
315
311
  };
316
312
  }
@@ -627,4 +623,4 @@ function getConfigPath() {
627
623
  return cfg.path;
628
624
  }
629
625
 
630
- export { AUTH_MODE_HEADER, DEFAULT_AUTH_BASE_URL, ZapierAuthenticationError, clearTokensFromKeychain, createCache, getActiveCredentials, getAuthAuthorizeUrl, getAuthTokenUrl, getConfig, getConfigPath, getLoggedInUser, getLoginStorageMode, getPkceLoginConfig, getStoredClientCredentials, getToken, logout, unloadConfig, updateLogin };
626
+ export { AUTH_MODE_HEADER, DEFAULT_AUTH_BASE_URL, clearTokensFromKeychain, createCache, getActiveCredentials, getAuthAuthorizeUrl, getAuthTokenUrl, getConfig, getConfigPath, getLoggedInUser, getLoginStorageMode, getPkceLoginConfig, getStoredClientCredentials, getToken, logout, unloadConfig, updateLogin };
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zapier/zapier-sdk-cli",
3
- "version": "0.52.10",
3
+ "version": "0.53.0",
4
4
  "description": "Command line interface for Zapier SDK",
5
5
  "main": "dist/index.cjs",
6
6
  "module": "dist/index.mjs",
@@ -1,5 +1,5 @@
1
1
  import * as _zapier_zapier_sdk from '@zapier/zapier-sdk';
2
- import { AppItem, Manifest, ZapierSdk } from '@zapier/zapier-sdk';
2
+ import { AppItem, Manifest, ResolvedCredentials, ApiClient, ZapierSdk } from '@zapier/zapier-sdk';
3
3
  import { z } from 'zod';
4
4
 
5
5
  declare const BuildManifestSchema: z.ZodObject<{
@@ -113,7 +113,7 @@ declare const buildManifestPlugin: (sdk: {
113
113
  } & {
114
114
  context: {
115
115
  meta: {
116
- listApps: _zapier_zapier_sdk.PluginMeta;
116
+ listApps: _zapier_zapier_sdk.PluginMeta<unknown>;
117
117
  };
118
118
  };
119
119
  } & {
@@ -158,7 +158,7 @@ declare const buildManifestPlugin: (sdk: {
158
158
  } & {
159
159
  context: {
160
160
  meta: {
161
- buildManifest: _zapier_zapier_sdk.PluginMeta;
161
+ buildManifest: _zapier_zapier_sdk.PluginMeta<unknown>;
162
162
  };
163
163
  };
164
164
  };
@@ -183,7 +183,7 @@ declare const feedbackPlugin: (sdk: {
183
183
  } & {
184
184
  context: {
185
185
  meta: {
186
- feedback: _zapier_zapier_sdk.PluginMeta;
186
+ feedback: _zapier_zapier_sdk.PluginMeta<unknown>;
187
187
  };
188
188
  };
189
189
  };
@@ -314,19 +314,19 @@ declare const generateAppTypesPlugin: (sdk: {
314
314
  } & {
315
315
  context: {
316
316
  meta: {
317
- listApps: _zapier_zapier_sdk.PluginMeta;
317
+ listApps: _zapier_zapier_sdk.PluginMeta<unknown>;
318
318
  };
319
319
  };
320
320
  } & {
321
321
  listActions: (options?: (({
322
322
  app: string;
323
- actionType?: "filter" | "read" | "read_bulk" | "run" | "search" | "search_and_write" | "search_or_write" | "write" | undefined;
323
+ actionType?: "read" | "read_bulk" | "write" | "search" | "search_or_write" | "search_and_write" | "filter" | "run" | undefined;
324
324
  pageSize?: number | undefined;
325
325
  maxItems?: number | undefined;
326
326
  cursor?: string | undefined;
327
327
  } | {
328
328
  appKey: string;
329
- actionType?: "filter" | "read" | "read_bulk" | "run" | "search" | "search_and_write" | "search_or_write" | "write" | undefined;
329
+ actionType?: "read" | "read_bulk" | "write" | "search" | "search_or_write" | "search_and_write" | "filter" | "run" | undefined;
330
330
  pageSize?: number | undefined;
331
331
  maxItems?: number | undefined;
332
332
  cursor?: string | undefined;
@@ -338,24 +338,24 @@ declare const generateAppTypesPlugin: (sdk: {
338
338
  description: string;
339
339
  key: string;
340
340
  app_key: string;
341
- action_type: "filter" | "read" | "read_bulk" | "run" | "search" | "search_and_write" | "search_or_write" | "write";
341
+ action_type: "read" | "read_bulk" | "write" | "search" | "search_or_write" | "search_and_write" | "filter" | "run";
342
342
  title: string;
343
343
  type: "action";
344
+ is_hidden?: boolean | undefined;
344
345
  id?: string | undefined;
345
346
  is_important?: boolean | undefined;
346
- is_hidden?: boolean | undefined;
347
347
  app_version?: string | undefined;
348
348
  }>;
349
349
  } & {
350
350
  context: {
351
351
  meta: {
352
- listActions: _zapier_zapier_sdk.PluginMeta;
352
+ listActions: _zapier_zapier_sdk.PluginMeta<unknown>;
353
353
  };
354
354
  };
355
355
  } & {
356
356
  listActionInputFields: (options?: (({
357
357
  app: string;
358
- actionType: "filter" | "read" | "read_bulk" | "run" | "search" | "search_and_write" | "search_or_write" | "write";
358
+ actionType: "read" | "read_bulk" | "write" | "search" | "search_or_write" | "search_and_write" | "filter" | "run";
359
359
  action: string;
360
360
  connection?: string | number | undefined;
361
361
  connectionId?: string | number | null | undefined;
@@ -366,7 +366,7 @@ declare const generateAppTypesPlugin: (sdk: {
366
366
  cursor?: string | undefined;
367
367
  } | {
368
368
  appKey: string;
369
- actionType: "filter" | "read" | "read_bulk" | "run" | "search" | "search_and_write" | "search_or_write" | "write";
369
+ actionType: "read" | "read_bulk" | "write" | "search" | "search_or_write" | "search_and_write" | "filter" | "run";
370
370
  actionKey: string;
371
371
  connection?: string | number | undefined;
372
372
  connectionId?: string | number | null | undefined;
@@ -403,7 +403,7 @@ declare const generateAppTypesPlugin: (sdk: {
403
403
  } & {
404
404
  context: {
405
405
  meta: {
406
- listActionInputFields: _zapier_zapier_sdk.PluginMeta;
406
+ listActionInputFields: _zapier_zapier_sdk.PluginMeta<unknown>;
407
407
  };
408
408
  };
409
409
  } & {
@@ -460,7 +460,7 @@ declare const generateAppTypesPlugin: (sdk: {
460
460
  } & {
461
461
  context: {
462
462
  meta: {
463
- listConnections: _zapier_zapier_sdk.PluginMeta;
463
+ listConnections: _zapier_zapier_sdk.PluginMeta<unknown>;
464
464
  };
465
465
  };
466
466
  } & {
@@ -505,12 +505,50 @@ declare const generateAppTypesPlugin: (sdk: {
505
505
  } & {
506
506
  context: {
507
507
  meta: {
508
- generateAppTypes: _zapier_zapier_sdk.PluginMeta;
508
+ generateAppTypes: _zapier_zapier_sdk.PluginMeta<unknown>;
509
509
  };
510
510
  };
511
511
  };
512
512
  type GenerateAppTypesPluginProvides = ReturnType<typeof generateAppTypesPlugin>;
513
513
 
514
- type ZapierSdkCli = ZapierSdk & BuildManifestPluginProvides & FeedbackPluginProvides & GenerateAppTypesPluginProvides;
514
+ interface AccountAuthCliContext {
515
+ session_id?: string | null;
516
+ selected_api?: string | null;
517
+ app_id?: number | null;
518
+ app_version_id?: number | null;
519
+ resolveCredentials: () => Promise<ResolvedCredentials | undefined>;
520
+ api: ApiClient;
521
+ options?: {
522
+ baseUrl?: string;
523
+ credentials?: unknown;
524
+ };
525
+ }
526
+
527
+ declare const signupPlugin: (sdk: {
528
+ context: _zapier_zapier_sdk.EventEmissionContext;
529
+ } & {
530
+ context: AccountAuthCliContext;
531
+ } & {
532
+ context: {
533
+ meta: Record<string, _zapier_zapier_sdk.PluginMeta>;
534
+ };
535
+ }) => {
536
+ signup: (options?: {
537
+ timeout?: string | undefined;
538
+ useApprovals?: boolean | undefined;
539
+ nonInteractive?: boolean | undefined;
540
+ skipPrompts?: boolean | undefined;
541
+ headless?: boolean | undefined;
542
+ } | undefined) => Promise<void>;
543
+ } & {
544
+ context: {
545
+ meta: {
546
+ signup: _zapier_zapier_sdk.PluginMeta<unknown>;
547
+ };
548
+ };
549
+ };
550
+ type SignupPluginProvides = ReturnType<typeof signupPlugin>;
551
+
552
+ type ZapierSdkCli = ZapierSdk & BuildManifestPluginProvides & FeedbackPluginProvides & GenerateAppTypesPluginProvides & SignupPluginProvides;
515
553
 
516
554
  export type { ZapierSdkCli as Z };
@@ -1,5 +1,5 @@
1
1
  import * as _zapier_zapier_sdk from '@zapier/zapier-sdk';
2
- import { AppItem, Manifest, ZapierSdk } from '@zapier/zapier-sdk';
2
+ import { AppItem, Manifest, ResolvedCredentials, ApiClient, ZapierSdk } from '@zapier/zapier-sdk';
3
3
  import { z } from 'zod';
4
4
 
5
5
  declare const BuildManifestSchema: z.ZodObject<{
@@ -113,7 +113,7 @@ declare const buildManifestPlugin: (sdk: {
113
113
  } & {
114
114
  context: {
115
115
  meta: {
116
- listApps: _zapier_zapier_sdk.PluginMeta;
116
+ listApps: _zapier_zapier_sdk.PluginMeta<unknown>;
117
117
  };
118
118
  };
119
119
  } & {
@@ -158,7 +158,7 @@ declare const buildManifestPlugin: (sdk: {
158
158
  } & {
159
159
  context: {
160
160
  meta: {
161
- buildManifest: _zapier_zapier_sdk.PluginMeta;
161
+ buildManifest: _zapier_zapier_sdk.PluginMeta<unknown>;
162
162
  };
163
163
  };
164
164
  };
@@ -183,7 +183,7 @@ declare const feedbackPlugin: (sdk: {
183
183
  } & {
184
184
  context: {
185
185
  meta: {
186
- feedback: _zapier_zapier_sdk.PluginMeta;
186
+ feedback: _zapier_zapier_sdk.PluginMeta<unknown>;
187
187
  };
188
188
  };
189
189
  };
@@ -314,19 +314,19 @@ declare const generateAppTypesPlugin: (sdk: {
314
314
  } & {
315
315
  context: {
316
316
  meta: {
317
- listApps: _zapier_zapier_sdk.PluginMeta;
317
+ listApps: _zapier_zapier_sdk.PluginMeta<unknown>;
318
318
  };
319
319
  };
320
320
  } & {
321
321
  listActions: (options?: (({
322
322
  app: string;
323
- actionType?: "filter" | "read" | "read_bulk" | "run" | "search" | "search_and_write" | "search_or_write" | "write" | undefined;
323
+ actionType?: "read" | "read_bulk" | "write" | "search" | "search_or_write" | "search_and_write" | "filter" | "run" | undefined;
324
324
  pageSize?: number | undefined;
325
325
  maxItems?: number | undefined;
326
326
  cursor?: string | undefined;
327
327
  } | {
328
328
  appKey: string;
329
- actionType?: "filter" | "read" | "read_bulk" | "run" | "search" | "search_and_write" | "search_or_write" | "write" | undefined;
329
+ actionType?: "read" | "read_bulk" | "write" | "search" | "search_or_write" | "search_and_write" | "filter" | "run" | undefined;
330
330
  pageSize?: number | undefined;
331
331
  maxItems?: number | undefined;
332
332
  cursor?: string | undefined;
@@ -338,24 +338,24 @@ declare const generateAppTypesPlugin: (sdk: {
338
338
  description: string;
339
339
  key: string;
340
340
  app_key: string;
341
- action_type: "filter" | "read" | "read_bulk" | "run" | "search" | "search_and_write" | "search_or_write" | "write";
341
+ action_type: "read" | "read_bulk" | "write" | "search" | "search_or_write" | "search_and_write" | "filter" | "run";
342
342
  title: string;
343
343
  type: "action";
344
+ is_hidden?: boolean | undefined;
344
345
  id?: string | undefined;
345
346
  is_important?: boolean | undefined;
346
- is_hidden?: boolean | undefined;
347
347
  app_version?: string | undefined;
348
348
  }>;
349
349
  } & {
350
350
  context: {
351
351
  meta: {
352
- listActions: _zapier_zapier_sdk.PluginMeta;
352
+ listActions: _zapier_zapier_sdk.PluginMeta<unknown>;
353
353
  };
354
354
  };
355
355
  } & {
356
356
  listActionInputFields: (options?: (({
357
357
  app: string;
358
- actionType: "filter" | "read" | "read_bulk" | "run" | "search" | "search_and_write" | "search_or_write" | "write";
358
+ actionType: "read" | "read_bulk" | "write" | "search" | "search_or_write" | "search_and_write" | "filter" | "run";
359
359
  action: string;
360
360
  connection?: string | number | undefined;
361
361
  connectionId?: string | number | null | undefined;
@@ -366,7 +366,7 @@ declare const generateAppTypesPlugin: (sdk: {
366
366
  cursor?: string | undefined;
367
367
  } | {
368
368
  appKey: string;
369
- actionType: "filter" | "read" | "read_bulk" | "run" | "search" | "search_and_write" | "search_or_write" | "write";
369
+ actionType: "read" | "read_bulk" | "write" | "search" | "search_or_write" | "search_and_write" | "filter" | "run";
370
370
  actionKey: string;
371
371
  connection?: string | number | undefined;
372
372
  connectionId?: string | number | null | undefined;
@@ -403,7 +403,7 @@ declare const generateAppTypesPlugin: (sdk: {
403
403
  } & {
404
404
  context: {
405
405
  meta: {
406
- listActionInputFields: _zapier_zapier_sdk.PluginMeta;
406
+ listActionInputFields: _zapier_zapier_sdk.PluginMeta<unknown>;
407
407
  };
408
408
  };
409
409
  } & {
@@ -460,7 +460,7 @@ declare const generateAppTypesPlugin: (sdk: {
460
460
  } & {
461
461
  context: {
462
462
  meta: {
463
- listConnections: _zapier_zapier_sdk.PluginMeta;
463
+ listConnections: _zapier_zapier_sdk.PluginMeta<unknown>;
464
464
  };
465
465
  };
466
466
  } & {
@@ -505,12 +505,50 @@ declare const generateAppTypesPlugin: (sdk: {
505
505
  } & {
506
506
  context: {
507
507
  meta: {
508
- generateAppTypes: _zapier_zapier_sdk.PluginMeta;
508
+ generateAppTypes: _zapier_zapier_sdk.PluginMeta<unknown>;
509
509
  };
510
510
  };
511
511
  };
512
512
  type GenerateAppTypesPluginProvides = ReturnType<typeof generateAppTypesPlugin>;
513
513
 
514
- type ZapierSdkCli = ZapierSdk & BuildManifestPluginProvides & FeedbackPluginProvides & GenerateAppTypesPluginProvides;
514
+ interface AccountAuthCliContext {
515
+ session_id?: string | null;
516
+ selected_api?: string | null;
517
+ app_id?: number | null;
518
+ app_version_id?: number | null;
519
+ resolveCredentials: () => Promise<ResolvedCredentials | undefined>;
520
+ api: ApiClient;
521
+ options?: {
522
+ baseUrl?: string;
523
+ credentials?: unknown;
524
+ };
525
+ }
526
+
527
+ declare const signupPlugin: (sdk: {
528
+ context: _zapier_zapier_sdk.EventEmissionContext;
529
+ } & {
530
+ context: AccountAuthCliContext;
531
+ } & {
532
+ context: {
533
+ meta: Record<string, _zapier_zapier_sdk.PluginMeta>;
534
+ };
535
+ }) => {
536
+ signup: (options?: {
537
+ timeout?: string | undefined;
538
+ useApprovals?: boolean | undefined;
539
+ nonInteractive?: boolean | undefined;
540
+ skipPrompts?: boolean | undefined;
541
+ headless?: boolean | undefined;
542
+ } | undefined) => Promise<void>;
543
+ } & {
544
+ context: {
545
+ meta: {
546
+ signup: _zapier_zapier_sdk.PluginMeta<unknown>;
547
+ };
548
+ };
549
+ };
550
+ type SignupPluginProvides = ReturnType<typeof signupPlugin>;
551
+
552
+ type ZapierSdkCli = ZapierSdk & BuildManifestPluginProvides & FeedbackPluginProvides & GenerateAppTypesPluginProvides & SignupPluginProvides;
515
553
 
516
554
  export type { ZapierSdkCli as Z };
@@ -14,8 +14,8 @@
14
14
  * factories are kept in sync by shape tests.
15
15
  */
16
16
  import * as cliLogin from "./login";
17
- import { createZapierSdk, injectCliLogin, } from "@zapier/zapier-sdk/experimental";
18
- import { loginPlugin, logoutPlugin, mcpPlugin, bundleCodePlugin, getLoginConfigPathPlugin, addPlugin, generateAppTypesPlugin, buildManifestPlugin, feedbackPlugin, curlPlugin, cliOverridesPlugin, initPlugin, drainTriggerInboxCliPlugin, watchTriggerInboxCliPlugin, } from "./plugins/index";
17
+ import { addPlugin, createZapierSdkStack, injectCliLogin, } from "@zapier/zapier-sdk/experimental";
18
+ import { loginPlugin, signupPlugin, logoutPlugin, mcpPlugin, bundleCodePlugin, getLoginConfigPathPlugin, addAppsPlugin, generateAppTypesPlugin, buildManifestPlugin, feedbackPlugin, curlPlugin, cliOverridesPlugin, initPlugin, drainTriggerInboxCliPlugin, watchTriggerInboxCliPlugin, } from "./plugins/index";
19
19
  import packageJson from "../package.json" with { type: "json" };
20
20
  injectCliLogin(cliLogin);
21
21
  /**
@@ -38,46 +38,49 @@ export function createZapierCliSdk(options = {}) {
38
38
  const experimentalContextPlugin = () => ({
39
39
  context: { experimental: true },
40
40
  });
41
- let chain = createZapierSdk({
41
+ const sdk = createZapierSdkStack({
42
42
  ...sdkOptions,
43
43
  eventEmission: { ...sdkOptions.eventEmission, callContext: "cli" },
44
44
  callerPackage: { name: packageJson.name, version: packageJson.version },
45
45
  })
46
- .addPlugin(extensionsContextPlugin)
47
- .addPlugin(experimentalContextPlugin)
48
- .addPlugin(generateAppTypesPlugin)
49
- .addPlugin(buildManifestPlugin)
50
- .addPlugin(bundleCodePlugin)
51
- .addPlugin(getLoginConfigPathPlugin)
52
- .addPlugin(addPlugin)
53
- .addPlugin(feedbackPlugin)
54
- .addPlugin(curlPlugin)
55
- .addPlugin(initPlugin)
46
+ .use(extensionsContextPlugin)
47
+ .use(experimentalContextPlugin)
48
+ .use(generateAppTypesPlugin)
49
+ .use(buildManifestPlugin)
50
+ .use(bundleCodePlugin)
51
+ .use(getLoginConfigPathPlugin)
52
+ .use(addAppsPlugin)
53
+ .use(feedbackPlugin)
54
+ .use(curlPlugin)
55
+ .use(initPlugin)
56
56
  // Trigger inbox commands: the SDK's `drainTriggerInbox` and
57
57
  // `watchTriggerInbox` are eager, callback-driven methods. Both CLI
58
58
  // plugins override them to layer presentation flags (`--json`,
59
59
  // interactive prompt, `--exec-shell` wrapping) around the same
60
60
  // `onMessage` callback. `override: true` is the documented opt-in
61
61
  // for intentional same-name replacement.
62
- .addPlugin(drainTriggerInboxCliPlugin, { override: true })
63
- .addPlugin(watchTriggerInboxCliPlugin, { override: true })
64
- .addPlugin(mcpPlugin)
65
- .addPlugin(loginPlugin)
66
- .addPlugin(logoutPlugin)
67
- .addPlugin(cliOverridesPlugin);
68
- // Construct extensions defensively. The loader (`utils/extensions.ts`)
69
- // already isolates *load*-time failures (failed dynamic imports);
70
- // here we cover the second failure mode a successfully-imported
71
- // plugin that throws during construction (bad context lookup, schema
72
- // build error, composePlugins collision, etc.). Honors the
73
- // design-doc promise that "a broken extension does not kill the CLI."
62
+ .use(drainTriggerInboxCliPlugin, { override: true })
63
+ .use(watchTriggerInboxCliPlugin, { override: true })
64
+ .use(mcpPlugin)
65
+ .use(loginPlugin)
66
+ .use(signupPlugin)
67
+ .use(logoutPlugin)
68
+ // cliOverridesPlugin patches existing meta entries (e.g. flags `fetch`
69
+ // as deprecated) without re-registering the method. `.use` throws on
70
+ // meta-key collisions by default, so the intent has to be explicit.
71
+ .use(cliOverridesPlugin, { override: true })
72
+ .toSdk();
73
+ // Construct extensions defensively. See `./sdk.ts` for the rationale;
74
+ // `addPlugin` mutates the sdk in place, atomically (validate-then-
75
+ // apply), so a failed extension leaves the sdk in its prior state
76
+ // and skipping is safe.
74
77
  for (const ext of extensions) {
75
78
  try {
76
- chain = chain.addPlugin(ext);
79
+ addPlugin(sdk, ext);
77
80
  }
78
81
  catch (err) {
79
82
  console.warn(`Extension plugin failed to construct: ${err.message}; skipping.`);
80
83
  }
81
84
  }
82
- return chain;
85
+ return sdk;
83
86
  }
@@ -6,15 +6,7 @@
6
6
  */
7
7
  export { DEFAULT_AUTH_BASE_URL, getConfig } from "./config";
8
8
  export { createCache } from "./filesystem-cache";
9
- /**
10
- * Authentication error for token refresh failures.
11
- * This is a standalone clone of ZapierAuthenticationError from the SDK.
12
- * We can't import from SDK because cli-login must remain a standalone package
13
- * with no SDK dependencies. The SDK recognizes this error by name.
14
- */
15
- export declare class ZapierAuthenticationError extends Error {
16
- constructor(message: string);
17
- }
9
+ export { ZapierAuthenticationError } from "@zapier/zapier-sdk";
18
10
  export interface PkceCredentials {
19
11
  type: "pkce";
20
12
  clientId: string;
@@ -10,18 +10,14 @@ import { clearLegacyJwtConfigKeys } from "./legacy-jwt";
10
10
  import { getConfig, resetConfig, DEFAULT_AUTH_BASE_URL } from "./config";
11
11
  export { DEFAULT_AUTH_BASE_URL, getConfig } from "./config";
12
12
  export { createCache } from "./filesystem-cache";
13
- /**
14
- * Authentication error for token refresh failures.
15
- * This is a standalone clone of ZapierAuthenticationError from the SDK.
16
- * We can't import from SDK because cli-login must remain a standalone package
17
- * with no SDK dependencies. The SDK recognizes this error by name.
18
- */
19
- export class ZapierAuthenticationError extends Error {
20
- constructor(message) {
21
- super(message);
22
- this.name = "ZapierAuthenticationError";
23
- }
24
- }
13
+ // Authentication error for token refresh failures. Re-exported from
14
+ // `@zapier/zapier-sdk` so existing cli-login callers (and tests) can
15
+ // import it from here without reaching into the SDK directly. Sharing
16
+ // one class identity across packages keeps `instanceof
17
+ // ZapierAuthenticationError` working when the SDK catches errors
18
+ // thrown by cli-login's refresh flow.
19
+ export { ZapierAuthenticationError } from "@zapier/zapier-sdk";
20
+ import { ZapierAuthenticationError } from "@zapier/zapier-sdk";
25
21
  // Default OAuth client ID
26
22
  const DEFAULT_AUTH_CLIENT_ID = "grwWZD5hUWGvb4V8ODBuOtXer3h0DBEZ2HR8aay6";
27
23
  // Buffer time before token expiration to trigger refresh (5 minutes)
@@ -35,11 +31,13 @@ function createDebugLog(enabled) {
35
31
  return () => { };
36
32
  }
37
33
  return (message, data) => {
34
+ // stderr keeps debug output out of stdout so it never breaks callers
35
+ // that pipe CLI output through jq, > redirect, or JSON.parse.
38
36
  if (data === undefined) {
39
- console.log(`[Zapier SDK CLI Login] ${message}`);
37
+ console.error(`[Zapier SDK CLI Login] ${message}`);
40
38
  }
41
39
  else {
42
- console.log(`[Zapier SDK CLI Login] ${message}`, data);
40
+ console.error(`[Zapier SDK CLI Login] ${message}`, data);
43
41
  }
44
42
  };
45
43
  }