@tryarcanist/cli 0.1.80 → 0.1.81
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/index.js +39 -16
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -200,7 +200,7 @@ function validateApiUrl(url) {
|
|
|
200
200
|
// src/runtime.ts
|
|
201
201
|
import { randomUUID } from "crypto";
|
|
202
202
|
import { createInterface } from "readline/promises";
|
|
203
|
-
var ANSI_CONTROL_SEQUENCE = /\u001b\[[0-9
|
|
203
|
+
var ANSI_CONTROL_SEQUENCE = /\u001b\[[0-9:;<=>?]*[ -/]*[@-~]/g;
|
|
204
204
|
function getRuntimeOptions(command, options = {}) {
|
|
205
205
|
const globals = command?.optsWithGlobals?.();
|
|
206
206
|
const merged = { ...globals, ...options };
|
|
@@ -434,6 +434,27 @@ function validateUploadedName(name, kind) {
|
|
|
434
434
|
function trimNamedItems(items) {
|
|
435
435
|
return items.map((item) => ({ ...item, name: item.name.trim() }));
|
|
436
436
|
}
|
|
437
|
+
function validateUploadItems({
|
|
438
|
+
items,
|
|
439
|
+
existingNames = [],
|
|
440
|
+
kind,
|
|
441
|
+
max,
|
|
442
|
+
label,
|
|
443
|
+
normalizeItems,
|
|
444
|
+
validateItem
|
|
445
|
+
}) {
|
|
446
|
+
const normalized = normalizeItems ? normalizeItems(items) : [...items];
|
|
447
|
+
const deduped = deduplicateByName(normalized, existingNames);
|
|
448
|
+
const capacityError = checkUploadCapacity(existingNames.length, deduped.length, max, label);
|
|
449
|
+
if (capacityError) return fail(capacityError);
|
|
450
|
+
for (const item of deduped) {
|
|
451
|
+
const nameError = validateUploadedName(item.name, kind);
|
|
452
|
+
if (nameError) return fail(nameError);
|
|
453
|
+
const itemError = validateItem(item);
|
|
454
|
+
if (itemError) return fail(itemError);
|
|
455
|
+
}
|
|
456
|
+
return ok(deduped);
|
|
457
|
+
}
|
|
437
458
|
function hasNullBytes(content) {
|
|
438
459
|
return content.slice(0, 8192).includes("\0");
|
|
439
460
|
}
|
|
@@ -455,22 +476,24 @@ function deduplicateByName(items, existingNames = []) {
|
|
|
455
476
|
return deduped;
|
|
456
477
|
}
|
|
457
478
|
function validateUploadedFilePayload(files, existingNames = []) {
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
479
|
+
return validateUploadItems({
|
|
480
|
+
items: files,
|
|
481
|
+
existingNames,
|
|
482
|
+
kind: "file",
|
|
483
|
+
max: MAX_UPLOADED_FILES,
|
|
484
|
+
label: "uploaded files",
|
|
485
|
+
normalizeItems: trimNamedItems,
|
|
486
|
+
validateItem: (file) => {
|
|
487
|
+
const byteLength = new TextEncoder().encode(file.content).byteLength;
|
|
488
|
+
if (byteLength > MAX_UPLOADED_FILE_SIZE_BYTES) {
|
|
489
|
+
return `Uploaded file too large: ${file.name} (${byteLength} bytes, max ${MAX_UPLOADED_FILE_SIZE_BYTES})`;
|
|
490
|
+
}
|
|
491
|
+
if (hasNullBytes(file.content)) {
|
|
492
|
+
return `Binary files are not supported: ${file.name}`;
|
|
493
|
+
}
|
|
494
|
+
return null;
|
|
471
495
|
}
|
|
472
|
-
}
|
|
473
|
-
return ok(deduped);
|
|
496
|
+
});
|
|
474
497
|
}
|
|
475
498
|
|
|
476
499
|
// src/uploads.ts
|