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

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
@@ -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
@@ -249105,18 +249105,17 @@ var SPACE_OR_PUNCTUATION = /[\n\r\p{Z}\p{P}]+/u;
249105
249105
  var BOOST = { path: 8, summary: 5, description: 2, parameters: 0.5 };
249106
249106
  var MIN_RELATIVE_SCORE = 0.2;
249107
249107
  var TOKEN_SEPARATOR = /[\n\r\p{Z}\p{P}\p{S}]+/u;
249108
+ var STOPWORDS = new Set("a an and are at be by do does for from how i in is it its me my of on or our that the this to we what who with you your".split(" "));
249109
+ function tokenize(text) {
249110
+ return text.split(TOKEN_SEPARATOR).filter((word) => word && !STOPWORDS.has(word.toLowerCase()));
249111
+ }
249108
249112
  function toOperationSummary(op) {
249109
- return {
249110
- method: op.method,
249111
- path: op.path,
249112
- summary: op.summary,
249113
- readOnly: op.readOnly
249114
- };
249113
+ return { endpoint: op.endpoint, summary: op.summary };
249115
249114
  }
249116
249115
  function buildSearchIndex(operations) {
249117
249116
  const index = new MiniSearch({
249118
249117
  fields: ["path", "summary", "description", "parameters"],
249119
- tokenize: (text) => text.split(TOKEN_SEPARATOR).filter(Boolean)
249118
+ tokenize
249120
249119
  });
249121
249120
  index.addAll(operations.map((op, id) => ({
249122
249121
  id,
@@ -249127,14 +249126,25 @@ function buildSearchIndex(operations) {
249127
249126
  })));
249128
249127
  return index;
249129
249128
  }
249129
+ function summaryCoverage(query, op) {
249130
+ const terms = tokenize(query.toLowerCase());
249131
+ if (!op || terms.length === 0) {
249132
+ return 0;
249133
+ }
249134
+ const words = tokenize(op.summary.toLowerCase());
249135
+ return terms.filter((term) => words.some((word) => word.startsWith(term))).length / terms.length;
249136
+ }
249130
249137
  function searchOperations(operations, query, options = {}) {
249131
249138
  const index = buildSearchIndex(operations);
249132
249139
  const hits = index.search(query, {
249133
- prefix: true,
249134
- fuzzy: 0.2,
249140
+ prefix: (term) => term.length >= 3,
249141
+ fuzzy: (term) => term.length >= 4 ? 0.2 : false,
249135
249142
  boost: BOOST,
249136
249143
  filter: options.readOnly ? (hit) => operations[hit.id]?.readOnly === true : undefined
249137
- });
249144
+ }).map((hit) => ({
249145
+ ...hit,
249146
+ score: hit.score * (1 + summaryCoverage(query, operations[hit.id]))
249147
+ })).sort((a, b) => b.score - a.score);
249138
249148
  const baseline = (hits[0]?.score ?? 0) * MIN_RELATIVE_SCORE;
