@base44-preview/cli 0.1.32-pr.663.d01623b → 0.1.32-pr.663.d2e3c0d

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
@@ -249102,19 +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
249119
  return { endpoint: op.endpoint, summary: op.summary };
249110
249120
  }
249111
249121
  function buildSearchIndex(operations) {
249112
249122
  const index = new MiniSearch({
249113
- fields: ["path", "summary", "description", "parameters"],
249114
- tokenize: (text) => text.split(TOKEN_SEPARATOR).filter(Boolean)
249123
+ fields: ["method", "path", "summary", "description", "parameters"],
249124
+ tokenize
249115
249125
  });
249116
249126
  index.addAll(operations.map((op, id) => ({
249117
249127
  id,
249128
+ method: op.method,
249118
249129
  path: op.path.replace(/\{[^}]*\}/g, ""),
249119
249130
  summary: op.summary,
249120
249131
  description: op.description,
@@ -249122,16 +249133,37 @@ function buildSearchIndex(operations) {
249122
249133
  })));
249123
249134
  return index;
249124
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;
249125
249145
  function searchOperations(operations, query, options = {}) {
249146
+ const terms = tokenize(query.toLowerCase());
249147
+ if (terms.length === 0) {
249148
+ return [];
249149
+ }
249126
249150
  const index = buildSearchIndex(operations);
249127
249151
  const hits = index.search(query, {
249128
- prefix: true,
249129
- fuzzy: 0.2,
249152
+ prefix: (term) => term.length >= 3,
249153
+ fuzzy: (term) => term.length >= 4 ? 0.2 : false,
249130
249154
  boost: BOOST,
249131
249155
  filter: options.readOnly ? (hit) => operations[hit.id]?.readOnly === true : undefined
249132
- });
249133
- const baseline = (hits[0]?.score ?? 0) * MIN_RELATIVE_SCORE;
249134
- 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) => {
249135
249167
  const op = operations[hit.id];
249136
249168
  return op ? [toOperationSummary(op)] : [];
249137
249169
  });
@@ -249162,7 +249194,7 @@ function groupByArea(operations) {
249162
249194
  }
249163
249195
  return new Map([...areas].sort(([a], [b]) => byCodePoint(a, b)));
249164
249196
  }
249165
- function readsFirst(ops) {
249197
+ function readsFirst2(ops) {
249166
249198
  const isRead = (op) => op.method === "GET" ? 0 : 1;
249167
249199
  return [...ops].sort((a, b) => isRead(a) - isRead(b));
249168
249200
  }
@@ -249170,7 +249202,7 @@ 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: readsFirst(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
  }
@@ -249182,45 +249214,6 @@ function areaListing(area, operations, max = AREA_OPERATIONS_MAX) {
249182
249214
  truncated: operations.length > max
249183
249215
  };
249184
249216
  }
