@base44-preview/cli 0.1.32-pr.665.1a74073 → 0.1.32-pr.665.9dd49bd
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 +4 -0
- package/dist/cli/index.js +1943 -81
- package/dist/cli/index.js.map +24 -8
- package/package.json +1 -1
package/dist/cli/index.js
CHANGED
|
@@ -31177,7 +31177,7 @@ function cleanDoc(doc) {
|
|
|
31177
31177
|
return mapDoc(doc, (currentDoc) => cleanDocFn(currentDoc));
|
|
31178
31178
|
}
|
|
31179
31179
|
function replaceEndOfLine(doc, replacement = literalline) {
|
|
31180
|
-
return mapDoc(doc, (currentDoc) => typeof currentDoc === "string" ?
|
|
31180
|
+
return mapDoc(doc, (currentDoc) => typeof currentDoc === "string" ? join31(replacement, currentDoc.split(`
|
|
31181
31181
|
`)) : currentDoc);
|
|
31182
31182
|
}
|
|
31183
31183
|
function canBreakFn(doc) {
|
|
@@ -31257,7 +31257,7 @@ function indentIfBreak(contents, options) {
|
|
|
31257
31257
|
negate: options.negate
|
|
31258
31258
|
};
|
|
31259
31259
|
}
|
|
31260
|
-
function
|
|
31260
|
+
function join31(separator, docs) {
|
|
31261
31261
|
assertDoc(separator);
|
|
31262
31262
|
assertDocArray(docs);
|
|
31263
31263
|
const parts = [];
|
|
@@ -31968,7 +31968,7 @@ var init_doc = __esm(() => {
|
|
|
31968
31968
|
MODE_FLAT = Symbol("MODE_FLAT");
|
|
31969
31969
|
DOC_FILL_PRINTED_LENGTH = Symbol("DOC_FILL_PRINTED_LENGTH");
|
|
31970
31970
|
builders = {
|
|
31971
|
-
join:
|
|
31971
|
+
join: join31,
|
|
31972
31972
|
line,
|
|
31973
31973
|
softline,
|
|
31974
31974
|
hardline,
|
|
@@ -39570,9 +39570,9 @@ function tm(e, t, r) {
|
|
|
39570
39570
|
return l(["<", r("name"), r("typeArguments"), " ", ...e.map(r, "attributes"), n.selfClosing ? " />" : ">"]);
|
|
39571
39571
|
let i = n.attributes?.some((u) => V3(u.value) && u.value.value.includes(`
|
|
39572
39572
|
`)), o = t.singleAttributePerLine && n.attributes.length > 1 ? E : A;
|
|
39573
|
-
return l(["<", r("name"), r("typeArguments"), m(e.map(() => [o, r()], "attributes")), ...
|
|
39573
|
+
return l(["<", r("name"), r("typeArguments"), m(e.map(() => [o, r()], "attributes")), ...rm3(n, t, s)], { shouldBreak: i });
|
|
39574
39574
|
}
|
|
39575
|
-
function
|
|
39575
|
+
function rm3(e, t, r) {
|
|
39576
39576
|
return e.selfClosing ? [A, "/>"] : nm(e, t, r) ? [">"] : [f, ">"];
|
|
39577
39577
|
}
|
|
39578
39578
|
function nm(e, t, r) {
|
|
@@ -111521,7 +111521,7 @@ function N62(e) {
|
|
|
111521
111521
|
function nm2(e, t, a) {
|
|
111522
111522
|
return ie10(t, a, e.typeParameters) || ie10(t, a, e.parameters) || S7(t, e.type);
|
|
111523
111523
|
}
|
|
111524
|
-
function
|
|
111524
|
+
function rm4(e, t, a) {
|
|
111525
111525
|
return ie10(t, a, e.types);
|
|
111526
111526
|
}
|
|
111527
111527
|
function im2(e, t, a) {
|
|
@@ -114489,7 +114489,7 @@ ${Me.join(`
|
|
|
114489
114489
|
return S7(a, t.elementType);
|
|
114490
114490
|
}, 190: function(t, a, _) {
|
|
114491
114491
|
return ie10(a, _, t.elements);
|
|
114492
|
-
}, 193:
|
|
114492
|
+
}, 193: rm4, 194: rm4, 195: function(t, a, _) {
|
|
114493
114493
|
return S7(a, t.checkType) || S7(a, t.extendsType) || S7(a, t.trueType) || S7(a, t.falseType);
|
|
114494
114494
|
}, 196: function(t, a, _) {
|
|
114495
114495
|
return S7(a, t.typeParameter);
|
|
@@ -119123,7 +119123,7 @@ import url22 from "url";
|
|
|
119123
119123
|
function diffLines(oldStr, newStr, options8) {
|
|
119124
119124
|
return lineDiff.diff(oldStr, newStr, options8);
|
|
119125
119125
|
}
|
|
119126
|
-
function
|
|
119126
|
+
function tokenize2(value, options8) {
|
|
119127
119127
|
if (options8.stripTrailingCr) {
|
|
119128
119128
|
value = value.replace(/\r\n/g, `
|
|
119129
119129
|
`);
|
|
@@ -120053,7 +120053,7 @@ function highlight(text) {
|
|
|
120053
120053
|
for (const {
|
|
120054
120054
|
type,
|
|
120055
120055
|
value
|
|
120056
|
-
} of
|
|
120056
|
+
} of tokenize22(text)) {
|
|
120057
120057
|
if (type in defs) {
|
|
120058
120058
|
highlighted += value.split(NEWLINE$1).map((str) => defs[type](str)).join(`
|
|
120059
120059
|
`);
|
|
@@ -124581,7 +124581,7 @@ var require2, __filename2, __dirname3, __create2, __defProp3, __getOwnPropDesc2,
|
|
|
124581
124581
|
return internalize({ "": root }, "", reviver);
|
|
124582
124582
|
}
|
|
124583
124583
|
return root;
|
|
124584
|
-
}, lexState, buffer, doubleQuote, sign, c7, lexStates, parseStates, dist_default, import_picocolors4, import_js_tokens, nonASCIIidentifierStartChars = "ªµºÀ-ÖØ-öø-ˁˆ-ˑˠ-ˤˬˮͰ-ʹͶͷͺ-ͽͿΆΈ-ΊΌΎ-ΡΣ-ϵϷ-ҁҊ-ԯԱ-Ֆՙՠ-ֈא-תׯ-ײؠ-يٮٯٱ-ۓەۥۦۮۯۺ-ۼۿܐܒ-ܯݍ-ޥޱߊ-ߪߴߵߺࠀ-ࠕࠚࠤࠨࡀ-ࡘࡠ-ࡪࡰ-ࢇࢉ-ࢠ-ࣉऄ-हऽॐक़-ॡॱ-ঀঅ-ঌএঐও-নপ-রলশ-হঽৎড়ঢ়য়-ৡৰৱৼਅ-ਊਏਐਓ-ਨਪ-ਰਲਲ਼ਵਸ਼ਸਹਖ਼-ੜਫ਼ੲ-ੴઅ-ઍએ-ઑઓ-નપ-રલળવ-હઽૐૠૡૹଅ-ଌଏଐଓ-ନପ-ରଲଳଵ-ହଽଡ଼ଢ଼ୟ-ୡୱஃஅ-ஊஎ-ஐஒ-கஙசஜஞடணதந-பம-ஹௐఅ-ఌఎ-ఐఒ-నప-హఽౘ-ౚౝౠౡಀಅ-ಌಎ-ಐಒ-ನಪ-ಳವ-ಹಽ-ೞೠೡೱೲഄ-ഌഎ-ഐഒ-ഺഽൎൔ-ൖൟ-ൡൺ-ൿඅ-ඖක-නඳ-රලව-ෆก-ะาำเ-ๆກຂຄຆ-ຊຌ-ຣລວ-ະາຳຽເ-ໄໆໜ-ໟༀཀ-ཇཉ-ཬྈ-ྌက-ဪဿၐ-ၕၚ-ၝၡၥၦၮ-ၰၵ-ႁႎႠ-ჅჇჍა-ჺჼ-ቈቊ-ቍቐ-ቖቘቚ-ቝበ-ኈኊ-ኍነ-ኰኲ-ኵኸ-ኾዀዂ-ዅወ-ዖዘ-ጐጒ-ጕጘ-ፚᎀ-ᎏᎠ-Ᏽᏸ-ᏽᐁ-ᙬᙯ-ᙿᚁ-ᚚᚠ-ᛪᛮ-ᛸᜀ-ᜑᜟ-ᜱᝀ-ᝑᝠ-ᝬᝮ-ᝰក-ឳៗៜᠠ-ᡸᢀ-ᢨᢪᢰ-ᣵᤀ-ᤞᥐ-ᥭᥰ-ᥴᦀ-ᦫᦰ-ᧉᨀ-ᨖᨠ-ᩔᪧᬅ-ᬳᭅ-ᭌᮃ-ᮠᮮᮯᮺ-ᯥᰀ-ᰣᱍ-ᱏᱚ-ᱽᲀ-Ა-ᲺᲽ-Ჿᳩ-ᳬᳮ-ᳳᳵᳶᳺᴀ-ᶿḀ-ἕἘ-Ἕἠ-ὅὈ-Ὅὐ-ὗὙὛὝὟ-ώᾀ-ᾴᾶ-ᾼιῂ-ῄῆ-ῌῐ-ΐῖ-Ίῠ-Ῥῲ-ῴῶ-ῼⁱⁿₐ-ₜℂℇℊ-ℓℕ℘-ℝℤΩℨK-ℹℼ-ℿⅅ-ⅉⅎⅠ-ↈⰀ-ⳤⳫ-ⳮⳲⳳⴀ-ⴥⴧⴭⴰ-ⵧⵯⶀ-ⶖⶠ-ⶦⶨ-ⶮⶰ-ⶶⶸ-ⶾⷀ-ⷆⷈ-ⷎⷐ-ⷖⷘ-ⷞ々-〇〡-〩〱-〵〸-〼ぁ-ゖ゛-ゟァ-ヺー-ヿㄅ-ㄯㄱ-ㆎㆠ-ㆿㇰ-ㇿ㐀-䶿一-ꒌꓐ-ꓽꔀ-ꘌꘐ-ꘟꘪꘫꙀ-ꙮꙿ-ꚝꚠ-ꛯꜗ-ꜟꜢ-ꞈꞋ--ꠁꠃ-ꠅꠇ-ꠊꠌ-ꠢꡀ-ꡳꢂ-ꢳꣲ-ꣷꣻꣽꣾꤊ-ꤥꤰ-ꥆꥠ-ꥼꦄ-ꦲꧏꧠ-ꧤꧦ-ꧯꧺ-ꧾꨀ-ꨨꩀ-ꩂꩄ-ꩋꩠ-ꩶꩺꩾ-ꪯꪱꪵꪶꪹ-ꪽꫀꫂꫛ-ꫝꫠ-ꫪꫲ-ꫴꬁ-ꬆꬉ-ꬎꬑ-ꬖꬠ-ꬦꬨ-ꬮꬰ-ꭚꭜ-ꭩꭰ-ꯢ가-힣ힰ-ퟆퟋ-ퟻ豈-舘並-龎ff-stﬓ-ﬗיִײַ-ﬨשׁ-זּטּ-לּמּנּסּףּפּצּ-ﮱﯓ-ﴽﵐ-ﶏﶒ-ﷇﷰ-ﷻﹰ-ﹴﹶ-ﻼA-Za-zヲ-하-ᅦᅧ-ᅬᅭ-ᅲᅳ-ᅵ", nonASCIIidentifierChars = "·̀-ͯ·҃-֑҇-ׇֽֿׁׂׅׄؐ-ًؚ-٩ٰۖ-ۜ۟-۪ۤۧۨ-ۭ۰-۹ܑܰ-݊ަ-ް߀-߉߫-߽߳ࠖ-࠙ࠛ-ࠣࠥ-ࠧࠩ-࡙࠭-࡛-࢟࣊-ࣣ࣡-ःऺ-़ा-ॏ॑-ॗॢॣ०-९ঁ-ঃ়া-ৄেৈো-্ৗৢৣ০-৯৾ਁ-ਃ਼ਾ-ੂੇੈੋ-੍ੑ੦-ੱੵઁ-ઃ઼ા-ૅે-ૉો-્ૢૣ૦-૯ૺ-૿ଁ-ଃ଼ା-ୄେୈୋ-୍୕-ୗୢୣ୦-୯ஂா-ூெ-ைொ-்ௗ௦-௯ఀ-ఄ఼ా-ౄె-ైొ-్ౕౖౢౣ౦-౯ಁ-ಃ಼ಾ-ೄೆ-ೈೊ-್ೕೖೢೣ೦-೯ೳഀ-ഃ഻഼ാ-ൄെ-ൈൊ-്ൗൢൣ൦-൯ඁ-ඃ්ා-ුූෘ-ෟ෦-෯ෲෳัิ-ฺ็-๎๐-๙ັິ-ຼ່-໎໐-໙༘༙༠-༩༹༵༷༾༿ཱ-྄྆྇ྍ-ྗྙ-ྼ࿆ါ-ှ၀-၉ၖ-ၙၞ-ၠၢ-ၤၧ-ၭၱ-ၴႂ-ႍႏ-ႝ፝-፟፩-፱ᜒ-᜕ᜲ-᜴ᝒᝓᝲᝳ឴-៓៝០-៩᠋-᠍᠏-᠙ᢩᤠ-ᤫᤰ-᤻᥆-᥏᧐-᧚ᨗ-ᨛᩕ-ᩞ᩠-᩿᩼-᪉᪐-᪙᪰-᪽ᪿ--ᬀ-ᬄ᬴-᭄᭐-᭙᭫-᭳ᮀ-ᮂᮡ-ᮭ᮰-᮹᯦-᯳ᰤ-᰷᱀-᱉᱐-᱙᳐-᳔᳒-᳨᳭᳴᳷-᳹᷀-᷿‿⁀⁔⃐-⃥⃜⃡-⃰⳯-⵿⳱ⷠ-〪ⷿ-゙゚〯・꘠-꘩꙯ꙴ-꙽ꚞꚟ꛰꛱ꠂ꠆ꠋꠣ-ꠧ꠬ꢀꢁꢴ-ꣅ꣐-꣙꣠-꣱ꣿ-꤉ꤦ-꤭ꥇ-꥓ꦀ-ꦃ꦳-꧀꧐-꧙ꧥ꧰-꧹ꨩ-ꨶꩃꩌꩍ꩐-꩙ꩻ-ꩽꪰꪲ-ꪴꪷꪸꪾ꪿꫁ꫫ-ꫯꫵ꫶ꯣ-ꯪ꯬꯭꯰-꯹ﬞ︀-️︠-︯︳︴﹍-﹏0-9_・", nonASCIIidentifierStart, nonASCIIidentifier, reservedWords, keywords, reservedWordsStrictSet, reservedWordsStrictBindSet, compose = (f, g) => (v) => f(g(v)), defsOn, defsOff, sometimesKeywords, NEWLINE$1, BRACKET,
|
|
124584
|
+
}, lexState, buffer, doubleQuote, sign, c7, lexStates, parseStates, dist_default, import_picocolors4, import_js_tokens, nonASCIIidentifierStartChars = "ªµºÀ-ÖØ-öø-ˁˆ-ˑˠ-ˤˬˮͰ-ʹͶͷͺ-ͽͿΆΈ-ΊΌΎ-ΡΣ-ϵϷ-ҁҊ-ԯԱ-Ֆՙՠ-ֈא-תׯ-ײؠ-يٮٯٱ-ۓەۥۦۮۯۺ-ۼۿܐܒ-ܯݍ-ޥޱߊ-ߪߴߵߺࠀ-ࠕࠚࠤࠨࡀ-ࡘࡠ-ࡪࡰ-ࢇࢉ-ࢠ-ࣉऄ-हऽॐक़-ॡॱ-ঀঅ-ঌএঐও-নপ-রলশ-হঽৎড়ঢ়য়-ৡৰৱৼਅ-ਊਏਐਓ-ਨਪ-ਰਲਲ਼ਵਸ਼ਸਹਖ਼-ੜਫ਼ੲ-ੴઅ-ઍએ-ઑઓ-નપ-રલળવ-હઽૐૠૡૹଅ-ଌଏଐଓ-ନପ-ରଲଳଵ-ହଽଡ଼ଢ଼ୟ-ୡୱஃஅ-ஊஎ-ஐஒ-கஙசஜஞடணதந-பம-ஹௐఅ-ఌఎ-ఐఒ-నప-హఽౘ-ౚౝౠౡಀಅ-ಌಎ-ಐಒ-ನಪ-ಳವ-ಹಽ-ೞೠೡೱೲഄ-ഌഎ-ഐഒ-ഺഽൎൔ-ൖൟ-ൡൺ-ൿඅ-ඖක-නඳ-රලව-ෆก-ะาำเ-ๆກຂຄຆ-ຊຌ-ຣລວ-ະາຳຽເ-ໄໆໜ-ໟༀཀ-ཇཉ-ཬྈ-ྌက-ဪဿၐ-ၕၚ-ၝၡၥၦၮ-ၰၵ-ႁႎႠ-ჅჇჍა-ჺჼ-ቈቊ-ቍቐ-ቖቘቚ-ቝበ-ኈኊ-ኍነ-ኰኲ-ኵኸ-ኾዀዂ-ዅወ-ዖዘ-ጐጒ-ጕጘ-ፚᎀ-ᎏᎠ-Ᏽᏸ-ᏽᐁ-ᙬᙯ-ᙿᚁ-ᚚᚠ-ᛪᛮ-ᛸᜀ-ᜑᜟ-ᜱᝀ-ᝑᝠ-ᝬᝮ-ᝰក-ឳៗៜᠠ-ᡸᢀ-ᢨᢪᢰ-ᣵᤀ-ᤞᥐ-ᥭᥰ-ᥴᦀ-ᦫᦰ-ᧉᨀ-ᨖᨠ-ᩔᪧᬅ-ᬳᭅ-ᭌᮃ-ᮠᮮᮯᮺ-ᯥᰀ-ᰣᱍ-ᱏᱚ-ᱽᲀ-Ა-ᲺᲽ-Ჿᳩ-ᳬᳮ-ᳳᳵᳶᳺᴀ-ᶿḀ-ἕἘ-Ἕἠ-ὅὈ-Ὅὐ-ὗὙὛὝὟ-ώᾀ-ᾴᾶ-ᾼιῂ-ῄῆ-ῌῐ-ΐῖ-Ίῠ-Ῥῲ-ῴῶ-ῼⁱⁿₐ-ₜℂℇℊ-ℓℕ℘-ℝℤΩℨK-ℹℼ-ℿⅅ-ⅉⅎⅠ-ↈⰀ-ⳤⳫ-ⳮⳲⳳⴀ-ⴥⴧⴭⴰ-ⵧⵯⶀ-ⶖⶠ-ⶦⶨ-ⶮⶰ-ⶶⶸ-ⶾⷀ-ⷆⷈ-ⷎⷐ-ⷖⷘ-ⷞ々-〇〡-〩〱-〵〸-〼ぁ-ゖ゛-ゟァ-ヺー-ヿㄅ-ㄯㄱ-ㆎㆠ-ㆿㇰ-ㇿ㐀-䶿一-ꒌꓐ-ꓽꔀ-ꘌꘐ-ꘟꘪꘫꙀ-ꙮꙿ-ꚝꚠ-ꛯꜗ-ꜟꜢ-ꞈꞋ--ꠁꠃ-ꠅꠇ-ꠊꠌ-ꠢꡀ-ꡳꢂ-ꢳꣲ-ꣷꣻꣽꣾꤊ-ꤥꤰ-ꥆꥠ-ꥼꦄ-ꦲꧏꧠ-ꧤꧦ-ꧯꧺ-ꧾꨀ-ꨨꩀ-ꩂꩄ-ꩋꩠ-ꩶꩺꩾ-ꪯꪱꪵꪶꪹ-ꪽꫀꫂꫛ-ꫝꫠ-ꫪꫲ-ꫴꬁ-ꬆꬉ-ꬎꬑ-ꬖꬠ-ꬦꬨ-ꬮꬰ-ꭚꭜ-ꭩꭰ-ꯢ가-힣ힰ-ퟆퟋ-ퟻ豈-舘並-龎ff-stﬓ-ﬗיִײַ-ﬨשׁ-זּטּ-לּמּנּסּףּפּצּ-ﮱﯓ-ﴽﵐ-ﶏﶒ-ﷇﷰ-ﷻﹰ-ﹴﹶ-ﻼA-Za-zヲ-하-ᅦᅧ-ᅬᅭ-ᅲᅳ-ᅵ", nonASCIIidentifierChars = "·̀-ͯ·҃-֑҇-ׇֽֿׁׂׅׄؐ-ًؚ-٩ٰۖ-ۜ۟-۪ۤۧۨ-ۭ۰-۹ܑܰ-݊ަ-ް߀-߉߫-߽߳ࠖ-࠙ࠛ-ࠣࠥ-ࠧࠩ-࡙࠭-࡛-࢟࣊-ࣣ࣡-ःऺ-़ा-ॏ॑-ॗॢॣ०-९ঁ-ঃ়া-ৄেৈো-্ৗৢৣ০-৯৾ਁ-ਃ਼ਾ-ੂੇੈੋ-੍ੑ੦-ੱੵઁ-ઃ઼ા-ૅે-ૉો-્ૢૣ૦-૯ૺ-૿ଁ-ଃ଼ା-ୄେୈୋ-୍୕-ୗୢୣ୦-୯ஂா-ூெ-ைொ-்ௗ௦-௯ఀ-ఄ఼ా-ౄె-ైొ-్ౕౖౢౣ౦-౯ಁ-ಃ಼ಾ-ೄೆ-ೈೊ-್ೕೖೢೣ೦-೯ೳഀ-ഃ഻഼ാ-ൄെ-ൈൊ-്ൗൢൣ൦-൯ඁ-ඃ්ා-ුූෘ-ෟ෦-෯ෲෳัิ-ฺ็-๎๐-๙ັິ-ຼ່-໎໐-໙༘༙༠-༩༹༵༷༾༿ཱ-྄྆྇ྍ-ྗྙ-ྼ࿆ါ-ှ၀-၉ၖ-ၙၞ-ၠၢ-ၤၧ-ၭၱ-ၴႂ-ႍႏ-ႝ፝-፟፩-፱ᜒ-᜕ᜲ-᜴ᝒᝓᝲᝳ឴-៓៝០-៩᠋-᠍᠏-᠙ᢩᤠ-ᤫᤰ-᤻᥆-᥏᧐-᧚ᨗ-ᨛᩕ-ᩞ᩠-᩿᩼-᪉᪐-᪙᪰-᪽ᪿ--ᬀ-ᬄ᬴-᭄᭐-᭙᭫-᭳ᮀ-ᮂᮡ-ᮭ᮰-᮹᯦-᯳ᰤ-᰷᱀-᱉᱐-᱙᳐-᳔᳒-᳨᳭᳴᳷-᳹᷀-᷿‿⁀⁔⃐-⃥⃜⃡-⃰⳯-⵿⳱ⷠ-〪ⷿ-゙゚〯・꘠-꘩꙯ꙴ-꙽ꚞꚟ꛰꛱ꠂ꠆ꠋꠣ-ꠧ꠬ꢀꢁꢴ-ꣅ꣐-꣙꣠-꣱ꣿ-꤉ꤦ-꤭ꥇ-꥓ꦀ-ꦃ꦳-꧀꧐-꧙ꧥ꧰-꧹ꨩ-ꨶꩃꩌꩍ꩐-꩙ꩻ-ꩽꪰꪲ-ꪴꪷꪸꪾ꪿꫁ꫫ-ꫯꫵ꫶ꯣ-ꯪ꯬꯭꯰-꯹ﬞ︀-️︠-︯︳︴﹍-﹏0-9_・", nonASCIIidentifierStart, nonASCIIidentifier, reservedWords, keywords, reservedWordsStrictSet, reservedWordsStrictBindSet, compose = (f, g) => (v) => f(g(v)), defsOn, defsOff, sometimesKeywords, NEWLINE$1, BRACKET, tokenize22, NEWLINE, getOffsets = ({
|
|
124585
124585
|
oneBased,
|
|
124586
124586
|
oneBasedLine = oneBased,
|
|
124587
124587
|
oneBasedColumn = oneBased
|
|
@@ -124807,7 +124807,7 @@ var require2, __filename2, __dirname3, __create2, __defProp3, __getOwnPropDesc2,
|
|
|
124807
124807
|
}
|
|
124808
124808
|
}
|
|
124809
124809
|
}, ast_path_default, is_object_default, skipWhitespace, skipSpaces, skipToLineEnd, skipEverythingButNewLine, isNewlineCharacter = (character) => character === `
|
|
124810
|
-
` || character === "\r" || character === "\u2028" || character === "\u2029", skip_newline_default, has_newline_default, is_non_empty_array_default, get_sorted_child_nodes_default, childNodesCache, returnFalse = () => false, isAllEmptyAndNoLineBreak = (text) => !/[\S\n\u2028\u2029]/u.test(text), is_previous_line_empty_default, breakParent2, hardline2, indent2,
|
|
124810
|
+
` || character === "\r" || character === "\u2028" || character === "\u2029", skip_newline_default, has_newline_default, is_non_empty_array_default, get_sorted_child_nodes_default, childNodesCache, returnFalse = () => false, isAllEmptyAndNoLineBreak = (text) => !/[\S\n\u2028\u2029]/u.test(text), is_previous_line_empty_default, breakParent2, hardline2, indent2, join33, line22, lineSuffix2, create_print_pre_check_function_default = () => noop_default2, core_options_evaluate_default, arrayToReversed, toReversed, method_to_reversed_default, import_n_readlines, get_interpreter_default, getFileBasename = (file) => {
|
|
124811
124811
|
try {
|
|
124812
124812
|
return path112.basename(toPath3(file));
|
|
124813
124813
|
} catch {
|
|
@@ -133471,7 +133471,7 @@ globstar while`, file, fr, pattern, pr, swallowee);
|
|
|
133471
133471
|
LineDiff = class extends Diff {
|
|
133472
133472
|
constructor() {
|
|
133473
133473
|
super(...arguments);
|
|
133474
|
-
this.tokenize =
|
|
133474
|
+
this.tokenize = tokenize2;
|
|
133475
133475
|
}
|
|
133476
133476
|
equals(left, right, options8) {
|
|
133477
133477
|
if (options8.ignoreWhitespace) {
|
|
@@ -134348,7 +134348,7 @@ globstar while`, file, fr, pattern, pr, swallowee);
|
|
|
134348
134348
|
return "uncolored";
|
|
134349
134349
|
}
|
|
134350
134350
|
};
|
|
134351
|
-
|
|
134351
|
+
tokenize22 = function* (text) {
|
|
134352
134352
|
for (const token2 of (0, import_js_tokens.default)(text, {
|
|
134353
134353
|
jsx: true
|
|
134354
134354
|
})) {
|
|
@@ -134836,7 +134836,7 @@ ${codeblock}`, options8);
|
|
|
134836
134836
|
breakParent: breakParent2,
|
|
134837
134837
|
hardline: hardline2,
|
|
134838
134838
|
indent: indent2,
|
|
134839
|
-
join:
|
|
134839
|
+
join: join33,
|
|
134840
134840
|
line: line22,
|
|
134841
134841
|
lineSuffix: lineSuffix2
|
|
134842
134842
|
} = builders);
|
|
@@ -228838,7 +228838,7 @@ function normalizeBase44Env() {
|
|
|
228838
228838
|
loadProjectEnvFiles();
|
|
228839
228839
|
|
|
228840
228840
|
// src/cli/index.ts
|
|
228841
|
-
import { dirname as dirname30, join as
|
|
228841
|
+
import { dirname as dirname30, join as join41 } from "node:path";
|
|
228842
228842
|
import { fileURLToPath as fileURLToPath7 } from "node:url";
|
|
228843
228843
|
|
|
228844
228844
|
// ../../node_modules/@clack/core/dist/index.mjs
|
|
@@ -239451,6 +239451,7 @@ var package_default = {
|
|
|
239451
239451
|
jsonwebtoken: "^9.0.3",
|
|
239452
239452
|
ky: "^1.14.2",
|
|
239453
239453
|
lodash: "^4.17.23",
|
|
239454
|
+
minisearch: "^7.1.2",
|
|
239454
239455
|
ms: "^2.1.3",
|
|
239455
239456
|
multer: "^2.0.0",
|
|
239456
239457
|
nanoid: "^5.1.6",
|
|
@@ -247587,8 +247588,8 @@ function normalizeDatetime(value) {
|
|
|
247587
247588
|
return `${value}Z`;
|
|
247588
247589
|
}
|
|
247589
247590
|
// src/cli/utils/json.ts
|
|
247590
|
-
function toJsonStdout(result) {
|
|
247591
|
-
return `${JSON.stringify(result, null, 2)}
|
|
247591
|
+
function toJsonStdout(result, options = {}) {
|
|
247592
|
+
return `${JSON.stringify(result, null, options.compact ? undefined : 2)}
|
|
247592
247593
|
`;
|
|
247593
247594
|
}
|
|
247594
247595
|
// src/cli/errors.ts
|
|
@@ -248042,13 +248043,1873 @@ function getAgentsCommand() {
|
|
|
248042
248043
|
return new Command2("agents").description("Manage project agents").addCommand(getAgentsPushCommand()).addCommand(getAgentsPullCommand());
|
|
248043
248044
|
}
|
|
248044
248045
|
|
|
248046
|
+
// ../../node_modules/minisearch/dist/es/index.js
|
|
248047
|
+
var ENTRIES = "ENTRIES";
|
|
248048
|
+
var KEYS = "KEYS";
|
|
248049
|
+
var VALUES = "VALUES";
|
|
248050
|
+
var LEAF = "";
|
|
248051
|
+
|
|
248052
|
+
class TreeIterator {
|
|
248053
|
+
constructor(set, type) {
|
|
248054
|
+
const node = set._tree;
|
|
248055
|
+
const keys = Array.from(node.keys());
|
|
248056
|
+
this.set = set;
|
|
248057
|
+
this._type = type;
|
|
248058
|
+
this._path = keys.length > 0 ? [{ node, keys }] : [];
|
|
248059
|
+
}
|
|
248060
|
+
next() {
|
|
248061
|
+
const value = this.dive();
|
|
248062
|
+
this.backtrack();
|
|
248063
|
+
return value;
|
|
248064
|
+
}
|
|
248065
|
+
dive() {
|
|
248066
|
+
if (this._path.length === 0) {
|
|
248067
|
+
return { done: true, value: undefined };
|
|
248068
|
+
}
|
|
248069
|
+
const { node, keys } = last$1(this._path);
|
|
248070
|
+
if (last$1(keys) === LEAF) {
|
|
248071
|
+
return { done: false, value: this.result() };
|
|
248072
|
+
}
|
|
248073
|
+
const child = node.get(last$1(keys));
|
|
248074
|
+
this._path.push({ node: child, keys: Array.from(child.keys()) });
|
|
248075
|
+
return this.dive();
|
|
248076
|
+
}
|
|
248077
|
+
backtrack() {
|
|
248078
|
+
if (this._path.length === 0) {
|
|
248079
|
+
return;
|
|
248080
|
+
}
|
|
248081
|
+
const keys = last$1(this._path).keys;
|
|
248082
|
+
keys.pop();
|
|
248083
|
+
if (keys.length > 0) {
|
|
248084
|
+
return;
|
|
248085
|
+
}
|
|
248086
|
+
this._path.pop();
|
|
248087
|
+
this.backtrack();
|
|
248088
|
+
}
|
|
248089
|
+
key() {
|
|
248090
|
+
return this.set._prefix + this._path.map(({ keys }) => last$1(keys)).filter((key) => key !== LEAF).join("");
|
|
248091
|
+
}
|
|
248092
|
+
value() {
|
|
248093
|
+
return last$1(this._path).node.get(LEAF);
|
|
248094
|
+
}
|
|
248095
|
+
result() {
|
|
248096
|
+
switch (this._type) {
|
|
248097
|
+
case VALUES:
|
|
248098
|
+
return this.value();
|
|
248099
|
+
case KEYS:
|
|
248100
|
+
return this.key();
|
|
248101
|
+
default:
|
|
248102
|
+
return [this.key(), this.value()];
|
|
248103
|
+
}
|
|
248104
|
+
}
|
|
248105
|
+
[Symbol.iterator]() {
|
|
248106
|
+
return this;
|
|
248107
|
+
}
|
|
248108
|
+
}
|
|
248109
|
+
var last$1 = (array) => {
|
|
248110
|
+
return array[array.length - 1];
|
|
248111
|
+
};
|
|
248112
|
+
var fuzzySearch = (node, query, maxDistance) => {
|
|
248113
|
+
const results = new Map;
|
|
248114
|
+
if (query === undefined)
|
|
248115
|
+
return results;
|
|
248116
|
+
const n = query.length + 1;
|
|
248117
|
+
const m = n + maxDistance;
|
|
248118
|
+
const matrix = new Uint8Array(m * n).fill(maxDistance + 1);
|
|
248119
|
+
for (let j = 0;j < n; ++j)
|
|
248120
|
+
matrix[j] = j;
|
|
248121
|
+
for (let i = 1;i < m; ++i)
|
|
248122
|
+
matrix[i * n] = i;
|
|
248123
|
+
recurse(node, query, maxDistance, results, matrix, 1, n, "");
|
|
248124
|
+
return results;
|
|
248125
|
+
};
|
|
248126
|
+
var recurse = (node, query, maxDistance, results, matrix, m, n, prefix) => {
|
|
248127
|
+
const offset = m * n;
|
|
248128
|
+
key:
|
|
248129
|
+
for (const key of node.keys()) {
|
|
248130
|
+
if (key === LEAF) {
|
|
248131
|
+
const distance = matrix[offset - 1];
|
|
248132
|
+
if (distance <= maxDistance) {
|
|
248133
|
+
results.set(prefix, [node.get(key), distance]);
|
|
248134
|
+
}
|
|
248135
|
+
} else {
|
|
248136
|
+
let i = m;
|
|
248137
|
+
for (let pos = 0;pos < key.length; ++pos, ++i) {
|
|
248138
|
+
const char = key[pos];
|
|
248139
|
+
const thisRowOffset = n * i;
|
|
248140
|
+
const prevRowOffset = thisRowOffset - n;
|
|
248141
|
+
let minDistance = matrix[thisRowOffset];
|
|
248142
|
+
const jmin = Math.max(0, i - maxDistance - 1);
|
|
248143
|
+
const jmax = Math.min(n - 1, i + maxDistance);
|
|
248144
|
+
for (let j = jmin;j < jmax; ++j) {
|
|
248145
|
+
const different = char !== query[j];
|
|
248146
|
+
const rpl = matrix[prevRowOffset + j] + +different;
|
|
248147
|
+
const del = matrix[prevRowOffset + j + 1] + 1;
|
|
248148
|
+
const ins = matrix[thisRowOffset + j] + 1;
|
|
248149
|
+
const dist = matrix[thisRowOffset + j + 1] = Math.min(rpl, del, ins);
|
|
248150
|
+
if (dist < minDistance)
|
|
248151
|
+
minDistance = dist;
|
|
248152
|
+
}
|
|
248153
|
+
if (minDistance > maxDistance) {
|
|
248154
|
+
continue key;
|
|
248155
|
+
}
|
|
248156
|
+
}
|
|
248157
|
+
recurse(node.get(key), query, maxDistance, results, matrix, i, n, prefix + key);
|
|
248158
|
+
}
|
|
248159
|
+
}
|
|
248160
|
+
};
|
|
248161
|
+
|
|
248162
|
+
class SearchableMap {
|
|
248163
|
+
constructor(tree = new Map, prefix = "") {
|
|
248164
|
+
this._size = undefined;
|
|
248165
|
+
this._tree = tree;
|
|
248166
|
+
this._prefix = prefix;
|
|
248167
|
+
}
|
|
248168
|
+
atPrefix(prefix) {
|
|
248169
|
+
if (!prefix.startsWith(this._prefix)) {
|
|
248170
|
+
throw new Error("Mismatched prefix");
|
|
248171
|
+
}
|
|
248172
|
+
const [node, path] = trackDown(this._tree, prefix.slice(this._prefix.length));
|
|
248173
|
+
if (node === undefined) {
|
|
248174
|
+
const [parentNode, key] = last(path);
|
|
248175
|
+
for (const k of parentNode.keys()) {
|
|
248176
|
+
if (k !== LEAF && k.startsWith(key)) {
|
|
248177
|
+
const node = new Map;
|
|
248178
|
+
node.set(k.slice(key.length), parentNode.get(k));
|
|
248179
|
+
return new SearchableMap(node, prefix);
|
|
248180
|
+
}
|
|
248181
|
+
}
|
|
248182
|
+
}
|
|
248183
|
+
return new SearchableMap(node, prefix);
|
|
248184
|
+
}
|
|
248185
|
+
clear() {
|
|
248186
|
+
this._size = undefined;
|
|
248187
|
+
this._tree.clear();
|
|
248188
|
+
}
|
|
248189
|
+
delete(key) {
|
|
248190
|
+
this._size = undefined;
|
|
248191
|
+
return remove(this._tree, key);
|
|
248192
|
+
}
|
|
248193
|
+
entries() {
|
|
248194
|
+
return new TreeIterator(this, ENTRIES);
|
|
248195
|
+
}
|
|
248196
|
+
forEach(fn) {
|
|
248197
|
+
for (const [key, value] of this) {
|
|
248198
|
+
fn(key, value, this);
|
|
248199
|
+
}
|
|
248200
|
+
}
|
|
248201
|
+
fuzzyGet(key, maxEditDistance) {
|
|
248202
|
+
return fuzzySearch(this._tree, key, maxEditDistance);
|
|
248203
|
+
}
|
|
248204
|
+
get(key) {
|
|
248205
|
+
const node = lookup(this._tree, key);
|
|
248206
|
+
return node !== undefined ? node.get(LEAF) : undefined;
|
|
248207
|
+
}
|
|
248208
|
+
has(key) {
|
|
248209
|
+
const node = lookup(this._tree, key);
|
|
248210
|
+
return node !== undefined && node.has(LEAF);
|
|
248211
|
+
}
|
|
248212
|
+
keys() {
|
|
248213
|
+
return new TreeIterator(this, KEYS);
|
|
248214
|
+
}
|
|
248215
|
+
set(key, value) {
|
|
248216
|
+
if (typeof key !== "string") {
|
|
248217
|
+
throw new Error("key must be a string");
|
|
248218
|
+
}
|
|
248219
|
+
this._size = undefined;
|
|
248220
|
+
const node = createPath(this._tree, key);
|
|
248221
|
+
node.set(LEAF, value);
|
|
248222
|
+
return this;
|
|
248223
|
+
}
|
|
248224
|
+
get size() {
|
|
248225
|
+
if (this._size) {
|
|
248226
|
+
return this._size;
|
|
248227
|
+
}
|
|
248228
|
+
this._size = 0;
|
|
248229
|
+
const iter = this.entries();
|
|
248230
|
+
while (!iter.next().done)
|
|
248231
|
+
this._size += 1;
|
|
248232
|
+
return this._size;
|
|
248233
|
+
}
|
|
248234
|
+
update(key, fn) {
|
|
248235
|
+
if (typeof key !== "string") {
|
|
248236
|
+
throw new Error("key must be a string");
|
|
248237
|
+
}
|
|
248238
|
+
this._size = undefined;
|
|
248239
|
+
const node = createPath(this._tree, key);
|
|
248240
|
+
node.set(LEAF, fn(node.get(LEAF)));
|
|
248241
|
+
return this;
|
|
248242
|
+
}
|
|
248243
|
+
fetch(key, initial) {
|
|
248244
|
+
if (typeof key !== "string") {
|
|
248245
|
+
throw new Error("key must be a string");
|
|
248246
|
+
}
|
|
248247
|
+
this._size = undefined;
|
|
248248
|
+
const node = createPath(this._tree, key);
|
|
248249
|
+
let value = node.get(LEAF);
|
|
248250
|
+
if (value === undefined) {
|
|
248251
|
+
node.set(LEAF, value = initial());
|
|
248252
|
+
}
|
|
248253
|
+
return value;
|
|
248254
|
+
}
|
|
248255
|
+
values() {
|
|
248256
|
+
return new TreeIterator(this, VALUES);
|
|
248257
|
+
}
|
|
248258
|
+
[Symbol.iterator]() {
|
|
248259
|
+
return this.entries();
|
|
248260
|
+
}
|
|
248261
|
+
static from(entries) {
|
|
248262
|
+
const tree = new SearchableMap;
|
|
248263
|
+
for (const [key, value] of entries) {
|
|
248264
|
+
tree.set(key, value);
|
|
248265
|
+
}
|
|
248266
|
+
return tree;
|
|
248267
|
+
}
|
|
248268
|
+
static fromObject(object) {
|
|
248269
|
+
return SearchableMap.from(Object.entries(object));
|
|
248270
|
+
}
|
|
248271
|
+
}
|
|
248272
|
+
var trackDown = (tree, key, path = []) => {
|
|
248273
|
+
if (key.length === 0 || tree == null) {
|
|
248274
|
+
return [tree, path];
|
|
248275
|
+
}
|
|
248276
|
+
for (const k of tree.keys()) {
|
|
248277
|
+
if (k !== LEAF && key.startsWith(k)) {
|
|
248278
|
+
path.push([tree, k]);
|
|
248279
|
+
return trackDown(tree.get(k), key.slice(k.length), path);
|
|
248280
|
+
}
|
|
248281
|
+
}
|
|
248282
|
+
path.push([tree, key]);
|
|
248283
|
+
return trackDown(undefined, "", path);
|
|
248284
|
+
};
|
|
248285
|
+
var lookup = (tree, key) => {
|
|
248286
|
+
if (key.length === 0 || tree == null) {
|
|
248287
|
+
return tree;
|
|
248288
|
+
}
|
|
248289
|
+
for (const k of tree.keys()) {
|
|
248290
|
+
if (k !== LEAF && key.startsWith(k)) {
|
|
248291
|
+
return lookup(tree.get(k), key.slice(k.length));
|
|
248292
|
+
}
|
|
248293
|
+
}
|
|
248294
|
+
};
|
|
248295
|
+
var createPath = (node, key) => {
|
|
248296
|
+
const keyLength = key.length;
|
|
248297
|
+
outer:
|
|
248298
|
+
for (let pos = 0;node && pos < keyLength; ) {
|
|
248299
|
+
for (const k of node.keys()) {
|
|
248300
|
+
if (k !== LEAF && key[pos] === k[0]) {
|
|
248301
|
+
const len = Math.min(keyLength - pos, k.length);
|
|
248302
|
+
let offset = 1;
|
|
248303
|
+
while (offset < len && key[pos + offset] === k[offset])
|
|
248304
|
+
++offset;
|
|
248305
|
+
const child = node.get(k);
|
|
248306
|
+
if (offset === k.length) {
|
|
248307
|
+
node = child;
|
|
248308
|
+
} else {
|
|
248309
|
+
const intermediate = new Map;
|
|
248310
|
+
intermediate.set(k.slice(offset), child);
|
|
248311
|
+
node.set(key.slice(pos, pos + offset), intermediate);
|
|
248312
|
+
node.delete(k);
|
|
248313
|
+
node = intermediate;
|
|
248314
|
+
}
|
|
248315
|
+
pos += offset;
|
|
248316
|
+
continue outer;
|
|
248317
|
+
}
|
|
248318
|
+
}
|
|
248319
|
+
const child = new Map;
|
|
248320
|
+
node.set(key.slice(pos), child);
|
|
248321
|
+
return child;
|
|
248322
|
+
}
|
|
248323
|
+
return node;
|
|
248324
|
+
};
|
|
248325
|
+
var remove = (tree, key) => {
|
|
248326
|
+
const [node, path] = trackDown(tree, key);
|
|
248327
|
+
if (node === undefined) {
|
|
248328
|
+
return;
|
|
248329
|
+
}
|
|
248330
|
+
node.delete(LEAF);
|
|
248331
|
+
if (node.size === 0) {
|
|
248332
|
+
cleanup(path);
|
|
248333
|
+
} else if (node.size === 1) {
|
|
248334
|
+
const [key, value] = node.entries().next().value;
|
|
248335
|
+
merge3(path, key, value);
|
|
248336
|
+
}
|
|
248337
|
+
};
|
|
248338
|
+
var cleanup = (path) => {
|
|
248339
|
+
if (path.length === 0) {
|
|
248340
|
+
return;
|
|
248341
|
+
}
|
|
248342
|
+
const [node, key] = last(path);
|
|
248343
|
+
node.delete(key);
|
|
248344
|
+
if (node.size === 0) {
|
|
248345
|
+
cleanup(path.slice(0, -1));
|
|
248346
|
+
} else if (node.size === 1) {
|
|
248347
|
+
const [key, value] = node.entries().next().value;
|
|
248348
|
+
if (key !== LEAF) {
|
|
248349
|
+
merge3(path.slice(0, -1), key, value);
|
|
248350
|
+
}
|
|
248351
|
+
}
|
|
248352
|
+
};
|
|
248353
|
+
var merge3 = (path, key, value) => {
|
|
248354
|
+
if (path.length === 0) {
|
|
248355
|
+
return;
|
|
248356
|
+
}
|
|
248357
|
+
const [node, nodeKey] = last(path);
|
|
248358
|
+
node.set(nodeKey + key, value);
|
|
248359
|
+
node.delete(nodeKey);
|
|
248360
|
+
};
|
|
248361
|
+
var last = (array) => {
|
|
248362
|
+
return array[array.length - 1];
|
|
248363
|
+
};
|
|
248364
|
+
var OR = "or";
|
|
248365
|
+
var AND = "and";
|
|
248366
|
+
var AND_NOT = "and_not";
|
|
248367
|
+
|
|
248368
|
+
class MiniSearch {
|
|
248369
|
+
constructor(options) {
|
|
248370
|
+
if ((options === null || options === undefined ? undefined : options.fields) == null) {
|
|
248371
|
+
throw new Error('MiniSearch: option "fields" must be provided');
|
|
248372
|
+
}
|
|
248373
|
+
const autoVacuum = options.autoVacuum == null || options.autoVacuum === true ? defaultAutoVacuumOptions : options.autoVacuum;
|
|
248374
|
+
this._options = {
|
|
248375
|
+
...defaultOptions,
|
|
248376
|
+
...options,
|
|
248377
|
+
autoVacuum,
|
|
248378
|
+
searchOptions: { ...defaultSearchOptions, ...options.searchOptions || {} },
|
|
248379
|
+
autoSuggestOptions: { ...defaultAutoSuggestOptions, ...options.autoSuggestOptions || {} }
|
|
248380
|
+
};
|
|
248381
|
+
this._index = new SearchableMap;
|
|
248382
|
+
this._documentCount = 0;
|
|
248383
|
+
this._documentIds = new Map;
|
|
248384
|
+
this._idToShortId = new Map;
|
|
248385
|
+
this._fieldIds = {};
|
|
248386
|
+
this._fieldLength = new Map;
|
|
248387
|
+
this._avgFieldLength = [];
|
|
248388
|
+
this._nextId = 0;
|
|
248389
|
+
this._storedFields = new Map;
|
|
248390
|
+
this._dirtCount = 0;
|
|
248391
|
+
this._currentVacuum = null;
|
|
248392
|
+
this._enqueuedVacuum = null;
|
|
248393
|
+
this._enqueuedVacuumConditions = defaultVacuumConditions;
|
|
248394
|
+
this.addFields(this._options.fields);
|
|
248395
|
+
}
|
|
248396
|
+
add(document2) {
|
|
248397
|
+
const { extractField, tokenize, processTerm, fields, idField } = this._options;
|
|
248398
|
+
const id = extractField(document2, idField);
|
|
248399
|
+
if (id == null) {
|
|
248400
|
+
throw new Error(`MiniSearch: document does not have ID field "${idField}"`);
|
|
248401
|
+
}
|
|
248402
|
+
if (this._idToShortId.has(id)) {
|
|
248403
|
+
throw new Error(`MiniSearch: duplicate ID ${id}`);
|
|
248404
|
+
}
|
|
248405
|
+
const shortDocumentId = this.addDocumentId(id);
|
|
248406
|
+
this.saveStoredFields(shortDocumentId, document2);
|
|
248407
|
+
for (const field of fields) {
|
|
248408
|
+
const fieldValue = extractField(document2, field);
|
|
248409
|
+
if (fieldValue == null)
|
|
248410
|
+
continue;
|
|
248411
|
+
const tokens = tokenize(fieldValue.toString(), field);
|
|
248412
|
+
const fieldId = this._fieldIds[field];
|
|
248413
|
+
const uniqueTerms = new Set(tokens).size;
|
|
248414
|
+
this.addFieldLength(shortDocumentId, fieldId, this._documentCount - 1, uniqueTerms);
|
|
248415
|
+
for (const term of tokens) {
|
|
248416
|
+
const processedTerm = processTerm(term, field);
|
|
248417
|
+
if (Array.isArray(processedTerm)) {
|
|
248418
|
+
for (const t of processedTerm) {
|
|
248419
|
+
this.addTerm(fieldId, shortDocumentId, t);
|
|
248420
|
+
}
|
|
248421
|
+
} else if (processedTerm) {
|
|
248422
|
+
this.addTerm(fieldId, shortDocumentId, processedTerm);
|
|
248423
|
+
}
|
|
248424
|
+
}
|
|
248425
|
+
}
|
|
248426
|
+
}
|
|
248427
|
+
addAll(documents) {
|
|
248428
|
+
for (const document2 of documents)
|
|
248429
|
+
this.add(document2);
|
|
248430
|
+
}
|
|
248431
|
+
addAllAsync(documents, options = {}) {
|
|
248432
|
+
const { chunkSize = 10 } = options;
|
|
248433
|
+
const acc = { chunk: [], promise: Promise.resolve() };
|
|
248434
|
+
const { chunk, promise } = documents.reduce(({ chunk, promise }, document2, i) => {
|
|
248435
|
+
chunk.push(document2);
|
|
248436
|
+
if ((i + 1) % chunkSize === 0) {
|
|
248437
|
+
return {
|
|
248438
|
+
chunk: [],
|
|
248439
|
+
promise: promise.then(() => new Promise((resolve) => setTimeout(resolve, 0))).then(() => this.addAll(chunk))
|
|
248440
|
+
};
|
|
248441
|
+
} else {
|
|
248442
|
+
return { chunk, promise };
|
|
248443
|
+
}
|
|
248444
|
+
}, acc);
|
|
248445
|
+
return promise.then(() => this.addAll(chunk));
|
|
248446
|
+
}
|
|
248447
|
+
remove(document2) {
|
|
248448
|
+
const { tokenize, processTerm, extractField, fields, idField } = this._options;
|
|
248449
|
+
const id = extractField(document2, idField);
|
|
248450
|
+
if (id == null) {
|
|
248451
|
+
throw new Error(`MiniSearch: document does not have ID field "${idField}"`);
|
|
248452
|
+
}
|
|
248453
|
+
const shortId = this._idToShortId.get(id);
|
|
248454
|
+
if (shortId == null) {
|
|
248455
|
+
throw new Error(`MiniSearch: cannot remove document with ID ${id}: it is not in the index`);
|
|
248456
|
+
}
|
|
248457
|
+
for (const field of fields) {
|
|
248458
|
+
const fieldValue = extractField(document2, field);
|
|
248459
|
+
if (fieldValue == null)
|
|
248460
|
+
continue;
|
|
248461
|
+
const tokens = tokenize(fieldValue.toString(), field);
|
|
248462
|
+
const fieldId = this._fieldIds[field];
|
|
248463
|
+
const uniqueTerms = new Set(tokens).size;
|
|
248464
|
+
this.removeFieldLength(shortId, fieldId, this._documentCount, uniqueTerms);
|
|
248465
|
+
for (const term of tokens) {
|
|
248466
|
+
const processedTerm = processTerm(term, field);
|
|
248467
|
+
if (Array.isArray(processedTerm)) {
|
|
248468
|
+
for (const t of processedTerm) {
|
|
248469
|
+
this.removeTerm(fieldId, shortId, t);
|
|
248470
|
+
}
|
|
248471
|
+
} else if (processedTerm) {
|
|
248472
|
+
this.removeTerm(fieldId, shortId, processedTerm);
|
|
248473
|
+
}
|
|
248474
|
+
}
|
|
248475
|
+
}
|
|
248476
|
+
this._storedFields.delete(shortId);
|
|
248477
|
+
this._documentIds.delete(shortId);
|
|
248478
|
+
this._idToShortId.delete(id);
|
|
248479
|
+
this._fieldLength.delete(shortId);
|
|
248480
|
+
this._documentCount -= 1;
|
|
248481
|
+
}
|
|
248482
|
+
removeAll(documents) {
|
|
248483
|
+
if (documents) {
|
|
248484
|
+
for (const document2 of documents)
|
|
248485
|
+
this.remove(document2);
|
|
248486
|
+
} else if (arguments.length > 0) {
|
|
248487
|
+
throw new Error("Expected documents to be present. Omit the argument to remove all documents.");
|
|
248488
|
+
} else {
|
|
248489
|
+
this._index = new SearchableMap;
|
|
248490
|
+
this._documentCount = 0;
|
|
248491
|
+
this._documentIds = new Map;
|
|
248492
|
+
this._idToShortId = new Map;
|
|
248493
|
+
this._fieldLength = new Map;
|
|
248494
|
+
this._avgFieldLength = [];
|
|
248495
|
+
this._storedFields = new Map;
|
|
248496
|
+
this._nextId = 0;
|
|
248497
|
+
}
|
|
248498
|
+
}
|
|
248499
|
+
discard(id) {
|
|
248500
|
+
const shortId = this._idToShortId.get(id);
|
|
248501
|
+
if (shortId == null) {
|
|
248502
|
+
throw new Error(`MiniSearch: cannot discard document with ID ${id}: it is not in the index`);
|
|
248503
|
+
}
|
|
248504
|
+
this._idToShortId.delete(id);
|
|
248505
|
+
this._documentIds.delete(shortId);
|
|
248506
|
+
this._storedFields.delete(shortId);
|
|
248507
|
+
(this._fieldLength.get(shortId) || []).forEach((fieldLength, fieldId) => {
|
|
248508
|
+
this.removeFieldLength(shortId, fieldId, this._documentCount, fieldLength);
|
|
248509
|
+
});
|
|
248510
|
+
this._fieldLength.delete(shortId);
|
|
248511
|
+
this._documentCount -= 1;
|
|
248512
|
+
this._dirtCount += 1;
|
|
248513
|
+
this.maybeAutoVacuum();
|
|
248514
|
+
}
|
|
248515
|
+
maybeAutoVacuum() {
|
|
248516
|
+
if (this._options.autoVacuum === false) {
|
|
248517
|
+
return;
|
|
248518
|
+
}
|
|
248519
|
+
const { minDirtFactor, minDirtCount, batchSize, batchWait } = this._options.autoVacuum;
|
|
248520
|
+
this.conditionalVacuum({ batchSize, batchWait }, { minDirtCount, minDirtFactor });
|
|
248521
|
+
}
|
|
248522
|
+
discardAll(ids) {
|
|
248523
|
+
const autoVacuum = this._options.autoVacuum;
|
|
248524
|
+
try {
|
|
248525
|
+
this._options.autoVacuum = false;
|
|
248526
|
+
for (const id of ids) {
|
|
248527
|
+
this.discard(id);
|
|
248528
|
+
}
|
|
248529
|
+
} finally {
|
|
248530
|
+
this._options.autoVacuum = autoVacuum;
|
|
248531
|
+
}
|
|
248532
|
+
this.maybeAutoVacuum();
|
|
248533
|
+
}
|
|
248534
|
+
replace(updatedDocument) {
|
|
248535
|
+
const { idField, extractField } = this._options;
|
|
248536
|
+
const id = extractField(updatedDocument, idField);
|
|
248537
|
+
this.discard(id);
|
|
248538
|
+
this.add(updatedDocument);
|
|
248539
|
+
}
|
|
248540
|
+
vacuum(options = {}) {
|
|
248541
|
+
return this.conditionalVacuum(options);
|
|
248542
|
+
}
|
|
248543
|
+
conditionalVacuum(options, conditions) {
|
|
248544
|
+
if (this._currentVacuum) {
|
|
248545
|
+
this._enqueuedVacuumConditions = this._enqueuedVacuumConditions && conditions;
|
|
248546
|
+
if (this._enqueuedVacuum != null) {
|
|
248547
|
+
return this._enqueuedVacuum;
|
|
248548
|
+
}
|
|
248549
|
+
this._enqueuedVacuum = this._currentVacuum.then(() => {
|
|
248550
|
+
const conditions = this._enqueuedVacuumConditions;
|
|
248551
|
+
this._enqueuedVacuumConditions = defaultVacuumConditions;
|
|
248552
|
+
return this.performVacuuming(options, conditions);
|
|
248553
|
+
});
|
|
248554
|
+
return this._enqueuedVacuum;
|
|
248555
|
+
}
|
|
248556
|
+
if (this.vacuumConditionsMet(conditions) === false) {
|
|
248557
|
+
return Promise.resolve();
|
|
248558
|
+
}
|
|
248559
|
+
this._currentVacuum = this.performVacuuming(options);
|
|
248560
|
+
return this._currentVacuum;
|
|
248561
|
+
}
|
|
248562
|
+
async performVacuuming(options, conditions) {
|
|
248563
|
+
const initialDirtCount = this._dirtCount;
|
|
248564
|
+
if (this.vacuumConditionsMet(conditions)) {
|
|
248565
|
+
const batchSize = options.batchSize || defaultVacuumOptions.batchSize;
|
|
248566
|
+
const batchWait = options.batchWait || defaultVacuumOptions.batchWait;
|
|
248567
|
+
let i = 1;
|
|
248568
|
+
for (const [term, fieldsData] of this._index) {
|
|
248569
|
+
for (const [fieldId, fieldIndex] of fieldsData) {
|
|
248570
|
+
for (const [shortId] of fieldIndex) {
|
|
248571
|
+
if (this._documentIds.has(shortId)) {
|
|
248572
|
+
continue;
|
|
248573
|
+
}
|
|
248574
|
+
if (fieldIndex.size <= 1) {
|
|
248575
|
+
fieldsData.delete(fieldId);
|
|
248576
|
+
} else {
|
|
248577
|
+
fieldIndex.delete(shortId);
|
|
248578
|
+
}
|
|
248579
|
+
}
|
|
248580
|
+
}
|
|
248581
|
+
if (this._index.get(term).size === 0) {
|
|
248582
|
+
this._index.delete(term);
|
|
248583
|
+
}
|
|
248584
|
+
if (i % batchSize === 0) {
|
|
248585
|
+
await new Promise((resolve) => setTimeout(resolve, batchWait));
|
|
248586
|
+
}
|
|
248587
|
+
i += 1;
|
|
248588
|
+
}
|
|
248589
|
+
this._dirtCount -= initialDirtCount;
|
|
248590
|
+
}
|
|
248591
|
+
await null;
|
|
248592
|
+
this._currentVacuum = this._enqueuedVacuum;
|
|
248593
|
+
this._enqueuedVacuum = null;
|
|
248594
|
+
}
|
|
248595
|
+
vacuumConditionsMet(conditions) {
|
|
248596
|
+
if (conditions == null) {
|
|
248597
|
+
return true;
|
|
248598
|
+
}
|
|
248599
|
+
let { minDirtCount, minDirtFactor } = conditions;
|
|
248600
|
+
minDirtCount = minDirtCount || defaultAutoVacuumOptions.minDirtCount;
|
|
248601
|
+
minDirtFactor = minDirtFactor || defaultAutoVacuumOptions.minDirtFactor;
|
|
248602
|
+
return this.dirtCount >= minDirtCount && this.dirtFactor >= minDirtFactor;
|
|
248603
|
+
}
|
|
248604
|
+
get isVacuuming() {
|
|
248605
|
+
return this._currentVacuum != null;
|
|
248606
|
+
}
|
|
248607
|
+
get dirtCount() {
|
|
248608
|
+
return this._dirtCount;
|
|
248609
|
+
}
|
|
248610
|
+
get dirtFactor() {
|
|
248611
|
+
return this._dirtCount / (1 + this._documentCount + this._dirtCount);
|
|
248612
|
+
}
|
|
248613
|
+
has(id) {
|
|
248614
|
+
return this._idToShortId.has(id);
|
|
248615
|
+
}
|
|
248616
|
+
getStoredFields(id) {
|
|
248617
|
+
const shortId = this._idToShortId.get(id);
|
|
248618
|
+
if (shortId == null) {
|
|
248619
|
+
return;
|
|
248620
|
+
}
|
|
248621
|
+
return this._storedFields.get(shortId);
|
|
248622
|
+
}
|
|
248623
|
+
search(query, searchOptions = {}) {
|
|
248624
|
+
const { searchOptions: globalSearchOptions } = this._options;
|
|
248625
|
+
const searchOptionsWithDefaults = { ...globalSearchOptions, ...searchOptions };
|
|
248626
|
+
const rawResults = this.executeQuery(query, searchOptions);
|
|
248627
|
+
const results = [];
|
|
248628
|
+
for (const [docId, { score, terms, match }] of rawResults) {
|
|
248629
|
+
const quality = terms.length || 1;
|
|
248630
|
+
const result = {
|
|
248631
|
+
id: this._documentIds.get(docId),
|
|
248632
|
+
score: score * quality,
|
|
248633
|
+
terms: Object.keys(match),
|
|
248634
|
+
queryTerms: terms,
|
|
248635
|
+
match
|
|
248636
|
+
};
|
|
248637
|
+
Object.assign(result, this._storedFields.get(docId));
|
|
248638
|
+
if (searchOptionsWithDefaults.filter == null || searchOptionsWithDefaults.filter(result)) {
|
|
248639
|
+
results.push(result);
|
|
248640
|
+
}
|
|
248641
|
+
}
|
|
248642
|
+
if (query === MiniSearch.wildcard && searchOptionsWithDefaults.boostDocument == null) {
|
|
248643
|
+
return results;
|
|
248644
|
+
}
|
|
248645
|
+
results.sort(byScore);
|
|
248646
|
+
return results;
|
|
248647
|
+
}
|
|
248648
|
+
autoSuggest(queryString, options = {}) {
|
|
248649
|
+
options = { ...this._options.autoSuggestOptions, ...options };
|
|
248650
|
+
const suggestions = new Map;
|
|
248651
|
+
for (const { score, terms } of this.search(queryString, options)) {
|
|
248652
|
+
const phrase = terms.join(" ");
|
|
248653
|
+
const suggestion = suggestions.get(phrase);
|
|
248654
|
+
if (suggestion != null) {
|
|
248655
|
+
suggestion.score += score;
|
|
248656
|
+
suggestion.count += 1;
|
|
248657
|
+
} else {
|
|
248658
|
+
suggestions.set(phrase, { score, terms, count: 1 });
|
|
248659
|
+
}
|
|
248660
|
+
}
|
|
248661
|
+
const results = [];
|
|
248662
|
+
for (const [suggestion, { score, terms, count }] of suggestions) {
|
|
248663
|
+
results.push({ suggestion, terms, score: score / count });
|
|
248664
|
+
}
|
|
248665
|
+
results.sort(byScore);
|
|
248666
|
+
return results;
|
|
248667
|
+
}
|
|
248668
|
+
get documentCount() {
|
|
248669
|
+
return this._documentCount;
|
|
248670
|
+
}
|
|
248671
|
+
get termCount() {
|
|
248672
|
+
return this._index.size;
|
|
248673
|
+
}
|
|
248674
|
+
static loadJSON(json, options) {
|
|
248675
|
+
if (options == null) {
|
|
248676
|
+
throw new Error("MiniSearch: loadJSON should be given the same options used when serializing the index");
|
|
248677
|
+
}
|
|
248678
|
+
return this.loadJS(JSON.parse(json), options);
|
|
248679
|
+
}
|
|
248680
|
+
static async loadJSONAsync(json, options) {
|
|
248681
|
+
if (options == null) {
|
|
248682
|
+
throw new Error("MiniSearch: loadJSON should be given the same options used when serializing the index");
|
|
248683
|
+
}
|
|
248684
|
+
return this.loadJSAsync(JSON.parse(json), options);
|
|
248685
|
+
}
|
|
248686
|
+
static getDefault(optionName) {
|
|
248687
|
+
if (defaultOptions.hasOwnProperty(optionName)) {
|
|
248688
|
+
return getOwnProperty(defaultOptions, optionName);
|
|
248689
|
+
} else {
|
|
248690
|
+
throw new Error(`MiniSearch: unknown option "${optionName}"`);
|
|
248691
|
+
}
|
|
248692
|
+
}
|
|
248693
|
+
static loadJS(js, options) {
|
|
248694
|
+
const { index, documentIds, fieldLength, storedFields, serializationVersion } = js;
|
|
248695
|
+
const miniSearch = this.instantiateMiniSearch(js, options);
|
|
248696
|
+
miniSearch._documentIds = objectToNumericMap(documentIds);
|
|
248697
|
+
miniSearch._fieldLength = objectToNumericMap(fieldLength);
|
|
248698
|
+
miniSearch._storedFields = objectToNumericMap(storedFields);
|
|
248699
|
+
for (const [shortId, id] of miniSearch._documentIds) {
|
|
248700
|
+
miniSearch._idToShortId.set(id, shortId);
|
|
248701
|
+
}
|
|
248702
|
+
for (const [term, data] of index) {
|
|
248703
|
+
const dataMap = new Map;
|
|
248704
|
+
for (const fieldId of Object.keys(data)) {
|
|
248705
|
+
let indexEntry = data[fieldId];
|
|
248706
|
+
if (serializationVersion === 1) {
|
|
248707
|
+
indexEntry = indexEntry.ds;
|
|
248708
|
+
}
|
|
248709
|
+
dataMap.set(parseInt(fieldId, 10), objectToNumericMap(indexEntry));
|
|
248710
|
+
}
|
|
248711
|
+
miniSearch._index.set(term, dataMap);
|
|
248712
|
+
}
|
|
248713
|
+
return miniSearch;
|
|
248714
|
+
}
|
|
248715
|
+
static async loadJSAsync(js, options) {
|
|
248716
|
+
const { index, documentIds, fieldLength, storedFields, serializationVersion } = js;
|
|
248717
|
+
const miniSearch = this.instantiateMiniSearch(js, options);
|
|
248718
|
+
miniSearch._documentIds = await objectToNumericMapAsync(documentIds);
|
|
248719
|
+
miniSearch._fieldLength = await objectToNumericMapAsync(fieldLength);
|
|
248720
|
+
miniSearch._storedFields = await objectToNumericMapAsync(storedFields);
|
|
248721
|
+
for (const [shortId, id] of miniSearch._documentIds) {
|
|
248722
|
+
miniSearch._idToShortId.set(id, shortId);
|
|
248723
|
+
}
|
|
248724
|
+
let count = 0;
|
|
248725
|
+
for (const [term, data] of index) {
|
|
248726
|
+
const dataMap = new Map;
|
|
248727
|
+
for (const fieldId of Object.keys(data)) {
|
|
248728
|
+
let indexEntry = data[fieldId];
|
|
248729
|
+
if (serializationVersion === 1) {
|
|
248730
|
+
indexEntry = indexEntry.ds;
|
|
248731
|
+
}
|
|
248732
|
+
dataMap.set(parseInt(fieldId, 10), await objectToNumericMapAsync(indexEntry));
|
|
248733
|
+
}
|
|
248734
|
+
if (++count % 1000 === 0)
|
|
248735
|
+
await wait(0);
|
|
248736
|
+
miniSearch._index.set(term, dataMap);
|
|
248737
|
+
}
|
|
248738
|
+
return miniSearch;
|
|
248739
|
+
}
|
|
248740
|
+
static instantiateMiniSearch(js, options) {
|
|
248741
|
+
const { documentCount, nextId, fieldIds, averageFieldLength, dirtCount, serializationVersion } = js;
|
|
248742
|
+
if (serializationVersion !== 1 && serializationVersion !== 2) {
|
|
248743
|
+
throw new Error("MiniSearch: cannot deserialize an index created with an incompatible version");
|
|
248744
|
+
}
|
|
248745
|
+
const miniSearch = new MiniSearch(options);
|
|
248746
|
+
miniSearch._documentCount = documentCount;
|
|
248747
|
+
miniSearch._nextId = nextId;
|
|
248748
|
+
miniSearch._idToShortId = new Map;
|
|
248749
|
+
miniSearch._fieldIds = fieldIds;
|
|
248750
|
+
miniSearch._avgFieldLength = averageFieldLength;
|
|
248751
|
+
miniSearch._dirtCount = dirtCount || 0;
|
|
248752
|
+
miniSearch._index = new SearchableMap;
|
|
248753
|
+
return miniSearch;
|
|
248754
|
+
}
|
|
248755
|
+
executeQuery(query, searchOptions = {}) {
|
|
248756
|
+
if (query === MiniSearch.wildcard) {
|
|
248757
|
+
return this.executeWildcardQuery(searchOptions);
|
|
248758
|
+
}
|
|
248759
|
+
if (typeof query !== "string") {
|
|
248760
|
+
const options = { ...searchOptions, ...query, queries: undefined };
|
|
248761
|
+
const results = query.queries.map((subquery) => this.executeQuery(subquery, options));
|
|
248762
|
+
return this.combineResults(results, options.combineWith);
|
|
248763
|
+
}
|
|
248764
|
+
const { tokenize, processTerm, searchOptions: globalSearchOptions } = this._options;
|
|
248765
|
+
const options = { tokenize, processTerm, ...globalSearchOptions, ...searchOptions };
|
|
248766
|
+
const { tokenize: searchTokenize, processTerm: searchProcessTerm } = options;
|
|
248767
|
+
const terms = searchTokenize(query).flatMap((term) => searchProcessTerm(term)).filter((term) => !!term);
|
|
248768
|
+
const queries = terms.map(termToQuerySpec(options));
|
|
248769
|
+
const results = queries.map((query) => this.executeQuerySpec(query, options));
|
|
248770
|
+
return this.combineResults(results, options.combineWith);
|
|
248771
|
+
}
|
|
248772
|
+
executeQuerySpec(query, searchOptions) {
|
|
248773
|
+
const options = { ...this._options.searchOptions, ...searchOptions };
|
|
248774
|
+
const boosts = (options.fields || this._options.fields).reduce((boosts, field) => ({ ...boosts, [field]: getOwnProperty(options.boost, field) || 1 }), {});
|
|
248775
|
+
const { boostDocument, weights, maxFuzzy, bm25: bm25params } = options;
|
|
248776
|
+
const { fuzzy: fuzzyWeight, prefix: prefixWeight } = { ...defaultSearchOptions.weights, ...weights };
|
|
248777
|
+
const data = this._index.get(query.term);
|
|
248778
|
+
const results = this.termResults(query.term, query.term, 1, query.termBoost, data, boosts, boostDocument, bm25params);
|
|
248779
|
+
let prefixMatches;
|
|
248780
|
+
let fuzzyMatches;
|
|
248781
|
+
if (query.prefix) {
|
|
248782
|
+
prefixMatches = this._index.atPrefix(query.term);
|
|
248783
|
+
}
|
|
248784
|
+
if (query.fuzzy) {
|
|
248785
|
+
const fuzzy = query.fuzzy === true ? 0.2 : query.fuzzy;
|
|
248786
|
+
const maxDistance = fuzzy < 1 ? Math.min(maxFuzzy, Math.round(query.term.length * fuzzy)) : fuzzy;
|
|
248787
|
+
if (maxDistance)
|
|
248788
|
+
fuzzyMatches = this._index.fuzzyGet(query.term, maxDistance);
|
|
248789
|
+
}
|
|
248790
|
+
if (prefixMatches) {
|
|
248791
|
+
for (const [term, data] of prefixMatches) {
|
|
248792
|
+
const distance = term.length - query.term.length;
|
|
248793
|
+
if (!distance) {
|
|
248794
|
+
continue;
|
|
248795
|
+
}
|
|
248796
|
+
fuzzyMatches === null || fuzzyMatches === undefined || fuzzyMatches.delete(term);
|
|
248797
|
+
const weight = prefixWeight * term.length / (term.length + 0.3 * distance);
|
|
248798
|
+
this.termResults(query.term, term, weight, query.termBoost, data, boosts, boostDocument, bm25params, results);
|
|
248799
|
+
}
|
|
248800
|
+
}
|
|
248801
|
+
if (fuzzyMatches) {
|
|
248802
|
+
for (const term of fuzzyMatches.keys()) {
|
|
248803
|
+
const [data, distance] = fuzzyMatches.get(term);
|
|
248804
|
+
if (!distance) {
|
|
248805
|
+
continue;
|
|
248806
|
+
}
|
|
248807
|
+
const weight = fuzzyWeight * term.length / (term.length + distance);
|
|
248808
|
+
this.termResults(query.term, term, weight, query.termBoost, data, boosts, boostDocument, bm25params, results);
|
|
248809
|
+
}
|
|
248810
|
+
}
|
|
248811
|
+
return results;
|
|
248812
|
+
}
|
|
248813
|
+
executeWildcardQuery(searchOptions) {
|
|
248814
|
+
const results = new Map;
|
|
248815
|
+
const options = { ...this._options.searchOptions, ...searchOptions };
|
|
248816
|
+
for (const [shortId, id] of this._documentIds) {
|
|
248817
|
+
const score = options.boostDocument ? options.boostDocument(id, "", this._storedFields.get(shortId)) : 1;
|
|
248818
|
+
results.set(shortId, {
|
|
248819
|
+
score,
|
|
248820
|
+
terms: [],
|
|
248821
|
+
match: {}
|
|
248822
|
+
});
|
|
248823
|
+
}
|
|
248824
|
+
return results;
|
|
248825
|
+
}
|
|
248826
|
+
combineResults(results, combineWith = OR) {
|
|
248827
|
+
if (results.length === 0) {
|
|
248828
|
+
return new Map;
|
|
248829
|
+
}
|
|
248830
|
+
const operator = combineWith.toLowerCase();
|
|
248831
|
+
const combinator = combinators[operator];
|
|
248832
|
+
if (!combinator) {
|
|
248833
|
+
throw new Error(`Invalid combination operator: ${combineWith}`);
|
|
248834
|
+
}
|
|
248835
|
+
return results.reduce(combinator) || new Map;
|
|
248836
|
+
}
|
|
248837
|
+
toJSON() {
|
|
248838
|
+
const index = [];
|
|
248839
|
+
for (const [term, fieldIndex] of this._index) {
|
|
248840
|
+
const data = {};
|
|
248841
|
+
for (const [fieldId, freqs] of fieldIndex) {
|
|
248842
|
+
data[fieldId] = Object.fromEntries(freqs);
|
|
248843
|
+
}
|
|
248844
|
+
index.push([term, data]);
|
|
248845
|
+
}
|
|
248846
|
+
return {
|
|
248847
|
+
documentCount: this._documentCount,
|
|
248848
|
+
nextId: this._nextId,
|
|
248849
|
+
documentIds: Object.fromEntries(this._documentIds),
|
|
248850
|
+
fieldIds: this._fieldIds,
|
|
248851
|
+
fieldLength: Object.fromEntries(this._fieldLength),
|
|
248852
|
+
averageFieldLength: this._avgFieldLength,
|
|
248853
|
+
storedFields: Object.fromEntries(this._storedFields),
|
|
248854
|
+
dirtCount: this._dirtCount,
|
|
248855
|
+
index,
|
|
248856
|
+
serializationVersion: 2
|
|
248857
|
+
};
|
|
248858
|
+
}
|
|
248859
|
+
termResults(sourceTerm, derivedTerm, termWeight, termBoost, fieldTermData, fieldBoosts, boostDocumentFn, bm25params, results = new Map) {
|
|
248860
|
+
if (fieldTermData == null)
|
|
248861
|
+
return results;
|
|
248862
|
+
for (const field of Object.keys(fieldBoosts)) {
|
|
248863
|
+
const fieldBoost = fieldBoosts[field];
|
|
248864
|
+
const fieldId = this._fieldIds[field];
|
|
248865
|
+
const fieldTermFreqs = fieldTermData.get(fieldId);
|
|
248866
|
+
if (fieldTermFreqs == null)
|
|
248867
|
+
continue;
|
|
248868
|
+
let matchingFields = fieldTermFreqs.size;
|
|
248869
|
+
const avgFieldLength = this._avgFieldLength[fieldId];
|
|
248870
|
+
for (const docId of fieldTermFreqs.keys()) {
|
|
248871
|
+
if (!this._documentIds.has(docId)) {
|
|
248872
|
+
this.removeTerm(fieldId, docId, derivedTerm);
|
|
248873
|
+
matchingFields -= 1;
|
|
248874
|
+
continue;
|
|
248875
|
+
}
|
|
248876
|
+
const docBoost = boostDocumentFn ? boostDocumentFn(this._documentIds.get(docId), derivedTerm, this._storedFields.get(docId)) : 1;
|
|
248877
|
+
if (!docBoost)
|
|
248878
|
+
continue;
|
|
248879
|
+
const termFreq = fieldTermFreqs.get(docId);
|
|
248880
|
+
const fieldLength = this._fieldLength.get(docId)[fieldId];
|
|
248881
|
+
const rawScore = calcBM25Score(termFreq, matchingFields, this._documentCount, fieldLength, avgFieldLength, bm25params);
|
|
248882
|
+
const weightedScore = termWeight * termBoost * fieldBoost * docBoost * rawScore;
|
|
248883
|
+
const result = results.get(docId);
|
|
248884
|
+
if (result) {
|
|
248885
|
+
result.score += weightedScore;
|
|
248886
|
+
assignUniqueTerm(result.terms, sourceTerm);
|
|
248887
|
+
const match = getOwnProperty(result.match, derivedTerm);
|
|
248888
|
+
if (match) {
|
|
248889
|
+
match.push(field);
|
|
248890
|
+
} else {
|
|
248891
|
+
result.match[derivedTerm] = [field];
|
|
248892
|
+
}
|
|
248893
|
+
} else {
|
|
248894
|
+
results.set(docId, {
|
|
248895
|
+
score: weightedScore,
|
|
248896
|
+
terms: [sourceTerm],
|
|
248897
|
+
match: { [derivedTerm]: [field] }
|
|
248898
|
+
});
|
|
248899
|
+
}
|
|
248900
|
+
}
|
|
248901
|
+
}
|
|
248902
|
+
return results;
|
|
248903
|
+
}
|
|
248904
|
+
addTerm(fieldId, documentId, term) {
|
|
248905
|
+
const indexData = this._index.fetch(term, createMap);
|
|
248906
|
+
let fieldIndex = indexData.get(fieldId);
|
|
248907
|
+
if (fieldIndex == null) {
|
|
248908
|
+
fieldIndex = new Map;
|
|
248909
|
+
fieldIndex.set(documentId, 1);
|
|
248910
|
+
indexData.set(fieldId, fieldIndex);
|
|
248911
|
+
} else {
|
|
248912
|
+
const docs = fieldIndex.get(documentId);
|
|
248913
|
+
fieldIndex.set(documentId, (docs || 0) + 1);
|
|
248914
|
+
}
|
|
248915
|
+
}
|
|
248916
|
+
removeTerm(fieldId, documentId, term) {
|
|
248917
|
+
if (!this._index.has(term)) {
|
|
248918
|
+
this.warnDocumentChanged(documentId, fieldId, term);
|
|
248919
|
+
return;
|
|
248920
|
+
}
|
|
248921
|
+
const indexData = this._index.fetch(term, createMap);
|
|
248922
|
+
const fieldIndex = indexData.get(fieldId);
|
|
248923
|
+
if (fieldIndex == null || fieldIndex.get(documentId) == null) {
|
|
248924
|
+
this.warnDocumentChanged(documentId, fieldId, term);
|
|
248925
|
+
} else if (fieldIndex.get(documentId) <= 1) {
|
|
248926
|
+
if (fieldIndex.size <= 1) {
|
|
248927
|
+
indexData.delete(fieldId);
|
|
248928
|
+
} else {
|
|
248929
|
+
fieldIndex.delete(documentId);
|
|
248930
|
+
}
|
|
248931
|
+
} else {
|
|
248932
|
+
fieldIndex.set(documentId, fieldIndex.get(documentId) - 1);
|
|
248933
|
+
}
|
|
248934
|
+
if (this._index.get(term).size === 0) {
|
|
248935
|
+
this._index.delete(term);
|
|
248936
|
+
}
|
|
248937
|
+
}
|
|
248938
|
+
warnDocumentChanged(shortDocumentId, fieldId, term) {
|
|
248939
|
+
for (const fieldName of Object.keys(this._fieldIds)) {
|
|
248940
|
+
if (this._fieldIds[fieldName] === fieldId) {
|
|
248941
|
+
this._options.logger("warn", `MiniSearch: document with ID ${this._documentIds.get(shortDocumentId)} has changed before removal: term "${term}" was not present in field "${fieldName}". Removing a document after it has changed can corrupt the index!`, "version_conflict");
|
|
248942
|
+
return;
|
|
248943
|
+
}
|
|
248944
|
+
}
|
|
248945
|
+
}
|
|
248946
|
+
addDocumentId(documentId) {
|
|
248947
|
+
const shortDocumentId = this._nextId;
|
|
248948
|
+
this._idToShortId.set(documentId, shortDocumentId);
|
|
248949
|
+
this._documentIds.set(shortDocumentId, documentId);
|
|
248950
|
+
this._documentCount += 1;
|
|
248951
|
+
this._nextId += 1;
|
|
248952
|
+
return shortDocumentId;
|
|
248953
|
+
}
|
|
248954
|
+
addFields(fields) {
|
|
248955
|
+
for (let i = 0;i < fields.length; i++) {
|
|
248956
|
+
this._fieldIds[fields[i]] = i;
|
|
248957
|
+
}
|
|
248958
|
+
}
|
|
248959
|
+
addFieldLength(documentId, fieldId, count, length) {
|
|
248960
|
+
let fieldLengths = this._fieldLength.get(documentId);
|
|
248961
|
+
if (fieldLengths == null)
|
|
248962
|
+
this._fieldLength.set(documentId, fieldLengths = []);
|
|
248963
|
+
fieldLengths[fieldId] = length;
|
|
248964
|
+
const averageFieldLength = this._avgFieldLength[fieldId] || 0;
|
|
248965
|
+
const totalFieldLength = averageFieldLength * count + length;
|
|
248966
|
+
this._avgFieldLength[fieldId] = totalFieldLength / (count + 1);
|
|
248967
|
+
}
|
|
248968
|
+
removeFieldLength(documentId, fieldId, count, length) {
|
|
248969
|
+
if (count === 1) {
|
|
248970
|
+
this._avgFieldLength[fieldId] = 0;
|
|
248971
|
+
return;
|
|
248972
|
+
}
|
|
248973
|
+
const totalFieldLength = this._avgFieldLength[fieldId] * count - length;
|
|
248974
|
+
this._avgFieldLength[fieldId] = totalFieldLength / (count - 1);
|
|
248975
|
+
}
|
|
248976
|
+
saveStoredFields(documentId, doc) {
|
|
248977
|
+
const { storeFields, extractField } = this._options;
|
|
248978
|
+
if (storeFields == null || storeFields.length === 0) {
|
|
248979
|
+
return;
|
|
248980
|
+
}
|
|
248981
|
+
let documentFields = this._storedFields.get(documentId);
|
|
248982
|
+
if (documentFields == null)
|
|
248983
|
+
this._storedFields.set(documentId, documentFields = {});
|
|
248984
|
+
for (const fieldName of storeFields) {
|
|
248985
|
+
const fieldValue = extractField(doc, fieldName);
|
|
248986
|
+
if (fieldValue !== undefined)
|
|
248987
|
+
documentFields[fieldName] = fieldValue;
|
|
248988
|
+
}
|
|
248989
|
+
}
|
|
248990
|
+
}
|
|
248991
|
+
MiniSearch.wildcard = Symbol("*");
|
|
248992
|
+
var getOwnProperty = (object, property) => Object.prototype.hasOwnProperty.call(object, property) ? object[property] : undefined;
|
|
248993
|
+
var combinators = {
|
|
248994
|
+
[OR]: (a, b) => {
|
|
248995
|
+
for (const docId of b.keys()) {
|
|
248996
|
+
const existing = a.get(docId);
|
|
248997
|
+
if (existing == null) {
|
|
248998
|
+
a.set(docId, b.get(docId));
|
|
248999
|
+
} else {
|
|
249000
|
+
const { score, terms, match } = b.get(docId);
|
|
249001
|
+
existing.score = existing.score + score;
|
|
249002
|
+
existing.match = Object.assign(existing.match, match);
|
|
249003
|
+
assignUniqueTerms(existing.terms, terms);
|
|
249004
|
+
}
|
|
249005
|
+
}
|
|
249006
|
+
return a;
|
|
249007
|
+
},
|
|
249008
|
+
[AND]: (a, b) => {
|
|
249009
|
+
const combined = new Map;
|
|
249010
|
+
for (const docId of b.keys()) {
|
|
249011
|
+
const existing = a.get(docId);
|
|
249012
|
+
if (existing == null)
|
|
249013
|
+
continue;
|
|
249014
|
+
const { score, terms, match } = b.get(docId);
|
|
249015
|
+
assignUniqueTerms(existing.terms, terms);
|
|
249016
|
+
combined.set(docId, {
|
|
249017
|
+
score: existing.score + score,
|
|
249018
|
+
terms: existing.terms,
|
|
249019
|
+
match: Object.assign(existing.match, match)
|
|
249020
|
+
});
|
|
249021
|
+
}
|
|
249022
|
+
return combined;
|
|
249023
|
+
},
|
|
249024
|
+
[AND_NOT]: (a, b) => {
|
|
249025
|
+
for (const docId of b.keys())
|
|
249026
|
+
a.delete(docId);
|
|
249027
|
+
return a;
|
|
249028
|
+
}
|
|
249029
|
+
};
|
|
249030
|
+
var defaultBM25params = { k: 1.2, b: 0.7, d: 0.5 };
|
|
249031
|
+
var calcBM25Score = (termFreq, matchingCount, totalCount, fieldLength, avgFieldLength, bm25params) => {
|
|
249032
|
+
const { k, b, d } = bm25params;
|
|
249033
|
+
const invDocFreq = Math.log(1 + (totalCount - matchingCount + 0.5) / (matchingCount + 0.5));
|
|
249034
|
+
return invDocFreq * (d + termFreq * (k + 1) / (termFreq + k * (1 - b + b * fieldLength / avgFieldLength)));
|
|
249035
|
+
};
|
|
249036
|
+
var termToQuerySpec = (options) => (term, i, terms) => {
|
|
249037
|
+
const fuzzy = typeof options.fuzzy === "function" ? options.fuzzy(term, i, terms) : options.fuzzy || false;
|
|
249038
|
+
const prefix = typeof options.prefix === "function" ? options.prefix(term, i, terms) : options.prefix === true;
|
|
249039
|
+
const termBoost = typeof options.boostTerm === "function" ? options.boostTerm(term, i, terms) : 1;
|
|
249040
|
+
return { term, fuzzy, prefix, termBoost };
|
|
249041
|
+
};
|
|
249042
|
+
var defaultOptions = {
|
|
249043
|
+
idField: "id",
|
|
249044
|
+
extractField: (document2, fieldName) => document2[fieldName],
|
|
249045
|
+
tokenize: (text) => text.split(SPACE_OR_PUNCTUATION),
|
|
249046
|
+
processTerm: (term) => term.toLowerCase(),
|
|
249047
|
+
fields: undefined,
|
|
249048
|
+
searchOptions: undefined,
|
|
249049
|
+
storeFields: [],
|
|
249050
|
+
logger: (level, message) => {
|
|
249051
|
+
if (typeof (console === null || console === undefined ? undefined : console[level]) === "function")
|
|
249052
|
+
console[level](message);
|
|
249053
|
+
},
|
|
249054
|
+
autoVacuum: true
|
|
249055
|
+
};
|
|
249056
|
+
var defaultSearchOptions = {
|
|
249057
|
+
combineWith: OR,
|
|
249058
|
+
prefix: false,
|
|
249059
|
+
fuzzy: false,
|
|
249060
|
+
maxFuzzy: 6,
|
|
249061
|
+
boost: {},
|
|
249062
|
+
weights: { fuzzy: 0.45, prefix: 0.375 },
|
|
249063
|
+
bm25: defaultBM25params
|
|
249064
|
+
};
|
|
249065
|
+
var defaultAutoSuggestOptions = {
|
|
249066
|
+
combineWith: AND,
|
|
249067
|
+
prefix: (term, i, terms) => i === terms.length - 1
|
|
249068
|
+
};
|
|
249069
|
+
var defaultVacuumOptions = { batchSize: 1000, batchWait: 10 };
|
|
249070
|
+
var defaultVacuumConditions = { minDirtFactor: 0.1, minDirtCount: 20 };
|
|
249071
|
+
var defaultAutoVacuumOptions = { ...defaultVacuumOptions, ...defaultVacuumConditions };
|
|
249072
|
+
var assignUniqueTerm = (target, term) => {
|
|
249073
|
+
if (!target.includes(term))
|
|
249074
|
+
target.push(term);
|
|
249075
|
+
};
|
|
249076
|
+
var assignUniqueTerms = (target, source) => {
|
|
249077
|
+
for (const term of source) {
|
|
249078
|
+
if (!target.includes(term))
|
|
249079
|
+
target.push(term);
|
|
249080
|
+
}
|
|
249081
|
+
};
|
|
249082
|
+
var byScore = ({ score: a }, { score: b }) => b - a;
|
|
249083
|
+
var createMap = () => new Map;
|
|
249084
|
+
var objectToNumericMap = (object) => {
|
|
249085
|
+
const map = new Map;
|
|
249086
|
+
for (const key of Object.keys(object)) {
|
|
249087
|
+
map.set(parseInt(key, 10), object[key]);
|
|
249088
|
+
}
|
|
249089
|
+
return map;
|
|
249090
|
+
};
|
|
249091
|
+
var objectToNumericMapAsync = async (object) => {
|
|
249092
|
+
const map = new Map;
|
|
249093
|
+
let count = 0;
|
|
249094
|
+
for (const key of Object.keys(object)) {
|
|
249095
|
+
map.set(parseInt(key, 10), object[key]);
|
|
249096
|
+
if (++count % 1000 === 0) {
|
|
249097
|
+
await wait(0);
|
|
249098
|
+
}
|
|
249099
|
+
}
|
|
249100
|
+
return map;
|
|
249101
|
+
};
|
|
249102
|
+
var wait = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
249103
|
+
var SPACE_OR_PUNCTUATION = /[\n\r\p{Z}\p{P}]+/u;
|
|
249104
|
+
|
|
249105
|
+
// src/core/api-spec/search.ts
|
|
249106
|
+
var BOOST = {
|
|
249107
|
+
method: 1,
|
|
249108
|
+
path: 8,
|
|
249109
|
+
summary: 5,
|
|
249110
|
+
description: 2,
|
|
249111
|
+
parameters: 0.5
|
|
249112
|
+
};
|
|
249113
|
+
var MIN_RELATIVE_SCORE = 0.2;
|
|
249114
|
+
var TOKEN_SEPARATOR = /[\n\r\p{Z}\p{P}\p{S}]+/u;
|
|
249115
|
+
var STOPWORDS = new Set("a an and are at be by do does for from how i id in is it its me my of on or our that the this to we what who with you your".split(" "));
|
|
249116
|
+
function tokenize(text) {
|
|
249117
|
+
return text.split(TOKEN_SEPARATOR).filter((word) => word.length >= 2 && !STOPWORDS.has(word.toLowerCase()));
|
|
249118
|
+
}
|
|
249119
|
+
function toOperationSummary(op) {
|
|
249120
|
+
return { endpoint: op.endpoint, summary: op.summary };
|
|
249121
|
+
}
|
|
249122
|
+
function buildSearchIndex(operations) {
|
|
249123
|
+
const index = new MiniSearch({
|
|
249124
|
+
fields: ["method", "path", "summary", "description", "parameters"],
|
|
249125
|
+
tokenize
|
|
249126
|
+
});
|
|
249127
|
+
index.addAll(operations.map((op, id) => ({
|
|
249128
|
+
id,
|
|
249129
|
+
method: op.method,
|
|
249130
|
+
path: op.path.replace(/\{[^}]*\}/g, ""),
|
|
249131
|
+
summary: op.summary,
|
|
249132
|
+
description: op.description,
|
|
249133
|
+
parameters: op.parameterText
|
|
249134
|
+
})));
|
|
249135
|
+
return index;
|
|
249136
|
+
}
|
|
249137
|
+
function summaryMatch(terms, op) {
|
|
249138
|
+
const words = tokenize(op?.summary.toLowerCase() ?? "");
|
|
249139
|
+
const named = (word) => terms.some((term) => word.startsWith(term));
|
|
249140
|
+
return {
|
|
249141
|
+
coverage: terms.filter((term) => words.some((word) => word.startsWith(term))).length / terms.length,
|
|
249142
|
+
precision: words.length ? words.filter(named).length / words.length : 0
|
|
249143
|
+
};
|
|
249144
|
+
}
|
|
249145
|
+
var readsFirst = (op) => op?.method === "GET" ? 0 : 1;
|
|
249146
|
+
function searchOperations(operations, query, options = {}) {
|
|
249147
|
+
const terms = tokenize(query.toLowerCase());
|
|
249148
|
+
if (terms.length === 0) {
|
|
249149
|
+
return [];
|
|
249150
|
+
}
|
|
249151
|
+
const index = buildSearchIndex(operations);
|
|
249152
|
+
const hits = index.search(query, {
|
|
249153
|
+
prefix: (term) => term.length >= 3,
|
|
249154
|
+
fuzzy: (term) => term.length >= 4 ? 0.2 : false,
|
|
249155
|
+
boost: BOOST,
|
|
249156
|
+
filter: options.readOnly ? (hit) => operations[hit.id]?.readOnly === true : undefined
|
|
249157
|
+
}).map((hit) => {
|
|
249158
|
+
const match = summaryMatch(terms, operations[hit.id]);
|
|
249159
|
+
return {
|
|
249160
|
+
...hit,
|
|
249161
|
+
...match,
|
|
249162
|
+
full: match.coverage === 1,
|
|
249163
|
+
score: hit.score * (1 + match.coverage)
|
|
249164
|
+
};
|
|
249165
|
+
}).sort((a, b) => Number(b.full) - Number(a.full) || (a.full ? b.precision - a.precision || readsFirst(operations[a.id]) - readsFirst(operations[b.id]) : 0) || b.score - a.score);
|
|
249166
|
+
const baseline = Math.max(0, ...hits.map((hit) => hit.score)) * MIN_RELATIVE_SCORE;
|
|
249167
|
+
return hits.filter((hit) => hit.full || hit.score >= baseline).slice(0, options.limit ?? 5).flatMap((hit) => {
|
|
249168
|
+
const op = operations[hit.id];
|
|
249169
|
+
return op ? [toOperationSummary(op)] : [];
|
|
249170
|
+
});
|
|
249171
|
+
}
|
|
249172
|
+
|
|
249173
|
+
// src/core/api-spec/catalog.ts
|
|
249174
|
+
var INLINE_AREA_MAX = 2;
|
|
249175
|
+
var AREA_SAMPLE_MAX = 3;
|
|
249176
|
+
var AREA_OPERATIONS_MAX = 200;
|
|
249177
|
+
var byCodePoint = (a, b) => a < b ? -1 : a > b ? 1 : 0;
|
|
249178
|
+
function areaOf(path) {
|
|
249179
|
+
const parts = path.split("/").filter(Boolean);
|
|
249180
|
+
const appIdIndex = parts.indexOf("{app_id}");
|
|
249181
|
+
if (appIdIndex !== -1 && appIdIndex + 1 < parts.length) {
|
|
249182
|
+
return parts[appIdIndex + 1] ?? "other";
|
|
249183
|
+
}
|
|
249184
|
+
if (parts[0] === "api" && parts.length > 1) {
|
|
249185
|
+
return parts[1] ?? "other";
|
|
249186
|
+
}
|
|
249187
|
+
return parts[0] ?? "other";
|
|
249188
|
+
}
|
|
249189
|
+
function groupByArea(operations) {
|
|
249190
|
+
const sorted = [...operations].sort((a, b) => byCodePoint(`${a.method} ${a.path}`, `${b.method} ${b.path}`));
|
|
249191
|
+
const areas = new Map;
|
|
249192
|
+
for (const op of sorted) {
|
|
249193
|
+
const area = areaOf(op.path);
|
|
249194
|
+
areas.set(area, [...areas.get(area) ?? [], op]);
|
|
249195
|
+
}
|
|
249196
|
+
return new Map([...areas].sort(([a], [b]) => byCodePoint(a, b)));
|
|
249197
|
+
}
|
|
249198
|
+
function readsFirst2(ops) {
|
|
249199
|
+
const isRead = (op) => op.method === "GET" ? 0 : 1;
|
|
249200
|
+
return [...ops].sort((a, b) => isRead(a) - isRead(b));
|
|
249201
|
+
}
|
|
249202
|
+
function catalogIndex(operations) {
|
|
249203
|
+
const areas = [...groupByArea(operations)].map(([area, ops]) => ops.length <= INLINE_AREA_MAX ? { area, operations: ops.map(toOperationSummary) } : {
|
|
249204
|
+
area,
|
|
249205
|
+
operationCount: ops.length,
|
|
249206
|
+
sample: readsFirst2(ops).slice(0, AREA_SAMPLE_MAX).map((op) => op.summary)
|
|
249207
|
+
});
|
|
249208
|
+
return { areas, total: operations.length };
|
|
249209
|
+
}
|
|
249210
|
+
function areaListing(area, operations, max = AREA_OPERATIONS_MAX) {
|
|
249211
|
+
return {
|
|
249212
|
+
area,
|
|
249213
|
+
operations: operations.slice(0, max).map(toOperationSummary),
|
|
249214
|
+
total: operations.length,
|
|
249215
|
+
truncated: operations.length > max
|
|
249216
|
+
};
|
|
249217
|
+
}
|
|
249218
|
+
// src/core/api-spec/schema.ts
|
|
249219
|
+
var HTTP_METHODS = [
|
|
249220
|
+
"get",
|
|
249221
|
+
"put",
|
|
249222
|
+
"post",
|
|
249223
|
+
"delete",
|
|
249224
|
+
"patch",
|
|
249225
|
+
"head",
|
|
249226
|
+
"options",
|
|
249227
|
+
"trace"
|
|
249228
|
+
];
|
|
249229
|
+
var ParameterSchema = looseObject({
|
|
249230
|
+
name: string2(),
|
|
249231
|
+
in: string2(),
|
|
249232
|
+
required: boolean2().optional(),
|
|
249233
|
+
description: string2().optional(),
|
|
249234
|
+
schema: unknown().optional(),
|
|
249235
|
+
example: unknown().optional()
|
|
249236
|
+
});
|
|
249237
|
+
var MediaTypesSchema = record(string2(), looseObject({ schema: unknown().optional() }));
|
|
249238
|
+
var MediaContentSchema = looseObject({
|
|
249239
|
+
content: MediaTypesSchema.optional()
|
|
249240
|
+
});
|
|
249241
|
+
var ResponseObjectSchema = looseObject({
|
|
249242
|
+
description: string2().optional(),
|
|
249243
|
+
content: MediaTypesSchema.optional()
|
|
249244
|
+
});
|
|
249245
|
+
var SecurityRequirementSchema = record(string2(), array(string2()));
|
|
249246
|
+
var OperationSchema = looseObject({
|
|
249247
|
+
summary: string2().optional(),
|
|
249248
|
+
description: string2().optional(),
|
|
249249
|
+
operationId: string2().optional(),
|
|
249250
|
+
parameters: array(unknown()).optional(),
|
|
249251
|
+
requestBody: unknown().optional(),
|
|
249252
|
+
responses: record(string2(), unknown()).optional(),
|
|
249253
|
+
security: array(SecurityRequirementSchema).optional()
|
|
249254
|
+
});
|
|
249255
|
+
var OpenApiSpecSchema = looseObject({
|
|
249256
|
+
openapi: string2(),
|
|
249257
|
+
paths: record(string2(), record(string2(), unknown())),
|
|
249258
|
+
components: looseObject({
|
|
249259
|
+
schemas: record(string2(), unknown()).optional()
|
|
249260
|
+
}).optional(),
|
|
249261
|
+
security: array(SecurityRequirementSchema).optional().catch(undefined)
|
|
249262
|
+
});
|
|
249263
|
+
var ParameterListSchema = array(unknown());
|
|
249264
|
+
|
|
249265
|
+
// src/core/api-spec/text.ts
|
|
249266
|
+
var DOCS_CALLOUT = /<(Info|Note|Tip|Check|Warning)>([\s\S]*?)<\/\1>/g;
|
|
249267
|
+
var RELATIVE_LINK = /\[([^\]]+)\]\(\/[^)]*\)/g;
|
|
249268
|
+
function cleanText(text) {
|
|
249269
|
+
return text.replace(DOCS_CALLOUT, (_, kind, body) => kind === "Warning" ? `Warning: ${body}` : body).replace(RELATIVE_LINK, "$1");
|
|
249270
|
+
}
|
|
249271
|
+
|
|
249272
|
+
// src/core/api-spec/operations.ts
|
|
249273
|
+
var PERSONAL_ACCESS_TOKEN_SCHEME = "PersonalAccessTokenAuth";
|
|
249274
|
+
var READ_ONLY_SCOPE = "read_only";
|
|
249275
|
+
function isReadOnly(operation, spec) {
|
|
249276
|
+
const security = operation.security ?? spec.security ?? [];
|
|
249277
|
+
return security.some((requirement) => requirement[PERSONAL_ACCESS_TOKEN_SCHEME]?.includes(READ_ONLY_SCOPE));
|
|
249278
|
+
}
|
|
249279
|
+
function parameterText(operation) {
|
|
249280
|
+
return (operation.parameters ?? []).flatMap((parameter) => {
|
|
249281
|
+
const parsed = ParameterSchema.safeParse(parameter);
|
|
249282
|
+
return parsed.success ? [parsed.data.name, cleanText(parsed.data.description ?? "")] : [];
|
|
249283
|
+
}).join(" ");
|
|
249284
|
+
}
|
|
249285
|
+
var COMPONENT_REF = /^#\/components\/([^/]+)\/([^/]+)$/;
|
|
249286
|
+
function resolveComponentRef(spec, value) {
|
|
249287
|
+
const ref = value !== null && typeof value === "object" ? value.$ref : undefined;
|
|
249288
|
+
const match = typeof ref === "string" ? COMPONENT_REF.exec(ref) : null;
|
|
249289
|
+
if (!match?.[1] || !match[2]) {
|
|
249290
|
+
return value;
|
|
249291
|
+
}
|
|
249292
|
+
const components = spec.components;
|
|
249293
|
+
return components?.[match[1]]?.[match[2]] ?? value;
|
|
249294
|
+
}
|
|
249295
|
+
function mergeParameters(shared, own) {
|
|
249296
|
+
if (!shared?.length) {
|
|
249297
|
+
return own;
|
|
249298
|
+
}
|
|
249299
|
+
const key = (parameter) => {
|
|
249300
|
+
const parsed = ParameterSchema.safeParse(parameter);
|
|
249301
|
+
return parsed.success ? `${parsed.data.in}:${parsed.data.name}` : undefined;
|
|
249302
|
+
};
|
|
249303
|
+
const ownKeys = new Set((own ?? []).map(key));
|
|
249304
|
+
return [
|
|
249305
|
+
...shared.filter((parameter) => !ownKeys.has(key(parameter))),
|
|
249306
|
+
...own ?? []
|
|
249307
|
+
];
|
|
249308
|
+
}
|
|
249309
|
+
function listOperations(spec) {
|
|
249310
|
+
return Object.entries(spec.paths).flatMap(([path, item]) => HTTP_METHODS.flatMap((method) => {
|
|
249311
|
+
const parsed = OperationSchema.safeParse(item[method]);
|
|
249312
|
+
if (!parsed.success) {
|
|
249313
|
+
return [];
|
|
249314
|
+
}
|
|
249315
|
+
const shared = ParameterListSchema.safeParse(item.parameters);
|
|
249316
|
+
const resolve = (list) => list?.map((parameter) => resolveComponentRef(spec, parameter));
|
|
249317
|
+
const operation = {
|
|
249318
|
+
...parsed.data,
|
|
249319
|
+
parameters: mergeParameters(resolve(shared.success ? shared.data : undefined), resolve(parsed.data.parameters))
|
|
249320
|
+
};
|
|
249321
|
+
return [
|
|
249322
|
+
{
|
|
249323
|
+
endpoint: `${method.toUpperCase()} ${path}`,
|
|
249324
|
+
method: method.toUpperCase(),
|
|
249325
|
+
path,
|
|
249326
|
+
summary: operation.summary ?? "",
|
|
249327
|
+
description: cleanText(operation.description ?? ""),
|
|
249328
|
+
parameterText: parameterText(operation),
|
|
249329
|
+
readOnly: isReadOnly(operation, spec),
|
|
249330
|
+
operation
|
|
249331
|
+
}
|
|
249332
|
+
];
|
|
249333
|
+
}));
|
|
249334
|
+
}
|
|
249335
|
+
function pathSegments(path) {
|
|
249336
|
+
const pathname = path.split(/[?#]/, 1)[0] ?? "";
|
|
249337
|
+
return pathname.replace(/^\/+|\/+$/g, "").split("/");
|
|
249338
|
+
}
|
|
249339
|
+
function segmentPattern(segment) {
|
|
249340
|
+
const source = segment.split(/(\{[^}]+\})/).map((part) => part.startsWith("{") ? "[^/]+" : part.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")).join("");
|
|
249341
|
+
return new RegExp(`^${source}$`);
|
|
249342
|
+
}
|
|
249343
|
+
function literalSegments(path) {
|
|
249344
|
+
return pathSegments(path).map((segment) => segment.includes("{") ? "0" : "1").join("");
|
|
249345
|
+
}
|
|
249346
|
+
function matchOperation(operations, method, concretePath) {
|
|
249347
|
+
const upperMethod = method.toUpperCase();
|
|
249348
|
+
const segments = pathSegments(concretePath);
|
|
249349
|
+
const candidates = operations.filter((op) => {
|
|
249350
|
+
if (op.method !== upperMethod) {
|
|
249351
|
+
return false;
|
|
249352
|
+
}
|
|
249353
|
+
const template = pathSegments(op.path);
|
|
249354
|
+
return template.length === segments.length && template.every((part, i) => segmentPattern(part).test(segments[i] ?? ""));
|
|
249355
|
+
});
|
|
249356
|
+
return candidates.sort((a, b) => literalSegments(b.path).localeCompare(literalSegments(a.path)))[0];
|
|
249357
|
+
}
|
|
249358
|
+
|
|
249359
|
+
// src/core/api-spec/contract.ts
|
|
249360
|
+
var SCHEMA_REF_PREFIX = "#/components/schemas/";
|
|
249361
|
+
var MAX_REF_DEPTH = 4;
|
|
249362
|
+
function inlineRefs(node, schemas, seen = new Set, depth = 0) {
|
|
249363
|
+
if (depth > MAX_REF_DEPTH) {
|
|
249364
|
+
return node;
|
|
249365
|
+
}
|
|
249366
|
+
if (Array.isArray(node)) {
|
|
249367
|
+
return node.map((item) => inlineRefs(item, schemas, seen, depth));
|
|
249368
|
+
}
|
|
249369
|
+
if (node === null || typeof node !== "object") {
|
|
249370
|
+
return node;
|
|
249371
|
+
}
|
|
249372
|
+
const { $ref, ...siblings } = node;
|
|
249373
|
+
if (typeof $ref === "string" && $ref.startsWith(SCHEMA_REF_PREFIX)) {
|
|
249374
|
+
const name = $ref.slice(SCHEMA_REF_PREFIX.length);
|
|
249375
|
+
if (seen.has(name) || !(name in schemas)) {
|
|
249376
|
+
return node;
|
|
249377
|
+
}
|
|
249378
|
+
const resolved = inlineRefs(schemas[name], schemas, new Set([...seen, name]), depth + 1);
|
|
249379
|
+
return resolved !== null && typeof resolved === "object" ? { ...resolved, ...siblings } : resolved;
|
|
249380
|
+
}
|
|
249381
|
+
return Object.fromEntries(Object.entries(node).map(([key, value]) => [
|
|
249382
|
+
key,
|
|
249383
|
+
inlineRefs(value, schemas, seen, depth)
|
|
249384
|
+
]));
|
|
249385
|
+
}
|
|
249386
|
+
function bodyOf(value) {
|
|
249387
|
+
const parsed = MediaContentSchema.safeParse(value);
|
|
249388
|
+
const content = parsed.success ? parsed.data.content ?? {} : {};
|
|
249389
|
+
const contentType = "application/json" in content ? "application/json" : Object.keys(content)[0];
|
|
249390
|
+
return contentType ? { contentType, schema: content[contentType]?.schema } : {};
|
|
249391
|
+
}
|
|
249392
|
+
function leftoverRefs(node, schemas, found = new Map) {
|
|
249393
|
+
if (Array.isArray(node)) {
|
|
249394
|
+
for (const item of node) {
|
|
249395
|
+
leftoverRefs(item, schemas, found);
|
|
249396
|
+
}
|
|
249397
|
+
} else if (node !== null && typeof node === "object") {
|
|
249398
|
+
for (const [key, value] of Object.entries(node)) {
|
|
249399
|
+
if (key === "$ref" && typeof value === "string" && value.startsWith(SCHEMA_REF_PREFIX) && !found.has(value)) {
|
|
249400
|
+
const schema = schemas[value.slice(SCHEMA_REF_PREFIX.length)];
|
|
249401
|
+
if (schema !== undefined) {
|
|
249402
|
+
found.set(value, schema);
|
|
249403
|
+
leftoverRefs(schema, schemas, found);
|
|
249404
|
+
}
|
|
249405
|
+
} else {
|
|
249406
|
+
leftoverRefs(value, schemas, found);
|
|
249407
|
+
}
|
|
249408
|
+
}
|
|
249409
|
+
}
|
|
249410
|
+
return found;
|
|
249411
|
+
}
|
|
249412
|
+
var SCHEMA_DATA_KEYS = new Set([
|
|
249413
|
+
"example",
|
|
249414
|
+
"examples",
|
|
249415
|
+
"default",
|
|
249416
|
+
"enum",
|
|
249417
|
+
"const"
|
|
249418
|
+
]);
|
|
249419
|
+
function slimSchema(node, isPropertyMap = false) {
|
|
249420
|
+
if (Array.isArray(node)) {
|
|
249421
|
+
return node.map((item) => slimSchema(item));
|
|
249422
|
+
}
|
|
249423
|
+
if (node === null || typeof node !== "object") {
|
|
249424
|
+
return node;
|
|
249425
|
+
}
|
|
249426
|
+
const entries = Object.entries(node);
|
|
249427
|
+
if (isPropertyMap) {
|
|
249428
|
+
return Object.fromEntries(entries.map(([name, value]) => [name, slimSchema(value)]));
|
|
249429
|
+
}
|
|
249430
|
+
const slim = {};
|
|
249431
|
+
for (const [key, value] of entries) {
|
|
249432
|
+
if (key === "title" && typeof value === "string") {
|
|
249433
|
+
continue;
|
|
249434
|
+
}
|
|
249435
|
+
slim[key] = SCHEMA_DATA_KEYS.has(key) ? value : key === "properties" ? slimSchema(value, true) : key === "description" && typeof value === "string" ? cleanText(value) : slimSchema(value);
|
|
249436
|
+
}
|
|
249437
|
+
const { anyOf, ...rest } = slim;
|
|
249438
|
+
const nullable = Array.isArray(anyOf) && anyOf.length === 2 ? nullableType(anyOf) : undefined;
|
|
249439
|
+
return nullable ? { type: [nullable, "null"], ...rest } : slim;
|
|
249440
|
+
}
|
|
249441
|
+
function nullableType(variants) {
|
|
249442
|
+
const types = variants.map((variant) => variant !== null && typeof variant === "object" && Object.keys(variant).length === 1 && typeof variant.type === "string" ? variant.type : undefined);
|
|
249443
|
+
if (types.includes(undefined) || !types.includes("null")) {
|
|
249444
|
+
return;
|
|
249445
|
+
}
|
|
249446
|
+
return types.find((type) => type !== "null");
|
|
249447
|
+
}
|
|
249448
|
+
function getOperationContract(spec, op) {
|
|
249449
|
+
const schemas = spec.components?.schemas ?? {};
|
|
249450
|
+
const inline = (node) => node === undefined ? null : slimSchema(inlineRefs(node, schemas));
|
|
249451
|
+
const responses = Object.entries(op.operation.responses ?? {}).flatMap(([status, response]) => {
|
|
249452
|
+
const parsed = ResponseObjectSchema.safeParse(resolveComponentRef(spec, response));
|
|
249453
|
+
return parsed.success ? [[status, parsed.data]] : [];
|
|
249454
|
+
});
|
|
249455
|
+
const success = responses.filter(([status]) => status.startsWith("2")).sort(([a], [b]) => a.localeCompare(b)).map(([, response]) => bodyOf(response).schema).find(Boolean);
|
|
249456
|
+
const requestBody = bodyOf(resolveComponentRef(spec, op.operation.requestBody));
|
|
249457
|
+
const contract = {
|
|
249458
|
+
endpoint: op.endpoint,
|
|
249459
|
+
method: op.method,
|
|
249460
|
+
path: op.path,
|
|
249461
|
+
summary: op.summary,
|
|
249462
|
+
description: op.description,
|
|
249463
|
+
parameters: (op.operation.parameters ?? []).flatMap((parameter) => {
|
|
249464
|
+
const parsed = ParameterSchema.safeParse(parameter);
|
|
249465
|
+
if (!parsed.success) {
|
|
249466
|
+
return [parameter];
|
|
249467
|
+
}
|
|
249468
|
+
const { name, in: location2, required, schema, description } = parsed.data;
|
|
249469
|
+
const inSchema = schema !== null && typeof schema === "object" && "description" in schema;
|
|
249470
|
+
return [
|
|
249471
|
+
{
|
|
249472
|
+
name,
|
|
249473
|
+
in: location2,
|
|
249474
|
+
required: required ?? false,
|
|
249475
|
+
schema: inline(schema ?? {}),
|
|
249476
|
+
...description && !inSchema ? { description: cleanText(description) } : {},
|
|
249477
|
+
..."example" in parsed.data ? { example: parsed.data.example } : {}
|
|
249478
|
+
}
|
|
249479
|
+
];
|
|
249480
|
+
}),
|
|
249481
|
+
...requestBody.contentType && requestBody.contentType !== "application/json" ? { requestBodyContentType: requestBody.contentType } : {},
|
|
249482
|
+
requestBodySchema: inline(requestBody.schema),
|
|
249483
|
+
responseSchema: inline(success)
|
|
249484
|
+
};
|
|
249485
|
+
const refs = leftoverRefs(contract, schemas);
|
|
249486
|
+
return {
|
|
249487
|
+
...contract,
|
|
249488
|
+
...refs.size > 0 ? {
|
|
249489
|
+
refs: Object.fromEntries([...refs].map(([ref, schema]) => [ref, slimSchema(schema)]))
|
|
249490
|
+
} : {}
|
|
249491
|
+
};
|
|
249492
|
+
}
|
|
249493
|
+
// src/core/api-spec/grep.ts
|
|
249494
|
+
function grepOperations(spec, operations, pattern, options = {}) {
|
|
249495
|
+
const regex = new RegExp(pattern, options.ignoreCase ? "i" : "");
|
|
249496
|
+
return operations.filter((op) => regex.test(JSON.stringify(getOperationContract(spec, op)))).slice(0, options.limit ?? 20).map(toOperationSummary);
|
|
249497
|
+
}
|
|
249498
|
+
// src/core/api-spec/request.ts
|
|
249499
|
+
var MAX_ERROR_BODY_CHARS = 4000;
|
|
249500
|
+
var QUERY_STRING = /\?\S*/g;
|
|
249501
|
+
async function readBody(response) {
|
|
249502
|
+
try {
|
|
249503
|
+
const text = (await response.clone().text()).trim();
|
|
249504
|
+
return text.length > MAX_ERROR_BODY_CHARS ? `${text.slice(0, MAX_ERROR_BODY_CHARS)}…` : text || undefined;
|
|
249505
|
+
} catch {
|
|
249506
|
+
return;
|
|
249507
|
+
}
|
|
249508
|
+
}
|
|
249509
|
+
function normalizePath(path) {
|
|
249510
|
+
const url = new URL(path.replace(/^\/*/, "/"), "http://placeholder");
|
|
249511
|
+
return `${url.pathname}${url.search}`;
|
|
249512
|
+
}
|
|
249513
|
+
async function sendApiRequest(method, path, body) {
|
|
249514
|
+
try {
|
|
249515
|
+
const response = await base44Client(path.replace(/^\/+/, ""), {
|
|
249516
|
+
method,
|
|
249517
|
+
body,
|
|
249518
|
+
headers: typeof body === "string" ? { "Content-Type": "application/json" } : {},
|
|
249519
|
+
timeout: false,
|
|
249520
|
+
retry: { methods: ["get", "head"] }
|
|
249521
|
+
});
|
|
249522
|
+
return {
|
|
249523
|
+
status: response.status,
|
|
249524
|
+
contentType: response.headers.get("content-type") ?? "",
|
|
249525
|
+
body: new Uint8Array(await response.arrayBuffer())
|
|
249526
|
+
};
|
|
249527
|
+
} catch (error) {
|
|
249528
|
+
const apiError = await ApiError.fromHttpError(error, `calling ${method} ${path}`);
|
|
249529
|
+
const response = error instanceof HTTPError ? error.response : undefined;
|
|
249530
|
+
const raw = response ? await readBody(response) : undefined;
|
|
249531
|
+
const retryAfter = response?.headers.get("retry-after") ?? undefined;
|
|
249532
|
+
throw redactedApiError(apiError, raw, method, path, retryAfter);
|
|
249533
|
+
}
|
|
249534
|
+
}
|
|
249535
|
+
function redactedApiError(apiError, raw, method, path, retryAfter) {
|
|
249536
|
+
const wait = retryAfter ? ` (retry after ${/^\d+$/.test(retryAfter) ? `${retryAfter} s` : retryAfter})` : "";
|
|
249537
|
+
const reason = apiError.statusCode !== undefined ? `HTTP ${apiError.statusCode}${wait}` : (apiError.cause?.message ?? "request failed").replace(QUERY_STRING, "");
|
|
249538
|
+
const message = `Error calling ${method} ${path.split("?", 1)[0]}: ${reason}`;
|
|
249539
|
+
return new ApiError(message, {
|
|
249540
|
+
statusCode: apiError.statusCode,
|
|
249541
|
+
requestUrl: apiError.requestUrl?.split("?", 1)[0],
|
|
249542
|
+
requestMethod: apiError.requestMethod,
|
|
249543
|
+
requestId: apiError.requestId,
|
|
249544
|
+
hints: apiError.hints,
|
|
249545
|
+
details: [
|
|
249546
|
+
...raw ? [`Response body: ${raw}`] : apiError.details ?? [],
|
|
249547
|
+
...apiError.requestId ? [`Request ID: ${apiError.requestId}`] : []
|
|
249548
|
+
]
|
|
249549
|
+
});
|
|
249550
|
+
}
|
|
249551
|
+
// src/core/api-spec/spec.ts
|
|
249552
|
+
import { rename, rm, stat as stat3 } from "node:fs/promises";
|
|
249553
|
+
import { join as join22 } from "node:path";
|
|
249554
|
+
var SPEC_CACHE_TTL_MS = 60 * 60 * 1000;
|
|
249555
|
+
function getSpecCachePath(apiUrl = getBase44ApiUrl()) {
|
|
249556
|
+
const server = new URL(apiUrl).host.replace(/[^a-zA-Z0-9.-]/g, "_");
|
|
249557
|
+
return join22(getBase44GlobalDir(), "cache", server, "openapi.json");
|
|
249558
|
+
}
|
|
249559
|
+
function isSpecCacheFresh(mtimeMs, now = Date.now()) {
|
|
249560
|
+
return now - mtimeMs < SPEC_CACHE_TTL_MS;
|
|
249561
|
+
}
|
|
249562
|
+
function parseSpec(text) {
|
|
249563
|
+
let json;
|
|
249564
|
+
try {
|
|
249565
|
+
json = JSON.parse(text);
|
|
249566
|
+
} catch {
|
|
249567
|
+
throw new ApiError("The API spec from the server is not valid JSON");
|
|
249568
|
+
}
|
|
249569
|
+
const result = OpenApiSpecSchema.safeParse(json);
|
|
249570
|
+
if (!result.success) {
|
|
249571
|
+
throw new SchemaValidationError("Invalid API spec", result.error);
|
|
249572
|
+
}
|
|
249573
|
+
return result.data;
|
|
249574
|
+
}
|
|
249575
|
+
var SPEC_DOWNLOAD_TIMEOUT_MS = 60000;
|
|
249576
|
+
async function readFreshCache(path) {
|
|
249577
|
+
try {
|
|
249578
|
+
const { mtimeMs } = await stat3(path);
|
|
249579
|
+
if (!isSpecCacheFresh(mtimeMs)) {
|
|
249580
|
+
return null;
|
|
249581
|
+
}
|
|
249582
|
+
const text = await readTextFile(path);
|
|
249583
|
+
return { text, spec: parseSpec(text) };
|
|
249584
|
+
} catch {
|
|
249585
|
+
return null;
|
|
249586
|
+
}
|
|
249587
|
+
}
|
|
249588
|
+
async function downloadSpec() {
|
|
249589
|
+
try {
|
|
249590
|
+
const response = await base44Client.get("api/openapi.json", {
|
|
249591
|
+
timeout: SPEC_DOWNLOAD_TIMEOUT_MS
|
|
249592
|
+
});
|
|
249593
|
+
return await response.text();
|
|
249594
|
+
} catch (error) {
|
|
249595
|
+
throw await ApiError.fromHttpError(error, "fetching the API spec");
|
|
249596
|
+
}
|
|
249597
|
+
}
|
|
249598
|
+
async function loadSpec(options = {}) {
|
|
249599
|
+
const path = getSpecCachePath();
|
|
249600
|
+
const cached = options.refresh ? null : await readFreshCache(path);
|
|
249601
|
+
if (cached !== null) {
|
|
249602
|
+
return cached;
|
|
249603
|
+
}
|
|
249604
|
+
const text = await downloadSpec();
|
|
249605
|
+
const spec = parseSpec(text);
|
|
249606
|
+
const partial = `${path}.${process.pid}.tmp`;
|
|
249607
|
+
try {
|
|
249608
|
+
await writeFile(partial, text);
|
|
249609
|
+
await rename(partial, path);
|
|
249610
|
+
} catch {
|
|
249611
|
+
await rm(partial, { force: true }).catch(() => {
|
|
249612
|
+
return;
|
|
249613
|
+
});
|
|
249614
|
+
}
|
|
249615
|
+
return { text, spec };
|
|
249616
|
+
}
|
|
249617
|
+
// src/cli/commands/api/shared.ts
|
|
249618
|
+
import { basename as basename6 } from "node:path";
|
|
249619
|
+
function formatJson(value) {
|
|
249620
|
+
return toJsonStdout(value, { compact: !process.stdout.isTTY });
|
|
249621
|
+
}
|
|
249622
|
+
function parseLimit(value) {
|
|
249623
|
+
if (value === undefined) {
|
|
249624
|
+
return;
|
|
249625
|
+
}
|
|
249626
|
+
const n = Number.parseInt(value, 10);
|
|
249627
|
+
if (!Number.isInteger(n) || n < 1) {
|
|
249628
|
+
throw new InvalidInputError("--limit must be a positive integer.");
|
|
249629
|
+
}
|
|
249630
|
+
return n;
|
|
249631
|
+
}
|
|
249632
|
+
var READ_ONLY_FILTER_HELP = "Only read-only operations";
|
|
249633
|
+
var REFRESH_OPTION_HELP = "Fetch the API spec again instead of using the cached copy (kept 1 hour)";
|
|
249634
|
+
function loadSpecTask({ runTask }, refresh) {
|
|
249635
|
+
return runTask("Loading the API spec", () => loadSpec({ refresh }), {
|
|
249636
|
+
successMessage: "Loaded the API spec"
|
|
249637
|
+
});
|
|
249638
|
+
}
|
|
249639
|
+
function operationsInArea(operations, area) {
|
|
249640
|
+
const areas = groupByArea(operations);
|
|
249641
|
+
const inArea = areas.get(area);
|
|
249642
|
+
if (!inArea) {
|
|
249643
|
+
throw new InvalidInputError(`Unknown API area: ${area}`, {
|
|
249644
|
+
details: [`Areas: ${[...areas.keys()].join(", ")}`],
|
|
249645
|
+
hints: [{ message: "List the areas", command: "base44 api catalog" }]
|
|
249646
|
+
});
|
|
249647
|
+
}
|
|
249648
|
+
return inArea;
|
|
249649
|
+
}
|
|
249650
|
+
async function readRequestBody(flag) {
|
|
249651
|
+
if (flag === "@-") {
|
|
249652
|
+
return readStdin("--body @-", { trim: false });
|
|
249653
|
+
}
|
|
249654
|
+
if (flag?.startsWith("@")) {
|
|
249655
|
+
return readTextFile(flag.slice(1));
|
|
249656
|
+
}
|
|
249657
|
+
return flag;
|
|
249658
|
+
}
|
|
249659
|
+
var FORM_FILE = /^@(.+?)(?:;type=([^;]+))?$/;
|
|
249660
|
+
async function readFormBody(fields) {
|
|
249661
|
+
const form = new FormData;
|
|
249662
|
+
for (const field of fields) {
|
|
249663
|
+
const separator = field.indexOf("=");
|
|
249664
|
+
if (separator < 1) {
|
|
249665
|
+
throw new InvalidInputError(`--form takes name=value or name=@file, got "${field}".`);
|
|
249666
|
+
}
|
|
249667
|
+
const name = field.slice(0, separator);
|
|
249668
|
+
const value = field.slice(separator + 1);
|
|
249669
|
+
const file = FORM_FILE.exec(value);
|
|
249670
|
+
if (file?.[1]) {
|
|
249671
|
+
const type = file[2] ?? "application/octet-stream";
|
|
249672
|
+
const blob = new Blob([await readFile(file[1])], { type });
|
|
249673
|
+
form.append(name, blob, basename6(file[1]));
|
|
249674
|
+
} else {
|
|
249675
|
+
form.append(name, value);
|
|
249676
|
+
}
|
|
249677
|
+
}
|
|
249678
|
+
return form;
|
|
249679
|
+
}
|
|
249680
|
+
function withoutQuery(path) {
|
|
249681
|
+
return path.split("?", 1)[0] ?? "";
|
|
249682
|
+
}
|
|
249683
|
+
function reportedFetchCommand(method, path, options) {
|
|
249684
|
+
return {
|
|
249685
|
+
name: "api fetch",
|
|
249686
|
+
args: [method, withoutQuery(path)],
|
|
249687
|
+
options: {
|
|
249688
|
+
...options,
|
|
249689
|
+
...options.body === undefined ? {} : { body: "[not reported]" },
|
|
249690
|
+
...Array.isArray(options.form) && options.form.length > 0 ? { form: "[not reported]" } : {}
|
|
249691
|
+
}
|
|
249692
|
+
};
|
|
249693
|
+
}
|
|
249694
|
+
|
|
249695
|
+
// src/cli/commands/api/catalog.ts
|
|
249696
|
+
async function catalogAction(ctx, area, options) {
|
|
249697
|
+
const { spec } = await loadSpecTask(ctx, options.refresh);
|
|
249698
|
+
const operations = listOperations(spec);
|
|
249699
|
+
const filterReadOnly = (ops) => options.readOnly ? ops.filter((op) => op.readOnly) : ops;
|
|
249700
|
+
if (!area) {
|
|
249701
|
+
return { stdout: formatJson(catalogIndex(filterReadOnly(operations))) };
|
|
249702
|
+
}
|
|
249703
|
+
const inArea = filterReadOnly(operationsInArea(operations, area));
|
|
249704
|
+
return { stdout: formatJson(areaListing(area, inArea)) };
|
|
249705
|
+
}
|
|
249706
|
+
function getApiCatalogCommand() {
|
|
249707
|
+
return new Base44Command("catalog", {
|
|
249708
|
+
requireAuth: false,
|
|
249709
|
+
requireAppContext: false
|
|
249710
|
+
}).description("List the API's areas, or every operation in one area").argument("[area]", 'An area from the list, e.g. "workflows"').option("--read-only", READ_ONLY_FILTER_HELP).option("--refresh", REFRESH_OPTION_HELP).action(catalogAction);
|
|
249711
|
+
}
|
|
249712
|
+
|
|
249713
|
+
// src/cli/commands/api/fetch.ts
|
|
249714
|
+
async function findOperation(ctx, method, path, { refresh, flag }) {
|
|
249715
|
+
const { spec } = await loadSpecTask(ctx, refresh);
|
|
249716
|
+
const op = matchOperation(listOperations(spec), method, path);
|
|
249717
|
+
if (!op) {
|
|
249718
|
+
throw new InvalidInputError(`No operation in the API spec matches ${method} ${withoutQuery(path)}.`, {
|
|
249719
|
+
hints: [
|
|
249720
|
+
{
|
|
249721
|
+
message: "The cached spec may predate this route; fetch it again",
|
|
249722
|
+
command: `base44 api fetch ${method} ${path} ${flag} --refresh`
|
|
249723
|
+
},
|
|
249724
|
+
{
|
|
249725
|
+
message: "Find the operation and its path template",
|
|
249726
|
+
command: 'base44 api search "<what you want to do>"'
|
|
249727
|
+
}
|
|
249728
|
+
]
|
|
249729
|
+
});
|
|
249730
|
+
}
|
|
249731
|
+
return { spec, op };
|
|
249732
|
+
}
|
|
249733
|
+
var ENCODED_SEPARATOR = /%(2f|5c|2e)/i;
|
|
249734
|
+
async function fillAppId(ctx, path, command) {
|
|
249735
|
+
let filled = path;
|
|
249736
|
+
if (withoutQuery(path).includes("{app_id}")) {
|
|
249737
|
+
const { appId } = command.optsWithGlobals();
|
|
249738
|
+
await ensureAppContext(ctx, { appId });
|
|
249739
|
+
filled = path.replaceAll("{app_id}", requireApp(ctx).id);
|
|
249740
|
+
}
|
|
249741
|
+
const placeholder = withoutQuery(filled).match(/\{[^}/]*\}/);
|
|
249742
|
+
if (placeholder) {
|
|
249743
|
+
throw new InvalidInputError(`Replace ${placeholder[0]} in the path with a real value; only {app_id} is filled in.`);
|
|
249744
|
+
}
|
|
249745
|
+
return filled;
|
|
249746
|
+
}
|
|
249747
|
+
var MULTIPART_HINT = "Send this body with --form name=value, and --form name=@path for files.";
|
|
249748
|
+
var CONTRACT_HELP = "The contract is JSON; cut it down with e.g. | jq '.parameters, .requestBodySchema'";
|
|
249749
|
+
var TEXT_CONTENT_TYPES = [
|
|
249750
|
+
"json",
|
|
249751
|
+
"text/",
|
|
249752
|
+
"xml",
|
|
249753
|
+
"javascript",
|
|
249754
|
+
"x-www-form-urlencoded"
|
|
249755
|
+
];
|
|
249756
|
+
function decodeText(body, contentType) {
|
|
249757
|
+
const type = contentType.toLowerCase();
|
|
249758
|
+
if (type && !TEXT_CONTENT_TYPES.some((hint) => type.includes(hint))) {
|
|
249759
|
+
return;
|
|
249760
|
+
}
|
|
249761
|
+
try {
|
|
249762
|
+
return new TextDecoder("utf-8", { fatal: true }).decode(body);
|
|
249763
|
+
} catch {
|
|
249764
|
+
return;
|
|
249765
|
+
}
|
|
249766
|
+
}
|
|
249767
|
+
async function formatResponse({ status, contentType, body }, output, jsonMode) {
|
|
249768
|
+
if (output) {
|
|
249769
|
+
await writeFile(output, body);
|
|
249770
|
+
return formatJson({ status, contentType, bytes: body.length, output });
|
|
249771
|
+
}
|
|
249772
|
+
if (body.length === 0) {
|
|
249773
|
+
return formatJson({ status });
|
|
249774
|
+
}
|
|
249775
|
+
const text = decodeText(body, contentType);
|
|
249776
|
+
if (text === undefined) {
|
|
249777
|
+
return formatJson({
|
|
249778
|
+
status,
|
|
249779
|
+
contentType,
|
|
249780
|
+
bytes: body.length,
|
|
249781
|
+
note: "Binary body not printed; add --output <file> to save it."
|
|
249782
|
+
});
|
|
249783
|
+
}
|
|
249784
|
+
const asIs = text.endsWith(`
|
|
249785
|
+
`) ? text : `${text}
|
|
249786
|
+
`;
|
|
249787
|
+
try {
|
|
249788
|
+
const parsed = JSON.parse(text);
|
|
249789
|
+
return process.stdout.isTTY ? formatJson(parsed) : asIs;
|
|
249790
|
+
} catch {
|
|
249791
|
+
return jsonMode ? formatJson({ status, contentType, body: text }) : asIs;
|
|
249792
|
+
}
|
|
249793
|
+
}
|
|
249794
|
+
async function fetchAction(ctx, methodArg, path, options, command) {
|
|
249795
|
+
ctx.errorReporter.setContext({
|
|
249796
|
+
command: reportedFetchCommand(methodArg ?? "", path ?? "", { ...options })
|
|
249797
|
+
});
|
|
249798
|
+
if (!methodArg || !path) {
|
|
249799
|
+
if (options.help) {
|
|
249800
|
+
const usage = `${command.helpInformation()}
|
|
249801
|
+
${CONTRACT_HELP}
|
|
249802
|
+
`;
|
|
249803
|
+
return { stdout: ctx.jsonMode ? formatJson({ usage }) : usage };
|
|
249804
|
+
}
|
|
249805
|
+
throw new InvalidInputError("Provide a method and a path, e.g. GET /api/apps.");
|
|
249806
|
+
}
|
|
249807
|
+
const method = methodArg.toUpperCase();
|
|
249808
|
+
if (options.help) {
|
|
249809
|
+
const { spec, op } = await findOperation(ctx, method, normalizePath(path), {
|
|
249810
|
+
refresh: options.refresh,
|
|
249811
|
+
flag: "--help"
|
|
249812
|
+
});
|
|
249813
|
+
const contract = getOperationContract(spec, op);
|
|
249814
|
+
return {
|
|
249815
|
+
stdout: formatJson(contract.requestBodyContentType === "multipart/form-data" ? { ...contract, hint: MULTIPART_HINT } : contract)
|
|
249816
|
+
};
|
|
249817
|
+
}
|
|
249818
|
+
const target = normalizePath(await fillAppId(ctx, path, command));
|
|
249819
|
+
if (options.readOnly) {
|
|
249820
|
+
if (ENCODED_SEPARATOR.test(withoutQuery(target))) {
|
|
249821
|
+
throw new InvalidInputError("Refused under --read-only: the path has an encoded /, \\ or ., so it can't be checked. Nothing was sent.");
|
|
249822
|
+
}
|
|
249823
|
+
const { op } = await findOperation(ctx, method, target, {
|
|
249824
|
+
refresh: options.refresh,
|
|
249825
|
+
flag: "--read-only"
|
|
249826
|
+
});
|
|
249827
|
+
if (!op.readOnly) {
|
|
249828
|
+
throw new InvalidInputError(`Refused under --read-only: ${op.method} ${op.path} is not a read-only operation. Nothing was sent.`);
|
|
249829
|
+
}
|
|
249830
|
+
}
|
|
249831
|
+
if (options.body !== undefined && options.form.length > 0) {
|
|
249832
|
+
throw new InvalidInputError("Use --body or --form, not both.");
|
|
249833
|
+
}
|
|
249834
|
+
await ensureAuth(ctx);
|
|
249835
|
+
const body = options.form.length > 0 ? await readFormBody(options.form) : await readRequestBody(options.body);
|
|
249836
|
+
const response = await ctx.runTask(`Calling ${method} ${target}`, () => sendApiRequest(method, target, body), {
|
|
249837
|
+
successMessage: `Called ${method} ${target}`,
|
|
249838
|
+
errorMessage: "Request failed"
|
|
249839
|
+
});
|
|
249840
|
+
return {
|
|
249841
|
+
stdout: await formatResponse(response, options.output, ctx.jsonMode)
|
|
249842
|
+
};
|
|
249843
|
+
}
|
|
249844
|
+
function getApiFetchCommand() {
|
|
249845
|
+
return new Base44Command("fetch", {
|
|
249846
|
+
requireAuth: false,
|
|
249847
|
+
requireAppContext: false
|
|
249848
|
+
}).description("Call a Base44 API operation; add --help after a path for its contract").helpOption(false).argument("[method]", "HTTP method, e.g. GET or POST").argument("[path]", 'Path with any query string; {app_id} is filled from --app-id or the project, e.g. "/api/apps/{app_id}/workflows/runs?status=failed"').option("--body <json>", "Request body: JSON, @file.json, or @- to read it from stdin").option("--form <field>", "Multipart field: name=value, or name=@file to attach a file (repeatable)", (field, fields) => [...fields, field], []).option("--output <file>", "Save the response body to a file").option("--read-only", "Refuse, before sending, any operation the spec does not mark read-only").option("--refresh", REFRESH_OPTION_HELP).option("-h, --help", "With a method and path, print that operation's contract; otherwise this help").addHelpText("after", `
|
|
249849
|
+
${CONTRACT_HELP}`).action(fetchAction);
|
|
249850
|
+
}
|
|
249851
|
+
|
|
249852
|
+
// src/cli/commands/api/grep.ts
|
|
249853
|
+
function assertValidRegex(pattern) {
|
|
249854
|
+
try {
|
|
249855
|
+
new RegExp(pattern);
|
|
249856
|
+
} catch (error) {
|
|
249857
|
+
throw new InvalidInputError(`Invalid regular expression: ${error instanceof Error ? error.message : pattern}`);
|
|
249858
|
+
}
|
|
249859
|
+
}
|
|
249860
|
+
async function grepAction(ctx, pattern, options) {
|
|
249861
|
+
const limit = parseLimit(options.limit);
|
|
249862
|
+
assertValidRegex(pattern);
|
|
249863
|
+
const { spec } = await loadSpecTask(ctx, options.refresh);
|
|
249864
|
+
let operations = listOperations(spec);
|
|
249865
|
+
if (options.area) {
|
|
249866
|
+
operations = operationsInArea(operations, options.area);
|
|
249867
|
+
}
|
|
249868
|
+
if (options.readOnly) {
|
|
249869
|
+
operations = operations.filter((op) => op.readOnly);
|
|
249870
|
+
}
|
|
249871
|
+
const hits = grepOperations(spec, operations, pattern, {
|
|
249872
|
+
ignoreCase: options.ignoreCase,
|
|
249873
|
+
limit
|
|
249874
|
+
});
|
|
249875
|
+
return { stdout: formatJson(hits) };
|
|
249876
|
+
}
|
|
249877
|
+
function getApiGrepCommand() {
|
|
249878
|
+
return new Base44Command("grep", {
|
|
249879
|
+
requireAuth: false,
|
|
249880
|
+
requireAppContext: false
|
|
249881
|
+
}).description("Search the API spec with a regular expression, for when search misses").argument("<pattern>", `Regular expression over each operation's contract as JSON text (quotes and newlines appear escaped), e.g. "runs.*status"`).option("--area <area>", "Search only one area's operations (see base44 api catalog)").option("-i, --ignore-case", "Case-insensitive match").option("--limit <n>", "Most operations to return (default 20)").option("--read-only", READ_ONLY_FILTER_HELP).option("--refresh", REFRESH_OPTION_HELP).action(grepAction);
|
|
249882
|
+
}
|
|
249883
|
+
|
|
249884
|
+
// src/cli/commands/api/search.ts
|
|
249885
|
+
async function searchAction(ctx, words, options) {
|
|
249886
|
+
const limit = parseLimit(options.limit);
|
|
249887
|
+
const { spec } = await loadSpecTask(ctx, options.refresh);
|
|
249888
|
+
const results = searchOperations(listOperations(spec), words.join(" "), {
|
|
249889
|
+
limit,
|
|
249890
|
+
readOnly: options.readOnly
|
|
249891
|
+
});
|
|
249892
|
+
return { stdout: formatJson(results) };
|
|
249893
|
+
}
|
|
249894
|
+
function getApiSearchCommand() {
|
|
249895
|
+
return new Base44Command("search", {
|
|
249896
|
+
requireAuth: false,
|
|
249897
|
+
requireAppContext: false
|
|
249898
|
+
}).description("Search every Base44 API operation by what it does").argument("<text...>", 'What you are looking for, e.g. "failed workflow runs"').option("--limit <n>", "Most results to return (default 5)").option("--read-only", READ_ONLY_FILTER_HELP).option("--refresh", REFRESH_OPTION_HELP).action(searchAction);
|
|
249899
|
+
}
|
|
249900
|
+
|
|
249901
|
+
// src/cli/commands/api/index.ts
|
|
249902
|
+
function getApiCommand() {
|
|
249903
|
+
return new Command2("api").description("Search and call any public Base44 API operation").addCommand(getApiCatalogCommand()).addCommand(getApiSearchCommand()).addCommand(getApiGrepCommand()).addCommand(getApiFetchCommand());
|
|
249904
|
+
}
|
|
249905
|
+
|
|
248045
249906
|
// src/cli/commands/auth/password-login.ts
|
|
248046
|
-
import { dirname as dirname16, join as
|
|
249907
|
+
import { dirname as dirname16, join as join23 } from "node:path";
|
|
248047
249908
|
async function passwordLoginAction({ log, runTask }, action) {
|
|
248048
249909
|
const shouldEnable = action === "enable";
|
|
248049
249910
|
const { project } = await readProjectConfig();
|
|
248050
249911
|
const configDir = dirname16(project.configPath);
|
|
248051
|
-
const authDir =
|
|
249912
|
+
const authDir = join23(configDir, project.authDir);
|
|
248052
249913
|
const updated = await runTask("Updating local auth config", async () => {
|
|
248053
249914
|
const current = await readAuthConfig(authDir) ?? DEFAULT_AUTH_CONFIG;
|
|
248054
249915
|
const merged = { ...current, enableUsernamePassword: shouldEnable };
|
|
@@ -248068,14 +249929,14 @@ function getPasswordLoginCommand() {
|
|
|
248068
249929
|
}
|
|
248069
249930
|
|
|
248070
249931
|
// src/cli/commands/auth/pull.ts
|
|
248071
|
-
import { dirname as dirname17, join as
|
|
249932
|
+
import { dirname as dirname17, join as join24 } from "node:path";
|
|
248072
249933
|
async function pullAuthAction({
|
|
248073
249934
|
log,
|
|
248074
249935
|
runTask
|
|
248075
249936
|
}) {
|
|
248076
249937
|
const { project } = await readProjectConfig();
|
|
248077
249938
|
const configDir = dirname17(project.configPath);
|
|
248078
|
-
const authDir =
|
|
249939
|
+
const authDir = join24(configDir, project.authDir);
|
|
248079
249940
|
const remoteConfig = await runTask("Fetching auth config from Base44", async () => {
|
|
248080
249941
|
return await pullAuthConfig();
|
|
248081
249942
|
}, {
|
|
@@ -248139,7 +250000,7 @@ function getAuthPushCommand() {
|
|
|
248139
250000
|
}
|
|
248140
250001
|
|
|
248141
250002
|
// src/cli/commands/auth/social-login.ts
|
|
248142
|
-
import { dirname as dirname18, join as
|
|
250003
|
+
import { dirname as dirname18, join as join25, resolve as resolve7 } from "node:path";
|
|
248143
250004
|
var PROVIDER_LABELS = {
|
|
248144
250005
|
google: "Google",
|
|
248145
250006
|
microsoft: "Microsoft",
|
|
@@ -248210,7 +250071,7 @@ async function socialLoginAction({ log, isNonInteractive, runTask }, provider, a
|
|
|
248210
250071
|
}
|
|
248211
250072
|
const { project } = await readProjectConfig();
|
|
248212
250073
|
const configDir = dirname18(project.configPath);
|
|
248213
|
-
const authDir =
|
|
250074
|
+
const authDir = join25(configDir, project.authDir);
|
|
248214
250075
|
const { config: updated } = await runTask("Updating local auth config", async () => updateSocialLoginConfig(authDir, provider, shouldEnable, useCustomOAuth && options.clientId ? { clientId: options.clientId } : undefined));
|
|
248215
250076
|
if (clientSecret) {
|
|
248216
250077
|
await runTask("Saving client secret", async () => pushCustomOAuthSecret(provider, clientSecret));
|
|
@@ -248235,7 +250096,7 @@ function getSocialLoginCommand() {
|
|
|
248235
250096
|
}
|
|
248236
250097
|
|
|
248237
250098
|
// src/cli/commands/auth/sso.ts
|
|
248238
|
-
import { dirname as dirname19, join as
|
|
250099
|
+
import { dirname as dirname19, join as join26, resolve as resolve8 } from "node:path";
|
|
248239
250100
|
var SSOConfigFileSchema = object({
|
|
248240
250101
|
provider: _enum(Object.values(KNOWN_SSO_PROVIDERS)),
|
|
248241
250102
|
clientId: string2(),
|
|
@@ -248399,7 +250260,7 @@ async function ssoEnableAction({ isNonInteractive, runTask }, options) {
|
|
|
248399
250260
|
}
|
|
248400
250261
|
const { project } = await readProjectConfig();
|
|
248401
250262
|
const configDir = dirname19(project.configPath);
|
|
248402
|
-
const authDir =
|
|
250263
|
+
const authDir = join26(configDir, project.authDir);
|
|
248403
250264
|
await runTask("Updating local auth config", async () => updateSSOConfig(authDir, provider, true));
|
|
248404
250265
|
await runTask("Saving SSO credentials", async () => pushSSOSecrets(secrets));
|
|
248405
250266
|
return {
|
|
@@ -248415,7 +250276,7 @@ async function ssoDisableAction({ log, runTask }, options) {
|
|
|
248415
250276
|
}
|
|
248416
250277
|
const { project } = await readProjectConfig();
|
|
248417
250278
|
const configDir = dirname19(project.configPath);
|
|
248418
|
-
const authDir =
|
|
250279
|
+
const authDir = join26(configDir, project.authDir);
|
|
248419
250280
|
const updated = await runTask("Updating local auth config", async () => updateSSOConfig(authDir, null, false));
|
|
248420
250281
|
await runTask("Removing SSO credentials", async () => deleteSSOSecrets());
|
|
248421
250282
|
if (!hasAnyLoginMethod(updated)) {
|
|
@@ -249297,13 +251158,13 @@ function getConnectorsListAvailableCommand() {
|
|
|
249297
251158
|
}
|
|
249298
251159
|
|
|
249299
251160
|
// src/cli/commands/connectors/pull.ts
|
|
249300
|
-
import { dirname as dirname20, join as
|
|
251161
|
+
import { dirname as dirname20, join as join27, resolve as resolve9 } from "node:path";
|
|
249301
251162
|
async function resolveConnectorsDir(options) {
|
|
249302
251163
|
if (!getAppContext().projectRoot) {
|
|
249303
251164
|
return resolve9(options.dir ?? "connectors");
|
|
249304
251165
|
}
|
|
249305
251166
|
const { project } = await readProjectConfig();
|
|
249306
|
-
return
|
|
251167
|
+
return join27(dirname20(project.configPath), project.connectorsDir);
|
|
249307
251168
|
}
|
|
249308
251169
|
async function pullConnectorsAction({ log, runTask, jsonMode }, options) {
|
|
249309
251170
|
const connectorsDir = await resolveConnectorsDir(options);
|
|
@@ -249690,11 +251551,11 @@ function getListCommand() {
|
|
|
249690
251551
|
}
|
|
249691
251552
|
|
|
249692
251553
|
// src/cli/commands/functions/pull.ts
|
|
249693
|
-
import { dirname as dirname21, join as
|
|
251554
|
+
import { dirname as dirname21, join as join28 } from "node:path";
|
|
249694
251555
|
async function pullFunctionsAction({ log, runTask }, name) {
|
|
249695
251556
|
const { project, functions } = await readProjectConfig();
|
|
249696
251557
|
const configDir = dirname21(project.configPath);
|
|
249697
|
-
const functionsDir =
|
|
251558
|
+
const functionsDir = join28(configDir, project.functionsDir);
|
|
249698
251559
|
const pluginFunctionNames = new Set(functions.filter((fn) => fn.source.type === "plugin").map((fn) => fn.name));
|
|
249699
251560
|
const remoteFunctions = await runTask("Fetching functions from Base44", async () => {
|
|
249700
251561
|
const { functions } = await listDeployedFunctions();
|
|
@@ -249804,11 +251665,11 @@ function getBuildCommand() {
|
|
|
249804
251665
|
}
|
|
249805
251666
|
|
|
249806
251667
|
// src/cli/commands/project/create.ts
|
|
249807
|
-
import { basename as
|
|
251668
|
+
import { basename as basename7, resolve as resolve11 } from "node:path";
|
|
249808
251669
|
var import_kebabCase = __toESM(require_kebabCase(), 1);
|
|
249809
251670
|
|
|
249810
251671
|
// src/cli/commands/project/scaffold-shared.ts
|
|
249811
|
-
import { join as
|
|
251672
|
+
import { join as join29 } from "node:path";
|
|
249812
251673
|
var DEFAULT_TEMPLATE_ID = "backend-only";
|
|
249813
251674
|
async function getTemplateById(templateId) {
|
|
249814
251675
|
const templates = await listTemplates();
|
|
@@ -249871,7 +251732,7 @@ async function completeProjectSetup({
|
|
|
249871
251732
|
env: { VITE_BASE44_APP_ID: projectId }
|
|
249872
251733
|
})`${buildCommand}`;
|
|
249873
251734
|
updateMessage("Deploying site...");
|
|
249874
|
-
return await deploySite(
|
|
251735
|
+
return await deploySite(join29(resolvedPath, outputDirectory));
|
|
249875
251736
|
}, {
|
|
249876
251737
|
successMessage: theme.colors.base44Orange("Site deployed successfully"),
|
|
249877
251738
|
errorMessage: "Failed to deploy site"
|
|
@@ -249969,8 +251830,8 @@ async function createInteractive(options, ctx) {
|
|
|
249969
251830
|
name: () => {
|
|
249970
251831
|
return options.name ? Promise.resolve(options.name) : Ze({
|
|
249971
251832
|
message: "What is the name of your project?",
|
|
249972
|
-
placeholder:
|
|
249973
|
-
initialValue:
|
|
251833
|
+
placeholder: basename7(process.cwd()),
|
|
251834
|
+
initialValue: basename7(process.cwd()),
|
|
249974
251835
|
validate: (value) => {
|
|
249975
251836
|
if (!value || value.trim().length === 0) {
|
|
249976
251837
|
return "Every project deserves a name";
|
|
@@ -250665,7 +252526,7 @@ function getLogsCommand() {
|
|
|
250665
252526
|
}
|
|
250666
252527
|
|
|
250667
252528
|
// src/cli/commands/project/scaffold.ts
|
|
250668
|
-
import { basename as
|
|
252529
|
+
import { basename as basename8, resolve as resolve12 } from "node:path";
|
|
250669
252530
|
function resolveAppId(options) {
|
|
250670
252531
|
const appId = options.appId;
|
|
250671
252532
|
if (!appId) {
|
|
@@ -250682,7 +252543,7 @@ async function scaffoldAction(ctx, name, options, command) {
|
|
|
250682
252543
|
const { log, runTask } = ctx;
|
|
250683
252544
|
const appId = resolveAppId(command.optsWithGlobals());
|
|
250684
252545
|
const resolvedPath = resolve12("./");
|
|
250685
|
-
const projectName = (name ??
|
|
252546
|
+
const projectName = (name ?? basename8(resolvedPath)).trim();
|
|
250686
252547
|
const template = await getTemplateById("backend-only");
|
|
250687
252548
|
log.info(`Scaffolding project at ${resolvedPath}`);
|
|
250688
252549
|
const { projectId } = await runTask("Setting up your project...", async () => {
|
|
@@ -250914,7 +252775,7 @@ async function setEnvironmentVersion(environment, versionId, options = {}) {
|
|
|
250914
252775
|
}
|
|
250915
252776
|
// src/core/version/artifacts.ts
|
|
250916
252777
|
import { createHash as createHash3 } from "node:crypto";
|
|
250917
|
-
import { join as
|
|
252778
|
+
import { join as join30, resolve as resolve14 } from "node:path";
|
|
250918
252779
|
|
|
250919
252780
|
// src/core/version/actors.ts
|
|
250920
252781
|
import { dirname as dirname22, relative as relative7, resolve as resolve13 } from "node:path";
|
|
@@ -256400,7 +258261,7 @@ var TELEMETRY_PATCH = [
|
|
|
256400
258261
|
var TELEMETRY_STORE_FIELDS = "reqId: crypto.randomUUID(), respondedAt: null, inflight: new Map(), inflightTotal: 0, hadRejection: false, hadNonOk: false, logBudget: 5";
|
|
256401
258262
|
|
|
256402
258263
|
// ../functions-compiler/src/version.ts
|
|
256403
|
-
var COMPILER_VERSION = "0.1.
|
|
258264
|
+
var COMPILER_VERSION = "0.1.8";
|
|
256404
258265
|
|
|
256405
258266
|
// ../functions-compiler/src/worker-entry.ts
|
|
256406
258267
|
function denoShimSource() {
|
|
@@ -260937,7 +262798,7 @@ var nativeEnumType = ZodNativeEnum.create;
|
|
|
260937
262798
|
var promiseType = ZodPromise.create;
|
|
260938
262799
|
var effectsType = ZodEffects.create;
|
|
260939
262800
|
var optionalType = ZodOptional2.create;
|
|
260940
|
-
var
|
|
262801
|
+
var nullableType2 = ZodNullable2.create;
|
|
260941
262802
|
var preprocessType = ZodEffects.createWithPreprocess;
|
|
260942
262803
|
var pipelineType = ZodPipeline.create;
|
|
260943
262804
|
// ../functions-compiler/src/contracts.ts
|
|
@@ -260967,7 +262828,7 @@ var bundleAppRequestSchema = objectType({
|
|
|
260967
262828
|
var ACTIVATION_MODE = "pull";
|
|
260968
262829
|
|
|
260969
262830
|
// ../functions-compiler/src/deno-bundle.ts
|
|
260970
|
-
import { mkdtemp, rm, writeFile as writeFile2 } from "node:fs/promises";
|
|
262831
|
+
import { mkdtemp, rm as rm2, writeFile as writeFile2 } from "node:fs/promises";
|
|
260971
262832
|
import { tmpdir as tmpdir2 } from "node:os";
|
|
260972
262833
|
import path21 from "node:path";
|
|
260973
262834
|
|
|
@@ -261574,7 +263435,7 @@ async function bundleToModule(prepared, nodeModulesDir = "none") {
|
|
|
261574
263435
|
warnings: result.warnings.map((w) => w.text)
|
|
261575
263436
|
};
|
|
261576
263437
|
} finally {
|
|
261577
|
-
await
|
|
263438
|
+
await rm2(dir, { recursive: true, force: true });
|
|
261578
263439
|
}
|
|
261579
263440
|
}
|
|
261580
263441
|
function buildFailureErrors(e, dir) {
|
|
@@ -262322,14 +264183,14 @@ async function readRawResources(dir) {
|
|
|
262322
264183
|
const payloads = {};
|
|
262323
264184
|
for (const relativePath of files.sort()) {
|
|
262324
264185
|
const name = relativePath.replace(/\.jsonc?$/, "");
|
|
262325
|
-
payloads[name] = await readJsonFile(
|
|
264186
|
+
payloads[name] = await readJsonFile(join30(dir, ...relativePath.split("/")));
|
|
262326
264187
|
}
|
|
262327
264188
|
return payloads;
|
|
262328
264189
|
}
|
|
262329
264190
|
async function collectResources(configDir, dirs) {
|
|
262330
264191
|
const [entities, agents] = await Promise.all([
|
|
262331
|
-
readRawResources(
|
|
262332
|
-
readRawResources(
|
|
264192
|
+
readRawResources(join30(configDir, dirs.entitiesDir)),
|
|
264193
|
+
readRawResources(join30(configDir, dirs.agentsDir))
|
|
262333
264194
|
]);
|
|
262334
264195
|
return { entities, agents };
|
|
262335
264196
|
}
|
|
@@ -262341,8 +264202,8 @@ async function collectArtifacts(target) {
|
|
|
262341
264202
|
entryFile: ENTRY2
|
|
262342
264203
|
}),
|
|
262343
264204
|
...siteWorker ? { siteWorker } : {},
|
|
262344
|
-
backendBundles: await tagStep2("build", () => compileBackendBundles(target.root,
|
|
262345
|
-
actors: await tagStep2("build", () => compileActors(
|
|
264205
|
+
backendBundles: await tagStep2("build", () => compileBackendBundles(target.root, join30(target.configDir, target.functionsDir))),
|
|
264206
|
+
actors: await tagStep2("build", () => compileActors(join30(target.configDir, target.actorsDir))),
|
|
262346
264207
|
...await collectResources(target.configDir, target)
|
|
262347
264208
|
};
|
|
262348
264209
|
}
|
|
@@ -262559,7 +264420,7 @@ function writeFile3(appId, params) {
|
|
|
262559
264420
|
function editFile(appId, params) {
|
|
262560
264421
|
return callTool(appId, "edit_file", { ...params }, EditFileResponseSchema, `editing file "${params.path}"`);
|
|
262561
264422
|
}
|
|
262562
|
-
function
|
|
264423
|
+
function grep2(appId, params) {
|
|
262563
264424
|
return callTool(appId, "grep", { ...params }, GrepResponseSchema, "searching files");
|
|
262564
264425
|
}
|
|
262565
264426
|
function runCommand(appId, params) {
|
|
@@ -262663,10 +264524,10 @@ Examples:
|
|
|
262663
264524
|
}
|
|
262664
264525
|
|
|
262665
264526
|
// src/cli/commands/sandbox/grep.ts
|
|
262666
|
-
async function
|
|
264527
|
+
async function grepAction2({ runTask, branchId }, pattern, options) {
|
|
262667
264528
|
const { id: appId } = getAppContext();
|
|
262668
264529
|
const maxResults = parsePositiveInt(options.maxResults, "--max-results");
|
|
262669
|
-
const result = await runTask("Searching files", () =>
|
|
264530
|
+
const result = await runTask("Searching files", () => grep2(appId, {
|
|
262670
264531
|
pattern,
|
|
262671
264532
|
path: options.path,
|
|
262672
264533
|
is_regex: options.regex,
|
|
@@ -262678,7 +264539,7 @@ async function grepAction({ runTask, branchId }, pattern, options) {
|
|
|
262678
264539
|
return { outroMessage: "Searched files", stdout: toJsonStdout(result) };
|
|
262679
264540
|
}
|
|
262680
264541
|
function getSandboxGrepCommand() {
|
|
262681
|
-
return new Base44Command("grep", { supportsBranch: true }).description("Search files for a pattern in an app's remote sandbox").argument("<pattern>", "Search pattern").option("--path <path>", "Subtree to search, relative to the app root").option("--no-regex", "Treat the pattern as a literal string, not a regex").option("--case-sensitive", "Case-sensitive match").option("--glob <glob>", 'File glob filter, e.g. "*.tsx"').option("--max-results <n>", "Maximum number of match lines to return").action(
|
|
264542
|
+
return new Base44Command("grep", { supportsBranch: true }).description("Search files for a pattern in an app's remote sandbox").argument("<pattern>", "Search pattern").option("--path <path>", "Subtree to search, relative to the app root").option("--no-regex", "Treat the pattern as a literal string, not a regex").option("--case-sensitive", "Case-sensitive match").option("--glob <glob>", 'File glob filter, e.g. "*.tsx"').option("--max-results <n>", "Maximum number of match lines to return").action(grepAction2);
|
|
262682
264543
|
}
|
|
262683
264544
|
|
|
262684
264545
|
// src/cli/commands/sandbox/list-directory.ts
|
|
@@ -263273,10 +265134,10 @@ function toPascalCase(name) {
|
|
|
263273
265134
|
return name.split(/[-_\s]+/).map((w) => w.charAt(0).toUpperCase() + w.slice(1)).join("");
|
|
263274
265135
|
}
|
|
263275
265136
|
// src/core/types/update-project.ts
|
|
263276
|
-
import { join as
|
|
265137
|
+
import { join as join34 } from "node:path";
|
|
263277
265138
|
var TYPES_INCLUDE_PATH = `${PROJECT_SUBDIR}/${TYPES_OUTPUT_SUBDIR}/*.d.ts`;
|
|
263278
265139
|
async function updateProjectConfig(projectRoot) {
|
|
263279
|
-
const tsconfigPath =
|
|
265140
|
+
const tsconfigPath = join34(projectRoot, "tsconfig.json");
|
|
263280
265141
|
if (!await pathExists(tsconfigPath)) {
|
|
263281
265142
|
return false;
|
|
263282
265143
|
}
|
|
@@ -263495,7 +265356,7 @@ function rethrowLegacyAppAsExplanation(error) {
|
|
|
263495
265356
|
|
|
263496
265357
|
// src/cli/commands/workflows/limit.ts
|
|
263497
265358
|
var MAX_LIMIT = 200;
|
|
263498
|
-
function
|
|
265359
|
+
function parseLimit2(limit) {
|
|
263499
265360
|
if (limit === undefined)
|
|
263500
265361
|
return;
|
|
263501
265362
|
const parsed = Number.parseInt(limit, 10);
|
|
@@ -263512,7 +265373,7 @@ function formatWorkflowLine(workflow) {
|
|
|
263512
265373
|
return `${workflow.name} [${workflow.status}] runs: ${workflow.totalRuns}, ${lastRun}${failures}`;
|
|
263513
265374
|
}
|
|
263514
265375
|
async function listAction({ log, runTask, jsonMode }, options) {
|
|
263515
|
-
const limit =
|
|
265376
|
+
const limit = parseLimit2(options.limit);
|
|
263516
265377
|
const workflows = await runTask("Fetching workflows from Base44", async () => listWorkflows(limit).catch(rethrowLegacyAppAsExplanation), {
|
|
263517
265378
|
successMessage: "Workflows fetched successfully",
|
|
263518
265379
|
errorMessage: "Failed to fetch workflows"
|
|
@@ -263571,7 +265432,7 @@ async function describeEmptyResult(hasFilters) {
|
|
|
263571
265432
|
return hasFilters ? `No runs match your filters. Workflows in this app: ${names}.` : `No runs yet. Workflows in this app: ${names}.`;
|
|
263572
265433
|
}
|
|
263573
265434
|
async function runsAction(ctx, options) {
|
|
263574
|
-
const limit =
|
|
265435
|
+
const limit = parseLimit2(options.limit);
|
|
263575
265436
|
const runs = await ctx.runTask("Fetching workflow runs from Base44", async () => listWorkflowRuns({
|
|
263576
265437
|
status: options.status,
|
|
263577
265438
|
since: options.since,
|
|
@@ -263757,7 +265618,7 @@ function getWorkspaceCommand() {
|
|
|
263757
265618
|
// src/cli/dev/dev-server/main.ts
|
|
263758
265619
|
var import_cors = __toESM(require_lib4(), 1);
|
|
263759
265620
|
var import_express6 = __toESM(require_express(), 1);
|
|
263760
|
-
import { dirname as dirname28, join as
|
|
265621
|
+
import { dirname as dirname28, join as join39 } from "node:path";
|
|
263761
265622
|
|
|
263762
265623
|
// ../../node_modules/get-port/index.js
|
|
263763
265624
|
import net from "node:net";
|
|
@@ -263887,7 +265748,7 @@ var $tmpName = promisify12(tmp.tmpName);
|
|
|
263887
265748
|
|
|
263888
265749
|
// src/cli/dev/dev-server/function-manager.ts
|
|
263889
265750
|
import { spawn as spawn3 } from "node:child_process";
|
|
263890
|
-
import { dirname as dirname25, join as
|
|
265751
|
+
import { dirname as dirname25, join as join35 } from "node:path";
|
|
263891
265752
|
import { pathToFileURL as pathToFileURL6 } from "node:url";
|
|
263892
265753
|
|
|
263893
265754
|
// src/cli/dev/dev-server/base-function-manager.ts
|
|
@@ -263992,7 +265853,7 @@ class FunctionManager extends BaseFunctionManager {
|
|
|
263992
265853
|
}
|
|
263993
265854
|
spawnFunction(func, port) {
|
|
263994
265855
|
this.logger.log(`Spawning function "${func.name}" on port ${port}`);
|
|
263995
|
-
const importMapPath =
|
|
265856
|
+
const importMapPath = join35(dirname25(this.wrapperPath), "import-map.json");
|
|
263996
265857
|
const process2 = spawn3("deno", ["run", "--allow-all", "--import-map", importMapPath, this.wrapperPath], {
|
|
263997
265858
|
env: {
|
|
263998
265859
|
...globalThis.process.env,
|
|
@@ -264066,7 +265927,7 @@ class FunctionManager extends BaseFunctionManager {
|
|
|
264066
265927
|
import { mkdirSync as mkdirSync2, writeFileSync as writeFileSync2 } from "node:fs";
|
|
264067
265928
|
import { isBuiltin as isBuiltin3 } from "node:module";
|
|
264068
265929
|
import { homedir as homedir4 } from "node:os";
|
|
264069
|
-
import { join as
|
|
265930
|
+
import { join as join36 } from "node:path";
|
|
264070
265931
|
import { pathToFileURL as pathToFileURL7 } from "node:url";
|
|
264071
265932
|
var depsPromise;
|
|
264072
265933
|
function loadDeps() {
|
|
@@ -264187,9 +266048,9 @@ export default {
|
|
|
264187
266048
|
};
|
|
264188
266049
|
`;
|
|
264189
266050
|
function ensureBundlerConfig() {
|
|
264190
|
-
const dir =
|
|
266051
|
+
const dir = join36(homedir4(), ".base44", "function-bundler");
|
|
264191
266052
|
mkdirSync2(dir, { recursive: true });
|
|
264192
|
-
const configPath =
|
|
266053
|
+
const configPath = join36(dir, "deno.json");
|
|
264193
266054
|
writeFileSync2(configPath, `${JSON.stringify({ nodeModulesDir: "auto" }, null, 2)}
|
|
264194
266055
|
`);
|
|
264195
266056
|
return configPath;
|
|
@@ -265726,11 +267587,11 @@ import { relative as relative11 } from "node:path";
|
|
|
265726
267587
|
// ../../node_modules/chokidar/index.js
|
|
265727
267588
|
import { EventEmitter as EventEmitter3 } from "node:events";
|
|
265728
267589
|
import { stat as statcb, Stats } from "node:fs";
|
|
265729
|
-
import { readdir as readdir3, stat as
|
|
267590
|
+
import { readdir as readdir3, stat as stat7 } from "node:fs/promises";
|
|
265730
267591
|
import * as sp3 from "node:path";
|
|
265731
267592
|
|
|
265732
267593
|
// ../../node_modules/readdirp/index.js
|
|
265733
|
-
import { lstat as lstat2, readdir as readdir2, realpath, stat as
|
|
267594
|
+
import { lstat as lstat2, readdir as readdir2, realpath, stat as stat5 } from "node:fs/promises";
|
|
265734
267595
|
import { join as pjoin, relative as prelative, resolve as presolve, sep as psep } from "node:path";
|
|
265735
267596
|
import { Readable as Readable6 } from "node:stream";
|
|
265736
267597
|
var EntryTypes = {
|
|
@@ -265739,7 +267600,7 @@ var EntryTypes = {
|
|
|
265739
267600
|
FILE_DIR_TYPE: "files_directories",
|
|
265740
267601
|
EVERYTHING_TYPE: "all"
|
|
265741
267602
|
};
|
|
265742
|
-
var
|
|
267603
|
+
var defaultOptions2 = {
|
|
265743
267604
|
root: ".",
|
|
265744
267605
|
fileFilter: (_entryInfo) => true,
|
|
265745
267606
|
directoryFilter: (_entryInfo) => true,
|
|
@@ -265749,7 +267610,7 @@ var defaultOptions = {
|
|
|
265749
267610
|
alwaysStat: false,
|
|
265750
267611
|
highWaterMark: 4096
|
|
265751
267612
|
};
|
|
265752
|
-
Object.freeze(
|
|
267613
|
+
Object.freeze(defaultOptions2);
|
|
265753
267614
|
var RECURSIVE_ERROR_CODE = "READDIRP_RECURSIVE_ERROR";
|
|
265754
267615
|
var NORMAL_FLOW_ERRORS = new Set(["ENOENT", "EPERM", "EACCES", "ELOOP", RECURSIVE_ERROR_CODE]);
|
|
265755
267616
|
var ALL_TYPES = [
|
|
@@ -265808,17 +267669,17 @@ class ReaddirpStream extends Readable6 {
|
|
|
265808
267669
|
autoDestroy: true,
|
|
265809
267670
|
highWaterMark: options.highWaterMark
|
|
265810
267671
|
});
|
|
265811
|
-
const opts = { ...
|
|
267672
|
+
const opts = { ...defaultOptions2, ...options };
|
|
265812
267673
|
const { root, type } = opts;
|
|
265813
267674
|
this._fileFilter = normalizeFilter(opts.fileFilter);
|
|
265814
267675
|
this._directoryFilter = normalizeFilter(opts.directoryFilter);
|
|
265815
|
-
const statMethod = opts.lstat ? lstat2 :
|
|
267676
|
+
const statMethod = opts.lstat ? lstat2 : stat5;
|
|
265816
267677
|
if (wantBigintFsStats) {
|
|
265817
267678
|
this._stat = (path) => statMethod(path, { bigint: true });
|
|
265818
267679
|
} else {
|
|
265819
267680
|
this._stat = statMethod;
|
|
265820
267681
|
}
|
|
265821
|
-
this._maxDepth = opts.depth != null && Number.isSafeInteger(opts.depth) ? opts.depth :
|
|
267682
|
+
this._maxDepth = opts.depth != null && Number.isSafeInteger(opts.depth) ? opts.depth : defaultOptions2.depth;
|
|
265822
267683
|
this._wantsDir = type ? DIR_TYPES.has(type) : false;
|
|
265823
267684
|
this._wantsFile = type ? FILE_TYPES2.has(type) : false;
|
|
265824
267685
|
this._wantsEverything = type === EntryTypes.EVERYTHING_TYPE;
|
|
@@ -265965,7 +267826,7 @@ function readdirp(root, options = {}) {
|
|
|
265965
267826
|
|
|
265966
267827
|
// ../../node_modules/chokidar/handler.js
|
|
265967
267828
|
import { watch as fs_watch, unwatchFile, watchFile } from "node:fs";
|
|
265968
|
-
import { realpath as fsrealpath, lstat as lstat3, open as open2, stat as
|
|
267829
|
+
import { realpath as fsrealpath, lstat as lstat3, open as open2, stat as stat6 } from "node:fs/promises";
|
|
265969
267830
|
import { type as osType } from "node:os";
|
|
265970
267831
|
import * as sp2 from "node:path";
|
|
265971
267832
|
var STR_DATA = "data";
|
|
@@ -265991,7 +267852,7 @@ var EVENTS = {
|
|
|
265991
267852
|
};
|
|
265992
267853
|
var EV = EVENTS;
|
|
265993
267854
|
var THROTTLE_MODE_WATCH = "watch";
|
|
265994
|
-
var statMethods = { lstat: lstat3, stat:
|
|
267855
|
+
var statMethods = { lstat: lstat3, stat: stat6 };
|
|
265995
267856
|
var KEY_LISTENERS = "listeners";
|
|
265996
267857
|
var KEY_ERR = "errHandlers";
|
|
265997
267858
|
var KEY_RAW = "rawEmitters";
|
|
@@ -266462,7 +268323,7 @@ class NodeFsHandler {
|
|
|
266462
268323
|
return;
|
|
266463
268324
|
if (!newStats || newStats.mtimeMs === 0) {
|
|
266464
268325
|
try {
|
|
266465
|
-
const newStats = await
|
|
268326
|
+
const newStats = await stat6(file);
|
|
266466
268327
|
if (this.fsw.closed)
|
|
266467
268328
|
return;
|
|
266468
268329
|
const at = newStats.atimeMs;
|
|
@@ -266714,7 +268575,7 @@ function createPattern(matcher) {
|
|
|
266714
268575
|
}
|
|
266715
268576
|
return () => false;
|
|
266716
268577
|
}
|
|
266717
|
-
function
|
|
268578
|
+
function normalizePath2(path) {
|
|
266718
268579
|
if (typeof path !== "string")
|
|
266719
268580
|
throw new Error("string expected");
|
|
266720
268581
|
path = sp3.normalize(path);
|
|
@@ -266728,7 +268589,7 @@ function normalizePath(path) {
|
|
|
266728
268589
|
return path;
|
|
266729
268590
|
}
|
|
266730
268591
|
function matchPatterns(patterns, testString, stats) {
|
|
266731
|
-
const path =
|
|
268592
|
+
const path = normalizePath2(testString);
|
|
266732
268593
|
for (let index = 0;index < patterns.length; index++) {
|
|
266733
268594
|
const pattern = patterns[index];
|
|
266734
268595
|
if (pattern(path, stats)) {
|
|
@@ -267134,7 +268995,7 @@ class FSWatcher extends EventEmitter3 {
|
|
|
267134
268995
|
const fullPath = opts.cwd ? sp3.join(opts.cwd, path) : path;
|
|
267135
268996
|
let stats;
|
|
267136
268997
|
try {
|
|
267137
|
-
stats = await
|
|
268998
|
+
stats = await stat7(fullPath);
|
|
267138
268999
|
} catch (err) {}
|
|
267139
269000
|
if (!stats || this.closed)
|
|
267140
269001
|
return;
|
|
@@ -267518,8 +269379,8 @@ async function createDevServer(options) {
|
|
|
267518
269379
|
broadcastEntityEvent(io, appId, entityName, event);
|
|
267519
269380
|
};
|
|
267520
269381
|
const base44ConfigWatcher = new WatchBase44({
|
|
267521
|
-
functions:
|
|
267522
|
-
entities:
|
|
269382
|
+
functions: join39(dirname28(project.configPath), project.functionsDir),
|
|
269383
|
+
entities: join39(dirname28(project.configPath), project.entitiesDir)
|
|
267523
269384
|
}, devLogger);
|
|
267524
269385
|
base44ConfigWatcher.on("change", async (name) => {
|
|
267525
269386
|
try {
|
|
@@ -267722,7 +269583,7 @@ function readExecEnvTarget(env = process.env) {
|
|
|
267722
269583
|
// src/core/exec/run-script.ts
|
|
267723
269584
|
import { spawn as spawn4 } from "node:child_process";
|
|
267724
269585
|
import { readFileSync as readFileSync4, writeFileSync as writeFileSync3 } from "node:fs";
|
|
267725
|
-
import { join as
|
|
269586
|
+
import { join as join40 } from "node:path";
|
|
267726
269587
|
var SDK_SPECIFIER = '"npm:@base44/sdk"';
|
|
267727
269588
|
function wrapperSource(sdkVersion) {
|
|
267728
269589
|
const source = readFileSync4(getExecWrapperPath(), "utf-8");
|
|
@@ -267758,7 +269619,7 @@ async function runScript(options) {
|
|
|
267758
269619
|
writeFileSync3(tempWrapper.path, wrapperSource(sdkVersion), "utf-8");
|
|
267759
269620
|
const configDir = await $dir({ unsafeCleanup: true });
|
|
267760
269621
|
cleanupFns.push(configDir.cleanup);
|
|
267761
|
-
const configPath =
|
|
269622
|
+
const configPath = join40(configDir.path, "deno.json");
|
|
267762
269623
|
writeFileSync3(configPath, JSON.stringify(DENO_CONFIG), "utf-8");
|
|
267763
269624
|
try {
|
|
267764
269625
|
const exitCode = await new Promise((resolvePromise) => {
|
|
@@ -268030,6 +269891,7 @@ function createProgram(context) {
|
|
|
268030
269891
|
program.addCommand(getSecretsCommand());
|
|
268031
269892
|
program.addCommand(getSandboxCommand());
|
|
268032
269893
|
program.addCommand(getBranchesCommand());
|
|
269894
|
+
program.addCommand(getApiCommand());
|
|
268033
269895
|
program.addCommand(getAuthCommand());
|
|
268034
269896
|
program.addCommand(getSiteCommand());
|
|
268035
269897
|
if (versionsApiEnabled()) {
|
|
@@ -272048,7 +273910,7 @@ function addCommandInfoToErrorReporter(program, errorReporter) {
|
|
|
272048
273910
|
// src/cli/index.ts
|
|
272049
273911
|
var __dirname4 = dirname30(fileURLToPath7(import.meta.url));
|
|
272050
273912
|
async function runCLI(options) {
|
|
272051
|
-
ensureNpmAssets(
|
|
273913
|
+
ensureNpmAssets(join41(__dirname4, "../assets"));
|
|
272052
273914
|
const errorReporter = new ErrorReporter;
|
|
272053
273915
|
errorReporter.registerProcessErrorHandlers();
|
|
272054
273916
|
const jsonMode = process.argv.includes("--json");
|
|
@@ -272087,4 +273949,4 @@ export {
|
|
|
272087
273949
|
runCLI
|
|
272088
273950
|
};
|
|
272089
273951
|
|
|
272090
|
-
//# debugId=
|
|
273952
|
+
//# debugId=9B0010644779EACB64756E2164756E21
|