@dereekb/dbx-cli 13.11.2 → 13.11.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/firebase-api-manifest/package.json +1 -1
- package/index.cjs.js +42 -2
- package/index.esm.js +43 -3
- package/manifest-extract/package.json +1 -1
- package/package.json +5 -4
- package/src/lib/api/call-model.command.factory.d.ts +1 -0
- package/src/lib/auth/auth.command.factory.d.ts +1 -0
- package/src/lib/auth/oidc.flow.d.ts +8 -0
- package/src/lib/config/paths.d.ts +1 -0
- package/src/lib/config/token.cache.d.ts +1 -0
- package/src/lib/context/cli.context.d.ts +1 -0
- package/src/lib/doctor/doctor.command.factory.d.ts +1 -0
- package/src/lib/env/env.command.factory.d.ts +1 -0
- package/src/lib/manifest/build-manifest-commands.d.ts +1 -0
- package/src/lib/middleware/auth.middleware.d.ts +1 -0
- package/src/lib/middleware/output.middleware.d.ts +1 -0
- package/src/lib/output/output.command.factory.d.ts +1 -0
- package/src/lib/runner/run.d.ts +1 -0
- package/src/lib/util/context.slot.d.ts +1 -0
- package/src/lib/util/output.d.ts +2 -0
package/index.cjs.js
CHANGED
|
@@ -4,6 +4,7 @@ var node_fs = require('node:fs');
|
|
|
4
4
|
var node_path = require('node:path');
|
|
5
5
|
var firebase = require('@dereekb/firebase');
|
|
6
6
|
var util = require('@dereekb/util');
|
|
7
|
+
var date = require('@dereekb/date');
|
|
7
8
|
var nestjs = require('@dereekb/nestjs');
|
|
8
9
|
var node_os = require('node:os');
|
|
9
10
|
var node_readline = require('node:readline');
|
|
@@ -274,6 +275,7 @@ var _errorMapper;
|
|
|
274
275
|
* @param extension - File extension to append (`json` for full responses, `ndjson` for streaming dumps).
|
|
275
276
|
* @param suffix - Optional suffix appended to the filename before the extension.
|
|
276
277
|
* @returns The absolute file path, or `undefined` when `dumpDir` is not configured.
|
|
278
|
+
* @__NO_SIDE_EFFECTS__
|
|
277
279
|
*/ function buildDumpFilePath(extension, suffix) {
|
|
278
280
|
var dumpDir = _outputOptions.dumpDir, commandPath = _outputOptions.commandPath;
|
|
279
281
|
if (!dumpDir) {
|
|
@@ -410,6 +412,7 @@ function pickFromObject(obj, fields) {
|
|
|
410
412
|
*
|
|
411
413
|
* @param error - The thrown value to convert.
|
|
412
414
|
* @returns The structured {@link CliErrorOutput}.
|
|
415
|
+
* @__NO_SIDE_EFFECTS__
|
|
413
416
|
*/ function buildErrorOutput(error) {
|
|
414
417
|
if (_errorMapper) {
|
|
415
418
|
var mapped = _errorMapper(error);
|
|
@@ -671,6 +674,7 @@ function trimSlash$1(url) {
|
|
|
671
674
|
* @param input - Optional slot configuration.
|
|
672
675
|
* @param input.notInitializedMessage - Custom error message thrown by `require()` when the slot is unset.
|
|
673
676
|
* @returns A new {@link ContextSlot} for type `T`.
|
|
677
|
+
* @__NO_SIDE_EFFECTS__
|
|
674
678
|
*/ function createContextSlot(input) {
|
|
675
679
|
var _ref;
|
|
676
680
|
var _value;
|
|
@@ -715,6 +719,7 @@ var getCliContext = _cliContextSlot.get;
|
|
|
715
719
|
* @param input.env - The resolved {@link CliEnvConfig} for the active env.
|
|
716
720
|
* @param input.accessToken - The Bearer access token to include on outgoing API calls.
|
|
717
721
|
* @returns The constructed {@link CliContext}.
|
|
722
|
+
* @__NO_SIDE_EFFECTS__
|
|
718
723
|
*/ function createCliContext(input) {
|
|
719
724
|
return {
|
|
720
725
|
cliName: input.cliName,
|
|
@@ -914,6 +919,7 @@ function _ts_generator$e(thisArg, body) {
|
|
|
914
919
|
*
|
|
915
920
|
* @param spec - The command spec describing the yargs command surface plus how to map argv into the typed call params and the result.
|
|
916
921
|
* @returns A yargs `CommandModule` whose handler runs the spec against the active CLI context.
|
|
922
|
+
* @__NO_SIDE_EFFECTS__
|
|
917
923
|
*/ function createCallModelCommand(spec) {
|
|
918
924
|
return {
|
|
919
925
|
command: spec.command,
|
|
@@ -1788,6 +1794,7 @@ function nonEmpty(value) {
|
|
|
1788
1794
|
* @param config.cliName - The CLI's binary name; the default config dir is `~/.<cliName>`.
|
|
1789
1795
|
* @param config.configDirOverride - Optional override that replaces the default config directory verbatim (used by tests).
|
|
1790
1796
|
* @returns The {@link CliPaths} pointing at `configDir`, the config file, and the token cache file.
|
|
1797
|
+
* @__NO_SIDE_EFFECTS__
|
|
1791
1798
|
*/ function buildCliPaths(config) {
|
|
1792
1799
|
var _config_configDirOverride;
|
|
1793
1800
|
var configDir = (_config_configDirOverride = config.configDirOverride) !== null && _config_configDirOverride !== void 0 ? _config_configDirOverride : node_path.join(node_os.homedir(), ".".concat(config.cliName));
|
|
@@ -1807,6 +1814,7 @@ function nonEmpty(value) {
|
|
|
1807
1814
|
* @param input - The cache store inputs.
|
|
1808
1815
|
* @param input.tokenCachePath - Absolute path to the JSON file backing the cache.
|
|
1809
1816
|
* @returns A {@link CliTokenCacheStore} keyed by env name.
|
|
1817
|
+
* @__NO_SIDE_EFFECTS__
|
|
1810
1818
|
*/ function createCliTokenCacheStore(input) {
|
|
1811
1819
|
return nestjs.createMemoizedJsonFileAsyncKeyedValueCache({
|
|
1812
1820
|
filePath: input.tokenCachePath
|
|
@@ -2534,6 +2542,7 @@ function _ts_generator$a(thisArg, body) {
|
|
|
2534
2542
|
* @param input.state - The opaque OAuth state token used for CSRF protection.
|
|
2535
2543
|
* @param input.codeChallenge - The PKCE code challenge derived from the verifier.
|
|
2536
2544
|
* @returns The full authorization URL with all OAuth params merged in.
|
|
2545
|
+
* @__NO_SIDE_EFFECTS__
|
|
2537
2546
|
*/ function buildAuthorizationUrl(input) {
|
|
2538
2547
|
var _input_scopes;
|
|
2539
2548
|
var authParams = {
|
|
@@ -2545,6 +2554,15 @@ function _ts_generator$a(thisArg, body) {
|
|
|
2545
2554
|
code_challenge_method: 'S256',
|
|
2546
2555
|
state: input.state
|
|
2547
2556
|
};
|
|
2557
|
+
if (input.requestedSessionTtlSeconds != null) {
|
|
2558
|
+
if (!Number.isInteger(input.requestedSessionTtlSeconds) || input.requestedSessionTtlSeconds <= 0) {
|
|
2559
|
+
throw new CliError({
|
|
2560
|
+
message: "requestedSessionTtlSeconds must be a positive integer (got ".concat(input.requestedSessionTtlSeconds, ")."),
|
|
2561
|
+
code: 'AUTH_LOGIN_FOR_INVALID'
|
|
2562
|
+
});
|
|
2563
|
+
}
|
|
2564
|
+
authParams.dbx_session_ttl = String(input.requestedSessionTtlSeconds);
|
|
2565
|
+
}
|
|
2548
2566
|
var endpoint;
|
|
2549
2567
|
if (input.appClientUrl) {
|
|
2550
2568
|
endpoint = rebaseUrlOrigin({
|
|
@@ -3066,6 +3084,7 @@ function maskEnv$1(env) {
|
|
|
3066
3084
|
* @param input.envVarName - Override for the env-name env var. Defaults to `<CLINAME>_ENV` (e.g. `DEMO_CLI_ENV`).
|
|
3067
3085
|
* @param input.defaultEnvs - Built-in env presets merged underneath the user's stored env when names match.
|
|
3068
3086
|
* @returns A yargs `CommandModule` exposing the full `auth` subcommand surface.
|
|
3087
|
+
* @__NO_SIDE_EFFECTS__
|
|
3069
3088
|
*/ function createAuthCommand(input) {
|
|
3070
3089
|
var _input_envVarName;
|
|
3071
3090
|
var cliName = input.cliName;
|
|
@@ -3323,11 +3342,14 @@ function maskEnv$1(env) {
|
|
|
3323
3342
|
type: 'boolean',
|
|
3324
3343
|
default: false,
|
|
3325
3344
|
describe: 'Drop model.create/model.update/model.delete from the requested scopes (keeps model.read and model.query)'
|
|
3345
|
+
}).option('login-for', {
|
|
3346
|
+
type: 'string',
|
|
3347
|
+
describe: 'Requested login duration with a unit (e.g. 30d, 12h, 3600s). Mixed units are allowed (e.g. "1h30m", "2d 12h"). Subject to server/client caps. Applied to Session, Grant, and RefreshToken.'
|
|
3326
3348
|
});
|
|
3327
3349
|
},
|
|
3328
3350
|
handler: function handler(argv) {
|
|
3329
3351
|
return _async_to_generator$9(function() {
|
|
3330
|
-
var _argv_code, _tokenResponse_expires_in, _ref, envName, env, meta, _ref1, codeVerifier, codeChallenge, state, requestedScopes, url, pasted, _tmp, code, tokenResponse, expiresAt, entry, e;
|
|
3352
|
+
var _argv_code, _tokenResponse_expires_in, _ref, envName, env, meta, _ref1, codeVerifier, codeChallenge, state, requestedScopes, requestedSessionTtlSeconds, ms, url, pasted, _tmp, code, tokenResponse, expiresAt, entry, e;
|
|
3331
3353
|
return _ts_generator$9(this, function(_state) {
|
|
3332
3354
|
switch(_state.label){
|
|
3333
3355
|
case 0:
|
|
@@ -3372,6 +3394,16 @@ function maskEnv$1(env) {
|
|
|
3372
3394
|
_ref1 = _state.sent(), codeVerifier = _ref1.codeVerifier, codeChallenge = _ref1.codeChallenge;
|
|
3373
3395
|
state = generateOAuthState();
|
|
3374
3396
|
requestedScopes = argv.readOnlyScopes ? filterReadOnlyModelScopes(env.scopes) : env.scopes;
|
|
3397
|
+
if (argv.loginFor) {
|
|
3398
|
+
ms = date.durationDataToMilliseconds(date.parseDurationString(argv.loginFor));
|
|
3399
|
+
if (ms <= 0) {
|
|
3400
|
+
throw new CliError({
|
|
3401
|
+
message: '--login-for: invalid duration "'.concat(argv.loginFor, '". Use formats like "30d", "12h", "3600s", or mixed units like "1h30m" or "2d 12h".'),
|
|
3402
|
+
code: 'AUTH_LOGIN_FOR_INVALID'
|
|
3403
|
+
});
|
|
3404
|
+
}
|
|
3405
|
+
requestedSessionTtlSeconds = Math.floor(ms / util.MS_IN_SECOND);
|
|
3406
|
+
}
|
|
3375
3407
|
url = buildAuthorizationUrl({
|
|
3376
3408
|
authorizationEndpoint: meta.authorization_endpoint,
|
|
3377
3409
|
apiBaseUrl: env.apiBaseUrl,
|
|
@@ -3380,7 +3412,8 @@ function maskEnv$1(env) {
|
|
|
3380
3412
|
redirectUri: env.redirectUri,
|
|
3381
3413
|
scopes: requestedScopes,
|
|
3382
3414
|
state: state,
|
|
3383
|
-
codeChallenge: codeChallenge
|
|
3415
|
+
codeChallenge: codeChallenge,
|
|
3416
|
+
requestedSessionTtlSeconds: requestedSessionTtlSeconds
|
|
3384
3417
|
});
|
|
3385
3418
|
// The CLI never opens a browser itself — it prints the URL and reads the redirect back.
|
|
3386
3419
|
// Emit the URL through a clearly-prefixed stderr line so JSON stdout stays parseable.
|
|
@@ -4413,6 +4446,7 @@ function _ts_generator$8(thisArg, body) {
|
|
|
4413
4446
|
* @param input.checks - Additional checks to append after the default check list.
|
|
4414
4447
|
* @param input.defaultEnvs - Built-in env presets merged underneath the user's stored env when names match.
|
|
4415
4448
|
* @returns A yargs `CommandModule` exposing the `doctor` command.
|
|
4449
|
+
* @__NO_SIDE_EFFECTS__
|
|
4416
4450
|
*/ function createDoctorCommand(input) {
|
|
4417
4451
|
var _input_checks;
|
|
4418
4452
|
var cliName = input.cliName;
|
|
@@ -4851,6 +4885,7 @@ function resolveEnvWithDefault(input) {
|
|
|
4851
4885
|
* @param input.cliName - The CLI's binary name.
|
|
4852
4886
|
* @param input.defaultEnvs - Built-in env presets merged underneath the user's stored env when names match.
|
|
4853
4887
|
* @returns A yargs `CommandModule` exposing the full `env` subcommand surface.
|
|
4888
|
+
* @__NO_SIDE_EFFECTS__
|
|
4854
4889
|
*/ function createEnvCommand(input) {
|
|
4855
4890
|
var paths = buildCliPaths({
|
|
4856
4891
|
cliName: input.cliName
|
|
@@ -5466,6 +5501,7 @@ function _ts_generator$6(thisArg, body) {
|
|
|
5466
5501
|
* @param input.skipCommands - Top-level command names that bypass authentication entirely.
|
|
5467
5502
|
* @param input.defaultEnvs - Built-in env presets merged underneath the user's stored env when names match.
|
|
5468
5503
|
* @returns A yargs middleware function suitable for `.middleware([..., true])`.
|
|
5504
|
+
* @__NO_SIDE_EFFECTS__
|
|
5469
5505
|
*/ function createAuthMiddleware(input) {
|
|
5470
5506
|
var paths = buildCliPaths({
|
|
5471
5507
|
cliName: input.cliName
|
|
@@ -5784,6 +5820,7 @@ function _ts_generator$5(thisArg, body) {
|
|
|
5784
5820
|
* @param input.loadOutputConfig - Optional override for how the output config is read.
|
|
5785
5821
|
* @param input.saveCommandOutputConfig - Optional override for how a per-command output config is persisted.
|
|
5786
5822
|
* @returns A yargs middleware function suitable for `.middleware([..., true])`.
|
|
5823
|
+
* @__NO_SIDE_EFFECTS__
|
|
5787
5824
|
*/ function createOutputMiddleware(input) {
|
|
5788
5825
|
var _input_loadOutputConfig, _input_saveCommandOutputConfig;
|
|
5789
5826
|
var paths = buildCliPaths({
|
|
@@ -6343,6 +6380,7 @@ function resolveCallbacks(input) {
|
|
|
6343
6380
|
* @param input.mergeOutputConfig - Optional override for persisting partial output-config updates.
|
|
6344
6381
|
* @param input.clearOutputConfig - Optional override for clearing the persisted output config entirely.
|
|
6345
6382
|
* @returns A yargs `CommandModule` exposing the full `output` subcommand surface.
|
|
6383
|
+
* @__NO_SIDE_EFFECTS__
|
|
6346
6384
|
*/ function createOutputCommand(input) {
|
|
6347
6385
|
var callbacks = resolveCallbacks(input);
|
|
6348
6386
|
var setCommand = {
|
|
@@ -6704,6 +6742,7 @@ function _ts_generator$2(thisArg, body) {
|
|
|
6704
6742
|
* @param input.argv - Argv to parse. Defaults to `hideBin(process.argv)`.
|
|
6705
6743
|
* @param input.disableCallPassthrough - When `true`, omits the built-in `call` passthrough.
|
|
6706
6744
|
* @returns The configured yargs `Argv` ready to be `.parse()`-d.
|
|
6745
|
+
* @__NO_SIDE_EFFECTS__
|
|
6707
6746
|
*/ function createCli(input) {
|
|
6708
6747
|
var _input_configCommands, _input_apiCommands, _input_argv;
|
|
6709
6748
|
var cliName = input.cliName;
|
|
@@ -7133,6 +7172,7 @@ var DATA_HELP_FLAG = '--data-help';
|
|
|
7133
7172
|
* @param options - Optional overrides; see {@link BuildManifestCommandsOptions}.
|
|
7134
7173
|
* @returns The yargs `CommandModule[]` ready to be passed to `runCli({ apiCommands })`. Empty
|
|
7135
7174
|
* when the manifest has no callable entries.
|
|
7175
|
+
* @__NO_SIDE_EFFECTS__
|
|
7136
7176
|
*/ function buildManifestCommands(manifest, options) {
|
|
7137
7177
|
var _ref, _ref1, _ref2, _ref3, _ref4, _ref5;
|
|
7138
7178
|
var callable = manifest.filter(function(e) {
|
package/index.esm.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { existsSync, mkdirSync, writeFileSync, appendFileSync } from 'node:fs';
|
|
2
2
|
import { join } from 'node:path';
|
|
3
3
|
export { CALL_MODEL_APP_FUNCTION_KEY } from '@dereekb/firebase';
|
|
4
|
-
import { expirationDetails, generatePkceCodeVerifier, generatePkceCodeChallenge, noop } from '@dereekb/util';
|
|
4
|
+
import { expirationDetails, generatePkceCodeVerifier, generatePkceCodeChallenge, noop, MS_IN_SECOND } from '@dereekb/util';
|
|
5
|
+
import { durationDataToMilliseconds, parseDurationString } from '@dereekb/date';
|
|
5
6
|
import { readJsonFile, writeJsonFile, createMemoizedJsonFileAsyncKeyedValueCache } from '@dereekb/nestjs';
|
|
6
7
|
import { homedir } from 'node:os';
|
|
7
8
|
import { createInterface } from 'node:readline';
|
|
@@ -272,6 +273,7 @@ var _errorMapper;
|
|
|
272
273
|
* @param extension - File extension to append (`json` for full responses, `ndjson` for streaming dumps).
|
|
273
274
|
* @param suffix - Optional suffix appended to the filename before the extension.
|
|
274
275
|
* @returns The absolute file path, or `undefined` when `dumpDir` is not configured.
|
|
276
|
+
* @__NO_SIDE_EFFECTS__
|
|
275
277
|
*/ function buildDumpFilePath(extension, suffix) {
|
|
276
278
|
var dumpDir = _outputOptions.dumpDir, commandPath = _outputOptions.commandPath;
|
|
277
279
|
if (!dumpDir) {
|
|
@@ -408,6 +410,7 @@ function pickFromObject(obj, fields) {
|
|
|
408
410
|
*
|
|
409
411
|
* @param error - The thrown value to convert.
|
|
410
412
|
* @returns The structured {@link CliErrorOutput}.
|
|
413
|
+
* @__NO_SIDE_EFFECTS__
|
|
411
414
|
*/ function buildErrorOutput(error) {
|
|
412
415
|
if (_errorMapper) {
|
|
413
416
|
var mapped = _errorMapper(error);
|
|
@@ -669,6 +672,7 @@ function trimSlash$1(url) {
|
|
|
669
672
|
* @param input - Optional slot configuration.
|
|
670
673
|
* @param input.notInitializedMessage - Custom error message thrown by `require()` when the slot is unset.
|
|
671
674
|
* @returns A new {@link ContextSlot} for type `T`.
|
|
675
|
+
* @__NO_SIDE_EFFECTS__
|
|
672
676
|
*/ function createContextSlot(input) {
|
|
673
677
|
var _ref;
|
|
674
678
|
var _value;
|
|
@@ -713,6 +717,7 @@ var getCliContext = _cliContextSlot.get;
|
|
|
713
717
|
* @param input.env - The resolved {@link CliEnvConfig} for the active env.
|
|
714
718
|
* @param input.accessToken - The Bearer access token to include on outgoing API calls.
|
|
715
719
|
* @returns The constructed {@link CliContext}.
|
|
720
|
+
* @__NO_SIDE_EFFECTS__
|
|
716
721
|
*/ function createCliContext(input) {
|
|
717
722
|
return {
|
|
718
723
|
cliName: input.cliName,
|
|
@@ -912,6 +917,7 @@ function _ts_generator$e(thisArg, body) {
|
|
|
912
917
|
*
|
|
913
918
|
* @param spec - The command spec describing the yargs command surface plus how to map argv into the typed call params and the result.
|
|
914
919
|
* @returns A yargs `CommandModule` whose handler runs the spec against the active CLI context.
|
|
920
|
+
* @__NO_SIDE_EFFECTS__
|
|
915
921
|
*/ function createCallModelCommand(spec) {
|
|
916
922
|
return {
|
|
917
923
|
command: spec.command,
|
|
@@ -1786,6 +1792,7 @@ function nonEmpty(value) {
|
|
|
1786
1792
|
* @param config.cliName - The CLI's binary name; the default config dir is `~/.<cliName>`.
|
|
1787
1793
|
* @param config.configDirOverride - Optional override that replaces the default config directory verbatim (used by tests).
|
|
1788
1794
|
* @returns The {@link CliPaths} pointing at `configDir`, the config file, and the token cache file.
|
|
1795
|
+
* @__NO_SIDE_EFFECTS__
|
|
1789
1796
|
*/ function buildCliPaths(config) {
|
|
1790
1797
|
var _config_configDirOverride;
|
|
1791
1798
|
var configDir = (_config_configDirOverride = config.configDirOverride) !== null && _config_configDirOverride !== void 0 ? _config_configDirOverride : join(homedir(), ".".concat(config.cliName));
|
|
@@ -1805,6 +1812,7 @@ function nonEmpty(value) {
|
|
|
1805
1812
|
* @param input - The cache store inputs.
|
|
1806
1813
|
* @param input.tokenCachePath - Absolute path to the JSON file backing the cache.
|
|
1807
1814
|
* @returns A {@link CliTokenCacheStore} keyed by env name.
|
|
1815
|
+
* @__NO_SIDE_EFFECTS__
|
|
1808
1816
|
*/ function createCliTokenCacheStore(input) {
|
|
1809
1817
|
return createMemoizedJsonFileAsyncKeyedValueCache({
|
|
1810
1818
|
filePath: input.tokenCachePath
|
|
@@ -2532,6 +2540,7 @@ function _ts_generator$a(thisArg, body) {
|
|
|
2532
2540
|
* @param input.state - The opaque OAuth state token used for CSRF protection.
|
|
2533
2541
|
* @param input.codeChallenge - The PKCE code challenge derived from the verifier.
|
|
2534
2542
|
* @returns The full authorization URL with all OAuth params merged in.
|
|
2543
|
+
* @__NO_SIDE_EFFECTS__
|
|
2535
2544
|
*/ function buildAuthorizationUrl(input) {
|
|
2536
2545
|
var _input_scopes;
|
|
2537
2546
|
var authParams = {
|
|
@@ -2543,6 +2552,15 @@ function _ts_generator$a(thisArg, body) {
|
|
|
2543
2552
|
code_challenge_method: 'S256',
|
|
2544
2553
|
state: input.state
|
|
2545
2554
|
};
|
|
2555
|
+
if (input.requestedSessionTtlSeconds != null) {
|
|
2556
|
+
if (!Number.isInteger(input.requestedSessionTtlSeconds) || input.requestedSessionTtlSeconds <= 0) {
|
|
2557
|
+
throw new CliError({
|
|
2558
|
+
message: "requestedSessionTtlSeconds must be a positive integer (got ".concat(input.requestedSessionTtlSeconds, ")."),
|
|
2559
|
+
code: 'AUTH_LOGIN_FOR_INVALID'
|
|
2560
|
+
});
|
|
2561
|
+
}
|
|
2562
|
+
authParams.dbx_session_ttl = String(input.requestedSessionTtlSeconds);
|
|
2563
|
+
}
|
|
2546
2564
|
var endpoint;
|
|
2547
2565
|
if (input.appClientUrl) {
|
|
2548
2566
|
endpoint = rebaseUrlOrigin({
|
|
@@ -3064,6 +3082,7 @@ function maskEnv$1(env) {
|
|
|
3064
3082
|
* @param input.envVarName - Override for the env-name env var. Defaults to `<CLINAME>_ENV` (e.g. `DEMO_CLI_ENV`).
|
|
3065
3083
|
* @param input.defaultEnvs - Built-in env presets merged underneath the user's stored env when names match.
|
|
3066
3084
|
* @returns A yargs `CommandModule` exposing the full `auth` subcommand surface.
|
|
3085
|
+
* @__NO_SIDE_EFFECTS__
|
|
3067
3086
|
*/ function createAuthCommand(input) {
|
|
3068
3087
|
var _input_envVarName;
|
|
3069
3088
|
var cliName = input.cliName;
|
|
@@ -3321,11 +3340,14 @@ function maskEnv$1(env) {
|
|
|
3321
3340
|
type: 'boolean',
|
|
3322
3341
|
default: false,
|
|
3323
3342
|
describe: 'Drop model.create/model.update/model.delete from the requested scopes (keeps model.read and model.query)'
|
|
3343
|
+
}).option('login-for', {
|
|
3344
|
+
type: 'string',
|
|
3345
|
+
describe: 'Requested login duration with a unit (e.g. 30d, 12h, 3600s). Mixed units are allowed (e.g. "1h30m", "2d 12h"). Subject to server/client caps. Applied to Session, Grant, and RefreshToken.'
|
|
3324
3346
|
});
|
|
3325
3347
|
},
|
|
3326
3348
|
handler: function handler(argv) {
|
|
3327
3349
|
return _async_to_generator$9(function() {
|
|
3328
|
-
var _argv_code, _tokenResponse_expires_in, _ref, envName, env, meta, _ref1, codeVerifier, codeChallenge, state, requestedScopes, url, pasted, _tmp, code, tokenResponse, expiresAt, entry, e;
|
|
3350
|
+
var _argv_code, _tokenResponse_expires_in, _ref, envName, env, meta, _ref1, codeVerifier, codeChallenge, state, requestedScopes, requestedSessionTtlSeconds, ms, url, pasted, _tmp, code, tokenResponse, expiresAt, entry, e;
|
|
3329
3351
|
return _ts_generator$9(this, function(_state) {
|
|
3330
3352
|
switch(_state.label){
|
|
3331
3353
|
case 0:
|
|
@@ -3370,6 +3392,16 @@ function maskEnv$1(env) {
|
|
|
3370
3392
|
_ref1 = _state.sent(), codeVerifier = _ref1.codeVerifier, codeChallenge = _ref1.codeChallenge;
|
|
3371
3393
|
state = generateOAuthState();
|
|
3372
3394
|
requestedScopes = argv.readOnlyScopes ? filterReadOnlyModelScopes(env.scopes) : env.scopes;
|
|
3395
|
+
if (argv.loginFor) {
|
|
3396
|
+
ms = durationDataToMilliseconds(parseDurationString(argv.loginFor));
|
|
3397
|
+
if (ms <= 0) {
|
|
3398
|
+
throw new CliError({
|
|
3399
|
+
message: '--login-for: invalid duration "'.concat(argv.loginFor, '". Use formats like "30d", "12h", "3600s", or mixed units like "1h30m" or "2d 12h".'),
|
|
3400
|
+
code: 'AUTH_LOGIN_FOR_INVALID'
|
|
3401
|
+
});
|
|
3402
|
+
}
|
|
3403
|
+
requestedSessionTtlSeconds = Math.floor(ms / MS_IN_SECOND);
|
|
3404
|
+
}
|
|
3373
3405
|
url = buildAuthorizationUrl({
|
|
3374
3406
|
authorizationEndpoint: meta.authorization_endpoint,
|
|
3375
3407
|
apiBaseUrl: env.apiBaseUrl,
|
|
@@ -3378,7 +3410,8 @@ function maskEnv$1(env) {
|
|
|
3378
3410
|
redirectUri: env.redirectUri,
|
|
3379
3411
|
scopes: requestedScopes,
|
|
3380
3412
|
state: state,
|
|
3381
|
-
codeChallenge: codeChallenge
|
|
3413
|
+
codeChallenge: codeChallenge,
|
|
3414
|
+
requestedSessionTtlSeconds: requestedSessionTtlSeconds
|
|
3382
3415
|
});
|
|
3383
3416
|
// The CLI never opens a browser itself — it prints the URL and reads the redirect back.
|
|
3384
3417
|
// Emit the URL through a clearly-prefixed stderr line so JSON stdout stays parseable.
|
|
@@ -4411,6 +4444,7 @@ function _ts_generator$8(thisArg, body) {
|
|
|
4411
4444
|
* @param input.checks - Additional checks to append after the default check list.
|
|
4412
4445
|
* @param input.defaultEnvs - Built-in env presets merged underneath the user's stored env when names match.
|
|
4413
4446
|
* @returns A yargs `CommandModule` exposing the `doctor` command.
|
|
4447
|
+
* @__NO_SIDE_EFFECTS__
|
|
4414
4448
|
*/ function createDoctorCommand(input) {
|
|
4415
4449
|
var _input_checks;
|
|
4416
4450
|
var cliName = input.cliName;
|
|
@@ -4849,6 +4883,7 @@ function resolveEnvWithDefault(input) {
|
|
|
4849
4883
|
* @param input.cliName - The CLI's binary name.
|
|
4850
4884
|
* @param input.defaultEnvs - Built-in env presets merged underneath the user's stored env when names match.
|
|
4851
4885
|
* @returns A yargs `CommandModule` exposing the full `env` subcommand surface.
|
|
4886
|
+
* @__NO_SIDE_EFFECTS__
|
|
4852
4887
|
*/ function createEnvCommand(input) {
|
|
4853
4888
|
var paths = buildCliPaths({
|
|
4854
4889
|
cliName: input.cliName
|
|
@@ -5464,6 +5499,7 @@ function _ts_generator$6(thisArg, body) {
|
|
|
5464
5499
|
* @param input.skipCommands - Top-level command names that bypass authentication entirely.
|
|
5465
5500
|
* @param input.defaultEnvs - Built-in env presets merged underneath the user's stored env when names match.
|
|
5466
5501
|
* @returns A yargs middleware function suitable for `.middleware([..., true])`.
|
|
5502
|
+
* @__NO_SIDE_EFFECTS__
|
|
5467
5503
|
*/ function createAuthMiddleware(input) {
|
|
5468
5504
|
var paths = buildCliPaths({
|
|
5469
5505
|
cliName: input.cliName
|
|
@@ -5782,6 +5818,7 @@ function _ts_generator$5(thisArg, body) {
|
|
|
5782
5818
|
* @param input.loadOutputConfig - Optional override for how the output config is read.
|
|
5783
5819
|
* @param input.saveCommandOutputConfig - Optional override for how a per-command output config is persisted.
|
|
5784
5820
|
* @returns A yargs middleware function suitable for `.middleware([..., true])`.
|
|
5821
|
+
* @__NO_SIDE_EFFECTS__
|
|
5785
5822
|
*/ function createOutputMiddleware(input) {
|
|
5786
5823
|
var _input_loadOutputConfig, _input_saveCommandOutputConfig;
|
|
5787
5824
|
var paths = buildCliPaths({
|
|
@@ -6341,6 +6378,7 @@ function resolveCallbacks(input) {
|
|
|
6341
6378
|
* @param input.mergeOutputConfig - Optional override for persisting partial output-config updates.
|
|
6342
6379
|
* @param input.clearOutputConfig - Optional override for clearing the persisted output config entirely.
|
|
6343
6380
|
* @returns A yargs `CommandModule` exposing the full `output` subcommand surface.
|
|
6381
|
+
* @__NO_SIDE_EFFECTS__
|
|
6344
6382
|
*/ function createOutputCommand(input) {
|
|
6345
6383
|
var callbacks = resolveCallbacks(input);
|
|
6346
6384
|
var setCommand = {
|
|
@@ -6702,6 +6740,7 @@ function _ts_generator$2(thisArg, body) {
|
|
|
6702
6740
|
* @param input.argv - Argv to parse. Defaults to `hideBin(process.argv)`.
|
|
6703
6741
|
* @param input.disableCallPassthrough - When `true`, omits the built-in `call` passthrough.
|
|
6704
6742
|
* @returns The configured yargs `Argv` ready to be `.parse()`-d.
|
|
6743
|
+
* @__NO_SIDE_EFFECTS__
|
|
6705
6744
|
*/ function createCli(input) {
|
|
6706
6745
|
var _input_configCommands, _input_apiCommands, _input_argv;
|
|
6707
6746
|
var cliName = input.cliName;
|
|
@@ -7131,6 +7170,7 @@ var DATA_HELP_FLAG = '--data-help';
|
|
|
7131
7170
|
* @param options - Optional overrides; see {@link BuildManifestCommandsOptions}.
|
|
7132
7171
|
* @returns The yargs `CommandModule[]` ready to be passed to `runCli({ apiCommands })`. Empty
|
|
7133
7172
|
* when the manifest has no callable entries.
|
|
7173
|
+
* @__NO_SIDE_EFFECTS__
|
|
7134
7174
|
*/ function buildManifestCommands(manifest, options) {
|
|
7135
7175
|
var _ref, _ref1, _ref2, _ref3, _ref4, _ref5;
|
|
7136
7176
|
var callable = manifest.filter(function(e) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dereekb/dbx-cli",
|
|
3
|
-
"version": "13.11.
|
|
3
|
+
"version": "13.11.4",
|
|
4
4
|
"sideEffects": false,
|
|
5
5
|
"bin": {
|
|
6
6
|
"dbx-cli-generate-firebase-api-manifest": "firebase-api-manifest/main.js"
|
|
@@ -24,9 +24,10 @@
|
|
|
24
24
|
}
|
|
25
25
|
},
|
|
26
26
|
"peerDependencies": {
|
|
27
|
-
"@dereekb/
|
|
28
|
-
"@dereekb/
|
|
29
|
-
"@dereekb/
|
|
27
|
+
"@dereekb/date": "13.11.4",
|
|
28
|
+
"@dereekb/firebase": "13.11.4",
|
|
29
|
+
"@dereekb/nestjs": "13.11.4",
|
|
30
|
+
"@dereekb/util": "13.11.4",
|
|
30
31
|
"arktype": "^2.2.0",
|
|
31
32
|
"yargs": "^18.0.0"
|
|
32
33
|
},
|
|
@@ -38,5 +38,6 @@ export interface CallModelCommandSpec<TParams = unknown, TResult = unknown> {
|
|
|
38
38
|
*
|
|
39
39
|
* @param spec - The command spec describing the yargs command surface plus how to map argv into the typed call params and the result.
|
|
40
40
|
* @returns A yargs `CommandModule` whose handler runs the spec against the active CLI context.
|
|
41
|
+
* @__NO_SIDE_EFFECTS__
|
|
41
42
|
*/
|
|
42
43
|
export declare function createCallModelCommand<TParams = unknown, TResult = unknown>(spec: CallModelCommandSpec<TParams, TResult>): CommandModule;
|
|
@@ -25,5 +25,6 @@ export interface CreateAuthCommandInput {
|
|
|
25
25
|
* @param input.envVarName - Override for the env-name env var. Defaults to `<CLINAME>_ENV` (e.g. `DEMO_CLI_ENV`).
|
|
26
26
|
* @param input.defaultEnvs - Built-in env presets merged underneath the user's stored env when names match.
|
|
27
27
|
* @returns A yargs `CommandModule` exposing the full `auth` subcommand surface.
|
|
28
|
+
* @__NO_SIDE_EFFECTS__
|
|
28
29
|
*/
|
|
29
30
|
export declare function createAuthCommand(input: CreateAuthCommandInput): CommandModule;
|
|
@@ -22,6 +22,13 @@ export interface BuildAuthorizationUrlInput {
|
|
|
22
22
|
readonly scopes?: string;
|
|
23
23
|
readonly state: string;
|
|
24
24
|
readonly codeChallenge: string;
|
|
25
|
+
/**
|
|
26
|
+
* Optional requested login duration in seconds. When set, the URL includes the
|
|
27
|
+
* `dbx_session_ttl=<seconds>` query param so the OIDC server applies the requested
|
|
28
|
+
* lifetime to the issued Session, Grant, and RefreshToken (subject to per-client and
|
|
29
|
+
* server caps).
|
|
30
|
+
*/
|
|
31
|
+
readonly requestedSessionTtlSeconds?: Maybe<number>;
|
|
25
32
|
}
|
|
26
33
|
/**
|
|
27
34
|
* Builds the authorization URL the user opens in a browser to start the PKCE flow.
|
|
@@ -40,6 +47,7 @@ export interface BuildAuthorizationUrlInput {
|
|
|
40
47
|
* @param input.state - The opaque OAuth state token used for CSRF protection.
|
|
41
48
|
* @param input.codeChallenge - The PKCE code challenge derived from the verifier.
|
|
42
49
|
* @returns The full authorization URL with all OAuth params merged in.
|
|
50
|
+
* @__NO_SIDE_EFFECTS__
|
|
43
51
|
*/
|
|
44
52
|
export declare function buildAuthorizationUrl(input: BuildAuthorizationUrlInput): string;
|
|
45
53
|
export interface PkceMaterial {
|
|
@@ -29,5 +29,6 @@ export interface CliPathsConfig {
|
|
|
29
29
|
* @param config.cliName - The CLI's binary name; the default config dir is `~/.<cliName>`.
|
|
30
30
|
* @param config.configDirOverride - Optional override that replaces the default config directory verbatim (used by tests).
|
|
31
31
|
* @returns The {@link CliPaths} pointing at `configDir`, the config file, and the token cache file.
|
|
32
|
+
* @__NO_SIDE_EFFECTS__
|
|
32
33
|
*/
|
|
33
34
|
export declare function buildCliPaths(config: CliPathsConfig): CliPaths;
|
|
@@ -36,6 +36,7 @@ export interface CreateCliTokenCacheStoreInput {
|
|
|
36
36
|
* @param input - The cache store inputs.
|
|
37
37
|
* @param input.tokenCachePath - Absolute path to the JSON file backing the cache.
|
|
38
38
|
* @returns A {@link CliTokenCacheStore} keyed by env name.
|
|
39
|
+
* @__NO_SIDE_EFFECTS__
|
|
39
40
|
*/
|
|
40
41
|
export declare function createCliTokenCacheStore(input: CreateCliTokenCacheStoreInput): CliTokenCacheStore;
|
|
41
42
|
/**
|
|
@@ -37,5 +37,6 @@ export interface CreateCliContextInput {
|
|
|
37
37
|
* @param input.env - The resolved {@link CliEnvConfig} for the active env.
|
|
38
38
|
* @param input.accessToken - The Bearer access token to include on outgoing API calls.
|
|
39
39
|
* @returns The constructed {@link CliContext}.
|
|
40
|
+
* @__NO_SIDE_EFFECTS__
|
|
40
41
|
*/
|
|
41
42
|
export declare function createCliContext(input: CreateCliContextInput): CliContext;
|
|
@@ -44,5 +44,6 @@ export interface CreateDoctorCommandInput {
|
|
|
44
44
|
* @param input.checks - Additional checks to append after the default check list.
|
|
45
45
|
* @param input.defaultEnvs - Built-in env presets merged underneath the user's stored env when names match.
|
|
46
46
|
* @returns A yargs `CommandModule` exposing the `doctor` command.
|
|
47
|
+
* @__NO_SIDE_EFFECTS__
|
|
47
48
|
*/
|
|
48
49
|
export declare function createDoctorCommand(input: CreateDoctorCommandInput): CommandModule;
|
|
@@ -18,5 +18,6 @@ export interface CreateEnvCommandInput {
|
|
|
18
18
|
* @param input.cliName - The CLI's binary name.
|
|
19
19
|
* @param input.defaultEnvs - Built-in env presets merged underneath the user's stored env when names match.
|
|
20
20
|
* @returns A yargs `CommandModule` exposing the full `env` subcommand surface.
|
|
21
|
+
* @__NO_SIDE_EFFECTS__
|
|
21
22
|
*/
|
|
22
23
|
export declare function createEnvCommand(input: CreateEnvCommandInput): CommandModule;
|
|
@@ -103,6 +103,7 @@ export declare const DEFAULT_MANIFEST_MODEL_COMMAND_NAME = "model";
|
|
|
103
103
|
* @param options - Optional overrides; see {@link BuildManifestCommandsOptions}.
|
|
104
104
|
* @returns The yargs `CommandModule[]` ready to be passed to `runCli({ apiCommands })`. Empty
|
|
105
105
|
* when the manifest has no callable entries.
|
|
106
|
+
* @__NO_SIDE_EFFECTS__
|
|
106
107
|
*/
|
|
107
108
|
export declare function buildManifestCommands(manifest: CliApiManifest, options?: BuildManifestCommandsOptions): CommandModule[];
|
|
108
109
|
/**
|
|
@@ -25,5 +25,6 @@ export interface CreateAuthMiddlewareInput {
|
|
|
25
25
|
* @param input.skipCommands - Top-level command names that bypass authentication entirely.
|
|
26
26
|
* @param input.defaultEnvs - Built-in env presets merged underneath the user's stored env when names match.
|
|
27
27
|
* @returns A yargs middleware function suitable for `.middleware([..., true])`.
|
|
28
|
+
* @__NO_SIDE_EFFECTS__
|
|
28
29
|
*/
|
|
29
30
|
export declare function createAuthMiddleware(input: CreateAuthMiddlewareInput): MiddlewareFunction;
|
|
@@ -50,5 +50,6 @@ export interface CreateOutputMiddlewareInput {
|
|
|
50
50
|
* @param input.loadOutputConfig - Optional override for how the output config is read.
|
|
51
51
|
* @param input.saveCommandOutputConfig - Optional override for how a per-command output config is persisted.
|
|
52
52
|
* @returns A yargs middleware function suitable for `.middleware([..., true])`.
|
|
53
|
+
* @__NO_SIDE_EFFECTS__
|
|
53
54
|
*/
|
|
54
55
|
export declare function createOutputMiddleware(input: CreateOutputMiddlewareInput): MiddlewareFunction;
|
|
@@ -51,5 +51,6 @@ export interface CreateOutputCommandInput {
|
|
|
51
51
|
* @param input.mergeOutputConfig - Optional override for persisting partial output-config updates.
|
|
52
52
|
* @param input.clearOutputConfig - Optional override for clearing the persisted output config entirely.
|
|
53
53
|
* @returns A yargs `CommandModule` exposing the full `output` subcommand surface.
|
|
54
|
+
* @__NO_SIDE_EFFECTS__
|
|
54
55
|
*/
|
|
55
56
|
export declare function createOutputCommand(input: CreateOutputCommandInput): CommandModule;
|
package/src/lib/runner/run.d.ts
CHANGED
|
@@ -62,6 +62,7 @@ export interface CreateCliInput {
|
|
|
62
62
|
* @param input.argv - Argv to parse. Defaults to `hideBin(process.argv)`.
|
|
63
63
|
* @param input.disableCallPassthrough - When `true`, omits the built-in `call` passthrough.
|
|
64
64
|
* @returns The configured yargs `Argv` ready to be `.parse()`-d.
|
|
65
|
+
* @__NO_SIDE_EFFECTS__
|
|
65
66
|
*/
|
|
66
67
|
export declare function createCli(input: CreateCliInput): Argv;
|
|
67
68
|
/**
|
|
@@ -46,5 +46,6 @@ export interface CreateContextSlotInput {
|
|
|
46
46
|
* @param input - Optional slot configuration.
|
|
47
47
|
* @param input.notInitializedMessage - Custom error message thrown by `require()` when the slot is unset.
|
|
48
48
|
* @returns A new {@link ContextSlot} for type `T`.
|
|
49
|
+
* @__NO_SIDE_EFFECTS__
|
|
49
50
|
*/
|
|
50
51
|
export declare function createContextSlot<T>(input?: CreateContextSlotInput): ContextSlot<T>;
|
package/src/lib/util/output.d.ts
CHANGED
|
@@ -95,6 +95,7 @@ export declare function dumpTimestamp(): string;
|
|
|
95
95
|
* @param extension - File extension to append (`json` for full responses, `ndjson` for streaming dumps).
|
|
96
96
|
* @param suffix - Optional suffix appended to the filename before the extension.
|
|
97
97
|
* @returns The absolute file path, or `undefined` when `dumpDir` is not configured.
|
|
98
|
+
* @__NO_SIDE_EFFECTS__
|
|
98
99
|
*/
|
|
99
100
|
export declare function buildDumpFilePath(extension: 'json' | 'ndjson', suffix?: string): Maybe<string>;
|
|
100
101
|
/**
|
|
@@ -148,5 +149,6 @@ export declare class CliError extends Error {
|
|
|
148
149
|
*
|
|
149
150
|
* @param error - The thrown value to convert.
|
|
150
151
|
* @returns The structured {@link CliErrorOutput}.
|
|
152
|
+
* @__NO_SIDE_EFFECTS__
|
|
151
153
|
*/
|
|
152
154
|
export declare function buildErrorOutput(error: unknown): CliErrorOutput;
|