@moldea.ai/cli 13.0.3 → 14.0.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/README.md +5 -9
- package/dist/chunks/{composition-eP3YRV8y.js → composition-D1OYuZ5d.js} +1 -1
- package/dist/chunks/{composition-BNE2Fn_6.js → composition-_3bygS_a.js} +21 -23
- package/dist/chunks/composition-_3bygS_a.js.map +1 -0
- package/dist/chunks/{core-composition-CJkwbKa4.js → core-composition-BKcJ--NX.js} +2 -2
- package/dist/chunks/{core-composition-CJkwbKa4.js.map → core-composition-BKcJ--NX.js.map} +1 -1
- package/dist/moldea.js +7 -12
- package/dist/moldea.js.map +1 -1
- package/dist/portable/LICENSES.md +506 -0
- package/dist/portable/SHA256SUMS +17 -0
- package/dist/portable/analysis-worker.mjs +193 -0
- package/dist/portable/chunk-131f8005.mjs +115 -0
- package/dist/portable/chunk-2ba7e89e.mjs +26 -0
- package/dist/portable/chunk-459da9cf.mjs +4138 -0
- package/dist/portable/chunk-728df961.mjs +544 -0
- package/dist/portable/chunk-8d6114d2.mjs +588 -0
- package/dist/portable/chunk-90403e67.mjs +2 -0
- package/dist/portable/chunk-94b5ac22.mjs +59 -0
- package/dist/portable/chunk-a5514957.mjs +5870 -0
- package/dist/portable/chunk-b98ca669.mjs +2 -0
- package/dist/portable/chunk-c13db66a.mjs +380 -0
- package/dist/portable/chunk-d5af3eda.mjs +2926 -0
- package/dist/portable/chunk-ec3f49d3.mjs +367 -0
- package/dist/portable/chunk-fcbcf4e3.mjs +147458 -0
- package/dist/portable/moldea.mjs +3529 -0
- package/dist/portable/node-runner.mjs +146 -0
- package/package.json +3 -3
- package/dist/chunks/composition-BNE2Fn_6.js.map +0 -1
|
@@ -0,0 +1,544 @@
|
|
|
1
|
+
//#region ../../node_modules/.pnpm/jg-exception@1.7.1/node_modules/jg-exception/dist/shared/constants.js
|
|
2
|
+
var UNKNOWN_ERROR_CODE = "UNKNOWN_ERROR";
|
|
3
|
+
var REDACTED_VALUE = "[redacted]";
|
|
4
|
+
//#endregion
|
|
5
|
+
//#region ../../node_modules/.pnpm/jg-exception@1.7.1/node_modules/jg-exception/dist/shared/utilities.js
|
|
6
|
+
var stringifyWithinDepth = (value) => {
|
|
7
|
+
const levels = new WeakMap();
|
|
8
|
+
const limitDepth = function(_key, member) {
|
|
9
|
+
if (typeof member === "object" && member !== null) {
|
|
10
|
+
const level = (levels.get(this) ?? 0) + 1;
|
|
11
|
+
if (level > 256) throw new RangeError("The value is nested too deeply to serialize.");
|
|
12
|
+
levels.set(member, level);
|
|
13
|
+
}
|
|
14
|
+
return member;
|
|
15
|
+
};
|
|
16
|
+
return JSON.stringify(value, limitDepth);
|
|
17
|
+
};
|
|
18
|
+
//#endregion
|
|
19
|
+
//#region ../../node_modules/.pnpm/jg-exception@1.7.1/node_modules/jg-exception/dist/error-handler/utilities.js
|
|
20
|
+
var collectSensitiveRanges = (message, sensitiveValues) => {
|
|
21
|
+
const sensitiveRanges = [];
|
|
22
|
+
sensitiveValues.forEach((sensitiveValue) => {
|
|
23
|
+
let matchStart = message.indexOf(sensitiveValue);
|
|
24
|
+
while (matchStart !== -1) {
|
|
25
|
+
sensitiveRanges.push({
|
|
26
|
+
start: matchStart,
|
|
27
|
+
end: matchStart + sensitiveValue.length
|
|
28
|
+
});
|
|
29
|
+
matchStart = message.indexOf(sensitiveValue, matchStart + 1);
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
return sensitiveRanges;
|
|
33
|
+
};
|
|
34
|
+
var mergeOverlappingRanges = (sensitiveRanges) => {
|
|
35
|
+
const sortedSensitiveRanges = [...sensitiveRanges].sort((firstRange, secondRange) => firstRange.start - secondRange.start || secondRange.end - firstRange.end);
|
|
36
|
+
const mergedSensitiveRanges = [];
|
|
37
|
+
sortedSensitiveRanges.forEach((currentRange) => {
|
|
38
|
+
const previousRange = mergedSensitiveRanges.at(-1);
|
|
39
|
+
if (!previousRange || currentRange.start >= previousRange.end) {
|
|
40
|
+
mergedSensitiveRanges.push({ ...currentRange });
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
if (currentRange.end > previousRange.end) previousRange.end = currentRange.end;
|
|
44
|
+
});
|
|
45
|
+
return mergedSensitiveRanges;
|
|
46
|
+
};
|
|
47
|
+
var redactSensitiveValues = (message, sensitiveValues) => {
|
|
48
|
+
const uniqueSensitiveValues = [...new Set(sensitiveValues.filter((sensitiveValue) => sensitiveValue.length > 0))];
|
|
49
|
+
if (!uniqueSensitiveValues.length) return message;
|
|
50
|
+
const sensitiveRanges = mergeOverlappingRanges(collectSensitiveRanges(message, uniqueSensitiveValues));
|
|
51
|
+
if (!sensitiveRanges.length) return message;
|
|
52
|
+
const redactedMessageParts = [];
|
|
53
|
+
let nextMessageIndex = 0;
|
|
54
|
+
sensitiveRanges.forEach((sensitiveRange) => {
|
|
55
|
+
redactedMessageParts.push(message.slice(nextMessageIndex, sensitiveRange.start), REDACTED_VALUE);
|
|
56
|
+
nextMessageIndex = sensitiveRange.end;
|
|
57
|
+
});
|
|
58
|
+
redactedMessageParts.push(message.slice(nextMessageIndex));
|
|
59
|
+
return redactedMessageParts.join("");
|
|
60
|
+
};
|
|
61
|
+
//#endregion
|
|
62
|
+
//#region ../../node_modules/.pnpm/jg-exception@1.7.1/node_modules/jg-exception/dist/error-handler/index.js
|
|
63
|
+
var getErrorCode = (error) => {
|
|
64
|
+
if (typeof error !== "object" || error === null) return null;
|
|
65
|
+
const { code } = error;
|
|
66
|
+
return typeof code === "string" && code.length > 0 ? code : null;
|
|
67
|
+
};
|
|
68
|
+
var hasErrorCode = (error, code) => code.length > 0 && (typeof error === "string" ? error : getErrorCode(error)) === code;
|
|
69
|
+
//#endregion
|
|
70
|
+
//#region ../../node_modules/.pnpm/jg-exception@1.7.1/node_modules/jg-exception/dist/exception/constants.js
|
|
71
|
+
var EXCEPTION_BRAND = Symbol.for("jg-exception.Exception");
|
|
72
|
+
var EXCEPTION_SEVERITIES = ["expected", "critical"];
|
|
73
|
+
//#endregion
|
|
74
|
+
//#region ../../node_modules/.pnpm/jg-exception@1.7.1/node_modules/jg-exception/dist/exception/redaction.js
|
|
75
|
+
var BUILT_PROPERTIES = new Set([
|
|
76
|
+
"name",
|
|
77
|
+
"message",
|
|
78
|
+
"stack",
|
|
79
|
+
"cause"
|
|
80
|
+
]);
|
|
81
|
+
var VERBATIM_EXCEPTION_PROPERTIES = new Set(["severity", "shouldLog"]);
|
|
82
|
+
var MAX_PROTOTYPE_DEPTH = 32;
|
|
83
|
+
var ARRAY_INDEX = /^(?:0|[1-9]\d*)$/;
|
|
84
|
+
var findDescriptor = (target, key) => {
|
|
85
|
+
let current = target;
|
|
86
|
+
for (let depth = 0; current !== null && depth < MAX_PROTOTYPE_DEPTH; depth += 1) {
|
|
87
|
+
const descriptor = Reflect.getOwnPropertyDescriptor(current, key);
|
|
88
|
+
if (descriptor !== void 0) return descriptor;
|
|
89
|
+
current = Reflect.getPrototypeOf(current);
|
|
90
|
+
}
|
|
91
|
+
return {};
|
|
92
|
+
};
|
|
93
|
+
var ENGINE_STACK_GETTER = Reflect.get(findDescriptor(new Error(), "stack"), "get");
|
|
94
|
+
var readDescriptor = (target, descriptor) => {
|
|
95
|
+
if ("value" in descriptor) return descriptor.value;
|
|
96
|
+
const getter = Reflect.get(descriptor, "get");
|
|
97
|
+
return typeof getter === "function" && getter === ENGINE_STACK_GETTER ? Reflect.apply(getter, target, []) : void 0;
|
|
98
|
+
};
|
|
99
|
+
var readProperty = (target, key, isInherited) => {
|
|
100
|
+
try {
|
|
101
|
+
return readDescriptor(target, isInherited ? findDescriptor(target, key) : Reflect.getOwnPropertyDescriptor(target, key) ?? {});
|
|
102
|
+
} catch {
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
};
|
|
106
|
+
var readDataEntries = (target) => {
|
|
107
|
+
let keys;
|
|
108
|
+
try {
|
|
109
|
+
keys = Reflect.ownKeys(target);
|
|
110
|
+
} catch {
|
|
111
|
+
return [];
|
|
112
|
+
}
|
|
113
|
+
return keys.flatMap((key) => {
|
|
114
|
+
if (typeof key !== "string") return [];
|
|
115
|
+
try {
|
|
116
|
+
const descriptor = Reflect.getOwnPropertyDescriptor(target, key);
|
|
117
|
+
return descriptor?.enumerable === true && "value" in descriptor ? [[key, descriptor.value]] : [];
|
|
118
|
+
} catch {
|
|
119
|
+
return [];
|
|
120
|
+
}
|
|
121
|
+
});
|
|
122
|
+
};
|
|
123
|
+
var defineValue = (target, key, value, enumerable) => {
|
|
124
|
+
Object.defineProperty(target, key, {
|
|
125
|
+
value,
|
|
126
|
+
enumerable,
|
|
127
|
+
writable: true,
|
|
128
|
+
configurable: true
|
|
129
|
+
});
|
|
130
|
+
};
|
|
131
|
+
var isPrimitive = (value) => value === null || typeof value !== "object" && typeof value !== "function";
|
|
132
|
+
var redactPrimitive = (value, values) => {
|
|
133
|
+
if (typeof value === "string") return redactSensitiveValues(value, values);
|
|
134
|
+
if (value === null || value === void 0) return value;
|
|
135
|
+
const text = String(value);
|
|
136
|
+
const redacted = redactSensitiveValues(text, values);
|
|
137
|
+
return redacted === text ? value : redacted;
|
|
138
|
+
};
|
|
139
|
+
var redactJson = (value, values, ancestors, depth) => {
|
|
140
|
+
if (typeof value !== "object" || value === null) return typeof value === "function" || typeof value === "symbol" || typeof value === "bigint" ? void 0 : redactPrimitive(value, values);
|
|
141
|
+
if (ancestors.has(value)) return;
|
|
142
|
+
if (depth >= 256) throw new RangeError("The data is nested too deeply to copy.");
|
|
143
|
+
ancestors.add(value);
|
|
144
|
+
try {
|
|
145
|
+
const entries = readDataEntries(value);
|
|
146
|
+
if (Array.isArray(value)) {
|
|
147
|
+
const copy = [];
|
|
148
|
+
for (const [key, item] of entries) if (ARRAY_INDEX.test(key)) copy[Number(key)] = redactJson(item, values, ancestors, depth + 1) ?? null;
|
|
149
|
+
return copy;
|
|
150
|
+
}
|
|
151
|
+
const copy = {};
|
|
152
|
+
for (const [key, item] of entries) {
|
|
153
|
+
const redacted = redactJson(item, values, ancestors, depth + 1);
|
|
154
|
+
if (redacted !== void 0) defineValue(copy, key, redacted, true);
|
|
155
|
+
}
|
|
156
|
+
return copy;
|
|
157
|
+
} finally {
|
|
158
|
+
ancestors.delete(value);
|
|
159
|
+
}
|
|
160
|
+
};
|
|
161
|
+
var redactData = (data, values) => {
|
|
162
|
+
try {
|
|
163
|
+
return redactJson(data, values, new Set(), 0);
|
|
164
|
+
} catch {
|
|
165
|
+
return null;
|
|
166
|
+
}
|
|
167
|
+
};
|
|
168
|
+
var createSnapshot = (cause, context, depth) => {
|
|
169
|
+
const { values, exceptionClass, snapshots } = context;
|
|
170
|
+
const isRecognisedException = readProperty(cause, EXCEPTION_BRAND, false) === true;
|
|
171
|
+
const message = readProperty(cause, "message", false);
|
|
172
|
+
const snapshot = Reflect.construct(Error, [typeof message === "string" ? redactSensitiveValues(message, values) : ""], isRecognisedException ? exceptionClass : Error);
|
|
173
|
+
snapshots.set(cause, snapshot);
|
|
174
|
+
const name = readProperty(cause, "name", true);
|
|
175
|
+
defineValue(snapshot, "name", typeof name === "string" ? redactSensitiveValues(name, values) : "Error", false);
|
|
176
|
+
const stack = readProperty(cause, "stack", true);
|
|
177
|
+
if (typeof stack === "string") defineValue(snapshot, "stack", redactSensitiveValues(stack, values), false);
|
|
178
|
+
else Reflect.deleteProperty(snapshot, "stack");
|
|
179
|
+
for (const [key, value] of readDataEntries(cause)) if (!(BUILT_PROPERTIES.has(key) || isRecognisedException && key === "data") && isPrimitive(value)) defineValue(snapshot, key, isRecognisedException && VERBATIM_EXCEPTION_PROPERTIES.has(key) ? value : redactPrimitive(value, values), true);
|
|
180
|
+
if (isRecognisedException) {
|
|
181
|
+
Object.defineProperty(snapshot, EXCEPTION_BRAND, { value: true });
|
|
182
|
+
const data = readProperty(cause, "data", false);
|
|
183
|
+
defineValue(snapshot, "data", data === void 0 ? void 0 : redactData(data, values), true);
|
|
184
|
+
}
|
|
185
|
+
let hasCause;
|
|
186
|
+
try {
|
|
187
|
+
hasCause = Reflect.getOwnPropertyDescriptor(cause, "cause") !== void 0;
|
|
188
|
+
} catch {
|
|
189
|
+
hasCause = false;
|
|
190
|
+
}
|
|
191
|
+
if (hasCause && depth < 256) defineValue(snapshot, "cause", redactCause(readProperty(cause, "cause", false), context, depth + 1), false);
|
|
192
|
+
return snapshot;
|
|
193
|
+
};
|
|
194
|
+
var redactCause = (cause, context, depth) => {
|
|
195
|
+
if (isPrimitive(cause)) return redactPrimitive(cause, context.values);
|
|
196
|
+
if (context.snapshots.has(cause)) return context.snapshots.get(cause);
|
|
197
|
+
return createSnapshot(cause, context, depth);
|
|
198
|
+
};
|
|
199
|
+
var toRedactionValues = (redact) => {
|
|
200
|
+
const values = new Set();
|
|
201
|
+
try {
|
|
202
|
+
for (const value of Array.isArray(redact) ? redact : []) if (typeof value === "string" && value.length > 0) {
|
|
203
|
+
values.add(value);
|
|
204
|
+
try {
|
|
205
|
+
values.add(encodeURIComponent(value));
|
|
206
|
+
} catch {}
|
|
207
|
+
}
|
|
208
|
+
} catch {}
|
|
209
|
+
return [...values];
|
|
210
|
+
};
|
|
211
|
+
var redactExceptionParts = (parts, redact, exceptionClass) => {
|
|
212
|
+
const values = toRedactionValues(redact);
|
|
213
|
+
if (values.length === 0) return parts;
|
|
214
|
+
let message;
|
|
215
|
+
try {
|
|
216
|
+
message = redactSensitiveValues(new Error(parts.message).message, values);
|
|
217
|
+
} catch {
|
|
218
|
+
message = "";
|
|
219
|
+
}
|
|
220
|
+
return {
|
|
221
|
+
message,
|
|
222
|
+
data: parts.data === void 0 ? void 0 : redactData(parts.data, values),
|
|
223
|
+
cause: redactCause(parts.cause, {
|
|
224
|
+
values,
|
|
225
|
+
exceptionClass,
|
|
226
|
+
snapshots: new Map()
|
|
227
|
+
}, 1)
|
|
228
|
+
};
|
|
229
|
+
};
|
|
230
|
+
//#endregion
|
|
231
|
+
//#region ../../node_modules/.pnpm/jg-exception@1.7.1/node_modules/jg-exception/dist/exception/exception.js
|
|
232
|
+
var toSerializableData = (data) => {
|
|
233
|
+
try {
|
|
234
|
+
const serialized = stringifyWithinDepth(data);
|
|
235
|
+
return serialized === void 0 ? null : JSON.parse(serialized);
|
|
236
|
+
} catch {
|
|
237
|
+
return null;
|
|
238
|
+
}
|
|
239
|
+
};
|
|
240
|
+
var isExceptionSeverity = (value) => EXCEPTION_SEVERITIES.includes(value);
|
|
241
|
+
var Exception = class Exception extends Error {
|
|
242
|
+
code;
|
|
243
|
+
data;
|
|
244
|
+
constructor(message, options) {
|
|
245
|
+
const { code, data, cause, redact, severity, shouldLog } = options ?? { code: "" };
|
|
246
|
+
const parts = redactExceptionParts({
|
|
247
|
+
message,
|
|
248
|
+
data,
|
|
249
|
+
cause
|
|
250
|
+
}, redact, Exception);
|
|
251
|
+
super(parts.message, parts.cause === void 0 ? void 0 : { cause: parts.cause });
|
|
252
|
+
this.name = "Exception";
|
|
253
|
+
this.code = typeof code === "string" && code.length > 0 ? code : UNKNOWN_ERROR_CODE;
|
|
254
|
+
this.data = parts.data;
|
|
255
|
+
if (isExceptionSeverity(severity)) this.severity = severity;
|
|
256
|
+
if (shouldLog === true) this.shouldLog = true;
|
|
257
|
+
Object.defineProperty(this, EXCEPTION_BRAND, { value: true });
|
|
258
|
+
}
|
|
259
|
+
toJSON() {
|
|
260
|
+
return {
|
|
261
|
+
name: this.name,
|
|
262
|
+
code: this.code,
|
|
263
|
+
message: this.message,
|
|
264
|
+
data: toSerializableData(this.data)
|
|
265
|
+
};
|
|
266
|
+
}
|
|
267
|
+
toString() {
|
|
268
|
+
return `${this.name} [${this.code}]: ${this.message}`;
|
|
269
|
+
}
|
|
270
|
+
};
|
|
271
|
+
//#endregion
|
|
272
|
+
//#region ../../node_modules/.pnpm/jg-utilities@1.7.2/node_modules/jg-utilities/dist/shared/errors.js
|
|
273
|
+
var ERRORS = {
|
|
274
|
+
MIXED_OR_UNSUPPORTED_DATA_TYPES: "MIXED_OR_UNSUPPORTED_DATA_TYPES",
|
|
275
|
+
UNSUPPORTED_DATA_TYPE: "UNSUPPORTED_DATA_TYPE",
|
|
276
|
+
INVALID_OR_EMPTY_ARRAY: "INVALID_OR_EMPTY_ARRAY",
|
|
277
|
+
INVALID_OR_EMPTY_OBJECT: "INVALID_OR_EMPTY_OBJECT",
|
|
278
|
+
UNABLE_TO_SERIALIZE_JSON: "UNABLE_TO_SERIALIZE_JSON",
|
|
279
|
+
UNABLE_TO_DESERIALIZE_JSON: "UNABLE_TO_DESERIALIZE_JSON",
|
|
280
|
+
INVALID_BATCH_SIZE: "INVALID_BATCH_SIZE",
|
|
281
|
+
UNABLE_TO_SLUGIFY_STRING: "UNABLE_TO_SLUGIFY_STRING",
|
|
282
|
+
INVALID_TIME_STRING: "INVALID_TIME_STRING",
|
|
283
|
+
INVALID_AUTHORIZATION_HEADER: "INVALID_AUTHORIZATION_HEADER",
|
|
284
|
+
INVALID_EMAIL_ADDRESS: "INVALID_EMAIL_ADDRESS",
|
|
285
|
+
INVALID_BASE64URL: "INVALID_BASE64URL",
|
|
286
|
+
WAIT_UNTIL_TIMED_OUT: "WAIT_UNTIL_TIMED_OUT",
|
|
287
|
+
INVALID_CURSOR: "INVALID_CURSOR",
|
|
288
|
+
INVALID_DATE: "INVALID_DATE",
|
|
289
|
+
INVALID_DAY_COUNT: "INVALID_DAY_COUNT",
|
|
290
|
+
INVALID_DATE_RANGE: "INVALID_DATE_RANGE",
|
|
291
|
+
INVALID_BYTE_LIMIT: "INVALID_BYTE_LIMIT",
|
|
292
|
+
INVALID_YOUTUBE_VIDEO_ID: "INVALID_YOUTUBE_VIDEO_ID",
|
|
293
|
+
INVALID_CONCURRENCY_LIMIT: "INVALID_CONCURRENCY_LIMIT",
|
|
294
|
+
INVALID_QUEUE_LIMIT: "INVALID_QUEUE_LIMIT",
|
|
295
|
+
REQUEST_QUEUE_FULL: "REQUEST_QUEUE_FULL",
|
|
296
|
+
REQUEST_COOLDOWN_ACTIVE: "REQUEST_COOLDOWN_ACTIVE",
|
|
297
|
+
REQUEST_COORDINATOR_CLOSED: "REQUEST_COORDINATOR_CLOSED",
|
|
298
|
+
CURSOR_TOO_LONG: "CURSOR_TOO_LONG",
|
|
299
|
+
TASK_RUNNER_CLOSED: "TASK_RUNNER_CLOSED",
|
|
300
|
+
TASK_RUNNER_BUSY: "TASK_RUNNER_BUSY",
|
|
301
|
+
DEADLINE_EXCEEDED: "DEADLINE_EXCEEDED",
|
|
302
|
+
INVALID_DEADLINE: "INVALID_DEADLINE",
|
|
303
|
+
INVALID_MARKED_REGION: "INVALID_MARKED_REGION"
|
|
304
|
+
};
|
|
305
|
+
//#endregion
|
|
306
|
+
//#region ../../node_modules/.pnpm/jg-utilities@1.7.2/node_modules/jg-utilities/dist/validations/validations.js
|
|
307
|
+
var isNumberValid = (value, min = Number.MIN_SAFE_INTEGER, max = Number.MAX_SAFE_INTEGER) => typeof value === "number" && value >= min && value <= max;
|
|
308
|
+
var isIntegerValid = (value, min, max) => isNumberValid(value, min, max) && Number.isInteger(value);
|
|
309
|
+
var isObjectValid = (value, allowEmpty) => value !== null && typeof value === "object" && !Array.isArray(value) && (allowEmpty || Object.keys(value).length > 0);
|
|
310
|
+
var isArrayValid = (value, allowEmpty) => Array.isArray(value) && (allowEmpty || value.length > 0);
|
|
311
|
+
//#endregion
|
|
312
|
+
//#region ../../node_modules/.pnpm/jg-utilities@1.7.2/node_modules/jg-utilities/dist/transformers/validations.js
|
|
313
|
+
var canJsonBeSerialized = (value) => {
|
|
314
|
+
if (!isObjectValid(value, true) && !isArrayValid(value, true)) throw new Exception(`The JSON value must be an object or an array in order to be stringified. Received: ${String(value)}`, { code: ERRORS.UNSUPPORTED_DATA_TYPE });
|
|
315
|
+
};
|
|
316
|
+
var validateJsonSerializationResult = (value, result) => {
|
|
317
|
+
if (typeof result !== "string" || !result.length) throw new Exception(`Stringifying the JSON value '${String(value)}' produced an invalid result: ${String(result)}.`, { code: ERRORS.UNABLE_TO_SERIALIZE_JSON });
|
|
318
|
+
};
|
|
319
|
+
var validateByteLimit = (maxBytes) => {
|
|
320
|
+
if (!Number.isSafeInteger(maxBytes) || maxBytes < 0) throw new Exception("The byte limit must be a non-negative safe integer.", {
|
|
321
|
+
code: ERRORS.INVALID_BYTE_LIMIT,
|
|
322
|
+
data: { maxBytes: String(maxBytes) }
|
|
323
|
+
});
|
|
324
|
+
};
|
|
325
|
+
//#endregion
|
|
326
|
+
//#region ../../node_modules/.pnpm/jg-utilities@1.7.2/node_modules/jg-utilities/dist/transformers/json.js
|
|
327
|
+
var formatJsonPath = (path) => path.reduce((formatted, step) => {
|
|
328
|
+
if (typeof step === "number") return `${formatted}[${step}]`;
|
|
329
|
+
return /^[A-Za-z_$][\w$]*$/.test(step) ? `${formatted}.${step}` : `${formatted}[${JSON.stringify(step)}]`;
|
|
330
|
+
}, "$");
|
|
331
|
+
var throwUnserializable = (path, problem) => {
|
|
332
|
+
throw new Exception(`Failed to stringify the JSON value deterministically: the value at ${formatJsonPath(path)} ${problem}.`, { code: ERRORS.UNABLE_TO_SERIALIZE_JSON });
|
|
333
|
+
};
|
|
334
|
+
var toJsonInput = (value, key) => {
|
|
335
|
+
const converted = typeof value === "object" && value !== null && typeof value.toJSON === "function" ? value.toJSON(key) : value;
|
|
336
|
+
if (converted instanceof Number) return Number(converted);
|
|
337
|
+
if (converted instanceof String || converted instanceof Boolean) return converted.valueOf();
|
|
338
|
+
return converted;
|
|
339
|
+
};
|
|
340
|
+
var serializeSorted = (value, strict, ancestors, path) => {
|
|
341
|
+
switch (typeof value) {
|
|
342
|
+
case "string":
|
|
343
|
+
case "boolean": return JSON.stringify(value);
|
|
344
|
+
case "number":
|
|
345
|
+
if (strict && !Number.isFinite(value)) throwUnserializable(path, `is ${String(value)}, which JSON can't hold`);
|
|
346
|
+
return JSON.stringify(value);
|
|
347
|
+
case "bigint": return throwUnserializable(path, "is a BigInt, which JSON can't hold");
|
|
348
|
+
case "undefined":
|
|
349
|
+
case "function":
|
|
350
|
+
case "symbol": return strict ? throwUnserializable(path, `is ${typeof value}`) : void 0;
|
|
351
|
+
}
|
|
352
|
+
if (value === null) return "null";
|
|
353
|
+
const container = value;
|
|
354
|
+
if (ancestors.has(container)) throwUnserializable(path, "refers back to an object that contains it");
|
|
355
|
+
const isArray = Array.isArray(container);
|
|
356
|
+
if (strict && !isArray) {
|
|
357
|
+
const prototype = Object.getPrototypeOf(container);
|
|
358
|
+
if (prototype !== Object.prototype && prototype !== null) throwUnserializable(path, "is not a plain object");
|
|
359
|
+
if (Object.getOwnPropertySymbols(container).length > 0) throwUnserializable(path, "has a symbol key");
|
|
360
|
+
}
|
|
361
|
+
ancestors.add(container);
|
|
362
|
+
const parts = [];
|
|
363
|
+
if (isArray) for (let index = 0; index < container.length; index += 1) {
|
|
364
|
+
if (strict && !Object.hasOwn(container, index)) throwUnserializable([...path, index], "is a hole in the array");
|
|
365
|
+
path.push(index);
|
|
366
|
+
const item = strict ? container[index] : toJsonInput(container[index], String(index));
|
|
367
|
+
parts.push(serializeSorted(item, strict, ancestors, path) ?? "null");
|
|
368
|
+
path.pop();
|
|
369
|
+
}
|
|
370
|
+
else {
|
|
371
|
+
const record = container;
|
|
372
|
+
for (const key of Object.keys(record).sort()) {
|
|
373
|
+
path.push(key);
|
|
374
|
+
const serialized = serializeSorted(strict ? record[key] : toJsonInput(record[key], key), strict, ancestors, path);
|
|
375
|
+
if (serialized !== void 0) parts.push(`${JSON.stringify(key)}:${serialized}`);
|
|
376
|
+
path.pop();
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
ancestors.delete(container);
|
|
380
|
+
return isArray ? `[${parts.join(",")}]` : `{${parts.join(",")}}`;
|
|
381
|
+
};
|
|
382
|
+
var stringifyJsonDeterministically = (value, { strict = false } = {}) => {
|
|
383
|
+
canJsonBeSerialized(value);
|
|
384
|
+
try {
|
|
385
|
+
const serialized = serializeSorted(strict ? value : toJsonInput(value, ""), strict, new Set(), []);
|
|
386
|
+
validateJsonSerializationResult(value, serialized);
|
|
387
|
+
return serialized;
|
|
388
|
+
} catch (error) {
|
|
389
|
+
if (getErrorCode(error) !== ERRORS.UNABLE_TO_SERIALIZE_JSON) throw new Exception(`Failed to stringify the JSON value deterministically '${String(value)}'.`, {
|
|
390
|
+
code: ERRORS.UNABLE_TO_SERIALIZE_JSON,
|
|
391
|
+
cause: error
|
|
392
|
+
});
|
|
393
|
+
throw error;
|
|
394
|
+
}
|
|
395
|
+
};
|
|
396
|
+
var MAX_MEASURED_JSON_DEPTH = 64;
|
|
397
|
+
var SHORT_JSON_ESCAPES = new Set([
|
|
398
|
+
8,
|
|
399
|
+
9,
|
|
400
|
+
10,
|
|
401
|
+
12,
|
|
402
|
+
13,
|
|
403
|
+
34,
|
|
404
|
+
92
|
|
405
|
+
]);
|
|
406
|
+
var measureJsonString = (text, maxBytes) => {
|
|
407
|
+
let bytes = 2;
|
|
408
|
+
for (let index = 0; index < text.length && bytes <= maxBytes; index += 1) {
|
|
409
|
+
const code = text.charCodeAt(index);
|
|
410
|
+
if (SHORT_JSON_ESCAPES.has(code)) bytes += 2;
|
|
411
|
+
else if (code < 32) bytes += 6;
|
|
412
|
+
else if (code < 128) bytes += 1;
|
|
413
|
+
else if (code < 2048) bytes += 2;
|
|
414
|
+
else if (code >= 55296 && code <= 56319 && (text.charCodeAt(index + 1) & 64512) === 56320) {
|
|
415
|
+
bytes += 4;
|
|
416
|
+
index += 1;
|
|
417
|
+
} else bytes += code >= 55296 && code <= 57343 ? 6 : 3;
|
|
418
|
+
}
|
|
419
|
+
return bytes;
|
|
420
|
+
};
|
|
421
|
+
var measureJsonValue = (value, maxBytes, ancestors, depth) => {
|
|
422
|
+
if (depth > MAX_MEASURED_JSON_DEPTH) throw new Exception(`The value is nested more than ${MAX_MEASURED_JSON_DEPTH} levels deep.`, { code: ERRORS.UNABLE_TO_SERIALIZE_JSON });
|
|
423
|
+
switch (typeof value) {
|
|
424
|
+
case "string": return measureJsonString(value, maxBytes);
|
|
425
|
+
case "number": return Number.isFinite(value) ? String(value).length : 4;
|
|
426
|
+
case "boolean": return value ? 4 : 5;
|
|
427
|
+
case "bigint": throw new Exception("The value holds a BigInt, which JSON can't hold.", { code: ERRORS.UNABLE_TO_SERIALIZE_JSON });
|
|
428
|
+
case "undefined":
|
|
429
|
+
case "function":
|
|
430
|
+
case "symbol": return;
|
|
431
|
+
}
|
|
432
|
+
if (value === null) return 4;
|
|
433
|
+
const container = value;
|
|
434
|
+
if (ancestors.has(container)) throw new Exception("The value refers back to an object that contains it.", { code: ERRORS.UNABLE_TO_SERIALIZE_JSON });
|
|
435
|
+
ancestors.add(container);
|
|
436
|
+
let bytes = 2;
|
|
437
|
+
let count = 0;
|
|
438
|
+
if (Array.isArray(container)) for (let index = 0; index < container.length && bytes <= maxBytes; index += 1) {
|
|
439
|
+
const item = toJsonInput(container[index], String(index));
|
|
440
|
+
bytes += (count === 0 ? 0 : 1) + (measureJsonValue(item, maxBytes, ancestors, depth + 1) ?? 4);
|
|
441
|
+
count += 1;
|
|
442
|
+
}
|
|
443
|
+
else {
|
|
444
|
+
const record = container;
|
|
445
|
+
for (const key of Object.keys(record)) {
|
|
446
|
+
if (bytes > maxBytes) break;
|
|
447
|
+
const item = measureJsonValue(toJsonInput(record[key], key), maxBytes, ancestors, depth + 1);
|
|
448
|
+
if (item !== void 0) {
|
|
449
|
+
bytes += (count === 0 ? 0 : 1) + measureJsonString(key, maxBytes) + 1 + item;
|
|
450
|
+
count += 1;
|
|
451
|
+
}
|
|
452
|
+
}
|
|
453
|
+
}
|
|
454
|
+
ancestors.delete(container);
|
|
455
|
+
return bytes;
|
|
456
|
+
};
|
|
457
|
+
var measureJsonBytes = (value, maxBytes) => {
|
|
458
|
+
validateByteLimit(maxBytes);
|
|
459
|
+
let bytes;
|
|
460
|
+
try {
|
|
461
|
+
bytes = measureJsonValue(toJsonInput(value, ""), maxBytes, new Set(), 0);
|
|
462
|
+
} catch (error) {
|
|
463
|
+
if (getErrorCode(error) === ERRORS.UNABLE_TO_SERIALIZE_JSON) throw error;
|
|
464
|
+
throw new Exception("Failed to measure the JSON value.", {
|
|
465
|
+
code: ERRORS.UNABLE_TO_SERIALIZE_JSON,
|
|
466
|
+
cause: error
|
|
467
|
+
});
|
|
468
|
+
}
|
|
469
|
+
if (bytes === void 0) throw new Exception(`JSON.stringify writes nothing for ${typeof value} values.`, { code: ERRORS.UNABLE_TO_SERIALIZE_JSON });
|
|
470
|
+
return bytes;
|
|
471
|
+
};
|
|
472
|
+
//#endregion
|
|
473
|
+
//#region ../core/dist/chunks/exceptions-AT654xUL.js
|
|
474
|
+
var CORE_OPERATIONS = [
|
|
475
|
+
"create-core",
|
|
476
|
+
"normalize-text",
|
|
477
|
+
"calculate-content-digest",
|
|
478
|
+
"parse-manifest",
|
|
479
|
+
"match-manifest-scope",
|
|
480
|
+
"parse-decision",
|
|
481
|
+
"create-project-inspection",
|
|
482
|
+
"read-canonical-content-page",
|
|
483
|
+
"validate-project"
|
|
484
|
+
];
|
|
485
|
+
var CONFIGURATION_ERROR_MESSAGES = { INVALID_RESOURCE_LIMIT: "A Core resource limit is invalid." };
|
|
486
|
+
var OPERATION_ERROR_MESSAGES = {
|
|
487
|
+
ABORTED: "The Core operation was aborted.",
|
|
488
|
+
CONTENT_INVALID: "The canonical content is not valid UTF-8 text.",
|
|
489
|
+
INVALID_ARGUMENT: "The Core operation received an invalid argument.",
|
|
490
|
+
INSPECTION_BUSY: "Project inspection capacity is busy. Try again shortly.",
|
|
491
|
+
INSPECTION_TIMEOUT: "The isolated project inspection timed out.",
|
|
492
|
+
INSPECTION_PROCESS_FAILED: "The isolated project inspection failed.",
|
|
493
|
+
RESOURCE_LIMIT_EXCEEDED: "A Core resource limit was exceeded."
|
|
494
|
+
};
|
|
495
|
+
var OPERATION_ERROR_RETRYABILITY = {
|
|
496
|
+
ABORTED: true,
|
|
497
|
+
CONTENT_INVALID: false,
|
|
498
|
+
INVALID_ARGUMENT: false,
|
|
499
|
+
INSPECTION_BUSY: true,
|
|
500
|
+
INSPECTION_TIMEOUT: true,
|
|
501
|
+
INSPECTION_PROCESS_FAILED: false,
|
|
502
|
+
RESOURCE_LIMIT_EXCEEDED: false
|
|
503
|
+
};
|
|
504
|
+
var isCoreOperation = (input) => CORE_OPERATIONS.some((operation) => operation === input);
|
|
505
|
+
var isCoreConfigurationErrorCode = (input) => typeof input === "string" && Object.hasOwn(CONFIGURATION_ERROR_MESSAGES, input);
|
|
506
|
+
var isCoreOperationErrorCode = (input) => typeof input === "string" && Object.hasOwn(OPERATION_ERROR_MESSAGES, input);
|
|
507
|
+
var CoreConfigurationException = class extends Exception {
|
|
508
|
+
code;
|
|
509
|
+
operation;
|
|
510
|
+
constructor(options) {
|
|
511
|
+
super(CONFIGURATION_ERROR_MESSAGES[options.code], {
|
|
512
|
+
code: options.code,
|
|
513
|
+
cause: options.cause
|
|
514
|
+
});
|
|
515
|
+
this.code = options.code;
|
|
516
|
+
this.name = "CoreConfigurationException";
|
|
517
|
+
this.operation = options.operation;
|
|
518
|
+
}
|
|
519
|
+
};
|
|
520
|
+
var CoreOperationException = class extends Exception {
|
|
521
|
+
code;
|
|
522
|
+
operation;
|
|
523
|
+
retryable;
|
|
524
|
+
limit;
|
|
525
|
+
limitMaximum;
|
|
526
|
+
nextAction;
|
|
527
|
+
observedUsage;
|
|
528
|
+
constructor(options) {
|
|
529
|
+
super(OPERATION_ERROR_MESSAGES[options.code], {
|
|
530
|
+
code: options.code,
|
|
531
|
+
cause: options.cause
|
|
532
|
+
});
|
|
533
|
+
this.code = options.code;
|
|
534
|
+
this.name = "CoreOperationException";
|
|
535
|
+
this.operation = options.operation;
|
|
536
|
+
this.retryable = OPERATION_ERROR_RETRYABILITY[options.code];
|
|
537
|
+
this.limit = options.limit ?? null;
|
|
538
|
+
this.limitMaximum = options.limitMaximum ?? null;
|
|
539
|
+
this.nextAction = options.nextAction ?? null;
|
|
540
|
+
this.observedUsage = options.observedUsage ?? null;
|
|
541
|
+
}
|
|
542
|
+
};
|
|
543
|
+
//#endregion
|
|
544
|
+
export { isCoreOperationErrorCode as a, validateByteLimit as c, ERRORS as d, Exception as f, isCoreOperation as i, isIntegerValid as l, hasErrorCode as m, CoreOperationException as n, measureJsonBytes as o, getErrorCode as p, isCoreConfigurationErrorCode as r, stringifyJsonDeterministically as s, CoreConfigurationException as t, isObjectValid as u };
|