@lotics/cli 0.35.0 → 0.36.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +33 -15
- package/dist/args.d.ts +2 -0
- package/dist/args.js +9 -0
- package/dist/args.test.js +28 -0
- package/dist/cli.js +224 -81
- package/dist/config.d.ts +102 -16
- package/dist/config.js +214 -25
- package/dist/config.test.js +229 -22
- package/dist/src/cli.js +1262 -552
- package/package.json +1 -1
package/dist/src/cli.js
CHANGED
|
@@ -120,7 +120,7 @@ var require_helpers = __commonJS({
|
|
|
120
120
|
* @returns {*}
|
|
121
121
|
*/
|
|
122
122
|
flattenDeep(arr1) {
|
|
123
|
-
return arr1.reduce((acc,
|
|
123
|
+
return arr1.reduce((acc, val) => Array.isArray(val) ? acc.concat(this.flattenDeep(val)) : acc.concat(val), []);
|
|
124
124
|
}
|
|
125
125
|
/**
|
|
126
126
|
*
|
|
@@ -768,11 +768,11 @@ var require_ssf = __commonJS({
|
|
|
768
768
|
function fix_hijri() {
|
|
769
769
|
return 0;
|
|
770
770
|
}
|
|
771
|
-
function write_date(type, fmt,
|
|
772
|
-
let o = "", ss = 0, tt = 0, y =
|
|
771
|
+
function write_date(type, fmt, val, ss0) {
|
|
772
|
+
let o = "", ss = 0, tt = 0, y = val.y, out, outl = 0;
|
|
773
773
|
switch (type) {
|
|
774
774
|
case 98:
|
|
775
|
-
y =
|
|
775
|
+
y = val.y + 543;
|
|
776
776
|
/* falls through */
|
|
777
777
|
case 121:
|
|
778
778
|
switch (fmt.length) {
|
|
@@ -791,35 +791,35 @@ var require_ssf = __commonJS({
|
|
|
791
791
|
switch (fmt.length) {
|
|
792
792
|
case 1:
|
|
793
793
|
case 2:
|
|
794
|
-
out =
|
|
794
|
+
out = val.m;
|
|
795
795
|
outl = fmt.length;
|
|
796
796
|
break;
|
|
797
797
|
case 3:
|
|
798
|
-
return months[
|
|
798
|
+
return months[val.m - 1][1];
|
|
799
799
|
case 5:
|
|
800
|
-
return months[
|
|
800
|
+
return months[val.m - 1][0];
|
|
801
801
|
default:
|
|
802
|
-
return months[
|
|
802
|
+
return months[val.m - 1][2];
|
|
803
803
|
}
|
|
804
804
|
break;
|
|
805
805
|
case 100:
|
|
806
806
|
switch (fmt.length) {
|
|
807
807
|
case 1:
|
|
808
808
|
case 2:
|
|
809
|
-
out =
|
|
809
|
+
out = val.d;
|
|
810
810
|
outl = fmt.length;
|
|
811
811
|
break;
|
|
812
812
|
case 3:
|
|
813
|
-
return days[
|
|
813
|
+
return days[val.q][0];
|
|
814
814
|
default:
|
|
815
|
-
return days[
|
|
815
|
+
return days[val.q][1];
|
|
816
816
|
}
|
|
817
817
|
break;
|
|
818
818
|
case 104:
|
|
819
819
|
switch (fmt.length) {
|
|
820
820
|
case 1:
|
|
821
821
|
case 2:
|
|
822
|
-
out = 1 + (
|
|
822
|
+
out = 1 + (val.H + 11) % 12;
|
|
823
823
|
outl = fmt.length;
|
|
824
824
|
break;
|
|
825
825
|
default:
|
|
@@ -830,7 +830,7 @@ var require_ssf = __commonJS({
|
|
|
830
830
|
switch (fmt.length) {
|
|
831
831
|
case 1:
|
|
832
832
|
case 2:
|
|
833
|
-
out =
|
|
833
|
+
out = val.H;
|
|
834
834
|
outl = fmt.length;
|
|
835
835
|
break;
|
|
836
836
|
default:
|
|
@@ -841,7 +841,7 @@ var require_ssf = __commonJS({
|
|
|
841
841
|
switch (fmt.length) {
|
|
842
842
|
case 1:
|
|
843
843
|
case 2:
|
|
844
|
-
out =
|
|
844
|
+
out = val.M;
|
|
845
845
|
outl = fmt.length;
|
|
846
846
|
break;
|
|
847
847
|
default:
|
|
@@ -850,10 +850,10 @@ var require_ssf = __commonJS({
|
|
|
850
850
|
break;
|
|
851
851
|
case 115:
|
|
852
852
|
if (fmt !== "s" && fmt !== "ss" && fmt !== ".0" && fmt !== ".00" && fmt !== ".000") throw "bad second format: " + fmt;
|
|
853
|
-
if (
|
|
853
|
+
if (val.u === 0 && (fmt === "s" || fmt === "ss")) return pad0(val.S, fmt.length);
|
|
854
854
|
if (ss0 >= 2) tt = ss0 === 3 ? 1e3 : 100;
|
|
855
855
|
else tt = ss0 === 1 ? 10 : 1;
|
|
856
|
-
ss = Math.round(tt * (
|
|
856
|
+
ss = Math.round(tt * (val.S + val.u));
|
|
857
857
|
if (ss >= 60 * tt) ss = 0;
|
|
858
858
|
if (fmt === "s") return ss === 0 ? "0" : "" + ss / tt;
|
|
859
859
|
o = pad0(ss, 2 + ss0);
|
|
@@ -863,15 +863,15 @@ var require_ssf = __commonJS({
|
|
|
863
863
|
switch (fmt) {
|
|
864
864
|
case "[h]":
|
|
865
865
|
case "[hh]":
|
|
866
|
-
out =
|
|
866
|
+
out = val.D * 24 + val.H;
|
|
867
867
|
break;
|
|
868
868
|
case "[m]":
|
|
869
869
|
case "[mm]":
|
|
870
|
-
out = (
|
|
870
|
+
out = (val.D * 24 + val.H) * 60 + val.M;
|
|
871
871
|
break;
|
|
872
872
|
case "[s]":
|
|
873
873
|
case "[ss]":
|
|
874
|
-
out = ((
|
|
874
|
+
out = ((val.D * 24 + val.H) * 60 + val.M) * 60 + Math.round(val.S + val.u);
|
|
875
875
|
break;
|
|
876
876
|
default:
|
|
877
877
|
throw "bad abstime format: " + fmt;
|
|
@@ -894,28 +894,28 @@ var require_ssf = __commonJS({
|
|
|
894
894
|
}
|
|
895
895
|
var write_num = /* @__PURE__ */ (function make_write_num() {
|
|
896
896
|
const pct1 = /%/g;
|
|
897
|
-
function write_num_pct(type, fmt,
|
|
897
|
+
function write_num_pct(type, fmt, val) {
|
|
898
898
|
const sfmt = fmt.replace(pct1, ""), mul = fmt.length - sfmt.length;
|
|
899
|
-
return write_num(type, sfmt,
|
|
899
|
+
return write_num(type, sfmt, val * Math.pow(10, 2 * mul)) + fill("%", mul);
|
|
900
900
|
}
|
|
901
|
-
function write_num_cm(type, fmt,
|
|
901
|
+
function write_num_cm(type, fmt, val) {
|
|
902
902
|
let idx = fmt.length - 1;
|
|
903
903
|
while (fmt.charCodeAt(idx - 1) === 44) --idx;
|
|
904
|
-
return write_num(type, fmt.substr(0, idx),
|
|
904
|
+
return write_num(type, fmt.substr(0, idx), val / Math.pow(10, 3 * (fmt.length - idx)));
|
|
905
905
|
}
|
|
906
|
-
function write_num_exp(fmt,
|
|
906
|
+
function write_num_exp(fmt, val) {
|
|
907
907
|
let o;
|
|
908
908
|
let idx = fmt.indexOf("E") - fmt.indexOf(".") - 1;
|
|
909
909
|
if (fmt.match(/^#+0.0E\+0$/)) {
|
|
910
|
-
if (
|
|
911
|
-
else if (
|
|
910
|
+
if (val === 0) return "0.0E+0";
|
|
911
|
+
else if (val < 0) return "-" + write_num_exp(fmt, -val);
|
|
912
912
|
let period = fmt.indexOf(".");
|
|
913
913
|
if (period === -1) period = fmt.indexOf("E");
|
|
914
|
-
let ee = Math.floor(Math.log(
|
|
914
|
+
let ee = Math.floor(Math.log(val) * Math.LOG10E) % period;
|
|
915
915
|
if (ee < 0) ee += period;
|
|
916
|
-
o = (
|
|
916
|
+
o = (val / Math.pow(10, ee)).toPrecision(idx + 1 + (period + ee) % period);
|
|
917
917
|
if (o.indexOf("e") === -1) {
|
|
918
|
-
const fakee = Math.floor(Math.log(
|
|
918
|
+
const fakee = Math.floor(Math.log(val) * Math.LOG10E);
|
|
919
919
|
if (o.indexOf(".") === -1) o = o.charAt(0) + "." + o.substr(1) + "E+" + (fakee - o.length + ee);
|
|
920
920
|
else o += "E+" + (fakee - ee);
|
|
921
921
|
while (o.substr(0, 2) === "0.") {
|
|
@@ -927,7 +927,7 @@ var require_ssf = __commonJS({
|
|
|
927
927
|
o = o.replace(/^([+-]?)(\d*)\.(\d*)[Ee]/, function($$, $1, $2, $3) {
|
|
928
928
|
return $1 + $2 + $3.substr(0, (period + ee) % period) + "." + $3.substr(ee) + "E";
|
|
929
929
|
});
|
|
930
|
-
} else o =
|
|
930
|
+
} else o = val.toExponential(idx);
|
|
931
931
|
if (fmt.match(/E\+00$/) && o.match(/e[+-]\d$/)) o = o.substr(0, o.length - 1) + "0" + o.charAt(o.length - 1);
|
|
932
932
|
if (fmt.match(/E\-/) && o.match(/e\+/)) o = o.replace(/e\+/, "e");
|
|
933
933
|
return o.replace("e", "E");
|
|
@@ -960,48 +960,48 @@ var require_ssf = __commonJS({
|
|
|
960
960
|
}
|
|
961
961
|
return o;
|
|
962
962
|
}
|
|
963
|
-
function rnd(
|
|
963
|
+
function rnd(val, d) {
|
|
964
964
|
const dd = Math.pow(10, d);
|
|
965
|
-
return "" + Math.round(
|
|
965
|
+
return "" + Math.round(val * dd) / dd;
|
|
966
966
|
}
|
|
967
|
-
function dec(
|
|
968
|
-
if (d < ("" + Math.round((
|
|
967
|
+
function dec(val, d) {
|
|
968
|
+
if (d < ("" + Math.round((val - Math.floor(val)) * Math.pow(10, d))).length) {
|
|
969
969
|
return 0;
|
|
970
970
|
}
|
|
971
|
-
return Math.round((
|
|
971
|
+
return Math.round((val - Math.floor(val)) * Math.pow(10, d));
|
|
972
972
|
}
|
|
973
|
-
function carry(
|
|
974
|
-
if (d < ("" + Math.round((
|
|
973
|
+
function carry(val, d) {
|
|
974
|
+
if (d < ("" + Math.round((val - Math.floor(val)) * Math.pow(10, d))).length) {
|
|
975
975
|
return 1;
|
|
976
976
|
}
|
|
977
977
|
return 0;
|
|
978
978
|
}
|
|
979
|
-
function flr(
|
|
980
|
-
if (
|
|
981
|
-
return "" + Math.floor(
|
|
979
|
+
function flr(val) {
|
|
980
|
+
if (val < 2147483647 && val > -2147483648) return "" + (val >= 0 ? val | 0 : val - 1 | 0);
|
|
981
|
+
return "" + Math.floor(val);
|
|
982
982
|
}
|
|
983
|
-
function write_num_flt(type, fmt,
|
|
983
|
+
function write_num_flt(type, fmt, val) {
|
|
984
984
|
if (type.charCodeAt(0) === 40 && !fmt.match(closeparen)) {
|
|
985
985
|
const ffmt = fmt.replace(/\( */, "").replace(/ \)/, "").replace(/\)/, "");
|
|
986
|
-
if (
|
|
987
|
-
return "(" + write_num_flt("n", ffmt, -
|
|
986
|
+
if (val >= 0) return write_num_flt("n", ffmt, val);
|
|
987
|
+
return "(" + write_num_flt("n", ffmt, -val) + ")";
|
|
988
988
|
}
|
|
989
|
-
if (fmt.charCodeAt(fmt.length - 1) === 44) return write_num_cm(type, fmt,
|
|
990
|
-
if (fmt.indexOf("%") !== -1) return write_num_pct(type, fmt,
|
|
991
|
-
if (fmt.indexOf("E") !== -1) return write_num_exp(fmt,
|
|
992
|
-
if (fmt.charCodeAt(0) === 36) return "$" + write_num_flt(type, fmt.substr(fmt.charAt(1) == " " ? 2 : 1),
|
|
989
|
+
if (fmt.charCodeAt(fmt.length - 1) === 44) return write_num_cm(type, fmt, val);
|
|
990
|
+
if (fmt.indexOf("%") !== -1) return write_num_pct(type, fmt, val);
|
|
991
|
+
if (fmt.indexOf("E") !== -1) return write_num_exp(fmt, val);
|
|
992
|
+
if (fmt.charCodeAt(0) === 36) return "$" + write_num_flt(type, fmt.substr(fmt.charAt(1) == " " ? 2 : 1), val);
|
|
993
993
|
let o;
|
|
994
|
-
let r, ri, ff, aval = Math.abs(
|
|
994
|
+
let r, ri, ff, aval = Math.abs(val), sign = val < 0 ? "-" : "";
|
|
995
995
|
if (fmt.match(/^00+$/)) return sign + pad0r(aval, fmt.length);
|
|
996
996
|
if (fmt.match(/^[#?]+$/)) {
|
|
997
|
-
o = pad0r(
|
|
997
|
+
o = pad0r(val, 0);
|
|
998
998
|
if (o === "0") o = "";
|
|
999
999
|
return o.length > fmt.length ? o : hashq(fmt.substr(0, fmt.length - o.length)) + o;
|
|
1000
1000
|
}
|
|
1001
1001
|
if (r = fmt.match(frac1)) return write_num_f1(r, aval, sign);
|
|
1002
1002
|
if (fmt.match(/^#+0+$/)) return sign + pad0r(aval, fmt.length - fmt.indexOf("0"));
|
|
1003
1003
|
if (r = fmt.match(dec1)) {
|
|
1004
|
-
o = rnd(
|
|
1004
|
+
o = rnd(val, r[1].length).replace(/^([^\.]+)$/, "$1." + hashq(r[1])).replace(/\.$/, "." + hashq(r[1])).replace(/\.(\d*)$/, function($$, $1) {
|
|
1005
1005
|
return "." + $1 + fill("0", hashq(r[1]).length - $1.length);
|
|
1006
1006
|
});
|
|
1007
1007
|
return fmt.indexOf("0.") !== -1 ? o : o.replace(/^0\./, ".");
|
|
@@ -1012,18 +1012,18 @@ var require_ssf = __commonJS({
|
|
|
1012
1012
|
}
|
|
1013
1013
|
if (r = fmt.match(/^#{1,3},##0(\.?)$/)) return sign + commaify(pad0r(aval, 0));
|
|
1014
1014
|
if (r = fmt.match(/^#,##0\.([#0]*0)$/)) {
|
|
1015
|
-
return
|
|
1015
|
+
return val < 0 ? "-" + write_num_flt(type, fmt, -val) : commaify("" + (Math.floor(val) + carry(val, r[1].length))) + "." + pad0(dec(val, r[1].length), r[1].length);
|
|
1016
1016
|
}
|
|
1017
|
-
if (r = fmt.match(/^#,#*,#0/)) return write_num_flt(type, fmt.replace(/^#,#*,/, ""),
|
|
1017
|
+
if (r = fmt.match(/^#,#*,#0/)) return write_num_flt(type, fmt.replace(/^#,#*,/, ""), val);
|
|
1018
1018
|
if (r = fmt.match(/^([0#]+)(\\?-([0#]+))+$/)) {
|
|
1019
|
-
o = _strrev(write_num_flt(type, fmt.replace(/[\\-]/g, ""),
|
|
1019
|
+
o = _strrev(write_num_flt(type, fmt.replace(/[\\-]/g, ""), val));
|
|
1020
1020
|
ri = 0;
|
|
1021
1021
|
return _strrev(_strrev(fmt.replace(/\\/g, "")).replace(/[0#]/g, function(x) {
|
|
1022
1022
|
return ri < o.length ? o.charAt(ri++) : x === "0" ? "0" : "";
|
|
1023
1023
|
}));
|
|
1024
1024
|
}
|
|
1025
1025
|
if (fmt.match(phone)) {
|
|
1026
|
-
o = write_num_flt(type, "##########",
|
|
1026
|
+
o = write_num_flt(type, "##########", val);
|
|
1027
1027
|
return "(" + o.substr(0, 3) + ") " + o.substr(3, 3) + "-" + o.substr(6);
|
|
1028
1028
|
}
|
|
1029
1029
|
let oa = "";
|
|
@@ -1045,60 +1045,60 @@ var require_ssf = __commonJS({
|
|
|
1045
1045
|
return sign + (ff[0] || (ff[1] ? "" : "0")) + " " + (ff[1] ? pad_(ff[1], ri) + r[2] + "/" + r[3] + rpad_(ff[2], ri) : fill(" ", 2 * ri + 1 + r[2].length + r[3].length));
|
|
1046
1046
|
}
|
|
1047
1047
|
if (r = fmt.match(/^[#0?]+$/)) {
|
|
1048
|
-
o = pad0r(
|
|
1048
|
+
o = pad0r(val, 0);
|
|
1049
1049
|
if (fmt.length <= o.length) return o;
|
|
1050
1050
|
return hashq(fmt.substr(0, fmt.length - o.length)) + o;
|
|
1051
1051
|
}
|
|
1052
1052
|
if (r = fmt.match(/^([#0?]+)\.([#0]+)$/)) {
|
|
1053
|
-
o = "" +
|
|
1053
|
+
o = "" + val.toFixed(Math.min(r[2].length, 10)).replace(/([^0])0+$/, "$1");
|
|
1054
1054
|
ri = o.indexOf(".");
|
|
1055
1055
|
const lres = fmt.indexOf(".") - ri, rres = fmt.length - o.length - lres;
|
|
1056
1056
|
return hashq(fmt.substr(0, lres) + o + fmt.substr(fmt.length - rres));
|
|
1057
1057
|
}
|
|
1058
1058
|
if (r = fmt.match(/^00,000\.([#0]*0)$/)) {
|
|
1059
|
-
ri = dec(
|
|
1060
|
-
return
|
|
1059
|
+
ri = dec(val, r[1].length);
|
|
1060
|
+
return val < 0 ? "-" + write_num_flt(type, fmt, -val) : commaify(flr(val)).replace(/^\d,\d{3}$/, "0$&").replace(/^\d*$/, function($$) {
|
|
1061
1061
|
return "00," + ($$.length < 3 ? pad0(0, 3 - $$.length) : "") + $$;
|
|
1062
1062
|
}) + "." + pad0(ri, r[1].length);
|
|
1063
1063
|
}
|
|
1064
1064
|
switch (fmt) {
|
|
1065
1065
|
case "###,##0.00":
|
|
1066
|
-
return write_num_flt(type, "#,##0.00",
|
|
1066
|
+
return write_num_flt(type, "#,##0.00", val);
|
|
1067
1067
|
case "###,###":
|
|
1068
1068
|
case "##,###":
|
|
1069
1069
|
case "#,###":
|
|
1070
1070
|
const x = commaify(pad0r(aval, 0));
|
|
1071
1071
|
return x !== "0" ? sign + x : "";
|
|
1072
1072
|
case "###,###.00":
|
|
1073
|
-
return write_num_flt(type, "###,##0.00",
|
|
1073
|
+
return write_num_flt(type, "###,##0.00", val).replace(/^0\./, ".");
|
|
1074
1074
|
case "#,###.00":
|
|
1075
|
-
return write_num_flt(type, "#,##0.00",
|
|
1075
|
+
return write_num_flt(type, "#,##0.00", val).replace(/^0\./, ".");
|
|
1076
1076
|
default:
|
|
1077
1077
|
}
|
|
1078
1078
|
throw new Error("unsupported format |" + fmt + "|");
|
|
1079
1079
|
}
|
|
1080
|
-
function write_num_cm2(type, fmt,
|
|
1080
|
+
function write_num_cm2(type, fmt, val) {
|
|
1081
1081
|
let idx = fmt.length - 1;
|
|
1082
1082
|
while (fmt.charCodeAt(idx - 1) === 44) --idx;
|
|
1083
|
-
return write_num(type, fmt.substr(0, idx),
|
|
1083
|
+
return write_num(type, fmt.substr(0, idx), val / Math.pow(10, 3 * (fmt.length - idx)));
|
|
1084
1084
|
}
|
|
1085
|
-
function write_num_pct2(type, fmt,
|
|
1085
|
+
function write_num_pct2(type, fmt, val) {
|
|
1086
1086
|
const sfmt = fmt.replace(pct1, ""), mul = fmt.length - sfmt.length;
|
|
1087
|
-
return write_num(type, sfmt,
|
|
1087
|
+
return write_num(type, sfmt, val * Math.pow(10, 2 * mul)) + fill("%", mul);
|
|
1088
1088
|
}
|
|
1089
|
-
function write_num_exp2(fmt,
|
|
1089
|
+
function write_num_exp2(fmt, val) {
|
|
1090
1090
|
let o;
|
|
1091
1091
|
let idx = fmt.indexOf("E") - fmt.indexOf(".") - 1;
|
|
1092
1092
|
if (fmt.match(/^#+0.0E\+0$/)) {
|
|
1093
|
-
if (
|
|
1094
|
-
else if (
|
|
1093
|
+
if (val === 0) return "0.0E+0";
|
|
1094
|
+
else if (val < 0) return "-" + write_num_exp2(fmt, -val);
|
|
1095
1095
|
let period = fmt.indexOf(".");
|
|
1096
1096
|
if (period === -1) period = fmt.indexOf("E");
|
|
1097
|
-
let ee = Math.floor(Math.log(
|
|
1097
|
+
let ee = Math.floor(Math.log(val) * Math.LOG10E) % period;
|
|
1098
1098
|
if (ee < 0) ee += period;
|
|
1099
|
-
o = (
|
|
1099
|
+
o = (val / Math.pow(10, ee)).toPrecision(idx + 1 + (period + ee) % period);
|
|
1100
1100
|
if (!o.match(/[Ee]/)) {
|
|
1101
|
-
const fakee = Math.floor(Math.log(
|
|
1101
|
+
const fakee = Math.floor(Math.log(val) * Math.LOG10E);
|
|
1102
1102
|
if (o.indexOf(".") === -1) o = o.charAt(0) + "." + o.substr(1) + "E+" + (fakee - o.length + ee);
|
|
1103
1103
|
else o += "E+" + (fakee - ee);
|
|
1104
1104
|
o = o.replace(/\+-/, "-");
|
|
@@ -1106,33 +1106,33 @@ var require_ssf = __commonJS({
|
|
|
1106
1106
|
o = o.replace(/^([+-]?)(\d*)\.(\d*)[Ee]/, function($$, $1, $2, $3) {
|
|
1107
1107
|
return $1 + $2 + $3.substr(0, (period + ee) % period) + "." + $3.substr(ee) + "E";
|
|
1108
1108
|
});
|
|
1109
|
-
} else o =
|
|
1109
|
+
} else o = val.toExponential(idx);
|
|
1110
1110
|
if (fmt.match(/E\+00$/) && o.match(/e[+-]\d$/)) o = o.substr(0, o.length - 1) + "0" + o.charAt(o.length - 1);
|
|
1111
1111
|
if (fmt.match(/E\-/) && o.match(/e\+/)) o = o.replace(/e\+/, "e");
|
|
1112
1112
|
return o.replace("e", "E");
|
|
1113
1113
|
}
|
|
1114
|
-
function write_num_int(type, fmt,
|
|
1114
|
+
function write_num_int(type, fmt, val) {
|
|
1115
1115
|
if (type.charCodeAt(0) === 40 && !fmt.match(closeparen)) {
|
|
1116
1116
|
const ffmt = fmt.replace(/\( */, "").replace(/ \)/, "").replace(/\)/, "");
|
|
1117
|
-
if (
|
|
1118
|
-
return "(" + write_num_int("n", ffmt, -
|
|
1117
|
+
if (val >= 0) return write_num_int("n", ffmt, val);
|
|
1118
|
+
return "(" + write_num_int("n", ffmt, -val) + ")";
|
|
1119
1119
|
}
|
|
1120
|
-
if (fmt.charCodeAt(fmt.length - 1) === 44) return write_num_cm2(type, fmt,
|
|
1121
|
-
if (fmt.indexOf("%") !== -1) return write_num_pct2(type, fmt,
|
|
1122
|
-
if (fmt.indexOf("E") !== -1) return write_num_exp2(fmt,
|
|
1123
|
-
if (fmt.charCodeAt(0) === 36) return "$" + write_num_int(type, fmt.substr(fmt.charAt(1) == " " ? 2 : 1),
|
|
1120
|
+
if (fmt.charCodeAt(fmt.length - 1) === 44) return write_num_cm2(type, fmt, val);
|
|
1121
|
+
if (fmt.indexOf("%") !== -1) return write_num_pct2(type, fmt, val);
|
|
1122
|
+
if (fmt.indexOf("E") !== -1) return write_num_exp2(fmt, val);
|
|
1123
|
+
if (fmt.charCodeAt(0) === 36) return "$" + write_num_int(type, fmt.substr(fmt.charAt(1) == " " ? 2 : 1), val);
|
|
1124
1124
|
let o;
|
|
1125
|
-
let r, ri, ff, aval = Math.abs(
|
|
1125
|
+
let r, ri, ff, aval = Math.abs(val), sign = val < 0 ? "-" : "";
|
|
1126
1126
|
if (fmt.match(/^00+$/)) return sign + pad0(aval, fmt.length);
|
|
1127
1127
|
if (fmt.match(/^[#?]+$/)) {
|
|
1128
|
-
o = "" +
|
|
1129
|
-
if (
|
|
1128
|
+
o = "" + val;
|
|
1129
|
+
if (val === 0) o = "";
|
|
1130
1130
|
return o.length > fmt.length ? o : hashq(fmt.substr(0, fmt.length - o.length)) + o;
|
|
1131
1131
|
}
|
|
1132
1132
|
if (r = fmt.match(frac1)) return write_num_f2(r, aval, sign);
|
|
1133
1133
|
if (fmt.match(/^#+0+$/)) return sign + pad0(aval, fmt.length - fmt.indexOf("0"));
|
|
1134
1134
|
if (r = fmt.match(dec1)) {
|
|
1135
|
-
o = ("" +
|
|
1135
|
+
o = ("" + val).replace(/^([^\.]+)$/, "$1." + hashq(r[1])).replace(/\.$/, "." + hashq(r[1]));
|
|
1136
1136
|
o = o.replace(/\.(\d*)$/, function($$, $1) {
|
|
1137
1137
|
return "." + $1 + fill("0", hashq(r[1]).length - $1.length);
|
|
1138
1138
|
});
|
|
@@ -1144,18 +1144,18 @@ var require_ssf = __commonJS({
|
|
|
1144
1144
|
}
|
|
1145
1145
|
if (r = fmt.match(/^#{1,3},##0(\.?)$/)) return sign + commaify("" + aval);
|
|
1146
1146
|
if (r = fmt.match(/^#,##0\.([#0]*0)$/)) {
|
|
1147
|
-
return
|
|
1147
|
+
return val < 0 ? "-" + write_num_int(type, fmt, -val) : commaify("" + val) + "." + fill("0", r[1].length);
|
|
1148
1148
|
}
|
|
1149
|
-
if (r = fmt.match(/^#,#*,#0/)) return write_num_int(type, fmt.replace(/^#,#*,/, ""),
|
|
1149
|
+
if (r = fmt.match(/^#,#*,#0/)) return write_num_int(type, fmt.replace(/^#,#*,/, ""), val);
|
|
1150
1150
|
if (r = fmt.match(/^([0#]+)(\\?-([0#]+))+$/)) {
|
|
1151
|
-
o = _strrev(write_num_int(type, fmt.replace(/[\\-]/g, ""),
|
|
1151
|
+
o = _strrev(write_num_int(type, fmt.replace(/[\\-]/g, ""), val));
|
|
1152
1152
|
ri = 0;
|
|
1153
1153
|
return _strrev(_strrev(fmt.replace(/\\/g, "")).replace(/[0#]/g, function(x) {
|
|
1154
1154
|
return ri < o.length ? o.charAt(ri++) : x === "0" ? "0" : "";
|
|
1155
1155
|
}));
|
|
1156
1156
|
}
|
|
1157
1157
|
if (fmt.match(phone)) {
|
|
1158
|
-
o = write_num_int(type, "##########",
|
|
1158
|
+
o = write_num_int(type, "##########", val);
|
|
1159
1159
|
return "(" + o.substr(0, 3) + ") " + o.substr(3, 3) + "-" + o.substr(6);
|
|
1160
1160
|
}
|
|
1161
1161
|
let oa = "";
|
|
@@ -1177,18 +1177,18 @@ var require_ssf = __commonJS({
|
|
|
1177
1177
|
return sign + (ff[0] || (ff[1] ? "" : "0")) + " " + (ff[1] ? pad_(ff[1], ri) + r[2] + "/" + r[3] + rpad_(ff[2], ri) : fill(" ", 2 * ri + 1 + r[2].length + r[3].length));
|
|
1178
1178
|
}
|
|
1179
1179
|
if (r = fmt.match(/^[#0?]+$/)) {
|
|
1180
|
-
o = "" +
|
|
1180
|
+
o = "" + val;
|
|
1181
1181
|
if (fmt.length <= o.length) return o;
|
|
1182
1182
|
return hashq(fmt.substr(0, fmt.length - o.length)) + o;
|
|
1183
1183
|
}
|
|
1184
1184
|
if (r = fmt.match(/^([#0]+)\.([#0]+)$/)) {
|
|
1185
|
-
o = "" +
|
|
1185
|
+
o = "" + val.toFixed(Math.min(r[2].length, 10)).replace(/([^0])0+$/, "$1");
|
|
1186
1186
|
ri = o.indexOf(".");
|
|
1187
1187
|
let lres = fmt.indexOf(".") - ri, rres = fmt.length - o.length - lres;
|
|
1188
1188
|
return hashq(fmt.substr(0, lres) + o + fmt.substr(fmt.length - rres));
|
|
1189
1189
|
}
|
|
1190
1190
|
if (r = fmt.match(/^00,000\.([#0]*0)$/)) {
|
|
1191
|
-
return
|
|
1191
|
+
return val < 0 ? "-" + write_num_int(type, fmt, -val) : commaify("" + val).replace(/^\d,\d{3}$/, "0$&").replace(/^\d*$/, function($$) {
|
|
1192
1192
|
return "00," + ($$.length < 3 ? pad0(0, 3 - $$.length) : "") + $$;
|
|
1193
1193
|
}) + "." + pad0(0, r[1].length);
|
|
1194
1194
|
}
|
|
@@ -1199,12 +1199,12 @@ var require_ssf = __commonJS({
|
|
|
1199
1199
|
const x = commaify("" + aval);
|
|
1200
1200
|
return x !== "0" ? sign + x : "";
|
|
1201
1201
|
default:
|
|
1202
|
-
if (fmt.match(/\.[0#?]*$/)) return write_num_int(type, fmt.slice(0, fmt.lastIndexOf(".")),
|
|
1202
|
+
if (fmt.match(/\.[0#?]*$/)) return write_num_int(type, fmt.slice(0, fmt.lastIndexOf(".")), val) + hashq(fmt.slice(fmt.lastIndexOf(".")));
|
|
1203
1203
|
}
|
|
1204
1204
|
throw new Error("unsupported format |" + fmt + "|");
|
|
1205
1205
|
}
|
|
1206
|
-
return function write_num2(type, fmt,
|
|
1207
|
-
return (
|
|
1206
|
+
return function write_num2(type, fmt, val) {
|
|
1207
|
+
return (val | 0) === val ? write_num_int(type, fmt, val) : write_num_flt(type, fmt, val);
|
|
1208
1208
|
};
|
|
1209
1209
|
})();
|
|
1210
1210
|
function split_fmt(fmt) {
|
|
@@ -3061,17 +3061,17 @@ var require_logical = __commonJS({
|
|
|
3061
3061
|
var H = FormulaHelpers;
|
|
3062
3062
|
function getNumLogicalValue(params) {
|
|
3063
3063
|
let numTrue = 0, numFalse = 0;
|
|
3064
|
-
H.flattenParams(params, null, true, (
|
|
3065
|
-
const type = typeof
|
|
3064
|
+
H.flattenParams(params, null, true, (val) => {
|
|
3065
|
+
const type = typeof val;
|
|
3066
3066
|
if (type === "string") {
|
|
3067
|
-
if (
|
|
3068
|
-
|
|
3069
|
-
else if (
|
|
3070
|
-
|
|
3067
|
+
if (val === "TRUE")
|
|
3068
|
+
val = true;
|
|
3069
|
+
else if (val === "FALSE")
|
|
3070
|
+
val = false;
|
|
3071
3071
|
} else if (type === "number")
|
|
3072
|
-
|
|
3073
|
-
if (typeof
|
|
3074
|
-
if (
|
|
3072
|
+
val = Boolean(val);
|
|
3073
|
+
if (typeof val === "boolean") {
|
|
3074
|
+
if (val === true)
|
|
3075
3075
|
numTrue++;
|
|
3076
3076
|
else
|
|
3077
3077
|
numFalse++;
|
|
@@ -3387,10 +3387,10 @@ var require_jstat = __commonJS({
|
|
|
3387
3387
|
var slice = Array.prototype.slice;
|
|
3388
3388
|
var toString = Object.prototype.toString;
|
|
3389
3389
|
function calcRdx(n, m) {
|
|
3390
|
-
var
|
|
3390
|
+
var val = n > m ? n : m;
|
|
3391
3391
|
return Math2.pow(
|
|
3392
3392
|
10,
|
|
3393
|
-
17 - ~~(Math2.log(
|
|
3393
|
+
17 - ~~(Math2.log(val > 0 ? val : -val) * Math2.LOG10E)
|
|
3394
3394
|
);
|
|
3395
3395
|
}
|
|
3396
3396
|
var isArray2 = Array.isArray || function isArray3(arg) {
|
|
@@ -10243,10 +10243,10 @@ var require_utils = __commonJS({
|
|
|
10243
10243
|
exports.peek = peek;
|
|
10244
10244
|
function timer(func) {
|
|
10245
10245
|
var start = (/* @__PURE__ */ new Date()).getTime();
|
|
10246
|
-
var
|
|
10246
|
+
var val = func();
|
|
10247
10247
|
var end = (/* @__PURE__ */ new Date()).getTime();
|
|
10248
10248
|
var total = end - start;
|
|
10249
|
-
return { time: total, value:
|
|
10249
|
+
return { time: total, value: val };
|
|
10250
10250
|
}
|
|
10251
10251
|
exports.timer = timer;
|
|
10252
10252
|
}
|
|
@@ -12227,7 +12227,7 @@ var require_tokens = __commonJS({
|
|
|
12227
12227
|
function assignCategoriesTokensProp(tokenTypes) {
|
|
12228
12228
|
utils_1.forEach(tokenTypes, function(currTokType) {
|
|
12229
12229
|
currTokType.categoryMatches = [];
|
|
12230
|
-
utils_1.forEach(currTokType.categoryMatchesMap, function(
|
|
12230
|
+
utils_1.forEach(currTokType.categoryMatchesMap, function(val, key) {
|
|
12231
12231
|
currTokType.categoryMatches.push(exports2.tokenIdxToClass[key].tokenTypeIdx);
|
|
12232
12232
|
});
|
|
12233
12233
|
});
|
|
@@ -18825,14 +18825,14 @@ var require_utils2 = __commonJS({
|
|
|
18825
18825
|
}
|
|
18826
18826
|
};
|
|
18827
18827
|
}
|
|
18828
|
-
_applyPrefix(prefixes,
|
|
18829
|
-
if (this.isFormulaError(
|
|
18830
|
-
return
|
|
18831
|
-
return Prefix.unaryOp(prefixes,
|
|
18828
|
+
_applyPrefix(prefixes, val, isArray2) {
|
|
18829
|
+
if (this.isFormulaError(val))
|
|
18830
|
+
return val;
|
|
18831
|
+
return Prefix.unaryOp(prefixes, val, isArray2);
|
|
18832
18832
|
}
|
|
18833
18833
|
async applyPrefixAsync(prefixes, value) {
|
|
18834
|
-
const { val
|
|
18835
|
-
return this._applyPrefix(prefixes,
|
|
18834
|
+
const { val, isArray: isArray2 } = this.extractRefValue(await value);
|
|
18835
|
+
return this._applyPrefix(prefixes, val, isArray2);
|
|
18836
18836
|
}
|
|
18837
18837
|
/**
|
|
18838
18838
|
* Apply + or - unary prefix.
|
|
@@ -18844,25 +18844,25 @@ var require_utils2 = __commonJS({
|
|
|
18844
18844
|
if (this.context.async) {
|
|
18845
18845
|
return this.applyPrefixAsync(prefixes, value);
|
|
18846
18846
|
} else {
|
|
18847
|
-
const { val
|
|
18848
|
-
return this._applyPrefix(prefixes,
|
|
18847
|
+
const { val, isArray: isArray2 } = this.extractRefValue(value);
|
|
18848
|
+
return this._applyPrefix(prefixes, val, isArray2);
|
|
18849
18849
|
}
|
|
18850
18850
|
}
|
|
18851
|
-
_applyPostfix(
|
|
18852
|
-
if (this.isFormulaError(
|
|
18853
|
-
return
|
|
18854
|
-
return Postfix.percentOp(
|
|
18851
|
+
_applyPostfix(val, isArray2, postfix) {
|
|
18852
|
+
if (this.isFormulaError(val))
|
|
18853
|
+
return val;
|
|
18854
|
+
return Postfix.percentOp(val, postfix, isArray2);
|
|
18855
18855
|
}
|
|
18856
18856
|
async applyPostfixAsync(value, postfix) {
|
|
18857
|
-
const { val
|
|
18858
|
-
return this._applyPostfix(
|
|
18857
|
+
const { val, isArray: isArray2 } = this.extractRefValue(await value);
|
|
18858
|
+
return this._applyPostfix(val, isArray2, postfix);
|
|
18859
18859
|
}
|
|
18860
18860
|
applyPostfix(value, postfix) {
|
|
18861
18861
|
if (this.context.async) {
|
|
18862
18862
|
return this.applyPostfixAsync(value, postfix);
|
|
18863
18863
|
} else {
|
|
18864
|
-
const { val
|
|
18865
|
-
return this._applyPostfix(
|
|
18864
|
+
const { val, isArray: isArray2 } = this.extractRefValue(value);
|
|
18865
|
+
return this._applyPostfix(val, isArray2, postfix);
|
|
18866
18866
|
}
|
|
18867
18867
|
}
|
|
18868
18868
|
_applyInfix(res1, infix, res2) {
|
|
@@ -25328,7 +25328,7 @@ var require_deflate = __commonJS({
|
|
|
25328
25328
|
}
|
|
25329
25329
|
function deflate(strm, flush) {
|
|
25330
25330
|
var old_flush, s;
|
|
25331
|
-
var beg,
|
|
25331
|
+
var beg, val;
|
|
25332
25332
|
if (!strm || !strm.state || flush > Z_BLOCK || flush < 0) {
|
|
25333
25333
|
return strm ? err2(strm, Z_STREAM_ERROR) : Z_STREAM_ERROR;
|
|
25334
25334
|
}
|
|
@@ -25440,21 +25440,21 @@ var require_deflate = __commonJS({
|
|
|
25440
25440
|
flush_pending(strm);
|
|
25441
25441
|
beg = s.pending;
|
|
25442
25442
|
if (s.pending === s.pending_buf_size) {
|
|
25443
|
-
|
|
25443
|
+
val = 1;
|
|
25444
25444
|
break;
|
|
25445
25445
|
}
|
|
25446
25446
|
}
|
|
25447
25447
|
if (s.gzindex < s.gzhead.name.length) {
|
|
25448
|
-
|
|
25448
|
+
val = s.gzhead.name.charCodeAt(s.gzindex++) & 255;
|
|
25449
25449
|
} else {
|
|
25450
|
-
|
|
25450
|
+
val = 0;
|
|
25451
25451
|
}
|
|
25452
|
-
put_byte(s,
|
|
25453
|
-
} while (
|
|
25452
|
+
put_byte(s, val);
|
|
25453
|
+
} while (val !== 0);
|
|
25454
25454
|
if (s.gzhead.hcrc && s.pending > beg) {
|
|
25455
25455
|
strm.adler = crc32(strm.adler, s.pending_buf, s.pending - beg, beg);
|
|
25456
25456
|
}
|
|
25457
|
-
if (
|
|
25457
|
+
if (val === 0) {
|
|
25458
25458
|
s.gzindex = 0;
|
|
25459
25459
|
s.status = COMMENT_STATE;
|
|
25460
25460
|
}
|
|
@@ -25473,21 +25473,21 @@ var require_deflate = __commonJS({
|
|
|
25473
25473
|
flush_pending(strm);
|
|
25474
25474
|
beg = s.pending;
|
|
25475
25475
|
if (s.pending === s.pending_buf_size) {
|
|
25476
|
-
|
|
25476
|
+
val = 1;
|
|
25477
25477
|
break;
|
|
25478
25478
|
}
|
|
25479
25479
|
}
|
|
25480
25480
|
if (s.gzindex < s.gzhead.comment.length) {
|
|
25481
|
-
|
|
25481
|
+
val = s.gzhead.comment.charCodeAt(s.gzindex++) & 255;
|
|
25482
25482
|
} else {
|
|
25483
|
-
|
|
25483
|
+
val = 0;
|
|
25484
25484
|
}
|
|
25485
|
-
put_byte(s,
|
|
25486
|
-
} while (
|
|
25485
|
+
put_byte(s, val);
|
|
25486
|
+
} while (val !== 0);
|
|
25487
25487
|
if (s.gzhead.hcrc && s.pending > beg) {
|
|
25488
25488
|
strm.adler = crc32(strm.adler, s.pending_buf, s.pending - beg, beg);
|
|
25489
25489
|
}
|
|
25490
|
-
if (
|
|
25490
|
+
if (val === 0) {
|
|
25491
25491
|
s.status = HCRC_STATE;
|
|
25492
25492
|
}
|
|
25493
25493
|
} else {
|
|
@@ -29627,9 +29627,24 @@ var require_util2 = __commonJS({
|
|
|
29627
29627
|
return "";
|
|
29628
29628
|
}
|
|
29629
29629
|
};
|
|
29630
|
+
var DANGEROUS_PROPERTY_NAMES2 = [
|
|
29631
|
+
// '__proto__',
|
|
29632
|
+
// 'constructor',
|
|
29633
|
+
// 'prototype',
|
|
29634
|
+
"hasOwnProperty",
|
|
29635
|
+
"toString",
|
|
29636
|
+
"valueOf",
|
|
29637
|
+
"__defineGetter__",
|
|
29638
|
+
"__defineSetter__",
|
|
29639
|
+
"__lookupGetter__",
|
|
29640
|
+
"__lookupSetter__"
|
|
29641
|
+
];
|
|
29642
|
+
var criticalProperties2 = ["__proto__", "constructor", "prototype"];
|
|
29630
29643
|
exports2.isName = isName2;
|
|
29631
29644
|
exports2.getAllMatches = getAllMatches2;
|
|
29632
29645
|
exports2.nameRegexp = nameRegexp2;
|
|
29646
|
+
exports2.DANGEROUS_PROPERTY_NAMES = DANGEROUS_PROPERTY_NAMES2;
|
|
29647
|
+
exports2.criticalProperties = criticalProperties2;
|
|
29633
29648
|
}
|
|
29634
29649
|
});
|
|
29635
29650
|
|
|
@@ -29948,6 +29963,13 @@ var require_validator = __commonJS({
|
|
|
29948
29963
|
// ../../node_modules/fast-xml-parser/src/xmlparser/OptionsBuilder.js
|
|
29949
29964
|
var require_OptionsBuilder = __commonJS({
|
|
29950
29965
|
"../../node_modules/fast-xml-parser/src/xmlparser/OptionsBuilder.js"(exports2) {
|
|
29966
|
+
var { DANGEROUS_PROPERTY_NAMES: DANGEROUS_PROPERTY_NAMES2, criticalProperties: criticalProperties2 } = require_util2();
|
|
29967
|
+
var defaultOnDangerousProperty2 = (name) => {
|
|
29968
|
+
if (DANGEROUS_PROPERTY_NAMES2.includes(name)) {
|
|
29969
|
+
return "__" + name;
|
|
29970
|
+
}
|
|
29971
|
+
return name;
|
|
29972
|
+
};
|
|
29951
29973
|
var defaultOptions3 = {
|
|
29952
29974
|
preserveOrder: false,
|
|
29953
29975
|
attributeNamePrefix: "@_",
|
|
@@ -29969,11 +29991,11 @@ var require_OptionsBuilder = __commonJS({
|
|
|
29969
29991
|
leadingZeros: true,
|
|
29970
29992
|
eNotation: true
|
|
29971
29993
|
},
|
|
29972
|
-
tagValueProcessor: function(tagName,
|
|
29973
|
-
return
|
|
29994
|
+
tagValueProcessor: function(tagName, val) {
|
|
29995
|
+
return val;
|
|
29974
29996
|
},
|
|
29975
|
-
attributeValueProcessor: function(attrName,
|
|
29976
|
-
return
|
|
29997
|
+
attributeValueProcessor: function(attrName, val) {
|
|
29998
|
+
return val;
|
|
29977
29999
|
},
|
|
29978
30000
|
stopNodes: [],
|
|
29979
30001
|
//nested tags will not be parsed even for errors
|
|
@@ -29989,11 +30011,75 @@ var require_OptionsBuilder = __commonJS({
|
|
|
29989
30011
|
transformAttributeName: false,
|
|
29990
30012
|
updateTag: function(tagName, jPath, attrs) {
|
|
29991
30013
|
return tagName;
|
|
29992
|
-
}
|
|
30014
|
+
},
|
|
29993
30015
|
// skipEmptyListItem: false
|
|
30016
|
+
captureMetaData: false,
|
|
30017
|
+
maxNestedTags: 100,
|
|
30018
|
+
strictReservedNames: true,
|
|
30019
|
+
onDangerousProperty: defaultOnDangerousProperty2
|
|
29994
30020
|
};
|
|
30021
|
+
function validatePropertyName2(propertyName, optionName) {
|
|
30022
|
+
if (typeof propertyName !== "string") {
|
|
30023
|
+
return;
|
|
30024
|
+
}
|
|
30025
|
+
const normalized = propertyName.toLowerCase();
|
|
30026
|
+
if (DANGEROUS_PROPERTY_NAMES2.some((dangerous) => normalized === dangerous.toLowerCase())) {
|
|
30027
|
+
throw new Error(
|
|
30028
|
+
`[SECURITY] Invalid ${optionName}: "${propertyName}" is a reserved JavaScript keyword that could cause prototype pollution`
|
|
30029
|
+
);
|
|
30030
|
+
}
|
|
30031
|
+
if (criticalProperties2.some((dangerous) => normalized === dangerous.toLowerCase())) {
|
|
30032
|
+
throw new Error(
|
|
30033
|
+
`[SECURITY] Invalid ${optionName}: "${propertyName}" is a reserved JavaScript keyword that could cause prototype pollution`
|
|
30034
|
+
);
|
|
30035
|
+
}
|
|
30036
|
+
}
|
|
30037
|
+
function normalizeProcessEntities2(value) {
|
|
30038
|
+
if (typeof value === "boolean") {
|
|
30039
|
+
return {
|
|
30040
|
+
enabled: value,
|
|
30041
|
+
// true or false
|
|
30042
|
+
maxEntitySize: 1e4,
|
|
30043
|
+
maxExpansionDepth: 10,
|
|
30044
|
+
maxTotalExpansions: 1e3,
|
|
30045
|
+
maxExpandedLength: 1e5,
|
|
30046
|
+
allowedTags: null,
|
|
30047
|
+
tagFilter: null
|
|
30048
|
+
};
|
|
30049
|
+
}
|
|
30050
|
+
if (typeof value === "object" && value !== null) {
|
|
30051
|
+
return {
|
|
30052
|
+
enabled: value.enabled !== false,
|
|
30053
|
+
maxEntitySize: Math.max(1, value.maxEntitySize ?? 1e4),
|
|
30054
|
+
maxExpansionDepth: Math.max(1, value.maxExpansionDepth ?? 1e4),
|
|
30055
|
+
maxTotalExpansions: Math.max(1, value.maxTotalExpansions ?? Infinity),
|
|
30056
|
+
maxExpandedLength: Math.max(1, value.maxExpandedLength ?? 1e5),
|
|
30057
|
+
maxEntityCount: Math.max(1, value.maxEntityCount ?? 1e3),
|
|
30058
|
+
allowedTags: value.allowedTags ?? null,
|
|
30059
|
+
tagFilter: value.tagFilter ?? null
|
|
30060
|
+
};
|
|
30061
|
+
}
|
|
30062
|
+
return normalizeProcessEntities2(true);
|
|
30063
|
+
}
|
|
29995
30064
|
var buildOptions2 = function(options) {
|
|
29996
|
-
|
|
30065
|
+
const built = Object.assign({}, defaultOptions3, options);
|
|
30066
|
+
const propertyNameOptions = [
|
|
30067
|
+
{ value: built.attributeNamePrefix, name: "attributeNamePrefix" },
|
|
30068
|
+
{ value: built.attributesGroupName, name: "attributesGroupName" },
|
|
30069
|
+
{ value: built.textNodeName, name: "textNodeName" },
|
|
30070
|
+
{ value: built.cdataPropName, name: "cdataPropName" },
|
|
30071
|
+
{ value: built.commentPropName, name: "commentPropName" }
|
|
30072
|
+
];
|
|
30073
|
+
for (const { value, name } of propertyNameOptions) {
|
|
30074
|
+
if (value) {
|
|
30075
|
+
validatePropertyName2(value, name);
|
|
30076
|
+
}
|
|
30077
|
+
}
|
|
30078
|
+
if (built.onDangerousProperty === null) {
|
|
30079
|
+
built.onDangerousProperty = defaultOnDangerousProperty2;
|
|
30080
|
+
}
|
|
30081
|
+
built.processEntities = normalizeProcessEntities2(built.processEntities);
|
|
30082
|
+
return built;
|
|
29997
30083
|
};
|
|
29998
30084
|
exports2.buildOptions = buildOptions2;
|
|
29999
30085
|
exports2.defaultOptions = defaultOptions3;
|
|
@@ -30010,9 +30096,9 @@ var require_xmlNode = __commonJS({
|
|
|
30010
30096
|
this.child = [];
|
|
30011
30097
|
this[":@"] = {};
|
|
30012
30098
|
}
|
|
30013
|
-
add(key,
|
|
30099
|
+
add(key, val) {
|
|
30014
30100
|
if (key === "__proto__") key = "#__proto__";
|
|
30015
|
-
this.child.push({ [key]:
|
|
30101
|
+
this.child.push({ [key]: val });
|
|
30016
30102
|
}
|
|
30017
30103
|
addChild(node) {
|
|
30018
30104
|
if (node.tagname === "__proto__") node.tagname = "#__proto__";
|
|
@@ -30031,89 +30117,279 @@ var require_xmlNode = __commonJS({
|
|
|
30031
30117
|
var require_DocTypeReader = __commonJS({
|
|
30032
30118
|
"../../node_modules/fast-xml-parser/src/xmlparser/DocTypeReader.js"(exports2, module2) {
|
|
30033
30119
|
var util = require_util2();
|
|
30034
|
-
|
|
30035
|
-
|
|
30036
|
-
|
|
30037
|
-
|
|
30038
|
-
|
|
30039
|
-
|
|
30040
|
-
|
|
30041
|
-
|
|
30042
|
-
|
|
30043
|
-
|
|
30044
|
-
|
|
30045
|
-
|
|
30046
|
-
|
|
30047
|
-
|
|
30048
|
-
|
|
30049
|
-
|
|
30050
|
-
|
|
30051
|
-
|
|
30052
|
-
|
|
30053
|
-
|
|
30054
|
-
|
|
30055
|
-
|
|
30056
|
-
|
|
30057
|
-
|
|
30058
|
-
|
|
30059
|
-
|
|
30060
|
-
|
|
30061
|
-
|
|
30120
|
+
var DocTypeReader2 = class {
|
|
30121
|
+
constructor(options) {
|
|
30122
|
+
this.suppressValidationErr = !options;
|
|
30123
|
+
this.options = options || {};
|
|
30124
|
+
}
|
|
30125
|
+
readDocType(xmlData, i) {
|
|
30126
|
+
const entities = /* @__PURE__ */ Object.create(null);
|
|
30127
|
+
let entityCount = 0;
|
|
30128
|
+
if (xmlData[i + 3] === "O" && xmlData[i + 4] === "C" && xmlData[i + 5] === "T" && xmlData[i + 6] === "Y" && xmlData[i + 7] === "P" && xmlData[i + 8] === "E") {
|
|
30129
|
+
i = i + 9;
|
|
30130
|
+
let angleBracketsCount = 1;
|
|
30131
|
+
let hasBody = false, comment = false;
|
|
30132
|
+
let exp = "";
|
|
30133
|
+
for (; i < xmlData.length; i++) {
|
|
30134
|
+
if (xmlData[i] === "<" && !comment) {
|
|
30135
|
+
if (hasBody && hasSeq2(xmlData, "!ENTITY", i)) {
|
|
30136
|
+
i += 7;
|
|
30137
|
+
let entityName, val;
|
|
30138
|
+
[entityName, val, i] = this.readEntityExp(xmlData, i + 1, this.suppressValidationErr);
|
|
30139
|
+
if (val.indexOf("&") === -1) {
|
|
30140
|
+
if (this.options.enabled !== false && this.options.maxEntityCount != null && entityCount >= this.options.maxEntityCount) {
|
|
30141
|
+
throw new Error(
|
|
30142
|
+
`Entity count (${entityCount + 1}) exceeds maximum allowed (${this.options.maxEntityCount})`
|
|
30143
|
+
);
|
|
30144
|
+
}
|
|
30145
|
+
const escaped = entityName.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
30146
|
+
entities[entityName] = {
|
|
30147
|
+
regx: RegExp(`&${escaped};`, "g"),
|
|
30148
|
+
val
|
|
30149
|
+
};
|
|
30150
|
+
entityCount++;
|
|
30151
|
+
}
|
|
30152
|
+
} else if (hasBody && hasSeq2(xmlData, "!ELEMENT", i)) {
|
|
30153
|
+
i += 8;
|
|
30154
|
+
const { index } = this.readElementExp(xmlData, i + 1);
|
|
30155
|
+
i = index;
|
|
30156
|
+
} else if (hasBody && hasSeq2(xmlData, "!ATTLIST", i)) {
|
|
30157
|
+
i += 8;
|
|
30158
|
+
} else if (hasBody && hasSeq2(xmlData, "!NOTATION", i)) {
|
|
30159
|
+
i += 9;
|
|
30160
|
+
const { index } = this.readNotationExp(xmlData, i + 1, this.suppressValidationErr);
|
|
30161
|
+
i = index;
|
|
30162
|
+
} else if (hasSeq2(xmlData, "!--", i)) {
|
|
30163
|
+
comment = true;
|
|
30164
|
+
} else {
|
|
30165
|
+
throw new Error(`Invalid DOCTYPE`);
|
|
30166
|
+
}
|
|
30167
|
+
angleBracketsCount++;
|
|
30168
|
+
exp = "";
|
|
30169
|
+
} else if (xmlData[i] === ">") {
|
|
30170
|
+
if (comment) {
|
|
30171
|
+
if (xmlData[i - 1] === "-" && xmlData[i - 2] === "-") {
|
|
30172
|
+
comment = false;
|
|
30173
|
+
angleBracketsCount--;
|
|
30174
|
+
}
|
|
30175
|
+
} else {
|
|
30062
30176
|
angleBracketsCount--;
|
|
30063
30177
|
}
|
|
30178
|
+
if (angleBracketsCount === 0) {
|
|
30179
|
+
break;
|
|
30180
|
+
}
|
|
30181
|
+
} else if (xmlData[i] === "[") {
|
|
30182
|
+
hasBody = true;
|
|
30064
30183
|
} else {
|
|
30065
|
-
|
|
30184
|
+
exp += xmlData[i];
|
|
30066
30185
|
}
|
|
30067
|
-
|
|
30068
|
-
|
|
30186
|
+
}
|
|
30187
|
+
if (angleBracketsCount !== 0) {
|
|
30188
|
+
throw new Error(`Unclosed DOCTYPE`);
|
|
30189
|
+
}
|
|
30190
|
+
} else {
|
|
30191
|
+
throw new Error(`Invalid Tag instead of DOCTYPE`);
|
|
30192
|
+
}
|
|
30193
|
+
return { entities, i };
|
|
30194
|
+
}
|
|
30195
|
+
readEntityExp(xmlData, i) {
|
|
30196
|
+
i = skipWhitespace2(xmlData, i);
|
|
30197
|
+
let entityName = "";
|
|
30198
|
+
while (i < xmlData.length && !/\s/.test(xmlData[i]) && xmlData[i] !== '"' && xmlData[i] !== "'") {
|
|
30199
|
+
entityName += xmlData[i];
|
|
30200
|
+
i++;
|
|
30201
|
+
}
|
|
30202
|
+
validateEntityName3(entityName);
|
|
30203
|
+
i = skipWhitespace2(xmlData, i);
|
|
30204
|
+
if (!this.suppressValidationErr) {
|
|
30205
|
+
if (xmlData.substring(i, i + 6).toUpperCase() === "SYSTEM") {
|
|
30206
|
+
throw new Error("External entities are not supported");
|
|
30207
|
+
} else if (xmlData[i] === "%") {
|
|
30208
|
+
throw new Error("Parameter entities are not supported");
|
|
30209
|
+
}
|
|
30210
|
+
}
|
|
30211
|
+
let entityValue = "";
|
|
30212
|
+
[i, entityValue] = this.readIdentifierVal(xmlData, i, "entity");
|
|
30213
|
+
if (this.options.enabled !== false && this.options.maxEntitySize != null && entityValue.length > this.options.maxEntitySize) {
|
|
30214
|
+
throw new Error(
|
|
30215
|
+
`Entity "${entityName}" size (${entityValue.length}) exceeds maximum allowed size (${this.options.maxEntitySize})`
|
|
30216
|
+
);
|
|
30217
|
+
}
|
|
30218
|
+
i--;
|
|
30219
|
+
return [entityName, entityValue, i];
|
|
30220
|
+
}
|
|
30221
|
+
readNotationExp(xmlData, i) {
|
|
30222
|
+
i = skipWhitespace2(xmlData, i);
|
|
30223
|
+
let notationName = "";
|
|
30224
|
+
while (i < xmlData.length && !/\s/.test(xmlData[i])) {
|
|
30225
|
+
notationName += xmlData[i];
|
|
30226
|
+
i++;
|
|
30227
|
+
}
|
|
30228
|
+
!this.suppressValidationErr && validateEntityName3(notationName);
|
|
30229
|
+
i = skipWhitespace2(xmlData, i);
|
|
30230
|
+
const identifierType = xmlData.substring(i, i + 6).toUpperCase();
|
|
30231
|
+
if (!this.suppressValidationErr && identifierType !== "SYSTEM" && identifierType !== "PUBLIC") {
|
|
30232
|
+
throw new Error(`Expected SYSTEM or PUBLIC, found "${identifierType}"`);
|
|
30233
|
+
}
|
|
30234
|
+
i += identifierType.length;
|
|
30235
|
+
i = skipWhitespace2(xmlData, i);
|
|
30236
|
+
let publicIdentifier = null;
|
|
30237
|
+
let systemIdentifier = null;
|
|
30238
|
+
if (identifierType === "PUBLIC") {
|
|
30239
|
+
[i, publicIdentifier] = this.readIdentifierVal(xmlData, i, "publicIdentifier");
|
|
30240
|
+
i = skipWhitespace2(xmlData, i);
|
|
30241
|
+
if (xmlData[i] === '"' || xmlData[i] === "'") {
|
|
30242
|
+
[i, systemIdentifier] = this.readIdentifierVal(xmlData, i, "systemIdentifier");
|
|
30243
|
+
}
|
|
30244
|
+
} else if (identifierType === "SYSTEM") {
|
|
30245
|
+
[i, systemIdentifier] = this.readIdentifierVal(xmlData, i, "systemIdentifier");
|
|
30246
|
+
if (!this.suppressValidationErr && !systemIdentifier) {
|
|
30247
|
+
throw new Error("Missing mandatory system identifier for SYSTEM notation");
|
|
30248
|
+
}
|
|
30249
|
+
}
|
|
30250
|
+
return { notationName, publicIdentifier, systemIdentifier, index: --i };
|
|
30251
|
+
}
|
|
30252
|
+
readIdentifierVal(xmlData, i, type) {
|
|
30253
|
+
let identifierVal = "";
|
|
30254
|
+
const startChar = xmlData[i];
|
|
30255
|
+
if (startChar !== '"' && startChar !== "'") {
|
|
30256
|
+
throw new Error(`Expected quoted string, found "${startChar}"`);
|
|
30257
|
+
}
|
|
30258
|
+
i++;
|
|
30259
|
+
while (i < xmlData.length && xmlData[i] !== startChar) {
|
|
30260
|
+
identifierVal += xmlData[i];
|
|
30261
|
+
i++;
|
|
30262
|
+
}
|
|
30263
|
+
if (xmlData[i] !== startChar) {
|
|
30264
|
+
throw new Error(`Unterminated ${type} value`);
|
|
30265
|
+
}
|
|
30266
|
+
i++;
|
|
30267
|
+
return [i, identifierVal];
|
|
30268
|
+
}
|
|
30269
|
+
readElementExp(xmlData, i) {
|
|
30270
|
+
i = skipWhitespace2(xmlData, i);
|
|
30271
|
+
let elementName = "";
|
|
30272
|
+
while (i < xmlData.length && !/\s/.test(xmlData[i])) {
|
|
30273
|
+
elementName += xmlData[i];
|
|
30274
|
+
i++;
|
|
30275
|
+
}
|
|
30276
|
+
if (!this.suppressValidationErr && !util.isName(elementName)) {
|
|
30277
|
+
throw new Error(`Invalid element name: "${elementName}"`);
|
|
30278
|
+
}
|
|
30279
|
+
i = skipWhitespace2(xmlData, i);
|
|
30280
|
+
let contentModel = "";
|
|
30281
|
+
if (xmlData[i] === "E" && hasSeq2(xmlData, "MPTY", i)) {
|
|
30282
|
+
i += 4;
|
|
30283
|
+
} else if (xmlData[i] === "A" && hasSeq2(xmlData, "NY", i)) {
|
|
30284
|
+
i += 2;
|
|
30285
|
+
} else if (xmlData[i] === "(") {
|
|
30286
|
+
i++;
|
|
30287
|
+
while (i < xmlData.length && xmlData[i] !== ")") {
|
|
30288
|
+
contentModel += xmlData[i];
|
|
30289
|
+
i++;
|
|
30290
|
+
}
|
|
30291
|
+
if (xmlData[i] !== ")") {
|
|
30292
|
+
throw new Error("Unterminated content model");
|
|
30293
|
+
}
|
|
30294
|
+
} else if (!this.suppressValidationErr) {
|
|
30295
|
+
throw new Error(`Invalid Element Expression, found "${xmlData[i]}"`);
|
|
30296
|
+
}
|
|
30297
|
+
return {
|
|
30298
|
+
elementName,
|
|
30299
|
+
contentModel: contentModel.trim(),
|
|
30300
|
+
index: i
|
|
30301
|
+
};
|
|
30302
|
+
}
|
|
30303
|
+
readAttlistExp(xmlData, i) {
|
|
30304
|
+
i = skipWhitespace2(xmlData, i);
|
|
30305
|
+
let elementName = "";
|
|
30306
|
+
while (i < xmlData.length && !/\s/.test(xmlData[i])) {
|
|
30307
|
+
elementName += xmlData[i];
|
|
30308
|
+
i++;
|
|
30309
|
+
}
|
|
30310
|
+
validateEntityName3(elementName);
|
|
30311
|
+
i = skipWhitespace2(xmlData, i);
|
|
30312
|
+
let attributeName = "";
|
|
30313
|
+
while (i < xmlData.length && !/\s/.test(xmlData[i])) {
|
|
30314
|
+
attributeName += xmlData[i];
|
|
30315
|
+
i++;
|
|
30316
|
+
}
|
|
30317
|
+
if (!validateEntityName3(attributeName)) {
|
|
30318
|
+
throw new Error(`Invalid attribute name: "${attributeName}"`);
|
|
30319
|
+
}
|
|
30320
|
+
i = skipWhitespace2(xmlData, i);
|
|
30321
|
+
let attributeType = "";
|
|
30322
|
+
if (xmlData.substring(i, i + 8).toUpperCase() === "NOTATION") {
|
|
30323
|
+
attributeType = "NOTATION";
|
|
30324
|
+
i += 8;
|
|
30325
|
+
i = skipWhitespace2(xmlData, i);
|
|
30326
|
+
if (xmlData[i] !== "(") {
|
|
30327
|
+
throw new Error(`Expected '(', found "${xmlData[i]}"`);
|
|
30328
|
+
}
|
|
30329
|
+
i++;
|
|
30330
|
+
let allowedNotations = [];
|
|
30331
|
+
while (i < xmlData.length && xmlData[i] !== ")") {
|
|
30332
|
+
let notation = "";
|
|
30333
|
+
while (i < xmlData.length && xmlData[i] !== "|" && xmlData[i] !== ")") {
|
|
30334
|
+
notation += xmlData[i];
|
|
30335
|
+
i++;
|
|
30336
|
+
}
|
|
30337
|
+
notation = notation.trim();
|
|
30338
|
+
if (!validateEntityName3(notation)) {
|
|
30339
|
+
throw new Error(`Invalid notation name: "${notation}"`);
|
|
30340
|
+
}
|
|
30341
|
+
allowedNotations.push(notation);
|
|
30342
|
+
if (xmlData[i] === "|") {
|
|
30343
|
+
i++;
|
|
30344
|
+
i = skipWhitespace2(xmlData, i);
|
|
30069
30345
|
}
|
|
30070
|
-
}
|
|
30071
|
-
|
|
30072
|
-
|
|
30073
|
-
|
|
30346
|
+
}
|
|
30347
|
+
if (xmlData[i] !== ")") {
|
|
30348
|
+
throw new Error("Unterminated list of notations");
|
|
30349
|
+
}
|
|
30350
|
+
i++;
|
|
30351
|
+
attributeType += " (" + allowedNotations.join("|") + ")";
|
|
30352
|
+
} else {
|
|
30353
|
+
while (i < xmlData.length && !/\s/.test(xmlData[i])) {
|
|
30354
|
+
attributeType += xmlData[i];
|
|
30355
|
+
i++;
|
|
30356
|
+
}
|
|
30357
|
+
const validTypes = ["CDATA", "ID", "IDREF", "IDREFS", "ENTITY", "ENTITIES", "NMTOKEN", "NMTOKENS"];
|
|
30358
|
+
if (!this.suppressValidationErr && !validTypes.includes(attributeType.toUpperCase())) {
|
|
30359
|
+
throw new Error(`Invalid attribute type: "${attributeType}"`);
|
|
30074
30360
|
}
|
|
30075
30361
|
}
|
|
30076
|
-
|
|
30077
|
-
|
|
30362
|
+
i = skipWhitespace2(xmlData, i);
|
|
30363
|
+
let defaultValue = "";
|
|
30364
|
+
if (xmlData.substring(i, i + 8).toUpperCase() === "#REQUIRED") {
|
|
30365
|
+
defaultValue = "#REQUIRED";
|
|
30366
|
+
i += 8;
|
|
30367
|
+
} else if (xmlData.substring(i, i + 7).toUpperCase() === "#IMPLIED") {
|
|
30368
|
+
defaultValue = "#IMPLIED";
|
|
30369
|
+
i += 7;
|
|
30370
|
+
} else {
|
|
30371
|
+
[i, defaultValue] = this.readIdentifierVal(xmlData, i, "ATTLIST");
|
|
30078
30372
|
}
|
|
30079
|
-
|
|
30080
|
-
|
|
30373
|
+
return {
|
|
30374
|
+
elementName,
|
|
30375
|
+
attributeName,
|
|
30376
|
+
attributeType,
|
|
30377
|
+
defaultValue,
|
|
30378
|
+
index: i
|
|
30379
|
+
};
|
|
30081
30380
|
}
|
|
30082
|
-
|
|
30083
|
-
|
|
30084
|
-
|
|
30085
|
-
|
|
30086
|
-
for (; i < xmlData.length && (xmlData[i] !== "'" && xmlData[i] !== '"'); i++) {
|
|
30087
|
-
entityName2 += xmlData[i];
|
|
30381
|
+
};
|
|
30382
|
+
var skipWhitespace2 = (data, index) => {
|
|
30383
|
+
while (index < data.length && /\s/.test(data[index])) {
|
|
30384
|
+
index++;
|
|
30088
30385
|
}
|
|
30089
|
-
|
|
30090
|
-
|
|
30091
|
-
|
|
30092
|
-
let
|
|
30093
|
-
|
|
30094
|
-
val2 += xmlData[i];
|
|
30386
|
+
return index;
|
|
30387
|
+
};
|
|
30388
|
+
function hasSeq2(data, seq, i) {
|
|
30389
|
+
for (let j = 0; j < seq.length; j++) {
|
|
30390
|
+
if (seq[j] !== data[i + j + 1]) return false;
|
|
30095
30391
|
}
|
|
30096
|
-
return
|
|
30097
|
-
}
|
|
30098
|
-
function isComment(xmlData, i) {
|
|
30099
|
-
if (xmlData[i + 1] === "!" && xmlData[i + 2] === "-" && xmlData[i + 3] === "-") return true;
|
|
30100
|
-
return false;
|
|
30101
|
-
}
|
|
30102
|
-
function isEntity(xmlData, i) {
|
|
30103
|
-
if (xmlData[i + 1] === "!" && xmlData[i + 2] === "E" && xmlData[i + 3] === "N" && xmlData[i + 4] === "T" && xmlData[i + 5] === "I" && xmlData[i + 6] === "T" && xmlData[i + 7] === "Y") return true;
|
|
30104
|
-
return false;
|
|
30105
|
-
}
|
|
30106
|
-
function isElement(xmlData, i) {
|
|
30107
|
-
if (xmlData[i + 1] === "!" && xmlData[i + 2] === "E" && xmlData[i + 3] === "L" && xmlData[i + 4] === "E" && xmlData[i + 5] === "M" && xmlData[i + 6] === "E" && xmlData[i + 7] === "N" && xmlData[i + 8] === "T") return true;
|
|
30108
|
-
return false;
|
|
30109
|
-
}
|
|
30110
|
-
function isAttlist(xmlData, i) {
|
|
30111
|
-
if (xmlData[i + 1] === "!" && xmlData[i + 2] === "A" && xmlData[i + 3] === "T" && xmlData[i + 4] === "T" && xmlData[i + 5] === "L" && xmlData[i + 6] === "I" && xmlData[i + 7] === "S" && xmlData[i + 8] === "T") return true;
|
|
30112
|
-
return false;
|
|
30113
|
-
}
|
|
30114
|
-
function isNotation(xmlData, i) {
|
|
30115
|
-
if (xmlData[i + 1] === "!" && xmlData[i + 2] === "N" && xmlData[i + 3] === "O" && xmlData[i + 4] === "T" && xmlData[i + 5] === "A" && xmlData[i + 6] === "T" && xmlData[i + 7] === "I" && xmlData[i + 8] === "O" && xmlData[i + 9] === "N") return true;
|
|
30116
|
-
return false;
|
|
30392
|
+
return true;
|
|
30117
30393
|
}
|
|
30118
30394
|
function validateEntityName3(name) {
|
|
30119
30395
|
if (util.isName(name))
|
|
@@ -30121,7 +30397,7 @@ var require_DocTypeReader = __commonJS({
|
|
|
30121
30397
|
else
|
|
30122
30398
|
throw new Error(`Invalid entity name ${name}`);
|
|
30123
30399
|
}
|
|
30124
|
-
module2.exports =
|
|
30400
|
+
module2.exports = DocTypeReader2;
|
|
30125
30401
|
}
|
|
30126
30402
|
});
|
|
30127
30403
|
|
|
@@ -30213,14 +30489,40 @@ var require_strnum = __commonJS({
|
|
|
30213
30489
|
}
|
|
30214
30490
|
});
|
|
30215
30491
|
|
|
30492
|
+
// ../../node_modules/fast-xml-parser/src/ignoreAttributes.js
|
|
30493
|
+
var require_ignoreAttributes = __commonJS({
|
|
30494
|
+
"../../node_modules/fast-xml-parser/src/ignoreAttributes.js"(exports2, module2) {
|
|
30495
|
+
function getIgnoreAttributesFn2(ignoreAttributes) {
|
|
30496
|
+
if (typeof ignoreAttributes === "function") {
|
|
30497
|
+
return ignoreAttributes;
|
|
30498
|
+
}
|
|
30499
|
+
if (Array.isArray(ignoreAttributes)) {
|
|
30500
|
+
return (attrName) => {
|
|
30501
|
+
for (const pattern of ignoreAttributes) {
|
|
30502
|
+
if (typeof pattern === "string" && attrName === pattern) {
|
|
30503
|
+
return true;
|
|
30504
|
+
}
|
|
30505
|
+
if (pattern instanceof RegExp && pattern.test(attrName)) {
|
|
30506
|
+
return true;
|
|
30507
|
+
}
|
|
30508
|
+
}
|
|
30509
|
+
};
|
|
30510
|
+
}
|
|
30511
|
+
return () => false;
|
|
30512
|
+
}
|
|
30513
|
+
module2.exports = getIgnoreAttributesFn2;
|
|
30514
|
+
}
|
|
30515
|
+
});
|
|
30516
|
+
|
|
30216
30517
|
// ../../node_modules/fast-xml-parser/src/xmlparser/OrderedObjParser.js
|
|
30217
30518
|
var require_OrderedObjParser = __commonJS({
|
|
30218
30519
|
"../../node_modules/fast-xml-parser/src/xmlparser/OrderedObjParser.js"(exports2, module2) {
|
|
30219
30520
|
"use strict";
|
|
30220
30521
|
var util = require_util2();
|
|
30221
30522
|
var xmlNode = require_xmlNode();
|
|
30222
|
-
var
|
|
30523
|
+
var DocTypeReader2 = require_DocTypeReader();
|
|
30223
30524
|
var toNumber2 = require_strnum();
|
|
30525
|
+
var getIgnoreAttributesFn2 = require_ignoreAttributes();
|
|
30224
30526
|
var OrderedObjParser2 = class {
|
|
30225
30527
|
constructor(options) {
|
|
30226
30528
|
this.options = options;
|
|
@@ -30248,8 +30550,8 @@ var require_OrderedObjParser = __commonJS({
|
|
|
30248
30550
|
"copyright": { regex: /&(copy|#169);/g, val: "\xA9" },
|
|
30249
30551
|
"reg": { regex: /&(reg|#174);/g, val: "\xAE" },
|
|
30250
30552
|
"inr": { regex: /&(inr|#8377);/g, val: "\u20B9" },
|
|
30251
|
-
"num_dec": { regex: /&#([0-9]{1,7});/g, val: (_, str) =>
|
|
30252
|
-
"num_hex": { regex: /&#x([0-9a-fA-F]{1,6});/g, val: (_, str) =>
|
|
30553
|
+
"num_dec": { regex: /&#([0-9]{1,7});/g, val: (_, str) => fromCodePoint(str, 10, "&#") },
|
|
30554
|
+
"num_hex": { regex: /&#x([0-9a-fA-F]{1,6});/g, val: (_, str) => fromCodePoint(str, 16, "&#x") }
|
|
30253
30555
|
};
|
|
30254
30556
|
this.addExternalEntities = addExternalEntities;
|
|
30255
30557
|
this.parseXml = parseXml3;
|
|
@@ -30261,38 +30563,55 @@ var require_OrderedObjParser = __commonJS({
|
|
|
30261
30563
|
this.readStopNodeData = readStopNodeData2;
|
|
30262
30564
|
this.saveTextToParentTag = saveTextToParentTag2;
|
|
30263
30565
|
this.addChild = addChild2;
|
|
30566
|
+
this.ignoreAttributesFn = getIgnoreAttributesFn2(this.options.ignoreAttributes);
|
|
30567
|
+
this.entityExpansionCount = 0;
|
|
30568
|
+
this.currentExpandedLength = 0;
|
|
30569
|
+
if (this.options.stopNodes && this.options.stopNodes.length > 0) {
|
|
30570
|
+
this.stopNodesExact = /* @__PURE__ */ new Set();
|
|
30571
|
+
this.stopNodesWildcard = /* @__PURE__ */ new Set();
|
|
30572
|
+
for (let i = 0; i < this.options.stopNodes.length; i++) {
|
|
30573
|
+
const stopNodeExp = this.options.stopNodes[i];
|
|
30574
|
+
if (typeof stopNodeExp !== "string") continue;
|
|
30575
|
+
if (stopNodeExp.startsWith("*.")) {
|
|
30576
|
+
this.stopNodesWildcard.add(stopNodeExp.substring(2));
|
|
30577
|
+
} else {
|
|
30578
|
+
this.stopNodesExact.add(stopNodeExp);
|
|
30579
|
+
}
|
|
30580
|
+
}
|
|
30581
|
+
}
|
|
30264
30582
|
}
|
|
30265
30583
|
};
|
|
30266
30584
|
function addExternalEntities(externalEntities) {
|
|
30267
30585
|
const entKeys = Object.keys(externalEntities);
|
|
30268
30586
|
for (let i = 0; i < entKeys.length; i++) {
|
|
30269
30587
|
const ent = entKeys[i];
|
|
30588
|
+
const escaped = ent.replace(/[.\-+*:]/g, "\\.");
|
|
30270
30589
|
this.lastEntities[ent] = {
|
|
30271
|
-
regex: new RegExp("&" +
|
|
30590
|
+
regex: new RegExp("&" + escaped + ";", "g"),
|
|
30272
30591
|
val: externalEntities[ent]
|
|
30273
30592
|
};
|
|
30274
30593
|
}
|
|
30275
30594
|
}
|
|
30276
|
-
function parseTextData2(
|
|
30277
|
-
if (
|
|
30595
|
+
function parseTextData2(val, tagName, jPath, dontTrim, hasAttributes, isLeafNode, escapeEntities) {
|
|
30596
|
+
if (val !== void 0) {
|
|
30278
30597
|
if (this.options.trimValues && !dontTrim) {
|
|
30279
|
-
|
|
30598
|
+
val = val.trim();
|
|
30280
30599
|
}
|
|
30281
|
-
if (
|
|
30282
|
-
if (!escapeEntities)
|
|
30283
|
-
const newval = this.options.tagValueProcessor(tagName,
|
|
30600
|
+
if (val.length > 0) {
|
|
30601
|
+
if (!escapeEntities) val = this.replaceEntitiesValue(val, tagName, jPath);
|
|
30602
|
+
const newval = this.options.tagValueProcessor(tagName, val, jPath, hasAttributes, isLeafNode);
|
|
30284
30603
|
if (newval === null || newval === void 0) {
|
|
30285
|
-
return
|
|
30286
|
-
} else if (typeof newval !== typeof
|
|
30604
|
+
return val;
|
|
30605
|
+
} else if (typeof newval !== typeof val || newval !== val) {
|
|
30287
30606
|
return newval;
|
|
30288
30607
|
} else if (this.options.trimValues) {
|
|
30289
|
-
return parseValue2(
|
|
30608
|
+
return parseValue2(val, this.options.parseTagValue, this.options.numberParseOptions);
|
|
30290
30609
|
} else {
|
|
30291
|
-
const trimmedVal =
|
|
30292
|
-
if (trimmedVal ===
|
|
30293
|
-
return parseValue2(
|
|
30610
|
+
const trimmedVal = val.trim();
|
|
30611
|
+
if (trimmedVal === val) {
|
|
30612
|
+
return parseValue2(val, this.options.parseTagValue, this.options.numberParseOptions);
|
|
30294
30613
|
} else {
|
|
30295
|
-
return
|
|
30614
|
+
return val;
|
|
30296
30615
|
}
|
|
30297
30616
|
}
|
|
30298
30617
|
}
|
|
@@ -30313,24 +30632,27 @@ var require_OrderedObjParser = __commonJS({
|
|
|
30313
30632
|
}
|
|
30314
30633
|
var attrsRegx2 = new RegExp(`([^\\s=]+)\\s*(=\\s*(['"])([\\s\\S]*?)\\3)?`, "gm");
|
|
30315
30634
|
function buildAttributesMap2(attrStr, jPath, tagName) {
|
|
30316
|
-
if (
|
|
30635
|
+
if (this.options.ignoreAttributes !== true && typeof attrStr === "string") {
|
|
30317
30636
|
const matches = util.getAllMatches(attrStr, attrsRegx2);
|
|
30318
30637
|
const len = matches.length;
|
|
30319
30638
|
const attrs = {};
|
|
30320
30639
|
for (let i = 0; i < len; i++) {
|
|
30321
30640
|
const attrName = this.resolveNameSpace(matches[i][1]);
|
|
30641
|
+
if (this.ignoreAttributesFn(attrName, jPath)) {
|
|
30642
|
+
continue;
|
|
30643
|
+
}
|
|
30322
30644
|
let oldVal = matches[i][4];
|
|
30323
30645
|
let aName = this.options.attributeNamePrefix + attrName;
|
|
30324
30646
|
if (attrName.length) {
|
|
30325
30647
|
if (this.options.transformAttributeName) {
|
|
30326
30648
|
aName = this.options.transformAttributeName(aName);
|
|
30327
30649
|
}
|
|
30328
|
-
|
|
30650
|
+
aName = sanitizeName2(aName, this.options);
|
|
30329
30651
|
if (oldVal !== void 0) {
|
|
30330
30652
|
if (this.options.trimValues) {
|
|
30331
30653
|
oldVal = oldVal.trim();
|
|
30332
30654
|
}
|
|
30333
|
-
oldVal = this.replaceEntitiesValue(oldVal);
|
|
30655
|
+
oldVal = this.replaceEntitiesValue(oldVal, tagName, jPath);
|
|
30334
30656
|
const newVal = this.options.attributeValueProcessor(attrName, oldVal, jPath);
|
|
30335
30657
|
if (newVal === null || newVal === void 0) {
|
|
30336
30658
|
attrs[aName] = oldVal;
|
|
@@ -30365,6 +30687,9 @@ var require_OrderedObjParser = __commonJS({
|
|
|
30365
30687
|
let currentNode = xmlObj;
|
|
30366
30688
|
let textData = "";
|
|
30367
30689
|
let jPath = "";
|
|
30690
|
+
this.entityExpansionCount = 0;
|
|
30691
|
+
this.currentExpandedLength = 0;
|
|
30692
|
+
const docTypeReader = new DocTypeReader2(this.options.processEntities);
|
|
30368
30693
|
for (let i = 0; i < xmlData.length; i++) {
|
|
30369
30694
|
const ch = xmlData[i];
|
|
30370
30695
|
if (ch === "<") {
|
|
@@ -30409,7 +30734,7 @@ var require_OrderedObjParser = __commonJS({
|
|
|
30409
30734
|
if (tagData.tagName !== tagData.tagExp && tagData.attrExpPresent) {
|
|
30410
30735
|
childNode[":@"] = this.buildAttributesMap(tagData.tagExp, jPath, tagData.tagName);
|
|
30411
30736
|
}
|
|
30412
|
-
this.addChild(currentNode, childNode, jPath);
|
|
30737
|
+
this.addChild(currentNode, childNode, jPath, i);
|
|
30413
30738
|
}
|
|
30414
30739
|
i = tagData.closeIndex + 1;
|
|
30415
30740
|
} else if (xmlData.substr(i + 1, 3) === "!--") {
|
|
@@ -30421,19 +30746,19 @@ var require_OrderedObjParser = __commonJS({
|
|
|
30421
30746
|
}
|
|
30422
30747
|
i = endIndex;
|
|
30423
30748
|
} else if (xmlData.substr(i + 1, 2) === "!D") {
|
|
30424
|
-
const result = readDocType(xmlData, i);
|
|
30749
|
+
const result = docTypeReader.readDocType(xmlData, i);
|
|
30425
30750
|
this.docTypeEntities = result.entities;
|
|
30426
30751
|
i = result.i;
|
|
30427
30752
|
} else if (xmlData.substr(i + 1, 2) === "![") {
|
|
30428
30753
|
const closeIndex = findClosingIndex2(xmlData, "]]>", i, "CDATA is not closed.") - 2;
|
|
30429
30754
|
const tagExp = xmlData.substring(i + 9, closeIndex);
|
|
30430
30755
|
textData = this.saveTextToParentTag(textData, currentNode, jPath);
|
|
30431
|
-
let
|
|
30432
|
-
if (
|
|
30756
|
+
let val = this.parseTextData(tagExp, currentNode.tagname, jPath, true, false, true, true);
|
|
30757
|
+
if (val == void 0) val = "";
|
|
30433
30758
|
if (this.options.cdataPropName) {
|
|
30434
30759
|
currentNode.add(this.options.cdataPropName, [{ [this.options.textNodeName]: tagExp }]);
|
|
30435
30760
|
} else {
|
|
30436
|
-
currentNode.add(this.options.textNodeName,
|
|
30761
|
+
currentNode.add(this.options.textNodeName, val);
|
|
30437
30762
|
}
|
|
30438
30763
|
i = closeIndex + 2;
|
|
30439
30764
|
} else {
|
|
@@ -30444,7 +30769,14 @@ var require_OrderedObjParser = __commonJS({
|
|
|
30444
30769
|
let attrExpPresent = result.attrExpPresent;
|
|
30445
30770
|
let closeIndex = result.closeIndex;
|
|
30446
30771
|
if (this.options.transformTagName) {
|
|
30447
|
-
|
|
30772
|
+
const newTagName = this.options.transformTagName(tagName);
|
|
30773
|
+
if (tagExp === tagName) {
|
|
30774
|
+
tagExp = newTagName;
|
|
30775
|
+
}
|
|
30776
|
+
tagName = newTagName;
|
|
30777
|
+
}
|
|
30778
|
+
if (this.options.strictReservedNames && (tagName === this.options.commentPropName || tagName === this.options.cdataPropName || tagName === this.options.textNodeName || tagName === this.options.attributesGroupName)) {
|
|
30779
|
+
throw new Error(`Invalid tag name: ${tagName}`);
|
|
30448
30780
|
}
|
|
30449
30781
|
if (currentNode && textData) {
|
|
30450
30782
|
if (currentNode.tagname !== "!xml") {
|
|
@@ -30459,7 +30791,8 @@ var require_OrderedObjParser = __commonJS({
|
|
|
30459
30791
|
if (tagName !== xmlObj.tagname) {
|
|
30460
30792
|
jPath += jPath ? "." + tagName : tagName;
|
|
30461
30793
|
}
|
|
30462
|
-
|
|
30794
|
+
const startIndex = i;
|
|
30795
|
+
if (this.isItStopNode(this.stopNodesExact, this.stopNodesWildcard, jPath, tagName)) {
|
|
30463
30796
|
let tagContent = "";
|
|
30464
30797
|
if (tagExp.length > 0 && tagExp.lastIndexOf("/") === tagExp.length - 1) {
|
|
30465
30798
|
if (tagName[tagName.length - 1] === "/") {
|
|
@@ -30487,7 +30820,7 @@ var require_OrderedObjParser = __commonJS({
|
|
|
30487
30820
|
}
|
|
30488
30821
|
jPath = jPath.substr(0, jPath.lastIndexOf("."));
|
|
30489
30822
|
childNode.add(this.options.textNodeName, tagContent);
|
|
30490
|
-
this.addChild(currentNode, childNode, jPath);
|
|
30823
|
+
this.addChild(currentNode, childNode, jPath, startIndex);
|
|
30491
30824
|
} else {
|
|
30492
30825
|
if (tagExp.length > 0 && tagExp.lastIndexOf("/") === tagExp.length - 1) {
|
|
30493
30826
|
if (tagName[tagName.length - 1] === "/") {
|
|
@@ -30498,16 +30831,32 @@ var require_OrderedObjParser = __commonJS({
|
|
|
30498
30831
|
tagExp = tagExp.substr(0, tagExp.length - 1);
|
|
30499
30832
|
}
|
|
30500
30833
|
if (this.options.transformTagName) {
|
|
30501
|
-
|
|
30834
|
+
const newTagName = this.options.transformTagName(tagName);
|
|
30835
|
+
if (tagExp === tagName) {
|
|
30836
|
+
tagExp = newTagName;
|
|
30837
|
+
}
|
|
30838
|
+
tagName = newTagName;
|
|
30502
30839
|
}
|
|
30503
30840
|
const childNode = new xmlNode(tagName);
|
|
30504
30841
|
if (tagName !== tagExp && attrExpPresent) {
|
|
30505
30842
|
childNode[":@"] = this.buildAttributesMap(tagExp, jPath, tagName);
|
|
30506
30843
|
}
|
|
30507
|
-
this.addChild(currentNode, childNode, jPath);
|
|
30844
|
+
this.addChild(currentNode, childNode, jPath, startIndex);
|
|
30508
30845
|
jPath = jPath.substr(0, jPath.lastIndexOf("."));
|
|
30846
|
+
} else if (this.options.unpairedTags.indexOf(tagName) !== -1) {
|
|
30847
|
+
const childNode = new xmlNode(tagName);
|
|
30848
|
+
if (tagName !== tagExp && attrExpPresent) {
|
|
30849
|
+
childNode[":@"] = this.buildAttributesMap(tagExp, jPath);
|
|
30850
|
+
}
|
|
30851
|
+
this.addChild(currentNode, childNode, jPath, startIndex);
|
|
30852
|
+
jPath = jPath.substr(0, jPath.lastIndexOf("."));
|
|
30853
|
+
i = result.closeIndex;
|
|
30854
|
+
continue;
|
|
30509
30855
|
} else {
|
|
30510
30856
|
const childNode = new xmlNode(tagName);
|
|
30857
|
+
if (this.tagsNodeStack.length > this.options.maxNestedTags) {
|
|
30858
|
+
throw new Error("Maximum nested tags exceeded");
|
|
30859
|
+
}
|
|
30511
30860
|
this.tagsNodeStack.push(currentNode);
|
|
30512
30861
|
if (tagName !== tagExp && attrExpPresent) {
|
|
30513
30862
|
childNode[":@"] = this.buildAttributesMap(tagExp, jPath, tagName);
|
|
@@ -30525,59 +30874,110 @@ var require_OrderedObjParser = __commonJS({
|
|
|
30525
30874
|
}
|
|
30526
30875
|
return xmlObj.child;
|
|
30527
30876
|
};
|
|
30528
|
-
function addChild2(currentNode, childNode, jPath) {
|
|
30877
|
+
function addChild2(currentNode, childNode, jPath, startIndex) {
|
|
30878
|
+
if (!this.options.captureMetaData) startIndex = void 0;
|
|
30529
30879
|
const result = this.options.updateTag(childNode.tagname, jPath, childNode[":@"]);
|
|
30530
30880
|
if (result === false) {
|
|
30531
30881
|
} else if (typeof result === "string") {
|
|
30532
30882
|
childNode.tagname = result;
|
|
30533
|
-
currentNode.addChild(childNode);
|
|
30883
|
+
currentNode.addChild(childNode, startIndex);
|
|
30534
30884
|
} else {
|
|
30535
|
-
currentNode.addChild(childNode);
|
|
30885
|
+
currentNode.addChild(childNode, startIndex);
|
|
30536
30886
|
}
|
|
30537
30887
|
}
|
|
30538
|
-
var replaceEntitiesValue2 = function(
|
|
30539
|
-
if (
|
|
30540
|
-
|
|
30541
|
-
|
|
30542
|
-
|
|
30888
|
+
var replaceEntitiesValue2 = function(val, tagName, jPath) {
|
|
30889
|
+
if (val.indexOf("&") === -1) {
|
|
30890
|
+
return val;
|
|
30891
|
+
}
|
|
30892
|
+
const entityConfig = this.options.processEntities;
|
|
30893
|
+
if (!entityConfig.enabled) {
|
|
30894
|
+
return val;
|
|
30895
|
+
}
|
|
30896
|
+
if (entityConfig.allowedTags) {
|
|
30897
|
+
if (!entityConfig.allowedTags.includes(tagName)) {
|
|
30898
|
+
return val;
|
|
30543
30899
|
}
|
|
30544
|
-
|
|
30545
|
-
|
|
30546
|
-
|
|
30900
|
+
}
|
|
30901
|
+
if (entityConfig.tagFilter) {
|
|
30902
|
+
if (!entityConfig.tagFilter(tagName, jPath)) {
|
|
30903
|
+
return val;
|
|
30547
30904
|
}
|
|
30548
|
-
|
|
30549
|
-
|
|
30550
|
-
|
|
30551
|
-
|
|
30905
|
+
}
|
|
30906
|
+
for (let entityName in this.docTypeEntities) {
|
|
30907
|
+
const entity = this.docTypeEntities[entityName];
|
|
30908
|
+
const matches = val.match(entity.regx);
|
|
30909
|
+
if (matches) {
|
|
30910
|
+
this.entityExpansionCount += matches.length;
|
|
30911
|
+
if (entityConfig.maxTotalExpansions && this.entityExpansionCount > entityConfig.maxTotalExpansions) {
|
|
30912
|
+
throw new Error(
|
|
30913
|
+
`Entity expansion limit exceeded: ${this.entityExpansionCount} > ${entityConfig.maxTotalExpansions}`
|
|
30914
|
+
);
|
|
30915
|
+
}
|
|
30916
|
+
const lengthBefore = val.length;
|
|
30917
|
+
val = val.replace(entity.regx, entity.val);
|
|
30918
|
+
if (entityConfig.maxExpandedLength) {
|
|
30919
|
+
this.currentExpandedLength += val.length - lengthBefore;
|
|
30920
|
+
if (this.currentExpandedLength > entityConfig.maxExpandedLength) {
|
|
30921
|
+
throw new Error(
|
|
30922
|
+
`Total expanded content size exceeded: ${this.currentExpandedLength} > ${entityConfig.maxExpandedLength}`
|
|
30923
|
+
);
|
|
30924
|
+
}
|
|
30552
30925
|
}
|
|
30553
30926
|
}
|
|
30554
|
-
val2 = val2.replace(this.ampEntity.regex, this.ampEntity.val);
|
|
30555
30927
|
}
|
|
30556
|
-
return
|
|
30928
|
+
if (val.indexOf("&") === -1) return val;
|
|
30929
|
+
for (const entityName of Object.keys(this.lastEntities)) {
|
|
30930
|
+
const entity = this.lastEntities[entityName];
|
|
30931
|
+
const matches = val.match(entity.regex);
|
|
30932
|
+
if (matches) {
|
|
30933
|
+
this.entityExpansionCount += matches.length;
|
|
30934
|
+
if (entityConfig.maxTotalExpansions && this.entityExpansionCount > entityConfig.maxTotalExpansions) {
|
|
30935
|
+
throw new Error(
|
|
30936
|
+
`Entity expansion limit exceeded: ${this.entityExpansionCount} > ${entityConfig.maxTotalExpansions}`
|
|
30937
|
+
);
|
|
30938
|
+
}
|
|
30939
|
+
}
|
|
30940
|
+
val = val.replace(entity.regex, entity.val);
|
|
30941
|
+
}
|
|
30942
|
+
if (val.indexOf("&") === -1) return val;
|
|
30943
|
+
if (this.options.htmlEntities) {
|
|
30944
|
+
for (const entityName of Object.keys(this.htmlEntities)) {
|
|
30945
|
+
const entity = this.htmlEntities[entityName];
|
|
30946
|
+
const matches = val.match(entity.regex);
|
|
30947
|
+
if (matches) {
|
|
30948
|
+
this.entityExpansionCount += matches.length;
|
|
30949
|
+
if (entityConfig.maxTotalExpansions && this.entityExpansionCount > entityConfig.maxTotalExpansions) {
|
|
30950
|
+
throw new Error(
|
|
30951
|
+
`Entity expansion limit exceeded: ${this.entityExpansionCount} > ${entityConfig.maxTotalExpansions}`
|
|
30952
|
+
);
|
|
30953
|
+
}
|
|
30954
|
+
}
|
|
30955
|
+
val = val.replace(entity.regex, entity.val);
|
|
30956
|
+
}
|
|
30957
|
+
}
|
|
30958
|
+
val = val.replace(this.ampEntity.regex, this.ampEntity.val);
|
|
30959
|
+
return val;
|
|
30557
30960
|
};
|
|
30558
|
-
function saveTextToParentTag2(textData,
|
|
30961
|
+
function saveTextToParentTag2(textData, parentNode, jPath, isLeafNode) {
|
|
30559
30962
|
if (textData) {
|
|
30560
|
-
if (isLeafNode === void 0) isLeafNode =
|
|
30963
|
+
if (isLeafNode === void 0) isLeafNode = parentNode.child.length === 0;
|
|
30561
30964
|
textData = this.parseTextData(
|
|
30562
30965
|
textData,
|
|
30563
|
-
|
|
30966
|
+
parentNode.tagname,
|
|
30564
30967
|
jPath,
|
|
30565
30968
|
false,
|
|
30566
|
-
|
|
30969
|
+
parentNode[":@"] ? Object.keys(parentNode[":@"]).length !== 0 : false,
|
|
30567
30970
|
isLeafNode
|
|
30568
30971
|
);
|
|
30569
30972
|
if (textData !== void 0 && textData !== "")
|
|
30570
|
-
|
|
30973
|
+
parentNode.add(this.options.textNodeName, textData);
|
|
30571
30974
|
textData = "";
|
|
30572
30975
|
}
|
|
30573
30976
|
return textData;
|
|
30574
30977
|
}
|
|
30575
|
-
function isItStopNode2(
|
|
30576
|
-
|
|
30577
|
-
|
|
30578
|
-
const stopNodeExp = stopNodes[stopNodePath];
|
|
30579
|
-
if (allNodesExp === stopNodeExp || jPath === stopNodeExp) return true;
|
|
30580
|
-
}
|
|
30978
|
+
function isItStopNode2(stopNodesExact, stopNodesWildcard, jPath, currentTagName) {
|
|
30979
|
+
if (stopNodesWildcard && stopNodesWildcard.has(currentTagName)) return true;
|
|
30980
|
+
if (stopNodesExact && stopNodesExact.has(jPath)) return true;
|
|
30581
30981
|
return false;
|
|
30582
30982
|
}
|
|
30583
30983
|
function tagExpWithClosingIndex2(xmlData, i, closingChar = ">") {
|
|
@@ -30685,20 +31085,36 @@ var require_OrderedObjParser = __commonJS({
|
|
|
30685
31085
|
}
|
|
30686
31086
|
}
|
|
30687
31087
|
}
|
|
30688
|
-
function parseValue2(
|
|
30689
|
-
if (shouldParse && typeof
|
|
30690
|
-
const newval =
|
|
31088
|
+
function parseValue2(val, shouldParse, options) {
|
|
31089
|
+
if (shouldParse && typeof val === "string") {
|
|
31090
|
+
const newval = val.trim();
|
|
30691
31091
|
if (newval === "true") return true;
|
|
30692
31092
|
else if (newval === "false") return false;
|
|
30693
|
-
else return toNumber2(
|
|
31093
|
+
else return toNumber2(val, options);
|
|
30694
31094
|
} else {
|
|
30695
|
-
if (util.isExist(
|
|
30696
|
-
return
|
|
31095
|
+
if (util.isExist(val)) {
|
|
31096
|
+
return val;
|
|
30697
31097
|
} else {
|
|
30698
31098
|
return "";
|
|
30699
31099
|
}
|
|
30700
31100
|
}
|
|
30701
31101
|
}
|
|
31102
|
+
function fromCodePoint(str, base, prefix) {
|
|
31103
|
+
const codePoint = Number.parseInt(str, base);
|
|
31104
|
+
if (codePoint >= 0 && codePoint <= 1114111) {
|
|
31105
|
+
return String.fromCodePoint(codePoint);
|
|
31106
|
+
} else {
|
|
31107
|
+
return prefix + str + ";";
|
|
31108
|
+
}
|
|
31109
|
+
}
|
|
31110
|
+
function sanitizeName2(name, options) {
|
|
31111
|
+
if (util.criticalProperties.includes(name)) {
|
|
31112
|
+
throw new Error(`[SECURITY] Invalid name: "${name}" is a reserved JavaScript keyword that could cause prototype pollution`);
|
|
31113
|
+
} else if (util.DANGEROUS_PROPERTY_NAMES.includes(name)) {
|
|
31114
|
+
return options.onDangerousProperty(name);
|
|
31115
|
+
}
|
|
31116
|
+
return name;
|
|
31117
|
+
}
|
|
30702
31118
|
module2.exports = OrderedObjParser2;
|
|
30703
31119
|
}
|
|
30704
31120
|
});
|
|
@@ -30725,26 +31141,26 @@ var require_node2json = __commonJS({
|
|
|
30725
31141
|
} else if (property === void 0) {
|
|
30726
31142
|
continue;
|
|
30727
31143
|
} else if (tagObj[property]) {
|
|
30728
|
-
let
|
|
30729
|
-
const isLeaf = isLeafTag2(
|
|
31144
|
+
let val = compress2(tagObj[property], options, newJpath);
|
|
31145
|
+
const isLeaf = isLeafTag2(val, options);
|
|
30730
31146
|
if (tagObj[":@"]) {
|
|
30731
|
-
assignAttributes2(
|
|
30732
|
-
} else if (Object.keys(
|
|
30733
|
-
|
|
30734
|
-
} else if (Object.keys(
|
|
30735
|
-
if (options.alwaysCreateTextNode)
|
|
30736
|
-
else
|
|
31147
|
+
assignAttributes2(val, tagObj[":@"], newJpath, options);
|
|
31148
|
+
} else if (Object.keys(val).length === 1 && val[options.textNodeName] !== void 0 && !options.alwaysCreateTextNode) {
|
|
31149
|
+
val = val[options.textNodeName];
|
|
31150
|
+
} else if (Object.keys(val).length === 0) {
|
|
31151
|
+
if (options.alwaysCreateTextNode) val[options.textNodeName] = "";
|
|
31152
|
+
else val = "";
|
|
30737
31153
|
}
|
|
30738
31154
|
if (compressedObj[property] !== void 0 && compressedObj.hasOwnProperty(property)) {
|
|
30739
31155
|
if (!Array.isArray(compressedObj[property])) {
|
|
30740
31156
|
compressedObj[property] = [compressedObj[property]];
|
|
30741
31157
|
}
|
|
30742
|
-
compressedObj[property].push(
|
|
31158
|
+
compressedObj[property].push(val);
|
|
30743
31159
|
} else {
|
|
30744
31160
|
if (options.isArray(property, newJpath, isLeaf)) {
|
|
30745
|
-
compressedObj[property] = [
|
|
31161
|
+
compressedObj[property] = [val];
|
|
30746
31162
|
} else {
|
|
30747
|
-
compressedObj[property] =
|
|
31163
|
+
compressedObj[property] = val;
|
|
30748
31164
|
}
|
|
30749
31165
|
}
|
|
30750
31166
|
}
|
|
@@ -30862,6 +31278,14 @@ var require_orderedJs2Xml = __commonJS({
|
|
|
30862
31278
|
function arrToStr(arr, options, jPath, indentation) {
|
|
30863
31279
|
let xmlStr = "";
|
|
30864
31280
|
let isPreviousElementTag = false;
|
|
31281
|
+
if (!Array.isArray(arr)) {
|
|
31282
|
+
if (arr !== void 0 && arr !== null) {
|
|
31283
|
+
let text = arr.toString();
|
|
31284
|
+
text = replaceEntitiesValue2(text, options);
|
|
31285
|
+
return text;
|
|
31286
|
+
}
|
|
31287
|
+
return "";
|
|
31288
|
+
}
|
|
30865
31289
|
for (let i = 0; i < arr.length; i++) {
|
|
30866
31290
|
const tagObj = arr[i];
|
|
30867
31291
|
const tagName = propName2(tagObj);
|
|
@@ -30932,7 +31356,7 @@ var require_orderedJs2Xml = __commonJS({
|
|
|
30932
31356
|
const keys2 = Object.keys(obj);
|
|
30933
31357
|
for (let i = 0; i < keys2.length; i++) {
|
|
30934
31358
|
const key = keys2[i];
|
|
30935
|
-
if (!
|
|
31359
|
+
if (!Object.prototype.hasOwnProperty.call(obj, key)) continue;
|
|
30936
31360
|
if (key !== ":@") return key;
|
|
30937
31361
|
}
|
|
30938
31362
|
}
|
|
@@ -30940,7 +31364,7 @@ var require_orderedJs2Xml = __commonJS({
|
|
|
30940
31364
|
let attrStr = "";
|
|
30941
31365
|
if (attrMap && !options.ignoreAttributes) {
|
|
30942
31366
|
for (let attr in attrMap) {
|
|
30943
|
-
if (!
|
|
31367
|
+
if (!Object.prototype.hasOwnProperty.call(attrMap, attr)) continue;
|
|
30944
31368
|
let attrVal = options.attributeValueProcessor(attr, attrMap[attr]);
|
|
30945
31369
|
attrVal = replaceEntitiesValue2(attrVal, options);
|
|
30946
31370
|
if (attrVal === true && options.suppressBooleanAttributes) {
|
|
@@ -30978,6 +31402,7 @@ var require_json2xml = __commonJS({
|
|
|
30978
31402
|
"../../node_modules/fast-xml-parser/src/xmlbuilder/json2xml.js"(exports2, module2) {
|
|
30979
31403
|
"use strict";
|
|
30980
31404
|
var buildFromOrderedJs = require_orderedJs2Xml();
|
|
31405
|
+
var getIgnoreAttributesFn2 = require_ignoreAttributes();
|
|
30981
31406
|
var defaultOptions3 = {
|
|
30982
31407
|
attributeNamePrefix: "@_",
|
|
30983
31408
|
attributesGroupName: false,
|
|
@@ -31014,11 +31439,12 @@ var require_json2xml = __commonJS({
|
|
|
31014
31439
|
};
|
|
31015
31440
|
function Builder(options) {
|
|
31016
31441
|
this.options = Object.assign({}, defaultOptions3, options);
|
|
31017
|
-
if (this.options.ignoreAttributes || this.options.attributesGroupName) {
|
|
31442
|
+
if (this.options.ignoreAttributes === true || this.options.attributesGroupName) {
|
|
31018
31443
|
this.isAttribute = function() {
|
|
31019
31444
|
return false;
|
|
31020
31445
|
};
|
|
31021
31446
|
} else {
|
|
31447
|
+
this.ignoreAttributesFn = getIgnoreAttributesFn2(this.options.ignoreAttributes);
|
|
31022
31448
|
this.attrPrefixLen = this.options.attributeNamePrefix.length;
|
|
31023
31449
|
this.isAttribute = isAttribute;
|
|
31024
31450
|
}
|
|
@@ -31044,38 +31470,41 @@ var require_json2xml = __commonJS({
|
|
|
31044
31470
|
[this.options.arrayNodeName]: jObj
|
|
31045
31471
|
};
|
|
31046
31472
|
}
|
|
31047
|
-
return this.j2x(jObj, 0).val;
|
|
31473
|
+
return this.j2x(jObj, 0, []).val;
|
|
31048
31474
|
}
|
|
31049
31475
|
};
|
|
31050
|
-
Builder.prototype.j2x = function(jObj, level) {
|
|
31476
|
+
Builder.prototype.j2x = function(jObj, level, ajPath) {
|
|
31051
31477
|
let attrStr = "";
|
|
31052
|
-
let
|
|
31478
|
+
let val = "";
|
|
31479
|
+
const jPath = ajPath.join(".");
|
|
31053
31480
|
for (let key in jObj) {
|
|
31054
31481
|
if (!Object.prototype.hasOwnProperty.call(jObj, key)) continue;
|
|
31055
31482
|
if (typeof jObj[key] === "undefined") {
|
|
31056
31483
|
if (this.isAttribute(key)) {
|
|
31057
|
-
|
|
31484
|
+
val += "";
|
|
31058
31485
|
}
|
|
31059
31486
|
} else if (jObj[key] === null) {
|
|
31060
31487
|
if (this.isAttribute(key)) {
|
|
31061
|
-
|
|
31488
|
+
val += "";
|
|
31489
|
+
} else if (key === this.options.cdataPropName) {
|
|
31490
|
+
val += "";
|
|
31062
31491
|
} else if (key[0] === "?") {
|
|
31063
|
-
|
|
31492
|
+
val += this.indentate(level) + "<" + key + "?" + this.tagEndChar;
|
|
31064
31493
|
} else {
|
|
31065
|
-
|
|
31494
|
+
val += this.indentate(level) + "<" + key + "/" + this.tagEndChar;
|
|
31066
31495
|
}
|
|
31067
31496
|
} else if (jObj[key] instanceof Date) {
|
|
31068
|
-
|
|
31497
|
+
val += this.buildTextValNode(jObj[key], key, "", level);
|
|
31069
31498
|
} else if (typeof jObj[key] !== "object") {
|
|
31070
31499
|
const attr = this.isAttribute(key);
|
|
31071
|
-
if (attr) {
|
|
31500
|
+
if (attr && !this.ignoreAttributesFn(attr, jPath)) {
|
|
31072
31501
|
attrStr += this.buildAttrPairStr(attr, "" + jObj[key]);
|
|
31073
|
-
} else {
|
|
31502
|
+
} else if (!attr) {
|
|
31074
31503
|
if (key === this.options.textNodeName) {
|
|
31075
31504
|
let newval = this.options.tagValueProcessor(key, "" + jObj[key]);
|
|
31076
|
-
|
|
31505
|
+
val += this.replaceEntitiesValue(newval);
|
|
31077
31506
|
} else {
|
|
31078
|
-
|
|
31507
|
+
val += this.buildTextValNode(jObj[key], key, "", level);
|
|
31079
31508
|
}
|
|
31080
31509
|
}
|
|
31081
31510
|
} else if (Array.isArray(jObj[key])) {
|
|
@@ -31086,17 +31515,17 @@ var require_json2xml = __commonJS({
|
|
|
31086
31515
|
const item = jObj[key][j];
|
|
31087
31516
|
if (typeof item === "undefined") {
|
|
31088
31517
|
} else if (item === null) {
|
|
31089
|
-
if (key[0] === "?")
|
|
31090
|
-
else
|
|
31518
|
+
if (key[0] === "?") val += this.indentate(level) + "<" + key + "?" + this.tagEndChar;
|
|
31519
|
+
else val += this.indentate(level) + "<" + key + "/" + this.tagEndChar;
|
|
31091
31520
|
} else if (typeof item === "object") {
|
|
31092
31521
|
if (this.options.oneListGroup) {
|
|
31093
|
-
const result = this.j2x(item, level + 1);
|
|
31522
|
+
const result = this.j2x(item, level + 1, ajPath.concat(key));
|
|
31094
31523
|
listTagVal += result.val;
|
|
31095
31524
|
if (this.options.attributesGroupName && item.hasOwnProperty(this.options.attributesGroupName)) {
|
|
31096
31525
|
listTagAttr += result.attrStr;
|
|
31097
31526
|
}
|
|
31098
31527
|
} else {
|
|
31099
|
-
listTagVal += this.processTextOrObjNode(item, key, level);
|
|
31528
|
+
listTagVal += this.processTextOrObjNode(item, key, level, ajPath);
|
|
31100
31529
|
}
|
|
31101
31530
|
} else {
|
|
31102
31531
|
if (this.options.oneListGroup) {
|
|
@@ -31111,7 +31540,7 @@ var require_json2xml = __commonJS({
|
|
|
31111
31540
|
if (this.options.oneListGroup) {
|
|
31112
31541
|
listTagVal = this.buildObjectNode(listTagVal, key, listTagAttr, level);
|
|
31113
31542
|
}
|
|
31114
|
-
|
|
31543
|
+
val += listTagVal;
|
|
31115
31544
|
} else {
|
|
31116
31545
|
if (this.options.attributesGroupName && key === this.options.attributesGroupName) {
|
|
31117
31546
|
const Ks = Object.keys(jObj[key]);
|
|
@@ -31120,29 +31549,29 @@ var require_json2xml = __commonJS({
|
|
|
31120
31549
|
attrStr += this.buildAttrPairStr(Ks[j], "" + jObj[key][Ks[j]]);
|
|
31121
31550
|
}
|
|
31122
31551
|
} else {
|
|
31123
|
-
|
|
31552
|
+
val += this.processTextOrObjNode(jObj[key], key, level, ajPath);
|
|
31124
31553
|
}
|
|
31125
31554
|
}
|
|
31126
31555
|
}
|
|
31127
|
-
return { attrStr, val
|
|
31556
|
+
return { attrStr, val };
|
|
31128
31557
|
};
|
|
31129
|
-
Builder.prototype.buildAttrPairStr = function(attrName,
|
|
31130
|
-
|
|
31131
|
-
|
|
31132
|
-
if (this.options.suppressBooleanAttributes &&
|
|
31558
|
+
Builder.prototype.buildAttrPairStr = function(attrName, val) {
|
|
31559
|
+
val = this.options.attributeValueProcessor(attrName, "" + val);
|
|
31560
|
+
val = this.replaceEntitiesValue(val);
|
|
31561
|
+
if (this.options.suppressBooleanAttributes && val === "true") {
|
|
31133
31562
|
return " " + attrName;
|
|
31134
|
-
} else return " " + attrName + '="' +
|
|
31563
|
+
} else return " " + attrName + '="' + val + '"';
|
|
31135
31564
|
};
|
|
31136
|
-
function processTextOrObjNode(object, key, level) {
|
|
31137
|
-
const result = this.j2x(object, level + 1);
|
|
31565
|
+
function processTextOrObjNode(object, key, level, ajPath) {
|
|
31566
|
+
const result = this.j2x(object, level + 1, ajPath.concat(key));
|
|
31138
31567
|
if (object[this.options.textNodeName] !== void 0 && Object.keys(object).length === 1) {
|
|
31139
31568
|
return this.buildTextValNode(object[this.options.textNodeName], key, result.attrStr, level);
|
|
31140
31569
|
} else {
|
|
31141
31570
|
return this.buildObjectNode(result.val, key, result.attrStr, level);
|
|
31142
31571
|
}
|
|
31143
31572
|
}
|
|
31144
|
-
Builder.prototype.buildObjectNode = function(
|
|
31145
|
-
if (
|
|
31573
|
+
Builder.prototype.buildObjectNode = function(val, key, attrStr, level) {
|
|
31574
|
+
if (val === "") {
|
|
31146
31575
|
if (key[0] === "?") return this.indentate(level) + "<" + key + attrStr + "?" + this.tagEndChar;
|
|
31147
31576
|
else {
|
|
31148
31577
|
return this.indentate(level) + "<" + key + attrStr + this.closeTag(key) + this.tagEndChar;
|
|
@@ -31154,12 +31583,12 @@ var require_json2xml = __commonJS({
|
|
|
31154
31583
|
piClosingChar = "?";
|
|
31155
31584
|
tagEndExp = "";
|
|
31156
31585
|
}
|
|
31157
|
-
if ((attrStr || attrStr === "") &&
|
|
31158
|
-
return this.indentate(level) + "<" + key + attrStr + piClosingChar + ">" +
|
|
31586
|
+
if ((attrStr || attrStr === "") && val.indexOf("<") === -1) {
|
|
31587
|
+
return this.indentate(level) + "<" + key + attrStr + piClosingChar + ">" + val + tagEndExp;
|
|
31159
31588
|
} else if (this.options.commentPropName !== false && key === this.options.commentPropName && piClosingChar.length === 0) {
|
|
31160
|
-
return this.indentate(level) + `<!--${
|
|
31589
|
+
return this.indentate(level) + `<!--${val}-->` + this.newLine;
|
|
31161
31590
|
} else {
|
|
31162
|
-
return this.indentate(level) + "<" + key + attrStr + piClosingChar + this.tagEndChar +
|
|
31591
|
+
return this.indentate(level) + "<" + key + attrStr + piClosingChar + this.tagEndChar + val + this.indentate(level) + tagEndExp;
|
|
31163
31592
|
}
|
|
31164
31593
|
}
|
|
31165
31594
|
};
|
|
@@ -31174,15 +31603,15 @@ var require_json2xml = __commonJS({
|
|
|
31174
31603
|
}
|
|
31175
31604
|
return closeTag;
|
|
31176
31605
|
};
|
|
31177
|
-
Builder.prototype.buildTextValNode = function(
|
|
31606
|
+
Builder.prototype.buildTextValNode = function(val, key, attrStr, level) {
|
|
31178
31607
|
if (this.options.cdataPropName !== false && key === this.options.cdataPropName) {
|
|
31179
|
-
return this.indentate(level) + `<![CDATA[${
|
|
31608
|
+
return this.indentate(level) + `<![CDATA[${val}]]>` + this.newLine;
|
|
31180
31609
|
} else if (this.options.commentPropName !== false && key === this.options.commentPropName) {
|
|
31181
|
-
return this.indentate(level) + `<!--${
|
|
31610
|
+
return this.indentate(level) + `<!--${val}-->` + this.newLine;
|
|
31182
31611
|
} else if (key[0] === "?") {
|
|
31183
31612
|
return this.indentate(level) + "<" + key + attrStr + "?" + this.tagEndChar;
|
|
31184
31613
|
} else {
|
|
31185
|
-
let textValue = this.options.tagValueProcessor(key,
|
|
31614
|
+
let textValue = this.options.tagValueProcessor(key, val);
|
|
31186
31615
|
textValue = this.replaceEntitiesValue(textValue);
|
|
31187
31616
|
if (textValue === "") {
|
|
31188
31617
|
return this.indentate(level) + "<" + key + attrStr + this.closeTag(key) + this.tagEndChar;
|
|
@@ -31569,6 +31998,9 @@ var LoticsClient = class {
|
|
|
31569
31998
|
import fs2 from "node:fs";
|
|
31570
31999
|
import path2 from "node:path";
|
|
31571
32000
|
import os from "node:os";
|
|
32001
|
+
function globalConfigFile() {
|
|
32002
|
+
return path2.join(os.homedir(), ".lotics", "config.json");
|
|
32003
|
+
}
|
|
31572
32004
|
function configFileForScope(scope) {
|
|
31573
32005
|
if (scope === "local") {
|
|
31574
32006
|
return path2.join(process.cwd(), ".lotics", "config.json");
|
|
@@ -31585,21 +32017,25 @@ function configFileForScope(scope) {
|
|
|
31585
32017
|
}
|
|
31586
32018
|
dir = parent;
|
|
31587
32019
|
}
|
|
31588
|
-
return
|
|
32020
|
+
return globalConfigFile();
|
|
31589
32021
|
}
|
|
31590
|
-
function
|
|
32022
|
+
function readConfigFile(file) {
|
|
31591
32023
|
try {
|
|
31592
|
-
const raw = fs2.readFileSync(
|
|
32024
|
+
const raw = fs2.readFileSync(file, "utf-8");
|
|
31593
32025
|
return JSON.parse(raw);
|
|
31594
32026
|
} catch {
|
|
31595
32027
|
return null;
|
|
31596
32028
|
}
|
|
31597
32029
|
}
|
|
31598
|
-
function
|
|
31599
|
-
const file = configFileForScope(scope);
|
|
32030
|
+
function writeConfigFile(file, config) {
|
|
31600
32031
|
fs2.mkdirSync(path2.dirname(file), { recursive: true, mode: 448 });
|
|
31601
|
-
|
|
31602
|
-
fs2.
|
|
32032
|
+
const tmp = `${file}.${process.pid}.tmp`;
|
|
32033
|
+
fs2.writeFileSync(tmp, JSON.stringify(config, null, 2) + "\n", { encoding: "utf-8", mode: 384 });
|
|
32034
|
+
fs2.chmodSync(tmp, 384);
|
|
32035
|
+
fs2.renameSync(tmp, file);
|
|
32036
|
+
}
|
|
32037
|
+
function saveConfig(config, scope = "auto") {
|
|
32038
|
+
writeConfigFile(configFileForScope(scope), config);
|
|
31603
32039
|
}
|
|
31604
32040
|
function deleteConfig(scope = "auto") {
|
|
31605
32041
|
try {
|
|
@@ -31610,9 +32046,154 @@ function deleteConfig(scope = "auto") {
|
|
|
31610
32046
|
function getConfigPath(scope = "auto") {
|
|
31611
32047
|
return configFileForScope(scope);
|
|
31612
32048
|
}
|
|
32049
|
+
function loadGlobalConfig() {
|
|
32050
|
+
return readConfigFile(globalConfigFile());
|
|
32051
|
+
}
|
|
32052
|
+
function saveGlobalConfig(config) {
|
|
32053
|
+
writeConfigFile(globalConfigFile(), config);
|
|
32054
|
+
}
|
|
32055
|
+
function loadLocalConfig() {
|
|
32056
|
+
const file = configFileForScope("auto");
|
|
32057
|
+
if (file === globalConfigFile()) return null;
|
|
32058
|
+
return readConfigFile(file);
|
|
32059
|
+
}
|
|
32060
|
+
function resolveProfileByNameOrId(profiles, nameOrId) {
|
|
32061
|
+
const byId = profiles[nameOrId];
|
|
32062
|
+
if (byId) return [nameOrId, byId];
|
|
32063
|
+
const matches = Object.entries(profiles).filter(
|
|
32064
|
+
([, p]) => p.org_name.toLowerCase() === nameOrId.toLowerCase()
|
|
32065
|
+
);
|
|
32066
|
+
if (matches.length === 1) return matches[0];
|
|
32067
|
+
if (matches.length > 1) {
|
|
32068
|
+
throw new Error(
|
|
32069
|
+
`"${nameOrId}" matches multiple saved orgs: ${matches.map(([id]) => id).join(", ")}. Use the org id.`
|
|
32070
|
+
);
|
|
32071
|
+
}
|
|
32072
|
+
return null;
|
|
32073
|
+
}
|
|
32074
|
+
function resolveContext(flags) {
|
|
32075
|
+
const envKey = process.env.LOTICS_API_KEY;
|
|
32076
|
+
const envOrg = process.env.LOTICS_ORG;
|
|
32077
|
+
const envWorkspace = process.env.LOTICS_WORKSPACE;
|
|
32078
|
+
const wsOverride = flags.workspace ?? envWorkspace;
|
|
32079
|
+
if (flags.apiKey) {
|
|
32080
|
+
return { apiKey: flags.apiKey, workspaceId: wsOverride, source: "flag" };
|
|
32081
|
+
}
|
|
32082
|
+
if (envKey) {
|
|
32083
|
+
return { apiKey: envKey, workspaceId: wsOverride, source: "env_key" };
|
|
32084
|
+
}
|
|
32085
|
+
const global2 = loadGlobalConfig();
|
|
32086
|
+
const profiles = global2?.profiles ?? {};
|
|
32087
|
+
if (envOrg) {
|
|
32088
|
+
const resolved = resolveProfileByNameOrId(profiles, envOrg);
|
|
32089
|
+
if (!resolved) {
|
|
32090
|
+
throw new Error(
|
|
32091
|
+
`LOTICS_ORG="${envOrg}" matches no saved credential. Run "lotics org" to list, or "lotics auth api-key <key>" to add one.`
|
|
32092
|
+
);
|
|
32093
|
+
}
|
|
32094
|
+
const [orgId, profile] = resolved;
|
|
32095
|
+
return {
|
|
32096
|
+
apiKey: profile.api_key,
|
|
32097
|
+
orgId,
|
|
32098
|
+
orgName: profile.org_name,
|
|
32099
|
+
workspaceId: wsOverride ?? profile.workspace_id,
|
|
32100
|
+
source: "env_org"
|
|
32101
|
+
};
|
|
32102
|
+
}
|
|
32103
|
+
const local = loadLocalConfig();
|
|
32104
|
+
if (local?.active_org) {
|
|
32105
|
+
const profile = profiles[local.active_org];
|
|
32106
|
+
if (!profile) {
|
|
32107
|
+
throw new Error(
|
|
32108
|
+
`This directory is pinned to org "${local.active_org}" (.lotics/config.json) but no saved credential exists for it. Run "lotics auth api-key <key>" while authenticated to that org.`
|
|
32109
|
+
);
|
|
32110
|
+
}
|
|
32111
|
+
return {
|
|
32112
|
+
apiKey: profile.api_key,
|
|
32113
|
+
orgId: local.active_org,
|
|
32114
|
+
orgName: profile.org_name,
|
|
32115
|
+
workspaceId: wsOverride ?? local.workspace_id ?? profile.workspace_id,
|
|
32116
|
+
source: "local_pointer"
|
|
32117
|
+
};
|
|
32118
|
+
}
|
|
32119
|
+
if (local && "api_key" in local) {
|
|
32120
|
+
throw new Error(
|
|
32121
|
+
`This directory's .lotics/config.json uses the old self-contained format (inline key), which is no longer supported. Re-pin with "lotics auth api-key <key> --local" (or "lotics org use <name|id> --local").`
|
|
32122
|
+
);
|
|
32123
|
+
}
|
|
32124
|
+
if (global2?.active_org) {
|
|
32125
|
+
const profile = profiles[global2.active_org];
|
|
32126
|
+
if (!profile) {
|
|
32127
|
+
throw new Error(
|
|
32128
|
+
`Active org "${global2.active_org}" has no saved credential. Run "lotics org use <name|id>" to pick one, or "lotics auth api-key <key>".`
|
|
32129
|
+
);
|
|
32130
|
+
}
|
|
32131
|
+
return {
|
|
32132
|
+
apiKey: profile.api_key,
|
|
32133
|
+
orgId: global2.active_org,
|
|
32134
|
+
orgName: profile.org_name,
|
|
32135
|
+
workspaceId: wsOverride ?? profile.workspace_id,
|
|
32136
|
+
source: "global_profile"
|
|
32137
|
+
};
|
|
32138
|
+
}
|
|
32139
|
+
return null;
|
|
32140
|
+
}
|
|
32141
|
+
function upsertProfile(orgId, fields) {
|
|
32142
|
+
const config = loadGlobalConfig() ?? {};
|
|
32143
|
+
const existing = config.profiles?.[orgId];
|
|
32144
|
+
const profile = {
|
|
32145
|
+
api_key: fields.api_key,
|
|
32146
|
+
org_name: fields.org_name,
|
|
32147
|
+
workspace_id: fields.workspace_id ?? existing?.workspace_id
|
|
32148
|
+
};
|
|
32149
|
+
saveGlobalConfig({
|
|
32150
|
+
profiles: { ...config.profiles, [orgId]: profile },
|
|
32151
|
+
active_org: config.active_org,
|
|
32152
|
+
email: config.email,
|
|
32153
|
+
last_update_check: config.last_update_check,
|
|
32154
|
+
latest_version: config.latest_version
|
|
32155
|
+
});
|
|
32156
|
+
}
|
|
32157
|
+
function removeProfile(orgId) {
|
|
32158
|
+
const config = loadGlobalConfig();
|
|
32159
|
+
if (!config?.profiles?.[orgId]) return;
|
|
32160
|
+
const { [orgId]: _removed, ...rest } = config.profiles;
|
|
32161
|
+
const remaining = Object.keys(rest);
|
|
32162
|
+
saveGlobalConfig({
|
|
32163
|
+
...config,
|
|
32164
|
+
profiles: rest,
|
|
32165
|
+
active_org: config.active_org === orgId ? remaining[0] : config.active_org
|
|
32166
|
+
});
|
|
32167
|
+
}
|
|
32168
|
+
function setActiveOrg(orgId, scope) {
|
|
32169
|
+
if (scope === "local") {
|
|
32170
|
+
saveConfig({ active_org: orgId }, "local");
|
|
32171
|
+
return;
|
|
32172
|
+
}
|
|
32173
|
+
const config = loadGlobalConfig() ?? {};
|
|
32174
|
+
saveGlobalConfig({ ...config, active_org: orgId });
|
|
32175
|
+
}
|
|
32176
|
+
function setSelectedWorkspace(workspaceId) {
|
|
32177
|
+
const local = loadLocalConfig();
|
|
32178
|
+
if (local?.active_org) {
|
|
32179
|
+
saveConfig({ ...local, workspace_id: workspaceId }, "auto");
|
|
32180
|
+
return { scope: "local", orgId: local.active_org };
|
|
32181
|
+
}
|
|
32182
|
+
const config = loadGlobalConfig() ?? {};
|
|
32183
|
+
const orgId = config.active_org;
|
|
32184
|
+
const profile = orgId ? config.profiles?.[orgId] : void 0;
|
|
32185
|
+
if (!orgId || !profile) {
|
|
32186
|
+
return null;
|
|
32187
|
+
}
|
|
32188
|
+
saveGlobalConfig({
|
|
32189
|
+
...config,
|
|
32190
|
+
profiles: { ...config.profiles, [orgId]: { ...profile, workspace_id: workspaceId } }
|
|
32191
|
+
});
|
|
32192
|
+
return { scope: "global", orgId };
|
|
32193
|
+
}
|
|
31613
32194
|
var UPDATE_CHECK_INTERVAL_MS = 24 * 60 * 60 * 1e3;
|
|
31614
32195
|
function checkForUpdate(currentVersion) {
|
|
31615
|
-
const config =
|
|
32196
|
+
const config = loadGlobalConfig();
|
|
31616
32197
|
const lastCheck = config?.last_update_check ?? 0;
|
|
31617
32198
|
if (Date.now() - lastCheck < UPDATE_CHECK_INTERVAL_MS) {
|
|
31618
32199
|
if (config?.latest_version && config.latest_version !== currentVersion) {
|
|
@@ -31622,8 +32203,8 @@ function checkForUpdate(currentVersion) {
|
|
|
31622
32203
|
}
|
|
31623
32204
|
fetchLatestVersion().then((latest) => {
|
|
31624
32205
|
if (!latest) return;
|
|
31625
|
-
const existing =
|
|
31626
|
-
|
|
32206
|
+
const existing = loadGlobalConfig() ?? {};
|
|
32207
|
+
saveGlobalConfig({ ...existing, last_update_check: Date.now(), latest_version: latest });
|
|
31627
32208
|
}).catch(() => {
|
|
31628
32209
|
});
|
|
31629
32210
|
}
|
|
@@ -31658,12 +32239,6 @@ Update available: ${current} \u2192 ${latest}`);
|
|
|
31658
32239
|
console.error(`Run: npm i -g @lotics/cli
|
|
31659
32240
|
`);
|
|
31660
32241
|
}
|
|
31661
|
-
function resolveAuth(flags) {
|
|
31662
|
-
const config = loadConfig();
|
|
31663
|
-
const apiKey = flags.apiKey ?? process.env.LOTICS_API_KEY ?? config?.api_key;
|
|
31664
|
-
if (!apiKey) return null;
|
|
31665
|
-
return { apiKey };
|
|
31666
|
-
}
|
|
31667
32242
|
|
|
31668
32243
|
// src/version.ts
|
|
31669
32244
|
import { readFileSync } from "node:fs";
|
|
@@ -32942,11 +33517,13 @@ function parseArgs(argv) {
|
|
|
32942
33517
|
output: void 0,
|
|
32943
33518
|
as: void 0,
|
|
32944
33519
|
apiKey: void 0,
|
|
33520
|
+
workspace: void 0,
|
|
32945
33521
|
name: void 0,
|
|
32946
33522
|
timezone: void 0,
|
|
32947
33523
|
message: void 0,
|
|
32948
33524
|
forceWorkflowSync: false,
|
|
32949
33525
|
local: false,
|
|
33526
|
+
all: false,
|
|
32950
33527
|
version: false,
|
|
32951
33528
|
help: false
|
|
32952
33529
|
};
|
|
@@ -32974,6 +33551,10 @@ function parseArgs(argv) {
|
|
|
32974
33551
|
case "--api-key":
|
|
32975
33552
|
flags.apiKey = argv[++i];
|
|
32976
33553
|
break;
|
|
33554
|
+
case "--workspace":
|
|
33555
|
+
case "-w":
|
|
33556
|
+
flags.workspace = argv[++i];
|
|
33557
|
+
break;
|
|
32977
33558
|
case "--name":
|
|
32978
33559
|
flags.name = argv[++i];
|
|
32979
33560
|
break;
|
|
@@ -32990,6 +33571,9 @@ function parseArgs(argv) {
|
|
|
32990
33571
|
case "--local":
|
|
32991
33572
|
flags.local = true;
|
|
32992
33573
|
break;
|
|
33574
|
+
case "--all":
|
|
33575
|
+
flags.all = true;
|
|
33576
|
+
break;
|
|
32993
33577
|
case "--version":
|
|
32994
33578
|
case "-v":
|
|
32995
33579
|
flags.version = true;
|
|
@@ -34515,9 +35099,9 @@ function mergeEntityMaps(...maps) {
|
|
|
34515
35099
|
if (typeof raw === "string") {
|
|
34516
35100
|
out[key] = raw;
|
|
34517
35101
|
} else if (raw && typeof raw === "object" && raw.val !== void 0) {
|
|
34518
|
-
const
|
|
34519
|
-
if (typeof
|
|
34520
|
-
out[key] =
|
|
35102
|
+
const val = raw.val;
|
|
35103
|
+
if (typeof val === "string") {
|
|
35104
|
+
out[key] = val;
|
|
34521
35105
|
}
|
|
34522
35106
|
}
|
|
34523
35107
|
}
|
|
@@ -34890,11 +35474,11 @@ var defaultOptions2 = {
|
|
|
34890
35474
|
leadingZeros: true,
|
|
34891
35475
|
eNotation: true
|
|
34892
35476
|
},
|
|
34893
|
-
tagValueProcessor: function(tagName,
|
|
34894
|
-
return
|
|
35477
|
+
tagValueProcessor: function(tagName, val) {
|
|
35478
|
+
return val;
|
|
34895
35479
|
},
|
|
34896
|
-
attributeValueProcessor: function(attrName,
|
|
34897
|
-
return
|
|
35480
|
+
attributeValueProcessor: function(attrName, val) {
|
|
35481
|
+
return val;
|
|
34898
35482
|
},
|
|
34899
35483
|
stopNodes: [],
|
|
34900
35484
|
//nested tags will not be parsed even for errors
|
|
@@ -35009,9 +35593,9 @@ var XmlNode = class {
|
|
|
35009
35593
|
this.child = [];
|
|
35010
35594
|
this[":@"] = /* @__PURE__ */ Object.create(null);
|
|
35011
35595
|
}
|
|
35012
|
-
add(key,
|
|
35596
|
+
add(key, val) {
|
|
35013
35597
|
if (key === "__proto__") key = "#__proto__";
|
|
35014
|
-
this.child.push({ [key]:
|
|
35598
|
+
this.child.push({ [key]: val });
|
|
35015
35599
|
}
|
|
35016
35600
|
addChild(node, startIndex) {
|
|
35017
35601
|
if (node.tagname === "__proto__") node.tagname = "#__proto__";
|
|
@@ -35074,15 +35658,15 @@ var DocTypeReader = class {
|
|
|
35074
35658
|
if (xmlData[i] === "<" && !comment) {
|
|
35075
35659
|
if (hasBody && hasSeq(xmlData, "!ENTITY", i)) {
|
|
35076
35660
|
i += 7;
|
|
35077
|
-
let
|
|
35078
|
-
[
|
|
35079
|
-
if (
|
|
35661
|
+
let entityName, val;
|
|
35662
|
+
[entityName, val, i] = this.readEntityExp(xmlData, i + 1, this.suppressValidationErr);
|
|
35663
|
+
if (val.indexOf("&") === -1) {
|
|
35080
35664
|
if (this.options.enabled !== false && this.options.maxEntityCount != null && entityCount >= this.options.maxEntityCount) {
|
|
35081
35665
|
throw new Error(
|
|
35082
35666
|
`Entity count (${entityCount + 1}) exceeds maximum allowed (${this.options.maxEntityCount})`
|
|
35083
35667
|
);
|
|
35084
35668
|
}
|
|
35085
|
-
entities[
|
|
35669
|
+
entities[entityName] = val;
|
|
35086
35670
|
entityCount++;
|
|
35087
35671
|
}
|
|
35088
35672
|
} else if (hasBody && hasSeq(xmlData, "!ELEMENT", i)) {
|
|
@@ -35131,8 +35715,8 @@ var DocTypeReader = class {
|
|
|
35131
35715
|
while (i < xmlData.length && !/\s/.test(xmlData[i]) && xmlData[i] !== '"' && xmlData[i] !== "'") {
|
|
35132
35716
|
i++;
|
|
35133
35717
|
}
|
|
35134
|
-
let
|
|
35135
|
-
validateEntityName2(
|
|
35718
|
+
let entityName = xmlData.substring(startIndex, i);
|
|
35719
|
+
validateEntityName2(entityName, { xmlVersion: this.xmlVersion });
|
|
35136
35720
|
i = skipWhitespace(xmlData, i);
|
|
35137
35721
|
if (!this.suppressValidationErr) {
|
|
35138
35722
|
if (xmlData.substring(i, i + 6).toUpperCase() === "SYSTEM") {
|
|
@@ -35145,11 +35729,11 @@ var DocTypeReader = class {
|
|
|
35145
35729
|
[i, entityValue] = this.readIdentifierVal(xmlData, i, "entity");
|
|
35146
35730
|
if (this.options.enabled !== false && this.options.maxEntitySize != null && entityValue.length > this.options.maxEntitySize) {
|
|
35147
35731
|
throw new Error(
|
|
35148
|
-
`Entity "${
|
|
35732
|
+
`Entity "${entityName}" size (${entityValue.length}) exceeds maximum allowed size (${this.options.maxEntitySize})`
|
|
35149
35733
|
);
|
|
35150
35734
|
}
|
|
35151
35735
|
i--;
|
|
35152
|
-
return [
|
|
35736
|
+
return [entityName, entityValue, i];
|
|
35153
35737
|
}
|
|
35154
35738
|
readNotationExp(xmlData, i) {
|
|
35155
35739
|
i = skipWhitespace(xmlData, i);
|
|
@@ -36330,28 +36914,28 @@ var OrderedObjParser = class {
|
|
|
36330
36914
|
}
|
|
36331
36915
|
}
|
|
36332
36916
|
};
|
|
36333
|
-
function parseTextData(
|
|
36917
|
+
function parseTextData(val, tagName, jPath, dontTrim, hasAttributes, isLeafNode, escapeEntities) {
|
|
36334
36918
|
const options = this.options;
|
|
36335
|
-
if (
|
|
36919
|
+
if (val !== void 0) {
|
|
36336
36920
|
if (options.trimValues && !dontTrim) {
|
|
36337
|
-
|
|
36921
|
+
val = val.trim();
|
|
36338
36922
|
}
|
|
36339
|
-
if (
|
|
36340
|
-
if (!escapeEntities)
|
|
36923
|
+
if (val.length > 0) {
|
|
36924
|
+
if (!escapeEntities) val = this.replaceEntitiesValue(val, tagName, jPath);
|
|
36341
36925
|
const jPathOrMatcher = options.jPath ? jPath.toString() : jPath;
|
|
36342
|
-
const newval = options.tagValueProcessor(tagName,
|
|
36926
|
+
const newval = options.tagValueProcessor(tagName, val, jPathOrMatcher, hasAttributes, isLeafNode);
|
|
36343
36927
|
if (newval === null || newval === void 0) {
|
|
36344
|
-
return
|
|
36345
|
-
} else if (typeof newval !== typeof
|
|
36928
|
+
return val;
|
|
36929
|
+
} else if (typeof newval !== typeof val || newval !== val) {
|
|
36346
36930
|
return newval;
|
|
36347
36931
|
} else if (options.trimValues) {
|
|
36348
|
-
return parseValue(
|
|
36932
|
+
return parseValue(val, options.parseTagValue, options.numberParseOptions);
|
|
36349
36933
|
} else {
|
|
36350
|
-
const trimmedVal =
|
|
36351
|
-
if (trimmedVal ===
|
|
36352
|
-
return parseValue(
|
|
36934
|
+
const trimmedVal = val.trim();
|
|
36935
|
+
if (trimmedVal === val) {
|
|
36936
|
+
return parseValue(val, options.parseTagValue, options.numberParseOptions);
|
|
36353
36937
|
} else {
|
|
36354
|
-
return
|
|
36938
|
+
return val;
|
|
36355
36939
|
}
|
|
36356
36940
|
}
|
|
36357
36941
|
}
|
|
@@ -36384,11 +36968,11 @@ function buildAttributesMap(attrStr, jPath, tagName, force = false) {
|
|
|
36384
36968
|
const attrName = this.resolveNameSpace(matches[i][1]);
|
|
36385
36969
|
const oldVal = matches[i][4];
|
|
36386
36970
|
if (attrName.length && oldVal !== void 0) {
|
|
36387
|
-
let
|
|
36388
|
-
if (options.trimValues)
|
|
36389
|
-
|
|
36390
|
-
processedVals[i] =
|
|
36391
|
-
rawAttrsForMatcher[attrName] =
|
|
36971
|
+
let val = oldVal;
|
|
36972
|
+
if (options.trimValues) val = val.trim();
|
|
36973
|
+
val = this.replaceEntitiesValue(val, tagName, this.readonlyMatcher);
|
|
36974
|
+
processedVals[i] = val;
|
|
36975
|
+
rawAttrsForMatcher[attrName] = val;
|
|
36392
36976
|
hasRawAttrs = true;
|
|
36393
36977
|
}
|
|
36394
36978
|
}
|
|
@@ -36510,12 +37094,12 @@ var parseXml = function(xmlData) {
|
|
|
36510
37094
|
const closeIndex = findClosingIndex(xmlData, "]]>", i, "CDATA is not closed.") - 2;
|
|
36511
37095
|
const tagExp = xmlData.substring(i + 9, closeIndex);
|
|
36512
37096
|
textData = this.saveTextToParentTag(textData, currentNode, this.readonlyMatcher);
|
|
36513
|
-
let
|
|
36514
|
-
if (
|
|
37097
|
+
let val = this.parseTextData(tagExp, currentNode.tagname, this.readonlyMatcher, true, false, true, true);
|
|
37098
|
+
if (val == void 0) val = "";
|
|
36515
37099
|
if (options.cdataPropName) {
|
|
36516
37100
|
currentNode.add(options.cdataPropName, [{ [options.textNodeName]: tagExp }]);
|
|
36517
37101
|
} else {
|
|
36518
|
-
currentNode.add(options.textNodeName,
|
|
37102
|
+
currentNode.add(options.textNodeName, val);
|
|
36519
37103
|
}
|
|
36520
37104
|
i = closeIndex + 2;
|
|
36521
37105
|
} else {
|
|
@@ -36645,25 +37229,25 @@ function addChild(currentNode, childNode, matcher, startIndex) {
|
|
|
36645
37229
|
currentNode.addChild(childNode, startIndex);
|
|
36646
37230
|
}
|
|
36647
37231
|
}
|
|
36648
|
-
function replaceEntitiesValue(
|
|
37232
|
+
function replaceEntitiesValue(val, tagName, jPath) {
|
|
36649
37233
|
const entityConfig = this.options.processEntities;
|
|
36650
37234
|
if (!entityConfig || !entityConfig.enabled) {
|
|
36651
|
-
return
|
|
37235
|
+
return val;
|
|
36652
37236
|
}
|
|
36653
37237
|
if (entityConfig.allowedTags) {
|
|
36654
37238
|
const jPathOrMatcher = this.options.jPath ? jPath.toString() : jPath;
|
|
36655
37239
|
const allowed = Array.isArray(entityConfig.allowedTags) ? entityConfig.allowedTags.includes(tagName) : entityConfig.allowedTags(tagName, jPathOrMatcher);
|
|
36656
37240
|
if (!allowed) {
|
|
36657
|
-
return
|
|
37241
|
+
return val;
|
|
36658
37242
|
}
|
|
36659
37243
|
}
|
|
36660
37244
|
if (entityConfig.tagFilter) {
|
|
36661
37245
|
const jPathOrMatcher = this.options.jPath ? jPath.toString() : jPath;
|
|
36662
37246
|
if (!entityConfig.tagFilter(tagName, jPathOrMatcher)) {
|
|
36663
|
-
return
|
|
37247
|
+
return val;
|
|
36664
37248
|
}
|
|
36665
37249
|
}
|
|
36666
|
-
return this.entityDecoder.decode(
|
|
37250
|
+
return this.entityDecoder.decode(val);
|
|
36667
37251
|
}
|
|
36668
37252
|
function saveTextToParentTag(textData, parentNode, matcher, isLeafNode) {
|
|
36669
37253
|
if (textData) {
|
|
@@ -36798,15 +37382,15 @@ function readStopNodeData(xmlData, tagName, i) {
|
|
|
36798
37382
|
}
|
|
36799
37383
|
}
|
|
36800
37384
|
}
|
|
36801
|
-
function parseValue(
|
|
36802
|
-
if (shouldParse && typeof
|
|
36803
|
-
const newval =
|
|
37385
|
+
function parseValue(val, shouldParse, options) {
|
|
37386
|
+
if (shouldParse && typeof val === "string") {
|
|
37387
|
+
const newval = val.trim();
|
|
36804
37388
|
if (newval === "true") return true;
|
|
36805
37389
|
else if (newval === "false") return false;
|
|
36806
|
-
else return toNumber(
|
|
37390
|
+
else return toNumber(val, options);
|
|
36807
37391
|
} else {
|
|
36808
|
-
if (isExist(
|
|
36809
|
-
return
|
|
37392
|
+
if (isExist(val)) {
|
|
37393
|
+
return val;
|
|
36810
37394
|
} else {
|
|
36811
37395
|
return "";
|
|
36812
37396
|
}
|
|
@@ -36870,33 +37454,33 @@ function compress(arr, options, matcher, readonlyMatcher) {
|
|
|
36870
37454
|
} else if (property === void 0) {
|
|
36871
37455
|
continue;
|
|
36872
37456
|
} else if (tagObj[property]) {
|
|
36873
|
-
let
|
|
36874
|
-
const isLeaf = isLeafTag(
|
|
36875
|
-
if (Object.keys(
|
|
36876
|
-
|
|
37457
|
+
let val = compress(tagObj[property], options, matcher, readonlyMatcher);
|
|
37458
|
+
const isLeaf = isLeafTag(val, options);
|
|
37459
|
+
if (Object.keys(val).length === 0 && options.alwaysCreateTextNode) {
|
|
37460
|
+
val[options.textNodeName] = "";
|
|
36877
37461
|
}
|
|
36878
37462
|
if (tagObj[":@"]) {
|
|
36879
|
-
assignAttributes(
|
|
36880
|
-
} else if (Object.keys(
|
|
36881
|
-
|
|
36882
|
-
} else if (Object.keys(
|
|
36883
|
-
if (options.alwaysCreateTextNode)
|
|
36884
|
-
else
|
|
37463
|
+
assignAttributes(val, tagObj[":@"], readonlyMatcher, options);
|
|
37464
|
+
} else if (Object.keys(val).length === 1 && val[options.textNodeName] !== void 0 && !options.alwaysCreateTextNode) {
|
|
37465
|
+
val = val[options.textNodeName];
|
|
37466
|
+
} else if (Object.keys(val).length === 0) {
|
|
37467
|
+
if (options.alwaysCreateTextNode) val[options.textNodeName] = "";
|
|
37468
|
+
else val = "";
|
|
36885
37469
|
}
|
|
36886
|
-
if (tagObj[METADATA_SYMBOL2] !== void 0 && typeof
|
|
36887
|
-
|
|
37470
|
+
if (tagObj[METADATA_SYMBOL2] !== void 0 && typeof val === "object" && val !== null) {
|
|
37471
|
+
val[METADATA_SYMBOL2] = tagObj[METADATA_SYMBOL2];
|
|
36888
37472
|
}
|
|
36889
37473
|
if (compressedObj[property] !== void 0 && Object.prototype.hasOwnProperty.call(compressedObj, property)) {
|
|
36890
37474
|
if (!Array.isArray(compressedObj[property])) {
|
|
36891
37475
|
compressedObj[property] = [compressedObj[property]];
|
|
36892
37476
|
}
|
|
36893
|
-
compressedObj[property].push(
|
|
37477
|
+
compressedObj[property].push(val);
|
|
36894
37478
|
} else {
|
|
36895
37479
|
const jPathOrMatcher = options.jPath ? readonlyMatcher.toString() : readonlyMatcher;
|
|
36896
37480
|
if (options.isArray(property, jPathOrMatcher, isLeaf)) {
|
|
36897
|
-
compressedObj[property] = [
|
|
37481
|
+
compressedObj[property] = [val];
|
|
36898
37482
|
} else {
|
|
36899
|
-
compressedObj[property] =
|
|
37483
|
+
compressedObj[property] = val;
|
|
36900
37484
|
}
|
|
36901
37485
|
}
|
|
36902
37486
|
if (property !== void 0 && property !== options.textNodeName) {
|
|
@@ -37734,14 +38318,14 @@ function inflateSync(data, opts) {
|
|
|
37734
38318
|
}
|
|
37735
38319
|
var fltn = function(d, p, t, o) {
|
|
37736
38320
|
for (var k in d) {
|
|
37737
|
-
var
|
|
37738
|
-
if (Array.isArray(
|
|
37739
|
-
op = mrg(o,
|
|
37740
|
-
if (
|
|
37741
|
-
t[n] = [
|
|
38321
|
+
var val = d[k], n = p + k, op = o;
|
|
38322
|
+
if (Array.isArray(val))
|
|
38323
|
+
op = mrg(o, val[1]), val = val[0];
|
|
38324
|
+
if (val instanceof u8)
|
|
38325
|
+
t[n] = [val, op];
|
|
37742
38326
|
else {
|
|
37743
38327
|
t[n += "/"] = [new u8(0), op];
|
|
37744
|
-
fltn(
|
|
38328
|
+
fltn(val, n, t, o);
|
|
37745
38329
|
}
|
|
37746
38330
|
}
|
|
37747
38331
|
};
|
|
@@ -38128,14 +38712,14 @@ function extractSchemeColor(el) {
|
|
|
38128
38712
|
if (!el) return "000000";
|
|
38129
38713
|
const srgb = el["a:srgbClr"];
|
|
38130
38714
|
if (srgb) {
|
|
38131
|
-
const
|
|
38132
|
-
const hex = typeof
|
|
38715
|
+
const val = Array.isArray(srgb) ? srgb[0] : srgb;
|
|
38716
|
+
const hex = typeof val === "object" && val !== null ? val["@_val"] : void 0;
|
|
38133
38717
|
if (hex) return hex;
|
|
38134
38718
|
}
|
|
38135
38719
|
const sys = el["a:sysClr"];
|
|
38136
38720
|
if (sys) {
|
|
38137
|
-
const
|
|
38138
|
-
const lastClr = typeof
|
|
38721
|
+
const val = Array.isArray(sys) ? sys[0] : sys;
|
|
38722
|
+
const lastClr = typeof val === "object" && val !== null ? val["@_lastClr"] : void 0;
|
|
38139
38723
|
if (lastClr) return lastClr;
|
|
38140
38724
|
}
|
|
38141
38725
|
return "000000";
|
|
@@ -39915,9 +40499,9 @@ function parsePageSetupElement(worksheet) {
|
|
|
39915
40499
|
for (const [key, def] of fields) {
|
|
39916
40500
|
const raw = pm[`@_${key}`];
|
|
39917
40501
|
if (raw === void 0) continue;
|
|
39918
|
-
const
|
|
39919
|
-
if (!Number.isNaN(
|
|
39920
|
-
margins[key] =
|
|
40502
|
+
const val = parseFloat(raw);
|
|
40503
|
+
if (!Number.isNaN(val) && Math.abs(val - def) > 1e-6) {
|
|
40504
|
+
margins[key] = val;
|
|
39921
40505
|
anyNonDefault = true;
|
|
39922
40506
|
}
|
|
39923
40507
|
}
|
|
@@ -39930,11 +40514,11 @@ function parseHeaderFooterElement(worksheet) {
|
|
|
39930
40514
|
if (!hf) return void 0;
|
|
39931
40515
|
const out = {};
|
|
39932
40516
|
const readText = (key) => {
|
|
39933
|
-
const
|
|
40517
|
+
const val = hf[key];
|
|
39934
40518
|
let raw;
|
|
39935
|
-
if (typeof
|
|
39936
|
-
else if (
|
|
39937
|
-
raw =
|
|
40519
|
+
if (typeof val === "string") raw = val;
|
|
40520
|
+
else if (val && typeof val === "object" && "#text" in val && typeof val["#text"] === "string") {
|
|
40521
|
+
raw = val["#text"];
|
|
39938
40522
|
}
|
|
39939
40523
|
return raw !== void 0 ? decodeXmlEntities(raw) : void 0;
|
|
39940
40524
|
};
|
|
@@ -40505,9 +41089,9 @@ function extractSparklineColor(group) {
|
|
|
40505
41089
|
if (!rgb) return void 0;
|
|
40506
41090
|
return `#${rgb.length === 8 ? rgb.slice(2) : rgb}`;
|
|
40507
41091
|
}
|
|
40508
|
-
function ensureSparkArray(
|
|
40509
|
-
if (
|
|
40510
|
-
return Array.isArray(
|
|
41092
|
+
function ensureSparkArray(val) {
|
|
41093
|
+
if (val === void 0 || val === null) return [];
|
|
41094
|
+
return Array.isArray(val) ? val : [val];
|
|
40511
41095
|
}
|
|
40512
41096
|
function parsePageBreaks(worksheet) {
|
|
40513
41097
|
const rowPageBreaks = [];
|
|
@@ -40532,9 +41116,9 @@ function parsePageBreaks(worksheet) {
|
|
|
40532
41116
|
}
|
|
40533
41117
|
return { rowPageBreaks: rowPageBreaks.sort((a, b) => a - b), colPageBreaks: colPageBreaks.sort((a, b) => a - b) };
|
|
40534
41118
|
}
|
|
40535
|
-
function ensureBreakArray(
|
|
40536
|
-
if (
|
|
40537
|
-
return Array.isArray(
|
|
41119
|
+
function ensureBreakArray(val) {
|
|
41120
|
+
if (val === void 0 || val === null) return [];
|
|
41121
|
+
return Array.isArray(val) ? val : [val];
|
|
40538
41122
|
}
|
|
40539
41123
|
function parseAutoFilter(worksheet) {
|
|
40540
41124
|
const afEl = worksheet["autoFilter"];
|
|
@@ -40552,8 +41136,8 @@ function parseAutoFilter(worksheet) {
|
|
|
40552
41136
|
const filterArr = filtersEl["filter"];
|
|
40553
41137
|
if (filterArr) {
|
|
40554
41138
|
for (const f of filterArr) {
|
|
40555
|
-
const
|
|
40556
|
-
if (
|
|
41139
|
+
const val = f["@_val"];
|
|
41140
|
+
if (val !== void 0) filterValues.push(decodeXmlEntities(val));
|
|
40557
41141
|
}
|
|
40558
41142
|
}
|
|
40559
41143
|
}
|
|
@@ -40746,9 +41330,9 @@ function extractSeriesName(txNode) {
|
|
|
40746
41330
|
}
|
|
40747
41331
|
function extractNumericValues(valNode) {
|
|
40748
41332
|
if (!valNode || typeof valNode !== "object") return [];
|
|
40749
|
-
const
|
|
40750
|
-
const numRef = getObj(
|
|
40751
|
-
const cache = numRef ? getObj(numRef, "c:numCache") ?? getObj(numRef, "numCache") : getObj(
|
|
41333
|
+
const val = valNode;
|
|
41334
|
+
const numRef = getObj(val, "c:numRef") ?? getObj(val, "numRef");
|
|
41335
|
+
const cache = numRef ? getObj(numRef, "c:numCache") ?? getObj(numRef, "numCache") : getObj(val, "c:numLit") ?? getObj(val, "numLit");
|
|
40752
41336
|
if (!cache || typeof cache !== "object") return [];
|
|
40753
41337
|
const pts = ensureArray(cache["c:pt"] ?? cache["pt"]);
|
|
40754
41338
|
const values2 = [];
|
|
@@ -40792,8 +41376,8 @@ function extractColor2(spPr) {
|
|
|
40792
41376
|
if (!solidFill || typeof solidFill !== "object") return void 0;
|
|
40793
41377
|
const srgb = getObj(solidFill, "a:srgbClr") ?? getObj(solidFill, "srgbClr");
|
|
40794
41378
|
if (srgb && typeof srgb === "object") {
|
|
40795
|
-
const
|
|
40796
|
-
if (typeof
|
|
41379
|
+
const val = srgb["@_val"];
|
|
41380
|
+
if (typeof val === "string") return `#${val}`;
|
|
40797
41381
|
}
|
|
40798
41382
|
return void 0;
|
|
40799
41383
|
}
|
|
@@ -40820,9 +41404,9 @@ function extractLegendPosition(legendNode) {
|
|
|
40820
41404
|
if (!legendNode || typeof legendNode !== "object") return void 0;
|
|
40821
41405
|
const pos = getObj(legendNode, "c:legendPos") ?? getObj(legendNode, "legendPos");
|
|
40822
41406
|
if (!pos || typeof pos !== "object") return void 0;
|
|
40823
|
-
const
|
|
41407
|
+
const val = pos["@_val"];
|
|
40824
41408
|
const map2 = { t: "top", b: "bottom", l: "left", r: "right" };
|
|
40825
|
-
return typeof
|
|
41409
|
+
return typeof val === "string" ? map2[val] ?? "right" : "right";
|
|
40826
41410
|
}
|
|
40827
41411
|
function parseAxes(plotArea) {
|
|
40828
41412
|
const axes = [];
|
|
@@ -40871,12 +41455,12 @@ function getObj(parent, key) {
|
|
|
40871
41455
|
function getAttr(obj, childKey, attr) {
|
|
40872
41456
|
const child = childKey ? obj[childKey] : obj;
|
|
40873
41457
|
if (!child || typeof child !== "object") return void 0;
|
|
40874
|
-
const
|
|
40875
|
-
return typeof
|
|
41458
|
+
const val = child[`@_${attr}`];
|
|
41459
|
+
return typeof val === "string" ? val : void 0;
|
|
40876
41460
|
}
|
|
40877
|
-
function ensureArray(
|
|
40878
|
-
if (
|
|
40879
|
-
return Array.isArray(
|
|
41461
|
+
function ensureArray(val) {
|
|
41462
|
+
if (val === void 0 || val === null) return [];
|
|
41463
|
+
return Array.isArray(val) ? val : [val];
|
|
40880
41464
|
}
|
|
40881
41465
|
|
|
40882
41466
|
// ../xlsx/src/ooxml_drawing.ts
|
|
@@ -41005,8 +41589,8 @@ function extractOutlineColor(spPr) {
|
|
|
41005
41589
|
function extractSrgb(fill) {
|
|
41006
41590
|
const srgb = fill["a:srgbClr"] ?? fill["srgbClr"];
|
|
41007
41591
|
if (srgb && typeof srgb === "object") {
|
|
41008
|
-
const
|
|
41009
|
-
if (typeof
|
|
41592
|
+
const val = srgb["@_val"];
|
|
41593
|
+
if (typeof val === "string") return `#${val}`;
|
|
41010
41594
|
}
|
|
41011
41595
|
return void 0;
|
|
41012
41596
|
}
|
|
@@ -41043,14 +41627,14 @@ function extractPicRId(pic) {
|
|
|
41043
41627
|
const rId = blip["@_r:embed"] ?? blip["@_embed"];
|
|
41044
41628
|
return typeof rId === "string" ? rId : void 0;
|
|
41045
41629
|
}
|
|
41046
|
-
function ensureArray2(
|
|
41047
|
-
if (
|
|
41048
|
-
return Array.isArray(
|
|
41630
|
+
function ensureArray2(val) {
|
|
41631
|
+
if (val === void 0 || val === null) return [];
|
|
41632
|
+
return Array.isArray(val) ? val : [val];
|
|
41049
41633
|
}
|
|
41050
|
-
function parseIntVal(
|
|
41051
|
-
if (typeof
|
|
41052
|
-
if (typeof
|
|
41053
|
-
const n = parseInt(
|
|
41634
|
+
function parseIntVal(val) {
|
|
41635
|
+
if (typeof val === "number") return val;
|
|
41636
|
+
if (typeof val === "string") {
|
|
41637
|
+
const n = parseInt(val, 10);
|
|
41054
41638
|
return isNaN(n) ? void 0 : n;
|
|
41055
41639
|
}
|
|
41056
41640
|
return void 0;
|
|
@@ -41122,12 +41706,12 @@ function extractTableRIds(rels) {
|
|
|
41122
41706
|
return result;
|
|
41123
41707
|
}
|
|
41124
41708
|
function strAttr(obj, attr) {
|
|
41125
|
-
const
|
|
41126
|
-
return typeof
|
|
41709
|
+
const val = obj[`@_${attr}`];
|
|
41710
|
+
return typeof val === "string" ? val : void 0;
|
|
41127
41711
|
}
|
|
41128
|
-
function ensureArray3(
|
|
41129
|
-
if (
|
|
41130
|
-
return Array.isArray(
|
|
41712
|
+
function ensureArray3(val) {
|
|
41713
|
+
if (val === void 0 || val === null) return [];
|
|
41714
|
+
return Array.isArray(val) ? val : [val];
|
|
41131
41715
|
}
|
|
41132
41716
|
|
|
41133
41717
|
// ../xlsx/src/ooxml_pivot.ts
|
|
@@ -41423,9 +42007,9 @@ function extractWorkbookPivotCaches(workbook) {
|
|
|
41423
42007
|
return out;
|
|
41424
42008
|
}
|
|
41425
42009
|
function strAttr2(obj, attr) {
|
|
41426
|
-
const
|
|
41427
|
-
if (typeof
|
|
41428
|
-
if (typeof
|
|
42010
|
+
const val = obj[`@_${attr}`];
|
|
42011
|
+
if (typeof val === "string") return val;
|
|
42012
|
+
if (typeof val === "number") return String(val);
|
|
41429
42013
|
return void 0;
|
|
41430
42014
|
}
|
|
41431
42015
|
function intAttr(obj, attr) {
|
|
@@ -41441,12 +42025,12 @@ function boolAttr(obj, attr, fallback) {
|
|
|
41441
42025
|
if (v === "0" || v === "false") return false;
|
|
41442
42026
|
return fallback;
|
|
41443
42027
|
}
|
|
41444
|
-
function ensureArray4(
|
|
41445
|
-
if (
|
|
41446
|
-
return Array.isArray(
|
|
42028
|
+
function ensureArray4(val) {
|
|
42029
|
+
if (val === void 0 || val === null) return [];
|
|
42030
|
+
return Array.isArray(val) ? val : [val];
|
|
41447
42031
|
}
|
|
41448
|
-
function asObj(
|
|
41449
|
-
return
|
|
42032
|
+
function asObj(val) {
|
|
42033
|
+
return val && typeof val === "object" ? val : {};
|
|
41450
42034
|
}
|
|
41451
42035
|
|
|
41452
42036
|
// ../xlsx/src/ooxml_shape.ts
|
|
@@ -41709,9 +42293,9 @@ function extractVmlText(textbox) {
|
|
|
41709
42293
|
}
|
|
41710
42294
|
return void 0;
|
|
41711
42295
|
}
|
|
41712
|
-
function ensureVmlArray(
|
|
41713
|
-
if (
|
|
41714
|
-
return Array.isArray(
|
|
42296
|
+
function ensureVmlArray(val) {
|
|
42297
|
+
if (val === void 0 || val === null) return [];
|
|
42298
|
+
return Array.isArray(val) ? val : [val];
|
|
41715
42299
|
}
|
|
41716
42300
|
|
|
41717
42301
|
// ../xlsx/src/excel_parser.ts
|
|
@@ -46313,20 +46897,31 @@ Lotics is an AI-powered operations platform. Through this CLI you can:
|
|
|
46313
46897
|
AUTHENTICATION
|
|
46314
46898
|
lotics auth Show auth help
|
|
46315
46899
|
lotics auth signup <email> Create account (run "lotics auth" for details)
|
|
46900
|
+
lotics auth api-key <key> Save a key \u2014 registers its org as a profile
|
|
46901
|
+
|
|
46902
|
+
ORGANIZATIONS
|
|
46903
|
+
Each saved API key belongs to one org. Register a key per org once, then
|
|
46904
|
+
switch between them with no re-pasting. Workspaces live inside an org.
|
|
46905
|
+
lotics org List saved orgs (marks active)
|
|
46906
|
+
lotics org use <name|id> Switch the active org
|
|
46907
|
+
lotics org use <name|id> --local Pin THIS directory to an org (worktrees)
|
|
46316
46908
|
|
|
46317
46909
|
USAGE
|
|
46318
46910
|
1. lotics auth signup <email> Create account or authenticate
|
|
46319
|
-
2. lotics
|
|
46320
|
-
3. lotics
|
|
46321
|
-
4. lotics tools
|
|
46322
|
-
5. lotics
|
|
46911
|
+
2. lotics org See saved orgs / which one is active
|
|
46912
|
+
3. lotics workspace Check current workspace (auto-selects if only one)
|
|
46913
|
+
4. lotics tools List available tools by category
|
|
46914
|
+
5. lotics tools <name> Show tool description and full input schema
|
|
46915
|
+
6. lotics run <tool> '<json>' Execute a tool with JSON arguments
|
|
46323
46916
|
|
|
46324
46917
|
Always inspect the schema (step 4) before calling a tool.
|
|
46325
46918
|
Tools are grouped by category (tables, records, views, etc.).
|
|
46326
46919
|
Query tools return IDs used as arguments to other tools.
|
|
46327
46920
|
|
|
46328
46921
|
COMMANDS
|
|
46329
|
-
lotics
|
|
46922
|
+
lotics org List saved orgs (marks active)
|
|
46923
|
+
lotics org use <name|id> [--local] Switch active org (--local pins this dir)
|
|
46924
|
+
lotics workspace List workspaces in the active org (marks current)
|
|
46330
46925
|
lotics workspace select <id> Switch to a different workspace
|
|
46331
46926
|
lotics workspace create <name> Create a new workspace (admin only)
|
|
46332
46927
|
lotics tools List all available tools
|
|
@@ -46357,15 +46952,23 @@ FLAGS
|
|
|
46357
46952
|
--timeout <ms> Timeout for tool execution (default: 60000)
|
|
46358
46953
|
-o <path> Output dir for downloads
|
|
46359
46954
|
--as <name> Override upload filename
|
|
46360
|
-
--api-key <key> API key (overrides saved config
|
|
46361
|
-
--
|
|
46955
|
+
--api-key <key> One-off API key (overrides saved config + env)
|
|
46956
|
+
--workspace <id> One-off workspace override (alias: -w)
|
|
46957
|
+
--local Pin the current directory (lotics org use / auth api-key)
|
|
46958
|
+
--all (lotics auth logout) Remove every saved credential
|
|
46362
46959
|
--version Show version
|
|
46363
46960
|
|
|
46364
46961
|
CONFIG
|
|
46365
|
-
|
|
46366
|
-
|
|
46367
|
-
|
|
46368
|
-
|
|
46962
|
+
API keys are stored once per org in the global ~/.lotics/config.json as named
|
|
46963
|
+
profiles. Switch with "lotics org use <name|id>" \u2014 no re-pasting. A directory
|
|
46964
|
+
(e.g. a git worktree) can pin its own org/workspace with "lotics org use
|
|
46965
|
+
<name|id> --local", which writes a .lotics/config.json pointer (the key is
|
|
46966
|
+
resolved from the global store) \u2014 so a global switch never disturbs it.
|
|
46967
|
+
|
|
46968
|
+
Resolution precedence (highest first):
|
|
46969
|
+
--api-key flag > LOTICS_API_KEY env > LOTICS_ORG env >
|
|
46970
|
+
local .lotics/config.json > global active profile
|
|
46971
|
+
LOTICS_WORKSPACE (or --workspace) overrides the workspace at any level.
|
|
46369
46972
|
|
|
46370
46973
|
OUTPUT
|
|
46371
46974
|
Default output is a compact text summary optimized for AI agents \u2014
|
|
@@ -46394,25 +46997,27 @@ function printAuthHelp() {
|
|
|
46394
46997
|
console.log(`Authentication commands:
|
|
46395
46998
|
|
|
46396
46999
|
lotics auth signup <email> Create account, org, workspace, and API key
|
|
46397
|
-
lotics auth api-key [key] Save an
|
|
47000
|
+
lotics auth api-key [key] Save an API key \u2014 registers its org as a profile
|
|
46398
47001
|
lotics auth web Send a magic link email to access the web app
|
|
46399
|
-
lotics auth whoami Show the
|
|
46400
|
-
lotics auth logout
|
|
47002
|
+
lotics auth whoami Show the active account, org, workspace, and source
|
|
47003
|
+
lotics auth logout [<name|id>] Remove a saved credential (default: the active org,
|
|
47004
|
+
or unpin the current directory)
|
|
47005
|
+
lotics auth logout --all Remove every saved credential
|
|
46401
47006
|
|
|
46402
47007
|
Auth flags:
|
|
46403
|
-
--local
|
|
46404
|
-
|
|
47008
|
+
--local Pin the current directory instead of the global store.
|
|
47009
|
+
signup/api-key write a self-contained ./.lotics/config.json
|
|
47010
|
+
(inline key) \u2014 for a hermetic worktree or CI.
|
|
46405
47011
|
--name <name> (signup) Display name (defaults to email prefix)
|
|
46406
47012
|
--timezone <timezone> (signup) Workspace timezone (defaults to UTC, e.g. Asia/Ho_Chi_Minh)
|
|
46407
47013
|
|
|
46408
|
-
|
|
46409
|
-
|
|
47014
|
+
API keys are stored once per org as named profiles in ~/.lotics/config.json.
|
|
47015
|
+
Registering a second key adds a profile \u2014 it does not overwrite the first.
|
|
47016
|
+
Switch active org with "lotics org use <name|id>".
|
|
46410
47017
|
|
|
46411
|
-
|
|
46412
|
-
|
|
46413
|
-
|
|
46414
|
-
its own account and workspace; --local creates one. Note: an exported
|
|
46415
|
-
LOTICS_API_KEY env var overrides the config file's key.`);
|
|
47018
|
+
Resolution precedence (highest first):
|
|
47019
|
+
--api-key flag > LOTICS_API_KEY env > LOTICS_ORG env > local .lotics/config.json
|
|
47020
|
+
> global active profile. LOTICS_WORKSPACE / --workspace override the workspace.`);
|
|
46416
47021
|
}
|
|
46417
47022
|
function readStdin() {
|
|
46418
47023
|
return new Promise((resolve, reject2) => {
|
|
@@ -46464,17 +47069,18 @@ async function handleSignup(positionalEmail, flags) {
|
|
|
46464
47069
|
}
|
|
46465
47070
|
process.exit(1);
|
|
46466
47071
|
}
|
|
46467
|
-
const
|
|
46468
|
-
const
|
|
46469
|
-
|
|
46470
|
-
|
|
46471
|
-
|
|
46472
|
-
|
|
46473
|
-
|
|
46474
|
-
|
|
47072
|
+
const apiKey = data.api_key;
|
|
47073
|
+
const orgId = data.organization_id;
|
|
47074
|
+
const workspaceId = data.workspace_id;
|
|
47075
|
+
const orgName = name || email.split("@")[0];
|
|
47076
|
+
upsertProfile(orgId, { api_key: apiKey, org_name: orgName, workspace_id: workspaceId });
|
|
47077
|
+
const existing = loadGlobalConfig() ?? {};
|
|
47078
|
+
saveGlobalConfig({ ...existing, email });
|
|
47079
|
+
setActiveOrg(orgId, flags.local ? "local" : "global");
|
|
46475
47080
|
console.error(`Account created. You can now use the CLI.`);
|
|
46476
|
-
console.error(` Email: ${
|
|
46477
|
-
console.error(`
|
|
47081
|
+
console.error(` Email: ${email}`);
|
|
47082
|
+
console.error(` Org: ${orgName} (${orgId})`);
|
|
47083
|
+
console.error(flags.local ? ` Pinned this directory: ${getConfigPath("local")}` : ` Saved to the "${orgName}" profile in ~/.lotics (now active)`);
|
|
46478
47084
|
console.error(`
|
|
46479
47085
|
Check your email for a magic link to access the Lotics web app.`);
|
|
46480
47086
|
console.error(`Run "lotics auth web" to request a new link at any time.`);
|
|
@@ -46486,53 +47092,70 @@ async function handleSetup(providedKey, local) {
|
|
|
46486
47092
|
process.exit(1);
|
|
46487
47093
|
}
|
|
46488
47094
|
const client = new LoticsClient({ apiKey });
|
|
46489
|
-
let
|
|
47095
|
+
let info;
|
|
46490
47096
|
try {
|
|
46491
|
-
|
|
46492
|
-
email = info.email;
|
|
47097
|
+
info = await client.whoami();
|
|
46493
47098
|
} catch (error) {
|
|
46494
47099
|
const message = error instanceof Error ? error.message : String(error);
|
|
46495
47100
|
console.error(`Authentication failed: ${message}`);
|
|
46496
47101
|
process.exit(1);
|
|
46497
47102
|
}
|
|
46498
|
-
|
|
46499
|
-
const existing = loadConfig(scope) ?? {};
|
|
46500
|
-
const newConfig = { ...existing, api_key: apiKey, email };
|
|
47103
|
+
let workspaceId;
|
|
46501
47104
|
try {
|
|
46502
47105
|
const workspaces = await client.listWorkspaces();
|
|
46503
47106
|
if (workspaces.length === 1) {
|
|
46504
|
-
|
|
47107
|
+
workspaceId = workspaces[0].id;
|
|
46505
47108
|
} else if (workspaces.length > 1) {
|
|
46506
47109
|
console.error(`
|
|
46507
|
-
Multiple workspaces
|
|
47110
|
+
Multiple workspaces in ${info.organization_name}. Run "lotics workspace select <id>" to choose one:`);
|
|
46508
47111
|
printWorkspaceList(workspaces);
|
|
46509
47112
|
}
|
|
46510
47113
|
} catch (error) {
|
|
46511
47114
|
const msg = error instanceof Error ? error.message : String(error);
|
|
46512
47115
|
console.error(`Warning: could not resolve workspace: ${msg}`);
|
|
46513
47116
|
}
|
|
46514
|
-
|
|
46515
|
-
|
|
46516
|
-
|
|
47117
|
+
upsertProfile(info.organization_id, {
|
|
47118
|
+
api_key: apiKey,
|
|
47119
|
+
org_name: info.organization_name,
|
|
47120
|
+
workspace_id: workspaceId
|
|
47121
|
+
});
|
|
47122
|
+
const existing = loadGlobalConfig() ?? {};
|
|
47123
|
+
saveGlobalConfig({ ...existing, email: info.email });
|
|
47124
|
+
setActiveOrg(info.organization_id, local ? "local" : "global");
|
|
47125
|
+
if (local) {
|
|
47126
|
+
console.error(`Authenticated as ${info.email} in ${info.organization_name}.`);
|
|
47127
|
+
console.error(` Pinned this directory: ${getConfigPath("local")}`);
|
|
47128
|
+
} else {
|
|
47129
|
+
console.error(`Authenticated as ${info.email} in ${info.organization_name} (now active).`);
|
|
47130
|
+
console.error(` Saved to the "${info.organization_name}" profile in ~/.lotics`);
|
|
47131
|
+
}
|
|
46517
47132
|
}
|
|
46518
47133
|
function requireClient(flags) {
|
|
46519
|
-
const
|
|
46520
|
-
if (!
|
|
46521
|
-
console.error('Not authenticated. Run "lotics auth signup" or set LOTICS_API_KEY.');
|
|
47134
|
+
const ctx = resolveContext(flags);
|
|
47135
|
+
if (!ctx) {
|
|
47136
|
+
console.error('Not authenticated. Run "lotics auth signup", "lotics auth api-key <key>", or set LOTICS_API_KEY.');
|
|
46522
47137
|
process.exit(1);
|
|
46523
47138
|
}
|
|
46524
|
-
|
|
46525
|
-
return new LoticsClient({ apiKey: auth.apiKey, workspaceId: config?.workspace_id });
|
|
47139
|
+
return { client: new LoticsClient({ apiKey: ctx.apiKey, workspaceId: ctx.workspaceId }), ctx };
|
|
46526
47140
|
}
|
|
47141
|
+
var SOURCE_LABELS = {
|
|
47142
|
+
flag: "--api-key flag",
|
|
47143
|
+
env_key: "LOTICS_API_KEY env",
|
|
47144
|
+
env_org: "LOTICS_ORG env",
|
|
47145
|
+
local_pointer: "local .lotics/config.json (pin)",
|
|
47146
|
+
global_profile: "global active profile"
|
|
47147
|
+
};
|
|
46527
47148
|
function printWorkspaceList(workspaces, currentId) {
|
|
46528
47149
|
for (const ws of workspaces) {
|
|
46529
47150
|
const marker = ws.id === currentId ? " (current)" : "";
|
|
46530
47151
|
console.error(` ${ws.id} ${ws.name} ${ws.timezone} ${ws.default_currency}${marker}`);
|
|
46531
47152
|
}
|
|
46532
47153
|
}
|
|
46533
|
-
async function resolveWorkspace(client) {
|
|
46534
|
-
|
|
46535
|
-
|
|
47154
|
+
async function resolveWorkspace(client, ctx) {
|
|
47155
|
+
if (ctx.workspaceId) {
|
|
47156
|
+
client.setWorkspaceId(ctx.workspaceId);
|
|
47157
|
+
return;
|
|
47158
|
+
}
|
|
46536
47159
|
let workspaces;
|
|
46537
47160
|
try {
|
|
46538
47161
|
workspaces = await client.listWorkspaces();
|
|
@@ -46546,8 +47169,7 @@ async function resolveWorkspace(client) {
|
|
|
46546
47169
|
process.exit(1);
|
|
46547
47170
|
}
|
|
46548
47171
|
if (workspaces.length === 1) {
|
|
46549
|
-
|
|
46550
|
-
saveConfig({ ...existing, workspace_id: workspaces[0].id });
|
|
47172
|
+
setSelectedWorkspace(workspaces[0].id);
|
|
46551
47173
|
client.setWorkspaceId(workspaces[0].id);
|
|
46552
47174
|
return;
|
|
46553
47175
|
}
|
|
@@ -46595,32 +47217,60 @@ async function main() {
|
|
|
46595
47217
|
return;
|
|
46596
47218
|
}
|
|
46597
47219
|
if (subcommand === "whoami") {
|
|
46598
|
-
const
|
|
46599
|
-
if (!
|
|
46600
|
-
console.error('Not authenticated. Run "lotics auth signup" or set LOTICS_API_KEY.');
|
|
47220
|
+
const ctx2 = resolveContext(flags);
|
|
47221
|
+
if (!ctx2) {
|
|
47222
|
+
console.error('Not authenticated. Run "lotics auth signup", "lotics auth api-key <key>", or set LOTICS_API_KEY.');
|
|
46601
47223
|
process.exit(1);
|
|
46602
47224
|
}
|
|
46603
|
-
const client2 = new LoticsClient({ apiKey:
|
|
47225
|
+
const client2 = new LoticsClient({ apiKey: ctx2.apiKey });
|
|
46604
47226
|
const info = await client2.whoami();
|
|
46605
|
-
const existing =
|
|
46606
|
-
|
|
47227
|
+
const existing = loadGlobalConfig() ?? {};
|
|
47228
|
+
saveGlobalConfig({ ...existing, email: info.email });
|
|
46607
47229
|
if (flags.json) {
|
|
46608
|
-
console.log(JSON.stringify(info, null, 2));
|
|
47230
|
+
console.log(JSON.stringify({ ...info, workspace_id: ctx2.workspaceId ?? null, source: ctx2.source }, null, 2));
|
|
46609
47231
|
} else {
|
|
46610
|
-
console.log(`Name:
|
|
46611
|
-
console.log(`Email:
|
|
46612
|
-
console.log(`Org:
|
|
47232
|
+
console.log(`Name: ${info.name}`);
|
|
47233
|
+
console.log(`Email: ${info.email}`);
|
|
47234
|
+
console.log(`Org: ${info.organization_name} (${info.organization_id})`);
|
|
47235
|
+
console.log(`Workspace: ${ctx2.workspaceId ?? "(none selected)"}`);
|
|
47236
|
+
console.log(`Source: ${SOURCE_LABELS[ctx2.source]}`);
|
|
46613
47237
|
}
|
|
46614
|
-
console.error(`Config: ${getConfigPath()}`);
|
|
46615
47238
|
return;
|
|
46616
47239
|
}
|
|
46617
47240
|
if (subcommand === "logout") {
|
|
46618
|
-
|
|
46619
|
-
|
|
47241
|
+
const local = loadLocalConfig();
|
|
47242
|
+
if (local && !flags.all && !toolArgs) {
|
|
47243
|
+
deleteConfig();
|
|
47244
|
+
console.error("Removed the local pin for this directory.");
|
|
47245
|
+
return;
|
|
47246
|
+
}
|
|
47247
|
+
if (flags.all) {
|
|
47248
|
+
const g2 = loadGlobalConfig();
|
|
47249
|
+
saveGlobalConfig({ last_update_check: g2?.last_update_check, latest_version: g2?.latest_version });
|
|
47250
|
+
console.error("Removed all saved credentials.");
|
|
47251
|
+
return;
|
|
47252
|
+
}
|
|
47253
|
+
const g = loadGlobalConfig() ?? {};
|
|
47254
|
+
const profiles = g.profiles ?? {};
|
|
47255
|
+
let resolved;
|
|
47256
|
+
if (toolArgs) {
|
|
47257
|
+
resolved = resolveProfileByNameOrId(profiles, toolArgs);
|
|
47258
|
+
} else if (g.active_org && profiles[g.active_org]) {
|
|
47259
|
+
resolved = [g.active_org, profiles[g.active_org]];
|
|
47260
|
+
} else {
|
|
47261
|
+
resolved = null;
|
|
47262
|
+
}
|
|
47263
|
+
if (!resolved) {
|
|
47264
|
+
console.error(toolArgs ? `No saved credential matches "${toolArgs}".` : "No active credential to remove. Pass an org name/id, or use --all.");
|
|
47265
|
+
process.exit(1);
|
|
47266
|
+
}
|
|
47267
|
+
const [orgId, profile] = resolved;
|
|
47268
|
+
removeProfile(orgId);
|
|
47269
|
+
console.error(`Removed the "${profile.org_name}" credential (${orgId}).`);
|
|
46620
47270
|
return;
|
|
46621
47271
|
}
|
|
46622
47272
|
if (subcommand === "web") {
|
|
46623
|
-
const client2 = requireClient(flags);
|
|
47273
|
+
const { client: client2 } = requireClient(flags);
|
|
46624
47274
|
const { email } = await client2.login();
|
|
46625
47275
|
console.error(`Magic link sent to ${email}. Check your email to access the Lotics web app.`);
|
|
46626
47276
|
return;
|
|
@@ -46640,6 +47290,63 @@ async function main() {
|
|
|
46640
47290
|
await runDocxCommand(subcommand, toolArgs, restArgs);
|
|
46641
47291
|
return;
|
|
46642
47292
|
}
|
|
47293
|
+
if (command === "org") {
|
|
47294
|
+
const global2 = loadGlobalConfig() ?? {};
|
|
47295
|
+
const profiles = global2.profiles ?? {};
|
|
47296
|
+
const local = loadLocalConfig();
|
|
47297
|
+
if (subcommand === "use") {
|
|
47298
|
+
if (!toolArgs) {
|
|
47299
|
+
console.error("Usage: lotics org use <name|id> [--local]");
|
|
47300
|
+
process.exit(1);
|
|
47301
|
+
}
|
|
47302
|
+
const resolved = resolveProfileByNameOrId(profiles, toolArgs);
|
|
47303
|
+
if (!resolved) {
|
|
47304
|
+
console.error(`No saved credential for "${toolArgs}". Run "lotics auth api-key <key>" while authenticated to that org, or "lotics org" to list.`);
|
|
47305
|
+
process.exit(1);
|
|
47306
|
+
}
|
|
47307
|
+
const [orgId, profile] = resolved;
|
|
47308
|
+
if (flags.local) {
|
|
47309
|
+
setActiveOrg(orgId, "local");
|
|
47310
|
+
console.error(`Pinned this directory to ${profile.org_name} (${orgId}).`);
|
|
47311
|
+
} else {
|
|
47312
|
+
setActiveOrg(orgId, "global");
|
|
47313
|
+
console.error(`Switched active org to ${profile.org_name} (${orgId}).`);
|
|
47314
|
+
if (local?.active_org) {
|
|
47315
|
+
console.error("Note: a local pin (.lotics/config.json) overrides the global default in this directory. Use --local to change the pin here.");
|
|
47316
|
+
}
|
|
47317
|
+
}
|
|
47318
|
+
return;
|
|
47319
|
+
}
|
|
47320
|
+
if (subcommand && subcommand !== "list") {
|
|
47321
|
+
console.error(`Unknown org subcommand: ${subcommand}`);
|
|
47322
|
+
console.error("Usage: lotics org [list | use <name|id> [--local]]");
|
|
47323
|
+
process.exit(1);
|
|
47324
|
+
}
|
|
47325
|
+
const orgIds = Object.keys(profiles);
|
|
47326
|
+
if (orgIds.length === 0) {
|
|
47327
|
+
console.error('No saved orgs. Run "lotics auth api-key <key>" to add one.');
|
|
47328
|
+
return;
|
|
47329
|
+
}
|
|
47330
|
+
const effectiveActive = local?.active_org ?? global2.active_org;
|
|
47331
|
+
if (flags.json) {
|
|
47332
|
+
console.log(JSON.stringify(
|
|
47333
|
+
orgIds.map((id) => ({
|
|
47334
|
+
org_id: id,
|
|
47335
|
+
org_name: profiles[id].org_name,
|
|
47336
|
+
workspace_id: profiles[id].workspace_id ?? null,
|
|
47337
|
+
active: id === effectiveActive
|
|
47338
|
+
})),
|
|
47339
|
+
null,
|
|
47340
|
+
2
|
|
47341
|
+
));
|
|
47342
|
+
} else {
|
|
47343
|
+
for (const id of orgIds) {
|
|
47344
|
+
const marker = id === effectiveActive ? " (active)" : "";
|
|
47345
|
+
console.log(`${id} ${profiles[id].org_name}${marker}`);
|
|
47346
|
+
}
|
|
47347
|
+
}
|
|
47348
|
+
return;
|
|
47349
|
+
}
|
|
46643
47350
|
if (command !== "tools" && command !== "upload" && command !== "run" && command !== "download" && command !== "workspace" && command !== "app") {
|
|
46644
47351
|
console.error(`Unknown command: ${command}`);
|
|
46645
47352
|
console.error('Run "lotics --help" for usage.');
|
|
@@ -46678,10 +47385,10 @@ async function main() {
|
|
|
46678
47385
|
console.error("Downloads every file on the given file field into the output dir.");
|
|
46679
47386
|
process.exit(1);
|
|
46680
47387
|
}
|
|
46681
|
-
const client = requireClient(flags);
|
|
47388
|
+
const { client, ctx } = requireClient(flags);
|
|
46682
47389
|
if (command === "workspace") {
|
|
46683
47390
|
const workspaces = await client.listWorkspaces();
|
|
46684
|
-
const
|
|
47391
|
+
const currentWorkspaceId = ctx.workspaceId;
|
|
46685
47392
|
if (subcommand === "select") {
|
|
46686
47393
|
const targetId = toolArgs;
|
|
46687
47394
|
if (!targetId) {
|
|
@@ -46693,12 +47400,16 @@ async function main() {
|
|
|
46693
47400
|
console.error(`Workspace not found: ${targetId}
|
|
46694
47401
|
|
|
46695
47402
|
Available workspaces:`);
|
|
46696
|
-
printWorkspaceList(workspaces,
|
|
47403
|
+
printWorkspaceList(workspaces, currentWorkspaceId);
|
|
46697
47404
|
process.exit(1);
|
|
46698
47405
|
}
|
|
46699
|
-
const
|
|
46700
|
-
|
|
46701
|
-
|
|
47406
|
+
const written = setSelectedWorkspace(target.id);
|
|
47407
|
+
if (!written) {
|
|
47408
|
+
console.error(`Switched to ${target.name} (${target.id}) for this command, but it could not be saved \u2014 credentials came from --api-key/LOTICS_API_KEY with no saved profile. Run "lotics auth api-key <key>" to persist a default.`);
|
|
47409
|
+
return;
|
|
47410
|
+
}
|
|
47411
|
+
const where = written.scope === "local" ? " (pinned to this directory)" : "";
|
|
47412
|
+
console.error(`Switched to workspace: ${target.name} (${target.id})${where}`);
|
|
46702
47413
|
return;
|
|
46703
47414
|
}
|
|
46704
47415
|
if (subcommand === "create") {
|
|
@@ -46709,8 +47420,7 @@ Available workspaces:`);
|
|
|
46709
47420
|
}
|
|
46710
47421
|
const timezone = flags.timezone;
|
|
46711
47422
|
const created = await client.createWorkspace({ name, timezone });
|
|
46712
|
-
|
|
46713
|
-
saveConfig({ ...existing, workspace_id: created.id });
|
|
47423
|
+
setSelectedWorkspace(created.id);
|
|
46714
47424
|
client.setWorkspaceId(created.id);
|
|
46715
47425
|
if (flags.json) {
|
|
46716
47426
|
console.log(JSON.stringify(created, null, 2));
|
|
@@ -46732,15 +47442,15 @@ Available workspaces:`);
|
|
|
46732
47442
|
console.error("No workspaces found.");
|
|
46733
47443
|
} else {
|
|
46734
47444
|
for (const ws of workspaces) {
|
|
46735
|
-
const marker = ws.id ===
|
|
47445
|
+
const marker = ws.id === currentWorkspaceId ? " (current)" : "";
|
|
46736
47446
|
console.log(`${ws.id} ${ws.name} ${ws.timezone} ${ws.default_currency}${marker}`);
|
|
46737
47447
|
}
|
|
46738
47448
|
}
|
|
46739
47449
|
}
|
|
46740
|
-
console.error(`
|
|
47450
|
+
if (ctx.orgName) console.error(`Org: ${ctx.orgName}`);
|
|
46741
47451
|
return;
|
|
46742
47452
|
}
|
|
46743
|
-
await resolveWorkspace(client);
|
|
47453
|
+
await resolveWorkspace(client, ctx);
|
|
46744
47454
|
if (command === "app") {
|
|
46745
47455
|
if (subcommand === "create") {
|
|
46746
47456
|
const name = toolArgs;
|