@base44-preview/cli 0.1.32-pr.663.57b7b28 → 0.1.32-pr.663.63c4a74
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 +3 -2
- package/dist/cli/index.js +632 -172
- package/dist/cli/index.js.map +23 -20
- 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
|
|
@@ -248042,28 +248042,6 @@ function getAgentsCommand() {
|
|
|
248042
248042
|
return new Command2("agents").description("Manage project agents").addCommand(getAgentsPushCommand()).addCommand(getAgentsPullCommand());
|
|
248043
248043
|
}
|
|
248044
248044
|
|
|
248045
|
-
// src/core/api-spec/body.ts
|
|
248046
|
-
var METHODS_WITHOUT_BODY = new Set(["GET", "HEAD"]);
|
|
248047
|
-
async function resolveRequestBody(method, flag, source) {
|
|
248048
|
-
const takesBody = !METHODS_WITHOUT_BODY.has(method.toUpperCase());
|
|
248049
|
-
if (flag !== undefined && !takesBody) {
|
|
248050
|
-
throw new InvalidInputError(`${method.toUpperCase()} requests cannot have a body.`);
|
|
248051
|
-
}
|
|
248052
|
-
if (flag === "@-") {
|
|
248053
|
-
return source.readStdin();
|
|
248054
|
-
}
|
|
248055
|
-
if (flag?.startsWith("@")) {
|
|
248056
|
-
return readTextFile(flag.slice(1));
|
|
248057
|
-
}
|
|
248058
|
-
if (flag !== undefined) {
|
|
248059
|
-
return flag;
|
|
248060
|
-
}
|
|
248061
|
-
if (!takesBody || source.stdinIsTTY) {
|
|
248062
|
-
return;
|
|
248063
|
-
}
|
|
248064
|
-
const piped = await source.readStdin();
|
|
248065
|
-
return piped.trim() ? piped : undefined;
|
|
248066
|
-
}
|
|
248067
248045
|
// ../../node_modules/minisearch/dist/es/index.js
|
|
248068
248046
|
var ENTRIES = "ENTRIES";
|
|
248069
248047
|
var KEYS = "KEYS";
|
|
@@ -249124,24 +249102,30 @@ var wait = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
|
249124
249102
|
var SPACE_OR_PUNCTUATION = /[\n\r\p{Z}\p{P}]+/u;
|
|
249125
249103
|
|
|
249126
249104
|
// src/core/api-spec/search.ts
|
|
249127
|
-
var BOOST = {
|
|
249105
|
+
var BOOST = {
|
|
249106
|
+
method: 1,
|
|
249107
|
+
path: 8,
|
|
249108
|
+
summary: 5,
|
|
249109
|
+
description: 2,
|
|
249110
|
+
parameters: 0.5
|
|
249111
|
+
};
|
|
249128
249112
|
var MIN_RELATIVE_SCORE = 0.2;
|
|
249129
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
|
+
}
|
|
249130
249118
|
function toOperationSummary(op) {
|
|
249131
|
-
return {
|
|
249132
|
-
method: op.method,
|
|
249133
|
-
path: op.path,
|
|
249134
|
-
summary: op.summary,
|
|
249135
|
-
readOnly: op.readOnly
|
|
249136
|
-
};
|
|
249119
|
+
return { endpoint: op.endpoint, summary: op.summary };
|
|
249137
249120
|
}
|
|
249138
249121
|
function buildSearchIndex(operations) {
|
|
249139
249122
|
const index = new MiniSearch({
|
|
249140
|
-
fields: ["path", "summary", "description", "parameters"],
|
|
249141
|
-
tokenize
|
|
249123
|
+
fields: ["method", "path", "summary", "description", "parameters"],
|
|
249124
|
+
tokenize
|
|
249142
249125
|
});
|
|
249143
249126
|
index.addAll(operations.map((op, id) => ({
|
|
249144
249127
|
id,
|
|
249128
|
+
method: op.method,
|
|
249145
249129
|
path: op.path.replace(/\{[^}]*\}/g, ""),
|
|
249146
249130
|
summary: op.summary,
|
|
249147
249131
|
description: op.description,
|
|
@@ -249149,53 +249133,86 @@ function buildSearchIndex(operations) {
|
|
|
249149
249133
|
})));
|
|
249150
249134
|
return index;
|
|
249151
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;
|
|
249152
249145
|
function searchOperations(operations, query, options = {}) {
|
|
249146
|
+
const terms = tokenize(query.toLowerCase());
|
|
249147
|
+
if (terms.length === 0) {
|
|
249148
|
+
return [];
|
|
249149
|
+
}
|
|
249153
249150
|
const index = buildSearchIndex(operations);
|
|
249154
249151
|
const hits = index.search(query, {
|
|
249155
|
-
prefix:
|
|
249156
|
-
fuzzy: 0.2,
|
|
249152
|
+
prefix: (term) => term.length >= 3,
|
|
249153
|
+
fuzzy: (term) => term.length >= 4 ? 0.2 : false,
|
|
249157
249154
|
boost: BOOST,
|
|
249158
249155
|
filter: options.readOnly ? (hit) => operations[hit.id]?.readOnly === true : undefined
|
|
249159
|
-
})
|
|
249160
|
-
|
|
249161
|
-
|
|
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) => {
|
|
249162
249167
|
const op = operations[hit.id];
|
|
249163
249168
|
return op ? [toOperationSummary(op)] : [];
|
|
249164
249169
|
});
|
|
249165
249170
|
}
|
|
249166
249171
|
|
|
249167
|
-
// src/core/api-spec/
|
|
249168
|
-
var
|
|
249169
|
-
var
|
|
249170
|
-
var
|
|
249171
|
-
|
|
249172
|
-
|
|
249173
|
-
|
|
249174
|
-
|
|
249175
|
-
|
|
249176
|
-
|
|
249177
|
-
if (found.length === MAX_SNIPPETS || match[0].length === 0) {
|
|
249178
|
-
break;
|
|
249179
|
-
}
|
|
249172
|
+
// src/core/api-spec/catalog.ts
|
|
249173
|
+
var INLINE_AREA_MAX = 2;
|
|
249174
|
+
var AREA_SAMPLE_MAX = 3;
|
|
249175
|
+
var AREA_OPERATIONS_MAX = 200;
|
|
249176
|
+
var byCodePoint = (a, b) => a < b ? -1 : a > b ? 1 : 0;
|
|
249177
|
+
function areaOf(path) {
|
|
249178
|
+
const parts = path.split("/").filter(Boolean);
|
|
249179
|
+
const appIdIndex = parts.indexOf("{app_id}");
|
|
249180
|
+
if (appIdIndex !== -1 && appIdIndex + 1 < parts.length) {
|
|
249181
|
+
return parts[appIdIndex + 1] ?? "other";
|
|
249180
249182
|
}
|
|
249181
|
-
|
|
249182
|
-
|
|
249183
|
-
function grepSpec(spec, operations, pattern, options = {}) {
|
|
249184
|
-
const regex = new RegExp(pattern, options.ignoreCase ? "gi" : "g");
|
|
249185
|
-
const hits = [];
|
|
249186
|
-
for (const op of operations) {
|
|
249187
|
-
const matches = snippets(`${op.method} ${op.path} ${JSON.stringify(op.operation)}`, regex);
|
|
249188
|
-
if (matches.length > 0) {
|
|
249189
|
-
hits.push({ ...toOperationSummary(op), matches });
|
|
249190
|
-
}
|
|
249183
|
+
if (parts[0] === "api" && parts.length > 1) {
|
|
249184
|
+
return parts[1] ?? "other";
|
|
249191
249185
|
}
|
|
249192
|
-
|
|
249193
|
-
|
|
249194
|
-
|
|
249195
|
-
|
|
249196
|
-
|
|
249186
|
+
return parts[0] ?? "other";
|
|
249187
|
+
}
|
|
249188
|
+
function groupByArea(operations) {
|
|
249189
|
+
const sorted = [...operations].sort((a, b) => byCodePoint(`${a.method} ${a.path}`, `${b.method} ${b.path}`));
|
|
249190
|
+
const areas = new Map;
|
|
249191
|
+
for (const op of sorted) {
|
|
249192
|
+
const area = areaOf(op.path);
|
|
249193
|
+
areas.set(area, [...areas.get(area) ?? [], op]);
|
|
249197
249194
|
}
|
|
249198
|
-
return
|
|
249195
|
+
return new Map([...areas].sort(([a], [b]) => byCodePoint(a, b)));
|
|
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
|
+
}
|
|
249201
|
+
function catalogIndex(operations) {
|
|
249202
|
+
const areas = [...groupByArea(operations)].map(([area, ops]) => ops.length <= INLINE_AREA_MAX ? { area, operations: ops.map(toOperationSummary) } : {
|
|
249203
|
+
area,
|
|
249204
|
+
operationCount: ops.length,
|
|
249205
|
+
sample: readsFirst2(ops).slice(0, AREA_SAMPLE_MAX).map((op) => op.summary)
|
|
249206
|
+
});
|
|
249207
|
+
return { areas, total: operations.length };
|
|
249208
|
+
}
|
|
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
|
+
};
|
|
249199
249216
|
}
|
|
249200
249217
|
// src/core/api-spec/schema.ts
|
|
249201
249218
|
var HTTP_METHODS = [
|
|
@@ -249213,7 +249230,16 @@ var ParameterSchema = looseObject({
|
|
|
249213
249230
|
in: string2(),
|
|
249214
249231
|
required: boolean2().optional(),
|
|
249215
249232
|
description: string2().optional(),
|
|
249216
|
-
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()
|
|
249217
249243
|
});
|
|
249218
249244
|
var SecurityRequirementSchema = record(string2(), array(string2()));
|
|
249219
249245
|
var OperationSchema = looseObject({
|
|
@@ -249225,7 +249251,10 @@ var OperationSchema = looseObject({
|
|
|
249225
249251
|
responses: record(string2(), unknown()).optional(),
|
|
249226
249252
|
security: array(SecurityRequirementSchema).optional()
|
|
249227
249253
|
});
|
|
249228
|
-
var PathItemSchema = looseObject(
|
|
249254
|
+
var PathItemSchema = looseObject({
|
|
249255
|
+
...Object.fromEntries(HTTP_METHODS.map((method) => [method, OperationSchema.optional()])),
|
|
249256
|
+
parameters: array(unknown()).optional()
|
|
249257
|
+
});
|
|
249229
249258
|
var OpenApiSpecSchema = looseObject({
|
|
249230
249259
|
openapi: string2(),
|
|
249231
249260
|
paths: record(string2(), PathItemSchema),
|
|
@@ -249235,6 +249264,154 @@ var OpenApiSpecSchema = looseObject({
|
|
|
249235
249264
|
security: array(SecurityRequirementSchema).optional()
|
|
249236
249265
|
});
|
|
249237
249266
|
|
|
249267
|
+
// src/core/api-spec/contract.ts
|
|
249268
|
+
var SCHEMA_REF_PREFIX = "#/components/schemas/";
|
|
249269
|
+
var MAX_REF_DEPTH = 4;
|
|
249270
|
+
var FRAMEWORK_VALIDATION_ERROR = "Validation Error";
|
|
249271
|
+
function inlineRefs(node, schemas, seen = new Set, depth = 0) {
|
|
249272
|
+
if (depth > MAX_REF_DEPTH) {
|
|
249273
|
+
return node;
|
|
249274
|
+
}
|
|
249275
|
+
if (Array.isArray(node)) {
|
|
249276
|
+
return node.map((item) => inlineRefs(item, schemas, seen, depth));
|
|
249277
|
+
}
|
|
249278
|
+
if (node === null || typeof node !== "object") {
|
|
249279
|
+
return node;
|
|
249280
|
+
}
|
|
249281
|
+
const { $ref, ...siblings } = node;
|
|
249282
|
+
if (typeof $ref === "string" && $ref.startsWith(SCHEMA_REF_PREFIX)) {
|
|
249283
|
+
const name = $ref.slice(SCHEMA_REF_PREFIX.length);
|
|
249284
|
+
if (seen.has(name) || !(name in schemas)) {
|
|
249285
|
+
return node;
|
|
249286
|
+
}
|
|
249287
|
+
const resolved = inlineRefs(schemas[name], schemas, new Set([...seen, name]), depth + 1);
|
|
249288
|
+
return resolved !== null && typeof resolved === "object" ? { ...resolved, ...siblings } : resolved;
|
|
249289
|
+
}
|
|
249290
|
+
return Object.fromEntries(Object.entries(node).map(([key, value]) => [
|
|
249291
|
+
key,
|
|
249292
|
+
inlineRefs(value, schemas, seen, depth)
|
|
249293
|
+
]));
|
|
249294
|
+
}
|
|
249295
|
+
function bodyOf(value) {
|
|
249296
|
+
const parsed = MediaContentSchema.safeParse(value);
|
|
249297
|
+
const content = parsed.success ? parsed.data.content ?? {} : {};
|
|
249298
|
+
const contentType = "application/json" in content ? "application/json" : Object.keys(content)[0];
|
|
249299
|
+
return contentType ? { contentType, schema: content[contentType]?.schema } : {};
|
|
249300
|
+
}
|
|
249301
|
+
function leftoverRefs(node, schemas, found = new Map) {
|
|
249302
|
+
if (Array.isArray(node)) {
|
|
249303
|
+
for (const item of node) {
|
|
249304
|
+
leftoverRefs(item, schemas, found);
|
|
249305
|
+
}
|
|
249306
|
+
} else if (node !== null && typeof node === "object") {
|
|
249307
|
+
for (const [key, value] of Object.entries(node)) {
|
|
249308
|
+
if (key === "$ref" && typeof value === "string" && value.startsWith(SCHEMA_REF_PREFIX) && !found.has(value)) {
|
|
249309
|
+
const schema = schemas[value.slice(SCHEMA_REF_PREFIX.length)];
|
|
249310
|
+
found.set(value, schema);
|
|
249311
|
+
leftoverRefs(schema, schemas, found);
|
|
249312
|
+
} else {
|
|
249313
|
+
leftoverRefs(value, schemas, found);
|
|
249314
|
+
}
|
|
249315
|
+
}
|
|
249316
|
+
}
|
|
249317
|
+
return found;
|
|
249318
|
+
}
|
|
249319
|
+
var SCHEMA_DATA_KEYS = new Set([
|
|
249320
|
+
"example",
|
|
249321
|
+
"examples",
|
|
249322
|
+
"default",
|
|
249323
|
+
"enum",
|
|
249324
|
+
"const"
|
|
249325
|
+
]);
|
|
249326
|
+
var DOCS_CALLOUT = /<(Info|Note|Tip|Check|Warning)>([\s\S]*?)<\/\1>/g;
|
|
249327
|
+
var RELATIVE_LINK = /\[([^\]]+)\]\(\/[^)]*\)/g;
|
|
249328
|
+
function cleanText(text) {
|
|
249329
|
+
return text.replace(DOCS_CALLOUT, (_, kind, body) => kind === "Warning" ? `Warning: ${body}` : body).replace(RELATIVE_LINK, "$1");
|
|
249330
|
+
}
|
|
249331
|
+
function slimSchema(node, isPropertyMap = false) {
|
|
249332
|
+
if (Array.isArray(node)) {
|
|
249333
|
+
return node.map((item) => slimSchema(item));
|
|
249334
|
+
}
|
|
249335
|
+
if (node === null || typeof node !== "object") {
|
|
249336
|
+
return node;
|
|
249337
|
+
}
|
|
249338
|
+
const entries = Object.entries(node);
|
|
249339
|
+
if (isPropertyMap) {
|
|
249340
|
+
return Object.fromEntries(entries.map(([name, value]) => [name, slimSchema(value)]));
|
|
249341
|
+
}
|
|
249342
|
+
const slim = {};
|
|
249343
|
+
for (const [key, value] of entries) {
|
|
249344
|
+
if (key === "title" && typeof value === "string") {
|
|
249345
|
+
continue;
|
|
249346
|
+
}
|
|
249347
|
+
slim[key] = SCHEMA_DATA_KEYS.has(key) ? value : key === "properties" ? slimSchema(value, true) : key === "description" && typeof value === "string" ? cleanText(value) : slimSchema(value);
|
|
249348
|
+
}
|
|
249349
|
+
const { anyOf, ...rest } = slim;
|
|
249350
|
+
const nullable = Array.isArray(anyOf) && anyOf.length === 2 ? nullableType(anyOf) : undefined;
|
|
249351
|
+
return nullable ? { type: [nullable, "null"], ...rest } : slim;
|
|
249352
|
+
}
|
|
249353
|
+
function nullableType(variants) {
|
|
249354
|
+
const types = variants.map((variant) => variant !== null && typeof variant === "object" && Object.keys(variant).length === 1 && typeof variant.type === "string" ? variant.type : undefined);
|
|
249355
|
+
if (types.includes(undefined) || !types.includes("null")) {
|
|
249356
|
+
return;
|
|
249357
|
+
}
|
|
249358
|
+
return types.find((type) => type !== "null");
|
|
249359
|
+
}
|
|
249360
|
+
function getOperationContract(spec, op) {
|
|
249361
|
+
const schemas = spec.components?.schemas ?? {};
|
|
249362
|
+
const inline = (node) => node === undefined ? null : slimSchema(inlineRefs(node, schemas));
|
|
249363
|
+
const responses = Object.entries(op.operation.responses ?? {}).flatMap(([status, response]) => {
|
|
249364
|
+
const parsed = ResponseObjectSchema.safeParse(response);
|
|
249365
|
+
return parsed.success ? [[status, parsed.data]] : [];
|
|
249366
|
+
});
|
|
249367
|
+
const success = responses.filter(([status]) => status.startsWith("2")).sort(([a], [b]) => a.localeCompare(b)).map(([, response]) => bodyOf(response).schema).find(Boolean);
|
|
249368
|
+
const errors = responses.filter(([status, response]) => !status.startsWith("2") && response.description !== FRAMEWORK_VALIDATION_ERROR);
|
|
249369
|
+
const requestBody = bodyOf(op.operation.requestBody);
|
|
249370
|
+
const contract = {
|
|
249371
|
+
endpoint: op.endpoint,
|
|
249372
|
+
method: op.method,
|
|
249373
|
+
path: op.path,
|
|
249374
|
+
summary: op.summary,
|
|
249375
|
+
description: cleanText(op.description),
|
|
249376
|
+
parameters: (op.operation.parameters ?? []).flatMap((parameter) => {
|
|
249377
|
+
const parsed = ParameterSchema.safeParse(parameter);
|
|
249378
|
+
if (!parsed.success) {
|
|
249379
|
+
return [];
|
|
249380
|
+
}
|
|
249381
|
+
const { name, in: location2, required, schema, description } = parsed.data;
|
|
249382
|
+
const inSchema = schema !== null && typeof schema === "object" && "description" in schema;
|
|
249383
|
+
return [
|
|
249384
|
+
{
|
|
249385
|
+
name,
|
|
249386
|
+
in: location2,
|
|
249387
|
+
required: required ?? false,
|
|
249388
|
+
schema: inline(schema ?? {}),
|
|
249389
|
+
...description && !inSchema ? { description: cleanText(description) } : {},
|
|
249390
|
+
..."example" in parsed.data ? { example: parsed.data.example } : {}
|
|
249391
|
+
}
|
|
249392
|
+
];
|
|
249393
|
+
}),
|
|
249394
|
+
...requestBody.contentType && requestBody.contentType !== "application/json" ? { requestBodyContentType: requestBody.contentType } : {},
|
|
249395
|
+
requestBodySchema: inline(requestBody.schema),
|
|
249396
|
+
responseSchema: inline(success),
|
|
249397
|
+
errors: Object.fromEntries(errors.map(([status, response]) => [
|
|
249398
|
+
status,
|
|
249399
|
+
cleanText(response.description ?? "")
|
|
249400
|
+
]))
|
|
249401
|
+
};
|
|
249402
|
+
const refs = leftoverRefs(contract, schemas);
|
|
249403
|
+
return {
|
|
249404
|
+
...contract,
|
|
249405
|
+
...refs.size > 0 ? {
|
|
249406
|
+
refs: Object.fromEntries([...refs].map(([ref, schema]) => [ref, slimSchema(schema)]))
|
|
249407
|
+
} : {}
|
|
249408
|
+
};
|
|
249409
|
+
}
|
|
249410
|
+
// src/core/api-spec/grep.ts
|
|
249411
|
+
function grepOperations(spec, operations, pattern, options = {}) {
|
|
249412
|
+
const regex = new RegExp(pattern, options.ignoreCase ? "i" : "");
|
|
249413
|
+
return operations.filter((op) => regex.test(JSON.stringify(getOperationContract(spec, op)))).slice(0, options.limit ?? 20).map(toOperationSummary);
|
|
249414
|
+
}
|
|
249238
249415
|
// src/core/api-spec/operations.ts
|
|
249239
249416
|
var PERSONAL_ACCESS_TOKEN_SCHEME = "PersonalAccessTokenAuth";
|
|
249240
249417
|
var READ_ONLY_SCOPE = "read_only";
|
|
@@ -249248,14 +249425,33 @@ function parameterText(operation) {
|
|
|
249248
249425
|
return parsed.success ? [parsed.data.name, parsed.data.description ?? ""] : [];
|
|
249249
249426
|
}).join(" ");
|
|
249250
249427
|
}
|
|
249428
|
+
function mergeParameters(shared, own) {
|
|
249429
|
+
if (!shared?.length) {
|
|
249430
|
+
return own;
|
|
249431
|
+
}
|
|
249432
|
+
const key = (parameter) => {
|
|
249433
|
+
const parsed = ParameterSchema.safeParse(parameter);
|
|
249434
|
+
return parsed.success ? `${parsed.data.in}:${parsed.data.name}` : undefined;
|
|
249435
|
+
};
|
|
249436
|
+
const ownKeys = new Set((own ?? []).map(key));
|
|
249437
|
+
return [
|
|
249438
|
+
...shared.filter((parameter) => !ownKeys.has(key(parameter))),
|
|
249439
|
+
...own ?? []
|
|
249440
|
+
];
|
|
249441
|
+
}
|
|
249251
249442
|
function listOperations(spec) {
|
|
249252
249443
|
return Object.entries(spec.paths).flatMap(([path, item]) => HTTP_METHODS.flatMap((method) => {
|
|
249253
|
-
const
|
|
249254
|
-
if (!
|
|
249444
|
+
const declared = item[method];
|
|
249445
|
+
if (!declared) {
|
|
249255
249446
|
return [];
|
|
249256
249447
|
}
|
|
249448
|
+
const operation = {
|
|
249449
|
+
...declared,
|
|
249450
|
+
parameters: mergeParameters(item.parameters, declared.parameters)
|
|
249451
|
+
};
|
|
249257
249452
|
return [
|
|
249258
249453
|
{
|
|
249454
|
+
endpoint: `${method.toUpperCase()} ${path}`,
|
|
249259
249455
|
method: method.toUpperCase(),
|
|
249260
249456
|
path,
|
|
249261
249457
|
summary: operation.summary ?? "",
|
|
@@ -249275,16 +249471,8 @@ function segmentPattern(segment) {
|
|
|
249275
249471
|
const source = segment.split(/(\{[^}]+\})/).map((part) => part.startsWith("{") ? "[^/]+" : part.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")).join("");
|
|
249276
249472
|
return new RegExp(`^${source}$`);
|
|
249277
249473
|
}
|
|
249278
|
-
function
|
|
249279
|
-
return
|
|
249280
|
-
}
|
|
249281
|
-
function compareSpecificity(a, b) {
|
|
249282
|
-
for (let i = 0;i < a.length; i++) {
|
|
249283
|
-
if (a[i] !== b[i]) {
|
|
249284
|
-
return (b[i] ?? 0) - (a[i] ?? 0);
|
|
249285
|
-
}
|
|
249286
|
-
}
|
|
249287
|
-
return 0;
|
|
249474
|
+
function literalSegments(path) {
|
|
249475
|
+
return pathSegments(path).map((segment) => segment.includes("{") ? "0" : "1").join("");
|
|
249288
249476
|
}
|
|
249289
249477
|
function matchOperation(operations, method, concretePath) {
|
|
249290
249478
|
const upperMethod = method.toUpperCase();
|
|
@@ -249296,65 +249484,50 @@ function matchOperation(operations, method, concretePath) {
|
|
|
249296
249484
|
const template = pathSegments(op.path);
|
|
249297
249485
|
return template.length === segments.length && template.every((part, i) => segmentPattern(part).test(segments[i] ?? ""));
|
|
249298
249486
|
});
|
|
249299
|
-
return candidates.sort((a, b) =>
|
|
249487
|
+
return candidates.sort((a, b) => literalSegments(b.path).localeCompare(literalSegments(a.path)))[0];
|
|
249300
249488
|
}
|
|
249301
|
-
|
|
249302
|
-
|
|
249303
|
-
|
|
249304
|
-
|
|
249305
|
-
|
|
249306
|
-
return;
|
|
249307
|
-
}
|
|
249308
|
-
if (value === null || typeof value !== "object") {
|
|
249309
|
-
return;
|
|
249310
|
-
}
|
|
249311
|
-
for (const [key, child] of Object.entries(value)) {
|
|
249312
|
-
if (key === "$ref" && typeof child === "string" && !found.has(child)) {
|
|
249313
|
-
const target = resolvePointer(spec, child);
|
|
249314
|
-
found.set(child, target);
|
|
249315
|
-
collectRefs(target, spec, found);
|
|
249316
|
-
} else {
|
|
249317
|
-
collectRefs(child, spec, found);
|
|
249318
|
-
}
|
|
249319
|
-
}
|
|
249320
|
-
}
|
|
249321
|
-
function resolvePointer(spec, ref) {
|
|
249322
|
-
if (!ref.startsWith("#/")) {
|
|
249489
|
+
// src/core/api-spec/request.ts
|
|
249490
|
+
var MAX_ERROR_BODY_CHARS = 4000;
|
|
249491
|
+
async function readBody(response) {
|
|
249492
|
+
try {
|
|
249493
|
+
const text = (await response.clone().text()).trim();
|
|
249494
|
+
return text.length > MAX_ERROR_BODY_CHARS ? `${text.slice(0, MAX_ERROR_BODY_CHARS)}…` : text || undefined;
|
|
249495
|
+
} catch {
|
|
249323
249496
|
return;
|
|
249324
249497
|
}
|
|
249325
|
-
return ref.slice(2).split("/").map((part) => part.replace(/~1/g, "/").replace(/~0/g, "~")).reduce((node, part) => node !== null && typeof node === "object" ? node[part] : undefined, spec);
|
|
249326
|
-
}
|
|
249327
|
-
function getOperationContract(spec, op) {
|
|
249328
|
-
const { parameters, requestBody, responses } = op.operation;
|
|
249329
|
-
const refs = new Map;
|
|
249330
|
-
collectRefs({ parameters, requestBody, responses }, spec, refs);
|
|
249331
|
-
return {
|
|
249332
|
-
method: op.method,
|
|
249333
|
-
path: op.path,
|
|
249334
|
-
summary: op.summary,
|
|
249335
|
-
description: op.description,
|
|
249336
|
-
readOnly: op.readOnly,
|
|
249337
|
-
parameters: parameters ?? [],
|
|
249338
|
-
requestBody: requestBody ?? null,
|
|
249339
|
-
responses: responses ?? {},
|
|
249340
|
-
refs: Object.fromEntries(refs)
|
|
249341
|
-
};
|
|
249342
249498
|
}
|
|
249343
|
-
// src/core/api-spec/request.ts
|
|
249344
249499
|
async function sendApiRequest(method, path, body) {
|
|
249345
249500
|
try {
|
|
249346
249501
|
const response = await base44Client(path.replace(/^\/+/, ""), {
|
|
249347
249502
|
method,
|
|
249348
249503
|
body,
|
|
249349
|
-
headers: body === undefined ? {} : { "Content-Type": "application/json" }
|
|
249504
|
+
headers: body === undefined ? {} : { "Content-Type": "application/json" },
|
|
249505
|
+
timeout: false
|
|
249350
249506
|
});
|
|
249351
|
-
return
|
|
249507
|
+
return {
|
|
249508
|
+
status: response.status,
|
|
249509
|
+
contentType: response.headers.get("content-type") ?? "",
|
|
249510
|
+
body: new Uint8Array(await response.arrayBuffer())
|
|
249511
|
+
};
|
|
249352
249512
|
} catch (error) {
|
|
249353
|
-
|
|
249513
|
+
const apiError = await ApiError.fromHttpError(error, `calling ${method} ${path}`);
|
|
249514
|
+
const raw = error instanceof HTTPError ? await readBody(error.response) : undefined;
|
|
249515
|
+
throw redactedApiError(apiError, raw, method, path);
|
|
249354
249516
|
}
|
|
249355
249517
|
}
|
|
249518
|
+
function redactedApiError(apiError, raw, method, path) {
|
|
249519
|
+
const message = raw && apiError.statusCode !== undefined ? `Error calling ${method} ${path.split("?", 1)[0]}: HTTP ${apiError.statusCode}` : apiError.message;
|
|
249520
|
+
return new ApiError(message, {
|
|
249521
|
+
statusCode: apiError.statusCode,
|
|
249522
|
+
requestUrl: apiError.requestUrl?.split("?", 1)[0],
|
|
249523
|
+
requestMethod: apiError.requestMethod,
|
|
249524
|
+
requestId: apiError.requestId,
|
|
249525
|
+
hints: apiError.hints,
|
|
249526
|
+
details: raw ? [`Response body: ${raw}`] : apiError.details
|
|
249527
|
+
});
|
|
249528
|
+
}
|
|
249356
249529
|
// src/core/api-spec/spec.ts
|
|
249357
|
-
import { stat as stat3 } from "node:fs/promises";
|
|
249530
|
+
import { rename, stat as stat3 } from "node:fs/promises";
|
|
249358
249531
|
import { join as join22 } from "node:path";
|
|
249359
249532
|
var SPEC_CACHE_TTL_MS = 60 * 60 * 1000;
|
|
249360
249533
|
function getSpecCachePath(apiUrl = getBase44ApiUrl()) {
|
|
@@ -249377,17 +249550,24 @@ function parseSpec(text) {
|
|
|
249377
249550
|
}
|
|
249378
249551
|
return result.data;
|
|
249379
249552
|
}
|
|
249553
|
+
var SPEC_DOWNLOAD_TIMEOUT_MS = 60000;
|
|
249380
249554
|
async function readFreshCache(path) {
|
|
249381
249555
|
try {
|
|
249382
249556
|
const { mtimeMs } = await stat3(path);
|
|
249383
|
-
|
|
249557
|
+
if (!isSpecCacheFresh(mtimeMs)) {
|
|
249558
|
+
return null;
|
|
249559
|
+
}
|
|
249560
|
+
const text = await readTextFile(path);
|
|
249561
|
+
return { text, spec: parseSpec(text) };
|
|
249384
249562
|
} catch {
|
|
249385
249563
|
return null;
|
|
249386
249564
|
}
|
|
249387
249565
|
}
|
|
249388
249566
|
async function downloadSpec() {
|
|
249389
249567
|
try {
|
|
249390
|
-
const response = await base44Client.get("api/openapi.json"
|
|
249568
|
+
const response = await base44Client.get("api/openapi.json", {
|
|
249569
|
+
timeout: SPEC_DOWNLOAD_TIMEOUT_MS
|
|
249570
|
+
});
|
|
249391
249571
|
return await response.text();
|
|
249392
249572
|
} catch (error) {
|
|
249393
249573
|
throw await ApiError.fromHttpError(error, "fetching the API spec");
|
|
@@ -249397,29 +249577,19 @@ async function loadSpec(options = {}) {
|
|
|
249397
249577
|
const path = getSpecCachePath();
|
|
249398
249578
|
const cached = options.refresh ? null : await readFreshCache(path);
|
|
249399
249579
|
if (cached !== null) {
|
|
249400
|
-
return
|
|
249580
|
+
return cached;
|
|
249401
249581
|
}
|
|
249402
249582
|
const text = await downloadSpec();
|
|
249403
249583
|
const spec = parseSpec(text);
|
|
249404
|
-
|
|
249584
|
+
const partial = `${path}.${process.pid}.tmp`;
|
|
249585
|
+
await writeFile(partial, text);
|
|
249586
|
+
await rename(partial, path);
|
|
249405
249587
|
return { text, spec };
|
|
249406
249588
|
}
|
|
249407
249589
|
// src/cli/commands/api/shared.ts
|
|
249590
|
+
import { fstatSync } from "node:fs";
|
|
249408
249591
|
function formatJson(value) {
|
|
249409
|
-
return
|
|
249410
|
-
`;
|
|
249411
|
-
}
|
|
249412
|
-
function formatResponseBody(text) {
|
|
249413
|
-
if (!text) {
|
|
249414
|
-
return "";
|
|
249415
|
-
}
|
|
249416
|
-
try {
|
|
249417
|
-
return formatJson(JSON.parse(text));
|
|
249418
|
-
} catch {
|
|
249419
|
-
return text.endsWith(`
|
|
249420
|
-
`) ? text : `${text}
|
|
249421
|
-
`;
|
|
249422
|
-
}
|
|
249592
|
+
return toJsonStdout(value, { compact: !process.stdout.isTTY });
|
|
249423
249593
|
}
|
|
249424
249594
|
function parseLimit(value) {
|
|
249425
249595
|
if (value === undefined) {
|
|
@@ -249431,20 +249601,84 @@ function parseLimit(value) {
|
|
|
249431
249601
|
}
|
|
249432
249602
|
return n;
|
|
249433
249603
|
}
|
|
249604
|
+
var READ_ONLY_FILTER_HELP = "Only read-only operations";
|
|
249434
249605
|
var REFRESH_OPTION_HELP = "Fetch the API spec again instead of using the cached copy (kept 1 hour)";
|
|
249435
249606
|
function loadSpecTask({ runTask }, refresh) {
|
|
249436
249607
|
return runTask("Loading the API spec", () => loadSpec({ refresh }), {
|
|
249437
249608
|
successMessage: "Loaded the API spec"
|
|
249438
249609
|
});
|
|
249439
249610
|
}
|
|
249611
|
+
function operationsInArea(operations, area) {
|
|
249612
|
+
const areas = groupByArea(operations);
|
|
249613
|
+
const inArea = areas.get(area);
|
|
249614
|
+
if (!inArea) {
|
|
249615
|
+
throw new InvalidInputError(`Unknown API area: ${area}`, {
|
|
249616
|
+
details: [`Areas: ${[...areas.keys()].join(", ")}`],
|
|
249617
|
+
hints: [{ message: "List the areas", command: "base44 api catalog" }]
|
|
249618
|
+
});
|
|
249619
|
+
}
|
|
249620
|
+
return inArea;
|
|
249621
|
+
}
|
|
249622
|
+
function isPipedStdin() {
|
|
249623
|
+
try {
|
|
249624
|
+
const stats = fstatSync(0);
|
|
249625
|
+
return stats.isFIFO() || stats.isFile();
|
|
249626
|
+
} catch {
|
|
249627
|
+
return false;
|
|
249628
|
+
}
|
|
249629
|
+
}
|
|
249630
|
+
async function readRequestBody(flag, log) {
|
|
249631
|
+
if (flag === "@-") {
|
|
249632
|
+
return readStdin("--body @-", { trim: false });
|
|
249633
|
+
}
|
|
249634
|
+
if (flag?.startsWith("@")) {
|
|
249635
|
+
return readTextFile(flag.slice(1));
|
|
249636
|
+
}
|
|
249637
|
+
if (flag === undefined && isPipedStdin()) {
|
|
249638
|
+
log.warn("stdin is ignored; pass --body @- to send it as the body.");
|
|
249639
|
+
}
|
|
249640
|
+
return flag;
|
|
249641
|
+
}
|
|
249642
|
+
function reportedFetchCommand(method, path, options) {
|
|
249643
|
+
return {
|
|
249644
|
+
name: "api fetch",
|
|
249645
|
+
args: [method, path.split("?", 1)[0] ?? ""],
|
|
249646
|
+
options: {
|
|
249647
|
+
...options,
|
|
249648
|
+
...options.body === undefined ? {} : { body: "[not reported]" }
|
|
249649
|
+
}
|
|
249650
|
+
};
|
|
249651
|
+
}
|
|
249652
|
+
|
|
249653
|
+
// src/cli/commands/api/catalog.ts
|
|
249654
|
+
async function catalogAction(ctx, area, options) {
|
|
249655
|
+
const { spec } = await loadSpecTask(ctx, options.refresh);
|
|
249656
|
+
const operations = listOperations(spec);
|
|
249657
|
+
const readOnly = (ops) => options.readOnly ? ops.filter((op) => op.readOnly) : ops;
|
|
249658
|
+
if (area === undefined) {
|
|
249659
|
+
return { stdout: formatJson(catalogIndex(readOnly(operations))) };
|
|
249660
|
+
}
|
|
249661
|
+
const inArea = readOnly(operationsInArea(operations, area));
|
|
249662
|
+
return { stdout: formatJson(areaListing(area, inArea)) };
|
|
249663
|
+
}
|
|
249664
|
+
function getApiCatalogCommand() {
|
|
249665
|
+
return new Base44Command("catalog", {
|
|
249666
|
+
requireAuth: false,
|
|
249667
|
+
requireAppContext: false
|
|
249668
|
+
}).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);
|
|
249669
|
+
}
|
|
249440
249670
|
|
|
249441
249671
|
// src/cli/commands/api/fetch.ts
|
|
249442
|
-
async function findOperation(ctx, method, path, refresh) {
|
|
249672
|
+
async function findOperation(ctx, method, path, { refresh, flag }) {
|
|
249443
249673
|
const { spec } = await loadSpecTask(ctx, refresh);
|
|
249444
249674
|
const op = matchOperation(listOperations(spec), method, path);
|
|
249445
249675
|
if (!op) {
|
|
249446
249676
|
throw new InvalidInputError(`No operation in the API spec matches ${method} ${path}.`, {
|
|
249447
249677
|
hints: [
|
|
249678
|
+
{
|
|
249679
|
+
message: "The cached spec may predate this route; fetch it again",
|
|
249680
|
+
command: `base44 api fetch ${method} ${path} ${flag} --refresh`
|
|
249681
|
+
},
|
|
249448
249682
|
{
|
|
249449
249683
|
message: "Find the operation and its path template",
|
|
249450
249684
|
command: 'base44 api search "<what you want to do>"'
|
|
@@ -249454,43 +249688,87 @@ async function findOperation(ctx, method, path, refresh) {
|
|
|
249454
249688
|
}
|
|
249455
249689
|
return { spec, op };
|
|
249456
249690
|
}
|
|
249691
|
+
var TEXT_CONTENT_TYPES = [
|
|
249692
|
+
"json",
|
|
249693
|
+
"text/",
|
|
249694
|
+
"xml",
|
|
249695
|
+
"javascript",
|
|
249696
|
+
"x-www-form-urlencoded"
|
|
249697
|
+
];
|
|
249698
|
+
function isText(contentType) {
|
|
249699
|
+
return !contentType || TEXT_CONTENT_TYPES.some((hint) => contentType.toLowerCase().includes(hint));
|
|
249700
|
+
}
|
|
249701
|
+
async function formatResponse({ status, contentType, body }, output, jsonMode) {
|
|
249702
|
+
if (output !== undefined) {
|
|
249703
|
+
await writeFile(output, body);
|
|
249704
|
+
return formatJson({ status, contentType, bytes: body.length, output });
|
|
249705
|
+
}
|
|
249706
|
+
if (body.length === 0) {
|
|
249707
|
+
return formatJson({ status });
|
|
249708
|
+
}
|
|
249709
|
+
if (!isText(contentType)) {
|
|
249710
|
+
return formatJson({
|
|
249711
|
+
status,
|
|
249712
|
+
contentType,
|
|
249713
|
+
bytes: body.length,
|
|
249714
|
+
note: "Binary body not printed; add --output <file> to save it."
|
|
249715
|
+
});
|
|
249716
|
+
}
|
|
249717
|
+
const text = new TextDecoder().decode(body);
|
|
249718
|
+
try {
|
|
249719
|
+
return formatJson(JSON.parse(text));
|
|
249720
|
+
} catch {
|
|
249721
|
+
if (jsonMode) {
|
|
249722
|
+
return formatJson({ status, contentType, body: text });
|
|
249723
|
+
}
|
|
249724
|
+
return text.endsWith(`
|
|
249725
|
+
`) ? text : `${text}
|
|
249726
|
+
`;
|
|
249727
|
+
}
|
|
249728
|
+
}
|
|
249457
249729
|
async function fetchAction(ctx, methodArg, path, options, command) {
|
|
249458
249730
|
if (!methodArg || !path) {
|
|
249459
249731
|
if (options.help) {
|
|
249460
|
-
|
|
249732
|
+
const usage = command.helpInformation();
|
|
249733
|
+
return { stdout: ctx.jsonMode ? formatJson({ usage }) : usage };
|
|
249461
249734
|
}
|
|
249462
249735
|
throw new InvalidInputError("Provide a method and a path, e.g. GET /api/apps.");
|
|
249463
249736
|
}
|
|
249464
249737
|
const method = methodArg.toUpperCase();
|
|
249465
|
-
if (!HTTP_METHODS.some((m) => m.toUpperCase() === method)) {
|
|
249466
|
-
throw new InvalidInputError(`Unknown HTTP method: ${methodArg}`);
|
|
249467
|
-
}
|
|
249468
|
-
if (!path.startsWith("/")) {
|
|
249469
|
-
throw new InvalidInputError(`The path must start with "/", got ${path}.`);
|
|
249470
|
-
}
|
|
249471
249738
|
if (options.help) {
|
|
249472
|
-
const { spec, op } = await findOperation(ctx, method, path,
|
|
249739
|
+
const { spec, op } = await findOperation(ctx, method, path, {
|
|
249740
|
+
refresh: options.refresh,
|
|
249741
|
+
flag: "--help"
|
|
249742
|
+
});
|
|
249473
249743
|
return { stdout: formatJson(getOperationContract(spec, op)) };
|
|
249474
249744
|
}
|
|
249475
249745
|
if (options.readOnly) {
|
|
249476
|
-
const { op } = await findOperation(ctx, method, path,
|
|
249746
|
+
const { op } = await findOperation(ctx, method, path, {
|
|
249747
|
+
refresh: options.refresh,
|
|
249748
|
+
flag: "--read-only"
|
|
249749
|
+
});
|
|
249477
249750
|
if (!op.readOnly) {
|
|
249478
249751
|
throw new InvalidInputError(`Refused under --read-only: ${op.method} ${op.path} is not a read-only operation. Nothing was sent.`);
|
|
249479
249752
|
}
|
|
249480
249753
|
}
|
|
249481
|
-
|
|
249482
|
-
|
|
249483
|
-
readStdin: () => readStdin("--body @-", { trim: false })
|
|
249754
|
+
ctx.errorReporter.setContext({
|
|
249755
|
+
command: reportedFetchCommand(method, path, { ...options })
|
|
249484
249756
|
});
|
|
249485
249757
|
await ensureAuth(ctx);
|
|
249486
|
-
const
|
|
249487
|
-
|
|
249758
|
+
const body = await readRequestBody(options.body, ctx.log);
|
|
249759
|
+
const response = await ctx.runTask(`Calling ${method} ${path}`, () => sendApiRequest(method, path, body), {
|
|
249760
|
+
successMessage: `Called ${method} ${path}`,
|
|
249761
|
+
errorMessage: "Request failed"
|
|
249762
|
+
});
|
|
249763
|
+
return {
|
|
249764
|
+
stdout: await formatResponse(response, options.output, ctx.jsonMode)
|
|
249765
|
+
};
|
|
249488
249766
|
}
|
|
249489
249767
|
function getApiFetchCommand() {
|
|
249490
249768
|
return new Base44Command("fetch", {
|
|
249491
249769
|
requireAuth: false,
|
|
249492
249770
|
requireAppContext: false
|
|
249493
|
-
}).description("Call a Base44 API operation
|
|
249771
|
+
}).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);
|
|
249494
249772
|
}
|
|
249495
249773
|
|
|
249496
249774
|
// src/cli/commands/api/grep.ts
|
|
@@ -249505,7 +249783,14 @@ async function grepAction(ctx, pattern, options) {
|
|
|
249505
249783
|
const limit = parseLimit(options.limit);
|
|
249506
249784
|
assertValidRegex(pattern);
|
|
249507
249785
|
const { spec } = await loadSpecTask(ctx, options.refresh);
|
|
249508
|
-
|
|
249786
|
+
let operations = listOperations(spec);
|
|
249787
|
+
if (options.area !== undefined) {
|
|
249788
|
+
operations = operationsInArea(operations, options.area);
|
|
249789
|
+
}
|
|
249790
|
+
if (options.readOnly) {
|
|
249791
|
+
operations = operations.filter((op) => op.readOnly);
|
|
249792
|
+
}
|
|
249793
|
+
const hits = grepOperations(spec, operations, pattern, {
|
|
249509
249794
|
ignoreCase: options.ignoreCase,
|
|
249510
249795
|
limit
|
|
249511
249796
|
});
|
|
@@ -249515,7 +249800,7 @@ function getApiGrepCommand() {
|
|
|
249515
249800
|
return new Base44Command("grep", {
|
|
249516
249801
|
requireAuth: false,
|
|
249517
249802
|
requireAppContext: false
|
|
249518
|
-
}).description("Search the
|
|
249803
|
+
}).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);
|
|
249519
249804
|
}
|
|
249520
249805
|
|
|
249521
249806
|
// src/cli/commands/api/search.ts
|
|
@@ -249532,12 +249817,12 @@ function getApiSearchCommand() {
|
|
|
249532
249817
|
return new Base44Command("search", {
|
|
249533
249818
|
requireAuth: false,
|
|
249534
249819
|
requireAppContext: false
|
|
249535
|
-
}).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",
|
|
249820
|
+
}).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);
|
|
249536
249821
|
}
|
|
249537
249822
|
|
|
249538
249823
|
// src/cli/commands/api/index.ts
|
|
249539
249824
|
function getApiCommand() {
|
|
249540
|
-
return new Command2("api").description("Search and call any public Base44 API operation").addCommand(getApiSearchCommand()).addCommand(getApiGrepCommand()).addCommand(getApiFetchCommand());
|
|
249825
|
+
return new Command2("api").description("Search and call any public Base44 API operation").addCommand(getApiCatalogCommand()).addCommand(getApiSearchCommand()).addCommand(getApiGrepCommand()).addCommand(getApiFetchCommand());
|
|
249541
249826
|
}
|
|
249542
249827
|
|
|
249543
249828
|
// src/cli/commands/auth/password-login.ts
|
|
@@ -254901,6 +255186,12 @@ var deno2 = Object.freeze({
|
|
|
254901
255186
|
});
|
|
254902
255187
|
globalThis.Deno = deno2;
|
|
254903
255188
|
globalThis.Buffer = Buffer2;
|
|
255189
|
+
try {
|
|
255190
|
+
new AsyncLocalStorage().enterWith(void 0);
|
|
255191
|
+
} catch {
|
|
255192
|
+
AsyncLocalStorage.prototype.enterWith = () => {
|
|
255193
|
+
};
|
|
255194
|
+
}
|
|
254904
255195
|
function getRegisteredHandler() {
|
|
254905
255196
|
return registeredHandler;
|
|
254906
255197
|
}
|
|
@@ -257866,7 +258157,7 @@ var TELEMETRY_PATCH = [
|
|
|
257866
258157
|
var TELEMETRY_STORE_FIELDS = "reqId: crypto.randomUUID(), respondedAt: null, inflight: new Map(), inflightTotal: 0, hadRejection: false, hadNonOk: false, logBudget: 5";
|
|
257867
258158
|
|
|
257868
258159
|
// ../functions-compiler/src/version.ts
|
|
257869
|
-
var COMPILER_VERSION = "0.1.
|
|
258160
|
+
var COMPILER_VERSION = "0.1.8";
|
|
257870
258161
|
|
|
257871
258162
|
// ../functions-compiler/src/worker-entry.ts
|
|
257872
258163
|
function denoShimSource() {
|
|
@@ -262069,7 +262360,7 @@ var nativeEnumType = ZodNativeEnum.create;
|
|
|
262069
262360
|
var promiseType = ZodPromise.create;
|
|
262070
262361
|
var effectsType = ZodEffects.create;
|
|
262071
262362
|
var optionalType = ZodOptional2.create;
|
|
262072
|
-
var
|
|
262363
|
+
var nullableType2 = ZodNullable2.create;
|
|
262073
262364
|
var preprocessType = ZodEffects.createWithPreprocess;
|
|
262074
262365
|
var pipelineType = ZodPipeline.create;
|
|
262075
262366
|
// ../functions-compiler/src/contracts.ts
|
|
@@ -262490,6 +262781,174 @@ function runtimeVirtualPlugin() {
|
|
|
262490
262781
|
};
|
|
262491
262782
|
}
|
|
262492
262783
|
|
|
262784
|
+
// ../functions-compiler/src/esbuild/ws-native-virtual.ts
|
|
262785
|
+
var NAMESPACE4 = "base44-ws-native";
|
|
262786
|
+
var WS_SPECIFIER = /^(npm:)?ws(@[^/]+)?$/;
|
|
262787
|
+
var ADAPTER = `"use strict";
|
|
262788
|
+
const toBuffer = (value) => (globalThis.Buffer ? globalThis.Buffer.from(value) : value);
|
|
262789
|
+
const READY_STATES = ["CONNECTING", "OPEN", "CLOSING", "CLOSED"];
|
|
262790
|
+
const later = (fn, ...args) => queueMicrotask(() => fn(...args));
|
|
262791
|
+
const upgradeHeaders = (options) => {
|
|
262792
|
+
const headers = new Headers(options?.headers);
|
|
262793
|
+
for (const name of headers.keys()) if (name !== "user-agent") return headers;
|
|
262794
|
+
return null;
|
|
262795
|
+
};
|
|
262796
|
+
class WebSocket {
|
|
262797
|
+
static CONNECTING = 0;
|
|
262798
|
+
static OPEN = 1;
|
|
262799
|
+
static CLOSING = 2;
|
|
262800
|
+
static CLOSED = 3;
|
|
262801
|
+
#socket = null;
|
|
262802
|
+
#state = 0;
|
|
262803
|
+
#url;
|
|
262804
|
+
#closeRequested = null;
|
|
262805
|
+
#terminated = false;
|
|
262806
|
+
#listeners = new Map();
|
|
262807
|
+
constructor(address, protocols, options) {
|
|
262808
|
+
if (protocols && typeof protocols === "object" && !Array.isArray(protocols)) {
|
|
262809
|
+
options = protocols;
|
|
262810
|
+
protocols = undefined;
|
|
262811
|
+
}
|
|
262812
|
+
this.#url = String(address);
|
|
262813
|
+
const headers = upgradeHeaders(options);
|
|
262814
|
+
if (headers) {
|
|
262815
|
+
this.#upgrade(headers, protocols);
|
|
262816
|
+
} else {
|
|
262817
|
+
this.#attach(new globalThis.WebSocket(this.#url, protocols));
|
|
262818
|
+
}
|
|
262819
|
+
}
|
|
262820
|
+
get readyState() {
|
|
262821
|
+
if (this.#terminated) return 3;
|
|
262822
|
+
return this.#socket ? this.#socket.readyState : this.#state;
|
|
262823
|
+
}
|
|
262824
|
+
get url() { return this.#url; }
|
|
262825
|
+
get protocol() { return this.#socket ? this.#socket.protocol ?? "" : ""; }
|
|
262826
|
+
on(name, listener) { return this.#add(name, listener, false); }
|
|
262827
|
+
addListener(name, listener) { return this.#add(name, listener, false); }
|
|
262828
|
+
once(name, listener) { return this.#add(name, listener, true); }
|
|
262829
|
+
off(name, listener) { return this.removeListener(name, listener); }
|
|
262830
|
+
removeListener(name, listener) {
|
|
262831
|
+
const listeners = this.#listeners.get(name);
|
|
262832
|
+
if (listeners) this.#listeners.set(name, listeners.filter((entry) => entry.listener !== listener));
|
|
262833
|
+
return this;
|
|
262834
|
+
}
|
|
262835
|
+
removeAllListeners(name) {
|
|
262836
|
+
if (name === undefined) this.#listeners.clear();
|
|
262837
|
+
else this.#listeners.delete(name);
|
|
262838
|
+
return this;
|
|
262839
|
+
}
|
|
262840
|
+
emit(name, ...args) {
|
|
262841
|
+
const listeners = this.#listeners.get(name) ?? [];
|
|
262842
|
+
this.#listeners.set(name, listeners.filter((entry) => !entry.once));
|
|
262843
|
+
for (const entry of listeners) entry.listener.apply(this, args);
|
|
262844
|
+
return listeners.length > 0;
|
|
262845
|
+
}
|
|
262846
|
+
send(data, options, callback) {
|
|
262847
|
+
const done = typeof options === "function" ? options : callback;
|
|
262848
|
+
try {
|
|
262849
|
+
if (!this.#socket) {
|
|
262850
|
+
throw new Error("WebSocket is not open: readyState " + this.#state + " (" + READY_STATES[this.#state] + ")");
|
|
262851
|
+
}
|
|
262852
|
+
this.#socket.send(data);
|
|
262853
|
+
done?.();
|
|
262854
|
+
} catch (error) {
|
|
262855
|
+
if (!done) throw error;
|
|
262856
|
+
done(error);
|
|
262857
|
+
}
|
|
262858
|
+
}
|
|
262859
|
+
close(code, reason) {
|
|
262860
|
+
if (this.#socket) this.#socket.close(code, reason);
|
|
262861
|
+
else if (this.#state === 0) {
|
|
262862
|
+
// Upgrade still in flight: close as soon as it lands.
|
|
262863
|
+
this.#closeRequested = [code, reason];
|
|
262864
|
+
this.#state = 2;
|
|
262865
|
+
}
|
|
262866
|
+
}
|
|
262867
|
+
// \`ws\` tears the connection down at once. workerd has no abrupt close, so the
|
|
262868
|
+
// socket is closed normally and "close" is reported now, not on the reply.
|
|
262869
|
+
terminate() {
|
|
262870
|
+
if (this.#terminated || this.readyState === 3) return;
|
|
262871
|
+
this.#terminated = true;
|
|
262872
|
+
if (this.#socket) {
|
|
262873
|
+
try { this.#socket.close(); } catch {}
|
|
262874
|
+
} else {
|
|
262875
|
+
// Upgrade still in flight: close it on arrival, without an "open".
|
|
262876
|
+
this.#closeRequested = [];
|
|
262877
|
+
this.#state = 3;
|
|
262878
|
+
}
|
|
262879
|
+
later(() => this.emit("close", 1006, toBuffer("")));
|
|
262880
|
+
}
|
|
262881
|
+
#attach(socket) {
|
|
262882
|
+
this.#socket = socket;
|
|
262883
|
+
try { socket.binaryType = "arraybuffer"; } catch {}
|
|
262884
|
+
socket.addEventListener("open", () => this.emit("open"));
|
|
262885
|
+
socket.addEventListener("message", (event) => {
|
|
262886
|
+
const isBinary = typeof event.data !== "string";
|
|
262887
|
+
this.emit("message", toBuffer(isBinary ? new Uint8Array(event.data) : event.data), isBinary);
|
|
262888
|
+
});
|
|
262889
|
+
socket.addEventListener("error", (event) => this.emit("error", event.error ?? new Error(event.message || "WebSocket error")));
|
|
262890
|
+
socket.addEventListener("close", (event) => {
|
|
262891
|
+
if (!this.#terminated) this.emit("close", event.code, toBuffer(event.reason ?? ""));
|
|
262892
|
+
});
|
|
262893
|
+
}
|
|
262894
|
+
#upgrade(headers, protocols) {
|
|
262895
|
+
headers.set("Upgrade", "websocket");
|
|
262896
|
+
if (protocols) headers.set("Sec-WebSocket-Protocol", [].concat(protocols).join(", "));
|
|
262897
|
+
const httpUrl = this.#url.replace(/^ws(s?):/i, "http$1:");
|
|
262898
|
+
const fail = (error) => {
|
|
262899
|
+
this.#state = 3;
|
|
262900
|
+
if (this.#terminated) return;
|
|
262901
|
+
this.emit("error", error);
|
|
262902
|
+
this.emit("close", 1006, toBuffer(""));
|
|
262903
|
+
};
|
|
262904
|
+
// Two-argument then(): an exception from an "open" listener must not be
|
|
262905
|
+
// reported as a failed upgrade.
|
|
262906
|
+
fetch(httpUrl, { headers }).then((response) => {
|
|
262907
|
+
const socket = response.webSocket;
|
|
262908
|
+
if (!socket) {
|
|
262909
|
+
response.body?.cancel();
|
|
262910
|
+
return fail(new Error("Unexpected server response: " + response.status));
|
|
262911
|
+
}
|
|
262912
|
+
socket.accept();
|
|
262913
|
+
this.#attach(socket);
|
|
262914
|
+
if (this.#closeRequested) return socket.close(...this.#closeRequested);
|
|
262915
|
+
// accept() opens the socket without dispatching an "open" event.
|
|
262916
|
+
this.emit("open");
|
|
262917
|
+
}, fail);
|
|
262918
|
+
}
|
|
262919
|
+
#add(name, listener, once) {
|
|
262920
|
+
const listeners = this.#listeners.get(name) ?? [];
|
|
262921
|
+
listeners.push({ listener, once });
|
|
262922
|
+
this.#listeners.set(name, listeners);
|
|
262923
|
+
return this;
|
|
262924
|
+
}
|
|
262925
|
+
}
|
|
262926
|
+
class WebSocketServer {
|
|
262927
|
+
constructor() {
|
|
262928
|
+
throw new Error("ws WebSocketServer is not available in Base44 functions: a function can open WebSocket connections but cannot listen for them.");
|
|
262929
|
+
}
|
|
262930
|
+
}
|
|
262931
|
+
module.exports = WebSocket;
|
|
262932
|
+
module.exports.WebSocket = WebSocket;
|
|
262933
|
+
module.exports.WebSocketServer = WebSocketServer;
|
|
262934
|
+
module.exports.default = WebSocket;
|
|
262935
|
+
`;
|
|
262936
|
+
function wsNativeVirtualPlugin() {
|
|
262937
|
+
return {
|
|
262938
|
+
name: "base44-ws-native",
|
|
262939
|
+
setup(build) {
|
|
262940
|
+
build.onResolve({ filter: WS_SPECIFIER }, () => ({
|
|
262941
|
+
path: "ws",
|
|
262942
|
+
namespace: NAMESPACE4
|
|
262943
|
+
}));
|
|
262944
|
+
build.onLoad({ filter: /.*/, namespace: NAMESPACE4 }, () => ({
|
|
262945
|
+
contents: ADAPTER,
|
|
262946
|
+
loader: "js"
|
|
262947
|
+
}));
|
|
262948
|
+
}
|
|
262949
|
+
};
|
|
262950
|
+
}
|
|
262951
|
+
|
|
262493
262952
|
// ../functions-compiler/src/deno-bundle.ts
|
|
262494
262953
|
async function bundleToModule(prepared, nodeModulesDir = "none") {
|
|
262495
262954
|
const dir = await mkdtemp(path21.join(tmpdir2(), "b44-bundle-"));
|
|
@@ -262513,6 +262972,7 @@ async function bundleToModule(prepared, nodeModulesDir = "none") {
|
|
|
262513
262972
|
sourcemap: false,
|
|
262514
262973
|
logLevel: "silent",
|
|
262515
262974
|
plugins: [
|
|
262975
|
+
wsNativeVirtualPlugin(),
|
|
262516
262976
|
nodeBuiltinRequirePlugin(),
|
|
262517
262977
|
userFilesPlugin(prepared.files, prepared.entry),
|
|
262518
262978
|
privateDataSourcesVirtualPlugin(),
|
|
@@ -272902,4 +273362,4 @@ export {
|
|
|
272902
273362
|
runCLI
|
|
272903
273363
|
};
|
|
272904
273364
|
|
|
272905
|
-
//# debugId=
|
|
273365
|
+
//# debugId=FFB0D67D7951621A64756E2164756E21
|