@zapier/zapier-sdk-cli 0.55.4 → 0.55.5

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 CHANGED
@@ -1,5 +1,11 @@
1
1
  # @zapier/zapier-sdk-cli
2
2
 
3
+ ## 0.55.5
4
+
5
+ ### Patch Changes
6
+
7
+ - aca0385: `login` now accepts a `--name` flag to label credentials without the interactive prompt — useful in CI and non-interactive environments. After trimming, the provided name is honored as given in both interactive and non-interactive modes — it is never auto-suffixed.
8
+
3
9
  ## 0.55.4
4
10
 
5
11
  ### Patch Changes
package/README.md CHANGED
@@ -200,6 +200,7 @@ Log in to Zapier to access your account
200
200
 
201
201
  | Option | Type | Required | Default | Possible Values | Description |
202
202
  | ------------------- | --------- | -------- | ------- | --------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
203
+ | `--name` | `string` | ❌ | — | — | Name to identify these credentials (defaults to <email>@<hostname>). Provide this to set a custom name without the interactive prompt. |
203
204
  | `--timeout` | `string` | ❌ | — | — | Login timeout in seconds (default: 300) |
204
205
  | `--use-approvals` | `boolean` | ❌ | — | — | Require approvals for actions performed with these credentials |
205
206
  | `--non-interactive` | `boolean` | ❌ | — | — | Skip interactive prompts. Uses defaults where possible; errors instead of prompting when input is required. Useful in CI, piped output, or environments where TTY detection is unreliable. |
@@ -207,7 +208,7 @@ Log in to Zapier to access your account
207
208
  **Usage:**
208
209
 
209
210
  ```bash
210
- npx zapier-sdk login [--timeout] [--use-approvals] [--non-interactive]
211
+ npx zapier-sdk login [--name] [--timeout] [--use-approvals] [--non-interactive]
211
212
  ```
212
213
 
213
214
  #### `logout`
package/dist/cli.cjs CHANGED
@@ -1573,7 +1573,7 @@ var SHARED_COMMAND_CLI_OPTIONS = [
1573
1573
 
1574
1574
  // package.json
1575
1575
  var package_default = {
1576
- version: "0.55.4"};
1576
+ version: "0.55.5"};
1577
1577
 
1578
1578
  // src/telemetry/builders.ts
