@resourcexjs/cli 2.7.0 → 2.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +1294 -1223
- package/dist/index.js.map +18 -18
- package/package.json +5 -5
package/dist/index.js
CHANGED
|
@@ -770,249 +770,614 @@ var init_prompt = __esm(() => {
|
|
|
770
770
|
});
|
|
771
771
|
|
|
772
772
|
// ../../packages/core/dist/index.js
|
|
773
|
-
import { gzip } from "zlib";
|
|
774
773
|
import { promisify } from "util";
|
|
775
|
-
import {
|
|
774
|
+
import { gzip } from "zlib";
|
|
776
775
|
import { promisify as promisify2 } from "util";
|
|
776
|
+
import { gunzip } from "zlib";
|
|
777
|
+
import { readdir, readFile, stat } from "fs/promises";
|
|
777
778
|
import { join, relative } from "path";
|
|
778
|
-
import {
|
|
779
|
+
import { readdir as readdir2, readFile as readFile2, stat as stat2 } from "fs/promises";
|
|
780
|
+
import { join as join2, relative as relative2 } from "path";
|
|
779
781
|
import { createHash } from "crypto";
|
|
780
|
-
function
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
Object.defineProperty(inst, "_zod", {
|
|
784
|
-
value: {
|
|
785
|
-
def,
|
|
786
|
-
constr: _3,
|
|
787
|
-
traits: new Set
|
|
788
|
-
},
|
|
789
|
-
enumerable: false
|
|
790
|
-
});
|
|
791
|
-
}
|
|
792
|
-
if (inst._zod.traits.has(name)) {
|
|
793
|
-
return;
|
|
794
|
-
}
|
|
795
|
-
inst._zod.traits.add(name);
|
|
796
|
-
initializer(inst, def);
|
|
797
|
-
const proto = _3.prototype;
|
|
798
|
-
const keys = Object.keys(proto);
|
|
799
|
-
for (let i2 = 0;i2 < keys.length; i2++) {
|
|
800
|
-
const k2 = keys[i2];
|
|
801
|
-
if (!(k2 in inst)) {
|
|
802
|
-
inst[k2] = proto[k2].bind(inst);
|
|
803
|
-
}
|
|
804
|
-
}
|
|
805
|
-
}
|
|
806
|
-
const Parent = params?.Parent ?? Object;
|
|
807
|
-
|
|
808
|
-
class Definition extends Parent {
|
|
809
|
-
}
|
|
810
|
-
Object.defineProperty(Definition, "name", { value: name });
|
|
811
|
-
function _3(def) {
|
|
812
|
-
var _a;
|
|
813
|
-
const inst = params?.Parent ? new Definition : this;
|
|
814
|
-
init2(inst, def);
|
|
815
|
-
(_a = inst._zod).deferred ?? (_a.deferred = []);
|
|
816
|
-
for (const fn of inst._zod.deferred) {
|
|
817
|
-
fn();
|
|
818
|
-
}
|
|
819
|
-
return inst;
|
|
820
|
-
}
|
|
821
|
-
Object.defineProperty(_3, "init", { value: init2 });
|
|
822
|
-
Object.defineProperty(_3, Symbol.hasInstance, {
|
|
823
|
-
value: (inst) => {
|
|
824
|
-
if (params?.Parent && inst instanceof params.Parent)
|
|
825
|
-
return true;
|
|
826
|
-
return inst?._zod?.traits?.has(name);
|
|
827
|
-
}
|
|
828
|
-
});
|
|
829
|
-
Object.defineProperty(_3, "name", { value: name });
|
|
830
|
-
return _3;
|
|
831
|
-
}
|
|
832
|
-
function config(newConfig) {
|
|
833
|
-
if (newConfig)
|
|
834
|
-
Object.assign(globalConfig, newConfig);
|
|
835
|
-
return globalConfig;
|
|
836
|
-
}
|
|
837
|
-
function assertEqual(val) {
|
|
838
|
-
return val;
|
|
839
|
-
}
|
|
840
|
-
function assertNotEqual(val) {
|
|
841
|
-
return val;
|
|
842
|
-
}
|
|
843
|
-
function assertIs(_arg) {}
|
|
844
|
-
function assertNever(_x) {
|
|
845
|
-
throw new Error("Unexpected value in exhaustive check");
|
|
782
|
+
function writeString(view, offset, size, value) {
|
|
783
|
+
if (value)
|
|
784
|
+
encoder.encodeInto(value, view.subarray(offset, offset + size));
|
|
846
785
|
}
|
|
847
|
-
function
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
const
|
|
851
|
-
|
|
786
|
+
function writeOctal(view, offset, size, value) {
|
|
787
|
+
if (value === undefined)
|
|
788
|
+
return;
|
|
789
|
+
const octalString = value.toString(8).padStart(size - 1, "0");
|
|
790
|
+
encoder.encodeInto(octalString, view.subarray(offset, offset + size - 1));
|
|
852
791
|
}
|
|
853
|
-
function
|
|
854
|
-
|
|
792
|
+
async function normalizeBody(body) {
|
|
793
|
+
if (body === null || body === undefined)
|
|
794
|
+
return EMPTY;
|
|
795
|
+
if (body instanceof Uint8Array)
|
|
796
|
+
return body;
|
|
797
|
+
if (typeof body === "string")
|
|
798
|
+
return encoder.encode(body);
|
|
799
|
+
if (body instanceof ArrayBuffer)
|
|
800
|
+
return new Uint8Array(body);
|
|
801
|
+
if (body instanceof Blob)
|
|
802
|
+
return new Uint8Array(await body.arrayBuffer());
|
|
803
|
+
throw new TypeError("Unsupported content type for entry body.");
|
|
855
804
|
}
|
|
856
|
-
function
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
805
|
+
function writeChecksum(block) {
|
|
806
|
+
block.fill(CHECKSUM_SPACE, USTAR_CHECKSUM_OFFSET, USTAR_CHECKSUM_OFFSET + USTAR_CHECKSUM_SIZE);
|
|
807
|
+
let checksum = 0;
|
|
808
|
+
for (const byte of block)
|
|
809
|
+
checksum += byte;
|
|
810
|
+
for (let i2 = USTAR_CHECKSUM_OFFSET + 6 - 1;i2 >= USTAR_CHECKSUM_OFFSET; i2--) {
|
|
811
|
+
block[i2] = (checksum & 7) + ASCII_ZERO;
|
|
812
|
+
checksum >>= 3;
|
|
813
|
+
}
|
|
814
|
+
block[USTAR_CHECKSUM_OFFSET + 6] = 0;
|
|
815
|
+
block[USTAR_CHECKSUM_OFFSET + 7] = CHECKSUM_SPACE;
|
|
860
816
|
}
|
|
861
|
-
function
|
|
862
|
-
const
|
|
817
|
+
function generatePax(header) {
|
|
818
|
+
const paxRecords = {};
|
|
819
|
+
if (header.name.length > USTAR_NAME_SIZE) {
|
|
820
|
+
if (findUstarSplit(header.name) === null)
|
|
821
|
+
paxRecords.path = header.name;
|
|
822
|
+
}
|
|
823
|
+
if (header.linkname && header.linkname.length > USTAR_NAME_SIZE)
|
|
824
|
+
paxRecords.linkpath = header.linkname;
|
|
825
|
+
if (header.uname && header.uname.length > USTAR_UNAME_SIZE)
|
|
826
|
+
paxRecords.uname = header.uname;
|
|
827
|
+
if (header.gname && header.gname.length > USTAR_GNAME_SIZE)
|
|
828
|
+
paxRecords.gname = header.gname;
|
|
829
|
+
if (header.uid != null && header.uid > USTAR_MAX_UID_GID)
|
|
830
|
+
paxRecords.uid = String(header.uid);
|
|
831
|
+
if (header.gid != null && header.gid > USTAR_MAX_UID_GID)
|
|
832
|
+
paxRecords.gid = String(header.gid);
|
|
833
|
+
if (header.size != null && header.size > USTAR_MAX_SIZE)
|
|
834
|
+
paxRecords.size = String(header.size);
|
|
835
|
+
if (header.pax)
|
|
836
|
+
Object.assign(paxRecords, header.pax);
|
|
837
|
+
const paxEntries = Object.entries(paxRecords);
|
|
838
|
+
if (paxEntries.length === 0)
|
|
839
|
+
return null;
|
|
840
|
+
const paxBody = encoder.encode(paxEntries.map(([key, value]) => {
|
|
841
|
+
const record = `${key}=${value}
|
|
842
|
+
`;
|
|
843
|
+
const partLength = encoder.encode(record).length + 1;
|
|
844
|
+
let totalLength = partLength + String(partLength).length;
|
|
845
|
+
totalLength = partLength + String(totalLength).length;
|
|
846
|
+
return `${totalLength} ${record}`;
|
|
847
|
+
}).join(""));
|
|
863
848
|
return {
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
849
|
+
paxHeader: createTarHeader({
|
|
850
|
+
name: decoder.decode(encoder.encode(`PaxHeader/${header.name}`).slice(0, 100)),
|
|
851
|
+
size: paxBody.length,
|
|
852
|
+
type: "pax-header",
|
|
853
|
+
mode: 420,
|
|
854
|
+
mtime: header.mtime,
|
|
855
|
+
uname: header.uname,
|
|
856
|
+
gname: header.gname,
|
|
857
|
+
uid: header.uid,
|
|
858
|
+
gid: header.gid
|
|
859
|
+
}),
|
|
860
|
+
paxBody
|
|
872
861
|
};
|
|
873
862
|
}
|
|
874
|
-
function
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
const
|
|
879
|
-
|
|
880
|
-
|
|
863
|
+
function findUstarSplit(path) {
|
|
864
|
+
if (path.length <= USTAR_NAME_SIZE)
|
|
865
|
+
return null;
|
|
866
|
+
const minSlashIndex = path.length - USTAR_NAME_SIZE - 1;
|
|
867
|
+
const slashIndex = path.lastIndexOf("/", USTAR_PREFIX_SIZE);
|
|
868
|
+
if (slashIndex > 0 && slashIndex >= minSlashIndex)
|
|
869
|
+
return {
|
|
870
|
+
prefix: path.slice(0, slashIndex),
|
|
871
|
+
name: path.slice(slashIndex + 1)
|
|
872
|
+
};
|
|
873
|
+
return null;
|
|
881
874
|
}
|
|
882
|
-
function
|
|
883
|
-
const
|
|
884
|
-
const
|
|
885
|
-
let
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
875
|
+
function createTarHeader(header) {
|
|
876
|
+
const view = new Uint8Array(BLOCK_SIZE);
|
|
877
|
+
const size = isBodyless(header) ? 0 : header.size ?? 0;
|
|
878
|
+
let name = header.name;
|
|
879
|
+
let prefix = "";
|
|
880
|
+
if (!header.pax?.path) {
|
|
881
|
+
const split = findUstarSplit(name);
|
|
882
|
+
if (split) {
|
|
883
|
+
name = split.name;
|
|
884
|
+
prefix = split.prefix;
|
|
890
885
|
}
|
|
891
886
|
}
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
887
|
+
writeString(view, USTAR_NAME_OFFSET, USTAR_NAME_SIZE, name);
|
|
888
|
+
writeOctal(view, USTAR_MODE_OFFSET, USTAR_MODE_SIZE, header.mode ?? (header.type === DIRECTORY ? DEFAULT_DIR_MODE : DEFAULT_FILE_MODE));
|
|
889
|
+
writeOctal(view, USTAR_UID_OFFSET, USTAR_UID_SIZE, header.uid ?? 0);
|
|
890
|
+
writeOctal(view, USTAR_GID_OFFSET, USTAR_GID_SIZE, header.gid ?? 0);
|
|
891
|
+
writeOctal(view, USTAR_SIZE_OFFSET, USTAR_SIZE_SIZE, size);
|
|
892
|
+
writeOctal(view, USTAR_MTIME_OFFSET, USTAR_MTIME_SIZE, Math.floor((header.mtime?.getTime() ?? Date.now()) / 1000));
|
|
893
|
+
writeString(view, USTAR_TYPEFLAG_OFFSET, USTAR_TYPEFLAG_SIZE, TYPEFLAG[header.type ?? FILE]);
|
|
894
|
+
writeString(view, USTAR_LINKNAME_OFFSET, USTAR_LINKNAME_SIZE, header.linkname);
|
|
895
|
+
writeString(view, USTAR_MAGIC_OFFSET, USTAR_MAGIC_SIZE, "ustar\x00");
|
|
896
|
+
writeString(view, USTAR_VERSION_OFFSET, USTAR_VERSION_SIZE, USTAR_VERSION);
|
|
897
|
+
writeString(view, USTAR_UNAME_OFFSET, USTAR_UNAME_SIZE, header.uname);
|
|
898
|
+
writeString(view, USTAR_GNAME_OFFSET, USTAR_GNAME_SIZE, header.gname);
|
|
899
|
+
writeString(view, USTAR_PREFIX_OFFSET, USTAR_PREFIX_SIZE, prefix);
|
|
900
|
+
writeChecksum(view);
|
|
901
|
+
return view;
|
|
896
902
|
}
|
|
897
|
-
function
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
+
function getHeaderBlocks(header) {
|
|
904
|
+
const base = createTarHeader(header);
|
|
905
|
+
const pax = generatePax(header);
|
|
906
|
+
if (!pax)
|
|
907
|
+
return [base];
|
|
908
|
+
const paxPadding = -pax.paxBody.length & BLOCK_SIZE_MASK;
|
|
909
|
+
const paddingBlocks = paxPadding > 0 ? [ZERO_BLOCK.subarray(0, paxPadding)] : [];
|
|
910
|
+
return [
|
|
911
|
+
pax.paxHeader,
|
|
912
|
+
pax.paxBody,
|
|
913
|
+
...paddingBlocks,
|
|
914
|
+
base
|
|
915
|
+
];
|
|
916
|
+
}
|
|
917
|
+
function createTarPacker(onData, onError, onFinalize) {
|
|
918
|
+
let currentHeader = null;
|
|
919
|
+
let bytesWritten = 0;
|
|
920
|
+
let finalized = false;
|
|
921
|
+
return {
|
|
922
|
+
add(header) {
|
|
923
|
+
if (finalized) {
|
|
924
|
+
const error = /* @__PURE__ */ new Error("No new tar entries after finalize.");
|
|
925
|
+
onError(error);
|
|
926
|
+
throw error;
|
|
903
927
|
}
|
|
904
|
-
if (
|
|
905
|
-
|
|
906
|
-
|
|
928
|
+
if (currentHeader !== null) {
|
|
929
|
+
const error = /* @__PURE__ */ new Error("Previous entry must be completed before adding a new one");
|
|
930
|
+
onError(error);
|
|
931
|
+
throw error;
|
|
932
|
+
}
|
|
933
|
+
try {
|
|
934
|
+
const size = isBodyless(header) ? 0 : header.size ?? 0;
|
|
935
|
+
const headerBlocks = getHeaderBlocks({
|
|
936
|
+
...header,
|
|
937
|
+
size
|
|
938
|
+
});
|
|
939
|
+
for (const block of headerBlocks)
|
|
940
|
+
onData(block);
|
|
941
|
+
currentHeader = {
|
|
942
|
+
...header,
|
|
943
|
+
size
|
|
944
|
+
};
|
|
945
|
+
bytesWritten = 0;
|
|
946
|
+
} catch (error) {
|
|
947
|
+
onError(error);
|
|
907
948
|
}
|
|
908
|
-
return value;
|
|
909
|
-
},
|
|
910
|
-
set(v2) {
|
|
911
|
-
Object.defineProperty(object, key, {
|
|
912
|
-
value: v2
|
|
913
|
-
});
|
|
914
949
|
},
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
950
|
+
write(chunk) {
|
|
951
|
+
if (!currentHeader) {
|
|
952
|
+
const error = /* @__PURE__ */ new Error("No active tar entry.");
|
|
953
|
+
onError(error);
|
|
954
|
+
throw error;
|
|
955
|
+
}
|
|
956
|
+
if (finalized) {
|
|
957
|
+
const error = /* @__PURE__ */ new Error("Cannot write data after finalize.");
|
|
958
|
+
onError(error);
|
|
959
|
+
throw error;
|
|
960
|
+
}
|
|
961
|
+
const newTotal = bytesWritten + chunk.length;
|
|
962
|
+
if (newTotal > currentHeader.size) {
|
|
963
|
+
const error = /* @__PURE__ */ new Error(`"${currentHeader.name}" exceeds given size of ${currentHeader.size} bytes.`);
|
|
964
|
+
onError(error);
|
|
965
|
+
throw error;
|
|
966
|
+
}
|
|
967
|
+
try {
|
|
968
|
+
bytesWritten = newTotal;
|
|
969
|
+
onData(chunk);
|
|
970
|
+
} catch (error) {
|
|
971
|
+
onError(error);
|
|
972
|
+
}
|
|
973
|
+
},
|
|
974
|
+
endEntry() {
|
|
975
|
+
if (!currentHeader) {
|
|
976
|
+
const error = /* @__PURE__ */ new Error("No active entry to end.");
|
|
977
|
+
onError(error);
|
|
978
|
+
throw error;
|
|
979
|
+
}
|
|
980
|
+
if (finalized) {
|
|
981
|
+
const error = /* @__PURE__ */ new Error("Cannot end entry after finalize.");
|
|
982
|
+
onError(error);
|
|
983
|
+
throw error;
|
|
984
|
+
}
|
|
985
|
+
try {
|
|
986
|
+
if (bytesWritten !== currentHeader.size) {
|
|
987
|
+
const error = /* @__PURE__ */ new Error(`Size mismatch for "${currentHeader.name}".`);
|
|
988
|
+
onError(error);
|
|
989
|
+
throw error;
|
|
990
|
+
}
|
|
991
|
+
const paddingSize = -currentHeader.size & BLOCK_SIZE_MASK;
|
|
992
|
+
if (paddingSize > 0)
|
|
993
|
+
onData(new Uint8Array(paddingSize));
|
|
994
|
+
currentHeader = null;
|
|
995
|
+
bytesWritten = 0;
|
|
996
|
+
} catch (error) {
|
|
997
|
+
onError(error);
|
|
998
|
+
throw error;
|
|
999
|
+
}
|
|
1000
|
+
},
|
|
1001
|
+
finalize() {
|
|
1002
|
+
if (finalized) {
|
|
1003
|
+
const error = /* @__PURE__ */ new Error("Archive has already been finalized");
|
|
1004
|
+
onError(error);
|
|
1005
|
+
throw error;
|
|
1006
|
+
}
|
|
1007
|
+
if (currentHeader !== null) {
|
|
1008
|
+
const error = /* @__PURE__ */ new Error("Cannot finalize while an entry is still active");
|
|
1009
|
+
onError(error);
|
|
1010
|
+
throw error;
|
|
1011
|
+
}
|
|
1012
|
+
try {
|
|
1013
|
+
onData(EOF_BUFFER);
|
|
1014
|
+
finalized = true;
|
|
1015
|
+
if (onFinalize)
|
|
1016
|
+
onFinalize();
|
|
1017
|
+
} catch (error) {
|
|
1018
|
+
onError(error);
|
|
1019
|
+
}
|
|
1020
|
+
}
|
|
1021
|
+
};
|
|
920
1022
|
}
|
|
921
|
-
function
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
1023
|
+
function createTarPacker2() {
|
|
1024
|
+
let streamController;
|
|
1025
|
+
let packer;
|
|
1026
|
+
return {
|
|
1027
|
+
readable: new ReadableStream({ start(controller) {
|
|
1028
|
+
streamController = controller;
|
|
1029
|
+
packer = createTarPacker(controller.enqueue.bind(controller), controller.error.bind(controller), controller.close.bind(controller));
|
|
1030
|
+
} }),
|
|
1031
|
+
controller: {
|
|
1032
|
+
add(header) {
|
|
1033
|
+
const bodyless = isBodyless(header);
|
|
1034
|
+
const h2 = { ...header };
|
|
1035
|
+
if (bodyless)
|
|
1036
|
+
h2.size = 0;
|
|
1037
|
+
packer.add(h2);
|
|
1038
|
+
if (bodyless)
|
|
1039
|
+
packer.endEntry();
|
|
1040
|
+
return new WritableStream({
|
|
1041
|
+
write(chunk) {
|
|
1042
|
+
packer.write(chunk);
|
|
1043
|
+
},
|
|
1044
|
+
close() {
|
|
1045
|
+
if (!bodyless)
|
|
1046
|
+
packer.endEntry();
|
|
1047
|
+
},
|
|
1048
|
+
abort(reason) {
|
|
1049
|
+
streamController.error(reason);
|
|
1050
|
+
}
|
|
1051
|
+
});
|
|
1052
|
+
},
|
|
1053
|
+
finalize() {
|
|
1054
|
+
packer.finalize();
|
|
1055
|
+
},
|
|
1056
|
+
error(err) {
|
|
1057
|
+
streamController.error(err);
|
|
1058
|
+
}
|
|
1059
|
+
}
|
|
1060
|
+
};
|
|
928
1061
|
}
|
|
929
|
-
function
|
|
930
|
-
const
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
1062
|
+
async function streamToBuffer(stream) {
|
|
1063
|
+
const chunks = [];
|
|
1064
|
+
const reader = stream.getReader();
|
|
1065
|
+
let totalLength = 0;
|
|
1066
|
+
try {
|
|
1067
|
+
while (true) {
|
|
1068
|
+
const { done, value } = await reader.read();
|
|
1069
|
+
if (done)
|
|
1070
|
+
break;
|
|
1071
|
+
chunks.push(value);
|
|
1072
|
+
totalLength += value.length;
|
|
1073
|
+
}
|
|
1074
|
+
const result = new Uint8Array(totalLength);
|
|
1075
|
+
let offset = 0;
|
|
1076
|
+
for (const chunk of chunks) {
|
|
1077
|
+
result.set(chunk, offset);
|
|
1078
|
+
offset += chunk.length;
|
|
1079
|
+
}
|
|
1080
|
+
return result;
|
|
1081
|
+
} finally {
|
|
1082
|
+
reader.releaseLock();
|
|
934
1083
|
}
|
|
935
|
-
return Object.defineProperties({}, mergedDescriptors);
|
|
936
|
-
}
|
|
937
|
-
function cloneDef(schema) {
|
|
938
|
-
return mergeDefs(schema._zod.def);
|
|
939
|
-
}
|
|
940
|
-
function getElementAtPath(obj, path) {
|
|
941
|
-
if (!path)
|
|
942
|
-
return obj;
|
|
943
|
-
return path.reduce((acc, key) => acc?.[key], obj);
|
|
944
1084
|
}
|
|
945
|
-
function
|
|
946
|
-
const
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
1085
|
+
async function packTar(entries) {
|
|
1086
|
+
const { readable, controller } = createTarPacker2();
|
|
1087
|
+
await (async () => {
|
|
1088
|
+
for (const entry of entries) {
|
|
1089
|
+
const entryStream = controller.add(entry.header);
|
|
1090
|
+
const body = "body" in entry ? entry.body : entry.data;
|
|
1091
|
+
if (!body) {
|
|
1092
|
+
await entryStream.close();
|
|
1093
|
+
continue;
|
|
1094
|
+
}
|
|
1095
|
+
if (body instanceof ReadableStream)
|
|
1096
|
+
await body.pipeTo(entryStream);
|
|
1097
|
+
else if (body instanceof Blob)
|
|
1098
|
+
await body.stream().pipeTo(entryStream);
|
|
1099
|
+
else
|
|
1100
|
+
try {
|
|
1101
|
+
const chunk = await normalizeBody(body);
|
|
1102
|
+
if (chunk.length > 0) {
|
|
1103
|
+
const writer = entryStream.getWriter();
|
|
1104
|
+
await writer.write(chunk);
|
|
1105
|
+
await writer.close();
|
|
1106
|
+
} else
|
|
1107
|
+
await entryStream.close();
|
|
1108
|
+
} catch {
|
|
1109
|
+
throw new TypeError(`Unsupported content type for entry "${entry.header.name}".`);
|
|
1110
|
+
}
|
|
952
1111
|
}
|
|
953
|
-
|
|
954
|
-
|
|
1112
|
+
})().then(() => controller.finalize()).catch((err) => controller.error(err));
|
|
1113
|
+
return new Uint8Array(await streamToBuffer(readable));
|
|
955
1114
|
}
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
1115
|
+
|
|
1116
|
+
class RXAImpl {
|
|
1117
|
+
_buffer;
|
|
1118
|
+
constructor(buffer) {
|
|
1119
|
+
this._buffer = buffer;
|
|
961
1120
|
}
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
}
|
|
970
|
-
function isObject(data) {
|
|
971
|
-
return typeof data === "object" && data !== null && !Array.isArray(data);
|
|
972
|
-
}
|
|
973
|
-
function isPlainObject2(o3) {
|
|
974
|
-
if (isObject(o3) === false)
|
|
975
|
-
return false;
|
|
976
|
-
const ctor = o3.constructor;
|
|
977
|
-
if (ctor === undefined)
|
|
978
|
-
return true;
|
|
979
|
-
if (typeof ctor !== "function")
|
|
980
|
-
return true;
|
|
981
|
-
const prot = ctor.prototype;
|
|
982
|
-
if (isObject(prot) === false)
|
|
983
|
-
return false;
|
|
984
|
-
if (Object.prototype.hasOwnProperty.call(prot, "isPrototypeOf") === false) {
|
|
985
|
-
return false;
|
|
1121
|
+
get stream() {
|
|
1122
|
+
const buffer = this._buffer;
|
|
1123
|
+
return new ReadableStream({
|
|
1124
|
+
start(controller) {
|
|
1125
|
+
controller.enqueue(new Uint8Array(buffer));
|
|
1126
|
+
controller.close();
|
|
1127
|
+
}
|
|
1128
|
+
});
|
|
986
1129
|
}
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
function shallowClone(o3) {
|
|
990
|
-
if (isPlainObject2(o3))
|
|
991
|
-
return { ...o3 };
|
|
992
|
-
if (Array.isArray(o3))
|
|
993
|
-
return [...o3];
|
|
994
|
-
return o3;
|
|
995
|
-
}
|
|
996
|
-
function numKeys(data) {
|
|
997
|
-
let keyCount = 0;
|
|
998
|
-
for (const key in data) {
|
|
999
|
-
if (Object.prototype.hasOwnProperty.call(data, key)) {
|
|
1000
|
-
keyCount++;
|
|
1001
|
-
}
|
|
1130
|
+
async buffer() {
|
|
1131
|
+
return this._buffer;
|
|
1002
1132
|
}
|
|
1003
|
-
return keyCount;
|
|
1004
|
-
}
|
|
1005
|
-
function escapeRegex(str) {
|
|
1006
|
-
return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
1007
1133
|
}
|
|
1008
|
-
function
|
|
1009
|
-
const
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
}
|
|
1014
|
-
|
|
1015
|
-
const
|
|
1134
|
+
async function archive(files) {
|
|
1135
|
+
const entries = Object.entries(files).map(([name, content]) => {
|
|
1136
|
+
return {
|
|
1137
|
+
header: { name, size: content.length, type: "file" },
|
|
1138
|
+
body: new Uint8Array(content)
|
|
1139
|
+
};
|
|
1140
|
+
});
|
|
1141
|
+
const tarBuffer = await packTar(entries);
|
|
1142
|
+
const gzipBuffer = await gzipAsync(Buffer.from(tarBuffer));
|
|
1143
|
+
return new RXAImpl(gzipBuffer);
|
|
1144
|
+
}
|
|
1145
|
+
function $constructor(name, initializer, params) {
|
|
1146
|
+
function init2(inst, def) {
|
|
1147
|
+
if (!inst._zod) {
|
|
1148
|
+
Object.defineProperty(inst, "_zod", {
|
|
1149
|
+
value: {
|
|
1150
|
+
def,
|
|
1151
|
+
constr: _3,
|
|
1152
|
+
traits: new Set
|
|
1153
|
+
},
|
|
1154
|
+
enumerable: false
|
|
1155
|
+
});
|
|
1156
|
+
}
|
|
1157
|
+
if (inst._zod.traits.has(name)) {
|
|
1158
|
+
return;
|
|
1159
|
+
}
|
|
1160
|
+
inst._zod.traits.add(name);
|
|
1161
|
+
initializer(inst, def);
|
|
1162
|
+
const proto = _3.prototype;
|
|
1163
|
+
const keys = Object.keys(proto);
|
|
1164
|
+
for (let i2 = 0;i2 < keys.length; i2++) {
|
|
1165
|
+
const k2 = keys[i2];
|
|
1166
|
+
if (!(k2 in inst)) {
|
|
1167
|
+
inst[k2] = proto[k2].bind(inst);
|
|
1168
|
+
}
|
|
1169
|
+
}
|
|
1170
|
+
}
|
|
1171
|
+
const Parent = params?.Parent ?? Object;
|
|
1172
|
+
|
|
1173
|
+
class Definition extends Parent {
|
|
1174
|
+
}
|
|
1175
|
+
Object.defineProperty(Definition, "name", { value: name });
|
|
1176
|
+
function _3(def) {
|
|
1177
|
+
var _a;
|
|
1178
|
+
const inst = params?.Parent ? new Definition : this;
|
|
1179
|
+
init2(inst, def);
|
|
1180
|
+
(_a = inst._zod).deferred ?? (_a.deferred = []);
|
|
1181
|
+
for (const fn of inst._zod.deferred) {
|
|
1182
|
+
fn();
|
|
1183
|
+
}
|
|
1184
|
+
return inst;
|
|
1185
|
+
}
|
|
1186
|
+
Object.defineProperty(_3, "init", { value: init2 });
|
|
1187
|
+
Object.defineProperty(_3, Symbol.hasInstance, {
|
|
1188
|
+
value: (inst) => {
|
|
1189
|
+
if (params?.Parent && inst instanceof params.Parent)
|
|
1190
|
+
return true;
|
|
1191
|
+
return inst?._zod?.traits?.has(name);
|
|
1192
|
+
}
|
|
1193
|
+
});
|
|
1194
|
+
Object.defineProperty(_3, "name", { value: name });
|
|
1195
|
+
return _3;
|
|
1196
|
+
}
|
|
1197
|
+
function config(newConfig) {
|
|
1198
|
+
if (newConfig)
|
|
1199
|
+
Object.assign(globalConfig, newConfig);
|
|
1200
|
+
return globalConfig;
|
|
1201
|
+
}
|
|
1202
|
+
function assertEqual(val) {
|
|
1203
|
+
return val;
|
|
1204
|
+
}
|
|
1205
|
+
function assertNotEqual(val) {
|
|
1206
|
+
return val;
|
|
1207
|
+
}
|
|
1208
|
+
function assertIs(_arg) {}
|
|
1209
|
+
function assertNever(_x) {
|
|
1210
|
+
throw new Error("Unexpected value in exhaustive check");
|
|
1211
|
+
}
|
|
1212
|
+
function assert(_3) {}
|
|
1213
|
+
function getEnumValues(entries) {
|
|
1214
|
+
const numericValues = Object.values(entries).filter((v2) => typeof v2 === "number");
|
|
1215
|
+
const values = Object.entries(entries).filter(([k2, _3]) => numericValues.indexOf(+k2) === -1).map(([_3, v2]) => v2);
|
|
1216
|
+
return values;
|
|
1217
|
+
}
|
|
1218
|
+
function joinValues(array, separator = "|") {
|
|
1219
|
+
return array.map((val) => stringifyPrimitive(val)).join(separator);
|
|
1220
|
+
}
|
|
1221
|
+
function jsonStringifyReplacer(_3, value) {
|
|
1222
|
+
if (typeof value === "bigint")
|
|
1223
|
+
return value.toString();
|
|
1224
|
+
return value;
|
|
1225
|
+
}
|
|
1226
|
+
function cached(getter) {
|
|
1227
|
+
const set = false;
|
|
1228
|
+
return {
|
|
1229
|
+
get value() {
|
|
1230
|
+
if (!set) {
|
|
1231
|
+
const value = getter();
|
|
1232
|
+
Object.defineProperty(this, "value", { value });
|
|
1233
|
+
return value;
|
|
1234
|
+
}
|
|
1235
|
+
throw new Error("cached value already set");
|
|
1236
|
+
}
|
|
1237
|
+
};
|
|
1238
|
+
}
|
|
1239
|
+
function nullish(input) {
|
|
1240
|
+
return input === null || input === undefined;
|
|
1241
|
+
}
|
|
1242
|
+
function cleanRegex(source) {
|
|
1243
|
+
const start = source.startsWith("^") ? 1 : 0;
|
|
1244
|
+
const end = source.endsWith("$") ? source.length - 1 : source.length;
|
|
1245
|
+
return source.slice(start, end);
|
|
1246
|
+
}
|
|
1247
|
+
function floatSafeRemainder(val, step) {
|
|
1248
|
+
const valDecCount = (val.toString().split(".")[1] || "").length;
|
|
1249
|
+
const stepString = step.toString();
|
|
1250
|
+
let stepDecCount = (stepString.split(".")[1] || "").length;
|
|
1251
|
+
if (stepDecCount === 0 && /\d?e-\d?/.test(stepString)) {
|
|
1252
|
+
const match = stepString.match(/\d?e-(\d?)/);
|
|
1253
|
+
if (match?.[1]) {
|
|
1254
|
+
stepDecCount = Number.parseInt(match[1]);
|
|
1255
|
+
}
|
|
1256
|
+
}
|
|
1257
|
+
const decCount = valDecCount > stepDecCount ? valDecCount : stepDecCount;
|
|
1258
|
+
const valInt = Number.parseInt(val.toFixed(decCount).replace(".", ""));
|
|
1259
|
+
const stepInt = Number.parseInt(step.toFixed(decCount).replace(".", ""));
|
|
1260
|
+
return valInt % stepInt / 10 ** decCount;
|
|
1261
|
+
}
|
|
1262
|
+
function defineLazy(object, key, getter) {
|
|
1263
|
+
let value = undefined;
|
|
1264
|
+
Object.defineProperty(object, key, {
|
|
1265
|
+
get() {
|
|
1266
|
+
if (value === EVALUATING) {
|
|
1267
|
+
return;
|
|
1268
|
+
}
|
|
1269
|
+
if (value === undefined) {
|
|
1270
|
+
value = EVALUATING;
|
|
1271
|
+
value = getter();
|
|
1272
|
+
}
|
|
1273
|
+
return value;
|
|
1274
|
+
},
|
|
1275
|
+
set(v2) {
|
|
1276
|
+
Object.defineProperty(object, key, {
|
|
1277
|
+
value: v2
|
|
1278
|
+
});
|
|
1279
|
+
},
|
|
1280
|
+
configurable: true
|
|
1281
|
+
});
|
|
1282
|
+
}
|
|
1283
|
+
function objectClone(obj) {
|
|
1284
|
+
return Object.create(Object.getPrototypeOf(obj), Object.getOwnPropertyDescriptors(obj));
|
|
1285
|
+
}
|
|
1286
|
+
function assignProp(target, prop, value) {
|
|
1287
|
+
Object.defineProperty(target, prop, {
|
|
1288
|
+
value,
|
|
1289
|
+
writable: true,
|
|
1290
|
+
enumerable: true,
|
|
1291
|
+
configurable: true
|
|
1292
|
+
});
|
|
1293
|
+
}
|
|
1294
|
+
function mergeDefs(...defs) {
|
|
1295
|
+
const mergedDescriptors = {};
|
|
1296
|
+
for (const def of defs) {
|
|
1297
|
+
const descriptors = Object.getOwnPropertyDescriptors(def);
|
|
1298
|
+
Object.assign(mergedDescriptors, descriptors);
|
|
1299
|
+
}
|
|
1300
|
+
return Object.defineProperties({}, mergedDescriptors);
|
|
1301
|
+
}
|
|
1302
|
+
function cloneDef(schema) {
|
|
1303
|
+
return mergeDefs(schema._zod.def);
|
|
1304
|
+
}
|
|
1305
|
+
function getElementAtPath(obj, path) {
|
|
1306
|
+
if (!path)
|
|
1307
|
+
return obj;
|
|
1308
|
+
return path.reduce((acc, key) => acc?.[key], obj);
|
|
1309
|
+
}
|
|
1310
|
+
function promiseAllObject(promisesObj) {
|
|
1311
|
+
const keys = Object.keys(promisesObj);
|
|
1312
|
+
const promises = keys.map((key) => promisesObj[key]);
|
|
1313
|
+
return Promise.all(promises).then((results) => {
|
|
1314
|
+
const resolvedObj = {};
|
|
1315
|
+
for (let i2 = 0;i2 < keys.length; i2++) {
|
|
1316
|
+
resolvedObj[keys[i2]] = results[i2];
|
|
1317
|
+
}
|
|
1318
|
+
return resolvedObj;
|
|
1319
|
+
});
|
|
1320
|
+
}
|
|
1321
|
+
function randomString(length = 10) {
|
|
1322
|
+
const chars = "abcdefghijklmnopqrstuvwxyz";
|
|
1323
|
+
let str = "";
|
|
1324
|
+
for (let i2 = 0;i2 < length; i2++) {
|
|
1325
|
+
str += chars[Math.floor(Math.random() * chars.length)];
|
|
1326
|
+
}
|
|
1327
|
+
return str;
|
|
1328
|
+
}
|
|
1329
|
+
function esc(str) {
|
|
1330
|
+
return JSON.stringify(str);
|
|
1331
|
+
}
|
|
1332
|
+
function slugify(input) {
|
|
1333
|
+
return input.toLowerCase().trim().replace(/[^\w\s-]/g, "").replace(/[\s_-]+/g, "-").replace(/^-+|-+$/g, "");
|
|
1334
|
+
}
|
|
1335
|
+
function isObject(data) {
|
|
1336
|
+
return typeof data === "object" && data !== null && !Array.isArray(data);
|
|
1337
|
+
}
|
|
1338
|
+
function isPlainObject2(o3) {
|
|
1339
|
+
if (isObject(o3) === false)
|
|
1340
|
+
return false;
|
|
1341
|
+
const ctor = o3.constructor;
|
|
1342
|
+
if (ctor === undefined)
|
|
1343
|
+
return true;
|
|
1344
|
+
if (typeof ctor !== "function")
|
|
1345
|
+
return true;
|
|
1346
|
+
const prot = ctor.prototype;
|
|
1347
|
+
if (isObject(prot) === false)
|
|
1348
|
+
return false;
|
|
1349
|
+
if (Object.prototype.hasOwnProperty.call(prot, "isPrototypeOf") === false) {
|
|
1350
|
+
return false;
|
|
1351
|
+
}
|
|
1352
|
+
return true;
|
|
1353
|
+
}
|
|
1354
|
+
function shallowClone(o3) {
|
|
1355
|
+
if (isPlainObject2(o3))
|
|
1356
|
+
return { ...o3 };
|
|
1357
|
+
if (Array.isArray(o3))
|
|
1358
|
+
return [...o3];
|
|
1359
|
+
return o3;
|
|
1360
|
+
}
|
|
1361
|
+
function numKeys(data) {
|
|
1362
|
+
let keyCount = 0;
|
|
1363
|
+
for (const key in data) {
|
|
1364
|
+
if (Object.prototype.hasOwnProperty.call(data, key)) {
|
|
1365
|
+
keyCount++;
|
|
1366
|
+
}
|
|
1367
|
+
}
|
|
1368
|
+
return keyCount;
|
|
1369
|
+
}
|
|
1370
|
+
function escapeRegex(str) {
|
|
1371
|
+
return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
1372
|
+
}
|
|
1373
|
+
function clone(inst, def, params) {
|
|
1374
|
+
const cl = new inst._zod.constr(def ?? inst._zod.def);
|
|
1375
|
+
if (!def || params?.parent)
|
|
1376
|
+
cl._zod.parent = inst;
|
|
1377
|
+
return cl;
|
|
1378
|
+
}
|
|
1379
|
+
function normalizeParams(_params) {
|
|
1380
|
+
const params = _params;
|
|
1016
1381
|
if (!params)
|
|
1017
1382
|
return {};
|
|
1018
1383
|
if (typeof params === "string")
|
|
@@ -4224,648 +4589,294 @@ function convertBaseSchema(schema, ctx) {
|
|
|
4224
4589
|
stringSchema = stringSchema.max(schema.maxLength);
|
|
4225
4590
|
}
|
|
4226
4591
|
if (schema.pattern) {
|
|
4227
|
-
stringSchema = stringSchema.regex(new RegExp(schema.pattern));
|
|
4228
|
-
}
|
|
4229
|
-
zodSchema = stringSchema;
|
|
4230
|
-
break;
|
|
4231
|
-
}
|
|
4232
|
-
case "number":
|
|
4233
|
-
case "integer": {
|
|
4234
|
-
let numberSchema = type === "integer" ? z2.number().int() : z2.number();
|
|
4235
|
-
if (typeof schema.minimum === "number") {
|
|
4236
|
-
numberSchema = numberSchema.min(schema.minimum);
|
|
4237
|
-
}
|
|
4238
|
-
if (typeof schema.maximum === "number") {
|
|
4239
|
-
numberSchema = numberSchema.max(schema.maximum);
|
|
4240
|
-
}
|
|
4241
|
-
if (typeof schema.exclusiveMinimum === "number") {
|
|
4242
|
-
numberSchema = numberSchema.gt(schema.exclusiveMinimum);
|
|
4243
|
-
} else if (schema.exclusiveMinimum === true && typeof schema.minimum === "number") {
|
|
4244
|
-
numberSchema = numberSchema.gt(schema.minimum);
|
|
4245
|
-
}
|
|
4246
|
-
if (typeof schema.exclusiveMaximum === "number") {
|
|
4247
|
-
numberSchema = numberSchema.lt(schema.exclusiveMaximum);
|
|
4248
|
-
} else if (schema.exclusiveMaximum === true && typeof schema.maximum === "number") {
|
|
4249
|
-
numberSchema = numberSchema.lt(schema.maximum);
|
|
4250
|
-
}
|
|
4251
|
-
if (typeof schema.multipleOf === "number") {
|
|
4252
|
-
numberSchema = numberSchema.multipleOf(schema.multipleOf);
|
|
4253
|
-
}
|
|
4254
|
-
zodSchema = numberSchema;
|
|
4255
|
-
break;
|
|
4256
|
-
}
|
|
4257
|
-
case "boolean": {
|
|
4258
|
-
zodSchema = z2.boolean();
|
|
4259
|
-
break;
|
|
4260
|
-
}
|
|
4261
|
-
case "null": {
|
|
4262
|
-
zodSchema = z2.null();
|
|
4263
|
-
break;
|
|
4264
|
-
}
|
|
4265
|
-
case "object": {
|
|
4266
|
-
const shape = {};
|
|
4267
|
-
const properties = schema.properties || {};
|
|
4268
|
-
const requiredSet = new Set(schema.required || []);
|
|
4269
|
-
for (const [key, propSchema] of Object.entries(properties)) {
|
|
4270
|
-
const propZodSchema = convertSchema(propSchema, ctx);
|
|
4271
|
-
shape[key] = requiredSet.has(key) ? propZodSchema : propZodSchema.optional();
|
|
4272
|
-
}
|
|
4273
|
-
if (schema.propertyNames) {
|
|
4274
|
-
const keySchema = convertSchema(schema.propertyNames, ctx);
|
|
4275
|
-
const valueSchema = schema.additionalProperties && typeof schema.additionalProperties === "object" ? convertSchema(schema.additionalProperties, ctx) : z2.any();
|
|
4276
|
-
if (Object.keys(shape).length === 0) {
|
|
4277
|
-
zodSchema = z2.record(keySchema, valueSchema);
|
|
4278
|
-
break;
|
|
4279
|
-
}
|
|
4280
|
-
const objectSchema2 = z2.object(shape).passthrough();
|
|
4281
|
-
const recordSchema = z2.looseRecord(keySchema, valueSchema);
|
|
4282
|
-
zodSchema = z2.intersection(objectSchema2, recordSchema);
|
|
4283
|
-
break;
|
|
4284
|
-
}
|
|
4285
|
-
if (schema.patternProperties) {
|
|
4286
|
-
const patternProps = schema.patternProperties;
|
|
4287
|
-
const patternKeys = Object.keys(patternProps);
|
|
4288
|
-
const looseRecords = [];
|
|
4289
|
-
for (const pattern of patternKeys) {
|
|
4290
|
-
const patternValue = convertSchema(patternProps[pattern], ctx);
|
|
4291
|
-
const keySchema = z2.string().regex(new RegExp(pattern));
|
|
4292
|
-
looseRecords.push(z2.looseRecord(keySchema, patternValue));
|
|
4293
|
-
}
|
|
4294
|
-
const schemasToIntersect = [];
|
|
4295
|
-
if (Object.keys(shape).length > 0) {
|
|
4296
|
-
schemasToIntersect.push(z2.object(shape).passthrough());
|
|
4297
|
-
}
|
|
4298
|
-
schemasToIntersect.push(...looseRecords);
|
|
4299
|
-
if (schemasToIntersect.length === 0) {
|
|
4300
|
-
zodSchema = z2.object({}).passthrough();
|
|
4301
|
-
} else if (schemasToIntersect.length === 1) {
|
|
4302
|
-
zodSchema = schemasToIntersect[0];
|
|
4303
|
-
} else {
|
|
4304
|
-
let result = z2.intersection(schemasToIntersect[0], schemasToIntersect[1]);
|
|
4305
|
-
for (let i2 = 2;i2 < schemasToIntersect.length; i2++) {
|
|
4306
|
-
result = z2.intersection(result, schemasToIntersect[i2]);
|
|
4307
|
-
}
|
|
4308
|
-
zodSchema = result;
|
|
4309
|
-
}
|
|
4310
|
-
break;
|
|
4311
|
-
}
|
|
4312
|
-
const objectSchema = z2.object(shape);
|
|
4313
|
-
if (schema.additionalProperties === false) {
|
|
4314
|
-
zodSchema = objectSchema.strict();
|
|
4315
|
-
} else if (typeof schema.additionalProperties === "object") {
|
|
4316
|
-
zodSchema = objectSchema.catchall(convertSchema(schema.additionalProperties, ctx));
|
|
4317
|
-
} else {
|
|
4318
|
-
zodSchema = objectSchema.passthrough();
|
|
4319
|
-
}
|
|
4320
|
-
break;
|
|
4321
|
-
}
|
|
4322
|
-
case "array": {
|
|
4323
|
-
const prefixItems = schema.prefixItems;
|
|
4324
|
-
const items = schema.items;
|
|
4325
|
-
if (prefixItems && Array.isArray(prefixItems)) {
|
|
4326
|
-
const tupleItems = prefixItems.map((item) => convertSchema(item, ctx));
|
|
4327
|
-
const rest = items && typeof items === "object" && !Array.isArray(items) ? convertSchema(items, ctx) : undefined;
|
|
4328
|
-
if (rest) {
|
|
4329
|
-
zodSchema = z2.tuple(tupleItems).rest(rest);
|
|
4330
|
-
} else {
|
|
4331
|
-
zodSchema = z2.tuple(tupleItems);
|
|
4332
|
-
}
|
|
4333
|
-
if (typeof schema.minItems === "number") {
|
|
4334
|
-
zodSchema = zodSchema.check(z2.minLength(schema.minItems));
|
|
4335
|
-
}
|
|
4336
|
-
if (typeof schema.maxItems === "number") {
|
|
4337
|
-
zodSchema = zodSchema.check(z2.maxLength(schema.maxItems));
|
|
4338
|
-
}
|
|
4339
|
-
} else if (Array.isArray(items)) {
|
|
4340
|
-
const tupleItems = items.map((item) => convertSchema(item, ctx));
|
|
4341
|
-
const rest = schema.additionalItems && typeof schema.additionalItems === "object" ? convertSchema(schema.additionalItems, ctx) : undefined;
|
|
4342
|
-
if (rest) {
|
|
4343
|
-
zodSchema = z2.tuple(tupleItems).rest(rest);
|
|
4344
|
-
} else {
|
|
4345
|
-
zodSchema = z2.tuple(tupleItems);
|
|
4346
|
-
}
|
|
4347
|
-
if (typeof schema.minItems === "number") {
|
|
4348
|
-
zodSchema = zodSchema.check(z2.minLength(schema.minItems));
|
|
4349
|
-
}
|
|
4350
|
-
if (typeof schema.maxItems === "number") {
|
|
4351
|
-
zodSchema = zodSchema.check(z2.maxLength(schema.maxItems));
|
|
4352
|
-
}
|
|
4353
|
-
} else if (items !== undefined) {
|
|
4354
|
-
const element = convertSchema(items, ctx);
|
|
4355
|
-
let arraySchema = z2.array(element);
|
|
4356
|
-
if (typeof schema.minItems === "number") {
|
|
4357
|
-
arraySchema = arraySchema.min(schema.minItems);
|
|
4358
|
-
}
|
|
4359
|
-
if (typeof schema.maxItems === "number") {
|
|
4360
|
-
arraySchema = arraySchema.max(schema.maxItems);
|
|
4361
|
-
}
|
|
4362
|
-
zodSchema = arraySchema;
|
|
4363
|
-
} else {
|
|
4364
|
-
zodSchema = z2.array(z2.any());
|
|
4365
|
-
}
|
|
4366
|
-
break;
|
|
4367
|
-
}
|
|
4368
|
-
default:
|
|
4369
|
-
throw new Error(`Unsupported type: ${type}`);
|
|
4370
|
-
}
|
|
4371
|
-
if (schema.description) {
|
|
4372
|
-
zodSchema = zodSchema.describe(schema.description);
|
|
4373
|
-
}
|
|
4374
|
-
if (schema.default !== undefined) {
|
|
4375
|
-
zodSchema = zodSchema.default(schema.default);
|
|
4376
|
-
}
|
|
4377
|
-
return zodSchema;
|
|
4378
|
-
}
|
|
4379
|
-
function convertSchema(schema, ctx) {
|
|
4380
|
-
if (typeof schema === "boolean") {
|
|
4381
|
-
return schema ? z2.any() : z2.never();
|
|
4382
|
-
}
|
|
4383
|
-
let baseSchema = convertBaseSchema(schema, ctx);
|
|
4384
|
-
const hasExplicitType = schema.type || schema.enum !== undefined || schema.const !== undefined;
|
|
4385
|
-
if (schema.anyOf && Array.isArray(schema.anyOf)) {
|
|
4386
|
-
const options = schema.anyOf.map((s2) => convertSchema(s2, ctx));
|
|
4387
|
-
const anyOfUnion = z2.union(options);
|
|
4388
|
-
baseSchema = hasExplicitType ? z2.intersection(baseSchema, anyOfUnion) : anyOfUnion;
|
|
4389
|
-
}
|
|
4390
|
-
if (schema.oneOf && Array.isArray(schema.oneOf)) {
|
|
4391
|
-
const options = schema.oneOf.map((s2) => convertSchema(s2, ctx));
|
|
4392
|
-
const oneOfUnion = z2.xor(options);
|
|
4393
|
-
baseSchema = hasExplicitType ? z2.intersection(baseSchema, oneOfUnion) : oneOfUnion;
|
|
4394
|
-
}
|
|
4395
|
-
if (schema.allOf && Array.isArray(schema.allOf)) {
|
|
4396
|
-
if (schema.allOf.length === 0) {
|
|
4397
|
-
baseSchema = hasExplicitType ? baseSchema : z2.any();
|
|
4398
|
-
} else {
|
|
4399
|
-
let result = hasExplicitType ? baseSchema : convertSchema(schema.allOf[0], ctx);
|
|
4400
|
-
const startIdx = hasExplicitType ? 0 : 1;
|
|
4401
|
-
for (let i2 = startIdx;i2 < schema.allOf.length; i2++) {
|
|
4402
|
-
result = z2.intersection(result, convertSchema(schema.allOf[i2], ctx));
|
|
4403
|
-
}
|
|
4404
|
-
baseSchema = result;
|
|
4405
|
-
}
|
|
4406
|
-
}
|
|
4407
|
-
if (schema.nullable === true && ctx.version === "openapi-3.0") {
|
|
4408
|
-
baseSchema = z2.nullable(baseSchema);
|
|
4409
|
-
}
|
|
4410
|
-
if (schema.readOnly === true) {
|
|
4411
|
-
baseSchema = z2.readonly(baseSchema);
|
|
4412
|
-
}
|
|
4413
|
-
const extraMeta = {};
|
|
4414
|
-
const coreMetadataKeys = ["$id", "id", "$comment", "$anchor", "$vocabulary", "$dynamicRef", "$dynamicAnchor"];
|
|
4415
|
-
for (const key of coreMetadataKeys) {
|
|
4416
|
-
if (key in schema) {
|
|
4417
|
-
extraMeta[key] = schema[key];
|
|
4418
|
-
}
|
|
4419
|
-
}
|
|
4420
|
-
const contentMetadataKeys = ["contentEncoding", "contentMediaType", "contentSchema"];
|
|
4421
|
-
for (const key of contentMetadataKeys) {
|
|
4422
|
-
if (key in schema) {
|
|
4423
|
-
extraMeta[key] = schema[key];
|
|
4424
|
-
}
|
|
4425
|
-
}
|
|
4426
|
-
for (const key of Object.keys(schema)) {
|
|
4427
|
-
if (!RECOGNIZED_KEYS.has(key)) {
|
|
4428
|
-
extraMeta[key] = schema[key];
|
|
4429
|
-
}
|
|
4430
|
-
}
|
|
4431
|
-
if (Object.keys(extraMeta).length > 0) {
|
|
4432
|
-
ctx.registry.add(baseSchema, extraMeta);
|
|
4433
|
-
}
|
|
4434
|
-
return baseSchema;
|
|
4435
|
-
}
|
|
4436
|
-
function fromJSONSchema(schema, params) {
|
|
4437
|
-
if (typeof schema === "boolean") {
|
|
4438
|
-
return schema ? z2.any() : z2.never();
|
|
4439
|
-
}
|
|
4440
|
-
const version2 = detectVersion(schema, params?.defaultTarget);
|
|
4441
|
-
const defs = schema.$defs || schema.definitions || {};
|
|
4442
|
-
const ctx = {
|
|
4443
|
-
version: version2,
|
|
4444
|
-
defs,
|
|
4445
|
-
refs: new Map,
|
|
4446
|
-
processing: new Set,
|
|
4447
|
-
rootSchema: schema,
|
|
4448
|
-
registry: params?.registry ?? globalRegistry
|
|
4449
|
-
};
|
|
4450
|
-
return convertSchema(schema, ctx);
|
|
4451
|
-
}
|
|
4452
|
-
function string3(params) {
|
|
4453
|
-
return _coercedString(ZodString, params);
|
|
4454
|
-
}
|
|
4455
|
-
function number3(params) {
|
|
4456
|
-
return _coercedNumber(ZodNumber, params);
|
|
4457
|
-
}
|
|
4458
|
-
function boolean3(params) {
|
|
4459
|
-
return _coercedBoolean(ZodBoolean, params);
|
|
4460
|
-
}
|
|
4461
|
-
function bigint3(params) {
|
|
4462
|
-
return _coercedBigint(ZodBigInt, params);
|
|
4463
|
-
}
|
|
4464
|
-
function date4(params) {
|
|
4465
|
-
return _coercedDate(ZodDate, params);
|
|
4466
|
-
}
|
|
4467
|
-
function define(input) {
|
|
4468
|
-
if (input === null || typeof input !== "object") {
|
|
4469
|
-
throw new DefinitionError("definition must be an object");
|
|
4470
|
-
}
|
|
4471
|
-
let validated;
|
|
4472
|
-
try {
|
|
4473
|
-
validated = RXDSchema.parse(input);
|
|
4474
|
-
} catch (e2) {
|
|
4475
|
-
throw new DefinitionError(`Invalid definition: ${e2 instanceof Error ? e2.message : String(e2)}`);
|
|
4476
|
-
}
|
|
4477
|
-
const rxd = Object.assign(Object.create(null), {
|
|
4478
|
-
name: validated.name,
|
|
4479
|
-
type: validated.type,
|
|
4480
|
-
tag: validated.tag ?? validated.version ?? undefined,
|
|
4481
|
-
registry: validated.registry,
|
|
4482
|
-
path: validated.path,
|
|
4483
|
-
description: validated.description,
|
|
4484
|
-
author: validated.author,
|
|
4485
|
-
license: validated.license,
|
|
4486
|
-
keywords: validated.keywords,
|
|
4487
|
-
repository: validated.repository
|
|
4488
|
-
});
|
|
4489
|
-
return rxd;
|
|
4490
|
-
}
|
|
4491
|
-
function manifest(rxd) {
|
|
4492
|
-
return {
|
|
4493
|
-
registry: rxd.registry,
|
|
4494
|
-
path: rxd.path,
|
|
4495
|
-
name: rxd.name,
|
|
4496
|
-
type: rxd.type,
|
|
4497
|
-
tag: rxd.tag ?? "latest"
|
|
4498
|
-
};
|
|
4499
|
-
}
|
|
4500
|
-
function writeString(view, offset, size, value) {
|
|
4501
|
-
if (value)
|
|
4502
|
-
encoder.encodeInto(value, view.subarray(offset, offset + size));
|
|
4503
|
-
}
|
|
4504
|
-
function writeOctal(view, offset, size, value) {
|
|
4505
|
-
if (value === undefined)
|
|
4506
|
-
return;
|
|
4507
|
-
const octalString = value.toString(8).padStart(size - 1, "0");
|
|
4508
|
-
encoder.encodeInto(octalString, view.subarray(offset, offset + size - 1));
|
|
4509
|
-
}
|
|
4510
|
-
async function normalizeBody(body) {
|
|
4511
|
-
if (body === null || body === undefined)
|
|
4512
|
-
return EMPTY;
|
|
4513
|
-
if (body instanceof Uint8Array)
|
|
4514
|
-
return body;
|
|
4515
|
-
if (typeof body === "string")
|
|
4516
|
-
return encoder.encode(body);
|
|
4517
|
-
if (body instanceof ArrayBuffer)
|
|
4518
|
-
return new Uint8Array(body);
|
|
4519
|
-
if (body instanceof Blob)
|
|
4520
|
-
return new Uint8Array(await body.arrayBuffer());
|
|
4521
|
-
throw new TypeError("Unsupported content type for entry body.");
|
|
4522
|
-
}
|
|
4523
|
-
function writeChecksum(block) {
|
|
4524
|
-
block.fill(CHECKSUM_SPACE, USTAR_CHECKSUM_OFFSET, USTAR_CHECKSUM_OFFSET + USTAR_CHECKSUM_SIZE);
|
|
4525
|
-
let checksum = 0;
|
|
4526
|
-
for (const byte of block)
|
|
4527
|
-
checksum += byte;
|
|
4528
|
-
for (let i2 = USTAR_CHECKSUM_OFFSET + 6 - 1;i2 >= USTAR_CHECKSUM_OFFSET; i2--) {
|
|
4529
|
-
block[i2] = (checksum & 7) + ASCII_ZERO;
|
|
4530
|
-
checksum >>= 3;
|
|
4531
|
-
}
|
|
4532
|
-
block[USTAR_CHECKSUM_OFFSET + 6] = 0;
|
|
4533
|
-
block[USTAR_CHECKSUM_OFFSET + 7] = CHECKSUM_SPACE;
|
|
4534
|
-
}
|
|
4535
|
-
function generatePax(header) {
|
|
4536
|
-
const paxRecords = {};
|
|
4537
|
-
if (header.name.length > USTAR_NAME_SIZE) {
|
|
4538
|
-
if (findUstarSplit(header.name) === null)
|
|
4539
|
-
paxRecords.path = header.name;
|
|
4540
|
-
}
|
|
4541
|
-
if (header.linkname && header.linkname.length > USTAR_NAME_SIZE)
|
|
4542
|
-
paxRecords.linkpath = header.linkname;
|
|
4543
|
-
if (header.uname && header.uname.length > USTAR_UNAME_SIZE)
|
|
4544
|
-
paxRecords.uname = header.uname;
|
|
4545
|
-
if (header.gname && header.gname.length > USTAR_GNAME_SIZE)
|
|
4546
|
-
paxRecords.gname = header.gname;
|
|
4547
|
-
if (header.uid != null && header.uid > USTAR_MAX_UID_GID)
|
|
4548
|
-
paxRecords.uid = String(header.uid);
|
|
4549
|
-
if (header.gid != null && header.gid > USTAR_MAX_UID_GID)
|
|
4550
|
-
paxRecords.gid = String(header.gid);
|
|
4551
|
-
if (header.size != null && header.size > USTAR_MAX_SIZE)
|
|
4552
|
-
paxRecords.size = String(header.size);
|
|
4553
|
-
if (header.pax)
|
|
4554
|
-
Object.assign(paxRecords, header.pax);
|
|
4555
|
-
const paxEntries = Object.entries(paxRecords);
|
|
4556
|
-
if (paxEntries.length === 0)
|
|
4557
|
-
return null;
|
|
4558
|
-
const paxBody = encoder.encode(paxEntries.map(([key, value]) => {
|
|
4559
|
-
const record2 = `${key}=${value}
|
|
4560
|
-
`;
|
|
4561
|
-
const partLength = encoder.encode(record2).length + 1;
|
|
4562
|
-
let totalLength = partLength + String(partLength).length;
|
|
4563
|
-
totalLength = partLength + String(totalLength).length;
|
|
4564
|
-
return `${totalLength} ${record2}`;
|
|
4565
|
-
}).join(""));
|
|
4566
|
-
return {
|
|
4567
|
-
paxHeader: createTarHeader({
|
|
4568
|
-
name: decoder.decode(encoder.encode(`PaxHeader/${header.name}`).slice(0, 100)),
|
|
4569
|
-
size: paxBody.length,
|
|
4570
|
-
type: "pax-header",
|
|
4571
|
-
mode: 420,
|
|
4572
|
-
mtime: header.mtime,
|
|
4573
|
-
uname: header.uname,
|
|
4574
|
-
gname: header.gname,
|
|
4575
|
-
uid: header.uid,
|
|
4576
|
-
gid: header.gid
|
|
4577
|
-
}),
|
|
4578
|
-
paxBody
|
|
4579
|
-
};
|
|
4580
|
-
}
|
|
4581
|
-
function findUstarSplit(path) {
|
|
4582
|
-
if (path.length <= USTAR_NAME_SIZE)
|
|
4583
|
-
return null;
|
|
4584
|
-
const minSlashIndex = path.length - USTAR_NAME_SIZE - 1;
|
|
4585
|
-
const slashIndex = path.lastIndexOf("/", USTAR_PREFIX_SIZE);
|
|
4586
|
-
if (slashIndex > 0 && slashIndex >= minSlashIndex)
|
|
4587
|
-
return {
|
|
4588
|
-
prefix: path.slice(0, slashIndex),
|
|
4589
|
-
name: path.slice(slashIndex + 1)
|
|
4590
|
-
};
|
|
4591
|
-
return null;
|
|
4592
|
-
}
|
|
4593
|
-
function createTarHeader(header) {
|
|
4594
|
-
const view = new Uint8Array(BLOCK_SIZE);
|
|
4595
|
-
const size = isBodyless(header) ? 0 : header.size ?? 0;
|
|
4596
|
-
let name = header.name;
|
|
4597
|
-
let prefix = "";
|
|
4598
|
-
if (!header.pax?.path) {
|
|
4599
|
-
const split = findUstarSplit(name);
|
|
4600
|
-
if (split) {
|
|
4601
|
-
name = split.name;
|
|
4602
|
-
prefix = split.prefix;
|
|
4603
|
-
}
|
|
4604
|
-
}
|
|
4605
|
-
writeString(view, USTAR_NAME_OFFSET, USTAR_NAME_SIZE, name);
|
|
4606
|
-
writeOctal(view, USTAR_MODE_OFFSET, USTAR_MODE_SIZE, header.mode ?? (header.type === DIRECTORY ? DEFAULT_DIR_MODE : DEFAULT_FILE_MODE));
|
|
4607
|
-
writeOctal(view, USTAR_UID_OFFSET, USTAR_UID_SIZE, header.uid ?? 0);
|
|
4608
|
-
writeOctal(view, USTAR_GID_OFFSET, USTAR_GID_SIZE, header.gid ?? 0);
|
|
4609
|
-
writeOctal(view, USTAR_SIZE_OFFSET, USTAR_SIZE_SIZE, size);
|
|
4610
|
-
writeOctal(view, USTAR_MTIME_OFFSET, USTAR_MTIME_SIZE, Math.floor((header.mtime?.getTime() ?? Date.now()) / 1000));
|
|
4611
|
-
writeString(view, USTAR_TYPEFLAG_OFFSET, USTAR_TYPEFLAG_SIZE, TYPEFLAG[header.type ?? FILE]);
|
|
4612
|
-
writeString(view, USTAR_LINKNAME_OFFSET, USTAR_LINKNAME_SIZE, header.linkname);
|
|
4613
|
-
writeString(view, USTAR_MAGIC_OFFSET, USTAR_MAGIC_SIZE, "ustar\x00");
|
|
4614
|
-
writeString(view, USTAR_VERSION_OFFSET, USTAR_VERSION_SIZE, USTAR_VERSION);
|
|
4615
|
-
writeString(view, USTAR_UNAME_OFFSET, USTAR_UNAME_SIZE, header.uname);
|
|
4616
|
-
writeString(view, USTAR_GNAME_OFFSET, USTAR_GNAME_SIZE, header.gname);
|
|
4617
|
-
writeString(view, USTAR_PREFIX_OFFSET, USTAR_PREFIX_SIZE, prefix);
|
|
4618
|
-
writeChecksum(view);
|
|
4619
|
-
return view;
|
|
4620
|
-
}
|
|
4621
|
-
function getHeaderBlocks(header) {
|
|
4622
|
-
const base = createTarHeader(header);
|
|
4623
|
-
const pax = generatePax(header);
|
|
4624
|
-
if (!pax)
|
|
4625
|
-
return [base];
|
|
4626
|
-
const paxPadding = -pax.paxBody.length & BLOCK_SIZE_MASK;
|
|
4627
|
-
const paddingBlocks = paxPadding > 0 ? [ZERO_BLOCK.subarray(0, paxPadding)] : [];
|
|
4628
|
-
return [
|
|
4629
|
-
pax.paxHeader,
|
|
4630
|
-
pax.paxBody,
|
|
4631
|
-
...paddingBlocks,
|
|
4632
|
-
base
|
|
4633
|
-
];
|
|
4634
|
-
}
|
|
4635
|
-
function createTarPacker(onData, onError, onFinalize) {
|
|
4636
|
-
let currentHeader = null;
|
|
4637
|
-
let bytesWritten = 0;
|
|
4638
|
-
let finalized = false;
|
|
4639
|
-
return {
|
|
4640
|
-
add(header) {
|
|
4641
|
-
if (finalized) {
|
|
4642
|
-
const error48 = /* @__PURE__ */ new Error("No new tar entries after finalize.");
|
|
4643
|
-
onError(error48);
|
|
4644
|
-
throw error48;
|
|
4645
|
-
}
|
|
4646
|
-
if (currentHeader !== null) {
|
|
4647
|
-
const error48 = /* @__PURE__ */ new Error("Previous entry must be completed before adding a new one");
|
|
4648
|
-
onError(error48);
|
|
4649
|
-
throw error48;
|
|
4650
|
-
}
|
|
4651
|
-
try {
|
|
4652
|
-
const size = isBodyless(header) ? 0 : header.size ?? 0;
|
|
4653
|
-
const headerBlocks = getHeaderBlocks({
|
|
4654
|
-
...header,
|
|
4655
|
-
size
|
|
4656
|
-
});
|
|
4657
|
-
for (const block of headerBlocks)
|
|
4658
|
-
onData(block);
|
|
4659
|
-
currentHeader = {
|
|
4660
|
-
...header,
|
|
4661
|
-
size
|
|
4662
|
-
};
|
|
4663
|
-
bytesWritten = 0;
|
|
4664
|
-
} catch (error48) {
|
|
4665
|
-
onError(error48);
|
|
4592
|
+
stringSchema = stringSchema.regex(new RegExp(schema.pattern));
|
|
4666
4593
|
}
|
|
4667
|
-
|
|
4668
|
-
|
|
4669
|
-
|
|
4670
|
-
|
|
4671
|
-
|
|
4672
|
-
|
|
4594
|
+
zodSchema = stringSchema;
|
|
4595
|
+
break;
|
|
4596
|
+
}
|
|
4597
|
+
case "number":
|
|
4598
|
+
case "integer": {
|
|
4599
|
+
let numberSchema = type === "integer" ? z2.number().int() : z2.number();
|
|
4600
|
+
if (typeof schema.minimum === "number") {
|
|
4601
|
+
numberSchema = numberSchema.min(schema.minimum);
|
|
4673
4602
|
}
|
|
4674
|
-
if (
|
|
4675
|
-
|
|
4676
|
-
onError(error48);
|
|
4677
|
-
throw error48;
|
|
4603
|
+
if (typeof schema.maximum === "number") {
|
|
4604
|
+
numberSchema = numberSchema.max(schema.maximum);
|
|
4678
4605
|
}
|
|
4679
|
-
|
|
4680
|
-
|
|
4681
|
-
|
|
4682
|
-
|
|
4683
|
-
throw error48;
|
|
4606
|
+
if (typeof schema.exclusiveMinimum === "number") {
|
|
4607
|
+
numberSchema = numberSchema.gt(schema.exclusiveMinimum);
|
|
4608
|
+
} else if (schema.exclusiveMinimum === true && typeof schema.minimum === "number") {
|
|
4609
|
+
numberSchema = numberSchema.gt(schema.minimum);
|
|
4684
4610
|
}
|
|
4685
|
-
|
|
4686
|
-
|
|
4687
|
-
|
|
4688
|
-
|
|
4689
|
-
onError(error48);
|
|
4611
|
+
if (typeof schema.exclusiveMaximum === "number") {
|
|
4612
|
+
numberSchema = numberSchema.lt(schema.exclusiveMaximum);
|
|
4613
|
+
} else if (schema.exclusiveMaximum === true && typeof schema.maximum === "number") {
|
|
4614
|
+
numberSchema = numberSchema.lt(schema.maximum);
|
|
4690
4615
|
}
|
|
4691
|
-
|
|
4692
|
-
|
|
4693
|
-
if (!currentHeader) {
|
|
4694
|
-
const error48 = /* @__PURE__ */ new Error("No active entry to end.");
|
|
4695
|
-
onError(error48);
|
|
4696
|
-
throw error48;
|
|
4616
|
+
if (typeof schema.multipleOf === "number") {
|
|
4617
|
+
numberSchema = numberSchema.multipleOf(schema.multipleOf);
|
|
4697
4618
|
}
|
|
4698
|
-
|
|
4699
|
-
|
|
4700
|
-
|
|
4701
|
-
|
|
4619
|
+
zodSchema = numberSchema;
|
|
4620
|
+
break;
|
|
4621
|
+
}
|
|
4622
|
+
case "boolean": {
|
|
4623
|
+
zodSchema = z2.boolean();
|
|
4624
|
+
break;
|
|
4625
|
+
}
|
|
4626
|
+
case "null": {
|
|
4627
|
+
zodSchema = z2.null();
|
|
4628
|
+
break;
|
|
4629
|
+
}
|
|
4630
|
+
case "object": {
|
|
4631
|
+
const shape = {};
|
|
4632
|
+
const properties = schema.properties || {};
|
|
4633
|
+
const requiredSet = new Set(schema.required || []);
|
|
4634
|
+
for (const [key, propSchema] of Object.entries(properties)) {
|
|
4635
|
+
const propZodSchema = convertSchema(propSchema, ctx);
|
|
4636
|
+
shape[key] = requiredSet.has(key) ? propZodSchema : propZodSchema.optional();
|
|
4702
4637
|
}
|
|
4703
|
-
|
|
4704
|
-
|
|
4705
|
-
|
|
4706
|
-
|
|
4707
|
-
|
|
4638
|
+
if (schema.propertyNames) {
|
|
4639
|
+
const keySchema = convertSchema(schema.propertyNames, ctx);
|
|
4640
|
+
const valueSchema = schema.additionalProperties && typeof schema.additionalProperties === "object" ? convertSchema(schema.additionalProperties, ctx) : z2.any();
|
|
4641
|
+
if (Object.keys(shape).length === 0) {
|
|
4642
|
+
zodSchema = z2.record(keySchema, valueSchema);
|
|
4643
|
+
break;
|
|
4708
4644
|
}
|
|
4709
|
-
const
|
|
4710
|
-
|
|
4711
|
-
|
|
4712
|
-
|
|
4713
|
-
bytesWritten = 0;
|
|
4714
|
-
} catch (error48) {
|
|
4715
|
-
onError(error48);
|
|
4716
|
-
throw error48;
|
|
4717
|
-
}
|
|
4718
|
-
},
|
|
4719
|
-
finalize() {
|
|
4720
|
-
if (finalized) {
|
|
4721
|
-
const error48 = /* @__PURE__ */ new Error("Archive has already been finalized");
|
|
4722
|
-
onError(error48);
|
|
4723
|
-
throw error48;
|
|
4645
|
+
const objectSchema2 = z2.object(shape).passthrough();
|
|
4646
|
+
const recordSchema = z2.looseRecord(keySchema, valueSchema);
|
|
4647
|
+
zodSchema = z2.intersection(objectSchema2, recordSchema);
|
|
4648
|
+
break;
|
|
4724
4649
|
}
|
|
4725
|
-
if (
|
|
4726
|
-
const
|
|
4727
|
-
|
|
4728
|
-
|
|
4650
|
+
if (schema.patternProperties) {
|
|
4651
|
+
const patternProps = schema.patternProperties;
|
|
4652
|
+
const patternKeys = Object.keys(patternProps);
|
|
4653
|
+
const looseRecords = [];
|
|
4654
|
+
for (const pattern of patternKeys) {
|
|
4655
|
+
const patternValue = convertSchema(patternProps[pattern], ctx);
|
|
4656
|
+
const keySchema = z2.string().regex(new RegExp(pattern));
|
|
4657
|
+
looseRecords.push(z2.looseRecord(keySchema, patternValue));
|
|
4658
|
+
}
|
|
4659
|
+
const schemasToIntersect = [];
|
|
4660
|
+
if (Object.keys(shape).length > 0) {
|
|
4661
|
+
schemasToIntersect.push(z2.object(shape).passthrough());
|
|
4662
|
+
}
|
|
4663
|
+
schemasToIntersect.push(...looseRecords);
|
|
4664
|
+
if (schemasToIntersect.length === 0) {
|
|
4665
|
+
zodSchema = z2.object({}).passthrough();
|
|
4666
|
+
} else if (schemasToIntersect.length === 1) {
|
|
4667
|
+
zodSchema = schemasToIntersect[0];
|
|
4668
|
+
} else {
|
|
4669
|
+
let result = z2.intersection(schemasToIntersect[0], schemasToIntersect[1]);
|
|
4670
|
+
for (let i2 = 2;i2 < schemasToIntersect.length; i2++) {
|
|
4671
|
+
result = z2.intersection(result, schemasToIntersect[i2]);
|
|
4672
|
+
}
|
|
4673
|
+
zodSchema = result;
|
|
4674
|
+
}
|
|
4675
|
+
break;
|
|
4729
4676
|
}
|
|
4730
|
-
|
|
4731
|
-
|
|
4732
|
-
|
|
4733
|
-
|
|
4734
|
-
|
|
4735
|
-
}
|
|
4736
|
-
|
|
4677
|
+
const objectSchema = z2.object(shape);
|
|
4678
|
+
if (schema.additionalProperties === false) {
|
|
4679
|
+
zodSchema = objectSchema.strict();
|
|
4680
|
+
} else if (typeof schema.additionalProperties === "object") {
|
|
4681
|
+
zodSchema = objectSchema.catchall(convertSchema(schema.additionalProperties, ctx));
|
|
4682
|
+
} else {
|
|
4683
|
+
zodSchema = objectSchema.passthrough();
|
|
4737
4684
|
}
|
|
4685
|
+
break;
|
|
4738
4686
|
}
|
|
4739
|
-
|
|
4740
|
-
|
|
4741
|
-
|
|
4742
|
-
|
|
4743
|
-
|
|
4744
|
-
|
|
4745
|
-
|
|
4746
|
-
|
|
4747
|
-
|
|
4748
|
-
|
|
4749
|
-
|
|
4750
|
-
|
|
4751
|
-
|
|
4752
|
-
|
|
4753
|
-
if (
|
|
4754
|
-
|
|
4755
|
-
|
|
4756
|
-
|
|
4757
|
-
|
|
4758
|
-
|
|
4759
|
-
|
|
4760
|
-
|
|
4761
|
-
|
|
4762
|
-
|
|
4763
|
-
|
|
4764
|
-
|
|
4765
|
-
|
|
4766
|
-
|
|
4767
|
-
|
|
4768
|
-
|
|
4769
|
-
}
|
|
4770
|
-
}
|
|
4771
|
-
|
|
4772
|
-
|
|
4773
|
-
|
|
4774
|
-
|
|
4775
|
-
|
|
4687
|
+
case "array": {
|
|
4688
|
+
const prefixItems = schema.prefixItems;
|
|
4689
|
+
const items = schema.items;
|
|
4690
|
+
if (prefixItems && Array.isArray(prefixItems)) {
|
|
4691
|
+
const tupleItems = prefixItems.map((item) => convertSchema(item, ctx));
|
|
4692
|
+
const rest = items && typeof items === "object" && !Array.isArray(items) ? convertSchema(items, ctx) : undefined;
|
|
4693
|
+
if (rest) {
|
|
4694
|
+
zodSchema = z2.tuple(tupleItems).rest(rest);
|
|
4695
|
+
} else {
|
|
4696
|
+
zodSchema = z2.tuple(tupleItems);
|
|
4697
|
+
}
|
|
4698
|
+
if (typeof schema.minItems === "number") {
|
|
4699
|
+
zodSchema = zodSchema.check(z2.minLength(schema.minItems));
|
|
4700
|
+
}
|
|
4701
|
+
if (typeof schema.maxItems === "number") {
|
|
4702
|
+
zodSchema = zodSchema.check(z2.maxLength(schema.maxItems));
|
|
4703
|
+
}
|
|
4704
|
+
} else if (Array.isArray(items)) {
|
|
4705
|
+
const tupleItems = items.map((item) => convertSchema(item, ctx));
|
|
4706
|
+
const rest = schema.additionalItems && typeof schema.additionalItems === "object" ? convertSchema(schema.additionalItems, ctx) : undefined;
|
|
4707
|
+
if (rest) {
|
|
4708
|
+
zodSchema = z2.tuple(tupleItems).rest(rest);
|
|
4709
|
+
} else {
|
|
4710
|
+
zodSchema = z2.tuple(tupleItems);
|
|
4711
|
+
}
|
|
4712
|
+
if (typeof schema.minItems === "number") {
|
|
4713
|
+
zodSchema = zodSchema.check(z2.minLength(schema.minItems));
|
|
4714
|
+
}
|
|
4715
|
+
if (typeof schema.maxItems === "number") {
|
|
4716
|
+
zodSchema = zodSchema.check(z2.maxLength(schema.maxItems));
|
|
4717
|
+
}
|
|
4718
|
+
} else if (items !== undefined) {
|
|
4719
|
+
const element = convertSchema(items, ctx);
|
|
4720
|
+
let arraySchema = z2.array(element);
|
|
4721
|
+
if (typeof schema.minItems === "number") {
|
|
4722
|
+
arraySchema = arraySchema.min(schema.minItems);
|
|
4723
|
+
}
|
|
4724
|
+
if (typeof schema.maxItems === "number") {
|
|
4725
|
+
arraySchema = arraySchema.max(schema.maxItems);
|
|
4726
|
+
}
|
|
4727
|
+
zodSchema = arraySchema;
|
|
4728
|
+
} else {
|
|
4729
|
+
zodSchema = z2.array(z2.any());
|
|
4776
4730
|
}
|
|
4731
|
+
break;
|
|
4777
4732
|
}
|
|
4778
|
-
|
|
4733
|
+
default:
|
|
4734
|
+
throw new Error(`Unsupported type: ${type}`);
|
|
4735
|
+
}
|
|
4736
|
+
if (schema.description) {
|
|
4737
|
+
zodSchema = zodSchema.describe(schema.description);
|
|
4738
|
+
}
|
|
4739
|
+
if (schema.default !== undefined) {
|
|
4740
|
+
zodSchema = zodSchema.default(schema.default);
|
|
4741
|
+
}
|
|
4742
|
+
return zodSchema;
|
|
4779
4743
|
}
|
|
4780
|
-
|
|
4781
|
-
|
|
4782
|
-
|
|
4783
|
-
|
|
4784
|
-
|
|
4785
|
-
|
|
4786
|
-
|
|
4787
|
-
|
|
4788
|
-
|
|
4789
|
-
|
|
4790
|
-
|
|
4744
|
+
function convertSchema(schema, ctx) {
|
|
4745
|
+
if (typeof schema === "boolean") {
|
|
4746
|
+
return schema ? z2.any() : z2.never();
|
|
4747
|
+
}
|
|
4748
|
+
let baseSchema = convertBaseSchema(schema, ctx);
|
|
4749
|
+
const hasExplicitType = schema.type || schema.enum !== undefined || schema.const !== undefined;
|
|
4750
|
+
if (schema.anyOf && Array.isArray(schema.anyOf)) {
|
|
4751
|
+
const options = schema.anyOf.map((s2) => convertSchema(s2, ctx));
|
|
4752
|
+
const anyOfUnion = z2.union(options);
|
|
4753
|
+
baseSchema = hasExplicitType ? z2.intersection(baseSchema, anyOfUnion) : anyOfUnion;
|
|
4754
|
+
}
|
|
4755
|
+
if (schema.oneOf && Array.isArray(schema.oneOf)) {
|
|
4756
|
+
const options = schema.oneOf.map((s2) => convertSchema(s2, ctx));
|
|
4757
|
+
const oneOfUnion = z2.xor(options);
|
|
4758
|
+
baseSchema = hasExplicitType ? z2.intersection(baseSchema, oneOfUnion) : oneOfUnion;
|
|
4759
|
+
}
|
|
4760
|
+
if (schema.allOf && Array.isArray(schema.allOf)) {
|
|
4761
|
+
if (schema.allOf.length === 0) {
|
|
4762
|
+
baseSchema = hasExplicitType ? baseSchema : z2.any();
|
|
4763
|
+
} else {
|
|
4764
|
+
let result = hasExplicitType ? baseSchema : convertSchema(schema.allOf[0], ctx);
|
|
4765
|
+
const startIdx = hasExplicitType ? 0 : 1;
|
|
4766
|
+
for (let i2 = startIdx;i2 < schema.allOf.length; i2++) {
|
|
4767
|
+
result = z2.intersection(result, convertSchema(schema.allOf[i2], ctx));
|
|
4768
|
+
}
|
|
4769
|
+
baseSchema = result;
|
|
4791
4770
|
}
|
|
4792
|
-
|
|
4793
|
-
|
|
4794
|
-
|
|
4795
|
-
|
|
4796
|
-
|
|
4771
|
+
}
|
|
4772
|
+
if (schema.nullable === true && ctx.version === "openapi-3.0") {
|
|
4773
|
+
baseSchema = z2.nullable(baseSchema);
|
|
4774
|
+
}
|
|
4775
|
+
if (schema.readOnly === true) {
|
|
4776
|
+
baseSchema = z2.readonly(baseSchema);
|
|
4777
|
+
}
|
|
4778
|
+
const extraMeta = {};
|
|
4779
|
+
const coreMetadataKeys = ["$id", "id", "$comment", "$anchor", "$vocabulary", "$dynamicRef", "$dynamicAnchor"];
|
|
4780
|
+
for (const key of coreMetadataKeys) {
|
|
4781
|
+
if (key in schema) {
|
|
4782
|
+
extraMeta[key] = schema[key];
|
|
4797
4783
|
}
|
|
4798
|
-
return result;
|
|
4799
|
-
} finally {
|
|
4800
|
-
reader.releaseLock();
|
|
4801
4784
|
}
|
|
4802
|
-
|
|
4803
|
-
|
|
4804
|
-
|
|
4805
|
-
|
|
4806
|
-
for (const entry of entries) {
|
|
4807
|
-
const entryStream = controller.add(entry.header);
|
|
4808
|
-
const body = "body" in entry ? entry.body : entry.data;
|
|
4809
|
-
if (!body) {
|
|
4810
|
-
await entryStream.close();
|
|
4811
|
-
continue;
|
|
4812
|
-
}
|
|
4813
|
-
if (body instanceof ReadableStream)
|
|
4814
|
-
await body.pipeTo(entryStream);
|
|
4815
|
-
else if (body instanceof Blob)
|
|
4816
|
-
await body.stream().pipeTo(entryStream);
|
|
4817
|
-
else
|
|
4818
|
-
try {
|
|
4819
|
-
const chunk = await normalizeBody(body);
|
|
4820
|
-
if (chunk.length > 0) {
|
|
4821
|
-
const writer = entryStream.getWriter();
|
|
4822
|
-
await writer.write(chunk);
|
|
4823
|
-
await writer.close();
|
|
4824
|
-
} else
|
|
4825
|
-
await entryStream.close();
|
|
4826
|
-
} catch {
|
|
4827
|
-
throw new TypeError(`Unsupported content type for entry "${entry.header.name}".`);
|
|
4828
|
-
}
|
|
4785
|
+
const contentMetadataKeys = ["contentEncoding", "contentMediaType", "contentSchema"];
|
|
4786
|
+
for (const key of contentMetadataKeys) {
|
|
4787
|
+
if (key in schema) {
|
|
4788
|
+
extraMeta[key] = schema[key];
|
|
4829
4789
|
}
|
|
4830
|
-
})().then(() => controller.finalize()).catch((err) => controller.error(err));
|
|
4831
|
-
return new Uint8Array(await streamToBuffer(readable));
|
|
4832
|
-
}
|
|
4833
|
-
|
|
4834
|
-
class RXAImpl {
|
|
4835
|
-
_buffer;
|
|
4836
|
-
constructor(buffer) {
|
|
4837
|
-
this._buffer = buffer;
|
|
4838
4790
|
}
|
|
4839
|
-
|
|
4840
|
-
|
|
4841
|
-
|
|
4842
|
-
|
|
4843
|
-
controller.enqueue(new Uint8Array(buffer));
|
|
4844
|
-
controller.close();
|
|
4845
|
-
}
|
|
4846
|
-
});
|
|
4791
|
+
for (const key of Object.keys(schema)) {
|
|
4792
|
+
if (!RECOGNIZED_KEYS.has(key)) {
|
|
4793
|
+
extraMeta[key] = schema[key];
|
|
4794
|
+
}
|
|
4847
4795
|
}
|
|
4848
|
-
|
|
4849
|
-
|
|
4796
|
+
if (Object.keys(extraMeta).length > 0) {
|
|
4797
|
+
ctx.registry.add(baseSchema, extraMeta);
|
|
4850
4798
|
}
|
|
4799
|
+
return baseSchema;
|
|
4851
4800
|
}
|
|
4852
|
-
|
|
4853
|
-
|
|
4854
|
-
return
|
|
4855
|
-
|
|
4856
|
-
|
|
4857
|
-
|
|
4801
|
+
function fromJSONSchema(schema, params) {
|
|
4802
|
+
if (typeof schema === "boolean") {
|
|
4803
|
+
return schema ? z2.any() : z2.never();
|
|
4804
|
+
}
|
|
4805
|
+
const version2 = detectVersion(schema, params?.defaultTarget);
|
|
4806
|
+
const defs = schema.$defs || schema.definitions || {};
|
|
4807
|
+
const ctx = {
|
|
4808
|
+
version: version2,
|
|
4809
|
+
defs,
|
|
4810
|
+
refs: new Map,
|
|
4811
|
+
processing: new Set,
|
|
4812
|
+
rootSchema: schema,
|
|
4813
|
+
registry: params?.registry ?? globalRegistry
|
|
4814
|
+
};
|
|
4815
|
+
return convertSchema(schema, ctx);
|
|
4816
|
+
}
|
|
4817
|
+
function string3(params) {
|
|
4818
|
+
return _coercedString(ZodString, params);
|
|
4819
|
+
}
|
|
4820
|
+
function number3(params) {
|
|
4821
|
+
return _coercedNumber(ZodNumber, params);
|
|
4822
|
+
}
|
|
4823
|
+
function boolean3(params) {
|
|
4824
|
+
return _coercedBoolean(ZodBoolean, params);
|
|
4825
|
+
}
|
|
4826
|
+
function bigint3(params) {
|
|
4827
|
+
return _coercedBigint(ZodBigInt, params);
|
|
4828
|
+
}
|
|
4829
|
+
function date4(params) {
|
|
4830
|
+
return _coercedDate(ZodDate, params);
|
|
4831
|
+
}
|
|
4832
|
+
function define(input) {
|
|
4833
|
+
if (input === null || typeof input !== "object") {
|
|
4834
|
+
throw new DefinitionError("definition must be an object");
|
|
4835
|
+
}
|
|
4836
|
+
let validated;
|
|
4837
|
+
try {
|
|
4838
|
+
validated = RXDSchema.parse(input);
|
|
4839
|
+
} catch (e2) {
|
|
4840
|
+
throw new DefinitionError(`Invalid definition: ${e2 instanceof Error ? e2.message : String(e2)}`);
|
|
4841
|
+
}
|
|
4842
|
+
const rxd = Object.assign(Object.create(null), {
|
|
4843
|
+
name: validated.name,
|
|
4844
|
+
type: validated.type,
|
|
4845
|
+
tag: validated.tag ?? validated.version ?? undefined,
|
|
4846
|
+
registry: validated.registry,
|
|
4847
|
+
path: validated.path,
|
|
4848
|
+
description: validated.description,
|
|
4849
|
+
author: validated.author,
|
|
4850
|
+
license: validated.license,
|
|
4851
|
+
keywords: validated.keywords,
|
|
4852
|
+
repository: validated.repository
|
|
4858
4853
|
});
|
|
4859
|
-
|
|
4860
|
-
const gzipBuffer = await gzipAsync(Buffer.from(tarBuffer));
|
|
4861
|
-
return new RXAImpl(gzipBuffer);
|
|
4854
|
+
return rxd;
|
|
4862
4855
|
}
|
|
4863
4856
|
function locate(rxm) {
|
|
4864
4857
|
return {
|
|
4865
|
-
registry: rxm.registry,
|
|
4866
|
-
path: rxm.path,
|
|
4867
|
-
name: rxm.name,
|
|
4868
|
-
tag: rxm.tag
|
|
4858
|
+
registry: rxm.definition.registry,
|
|
4859
|
+
path: rxm.definition.path,
|
|
4860
|
+
name: rxm.definition.name,
|
|
4861
|
+
tag: rxm.definition.tag
|
|
4862
|
+
};
|
|
4863
|
+
}
|
|
4864
|
+
function manifest(rxd) {
|
|
4865
|
+
return {
|
|
4866
|
+
definition: {
|
|
4867
|
+
name: rxd.name,
|
|
4868
|
+
type: rxd.type,
|
|
4869
|
+
tag: rxd.tag ?? "latest",
|
|
4870
|
+
registry: rxd.registry,
|
|
4871
|
+
path: rxd.path,
|
|
4872
|
+
description: rxd.description,
|
|
4873
|
+
author: rxd.author,
|
|
4874
|
+
license: rxd.license,
|
|
4875
|
+
keywords: rxd.keywords,
|
|
4876
|
+
repository: rxd.repository
|
|
4877
|
+
},
|
|
4878
|
+
archive: {},
|
|
4879
|
+
source: {}
|
|
4869
4880
|
};
|
|
4870
4881
|
}
|
|
4871
4882
|
function resource(rxm, rxa) {
|
|
@@ -4877,59 +4888,6 @@ function resource(rxm, rxa) {
|
|
|
4877
4888
|
};
|
|
4878
4889
|
}
|
|
4879
4890
|
|
|
4880
|
-
class TypeHandlerChain {
|
|
4881
|
-
handlers = new Map;
|
|
4882
|
-
constructor() {
|
|
4883
|
-
for (const type of builtinTypes) {
|
|
4884
|
-
this.registerInternal(type);
|
|
4885
|
-
}
|
|
4886
|
-
}
|
|
4887
|
-
static create() {
|
|
4888
|
-
return new TypeHandlerChain;
|
|
4889
|
-
}
|
|
4890
|
-
registerInternal(type) {
|
|
4891
|
-
this.handlers.set(type.name, type);
|
|
4892
|
-
if (type.aliases) {
|
|
4893
|
-
for (const alias of type.aliases) {
|
|
4894
|
-
this.handlers.set(alias, type);
|
|
4895
|
-
}
|
|
4896
|
-
}
|
|
4897
|
-
}
|
|
4898
|
-
register(type) {
|
|
4899
|
-
if (this.handlers.has(type.name)) {
|
|
4900
|
-
throw new ResourceTypeError(`Type '${type.name}' is already registered`);
|
|
4901
|
-
}
|
|
4902
|
-
this.handlers.set(type.name, type);
|
|
4903
|
-
if (type.aliases) {
|
|
4904
|
-
for (const alias of type.aliases) {
|
|
4905
|
-
if (this.handlers.has(alias)) {
|
|
4906
|
-
throw new ResourceTypeError(`Alias '${alias}' conflicts with existing type or alias`);
|
|
4907
|
-
}
|
|
4908
|
-
this.handlers.set(alias, type);
|
|
4909
|
-
}
|
|
4910
|
-
}
|
|
4911
|
-
}
|
|
4912
|
-
canHandle(typeName) {
|
|
4913
|
-
return this.handlers.has(typeName);
|
|
4914
|
-
}
|
|
4915
|
-
getHandler(typeName) {
|
|
4916
|
-
const handler = this.handlers.get(typeName);
|
|
4917
|
-
if (!handler) {
|
|
4918
|
-
throw new ResourceTypeError(`Unsupported resource type: ${typeName}`);
|
|
4919
|
-
}
|
|
4920
|
-
return handler;
|
|
4921
|
-
}
|
|
4922
|
-
getHandlerOrUndefined(typeName) {
|
|
4923
|
-
return this.handlers.get(typeName);
|
|
4924
|
-
}
|
|
4925
|
-
getSupportedTypes() {
|
|
4926
|
-
return Array.from(this.handlers.keys());
|
|
4927
|
-
}
|
|
4928
|
-
clear() {
|
|
4929
|
-
this.handlers.clear();
|
|
4930
|
-
}
|
|
4931
|
-
}
|
|
4932
|
-
|
|
4933
4891
|
class FolderLoader {
|
|
4934
4892
|
async canLoad(source) {
|
|
4935
4893
|
try {
|
|
@@ -4948,7 +4906,7 @@ class FolderLoader {
|
|
|
4948
4906
|
const resourceJsonPath = join(folderPath, "resource.json");
|
|
4949
4907
|
let resourceJson;
|
|
4950
4908
|
try {
|
|
4951
|
-
resourceJson = await
|
|
4909
|
+
resourceJson = await readFile(resourceJsonPath, "utf-8");
|
|
4952
4910
|
} catch (error48) {
|
|
4953
4911
|
throw new ResourceXError(`Failed to read resource.json: ${error48 instanceof Error ? error48.message : String(error48)}`);
|
|
4954
4912
|
}
|
|
@@ -4976,6 +4934,40 @@ class FolderLoader {
|
|
|
4976
4934
|
if (relativePath === "resource.json") {
|
|
4977
4935
|
continue;
|
|
4978
4936
|
}
|
|
4937
|
+
if (entry.isFile()) {
|
|
4938
|
+
files[relativePath] = await readFile(fullPath);
|
|
4939
|
+
} else if (entry.isDirectory()) {
|
|
4940
|
+
const subFiles = await this.readFolderFiles(fullPath, basePath);
|
|
4941
|
+
Object.assign(files, subFiles);
|
|
4942
|
+
}
|
|
4943
|
+
}
|
|
4944
|
+
return files;
|
|
4945
|
+
}
|
|
4946
|
+
}
|
|
4947
|
+
|
|
4948
|
+
class FolderSourceLoader {
|
|
4949
|
+
async canLoad(source) {
|
|
4950
|
+
try {
|
|
4951
|
+
const stats = await stat2(source);
|
|
4952
|
+
return stats.isDirectory();
|
|
4953
|
+
} catch {
|
|
4954
|
+
return false;
|
|
4955
|
+
}
|
|
4956
|
+
}
|
|
4957
|
+
async load(source) {
|
|
4958
|
+
const canLoad = await this.canLoad(source);
|
|
4959
|
+
if (!canLoad) {
|
|
4960
|
+
throw new ResourceXError(`Source is not a directory: ${source}`);
|
|
4961
|
+
}
|
|
4962
|
+
const files = await this.readFolderFiles(source);
|
|
4963
|
+
return { source, files };
|
|
4964
|
+
}
|
|
4965
|
+
async readFolderFiles(folderPath, basePath = folderPath) {
|
|
4966
|
+
const files = {};
|
|
4967
|
+
const entries = await readdir2(folderPath, { withFileTypes: true });
|
|
4968
|
+
for (const entry of entries) {
|
|
4969
|
+
const fullPath = join2(folderPath, entry.name);
|
|
4970
|
+
const relativePath = relative2(basePath, fullPath);
|
|
4979
4971
|
if (entry.isFile()) {
|
|
4980
4972
|
files[relativePath] = await readFile2(fullPath);
|
|
4981
4973
|
} else if (entry.isDirectory()) {
|
|
@@ -5026,6 +5018,7 @@ class MemoryRXAStore {
|
|
|
5026
5018
|
|
|
5027
5019
|
class MemoryRXMStore {
|
|
5028
5020
|
manifests = new Map;
|
|
5021
|
+
latestPointers = new Map;
|
|
5029
5022
|
buildKey(name, tag, registry2) {
|
|
5030
5023
|
return registry2 ? `${registry2}/${name}:${tag}` : `${name}:${tag}`;
|
|
5031
5024
|
}
|
|
@@ -5095,8 +5088,70 @@ class MemoryRXMStore {
|
|
|
5095
5088
|
}
|
|
5096
5089
|
}
|
|
5097
5090
|
}
|
|
5091
|
+
async setLatest(name, tag, registry2) {
|
|
5092
|
+
const key = registry2 ? `${registry2}/${name}` : name;
|
|
5093
|
+
this.latestPointers.set(key, tag);
|
|
5094
|
+
}
|
|
5095
|
+
async getLatest(name, registry2) {
|
|
5096
|
+
const key = registry2 ? `${registry2}/${name}` : name;
|
|
5097
|
+
return this.latestPointers.get(key) ?? null;
|
|
5098
|
+
}
|
|
5099
|
+
clear() {
|
|
5100
|
+
this.manifests.clear();
|
|
5101
|
+
this.latestPointers.clear();
|
|
5102
|
+
}
|
|
5103
|
+
}
|
|
5104
|
+
|
|
5105
|
+
class TypeHandlerChain {
|
|
5106
|
+
handlers = new Map;
|
|
5107
|
+
constructor() {
|
|
5108
|
+
for (const type of builtinTypes) {
|
|
5109
|
+
this.registerInternal(type);
|
|
5110
|
+
}
|
|
5111
|
+
}
|
|
5112
|
+
static create() {
|
|
5113
|
+
return new TypeHandlerChain;
|
|
5114
|
+
}
|
|
5115
|
+
registerInternal(type) {
|
|
5116
|
+
this.handlers.set(type.name, type);
|
|
5117
|
+
if (type.aliases) {
|
|
5118
|
+
for (const alias of type.aliases) {
|
|
5119
|
+
this.handlers.set(alias, type);
|
|
5120
|
+
}
|
|
5121
|
+
}
|
|
5122
|
+
}
|
|
5123
|
+
register(type) {
|
|
5124
|
+
if (this.handlers.has(type.name)) {
|
|
5125
|
+
throw new ResourceTypeError(`Type '${type.name}' is already registered`);
|
|
5126
|
+
}
|
|
5127
|
+
this.handlers.set(type.name, type);
|
|
5128
|
+
if (type.aliases) {
|
|
5129
|
+
for (const alias of type.aliases) {
|
|
5130
|
+
if (this.handlers.has(alias)) {
|
|
5131
|
+
throw new ResourceTypeError(`Alias '${alias}' conflicts with existing type or alias`);
|
|
5132
|
+
}
|
|
5133
|
+
this.handlers.set(alias, type);
|
|
5134
|
+
}
|
|
5135
|
+
}
|
|
5136
|
+
}
|
|
5137
|
+
canHandle(typeName) {
|
|
5138
|
+
return this.handlers.has(typeName);
|
|
5139
|
+
}
|
|
5140
|
+
getHandler(typeName) {
|
|
5141
|
+
const handler = this.handlers.get(typeName);
|
|
5142
|
+
if (!handler) {
|
|
5143
|
+
throw new ResourceTypeError(`Unsupported resource type: ${typeName}`);
|
|
5144
|
+
}
|
|
5145
|
+
return handler;
|
|
5146
|
+
}
|
|
5147
|
+
getHandlerOrUndefined(typeName) {
|
|
5148
|
+
return this.handlers.get(typeName);
|
|
5149
|
+
}
|
|
5150
|
+
getSupportedTypes() {
|
|
5151
|
+
return Array.from(this.handlers.keys());
|
|
5152
|
+
}
|
|
5098
5153
|
clear() {
|
|
5099
|
-
this.
|
|
5154
|
+
this.handlers.clear();
|
|
5100
5155
|
}
|
|
5101
5156
|
}
|
|
5102
5157
|
var __defProp2, __export2 = (target, all) => {
|
|
@@ -5107,7 +5162,7 @@ var __defProp2, __export2 = (target, all) => {
|
|
|
5107
5162
|
configurable: true,
|
|
5108
5163
|
set: (newValue) => all[name] = () => newValue
|
|
5109
5164
|
});
|
|
5110
|
-
},
|
|
5165
|
+
}, BLOCK_SIZE = 512, BLOCK_SIZE_MASK = 511, DEFAULT_FILE_MODE = 420, DEFAULT_DIR_MODE = 493, USTAR_NAME_OFFSET = 0, USTAR_NAME_SIZE = 100, USTAR_MODE_OFFSET = 100, USTAR_MODE_SIZE = 8, USTAR_UID_OFFSET = 108, USTAR_UID_SIZE = 8, USTAR_GID_OFFSET = 116, USTAR_GID_SIZE = 8, USTAR_SIZE_OFFSET = 124, USTAR_SIZE_SIZE = 12, USTAR_MTIME_OFFSET = 136, USTAR_MTIME_SIZE = 12, USTAR_CHECKSUM_OFFSET = 148, USTAR_CHECKSUM_SIZE = 8, USTAR_TYPEFLAG_OFFSET = 156, USTAR_TYPEFLAG_SIZE = 1, USTAR_LINKNAME_OFFSET = 157, USTAR_LINKNAME_SIZE = 100, USTAR_MAGIC_OFFSET = 257, USTAR_MAGIC_SIZE = 6, USTAR_VERSION_OFFSET = 263, USTAR_VERSION_SIZE = 2, USTAR_UNAME_OFFSET = 265, USTAR_UNAME_SIZE = 32, USTAR_GNAME_OFFSET = 297, USTAR_GNAME_SIZE = 32, USTAR_PREFIX_OFFSET = 345, USTAR_PREFIX_SIZE = 155, USTAR_VERSION = "00", USTAR_MAX_UID_GID = 2097151, USTAR_MAX_SIZE = 8589934591, FILE = "file", LINK = "link", SYMLINK = "symlink", DIRECTORY = "directory", TYPEFLAG, ZERO_BLOCK, EMPTY, encoder, decoder, isBodyless = (header) => header.type === DIRECTORY || header.type === SYMLINK || header.type === LINK, CHECKSUM_SPACE = 32, ASCII_ZERO = 48, EOF_BUFFER, gzipAsync, exports_external, exports_core2, NEVER, $brand, $ZodAsyncError, $ZodEncodeError, globalConfig, exports_util, EVALUATING, captureStackTrace, allowsEval, getParsedType = (data) => {
|
|
5111
5166
|
const t2 = typeof data;
|
|
5112
5167
|
switch (t2) {
|
|
5113
5168
|
case "undefined":
|
|
@@ -10785,21 +10840,28 @@ var __defProp2, __export2 = (target, all) => {
|
|
|
10785
10840
|
Codec: ZodCodec,
|
|
10786
10841
|
Boolean: ZodBoolean,
|
|
10787
10842
|
String: ZodString
|
|
10788
|
-
}, ...args), ZodIssueCode, ZodFirstPartyTypeKind, z2, RECOGNIZED_KEYS, exports_coerce,
|
|
10843
|
+
}, ...args), ZodIssueCode, ZodFirstPartyTypeKind, z2, RECOGNIZED_KEYS, exports_coerce, ResourceXError, DefinitionError, RXDSchema, gunzipAsync, RegistryError, textType, jsonType, binaryType, skillType, builtinTypes, ResourceTypeError;
|
|
10789
10844
|
var init_dist = __esm(() => {
|
|
10790
10845
|
__defProp2 = Object.defineProperty;
|
|
10791
|
-
|
|
10792
|
-
|
|
10793
|
-
|
|
10794
|
-
|
|
10795
|
-
|
|
10796
|
-
|
|
10797
|
-
|
|
10798
|
-
|
|
10799
|
-
|
|
10800
|
-
|
|
10801
|
-
|
|
10846
|
+
TYPEFLAG = {
|
|
10847
|
+
file: "0",
|
|
10848
|
+
link: "1",
|
|
10849
|
+
symlink: "2",
|
|
10850
|
+
"character-device": "3",
|
|
10851
|
+
"block-device": "4",
|
|
10852
|
+
directory: "5",
|
|
10853
|
+
fifo: "6",
|
|
10854
|
+
"pax-header": "x",
|
|
10855
|
+
"pax-global-header": "g",
|
|
10856
|
+
"gnu-long-name": "L",
|
|
10857
|
+
"gnu-long-link-name": "K"
|
|
10802
10858
|
};
|
|
10859
|
+
ZERO_BLOCK = new Uint8Array(BLOCK_SIZE);
|
|
10860
|
+
EMPTY = new Uint8Array(0);
|
|
10861
|
+
encoder = new TextEncoder;
|
|
10862
|
+
decoder = new TextDecoder;
|
|
10863
|
+
EOF_BUFFER = new Uint8Array(BLOCK_SIZE * 2);
|
|
10864
|
+
gzipAsync = promisify(gzip);
|
|
10803
10865
|
exports_external = {};
|
|
10804
10866
|
__export2(exports_external, {
|
|
10805
10867
|
xor: () => xor,
|
|
@@ -14761,6 +14823,18 @@ var init_dist = __esm(() => {
|
|
|
14761
14823
|
bigint: () => bigint3
|
|
14762
14824
|
});
|
|
14763
14825
|
config(en_default());
|
|
14826
|
+
ResourceXError = class ResourceXError extends Error {
|
|
14827
|
+
constructor(message, options) {
|
|
14828
|
+
super(message, options);
|
|
14829
|
+
this.name = "ResourceXError";
|
|
14830
|
+
}
|
|
14831
|
+
};
|
|
14832
|
+
DefinitionError = class DefinitionError extends ResourceXError {
|
|
14833
|
+
constructor(message) {
|
|
14834
|
+
super(message);
|
|
14835
|
+
this.name = "DefinitionError";
|
|
14836
|
+
}
|
|
14837
|
+
};
|
|
14764
14838
|
RXDSchema = exports_external.object({
|
|
14765
14839
|
name: exports_external.string().min(1).max(128),
|
|
14766
14840
|
type: exports_external.string().min(1).max(64),
|
|
@@ -14774,30 +14848,11 @@ var init_dist = __esm(() => {
|
|
|
14774
14848
|
keywords: exports_external.array(exports_external.string().max(64)).max(20).optional(),
|
|
14775
14849
|
repository: exports_external.string().max(256).optional()
|
|
14776
14850
|
}).strict();
|
|
14777
|
-
TYPEFLAG = {
|
|
14778
|
-
file: "0",
|
|
14779
|
-
link: "1",
|
|
14780
|
-
symlink: "2",
|
|
14781
|
-
"character-device": "3",
|
|
14782
|
-
"block-device": "4",
|
|
14783
|
-
directory: "5",
|
|
14784
|
-
fifo: "6",
|
|
14785
|
-
"pax-header": "x",
|
|
14786
|
-
"pax-global-header": "g",
|
|
14787
|
-
"gnu-long-name": "L",
|
|
14788
|
-
"gnu-long-link-name": "K"
|
|
14789
|
-
};
|
|
14790
|
-
ZERO_BLOCK = new Uint8Array(BLOCK_SIZE);
|
|
14791
|
-
EMPTY = new Uint8Array(0);
|
|
14792
|
-
encoder = new TextEncoder;
|
|
14793
|
-
decoder = new TextDecoder;
|
|
14794
|
-
EOF_BUFFER = new Uint8Array(BLOCK_SIZE * 2);
|
|
14795
|
-
gzipAsync = promisify(gzip);
|
|
14796
14851
|
gunzipAsync = promisify2(gunzip);
|
|
14797
|
-
|
|
14798
|
-
constructor(message) {
|
|
14799
|
-
super(message);
|
|
14800
|
-
this.name = "
|
|
14852
|
+
RegistryError = class RegistryError extends ResourceXError {
|
|
14853
|
+
constructor(message, options) {
|
|
14854
|
+
super(message, options);
|
|
14855
|
+
this.name = "RegistryError";
|
|
14801
14856
|
}
|
|
14802
14857
|
};
|
|
14803
14858
|
textType = {
|
|
@@ -14887,10 +14942,10 @@ var skill_type_default = {
|
|
|
14887
14942
|
}
|
|
14888
14943
|
};
|
|
14889
14944
|
builtinTypes = [textType, jsonType, binaryType, skillType];
|
|
14890
|
-
|
|
14891
|
-
constructor(message
|
|
14892
|
-
super(message
|
|
14893
|
-
this.name = "
|
|
14945
|
+
ResourceTypeError = class ResourceTypeError extends ResourceXError {
|
|
14946
|
+
constructor(message) {
|
|
14947
|
+
super(message);
|
|
14948
|
+
this.name = "ResourceTypeError";
|
|
14894
14949
|
}
|
|
14895
14950
|
};
|
|
14896
14951
|
});
|
|
@@ -14902,14 +14957,14 @@ __export(exports_dist, {
|
|
|
14902
14957
|
FileSystemRXMStore: () => FileSystemRXMStore,
|
|
14903
14958
|
FileSystemRXAStore: () => FileSystemRXAStore
|
|
14904
14959
|
});
|
|
14905
|
-
import { homedir } from "os";
|
|
14906
|
-
import { join as join3 } from "path";
|
|
14907
|
-
import { mkdir, writeFile, unlink, readdir as readdir2, stat as stat2 } from "fs/promises";
|
|
14908
|
-
import { createReadStream } from "fs";
|
|
14909
14960
|
import { createHash as createHash2 } from "crypto";
|
|
14910
|
-
import {
|
|
14911
|
-
import { mkdir
|
|
14961
|
+
import { createReadStream } from "fs";
|
|
14962
|
+
import { mkdir, readdir as readdir3, stat as stat3, unlink, writeFile } from "fs/promises";
|
|
14963
|
+
import { join as join3 } from "path";
|
|
14964
|
+
import { mkdir as mkdir2, readdir as readdir22, readFile as readFile3, rm, stat as stat22, unlink as unlink2, writeFile as writeFile2 } from "fs/promises";
|
|
14912
14965
|
import { join as join22 } from "path";
|
|
14966
|
+
import { homedir } from "os";
|
|
14967
|
+
import { join as join32 } from "path";
|
|
14913
14968
|
|
|
14914
14969
|
class FileSystemRXAStore {
|
|
14915
14970
|
basePath;
|
|
@@ -14918,7 +14973,7 @@ class FileSystemRXAStore {
|
|
|
14918
14973
|
}
|
|
14919
14974
|
getPath(digest) {
|
|
14920
14975
|
const prefix = digest.substring(7, 9);
|
|
14921
|
-
return
|
|
14976
|
+
return join3(this.basePath, prefix, digest);
|
|
14922
14977
|
}
|
|
14923
14978
|
async get(digest) {
|
|
14924
14979
|
if (!isValidDigest(digest)) {
|
|
@@ -14930,6 +14985,8 @@ class FileSystemRXAStore {
|
|
|
14930
14985
|
const readStream = createReadStream(path);
|
|
14931
14986
|
await new Promise((resolve, reject) => {
|
|
14932
14987
|
readStream.on("data", (chunk) => {
|
|
14988
|
+
if (typeof chunk === "string")
|
|
14989
|
+
chunk = Buffer.from(chunk);
|
|
14933
14990
|
chunks.push(chunk);
|
|
14934
14991
|
hash2.update(chunk);
|
|
14935
14992
|
});
|
|
@@ -14948,7 +15005,7 @@ class FileSystemRXAStore {
|
|
|
14948
15005
|
if (await this.has(digest)) {
|
|
14949
15006
|
return digest;
|
|
14950
15007
|
}
|
|
14951
|
-
const dir =
|
|
15008
|
+
const dir = join3(path, "..");
|
|
14952
15009
|
await mkdir(dir, { recursive: true });
|
|
14953
15010
|
await writeFile(path, data);
|
|
14954
15011
|
return digest;
|
|
@@ -14956,7 +15013,7 @@ class FileSystemRXAStore {
|
|
|
14956
15013
|
async has(digest) {
|
|
14957
15014
|
const path = this.getPath(digest);
|
|
14958
15015
|
try {
|
|
14959
|
-
await
|
|
15016
|
+
await stat3(path);
|
|
14960
15017
|
return true;
|
|
14961
15018
|
} catch {
|
|
14962
15019
|
return false;
|
|
@@ -14971,11 +15028,11 @@ class FileSystemRXAStore {
|
|
|
14971
15028
|
async list() {
|
|
14972
15029
|
const digests = [];
|
|
14973
15030
|
try {
|
|
14974
|
-
const prefixes = await
|
|
15031
|
+
const prefixes = await readdir3(this.basePath);
|
|
14975
15032
|
for (const prefix of prefixes) {
|
|
14976
|
-
const prefixPath =
|
|
15033
|
+
const prefixPath = join3(this.basePath, prefix);
|
|
14977
15034
|
try {
|
|
14978
|
-
const files = await
|
|
15035
|
+
const files = await readdir3(prefixPath);
|
|
14979
15036
|
for (const file2 of files) {
|
|
14980
15037
|
if (file2.startsWith("sha256:")) {
|
|
14981
15038
|
digests.push(file2);
|
|
@@ -15003,7 +15060,7 @@ class FileSystemRXMStore {
|
|
|
15003
15060
|
async get(name, tag, registry2) {
|
|
15004
15061
|
const path = this.getPath(name, tag, registry2);
|
|
15005
15062
|
try {
|
|
15006
|
-
const data = await
|
|
15063
|
+
const data = await readFile3(path, "utf-8");
|
|
15007
15064
|
return JSON.parse(data);
|
|
15008
15065
|
} catch {
|
|
15009
15066
|
return null;
|
|
@@ -15043,6 +15100,19 @@ class FileSystemRXMStore {
|
|
|
15043
15100
|
} catch {}
|
|
15044
15101
|
return tags;
|
|
15045
15102
|
}
|
|
15103
|
+
async setLatest(name, tag, registry2) {
|
|
15104
|
+
const dir = this.getDir(name, registry2);
|
|
15105
|
+
await mkdir2(dir, { recursive: true });
|
|
15106
|
+
await writeFile2(join22(dir, LATEST_FILE), tag, "utf-8");
|
|
15107
|
+
}
|
|
15108
|
+
async getLatest(name, registry2) {
|
|
15109
|
+
const dir = this.getDir(name, registry2);
|
|
15110
|
+
try {
|
|
15111
|
+
return (await readFile3(join22(dir, LATEST_FILE), "utf-8")).trim();
|
|
15112
|
+
} catch {
|
|
15113
|
+
return null;
|
|
15114
|
+
}
|
|
15115
|
+
}
|
|
15046
15116
|
async listNames(registry2, query) {
|
|
15047
15117
|
const registryDir = registry2 ?? LOCAL_DIR;
|
|
15048
15118
|
const basePath = join22(this.basePath, registryDir);
|
|
@@ -15092,7 +15162,7 @@ class FileSystemRXMStore {
|
|
|
15092
15162
|
for (const file2 of files) {
|
|
15093
15163
|
if (file2.endsWith(".json")) {
|
|
15094
15164
|
const filePath = join22(namePath, file2);
|
|
15095
|
-
const data = await
|
|
15165
|
+
const data = await readFile3(filePath, "utf-8");
|
|
15096
15166
|
const manifest2 = JSON.parse(data);
|
|
15097
15167
|
results.push(manifest2);
|
|
15098
15168
|
}
|
|
@@ -15120,15 +15190,18 @@ class NodeProvider {
|
|
|
15120
15190
|
createStores(config2) {
|
|
15121
15191
|
const basePath = config2.path ?? DEFAULT_BASE_PATH;
|
|
15122
15192
|
return {
|
|
15123
|
-
rxaStore: new FileSystemRXAStore(
|
|
15124
|
-
rxmStore: new FileSystemRXMStore(
|
|
15193
|
+
rxaStore: new FileSystemRXAStore(join32(basePath, "blobs")),
|
|
15194
|
+
rxmStore: new FileSystemRXMStore(join32(basePath, "manifests"))
|
|
15125
15195
|
};
|
|
15126
15196
|
}
|
|
15127
15197
|
createLoader(_config) {
|
|
15128
15198
|
return new FolderLoader;
|
|
15129
15199
|
}
|
|
15200
|
+
createSourceLoader(_config) {
|
|
15201
|
+
return new FolderSourceLoader;
|
|
15202
|
+
}
|
|
15130
15203
|
}
|
|
15131
|
-
var LOCAL_DIR = "_local", DEFAULT_BASE_PATH;
|
|
15204
|
+
var LOCAL_DIR = "_local", LATEST_FILE = ".latest", DEFAULT_BASE_PATH;
|
|
15132
15205
|
var init_dist2 = __esm(() => {
|
|
15133
15206
|
init_dist();
|
|
15134
15207
|
init_dist();
|
|
@@ -15624,12 +15697,12 @@ var init_dist3 = __esm(() => {
|
|
|
15624
15697
|
}
|
|
15625
15698
|
}
|
|
15626
15699
|
get headers() {
|
|
15627
|
-
const
|
|
15628
|
-
if (
|
|
15629
|
-
if (!(
|
|
15630
|
-
|
|
15700
|
+
const cache2 = this[cacheKey];
|
|
15701
|
+
if (cache2) {
|
|
15702
|
+
if (!(cache2[2] instanceof Headers)) {
|
|
15703
|
+
cache2[2] = new Headers(cache2[2]);
|
|
15631
15704
|
}
|
|
15632
|
-
return
|
|
15705
|
+
return cache2[2];
|
|
15633
15706
|
}
|
|
15634
15707
|
return this[getResponseCache]().headers;
|
|
15635
15708
|
}
|
|
@@ -17068,14 +17141,14 @@ import { createResourceX, setProvider } from "resourcexjs";
|
|
|
17068
17141
|
|
|
17069
17142
|
// src/lib/paths.ts
|
|
17070
17143
|
import { homedir as homedir2 } from "os";
|
|
17071
|
-
import { join as
|
|
17072
|
-
var RX_HOME = process.env.RX_HOME ||
|
|
17144
|
+
import { join as join5 } from "path";
|
|
17145
|
+
var RX_HOME = process.env.RX_HOME || join5(homedir2(), ".resourcex");
|
|
17073
17146
|
var PATHS = {
|
|
17074
17147
|
root: RX_HOME,
|
|
17075
|
-
config:
|
|
17076
|
-
local:
|
|
17077
|
-
cache:
|
|
17078
|
-
linked:
|
|
17148
|
+
config: join5(RX_HOME, "config.json"),
|
|
17149
|
+
local: join5(RX_HOME, "local"),
|
|
17150
|
+
cache: join5(RX_HOME, "cache"),
|
|
17151
|
+
linked: join5(RX_HOME, "linked")
|
|
17079
17152
|
};
|
|
17080
17153
|
|
|
17081
17154
|
// src/lib/config.ts
|
|
@@ -17209,12 +17282,9 @@ var add = defineCommand({
|
|
|
17209
17282
|
consola.success(`Added resource:
|
|
17210
17283
|
`);
|
|
17211
17284
|
console.log(` Locator: ${resource2.locator}`);
|
|
17212
|
-
console.log(` Name: ${resource2.name}`);
|
|
17213
|
-
console.log(` Type: ${resource2.type}`);
|
|
17214
|
-
console.log(` Tag: ${resource2.tag}`);
|
|
17215
|
-
if (resource2.files?.length) {
|
|
17216
|
-
console.log(` Files: ${resource2.files.join(", ")}`);
|
|
17217
|
-
}
|
|
17285
|
+
console.log(` Name: ${resource2.definition.name}`);
|
|
17286
|
+
console.log(` Type: ${resource2.definition.type}`);
|
|
17287
|
+
console.log(` Tag: ${resource2.definition.tag}`);
|
|
17218
17288
|
} catch (error48) {
|
|
17219
17289
|
consola.error(error48 instanceof Error ? error48.message : "Failed to add resource");
|
|
17220
17290
|
process.exit(1);
|
|
@@ -17222,36 +17292,93 @@ var add = defineCommand({
|
|
|
17222
17292
|
}
|
|
17223
17293
|
});
|
|
17224
17294
|
|
|
17225
|
-
// src/commands/
|
|
17226
|
-
var
|
|
17295
|
+
// src/commands/cache.ts
|
|
17296
|
+
var clear = defineCommand({
|
|
17227
17297
|
meta: {
|
|
17228
|
-
name: "
|
|
17229
|
-
description: "
|
|
17298
|
+
name: "clear",
|
|
17299
|
+
description: "Clear all cached resources"
|
|
17230
17300
|
},
|
|
17231
17301
|
args: {
|
|
17232
|
-
|
|
17233
|
-
type: "
|
|
17234
|
-
|
|
17235
|
-
|
|
17302
|
+
registry: {
|
|
17303
|
+
type: "string",
|
|
17304
|
+
alias: "r",
|
|
17305
|
+
description: "Only clear resources from this registry"
|
|
17236
17306
|
}
|
|
17237
17307
|
},
|
|
17238
17308
|
async run({ args }) {
|
|
17239
17309
|
try {
|
|
17240
17310
|
const rx = await getClient();
|
|
17241
|
-
|
|
17242
|
-
if (
|
|
17243
|
-
consola.
|
|
17244
|
-
|
|
17245
|
-
|
|
17246
|
-
consola.info(`Found ${results.length} resource(s):
|
|
17247
|
-
`);
|
|
17248
|
-
for (const locator of results) {
|
|
17249
|
-
console.log(` ${locator}`);
|
|
17311
|
+
await rx.clearCache(args.registry);
|
|
17312
|
+
if (args.registry) {
|
|
17313
|
+
consola.success(`Cleared cache for registry: ${args.registry}`);
|
|
17314
|
+
} else {
|
|
17315
|
+
consola.success("Cleared all cached resources");
|
|
17250
17316
|
}
|
|
17251
17317
|
} catch (error48) {
|
|
17252
|
-
consola.error(error48 instanceof Error ? error48.message : "Failed to
|
|
17318
|
+
consola.error(error48 instanceof Error ? error48.message : "Failed to clear cache");
|
|
17319
|
+
process.exit(1);
|
|
17320
|
+
}
|
|
17321
|
+
}
|
|
17322
|
+
});
|
|
17323
|
+
var cache = defineCommand({
|
|
17324
|
+
meta: {
|
|
17325
|
+
name: "cache",
|
|
17326
|
+
description: "Manage cached resources"
|
|
17327
|
+
},
|
|
17328
|
+
subCommands: {
|
|
17329
|
+
clear
|
|
17330
|
+
}
|
|
17331
|
+
});
|
|
17332
|
+
|
|
17333
|
+
// src/commands/config.ts
|
|
17334
|
+
var set2 = defineCommand({
|
|
17335
|
+
meta: {
|
|
17336
|
+
name: "set",
|
|
17337
|
+
description: "Set configuration value"
|
|
17338
|
+
},
|
|
17339
|
+
args: {
|
|
17340
|
+
key: {
|
|
17341
|
+
type: "positional",
|
|
17342
|
+
description: "Configuration key (path, registry)",
|
|
17343
|
+
required: true
|
|
17344
|
+
},
|
|
17345
|
+
value: {
|
|
17346
|
+
type: "positional",
|
|
17347
|
+
description: "Configuration value",
|
|
17348
|
+
required: true
|
|
17349
|
+
}
|
|
17350
|
+
},
|
|
17351
|
+
async run({ args }) {
|
|
17352
|
+
const validKeys = ["path", "registry"];
|
|
17353
|
+
if (!validKeys.includes(args.key)) {
|
|
17354
|
+
consola.error(`Invalid key: ${args.key}. Valid keys: ${validKeys.join(", ")}`);
|
|
17253
17355
|
process.exit(1);
|
|
17254
17356
|
}
|
|
17357
|
+
await setConfig(args.key, args.value);
|
|
17358
|
+
consola.success(`Set ${args.key} = ${args.value}`);
|
|
17359
|
+
}
|
|
17360
|
+
});
|
|
17361
|
+
var list = defineCommand({
|
|
17362
|
+
meta: {
|
|
17363
|
+
name: "list",
|
|
17364
|
+
description: "List configuration"
|
|
17365
|
+
},
|
|
17366
|
+
async run() {
|
|
17367
|
+
const config2 = await getConfig();
|
|
17368
|
+
consola.info(`Configuration:
|
|
17369
|
+
`);
|
|
17370
|
+
console.log(` path: ${config2.path}`);
|
|
17371
|
+
console.log(` registry: ${config2.registry || "(not set)"}`);
|
|
17372
|
+
}
|
|
17373
|
+
});
|
|
17374
|
+
var config2 = defineCommand({
|
|
17375
|
+
meta: {
|
|
17376
|
+
name: "config",
|
|
17377
|
+
description: "Manage CLI configuration"
|
|
17378
|
+
},
|
|
17379
|
+
subCommands: {
|
|
17380
|
+
set: set2,
|
|
17381
|
+
list
|
|
17255
17382
|
}
|
|
17256
17383
|
});
|
|
17257
17384
|
|
|
@@ -17272,24 +17399,40 @@ var info = defineCommand({
|
|
|
17272
17399
|
try {
|
|
17273
17400
|
const rx = await getClient();
|
|
17274
17401
|
const resource2 = await rx.info(args.locator);
|
|
17402
|
+
const { definition, source } = resource2;
|
|
17275
17403
|
console.log();
|
|
17276
|
-
console.log(` ${
|
|
17404
|
+
console.log(` ${definition.name}:${definition.tag}`);
|
|
17277
17405
|
console.log(` ${"\u2500".repeat(40)}`);
|
|
17278
17406
|
console.log();
|
|
17279
17407
|
console.log(` Locator: ${resource2.locator}`);
|
|
17280
|
-
if (
|
|
17281
|
-
console.log(` Registry: ${
|
|
17408
|
+
if (definition.registry) {
|
|
17409
|
+
console.log(` Registry: ${definition.registry}`);
|
|
17410
|
+
}
|
|
17411
|
+
if (definition.path) {
|
|
17412
|
+
console.log(` Path: ${definition.path}`);
|
|
17282
17413
|
}
|
|
17283
|
-
|
|
17284
|
-
|
|
17414
|
+
console.log(` Name: ${definition.name}`);
|
|
17415
|
+
console.log(` Type: ${definition.type}`);
|
|
17416
|
+
console.log(` Tag: ${definition.tag}`);
|
|
17417
|
+
if (definition.description) {
|
|
17418
|
+
console.log(` Desc: ${definition.description}`);
|
|
17419
|
+
}
|
|
17420
|
+
if (definition.author) {
|
|
17421
|
+
console.log(` Author: ${definition.author}`);
|
|
17285
17422
|
}
|
|
17286
|
-
console.log(` Name: ${resource2.name}`);
|
|
17287
|
-
console.log(` Type: ${resource2.type}`);
|
|
17288
|
-
console.log(` Tag: ${resource2.tag}`);
|
|
17289
17423
|
console.log();
|
|
17290
|
-
if (
|
|
17424
|
+
if (source.files && Object.keys(source.files).length > 0) {
|
|
17291
17425
|
console.log(` Files:`);
|
|
17292
|
-
printFileTree(
|
|
17426
|
+
printFileTree(source.files);
|
|
17427
|
+
}
|
|
17428
|
+
if (source.preview) {
|
|
17429
|
+
console.log();
|
|
17430
|
+
console.log(` Preview:`);
|
|
17431
|
+
const lines = source.preview.split(`
|
|
17432
|
+
`).slice(0, 5);
|
|
17433
|
+
for (const line of lines) {
|
|
17434
|
+
console.log(` ${line}`);
|
|
17435
|
+
}
|
|
17293
17436
|
}
|
|
17294
17437
|
console.log();
|
|
17295
17438
|
} catch (error48) {
|
|
@@ -17298,113 +17441,60 @@ var info = defineCommand({
|
|
|
17298
17441
|
}
|
|
17299
17442
|
}
|
|
17300
17443
|
});
|
|
17301
|
-
function
|
|
17302
|
-
|
|
17303
|
-
|
|
17304
|
-
|
|
17305
|
-
|
|
17306
|
-
|
|
17307
|
-
|
|
17308
|
-
|
|
17309
|
-
} else {
|
|
17310
|
-
const dir = parts[0];
|
|
17311
|
-
const rest = parts.slice(1).join("/");
|
|
17312
|
-
if (!tree[dir]) {
|
|
17313
|
-
tree[dir] = [];
|
|
17314
|
-
}
|
|
17315
|
-
tree[dir].push(rest);
|
|
17316
|
-
}
|
|
17317
|
-
}
|
|
17318
|
-
const dirs = Object.keys(tree).sort();
|
|
17319
|
-
const allItems = [...dirs, ...rootFiles];
|
|
17320
|
-
for (let i2 = 0;i2 < allItems.length; i2++) {
|
|
17321
|
-
const item = allItems[i2];
|
|
17322
|
-
const isLast = i2 === allItems.length - 1;
|
|
17444
|
+
function isFileEntry(value) {
|
|
17445
|
+
return "size" in value && typeof value.size === "number";
|
|
17446
|
+
}
|
|
17447
|
+
function printFileTree(tree, indent = "") {
|
|
17448
|
+
const entries = Object.entries(tree);
|
|
17449
|
+
for (let i2 = 0;i2 < entries.length; i2++) {
|
|
17450
|
+
const [name, value] = entries[i2];
|
|
17451
|
+
const isLast = i2 === entries.length - 1;
|
|
17323
17452
|
const prefix = isLast ? "\u2514\u2500\u2500 " : "\u251C\u2500\u2500 ";
|
|
17324
|
-
|
|
17325
|
-
|
|
17326
|
-
|
|
17453
|
+
const childIndent = indent + (isLast ? " " : "\u2502 ");
|
|
17454
|
+
if (isFileEntry(value)) {
|
|
17455
|
+
console.log(` ${indent}${prefix}${name} (${formatSize(value.size)})`);
|
|
17327
17456
|
} else {
|
|
17328
|
-
console.log(` ${prefix}${
|
|
17457
|
+
console.log(` ${indent}${prefix}${name}`);
|
|
17458
|
+
printFileTree(value, childIndent);
|
|
17329
17459
|
}
|
|
17330
17460
|
}
|
|
17331
17461
|
}
|
|
17332
|
-
function
|
|
17333
|
-
|
|
17334
|
-
|
|
17335
|
-
|
|
17336
|
-
|
|
17337
|
-
|
|
17338
|
-
}
|
|
17462
|
+
function formatSize(bytes) {
|
|
17463
|
+
if (bytes < 1024)
|
|
17464
|
+
return `${bytes}B`;
|
|
17465
|
+
if (bytes < 1024 * 1024)
|
|
17466
|
+
return `${(bytes / 1024).toFixed(1)}KB`;
|
|
17467
|
+
return `${(bytes / (1024 * 1024)).toFixed(1)}MB`;
|
|
17339
17468
|
}
|
|
17340
17469
|
|
|
17341
|
-
// src/commands/
|
|
17342
|
-
var
|
|
17470
|
+
// src/commands/list.ts
|
|
17471
|
+
var list2 = defineCommand({
|
|
17343
17472
|
meta: {
|
|
17344
|
-
name: "
|
|
17345
|
-
description: "
|
|
17473
|
+
name: "list",
|
|
17474
|
+
description: "List local resources"
|
|
17346
17475
|
},
|
|
17347
17476
|
args: {
|
|
17348
|
-
|
|
17477
|
+
query: {
|
|
17349
17478
|
type: "positional",
|
|
17350
|
-
description: "
|
|
17351
|
-
required:
|
|
17479
|
+
description: "Optional search query",
|
|
17480
|
+
required: false
|
|
17352
17481
|
}
|
|
17353
17482
|
},
|
|
17354
17483
|
async run({ args }) {
|
|
17355
17484
|
try {
|
|
17356
17485
|
const rx = await getClient();
|
|
17357
|
-
const
|
|
17358
|
-
if (
|
|
17359
|
-
consola.
|
|
17486
|
+
const results = await rx.search(args.query);
|
|
17487
|
+
if (results.length === 0) {
|
|
17488
|
+
consola.info("No resources found");
|
|
17360
17489
|
return;
|
|
17361
17490
|
}
|
|
17362
|
-
|
|
17363
|
-
|
|
17364
|
-
|
|
17365
|
-
|
|
17366
|
-
process.exit(1);
|
|
17367
|
-
}
|
|
17368
|
-
}
|
|
17369
|
-
});
|
|
17370
|
-
|
|
17371
|
-
// src/commands/push.ts
|
|
17372
|
-
var push = defineCommand({
|
|
17373
|
-
meta: {
|
|
17374
|
-
name: "push",
|
|
17375
|
-
description: "Push local resource to remote registry"
|
|
17376
|
-
},
|
|
17377
|
-
args: {
|
|
17378
|
-
locator: {
|
|
17379
|
-
type: "positional",
|
|
17380
|
-
description: "Resource locator (e.g., hello.text@1.0.0)",
|
|
17381
|
-
required: true
|
|
17382
|
-
},
|
|
17383
|
-
registry: {
|
|
17384
|
-
type: "string",
|
|
17385
|
-
alias: "r",
|
|
17386
|
-
description: "Registry name or URL (overrides default)"
|
|
17387
|
-
}
|
|
17388
|
-
},
|
|
17389
|
-
async run({ args }) {
|
|
17390
|
-
try {
|
|
17391
|
-
let registryUrl;
|
|
17392
|
-
if (args.registry) {
|
|
17393
|
-
const entry = await getRegistryByName(args.registry);
|
|
17394
|
-
registryUrl = entry ? entry.url : args.registry;
|
|
17395
|
-
} else {
|
|
17396
|
-
const config2 = await getConfig();
|
|
17397
|
-
registryUrl = config2.registry;
|
|
17398
|
-
}
|
|
17399
|
-
if (!registryUrl) {
|
|
17400
|
-
consola.error("No registry configured. Use: rx registry add <name> <url> or --registry <name|url>");
|
|
17401
|
-
process.exit(1);
|
|
17491
|
+
consola.info(`Found ${results.length} resource(s):
|
|
17492
|
+
`);
|
|
17493
|
+
for (const locator of results) {
|
|
17494
|
+
console.log(` ${locator}`);
|
|
17402
17495
|
}
|
|
17403
|
-
const rx = await getClient({ registry: registryUrl });
|
|
17404
|
-
await rx.push(args.locator);
|
|
17405
|
-
consola.success(`Pushed: ${args.locator}`);
|
|
17406
17496
|
} catch (error48) {
|
|
17407
|
-
consola.error(error48 instanceof Error ? error48.message : "Failed to
|
|
17497
|
+
consola.error(error48 instanceof Error ? error48.message : "Failed to list resources");
|
|
17408
17498
|
process.exit(1);
|
|
17409
17499
|
}
|
|
17410
17500
|
}
|
|
@@ -17430,8 +17520,8 @@ var pull = defineCommand({
|
|
|
17430
17520
|
},
|
|
17431
17521
|
async run({ args }) {
|
|
17432
17522
|
try {
|
|
17433
|
-
const
|
|
17434
|
-
const registryUrl = args.registry ??
|
|
17523
|
+
const config3 = await getConfig();
|
|
17524
|
+
const registryUrl = args.registry ?? config3.registry;
|
|
17435
17525
|
if (!registryUrl) {
|
|
17436
17526
|
consola.error("No registry configured. Use: rx config set registry <url> or --registry <url>");
|
|
17437
17527
|
process.exit(1);
|
|
@@ -17446,141 +17536,45 @@ var pull = defineCommand({
|
|
|
17446
17536
|
}
|
|
17447
17537
|
});
|
|
17448
17538
|
|
|
17449
|
-
// src/commands/
|
|
17450
|
-
|
|
17451
|
-
var search = defineCommand({
|
|
17452
|
-
meta: {
|
|
17453
|
-
name: "search",
|
|
17454
|
-
description: "Search remote registry"
|
|
17455
|
-
},
|
|
17456
|
-
args: {
|
|
17457
|
-
query: {
|
|
17458
|
-
type: "positional",
|
|
17459
|
-
description: "Search query",
|
|
17460
|
-
required: true
|
|
17461
|
-
},
|
|
17462
|
-
limit: {
|
|
17463
|
-
type: "string",
|
|
17464
|
-
description: "Maximum results",
|
|
17465
|
-
default: "20"
|
|
17466
|
-
}
|
|
17467
|
-
},
|
|
17468
|
-
async run({ args }) {
|
|
17469
|
-
try {
|
|
17470
|
-
const config2 = await getConfig();
|
|
17471
|
-
if (!config2.registry) {
|
|
17472
|
-
consola.error("No registry configured. Use: rx config set registry <url>");
|
|
17473
|
-
process.exit(1);
|
|
17474
|
-
}
|
|
17475
|
-
const url2 = buildSearchUrl(config2.registry, {
|
|
17476
|
-
q: args.query,
|
|
17477
|
-
limit: Number(args.limit)
|
|
17478
|
-
});
|
|
17479
|
-
const response = await fetch(url2);
|
|
17480
|
-
if (!response.ok) {
|
|
17481
|
-
throw new Error(`Search failed: ${response.statusText}`);
|
|
17482
|
-
}
|
|
17483
|
-
const data = await response.json();
|
|
17484
|
-
if (data.results.length === 0) {
|
|
17485
|
-
consola.info("No resources found");
|
|
17486
|
-
return;
|
|
17487
|
-
}
|
|
17488
|
-
consola.info(`Found ${data.total} resource(s):
|
|
17489
|
-
`);
|
|
17490
|
-
for (const item of data.results) {
|
|
17491
|
-
console.log(` ${item.locator}`);
|
|
17492
|
-
if (item.type) {
|
|
17493
|
-
console.log(` type: ${item.type}`);
|
|
17494
|
-
}
|
|
17495
|
-
}
|
|
17496
|
-
} catch (error48) {
|
|
17497
|
-
consola.error(error48 instanceof Error ? error48.message : "Search failed");
|
|
17498
|
-
process.exit(1);
|
|
17499
|
-
}
|
|
17500
|
-
}
|
|
17501
|
-
});
|
|
17502
|
-
|
|
17503
|
-
// src/commands/use.ts
|
|
17504
|
-
var use = defineCommand({
|
|
17539
|
+
// src/commands/push.ts
|
|
17540
|
+
var push = defineCommand({
|
|
17505
17541
|
meta: {
|
|
17506
|
-
name: "
|
|
17507
|
-
description: "
|
|
17542
|
+
name: "push",
|
|
17543
|
+
description: "Push local resource to remote registry"
|
|
17508
17544
|
},
|
|
17509
17545
|
args: {
|
|
17510
17546
|
locator: {
|
|
17511
17547
|
type: "positional",
|
|
17512
17548
|
description: "Resource locator (e.g., hello.text@1.0.0)",
|
|
17513
17549
|
required: true
|
|
17550
|
+
},
|
|
17551
|
+
registry: {
|
|
17552
|
+
type: "string",
|
|
17553
|
+
alias: "r",
|
|
17554
|
+
description: "Registry name or URL (overrides default)"
|
|
17514
17555
|
}
|
|
17515
17556
|
},
|
|
17516
17557
|
async run({ args }) {
|
|
17517
17558
|
try {
|
|
17518
|
-
|
|
17519
|
-
|
|
17520
|
-
|
|
17521
|
-
|
|
17522
|
-
console.log(result);
|
|
17523
|
-
} else if (result instanceof Uint8Array) {
|
|
17524
|
-
process.stdout.write(result);
|
|
17559
|
+
let registryUrl;
|
|
17560
|
+
if (args.registry) {
|
|
17561
|
+
const entry = await getRegistryByName(args.registry);
|
|
17562
|
+
registryUrl = entry ? entry.url : args.registry;
|
|
17525
17563
|
} else {
|
|
17526
|
-
|
|
17564
|
+
const config3 = await getConfig();
|
|
17565
|
+
registryUrl = config3.registry;
|
|
17527
17566
|
}
|
|
17567
|
+
if (!registryUrl) {
|
|
17568
|
+
consola.error("No registry configured. Use: rx registry add <name> <url> or --registry <name|url>");
|
|
17569
|
+
process.exit(1);
|
|
17570
|
+
}
|
|
17571
|
+
const rx = await getClient({ registry: registryUrl });
|
|
17572
|
+
await rx.push(args.locator);
|
|
17573
|
+
consola.success(`Pushed: ${args.locator}`);
|
|
17528
17574
|
} catch (error48) {
|
|
17529
|
-
consola.error(error48 instanceof Error ? error48.message : "Failed to
|
|
17530
|
-
process.exit(1);
|
|
17531
|
-
}
|
|
17532
|
-
}
|
|
17533
|
-
});
|
|
17534
|
-
|
|
17535
|
-
// src/commands/config.ts
|
|
17536
|
-
var set2 = defineCommand({
|
|
17537
|
-
meta: {
|
|
17538
|
-
name: "set",
|
|
17539
|
-
description: "Set configuration value"
|
|
17540
|
-
},
|
|
17541
|
-
args: {
|
|
17542
|
-
key: {
|
|
17543
|
-
type: "positional",
|
|
17544
|
-
description: "Configuration key (path, registry)",
|
|
17545
|
-
required: true
|
|
17546
|
-
},
|
|
17547
|
-
value: {
|
|
17548
|
-
type: "positional",
|
|
17549
|
-
description: "Configuration value",
|
|
17550
|
-
required: true
|
|
17551
|
-
}
|
|
17552
|
-
},
|
|
17553
|
-
async run({ args }) {
|
|
17554
|
-
const validKeys = ["path", "registry"];
|
|
17555
|
-
if (!validKeys.includes(args.key)) {
|
|
17556
|
-
consola.error(`Invalid key: ${args.key}. Valid keys: ${validKeys.join(", ")}`);
|
|
17575
|
+
consola.error(error48 instanceof Error ? error48.message : "Failed to push resource");
|
|
17557
17576
|
process.exit(1);
|
|
17558
17577
|
}
|
|
17559
|
-
await setConfig(args.key, args.value);
|
|
17560
|
-
consola.success(`Set ${args.key} = ${args.value}`);
|
|
17561
|
-
}
|
|
17562
|
-
});
|
|
17563
|
-
var list2 = defineCommand({
|
|
17564
|
-
meta: {
|
|
17565
|
-
name: "list",
|
|
17566
|
-
description: "List configuration"
|
|
17567
|
-
},
|
|
17568
|
-
async run() {
|
|
17569
|
-
const config2 = await getConfig();
|
|
17570
|
-
consola.info(`Configuration:
|
|
17571
|
-
`);
|
|
17572
|
-
console.log(` path: ${config2.path}`);
|
|
17573
|
-
console.log(` registry: ${config2.registry || "(not set)"}`);
|
|
17574
|
-
}
|
|
17575
|
-
});
|
|
17576
|
-
var config2 = defineCommand({
|
|
17577
|
-
meta: {
|
|
17578
|
-
name: "config",
|
|
17579
|
-
description: "Manage CLI configuration"
|
|
17580
|
-
},
|
|
17581
|
-
subCommands: {
|
|
17582
|
-
set: set2,
|
|
17583
|
-
list: list2
|
|
17584
17578
|
}
|
|
17585
17579
|
});
|
|
17586
17580
|
|
|
@@ -17620,7 +17614,7 @@ var add2 = defineCommand({
|
|
|
17620
17614
|
}
|
|
17621
17615
|
}
|
|
17622
17616
|
});
|
|
17623
|
-
var
|
|
17617
|
+
var remove = defineCommand({
|
|
17624
17618
|
meta: {
|
|
17625
17619
|
name: "remove",
|
|
17626
17620
|
description: "Remove a registry"
|
|
@@ -17690,12 +17684,96 @@ var registry2 = defineCommand({
|
|
|
17690
17684
|
},
|
|
17691
17685
|
subCommands: {
|
|
17692
17686
|
add: add2,
|
|
17693
|
-
remove
|
|
17687
|
+
remove,
|
|
17694
17688
|
list: listCmd,
|
|
17695
17689
|
default: defaultCmd
|
|
17696
17690
|
}
|
|
17697
17691
|
});
|
|
17698
17692
|
|
|
17693
|
+
// src/commands/remove.ts
|
|
17694
|
+
var remove2 = defineCommand({
|
|
17695
|
+
meta: {
|
|
17696
|
+
name: "remove",
|
|
17697
|
+
description: "Remove resource from local storage"
|
|
17698
|
+
},
|
|
17699
|
+
args: {
|
|
17700
|
+
locator: {
|
|
17701
|
+
type: "positional",
|
|
17702
|
+
description: "Resource locator (e.g., hello.text@1.0.0)",
|
|
17703
|
+
required: true
|
|
17704
|
+
}
|
|
17705
|
+
},
|
|
17706
|
+
async run({ args }) {
|
|
17707
|
+
try {
|
|
17708
|
+
const rx = await getClient();
|
|
17709
|
+
const exists = await rx.has(args.locator);
|
|
17710
|
+
if (!exists) {
|
|
17711
|
+
consola.warn(`Resource not found: ${args.locator}`);
|
|
17712
|
+
return;
|
|
17713
|
+
}
|
|
17714
|
+
await rx.remove(args.locator);
|
|
17715
|
+
consola.success(`Removed: ${args.locator}`);
|
|
17716
|
+
} catch (error48) {
|
|
17717
|
+
consola.error(error48 instanceof Error ? error48.message : "Failed to remove resource");
|
|
17718
|
+
process.exit(1);
|
|
17719
|
+
}
|
|
17720
|
+
}
|
|
17721
|
+
});
|
|
17722
|
+
|
|
17723
|
+
// src/commands/search.ts
|
|
17724
|
+
import { buildSearchUrl } from "@resourcexjs/server";
|
|
17725
|
+
var search = defineCommand({
|
|
17726
|
+
meta: {
|
|
17727
|
+
name: "search",
|
|
17728
|
+
description: "Search remote registry"
|
|
17729
|
+
},
|
|
17730
|
+
args: {
|
|
17731
|
+
query: {
|
|
17732
|
+
type: "positional",
|
|
17733
|
+
description: "Search query",
|
|
17734
|
+
required: true
|
|
17735
|
+
},
|
|
17736
|
+
limit: {
|
|
17737
|
+
type: "string",
|
|
17738
|
+
description: "Maximum results",
|
|
17739
|
+
default: "20"
|
|
17740
|
+
}
|
|
17741
|
+
},
|
|
17742
|
+
async run({ args }) {
|
|
17743
|
+
try {
|
|
17744
|
+
const config3 = await getConfig();
|
|
17745
|
+
if (!config3.registry) {
|
|
17746
|
+
consola.error("No registry configured. Use: rx config set registry <url>");
|
|
17747
|
+
process.exit(1);
|
|
17748
|
+
}
|
|
17749
|
+
const url2 = buildSearchUrl(config3.registry, {
|
|
17750
|
+
q: args.query,
|
|
17751
|
+
limit: Number(args.limit)
|
|
17752
|
+
});
|
|
17753
|
+
const response = await fetch(url2);
|
|
17754
|
+
if (!response.ok) {
|
|
17755
|
+
throw new Error(`Search failed: ${response.statusText}`);
|
|
17756
|
+
}
|
|
17757
|
+
const data = await response.json();
|
|
17758
|
+
if (data.results.length === 0) {
|
|
17759
|
+
consola.info("No resources found");
|
|
17760
|
+
return;
|
|
17761
|
+
}
|
|
17762
|
+
consola.info(`Found ${data.total} resource(s):
|
|
17763
|
+
`);
|
|
17764
|
+
for (const item of data.results) {
|
|
17765
|
+
console.log(` ${item.locator}`);
|
|
17766
|
+
if (item.type) {
|
|
17767
|
+
console.log(` type: ${item.type}`);
|
|
17768
|
+
}
|
|
17769
|
+
}
|
|
17770
|
+
} catch (error48) {
|
|
17771
|
+
consola.error(error48 instanceof Error ? error48.message : "Search failed");
|
|
17772
|
+
process.exit(1);
|
|
17773
|
+
}
|
|
17774
|
+
}
|
|
17775
|
+
});
|
|
17776
|
+
|
|
17699
17777
|
// src/commands/server.ts
|
|
17700
17778
|
import { join as join6 } from "path";
|
|
17701
17779
|
var server = defineCommand({
|
|
@@ -17744,43 +17822,36 @@ var server = defineCommand({
|
|
|
17744
17822
|
}
|
|
17745
17823
|
});
|
|
17746
17824
|
|
|
17747
|
-
// src/commands/
|
|
17748
|
-
var
|
|
17825
|
+
// src/commands/use.ts
|
|
17826
|
+
var ingest = defineCommand({
|
|
17749
17827
|
meta: {
|
|
17750
|
-
name: "
|
|
17751
|
-
description: "
|
|
17828
|
+
name: "ingest",
|
|
17829
|
+
description: "Ingest and execute resource from any source (directory path or locator)"
|
|
17752
17830
|
},
|
|
17753
17831
|
args: {
|
|
17754
|
-
|
|
17755
|
-
type: "
|
|
17756
|
-
|
|
17757
|
-
|
|
17832
|
+
source: {
|
|
17833
|
+
type: "positional",
|
|
17834
|
+
description: "Resource source (directory path or locator, e.g., ./my-skill or hello:1.0.0)",
|
|
17835
|
+
required: true
|
|
17758
17836
|
}
|
|
17759
17837
|
},
|
|
17760
17838
|
async run({ args }) {
|
|
17761
17839
|
try {
|
|
17762
17840
|
const rx = await getClient();
|
|
17763
|
-
await rx.
|
|
17764
|
-
if (
|
|
17765
|
-
|
|
17841
|
+
const result = await rx.ingest(args.source);
|
|
17842
|
+
if (typeof result === "string") {
|
|
17843
|
+
console.log(result);
|
|
17844
|
+
} else if (result instanceof Uint8Array) {
|
|
17845
|
+
process.stdout.write(result);
|
|
17766
17846
|
} else {
|
|
17767
|
-
|
|
17847
|
+
console.log(JSON.stringify(result, null, 2));
|
|
17768
17848
|
}
|
|
17769
17849
|
} catch (error48) {
|
|
17770
|
-
consola.error(error48 instanceof Error ? error48.message : "Failed to
|
|
17850
|
+
consola.error(error48 instanceof Error ? error48.message : "Failed to ingest resource");
|
|
17771
17851
|
process.exit(1);
|
|
17772
17852
|
}
|
|
17773
17853
|
}
|
|
17774
17854
|
});
|
|
17775
|
-
var cache = defineCommand({
|
|
17776
|
-
meta: {
|
|
17777
|
-
name: "cache",
|
|
17778
|
-
description: "Manage cached resources"
|
|
17779
|
-
},
|
|
17780
|
-
subCommands: {
|
|
17781
|
-
clear
|
|
17782
|
-
}
|
|
17783
|
-
});
|
|
17784
17855
|
|
|
17785
17856
|
// src/index.ts
|
|
17786
17857
|
var main = defineCommand({
|
|
@@ -17791,13 +17862,13 @@ var main = defineCommand({
|
|
|
17791
17862
|
},
|
|
17792
17863
|
subCommands: {
|
|
17793
17864
|
add,
|
|
17794
|
-
list,
|
|
17865
|
+
list: list2,
|
|
17795
17866
|
info,
|
|
17796
|
-
remove,
|
|
17867
|
+
remove: remove2,
|
|
17797
17868
|
push,
|
|
17798
17869
|
pull,
|
|
17799
17870
|
search,
|
|
17800
|
-
|
|
17871
|
+
ingest,
|
|
17801
17872
|
config: config2,
|
|
17802
17873
|
registry: registry2,
|
|
17803
17874
|
cache,
|
|
@@ -17806,4 +17877,4 @@ var main = defineCommand({
|
|
|
17806
17877
|
});
|
|
17807
17878
|
runMain(main);
|
|
17808
17879
|
|
|
17809
|
-
//# debugId=
|
|
17880
|
+
//# debugId=2A8A66053CB1D89B64756E2164756E21
|