@base44-preview/cli 0.1.32-pr.662.e04bb64 → 0.1.32-pr.663.43d14f8
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 +2113 -218
- package/dist/cli/index.js.map +28 -11
- 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 dirname29, join as
|
|
228841
|
+
import { dirname as dirname29, 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",
|
|
@@ -247586,8 +247587,8 @@ function normalizeDatetime(value) {
|
|
|
247586
247587
|
return `${value}Z`;
|
|
247587
247588
|
}
|
|
247588
247589
|
// src/cli/utils/json.ts
|
|
247589
|
-
function toJsonStdout(result) {
|
|
247590
|
-
return `${JSON.stringify(result, null, 2)}
|
|
247590
|
+
function toJsonStdout(result, options = {}) {
|
|
247591
|
+
return `${JSON.stringify(result, null, options.compact ? undefined : 2)}
|
|
247591
247592
|
`;
|
|
247592
247593
|
}
|
|
247593
247594
|
// src/cli/errors.ts
|
|
@@ -248041,13 +248042,1864 @@ function getAgentsCommand() {
|
|
|
248041
248042
|
return new Command2("agents").description("Manage project agents").addCommand(getAgentsPushCommand()).addCommand(getAgentsPullCommand());
|
|
248042
248043
|
}
|
|
248043
248044
|
|
|
248045
|
+
// ../../node_modules/minisearch/dist/es/index.js
|
|
248046
|
+
var ENTRIES = "ENTRIES";
|
|
248047
|
+
var KEYS = "KEYS";
|
|
248048
|
+
var VALUES = "VALUES";
|
|
248049
|
+
var LEAF = "";
|
|
248050
|
+
|
|
248051
|
+
class TreeIterator {
|
|
248052
|
+
constructor(set, type) {
|
|
248053
|
+
const node = set._tree;
|
|
248054
|
+
const keys = Array.from(node.keys());
|
|
248055
|
+
this.set = set;
|
|
248056
|
+
this._type = type;
|
|
248057
|
+
this._path = keys.length > 0 ? [{ node, keys }] : [];
|
|
248058
|
+
}
|
|
248059
|
+
next() {
|
|
248060
|
+
const value = this.dive();
|
|
248061
|
+
this.backtrack();
|
|
248062
|
+
return value;
|
|
248063
|
+
}
|
|
248064
|
+
dive() {
|
|
248065
|
+
if (this._path.length === 0) {
|
|
248066
|
+
return { done: true, value: undefined };
|
|
248067
|
+
}
|
|
248068
|
+
const { node, keys } = last$1(this._path);
|
|
248069
|
+
if (last$1(keys) === LEAF) {
|
|
248070
|
+
return { done: false, value: this.result() };
|
|
248071
|
+
}
|
|
248072
|
+
const child = node.get(last$1(keys));
|
|
248073
|
+
this._path.push({ node: child, keys: Array.from(child.keys()) });
|
|
248074
|
+
return this.dive();
|
|
248075
|
+
}
|
|
248076
|
+
backtrack() {
|
|
248077
|
+
if (this._path.length === 0) {
|
|
248078
|
+
return;
|
|
248079
|
+
}
|
|
248080
|
+
const keys = last$1(this._path).keys;
|
|
248081
|
+
keys.pop();
|
|
248082
|
+
if (keys.length > 0) {
|
|
248083
|
+
return;
|
|
248084
|
+
}
|
|
248085
|
+
this._path.pop();
|
|
248086
|
+
this.backtrack();
|
|
248087
|
+
}
|
|
248088
|
+
key() {
|
|
248089
|
+
return this.set._prefix + this._path.map(({ keys }) => last$1(keys)).filter((key) => key !== LEAF).join("");
|
|
248090
|
+
}
|
|
248091
|
+
value() {
|
|
248092
|
+
return last$1(this._path).node.get(LEAF);
|
|
248093
|
+
}
|
|
248094
|
+
result() {
|
|
248095
|
+
switch (this._type) {
|
|
248096
|
+
case VALUES:
|
|
248097
|
+
return this.value();
|
|
248098
|
+
case KEYS:
|
|
248099
|
+
return this.key();
|
|
248100
|
+
default:
|
|
248101
|
+
return [this.key(), this.value()];
|
|
248102
|
+
}
|
|
248103
|
+
}
|
|
248104
|
+
[Symbol.iterator]() {
|
|
248105
|
+
return this;
|
|
248106
|
+
}
|
|
248107
|
+
}
|
|
248108
|
+
var last$1 = (array) => {
|
|
248109
|
+
return array[array.length - 1];
|
|
248110
|
+
};
|
|
248111
|
+
var fuzzySearch = (node, query, maxDistance) => {
|
|
248112
|
+
const results = new Map;
|
|
248113
|
+
if (query === undefined)
|
|
248114
|
+
return results;
|
|
248115
|
+
const n = query.length + 1;
|
|
248116
|
+
const m = n + maxDistance;
|
|
248117
|
+
const matrix = new Uint8Array(m * n).fill(maxDistance + 1);
|
|
248118
|
+
for (let j = 0;j < n; ++j)
|
|
248119
|
+
matrix[j] = j;
|
|
248120
|
+
for (let i = 1;i < m; ++i)
|
|
248121
|
+
matrix[i * n] = i;
|
|
248122
|
+
recurse(node, query, maxDistance, results, matrix, 1, n, "");
|
|
248123
|
+
return results;
|
|
248124
|
+
};
|
|
248125
|
+
var recurse = (node, query, maxDistance, results, matrix, m, n, prefix) => {
|
|
248126
|
+
const offset = m * n;
|
|
248127
|
+
key:
|
|
248128
|
+
for (const key of node.keys()) {
|
|
248129
|
+
if (key === LEAF) {
|
|
248130
|
+
const distance = matrix[offset - 1];
|
|
248131
|
+
if (distance <= maxDistance) {
|
|
248132
|
+
results.set(prefix, [node.get(key), distance]);
|
|
248133
|
+
}
|
|
248134
|
+
} else {
|
|
248135
|
+
let i = m;
|
|
248136
|
+
for (let pos = 0;pos < key.length; ++pos, ++i) {
|
|
248137
|
+
const char = key[pos];
|
|
248138
|
+
const thisRowOffset = n * i;
|
|
248139
|
+
const prevRowOffset = thisRowOffset - n;
|
|
248140
|
+
let minDistance = matrix[thisRowOffset];
|
|
248141
|
+
const jmin = Math.max(0, i - maxDistance - 1);
|
|
248142
|
+
const jmax = Math.min(n - 1, i + maxDistance);
|
|
248143
|
+
for (let j = jmin;j < jmax; ++j) {
|
|
248144
|
+
const different = char !== query[j];
|
|
248145
|
+
const rpl = matrix[prevRowOffset + j] + +different;
|
|
248146
|
+
const del = matrix[prevRowOffset + j + 1] + 1;
|
|
248147
|
+
const ins = matrix[thisRowOffset + j] + 1;
|
|
248148
|
+
const dist = matrix[thisRowOffset + j + 1] = Math.min(rpl, del, ins);
|
|
248149
|
+
if (dist < minDistance)
|
|
248150
|
+
minDistance = dist;
|
|
248151
|
+
}
|
|
248152
|
+
if (minDistance > maxDistance) {
|
|
248153
|
+
continue key;
|
|
248154
|
+
}
|
|
248155
|
+
}
|
|
248156
|
+
recurse(node.get(key), query, maxDistance, results, matrix, i, n, prefix + key);
|
|
248157
|
+
}
|
|
248158
|
+
}
|
|
248159
|
+
};
|
|
248160
|
+
|
|
248161
|
+
class SearchableMap {
|
|
248162
|
+
constructor(tree = new Map, prefix = "") {
|
|
248163
|
+
this._size = undefined;
|
|
248164
|
+
this._tree = tree;
|
|
248165
|
+
this._prefix = prefix;
|
|
248166
|
+
}
|
|
248167
|
+
atPrefix(prefix) {
|
|
248168
|
+
if (!prefix.startsWith(this._prefix)) {
|
|
248169
|
+
throw new Error("Mismatched prefix");
|
|
248170
|
+
}
|
|
248171
|
+
const [node, path] = trackDown(this._tree, prefix.slice(this._prefix.length));
|
|
248172
|
+
if (node === undefined) {
|
|
248173
|
+
const [parentNode, key] = last(path);
|
|
248174
|
+
for (const k of parentNode.keys()) {
|
|
248175
|
+
if (k !== LEAF && k.startsWith(key)) {
|
|
248176
|
+
const node = new Map;
|
|
248177
|
+
node.set(k.slice(key.length), parentNode.get(k));
|
|
248178
|
+
return new SearchableMap(node, prefix);
|
|
248179
|
+
}
|
|
248180
|
+
}
|
|
248181
|
+
}
|
|
248182
|
+
return new SearchableMap(node, prefix);
|
|
248183
|
+
}
|
|
248184
|
+
clear() {
|
|
248185
|
+
this._size = undefined;
|
|
248186
|
+
this._tree.clear();
|
|
248187
|
+
}
|
|
248188
|
+
delete(key) {
|
|
248189
|
+
this._size = undefined;
|
|
248190
|
+
return remove(this._tree, key);
|
|
248191
|
+
}
|
|
248192
|
+
entries() {
|
|
248193
|
+
return new TreeIterator(this, ENTRIES);
|
|
248194
|
+
}
|
|
248195
|
+
forEach(fn) {
|
|
248196
|
+
for (const [key, value] of this) {
|
|
248197
|
+
fn(key, value, this);
|
|
248198
|
+
}
|
|
248199
|
+
}
|
|
248200
|
+
fuzzyGet(key, maxEditDistance) {
|
|
248201
|
+
return fuzzySearch(this._tree, key, maxEditDistance);
|
|
248202
|
+
}
|
|
248203
|
+
get(key) {
|
|
248204
|
+
const node = lookup(this._tree, key);
|
|
248205
|
+
return node !== undefined ? node.get(LEAF) : undefined;
|
|
248206
|
+
}
|
|
248207
|
+
has(key) {
|
|
248208
|
+
const node = lookup(this._tree, key);
|
|
248209
|
+
return node !== undefined && node.has(LEAF);
|
|
248210
|
+
}
|
|
248211
|
+
keys() {
|
|
248212
|
+
return new TreeIterator(this, KEYS);
|
|
248213
|
+
}
|
|
248214
|
+
set(key, value) {
|
|
248215
|
+
if (typeof key !== "string") {
|
|
248216
|
+
throw new Error("key must be a string");
|
|
248217
|
+
}
|
|
248218
|
+
this._size = undefined;
|
|
248219
|
+
const node = createPath(this._tree, key);
|
|
248220
|
+
node.set(LEAF, value);
|
|
248221
|
+
return this;
|
|
248222
|
+
}
|
|
248223
|
+
get size() {
|
|
248224
|
+
if (this._size) {
|
|
248225
|
+
return this._size;
|
|
248226
|
+
}
|
|
248227
|
+
this._size = 0;
|
|
248228
|
+
const iter = this.entries();
|
|
248229
|
+
while (!iter.next().done)
|
|
248230
|
+
this._size += 1;
|
|
248231
|
+
return this._size;
|
|
248232
|
+
}
|
|
248233
|
+
update(key, fn) {
|
|
248234
|
+
if (typeof key !== "string") {
|
|
248235
|
+
throw new Error("key must be a string");
|
|
248236
|
+
}
|
|
248237
|
+
this._size = undefined;
|
|
248238
|
+
const node = createPath(this._tree, key);
|
|
248239
|
+
node.set(LEAF, fn(node.get(LEAF)));
|
|
248240
|
+
return this;
|
|
248241
|
+
}
|
|
248242
|
+
fetch(key, initial) {
|
|
248243
|
+
if (typeof key !== "string") {
|
|
248244
|
+
throw new Error("key must be a string");
|
|
248245
|
+
}
|
|
248246
|
+
this._size = undefined;
|
|
248247
|
+
const node = createPath(this._tree, key);
|
|
248248
|
+
let value = node.get(LEAF);
|
|
248249
|
+
if (value === undefined) {
|
|
248250
|
+
node.set(LEAF, value = initial());
|
|
248251
|
+
}
|
|
248252
|
+
return value;
|
|
248253
|
+
}
|
|
248254
|
+
values() {
|
|
248255
|
+
return new TreeIterator(this, VALUES);
|
|
248256
|
+
}
|
|
248257
|
+
[Symbol.iterator]() {
|
|
248258
|
+
return this.entries();
|
|
248259
|
+
}
|
|
248260
|
+
static from(entries) {
|
|
248261
|
+
const tree = new SearchableMap;
|
|
248262
|
+
for (const [key, value] of entries) {
|
|
248263
|
+
tree.set(key, value);
|
|
248264
|
+
}
|
|
248265
|
+
return tree;
|
|
248266
|
+
}
|
|
248267
|
+
static fromObject(object) {
|
|
248268
|
+
return SearchableMap.from(Object.entries(object));
|
|
248269
|
+
}
|
|
248270
|
+
}
|
|
248271
|
+
var trackDown = (tree, key, path = []) => {
|
|
248272
|
+
if (key.length === 0 || tree == null) {
|
|
248273
|
+
return [tree, path];
|
|
248274
|
+
}
|
|
248275
|
+
for (const k of tree.keys()) {
|
|
248276
|
+
if (k !== LEAF && key.startsWith(k)) {
|
|
248277
|
+
path.push([tree, k]);
|
|
248278
|
+
return trackDown(tree.get(k), key.slice(k.length), path);
|
|
248279
|
+
}
|
|
248280
|
+
}
|
|
248281
|
+
path.push([tree, key]);
|
|
248282
|
+
return trackDown(undefined, "", path);
|
|
248283
|
+
};
|
|
248284
|
+
var lookup = (tree, key) => {
|
|
248285
|
+
if (key.length === 0 || tree == null) {
|
|
248286
|
+
return tree;
|
|
248287
|
+
}
|
|
248288
|
+
for (const k of tree.keys()) {
|
|
248289
|
+
if (k !== LEAF && key.startsWith(k)) {
|
|
248290
|
+
return lookup(tree.get(k), key.slice(k.length));
|
|
248291
|
+
}
|
|
248292
|
+
}
|
|
248293
|
+
};
|
|
248294
|
+
var createPath = (node, key) => {
|
|
248295
|
+
const keyLength = key.length;
|
|
248296
|
+
outer:
|
|
248297
|
+
for (let pos = 0;node && pos < keyLength; ) {
|
|
248298
|
+
for (const k of node.keys()) {
|
|
248299
|
+
if (k !== LEAF && key[pos] === k[0]) {
|
|
248300
|
+
const len = Math.min(keyLength - pos, k.length);
|
|
248301
|
+
let offset = 1;
|
|
248302
|
+
while (offset < len && key[pos + offset] === k[offset])
|
|
248303
|
+
++offset;
|
|
248304
|
+
const child = node.get(k);
|
|
248305
|
+
if (offset === k.length) {
|
|
248306
|
+
node = child;
|
|
248307
|
+
} else {
|
|
248308
|
+
const intermediate = new Map;
|
|
248309
|
+
intermediate.set(k.slice(offset), child);
|
|
248310
|
+
node.set(key.slice(pos, pos + offset), intermediate);
|
|
248311
|
+
node.delete(k);
|
|
248312
|
+
node = intermediate;
|
|
248313
|
+
}
|
|
248314
|
+
pos += offset;
|
|
248315
|
+
continue outer;
|
|
248316
|
+
}
|
|
248317
|
+
}
|
|
248318
|
+
const child = new Map;
|
|
248319
|
+
node.set(key.slice(pos), child);
|
|
248320
|
+
return child;
|
|
248321
|
+
}
|
|
248322
|
+
return node;
|
|
248323
|
+
};
|
|
248324
|
+
var remove = (tree, key) => {
|
|
248325
|
+
const [node, path] = trackDown(tree, key);
|
|
248326
|
+
if (node === undefined) {
|
|
248327
|
+
return;
|
|
248328
|
+
}
|
|
248329
|
+
node.delete(LEAF);
|
|
248330
|
+
if (node.size === 0) {
|
|
248331
|
+
cleanup(path);
|
|
248332
|
+
} else if (node.size === 1) {
|
|
248333
|
+
const [key, value] = node.entries().next().value;
|
|
248334
|
+
merge3(path, key, value);
|
|
248335
|
+
}
|
|
248336
|
+
};
|
|
248337
|
+
var cleanup = (path) => {
|
|
248338
|
+
if (path.length === 0) {
|
|
248339
|
+
return;
|
|
248340
|
+
}
|
|
248341
|
+
const [node, key] = last(path);
|
|
248342
|
+
node.delete(key);
|
|
248343
|
+
if (node.size === 0) {
|
|
248344
|
+
cleanup(path.slice(0, -1));
|
|
248345
|
+
} else if (node.size === 1) {
|
|
248346
|
+
const [key, value] = node.entries().next().value;
|
|
248347
|
+
if (key !== LEAF) {
|
|
248348
|
+
merge3(path.slice(0, -1), key, value);
|
|
248349
|
+
}
|
|
248350
|
+
}
|
|
248351
|
+
};
|
|
248352
|
+
var merge3 = (path, key, value) => {
|
|
248353
|
+
if (path.length === 0) {
|
|
248354
|
+
return;
|
|
248355
|
+
}
|
|
248356
|
+
const [node, nodeKey] = last(path);
|
|
248357
|
+
node.set(nodeKey + key, value);
|
|
248358
|
+
node.delete(nodeKey);
|
|
248359
|
+
};
|
|
248360
|
+
var last = (array) => {
|
|
248361
|
+
return array[array.length - 1];
|
|
248362
|
+
};
|
|
248363
|
+
var OR = "or";
|
|
248364
|
+
var AND = "and";
|
|
248365
|
+
var AND_NOT = "and_not";
|
|
248366
|
+
|
|
248367
|
+
class MiniSearch {
|
|
248368
|
+
constructor(options) {
|
|
248369
|
+
if ((options === null || options === undefined ? undefined : options.fields) == null) {
|
|
248370
|
+
throw new Error('MiniSearch: option "fields" must be provided');
|
|
248371
|
+
}
|
|
248372
|
+
const autoVacuum = options.autoVacuum == null || options.autoVacuum === true ? defaultAutoVacuumOptions : options.autoVacuum;
|
|
248373
|
+
this._options = {
|
|
248374
|
+
...defaultOptions,
|
|
248375
|
+
...options,
|
|
248376
|
+
autoVacuum,
|
|
248377
|
+
searchOptions: { ...defaultSearchOptions, ...options.searchOptions || {} },
|
|
248378
|
+
autoSuggestOptions: { ...defaultAutoSuggestOptions, ...options.autoSuggestOptions || {} }
|
|
248379
|
+
};
|
|
248380
|
+
this._index = new SearchableMap;
|
|
248381
|
+
this._documentCount = 0;
|
|
248382
|
+
this._documentIds = new Map;
|
|
248383
|
+
this._idToShortId = new Map;
|
|
248384
|
+
this._fieldIds = {};
|
|
248385
|
+
this._fieldLength = new Map;
|
|
248386
|
+
this._avgFieldLength = [];
|
|
248387
|
+
this._nextId = 0;
|
|
248388
|
+
this._storedFields = new Map;
|
|
248389
|
+
this._dirtCount = 0;
|
|
248390
|
+
this._currentVacuum = null;
|
|
248391
|
+
this._enqueuedVacuum = null;
|
|
248392
|
+
this._enqueuedVacuumConditions = defaultVacuumConditions;
|
|
248393
|
+
this.addFields(this._options.fields);
|
|
248394
|
+
}
|
|
248395
|
+
add(document2) {
|
|
248396
|
+
const { extractField, tokenize, processTerm, fields, idField } = this._options;
|
|
248397
|
+
const id = extractField(document2, idField);
|
|
248398
|
+
if (id == null) {
|
|
248399
|
+
throw new Error(`MiniSearch: document does not have ID field "${idField}"`);
|
|
248400
|
+
}
|
|
248401
|
+
if (this._idToShortId.has(id)) {
|
|
248402
|
+
throw new Error(`MiniSearch: duplicate ID ${id}`);
|
|
248403
|
+
}
|
|
248404
|
+
const shortDocumentId = this.addDocumentId(id);
|
|
248405
|
+
this.saveStoredFields(shortDocumentId, document2);
|
|
248406
|
+
for (const field of fields) {
|
|
248407
|
+
const fieldValue = extractField(document2, field);
|
|
248408
|
+
if (fieldValue == null)
|
|
248409
|
+
continue;
|
|
248410
|
+
const tokens = tokenize(fieldValue.toString(), field);
|
|
248411
|
+
const fieldId = this._fieldIds[field];
|
|
248412
|
+
const uniqueTerms = new Set(tokens).size;
|
|
248413
|
+
this.addFieldLength(shortDocumentId, fieldId, this._documentCount - 1, uniqueTerms);
|
|
248414
|
+
for (const term of tokens) {
|
|
248415
|
+
const processedTerm = processTerm(term, field);
|
|
248416
|
+
if (Array.isArray(processedTerm)) {
|
|
248417
|
+
for (const t of processedTerm) {
|
|
248418
|
+
this.addTerm(fieldId, shortDocumentId, t);
|
|
248419
|
+
}
|
|
248420
|
+
} else if (processedTerm) {
|
|
248421
|
+
this.addTerm(fieldId, shortDocumentId, processedTerm);
|
|
248422
|
+
}
|
|
248423
|
+
}
|
|
248424
|
+
}
|
|
248425
|
+
}
|
|
248426
|
+
addAll(documents) {
|
|
248427
|
+
for (const document2 of documents)
|
|
248428
|
+
this.add(document2);
|
|
248429
|
+
}
|
|
248430
|
+
addAllAsync(documents, options = {}) {
|
|
248431
|
+
const { chunkSize = 10 } = options;
|
|
248432
|
+
const acc = { chunk: [], promise: Promise.resolve() };
|
|
248433
|
+
const { chunk, promise } = documents.reduce(({ chunk, promise }, document2, i) => {
|
|
248434
|
+
chunk.push(document2);
|
|
248435
|
+
if ((i + 1) % chunkSize === 0) {
|
|
248436
|
+
return {
|
|
248437
|
+
chunk: [],
|
|
248438
|
+
promise: promise.then(() => new Promise((resolve) => setTimeout(resolve, 0))).then(() => this.addAll(chunk))
|
|
248439
|
+
};
|
|
248440
|
+
} else {
|
|
248441
|
+
return { chunk, promise };
|
|
248442
|
+
}
|
|
248443
|
+
}, acc);
|
|
248444
|
+
return promise.then(() => this.addAll(chunk));
|
|
248445
|
+
}
|
|
248446
|
+
remove(document2) {
|
|
248447
|
+
const { tokenize, processTerm, extractField, fields, idField } = this._options;
|
|
248448
|
+
const id = extractField(document2, idField);
|
|
248449
|
+
if (id == null) {
|
|
248450
|
+
throw new Error(`MiniSearch: document does not have ID field "${idField}"`);
|
|
248451
|
+
}
|
|
248452
|
+
const shortId = this._idToShortId.get(id);
|
|
248453
|
+
if (shortId == null) {
|
|
248454
|
+
throw new Error(`MiniSearch: cannot remove document with ID ${id}: it is not in the index`);
|
|
248455
|
+
}
|
|
248456
|
+
for (const field of fields) {
|
|
248457
|
+
const fieldValue = extractField(document2, field);
|
|
248458
|
+
if (fieldValue == null)
|
|
248459
|
+
continue;
|
|
248460
|
+
const tokens = tokenize(fieldValue.toString(), field);
|
|
248461
|
+
const fieldId = this._fieldIds[field];
|
|
248462
|
+
const uniqueTerms = new Set(tokens).size;
|
|
248463
|
+
this.removeFieldLength(shortId, fieldId, this._documentCount, uniqueTerms);
|
|
248464
|
+
for (const term of tokens) {
|
|
248465
|
+
const processedTerm = processTerm(term, field);
|
|
248466
|
+
if (Array.isArray(processedTerm)) {
|
|
248467
|
+
for (const t of processedTerm) {
|
|
248468
|
+
this.removeTerm(fieldId, shortId, t);
|
|
248469
|
+
}
|
|
248470
|
+
} else if (processedTerm) {
|
|
248471
|
+
this.removeTerm(fieldId, shortId, processedTerm);
|
|
248472
|
+
}
|
|
248473
|
+
}
|
|
248474
|
+
}
|
|
248475
|
+
this._storedFields.delete(shortId);
|
|
248476
|
+
this._documentIds.delete(shortId);
|
|
248477
|
+
this._idToShortId.delete(id);
|
|
248478
|
+
this._fieldLength.delete(shortId);
|
|
248479
|
+
this._documentCount -= 1;
|
|
248480
|
+
}
|
|
248481
|
+
removeAll(documents) {
|
|
248482
|
+
if (documents) {
|
|
248483
|
+
for (const document2 of documents)
|
|
248484
|
+
this.remove(document2);
|
|
248485
|
+
} else if (arguments.length > 0) {
|
|
248486
|
+
throw new Error("Expected documents to be present. Omit the argument to remove all documents.");
|
|
248487
|
+
} else {
|
|
248488
|
+
this._index = new SearchableMap;
|
|
248489
|
+
this._documentCount = 0;
|
|
248490
|
+
this._documentIds = new Map;
|
|
248491
|
+
this._idToShortId = new Map;
|
|
248492
|
+
this._fieldLength = new Map;
|
|
248493
|
+
this._avgFieldLength = [];
|
|
248494
|
+
this._storedFields = new Map;
|
|
248495
|
+
this._nextId = 0;
|
|
248496
|
+
}
|
|
248497
|
+
}
|
|
248498
|
+
discard(id) {
|
|
248499
|
+
const shortId = this._idToShortId.get(id);
|
|
248500
|
+
if (shortId == null) {
|
|
248501
|
+
throw new Error(`MiniSearch: cannot discard document with ID ${id}: it is not in the index`);
|
|
248502
|
+
}
|
|
248503
|
+
this._idToShortId.delete(id);
|
|
248504
|
+
this._documentIds.delete(shortId);
|
|
248505
|
+
this._storedFields.delete(shortId);
|
|
248506
|
+
(this._fieldLength.get(shortId) || []).forEach((fieldLength, fieldId) => {
|
|
248507
|
+
this.removeFieldLength(shortId, fieldId, this._documentCount, fieldLength);
|
|
248508
|
+
});
|
|
248509
|
+
this._fieldLength.delete(shortId);
|
|
248510
|
+
this._documentCount -= 1;
|
|
248511
|
+
this._dirtCount += 1;
|
|
248512
|
+
this.maybeAutoVacuum();
|
|
248513
|
+
}
|
|
248514
|
+
maybeAutoVacuum() {
|
|
248515
|
+
if (this._options.autoVacuum === false) {
|
|
248516
|
+
return;
|
|
248517
|
+
}
|
|
248518
|
+
const { minDirtFactor, minDirtCount, batchSize, batchWait } = this._options.autoVacuum;
|
|
248519
|
+
this.conditionalVacuum({ batchSize, batchWait }, { minDirtCount, minDirtFactor });
|
|
248520
|
+
}
|
|
248521
|
+
discardAll(ids) {
|
|
248522
|
+
const autoVacuum = this._options.autoVacuum;
|
|
248523
|
+
try {
|
|
248524
|
+
this._options.autoVacuum = false;
|
|
248525
|
+
for (const id of ids) {
|
|
248526
|
+
this.discard(id);
|
|
248527
|
+
}
|
|
248528
|
+
} finally {
|
|
248529
|
+
this._options.autoVacuum = autoVacuum;
|
|
248530
|
+
}
|
|
248531
|
+
this.maybeAutoVacuum();
|
|
248532
|
+
}
|
|
248533
|
+
replace(updatedDocument) {
|
|
248534
|
+
const { idField, extractField } = this._options;
|
|
248535
|
+
const id = extractField(updatedDocument, idField);
|
|
248536
|
+
this.discard(id);
|
|
248537
|
+
this.add(updatedDocument);
|
|
248538
|
+
}
|
|
248539
|
+
vacuum(options = {}) {
|
|
248540
|
+
return this.conditionalVacuum(options);
|
|
248541
|
+
}
|
|
248542
|
+
conditionalVacuum(options, conditions) {
|
|
248543
|
+
if (this._currentVacuum) {
|
|
248544
|
+
this._enqueuedVacuumConditions = this._enqueuedVacuumConditions && conditions;
|
|
248545
|
+
if (this._enqueuedVacuum != null) {
|
|
248546
|
+
return this._enqueuedVacuum;
|
|
248547
|
+
}
|
|
248548
|
+
this._enqueuedVacuum = this._currentVacuum.then(() => {
|
|
248549
|
+
const conditions = this._enqueuedVacuumConditions;
|
|
248550
|
+
this._enqueuedVacuumConditions = defaultVacuumConditions;
|
|
248551
|
+
return this.performVacuuming(options, conditions);
|
|
248552
|
+
});
|
|
248553
|
+
return this._enqueuedVacuum;
|
|
248554
|
+
}
|
|
248555
|
+
if (this.vacuumConditionsMet(conditions) === false) {
|
|
248556
|
+
return Promise.resolve();
|
|
248557
|
+
}
|
|
248558
|
+
this._currentVacuum = this.performVacuuming(options);
|
|
248559
|
+
return this._currentVacuum;
|
|
248560
|
+
}
|
|
248561
|
+
async performVacuuming(options, conditions) {
|
|
248562
|
+
const initialDirtCount = this._dirtCount;
|
|
248563
|
+
if (this.vacuumConditionsMet(conditions)) {
|
|
248564
|
+
const batchSize = options.batchSize || defaultVacuumOptions.batchSize;
|
|
248565
|
+
const batchWait = options.batchWait || defaultVacuumOptions.batchWait;
|
|
248566
|
+
let i = 1;
|
|
248567
|
+
for (const [term, fieldsData] of this._index) {
|
|
248568
|
+
for (const [fieldId, fieldIndex] of fieldsData) {
|
|
248569
|
+
for (const [shortId] of fieldIndex) {
|
|
248570
|
+
if (this._documentIds.has(shortId)) {
|
|
248571
|
+
continue;
|
|
248572
|
+
}
|
|
248573
|
+
if (fieldIndex.size <= 1) {
|
|
248574
|
+
fieldsData.delete(fieldId);
|
|
248575
|
+
} else {
|
|
248576
|
+
fieldIndex.delete(shortId);
|
|
248577
|
+
}
|
|
248578
|
+
}
|
|
248579
|
+
}
|
|
248580
|
+
if (this._index.get(term).size === 0) {
|
|
248581
|
+
this._index.delete(term);
|
|
248582
|
+
}
|
|
248583
|
+
if (i % batchSize === 0) {
|
|
248584
|
+
await new Promise((resolve) => setTimeout(resolve, batchWait));
|
|
248585
|
+
}
|
|
248586
|
+
i += 1;
|
|
248587
|
+
}
|
|
248588
|
+
this._dirtCount -= initialDirtCount;
|
|
248589
|
+
}
|
|
248590
|
+
await null;
|
|
248591
|
+
this._currentVacuum = this._enqueuedVacuum;
|
|
248592
|
+
this._enqueuedVacuum = null;
|
|
248593
|
+
}
|
|
248594
|
+
vacuumConditionsMet(conditions) {
|
|
248595
|
+
if (conditions == null) {
|
|
248596
|
+
return true;
|
|
248597
|
+
}
|
|
248598
|
+
let { minDirtCount, minDirtFactor } = conditions;
|
|
248599
|
+
minDirtCount = minDirtCount || defaultAutoVacuumOptions.minDirtCount;
|
|
248600
|
+
minDirtFactor = minDirtFactor || defaultAutoVacuumOptions.minDirtFactor;
|
|
248601
|
+
return this.dirtCount >= minDirtCount && this.dirtFactor >= minDirtFactor;
|
|
248602
|
+
}
|
|
248603
|
+
get isVacuuming() {
|
|
248604
|
+
return this._currentVacuum != null;
|
|
248605
|
+
}
|
|
248606
|
+
get dirtCount() {
|
|
248607
|
+
return this._dirtCount;
|
|
248608
|
+
}
|
|
248609
|
+
get dirtFactor() {
|
|
248610
|
+
return this._dirtCount / (1 + this._documentCount + this._dirtCount);
|
|
248611
|
+
}
|
|
248612
|
+
has(id) {
|
|
248613
|
+
return this._idToShortId.has(id);
|
|
248614
|
+
}
|
|
248615
|
+
getStoredFields(id) {
|
|
248616
|
+
const shortId = this._idToShortId.get(id);
|
|
248617
|
+
if (shortId == null) {
|
|
248618
|
+
return;
|
|
248619
|
+
}
|
|
248620
|
+
return this._storedFields.get(shortId);
|
|
248621
|
+
}
|
|
248622
|
+
search(query, searchOptions = {}) {
|
|
248623
|
+
const { searchOptions: globalSearchOptions } = this._options;
|
|
248624
|
+
const searchOptionsWithDefaults = { ...globalSearchOptions, ...searchOptions };
|
|
248625
|
+
const rawResults = this.executeQuery(query, searchOptions);
|
|
248626
|
+
const results = [];
|
|
248627
|
+
for (const [docId, { score, terms, match }] of rawResults) {
|
|
248628
|
+
const quality = terms.length || 1;
|
|
248629
|
+
const result = {
|
|
248630
|
+
id: this._documentIds.get(docId),
|
|
248631
|
+
score: score * quality,
|
|
248632
|
+
terms: Object.keys(match),
|
|
248633
|
+
queryTerms: terms,
|
|
248634
|
+
match
|
|
248635
|
+
};
|
|
248636
|
+
Object.assign(result, this._storedFields.get(docId));
|
|
248637
|
+
if (searchOptionsWithDefaults.filter == null || searchOptionsWithDefaults.filter(result)) {
|
|
248638
|
+
results.push(result);
|
|
248639
|
+
}
|
|
248640
|
+
}
|
|
248641
|
+
if (query === MiniSearch.wildcard && searchOptionsWithDefaults.boostDocument == null) {
|
|
248642
|
+
return results;
|
|
248643
|
+
}
|
|
248644
|
+
results.sort(byScore);
|
|
248645
|
+
return results;
|
|
248646
|
+
}
|
|
248647
|
+
autoSuggest(queryString, options = {}) {
|
|
248648
|
+
options = { ...this._options.autoSuggestOptions, ...options };
|
|
248649
|
+
const suggestions = new Map;
|
|
248650
|
+
for (const { score, terms } of this.search(queryString, options)) {
|
|
248651
|
+
const phrase = terms.join(" ");
|
|
248652
|
+
const suggestion = suggestions.get(phrase);
|
|
248653
|
+
if (suggestion != null) {
|
|
248654
|
+
suggestion.score += score;
|
|
248655
|
+
suggestion.count += 1;
|
|
248656
|
+
} else {
|
|
248657
|
+
suggestions.set(phrase, { score, terms, count: 1 });
|
|
248658
|
+
}
|
|
248659
|
+
}
|
|
248660
|
+
const results = [];
|
|
248661
|
+
for (const [suggestion, { score, terms, count }] of suggestions) {
|
|
248662
|
+
results.push({ suggestion, terms, score: score / count });
|
|
248663
|
+
}
|
|
248664
|
+
results.sort(byScore);
|
|
248665
|
+
return results;
|
|
248666
|
+
}
|
|
248667
|
+
get documentCount() {
|
|
248668
|
+
return this._documentCount;
|
|
248669
|
+
}
|
|
248670
|
+
get termCount() {
|
|
248671
|
+
return this._index.size;
|
|
248672
|
+
}
|
|
248673
|
+
static loadJSON(json, options) {
|
|
248674
|
+
if (options == null) {
|
|
248675
|
+
throw new Error("MiniSearch: loadJSON should be given the same options used when serializing the index");
|
|
248676
|
+
}
|
|
248677
|
+
return this.loadJS(JSON.parse(json), options);
|
|
248678
|
+
}
|
|
248679
|
+
static async loadJSONAsync(json, options) {
|
|
248680
|
+
if (options == null) {
|
|
248681
|
+
throw new Error("MiniSearch: loadJSON should be given the same options used when serializing the index");
|
|
248682
|
+
}
|
|
248683
|
+
return this.loadJSAsync(JSON.parse(json), options);
|
|
248684
|
+
}
|
|
248685
|
+
static getDefault(optionName) {
|
|
248686
|
+
if (defaultOptions.hasOwnProperty(optionName)) {
|
|
248687
|
+
return getOwnProperty(defaultOptions, optionName);
|
|
248688
|
+
} else {
|
|
248689
|
+
throw new Error(`MiniSearch: unknown option "${optionName}"`);
|
|
248690
|
+
}
|
|
248691
|
+
}
|
|
248692
|
+
static loadJS(js, options) {
|
|
248693
|
+
const { index, documentIds, fieldLength, storedFields, serializationVersion } = js;
|
|
248694
|
+
const miniSearch = this.instantiateMiniSearch(js, options);
|
|
248695
|
+
miniSearch._documentIds = objectToNumericMap(documentIds);
|
|
248696
|
+
miniSearch._fieldLength = objectToNumericMap(fieldLength);
|
|
248697
|
+
miniSearch._storedFields = objectToNumericMap(storedFields);
|
|
248698
|
+
for (const [shortId, id] of miniSearch._documentIds) {
|
|
248699
|
+
miniSearch._idToShortId.set(id, shortId);
|
|
248700
|
+
}
|
|
248701
|
+
for (const [term, data] of index) {
|
|
248702
|
+
const dataMap = new Map;
|
|
248703
|
+
for (const fieldId of Object.keys(data)) {
|
|
248704
|
+
let indexEntry = data[fieldId];
|
|
248705
|
+
if (serializationVersion === 1) {
|
|
248706
|
+
indexEntry = indexEntry.ds;
|
|
248707
|
+
}
|
|
248708
|
+
dataMap.set(parseInt(fieldId, 10), objectToNumericMap(indexEntry));
|
|
248709
|
+
}
|
|
248710
|
+
miniSearch._index.set(term, dataMap);
|
|
248711
|
+
}
|
|
248712
|
+
return miniSearch;
|
|
248713
|
+
}
|
|
248714
|
+
static async loadJSAsync(js, options) {
|
|
248715
|
+
const { index, documentIds, fieldLength, storedFields, serializationVersion } = js;
|
|
248716
|
+
const miniSearch = this.instantiateMiniSearch(js, options);
|
|
248717
|
+
miniSearch._documentIds = await objectToNumericMapAsync(documentIds);
|
|
248718
|
+
miniSearch._fieldLength = await objectToNumericMapAsync(fieldLength);
|
|
248719
|
+
miniSearch._storedFields = await objectToNumericMapAsync(storedFields);
|
|
248720
|
+
for (const [shortId, id] of miniSearch._documentIds) {
|
|
248721
|
+
miniSearch._idToShortId.set(id, shortId);
|
|
248722
|
+
}
|
|
248723
|
+
let count = 0;
|
|
248724
|
+
for (const [term, data] of index) {
|
|
248725
|
+
const dataMap = new Map;
|
|
248726
|
+
for (const fieldId of Object.keys(data)) {
|
|
248727
|
+
let indexEntry = data[fieldId];
|
|
248728
|
+
if (serializationVersion === 1) {
|
|
248729
|
+
indexEntry = indexEntry.ds;
|
|
248730
|
+
}
|
|
248731
|
+
dataMap.set(parseInt(fieldId, 10), await objectToNumericMapAsync(indexEntry));
|
|
248732
|
+
}
|
|
248733
|
+
if (++count % 1000 === 0)
|
|
248734
|
+
await wait(0);
|
|
248735
|
+
miniSearch._index.set(term, dataMap);
|
|
248736
|
+
}
|
|
248737
|
+
return miniSearch;
|
|
248738
|
+
}
|
|
248739
|
+
static instantiateMiniSearch(js, options) {
|
|
248740
|
+
const { documentCount, nextId, fieldIds, averageFieldLength, dirtCount, serializationVersion } = js;
|
|
248741
|
+
if (serializationVersion !== 1 && serializationVersion !== 2) {
|
|
248742
|
+
throw new Error("MiniSearch: cannot deserialize an index created with an incompatible version");
|
|
248743
|
+
}
|
|
248744
|
+
const miniSearch = new MiniSearch(options);
|
|
248745
|
+
miniSearch._documentCount = documentCount;
|
|
248746
|
+
miniSearch._nextId = nextId;
|
|
248747
|
+
miniSearch._idToShortId = new Map;
|
|
248748
|
+
miniSearch._fieldIds = fieldIds;
|
|
248749
|
+
miniSearch._avgFieldLength = averageFieldLength;
|
|
248750
|
+
miniSearch._dirtCount = dirtCount || 0;
|
|
248751
|
+
miniSearch._index = new SearchableMap;
|
|
248752
|
+
return miniSearch;
|
|
248753
|
+
}
|
|
248754
|
+
executeQuery(query, searchOptions = {}) {
|
|
248755
|
+
if (query === MiniSearch.wildcard) {
|
|
248756
|
+
return this.executeWildcardQuery(searchOptions);
|
|
248757
|
+
}
|
|
248758
|
+
if (typeof query !== "string") {
|
|
248759
|
+
const options = { ...searchOptions, ...query, queries: undefined };
|
|
248760
|
+
const results = query.queries.map((subquery) => this.executeQuery(subquery, options));
|
|
248761
|
+
return this.combineResults(results, options.combineWith);
|
|
248762
|
+
}
|
|
248763
|
+
const { tokenize, processTerm, searchOptions: globalSearchOptions } = this._options;
|
|
248764
|
+
const options = { tokenize, processTerm, ...globalSearchOptions, ...searchOptions };
|
|
248765
|
+
const { tokenize: searchTokenize, processTerm: searchProcessTerm } = options;
|
|
248766
|
+
const terms = searchTokenize(query).flatMap((term) => searchProcessTerm(term)).filter((term) => !!term);
|
|
248767
|
+
const queries = terms.map(termToQuerySpec(options));
|
|
248768
|
+
const results = queries.map((query) => this.executeQuerySpec(query, options));
|
|
248769
|
+
return this.combineResults(results, options.combineWith);
|
|
248770
|
+
}
|
|
248771
|
+
executeQuerySpec(query, searchOptions) {
|
|
248772
|
+
const options = { ...this._options.searchOptions, ...searchOptions };
|
|
248773
|
+
const boosts = (options.fields || this._options.fields).reduce((boosts, field) => ({ ...boosts, [field]: getOwnProperty(options.boost, field) || 1 }), {});
|
|
248774
|
+
const { boostDocument, weights, maxFuzzy, bm25: bm25params } = options;
|
|
248775
|
+
const { fuzzy: fuzzyWeight, prefix: prefixWeight } = { ...defaultSearchOptions.weights, ...weights };
|
|
248776
|
+
const data = this._index.get(query.term);
|
|
248777
|
+
const results = this.termResults(query.term, query.term, 1, query.termBoost, data, boosts, boostDocument, bm25params);
|
|
248778
|
+
let prefixMatches;
|
|
248779
|
+
let fuzzyMatches;
|
|
248780
|
+
if (query.prefix) {
|
|
248781
|
+
prefixMatches = this._index.atPrefix(query.term);
|
|
248782
|
+
}
|
|
248783
|
+
if (query.fuzzy) {
|
|
248784
|
+
const fuzzy = query.fuzzy === true ? 0.2 : query.fuzzy;
|
|
248785
|
+
const maxDistance = fuzzy < 1 ? Math.min(maxFuzzy, Math.round(query.term.length * fuzzy)) : fuzzy;
|
|
248786
|
+
if (maxDistance)
|
|
248787
|
+
fuzzyMatches = this._index.fuzzyGet(query.term, maxDistance);
|
|
248788
|
+
}
|
|
248789
|
+
if (prefixMatches) {
|
|
248790
|
+
for (const [term, data] of prefixMatches) {
|
|
248791
|
+
const distance = term.length - query.term.length;
|
|
248792
|
+
if (!distance) {
|
|
248793
|
+
continue;
|
|
248794
|
+
}
|
|
248795
|
+
fuzzyMatches === null || fuzzyMatches === undefined || fuzzyMatches.delete(term);
|
|
248796
|
+
const weight = prefixWeight * term.length / (term.length + 0.3 * distance);
|
|
248797
|
+
this.termResults(query.term, term, weight, query.termBoost, data, boosts, boostDocument, bm25params, results);
|
|
248798
|
+
}
|
|
248799
|
+
}
|
|
248800
|
+
if (fuzzyMatches) {
|
|
248801
|
+
for (const term of fuzzyMatches.keys()) {
|
|
248802
|
+
const [data, distance] = fuzzyMatches.get(term);
|
|
248803
|
+
if (!distance) {
|
|
248804
|
+
continue;
|
|
248805
|
+
}
|
|
248806
|
+
const weight = fuzzyWeight * term.length / (term.length + distance);
|
|
248807
|
+
this.termResults(query.term, term, weight, query.termBoost, data, boosts, boostDocument, bm25params, results);
|
|
248808
|
+
}
|
|
248809
|
+
}
|
|
248810
|
+
return results;
|
|
248811
|
+
}
|
|
248812
|
+
executeWildcardQuery(searchOptions) {
|
|
248813
|
+
const results = new Map;
|
|
248814
|
+
const options = { ...this._options.searchOptions, ...searchOptions };
|
|
248815
|
+
for (const [shortId, id] of this._documentIds) {
|
|
248816
|
+
const score = options.boostDocument ? options.boostDocument(id, "", this._storedFields.get(shortId)) : 1;
|
|
248817
|
+
results.set(shortId, {
|
|
248818
|
+
score,
|
|
248819
|
+
terms: [],
|
|
248820
|
+
match: {}
|
|
248821
|
+
});
|
|
248822
|
+
}
|
|
248823
|
+
return results;
|
|
248824
|
+
}
|
|
248825
|
+
combineResults(results, combineWith = OR) {
|
|
248826
|
+
if (results.length === 0) {
|
|
248827
|
+
return new Map;
|
|
248828
|
+
}
|
|
248829
|
+
const operator = combineWith.toLowerCase();
|
|
248830
|
+
const combinator = combinators[operator];
|
|
248831
|
+
if (!combinator) {
|
|
248832
|
+
throw new Error(`Invalid combination operator: ${combineWith}`);
|
|
248833
|
+
}
|
|
248834
|
+
return results.reduce(combinator) || new Map;
|
|
248835
|
+
}
|
|
248836
|
+
toJSON() {
|
|
248837
|
+
const index = [];
|
|
248838
|
+
for (const [term, fieldIndex] of this._index) {
|
|
248839
|
+
const data = {};
|
|
248840
|
+
for (const [fieldId, freqs] of fieldIndex) {
|
|
248841
|
+
data[fieldId] = Object.fromEntries(freqs);
|
|
248842
|
+
}
|
|
248843
|
+
index.push([term, data]);
|
|
248844
|
+
}
|
|
248845
|
+
return {
|
|
248846
|
+
documentCount: this._documentCount,
|
|
248847
|
+
nextId: this._nextId,
|
|
248848
|
+
documentIds: Object.fromEntries(this._documentIds),
|
|
248849
|
+
fieldIds: this._fieldIds,
|
|
248850
|
+
fieldLength: Object.fromEntries(this._fieldLength),
|
|
248851
|
+
averageFieldLength: this._avgFieldLength,
|
|
248852
|
+
storedFields: Object.fromEntries(this._storedFields),
|
|
248853
|
+
dirtCount: this._dirtCount,
|
|
248854
|
+
index,
|
|
248855
|
+
serializationVersion: 2
|
|
248856
|
+
};
|
|
248857
|
+
}
|
|
248858
|
+
termResults(sourceTerm, derivedTerm, termWeight, termBoost, fieldTermData, fieldBoosts, boostDocumentFn, bm25params, results = new Map) {
|
|
248859
|
+
if (fieldTermData == null)
|
|
248860
|
+
return results;
|
|
248861
|
+
for (const field of Object.keys(fieldBoosts)) {
|
|
248862
|
+
const fieldBoost = fieldBoosts[field];
|
|
248863
|
+
const fieldId = this._fieldIds[field];
|
|
248864
|
+
const fieldTermFreqs = fieldTermData.get(fieldId);
|
|
248865
|
+
if (fieldTermFreqs == null)
|
|
248866
|
+
continue;
|
|
248867
|
+
let matchingFields = fieldTermFreqs.size;
|
|
248868
|
+
const avgFieldLength = this._avgFieldLength[fieldId];
|
|
248869
|
+
for (const docId of fieldTermFreqs.keys()) {
|
|
248870
|
+
if (!this._documentIds.has(docId)) {
|
|
248871
|
+
this.removeTerm(fieldId, docId, derivedTerm);
|
|
248872
|
+
matchingFields -= 1;
|
|
248873
|
+
continue;
|
|
248874
|
+
}
|
|
248875
|
+
const docBoost = boostDocumentFn ? boostDocumentFn(this._documentIds.get(docId), derivedTerm, this._storedFields.get(docId)) : 1;
|
|
248876
|
+
if (!docBoost)
|
|
248877
|
+
continue;
|
|
248878
|
+
const termFreq = fieldTermFreqs.get(docId);
|
|
248879
|
+
const fieldLength = this._fieldLength.get(docId)[fieldId];
|
|
248880
|
+
const rawScore = calcBM25Score(termFreq, matchingFields, this._documentCount, fieldLength, avgFieldLength, bm25params);
|
|
248881
|
+
const weightedScore = termWeight * termBoost * fieldBoost * docBoost * rawScore;
|
|
248882
|
+
const result = results.get(docId);
|
|
248883
|
+
if (result) {
|
|
248884
|
+
result.score += weightedScore;
|
|
248885
|
+
assignUniqueTerm(result.terms, sourceTerm);
|
|
248886
|
+
const match = getOwnProperty(result.match, derivedTerm);
|
|
248887
|
+
if (match) {
|
|
248888
|
+
match.push(field);
|
|
248889
|
+
} else {
|
|
248890
|
+
result.match[derivedTerm] = [field];
|
|
248891
|
+
}
|
|
248892
|
+
} else {
|
|
248893
|
+
results.set(docId, {
|
|
248894
|
+
score: weightedScore,
|
|
248895
|
+
terms: [sourceTerm],
|
|
248896
|
+
match: { [derivedTerm]: [field] }
|
|
248897
|
+
});
|
|
248898
|
+
}
|
|
248899
|
+
}
|
|
248900
|
+
}
|
|
248901
|
+
return results;
|
|
248902
|
+
}
|
|
248903
|
+
addTerm(fieldId, documentId, term) {
|
|
248904
|
+
const indexData = this._index.fetch(term, createMap);
|
|
248905
|
+
let fieldIndex = indexData.get(fieldId);
|
|
248906
|
+
if (fieldIndex == null) {
|
|
248907
|
+
fieldIndex = new Map;
|
|
248908
|
+
fieldIndex.set(documentId, 1);
|
|
248909
|
+
indexData.set(fieldId, fieldIndex);
|
|
248910
|
+
} else {
|
|
248911
|
+
const docs = fieldIndex.get(documentId);
|
|
248912
|
+
fieldIndex.set(documentId, (docs || 0) + 1);
|
|
248913
|
+
}
|
|
248914
|
+
}
|
|
248915
|
+
removeTerm(fieldId, documentId, term) {
|
|
248916
|
+
if (!this._index.has(term)) {
|
|
248917
|
+
this.warnDocumentChanged(documentId, fieldId, term);
|
|
248918
|
+
return;
|
|
248919
|
+
}
|
|
248920
|
+
const indexData = this._index.fetch(term, createMap);
|
|
248921
|
+
const fieldIndex = indexData.get(fieldId);
|
|
248922
|
+
if (fieldIndex == null || fieldIndex.get(documentId) == null) {
|
|
248923
|
+
this.warnDocumentChanged(documentId, fieldId, term);
|
|
248924
|
+
} else if (fieldIndex.get(documentId) <= 1) {
|
|
248925
|
+
if (fieldIndex.size <= 1) {
|
|
248926
|
+
indexData.delete(fieldId);
|
|
248927
|
+
} else {
|
|
248928
|
+
fieldIndex.delete(documentId);
|
|
248929
|
+
}
|
|
248930
|
+
} else {
|
|
248931
|
+
fieldIndex.set(documentId, fieldIndex.get(documentId) - 1);
|
|
248932
|
+
}
|
|
248933
|
+
if (this._index.get(term).size === 0) {
|
|
248934
|
+
this._index.delete(term);
|
|
248935
|
+
}
|
|
248936
|
+
}
|
|
248937
|
+
warnDocumentChanged(shortDocumentId, fieldId, term) {
|
|
248938
|
+
for (const fieldName of Object.keys(this._fieldIds)) {
|
|
248939
|
+
if (this._fieldIds[fieldName] === fieldId) {
|
|
248940
|
+
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");
|
|
248941
|
+
return;
|
|
248942
|
+
}
|
|
248943
|
+
}
|
|
248944
|
+
}
|
|
248945
|
+
addDocumentId(documentId) {
|
|
248946
|
+
const shortDocumentId = this._nextId;
|
|
248947
|
+
this._idToShortId.set(documentId, shortDocumentId);
|
|
248948
|
+
this._documentIds.set(shortDocumentId, documentId);
|
|
248949
|
+
this._documentCount += 1;
|
|
248950
|
+
this._nextId += 1;
|
|
248951
|
+
return shortDocumentId;
|
|
248952
|
+
}
|
|
248953
|
+
addFields(fields) {
|
|
248954
|
+
for (let i = 0;i < fields.length; i++) {
|
|
248955
|
+
this._fieldIds[fields[i]] = i;
|
|
248956
|
+
}
|
|
248957
|
+
}
|
|
248958
|
+
addFieldLength(documentId, fieldId, count, length) {
|
|
248959
|
+
let fieldLengths = this._fieldLength.get(documentId);
|
|
248960
|
+
if (fieldLengths == null)
|
|
248961
|
+
this._fieldLength.set(documentId, fieldLengths = []);
|
|
248962
|
+
fieldLengths[fieldId] = length;
|
|
248963
|
+
const averageFieldLength = this._avgFieldLength[fieldId] || 0;
|
|
248964
|
+
const totalFieldLength = averageFieldLength * count + length;
|
|
248965
|
+
this._avgFieldLength[fieldId] = totalFieldLength / (count + 1);
|
|
248966
|
+
}
|
|
248967
|
+
removeFieldLength(documentId, fieldId, count, length) {
|
|
248968
|
+
if (count === 1) {
|
|
248969
|
+
this._avgFieldLength[fieldId] = 0;
|
|
248970
|
+
return;
|
|
248971
|
+
}
|
|
248972
|
+
const totalFieldLength = this._avgFieldLength[fieldId] * count - length;
|
|
248973
|
+
this._avgFieldLength[fieldId] = totalFieldLength / (count - 1);
|
|
248974
|
+
}
|
|
248975
|
+
saveStoredFields(documentId, doc) {
|
|
248976
|
+
const { storeFields, extractField } = this._options;
|
|
248977
|
+
if (storeFields == null || storeFields.length === 0) {
|
|
248978
|
+
return;
|
|
248979
|
+
}
|
|
248980
|
+
let documentFields = this._storedFields.get(documentId);
|
|
248981
|
+
if (documentFields == null)
|
|
248982
|
+
this._storedFields.set(documentId, documentFields = {});
|
|
248983
|
+
for (const fieldName of storeFields) {
|
|
248984
|
+
const fieldValue = extractField(doc, fieldName);
|
|
248985
|
+
if (fieldValue !== undefined)
|
|
248986
|
+
documentFields[fieldName] = fieldValue;
|
|
248987
|
+
}
|
|
248988
|
+
}
|
|
248989
|
+
}
|
|
248990
|
+
MiniSearch.wildcard = Symbol("*");
|
|
248991
|
+
var getOwnProperty = (object, property) => Object.prototype.hasOwnProperty.call(object, property) ? object[property] : undefined;
|
|
248992
|
+
var combinators = {
|
|
248993
|
+
[OR]: (a, b) => {
|
|
248994
|
+
for (const docId of b.keys()) {
|
|
248995
|
+
const existing = a.get(docId);
|
|
248996
|
+
if (existing == null) {
|
|
248997
|
+
a.set(docId, b.get(docId));
|
|
248998
|
+
} else {
|
|
248999
|
+
const { score, terms, match } = b.get(docId);
|
|
249000
|
+
existing.score = existing.score + score;
|
|
249001
|
+
existing.match = Object.assign(existing.match, match);
|
|
249002
|
+
assignUniqueTerms(existing.terms, terms);
|
|
249003
|
+
}
|
|
249004
|
+
}
|
|
249005
|
+
return a;
|
|
249006
|
+
},
|
|
249007
|
+
[AND]: (a, b) => {
|
|
249008
|
+
const combined = new Map;
|
|
249009
|
+
for (const docId of b.keys()) {
|
|
249010
|
+
const existing = a.get(docId);
|
|
249011
|
+
if (existing == null)
|
|
249012
|
+
continue;
|
|
249013
|
+
const { score, terms, match } = b.get(docId);
|
|
249014
|
+
assignUniqueTerms(existing.terms, terms);
|
|
249015
|
+
combined.set(docId, {
|
|
249016
|
+
score: existing.score + score,
|
|
249017
|
+
terms: existing.terms,
|
|
249018
|
+
match: Object.assign(existing.match, match)
|
|
249019
|
+
});
|
|
249020
|
+
}
|
|
249021
|
+
return combined;
|
|
249022
|
+
},
|
|
249023
|
+
[AND_NOT]: (a, b) => {
|
|
249024
|
+
for (const docId of b.keys())
|
|
249025
|
+
a.delete(docId);
|
|
249026
|
+
return a;
|
|
249027
|
+
}
|
|
249028
|
+
};
|
|
249029
|
+
var defaultBM25params = { k: 1.2, b: 0.7, d: 0.5 };
|
|
249030
|
+
var calcBM25Score = (termFreq, matchingCount, totalCount, fieldLength, avgFieldLength, bm25params) => {
|
|
249031
|
+
const { k, b, d } = bm25params;
|
|
249032
|
+
const invDocFreq = Math.log(1 + (totalCount - matchingCount + 0.5) / (matchingCount + 0.5));
|
|
249033
|
+
return invDocFreq * (d + termFreq * (k + 1) / (termFreq + k * (1 - b + b * fieldLength / avgFieldLength)));
|
|
249034
|
+
};
|
|
249035
|
+
var termToQuerySpec = (options) => (term, i, terms) => {
|
|
249036
|
+
const fuzzy = typeof options.fuzzy === "function" ? options.fuzzy(term, i, terms) : options.fuzzy || false;
|
|
249037
|
+
const prefix = typeof options.prefix === "function" ? options.prefix(term, i, terms) : options.prefix === true;
|
|
249038
|
+
const termBoost = typeof options.boostTerm === "function" ? options.boostTerm(term, i, terms) : 1;
|
|
249039
|
+
return { term, fuzzy, prefix, termBoost };
|
|
249040
|
+
};
|
|
249041
|
+
var defaultOptions = {
|
|
249042
|
+
idField: "id",
|
|
249043
|
+
extractField: (document2, fieldName) => document2[fieldName],
|
|
249044
|
+
tokenize: (text) => text.split(SPACE_OR_PUNCTUATION),
|
|
249045
|
+
processTerm: (term) => term.toLowerCase(),
|
|
249046
|
+
fields: undefined,
|
|
249047
|
+
searchOptions: undefined,
|
|
249048
|
+
storeFields: [],
|
|
249049
|
+
logger: (level, message) => {
|
|
249050
|
+
if (typeof (console === null || console === undefined ? undefined : console[level]) === "function")
|
|
249051
|
+
console[level](message);
|
|
249052
|
+
},
|
|
249053
|
+
autoVacuum: true
|
|
249054
|
+
};
|
|
249055
|
+
var defaultSearchOptions = {
|
|
249056
|
+
combineWith: OR,
|
|
249057
|
+
prefix: false,
|
|
249058
|
+
fuzzy: false,
|
|
249059
|
+
maxFuzzy: 6,
|
|
249060
|
+
boost: {},
|
|
249061
|
+
weights: { fuzzy: 0.45, prefix: 0.375 },
|
|
249062
|
+
bm25: defaultBM25params
|
|
249063
|
+
};
|
|
249064
|
+
var defaultAutoSuggestOptions = {
|
|
249065
|
+
combineWith: AND,
|
|
249066
|
+
prefix: (term, i, terms) => i === terms.length - 1
|
|
249067
|
+
};
|
|
249068
|
+
var defaultVacuumOptions = { batchSize: 1000, batchWait: 10 };
|
|
249069
|
+
var defaultVacuumConditions = { minDirtFactor: 0.1, minDirtCount: 20 };
|
|
249070
|
+
var defaultAutoVacuumOptions = { ...defaultVacuumOptions, ...defaultVacuumConditions };
|
|
249071
|
+
var assignUniqueTerm = (target, term) => {
|
|
249072
|
+
if (!target.includes(term))
|
|
249073
|
+
target.push(term);
|
|
249074
|
+
};
|
|
249075
|
+
var assignUniqueTerms = (target, source) => {
|
|
249076
|
+
for (const term of source) {
|
|
249077
|
+
if (!target.includes(term))
|
|
249078
|
+
target.push(term);
|
|
249079
|
+
}
|
|
249080
|
+
};
|
|
249081
|
+
var byScore = ({ score: a }, { score: b }) => b - a;
|
|
249082
|
+
var createMap = () => new Map;
|
|
249083
|
+
var objectToNumericMap = (object) => {
|
|
249084
|
+
const map = new Map;
|
|
249085
|
+
for (const key of Object.keys(object)) {
|
|
249086
|
+
map.set(parseInt(key, 10), object[key]);
|
|
249087
|
+
}
|
|
249088
|
+
return map;
|
|
249089
|
+
};
|
|
249090
|
+
var objectToNumericMapAsync = async (object) => {
|
|
249091
|
+
const map = new Map;
|
|
249092
|
+
let count = 0;
|
|
249093
|
+
for (const key of Object.keys(object)) {
|
|
249094
|
+
map.set(parseInt(key, 10), object[key]);
|
|
249095
|
+
if (++count % 1000 === 0) {
|
|
249096
|
+
await wait(0);
|
|
249097
|
+
}
|
|
249098
|
+
}
|
|
249099
|
+
return map;
|
|
249100
|
+
};
|
|
249101
|
+
var wait = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
249102
|
+
var SPACE_OR_PUNCTUATION = /[\n\r\p{Z}\p{P}]+/u;
|
|
249103
|
+
|
|
249104
|
+
// src/core/api-spec/search.ts
|
|
249105
|
+
var BOOST = {
|
|
249106
|
+
method: 1,
|
|
249107
|
+
path: 8,
|
|
249108
|
+
summary: 5,
|
|
249109
|
+
description: 2,
|
|
249110
|
+
parameters: 0.5
|
|
249111
|
+
};
|
|
249112
|
+
var MIN_RELATIVE_SCORE = 0.2;
|
|
249113
|
+
var TOKEN_SEPARATOR = /[\n\r\p{Z}\p{P}\p{S}]+/u;
|
|
249114
|
+
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(" "));
|
|
249115
|
+
function tokenize(text) {
|
|
249116
|
+
return text.split(TOKEN_SEPARATOR).filter((word) => word.length >= 2 && !STOPWORDS.has(word.toLowerCase()));
|
|
249117
|
+
}
|
|
249118
|
+
function toOperationSummary(op) {
|
|
249119
|
+
return { endpoint: op.endpoint, summary: op.summary };
|
|
249120
|
+
}
|
|
249121
|
+
function buildSearchIndex(operations) {
|
|
249122
|
+
const index = new MiniSearch({
|
|
249123
|
+
fields: ["method", "path", "summary", "description", "parameters"],
|
|
249124
|
+
tokenize
|
|
249125
|
+
});
|
|
249126
|
+
index.addAll(operations.map((op, id) => ({
|
|
249127
|
+
id,
|
|
249128
|
+
method: op.method,
|
|
249129
|
+
path: op.path.replace(/\{[^}]*\}/g, ""),
|
|
249130
|
+
summary: op.summary,
|
|
249131
|
+
description: op.description,
|
|
249132
|
+
parameters: op.parameterText
|
|
249133
|
+
})));
|
|
249134
|
+
return index;
|
|
249135
|
+
}
|
|
249136
|
+
function summaryMatch(terms, op) {
|
|
249137
|
+
const words = tokenize(op?.summary.toLowerCase() ?? "");
|
|
249138
|
+
const named = (word) => terms.some((term) => word.startsWith(term));
|
|
249139
|
+
return {
|
|
249140
|
+
coverage: terms.filter((term) => words.some((word) => word.startsWith(term))).length / terms.length,
|
|
249141
|
+
precision: words.length ? words.filter(named).length / words.length : 0
|
|
249142
|
+
};
|
|
249143
|
+
}
|
|
249144
|
+
var readsFirst = (op) => op?.method === "GET" ? 0 : 1;
|
|
249145
|
+
function searchOperations(operations, query, options = {}) {
|
|
249146
|
+
const terms = tokenize(query.toLowerCase());
|
|
249147
|
+
if (terms.length === 0) {
|
|
249148
|
+
return [];
|
|
249149
|
+
}
|
|
249150
|
+
const index = buildSearchIndex(operations);
|
|
249151
|
+
const hits = index.search(query, {
|
|
249152
|
+
prefix: (term) => term.length >= 3,
|
|
249153
|
+
fuzzy: (term) => term.length >= 4 ? 0.2 : false,
|
|
249154
|
+
boost: BOOST,
|
|
249155
|
+
filter: options.readOnly ? (hit) => operations[hit.id]?.readOnly === true : undefined
|
|
249156
|
+
}).map((hit) => {
|
|
249157
|
+
const match = summaryMatch(terms, operations[hit.id]);
|
|
249158
|
+
return {
|
|
249159
|
+
...hit,
|
|
249160
|
+
...match,
|
|
249161
|
+
full: match.coverage === 1,
|
|
249162
|
+
score: hit.score * (1 + match.coverage)
|
|
249163
|
+
};
|
|
249164
|
+
}).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);
|
|
249165
|
+
const baseline = Math.max(0, ...hits.map((hit) => hit.score)) * MIN_RELATIVE_SCORE;
|
|
249166
|
+
return hits.filter((hit) => hit.full || hit.score >= baseline).slice(0, options.limit ?? 5).flatMap((hit) => {
|
|
249167
|
+
const op = operations[hit.id];
|
|
249168
|
+
return op ? [toOperationSummary(op)] : [];
|
|
249169
|
+
});
|
|
249170
|
+
}
|
|
249171
|
+
|
|
249172
|
+
// src/core/api-spec/catalog.ts
|
|
249173
|
+
var INLINE_AREA_MAX = 2;
|
|
249174
|
+
var AREA_SAMPLE_MAX = 3;
|
|
249175
|
+
var AREA_OPERATIONS_MAX = 200;
|
|
249176
|
+
var byCodePoint = (a, b) => a < b ? -1 : a > b ? 1 : 0;
|
|
249177
|
+
function areaOf(path) {
|
|
249178
|
+
const parts = path.split("/").filter(Boolean);
|
|
249179
|
+
const appIdIndex = parts.indexOf("{app_id}");
|
|
249180
|
+
if (appIdIndex !== -1 && appIdIndex + 1 < parts.length) {
|
|
249181
|
+
return parts[appIdIndex + 1] ?? "other";
|
|
249182
|
+
}
|
|
249183
|
+
if (parts[0] === "api" && parts.length > 1) {
|
|
249184
|
+
return parts[1] ?? "other";
|
|
249185
|
+
}
|
|
249186
|
+
return parts[0] ?? "other";
|
|
249187
|
+
}
|
|
249188
|
+
function groupByArea(operations) {
|
|
249189
|
+
const sorted = [...operations].sort((a, b) => byCodePoint(`${a.method} ${a.path}`, `${b.method} ${b.path}`));
|
|
249190
|
+
const areas = new Map;
|
|
249191
|
+
for (const op of sorted) {
|
|
249192
|
+
const area = areaOf(op.path);
|
|
249193
|
+
areas.set(area, [...areas.get(area) ?? [], op]);
|
|
249194
|
+
}
|
|
249195
|
+
return new Map([...areas].sort(([a], [b]) => byCodePoint(a, b)));
|
|
249196
|
+
}
|
|
249197
|
+
function readsFirst2(ops) {
|
|
249198
|
+
const isRead = (op) => op.method === "GET" ? 0 : 1;
|
|
249199
|
+
return [...ops].sort((a, b) => isRead(a) - isRead(b));
|
|
249200
|
+
}
|
|
249201
|
+
function catalogIndex(operations) {
|
|
249202
|
+
const areas = [...groupByArea(operations)].map(([area, ops]) => ops.length <= INLINE_AREA_MAX ? { area, operations: ops.map(toOperationSummary) } : {
|
|
249203
|
+
area,
|
|
249204
|
+
operationCount: ops.length,
|
|
249205
|
+
sample: readsFirst2(ops).slice(0, AREA_SAMPLE_MAX).map((op) => op.summary)
|
|
249206
|
+
});
|
|
249207
|
+
return { areas, total: operations.length };
|
|
249208
|
+
}
|
|
249209
|
+
function areaListing(area, operations, max = AREA_OPERATIONS_MAX) {
|
|
249210
|
+
return {
|
|
249211
|
+
area,
|
|
249212
|
+
operations: operations.slice(0, max).map(toOperationSummary),
|
|
249213
|
+
total: operations.length,
|
|
249214
|
+
truncated: operations.length > max
|
|
249215
|
+
};
|
|
249216
|
+
}
|
|
249217
|
+
// src/core/api-spec/schema.ts
|
|
249218
|
+
var HTTP_METHODS = [
|
|
249219
|
+
"get",
|
|
249220
|
+
"put",
|
|
249221
|
+
"post",
|
|
249222
|
+
"delete",
|
|
249223
|
+
"patch",
|
|
249224
|
+
"head",
|
|
249225
|
+
"options",
|
|
249226
|
+
"trace"
|
|
249227
|
+
];
|
|
249228
|
+
var ParameterSchema = looseObject({
|
|
249229
|
+
name: string2(),
|
|
249230
|
+
in: string2(),
|
|
249231
|
+
required: boolean2().optional(),
|
|
249232
|
+
description: string2().optional(),
|
|
249233
|
+
schema: unknown().optional(),
|
|
249234
|
+
example: unknown().optional()
|
|
249235
|
+
});
|
|
249236
|
+
var MediaTypesSchema = record(string2(), looseObject({ schema: unknown().optional() }));
|
|
249237
|
+
var MediaContentSchema = looseObject({
|
|
249238
|
+
content: MediaTypesSchema.optional()
|
|
249239
|
+
});
|
|
249240
|
+
var ResponseObjectSchema = looseObject({
|
|
249241
|
+
description: string2().optional(),
|
|
249242
|
+
content: MediaTypesSchema.optional()
|
|
249243
|
+
});
|
|
249244
|
+
var SecurityRequirementSchema = record(string2(), array(string2()));
|
|
249245
|
+
var OperationSchema = looseObject({
|
|
249246
|
+
summary: string2().optional(),
|
|
249247
|
+
description: string2().optional(),
|
|
249248
|
+
operationId: string2().optional(),
|
|
249249
|
+
parameters: array(unknown()).optional(),
|
|
249250
|
+
requestBody: unknown().optional(),
|
|
249251
|
+
responses: record(string2(), unknown()).optional(),
|
|
249252
|
+
security: array(SecurityRequirementSchema).optional()
|
|
249253
|
+
});
|
|
249254
|
+
var OpenApiSpecSchema = looseObject({
|
|
249255
|
+
openapi: string2(),
|
|
249256
|
+
paths: record(string2(), record(string2(), unknown())),
|
|
249257
|
+
components: looseObject({
|
|
249258
|
+
schemas: record(string2(), unknown()).optional()
|
|
249259
|
+
}).optional(),
|
|
249260
|
+
security: array(SecurityRequirementSchema).optional().catch(undefined)
|
|
249261
|
+
});
|
|
249262
|
+
var ParameterListSchema = array(unknown());
|
|
249263
|
+
|
|
249264
|
+
// src/core/api-spec/text.ts
|
|
249265
|
+
var DOCS_CALLOUT = /<(Info|Note|Tip|Check|Warning)>([\s\S]*?)<\/\1>/g;
|
|
249266
|
+
var RELATIVE_LINK = /\[([^\]]+)\]\(\/[^)]*\)/g;
|
|
249267
|
+
function cleanText(text) {
|
|
249268
|
+
return text.replace(DOCS_CALLOUT, (_, kind, body) => kind === "Warning" ? `Warning: ${body}` : body).replace(RELATIVE_LINK, "$1");
|
|
249269
|
+
}
|
|
249270
|
+
|
|
249271
|
+
// src/core/api-spec/operations.ts
|
|
249272
|
+
var PERSONAL_ACCESS_TOKEN_SCHEME = "PersonalAccessTokenAuth";
|
|
249273
|
+
var READ_ONLY_SCOPE = "read_only";
|
|
249274
|
+
function isReadOnly(operation, spec) {
|
|
249275
|
+
const security = operation.security ?? spec.security ?? [];
|
|
249276
|
+
return security.some((requirement) => requirement[PERSONAL_ACCESS_TOKEN_SCHEME]?.includes(READ_ONLY_SCOPE));
|
|
249277
|
+
}
|
|
249278
|
+
function parameterText(operation) {
|
|
249279
|
+
return (operation.parameters ?? []).flatMap((parameter) => {
|
|
249280
|
+
const parsed = ParameterSchema.safeParse(parameter);
|
|
249281
|
+
return parsed.success ? [parsed.data.name, cleanText(parsed.data.description ?? "")] : [];
|
|
249282
|
+
}).join(" ");
|
|
249283
|
+
}
|
|
249284
|
+
var COMPONENT_REF = /^#\/components\/([^/]+)\/([^/]+)$/;
|
|
249285
|
+
function resolveComponentRef(spec, value) {
|
|
249286
|
+
const ref = value !== null && typeof value === "object" ? value.$ref : undefined;
|
|
249287
|
+
const match = typeof ref === "string" ? COMPONENT_REF.exec(ref) : null;
|
|
249288
|
+
if (!match?.[1] || !match[2]) {
|
|
249289
|
+
return value;
|
|
249290
|
+
}
|
|
249291
|
+
const components = spec.components;
|
|
249292
|
+
return components?.[match[1]]?.[match[2]] ?? value;
|
|
249293
|
+
}
|
|
249294
|
+
function mergeParameters(shared, own) {
|
|
249295
|
+
if (!shared?.length) {
|
|
249296
|
+
return own;
|
|
249297
|
+
}
|
|
249298
|
+
const key = (parameter) => {
|
|
249299
|
+
const parsed = ParameterSchema.safeParse(parameter);
|
|
249300
|
+
return parsed.success ? `${parsed.data.in}:${parsed.data.name}` : undefined;
|
|
249301
|
+
};
|
|
249302
|
+
const ownKeys = new Set((own ?? []).map(key));
|
|
249303
|
+
return [
|
|
249304
|
+
...shared.filter((parameter) => !ownKeys.has(key(parameter))),
|
|
249305
|
+
...own ?? []
|
|
249306
|
+
];
|
|
249307
|
+
}
|
|
249308
|
+
function listOperations(spec) {
|
|
249309
|
+
return Object.entries(spec.paths).flatMap(([path, item]) => HTTP_METHODS.flatMap((method) => {
|
|
249310
|
+
const parsed = OperationSchema.safeParse(item[method]);
|
|
249311
|
+
if (!parsed.success) {
|
|
249312
|
+
return [];
|
|
249313
|
+
}
|
|
249314
|
+
const shared = ParameterListSchema.safeParse(item.parameters);
|
|
249315
|
+
const resolve = (list) => list?.map((parameter) => resolveComponentRef(spec, parameter));
|
|
249316
|
+
const operation = {
|
|
249317
|
+
...parsed.data,
|
|
249318
|
+
parameters: mergeParameters(resolve(shared.success ? shared.data : undefined), resolve(parsed.data.parameters))
|
|
249319
|
+
};
|
|
249320
|
+
return [
|
|
249321
|
+
{
|
|
249322
|
+
endpoint: `${method.toUpperCase()} ${path}`,
|
|
249323
|
+
method: method.toUpperCase(),
|
|
249324
|
+
path,
|
|
249325
|
+
summary: operation.summary ?? "",
|
|
249326
|
+
description: cleanText(operation.description ?? ""),
|
|
249327
|
+
parameterText: parameterText(operation),
|
|
249328
|
+
readOnly: isReadOnly(operation, spec),
|
|
249329
|
+
operation
|
|
249330
|
+
}
|
|
249331
|
+
];
|
|
249332
|
+
}));
|
|
249333
|
+
}
|
|
249334
|
+
function pathSegments(path) {
|
|
249335
|
+
const pathname = path.split(/[?#]/, 1)[0] ?? "";
|
|
249336
|
+
return pathname.replace(/^\/+|\/+$/g, "").split("/");
|
|
249337
|
+
}
|
|
249338
|
+
function segmentPattern(segment) {
|
|
249339
|
+
const source = segment.split(/(\{[^}]+\})/).map((part) => part.startsWith("{") ? "[^/]+" : part.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")).join("");
|
|
249340
|
+
return new RegExp(`^${source}$`);
|
|
249341
|
+
}
|
|
249342
|
+
function literalSegments(path) {
|
|
249343
|
+
return pathSegments(path).map((segment) => segment.includes("{") ? "0" : "1").join("");
|
|
249344
|
+
}
|
|
249345
|
+
function matchOperation(operations, method, concretePath) {
|
|
249346
|
+
const upperMethod = method.toUpperCase();
|
|
249347
|
+
const segments = pathSegments(concretePath);
|
|
249348
|
+
const candidates = operations.filter((op) => {
|
|
249349
|
+
if (op.method !== upperMethod) {
|
|
249350
|
+
return false;
|
|
249351
|
+
}
|
|
249352
|
+
const template = pathSegments(op.path);
|
|
249353
|
+
return template.length === segments.length && template.every((part, i) => segmentPattern(part).test(segments[i] ?? ""));
|
|
249354
|
+
});
|
|
249355
|
+
return candidates.sort((a, b) => literalSegments(b.path).localeCompare(literalSegments(a.path)))[0];
|
|
249356
|
+
}
|
|
249357
|
+
|
|
249358
|
+
// src/core/api-spec/contract.ts
|
|
249359
|
+
var SCHEMA_REF_PREFIX = "#/components/schemas/";
|
|
249360
|
+
var MAX_REF_DEPTH = 4;
|
|
249361
|
+
function inlineRefs(node, schemas, seen = new Set, depth = 0) {
|
|
249362
|
+
if (depth > MAX_REF_DEPTH) {
|
|
249363
|
+
return node;
|
|
249364
|
+
}
|
|
249365
|
+
if (Array.isArray(node)) {
|
|
249366
|
+
return node.map((item) => inlineRefs(item, schemas, seen, depth));
|
|
249367
|
+
}
|
|
249368
|
+
if (node === null || typeof node !== "object") {
|
|
249369
|
+
return node;
|
|
249370
|
+
}
|
|
249371
|
+
const { $ref, ...siblings } = node;
|
|
249372
|
+
if (typeof $ref === "string" && $ref.startsWith(SCHEMA_REF_PREFIX)) {
|
|
249373
|
+
const name = $ref.slice(SCHEMA_REF_PREFIX.length);
|
|
249374
|
+
if (seen.has(name) || !(name in schemas)) {
|
|
249375
|
+
return node;
|
|
249376
|
+
}
|
|
249377
|
+
const resolved = inlineRefs(schemas[name], schemas, new Set([...seen, name]), depth + 1);
|
|
249378
|
+
return resolved !== null && typeof resolved === "object" ? { ...resolved, ...siblings } : resolved;
|
|
249379
|
+
}
|
|
249380
|
+
return Object.fromEntries(Object.entries(node).map(([key, value]) => [
|
|
249381
|
+
key,
|
|
249382
|
+
inlineRefs(value, schemas, seen, depth)
|
|
249383
|
+
]));
|
|
249384
|
+
}
|
|
249385
|
+
function bodyOf(value) {
|
|
249386
|
+
const parsed = MediaContentSchema.safeParse(value);
|
|
249387
|
+
const content = parsed.success ? parsed.data.content ?? {} : {};
|
|
249388
|
+
const contentType = "application/json" in content ? "application/json" : Object.keys(content)[0];
|
|
249389
|
+
return contentType ? { contentType, schema: content[contentType]?.schema } : {};
|
|
249390
|
+
}
|
|
249391
|
+
function leftoverRefs(node, schemas, found = new Map) {
|
|
249392
|
+
if (Array.isArray(node)) {
|
|
249393
|
+
for (const item of node) {
|
|
249394
|
+
leftoverRefs(item, schemas, found);
|
|
249395
|
+
}
|
|
249396
|
+
} else if (node !== null && typeof node === "object") {
|
|
249397
|
+
for (const [key, value] of Object.entries(node)) {
|
|
249398
|
+
if (key === "$ref" && typeof value === "string" && value.startsWith(SCHEMA_REF_PREFIX) && !found.has(value)) {
|
|
249399
|
+
const schema = schemas[value.slice(SCHEMA_REF_PREFIX.length)];
|
|
249400
|
+
if (schema !== undefined) {
|
|
249401
|
+
found.set(value, schema);
|
|
249402
|
+
leftoverRefs(schema, schemas, found);
|
|
249403
|
+
}
|
|
249404
|
+
} else {
|
|
249405
|
+
leftoverRefs(value, schemas, found);
|
|
249406
|
+
}
|
|
249407
|
+
}
|
|
249408
|
+
}
|
|
249409
|
+
return found;
|
|
249410
|
+
}
|
|
249411
|
+
var SCHEMA_DATA_KEYS = new Set([
|
|
249412
|
+
"example",
|
|
249413
|
+
"examples",
|
|
249414
|
+
"default",
|
|
249415
|
+
"enum",
|
|
249416
|
+
"const"
|
|
249417
|
+
]);
|
|
249418
|
+
function slimSchema(node, isPropertyMap = false) {
|
|
249419
|
+
if (Array.isArray(node)) {
|
|
249420
|
+
return node.map((item) => slimSchema(item));
|
|
249421
|
+
}
|
|
249422
|
+
if (node === null || typeof node !== "object") {
|
|
249423
|
+
return node;
|
|
249424
|
+
}
|
|
249425
|
+
const entries = Object.entries(node);
|
|
249426
|
+
if (isPropertyMap) {
|
|
249427
|
+
return Object.fromEntries(entries.map(([name, value]) => [name, slimSchema(value)]));
|
|
249428
|
+
}
|
|
249429
|
+
const slim = {};
|
|
249430
|
+
for (const [key, value] of entries) {
|
|
249431
|
+
if (key === "title" && typeof value === "string") {
|
|
249432
|
+
continue;
|
|
249433
|
+
}
|
|
249434
|
+
slim[key] = SCHEMA_DATA_KEYS.has(key) ? value : key === "properties" ? slimSchema(value, true) : key === "description" && typeof value === "string" ? cleanText(value) : slimSchema(value);
|
|
249435
|
+
}
|
|
249436
|
+
const { anyOf, ...rest } = slim;
|
|
249437
|
+
const nullable = Array.isArray(anyOf) && anyOf.length === 2 ? nullableType(anyOf) : undefined;
|
|
249438
|
+
return nullable ? { type: [nullable, "null"], ...rest } : slim;
|
|
249439
|
+
}
|
|
249440
|
+
function nullableType(variants) {
|
|
249441
|
+
const types = variants.map((variant) => variant !== null && typeof variant === "object" && Object.keys(variant).length === 1 && typeof variant.type === "string" ? variant.type : undefined);
|
|
249442
|
+
if (types.includes(undefined) || !types.includes("null")) {
|
|
249443
|
+
return;
|
|
249444
|
+
}
|
|
249445
|
+
return types.find((type) => type !== "null");
|
|
249446
|
+
}
|
|
249447
|
+
function getOperationContract(spec, op) {
|
|
249448
|
+
const schemas = spec.components?.schemas ?? {};
|
|
249449
|
+
const inline = (node) => node === undefined ? null : slimSchema(inlineRefs(node, schemas));
|
|
249450
|
+
const responses = Object.entries(op.operation.responses ?? {}).flatMap(([status, response]) => {
|
|
249451
|
+
const parsed = ResponseObjectSchema.safeParse(resolveComponentRef(spec, response));
|
|
249452
|
+
return parsed.success ? [[status, parsed.data]] : [];
|
|
249453
|
+
});
|
|
249454
|
+
const success = responses.filter(([status]) => status.startsWith("2")).sort(([a], [b]) => a.localeCompare(b)).map(([, response]) => bodyOf(response).schema).find(Boolean);
|
|
249455
|
+
const requestBody = bodyOf(resolveComponentRef(spec, op.operation.requestBody));
|
|
249456
|
+
const contract = {
|
|
249457
|
+
endpoint: op.endpoint,
|
|
249458
|
+
method: op.method,
|
|
249459
|
+
path: op.path,
|
|
249460
|
+
summary: op.summary,
|
|
249461
|
+
description: op.description,
|
|
249462
|
+
parameters: (op.operation.parameters ?? []).flatMap((parameter) => {
|
|
249463
|
+
const parsed = ParameterSchema.safeParse(parameter);
|
|
249464
|
+
if (!parsed.success) {
|
|
249465
|
+
return [parameter];
|
|
249466
|
+
}
|
|
249467
|
+
const { name, in: location2, required, schema, description } = parsed.data;
|
|
249468
|
+
const inSchema = schema !== null && typeof schema === "object" && "description" in schema;
|
|
249469
|
+
return [
|
|
249470
|
+
{
|
|
249471
|
+
name,
|
|
249472
|
+
in: location2,
|
|
249473
|
+
required: required ?? false,
|
|
249474
|
+
schema: inline(schema ?? {}),
|
|
249475
|
+
...description && !inSchema ? { description: cleanText(description) } : {},
|
|
249476
|
+
..."example" in parsed.data ? { example: parsed.data.example } : {}
|
|
249477
|
+
}
|
|
249478
|
+
];
|
|
249479
|
+
}),
|
|
249480
|
+
...requestBody.contentType && requestBody.contentType !== "application/json" ? { requestBodyContentType: requestBody.contentType } : {},
|
|
249481
|
+
requestBodySchema: inline(requestBody.schema),
|
|
249482
|
+
responseSchema: inline(success)
|
|
249483
|
+
};
|
|
249484
|
+
const refs = leftoverRefs(contract, schemas);
|
|
249485
|
+
return {
|
|
249486
|
+
...contract,
|
|
249487
|
+
...refs.size > 0 ? {
|
|
249488
|
+
refs: Object.fromEntries([...refs].map(([ref, schema]) => [ref, slimSchema(schema)]))
|
|
249489
|
+
} : {}
|
|
249490
|
+
};
|
|
249491
|
+
}
|
|
249492
|
+
// src/core/api-spec/grep.ts
|
|
249493
|
+
function grepOperations(spec, operations, pattern, options = {}) {
|
|
249494
|
+
const regex = new RegExp(pattern, options.ignoreCase ? "i" : "");
|
|
249495
|
+
return operations.filter((op) => regex.test(JSON.stringify(getOperationContract(spec, op)))).slice(0, options.limit ?? 20).map(toOperationSummary);
|
|
249496
|
+
}
|
|
249497
|
+
// src/core/api-spec/request.ts
|
|
249498
|
+
var MAX_ERROR_BODY_CHARS = 4000;
|
|
249499
|
+
var QUERY_STRING = /\?\S*/g;
|
|
249500
|
+
async function readBody(response) {
|
|
249501
|
+
try {
|
|
249502
|
+
const text = (await response.clone().text()).trim();
|
|
249503
|
+
return text.length > MAX_ERROR_BODY_CHARS ? `${text.slice(0, MAX_ERROR_BODY_CHARS)}…` : text || undefined;
|
|
249504
|
+
} catch {
|
|
249505
|
+
return;
|
|
249506
|
+
}
|
|
249507
|
+
}
|
|
249508
|
+
function normalizePath(path) {
|
|
249509
|
+
const url = new URL(path.replace(/^\/*/, "/"), "http://placeholder");
|
|
249510
|
+
return `${url.pathname}${url.search}`;
|
|
249511
|
+
}
|
|
249512
|
+
async function sendApiRequest(method, path, body) {
|
|
249513
|
+
try {
|
|
249514
|
+
const response = await base44Client(path.replace(/^\/+/, ""), {
|
|
249515
|
+
method,
|
|
249516
|
+
body,
|
|
249517
|
+
headers: typeof body === "string" ? { "Content-Type": "application/json" } : {},
|
|
249518
|
+
timeout: false,
|
|
249519
|
+
retry: { methods: ["get", "head"] }
|
|
249520
|
+
});
|
|
249521
|
+
return {
|
|
249522
|
+
status: response.status,
|
|
249523
|
+
contentType: response.headers.get("content-type") ?? "",
|
|
249524
|
+
body: new Uint8Array(await response.arrayBuffer())
|
|
249525
|
+
};
|
|
249526
|
+
} catch (error) {
|
|
249527
|
+
const apiError = await ApiError.fromHttpError(error, `calling ${method} ${path}`);
|
|
249528
|
+
const response = error instanceof HTTPError ? error.response : undefined;
|
|
249529
|
+
const raw = response ? await readBody(response) : undefined;
|
|
249530
|
+
const retryAfter = response?.headers.get("retry-after") ?? undefined;
|
|
249531
|
+
throw redactedApiError(apiError, raw, method, path, retryAfter);
|
|
249532
|
+
}
|
|
249533
|
+
}
|
|
249534
|
+
function redactedApiError(apiError, raw, method, path, retryAfter) {
|
|
249535
|
+
const wait = retryAfter ? ` (retry after ${/^\d+$/.test(retryAfter) ? `${retryAfter} s` : retryAfter})` : "";
|
|
249536
|
+
const reason = apiError.statusCode !== undefined ? `HTTP ${apiError.statusCode}${wait}` : (apiError.cause?.message ?? "request failed").replace(QUERY_STRING, "");
|
|
249537
|
+
const message = `Error calling ${method} ${path.split("?", 1)[0]}: ${reason}`;
|
|
249538
|
+
return new ApiError(message, {
|
|
249539
|
+
statusCode: apiError.statusCode,
|
|
249540
|
+
requestUrl: apiError.requestUrl?.split("?", 1)[0],
|
|
249541
|
+
requestMethod: apiError.requestMethod,
|
|
249542
|
+
requestId: apiError.requestId,
|
|
249543
|
+
hints: apiError.hints,
|
|
249544
|
+
details: raw ? [`Response body: ${raw}`] : apiError.details
|
|
249545
|
+
});
|
|
249546
|
+
}
|
|
249547
|
+
// src/core/api-spec/spec.ts
|
|
249548
|
+
import { rename, rm, stat as stat3 } from "node:fs/promises";
|
|
249549
|
+
import { join as join22 } from "node:path";
|
|
249550
|
+
var SPEC_CACHE_TTL_MS = 60 * 60 * 1000;
|
|
249551
|
+
function getSpecCachePath(apiUrl = getBase44ApiUrl()) {
|
|
249552
|
+
const server = new URL(apiUrl).host.replace(/[^a-zA-Z0-9.-]/g, "_");
|
|
249553
|
+
return join22(getBase44GlobalDir(), "cache", server, "openapi.json");
|
|
249554
|
+
}
|
|
249555
|
+
function isSpecCacheFresh(mtimeMs, now = Date.now()) {
|
|
249556
|
+
return now - mtimeMs < SPEC_CACHE_TTL_MS;
|
|
249557
|
+
}
|
|
249558
|
+
function parseSpec(text) {
|
|
249559
|
+
let json;
|
|
249560
|
+
try {
|
|
249561
|
+
json = JSON.parse(text);
|
|
249562
|
+
} catch {
|
|
249563
|
+
throw new ApiError("The API spec from the server is not valid JSON");
|
|
249564
|
+
}
|
|
249565
|
+
const result = OpenApiSpecSchema.safeParse(json);
|
|
249566
|
+
if (!result.success) {
|
|
249567
|
+
throw new SchemaValidationError("Invalid API spec", result.error);
|
|
249568
|
+
}
|
|
249569
|
+
return result.data;
|
|
249570
|
+
}
|
|
249571
|
+
var SPEC_DOWNLOAD_TIMEOUT_MS = 60000;
|
|
249572
|
+
async function readFreshCache(path) {
|
|
249573
|
+
try {
|
|
249574
|
+
const { mtimeMs } = await stat3(path);
|
|
249575
|
+
if (!isSpecCacheFresh(mtimeMs)) {
|
|
249576
|
+
return null;
|
|
249577
|
+
}
|
|
249578
|
+
const text = await readTextFile(path);
|
|
249579
|
+
return { text, spec: parseSpec(text) };
|
|
249580
|
+
} catch {
|
|
249581
|
+
return null;
|
|
249582
|
+
}
|
|
249583
|
+
}
|
|
249584
|
+
async function downloadSpec() {
|
|
249585
|
+
try {
|
|
249586
|
+
const response = await base44Client.get("api/openapi.json", {
|
|
249587
|
+
timeout: SPEC_DOWNLOAD_TIMEOUT_MS
|
|
249588
|
+
});
|
|
249589
|
+
return await response.text();
|
|
249590
|
+
} catch (error) {
|
|
249591
|
+
throw await ApiError.fromHttpError(error, "fetching the API spec");
|
|
249592
|
+
}
|
|
249593
|
+
}
|
|
249594
|
+
async function loadSpec(options = {}) {
|
|
249595
|
+
const path = getSpecCachePath();
|
|
249596
|
+
const cached = options.refresh ? null : await readFreshCache(path);
|
|
249597
|
+
if (cached !== null) {
|
|
249598
|
+
return cached;
|
|
249599
|
+
}
|
|
249600
|
+
const text = await downloadSpec();
|
|
249601
|
+
const spec = parseSpec(text);
|
|
249602
|
+
const partial = `${path}.${process.pid}.tmp`;
|
|
249603
|
+
try {
|
|
249604
|
+
await writeFile(partial, text);
|
|
249605
|
+
await rename(partial, path);
|
|
249606
|
+
} catch {
|
|
249607
|
+
await rm(partial, { force: true }).catch(() => {
|
|
249608
|
+
return;
|
|
249609
|
+
});
|
|
249610
|
+
}
|
|
249611
|
+
return { text, spec };
|
|
249612
|
+
}
|
|
249613
|
+
// src/cli/commands/api/shared.ts
|
|
249614
|
+
import { fstatSync } from "node:fs";
|
|
249615
|
+
import { basename as basename6 } from "node:path";
|
|
249616
|
+
function formatJson(value) {
|
|
249617
|
+
return toJsonStdout(value, { compact: !process.stdout.isTTY });
|
|
249618
|
+
}
|
|
249619
|
+
function parseLimit(value) {
|
|
249620
|
+
if (value === undefined) {
|
|
249621
|
+
return;
|
|
249622
|
+
}
|
|
249623
|
+
const n = Number.parseInt(value, 10);
|
|
249624
|
+
if (!Number.isInteger(n) || n < 1) {
|
|
249625
|
+
throw new InvalidInputError("--limit must be a positive integer.");
|
|
249626
|
+
}
|
|
249627
|
+
return n;
|
|
249628
|
+
}
|
|
249629
|
+
var READ_ONLY_FILTER_HELP = "Only read-only operations";
|
|
249630
|
+
var REFRESH_OPTION_HELP = "Fetch the API spec again instead of using the cached copy (kept 1 hour)";
|
|
249631
|
+
function loadSpecTask({ runTask }, refresh) {
|
|
249632
|
+
return runTask("Loading the API spec", () => loadSpec({ refresh }), {
|
|
249633
|
+
successMessage: "Loaded the API spec"
|
|
249634
|
+
});
|
|
249635
|
+
}
|
|
249636
|
+
function operationsInArea(operations, area) {
|
|
249637
|
+
const areas = groupByArea(operations);
|
|
249638
|
+
const inArea = areas.get(area);
|
|
249639
|
+
if (!inArea) {
|
|
249640
|
+
throw new InvalidInputError(`Unknown API area: ${area}`, {
|
|
249641
|
+
details: [`Areas: ${[...areas.keys()].join(", ")}`],
|
|
249642
|
+
hints: [{ message: "List the areas", command: "base44 api catalog" }]
|
|
249643
|
+
});
|
|
249644
|
+
}
|
|
249645
|
+
return inArea;
|
|
249646
|
+
}
|
|
249647
|
+
function isPipedStdin() {
|
|
249648
|
+
try {
|
|
249649
|
+
const stats = fstatSync(0);
|
|
249650
|
+
return stats.isFIFO() || stats.isFile();
|
|
249651
|
+
} catch {
|
|
249652
|
+
return false;
|
|
249653
|
+
}
|
|
249654
|
+
}
|
|
249655
|
+
async function readRequestBody(flag, log) {
|
|
249656
|
+
if (flag === "@-") {
|
|
249657
|
+
return readStdin("--body @-", { trim: false });
|
|
249658
|
+
}
|
|
249659
|
+
if (flag?.startsWith("@")) {
|
|
249660
|
+
return readTextFile(flag.slice(1));
|
|
249661
|
+
}
|
|
249662
|
+
if (flag === undefined && isPipedStdin()) {
|
|
249663
|
+
log.warn("stdin is ignored; pass --body @- to send it as the body.");
|
|
249664
|
+
}
|
|
249665
|
+
return flag;
|
|
249666
|
+
}
|
|
249667
|
+
var FORM_FILE = /^@(.+?)(?:;type=([^;]+))?$/;
|
|
249668
|
+
async function readFormBody(fields) {
|
|
249669
|
+
const form = new FormData;
|
|
249670
|
+
for (const field of fields) {
|
|
249671
|
+
const separator = field.indexOf("=");
|
|
249672
|
+
if (separator < 1) {
|
|
249673
|
+
throw new InvalidInputError(`--form takes name=value or name=@file, got "${field}".`);
|
|
249674
|
+
}
|
|
249675
|
+
const name = field.slice(0, separator);
|
|
249676
|
+
const value = field.slice(separator + 1);
|
|
249677
|
+
const file = FORM_FILE.exec(value);
|
|
249678
|
+
if (file?.[1]) {
|
|
249679
|
+
const type = file[2] ?? "application/octet-stream";
|
|
249680
|
+
const blob = new Blob([await readFile(file[1])], { type });
|
|
249681
|
+
form.append(name, blob, basename6(file[1]));
|
|
249682
|
+
} else {
|
|
249683
|
+
form.append(name, value);
|
|
249684
|
+
}
|
|
249685
|
+
}
|
|
249686
|
+
return form;
|
|
249687
|
+
}
|
|
249688
|
+
function withoutQuery(path) {
|
|
249689
|
+
return path.split("?", 1)[0] ?? "";
|
|
249690
|
+
}
|
|
249691
|
+
function reportedFetchCommand(method, path, options) {
|
|
249692
|
+
return {
|
|
249693
|
+
name: "api fetch",
|
|
249694
|
+
args: [method, withoutQuery(path)],
|
|
249695
|
+
options: {
|
|
249696
|
+
...options,
|
|
249697
|
+
...options.body === undefined ? {} : { body: "[not reported]" },
|
|
249698
|
+
...Array.isArray(options.form) && options.form.length > 0 ? { form: "[not reported]" } : {}
|
|
249699
|
+
}
|
|
249700
|
+
};
|
|
249701
|
+
}
|
|
249702
|
+
|
|
249703
|
+
// src/cli/commands/api/catalog.ts
|
|
249704
|
+
async function catalogAction(ctx, area, options) {
|
|
249705
|
+
const { spec } = await loadSpecTask(ctx, options.refresh);
|
|
249706
|
+
const operations = listOperations(spec);
|
|
249707
|
+
const readOnly = (ops) => options.readOnly ? ops.filter((op) => op.readOnly) : ops;
|
|
249708
|
+
if (area === undefined) {
|
|
249709
|
+
return { stdout: formatJson(catalogIndex(readOnly(operations))) };
|
|
249710
|
+
}
|
|
249711
|
+
const inArea = readOnly(operationsInArea(operations, area));
|
|
249712
|
+
return { stdout: formatJson(areaListing(area, inArea)) };
|
|
249713
|
+
}
|
|
249714
|
+
function getApiCatalogCommand() {
|
|
249715
|
+
return new Base44Command("catalog", {
|
|
249716
|
+
requireAuth: false,
|
|
249717
|
+
requireAppContext: false
|
|
249718
|
+
}).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);
|
|
249719
|
+
}
|
|
249720
|
+
|
|
249721
|
+
// src/cli/commands/api/fetch.ts
|
|
249722
|
+
async function findOperation(ctx, method, path, { refresh, flag }) {
|
|
249723
|
+
const { spec } = await loadSpecTask(ctx, refresh);
|
|
249724
|
+
const op = matchOperation(listOperations(spec), method, path);
|
|
249725
|
+
if (!op) {
|
|
249726
|
+
throw new InvalidInputError(`No operation in the API spec matches ${method} ${withoutQuery(path)}.`, {
|
|
249727
|
+
hints: [
|
|
249728
|
+
{
|
|
249729
|
+
message: "The cached spec may predate this route; fetch it again",
|
|
249730
|
+
command: `base44 api fetch ${method} ${path} ${flag} --refresh`
|
|
249731
|
+
},
|
|
249732
|
+
{
|
|
249733
|
+
message: "Find the operation and its path template",
|
|
249734
|
+
command: 'base44 api search "<what you want to do>"'
|
|
249735
|
+
}
|
|
249736
|
+
]
|
|
249737
|
+
});
|
|
249738
|
+
}
|
|
249739
|
+
return { spec, op };
|
|
249740
|
+
}
|
|
249741
|
+
var MULTIPART_HINT = "Send this body with --form name=value, and --form name=@path for files.";
|
|
249742
|
+
var CONTRACT_HELP = `
|
|
249743
|
+
The contract is JSON; cut it down with e.g. | jq '.parameters, .requestBodySchema'`;
|
|
249744
|
+
var TEXT_CONTENT_TYPES = [
|
|
249745
|
+
"json",
|
|
249746
|
+
"text/",
|
|
249747
|
+
"xml",
|
|
249748
|
+
"javascript",
|
|
249749
|
+
"x-www-form-urlencoded"
|
|
249750
|
+
];
|
|
249751
|
+
function decodeText(body, contentType) {
|
|
249752
|
+
const type = contentType.toLowerCase();
|
|
249753
|
+
if (type && !TEXT_CONTENT_TYPES.some((hint) => type.includes(hint))) {
|
|
249754
|
+
return;
|
|
249755
|
+
}
|
|
249756
|
+
try {
|
|
249757
|
+
return new TextDecoder("utf-8", { fatal: true }).decode(body);
|
|
249758
|
+
} catch {
|
|
249759
|
+
return;
|
|
249760
|
+
}
|
|
249761
|
+
}
|
|
249762
|
+
async function formatResponse({ status, contentType, body }, output, jsonMode) {
|
|
249763
|
+
if (output !== undefined) {
|
|
249764
|
+
await writeFile(output, body);
|
|
249765
|
+
return formatJson({ status, contentType, bytes: body.length, output });
|
|
249766
|
+
}
|
|
249767
|
+
if (body.length === 0) {
|
|
249768
|
+
return formatJson({ status });
|
|
249769
|
+
}
|
|
249770
|
+
const text = decodeText(body, contentType);
|
|
249771
|
+
if (text === undefined) {
|
|
249772
|
+
return formatJson({
|
|
249773
|
+
status,
|
|
249774
|
+
contentType,
|
|
249775
|
+
bytes: body.length,
|
|
249776
|
+
note: "Binary body not printed; add --output <file> to save it."
|
|
249777
|
+
});
|
|
249778
|
+
}
|
|
249779
|
+
const asIs = text.endsWith(`
|
|
249780
|
+
`) ? text : `${text}
|
|
249781
|
+
`;
|
|
249782
|
+
try {
|
|
249783
|
+
const parsed = JSON.parse(text);
|
|
249784
|
+
return process.stdout.isTTY ? formatJson(parsed) : asIs;
|
|
249785
|
+
} catch {
|
|
249786
|
+
return jsonMode ? formatJson({ status, contentType, body: text }) : asIs;
|
|
249787
|
+
}
|
|
249788
|
+
}
|
|
249789
|
+
async function fetchAction(ctx, methodArg, path, options, command) {
|
|
249790
|
+
ctx.errorReporter.setContext({
|
|
249791
|
+
command: reportedFetchCommand(methodArg ?? "", path ?? "", { ...options })
|
|
249792
|
+
});
|
|
249793
|
+
if (!methodArg || !path) {
|
|
249794
|
+
if (options.help) {
|
|
249795
|
+
const usage = `${command.helpInformation()}${CONTRACT_HELP}
|
|
249796
|
+
`;
|
|
249797
|
+
return { stdout: ctx.jsonMode ? formatJson({ usage }) : usage };
|
|
249798
|
+
}
|
|
249799
|
+
throw new InvalidInputError("Provide a method and a path, e.g. GET /api/apps.");
|
|
249800
|
+
}
|
|
249801
|
+
const method = methodArg.toUpperCase();
|
|
249802
|
+
const target = normalizePath(path);
|
|
249803
|
+
if (options.help) {
|
|
249804
|
+
const { spec, op } = await findOperation(ctx, method, target, {
|
|
249805
|
+
refresh: options.refresh,
|
|
249806
|
+
flag: "--help"
|
|
249807
|
+
});
|
|
249808
|
+
const contract = getOperationContract(spec, op);
|
|
249809
|
+
return {
|
|
249810
|
+
stdout: formatJson(contract.requestBodyContentType === "multipart/form-data" ? { ...contract, hint: MULTIPART_HINT } : contract)
|
|
249811
|
+
};
|
|
249812
|
+
}
|
|
249813
|
+
if (options.readOnly) {
|
|
249814
|
+
const { op } = await findOperation(ctx, method, target, {
|
|
249815
|
+
refresh: options.refresh,
|
|
249816
|
+
flag: "--read-only"
|
|
249817
|
+
});
|
|
249818
|
+
if (!op.readOnly) {
|
|
249819
|
+
throw new InvalidInputError(`Refused under --read-only: ${op.method} ${op.path} is not a read-only operation. Nothing was sent.`);
|
|
249820
|
+
}
|
|
249821
|
+
}
|
|
249822
|
+
if (options.body !== undefined && options.form.length > 0) {
|
|
249823
|
+
throw new InvalidInputError("Use --body or --form, not both.");
|
|
249824
|
+
}
|
|
249825
|
+
await ensureAuth(ctx);
|
|
249826
|
+
const body = options.form.length > 0 ? await readFormBody(options.form) : await readRequestBody(options.body, ctx.log);
|
|
249827
|
+
const response = await ctx.runTask(`Calling ${method} ${target}`, () => sendApiRequest(method, target, body), {
|
|
249828
|
+
successMessage: `Called ${method} ${target}`,
|
|
249829
|
+
errorMessage: "Request failed"
|
|
249830
|
+
});
|
|
249831
|
+
return {
|
|
249832
|
+
stdout: await formatResponse(response, options.output, ctx.jsonMode)
|
|
249833
|
+
};
|
|
249834
|
+
}
|
|
249835
|
+
function getApiFetchCommand() {
|
|
249836
|
+
return new Base44Command("fetch", {
|
|
249837
|
+
requireAuth: false,
|
|
249838
|
+
requireAppContext: false
|
|
249839
|
+
}).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]", 'Concrete path with any query string, 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", CONTRACT_HELP).action(fetchAction);
|
|
249840
|
+
}
|
|
249841
|
+
|
|
249842
|
+
// src/cli/commands/api/grep.ts
|
|
249843
|
+
function assertValidRegex(pattern) {
|
|
249844
|
+
try {
|
|
249845
|
+
new RegExp(pattern);
|
|
249846
|
+
} catch (error) {
|
|
249847
|
+
throw new InvalidInputError(`Invalid regular expression: ${error instanceof Error ? error.message : pattern}`);
|
|
249848
|
+
}
|
|
249849
|
+
}
|
|
249850
|
+
async function grepAction(ctx, pattern, options) {
|
|
249851
|
+
const limit = parseLimit(options.limit);
|
|
249852
|
+
assertValidRegex(pattern);
|
|
249853
|
+
const { spec } = await loadSpecTask(ctx, options.refresh);
|
|
249854
|
+
let operations = listOperations(spec);
|
|
249855
|
+
if (options.area !== undefined) {
|
|
249856
|
+
operations = operationsInArea(operations, options.area);
|
|
249857
|
+
}
|
|
249858
|
+
if (options.readOnly) {
|
|
249859
|
+
operations = operations.filter((op) => op.readOnly);
|
|
249860
|
+
}
|
|
249861
|
+
const hits = grepOperations(spec, operations, pattern, {
|
|
249862
|
+
ignoreCase: options.ignoreCase,
|
|
249863
|
+
limit
|
|
249864
|
+
});
|
|
249865
|
+
return { stdout: formatJson(hits) };
|
|
249866
|
+
}
|
|
249867
|
+
function getApiGrepCommand() {
|
|
249868
|
+
return new Base44Command("grep", {
|
|
249869
|
+
requireAuth: false,
|
|
249870
|
+
requireAppContext: false
|
|
249871
|
+
}).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);
|
|
249872
|
+
}
|
|
249873
|
+
|
|
249874
|
+
// src/cli/commands/api/search.ts
|
|
249875
|
+
async function searchAction(ctx, words, options) {
|
|
249876
|
+
const limit = parseLimit(options.limit);
|
|
249877
|
+
const { spec } = await loadSpecTask(ctx, options.refresh);
|
|
249878
|
+
const results = searchOperations(listOperations(spec), words.join(" "), {
|
|
249879
|
+
limit,
|
|
249880
|
+
readOnly: options.readOnly
|
|
249881
|
+
});
|
|
249882
|
+
return { stdout: formatJson(results) };
|
|
249883
|
+
}
|
|
249884
|
+
function getApiSearchCommand() {
|
|
249885
|
+
return new Base44Command("search", {
|
|
249886
|
+
requireAuth: false,
|
|
249887
|
+
requireAppContext: false
|
|
249888
|
+
}).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);
|
|
249889
|
+
}
|
|
249890
|
+
|
|
249891
|
+
// src/cli/commands/api/index.ts
|
|
249892
|
+
function getApiCommand() {
|
|
249893
|
+
return new Command2("api").description("Search and call any public Base44 API operation").addCommand(getApiCatalogCommand()).addCommand(getApiSearchCommand()).addCommand(getApiGrepCommand()).addCommand(getApiFetchCommand());
|
|
249894
|
+
}
|
|
249895
|
+
|
|
248044
249896
|
// src/cli/commands/auth/password-login.ts
|
|
248045
|
-
import { dirname as dirname16, join as
|
|
249897
|
+
import { dirname as dirname16, join as join23 } from "node:path";
|
|
248046
249898
|
async function passwordLoginAction({ log, runTask }, action) {
|
|
248047
249899
|
const shouldEnable = action === "enable";
|
|
248048
249900
|
const { project } = await readProjectConfig();
|
|
248049
249901
|
const configDir = dirname16(project.configPath);
|
|
248050
|
-
const authDir =
|
|
249902
|
+
const authDir = join23(configDir, project.authDir);
|
|
248051
249903
|
const updated = await runTask("Updating local auth config", async () => {
|
|
248052
249904
|
const current = await readAuthConfig(authDir) ?? DEFAULT_AUTH_CONFIG;
|
|
248053
249905
|
const merged = { ...current, enableUsernamePassword: shouldEnable };
|
|
@@ -248067,14 +249919,14 @@ function getPasswordLoginCommand() {
|
|
|
248067
249919
|
}
|
|
248068
249920
|
|
|
248069
249921
|
// src/cli/commands/auth/pull.ts
|
|
248070
|
-
import { dirname as dirname17, join as
|
|
249922
|
+
import { dirname as dirname17, join as join24 } from "node:path";
|
|
248071
249923
|
async function pullAuthAction({
|
|
248072
249924
|
log,
|
|
248073
249925
|
runTask
|
|
248074
249926
|
}) {
|
|
248075
249927
|
const { project } = await readProjectConfig();
|
|
248076
249928
|
const configDir = dirname17(project.configPath);
|
|
248077
|
-
const authDir =
|
|
249929
|
+
const authDir = join24(configDir, project.authDir);
|
|
248078
249930
|
const remoteConfig = await runTask("Fetching auth config from Base44", async () => {
|
|
248079
249931
|
return await pullAuthConfig();
|
|
248080
249932
|
}, {
|
|
@@ -248138,7 +249990,7 @@ function getAuthPushCommand() {
|
|
|
248138
249990
|
}
|
|
248139
249991
|
|
|
248140
249992
|
// src/cli/commands/auth/social-login.ts
|
|
248141
|
-
import { dirname as dirname18, join as
|
|
249993
|
+
import { dirname as dirname18, join as join25, resolve as resolve7 } from "node:path";
|
|
248142
249994
|
var PROVIDER_LABELS = {
|
|
248143
249995
|
google: "Google",
|
|
248144
249996
|
microsoft: "Microsoft",
|
|
@@ -248209,7 +250061,7 @@ async function socialLoginAction({ log, isNonInteractive, runTask }, provider, a
|
|
|
248209
250061
|
}
|
|
248210
250062
|
const { project } = await readProjectConfig();
|
|
248211
250063
|
const configDir = dirname18(project.configPath);
|
|
248212
|
-
const authDir =
|
|
250064
|
+
const authDir = join25(configDir, project.authDir);
|
|
248213
250065
|
const { config: updated } = await runTask("Updating local auth config", async () => updateSocialLoginConfig(authDir, provider, shouldEnable, useCustomOAuth && options.clientId ? { clientId: options.clientId } : undefined));
|
|
248214
250066
|
if (clientSecret) {
|
|
248215
250067
|
await runTask("Saving client secret", async () => pushCustomOAuthSecret(provider, clientSecret));
|
|
@@ -248234,7 +250086,7 @@ function getSocialLoginCommand() {
|
|
|
248234
250086
|
}
|
|
248235
250087
|
|
|
248236
250088
|
// src/cli/commands/auth/sso.ts
|
|
248237
|
-
import { dirname as dirname19, join as
|
|
250089
|
+
import { dirname as dirname19, join as join26, resolve as resolve8 } from "node:path";
|
|
248238
250090
|
var SSOConfigFileSchema = object({
|
|
248239
250091
|
provider: _enum(Object.values(KNOWN_SSO_PROVIDERS)),
|
|
248240
250092
|
clientId: string2(),
|
|
@@ -248398,7 +250250,7 @@ async function ssoEnableAction({ isNonInteractive, runTask }, options) {
|
|
|
248398
250250
|
}
|
|
248399
250251
|
const { project } = await readProjectConfig();
|
|
248400
250252
|
const configDir = dirname19(project.configPath);
|
|
248401
|
-
const authDir =
|
|
250253
|
+
const authDir = join26(configDir, project.authDir);
|
|
248402
250254
|
await runTask("Updating local auth config", async () => updateSSOConfig(authDir, provider, true));
|
|
248403
250255
|
await runTask("Saving SSO credentials", async () => pushSSOSecrets(secrets));
|
|
248404
250256
|
return {
|
|
@@ -248414,7 +250266,7 @@ async function ssoDisableAction({ log, runTask }, options) {
|
|
|
248414
250266
|
}
|
|
248415
250267
|
const { project } = await readProjectConfig();
|
|
248416
250268
|
const configDir = dirname19(project.configPath);
|
|
248417
|
-
const authDir =
|
|
250269
|
+
const authDir = join26(configDir, project.authDir);
|
|
248418
250270
|
const updated = await runTask("Updating local auth config", async () => updateSSOConfig(authDir, null, false));
|
|
248419
250271
|
await runTask("Removing SSO credentials", async () => deleteSSOSecrets());
|
|
248420
250272
|
if (!hasAnyLoginMethod(updated)) {
|
|
@@ -249296,13 +251148,13 @@ function getConnectorsListAvailableCommand() {
|
|
|
249296
251148
|
}
|
|
249297
251149
|
|
|
249298
251150
|
// src/cli/commands/connectors/pull.ts
|
|
249299
|
-
import { dirname as dirname20, join as
|
|
251151
|
+
import { dirname as dirname20, join as join27, resolve as resolve9 } from "node:path";
|
|
249300
251152
|
async function resolveConnectorsDir(options) {
|
|
249301
251153
|
if (!getAppContext().projectRoot) {
|
|
249302
251154
|
return resolve9(options.dir ?? "connectors");
|
|
249303
251155
|
}
|
|
249304
251156
|
const { project } = await readProjectConfig();
|
|
249305
|
-
return
|
|
251157
|
+
return join27(dirname20(project.configPath), project.connectorsDir);
|
|
249306
251158
|
}
|
|
249307
251159
|
async function pullConnectorsAction({ log, runTask, jsonMode }, options) {
|
|
249308
251160
|
const connectorsDir = await resolveConnectorsDir(options);
|
|
@@ -249689,11 +251541,11 @@ function getListCommand() {
|
|
|
249689
251541
|
}
|
|
249690
251542
|
|
|
249691
251543
|
// src/cli/commands/functions/pull.ts
|
|
249692
|
-
import { dirname as dirname21, join as
|
|
251544
|
+
import { dirname as dirname21, join as join28 } from "node:path";
|
|
249693
251545
|
async function pullFunctionsAction({ log, runTask }, name) {
|
|
249694
251546
|
const { project, functions } = await readProjectConfig();
|
|
249695
251547
|
const configDir = dirname21(project.configPath);
|
|
249696
|
-
const functionsDir =
|
|
251548
|
+
const functionsDir = join28(configDir, project.functionsDir);
|
|
249697
251549
|
const pluginFunctionNames = new Set(functions.filter((fn) => fn.source.type === "plugin").map((fn) => fn.name));
|
|
249698
251550
|
const remoteFunctions = await runTask("Fetching functions from Base44", async () => {
|
|
249699
251551
|
const { functions } = await listDeployedFunctions();
|
|
@@ -249803,11 +251655,11 @@ function getBuildCommand() {
|
|
|
249803
251655
|
}
|
|
249804
251656
|
|
|
249805
251657
|
// src/cli/commands/project/create.ts
|
|
249806
|
-
import { basename as
|
|
251658
|
+
import { basename as basename7, resolve as resolve11 } from "node:path";
|
|
249807
251659
|
var import_kebabCase = __toESM(require_kebabCase(), 1);
|
|
249808
251660
|
|
|
249809
251661
|
// src/cli/commands/project/scaffold-shared.ts
|
|
249810
|
-
import { join as
|
|
251662
|
+
import { join as join29 } from "node:path";
|
|
249811
251663
|
var DEFAULT_TEMPLATE_ID = "backend-only";
|
|
249812
251664
|
async function getTemplateById(templateId) {
|
|
249813
251665
|
const templates = await listTemplates();
|
|
@@ -249870,7 +251722,7 @@ async function completeProjectSetup({
|
|
|
249870
251722
|
env: { VITE_BASE44_APP_ID: projectId }
|
|
249871
251723
|
})`${buildCommand}`;
|
|
249872
251724
|
updateMessage("Deploying site...");
|
|
249873
|
-
return await deploySite(
|
|
251725
|
+
return await deploySite(join29(resolvedPath, outputDirectory));
|
|
249874
251726
|
}, {
|
|
249875
251727
|
successMessage: theme.colors.base44Orange("Site deployed successfully"),
|
|
249876
251728
|
errorMessage: "Failed to deploy site"
|
|
@@ -249968,8 +251820,8 @@ async function createInteractive(options, ctx) {
|
|
|
249968
251820
|
name: () => {
|
|
249969
251821
|
return options.name ? Promise.resolve(options.name) : Ze({
|
|
249970
251822
|
message: "What is the name of your project?",
|
|
249971
|
-
placeholder:
|
|
249972
|
-
initialValue:
|
|
251823
|
+
placeholder: basename7(process.cwd()),
|
|
251824
|
+
initialValue: basename7(process.cwd()),
|
|
249973
251825
|
validate: (value) => {
|
|
249974
251826
|
if (!value || value.trim().length === 0) {
|
|
249975
251827
|
return "Every project deserves a name";
|
|
@@ -250664,7 +252516,7 @@ function getLogsCommand() {
|
|
|
250664
252516
|
}
|
|
250665
252517
|
|
|
250666
252518
|
// src/cli/commands/project/scaffold.ts
|
|
250667
|
-
import { basename as
|
|
252519
|
+
import { basename as basename8, resolve as resolve12 } from "node:path";
|
|
250668
252520
|
function resolveAppId(options) {
|
|
250669
252521
|
const appId = options.appId;
|
|
250670
252522
|
if (!appId) {
|
|
@@ -250681,7 +252533,7 @@ async function scaffoldAction(ctx, name, options, command) {
|
|
|
250681
252533
|
const { log, runTask } = ctx;
|
|
250682
252534
|
const appId = resolveAppId(command.optsWithGlobals());
|
|
250683
252535
|
const resolvedPath = resolve12("./");
|
|
250684
|
-
const projectName = (name ??
|
|
252536
|
+
const projectName = (name ?? basename8(resolvedPath)).trim();
|
|
250685
252537
|
const template = await getTemplateById("backend-only");
|
|
250686
252538
|
log.info(`Scaffolding project at ${resolvedPath}`);
|
|
250687
252539
|
const { projectId } = await runTask("Setting up your project...", async () => {
|
|
@@ -250886,7 +252738,7 @@ async function setEnvironmentVersion(environment, versionId, options = {}) {
|
|
|
250886
252738
|
}
|
|
250887
252739
|
// src/core/version/artifacts.ts
|
|
250888
252740
|
import { createHash as createHash3 } from "node:crypto";
|
|
250889
|
-
import { join as
|
|
252741
|
+
import { join as join30, resolve as resolve13 } from "node:path";
|
|
250890
252742
|
|
|
250891
252743
|
// src/core/version/functions.ts
|
|
250892
252744
|
import { createHash as createHash2 } from "node:crypto";
|
|
@@ -253161,10 +255013,6 @@ var STATIC_EGRESS_ENABLED_ENV = "BASE44_STATIC_EGRESS_ENABLED";
|
|
|
253161
255013
|
var STATIC_EGRESS_DIAGNOSTIC_LIMIT = 5;
|
|
253162
255014
|
var staticEgressFetchInstalled = false;
|
|
253163
255015
|
var staticEgressDiagnosticCount = 0;
|
|
253164
|
-
var dedicatedEgressResponses = /* @__PURE__ */ new WeakSet();
|
|
253165
|
-
function isDedicatedEgressResponse(response) {
|
|
253166
|
-
return dedicatedEgressResponses.has(response);
|
|
253167
|
-
}
|
|
253168
255016
|
function inputKind(input) {
|
|
253169
255017
|
if (typeof input === "string") return "string";
|
|
253170
255018
|
return input instanceof URL ? "url" : "request";
|
|
@@ -253266,10 +255114,7 @@ function createRequestScopedStaticEgressFetch(originalFetch, readEnvironment) {
|
|
|
253266
255114
|
return originalFetch(input, init);
|
|
253267
255115
|
}
|
|
253268
255116
|
logStaticEgressDecision("dedicated", input, binding, enableSecret);
|
|
253269
|
-
return binding.fetch(input, init)
|
|
253270
|
-
dedicatedEgressResponses.add(response);
|
|
253271
|
-
return response;
|
|
253272
|
-
});
|
|
255117
|
+
return binding.fetch(input, init);
|
|
253273
255118
|
};
|
|
253274
255119
|
}
|
|
253275
255120
|
function installStaticEgressFetch() {
|
|
@@ -253281,128 +255126,6 @@ function installStaticEgressFetch() {
|
|
|
253281
255126
|
staticEgressFetchInstalled = true;
|
|
253282
255127
|
}
|
|
253283
255128
|
|
|
253284
|
-
// src/edge-errors.ts
|
|
253285
|
-
var EDGE_ERRORS_HEADER = "X-B44-Edge-Errors";
|
|
253286
|
-
var MAX_EDGE_ERRORS = 5;
|
|
253287
|
-
var MAX_INSPECTED_BODY_BYTES = 8192;
|
|
253288
|
-
var BODY_READ_TIMEOUT_MS = 500;
|
|
253289
|
-
var PLAIN_TEXT_EDGE_ERROR = /^error code: (\\d{3,4})\\s*$/;
|
|
253290
|
-
var UNBRANDED_5XX_PAGE = /<center>cloudflare<\\/center>/i;
|
|
253291
|
-
var SAFE_VALUE = /^[\\x20-\\x7e]{1,253}$/;
|
|
253292
|
-
function safe(value) {
|
|
253293
|
-
return typeof value === "string" && SAFE_VALUE.test(value) ? value : void 0;
|
|
253294
|
-
}
|
|
253295
|
-
function parseEdgeErrorBody(body, status) {
|
|
253296
|
-
const plain = PLAIN_TEXT_EDGE_ERROR.exec(body);
|
|
253297
|
-
if (plain) return { code: Number(plain[1]) };
|
|
253298
|
-
if (status >= 500 && UNBRANDED_5XX_PAGE.test(body)) return { code: status };
|
|
253299
|
-
try {
|
|
253300
|
-
const json = JSON.parse(body);
|
|
253301
|
-
if (json === null || typeof json !== "object") return null;
|
|
253302
|
-
const fields = json;
|
|
253303
|
-
if (fields.cloudflare_error !== true || !Number.isInteger(fields.error_code)) return null;
|
|
253304
|
-
return {
|
|
253305
|
-
code: fields.error_code,
|
|
253306
|
-
name: safe(fields.error_name),
|
|
253307
|
-
category: safe(fields.error_category),
|
|
253308
|
-
zone: safe(fields.zone)
|
|
253309
|
-
};
|
|
253310
|
-
} catch {
|
|
253311
|
-
return null;
|
|
253312
|
-
}
|
|
253313
|
-
}
|
|
253314
|
-
async function readBodyPrefix(response) {
|
|
253315
|
-
if (Number(response.headers.get("content-length")) > MAX_INSPECTED_BODY_BYTES) return null;
|
|
253316
|
-
const reader = response.clone().body?.getReader();
|
|
253317
|
-
if (!reader) return "";
|
|
253318
|
-
const timer = setTimeout(() => reader.cancel().catch(() => {
|
|
253319
|
-
}), BODY_READ_TIMEOUT_MS);
|
|
253320
|
-
const decoder = new TextDecoder();
|
|
253321
|
-
let text = "";
|
|
253322
|
-
let size = 0;
|
|
253323
|
-
try {
|
|
253324
|
-
for (; ; ) {
|
|
253325
|
-
const { done, value } = await reader.read();
|
|
253326
|
-
if (done) break;
|
|
253327
|
-
size += value.byteLength;
|
|
253328
|
-
if (size > MAX_INSPECTED_BODY_BYTES) return null;
|
|
253329
|
-
text += decoder.decode(value, { stream: true });
|
|
253330
|
-
}
|
|
253331
|
-
} catch {
|
|
253332
|
-
return null;
|
|
253333
|
-
} finally {
|
|
253334
|
-
clearTimeout(timer);
|
|
253335
|
-
reader.cancel().catch(() => {
|
|
253336
|
-
});
|
|
253337
|
-
}
|
|
253338
|
-
return text + decoder.decode();
|
|
253339
|
-
}
|
|
253340
|
-
async function readEdgeError(response) {
|
|
253341
|
-
if (response.status < 400 || !response.headers.get("cf-ray")) return null;
|
|
253342
|
-
if (response.headers.get("cf-mitigated") === "challenge") {
|
|
253343
|
-
return { code: response.status, name: "challenge" };
|
|
253344
|
-
}
|
|
253345
|
-
const body = await readBodyPrefix(response);
|
|
253346
|
-
return body === null ? null : parseEdgeErrorBody(body, response.status);
|
|
253347
|
-
}
|
|
253348
|
-
function targetOrigin(input) {
|
|
253349
|
-
try {
|
|
253350
|
-
const raw = input instanceof URL ? input.href : typeof input === "string" ? input : input.url;
|
|
253351
|
-
return new URL(raw).origin;
|
|
253352
|
-
} catch {
|
|
253353
|
-
return null;
|
|
253354
|
-
}
|
|
253355
|
-
}
|
|
253356
|
-
async function recordEdgeError(input, response, startedAt) {
|
|
253357
|
-
const store = currentWorkerRuntimeContext();
|
|
253358
|
-
if (!store) return;
|
|
253359
|
-
const body = await readEdgeError(response);
|
|
253360
|
-
const target = targetOrigin(input);
|
|
253361
|
-
if (!body || !target) return;
|
|
253362
|
-
const record = store.edgeErrors ??= { errors: [], dropped: 0 };
|
|
253363
|
-
if (record.errors.length >= MAX_EDGE_ERRORS) {
|
|
253364
|
-
record.dropped += 1;
|
|
253365
|
-
return;
|
|
253366
|
-
}
|
|
253367
|
-
record.errors.push({
|
|
253368
|
-
...body,
|
|
253369
|
-
target,
|
|
253370
|
-
status: response.status,
|
|
253371
|
-
ray: safe(response.headers.get("cf-ray")) ?? "",
|
|
253372
|
-
egress: isDedicatedEgressResponse(response) ? "dedicated" : "shared",
|
|
253373
|
-
elapsed_ms: Date.now() - startedAt
|
|
253374
|
-
});
|
|
253375
|
-
}
|
|
253376
|
-
function createEdgeErrorFetch(innerFetch) {
|
|
253377
|
-
return async (input, init) => {
|
|
253378
|
-
const startedAt = Date.now();
|
|
253379
|
-
const response = await innerFetch(input, init);
|
|
253380
|
-
try {
|
|
253381
|
-
await recordEdgeError(input, response, startedAt);
|
|
253382
|
-
} catch {
|
|
253383
|
-
}
|
|
253384
|
-
return response;
|
|
253385
|
-
};
|
|
253386
|
-
}
|
|
253387
|
-
var edgeErrorFetchInstalled = false;
|
|
253388
|
-
function installEdgeErrorFetch() {
|
|
253389
|
-
if (edgeErrorFetchInstalled) return;
|
|
253390
|
-
globalThis.fetch = createEdgeErrorFetch(globalThis.fetch.bind(globalThis));
|
|
253391
|
-
edgeErrorFetchInstalled = true;
|
|
253392
|
-
}
|
|
253393
|
-
function attachEdgeErrors(response) {
|
|
253394
|
-
const record = currentWorkerRuntimeContext()?.edgeErrors;
|
|
253395
|
-
if (!record || !(response instanceof Response)) return response;
|
|
253396
|
-
if (response.status === 101 || response.webSocket) return response;
|
|
253397
|
-
try {
|
|
253398
|
-
const wrapped = new Response(response.body, response);
|
|
253399
|
-
wrapped.headers.set(EDGE_ERRORS_HEADER, JSON.stringify(record));
|
|
253400
|
-
return wrapped;
|
|
253401
|
-
} catch {
|
|
253402
|
-
return response;
|
|
253403
|
-
}
|
|
253404
|
-
}
|
|
253405
|
-
|
|
253406
255129
|
// src/static-egress-tcp-core.mjs
|
|
253407
255130
|
function normalizeHost(host) {
|
|
253408
255131
|
return host.toLowerCase().replace(/^\\[(.*)\\]$/, "$1").replace(/\\.$/, "");
|
|
@@ -253531,6 +255254,12 @@ var deno2 = Object.freeze({
|
|
|
253531
255254
|
});
|
|
253532
255255
|
globalThis.Deno = deno2;
|
|
253533
255256
|
globalThis.Buffer = Buffer2;
|
|
255257
|
+
try {
|
|
255258
|
+
new AsyncLocalStorage().enterWith(void 0);
|
|
255259
|
+
} catch {
|
|
255260
|
+
AsyncLocalStorage.prototype.enterWith = () => {
|
|
255261
|
+
};
|
|
255262
|
+
}
|
|
253534
255263
|
function getRegisteredHandler() {
|
|
253535
255264
|
return registeredHandler;
|
|
253536
255265
|
}
|
|
@@ -253556,9 +255285,7 @@ function resolveHandler(functionName) {
|
|
|
253556
255285
|
return handler;
|
|
253557
255286
|
}
|
|
253558
255287
|
export {
|
|
253559
|
-
attachEdgeErrors,
|
|
253560
255288
|
getRegisteredHandler,
|
|
253561
|
-
installEdgeErrorFetch,
|
|
253562
255289
|
installStaticEgressFetch,
|
|
253563
255290
|
registerLazy,
|
|
253564
255291
|
resolveHandler
|
|
@@ -256498,7 +258225,7 @@ var TELEMETRY_PATCH = [
|
|
|
256498
258225
|
var TELEMETRY_STORE_FIELDS = "reqId: crypto.randomUUID(), respondedAt: null, inflight: new Map(), inflightTotal: 0, hadRejection: false, hadNonOk: false, logBudget: 5";
|
|
256499
258226
|
|
|
256500
258227
|
// ../functions-compiler/src/version.ts
|
|
256501
|
-
var COMPILER_VERSION = "0.1.
|
|
258228
|
+
var COMPILER_VERSION = "0.1.8";
|
|
256502
258229
|
|
|
256503
258230
|
// ../functions-compiler/src/worker-entry.ts
|
|
256504
258231
|
function denoShimSource() {
|
|
@@ -256603,22 +258330,20 @@ registerLazy(${JSON.stringify(functionName)}, () => import(${JSON.stringify(user
|
|
|
256603
258330
|
function buildAppEntrySource(functionModules, telemetry, runtimeSecrets = false) {
|
|
256604
258331
|
const moduleImports = functionModules.map((file) => `import "./${file}";`).join(`
|
|
256605
258332
|
`);
|
|
256606
|
-
const handlerExpr = `_b44AttachInvocationLogs(
|
|
258333
|
+
const handlerExpr = `_b44AttachInvocationLogs(${telemetry ? "_b44AttachTelemetry(await handler(request, info))" : "await handler(request, info)"})`;
|
|
256607
258334
|
const guard = activationGuard(runtimeSecrets);
|
|
256608
258335
|
const returnExpr = guard(handlerExpr);
|
|
256609
258336
|
return `// Auto-generated by the base44 bundler. Do not edit.
|
|
256610
258337
|
|
|
256611
258338
|
import { currentWorkerRuntimeContext as _b44Context, runWithWorkerEnvironment as _b44Run } from ${JSON.stringify(RUNTIME_CONTEXT_SPECIFIER)};
|
|
256612
|
-
import {
|
|
258339
|
+
import { installStaticEgressFetch, resolveHandler } from "./${SHIM_FILENAME}";${activationImport(runtimeSecrets)}
|
|
256613
258340
|
${moduleImports}
|
|
256614
258341
|
|
|
256615
258342
|
${consolePatch(runtimeSecrets)}
|
|
256616
258343
|
${INVOCATION_LOGS_PATCH}
|
|
256617
|
-
// Static egress reads workerEnv from the active request store. Install it
|
|
256618
|
-
//
|
|
256619
|
-
// fetch wrapper.
|
|
258344
|
+
// Static egress reads workerEnv from the active request store. Install it
|
|
258345
|
+
// before telemetry so telemetry remains the outermost fetch wrapper.
|
|
256620
258346
|
installStaticEgressFetch();
|
|
256621
|
-
installEdgeErrorFetch();
|
|
256622
258347
|
${telemetry ? TELEMETRY_PATCH : ""}
|
|
256623
258348
|
|
|
256624
258349
|
export default {
|
|
@@ -260703,7 +262428,7 @@ var nativeEnumType = ZodNativeEnum.create;
|
|
|
260703
262428
|
var promiseType = ZodPromise.create;
|
|
260704
262429
|
var effectsType = ZodEffects.create;
|
|
260705
262430
|
var optionalType = ZodOptional2.create;
|
|
260706
|
-
var
|
|
262431
|
+
var nullableType2 = ZodNullable2.create;
|
|
260707
262432
|
var preprocessType = ZodEffects.createWithPreprocess;
|
|
260708
262433
|
var pipelineType = ZodPipeline.create;
|
|
260709
262434
|
// ../functions-compiler/src/contracts.ts
|
|
@@ -260733,7 +262458,7 @@ var bundleAppRequestSchema = objectType({
|
|
|
260733
262458
|
var ACTIVATION_MODE = "pull";
|
|
260734
262459
|
|
|
260735
262460
|
// ../functions-compiler/src/deno-bundle.ts
|
|
260736
|
-
import { mkdtemp, rm, writeFile as writeFile2 } from "node:fs/promises";
|
|
262461
|
+
import { mkdtemp, rm as rm2, writeFile as writeFile2 } from "node:fs/promises";
|
|
260737
262462
|
import { tmpdir as tmpdir2 } from "node:os";
|
|
260738
262463
|
import path21 from "node:path";
|
|
260739
262464
|
|
|
@@ -261124,6 +262849,174 @@ function runtimeVirtualPlugin() {
|
|
|
261124
262849
|
};
|
|
261125
262850
|
}
|
|
261126
262851
|
|
|
262852
|
+
// ../functions-compiler/src/esbuild/ws-native-virtual.ts
|
|
262853
|
+
var NAMESPACE4 = "base44-ws-native";
|
|
262854
|
+
var WS_SPECIFIER = /^(npm:)?ws(@[^/]+)?$/;
|
|
262855
|
+
var ADAPTER = `"use strict";
|
|
262856
|
+
const toBuffer = (value) => (globalThis.Buffer ? globalThis.Buffer.from(value) : value);
|
|
262857
|
+
const READY_STATES = ["CONNECTING", "OPEN", "CLOSING", "CLOSED"];
|
|
262858
|
+
const later = (fn, ...args) => queueMicrotask(() => fn(...args));
|
|
262859
|
+
const upgradeHeaders = (options) => {
|
|
262860
|
+
const headers = new Headers(options?.headers);
|
|
262861
|
+
for (const name of headers.keys()) if (name !== "user-agent") return headers;
|
|
262862
|
+
return null;
|
|
262863
|
+
};
|
|
262864
|
+
class WebSocket {
|
|
262865
|
+
static CONNECTING = 0;
|
|
262866
|
+
static OPEN = 1;
|
|
262867
|
+
static CLOSING = 2;
|
|
262868
|
+
static CLOSED = 3;
|
|
262869
|
+
#socket = null;
|
|
262870
|
+
#state = 0;
|
|
262871
|
+
#url;
|
|
262872
|
+
#closeRequested = null;
|
|
262873
|
+
#terminated = false;
|
|
262874
|
+
#listeners = new Map();
|
|
262875
|
+
constructor(address, protocols, options) {
|
|
262876
|
+
if (protocols && typeof protocols === "object" && !Array.isArray(protocols)) {
|
|
262877
|
+
options = protocols;
|
|
262878
|
+
protocols = undefined;
|
|
262879
|
+
}
|
|
262880
|
+
this.#url = String(address);
|
|
262881
|
+
const headers = upgradeHeaders(options);
|
|
262882
|
+
if (headers) {
|
|
262883
|
+
this.#upgrade(headers, protocols);
|
|
262884
|
+
} else {
|
|
262885
|
+
this.#attach(new globalThis.WebSocket(this.#url, protocols));
|
|
262886
|
+
}
|
|
262887
|
+
}
|
|
262888
|
+
get readyState() {
|
|
262889
|
+
if (this.#terminated) return 3;
|
|
262890
|
+
return this.#socket ? this.#socket.readyState : this.#state;
|
|
262891
|
+
}
|
|
262892
|
+
get url() { return this.#url; }
|
|
262893
|
+
get protocol() { return this.#socket ? this.#socket.protocol ?? "" : ""; }
|
|
262894
|
+
on(name, listener) { return this.#add(name, listener, false); }
|
|
262895
|
+
addListener(name, listener) { return this.#add(name, listener, false); }
|
|
262896
|
+
once(name, listener) { return this.#add(name, listener, true); }
|
|
262897
|
+
off(name, listener) { return this.removeListener(name, listener); }
|
|
262898
|
+
removeListener(name, listener) {
|
|
262899
|
+
const listeners = this.#listeners.get(name);
|
|
262900
|
+
if (listeners) this.#listeners.set(name, listeners.filter((entry) => entry.listener !== listener));
|
|
262901
|
+
return this;
|
|
262902
|
+
}
|
|
262903
|
+
removeAllListeners(name) {
|
|
262904
|
+
if (name === undefined) this.#listeners.clear();
|
|
262905
|
+
else this.#listeners.delete(name);
|
|
262906
|
+
return this;
|
|
262907
|
+
}
|
|
262908
|
+
emit(name, ...args) {
|
|
262909
|
+
const listeners = this.#listeners.get(name) ?? [];
|
|
262910
|
+
this.#listeners.set(name, listeners.filter((entry) => !entry.once));
|
|
262911
|
+
for (const entry of listeners) entry.listener.apply(this, args);
|
|
262912
|
+
return listeners.length > 0;
|
|
262913
|
+
}
|
|
262914
|
+
send(data, options, callback) {
|
|
262915
|
+
const done = typeof options === "function" ? options : callback;
|
|
262916
|
+
try {
|
|
262917
|
+
if (!this.#socket) {
|
|
262918
|
+
throw new Error("WebSocket is not open: readyState " + this.#state + " (" + READY_STATES[this.#state] + ")");
|
|
262919
|
+
}
|
|
262920
|
+
this.#socket.send(data);
|
|
262921
|
+
done?.();
|
|
262922
|
+
} catch (error) {
|
|
262923
|
+
if (!done) throw error;
|
|
262924
|
+
done(error);
|
|
262925
|
+
}
|
|
262926
|
+
}
|
|
262927
|
+
close(code, reason) {
|
|
262928
|
+
if (this.#socket) this.#socket.close(code, reason);
|
|
262929
|
+
else if (this.#state === 0) {
|
|
262930
|
+
// Upgrade still in flight: close as soon as it lands.
|
|
262931
|
+
this.#closeRequested = [code, reason];
|
|
262932
|
+
this.#state = 2;
|
|
262933
|
+
}
|
|
262934
|
+
}
|
|
262935
|
+
// \`ws\` tears the connection down at once. workerd has no abrupt close, so the
|
|
262936
|
+
// socket is closed normally and "close" is reported now, not on the reply.
|
|
262937
|
+
terminate() {
|
|
262938
|
+
if (this.#terminated || this.readyState === 3) return;
|
|
262939
|
+
this.#terminated = true;
|
|
262940
|
+
if (this.#socket) {
|
|
262941
|
+
try { this.#socket.close(); } catch {}
|
|
262942
|
+
} else {
|
|
262943
|
+
// Upgrade still in flight: close it on arrival, without an "open".
|
|
262944
|
+
this.#closeRequested = [];
|
|
262945
|
+
this.#state = 3;
|
|
262946
|
+
}
|
|
262947
|
+
later(() => this.emit("close", 1006, toBuffer("")));
|
|
262948
|
+
}
|
|
262949
|
+
#attach(socket) {
|
|
262950
|
+
this.#socket = socket;
|
|
262951
|
+
try { socket.binaryType = "arraybuffer"; } catch {}
|
|
262952
|
+
socket.addEventListener("open", () => this.emit("open"));
|
|
262953
|
+
socket.addEventListener("message", (event) => {
|
|
262954
|
+
const isBinary = typeof event.data !== "string";
|
|
262955
|
+
this.emit("message", toBuffer(isBinary ? new Uint8Array(event.data) : event.data), isBinary);
|
|
262956
|
+
});
|
|
262957
|
+
socket.addEventListener("error", (event) => this.emit("error", event.error ?? new Error(event.message || "WebSocket error")));
|
|
262958
|
+
socket.addEventListener("close", (event) => {
|
|
262959
|
+
if (!this.#terminated) this.emit("close", event.code, toBuffer(event.reason ?? ""));
|
|
262960
|
+
});
|
|
262961
|
+
}
|
|
262962
|
+
#upgrade(headers, protocols) {
|
|
262963
|
+
headers.set("Upgrade", "websocket");
|
|
262964
|
+
if (protocols) headers.set("Sec-WebSocket-Protocol", [].concat(protocols).join(", "));
|
|
262965
|
+
const httpUrl = this.#url.replace(/^ws(s?):/i, "http$1:");
|
|
262966
|
+
const fail = (error) => {
|
|
262967
|
+
this.#state = 3;
|
|
262968
|
+
if (this.#terminated) return;
|
|
262969
|
+
this.emit("error", error);
|
|
262970
|
+
this.emit("close", 1006, toBuffer(""));
|
|
262971
|
+
};
|
|
262972
|
+
// Two-argument then(): an exception from an "open" listener must not be
|
|
262973
|
+
// reported as a failed upgrade.
|
|
262974
|
+
fetch(httpUrl, { headers }).then((response) => {
|
|
262975
|
+
const socket = response.webSocket;
|
|
262976
|
+
if (!socket) {
|
|
262977
|
+
response.body?.cancel();
|
|
262978
|
+
return fail(new Error("Unexpected server response: " + response.status));
|
|
262979
|
+
}
|
|
262980
|
+
socket.accept();
|
|
262981
|
+
this.#attach(socket);
|
|
262982
|
+
if (this.#closeRequested) return socket.close(...this.#closeRequested);
|
|
262983
|
+
// accept() opens the socket without dispatching an "open" event.
|
|
262984
|
+
this.emit("open");
|
|
262985
|
+
}, fail);
|
|
262986
|
+
}
|
|
262987
|
+
#add(name, listener, once) {
|
|
262988
|
+
const listeners = this.#listeners.get(name) ?? [];
|
|
262989
|
+
listeners.push({ listener, once });
|
|
262990
|
+
this.#listeners.set(name, listeners);
|
|
262991
|
+
return this;
|
|
262992
|
+
}
|
|
262993
|
+
}
|
|
262994
|
+
class WebSocketServer {
|
|
262995
|
+
constructor() {
|
|
262996
|
+
throw new Error("ws WebSocketServer is not available in Base44 functions: a function can open WebSocket connections but cannot listen for them.");
|
|
262997
|
+
}
|
|
262998
|
+
}
|
|
262999
|
+
module.exports = WebSocket;
|
|
263000
|
+
module.exports.WebSocket = WebSocket;
|
|
263001
|
+
module.exports.WebSocketServer = WebSocketServer;
|
|
263002
|
+
module.exports.default = WebSocket;
|
|
263003
|
+
`;
|
|
263004
|
+
function wsNativeVirtualPlugin() {
|
|
263005
|
+
return {
|
|
263006
|
+
name: "base44-ws-native",
|
|
263007
|
+
setup(build) {
|
|
263008
|
+
build.onResolve({ filter: WS_SPECIFIER }, () => ({
|
|
263009
|
+
path: "ws",
|
|
263010
|
+
namespace: NAMESPACE4
|
|
263011
|
+
}));
|
|
263012
|
+
build.onLoad({ filter: /.*/, namespace: NAMESPACE4 }, () => ({
|
|
263013
|
+
contents: ADAPTER,
|
|
263014
|
+
loader: "js"
|
|
263015
|
+
}));
|
|
263016
|
+
}
|
|
263017
|
+
};
|
|
263018
|
+
}
|
|
263019
|
+
|
|
261127
263020
|
// ../functions-compiler/src/deno-bundle.ts
|
|
261128
263021
|
async function bundleToModule(prepared, nodeModulesDir = "none") {
|
|
261129
263022
|
const dir = await mkdtemp(path21.join(tmpdir2(), "b44-bundle-"));
|
|
@@ -261147,6 +263040,7 @@ async function bundleToModule(prepared, nodeModulesDir = "none") {
|
|
|
261147
263040
|
sourcemap: false,
|
|
261148
263041
|
logLevel: "silent",
|
|
261149
263042
|
plugins: [
|
|
263043
|
+
wsNativeVirtualPlugin(),
|
|
261150
263044
|
nodeBuiltinRequirePlugin(),
|
|
261151
263045
|
userFilesPlugin(prepared.files, prepared.entry),
|
|
261152
263046
|
privateDataSourcesVirtualPlugin(),
|
|
@@ -261171,7 +263065,7 @@ async function bundleToModule(prepared, nodeModulesDir = "none") {
|
|
|
261171
263065
|
warnings: result.warnings.map((w) => w.text)
|
|
261172
263066
|
};
|
|
261173
263067
|
} finally {
|
|
261174
|
-
await
|
|
263068
|
+
await rm2(dir, { recursive: true, force: true });
|
|
261175
263069
|
}
|
|
261176
263070
|
}
|
|
261177
263071
|
function buildFailureErrors(e, dir) {
|
|
@@ -261771,14 +263665,14 @@ async function readRawResources(dir) {
|
|
|
261771
263665
|
const payloads = {};
|
|
261772
263666
|
for (const relativePath of files.sort()) {
|
|
261773
263667
|
const name = relativePath.replace(/\.jsonc?$/, "");
|
|
261774
|
-
payloads[name] = await readJsonFile(
|
|
263668
|
+
payloads[name] = await readJsonFile(join30(dir, ...relativePath.split("/")));
|
|
261775
263669
|
}
|
|
261776
263670
|
return payloads;
|
|
261777
263671
|
}
|
|
261778
263672
|
async function collectResources(configDir, dirs) {
|
|
261779
263673
|
const [entities, agents] = await Promise.all([
|
|
261780
|
-
readRawResources(
|
|
261781
|
-
readRawResources(
|
|
263674
|
+
readRawResources(join30(configDir, dirs.entitiesDir)),
|
|
263675
|
+
readRawResources(join30(configDir, dirs.agentsDir))
|
|
261782
263676
|
]);
|
|
261783
263677
|
return { entities, agents };
|
|
261784
263678
|
}
|
|
@@ -261790,7 +263684,7 @@ async function collectArtifacts(target) {
|
|
|
261790
263684
|
entryFile: ENTRY2
|
|
261791
263685
|
}),
|
|
261792
263686
|
...siteWorker ? { siteWorker } : {},
|
|
261793
|
-
backendBundles: await tagStep2("build", () => compileBackendBundles(target.root,
|
|
263687
|
+
backendBundles: await tagStep2("build", () => compileBackendBundles(target.root, join30(target.configDir, target.functionsDir))),
|
|
261794
263688
|
...await collectResources(target.configDir, target)
|
|
261795
263689
|
};
|
|
261796
263690
|
}
|
|
@@ -262007,7 +263901,7 @@ function writeFile3(appId, params) {
|
|
|
262007
263901
|
function editFile(appId, params) {
|
|
262008
263902
|
return callTool(appId, "edit_file", { ...params }, EditFileResponseSchema, `editing file "${params.path}"`);
|
|
262009
263903
|
}
|
|
262010
|
-
function
|
|
263904
|
+
function grep2(appId, params) {
|
|
262011
263905
|
return callTool(appId, "grep", { ...params }, GrepResponseSchema, "searching files");
|
|
262012
263906
|
}
|
|
262013
263907
|
function runCommand(appId, params) {
|
|
@@ -262111,10 +264005,10 @@ Examples:
|
|
|
262111
264005
|
}
|
|
262112
264006
|
|
|
262113
264007
|
// src/cli/commands/sandbox/grep.ts
|
|
262114
|
-
async function
|
|
264008
|
+
async function grepAction2({ runTask, branchId }, pattern, options) {
|
|
262115
264009
|
const { id: appId } = getAppContext();
|
|
262116
264010
|
const maxResults = parsePositiveInt(options.maxResults, "--max-results");
|
|
262117
|
-
const result = await runTask("Searching files", () =>
|
|
264011
|
+
const result = await runTask("Searching files", () => grep2(appId, {
|
|
262118
264012
|
pattern,
|
|
262119
264013
|
path: options.path,
|
|
262120
264014
|
is_regex: options.regex,
|
|
@@ -262126,7 +264020,7 @@ async function grepAction({ runTask, branchId }, pattern, options) {
|
|
|
262126
264020
|
return { outroMessage: "Searched files", stdout: toJsonStdout(result) };
|
|
262127
264021
|
}
|
|
262128
264022
|
function getSandboxGrepCommand() {
|
|
262129
|
-
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(
|
|
264023
|
+
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);
|
|
262130
264024
|
}
|
|
262131
264025
|
|
|
262132
264026
|
// src/cli/commands/sandbox/list-directory.ts
|
|
@@ -262721,10 +264615,10 @@ function toPascalCase(name) {
|
|
|
262721
264615
|
return name.split(/[-_\s]+/).map((w) => w.charAt(0).toUpperCase() + w.slice(1)).join("");
|
|
262722
264616
|
}
|
|
262723
264617
|
// src/core/types/update-project.ts
|
|
262724
|
-
import { join as
|
|
264618
|
+
import { join as join34 } from "node:path";
|
|
262725
264619
|
var TYPES_INCLUDE_PATH = `${PROJECT_SUBDIR}/${TYPES_OUTPUT_SUBDIR}/*.d.ts`;
|
|
262726
264620
|
async function updateProjectConfig(projectRoot) {
|
|
262727
|
-
const tsconfigPath =
|
|
264621
|
+
const tsconfigPath = join34(projectRoot, "tsconfig.json");
|
|
262728
264622
|
if (!await pathExists(tsconfigPath)) {
|
|
262729
264623
|
return false;
|
|
262730
264624
|
}
|
|
@@ -262943,7 +264837,7 @@ function rethrowLegacyAppAsExplanation(error) {
|
|
|
262943
264837
|
|
|
262944
264838
|
// src/cli/commands/workflows/limit.ts
|
|
262945
264839
|
var MAX_LIMIT = 200;
|
|
262946
|
-
function
|
|
264840
|
+
function parseLimit2(limit) {
|
|
262947
264841
|
if (limit === undefined)
|
|
262948
264842
|
return;
|
|
262949
264843
|
const parsed = Number.parseInt(limit, 10);
|
|
@@ -262960,7 +264854,7 @@ function formatWorkflowLine(workflow) {
|
|
|
262960
264854
|
return `${workflow.name} [${workflow.status}] runs: ${workflow.totalRuns}, ${lastRun}${failures}`;
|
|
262961
264855
|
}
|
|
262962
264856
|
async function listAction({ log, runTask, jsonMode }, options) {
|
|
262963
|
-
const limit =
|
|
264857
|
+
const limit = parseLimit2(options.limit);
|
|
262964
264858
|
const workflows = await runTask("Fetching workflows from Base44", async () => listWorkflows(limit).catch(rethrowLegacyAppAsExplanation), {
|
|
262965
264859
|
successMessage: "Workflows fetched successfully",
|
|
262966
264860
|
errorMessage: "Failed to fetch workflows"
|
|
@@ -263019,7 +264913,7 @@ async function describeEmptyResult(hasFilters) {
|
|
|
263019
264913
|
return hasFilters ? `No runs match your filters. Workflows in this app: ${names}.` : `No runs yet. Workflows in this app: ${names}.`;
|
|
263020
264914
|
}
|
|
263021
264915
|
async function runsAction(ctx, options) {
|
|
263022
|
-
const limit =
|
|
264916
|
+
const limit = parseLimit2(options.limit);
|
|
263023
264917
|
const runs = await ctx.runTask("Fetching workflow runs from Base44", async () => listWorkflowRuns({
|
|
263024
264918
|
status: options.status,
|
|
263025
264919
|
since: options.since,
|
|
@@ -263205,7 +265099,7 @@ function getWorkspaceCommand() {
|
|
|
263205
265099
|
// src/cli/dev/dev-server/main.ts
|
|
263206
265100
|
var import_cors = __toESM(require_lib4(), 1);
|
|
263207
265101
|
var import_express6 = __toESM(require_express(), 1);
|
|
263208
|
-
import { dirname as dirname27, join as
|
|
265102
|
+
import { dirname as dirname27, join as join39 } from "node:path";
|
|
263209
265103
|
|
|
263210
265104
|
// ../../node_modules/get-port/index.js
|
|
263211
265105
|
import net from "node:net";
|
|
@@ -263335,7 +265229,7 @@ var $tmpName = promisify12(tmp.tmpName);
|
|
|
263335
265229
|
|
|
263336
265230
|
// src/cli/dev/dev-server/function-manager.ts
|
|
263337
265231
|
import { spawn as spawn3 } from "node:child_process";
|
|
263338
|
-
import { dirname as dirname24, join as
|
|
265232
|
+
import { dirname as dirname24, join as join35 } from "node:path";
|
|
263339
265233
|
import { pathToFileURL as pathToFileURL6 } from "node:url";
|
|
263340
265234
|
|
|
263341
265235
|
// src/cli/dev/dev-server/base-function-manager.ts
|
|
@@ -263440,7 +265334,7 @@ class FunctionManager extends BaseFunctionManager {
|
|
|
263440
265334
|
}
|
|
263441
265335
|
spawnFunction(func, port) {
|
|
263442
265336
|
this.logger.log(`Spawning function "${func.name}" on port ${port}`);
|
|
263443
|
-
const importMapPath =
|
|
265337
|
+
const importMapPath = join35(dirname24(this.wrapperPath), "import-map.json");
|
|
263444
265338
|
const process2 = spawn3("deno", ["run", "--allow-all", "--import-map", importMapPath, this.wrapperPath], {
|
|
263445
265339
|
env: {
|
|
263446
265340
|
...globalThis.process.env,
|
|
@@ -263514,7 +265408,7 @@ class FunctionManager extends BaseFunctionManager {
|
|
|
263514
265408
|
import { mkdirSync as mkdirSync2, writeFileSync as writeFileSync2 } from "node:fs";
|
|
263515
265409
|
import { isBuiltin as isBuiltin3 } from "node:module";
|
|
263516
265410
|
import { homedir as homedir4 } from "node:os";
|
|
263517
|
-
import { join as
|
|
265411
|
+
import { join as join36 } from "node:path";
|
|
263518
265412
|
import { pathToFileURL as pathToFileURL7 } from "node:url";
|
|
263519
265413
|
var depsPromise;
|
|
263520
265414
|
function loadDeps() {
|
|
@@ -263635,9 +265529,9 @@ export default {
|
|
|
263635
265529
|
};
|
|
263636
265530
|
`;
|
|
263637
265531
|
function ensureBundlerConfig() {
|
|
263638
|
-
const dir =
|
|
265532
|
+
const dir = join36(homedir4(), ".base44", "function-bundler");
|
|
263639
265533
|
mkdirSync2(dir, { recursive: true });
|
|
263640
|
-
const configPath =
|
|
265534
|
+
const configPath = join36(dir, "deno.json");
|
|
263641
265535
|
writeFileSync2(configPath, `${JSON.stringify({ nodeModulesDir: "auto" }, null, 2)}
|
|
263642
265536
|
`);
|
|
263643
265537
|
return configPath;
|
|
@@ -265174,11 +267068,11 @@ import { relative as relative10 } from "node:path";
|
|
|
265174
267068
|
// ../../node_modules/chokidar/index.js
|
|
265175
267069
|
import { EventEmitter as EventEmitter3 } from "node:events";
|
|
265176
267070
|
import { stat as statcb, Stats } from "node:fs";
|
|
265177
|
-
import { readdir as readdir3, stat as
|
|
267071
|
+
import { readdir as readdir3, stat as stat7 } from "node:fs/promises";
|
|
265178
267072
|
import * as sp3 from "node:path";
|
|
265179
267073
|
|
|
265180
267074
|
// ../../node_modules/readdirp/index.js
|
|
265181
|
-
import { lstat as lstat2, readdir as readdir2, realpath, stat as
|
|
267075
|
+
import { lstat as lstat2, readdir as readdir2, realpath, stat as stat5 } from "node:fs/promises";
|
|
265182
267076
|
import { join as pjoin, relative as prelative, resolve as presolve, sep as psep } from "node:path";
|
|
265183
267077
|
import { Readable as Readable6 } from "node:stream";
|
|
265184
267078
|
var EntryTypes = {
|
|
@@ -265187,7 +267081,7 @@ var EntryTypes = {
|
|
|
265187
267081
|
FILE_DIR_TYPE: "files_directories",
|
|
265188
267082
|
EVERYTHING_TYPE: "all"
|
|
265189
267083
|
};
|
|
265190
|
-
var
|
|
267084
|
+
var defaultOptions2 = {
|
|
265191
267085
|
root: ".",
|
|
265192
267086
|
fileFilter: (_entryInfo) => true,
|
|
265193
267087
|
directoryFilter: (_entryInfo) => true,
|
|
@@ -265197,7 +267091,7 @@ var defaultOptions = {
|
|
|
265197
267091
|
alwaysStat: false,
|
|
265198
267092
|
highWaterMark: 4096
|
|
265199
267093
|
};
|
|
265200
|
-
Object.freeze(
|
|
267094
|
+
Object.freeze(defaultOptions2);
|
|
265201
267095
|
var RECURSIVE_ERROR_CODE = "READDIRP_RECURSIVE_ERROR";
|
|
265202
267096
|
var NORMAL_FLOW_ERRORS = new Set(["ENOENT", "EPERM", "EACCES", "ELOOP", RECURSIVE_ERROR_CODE]);
|
|
265203
267097
|
var ALL_TYPES = [
|
|
@@ -265256,17 +267150,17 @@ class ReaddirpStream extends Readable6 {
|
|
|
265256
267150
|
autoDestroy: true,
|
|
265257
267151
|
highWaterMark: options.highWaterMark
|
|
265258
267152
|
});
|
|
265259
|
-
const opts = { ...
|
|
267153
|
+
const opts = { ...defaultOptions2, ...options };
|
|
265260
267154
|
const { root, type } = opts;
|
|
265261
267155
|
this._fileFilter = normalizeFilter(opts.fileFilter);
|
|
265262
267156
|
this._directoryFilter = normalizeFilter(opts.directoryFilter);
|
|
265263
|
-
const statMethod = opts.lstat ? lstat2 :
|
|
267157
|
+
const statMethod = opts.lstat ? lstat2 : stat5;
|
|
265264
267158
|
if (wantBigintFsStats) {
|
|
265265
267159
|
this._stat = (path) => statMethod(path, { bigint: true });
|
|
265266
267160
|
} else {
|
|
265267
267161
|
this._stat = statMethod;
|
|
265268
267162
|
}
|
|
265269
|
-
this._maxDepth = opts.depth != null && Number.isSafeInteger(opts.depth) ? opts.depth :
|
|
267163
|
+
this._maxDepth = opts.depth != null && Number.isSafeInteger(opts.depth) ? opts.depth : defaultOptions2.depth;
|
|
265270
267164
|
this._wantsDir = type ? DIR_TYPES.has(type) : false;
|
|
265271
267165
|
this._wantsFile = type ? FILE_TYPES2.has(type) : false;
|
|
265272
267166
|
this._wantsEverything = type === EntryTypes.EVERYTHING_TYPE;
|
|
@@ -265413,7 +267307,7 @@ function readdirp(root, options = {}) {
|
|
|
265413
267307
|
|
|
265414
267308
|
// ../../node_modules/chokidar/handler.js
|
|
265415
267309
|
import { watch as fs_watch, unwatchFile, watchFile } from "node:fs";
|
|
265416
|
-
import { realpath as fsrealpath, lstat as lstat3, open as open2, stat as
|
|
267310
|
+
import { realpath as fsrealpath, lstat as lstat3, open as open2, stat as stat6 } from "node:fs/promises";
|
|
265417
267311
|
import { type as osType } from "node:os";
|
|
265418
267312
|
import * as sp2 from "node:path";
|
|
265419
267313
|
var STR_DATA = "data";
|
|
@@ -265439,7 +267333,7 @@ var EVENTS = {
|
|
|
265439
267333
|
};
|
|
265440
267334
|
var EV = EVENTS;
|
|
265441
267335
|
var THROTTLE_MODE_WATCH = "watch";
|
|
265442
|
-
var statMethods = { lstat: lstat3, stat:
|
|
267336
|
+
var statMethods = { lstat: lstat3, stat: stat6 };
|
|
265443
267337
|
var KEY_LISTENERS = "listeners";
|
|
265444
267338
|
var KEY_ERR = "errHandlers";
|
|
265445
267339
|
var KEY_RAW = "rawEmitters";
|
|
@@ -265910,7 +267804,7 @@ class NodeFsHandler {
|
|
|
265910
267804
|
return;
|
|
265911
267805
|
if (!newStats || newStats.mtimeMs === 0) {
|
|
265912
267806
|
try {
|
|
265913
|
-
const newStats = await
|
|
267807
|
+
const newStats = await stat6(file);
|
|
265914
267808
|
if (this.fsw.closed)
|
|
265915
267809
|
return;
|
|
265916
267810
|
const at = newStats.atimeMs;
|
|
@@ -266162,7 +268056,7 @@ function createPattern(matcher) {
|
|
|
266162
268056
|
}
|
|
266163
268057
|
return () => false;
|
|
266164
268058
|
}
|
|
266165
|
-
function
|
|
268059
|
+
function normalizePath2(path) {
|
|
266166
268060
|
if (typeof path !== "string")
|
|
266167
268061
|
throw new Error("string expected");
|
|
266168
268062
|
path = sp3.normalize(path);
|
|
@@ -266176,7 +268070,7 @@ function normalizePath(path) {
|
|
|
266176
268070
|
return path;
|
|
266177
268071
|
}
|
|
266178
268072
|
function matchPatterns(patterns, testString, stats) {
|
|
266179
|
-
const path =
|
|
268073
|
+
const path = normalizePath2(testString);
|
|
266180
268074
|
for (let index = 0;index < patterns.length; index++) {
|
|
266181
268075
|
const pattern = patterns[index];
|
|
266182
268076
|
if (pattern(path, stats)) {
|
|
@@ -266582,7 +268476,7 @@ class FSWatcher extends EventEmitter3 {
|
|
|
266582
268476
|
const fullPath = opts.cwd ? sp3.join(opts.cwd, path) : path;
|
|
266583
268477
|
let stats;
|
|
266584
268478
|
try {
|
|
266585
|
-
stats = await
|
|
268479
|
+
stats = await stat7(fullPath);
|
|
266586
268480
|
} catch (err) {}
|
|
266587
268481
|
if (!stats || this.closed)
|
|
266588
268482
|
return;
|
|
@@ -266966,8 +268860,8 @@ async function createDevServer(options) {
|
|
|
266966
268860
|
broadcastEntityEvent(io, appId, entityName, event);
|
|
266967
268861
|
};
|
|
266968
268862
|
const base44ConfigWatcher = new WatchBase44({
|
|
266969
|
-
functions:
|
|
266970
|
-
entities:
|
|
268863
|
+
functions: join39(dirname27(project.configPath), project.functionsDir),
|
|
268864
|
+
entities: join39(dirname27(project.configPath), project.entitiesDir)
|
|
266971
268865
|
}, devLogger);
|
|
266972
268866
|
base44ConfigWatcher.on("change", async (name) => {
|
|
266973
268867
|
try {
|
|
@@ -267170,7 +269064,7 @@ function readExecEnvTarget(env = process.env) {
|
|
|
267170
269064
|
// src/core/exec/run-script.ts
|
|
267171
269065
|
import { spawn as spawn4 } from "node:child_process";
|
|
267172
269066
|
import { readFileSync as readFileSync4, writeFileSync as writeFileSync3 } from "node:fs";
|
|
267173
|
-
import { join as
|
|
269067
|
+
import { join as join40 } from "node:path";
|
|
267174
269068
|
var SDK_SPECIFIER = '"npm:@base44/sdk"';
|
|
267175
269069
|
function wrapperSource(sdkVersion) {
|
|
267176
269070
|
const source = readFileSync4(getExecWrapperPath(), "utf-8");
|
|
@@ -267206,7 +269100,7 @@ async function runScript(options) {
|
|
|
267206
269100
|
writeFileSync3(tempWrapper.path, wrapperSource(sdkVersion), "utf-8");
|
|
267207
269101
|
const configDir = await $dir({ unsafeCleanup: true });
|
|
267208
269102
|
cleanupFns.push(configDir.cleanup);
|
|
267209
|
-
const configPath =
|
|
269103
|
+
const configPath = join40(configDir.path, "deno.json");
|
|
267210
269104
|
writeFileSync3(configPath, JSON.stringify(DENO_CONFIG), "utf-8");
|
|
267211
269105
|
try {
|
|
267212
269106
|
const exitCode = await new Promise((resolvePromise) => {
|
|
@@ -267478,6 +269372,7 @@ function createProgram(context) {
|
|
|
267478
269372
|
program.addCommand(getSecretsCommand());
|
|
267479
269373
|
program.addCommand(getSandboxCommand());
|
|
267480
269374
|
program.addCommand(getBranchesCommand());
|
|
269375
|
+
program.addCommand(getApiCommand());
|
|
267481
269376
|
program.addCommand(getAuthCommand());
|
|
267482
269377
|
program.addCommand(getSiteCommand());
|
|
267483
269378
|
if (versionsApiEnabled()) {
|
|
@@ -271496,7 +273391,7 @@ function addCommandInfoToErrorReporter(program, errorReporter) {
|
|
|
271496
273391
|
// src/cli/index.ts
|
|
271497
273392
|
var __dirname4 = dirname29(fileURLToPath7(import.meta.url));
|
|
271498
273393
|
async function runCLI(options) {
|
|
271499
|
-
ensureNpmAssets(
|
|
273394
|
+
ensureNpmAssets(join41(__dirname4, "../assets"));
|
|
271500
273395
|
const errorReporter = new ErrorReporter;
|
|
271501
273396
|
errorReporter.registerProcessErrorHandlers();
|
|
271502
273397
|
const jsonMode = process.argv.includes("--json");
|
|
@@ -271535,4 +273430,4 @@ export {
|
|
|
271535
273430
|
runCLI
|
|
271536
273431
|
};
|
|
271537
273432
|
|
|
271538
|
-
//# debugId=
|
|
273433
|
+
//# debugId=67402E43327C710664756E2164756E21
|