@dereekb/dbx-cli 13.11.3 → 13.11.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/firebase-api-manifest/main.js +666 -16
- package/firebase-api-manifest/package.json +1 -1
- package/index.cjs.js +593 -50
- package/index.esm.js +587 -52
- package/manifest-extract/index.cjs.js +705 -0
- package/manifest-extract/index.esm.js +705 -1
- package/manifest-extract/package.json +1 -1
- package/manifest-extract/src/index.d.ts +1 -0
- package/manifest-extract/src/lib/extract-models.d.ts +33 -0
- package/manifest-extract/src/lib/types.d.ts +148 -0
- package/package.json +5 -4
- package/src/lib/api/expand-keys.d.ts +31 -0
- package/src/lib/api/index.d.ts +1 -0
- package/src/lib/auth/oidc.flow.d.ts +7 -0
- package/src/lib/manifest/build-manifest-commands.d.ts +12 -1
- package/src/lib/manifest/build-model-info-command.d.ts +37 -0
- package/src/lib/manifest/index.d.ts +2 -0
- package/src/lib/manifest/model-info-utils.d.ts +40 -0
- package/src/lib/manifest/types.d.ts +126 -0
- package/src/lib/runner/run.d.ts +29 -0
package/index.cjs.js
CHANGED
|
@@ -4,19 +4,20 @@ 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');
|
|
10
11
|
var yargs = require('yargs');
|
|
11
12
|
var helpers = require('yargs/helpers');
|
|
12
13
|
|
|
13
|
-
function _array_like_to_array$
|
|
14
|
+
function _array_like_to_array$7(arr, len) {
|
|
14
15
|
if (len == null || len > arr.length) len = arr.length;
|
|
15
16
|
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
16
17
|
return arr2;
|
|
17
18
|
}
|
|
18
|
-
function _array_without_holes$
|
|
19
|
-
if (Array.isArray(arr)) return _array_like_to_array$
|
|
19
|
+
function _array_without_holes$4(arr) {
|
|
20
|
+
if (Array.isArray(arr)) return _array_like_to_array$7(arr);
|
|
20
21
|
}
|
|
21
22
|
function _assert_this_initialized(self) {
|
|
22
23
|
if (self === void 0) {
|
|
@@ -82,7 +83,7 @@ function _inherits(subClass, superClass) {
|
|
|
82
83
|
});
|
|
83
84
|
if (superClass) _set_prototype_of(subClass, superClass);
|
|
84
85
|
}
|
|
85
|
-
function _instanceof$
|
|
86
|
+
function _instanceof$6(left, right) {
|
|
86
87
|
"@swc/helpers - instanceof";
|
|
87
88
|
if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
|
|
88
89
|
return !!right[Symbol.hasInstance](left);
|
|
@@ -93,10 +94,10 @@ function _instanceof$5(left, right) {
|
|
|
93
94
|
function _is_native_function(fn) {
|
|
94
95
|
return Function.toString.call(fn).indexOf("[native code]") !== -1;
|
|
95
96
|
}
|
|
96
|
-
function _iterable_to_array$
|
|
97
|
+
function _iterable_to_array$4(iter) {
|
|
97
98
|
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
|
|
98
99
|
}
|
|
99
|
-
function _non_iterable_spread$
|
|
100
|
+
function _non_iterable_spread$4() {
|
|
100
101
|
throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
101
102
|
}
|
|
102
103
|
function _object_spread$c(target) {
|
|
@@ -115,7 +116,7 @@ function _object_spread$c(target) {
|
|
|
115
116
|
return target;
|
|
116
117
|
}
|
|
117
118
|
function _possible_constructor_return(self, call) {
|
|
118
|
-
if (call && (_type_of$
|
|
119
|
+
if (call && (_type_of$3(call) === "object" || typeof call === "function")) {
|
|
119
120
|
return call;
|
|
120
121
|
}
|
|
121
122
|
return _assert_this_initialized(self);
|
|
@@ -127,20 +128,20 @@ function _set_prototype_of(o, p) {
|
|
|
127
128
|
};
|
|
128
129
|
return _set_prototype_of(o, p);
|
|
129
130
|
}
|
|
130
|
-
function _to_consumable_array$
|
|
131
|
-
return _array_without_holes$
|
|
131
|
+
function _to_consumable_array$4(arr) {
|
|
132
|
+
return _array_without_holes$4(arr) || _iterable_to_array$4(arr) || _unsupported_iterable_to_array$7(arr) || _non_iterable_spread$4();
|
|
132
133
|
}
|
|
133
|
-
function _type_of$
|
|
134
|
+
function _type_of$3(obj) {
|
|
134
135
|
"@swc/helpers - typeof";
|
|
135
136
|
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
136
137
|
}
|
|
137
|
-
function _unsupported_iterable_to_array$
|
|
138
|
+
function _unsupported_iterable_to_array$7(o, minLen) {
|
|
138
139
|
if (!o) return;
|
|
139
|
-
if (typeof o === "string") return _array_like_to_array$
|
|
140
|
+
if (typeof o === "string") return _array_like_to_array$7(o, minLen);
|
|
140
141
|
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
141
142
|
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
142
143
|
if (n === "Map" || n === "Set") return Array.from(n);
|
|
143
|
-
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$
|
|
144
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$7(o, minLen);
|
|
144
145
|
}
|
|
145
146
|
function _wrap_native_super(Class) {
|
|
146
147
|
var _cache = typeof Map === "function" ? new Map() : undefined;
|
|
@@ -189,7 +190,7 @@ function _is_native_reflect_construct() {
|
|
|
189
190
|
/id_token[=:]\s*\S+/gi
|
|
190
191
|
];
|
|
191
192
|
var _outputOptions = {};
|
|
192
|
-
var _secretPatterns = _to_consumable_array$
|
|
193
|
+
var _secretPatterns = _to_consumable_array$4(DEFAULT_CLI_SECRET_PATTERNS);
|
|
193
194
|
var _errorMapper;
|
|
194
195
|
/**
|
|
195
196
|
* Configures output options from parsed CLI arguments.
|
|
@@ -318,13 +319,13 @@ function dumpResponse(data, meta) {
|
|
|
318
319
|
return pickFromObject(item, fields);
|
|
319
320
|
});
|
|
320
321
|
}
|
|
321
|
-
if (data != null && (typeof data === "undefined" ? "undefined" : _type_of$
|
|
322
|
+
if (data != null && (typeof data === "undefined" ? "undefined" : _type_of$3(data)) === 'object') {
|
|
322
323
|
return pickFromObject(data, fields);
|
|
323
324
|
}
|
|
324
325
|
return data;
|
|
325
326
|
}
|
|
326
327
|
function pickFromObject(obj, fields) {
|
|
327
|
-
if (obj == null || (typeof obj === "undefined" ? "undefined" : _type_of$
|
|
328
|
+
if (obj == null || (typeof obj === "undefined" ? "undefined" : _type_of$3(obj)) !== 'object') {
|
|
328
329
|
return obj;
|
|
329
330
|
}
|
|
330
331
|
var result = {};
|
|
@@ -419,7 +420,7 @@ function pickFromObject(obj, fields) {
|
|
|
419
420
|
return mapped;
|
|
420
421
|
}
|
|
421
422
|
}
|
|
422
|
-
if (_instanceof$
|
|
423
|
+
if (_instanceof$6(error, CliError)) {
|
|
423
424
|
return _object_spread$c({
|
|
424
425
|
ok: false,
|
|
425
426
|
error: sanitizeString(error.message),
|
|
@@ -428,7 +429,7 @@ function pickFromObject(obj, fields) {
|
|
|
428
429
|
suggestion: error.suggestion
|
|
429
430
|
} : {});
|
|
430
431
|
}
|
|
431
|
-
if (_instanceof$
|
|
432
|
+
if (_instanceof$6(error, Error)) {
|
|
432
433
|
return {
|
|
433
434
|
ok: false,
|
|
434
435
|
error: sanitizeString(error.message),
|
|
@@ -471,7 +472,7 @@ function _async_to_generator$f(fn) {
|
|
|
471
472
|
});
|
|
472
473
|
};
|
|
473
474
|
}
|
|
474
|
-
function _type_of$
|
|
475
|
+
function _type_of$2(obj) {
|
|
475
476
|
"@swc/helpers - typeof";
|
|
476
477
|
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
477
478
|
}
|
|
@@ -625,7 +626,7 @@ var CALL_MODEL_API_PATH = "/model/call";
|
|
|
625
626
|
}
|
|
626
627
|
}
|
|
627
628
|
if (!res.ok) {
|
|
628
|
-
bodyMessage = (typeof body === "undefined" ? "undefined" : _type_of$
|
|
629
|
+
bodyMessage = (typeof body === "undefined" ? "undefined" : _type_of$2(body)) === 'object' && body && 'message' in body ? body.message : undefined;
|
|
629
630
|
messageString = typeof bodyMessage === 'string' ? bodyMessage : undefined;
|
|
630
631
|
message = messageString !== null && messageString !== void 0 ? messageString : text || "".concat(res.status, " ").concat(res.statusText);
|
|
631
632
|
throw new CliError({
|
|
@@ -1132,7 +1133,7 @@ function _define_property$a(obj, key, value) {
|
|
|
1132
1133
|
}
|
|
1133
1134
|
return obj;
|
|
1134
1135
|
}
|
|
1135
|
-
function _instanceof$
|
|
1136
|
+
function _instanceof$5(left, right) {
|
|
1136
1137
|
"@swc/helpers - instanceof";
|
|
1137
1138
|
if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
|
|
1138
1139
|
return !!right[Symbol.hasInstance](left);
|
|
@@ -1303,7 +1304,7 @@ function _ts_generator$d(thisArg, body) {
|
|
|
1303
1304
|
data = JSON.parse(argv.data);
|
|
1304
1305
|
} catch (e) {
|
|
1305
1306
|
throw new CliError({
|
|
1306
|
-
message: "--data must be valid JSON: ".concat(_instanceof$
|
|
1307
|
+
message: "--data must be valid JSON: ".concat(_instanceof$5(e, Error) ? e.message : String(e)),
|
|
1307
1308
|
code: 'INVALID_DATA_JSON'
|
|
1308
1309
|
});
|
|
1309
1310
|
}
|
|
@@ -1345,6 +1346,201 @@ function _ts_generator$d(thisArg, body) {
|
|
|
1345
1346
|
}
|
|
1346
1347
|
};
|
|
1347
1348
|
|
|
1349
|
+
function _array_like_to_array$6(arr, len) {
|
|
1350
|
+
if (len == null || len > arr.length) len = arr.length;
|
|
1351
|
+
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
1352
|
+
return arr2;
|
|
1353
|
+
}
|
|
1354
|
+
function _array_with_holes$3(arr) {
|
|
1355
|
+
if (Array.isArray(arr)) return arr;
|
|
1356
|
+
}
|
|
1357
|
+
function _instanceof$4(left, right) {
|
|
1358
|
+
"@swc/helpers - instanceof";
|
|
1359
|
+
if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
|
|
1360
|
+
return !!right[Symbol.hasInstance](left);
|
|
1361
|
+
} else {
|
|
1362
|
+
return left instanceof right;
|
|
1363
|
+
}
|
|
1364
|
+
}
|
|
1365
|
+
function _iterable_to_array_limit$3(arr, i) {
|
|
1366
|
+
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
1367
|
+
if (_i == null) return;
|
|
1368
|
+
var _arr = [];
|
|
1369
|
+
var _n = true;
|
|
1370
|
+
var _d = false;
|
|
1371
|
+
var _s, _e;
|
|
1372
|
+
try {
|
|
1373
|
+
for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
|
|
1374
|
+
_arr.push(_s.value);
|
|
1375
|
+
if (i && _arr.length === i) break;
|
|
1376
|
+
}
|
|
1377
|
+
} catch (err) {
|
|
1378
|
+
_d = true;
|
|
1379
|
+
_e = err;
|
|
1380
|
+
} finally{
|
|
1381
|
+
try {
|
|
1382
|
+
if (!_n && _i["return"] != null) _i["return"]();
|
|
1383
|
+
} finally{
|
|
1384
|
+
if (_d) throw _e;
|
|
1385
|
+
}
|
|
1386
|
+
}
|
|
1387
|
+
return _arr;
|
|
1388
|
+
}
|
|
1389
|
+
function _non_iterable_rest$3() {
|
|
1390
|
+
throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
1391
|
+
}
|
|
1392
|
+
function _sliced_to_array$3(arr, i) {
|
|
1393
|
+
return _array_with_holes$3(arr) || _iterable_to_array_limit$3(arr, i) || _unsupported_iterable_to_array$6(arr, i) || _non_iterable_rest$3();
|
|
1394
|
+
}
|
|
1395
|
+
function _type_of$1(obj) {
|
|
1396
|
+
"@swc/helpers - typeof";
|
|
1397
|
+
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
1398
|
+
}
|
|
1399
|
+
function _unsupported_iterable_to_array$6(o, minLen) {
|
|
1400
|
+
if (!o) return;
|
|
1401
|
+
if (typeof o === "string") return _array_like_to_array$6(o, minLen);
|
|
1402
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
1403
|
+
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
1404
|
+
if (n === "Map" || n === "Set") return Array.from(n);
|
|
1405
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$6(o, minLen);
|
|
1406
|
+
}
|
|
1407
|
+
/**
|
|
1408
|
+
* Resolves the manifest entry for `modelType`. Lookup tries
|
|
1409
|
+
* `modelType` first, then falls back to `identityConst` and `collectionPrefix`
|
|
1410
|
+
* so callers can pass any of the three forms a user might type at the CLI.
|
|
1411
|
+
*
|
|
1412
|
+
* @param modelType - identifier to look up.
|
|
1413
|
+
* @param manifest - generated model manifest.
|
|
1414
|
+
* @returns the matching entry, or `undefined` when none exists.
|
|
1415
|
+
* @__NO_SIDE_EFFECTS__
|
|
1416
|
+
*/ function findCliModelManifestEntry(modelType, manifest) {
|
|
1417
|
+
var result;
|
|
1418
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
1419
|
+
try {
|
|
1420
|
+
for(var _iterator = manifest[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
1421
|
+
var entry = _step.value;
|
|
1422
|
+
if (entry.modelType === modelType || entry.identityConst === modelType || entry.collectionPrefix === modelType) {
|
|
1423
|
+
result = entry;
|
|
1424
|
+
break;
|
|
1425
|
+
}
|
|
1426
|
+
}
|
|
1427
|
+
} catch (err) {
|
|
1428
|
+
_didIteratorError = true;
|
|
1429
|
+
_iteratorError = err;
|
|
1430
|
+
} finally{
|
|
1431
|
+
try {
|
|
1432
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
1433
|
+
_iterator.return();
|
|
1434
|
+
}
|
|
1435
|
+
} finally{
|
|
1436
|
+
if (_didIteratorError) {
|
|
1437
|
+
throw _iteratorError;
|
|
1438
|
+
}
|
|
1439
|
+
}
|
|
1440
|
+
}
|
|
1441
|
+
return result;
|
|
1442
|
+
}
|
|
1443
|
+
/**
|
|
1444
|
+
* Rewrites the persisted (short) keys in `data` to the long-name form
|
|
1445
|
+
* declared in the model's manifest entry. Recurses into nested object-array
|
|
1446
|
+
* and sub-object fields when the manifest captured a nested field map.
|
|
1447
|
+
*
|
|
1448
|
+
* Returns the input untouched when `modelType` is not in the manifest, when
|
|
1449
|
+
* the model has no fields, or when the input is not a plain object/array.
|
|
1450
|
+
* Unknown keys, primitives, `Date`, `null`, and `undefined` pass through
|
|
1451
|
+
* unchanged.
|
|
1452
|
+
*
|
|
1453
|
+
* @param modelType - the model identifier (`modelType`, `identityConst`,
|
|
1454
|
+
* or `collectionPrefix`) used to look up the rewrite map.
|
|
1455
|
+
* @param data - the value to rewrite (typically a `read`/`query` response
|
|
1456
|
+
* payload).
|
|
1457
|
+
* @param manifest - generated model manifest.
|
|
1458
|
+
* @returns the rewritten value, or `data` unchanged when no rewrite applies.
|
|
1459
|
+
* @__NO_SIDE_EFFECTS__
|
|
1460
|
+
*/ function expandModelKeys(modelType, data, manifest) {
|
|
1461
|
+
var entry = findCliModelManifestEntry(modelType, manifest);
|
|
1462
|
+
if (!entry) return data;
|
|
1463
|
+
return rewriteWithFields(data, entry.fields);
|
|
1464
|
+
}
|
|
1465
|
+
function rewriteWithFields(value, fields) {
|
|
1466
|
+
if (Array.isArray(value)) {
|
|
1467
|
+
return value.map(function(item) {
|
|
1468
|
+
return rewriteWithFields(item, fields);
|
|
1469
|
+
});
|
|
1470
|
+
}
|
|
1471
|
+
if (!isPlainObject(value)) return value;
|
|
1472
|
+
var fieldByName = new Map();
|
|
1473
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
1474
|
+
try {
|
|
1475
|
+
for(var _iterator = fields[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
1476
|
+
var field = _step.value;
|
|
1477
|
+
fieldByName.set(field.name, field);
|
|
1478
|
+
}
|
|
1479
|
+
} catch (err) {
|
|
1480
|
+
_didIteratorError = true;
|
|
1481
|
+
_iteratorError = err;
|
|
1482
|
+
} finally{
|
|
1483
|
+
try {
|
|
1484
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
1485
|
+
_iterator.return();
|
|
1486
|
+
}
|
|
1487
|
+
} finally{
|
|
1488
|
+
if (_didIteratorError) {
|
|
1489
|
+
throw _iteratorError;
|
|
1490
|
+
}
|
|
1491
|
+
}
|
|
1492
|
+
}
|
|
1493
|
+
var out = {};
|
|
1494
|
+
var _iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = undefined;
|
|
1495
|
+
try {
|
|
1496
|
+
for(var _iterator1 = Object.entries(value)[Symbol.iterator](), _step1; !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true){
|
|
1497
|
+
var _step_value = _sliced_to_array$3(_step1.value, 2), key = _step_value[0], raw = _step_value[1];
|
|
1498
|
+
var field1 = fieldByName.get(key);
|
|
1499
|
+
if (!field1) {
|
|
1500
|
+
out[key] = raw;
|
|
1501
|
+
continue;
|
|
1502
|
+
}
|
|
1503
|
+
var longKey = field1.longName.length > 0 ? field1.longName : key;
|
|
1504
|
+
out[longKey] = rewriteFieldValue(raw, field1);
|
|
1505
|
+
}
|
|
1506
|
+
} catch (err) {
|
|
1507
|
+
_didIteratorError1 = true;
|
|
1508
|
+
_iteratorError1 = err;
|
|
1509
|
+
} finally{
|
|
1510
|
+
try {
|
|
1511
|
+
if (!_iteratorNormalCompletion1 && _iterator1.return != null) {
|
|
1512
|
+
_iterator1.return();
|
|
1513
|
+
}
|
|
1514
|
+
} finally{
|
|
1515
|
+
if (_didIteratorError1) {
|
|
1516
|
+
throw _iteratorError1;
|
|
1517
|
+
}
|
|
1518
|
+
}
|
|
1519
|
+
}
|
|
1520
|
+
return out;
|
|
1521
|
+
}
|
|
1522
|
+
function rewriteFieldValue(value, field) {
|
|
1523
|
+
var nested = field.nestedFields;
|
|
1524
|
+
if (!nested || nested.length === 0) return value;
|
|
1525
|
+
if (field.nestedIsArray) {
|
|
1526
|
+
if (!Array.isArray(value)) return value;
|
|
1527
|
+
return value.map(function(item) {
|
|
1528
|
+
return rewriteWithFields(item, nested);
|
|
1529
|
+
});
|
|
1530
|
+
}
|
|
1531
|
+
if (!isPlainObject(value)) return value;
|
|
1532
|
+
return rewriteWithFields(value, nested);
|
|
1533
|
+
}
|
|
1534
|
+
function isPlainObject(value) {
|
|
1535
|
+
if (value === null || (typeof value === "undefined" ? "undefined" : _type_of$1(value)) !== 'object') return false;
|
|
1536
|
+
if (Array.isArray(value)) return false;
|
|
1537
|
+
if (_instanceof$4(value, Date)) return false;
|
|
1538
|
+
// Objects from JSON.parse have Object.prototype as their proto. Anything
|
|
1539
|
+
// exotic (Map, Set, Buffer, class instances) we leave untouched.
|
|
1540
|
+
var proto = Object.getPrototypeOf(value);
|
|
1541
|
+
return proto === Object.prototype || proto === null;
|
|
1542
|
+
}
|
|
1543
|
+
|
|
1348
1544
|
function asyncGeneratorStep$c(gen, resolve, reject, _next, _throw, key, arg) {
|
|
1349
1545
|
try {
|
|
1350
1546
|
var info = gen[key](arg);
|
|
@@ -2350,7 +2546,7 @@ function trimSlash(url) {
|
|
|
2350
2546
|
return url.endsWith('/') ? url.slice(0, -1) : url;
|
|
2351
2547
|
}
|
|
2352
2548
|
|
|
2353
|
-
function _array_like_to_array$
|
|
2549
|
+
function _array_like_to_array$5(arr, len) {
|
|
2354
2550
|
if (len == null || len > arr.length) len = arr.length;
|
|
2355
2551
|
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
2356
2552
|
return arr2;
|
|
@@ -2415,15 +2611,15 @@ function _non_iterable_rest$2() {
|
|
|
2415
2611
|
throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
2416
2612
|
}
|
|
2417
2613
|
function _sliced_to_array$2(arr, i) {
|
|
2418
|
-
return _array_with_holes$2(arr) || _iterable_to_array_limit$2(arr, i) || _unsupported_iterable_to_array$
|
|
2614
|
+
return _array_with_holes$2(arr) || _iterable_to_array_limit$2(arr, i) || _unsupported_iterable_to_array$5(arr, i) || _non_iterable_rest$2();
|
|
2419
2615
|
}
|
|
2420
|
-
function _unsupported_iterable_to_array$
|
|
2616
|
+
function _unsupported_iterable_to_array$5(o, minLen) {
|
|
2421
2617
|
if (!o) return;
|
|
2422
|
-
if (typeof o === "string") return _array_like_to_array$
|
|
2618
|
+
if (typeof o === "string") return _array_like_to_array$5(o, minLen);
|
|
2423
2619
|
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
2424
2620
|
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
2425
2621
|
if (n === "Map" || n === "Set") return Array.from(n);
|
|
2426
|
-
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$
|
|
2622
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$5(o, minLen);
|
|
2427
2623
|
}
|
|
2428
2624
|
function _ts_generator$a(thisArg, body) {
|
|
2429
2625
|
var f, y, t, _ = {
|
|
@@ -2553,6 +2749,15 @@ function _ts_generator$a(thisArg, body) {
|
|
|
2553
2749
|
code_challenge_method: 'S256',
|
|
2554
2750
|
state: input.state
|
|
2555
2751
|
};
|
|
2752
|
+
if (input.requestedSessionTtlSeconds != null) {
|
|
2753
|
+
if (!Number.isInteger(input.requestedSessionTtlSeconds) || input.requestedSessionTtlSeconds <= 0) {
|
|
2754
|
+
throw new CliError({
|
|
2755
|
+
message: "requestedSessionTtlSeconds must be a positive integer (got ".concat(input.requestedSessionTtlSeconds, ")."),
|
|
2756
|
+
code: 'AUTH_LOGIN_FOR_INVALID'
|
|
2757
|
+
});
|
|
2758
|
+
}
|
|
2759
|
+
authParams.dbx_session_ttl = String(input.requestedSessionTtlSeconds);
|
|
2760
|
+
}
|
|
2556
2761
|
var endpoint;
|
|
2557
2762
|
if (input.appClientUrl) {
|
|
2558
2763
|
endpoint = rebaseUrlOrigin({
|
|
@@ -3332,11 +3537,14 @@ function maskEnv$1(env) {
|
|
|
3332
3537
|
type: 'boolean',
|
|
3333
3538
|
default: false,
|
|
3334
3539
|
describe: 'Drop model.create/model.update/model.delete from the requested scopes (keeps model.read and model.query)'
|
|
3540
|
+
}).option('login-for', {
|
|
3541
|
+
type: 'string',
|
|
3542
|
+
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.'
|
|
3335
3543
|
});
|
|
3336
3544
|
},
|
|
3337
3545
|
handler: function handler(argv) {
|
|
3338
3546
|
return _async_to_generator$9(function() {
|
|
3339
|
-
var _argv_code, _tokenResponse_expires_in, _ref, envName, env, meta, _ref1, codeVerifier, codeChallenge, state, requestedScopes, url, pasted, _tmp, code, tokenResponse, expiresAt, entry, e;
|
|
3547
|
+
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;
|
|
3340
3548
|
return _ts_generator$9(this, function(_state) {
|
|
3341
3549
|
switch(_state.label){
|
|
3342
3550
|
case 0:
|
|
@@ -3381,6 +3589,16 @@ function maskEnv$1(env) {
|
|
|
3381
3589
|
_ref1 = _state.sent(), codeVerifier = _ref1.codeVerifier, codeChallenge = _ref1.codeChallenge;
|
|
3382
3590
|
state = generateOAuthState();
|
|
3383
3591
|
requestedScopes = argv.readOnlyScopes ? filterReadOnlyModelScopes(env.scopes) : env.scopes;
|
|
3592
|
+
if (argv.loginFor) {
|
|
3593
|
+
ms = date.durationDataToMilliseconds(date.parseDurationString(argv.loginFor));
|
|
3594
|
+
if (ms <= 0) {
|
|
3595
|
+
throw new CliError({
|
|
3596
|
+
message: '--login-for: invalid duration "'.concat(argv.loginFor, '". Use formats like "30d", "12h", "3600s", or mixed units like "1h30m" or "2d 12h".'),
|
|
3597
|
+
code: 'AUTH_LOGIN_FOR_INVALID'
|
|
3598
|
+
});
|
|
3599
|
+
}
|
|
3600
|
+
requestedSessionTtlSeconds = Math.floor(ms / util.MS_IN_SECOND);
|
|
3601
|
+
}
|
|
3384
3602
|
url = buildAuthorizationUrl({
|
|
3385
3603
|
authorizationEndpoint: meta.authorization_endpoint,
|
|
3386
3604
|
apiBaseUrl: env.apiBaseUrl,
|
|
@@ -3389,7 +3607,8 @@ function maskEnv$1(env) {
|
|
|
3389
3607
|
redirectUri: env.redirectUri,
|
|
3390
3608
|
scopes: requestedScopes,
|
|
3391
3609
|
state: state,
|
|
3392
|
-
codeChallenge: codeChallenge
|
|
3610
|
+
codeChallenge: codeChallenge,
|
|
3611
|
+
requestedSessionTtlSeconds: requestedSessionTtlSeconds
|
|
3393
3612
|
});
|
|
3394
3613
|
// The CLI never opens a browser itself — it prints the URL and reads the redirect back.
|
|
3395
3614
|
// Emit the URL through a clearly-prefixed stderr line so JSON stdout stays parseable.
|
|
@@ -3896,13 +4115,13 @@ function maskEnv$1(env) {
|
|
|
3896
4115
|
};
|
|
3897
4116
|
}
|
|
3898
4117
|
|
|
3899
|
-
function _array_like_to_array$
|
|
4118
|
+
function _array_like_to_array$4(arr, len) {
|
|
3900
4119
|
if (len == null || len > arr.length) len = arr.length;
|
|
3901
4120
|
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
3902
4121
|
return arr2;
|
|
3903
4122
|
}
|
|
3904
|
-
function _array_without_holes$
|
|
3905
|
-
if (Array.isArray(arr)) return _array_like_to_array$
|
|
4123
|
+
function _array_without_holes$3(arr) {
|
|
4124
|
+
if (Array.isArray(arr)) return _array_like_to_array$4(arr);
|
|
3906
4125
|
}
|
|
3907
4126
|
function asyncGeneratorStep$8(gen, resolve, reject, _next, _throw, key, arg) {
|
|
3908
4127
|
try {
|
|
@@ -3954,10 +4173,10 @@ function _instanceof$2(left, right) {
|
|
|
3954
4173
|
return left instanceof right;
|
|
3955
4174
|
}
|
|
3956
4175
|
}
|
|
3957
|
-
function _iterable_to_array$
|
|
4176
|
+
function _iterable_to_array$3(iter) {
|
|
3958
4177
|
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
|
|
3959
4178
|
}
|
|
3960
|
-
function _non_iterable_spread$
|
|
4179
|
+
function _non_iterable_spread$3() {
|
|
3961
4180
|
throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
3962
4181
|
}
|
|
3963
4182
|
function _object_spread$6(target) {
|
|
@@ -3975,16 +4194,16 @@ function _object_spread$6(target) {
|
|
|
3975
4194
|
}
|
|
3976
4195
|
return target;
|
|
3977
4196
|
}
|
|
3978
|
-
function _to_consumable_array$
|
|
3979
|
-
return _array_without_holes$
|
|
4197
|
+
function _to_consumable_array$3(arr) {
|
|
4198
|
+
return _array_without_holes$3(arr) || _iterable_to_array$3(arr) || _unsupported_iterable_to_array$4(arr) || _non_iterable_spread$3();
|
|
3980
4199
|
}
|
|
3981
|
-
function _unsupported_iterable_to_array$
|
|
4200
|
+
function _unsupported_iterable_to_array$4(o, minLen) {
|
|
3982
4201
|
if (!o) return;
|
|
3983
|
-
if (typeof o === "string") return _array_like_to_array$
|
|
4202
|
+
if (typeof o === "string") return _array_like_to_array$4(o, minLen);
|
|
3984
4203
|
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
3985
4204
|
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
3986
4205
|
if (n === "Map" || n === "Set") return Array.from(n);
|
|
3987
|
-
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$
|
|
4206
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$4(o, minLen);
|
|
3988
4207
|
}
|
|
3989
4208
|
function _ts_generator$8(thisArg, body) {
|
|
3990
4209
|
var f, y, t, _ = {
|
|
@@ -4426,7 +4645,7 @@ function _ts_generator$8(thisArg, body) {
|
|
|
4426
4645
|
*/ function createDoctorCommand(input) {
|
|
4427
4646
|
var _input_checks;
|
|
4428
4647
|
var cliName = input.cliName;
|
|
4429
|
-
var checks = _to_consumable_array$
|
|
4648
|
+
var checks = _to_consumable_array$3(defaultDoctorChecks()).concat(_to_consumable_array$3((_input_checks = input.checks) !== null && _input_checks !== void 0 ? _input_checks : []));
|
|
4430
4649
|
var defaultEnvs = input.defaultEnvs;
|
|
4431
4650
|
return {
|
|
4432
4651
|
command: 'doctor',
|
|
@@ -4593,7 +4812,7 @@ function _ts_generator$8(thisArg, body) {
|
|
|
4593
4812
|
};
|
|
4594
4813
|
}
|
|
4595
4814
|
|
|
4596
|
-
function _array_like_to_array$
|
|
4815
|
+
function _array_like_to_array$3(arr, len) {
|
|
4597
4816
|
if (len == null || len > arr.length) len = arr.length;
|
|
4598
4817
|
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
4599
4818
|
return arr2;
|
|
@@ -4713,15 +4932,15 @@ function _object_spread_props$4(target, source) {
|
|
|
4713
4932
|
return target;
|
|
4714
4933
|
}
|
|
4715
4934
|
function _sliced_to_array$1(arr, i) {
|
|
4716
|
-
return _array_with_holes$1(arr) || _iterable_to_array_limit$1(arr, i) || _unsupported_iterable_to_array$
|
|
4935
|
+
return _array_with_holes$1(arr) || _iterable_to_array_limit$1(arr, i) || _unsupported_iterable_to_array$3(arr, i) || _non_iterable_rest$1();
|
|
4717
4936
|
}
|
|
4718
|
-
function _unsupported_iterable_to_array$
|
|
4937
|
+
function _unsupported_iterable_to_array$3(o, minLen) {
|
|
4719
4938
|
if (!o) return;
|
|
4720
|
-
if (typeof o === "string") return _array_like_to_array$
|
|
4939
|
+
if (typeof o === "string") return _array_like_to_array$3(o, minLen);
|
|
4721
4940
|
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
4722
4941
|
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
4723
4942
|
if (n === "Map" || n === "Set") return Array.from(n);
|
|
4724
|
-
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$
|
|
4943
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$3(o, minLen);
|
|
4725
4944
|
}
|
|
4726
4945
|
function _ts_generator$7(thisArg, body) {
|
|
4727
4946
|
var f, y, t, _ = {
|
|
@@ -5290,6 +5509,302 @@ function resolveEnvWithDefault(input) {
|
|
|
5290
5509
|
};
|
|
5291
5510
|
}
|
|
5292
5511
|
|
|
5512
|
+
function _array_like_to_array$2(arr, len) {
|
|
5513
|
+
if (len == null || len > arr.length) len = arr.length;
|
|
5514
|
+
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
5515
|
+
return arr2;
|
|
5516
|
+
}
|
|
5517
|
+
function _array_without_holes$2(arr) {
|
|
5518
|
+
if (Array.isArray(arr)) return _array_like_to_array$2(arr);
|
|
5519
|
+
}
|
|
5520
|
+
function _iterable_to_array$2(iter) {
|
|
5521
|
+
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
|
|
5522
|
+
}
|
|
5523
|
+
function _non_iterable_spread$2() {
|
|
5524
|
+
throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
5525
|
+
}
|
|
5526
|
+
function _to_consumable_array$2(arr) {
|
|
5527
|
+
return _array_without_holes$2(arr) || _iterable_to_array$2(arr) || _unsupported_iterable_to_array$2(arr) || _non_iterable_spread$2();
|
|
5528
|
+
}
|
|
5529
|
+
function _unsupported_iterable_to_array$2(o, minLen) {
|
|
5530
|
+
if (!o) return;
|
|
5531
|
+
if (typeof o === "string") return _array_like_to_array$2(o, minLen);
|
|
5532
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
5533
|
+
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
5534
|
+
if (n === "Map" || n === "Set") return Array.from(n);
|
|
5535
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$2(o, minLen);
|
|
5536
|
+
}
|
|
5537
|
+
/**
|
|
5538
|
+
* Resolves the manifest entry for `query` against `modelType`, `identityConst`,
|
|
5539
|
+
* and `collectionPrefix` in that order.
|
|
5540
|
+
*
|
|
5541
|
+
* Re-exports {@link findCliModelManifestEntry} under a more descriptive name
|
|
5542
|
+
* for the model-info command.
|
|
5543
|
+
*
|
|
5544
|
+
* @param manifest - the generated model manifest.
|
|
5545
|
+
* @param query - identifier to look up.
|
|
5546
|
+
* @returns the matching entry or `undefined`.
|
|
5547
|
+
* @__NO_SIDE_EFFECTS__
|
|
5548
|
+
*/ function resolveCliModel(manifest, query) {
|
|
5549
|
+
return findCliModelManifestEntry(query, manifest);
|
|
5550
|
+
}
|
|
5551
|
+
/**
|
|
5552
|
+
* Produces a column-aligned summary table of every model in the manifest.
|
|
5553
|
+
*
|
|
5554
|
+
* @param manifest - the generated model manifest.
|
|
5555
|
+
* @returns the formatted table as a single string with a trailing newline.
|
|
5556
|
+
* @__NO_SIDE_EFFECTS__
|
|
5557
|
+
*/ function renderModelManifestList(manifest) {
|
|
5558
|
+
if (manifest.length === 0) {
|
|
5559
|
+
return 'No models found in the generated manifest.\n';
|
|
5560
|
+
}
|
|
5561
|
+
var rows = [
|
|
5562
|
+
[
|
|
5563
|
+
'MODEL',
|
|
5564
|
+
'PREFIX',
|
|
5565
|
+
'GROUP',
|
|
5566
|
+
'FIELDS',
|
|
5567
|
+
'PACKAGE',
|
|
5568
|
+
'IDENTITY'
|
|
5569
|
+
]
|
|
5570
|
+
].concat(_to_consumable_array$2(manifest.map(function(m) {
|
|
5571
|
+
var _m_modelGroup;
|
|
5572
|
+
return [
|
|
5573
|
+
m.modelType,
|
|
5574
|
+
m.collectionPrefix,
|
|
5575
|
+
(_m_modelGroup = m.modelGroup) !== null && _m_modelGroup !== void 0 ? _m_modelGroup : '',
|
|
5576
|
+
String(m.fields.length),
|
|
5577
|
+
m.sourcePackage,
|
|
5578
|
+
m.identityConst
|
|
5579
|
+
];
|
|
5580
|
+
})));
|
|
5581
|
+
return renderTable(rows);
|
|
5582
|
+
}
|
|
5583
|
+
/**
|
|
5584
|
+
* Produces a human-readable summary of one model entry: header, description,
|
|
5585
|
+
* and an indented field tree (recursing into `nestedFields`).
|
|
5586
|
+
*
|
|
5587
|
+
* @param entry - the manifest entry to render.
|
|
5588
|
+
* @returns the formatted summary as a single string with a trailing newline.
|
|
5589
|
+
* @__NO_SIDE_EFFECTS__
|
|
5590
|
+
*/ function renderModelManifestEntry(entry) {
|
|
5591
|
+
var lines = [];
|
|
5592
|
+
lines.push("# ".concat(entry.modelType) + (entry.modelGroup ? " \xb7 group ".concat(entry.modelGroup) : ''));
|
|
5593
|
+
lines.push("Identity: ".concat(entry.identityConst));
|
|
5594
|
+
lines.push("Collection prefix: ".concat(entry.collectionPrefix));
|
|
5595
|
+
if (entry.parentIdentityConst) lines.push("Parent identity: ".concat(entry.parentIdentityConst));
|
|
5596
|
+
lines.push("Source package: ".concat(entry.sourcePackage));
|
|
5597
|
+
lines.push("Source file: ".concat(entry.sourceFile));
|
|
5598
|
+
if (entry.description) {
|
|
5599
|
+
lines.push('');
|
|
5600
|
+
lines.push(entry.description);
|
|
5601
|
+
}
|
|
5602
|
+
lines.push('');
|
|
5603
|
+
lines.push("Fields (".concat(entry.fields.length, "):"));
|
|
5604
|
+
lines.push(renderFieldsTree(entry.fields, 0));
|
|
5605
|
+
return lines.join('\n') + '\n';
|
|
5606
|
+
}
|
|
5607
|
+
/**
|
|
5608
|
+
* Produces the field-table portion of {@link renderModelManifestEntry} on its
|
|
5609
|
+
* own, used by the `--fields` flag of the `model-info` command.
|
|
5610
|
+
*
|
|
5611
|
+
* @param entry - the manifest entry whose fields should be rendered.
|
|
5612
|
+
* @returns the formatted field tree as a single string with a trailing newline.
|
|
5613
|
+
* @__NO_SIDE_EFFECTS__
|
|
5614
|
+
*/ function renderModelManifestFields(entry) {
|
|
5615
|
+
return renderFieldsTree(entry.fields, 0) + '\n';
|
|
5616
|
+
}
|
|
5617
|
+
function renderFieldsTree(fields, indent) {
|
|
5618
|
+
var out = [];
|
|
5619
|
+
var rows = [
|
|
5620
|
+
[
|
|
5621
|
+
'NAME',
|
|
5622
|
+
'LONG NAME',
|
|
5623
|
+
'TYPE',
|
|
5624
|
+
'OPTIONAL',
|
|
5625
|
+
'CONVERTER'
|
|
5626
|
+
]
|
|
5627
|
+
];
|
|
5628
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
5629
|
+
try {
|
|
5630
|
+
for(var _iterator = fields[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
5631
|
+
var field = _step.value;
|
|
5632
|
+
var _field_tsType;
|
|
5633
|
+
rows.push([
|
|
5634
|
+
field.name,
|
|
5635
|
+
field.longName,
|
|
5636
|
+
(_field_tsType = field.tsType) !== null && _field_tsType !== void 0 ? _field_tsType : '',
|
|
5637
|
+
field.optional ? 'yes' : 'no',
|
|
5638
|
+
truncate(field.converter, 60)
|
|
5639
|
+
]);
|
|
5640
|
+
}
|
|
5641
|
+
} catch (err) {
|
|
5642
|
+
_didIteratorError = true;
|
|
5643
|
+
_iteratorError = err;
|
|
5644
|
+
} finally{
|
|
5645
|
+
try {
|
|
5646
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
5647
|
+
_iterator.return();
|
|
5648
|
+
}
|
|
5649
|
+
} finally{
|
|
5650
|
+
if (_didIteratorError) {
|
|
5651
|
+
throw _iteratorError;
|
|
5652
|
+
}
|
|
5653
|
+
}
|
|
5654
|
+
}
|
|
5655
|
+
out.push(indentLines$1(renderTable(rows), indent));
|
|
5656
|
+
var _iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = undefined;
|
|
5657
|
+
try {
|
|
5658
|
+
for(var _iterator1 = fields[Symbol.iterator](), _step1; !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true){
|
|
5659
|
+
var field1 = _step1.value;
|
|
5660
|
+
if (field1.nestedFields && field1.nestedFields.length > 0) {
|
|
5661
|
+
var label = field1.nestedIsArray ? 'array element' : 'sub-object';
|
|
5662
|
+
out.push(indentLines$1("↳ ".concat(field1.name, " (").concat(label, ", ").concat(field1.nestedFields.length, " field").concat(field1.nestedFields.length === 1 ? '' : 's', ")"), indent + 2));
|
|
5663
|
+
out.push(renderFieldsTree(field1.nestedFields, indent + 4));
|
|
5664
|
+
}
|
|
5665
|
+
}
|
|
5666
|
+
} catch (err) {
|
|
5667
|
+
_didIteratorError1 = true;
|
|
5668
|
+
_iteratorError1 = err;
|
|
5669
|
+
} finally{
|
|
5670
|
+
try {
|
|
5671
|
+
if (!_iteratorNormalCompletion1 && _iterator1.return != null) {
|
|
5672
|
+
_iterator1.return();
|
|
5673
|
+
}
|
|
5674
|
+
} finally{
|
|
5675
|
+
if (_didIteratorError1) {
|
|
5676
|
+
throw _iteratorError1;
|
|
5677
|
+
}
|
|
5678
|
+
}
|
|
5679
|
+
}
|
|
5680
|
+
return out.join('\n');
|
|
5681
|
+
}
|
|
5682
|
+
function renderTable(rows) {
|
|
5683
|
+
if (rows.length === 0) return '';
|
|
5684
|
+
var widths = [];
|
|
5685
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
5686
|
+
try {
|
|
5687
|
+
for(var _iterator = rows[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
5688
|
+
var row = _step.value;
|
|
5689
|
+
row.forEach(function(cell, i) {
|
|
5690
|
+
var _widths_i;
|
|
5691
|
+
var cellWidth = cell.length;
|
|
5692
|
+
widths[i] = Math.max((_widths_i = widths[i]) !== null && _widths_i !== void 0 ? _widths_i : 0, cellWidth);
|
|
5693
|
+
});
|
|
5694
|
+
}
|
|
5695
|
+
} catch (err) {
|
|
5696
|
+
_didIteratorError = true;
|
|
5697
|
+
_iteratorError = err;
|
|
5698
|
+
} finally{
|
|
5699
|
+
try {
|
|
5700
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
5701
|
+
_iterator.return();
|
|
5702
|
+
}
|
|
5703
|
+
} finally{
|
|
5704
|
+
if (_didIteratorError) {
|
|
5705
|
+
throw _iteratorError;
|
|
5706
|
+
}
|
|
5707
|
+
}
|
|
5708
|
+
}
|
|
5709
|
+
return rows.map(function(row) {
|
|
5710
|
+
return row.map(function(cell, i) {
|
|
5711
|
+
var _widths_i;
|
|
5712
|
+
return i === row.length - 1 ? cell : cell.padEnd((_widths_i = widths[i]) !== null && _widths_i !== void 0 ? _widths_i : 0);
|
|
5713
|
+
}).join(' ').replace(/\s+$/, '');
|
|
5714
|
+
}).join('\n');
|
|
5715
|
+
}
|
|
5716
|
+
function truncate(text, max) {
|
|
5717
|
+
if (text.length <= max) return text;
|
|
5718
|
+
return text.slice(0, max - 1) + '…';
|
|
5719
|
+
}
|
|
5720
|
+
function indentLines$1(text, indent) {
|
|
5721
|
+
if (indent <= 0) return text;
|
|
5722
|
+
var pad = ' '.repeat(indent);
|
|
5723
|
+
return text.split('\n').map(function(line) {
|
|
5724
|
+
return line.length > 0 ? pad + line : line;
|
|
5725
|
+
}).join('\n');
|
|
5726
|
+
}
|
|
5727
|
+
|
|
5728
|
+
/**
|
|
5729
|
+
* Default command name for the model-info command. Top-level so it stays out
|
|
5730
|
+
* of the API-call namespace owned by `model <model> <action>`.
|
|
5731
|
+
*/ var DEFAULT_MODEL_INFO_COMMAND_NAME = 'model-info';
|
|
5732
|
+
/**
|
|
5733
|
+
* Builds the top-level `model-info [model]` command.
|
|
5734
|
+
*
|
|
5735
|
+
* Without an argument: prints a column-aligned table summarising every model
|
|
5736
|
+
* in the manifest. With an argument: looks the model up by `modelType`,
|
|
5737
|
+
* `identityConst`, or `collectionPrefix` and prints its full per-field
|
|
5738
|
+
* documentation, recursing into nested converters when the manifest captured
|
|
5739
|
+
* them.
|
|
5740
|
+
*
|
|
5741
|
+
* Flags:
|
|
5742
|
+
* - `--json` emits a structured `{ ok, data }` envelope instead of the
|
|
5743
|
+
* human-readable table (useful for scripting or LLM agents).
|
|
5744
|
+
* - `--fields` prints only the field table for the resolved model.
|
|
5745
|
+
*
|
|
5746
|
+
* @param manifest - The generated model manifest (e.g. `DEMO_CLI_MODEL_MANIFEST`).
|
|
5747
|
+
* @param options - Optional overrides; see {@link BuildModelInfoCommandOptions}.
|
|
5748
|
+
* @returns A yargs `CommandModule` ready to be passed to `runCli({ configCommands })`.
|
|
5749
|
+
* @__NO_SIDE_EFFECTS__
|
|
5750
|
+
*/ function buildModelInfoCommand(manifest, options) {
|
|
5751
|
+
var _ref;
|
|
5752
|
+
var commandName = (_ref = options === null || options === void 0 ? void 0 : options.commandName) !== null && _ref !== void 0 ? _ref : DEFAULT_MODEL_INFO_COMMAND_NAME;
|
|
5753
|
+
return {
|
|
5754
|
+
command: "".concat(commandName, " [model]"),
|
|
5755
|
+
describe: "Show generated catalog and field info for Firestore models (".concat(manifest.length, " model").concat(manifest.length === 1 ? '' : 's', ")."),
|
|
5756
|
+
builder: function builder(yargs) {
|
|
5757
|
+
return yargs.positional('model', {
|
|
5758
|
+
type: 'string',
|
|
5759
|
+
describe: 'Model to inspect (modelType, identity const, or collection prefix). Omit to list every model.'
|
|
5760
|
+
}).option('json', {
|
|
5761
|
+
type: 'boolean',
|
|
5762
|
+
default: false,
|
|
5763
|
+
describe: 'Emit a structured JSON envelope instead of the human-readable table.'
|
|
5764
|
+
}).option('fields', {
|
|
5765
|
+
type: 'boolean',
|
|
5766
|
+
default: false,
|
|
5767
|
+
describe: 'Print only the field table for the resolved model.'
|
|
5768
|
+
});
|
|
5769
|
+
},
|
|
5770
|
+
handler: function handler(argv) {
|
|
5771
|
+
try {
|
|
5772
|
+
runHandler(manifest, argv);
|
|
5773
|
+
} catch (e) {
|
|
5774
|
+
outputError(e);
|
|
5775
|
+
process.exit(1);
|
|
5776
|
+
}
|
|
5777
|
+
}
|
|
5778
|
+
};
|
|
5779
|
+
}
|
|
5780
|
+
function runHandler(manifest, argv) {
|
|
5781
|
+
var query = typeof argv.model === 'string' && argv.model.length > 0 ? argv.model : undefined;
|
|
5782
|
+
if (!query) {
|
|
5783
|
+
if (argv.json) {
|
|
5784
|
+
outputResult(manifest);
|
|
5785
|
+
return;
|
|
5786
|
+
}
|
|
5787
|
+
process.stdout.write(renderModelManifestList(manifest));
|
|
5788
|
+
return;
|
|
5789
|
+
}
|
|
5790
|
+
var entry = resolveCliModel(manifest, query);
|
|
5791
|
+
if (!entry) {
|
|
5792
|
+
throw new CliError({
|
|
5793
|
+
message: "No model matches '".concat(query, "'. Run `model-info` without an argument to list available models."),
|
|
5794
|
+
code: 'MODEL_INFO_NOT_FOUND'
|
|
5795
|
+
});
|
|
5796
|
+
}
|
|
5797
|
+
if (argv.json) {
|
|
5798
|
+
outputResult(entry);
|
|
5799
|
+
return;
|
|
5800
|
+
}
|
|
5801
|
+
if (argv.fields) {
|
|
5802
|
+
process.stdout.write(renderModelManifestFields(entry));
|
|
5803
|
+
return;
|
|
5804
|
+
}
|
|
5805
|
+
process.stdout.write(renderModelManifestEntry(entry));
|
|
5806
|
+
}
|
|
5807
|
+
|
|
5293
5808
|
function asyncGeneratorStep$6(gen, resolve, reject, _next, _throw, key, arg) {
|
|
5294
5809
|
try {
|
|
5295
5810
|
var info = gen[key](arg);
|
|
@@ -6717,6 +7232,10 @@ function _ts_generator$2(thisArg, body) {
|
|
|
6717
7232
|
* @param input.defaultEnvs - Built-in env presets shipped with the CLI.
|
|
6718
7233
|
* @param input.argv - Argv to parse. Defaults to `hideBin(process.argv)`.
|
|
6719
7234
|
* @param input.disableCallPassthrough - When `true`, omits the built-in `call` passthrough.
|
|
7235
|
+
* @param input.modelManifest - Optional Firestore model manifest. When provided, auto-wires the
|
|
7236
|
+
* built-in `model-info` command. Opt-in per app.
|
|
7237
|
+
* @param input.disableModelInfo - When `true`, suppresses the auto-wired `model-info` command even
|
|
7238
|
+
* if {@link CreateCliInput.modelManifest} is provided.
|
|
6720
7239
|
* @returns The configured yargs `Argv` ready to be `.parse()`-d.
|
|
6721
7240
|
* @__NO_SIDE_EFFECTS__
|
|
6722
7241
|
*/ function createCli(input) {
|
|
@@ -6741,6 +7260,9 @@ function _ts_generator$2(thisArg, body) {
|
|
|
6741
7260
|
cliName: cliName
|
|
6742
7261
|
})
|
|
6743
7262
|
];
|
|
7263
|
+
if (input.modelManifest && input.disableModelInfo !== true) {
|
|
7264
|
+
builtInConfigCommands.push(buildModelInfoCommand(input.modelManifest));
|
|
7265
|
+
}
|
|
6744
7266
|
var allConfigCommands = _to_consumable_array$1(builtInConfigCommands).concat(_to_consumable_array$1((_input_configCommands = input.configCommands) !== null && _input_configCommands !== void 0 ? _input_configCommands : []));
|
|
6745
7267
|
var builtInApiCommands = input.disableCallPassthrough ? [] : [
|
|
6746
7268
|
callPassthroughCommand
|
|
@@ -7198,7 +7720,8 @@ var DATA_HELP_FLAG = '--data-help';
|
|
|
7198
7720
|
var context = {
|
|
7199
7721
|
dataHelpFormat: dataHelpFormat,
|
|
7200
7722
|
helpMode: helpMode,
|
|
7201
|
-
hideOnFocus: hideOnFocus
|
|
7723
|
+
hideOnFocus: hideOnFocus,
|
|
7724
|
+
modelManifest: options === null || options === void 0 ? void 0 : options.modelManifest
|
|
7202
7725
|
};
|
|
7203
7726
|
return [
|
|
7204
7727
|
{
|
|
@@ -7362,6 +7885,7 @@ function buildEntryCommand(entry, context) {
|
|
|
7362
7885
|
var fallbackDescribe = "".concat(entry.verb).concat(specPart, " on ").concat(entry.model);
|
|
7363
7886
|
var describeOneLine = (_oneLineDescription = oneLineDescription(entry.description)) !== null && _oneLineDescription !== void 0 ? _oneLineDescription : fallbackDescribe;
|
|
7364
7887
|
var epilogue = buildEntryEpilogue(entry, context);
|
|
7888
|
+
var expandKeysAvailable = Boolean(context.modelManifest);
|
|
7365
7889
|
return {
|
|
7366
7890
|
command: action,
|
|
7367
7891
|
describe: describeOneLine,
|
|
@@ -7370,6 +7894,13 @@ function buildEntryCommand(entry, context) {
|
|
|
7370
7894
|
type: 'string',
|
|
7371
7895
|
describe: 'JSON-encoded payload (defaults to {} when omitted)'
|
|
7372
7896
|
});
|
|
7897
|
+
if (expandKeysAvailable) {
|
|
7898
|
+
y = y.option('expand-keys', {
|
|
7899
|
+
type: 'boolean',
|
|
7900
|
+
default: false,
|
|
7901
|
+
describe: "Rewrite the response payload's persisted short keys to their long-name form using the generated model manifest."
|
|
7902
|
+
});
|
|
7903
|
+
}
|
|
7373
7904
|
hideGlobalOptions(y, context.hideOnFocus);
|
|
7374
7905
|
return epilogue ? y.epilogue(epilogue) : y;
|
|
7375
7906
|
},
|
|
@@ -7387,7 +7918,10 @@ function buildEntryCommand(entry, context) {
|
|
|
7387
7918
|
]);
|
|
7388
7919
|
return [
|
|
7389
7920
|
4,
|
|
7390
|
-
callEntry(entry, typeof argv.data === 'string' ? argv.data : undefined
|
|
7921
|
+
callEntry(entry, typeof argv.data === 'string' ? argv.data : undefined, {
|
|
7922
|
+
expandKeys: expandKeysAvailable && argv.expandKeys === true,
|
|
7923
|
+
modelManifest: context.modelManifest
|
|
7924
|
+
})
|
|
7391
7925
|
];
|
|
7392
7926
|
case 1:
|
|
7393
7927
|
_state.sent();
|
|
@@ -7712,9 +8246,9 @@ function readArktypeExpression(entry) {
|
|
|
7712
8246
|
}
|
|
7713
8247
|
return result;
|
|
7714
8248
|
}
|
|
7715
|
-
function callEntry(entry, rawData) {
|
|
8249
|
+
function callEntry(entry, rawData, options) {
|
|
7716
8250
|
return _async_to_generator$1(function() {
|
|
7717
|
-
var ctx, data, params, result;
|
|
8251
|
+
var ctx, data, params, result, finalResult;
|
|
7718
8252
|
return _ts_generator$1(this, function(_state) {
|
|
7719
8253
|
switch(_state.label){
|
|
7720
8254
|
case 0:
|
|
@@ -7734,7 +8268,8 @@ function callEntry(entry, rawData) {
|
|
|
7734
8268
|
];
|
|
7735
8269
|
case 1:
|
|
7736
8270
|
result = _state.sent();
|
|
7737
|
-
|
|
8271
|
+
finalResult = options.expandKeys && options.modelManifest ? expandModelKeys(entry.model, result, options.modelManifest) : result;
|
|
8272
|
+
outputResult(finalResult);
|
|
7738
8273
|
return [
|
|
7739
8274
|
2
|
|
7740
8275
|
];
|
|
@@ -8295,6 +8830,7 @@ exports.DEFAULT_CLI_SECRET_PATTERNS = DEFAULT_CLI_SECRET_PATTERNS;
|
|
|
8295
8830
|
exports.DEFAULT_MANIFEST_HELP_DATA_FORMAT = DEFAULT_MANIFEST_HELP_DATA_FORMAT;
|
|
8296
8831
|
exports.DEFAULT_MANIFEST_HELP_MODE = DEFAULT_MANIFEST_HELP_MODE;
|
|
8297
8832
|
exports.DEFAULT_MANIFEST_MODEL_COMMAND_NAME = DEFAULT_MANIFEST_MODEL_COMMAND_NAME;
|
|
8833
|
+
exports.DEFAULT_MODEL_INFO_COMMAND_NAME = DEFAULT_MODEL_INFO_COMMAND_NAME;
|
|
8298
8834
|
exports.DUMP_MERGE_MODES = DUMP_MERGE_MODES;
|
|
8299
8835
|
exports.DUMP_OUTPUT_MODES = DUMP_OUTPUT_MODES;
|
|
8300
8836
|
exports.MODEL_WRITE_OIDC_SCOPES = MODEL_WRITE_OIDC_SCOPES;
|
|
@@ -8307,6 +8843,7 @@ exports.buildCliPaths = buildCliPaths;
|
|
|
8307
8843
|
exports.buildDumpFilePath = buildDumpFilePath;
|
|
8308
8844
|
exports.buildErrorOutput = buildErrorOutput;
|
|
8309
8845
|
exports.buildManifestCommands = buildManifestCommands;
|
|
8846
|
+
exports.buildModelInfoCommand = buildModelInfoCommand;
|
|
8310
8847
|
exports.callModelOverHttp = callModelOverHttp;
|
|
8311
8848
|
exports.callPassthroughCommand = callPassthroughCommand;
|
|
8312
8849
|
exports.configureCliErrorMapper = configureCliErrorMapper;
|
|
@@ -8329,9 +8866,11 @@ exports.detectHelpMode = detectHelpMode;
|
|
|
8329
8866
|
exports.discoverOidcMetadata = discoverOidcMetadata;
|
|
8330
8867
|
exports.dumpTimestamp = dumpTimestamp;
|
|
8331
8868
|
exports.exchangeAuthorizationCode = exchangeAuthorizationCode;
|
|
8869
|
+
exports.expandModelKeys = expandModelKeys;
|
|
8332
8870
|
exports.fetchUserInfo = fetchUserInfo;
|
|
8333
8871
|
exports.filterReadOnlyModelScopes = filterReadOnlyModelScopes;
|
|
8334
8872
|
exports.findCliEnvDefault = findCliEnvDefault;
|
|
8873
|
+
exports.findCliModelManifestEntry = findCliModelManifestEntry;
|
|
8335
8874
|
exports.generateOAuthState = generateOAuthState;
|
|
8336
8875
|
exports.generatePkceMaterial = generatePkceMaterial;
|
|
8337
8876
|
exports.getCliContext = getCliContext;
|
|
@@ -8350,8 +8889,12 @@ exports.parsePastedRedirect = parsePastedRedirect;
|
|
|
8350
8889
|
exports.pickFields = pickFields;
|
|
8351
8890
|
exports.promptLine = promptLine;
|
|
8352
8891
|
exports.refreshAccessToken = refreshAccessToken;
|
|
8892
|
+
exports.renderModelManifestEntry = renderModelManifestEntry;
|
|
8893
|
+
exports.renderModelManifestFields = renderModelManifestFields;
|
|
8894
|
+
exports.renderModelManifestList = renderModelManifestList;
|
|
8353
8895
|
exports.requireCliContext = requireCliContext;
|
|
8354
8896
|
exports.resolveActiveEnvName = resolveActiveEnvName;
|
|
8897
|
+
exports.resolveCliModel = resolveCliModel;
|
|
8355
8898
|
exports.resolveOutputConfig = resolveOutputConfig;
|
|
8356
8899
|
exports.revokeToken = revokeToken;
|
|
8357
8900
|
exports.runCli = runCli;
|