@base44-preview/cli 0.1.32-pr.664.f359bf9 → 0.1.32-pr.665.9dd49bd
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -0
- package/dist/cli/index.js +2472 -100
- package/dist/cli/index.js.map +31 -13
- 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
|
|
228841
|
+
import { dirname as dirname30, join as join41 } from "node:path";
|
|
228842
228842
|
import { fileURLToPath as fileURLToPath7 } from "node:url";
|
|
228843
228843
|
|
|
228844
228844
|
// ../../node_modules/@clack/core/dist/index.mjs
|
|
@@ -239451,6 +239451,7 @@ var package_default = {
|
|
|
239451
239451
|
jsonwebtoken: "^9.0.3",
|
|
239452
239452
|
ky: "^1.14.2",
|
|
239453
239453
|
lodash: "^4.17.23",
|
|
239454
|
+
minisearch: "^7.1.2",
|
|
239454
239455
|
ms: "^2.1.3",
|
|
239455
239456
|
multer: "^2.0.0",
|
|
239456
239457
|
nanoid: "^5.1.6",
|
|
@@ -246963,7 +246964,8 @@ async function resolveBuildTarget(projectRoot, overrides = {}) {
|
|
|
246963
246964
|
outputDir: resolve6(root, overrides.outputDir ?? site.outputDirectory ?? DEFAULT_SITE.outputDirectory),
|
|
246964
246965
|
entitiesDir: project?.entitiesDir ?? "entities",
|
|
246965
246966
|
agentsDir: project?.agentsDir ?? "agents",
|
|
246966
|
-
functionsDir: project?.functionsDir ?? "functions"
|
|
246967
|
+
functionsDir: project?.functionsDir ?? "functions",
|
|
246968
|
+
actorsDir: project?.actorsDir ?? "actors"
|
|
246967
246969
|
};
|
|
246968
246970
|
}
|
|
246969
246971
|
async function readSettingsIfPresent(projectRoot) {
|
|
@@ -247586,8 +247588,8 @@ function normalizeDatetime(value) {
|
|
|
247586
247588
|
return `${value}Z`;
|
|
247587
247589
|
}
|
|
247588
247590
|
// src/cli/utils/json.ts
|
|
247589
|
-
function toJsonStdout(result) {
|
|
247590
|
-
return `${JSON.stringify(result, null, 2)}
|
|
247591
|
+
function toJsonStdout(result, options = {}) {
|
|
247592
|
+
return `${JSON.stringify(result, null, options.compact ? undefined : 2)}
|
|
247591
247593
|
`;
|
|
247592
247594
|
}
|
|
247593
247595
|
// src/cli/errors.ts
|
|
@@ -248041,13 +248043,1873 @@ function getAgentsCommand() {
|
|
|
248041
248043
|
return new Command2("agents").description("Manage project agents").addCommand(getAgentsPushCommand()).addCommand(getAgentsPullCommand());
|
|
248042
248044
|
}
|
|
248043
248045
|
|
|
248046
|
+
// ../../node_modules/minisearch/dist/es/index.js
|
|
248047
|
+
var ENTRIES = "ENTRIES";
|
|
248048
|
+
var KEYS = "KEYS";
|
|
248049
|
+
var VALUES = "VALUES";
|
|
248050
|
+
var LEAF = "";
|
|
248051
|
+
|
|
248052
|
+
class TreeIterator {
|
|
248053
|
+
constructor(set, type) {
|
|
248054
|
+
const node = set._tree;
|
|
248055
|
+
const keys = Array.from(node.keys());
|
|
248056
|
+
this.set = set;
|
|
248057
|
+
this._type = type;
|
|
248058
|
+
this._path = keys.length > 0 ? [{ node, keys }] : [];
|
|
248059
|
+
}
|
|
248060
|
+
next() {
|
|
248061
|
+
const value = this.dive();
|
|
248062
|
+
this.backtrack();
|
|
248063
|
+
return value;
|
|
248064
|
+
}
|
|
248065
|
+
dive() {
|
|
248066
|
+
if (this._path.length === 0) {
|
|
248067
|
+
return { done: true, value: undefined };
|
|
248068
|
+
}
|
|
248069
|
+
const { node, keys } = last$1(this._path);
|
|
248070
|
+
if (last$1(keys) === LEAF) {
|
|
248071
|
+
return { done: false, value: this.result() };
|
|
248072
|
+
}
|
|
248073
|
+
const child = node.get(last$1(keys));
|
|
248074
|
+
this._path.push({ node: child, keys: Array.from(child.keys()) });
|
|
248075
|
+
return this.dive();
|
|
248076
|
+
}
|
|
248077
|
+
backtrack() {
|
|
248078
|
+
if (this._path.length === 0) {
|
|
248079
|
+
return;
|
|
248080
|
+
}
|
|
248081
|
+
const keys = last$1(this._path).keys;
|
|
248082
|
+
keys.pop();
|
|
248083
|
+
if (keys.length > 0) {
|
|
248084
|
+
return;
|
|
248085
|
+
}
|
|
248086
|
+
this._path.pop();
|
|
248087
|
+
this.backtrack();
|
|
248088
|
+
}
|
|
248089
|
+
key() {
|
|
248090
|
+
return this.set._prefix + this._path.map(({ keys }) => last$1(keys)).filter((key) => key !== LEAF).join("");
|
|
248091
|
+
}
|
|
248092
|
+
value() {
|
|
248093
|
+
return last$1(this._path).node.get(LEAF);
|
|
248094
|
+
}
|
|
248095
|
+
result() {
|
|
248096
|
+
switch (this._type) {
|
|
248097
|
+
case VALUES:
|
|
248098
|
+
return this.value();
|
|
248099
|
+
case KEYS:
|
|
248100
|
+
return this.key();
|
|
248101
|
+
default:
|
|
248102
|
+
return [this.key(), this.value()];
|
|
248103
|
+
}
|
|
248104
|
+
}
|
|
248105
|
+
[Symbol.iterator]() {
|
|
248106
|
+
return this;
|
|
248107
|
+
}
|
|
248108
|
+
}
|
|
248109
|
+
var last$1 = (array) => {
|
|
248110
|
+
return array[array.length - 1];
|
|
248111
|
+
};
|
|
248112
|
+
var fuzzySearch = (node, query, maxDistance) => {
|
|
248113
|
+
const results = new Map;
|
|
248114
|
+
if (query === undefined)
|
|
248115
|
+
return results;
|
|
248116
|
+
const n = query.length + 1;
|
|
248117
|
+
const m = n + maxDistance;
|
|
248118
|
+
const matrix = new Uint8Array(m * n).fill(maxDistance + 1);
|
|
248119
|
+
for (let j = 0;j < n; ++j)
|
|
248120
|
+
matrix[j] = j;
|
|
248121
|
+
for (let i = 1;i < m; ++i)
|
|
248122
|
+
matrix[i * n] = i;
|
|
248123
|
+
recurse(node, query, maxDistance, results, matrix, 1, n, "");
|
|
248124
|
+
return results;
|
|
248125
|
+
};
|
|
248126
|
+
var recurse = (node, query, maxDistance, results, matrix, m, n, prefix) => {
|
|
248127
|
+
const offset = m * n;
|
|
248128
|
+
key:
|
|
248129
|
+
for (const key of node.keys()) {
|
|
248130
|
+
if (key === LEAF) {
|
|
248131
|
+
const distance = matrix[offset - 1];
|
|
248132
|
+
if (distance <= maxDistance) {
|
|
248133
|
+
results.set(prefix, [node.get(key), distance]);
|
|
248134
|
+
}
|
|
248135
|
+
} else {
|
|
248136
|
+
let i = m;
|
|
248137
|
+
for (let pos = 0;pos < key.length; ++pos, ++i) {
|
|
248138
|
+
const char = key[pos];
|
|
248139
|
+
const thisRowOffset = n * i;
|
|
248140
|
+
const prevRowOffset = thisRowOffset - n;
|
|
248141
|
+
let minDistance = matrix[thisRowOffset];
|
|
248142
|
+
const jmin = Math.max(0, i - maxDistance - 1);
|
|
248143
|
+
const jmax = Math.min(n - 1, i + maxDistance);
|
|
248144
|
+
for (let j = jmin;j < jmax; ++j) {
|
|
248145
|
+
const different = char !== query[j];
|
|
248146
|
+
const rpl = matrix[prevRowOffset + j] + +different;
|
|
248147
|
+
const del = matrix[prevRowOffset + j + 1] + 1;
|
|
248148
|
+
const ins = matrix[thisRowOffset + j] + 1;
|
|
248149
|
+
const dist = matrix[thisRowOffset + j + 1] = Math.min(rpl, del, ins);
|
|
248150
|
+
if (dist < minDistance)
|
|
248151
|
+
minDistance = dist;
|
|
248152
|
+
}
|
|
248153
|
+
if (minDistance > maxDistance) {
|
|
248154
|
+
continue key;
|
|
248155
|
+
}
|
|
248156
|
+
}
|
|
248157
|
+
recurse(node.get(key), query, maxDistance, results, matrix, i, n, prefix + key);
|
|
248158
|
+
}
|
|
248159
|
+
}
|
|
248160
|
+
};
|
|
248161
|
+
|
|
248162
|
+
class SearchableMap {
|
|
248163
|
+
constructor(tree = new Map, prefix = "") {
|
|
248164
|
+
this._size = undefined;
|
|
248165
|
+
this._tree = tree;
|
|
248166
|
+
this._prefix = prefix;
|
|
248167
|
+
}
|
|
248168
|
+
atPrefix(prefix) {
|
|
248169
|
+
if (!prefix.startsWith(this._prefix)) {
|
|
248170
|
+
throw new Error("Mismatched prefix");
|
|
248171
|
+
}
|
|
248172
|
+
const [node, path] = trackDown(this._tree, prefix.slice(this._prefix.length));
|
|
248173
|
+
if (node === undefined) {
|
|
248174
|
+
const [parentNode, key] = last(path);
|
|
248175
|
+
for (const k of parentNode.keys()) {
|
|
248176
|
+
if (k !== LEAF && k.startsWith(key)) {
|
|
248177
|
+
const node = new Map;
|
|
248178
|
+
node.set(k.slice(key.length), parentNode.get(k));
|
|
248179
|
+
return new SearchableMap(node, prefix);
|
|
248180
|
+
}
|
|
248181
|
+
}
|
|
248182
|
+
}
|
|
248183
|
+
return new SearchableMap(node, prefix);
|
|
248184
|
+
}
|
|
248185
|
+
clear() {
|
|
248186
|
+
this._size = undefined;
|
|
248187
|
+
this._tree.clear();
|
|
248188
|
+
}
|
|
248189
|
+
delete(key) {
|
|
248190
|
+
this._size = undefined;
|
|
248191
|
+
return remove(this._tree, key);
|
|
248192
|
+
}
|
|
248193
|
+
entries() {
|
|
248194
|
+
return new TreeIterator(this, ENTRIES);
|
|
248195
|
+
}
|
|
248196
|
+
forEach(fn) {
|
|
248197
|
+
for (const [key, value] of this) {
|
|
248198
|
+
fn(key, value, this);
|
|
248199
|
+
}
|
|
248200
|
+
}
|
|
248201
|
+
fuzzyGet(key, maxEditDistance) {
|
|
248202
|
+
return fuzzySearch(this._tree, key, maxEditDistance);
|
|
248203
|
+
}
|
|
248204
|
+
get(key) {
|
|
248205
|
+
const node = lookup(this._tree, key);
|
|
248206
|
+
return node !== undefined ? node.get(LEAF) : undefined;
|
|
248207
|
+
}
|
|
248208
|
+
has(key) {
|
|
248209
|
+
const node = lookup(this._tree, key);
|
|
248210
|
+
return node !== undefined && node.has(LEAF);
|
|
248211
|
+
}
|
|
248212
|
+
keys() {
|
|
248213
|
+
return new TreeIterator(this, KEYS);
|
|
248214
|
+
}
|
|
248215
|
+
set(key, value) {
|
|
248216
|
+
if (typeof key !== "string") {
|
|
248217
|
+
throw new Error("key must be a string");
|
|
248218
|
+
}
|
|
248219
|
+
this._size = undefined;
|
|
248220
|
+
const node = createPath(this._tree, key);
|
|
248221
|
+
node.set(LEAF, value);
|
|
248222
|
+
return this;
|
|
248223
|
+
}
|
|
248224
|
+
get size() {
|
|
248225
|
+
if (this._size) {
|
|
248226
|
+
return this._size;
|
|
248227
|
+
}
|
|
248228
|
+
this._size = 0;
|
|
248229
|
+
const iter = this.entries();
|
|
248230
|
+
while (!iter.next().done)
|
|
248231
|
+
this._size += 1;
|
|
248232
|
+
return this._size;
|
|
248233
|
+
}
|
|
248234
|
+
update(key, fn) {
|
|
248235
|
+
if (typeof key !== "string") {
|
|
248236
|
+
throw new Error("key must be a string");
|
|
248237
|
+
}
|
|
248238
|
+
this._size = undefined;
|
|
248239
|
+
const node = createPath(this._tree, key);
|
|
248240
|
+
node.set(LEAF, fn(node.get(LEAF)));
|
|
248241
|
+
return this;
|
|
248242
|
+
}
|
|
248243
|
+
fetch(key, initial) {
|
|
248244
|
+
if (typeof key !== "string") {
|
|
248245
|
+
throw new Error("key must be a string");
|
|
248246
|
+
}
|
|
248247
|
+
this._size = undefined;
|
|
248248
|
+
const node = createPath(this._tree, key);
|
|
248249
|
+
let value = node.get(LEAF);
|
|
248250
|
+
if (value === undefined) {
|
|
248251
|
+
node.set(LEAF, value = initial());
|
|
248252
|
+
}
|
|
248253
|
+
return value;
|
|
248254
|
+
}
|
|
248255
|
+
values() {
|
|
248256
|
+
return new TreeIterator(this, VALUES);
|
|
248257
|
+
}
|
|
248258
|
+
[Symbol.iterator]() {
|
|
248259
|
+
return this.entries();
|
|
248260
|
+
}
|
|
248261
|
+
static from(entries) {
|
|
248262
|
+
const tree = new SearchableMap;
|
|
248263
|
+
for (const [key, value] of entries) {
|
|
248264
|
+
tree.set(key, value);
|
|
248265
|
+
}
|
|
248266
|
+
return tree;
|
|
248267
|
+
}
|
|
248268
|
+
static fromObject(object) {
|
|
248269
|
+
return SearchableMap.from(Object.entries(object));
|
|
248270
|
+
}
|
|
248271
|
+
}
|
|
248272
|
+
var trackDown = (tree, key, path = []) => {
|
|
248273
|
+
if (key.length === 0 || tree == null) {
|
|
248274
|
+
return [tree, path];
|
|
248275
|
+
}
|
|
248276
|
+
for (const k of tree.keys()) {
|
|
248277
|
+
if (k !== LEAF && key.startsWith(k)) {
|
|
248278
|
+
path.push([tree, k]);
|
|
248279
|
+
return trackDown(tree.get(k), key.slice(k.length), path);
|
|
248280
|
+
}
|
|
248281
|
+
}
|
|
248282
|
+
path.push([tree, key]);
|
|
248283
|
+
return trackDown(undefined, "", path);
|
|
248284
|
+
};
|
|
248285
|
+
var lookup = (tree, key) => {
|
|
248286
|
+
if (key.length === 0 || tree == null) {
|
|
248287
|
+
return tree;
|
|
248288
|
+
}
|
|
248289
|
+
for (const k of tree.keys()) {
|
|
248290
|
+
if (k !== LEAF && key.startsWith(k)) {
|
|
248291
|
+
return lookup(tree.get(k), key.slice(k.length));
|
|
248292
|
+
}
|
|
248293
|
+
}
|
|
248294
|
+
};
|
|
248295
|
+
var createPath = (node, key) => {
|
|
248296
|
+
const keyLength = key.length;
|
|
248297
|
+
outer:
|
|
248298
|
+
for (let pos = 0;node && pos < keyLength; ) {
|
|
248299
|
+
for (const k of node.keys()) {
|
|
248300
|
+
if (k !== LEAF && key[pos] === k[0]) {
|
|
248301
|
+
const len = Math.min(keyLength - pos, k.length);
|
|
248302
|
+
let offset = 1;
|
|
248303
|
+
while (offset < len && key[pos + offset] === k[offset])
|
|
248304
|
+
++offset;
|
|
248305
|
+
const child = node.get(k);
|
|
248306
|
+
if (offset === k.length) {
|
|
248307
|
+
node = child;
|
|
248308
|
+
} else {
|
|
248309
|
+
const intermediate = new Map;
|
|
248310
|
+
intermediate.set(k.slice(offset), child);
|
|
248311
|
+
node.set(key.slice(pos, pos + offset), intermediate);
|
|
248312
|
+
node.delete(k);
|
|
248313
|
+
node = intermediate;
|
|
248314
|
+
}
|
|
248315
|
+
pos += offset;
|
|
248316
|
+
continue outer;
|
|
248317
|
+
}
|
|
248318
|
+
}
|
|
248319
|
+
const child = new Map;
|
|
248320
|
+
node.set(key.slice(pos), child);
|
|
248321
|
+
return child;
|
|
248322
|
+
}
|
|
248323
|
+
return node;
|
|
248324
|
+
};
|
|
248325
|
+
var remove = (tree, key) => {
|
|
248326
|
+
const [node, path] = trackDown(tree, key);
|
|
248327
|
+
if (node === undefined) {
|
|
248328
|
+
return;
|
|
248329
|
+
}
|
|
248330
|
+
node.delete(LEAF);
|
|
248331
|
+
if (node.size === 0) {
|
|
248332
|
+
cleanup(path);
|
|
248333
|
+
} else if (node.size === 1) {
|
|
248334
|
+
const [key, value] = node.entries().next().value;
|
|
248335
|
+
merge3(path, key, value);
|
|
248336
|
+
}
|
|
248337
|
+
};
|
|
248338
|
+
var cleanup = (path) => {
|
|
248339
|
+
if (path.length === 0) {
|
|
248340
|
+
return;
|
|
248341
|
+
}
|
|
248342
|
+
const [node, key] = last(path);
|
|
248343
|
+
node.delete(key);
|
|
248344
|
+
if (node.size === 0) {
|
|
248345
|
+
cleanup(path.slice(0, -1));
|
|
248346
|
+
} else if (node.size === 1) {
|
|
248347
|
+
const [key, value] = node.entries().next().value;
|
|
248348
|
+
if (key !== LEAF) {
|
|
248349
|
+
merge3(path.slice(0, -1), key, value);
|
|
248350
|
+
}
|
|
248351
|
+
}
|
|
248352
|
+
};
|
|
248353
|
+
var merge3 = (path, key, value) => {
|
|
248354
|
+
if (path.length === 0) {
|
|
248355
|
+
return;
|
|
248356
|
+
}
|
|
248357
|
+
const [node, nodeKey] = last(path);
|
|
248358
|
+
node.set(nodeKey + key, value);
|
|
248359
|
+
node.delete(nodeKey);
|
|
248360
|
+
};
|
|
248361
|
+
var last = (array) => {
|
|
248362
|
+
return array[array.length - 1];
|
|
248363
|
+
};
|
|
248364
|
+
var OR = "or";
|
|
248365
|
+
var AND = "and";
|
|
248366
|
+
var AND_NOT = "and_not";
|
|
248367
|
+
|
|
248368
|
+
class MiniSearch {
|
|
248369
|
+
constructor(options) {
|
|
248370
|
+
if ((options === null || options === undefined ? undefined : options.fields) == null) {
|
|
248371
|
+
throw new Error('MiniSearch: option "fields" must be provided');
|
|
248372
|
+
}
|
|
248373
|
+
const autoVacuum = options.autoVacuum == null || options.autoVacuum === true ? defaultAutoVacuumOptions : options.autoVacuum;
|
|
248374
|
+
this._options = {
|
|
248375
|
+
...defaultOptions,
|
|
248376
|
+
...options,
|
|
248377
|
+
autoVacuum,
|
|
248378
|
+
searchOptions: { ...defaultSearchOptions, ...options.searchOptions || {} },
|
|
248379
|
+
autoSuggestOptions: { ...defaultAutoSuggestOptions, ...options.autoSuggestOptions || {} }
|
|
248380
|
+
};
|
|
248381
|
+
this._index = new SearchableMap;
|
|
248382
|
+
this._documentCount = 0;
|
|
248383
|
+
this._documentIds = new Map;
|
|
248384
|
+
this._idToShortId = new Map;
|
|
248385
|
+
this._fieldIds = {};
|
|
248386
|
+
this._fieldLength = new Map;
|
|
248387
|
+
this._avgFieldLength = [];
|
|
248388
|
+
this._nextId = 0;
|
|
248389
|
+
this._storedFields = new Map;
|
|
248390
|
+
this._dirtCount = 0;
|
|
248391
|
+
this._currentVacuum = null;
|
|
248392
|
+
this._enqueuedVacuum = null;
|
|
248393
|
+
this._enqueuedVacuumConditions = defaultVacuumConditions;
|
|
248394
|
+
this.addFields(this._options.fields);
|
|
248395
|
+
}
|
|
248396
|
+
add(document2) {
|
|
248397
|
+
const { extractField, tokenize, processTerm, fields, idField } = this._options;
|
|
248398
|
+
const id = extractField(document2, idField);
|
|
248399
|
+
if (id == null) {
|
|
248400
|
+
throw new Error(`MiniSearch: document does not have ID field "${idField}"`);
|
|
248401
|
+
}
|
|
248402
|
+
if (this._idToShortId.has(id)) {
|
|
248403
|
+
throw new Error(`MiniSearch: duplicate ID ${id}`);
|
|
248404
|
+
}
|
|
248405
|
+
const shortDocumentId = this.addDocumentId(id);
|
|
248406
|
+
this.saveStoredFields(shortDocumentId, document2);
|
|
248407
|
+
for (const field of fields) {
|
|
248408
|
+
const fieldValue = extractField(document2, field);
|
|
248409
|
+
if (fieldValue == null)
|
|
248410
|
+
continue;
|
|
248411
|
+
const tokens = tokenize(fieldValue.toString(), field);
|
|
248412
|
+
const fieldId = this._fieldIds[field];
|
|
248413
|
+
const uniqueTerms = new Set(tokens).size;
|
|
248414
|
+
this.addFieldLength(shortDocumentId, fieldId, this._documentCount - 1, uniqueTerms);
|
|
248415
|
+
for (const term of tokens) {
|
|
248416
|
+
const processedTerm = processTerm(term, field);
|
|
248417
|
+
if (Array.isArray(processedTerm)) {
|
|
248418
|
+
for (const t of processedTerm) {
|
|
248419
|
+
this.addTerm(fieldId, shortDocumentId, t);
|
|
248420
|
+
}
|
|
248421
|
+
} else if (processedTerm) {
|
|
248422
|
+
this.addTerm(fieldId, shortDocumentId, processedTerm);
|
|
248423
|
+
}
|
|
248424
|
+
}
|
|
248425
|
+
}
|
|
248426
|
+
}
|
|
248427
|
+
addAll(documents) {
|
|
248428
|
+
for (const document2 of documents)
|
|
248429
|
+
this.add(document2);
|
|
248430
|
+
}
|
|
248431
|
+
addAllAsync(documents, options = {}) {
|
|
248432
|
+
const { chunkSize = 10 } = options;
|
|
248433
|
+
const acc = { chunk: [], promise: Promise.resolve() };
|
|
248434
|
+
const { chunk, promise } = documents.reduce(({ chunk, promise }, document2, i) => {
|
|
248435
|
+
chunk.push(document2);
|
|
248436
|
+
if ((i + 1) % chunkSize === 0) {
|
|
248437
|
+
return {
|
|
248438
|
+
chunk: [],
|
|
248439
|
+
promise: promise.then(() => new Promise((resolve) => setTimeout(resolve, 0))).then(() => this.addAll(chunk))
|
|
248440
|
+
};
|
|
248441
|
+
} else {
|
|
248442
|
+
return { chunk, promise };
|
|
248443
|
+
}
|
|
248444
|
+
}, acc);
|
|
248445
|
+
return promise.then(() => this.addAll(chunk));
|
|
248446
|
+
}
|
|
248447
|
+
remove(document2) {
|
|
248448
|
+
const { tokenize, processTerm, extractField, fields, idField } = this._options;
|
|
248449
|
+
const id = extractField(document2, idField);
|
|
248450
|
+
if (id == null) {
|
|
248451
|
+
throw new Error(`MiniSearch: document does not have ID field "${idField}"`);
|
|
248452
|
+
}
|
|
248453
|
+
const shortId = this._idToShortId.get(id);
|
|
248454
|
+
if (shortId == null) {
|
|
248455
|
+
throw new Error(`MiniSearch: cannot remove document with ID ${id}: it is not in the index`);
|
|
248456
|
+
}
|
|
248457
|
+
for (const field of fields) {
|
|
248458
|
+
const fieldValue = extractField(document2, field);
|
|
248459
|
+
if (fieldValue == null)
|
|
248460
|
+
continue;
|
|
248461
|
+
const tokens = tokenize(fieldValue.toString(), field);
|
|
248462
|
+
const fieldId = this._fieldIds[field];
|
|
248463
|
+
const uniqueTerms = new Set(tokens).size;
|
|
248464
|
+
this.removeFieldLength(shortId, fieldId, this._documentCount, uniqueTerms);
|
|
248465
|
+
for (const term of tokens) {
|
|
248466
|
+
const processedTerm = processTerm(term, field);
|
|
248467
|
+
if (Array.isArray(processedTerm)) {
|
|
248468
|
+
for (const t of processedTerm) {
|
|
248469
|
+
this.removeTerm(fieldId, shortId, t);
|
|
248470
|
+
}
|
|
248471
|
+
} else if (processedTerm) {
|
|
248472
|
+
this.removeTerm(fieldId, shortId, processedTerm);
|
|
248473
|
+
}
|
|
248474
|
+
}
|
|
248475
|
+
}
|
|
248476
|
+
this._storedFields.delete(shortId);
|
|
248477
|
+
this._documentIds.delete(shortId);
|
|
248478
|
+
this._idToShortId.delete(id);
|
|
248479
|
+
this._fieldLength.delete(shortId);
|
|
248480
|
+
this._documentCount -= 1;
|
|
248481
|
+
}
|
|
248482
|
+
removeAll(documents) {
|
|
248483
|
+
if (documents) {
|
|
248484
|
+
for (const document2 of documents)
|
|
248485
|
+
this.remove(document2);
|
|
248486
|
+
} else if (arguments.length > 0) {
|
|
248487
|
+
throw new Error("Expected documents to be present. Omit the argument to remove all documents.");
|
|
248488
|
+
} else {
|
|
248489
|
+
this._index = new SearchableMap;
|
|
248490
|
+
this._documentCount = 0;
|
|
248491
|
+
this._documentIds = new Map;
|
|
248492
|
+
this._idToShortId = new Map;
|
|
248493
|
+
this._fieldLength = new Map;
|
|
248494
|
+
this._avgFieldLength = [];
|
|
248495
|
+
this._storedFields = new Map;
|
|
248496
|
+
this._nextId = 0;
|
|
248497
|
+
}
|
|
248498
|
+
}
|
|
248499
|
+
discard(id) {
|
|
248500
|
+
const shortId = this._idToShortId.get(id);
|
|
248501
|
+
if (shortId == null) {
|
|
248502
|
+
throw new Error(`MiniSearch: cannot discard document with ID ${id}: it is not in the index`);
|
|
248503
|
+
}
|
|
248504
|
+
this._idToShortId.delete(id);
|
|
248505
|
+
this._documentIds.delete(shortId);
|
|
248506
|
+
this._storedFields.delete(shortId);
|
|
248507
|
+
(this._fieldLength.get(shortId) || []).forEach((fieldLength, fieldId) => {
|
|
248508
|
+
this.removeFieldLength(shortId, fieldId, this._documentCount, fieldLength);
|
|
248509
|
+
});
|
|
248510
|
+
this._fieldLength.delete(shortId);
|
|
248511
|
+
this._documentCount -= 1;
|
|
248512
|
+
this._dirtCount += 1;
|
|
248513
|
+
this.maybeAutoVacuum();
|
|
248514
|
+
}
|
|
248515
|
+
maybeAutoVacuum() {
|
|
248516
|
+
if (this._options.autoVacuum === false) {
|
|
248517
|
+
return;
|
|
248518
|
+
}
|
|
248519
|
+
const { minDirtFactor, minDirtCount, batchSize, batchWait } = this._options.autoVacuum;
|
|
248520
|
+
this.conditionalVacuum({ batchSize, batchWait }, { minDirtCount, minDirtFactor });
|
|
248521
|
+
}
|
|
248522
|
+
discardAll(ids) {
|
|
248523
|
+
const autoVacuum = this._options.autoVacuum;
|
|
248524
|
+
try {
|
|
248525
|
+
this._options.autoVacuum = false;
|
|
248526
|
+
for (const id of ids) {
|
|
248527
|
+
this.discard(id);
|
|
248528
|
+
}
|
|
248529
|
+
} finally {
|
|
248530
|
+
this._options.autoVacuum = autoVacuum;
|
|
248531
|
+
}
|
|
248532
|
+
this.maybeAutoVacuum();
|
|
248533
|
+
}
|
|
248534
|
+
replace(updatedDocument) {
|
|
248535
|
+
const { idField, extractField } = this._options;
|
|
248536
|
+
const id = extractField(updatedDocument, idField);
|
|
248537
|
+
this.discard(id);
|
|
248538
|
+
this.add(updatedDocument);
|
|
248539
|
+
}
|
|
248540
|
+
vacuum(options = {}) {
|
|
248541
|
+
return this.conditionalVacuum(options);
|
|
248542
|
+
}
|
|
248543
|
+
conditionalVacuum(options, conditions) {
|
|
248544
|
+
if (this._currentVacuum) {
|
|
248545
|
+
this._enqueuedVacuumConditions = this._enqueuedVacuumConditions && conditions;
|
|
248546
|
+
if (this._enqueuedVacuum != null) {
|
|
248547
|
+
return this._enqueuedVacuum;
|
|
248548
|
+
}
|
|
248549
|
+
this._enqueuedVacuum = this._currentVacuum.then(() => {
|
|
248550
|
+
const conditions = this._enqueuedVacuumConditions;
|
|
248551
|
+
this._enqueuedVacuumConditions = defaultVacuumConditions;
|
|
248552
|
+
return this.performVacuuming(options, conditions);
|
|
248553
|
+
});
|
|
248554
|
+
return this._enqueuedVacuum;
|
|
248555
|
+
}
|
|
248556
|
+
if (this.vacuumConditionsMet(conditions) === false) {
|
|
248557
|
+
return Promise.resolve();
|
|
248558
|
+
}
|
|
248559
|
+
this._currentVacuum = this.performVacuuming(options);
|
|
248560
|
+
return this._currentVacuum;
|
|
248561
|
+
}
|
|
248562
|
+
async performVacuuming(options, conditions) {
|
|
248563
|
+
const initialDirtCount = this._dirtCount;
|
|
248564
|
+
if (this.vacuumConditionsMet(conditions)) {
|
|
248565
|
+
const batchSize = options.batchSize || defaultVacuumOptions.batchSize;
|
|
248566
|
+
const batchWait = options.batchWait || defaultVacuumOptions.batchWait;
|
|
248567
|
+
let i = 1;
|
|
248568
|
+
for (const [term, fieldsData] of this._index) {
|
|
248569
|
+
for (const [fieldId, fieldIndex] of fieldsData) {
|
|
248570
|
+
for (const [shortId] of fieldIndex) {
|
|
248571
|
+
if (this._documentIds.has(shortId)) {
|
|
248572
|
+
continue;
|
|
248573
|
+
}
|
|
248574
|
+
if (fieldIndex.size <= 1) {
|
|
248575
|
+
fieldsData.delete(fieldId);
|
|
248576
|
+
} else {
|
|
248577
|
+
fieldIndex.delete(shortId);
|
|
248578
|
+
}
|
|
248579
|
+
}
|
|
248580
|
+
}
|
|
248581
|
+
if (this._index.get(term).size === 0) {
|
|
248582
|
+
this._index.delete(term);
|
|
248583
|
+
}
|
|
248584
|
+
if (i % batchSize === 0) {
|
|
248585
|
+
await new Promise((resolve) => setTimeout(resolve, batchWait));
|
|
248586
|
+
}
|
|
248587
|
+
i += 1;
|
|
248588
|
+
}
|
|
248589
|
+
this._dirtCount -= initialDirtCount;
|
|
248590
|
+
}
|
|
248591
|
+
await null;
|
|
248592
|
+
this._currentVacuum = this._enqueuedVacuum;
|
|
248593
|
+
this._enqueuedVacuum = null;
|
|
248594
|
+
}
|
|
248595
|
+
vacuumConditionsMet(conditions) {
|
|
248596
|
+
if (conditions == null) {
|
|
248597
|
+
return true;
|
|
248598
|
+
}
|
|
248599
|
+
let { minDirtCount, minDirtFactor } = conditions;
|
|
248600
|
+
minDirtCount = minDirtCount || defaultAutoVacuumOptions.minDirtCount;
|
|
248601
|
+
minDirtFactor = minDirtFactor || defaultAutoVacuumOptions.minDirtFactor;
|
|
248602
|
+
return this.dirtCount >= minDirtCount && this.dirtFactor >= minDirtFactor;
|
|
248603
|
+
}
|
|
248604
|
+
get isVacuuming() {
|
|
248605
|
+
return this._currentVacuum != null;
|
|
248606
|
+
}
|
|
248607
|
+
get dirtCount() {
|
|
248608
|
+
return this._dirtCount;
|
|
248609
|
+
}
|
|
248610
|
+
get dirtFactor() {
|
|
248611
|
+
return this._dirtCount / (1 + this._documentCount + this._dirtCount);
|
|
248612
|
+
}
|
|
248613
|
+
has(id) {
|
|
248614
|
+
return this._idToShortId.has(id);
|
|
248615
|
+
}
|
|
248616
|
+
getStoredFields(id) {
|
|
248617
|
+
const shortId = this._idToShortId.get(id);
|
|
248618
|
+
if (shortId == null) {
|
|
248619
|
+
return;
|
|
248620
|
+
}
|
|
248621
|
+
return this._storedFields.get(shortId);
|
|
248622
|
+
}
|
|
248623
|
+
search(query, searchOptions = {}) {
|
|
248624
|
+
const { searchOptions: globalSearchOptions } = this._options;
|
|
248625
|
+
const searchOptionsWithDefaults = { ...globalSearchOptions, ...searchOptions };
|
|
248626
|
+
const rawResults = this.executeQuery(query, searchOptions);
|
|
248627
|
+
const results = [];
|
|
248628
|
+
for (const [docId, { score, terms, match }] of rawResults) {
|
|
248629
|
+
const quality = terms.length || 1;
|
|
248630
|
+
const result = {
|
|
248631
|
+
id: this._documentIds.get(docId),
|
|
248632
|
+
score: score * quality,
|
|
248633
|
+
terms: Object.keys(match),
|
|
248634
|
+
queryTerms: terms,
|
|
248635
|
+
match
|
|
248636
|
+
};
|
|
248637
|
+
Object.assign(result, this._storedFields.get(docId));
|
|
248638
|
+
if (searchOptionsWithDefaults.filter == null || searchOptionsWithDefaults.filter(result)) {
|
|
248639
|
+
results.push(result);
|
|
248640
|
+
}
|
|
248641
|
+
}
|
|
248642
|
+
if (query === MiniSearch.wildcard && searchOptionsWithDefaults.boostDocument == null) {
|
|
248643
|
+
return results;
|
|
248644
|
+
}
|
|
248645
|
+
results.sort(byScore);
|
|
248646
|
+
return results;
|
|
248647
|
+
}
|
|
248648
|
+
autoSuggest(queryString, options = {}) {
|
|
248649
|
+
options = { ...this._options.autoSuggestOptions, ...options };
|
|
248650
|
+
const suggestions = new Map;
|
|
248651
|
+
for (const { score, terms } of this.search(queryString, options)) {
|
|
248652
|
+
const phrase = terms.join(" ");
|
|
248653
|
+
const suggestion = suggestions.get(phrase);
|
|
248654
|
+
if (suggestion != null) {
|
|
248655
|
+
suggestion.score += score;
|
|
248656
|
+
suggestion.count += 1;
|
|
248657
|
+
} else {
|
|
248658
|
+
suggestions.set(phrase, { score, terms, count: 1 });
|
|
248659
|
+
}
|
|
248660
|
+
}
|
|
248661
|
+
const results = [];
|
|
248662
|
+
for (const [suggestion, { score, terms, count }] of suggestions) {
|
|
248663
|
+
results.push({ suggestion, terms, score: score / count });
|
|
248664
|
+
}
|
|
248665
|
+
results.sort(byScore);
|
|
248666
|
+
return results;
|
|
248667
|
+
}
|
|
248668
|
+
get documentCount() {
|
|
248669
|
+
return this._documentCount;
|
|
248670
|
+
}
|
|
248671
|
+
get termCount() {
|
|
248672
|
+
return this._index.size;
|
|
248673
|
+
}
|
|
248674
|
+
static loadJSON(json, options) {
|
|
248675
|
+
if (options == null) {
|
|
248676
|
+
throw new Error("MiniSearch: loadJSON should be given the same options used when serializing the index");
|
|
248677
|
+
}
|
|
248678
|
+
return this.loadJS(JSON.parse(json), options);
|
|
248679
|
+
}
|
|
248680
|
+
static async loadJSONAsync(json, options) {
|
|
248681
|
+
if (options == null) {
|
|
248682
|
+
throw new Error("MiniSearch: loadJSON should be given the same options used when serializing the index");
|
|
248683
|
+
}
|
|
248684
|
+
return this.loadJSAsync(JSON.parse(json), options);
|
|
248685
|
+
}
|
|
248686
|
+
static getDefault(optionName) {
|
|
248687
|
+
if (defaultOptions.hasOwnProperty(optionName)) {
|
|
248688
|
+
return getOwnProperty(defaultOptions, optionName);
|
|
248689
|
+
} else {
|
|
248690
|
+
throw new Error(`MiniSearch: unknown option "${optionName}"`);
|
|
248691
|
+
}
|
|
248692
|
+
}
|
|
248693
|
+
static loadJS(js, options) {
|
|
248694
|
+
const { index, documentIds, fieldLength, storedFields, serializationVersion } = js;
|
|
248695
|
+
const miniSearch = this.instantiateMiniSearch(js, options);
|
|
248696
|
+
miniSearch._documentIds = objectToNumericMap(documentIds);
|
|
248697
|
+
miniSearch._fieldLength = objectToNumericMap(fieldLength);
|
|
248698
|
+
miniSearch._storedFields = objectToNumericMap(storedFields);
|
|
248699
|
+
for (const [shortId, id] of miniSearch._documentIds) {
|
|
248700
|
+
miniSearch._idToShortId.set(id, shortId);
|
|
248701
|
+
}
|
|
248702
|
+
for (const [term, data] of index) {
|
|
248703
|
+
const dataMap = new Map;
|
|
248704
|
+
for (const fieldId of Object.keys(data)) {
|
|
248705
|
+
let indexEntry = data[fieldId];
|
|
248706
|
+
if (serializationVersion === 1) {
|
|
248707
|
+
indexEntry = indexEntry.ds;
|
|
248708
|
+
}
|
|
248709
|
+
dataMap.set(parseInt(fieldId, 10), objectToNumericMap(indexEntry));
|
|
248710
|
+
}
|
|
248711
|
+
miniSearch._index.set(term, dataMap);
|
|
248712
|
+
}
|
|
248713
|
+
return miniSearch;
|
|
248714
|
+
}
|
|
248715
|
+
static async loadJSAsync(js, options) {
|
|
248716
|
+
const { index, documentIds, fieldLength, storedFields, serializationVersion } = js;
|
|
248717
|
+
const miniSearch = this.instantiateMiniSearch(js, options);
|
|
248718
|
+
miniSearch._documentIds = await objectToNumericMapAsync(documentIds);
|
|
248719
|
+
miniSearch._fieldLength = await objectToNumericMapAsync(fieldLength);
|
|
248720
|
+
miniSearch._storedFields = await objectToNumericMapAsync(storedFields);
|
|
248721
|
+
for (const [shortId, id] of miniSearch._documentIds) {
|
|
248722
|
+
miniSearch._idToShortId.set(id, shortId);
|
|
248723
|
+
}
|
|
248724
|
+
let count = 0;
|
|
248725
|
+
for (const [term, data] of index) {
|
|
248726
|
+
const dataMap = new Map;
|
|
248727
|
+
for (const fieldId of Object.keys(data)) {
|
|
248728
|
+
let indexEntry = data[fieldId];
|
|
248729
|
+
if (serializationVersion === 1) {
|
|
248730
|
+
indexEntry = indexEntry.ds;
|
|
248731
|
+
}
|
|
248732
|
+
dataMap.set(parseInt(fieldId, 10), await objectToNumericMapAsync(indexEntry));
|
|
248733
|
+
}
|
|
248734
|
+
if (++count % 1000 === 0)
|
|
248735
|
+
await wait(0);
|
|
248736
|
+
miniSearch._index.set(term, dataMap);
|
|
248737
|
+
}
|
|
248738
|
+
return miniSearch;
|
|
248739
|
+
}
|
|
248740
|
+
static instantiateMiniSearch(js, options) {
|
|
248741
|
+
const { documentCount, nextId, fieldIds, averageFieldLength, dirtCount, serializationVersion } = js;
|
|
248742
|
+
if (serializationVersion !== 1 && serializationVersion !== 2) {
|
|
248743
|
+
throw new Error("MiniSearch: cannot deserialize an index created with an incompatible version");
|
|
248744
|
+
}
|
|
248745
|
+
const miniSearch = new MiniSearch(options);
|
|
248746
|
+
miniSearch._documentCount = documentCount;
|
|
248747
|
+
miniSearch._nextId = nextId;
|
|
248748
|
+
miniSearch._idToShortId = new Map;
|
|
248749
|
+
miniSearch._fieldIds = fieldIds;
|
|
248750
|
+
miniSearch._avgFieldLength = averageFieldLength;
|
|
248751
|
+
miniSearch._dirtCount = dirtCount || 0;
|
|
248752
|
+
miniSearch._index = new SearchableMap;
|
|
248753
|
+
return miniSearch;
|
|
248754
|
+
}
|
|
248755
|
+
executeQuery(query, searchOptions = {}) {
|
|
248756
|
+
if (query === MiniSearch.wildcard) {
|
|
248757
|
+
return this.executeWildcardQuery(searchOptions);
|
|
248758
|
+
}
|
|
248759
|
+
if (typeof query !== "string") {
|
|
248760
|
+
const options = { ...searchOptions, ...query, queries: undefined };
|
|
248761
|
+
const results = query.queries.map((subquery) => this.executeQuery(subquery, options));
|
|
248762
|
+
return this.combineResults(results, options.combineWith);
|
|
248763
|
+
}
|
|
248764
|
+
const { tokenize, processTerm, searchOptions: globalSearchOptions } = this._options;
|
|
248765
|
+
const options = { tokenize, processTerm, ...globalSearchOptions, ...searchOptions };
|
|
248766
|
+
const { tokenize: searchTokenize, processTerm: searchProcessTerm } = options;
|
|
248767
|
+
const terms = searchTokenize(query).flatMap((term) => searchProcessTerm(term)).filter((term) => !!term);
|
|
248768
|
+
const queries = terms.map(termToQuerySpec(options));
|
|
248769
|
+
const results = queries.map((query) => this.executeQuerySpec(query, options));
|
|
248770
|
+
return this.combineResults(results, options.combineWith);
|
|
248771
|
+
}
|
|
248772
|
+
executeQuerySpec(query, searchOptions) {
|
|
248773
|
+
const options = { ...this._options.searchOptions, ...searchOptions };
|
|
248774
|
+
const boosts = (options.fields || this._options.fields).reduce((boosts, field) => ({ ...boosts, [field]: getOwnProperty(options.boost, field) || 1 }), {});
|
|
248775
|
+
const { boostDocument, weights, maxFuzzy, bm25: bm25params } = options;
|
|
248776
|
+
const { fuzzy: fuzzyWeight, prefix: prefixWeight } = { ...defaultSearchOptions.weights, ...weights };
|
|
248777
|
+
const data = this._index.get(query.term);
|
|
248778
|
+
const results = this.termResults(query.term, query.term, 1, query.termBoost, data, boosts, boostDocument, bm25params);
|
|
248779
|
+
let prefixMatches;
|
|
248780
|
+
let fuzzyMatches;
|
|
248781
|
+
if (query.prefix) {
|
|
248782
|
+
prefixMatches = this._index.atPrefix(query.term);
|
|
248783
|
+
}
|
|
248784
|
+
if (query.fuzzy) {
|
|
248785
|
+
const fuzzy = query.fuzzy === true ? 0.2 : query.fuzzy;
|
|
248786
|
+
const maxDistance = fuzzy < 1 ? Math.min(maxFuzzy, Math.round(query.term.length * fuzzy)) : fuzzy;
|
|
248787
|
+
if (maxDistance)
|
|
248788
|
+
fuzzyMatches = this._index.fuzzyGet(query.term, maxDistance);
|
|
248789
|
+
}
|
|
248790
|
+
if (prefixMatches) {
|
|
248791
|
+
for (const [term, data] of prefixMatches) {
|
|
248792
|
+
const distance = term.length - query.term.length;
|
|
248793
|
+
if (!distance) {
|
|
248794
|
+
continue;
|
|
248795
|
+
}
|
|
248796
|
+
fuzzyMatches === null || fuzzyMatches === undefined || fuzzyMatches.delete(term);
|
|
248797
|
+
const weight = prefixWeight * term.length / (term.length + 0.3 * distance);
|
|
248798
|
+
this.termResults(query.term, term, weight, query.termBoost, data, boosts, boostDocument, bm25params, results);
|
|
248799
|
+
}
|
|
248800
|
+
}
|
|
248801
|
+
if (fuzzyMatches) {
|
|
248802
|
+
for (const term of fuzzyMatches.keys()) {
|
|
248803
|
+
const [data, distance] = fuzzyMatches.get(term);
|
|
248804
|
+
if (!distance) {
|
|
248805
|
+
continue;
|
|
248806
|
+
}
|
|
248807
|
+
const weight = fuzzyWeight * term.length / (term.length + distance);
|
|
248808
|
+
this.termResults(query.term, term, weight, query.termBoost, data, boosts, boostDocument, bm25params, results);
|
|
248809
|
+
}
|
|
248810
|
+
}
|
|
248811
|
+
return results;
|
|
248812
|
+
}
|
|
248813
|
+
executeWildcardQuery(searchOptions) {
|
|
248814
|
+
const results = new Map;
|
|
248815
|
+
const options = { ...this._options.searchOptions, ...searchOptions };
|
|
248816
|
+
for (const [shortId, id] of this._documentIds) {
|
|
248817
|
+
const score = options.boostDocument ? options.boostDocument(id, "", this._storedFields.get(shortId)) : 1;
|
|
248818
|
+
results.set(shortId, {
|
|
248819
|
+
score,
|
|
248820
|
+
terms: [],
|
|
248821
|
+
match: {}
|
|
248822
|
+
});
|
|
248823
|
+
}
|
|
248824
|
+
return results;
|
|
248825
|
+
}
|
|
248826
|
+
combineResults(results, combineWith = OR) {
|
|
248827
|
+
if (results.length === 0) {
|
|
248828
|
+
return new Map;
|
|
248829
|
+
}
|
|
248830
|
+
const operator = combineWith.toLowerCase();
|
|
248831
|
+
const combinator = combinators[operator];
|
|
248832
|
+
if (!combinator) {
|
|
248833
|
+
throw new Error(`Invalid combination operator: ${combineWith}`);
|
|
248834
|
+
}
|
|
248835
|
+
return results.reduce(combinator) || new Map;
|
|
248836
|
+
}
|
|
248837
|
+
toJSON() {
|
|
248838
|
+
const index = [];
|
|
248839
|
+
for (const [term, fieldIndex] of this._index) {
|
|
248840
|
+
const data = {};
|
|
248841
|
+
for (const [fieldId, freqs] of fieldIndex) {
|
|
248842
|
+
data[fieldId] = Object.fromEntries(freqs);
|
|
248843
|
+
}
|
|
248844
|
+
index.push([term, data]);
|
|
248845
|
+
}
|
|
248846
|
+
return {
|
|
248847
|
+
documentCount: this._documentCount,
|
|
248848
|
+
nextId: this._nextId,
|
|
248849
|
+
documentIds: Object.fromEntries(this._documentIds),
|
|
248850
|
+
fieldIds: this._fieldIds,
|
|
248851
|
+
fieldLength: Object.fromEntries(this._fieldLength),
|
|
248852
|
+
averageFieldLength: this._avgFieldLength,
|
|
248853
|
+
storedFields: Object.fromEntries(this._storedFields),
|
|
248854
|
+
dirtCount: this._dirtCount,
|
|
248855
|
+
index,
|
|
248856
|
+
serializationVersion: 2
|
|
248857
|
+
};
|
|
248858
|
+
}
|
|
248859
|
+
termResults(sourceTerm, derivedTerm, termWeight, termBoost, fieldTermData, fieldBoosts, boostDocumentFn, bm25params, results = new Map) {
|
|
248860
|
+
if (fieldTermData == null)
|
|
248861
|
+
return results;
|
|
248862
|
+
for (const field of Object.keys(fieldBoosts)) {
|
|
248863
|
+
const fieldBoost = fieldBoosts[field];
|
|
248864
|
+
const fieldId = this._fieldIds[field];
|
|
248865
|
+
const fieldTermFreqs = fieldTermData.get(fieldId);
|
|
248866
|
+
if (fieldTermFreqs == null)
|
|
248867
|
+
continue;
|
|
248868
|
+
let matchingFields = fieldTermFreqs.size;
|
|
248869
|
+
const avgFieldLength = this._avgFieldLength[fieldId];
|
|
248870
|
+
for (const docId of fieldTermFreqs.keys()) {
|
|
248871
|
+
if (!this._documentIds.has(docId)) {
|
|
248872
|
+
this.removeTerm(fieldId, docId, derivedTerm);
|
|
248873
|
+
matchingFields -= 1;
|
|
248874
|
+
continue;
|
|
248875
|
+
}
|
|
248876
|
+
const docBoost = boostDocumentFn ? boostDocumentFn(this._documentIds.get(docId), derivedTerm, this._storedFields.get(docId)) : 1;
|
|
248877
|
+
if (!docBoost)
|
|
248878
|
+
continue;
|
|
248879
|
+
const termFreq = fieldTermFreqs.get(docId);
|
|
248880
|
+
const fieldLength = this._fieldLength.get(docId)[fieldId];
|
|
248881
|
+
const rawScore = calcBM25Score(termFreq, matchingFields, this._documentCount, fieldLength, avgFieldLength, bm25params);
|
|
248882
|
+
const weightedScore = termWeight * termBoost * fieldBoost * docBoost * rawScore;
|
|
248883
|
+
const result = results.get(docId);
|
|
248884
|
+
if (result) {
|
|
248885
|
+
result.score += weightedScore;
|
|
248886
|
+
assignUniqueTerm(result.terms, sourceTerm);
|
|
248887
|
+
const match = getOwnProperty(result.match, derivedTerm);
|
|
248888
|
+
if (match) {
|
|
248889
|
+
match.push(field);
|
|
248890
|
+
} else {
|
|
248891
|
+
result.match[derivedTerm] = [field];
|
|
248892
|
+
}
|
|
248893
|
+
} else {
|
|
248894
|
+
results.set(docId, {
|
|
248895
|
+
score: weightedScore,
|
|
248896
|
+
terms: [sourceTerm],
|
|
248897
|
+
match: { [derivedTerm]: [field] }
|
|
248898
|
+
});
|
|
248899
|
+
}
|
|
248900
|
+
}
|
|
248901
|
+
}
|
|
248902
|
+
return results;
|
|
248903
|
+
}
|
|
248904
|
+
addTerm(fieldId, documentId, term) {
|
|
248905
|
+
const indexData = this._index.fetch(term, createMap);
|
|
248906
|
+
let fieldIndex = indexData.get(fieldId);
|
|
248907
|
+
if (fieldIndex == null) {
|
|
248908
|
+
fieldIndex = new Map;
|
|
248909
|
+
fieldIndex.set(documentId, 1);
|
|
248910
|
+
indexData.set(fieldId, fieldIndex);
|
|
248911
|
+
} else {
|
|
248912
|
+
const docs = fieldIndex.get(documentId);
|
|
248913
|
+
fieldIndex.set(documentId, (docs || 0) + 1);
|
|
248914
|
+
}
|
|
248915
|
+
}
|
|
248916
|
+
removeTerm(fieldId, documentId, term) {
|
|
248917
|
+
if (!this._index.has(term)) {
|
|
248918
|
+
this.warnDocumentChanged(documentId, fieldId, term);
|
|
248919
|
+
return;
|
|
248920
|
+
}
|
|
248921
|
+
const indexData = this._index.fetch(term, createMap);
|
|
248922
|
+
const fieldIndex = indexData.get(fieldId);
|
|
248923
|
+
if (fieldIndex == null || fieldIndex.get(documentId) == null) {
|
|
248924
|
+
this.warnDocumentChanged(documentId, fieldId, term);
|
|
248925
|
+
} else if (fieldIndex.get(documentId) <= 1) {
|
|
248926
|
+
if (fieldIndex.size <= 1) {
|
|
248927
|
+
indexData.delete(fieldId);
|
|
248928
|
+
} else {
|
|
248929
|
+
fieldIndex.delete(documentId);
|
|
248930
|
+
}
|
|
248931
|
+
} else {
|
|
248932
|
+
fieldIndex.set(documentId, fieldIndex.get(documentId) - 1);
|
|
248933
|
+
}
|
|
248934
|
+
if (this._index.get(term).size === 0) {
|
|
248935
|
+
this._index.delete(term);
|
|
248936
|
+
}
|
|
248937
|
+
}
|
|
248938
|
+
warnDocumentChanged(shortDocumentId, fieldId, term) {
|
|
248939
|
+
for (const fieldName of Object.keys(this._fieldIds)) {
|
|
248940
|
+
if (this._fieldIds[fieldName] === fieldId) {
|
|
248941
|
+
this._options.logger("warn", `MiniSearch: document with ID ${this._documentIds.get(shortDocumentId)} has changed before removal: term "${term}" was not present in field "${fieldName}". Removing a document after it has changed can corrupt the index!`, "version_conflict");
|
|
248942
|
+
return;
|
|
248943
|
+
}
|
|
248944
|
+
}
|
|
248945
|
+
}
|
|
248946
|
+
addDocumentId(documentId) {
|
|
248947
|
+
const shortDocumentId = this._nextId;
|
|
248948
|
+
this._idToShortId.set(documentId, shortDocumentId);
|
|
248949
|
+
this._documentIds.set(shortDocumentId, documentId);
|
|
248950
|
+
this._documentCount += 1;
|
|
248951
|
+
this._nextId += 1;
|
|
248952
|
+
return shortDocumentId;
|
|
248953
|
+
}
|
|
248954
|
+
addFields(fields) {
|
|
248955
|
+
for (let i = 0;i < fields.length; i++) {
|
|
248956
|
+
this._fieldIds[fields[i]] = i;
|
|
248957
|
+
}
|
|
248958
|
+
}
|
|
248959
|
+
addFieldLength(documentId, fieldId, count, length) {
|
|
248960
|
+
let fieldLengths = this._fieldLength.get(documentId);
|
|
248961
|
+
if (fieldLengths == null)
|
|
248962
|
+
this._fieldLength.set(documentId, fieldLengths = []);
|
|
248963
|
+
fieldLengths[fieldId] = length;
|
|
248964
|
+
const averageFieldLength = this._avgFieldLength[fieldId] || 0;
|
|
248965
|
+
const totalFieldLength = averageFieldLength * count + length;
|
|
248966
|
+
this._avgFieldLength[fieldId] = totalFieldLength / (count + 1);
|
|
248967
|
+
}
|
|
248968
|
+
removeFieldLength(documentId, fieldId, count, length) {
|
|
248969
|
+
if (count === 1) {
|
|
248970
|
+
this._avgFieldLength[fieldId] = 0;
|
|
248971
|
+
return;
|
|
248972
|
+
}
|
|
248973
|
+
const totalFieldLength = this._avgFieldLength[fieldId] * count - length;
|
|
248974
|
+
this._avgFieldLength[fieldId] = totalFieldLength / (count - 1);
|
|
248975
|
+
}
|
|
248976
|
+
saveStoredFields(documentId, doc) {
|
|
248977
|
+
const { storeFields, extractField } = this._options;
|
|
248978
|
+
if (storeFields == null || storeFields.length === 0) {
|
|
248979
|
+
return;
|
|
248980
|
+
}
|
|
248981
|
+
let documentFields = this._storedFields.get(documentId);
|
|
248982
|
+
if (documentFields == null)
|
|
248983
|
+
this._storedFields.set(documentId, documentFields = {});
|
|
248984
|
+
for (const fieldName of storeFields) {
|
|
248985
|
+
const fieldValue = extractField(doc, fieldName);
|
|
248986
|
+
if (fieldValue !== undefined)
|
|
248987
|
+
documentFields[fieldName] = fieldValue;
|
|
248988
|
+
}
|
|
248989
|
+
}
|
|
248990
|
+
}
|
|
248991
|
+
MiniSearch.wildcard = Symbol("*");
|
|
248992
|
+
var getOwnProperty = (object, property) => Object.prototype.hasOwnProperty.call(object, property) ? object[property] : undefined;
|
|
248993
|
+
var combinators = {
|
|
248994
|
+
[OR]: (a, b) => {
|
|
248995
|
+
for (const docId of b.keys()) {
|
|
248996
|
+
const existing = a.get(docId);
|
|
248997
|
+
if (existing == null) {
|
|
248998
|
+
a.set(docId, b.get(docId));
|
|
248999
|
+
} else {
|
|
249000
|
+
const { score, terms, match } = b.get(docId);
|
|
249001
|
+
existing.score = existing.score + score;
|
|
249002
|
+
existing.match = Object.assign(existing.match, match);
|
|
249003
|
+
assignUniqueTerms(existing.terms, terms);
|
|
249004
|
+
}
|
|
249005
|
+
}
|
|
249006
|
+
return a;
|
|
249007
|
+
},
|
|
249008
|
+
[AND]: (a, b) => {
|
|
249009
|
+
const combined = new Map;
|
|
249010
|
+
for (const docId of b.keys()) {
|
|
249011
|
+
const existing = a.get(docId);
|
|
249012
|
+
if (existing == null)
|
|
249013
|
+
continue;
|
|
249014
|
+
const { score, terms, match } = b.get(docId);
|
|
249015
|
+
assignUniqueTerms(existing.terms, terms);
|
|
249016
|
+
combined.set(docId, {
|
|
249017
|
+
score: existing.score + score,
|
|
249018
|
+
terms: existing.terms,
|
|
249019
|
+
match: Object.assign(existing.match, match)
|
|
249020
|
+
});
|
|
249021
|
+
}
|
|
249022
|
+
return combined;
|
|
249023
|
+
},
|
|
249024
|
+
[AND_NOT]: (a, b) => {
|
|
249025
|
+
for (const docId of b.keys())
|
|
249026
|
+
a.delete(docId);
|
|
249027
|
+
return a;
|
|
249028
|
+
}
|
|
249029
|
+
};
|
|
249030
|
+
var defaultBM25params = { k: 1.2, b: 0.7, d: 0.5 };
|
|
249031
|
+
var calcBM25Score = (termFreq, matchingCount, totalCount, fieldLength, avgFieldLength, bm25params) => {
|
|
249032
|
+
const { k, b, d } = bm25params;
|
|
249033
|
+
const invDocFreq = Math.log(1 + (totalCount - matchingCount + 0.5) / (matchingCount + 0.5));
|
|
249034
|
+
return invDocFreq * (d + termFreq * (k + 1) / (termFreq + k * (1 - b + b * fieldLength / avgFieldLength)));
|
|
249035
|
+
};
|
|
249036
|
+
var termToQuerySpec = (options) => (term, i, terms) => {
|
|
249037
|
+
const fuzzy = typeof options.fuzzy === "function" ? options.fuzzy(term, i, terms) : options.fuzzy || false;
|
|
249038
|
+
const prefix = typeof options.prefix === "function" ? options.prefix(term, i, terms) : options.prefix === true;
|
|
249039
|
+
const termBoost = typeof options.boostTerm === "function" ? options.boostTerm(term, i, terms) : 1;
|
|
249040
|
+
return { term, fuzzy, prefix, termBoost };
|
|
249041
|
+
};
|
|
249042
|
+
var defaultOptions = {
|
|
249043
|
+
idField: "id",
|
|
249044
|
+
extractField: (document2, fieldName) => document2[fieldName],
|
|
249045
|
+
tokenize: (text) => text.split(SPACE_OR_PUNCTUATION),
|
|
249046
|
+
processTerm: (term) => term.toLowerCase(),
|
|
249047
|
+
fields: undefined,
|
|
249048
|
+
searchOptions: undefined,
|
|
249049
|
+
storeFields: [],
|
|
249050
|
+
logger: (level, message) => {
|
|
249051
|
+
if (typeof (console === null || console === undefined ? undefined : console[level]) === "function")
|
|
249052
|
+
console[level](message);
|
|
249053
|
+
},
|
|
249054
|
+
autoVacuum: true
|
|
249055
|
+
};
|
|
249056
|
+
var defaultSearchOptions = {
|
|
249057
|
+
combineWith: OR,
|
|
249058
|
+
prefix: false,
|
|
249059
|
+
fuzzy: false,
|
|
249060
|
+
maxFuzzy: 6,
|
|
249061
|
+
boost: {},
|
|
249062
|
+
weights: { fuzzy: 0.45, prefix: 0.375 },
|
|
249063
|
+
bm25: defaultBM25params
|
|
249064
|
+
};
|
|
249065
|
+
var defaultAutoSuggestOptions = {
|
|
249066
|
+
combineWith: AND,
|
|
249067
|
+
prefix: (term, i, terms) => i === terms.length - 1
|
|
249068
|
+
};
|
|
249069
|
+
var defaultVacuumOptions = { batchSize: 1000, batchWait: 10 };
|
|
249070
|
+
var defaultVacuumConditions = { minDirtFactor: 0.1, minDirtCount: 20 };
|
|
249071
|
+
var defaultAutoVacuumOptions = { ...defaultVacuumOptions, ...defaultVacuumConditions };
|
|
249072
|
+
var assignUniqueTerm = (target, term) => {
|
|
249073
|
+
if (!target.includes(term))
|
|
249074
|
+
target.push(term);
|
|
249075
|
+
};
|
|
249076
|
+
var assignUniqueTerms = (target, source) => {
|
|
249077
|
+
for (const term of source) {
|
|
249078
|
+
if (!target.includes(term))
|
|
249079
|
+
target.push(term);
|
|
249080
|
+
}
|
|
249081
|
+
};
|
|
249082
|
+
var byScore = ({ score: a }, { score: b }) => b - a;
|
|
249083
|
+
var createMap = () => new Map;
|
|
249084
|
+
var objectToNumericMap = (object) => {
|
|
249085
|
+
const map = new Map;
|
|
249086
|
+
for (const key of Object.keys(object)) {
|
|
249087
|
+
map.set(parseInt(key, 10), object[key]);
|
|
249088
|
+
}
|
|
249089
|
+
return map;
|
|
249090
|
+
};
|
|
249091
|
+
var objectToNumericMapAsync = async (object) => {
|
|
249092
|
+
const map = new Map;
|
|
249093
|
+
let count = 0;
|
|
249094
|
+
for (const key of Object.keys(object)) {
|
|
249095
|
+
map.set(parseInt(key, 10), object[key]);
|
|
249096
|
+
if (++count % 1000 === 0) {
|
|
249097
|
+
await wait(0);
|
|
249098
|
+
}
|
|
249099
|
+
}
|
|
249100
|
+
return map;
|
|
249101
|
+
};
|
|
249102
|
+
var wait = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
249103
|
+
var SPACE_OR_PUNCTUATION = /[\n\r\p{Z}\p{P}]+/u;
|
|
249104
|
+
|
|
249105
|
+
// src/core/api-spec/search.ts
|
|
249106
|
+
var BOOST = {
|
|
249107
|
+
method: 1,
|
|
249108
|
+
path: 8,
|
|
249109
|
+
summary: 5,
|
|
249110
|
+
description: 2,
|
|
249111
|
+
parameters: 0.5
|
|
249112
|
+
};
|
|
249113
|
+
var MIN_RELATIVE_SCORE = 0.2;
|
|
249114
|
+
var TOKEN_SEPARATOR = /[\n\r\p{Z}\p{P}\p{S}]+/u;
|
|
249115
|
+
var STOPWORDS = new Set("a an and are at be by do does for from how i id in is it its me my of on or our that the this to we what who with you your".split(" "));
|
|
249116
|
+
function tokenize(text) {
|
|
249117
|
+
return text.split(TOKEN_SEPARATOR).filter((word) => word.length >= 2 && !STOPWORDS.has(word.toLowerCase()));
|
|
249118
|
+
}
|
|
249119
|
+
function toOperationSummary(op) {
|
|
249120
|
+
return { endpoint: op.endpoint, summary: op.summary };
|
|
249121
|
+
}
|
|
249122
|
+
function buildSearchIndex(operations) {
|
|
249123
|
+
const index = new MiniSearch({
|
|
249124
|
+
fields: ["method", "path", "summary", "description", "parameters"],
|
|
249125
|
+
tokenize
|
|
249126
|
+
});
|
|
249127
|
+
index.addAll(operations.map((op, id) => ({
|
|
249128
|
+
id,
|
|
249129
|
+
method: op.method,
|
|
249130
|
+
path: op.path.replace(/\{[^}]*\}/g, ""),
|
|
249131
|
+
summary: op.summary,
|
|
249132
|
+
description: op.description,
|
|
249133
|
+
parameters: op.parameterText
|
|
249134
|
+
})));
|
|
249135
|
+
return index;
|
|
249136
|
+
}
|
|
249137
|
+
function summaryMatch(terms, op) {
|
|
249138
|
+
const words = tokenize(op?.summary.toLowerCase() ?? "");
|
|
249139
|
+
const named = (word) => terms.some((term) => word.startsWith(term));
|
|
249140
|
+
return {
|
|
249141
|
+
coverage: terms.filter((term) => words.some((word) => word.startsWith(term))).length / terms.length,
|
|
249142
|
+
precision: words.length ? words.filter(named).length / words.length : 0
|
|
249143
|
+
};
|
|
249144
|
+
}
|
|
249145
|
+
var readsFirst = (op) => op?.method === "GET" ? 0 : 1;
|
|
249146
|
+
function searchOperations(operations, query, options = {}) {
|
|
249147
|
+
const terms = tokenize(query.toLowerCase());
|
|
249148
|
+
if (terms.length === 0) {
|
|
249149
|
+
return [];
|
|
249150
|
+
}
|
|
249151
|
+
const index = buildSearchIndex(operations);
|
|
249152
|
+
const hits = index.search(query, {
|
|
249153
|
+
prefix: (term) => term.length >= 3,
|
|
249154
|
+
fuzzy: (term) => term.length >= 4 ? 0.2 : false,
|
|
249155
|
+
boost: BOOST,
|
|
249156
|
+
filter: options.readOnly ? (hit) => operations[hit.id]?.readOnly === true : undefined
|
|
249157
|
+
}).map((hit) => {
|
|
249158
|
+
const match = summaryMatch(terms, operations[hit.id]);
|
|
249159
|
+
return {
|
|
249160
|
+
...hit,
|
|
249161
|
+
...match,
|
|
249162
|
+
full: match.coverage === 1,
|
|
249163
|
+
score: hit.score * (1 + match.coverage)
|
|
249164
|
+
};
|
|
249165
|
+
}).sort((a, b) => Number(b.full) - Number(a.full) || (a.full ? b.precision - a.precision || readsFirst(operations[a.id]) - readsFirst(operations[b.id]) : 0) || b.score - a.score);
|
|
249166
|
+
const baseline = Math.max(0, ...hits.map((hit) => hit.score)) * MIN_RELATIVE_SCORE;
|
|
249167
|
+
return hits.filter((hit) => hit.full || hit.score >= baseline).slice(0, options.limit ?? 5).flatMap((hit) => {
|
|
249168
|
+
const op = operations[hit.id];
|
|
249169
|
+
return op ? [toOperationSummary(op)] : [];
|
|
249170
|
+
});
|
|
249171
|
+
}
|
|
249172
|
+
|
|
249173
|
+
// src/core/api-spec/catalog.ts
|
|
249174
|
+
var INLINE_AREA_MAX = 2;
|
|
249175
|
+
var AREA_SAMPLE_MAX = 3;
|
|
249176
|
+
var AREA_OPERATIONS_MAX = 200;
|
|
249177
|
+
var byCodePoint = (a, b) => a < b ? -1 : a > b ? 1 : 0;
|
|
249178
|
+
function areaOf(path) {
|
|
249179
|
+
const parts = path.split("/").filter(Boolean);
|
|
249180
|
+
const appIdIndex = parts.indexOf("{app_id}");
|
|
249181
|
+
if (appIdIndex !== -1 && appIdIndex + 1 < parts.length) {
|
|
249182
|
+
return parts[appIdIndex + 1] ?? "other";
|
|
249183
|
+
}
|
|
249184
|
+
if (parts[0] === "api" && parts.length > 1) {
|
|
249185
|
+
return parts[1] ?? "other";
|
|
249186
|
+
}
|
|
249187
|
+
return parts[0] ?? "other";
|
|
249188
|
+
}
|
|
249189
|
+
function groupByArea(operations) {
|
|
249190
|
+
const sorted = [...operations].sort((a, b) => byCodePoint(`${a.method} ${a.path}`, `${b.method} ${b.path}`));
|
|
249191
|
+
const areas = new Map;
|
|
249192
|
+
for (const op of sorted) {
|
|
249193
|
+
const area = areaOf(op.path);
|
|
249194
|
+
areas.set(area, [...areas.get(area) ?? [], op]);
|
|
249195
|
+
}
|
|
249196
|
+
return new Map([...areas].sort(([a], [b]) => byCodePoint(a, b)));
|
|
249197
|
+
}
|
|
249198
|
+
function readsFirst2(ops) {
|
|
249199
|
+
const isRead = (op) => op.method === "GET" ? 0 : 1;
|
|
249200
|
+
return [...ops].sort((a, b) => isRead(a) - isRead(b));
|
|
249201
|
+
}
|
|
249202
|
+
function catalogIndex(operations) {
|
|
249203
|
+
const areas = [...groupByArea(operations)].map(([area, ops]) => ops.length <= INLINE_AREA_MAX ? { area, operations: ops.map(toOperationSummary) } : {
|
|
249204
|
+
area,
|
|
249205
|
+
operationCount: ops.length,
|
|
249206
|
+
sample: readsFirst2(ops).slice(0, AREA_SAMPLE_MAX).map((op) => op.summary)
|
|
249207
|
+
});
|
|
249208
|
+
return { areas, total: operations.length };
|
|
249209
|
+
}
|
|
249210
|
+
function areaListing(area, operations, max = AREA_OPERATIONS_MAX) {
|
|
249211
|
+
return {
|
|
249212
|
+
area,
|
|
249213
|
+
operations: operations.slice(0, max).map(toOperationSummary),
|
|
249214
|
+
total: operations.length,
|
|
249215
|
+
truncated: operations.length > max
|
|
249216
|
+
};
|
|
249217
|
+
}
|
|
249218
|
+
// src/core/api-spec/schema.ts
|
|
249219
|
+
var HTTP_METHODS = [
|
|
249220
|
+
"get",
|
|
249221
|
+
"put",
|
|
249222
|
+
"post",
|
|
249223
|
+
"delete",
|
|
249224
|
+
"patch",
|
|
249225
|
+
"head",
|
|
249226
|
+
"options",
|
|
249227
|
+
"trace"
|
|
249228
|
+
];
|
|
249229
|
+
var ParameterSchema = looseObject({
|
|
249230
|
+
name: string2(),
|
|
249231
|
+
in: string2(),
|
|
249232
|
+
required: boolean2().optional(),
|
|
249233
|
+
description: string2().optional(),
|
|
249234
|
+
schema: unknown().optional(),
|
|
249235
|
+
example: unknown().optional()
|
|
249236
|
+
});
|
|
249237
|
+
var MediaTypesSchema = record(string2(), looseObject({ schema: unknown().optional() }));
|
|
249238
|
+
var MediaContentSchema = looseObject({
|
|
249239
|
+
content: MediaTypesSchema.optional()
|
|
249240
|
+
});
|
|
249241
|
+
var ResponseObjectSchema = looseObject({
|
|
249242
|
+
description: string2().optional(),
|
|
249243
|
+
content: MediaTypesSchema.optional()
|
|
249244
|
+
});
|
|
249245
|
+
var SecurityRequirementSchema = record(string2(), array(string2()));
|
|
249246
|
+
var OperationSchema = looseObject({
|
|
249247
|
+
summary: string2().optional(),
|
|
249248
|
+
description: string2().optional(),
|
|
249249
|
+
operationId: string2().optional(),
|
|
249250
|
+
parameters: array(unknown()).optional(),
|
|
249251
|
+
requestBody: unknown().optional(),
|
|
249252
|
+
responses: record(string2(), unknown()).optional(),
|
|
249253
|
+
security: array(SecurityRequirementSchema).optional()
|
|
249254
|
+
});
|
|
249255
|
+
var OpenApiSpecSchema = looseObject({
|
|
249256
|
+
openapi: string2(),
|
|
249257
|
+
paths: record(string2(), record(string2(), unknown())),
|
|
249258
|
+
components: looseObject({
|
|
249259
|
+
schemas: record(string2(), unknown()).optional()
|
|
249260
|
+
}).optional(),
|
|
249261
|
+
security: array(SecurityRequirementSchema).optional().catch(undefined)
|
|
249262
|
+
});
|
|
249263
|
+
var ParameterListSchema = array(unknown());
|
|
249264
|
+
|
|
249265
|
+
// src/core/api-spec/text.ts
|
|
249266
|
+
var DOCS_CALLOUT = /<(Info|Note|Tip|Check|Warning)>([\s\S]*?)<\/\1>/g;
|
|
249267
|
+
var RELATIVE_LINK = /\[([^\]]+)\]\(\/[^)]*\)/g;
|
|
249268
|
+
function cleanText(text) {
|
|
249269
|
+
return text.replace(DOCS_CALLOUT, (_, kind, body) => kind === "Warning" ? `Warning: ${body}` : body).replace(RELATIVE_LINK, "$1");
|
|
249270
|
+
}
|
|
249271
|
+
|
|
249272
|
+
// src/core/api-spec/operations.ts
|
|
249273
|
+
var PERSONAL_ACCESS_TOKEN_SCHEME = "PersonalAccessTokenAuth";
|
|
249274
|
+
var READ_ONLY_SCOPE = "read_only";
|
|
249275
|
+
function isReadOnly(operation, spec) {
|
|
249276
|
+
const security = operation.security ?? spec.security ?? [];
|
|
249277
|
+
return security.some((requirement) => requirement[PERSONAL_ACCESS_TOKEN_SCHEME]?.includes(READ_ONLY_SCOPE));
|
|
249278
|
+
}
|
|
249279
|
+
function parameterText(operation) {
|
|
249280
|
+
return (operation.parameters ?? []).flatMap((parameter) => {
|
|
249281
|
+
const parsed = ParameterSchema.safeParse(parameter);
|
|
249282
|
+
return parsed.success ? [parsed.data.name, cleanText(parsed.data.description ?? "")] : [];
|
|
249283
|
+
}).join(" ");
|
|
249284
|
+
}
|
|
249285
|
+
var COMPONENT_REF = /^#\/components\/([^/]+)\/([^/]+)$/;
|
|
249286
|
+
function resolveComponentRef(spec, value) {
|
|
249287
|
+
const ref = value !== null && typeof value === "object" ? value.$ref : undefined;
|
|
249288
|
+
const match = typeof ref === "string" ? COMPONENT_REF.exec(ref) : null;
|
|
249289
|
+
if (!match?.[1] || !match[2]) {
|
|
249290
|
+
return value;
|
|
249291
|
+
}
|
|
249292
|
+
const components = spec.components;
|
|
249293
|
+
return components?.[match[1]]?.[match[2]] ?? value;
|
|
249294
|
+
}
|
|
249295
|
+
function mergeParameters(shared, own) {
|
|
249296
|
+
if (!shared?.length) {
|
|
249297
|
+
return own;
|
|
249298
|
+
}
|
|
249299
|
+
const key = (parameter) => {
|
|
249300
|
+
const parsed = ParameterSchema.safeParse(parameter);
|
|
249301
|
+
return parsed.success ? `${parsed.data.in}:${parsed.data.name}` : undefined;
|
|
249302
|
+
};
|
|
249303
|
+
const ownKeys = new Set((own ?? []).map(key));
|
|
249304
|
+
return [
|
|
249305
|
+
...shared.filter((parameter) => !ownKeys.has(key(parameter))),
|
|
249306
|
+
...own ?? []
|
|
249307
|
+
];
|
|
249308
|
+
}
|
|
249309
|
+
function listOperations(spec) {
|
|
249310
|
+
return Object.entries(spec.paths).flatMap(([path, item]) => HTTP_METHODS.flatMap((method) => {
|
|
249311
|
+
const parsed = OperationSchema.safeParse(item[method]);
|
|
249312
|
+
if (!parsed.success) {
|
|
249313
|
+
return [];
|
|
249314
|
+
}
|
|
249315
|
+
const shared = ParameterListSchema.safeParse(item.parameters);
|
|
249316
|
+
const resolve = (list) => list?.map((parameter) => resolveComponentRef(spec, parameter));
|
|
249317
|
+
const operation = {
|
|
249318
|
+
...parsed.data,
|
|
249319
|
+
parameters: mergeParameters(resolve(shared.success ? shared.data : undefined), resolve(parsed.data.parameters))
|
|
249320
|
+
};
|
|
249321
|
+
return [
|
|
249322
|
+
{
|
|
249323
|
+
endpoint: `${method.toUpperCase()} ${path}`,
|
|
249324
|
+
method: method.toUpperCase(),
|
|
249325
|
+
path,
|
|
249326
|
+
summary: operation.summary ?? "",
|
|
249327
|
+
description: cleanText(operation.description ?? ""),
|
|
249328
|
+
parameterText: parameterText(operation),
|
|
249329
|
+
readOnly: isReadOnly(operation, spec),
|
|
249330
|
+
operation
|
|
249331
|
+
}
|
|
249332
|
+
];
|
|
249333
|
+
}));
|
|
249334
|
+
}
|
|
249335
|
+
function pathSegments(path) {
|
|
249336
|
+
const pathname = path.split(/[?#]/, 1)[0] ?? "";
|
|
249337
|
+
return pathname.replace(/^\/+|\/+$/g, "").split("/");
|
|
249338
|
+
}
|
|
249339
|
+
function segmentPattern(segment) {
|
|
249340
|
+
const source = segment.split(/(\{[^}]+\})/).map((part) => part.startsWith("{") ? "[^/]+" : part.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")).join("");
|
|
249341
|
+
return new RegExp(`^${source}$`);
|
|
249342
|
+
}
|
|
249343
|
+
function literalSegments(path) {
|
|
249344
|
+
return pathSegments(path).map((segment) => segment.includes("{") ? "0" : "1").join("");
|
|
249345
|
+
}
|
|
249346
|
+
function matchOperation(operations, method, concretePath) {
|
|
249347
|
+
const upperMethod = method.toUpperCase();
|
|
249348
|
+
const segments = pathSegments(concretePath);
|
|
249349
|
+
const candidates = operations.filter((op) => {
|
|
249350
|
+
if (op.method !== upperMethod) {
|
|
249351
|
+
return false;
|
|
249352
|
+
}
|
|
249353
|
+
const template = pathSegments(op.path);
|
|
249354
|
+
return template.length === segments.length && template.every((part, i) => segmentPattern(part).test(segments[i] ?? ""));
|
|
249355
|
+
});
|
|
249356
|
+
return candidates.sort((a, b) => literalSegments(b.path).localeCompare(literalSegments(a.path)))[0];
|
|
249357
|
+
}
|
|
249358
|
+
|
|
249359
|
+
// src/core/api-spec/contract.ts
|
|
249360
|
+
var SCHEMA_REF_PREFIX = "#/components/schemas/";
|
|
249361
|
+
var MAX_REF_DEPTH = 4;
|
|
249362
|
+
function inlineRefs(node, schemas, seen = new Set, depth = 0) {
|
|
249363
|
+
if (depth > MAX_REF_DEPTH) {
|
|
249364
|
+
return node;
|
|
249365
|
+
}
|
|
249366
|
+
if (Array.isArray(node)) {
|
|
249367
|
+
return node.map((item) => inlineRefs(item, schemas, seen, depth));
|
|
249368
|
+
}
|
|
249369
|
+
if (node === null || typeof node !== "object") {
|
|
249370
|
+
return node;
|
|
249371
|
+
}
|
|
249372
|
+
const { $ref, ...siblings } = node;
|
|
249373
|
+
if (typeof $ref === "string" && $ref.startsWith(SCHEMA_REF_PREFIX)) {
|
|
249374
|
+
const name = $ref.slice(SCHEMA_REF_PREFIX.length);
|
|
249375
|
+
if (seen.has(name) || !(name in schemas)) {
|
|
249376
|
+
return node;
|
|
249377
|
+
}
|
|
249378
|
+
const resolved = inlineRefs(schemas[name], schemas, new Set([...seen, name]), depth + 1);
|
|
249379
|
+
return resolved !== null && typeof resolved === "object" ? { ...resolved, ...siblings } : resolved;
|
|
249380
|
+
}
|
|
249381
|
+
return Object.fromEntries(Object.entries(node).map(([key, value]) => [
|
|
249382
|
+
key,
|
|
249383
|
+
inlineRefs(value, schemas, seen, depth)
|
|
249384
|
+
]));
|
|
249385
|
+
}
|
|
249386
|
+
function bodyOf(value) {
|
|
249387
|
+
const parsed = MediaContentSchema.safeParse(value);
|
|
249388
|
+
const content = parsed.success ? parsed.data.content ?? {} : {};
|
|
249389
|
+
const contentType = "application/json" in content ? "application/json" : Object.keys(content)[0];
|
|
249390
|
+
return contentType ? { contentType, schema: content[contentType]?.schema } : {};
|
|
249391
|
+
}
|
|
249392
|
+
function leftoverRefs(node, schemas, found = new Map) {
|
|
249393
|
+
if (Array.isArray(node)) {
|
|
249394
|
+
for (const item of node) {
|
|
249395
|
+
leftoverRefs(item, schemas, found);
|
|
249396
|
+
}
|
|
249397
|
+
} else if (node !== null && typeof node === "object") {
|
|
249398
|
+
for (const [key, value] of Object.entries(node)) {
|
|
249399
|
+
if (key === "$ref" && typeof value === "string" && value.startsWith(SCHEMA_REF_PREFIX) && !found.has(value)) {
|
|
249400
|
+
const schema = schemas[value.slice(SCHEMA_REF_PREFIX.length)];
|
|
249401
|
+
if (schema !== undefined) {
|
|
249402
|
+
found.set(value, schema);
|
|
249403
|
+
leftoverRefs(schema, schemas, found);
|
|
249404
|
+
}
|
|
249405
|
+
} else {
|
|
249406
|
+
leftoverRefs(value, schemas, found);
|
|
249407
|
+
}
|
|
249408
|
+
}
|
|
249409
|
+
}
|
|
249410
|
+
return found;
|
|
249411
|
+
}
|
|
249412
|
+
var SCHEMA_DATA_KEYS = new Set([
|
|
249413
|
+
"example",
|
|
249414
|
+
"examples",
|
|
249415
|
+
"default",
|
|
249416
|
+
"enum",
|
|
249417
|
+
"const"
|
|
249418
|
+
]);
|
|
249419
|
+
function slimSchema(node, isPropertyMap = false) {
|
|
249420
|
+
if (Array.isArray(node)) {
|
|
249421
|
+
return node.map((item) => slimSchema(item));
|
|
249422
|
+
}
|
|
249423
|
+
if (node === null || typeof node !== "object") {
|
|
249424
|
+
return node;
|
|
249425
|
+
}
|
|
249426
|
+
const entries = Object.entries(node);
|
|
249427
|
+
if (isPropertyMap) {
|
|
249428
|
+
return Object.fromEntries(entries.map(([name, value]) => [name, slimSchema(value)]));
|
|
249429
|
+
}
|
|
249430
|
+
const slim = {};
|
|
249431
|
+
for (const [key, value] of entries) {
|
|
249432
|
+
if (key === "title" && typeof value === "string") {
|
|
249433
|
+
continue;
|
|
249434
|
+
}
|
|
249435
|
+
slim[key] = SCHEMA_DATA_KEYS.has(key) ? value : key === "properties" ? slimSchema(value, true) : key === "description" && typeof value === "string" ? cleanText(value) : slimSchema(value);
|
|
249436
|
+
}
|
|
249437
|
+
const { anyOf, ...rest } = slim;
|
|
249438
|
+
const nullable = Array.isArray(anyOf) && anyOf.length === 2 ? nullableType(anyOf) : undefined;
|
|
249439
|
+
return nullable ? { type: [nullable, "null"], ...rest } : slim;
|
|
249440
|
+
}
|
|
249441
|
+
function nullableType(variants) {
|
|
249442
|
+
const types = variants.map((variant) => variant !== null && typeof variant === "object" && Object.keys(variant).length === 1 && typeof variant.type === "string" ? variant.type : undefined);
|
|
249443
|
+
if (types.includes(undefined) || !types.includes("null")) {
|
|
249444
|
+
return;
|
|
249445
|
+
}
|
|
249446
|
+
return types.find((type) => type !== "null");
|
|
249447
|
+
}
|
|
249448
|
+
function getOperationContract(spec, op) {
|
|
249449
|
+
const schemas = spec.components?.schemas ?? {};
|
|
249450
|
+
const inline = (node) => node === undefined ? null : slimSchema(inlineRefs(node, schemas));
|
|
249451
|
+
const responses = Object.entries(op.operation.responses ?? {}).flatMap(([status, response]) => {
|
|
249452
|
+
const parsed = ResponseObjectSchema.safeParse(resolveComponentRef(spec, response));
|
|
249453
|
+
return parsed.success ? [[status, parsed.data]] : [];
|
|
249454
|
+
});
|
|
249455
|
+
const success = responses.filter(([status]) => status.startsWith("2")).sort(([a], [b]) => a.localeCompare(b)).map(([, response]) => bodyOf(response).schema).find(Boolean);
|
|
249456
|
+
const requestBody = bodyOf(resolveComponentRef(spec, op.operation.requestBody));
|
|
249457
|
+
const contract = {
|
|
249458
|
+
endpoint: op.endpoint,
|
|
249459
|
+
method: op.method,
|
|
249460
|
+
path: op.path,
|
|
249461
|
+
summary: op.summary,
|
|
249462
|
+
description: op.description,
|
|
249463
|
+
parameters: (op.operation.parameters ?? []).flatMap((parameter) => {
|
|
249464
|
+
const parsed = ParameterSchema.safeParse(parameter);
|
|
249465
|
+
if (!parsed.success) {
|
|
249466
|
+
return [parameter];
|
|
249467
|
+
}
|
|
249468
|
+
const { name, in: location2, required, schema, description } = parsed.data;
|
|
249469
|
+
const inSchema = schema !== null && typeof schema === "object" && "description" in schema;
|
|
249470
|
+
return [
|
|
249471
|
+
{
|
|
249472
|
+
name,
|
|
249473
|
+
in: location2,
|
|
249474
|
+
required: required ?? false,
|
|
249475
|
+
schema: inline(schema ?? {}),
|
|
249476
|
+
...description && !inSchema ? { description: cleanText(description) } : {},
|
|
249477
|
+
..."example" in parsed.data ? { example: parsed.data.example } : {}
|
|
249478
|
+
}
|
|
249479
|
+
];
|
|
249480
|
+
}),
|
|
249481
|
+
...requestBody.contentType && requestBody.contentType !== "application/json" ? { requestBodyContentType: requestBody.contentType } : {},
|
|
249482
|
+
requestBodySchema: inline(requestBody.schema),
|
|
249483
|
+
responseSchema: inline(success)
|
|
249484
|
+
};
|
|
249485
|
+
const refs = leftoverRefs(contract, schemas);
|
|
249486
|
+
return {
|
|
249487
|
+
...contract,
|
|
249488
|
+
...refs.size > 0 ? {
|
|
249489
|
+
refs: Object.fromEntries([...refs].map(([ref, schema]) => [ref, slimSchema(schema)]))
|
|
249490
|
+
} : {}
|
|
249491
|
+
};
|
|
249492
|
+
}
|
|
249493
|
+
// src/core/api-spec/grep.ts
|
|
249494
|
+
function grepOperations(spec, operations, pattern, options = {}) {
|
|
249495
|
+
const regex = new RegExp(pattern, options.ignoreCase ? "i" : "");
|
|
249496
|
+
return operations.filter((op) => regex.test(JSON.stringify(getOperationContract(spec, op)))).slice(0, options.limit ?? 20).map(toOperationSummary);
|
|
249497
|
+
}
|
|
249498
|
+
// src/core/api-spec/request.ts
|
|
249499
|
+
var MAX_ERROR_BODY_CHARS = 4000;
|
|
249500
|
+
var QUERY_STRING = /\?\S*/g;
|
|
249501
|
+
async function readBody(response) {
|
|
249502
|
+
try {
|
|
249503
|
+
const text = (await response.clone().text()).trim();
|
|
249504
|
+
return text.length > MAX_ERROR_BODY_CHARS ? `${text.slice(0, MAX_ERROR_BODY_CHARS)}…` : text || undefined;
|
|
249505
|
+
} catch {
|
|
249506
|
+
return;
|
|
249507
|
+
}
|
|
249508
|
+
}
|
|
249509
|
+
function normalizePath(path) {
|
|
249510
|
+
const url = new URL(path.replace(/^\/*/, "/"), "http://placeholder");
|
|
249511
|
+
return `${url.pathname}${url.search}`;
|
|
249512
|
+
}
|
|
249513
|
+
async function sendApiRequest(method, path, body) {
|
|
249514
|
+
try {
|
|
249515
|
+
const response = await base44Client(path.replace(/^\/+/, ""), {
|
|
249516
|
+
method,
|
|
249517
|
+
body,
|
|
249518
|
+
headers: typeof body === "string" ? { "Content-Type": "application/json" } : {},
|
|
249519
|
+
timeout: false,
|
|
249520
|
+
retry: { methods: ["get", "head"] }
|
|
249521
|
+
});
|
|
249522
|
+
return {
|
|
249523
|
+
status: response.status,
|
|
249524
|
+
contentType: response.headers.get("content-type") ?? "",
|
|
249525
|
+
body: new Uint8Array(await response.arrayBuffer())
|
|
249526
|
+
};
|
|
249527
|
+
} catch (error) {
|
|
249528
|
+
const apiError = await ApiError.fromHttpError(error, `calling ${method} ${path}`);
|
|
249529
|
+
const response = error instanceof HTTPError ? error.response : undefined;
|
|
249530
|
+
const raw = response ? await readBody(response) : undefined;
|
|
249531
|
+
const retryAfter = response?.headers.get("retry-after") ?? undefined;
|
|
249532
|
+
throw redactedApiError(apiError, raw, method, path, retryAfter);
|
|
249533
|
+
}
|
|
249534
|
+
}
|
|
249535
|
+
function redactedApiError(apiError, raw, method, path, retryAfter) {
|
|
249536
|
+
const wait = retryAfter ? ` (retry after ${/^\d+$/.test(retryAfter) ? `${retryAfter} s` : retryAfter})` : "";
|
|
249537
|
+
const reason = apiError.statusCode !== undefined ? `HTTP ${apiError.statusCode}${wait}` : (apiError.cause?.message ?? "request failed").replace(QUERY_STRING, "");
|
|
249538
|
+
const message = `Error calling ${method} ${path.split("?", 1)[0]}: ${reason}`;
|
|
249539
|
+
return new ApiError(message, {
|
|
249540
|
+
statusCode: apiError.statusCode,
|
|
249541
|
+
requestUrl: apiError.requestUrl?.split("?", 1)[0],
|
|
249542
|
+
requestMethod: apiError.requestMethod,
|
|
249543
|
+
requestId: apiError.requestId,
|
|
249544
|
+
hints: apiError.hints,
|
|
249545
|
+
details: [
|
|
249546
|
+
...raw ? [`Response body: ${raw}`] : apiError.details ?? [],
|
|
249547
|
+
...apiError.requestId ? [`Request ID: ${apiError.requestId}`] : []
|
|
249548
|
+
]
|
|
249549
|
+
});
|
|
249550
|
+
}
|
|
249551
|
+
// src/core/api-spec/spec.ts
|
|
249552
|
+
import { rename, rm, stat as stat3 } from "node:fs/promises";
|
|
249553
|
+
import { join as join22 } from "node:path";
|
|
249554
|
+
var SPEC_CACHE_TTL_MS = 60 * 60 * 1000;
|
|
249555
|
+
function getSpecCachePath(apiUrl = getBase44ApiUrl()) {
|
|
249556
|
+
const server = new URL(apiUrl).host.replace(/[^a-zA-Z0-9.-]/g, "_");
|
|
249557
|
+
return join22(getBase44GlobalDir(), "cache", server, "openapi.json");
|
|
249558
|
+
}
|
|
249559
|
+
function isSpecCacheFresh(mtimeMs, now = Date.now()) {
|
|
249560
|
+
return now - mtimeMs < SPEC_CACHE_TTL_MS;
|
|
249561
|
+
}
|
|
249562
|
+
function parseSpec(text) {
|
|
249563
|
+
let json;
|
|
249564
|
+
try {
|
|
249565
|
+
json = JSON.parse(text);
|
|
249566
|
+
} catch {
|
|
249567
|
+
throw new ApiError("The API spec from the server is not valid JSON");
|
|
249568
|
+
}
|
|
249569
|
+
const result = OpenApiSpecSchema.safeParse(json);
|
|
249570
|
+
if (!result.success) {
|
|
249571
|
+
throw new SchemaValidationError("Invalid API spec", result.error);
|
|
249572
|
+
}
|
|
249573
|
+
return result.data;
|
|
249574
|
+
}
|
|
249575
|
+
var SPEC_DOWNLOAD_TIMEOUT_MS = 60000;
|
|
249576
|
+
async function readFreshCache(path) {
|
|
249577
|
+
try {
|
|
249578
|
+
const { mtimeMs } = await stat3(path);
|
|
249579
|
+
if (!isSpecCacheFresh(mtimeMs)) {
|
|
249580
|
+
return null;
|
|
249581
|
+
}
|
|
249582
|
+
const text = await readTextFile(path);
|
|
249583
|
+
return { text, spec: parseSpec(text) };
|
|
249584
|
+
} catch {
|
|
249585
|
+
return null;
|
|
249586
|
+
}
|
|
249587
|
+
}
|
|
249588
|
+
async function downloadSpec() {
|
|
249589
|
+
try {
|
|
249590
|
+
const response = await base44Client.get("api/openapi.json", {
|
|
249591
|
+
timeout: SPEC_DOWNLOAD_TIMEOUT_MS
|
|
249592
|
+
});
|
|
249593
|
+
return await response.text();
|
|
249594
|
+
} catch (error) {
|
|
249595
|
+
throw await ApiError.fromHttpError(error, "fetching the API spec");
|
|
249596
|
+
}
|
|
249597
|
+
}
|
|
249598
|
+
async function loadSpec(options = {}) {
|
|
249599
|
+
const path = getSpecCachePath();
|
|
249600
|
+
const cached = options.refresh ? null : await readFreshCache(path);
|
|
249601
|
+
if (cached !== null) {
|
|
249602
|
+
return cached;
|
|
249603
|
+
}
|
|
249604
|
+
const text = await downloadSpec();
|
|
249605
|
+
const spec = parseSpec(text);
|
|
249606
|
+
const partial = `${path}.${process.pid}.tmp`;
|
|
249607
|
+
try {
|
|
249608
|
+
await writeFile(partial, text);
|
|
249609
|
+
await rename(partial, path);
|
|
249610
|
+
} catch {
|
|
249611
|
+
await rm(partial, { force: true }).catch(() => {
|
|
249612
|
+
return;
|
|
249613
|
+
});
|
|
249614
|
+
}
|
|
249615
|
+
return { text, spec };
|
|
249616
|
+
}
|
|
249617
|
+
// src/cli/commands/api/shared.ts
|
|
249618
|
+
import { basename as basename6 } from "node:path";
|
|
249619
|
+
function formatJson(value) {
|
|
249620
|
+
return toJsonStdout(value, { compact: !process.stdout.isTTY });
|
|
249621
|
+
}
|
|
249622
|
+
function parseLimit(value) {
|
|
249623
|
+
if (value === undefined) {
|
|
249624
|
+
return;
|
|
249625
|
+
}
|
|
249626
|
+
const n = Number.parseInt(value, 10);
|
|
249627
|
+
if (!Number.isInteger(n) || n < 1) {
|
|
249628
|
+
throw new InvalidInputError("--limit must be a positive integer.");
|
|
249629
|
+
}
|
|
249630
|
+
return n;
|
|
249631
|
+
}
|
|
249632
|
+
var READ_ONLY_FILTER_HELP = "Only read-only operations";
|
|
249633
|
+
var REFRESH_OPTION_HELP = "Fetch the API spec again instead of using the cached copy (kept 1 hour)";
|
|
249634
|
+
function loadSpecTask({ runTask }, refresh) {
|
|
249635
|
+
return runTask("Loading the API spec", () => loadSpec({ refresh }), {
|
|
249636
|
+
successMessage: "Loaded the API spec"
|
|
249637
|
+
});
|
|
249638
|
+
}
|
|
249639
|
+
function operationsInArea(operations, area) {
|
|
249640
|
+
const areas = groupByArea(operations);
|
|
249641
|
+
const inArea = areas.get(area);
|
|
249642
|
+
if (!inArea) {
|
|
249643
|
+
throw new InvalidInputError(`Unknown API area: ${area}`, {
|
|
249644
|
+
details: [`Areas: ${[...areas.keys()].join(", ")}`],
|
|
249645
|
+
hints: [{ message: "List the areas", command: "base44 api catalog" }]
|
|
249646
|
+
});
|
|
249647
|
+
}
|
|
249648
|
+
return inArea;
|
|
249649
|
+
}
|
|
249650
|
+
async function readRequestBody(flag) {
|
|
249651
|
+
if (flag === "@-") {
|
|
249652
|
+
return readStdin("--body @-", { trim: false });
|
|
249653
|
+
}
|
|
249654
|
+
if (flag?.startsWith("@")) {
|
|
249655
|
+
return readTextFile(flag.slice(1));
|
|
249656
|
+
}
|
|
249657
|
+
return flag;
|
|
249658
|
+
}
|
|
249659
|
+
var FORM_FILE = /^@(.+?)(?:;type=([^;]+))?$/;
|
|
249660
|
+
async function readFormBody(fields) {
|
|
249661
|
+
const form = new FormData;
|
|
249662
|
+
for (const field of fields) {
|
|
249663
|
+
const separator = field.indexOf("=");
|
|
249664
|
+
if (separator < 1) {
|
|
249665
|
+
throw new InvalidInputError(`--form takes name=value or name=@file, got "${field}".`);
|
|
249666
|
+
}
|
|
249667
|
+
const name = field.slice(0, separator);
|
|
249668
|
+
const value = field.slice(separator + 1);
|
|
249669
|
+
const file = FORM_FILE.exec(value);
|
|
249670
|
+
if (file?.[1]) {
|
|
249671
|
+
const type = file[2] ?? "application/octet-stream";
|
|
249672
|
+
const blob = new Blob([await readFile(file[1])], { type });
|
|
249673
|
+
form.append(name, blob, basename6(file[1]));
|
|
249674
|
+
} else {
|
|
249675
|
+
form.append(name, value);
|
|
249676
|
+
}
|
|
249677
|
+
}
|
|
249678
|
+
return form;
|
|
249679
|
+
}
|
|
249680
|
+
function withoutQuery(path) {
|
|
249681
|
+
return path.split("?", 1)[0] ?? "";
|
|
249682
|
+
}
|
|
249683
|
+
function reportedFetchCommand(method, path, options) {
|
|
249684
|
+
return {
|
|
249685
|
+
name: "api fetch",
|
|
249686
|
+
args: [method, withoutQuery(path)],
|
|
249687
|
+
options: {
|
|
249688
|
+
...options,
|
|
249689
|
+
...options.body === undefined ? {} : { body: "[not reported]" },
|
|
249690
|
+
...Array.isArray(options.form) && options.form.length > 0 ? { form: "[not reported]" } : {}
|
|
249691
|
+
}
|
|
249692
|
+
};
|
|
249693
|
+
}
|
|
249694
|
+
|
|
249695
|
+
// src/cli/commands/api/catalog.ts
|
|
249696
|
+
async function catalogAction(ctx, area, options) {
|
|
249697
|
+
const { spec } = await loadSpecTask(ctx, options.refresh);
|
|
249698
|
+
const operations = listOperations(spec);
|
|
249699
|
+
const filterReadOnly = (ops) => options.readOnly ? ops.filter((op) => op.readOnly) : ops;
|
|
249700
|
+
if (!area) {
|
|
249701
|
+
return { stdout: formatJson(catalogIndex(filterReadOnly(operations))) };
|
|
249702
|
+
}
|
|
249703
|
+
const inArea = filterReadOnly(operationsInArea(operations, area));
|
|
249704
|
+
return { stdout: formatJson(areaListing(area, inArea)) };
|
|
249705
|
+
}
|
|
249706
|
+
function getApiCatalogCommand() {
|
|
249707
|
+
return new Base44Command("catalog", {
|
|
249708
|
+
requireAuth: false,
|
|
249709
|
+
requireAppContext: false
|
|
249710
|
+
}).description("List the API's areas, or every operation in one area").argument("[area]", 'An area from the list, e.g. "workflows"').option("--read-only", READ_ONLY_FILTER_HELP).option("--refresh", REFRESH_OPTION_HELP).action(catalogAction);
|
|
249711
|
+
}
|
|
249712
|
+
|
|
249713
|
+
// src/cli/commands/api/fetch.ts
|
|
249714
|
+
async function findOperation(ctx, method, path, { refresh, flag }) {
|
|
249715
|
+
const { spec } = await loadSpecTask(ctx, refresh);
|
|
249716
|
+
const op = matchOperation(listOperations(spec), method, path);
|
|
249717
|
+
if (!op) {
|
|
249718
|
+
throw new InvalidInputError(`No operation in the API spec matches ${method} ${withoutQuery(path)}.`, {
|
|
249719
|
+
hints: [
|
|
249720
|
+
{
|
|
249721
|
+
message: "The cached spec may predate this route; fetch it again",
|
|
249722
|
+
command: `base44 api fetch ${method} ${path} ${flag} --refresh`
|
|
249723
|
+
},
|
|
249724
|
+
{
|
|
249725
|
+
message: "Find the operation and its path template",
|
|
249726
|
+
command: 'base44 api search "<what you want to do>"'
|
|
249727
|
+
}
|
|
249728
|
+
]
|
|
249729
|
+
});
|
|
249730
|
+
}
|
|
249731
|
+
return { spec, op };
|
|
249732
|
+
}
|
|
249733
|
+
var ENCODED_SEPARATOR = /%(2f|5c|2e)/i;
|
|
249734
|
+
async function fillAppId(ctx, path, command) {
|
|
249735
|
+
let filled = path;
|
|
249736
|
+
if (withoutQuery(path).includes("{app_id}")) {
|
|
249737
|
+
const { appId } = command.optsWithGlobals();
|
|
249738
|
+
await ensureAppContext(ctx, { appId });
|
|
249739
|
+
filled = path.replaceAll("{app_id}", requireApp(ctx).id);
|
|
249740
|
+
}
|
|
249741
|
+
const placeholder = withoutQuery(filled).match(/\{[^}/]*\}/);
|
|
249742
|
+
if (placeholder) {
|
|
249743
|
+
throw new InvalidInputError(`Replace ${placeholder[0]} in the path with a real value; only {app_id} is filled in.`);
|
|
249744
|
+
}
|
|
249745
|
+
return filled;
|
|
249746
|
+
}
|
|
249747
|
+
var MULTIPART_HINT = "Send this body with --form name=value, and --form name=@path for files.";
|
|
249748
|
+
var CONTRACT_HELP = "The contract is JSON; cut it down with e.g. | jq '.parameters, .requestBodySchema'";
|
|
249749
|
+
var TEXT_CONTENT_TYPES = [
|
|
249750
|
+
"json",
|
|
249751
|
+
"text/",
|
|
249752
|
+
"xml",
|
|
249753
|
+
"javascript",
|
|
249754
|
+
"x-www-form-urlencoded"
|
|
249755
|
+
];
|
|
249756
|
+
function decodeText(body, contentType) {
|
|
249757
|
+
const type = contentType.toLowerCase();
|
|
249758
|
+
if (type && !TEXT_CONTENT_TYPES.some((hint) => type.includes(hint))) {
|
|
249759
|
+
return;
|
|
249760
|
+
}
|
|
249761
|
+
try {
|
|
249762
|
+
return new TextDecoder("utf-8", { fatal: true }).decode(body);
|
|
249763
|
+
} catch {
|
|
249764
|
+
return;
|
|
249765
|
+
}
|
|
249766
|
+
}
|
|
249767
|
+
async function formatResponse({ status, contentType, body }, output, jsonMode) {
|
|
249768
|
+
if (output) {
|
|
249769
|
+
await writeFile(output, body);
|
|
249770
|
+
return formatJson({ status, contentType, bytes: body.length, output });
|
|
249771
|
+
}
|
|
249772
|
+
if (body.length === 0) {
|
|
249773
|
+
return formatJson({ status });
|
|
249774
|
+
}
|
|
249775
|
+
const text = decodeText(body, contentType);
|
|
249776
|
+
if (text === undefined) {
|
|
249777
|
+
return formatJson({
|
|
249778
|
+
status,
|
|
249779
|
+
contentType,
|
|
249780
|
+
bytes: body.length,
|
|
249781
|
+
note: "Binary body not printed; add --output <file> to save it."
|
|
249782
|
+
});
|
|
249783
|
+
}
|
|
249784
|
+
const asIs = text.endsWith(`
|
|
249785
|
+
`) ? text : `${text}
|
|
249786
|
+
`;
|
|
249787
|
+
try {
|
|
249788
|
+
const parsed = JSON.parse(text);
|
|
249789
|
+
return process.stdout.isTTY ? formatJson(parsed) : asIs;
|
|
249790
|
+
} catch {
|
|
249791
|
+
return jsonMode ? formatJson({ status, contentType, body: text }) : asIs;
|
|
249792
|
+
}
|
|
249793
|
+
}
|
|
249794
|
+
async function fetchAction(ctx, methodArg, path, options, command) {
|
|
249795
|
+
ctx.errorReporter.setContext({
|
|
249796
|
+
command: reportedFetchCommand(methodArg ?? "", path ?? "", { ...options })
|
|
249797
|
+
});
|
|
249798
|
+
if (!methodArg || !path) {
|
|
249799
|
+
if (options.help) {
|
|
249800
|
+
const usage = `${command.helpInformation()}
|
|
249801
|
+
${CONTRACT_HELP}
|
|
249802
|
+
`;
|
|
249803
|
+
return { stdout: ctx.jsonMode ? formatJson({ usage }) : usage };
|
|
249804
|
+
}
|
|
249805
|
+
throw new InvalidInputError("Provide a method and a path, e.g. GET /api/apps.");
|
|
249806
|
+
}
|
|
249807
|
+
const method = methodArg.toUpperCase();
|
|
249808
|
+
if (options.help) {
|
|
249809
|
+
const { spec, op } = await findOperation(ctx, method, normalizePath(path), {
|
|
249810
|
+
refresh: options.refresh,
|
|
249811
|
+
flag: "--help"
|
|
249812
|
+
});
|
|
249813
|
+
const contract = getOperationContract(spec, op);
|
|
249814
|
+
return {
|
|
249815
|
+
stdout: formatJson(contract.requestBodyContentType === "multipart/form-data" ? { ...contract, hint: MULTIPART_HINT } : contract)
|
|
249816
|
+
};
|
|
249817
|
+
}
|
|
249818
|
+
const target = normalizePath(await fillAppId(ctx, path, command));
|
|
249819
|
+
if (options.readOnly) {
|
|
249820
|
+
if (ENCODED_SEPARATOR.test(withoutQuery(target))) {
|
|
249821
|
+
throw new InvalidInputError("Refused under --read-only: the path has an encoded /, \\ or ., so it can't be checked. Nothing was sent.");
|
|
249822
|
+
}
|
|
249823
|
+
const { op } = await findOperation(ctx, method, target, {
|
|
249824
|
+
refresh: options.refresh,
|
|
249825
|
+
flag: "--read-only"
|
|
249826
|
+
});
|
|
249827
|
+
if (!op.readOnly) {
|
|
249828
|
+
throw new InvalidInputError(`Refused under --read-only: ${op.method} ${op.path} is not a read-only operation. Nothing was sent.`);
|
|
249829
|
+
}
|
|
249830
|
+
}
|
|
249831
|
+
if (options.body !== undefined && options.form.length > 0) {
|
|
249832
|
+
throw new InvalidInputError("Use --body or --form, not both.");
|
|
249833
|
+
}
|
|
249834
|
+
await ensureAuth(ctx);
|
|
249835
|
+
const body = options.form.length > 0 ? await readFormBody(options.form) : await readRequestBody(options.body);
|
|
249836
|
+
const response = await ctx.runTask(`Calling ${method} ${target}`, () => sendApiRequest(method, target, body), {
|
|
249837
|
+
successMessage: `Called ${method} ${target}`,
|
|
249838
|
+
errorMessage: "Request failed"
|
|
249839
|
+
});
|
|
249840
|
+
return {
|
|
249841
|
+
stdout: await formatResponse(response, options.output, ctx.jsonMode)
|
|
249842
|
+
};
|
|
249843
|
+
}
|
|
249844
|
+
function getApiFetchCommand() {
|
|
249845
|
+
return new Base44Command("fetch", {
|
|
249846
|
+
requireAuth: false,
|
|
249847
|
+
requireAppContext: false
|
|
249848
|
+
}).description("Call a Base44 API operation; add --help after a path for its contract").helpOption(false).argument("[method]", "HTTP method, e.g. GET or POST").argument("[path]", 'Path with any query string; {app_id} is filled from --app-id or the project, e.g. "/api/apps/{app_id}/workflows/runs?status=failed"').option("--body <json>", "Request body: JSON, @file.json, or @- to read it from stdin").option("--form <field>", "Multipart field: name=value, or name=@file to attach a file (repeatable)", (field, fields) => [...fields, field], []).option("--output <file>", "Save the response body to a file").option("--read-only", "Refuse, before sending, any operation the spec does not mark read-only").option("--refresh", REFRESH_OPTION_HELP).option("-h, --help", "With a method and path, print that operation's contract; otherwise this help").addHelpText("after", `
|
|
249849
|
+
${CONTRACT_HELP}`).action(fetchAction);
|
|
249850
|
+
}
|
|
249851
|
+
|
|
249852
|
+
// src/cli/commands/api/grep.ts
|
|
249853
|
+
function assertValidRegex(pattern) {
|
|
249854
|
+
try {
|
|
249855
|
+
new RegExp(pattern);
|
|
249856
|
+
} catch (error) {
|
|
249857
|
+
throw new InvalidInputError(`Invalid regular expression: ${error instanceof Error ? error.message : pattern}`);
|
|
249858
|
+
}
|
|
249859
|
+
}
|
|
249860
|
+
async function grepAction(ctx, pattern, options) {
|
|
249861
|
+
const limit = parseLimit(options.limit);
|
|
249862
|
+
assertValidRegex(pattern);
|
|
249863
|
+
const { spec } = await loadSpecTask(ctx, options.refresh);
|
|
249864
|
+
let operations = listOperations(spec);
|
|
249865
|
+
if (options.area) {
|
|
249866
|
+
operations = operationsInArea(operations, options.area);
|
|
249867
|
+
}
|
|
249868
|
+
if (options.readOnly) {
|
|
249869
|
+
operations = operations.filter((op) => op.readOnly);
|
|
249870
|
+
}
|
|
249871
|
+
const hits = grepOperations(spec, operations, pattern, {
|
|
249872
|
+
ignoreCase: options.ignoreCase,
|
|
249873
|
+
limit
|
|
249874
|
+
});
|
|
249875
|
+
return { stdout: formatJson(hits) };
|
|
249876
|
+
}
|
|
249877
|
+
function getApiGrepCommand() {
|
|
249878
|
+
return new Base44Command("grep", {
|
|
249879
|
+
requireAuth: false,
|
|
249880
|
+
requireAppContext: false
|
|
249881
|
+
}).description("Search the API spec with a regular expression, for when search misses").argument("<pattern>", `Regular expression over each operation's contract as JSON text (quotes and newlines appear escaped), e.g. "runs.*status"`).option("--area <area>", "Search only one area's operations (see base44 api catalog)").option("-i, --ignore-case", "Case-insensitive match").option("--limit <n>", "Most operations to return (default 20)").option("--read-only", READ_ONLY_FILTER_HELP).option("--refresh", REFRESH_OPTION_HELP).action(grepAction);
|
|
249882
|
+
}
|
|
249883
|
+
|
|
249884
|
+
// src/cli/commands/api/search.ts
|
|
249885
|
+
async function searchAction(ctx, words, options) {
|
|
249886
|
+
const limit = parseLimit(options.limit);
|
|
249887
|
+
const { spec } = await loadSpecTask(ctx, options.refresh);
|
|
249888
|
+
const results = searchOperations(listOperations(spec), words.join(" "), {
|
|
249889
|
+
limit,
|
|
249890
|
+
readOnly: options.readOnly
|
|
249891
|
+
});
|
|
249892
|
+
return { stdout: formatJson(results) };
|
|
249893
|
+
}
|
|
249894
|
+
function getApiSearchCommand() {
|
|
249895
|
+
return new Base44Command("search", {
|
|
249896
|
+
requireAuth: false,
|
|
249897
|
+
requireAppContext: false
|
|
249898
|
+
}).description("Search every Base44 API operation by what it does").argument("<text...>", 'What you are looking for, e.g. "failed workflow runs"').option("--limit <n>", "Most results to return (default 5)").option("--read-only", READ_ONLY_FILTER_HELP).option("--refresh", REFRESH_OPTION_HELP).action(searchAction);
|
|
249899
|
+
}
|
|
249900
|
+
|
|
249901
|
+
// src/cli/commands/api/index.ts
|
|
249902
|
+
function getApiCommand() {
|
|
249903
|
+
return new Command2("api").description("Search and call any public Base44 API operation").addCommand(getApiCatalogCommand()).addCommand(getApiSearchCommand()).addCommand(getApiGrepCommand()).addCommand(getApiFetchCommand());
|
|
249904
|
+
}
|
|
249905
|
+
|
|
248044
249906
|
// src/cli/commands/auth/password-login.ts
|
|
248045
|
-
import { dirname as dirname16, join as
|
|
249907
|
+
import { dirname as dirname16, join as join23 } from "node:path";
|
|
248046
249908
|
async function passwordLoginAction({ log, runTask }, action) {
|
|
248047
249909
|
const shouldEnable = action === "enable";
|
|
248048
249910
|
const { project } = await readProjectConfig();
|
|
248049
249911
|
const configDir = dirname16(project.configPath);
|
|
248050
|
-
const authDir =
|
|
249912
|
+
const authDir = join23(configDir, project.authDir);
|
|
248051
249913
|
const updated = await runTask("Updating local auth config", async () => {
|
|
248052
249914
|
const current = await readAuthConfig(authDir) ?? DEFAULT_AUTH_CONFIG;
|
|
248053
249915
|
const merged = { ...current, enableUsernamePassword: shouldEnable };
|
|
@@ -248067,14 +249929,14 @@ function getPasswordLoginCommand() {
|
|
|
248067
249929
|
}
|
|
248068
249930
|
|
|
248069
249931
|
// src/cli/commands/auth/pull.ts
|
|
248070
|
-
import { dirname as dirname17, join as
|
|
249932
|
+
import { dirname as dirname17, join as join24 } from "node:path";
|
|
248071
249933
|
async function pullAuthAction({
|
|
248072
249934
|
log,
|
|
248073
249935
|
runTask
|
|
248074
249936
|
}) {
|
|
248075
249937
|
const { project } = await readProjectConfig();
|
|
248076
249938
|
const configDir = dirname17(project.configPath);
|
|
248077
|
-
const authDir =
|
|
249939
|
+
const authDir = join24(configDir, project.authDir);
|
|
248078
249940
|
const remoteConfig = await runTask("Fetching auth config from Base44", async () => {
|
|
248079
249941
|
return await pullAuthConfig();
|
|
248080
249942
|
}, {
|
|
@@ -248138,7 +250000,7 @@ function getAuthPushCommand() {
|
|
|
248138
250000
|
}
|
|
248139
250001
|
|
|
248140
250002
|
// src/cli/commands/auth/social-login.ts
|
|
248141
|
-
import { dirname as dirname18, join as
|
|
250003
|
+
import { dirname as dirname18, join as join25, resolve as resolve7 } from "node:path";
|
|
248142
250004
|
var PROVIDER_LABELS = {
|
|
248143
250005
|
google: "Google",
|
|
248144
250006
|
microsoft: "Microsoft",
|
|
@@ -248209,7 +250071,7 @@ async function socialLoginAction({ log, isNonInteractive, runTask }, provider, a
|
|
|
248209
250071
|
}
|
|
248210
250072
|
const { project } = await readProjectConfig();
|
|
248211
250073
|
const configDir = dirname18(project.configPath);
|
|
248212
|
-
const authDir =
|
|
250074
|
+
const authDir = join25(configDir, project.authDir);
|
|
248213
250075
|
const { config: updated } = await runTask("Updating local auth config", async () => updateSocialLoginConfig(authDir, provider, shouldEnable, useCustomOAuth && options.clientId ? { clientId: options.clientId } : undefined));
|
|
248214
250076
|
if (clientSecret) {
|
|
248215
250077
|
await runTask("Saving client secret", async () => pushCustomOAuthSecret(provider, clientSecret));
|
|
@@ -248234,7 +250096,7 @@ function getSocialLoginCommand() {
|
|
|
248234
250096
|
}
|
|
248235
250097
|
|
|
248236
250098
|
// src/cli/commands/auth/sso.ts
|
|
248237
|
-
import { dirname as dirname19, join as
|
|
250099
|
+
import { dirname as dirname19, join as join26, resolve as resolve8 } from "node:path";
|
|
248238
250100
|
var SSOConfigFileSchema = object({
|
|
248239
250101
|
provider: _enum(Object.values(KNOWN_SSO_PROVIDERS)),
|
|
248240
250102
|
clientId: string2(),
|
|
@@ -248398,7 +250260,7 @@ async function ssoEnableAction({ isNonInteractive, runTask }, options) {
|
|
|
248398
250260
|
}
|
|
248399
250261
|
const { project } = await readProjectConfig();
|
|
248400
250262
|
const configDir = dirname19(project.configPath);
|
|
248401
|
-
const authDir =
|
|
250263
|
+
const authDir = join26(configDir, project.authDir);
|
|
248402
250264
|
await runTask("Updating local auth config", async () => updateSSOConfig(authDir, provider, true));
|
|
248403
250265
|
await runTask("Saving SSO credentials", async () => pushSSOSecrets(secrets));
|
|
248404
250266
|
return {
|
|
@@ -248414,7 +250276,7 @@ async function ssoDisableAction({ log, runTask }, options) {
|
|
|
248414
250276
|
}
|
|
248415
250277
|
const { project } = await readProjectConfig();
|
|
248416
250278
|
const configDir = dirname19(project.configPath);
|
|
248417
|
-
const authDir =
|
|
250279
|
+
const authDir = join26(configDir, project.authDir);
|
|
248418
250280
|
const updated = await runTask("Updating local auth config", async () => updateSSOConfig(authDir, null, false));
|
|
248419
250281
|
await runTask("Removing SSO credentials", async () => deleteSSOSecrets());
|
|
248420
250282
|
if (!hasAnyLoginMethod(updated)) {
|
|
@@ -249296,13 +251158,13 @@ function getConnectorsListAvailableCommand() {
|
|
|
249296
251158
|
}
|
|
249297
251159
|
|
|
249298
251160
|
// src/cli/commands/connectors/pull.ts
|
|
249299
|
-
import { dirname as dirname20, join as
|
|
251161
|
+
import { dirname as dirname20, join as join27, resolve as resolve9 } from "node:path";
|
|
249300
251162
|
async function resolveConnectorsDir(options) {
|
|
249301
251163
|
if (!getAppContext().projectRoot) {
|
|
249302
251164
|
return resolve9(options.dir ?? "connectors");
|
|
249303
251165
|
}
|
|
249304
251166
|
const { project } = await readProjectConfig();
|
|
249305
|
-
return
|
|
251167
|
+
return join27(dirname20(project.configPath), project.connectorsDir);
|
|
249306
251168
|
}
|
|
249307
251169
|
async function pullConnectorsAction({ log, runTask, jsonMode }, options) {
|
|
249308
251170
|
const connectorsDir = await resolveConnectorsDir(options);
|
|
@@ -249689,11 +251551,11 @@ function getListCommand() {
|
|
|
249689
251551
|
}
|
|
249690
251552
|
|
|
249691
251553
|
// src/cli/commands/functions/pull.ts
|
|
249692
|
-
import { dirname as dirname21, join as
|
|
251554
|
+
import { dirname as dirname21, join as join28 } from "node:path";
|
|
249693
251555
|
async function pullFunctionsAction({ log, runTask }, name) {
|
|
249694
251556
|
const { project, functions } = await readProjectConfig();
|
|
249695
251557
|
const configDir = dirname21(project.configPath);
|
|
249696
|
-
const functionsDir =
|
|
251558
|
+
const functionsDir = join28(configDir, project.functionsDir);
|
|
249697
251559
|
const pluginFunctionNames = new Set(functions.filter((fn) => fn.source.type === "plugin").map((fn) => fn.name));
|
|
249698
251560
|
const remoteFunctions = await runTask("Fetching functions from Base44", async () => {
|
|
249699
251561
|
const { functions } = await listDeployedFunctions();
|
|
@@ -249803,11 +251665,11 @@ function getBuildCommand() {
|
|
|
249803
251665
|
}
|
|
249804
251666
|
|
|
249805
251667
|
// src/cli/commands/project/create.ts
|
|
249806
|
-
import { basename as
|
|
251668
|
+
import { basename as basename7, resolve as resolve11 } from "node:path";
|
|
249807
251669
|
var import_kebabCase = __toESM(require_kebabCase(), 1);
|
|
249808
251670
|
|
|
249809
251671
|
// src/cli/commands/project/scaffold-shared.ts
|
|
249810
|
-
import { join as
|
|
251672
|
+
import { join as join29 } from "node:path";
|
|
249811
251673
|
var DEFAULT_TEMPLATE_ID = "backend-only";
|
|
249812
251674
|
async function getTemplateById(templateId) {
|
|
249813
251675
|
const templates = await listTemplates();
|
|
@@ -249870,7 +251732,7 @@ async function completeProjectSetup({
|
|
|
249870
251732
|
env: { VITE_BASE44_APP_ID: projectId }
|
|
249871
251733
|
})`${buildCommand}`;
|
|
249872
251734
|
updateMessage("Deploying site...");
|
|
249873
|
-
return await deploySite(
|
|
251735
|
+
return await deploySite(join29(resolvedPath, outputDirectory));
|
|
249874
251736
|
}, {
|
|
249875
251737
|
successMessage: theme.colors.base44Orange("Site deployed successfully"),
|
|
249876
251738
|
errorMessage: "Failed to deploy site"
|
|
@@ -249968,8 +251830,8 @@ async function createInteractive(options, ctx) {
|
|
|
249968
251830
|
name: () => {
|
|
249969
251831
|
return options.name ? Promise.resolve(options.name) : Ze({
|
|
249970
251832
|
message: "What is the name of your project?",
|
|
249971
|
-
placeholder:
|
|
249972
|
-
initialValue:
|
|
251833
|
+
placeholder: basename7(process.cwd()),
|
|
251834
|
+
initialValue: basename7(process.cwd()),
|
|
249973
251835
|
validate: (value) => {
|
|
249974
251836
|
if (!value || value.trim().length === 0) {
|
|
249975
251837
|
return "Every project deserves a name";
|
|
@@ -250664,7 +252526,7 @@ function getLogsCommand() {
|
|
|
250664
252526
|
}
|
|
250665
252527
|
|
|
250666
252528
|
// src/cli/commands/project/scaffold.ts
|
|
250667
|
-
import { basename as
|
|
252529
|
+
import { basename as basename8, resolve as resolve12 } from "node:path";
|
|
250668
252530
|
function resolveAppId(options) {
|
|
250669
252531
|
const appId = options.appId;
|
|
250670
252532
|
if (!appId) {
|
|
@@ -250681,7 +252543,7 @@ async function scaffoldAction(ctx, name, options, command) {
|
|
|
250681
252543
|
const { log, runTask } = ctx;
|
|
250682
252544
|
const appId = resolveAppId(command.optsWithGlobals());
|
|
250683
252545
|
const resolvedPath = resolve12("./");
|
|
250684
|
-
const projectName = (name ??
|
|
252546
|
+
const projectName = (name ?? basename8(resolvedPath)).trim();
|
|
250685
252547
|
const template = await getTemplateById("backend-only");
|
|
250686
252548
|
log.info(`Scaffolding project at ${resolvedPath}`);
|
|
250687
252549
|
const { projectId } = await runTask("Setting up your project...", async () => {
|
|
@@ -250792,6 +252654,25 @@ function declaredBundle({
|
|
|
250792
252654
|
}
|
|
250793
252655
|
};
|
|
250794
252656
|
}
|
|
252657
|
+
function declaredActor({
|
|
252658
|
+
name,
|
|
252659
|
+
entry,
|
|
252660
|
+
source,
|
|
252661
|
+
size,
|
|
252662
|
+
digest,
|
|
252663
|
+
staticEgress
|
|
252664
|
+
}) {
|
|
252665
|
+
return {
|
|
252666
|
+
name,
|
|
252667
|
+
entry,
|
|
252668
|
+
source,
|
|
252669
|
+
module: { size, digest },
|
|
252670
|
+
static_egress: staticEgress
|
|
252671
|
+
};
|
|
252672
|
+
}
|
|
252673
|
+
function actorUploadPath(actor) {
|
|
252674
|
+
return `actors/${actor.name}.mjs`;
|
|
252675
|
+
}
|
|
250795
252676
|
function declaredServingConfig(config) {
|
|
250796
252677
|
const stated = {
|
|
250797
252678
|
html_handling: config?.htmlHandling ?? null,
|
|
@@ -250846,6 +252727,7 @@ async function createVersion(artifacts, options = {}) {
|
|
|
250846
252727
|
}
|
|
250847
252728
|
} : {},
|
|
250848
252729
|
backend_bundles: artifacts.backendBundles.map(declaredBundle),
|
|
252730
|
+
actors: artifacts.actors.map(declaredActor),
|
|
250849
252731
|
entities: artifacts.entities,
|
|
250850
252732
|
agents: artifacts.agents,
|
|
250851
252733
|
source_commit: options.sourceCommit
|
|
@@ -250854,7 +252736,8 @@ async function createVersion(artifacts, options = {}) {
|
|
|
250854
252736
|
...artifacts.assets,
|
|
250855
252737
|
...artifacts.siteWorker?.modules ?? []
|
|
250856
252738
|
];
|
|
250857
|
-
const
|
|
252739
|
+
const actorsAt = declaredFiles.length + artifacts.backendBundles.length;
|
|
252740
|
+
const slotCount = actorsAt + artifacts.actors.length;
|
|
250858
252741
|
options.progress?.onDeclared?.({ fileCount: slotCount });
|
|
250859
252742
|
if (declared.uploads.length !== slotCount) {
|
|
250860
252743
|
throw new InternalError(`Declared ${slotCount} files but the server signed ${declared.uploads.length} upload URLs.`);
|
|
@@ -250863,12 +252746,18 @@ async function createVersion(artifacts, options = {}) {
|
|
|
250863
252746
|
if (drifted !== -1) {
|
|
250864
252747
|
throw new InternalError(`Upload ${drifted} is signed for ${declared.uploads[drifted].path}, but that slot declared ${declaredFiles[drifted].path}.`);
|
|
250865
252748
|
}
|
|
252749
|
+
const actorDrifted = artifacts.actors.findIndex((actor, index) => declared.uploads[actorsAt + index].path !== actorUploadPath(actor));
|
|
252750
|
+
if (actorDrifted !== -1) {
|
|
252751
|
+
throw new InternalError(`Upload ${actorsAt + actorDrifted} is signed for ${declared.uploads[actorsAt + actorDrifted].path}, but that slot declared the actor ${artifacts.actors[actorDrifted].name}.`);
|
|
252752
|
+
}
|
|
250866
252753
|
let uploadedFiles = 0;
|
|
250867
252754
|
await pMap(declared.uploads, async (upload, index) => {
|
|
250868
252755
|
if (index < declaredFiles.length) {
|
|
250869
252756
|
await putPresigned(upload, declaredFiles[index].absolutePath);
|
|
250870
|
-
} else {
|
|
252757
|
+
} else if (index < actorsAt) {
|
|
250871
252758
|
await putPresignedBody(upload, artifacts.backendBundles[index - declaredFiles.length].module);
|
|
252759
|
+
} else {
|
|
252760
|
+
await putPresignedBody(upload, artifacts.actors[index - actorsAt].module);
|
|
250872
252761
|
}
|
|
250873
252762
|
uploadedFiles++;
|
|
250874
252763
|
options.progress?.onUpload?.({
|
|
@@ -250886,11 +252775,10 @@ async function setEnvironmentVersion(environment, versionId, options = {}) {
|
|
|
250886
252775
|
}
|
|
250887
252776
|
// src/core/version/artifacts.ts
|
|
250888
252777
|
import { createHash as createHash3 } from "node:crypto";
|
|
250889
|
-
import { join as
|
|
252778
|
+
import { join as join30, resolve as resolve14 } from "node:path";
|
|
250890
252779
|
|
|
250891
|
-
// src/core/version/
|
|
250892
|
-
import {
|
|
250893
|
-
import { relative as relative6 } from "node:path";
|
|
252780
|
+
// src/core/version/actors.ts
|
|
252781
|
+
import { dirname as dirname22, relative as relative7, resolve as resolve13 } from "node:path";
|
|
250894
252782
|
|
|
250895
252783
|
// ../functions-compiler/src/assembly.ts
|
|
250896
252784
|
import path17 from "node:path";
|
|
@@ -256373,7 +258261,7 @@ var TELEMETRY_PATCH = [
|
|
|
256373
258261
|
var TELEMETRY_STORE_FIELDS = "reqId: crypto.randomUUID(), respondedAt: null, inflight: new Map(), inflightTotal: 0, hadRejection: false, hadNonOk: false, logBudget: 5";
|
|
256374
258262
|
|
|
256375
258263
|
// ../functions-compiler/src/version.ts
|
|
256376
|
-
var COMPILER_VERSION = "0.1.
|
|
258264
|
+
var COMPILER_VERSION = "0.1.8";
|
|
256377
258265
|
|
|
256378
258266
|
// ../functions-compiler/src/worker-entry.ts
|
|
256379
258267
|
function denoShimSource() {
|
|
@@ -256424,6 +258312,18 @@ function consolePatch(runtimeSecrets) {
|
|
|
256424
258312
|
return runtimeSecrets ? `${CONSOLE_PATCH}
|
|
256425
258313
|
${RUNTIME_SECRETS_RESERVED_PATCH}` : CONSOLE_PATCH;
|
|
256426
258314
|
}
|
|
258315
|
+
async function prepareFunction(entry, files, postResponseTelemetry = false, runtimeSecrets = false) {
|
|
258316
|
+
assertNoReservedFilenames(files);
|
|
258317
|
+
return {
|
|
258318
|
+
entry: ENTRY_FILENAME,
|
|
258319
|
+
files: {
|
|
258320
|
+
...userFiles(files),
|
|
258321
|
+
...workerRuntimeFiles(),
|
|
258322
|
+
...runtimeSecrets ? { [ACTIVATION_FILENAME]: activationShimSource() } : {},
|
|
258323
|
+
[ENTRY_FILENAME]: buildEntrySource(entry, postResponseTelemetry, runtimeSecrets)
|
|
258324
|
+
}
|
|
258325
|
+
};
|
|
258326
|
+
}
|
|
256427
258327
|
var BANNER_FORMAT = 1;
|
|
256428
258328
|
function buildBanner(entries, telemetry, runtimeSecrets) {
|
|
256429
258329
|
return `//!b44:${BANNER_FORMAT} ${JSON.stringify({
|
|
@@ -256467,6 +258367,50 @@ function activationImport(runtimeSecrets) {
|
|
|
256467
258367
|
return runtimeSecrets ? `
|
|
256468
258368
|
import { ensureActivation, takeActivationChallenge, withoutActivationHeaders } from "./${ACTIVATION_FILENAME}";` : "";
|
|
256469
258369
|
}
|
|
258370
|
+
function buildEntrySource(userEntry, telemetry, runtimeSecrets = false) {
|
|
258371
|
+
const userImport = `./${userEntry.replace(/^\.\//, "")}`;
|
|
258372
|
+
const handlerExpr = telemetry ? "_b44AttachTelemetry(await handler(request, info))" : runtimeSecrets ? "await handler(request, info)" : "handler(request, info)";
|
|
258373
|
+
const guard = activationGuard(runtimeSecrets);
|
|
258374
|
+
const returnExpr = guard(handlerExpr);
|
|
258375
|
+
return `// Auto-generated by the base44 bundler. Do not edit.
|
|
258376
|
+
|
|
258377
|
+
import { currentWorkerRuntimeContext as _b44Context, runWithWorkerEnvironment as _b44Run } from ${JSON.stringify(RUNTIME_CONTEXT_SPECIFIER)};
|
|
258378
|
+
import { getRegisteredHandler, installStaticEgressFetch } from "./${SHIM_FILENAME}";${activationImport(runtimeSecrets)}
|
|
258379
|
+
|
|
258380
|
+
${consolePatch(runtimeSecrets)}
|
|
258381
|
+
// Static egress reads workerEnv from the active request store. Install it
|
|
258382
|
+
// before telemetry so telemetry remains the outermost fetch wrapper.
|
|
258383
|
+
installStaticEgressFetch();
|
|
258384
|
+
${telemetry ? TELEMETRY_PATCH : ""}
|
|
258385
|
+
|
|
258386
|
+
let _b44Init = null;
|
|
258387
|
+
export default {
|
|
258388
|
+
async fetch(request, env, ctx) {
|
|
258389
|
+
${runtimeSecrets ? ACTIVATION_TAKE : ""} const _b44Env = (request.headers.get('base44-functions-version') ?? '') === 'prod' ? 'prod' : 'preview';
|
|
258390
|
+
return _b44Run({ env: _b44Env, secrets: ${runtimeSecrets ? "process.env" : "env"}, workerEnv: env, waitUntil: (p) => ctx.waitUntil(p)${telemetry ? `, ${TELEMETRY_STORE_FIELDS}` : ""} }, async () => {
|
|
258391
|
+
${runtimeSecrets ? ACTIVATION_GATE : ""} if (!_b44Init) _b44Init = import(${JSON.stringify(userImport)}).catch(e => { _b44Init = null; throw e; });
|
|
258392
|
+
const _b44Mod = await _b44Init;
|
|
258393
|
+
// Deno.serve capture wins (legacy contract, zero behavior change);
|
|
258394
|
+
// a default-exported handler is the new-contract fallback.
|
|
258395
|
+
const handler = getRegisteredHandler() ?? (typeof _b44Mod?.default === 'function' ? _b44Mod.default : null);
|
|
258396
|
+
if (!handler) {
|
|
258397
|
+
return ${guard(`new Response(
|
|
258398
|
+
"The function must export default a request handler or call Deno.serve()",
|
|
258399
|
+
{ status: 503 },
|
|
258400
|
+
)`)};
|
|
258401
|
+
}
|
|
258402
|
+
// Deno's handler signature is (request, info). Cloudflare doesn't expose a
|
|
258403
|
+
// connection address the same way; pass a best-effort placeholder. Real
|
|
258404
|
+
// client IP is available via the "cf-connecting-ip" request header.
|
|
258405
|
+
const info = {
|
|
258406
|
+
remoteAddr: { transport: "tcp", hostname: "0.0.0.0", port: 0 },
|
|
258407
|
+
};
|
|
258408
|
+
return ${returnExpr};
|
|
258409
|
+
});
|
|
258410
|
+
},
|
|
258411
|
+
};
|
|
258412
|
+
`;
|
|
258413
|
+
}
|
|
256470
258414
|
function buildFunctionModuleSource(functionName, userEntry) {
|
|
256471
258415
|
const userImport = `./${userEntry.replace(/^\.\//, "")}`;
|
|
256472
258416
|
return `// Auto-generated by the base44 bundler. Do not edit.
|
|
@@ -256769,6 +258713,284 @@ function runtimeContextVirtualPlugin() {
|
|
|
256769
258713
|
};
|
|
256770
258714
|
}
|
|
256771
258715
|
|
|
258716
|
+
// ../functions-compiler/src/actor-compat.ts
|
|
258717
|
+
var ACTOR_ENTRY_FILENAME2 = "__base44_actor_entry.mjs";
|
|
258718
|
+
var ACTOR_PRELUDE_FILENAME = "__base44_actor_prelude.mjs";
|
|
258719
|
+
var ACTOR_AUTH_FILENAME = "__base44_actor_auth.mjs";
|
|
258720
|
+
var ACTORS_PREFIX = "base44/actors/";
|
|
258721
|
+
var ENTRY_SUFFIX = "/entry.ts";
|
|
258722
|
+
function actorNameFromEntry(entry) {
|
|
258723
|
+
if (!entry.startsWith(ACTORS_PREFIX) || !entry.endsWith(ENTRY_SUFFIX))
|
|
258724
|
+
return null;
|
|
258725
|
+
const name = entry.slice(ACTORS_PREFIX.length, -ENTRY_SUFFIX.length);
|
|
258726
|
+
return name && !name.includes("/") ? name : null;
|
|
258727
|
+
}
|
|
258728
|
+
function applyActorCompat(entry, files) {
|
|
258729
|
+
const actorName = actorNameFromEntry(entry);
|
|
258730
|
+
if (!actorName || files[entry] === undefined)
|
|
258731
|
+
return null;
|
|
258732
|
+
assertNoReservedFilenames(files);
|
|
258733
|
+
if (ACTOR_PRELUDE_FILENAME in files) {
|
|
258734
|
+
throw new Error(`Reserved filename "${ACTOR_PRELUDE_FILENAME}" in actor bundle — ` + "it is generated by the bundler. Rename the file.");
|
|
258735
|
+
}
|
|
258736
|
+
if (ACTOR_AUTH_FILENAME in files) {
|
|
258737
|
+
throw new Error(`Reserved filename "${ACTOR_AUTH_FILENAME}" in actor bundle — ` + "it is generated by the bundler. Rename the file.");
|
|
258738
|
+
}
|
|
258739
|
+
const handlerName = actorName;
|
|
258740
|
+
const doClassName = handlerName;
|
|
258741
|
+
const prelude = buildPrelude();
|
|
258742
|
+
const entryWrapper = buildEntryWrapper(doClassName, entry);
|
|
258743
|
+
return {
|
|
258744
|
+
entry: ACTOR_ENTRY_FILENAME2,
|
|
258745
|
+
files: {
|
|
258746
|
+
...files,
|
|
258747
|
+
...workerRuntimeFiles(),
|
|
258748
|
+
[ACTOR_AUTH_FILENAME]: buildActorAuth(),
|
|
258749
|
+
[ACTOR_PRELUDE_FILENAME]: prelude,
|
|
258750
|
+
[ACTOR_ENTRY_FILENAME2]: entryWrapper
|
|
258751
|
+
},
|
|
258752
|
+
handlerName,
|
|
258753
|
+
doClassName
|
|
258754
|
+
};
|
|
258755
|
+
}
|
|
258756
|
+
function buildActorAuth() {
|
|
258757
|
+
return `// Auto-generated by the base44 bundler. Do not edit.
|
|
258758
|
+
const TOKEN_HEADER = "X-Base44-Actor-Token";
|
|
258759
|
+
const IDENTITY_HEADER = "X-Base44-Actor-Identity";
|
|
258760
|
+
const CLOCK_SKEW_SECONDS = 30;
|
|
258761
|
+
const TOKEN_TTL_SECONDS = 300;
|
|
258762
|
+
|
|
258763
|
+
const decodeSegment = (segment) => {
|
|
258764
|
+
const normalized = segment.replace(/-/g, "+").replace(/_/g, "/");
|
|
258765
|
+
const padded = normalized + "=".repeat((4 - normalized.length % 4) % 4);
|
|
258766
|
+
const binary = atob(padded);
|
|
258767
|
+
return new Uint8Array([...binary].map((character) => character.charCodeAt(0)));
|
|
258768
|
+
};
|
|
258769
|
+
|
|
258770
|
+
const decodeJsonSegment = (segment) =>
|
|
258771
|
+
JSON.parse(new TextDecoder().decode(decodeSegment(segment)));
|
|
258772
|
+
|
|
258773
|
+
const unauthorized = () => ({
|
|
258774
|
+
ok: false,
|
|
258775
|
+
response: new Response("Unauthorized", { status: 401 }),
|
|
258776
|
+
});
|
|
258777
|
+
|
|
258778
|
+
const validPrincipal = (principal) => {
|
|
258779
|
+
if (principal === null || typeof principal !== "object" || Array.isArray(principal)) return false;
|
|
258780
|
+
if (principal.type === "authenticated") {
|
|
258781
|
+
return typeof principal.userId === "string" && principal.userId.length > 0 && principal.userId.length <= 128;
|
|
258782
|
+
}
|
|
258783
|
+
if (principal.type === "anonymous") {
|
|
258784
|
+
return typeof principal.anonymousId === "string" && principal.anonymousId.length > 0 && principal.anonymousId.length <= 128;
|
|
258785
|
+
}
|
|
258786
|
+
return false;
|
|
258787
|
+
};
|
|
258788
|
+
|
|
258789
|
+
export async function verifyActorConnection(request, env, actorName, room) {
|
|
258790
|
+
const publicKey = env.BASE44_ACTOR_PUBLIC_KEY;
|
|
258791
|
+
const scriptId = env.BASE44_ACTOR_SCRIPT_ID;
|
|
258792
|
+
const token = request.headers.get(TOKEN_HEADER) ?? new URL(request.url).searchParams.get("token");
|
|
258793
|
+
if (
|
|
258794
|
+
typeof publicKey !== "string" || !publicKey ||
|
|
258795
|
+
typeof scriptId !== "string" || !scriptId ||
|
|
258796
|
+
typeof token !== "string" || token.length > 4096
|
|
258797
|
+
) return unauthorized();
|
|
258798
|
+
|
|
258799
|
+
const parts = token.split(".");
|
|
258800
|
+
if (parts.length !== 3) return unauthorized();
|
|
258801
|
+
try {
|
|
258802
|
+
const header = decodeJsonSegment(parts[0]);
|
|
258803
|
+
const claims = decodeJsonSegment(parts[1]);
|
|
258804
|
+
if (header?.alg !== "EdDSA" || (header.typ !== undefined && header.typ !== "JWT")) {
|
|
258805
|
+
return unauthorized();
|
|
258806
|
+
}
|
|
258807
|
+
const key = await crypto.subtle.importKey(
|
|
258808
|
+
"raw",
|
|
258809
|
+
decodeSegment(publicKey),
|
|
258810
|
+
{ name: "Ed25519" },
|
|
258811
|
+
false,
|
|
258812
|
+
["verify"],
|
|
258813
|
+
);
|
|
258814
|
+
const validSignature = await crypto.subtle.verify(
|
|
258815
|
+
{ name: "Ed25519" },
|
|
258816
|
+
key,
|
|
258817
|
+
decodeSegment(parts[2]),
|
|
258818
|
+
new TextEncoder().encode(parts[0] + "." + parts[1]),
|
|
258819
|
+
);
|
|
258820
|
+
if (!validSignature) return unauthorized();
|
|
258821
|
+
|
|
258822
|
+
const now = Math.floor(Date.now() / 1000);
|
|
258823
|
+
const times = [claims.iat, claims.nbf, claims.exp];
|
|
258824
|
+
if (!times.every(Number.isInteger)) return unauthorized();
|
|
258825
|
+
if (
|
|
258826
|
+
claims.iss !== "base44" ||
|
|
258827
|
+
claims.aud !== "base44-actor-connect" ||
|
|
258828
|
+
claims.purpose !== "actor-connect" ||
|
|
258829
|
+
claims.v !== 1 ||
|
|
258830
|
+
typeof claims.jti !== "string" || !claims.jti || claims.jti.length > 64 ||
|
|
258831
|
+
claims.iat > now + CLOCK_SKEW_SECONDS ||
|
|
258832
|
+
claims.nbf > now + CLOCK_SKEW_SECONDS ||
|
|
258833
|
+
claims.exp < now - CLOCK_SKEW_SECONDS ||
|
|
258834
|
+
claims.exp <= claims.iat || claims.exp - claims.iat > TOKEN_TTL_SECONDS ||
|
|
258835
|
+
claims.app_id !== env.BASE44_APP_ID ||
|
|
258836
|
+
claims.actor_name !== actorName ||
|
|
258837
|
+
claims.actor_script_id !== scriptId ||
|
|
258838
|
+
claims.room !== room ||
|
|
258839
|
+
claims.connection_id !== new URL(request.url).searchParams.get("_pk") ||
|
|
258840
|
+
claims.runtime_mode !== (env.BASE44_FUNCTIONS_VERSION === "prod" ? "prod" : "preview") ||
|
|
258841
|
+
!validPrincipal(claims.principal)
|
|
258842
|
+
) return unauthorized();
|
|
258843
|
+
|
|
258844
|
+
return {
|
|
258845
|
+
ok: true,
|
|
258846
|
+
identity: Object.freeze({ ...claims.principal }),
|
|
258847
|
+
runtimeMode: claims.runtime_mode,
|
|
258848
|
+
};
|
|
258849
|
+
} catch {
|
|
258850
|
+
return unauthorized();
|
|
258851
|
+
}
|
|
258852
|
+
}
|
|
258853
|
+
|
|
258854
|
+
export function authorizedActorRequest(request, identity, actorName, room, runtimeMode) {
|
|
258855
|
+
const url = new URL(request.url);
|
|
258856
|
+
url.searchParams.delete("token");
|
|
258857
|
+
url.pathname = "/parties/" + encodeURIComponent(actorName) + "/" + encodeURIComponent(room);
|
|
258858
|
+
const headers = new Headers(request.headers);
|
|
258859
|
+
headers.delete(TOKEN_HEADER);
|
|
258860
|
+
headers.set(IDENTITY_HEADER, JSON.stringify(identity));
|
|
258861
|
+
headers.set("base44-functions-version", runtimeMode === "prod" ? "prod" : "preview");
|
|
258862
|
+
return new Request(new Request(url.toString(), request), { headers });
|
|
258863
|
+
}
|
|
258864
|
+
`;
|
|
258865
|
+
}
|
|
258866
|
+
function buildPrelude() {
|
|
258867
|
+
return `// Auto-generated by the base44 bundler. Do not edit.
|
|
258868
|
+
import { currentWorkerRuntimeContext as _b44Context } from ${JSON.stringify(RUNTIME_CONTEXT_SPECIFIER)};
|
|
258869
|
+
import { installStaticEgressFetch } from "./${SHIM_FILENAME}";
|
|
258870
|
+
|
|
258871
|
+
${CONSOLE_PATCH}
|
|
258872
|
+
installStaticEgressFetch();
|
|
258873
|
+
`;
|
|
258874
|
+
}
|
|
258875
|
+
function buildEntryWrapper(doClassName, userEntry) {
|
|
258876
|
+
const userImport = `./${userEntry.replace(/^\.\//, "")}`;
|
|
258877
|
+
return `// Auto-generated by the base44 bundler. Do not edit.
|
|
258878
|
+
// The prelude is intentionally the first dependency: it installs the fetch
|
|
258879
|
+
// shim before the user module evaluates while this static default import keeps
|
|
258880
|
+
// missing-default actors as bundle-time errors.
|
|
258881
|
+
import "./${ACTOR_PRELUDE_FILENAME}";
|
|
258882
|
+
import Base44UserActor from ${JSON.stringify(userImport)};
|
|
258883
|
+
import { runWithWorkerEnvironment as _b44Run } from ${JSON.stringify(RUNTIME_CONTEXT_SPECIFIER)};
|
|
258884
|
+
import { authorizedActorRequest as _b44AuthorizedActorRequest, verifyActorConnection as _b44VerifyActorConnection } from "./${ACTOR_AUTH_FILENAME}";
|
|
258885
|
+
|
|
258886
|
+
const _b44ActorState = new WeakMap();
|
|
258887
|
+
const _b44RunWithActorEnvironment = (ctx, env, runtimeEnv, callback) => _b44Run({
|
|
258888
|
+
env: runtimeEnv,
|
|
258889
|
+
secrets: env,
|
|
258890
|
+
workerEnv: env,
|
|
258891
|
+
waitUntil: (promise) => ctx.waitUntil(promise),
|
|
258892
|
+
}, callback);
|
|
258893
|
+
const _b44ConstructActor = (ctx, env, newTarget) => _b44RunWithActorEnvironment(
|
|
258894
|
+
ctx,
|
|
258895
|
+
env,
|
|
258896
|
+
"prod",
|
|
258897
|
+
() => {
|
|
258898
|
+
// A derived constructor may return an explicitly constructed instance.
|
|
258899
|
+
// This keeps the user's constructor and class-field initializers inside the
|
|
258900
|
+
// request-scoped Worker environment without changing the exported subclass.
|
|
258901
|
+
const actor = Reflect.construct(Base44UserActor, [ctx, env], newTarget);
|
|
258902
|
+
_b44ActorState.set(actor, { ctx, env, runtimeEnv: null });
|
|
258903
|
+
return actor;
|
|
258904
|
+
},
|
|
258905
|
+
);
|
|
258906
|
+
const _b44RunActor = (actor, request, callback) => {
|
|
258907
|
+
const state = _b44ActorState.get(actor);
|
|
258908
|
+
const runtimeEnv = request
|
|
258909
|
+
? ((request.headers.get("base44-functions-version") ?? "") === "prod" ? "prod" : "preview")
|
|
258910
|
+
: (state.runtimeEnv ?? "prod");
|
|
258911
|
+
state.runtimeEnv = runtimeEnv;
|
|
258912
|
+
return _b44RunWithActorEnvironment(state.ctx, state.env, runtimeEnv, callback);
|
|
258913
|
+
};
|
|
258914
|
+
|
|
258915
|
+
export class ${doClassName} extends Base44UserActor {
|
|
258916
|
+
// Read by the shim's service-token exchange: the assertion's actor_name claim
|
|
258917
|
+
// selects the verification key on the platform side. A static (not .name) so
|
|
258918
|
+
// minification can't change it.
|
|
258919
|
+
static _b44ActorName = ${JSON.stringify(doClassName)};
|
|
258920
|
+
|
|
258921
|
+
constructor(ctx, env) {
|
|
258922
|
+
return _b44ConstructActor(ctx, env, new.target);
|
|
258923
|
+
}
|
|
258924
|
+
|
|
258925
|
+
fetch(request) {
|
|
258926
|
+
return _b44RunActor(this, request, () => super.fetch(request));
|
|
258927
|
+
}
|
|
258928
|
+
|
|
258929
|
+
onConnect(...args) {
|
|
258930
|
+
return _b44RunActor(this, null, () => super.onConnect(...args));
|
|
258931
|
+
}
|
|
258932
|
+
|
|
258933
|
+
onMessage(...args) {
|
|
258934
|
+
return _b44RunActor(this, null, () => super.onMessage(...args));
|
|
258935
|
+
}
|
|
258936
|
+
|
|
258937
|
+
onClose(...args) {
|
|
258938
|
+
return _b44RunActor(this, null, () => super.onClose(...args));
|
|
258939
|
+
}
|
|
258940
|
+
|
|
258941
|
+
onAlarm(...args) {
|
|
258942
|
+
return _b44RunActor(this, null, () => super.onAlarm(...args));
|
|
258943
|
+
}
|
|
258944
|
+
|
|
258945
|
+
onStart(...args) {
|
|
258946
|
+
return _b44RunActor(this, null, () => super.onStart(...args));
|
|
258947
|
+
}
|
|
258948
|
+
|
|
258949
|
+
onError(...args) {
|
|
258950
|
+
return _b44RunActor(this, null, () => super.onError(...args));
|
|
258951
|
+
}
|
|
258952
|
+
}
|
|
258953
|
+
export default {
|
|
258954
|
+
async fetch(request, env, ctx) {
|
|
258955
|
+
const url = new URL(request.url);
|
|
258956
|
+
const parts = url.pathname.split("/");
|
|
258957
|
+
const direct = parts[1] === "rooms" && parts.length === 3;
|
|
258958
|
+
const legacy = parts[1] === "parties" && parts.length === 4;
|
|
258959
|
+
if (direct || legacy) {
|
|
258960
|
+
// Decode the room: the token was verified against the decoded instance id,
|
|
258961
|
+
// so an escaped room must map to the same Durable Object.
|
|
258962
|
+
const namespace = direct ? "${doClassName}" : parts[2];
|
|
258963
|
+
const encodedRoom = direct ? parts[2] : parts[3];
|
|
258964
|
+
let room;
|
|
258965
|
+
try { room = decodeURIComponent(encodedRoom); } catch { return new Response("Invalid room", { status: 400 }); }
|
|
258966
|
+
let actorRequest = request;
|
|
258967
|
+
if (direct || typeof env.BASE44_ACTOR_PUBLIC_KEY === "string") {
|
|
258968
|
+
const verification = await _b44VerifyActorConnection(request, env, "${doClassName}", room);
|
|
258969
|
+
if (!verification.ok) return verification.response;
|
|
258970
|
+
actorRequest = _b44AuthorizedActorRequest(
|
|
258971
|
+
request,
|
|
258972
|
+
verification.identity,
|
|
258973
|
+
"${doClassName}",
|
|
258974
|
+
room,
|
|
258975
|
+
verification.runtimeMode,
|
|
258976
|
+
);
|
|
258977
|
+
}
|
|
258978
|
+
const doNs = env["${doClassName}"];
|
|
258979
|
+
if (doNs && typeof doNs.idFromName === "function") {
|
|
258980
|
+
const stub = doNs.get(doNs.idFromName(room));
|
|
258981
|
+
const req = new Request(actorRequest);
|
|
258982
|
+
req.headers.set("x-partykit-room", room);
|
|
258983
|
+
req.headers.set("x-partykit-namespace", namespace);
|
|
258984
|
+
return stub.fetch(req);
|
|
258985
|
+
}
|
|
258986
|
+
return new Response("DO binding not found", { status: 503 });
|
|
258987
|
+
}
|
|
258988
|
+
return new Response("Not found", { status: 404 });
|
|
258989
|
+
},
|
|
258990
|
+
};
|
|
258991
|
+
`;
|
|
258992
|
+
}
|
|
258993
|
+
|
|
256772
258994
|
// ../../node_modules/zod/v3/helpers/util.js
|
|
256773
258995
|
var util;
|
|
256774
258996
|
(function(util) {
|
|
@@ -260576,7 +262798,7 @@ var nativeEnumType = ZodNativeEnum.create;
|
|
|
260576
262798
|
var promiseType = ZodPromise.create;
|
|
260577
262799
|
var effectsType = ZodEffects.create;
|
|
260578
262800
|
var optionalType = ZodOptional2.create;
|
|
260579
|
-
var
|
|
262801
|
+
var nullableType2 = ZodNullable2.create;
|
|
260580
262802
|
var preprocessType = ZodEffects.createWithPreprocess;
|
|
260581
262803
|
var pipelineType = ZodPipeline.create;
|
|
260582
262804
|
// ../functions-compiler/src/contracts.ts
|
|
@@ -260606,7 +262828,7 @@ var bundleAppRequestSchema = objectType({
|
|
|
260606
262828
|
var ACTIVATION_MODE = "pull";
|
|
260607
262829
|
|
|
260608
262830
|
// ../functions-compiler/src/deno-bundle.ts
|
|
260609
|
-
import { mkdtemp, rm, writeFile as writeFile2 } from "node:fs/promises";
|
|
262831
|
+
import { mkdtemp, rm as rm2, writeFile as writeFile2 } from "node:fs/promises";
|
|
260610
262832
|
import { tmpdir as tmpdir2 } from "node:os";
|
|
260611
262833
|
import path21 from "node:path";
|
|
260612
262834
|
|
|
@@ -261213,7 +263435,7 @@ async function bundleToModule(prepared, nodeModulesDir = "none") {
|
|
|
261213
263435
|
warnings: result.warnings.map((w) => w.text)
|
|
261214
263436
|
};
|
|
261215
263437
|
} finally {
|
|
261216
|
-
await
|
|
263438
|
+
await rm2(dir, { recursive: true, force: true });
|
|
261217
263439
|
}
|
|
261218
263440
|
}
|
|
261219
263441
|
function buildFailureErrors(e, dir) {
|
|
@@ -261273,6 +263495,51 @@ function setSpanTags(tags) {
|
|
|
261273
263495
|
// ../functions-compiler/src/bundler.ts
|
|
261274
263496
|
var NORMALIZED_MAIN_MODULE = "_bundled.mjs";
|
|
261275
263497
|
var MAX_PARALLEL_COMPILES = 4;
|
|
263498
|
+
async function bundle(req) {
|
|
263499
|
+
let actor;
|
|
263500
|
+
try {
|
|
263501
|
+
actor = applyActorCompat(req.entry, req.files);
|
|
263502
|
+
} catch (e) {
|
|
263503
|
+
return denoCompatErrorOrThrow(e);
|
|
263504
|
+
}
|
|
263505
|
+
if (actor) {
|
|
263506
|
+
if (req.runtimeSecrets) {
|
|
263507
|
+
return denoCompatErrorOrThrow(new DenoCompatError("runtimeSecrets is not supported for Actor entries: an Actor reads secrets " + "from its Durable Object env, so it must be deployed in binding mode."));
|
|
263508
|
+
}
|
|
263509
|
+
const outcome = await installAndCompile({
|
|
263510
|
+
entry: actor.entry,
|
|
263511
|
+
files: actor.files
|
|
263512
|
+
});
|
|
263513
|
+
if (outcome.ok) {
|
|
263514
|
+
return {
|
|
263515
|
+
ok: true,
|
|
263516
|
+
module: outcome.module,
|
|
263517
|
+
main_module: NORMALIZED_MAIN_MODULE,
|
|
263518
|
+
warnings: outcome.warnings,
|
|
263519
|
+
handler_name: actor.handlerName,
|
|
263520
|
+
do_class_name: actor.doClassName
|
|
263521
|
+
};
|
|
263522
|
+
}
|
|
263523
|
+
return { ok: false, stage: outcome.stage, errors: outcome.errors };
|
|
263524
|
+
}
|
|
263525
|
+
let prepared;
|
|
263526
|
+
try {
|
|
263527
|
+
prepared = await prepareFunction(req.entry, req.files, req.postResponseTelemetry, req.runtimeSecrets);
|
|
263528
|
+
} catch (e) {
|
|
263529
|
+
return denoCompatErrorOrThrow(e);
|
|
263530
|
+
}
|
|
263531
|
+
const outcome = await installAndCompile(prepared);
|
|
263532
|
+
if (outcome.ok) {
|
|
263533
|
+
return {
|
|
263534
|
+
ok: true,
|
|
263535
|
+
module: outcome.module,
|
|
263536
|
+
main_module: NORMALIZED_MAIN_MODULE,
|
|
263537
|
+
warnings: outcome.warnings,
|
|
263538
|
+
...activationField(req.runtimeSecrets ?? false)
|
|
263539
|
+
};
|
|
263540
|
+
}
|
|
263541
|
+
return { ok: false, stage: outcome.stage, errors: outcome.errors };
|
|
263542
|
+
}
|
|
261276
263543
|
function activationField(runtimeSecrets) {
|
|
261277
263544
|
return runtimeSecrets ? { activation: ACTIVATION_MODE } : {};
|
|
261278
263545
|
}
|
|
@@ -261460,6 +263727,16 @@ async function installAndCompile(prepared) {
|
|
|
261460
263727
|
return { ok: false, stage: "esbuild", errors: result.errors };
|
|
261461
263728
|
});
|
|
261462
263729
|
}
|
|
263730
|
+
function denoCompatErrorOrThrow(e) {
|
|
263731
|
+
if (e instanceof DenoCompatError) {
|
|
263732
|
+
return {
|
|
263733
|
+
ok: false,
|
|
263734
|
+
stage: "deno_compat",
|
|
263735
|
+
errors: [denoCompatErrorItem(e)]
|
|
263736
|
+
};
|
|
263737
|
+
}
|
|
263738
|
+
throw e;
|
|
263739
|
+
}
|
|
261463
263740
|
function denoCompatErrorItem(e) {
|
|
261464
263741
|
return { message: e.message, file: e.file };
|
|
261465
263742
|
}
|
|
@@ -261662,6 +263939,8 @@ async function mapWithConcurrency2(items, limit, fn) {
|
|
|
261662
263939
|
return results;
|
|
261663
263940
|
}
|
|
261664
263941
|
// src/core/version/functions.ts
|
|
263942
|
+
import { createHash as createHash2 } from "node:crypto";
|
|
263943
|
+
import { relative as relative6 } from "node:path";
|
|
261665
263944
|
var SHARD_POLICY = {
|
|
261666
263945
|
shardSize: 100,
|
|
261667
263946
|
globalShardSize: 100,
|
|
@@ -261669,11 +263948,11 @@ var SHARD_POLICY = {
|
|
|
261669
263948
|
gzipCapBytes: 9500000
|
|
261670
263949
|
};
|
|
261671
263950
|
var COMPILE_MODES = { runtimeSecrets: false, postResponseTelemetry: false };
|
|
261672
|
-
async function requireCompilerRuntime() {
|
|
263951
|
+
async function requireCompilerRuntime(what = "Backend functions") {
|
|
261673
263952
|
try {
|
|
261674
263953
|
await Promise.all([import("esbuild"), import("@deno/loader")]);
|
|
261675
263954
|
} catch (error) {
|
|
261676
|
-
throw new DependencyNotFoundError(
|
|
263955
|
+
throw new DependencyNotFoundError(`${what} cannot be compiled by this installation of the CLI.`, {
|
|
261677
263956
|
hints: [{ message: "Install the CLI from npm: npm install -g base44" }],
|
|
261678
263957
|
cause: error instanceof Error ? error : undefined
|
|
261679
263958
|
});
|
|
@@ -261730,6 +264009,97 @@ async function compileBackendBundles(root, functionsDir) {
|
|
|
261730
264009
|
});
|
|
261731
264010
|
}
|
|
261732
264011
|
|
|
264012
|
+
// src/core/version/actors.ts
|
|
264013
|
+
var MAX_ACTORS = 50;
|
|
264014
|
+
var COMPILE_CONCURRENCY = 4;
|
|
264015
|
+
var ACTORS_ROOT = "base44/actors";
|
|
264016
|
+
var SHARED_ROOT = "base44/shared";
|
|
264017
|
+
function forwardSlashed(from, to) {
|
|
264018
|
+
return relative7(from, to).split(/[/\\]/).join("/");
|
|
264019
|
+
}
|
|
264020
|
+
async function readSharedFiles2(actorsDir) {
|
|
264021
|
+
const sharedDir = resolve13(actorsDir, "..", "shared");
|
|
264022
|
+
if (!await pathExists(sharedDir)) {
|
|
264023
|
+
return {};
|
|
264024
|
+
}
|
|
264025
|
+
const paths = await globby(BACKEND_FILE_GLOB, {
|
|
264026
|
+
cwd: sharedDir,
|
|
264027
|
+
absolute: true
|
|
264028
|
+
});
|
|
264029
|
+
const files = {};
|
|
264030
|
+
for (const path of paths.sort()) {
|
|
264031
|
+
files[`${SHARED_ROOT}/${forwardSlashed(sharedDir, path)}`] = await readTextFile(path);
|
|
264032
|
+
}
|
|
264033
|
+
return files;
|
|
264034
|
+
}
|
|
264035
|
+
async function compilerInput2(actor, shared) {
|
|
264036
|
+
const actorDir = dirname22(actor.entryPath);
|
|
264037
|
+
const entry = `${ACTORS_ROOT}/${actor.name}/entry.ts`;
|
|
264038
|
+
const source = await readTextFile(actor.entryPath);
|
|
264039
|
+
const candidates = { ...shared };
|
|
264040
|
+
for (const filePath of actor.filePaths) {
|
|
264041
|
+
if (filePath !== actor.entryPath) {
|
|
264042
|
+
candidates[`${ACTORS_ROOT}/${actor.name}/${forwardSlashed(actorDir, filePath)}`] = await readTextFile(filePath);
|
|
264043
|
+
}
|
|
264044
|
+
}
|
|
264045
|
+
candidates[entry] = source;
|
|
264046
|
+
return {
|
|
264047
|
+
entry,
|
|
264048
|
+
files: await collectReachableFiles(entry, candidates),
|
|
264049
|
+
source
|
|
264050
|
+
};
|
|
264051
|
+
}
|
|
264052
|
+
async function compileActors(actorsDir) {
|
|
264053
|
+
const actors = await readAllActors(actorsDir);
|
|
264054
|
+
if (actors.length === 0) {
|
|
264055
|
+
return [];
|
|
264056
|
+
}
|
|
264057
|
+
if (actors.length > MAX_ACTORS) {
|
|
264058
|
+
throw new InvalidInputError(`Too many actors: found ${actors.length}, the limit is ${MAX_ACTORS}.`);
|
|
264059
|
+
}
|
|
264060
|
+
await requireCompilerRuntime("Actors");
|
|
264061
|
+
const shared = await readSharedFiles2(actorsDir);
|
|
264062
|
+
const sorted = [...actors].sort((a, b) => a.name < b.name ? -1 : 1);
|
|
264063
|
+
const compiled = await pMap(sorted, async (actor) => {
|
|
264064
|
+
const input = await compilerInput2(actor, shared);
|
|
264065
|
+
const result = await bundle({ entry: input.entry, files: input.files });
|
|
264066
|
+
return {
|
|
264067
|
+
name: actor.name,
|
|
264068
|
+
entry: input.entry,
|
|
264069
|
+
source: input.source,
|
|
264070
|
+
result
|
|
264071
|
+
};
|
|
264072
|
+
}, { concurrency: COMPILE_CONCURRENCY });
|
|
264073
|
+
const failures = compiled.flatMap(({ name, result }) => result.ok ? [] : [
|
|
264074
|
+
{
|
|
264075
|
+
function: name,
|
|
264076
|
+
message: `Actor "${name}" failed to compile.`,
|
|
264077
|
+
errors: result.errors
|
|
264078
|
+
}
|
|
264079
|
+
]);
|
|
264080
|
+
if (failures.length > 0) {
|
|
264081
|
+
throw new InvalidInputError(`Actors failed to compile (${failures.length} error${failures.length === 1 ? "" : "s"}).`, { details: failures.map(describeFailure) });
|
|
264082
|
+
}
|
|
264083
|
+
return compiled.map(({ name, entry, source, result }) => {
|
|
264084
|
+
const module = new TextEncoder().encode(compiledModule(name, result));
|
|
264085
|
+
return {
|
|
264086
|
+
name,
|
|
264087
|
+
entry,
|
|
264088
|
+
source,
|
|
264089
|
+
module,
|
|
264090
|
+
size: module.byteLength,
|
|
264091
|
+
digest: sha256(module),
|
|
264092
|
+
staticEgress: STATIC_EGRESS_ARTIFACT_MARKER
|
|
264093
|
+
};
|
|
264094
|
+
});
|
|
264095
|
+
}
|
|
264096
|
+
function compiledModule(name, result) {
|
|
264097
|
+
if (!result.ok || result.do_class_name !== name) {
|
|
264098
|
+
throw new InternalError(`Actor "${name}" did not compile as an actor of that name.`);
|
|
264099
|
+
}
|
|
264100
|
+
return result.module;
|
|
264101
|
+
}
|
|
264102
|
+
|
|
261733
264103
|
// src/core/version/publish.ts
|
|
261734
264104
|
import { randomUUID as randomUUID4 } from "node:crypto";
|
|
261735
264105
|
var DEFAULT_ENVIRONMENT = "production";
|
|
@@ -261782,7 +264152,7 @@ async function collectBuildOutput(outputDir, options = {}) {
|
|
|
261782
264152
|
}
|
|
261783
264153
|
async function describeSiteWorker(built) {
|
|
261784
264154
|
const { config, modules } = built;
|
|
261785
|
-
const entry =
|
|
264155
|
+
const entry = resolve14(config.configDir, config.main);
|
|
261786
264156
|
const main = modules.find((m) => m.absolutePath === entry)?.name;
|
|
261787
264157
|
if (!main) {
|
|
261788
264158
|
throw new InvalidInputError(`The Worker's entry module ${config.main} is not among the ${modules.length} modules collected from ${config.configDir}.`);
|
|
@@ -261813,14 +264183,14 @@ async function readRawResources(dir) {
|
|
|
261813
264183
|
const payloads = {};
|
|
261814
264184
|
for (const relativePath of files.sort()) {
|
|
261815
264185
|
const name = relativePath.replace(/\.jsonc?$/, "");
|
|
261816
|
-
payloads[name] = await readJsonFile(
|
|
264186
|
+
payloads[name] = await readJsonFile(join30(dir, ...relativePath.split("/")));
|
|
261817
264187
|
}
|
|
261818
264188
|
return payloads;
|
|
261819
264189
|
}
|
|
261820
264190
|
async function collectResources(configDir, dirs) {
|
|
261821
264191
|
const [entities, agents] = await Promise.all([
|
|
261822
|
-
readRawResources(
|
|
261823
|
-
readRawResources(
|
|
264192
|
+
readRawResources(join30(configDir, dirs.entitiesDir)),
|
|
264193
|
+
readRawResources(join30(configDir, dirs.agentsDir))
|
|
261824
264194
|
]);
|
|
261825
264195
|
return { entities, agents };
|
|
261826
264196
|
}
|
|
@@ -261832,7 +264202,8 @@ async function collectArtifacts(target) {
|
|
|
261832
264202
|
entryFile: ENTRY2
|
|
261833
264203
|
}),
|
|
261834
264204
|
...siteWorker ? { siteWorker } : {},
|
|
261835
|
-
backendBundles: await tagStep2("build", () => compileBackendBundles(target.root,
|
|
264205
|
+
backendBundles: await tagStep2("build", () => compileBackendBundles(target.root, join30(target.configDir, target.functionsDir))),
|
|
264206
|
+
actors: await tagStep2("build", () => compileActors(join30(target.configDir, target.actorsDir))),
|
|
261836
264207
|
...await collectResources(target.configDir, target)
|
|
261837
264208
|
};
|
|
261838
264209
|
}
|
|
@@ -262049,7 +264420,7 @@ function writeFile3(appId, params) {
|
|
|
262049
264420
|
function editFile(appId, params) {
|
|
262050
264421
|
return callTool(appId, "edit_file", { ...params }, EditFileResponseSchema, `editing file "${params.path}"`);
|
|
262051
264422
|
}
|
|
262052
|
-
function
|
|
264423
|
+
function grep2(appId, params) {
|
|
262053
264424
|
return callTool(appId, "grep", { ...params }, GrepResponseSchema, "searching files");
|
|
262054
264425
|
}
|
|
262055
264426
|
function runCommand(appId, params) {
|
|
@@ -262153,10 +264524,10 @@ Examples:
|
|
|
262153
264524
|
}
|
|
262154
264525
|
|
|
262155
264526
|
// src/cli/commands/sandbox/grep.ts
|
|
262156
|
-
async function
|
|
264527
|
+
async function grepAction2({ runTask, branchId }, pattern, options) {
|
|
262157
264528
|
const { id: appId } = getAppContext();
|
|
262158
264529
|
const maxResults = parsePositiveInt(options.maxResults, "--max-results");
|
|
262159
|
-
const result = await runTask("Searching files", () =>
|
|
264530
|
+
const result = await runTask("Searching files", () => grep2(appId, {
|
|
262160
264531
|
pattern,
|
|
262161
264532
|
path: options.path,
|
|
262162
264533
|
is_regex: options.regex,
|
|
@@ -262168,7 +264539,7 @@ async function grepAction({ runTask, branchId }, pattern, options) {
|
|
|
262168
264539
|
return { outroMessage: "Searched files", stdout: toJsonStdout(result) };
|
|
262169
264540
|
}
|
|
262170
264541
|
function getSandboxGrepCommand() {
|
|
262171
|
-
return new Base44Command("grep", { supportsBranch: true }).description("Search files for a pattern in an app's remote sandbox").argument("<pattern>", "Search pattern").option("--path <path>", "Subtree to search, relative to the app root").option("--no-regex", "Treat the pattern as a literal string, not a regex").option("--case-sensitive", "Case-sensitive match").option("--glob <glob>", 'File glob filter, e.g. "*.tsx"').option("--max-results <n>", "Maximum number of match lines to return").action(
|
|
264542
|
+
return new Base44Command("grep", { supportsBranch: true }).description("Search files for a pattern in an app's remote sandbox").argument("<pattern>", "Search pattern").option("--path <path>", "Subtree to search, relative to the app root").option("--no-regex", "Treat the pattern as a literal string, not a regex").option("--case-sensitive", "Case-sensitive match").option("--glob <glob>", 'File glob filter, e.g. "*.tsx"').option("--max-results <n>", "Maximum number of match lines to return").action(grepAction2);
|
|
262172
264543
|
}
|
|
262173
264544
|
|
|
262174
264545
|
// src/cli/commands/sandbox/list-directory.ts
|
|
@@ -262290,7 +264661,7 @@ function getSecretsListCommand() {
|
|
|
262290
264661
|
}
|
|
262291
264662
|
|
|
262292
264663
|
// src/cli/commands/secrets/set.ts
|
|
262293
|
-
import { resolve as
|
|
264664
|
+
import { resolve as resolve15 } from "node:path";
|
|
262294
264665
|
function parseEntries(entries) {
|
|
262295
264666
|
const secrets = {};
|
|
262296
264667
|
for (const entry of entries) {
|
|
@@ -262321,7 +264692,7 @@ async function setSecretsAction({ log, runTask }, entries, options) {
|
|
|
262321
264692
|
validateInput(entries, options);
|
|
262322
264693
|
let secrets;
|
|
262323
264694
|
if (options.envFile) {
|
|
262324
|
-
secrets = await parseEnvFile(
|
|
264695
|
+
secrets = await parseEnvFile(resolve15(options.envFile));
|
|
262325
264696
|
if (Object.keys(secrets).length === 0) {
|
|
262326
264697
|
throw new InvalidInputError("The env file contains no valid KEY=VALUE entries.");
|
|
262327
264698
|
}
|
|
@@ -262350,7 +264721,7 @@ function getSecretsCommand() {
|
|
|
262350
264721
|
}
|
|
262351
264722
|
|
|
262352
264723
|
// src/cli/commands/site/deploy.ts
|
|
262353
|
-
import { resolve as
|
|
264724
|
+
import { resolve as resolve16 } from "node:path";
|
|
262354
264725
|
async function deployAction2(ctx, options) {
|
|
262355
264726
|
const { isNonInteractive } = ctx;
|
|
262356
264727
|
if (isNonInteractive && !options.yes) {
|
|
@@ -262419,7 +264790,7 @@ async function deployTarball({ runTask }, project) {
|
|
|
262419
264790
|
}
|
|
262420
264791
|
function siteOutputDir(project) {
|
|
262421
264792
|
const { outputDirectory = DEFAULT_SITE.outputDirectory } = siteOrDefault(project);
|
|
262422
|
-
return
|
|
264793
|
+
return resolve16(project.root, outputDirectory);
|
|
262423
264794
|
}
|
|
262424
264795
|
function getSiteDeployCommand() {
|
|
262425
264796
|
const command = new Base44Command("deploy").description("Deploy built site files to Base44 hosting").option("-y, --yes", "Skip confirmation prompt").option("--build", "Build the site before deploying (skips the prompt)").option("--no-build", "Deploy without building (skips the prompt)");
|
|
@@ -262763,10 +265134,10 @@ function toPascalCase(name) {
|
|
|
262763
265134
|
return name.split(/[-_\s]+/).map((w) => w.charAt(0).toUpperCase() + w.slice(1)).join("");
|
|
262764
265135
|
}
|
|
262765
265136
|
// src/core/types/update-project.ts
|
|
262766
|
-
import { join as
|
|
265137
|
+
import { join as join34 } from "node:path";
|
|
262767
265138
|
var TYPES_INCLUDE_PATH = `${PROJECT_SUBDIR}/${TYPES_OUTPUT_SUBDIR}/*.d.ts`;
|
|
262768
265139
|
async function updateProjectConfig(projectRoot) {
|
|
262769
|
-
const tsconfigPath =
|
|
265140
|
+
const tsconfigPath = join34(projectRoot, "tsconfig.json");
|
|
262770
265141
|
if (!await pathExists(tsconfigPath)) {
|
|
262771
265142
|
return false;
|
|
262772
265143
|
}
|
|
@@ -262985,7 +265356,7 @@ function rethrowLegacyAppAsExplanation(error) {
|
|
|
262985
265356
|
|
|
262986
265357
|
// src/cli/commands/workflows/limit.ts
|
|
262987
265358
|
var MAX_LIMIT = 200;
|
|
262988
|
-
function
|
|
265359
|
+
function parseLimit2(limit) {
|
|
262989
265360
|
if (limit === undefined)
|
|
262990
265361
|
return;
|
|
262991
265362
|
const parsed = Number.parseInt(limit, 10);
|
|
@@ -263002,7 +265373,7 @@ function formatWorkflowLine(workflow) {
|
|
|
263002
265373
|
return `${workflow.name} [${workflow.status}] runs: ${workflow.totalRuns}, ${lastRun}${failures}`;
|
|
263003
265374
|
}
|
|
263004
265375
|
async function listAction({ log, runTask, jsonMode }, options) {
|
|
263005
|
-
const limit =
|
|
265376
|
+
const limit = parseLimit2(options.limit);
|
|
263006
265377
|
const workflows = await runTask("Fetching workflows from Base44", async () => listWorkflows(limit).catch(rethrowLegacyAppAsExplanation), {
|
|
263007
265378
|
successMessage: "Workflows fetched successfully",
|
|
263008
265379
|
errorMessage: "Failed to fetch workflows"
|
|
@@ -263061,7 +265432,7 @@ async function describeEmptyResult(hasFilters) {
|
|
|
263061
265432
|
return hasFilters ? `No runs match your filters. Workflows in this app: ${names}.` : `No runs yet. Workflows in this app: ${names}.`;
|
|
263062
265433
|
}
|
|
263063
265434
|
async function runsAction(ctx, options) {
|
|
263064
|
-
const limit =
|
|
265435
|
+
const limit = parseLimit2(options.limit);
|
|
263065
265436
|
const runs = await ctx.runTask("Fetching workflow runs from Base44", async () => listWorkflowRuns({
|
|
263066
265437
|
status: options.status,
|
|
263067
265438
|
since: options.since,
|
|
@@ -263247,7 +265618,7 @@ function getWorkspaceCommand() {
|
|
|
263247
265618
|
// src/cli/dev/dev-server/main.ts
|
|
263248
265619
|
var import_cors = __toESM(require_lib4(), 1);
|
|
263249
265620
|
var import_express6 = __toESM(require_express(), 1);
|
|
263250
|
-
import { dirname as
|
|
265621
|
+
import { dirname as dirname28, join as join39 } from "node:path";
|
|
263251
265622
|
|
|
263252
265623
|
// ../../node_modules/get-port/index.js
|
|
263253
265624
|
import net from "node:net";
|
|
@@ -263377,7 +265748,7 @@ var $tmpName = promisify12(tmp.tmpName);
|
|
|
263377
265748
|
|
|
263378
265749
|
// src/cli/dev/dev-server/function-manager.ts
|
|
263379
265750
|
import { spawn as spawn3 } from "node:child_process";
|
|
263380
|
-
import { dirname as
|
|
265751
|
+
import { dirname as dirname25, join as join35 } from "node:path";
|
|
263381
265752
|
import { pathToFileURL as pathToFileURL6 } from "node:url";
|
|
263382
265753
|
|
|
263383
265754
|
// src/cli/dev/dev-server/base-function-manager.ts
|
|
@@ -263482,7 +265853,7 @@ class FunctionManager extends BaseFunctionManager {
|
|
|
263482
265853
|
}
|
|
263483
265854
|
spawnFunction(func, port) {
|
|
263484
265855
|
this.logger.log(`Spawning function "${func.name}" on port ${port}`);
|
|
263485
|
-
const importMapPath =
|
|
265856
|
+
const importMapPath = join35(dirname25(this.wrapperPath), "import-map.json");
|
|
263486
265857
|
const process2 = spawn3("deno", ["run", "--allow-all", "--import-map", importMapPath, this.wrapperPath], {
|
|
263487
265858
|
env: {
|
|
263488
265859
|
...globalThis.process.env,
|
|
@@ -263556,7 +265927,7 @@ class FunctionManager extends BaseFunctionManager {
|
|
|
263556
265927
|
import { mkdirSync as mkdirSync2, writeFileSync as writeFileSync2 } from "node:fs";
|
|
263557
265928
|
import { isBuiltin as isBuiltin3 } from "node:module";
|
|
263558
265929
|
import { homedir as homedir4 } from "node:os";
|
|
263559
|
-
import { join as
|
|
265930
|
+
import { join as join36 } from "node:path";
|
|
263560
265931
|
import { pathToFileURL as pathToFileURL7 } from "node:url";
|
|
263561
265932
|
var depsPromise;
|
|
263562
265933
|
function loadDeps() {
|
|
@@ -263677,9 +266048,9 @@ export default {
|
|
|
263677
266048
|
};
|
|
263678
266049
|
`;
|
|
263679
266050
|
function ensureBundlerConfig() {
|
|
263680
|
-
const dir =
|
|
266051
|
+
const dir = join36(homedir4(), ".base44", "function-bundler");
|
|
263681
266052
|
mkdirSync2(dir, { recursive: true });
|
|
263682
|
-
const configPath =
|
|
266053
|
+
const configPath = join36(dir, "deno.json");
|
|
263683
266054
|
writeFileSync2(configPath, `${JSON.stringify({ nodeModulesDir: "auto" }, null, 2)}
|
|
263684
266055
|
`);
|
|
263685
266056
|
return configPath;
|
|
@@ -265211,16 +267582,16 @@ function createCustomIntegrationRoutes(remoteProxy, logger) {
|
|
|
265211
267582
|
|
|
265212
267583
|
// src/cli/dev/dev-server/watcher.ts
|
|
265213
267584
|
import { EventEmitter as EventEmitter4 } from "node:events";
|
|
265214
|
-
import { relative as
|
|
267585
|
+
import { relative as relative11 } from "node:path";
|
|
265215
267586
|
|
|
265216
267587
|
// ../../node_modules/chokidar/index.js
|
|
265217
267588
|
import { EventEmitter as EventEmitter3 } from "node:events";
|
|
265218
267589
|
import { stat as statcb, Stats } from "node:fs";
|
|
265219
|
-
import { readdir as readdir3, stat as
|
|
267590
|
+
import { readdir as readdir3, stat as stat7 } from "node:fs/promises";
|
|
265220
267591
|
import * as sp3 from "node:path";
|
|
265221
267592
|
|
|
265222
267593
|
// ../../node_modules/readdirp/index.js
|
|
265223
|
-
import { lstat as lstat2, readdir as readdir2, realpath, stat as
|
|
267594
|
+
import { lstat as lstat2, readdir as readdir2, realpath, stat as stat5 } from "node:fs/promises";
|
|
265224
267595
|
import { join as pjoin, relative as prelative, resolve as presolve, sep as psep } from "node:path";
|
|
265225
267596
|
import { Readable as Readable6 } from "node:stream";
|
|
265226
267597
|
var EntryTypes = {
|
|
@@ -265229,7 +267600,7 @@ var EntryTypes = {
|
|
|
265229
267600
|
FILE_DIR_TYPE: "files_directories",
|
|
265230
267601
|
EVERYTHING_TYPE: "all"
|
|
265231
267602
|
};
|
|
265232
|
-
var
|
|
267603
|
+
var defaultOptions2 = {
|
|
265233
267604
|
root: ".",
|
|
265234
267605
|
fileFilter: (_entryInfo) => true,
|
|
265235
267606
|
directoryFilter: (_entryInfo) => true,
|
|
@@ -265239,7 +267610,7 @@ var defaultOptions = {
|
|
|
265239
267610
|
alwaysStat: false,
|
|
265240
267611
|
highWaterMark: 4096
|
|
265241
267612
|
};
|
|
265242
|
-
Object.freeze(
|
|
267613
|
+
Object.freeze(defaultOptions2);
|
|
265243
267614
|
var RECURSIVE_ERROR_CODE = "READDIRP_RECURSIVE_ERROR";
|
|
265244
267615
|
var NORMAL_FLOW_ERRORS = new Set(["ENOENT", "EPERM", "EACCES", "ELOOP", RECURSIVE_ERROR_CODE]);
|
|
265245
267616
|
var ALL_TYPES = [
|
|
@@ -265298,17 +267669,17 @@ class ReaddirpStream extends Readable6 {
|
|
|
265298
267669
|
autoDestroy: true,
|
|
265299
267670
|
highWaterMark: options.highWaterMark
|
|
265300
267671
|
});
|
|
265301
|
-
const opts = { ...
|
|
267672
|
+
const opts = { ...defaultOptions2, ...options };
|
|
265302
267673
|
const { root, type } = opts;
|
|
265303
267674
|
this._fileFilter = normalizeFilter(opts.fileFilter);
|
|
265304
267675
|
this._directoryFilter = normalizeFilter(opts.directoryFilter);
|
|
265305
|
-
const statMethod = opts.lstat ? lstat2 :
|
|
267676
|
+
const statMethod = opts.lstat ? lstat2 : stat5;
|
|
265306
267677
|
if (wantBigintFsStats) {
|
|
265307
267678
|
this._stat = (path) => statMethod(path, { bigint: true });
|
|
265308
267679
|
} else {
|
|
265309
267680
|
this._stat = statMethod;
|
|
265310
267681
|
}
|
|
265311
|
-
this._maxDepth = opts.depth != null && Number.isSafeInteger(opts.depth) ? opts.depth :
|
|
267682
|
+
this._maxDepth = opts.depth != null && Number.isSafeInteger(opts.depth) ? opts.depth : defaultOptions2.depth;
|
|
265312
267683
|
this._wantsDir = type ? DIR_TYPES.has(type) : false;
|
|
265313
267684
|
this._wantsFile = type ? FILE_TYPES2.has(type) : false;
|
|
265314
267685
|
this._wantsEverything = type === EntryTypes.EVERYTHING_TYPE;
|
|
@@ -265455,7 +267826,7 @@ function readdirp(root, options = {}) {
|
|
|
265455
267826
|
|
|
265456
267827
|
// ../../node_modules/chokidar/handler.js
|
|
265457
267828
|
import { watch as fs_watch, unwatchFile, watchFile } from "node:fs";
|
|
265458
|
-
import { realpath as fsrealpath, lstat as lstat3, open as open2, stat as
|
|
267829
|
+
import { realpath as fsrealpath, lstat as lstat3, open as open2, stat as stat6 } from "node:fs/promises";
|
|
265459
267830
|
import { type as osType } from "node:os";
|
|
265460
267831
|
import * as sp2 from "node:path";
|
|
265461
267832
|
var STR_DATA = "data";
|
|
@@ -265481,7 +267852,7 @@ var EVENTS = {
|
|
|
265481
267852
|
};
|
|
265482
267853
|
var EV = EVENTS;
|
|
265483
267854
|
var THROTTLE_MODE_WATCH = "watch";
|
|
265484
|
-
var statMethods = { lstat: lstat3, stat:
|
|
267855
|
+
var statMethods = { lstat: lstat3, stat: stat6 };
|
|
265485
267856
|
var KEY_LISTENERS = "listeners";
|
|
265486
267857
|
var KEY_ERR = "errHandlers";
|
|
265487
267858
|
var KEY_RAW = "rawEmitters";
|
|
@@ -265952,7 +268323,7 @@ class NodeFsHandler {
|
|
|
265952
268323
|
return;
|
|
265953
268324
|
if (!newStats || newStats.mtimeMs === 0) {
|
|
265954
268325
|
try {
|
|
265955
|
-
const newStats = await
|
|
268326
|
+
const newStats = await stat6(file);
|
|
265956
268327
|
if (this.fsw.closed)
|
|
265957
268328
|
return;
|
|
265958
268329
|
const at = newStats.atimeMs;
|
|
@@ -266204,7 +268575,7 @@ function createPattern(matcher) {
|
|
|
266204
268575
|
}
|
|
266205
268576
|
return () => false;
|
|
266206
268577
|
}
|
|
266207
|
-
function
|
|
268578
|
+
function normalizePath2(path) {
|
|
266208
268579
|
if (typeof path !== "string")
|
|
266209
268580
|
throw new Error("string expected");
|
|
266210
268581
|
path = sp3.normalize(path);
|
|
@@ -266218,7 +268589,7 @@ function normalizePath(path) {
|
|
|
266218
268589
|
return path;
|
|
266219
268590
|
}
|
|
266220
268591
|
function matchPatterns(patterns, testString, stats) {
|
|
266221
|
-
const path =
|
|
268592
|
+
const path = normalizePath2(testString);
|
|
266222
268593
|
for (let index = 0;index < patterns.length; index++) {
|
|
266223
268594
|
const pattern = patterns[index];
|
|
266224
268595
|
if (pattern(path, stats)) {
|
|
@@ -266624,7 +268995,7 @@ class FSWatcher extends EventEmitter3 {
|
|
|
266624
268995
|
const fullPath = opts.cwd ? sp3.join(opts.cwd, path) : path;
|
|
266625
268996
|
let stats;
|
|
266626
268997
|
try {
|
|
266627
|
-
stats = await
|
|
268998
|
+
stats = await stat7(fullPath);
|
|
266628
268999
|
} catch (err) {}
|
|
266629
269000
|
if (!stats || this.closed)
|
|
266630
269001
|
return;
|
|
@@ -266896,7 +269267,7 @@ class WatchBase44 extends EventEmitter4 {
|
|
|
266896
269267
|
ignoreInitial: true
|
|
266897
269268
|
});
|
|
266898
269269
|
watcher.on("all", import_debounce.default(async (_event, path) => {
|
|
266899
|
-
this.emit("change", name,
|
|
269270
|
+
this.emit("change", name, relative11(targetPath, path));
|
|
266900
269271
|
}, WATCH_DEBOUNCE_MS));
|
|
266901
269272
|
watcher.on("error", (err) => {
|
|
266902
269273
|
this.logger.error(`Watch handler failed for ${targetPath}`, err);
|
|
@@ -267008,8 +269379,8 @@ async function createDevServer(options) {
|
|
|
267008
269379
|
broadcastEntityEvent(io, appId, entityName, event);
|
|
267009
269380
|
};
|
|
267010
269381
|
const base44ConfigWatcher = new WatchBase44({
|
|
267011
|
-
functions:
|
|
267012
|
-
entities:
|
|
269382
|
+
functions: join39(dirname28(project.configPath), project.functionsDir),
|
|
269383
|
+
entities: join39(dirname28(project.configPath), project.entitiesDir)
|
|
267013
269384
|
}, devLogger);
|
|
267014
269385
|
base44ConfigWatcher.on("change", async (name) => {
|
|
267015
269386
|
try {
|
|
@@ -267212,7 +269583,7 @@ function readExecEnvTarget(env = process.env) {
|
|
|
267212
269583
|
// src/core/exec/run-script.ts
|
|
267213
269584
|
import { spawn as spawn4 } from "node:child_process";
|
|
267214
269585
|
import { readFileSync as readFileSync4, writeFileSync as writeFileSync3 } from "node:fs";
|
|
267215
|
-
import { join as
|
|
269586
|
+
import { join as join40 } from "node:path";
|
|
267216
269587
|
var SDK_SPECIFIER = '"npm:@base44/sdk"';
|
|
267217
269588
|
function wrapperSource(sdkVersion) {
|
|
267218
269589
|
const source = readFileSync4(getExecWrapperPath(), "utf-8");
|
|
@@ -267248,7 +269619,7 @@ async function runScript(options) {
|
|
|
267248
269619
|
writeFileSync3(tempWrapper.path, wrapperSource(sdkVersion), "utf-8");
|
|
267249
269620
|
const configDir = await $dir({ unsafeCleanup: true });
|
|
267250
269621
|
cleanupFns.push(configDir.cleanup);
|
|
267251
|
-
const configPath =
|
|
269622
|
+
const configPath = join40(configDir.path, "deno.json");
|
|
267252
269623
|
writeFileSync3(configPath, JSON.stringify(DENO_CONFIG), "utf-8");
|
|
267253
269624
|
try {
|
|
267254
269625
|
const exitCode = await new Promise((resolvePromise) => {
|
|
@@ -267369,7 +269740,7 @@ Examples:
|
|
|
267369
269740
|
}
|
|
267370
269741
|
|
|
267371
269742
|
// src/cli/commands/project/eject.ts
|
|
267372
|
-
import { resolve as
|
|
269743
|
+
import { resolve as resolve20 } from "node:path";
|
|
267373
269744
|
var import_kebabCase2 = __toESM(require_kebabCase(), 1);
|
|
267374
269745
|
async function eject(ctx, options, command) {
|
|
267375
269746
|
const { log, runTask, isNonInteractive } = ctx;
|
|
@@ -267433,7 +269804,7 @@ async function eject(ctx, options, command) {
|
|
|
267433
269804
|
Ne("Operation cancelled.");
|
|
267434
269805
|
throw new CLIExitError(0);
|
|
267435
269806
|
}
|
|
267436
|
-
const resolvedPath =
|
|
269807
|
+
const resolvedPath = resolve20(selectedPath);
|
|
267437
269808
|
await runTask("Downloading your project's code...", async (updateMessage) => {
|
|
267438
269809
|
await createProjectFilesForExistingProject({
|
|
267439
269810
|
projectId,
|
|
@@ -267520,6 +269891,7 @@ function createProgram(context) {
|
|
|
267520
269891
|
program.addCommand(getSecretsCommand());
|
|
267521
269892
|
program.addCommand(getSandboxCommand());
|
|
267522
269893
|
program.addCommand(getBranchesCommand());
|
|
269894
|
+
program.addCommand(getApiCommand());
|
|
267523
269895
|
program.addCommand(getAuthCommand());
|
|
267524
269896
|
program.addCommand(getSiteCommand());
|
|
267525
269897
|
if (versionsApiEnabled()) {
|
|
@@ -267538,7 +269910,7 @@ var import_detect_agent = __toESM(require_dist5(), 1);
|
|
|
267538
269910
|
import { release, type } from "node:os";
|
|
267539
269911
|
|
|
267540
269912
|
// ../../node_modules/posthog-node/dist/extensions/error-tracking/modifiers/module.node.mjs
|
|
267541
|
-
import { dirname as
|
|
269913
|
+
import { dirname as dirname29, posix, sep as sep2 } from "path";
|
|
267542
269914
|
function createModulerModifier() {
|
|
267543
269915
|
const getModuleFromFileName = createGetModuleFromFilename();
|
|
267544
269916
|
return async (frames) => {
|
|
@@ -267547,7 +269919,7 @@ function createModulerModifier() {
|
|
|
267547
269919
|
return frames;
|
|
267548
269920
|
};
|
|
267549
269921
|
}
|
|
267550
|
-
function createGetModuleFromFilename(basePath = process.argv[1] ?
|
|
269922
|
+
function createGetModuleFromFilename(basePath = process.argv[1] ? dirname29(process.argv[1]) : process.cwd(), isWindows = sep2 === "\\") {
|
|
267551
269923
|
const normalizedBase = isWindows ? normalizeWindowsPath2(basePath) : basePath;
|
|
267552
269924
|
return (filename) => {
|
|
267553
269925
|
if (!filename)
|
|
@@ -271536,9 +273908,9 @@ function addCommandInfoToErrorReporter(program, errorReporter) {
|
|
|
271536
273908
|
});
|
|
271537
273909
|
}
|
|
271538
273910
|
// src/cli/index.ts
|
|
271539
|
-
var __dirname4 =
|
|
273911
|
+
var __dirname4 = dirname30(fileURLToPath7(import.meta.url));
|
|
271540
273912
|
async function runCLI(options) {
|
|
271541
|
-
ensureNpmAssets(
|
|
273913
|
+
ensureNpmAssets(join41(__dirname4, "../assets"));
|
|
271542
273914
|
const errorReporter = new ErrorReporter;
|
|
271543
273915
|
errorReporter.registerProcessErrorHandlers();
|
|
271544
273916
|
const jsonMode = process.argv.includes("--json");
|
|
@@ -271577,4 +273949,4 @@ export {
|
|
|
271577
273949
|
runCLI
|
|
271578
273950
|
};
|
|
271579
273951
|
|
|
271580
|
-
//# debugId=
|
|
273952
|
+
//# debugId=9B0010644779EACB64756E2164756E21
|