@warmhub/cli 0.98.0 → 0.100.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/wh.js +913 -521
- package/package.json +1 -1
package/dist/wh.js
CHANGED
|
@@ -20466,6 +20466,56 @@ function validateManifestSemantics(manifest) {
|
|
|
20466
20466
|
}
|
|
20467
20467
|
return findings;
|
|
20468
20468
|
}
|
|
20469
|
+
// ../../packages/rules/src/external-contract.ts
|
|
20470
|
+
var FORBIDDEN_EXTERNAL_FIELDS = new Set([
|
|
20471
|
+
"_id",
|
|
20472
|
+
"_creationTime",
|
|
20473
|
+
"repoId",
|
|
20474
|
+
"orgId",
|
|
20475
|
+
"thingId",
|
|
20476
|
+
"shapeThingId",
|
|
20477
|
+
"aboutThingId",
|
|
20478
|
+
"currentVersionId",
|
|
20479
|
+
"createdInCommitId",
|
|
20480
|
+
"validatedShapeVersionId"
|
|
20481
|
+
]);
|
|
20482
|
+
function isObject3(value) {
|
|
20483
|
+
return typeof value === "object" && value !== null;
|
|
20484
|
+
}
|
|
20485
|
+
function findForbiddenExternalFields(value) {
|
|
20486
|
+
const leaks = [];
|
|
20487
|
+
const seen = new WeakSet;
|
|
20488
|
+
const visit = (current, path) => {
|
|
20489
|
+
if (!isObject3(current))
|
|
20490
|
+
return;
|
|
20491
|
+
if (seen.has(current))
|
|
20492
|
+
return;
|
|
20493
|
+
seen.add(current);
|
|
20494
|
+
if (Array.isArray(current)) {
|
|
20495
|
+
for (const [index, child] of current.entries()) {
|
|
20496
|
+
visit(child, `${path}[${index}]`);
|
|
20497
|
+
}
|
|
20498
|
+
return;
|
|
20499
|
+
}
|
|
20500
|
+
for (const [key, child] of Object.entries(current)) {
|
|
20501
|
+
const nextPath = path === "$" ? `$.${key}` : `${path}.${key}`;
|
|
20502
|
+
if (FORBIDDEN_EXTERNAL_FIELDS.has(key)) {
|
|
20503
|
+
leaks.push({ key, path: nextPath });
|
|
20504
|
+
}
|
|
20505
|
+
visit(child, nextPath);
|
|
20506
|
+
}
|
|
20507
|
+
};
|
|
20508
|
+
visit(value, "$");
|
|
20509
|
+
return leaks;
|
|
20510
|
+
}
|
|
20511
|
+
function assertNoForbiddenExternalFields(value, context = "external payload") {
|
|
20512
|
+
const leaks = findForbiddenExternalFields(value);
|
|
20513
|
+
if (leaks.length === 0)
|
|
20514
|
+
return;
|
|
20515
|
+
const details = leaks.slice(0, 8).map((leak) => `${leak.path} (${leak.key})`).join(", ");
|
|
20516
|
+
const extra = leaks.length > 8 ? ` (+${leaks.length - 8} more)` : "";
|
|
20517
|
+
throw new Error(`Forbidden external identity field leak in ${context}: ${details}${extra}`);
|
|
20518
|
+
}
|
|
20469
20519
|
// ../../packages/rules/src/field-name-safety.ts
|
|
20470
20520
|
var ESCAPE_DISPLAY_MAX_CHARS = 120;
|
|
20471
20521
|
var DANGEROUS_FORMAT_CODEPOINTS = new Set([
|
|
@@ -21486,7 +21536,7 @@ __export(exports_util, {
|
|
|
21486
21536
|
joinValues: () => joinValues,
|
|
21487
21537
|
issue: () => issue,
|
|
21488
21538
|
isPlainObject: () => isPlainObject,
|
|
21489
|
-
isObject: () =>
|
|
21539
|
+
isObject: () => isObject4,
|
|
21490
21540
|
hexToUint8Array: () => hexToUint8Array,
|
|
21491
21541
|
getSizableOrigin: () => getSizableOrigin,
|
|
21492
21542
|
getParsedType: () => getParsedType,
|
|
@@ -21649,7 +21699,7 @@ function slugify(input) {
|
|
|
21649
21699
|
return input.toLowerCase().trim().replace(/[^\w\s-]/g, "").replace(/[\s_-]+/g, "-").replace(/^-+|-+$/g, "");
|
|
21650
21700
|
}
|
|
21651
21701
|
var captureStackTrace = "captureStackTrace" in Error ? Error.captureStackTrace : (..._args) => {};
|
|
21652
|
-
function
|
|
21702
|
+
function isObject4(data) {
|
|
21653
21703
|
return typeof data === "object" && data !== null && !Array.isArray(data);
|
|
21654
21704
|
}
|
|
21655
21705
|
var allowsEval = /* @__PURE__ */ cached(() => {
|
|
@@ -21668,7 +21718,7 @@ var allowsEval = /* @__PURE__ */ cached(() => {
|
|
|
21668
21718
|
}
|
|
21669
21719
|
});
|
|
21670
21720
|
function isPlainObject(o) {
|
|
21671
|
-
if (
|
|
21721
|
+
if (isObject4(o) === false)
|
|
21672
21722
|
return false;
|
|
21673
21723
|
const ctor = o.constructor;
|
|
21674
21724
|
if (ctor === undefined)
|
|
@@ -21676,7 +21726,7 @@ function isPlainObject(o) {
|
|
|
21676
21726
|
if (typeof ctor !== "function")
|
|
21677
21727
|
return true;
|
|
21678
21728
|
const prot = ctor.prototype;
|
|
21679
|
-
if (
|
|
21729
|
+
if (isObject4(prot) === false)
|
|
21680
21730
|
return false;
|
|
21681
21731
|
if (Object.prototype.hasOwnProperty.call(prot, "isPrototypeOf") === false) {
|
|
21682
21732
|
return false;
|
|
@@ -23885,13 +23935,13 @@ var $ZodObject = /* @__PURE__ */ $constructor("$ZodObject", (inst, def) => {
|
|
|
23885
23935
|
}
|
|
23886
23936
|
return propValues;
|
|
23887
23937
|
});
|
|
23888
|
-
const
|
|
23938
|
+
const isObject5 = isObject4;
|
|
23889
23939
|
const catchall = def.catchall;
|
|
23890
23940
|
let value;
|
|
23891
23941
|
inst._zod.parse = (payload, ctx) => {
|
|
23892
23942
|
value ?? (value = _normalized.value);
|
|
23893
23943
|
const input = payload.value;
|
|
23894
|
-
if (!
|
|
23944
|
+
if (!isObject5(input)) {
|
|
23895
23945
|
payload.issues.push({
|
|
23896
23946
|
expected: "object",
|
|
23897
23947
|
code: "invalid_type",
|
|
@@ -24018,7 +24068,7 @@ var $ZodObjectJIT = /* @__PURE__ */ $constructor("$ZodObjectJIT", (inst, def) =>
|
|
|
24018
24068
|
return (payload, ctx) => fn(shape, payload, ctx);
|
|
24019
24069
|
};
|
|
24020
24070
|
let fastpass;
|
|
24021
|
-
const
|
|
24071
|
+
const isObject5 = isObject4;
|
|
24022
24072
|
const jit = !globalConfig.jitless;
|
|
24023
24073
|
const allowsEval2 = allowsEval;
|
|
24024
24074
|
const fastEnabled = jit && allowsEval2.value;
|
|
@@ -24027,7 +24077,7 @@ var $ZodObjectJIT = /* @__PURE__ */ $constructor("$ZodObjectJIT", (inst, def) =>
|
|
|
24027
24077
|
inst._zod.parse = (payload, ctx) => {
|
|
24028
24078
|
value ?? (value = _normalized.value);
|
|
24029
24079
|
const input = payload.value;
|
|
24030
|
-
if (!
|
|
24080
|
+
if (!isObject5(input)) {
|
|
24031
24081
|
payload.issues.push({
|
|
24032
24082
|
expected: "object",
|
|
24033
24083
|
code: "invalid_type",
|
|
@@ -24203,7 +24253,7 @@ var $ZodDiscriminatedUnion = /* @__PURE__ */ $constructor("$ZodDiscriminatedUnio
|
|
|
24203
24253
|
});
|
|
24204
24254
|
inst._zod.parse = (payload, ctx) => {
|
|
24205
24255
|
const input = payload.value;
|
|
24206
|
-
if (!
|
|
24256
|
+
if (!isObject4(input)) {
|
|
24207
24257
|
payload.issues.push({
|
|
24208
24258
|
code: "invalid_type",
|
|
24209
24259
|
expected: "object",
|
|
@@ -42856,6 +42906,273 @@ function commitValidateRequestBodyBytes(input) {
|
|
|
42856
42906
|
return new TextEncoder().encode(encodeCommitValidateRequestBody(input)).byteLength;
|
|
42857
42907
|
}
|
|
42858
42908
|
|
|
42909
|
+
// ../../packages/rules/src/crockford-base32.ts
|
|
42910
|
+
var ALPHABET = "0123456789ABCDEFGHJKMNPQRSTVWXYZ";
|
|
42911
|
+
var DECODE_TABLE = new Uint8Array(256).fill(255);
|
|
42912
|
+
for (let i = 0;i < ALPHABET.length; i++) {
|
|
42913
|
+
const ch = ALPHABET.charCodeAt(i);
|
|
42914
|
+
DECODE_TABLE[ch] = i;
|
|
42915
|
+
if (ch >= 65)
|
|
42916
|
+
DECODE_TABLE[ch + 32] = i;
|
|
42917
|
+
}
|
|
42918
|
+
function encodeBytes(data) {
|
|
42919
|
+
const bitLen = data.length * 8;
|
|
42920
|
+
const charCount = Math.ceil(bitLen / 5);
|
|
42921
|
+
let out = "";
|
|
42922
|
+
for (let i = 0;i < charCount; i++) {
|
|
42923
|
+
const bitPos = i * 5;
|
|
42924
|
+
const byteIdx = bitPos >> 3;
|
|
42925
|
+
const bitOff = bitPos & 7;
|
|
42926
|
+
const b1 = data[byteIdx] ?? 0;
|
|
42927
|
+
let val;
|
|
42928
|
+
if (bitOff <= 3) {
|
|
42929
|
+
val = b1 >> 3 - bitOff & 31;
|
|
42930
|
+
} else {
|
|
42931
|
+
const b2 = data[byteIdx + 1] ?? 0;
|
|
42932
|
+
val = (b1 << bitOff - 3 | b2 >> 11 - bitOff) & 31;
|
|
42933
|
+
}
|
|
42934
|
+
out += ALPHABET[val];
|
|
42935
|
+
}
|
|
42936
|
+
return out;
|
|
42937
|
+
}
|
|
42938
|
+
function decodeBytes(encoded) {
|
|
42939
|
+
const byteLen = Math.floor(encoded.length * 5 / 8);
|
|
42940
|
+
const bytes = new Uint8Array(byteLen);
|
|
42941
|
+
let bitBuf = 0;
|
|
42942
|
+
let bitsInBuf = 0;
|
|
42943
|
+
let bytePos = 0;
|
|
42944
|
+
for (let i = 0;i < encoded.length; i++) {
|
|
42945
|
+
const ch = encoded.charCodeAt(i);
|
|
42946
|
+
const val = DECODE_TABLE[ch];
|
|
42947
|
+
if (val === undefined || val === 255)
|
|
42948
|
+
return null;
|
|
42949
|
+
bitBuf = bitBuf << 5 | val;
|
|
42950
|
+
bitsInBuf += 5;
|
|
42951
|
+
if (bitsInBuf >= 8) {
|
|
42952
|
+
bitsInBuf -= 8;
|
|
42953
|
+
if (bytePos < byteLen) {
|
|
42954
|
+
bytes[bytePos++] = bitBuf >> bitsInBuf & 255;
|
|
42955
|
+
}
|
|
42956
|
+
}
|
|
42957
|
+
}
|
|
42958
|
+
return bytes;
|
|
42959
|
+
}
|
|
42960
|
+
|
|
42961
|
+
// ../../packages/rules/src/durable-id.ts
|
|
42962
|
+
var THING_SCHEME = 1;
|
|
42963
|
+
var REPO_SCHEME = 2;
|
|
42964
|
+
var UUID_BYTES = 16;
|
|
42965
|
+
var CRC_BYTES = 4;
|
|
42966
|
+
function encodedLengthFor(payloadLen) {
|
|
42967
|
+
return Math.ceil((1 + payloadLen + CRC_BYTES) * 8 / 5);
|
|
42968
|
+
}
|
|
42969
|
+
var CRC32C_TABLE = (() => {
|
|
42970
|
+
const POLY = 2197175160;
|
|
42971
|
+
const table = new Uint32Array(256);
|
|
42972
|
+
for (let i = 0;i < 256; i++) {
|
|
42973
|
+
let crc = i;
|
|
42974
|
+
for (let j = 0;j < 8; j++) {
|
|
42975
|
+
crc = crc & 1 ? crc >>> 1 ^ POLY : crc >>> 1;
|
|
42976
|
+
}
|
|
42977
|
+
table[i] = crc >>> 0;
|
|
42978
|
+
}
|
|
42979
|
+
return table;
|
|
42980
|
+
})();
|
|
42981
|
+
function crc32c(data) {
|
|
42982
|
+
let crc = 4294967295;
|
|
42983
|
+
for (const byte of data) {
|
|
42984
|
+
crc = (crc >>> 8 ^ (CRC32C_TABLE[(crc ^ byte) & 255] ?? 0)) >>> 0;
|
|
42985
|
+
}
|
|
42986
|
+
return (crc ^ 4294967295) >>> 0;
|
|
42987
|
+
}
|
|
42988
|
+
function bytesToUuid(bytes, offset = 0) {
|
|
42989
|
+
const hex3 = Array.from(bytes.slice(offset, offset + 16)).map((b) => b.toString(16).padStart(2, "0")).join("");
|
|
42990
|
+
return [
|
|
42991
|
+
hex3.slice(0, 8),
|
|
42992
|
+
hex3.slice(8, 12),
|
|
42993
|
+
hex3.slice(12, 16),
|
|
42994
|
+
hex3.slice(16, 20),
|
|
42995
|
+
hex3.slice(20, 32)
|
|
42996
|
+
].join("-");
|
|
42997
|
+
}
|
|
42998
|
+
function unpackToken(scheme, token, payloadLen) {
|
|
42999
|
+
const stripped = token.startsWith("wh:") ? token.slice(3) : token;
|
|
43000
|
+
if (stripped.length !== encodedLengthFor(payloadLen))
|
|
43001
|
+
return null;
|
|
43002
|
+
const raw = decodeBytes(stripped);
|
|
43003
|
+
if (!raw || raw.length !== 1 + payloadLen + CRC_BYTES)
|
|
43004
|
+
return null;
|
|
43005
|
+
if (raw[0] !== scheme)
|
|
43006
|
+
return null;
|
|
43007
|
+
const crcOffset = 1 + payloadLen;
|
|
43008
|
+
const storedCrc = (raw[crcOffset] ?? 0) << 24 | (raw[crcOffset + 1] ?? 0) << 16 | (raw[crcOffset + 2] ?? 0) << 8 | (raw[crcOffset + 3] ?? 0);
|
|
43009
|
+
const computedCrc = crc32c(raw.slice(0, crcOffset));
|
|
43010
|
+
if (storedCrc >>> 0 !== computedCrc >>> 0)
|
|
43011
|
+
return null;
|
|
43012
|
+
if (encodeBytes(raw) !== stripped.toUpperCase())
|
|
43013
|
+
return null;
|
|
43014
|
+
return raw.slice(1, 1 + payloadLen);
|
|
43015
|
+
}
|
|
43016
|
+
function decodeDurableId(token) {
|
|
43017
|
+
const payload = unpackToken(THING_SCHEME, token, UUID_BYTES * 2);
|
|
43018
|
+
if (!payload)
|
|
43019
|
+
return null;
|
|
43020
|
+
return {
|
|
43021
|
+
repoId: bytesToUuid(payload, 0),
|
|
43022
|
+
thingId: bytesToUuid(payload, UUID_BYTES)
|
|
43023
|
+
};
|
|
43024
|
+
}
|
|
43025
|
+
var VERSION_SELECTOR_RE = /^(?:v0*[1-9]\d*|[Hh][Ee][Aa][Dd]|[Aa][Ll][Ll])$/;
|
|
43026
|
+
function parseDurableReferenceToken(raw) {
|
|
43027
|
+
const at = raw.lastIndexOf("@");
|
|
43028
|
+
const selector = at >= 0 && VERSION_SELECTOR_RE.test(raw.slice(at + 1)) ? raw.slice(at + 1) : null;
|
|
43029
|
+
const core2 = selector === null ? raw : raw.slice(0, at);
|
|
43030
|
+
if (decodeDurableId(core2) === null)
|
|
43031
|
+
return null;
|
|
43032
|
+
const stripped = core2.startsWith("wh:") ? core2.slice(3) : core2;
|
|
43033
|
+
return { durableId: stripped.toUpperCase(), selector };
|
|
43034
|
+
}
|
|
43035
|
+
function decodeRepoDurableId(token) {
|
|
43036
|
+
const payload = unpackToken(REPO_SCHEME, token, UUID_BYTES);
|
|
43037
|
+
if (!payload)
|
|
43038
|
+
return null;
|
|
43039
|
+
return { repoId: bytesToUuid(payload, 0) };
|
|
43040
|
+
}
|
|
43041
|
+
|
|
43042
|
+
// ../../packages/rules/src/json-string-walk.ts
|
|
43043
|
+
function walkJsonStringLeaves(value, spec) {
|
|
43044
|
+
const { childContext, onStringValue, onObjectKey } = spec;
|
|
43045
|
+
const stack = [{ value, context: spec.rootContext }];
|
|
43046
|
+
while (stack.length > 0) {
|
|
43047
|
+
const { value: current, context } = stack.pop();
|
|
43048
|
+
if (typeof current === "string") {
|
|
43049
|
+
onStringValue(current, context);
|
|
43050
|
+
continue;
|
|
43051
|
+
}
|
|
43052
|
+
if (Array.isArray(current)) {
|
|
43053
|
+
for (let i = current.length - 1;i >= 0; i--) {
|
|
43054
|
+
stack.push({ value: current[i], context: childContext(context, i) });
|
|
43055
|
+
}
|
|
43056
|
+
continue;
|
|
43057
|
+
}
|
|
43058
|
+
if (!isPlainObject2(current))
|
|
43059
|
+
continue;
|
|
43060
|
+
const entries = Object.entries(current).map(([key, nested]) => [key, childContext(context, key), nested]);
|
|
43061
|
+
if (onObjectKey) {
|
|
43062
|
+
for (const [key, keyContext] of entries) {
|
|
43063
|
+
onObjectKey(key, keyContext);
|
|
43064
|
+
}
|
|
43065
|
+
}
|
|
43066
|
+
for (let i = entries.length - 1;i >= 0; i--) {
|
|
43067
|
+
const entry = entries[i];
|
|
43068
|
+
if (entry)
|
|
43069
|
+
stack.push({ value: entry[2], context: entry[1] });
|
|
43070
|
+
}
|
|
43071
|
+
}
|
|
43072
|
+
}
|
|
43073
|
+
|
|
43074
|
+
// ../../packages/rules/src/durable-token-collection.ts
|
|
43075
|
+
function collectDurableTokens(value) {
|
|
43076
|
+
const tokens = new Set;
|
|
43077
|
+
walkJsonStringLeaves(value, {
|
|
43078
|
+
rootContext: { key: null, parentKey: null, insideData: false },
|
|
43079
|
+
childContext: (parent, key) => ({
|
|
43080
|
+
key,
|
|
43081
|
+
parentKey: parent.key,
|
|
43082
|
+
insideData: parent.insideData || key === "data"
|
|
43083
|
+
}),
|
|
43084
|
+
onStringValue: (leaf, context) => {
|
|
43085
|
+
if (context.key === "durableId" && context.parentKey === "metadata" && !context.insideData) {
|
|
43086
|
+
return;
|
|
43087
|
+
}
|
|
43088
|
+
const parsed = parseDurableReferenceToken(leaf);
|
|
43089
|
+
if (parsed)
|
|
43090
|
+
tokens.add(parsed.durableId);
|
|
43091
|
+
}
|
|
43092
|
+
});
|
|
43093
|
+
return tokens;
|
|
43094
|
+
}
|
|
43095
|
+
|
|
43096
|
+
// ../../packages/sdk-ts/src/decoration.ts
|
|
43097
|
+
function buildDecorations(items) {
|
|
43098
|
+
const decorations = {};
|
|
43099
|
+
for (const item of items) {
|
|
43100
|
+
decorations[item.durableId] = item.canonicalWref;
|
|
43101
|
+
}
|
|
43102
|
+
return decorations;
|
|
43103
|
+
}
|
|
43104
|
+
function isObjectPayload(data) {
|
|
43105
|
+
return typeof data === "object" && data !== null && !Array.isArray(data);
|
|
43106
|
+
}
|
|
43107
|
+
function getResponseDecorations(result) {
|
|
43108
|
+
if (!isObjectPayload(result))
|
|
43109
|
+
return;
|
|
43110
|
+
const decorations = result.decorations;
|
|
43111
|
+
return isObjectPayload(decorations) ? decorations : undefined;
|
|
43112
|
+
}
|
|
43113
|
+
function markDecorationFailure(error51) {
|
|
43114
|
+
const marked = error51 instanceof Error ? error51 : new Error(String(error51));
|
|
43115
|
+
return Object.assign(marked, { decorationFailure: true });
|
|
43116
|
+
}
|
|
43117
|
+
function createDecorationLink(deps) {
|
|
43118
|
+
return () => ({ op, next }) => {
|
|
43119
|
+
if (!deps.enabled || op.type !== "query" || op.path === "thing.headVersions") {
|
|
43120
|
+
return next(op);
|
|
43121
|
+
}
|
|
43122
|
+
return observable((observer) => {
|
|
43123
|
+
let cancelled = false;
|
|
43124
|
+
let upstreamDone = false;
|
|
43125
|
+
let lookupInFlight = false;
|
|
43126
|
+
const maybeComplete = () => {
|
|
43127
|
+
if (!cancelled && upstreamDone && !lookupInFlight) {
|
|
43128
|
+
observer.complete();
|
|
43129
|
+
}
|
|
43130
|
+
};
|
|
43131
|
+
const subscription = next(op).subscribe({
|
|
43132
|
+
next: (envelope) => {
|
|
43133
|
+
const data = envelope.result?.data;
|
|
43134
|
+
if (!isObjectPayload(data)) {
|
|
43135
|
+
observer.next(envelope);
|
|
43136
|
+
return;
|
|
43137
|
+
}
|
|
43138
|
+
const tokens = collectDurableTokens(data);
|
|
43139
|
+
if (tokens.size === 0) {
|
|
43140
|
+
observer.next(envelope);
|
|
43141
|
+
return;
|
|
43142
|
+
}
|
|
43143
|
+
lookupInFlight = true;
|
|
43144
|
+
deps.getClient().thing.headVersions(undefined, undefined, [...tokens]).then(({ items }) => {
|
|
43145
|
+
if (cancelled)
|
|
43146
|
+
return;
|
|
43147
|
+
observer.next({
|
|
43148
|
+
...envelope,
|
|
43149
|
+
result: {
|
|
43150
|
+
...envelope.result,
|
|
43151
|
+
data: { ...data, decorations: buildDecorations(items) }
|
|
43152
|
+
}
|
|
43153
|
+
});
|
|
43154
|
+
}).catch((error51) => {
|
|
43155
|
+
if (cancelled)
|
|
43156
|
+
return;
|
|
43157
|
+
observer.error(TRPCClientError.from(markDecorationFailure(error51)));
|
|
43158
|
+
}).finally(() => {
|
|
43159
|
+
lookupInFlight = false;
|
|
43160
|
+
maybeComplete();
|
|
43161
|
+
});
|
|
43162
|
+
},
|
|
43163
|
+
error: (error51) => observer.error(error51),
|
|
43164
|
+
complete: () => {
|
|
43165
|
+
upstreamDone = true;
|
|
43166
|
+
maybeComplete();
|
|
43167
|
+
}
|
|
43168
|
+
});
|
|
43169
|
+
return () => {
|
|
43170
|
+
cancelled = true;
|
|
43171
|
+
subscription.unsubscribe();
|
|
43172
|
+
};
|
|
43173
|
+
});
|
|
43174
|
+
};
|
|
43175
|
+
}
|
|
42859
43176
|
// ../../packages/sdk-ts/src/grant-client.ts
|
|
42860
43177
|
function createGrantClient(getTrpc, mapError) {
|
|
42861
43178
|
return {
|
|
@@ -44164,7 +44481,7 @@ function createStreamingSubmissionHandle(input, deps) {
|
|
|
44164
44481
|
// ../../packages/sdk-ts/package.json
|
|
44165
44482
|
var package_default = {
|
|
44166
44483
|
name: "@warmhub/sdk-ts",
|
|
44167
|
-
version: "0.
|
|
44484
|
+
version: "0.98.0",
|
|
44168
44485
|
private: false,
|
|
44169
44486
|
type: "module",
|
|
44170
44487
|
description: "The TypeScript SDK for WarmHub — create repos, commit and query data, and compound knowledge with your AI agents.",
|
|
@@ -44272,7 +44589,6 @@ var package_default = {
|
|
|
44272
44589
|
react: "19.2.6",
|
|
44273
44590
|
tsup: "8.5.1",
|
|
44274
44591
|
typedoc: "0.28.19",
|
|
44275
|
-
"typedoc-plugin-markdown": "4.11.0",
|
|
44276
44592
|
typescript: "catalog:",
|
|
44277
44593
|
vitest: "catalog:"
|
|
44278
44594
|
}
|
|
@@ -44343,15 +44659,17 @@ function isProductionApiUrl(apiUrl, productionApiUrl) {
|
|
|
44343
44659
|
}
|
|
44344
44660
|
}
|
|
44345
44661
|
// ../../packages/sdk-ts/src/index.ts
|
|
44346
|
-
var
|
|
44347
|
-
|
|
44348
|
-
|
|
44349
|
-
|
|
44350
|
-
|
|
44351
|
-
|
|
44352
|
-
|
|
44353
|
-
|
|
44354
|
-
|
|
44662
|
+
var WARMHUB_CLIENT_OPTIONS = {
|
|
44663
|
+
apiUrl: true,
|
|
44664
|
+
fetch: true,
|
|
44665
|
+
accessToken: true,
|
|
44666
|
+
auth: true,
|
|
44667
|
+
functionLogs: true,
|
|
44668
|
+
client: true,
|
|
44669
|
+
clientFlags: true,
|
|
44670
|
+
decorateResponses: true
|
|
44671
|
+
};
|
|
44672
|
+
var WARMHUB_CLIENT_OPTION_NAMES = Object.keys(WARMHUB_CLIENT_OPTIONS);
|
|
44355
44673
|
var WARMHUB_CLIENT_OPTION_NAME_SET = new Set(WARMHUB_CLIENT_OPTION_NAMES);
|
|
44356
44674
|
var ACCESS_TOKEN_OPTION_ALIASES = new Set(["token", "apiKey", "bearer"]);
|
|
44357
44675
|
function validateWarmHubClientOptions(options) {
|
|
@@ -44719,6 +45037,7 @@ class WarmHubClient {
|
|
|
44719
45037
|
accessToken;
|
|
44720
45038
|
clientIdentity;
|
|
44721
45039
|
clientFlags;
|
|
45040
|
+
decorateResponses;
|
|
44722
45041
|
functionLogMode;
|
|
44723
45042
|
getToken;
|
|
44724
45043
|
compatibilityCheck;
|
|
@@ -46674,6 +46993,7 @@ class WarmHubClient {
|
|
|
46674
46993
|
version: options?.client?.version ?? SDK_VERSION
|
|
46675
46994
|
};
|
|
46676
46995
|
this.clientFlags = normalizeClientFlags(options?.clientFlags);
|
|
46996
|
+
this.decorateResponses = options?.decorateResponses ?? false;
|
|
46677
46997
|
if (typeof this.accessToken === "function") {
|
|
46678
46998
|
const provider = this.accessToken;
|
|
46679
46999
|
this.getToken = async () => await provider();
|
|
@@ -46687,6 +47007,10 @@ class WarmHubClient {
|
|
|
46687
47007
|
value: createTRPCClient({
|
|
46688
47008
|
links: [
|
|
46689
47009
|
this.createCompatibilityLink(),
|
|
47010
|
+
createDecorationLink({
|
|
47011
|
+
enabled: this.decorateResponses,
|
|
47012
|
+
getClient: () => this
|
|
47013
|
+
}),
|
|
46690
47014
|
splitLink({
|
|
46691
47015
|
condition: (op) => UNBATCHED_TRPC_PATHS.has(op.path),
|
|
46692
47016
|
true: httpLink({ url: url2, fetch: fetch2, methodOverride: "POST" }),
|
|
@@ -46705,7 +47029,8 @@ class WarmHubClient {
|
|
|
46705
47029
|
fetch: this.fetchImpl,
|
|
46706
47030
|
accessToken,
|
|
46707
47031
|
client: this.clientIdentity,
|
|
46708
|
-
clientFlags: this.clientFlags
|
|
47032
|
+
clientFlags: this.clientFlags,
|
|
47033
|
+
decorateResponses: this.decorateResponses
|
|
46709
47034
|
});
|
|
46710
47035
|
}
|
|
46711
47036
|
actions = this.action;
|
|
@@ -47404,7 +47729,15 @@ function printCliError(err, errWriter, opts = {}) {
|
|
|
47404
47729
|
|
|
47405
47730
|
// ../../packages/warmhub-cli/src/errors.ts
|
|
47406
47731
|
function fromWh(exit, kind, err, hint = err.hint) {
|
|
47407
|
-
return new CliError(exit, kind, err.message, err, hint, undefined, err.errorCode);
|
|
47732
|
+
return appendDecorationHint(err, new CliError(exit, kind, err.message, err, hint, undefined, err.errorCode));
|
|
47733
|
+
}
|
|
47734
|
+
var DECORATION_FAILURE_HINT = "This failure came from the --decorate label lookup; the read itself may be fine. Retry with --no-decorate to skip decoration.";
|
|
47735
|
+
function appendDecorationHint(err, cliError) {
|
|
47736
|
+
if (err.decorationFailure !== true)
|
|
47737
|
+
return cliError;
|
|
47738
|
+
const hint = cliError.hint ? `${cliError.hint}
|
|
47739
|
+
${DECORATION_FAILURE_HINT}` : DECORATION_FAILURE_HINT;
|
|
47740
|
+
return new CliError(cliError.code, cliError.kind, cliError.message, cliError.cause, hint, cliError.context, cliError.backendCode, cliError.recovery);
|
|
47408
47741
|
}
|
|
47409
47742
|
function classifyAuthError(input) {
|
|
47410
47743
|
if (input.code !== "UNAUTHENTICATED" && input.code !== "FORBIDDEN") {
|
|
@@ -47464,7 +47797,7 @@ function toCliError(err) {
|
|
|
47464
47797
|
backendCode: err.errorCode
|
|
47465
47798
|
});
|
|
47466
47799
|
if (authError)
|
|
47467
|
-
return authError;
|
|
47800
|
+
return appendDecorationHint(err, authError);
|
|
47468
47801
|
if (isFieldIndexErrorCode(err.code)) {
|
|
47469
47802
|
const exit = err.code === "FIELD_NOT_INDEXABLE" ? 2 /* UserInput */ : 4 /* Backend */;
|
|
47470
47803
|
return fromWh(exit, err.code, err);
|
|
@@ -48941,11 +49274,18 @@ async function modifyStore(mutator, path) {
|
|
|
48941
49274
|
return result;
|
|
48942
49275
|
});
|
|
48943
49276
|
}
|
|
48944
|
-
async function saveProfileWithFlagsLocked(name, profile, flags, path) {
|
|
49277
|
+
async function saveProfileWithFlagsLocked(name, profile, flags, decorate, path) {
|
|
48945
49278
|
await modifyStore((store) => {
|
|
48946
|
-
const stored = hasProfile(store, name) ? store.profiles[name]
|
|
48947
|
-
const
|
|
48948
|
-
|
|
49279
|
+
const stored = hasProfile(store, name) ? store.profiles[name] : undefined;
|
|
49280
|
+
const resolvedFlags = flags ?? (Array.isArray(stored?.flags) ? stored.flags : undefined);
|
|
49281
|
+
const resolvedDecorate = decorate ?? stored?.settings?.decorate;
|
|
49282
|
+
const next = { ...profile };
|
|
49283
|
+
if (resolvedFlags?.length)
|
|
49284
|
+
next.flags = [...resolvedFlags];
|
|
49285
|
+
if (resolvedDecorate !== undefined) {
|
|
49286
|
+
next.settings = { decorate: resolvedDecorate };
|
|
49287
|
+
}
|
|
49288
|
+
setProfile(store, name, next);
|
|
48949
49289
|
}, path);
|
|
48950
49290
|
}
|
|
48951
49291
|
async function deleteProfileLocked(name, path) {
|
|
@@ -49326,7 +49666,8 @@ function createClient(config2, opts = {}) {
|
|
|
49326
49666
|
fetch: createBenchmarkAwareFetch(benchmarkId, opts.signal),
|
|
49327
49667
|
functionLogs: opts.functionLogs,
|
|
49328
49668
|
client: cliClientIdentity(),
|
|
49329
|
-
clientFlags: opts.clientFlags
|
|
49669
|
+
clientFlags: opts.clientFlags,
|
|
49670
|
+
decorateResponses: opts.decorateResponses
|
|
49330
49671
|
});
|
|
49331
49672
|
}
|
|
49332
49673
|
function createUnauthenticatedClient(config2, opts = {}) {
|
|
@@ -49336,7 +49677,8 @@ function createUnauthenticatedClient(config2, opts = {}) {
|
|
|
49336
49677
|
fetch: createBenchmarkAwareFetch(benchmarkId, opts.signal),
|
|
49337
49678
|
functionLogs: opts.functionLogs,
|
|
49338
49679
|
client: cliClientIdentity(),
|
|
49339
|
-
clientFlags: opts.clientFlags
|
|
49680
|
+
clientFlags: opts.clientFlags,
|
|
49681
|
+
decorateResponses: opts.decorateResponses
|
|
49340
49682
|
});
|
|
49341
49683
|
}
|
|
49342
49684
|
function wantsStructuredLiveOutput(format) {
|
|
@@ -49370,7 +49712,8 @@ async function runLive(opts) {
|
|
|
49370
49712
|
fetch: createBenchmarkAwareFetch(benchmarkId, controller.signal),
|
|
49371
49713
|
functionLogs: opts.functionLogs,
|
|
49372
49714
|
client: cliClientIdentity(),
|
|
49373
|
-
clientFlags: opts.clientFlags
|
|
49715
|
+
clientFlags: opts.clientFlags,
|
|
49716
|
+
decorateResponses: opts.decorateResponses
|
|
49374
49717
|
});
|
|
49375
49718
|
if (opts.signal) {
|
|
49376
49719
|
if (opts.signal.aborted)
|
|
@@ -49725,6 +50068,24 @@ var FLAG_CATALOG = [
|
|
|
49725
50068
|
description: "Emit a dispatch plan; commit submit instead runs server validation"
|
|
49726
50069
|
}
|
|
49727
50070
|
},
|
|
50071
|
+
{
|
|
50072
|
+
scope: "global",
|
|
50073
|
+
spec: {
|
|
50074
|
+
long: "decorate",
|
|
50075
|
+
type: "boolean",
|
|
50076
|
+
description: "Resolve durable-id references to labels (default: on; adds label lookups when references are present)",
|
|
50077
|
+
conflictsWith: ["no-decorate"]
|
|
50078
|
+
}
|
|
50079
|
+
},
|
|
50080
|
+
{
|
|
50081
|
+
scope: "global",
|
|
50082
|
+
spec: {
|
|
50083
|
+
long: "no-decorate",
|
|
50084
|
+
type: "boolean",
|
|
50085
|
+
description: "Render durable-id references as raw tokens (no lookup)",
|
|
50086
|
+
conflictsWith: ["decorate"]
|
|
50087
|
+
}
|
|
50088
|
+
},
|
|
49728
50089
|
{
|
|
49729
50090
|
scope: "root",
|
|
49730
50091
|
spec: {
|
|
@@ -49734,6 +50095,11 @@ var FLAG_CATALOG = [
|
|
|
49734
50095
|
}
|
|
49735
50096
|
}
|
|
49736
50097
|
];
|
|
50098
|
+
function explicitDecorateFlag(flags) {
|
|
50099
|
+
if (flags["no-decorate"] === true)
|
|
50100
|
+
return false;
|
|
50101
|
+
return typeof flags.decorate === "boolean" ? flags.decorate : undefined;
|
|
50102
|
+
}
|
|
49737
50103
|
var GLOBAL_FLAG_SPECS = FLAG_CATALOG.filter((entry) => entry.scope === "global").map((entry) => entry.spec);
|
|
49738
50104
|
var CONTEXTUAL_CONTROL_SPECS = FLAG_CATALOG.filter((entry) => entry.scope === "contextual").map((entry) => entry.spec);
|
|
49739
50105
|
var ROOT_CONTROL_SPECS = FLAG_CATALOG.filter((entry) => entry.scope === "root").map((entry) => entry.spec);
|
|
@@ -50252,6 +50618,23 @@ function isInstallSnapshotCacheShape(value) {
|
|
|
50252
50618
|
return true;
|
|
50253
50619
|
}
|
|
50254
50620
|
|
|
50621
|
+
// ../../packages/warmhub-cli/src/pagination.ts
|
|
50622
|
+
async function* paginatePages2(args) {
|
|
50623
|
+
let cursor = args.initialCursor;
|
|
50624
|
+
const seenCursors = new Set(cursor ? [cursor] : []);
|
|
50625
|
+
while (true) {
|
|
50626
|
+
const page = await args.fetchPage(cursor);
|
|
50627
|
+
yield page;
|
|
50628
|
+
if (!page.nextCursor)
|
|
50629
|
+
return;
|
|
50630
|
+
if (seenCursors.has(page.nextCursor)) {
|
|
50631
|
+
throw new CliError(4 /* Backend */, "BACKEND", `${args.title} pagination cursor repeated; aborting pagination to avoid an infinite loop.`, undefined, "Retry the operation. If cursors continue to repeat, report this as a backend pagination issue.");
|
|
50632
|
+
}
|
|
50633
|
+
seenCursors.add(page.nextCursor);
|
|
50634
|
+
cursor = page.nextCursor;
|
|
50635
|
+
}
|
|
50636
|
+
}
|
|
50637
|
+
|
|
50255
50638
|
// ../../packages/warmhub-cli/src/install-snapshot-cache.ts
|
|
50256
50639
|
var INSTALL_SNAPSHOT_TTL_MS = 5 * 60 * 1000;
|
|
50257
50640
|
function loadInstallSnapshotCache(repoSlug) {
|
|
@@ -50388,15 +50771,15 @@ async function refreshFromSummaries(repoSlug, parsed, activeItems, client, now,
|
|
|
50388
50771
|
}
|
|
50389
50772
|
async function fetchAllSummaries(client, org, repo) {
|
|
50390
50773
|
const items = [];
|
|
50391
|
-
|
|
50392
|
-
|
|
50393
|
-
const page = await client.component.list(org, repo, {
|
|
50774
|
+
for await (const page of paginatePages2({
|
|
50775
|
+
fetchPage: (cursor) => client.component.list(org, repo, {
|
|
50394
50776
|
limit: 500,
|
|
50395
50777
|
cursor
|
|
50396
|
-
})
|
|
50778
|
+
}),
|
|
50779
|
+
title: "Component install snapshot"
|
|
50780
|
+
})) {
|
|
50397
50781
|
items.push(...page.items);
|
|
50398
|
-
|
|
50399
|
-
} while (cursor);
|
|
50782
|
+
}
|
|
50400
50783
|
return items;
|
|
50401
50784
|
}
|
|
50402
50785
|
function filterActiveItems(items) {
|
|
@@ -50699,55 +51082,27 @@ function findClosest(input, candidates, maxDistance = 2) {
|
|
|
50699
51082
|
return best;
|
|
50700
51083
|
}
|
|
50701
51084
|
|
|
50702
|
-
// ../../packages/warmhub-cli/src/
|
|
50703
|
-
|
|
50704
|
-
|
|
50705
|
-
|
|
50706
|
-
|
|
50707
|
-
|
|
50708
|
-
|
|
50709
|
-
|
|
50710
|
-
|
|
50711
|
-
|
|
50712
|
-
|
|
50713
|
-
|
|
50714
|
-
|
|
50715
|
-
function isObject4(value) {
|
|
50716
|
-
return typeof value === "object" && value !== null;
|
|
51085
|
+
// ../../packages/warmhub-cli/src/decorations.ts
|
|
51086
|
+
function rowDecorationsSubset(row, decorations) {
|
|
51087
|
+
if (decorations === undefined)
|
|
51088
|
+
return;
|
|
51089
|
+
let subset;
|
|
51090
|
+
for (const id of collectDurableTokens(row)) {
|
|
51091
|
+
const label = decorations[id];
|
|
51092
|
+
if (label === undefined)
|
|
51093
|
+
continue;
|
|
51094
|
+
subset ??= {};
|
|
51095
|
+
subset[id] = label;
|
|
51096
|
+
}
|
|
51097
|
+
return subset;
|
|
50717
51098
|
}
|
|
50718
|
-
function
|
|
50719
|
-
|
|
50720
|
-
|
|
50721
|
-
|
|
50722
|
-
if (!isObject4(current))
|
|
50723
|
-
return;
|
|
50724
|
-
if (seen.has(current))
|
|
50725
|
-
return;
|
|
50726
|
-
seen.add(current);
|
|
50727
|
-
if (Array.isArray(current)) {
|
|
50728
|
-
for (const [index, child] of current.entries()) {
|
|
50729
|
-
visit(child, `${path}[${index}]`);
|
|
50730
|
-
}
|
|
50731
|
-
return;
|
|
50732
|
-
}
|
|
50733
|
-
for (const [key, child] of Object.entries(current)) {
|
|
50734
|
-
const nextPath = path === "$" ? `$.${key}` : `${path}.${key}`;
|
|
50735
|
-
if (FORBIDDEN_EXTERNAL_FIELDS2.has(key)) {
|
|
50736
|
-
leaks.push({ key, path: nextPath });
|
|
50737
|
-
}
|
|
50738
|
-
visit(child, nextPath);
|
|
50739
|
-
}
|
|
50740
|
-
};
|
|
50741
|
-
visit(value, "$");
|
|
50742
|
-
return leaks;
|
|
51099
|
+
function mergeDecorations(into, page) {
|
|
51100
|
+
if (page === undefined)
|
|
51101
|
+
return into;
|
|
51102
|
+
return { ...into, ...page };
|
|
50743
51103
|
}
|
|
50744
|
-
function
|
|
50745
|
-
|
|
50746
|
-
if (leaks.length === 0)
|
|
50747
|
-
return;
|
|
50748
|
-
const details = leaks.slice(0, 8).map((leak) => `${leak.path} (${leak.key})`).join(", ");
|
|
50749
|
-
const extra = leaks.length > 8 ? ` (+${leaks.length - 8} more)` : "";
|
|
50750
|
-
throw new Error(`Forbidden external identity field leak in ${context}: ${details}${extra}`);
|
|
51104
|
+
function withDecorations(result, decorations) {
|
|
51105
|
+
return decorations === undefined ? result : Object.assign(result, { decorations });
|
|
50751
51106
|
}
|
|
50752
51107
|
|
|
50753
51108
|
// ../../packages/warmhub-cli/src/format.ts
|
|
@@ -50792,9 +51147,6 @@ function pinnedWref(c, wref, version2) {
|
|
|
50792
51147
|
const base = wref.replace(/@v\d+$/, "");
|
|
50793
51148
|
return `${c.cyan}${escapeTerminalTextForDisplay(base)}@v${version2}${c.reset}`;
|
|
50794
51149
|
}
|
|
50795
|
-
function formatAffirmedWrefs(c, wrefs) {
|
|
50796
|
-
return wrefs.map((wref) => pinnedWref(c, wref)).join(`${c.dim},${c.reset} `);
|
|
50797
|
-
}
|
|
50798
51150
|
function kindLabel(c, kind) {
|
|
50799
51151
|
return `${c.dim}${kind}${c.reset}`;
|
|
50800
51152
|
}
|
|
@@ -50935,11 +51287,11 @@ function renderSingleOpSuccess(out, c, chars, op, opts) {
|
|
|
50935
51287
|
renderWarningLine(out, c, chars, op);
|
|
50936
51288
|
}
|
|
50937
51289
|
function printJson(out, data) {
|
|
50938
|
-
|
|
51290
|
+
assertNoForbiddenExternalFields(data, "CLI JSON output");
|
|
50939
51291
|
out(JSON.stringify(data, null, 2));
|
|
50940
51292
|
}
|
|
50941
51293
|
function printJsonLine(out, data) {
|
|
50942
|
-
|
|
51294
|
+
assertNoForbiddenExternalFields(data, "CLI JSON output");
|
|
50943
51295
|
out(JSON.stringify(data) ?? "null");
|
|
50944
51296
|
}
|
|
50945
51297
|
function printJsonl(out, data) {
|
|
@@ -50973,6 +51325,7 @@ function pageEnvelope(items, opts) {
|
|
|
50973
51325
|
return {
|
|
50974
51326
|
items,
|
|
50975
51327
|
...opts.repoSeq === undefined ? {} : { repoSeq: opts.repoSeq },
|
|
51328
|
+
...opts.decorations === undefined ? {} : { decorations: opts.decorations },
|
|
50976
51329
|
page: {
|
|
50977
51330
|
limit: opts.limit,
|
|
50978
51331
|
count: items.length,
|
|
@@ -50987,11 +51340,22 @@ function writePageOutput(ctx, items, opts, prettyFn) {
|
|
|
50987
51340
|
return;
|
|
50988
51341
|
}
|
|
50989
51342
|
if (ctx.format === "jsonl") {
|
|
50990
|
-
printJsonl(ctx.out, items);
|
|
51343
|
+
printJsonl(ctx.out, decorateJsonlRows(items, opts.decorations));
|
|
50991
51344
|
return;
|
|
50992
51345
|
}
|
|
50993
51346
|
prettyFn();
|
|
50994
51347
|
}
|
|
51348
|
+
function decorateJsonlRows(items, decorations) {
|
|
51349
|
+
if (decorations === undefined)
|
|
51350
|
+
return items;
|
|
51351
|
+
return items.map((item) => {
|
|
51352
|
+
if (typeof item !== "object" || item === null || Array.isArray(item)) {
|
|
51353
|
+
return item;
|
|
51354
|
+
}
|
|
51355
|
+
const subset = rowDecorationsSubset(item, decorations);
|
|
51356
|
+
return subset === undefined ? item : { ...item, decorations: subset };
|
|
51357
|
+
});
|
|
51358
|
+
}
|
|
50995
51359
|
function emitPartialPageHint(ctx, count, _nextCursor, _limit) {
|
|
50996
51360
|
if (ctx.format === "json" || ctx.format === "jsonl")
|
|
50997
51361
|
return;
|
|
@@ -51011,6 +51375,110 @@ function identifyCommitSubmitOutput(value) {
|
|
|
51011
51375
|
return { schema: COMMIT_SUBMIT_OUTPUT_SCHEMA_ID, ...value };
|
|
51012
51376
|
}
|
|
51013
51377
|
|
|
51378
|
+
// ../../packages/warmhub-cli/src/durable-id-style.ts
|
|
51379
|
+
var REPO_TOKEN_LEN = 34;
|
|
51380
|
+
var HUE_REPO = "8A7C6A";
|
|
51381
|
+
var HUE_TIMESTAMP = "7E9BAC";
|
|
51382
|
+
var HUE_ENTROPY = "E8C378";
|
|
51383
|
+
var HUE_CRC = "74846B";
|
|
51384
|
+
var THING_BANDS = [
|
|
51385
|
+
{ start: 0, end: 28, weight: "faint", hex: HUE_REPO },
|
|
51386
|
+
{ start: 28, end: 37, weight: "normal", hex: HUE_TIMESTAMP },
|
|
51387
|
+
{ start: 37, end: 53, weight: "bold", hex: HUE_ENTROPY },
|
|
51388
|
+
{ start: 53, end: 60, weight: "faint", hex: HUE_CRC }
|
|
51389
|
+
];
|
|
51390
|
+
var REPO_BANDS = [
|
|
51391
|
+
{ start: 0, end: 28, weight: "faint", hex: HUE_REPO },
|
|
51392
|
+
{ start: 28, end: 34, weight: "faint", hex: HUE_CRC }
|
|
51393
|
+
];
|
|
51394
|
+
function fg(hex3) {
|
|
51395
|
+
const r = Number.parseInt(hex3.slice(0, 2), 16);
|
|
51396
|
+
const g = Number.parseInt(hex3.slice(2, 4), 16);
|
|
51397
|
+
const b = Number.parseInt(hex3.slice(4, 6), 16);
|
|
51398
|
+
return `\x1B[38;2;${r};${g};${b}m`;
|
|
51399
|
+
}
|
|
51400
|
+
function styleBand(text, band, c) {
|
|
51401
|
+
const weight = band.weight === "bold" ? c.bold : band.weight === "faint" ? c.dim : "";
|
|
51402
|
+
const hue = c.truecolor ? fg(band.hex) : "";
|
|
51403
|
+
const prefix = `${weight}${hue}`;
|
|
51404
|
+
return prefix === "" ? text : `${prefix}${text}${c.reset}`;
|
|
51405
|
+
}
|
|
51406
|
+
function styleDurableId(token, c) {
|
|
51407
|
+
if (c.reset === "")
|
|
51408
|
+
return token;
|
|
51409
|
+
const parsed = parseDurableReferenceToken(token);
|
|
51410
|
+
if (parsed) {
|
|
51411
|
+
const prefix = token.startsWith("wh:") ? "wh:" : "";
|
|
51412
|
+
const selector = parsed.selector === null ? "" : token.slice(token.lastIndexOf("@"));
|
|
51413
|
+
const core2 = token.slice(prefix.length, token.length - selector.length);
|
|
51414
|
+
return `${dimPart(prefix, c)}${styleBands(core2, THING_BANDS, c)}${dimPart(selector, c)}`;
|
|
51415
|
+
}
|
|
51416
|
+
if (token.length === REPO_TOKEN_LEN && decodeRepoDurableId(token)) {
|
|
51417
|
+
return styleBands(token, REPO_BANDS, c);
|
|
51418
|
+
}
|
|
51419
|
+
return token;
|
|
51420
|
+
}
|
|
51421
|
+
function dimPart(text, c) {
|
|
51422
|
+
return text === "" ? "" : `${c.dim}${text}${c.reset}`;
|
|
51423
|
+
}
|
|
51424
|
+
function styleBands(token, bands, c) {
|
|
51425
|
+
let out = "";
|
|
51426
|
+
for (const band of bands) {
|
|
51427
|
+
out += styleBand(token.slice(band.start, band.end), band, c);
|
|
51428
|
+
}
|
|
51429
|
+
return out;
|
|
51430
|
+
}
|
|
51431
|
+
|
|
51432
|
+
// ../../packages/warmhub-cli/src/reference-display.ts
|
|
51433
|
+
function decoratedRef(c, value, decorations) {
|
|
51434
|
+
const parsed = parseDurableReferenceToken(value);
|
|
51435
|
+
if (!parsed)
|
|
51436
|
+
return null;
|
|
51437
|
+
const label = decorations?.[parsed.durableId];
|
|
51438
|
+
if (label === undefined)
|
|
51439
|
+
return styleDurableId(value, c);
|
|
51440
|
+
return labeledRef(c, value, label);
|
|
51441
|
+
}
|
|
51442
|
+
function labeledRef(c, value, label) {
|
|
51443
|
+
const parsed = parseDurableReferenceToken(value);
|
|
51444
|
+
if (!parsed)
|
|
51445
|
+
return null;
|
|
51446
|
+
const styled = styleDurableId(value, c);
|
|
51447
|
+
const pin = parsed.selector !== null && /^v/i.test(parsed.selector) ? Number.parseInt(parsed.selector.slice(1), 10) : undefined;
|
|
51448
|
+
return `${pinnedWref(c, label, pin)} ${c.dim}(${c.reset}${styled}${c.dim})${c.reset}`;
|
|
51449
|
+
}
|
|
51450
|
+
function refDisplay(c, value, decorations, version2) {
|
|
51451
|
+
return decoratedRef(c, value, decorations) ?? pinnedWref(c, value, version2);
|
|
51452
|
+
}
|
|
51453
|
+
function refList(c, wrefs, decorations) {
|
|
51454
|
+
return wrefs.map((wref) => refDisplay(c, wref, decorations)).join(`${c.dim},${c.reset} `);
|
|
51455
|
+
}
|
|
51456
|
+
var JSON_LINE_STRING_VALUE_RE = /"([^"\\]+)",?$/;
|
|
51457
|
+
function jsonLineLabelSuffix(c, rawLine, decorations) {
|
|
51458
|
+
if (decorations === undefined)
|
|
51459
|
+
return "";
|
|
51460
|
+
const match = JSON_LINE_STRING_VALUE_RE.exec(rawLine);
|
|
51461
|
+
if (!match || match[1] === undefined)
|
|
51462
|
+
return "";
|
|
51463
|
+
const parsed = parseDurableReferenceToken(match[1]);
|
|
51464
|
+
const label = parsed ? decorations[parsed.durableId] : undefined;
|
|
51465
|
+
if (label === undefined)
|
|
51466
|
+
return "";
|
|
51467
|
+
return ` ${c.dim}← ${escapeTerminalTextForDisplay(label)}${c.reset}`;
|
|
51468
|
+
}
|
|
51469
|
+
function renderJsonDataBlock(out, c, data, indent, decorations) {
|
|
51470
|
+
const lines = JSON.stringify(data, null, 2).split(`
|
|
51471
|
+
`);
|
|
51472
|
+
for (const line of lines) {
|
|
51473
|
+
out(`${indent}${escapeTerminalTextForDisplay(line)}${jsonLineLabelSuffix(c, line, decorations)}`);
|
|
51474
|
+
}
|
|
51475
|
+
}
|
|
51476
|
+
function dataPreview(c, data) {
|
|
51477
|
+
const preview = JSON.stringify(data);
|
|
51478
|
+
const truncated = preview.length > 80 ? `${preview.slice(0, 77)}...` : preview;
|
|
51479
|
+
return `${c.dim}${escapeTerminalTextForDisplay(truncated)}${c.reset}`;
|
|
51480
|
+
}
|
|
51481
|
+
|
|
51014
51482
|
// ../../packages/warmhub-cli/src/domains/assertion/shared.ts
|
|
51015
51483
|
var COLLECTION_TAGS = ["arc", "bond", "pair", "set", "list"];
|
|
51016
51484
|
function parseAbout(raw) {
|
|
@@ -51026,6 +51494,7 @@ function parseAbout(raw) {
|
|
|
51026
51494
|
}
|
|
51027
51495
|
function renderAbout(out, c, result) {
|
|
51028
51496
|
const target = result.target;
|
|
51497
|
+
const decorations = getResponseDecorations(result);
|
|
51029
51498
|
const targetKind = target?.kind ?? "thing";
|
|
51030
51499
|
const targetWref = target?.wref ?? target?.name ?? "(unknown)";
|
|
51031
51500
|
out(`${c.bold}About:${c.reset} ${pinnedWref(c, targetWref, target?.version)} ${kindLabel(c, targetKind)}`);
|
|
@@ -51041,15 +51510,11 @@ function renderAbout(out, c, result) {
|
|
|
51041
51510
|
const wref = a.wref ?? a.name;
|
|
51042
51511
|
out(` ${pinnedWref(c, wref, a.version)} ${kindLabel(c, a.kind ?? "assertion")}`);
|
|
51043
51512
|
if (Array.isArray(a.affirmedWrefs) && a.affirmedWrefs.length > 0) {
|
|
51044
|
-
out(` ${c.dim}affirms:${c.reset} ${
|
|
51513
|
+
out(` ${c.dim}affirms:${c.reset} ${refList(c, a.affirmedWrefs.map(String), decorations)}`);
|
|
51045
51514
|
}
|
|
51046
51515
|
if (a.data && typeof a.data === "object") {
|
|
51047
51516
|
out(` ${c.dim}data:${c.reset}`);
|
|
51048
|
-
|
|
51049
|
-
`);
|
|
51050
|
-
for (const line of lines) {
|
|
51051
|
-
out(` ${line}`);
|
|
51052
|
-
}
|
|
51517
|
+
renderJsonDataBlock(out, c, a.data, " ", decorations);
|
|
51053
51518
|
}
|
|
51054
51519
|
const children = a.children;
|
|
51055
51520
|
if (children?.length) {
|
|
@@ -51062,11 +51527,7 @@ function renderAbout(out, c, result) {
|
|
|
51062
51527
|
out(` ${c.dim}+--${c.reset} ${pinnedWref(c, childWref)} ${childKl}`);
|
|
51063
51528
|
if (child.data) {
|
|
51064
51529
|
out(` ${c.dim}data:${c.reset}`);
|
|
51065
|
-
|
|
51066
|
-
`);
|
|
51067
|
-
for (const line of lines) {
|
|
51068
|
-
out(` ${line}`);
|
|
51069
|
-
}
|
|
51530
|
+
renderJsonDataBlock(out, c, child.data, " ", decorations);
|
|
51070
51531
|
}
|
|
51071
51532
|
}
|
|
51072
51533
|
}
|
|
@@ -51074,9 +51535,10 @@ function renderAbout(out, c, result) {
|
|
|
51074
51535
|
}
|
|
51075
51536
|
async function fetchAllAssertionHeadPages(ctx, org, repo, opts) {
|
|
51076
51537
|
const items = [];
|
|
51077
|
-
let
|
|
51078
|
-
|
|
51079
|
-
|
|
51538
|
+
let decorations;
|
|
51539
|
+
for await (const page of paginatePages2({
|
|
51540
|
+
initialCursor: opts.cursor,
|
|
51541
|
+
fetchPage: (cursor) => ctx.client.thing.head(org, repo, {
|
|
51080
51542
|
shape: opts.shape,
|
|
51081
51543
|
kind: opts.kind,
|
|
51082
51544
|
match: opts.match,
|
|
@@ -51084,20 +51546,21 @@ async function fetchAllAssertionHeadPages(ctx, org, repo, opts) {
|
|
|
51084
51546
|
limit: opts.limit,
|
|
51085
51547
|
cursor,
|
|
51086
51548
|
...opts.where ? { where: opts.where } : {}
|
|
51087
|
-
})
|
|
51549
|
+
}),
|
|
51550
|
+
title: "Assertion list"
|
|
51551
|
+
})) {
|
|
51088
51552
|
items.push(...page.items ?? []);
|
|
51089
|
-
|
|
51090
|
-
break;
|
|
51091
|
-
cursor = page.nextCursor;
|
|
51553
|
+
decorations = mergeDecorations(decorations, getResponseDecorations(page));
|
|
51092
51554
|
}
|
|
51093
|
-
return { items, nextCursor: undefined };
|
|
51555
|
+
return withDecorations({ items, nextCursor: undefined }, decorations);
|
|
51094
51556
|
}
|
|
51095
51557
|
async function fetchAllAssertionAboutPages(ctx, org, repo, wref, opts) {
|
|
51096
51558
|
const assertions = [];
|
|
51097
|
-
let
|
|
51559
|
+
let decorations;
|
|
51098
51560
|
let target;
|
|
51099
|
-
|
|
51100
|
-
|
|
51561
|
+
for await (const page of paginatePages2({
|
|
51562
|
+
initialCursor: opts.cursor,
|
|
51563
|
+
fetchPage: (cursor) => ctx.client.thing.about(org, repo, wref, {
|
|
51101
51564
|
shape: opts.shape,
|
|
51102
51565
|
match: opts.match,
|
|
51103
51566
|
depth: opts.depth,
|
|
@@ -51106,18 +51569,18 @@ async function fetchAllAssertionAboutPages(ctx, org, repo, wref, opts) {
|
|
|
51106
51569
|
limit: opts.limit,
|
|
51107
51570
|
cursor,
|
|
51108
51571
|
...opts.where ? { where: opts.where } : {}
|
|
51109
|
-
})
|
|
51572
|
+
}),
|
|
51573
|
+
title: "Assertion about"
|
|
51574
|
+
})) {
|
|
51110
51575
|
target = page.target;
|
|
51111
51576
|
assertions.push(...page.assertions ?? []);
|
|
51112
|
-
|
|
51113
|
-
break;
|
|
51114
|
-
cursor = page.nextCursor;
|
|
51577
|
+
decorations = mergeDecorations(decorations, getResponseDecorations(page));
|
|
51115
51578
|
}
|
|
51116
|
-
return {
|
|
51579
|
+
return withDecorations({
|
|
51117
51580
|
target,
|
|
51118
51581
|
assertions,
|
|
51119
51582
|
nextCursor: undefined
|
|
51120
|
-
};
|
|
51583
|
+
}, decorations);
|
|
51121
51584
|
}
|
|
51122
51585
|
|
|
51123
51586
|
// ../../packages/warmhub-cli/src/domains/assertion/mutators.ts
|
|
@@ -51303,7 +51766,7 @@ var handleCreate = async (ctx, { flags, args }) => {
|
|
|
51303
51766
|
// ../../packages/warmhub-cli/src/domains/thing/shared.ts
|
|
51304
51767
|
var CROCKFORD_CHARACTER_PATTERN = "0-9A-HJKMNP-TV-Za-hjkmnp-tv-z";
|
|
51305
51768
|
var VERSION_SUFFIX_PATTERN = String.raw`(?:v0*[1-9]\d*|[Hh][Ee][Aa][Dd]|[Aa][Ll][Ll])`;
|
|
51306
|
-
var DURABLE_ID_PATTERN_RE = new RegExp(`^[${CROCKFORD_CHARACTER_PATTERN}]{60}(?:@${VERSION_SUFFIX_PATTERN})?$`);
|
|
51769
|
+
var DURABLE_ID_PATTERN_RE = new RegExp(`^(?:wh:)?[${CROCKFORD_CHARACTER_PATTERN}]{60}(?:@${VERSION_SUFFIX_PATTERN})?$`);
|
|
51307
51770
|
var WREF_SEGMENT = String.raw`[^/?#@:\s$]+`;
|
|
51308
51771
|
var CANONICAL_WREF_PATTERN_RE = new RegExp(`^wh:${WREF_SEGMENT}/${WREF_SEGMENT}/${WREF_SEGMENT}(?:/${WREF_SEGMENT})*(?:@${VERSION_SUFFIX_PATTERN})?$`);
|
|
51309
51772
|
function looksLikeDurableId(wref) {
|
|
@@ -51344,32 +51807,33 @@ function requireIncrementalCheckpoint(repoSeq, required2) {
|
|
|
51344
51807
|
}
|
|
51345
51808
|
async function collectThingPages(args) {
|
|
51346
51809
|
const items = [];
|
|
51347
|
-
let
|
|
51348
|
-
|
|
51349
|
-
|
|
51350
|
-
|
|
51810
|
+
let decorations;
|
|
51811
|
+
for await (const page of paginatePages2({
|
|
51812
|
+
initialCursor: args.initialCursor,
|
|
51813
|
+
fetchPage: args.fetchPage,
|
|
51814
|
+
title: args.title
|
|
51815
|
+
})) {
|
|
51351
51816
|
const pageItems = page.items ?? [];
|
|
51817
|
+
const pageDecorations = getResponseDecorations(page);
|
|
51352
51818
|
if (args.onPage) {
|
|
51353
|
-
if (!await args.onPage(pageItems)) {
|
|
51819
|
+
if (!await args.onPage(pageItems, pageDecorations)) {
|
|
51354
51820
|
return { items, nextCursor: undefined };
|
|
51355
51821
|
}
|
|
51356
51822
|
} else {
|
|
51357
51823
|
items.push(...pageItems);
|
|
51824
|
+
decorations = mergeDecorations(decorations, pageDecorations);
|
|
51358
51825
|
}
|
|
51359
51826
|
if (!page.nextCursor) {
|
|
51360
51827
|
requireIncrementalCheckpoint(page.repoSeq, args.requireRepoSeq);
|
|
51361
51828
|
return {
|
|
51362
51829
|
items,
|
|
51363
51830
|
nextCursor: undefined,
|
|
51364
|
-
...page.repoSeq === undefined ? {} : { repoSeq: page.repoSeq }
|
|
51831
|
+
...page.repoSeq === undefined ? {} : { repoSeq: page.repoSeq },
|
|
51832
|
+
...decorations === undefined ? {} : { decorations }
|
|
51365
51833
|
};
|
|
51366
51834
|
}
|
|
51367
|
-
if (seenCursors.has(page.nextCursor)) {
|
|
51368
|
-
throw new CliError(4 /* Backend */, "BACKEND", `${args.title} pagination cursor repeated; aborting --all to avoid an infinite loop.`, undefined, "Retry without --all to fetch one page and inspect page.nextCursor. If cursors repeat, report this as a backend pagination issue.");
|
|
51369
|
-
}
|
|
51370
|
-
seenCursors.add(page.nextCursor);
|
|
51371
|
-
cursor = page.nextCursor;
|
|
51372
51835
|
}
|
|
51836
|
+
throw new Error("paginatePages completed without yielding a terminal page");
|
|
51373
51837
|
}
|
|
51374
51838
|
async function handleCount(ctx, org, repo, opts) {
|
|
51375
51839
|
const result = await ctx.client.thing.count(org, repo, opts);
|
|
@@ -51455,33 +51919,40 @@ var handleAbout = async (ctx, { flags, args }) => {
|
|
|
51455
51919
|
functionLogs: ctx.functionLogMode,
|
|
51456
51920
|
profile: ctx.profile,
|
|
51457
51921
|
clientFlags: ctx.clientFlags,
|
|
51922
|
+
decorateResponses: ctx.decorate,
|
|
51458
51923
|
signal: ctx.signal
|
|
51459
51924
|
});
|
|
51460
51925
|
return;
|
|
51461
51926
|
}
|
|
51462
51927
|
if (all) {
|
|
51463
51928
|
const assertions = [];
|
|
51464
|
-
let
|
|
51929
|
+
let decorations;
|
|
51465
51930
|
let target;
|
|
51466
|
-
|
|
51467
|
-
|
|
51931
|
+
for await (const page of paginatePages2({
|
|
51932
|
+
initialCursor: cursor,
|
|
51933
|
+
fetchPage,
|
|
51934
|
+
title: "Thing about"
|
|
51935
|
+
})) {
|
|
51468
51936
|
target = target ?? page.target;
|
|
51469
51937
|
assertions.push(...page.assertions ?? []);
|
|
51470
|
-
|
|
51471
|
-
break;
|
|
51472
|
-
cur = page.nextCursor;
|
|
51938
|
+
decorations = mergeDecorations(decorations, getResponseDecorations(page));
|
|
51473
51939
|
}
|
|
51474
|
-
const result2 = { target, assertions, nextCursor: undefined };
|
|
51475
|
-
writePageOutput(ctx, assertions, { limit: pageLimit, nextCursor: null }, () => renderAboutResult(ctx.out, ctx.colors, result2, wref));
|
|
51940
|
+
const result2 = withDecorations({ target, assertions, nextCursor: undefined }, decorations);
|
|
51941
|
+
writePageOutput(ctx, assertions, { limit: pageLimit, nextCursor: null, decorations }, () => renderAboutResult(ctx.out, ctx.colors, result2, wref));
|
|
51476
51942
|
return;
|
|
51477
51943
|
}
|
|
51478
51944
|
const result = await fetchPage(cursor);
|
|
51479
51945
|
if (result.nextCursor) {
|
|
51480
51946
|
emitPartialPageHint(ctx, result.assertions.length, result.nextCursor, boundedLimit);
|
|
51481
51947
|
}
|
|
51482
|
-
writePageOutput(ctx, result.assertions, {
|
|
51948
|
+
writePageOutput(ctx, result.assertions, {
|
|
51949
|
+
limit: boundedLimit,
|
|
51950
|
+
nextCursor: result.nextCursor ?? null,
|
|
51951
|
+
decorations: getResponseDecorations(result)
|
|
51952
|
+
}, () => renderAboutResult(ctx.out, ctx.colors, result, wref));
|
|
51483
51953
|
};
|
|
51484
51954
|
function renderAboutResult(out, c, result, wref) {
|
|
51955
|
+
const decorations = getResponseDecorations(result);
|
|
51485
51956
|
out(`${c.bold}Assertions about${c.reset} ${pinnedWref(c, wref)} (${result.assertions.length}${result.nextCursor ? "+" : ""})`);
|
|
51486
51957
|
if (result.assertions.length === 0) {
|
|
51487
51958
|
out(` ${c.dim}(no assertions found)${c.reset}`);
|
|
@@ -51491,32 +51962,31 @@ function renderAboutResult(out, c, result, wref) {
|
|
|
51491
51962
|
return;
|
|
51492
51963
|
}
|
|
51493
51964
|
for (const a of result.assertions) {
|
|
51494
|
-
renderAboutAssertion(out, c, a, " ");
|
|
51965
|
+
renderAboutAssertion(out, c, a, " ", decorations);
|
|
51495
51966
|
}
|
|
51496
51967
|
if (result.nextCursor) {
|
|
51497
51968
|
out(`${c.dim}More available. Use --all to fetch every page.${c.reset}`);
|
|
51498
51969
|
}
|
|
51499
51970
|
}
|
|
51500
|
-
function renderAboutAssertion(out, c, assertion, indent) {
|
|
51971
|
+
function renderAboutAssertion(out, c, assertion, indent, decorations) {
|
|
51501
51972
|
const sname = assertion.shapeName ?? assertion.shape ?? "?";
|
|
51502
51973
|
const aWref = assertion.wref ?? (assertion.name ? `${sname}/${assertion.name}` : "(unknown)");
|
|
51503
51974
|
const retractedTag = assertion.active === false ? ` ${c.red}[RETRACTED]${c.reset}` : "";
|
|
51504
51975
|
out(`${indent}${pinnedWref(c, aWref, assertion.version)}${retractedTag}`);
|
|
51505
51976
|
if (assertion.aboutWref) {
|
|
51506
|
-
out(`${indent} ${c.dim}about:${c.reset} ${
|
|
51977
|
+
out(`${indent} ${c.dim}about:${c.reset} ${refDisplay(c, assertion.aboutWref, decorations)}`);
|
|
51507
51978
|
}
|
|
51508
51979
|
if (assertion.roles?.length) {
|
|
51509
51980
|
out(`${indent} ${c.dim}roles:${c.reset} ${assertion.roles.join(", ")}`);
|
|
51510
51981
|
}
|
|
51511
51982
|
if (assertion.data && typeof assertion.data === "object") {
|
|
51512
|
-
|
|
51513
|
-
out(`${indent} ${c.dim}${preview.length > 80 ? `${preview.slice(0, 77)}...` : preview}${c.reset}`);
|
|
51983
|
+
out(`${indent} ${dataPreview(c, assertion.data)}`);
|
|
51514
51984
|
}
|
|
51515
51985
|
const children = assertion.children;
|
|
51516
51986
|
if (Array.isArray(children)) {
|
|
51517
51987
|
for (const child of children) {
|
|
51518
51988
|
if (child && typeof child === "object") {
|
|
51519
|
-
renderAboutAssertion(out, c, child, `${indent}
|
|
51989
|
+
renderAboutAssertion(out, c, child, `${indent} `, decorations);
|
|
51520
51990
|
}
|
|
51521
51991
|
}
|
|
51522
51992
|
}
|
|
@@ -51610,183 +52080,10 @@ var handleCreate2 = async (ctx, { flags, args }) => {
|
|
|
51610
52080
|
}));
|
|
51611
52081
|
};
|
|
51612
52082
|
|
|
51613
|
-
// ../../packages/rules/src/crockford-base32.ts
|
|
51614
|
-
var ALPHABET = "0123456789ABCDEFGHJKMNPQRSTVWXYZ";
|
|
51615
|
-
var DECODE_TABLE = new Uint8Array(256).fill(255);
|
|
51616
|
-
for (let i = 0;i < ALPHABET.length; i++) {
|
|
51617
|
-
const ch = ALPHABET.charCodeAt(i);
|
|
51618
|
-
DECODE_TABLE[ch] = i;
|
|
51619
|
-
if (ch >= 65)
|
|
51620
|
-
DECODE_TABLE[ch + 32] = i;
|
|
51621
|
-
}
|
|
51622
|
-
function encodeBytes(data) {
|
|
51623
|
-
const bitLen = data.length * 8;
|
|
51624
|
-
const charCount = Math.ceil(bitLen / 5);
|
|
51625
|
-
let out = "";
|
|
51626
|
-
for (let i = 0;i < charCount; i++) {
|
|
51627
|
-
const bitPos = i * 5;
|
|
51628
|
-
const byteIdx = bitPos >> 3;
|
|
51629
|
-
const bitOff = bitPos & 7;
|
|
51630
|
-
const b1 = data[byteIdx] ?? 0;
|
|
51631
|
-
let val;
|
|
51632
|
-
if (bitOff <= 3) {
|
|
51633
|
-
val = b1 >> 3 - bitOff & 31;
|
|
51634
|
-
} else {
|
|
51635
|
-
const b2 = data[byteIdx + 1] ?? 0;
|
|
51636
|
-
val = (b1 << bitOff - 3 | b2 >> 11 - bitOff) & 31;
|
|
51637
|
-
}
|
|
51638
|
-
out += ALPHABET[val];
|
|
51639
|
-
}
|
|
51640
|
-
return out;
|
|
51641
|
-
}
|
|
51642
|
-
function decodeBytes(encoded) {
|
|
51643
|
-
const byteLen = Math.floor(encoded.length * 5 / 8);
|
|
51644
|
-
const bytes = new Uint8Array(byteLen);
|
|
51645
|
-
let bitBuf = 0;
|
|
51646
|
-
let bitsInBuf = 0;
|
|
51647
|
-
let bytePos = 0;
|
|
51648
|
-
for (let i = 0;i < encoded.length; i++) {
|
|
51649
|
-
const ch = encoded.charCodeAt(i);
|
|
51650
|
-
const val = DECODE_TABLE[ch];
|
|
51651
|
-
if (val === undefined || val === 255)
|
|
51652
|
-
return null;
|
|
51653
|
-
bitBuf = bitBuf << 5 | val;
|
|
51654
|
-
bitsInBuf += 5;
|
|
51655
|
-
if (bitsInBuf >= 8) {
|
|
51656
|
-
bitsInBuf -= 8;
|
|
51657
|
-
if (bytePos < byteLen) {
|
|
51658
|
-
bytes[bytePos++] = bitBuf >> bitsInBuf & 255;
|
|
51659
|
-
}
|
|
51660
|
-
}
|
|
51661
|
-
}
|
|
51662
|
-
return bytes;
|
|
51663
|
-
}
|
|
51664
|
-
|
|
51665
|
-
// ../../packages/rules/src/durable-id.ts
|
|
51666
|
-
var THING_SCHEME = 1;
|
|
51667
|
-
var REPO_SCHEME = 2;
|
|
51668
|
-
var UUID_BYTES = 16;
|
|
51669
|
-
var CRC_BYTES = 4;
|
|
51670
|
-
function encodedLengthFor(payloadLen) {
|
|
51671
|
-
return Math.ceil((1 + payloadLen + CRC_BYTES) * 8 / 5);
|
|
51672
|
-
}
|
|
51673
|
-
var CRC32C_TABLE = (() => {
|
|
51674
|
-
const POLY = 2197175160;
|
|
51675
|
-
const table = new Uint32Array(256);
|
|
51676
|
-
for (let i = 0;i < 256; i++) {
|
|
51677
|
-
let crc = i;
|
|
51678
|
-
for (let j = 0;j < 8; j++) {
|
|
51679
|
-
crc = crc & 1 ? crc >>> 1 ^ POLY : crc >>> 1;
|
|
51680
|
-
}
|
|
51681
|
-
table[i] = crc >>> 0;
|
|
51682
|
-
}
|
|
51683
|
-
return table;
|
|
51684
|
-
})();
|
|
51685
|
-
function crc32c(data) {
|
|
51686
|
-
let crc = 4294967295;
|
|
51687
|
-
for (const byte of data) {
|
|
51688
|
-
crc = (crc >>> 8 ^ (CRC32C_TABLE[(crc ^ byte) & 255] ?? 0)) >>> 0;
|
|
51689
|
-
}
|
|
51690
|
-
return (crc ^ 4294967295) >>> 0;
|
|
51691
|
-
}
|
|
51692
|
-
function bytesToUuid(bytes, offset = 0) {
|
|
51693
|
-
const hex3 = Array.from(bytes.slice(offset, offset + 16)).map((b) => b.toString(16).padStart(2, "0")).join("");
|
|
51694
|
-
return [
|
|
51695
|
-
hex3.slice(0, 8),
|
|
51696
|
-
hex3.slice(8, 12),
|
|
51697
|
-
hex3.slice(12, 16),
|
|
51698
|
-
hex3.slice(16, 20),
|
|
51699
|
-
hex3.slice(20, 32)
|
|
51700
|
-
].join("-");
|
|
51701
|
-
}
|
|
51702
|
-
function unpackToken(scheme, token, payloadLen) {
|
|
51703
|
-
const stripped = token.startsWith("wh:") ? token.slice(3) : token;
|
|
51704
|
-
if (stripped.length !== encodedLengthFor(payloadLen))
|
|
51705
|
-
return null;
|
|
51706
|
-
const raw = decodeBytes(stripped);
|
|
51707
|
-
if (!raw || raw.length !== 1 + payloadLen + CRC_BYTES)
|
|
51708
|
-
return null;
|
|
51709
|
-
if (raw[0] !== scheme)
|
|
51710
|
-
return null;
|
|
51711
|
-
const crcOffset = 1 + payloadLen;
|
|
51712
|
-
const storedCrc = (raw[crcOffset] ?? 0) << 24 | (raw[crcOffset + 1] ?? 0) << 16 | (raw[crcOffset + 2] ?? 0) << 8 | (raw[crcOffset + 3] ?? 0);
|
|
51713
|
-
const computedCrc = crc32c(raw.slice(0, crcOffset));
|
|
51714
|
-
if (storedCrc >>> 0 !== computedCrc >>> 0)
|
|
51715
|
-
return null;
|
|
51716
|
-
if (encodeBytes(raw) !== stripped.toUpperCase())
|
|
51717
|
-
return null;
|
|
51718
|
-
return raw.slice(1, 1 + payloadLen);
|
|
51719
|
-
}
|
|
51720
|
-
function decodeDurableId(token) {
|
|
51721
|
-
const payload = unpackToken(THING_SCHEME, token, UUID_BYTES * 2);
|
|
51722
|
-
if (!payload)
|
|
51723
|
-
return null;
|
|
51724
|
-
return {
|
|
51725
|
-
repoId: bytesToUuid(payload, 0),
|
|
51726
|
-
thingId: bytesToUuid(payload, UUID_BYTES)
|
|
51727
|
-
};
|
|
51728
|
-
}
|
|
51729
|
-
function decodeRepoDurableId(token) {
|
|
51730
|
-
const payload = unpackToken(REPO_SCHEME, token, UUID_BYTES);
|
|
51731
|
-
if (!payload)
|
|
51732
|
-
return null;
|
|
51733
|
-
return { repoId: bytesToUuid(payload, 0) };
|
|
51734
|
-
}
|
|
51735
|
-
|
|
51736
|
-
// ../../packages/warmhub-cli/src/durable-id-style.ts
|
|
51737
|
-
var THING_TOKEN_LEN = 60;
|
|
51738
|
-
var REPO_TOKEN_LEN = 34;
|
|
51739
|
-
var HUE_REPO = "8A7C6A";
|
|
51740
|
-
var HUE_TIMESTAMP = "7E9BAC";
|
|
51741
|
-
var HUE_ENTROPY = "E8C378";
|
|
51742
|
-
var HUE_CRC = "74846B";
|
|
51743
|
-
var THING_BANDS = [
|
|
51744
|
-
{ start: 0, end: 28, weight: "faint", hex: HUE_REPO },
|
|
51745
|
-
{ start: 28, end: 37, weight: "normal", hex: HUE_TIMESTAMP },
|
|
51746
|
-
{ start: 37, end: 53, weight: "bold", hex: HUE_ENTROPY },
|
|
51747
|
-
{ start: 53, end: 60, weight: "faint", hex: HUE_CRC }
|
|
51748
|
-
];
|
|
51749
|
-
var REPO_BANDS = [
|
|
51750
|
-
{ start: 0, end: 28, weight: "faint", hex: HUE_REPO },
|
|
51751
|
-
{ start: 28, end: 34, weight: "faint", hex: HUE_CRC }
|
|
51752
|
-
];
|
|
51753
|
-
function fg(hex3) {
|
|
51754
|
-
const r = Number.parseInt(hex3.slice(0, 2), 16);
|
|
51755
|
-
const g = Number.parseInt(hex3.slice(2, 4), 16);
|
|
51756
|
-
const b = Number.parseInt(hex3.slice(4, 6), 16);
|
|
51757
|
-
return `\x1B[38;2;${r};${g};${b}m`;
|
|
51758
|
-
}
|
|
51759
|
-
function bandsFor(token) {
|
|
51760
|
-
if (token.length === THING_TOKEN_LEN && decodeDurableId(token)) {
|
|
51761
|
-
return THING_BANDS;
|
|
51762
|
-
}
|
|
51763
|
-
if (token.length === REPO_TOKEN_LEN && decodeRepoDurableId(token)) {
|
|
51764
|
-
return REPO_BANDS;
|
|
51765
|
-
}
|
|
51766
|
-
return null;
|
|
51767
|
-
}
|
|
51768
|
-
function styleBand(text, band, c) {
|
|
51769
|
-
const weight = band.weight === "bold" ? c.bold : band.weight === "faint" ? c.dim : "";
|
|
51770
|
-
const hue = c.truecolor ? fg(band.hex) : "";
|
|
51771
|
-
const prefix = `${weight}${hue}`;
|
|
51772
|
-
return prefix === "" ? text : `${prefix}${text}${c.reset}`;
|
|
51773
|
-
}
|
|
51774
|
-
function styleDurableId(token, c) {
|
|
51775
|
-
if (c.reset === "")
|
|
51776
|
-
return token;
|
|
51777
|
-
const bands = bandsFor(token);
|
|
51778
|
-
if (!bands)
|
|
51779
|
-
return token;
|
|
51780
|
-
let out = "";
|
|
51781
|
-
for (const band of bands) {
|
|
51782
|
-
out += styleBand(token.slice(band.start, band.end), band, c);
|
|
51783
|
-
}
|
|
51784
|
-
return out;
|
|
51785
|
-
}
|
|
51786
|
-
|
|
51787
52083
|
// ../../packages/warmhub-cli/src/domains/thing/render.ts
|
|
51788
52084
|
function renderHead(out, c, chars, result, org, repo, shape, kind) {
|
|
51789
52085
|
const items = result.items ?? [];
|
|
52086
|
+
const decorations = getResponseDecorations(result);
|
|
51790
52087
|
if (!items.length) {
|
|
51791
52088
|
out(`${c.dim}No items in HEAD${c.reset}`);
|
|
51792
52089
|
return;
|
|
@@ -51800,19 +52097,17 @@ function renderHead(out, c, chars, result, org, repo, shape, kind) {
|
|
|
51800
52097
|
const retractedTag = item.active === false ? ` ${c.red}[RETRACTED]${c.reset}` : "";
|
|
51801
52098
|
out(` ${wref} ${kl}${retractedTag}`);
|
|
51802
52099
|
if (item.kind === "assertion" && item.aboutWref) {
|
|
51803
|
-
out(` ${c.dim}about:${c.reset} ${
|
|
52100
|
+
out(` ${c.dim}about:${c.reset} ${refDisplay(c, item.aboutWref, decorations)}`);
|
|
51804
52101
|
}
|
|
51805
52102
|
if (item.affirmedWrefs?.length) {
|
|
51806
|
-
out(` ${c.dim}affirms:${c.reset} ${
|
|
52103
|
+
out(` ${c.dim}affirms:${c.reset} ${refList(c, item.affirmedWrefs, decorations)}`);
|
|
51807
52104
|
}
|
|
51808
52105
|
const fields = shapeName && (item.kind === "thing" || item.kind === "collection") && item.data ? collectionFields(shapeName, item.data) : null;
|
|
51809
52106
|
if (fields) {
|
|
51810
52107
|
const allWrefs = fields.flatMap((f) => f.wrefs);
|
|
51811
|
-
out(` ${
|
|
52108
|
+
out(` ${refList(c, allWrefs, decorations)}`);
|
|
51812
52109
|
} else if (item.data && typeof item.data === "object") {
|
|
51813
|
-
|
|
51814
|
-
const truncated = preview.length > 80 ? `${preview.slice(0, 77)}...` : preview;
|
|
51815
|
-
out(` ${c.dim}${escapeTerminalTextForDisplay(truncated)}${c.reset}`);
|
|
52110
|
+
out(` ${dataPreview(c, item.data)}`);
|
|
51816
52111
|
}
|
|
51817
52112
|
const itemMeta = item.metadata;
|
|
51818
52113
|
if (itemMeta?.durableId) {
|
|
@@ -51822,6 +52117,7 @@ function renderHead(out, c, chars, result, org, repo, shape, kind) {
|
|
|
51822
52117
|
out(`${c.dim}${items.length} item(s)${c.reset}`);
|
|
51823
52118
|
}
|
|
51824
52119
|
function renderThing(out, c, result) {
|
|
52120
|
+
const decorations = getResponseDecorations(result);
|
|
51825
52121
|
const wref = result.wref ?? result.name ?? "(unknown)";
|
|
51826
52122
|
const shapeName = result.shapeName ?? result.shape;
|
|
51827
52123
|
const displayKind = effectiveKind(result.kind ?? "thing", shapeName);
|
|
@@ -51831,14 +52127,14 @@ function renderThing(out, c, result) {
|
|
|
51831
52127
|
out(` ${c.dim}version:${c.reset} ${result.version ?? "-"}`);
|
|
51832
52128
|
out(` ${c.dim}active:${c.reset} ${String(result.active)}`);
|
|
51833
52129
|
if (result.committerWref) {
|
|
51834
|
-
out(` ${c.dim}by:${c.reset} ${
|
|
52130
|
+
out(` ${c.dim}by:${c.reset} ${refDisplay(c, result.committerWref, decorations)}`);
|
|
51835
52131
|
}
|
|
51836
52132
|
const aboutWref = result.aboutWref ?? result.about;
|
|
51837
52133
|
if (aboutWref) {
|
|
51838
|
-
out(` ${c.dim}about:${c.reset} ${escapeTerminalTextForDisplay(String(aboutWref))}`);
|
|
52134
|
+
out(` ${c.dim}about:${c.reset} ${decoratedRef(c, String(aboutWref), decorations) ?? escapeTerminalTextForDisplay(String(aboutWref))}`);
|
|
51839
52135
|
}
|
|
51840
52136
|
if (result.affirmedWrefs?.length) {
|
|
51841
|
-
out(` ${c.dim}affirms:${c.reset} ${
|
|
52137
|
+
out(` ${c.dim}affirms:${c.reset} ${refList(c, result.affirmedWrefs, decorations)}`);
|
|
51842
52138
|
}
|
|
51843
52139
|
const meta3 = result.metadata;
|
|
51844
52140
|
if (meta3?.durableId || meta3?.createdOn || meta3?.revisedOn) {
|
|
@@ -51854,31 +52150,27 @@ function renderThing(out, c, result) {
|
|
|
51854
52150
|
}
|
|
51855
52151
|
}
|
|
51856
52152
|
if (result.collection) {
|
|
51857
|
-
renderCollectionSummary(out, c, result.collection);
|
|
52153
|
+
renderCollectionSummary(out, c, result.collection, decorations);
|
|
51858
52154
|
}
|
|
51859
52155
|
const fields = shapeName && result.data ? collectionFields(shapeName, result.data) : null;
|
|
51860
52156
|
if (fields) {
|
|
51861
52157
|
for (const field of fields) {
|
|
51862
52158
|
if (field.wrefs.length === 1) {
|
|
51863
52159
|
const pad = " ".repeat(Math.max(1, 9 - field.name.length));
|
|
51864
|
-
out(` ${c.dim}${escapeTerminalTextForDisplay(field.name)}:${c.reset}${pad}${
|
|
52160
|
+
out(` ${c.dim}${escapeTerminalTextForDisplay(field.name)}:${c.reset}${pad}${refDisplay(c, field.wrefs[0] ?? "", decorations)}`);
|
|
51865
52161
|
} else {
|
|
51866
52162
|
out(` ${c.dim}${escapeTerminalTextForDisplay(field.name)}:${c.reset}`);
|
|
51867
52163
|
for (const w of field.wrefs) {
|
|
51868
|
-
out(` ${
|
|
52164
|
+
out(` ${refDisplay(c, w, decorations)}`);
|
|
51869
52165
|
}
|
|
51870
52166
|
}
|
|
51871
52167
|
}
|
|
51872
52168
|
} else if (result.data) {
|
|
51873
52169
|
out(` ${c.dim}data:${c.reset}`);
|
|
51874
|
-
|
|
51875
|
-
`);
|
|
51876
|
-
for (const line of lines) {
|
|
51877
|
-
out(` ${escapeTerminalTextForDisplay(line)}`);
|
|
51878
|
-
}
|
|
52170
|
+
renderJsonDataBlock(out, c, result.data, " ", decorations);
|
|
51879
52171
|
}
|
|
51880
52172
|
}
|
|
51881
|
-
function renderCollectionSummary(out, c, collection) {
|
|
52173
|
+
function renderCollectionSummary(out, c, collection, decorations) {
|
|
51882
52174
|
out(` ${c.dim}collection:${c.reset} ${collection.type}`);
|
|
51883
52175
|
out(` ${c.dim}members:${c.reset} ${collection.memberCount}`);
|
|
51884
52176
|
if (collection.fullData)
|
|
@@ -51890,19 +52182,12 @@ function renderCollectionSummary(out, c, collection) {
|
|
|
51890
52182
|
return;
|
|
51891
52183
|
out(` ${c.dim}preview:${c.reset}`);
|
|
51892
52184
|
for (const wref of preview) {
|
|
51893
|
-
out(` ${
|
|
52185
|
+
out(` ${refDisplay(c, wref, decorations)}`);
|
|
51894
52186
|
}
|
|
51895
52187
|
}
|
|
51896
|
-
function
|
|
51897
|
-
const lines = JSON.stringify(data, null, 2).split(`
|
|
51898
|
-
`);
|
|
51899
|
-
for (const line of lines) {
|
|
51900
|
-
out(`${indent}${escapeTerminalTextForDisplay(line)}`);
|
|
51901
|
-
}
|
|
51902
|
-
}
|
|
51903
|
-
function renderGraphValue(out, c, value, indent) {
|
|
52188
|
+
function renderGraphValue(out, c, value, indent, decorations) {
|
|
51904
52189
|
if (typeof value === "string") {
|
|
51905
|
-
out(`${indent}${
|
|
52190
|
+
out(`${indent}${refDisplay(c, value, decorations)}`);
|
|
51906
52191
|
return;
|
|
51907
52192
|
}
|
|
51908
52193
|
if (value === null || typeof value === "number" || typeof value === "boolean") {
|
|
@@ -51911,26 +52196,26 @@ function renderGraphValue(out, c, value, indent) {
|
|
|
51911
52196
|
}
|
|
51912
52197
|
if (Array.isArray(value)) {
|
|
51913
52198
|
for (const item of value) {
|
|
51914
|
-
renderGraphValue(out, c, item, indent);
|
|
52199
|
+
renderGraphValue(out, c, item, indent, decorations);
|
|
51915
52200
|
}
|
|
51916
52201
|
return;
|
|
51917
52202
|
}
|
|
51918
|
-
renderGraphNode(out, c, value, indent);
|
|
52203
|
+
renderGraphNode(out, c, value, indent, decorations);
|
|
51919
52204
|
}
|
|
51920
|
-
function renderGraphNode(out, c, result, indent = "") {
|
|
52205
|
+
function renderGraphNode(out, c, result, indent = "", decorations = undefined) {
|
|
51921
52206
|
const wref = result.wref ?? result.name ?? "(unknown)";
|
|
51922
52207
|
const shapeName = result.shapeName ?? result.shape;
|
|
51923
52208
|
const displayKind = effectiveKind(result.kind ?? "thing", shapeName);
|
|
51924
52209
|
out(`${indent}${pinnedWref(c, wref, result.version)} ${kindLabel(c, displayKind)}`);
|
|
51925
52210
|
if (result.about) {
|
|
51926
52211
|
out(`${indent} ${c.dim}about:${c.reset}`);
|
|
51927
|
-
renderGraphValue(out, c, result.about, `${indent}
|
|
52212
|
+
renderGraphValue(out, c, result.about, `${indent} `, decorations);
|
|
51928
52213
|
} else if (result.aboutWref) {
|
|
51929
|
-
out(`${indent} ${c.dim}about:${c.reset} ${
|
|
52214
|
+
out(`${indent} ${c.dim}about:${c.reset} ${refDisplay(c, result.aboutWref, decorations)}`);
|
|
51930
52215
|
}
|
|
51931
52216
|
if (result.data) {
|
|
51932
52217
|
out(`${indent} ${c.dim}data:${c.reset}`);
|
|
51933
|
-
|
|
52218
|
+
renderJsonDataBlock(out, c, result.data, `${indent} `, decorations);
|
|
51934
52219
|
}
|
|
51935
52220
|
const resolved = result.resolved ?? {};
|
|
51936
52221
|
const resolvedEntries = Object.entries(resolved);
|
|
@@ -51938,25 +52223,26 @@ function renderGraphNode(out, c, result, indent = "") {
|
|
|
51938
52223
|
out(`${indent} ${c.dim}resolved:${c.reset}`);
|
|
51939
52224
|
for (const [fieldPath, value] of resolvedEntries) {
|
|
51940
52225
|
out(`${indent} ${c.dim}${escapeTerminalTextForDisplay(fieldPath)}:${c.reset}`);
|
|
51941
|
-
renderGraphValue(out, c, value, `${indent}
|
|
52226
|
+
renderGraphValue(out, c, value, `${indent} `, decorations);
|
|
51942
52227
|
}
|
|
51943
52228
|
}
|
|
51944
52229
|
const assertions = result.assertions ?? [];
|
|
51945
52230
|
if (assertions.length > 0) {
|
|
51946
52231
|
out(`${indent} ${c.dim}assertions:${c.reset}`);
|
|
51947
52232
|
for (const assertion of assertions) {
|
|
51948
|
-
renderGraphNode(out, c, assertion, `${indent}
|
|
52233
|
+
renderGraphNode(out, c, assertion, `${indent} `, decorations);
|
|
51949
52234
|
}
|
|
51950
52235
|
}
|
|
51951
52236
|
}
|
|
51952
52237
|
function renderThingGraph(out, c, result) {
|
|
51953
|
-
renderGraphNode(out, c, result);
|
|
52238
|
+
renderGraphNode(out, c, result, "", getResponseDecorations(result));
|
|
51954
52239
|
if (result.graph) {
|
|
51955
52240
|
const truncated = result.graph.truncated ? " truncated" : "";
|
|
51956
52241
|
out(` ${c.dim}graph:${c.reset} depth=${result.graph.depth} limit=${result.graph.limit}${truncated}`);
|
|
51957
52242
|
}
|
|
51958
52243
|
}
|
|
51959
52244
|
function renderHistory(out, c, result) {
|
|
52245
|
+
const decorations = getResponseDecorations(result);
|
|
51960
52246
|
if (result.thing && typeof result.thing === "object") {
|
|
51961
52247
|
const wref = result.thing.wref ?? result.thing.name ?? "(unknown)";
|
|
51962
52248
|
out(`${c.bold}History: ${pinnedWref(c, wref)}${c.reset} ${kindLabel(c, effectiveKind(result.thing.kind ?? "thing", result.thing.shapeName))}`);
|
|
@@ -51982,13 +52268,13 @@ function renderHistory(out, c, result) {
|
|
|
51982
52268
|
const time3 = ver.createdAt ? formatTime(ver.createdAt, now) : "";
|
|
51983
52269
|
const wref = ver.wref ?? ver.thingName;
|
|
51984
52270
|
const wrefStr = wref ? pinnedWref(c, wref, ver.version) : "";
|
|
51985
|
-
const by = ver.committerWref ? ` ${c.dim}by${c.reset} ${
|
|
52271
|
+
const by = ver.committerWref ? ` ${c.dim}by${c.reset} ${refDisplay(c, ver.committerWref, decorations)}` : "";
|
|
51986
52272
|
const createdOn = ver.metadata?.createdOn;
|
|
51987
52273
|
const thingCreatedStr = createdOn ? ` ${c.dim}born:${formatTime(createdOn, now)}${c.reset}` : "";
|
|
51988
52274
|
out(` ${wrefStr} ${op} ${c.dim}${time3}${c.reset}${by}${thingCreatedStr}`);
|
|
51989
52275
|
const affirmed = ver.affirmedWrefs;
|
|
51990
52276
|
if (Array.isArray(affirmed) && affirmed.length > 0) {
|
|
51991
|
-
out(` ${c.dim}affirms:${c.reset} ${
|
|
52277
|
+
out(` ${c.dim}affirms:${c.reset} ${refList(c, affirmed.map(String), decorations)}`);
|
|
51992
52278
|
}
|
|
51993
52279
|
}
|
|
51994
52280
|
}
|
|
@@ -51998,11 +52284,12 @@ function renderRefs(out, c, result, wref, direction) {
|
|
|
51998
52284
|
out(`${c.dim}No ${direction} refs${c.reset}`);
|
|
51999
52285
|
return;
|
|
52000
52286
|
}
|
|
52287
|
+
const decorations = getResponseDecorations(result);
|
|
52001
52288
|
const label = direction === "inbound" ? "References to" : "Referenced by";
|
|
52002
52289
|
out(`${c.bold}${label}${c.reset} ${c.cyan}${escapeTerminalTextForDisplay(wref)}${c.reset}`);
|
|
52003
52290
|
out(`${c.dim}${"─".repeat(60)}${c.reset}`);
|
|
52004
52291
|
for (const item of items) {
|
|
52005
|
-
const refWref =
|
|
52292
|
+
const refWref = refDisplay(c, item.wref, decorations, item.version);
|
|
52006
52293
|
const kl = kindLabel(c, effectiveKind(item.kind ?? "thing", item.shapeName));
|
|
52007
52294
|
const field = `${c.dim}via ${c.reset}${escapeTerminalTextForDisplay(item.fieldPath ?? "(unknown)")}`;
|
|
52008
52295
|
out(` ${refWref} ${kl} ${field}`);
|
|
@@ -52043,7 +52330,8 @@ function renderBatchView(out, c, result, wrefs, flagsVersion) {
|
|
|
52043
52330
|
const base = requestedBase.length > 0 ? requestedBase : fallback.replace(/@v\d+$/, "");
|
|
52044
52331
|
const kl = kindLabel(c, effectiveKind(item.kind ?? "thing", item.shapeName));
|
|
52045
52332
|
const retractedTag = item.active === false ? ` ${c.red}[RETRACTED]${c.reset}` : "";
|
|
52046
|
-
|
|
52333
|
+
const display = labeledRef(c, `${base}@v${item.version}`, fallback) ?? `${escapeTerminalTextForDisplay(base)}@v${item.version}`;
|
|
52334
|
+
out(` ${display} ${kl}${retractedTag}`);
|
|
52047
52335
|
}
|
|
52048
52336
|
if (result.missing.length > 0) {
|
|
52049
52337
|
out("Missing:");
|
|
@@ -52135,6 +52423,7 @@ var handleHistory = async (ctx, { flags, args }) => {
|
|
|
52135
52423
|
functionLogs: ctx.functionLogMode,
|
|
52136
52424
|
profile: ctx.profile,
|
|
52137
52425
|
clientFlags: ctx.clientFlags,
|
|
52426
|
+
decorateResponses: ctx.decorate,
|
|
52138
52427
|
signal: ctx.signal
|
|
52139
52428
|
});
|
|
52140
52429
|
return;
|
|
@@ -52161,15 +52450,17 @@ var handleHistory = async (ctx, { flags, args }) => {
|
|
|
52161
52450
|
}
|
|
52162
52451
|
writePageOutput(ctx, result.versions ?? [], {
|
|
52163
52452
|
limit: all ? pageLimit : boundedLimit,
|
|
52164
|
-
nextCursor: result.nextCursor ?? null
|
|
52453
|
+
nextCursor: result.nextCursor ?? null,
|
|
52454
|
+
decorations: getResponseDecorations(result)
|
|
52165
52455
|
}, () => renderHistory(ctx.out, ctx.colors, result));
|
|
52166
52456
|
};
|
|
52167
52457
|
async function fetchAllHistoryPages(ctx, org, repo, opts) {
|
|
52168
52458
|
const versions2 = [];
|
|
52169
|
-
let
|
|
52459
|
+
let decorations;
|
|
52170
52460
|
let thing;
|
|
52171
|
-
|
|
52172
|
-
|
|
52461
|
+
for await (const page of paginatePages2({
|
|
52462
|
+
initialCursor: opts.cursor,
|
|
52463
|
+
fetchPage: (cursor) => ctx.client.thing.history(org, repo, {
|
|
52173
52464
|
wref: opts.wref,
|
|
52174
52465
|
shape: opts.shape,
|
|
52175
52466
|
about: opts.about,
|
|
@@ -52177,25 +52468,19 @@ async function fetchAllHistoryPages(ctx, org, repo, opts) {
|
|
|
52177
52468
|
resolveCollections: opts.resolveCollections,
|
|
52178
52469
|
limit: opts.limit,
|
|
52179
52470
|
cursor
|
|
52180
|
-
})
|
|
52471
|
+
}),
|
|
52472
|
+
title: "Thing history"
|
|
52473
|
+
})) {
|
|
52181
52474
|
if (!thing && page.thing)
|
|
52182
52475
|
thing = page.thing;
|
|
52183
52476
|
versions2.push(...page.versions ?? []);
|
|
52184
|
-
|
|
52185
|
-
break;
|
|
52186
|
-
cursor = page.nextCursor;
|
|
52187
|
-
}
|
|
52188
|
-
if (thing) {
|
|
52189
|
-
return {
|
|
52190
|
-
thing,
|
|
52191
|
-
versions: versions2,
|
|
52192
|
-
nextCursor: undefined
|
|
52193
|
-
};
|
|
52477
|
+
decorations = mergeDecorations(decorations, getResponseDecorations(page));
|
|
52194
52478
|
}
|
|
52195
|
-
return {
|
|
52479
|
+
return withDecorations({
|
|
52480
|
+
...thing === undefined ? {} : { thing },
|
|
52196
52481
|
versions: versions2,
|
|
52197
52482
|
nextCursor: undefined
|
|
52198
|
-
};
|
|
52483
|
+
}, decorations);
|
|
52199
52484
|
}
|
|
52200
52485
|
|
|
52201
52486
|
// ../../packages/warmhub-cli/src/domains/thing/lease.ts
|
|
@@ -52443,6 +52728,7 @@ var handleHead = async (ctx, { flags, args }) => {
|
|
|
52443
52728
|
functionLogs: ctx.functionLogMode,
|
|
52444
52729
|
profile: ctx.profile,
|
|
52445
52730
|
clientFlags: ctx.clientFlags,
|
|
52731
|
+
decorateResponses: ctx.decorate,
|
|
52446
52732
|
signal: ctx.signal
|
|
52447
52733
|
});
|
|
52448
52734
|
return;
|
|
@@ -52460,8 +52746,8 @@ var handleHead = async (ctx, { flags, args }) => {
|
|
|
52460
52746
|
excludeInfraShapes,
|
|
52461
52747
|
where: where.length > 0 ? where : undefined,
|
|
52462
52748
|
...sinceRepoSeq === undefined ? {} : { sinceRepoSeq }
|
|
52463
|
-
}, streamJsonl ? async (items) => {
|
|
52464
|
-
writePageOutput(ctx, items, { limit: pageLimit }, () => {});
|
|
52749
|
+
}, streamJsonl ? async (items, pageDecorations) => {
|
|
52750
|
+
writePageOutput(ctx, items, { limit: pageLimit, decorations: pageDecorations }, () => {});
|
|
52465
52751
|
return await ctx.flushOut?.() ?? true;
|
|
52466
52752
|
} : undefined) : await ctx.client.thing.head(org, repo, {
|
|
52467
52753
|
shape,
|
|
@@ -52485,7 +52771,8 @@ var handleHead = async (ctx, { flags, args }) => {
|
|
|
52485
52771
|
writePageOutput(ctx, result.items ?? [], {
|
|
52486
52772
|
limit: all ? pageLimit : boundedLimit,
|
|
52487
52773
|
nextCursor: result.nextCursor ?? null,
|
|
52488
|
-
...result.repoSeq === undefined ? {} : { repoSeq: result.repoSeq }
|
|
52774
|
+
...result.repoSeq === undefined ? {} : { repoSeq: result.repoSeq },
|
|
52775
|
+
decorations: getResponseDecorations(result)
|
|
52489
52776
|
}, () => renderHead(ctx.out, ctx.colors, ctx.chars, result, org, repo, shape, kind));
|
|
52490
52777
|
};
|
|
52491
52778
|
async function fetchAllHeadPages(ctx, org, repo, opts, onPage) {
|
|
@@ -52639,6 +52926,7 @@ var handleQuery = async (ctx, { flags }) => {
|
|
|
52639
52926
|
functionLogs: ctx.functionLogMode,
|
|
52640
52927
|
profile: ctx.profile,
|
|
52641
52928
|
clientFlags: ctx.clientFlags,
|
|
52929
|
+
decorateResponses: ctx.decorate,
|
|
52642
52930
|
signal: ctx.signal
|
|
52643
52931
|
});
|
|
52644
52932
|
return;
|
|
@@ -52660,8 +52948,8 @@ var handleQuery = async (ctx, { flags }) => {
|
|
|
52660
52948
|
excludeInfraShapes,
|
|
52661
52949
|
where: where.length > 0 ? where : undefined,
|
|
52662
52950
|
...sinceRepoSeq === undefined ? {} : { sinceRepoSeq }
|
|
52663
|
-
}, streamJsonl ? async (items) => {
|
|
52664
|
-
writePageOutput(ctx, items, { limit: pageLimit }, () => {});
|
|
52951
|
+
}, streamJsonl ? async (items, pageDecorations) => {
|
|
52952
|
+
writePageOutput(ctx, items, { limit: pageLimit, decorations: pageDecorations }, () => {});
|
|
52665
52953
|
return await ctx.flushOut?.() ?? true;
|
|
52666
52954
|
} : undefined) : await ctx.client.thing.query(org, repo, {
|
|
52667
52955
|
shape,
|
|
@@ -52689,7 +52977,8 @@ var handleQuery = async (ctx, { flags }) => {
|
|
|
52689
52977
|
writePageOutput(ctx, result.items ?? [], {
|
|
52690
52978
|
limit: all ? pageLimit : boundedLimit,
|
|
52691
52979
|
nextCursor: result.nextCursor ?? null,
|
|
52692
|
-
...result.repoSeq === undefined ? {} : { repoSeq: result.repoSeq }
|
|
52980
|
+
...result.repoSeq === undefined ? {} : { repoSeq: result.repoSeq },
|
|
52981
|
+
decorations: getResponseDecorations(result)
|
|
52693
52982
|
}, () => renderQueryResults(ctx.out, c, result));
|
|
52694
52983
|
};
|
|
52695
52984
|
async function fetchAllQueryPages(ctx, org, repo, opts, onPage) {
|
|
@@ -52719,6 +53008,7 @@ async function fetchAllQueryPages(ctx, org, repo, opts, onPage) {
|
|
|
52719
53008
|
}
|
|
52720
53009
|
function renderQueryResults(out, c, result) {
|
|
52721
53010
|
const items = result.items ?? [];
|
|
53011
|
+
const decorations = getResponseDecorations(result);
|
|
52722
53012
|
if (!items.length) {
|
|
52723
53013
|
out(`${c.dim}No results${c.reset}`);
|
|
52724
53014
|
return;
|
|
@@ -52735,11 +53025,9 @@ function renderQueryResults(out, c, result) {
|
|
|
52735
53025
|
const fields = shapeName && (item.kind === "thing" || item.kind === "collection" || !item.kind) && item.data ? collectionFields(shapeName, item.data) : null;
|
|
52736
53026
|
if (fields) {
|
|
52737
53027
|
const allWrefs = fields.flatMap((f) => f.wrefs);
|
|
52738
|
-
out(` ${
|
|
53028
|
+
out(` ${refList(c, allWrefs, decorations)}`);
|
|
52739
53029
|
} else if (item.data && typeof item.data === "object") {
|
|
52740
|
-
|
|
52741
|
-
const truncated = preview.length > 80 ? `${preview.slice(0, 77)}...` : preview;
|
|
52742
|
-
out(` ${c.dim}${truncated}${c.reset}`);
|
|
53030
|
+
out(` ${dataPreview(c, item.data)}`);
|
|
52743
53031
|
}
|
|
52744
53032
|
}
|
|
52745
53033
|
out(`${c.dim}${items.length} result(s)${c.reset}`);
|
|
@@ -52790,16 +53078,17 @@ var handleRefs = async (ctx, { flags, args }) => {
|
|
|
52790
53078
|
});
|
|
52791
53079
|
if (all) {
|
|
52792
53080
|
const items = [];
|
|
52793
|
-
let
|
|
52794
|
-
|
|
52795
|
-
|
|
53081
|
+
let decorations;
|
|
53082
|
+
for await (const page of paginatePages2({
|
|
53083
|
+
initialCursor: cursor,
|
|
53084
|
+
fetchPage,
|
|
53085
|
+
title: "Thing refs"
|
|
53086
|
+
})) {
|
|
52796
53087
|
items.push(...page.items ?? []);
|
|
52797
|
-
|
|
52798
|
-
break;
|
|
52799
|
-
cur = page.nextCursor;
|
|
53088
|
+
decorations = mergeDecorations(decorations, getResponseDecorations(page));
|
|
52800
53089
|
}
|
|
52801
|
-
const result2 = { items, nextCursor: undefined };
|
|
52802
|
-
writePageOutput(ctx, items, { limit: pageLimit, nextCursor: null }, () => renderRefs(ctx.out, ctx.colors, result2, wref, direction));
|
|
53090
|
+
const result2 = withDecorations({ items, nextCursor: undefined }, decorations);
|
|
53091
|
+
writePageOutput(ctx, items, { limit: pageLimit, nextCursor: null, decorations }, () => renderRefs(ctx.out, ctx.colors, result2, wref, direction));
|
|
52803
53092
|
maybeEmitAboutHint(ctx, direction, items.length, refsQueryIsNarrowed);
|
|
52804
53093
|
return;
|
|
52805
53094
|
}
|
|
@@ -52807,7 +53096,11 @@ var handleRefs = async (ctx, { flags, args }) => {
|
|
|
52807
53096
|
if (result.nextCursor) {
|
|
52808
53097
|
emitPartialPageHint(ctx, (result.items ?? []).length, result.nextCursor, boundedLimit);
|
|
52809
53098
|
}
|
|
52810
|
-
writePageOutput(ctx, result.items ?? [], {
|
|
53099
|
+
writePageOutput(ctx, result.items ?? [], {
|
|
53100
|
+
limit: boundedLimit,
|
|
53101
|
+
nextCursor: result.nextCursor ?? null,
|
|
53102
|
+
decorations: getResponseDecorations(result)
|
|
53103
|
+
}, () => renderRefs(ctx.out, ctx.colors, result, wref, direction));
|
|
52811
53104
|
maybeEmitAboutHint(ctx, direction, result.items?.length ?? 0, refsQueryIsNarrowed);
|
|
52812
53105
|
};
|
|
52813
53106
|
function maybeEmitAboutHint(ctx, direction, itemCount, refsQueryIsNarrowed) {
|
|
@@ -53073,23 +53366,25 @@ var handleSearch = async (ctx, { flags, args }) => {
|
|
|
53073
53366
|
excludeComponents,
|
|
53074
53367
|
excludeInfraShapes
|
|
53075
53368
|
});
|
|
53076
|
-
const result = {
|
|
53369
|
+
const result = withDecorations({
|
|
53077
53370
|
items: rawResult.items ?? [],
|
|
53078
53371
|
nextCursor: "nextCursor" in rawResult ? rawResult.nextCursor : undefined
|
|
53079
|
-
};
|
|
53372
|
+
}, getResponseDecorations(rawResult));
|
|
53080
53373
|
if (!all && result.nextCursor) {
|
|
53081
53374
|
emitPartialPageHint(ctx, result.items.length, result.nextCursor, boundedTextLimit);
|
|
53082
53375
|
}
|
|
53083
53376
|
writePageOutput(ctx, result.items, {
|
|
53084
53377
|
limit: all ? pageLimit : boundedTextLimit,
|
|
53085
|
-
nextCursor: result.nextCursor ?? null
|
|
53378
|
+
nextCursor: result.nextCursor ?? null,
|
|
53379
|
+
decorations: getResponseDecorations(result)
|
|
53086
53380
|
}, () => renderQueryResults(ctx.out, c, result));
|
|
53087
53381
|
};
|
|
53088
53382
|
async function fetchAllSearchPages(ctx, org, repo, queryText, opts) {
|
|
53089
53383
|
const items = [];
|
|
53090
|
-
let
|
|
53091
|
-
|
|
53092
|
-
|
|
53384
|
+
let decorations;
|
|
53385
|
+
for await (const page of paginatePages2({
|
|
53386
|
+
initialCursor: opts.cursor,
|
|
53387
|
+
fetchPage: (cursor) => ctx.client.thing.search(org, repo, queryText, {
|
|
53093
53388
|
shape: opts.shape,
|
|
53094
53389
|
kind: opts.kind,
|
|
53095
53390
|
about: opts.about,
|
|
@@ -53102,13 +53397,13 @@ async function fetchAllSearchPages(ctx, org, repo, queryText, opts) {
|
|
|
53102
53397
|
componentRef: opts.componentRef,
|
|
53103
53398
|
excludeComponents: opts.excludeComponents,
|
|
53104
53399
|
excludeInfraShapes: opts.excludeInfraShapes
|
|
53105
|
-
})
|
|
53400
|
+
}),
|
|
53401
|
+
title: "Thing search"
|
|
53402
|
+
})) {
|
|
53106
53403
|
items.push(...page.items ?? []);
|
|
53107
|
-
|
|
53108
|
-
break;
|
|
53109
|
-
cursor = page.nextCursor;
|
|
53404
|
+
decorations = mergeDecorations(decorations, getResponseDecorations(page));
|
|
53110
53405
|
}
|
|
53111
|
-
return { items, nextCursor: undefined };
|
|
53406
|
+
return withDecorations({ items, nextCursor: undefined }, decorations);
|
|
53112
53407
|
}
|
|
53113
53408
|
|
|
53114
53409
|
// ../../packages/warmhub-cli/src/domains/thing/view.ts
|
|
@@ -53349,6 +53644,7 @@ async function runSingleView(ctx, wref, flags) {
|
|
|
53349
53644
|
functionLogs: ctx.functionLogMode,
|
|
53350
53645
|
profile: ctx.profile,
|
|
53351
53646
|
clientFlags: ctx.clientFlags,
|
|
53647
|
+
decorateResponses: ctx.decorate,
|
|
53352
53648
|
signal: ctx.signal
|
|
53353
53649
|
});
|
|
53354
53650
|
return;
|
|
@@ -53374,6 +53670,7 @@ async function runBatchView(ctx, wrefs, flags) {
|
|
|
53374
53670
|
const dataMode = validateDataMode(flags["data-mode"]);
|
|
53375
53671
|
const result = await ctx.client.thing.getMany(org, repo, wrefs, flags.version, { includeRetracted, dataMode });
|
|
53376
53672
|
if (ctx.format === "jsonl") {
|
|
53673
|
+
const responseDecorations = getResponseDecorations(result);
|
|
53377
53674
|
for (const event of walkBatchResult(wrefs, result, flags.version)) {
|
|
53378
53675
|
if (event.kind === "miss") {
|
|
53379
53676
|
ctx.out(JSON.stringify({
|
|
@@ -53385,11 +53682,13 @@ async function runBatchView(ctx, wrefs, flags) {
|
|
|
53385
53682
|
ctx.out(JSON.stringify({ requested: event.requested, found: false }));
|
|
53386
53683
|
} else {
|
|
53387
53684
|
const { wref: itemWref, ...rest } = event.item;
|
|
53685
|
+
const decorations = rowDecorationsSubset(event.item, responseDecorations);
|
|
53388
53686
|
ctx.out(JSON.stringify({
|
|
53389
53687
|
requested: event.requested,
|
|
53390
53688
|
found: true,
|
|
53391
53689
|
wref: itemWref,
|
|
53392
|
-
...rest
|
|
53690
|
+
...rest,
|
|
53691
|
+
...decorations === undefined ? {} : { decorations }
|
|
53393
53692
|
}));
|
|
53394
53693
|
}
|
|
53395
53694
|
}
|
|
@@ -53634,6 +53933,7 @@ var handleView2 = async (ctx, { flags, args }) => {
|
|
|
53634
53933
|
functionLogs: ctx.functionLogMode,
|
|
53635
53934
|
profile: ctx.profile,
|
|
53636
53935
|
clientFlags: ctx.clientFlags,
|
|
53936
|
+
decorateResponses: ctx.decorate,
|
|
53637
53937
|
signal: ctx.signal
|
|
53638
53938
|
});
|
|
53639
53939
|
return;
|
|
@@ -53691,35 +53991,48 @@ var handleHistory2 = async (ctx, { flags, args }) => {
|
|
|
53691
53991
|
functionLogs: ctx.functionLogMode,
|
|
53692
53992
|
profile: ctx.profile,
|
|
53693
53993
|
clientFlags: ctx.clientFlags,
|
|
53994
|
+
decorateResponses: ctx.decorate,
|
|
53694
53995
|
signal: ctx.signal
|
|
53695
53996
|
});
|
|
53696
53997
|
return;
|
|
53697
53998
|
}
|
|
53698
53999
|
const versions2 = [];
|
|
53699
|
-
let cursor = flags.cursor;
|
|
53700
54000
|
let thing;
|
|
53701
54001
|
let nextCursor;
|
|
53702
|
-
|
|
53703
|
-
|
|
53704
|
-
|
|
53705
|
-
|
|
53706
|
-
|
|
53707
|
-
|
|
53708
|
-
|
|
53709
|
-
|
|
54002
|
+
let decorations;
|
|
54003
|
+
const fetchPage = (cursor) => ctx.client.thing.history(org, repo, {
|
|
54004
|
+
wref,
|
|
54005
|
+
includeRetracted: flags["include-retracted"],
|
|
54006
|
+
limit,
|
|
54007
|
+
cursor
|
|
54008
|
+
});
|
|
54009
|
+
if (flags.all) {
|
|
54010
|
+
for await (const page of paginatePages2({
|
|
54011
|
+
initialCursor: flags.cursor,
|
|
54012
|
+
fetchPage,
|
|
54013
|
+
title: "Assertion history"
|
|
54014
|
+
})) {
|
|
54015
|
+
thing = thing ?? page.thing;
|
|
54016
|
+
versions2.push(...page.versions ?? []);
|
|
54017
|
+
decorations = mergeDecorations(decorations, getResponseDecorations(page));
|
|
54018
|
+
nextCursor = page.nextCursor;
|
|
54019
|
+
}
|
|
54020
|
+
} else {
|
|
54021
|
+
const page = await fetchPage(flags.cursor);
|
|
54022
|
+
thing = page.thing;
|
|
53710
54023
|
versions2.push(...page.versions ?? []);
|
|
54024
|
+
decorations = getResponseDecorations(page);
|
|
53711
54025
|
nextCursor = page.nextCursor;
|
|
53712
|
-
|
|
53713
|
-
|
|
53714
|
-
const result = {
|
|
54026
|
+
}
|
|
54027
|
+
const result = withDecorations({
|
|
53715
54028
|
thing,
|
|
53716
54029
|
versions: versions2,
|
|
53717
54030
|
nextCursor: flags.all ? undefined : nextCursor
|
|
53718
|
-
};
|
|
54031
|
+
}, decorations);
|
|
53719
54032
|
if (!flags.all && result.nextCursor) {
|
|
53720
54033
|
emitPartialPageHint(ctx, result.versions.length, result.nextCursor, limit);
|
|
53721
54034
|
}
|
|
53722
|
-
writePageOutput(ctx, result.versions, { limit, nextCursor: result.nextCursor ?? null }, () => renderHistory(ctx.out, ctx.colors, result));
|
|
54035
|
+
writePageOutput(ctx, result.versions, { limit, nextCursor: result.nextCursor ?? null, decorations }, () => renderHistory(ctx.out, ctx.colors, result));
|
|
53723
54036
|
};
|
|
53724
54037
|
var listFlags = {
|
|
53725
54038
|
about: flag.string({
|
|
@@ -53816,6 +54129,7 @@ var handleList = async (ctx, { flags, args }) => {
|
|
|
53816
54129
|
functionLogs: ctx.functionLogMode,
|
|
53817
54130
|
profile: ctx.profile,
|
|
53818
54131
|
clientFlags: ctx.clientFlags,
|
|
54132
|
+
decorateResponses: ctx.decorate,
|
|
53819
54133
|
signal: ctx.signal
|
|
53820
54134
|
});
|
|
53821
54135
|
return;
|
|
@@ -53829,7 +54143,8 @@ var handleList = async (ctx, { flags, args }) => {
|
|
|
53829
54143
|
}
|
|
53830
54144
|
writePageOutput(ctx, result2.items ?? [], {
|
|
53831
54145
|
limit: all ? pageLimit : boundedLimit,
|
|
53832
|
-
nextCursor: result2.nextCursor ?? null
|
|
54146
|
+
nextCursor: result2.nextCursor ?? null,
|
|
54147
|
+
decorations: getResponseDecorations(result2)
|
|
53833
54148
|
}, () => renderHead(ctx.out, ctx.colors, ctx.chars, result2, org, repo, shape, "assertion"));
|
|
53834
54149
|
return;
|
|
53835
54150
|
}
|
|
@@ -53860,6 +54175,7 @@ var handleList = async (ctx, { flags, args }) => {
|
|
|
53860
54175
|
functionLogs: ctx.functionLogMode,
|
|
53861
54176
|
profile: ctx.profile,
|
|
53862
54177
|
clientFlags: ctx.clientFlags,
|
|
54178
|
+
decorateResponses: ctx.decorate,
|
|
53863
54179
|
signal: ctx.signal
|
|
53864
54180
|
});
|
|
53865
54181
|
return;
|
|
@@ -53888,7 +54204,8 @@ var handleList = async (ctx, { flags, args }) => {
|
|
|
53888
54204
|
}
|
|
53889
54205
|
writePageOutput(ctx, result.assertions ?? [], {
|
|
53890
54206
|
limit: all ? pageLimit : boundedLimit,
|
|
53891
|
-
nextCursor: result.nextCursor ?? null
|
|
54207
|
+
nextCursor: result.nextCursor ?? null,
|
|
54208
|
+
decorations: getResponseDecorations(result)
|
|
53892
54209
|
}, () => renderAbout(ctx.out, ctx.colors, result));
|
|
53893
54210
|
};
|
|
53894
54211
|
|
|
@@ -54044,13 +54361,15 @@ Run \`wh auth login --profile ${explicitProfile}\` to create it.`);
|
|
|
54044
54361
|
process.stderr.write(`warning: ignoring malformed client flag "${token}"
|
|
54045
54362
|
`);
|
|
54046
54363
|
}
|
|
54364
|
+
const decorate = explicitDecorateFlag(invocation.flags) ?? profileData?.settings?.decorate ?? true;
|
|
54047
54365
|
const client = args.client ?? createClient(config2, {
|
|
54048
54366
|
functionLogs: args.functionLogs,
|
|
54049
54367
|
profile: effectiveProfile,
|
|
54050
54368
|
signal: args.signal,
|
|
54051
|
-
clientFlags
|
|
54369
|
+
clientFlags,
|
|
54370
|
+
decorateResponses: decorate
|
|
54052
54371
|
});
|
|
54053
|
-
return { config: config2, profile: effectiveProfile, client, clientFlags };
|
|
54372
|
+
return { config: config2, profile: effectiveProfile, client, clientFlags, decorate };
|
|
54054
54373
|
}
|
|
54055
54374
|
|
|
54056
54375
|
// ../../packages/warmhub-cli/src/domains/auth-shared.ts
|
|
@@ -54064,10 +54383,11 @@ function clientForStoredFlags(ctx, profile) {
|
|
|
54064
54383
|
functionLogs: ctx.functionLogMode,
|
|
54065
54384
|
profile,
|
|
54066
54385
|
signal: ctx.signal,
|
|
54067
|
-
clientFlags: flags
|
|
54386
|
+
clientFlags: flags,
|
|
54387
|
+
decorateResponses: ctx.decorate
|
|
54068
54388
|
});
|
|
54069
54389
|
}
|
|
54070
|
-
async function loginWithToken(ctx, profile, explicitFlags) {
|
|
54390
|
+
async function loginWithToken(ctx, profile, explicitFlags, explicitDecorate) {
|
|
54071
54391
|
const c = ctx.colors;
|
|
54072
54392
|
if (process.stdin.isTTY) {
|
|
54073
54393
|
throw new CliError(2 /* UserInput */, "USER_INPUT", "No token provided on stdin.", undefined, 'Pipe a JWT token via stdin: echo "$TOKEN" | wh auth login --with-token');
|
|
@@ -54104,7 +54424,7 @@ async function loginWithToken(ctx, profile, explicitFlags) {
|
|
|
54104
54424
|
source: "token"
|
|
54105
54425
|
},
|
|
54106
54426
|
apiUrl: ctx.config.apiUrl
|
|
54107
|
-
}, explicitFlags);
|
|
54427
|
+
}, explicitFlags, explicitDecorate);
|
|
54108
54428
|
try {
|
|
54109
54429
|
await clientForStoredFlags(ctx, profile).auth.sync();
|
|
54110
54430
|
} catch (err) {
|
|
@@ -54193,7 +54513,7 @@ async function pollForDeviceToken(params) {
|
|
|
54193
54513
|
poll().catch(reject);
|
|
54194
54514
|
});
|
|
54195
54515
|
}
|
|
54196
|
-
function renderTokenInfo(ctx, info, profileName, apiUrl, identityWref, flags) {
|
|
54516
|
+
function renderTokenInfo(ctx, info, profileName, apiUrl, identityWref, flags, decorate) {
|
|
54197
54517
|
const c = ctx.colors;
|
|
54198
54518
|
const prefix = profileName ? `${c.bold}${profileName}${c.reset}: ` : "";
|
|
54199
54519
|
const sourceLabel = {
|
|
@@ -54231,6 +54551,9 @@ function renderTokenInfo(ctx, info, profileName, apiUrl, identityWref, flags) {
|
|
|
54231
54551
|
if (flags?.length) {
|
|
54232
54552
|
ctx.status(` ${c.dim}Client flags:${c.reset} ${flags.join(", ")}`);
|
|
54233
54553
|
}
|
|
54554
|
+
if (decorate !== undefined && decorate !== null) {
|
|
54555
|
+
ctx.status(` ${c.dim}Decorate:${c.reset} ${decorate ? "on" : "off"}`);
|
|
54556
|
+
}
|
|
54234
54557
|
}
|
|
54235
54558
|
async function fetchIdentityWref(ctx) {
|
|
54236
54559
|
if (process.env.WH_TOKEN)
|
|
@@ -54269,6 +54592,7 @@ function authStatusEntry(info, options) {
|
|
|
54269
54592
|
email: info.email ?? null,
|
|
54270
54593
|
expiresAt: info.expiresAt ?? null,
|
|
54271
54594
|
flags: options.flags ?? [],
|
|
54595
|
+
decorate: options.decorate ?? null,
|
|
54272
54596
|
identityWref: options.identityWref ?? null,
|
|
54273
54597
|
profile: options.profile ?? null,
|
|
54274
54598
|
source: info.source
|
|
@@ -54296,8 +54620,9 @@ var handleLogin = async (ctx, { flags }) => {
|
|
|
54296
54620
|
}
|
|
54297
54621
|
}
|
|
54298
54622
|
const explicitFlags = requestedFlags.length > 0 ? [...new Set(requestedFlags)].sort() : undefined;
|
|
54623
|
+
const explicitDecorate = explicitDecorateFlag(flags);
|
|
54299
54624
|
if (flags["with-token"]) {
|
|
54300
|
-
return loginWithToken(ctx, profile, explicitFlags);
|
|
54625
|
+
return loginWithToken(ctx, profile, explicitFlags, explicitDecorate);
|
|
54301
54626
|
}
|
|
54302
54627
|
const c = ctx.colors;
|
|
54303
54628
|
let clientId;
|
|
@@ -54306,7 +54631,8 @@ var handleLogin = async (ctx, { flags }) => {
|
|
|
54306
54631
|
} catch {
|
|
54307
54632
|
clientId = await createUnauthenticatedClient(ctx.config, {
|
|
54308
54633
|
functionLogs: ctx.functionLogMode,
|
|
54309
|
-
clientFlags: ctx.clientFlags
|
|
54634
|
+
clientFlags: ctx.clientFlags,
|
|
54635
|
+
decorateResponses: ctx.decorate
|
|
54310
54636
|
}).auth.getClientId();
|
|
54311
54637
|
}
|
|
54312
54638
|
if (!clientId) {
|
|
@@ -54381,7 +54707,7 @@ var handleLogin = async (ctx, { flags }) => {
|
|
|
54381
54707
|
source: "device"
|
|
54382
54708
|
},
|
|
54383
54709
|
apiUrl: ctx.config.apiUrl
|
|
54384
|
-
}, explicitFlags);
|
|
54710
|
+
}, explicitFlags, explicitDecorate);
|
|
54385
54711
|
try {
|
|
54386
54712
|
await clientForStoredFlags(ctx, profile).auth.sync();
|
|
54387
54713
|
} catch (err) {
|
|
@@ -54424,10 +54750,11 @@ var handleStatus = async (ctx, { flags }) => {
|
|
|
54424
54750
|
active: true,
|
|
54425
54751
|
apiUrl: prof.apiUrl,
|
|
54426
54752
|
flags: Array.isArray(prof.flags) ? prof.flags : [],
|
|
54753
|
+
decorate: prof.settings?.decorate,
|
|
54427
54754
|
identityWref,
|
|
54428
54755
|
profile: selectedProfile
|
|
54429
54756
|
});
|
|
54430
|
-
writeOutput(ctx, authStatusOutput(selectedProfile, [entry]), () => renderTokenInfo(ctx, info, selectedProfile, prof.apiUrl, identityWref, entry.flags));
|
|
54757
|
+
writeOutput(ctx, authStatusOutput(selectedProfile, [entry]), () => renderTokenInfo(ctx, info, selectedProfile, prof.apiUrl, identityWref, entry.flags, entry.decorate));
|
|
54431
54758
|
return;
|
|
54432
54759
|
}
|
|
54433
54760
|
const envToken = process.env.WH_TOKEN;
|
|
@@ -54461,10 +54788,11 @@ var handleStatus = async (ctx, { flags }) => {
|
|
|
54461
54788
|
active: !envToken && name === activeProfile,
|
|
54462
54789
|
apiUrl: prof.apiUrl,
|
|
54463
54790
|
flags: profileFlags,
|
|
54791
|
+
decorate: prof.settings?.decorate,
|
|
54464
54792
|
identityWref,
|
|
54465
54793
|
profile: name
|
|
54466
54794
|
}));
|
|
54467
|
-
prettyEntries.push(() => renderTokenInfo(ctx, info, name, prof.apiUrl, identityWref, profileFlags));
|
|
54795
|
+
prettyEntries.push(() => renderTokenInfo(ctx, info, name, prof.apiUrl, identityWref, profileFlags, prof.settings?.decorate));
|
|
54468
54796
|
}
|
|
54469
54797
|
}
|
|
54470
54798
|
writeOutput(ctx, authStatusOutput(envToken ? null : activeProfile, entries), () => {
|
|
@@ -54986,30 +55314,33 @@ function renderMembers(ctx, result) {
|
|
|
54986
55314
|
ctx.out(`${c.dim}No members${c.reset}`);
|
|
54987
55315
|
return;
|
|
54988
55316
|
}
|
|
55317
|
+
const decorations = getResponseDecorations(result);
|
|
54989
55318
|
for (const item of result.items) {
|
|
54990
55319
|
const position = item.position ?? 0;
|
|
54991
|
-
ctx.out(`${String(position).padStart(4, " ")} ${
|
|
55320
|
+
ctx.out(`${String(position).padStart(4, " ")} ${refDisplay(c, item.wref, decorations)}`);
|
|
54992
55321
|
}
|
|
54993
55322
|
}
|
|
54994
55323
|
function renderContains(ctx, result) {
|
|
54995
55324
|
const c = ctx.colors;
|
|
55325
|
+
const decorations = getResponseDecorations(result);
|
|
54996
55326
|
for (const item of result.results) {
|
|
54997
55327
|
const marker = item.contains ? ctx.chars.check : ctx.chars.cross;
|
|
54998
55328
|
const color = item.contains ? c.green : c.red;
|
|
54999
55329
|
const at = item.positions === undefined || item.positions.length === 0 ? "" : ` ${c.dim}@${item.positions.join(",")}${c.reset}`;
|
|
55000
|
-
ctx.out(`${color}${marker}${c.reset} ${
|
|
55330
|
+
ctx.out(`${color}${marker}${c.reset} ${refDisplay(c, item.member, decorations)}${at}`);
|
|
55001
55331
|
}
|
|
55002
55332
|
}
|
|
55003
55333
|
function renderDiff(ctx, result) {
|
|
55004
55334
|
const c = ctx.colors;
|
|
55335
|
+
const decorations = getResponseDecorations(result);
|
|
55005
55336
|
if (result.mode === "ordered") {
|
|
55006
55337
|
if (result.changed.length === 0) {
|
|
55007
55338
|
ctx.out(`${c.dim}No ordered differences${c.reset}`);
|
|
55008
55339
|
return;
|
|
55009
55340
|
}
|
|
55010
55341
|
for (const item of result.changed) {
|
|
55011
|
-
const left = item.left?.wref
|
|
55012
|
-
const right = item.right?.wref
|
|
55342
|
+
const left = item.left?.wref ? refDisplay(c, item.left.wref, decorations) : `${c.dim}(none)${c.reset}`;
|
|
55343
|
+
const right = item.right?.wref ? refDisplay(c, item.right.wref, decorations) : `${c.dim}(none)${c.reset}`;
|
|
55013
55344
|
ctx.out(`${String(item.position).padStart(4, " ")} ${left} -> ${right}`);
|
|
55014
55345
|
}
|
|
55015
55346
|
return;
|
|
@@ -55019,10 +55350,10 @@ function renderDiff(ctx, result) {
|
|
|
55019
55350
|
return;
|
|
55020
55351
|
}
|
|
55021
55352
|
for (const member of result.added) {
|
|
55022
|
-
ctx.out(`${c.green}+${c.reset} ${member.wref}`);
|
|
55353
|
+
ctx.out(`${c.green}+${c.reset} ${refDisplay(c, member.wref, decorations)}`);
|
|
55023
55354
|
}
|
|
55024
55355
|
for (const member of result.removed) {
|
|
55025
|
-
ctx.out(`${c.red}-${c.reset} ${member.wref}`);
|
|
55356
|
+
ctx.out(`${c.red}-${c.reset} ${refDisplay(c, member.wref, decorations)}`);
|
|
55026
55357
|
}
|
|
55027
55358
|
}
|
|
55028
55359
|
function renderStats(ctx, result) {
|
|
@@ -55413,33 +55744,34 @@ var handleCollectionMembers = async (ctx, { flags, args }) => {
|
|
|
55413
55744
|
const pageLimit = flags.all ? Math.min(flags.limit ?? AUTO_PAGE_LIMIT, MAX_PAGE_LIMIT) : boundedLimit;
|
|
55414
55745
|
if (flags.all) {
|
|
55415
55746
|
const items = [];
|
|
55416
|
-
let
|
|
55747
|
+
let decorations;
|
|
55417
55748
|
let snapshotVersion = flags.version;
|
|
55418
55749
|
let firstPage;
|
|
55419
|
-
|
|
55420
|
-
|
|
55750
|
+
for await (const page of paginatePages2({
|
|
55751
|
+
initialCursor: flags.cursor,
|
|
55752
|
+
fetchPage: (cursor) => ctx.client.collection.members(org, repo, wref, {
|
|
55421
55753
|
version: snapshotVersion,
|
|
55422
55754
|
limit: pageLimit,
|
|
55423
55755
|
cursor
|
|
55424
|
-
})
|
|
55756
|
+
}),
|
|
55757
|
+
title: "Collection members"
|
|
55758
|
+
})) {
|
|
55425
55759
|
firstPage ??= {
|
|
55426
55760
|
type: page.type,
|
|
55427
55761
|
wref: page.wref,
|
|
55428
55762
|
version: page.version
|
|
55429
55763
|
};
|
|
55430
55764
|
items.push(...page.items);
|
|
55765
|
+
decorations = mergeDecorations(decorations, getResponseDecorations(page));
|
|
55431
55766
|
snapshotVersion ??= page.version;
|
|
55432
|
-
if (!page.nextCursor)
|
|
55433
|
-
break;
|
|
55434
|
-
cursor = page.nextCursor;
|
|
55435
55767
|
}
|
|
55436
|
-
writeCollectionMembersOutput(ctx, {
|
|
55768
|
+
writeCollectionMembersOutput(ctx, withDecorations({
|
|
55437
55769
|
type: firstPage?.type ?? "set",
|
|
55438
55770
|
wref: firstPage?.wref ?? wref,
|
|
55439
55771
|
version: snapshotVersion ?? firstPage?.version ?? flags.version ?? 1,
|
|
55440
55772
|
items,
|
|
55441
55773
|
nextCursor: undefined
|
|
55442
|
-
}, { limit: pageLimit, nextCursor: null });
|
|
55774
|
+
}, decorations), { limit: pageLimit, nextCursor: null, decorations });
|
|
55443
55775
|
return;
|
|
55444
55776
|
}
|
|
55445
55777
|
const result = await ctx.client.collection.members(org, repo, wref, {
|
|
@@ -55452,7 +55784,8 @@ var handleCollectionMembers = async (ctx, { flags, args }) => {
|
|
|
55452
55784
|
}
|
|
55453
55785
|
writeCollectionMembersOutput(ctx, result, {
|
|
55454
55786
|
limit: boundedLimit,
|
|
55455
|
-
nextCursor: result.nextCursor ?? null
|
|
55787
|
+
nextCursor: result.nextCursor ?? null,
|
|
55788
|
+
decorations: getResponseDecorations(result)
|
|
55456
55789
|
});
|
|
55457
55790
|
};
|
|
55458
55791
|
function writeCollectionMembersOutput(ctx, result, page) {
|
|
@@ -55463,12 +55796,13 @@ function writeCollectionMembersOutput(ctx, result, page) {
|
|
|
55463
55796
|
wref: result.wref,
|
|
55464
55797
|
version: result.version,
|
|
55465
55798
|
items: result.items,
|
|
55799
|
+
...page.decorations === undefined ? {} : { decorations: page.decorations },
|
|
55466
55800
|
page: envelope.page
|
|
55467
55801
|
});
|
|
55468
55802
|
return;
|
|
55469
55803
|
}
|
|
55470
55804
|
if (ctx.format === "jsonl") {
|
|
55471
|
-
printJsonl(ctx.out, result.items);
|
|
55805
|
+
printJsonl(ctx.out, decorateJsonlRows(result.items, page.decorations));
|
|
55472
55806
|
return;
|
|
55473
55807
|
}
|
|
55474
55808
|
renderMembers(ctx, result);
|
|
@@ -55857,6 +56191,24 @@ function identifyCommitSubmitStreamRow(row) {
|
|
|
55857
56191
|
// ../../packages/warmhub-cli/src/domains/commit-submit-template.ts
|
|
55858
56192
|
import { writeFile } from "node:fs/promises";
|
|
55859
56193
|
var WRITE_TEMPLATE_KINDS = ["thing", "assertion"];
|
|
56194
|
+
var COLLECTION_TEMPLATE_SPECS = {
|
|
56195
|
+
Arc: {
|
|
56196
|
+
type: "arc",
|
|
56197
|
+
members: ["Shape/FILL_IN_FROM", "Shape/FILL_IN_TO"]
|
|
56198
|
+
},
|
|
56199
|
+
Bond: {
|
|
56200
|
+
type: "bond",
|
|
56201
|
+
members: ["Shape/FILL_IN_1", "Shape/FILL_IN_2"]
|
|
56202
|
+
},
|
|
56203
|
+
Set: { type: "set", members: ["Shape/FILL_IN"] },
|
|
56204
|
+
List: { type: "list", members: ["Shape/FILL_IN"] }
|
|
56205
|
+
};
|
|
56206
|
+
function collectionTemplateSpec(shapeName) {
|
|
56207
|
+
if (!isBuiltinCollectionShape(shapeName) || shapeName === "Pair") {
|
|
56208
|
+
return;
|
|
56209
|
+
}
|
|
56210
|
+
return COLLECTION_TEMPLATE_SPECS[shapeName];
|
|
56211
|
+
}
|
|
55860
56212
|
function zeroValueForField(fieldSpec) {
|
|
55861
56213
|
if (Array.isArray(fieldSpec))
|
|
55862
56214
|
return [];
|
|
@@ -55954,12 +56306,27 @@ var handleTemplate = async (ctx, { flags, args }) => {
|
|
|
55954
56306
|
const count = Math.max(1, flags.count ?? 1);
|
|
55955
56307
|
const operations = [];
|
|
55956
56308
|
for (const shapeName of shapeNames) {
|
|
56309
|
+
const collectionTemplate = templateKind === "thing" ? collectionTemplateSpec(shapeName) : undefined;
|
|
56310
|
+
const operationKind = collectionTemplate ? "collection" : templateKind;
|
|
55957
56311
|
if (operationType === "retract") {
|
|
55958
56312
|
for (let i = 0;i < count; i++) {
|
|
55959
56313
|
operations.push({
|
|
55960
56314
|
operation: "retract",
|
|
55961
|
-
kind:
|
|
55962
|
-
name:
|
|
56315
|
+
kind: operationKind,
|
|
56316
|
+
name: operationKind === "shape" ? shapeName : `${shapeName}/FILL_IN`
|
|
56317
|
+
});
|
|
56318
|
+
}
|
|
56319
|
+
continue;
|
|
56320
|
+
}
|
|
56321
|
+
const nameSuffix = count > 1 ? (i) => `my-${shapeName.toLowerCase()}-${i + 1}` : () => `my-${shapeName.toLowerCase()}`;
|
|
56322
|
+
if (collectionTemplate) {
|
|
56323
|
+
for (let i = 0;i < count; i++) {
|
|
56324
|
+
operations.push({
|
|
56325
|
+
operation: operationType,
|
|
56326
|
+
kind: "collection",
|
|
56327
|
+
type: collectionTemplate.type,
|
|
56328
|
+
name: operationType === "add" ? nameSuffix(i) : `${shapeName}/FILL_IN`,
|
|
56329
|
+
members: [...collectionTemplate.members]
|
|
55963
56330
|
});
|
|
55964
56331
|
}
|
|
55965
56332
|
continue;
|
|
@@ -55973,7 +56340,6 @@ var handleTemplate = async (ctx, { flags, args }) => {
|
|
|
55973
56340
|
aboutPlaceholder = flags.about ? parseCollectionAboutFlag(flags.about) : "Shape/FILL_IN";
|
|
55974
56341
|
}
|
|
55975
56342
|
const data = buildTemplateData(fields);
|
|
55976
|
-
const nameSuffix = count > 1 ? (i) => `my-${shapeName.toLowerCase()}-${i + 1}` : () => `my-${shapeName.toLowerCase()}`;
|
|
55977
56343
|
const affirmedTargetsPlaceholder = templateKind === "assertion" ? { affirmedTargets: [] } : {};
|
|
55978
56344
|
for (let i = 0;i < count; i++) {
|
|
55979
56345
|
const op = operationType === "add" ? {
|
|
@@ -58892,20 +59258,24 @@ var handleTeardown = async (ctx, { args, flags }) => {
|
|
|
58892
59258
|
var DEFAULT_LIMIT = 25;
|
|
58893
59259
|
async function runGlobalSearchCommand(ctx, args) {
|
|
58894
59260
|
const c = ctx.colors;
|
|
58895
|
-
const
|
|
58896
|
-
|
|
58897
|
-
let nextCursor = first.nextCursor;
|
|
59261
|
+
const items = [];
|
|
59262
|
+
let nextCursor;
|
|
58898
59263
|
if (args.all) {
|
|
58899
|
-
|
|
58900
|
-
|
|
58901
|
-
|
|
58902
|
-
|
|
58903
|
-
|
|
58904
|
-
seenCursors.add(nextCursor);
|
|
58905
|
-
const page = await args.fetch({ limit: args.limit, cursor: nextCursor });
|
|
59264
|
+
for await (const page of paginatePages2({
|
|
59265
|
+
initialCursor: args.cursor,
|
|
59266
|
+
fetchPage: (cursor) => args.fetch({ limit: args.limit, cursor }),
|
|
59267
|
+
title: args.title
|
|
59268
|
+
})) {
|
|
58906
59269
|
items.push(...page.items);
|
|
58907
59270
|
nextCursor = page.nextCursor;
|
|
58908
59271
|
}
|
|
59272
|
+
} else {
|
|
59273
|
+
const page = await args.fetch({
|
|
59274
|
+
limit: args.limit,
|
|
59275
|
+
cursor: args.cursor
|
|
59276
|
+
});
|
|
59277
|
+
items.push(...page.items);
|
|
59278
|
+
nextCursor = page.nextCursor;
|
|
58909
59279
|
}
|
|
58910
59280
|
if (!args.all && nextCursor) {
|
|
58911
59281
|
emitPartialPageHint(ctx, items.length, nextCursor, args.limit ?? DEFAULT_LIMIT);
|
|
@@ -58929,26 +59299,22 @@ async function runGlobalSearchCommand(ctx, args) {
|
|
|
58929
59299
|
|
|
58930
59300
|
// ../../packages/warmhub-cli/src/domains/component-list-handlers.ts
|
|
58931
59301
|
async function fetchComponentPages(client, org, repo, opts) {
|
|
58932
|
-
const
|
|
58933
|
-
|
|
58934
|
-
|
|
58935
|
-
});
|
|
58936
|
-
const items = [...firstPage.items ?? []];
|
|
58937
|
-
let nextCursor = firstPage.nextCursor;
|
|
59302
|
+
const items = [];
|
|
59303
|
+
let nextCursor;
|
|
59304
|
+
const fetchPage = (cursor) => client.component.list(org, repo, { limit: opts.limit, cursor });
|
|
58938
59305
|
if (opts.all) {
|
|
58939
|
-
|
|
58940
|
-
|
|
58941
|
-
|
|
58942
|
-
|
|
58943
|
-
|
|
58944
|
-
seenCursors.add(nextCursor);
|
|
58945
|
-
const page = await client.component.list(org, repo, {
|
|
58946
|
-
limit: opts.limit,
|
|
58947
|
-
cursor: nextCursor
|
|
58948
|
-
});
|
|
59306
|
+
for await (const page of paginatePages2({
|
|
59307
|
+
initialCursor: opts.cursor,
|
|
59308
|
+
fetchPage,
|
|
59309
|
+
title: "Component list"
|
|
59310
|
+
})) {
|
|
58949
59311
|
items.push(...page.items ?? []);
|
|
58950
59312
|
nextCursor = page.nextCursor;
|
|
58951
59313
|
}
|
|
59314
|
+
} else {
|
|
59315
|
+
const page = await fetchPage(opts.cursor);
|
|
59316
|
+
items.push(...page.items ?? []);
|
|
59317
|
+
nextCursor = page.nextCursor;
|
|
58952
59318
|
}
|
|
58953
59319
|
return { items, nextCursor };
|
|
58954
59320
|
}
|
|
@@ -63341,23 +63707,26 @@ var handleList6 = async (ctx, { flags, args }) => {
|
|
|
63341
63707
|
const c = ctx.colors;
|
|
63342
63708
|
const all = flags.all;
|
|
63343
63709
|
const includeArchived = flags["include-archived"];
|
|
63344
|
-
const
|
|
63710
|
+
const items = [];
|
|
63711
|
+
let nextCursor;
|
|
63712
|
+
const fetchPage = (cursor) => ctx.client.repo.list(orgName, {
|
|
63345
63713
|
includeArchived,
|
|
63346
63714
|
limit: flags.limit,
|
|
63347
|
-
cursor
|
|
63715
|
+
cursor
|
|
63348
63716
|
});
|
|
63349
|
-
const items = [...firstPage.items];
|
|
63350
|
-
let nextCursor = firstPage.nextCursor;
|
|
63351
63717
|
if (all) {
|
|
63352
|
-
|
|
63353
|
-
|
|
63354
|
-
|
|
63355
|
-
|
|
63356
|
-
|
|
63357
|
-
});
|
|
63718
|
+
for await (const page of paginatePages2({
|
|
63719
|
+
initialCursor: flags.cursor,
|
|
63720
|
+
fetchPage,
|
|
63721
|
+
title: "Repository list"
|
|
63722
|
+
})) {
|
|
63358
63723
|
items.push(...page.items);
|
|
63359
63724
|
nextCursor = page.nextCursor;
|
|
63360
63725
|
}
|
|
63726
|
+
} else {
|
|
63727
|
+
const page = await fetchPage(flags.cursor);
|
|
63728
|
+
items.push(...page.items);
|
|
63729
|
+
nextCursor = page.nextCursor;
|
|
63361
63730
|
}
|
|
63362
63731
|
if (!all && nextCursor) {
|
|
63363
63732
|
emitPartialPageHint(ctx, items.length, nextCursor, Math.min(flags.limit ?? DEFAULT_REPO_LIST_LIMIT, MAX_REPO_LIST_LIMIT));
|
|
@@ -63870,34 +64239,47 @@ var handleHistory3 = async (ctx, { flags, args }) => {
|
|
|
63870
64239
|
functionLogs: ctx.functionLogMode,
|
|
63871
64240
|
profile: ctx.profile,
|
|
63872
64241
|
clientFlags: ctx.clientFlags,
|
|
64242
|
+
decorateResponses: ctx.decorate,
|
|
63873
64243
|
signal: ctx.signal
|
|
63874
64244
|
});
|
|
63875
64245
|
return;
|
|
63876
64246
|
}
|
|
63877
64247
|
const versions2 = [];
|
|
63878
|
-
let next = cursor;
|
|
63879
64248
|
let thing;
|
|
63880
64249
|
let nextCursor;
|
|
63881
|
-
|
|
63882
|
-
|
|
63883
|
-
|
|
63884
|
-
|
|
63885
|
-
|
|
63886
|
-
|
|
63887
|
-
|
|
64250
|
+
let decorations;
|
|
64251
|
+
const fetchPage = (pageCursor) => ctx.client.shape.history(org, repo2, bareName, {
|
|
64252
|
+
includeRetracted,
|
|
64253
|
+
limit: pageLimit,
|
|
64254
|
+
cursor: pageCursor
|
|
64255
|
+
});
|
|
64256
|
+
if (all) {
|
|
64257
|
+
for await (const page of paginatePages2({
|
|
64258
|
+
initialCursor: cursor,
|
|
64259
|
+
fetchPage,
|
|
64260
|
+
title: "Shape history"
|
|
64261
|
+
})) {
|
|
64262
|
+
thing = thing ?? page.thing;
|
|
64263
|
+
versions2.push(...page.versions ?? []);
|
|
64264
|
+
decorations = mergeDecorations(decorations, getResponseDecorations(page));
|
|
64265
|
+
nextCursor = page.nextCursor;
|
|
64266
|
+
}
|
|
64267
|
+
} else {
|
|
64268
|
+
const page = await fetchPage(cursor);
|
|
64269
|
+
thing = page.thing;
|
|
63888
64270
|
versions2.push(...page.versions ?? []);
|
|
64271
|
+
decorations = getResponseDecorations(page);
|
|
63889
64272
|
nextCursor = page.nextCursor;
|
|
63890
|
-
|
|
63891
|
-
|
|
63892
|
-
const result = {
|
|
64273
|
+
}
|
|
64274
|
+
const result = withDecorations({
|
|
63893
64275
|
thing,
|
|
63894
64276
|
versions: versions2,
|
|
63895
64277
|
nextCursor: all ? undefined : nextCursor
|
|
63896
|
-
};
|
|
64278
|
+
}, decorations);
|
|
63897
64279
|
if (!all && result.nextCursor) {
|
|
63898
64280
|
emitPartialPageHint(ctx, (result.versions ?? []).length, result.nextCursor, pageLimit);
|
|
63899
64281
|
}
|
|
63900
|
-
writePageOutput(ctx, result.versions ?? [], { limit: pageLimit, nextCursor: result.nextCursor ?? null }, () => renderHistory(ctx.out, ctx.colors, result));
|
|
64282
|
+
writePageOutput(ctx, result.versions ?? [], { limit: pageLimit, nextCursor: result.nextCursor ?? null, decorations }, () => renderHistory(ctx.out, ctx.colors, result));
|
|
63901
64283
|
};
|
|
63902
64284
|
|
|
63903
64285
|
// ../../packages/warmhub-cli/src/domains/shape/list.ts
|
|
@@ -64650,14 +65032,8 @@ var handleView8 = async (ctx, { args, flags }) => {
|
|
|
64650
65032
|
ctx.out(` effective source: ${c.cyan}${operation.effectiveSourceRepo}${c.reset}`);
|
|
64651
65033
|
}
|
|
64652
65034
|
ctx.out(` revision: ${operation.revision} (${operation.lifecycle})`);
|
|
64653
|
-
ctx.out(` routing: ${operation.routingStatus}, generation ${operation.routingGeneration}${operation.routingShard === null ? "" : `, shard ${operation.routingShard}`}`);
|
|
64654
65035
|
ctx.out(` matcher: ${operation.matcherVersion} (${operation.matcherDigest})`);
|
|
64655
|
-
|
|
64656
|
-
ctx.out(` target generation: ${operation.targetGeneration}`);
|
|
64657
|
-
}
|
|
64658
|
-
if (operation.credentialGeneration !== null) {
|
|
64659
|
-
ctx.out(` credential generation: ${operation.credentialGeneration}`);
|
|
64660
|
-
}
|
|
65036
|
+
ctx.out(` credential generation: ${operation.credentialGeneration}`);
|
|
64661
65037
|
if (operation.retirement) {
|
|
64662
65038
|
ctx.out(` retired at: ${new Date(operation.retirement.retiredAt).toISOString()}`);
|
|
64663
65039
|
ctx.out(` retirement reason: ${operation.retirement.reason}`);
|
|
@@ -64881,6 +65257,7 @@ var handleLog = async (ctx, { flags, args }) => {
|
|
|
64881
65257
|
functionLogs: ctx.functionLogMode,
|
|
64882
65258
|
profile: ctx.profile,
|
|
64883
65259
|
clientFlags: ctx.clientFlags,
|
|
65260
|
+
decorateResponses: ctx.decorate,
|
|
64884
65261
|
signal: ctx.signal
|
|
64885
65262
|
});
|
|
64886
65263
|
return;
|
|
@@ -66069,13 +66446,22 @@ var handleEvaluate = async (ctx, { args, flags }) => {
|
|
|
66069
66446
|
const boundedLimit = Math.min(flags.limit ?? DEFAULT_PAGE_LIMIT, MAX_PAGE_LIMIT);
|
|
66070
66447
|
const pageLimit = flags.all ? Math.min(flags.limit ?? AUTO_PAGE_LIMIT, MAX_PAGE_LIMIT) : boundedLimit;
|
|
66071
66448
|
if (flags.all) {
|
|
66072
|
-
const
|
|
66073
|
-
|
|
66074
|
-
|
|
66449
|
+
const collected = await collectThingPages({
|
|
66450
|
+
initialCursor: flags.cursor,
|
|
66451
|
+
fetchPage: (cursor) => ctx.client.view.evaluate(org, repo2, wref, {
|
|
66452
|
+
limit: pageLimit,
|
|
66453
|
+
cursor
|
|
66454
|
+
}),
|
|
66455
|
+
requireRepoSeq: false,
|
|
66456
|
+
title: "View evaluate"
|
|
66075
66457
|
});
|
|
66076
|
-
writePageOutput(ctx, items, {
|
|
66458
|
+
writePageOutput(ctx, collected.items, {
|
|
66459
|
+
limit: pageLimit,
|
|
66460
|
+
nextCursor: null,
|
|
66461
|
+
decorations: getResponseDecorations(collected)
|
|
66462
|
+
}, () => {
|
|
66077
66463
|
ctx.out(`${ctx.colors.bold}View ${escapeTerminalTextForDisplay(wref)}${ctx.colors.reset}`);
|
|
66078
|
-
renderQueryResults(ctx.out, ctx.colors,
|
|
66464
|
+
renderQueryResults(ctx.out, ctx.colors, collected);
|
|
66079
66465
|
});
|
|
66080
66466
|
return;
|
|
66081
66467
|
}
|
|
@@ -66086,7 +66472,11 @@ var handleEvaluate = async (ctx, { args, flags }) => {
|
|
|
66086
66472
|
if (result.nextCursor) {
|
|
66087
66473
|
emitPartialPageHint(ctx, result.items.length, result.nextCursor, boundedLimit);
|
|
66088
66474
|
}
|
|
66089
|
-
writePageOutput(ctx, result.items, {
|
|
66475
|
+
writePageOutput(ctx, result.items, {
|
|
66476
|
+
limit: boundedLimit,
|
|
66477
|
+
nextCursor: result.nextCursor ?? null,
|
|
66478
|
+
decorations: getResponseDecorations(result)
|
|
66479
|
+
}, () => {
|
|
66090
66480
|
const selected = `${result.view.wref}@v${result.view.version}`;
|
|
66091
66481
|
ctx.out(`${ctx.colors.bold}View ${escapeTerminalTextForDisplay(selected)}${ctx.colors.reset}`);
|
|
66092
66482
|
renderQueryResults(ctx.out, ctx.colors, result);
|
|
@@ -67620,11 +68010,12 @@ async function runPreparedCli(rawArgv, prepared, opts) {
|
|
|
67620
68010
|
requestedMode: requestedFunctionLogs
|
|
67621
68011
|
});
|
|
67622
68012
|
const localOnlyCommand = isLocalOnlyInvocation(invocation);
|
|
67623
|
-
const { config: config2, client, profile, clientFlags } = localOnlyCommand ? {
|
|
68013
|
+
const { config: config2, client, profile, clientFlags, decorate } = localOnlyCommand ? {
|
|
67624
68014
|
config: loadConfig(),
|
|
67625
68015
|
client: createLocalOnlyClient(),
|
|
67626
68016
|
profile: "default",
|
|
67627
|
-
clientFlags: []
|
|
68017
|
+
clientFlags: [],
|
|
68018
|
+
decorate: true
|
|
67628
68019
|
} : resolveCliContext({
|
|
67629
68020
|
invocation,
|
|
67630
68021
|
format,
|
|
@@ -67645,6 +68036,7 @@ async function runPreparedCli(rawArgv, prepared, opts) {
|
|
|
67645
68036
|
invocation,
|
|
67646
68037
|
profile,
|
|
67647
68038
|
clientFlags,
|
|
68039
|
+
decorate,
|
|
67648
68040
|
colors,
|
|
67649
68041
|
chars,
|
|
67650
68042
|
format,
|
|
@@ -67763,7 +68155,7 @@ function resolveLogLevel(flagLevel, env) {
|
|
|
67763
68155
|
// package.json
|
|
67764
68156
|
var package_default3 = {
|
|
67765
68157
|
name: "@warmhub/cli",
|
|
67766
|
-
version: "0.
|
|
68158
|
+
version: "0.100.0",
|
|
67767
68159
|
private: false,
|
|
67768
68160
|
type: "module",
|
|
67769
68161
|
description: "The wh CLI for WarmHub — create repos, commit and query data, and compound knowledge with your AI agents.",
|
|
@@ -68388,5 +68780,5 @@ process.exitCode = interceptedExitCode === undefined ? await runPreparedCli(laun
|
|
|
68388
68780
|
version: package_default3.version
|
|
68389
68781
|
}) : interceptedExitCode;
|
|
68390
68782
|
|
|
68391
|
-
//# debugId=
|
|
68392
|
-
//# warmhub-cli-build-info {"cliVersion":"0.
|
|
68783
|
+
//# debugId=EFD7221F8FE4C7C064756E2164756E21
|
|
68784
|
+
//# warmhub-cli-build-info {"cliVersion":"0.100.0","sdkVersion":"0.98.0"}
|