@base44-preview/cli 0.1.32-pr.663.d960536 → 0.1.32-pr.663.da7454a
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 +481 -177
- package/dist/cli/index.js.map +19 -17
- package/package.json +1 -1
package/dist/cli/index.js
CHANGED
|
@@ -39570,9 +39570,9 @@ function tm(e, t, r) {
|
|
|
39570
39570
|
return l(["<", r("name"), r("typeArguments"), " ", ...e.map(r, "attributes"), n.selfClosing ? " />" : ">"]);
|
|
39571
39571
|
let i = n.attributes?.some((u) => V3(u.value) && u.value.value.includes(`
|
|
39572
39572
|
`)), o = t.singleAttributePerLine && n.attributes.length > 1 ? E : A;
|
|
39573
|
-
return l(["<", r("name"), r("typeArguments"), m(e.map(() => [o, r()], "attributes")), ...
|
|
39573
|
+
return l(["<", r("name"), r("typeArguments"), m(e.map(() => [o, r()], "attributes")), ...rm3(n, t, s)], { shouldBreak: i });
|
|
39574
39574
|
}
|
|
39575
|
-
function
|
|
39575
|
+
function rm3(e, t, r) {
|
|
39576
39576
|
return e.selfClosing ? [A, "/>"] : nm(e, t, r) ? [">"] : [f, ">"];
|
|
39577
39577
|
}
|
|
39578
39578
|
function nm(e, t, r) {
|
|
@@ -111521,7 +111521,7 @@ function N62(e) {
|
|
|
111521
111521
|
function nm2(e, t, a) {
|
|
111522
111522
|
return ie10(t, a, e.typeParameters) || ie10(t, a, e.parameters) || S7(t, e.type);
|
|
111523
111523
|
}
|
|
111524
|
-
function
|
|
111524
|
+
function rm4(e, t, a) {
|
|
111525
111525
|
return ie10(t, a, e.types);
|
|
111526
111526
|
}
|
|
111527
111527
|
function im2(e, t, a) {
|
|
@@ -114489,7 +114489,7 @@ ${Me.join(`
|
|
|
114489
114489
|
return S7(a, t.elementType);
|
|
114490
114490
|
}, 190: function(t, a, _) {
|
|
114491
114491
|
return ie10(a, _, t.elements);
|
|
114492
|
-
}, 193:
|
|
114492
|
+
}, 193: rm4, 194: rm4, 195: function(t, a, _) {
|
|
114493
114493
|
return S7(a, t.checkType) || S7(a, t.extendsType) || S7(a, t.trueType) || S7(a, t.falseType);
|
|
114494
114494
|
}, 196: function(t, a, _) {
|
|
114495
114495
|
return S7(a, t.typeParameter);
|
|
@@ -119123,7 +119123,7 @@ import url22 from "url";
|
|
|
119123
119123
|
function diffLines(oldStr, newStr, options8) {
|
|
119124
119124
|
return lineDiff.diff(oldStr, newStr, options8);
|
|
119125
119125
|
}
|
|
119126
|
-
function
|
|
119126
|
+
function tokenize2(value, options8) {
|
|
119127
119127
|
if (options8.stripTrailingCr) {
|
|
119128
119128
|
value = value.replace(/\r\n/g, `
|
|
119129
119129
|
`);
|
|
@@ -120053,7 +120053,7 @@ function highlight(text) {
|
|
|
120053
120053
|
for (const {
|
|
120054
120054
|
type,
|
|
120055
120055
|
value
|
|
120056
|
-
} of
|
|
120056
|
+
} of tokenize22(text)) {
|
|
120057
120057
|
if (type in defs) {
|
|
120058
120058
|
highlighted += value.split(NEWLINE$1).map((str) => defs[type](str)).join(`
|
|
120059
120059
|
`);
|
|
@@ -124581,7 +124581,7 @@ var require2, __filename2, __dirname3, __create2, __defProp3, __getOwnPropDesc2,
|
|
|
124581
124581
|
return internalize({ "": root }, "", reviver);
|
|
124582
124582
|
}
|
|
124583
124583
|
return root;
|
|
124584
|
-
}, lexState, buffer, doubleQuote, sign, c7, lexStates, parseStates, dist_default, import_picocolors4, import_js_tokens, nonASCIIidentifierStartChars = "ªµºÀ-ÖØ-öø-ˁˆ-ˑˠ-ˤˬˮͰ-ʹͶͷͺ-ͽͿΆΈ-ΊΌΎ-ΡΣ-ϵϷ-ҁҊ-ԯԱ-Ֆՙՠ-ֈא-תׯ-ײؠ-يٮٯٱ-ۓەۥۦۮۯۺ-ۼۿܐܒ-ܯݍ-ޥޱߊ-ߪߴߵߺࠀ-ࠕࠚࠤࠨࡀ-ࡘࡠ-ࡪࡰ-ࢇࢉ-ࢠ-ࣉऄ-हऽॐक़-ॡॱ-ঀঅ-ঌএঐও-নপ-রলশ-হঽৎড়ঢ়য়-ৡৰৱৼਅ-ਊਏਐਓ-ਨਪ-ਰਲਲ਼ਵਸ਼ਸਹਖ਼-ੜਫ਼ੲ-ੴઅ-ઍએ-ઑઓ-નપ-રલળવ-હઽૐૠૡૹଅ-ଌଏଐଓ-ନପ-ରଲଳଵ-ହଽଡ଼ଢ଼ୟ-ୡୱஃஅ-ஊஎ-ஐஒ-கஙசஜஞடணதந-பம-ஹௐఅ-ఌఎ-ఐఒ-నప-హఽౘ-ౚౝౠౡಀಅ-ಌಎ-ಐಒ-ನಪ-ಳವ-ಹಽ-ೞೠೡೱೲഄ-ഌഎ-ഐഒ-ഺഽൎൔ-ൖൟ-ൡൺ-ൿඅ-ඖක-නඳ-රලව-ෆก-ะาำเ-ๆກຂຄຆ-ຊຌ-ຣລວ-ະາຳຽເ-ໄໆໜ-ໟༀཀ-ཇཉ-ཬྈ-ྌက-ဪဿၐ-ၕၚ-ၝၡၥၦၮ-ၰၵ-ႁႎႠ-ჅჇჍა-ჺჼ-ቈቊ-ቍቐ-ቖቘቚ-ቝበ-ኈኊ-ኍነ-ኰኲ-ኵኸ-ኾዀዂ-ዅወ-ዖዘ-ጐጒ-ጕጘ-ፚᎀ-ᎏᎠ-Ᏽᏸ-ᏽᐁ-ᙬᙯ-ᙿᚁ-ᚚᚠ-ᛪᛮ-ᛸᜀ-ᜑᜟ-ᜱᝀ-ᝑᝠ-ᝬᝮ-ᝰក-ឳៗៜᠠ-ᡸᢀ-ᢨᢪᢰ-ᣵᤀ-ᤞᥐ-ᥭᥰ-ᥴᦀ-ᦫᦰ-ᧉᨀ-ᨖᨠ-ᩔᪧᬅ-ᬳᭅ-ᭌᮃ-ᮠᮮᮯᮺ-ᯥᰀ-ᰣᱍ-ᱏᱚ-ᱽᲀ-Ა-ᲺᲽ-Ჿᳩ-ᳬᳮ-ᳳᳵᳶᳺᴀ-ᶿḀ-ἕἘ-Ἕἠ-ὅὈ-Ὅὐ-ὗὙὛὝὟ-ώᾀ-ᾴᾶ-ᾼιῂ-ῄῆ-ῌῐ-ΐῖ-Ίῠ-Ῥῲ-ῴῶ-ῼⁱⁿₐ-ₜℂℇℊ-ℓℕ℘-ℝℤΩℨK-ℹℼ-ℿⅅ-ⅉⅎⅠ-ↈⰀ-ⳤⳫ-ⳮⳲⳳⴀ-ⴥⴧⴭⴰ-ⵧⵯⶀ-ⶖⶠ-ⶦⶨ-ⶮⶰ-ⶶⶸ-ⶾⷀ-ⷆⷈ-ⷎⷐ-ⷖⷘ-ⷞ々-〇〡-〩〱-〵〸-〼ぁ-ゖ゛-ゟァ-ヺー-ヿㄅ-ㄯㄱ-ㆎㆠ-ㆿㇰ-ㇿ㐀-䶿一-ꒌꓐ-ꓽꔀ-ꘌꘐ-ꘟꘪꘫꙀ-ꙮꙿ-ꚝꚠ-ꛯꜗ-ꜟꜢ-ꞈꞋ--ꠁꠃ-ꠅꠇ-ꠊꠌ-ꠢꡀ-ꡳꢂ-ꢳꣲ-ꣷꣻꣽꣾꤊ-ꤥꤰ-ꥆꥠ-ꥼꦄ-ꦲꧏꧠ-ꧤꧦ-ꧯꧺ-ꧾꨀ-ꨨꩀ-ꩂꩄ-ꩋꩠ-ꩶꩺꩾ-ꪯꪱꪵꪶꪹ-ꪽꫀꫂꫛ-ꫝꫠ-ꫪꫲ-ꫴꬁ-ꬆꬉ-ꬎꬑ-ꬖꬠ-ꬦꬨ-ꬮꬰ-ꭚꭜ-ꭩꭰ-ꯢ가-힣ힰ-ퟆퟋ-ퟻ豈-舘並-龎ff-stﬓ-ﬗיִײַ-ﬨשׁ-זּטּ-לּמּנּסּףּפּצּ-ﮱﯓ-ﴽﵐ-ﶏﶒ-ﷇﷰ-ﷻﹰ-ﹴﹶ-ﻼA-Za-zヲ-하-ᅦᅧ-ᅬᅭ-ᅲᅳ-ᅵ", nonASCIIidentifierChars = "·̀-ͯ·҃-֑҇-ׇֽֿׁׂׅׄؐ-ًؚ-٩ٰۖ-ۜ۟-۪ۤۧۨ-ۭ۰-۹ܑܰ-݊ަ-ް߀-߉߫-߽߳ࠖ-࠙ࠛ-ࠣࠥ-ࠧࠩ-࡙࠭-࡛-࢟࣊-ࣣ࣡-ःऺ-़ा-ॏ॑-ॗॢॣ०-९ঁ-ঃ়া-ৄেৈো-্ৗৢৣ০-৯৾ਁ-ਃ਼ਾ-ੂੇੈੋ-੍ੑ੦-ੱੵઁ-ઃ઼ા-ૅે-ૉો-્ૢૣ૦-૯ૺ-૿ଁ-ଃ଼ା-ୄେୈୋ-୍୕-ୗୢୣ୦-୯ஂா-ூெ-ைொ-்ௗ௦-௯ఀ-ఄ఼ా-ౄె-ైొ-్ౕౖౢౣ౦-౯ಁ-ಃ಼ಾ-ೄೆ-ೈೊ-್ೕೖೢೣ೦-೯ೳഀ-ഃ഻഼ാ-ൄെ-ൈൊ-്ൗൢൣ൦-൯ඁ-ඃ්ා-ුූෘ-ෟ෦-෯ෲෳัิ-ฺ็-๎๐-๙ັິ-ຼ່-໎໐-໙༘༙༠-༩༹༵༷༾༿ཱ-྄྆྇ྍ-ྗྙ-ྼ࿆ါ-ှ၀-၉ၖ-ၙၞ-ၠၢ-ၤၧ-ၭၱ-ၴႂ-ႍႏ-ႝ፝-፟፩-፱ᜒ-᜕ᜲ-᜴ᝒᝓᝲᝳ឴-៓៝០-៩᠋-᠍᠏-᠙ᢩᤠ-ᤫᤰ-᤻᥆-᥏᧐-᧚ᨗ-ᨛᩕ-ᩞ᩠-᩿᩼-᪉᪐-᪙᪰-᪽ᪿ--ᬀ-ᬄ᬴-᭄᭐-᭙᭫-᭳ᮀ-ᮂᮡ-ᮭ᮰-᮹᯦-᯳ᰤ-᰷᱀-᱉᱐-᱙᳐-᳔᳒-᳨᳭᳴᳷-᳹᷀-᷿‿⁀⁔⃐-⃥⃜⃡-⃰⳯-⵿⳱ⷠ-〪ⷿ-゙゚〯・꘠-꘩꙯ꙴ-꙽ꚞꚟ꛰꛱ꠂ꠆ꠋꠣ-ꠧ꠬ꢀꢁꢴ-ꣅ꣐-꣙꣠-꣱ꣿ-꤉ꤦ-꤭ꥇ-꥓ꦀ-ꦃ꦳-꧀꧐-꧙ꧥ꧰-꧹ꨩ-ꨶꩃꩌꩍ꩐-꩙ꩻ-ꩽꪰꪲ-ꪴꪷꪸꪾ꪿꫁ꫫ-ꫯꫵ꫶ꯣ-ꯪ꯬꯭꯰-꯹ﬞ︀-️︠-︯︳︴﹍-﹏0-9_・", nonASCIIidentifierStart, nonASCIIidentifier, reservedWords, keywords, reservedWordsStrictSet, reservedWordsStrictBindSet, compose = (f, g) => (v) => f(g(v)), defsOn, defsOff, sometimesKeywords, NEWLINE$1, BRACKET,
|
|
124584
|
+
}, lexState, buffer, doubleQuote, sign, c7, lexStates, parseStates, dist_default, import_picocolors4, import_js_tokens, nonASCIIidentifierStartChars = "ªµºÀ-ÖØ-öø-ˁˆ-ˑˠ-ˤˬˮͰ-ʹͶͷͺ-ͽͿΆΈ-ΊΌΎ-ΡΣ-ϵϷ-ҁҊ-ԯԱ-Ֆՙՠ-ֈא-תׯ-ײؠ-يٮٯٱ-ۓەۥۦۮۯۺ-ۼۿܐܒ-ܯݍ-ޥޱߊ-ߪߴߵߺࠀ-ࠕࠚࠤࠨࡀ-ࡘࡠ-ࡪࡰ-ࢇࢉ-ࢠ-ࣉऄ-हऽॐक़-ॡॱ-ঀঅ-ঌএঐও-নপ-রলশ-হঽৎড়ঢ়য়-ৡৰৱৼਅ-ਊਏਐਓ-ਨਪ-ਰਲਲ਼ਵਸ਼ਸਹਖ਼-ੜਫ਼ੲ-ੴઅ-ઍએ-ઑઓ-નપ-રલળવ-હઽૐૠૡૹଅ-ଌଏଐଓ-ନପ-ରଲଳଵ-ହଽଡ଼ଢ଼ୟ-ୡୱஃஅ-ஊஎ-ஐஒ-கஙசஜஞடணதந-பம-ஹௐఅ-ఌఎ-ఐఒ-నప-హఽౘ-ౚౝౠౡಀಅ-ಌಎ-ಐಒ-ನಪ-ಳವ-ಹಽ-ೞೠೡೱೲഄ-ഌഎ-ഐഒ-ഺഽൎൔ-ൖൟ-ൡൺ-ൿඅ-ඖක-නඳ-රලව-ෆก-ะาำเ-ๆກຂຄຆ-ຊຌ-ຣລວ-ະາຳຽເ-ໄໆໜ-ໟༀཀ-ཇཉ-ཬྈ-ྌက-ဪဿၐ-ၕၚ-ၝၡၥၦၮ-ၰၵ-ႁႎႠ-ჅჇჍა-ჺჼ-ቈቊ-ቍቐ-ቖቘቚ-ቝበ-ኈኊ-ኍነ-ኰኲ-ኵኸ-ኾዀዂ-ዅወ-ዖዘ-ጐጒ-ጕጘ-ፚᎀ-ᎏᎠ-Ᏽᏸ-ᏽᐁ-ᙬᙯ-ᙿᚁ-ᚚᚠ-ᛪᛮ-ᛸᜀ-ᜑᜟ-ᜱᝀ-ᝑᝠ-ᝬᝮ-ᝰក-ឳៗៜᠠ-ᡸᢀ-ᢨᢪᢰ-ᣵᤀ-ᤞᥐ-ᥭᥰ-ᥴᦀ-ᦫᦰ-ᧉᨀ-ᨖᨠ-ᩔᪧᬅ-ᬳᭅ-ᭌᮃ-ᮠᮮᮯᮺ-ᯥᰀ-ᰣᱍ-ᱏᱚ-ᱽᲀ-Ა-ᲺᲽ-Ჿᳩ-ᳬᳮ-ᳳᳵᳶᳺᴀ-ᶿḀ-ἕἘ-Ἕἠ-ὅὈ-Ὅὐ-ὗὙὛὝὟ-ώᾀ-ᾴᾶ-ᾼιῂ-ῄῆ-ῌῐ-ΐῖ-Ίῠ-Ῥῲ-ῴῶ-ῼⁱⁿₐ-ₜℂℇℊ-ℓℕ℘-ℝℤΩℨK-ℹℼ-ℿⅅ-ⅉⅎⅠ-ↈⰀ-ⳤⳫ-ⳮⳲⳳⴀ-ⴥⴧⴭⴰ-ⵧⵯⶀ-ⶖⶠ-ⶦⶨ-ⶮⶰ-ⶶⶸ-ⶾⷀ-ⷆⷈ-ⷎⷐ-ⷖⷘ-ⷞ々-〇〡-〩〱-〵〸-〼ぁ-ゖ゛-ゟァ-ヺー-ヿㄅ-ㄯㄱ-ㆎㆠ-ㆿㇰ-ㇿ㐀-䶿一-ꒌꓐ-ꓽꔀ-ꘌꘐ-ꘟꘪꘫꙀ-ꙮꙿ-ꚝꚠ-ꛯꜗ-ꜟꜢ-ꞈꞋ--ꠁꠃ-ꠅꠇ-ꠊꠌ-ꠢꡀ-ꡳꢂ-ꢳꣲ-ꣷꣻꣽꣾꤊ-ꤥꤰ-ꥆꥠ-ꥼꦄ-ꦲꧏꧠ-ꧤꧦ-ꧯꧺ-ꧾꨀ-ꨨꩀ-ꩂꩄ-ꩋꩠ-ꩶꩺꩾ-ꪯꪱꪵꪶꪹ-ꪽꫀꫂꫛ-ꫝꫠ-ꫪꫲ-ꫴꬁ-ꬆꬉ-ꬎꬑ-ꬖꬠ-ꬦꬨ-ꬮꬰ-ꭚꭜ-ꭩꭰ-ꯢ가-힣ힰ-ퟆퟋ-ퟻ豈-舘並-龎ff-stﬓ-ﬗיִײַ-ﬨשׁ-זּטּ-לּמּנּסּףּפּצּ-ﮱﯓ-ﴽﵐ-ﶏﶒ-ﷇﷰ-ﷻﹰ-ﹴﹶ-ﻼA-Za-zヲ-하-ᅦᅧ-ᅬᅭ-ᅲᅳ-ᅵ", nonASCIIidentifierChars = "·̀-ͯ·҃-֑҇-ׇֽֿׁׂׅׄؐ-ًؚ-٩ٰۖ-ۜ۟-۪ۤۧۨ-ۭ۰-۹ܑܰ-݊ަ-ް߀-߉߫-߽߳ࠖ-࠙ࠛ-ࠣࠥ-ࠧࠩ-࡙࠭-࡛-࢟࣊-ࣣ࣡-ःऺ-़ा-ॏ॑-ॗॢॣ०-९ঁ-ঃ়া-ৄেৈো-্ৗৢৣ০-৯৾ਁ-ਃ਼ਾ-ੂੇੈੋ-੍ੑ੦-ੱੵઁ-ઃ઼ા-ૅે-ૉો-્ૢૣ૦-૯ૺ-૿ଁ-ଃ଼ା-ୄେୈୋ-୍୕-ୗୢୣ୦-୯ஂா-ூெ-ைொ-்ௗ௦-௯ఀ-ఄ఼ా-ౄె-ైొ-్ౕౖౢౣ౦-౯ಁ-ಃ಼ಾ-ೄೆ-ೈೊ-್ೕೖೢೣ೦-೯ೳഀ-ഃ഻഼ാ-ൄെ-ൈൊ-്ൗൢൣ൦-൯ඁ-ඃ්ා-ුූෘ-ෟ෦-෯ෲෳัิ-ฺ็-๎๐-๙ັິ-ຼ່-໎໐-໙༘༙༠-༩༹༵༷༾༿ཱ-྄྆྇ྍ-ྗྙ-ྼ࿆ါ-ှ၀-၉ၖ-ၙၞ-ၠၢ-ၤၧ-ၭၱ-ၴႂ-ႍႏ-ႝ፝-፟፩-፱ᜒ-᜕ᜲ-᜴ᝒᝓᝲᝳ឴-៓៝០-៩᠋-᠍᠏-᠙ᢩᤠ-ᤫᤰ-᤻᥆-᥏᧐-᧚ᨗ-ᨛᩕ-ᩞ᩠-᩿᩼-᪉᪐-᪙᪰-᪽ᪿ--ᬀ-ᬄ᬴-᭄᭐-᭙᭫-᭳ᮀ-ᮂᮡ-ᮭ᮰-᮹᯦-᯳ᰤ-᰷᱀-᱉᱐-᱙᳐-᳔᳒-᳨᳭᳴᳷-᳹᷀-᷿‿⁀⁔⃐-⃥⃜⃡-⃰⳯-⵿⳱ⷠ-〪ⷿ-゙゚〯・꘠-꘩꙯ꙴ-꙽ꚞꚟ꛰꛱ꠂ꠆ꠋꠣ-ꠧ꠬ꢀꢁꢴ-ꣅ꣐-꣙꣠-꣱ꣿ-꤉ꤦ-꤭ꥇ-꥓ꦀ-ꦃ꦳-꧀꧐-꧙ꧥ꧰-꧹ꨩ-ꨶꩃꩌꩍ꩐-꩙ꩻ-ꩽꪰꪲ-ꪴꪷꪸꪾ꪿꫁ꫫ-ꫯꫵ꫶ꯣ-ꯪ꯬꯭꯰-꯹ﬞ︀-️︠-︯︳︴﹍-﹏0-9_・", nonASCIIidentifierStart, nonASCIIidentifier, reservedWords, keywords, reservedWordsStrictSet, reservedWordsStrictBindSet, compose = (f, g) => (v) => f(g(v)), defsOn, defsOff, sometimesKeywords, NEWLINE$1, BRACKET, tokenize22, NEWLINE, getOffsets = ({
|
|
124585
124585
|
oneBased,
|
|
124586
124586
|
oneBasedLine = oneBased,
|
|
124587
124587
|
oneBasedColumn = oneBased
|
|
@@ -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
|
})) {
|
|
@@ -239451,7 +239451,7 @@ var package_default = {
|
|
|
239451
239451
|
jsonwebtoken: "^9.0.3",
|
|
239452
239452
|
ky: "^1.14.2",
|
|
239453
239453
|
lodash: "^4.17.23",
|
|
239454
|
-
minisearch: "7.1.2",
|
|
239454
|
+
minisearch: "^7.1.2",
|
|
239455
239455
|
ms: "^2.1.3",
|
|
239456
239456
|
multer: "^2.0.0",
|
|
239457
239457
|
nanoid: "^5.1.6",
|
|
@@ -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 MediaContentSchema = looseObject({
|
|
249238
|
+
content: MediaTypesSchema.optional()
|
|
249239
|
+
});
|
|
249240
|
+
var ResponseObjectSchema = looseObject({
|
|
249241
|
+
description: string2().optional(),
|
|
249242
|
+
content: MediaTypesSchema.optional()
|
|
249229
249243
|
});
|
|
249230
249244
|
var SecurityRequirementSchema = record(string2(), array(string2()));
|
|
249231
249245
|
var OperationSchema = looseObject({
|
|
@@ -249237,15 +249251,22 @@ var OperationSchema = looseObject({
|
|
|
249237
249251
|
responses: record(string2(), unknown()).optional(),
|
|
249238
249252
|
security: array(SecurityRequirementSchema).optional()
|
|
249239
249253
|
});
|
|
249240
|
-
var PathItemSchema = looseObject(Object.fromEntries(HTTP_METHODS.map((method) => [method, OperationSchema.optional()])));
|
|
249241
249254
|
var OpenApiSpecSchema = looseObject({
|
|
249242
249255
|
openapi: string2(),
|
|
249243
|
-
paths: record(string2(),
|
|
249256
|
+
paths: record(string2(), record(string2(), unknown())),
|
|
249244
249257
|
components: looseObject({
|
|
249245
249258
|
schemas: record(string2(), unknown()).optional()
|
|
249246
249259
|
}).optional(),
|
|
249247
|
-
security: array(SecurityRequirementSchema).optional()
|
|
249260
|
+
security: array(SecurityRequirementSchema).optional().catch(undefined)
|
|
249248
249261
|
});
|
|
249262
|
+
var ParameterListSchema = array(unknown());
|
|
249263
|
+
|
|
249264
|
+
// src/core/api-spec/text.ts
|
|
249265
|
+
var DOCS_CALLOUT = /<(Info|Note|Tip|Check|Warning)>([\s\S]*?)<\/\1>/g;
|
|
249266
|
+
var RELATIVE_LINK = /\[([^\]]+)\]\(\/[^)]*\)/g;
|
|
249267
|
+
function cleanText(text) {
|
|
249268
|
+
return text.replace(DOCS_CALLOUT, (_, kind, body) => kind === "Warning" ? `Warning: ${body}` : body).replace(RELATIVE_LINK, "$1");
|
|
249269
|
+
}
|
|
249249
249270
|
|
|
249250
249271
|
// src/core/api-spec/operations.ts
|
|
249251
249272
|
var PERSONAL_ACCESS_TOKEN_SCHEME = "PersonalAccessTokenAuth";
|
|
@@ -249257,21 +249278,52 @@ function isReadOnly(operation, spec) {
|
|
|
249257
249278
|
function parameterText(operation) {
|
|
249258
249279
|
return (operation.parameters ?? []).flatMap((parameter) => {
|
|
249259
249280
|
const parsed = ParameterSchema.safeParse(parameter);
|
|
249260
|
-
return parsed.success ? [parsed.data.name, parsed.data.description ?? ""] : [];
|
|
249281
|
+
return parsed.success ? [parsed.data.name, cleanText(parsed.data.description ?? "")] : [];
|
|
249261
249282
|
}).join(" ");
|
|
249262
249283
|
}
|
|
249284
|
+
var COMPONENT_REF = /^#\/components\/([^/]+)\/([^/]+)$/;
|
|
249285
|
+
function resolveComponentRef(spec, value) {
|
|
249286
|
+
const ref = value !== null && typeof value === "object" ? value.$ref : undefined;
|
|
249287
|
+
const match = typeof ref === "string" ? COMPONENT_REF.exec(ref) : null;
|
|
249288
|
+
if (!match?.[1] || !match[2]) {
|
|
249289
|
+
return value;
|
|
249290
|
+
}
|
|
249291
|
+
const components = spec.components;
|
|
249292
|
+
return components?.[match[1]]?.[match[2]] ?? value;
|
|
249293
|
+
}
|
|
249294
|
+
function mergeParameters(shared, own) {
|
|
249295
|
+
if (!shared?.length) {
|
|
249296
|
+
return own;
|
|
249297
|
+
}
|
|
249298
|
+
const key = (parameter) => {
|
|
249299
|
+
const parsed = ParameterSchema.safeParse(parameter);
|
|
249300
|
+
return parsed.success ? `${parsed.data.in}:${parsed.data.name}` : undefined;
|
|
249301
|
+
};
|
|
249302
|
+
const ownKeys = new Set((own ?? []).map(key));
|
|
249303
|
+
return [
|
|
249304
|
+
...shared.filter((parameter) => !ownKeys.has(key(parameter))),
|
|
249305
|
+
...own ?? []
|
|
249306
|
+
];
|
|
249307
|
+
}
|
|
249263
249308
|
function listOperations(spec) {
|
|
249264
249309
|
return Object.entries(spec.paths).flatMap(([path, item]) => HTTP_METHODS.flatMap((method) => {
|
|
249265
|
-
const
|
|
249266
|
-
if (!
|
|
249310
|
+
const parsed = OperationSchema.safeParse(item[method]);
|
|
249311
|
+
if (!parsed.success) {
|
|
249267
249312
|
return [];
|
|
249268
249313
|
}
|
|
249314
|
+
const shared = ParameterListSchema.safeParse(item.parameters);
|
|
249315
|
+
const resolve = (list) => list?.map((parameter) => resolveComponentRef(spec, parameter));
|
|
249316
|
+
const operation = {
|
|
249317
|
+
...parsed.data,
|
|
249318
|
+
parameters: mergeParameters(resolve(shared.success ? shared.data : undefined), resolve(parsed.data.parameters))
|
|
249319
|
+
};
|
|
249269
249320
|
return [
|
|
249270
249321
|
{
|
|
249322
|
+
endpoint: `${method.toUpperCase()} ${path}`,
|
|
249271
249323
|
method: method.toUpperCase(),
|
|
249272
249324
|
path,
|
|
249273
249325
|
summary: operation.summary ?? "",
|
|
249274
|
-
description: operation.description ?? "",
|
|
249326
|
+
description: cleanText(operation.description ?? ""),
|
|
249275
249327
|
parameterText: parameterText(operation),
|
|
249276
249328
|
readOnly: isReadOnly(operation, spec),
|
|
249277
249329
|
operation
|
|
@@ -249281,22 +249333,14 @@ function listOperations(spec) {
|
|
|
249281
249333
|
}
|
|
249282
249334
|
function pathSegments(path) {
|
|
249283
249335
|
const pathname = path.split(/[?#]/, 1)[0] ?? "";
|
|
249284
|
-
return pathname.
|
|
249336
|
+
return pathname.replace(/^\/+|\/+$/g, "").split("/");
|
|
249285
249337
|
}
|
|
249286
249338
|
function segmentPattern(segment) {
|
|
249287
249339
|
const source = segment.split(/(\{[^}]+\})/).map((part) => part.startsWith("{") ? "[^/]+" : part.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")).join("");
|
|
249288
249340
|
return new RegExp(`^${source}$`);
|
|
249289
249341
|
}
|
|
249290
|
-
function
|
|
249291
|
-
return
|
|
249292
|
-
}
|
|
249293
|
-
function compareSpecificity(a, b) {
|
|
249294
|
-
for (let i = 0;i < a.length; i++) {
|
|
249295
|
-
if (a[i] !== b[i]) {
|
|
249296
|
-
return (b[i] ?? 0) - (a[i] ?? 0);
|
|
249297
|
-
}
|
|
249298
|
-
}
|
|
249299
|
-
return 0;
|
|
249342
|
+
function literalSegments(path) {
|
|
249343
|
+
return pathSegments(path).map((segment) => segment.includes("{") ? "0" : "1").join("");
|
|
249300
249344
|
}
|
|
249301
249345
|
function matchOperation(operations, method, concretePath) {
|
|
249302
249346
|
const upperMethod = method.toUpperCase();
|
|
@@ -249308,65 +249352,203 @@ function matchOperation(operations, method, concretePath) {
|
|
|
249308
249352
|
const template = pathSegments(op.path);
|
|
249309
249353
|
return template.length === segments.length && template.every((part, i) => segmentPattern(part).test(segments[i] ?? ""));
|
|
249310
249354
|
});
|
|
249311
|
-
return candidates.sort((a, b) =>
|
|
249355
|
+
return candidates.sort((a, b) => literalSegments(b.path).localeCompare(literalSegments(a.path)))[0];
|
|
249312
249356
|
}
|
|
249313
|
-
|
|
249314
|
-
|
|
249315
|
-
|
|
249316
|
-
|
|
249357
|
+
|
|
249358
|
+
// src/core/api-spec/contract.ts
|
|
249359
|
+
var SCHEMA_REF_PREFIX = "#/components/schemas/";
|
|
249360
|
+
var MAX_REF_DEPTH = 4;
|
|
249361
|
+
function inlineRefs(node, schemas, seen = new Set, depth = 0) {
|
|
249362
|
+
if (depth > MAX_REF_DEPTH) {
|
|
249363
|
+
return node;
|
|
249364
|
+
}
|
|
249365
|
+
if (Array.isArray(node)) {
|
|
249366
|
+
return node.map((item) => inlineRefs(item, schemas, seen, depth));
|
|
249367
|
+
}
|
|
249368
|
+
if (node === null || typeof node !== "object") {
|
|
249369
|
+
return node;
|
|
249370
|
+
}
|
|
249371
|
+
const { $ref, ...siblings } = node;
|
|
249372
|
+
if (typeof $ref === "string" && $ref.startsWith(SCHEMA_REF_PREFIX)) {
|
|
249373
|
+
const name = $ref.slice(SCHEMA_REF_PREFIX.length);
|
|
249374
|
+
if (seen.has(name) || !(name in schemas)) {
|
|
249375
|
+
return node;
|
|
249317
249376
|
}
|
|
249318
|
-
|
|
249377
|
+
const resolved = inlineRefs(schemas[name], schemas, new Set([...seen, name]), depth + 1);
|
|
249378
|
+
return resolved !== null && typeof resolved === "object" ? { ...resolved, ...siblings } : resolved;
|
|
249319
249379
|
}
|
|
249320
|
-
|
|
249321
|
-
|
|
249380
|
+
return Object.fromEntries(Object.entries(node).map(([key, value]) => [
|
|
249381
|
+
key,
|
|
249382
|
+
inlineRefs(value, schemas, seen, depth)
|
|
249383
|
+
]));
|
|
249384
|
+
}
|
|
249385
|
+
function bodyOf(value) {
|
|
249386
|
+
const parsed = MediaContentSchema.safeParse(value);
|
|
249387
|
+
const content = parsed.success ? parsed.data.content ?? {} : {};
|
|
249388
|
+
const contentType = "application/json" in content ? "application/json" : Object.keys(content)[0];
|
|
249389
|
+
return contentType ? { contentType, schema: content[contentType]?.schema } : {};
|
|
249390
|
+
}
|
|
249391
|
+
function leftoverRefs(node, schemas, found = new Map) {
|
|
249392
|
+
if (Array.isArray(node)) {
|
|
249393
|
+
for (const item of node) {
|
|
249394
|
+
leftoverRefs(item, schemas, found);
|
|
249395
|
+
}
|
|
249396
|
+
} else if (node !== null && typeof node === "object") {
|
|
249397
|
+
for (const [key, value] of Object.entries(node)) {
|
|
249398
|
+
if (key === "$ref" && typeof value === "string" && value.startsWith(SCHEMA_REF_PREFIX) && !found.has(value)) {
|
|
249399
|
+
const schema = schemas[value.slice(SCHEMA_REF_PREFIX.length)];
|
|
249400
|
+
if (schema !== undefined) {
|
|
249401
|
+
found.set(value, schema);
|
|
249402
|
+
leftoverRefs(schema, schemas, found);
|
|
249403
|
+
}
|
|
249404
|
+
} else {
|
|
249405
|
+
leftoverRefs(value, schemas, found);
|
|
249406
|
+
}
|
|
249407
|
+
}
|
|
249322
249408
|
}
|
|
249323
|
-
|
|
249324
|
-
|
|
249325
|
-
|
|
249326
|
-
|
|
249327
|
-
|
|
249328
|
-
|
|
249329
|
-
|
|
249409
|
+
return found;
|
|
249410
|
+
}
|
|
249411
|
+
var SCHEMA_DATA_KEYS = new Set([
|
|
249412
|
+
"example",
|
|
249413
|
+
"examples",
|
|
249414
|
+
"default",
|
|
249415
|
+
"enum",
|
|
249416
|
+
"const"
|
|
249417
|
+
]);
|
|
249418
|
+
function slimSchema(node, isPropertyMap = false) {
|
|
249419
|
+
if (Array.isArray(node)) {
|
|
249420
|
+
return node.map((item) => slimSchema(item));
|
|
249421
|
+
}
|
|
249422
|
+
if (node === null || typeof node !== "object") {
|
|
249423
|
+
return node;
|
|
249424
|
+
}
|
|
249425
|
+
const entries = Object.entries(node);
|
|
249426
|
+
if (isPropertyMap) {
|
|
249427
|
+
return Object.fromEntries(entries.map(([name, value]) => [name, slimSchema(value)]));
|
|
249428
|
+
}
|
|
249429
|
+
const slim = {};
|
|
249430
|
+
for (const [key, value] of entries) {
|
|
249431
|
+
if (key === "title" && typeof value === "string") {
|
|
249432
|
+
continue;
|
|
249330
249433
|
}
|
|
249434
|
+
slim[key] = SCHEMA_DATA_KEYS.has(key) ? value : key === "properties" ? slimSchema(value, true) : key === "description" && typeof value === "string" ? cleanText(value) : slimSchema(value);
|
|
249331
249435
|
}
|
|
249436
|
+
const { anyOf, ...rest } = slim;
|
|
249437
|
+
const nullable = Array.isArray(anyOf) && anyOf.length === 2 ? nullableType(anyOf) : undefined;
|
|
249438
|
+
return nullable ? { type: [nullable, "null"], ...rest } : slim;
|
|
249332
249439
|
}
|
|
249333
|
-
function
|
|
249334
|
-
|
|
249440
|
+
function nullableType(variants) {
|
|
249441
|
+
const types = variants.map((variant) => variant !== null && typeof variant === "object" && Object.keys(variant).length === 1 && typeof variant.type === "string" ? variant.type : undefined);
|
|
249442
|
+
if (types.includes(undefined) || !types.includes("null")) {
|
|
249335
249443
|
return;
|
|
249336
249444
|
}
|
|
249337
|
-
return
|
|
249445
|
+
return types.find((type) => type !== "null");
|
|
249338
249446
|
}
|
|
249339
249447
|
function getOperationContract(spec, op) {
|
|
249340
|
-
const
|
|
249341
|
-
const
|
|
249342
|
-
|
|
249343
|
-
|
|
249448
|
+
const schemas = spec.components?.schemas ?? {};
|
|
249449
|
+
const inline = (node) => node === undefined ? null : slimSchema(inlineRefs(node, schemas));
|
|
249450
|
+
const responses = Object.entries(op.operation.responses ?? {}).flatMap(([status, response]) => {
|
|
249451
|
+
const parsed = ResponseObjectSchema.safeParse(resolveComponentRef(spec, response));
|
|
249452
|
+
return parsed.success ? [[status, parsed.data]] : [];
|
|
249453
|
+
});
|
|
249454
|
+
const success = responses.filter(([status]) => status.startsWith("2")).sort(([a], [b]) => a.localeCompare(b)).map(([, response]) => bodyOf(response).schema).find(Boolean);
|
|
249455
|
+
const requestBody = bodyOf(resolveComponentRef(spec, op.operation.requestBody));
|
|
249456
|
+
const contract = {
|
|
249457
|
+
endpoint: op.endpoint,
|
|
249344
249458
|
method: op.method,
|
|
249345
249459
|
path: op.path,
|
|
249346
249460
|
summary: op.summary,
|
|
249347
249461
|
description: op.description,
|
|
249348
|
-
|
|
249349
|
-
|
|
249350
|
-
|
|
249351
|
-
|
|
249352
|
-
|
|
249462
|
+
parameters: (op.operation.parameters ?? []).flatMap((parameter) => {
|
|
249463
|
+
const parsed = ParameterSchema.safeParse(parameter);
|
|
249464
|
+
if (!parsed.success) {
|
|
249465
|
+
return [parameter];
|
|
249466
|
+
}
|
|
249467
|
+
const { name, in: location2, required, schema, description } = parsed.data;
|
|
249468
|
+
const inSchema = schema !== null && typeof schema === "object" && "description" in schema;
|
|
249469
|
+
return [
|
|
249470
|
+
{
|
|
249471
|
+
name,
|
|
249472
|
+
in: location2,
|
|
249473
|
+
required: required ?? false,
|
|
249474
|
+
schema: inline(schema ?? {}),
|
|
249475
|
+
...description && !inSchema ? { description: cleanText(description) } : {},
|
|
249476
|
+
..."example" in parsed.data ? { example: parsed.data.example } : {}
|
|
249477
|
+
}
|
|
249478
|
+
];
|
|
249479
|
+
}),
|
|
249480
|
+
...requestBody.contentType && requestBody.contentType !== "application/json" ? { requestBodyContentType: requestBody.contentType } : {},
|
|
249481
|
+
requestBodySchema: inline(requestBody.schema),
|
|
249482
|
+
responseSchema: inline(success)
|
|
249483
|
+
};
|
|
249484
|
+
const refs = leftoverRefs(contract, schemas);
|
|
249485
|
+
return {
|
|
249486
|
+
...contract,
|
|
249487
|
+
...refs.size > 0 ? {
|
|
249488
|
+
refs: Object.fromEntries([...refs].map(([ref, schema]) => [ref, slimSchema(schema)]))
|
|
249489
|
+
} : {}
|
|
249353
249490
|
};
|
|
249354
249491
|
}
|
|
249492
|
+
// src/core/api-spec/grep.ts
|
|
249493
|
+
function grepOperations(spec, operations, pattern, options = {}) {
|
|
249494
|
+
const regex = new RegExp(pattern, options.ignoreCase ? "i" : "");
|
|
249495
|
+
return operations.filter((op) => regex.test(JSON.stringify(getOperationContract(spec, op)))).slice(0, options.limit ?? 20).map(toOperationSummary);
|
|
249496
|
+
}
|
|
249355
249497
|
// src/core/api-spec/request.ts
|
|
249498
|
+
var MAX_ERROR_BODY_CHARS = 4000;
|
|
249499
|
+
var QUERY_STRING = /\?\S*/g;
|
|
249500
|
+
async function readBody(response) {
|
|
249501
|
+
try {
|
|
249502
|
+
const text = (await response.clone().text()).trim();
|
|
249503
|
+
return text.length > MAX_ERROR_BODY_CHARS ? `${text.slice(0, MAX_ERROR_BODY_CHARS)}…` : text || undefined;
|
|
249504
|
+
} catch {
|
|
249505
|
+
return;
|
|
249506
|
+
}
|
|
249507
|
+
}
|
|
249508
|
+
function normalizePath(path) {
|
|
249509
|
+
const url = new URL(path.replace(/^\/*/, "/"), "http://placeholder");
|
|
249510
|
+
return `${url.pathname}${url.search}`;
|
|
249511
|
+
}
|
|
249356
249512
|
async function sendApiRequest(method, path, body) {
|
|
249357
249513
|
try {
|
|
249358
249514
|
const response = await base44Client(path.replace(/^\/+/, ""), {
|
|
249359
249515
|
method,
|
|
249360
249516
|
body,
|
|
249361
|
-
headers: body ===
|
|
249517
|
+
headers: typeof body === "string" ? { "Content-Type": "application/json" } : {},
|
|
249518
|
+
timeout: false,
|
|
249519
|
+
retry: { methods: ["get", "head"] }
|
|
249362
249520
|
});
|
|
249363
|
-
return
|
|
249521
|
+
return {
|
|
249522
|
+
status: response.status,
|
|
249523
|
+
contentType: response.headers.get("content-type") ?? "",
|
|
249524
|
+
body: new Uint8Array(await response.arrayBuffer())
|
|
249525
|
+
};
|
|
249364
249526
|
} catch (error) {
|
|
249365
|
-
|
|
249366
|
-
|
|
249527
|
+
const apiError = await ApiError.fromHttpError(error, `calling ${method} ${path}`);
|
|
249528
|
+
const response = error instanceof HTTPError ? error.response : undefined;
|
|
249529
|
+
const raw = response ? await readBody(response) : undefined;
|
|
249530
|
+
const retryAfter = response?.headers.get("retry-after") ?? undefined;
|
|
249531
|
+
throw redactedApiError(apiError, raw, method, path, retryAfter);
|
|
249532
|
+
}
|
|
249533
|
+
}
|
|
249534
|
+
function redactedApiError(apiError, raw, method, path, retryAfter) {
|
|
249535
|
+
const wait = retryAfter ? ` (retry after ${/^\d+$/.test(retryAfter) ? `${retryAfter} s` : retryAfter})` : "";
|
|
249536
|
+
const reason = apiError.statusCode !== undefined ? `HTTP ${apiError.statusCode}${wait}` : (apiError.cause?.message ?? "request failed").replace(QUERY_STRING, "");
|
|
249537
|
+
const message = `Error calling ${method} ${path.split("?", 1)[0]}: ${reason}`;
|
|
249538
|
+
return new ApiError(message, {
|
|
249539
|
+
statusCode: apiError.statusCode,
|
|
249540
|
+
requestUrl: apiError.requestUrl?.split("?", 1)[0],
|
|
249541
|
+
requestMethod: apiError.requestMethod,
|
|
249542
|
+
requestId: apiError.requestId,
|
|
249543
|
+
hints: apiError.hints,
|
|
249544
|
+
details: [
|
|
249545
|
+
...raw ? [`Response body: ${raw}`] : apiError.details ?? [],
|
|
249546
|
+
...apiError.requestId ? [`Request ID: ${apiError.requestId}`] : []
|
|
249547
|
+
]
|
|
249548
|
+
});
|
|
249367
249549
|
}
|
|
249368
249550
|
// src/core/api-spec/spec.ts
|
|
249369
|
-
import { stat as stat3 } from "node:fs/promises";
|
|
249551
|
+
import { rename, rm, stat as stat3 } from "node:fs/promises";
|
|
249370
249552
|
import { join as join22 } from "node:path";
|
|
249371
249553
|
var SPEC_CACHE_TTL_MS = 60 * 60 * 1000;
|
|
249372
249554
|
function getSpecCachePath(apiUrl = getBase44ApiUrl()) {
|
|
@@ -249389,17 +249571,24 @@ function parseSpec(text) {
|
|
|
249389
249571
|
}
|
|
249390
249572
|
return result.data;
|
|
249391
249573
|
}
|
|
249574
|
+
var SPEC_DOWNLOAD_TIMEOUT_MS = 60000;
|
|
249392
249575
|
async function readFreshCache(path) {
|
|
249393
249576
|
try {
|
|
249394
249577
|
const { mtimeMs } = await stat3(path);
|
|
249395
|
-
|
|
249578
|
+
if (!isSpecCacheFresh(mtimeMs)) {
|
|
249579
|
+
return null;
|
|
249580
|
+
}
|
|
249581
|
+
const text = await readTextFile(path);
|
|
249582
|
+
return { text, spec: parseSpec(text) };
|
|
249396
249583
|
} catch {
|
|
249397
249584
|
return null;
|
|
249398
249585
|
}
|
|
249399
249586
|
}
|
|
249400
249587
|
async function downloadSpec() {
|
|
249401
249588
|
try {
|
|
249402
|
-
const response = await base44Client.get("api/openapi.json"
|
|
249589
|
+
const response = await base44Client.get("api/openapi.json", {
|
|
249590
|
+
timeout: SPEC_DOWNLOAD_TIMEOUT_MS
|
|
249591
|
+
});
|
|
249403
249592
|
return await response.text();
|
|
249404
249593
|
} catch (error) {
|
|
249405
249594
|
throw await ApiError.fromHttpError(error, "fetching the API spec");
|
|
@@ -249409,29 +249598,25 @@ async function loadSpec(options = {}) {
|
|
|
249409
249598
|
const path = getSpecCachePath();
|
|
249410
249599
|
const cached = options.refresh ? null : await readFreshCache(path);
|
|
249411
249600
|
if (cached !== null) {
|
|
249412
|
-
return
|
|
249601
|
+
return cached;
|
|
249413
249602
|
}
|
|
249414
249603
|
const text = await downloadSpec();
|
|
249415
249604
|
const spec = parseSpec(text);
|
|
249416
|
-
|
|
249605
|
+
const partial = `${path}.${process.pid}.tmp`;
|
|
249606
|
+
try {
|
|
249607
|
+
await writeFile(partial, text);
|
|
249608
|
+
await rename(partial, path);
|
|
249609
|
+
} catch {
|
|
249610
|
+
await rm(partial, { force: true }).catch(() => {
|
|
249611
|
+
return;
|
|
249612
|
+
});
|
|
249613
|
+
}
|
|
249417
249614
|
return { text, spec };
|
|
249418
249615
|
}
|
|
249419
249616
|
// src/cli/commands/api/shared.ts
|
|
249617
|
+
import { basename as basename6 } from "node:path";
|
|
249420
249618
|
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
|
-
}
|
|
249619
|
+
return toJsonStdout(value, { compact: !process.stdout.isTTY });
|
|
249435
249620
|
}
|
|
249436
249621
|
function parseLimit(value) {
|
|
249437
249622
|
if (value === undefined) {
|
|
@@ -249443,6 +249628,7 @@ function parseLimit(value) {
|
|
|
249443
249628
|
}
|
|
249444
249629
|
return n;
|
|
249445
249630
|
}
|
|
249631
|
+
var READ_ONLY_FILTER_HELP = "Only read-only operations";
|
|
249446
249632
|
var REFRESH_OPTION_HELP = "Fetch the API spec again instead of using the cached copy (kept 1 hour)";
|
|
249447
249633
|
function loadSpecTask({ runTask }, refresh) {
|
|
249448
249634
|
return runTask("Loading the API spec", () => loadSpec({ refresh }), {
|
|
@@ -249460,53 +249646,80 @@ function operationsInArea(operations, area) {
|
|
|
249460
249646
|
}
|
|
249461
249647
|
return inArea;
|
|
249462
249648
|
}
|
|
249463
|
-
async function readRequestBody(
|
|
249649
|
+
async function readRequestBody(flag) {
|
|
249464
249650
|
if (flag === "@-") {
|
|
249465
249651
|
return readStdin("--body @-", { trim: false });
|
|
249466
249652
|
}
|
|
249467
249653
|
if (flag?.startsWith("@")) {
|
|
249468
249654
|
return readTextFile(flag.slice(1));
|
|
249469
249655
|
}
|
|
249470
|
-
|
|
249471
|
-
|
|
249472
|
-
|
|
249473
|
-
|
|
249474
|
-
|
|
249656
|
+
return flag;
|
|
249657
|
+
}
|
|
249658
|
+
var FORM_FILE = /^@(.+?)(?:;type=([^;]+))?$/;
|
|
249659
|
+
async function readFormBody(fields) {
|
|
249660
|
+
const form = new FormData;
|
|
249661
|
+
for (const field of fields) {
|
|
249662
|
+
const separator = field.indexOf("=");
|
|
249663
|
+
if (separator < 1) {
|
|
249664
|
+
throw new InvalidInputError(`--form takes name=value or name=@file, got "${field}".`);
|
|
249665
|
+
}
|
|
249666
|
+
const name = field.slice(0, separator);
|
|
249667
|
+
const value = field.slice(separator + 1);
|
|
249668
|
+
const file = FORM_FILE.exec(value);
|
|
249669
|
+
if (file?.[1]) {
|
|
249670
|
+
const type = file[2] ?? "application/octet-stream";
|
|
249671
|
+
const blob = new Blob([await readFile(file[1])], { type });
|
|
249672
|
+
form.append(name, blob, basename6(file[1]));
|
|
249673
|
+
} else {
|
|
249674
|
+
form.append(name, value);
|
|
249675
|
+
}
|
|
249475
249676
|
}
|
|
249476
|
-
|
|
249477
|
-
|
|
249677
|
+
return form;
|
|
249678
|
+
}
|
|
249679
|
+
function withoutQuery(path) {
|
|
249680
|
+
return path.split("?", 1)[0] ?? "";
|
|
249681
|
+
}
|
|
249682
|
+
function reportedFetchCommand(method, path, options) {
|
|
249683
|
+
return {
|
|
249684
|
+
name: "api fetch",
|
|
249685
|
+
args: [method, withoutQuery(path)],
|
|
249686
|
+
options: {
|
|
249687
|
+
...options,
|
|
249688
|
+
...options.body === undefined ? {} : { body: "[not reported]" },
|
|
249689
|
+
...Array.isArray(options.form) && options.form.length > 0 ? { form: "[not reported]" } : {}
|
|
249690
|
+
}
|
|
249691
|
+
};
|
|
249478
249692
|
}
|
|
249479
249693
|
|
|
249480
249694
|
// src/cli/commands/api/catalog.ts
|
|
249481
249695
|
async function catalogAction(ctx, area, options) {
|
|
249482
249696
|
const { spec } = await loadSpecTask(ctx, options.refresh);
|
|
249483
249697
|
const operations = listOperations(spec);
|
|
249484
|
-
|
|
249485
|
-
|
|
249698
|
+
const filterReadOnly = (ops) => options.readOnly ? ops.filter((op) => op.readOnly) : ops;
|
|
249699
|
+
if (!area) {
|
|
249700
|
+
return { stdout: formatJson(catalogIndex(filterReadOnly(operations))) };
|
|
249486
249701
|
}
|
|
249487
|
-
const inArea = operationsInArea(operations, area);
|
|
249488
|
-
return {
|
|
249489
|
-
stdout: formatJson({
|
|
249490
|
-
area,
|
|
249491
|
-
operations: inArea.map(toOperationSummary),
|
|
249492
|
-
total: inArea.length
|
|
249493
|
-
})
|
|
249494
|
-
};
|
|
249702
|
+
const inArea = filterReadOnly(operationsInArea(operations, area));
|
|
249703
|
+
return { stdout: formatJson(areaListing(area, inArea)) };
|
|
249495
249704
|
}
|
|
249496
249705
|
function getApiCatalogCommand() {
|
|
249497
249706
|
return new Base44Command("catalog", {
|
|
249498
249707
|
requireAuth: false,
|
|
249499
249708
|
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);
|
|
249709
|
+
}).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
249710
|
}
|
|
249502
249711
|
|
|
249503
249712
|
// src/cli/commands/api/fetch.ts
|
|
249504
|
-
async function findOperation(ctx, method, path, refresh) {
|
|
249713
|
+
async function findOperation(ctx, method, path, { refresh, flag }) {
|
|
249505
249714
|
const { spec } = await loadSpecTask(ctx, refresh);
|
|
249506
249715
|
const op = matchOperation(listOperations(spec), method, path);
|
|
249507
249716
|
if (!op) {
|
|
249508
|
-
throw new InvalidInputError(`No operation in the API spec matches ${method} ${path}.`, {
|
|
249717
|
+
throw new InvalidInputError(`No operation in the API spec matches ${method} ${withoutQuery(path)}.`, {
|
|
249509
249718
|
hints: [
|
|
249719
|
+
{
|
|
249720
|
+
message: "The cached spec may predate this route; fetch it again",
|
|
249721
|
+
command: `base44 api fetch ${method} ${path} ${flag} --refresh`
|
|
249722
|
+
},
|
|
249510
249723
|
{
|
|
249511
249724
|
message: "Find the operation and its path template",
|
|
249512
249725
|
command: 'base44 api search "<what you want to do>"'
|
|
@@ -249516,34 +249729,123 @@ async function findOperation(ctx, method, path, refresh) {
|
|
|
249516
249729
|
}
|
|
249517
249730
|
return { spec, op };
|
|
249518
249731
|
}
|
|
249732
|
+
var ENCODED_SEPARATOR = /%(2f|5c|2e)/i;
|
|
249733
|
+
async function fillAppId(ctx, path, command) {
|
|
249734
|
+
let filled = path;
|
|
249735
|
+
if (withoutQuery(path).includes("{app_id}")) {
|
|
249736
|
+
const { appId } = command.optsWithGlobals();
|
|
249737
|
+
await ensureAppContext(ctx, { appId });
|
|
249738
|
+
filled = path.replaceAll("{app_id}", requireApp(ctx).id);
|
|
249739
|
+
}
|
|
249740
|
+
const placeholder = withoutQuery(filled).match(/\{[^}/]*\}/);
|
|
249741
|
+
if (placeholder) {
|
|
249742
|
+
throw new InvalidInputError(`Replace ${placeholder[0]} in the path with a real value; only {app_id} is filled in.`);
|
|
249743
|
+
}
|
|
249744
|
+
return filled;
|
|
249745
|
+
}
|
|
249746
|
+
var MULTIPART_HINT = "Send this body with --form name=value, and --form name=@path for files.";
|
|
249747
|
+
var CONTRACT_HELP = "The contract is JSON; cut it down with e.g. | jq '.parameters, .requestBodySchema'";
|
|
249748
|
+
var TEXT_CONTENT_TYPES = [
|
|
249749
|
+
"json",
|
|
249750
|
+
"text/",
|
|
249751
|
+
"xml",
|
|
249752
|
+
"javascript",
|
|
249753
|
+
"x-www-form-urlencoded"
|
|
249754
|
+
];
|
|
249755
|
+
function decodeText(body, contentType) {
|
|
249756
|
+
const type = contentType.toLowerCase();
|
|
249757
|
+
if (type && !TEXT_CONTENT_TYPES.some((hint) => type.includes(hint))) {
|
|
249758
|
+
return;
|
|
249759
|
+
}
|
|
249760
|
+
try {
|
|
249761
|
+
return new TextDecoder("utf-8", { fatal: true }).decode(body);
|
|
249762
|
+
} catch {
|
|
249763
|
+
return;
|
|
249764
|
+
}
|
|
249765
|
+
}
|
|
249766
|
+
async function formatResponse({ status, contentType, body }, output, jsonMode) {
|
|
249767
|
+
if (output) {
|
|
249768
|
+
await writeFile(output, body);
|
|
249769
|
+
return formatJson({ status, contentType, bytes: body.length, output });
|
|
249770
|
+
}
|
|
249771
|
+
if (body.length === 0) {
|
|
249772
|
+
return formatJson({ status });
|
|
249773
|
+
}
|
|
249774
|
+
const text = decodeText(body, contentType);
|
|
249775
|
+
if (text === undefined) {
|
|
249776
|
+
return formatJson({
|
|
249777
|
+
status,
|
|
249778
|
+
contentType,
|
|
249779
|
+
bytes: body.length,
|
|
249780
|
+
note: "Binary body not printed; add --output <file> to save it."
|
|
249781
|
+
});
|
|
249782
|
+
}
|
|
249783
|
+
const asIs = text.endsWith(`
|
|
249784
|
+
`) ? text : `${text}
|
|
249785
|
+
`;
|
|
249786
|
+
try {
|
|
249787
|
+
const parsed = JSON.parse(text);
|
|
249788
|
+
return process.stdout.isTTY ? formatJson(parsed) : asIs;
|
|
249789
|
+
} catch {
|
|
249790
|
+
return jsonMode ? formatJson({ status, contentType, body: text }) : asIs;
|
|
249791
|
+
}
|
|
249792
|
+
}
|
|
249519
249793
|
async function fetchAction(ctx, methodArg, path, options, command) {
|
|
249794
|
+
ctx.errorReporter.setContext({
|
|
249795
|
+
command: reportedFetchCommand(methodArg ?? "", path ?? "", { ...options })
|
|
249796
|
+
});
|
|
249520
249797
|
if (!methodArg || !path) {
|
|
249521
249798
|
if (options.help) {
|
|
249522
|
-
|
|
249799
|
+
const usage = `${command.helpInformation()}
|
|
249800
|
+
${CONTRACT_HELP}
|
|
249801
|
+
`;
|
|
249802
|
+
return { stdout: ctx.jsonMode ? formatJson({ usage }) : usage };
|
|
249523
249803
|
}
|
|
249524
249804
|
throw new InvalidInputError("Provide a method and a path, e.g. GET /api/apps.");
|
|
249525
249805
|
}
|
|
249526
249806
|
const method = methodArg.toUpperCase();
|
|
249527
249807
|
if (options.help) {
|
|
249528
|
-
const { spec, op } = await findOperation(ctx, method, path,
|
|
249529
|
-
|
|
249808
|
+
const { spec, op } = await findOperation(ctx, method, normalizePath(path), {
|
|
249809
|
+
refresh: options.refresh,
|
|
249810
|
+
flag: "--help"
|
|
249811
|
+
});
|
|
249812
|
+
const contract = getOperationContract(spec, op);
|
|
249813
|
+
return {
|
|
249814
|
+
stdout: formatJson(contract.requestBodyContentType === "multipart/form-data" ? { ...contract, hint: MULTIPART_HINT } : contract)
|
|
249815
|
+
};
|
|
249530
249816
|
}
|
|
249817
|
+
const target = normalizePath(await fillAppId(ctx, path, command));
|
|
249531
249818
|
if (options.readOnly) {
|
|
249532
|
-
|
|
249819
|
+
if (ENCODED_SEPARATOR.test(withoutQuery(target))) {
|
|
249820
|
+
throw new InvalidInputError("Refused under --read-only: the path has an encoded /, \\ or ., so it can't be checked. Nothing was sent.");
|
|
249821
|
+
}
|
|
249822
|
+
const { op } = await findOperation(ctx, method, target, {
|
|
249823
|
+
refresh: options.refresh,
|
|
249824
|
+
flag: "--read-only"
|
|
249825
|
+
});
|
|
249533
249826
|
if (!op.readOnly) {
|
|
249534
249827
|
throw new InvalidInputError(`Refused under --read-only: ${op.method} ${op.path} is not a read-only operation. Nothing was sent.`);
|
|
249535
249828
|
}
|
|
249536
249829
|
}
|
|
249830
|
+
if (options.body !== undefined && options.form.length > 0) {
|
|
249831
|
+
throw new InvalidInputError("Use --body or --form, not both.");
|
|
249832
|
+
}
|
|
249537
249833
|
await ensureAuth(ctx);
|
|
249538
|
-
const body = await readRequestBody(
|
|
249539
|
-
const
|
|
249540
|
-
|
|
249834
|
+
const body = options.form.length > 0 ? await readFormBody(options.form) : await readRequestBody(options.body);
|
|
249835
|
+
const response = await ctx.runTask(`Calling ${method} ${target}`, () => sendApiRequest(method, target, body), {
|
|
249836
|
+
successMessage: `Called ${method} ${target}`,
|
|
249837
|
+
errorMessage: "Request failed"
|
|
249838
|
+
});
|
|
249839
|
+
return {
|
|
249840
|
+
stdout: await formatResponse(response, options.output, ctx.jsonMode)
|
|
249841
|
+
};
|
|
249541
249842
|
}
|
|
249542
249843
|
function getApiFetchCommand() {
|
|
249543
249844
|
return new Base44Command("fetch", {
|
|
249544
249845
|
requireAuth: false,
|
|
249545
249846
|
requireAppContext: false
|
|
249546
|
-
}).description("Call a Base44 API operation
|
|
249847
|
+
}).description("Call a Base44 API operation; add --help after a path for its contract").helpOption(false).argument("[method]", "HTTP method, e.g. GET or POST").argument("[path]", 'Path with any query string; {app_id} is filled from --app-id or the project, e.g. "/api/apps/{app_id}/workflows/runs?status=failed"').option("--body <json>", "Request body: JSON, @file.json, or @- to read it from stdin").option("--form <field>", "Multipart field: name=value, or name=@file to attach a file (repeatable)", (field, fields) => [...fields, field], []).option("--output <file>", "Save the response body to a file").option("--read-only", "Refuse, before sending, any operation the spec does not mark read-only").option("--refresh", REFRESH_OPTION_HELP).option("-h, --help", "With a method and path, print that operation's contract; otherwise this help").addHelpText("after", `
|
|
249848
|
+
${CONTRACT_HELP}`).action(fetchAction);
|
|
249547
249849
|
}
|
|
249548
249850
|
|
|
249549
249851
|
// src/cli/commands/api/grep.ts
|
|
@@ -249558,12 +249860,14 @@ async function grepAction(ctx, pattern, options) {
|
|
|
249558
249860
|
const limit = parseLimit(options.limit);
|
|
249559
249861
|
assertValidRegex(pattern);
|
|
249560
249862
|
const { spec } = await loadSpecTask(ctx, options.refresh);
|
|
249561
|
-
|
|
249562
|
-
if (options.area
|
|
249563
|
-
operationsInArea(operations, options.area);
|
|
249863
|
+
let operations = listOperations(spec);
|
|
249864
|
+
if (options.area) {
|
|
249865
|
+
operations = operationsInArea(operations, options.area);
|
|
249564
249866
|
}
|
|
249565
|
-
|
|
249566
|
-
|
|
249867
|
+
if (options.readOnly) {
|
|
249868
|
+
operations = operations.filter((op) => op.readOnly);
|
|
249869
|
+
}
|
|
249870
|
+
const hits = grepOperations(spec, operations, pattern, {
|
|
249567
249871
|
ignoreCase: options.ignoreCase,
|
|
249568
249872
|
limit
|
|
249569
249873
|
});
|
|
@@ -249573,7 +249877,7 @@ function getApiGrepCommand() {
|
|
|
249573
249877
|
return new Base44Command("grep", {
|
|
249574
249878
|
requireAuth: false,
|
|
249575
249879
|
requireAppContext: false
|
|
249576
|
-
}).description("Search the
|
|
249880
|
+
}).description("Search the API spec with a regular expression, for when search misses").argument("<pattern>", `Regular expression over each operation's contract as JSON text (quotes and newlines appear escaped), e.g. "runs.*status"`).option("--area <area>", "Search only one area's operations (see base44 api catalog)").option("-i, --ignore-case", "Case-insensitive match").option("--limit <n>", "Most operations to return (default 20)").option("--read-only", READ_ONLY_FILTER_HELP).option("--refresh", REFRESH_OPTION_HELP).action(grepAction);
|
|
249577
249881
|
}
|
|
249578
249882
|
|
|
249579
249883
|
// src/cli/commands/api/search.ts
|
|
@@ -249590,7 +249894,7 @@ function getApiSearchCommand() {
|
|
|
249590
249894
|
return new Base44Command("search", {
|
|
249591
249895
|
requireAuth: false,
|
|
249592
249896
|
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",
|
|
249897
|
+
}).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
249898
|
}
|
|
249595
249899
|
|
|
249596
249900
|
// src/cli/commands/api/index.ts
|
|
@@ -251360,7 +251664,7 @@ function getBuildCommand() {
|
|
|
251360
251664
|
}
|
|
251361
251665
|
|
|
251362
251666
|
// src/cli/commands/project/create.ts
|
|
251363
|
-
import { basename as
|
|
251667
|
+
import { basename as basename7, resolve as resolve11 } from "node:path";
|
|
251364
251668
|
var import_kebabCase = __toESM(require_kebabCase(), 1);
|
|
251365
251669
|
|
|
251366
251670
|
// src/cli/commands/project/scaffold-shared.ts
|
|
@@ -251525,8 +251829,8 @@ async function createInteractive(options, ctx) {
|
|
|
251525
251829
|
name: () => {
|
|
251526
251830
|
return options.name ? Promise.resolve(options.name) : Ze({
|
|
251527
251831
|
message: "What is the name of your project?",
|
|
251528
|
-
placeholder:
|
|
251529
|
-
initialValue:
|
|
251832
|
+
placeholder: basename7(process.cwd()),
|
|
251833
|
+
initialValue: basename7(process.cwd()),
|
|
251530
251834
|
validate: (value) => {
|
|
251531
251835
|
if (!value || value.trim().length === 0) {
|
|
251532
251836
|
return "Every project deserves a name";
|
|
@@ -252221,7 +252525,7 @@ function getLogsCommand() {
|
|
|
252221
252525
|
}
|
|
252222
252526
|
|
|
252223
252527
|
// src/cli/commands/project/scaffold.ts
|
|
252224
|
-
import { basename as
|
|
252528
|
+
import { basename as basename8, resolve as resolve12 } from "node:path";
|
|
252225
252529
|
function resolveAppId(options) {
|
|
252226
252530
|
const appId = options.appId;
|
|
252227
252531
|
if (!appId) {
|
|
@@ -252238,7 +252542,7 @@ async function scaffoldAction(ctx, name, options, command) {
|
|
|
252238
252542
|
const { log, runTask } = ctx;
|
|
252239
252543
|
const appId = resolveAppId(command.optsWithGlobals());
|
|
252240
252544
|
const resolvedPath = resolve12("./");
|
|
252241
|
-
const projectName = (name ??
|
|
252545
|
+
const projectName = (name ?? basename8(resolvedPath)).trim();
|
|
252242
252546
|
const template = await getTemplateById("backend-only");
|
|
252243
252547
|
log.info(`Scaffolding project at ${resolvedPath}`);
|
|
252244
252548
|
const { projectId } = await runTask("Setting up your project...", async () => {
|
|
@@ -262133,7 +262437,7 @@ var nativeEnumType = ZodNativeEnum.create;
|
|
|
262133
262437
|
var promiseType = ZodPromise.create;
|
|
262134
262438
|
var effectsType = ZodEffects.create;
|
|
262135
262439
|
var optionalType = ZodOptional2.create;
|
|
262136
|
-
var
|
|
262440
|
+
var nullableType2 = ZodNullable2.create;
|
|
262137
262441
|
var preprocessType = ZodEffects.createWithPreprocess;
|
|
262138
262442
|
var pipelineType = ZodPipeline.create;
|
|
262139
262443
|
// ../functions-compiler/src/contracts.ts
|
|
@@ -262163,7 +262467,7 @@ var bundleAppRequestSchema = objectType({
|
|
|
262163
262467
|
var ACTIVATION_MODE = "pull";
|
|
262164
262468
|
|
|
262165
262469
|
// ../functions-compiler/src/deno-bundle.ts
|
|
262166
|
-
import { mkdtemp, rm, writeFile as writeFile2 } from "node:fs/promises";
|
|
262470
|
+
import { mkdtemp, rm as rm2, writeFile as writeFile2 } from "node:fs/promises";
|
|
262167
262471
|
import { tmpdir as tmpdir2 } from "node:os";
|
|
262168
262472
|
import path21 from "node:path";
|
|
262169
262473
|
|
|
@@ -262770,7 +263074,7 @@ async function bundleToModule(prepared, nodeModulesDir = "none") {
|
|
|
262770
263074
|
warnings: result.warnings.map((w) => w.text)
|
|
262771
263075
|
};
|
|
262772
263076
|
} finally {
|
|
262773
|
-
await
|
|
263077
|
+
await rm2(dir, { recursive: true, force: true });
|
|
262774
263078
|
}
|
|
262775
263079
|
}
|
|
262776
263080
|
function buildFailureErrors(e, dir) {
|
|
@@ -267761,7 +268065,7 @@ function createPattern(matcher) {
|
|
|
267761
268065
|
}
|
|
267762
268066
|
return () => false;
|
|
267763
268067
|
}
|
|
267764
|
-
function
|
|
268068
|
+
function normalizePath2(path) {
|
|
267765
268069
|
if (typeof path !== "string")
|
|
267766
268070
|
throw new Error("string expected");
|
|
267767
268071
|
path = sp3.normalize(path);
|
|
@@ -267775,7 +268079,7 @@ function normalizePath(path) {
|
|
|
267775
268079
|
return path;
|
|
267776
268080
|
}
|
|
267777
268081
|
function matchPatterns(patterns, testString, stats) {
|
|
267778
|
-
const path =
|
|
268082
|
+
const path = normalizePath2(testString);
|
|
267779
268083
|
for (let index = 0;index < patterns.length; index++) {
|
|
267780
268084
|
const pattern = patterns[index];
|
|
267781
268085
|
if (pattern(path, stats)) {
|
|
@@ -273135,4 +273439,4 @@ export {
|
|
|
273135
273439
|
runCLI
|
|
273136
273440
|
};
|
|
273137
273441
|
|
|
273138
|
-
//# debugId=
|
|
273442
|
+
//# debugId=4213AA6F0A5C795F64756E2164756E21
|