249185
- // src/core/api-spec/grep.ts
249186
- var CONTEXT_CHARS = 40;
249187
- var MAX_SNIPPETS = 3;
249188
- var MAX_SNIPPET_CHARS = 200;
249189
- function unescapeJson(snippet) {
249190
- return snippet.replace(/\\[nrt]/g, " ").replace(/\\"/g, '"');
249191
- }
249192
- function snippets(text, pattern) {
249193
- const found = [];
249194
- for (const match of text.matchAll(pattern)) {
249195
- const start = Math.max(0, match.index - CONTEXT_CHARS);
249196
- const end = match.index + match[0].length + CONTEXT_CHARS;
249197
- found.push(unescapeJson(text.slice(start, Math.min(end, start + MAX_SNIPPET_CHARS))));
249198
- if (found.length === MAX_SNIPPETS || match[0].length === 0) {
249199
- break;
249200
- }
249201
- }
249202
- return found;
249203
- }
249204
- function grepSpec(spec, operations, pattern, options = {}) {
249205
- const regex = new RegExp(pattern, options.ignoreCase ? "gi" : "g");
249206
- const hits = [];
249207
- const selected = (op) => (options.area === undefined || areaOf(op.path) === options.area) && (!options.readOnly || op.readOnly);
249208
- for (const op of operations.filter(selected)) {
249209
- const { summary, description, parameters, requestBody, responses } = op.operation;
249210
- const matches = snippets(`${op.endpoint} ${JSON.stringify({ summary, description, parameters, requestBody, responses })}`, regex);
249211
- if (matches.length > 0) {
249212
- hits.push({ ...toOperationSummary(op), matches });
249213
- }
249214
- }
249215
- const schemas = options.area === undefined && !options.readOnly ? spec.components?.schemas : {};
249216
- for (const [schema, definition] of Object.entries(schemas ?? {})) {
249217
- const matches = snippets(JSON.stringify(definition), regex);
249218
- if (matches.length > 0) {
249219
- hits.push({ schema, matches });
249220
- }
249221
- }
249222
- return hits.slice(0, options.limit ?? 20);
249223
- }
249224
249217
  // src/core/api-spec/schema.ts
249225
249218
  var HTTP_METHODS = [
249226
249219
  "get",
@@ -249258,7 +249251,10 @@ var OperationSchema = looseObject({
249258
249251
  responses: record(string2(), unknown()).optional(),
249259
249252
  security: array(SecurityRequirementSchema).optional()
249260
249253
  });
249261
- 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
+ });
249262
249258
  var OpenApiSpecSchema = looseObject({
249263
249259
  openapi: string2(),
249264
249260
  paths: record(string2(), PathItemSchema),
@@ -249281,12 +249277,30 @@ function parameterText(operation) {
249281
249277
  return parsed.success ? [parsed.data.name, parsed.data.description ?? ""] : [];
249282
249278
  }).join(" ");
249283
249279
  }
