@base44-preview/cli 0.1.32-pr.663.d960536 → 0.1.32-pr.663.dc1ede1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/dist/cli/index.js +378 -145
- package/dist/cli/index.js.map +17 -17
- package/package.json +1 -1
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
|
|
119126
|
+
function tokenize2(value, options8) {
|
|
119127
119127
|
if (options8.stripTrailingCr) {
|
|
119128
119128
|
value = value.replace(/\r\n/g, `
|
|
119129
119129
|
`);
|
|
@@ -120053,7 +120053,7 @@ function highlight(text) {
|
|
|
120053
120053
|
for (const {
|
|
120054
120054
|
type,
|
|
120055
120055
|
value
|
|
120056
|
-
} of
|
|
120056
|
+
} of tokenize22(text)) {
|
|
120057
120057
|
if (type in defs) {
|
|
120058
120058
|
highlighted += value.split(NEWLINE$1).map((str) => defs[type](str)).join(`
|
|
120059
120059
|
`);
|
|
@@ -124581,7 +124581,7 @@ var require2, __filename2, __dirname3, __create2, __defProp3, __getOwnPropDesc2,
|
|
|
124581
124581
|
return internalize({ "": root }, "", reviver);
|
|
124582
124582
|
}
|
|
124583
124583
|
return root;
|
|
124584
|
-
}, lexState, buffer, doubleQuote, sign, c7, lexStates, parseStates, dist_default, import_picocolors4, import_js_tokens, nonASCIIidentifierStartChars = "ªµºÀ-ÖØ-öø-ˁˆ-ˑˠ-ˤˬˮͰ-ʹͶͷͺ-ͽͿΆΈ-ΊΌΎ-ΡΣ-ϵϷ-ҁҊ-ԯԱ-Ֆՙՠ-ֈא-תׯ-ײؠ-يٮٯٱ-ۓەۥۦۮۯۺ-ۼۿܐܒ-ܯݍ-ޥޱߊ-ߪߴߵߺࠀ-ࠕࠚࠤࠨࡀ-ࡘࡠ-ࡪࡰ-ࢇࢉ-ࢠ-ࣉऄ-हऽॐक़-ॡॱ-ঀঅ-ঌএঐও-নপ-রলশ-হঽৎড়ঢ়য়-ৡৰৱৼਅ-ਊਏਐਓ-ਨਪ-ਰਲਲ਼ਵਸ਼ਸਹਖ਼-ੜਫ਼ੲ-ੴઅ-ઍએ-ઑઓ-નપ-રલળવ-હઽૐૠૡૹଅ-ଌଏଐଓ-ନପ-ରଲଳଵ-ହଽଡ଼ଢ଼ୟ-ୡୱஃஅ-ஊஎ-ஐஒ-கஙசஜஞடணதந-பம-ஹௐఅ-ఌఎ-ఐఒ-నప-హఽౘ-ౚౝౠౡಀಅ-ಌಎ-ಐಒ-ನಪ-ಳವ-ಹಽ-ೞೠೡೱೲഄ-ഌഎ-ഐഒ-ഺഽൎൔ-ൖൟ-ൡൺ-ൿඅ-ඖක-නඳ-රලව-ෆก-ะาำเ-ๆກຂຄຆ-ຊຌ-ຣລວ-ະາຳຽເ-ໄໆໜ-ໟༀཀ-ཇཉ-ཬྈ-ྌက-ဪဿၐ-ၕၚ-ၝၡၥၦၮ-ၰၵ-ႁႎႠ-ჅჇჍა-ჺჼ-ቈቊ-ቍቐ-ቖቘቚ-ቝበ-ኈኊ-ኍነ-ኰኲ-ኵኸ-ኾዀዂ-ዅወ-ዖዘ-ጐጒ-ጕጘ-ፚᎀ-ᎏᎠ-Ᏽᏸ-ᏽᐁ-ᙬᙯ-ᙿᚁ-ᚚᚠ-ᛪᛮ-ᛸᜀ-ᜑᜟ-ᜱᝀ-ᝑᝠ-ᝬᝮ-ᝰក-ឳៗៜᠠ-ᡸᢀ-ᢨᢪᢰ-ᣵᤀ-ᤞᥐ-ᥭᥰ-ᥴᦀ-ᦫᦰ-ᧉᨀ-ᨖᨠ-ᩔᪧᬅ-ᬳᭅ-ᭌᮃ-ᮠᮮᮯᮺ-ᯥᰀ-ᰣᱍ-ᱏᱚ-ᱽᲀ-Ა-ᲺᲽ-Ჿᳩ-ᳬᳮ-ᳳᳵᳶᳺᴀ-ᶿḀ-ἕἘ-Ἕἠ-ὅὈ-Ὅὐ-ὗὙὛὝὟ-ώᾀ-ᾴᾶ-ᾼιῂ-ῄῆ-ῌῐ-ΐῖ-Ίῠ-Ῥῲ-ῴῶ-ῼⁱⁿₐ-ₜℂℇℊ-ℓℕ℘-ℝℤΩℨK-ℹℼ-ℿⅅ-ⅉⅎⅠ-ↈⰀ-ⳤⳫ-ⳮⳲⳳⴀ-ⴥⴧⴭⴰ-ⵧⵯⶀ-ⶖⶠ-ⶦⶨ-ⶮⶰ-ⶶⶸ-ⶾⷀ-ⷆⷈ-ⷎⷐ-ⷖⷘ-ⷞ々-〇〡-〩〱-〵〸-〼ぁ-ゖ゛-ゟァ-ヺー-ヿㄅ-ㄯㄱ-ㆎㆠ-ㆿㇰ-ㇿ㐀-䶿一-ꒌꓐ-ꓽꔀ-ꘌꘐ-ꘟꘪꘫꙀ-ꙮꙿ-ꚝꚠ-ꛯꜗ-ꜟꜢ-ꞈꞋ--ꠁꠃ-ꠅꠇ-ꠊꠌ-ꠢꡀ-ꡳꢂ-ꢳꣲ-ꣷꣻꣽꣾꤊ-ꤥꤰ-ꥆꥠ-ꥼꦄ-ꦲꧏꧠ-ꧤꧦ-ꧯꧺ-ꧾꨀ-ꨨꩀ-ꩂꩄ-ꩋꩠ-ꩶꩺꩾ-ꪯꪱꪵꪶꪹ-ꪽꫀꫂꫛ-ꫝꫠ-ꫪꫲ-ꫴꬁ-ꬆꬉ-ꬎꬑ-ꬖꬠ-ꬦꬨ-ꬮꬰ-ꭚꭜ-ꭩꭰ-ꯢ가-힣ힰ-ퟆퟋ-ퟻ豈-舘並-龎ff-stﬓ-ﬗיִײַ-ﬨשׁ-זּטּ-לּמּנּסּףּפּצּ-ﮱﯓ-ﴽﵐ-ﶏﶒ-ﷇﷰ-ﷻﹰ-ﹴﹶ-ﻼA-Za-zヲ-하-ᅦᅧ-ᅬᅭ-ᅲᅳ-ᅵ", nonASCIIidentifierChars = "·̀-ͯ·҃-֑҇-ׇֽֿׁׂׅׄؐ-ًؚ-٩ٰۖ-ۜ۟-۪ۤۧۨ-ۭ۰-۹ܑܰ-݊ަ-ް߀-߉߫-߽߳ࠖ-࠙ࠛ-ࠣࠥ-ࠧࠩ-࡙࠭-࡛-࢟࣊-ࣣ࣡-ःऺ-़ा-ॏ॑-ॗॢॣ०-९ঁ-ঃ়া-ৄেৈো-্ৗৢৣ০-৯৾ਁ-ਃ਼ਾ-ੂੇੈੋ-੍ੑ੦-ੱੵઁ-ઃ઼ા-ૅે-ૉો-્ૢૣ૦-૯ૺ-૿ଁ-ଃ଼ା-ୄେୈୋ-୍୕-ୗୢୣ୦-୯ஂா-ூெ-ைொ-்ௗ௦-௯ఀ-ఄ఼ా-ౄె-ైొ-్ౕౖౢౣ౦-౯ಁ-ಃ಼ಾ-ೄೆ-ೈೊ-್ೕೖೢೣ೦-೯ೳഀ-ഃ഻഼ാ-ൄെ-ൈൊ-്ൗൢൣ൦-൯ඁ-ඃ්ා-ුූෘ-ෟ෦-෯ෲෳัิ-ฺ็-๎๐-๙ັິ-ຼ່-໎໐-໙༘༙༠-༩༹༵༷༾༿ཱ-྄྆྇ྍ-ྗྙ-ྼ࿆ါ-ှ၀-၉ၖ-ၙၞ-ၠၢ-ၤၧ-ၭၱ-ၴႂ-ႍႏ-ႝ፝-፟፩-፱ᜒ-᜕ᜲ-᜴ᝒᝓᝲᝳ឴-៓៝០-៩᠋-᠍᠏-᠙ᢩᤠ-ᤫᤰ-᤻᥆-᥏᧐-᧚ᨗ-ᨛᩕ-ᩞ᩠-᩿᩼-᪉᪐-᪙᪰-᪽ᪿ--ᬀ-ᬄ᬴-᭄᭐-᭙᭫-᭳ᮀ-ᮂᮡ-ᮭ᮰-᮹᯦-᯳ᰤ-᰷᱀-᱉᱐-᱙᳐-᳔᳒-᳨᳭᳴᳷-᳹᷀-᷿‿⁀⁔⃐-⃥⃜⃡-⃰⳯-⵿⳱ⷠ-〪ⷿ-゙゚〯・꘠-꘩꙯ꙴ-꙽ꚞꚟ꛰꛱ꠂ꠆ꠋꠣ-ꠧ꠬ꢀꢁꢴ-ꣅ꣐-꣙꣠-꣱ꣿ-꤉ꤦ-꤭ꥇ-꥓ꦀ-ꦃ꦳-꧀꧐-꧙ꧥ꧰-꧹ꨩ-ꨶꩃꩌꩍ꩐-꩙ꩻ-ꩽꪰꪲ-ꪴꪷꪸꪾ꪿꫁ꫫ-ꫯꫵ꫶ꯣ-ꯪ꯬꯭꯰-꯹ﬞ︀-️︠-︯︳︴﹍-﹏0-9_・", nonASCIIidentifierStart, nonASCIIidentifier, reservedWords, keywords, reservedWordsStrictSet, reservedWordsStrictBindSet, compose = (f, g) => (v) => f(g(v)), defsOn, defsOff, sometimesKeywords, NEWLINE$1, BRACKET,
|
|
124584
|
+
}, lexState, buffer, doubleQuote, sign, c7, lexStates, parseStates, dist_default, import_picocolors4, import_js_tokens, nonASCIIidentifierStartChars = "ªµºÀ-ÖØ-öø-ˁˆ-ˑˠ-ˤˬˮͰ-ʹͶͷͺ-ͽͿΆΈ-ΊΌΎ-ΡΣ-ϵϷ-ҁҊ-ԯԱ-Ֆՙՠ-ֈא-תׯ-ײؠ-يٮٯٱ-ۓەۥۦۮۯۺ-ۼۿܐܒ-ܯݍ-ޥޱߊ-ߪߴߵߺࠀ-ࠕࠚࠤࠨࡀ-ࡘࡠ-ࡪࡰ-ࢇࢉ-ࢠ-ࣉऄ-हऽॐक़-ॡॱ-ঀঅ-ঌএঐও-নপ-রলশ-হঽৎড়ঢ়য়-ৡৰৱৼਅ-ਊਏਐਓ-ਨਪ-ਰਲਲ਼ਵਸ਼ਸਹਖ਼-ੜਫ਼ੲ-ੴઅ-ઍએ-ઑઓ-નપ-રલળવ-હઽૐૠૡૹଅ-ଌଏଐଓ-ନପ-ରଲଳଵ-ହଽଡ଼ଢ଼ୟ-ୡୱஃஅ-ஊஎ-ஐஒ-கஙசஜஞடணதந-பம-ஹௐఅ-ఌఎ-ఐఒ-నప-హఽౘ-ౚౝౠౡಀಅ-ಌಎ-ಐಒ-ನಪ-ಳವ-ಹಽ-ೞೠೡೱೲഄ-ഌഎ-ഐഒ-ഺഽൎൔ-ൖൟ-ൡൺ-ൿඅ-ඖක-නඳ-රලව-ෆก-ะาำเ-ๆກຂຄຆ-ຊຌ-ຣລວ-ະາຳຽເ-ໄໆໜ-ໟༀཀ-ཇཉ-ཬྈ-ྌက-ဪဿၐ-ၕၚ-ၝၡၥၦၮ-ၰၵ-ႁႎႠ-ჅჇჍა-ჺჼ-ቈቊ-ቍቐ-ቖቘቚ-ቝበ-ኈኊ-ኍነ-ኰኲ-ኵኸ-ኾዀዂ-ዅወ-ዖዘ-ጐጒ-ጕጘ-ፚᎀ-ᎏᎠ-Ᏽᏸ-ᏽᐁ-ᙬᙯ-ᙿᚁ-ᚚᚠ-ᛪᛮ-ᛸᜀ-ᜑᜟ-ᜱᝀ-ᝑᝠ-ᝬᝮ-ᝰក-ឳៗៜᠠ-ᡸᢀ-ᢨᢪᢰ-ᣵᤀ-ᤞᥐ-ᥭᥰ-ᥴᦀ-ᦫᦰ-ᧉᨀ-ᨖᨠ-ᩔᪧᬅ-ᬳᭅ-ᭌᮃ-ᮠᮮᮯᮺ-ᯥᰀ-ᰣᱍ-ᱏᱚ-ᱽᲀ-Ა-ᲺᲽ-Ჿᳩ-ᳬᳮ-ᳳᳵᳶᳺᴀ-ᶿḀ-ἕἘ-Ἕἠ-ὅὈ-Ὅὐ-ὗὙὛὝὟ-ώᾀ-ᾴᾶ-ᾼιῂ-ῄῆ-ῌῐ-ΐῖ-Ίῠ-Ῥῲ-ῴῶ-ῼⁱⁿₐ-ₜℂℇℊ-ℓℕ℘-ℝℤΩℨK-ℹℼ-ℿⅅ-ⅉⅎⅠ-ↈⰀ-ⳤⳫ-ⳮⳲⳳⴀ-ⴥⴧⴭⴰ-ⵧⵯⶀ-ⶖⶠ-ⶦⶨ-ⶮⶰ-ⶶⶸ-ⶾⷀ-ⷆⷈ-ⷎⷐ-ⷖⷘ-ⷞ々-〇〡-〩〱-〵〸-〼ぁ-ゖ゛-ゟァ-ヺー-ヿㄅ-ㄯㄱ-ㆎㆠ-ㆿㇰ-ㇿ㐀-䶿一-ꒌꓐ-ꓽꔀ-ꘌꘐ-ꘟꘪꘫꙀ-ꙮꙿ-ꚝꚠ-ꛯꜗ-ꜟꜢ-ꞈꞋ--ꠁꠃ-ꠅꠇ-ꠊꠌ-ꠢꡀ-ꡳꢂ-ꢳꣲ-ꣷꣻꣽꣾꤊ-ꤥꤰ-ꥆꥠ-ꥼꦄ-ꦲꧏꧠ-ꧤꧦ-ꧯꧺ-ꧾꨀ-ꨨꩀ-ꩂꩄ-ꩋꩠ-ꩶꩺꩾ-ꪯꪱꪵꪶꪹ-ꪽꫀꫂꫛ-ꫝꫠ-ꫪꫲ-ꫴꬁ-ꬆꬉ-ꬎꬑ-ꬖꬠ-ꬦꬨ-ꬮꬰ-ꭚꭜ-ꭩꭰ-ꯢ가-힣ힰ-ퟆퟋ-ퟻ豈-舘並-龎ff-stﬓ-ﬗיִײַ-ﬨשׁ-זּטּ-לּמּנּסּףּפּצּ-ﮱﯓ-ﴽﵐ-ﶏﶒ-ﷇﷰ-ﷻﹰ-ﹴﹶ-ﻼA-Za-zヲ-하-ᅦᅧ-ᅬᅭ-ᅲᅳ-ᅵ", nonASCIIidentifierChars = "·̀-ͯ·҃-֑҇-ׇֽֿׁׂׅׄؐ-ًؚ-٩ٰۖ-ۜ۟-۪ۤۧۨ-ۭ۰-۹ܑܰ-݊ަ-ް߀-߉߫-߽߳ࠖ-࠙ࠛ-ࠣࠥ-ࠧࠩ-࡙࠭-࡛-࢟࣊-ࣣ࣡-ःऺ-़ा-ॏ॑-ॗॢॣ०-९ঁ-ঃ়া-ৄেৈো-্ৗৢৣ০-৯৾ਁ-ਃ਼ਾ-ੂੇੈੋ-੍ੑ੦-ੱੵઁ-ઃ઼ા-ૅે-ૉો-્ૢૣ૦-૯ૺ-૿ଁ-ଃ଼ା-ୄେୈୋ-୍୕-ୗୢୣ୦-୯ஂா-ூெ-ைொ-்ௗ௦-௯ఀ-ఄ఼ా-ౄె-ైొ-్ౕౖౢౣ౦-౯ಁ-ಃ಼ಾ-ೄೆ-ೈೊ-್ೕೖೢೣ೦-೯ೳഀ-ഃ഻഼ാ-ൄെ-ൈൊ-്ൗൢൣ൦-൯ඁ-ඃ්ා-ුූෘ-ෟ෦-෯ෲෳัิ-ฺ็-๎๐-๙ັິ-ຼ່-໎໐-໙༘༙༠-༩༹༵༷༾༿ཱ-྄྆྇ྍ-ྗྙ-ྼ࿆ါ-ှ၀-၉ၖ-ၙၞ-ၠၢ-ၤၧ-ၭၱ-ၴႂ-ႍႏ-ႝ፝-፟፩-፱ᜒ-᜕ᜲ-᜴ᝒᝓᝲᝳ឴-៓៝០-៩᠋-᠍᠏-᠙ᢩᤠ-ᤫᤰ-᤻᥆-᥏᧐-᧚ᨗ-ᨛᩕ-ᩞ᩠-᩿᩼-᪉᪐-᪙᪰-᪽ᪿ--ᬀ-ᬄ᬴-᭄᭐-᭙᭫-᭳ᮀ-ᮂᮡ-ᮭ᮰-᮹᯦-᯳ᰤ-᰷᱀-᱉᱐-᱙᳐-᳔᳒-᳨᳭᳴᳷-᳹᷀-᷿‿⁀⁔⃐-⃥⃜⃡-⃰⳯-⵿⳱ⷠ-〪ⷿ-゙゚〯・꘠-꘩꙯ꙴ-꙽ꚞꚟ꛰꛱ꠂ꠆ꠋꠣ-ꠧ꠬ꢀꢁꢴ-ꣅ꣐-꣙꣠-꣱ꣿ-꤉ꤦ-꤭ꥇ-꥓ꦀ-ꦃ꦳-꧀꧐-꧙ꧥ꧰-꧹ꨩ-ꨶꩃꩌꩍ꩐-꩙ꩻ-ꩽꪰꪲ-ꪴꪷꪸꪾ꪿꫁ꫫ-ꫯꫵ꫶ꯣ-ꯪ꯬꯭꯰-꯹ﬞ︀-️︠-︯︳︴﹍-﹏0-9_・", nonASCIIidentifierStart, nonASCIIidentifier, reservedWords, keywords, reservedWordsStrictSet, reservedWordsStrictBindSet, compose = (f, g) => (v) => f(g(v)), defsOn, defsOff, sometimesKeywords, NEWLINE$1, BRACKET, tokenize22, NEWLINE, getOffsets = ({
|
|
124585
124585
|
oneBased,
|
|
124586
124586
|
oneBasedLine = oneBased,
|
|
124587
124587
|
oneBasedColumn = oneBased
|
|
@@ -133471,7 +133471,7 @@ globstar while`, file, fr, pattern, pr, swallowee);
|
|
|
133471
133471
|
LineDiff = class extends Diff {
|
|
133472
133472
|
constructor() {
|
|
133473
133473
|
super(...arguments);
|
|
133474
|
-
this.tokenize =
|
|
133474
|
+
this.tokenize = tokenize2;
|
|
133475
133475
|
}
|
|
133476
133476
|
equals(left, right, options8) {
|
|
133477
133477
|
if (options8.ignoreWhitespace) {
|
|
@@ -134348,7 +134348,7 @@ globstar while`, file, fr, pattern, pr, swallowee);
|
|
|
134348
134348
|
return "uncolored";
|
|
134349
134349
|
}
|
|
134350
134350
|
};
|
|
134351
|
-
|
|
134351
|
+
tokenize22 = function* (text) {
|
|
134352
134352
|
for (const token2 of (0, import_js_tokens.default)(text, {
|
|
134353
134353
|
jsx: true
|
|
134354
134354
|
})) {
|
|
@@ -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 = {
|
|
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
|
|
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:
|
|
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
|
-
|
|
249139
|
-
|
|
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
|
-
|
|
249178
|
-
|
|
249179
|
-
|
|
249180
|
-
|
|
249181
|
-
|
|
249182
|
-
|
|
249183
|
-
|
|
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 RequestBodySchema = 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(
|
|
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),
|
|
@@ -249260,14 +249277,33 @@ function parameterText(operation) {
|
|
|
249260
249277
|
return parsed.success ? [parsed.data.name, parsed.data.description ?? ""] : [];
|
|
249261
249278
|
}).join(" ");
|
|
249262
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
|
+
}
|
|
249263
249294
|
function listOperations(spec) {
|
|
249264
249295
|
return Object.entries(spec.paths).flatMap(([path, item]) => HTTP_METHODS.flatMap((method) => {
|
|
249265
|
-
const
|
|
249266
|
-
if (!
|
|
249296
|
+
const declared = item[method];
|
|
249297
|
+
if (!declared) {
|
|
249267
249298
|
return [];
|
|
249268
249299
|
}
|
|
249300
|
+
const operation = {
|
|
249301
|
+
...declared,
|
|
249302
|
+
parameters: mergeParameters(item.parameters, declared.parameters)
|
|
249303
|
+
};
|
|
249269
249304
|
return [
|
|
249270
249305
|
{
|
|
249306
|
+
endpoint: `${method.toUpperCase()} ${path}`,
|
|
249271
249307
|
method: method.toUpperCase(),
|
|
249272
249308
|
path,
|
|
249273
249309
|
summary: operation.summary ?? "",
|
|
@@ -249310,63 +249346,197 @@ function matchOperation(operations, method, concretePath) {
|
|
|
249310
249346
|
});
|
|
249311
249347
|
return candidates.sort((a, b) => compareSpecificity(specificity(pathSegments(a.path)), specificity(pathSegments(b.path))))[0];
|
|
249312
249348
|
}
|
|
249313
|
-
|
|
249314
|
-
|
|
249315
|
-
|
|
249316
|
-
|
|
249349
|
+
var SCHEMA_REF_PREFIX = "#/components/schemas/";
|
|
249350
|
+
var MAX_REF_DEPTH = 4;
|
|
249351
|
+
var FRAMEWORK_VALIDATION_ERROR = "Validation Error";
|
|
249352
|
+
function inlineRefs(node, schemas, seen = new Set, depth = 0) {
|
|
249353
|
+
if (depth > MAX_REF_DEPTH) {
|
|
249354
|
+
return node;
|
|
249355
|
+
}
|
|
249356
|
+
if (Array.isArray(node)) {
|
|
249357
|
+
return node.map((item) => inlineRefs(item, schemas, seen, depth));
|
|
249358
|
+
}
|
|
249359
|
+
if (node === null || typeof node !== "object") {
|
|
249360
|
+
return node;
|
|
249361
|
+
}
|
|
249362
|
+
const { $ref, ...siblings } = node;
|
|
249363
|
+
if (typeof $ref === "string" && $ref.startsWith(SCHEMA_REF_PREFIX)) {
|
|
249364
|
+
const name = $ref.slice(SCHEMA_REF_PREFIX.length);
|
|
249365
|
+
if (seen.has(name) || !(name in schemas)) {
|
|
249366
|
+
return node;
|
|
249317
249367
|
}
|
|
249318
|
-
|
|
249368
|
+
const resolved = inlineRefs(schemas[name], schemas, new Set([...seen, name]), depth + 1);
|
|
249369
|
+
return resolved !== null && typeof resolved === "object" ? { ...resolved, ...siblings } : resolved;
|
|
249319
249370
|
}
|
|
249320
|
-
|
|
249321
|
-
|
|
249371
|
+
return Object.fromEntries(Object.entries(node).map(([key, value]) => [
|
|
249372
|
+
key,
|
|
249373
|
+
inlineRefs(value, schemas, seen, depth)
|
|
249374
|
+
]));
|
|
249375
|
+
}
|
|
249376
|
+
function jsonSchemaOf(value) {
|
|
249377
|
+
const parsed = RequestBodySchema.safeParse(value);
|
|
249378
|
+
return parsed.success ? parsed.data.content?.["application/json"]?.schema : undefined;
|
|
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
|
+
}
|
|
249322
249401
|
}
|
|
249323
|
-
|
|
249324
|
-
|
|
249325
|
-
|
|
249326
|
-
|
|
249327
|
-
|
|
249328
|
-
|
|
249329
|
-
|
|
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;
|
|
249330
249431
|
}
|
|
249432
|
+
slim[key] = SCHEMA_DATA_KEYS.has(key) ? value : key === "properties" ? slimSchema(value, true) : key === "description" && typeof value === "string" ? cleanText(value) : slimSchema(value);
|
|
249331
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;
|
|
249332
249437
|
}
|
|
249333
|
-
function
|
|
249334
|
-
|
|
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")) {
|
|
249335
249441
|
return;
|
|
249336
249442
|
}
|
|
249337
|
-
return
|
|
249443
|
+
return types.find((type) => type !== "null");
|
|
249338
249444
|
}
|
|
249339
249445
|
function getOperationContract(spec, op) {
|
|
249340
|
-
const
|
|
249341
|
-
const
|
|
249342
|
-
|
|
249343
|
-
|
|
249446
|
+
const schemas = spec.components?.schemas ?? {};
|
|
249447
|
+
const inline = (node) => node === undefined ? null : slimSchema(inlineRefs(node, schemas));
|
|
249448
|
+
const responses = Object.entries(op.operation.responses ?? {}).flatMap(([status, response]) => {
|
|
249449
|
+
const parsed = ResponseObjectSchema.safeParse(response);
|
|
249450
|
+
return parsed.success ? [[status, parsed.data]] : [];
|
|
249451
|
+
});
|
|
249452
|
+
const success = responses.filter(([status]) => status.startsWith("2")).sort(([a], [b]) => a.localeCompare(b)).map(([, response]) => jsonSchemaOf(response)).find(Boolean);
|
|
249453
|
+
const errors = responses.filter(([status, response]) => !status.startsWith("2") && response.description !== FRAMEWORK_VALIDATION_ERROR);
|
|
249454
|
+
const requestBody = requestBodyOf(op.operation.requestBody);
|
|
249455
|
+
const contract = {
|
|
249456
|
+
endpoint: op.endpoint,
|
|
249344
249457
|
method: op.method,
|
|
249345
249458
|
path: op.path,
|
|
249346
249459
|
summary: op.summary,
|
|
249347
|
-
description: op.description,
|
|
249348
|
-
|
|
249349
|
-
|
|
249350
|
-
|
|
249351
|
-
|
|
249352
|
-
|
|
249460
|
+
description: cleanText(op.description),
|
|
249461
|
+
parameters: (op.operation.parameters ?? []).flatMap((parameter) => {
|
|
249462
|
+
const parsed = ParameterSchema.safeParse(parameter);
|
|
249463
|
+
if (!parsed.success) {
|
|
249464
|
+
return [];
|
|
249465
|
+
}
|
|
249466
|
+
const { name, in: location2, required, schema, description } = parsed.data;
|
|
249467
|
+
const inSchema = schema !== null && typeof schema === "object" && "description" in schema;
|
|
249468
|
+
return [
|
|
249469
|
+
{
|
|
249470
|
+
name,
|
|
249471
|
+
in: location2,
|
|
249472
|
+
required: required ?? false,
|
|
249473
|
+
schema: inline(schema ?? {}),
|
|
249474
|
+
...description && !inSchema ? { description: cleanText(description) } : {},
|
|
249475
|
+
..."example" in parsed.data ? { example: parsed.data.example } : {}
|
|
249476
|
+
}
|
|
249477
|
+
];
|
|
249478
|
+
}),
|
|
249479
|
+
...requestBody.contentType && requestBody.contentType !== "application/json" ? { requestBodyContentType: requestBody.contentType } : {},
|
|
249480
|
+
requestBodySchema: inline(requestBody.schema),
|
|
249481
|
+
responseSchema: inline(success),
|
|
249482
|
+
errors: Object.fromEntries(errors.map(([status, response]) => [
|
|
249483
|
+
status,
|
|
249484
|
+
cleanText(response.description ?? "")
|
|
249485
|
+
]))
|
|
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
|
+
} : {}
|
|
249353
249493
|
};
|
|
249354
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);
|
|
249500
|
+
}
|
|
249355
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
|
+
}
|
|
249356
249511
|
async function sendApiRequest(method, path, body) {
|
|
249357
249512
|
try {
|
|
249358
249513
|
const response = await base44Client(path.replace(/^\/+/, ""), {
|
|
249359
249514
|
method,
|
|
249360
249515
|
body,
|
|
249361
|
-
headers: body === undefined ? {} : { "Content-Type": "application/json" }
|
|
249516
|
+
headers: body === undefined ? {} : { "Content-Type": "application/json" },
|
|
249517
|
+
timeout: false
|
|
249362
249518
|
});
|
|
249363
|
-
return
|
|
249519
|
+
return {
|
|
249520
|
+
status: response.status,
|
|
249521
|
+
contentType: response.headers.get("content-type") ?? "",
|
|
249522
|
+
body: new Uint8Array(await response.arrayBuffer())
|
|
249523
|
+
};
|
|
249364
249524
|
} catch (error) {
|
|
249365
|
-
|
|
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
|
+
});
|
|
249366
249536
|
}
|
|
249367
249537
|
}
|
|
249368
249538
|
// src/core/api-spec/spec.ts
|
|
249369
|
-
import { stat as stat3 } from "node:fs/promises";
|
|
249539
|
+
import { rename, stat as stat3 } from "node:fs/promises";
|
|
249370
249540
|
import { join as join22 } from "node:path";
|
|
249371
249541
|
var SPEC_CACHE_TTL_MS = 60 * 60 * 1000;
|
|
249372
249542
|
function getSpecCachePath(apiUrl = getBase44ApiUrl()) {
|
|
@@ -249389,17 +249559,24 @@ function parseSpec(text) {
|
|
|
249389
249559
|
}
|
|
249390
249560
|
return result.data;
|
|
249391
249561
|
}
|
|
249562
|
+
var SPEC_DOWNLOAD_TIMEOUT_MS = 60000;
|
|
249392
249563
|
async function readFreshCache(path) {
|
|
249393
249564
|
try {
|
|
249394
249565
|
const { mtimeMs } = await stat3(path);
|
|
249395
|
-
|
|
249566
|
+
if (!isSpecCacheFresh(mtimeMs)) {
|
|
249567
|
+
return null;
|
|
249568
|
+
}
|
|
249569
|
+
const text = await readTextFile(path);
|
|
249570
|
+
return { text, spec: parseSpec(text) };
|
|
249396
249571
|
} catch {
|
|
249397
249572
|
return null;
|
|
249398
249573
|
}
|
|
249399
249574
|
}
|
|
249400
249575
|
async function downloadSpec() {
|
|
249401
249576
|
try {
|
|
249402
|
-
const response = await base44Client.get("api/openapi.json"
|
|
249577
|
+
const response = await base44Client.get("api/openapi.json", {
|
|
249578
|
+
timeout: SPEC_DOWNLOAD_TIMEOUT_MS
|
|
249579
|
+
});
|
|
249403
249580
|
return await response.text();
|
|
249404
249581
|
} catch (error) {
|
|
249405
249582
|
throw await ApiError.fromHttpError(error, "fetching the API spec");
|
|
@@ -249409,29 +249586,19 @@ async function loadSpec(options = {}) {
|
|
|
249409
249586
|
const path = getSpecCachePath();
|
|
249410
249587
|
const cached = options.refresh ? null : await readFreshCache(path);
|
|
249411
249588
|
if (cached !== null) {
|
|
249412
|
-
return
|
|
249589
|
+
return cached;
|
|
249413
249590
|
}
|
|
249414
249591
|
const text = await downloadSpec();
|
|
249415
249592
|
const spec = parseSpec(text);
|
|
249416
|
-
|
|
249593
|
+
const partial = `${path}.${process.pid}.tmp`;
|
|
249594
|
+
await writeFile(partial, text);
|
|
249595
|
+
await rename(partial, path);
|
|
249417
249596
|
return { text, spec };
|
|
249418
249597
|
}
|
|
249419
249598
|
// src/cli/commands/api/shared.ts
|
|
249599
|
+
import { fstatSync } from "node:fs";
|
|
249420
249600
|
function formatJson(value) {
|
|
249421
|
-
return
|
|
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
|
-
}
|
|
249601
|
+
return toJsonStdout(value, { compact: !process.stdout.isTTY });
|
|
249435
249602
|
}
|
|
249436
249603
|
function parseLimit(value) {
|
|
249437
249604
|
if (value === undefined) {
|
|
@@ -249443,9 +249610,13 @@ function parseLimit(value) {
|
|
|
249443
249610
|
}
|
|
249444
249611
|
return n;
|
|
249445
249612
|
}
|
|
249613
|
+
var READ_ONLY_FILTER_HELP = "Only read-only operations";
|
|
249446
249614
|
var REFRESH_OPTION_HELP = "Fetch the API spec again instead of using the cached copy (kept 1 hour)";
|
|
249447
|
-
function
|
|
249448
|
-
return
|
|
249615
|
+
function quietTask({ runTask, isNonInteractive }, label, operation, messages) {
|
|
249616
|
+
return isNonInteractive ? operation() : runTask(label, operation, messages);
|
|
249617
|
+
}
|
|
249618
|
+
function loadSpecTask(ctx, refresh) {
|
|
249619
|
+
return quietTask(ctx, "Loading the API spec", () => loadSpec({ refresh }), {
|
|
249449
249620
|
successMessage: "Loaded the API spec"
|
|
249450
249621
|
});
|
|
249451
249622
|
}
|
|
@@ -249460,53 +249631,56 @@ function operationsInArea(operations, area) {
|
|
|
249460
249631
|
}
|
|
249461
249632
|
return inArea;
|
|
249462
249633
|
}
|
|
249463
|
-
|
|
249634
|
+
function isPipedStdin() {
|
|
249635
|
+
try {
|
|
249636
|
+
const stats = fstatSync(0);
|
|
249637
|
+
return stats.isFIFO() || stats.isFile();
|
|
249638
|
+
} catch {
|
|
249639
|
+
return false;
|
|
249640
|
+
}
|
|
249641
|
+
}
|
|
249642
|
+
async function readRequestBody(flag, log) {
|
|
249464
249643
|
if (flag === "@-") {
|
|
249465
249644
|
return readStdin("--body @-", { trim: false });
|
|
249466
249645
|
}
|
|
249467
249646
|
if (flag?.startsWith("@")) {
|
|
249468
249647
|
return readTextFile(flag.slice(1));
|
|
249469
249648
|
}
|
|
249470
|
-
if (flag
|
|
249471
|
-
|
|
249472
|
-
}
|
|
249473
|
-
if (method === "GET" || method === "HEAD" || process.stdin.isTTY) {
|
|
249474
|
-
return;
|
|
249649
|
+
if (flag === undefined && isPipedStdin()) {
|
|
249650
|
+
log.warn("stdin is ignored; pass --body @- to send it as the body.");
|
|
249475
249651
|
}
|
|
249476
|
-
|
|
249477
|
-
return piped.trim() ? piped : undefined;
|
|
249652
|
+
return flag;
|
|
249478
249653
|
}
|
|
249479
249654
|
|
|
249480
249655
|
// src/cli/commands/api/catalog.ts
|
|
249481
249656
|
async function catalogAction(ctx, area, options) {
|
|
249482
249657
|
const { spec } = await loadSpecTask(ctx, options.refresh);
|
|
249483
249658
|
const operations = listOperations(spec);
|
|
249659
|
+
const readOnly = (ops) => options.readOnly ? ops.filter((op) => op.readOnly) : ops;
|
|
249484
249660
|
if (area === undefined) {
|
|
249485
|
-
return { stdout: formatJson(catalogIndex(operations)) };
|
|
249661
|
+
return { stdout: formatJson(catalogIndex(readOnly(operations))) };
|
|
249486
249662
|
}
|
|
249487
|
-
const inArea = operationsInArea(operations, area);
|
|
249488
|
-
return {
|
|
249489
|
-
stdout: formatJson({
|
|
249490
|
-
area,
|
|
249491
|
-
operations: inArea.map(toOperationSummary),
|
|
249492
|
-
total: inArea.length
|
|
249493
|
-
})
|
|
249494
|
-
};
|
|
249663
|
+
const inArea = readOnly(operationsInArea(operations, area));
|
|
249664
|
+
return { stdout: formatJson(areaListing(area, inArea)) };
|
|
249495
249665
|
}
|
|
249496
249666
|
function getApiCatalogCommand() {
|
|
249497
249667
|
return new Base44Command("catalog", {
|
|
249498
249668
|
requireAuth: false,
|
|
249499
249669
|
requireAppContext: false
|
|
249500
|
-
}).description("List the API's areas, or every operation in one area").argument("[area]", 'An area from the list, e.g. "workflows"').option("--refresh", REFRESH_OPTION_HELP).action(catalogAction);
|
|
249670
|
+
}).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
249671
|
}
|
|
249502
249672
|
|
|
249503
249673
|
// src/cli/commands/api/fetch.ts
|
|
249504
|
-
async function findOperation(ctx, method, path, refresh) {
|
|
249674
|
+
async function findOperation(ctx, method, path, { refresh, flag }) {
|
|
249505
249675
|
const { spec } = await loadSpecTask(ctx, refresh);
|
|
249506
249676
|
const op = matchOperation(listOperations(spec), method, path);
|
|
249507
249677
|
if (!op) {
|
|
249508
249678
|
throw new InvalidInputError(`No operation in the API spec matches ${method} ${path}.`, {
|
|
249509
249679
|
hints: [
|
|
249680
|
+
{
|
|
249681
|
+
message: "The cached spec may predate this route; fetch it again",
|
|
249682
|
+
command: `base44 api fetch ${method} ${path} ${flag} --refresh`
|
|
249683
|
+
},
|
|
249510
249684
|
{
|
|
249511
249685
|
message: "Find the operation and its path template",
|
|
249512
249686
|
command: 'base44 api search "<what you want to do>"'
|
|
@@ -249516,34 +249690,91 @@ async function findOperation(ctx, method, path, refresh) {
|
|
|
249516
249690
|
}
|
|
249517
249691
|
return { spec, op };
|
|
249518
249692
|
}
|
|
249693
|
+
var TEXT_CONTENT_TYPES = [
|
|
249694
|
+
"json",
|
|
249695
|
+
"text/",
|
|
249696
|
+
"xml",
|
|
249697
|
+
"javascript",
|
|
249698
|
+
"x-www-form-urlencoded"
|
|
249699
|
+
];
|
|
249700
|
+
function isText(contentType) {
|
|
249701
|
+
return !contentType || TEXT_CONTENT_TYPES.some((hint) => contentType.toLowerCase().includes(hint));
|
|
249702
|
+
}
|
|
249703
|
+
async function formatResponse({ status, contentType, body }, output, jsonMode) {
|
|
249704
|
+
if (output !== undefined) {
|
|
249705
|
+
await writeFile(output, body);
|
|
249706
|
+
return formatJson({ status, contentType, bytes: body.length, output });
|
|
249707
|
+
}
|
|
249708
|
+
if (body.length === 0) {
|
|
249709
|
+
return formatJson({ status });
|
|
249710
|
+
}
|
|
249711
|
+
if (!isText(contentType)) {
|
|
249712
|
+
return formatJson({
|
|
249713
|
+
status,
|
|
249714
|
+
contentType,
|
|
249715
|
+
bytes: body.length,
|
|
249716
|
+
note: "Binary body not printed; add --output <file> to save it."
|
|
249717
|
+
});
|
|
249718
|
+
}
|
|
249719
|
+
const text = new TextDecoder().decode(body);
|
|
249720
|
+
try {
|
|
249721
|
+
return formatJson(JSON.parse(text));
|
|
249722
|
+
} catch {
|
|
249723
|
+
if (jsonMode) {
|
|
249724
|
+
return formatJson({ status, contentType, body: text });
|
|
249725
|
+
}
|
|
249726
|
+
return text.endsWith(`
|
|
249727
|
+
`) ? text : `${text}
|
|
249728
|
+
`;
|
|
249729
|
+
}
|
|
249730
|
+
}
|
|
249519
249731
|
async function fetchAction(ctx, methodArg, path, options, command) {
|
|
249520
249732
|
if (!methodArg || !path) {
|
|
249521
249733
|
if (options.help) {
|
|
249522
|
-
|
|
249734
|
+
const usage = command.helpInformation();
|
|
249735
|
+
return { stdout: ctx.jsonMode ? formatJson({ usage }) : usage };
|
|
249523
249736
|
}
|
|
249524
249737
|
throw new InvalidInputError("Provide a method and a path, e.g. GET /api/apps.");
|
|
249525
249738
|
}
|
|
249526
249739
|
const method = methodArg.toUpperCase();
|
|
249527
249740
|
if (options.help) {
|
|
249528
|
-
const { spec, op } = await findOperation(ctx, method, path,
|
|
249741
|
+
const { spec, op } = await findOperation(ctx, method, path, {
|
|
249742
|
+
refresh: options.refresh,
|
|
249743
|
+
flag: "--help"
|
|
249744
|
+
});
|
|
249529
249745
|
return { stdout: formatJson(getOperationContract(spec, op)) };
|
|
249530
249746
|
}
|
|
249531
249747
|
if (options.readOnly) {
|
|
249532
|
-
const { op } = await findOperation(ctx, method, path,
|
|
249748
|
+
const { op } = await findOperation(ctx, method, path, {
|
|
249749
|
+
refresh: options.refresh,
|
|
249750
|
+
flag: "--read-only"
|
|
249751
|
+
});
|
|
249533
249752
|
if (!op.readOnly) {
|
|
249534
249753
|
throw new InvalidInputError(`Refused under --read-only: ${op.method} ${op.path} is not a read-only operation. Nothing was sent.`);
|
|
249535
249754
|
}
|
|
249536
249755
|
}
|
|
249756
|
+
ctx.errorReporter.setContext({
|
|
249757
|
+
command: {
|
|
249758
|
+
name: "api fetch",
|
|
249759
|
+
args: [method, path.split("?", 1)[0] ?? ""],
|
|
249760
|
+
options: { ...options, body: options.body && "[not reported]" }
|
|
249761
|
+
}
|
|
249762
|
+
});
|
|
249537
249763
|
await ensureAuth(ctx);
|
|
249538
|
-
const body = await readRequestBody(
|
|
249539
|
-
const
|
|
249540
|
-
|
|
249764
|
+
const body = await readRequestBody(options.body, ctx.log);
|
|
249765
|
+
const response = await quietTask(ctx, `Calling ${method} ${path}`, () => sendApiRequest(method, path, body), {
|
|
249766
|
+
successMessage: `Called ${method} ${path}`,
|
|
249767
|
+
errorMessage: "Request failed"
|
|
249768
|
+
});
|
|
249769
|
+
return {
|
|
249770
|
+
stdout: await formatResponse(response, options.output, ctx.jsonMode)
|
|
249771
|
+
};
|
|
249541
249772
|
}
|
|
249542
249773
|
function getApiFetchCommand() {
|
|
249543
249774
|
return new Base44Command("fetch", {
|
|
249544
249775
|
requireAuth: false,
|
|
249545
249776
|
requireAppContext: false
|
|
249546
|
-
}).description("Call a Base44 API operation
|
|
249777
|
+
}).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
249778
|
}
|
|
249548
249779
|
|
|
249549
249780
|
// src/cli/commands/api/grep.ts
|
|
@@ -249558,12 +249789,14 @@ async function grepAction(ctx, pattern, options) {
|
|
|
249558
249789
|
const limit = parseLimit(options.limit);
|
|
249559
249790
|
assertValidRegex(pattern);
|
|
249560
249791
|
const { spec } = await loadSpecTask(ctx, options.refresh);
|
|
249561
|
-
|
|
249792
|
+
let operations = listOperations(spec);
|
|
249562
249793
|
if (options.area !== undefined) {
|
|
249563
|
-
operationsInArea(operations, options.area);
|
|
249794
|
+
operations = operationsInArea(operations, options.area);
|
|
249795
|
+
}
|
|
249796
|
+
if (options.readOnly) {
|
|
249797
|
+
operations = operations.filter((op) => op.readOnly);
|
|
249564
249798
|
}
|
|
249565
|
-
const hits =
|
|
249566
|
-
area: options.area,
|
|
249799
|
+
const hits = grepOperations(spec, operations, pattern, {
|
|
249567
249800
|
ignoreCase: options.ignoreCase,
|
|
249568
249801
|
limit
|
|
249569
249802
|
});
|
|
@@ -249573,7 +249806,7 @@ function getApiGrepCommand() {
|
|
|
249573
249806
|
return new Base44Command("grep", {
|
|
249574
249807
|
requireAuth: false,
|
|
249575
249808
|
requireAppContext: false
|
|
249576
|
-
}).description("Search the
|
|
249809
|
+
}).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
249810
|
}
|
|
249578
249811
|
|
|
249579
249812
|
// src/cli/commands/api/search.ts
|
|
@@ -249590,7 +249823,7 @@ function getApiSearchCommand() {
|
|
|
249590
249823
|
return new Base44Command("search", {
|
|
249591
249824
|
requireAuth: false,
|
|
249592
249825
|
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",
|
|
249826
|
+
}).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
249827
|
}
|
|
249595
249828
|
|
|
249596
249829
|
// src/cli/commands/api/index.ts
|
|
@@ -262133,7 +262366,7 @@ var nativeEnumType = ZodNativeEnum.create;
|
|
|
262133
262366
|
var promiseType = ZodPromise.create;
|
|
262134
262367
|
var effectsType = ZodEffects.create;
|
|
262135
262368
|
var optionalType = ZodOptional2.create;
|
|
262136
|
-
var
|
|
262369
|
+
var nullableType2 = ZodNullable2.create;
|
|
262137
262370
|
var preprocessType = ZodEffects.createWithPreprocess;
|
|
262138
262371
|
var pipelineType = ZodPipeline.create;
|
|
262139
262372
|
// ../functions-compiler/src/contracts.ts
|
|
@@ -273135,4 +273368,4 @@ export {
|
|
|
273135
273368
|
runCLI
|
|
273136
273369
|
};
|
|
273137
273370
|
|
|
273138
|
-
//# debugId=
|
|
273371
|
+
//# debugId=426C741A046A975D64756E2164756E21
|