@base44-preview/cli 0.1.32-pr.663.7602773 → 0.1.32-pr.663.a2a6b70

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli/index.js CHANGED
@@ -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")), ...rm2(n, t, s)], { shouldBreak: i });
39573
+ return l(["<", r("name"), r("typeArguments"), m(e.map(() => [o, r()], "attributes")), ...rm3(n, t, s)], { shouldBreak: i });
39574
39574
  }
39575
- function rm2(e, t, r) {
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 rm3(e, t, a) {
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: rm3, 194: rm3, 195: function(t, a, _) {
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 tokenize(value, options8) {
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 tokenize2(text)) {
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, tokenize2, NEWLINE, getOffsets = ({
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
@@ -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 = 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
- tokenize2 = function* (text) {
134351
+ tokenize22 = function* (text) {
134352
134352
  for (const token2 of (0, import_js_tokens.default)(text, {
134353
134353
  jsx: true
134354
134354
  })) {
@@ -247587,8 +247587,8 @@ function normalizeDatetime(value) {
247587
247587
  return `${value}Z`;
247588
247588
  }
247589
247589
  // src/cli/utils/json.ts
247590
- function toJsonStdout(result) {
247591
- return `${JSON.stringify(result, null, 2)}
247590
+ function toJsonStdout(result, options = {}) {
247591
+ return `${JSON.stringify(result, null, options.compact ? undefined : 2)}
247592
247592
  `;
247593
247593
  }
247594
247594
  // src/cli/errors.ts
@@ -249102,24 +249102,30 @@ var wait = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
249102
249102
  var SPACE_OR_PUNCTUATION = /[\n\r\p{Z}\p{P}]+/u;
249103
249103
 
249104
249104
  // src/core/api-spec/search.ts
249105
- var BOOST = { path: 8, summary: 5, description: 2, parameters: 0.5 };
249105
+ var BOOST = {
249106
+ method: 1,
249107
+ path: 8,
249108
+ summary: 5,
249109
+ description: 2,
249110
+ parameters: 0.5
249111
+ };
249106
249112
  var MIN_RELATIVE_SCORE = 0.2;
249107
249113
  var TOKEN_SEPARATOR = /[\n\r\p{Z}\p{P}\p{S}]+/u;
249114
+ var STOPWORDS = new Set("a an and are at be by do does for from how i id in is it its me my of on or our that the this to we what who with you your".split(" "));
249115
+ function tokenize(text) {
249116
+ return text.split(TOKEN_SEPARATOR).filter((word) => word.length >= 2 && !STOPWORDS.has(word.toLowerCase()));
249117
+ }
249108
249118
  function toOperationSummary(op) {
249109
- return {
249110
- method: op.method,
249111
- path: op.path,
249112
- summary: op.summary,
249113
- readOnly: op.readOnly
249114
- };
249119
+ return { endpoint: op.endpoint, summary: op.summary };
249115
249120
  }
249116
249121
  function buildSearchIndex(operations) {
249117
249122
  const index = new MiniSearch({
249118
- fields: ["path", "summary", "description", "parameters"],
249119
- tokenize: (text) => text.split(TOKEN_SEPARATOR).filter(Boolean)
249123
+ fields: ["method", "path", "summary", "description", "parameters"],
249124
+ tokenize
249120
249125
  });
249121
249126
  index.addAll(operations.map((op, id) => ({
249122
249127
  id,
249128
+ method: op.method,
249123
249129
  path: op.path.replace(/\{[^}]*\}/g, ""),
249124
249130
  summary: op.summary,
249125
249131
  description: op.description,
@@ -249127,16 +249133,37 @@ function buildSearchIndex(operations) {
249127
249133
  })));
249128
249134
  return index;
249129
249135
  }
249136
+ function summaryMatch(terms, op) {
249137
+ const words = tokenize(op?.summary.toLowerCase() ?? "");
249138
+ const named = (word) => terms.some((term) => word.startsWith(term));
249139
+ return {
249140
+ coverage: terms.filter((term) => words.some((word) => word.startsWith(term))).length / terms.length,
249141
+ precision: words.length ? words.filter(named).length / words.length : 0
249142
+ };
249143
+ }
249144
+ var readsFirst = (op) => op?.method === "GET" ? 0 : 1;
249130
249145
  function searchOperations(operations, query, options = {}) {
249146
+ const terms = tokenize(query.toLowerCase());
249147
+ if (terms.length === 0) {
249148
+ return [];
249149
+ }
249131
249150
  const index = buildSearchIndex(operations);
249132
249151
  const hits = index.search(query, {
249133
- prefix: true,
249134
- fuzzy: 0.2,
249152
+ prefix: (term) => term.length >= 3,
249153
+ fuzzy: (term) => term.length >= 4 ? 0.2 : false,
249135
249154
  boost: BOOST,
249136
249155
  filter: options.readOnly ? (hit) => operations[hit.id]?.readOnly === true : undefined
249137
- });
249138
- const baseline = (hits[0]?.score ?? 0) * MIN_RELATIVE_SCORE;
249139
- return hits.filter((hit) => hit.score >= baseline).slice(0, options.limit ?? 5).flatMap((hit) => {
249156
+ }).map((hit) => {
249157
+ const match = summaryMatch(terms, operations[hit.id]);
249158
+ return {
249159
+ ...hit,
249160
+ ...match,
249161
+ full: match.coverage === 1,
249162
+ score: hit.score * (1 + match.coverage)
249163
+ };
249164
+ }).sort((a, b) => Number(b.full) - Number(a.full) || (a.full ? b.precision - a.precision || readsFirst(operations[a.id]) - readsFirst(operations[b.id]) : 0) || b.score - a.score);
249165
+ const baseline = Math.max(0, ...hits.map((hit) => hit.score)) * MIN_RELATIVE_SCORE;
249166
+ return hits.filter((hit) => hit.full || hit.score >= baseline).slice(0, options.limit ?? 5).flatMap((hit) => {
249140
249167
  const op = operations[hit.id];
249141
249168
  return op ? [toOperationSummary(op)] : [];
249142
249169
  });
@@ -249145,6 +249172,7 @@ function searchOperations(operations, query, options = {}) {
249145
249172
  // src/core/api-spec/catalog.ts
249146
249173
  var INLINE_AREA_MAX = 2;
249147
249174
  var AREA_SAMPLE_MAX = 3;
249175
+ var AREA_OPERATIONS_MAX = 200;
249148
249176
  var byCodePoint = (a, b) => a < b ? -1 : a > b ? 1 : 0;
249149
249177
  function areaOf(path) {
249150
249178
  const parts = path.split("/").filter(Boolean);
@@ -249166,48 +249194,25 @@ function groupByArea(operations) {
249166
249194
  }
249167
249195
  return new Map([...areas].sort(([a], [b]) => byCodePoint(a, b)));
249168
249196
  }
249197
+ function readsFirst2(ops) {
249198
+ const isRead = (op) => op.method === "GET" ? 0 : 1;
249199
+ return [...ops].sort((a, b) => isRead(a) - isRead(b));
249200
+ }
249169
249201
  function catalogIndex(operations) {
249170
249202
  const areas = [...groupByArea(operations)].map(([area, ops]) => ops.length <= INLINE_AREA_MAX ? { area, operations: ops.map(toOperationSummary) } : {
249171
249203
  area,
249172
249204
  operationCount: ops.length,
249173
- sample: ops.slice(0, AREA_SAMPLE_MAX).map((op) => op.summary)
249205
+ sample: readsFirst2(ops).slice(0, AREA_SAMPLE_MAX).map((op) => op.summary)
249174
249206
  });
249175
249207
  return { areas, total: operations.length };
249176
249208
  }
249177
- // src/core/api-spec/grep.ts
249178
- var CONTEXT_CHARS = 40;
249179
- var MAX_SNIPPETS = 3;
249180
- var MAX_SNIPPET_CHARS = 200;
249181
- function snippets(text, pattern) {
249182
- const found = [];
249183
- for (const match of text.matchAll(pattern)) {
249184
- const start = Math.max(0, match.index - CONTEXT_CHARS);
249185
- const end = match.index + match[0].length + CONTEXT_CHARS;
249186
- found.push(text.slice(start, Math.min(end, start + MAX_SNIPPET_CHARS)));
249187
- if (found.length === MAX_SNIPPETS || match[0].length === 0) {
249188
- break;
249189
- }
249190
- }
249191
- return found;
249192
- }
249193
- function grepSpec(spec, operations, pattern, options = {}) {
249194
- const regex = new RegExp(pattern, options.ignoreCase ? "gi" : "g");
249195
- const hits = [];
249196
- const inArea = (op) => options.area === undefined || areaOf(op.path) === options.area;
249197
- for (const op of operations.filter(inArea)) {
249198
- const matches = snippets(`${op.method} ${op.path} ${JSON.stringify(op.operation)}`, regex);
249199
- if (matches.length > 0) {
249200
- hits.push({ ...toOperationSummary(op), matches });
249201
- }
249202
- }
249203
- const schemas = options.area === undefined ? spec.components?.schemas : {};
249204
- for (const [schema, definition] of Object.entries(schemas ?? {})) {
249205
- const matches = snippets(JSON.stringify(definition), regex);
249206
- if (matches.length > 0) {
249207
- hits.push({ schema, matches });
249208
- }
249209
- }
249210
- return hits.slice(0, options.limit ?? 20);
249209
+ function areaListing(area, operations, max = AREA_OPERATIONS_MAX) {
249210
+ return {
249211
+ area,
249212
+ operations: operations.slice(0, max).map(toOperationSummary),
249213
+ total: operations.length,
249214
+ truncated: operations.length > max
249215
+ };
249211
249216
  }
249212
249217
  // src/core/api-spec/schema.ts
249213
249218
  var HTTP_METHODS = [
@@ -249225,7 +249230,16 @@ var ParameterSchema = looseObject({
249225
249230
  in: string2(),
249226
249231
  required: boolean2().optional(),
249227
249232
  description: string2().optional(),
249228
- schema: unknown().optional()
249233
+ schema: unknown().optional(),
249234
+ example: unknown().optional()
249235
+ });
249236
+ var MediaTypesSchema = record(string2(), looseObject({ schema: unknown().optional() }));
249237
+ var MediaContentSchema = looseObject({
249238
+ content: MediaTypesSchema.optional()
249239
+ });
249240
+ var ResponseObjectSchema = looseObject({
249241
+ description: string2().optional(),
249242
+ content: MediaTypesSchema.optional()
249229
249243
  });
249230
249244
  var SecurityRequirementSchema = record(string2(), array(string2()));
249231
249245
  var OperationSchema = looseObject({
@@ -249237,7 +249251,10 @@ var OperationSchema = looseObject({
249237
249251
  responses: record(string2(), unknown()).optional(),
249238
249252
  security: array(SecurityRequirementSchema).optional()
249239
249253
  });
249240
- var PathItemSchema = looseObject(Object.fromEntries(HTTP_METHODS.map((method) => [method, OperationSchema.optional()])));
249254
+ var PathItemSchema = looseObject({
249255
+ ...Object.fromEntries(HTTP_METHODS.map((method) => [method, OperationSchema.optional()])),
249256
+ parameters: array(unknown()).optional()
249257
+ });
249241
249258
  var OpenApiSpecSchema = looseObject({
249242
249259
  openapi: string2(),
249243
249260
  paths: record(string2(), PathItemSchema),
@@ -249247,6 +249264,152 @@ var OpenApiSpecSchema = looseObject({
249247
249264
  security: array(SecurityRequirementSchema).optional()
249248
249265
  });
249249
249266
 
249267
+ // src/core/api-spec/text.ts
249268
+ var DOCS_CALLOUT = /<(Info|Note|Tip|Check|Warning)>([\s\S]*?)<\/\1>/g;
249269
+ var RELATIVE_LINK = /\[([^\]]+)\]\(\/[^)]*\)/g;
249270
+ function cleanText(text) {
249271
+ return text.replace(DOCS_CALLOUT, (_, kind, body) => kind === "Warning" ? `Warning: ${body}` : body).replace(RELATIVE_LINK, "$1");
249272
+ }
249273
+
249274
+ // src/core/api-spec/contract.ts
249275
+ var SCHEMA_REF_PREFIX = "#/components/schemas/";
249276
+ var MAX_REF_DEPTH = 4;
249277
+ function inlineRefs(node, schemas, seen = new Set, depth = 0) {
249278
+ if (depth > MAX_REF_DEPTH) {
249279
+ return node;
249280
+ }
249281
+ if (Array.isArray(node)) {
249282
+ return node.map((item) => inlineRefs(item, schemas, seen, depth));
249283
+ }
249284
+ if (node === null || typeof node !== "object") {
249285
+ return node;
249286
+ }
249287
+ const { $ref, ...siblings } = node;
249288
+ if (typeof $ref === "string" && $ref.startsWith(SCHEMA_REF_PREFIX)) {
249289
+ const name = $ref.slice(SCHEMA_REF_PREFIX.length);
249290
+ if (seen.has(name) || !(name in schemas)) {
249291
+ return node;
249292
+ }
249293
+ const resolved = inlineRefs(schemas[name], schemas, new Set([...seen, name]), depth + 1);
249294
+ return resolved !== null && typeof resolved === "object" ? { ...resolved, ...siblings } : resolved;
249295
+ }
249296
+ return Object.fromEntries(Object.entries(node).map(([key, value]) => [
249297
+ key,
249298
+ inlineRefs(value, schemas, seen, depth)
249299
+ ]));
249300
+ }
249301
+ function bodyOf(value) {
249302
+ const parsed = MediaContentSchema.safeParse(value);
249303
+ const content = parsed.success ? parsed.data.content ?? {} : {};
249304
+ const contentType = "application/json" in content ? "application/json" : Object.keys(content)[0];
249305
+ return contentType ? { contentType, schema: content[contentType]?.schema } : {};
249306
+ }
249307
+ function leftoverRefs(node, schemas, found = new Map) {
249308
+ if (Array.isArray(node)) {
249309
+ for (const item of node) {
249310
+ leftoverRefs(item, schemas, found);
249311
+ }
249312
+ } else if (node !== null && typeof node === "object") {
249313
+ for (const [key, value] of Object.entries(node)) {
249314
+ if (key === "$ref" && typeof value === "string" && value.startsWith(SCHEMA_REF_PREFIX) && !found.has(value)) {
249315
+ const schema = schemas[value.slice(SCHEMA_REF_PREFIX.length)];
249316
+ if (schema !== undefined) {
249317
+ found.set(value, schema);
249318
+ leftoverRefs(schema, schemas, found);
249319
+ }
249320
+ } else {
249321
+ leftoverRefs(value, schemas, found);
249322
+ }
249323
+ }
249324
+ }
249325
+ return found;
249326
+ }
249327
+ var SCHEMA_DATA_KEYS = new Set([
249328
+ "example",
249329
+ "examples",
249330
+ "default",
249331
+ "enum",
249332
+ "const"
249333
+ ]);
249334
+ function slimSchema(node, isPropertyMap = false) {
249335
+ if (Array.isArray(node)) {
249336
+ return node.map((item) => slimSchema(item));
249337
+ }
249338
+ if (node === null || typeof node !== "object") {
249339
+ return node;
249340
+ }
249341
+ const entries = Object.entries(node);
249342
+ if (isPropertyMap) {
249343
+ return Object.fromEntries(entries.map(([name, value]) => [name, slimSchema(value)]));
249344
+ }
249345
+ const slim = {};
249346
+ for (const [key, value] of entries) {
249347
+ if (key === "title" && typeof value === "string") {
249348
+ continue;
249349
+ }
249350
+ slim[key] = SCHEMA_DATA_KEYS.has(key) ? value : key === "properties" ? slimSchema(value, true) : key === "description" && typeof value === "string" ? cleanText(value) : slimSchema(value);
249351
+ }
249352
+ const { anyOf, ...rest } = slim;
249353
+ const nullable = Array.isArray(anyOf) && anyOf.length === 2 ? nullableType(anyOf) : undefined;
249354
+ return nullable ? { type: [nullable, "null"], ...rest } : slim;
249355
+ }
249356
+ function nullableType(variants) {
249357
+ const types = variants.map((variant) => variant !== null && typeof variant === "object" && Object.keys(variant).length === 1 && typeof variant.type === "string" ? variant.type : undefined);
249358
+ if (types.includes(undefined) || !types.includes("null")) {
249359
+ return;
249360
+ }
249361
+ return types.find((type) => type !== "null");
249362
+ }
249363
+ function getOperationContract(spec, op) {
249364
+ const schemas = spec.components?.schemas ?? {};
249365
+ const inline = (node) => node === undefined ? null : slimSchema(inlineRefs(node, schemas));
249366
+ const responses = Object.entries(op.operation.responses ?? {}).flatMap(([status, response]) => {
249367
+ const parsed = ResponseObjectSchema.safeParse(response);
249368
+ return parsed.success ? [[status, parsed.data]] : [];
249369
+ });
249370
+ const success = responses.filter(([status]) => status.startsWith("2")).sort(([a], [b]) => a.localeCompare(b)).map(([, response]) => bodyOf(response).schema).find(Boolean);
249371
+ const requestBody = bodyOf(op.operation.requestBody);
249372
+ const contract = {
249373
+ endpoint: op.endpoint,
249374
+ method: op.method,
249375
+ path: op.path,
249376
+ summary: op.summary,
249377
+ description: op.description,
249378
+ parameters: (op.operation.parameters ?? []).flatMap((parameter) => {
249379
+ const parsed = ParameterSchema.safeParse(parameter);
249380
+ if (!parsed.success) {
249381
+ return [];
249382
+ }
249383
+ const { name, in: location2, required, schema, description } = parsed.data;
249384
+ const inSchema = schema !== null && typeof schema === "object" && "description" in schema;
249385
+ return [
249386
+ {
249387
+ name,
249388
+ in: location2,
249389
+ required: required ?? false,
249390
+ schema: inline(schema ?? {}),
249391
+ ...description && !inSchema ? { description: cleanText(description) } : {},
249392
+ ..."example" in parsed.data ? { example: parsed.data.example } : {}
249393
+ }
249394
+ ];
249395
+ }),
249396
+ ...requestBody.contentType && requestBody.contentType !== "application/json" ? { requestBodyContentType: requestBody.contentType } : {},
249397
+ requestBodySchema: inline(requestBody.schema),
249398
+ responseSchema: inline(success)
249399
+ };
249400
+ const refs = leftoverRefs(contract, schemas);
249401
+ return {
249402
+ ...contract,
249403
+ ...refs.size > 0 ? {
249404
+ refs: Object.fromEntries([...refs].map(([ref, schema]) => [ref, slimSchema(schema)]))
249405
+ } : {}
249406
+ };
249407
+ }
249408
+ // src/core/api-spec/grep.ts
249409
+ function grepOperations(spec, operations, pattern, options = {}) {
249410
+ const regex = new RegExp(pattern, options.ignoreCase ? "i" : "");
249411
+ return operations.filter((op) => regex.test(JSON.stringify(getOperationContract(spec, op)))).slice(0, options.limit ?? 20).map(toOperationSummary);
249412
+ }
249250
249413
  // src/core/api-spec/operations.ts
249251
249414
  var PERSONAL_ACCESS_TOKEN_SCHEME = "PersonalAccessTokenAuth";
249252
249415
  var READ_ONLY_SCOPE = "read_only";
@@ -249257,21 +249420,40 @@ function isReadOnly(operation, spec) {
249257
249420
  function parameterText(operation) {
249258
249421
  return (operation.parameters ?? []).flatMap((parameter) => {
249259
249422
  const parsed = ParameterSchema.safeParse(parameter);
249260
- return parsed.success ? [parsed.data.name, parsed.data.description ?? ""] : [];
249423
+ return parsed.success ? [parsed.data.name, cleanText(parsed.data.description ?? "")] : [];
249261
249424
  }).join(" ");
249262
249425
  }
249426
+ function mergeParameters(shared, own) {
249427
+ if (!shared?.length) {
249428
+ return own;
249429
+ }
249430
+ const key = (parameter) => {
249431
+ const parsed = ParameterSchema.safeParse(parameter);
249432
+ return parsed.success ? `${parsed.data.in}:${parsed.data.name}` : undefined;
249433
+ };
249434
+ const ownKeys = new Set((own ?? []).map(key));
249435
+ return [
249436
+ ...shared.filter((parameter) => !ownKeys.has(key(parameter))),
249437
+ ...own ?? []
249438
+ ];
249439
+ }
249263
249440
  function listOperations(spec) {
249264
249441
  return Object.entries(spec.paths).flatMap(([path, item]) => HTTP_METHODS.flatMap((method) => {
249265
- const operation = item[method];
249266
- if (!operation) {
249442
+ const declared = item[method];
249443
+ if (!declared) {
249267
249444
  return [];
249268
249445
  }
249446
+ const operation = {
249447
+ ...declared,
249448
+ parameters: mergeParameters(item.parameters, declared.parameters)
249449
+ };
249269
249450
  return [
249270
249451
  {
249452
+ endpoint: `${method.toUpperCase()} ${path}`,
249271
249453
  method: method.toUpperCase(),
249272
249454
  path,
249273
249455
  summary: operation.summary ?? "",
249274
- description: operation.description ?? "",
249456
+ description: cleanText(operation.description ?? ""),
249275
249457
  parameterText: parameterText(operation),
249276
249458
  readOnly: isReadOnly(operation, spec),
249277
249459
  operation
@@ -249287,16 +249469,8 @@ function segmentPattern(segment) {
249287
249469
  const source = segment.split(/(\{[^}]+\})/).map((part) => part.startsWith("{") ? "[^/]+" : part.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")).join("");
249288
249470
  return new RegExp(`^${source}$`);
249289
249471
  }
249290
- function specificity(templateSegments) {
249291
- return templateSegments.map((segment) => segment.includes("{") ? 0 : 1);
249292
- }
249293
- function compareSpecificity(a, b) {
249294
- for (let i = 0;i < a.length; i++) {
249295
- if (a[i] !== b[i]) {
249296
- return (b[i] ?? 0) - (a[i] ?? 0);
249297
- }
249298
- }
249299
- return 0;
249472
+ function literalSegments(path) {
249473
+ return pathSegments(path).map((segment) => segment.includes("{") ? "0" : "1").join("");
249300
249474
  }
249301
249475
  function matchOperation(operations, method, concretePath) {
249302
249476
  const upperMethod = method.toUpperCase();
@@ -249308,65 +249482,53 @@ function matchOperation(operations, method, concretePath) {
249308
249482
  const template = pathSegments(op.path);
249309
249483
  return template.length === segments.length && template.every((part, i) => segmentPattern(part).test(segments[i] ?? ""));
249310
249484
  });
249311
- return candidates.sort((a, b) => compareSpecificity(specificity(pathSegments(a.path)), specificity(pathSegments(b.path))))[0];
249312
- }
249313
- function collectRefs(value, spec, found) {
249314
- if (Array.isArray(value)) {
249315
- for (const item of value) {
249316
- collectRefs(item, spec, found);
249317
- }
249318
- return;
249319
- }
249320
- if (value === null || typeof value !== "object") {
249321
- return;
249322
- }
249323
- for (const [key, child] of Object.entries(value)) {
249324
- if (key === "$ref" && typeof child === "string" && !found.has(child)) {
249325
- const target = resolvePointer(spec, child);
249326
- found.set(child, target);
249327
- collectRefs(target, spec, found);
249328
- } else {
249329
- collectRefs(child, spec, found);
249330
- }
249331
- }
249485
+ return candidates.sort((a, b) => literalSegments(b.path).localeCompare(literalSegments(a.path)))[0];
249332
249486
  }
249333
- function resolvePointer(spec, ref) {
249334
- if (!ref.startsWith("#/")) {
249487
+ // src/core/api-spec/request.ts
249488
+ var MAX_ERROR_BODY_CHARS = 4000;
249489
+ var QUERY_STRING = /\?\S*/g;
249490
+ async function readBody(response) {
249491
+ try {
249492
+ const text = (await response.clone().text()).trim();
249493
+ return text.length > MAX_ERROR_BODY_CHARS ? `${text.slice(0, MAX_ERROR_BODY_CHARS)}…` : text || undefined;
249494
+ } catch {
249335
249495
  return;
249336
249496
  }
249337
- return ref.slice(2).split("/").map((part) => part.replace(/~1/g, "/").replace(/~0/g, "~")).reduce((node, part) => node !== null && typeof node === "object" ? node[part] : undefined, spec);
249338
249497
  }
249339
- function getOperationContract(spec, op) {
249340
- const { parameters, requestBody, responses } = op.operation;
249341
- const refs = new Map;
249342
- collectRefs({ parameters, requestBody, responses }, spec, refs);
249343
- return {
249344
- method: op.method,
249345
- path: op.path,
249346
- summary: op.summary,
249347
- description: op.description,
249348
- readOnly: op.readOnly,
249349
- parameters: parameters ?? [],
249350
- requestBody: requestBody ?? null,
249351
- responses: responses ?? {},
249352
- refs: Object.fromEntries(refs)
249353
- };
249354
- }
249355
- // src/core/api-spec/request.ts
249356
249498
  async function sendApiRequest(method, path, body) {
249357
249499
  try {
249358
249500
  const response = await base44Client(path.replace(/^\/+/, ""), {
249359
249501
  method,
249360
249502
  body,
249361
- headers: body === undefined ? {} : { "Content-Type": "application/json" }
249503
+ headers: body === undefined ? {} : { "Content-Type": "application/json" },
249504
+ timeout: false,
249505
+ retry: { methods: ["get", "head"] }
249362
249506
  });
249363
- return await response.text();
249507
+ return {
249508
+ status: response.status,
249509
+ contentType: response.headers.get("content-type") ?? "",
249510
+ body: new Uint8Array(await response.arrayBuffer())
249511
+ };
249364
249512
  } catch (error) {
249365
- throw await ApiError.fromHttpError(error, `calling ${method} ${path}`);
249513
+ const apiError = await ApiError.fromHttpError(error, `calling ${method} ${path}`);
249514
+ const raw = error instanceof HTTPError ? await readBody(error.response) : undefined;
249515
+ throw redactedApiError(apiError, raw, method, path);
249366
249516
  }
249367
249517
  }
249518
+ function redactedApiError(apiError, raw, method, path) {
249519
+ const reason = apiError.statusCode !== undefined ? `HTTP ${apiError.statusCode}` : (apiError.cause?.message ?? "request failed").replace(QUERY_STRING, "");
249520
+ const message = `Error calling ${method} ${path.split("?", 1)[0]}: ${reason}`;
249521
+ return new ApiError(message, {
249522
+ statusCode: apiError.statusCode,
249523
+ requestUrl: apiError.requestUrl?.split("?", 1)[0],
249524
+ requestMethod: apiError.requestMethod,
249525
+ requestId: apiError.requestId,
249526
+ hints: apiError.hints,
249527
+ details: raw ? [`Response body: ${raw}`] : apiError.details
249528
+ });
249529
+ }
249368
249530
  // src/core/api-spec/spec.ts
249369
- import { stat as stat3 } from "node:fs/promises";
249531
+ import { rename, rm, stat as stat3 } from "node:fs/promises";
249370
249532
  import { join as join22 } from "node:path";
249371
249533
  var SPEC_CACHE_TTL_MS = 60 * 60 * 1000;
249372
249534
  function getSpecCachePath(apiUrl = getBase44ApiUrl()) {
@@ -249389,17 +249551,24 @@ function parseSpec(text) {
249389
249551
  }
249390
249552
  return result.data;
249391
249553
  }
249554
+ var SPEC_DOWNLOAD_TIMEOUT_MS = 60000;
249392
249555
  async function readFreshCache(path) {
249393
249556
  try {
249394
249557
  const { mtimeMs } = await stat3(path);
249395
- return isSpecCacheFresh(mtimeMs) ? await readTextFile(path) : null;
249558
+ if (!isSpecCacheFresh(mtimeMs)) {
249559
+ return null;
249560
+ }
249561
+ const text = await readTextFile(path);
249562
+ return { text, spec: parseSpec(text) };
249396
249563
  } catch {
249397
249564
  return null;
249398
249565
  }
249399
249566
  }
249400
249567
  async function downloadSpec() {
249401
249568
  try {
249402
- const response = await base44Client.get("api/openapi.json");
249569
+ const response = await base44Client.get("api/openapi.json", {
249570
+ timeout: SPEC_DOWNLOAD_TIMEOUT_MS
249571
+ });
249403
249572
  return await response.text();
249404
249573
  } catch (error) {
249405
249574
  throw await ApiError.fromHttpError(error, "fetching the API spec");
@@ -249409,29 +249578,25 @@ async function loadSpec(options = {}) {
249409
249578
  const path = getSpecCachePath();
249410
249579
  const cached = options.refresh ? null : await readFreshCache(path);
249411
249580
  if (cached !== null) {
249412
- return { text: cached, spec: parseSpec(cached) };
249581
+ return cached;
249413
249582
  }
249414
249583
  const text = await downloadSpec();
249415
249584
  const spec = parseSpec(text);
249416
- await writeFile(path, text);
249585
+ const partial = `${path}.${process.pid}.tmp`;
249586
+ try {
249587
+ await writeFile(partial, text);
249588
+ await rename(partial, path);
249589
+ } catch {
249590
+ await rm(partial, { force: true }).catch(() => {
249591
+ return;
249592
+ });
249593
+ }
249417
249594
  return { text, spec };
249418
249595
  }
249419
249596
  // src/cli/commands/api/shared.ts
249597
+ import { fstatSync } from "node:fs";
249420
249598
  function formatJson(value) {
249421
- return `${JSON.stringify(value, null, process.stdout.isTTY ? 2 : undefined)}
249422
- `;
249423
- }
249424
- function formatResponseBody(text) {
249425
- if (!text) {
249426
- return "";
249427
- }
249428
- try {
249429
- return formatJson(JSON.parse(text));
249430
- } catch {
249431
- return text.endsWith(`
249432
- `) ? text : `${text}
249433
- `;
249434
- }
249599
+ return toJsonStdout(value, { compact: !process.stdout.isTTY });
249435
249600
  }
249436
249601
  function parseLimit(value) {
249437
249602
  if (value === undefined) {
@@ -249443,6 +249608,7 @@ function parseLimit(value) {
249443
249608
  }
249444
249609
  return n;
249445
249610
  }
249611
+ var READ_ONLY_FILTER_HELP = "Only read-only operations";
249446
249612
  var REFRESH_OPTION_HELP = "Fetch the API spec again instead of using the cached copy (kept 1 hour)";
249447
249613
  function loadSpecTask({ runTask }, refresh) {
249448
249614
  return runTask("Loading the API spec", () => loadSpec({ refresh }), {
@@ -249460,53 +249626,69 @@ function operationsInArea(operations, area) {
249460
249626
  }
249461
249627
  return inArea;
249462
249628
  }
249463
- async function readRequestBody(method, flag) {
249629
+ function isPipedStdin() {
249630
+ try {
249631
+ const stats = fstatSync(0);
249632
+ return stats.isFIFO() || stats.isFile();
249633
+ } catch {
249634
+ return false;
249635
+ }
249636
+ }
249637
+ async function readRequestBody(flag, log) {
249464
249638
  if (flag === "@-") {
249465
249639
  return readStdin("--body @-", { trim: false });
249466
249640
  }
249467
249641
  if (flag?.startsWith("@")) {
249468
249642
  return readTextFile(flag.slice(1));
249469
249643
  }
249470
- if (flag !== undefined) {
249471
- return flag;
249644
+ if (flag === undefined && isPipedStdin()) {
249645
+ log.warn("stdin is ignored; pass --body @- to send it as the body.");
249472
249646
  }
249473
- if (method === "GET" || method === "HEAD" || process.stdin.isTTY) {
249474
- return;
249475
- }
249476
- const piped = await readStdin("--body", { trim: false });
249477
- return piped.trim() ? piped : undefined;
249647
+ return flag;
249648
+ }
249649
+ function withoutQuery(path) {
249650
+ return path.split("?", 1)[0] ?? "";
249651
+ }
249652
+ function reportedFetchCommand(method, path, options) {
249653
+ return {
249654
+ name: "api fetch",
249655
+ args: [method, withoutQuery(path)],
249656
+ options: {
249657
+ ...options,
249658
+ ...options.body === undefined ? {} : { body: "[not reported]" }
249659
+ }
249660
+ };
249478
249661
  }
249479
249662
 
249480
249663
  // src/cli/commands/api/catalog.ts
249481
249664
  async function catalogAction(ctx, area, options) {
249482
249665
  const { spec } = await loadSpecTask(ctx, options.refresh);
249483
249666
  const operations = listOperations(spec);
249667
+ const readOnly = (ops) => options.readOnly ? ops.filter((op) => op.readOnly) : ops;
249484
249668
  if (area === undefined) {
249485
- return { stdout: formatJson(catalogIndex(operations)) };
249669
+ return { stdout: formatJson(catalogIndex(readOnly(operations))) };
249486
249670
  }
249487
- const inArea = operationsInArea(operations, area);
249488
- return {
249489
- stdout: formatJson({
249490
- area,
249491
- operations: inArea.map(toOperationSummary),
249492
- total: inArea.length
249493
- })
249494
- };
249671
+ const inArea = readOnly(operationsInArea(operations, area));
249672
+ return { stdout: formatJson(areaListing(area, inArea)) };
249495
249673
  }
249496
249674
  function getApiCatalogCommand() {
249497
249675
  return new Base44Command("catalog", {
249498
249676
  requireAuth: false,
249499
249677
  requireAppContext: false
249500
- }).description("List the API's areas, or every operation in one area (same areas as the MCP bridge)").argument("[area]", 'An area from the list, e.g. "workflows"').option("--refresh", REFRESH_OPTION_HELP).action(catalogAction);
249678
+ }).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);
249501
249679
  }
249502
249680
 
249503
249681
  // src/cli/commands/api/fetch.ts
249504
- async function findOperation(ctx, method, path, refresh) {
249682
+ async function findOperation(ctx, method, path, { refresh, flag }) {
249505
249683
  const { spec } = await loadSpecTask(ctx, refresh);
249506
249684
  const op = matchOperation(listOperations(spec), method, path);
249507
249685
  if (!op) {
249508
- throw new InvalidInputError(`No operation in the API spec matches ${method} ${path}.`, {
249686
+ throw new InvalidInputError(`No operation in the API spec matches ${method} ${withoutQuery(path)}.`, {
249509
249687
  hints: [
249688
+ {
249689
+ message: "The cached spec may predate this route; fetch it again",
249690
+ command: `base44 api fetch ${method} ${path} ${flag} --refresh`
249691
+ },
249510
249692
  {
249511
249693
  message: "Find the operation and its path template",
249512
249694
  command: 'base44 api search "<what you want to do>"'
@@ -249516,34 +249698,90 @@ async function findOperation(ctx, method, path, refresh) {
249516
249698
  }
249517
249699
  return { spec, op };
249518
249700
  }
249701
+ var CONTRACT_HELP = `
249702
+ The contract is JSON; cut it down with e.g. | jq '.parameters, .requestBodySchema'`;
249703
+ var TEXT_CONTENT_TYPES = [
249704
+ "json",
249705
+ "text/",
249706
+ "xml",
249707
+ "javascript",
249708
+ "x-www-form-urlencoded"
249709
+ ];
249710
+ function isText(contentType) {
249711
+ return !contentType || TEXT_CONTENT_TYPES.some((hint) => contentType.toLowerCase().includes(hint));
249712
+ }
249713
+ async function formatResponse({ status, contentType, body }, output, jsonMode) {
249714
+ if (output !== undefined) {
249715
+ await writeFile(output, body);
249716
+ return formatJson({ status, contentType, bytes: body.length, output });
249717
+ }
249718
+ if (body.length === 0) {
249719
+ return formatJson({ status });
249720
+ }
249721
+ if (!isText(contentType)) {
249722
+ return formatJson({
249723
+ status,
249724
+ contentType,
249725
+ bytes: body.length,
249726
+ note: "Binary body not printed; add --output <file> to save it."
249727
+ });
249728
+ }
249729
+ const text = new TextDecoder().decode(body);
249730
+ try {
249731
+ return formatJson(JSON.parse(text));
249732
+ } catch {
249733
+ if (jsonMode) {
249734
+ return formatJson({ status, contentType, body: text });
249735
+ }
249736
+ return text.endsWith(`
249737
+ `) ? text : `${text}
249738
+ `;
249739
+ }
249740
+ }
249519
249741
  async function fetchAction(ctx, methodArg, path, options, command) {
249742
+ ctx.errorReporter.setContext({
249743
+ command: reportedFetchCommand(methodArg ?? "", path ?? "", { ...options })
249744
+ });
249520
249745
  if (!methodArg || !path) {
249521
249746
  if (options.help) {
249522
- return { stdout: command.helpInformation() };
249747
+ const usage = `${command.helpInformation()}${CONTRACT_HELP}
249748
+ `;
249749
+ return { stdout: ctx.jsonMode ? formatJson({ usage }) : usage };
249523
249750
  }
249524
249751
  throw new InvalidInputError("Provide a method and a path, e.g. GET /api/apps.");
249525
249752
  }
249526
249753
  const method = methodArg.toUpperCase();
249527
249754
  if (options.help) {
249528
- const { spec, op } = await findOperation(ctx, method, path, options.refresh);
249755
+ const { spec, op } = await findOperation(ctx, method, path, {
249756
+ refresh: options.refresh,
249757
+ flag: "--help"
249758
+ });
249529
249759
  return { stdout: formatJson(getOperationContract(spec, op)) };
249530
249760
  }
249531
249761
  if (options.readOnly) {
249532
- const { op } = await findOperation(ctx, method, path, options.refresh);
249762
+ const { op } = await findOperation(ctx, method, path, {
249763
+ refresh: options.refresh,
249764
+ flag: "--read-only"
249765
+ });
249533
249766
  if (!op.readOnly) {
249534
249767
  throw new InvalidInputError(`Refused under --read-only: ${op.method} ${op.path} is not a read-only operation. Nothing was sent.`);
249535
249768
  }
249536
249769
  }
249537
249770
  await ensureAuth(ctx);
249538
- const body = await readRequestBody(method, options.body);
249539
- const text = await ctx.runTask(`Calling ${method} ${path}`, () => sendApiRequest(method, path, body), { successMessage: `Called ${method} ${path}` });
249540
- return { stdout: formatResponseBody(text) };
249771
+ const body = await readRequestBody(options.body, ctx.log);
249772
+ const response = await ctx.runTask(`Calling ${method} ${path}`, () => sendApiRequest(method, path, body), {
249773
+ successMessage: `Called ${method} ${path}`,
249774
+ errorMessage: "Request failed"
249775
+ });
249776
+ return {
249777
+ stdout: await formatResponse(response, options.output, ctx.jsonMode)
249778
+ };
249541
249779
  }
249542
249780
  function getApiFetchCommand() {
249543
249781
  return new Base44Command("fetch", {
249544
249782
  requireAuth: false,
249545
249783
  requireAppContext: false
249546
- }).description("Call a Base44 API operation, like curl; add --help after a path for its contract").helpOption(false).argument("[method]", "HTTP method, e.g. GET or POST").argument("[path]", 'Concrete path with any query string, e.g. "/api/apps/<app-id>/workflows/runs?status=failed"').option("--body <json>", "Request body: JSON, @file.json, or @- for stdin (piped stdin is read too)").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").action(fetchAction);
249784
+ }).description("Call a Base44 API operation; add --help after a path for its contract").helpOption(false).argument("[method]", "HTTP method, e.g. GET or POST").argument("[path]", 'Concrete path with any query string, e.g. "/api/apps/<app-id>/workflows/runs?status=failed"').option("--body <json>", "Request body: JSON, @file.json, or @- to read it from stdin").option("--output <file>", "Save the response body to a file").option("--read-only", "Refuse, before sending, any operation the spec does not mark read-only").option("--refresh", REFRESH_OPTION_HELP).option("-h, --help", "With a method and path, print that operation's contract; otherwise this help").addHelpText("after", CONTRACT_HELP).action(fetchAction);
249547
249785
  }
249548
249786
 
249549
249787
  // src/cli/commands/api/grep.ts
@@ -249558,12 +249796,14 @@ async function grepAction(ctx, pattern, options) {
249558
249796
  const limit = parseLimit(options.limit);
249559
249797
  assertValidRegex(pattern);
249560
249798
  const { spec } = await loadSpecTask(ctx, options.refresh);
249561
- const operations = listOperations(spec);
249799
+ let operations = listOperations(spec);
249562
249800
  if (options.area !== undefined) {
249563
- operationsInArea(operations, options.area);
249801
+ operations = operationsInArea(operations, options.area);
249802
+ }
249803
+ if (options.readOnly) {
249804
+ operations = operations.filter((op) => op.readOnly);
249564
249805
  }
249565
- const hits = grepSpec(spec, operations, pattern, {
249566
- area: options.area,
249806
+ const hits = grepOperations(spec, operations, pattern, {
249567
249807
  ignoreCase: options.ignoreCase,
249568
249808
  limit
249569
249809
  });
@@ -249573,7 +249813,7 @@ function getApiGrepCommand() {
249573
249813
  return new Base44Command("grep", {
249574
249814
  requireAuth: false,
249575
249815
  requireAppContext: false
249576
- }).description("Search the raw API spec with a regular expression, for when search misses").argument("<pattern>", 'Regular expression, 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 or schemas to return (default 20)").option("--refresh", REFRESH_OPTION_HELP).action(grepAction);
249816
+ }).description("Search the API spec with a regular expression, for when search misses").argument("<pattern>", 'Regular expression, 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);
249577
249817
  }
249578
249818
 
249579
249819
  // src/cli/commands/api/search.ts
@@ -249590,7 +249830,7 @@ function getApiSearchCommand() {
249590
249830
  return new Base44Command("search", {
249591
249831
  requireAuth: false,
249592
249832
  requireAppContext: false
249593
- }).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", "Return only read-only operations").option("--refresh", REFRESH_OPTION_HELP).action(searchAction);
249833
+ }).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);
249594
249834
  }
249595
249835
 
249596
249836
  // src/cli/commands/api/index.ts
@@ -254959,6 +255199,12 @@ var deno2 = Object.freeze({
254959
255199
  });
254960
255200
  globalThis.Deno = deno2;
254961
255201
  globalThis.Buffer = Buffer2;
255202
+ try {
255203
+ new AsyncLocalStorage().enterWith(void 0);
255204
+ } catch {
255205
+ AsyncLocalStorage.prototype.enterWith = () => {
255206
+ };
255207
+ }
254962
255208
  function getRegisteredHandler() {
254963
255209
  return registeredHandler;
254964
255210
  }
@@ -257924,7 +258170,7 @@ var TELEMETRY_PATCH = [
257924
258170
  var TELEMETRY_STORE_FIELDS = "reqId: crypto.randomUUID(), respondedAt: null, inflight: new Map(), inflightTotal: 0, hadRejection: false, hadNonOk: false, logBudget: 5";
257925
258171
 
257926
258172
  // ../functions-compiler/src/version.ts
257927
- var COMPILER_VERSION = "0.1.7";
258173
+ var COMPILER_VERSION = "0.1.8";
257928
258174
 
257929
258175
  // ../functions-compiler/src/worker-entry.ts
257930
258176
  function denoShimSource() {
@@ -262127,7 +262373,7 @@ var nativeEnumType = ZodNativeEnum.create;
262127
262373
  var promiseType = ZodPromise.create;
262128
262374
  var effectsType = ZodEffects.create;
262129
262375
  var optionalType = ZodOptional2.create;
262130
- var nullableType = ZodNullable2.create;
262376
+ var nullableType2 = ZodNullable2.create;
262131
262377
  var preprocessType = ZodEffects.createWithPreprocess;
262132
262378
  var pipelineType = ZodPipeline.create;
262133
262379
  // ../functions-compiler/src/contracts.ts
@@ -262157,7 +262403,7 @@ var bundleAppRequestSchema = objectType({
262157
262403
  var ACTIVATION_MODE = "pull";
262158
262404
 
262159
262405
  // ../functions-compiler/src/deno-bundle.ts
262160
- import { mkdtemp, rm, writeFile as writeFile2 } from "node:fs/promises";
262406
+ import { mkdtemp, rm as rm2, writeFile as writeFile2 } from "node:fs/promises";
262161
262407
  import { tmpdir as tmpdir2 } from "node:os";
262162
262408
  import path21 from "node:path";
262163
262409
 
@@ -262548,6 +262794,174 @@ function runtimeVirtualPlugin() {
262548
262794
  };
262549
262795
  }
262550
262796
 
262797
+ // ../functions-compiler/src/esbuild/ws-native-virtual.ts
262798
+ var NAMESPACE4 = "base44-ws-native";
262799
+ var WS_SPECIFIER = /^(npm:)?ws(@[^/]+)?$/;
262800
+ var ADAPTER = `"use strict";
262801
+ const toBuffer = (value) => (globalThis.Buffer ? globalThis.Buffer.from(value) : value);
262802
+ const READY_STATES = ["CONNECTING", "OPEN", "CLOSING", "CLOSED"];
262803
+ const later = (fn, ...args) => queueMicrotask(() => fn(...args));
262804
+ const upgradeHeaders = (options) => {
262805
+ const headers = new Headers(options?.headers);
262806
+ for (const name of headers.keys()) if (name !== "user-agent") return headers;
262807
+ return null;
262808
+ };
262809
+ class WebSocket {
262810
+ static CONNECTING = 0;
262811
+ static OPEN = 1;
262812
+ static CLOSING = 2;
262813
+ static CLOSED = 3;
262814
+ #socket = null;
262815
+ #state = 0;
262816
+ #url;
262817
+ #closeRequested = null;
262818
+ #terminated = false;
262819
+ #listeners = new Map();
262820
+ constructor(address, protocols, options) {
262821
+ if (protocols && typeof protocols === "object" && !Array.isArray(protocols)) {
262822
+ options = protocols;
262823
+ protocols = undefined;
262824
+ }
262825
+ this.#url = String(address);
262826
+ const headers = upgradeHeaders(options);
262827
+ if (headers) {
262828
+ this.#upgrade(headers, protocols);
262829
+ } else {
262830
+ this.#attach(new globalThis.WebSocket(this.#url, protocols));
262831
+ }
262832
+ }
262833
+ get readyState() {
262834
+ if (this.#terminated) return 3;
262835
+ return this.#socket ? this.#socket.readyState : this.#state;
262836
+ }
262837
+ get url() { return this.#url; }
262838
+ get protocol() { return this.#socket ? this.#socket.protocol ?? "" : ""; }
262839
+ on(name, listener) { return this.#add(name, listener, false); }
262840
+ addListener(name, listener) { return this.#add(name, listener, false); }
262841
+ once(name, listener) { return this.#add(name, listener, true); }
262842
+ off(name, listener) { return this.removeListener(name, listener); }
262843
+ removeListener(name, listener) {
262844
+ const listeners = this.#listeners.get(name);
262845
+ if (listeners) this.#listeners.set(name, listeners.filter((entry) => entry.listener !== listener));
262846
+ return this;
262847
+ }
262848
+ removeAllListeners(name) {
262849
+ if (name === undefined) this.#listeners.clear();
262850
+ else this.#listeners.delete(name);
262851
+ return this;
262852
+ }
262853
+ emit(name, ...args) {
262854
+ const listeners = this.#listeners.get(name) ?? [];
262855
+ this.#listeners.set(name, listeners.filter((entry) => !entry.once));
262856
+ for (const entry of listeners) entry.listener.apply(this, args);
262857
+ return listeners.length > 0;
262858
+ }
262859
+ send(data, options, callback) {
262860
+ const done = typeof options === "function" ? options : callback;
262861
+ try {
262862
+ if (!this.#socket) {
262863
+ throw new Error("WebSocket is not open: readyState " + this.#state + " (" + READY_STATES[this.#state] + ")");
262864
+ }
262865
+ this.#socket.send(data);
262866
+ done?.();
262867
+ } catch (error) {
262868
+ if (!done) throw error;
262869
+ done(error);
262870
+ }
262871
+ }
262872
+ close(code, reason) {
262873
+ if (this.#socket) this.#socket.close(code, reason);
262874
+ else if (this.#state === 0) {
262875
+ // Upgrade still in flight: close as soon as it lands.
262876
+ this.#closeRequested = [code, reason];
262877
+ this.#state = 2;
262878
+ }
262879
+ }
262880
+ // \`ws\` tears the connection down at once. workerd has no abrupt close, so the
262881
+ // socket is closed normally and "close" is reported now, not on the reply.
262882
+ terminate() {
262883
+ if (this.#terminated || this.readyState === 3) return;
262884
+ this.#terminated = true;
262885
+ if (this.#socket) {
262886
+ try { this.#socket.close(); } catch {}
262887
+ } else {
262888
+ // Upgrade still in flight: close it on arrival, without an "open".
262889
+ this.#closeRequested = [];
262890
+ this.#state = 3;
262891
+ }
262892
+ later(() => this.emit("close", 1006, toBuffer("")));
262893
+ }
262894
+ #attach(socket) {
262895
+ this.#socket = socket;
262896
+ try { socket.binaryType = "arraybuffer"; } catch {}
262897
+ socket.addEventListener("open", () => this.emit("open"));
262898
+ socket.addEventListener("message", (event) => {
262899
+ const isBinary = typeof event.data !== "string";
262900
+ this.emit("message", toBuffer(isBinary ? new Uint8Array(event.data) : event.data), isBinary);
262901
+ });
262902
+ socket.addEventListener("error", (event) => this.emit("error", event.error ?? new Error(event.message || "WebSocket error")));
262903
+ socket.addEventListener("close", (event) => {
262904
+ if (!this.#terminated) this.emit("close", event.code, toBuffer(event.reason ?? ""));
262905
+ });
262906
+ }
262907
+ #upgrade(headers, protocols) {
262908
+ headers.set("Upgrade", "websocket");
262909
+ if (protocols) headers.set("Sec-WebSocket-Protocol", [].concat(protocols).join(", "));
262910
+ const httpUrl = this.#url.replace(/^ws(s?):/i, "http$1:");
262911
+ const fail = (error) => {
262912
+ this.#state = 3;
262913
+ if (this.#terminated) return;
262914
+ this.emit("error", error);
262915
+ this.emit("close", 1006, toBuffer(""));
262916
+ };
262917
+ // Two-argument then(): an exception from an "open" listener must not be
262918
+ // reported as a failed upgrade.
262919
+ fetch(httpUrl, { headers }).then((response) => {
262920
+ const socket = response.webSocket;
262921
+ if (!socket) {
262922
+ response.body?.cancel();
262923
+ return fail(new Error("Unexpected server response: " + response.status));
262924
+ }
262925
+ socket.accept();
262926
+ this.#attach(socket);
262927
+ if (this.#closeRequested) return socket.close(...this.#closeRequested);
262928
+ // accept() opens the socket without dispatching an "open" event.
262929
+ this.emit("open");
262930
+ }, fail);
262931
+ }
262932
+ #add(name, listener, once) {
262933
+ const listeners = this.#listeners.get(name) ?? [];
262934
+ listeners.push({ listener, once });
262935
+ this.#listeners.set(name, listeners);
262936
+ return this;
262937
+ }
262938
+ }
262939
+ class WebSocketServer {
262940
+ constructor() {
262941
+ throw new Error("ws WebSocketServer is not available in Base44 functions: a function can open WebSocket connections but cannot listen for them.");
262942
+ }
262943
+ }
262944
+ module.exports = WebSocket;
262945
+ module.exports.WebSocket = WebSocket;
262946
+ module.exports.WebSocketServer = WebSocketServer;
262947
+ module.exports.default = WebSocket;
262948
+ `;
262949
+ function wsNativeVirtualPlugin() {
262950
+ return {
262951
+ name: "base44-ws-native",
262952
+ setup(build) {
262953
+ build.onResolve({ filter: WS_SPECIFIER }, () => ({
262954
+ path: "ws",
262955
+ namespace: NAMESPACE4
262956
+ }));
262957
+ build.onLoad({ filter: /.*/, namespace: NAMESPACE4 }, () => ({
262958
+ contents: ADAPTER,
262959
+ loader: "js"
262960
+ }));
262961
+ }
262962
+ };
262963
+ }
262964
+
262551
262965
  // ../functions-compiler/src/deno-bundle.ts
262552
262966
  async function bundleToModule(prepared, nodeModulesDir = "none") {
262553
262967
  const dir = await mkdtemp(path21.join(tmpdir2(), "b44-bundle-"));
@@ -262571,6 +262985,7 @@ async function bundleToModule(prepared, nodeModulesDir = "none") {
262571
262985
  sourcemap: false,
262572
262986
  logLevel: "silent",
262573
262987
  plugins: [
262988
+ wsNativeVirtualPlugin(),
262574
262989
  nodeBuiltinRequirePlugin(),
262575
262990
  userFilesPlugin(prepared.files, prepared.entry),
262576
262991
  privateDataSourcesVirtualPlugin(),
@@ -262595,7 +263010,7 @@ async function bundleToModule(prepared, nodeModulesDir = "none") {
262595
263010
  warnings: result.warnings.map((w) => w.text)
262596
263011
  };
262597
263012
  } finally {
262598
- await rm(dir, { recursive: true, force: true });
263013
+ await rm2(dir, { recursive: true, force: true });
262599
263014
  }
262600
263015
  }
262601
263016
  function buildFailureErrors(e, dir) {
@@ -272960,4 +273375,4 @@ export {
272960
273375
  runCLI
272961
273376
  };
272962
273377
 
272963
- //# debugId=9595882D8F2B0F6464756E2164756E21
273378
+ //# debugId=A6B266663FAD34EF64756E2164756E21