1579
1579
  function createCliBaseEvent(context = {}) {
@@ -3044,6 +3044,15 @@ function resolveAvailableCredentialName({
3044
3044
  );
3045
3045
  return firstAvailableCredentialName({ baseName, taken });
3046
3046
  }
3047
+ function credentialNameExists({
3048
+ name,
3049
+ baseUrl: baseUrl2
3050
+ }) {
3051
+ const resolvedBaseUrl = normalizeBaseUrl(baseUrl2);
3052
+ return readRegistry().some(
3053
+ (e) => e.name === name && e.baseUrl === resolvedBaseUrl
3054
+ );
3055
+ }
3047
3056
  async function storeClientCredentials({
3048
3057
  name,
3049
3058
  clientId,
@@ -4349,6 +4358,21 @@ function resolveDefaultCredentialsName({
4349
4358
  }) {
4350
4359
  return validateCredentialsName(defaultCredentialsName(email));
4351
4360
  }
4361
+ async function resolveCredentialName({
4362
+ email,
4363
+ interactive,
4364
+ baseUrl: baseUrl2,
4365
+ entryPoint
4366
+ }) {
4367
+ if (interactive) {
4368
+ return promptCredentialsName({
4369
+ email,
4370
+ promptMessage: getCredentialsPromptMessage(entryPoint)
4371
+ });
4372
+ }
4373
+ const baseName = resolveDefaultCredentialsName({ email });
4374
+ return resolveAvailableCredentialName({ baseName, baseUrl: baseUrl2 });
4375
+ }
4352
4376
  function toPkceCredentials(credentials2) {
4353
4377
  if (credentials2 && zapierSdk.isCredentialsObject(credentials2) && !("clientSecret" in credentials2)) {
4354
4378
  return {
@@ -4545,6 +4569,17 @@ async function runAccountAuth({
4545
4569
  ...sdk.context,
4546
4570
  resolvedCredentials
4547
4571
  });
4572
+ const providedName = options.name !== void 0 ? validateCredentialsName(options.name) : void 0;
4573
+ if (providedName !== void 0) {
4574
+ const activeCredentials = getActiveCredentials({
4575
+ baseUrl: credentialsBaseUrl2
4576
+ });
4577
+ if (activeCredentials?.name !== providedName && credentialNameExists({ name: providedName, baseUrl: credentialsBaseUrl2 })) {
4578
+ throw new ZapierCliValidationError(
4579
+ `A credential named "${providedName}" already exists. Choose a different --name.`
4580
+ );
4581
+ }
4582
+ }
4548
4583
  if (!await clearExistingAuthState({
4549
4584
  sdk,
4550
4585
  baseUrl: credentialsBaseUrl2,
@@ -4571,11 +4606,12 @@ async function runAccountAuth({
4571
4606
  console.log(
4572
4607
  "\nGenerating credentials so this machine can make authenticated requests on your behalf."
4573
4608
  );
4574
- const baseName = interactive ? await promptCredentialsName({
4609
+ const credentialName = providedName ?? await resolveCredentialName({
4575
4610
  email: profile.email,
4576
- promptMessage: getCredentialsPromptMessage(entryPoint)
4577
- }) : resolveDefaultCredentialsName({ email: profile.email });
4578
- const credentialName = interactive ? baseName : resolveAvailableCredentialName({ baseName, baseUrl: credentialsBaseUrl2 });
4611
+ interactive,
4612
+ baseUrl: credentialsBaseUrl2,
4613
+ entryPoint
4614
+ });
4579
4615
  const useApprovals = options.useApprovals === true;
4580
4616
  await saveClientCredentials({
4581
4617
  api: scopedApi,
@@ -4593,6 +4629,9 @@ async function runAccountAuth({
4593
4629
  emitAccountAuthSuccess({ sdk, profile });
4594
4630
  }
4595
4631
  var LoginSchema = zod.z.object({
4632
+ name: zod.z.string().optional().describe(
4633
+ "Name to identify these credentials (defaults to <email>@<hostname>). Provide this to set a custom name without the interactive prompt."
4634
+ ),
4596
4635
  timeout: zod.z.string().optional().describe("Login timeout in seconds (default: 300)"),
4597
4636
  useApprovals: zod.z.boolean().optional().describe(
4598
4637
  "Require approvals for actions performed with these credentials"
@@ -7198,7 +7237,7 @@ var watchTriggerInboxCliPlugin = zapierSdk.definePlugin(
7198
7237
  // package.json with { type: 'json' }
7199
7238
  var package_default2 = {
7200
7239
  name: "@zapier/zapier-sdk-cli",
7201
- version: "0.55.4"};
7240
+ version: "0.55.5"};
7202
7241
 
7203
7242
  // src/sdk.ts
7204
7243
  zapierSdk.injectCliLogin(login_exports);
package/dist/cli.mjs CHANGED
@@ -1531,7 +1531,7 @@ var SHARED_COMMAND_CLI_OPTIONS = [
1531
1531
 
1532
1532
  // package.json
1533
1533
  var package_default = {
1534
- version: "0.55.4"};
1534
+ version: "0.55.5"};
1535
1535
 
1536
1536
  // src/telemetry/builders.ts
1537
1537
  function createCliBaseEvent(context = {}) {
@@ -3002,6 +3002,15 @@ function resolveAvailableCredentialName({
3002
3002
  );
3003
3003
  return firstAvailableCredentialName({ baseName, taken });
3004
3004
  }
3005
+ function credentialNameExists({
3006
+ name,
3007
+ baseUrl: baseUrl2
3008
+ }) {
3009
+ const resolvedBaseUrl = normalizeBaseUrl(baseUrl2);
3010
+ return readRegistry().some(
3011
+ (e) => e.name === name && e.baseUrl === resolvedBaseUrl
3012
+ );
3013
+ }
3005
3014
  async function storeClientCredentials({
3006
3015
  name,
3007
3016
  clientId,
@@ -4307,6 +4316,21 @@ function resolveDefaultCredentialsName({
4307
4316
  }) {
4308
4317
  return validateCredentialsName(defaultCredentialsName(email));
4309
4318
  }
4319
+ async function resolveCredentialName({
4320
+ email,
4321
+ interactive,
4322
+ baseUrl: baseUrl2,
4323
+ entryPoint
4324
+ }) {
4325
+ if (interactive) {
4326
+ return promptCredentialsName({
4327
+ email,
4328
+ promptMessage: getCredentialsPromptMessage(entryPoint)
4329
+ });
4330
+ }
4331
+ const baseName = resolveDefaultCredentialsName({ email });
4332
+ return resolveAvailableCredentialName({ baseName, baseUrl: baseUrl2 });
4333
+ }
4310
4334
  function toPkceCredentials(credentials2) {
4311
4335
  if (credentials2 && isCredentialsObject(credentials2) && !("clientSecret" in credentials2)) {
4312
4336
  return {
@@ -4503,6 +4527,17 @@ async function runAccountAuth({
4503
4527
  ...sdk.context,
4504
4528
  resolvedCredentials
4505
4529
  });
4530
+ const providedName = options.name !== void 0 ? validateCredentialsName(options.name) : void 0;
4531
+ if (providedName !== void 0) {
4532
+ const activeCredentials = getActiveCredentials({
4533
+ baseUrl: credentialsBaseUrl2
4534
+ });
4535
+ if (activeCredentials?.name !== providedName && credentialNameExists({ name: providedName, baseUrl: credentialsBaseUrl2 })) {
4536
+ throw new ZapierCliValidationError(
4537
+ `A credential named "${providedName}" already exists. Choose a different --name.`
4538
+ );
4539
+ }
4540
+ }
4506
4541
  if (!await clearExistingAuthState({
4507
4542
  sdk,
4508
4543
  baseUrl: credentialsBaseUrl2,
@@ -4529,11 +4564,12 @@ async function runAccountAuth({
4529
4564
  console.log(
4530
4565
  "\nGenerating credentials so this machine can make authenticated requests on your behalf."
4531
4566
  );
4532
- const baseName = interactive ? await promptCredentialsName({
4567
+ const credentialName = providedName ?? await resolveCredentialName({
4533
4568
  email: profile.email,
4534
- promptMessage: getCredentialsPromptMessage(entryPoint)
4535
- }) : resolveDefaultCredentialsName({ email: profile.email });
4536
- const credentialName = interactive ? baseName : resolveAvailableCredentialName({ baseName, baseUrl: credentialsBaseUrl2 });
4569
+ interactive,
4570
+ baseUrl: credentialsBaseUrl2,
4571
+ entryPoint
4572
+ });
4537
4573
  const useApprovals = options.useApprovals === true;
4538
4574
  await saveClientCredentials({
4539
4575
  api: scopedApi,
@@ -4551,6 +4587,9 @@ async function runAccountAuth({
4551
4587
  emitAccountAuthSuccess({ sdk, profile });
4552
4588
  }
4553
4589
  var LoginSchema = z.object({
4590
+ name: z.string().optional().describe(
4591
+ "Name to identify these credentials (defaults to <email>@<hostname>). Provide this to set a custom name without the interactive prompt."
4592
+ ),
4554
4593
  timeout: z.string().optional().describe("Login timeout in seconds (default: 300)"),
4555
4594
  useApprovals: z.boolean().optional().describe(
4556
4595
  "Require approvals for actions performed with these credentials"
@@ -7156,7 +7195,7 @@ var watchTriggerInboxCliPlugin = definePlugin(
7156
7195
  // package.json with { type: 'json' }
7157
7196
  var package_default2 = {
7158
7197
  name: "@zapier/zapier-sdk-cli",
7159
- version: "0.55.4"};
7198
+ version: "0.55.5"};
7160
7199
 
7161
7200
  // src/sdk.ts
7162
7201
  injectCliLogin(login_exports);
@@ -414,6 +414,15 @@ function resolveAvailableCredentialName({
414
414
  );
415
415
  return firstAvailableCredentialName({ baseName, taken });
416
416
  }
417
+ function credentialNameExists({
418
+ name,
419
+ baseUrl
420
+ }) {
421
+ const resolvedBaseUrl = normalizeBaseUrl(baseUrl);
422
+ return readRegistry().some(
423
+ (e) => e.name === name && e.baseUrl === resolvedBaseUrl
424
+ );
425
+ }
417
426
  async function storeClientCredentials({
418
427
  name,
419
428
  clientId,
@@ -1719,6 +1728,21 @@ function resolveDefaultCredentialsName({
1719
1728
  }) {
1720
1729
  return validateCredentialsName(defaultCredentialsName(email));
1721
1730
  }
1731
+ async function resolveCredentialName({
1732
+ email,
1733
+ interactive,
1734
+ baseUrl,
1735
+ entryPoint
1736
+ }) {
1737
+ if (interactive) {
1738
+ return promptCredentialsName({
1739
+ email,
1740
+ promptMessage: getCredentialsPromptMessage(entryPoint)
1741
+ });
1742
+ }
1743
+ const baseName = resolveDefaultCredentialsName({ email });
1744
+ return resolveAvailableCredentialName({ baseName, baseUrl });
1745
+ }
1722
1746
  function toPkceCredentials(credentials) {
1723
1747
  if (credentials && zapierSdk.isCredentialsObject(credentials) && !("clientSecret" in credentials)) {
1724
1748
  return {
@@ -1915,6 +1939,17 @@ async function runAccountAuth({
1915
1939
  ...sdk.context,
1916
1940
  resolvedCredentials
1917
1941
  });
1942
+ const providedName = options.name !== void 0 ? validateCredentialsName(options.name) : void 0;
1943
+ if (providedName !== void 0) {
1944
+ const activeCredentials = getActiveCredentials({
1945
+ baseUrl: credentialsBaseUrl
1946
+ });
1947
+ if (activeCredentials?.name !== providedName && credentialNameExists({ name: providedName, baseUrl: credentialsBaseUrl })) {
1948
+ throw new ZapierCliValidationError(
1949
+ `A credential named "${providedName}" already exists. Choose a different --name.`
1950
+ );
1951
+ }
1952
+ }
1918
1953
  if (!await clearExistingAuthState({
1919
1954
  sdk,
1920
1955
  baseUrl: credentialsBaseUrl,
@@ -1941,11 +1976,12 @@ async function runAccountAuth({
1941
1976
  console.log(
1942
1977
  "\nGenerating credentials so this machine can make authenticated requests on your behalf."
1943
1978
  );
1944
- const baseName = interactive ? await promptCredentialsName({
1979
+ const credentialName = providedName ?? await resolveCredentialName({
1945
1980
  email: profile.email,
1946
- promptMessage: getCredentialsPromptMessage(entryPoint)
1947
- }) : resolveDefaultCredentialsName({ email: profile.email });
1948
- const credentialName = interactive ? baseName : resolveAvailableCredentialName({ baseName, baseUrl: credentialsBaseUrl });
1981
+ interactive,
1982
+ baseUrl: credentialsBaseUrl,
1983
+ entryPoint
1984
+ });
1949
1985
  const useApprovals = options.useApprovals === true;
1950
1986
  await saveClientCredentials({
1951
1987
  api: scopedApi,
@@ -1963,6 +1999,9 @@ async function runAccountAuth({
1963
1999
  emitAccountAuthSuccess({ sdk, profile });
1964
2000
  }
1965
2001
  var LoginSchema = zod.z.object({
2002
+ name: zod.z.string().optional().describe(
2003
+ "Name to identify these credentials (defaults to <email>@<hostname>). Provide this to set a custom name without the interactive prompt."
2004
+ ),
1966
2005
  timeout: zod.z.string().optional().describe("Login timeout in seconds (default: 300)"),
1967
2006
  useApprovals: zod.z.boolean().optional().describe(
1968
2007
  "Require approvals for actions performed with these credentials"
@@ -4551,7 +4590,7 @@ var watchTriggerInboxCliPlugin = zapierSdk.definePlugin(
4551
4590
  // package.json with { type: 'json' }
4552
4591
  var package_default = {
4553
4592
  name: "@zapier/zapier-sdk-cli",
4554
- version: "0.55.4"};
4593
+ version: "0.55.5"};
4555
4594
 
4556
4595
  // src/experimental.ts
4557
4596
  experimental.injectCliLogin(login_exports);
@@ -378,6 +378,15 @@ function resolveAvailableCredentialName({
378
378
  );
379
379
  return firstAvailableCredentialName({ baseName, taken });
380
380
  }
381
+ function credentialNameExists({
382
+ name,
383
+ baseUrl
384
+ }) {
385
+ const resolvedBaseUrl = normalizeBaseUrl(baseUrl);
386
+ return readRegistry().some(
387
+ (e) => e.name === name && e.baseUrl === resolvedBaseUrl
388
+ );
389
+ }
381
390
  async function storeClientCredentials({
382
391
  name,
383
392
  clientId,
@@ -1683,6 +1692,21 @@ function resolveDefaultCredentialsName({
1683
1692
  }) {
1684
1693
  return validateCredentialsName(defaultCredentialsName(email));
1685
1694
  }
1695
+ async function resolveCredentialName({
1696
+ email,
1697
+ interactive,
1698
+ baseUrl,
1699
+ entryPoint
1700
+ }) {
1701
+ if (interactive) {
1702
+ return promptCredentialsName({
1703
+ email,
1704
+ promptMessage: getCredentialsPromptMessage(entryPoint)
1705
+ });
1706
+ }
1707
+ const baseName = resolveDefaultCredentialsName({ email });
1708
+ return resolveAvailableCredentialName({ baseName, baseUrl });
1709
+ }
1686
1710
  function toPkceCredentials(credentials) {
1687
1711
  if (credentials && isCredentialsObject(credentials) && !("clientSecret" in credentials)) {
1688
1712
  return {
@@ -1879,6 +1903,17 @@ async function runAccountAuth({
1879
1903
  ...sdk.context,
1880
1904
  resolvedCredentials
1881
1905
  });
1906
+ const providedName = options.name !== void 0 ? validateCredentialsName(options.name) : void 0;
1907
+ if (providedName !== void 0) {
1908
+ const activeCredentials = getActiveCredentials({
1909
+ baseUrl: credentialsBaseUrl
1910
+ });
1911
+ if (activeCredentials?.name !== providedName && credentialNameExists({ name: providedName, baseUrl: credentialsBaseUrl })) {
1912
+ throw new ZapierCliValidationError(
1913
+ `A credential named "${providedName}" already exists. Choose a different --name.`
1914
+ );
1915
+ }
1916
+ }
1882
1917
  if (!await clearExistingAuthState({
1883
1918
  sdk,
1884
1919
  baseUrl: credentialsBaseUrl,
@@ -1905,11 +1940,12 @@ async function runAccountAuth({
1905
1940
  console.log(
1906
1941
  "\nGenerating credentials so this machine can make authenticated requests on your behalf."
1907
1942
  );
1908
- const baseName = interactive ? await promptCredentialsName({
1943
+ const credentialName = providedName ?? await resolveCredentialName({
1909
1944
  email: profile.email,
1910
- promptMessage: getCredentialsPromptMessage(entryPoint)
1911
- }) : resolveDefaultCredentialsName({ email: profile.email });
1912
- const credentialName = interactive ? baseName : resolveAvailableCredentialName({ baseName, baseUrl: credentialsBaseUrl });
1945
+ interactive,
1946
+ baseUrl: credentialsBaseUrl,
1947
+ entryPoint
1948
+ });
1913
1949
  const useApprovals = options.useApprovals === true;
1914
1950
  await saveClientCredentials({
1915
1951
  api: scopedApi,
@@ -1927,6 +1963,9 @@ async function runAccountAuth({
1927
1963
  emitAccountAuthSuccess({ sdk, profile });
1928
1964
  }
1929
1965
  var LoginSchema = z.object({
1966
+ name: z.string().optional().describe(
1967
+ "Name to identify these credentials (defaults to <email>@<hostname>). Provide this to set a custom name without the interactive prompt."
1968
+ ),
1930
1969
  timeout: z.string().optional().describe("Login timeout in seconds (default: 300)"),
1931
1970
  useApprovals: z.boolean().optional().describe(
1932
1971
  "Require approvals for actions performed with these credentials"
@@ -4515,7 +4554,7 @@ var watchTriggerInboxCliPlugin = definePlugin(
4515
4554
  // package.json with { type: 'json' }
4516
4555
  var package_default = {
4517
4556
  name: "@zapier/zapier-sdk-cli",
4518
- version: "0.55.4"};
4557
+ version: "0.55.5"};
4519
4558
 
4520
4559
  // src/experimental.ts
4521
4560
  injectCliLogin(login_exports);
package/dist/index.cjs CHANGED
@@ -413,6 +413,15 @@ function resolveAvailableCredentialName({
413
413
  );
414
414
  return firstAvailableCredentialName({ baseName, taken });
415
415
  }
416
+ function credentialNameExists({
417
+ name,
418
+ baseUrl
419
+ }) {
420
+ const resolvedBaseUrl = normalizeBaseUrl(baseUrl);
421
+ return readRegistry().some(
422
+ (e) => e.name === name && e.baseUrl === resolvedBaseUrl
423
+ );
424
+ }
416
425
  async function storeClientCredentials({
417
426
  name,
418
427
  clientId,
@@ -1718,6 +1727,21 @@ function resolveDefaultCredentialsName({
1718
1727
  }) {
1719
1728
  return validateCredentialsName(defaultCredentialsName(email));
1720
1729
  }
1730
+ async function resolveCredentialName({
1731
+ email,
1732
+ interactive,
1733
+ baseUrl,
1734
+ entryPoint
1735
+ }) {
1736
+ if (interactive) {
1737
+ return promptCredentialsName({
1738
+ email,
1739
+ promptMessage: getCredentialsPromptMessage(entryPoint)
1740
+ });
1741
+ }
1742
+ const baseName = resolveDefaultCredentialsName({ email });
1743
+ return resolveAvailableCredentialName({ baseName, baseUrl });
1744
+ }
1721
1745
  function toPkceCredentials(credentials) {
1722
1746
  if (credentials && zapierSdk.isCredentialsObject(credentials) && !("clientSecret" in credentials)) {
1723
1747
  return {
@@ -1914,6 +1938,17 @@ async function runAccountAuth({
1914
1938
  ...sdk.context,
1915
1939
  resolvedCredentials
1916
1940
  });
1941
+ const providedName = options.name !== void 0 ? validateCredentialsName(options.name) : void 0;
1942
+ if (providedName !== void 0) {
1943
+ const activeCredentials = getActiveCredentials({
1944
+ baseUrl: credentialsBaseUrl
1945
+ });
1946
+ if (activeCredentials?.name !== providedName && credentialNameExists({ name: providedName, baseUrl: credentialsBaseUrl })) {
1947
+ throw new ZapierCliValidationError(
1948
+ `A credential named "${providedName}" already exists. Choose a different --name.`
1949
+ );
1950
+ }
1951
+ }
1917
1952
  if (!await clearExistingAuthState({
1918
1953
  sdk,
1919
1954
  baseUrl: credentialsBaseUrl,
@@ -1940,11 +1975,12 @@ async function runAccountAuth({
1940
1975
  console.log(
1941
1976
  "\nGenerating credentials so this machine can make authenticated requests on your behalf."
1942
1977
  );
1943
- const baseName = interactive ? await promptCredentialsName({
1978
+ const credentialName = providedName ?? await resolveCredentialName({
1944
1979
  email: profile.email,
1945
- promptMessage: getCredentialsPromptMessage(entryPoint)
1946
- }) : resolveDefaultCredentialsName({ email: profile.email });
1947
- const credentialName = interactive ? baseName : resolveAvailableCredentialName({ baseName, baseUrl: credentialsBaseUrl });
1980
+ interactive,
1981
+ baseUrl: credentialsBaseUrl,
1982
+ entryPoint
1983
+ });
1948
1984
  const useApprovals = options.useApprovals === true;
1949
1985
  await saveClientCredentials({
1950
1986
  api: scopedApi,
@@ -1962,6 +1998,9 @@ async function runAccountAuth({
1962
1998
  emitAccountAuthSuccess({ sdk, profile });
1963
1999
  }
1964
2000
  var LoginSchema = zod.z.object({
2001
+ name: zod.z.string().optional().describe(
2002
+ "Name to identify these credentials (defaults to <email>@<hostname>). Provide this to set a custom name without the interactive prompt."
2003
+ ),
1965
2004
  timeout: zod.z.string().optional().describe("Login timeout in seconds (default: 300)"),
1966
2005
  useApprovals: zod.z.boolean().optional().describe(
1967
2006
  "Require approvals for actions performed with these credentials"
@@ -4550,7 +4589,7 @@ zapierSdk.definePlugin(
4550
4589
  // package.json with { type: 'json' }
4551
4590
  var package_default = {
4552
4591
  name: "@zapier/zapier-sdk-cli",
4553
- version: "0.55.4"};
4592
+ version: "0.55.5"};
4554
4593
 
4555
4594
  // src/sdk.ts
4556
4595
  zapierSdk.injectCliLogin(login_exports);
@@ -4578,7 +4617,7 @@ function createZapierCliSdk(options = {}) {
4578
4617
 
4579
4618
  // package.json
4580
4619
  var package_default2 = {
4581
- version: "0.55.4"};
4620
+ version: "0.55.5"};
4582
4621
 
4583
4622
  // src/telemetry/builders.ts
4584
4623
  function createCliBaseEvent(context = {}) {
package/dist/index.mjs CHANGED
@@ -377,6 +377,15 @@ function resolveAvailableCredentialName({
377
377
  );
378
378
  return firstAvailableCredentialName({ baseName, taken });
379
379
  }
380
+ function credentialNameExists({
381
+ name,
382
+ baseUrl
383
+ }) {
384
+ const resolvedBaseUrl = normalizeBaseUrl(baseUrl);
385
+ return readRegistry().some(
386
+ (e) => e.name === name && e.baseUrl === resolvedBaseUrl
387
+ );
388
+ }
380
389
  async function storeClientCredentials({
381
390
  name,
382
391
  clientId,
@@ -1682,6 +1691,21 @@ function resolveDefaultCredentialsName({
1682
1691
  }) {
1683
1692
  return validateCredentialsName(defaultCredentialsName(email));
1684
1693
  }
1694
+ async function resolveCredentialName({
1695
+ email,
1696
+ interactive,
1697
+ baseUrl,
1698
+ entryPoint
1699
+ }) {
1700
+ if (interactive) {
1701
+ return promptCredentialsName({
1702
+ email,
1703
+ promptMessage: getCredentialsPromptMessage(entryPoint)
1704
+ });
1705
+ }
1706
+ const baseName = resolveDefaultCredentialsName({ email });
1707
+ return resolveAvailableCredentialName({ baseName, baseUrl });
1708
+ }
1685
1709
  function toPkceCredentials(credentials) {
1686
1710
  if (credentials && isCredentialsObject(credentials) && !("clientSecret" in credentials)) {
1687
1711
  return {
@@ -1878,6 +1902,17 @@ async function runAccountAuth({
1878
1902
  ...sdk.context,
1879
1903
  resolvedCredentials
1880
1904
  });
1905
+ const providedName = options.name !== void 0 ? validateCredentialsName(options.name) : void 0;
1906
+ if (providedName !== void 0) {
1907
+ const activeCredentials = getActiveCredentials({
1908
+ baseUrl: credentialsBaseUrl
1909
+ });
1910
+ if (activeCredentials?.name !== providedName && credentialNameExists({ name: providedName, baseUrl: credentialsBaseUrl })) {
1911
+ throw new ZapierCliValidationError(
1912
+ `A credential named "${providedName}" already exists. Choose a different --name.`
1913
+ );
1914
+ }
1915
+ }
1881
1916
  if (!await clearExistingAuthState({
1882
1917
  sdk,
1883
1918
  baseUrl: credentialsBaseUrl,
@@ -1904,11 +1939,12 @@ async function runAccountAuth({
1904
1939
  console.log(
1905
1940
  "\nGenerating credentials so this machine can make authenticated requests on your behalf."
1906
1941
  );
1907
- const baseName = interactive ? await promptCredentialsName({
1942
+ const credentialName = providedName ?? await resolveCredentialName({
1908
1943
  email: profile.email,
1909
- promptMessage: getCredentialsPromptMessage(entryPoint)
1910
- }) : resolveDefaultCredentialsName({ email: profile.email });
1911
- const credentialName = interactive ? baseName : resolveAvailableCredentialName({ baseName, baseUrl: credentialsBaseUrl });
1944
+ interactive,
1945
+ baseUrl: credentialsBaseUrl,
1946
+ entryPoint
1947
+ });
1912
1948
  const useApprovals = options.useApprovals === true;
1913
1949
  await saveClientCredentials({
1914
1950
  api: scopedApi,
@@ -1926,6 +1962,9 @@ async function runAccountAuth({
1926
1962
  emitAccountAuthSuccess({ sdk, profile });
1927
1963
  }
1928
1964
  var LoginSchema = z.object({
1965
+ name: z.string().optional().describe(
1966
+ "Name to identify these credentials (defaults to <email>@<hostname>). Provide this to set a custom name without the interactive prompt."
1967
+ ),
1929
1968
  timeout: z.string().optional().describe("Login timeout in seconds (default: 300)"),
1930
1969
  useApprovals: z.boolean().optional().describe(
1931
1970
  "Require approvals for actions performed with these credentials"
@@ -4514,7 +4553,7 @@ definePlugin(
4514
4553
  // package.json with { type: 'json' }
4515
4554
  var package_default = {
4516
4555
  name: "@zapier/zapier-sdk-cli",
4517
- version: "0.55.4"};
4556
+ version: "0.55.5"};
4518
4557
 
4519
4558
  // src/sdk.ts
4520
4559
  injectCliLogin(login_exports);
@@ -4542,7 +4581,7 @@ function createZapierCliSdk(options = {}) {
4542
4581
 
4543
4582
  // package.json
4544
4583
  var package_default2 = {
4545
- version: "0.55.4"};
4584
+ version: "0.55.5"};
4546
4585
 
4547
4586
  // src/telemetry/builders.ts
4548
4587
  function createCliBaseEvent(context = {}) {
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zapier/zapier-sdk-cli",
3
- "version": "0.55.4",
3
+ "version": "0.55.5",
4
4
  "description": "Command line interface for Zapier SDK",
5
5
  "main": "dist/index.cjs",
6
6
  "module": "dist/index.mjs",
@@ -33,6 +33,15 @@ export declare function resolveAvailableCredentialName({ baseName, baseUrl, }: {
33
33
  baseName: string;
34
34
  baseUrl?: string;
35
35
  }): string;
36
+ /**
37
+ * Whether a credential with this exact (name, baseUrl) is already stored
38
+ * locally. Used to reject an explicitly-supplied login name that would
39
+ * otherwise silently overwrite a dormant credential of the same name.
40
+ */
41
+ export declare function credentialNameExists({ name, baseUrl, }: {
42
+ name: string;
43
+ baseUrl?: string;
44
+ }): boolean;
36
45
  export declare function storeClientCredentials({ name, clientId, clientSecret, scopes, baseUrl, }: {
37
46
  name: string;
38
47
  clientId: string;
@@ -74,6 +74,15 @@ export function resolveAvailableCredentialName({ baseName, baseUrl, }) {
74
74
  .map((e) => e.name));
75
75
  return firstAvailableCredentialName({ baseName, taken });
76
76
  }
77
+ /**
78
+ * Whether a credential with this exact (name, baseUrl) is already stored
79
+ * locally. Used to reject an explicitly-supplied login name that would
80
+ * otherwise silently overwrite a dormant credential of the same name.
81
+ */
82
+ export function credentialNameExists({ name, baseUrl, }) {
83
+ const resolvedBaseUrl = normalizeBaseUrl(baseUrl);
84
+ return readRegistry().some((e) => e.name === name && e.baseUrl === resolvedBaseUrl);
85
+ }
77
86
  export async function storeClientCredentials({ name, clientId, clientSecret, scopes, baseUrl, }) {
78
87
  if (!name || typeof name !== "string") {
79
88
  throw new Error("storeClientCredentials: name is required");
@@ -9,6 +9,7 @@ export declare const loginPlugin: (sdk: {
9
9
  };
10
10
  }) => {
11
11
  login: (options?: {
12
+ name?: string | undefined;
12
13
  timeout?: string | undefined;
13
14
  useApprovals?: boolean | undefined;
14
15
  nonInteractive?: boolean | undefined;
@@ -1,5 +1,6 @@
1
1
  import { z } from "zod";
2
2
  export declare const LoginSchema: z.ZodObject<{
3
+ name: z.ZodOptional<z.ZodString>;
3
4
  timeout: z.ZodOptional<z.ZodString>;
4
5
  useApprovals: z.ZodOptional<z.ZodBoolean>;
5
6
  nonInteractive: z.ZodOptional<z.ZodBoolean>;
@@ -2,6 +2,10 @@ import { z } from "zod";
2
2
  // Login schema
3
3
  export const LoginSchema = z
4
4
  .object({
5
+ name: z
6
+ .string()
7
+ .optional()
8
+ .describe("Name to identify these credentials (defaults to <email>@<hostname>). Provide this to set a custom name without the interactive prompt."),
5
9
  timeout: z
6
10
  .string()
7
11
  .optional()