@zapier/zapier-sdk-cli 0.55.2 → 0.55.4
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 +32 -6
- package/dist/cli.mjs +33 -7
- package/dist/experimental.cjs +57 -31
- package/dist/experimental.mjs +57 -31
- package/dist/index.cjs +60 -32
- package/dist/index.d.mts +3 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.mjs +61 -33
- package/dist/login.cjs +2 -0
- package/dist/login.mjs +2 -0
- package/dist/package.json +1 -1
- package/dist/src/login/credentials-store.d.ts +22 -0
- package/dist/src/login/credentials-store.js +33 -0
- package/dist/src/telemetry/builders.js +3 -1
- package/dist/src/telemetry/events.d.ts +3 -0
- package/dist/src/utils/auth/account-auth.js +11 -6
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# @zapier/zapier-sdk-cli
|
|
2
2
|
|
|
3
|
+
## 0.55.4
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- b83f0b6: Add TTY and agent caller context to SDK telemetry events
|
|
8
|
+
- Updated dependencies [b83f0b6]
|
|
9
|
+
- Updated dependencies [3fa4bbe]
|
|
10
|
+
- @zapier/zapier-sdk@0.70.3
|
|
11
|
+
- @zapier/zapier-sdk-mcp@0.13.31
|
|
12
|
+
|
|
13
|
+
## 0.55.3
|
|
14
|
+
|
|
15
|
+
### Patch Changes
|
|
16
|
+
|
|
17
|
+
- 036fb94: Non-interactive `login` and `signup` now append an incrementing suffix (`<name>-1`, `<name>-2`, …) when the default credential name (`<email>@<hostname>`) already exists locally, instead of silently overwriting the existing credential's local entry and keychain secret. Interactive logins are unchanged.
|
|
18
|
+
|
|
3
19
|
## 0.55.2
|
|
4
20
|
|
|
5
21
|
### Patch Changes
|
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.
|
|
1576
|
+
version: "0.55.4"};
|
|
1577
1577
|
|
|
1578
1578
|
// src/telemetry/builders.ts
|
|
1579
1579
|
function createCliBaseEvent(context = {}) {
|
|
@@ -1617,6 +1617,8 @@ function buildCliCommandExecutedEvent({
|
|
|
1617
1617
|
requires_auth: null,
|
|
1618
1618
|
is_ci_environment: zapierSdk.isCi(),
|
|
1619
1619
|
ci_platform: zapierSdk.getCiPlatform(),
|
|
1620
|
+
...zapierSdk.getTtyContext(),
|
|
1621
|
+
agent: zapierSdk.getAgent(),
|
|
1620
1622
|
package_manager: data.package_manager ?? "pnpm",
|
|
1621
1623
|
// Default based on project setup
|
|
1622
1624
|
made_network_requests: data.made_network_requests ?? null,
|
|
@@ -3018,6 +3020,30 @@ function getActiveCredentials(options) {
|
|
|
3018
3020
|
if (!name) return void 0;
|
|
3019
3021
|
return findEntry(readRegistry(), name, normalizeBaseUrl(options?.baseUrl));
|
|
3020
3022
|
}
|
|
3023
|
+
var MAX_CREDENTIAL_NAME_ATTEMPTS = 500;
|
|
3024
|
+
function firstAvailableCredentialName({
|
|
3025
|
+
baseName,
|
|
3026
|
+
taken
|
|
3027
|
+
}) {
|
|
3028
|
+
if (!taken.has(baseName)) return baseName;
|
|
3029
|
+
for (let i = 1; i <= MAX_CREDENTIAL_NAME_ATTEMPTS; i++) {
|
|
3030
|
+
const candidate = `${baseName}-${i}`;
|
|
3031
|
+
if (!taken.has(candidate)) return candidate;
|
|
3032
|
+
}
|
|
3033
|
+
throw new ZapierCliValidationError(
|
|
3034
|
+
`Could not find an available credential name for "${baseName}" after ${MAX_CREDENTIAL_NAME_ATTEMPTS} attempts.`
|
|
3035
|
+
);
|
|
3036
|
+
}
|
|
3037
|
+
function resolveAvailableCredentialName({
|
|
3038
|
+
baseName,
|
|
3039
|
+
baseUrl: baseUrl2
|
|
3040
|
+
}) {
|
|
3041
|
+
const resolvedBaseUrl = normalizeBaseUrl(baseUrl2);
|
|
3042
|
+
const taken = new Set(
|
|
3043
|
+
readRegistry().filter((e) => e.baseUrl === resolvedBaseUrl).map((e) => e.name)
|
|
3044
|
+
);
|
|
3045
|
+
return firstAvailableCredentialName({ baseName, taken });
|
|
3046
|
+
}
|
|
3021
3047
|
async function storeClientCredentials({
|
|
3022
3048
|
name,
|
|
3023
3049
|
clientId,
|
|
@@ -4545,11 +4571,11 @@ async function runAccountAuth({
|
|
|
4545
4571
|
console.log(
|
|
4546
4572
|
"\nGenerating credentials so this machine can make authenticated requests on your behalf."
|
|
4547
4573
|
);
|
|
4548
|
-
const
|
|
4549
|
-
email,
|
|
4574
|
+
const baseName = interactive ? await promptCredentialsName({
|
|
4575
|
+
email: profile.email,
|
|
4550
4576
|
promptMessage: getCredentialsPromptMessage(entryPoint)
|
|
4551
|
-
}) : resolveDefaultCredentialsName;
|
|
4552
|
-
const credentialName =
|
|
4577
|
+
}) : resolveDefaultCredentialsName({ email: profile.email });
|
|
4578
|
+
const credentialName = interactive ? baseName : resolveAvailableCredentialName({ baseName, baseUrl: credentialsBaseUrl2 });
|
|
4553
4579
|
const useApprovals = options.useApprovals === true;
|
|
4554
4580
|
await saveClientCredentials({
|
|
4555
4581
|
api: scopedApi,
|
|
@@ -7172,7 +7198,7 @@ var watchTriggerInboxCliPlugin = zapierSdk.definePlugin(
|
|
|
7172
7198
|
// package.json with { type: 'json' }
|
|
7173
7199
|
var package_default2 = {
|
|
7174
7200
|
name: "@zapier/zapier-sdk-cli",
|
|
7175
|
-
version: "0.55.
|
|
7201
|
+
version: "0.55.4"};
|
|
7176
7202
|
|
|
7177
7203
|
// src/sdk.ts
|
|
7178
7204
|
zapierSdk.injectCliLogin(login_exports);
|
package/dist/cli.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { Command, CommanderError, Option } from 'commander';
|
|
3
3
|
import { z } from 'zod';
|
|
4
|
-
import { definePlugin, createPluginMethod, OutputPropertySchema, ZapierBundleError, DEFAULT_CONFIG_PATH, ZapierValidationError, ZapierUnknownError, ZapierReleaseTriggerMessageSignal, injectCliLogin, BaseSdkOptionsSchema, getOrCreateApiClient, isPermanentHttpError, invalidateCachedToken, batch, toSnakeCase, ZapierAbortDrainSignal, createZapierSdkStack as createZapierSdkStack$1, addPlugin as addPlugin$1, ZapierError, isCredentialsObject, buildApplicationLifecycleEvent, ZapierAuthenticationError, isPositional, runWithTelemetryContext, buildCapabilityMessage, formatErrorMessage, getOsInfo, getPlatformVersions, getCiPlatform, isCi, getReleaseId, getCurrentTimestamp, generateEventId } from '@zapier/zapier-sdk';
|
|
4
|
+
import { definePlugin, createPluginMethod, OutputPropertySchema, ZapierBundleError, DEFAULT_CONFIG_PATH, ZapierValidationError, ZapierUnknownError, ZapierReleaseTriggerMessageSignal, injectCliLogin, BaseSdkOptionsSchema, getOrCreateApiClient, isPermanentHttpError, invalidateCachedToken, batch, toSnakeCase, ZapierAbortDrainSignal, createZapierSdkStack as createZapierSdkStack$1, addPlugin as addPlugin$1, ZapierError, isCredentialsObject, buildApplicationLifecycleEvent, ZapierAuthenticationError, isPositional, runWithTelemetryContext, buildCapabilityMessage, formatErrorMessage, getOsInfo, getPlatformVersions, getAgent, getTtyContext, getCiPlatform, isCi, getReleaseId, getCurrentTimestamp, generateEventId } from '@zapier/zapier-sdk';
|
|
5
5
|
import inquirer from 'inquirer';
|
|
6
6
|
import search from '@inquirer/search';
|
|
7
7
|
import chalk from 'chalk';
|
|
@@ -1531,7 +1531,7 @@ var SHARED_COMMAND_CLI_OPTIONS = [
|
|
|
1531
1531
|
|
|
1532
1532
|
// package.json
|
|
1533
1533
|
var package_default = {
|
|
1534
|
-
version: "0.55.
|
|
1534
|
+
version: "0.55.4"};
|
|
1535
1535
|
|
|
1536
1536
|
// src/telemetry/builders.ts
|
|
1537
1537
|
function createCliBaseEvent(context = {}) {
|
|
@@ -1575,6 +1575,8 @@ function buildCliCommandExecutedEvent({
|
|
|
1575
1575
|
requires_auth: null,
|
|
1576
1576
|
is_ci_environment: isCi(),
|
|
1577
1577
|
ci_platform: getCiPlatform(),
|
|
1578
|
+
...getTtyContext(),
|
|
1579
|
+
agent: getAgent(),
|
|
1578
1580
|
package_manager: data.package_manager ?? "pnpm",
|
|
1579
1581
|
// Default based on project setup
|
|
1580
1582
|
made_network_requests: data.made_network_requests ?? null,
|
|
@@ -2976,6 +2978,30 @@ function getActiveCredentials(options) {
|
|
|
2976
2978
|
if (!name) return void 0;
|
|
2977
2979
|
return findEntry(readRegistry(), name, normalizeBaseUrl(options?.baseUrl));
|
|
2978
2980
|
}
|
|
2981
|
+
var MAX_CREDENTIAL_NAME_ATTEMPTS = 500;
|
|
2982
|
+
function firstAvailableCredentialName({
|
|
2983
|
+
baseName,
|
|
2984
|
+
taken
|
|
2985
|
+
}) {
|
|
2986
|
+
if (!taken.has(baseName)) return baseName;
|
|
2987
|
+
for (let i = 1; i <= MAX_CREDENTIAL_NAME_ATTEMPTS; i++) {
|
|
2988
|
+
const candidate = `${baseName}-${i}`;
|
|
2989
|
+
if (!taken.has(candidate)) return candidate;
|
|
2990
|
+
}
|
|
2991
|
+
throw new ZapierCliValidationError(
|
|
2992
|
+
`Could not find an available credential name for "${baseName}" after ${MAX_CREDENTIAL_NAME_ATTEMPTS} attempts.`
|
|
2993
|
+
);
|
|
2994
|
+
}
|
|
2995
|
+
function resolveAvailableCredentialName({
|
|
2996
|
+
baseName,
|
|
2997
|
+
baseUrl: baseUrl2
|
|
2998
|
+
}) {
|
|
2999
|
+
const resolvedBaseUrl = normalizeBaseUrl(baseUrl2);
|
|
3000
|
+
const taken = new Set(
|
|
3001
|
+
readRegistry().filter((e) => e.baseUrl === resolvedBaseUrl).map((e) => e.name)
|
|
3002
|
+
);
|
|
3003
|
+
return firstAvailableCredentialName({ baseName, taken });
|
|
3004
|
+
}
|
|
2979
3005
|
async function storeClientCredentials({
|
|
2980
3006
|
name,
|
|
2981
3007
|
clientId,
|
|
@@ -4503,11 +4529,11 @@ async function runAccountAuth({
|
|
|
4503
4529
|
console.log(
|
|
4504
4530
|
"\nGenerating credentials so this machine can make authenticated requests on your behalf."
|
|
4505
4531
|
);
|
|
4506
|
-
const
|
|
4507
|
-
email,
|
|
4532
|
+
const baseName = interactive ? await promptCredentialsName({
|
|
4533
|
+
email: profile.email,
|
|
4508
4534
|
promptMessage: getCredentialsPromptMessage(entryPoint)
|
|
4509
|
-
}) : resolveDefaultCredentialsName;
|
|
4510
|
-
const credentialName =
|
|
4535
|
+
}) : resolveDefaultCredentialsName({ email: profile.email });
|
|
4536
|
+
const credentialName = interactive ? baseName : resolveAvailableCredentialName({ baseName, baseUrl: credentialsBaseUrl2 });
|
|
4511
4537
|
const useApprovals = options.useApprovals === true;
|
|
4512
4538
|
await saveClientCredentials({
|
|
4513
4539
|
api: scopedApi,
|
|
@@ -7130,7 +7156,7 @@ var watchTriggerInboxCliPlugin = definePlugin(
|
|
|
7130
7156
|
// package.json with { type: 'json' }
|
|
7131
7157
|
var package_default2 = {
|
|
7132
7158
|
name: "@zapier/zapier-sdk-cli",
|
|
7133
|
-
version: "0.55.
|
|
7159
|
+
version: "0.55.4"};
|
|
7134
7160
|
|
|
7135
7161
|
// src/sdk.ts
|
|
7136
7162
|
injectCliLogin(login_exports);
|
package/dist/experimental.cjs
CHANGED
|
@@ -326,6 +326,34 @@ function createCache() {
|
|
|
326
326
|
}
|
|
327
327
|
};
|
|
328
328
|
}
|
|
329
|
+
var ZapierCliError = class extends zapierSdk.ZapierError {
|
|
330
|
+
};
|
|
331
|
+
var ZapierCliUserCancellationError = class extends ZapierCliError {
|
|
332
|
+
constructor(message = "Operation cancelled by user") {
|
|
333
|
+
super(message);
|
|
334
|
+
this.name = "ZapierCliUserCancellationError";
|
|
335
|
+
this.code = "ZAPIER_CLI_USER_CANCELLATION";
|
|
336
|
+
this.exitCode = 0;
|
|
337
|
+
}
|
|
338
|
+
};
|
|
339
|
+
var ZapierCliExitError = class extends ZapierCliError {
|
|
340
|
+
constructor(message, exitCode = 1) {
|
|
341
|
+
super(message);
|
|
342
|
+
this.name = "ZapierCliExitError";
|
|
343
|
+
this.code = "ZAPIER_CLI_EXIT";
|
|
344
|
+
this.exitCode = exitCode;
|
|
345
|
+
}
|
|
346
|
+
};
|
|
347
|
+
var ZapierCliValidationError = class extends ZapierCliError {
|
|
348
|
+
constructor(message) {
|
|
349
|
+
super(message);
|
|
350
|
+
this.name = "ZapierCliValidationError";
|
|
351
|
+
this.code = "ZAPIER_CLI_VALIDATION_ERROR";
|
|
352
|
+
this.exitCode = 1;
|
|
353
|
+
}
|
|
354
|
+
};
|
|
355
|
+
|
|
356
|
+
// src/login/credentials-store.ts
|
|
329
357
|
var SERVICE3 = "zapier-sdk-cli";
|
|
330
358
|
var CREDENTIALS_KEY = "credentials";
|
|
331
359
|
var REGISTRY_KEY = "credentialsRegistry";
|
|
@@ -362,6 +390,30 @@ function getActiveCredentials(options) {
|
|
|
362
390
|
if (!name) return void 0;
|
|
363
391
|
return findEntry(readRegistry(), name, normalizeBaseUrl(options?.baseUrl));
|
|
364
392
|
}
|
|
393
|
+
var MAX_CREDENTIAL_NAME_ATTEMPTS = 500;
|
|
394
|
+
function firstAvailableCredentialName({
|
|
395
|
+
baseName,
|
|
396
|
+
taken
|
|
397
|
+
}) {
|
|
398
|
+
if (!taken.has(baseName)) return baseName;
|
|
399
|
+
for (let i = 1; i <= MAX_CREDENTIAL_NAME_ATTEMPTS; i++) {
|
|
400
|
+
const candidate = `${baseName}-${i}`;
|
|
401
|
+
if (!taken.has(candidate)) return candidate;
|
|
402
|
+
}
|
|
403
|
+
throw new ZapierCliValidationError(
|
|
404
|
+
`Could not find an available credential name for "${baseName}" after ${MAX_CREDENTIAL_NAME_ATTEMPTS} attempts.`
|
|
405
|
+
);
|
|
406
|
+
}
|
|
407
|
+
function resolveAvailableCredentialName({
|
|
408
|
+
baseName,
|
|
409
|
+
baseUrl
|
|
410
|
+
}) {
|
|
411
|
+
const resolvedBaseUrl = normalizeBaseUrl(baseUrl);
|
|
412
|
+
const taken = new Set(
|
|
413
|
+
readRegistry().filter((e) => e.baseUrl === resolvedBaseUrl).map((e) => e.name)
|
|
414
|
+
);
|
|
415
|
+
return firstAvailableCredentialName({ baseName, taken });
|
|
416
|
+
}
|
|
365
417
|
async function storeClientCredentials({
|
|
366
418
|
name,
|
|
367
419
|
clientId,
|
|
@@ -928,32 +980,6 @@ async function resolveCredentialsBaseUrl(context) {
|
|
|
928
980
|
function resolveNonInteractive(options) {
|
|
929
981
|
return options.nonInteractive === true || options.skipPrompts === true || !process.stdin.isTTY || !process.stdout.isTTY;
|
|
930
982
|
}
|
|
931
|
-
var ZapierCliError = class extends zapierSdk.ZapierError {
|
|
932
|
-
};
|
|
933
|
-
var ZapierCliUserCancellationError = class extends ZapierCliError {
|
|
934
|
-
constructor(message = "Operation cancelled by user") {
|
|
935
|
-
super(message);
|
|
936
|
-
this.name = "ZapierCliUserCancellationError";
|
|
937
|
-
this.code = "ZAPIER_CLI_USER_CANCELLATION";
|
|
938
|
-
this.exitCode = 0;
|
|
939
|
-
}
|
|
940
|
-
};
|
|
941
|
-
var ZapierCliExitError = class extends ZapierCliError {
|
|
942
|
-
constructor(message, exitCode = 1) {
|
|
943
|
-
super(message);
|
|
944
|
-
this.name = "ZapierCliExitError";
|
|
945
|
-
this.code = "ZAPIER_CLI_EXIT";
|
|
946
|
-
this.exitCode = exitCode;
|
|
947
|
-
}
|
|
948
|
-
};
|
|
949
|
-
var ZapierCliValidationError = class extends ZapierCliError {
|
|
950
|
-
constructor(message) {
|
|
951
|
-
super(message);
|
|
952
|
-
this.name = "ZapierCliValidationError";
|
|
953
|
-
this.code = "ZAPIER_CLI_VALIDATION_ERROR";
|
|
954
|
-
this.exitCode = 1;
|
|
955
|
-
}
|
|
956
|
-
};
|
|
957
983
|
|
|
958
984
|
// src/utils/auth/client-credentials.ts
|
|
959
985
|
var CREDENTIALS_SCOPES = ["external", "credentials"];
|
|
@@ -1915,11 +1941,11 @@ async function runAccountAuth({
|
|
|
1915
1941
|
console.log(
|
|
1916
1942
|
"\nGenerating credentials so this machine can make authenticated requests on your behalf."
|
|
1917
1943
|
);
|
|
1918
|
-
const
|
|
1919
|
-
email,
|
|
1944
|
+
const baseName = interactive ? await promptCredentialsName({
|
|
1945
|
+
email: profile.email,
|
|
1920
1946
|
promptMessage: getCredentialsPromptMessage(entryPoint)
|
|
1921
|
-
}) : resolveDefaultCredentialsName;
|
|
1922
|
-
const credentialName =
|
|
1947
|
+
}) : resolveDefaultCredentialsName({ email: profile.email });
|
|
1948
|
+
const credentialName = interactive ? baseName : resolveAvailableCredentialName({ baseName, baseUrl: credentialsBaseUrl });
|
|
1923
1949
|
const useApprovals = options.useApprovals === true;
|
|
1924
1950
|
await saveClientCredentials({
|
|
1925
1951
|
api: scopedApi,
|
|
@@ -4525,7 +4551,7 @@ var watchTriggerInboxCliPlugin = zapierSdk.definePlugin(
|
|
|
4525
4551
|
// package.json with { type: 'json' }
|
|
4526
4552
|
var package_default = {
|
|
4527
4553
|
name: "@zapier/zapier-sdk-cli",
|
|
4528
|
-
version: "0.55.
|
|
4554
|
+
version: "0.55.4"};
|
|
4529
4555
|
|
|
4530
4556
|
// src/experimental.ts
|
|
4531
4557
|
experimental.injectCliLogin(login_exports);
|
package/dist/experimental.mjs
CHANGED
|
@@ -290,6 +290,34 @@ function createCache() {
|
|
|
290
290
|
}
|
|
291
291
|
};
|
|
292
292
|
}
|
|
293
|
+
var ZapierCliError = class extends ZapierError {
|
|
294
|
+
};
|
|
295
|
+
var ZapierCliUserCancellationError = class extends ZapierCliError {
|
|
296
|
+
constructor(message = "Operation cancelled by user") {
|
|
297
|
+
super(message);
|
|
298
|
+
this.name = "ZapierCliUserCancellationError";
|
|
299
|
+
this.code = "ZAPIER_CLI_USER_CANCELLATION";
|
|
300
|
+
this.exitCode = 0;
|
|
301
|
+
}
|
|
302
|
+
};
|
|
303
|
+
var ZapierCliExitError = class extends ZapierCliError {
|
|
304
|
+
constructor(message, exitCode = 1) {
|
|
305
|
+
super(message);
|
|
306
|
+
this.name = "ZapierCliExitError";
|
|
307
|
+
this.code = "ZAPIER_CLI_EXIT";
|
|
308
|
+
this.exitCode = exitCode;
|
|
309
|
+
}
|
|
310
|
+
};
|
|
311
|
+
var ZapierCliValidationError = class extends ZapierCliError {
|
|
312
|
+
constructor(message) {
|
|
313
|
+
super(message);
|
|
314
|
+
this.name = "ZapierCliValidationError";
|
|
315
|
+
this.code = "ZAPIER_CLI_VALIDATION_ERROR";
|
|
316
|
+
this.exitCode = 1;
|
|
317
|
+
}
|
|
318
|
+
};
|
|
319
|
+
|
|
320
|
+
// src/login/credentials-store.ts
|
|
293
321
|
var SERVICE3 = "zapier-sdk-cli";
|
|
294
322
|
var CREDENTIALS_KEY = "credentials";
|
|
295
323
|
var REGISTRY_KEY = "credentialsRegistry";
|
|
@@ -326,6 +354,30 @@ function getActiveCredentials(options) {
|
|
|
326
354
|
if (!name) return void 0;
|
|
327
355
|
return findEntry(readRegistry(), name, normalizeBaseUrl(options?.baseUrl));
|
|
328
356
|
}
|
|
357
|
+
var MAX_CREDENTIAL_NAME_ATTEMPTS = 500;
|
|
358
|
+
function firstAvailableCredentialName({
|
|
359
|
+
baseName,
|
|
360
|
+
taken
|
|
361
|
+
}) {
|
|
362
|
+
if (!taken.has(baseName)) return baseName;
|
|
363
|
+
for (let i = 1; i <= MAX_CREDENTIAL_NAME_ATTEMPTS; i++) {
|
|
364
|
+
const candidate = `${baseName}-${i}`;
|
|
365
|
+
if (!taken.has(candidate)) return candidate;
|
|
366
|
+
}
|
|
367
|
+
throw new ZapierCliValidationError(
|
|
368
|
+
`Could not find an available credential name for "${baseName}" after ${MAX_CREDENTIAL_NAME_ATTEMPTS} attempts.`
|
|
369
|
+
);
|
|
370
|
+
}
|
|
371
|
+
function resolveAvailableCredentialName({
|
|
372
|
+
baseName,
|
|
373
|
+
baseUrl
|
|
374
|
+
}) {
|
|
375
|
+
const resolvedBaseUrl = normalizeBaseUrl(baseUrl);
|
|
376
|
+
const taken = new Set(
|
|
377
|
+
readRegistry().filter((e) => e.baseUrl === resolvedBaseUrl).map((e) => e.name)
|
|
378
|
+
);
|
|
379
|
+
return firstAvailableCredentialName({ baseName, taken });
|
|
380
|
+
}
|
|
329
381
|
async function storeClientCredentials({
|
|
330
382
|
name,
|
|
331
383
|
clientId,
|
|
@@ -892,32 +944,6 @@ async function resolveCredentialsBaseUrl(context) {
|
|
|
892
944
|
function resolveNonInteractive(options) {
|
|
893
945
|
return options.nonInteractive === true || options.skipPrompts === true || !process.stdin.isTTY || !process.stdout.isTTY;
|
|
894
946
|
}
|
|
895
|
-
var ZapierCliError = class extends ZapierError {
|
|
896
|
-
};
|
|
897
|
-
var ZapierCliUserCancellationError = class extends ZapierCliError {
|
|
898
|
-
constructor(message = "Operation cancelled by user") {
|
|
899
|
-
super(message);
|
|
900
|
-
this.name = "ZapierCliUserCancellationError";
|
|
901
|
-
this.code = "ZAPIER_CLI_USER_CANCELLATION";
|
|
902
|
-
this.exitCode = 0;
|
|
903
|
-
}
|
|
904
|
-
};
|
|
905
|
-
var ZapierCliExitError = class extends ZapierCliError {
|
|
906
|
-
constructor(message, exitCode = 1) {
|
|
907
|
-
super(message);
|
|
908
|
-
this.name = "ZapierCliExitError";
|
|
909
|
-
this.code = "ZAPIER_CLI_EXIT";
|
|
910
|
-
this.exitCode = exitCode;
|
|
911
|
-
}
|
|
912
|
-
};
|
|
913
|
-
var ZapierCliValidationError = class extends ZapierCliError {
|
|
914
|
-
constructor(message) {
|
|
915
|
-
super(message);
|
|
916
|
-
this.name = "ZapierCliValidationError";
|
|
917
|
-
this.code = "ZAPIER_CLI_VALIDATION_ERROR";
|
|
918
|
-
this.exitCode = 1;
|
|
919
|
-
}
|
|
920
|
-
};
|
|
921
947
|
|
|
922
948
|
// src/utils/auth/client-credentials.ts
|
|
923
949
|
var CREDENTIALS_SCOPES = ["external", "credentials"];
|
|
@@ -1879,11 +1905,11 @@ async function runAccountAuth({
|
|
|
1879
1905
|
console.log(
|
|
1880
1906
|
"\nGenerating credentials so this machine can make authenticated requests on your behalf."
|
|
1881
1907
|
);
|
|
1882
|
-
const
|
|
1883
|
-
email,
|
|
1908
|
+
const baseName = interactive ? await promptCredentialsName({
|
|
1909
|
+
email: profile.email,
|
|
1884
1910
|
promptMessage: getCredentialsPromptMessage(entryPoint)
|
|
1885
|
-
}) : resolveDefaultCredentialsName;
|
|
1886
|
-
const credentialName =
|
|
1911
|
+
}) : resolveDefaultCredentialsName({ email: profile.email });
|
|
1912
|
+
const credentialName = interactive ? baseName : resolveAvailableCredentialName({ baseName, baseUrl: credentialsBaseUrl });
|
|
1887
1913
|
const useApprovals = options.useApprovals === true;
|
|
1888
1914
|
await saveClientCredentials({
|
|
1889
1915
|
api: scopedApi,
|
|
@@ -4489,7 +4515,7 @@ var watchTriggerInboxCliPlugin = definePlugin(
|
|
|
4489
4515
|
// package.json with { type: 'json' }
|
|
4490
4516
|
var package_default = {
|
|
4491
4517
|
name: "@zapier/zapier-sdk-cli",
|
|
4492
|
-
version: "0.55.
|
|
4518
|
+
version: "0.55.4"};
|
|
4493
4519
|
|
|
4494
4520
|
// src/experimental.ts
|
|
4495
4521
|
injectCliLogin(login_exports);
|
package/dist/index.cjs
CHANGED
|
@@ -325,6 +325,34 @@ function createCache() {
|
|
|
325
325
|
}
|
|
326
326
|
};
|
|
327
327
|
}
|
|
328
|
+
var ZapierCliError = class extends zapierSdk.ZapierError {
|
|
329
|
+
};
|
|
330
|
+
var ZapierCliUserCancellationError = class extends ZapierCliError {
|
|
331
|
+
constructor(message = "Operation cancelled by user") {
|
|
332
|
+
super(message);
|
|
333
|
+
this.name = "ZapierCliUserCancellationError";
|
|
334
|
+
this.code = "ZAPIER_CLI_USER_CANCELLATION";
|
|
335
|
+
this.exitCode = 0;
|
|
336
|
+
}
|
|
337
|
+
};
|
|
338
|
+
var ZapierCliExitError = class extends ZapierCliError {
|
|
339
|
+
constructor(message, exitCode = 1) {
|
|
340
|
+
super(message);
|
|
341
|
+
this.name = "ZapierCliExitError";
|
|
342
|
+
this.code = "ZAPIER_CLI_EXIT";
|
|
343
|
+
this.exitCode = exitCode;
|
|
344
|
+
}
|
|
345
|
+
};
|
|
346
|
+
var ZapierCliValidationError = class extends ZapierCliError {
|
|
347
|
+
constructor(message) {
|
|
348
|
+
super(message);
|
|
349
|
+
this.name = "ZapierCliValidationError";
|
|
350
|
+
this.code = "ZAPIER_CLI_VALIDATION_ERROR";
|
|
351
|
+
this.exitCode = 1;
|
|
352
|
+
}
|
|
353
|
+
};
|
|
354
|
+
|
|
355
|
+
// src/login/credentials-store.ts
|
|
328
356
|
var SERVICE3 = "zapier-sdk-cli";
|
|
329
357
|
var CREDENTIALS_KEY = "credentials";
|
|
330
358
|
var REGISTRY_KEY = "credentialsRegistry";
|
|
@@ -361,6 +389,30 @@ function getActiveCredentials(options) {
|
|
|
361
389
|
if (!name) return void 0;
|
|
362
390
|
return findEntry(readRegistry(), name, normalizeBaseUrl(options?.baseUrl));
|
|
363
391
|
}
|
|
392
|
+
var MAX_CREDENTIAL_NAME_ATTEMPTS = 500;
|
|
393
|
+
function firstAvailableCredentialName({
|
|
394
|
+
baseName,
|
|
395
|
+
taken
|
|
396
|
+
}) {
|
|
397
|
+
if (!taken.has(baseName)) return baseName;
|
|
398
|
+
for (let i = 1; i <= MAX_CREDENTIAL_NAME_ATTEMPTS; i++) {
|
|
399
|
+
const candidate = `${baseName}-${i}`;
|
|
400
|
+
if (!taken.has(candidate)) return candidate;
|
|
401
|
+
}
|
|
402
|
+
throw new ZapierCliValidationError(
|
|
403
|
+
`Could not find an available credential name for "${baseName}" after ${MAX_CREDENTIAL_NAME_ATTEMPTS} attempts.`
|
|
404
|
+
);
|
|
405
|
+
}
|
|
406
|
+
function resolveAvailableCredentialName({
|
|
407
|
+
baseName,
|
|
408
|
+
baseUrl
|
|
409
|
+
}) {
|
|
410
|
+
const resolvedBaseUrl = normalizeBaseUrl(baseUrl);
|
|
411
|
+
const taken = new Set(
|
|
412
|
+
readRegistry().filter((e) => e.baseUrl === resolvedBaseUrl).map((e) => e.name)
|
|
413
|
+
);
|
|
414
|
+
return firstAvailableCredentialName({ baseName, taken });
|
|
415
|
+
}
|
|
364
416
|
async function storeClientCredentials({
|
|
365
417
|
name,
|
|
366
418
|
clientId,
|
|
@@ -927,32 +979,6 @@ async function resolveCredentialsBaseUrl(context) {
|
|
|
927
979
|
function resolveNonInteractive(options) {
|
|
928
980
|
return options.nonInteractive === true || options.skipPrompts === true || !process.stdin.isTTY || !process.stdout.isTTY;
|
|
929
981
|
}
|
|
930
|
-
var ZapierCliError = class extends zapierSdk.ZapierError {
|
|
931
|
-
};
|
|
932
|
-
var ZapierCliUserCancellationError = class extends ZapierCliError {
|
|
933
|
-
constructor(message = "Operation cancelled by user") {
|
|
934
|
-
super(message);
|
|
935
|
-
this.name = "ZapierCliUserCancellationError";
|
|
936
|
-
this.code = "ZAPIER_CLI_USER_CANCELLATION";
|
|
937
|
-
this.exitCode = 0;
|
|
938
|
-
}
|
|
939
|
-
};
|
|
940
|
-
var ZapierCliExitError = class extends ZapierCliError {
|
|
941
|
-
constructor(message, exitCode = 1) {
|
|
942
|
-
super(message);
|
|
943
|
-
this.name = "ZapierCliExitError";
|
|
944
|
-
this.code = "ZAPIER_CLI_EXIT";
|
|
945
|
-
this.exitCode = exitCode;
|
|
946
|
-
}
|
|
947
|
-
};
|
|
948
|
-
var ZapierCliValidationError = class extends ZapierCliError {
|
|
949
|
-
constructor(message) {
|
|
950
|
-
super(message);
|
|
951
|
-
this.name = "ZapierCliValidationError";
|
|
952
|
-
this.code = "ZAPIER_CLI_VALIDATION_ERROR";
|
|
953
|
-
this.exitCode = 1;
|
|
954
|
-
}
|
|
955
|
-
};
|
|
956
982
|
|
|
957
983
|
// src/utils/auth/client-credentials.ts
|
|
958
984
|
var CREDENTIALS_SCOPES = ["external", "credentials"];
|
|
@@ -1914,11 +1940,11 @@ async function runAccountAuth({
|
|
|
1914
1940
|
console.log(
|
|
1915
1941
|
"\nGenerating credentials so this machine can make authenticated requests on your behalf."
|
|
1916
1942
|
);
|
|
1917
|
-
const
|
|
1918
|
-
email,
|
|
1943
|
+
const baseName = interactive ? await promptCredentialsName({
|
|
1944
|
+
email: profile.email,
|
|
1919
1945
|
promptMessage: getCredentialsPromptMessage(entryPoint)
|
|
1920
|
-
}) : resolveDefaultCredentialsName;
|
|
1921
|
-
const credentialName =
|
|
1946
|
+
}) : resolveDefaultCredentialsName({ email: profile.email });
|
|
1947
|
+
const credentialName = interactive ? baseName : resolveAvailableCredentialName({ baseName, baseUrl: credentialsBaseUrl });
|
|
1922
1948
|
const useApprovals = options.useApprovals === true;
|
|
1923
1949
|
await saveClientCredentials({
|
|
1924
1950
|
api: scopedApi,
|
|
@@ -4524,7 +4550,7 @@ zapierSdk.definePlugin(
|
|
|
4524
4550
|
// package.json with { type: 'json' }
|
|
4525
4551
|
var package_default = {
|
|
4526
4552
|
name: "@zapier/zapier-sdk-cli",
|
|
4527
|
-
version: "0.55.
|
|
4553
|
+
version: "0.55.4"};
|
|
4528
4554
|
|
|
4529
4555
|
// src/sdk.ts
|
|
4530
4556
|
zapierSdk.injectCliLogin(login_exports);
|
|
@@ -4552,7 +4578,7 @@ function createZapierCliSdk(options = {}) {
|
|
|
4552
4578
|
|
|
4553
4579
|
// package.json
|
|
4554
4580
|
var package_default2 = {
|
|
4555
|
-
version: "0.55.
|
|
4581
|
+
version: "0.55.4"};
|
|
4556
4582
|
|
|
4557
4583
|
// src/telemetry/builders.ts
|
|
4558
4584
|
function createCliBaseEvent(context = {}) {
|
|
@@ -4596,6 +4622,8 @@ function buildCliCommandExecutedEvent({
|
|
|
4596
4622
|
requires_auth: data.requires_auth ?? null,
|
|
4597
4623
|
is_ci_environment: zapierSdk.isCi(),
|
|
4598
4624
|
ci_platform: zapierSdk.getCiPlatform(),
|
|
4625
|
+
...zapierSdk.getTtyContext(),
|
|
4626
|
+
agent: zapierSdk.getAgent(),
|
|
4599
4627
|
package_manager: data.package_manager ?? "pnpm",
|
|
4600
4628
|
// Default based on project setup
|
|
4601
4629
|
made_network_requests: data.made_network_requests ?? null,
|
package/dist/index.d.mts
CHANGED
|
@@ -54,6 +54,9 @@ interface CliCommandExecutedEvent extends BaseEvent {
|
|
|
54
54
|
peak_memory_usage_bytes?: number | null;
|
|
55
55
|
cpu_time_ms?: number | null;
|
|
56
56
|
subprocess_count?: number | null;
|
|
57
|
+
stdin_is_tty?: boolean | null;
|
|
58
|
+
stdout_is_tty?: boolean | null;
|
|
59
|
+
agent?: string | null;
|
|
57
60
|
}
|
|
58
61
|
|
|
59
62
|
/**
|
package/dist/index.d.ts
CHANGED
|
@@ -54,6 +54,9 @@ interface CliCommandExecutedEvent extends BaseEvent {
|
|
|
54
54
|
peak_memory_usage_bytes?: number | null;
|
|
55
55
|
cpu_time_ms?: number | null;
|
|
56
56
|
subprocess_count?: number | null;
|
|
57
|
+
stdin_is_tty?: boolean | null;
|
|
58
|
+
stdout_is_tty?: boolean | null;
|
|
59
|
+
agent?: string | null;
|
|
57
60
|
}
|
|
58
61
|
|
|
59
62
|
/**
|