@intellectual-frontiers/ergonex 0.3.1 → 0.3.2
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/desired.d.ts +1 -1
- package/dist/mod.js +769 -909
- package/dist/modules/external.d.ts +1 -1
- package/dist/modules/registry.d.ts +1 -1
- package/dist/modules/types.d.ts +2 -2
- package/dist/plan.d.ts +1 -1
- package/dist/render.d.ts +2 -2
- package/dist/state-record.d.ts +2 -2
- package/dist/tools/catalog.d.ts +1 -1
- package/dist/vendor/ts/runtime/http-client.d.ts +1 -1
- package/ergonex.mjs +2249 -2250
- package/package.json +3 -2
- package/dist/vendor/ts/kernel/archive.d.ts +0 -147
- package/dist/vendor/ts/kernel/assess.d.ts +0 -247
- package/dist/vendor/ts/kernel/attest.d.ts +0 -164
- package/dist/vendor/ts/kernel/base64.d.ts +0 -24
- package/dist/vendor/ts/kernel/cbor.d.ts +0 -39
- package/dist/vendor/ts/kernel/cms.d.ts +0 -106
- package/dist/vendor/ts/kernel/cose.d.ts +0 -34
- package/dist/vendor/ts/kernel/crypt.d.ts +0 -30
- package/dist/vendor/ts/kernel/csv.d.ts +0 -38
- package/dist/vendor/ts/kernel/der.d.ts +0 -67
- package/dist/vendor/ts/kernel/documentation.d.ts +0 -118
- package/dist/vendor/ts/kernel/dsse.d.ts +0 -137
- package/dist/vendor/ts/kernel/evidence.d.ts +0 -212
- package/dist/vendor/ts/kernel/glob.d.ts +0 -64
- package/dist/vendor/ts/kernel/grc.d.ts +0 -356
- package/dist/vendor/ts/kernel/http.d.ts +0 -46
- package/dist/vendor/ts/kernel/json5.d.ts +0 -46
- package/dist/vendor/ts/kernel/layers.d.ts +0 -35
- package/dist/vendor/ts/kernel/md5.d.ts +0 -19
- package/dist/vendor/ts/kernel/media-types.d.ts +0 -28
- package/dist/vendor/ts/kernel/mod.d.ts +0 -89
- package/dist/vendor/ts/kernel/ocsf-types.auto.d.ts +0 -4374
- package/dist/vendor/ts/kernel/ocsf.d.ts +0 -160
- package/dist/vendor/ts/kernel/oscal.d.ts +0 -356
- package/dist/vendor/ts/kernel/otel.d.ts +0 -365
- package/dist/vendor/ts/kernel/otlp.d.ts +0 -83
- package/dist/vendor/ts/kernel/png.d.ts +0 -124
- package/dist/vendor/ts/kernel/render.d.ts +0 -111
- package/dist/vendor/ts/kernel/schedule.d.ts +0 -207
- package/dist/vendor/ts/kernel/semver.d.ts +0 -94
- package/dist/vendor/ts/kernel/sha256.d.ts +0 -29
- package/dist/vendor/ts/kernel/signals.d.ts +0 -371
- package/dist/vendor/ts/kernel/sigv4.d.ts +0 -67
- package/dist/vendor/ts/kernel/test-record.d.ts +0 -222
- package/dist/vendor/ts/kernel/test-report.d.ts +0 -294
- package/dist/vendor/ts/kernel/toml.d.ts +0 -51
- package/dist/vendor/ts/kernel/trace.d.ts +0 -169
- package/dist/vendor/ts/kernel/ts-literal.d.ts +0 -62
- package/dist/vendor/ts/kernel/uuid.d.ts +0 -53
- package/dist/vendor/ts/kernel/webauthn.d.ts +0 -212
- package/dist/vendor/ts/kernel/xml.d.ts +0 -73
- package/dist/vendor/ts/kernel/yaml.d.ts +0 -44
package/dist/mod.js
CHANGED
|
@@ -189,20 +189,6 @@ function oneOf(...alternatives) {
|
|
|
189
189
|
return fail(path, `one of ${alternatives.length} alternatives`, input);
|
|
190
190
|
};
|
|
191
191
|
}
|
|
192
|
-
function mapDecoder(base, f) {
|
|
193
|
-
return (input, path = "$") => {
|
|
194
|
-
const r = base(input, path);
|
|
195
|
-
return r.kind === "ok" ? ok(f(r.value)) : r;
|
|
196
|
-
};
|
|
197
|
-
}
|
|
198
|
-
function refine(base, name, valid) {
|
|
199
|
-
return (input, path = "$") => {
|
|
200
|
-
const r = base(input, path);
|
|
201
|
-
if (r.kind === "err")
|
|
202
|
-
return r;
|
|
203
|
-
return valid(r.value) ? ok(r.value) : fail(path, `a ${name}`, input);
|
|
204
|
-
};
|
|
205
|
-
}
|
|
206
192
|
function json(text, decoder) {
|
|
207
193
|
let value;
|
|
208
194
|
try {
|
|
@@ -214,7 +200,19 @@ function json(text, decoder) {
|
|
|
214
200
|
}
|
|
215
201
|
// ../core/src/text.ts
|
|
216
202
|
var ANSI = new RegExp(`${String.fromCharCode(27)}\\[[0-9;?]*[A-Za-z]`, "g");
|
|
217
|
-
// ../
|
|
203
|
+
// ../formats/src/base64.ts
|
|
204
|
+
function fromBase64(text) {
|
|
205
|
+
const t = text.replace(/[\t\n\r ]/g, "");
|
|
206
|
+
if (!/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(t))
|
|
207
|
+
return err("the text is not padded standard base64");
|
|
208
|
+
const s = atob(t);
|
|
209
|
+
const out = new Uint8Array(s.length);
|
|
210
|
+
for (let i = 0;i < s.length; i++)
|
|
211
|
+
out[i] = s.charCodeAt(i);
|
|
212
|
+
return ok(out);
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
// ../formats/src/archive.ts
|
|
218
216
|
var CRC_TABLE = Array.from({ length: 256 }, (_, i) => {
|
|
219
217
|
let c = i;
|
|
220
218
|
for (let k = 0;k < 8; k++)
|
|
@@ -227,126 +225,29 @@ function dosDate(year, month, day) {
|
|
|
227
225
|
var ZIP_EPOCH = dosDate(1980, 1, 1);
|
|
228
226
|
var NO_PENDING = { pax: new Map, longName: undefined, longLink: undefined };
|
|
229
227
|
var MAX_META = 1 << 20;
|
|
230
|
-
// ../ts/kernel/base64.ts
|
|
231
|
-
function fromBase64(text) {
|
|
232
|
-
const t = text.replace(/[\t\n\r ]/g, "");
|
|
233
|
-
if (!/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(t))
|
|
234
|
-
return err("the text is not padded standard base64");
|
|
235
|
-
const s = atob(t);
|
|
236
|
-
const out = new Uint8Array(s.length);
|
|
237
|
-
for (let i = 0;i < s.length; i++)
|
|
238
|
-
out[i] = s.charCodeAt(i);
|
|
239
|
-
return ok(out);
|
|
240
|
-
}
|
|
241
|
-
// ../ts/kernel/grc.ts
|
|
242
|
-
var INSTANT = /^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})(?:[.,](\d{1,9}))?(Z|[+-]\d{2}:\d{2})$/i;
|
|
243
|
-
var CANONICAL_INSTANT = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z$/;
|
|
244
|
-
function instantOf(text) {
|
|
245
|
-
const m = INSTANT.exec(text.trim());
|
|
246
|
-
if (m === null)
|
|
247
|
-
return;
|
|
248
|
-
const [y, mo, d, h, mi, s] = [m[1], m[2], m[3], m[4], m[5], m[6]].map((x) => Number(x ?? ""));
|
|
249
|
-
if (y === undefined || mo === undefined || d === undefined || h === undefined || mi === undefined || s === undefined)
|
|
250
|
-
return;
|
|
251
|
-
const ms = Number((m[7] ?? "").padEnd(3, "0").slice(0, 3));
|
|
252
|
-
if (mo < 1 || mo > 12 || d < 1 || d > daysInMonth(y, mo) || h > 23 || mi > 59 || s > 59)
|
|
253
|
-
return;
|
|
254
|
-
const zone = (m[8] ?? "Z").toUpperCase();
|
|
255
|
-
let offset = 0;
|
|
256
|
-
if (zone !== "Z") {
|
|
257
|
-
const oh = Number(zone.slice(1, 3));
|
|
258
|
-
const om = Number(zone.slice(4, 6));
|
|
259
|
-
if (oh > 23 || om > 59)
|
|
260
|
-
return;
|
|
261
|
-
offset = (zone.startsWith("-") ? -1 : 1) * (oh * 60 + om) * 60000;
|
|
262
|
-
}
|
|
263
|
-
const date = new Date(0);
|
|
264
|
-
date.setUTCFullYear(y, mo - 1, d);
|
|
265
|
-
date.setUTCHours(h, mi, s, ms);
|
|
266
|
-
return instantFromEpochMs(date.getTime() - offset);
|
|
267
|
-
}
|
|
268
|
-
function instantFromEpochMs(ms) {
|
|
269
|
-
if (!Number.isFinite(ms))
|
|
270
|
-
return;
|
|
271
|
-
const date = new Date(Math.trunc(ms));
|
|
272
|
-
if (Number.isNaN(date.getTime()))
|
|
273
|
-
return;
|
|
274
|
-
const text = date.toISOString();
|
|
275
|
-
return CANONICAL_INSTANT.test(text) ? text : undefined;
|
|
276
|
-
}
|
|
277
|
-
function daysInMonth(year, month) {
|
|
278
|
-
const leap = year % 4 === 0 && year % 100 !== 0 || year % 400 === 0;
|
|
279
|
-
return month === 2 ? leap ? 29 : 28 : [4, 6, 9, 11].includes(month) ? 30 : 31;
|
|
280
|
-
}
|
|
281
|
-
var DURATION = /^P(?:(\d+)Y)?(?:(\d+)M)?(?:(\d+)W)?(?:(\d+)D)?(?:T(?:(\d+)H)?(?:(\d+)M)?(?:(\d+(?:[.,]\d+)?)S)?)?$/;
|
|
282
|
-
function parseDuration(text) {
|
|
283
|
-
const m = DURATION.exec(text);
|
|
284
|
-
if (m === null || text === "P" || text.endsWith("T"))
|
|
285
|
-
return err({ kind: "duration", text });
|
|
286
|
-
const n = (i) => Number((m[i] ?? "0").replace(",", "."));
|
|
287
|
-
return ok({ text, years: n(1), months: n(2), weeks: n(3), days: n(4), hours: n(5), minutes: n(6), seconds: n(7) });
|
|
288
|
-
}
|
|
289
|
-
var ROLE = /^[a-z][a-z0-9]*(?:[-_./][a-z0-9]+)*$/;
|
|
290
|
-
function roleOf(text) {
|
|
291
|
-
return ROLE.test(text) ? text : undefined;
|
|
292
|
-
}
|
|
293
|
-
var SEVERITIES = ["info", "low", "medium", "high", "critical"];
|
|
294
|
-
var refined = (name, f) => {
|
|
295
|
-
return (input, path = "$") => {
|
|
296
|
-
if (typeof input === "string") {
|
|
297
|
-
const v = f(input);
|
|
298
|
-
if (v !== undefined)
|
|
299
|
-
return ok(v);
|
|
300
|
-
}
|
|
301
|
-
return err({
|
|
302
|
-
kind: "decode",
|
|
303
|
-
path,
|
|
304
|
-
expected: name,
|
|
305
|
-
found: typeof input === "string" ? `the string ${JSON.stringify(input).slice(0, 60)}` : typeof input
|
|
306
|
-
});
|
|
307
|
-
};
|
|
308
|
-
};
|
|
309
|
-
var instantDecoder = refined("an ISO 8601 date-time with a zone", instantOf);
|
|
310
|
-
var roleDecoder = refined("a role (lower-case words joined by - _ . or /)", roleOf);
|
|
311
|
-
var durationDecoder = refined("an ISO 8601 duration", (t) => {
|
|
312
|
-
const r = parseDuration(t);
|
|
313
|
-
return r.kind === "ok" ? r.value : undefined;
|
|
314
|
-
});
|
|
315
|
-
var severityDecoder = literal(...SEVERITIES);
|
|
316
|
-
var waiverInput = mapDecoder(object({ id: string, control: string, subjects: array(string), reason: string, approvedBy: roleDecoder, grantedAt: instantDecoder }, { expiresAt: instantDecoder }), (w) => w);
|
|
317
228
|
|
|
318
|
-
// ../
|
|
319
|
-
var impactDeclarationDecoder = object({ paths: array(string), controls: array(string) });
|
|
320
|
-
var RISK_LEVELS = ["very-low", "low", "moderate", "high", "very-high"];
|
|
321
|
-
var levelDecoder = literal(...RISK_LEVELS);
|
|
322
|
-
var riskDecoder = object({
|
|
323
|
-
id: string,
|
|
324
|
-
title: string,
|
|
325
|
-
likelihood: levelDecoder,
|
|
326
|
-
impact: levelDecoder,
|
|
327
|
-
treatment: literal("accept", "mitigate", "transfer", "avoid"),
|
|
328
|
-
owner: roleDecoder,
|
|
329
|
-
reviewBy: instantDecoder
|
|
330
|
-
}, { description: string, controls: array(string) });
|
|
331
|
-
// ../ts/kernel/sha256.ts
|
|
332
|
-
var SHA256 = /^[0-9a-f]{64}$/;
|
|
333
|
-
function sha256Of(text) {
|
|
334
|
-
const t = text.trim().toLowerCase();
|
|
335
|
-
return SHA256.test(t) ? t : undefined;
|
|
336
|
-
}
|
|
229
|
+
// ../formats/src/hex.ts
|
|
337
230
|
function toHex(bytes) {
|
|
338
231
|
let out = "";
|
|
339
232
|
for (const b of bytes)
|
|
340
233
|
out += b.toString(16).padStart(2, "0");
|
|
341
234
|
return out;
|
|
342
235
|
}
|
|
236
|
+
// ../formats/src/cbor.ts
|
|
237
|
+
var UTF8 = new TextDecoder("utf-8", { fatal: true });
|
|
238
|
+
// ../crypto/src/sha256.ts
|
|
239
|
+
var SHA256 = /^[0-9a-f]{64}$/;
|
|
240
|
+
function sha256Of(text) {
|
|
241
|
+
const t = text.trim().toLowerCase();
|
|
242
|
+
return SHA256.test(t) ? t : undefined;
|
|
243
|
+
}
|
|
343
244
|
async function sha256(data) {
|
|
344
245
|
const bytes = typeof data === "string" ? new TextEncoder().encode(data) : data;
|
|
345
246
|
const digest = await crypto.subtle.digest("SHA-256", new Uint8Array(bytes));
|
|
346
247
|
return toHex(new Uint8Array(digest));
|
|
347
248
|
}
|
|
348
249
|
|
|
349
|
-
// ../
|
|
250
|
+
// ../crypto/src/dsse.ts
|
|
350
251
|
var utf8 = new TextEncoder;
|
|
351
252
|
var lowerHex = (input, path = "$") => typeof input === "string" && /^(?:[0-9a-f]{2})+$/.test(input) ? ok(input) : err({ kind: "decode", path, expected: "lower-case hexadecimal", found: describe(input) });
|
|
352
253
|
var resourceDescriptorDecoder = object({ name: string, digest: record(lowerHex) }, { uri: string, mediaType: string, annotations: record(unknownValue) });
|
|
@@ -356,27 +257,12 @@ var envelopeDecoder = object({
|
|
|
356
257
|
payloadType: string,
|
|
357
258
|
signatures: array(object({ sig: base64Text }, { keyid: string }))
|
|
358
259
|
});
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
var
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
};
|
|
366
|
-
var ledgerEntryDecoder = object({
|
|
367
|
-
seq: refine(integer, "positive", (n) => n >= 1),
|
|
368
|
-
prev: sha256Decoder,
|
|
369
|
-
at: instantDecoder,
|
|
370
|
-
kind: string,
|
|
371
|
-
subject: object({ kind: string, id: string }),
|
|
372
|
-
evidence: sha256Decoder,
|
|
373
|
-
digest: sha256Decoder
|
|
374
|
-
});
|
|
375
|
-
var manifestDecoder = object({
|
|
376
|
-
files: array(object({ path: string, size: refine(integer, "size", (n) => n >= 0), sha256: sha256Decoder }))
|
|
377
|
-
});
|
|
378
|
-
|
|
379
|
-
// ../ts/kernel/uuid.ts
|
|
260
|
+
// ../crypto/src/md5.ts
|
|
261
|
+
var T = Array.from({ length: 64 }, (_, i) => Math.floor(Math.abs(Math.sin(i + 1)) * 4294967296) >>> 0);
|
|
262
|
+
// ../crypto/src/sigv4.ts
|
|
263
|
+
var UNSIGNED_HEADERS = new Set(["authorization", "connection", "expect", "user-agent", "x-amzn-trace-id", "traceparent", "tracestate"]);
|
|
264
|
+
var encoder = new TextEncoder;
|
|
265
|
+
// ../crypto/src/uuid.ts
|
|
380
266
|
var UUID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;
|
|
381
267
|
function uuidOf(text) {
|
|
382
268
|
const t = text.trim().toLowerCase();
|
|
@@ -395,769 +281,260 @@ var NAMESPACE_URL = constant("6ba7b811-9dad-11d1-80b4-00c04fd430c8");
|
|
|
395
281
|
var NAMESPACE_OID = constant("6ba7b812-9dad-11d1-80b4-00c04fd430c8");
|
|
396
282
|
var NAMESPACE_X500 = constant("6ba7b814-9dad-11d1-80b4-00c04fd430c8");
|
|
397
283
|
var utf82 = new TextEncoder;
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
var
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
// ../ts/kernel/md5.ts
|
|
425
|
-
var T = Array.from({ length: 64 }, (_, i) => Math.floor(Math.abs(Math.sin(i + 1)) * 4294967296) >>> 0);
|
|
426
|
-
// ../ts/kernel/semver.ts
|
|
427
|
-
var PATTERN = /^v?(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)(?:-((?:0|[1-9][0-9]*|[0-9]*[A-Za-z-][0-9A-Za-z-]*)(?:\.(?:0|[1-9][0-9]*|[0-9]*[A-Za-z-][0-9A-Za-z-]*))*))?(?:\+([0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*))?$/;
|
|
428
|
-
function parseSemVer(text) {
|
|
429
|
-
const m = PATTERN.exec(text.trim());
|
|
430
|
-
if (m === null)
|
|
431
|
-
return err(`${JSON.stringify(text)} is not a semantic version (major.minor.patch[-pre][+build])`);
|
|
432
|
-
const [, major = "", minor = "", patch = "", pre, build] = m;
|
|
433
|
-
const parts = [Number(major), Number(minor), Number(patch)];
|
|
434
|
-
if (!parts.every(Number.isSafeInteger))
|
|
435
|
-
return err(`${JSON.stringify(text)} has a number too large`);
|
|
436
|
-
return ok({
|
|
437
|
-
major: parts[0],
|
|
438
|
-
minor: parts[1],
|
|
439
|
-
patch: parts[2],
|
|
440
|
-
...pre === undefined ? {} : { pre },
|
|
441
|
-
...build === undefined ? {} : { build }
|
|
442
|
-
});
|
|
284
|
+
// ../crypto/src/webauthn.ts
|
|
285
|
+
var clientData = object({ type: string, challenge: string, origin: string }, { crossOrigin: boolean, topOrigin: string });
|
|
286
|
+
var kind = literal("public-key");
|
|
287
|
+
var extensionResults = record(unknownValue);
|
|
288
|
+
// src/portable.ts
|
|
289
|
+
function describePortableError(e) {
|
|
290
|
+
switch (e.kind) {
|
|
291
|
+
case "empty":
|
|
292
|
+
return "a path segment is empty";
|
|
293
|
+
case "dot":
|
|
294
|
+
return `the path segment ${JSON.stringify(e.segment)} would leave its folder`;
|
|
295
|
+
case "forbidden-character":
|
|
296
|
+
return `the path segment ${JSON.stringify(e.segment)} holds ${JSON.stringify(e.character)}, which Windows does not allow in a name`;
|
|
297
|
+
case "control-character":
|
|
298
|
+
return `the path segment ${JSON.stringify(e.segment)} holds a control character`;
|
|
299
|
+
case "trailing-dot-or-space":
|
|
300
|
+
return `the path segment ${JSON.stringify(e.segment)} ends in a dot or a space, which Windows drops`;
|
|
301
|
+
case "device-name":
|
|
302
|
+
return `the path segment ${JSON.stringify(e.segment)} is the Windows device name ${e.device}, with or without an extension, in any case`;
|
|
303
|
+
case "too-long":
|
|
304
|
+
return `the path segment is ${e.bytes} bytes in UTF-8, and a name may have 255`;
|
|
305
|
+
case "not-nfc":
|
|
306
|
+
return `the path segment ${JSON.stringify(e.segment)} is not in Unicode normalization form NFC, so it would be another name on macOS`;
|
|
307
|
+
default:
|
|
308
|
+
return absurd(e);
|
|
309
|
+
}
|
|
443
310
|
}
|
|
444
|
-
var
|
|
445
|
-
var
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
major,
|
|
449
|
-
minor,
|
|
450
|
-
patch,
|
|
451
|
-
...pre === undefined ? {} : { pre }
|
|
452
|
-
});
|
|
453
|
-
var at = (op, version) => ({ op, version });
|
|
454
|
-
var NOTHING = [at("<", ver(0, 0, 0, "0"))];
|
|
455
|
-
// ../ts/kernel/oscal.ts
|
|
456
|
-
var OPEN_OUTCOMES = new Set(["fail", "warn", "gap", "error", "accepted"]);
|
|
457
|
-
// ../ts/kernel/otel.ts
|
|
458
|
-
var TRACE_ID = /^[0-9a-f]{32}$/;
|
|
459
|
-
var SPAN_ID = /^[0-9a-f]{16}$/;
|
|
460
|
-
var ZEROS = /^0+$/;
|
|
461
|
-
function parseTraceId(text) {
|
|
462
|
-
if (!TRACE_ID.test(text))
|
|
463
|
-
return err("a trace id is 32 lower-case hexadecimal digits");
|
|
464
|
-
if (ZEROS.test(text))
|
|
465
|
-
return err("a trace id of all zeros is not valid");
|
|
466
|
-
return ok(text);
|
|
311
|
+
var FORBIDDEN = new Set(["<", ">", ":", '"', "/", "\\", "|", "?", "*"]);
|
|
312
|
+
var DEVICE = /^(?:CON|PRN|AUX|NUL|CONIN\$|CONOUT\$|COM[0-9\u00b9\u00b2\u00b3]|LPT[0-9\u00b9\u00b2\u00b3])$/i;
|
|
313
|
+
function isDeviceName(name) {
|
|
314
|
+
return DEVICE.test((name.split(".")[0] ?? "").replace(/ +$/, ""));
|
|
467
315
|
}
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
316
|
+
var MAX_SEGMENT_BYTES = 255;
|
|
317
|
+
function segment(text) {
|
|
318
|
+
if (text === "")
|
|
319
|
+
return err({ kind: "empty" });
|
|
320
|
+
if (text === "." || text === "..")
|
|
321
|
+
return err({ kind: "dot", segment: text });
|
|
322
|
+
for (const ch of text) {
|
|
323
|
+
const code = ch.codePointAt(0) ?? 0;
|
|
324
|
+
if (code < 32 || code === 127)
|
|
325
|
+
return err({ kind: "control-character", segment: text });
|
|
326
|
+
if (FORBIDDEN.has(ch))
|
|
327
|
+
return err({ kind: "forbidden-character", segment: text, character: ch });
|
|
328
|
+
}
|
|
329
|
+
if (text.endsWith(".") || text.endsWith(" "))
|
|
330
|
+
return err({ kind: "trailing-dot-or-space", segment: text });
|
|
331
|
+
const stem = (text.split(".")[0] ?? "").replace(/ +$/, "");
|
|
332
|
+
if (isDeviceName(text))
|
|
333
|
+
return err({
|
|
334
|
+
kind: "device-name",
|
|
335
|
+
segment: text,
|
|
336
|
+
device: stem.toUpperCase()
|
|
337
|
+
});
|
|
338
|
+
const bytes = new TextEncoder().encode(text).length;
|
|
339
|
+
if (bytes > MAX_SEGMENT_BYTES)
|
|
340
|
+
return err({ kind: "too-long", segment: text.slice(0, 40), bytes });
|
|
341
|
+
if (text !== text.normalize("NFC"))
|
|
342
|
+
return err({ kind: "not-nfc", segment: text });
|
|
473
343
|
return ok(text);
|
|
474
344
|
}
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
}
|
|
485
|
-
function isTraceStateValue(value) {
|
|
486
|
-
return TRACESTATE_VALUE.test(value);
|
|
487
|
-
}
|
|
488
|
-
function parseTracestate(header) {
|
|
489
|
-
const out = [];
|
|
490
|
-
const seen = new Set;
|
|
491
|
-
for (const raw of header.split(",")) {
|
|
492
|
-
if (out.length >= TRACESTATE_MAX_MEMBERS)
|
|
493
|
-
break;
|
|
494
|
-
const member = raw.replace(/^[ \t]+|[ \t]+$/g, "");
|
|
495
|
-
if (member === "")
|
|
496
|
-
continue;
|
|
497
|
-
const eq = member.indexOf("=");
|
|
498
|
-
if (eq < 0)
|
|
499
|
-
continue;
|
|
500
|
-
const key = member.slice(0, eq);
|
|
501
|
-
const value = member.slice(eq + 1);
|
|
502
|
-
if (!isTraceStateKey(key) || !isTraceStateValue(value) || seen.has(key))
|
|
503
|
-
continue;
|
|
504
|
-
seen.add(key);
|
|
505
|
-
out.push({ key, value });
|
|
345
|
+
function repoPath(segments) {
|
|
346
|
+
if (segments.length === 0)
|
|
347
|
+
return err({ kind: "empty" });
|
|
348
|
+
const made = [];
|
|
349
|
+
for (const s of segments) {
|
|
350
|
+
const r = segment(s);
|
|
351
|
+
if (r.kind === "err")
|
|
352
|
+
return r;
|
|
353
|
+
made.push(r.value);
|
|
506
354
|
}
|
|
507
|
-
return
|
|
355
|
+
return ok(made.join("/"));
|
|
508
356
|
}
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
return Number.isInteger(n) && n >= 1 && n <= 24;
|
|
357
|
+
function segmentsOf(path) {
|
|
358
|
+
return path.split("/");
|
|
512
359
|
}
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
// ../ts/kernel/otlp.ts
|
|
516
|
-
var SPAN_KINDS = ["internal", "server", "client", "producer", "consumer"];
|
|
517
|
-
class Failure extends Error {
|
|
518
|
-
error;
|
|
519
|
-
constructor(error) {
|
|
520
|
-
super(error.path);
|
|
521
|
-
this.error = error;
|
|
522
|
-
}
|
|
360
|
+
function child(path, name) {
|
|
361
|
+
return `${path}/${name}`;
|
|
523
362
|
}
|
|
524
|
-
function
|
|
525
|
-
|
|
363
|
+
function nativePath(root, path, separator) {
|
|
364
|
+
const base = root.replace(/[\\/]+$/, "");
|
|
365
|
+
return [base, ...segmentsOf(path)].join(separator);
|
|
526
366
|
}
|
|
527
|
-
function
|
|
528
|
-
return (
|
|
529
|
-
if (typeof input !== "object" || input === null || Array.isArray(input))
|
|
530
|
-
return err(failure(path, "an object", input));
|
|
531
|
-
const read = (key, decoder) => {
|
|
532
|
-
const r = decoder(Reflect.get(input, key), `${path}.${key}`);
|
|
533
|
-
if (r.kind === "err")
|
|
534
|
-
throw new Failure(r.error);
|
|
535
|
-
return r.value;
|
|
536
|
-
};
|
|
537
|
-
const f = {
|
|
538
|
-
req: read,
|
|
539
|
-
opt: (key, decoder, fallback) => {
|
|
540
|
-
const v = Reflect.get(input, key);
|
|
541
|
-
return v === undefined || v === null ? fallback : read(key, decoder);
|
|
542
|
-
}
|
|
543
|
-
};
|
|
544
|
-
try {
|
|
545
|
-
return ok(build(f, path));
|
|
546
|
-
} catch (e) {
|
|
547
|
-
if (e instanceof Failure)
|
|
548
|
-
return err(e.error);
|
|
549
|
-
throw e;
|
|
550
|
-
}
|
|
551
|
-
};
|
|
367
|
+
function foldKey(path) {
|
|
368
|
+
return path.normalize("NFC").toUpperCase().toLowerCase().normalize("NFC");
|
|
552
369
|
}
|
|
553
|
-
function
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
const
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
return ok(out);
|
|
565
|
-
};
|
|
370
|
+
function collisions(items) {
|
|
371
|
+
const groups = new Map;
|
|
372
|
+
for (const item of items) {
|
|
373
|
+
const key = foldKey(item.path);
|
|
374
|
+
const group = groups.get(key);
|
|
375
|
+
if (group === undefined)
|
|
376
|
+
groups.set(key, [{ ...item }]);
|
|
377
|
+
else
|
|
378
|
+
group.push({ ...item });
|
|
379
|
+
}
|
|
380
|
+
return [...groups.entries()].filter(([, members]) => members.length > 1).map(([key, members]) => ({ key, members }));
|
|
566
381
|
}
|
|
567
|
-
var
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
const r = int64(input, path);
|
|
578
|
-
if (r.kind === "err")
|
|
579
|
-
return r;
|
|
580
|
-
return r.value >= 0n && r.value <= BigInt(Number.MAX_SAFE_INTEGER) ? ok(Number(r.value)) : err(failure(path, "a count", input));
|
|
581
|
-
};
|
|
582
|
-
var double = (input, path = "$") => {
|
|
583
|
-
if (typeof input === "number")
|
|
584
|
-
return ok(input);
|
|
585
|
-
if (input === "NaN")
|
|
586
|
-
return ok(NaN);
|
|
587
|
-
if (input === "Infinity")
|
|
588
|
-
return ok(Infinity);
|
|
589
|
-
if (input === "-Infinity")
|
|
590
|
-
return ok(-Infinity);
|
|
591
|
-
return err(failure(path, "a double", input));
|
|
592
|
-
};
|
|
593
|
-
var bytes = (input, path = "$") => {
|
|
594
|
-
if (typeof input !== "string")
|
|
595
|
-
return err(failure(path, "base64", input));
|
|
596
|
-
const r = fromBase64(input);
|
|
597
|
-
return r.kind === "ok" ? r : err(failure(path, "base64", input));
|
|
598
|
-
};
|
|
599
|
-
var traceId = (input, path = "$") => {
|
|
600
|
-
const r = typeof input === "string" ? parseTraceId(input.toLowerCase()) : err("");
|
|
601
|
-
return r.kind === "ok" ? r : err(failure(path, "a trace id (32 hexadecimal digits, not all zeros)", input));
|
|
602
|
-
};
|
|
603
|
-
var spanId = (input, path = "$") => {
|
|
604
|
-
const r = typeof input === "string" ? parseSpanId(input.toLowerCase()) : err("");
|
|
605
|
-
return r.kind === "ok" ? r : err(failure(path, "a span id (16 hexadecimal digits, not all zeros)", input));
|
|
606
|
-
};
|
|
607
|
-
function enumeration(names) {
|
|
608
|
-
return (input, path = "$") => {
|
|
609
|
-
if (typeof input === "number" && Number.isInteger(input) && input >= 0 && input < names.length)
|
|
610
|
-
return ok(input);
|
|
611
|
-
if (typeof input === "string") {
|
|
612
|
-
const i = names.indexOf(input);
|
|
613
|
-
if (i >= 0)
|
|
614
|
-
return ok(i);
|
|
615
|
-
}
|
|
616
|
-
return err(failure(path, `one of ${names.join(", ")} or its number`, input));
|
|
617
|
-
};
|
|
382
|
+
var WINDOWS_PATH_LIMIT = 259;
|
|
383
|
+
function checkPathLength(windowsPath, longPathsEnabled) {
|
|
384
|
+
if (longPathsEnabled || windowsPath.length <= WINDOWS_PATH_LIMIT)
|
|
385
|
+
return ok(windowsPath);
|
|
386
|
+
return err({
|
|
387
|
+
kind: "path-too-long",
|
|
388
|
+
path: windowsPath,
|
|
389
|
+
length: windowsPath.length,
|
|
390
|
+
limit: WINDOWS_PATH_LIMIT
|
|
391
|
+
});
|
|
618
392
|
}
|
|
619
|
-
var
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
};
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
const v = Reflect.get(input, key);
|
|
645
|
-
return v !== undefined && v !== null;
|
|
646
|
-
};
|
|
647
|
-
const at = (key) => Reflect.get(input, key);
|
|
648
|
-
if (has("stringValue"))
|
|
649
|
-
return str(at("stringValue"), `${path}.stringValue`);
|
|
650
|
-
if (has("boolValue"))
|
|
651
|
-
return bool(at("boolValue"), `${path}.boolValue`);
|
|
652
|
-
if (has("intValue"))
|
|
653
|
-
return int64(at("intValue"), `${path}.intValue`);
|
|
654
|
-
if (has("doubleValue"))
|
|
655
|
-
return double(at("doubleValue"), `${path}.doubleValue`);
|
|
656
|
-
if (has("bytesValue"))
|
|
657
|
-
return bytes(at("bytesValue"), `${path}.bytesValue`);
|
|
658
|
-
if (has("arrayValue"))
|
|
659
|
-
return message((f) => f.opt("values", list(decodeAnyValue), []))(at("arrayValue"), `${path}.arrayValue`);
|
|
660
|
-
if (has("kvlistValue")) {
|
|
661
|
-
return message((f) => {
|
|
662
|
-
const out = {};
|
|
663
|
-
for (const kv of f.opt("values", list(keyValue(decodeAnyValue)), [])) {
|
|
664
|
-
Object.defineProperty(out, kv.key, { value: kv.value, enumerable: true, writable: true, configurable: true });
|
|
665
|
-
}
|
|
666
|
-
return out;
|
|
667
|
-
})(at("kvlistValue"), `${path}.kvlistValue`);
|
|
393
|
+
var REPO_PATH_ROOM = 150;
|
|
394
|
+
function repoPathLength(root, path, separator) {
|
|
395
|
+
const length = nativePath(root, path, separator).length;
|
|
396
|
+
if (length > WINDOWS_PATH_LIMIT)
|
|
397
|
+
return { kind: "too-long", length };
|
|
398
|
+
if (length > REPO_PATH_ROOM)
|
|
399
|
+
return { kind: "no-room", length };
|
|
400
|
+
return { kind: "fits", length };
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
// src/render.ts
|
|
404
|
+
function describeGenerateError(e) {
|
|
405
|
+
switch (e.kind) {
|
|
406
|
+
case "bad-path":
|
|
407
|
+
return `${JSON.stringify(e.path)} cannot be the path of a generated file: ${e.reason}`;
|
|
408
|
+
case "not-auto":
|
|
409
|
+
return `${e.path} is a generated file whose name does not carry .auto. (only a Git hook in .ergonex/hooks/ may lack it)`;
|
|
410
|
+
case "collision":
|
|
411
|
+
return `${e.path} is the same path as ${e.other} after Unicode normalization and case folding; both are refused`;
|
|
412
|
+
case "inside-repository":
|
|
413
|
+
return `${e.path} is inside the working tree of ${e.repository}; a generated file is never written into a repository`;
|
|
414
|
+
case "bad-data":
|
|
415
|
+
return `${e.what}: ${e.reason}`;
|
|
416
|
+
default:
|
|
417
|
+
return absurd(e);
|
|
668
418
|
}
|
|
669
|
-
return err(failure(path, "an AnyValue holding a value", input));
|
|
670
|
-
};
|
|
671
|
-
function keyValue(value) {
|
|
672
|
-
return message((f) => ({ key: f.req("key", str), value: f.req("value", value) }));
|
|
673
419
|
}
|
|
674
|
-
var
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
420
|
+
var HOOKS_FOLDER = ".ergonex/hooks";
|
|
421
|
+
function headerText(generator) {
|
|
422
|
+
return `Generated by ${generator}. Do not edit by hand: change workspace.ts and run \`ergonex render\`.`;
|
|
423
|
+
}
|
|
424
|
+
function normalizeText(text) {
|
|
425
|
+
const lf = text.replace(/^/, "").replaceAll(`\r
|
|
426
|
+
`, `
|
|
427
|
+
`).replaceAll("\r", `
|
|
428
|
+
`);
|
|
429
|
+
return `${lf.replace(/\n+$/, "")}
|
|
430
|
+
`;
|
|
431
|
+
}
|
|
432
|
+
function isAutoName(name) {
|
|
433
|
+
return name.includes(".auto.") || name.endsWith(".auto");
|
|
434
|
+
}
|
|
435
|
+
function generatedPath(path) {
|
|
436
|
+
const made = repoPath(path.split("/"));
|
|
437
|
+
if (made.kind === "err")
|
|
438
|
+
return err({
|
|
439
|
+
kind: "bad-path",
|
|
440
|
+
path,
|
|
441
|
+
reason: describePortableError(made.error)
|
|
442
|
+
});
|
|
443
|
+
return made;
|
|
444
|
+
}
|
|
445
|
+
var noBom = (text) => text.replace(/^\uFEFF/, "");
|
|
446
|
+
function contentOf(body, generator) {
|
|
447
|
+
const header = headerText(generator);
|
|
448
|
+
switch (body.format) {
|
|
449
|
+
case "json":
|
|
450
|
+
return normalizeText(JSON.stringify({ _generated: header, ...body.value }, null, 2));
|
|
451
|
+
case "markdown":
|
|
452
|
+
return normalizeText(`<!-- ${header} -->
|
|
453
|
+
|
|
454
|
+
${noBom(body.text)}`);
|
|
455
|
+
case "yaml":
|
|
456
|
+
case "gitconfig":
|
|
457
|
+
case "envrc":
|
|
458
|
+
return normalizeText(`# ${header}
|
|
459
|
+
|
|
460
|
+
${noBom(body.text)}`);
|
|
461
|
+
case "sh": {
|
|
462
|
+
const text = noBom(body.text);
|
|
463
|
+
const m = /^(#![^\n]*)\n/.exec(text);
|
|
464
|
+
return m === null ? normalizeText(`# ${header}
|
|
465
|
+
${text}`) : normalizeText(`${m[1]}
|
|
466
|
+
# ${header}
|
|
467
|
+
${text.slice(m[0].length)}`);
|
|
468
|
+
}
|
|
469
|
+
default:
|
|
470
|
+
return absurd(body);
|
|
691
471
|
}
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
const
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
return ok(
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
traceState: parseTracestate(f.opt("traceState", str, "")),
|
|
723
|
-
traceFlags: f.opt("flags", count, 0) & 255,
|
|
724
|
-
attributes: f.opt("attributes", decodeAttributes, {}),
|
|
725
|
-
droppedAttributesCount: f.opt("droppedAttributesCount", count, 0)
|
|
726
|
-
}));
|
|
727
|
-
var status = message((f) => {
|
|
728
|
-
const code = f.opt("code", statusCodeEnum, 0);
|
|
729
|
-
if (code === 1)
|
|
730
|
-
return { kind: "ok" };
|
|
731
|
-
if (code === 2)
|
|
732
|
-
return { kind: "error", message: f.opt("message", str, "") };
|
|
733
|
-
return { kind: "unset" };
|
|
734
|
-
});
|
|
735
|
-
var optionalSpanId = (input, path = "$") => input === "" ? ok(undefined) : spanId(input, path);
|
|
736
|
-
var decodeSpan = message((f) => {
|
|
737
|
-
const parentSpanId = f.opt("parentSpanId", optionalSpanId, undefined);
|
|
738
|
-
const kind = f.opt("kind", spanKindEnum, 1);
|
|
739
|
-
return {
|
|
740
|
-
name: f.opt("name", str, ""),
|
|
741
|
-
context: {
|
|
742
|
-
traceId: f.req("traceId", traceId),
|
|
743
|
-
spanId: f.req("spanId", spanId),
|
|
744
|
-
traceFlags: f.opt("flags", count, 0) & 255,
|
|
745
|
-
traceState: parseTracestate(f.opt("traceState", str, "")),
|
|
746
|
-
isRemote: false
|
|
747
|
-
},
|
|
748
|
-
...parentSpanId === undefined ? {} : { parentSpanId },
|
|
749
|
-
kind: SPAN_KINDS[kind - 1] ?? "internal",
|
|
750
|
-
startTime: f.opt("startTimeUnixNano", int64, 0n),
|
|
751
|
-
endTime: f.opt("endTimeUnixNano", int64, 0n),
|
|
752
|
-
attributes: f.opt("attributes", decodeAttributes, {}),
|
|
753
|
-
events: f.opt("events", list(event), []),
|
|
754
|
-
links: f.opt("links", list(link), []),
|
|
755
|
-
status: f.opt("status", status, { kind: "unset" }),
|
|
756
|
-
droppedAttributesCount: f.opt("droppedAttributesCount", count, 0),
|
|
757
|
-
droppedEventsCount: f.opt("droppedEventsCount", count, 0),
|
|
758
|
-
droppedLinksCount: f.opt("droppedLinksCount", count, 0)
|
|
759
|
-
};
|
|
760
|
-
});
|
|
761
|
-
var optionalTraceId = (input, path = "$") => input === "" ? ok(undefined) : traceId(input, path);
|
|
762
|
-
var decodeLogRecord = message((f) => {
|
|
763
|
-
const body = f.opt("body", decodeAnyValue, undefined);
|
|
764
|
-
const traceFlags = f.opt("flags", count, undefined);
|
|
765
|
-
const tid = f.opt("traceId", optionalTraceId, undefined);
|
|
766
|
-
const sid = f.opt("spanId", optionalSpanId, undefined);
|
|
767
|
-
const eventName = f.opt("eventName", str, undefined);
|
|
768
|
-
return {
|
|
769
|
-
time: f.opt("timeUnixNano", int64, 0n),
|
|
770
|
-
observedTime: f.opt("observedTimeUnixNano", int64, 0n),
|
|
771
|
-
severityNumber: f.req("severityNumber", severityEnum),
|
|
772
|
-
severityText: f.opt("severityText", str, ""),
|
|
773
|
-
...body === undefined ? {} : { body },
|
|
774
|
-
attributes: f.opt("attributes", decodeAttributes, {}),
|
|
775
|
-
droppedAttributesCount: f.opt("droppedAttributesCount", count, 0),
|
|
776
|
-
...eventName === undefined ? {} : { eventName },
|
|
777
|
-
...tid === undefined ? {} : { traceId: tid },
|
|
778
|
-
...sid === undefined ? {} : { spanId: sid },
|
|
779
|
-
...traceFlags === undefined ? {} : { traceFlags: traceFlags & 255 }
|
|
780
|
-
};
|
|
781
|
-
});
|
|
782
|
-
var numberPoint = message((f, path) => {
|
|
783
|
-
const asInt = f.opt("asInt", int64, undefined);
|
|
784
|
-
const asDouble = f.opt("asDouble", double, undefined);
|
|
785
|
-
const value = asInt ?? asDouble;
|
|
786
|
-
if (value === undefined)
|
|
787
|
-
throw new Failure(failure(`${path}.asDouble`, "asInt or asDouble", undefined));
|
|
788
|
-
return {
|
|
789
|
-
attributes: f.opt("attributes", decodeAttributes, {}),
|
|
790
|
-
startTime: f.opt("startTimeUnixNano", int64, 0n),
|
|
791
|
-
time: f.opt("timeUnixNano", int64, 0n),
|
|
792
|
-
value
|
|
793
|
-
};
|
|
794
|
-
});
|
|
795
|
-
var histogramPoint = message((f, path) => {
|
|
796
|
-
const sum = f.opt("sum", double, undefined);
|
|
797
|
-
const min = f.opt("min", double, undefined);
|
|
798
|
-
const max = f.opt("max", double, undefined);
|
|
799
|
-
const bounds = f.opt("explicitBounds", list(double), []);
|
|
800
|
-
const bucketCounts = f.opt("bucketCounts", list(count), []);
|
|
801
|
-
if (bucketCounts.length !== 0 && bucketCounts.length !== bounds.length + 1) {
|
|
802
|
-
throw new Failure(failure(`${path}.bucketCounts`, `${bounds.length + 1} bucket counts`, bucketCounts.length));
|
|
472
|
+
}
|
|
473
|
+
function generated(path, body, options) {
|
|
474
|
+
const made = generatedPath(path);
|
|
475
|
+
if (made.kind === "err")
|
|
476
|
+
return made;
|
|
477
|
+
const name = made.value.split("/").at(-1) ?? "";
|
|
478
|
+
const isHook = made.value.startsWith(`${HOOKS_FOLDER}/`) && made.value.split("/").length === 3;
|
|
479
|
+
if (!isAutoName(name) && !isHook)
|
|
480
|
+
return err({ kind: "not-auto", path });
|
|
481
|
+
return ok({
|
|
482
|
+
path: made.value,
|
|
483
|
+
content: contentOf(body, options.generator),
|
|
484
|
+
mode: options.mode ?? "0644",
|
|
485
|
+
generator: options.generator
|
|
486
|
+
});
|
|
487
|
+
}
|
|
488
|
+
function fileDigest(file) {
|
|
489
|
+
return sha256(file.content);
|
|
490
|
+
}
|
|
491
|
+
function checkFiles(files, repositories) {
|
|
492
|
+
const errors = [];
|
|
493
|
+
for (const c of collisions(files.map((f) => ({ id: f.path, path: f.path })))) {
|
|
494
|
+
for (const m of c.members) {
|
|
495
|
+
const other = c.members.find((o) => o !== m);
|
|
496
|
+
errors.push({
|
|
497
|
+
kind: "collision",
|
|
498
|
+
path: m.path,
|
|
499
|
+
other: other?.path ?? m.path
|
|
500
|
+
});
|
|
501
|
+
}
|
|
803
502
|
}
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
return n === 1 ? "delta" : "cumulative";
|
|
503
|
+
for (const f of files) {
|
|
504
|
+
const key = foldKey(f.path);
|
|
505
|
+
const inside = repositories.find((r) => key.startsWith(`${foldKey(r)}/`));
|
|
506
|
+
if (inside !== undefined)
|
|
507
|
+
errors.push({
|
|
508
|
+
kind: "inside-repository",
|
|
509
|
+
path: f.path,
|
|
510
|
+
repository: inside
|
|
511
|
+
});
|
|
512
|
+
}
|
|
513
|
+
if (errors.length > 0)
|
|
514
|
+
return err(errors);
|
|
515
|
+
return ok([...files].sort((a, b) => foldKey(a.path) < foldKey(b.path) ? -1 : foldKey(a.path) > foldKey(b.path) ? 1 : 0));
|
|
818
516
|
}
|
|
819
|
-
var decodeMetric = message((f, path) => {
|
|
820
|
-
const head = { name: f.opt("name", str, ""), description: f.opt("description", str, ""), unit: f.opt("unit", str, "") };
|
|
821
|
-
const sum = f.opt("sum", message((g) => ({
|
|
822
|
-
kind: "sum",
|
|
823
|
-
points: g.opt("dataPoints", list(numberPoint), []),
|
|
824
|
-
temporality: temporalityOf(g.opt("aggregationTemporality", temporalityEnum, 2)),
|
|
825
|
-
monotonic: g.opt("isMonotonic", bool, false)
|
|
826
|
-
})), undefined);
|
|
827
|
-
if (sum !== undefined)
|
|
828
|
-
return { ...head, data: sum };
|
|
829
|
-
const gauge = f.opt("gauge", message((g) => ({ kind: "gauge", points: g.opt("dataPoints", list(numberPoint), []) })), undefined);
|
|
830
|
-
if (gauge !== undefined)
|
|
831
|
-
return { ...head, data: gauge };
|
|
832
|
-
const histogram = f.opt("histogram", message((g) => ({
|
|
833
|
-
kind: "histogram",
|
|
834
|
-
points: g.opt("dataPoints", list(histogramPoint), []),
|
|
835
|
-
temporality: temporalityOf(g.opt("aggregationTemporality", temporalityEnum, 2))
|
|
836
|
-
})), undefined);
|
|
837
|
-
if (histogram !== undefined)
|
|
838
|
-
return { ...head, data: histogram };
|
|
839
|
-
throw new Failure(failure(`${path}.sum`, "a sum, a gauge or a histogram", undefined));
|
|
840
|
-
});
|
|
841
|
-
// ../ts/kernel/png.ts
|
|
842
|
-
var MAX_PIXELS = 2 ** 24;
|
|
843
|
-
var COLOUR_TYPES = new Map([
|
|
844
|
-
[0, { samples: 1, depths: [1, 2, 4, 8, 16], name: "greyscale" }],
|
|
845
|
-
[2, { samples: 3, depths: [8, 16], name: "RGB" }],
|
|
846
|
-
[3, { samples: 1, depths: [1, 2, 4, 8], name: "palette" }],
|
|
847
|
-
[4, { samples: 2, depths: [8, 16], name: "greyscale with alpha" }],
|
|
848
|
-
[6, { samples: 4, depths: [8, 16], name: "RGBA" }]
|
|
849
|
-
]);
|
|
850
|
-
var PRECISION_BITS = 32 - 8 - 2;
|
|
851
|
-
var ONE = 2 ** PRECISION_BITS;
|
|
852
|
-
// ../terminal/src/palette.ts
|
|
853
|
-
var ESC = String.fromCharCode(27);
|
|
854
517
|
|
|
855
|
-
//
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
]);
|
|
867
|
-
function defineSignals(kinds) {
|
|
868
|
-
for (const [name, d] of Object.entries(kinds)) {
|
|
869
|
-
const declared = new Set(Object.keys(d.attributes).map((k) => k.replace(/\?$/, "")));
|
|
870
|
-
for (const [k, t] of Object.entries(d.attributes)) {
|
|
871
|
-
if (!ATTRIBUTE_TYPES.has(t))
|
|
872
|
-
throw new Error(`${name}: the attribute ${k} has the type ${t}, which does not exist`);
|
|
873
|
-
}
|
|
874
|
-
for (const s of d.secret ?? [])
|
|
875
|
-
if (!declared.has(s))
|
|
876
|
-
throw new Error(`${name}: the secret attribute ${s} is not declared`);
|
|
877
|
-
if (d.signal === "histogram" && d.bounds !== undefined) {
|
|
878
|
-
const b = d.bounds;
|
|
879
|
-
if (b.some((x, i) => !Number.isFinite(x) || i > 0 && x <= (b[i - 1] ?? -Infinity))) {
|
|
880
|
-
throw new Error(`${name}: the histogram bounds do not increase`);
|
|
881
|
-
}
|
|
518
|
+
// src/desired.ts
|
|
519
|
+
function settingsOf(manifest, facts) {
|
|
520
|
+
const settings = {
|
|
521
|
+
"core.hooksPath": `${facts.homePosix.replace(/\/+$/, "")}/.ergonex/hooks`
|
|
522
|
+
};
|
|
523
|
+
if (manifest.policy.requiresSignedCommits) {
|
|
524
|
+
settings["commit.gpgsign"] = "true";
|
|
525
|
+
if (manifest.signing !== undefined) {
|
|
526
|
+
settings["gpg.format"] = manifest.signing.format;
|
|
527
|
+
if (manifest.signing.key !== undefined)
|
|
528
|
+
settings["user.signingkey"] = manifest.signing.key;
|
|
882
529
|
}
|
|
883
530
|
}
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
var segmenter = new Intl.Segmenter(undefined, { granularity: "grapheme" });
|
|
892
|
-
var SGR = new RegExp(`^${ESC2}\\[([0-9;:]*)m$`);
|
|
893
|
-
var RESET = `${ESC2}[0m`;
|
|
894
|
-
|
|
895
|
-
// ../ts/kernel/render.ts
|
|
896
|
-
var ESC3 = String.fromCharCode(27);
|
|
897
|
-
var CONTROL = new RegExp(`[${String.fromCharCode(0)}-${String.fromCharCode(31)}${String.fromCharCode(127)}-${String.fromCharCode(159)}]`, "g");
|
|
898
|
-
// ../ts/kernel/xml.ts
|
|
899
|
-
var FORBIDDEN = new RegExp(`[${String.fromCharCode(0)}-${String.fromCharCode(8)}${String.fromCharCode(11, 12)}${String.fromCharCode(14)}-${String.fromCharCode(31)}\\ufffe\\uffff]`, "g");
|
|
900
|
-
// ../ts/kernel/sigv4.ts
|
|
901
|
-
var UNSIGNED_HEADERS = new Set(["authorization", "connection", "expect", "user-agent", "x-amzn-trace-id", "traceparent", "tracestate"]);
|
|
902
|
-
var encoder = new TextEncoder;
|
|
903
|
-
// ../ts/kernel/test-report.ts
|
|
904
|
-
var STYLE = "body{font:15px/1.5 system-ui,sans-serif;margin:2rem auto;max-width:72rem;padding:0 1rem;color:#1b1b1b;background:#fff}" + "table{border-collapse:collapse;margin:.5rem 0;width:100%}th,td{border:1px solid #c8c8c8;padding:.25rem .5rem;text-align:left;vertical-align:top;overflow-wrap:anywhere}" + "th{background:#f0f0f0}h1{font-size:1.6rem}h2{font-size:1.2rem;margin-top:2rem}" + "@media (prefers-color-scheme:dark){body{color:#e8e8e8;background:#161616}th{background:#2a2a2a}th,td{border-color:#444}}";
|
|
905
|
-
// ../ts/kernel/toml.ts
|
|
906
|
-
var CONTROL2 = new RegExp(`[${String.fromCharCode(0)}-${String.fromCharCode(8, 10)}-${String.fromCharCode(31, 127)}]`);
|
|
907
|
-
// ../ts/kernel/webauthn.ts
|
|
908
|
-
var clientData = object({ type: string, challenge: string, origin: string }, { crossOrigin: boolean, topOrigin: string });
|
|
909
|
-
var kind = literal("public-key");
|
|
910
|
-
var extensionResults = record(unknownValue);
|
|
911
|
-
// src/portable.ts
|
|
912
|
-
function describePortableError(e) {
|
|
913
|
-
switch (e.kind) {
|
|
914
|
-
case "empty":
|
|
915
|
-
return "a path segment is empty";
|
|
916
|
-
case "dot":
|
|
917
|
-
return `the path segment ${JSON.stringify(e.segment)} would leave its folder`;
|
|
918
|
-
case "forbidden-character":
|
|
919
|
-
return `the path segment ${JSON.stringify(e.segment)} holds ${JSON.stringify(e.character)}, which Windows does not allow in a name`;
|
|
920
|
-
case "control-character":
|
|
921
|
-
return `the path segment ${JSON.stringify(e.segment)} holds a control character`;
|
|
922
|
-
case "trailing-dot-or-space":
|
|
923
|
-
return `the path segment ${JSON.stringify(e.segment)} ends in a dot or a space, which Windows drops`;
|
|
924
|
-
case "device-name":
|
|
925
|
-
return `the path segment ${JSON.stringify(e.segment)} is the Windows device name ${e.device}, with or without an extension, in any case`;
|
|
926
|
-
case "too-long":
|
|
927
|
-
return `the path segment is ${e.bytes} bytes in UTF-8, and a name may have 255`;
|
|
928
|
-
case "not-nfc":
|
|
929
|
-
return `the path segment ${JSON.stringify(e.segment)} is not in Unicode normalization form NFC, so it would be another name on macOS`;
|
|
930
|
-
default:
|
|
931
|
-
return absurd(e);
|
|
932
|
-
}
|
|
933
|
-
}
|
|
934
|
-
var FORBIDDEN2 = new Set(["<", ">", ":", '"', "/", "\\", "|", "?", "*"]);
|
|
935
|
-
var DEVICE = /^(?:CON|PRN|AUX|NUL|CONIN\$|CONOUT\$|COM[0-9\u00b9\u00b2\u00b3]|LPT[0-9\u00b9\u00b2\u00b3])$/i;
|
|
936
|
-
function isDeviceName(name) {
|
|
937
|
-
return DEVICE.test((name.split(".")[0] ?? "").replace(/ +$/, ""));
|
|
938
|
-
}
|
|
939
|
-
var MAX_SEGMENT_BYTES = 255;
|
|
940
|
-
function segment(text) {
|
|
941
|
-
if (text === "")
|
|
942
|
-
return err({ kind: "empty" });
|
|
943
|
-
if (text === "." || text === "..")
|
|
944
|
-
return err({ kind: "dot", segment: text });
|
|
945
|
-
for (const ch of text) {
|
|
946
|
-
const code = ch.codePointAt(0) ?? 0;
|
|
947
|
-
if (code < 32 || code === 127)
|
|
948
|
-
return err({ kind: "control-character", segment: text });
|
|
949
|
-
if (FORBIDDEN2.has(ch))
|
|
950
|
-
return err({ kind: "forbidden-character", segment: text, character: ch });
|
|
951
|
-
}
|
|
952
|
-
if (text.endsWith(".") || text.endsWith(" "))
|
|
953
|
-
return err({ kind: "trailing-dot-or-space", segment: text });
|
|
954
|
-
const stem = (text.split(".")[0] ?? "").replace(/ +$/, "");
|
|
955
|
-
if (isDeviceName(text))
|
|
956
|
-
return err({
|
|
957
|
-
kind: "device-name",
|
|
958
|
-
segment: text,
|
|
959
|
-
device: stem.toUpperCase()
|
|
960
|
-
});
|
|
961
|
-
const bytes = new TextEncoder().encode(text).length;
|
|
962
|
-
if (bytes > MAX_SEGMENT_BYTES)
|
|
963
|
-
return err({ kind: "too-long", segment: text.slice(0, 40), bytes });
|
|
964
|
-
if (text !== text.normalize("NFC"))
|
|
965
|
-
return err({ kind: "not-nfc", segment: text });
|
|
966
|
-
return ok(text);
|
|
967
|
-
}
|
|
968
|
-
function repoPath(segments) {
|
|
969
|
-
if (segments.length === 0)
|
|
970
|
-
return err({ kind: "empty" });
|
|
971
|
-
const made = [];
|
|
972
|
-
for (const s of segments) {
|
|
973
|
-
const r = segment(s);
|
|
974
|
-
if (r.kind === "err")
|
|
975
|
-
return r;
|
|
976
|
-
made.push(r.value);
|
|
977
|
-
}
|
|
978
|
-
return ok(made.join("/"));
|
|
979
|
-
}
|
|
980
|
-
function segmentsOf(path) {
|
|
981
|
-
return path.split("/");
|
|
982
|
-
}
|
|
983
|
-
function child2(path, name) {
|
|
984
|
-
return `${path}/${name}`;
|
|
985
|
-
}
|
|
986
|
-
function nativePath(root, path, separator) {
|
|
987
|
-
const base = root.replace(/[\\/]+$/, "");
|
|
988
|
-
return [base, ...segmentsOf(path)].join(separator);
|
|
989
|
-
}
|
|
990
|
-
function foldKey(path) {
|
|
991
|
-
return path.normalize("NFC").toUpperCase().toLowerCase().normalize("NFC");
|
|
992
|
-
}
|
|
993
|
-
function collisions(items) {
|
|
994
|
-
const groups = new Map;
|
|
995
|
-
for (const item of items) {
|
|
996
|
-
const key = foldKey(item.path);
|
|
997
|
-
const group = groups.get(key);
|
|
998
|
-
if (group === undefined)
|
|
999
|
-
groups.set(key, [{ ...item }]);
|
|
1000
|
-
else
|
|
1001
|
-
group.push({ ...item });
|
|
1002
|
-
}
|
|
1003
|
-
return [...groups.entries()].filter(([, members]) => members.length > 1).map(([key, members]) => ({ key, members }));
|
|
1004
|
-
}
|
|
1005
|
-
var WINDOWS_PATH_LIMIT = 259;
|
|
1006
|
-
function checkPathLength(windowsPath, longPathsEnabled) {
|
|
1007
|
-
if (longPathsEnabled || windowsPath.length <= WINDOWS_PATH_LIMIT)
|
|
1008
|
-
return ok(windowsPath);
|
|
1009
|
-
return err({
|
|
1010
|
-
kind: "path-too-long",
|
|
1011
|
-
path: windowsPath,
|
|
1012
|
-
length: windowsPath.length,
|
|
1013
|
-
limit: WINDOWS_PATH_LIMIT
|
|
1014
|
-
});
|
|
1015
|
-
}
|
|
1016
|
-
var REPO_PATH_ROOM = 150;
|
|
1017
|
-
function repoPathLength(root, path, separator) {
|
|
1018
|
-
const length = nativePath(root, path, separator).length;
|
|
1019
|
-
if (length > WINDOWS_PATH_LIMIT)
|
|
1020
|
-
return { kind: "too-long", length };
|
|
1021
|
-
if (length > REPO_PATH_ROOM)
|
|
1022
|
-
return { kind: "no-room", length };
|
|
1023
|
-
return { kind: "fits", length };
|
|
1024
|
-
}
|
|
1025
|
-
|
|
1026
|
-
// src/render.ts
|
|
1027
|
-
function describeGenerateError(e) {
|
|
1028
|
-
switch (e.kind) {
|
|
1029
|
-
case "bad-path":
|
|
1030
|
-
return `${JSON.stringify(e.path)} cannot be the path of a generated file: ${e.reason}`;
|
|
1031
|
-
case "not-auto":
|
|
1032
|
-
return `${e.path} is a generated file whose name does not carry .auto. (only a Git hook in .ergonex/hooks/ may lack it)`;
|
|
1033
|
-
case "collision":
|
|
1034
|
-
return `${e.path} is the same path as ${e.other} after Unicode normalization and case folding; both are refused`;
|
|
1035
|
-
case "inside-repository":
|
|
1036
|
-
return `${e.path} is inside the working tree of ${e.repository}; a generated file is never written into a repository`;
|
|
1037
|
-
case "bad-data":
|
|
1038
|
-
return `${e.what}: ${e.reason}`;
|
|
1039
|
-
default:
|
|
1040
|
-
return absurd(e);
|
|
1041
|
-
}
|
|
1042
|
-
}
|
|
1043
|
-
var HOOKS_FOLDER = ".ergonex/hooks";
|
|
1044
|
-
function headerText(generator) {
|
|
1045
|
-
return `Generated by ${generator}. Do not edit by hand: change workspace.ts and run \`ergonex render\`.`;
|
|
1046
|
-
}
|
|
1047
|
-
function normalizeText(text) {
|
|
1048
|
-
const lf = text.replace(/^/, "").replaceAll(`\r
|
|
1049
|
-
`, `
|
|
1050
|
-
`).replaceAll("\r", `
|
|
1051
|
-
`);
|
|
1052
|
-
return `${lf.replace(/\n+$/, "")}
|
|
1053
|
-
`;
|
|
1054
|
-
}
|
|
1055
|
-
function isAutoName(name) {
|
|
1056
|
-
return name.includes(".auto.") || name.endsWith(".auto");
|
|
1057
|
-
}
|
|
1058
|
-
function generatedPath(path) {
|
|
1059
|
-
const made = repoPath(path.split("/"));
|
|
1060
|
-
if (made.kind === "err")
|
|
1061
|
-
return err({
|
|
1062
|
-
kind: "bad-path",
|
|
1063
|
-
path,
|
|
1064
|
-
reason: describePortableError(made.error)
|
|
1065
|
-
});
|
|
1066
|
-
return made;
|
|
1067
|
-
}
|
|
1068
|
-
var noBom = (text) => text.replace(/^\uFEFF/, "");
|
|
1069
|
-
function contentOf(body, generator) {
|
|
1070
|
-
const header = headerText(generator);
|
|
1071
|
-
switch (body.format) {
|
|
1072
|
-
case "json":
|
|
1073
|
-
return normalizeText(JSON.stringify({ _generated: header, ...body.value }, null, 2));
|
|
1074
|
-
case "markdown":
|
|
1075
|
-
return normalizeText(`<!-- ${header} -->
|
|
1076
|
-
|
|
1077
|
-
${noBom(body.text)}`);
|
|
1078
|
-
case "yaml":
|
|
1079
|
-
case "gitconfig":
|
|
1080
|
-
case "envrc":
|
|
1081
|
-
return normalizeText(`# ${header}
|
|
1082
|
-
|
|
1083
|
-
${noBom(body.text)}`);
|
|
1084
|
-
case "sh": {
|
|
1085
|
-
const text = noBom(body.text);
|
|
1086
|
-
const m = /^(#![^\n]*)\n/.exec(text);
|
|
1087
|
-
return m === null ? normalizeText(`# ${header}
|
|
1088
|
-
${text}`) : normalizeText(`${m[1]}
|
|
1089
|
-
# ${header}
|
|
1090
|
-
${text.slice(m[0].length)}`);
|
|
1091
|
-
}
|
|
1092
|
-
default:
|
|
1093
|
-
return absurd(body);
|
|
1094
|
-
}
|
|
1095
|
-
}
|
|
1096
|
-
function generated(path, body, options) {
|
|
1097
|
-
const made = generatedPath(path);
|
|
1098
|
-
if (made.kind === "err")
|
|
1099
|
-
return made;
|
|
1100
|
-
const name = made.value.split("/").at(-1) ?? "";
|
|
1101
|
-
const isHook = made.value.startsWith(`${HOOKS_FOLDER}/`) && made.value.split("/").length === 3;
|
|
1102
|
-
if (!isAutoName(name) && !isHook)
|
|
1103
|
-
return err({ kind: "not-auto", path });
|
|
1104
|
-
return ok({
|
|
1105
|
-
path: made.value,
|
|
1106
|
-
content: contentOf(body, options.generator),
|
|
1107
|
-
mode: options.mode ?? "0644",
|
|
1108
|
-
generator: options.generator
|
|
1109
|
-
});
|
|
1110
|
-
}
|
|
1111
|
-
function fileDigest(file) {
|
|
1112
|
-
return sha256(file.content);
|
|
1113
|
-
}
|
|
1114
|
-
function checkFiles(files, repositories) {
|
|
1115
|
-
const errors = [];
|
|
1116
|
-
for (const c of collisions(files.map((f) => ({ id: f.path, path: f.path })))) {
|
|
1117
|
-
for (const m of c.members) {
|
|
1118
|
-
const other = c.members.find((o) => o !== m);
|
|
1119
|
-
errors.push({
|
|
1120
|
-
kind: "collision",
|
|
1121
|
-
path: m.path,
|
|
1122
|
-
other: other?.path ?? m.path
|
|
1123
|
-
});
|
|
1124
|
-
}
|
|
1125
|
-
}
|
|
1126
|
-
for (const f of files) {
|
|
1127
|
-
const key = foldKey(f.path);
|
|
1128
|
-
const inside = repositories.find((r) => key.startsWith(`${foldKey(r)}/`));
|
|
1129
|
-
if (inside !== undefined)
|
|
1130
|
-
errors.push({
|
|
1131
|
-
kind: "inside-repository",
|
|
1132
|
-
path: f.path,
|
|
1133
|
-
repository: inside
|
|
1134
|
-
});
|
|
1135
|
-
}
|
|
1136
|
-
if (errors.length > 0)
|
|
1137
|
-
return err(errors);
|
|
1138
|
-
return ok([...files].sort((a, b) => foldKey(a.path) < foldKey(b.path) ? -1 : foldKey(a.path) > foldKey(b.path) ? 1 : 0));
|
|
1139
|
-
}
|
|
1140
|
-
|
|
1141
|
-
// src/desired.ts
|
|
1142
|
-
function settingsOf(manifest, facts) {
|
|
1143
|
-
const settings = {
|
|
1144
|
-
"core.hooksPath": `${facts.homePosix.replace(/\/+$/, "")}/.ergonex/hooks`
|
|
1145
|
-
};
|
|
1146
|
-
if (manifest.policy.requiresSignedCommits) {
|
|
1147
|
-
settings["commit.gpgsign"] = "true";
|
|
1148
|
-
if (manifest.signing !== undefined) {
|
|
1149
|
-
settings["gpg.format"] = manifest.signing.format;
|
|
1150
|
-
if (manifest.signing.key !== undefined)
|
|
1151
|
-
settings["user.signingkey"] = manifest.signing.key;
|
|
1152
|
-
}
|
|
1153
|
-
}
|
|
1154
|
-
if (manifest.identity !== undefined) {
|
|
1155
|
-
settings["user.name"] = manifest.identity.name;
|
|
1156
|
-
settings["user.email"] = manifest.identity.email;
|
|
1157
|
-
}
|
|
1158
|
-
if (facts.windows)
|
|
1159
|
-
settings["core.longpaths"] = "true";
|
|
1160
|
-
return settings;
|
|
531
|
+
if (manifest.identity !== undefined) {
|
|
532
|
+
settings["user.name"] = manifest.identity.name;
|
|
533
|
+
settings["user.email"] = manifest.identity.email;
|
|
534
|
+
}
|
|
535
|
+
if (facts.windows)
|
|
536
|
+
settings["core.longpaths"] = "true";
|
|
537
|
+
return settings;
|
|
1161
538
|
}
|
|
1162
539
|
async function desiredOf(manifest, files, facts) {
|
|
1163
540
|
const settings = settingsOf(manifest, facts);
|
|
@@ -1180,22 +557,87 @@ async function digestsOf(files) {
|
|
|
1180
557
|
out.set(f.path, await fileDigest(f));
|
|
1181
558
|
return out;
|
|
1182
559
|
}
|
|
1183
|
-
// src/
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
560
|
+
// ../formats/src/glob.ts
|
|
561
|
+
var ESCAPE_OUTSIDE = new Set(["!", "$", "(", ")", "*", "+", ".", "=", "?", "[", "\\", "^", "{", "|"]);
|
|
562
|
+
var ESCAPE_INSIDE = new Set(["-", "\\", "]"]);
|
|
563
|
+
var CLASSES = new Map([
|
|
564
|
+
["alnum", "\\dA-Za-z"],
|
|
565
|
+
["alpha", "A-Za-z"],
|
|
566
|
+
["ascii", "\\x00-\\x7F"],
|
|
567
|
+
["blank", "\\t "],
|
|
568
|
+
["cntrl", "\\x00-\\x1F\\x7F"],
|
|
569
|
+
["digit", "\\d"],
|
|
570
|
+
["graph", "\\x21-\\x7E"],
|
|
571
|
+
["lower", "a-z"],
|
|
572
|
+
["print", "\\x20-\\x7E"],
|
|
573
|
+
["punct", "!-\\/:-@\\[-`{-~"],
|
|
574
|
+
["space", "\\s\\v"],
|
|
575
|
+
["upper", "A-Z"],
|
|
576
|
+
["word", "\\w"],
|
|
577
|
+
["xdigit", "\\dA-Fa-f"]
|
|
578
|
+
]);
|
|
579
|
+
// ../formats/src/http.ts
|
|
580
|
+
var SAFE_METHODS = new Set(["GET", "HEAD", "OPTIONS", "TRACE"]);
|
|
581
|
+
// ../formats/src/semver.ts
|
|
582
|
+
var PATTERN = /^v?(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)(?:-((?:0|[1-9][0-9]*|[0-9]*[A-Za-z-][0-9A-Za-z-]*)(?:\.(?:0|[1-9][0-9]*|[0-9]*[A-Za-z-][0-9A-Za-z-]*))*))?(?:\+([0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*))?$/;
|
|
583
|
+
function parseSemVer(text) {
|
|
584
|
+
const m = PATTERN.exec(text.trim());
|
|
585
|
+
if (m === null)
|
|
586
|
+
return err(`${JSON.stringify(text)} is not a semantic version (major.minor.patch[-pre][+build])`);
|
|
587
|
+
const [, major = "", minor = "", patch = "", pre, build] = m;
|
|
588
|
+
const parts = [Number(major), Number(minor), Number(patch)];
|
|
589
|
+
if (!parts.every(Number.isSafeInteger))
|
|
590
|
+
return err(`${JSON.stringify(text)} has a number too large`);
|
|
591
|
+
return ok({
|
|
592
|
+
major: parts[0],
|
|
593
|
+
minor: parts[1],
|
|
594
|
+
patch: parts[2],
|
|
595
|
+
...pre === undefined ? {} : { pre },
|
|
596
|
+
...build === undefined ? {} : { build }
|
|
597
|
+
});
|
|
598
|
+
}
|
|
599
|
+
var IDENT = "(?:0|[1-9][0-9]*|[0-9]*[A-Za-z-][0-9A-Za-z-]*)";
|
|
600
|
+
var PART = "(0|[1-9][0-9]*|[xX*])";
|
|
601
|
+
var PARTIAL = new RegExp(`^v?${PART}(?:\\.${PART}(?:\\.${PART}(?:-(${IDENT}(?:\\.${IDENT})*))?(?:\\+[0-9A-Za-z-]+(?:\\.[0-9A-Za-z-]+)*)?)?)?$`);
|
|
602
|
+
var ver = (major, minor, patch, pre) => ({
|
|
603
|
+
major,
|
|
604
|
+
minor,
|
|
605
|
+
patch,
|
|
606
|
+
...pre === undefined ? {} : { pre }
|
|
607
|
+
});
|
|
608
|
+
var at = (op, version) => ({ op, version });
|
|
609
|
+
var NOTHING = [at("<", ver(0, 0, 0, "0"))];
|
|
610
|
+
// ../formats/src/png.ts
|
|
611
|
+
var MAX_PIXELS = 2 ** 24;
|
|
612
|
+
var COLOUR_TYPES = new Map([
|
|
613
|
+
[0, { samples: 1, depths: [1, 2, 4, 8, 16], name: "greyscale" }],
|
|
614
|
+
[2, { samples: 3, depths: [8, 16], name: "RGB" }],
|
|
615
|
+
[3, { samples: 1, depths: [1, 2, 4, 8], name: "palette" }],
|
|
616
|
+
[4, { samples: 2, depths: [8, 16], name: "greyscale with alpha" }],
|
|
617
|
+
[6, { samples: 4, depths: [8, 16], name: "RGBA" }]
|
|
618
|
+
]);
|
|
619
|
+
var PRECISION_BITS = 32 - 8 - 2;
|
|
620
|
+
var ONE = 2 ** PRECISION_BITS;
|
|
621
|
+
// ../formats/src/toml.ts
|
|
622
|
+
var CONTROL = new RegExp(`[${String.fromCharCode(0)}-${String.fromCharCode(8, 10)}-${String.fromCharCode(31, 127)}]`);
|
|
623
|
+
// ../formats/src/xml.ts
|
|
624
|
+
var FORBIDDEN2 = new RegExp(`[${String.fromCharCode(0)}-${String.fromCharCode(8)}${String.fromCharCode(11, 12)}${String.fromCharCode(14)}-${String.fromCharCode(31)}\\ufffe\\uffff]`, "g");
|
|
625
|
+
// src/doctor.ts
|
|
626
|
+
function severityOf(level) {
|
|
627
|
+
switch (level) {
|
|
628
|
+
case "ok":
|
|
629
|
+
return;
|
|
630
|
+
case "suggest":
|
|
631
|
+
return "Informational";
|
|
632
|
+
case "warn":
|
|
633
|
+
return "Warning";
|
|
634
|
+
case "error":
|
|
635
|
+
return "Error";
|
|
636
|
+
default:
|
|
637
|
+
return absurd(level);
|
|
638
|
+
}
|
|
639
|
+
}
|
|
640
|
+
function findingsOf(checks, today) {
|
|
1199
641
|
return checks.flatMap((c) => {
|
|
1200
642
|
const severity = severityOf(c.level);
|
|
1201
643
|
return severity === undefined ? [] : [
|
|
@@ -1388,7 +830,7 @@ function hookChecks(facts, wantedHooksPath) {
|
|
|
1388
830
|
});
|
|
1389
831
|
}
|
|
1390
832
|
// src/findings.ts
|
|
1391
|
-
var
|
|
833
|
+
var SEVERITIES = ["Informational", "Warning", "Error"];
|
|
1392
834
|
function sarifLevel(severity) {
|
|
1393
835
|
switch (severity) {
|
|
1394
836
|
case "Informational":
|
|
@@ -1404,7 +846,7 @@ function sarifLevel(severity) {
|
|
|
1404
846
|
function worst(findings) {
|
|
1405
847
|
let top;
|
|
1406
848
|
for (const f of findings)
|
|
1407
|
-
if (top === undefined ||
|
|
849
|
+
if (top === undefined || SEVERITIES.indexOf(f.severity) > SEVERITIES.indexOf(top))
|
|
1408
850
|
top = f.severity;
|
|
1409
851
|
return top;
|
|
1410
852
|
}
|
|
@@ -1469,7 +911,7 @@ function toSarif(findings, tool = "ergonex") {
|
|
|
1469
911
|
}
|
|
1470
912
|
|
|
1471
913
|
// src/state-record.ts
|
|
1472
|
-
var ERGONEX_VERSION = "0.3.
|
|
914
|
+
var ERGONEX_VERSION = "0.3.2";
|
|
1473
915
|
var STATE_RECORD_PATH = ".ergonex/state.auto.json";
|
|
1474
916
|
var EMPTY_RECORD = {
|
|
1475
917
|
ergonex: ERGONEX_VERSION,
|
|
@@ -1877,14 +1319,14 @@ var commandDecoder = object({
|
|
|
1877
1319
|
name: string,
|
|
1878
1320
|
summary: string
|
|
1879
1321
|
});
|
|
1880
|
-
var
|
|
1322
|
+
var manifestDecoder = object({
|
|
1881
1323
|
contract: integer,
|
|
1882
1324
|
name: string,
|
|
1883
1325
|
summary: string,
|
|
1884
1326
|
commands: array(commandDecoder)
|
|
1885
1327
|
});
|
|
1886
1328
|
function decodeExternalManifest(text) {
|
|
1887
|
-
const r = json(text,
|
|
1329
|
+
const r = json(text, manifestDecoder);
|
|
1888
1330
|
if (r.kind === "err")
|
|
1889
1331
|
return err(formatDecodeError(r.error));
|
|
1890
1332
|
const m = r.value;
|
|
@@ -2636,6 +2078,424 @@ function rcFileFor(shell, f) {
|
|
|
2636
2078
|
return absurd(shell);
|
|
2637
2079
|
}
|
|
2638
2080
|
}
|
|
2081
|
+
// ../ts/kernel/otel.ts
|
|
2082
|
+
var TRACE_ID = /^[0-9a-f]{32}$/;
|
|
2083
|
+
var SPAN_ID = /^[0-9a-f]{16}$/;
|
|
2084
|
+
var ZEROS = /^0+$/;
|
|
2085
|
+
function parseTraceId(text) {
|
|
2086
|
+
if (!TRACE_ID.test(text))
|
|
2087
|
+
return err("a trace id is 32 lower-case hexadecimal digits");
|
|
2088
|
+
if (ZEROS.test(text))
|
|
2089
|
+
return err("a trace id of all zeros is not valid");
|
|
2090
|
+
return ok(text);
|
|
2091
|
+
}
|
|
2092
|
+
function parseSpanId(text) {
|
|
2093
|
+
if (!SPAN_ID.test(text))
|
|
2094
|
+
return err("a span id is 16 lower-case hexadecimal digits");
|
|
2095
|
+
if (ZEROS.test(text))
|
|
2096
|
+
return err("a span id of all zeros is not valid");
|
|
2097
|
+
return ok(text);
|
|
2098
|
+
}
|
|
2099
|
+
var SAMPLED = 1;
|
|
2100
|
+
var RANDOM = 2;
|
|
2101
|
+
var KNOWN_FLAGS = SAMPLED | RANDOM;
|
|
2102
|
+
var TRACESTATE_MAX_MEMBERS = 32;
|
|
2103
|
+
var KEY_CHAR = "[a-z0-9_\\-*/]";
|
|
2104
|
+
var TRACESTATE_KEY = new RegExp(`^(?:[a-z]${KEY_CHAR}{0,255}|[a-z0-9]${KEY_CHAR}{0,240}@[a-z]${KEY_CHAR}{0,13})$`);
|
|
2105
|
+
var TRACESTATE_VALUE = /^[\x20-\x2b\x2d-\x3c\x3e-\x7e]{0,255}[\x21-\x2b\x2d-\x3c\x3e-\x7e]$/;
|
|
2106
|
+
function isTraceStateKey(key) {
|
|
2107
|
+
return TRACESTATE_KEY.test(key);
|
|
2108
|
+
}
|
|
2109
|
+
function isTraceStateValue(value) {
|
|
2110
|
+
return TRACESTATE_VALUE.test(value);
|
|
2111
|
+
}
|
|
2112
|
+
function parseTracestate(header) {
|
|
2113
|
+
const out = [];
|
|
2114
|
+
const seen = new Set;
|
|
2115
|
+
for (const raw of header.split(",")) {
|
|
2116
|
+
if (out.length >= TRACESTATE_MAX_MEMBERS)
|
|
2117
|
+
break;
|
|
2118
|
+
const member = raw.replace(/^[ \t]+|[ \t]+$/g, "");
|
|
2119
|
+
if (member === "")
|
|
2120
|
+
continue;
|
|
2121
|
+
const eq = member.indexOf("=");
|
|
2122
|
+
if (eq < 0)
|
|
2123
|
+
continue;
|
|
2124
|
+
const key = member.slice(0, eq);
|
|
2125
|
+
const value = member.slice(eq + 1);
|
|
2126
|
+
if (!isTraceStateKey(key) || !isTraceStateValue(value) || seen.has(key))
|
|
2127
|
+
continue;
|
|
2128
|
+
seen.add(key);
|
|
2129
|
+
out.push({ key, value });
|
|
2130
|
+
}
|
|
2131
|
+
return out;
|
|
2132
|
+
}
|
|
2133
|
+
var SEVERITY = { TRACE: 1, DEBUG: 5, INFO: 9, WARN: 13, ERROR: 17, FATAL: 21 };
|
|
2134
|
+
function isSeverityNumber(n) {
|
|
2135
|
+
return Number.isInteger(n) && n >= 1 && n <= 24;
|
|
2136
|
+
}
|
|
2137
|
+
var TWO_56 = 2 ** 56;
|
|
2138
|
+
var CREDENTIAL_WORDS = new Set(["key", "code", "sig", "pwd", "pass", "session", "sid", "otp", "awsaccesskeyid", "sas", "se", "sp", "sv"]);
|
|
2139
|
+
|
|
2140
|
+
// ../ts/kernel/otlp.ts
|
|
2141
|
+
var SPAN_KINDS = ["internal", "server", "client", "producer", "consumer"];
|
|
2142
|
+
class Failure extends Error {
|
|
2143
|
+
error;
|
|
2144
|
+
constructor(error) {
|
|
2145
|
+
super(error.path);
|
|
2146
|
+
this.error = error;
|
|
2147
|
+
}
|
|
2148
|
+
}
|
|
2149
|
+
function failure(path, expected, input) {
|
|
2150
|
+
return { kind: "decode", path, expected, found: describe(input) };
|
|
2151
|
+
}
|
|
2152
|
+
function message(build) {
|
|
2153
|
+
return (input, path = "$") => {
|
|
2154
|
+
if (typeof input !== "object" || input === null || Array.isArray(input))
|
|
2155
|
+
return err(failure(path, "an object", input));
|
|
2156
|
+
const read = (key, decoder) => {
|
|
2157
|
+
const r = decoder(Reflect.get(input, key), `${path}.${key}`);
|
|
2158
|
+
if (r.kind === "err")
|
|
2159
|
+
throw new Failure(r.error);
|
|
2160
|
+
return r.value;
|
|
2161
|
+
};
|
|
2162
|
+
const f = {
|
|
2163
|
+
req: read,
|
|
2164
|
+
opt: (key, decoder, fallback) => {
|
|
2165
|
+
const v = Reflect.get(input, key);
|
|
2166
|
+
return v === undefined || v === null ? fallback : read(key, decoder);
|
|
2167
|
+
}
|
|
2168
|
+
};
|
|
2169
|
+
try {
|
|
2170
|
+
return ok(build(f, path));
|
|
2171
|
+
} catch (e) {
|
|
2172
|
+
if (e instanceof Failure)
|
|
2173
|
+
return err(e.error);
|
|
2174
|
+
throw e;
|
|
2175
|
+
}
|
|
2176
|
+
};
|
|
2177
|
+
}
|
|
2178
|
+
function list(element) {
|
|
2179
|
+
return (input, path = "$") => {
|
|
2180
|
+
if (!Array.isArray(input))
|
|
2181
|
+
return err(failure(path, "an array", input));
|
|
2182
|
+
const out = [];
|
|
2183
|
+
for (const [i, value] of input.entries()) {
|
|
2184
|
+
const r = element(value, `${path}[${i}]`);
|
|
2185
|
+
if (r.kind === "err")
|
|
2186
|
+
return r;
|
|
2187
|
+
out.push(r.value);
|
|
2188
|
+
}
|
|
2189
|
+
return ok(out);
|
|
2190
|
+
};
|
|
2191
|
+
}
|
|
2192
|
+
var str = (input, path = "$") => typeof input === "string" ? ok(input) : err(failure(path, "a string", input));
|
|
2193
|
+
var bool = (input, path = "$") => typeof input === "boolean" ? ok(input) : err(failure(path, "a boolean", input));
|
|
2194
|
+
var int64 = (input, path = "$") => {
|
|
2195
|
+
if (typeof input === "number" && Number.isInteger(input))
|
|
2196
|
+
return ok(BigInt(input));
|
|
2197
|
+
if (typeof input === "string" && /^-?[0-9]+$/.test(input))
|
|
2198
|
+
return ok(BigInt(input));
|
|
2199
|
+
return err(failure(path, "a 64-bit integer (a number or a decimal string)", input));
|
|
2200
|
+
};
|
|
2201
|
+
var count = (input, path = "$") => {
|
|
2202
|
+
const r = int64(input, path);
|
|
2203
|
+
if (r.kind === "err")
|
|
2204
|
+
return r;
|
|
2205
|
+
return r.value >= 0n && r.value <= BigInt(Number.MAX_SAFE_INTEGER) ? ok(Number(r.value)) : err(failure(path, "a count", input));
|
|
2206
|
+
};
|
|
2207
|
+
var double = (input, path = "$") => {
|
|
2208
|
+
if (typeof input === "number")
|
|
2209
|
+
return ok(input);
|
|
2210
|
+
if (input === "NaN")
|
|
2211
|
+
return ok(NaN);
|
|
2212
|
+
if (input === "Infinity")
|
|
2213
|
+
return ok(Infinity);
|
|
2214
|
+
if (input === "-Infinity")
|
|
2215
|
+
return ok(-Infinity);
|
|
2216
|
+
return err(failure(path, "a double", input));
|
|
2217
|
+
};
|
|
2218
|
+
var bytes = (input, path = "$") => {
|
|
2219
|
+
if (typeof input !== "string")
|
|
2220
|
+
return err(failure(path, "base64", input));
|
|
2221
|
+
const r = fromBase64(input);
|
|
2222
|
+
return r.kind === "ok" ? r : err(failure(path, "base64", input));
|
|
2223
|
+
};
|
|
2224
|
+
var traceId = (input, path = "$") => {
|
|
2225
|
+
const r = typeof input === "string" ? parseTraceId(input.toLowerCase()) : err("");
|
|
2226
|
+
return r.kind === "ok" ? r : err(failure(path, "a trace id (32 hexadecimal digits, not all zeros)", input));
|
|
2227
|
+
};
|
|
2228
|
+
var spanId = (input, path = "$") => {
|
|
2229
|
+
const r = typeof input === "string" ? parseSpanId(input.toLowerCase()) : err("");
|
|
2230
|
+
return r.kind === "ok" ? r : err(failure(path, "a span id (16 hexadecimal digits, not all zeros)", input));
|
|
2231
|
+
};
|
|
2232
|
+
function enumeration(names) {
|
|
2233
|
+
return (input, path = "$") => {
|
|
2234
|
+
if (typeof input === "number" && Number.isInteger(input) && input >= 0 && input < names.length)
|
|
2235
|
+
return ok(input);
|
|
2236
|
+
if (typeof input === "string") {
|
|
2237
|
+
const i = names.indexOf(input);
|
|
2238
|
+
if (i >= 0)
|
|
2239
|
+
return ok(i);
|
|
2240
|
+
}
|
|
2241
|
+
return err(failure(path, `one of ${names.join(", ")} or its number`, input));
|
|
2242
|
+
};
|
|
2243
|
+
}
|
|
2244
|
+
var spanKindEnum = enumeration([
|
|
2245
|
+
"SPAN_KIND_UNSPECIFIED",
|
|
2246
|
+
"SPAN_KIND_INTERNAL",
|
|
2247
|
+
"SPAN_KIND_SERVER",
|
|
2248
|
+
"SPAN_KIND_CLIENT",
|
|
2249
|
+
"SPAN_KIND_PRODUCER",
|
|
2250
|
+
"SPAN_KIND_CONSUMER"
|
|
2251
|
+
]);
|
|
2252
|
+
var statusCodeEnum = enumeration(["STATUS_CODE_UNSET", "STATUS_CODE_OK", "STATUS_CODE_ERROR"]);
|
|
2253
|
+
var temporalityEnum = enumeration([
|
|
2254
|
+
"AGGREGATION_TEMPORALITY_UNSPECIFIED",
|
|
2255
|
+
"AGGREGATION_TEMPORALITY_DELTA",
|
|
2256
|
+
"AGGREGATION_TEMPORALITY_CUMULATIVE"
|
|
2257
|
+
]);
|
|
2258
|
+
var SEVERITY_NAMES = ["SEVERITY_NUMBER_UNSPECIFIED"].concat(["TRACE", "DEBUG", "INFO", "WARN", "ERROR", "FATAL"].flatMap((r) => ["", "2", "3", "4"].map((n) => `SEVERITY_NUMBER_${r}${n}`)));
|
|
2259
|
+
var severityEnum = (input, path = "$") => {
|
|
2260
|
+
const r = enumeration(SEVERITY_NAMES)(input, path);
|
|
2261
|
+
if (r.kind === "err")
|
|
2262
|
+
return r;
|
|
2263
|
+
return isSeverityNumber(r.value) ? ok(r.value) : err(failure(path, "a severity number from 1 to 24", input));
|
|
2264
|
+
};
|
|
2265
|
+
var decodeAnyValue = (input, path = "$") => {
|
|
2266
|
+
if (typeof input !== "object" || input === null || Array.isArray(input))
|
|
2267
|
+
return err(failure(path, "an AnyValue object", input));
|
|
2268
|
+
const has = (key) => {
|
|
2269
|
+
const v = Reflect.get(input, key);
|
|
2270
|
+
return v !== undefined && v !== null;
|
|
2271
|
+
};
|
|
2272
|
+
const at = (key) => Reflect.get(input, key);
|
|
2273
|
+
if (has("stringValue"))
|
|
2274
|
+
return str(at("stringValue"), `${path}.stringValue`);
|
|
2275
|
+
if (has("boolValue"))
|
|
2276
|
+
return bool(at("boolValue"), `${path}.boolValue`);
|
|
2277
|
+
if (has("intValue"))
|
|
2278
|
+
return int64(at("intValue"), `${path}.intValue`);
|
|
2279
|
+
if (has("doubleValue"))
|
|
2280
|
+
return double(at("doubleValue"), `${path}.doubleValue`);
|
|
2281
|
+
if (has("bytesValue"))
|
|
2282
|
+
return bytes(at("bytesValue"), `${path}.bytesValue`);
|
|
2283
|
+
if (has("arrayValue"))
|
|
2284
|
+
return message((f) => f.opt("values", list(decodeAnyValue), []))(at("arrayValue"), `${path}.arrayValue`);
|
|
2285
|
+
if (has("kvlistValue")) {
|
|
2286
|
+
return message((f) => {
|
|
2287
|
+
const out = {};
|
|
2288
|
+
for (const kv of f.opt("values", list(keyValue(decodeAnyValue)), [])) {
|
|
2289
|
+
Object.defineProperty(out, kv.key, { value: kv.value, enumerable: true, writable: true, configurable: true });
|
|
2290
|
+
}
|
|
2291
|
+
return out;
|
|
2292
|
+
})(at("kvlistValue"), `${path}.kvlistValue`);
|
|
2293
|
+
}
|
|
2294
|
+
return err(failure(path, "an AnyValue holding a value", input));
|
|
2295
|
+
};
|
|
2296
|
+
function keyValue(value) {
|
|
2297
|
+
return message((f) => ({ key: f.req("key", str), value: f.req("value", value) }));
|
|
2298
|
+
}
|
|
2299
|
+
var decodeAttributeValue = (input, path = "$") => {
|
|
2300
|
+
const r = decodeAnyValue(input, path);
|
|
2301
|
+
if (r.kind === "err")
|
|
2302
|
+
return r;
|
|
2303
|
+
const v = r.value;
|
|
2304
|
+
if (typeof v !== "object" || v instanceof Uint8Array)
|
|
2305
|
+
return ok(v);
|
|
2306
|
+
if (Array.isArray(v)) {
|
|
2307
|
+
const values = v;
|
|
2308
|
+
if (values.every((e) => typeof e === "string"))
|
|
2309
|
+
return ok(values.filter((e) => typeof e === "string"));
|
|
2310
|
+
if (values.every((e) => typeof e === "boolean"))
|
|
2311
|
+
return ok(values.filter((e) => typeof e === "boolean"));
|
|
2312
|
+
if (values.every((e) => typeof e === "bigint"))
|
|
2313
|
+
return ok(values.filter((e) => typeof e === "bigint"));
|
|
2314
|
+
if (values.every((e) => typeof e === "number"))
|
|
2315
|
+
return ok(values.filter((e) => typeof e === "number"));
|
|
2316
|
+
}
|
|
2317
|
+
return err(failure(path, "an attribute value (a primitive or a homogeneous array of primitives)", input));
|
|
2318
|
+
};
|
|
2319
|
+
var decodeAttributes = (input, path = "$") => {
|
|
2320
|
+
const r = list(keyValue(decodeAttributeValue))(input, path);
|
|
2321
|
+
if (r.kind === "err")
|
|
2322
|
+
return r;
|
|
2323
|
+
const out = {};
|
|
2324
|
+
for (const kv of r.value)
|
|
2325
|
+
Object.defineProperty(out, kv.key, { value: kv.value, enumerable: true, writable: true, configurable: true });
|
|
2326
|
+
return ok(out);
|
|
2327
|
+
};
|
|
2328
|
+
var resource = message((f) => ({ attributes: f.opt("attributes", decodeAttributes, {}) }));
|
|
2329
|
+
var scope = message((f) => {
|
|
2330
|
+
const version = f.opt("version", str, undefined);
|
|
2331
|
+
const attributes = f.opt("attributes", decodeAttributes, undefined);
|
|
2332
|
+
return {
|
|
2333
|
+
name: f.opt("name", str, ""),
|
|
2334
|
+
...version === undefined ? {} : { version },
|
|
2335
|
+
...attributes === undefined ? {} : { attributes }
|
|
2336
|
+
};
|
|
2337
|
+
});
|
|
2338
|
+
var event = message((f) => ({
|
|
2339
|
+
name: f.opt("name", str, ""),
|
|
2340
|
+
time: f.opt("timeUnixNano", int64, 0n),
|
|
2341
|
+
attributes: f.opt("attributes", decodeAttributes, {}),
|
|
2342
|
+
droppedAttributesCount: f.opt("droppedAttributesCount", count, 0)
|
|
2343
|
+
}));
|
|
2344
|
+
var link = message((f) => ({
|
|
2345
|
+
traceId: f.req("traceId", traceId),
|
|
2346
|
+
spanId: f.req("spanId", spanId),
|
|
2347
|
+
traceState: parseTracestate(f.opt("traceState", str, "")),
|
|
2348
|
+
traceFlags: f.opt("flags", count, 0) & 255,
|
|
2349
|
+
attributes: f.opt("attributes", decodeAttributes, {}),
|
|
2350
|
+
droppedAttributesCount: f.opt("droppedAttributesCount", count, 0)
|
|
2351
|
+
}));
|
|
2352
|
+
var status = message((f) => {
|
|
2353
|
+
const code = f.opt("code", statusCodeEnum, 0);
|
|
2354
|
+
if (code === 1)
|
|
2355
|
+
return { kind: "ok" };
|
|
2356
|
+
if (code === 2)
|
|
2357
|
+
return { kind: "error", message: f.opt("message", str, "") };
|
|
2358
|
+
return { kind: "unset" };
|
|
2359
|
+
});
|
|
2360
|
+
var optionalSpanId = (input, path = "$") => input === "" ? ok(undefined) : spanId(input, path);
|
|
2361
|
+
var decodeSpan = message((f) => {
|
|
2362
|
+
const parentSpanId = f.opt("parentSpanId", optionalSpanId, undefined);
|
|
2363
|
+
const kind = f.opt("kind", spanKindEnum, 1);
|
|
2364
|
+
return {
|
|
2365
|
+
name: f.opt("name", str, ""),
|
|
2366
|
+
context: {
|
|
2367
|
+
traceId: f.req("traceId", traceId),
|
|
2368
|
+
spanId: f.req("spanId", spanId),
|
|
2369
|
+
traceFlags: f.opt("flags", count, 0) & 255,
|
|
2370
|
+
traceState: parseTracestate(f.opt("traceState", str, "")),
|
|
2371
|
+
isRemote: false
|
|
2372
|
+
},
|
|
2373
|
+
...parentSpanId === undefined ? {} : { parentSpanId },
|
|
2374
|
+
kind: SPAN_KINDS[kind - 1] ?? "internal",
|
|
2375
|
+
startTime: f.opt("startTimeUnixNano", int64, 0n),
|
|
2376
|
+
endTime: f.opt("endTimeUnixNano", int64, 0n),
|
|
2377
|
+
attributes: f.opt("attributes", decodeAttributes, {}),
|
|
2378
|
+
events: f.opt("events", list(event), []),
|
|
2379
|
+
links: f.opt("links", list(link), []),
|
|
2380
|
+
status: f.opt("status", status, { kind: "unset" }),
|
|
2381
|
+
droppedAttributesCount: f.opt("droppedAttributesCount", count, 0),
|
|
2382
|
+
droppedEventsCount: f.opt("droppedEventsCount", count, 0),
|
|
2383
|
+
droppedLinksCount: f.opt("droppedLinksCount", count, 0)
|
|
2384
|
+
};
|
|
2385
|
+
});
|
|
2386
|
+
var optionalTraceId = (input, path = "$") => input === "" ? ok(undefined) : traceId(input, path);
|
|
2387
|
+
var decodeLogRecord = message((f) => {
|
|
2388
|
+
const body = f.opt("body", decodeAnyValue, undefined);
|
|
2389
|
+
const traceFlags = f.opt("flags", count, undefined);
|
|
2390
|
+
const tid = f.opt("traceId", optionalTraceId, undefined);
|
|
2391
|
+
const sid = f.opt("spanId", optionalSpanId, undefined);
|
|
2392
|
+
const eventName = f.opt("eventName", str, undefined);
|
|
2393
|
+
return {
|
|
2394
|
+
time: f.opt("timeUnixNano", int64, 0n),
|
|
2395
|
+
observedTime: f.opt("observedTimeUnixNano", int64, 0n),
|
|
2396
|
+
severityNumber: f.req("severityNumber", severityEnum),
|
|
2397
|
+
severityText: f.opt("severityText", str, ""),
|
|
2398
|
+
...body === undefined ? {} : { body },
|
|
2399
|
+
attributes: f.opt("attributes", decodeAttributes, {}),
|
|
2400
|
+
droppedAttributesCount: f.opt("droppedAttributesCount", count, 0),
|
|
2401
|
+
...eventName === undefined ? {} : { eventName },
|
|
2402
|
+
...tid === undefined ? {} : { traceId: tid },
|
|
2403
|
+
...sid === undefined ? {} : { spanId: sid },
|
|
2404
|
+
...traceFlags === undefined ? {} : { traceFlags: traceFlags & 255 }
|
|
2405
|
+
};
|
|
2406
|
+
});
|
|
2407
|
+
var numberPoint = message((f, path) => {
|
|
2408
|
+
const asInt = f.opt("asInt", int64, undefined);
|
|
2409
|
+
const asDouble = f.opt("asDouble", double, undefined);
|
|
2410
|
+
const value = asInt ?? asDouble;
|
|
2411
|
+
if (value === undefined)
|
|
2412
|
+
throw new Failure(failure(`${path}.asDouble`, "asInt or asDouble", undefined));
|
|
2413
|
+
return {
|
|
2414
|
+
attributes: f.opt("attributes", decodeAttributes, {}),
|
|
2415
|
+
startTime: f.opt("startTimeUnixNano", int64, 0n),
|
|
2416
|
+
time: f.opt("timeUnixNano", int64, 0n),
|
|
2417
|
+
value
|
|
2418
|
+
};
|
|
2419
|
+
});
|
|
2420
|
+
var histogramPoint = message((f, path) => {
|
|
2421
|
+
const sum = f.opt("sum", double, undefined);
|
|
2422
|
+
const min = f.opt("min", double, undefined);
|
|
2423
|
+
const max = f.opt("max", double, undefined);
|
|
2424
|
+
const bounds = f.opt("explicitBounds", list(double), []);
|
|
2425
|
+
const bucketCounts = f.opt("bucketCounts", list(count), []);
|
|
2426
|
+
if (bucketCounts.length !== 0 && bucketCounts.length !== bounds.length + 1) {
|
|
2427
|
+
throw new Failure(failure(`${path}.bucketCounts`, `${bounds.length + 1} bucket counts`, bucketCounts.length));
|
|
2428
|
+
}
|
|
2429
|
+
return {
|
|
2430
|
+
attributes: f.opt("attributes", decodeAttributes, {}),
|
|
2431
|
+
startTime: f.opt("startTimeUnixNano", int64, 0n),
|
|
2432
|
+
time: f.opt("timeUnixNano", int64, 0n),
|
|
2433
|
+
count: f.opt("count", count, 0),
|
|
2434
|
+
...sum === undefined ? {} : { sum },
|
|
2435
|
+
...min === undefined ? {} : { min },
|
|
2436
|
+
...max === undefined ? {} : { max },
|
|
2437
|
+
bounds,
|
|
2438
|
+
bucketCounts
|
|
2439
|
+
};
|
|
2440
|
+
});
|
|
2441
|
+
function temporalityOf(n) {
|
|
2442
|
+
return n === 1 ? "delta" : "cumulative";
|
|
2443
|
+
}
|
|
2444
|
+
var decodeMetric = message((f, path) => {
|
|
2445
|
+
const head = { name: f.opt("name", str, ""), description: f.opt("description", str, ""), unit: f.opt("unit", str, "") };
|
|
2446
|
+
const sum = f.opt("sum", message((g) => ({
|
|
2447
|
+
kind: "sum",
|
|
2448
|
+
points: g.opt("dataPoints", list(numberPoint), []),
|
|
2449
|
+
temporality: temporalityOf(g.opt("aggregationTemporality", temporalityEnum, 2)),
|
|
2450
|
+
monotonic: g.opt("isMonotonic", bool, false)
|
|
2451
|
+
})), undefined);
|
|
2452
|
+
if (sum !== undefined)
|
|
2453
|
+
return { ...head, data: sum };
|
|
2454
|
+
const gauge = f.opt("gauge", message((g) => ({ kind: "gauge", points: g.opt("dataPoints", list(numberPoint), []) })), undefined);
|
|
2455
|
+
if (gauge !== undefined)
|
|
2456
|
+
return { ...head, data: gauge };
|
|
2457
|
+
const histogram = f.opt("histogram", message((g) => ({
|
|
2458
|
+
kind: "histogram",
|
|
2459
|
+
points: g.opt("dataPoints", list(histogramPoint), []),
|
|
2460
|
+
temporality: temporalityOf(g.opt("aggregationTemporality", temporalityEnum, 2))
|
|
2461
|
+
})), undefined);
|
|
2462
|
+
if (histogram !== undefined)
|
|
2463
|
+
return { ...head, data: histogram };
|
|
2464
|
+
throw new Failure(failure(`${path}.sum`, "a sum, a gauge or a histogram", undefined));
|
|
2465
|
+
});
|
|
2466
|
+
|
|
2467
|
+
// ../ts/kernel/signals.ts
|
|
2468
|
+
var ATTRIBUTE_TYPES = new Set([
|
|
2469
|
+
"string",
|
|
2470
|
+
"boolean",
|
|
2471
|
+
"int",
|
|
2472
|
+
"double",
|
|
2473
|
+
"bytes",
|
|
2474
|
+
"string[]",
|
|
2475
|
+
"boolean[]",
|
|
2476
|
+
"int[]",
|
|
2477
|
+
"double[]"
|
|
2478
|
+
]);
|
|
2479
|
+
function defineSignals(kinds) {
|
|
2480
|
+
for (const [name, d] of Object.entries(kinds)) {
|
|
2481
|
+
const declared = new Set(Object.keys(d.attributes).map((k) => k.replace(/\?$/, "")));
|
|
2482
|
+
for (const [k, t] of Object.entries(d.attributes)) {
|
|
2483
|
+
if (!ATTRIBUTE_TYPES.has(t))
|
|
2484
|
+
throw new Error(`${name}: the attribute ${k} has the type ${t}, which does not exist`);
|
|
2485
|
+
}
|
|
2486
|
+
for (const s of d.secret ?? [])
|
|
2487
|
+
if (!declared.has(s))
|
|
2488
|
+
throw new Error(`${name}: the secret attribute ${s} is not declared`);
|
|
2489
|
+
if (d.signal === "histogram" && d.bounds !== undefined) {
|
|
2490
|
+
const b = d.bounds;
|
|
2491
|
+
if (b.some((x, i) => !Number.isFinite(x) || i > 0 && x <= (b[i - 1] ?? -Infinity))) {
|
|
2492
|
+
throw new Error(`${name}: the histogram bounds do not increase`);
|
|
2493
|
+
}
|
|
2494
|
+
}
|
|
2495
|
+
}
|
|
2496
|
+
return { kinds };
|
|
2497
|
+
}
|
|
2498
|
+
|
|
2639
2499
|
// ../ts/runtime/otel.ts
|
|
2640
2500
|
var RETRYABLE_STATUSES = new Set([429, 502, 503, 504]);
|
|
2641
2501
|
var DAY_MS = 24 * 60 * 60 * 1000;
|
|
@@ -3820,7 +3680,7 @@ export {
|
|
|
3820
3680
|
MODULE_SOURCES,
|
|
3821
3681
|
REPO_PATH_ROOM,
|
|
3822
3682
|
REPO_STATE_KINDS,
|
|
3823
|
-
|
|
3683
|
+
SEVERITIES,
|
|
3824
3684
|
SHELLS,
|
|
3825
3685
|
STATE_RECORD_PATH,
|
|
3826
3686
|
TEMPLATES,
|
|
@@ -3830,7 +3690,7 @@ export {
|
|
|
3830
3690
|
branchName,
|
|
3831
3691
|
checkFiles,
|
|
3832
3692
|
checkPathLength,
|
|
3833
|
-
|
|
3693
|
+
child,
|
|
3834
3694
|
classify,
|
|
3835
3695
|
classifyFs,
|
|
3836
3696
|
collisions,
|