249139
249149
  return hits.filter((hit) => hit.score >= baseline).slice(0, options.limit ?? 5).flatMap((hit) => {
249140
249150
  const op = operations[hit.id];
@@ -249145,6 +249155,7 @@ function searchOperations(operations, query, options = {}) {
249145
249155
  // src/core/api-spec/catalog.ts
249146
249156
  var INLINE_AREA_MAX = 2;
249147
249157
  var AREA_SAMPLE_MAX = 3;
249158
+ var AREA_OPERATIONS_MAX = 200;
249148
249159
  var byCodePoint = (a, b) => a < b ? -1 : a > b ? 1 : 0;
249149
249160
  function areaOf(path) {
249150
249161
  const parts = path.split("/").filter(Boolean);
@@ -249166,24 +249177,39 @@ function groupByArea(operations) {
249166
249177
  }
249167
249178
  return new Map([...areas].sort(([a], [b]) => byCodePoint(a, b)));
249168
249179
  }
249180
+ function readsFirst(ops) {
249181
+ const isRead = (op) => op.method === "GET" ? 0 : 1;
249182
+ return [...ops].sort((a, b) => isRead(a) - isRead(b));
249183
+ }
249169
249184
  function catalogIndex(operations) {
249170
249185
  const areas = [...groupByArea(operations)].map(([area, ops]) => ops.length <= INLINE_AREA_MAX ? { area, operations: ops.map(toOperationSummary) } : {
249171
249186
  area,
249172
249187
  operationCount: ops.length,
249173
- sample: ops.slice(0, AREA_SAMPLE_MAX).map((op) => op.summary)
249188
+ sample: readsFirst(ops).slice(0, AREA_SAMPLE_MAX).map((op) => op.summary)
249174
249189
  });
249175
249190
  return { areas, total: operations.length };
249176
249191
  }
249192
+ function areaListing(area, operations, max = AREA_OPERATIONS_MAX) {
249193
+ return {
249194
+ area,
249195
+ operations: operations.slice(0, max).map(toOperationSummary),
249196
+ total: operations.length,
249197
+ truncated: operations.length > max
249198
+ };
249199
+ }
249177
249200
  // src/core/api-spec/grep.ts
249178
249201
  var CONTEXT_CHARS = 40;
249179
249202
  var MAX_SNIPPETS = 3;
249180
249203
  var MAX_SNIPPET_CHARS = 200;
249204
+ function unescapeJson(snippet) {
249205
+ return snippet.replace(/\\[nrt]/g, " ").replace(/\\"/g, '"');
249206
+ }
249181
249207
  function snippets(text, pattern) {
249182
249208
  const found = [];
249183
249209
  for (const match of text.matchAll(pattern)) {
249184
249210
  const start = Math.max(0, match.index - CONTEXT_CHARS);
249185
249211
  const end = match.index + match[0].length + CONTEXT_CHARS;
249186
- found.push(text.slice(start, Math.min(end, start + MAX_SNIPPET_CHARS)));
249212
+ found.push(unescapeJson(text.slice(start, Math.min(end, start + MAX_SNIPPET_CHARS))));
249187
249213
  if (found.length === MAX_SNIPPETS || match[0].length === 0) {
249188
249214
  break;
249189
249215
  }
@@ -249193,14 +249219,14 @@ function snippets(text, pattern) {
249193
249219
  function grepSpec(spec, operations, pattern, options = {}) {
249194
249220
  const regex = new RegExp(pattern, options.ignoreCase ? "gi" : "g");
249195
249221
  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);
249222
+ for (const op of operations) {
249223
+ const { summary, description, parameters, requestBody, responses } = op.operation;
249224
+ const matches = snippets(`${op.endpoint} ${JSON.stringify({ summary, description, parameters, requestBody, responses })}`, regex);
249199
249225
  if (matches.length > 0) {
249200
249226
  hits.push({ ...toOperationSummary(op), matches });
249201
249227
  }
249202
249228
  }
249203
- const schemas = options.area === undefined ? spec.components?.schemas : {};
249229
+ const schemas = options.schemas === false ? {} : spec.components?.schemas;
249204
249230
  for (const [schema, definition] of Object.entries(schemas ?? {})) {
249205
249231
  const matches = snippets(JSON.stringify(definition), regex);
249206
249232
  if (matches.length > 0) {
@@ -249225,7 +249251,16 @@ var ParameterSchema = looseObject({
249225
249251
  in: string2(),
249226
249252
  required: boolean2().optional(),
249227
249253
  description: string2().optional(),
249228
- schema: unknown().optional()
249254
+ schema: unknown().optional(),
249255
+ example: unknown().optional()
249256
+ });
249257
+ var MediaTypesSchema = record(string2(), looseObject({ schema: unknown().optional() }));
249258
+ var RequestBodySchema = looseObject({
249259
+ content: MediaTypesSchema.optional()
249260
+ });
249261
+ var ResponseObjectSchema = looseObject({
249262
+ description: string2().optional(),
249263
+ content: MediaTypesSchema.optional()
249229
249264
  });
249230
249265
  var SecurityRequirementSchema = record(string2(), array(string2()));
249231
249266
  var OperationSchema = looseObject({
@@ -249237,7 +249272,10 @@ var OperationSchema = looseObject({
249237
249272
  responses: record(string2(), unknown()).optional(),
249238
249273
  security: array(SecurityRequirementSchema).optional()
249239
249274
  });
249240
- var PathItemSchema = looseObject(Object.fromEntries(HTTP_METHODS.map((method) => [method, OperationSchema.optional()])));
249275
+ var PathItemSchema = looseObject({
249276
+ ...Object.fromEntries(HTTP_METHODS.map((method) => [method, OperationSchema.optional()])),
249277
+ parameters: array(unknown()).optional()
249278
+ });
249241
249279
  var OpenApiSpecSchema = looseObject({
249242
249280
  openapi: string2(),
249243
249281
  paths: record(string2(), PathItemSchema),
@@ -249260,14 +249298,33 @@ function parameterText(operation) {
249260
249298
  return parsed.success ? [parsed.data.name, parsed.data.description ?? ""] : [];
249261
249299
  }).join(" ");
249262
249300
  }
249301
+ function mergeParameters(shared, own) {
249302
+ if (!shared?.length) {
249303
+ return own;
249304
+ }
249305
+ const key = (parameter) => {
249306
+ const parsed = ParameterSchema.safeParse(parameter);
249307
+ return parsed.success ? `${parsed.data.in}:${parsed.data.name}` : undefined;
249308
+ };
249309
+ const ownKeys = new Set((own ?? []).map(key));
249310
+ return [
249311
+ ...shared.filter((parameter) => !ownKeys.has(key(parameter))),
249312
+ ...own ?? []
249313
+ ];
249314
+ }
249263
249315
  function listOperations(spec) {
249264
249316
  return Object.entries(spec.paths).flatMap(([path, item]) => HTTP_METHODS.flatMap((method) => {
249265
- const operation = item[method];
249266
- if (!operation) {
249317
+ const declared = item[method];
249318
+ if (!declared) {
249267
249319
  return [];
249268
249320
  }
249321
+ const operation = {
249322
+ ...declared,
249323
+ parameters: mergeParameters(item.parameters, declared.parameters)
249324
+ };
249269
249325
  return [
249270
249326
  {
249327
+ endpoint: `${method.toUpperCase()} ${path}`,
249271
249328
  method: method.toUpperCase(),
249272
249329
  path,
249273
249330
  summary: operation.summary ?? "",
@@ -249310,63 +249367,144 @@ function matchOperation(operations, method, concretePath) {
249310
249367
  });
249311
249368
  return candidates.sort((a, b) => compareSpecificity(specificity(pathSegments(a.path)), specificity(pathSegments(b.path))))[0];
249312
249369
  }
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;
249370
+ var SCHEMA_REF_PREFIX = "#/components/schemas/";
249371
+ var MAX_REF_DEPTH = 4;
249372
+ var FRAMEWORK_VALIDATION_ERROR = "Validation Error";
249373
+ function inlineRefs(node, schemas, seen = new Set, depth = 0) {
249374
+ if (depth > MAX_REF_DEPTH) {
249375
+ return node;
249319
249376
  }
249320
- if (value === null || typeof value !== "object") {
249321
- return;
249377
+ if (Array.isArray(node)) {
249378
+ return node.map((item) => inlineRefs(item, schemas, seen, depth));
249322
249379
  }
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);
249380
+ if (node === null || typeof node !== "object") {
249381
+ return node;
249382
+ }
249383
+ const { $ref, ...siblings } = node;
249384
+ if (typeof $ref === "string" && $ref.startsWith(SCHEMA_REF_PREFIX)) {
249385
+ const name = $ref.slice(SCHEMA_REF_PREFIX.length);
249386
+ if (seen.has(name) || !(name in schemas)) {
249387
+ return node;
249330
249388
  }
249389
+ const resolved = inlineRefs(schemas[name], schemas, new Set([...seen, name]), depth + 1);
249390
+ return resolved !== null && typeof resolved === "object" ? { ...resolved, ...siblings } : resolved;
249331
249391
  }
249392
+ return Object.fromEntries(Object.entries(node).map(([key, value]) => [
249393
+ key,
249394
+ inlineRefs(value, schemas, seen, depth)
249395
+ ]));
249332
249396
  }
249333
- function resolvePointer(spec, ref) {
249334
- if (!ref.startsWith("#/")) {
249335
- return;
249397
+ function jsonSchemaOf(value) {
249398
+ const parsed = RequestBodySchema.safeParse(value);
249399
+ return parsed.success ? parsed.data.content?.["application/json"]?.schema : undefined;
249400
+ }
249401
+ function requestBodyOf(value) {
249402
+ const parsed = RequestBodySchema.safeParse(value);
249403
+ const content = parsed.success ? parsed.data.content ?? {} : {};
249404
+ const contentType = "application/json" in content ? "application/json" : Object.keys(content)[0];
249405
+ return contentType ? { contentType, schema: content[contentType]?.schema } : {};
249406
+ }
249407
+ function leftoverRefs(node, schemas, found = new Map) {
249408
+ if (Array.isArray(node)) {
249409
+ for (const item of node) {
249410
+ leftoverRefs(item, schemas, found);
249411
+ }
249412
+ } else if (node !== null && typeof node === "object") {
249413
+ for (const [key, value] of Object.entries(node)) {
249414
+ if (key === "$ref" && typeof value === "string" && value.startsWith(SCHEMA_REF_PREFIX) && !found.has(value)) {
249415
+ const schema = schemas[value.slice(SCHEMA_REF_PREFIX.length)];
249416
+ found.set(value, schema);
249417
+ leftoverRefs(schema, schemas, found);
249418
+ } else {
249419
+ leftoverRefs(value, schemas, found);
249420
+ }
249421
+ }
249336
249422
  }
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);
249423
+ return found;
249338
249424
  }
249339
249425
  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 {
249426
+ const schemas = spec.components?.schemas ?? {};
249427
+ const inline = (node) => node === undefined ? null : inlineRefs(node, schemas);
249428
+ const responses = Object.entries(op.operation.responses ?? {}).flatMap(([status, response]) => {
249429
+ const parsed = ResponseObjectSchema.safeParse(response);
249430
+ return parsed.success ? [[status, parsed.data]] : [];
249431
+ });
249432
+ const success = responses.filter(([status]) => status.startsWith("2")).sort(([a], [b]) => a.localeCompare(b)).map(([, response]) => jsonSchemaOf(response)).find(Boolean);
249433
+ const errors = responses.filter(([status, response]) => !status.startsWith("2") && response.description !== FRAMEWORK_VALIDATION_ERROR);
249434
+ const requestBody = requestBodyOf(op.operation.requestBody);
249435
+ const contract = {
249436
+ endpoint: op.endpoint,
249344
249437
  method: op.method,
249345
249438
  path: op.path,
249346
249439
  summary: op.summary,
249347
249440
  description: op.description,
249348
- readOnly: op.readOnly,
249349
- parameters: parameters ?? [],
249350
- requestBody: requestBody ?? null,
249351
- responses: responses ?? {},
249352
- refs: Object.fromEntries(refs)
249441
+ parameters: (op.operation.parameters ?? []).flatMap((parameter) => {
249442
+ const parsed = ParameterSchema.safeParse(parameter);
249443
+ if (!parsed.success) {
249444
+ return [];
249445
+ }
249446
+ const { name, in: location2, required, schema, description } = parsed.data;
249447
+ const inSchema = schema !== null && typeof schema === "object" && "description" in schema;
249448
+ return [
249449
+ {
249450
+ name,
249451
+ in: location2,
249452
+ required: required ?? false,
249453
+ schema: inline(schema ?? {}),
249454
+ ...description && !inSchema ? { description } : {},
249455
+ ..."example" in parsed.data ? { example: parsed.data.example } : {}
249456
+ }
249457
+ ];
249458
+ }),
249459
+ ...requestBody.contentType && requestBody.contentType !== "application/json" ? { requestBodyContentType: requestBody.contentType } : {},
249460
+ requestBodySchema: inline(requestBody.schema),
249461
+ responseSchema: inline(success),
249462
+ errors: Object.fromEntries(errors.map(([status, response]) => [status, response.description ?? ""]))
249463
+ };
249464
+ const refs = leftoverRefs(contract, schemas);
249465
+ return {
249466
+ ...contract,
249467
+ ...refs.size > 0 ? { refs: Object.fromEntries(refs) } : {}
249353
249468
  };
249354
249469
  }
249355
249470
  // src/core/api-spec/request.ts
249471
+ var MAX_ERROR_BODY_CHARS = 4000;
249472
+ async function readBody(response) {
249473
+ try {
249474
+ const text = (await response.clone().text()).trim();
249475
+ return text.length > MAX_ERROR_BODY_CHARS ? `${text.slice(0, MAX_ERROR_BODY_CHARS)}…` : text || undefined;
249476
+ } catch {
249477
+ return;
249478
+ }
249479
+ }
249356
249480
  async function sendApiRequest(method, path, body) {
249357
249481
  try {
249358
249482
  const response = await base44Client(path.replace(/^\/+/, ""), {
249359
249483
  method,
249360
249484
  body,
249361
- headers: body === undefined ? {} : { "Content-Type": "application/json" }
249485
+ headers: body === undefined ? {} : { "Content-Type": "application/json" },
249486
+ timeout: false
249362
249487
  });
249363
- return await response.text();
249488
+ return {
249489
+ status: response.status,
249490
+ contentType: response.headers.get("content-type") ?? "",
249491
+ body: new Uint8Array(await response.arrayBuffer())
249492
+ };
249364
249493
  } catch (error) {
249365
- throw await ApiError.fromHttpError(error, `calling ${method} ${path}`);
249494
+ const apiError = await ApiError.fromHttpError(error, `calling ${method} ${path}`);
249495
+ const raw = error instanceof HTTPError ? await readBody(error.response) : undefined;
249496
+ throw new ApiError(apiError.message, {
249497
+ statusCode: apiError.statusCode,
249498
+ requestUrl: apiError.requestUrl,
249499
+ requestMethod: apiError.requestMethod,
249500
+ requestId: apiError.requestId,
249501
+ hints: apiError.hints,
249502
+ details: raw ? [`Response body: ${raw}`] : apiError.details
249503
+ });
249366
249504
  }
249367
249505
  }
249368
249506
  // src/core/api-spec/spec.ts
249369
- import { stat as stat3 } from "node:fs/promises";
249507
+ import { rename, stat as stat3 } from "node:fs/promises";
249370
249508
  import { join as join22 } from "node:path";
249371
249509
  var SPEC_CACHE_TTL_MS = 60 * 60 * 1000;
249372
249510
  function getSpecCachePath(apiUrl = getBase44ApiUrl()) {
@@ -249389,17 +249527,24 @@ function parseSpec(text) {
249389
249527
  }
249390
249528
  return result.data;
249391
249529
  }
249530
+ var SPEC_DOWNLOAD_TIMEOUT_MS = 60000;
249392
249531
  async function readFreshCache(path) {
249393
249532
  try {
249394
249533
  const { mtimeMs } = await stat3(path);
249395
- return isSpecCacheFresh(mtimeMs) ? await readTextFile(path) : null;
249534
+ if (!isSpecCacheFresh(mtimeMs)) {
249535
+ return null;
249536
+ }
249537
+ const text = await readTextFile(path);
249538
+ return { text, spec: parseSpec(text) };
249396
249539
  } catch {
249397
249540
  return null;
249398
249541
  }
249399
249542
  }
249400
249543
  async function downloadSpec() {
249401
249544
  try {
249402
- const response = await base44Client.get("api/openapi.json");
249545
+ const response = await base44Client.get("api/openapi.json", {
249546
+ timeout: SPEC_DOWNLOAD_TIMEOUT_MS
249547
+ });
249403
249548
  return await response.text();
249404
249549
  } catch (error) {
249405
249550
  throw await ApiError.fromHttpError(error, "fetching the API spec");
@@ -249409,29 +249554,19 @@ async function loadSpec(options = {}) {
249409
249554
  const path = getSpecCachePath();
249410
249555
  const cached = options.refresh ? null : await readFreshCache(path);
249411
249556
  if (cached !== null) {
249412
- return { text: cached, spec: parseSpec(cached) };
249557
+ return cached;
249413
249558
  }
249414
249559
  const text = await downloadSpec();
249415
249560
  const spec = parseSpec(text);
249416
- await writeFile(path, text);
249561
+ const partial = `${path}.${process.pid}.tmp`;
249562
+ await writeFile(partial, text);
249563
+ await rename(partial, path);
249417
249564
  return { text, spec };
249418
249565
  }
249419
249566
  // src/cli/commands/api/shared.ts
249567
+ import { fstatSync } from "node:fs";
249420
249568
  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
- }
249569
+ return toJsonStdout(value, { compact: !process.stdout.isTTY });
249435
249570
  }
249436
249571
  function parseLimit(value) {
249437
249572
  if (value === undefined) {
@@ -249443,6 +249578,7 @@ function parseLimit(value) {
249443
249578
  }
249444
249579
  return n;
249445
249580
  }
249581
+ var READ_ONLY_FILTER_HELP = "Only read-only operations";
249446
249582
  var REFRESH_OPTION_HELP = "Fetch the API spec again instead of using the cached copy (kept 1 hour)";
249447
249583
  function loadSpecTask({ runTask }, refresh) {
249448
249584
  return runTask("Loading the API spec", () => loadSpec({ refresh }), {
@@ -249460,44 +249596,43 @@ function operationsInArea(operations, area) {
249460
249596
  }
249461
249597
  return inArea;
249462
249598
  }
249463
- async function readRequestBody(method, flag) {
249599
+ function isPipedStdin() {
249600
+ try {
249601
+ const stats = fstatSync(0);
249602
+ return stats.isFIFO() || stats.isFile();
249603
+ } catch {
249604
+ return false;
249605
+ }
249606
+ }
249607
+ async function readRequestBody(flag, log) {
249464
249608
  if (flag === "@-") {
249465
249609
  return readStdin("--body @-", { trim: false });
249466
249610
  }
249467
249611
  if (flag?.startsWith("@")) {
249468
249612
  return readTextFile(flag.slice(1));
249469
249613
  }
249470
- if (flag !== undefined) {
249471
- return flag;
249472
- }
249473
- if (method === "GET" || method === "HEAD" || process.stdin.isTTY) {
249474
- return;
249614
+ if (flag === undefined && isPipedStdin()) {
249615
+ log.warn("stdin is ignored; pass --body @- to send it as the body.");
249475
249616
  }
249476
- const piped = await readStdin("--body", { trim: false });
249477
- return piped.trim() ? piped : undefined;
249617
+ return flag;
249478
249618
  }
249479
249619
 
249480
249620
  // src/cli/commands/api/catalog.ts
249481
249621
  async function catalogAction(ctx, area, options) {
249482
249622
  const { spec } = await loadSpecTask(ctx, options.refresh);
249483
249623
  const operations = listOperations(spec);
249624
+ const readOnly = (ops) => options.readOnly ? ops.filter((op) => op.readOnly) : ops;
249484
249625
  if (area === undefined) {
249485
- return { stdout: formatJson(catalogIndex(operations)) };
249626
+ return { stdout: formatJson(catalogIndex(readOnly(operations))) };
249486
249627
  }
249487
- const inArea = operationsInArea(operations, area);
249488
- return {
249489
- stdout: formatJson({
249490
- area,
249491
- operations: inArea.map(toOperationSummary),
249492
- total: inArea.length
249493
- })
249494
- };
249628
+ const inArea = readOnly(operationsInArea(operations, area));
249629
+ return { stdout: formatJson(areaListing(area, inArea)) };
249495
249630
  }
249496
249631
  function getApiCatalogCommand() {
249497
249632
  return new Base44Command("catalog", {
249498
249633
  requireAuth: false,
249499
249634
  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);
249635
+ }).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
249636
  }
249502
249637
 
249503
249638
  // src/cli/commands/api/fetch.ts
@@ -249507,6 +249642,10 @@ async function findOperation(ctx, method, path, refresh) {
249507
249642
  if (!op) {
249508
249643
  throw new InvalidInputError(`No operation in the API spec matches ${method} ${path}.`, {
249509
249644
  hints: [
249645
+ {
249646
+ message: "The cached spec may predate this route; fetch it again",
249647
+ command: "base44 api fetch <METHOD> <path> --help --refresh"
249648
+ },
249510
249649
  {
249511
249650
  message: "Find the operation and its path template",
249512
249651
  command: 'base44 api search "<what you want to do>"'
@@ -249516,10 +249655,49 @@ async function findOperation(ctx, method, path, refresh) {
249516
249655
  }
249517
249656
  return { spec, op };
249518
249657
  }
249658
+ var TEXT_CONTENT_TYPES = [
249659
+ "json",
249660
+ "text/",
249661
+ "xml",
249662
+ "javascript",
249663
+ "x-www-form-urlencoded"
249664
+ ];
249665
+ function isText(contentType) {
249666
+ return !contentType || TEXT_CONTENT_TYPES.some((hint) => contentType.toLowerCase().includes(hint));
249667
+ }
249668
+ async function formatResponse({ status, contentType, body }, output, jsonMode) {
249669
+ if (output !== undefined) {
249670
+ await writeFile(output, body);
249671
+ return formatJson({ status, contentType, bytes: body.length, output });
249672
+ }
249673
+ if (body.length === 0) {
249674
+ return formatJson({ status });
249675
+ }
249676
+ if (!isText(contentType)) {
249677
+ return formatJson({
249678
+ status,
249679
+ contentType,
249680
+ bytes: body.length,
249681
+ note: "Binary body not printed; add --output <file> to save it."
249682
+ });
249683
+ }
249684
+ const text = new TextDecoder().decode(body);
249685
+ try {
249686
+ return formatJson(JSON.parse(text));
249687
+ } catch {
249688
+ if (jsonMode) {
249689
+ return formatJson({ status, contentType, body: text });
249690
+ }
249691
+ return text.endsWith(`
249692
+ `) ? text : `${text}
249693
+ `;
249694
+ }
249695
+ }
249519
249696
  async function fetchAction(ctx, methodArg, path, options, command) {
249520
249697
  if (!methodArg || !path) {
249521
249698
  if (options.help) {
249522
- return { stdout: command.helpInformation() };
249699
+ const usage = command.helpInformation();
249700
+ return { stdout: ctx.jsonMode ? formatJson({ usage }) : usage };
249523
249701
  }
249524
249702
  throw new InvalidInputError("Provide a method and a path, e.g. GET /api/apps.");
249525
249703
  }
@@ -249534,16 +249712,28 @@ async function fetchAction(ctx, methodArg, path, options, command) {
249534
249712
  throw new InvalidInputError(`Refused under --read-only: ${op.method} ${op.path} is not a read-only operation. Nothing was sent.`);
249535
249713
  }
249536
249714
  }
249715
+ ctx.errorReporter.setContext({
249716
+ command: {
249717
+ name: "api fetch",
249718
+ args: [method, path.split("?", 1)[0] ?? ""],
249719
+ options: { ...options, body: options.body && "[not reported]" }
249720
+ }
249721
+ });
249537
249722
  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) };
249723
+ const body = await readRequestBody(options.body, ctx.log);
249724
+ const response = await ctx.runTask(`Calling ${method} ${path}`, () => sendApiRequest(method, path, body), {
249725
+ successMessage: `Called ${method} ${path}`,
249726
+ errorMessage: "Request failed"
249727
+ });
249728
+ return {
249729
+ stdout: await formatResponse(response, options.output, ctx.jsonMode)
249730
+ };
249541
249731
  }
249542
249732
  function getApiFetchCommand() {
249543
249733
  return new Base44Command("fetch", {
249544
249734
  requireAuth: false,
249545
249735
  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);
249736
+ }).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").action(fetchAction);
249547
249737
  }
249548
249738
 
249549
249739
  // src/cli/commands/api/grep.ts
@@ -249558,14 +249748,18 @@ async function grepAction(ctx, pattern, options) {
249558
249748
  const limit = parseLimit(options.limit);
249559
249749
  assertValidRegex(pattern);
249560
249750
  const { spec } = await loadSpecTask(ctx, options.refresh);
249561
- const operations = listOperations(spec);
249751
+ let operations = listOperations(spec);
249562
249752
  if (options.area !== undefined) {
249563
- operationsInArea(operations, options.area);
249753
+ operations = operationsInArea(operations, options.area);
249754
+ }
249755
+ if (options.readOnly) {
249756
+ operations = operations.filter((op) => op.readOnly);
249564
249757
  }
249758
+ const narrowed = options.area !== undefined || options.readOnly === true;
249565
249759
  const hits = grepSpec(spec, operations, pattern, {
249566
- area: options.area,
249567
249760
  ignoreCase: options.ignoreCase,
249568
- limit
249761
+ limit,
249762
+ schemas: !narrowed
249569
249763
  });
249570
249764
  return { stdout: formatJson(hits) };
249571
249765
  }
@@ -249573,7 +249767,7 @@ function getApiGrepCommand() {
249573
249767
  return new Base44Command("grep", {
249574
249768
  requireAuth: false,
249575
249769
  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);
249770
+ }).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 or schemas to return (default 20)").option("--read-only", READ_ONLY_FILTER_HELP).option("--refresh", REFRESH_OPTION_HELP).action(grepAction);
249577
249771
  }
249578
249772
 
249579
249773
  // src/cli/commands/api/search.ts
@@ -249590,7 +249784,7 @@ function getApiSearchCommand() {
249590
249784
  return new Base44Command("search", {
249591
249785
  requireAuth: false,
249592
249786
  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);
249787
+ }).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
249788
  }
249595
249789
 
249596
249790
  // src/cli/commands/api/index.ts
@@ -254959,6 +255153,12 @@ var deno2 = Object.freeze({
254959
255153
  });
254960
255154
  globalThis.Deno = deno2;
254961
255155
  globalThis.Buffer = Buffer2;
255156
+ try {
255157
+ new AsyncLocalStorage().enterWith(void 0);
255158
+ } catch {
255159
+ AsyncLocalStorage.prototype.enterWith = () => {
255160
+ };
255161
+ }
254962
255162
  function getRegisteredHandler() {
254963
255163
  return registeredHandler;
254964
255164
  }
@@ -257924,7 +258124,7 @@ var TELEMETRY_PATCH = [
257924
258124
  var TELEMETRY_STORE_FIELDS = "reqId: crypto.randomUUID(), respondedAt: null, inflight: new Map(), inflightTotal: 0, hadRejection: false, hadNonOk: false, logBudget: 5";
257925
258125
 
257926
258126
  // ../functions-compiler/src/version.ts
257927
- var COMPILER_VERSION = "0.1.7";
258127
+ var COMPILER_VERSION = "0.1.8";
257928
258128
 
257929
258129
  // ../functions-compiler/src/worker-entry.ts
257930
258130
  function denoShimSource() {
@@ -262548,6 +262748,174 @@ function runtimeVirtualPlugin() {
262548
262748
  };
262549
262749
  }
262550
262750
 
262751
+ // ../functions-compiler/src/esbuild/ws-native-virtual.ts
262752
+ var NAMESPACE4 = "base44-ws-native";
262753
+ var WS_SPECIFIER = /^(npm:)?ws(@[^/]+)?$/;
262754
+ var ADAPTER = `"use strict";
262755
+ const toBuffer = (value) => (globalThis.Buffer ? globalThis.Buffer.from(value) : value);
262756
+ const READY_STATES = ["CONNECTING", "OPEN", "CLOSING", "CLOSED"];
262757
+ const later = (fn, ...args) => queueMicrotask(() => fn(...args));
262758
+ const upgradeHeaders = (options) => {
262759
+ const headers = new Headers(options?.headers);
262760
+ for (const name of headers.keys()) if (name !== "user-agent") return headers;
262761
+ return null;
262762
+ };
262763
+ class WebSocket {
262764
+ static CONNECTING = 0;
262765
+ static OPEN = 1;
262766
+ static CLOSING = 2;
262767
+ static CLOSED = 3;
262768
+ #socket = null;
262769
+ #state = 0;
262770
+ #url;
262771
+ #closeRequested = null;
262772
+ #terminated = false;
262773
+ #listeners = new Map();
262774
+ constructor(address, protocols, options) {
262775
+ if (protocols && typeof protocols === "object" && !Array.isArray(protocols)) {
262776
+ options = protocols;
262777
+ protocols = undefined;
262778
+ }
262779
+ this.#url = String(address);
262780
+ const headers = upgradeHeaders(options);
262781
+ if (headers) {
262782
+ this.#upgrade(headers, protocols);
262783
+ } else {
262784
+ this.#attach(new globalThis.WebSocket(this.#url, protocols));
262785
+ }
262786
+ }
262787
+ get readyState() {
262788
+ if (this.#terminated) return 3;
262789
+ return this.#socket ? this.#socket.readyState : this.#state;
262790
+ }
262791
+ get url() { return this.#url; }
262792
+ get protocol() { return this.#socket ? this.#socket.protocol ?? "" : ""; }
262793
+ on(name, listener) { return this.#add(name, listener, false); }
262794
+ addListener(name, listener) { return this.#add(name, listener, false); }
262795
+ once(name, listener) { return this.#add(name, listener, true); }
262796
+ off(name, listener) { return this.removeListener(name, listener); }
262797
+ removeListener(name, listener) {
262798
+ const listeners = this.#listeners.get(name);
262799
+ if (listeners) this.#listeners.set(name, listeners.filter((entry) => entry.listener !== listener));
262800
+ return this;
262801
+ }
262802
+ removeAllListeners(name) {
262803
+ if (name === undefined) this.#listeners.clear();
262804
+ else this.#listeners.delete(name);
262805
+ return this;
262806
+ }
262807
+ emit(name, ...args) {
262808
+ const listeners = this.#listeners.get(name) ?? [];
262809
+ this.#listeners.set(name, listeners.filter((entry) => !entry.once));
262810
+ for (const entry of listeners) entry.listener.apply(this, args);
262811
+ return listeners.length > 0;
262812
+ }
262813
+ send(data, options, callback) {
262814
+ const done = typeof options === "function" ? options : callback;
262815
+ try {
262816
+ if (!this.#socket) {
262817
+ throw new Error("WebSocket is not open: readyState " + this.#state + " (" + READY_STATES[this.#state] + ")");
262818
+ }
262819
+ this.#socket.send(data);
262820
+ done?.();
262821
+ } catch (error) {
262822
+ if (!done) throw error;
262823
+ done(error);
262824
+ }
262825
+ }
262826
+ close(code, reason) {
262827
+ if (this.#socket) this.#socket.close(code, reason);
262828
+ else if (this.#state === 0) {
262829
+ // Upgrade still in flight: close as soon as it lands.
262830
+ this.#closeRequested = [code, reason];
262831
+ this.#state = 2;
262832
+ }
262833
+ }
262834
+ // \`ws\` tears the connection down at once. workerd has no abrupt close, so the
262835
+ // socket is closed normally and "close" is reported now, not on the reply.
262836
+ terminate() {
262837
+ if (this.#terminated || this.readyState === 3) return;
262838
+ this.#terminated = true;
262839
+ if (this.#socket) {
262840
+ try { this.#socket.close(); } catch {}
262841
+ } else {
262842
+ // Upgrade still in flight: close it on arrival, without an "open".
262843
+ this.#closeRequested = [];
262844
+ this.#state = 3;
262845
+ }
262846
+ later(() => this.emit("close", 1006, toBuffer("")));
262847
+ }
262848
+ #attach(socket) {
262849
+ this.#socket = socket;
262850
+ try { socket.binaryType = "arraybuffer"; } catch {}
262851
+ socket.addEventListener("open", () => this.emit("open"));
262852
+ socket.addEventListener("message", (event) => {
262853
+ const isBinary = typeof event.data !== "string";
262854
+ this.emit("message", toBuffer(isBinary ? new Uint8Array(event.data) : event.data), isBinary);
262855
+ });
262856
+ socket.addEventListener("error", (event) => this.emit("error", event.error ?? new Error(event.message || "WebSocket error")));
262857
+ socket.addEventListener("close", (event) => {
262858
+ if (!this.#terminated) this.emit("close", event.code, toBuffer(event.reason ?? ""));
262859
+ });
262860
+ }
262861
+ #upgrade(headers, protocols) {
262862
+ headers.set("Upgrade", "websocket");
262863
+ if (protocols) headers.set("Sec-WebSocket-Protocol", [].concat(protocols).join(", "));
262864
+ const httpUrl = this.#url.replace(/^ws(s?):/i, "http$1:");
262865
+ const fail = (error) => {
262866
+ this.#state = 3;
262867
+ if (this.#terminated) return;
262868
+ this.emit("error", error);
262869
+ this.emit("close", 1006, toBuffer(""));
262870
+ };
262871
+ // Two-argument then(): an exception from an "open" listener must not be
262872
+ // reported as a failed upgrade.
262873
+ fetch(httpUrl, { headers }).then((response) => {
262874
+ const socket = response.webSocket;
262875
+ if (!socket) {
262876
+ response.body?.cancel();
262877
+ return fail(new Error("Unexpected server response: " + response.status));
262878
+ }
262879
+ socket.accept();
262880
+ this.#attach(socket);
262881
+ if (this.#closeRequested) return socket.close(...this.#closeRequested);
262882
+ // accept() opens the socket without dispatching an "open" event.
262883
+ this.emit("open");
262884
+ }, fail);
262885
+ }
262886
+ #add(name, listener, once) {
262887
+ const listeners = this.#listeners.get(name) ?? [];
262888
+ listeners.push({ listener, once });
262889
+ this.#listeners.set(name, listeners);
262890
+ return this;
262891
+ }
262892
+ }
262893
+ class WebSocketServer {
262894
+ constructor() {
262895
+ throw new Error("ws WebSocketServer is not available in Base44 functions: a function can open WebSocket connections but cannot listen for them.");
262896
+ }
262897
+ }
262898
+ module.exports = WebSocket;
262899
+ module.exports.WebSocket = WebSocket;
262900
+ module.exports.WebSocketServer = WebSocketServer;
262901
+ module.exports.default = WebSocket;
262902
+ `;
262903
+ function wsNativeVirtualPlugin() {
262904
+ return {
262905
+ name: "base44-ws-native",
262906
+ setup(build) {
262907
+ build.onResolve({ filter: WS_SPECIFIER }, () => ({
262908
+ path: "ws",
262909
+ namespace: NAMESPACE4
262910
+ }));
262911
+ build.onLoad({ filter: /.*/, namespace: NAMESPACE4 }, () => ({
262912
+ contents: ADAPTER,
262913
+ loader: "js"
262914
+ }));
262915
+ }
262916
+ };
262917
+ }
262918
+
262551
262919
  // ../functions-compiler/src/deno-bundle.ts
262552
262920
  async function bundleToModule(prepared, nodeModulesDir = "none") {
262553
262921
  const dir = await mkdtemp(path21.join(tmpdir2(), "b44-bundle-"));
@@ -262571,6 +262939,7 @@ async function bundleToModule(prepared, nodeModulesDir = "none") {
262571
262939
  sourcemap: false,
262572
262940
  logLevel: "silent",
262573
262941
  plugins: [
262942
+ wsNativeVirtualPlugin(),
262574
262943
  nodeBuiltinRequirePlugin(),
262575
262944
  userFilesPlugin(prepared.files, prepared.entry),
262576
262945
  privateDataSourcesVirtualPlugin(),
@@ -272960,4 +273329,4 @@ export {
272960
273329
  runCLI
272961
273330
  };
272962
273331
 
272963
- //# debugId=9595882D8F2B0F6464756E2164756E21
273332
+ //# debugId=FB96E058A37AEBFF64756E2164756E21