249280
+ function mergeParameters(shared, own) {
249281
+ if (!shared?.length) {
249282
+ return own;
249283
+ }
249284
+ const key = (parameter) => {
249285
+ const parsed = ParameterSchema.safeParse(parameter);
249286
+ return parsed.success ? `${parsed.data.in}:${parsed.data.name}` : undefined;
249287
+ };
249288
+ const ownKeys = new Set((own ?? []).map(key));
249289
+ return [
249290
+ ...shared.filter((parameter) => !ownKeys.has(key(parameter))),
249291
+ ...own ?? []
249292
+ ];
249293
+ }
249284
249294
  function listOperations(spec) {
249285
249295
  return Object.entries(spec.paths).flatMap(([path, item]) => HTTP_METHODS.flatMap((method) => {
249286
- const operation = item[method];
249287
- if (!operation) {
249296
+ const declared = item[method];
249297
+ if (!declared) {
249288
249298
  return [];
249289
249299
  }
249300
+ const operation = {
249301
+ ...declared,
249302
+ parameters: mergeParameters(item.parameters, declared.parameters)
249303
+ };
249290
249304
  return [
249291
249305
  {
249292
249306
  endpoint: `${method.toUpperCase()} ${path}`,
@@ -249363,21 +249377,87 @@ function jsonSchemaOf(value) {
249363
249377
  const parsed = RequestBodySchema.safeParse(value);
249364
249378
  return parsed.success ? parsed.data.content?.["application/json"]?.schema : undefined;
249365
249379
  }
249380
+ function requestBodyOf(value) {
249381
+ const parsed = RequestBodySchema.safeParse(value);
249382
+ const content = parsed.success ? parsed.data.content ?? {} : {};
249383
+ const contentType = "application/json" in content ? "application/json" : Object.keys(content)[0];
249384
+ return contentType ? { contentType, schema: content[contentType]?.schema } : {};
249385
+ }
249386
+ function leftoverRefs(node, schemas, found = new Map) {
249387
+ if (Array.isArray(node)) {
249388
+ for (const item of node) {
249389
+ leftoverRefs(item, schemas, found);
249390
+ }
249391
+ } else if (node !== null && typeof node === "object") {
249392
+ for (const [key, value] of Object.entries(node)) {
249393
+ if (key === "$ref" && typeof value === "string" && value.startsWith(SCHEMA_REF_PREFIX) && !found.has(value)) {
249394
+ const schema = schemas[value.slice(SCHEMA_REF_PREFIX.length)];
249395
+ found.set(value, schema);
249396
+ leftoverRefs(schema, schemas, found);
249397
+ } else {
249398
+ leftoverRefs(value, schemas, found);
249399
+ }
249400
+ }
249401
+ }
249402
+ return found;
249403
+ }
249404
+ var SCHEMA_DATA_KEYS = new Set([
249405
+ "example",
249406
+ "examples",
249407
+ "default",
249408
+ "enum",
249409
+ "const"
249410
+ ]);
249411
+ var DOCS_CALLOUT = /<(Info|Note|Tip|Check|Warning)>([\s\S]*?)<\/\1>/g;
249412
+ var RELATIVE_LINK = /\[([^\]]+)\]\(\/[^)]*\)/g;
249413
+ function cleanText(text) {
249414
+ return text.replace(DOCS_CALLOUT, (_, kind, body) => kind === "Warning" ? `Warning: ${body}` : body).replace(RELATIVE_LINK, "$1");
249415
+ }
249416
+ function slimSchema(node, isPropertyMap = false) {
249417
+ if (Array.isArray(node)) {
249418
+ return node.map((item) => slimSchema(item));
249419
+ }
249420
+ if (node === null || typeof node !== "object") {
249421
+ return node;
249422
+ }
249423
+ const entries = Object.entries(node);
249424
+ if (isPropertyMap) {
249425
+ return Object.fromEntries(entries.map(([name, value]) => [name, slimSchema(value)]));
249426
+ }
249427
+ const slim = {};
249428
+ for (const [key, value] of entries) {
249429
+ if (key === "title" && typeof value === "string") {
249430
+ continue;
249431
+ }
249432
+ slim[key] = SCHEMA_DATA_KEYS.has(key) ? value : key === "properties" ? slimSchema(value, true) : key === "description" && typeof value === "string" ? cleanText(value) : slimSchema(value);
249433
+ }
249434
+ const { anyOf, ...rest } = slim;
249435
+ const nullable = Array.isArray(anyOf) && anyOf.length === 2 ? nullableType(anyOf) : undefined;
249436
+ return nullable ? { type: [nullable, "null"], ...rest } : slim;
249437
+ }
249438
+ function nullableType(variants) {
249439
+ const types = variants.map((variant) => variant !== null && typeof variant === "object" && Object.keys(variant).length === 1 && typeof variant.type === "string" ? variant.type : undefined);
249440
+ if (types.includes(undefined) || !types.includes("null")) {
249441
+ return;
249442
+ }
249443
+ return types.find((type) => type !== "null");
249444
+ }
249366
249445
  function getOperationContract(spec, op) {
249367
249446
  const schemas = spec.components?.schemas ?? {};
249368
- const inline = (node) => node === undefined ? null : inlineRefs(node, schemas);
249447
+ const inline = (node) => node === undefined ? null : slimSchema(inlineRefs(node, schemas));
249369
249448
  const responses = Object.entries(op.operation.responses ?? {}).flatMap(([status, response]) => {
249370
249449
  const parsed = ResponseObjectSchema.safeParse(response);
249371
249450
  return parsed.success ? [[status, parsed.data]] : [];
249372
249451
  });
249373
249452
  const success = responses.filter(([status]) => status.startsWith("2")).sort(([a], [b]) => a.localeCompare(b)).map(([, response]) => jsonSchemaOf(response)).find(Boolean);
249374
249453
  const errors = responses.filter(([status, response]) => !status.startsWith("2") && response.description !== FRAMEWORK_VALIDATION_ERROR);
249375
- return {
249454
+ const requestBody = requestBodyOf(op.operation.requestBody);
249455
+ const contract = {
249376
249456
  endpoint: op.endpoint,
249377
249457
  method: op.method,
249378
249458
  path: op.path,
249379
249459
  summary: op.summary,
249380
- description: op.description,
249460
+ description: cleanText(op.description),
249381
249461
  parameters: (op.operation.parameters ?? []).flatMap((parameter) => {
249382
249462
  const parsed = ParameterSchema.safeParse(parameter);
249383
249463
  if (!parsed.success) {
@@ -249391,23 +249471,50 @@ function getOperationContract(spec, op) {
249391
249471
  in: location2,
249392
249472
  required: required ?? false,
249393
249473
  schema: inline(schema ?? {}),
249394
- ...description && !inSchema ? { description } : {},
249474
+ ...description && !inSchema ? { description: cleanText(description) } : {},
249395
249475
  ..."example" in parsed.data ? { example: parsed.data.example } : {}
249396
249476
  }
249397
249477
  ];
249398
249478
  }),
249399
- requestBodySchema: inline(jsonSchemaOf(op.operation.requestBody)),
249479
+ ...requestBody.contentType && requestBody.contentType !== "application/json" ? { requestBodyContentType: requestBody.contentType } : {},
249480
+ requestBodySchema: inline(requestBody.schema),
249400
249481
  responseSchema: inline(success),
249401
- errors: Object.fromEntries(errors.map(([status, response]) => [status, response.description ?? ""]))
249482
+ errors: Object.fromEntries(errors.map(([status, response]) => [
249483
+ status,
249484
+ cleanText(response.description ?? "")
249485
+ ]))
249402
249486
  };
249487
+ const refs = leftoverRefs(contract, schemas);
249488
+ return {
249489
+ ...contract,
249490
+ ...refs.size > 0 ? {
249491
+ refs: Object.fromEntries([...refs].map(([ref, schema]) => [ref, slimSchema(schema)]))
249492
+ } : {}
249493
+ };
249494
+ }
249495
+
249496
+ // src/core/api-spec/grep.ts
249497
+ function grepOperations(spec, operations, pattern, options = {}) {
249498
+ const regex = new RegExp(pattern, options.ignoreCase ? "i" : "");
249499
+ return operations.filter((op) => regex.test(JSON.stringify(getOperationContract(spec, op)))).slice(0, options.limit ?? 20).map(toOperationSummary);
249403
249500
  }
249404
249501
  // src/core/api-spec/request.ts
249502
+ var MAX_ERROR_BODY_CHARS = 4000;
249503
+ async function readBody(response) {
249504
+ try {
249505
+ const text = (await response.clone().text()).trim();
249506
+ return text.length > MAX_ERROR_BODY_CHARS ? `${text.slice(0, MAX_ERROR_BODY_CHARS)}…` : text || undefined;
249507
+ } catch {
249508
+ return;
249509
+ }
249510
+ }
249405
249511
  async function sendApiRequest(method, path, body) {
249406
249512
  try {
249407
249513
  const response = await base44Client(path.replace(/^\/+/, ""), {
249408
249514
  method,
249409
249515
  body,
249410
- headers: body === undefined ? {} : { "Content-Type": "application/json" }
249516
+ headers: body === undefined ? {} : { "Content-Type": "application/json" },
249517
+ timeout: false
249411
249518
  });
249412
249519
  return {
249413
249520
  status: response.status,
@@ -249415,11 +249522,21 @@ async function sendApiRequest(method, path, body) {
249415
249522
  body: new Uint8Array(await response.arrayBuffer())
249416
249523
  };
249417
249524
  } catch (error) {
249418
- throw await ApiError.fromHttpError(error, `calling ${method} ${path}`);
249525
+ const apiError = await ApiError.fromHttpError(error, `calling ${method} ${path}`);
249526
+ const raw = error instanceof HTTPError ? await readBody(error.response) : undefined;
249527
+ const message = raw && apiError.statusCode !== undefined ? `Error calling ${method} ${path}: HTTP ${apiError.statusCode}` : apiError.message;
249528
+ throw new ApiError(message, {
249529
+ statusCode: apiError.statusCode,
249530
+ requestUrl: apiError.requestUrl,
249531
+ requestMethod: apiError.requestMethod,
249532
+ requestId: apiError.requestId,
249533
+ hints: apiError.hints,
249534
+ details: raw ? [`Response body: ${raw}`] : apiError.details
249535
+ });
249419
249536
  }
249420
249537
  }
249421
249538
  // src/core/api-spec/spec.ts
249422
- import { stat as stat3 } from "node:fs/promises";
249539
+ import { rename, stat as stat3 } from "node:fs/promises";
249423
249540
  import { join as join22 } from "node:path";
249424
249541
  var SPEC_CACHE_TTL_MS = 60 * 60 * 1000;
249425
249542
  function getSpecCachePath(apiUrl = getBase44ApiUrl()) {
@@ -249442,17 +249559,24 @@ function parseSpec(text) {
249442
249559
  }
249443
249560
  return result.data;
249444
249561
  }
249562
+ var SPEC_DOWNLOAD_TIMEOUT_MS = 60000;
249445
249563
  async function readFreshCache(path) {
249446
249564
  try {
249447
249565
  const { mtimeMs } = await stat3(path);
249448
- return isSpecCacheFresh(mtimeMs) ? await readTextFile(path) : null;
249566
+ if (!isSpecCacheFresh(mtimeMs)) {
249567
+ return null;
249568
+ }
249569
+ const text = await readTextFile(path);
249570
+ return { text, spec: parseSpec(text) };
249449
249571
  } catch {
249450
249572
  return null;
249451
249573
  }
249452
249574
  }
249453
249575
  async function downloadSpec() {
249454
249576
  try {
249455
- const response = await base44Client.get("api/openapi.json");
249577
+ const response = await base44Client.get("api/openapi.json", {
249578
+ timeout: SPEC_DOWNLOAD_TIMEOUT_MS
249579
+ });
249456
249580
  return await response.text();
249457
249581
  } catch (error) {
249458
249582
  throw await ApiError.fromHttpError(error, "fetching the API spec");
@@ -249462,17 +249586,19 @@ async function loadSpec(options = {}) {
249462
249586
  const path = getSpecCachePath();
249463
249587
  const cached = options.refresh ? null : await readFreshCache(path);
249464
249588
  if (cached !== null) {
249465
- return { text: cached, spec: parseSpec(cached) };
249589
+ return cached;
249466
249590
  }
249467
249591
  const text = await downloadSpec();
249468
249592
  const spec = parseSpec(text);
249469
- await writeFile(path, text);
249593
+ const partial = `${path}.${process.pid}.tmp`;
249594
+ await writeFile(partial, text);
249595
+ await rename(partial, path);
249470
249596
  return { text, spec };
249471
249597
  }
249472
249598
  // src/cli/commands/api/shared.ts
249599
+ import { fstatSync } from "node:fs";
249473
249600
  function formatJson(value) {
249474
- return `${JSON.stringify(value, null, process.stdout.isTTY ? 2 : undefined)}
249475
- `;
249601
+ return toJsonStdout(value, { compact: !process.stdout.isTTY });
249476
249602
  }
249477
249603
  function parseLimit(value) {
249478
249604
  if (value === undefined) {
@@ -249502,33 +249628,37 @@ function operationsInArea(operations, area) {
249502
249628
  }
249503
249629
  return inArea;
249504
249630
  }
249505
- async function readRequestBody(method, flag) {
249631
+ function isPipedStdin() {
249632
+ try {
249633
+ const stats = fstatSync(0);
249634
+ return stats.isFIFO() || stats.isFile();
249635
+ } catch {
249636
+ return false;
249637
+ }
249638
+ }
249639
+ async function readRequestBody(flag, log) {
249506
249640
  if (flag === "@-") {
249507
249641
  return readStdin("--body @-", { trim: false });
249508
249642
  }
249509
249643
  if (flag?.startsWith("@")) {
249510
249644
  return readTextFile(flag.slice(1));
249511
249645
  }
249512
- if (flag !== undefined) {
249513
- return flag;
249646
+ if (flag === undefined && isPipedStdin()) {
249647
+ log.warn("stdin is ignored; pass --body @- to send it as the body.");
249514
249648
  }
249515
- if (method === "GET" || method === "HEAD" || process.stdin.isTTY) {
249516
- return;
249517
- }
249518
- const piped = await readStdin("--body", { trim: false });
249519
- return piped.trim() ? piped : undefined;
249649
+ return flag;
249520
249650
  }
249521
249651
 
249522
249652
  // src/cli/commands/api/catalog.ts
249523
249653
  async function catalogAction(ctx, area, options) {
249524
249654
  const { spec } = await loadSpecTask(ctx, options.refresh);
249525
- const operations = listOperations(spec).filter((op) => !options.readOnly || op.readOnly);
249655
+ const operations = listOperations(spec);
249656
+ const readOnly = (ops) => options.readOnly ? ops.filter((op) => op.readOnly) : ops;
249526
249657
  if (area === undefined) {
249527
- return { stdout: formatJson(catalogIndex(operations)) };
249658
+ return { stdout: formatJson(catalogIndex(readOnly(operations))) };
249528
249659
  }
249529
- return {
249530
- stdout: formatJson(areaListing(area, operationsInArea(operations, area)))
249531
- };
249660
+ const inArea = readOnly(operationsInArea(operations, area));
249661
+ return { stdout: formatJson(areaListing(area, inArea)) };
249532
249662
  }
249533
249663
  function getApiCatalogCommand() {
249534
249664
  return new Base44Command("catalog", {
@@ -249538,12 +249668,16 @@ function getApiCatalogCommand() {
249538
249668
  }
249539
249669
 
249540
249670
  // src/cli/commands/api/fetch.ts
249541
- async function findOperation(ctx, method, path, refresh) {
249671
+ async function findOperation(ctx, method, path, { refresh, flag }) {
249542
249672
  const { spec } = await loadSpecTask(ctx, refresh);
249543
249673
  const op = matchOperation(listOperations(spec), method, path);
249544
249674
  if (!op) {
249545
249675
  throw new InvalidInputError(`No operation in the API spec matches ${method} ${path}.`, {
249546
249676
  hints: [
249677
+ {
249678
+ message: "The cached spec may predate this route; fetch it again",
249679
+ command: `base44 api fetch ${method} ${path} ${flag} --refresh`
249680
+ },
249547
249681
  {
249548
249682
  message: "Find the operation and its path template",
249549
249683
  command: 'base44 api search "<what you want to do>"'
@@ -249563,7 +249697,7 @@ var TEXT_CONTENT_TYPES = [
249563
249697
  function isText(contentType) {
249564
249698
  return !contentType || TEXT_CONTENT_TYPES.some((hint) => contentType.toLowerCase().includes(hint));
249565
249699
  }
249566
- async function formatResponse({ status, contentType, body }, output) {
249700
+ async function formatResponse({ status, contentType, body }, output, jsonMode) {
249567
249701
  if (output !== undefined) {
249568
249702
  await writeFile(output, body);
249569
249703
  return formatJson({ status, contentType, bytes: body.length, output });
@@ -249572,12 +249706,20 @@ async function formatResponse({ status, contentType, body }, output) {
249572
249706
  return formatJson({ status });
249573
249707
  }
249574
249708
  if (!isText(contentType)) {
249575
- throw new InvalidInputError(`The response is binary (${contentType}, ${body.length} bytes), so it was not printed. The request was sent; add --output <file> to save the response.`);
249709
+ return formatJson({
249710
+ status,
249711
+ contentType,
249712
+ bytes: body.length,
249713
+ note: "Binary body not printed; add --output <file> to save it."
249714
+ });
249576
249715
  }
249577
249716
  const text = new TextDecoder().decode(body);
249578
249717
  try {
249579
249718
  return formatJson(JSON.parse(text));
249580
249719
  } catch {
249720
+ if (jsonMode) {
249721
+ return formatJson({ status, contentType, body: text });
249722
+ }
249581
249723
  return text.endsWith(`
249582
249724
  `) ? text : `${text}
249583
249725
  `;
@@ -249586,34 +249728,50 @@ async function formatResponse({ status, contentType, body }, output) {
249586
249728
  async function fetchAction(ctx, methodArg, path, options, command) {
249587
249729
  if (!methodArg || !path) {
249588
249730
  if (options.help) {
249589
- return { stdout: command.helpInformation() };
249731
+ const usage = command.helpInformation();
249732
+ return { stdout: ctx.jsonMode ? formatJson({ usage }) : usage };
249590
249733
  }
249591
249734
  throw new InvalidInputError("Provide a method and a path, e.g. GET /api/apps.");
249592
249735
  }
249593
249736
  const method = methodArg.toUpperCase();
249594
249737
  if (options.help) {
249595
- const { spec, op } = await findOperation(ctx, method, path, options.refresh);
249738
+ const { spec, op } = await findOperation(ctx, method, path, {
249739
+ refresh: options.refresh,
249740
+ flag: "--help"
249741
+ });
249596
249742
  return { stdout: formatJson(getOperationContract(spec, op)) };
249597
249743
  }
249598
249744
  if (options.readOnly) {
249599
- const { op } = await findOperation(ctx, method, path, options.refresh);
249745
+ const { op } = await findOperation(ctx, method, path, {
249746
+ refresh: options.refresh,
249747
+ flag: "--read-only"
249748
+ });
249600
249749
  if (!op.readOnly) {
249601
249750
  throw new InvalidInputError(`Refused under --read-only: ${op.method} ${op.path} is not a read-only operation. Nothing was sent.`);
249602
249751
  }
249603
249752
  }
249753
+ ctx.errorReporter.setContext({
249754
+ command: {
249755
+ name: "api fetch",
249756
+ args: [method, path.split("?", 1)[0] ?? ""],
249757
+ options: { ...options, body: options.body && "[not reported]" }
249758
+ }
249759
+ });
249604
249760
  await ensureAuth(ctx);
249605
- const body = await readRequestBody(method, options.body);
249761
+ const body = await readRequestBody(options.body, ctx.log);
249606
249762
  const response = await ctx.runTask(`Calling ${method} ${path}`, () => sendApiRequest(method, path, body), {
249607
249763
  successMessage: `Called ${method} ${path}`,
249608
249764
  errorMessage: "Request failed"
249609
249765
  });
249610
- return { stdout: await formatResponse(response, options.output) };
249766
+ return {
249767
+ stdout: await formatResponse(response, options.output, ctx.jsonMode)
249768
+ };
249611
249769
  }
249612
249770
  function getApiFetchCommand() {
249613
249771
  return new Base44Command("fetch", {
249614
249772
  requireAuth: false,
249615
249773
  requireAppContext: false
249616
- }).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("--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);
249774
+ }).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);
249617
249775
  }
249618
249776
 
249619
249777
  // src/cli/commands/api/grep.ts
@@ -249628,15 +249786,16 @@ async function grepAction(ctx, pattern, options) {
249628
249786
  const limit = parseLimit(options.limit);
249629
249787
  assertValidRegex(pattern);
249630
249788
  const { spec } = await loadSpecTask(ctx, options.refresh);
249631
- const operations = listOperations(spec);
249789
+ let operations = listOperations(spec);
249632
249790
  if (options.area !== undefined) {
249633
- operationsInArea(operations, options.area);
249791
+ operations = operationsInArea(operations, options.area);
249792
+ }
249793
+ if (options.readOnly) {
249794
+ operations = operations.filter((op) => op.readOnly);
249634
249795
  }
249635
- const hits = grepSpec(spec, operations, pattern, {
249636
- area: options.area,
249796
+ const hits = grepOperations(spec, operations, pattern, {
249637
249797
  ignoreCase: options.ignoreCase,
249638
- limit,
249639
- readOnly: options.readOnly
249798
+ limit
249640
249799
  });
249641
249800
  return { stdout: formatJson(hits) };
249642
249801
  }
@@ -249644,7 +249803,7 @@ function getApiGrepCommand() {
249644
249803
  return new Base44Command("grep", {
249645
249804
  requireAuth: false,
249646
249805
  requireAppContext: false
249647
- }).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("--read-only", READ_ONLY_FILTER_HELP).option("--refresh", REFRESH_OPTION_HELP).action(grepAction);
249806
+ }).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);
249648
249807
  }
249649
249808
 
249650
249809
  // src/cli/commands/api/search.ts
@@ -262204,7 +262363,7 @@ var nativeEnumType = ZodNativeEnum.create;
262204
262363
  var promiseType = ZodPromise.create;
262205
262364
  var effectsType = ZodEffects.create;
262206
262365
  var optionalType = ZodOptional2.create;
262207
- var nullableType = ZodNullable2.create;
262366
+ var nullableType2 = ZodNullable2.create;
262208
262367
  var preprocessType = ZodEffects.createWithPreprocess;
262209
262368
  var pipelineType = ZodPipeline.create;
262210
262369
  // ../functions-compiler/src/contracts.ts
@@ -273206,4 +273365,4 @@ export {
273206
273365
  runCLI
273207
273366
  };
273208
273367
 
273209
- //# debugId=874A12DB9A1B72DD64756E2164756E21
273368
+ //# debugId=34B2FE9173AAC44664756E2164756E21