agent-shim 8.28.0 → 8.29.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.cjs +1667 -50
- package/dist/index.cjs +179 -137
- package/dist/index.mjs +178 -136
- package/dist/types/index.d.ts +12 -10
- package/package.json +2 -1
package/dist/cli.cjs
CHANGED
|
@@ -18556,10 +18556,10 @@ var require_mock_utils = __commonJS({
|
|
|
18556
18556
|
}
|
|
18557
18557
|
}
|
|
18558
18558
|
function buildHeadersFromArray(headers) {
|
|
18559
|
-
const
|
|
18559
|
+
const clone3 = headers.slice();
|
|
18560
18560
|
const entries = [];
|
|
18561
|
-
for (let index = 0; index <
|
|
18562
|
-
entries.push([
|
|
18561
|
+
for (let index = 0; index < clone3.length; index += 2) {
|
|
18562
|
+
entries.push([clone3[index], clone3[index + 1]]);
|
|
18563
18563
|
}
|
|
18564
18564
|
return Object.fromEntries(entries);
|
|
18565
18565
|
}
|
|
@@ -48113,9 +48113,9 @@ function compileValidator(schema, parser) {
|
|
|
48113
48113
|
function compile(schema, options) {
|
|
48114
48114
|
try {
|
|
48115
48115
|
const parser = compileFn(schema);
|
|
48116
|
-
const
|
|
48117
|
-
|
|
48118
|
-
return
|
|
48116
|
+
const clone3 = withParser(schema, parser);
|
|
48117
|
+
clone3._zod.bag.validator = compileValidator(schema, parser);
|
|
48118
|
+
return clone3;
|
|
48119
48119
|
} catch (err) {
|
|
48120
48120
|
if (options?.strict)
|
|
48121
48121
|
throw err;
|
|
@@ -48126,7 +48126,7 @@ function withParser(schema, parser) {
|
|
|
48126
48126
|
if (isRecursiveSchema(schema)) {
|
|
48127
48127
|
throw new ZodCompileUnsupportedError("a schema whose subtree contains a reference cycle");
|
|
48128
48128
|
}
|
|
48129
|
-
const
|
|
48129
|
+
const clone3 = clone(schema);
|
|
48130
48130
|
const liveRun = schema._zod.run;
|
|
48131
48131
|
const originalRun = liveRun.__originalRun ?? liveRun;
|
|
48132
48132
|
const wrapped = (payload, ctx) => {
|
|
@@ -48146,12 +48146,12 @@ function withParser(schema, parser) {
|
|
|
48146
48146
|
return originalRun(payload, ctx);
|
|
48147
48147
|
};
|
|
48148
48148
|
wrapped.__originalRun = originalRun;
|
|
48149
|
-
|
|
48150
|
-
|
|
48151
|
-
|
|
48149
|
+
clone3._zod.bag.fallbackRun = originalRun;
|
|
48150
|
+
clone3._zod.bag.validator = parser;
|
|
48151
|
+
clone3._zod.run = wrapped;
|
|
48152
48152
|
if (!liveRun.__originalRun)
|
|
48153
|
-
installCompiledUserMethods(
|
|
48154
|
-
return
|
|
48153
|
+
installCompiledUserMethods(clone3, schema, parser);
|
|
48154
|
+
return clone3;
|
|
48155
48155
|
}
|
|
48156
48156
|
function installCompiledUserMethods(target, source, parser) {
|
|
48157
48157
|
const targetAny = target;
|
|
@@ -61796,7 +61796,7 @@ function registerIdentityCommand(program2, deps) {
|
|
|
61796
61796
|
// package.json
|
|
61797
61797
|
var package_default = {
|
|
61798
61798
|
name: "agent-shim",
|
|
61799
|
-
version: "8.
|
|
61799
|
+
version: "8.29.0",
|
|
61800
61800
|
description: "A profile manager and launcher for Claude Code that lets one person run multiple logins from one machine while controlling what gets shared between them.",
|
|
61801
61801
|
license: "MIT",
|
|
61802
61802
|
author: "Joseph Mearman <joseph@mearman.co.uk>",
|
|
@@ -61847,6 +61847,7 @@ var package_default = {
|
|
|
61847
61847
|
dependencies: {
|
|
61848
61848
|
"@clack/prompts": "^1.8.0",
|
|
61849
61849
|
"@orpc/client": "1.15.4",
|
|
61850
|
+
"@orpc/openapi": "1.15.4",
|
|
61850
61851
|
"@orpc/server": "1.15.4",
|
|
61851
61852
|
commander: "^15.0.0",
|
|
61852
61853
|
cosmiconfig: "^10.0.1",
|
|
@@ -68796,6 +68797,21 @@ function parseEmptyableJSON(text2) {
|
|
|
68796
68797
|
function stringifyJSON(value2) {
|
|
68797
68798
|
return JSON.stringify(value2);
|
|
68798
68799
|
}
|
|
68800
|
+
function findDeepMatches(check2, payload, segments = [], maps = [], values = []) {
|
|
68801
|
+
if (check2(payload)) {
|
|
68802
|
+
maps.push(segments);
|
|
68803
|
+
values.push(payload);
|
|
68804
|
+
} else if (Array.isArray(payload)) {
|
|
68805
|
+
payload.forEach((v, i2) => {
|
|
68806
|
+
findDeepMatches(check2, v, [...segments, i2], maps, values);
|
|
68807
|
+
});
|
|
68808
|
+
} else if (isObject4(payload)) {
|
|
68809
|
+
for (const key in payload) {
|
|
68810
|
+
findDeepMatches(check2, payload[key], [...segments, key], maps, values);
|
|
68811
|
+
}
|
|
68812
|
+
}
|
|
68813
|
+
return { maps, values };
|
|
68814
|
+
}
|
|
68799
68815
|
function getConstructor(value2) {
|
|
68800
68816
|
if (!isTypescriptObject(value2)) {
|
|
68801
68817
|
return null;
|
|
@@ -68812,6 +68828,22 @@ function isObject4(value2) {
|
|
|
68812
68828
|
function isTypescriptObject(value2) {
|
|
68813
68829
|
return !!value2 && (typeof value2 === "object" || typeof value2 === "function");
|
|
68814
68830
|
}
|
|
68831
|
+
function clone2(value2) {
|
|
68832
|
+
if (Array.isArray(value2)) {
|
|
68833
|
+
return value2.map(clone2);
|
|
68834
|
+
}
|
|
68835
|
+
if (isObject4(value2)) {
|
|
68836
|
+
const result = {};
|
|
68837
|
+
for (const key in value2) {
|
|
68838
|
+
result[key] = clone2(value2[key]);
|
|
68839
|
+
}
|
|
68840
|
+
for (const sym of Object.getOwnPropertySymbols(value2)) {
|
|
68841
|
+
result[sym] = clone2(value2[sym]);
|
|
68842
|
+
}
|
|
68843
|
+
return result;
|
|
68844
|
+
}
|
|
68845
|
+
return value2;
|
|
68846
|
+
}
|
|
68815
68847
|
function setOwn(object2, key, value2) {
|
|
68816
68848
|
if (key === "__proto__") {
|
|
68817
68849
|
Object.defineProperty(object2, key, {
|
|
@@ -70894,6 +70926,12 @@ function eventIterator(yields, returns) {
|
|
|
70894
70926
|
}
|
|
70895
70927
|
};
|
|
70896
70928
|
}
|
|
70929
|
+
function getEventIteratorSchemaDetails(schema) {
|
|
70930
|
+
if (schema === void 0) {
|
|
70931
|
+
return void 0;
|
|
70932
|
+
}
|
|
70933
|
+
return schema["~standard"][EVENT_ITERATOR_DETAILS_SYMBOL];
|
|
70934
|
+
}
|
|
70897
70935
|
|
|
70898
70936
|
// node_modules/.pnpm/@orpc+server@1.15.4/node_modules/@orpc/server/dist/shared/server.DEBcqOjg.mjs
|
|
70899
70937
|
var LAZY_SYMBOL = /* @__PURE__ */ Symbol("ORPC_LAZY_SYMBOL");
|
|
@@ -71234,6 +71272,19 @@ function traverseContractProcedures(options, callback, lazyOptions = []) {
|
|
|
71234
71272
|
}
|
|
71235
71273
|
return lazyOptions;
|
|
71236
71274
|
}
|
|
71275
|
+
async function resolveContractProcedures(options, callback) {
|
|
71276
|
+
const pending = [options];
|
|
71277
|
+
for (const options2 of pending) {
|
|
71278
|
+
const lazyOptions = traverseContractProcedures(options2, callback);
|
|
71279
|
+
for (const options3 of lazyOptions) {
|
|
71280
|
+
const { default: router } = await unlazy(options3.router);
|
|
71281
|
+
pending.push({
|
|
71282
|
+
router,
|
|
71283
|
+
path: options3.path
|
|
71284
|
+
});
|
|
71285
|
+
}
|
|
71286
|
+
}
|
|
71287
|
+
}
|
|
71237
71288
|
function createContractedProcedure(procedure, contract) {
|
|
71238
71289
|
return new Procedure({
|
|
71239
71290
|
...procedure["~orpc"],
|
|
@@ -71628,6 +71679,1173 @@ var RPCLink = class extends StandardRPCLink {
|
|
|
71628
71679
|
}
|
|
71629
71680
|
};
|
|
71630
71681
|
|
|
71682
|
+
// node_modules/.pnpm/@orpc+openapi-client@1.15.4/node_modules/@orpc/openapi-client/dist/shared/openapi-client.t9fCAe3x.mjs
|
|
71683
|
+
var StandardBracketNotationSerializer = class {
|
|
71684
|
+
maxArrayIndex;
|
|
71685
|
+
constructor(options = {}) {
|
|
71686
|
+
this.maxArrayIndex = options.maxBracketNotationArrayIndex ?? 9999;
|
|
71687
|
+
}
|
|
71688
|
+
serialize(data, segments = [], result = []) {
|
|
71689
|
+
if (Array.isArray(data)) {
|
|
71690
|
+
data.forEach((item, i2) => {
|
|
71691
|
+
this.serialize(item, [...segments, i2], result);
|
|
71692
|
+
});
|
|
71693
|
+
} else if (isObject4(data)) {
|
|
71694
|
+
for (const key in data) {
|
|
71695
|
+
this.serialize(data[key], [...segments, key], result);
|
|
71696
|
+
}
|
|
71697
|
+
} else {
|
|
71698
|
+
result.push([this.stringifyPath(segments), data]);
|
|
71699
|
+
}
|
|
71700
|
+
return result;
|
|
71701
|
+
}
|
|
71702
|
+
deserialize(serialized) {
|
|
71703
|
+
if (serialized.length === 0) {
|
|
71704
|
+
return {};
|
|
71705
|
+
}
|
|
71706
|
+
const arrayPushStyles = /* @__PURE__ */ new WeakSet();
|
|
71707
|
+
const ref = { value: [] };
|
|
71708
|
+
for (const [path46, value2] of serialized) {
|
|
71709
|
+
const segments = this.parsePath(path46);
|
|
71710
|
+
let currentRef = ref;
|
|
71711
|
+
let nextSegment = "value";
|
|
71712
|
+
segments.forEach((segment, i2) => {
|
|
71713
|
+
if (!Array.isArray(currentRef[nextSegment]) && !isObject4(currentRef[nextSegment])) {
|
|
71714
|
+
currentRef[nextSegment] = [];
|
|
71715
|
+
}
|
|
71716
|
+
if (i2 !== segments.length - 1) {
|
|
71717
|
+
if (Array.isArray(currentRef[nextSegment]) && !isValidArrayIndex(segment, this.maxArrayIndex)) {
|
|
71718
|
+
if (arrayPushStyles.has(currentRef[nextSegment])) {
|
|
71719
|
+
arrayPushStyles.delete(currentRef[nextSegment]);
|
|
71720
|
+
currentRef[nextSegment] = pushStyleArrayToObject(currentRef[nextSegment]);
|
|
71721
|
+
} else {
|
|
71722
|
+
currentRef[nextSegment] = arrayToObject(currentRef[nextSegment]);
|
|
71723
|
+
}
|
|
71724
|
+
}
|
|
71725
|
+
} else {
|
|
71726
|
+
if (Array.isArray(currentRef[nextSegment])) {
|
|
71727
|
+
if (segment === "") {
|
|
71728
|
+
if (currentRef[nextSegment].length && !arrayPushStyles.has(currentRef[nextSegment])) {
|
|
71729
|
+
currentRef[nextSegment] = arrayToObject(currentRef[nextSegment]);
|
|
71730
|
+
}
|
|
71731
|
+
} else {
|
|
71732
|
+
if (arrayPushStyles.has(currentRef[nextSegment])) {
|
|
71733
|
+
arrayPushStyles.delete(currentRef[nextSegment]);
|
|
71734
|
+
currentRef[nextSegment] = pushStyleArrayToObject(currentRef[nextSegment]);
|
|
71735
|
+
} else if (!isValidArrayIndex(segment, this.maxArrayIndex)) {
|
|
71736
|
+
currentRef[nextSegment] = arrayToObject(currentRef[nextSegment]);
|
|
71737
|
+
}
|
|
71738
|
+
}
|
|
71739
|
+
}
|
|
71740
|
+
}
|
|
71741
|
+
currentRef = currentRef[nextSegment];
|
|
71742
|
+
nextSegment = segment;
|
|
71743
|
+
});
|
|
71744
|
+
if (Array.isArray(currentRef) && nextSegment === "") {
|
|
71745
|
+
arrayPushStyles.add(currentRef);
|
|
71746
|
+
currentRef.push(value2);
|
|
71747
|
+
} else if (nextSegment in currentRef) {
|
|
71748
|
+
if (Array.isArray(currentRef[nextSegment])) {
|
|
71749
|
+
currentRef[nextSegment].push(value2);
|
|
71750
|
+
} else {
|
|
71751
|
+
currentRef[nextSegment] = [currentRef[nextSegment], value2];
|
|
71752
|
+
}
|
|
71753
|
+
} else {
|
|
71754
|
+
currentRef[nextSegment] = value2;
|
|
71755
|
+
}
|
|
71756
|
+
}
|
|
71757
|
+
return ref.value;
|
|
71758
|
+
}
|
|
71759
|
+
stringifyPath(segments) {
|
|
71760
|
+
return segments.map((segment) => {
|
|
71761
|
+
return segment.toString().replace(/[\\[\]]/g, (match) => {
|
|
71762
|
+
switch (match) {
|
|
71763
|
+
case "\\":
|
|
71764
|
+
return "\\\\";
|
|
71765
|
+
case "[":
|
|
71766
|
+
return "\\[";
|
|
71767
|
+
case "]":
|
|
71768
|
+
return "\\]";
|
|
71769
|
+
/* v8 ignore next 2 */
|
|
71770
|
+
default:
|
|
71771
|
+
return match;
|
|
71772
|
+
}
|
|
71773
|
+
});
|
|
71774
|
+
}).reduce((result, segment, i2) => {
|
|
71775
|
+
if (i2 === 0) {
|
|
71776
|
+
return segment;
|
|
71777
|
+
}
|
|
71778
|
+
return `${result}[${segment}]`;
|
|
71779
|
+
}, "");
|
|
71780
|
+
}
|
|
71781
|
+
parsePath(path46) {
|
|
71782
|
+
const segments = [];
|
|
71783
|
+
let inBrackets = false;
|
|
71784
|
+
let currentSegment = "";
|
|
71785
|
+
let backslashCount = 0;
|
|
71786
|
+
for (let i2 = 0; i2 < path46.length; i2++) {
|
|
71787
|
+
const char = path46[i2];
|
|
71788
|
+
const nextChar = path46[i2 + 1];
|
|
71789
|
+
if (inBrackets && char === "]" && (nextChar === void 0 || nextChar === "[") && backslashCount % 2 === 0) {
|
|
71790
|
+
if (nextChar === void 0) {
|
|
71791
|
+
inBrackets = false;
|
|
71792
|
+
}
|
|
71793
|
+
segments.push(currentSegment);
|
|
71794
|
+
currentSegment = "";
|
|
71795
|
+
i2++;
|
|
71796
|
+
} else if (segments.length === 0 && char === "[" && backslashCount % 2 === 0) {
|
|
71797
|
+
inBrackets = true;
|
|
71798
|
+
segments.push(currentSegment);
|
|
71799
|
+
currentSegment = "";
|
|
71800
|
+
} else if (char === "\\") {
|
|
71801
|
+
backslashCount++;
|
|
71802
|
+
} else {
|
|
71803
|
+
currentSegment += "\\".repeat(backslashCount / 2) + char;
|
|
71804
|
+
backslashCount = 0;
|
|
71805
|
+
}
|
|
71806
|
+
}
|
|
71807
|
+
return inBrackets || segments.length === 0 ? [path46] : segments;
|
|
71808
|
+
}
|
|
71809
|
+
};
|
|
71810
|
+
function isValidArrayIndex(value2, maxIndex) {
|
|
71811
|
+
return /^0$|^[1-9]\d*$/.test(value2) && Number(value2) <= maxIndex;
|
|
71812
|
+
}
|
|
71813
|
+
function arrayToObject(array2) {
|
|
71814
|
+
const obj = new NullProtoObj();
|
|
71815
|
+
array2.forEach((item, i2) => {
|
|
71816
|
+
obj[i2] = item;
|
|
71817
|
+
});
|
|
71818
|
+
return obj;
|
|
71819
|
+
}
|
|
71820
|
+
function pushStyleArrayToObject(array2) {
|
|
71821
|
+
const obj = new NullProtoObj();
|
|
71822
|
+
obj[""] = array2.length === 1 ? array2[0] : array2;
|
|
71823
|
+
return obj;
|
|
71824
|
+
}
|
|
71825
|
+
|
|
71826
|
+
// node_modules/.pnpm/@orpc+openapi-client@1.15.4/node_modules/@orpc/openapi-client/dist/shared/openapi-client.B2Q9qU5m.mjs
|
|
71827
|
+
var StandardOpenAPIJsonSerializer = class {
|
|
71828
|
+
customSerializers;
|
|
71829
|
+
constructor(options = {}) {
|
|
71830
|
+
this.customSerializers = options.customJsonSerializers ?? [];
|
|
71831
|
+
}
|
|
71832
|
+
serialize(data, hasBlobRef = { value: false }) {
|
|
71833
|
+
for (const custom2 of this.customSerializers) {
|
|
71834
|
+
if (custom2.condition(data)) {
|
|
71835
|
+
const result = this.serialize(custom2.serialize(data), hasBlobRef);
|
|
71836
|
+
return result;
|
|
71837
|
+
}
|
|
71838
|
+
}
|
|
71839
|
+
if (data instanceof Blob) {
|
|
71840
|
+
hasBlobRef.value = true;
|
|
71841
|
+
return [data, hasBlobRef.value];
|
|
71842
|
+
}
|
|
71843
|
+
if (data instanceof Set) {
|
|
71844
|
+
return this.serialize(Array.from(data), hasBlobRef);
|
|
71845
|
+
}
|
|
71846
|
+
if (data instanceof Map) {
|
|
71847
|
+
return this.serialize(Array.from(data.entries()), hasBlobRef);
|
|
71848
|
+
}
|
|
71849
|
+
if (Array.isArray(data)) {
|
|
71850
|
+
const json2 = data.map((v) => v === void 0 ? null : this.serialize(v, hasBlobRef)[0]);
|
|
71851
|
+
return [json2, hasBlobRef.value];
|
|
71852
|
+
}
|
|
71853
|
+
if (isObject4(data)) {
|
|
71854
|
+
const json2 = {};
|
|
71855
|
+
for (const k in data) {
|
|
71856
|
+
if (k === "toJSON" && typeof data[k] === "function") {
|
|
71857
|
+
continue;
|
|
71858
|
+
}
|
|
71859
|
+
json2[k] = this.serialize(data[k], hasBlobRef)[0];
|
|
71860
|
+
}
|
|
71861
|
+
return [json2, hasBlobRef.value];
|
|
71862
|
+
}
|
|
71863
|
+
if (typeof data === "bigint" || data instanceof RegExp || data instanceof URL) {
|
|
71864
|
+
return [data.toString(), hasBlobRef.value];
|
|
71865
|
+
}
|
|
71866
|
+
if (data instanceof Date) {
|
|
71867
|
+
return [Number.isNaN(data.getTime()) ? null : data.toISOString(), hasBlobRef.value];
|
|
71868
|
+
}
|
|
71869
|
+
if (Number.isNaN(data)) {
|
|
71870
|
+
return [null, hasBlobRef.value];
|
|
71871
|
+
}
|
|
71872
|
+
return [data, hasBlobRef.value];
|
|
71873
|
+
}
|
|
71874
|
+
};
|
|
71875
|
+
function standardizeHTTPPath(path46) {
|
|
71876
|
+
return `/${path46.replace(/\/{2,}/g, "/").replace(/^\/|\/$/g, "")}`;
|
|
71877
|
+
}
|
|
71878
|
+
function getDynamicParams(path46) {
|
|
71879
|
+
return path46 ? standardizeHTTPPath(path46).match(/\/\{[^}]+\}/g)?.map((v) => ({
|
|
71880
|
+
raw: v,
|
|
71881
|
+
name: v.match(/\{\+?([^}]+)\}/)[1]
|
|
71882
|
+
})) : void 0;
|
|
71883
|
+
}
|
|
71884
|
+
var StandardOpenAPISerializer = class {
|
|
71885
|
+
constructor(jsonSerializer, bracketNotation) {
|
|
71886
|
+
this.jsonSerializer = jsonSerializer;
|
|
71887
|
+
this.bracketNotation = bracketNotation;
|
|
71888
|
+
}
|
|
71889
|
+
serialize(data, options = {}) {
|
|
71890
|
+
if (isAsyncIteratorObject(data) && !options.outputFormat) {
|
|
71891
|
+
return mapEventIterator(data, {
|
|
71892
|
+
value: async (value2) => this.#serialize(value2, { outputFormat: "plain" }),
|
|
71893
|
+
error: async (e) => {
|
|
71894
|
+
return new ErrorEvent({
|
|
71895
|
+
data: this.#serialize(toORPCError(e).toJSON(), { outputFormat: "plain" }),
|
|
71896
|
+
cause: e
|
|
71897
|
+
});
|
|
71898
|
+
}
|
|
71899
|
+
});
|
|
71900
|
+
}
|
|
71901
|
+
return this.#serialize(data, options);
|
|
71902
|
+
}
|
|
71903
|
+
#serialize(data, options) {
|
|
71904
|
+
const [json2, hasBlob] = this.jsonSerializer.serialize(data);
|
|
71905
|
+
if (options.outputFormat === "plain") {
|
|
71906
|
+
return json2;
|
|
71907
|
+
}
|
|
71908
|
+
if (options.outputFormat === "URLSearchParams") {
|
|
71909
|
+
const params = new URLSearchParams();
|
|
71910
|
+
for (const [path46, value2] of this.bracketNotation.serialize(json2)) {
|
|
71911
|
+
if (typeof value2 === "string" || typeof value2 === "number" || typeof value2 === "boolean") {
|
|
71912
|
+
params.append(path46, value2.toString());
|
|
71913
|
+
}
|
|
71914
|
+
}
|
|
71915
|
+
return params;
|
|
71916
|
+
}
|
|
71917
|
+
if (json2 instanceof Blob || json2 === void 0 || !hasBlob) {
|
|
71918
|
+
return json2;
|
|
71919
|
+
}
|
|
71920
|
+
const form = new FormData();
|
|
71921
|
+
for (const [path46, value2] of this.bracketNotation.serialize(json2)) {
|
|
71922
|
+
if (typeof value2 === "string" || typeof value2 === "number" || typeof value2 === "boolean") {
|
|
71923
|
+
form.append(path46, value2.toString());
|
|
71924
|
+
} else if (value2 instanceof Blob) {
|
|
71925
|
+
form.append(path46, value2);
|
|
71926
|
+
}
|
|
71927
|
+
}
|
|
71928
|
+
return form;
|
|
71929
|
+
}
|
|
71930
|
+
deserialize(data) {
|
|
71931
|
+
if (data instanceof URLSearchParams || data instanceof FormData) {
|
|
71932
|
+
return this.bracketNotation.deserialize(Array.from(data.entries()));
|
|
71933
|
+
}
|
|
71934
|
+
if (isAsyncIteratorObject(data)) {
|
|
71935
|
+
return mapEventIterator(data, {
|
|
71936
|
+
value: async (value2) => value2,
|
|
71937
|
+
error: async (e) => {
|
|
71938
|
+
if (e instanceof ErrorEvent && isORPCErrorJson(e.data)) {
|
|
71939
|
+
return createORPCErrorFromJson(e.data, { cause: e });
|
|
71940
|
+
}
|
|
71941
|
+
return e;
|
|
71942
|
+
}
|
|
71943
|
+
});
|
|
71944
|
+
}
|
|
71945
|
+
return data;
|
|
71946
|
+
}
|
|
71947
|
+
};
|
|
71948
|
+
|
|
71949
|
+
// node_modules/.pnpm/json-schema-typed@8.0.2/node_modules/json-schema-typed/draft_2020_12.js
|
|
71950
|
+
var ContentEncoding;
|
|
71951
|
+
(function(ContentEncoding2) {
|
|
71952
|
+
ContentEncoding2["7bit"] = "7bit";
|
|
71953
|
+
ContentEncoding2["8bit"] = "8bit";
|
|
71954
|
+
ContentEncoding2["Base64"] = "base64";
|
|
71955
|
+
ContentEncoding2["Binary"] = "binary";
|
|
71956
|
+
ContentEncoding2["IETFToken"] = "ietf-token";
|
|
71957
|
+
ContentEncoding2["QuotedPrintable"] = "quoted-printable";
|
|
71958
|
+
ContentEncoding2["XToken"] = "x-token";
|
|
71959
|
+
})(ContentEncoding || (ContentEncoding = {}));
|
|
71960
|
+
var Format;
|
|
71961
|
+
(function(Format2) {
|
|
71962
|
+
Format2["Date"] = "date";
|
|
71963
|
+
Format2["DateTime"] = "date-time";
|
|
71964
|
+
Format2["Duration"] = "duration";
|
|
71965
|
+
Format2["Email"] = "email";
|
|
71966
|
+
Format2["Hostname"] = "hostname";
|
|
71967
|
+
Format2["IDNEmail"] = "idn-email";
|
|
71968
|
+
Format2["IDNHostname"] = "idn-hostname";
|
|
71969
|
+
Format2["IPv4"] = "ipv4";
|
|
71970
|
+
Format2["IPv6"] = "ipv6";
|
|
71971
|
+
Format2["IRI"] = "iri";
|
|
71972
|
+
Format2["IRIReference"] = "iri-reference";
|
|
71973
|
+
Format2["JSONPointer"] = "json-pointer";
|
|
71974
|
+
Format2["JSONPointerURIFragment"] = "json-pointer-uri-fragment";
|
|
71975
|
+
Format2["RegEx"] = "regex";
|
|
71976
|
+
Format2["RelativeJSONPointer"] = "relative-json-pointer";
|
|
71977
|
+
Format2["Time"] = "time";
|
|
71978
|
+
Format2["URI"] = "uri";
|
|
71979
|
+
Format2["URIReference"] = "uri-reference";
|
|
71980
|
+
Format2["URITemplate"] = "uri-template";
|
|
71981
|
+
Format2["UUID"] = "uuid";
|
|
71982
|
+
})(Format || (Format = {}));
|
|
71983
|
+
var TypeName;
|
|
71984
|
+
(function(TypeName2) {
|
|
71985
|
+
TypeName2["Array"] = "array";
|
|
71986
|
+
TypeName2["Boolean"] = "boolean";
|
|
71987
|
+
TypeName2["Integer"] = "integer";
|
|
71988
|
+
TypeName2["Null"] = "null";
|
|
71989
|
+
TypeName2["Number"] = "number";
|
|
71990
|
+
TypeName2["Object"] = "object";
|
|
71991
|
+
TypeName2["String"] = "string";
|
|
71992
|
+
})(TypeName || (TypeName = {}));
|
|
71993
|
+
|
|
71994
|
+
// node_modules/.pnpm/@orpc+openapi@1.15.4/node_modules/@orpc/openapi/dist/shared/openapi.BwdtJjDu.mjs
|
|
71995
|
+
var OPERATION_EXTENDER_SYMBOL = /* @__PURE__ */ Symbol("ORPC_OPERATION_EXTENDER");
|
|
71996
|
+
function getCustomOpenAPIOperation(o) {
|
|
71997
|
+
return o[OPERATION_EXTENDER_SYMBOL];
|
|
71998
|
+
}
|
|
71999
|
+
function applyCustomOpenAPIOperation(operation, contract) {
|
|
72000
|
+
const operationCustoms = [];
|
|
72001
|
+
for (const errorItem of Object.values(contract["~orpc"].errorMap)) {
|
|
72002
|
+
const maybeExtender = errorItem ? getCustomOpenAPIOperation(errorItem) : void 0;
|
|
72003
|
+
if (maybeExtender) {
|
|
72004
|
+
operationCustoms.push(maybeExtender);
|
|
72005
|
+
}
|
|
72006
|
+
}
|
|
72007
|
+
if (isProcedure(contract)) {
|
|
72008
|
+
for (const middleware of contract["~orpc"].middlewares) {
|
|
72009
|
+
const maybeExtender = getCustomOpenAPIOperation(middleware);
|
|
72010
|
+
if (maybeExtender) {
|
|
72011
|
+
operationCustoms.push(maybeExtender);
|
|
72012
|
+
}
|
|
72013
|
+
}
|
|
72014
|
+
}
|
|
72015
|
+
let currentOperation = operation;
|
|
72016
|
+
for (const custom2 of operationCustoms) {
|
|
72017
|
+
if (typeof custom2 === "function") {
|
|
72018
|
+
currentOperation = custom2(currentOperation, contract);
|
|
72019
|
+
} else {
|
|
72020
|
+
currentOperation = {
|
|
72021
|
+
...currentOperation,
|
|
72022
|
+
...custom2
|
|
72023
|
+
};
|
|
72024
|
+
}
|
|
72025
|
+
}
|
|
72026
|
+
return currentOperation;
|
|
72027
|
+
}
|
|
72028
|
+
var LOGIC_KEYWORDS = [
|
|
72029
|
+
"$dynamicRef",
|
|
72030
|
+
"$ref",
|
|
72031
|
+
"additionalItems",
|
|
72032
|
+
"additionalProperties",
|
|
72033
|
+
"allOf",
|
|
72034
|
+
"anyOf",
|
|
72035
|
+
"const",
|
|
72036
|
+
"contains",
|
|
72037
|
+
"contentEncoding",
|
|
72038
|
+
"contentMediaType",
|
|
72039
|
+
"contentSchema",
|
|
72040
|
+
"dependencies",
|
|
72041
|
+
"dependentRequired",
|
|
72042
|
+
"dependentSchemas",
|
|
72043
|
+
"else",
|
|
72044
|
+
"enum",
|
|
72045
|
+
"exclusiveMaximum",
|
|
72046
|
+
"exclusiveMinimum",
|
|
72047
|
+
"format",
|
|
72048
|
+
"if",
|
|
72049
|
+
"items",
|
|
72050
|
+
"maxContains",
|
|
72051
|
+
"maximum",
|
|
72052
|
+
"maxItems",
|
|
72053
|
+
"maxLength",
|
|
72054
|
+
"maxProperties",
|
|
72055
|
+
"minContains",
|
|
72056
|
+
"minimum",
|
|
72057
|
+
"minItems",
|
|
72058
|
+
"minLength",
|
|
72059
|
+
"minProperties",
|
|
72060
|
+
"multipleOf",
|
|
72061
|
+
"not",
|
|
72062
|
+
"oneOf",
|
|
72063
|
+
"pattern",
|
|
72064
|
+
"patternProperties",
|
|
72065
|
+
"prefixItems",
|
|
72066
|
+
"properties",
|
|
72067
|
+
"propertyNames",
|
|
72068
|
+
"required",
|
|
72069
|
+
"then",
|
|
72070
|
+
"type",
|
|
72071
|
+
"unevaluatedItems",
|
|
72072
|
+
"unevaluatedProperties",
|
|
72073
|
+
"uniqueItems"
|
|
72074
|
+
];
|
|
72075
|
+
function isFileSchema(schema) {
|
|
72076
|
+
return isObject4(schema) && schema.type === "string" && typeof schema.contentMediaType === "string";
|
|
72077
|
+
}
|
|
72078
|
+
function isObjectSchema(schema) {
|
|
72079
|
+
return isObject4(schema) && schema.type === "object";
|
|
72080
|
+
}
|
|
72081
|
+
function isAnySchema(schema) {
|
|
72082
|
+
if (schema === true) {
|
|
72083
|
+
return true;
|
|
72084
|
+
}
|
|
72085
|
+
if (Object.keys(schema).filter((v) => schema[v] !== void 0).every((k) => !LOGIC_KEYWORDS.includes(k))) {
|
|
72086
|
+
return true;
|
|
72087
|
+
}
|
|
72088
|
+
return false;
|
|
72089
|
+
}
|
|
72090
|
+
function isNeverSchema(schema) {
|
|
72091
|
+
if (schema === false) {
|
|
72092
|
+
return true;
|
|
72093
|
+
}
|
|
72094
|
+
if (typeof schema === "object" && schema.not !== void 0) {
|
|
72095
|
+
if (schema.not === true) {
|
|
72096
|
+
return true;
|
|
72097
|
+
}
|
|
72098
|
+
if (typeof schema.not === "object" && Object.keys(schema.not).length === 0) {
|
|
72099
|
+
return true;
|
|
72100
|
+
}
|
|
72101
|
+
}
|
|
72102
|
+
return false;
|
|
72103
|
+
}
|
|
72104
|
+
function separateObjectSchema(schema, separatedProperties) {
|
|
72105
|
+
if (Object.keys(schema).some(
|
|
72106
|
+
(k) => !["type", "properties", "required", "additionalProperties"].includes(k) && LOGIC_KEYWORDS.includes(k) && schema[k] !== void 0
|
|
72107
|
+
)) {
|
|
72108
|
+
return [{ type: "object" }, schema];
|
|
72109
|
+
}
|
|
72110
|
+
const matched = { ...schema };
|
|
72111
|
+
const rest = { ...schema };
|
|
72112
|
+
matched.properties = separatedProperties.reduce((acc, key) => {
|
|
72113
|
+
const keySchema = schema.properties?.[key] ?? schema.additionalProperties;
|
|
72114
|
+
if (keySchema !== void 0) {
|
|
72115
|
+
acc[key] = keySchema;
|
|
72116
|
+
}
|
|
72117
|
+
return acc;
|
|
72118
|
+
}, {});
|
|
72119
|
+
if (Object.keys(matched.properties).length === 0) {
|
|
72120
|
+
matched.properties = void 0;
|
|
72121
|
+
}
|
|
72122
|
+
matched.required = schema.required?.filter((key) => separatedProperties.includes(key));
|
|
72123
|
+
if (matched.required?.length === 0) {
|
|
72124
|
+
matched.required = void 0;
|
|
72125
|
+
}
|
|
72126
|
+
matched.examples = schema.examples?.map((example) => {
|
|
72127
|
+
if (!isObject4(example)) {
|
|
72128
|
+
return example;
|
|
72129
|
+
}
|
|
72130
|
+
return Object.entries(example).reduce((acc, [key, value2]) => {
|
|
72131
|
+
if (separatedProperties.includes(key)) {
|
|
72132
|
+
acc[key] = value2;
|
|
72133
|
+
}
|
|
72134
|
+
return acc;
|
|
72135
|
+
}, {});
|
|
72136
|
+
});
|
|
72137
|
+
rest.properties = schema.properties && Object.entries(schema.properties).filter(([key]) => !separatedProperties.includes(key)).reduce((acc = {}, [key, value2]) => {
|
|
72138
|
+
acc[key] = value2;
|
|
72139
|
+
return acc;
|
|
72140
|
+
}, void 0);
|
|
72141
|
+
rest.required = schema.required?.filter((key) => !separatedProperties.includes(key));
|
|
72142
|
+
if (rest.required?.length === 0) {
|
|
72143
|
+
rest.required = void 0;
|
|
72144
|
+
}
|
|
72145
|
+
rest.examples = schema.examples?.map((example) => {
|
|
72146
|
+
if (!isObject4(example)) {
|
|
72147
|
+
return example;
|
|
72148
|
+
}
|
|
72149
|
+
return Object.entries(example).reduce((acc, [key, value2]) => {
|
|
72150
|
+
if (!separatedProperties.includes(key)) {
|
|
72151
|
+
acc[key] = value2;
|
|
72152
|
+
}
|
|
72153
|
+
return acc;
|
|
72154
|
+
}, {});
|
|
72155
|
+
});
|
|
72156
|
+
return [matched, rest];
|
|
72157
|
+
}
|
|
72158
|
+
function filterSchemaBranches(schema, check2, matches = []) {
|
|
72159
|
+
if (check2(schema)) {
|
|
72160
|
+
matches.push(schema);
|
|
72161
|
+
return [matches, void 0];
|
|
72162
|
+
}
|
|
72163
|
+
if (isObject4(schema)) {
|
|
72164
|
+
for (const keyword of ["anyOf", "oneOf"]) {
|
|
72165
|
+
if (schema[keyword] && Object.keys(schema).every(
|
|
72166
|
+
(k) => k === keyword || !LOGIC_KEYWORDS.includes(k)
|
|
72167
|
+
)) {
|
|
72168
|
+
const rest = schema[keyword].map((s) => filterSchemaBranches(s, check2, matches)[1]).filter((v) => !!v);
|
|
72169
|
+
if (rest.length === 1 && typeof rest[0] === "object") {
|
|
72170
|
+
return [matches, { ...schema, [keyword]: void 0, ...rest[0] }];
|
|
72171
|
+
}
|
|
72172
|
+
return [matches, { ...schema, [keyword]: rest }];
|
|
72173
|
+
}
|
|
72174
|
+
}
|
|
72175
|
+
}
|
|
72176
|
+
return [matches, schema];
|
|
72177
|
+
}
|
|
72178
|
+
function applySchemaOptionality(required2, schema) {
|
|
72179
|
+
if (required2) {
|
|
72180
|
+
return schema;
|
|
72181
|
+
}
|
|
72182
|
+
return {
|
|
72183
|
+
anyOf: [
|
|
72184
|
+
schema,
|
|
72185
|
+
{ not: {} }
|
|
72186
|
+
]
|
|
72187
|
+
};
|
|
72188
|
+
}
|
|
72189
|
+
function expandUnionSchema(schema) {
|
|
72190
|
+
if (typeof schema === "object") {
|
|
72191
|
+
for (const keyword of ["anyOf", "oneOf"]) {
|
|
72192
|
+
if (schema[keyword] && Object.keys(schema).every(
|
|
72193
|
+
(k) => k === keyword || !LOGIC_KEYWORDS.includes(k)
|
|
72194
|
+
)) {
|
|
72195
|
+
return schema[keyword].flatMap((s) => expandUnionSchema(s));
|
|
72196
|
+
}
|
|
72197
|
+
}
|
|
72198
|
+
}
|
|
72199
|
+
return [schema];
|
|
72200
|
+
}
|
|
72201
|
+
function expandArrayableSchema(schema) {
|
|
72202
|
+
const schemas = expandUnionSchema(schema);
|
|
72203
|
+
if (schemas.length !== 2) {
|
|
72204
|
+
return void 0;
|
|
72205
|
+
}
|
|
72206
|
+
const arraySchema = schemas.find(
|
|
72207
|
+
(s) => typeof s === "object" && s.type === "array" && Object.keys(s).filter((k) => LOGIC_KEYWORDS.includes(k)).every((k) => k === "type" || k === "items")
|
|
72208
|
+
);
|
|
72209
|
+
if (arraySchema === void 0) {
|
|
72210
|
+
return void 0;
|
|
72211
|
+
}
|
|
72212
|
+
const items1 = arraySchema.items;
|
|
72213
|
+
const items2 = schemas.find((s) => s !== arraySchema);
|
|
72214
|
+
if (stringifyJSON(items1) !== stringifyJSON(items2)) {
|
|
72215
|
+
return void 0;
|
|
72216
|
+
}
|
|
72217
|
+
return [items2, arraySchema];
|
|
72218
|
+
}
|
|
72219
|
+
var PRIMITIVE_SCHEMA_TYPES = /* @__PURE__ */ new Set([
|
|
72220
|
+
TypeName.String,
|
|
72221
|
+
TypeName.Number,
|
|
72222
|
+
TypeName.Integer,
|
|
72223
|
+
TypeName.Boolean,
|
|
72224
|
+
TypeName.Null
|
|
72225
|
+
]);
|
|
72226
|
+
function isPrimitiveSchema(schema) {
|
|
72227
|
+
return expandUnionSchema(schema).every((s) => {
|
|
72228
|
+
if (typeof s === "boolean") {
|
|
72229
|
+
return false;
|
|
72230
|
+
}
|
|
72231
|
+
if (typeof s.type === "string" && PRIMITIVE_SCHEMA_TYPES.has(s.type)) {
|
|
72232
|
+
return true;
|
|
72233
|
+
}
|
|
72234
|
+
if (s.const !== void 0) {
|
|
72235
|
+
return true;
|
|
72236
|
+
}
|
|
72237
|
+
return false;
|
|
72238
|
+
});
|
|
72239
|
+
}
|
|
72240
|
+
function toOpenAPIPath(path46) {
|
|
72241
|
+
return standardizeHTTPPath(path46).replace(/\/\{\+([^}]+)\}/g, "/{$1}");
|
|
72242
|
+
}
|
|
72243
|
+
function toOpenAPIMethod(method) {
|
|
72244
|
+
return method.toLocaleLowerCase();
|
|
72245
|
+
}
|
|
72246
|
+
function toOpenAPIContent(schema) {
|
|
72247
|
+
const content = {};
|
|
72248
|
+
const [matches, restSchema] = filterSchemaBranches(schema, isFileSchema);
|
|
72249
|
+
for (const file2 of matches) {
|
|
72250
|
+
content[file2.contentMediaType] = {
|
|
72251
|
+
schema: toOpenAPISchema(file2)
|
|
72252
|
+
};
|
|
72253
|
+
}
|
|
72254
|
+
if (restSchema !== void 0 && !isAnySchema(restSchema) && !isNeverSchema(restSchema)) {
|
|
72255
|
+
content["application/json"] = {
|
|
72256
|
+
schema: toOpenAPISchema(restSchema)
|
|
72257
|
+
};
|
|
72258
|
+
const isStillHasFileSchema = findDeepMatches((v) => isObject4(v) && isFileSchema(v), restSchema).values.length > 0;
|
|
72259
|
+
if (isStillHasFileSchema) {
|
|
72260
|
+
content["multipart/form-data"] = {
|
|
72261
|
+
schema: toOpenAPISchema(restSchema)
|
|
72262
|
+
};
|
|
72263
|
+
}
|
|
72264
|
+
}
|
|
72265
|
+
return content;
|
|
72266
|
+
}
|
|
72267
|
+
function toOpenAPIEventIteratorContent([yieldsRequired, yieldsSchema], [returnsRequired, returnsSchema]) {
|
|
72268
|
+
return {
|
|
72269
|
+
"text/event-stream": {
|
|
72270
|
+
schema: toOpenAPISchema({
|
|
72271
|
+
oneOf: [
|
|
72272
|
+
{
|
|
72273
|
+
type: "object",
|
|
72274
|
+
properties: {
|
|
72275
|
+
event: { const: "message" },
|
|
72276
|
+
data: yieldsSchema,
|
|
72277
|
+
id: { type: "string" },
|
|
72278
|
+
retry: { type: "number" }
|
|
72279
|
+
},
|
|
72280
|
+
required: yieldsRequired ? ["event", "data"] : ["event"]
|
|
72281
|
+
},
|
|
72282
|
+
{
|
|
72283
|
+
type: "object",
|
|
72284
|
+
properties: {
|
|
72285
|
+
event: { const: "done" },
|
|
72286
|
+
data: returnsSchema,
|
|
72287
|
+
id: { type: "string" },
|
|
72288
|
+
retry: { type: "number" }
|
|
72289
|
+
},
|
|
72290
|
+
required: returnsRequired ? ["event", "data"] : ["event"]
|
|
72291
|
+
},
|
|
72292
|
+
{
|
|
72293
|
+
type: "object",
|
|
72294
|
+
properties: {
|
|
72295
|
+
event: { const: "error" },
|
|
72296
|
+
data: {},
|
|
72297
|
+
id: { type: "string" },
|
|
72298
|
+
retry: { type: "number" }
|
|
72299
|
+
},
|
|
72300
|
+
required: ["event"]
|
|
72301
|
+
}
|
|
72302
|
+
]
|
|
72303
|
+
})
|
|
72304
|
+
}
|
|
72305
|
+
};
|
|
72306
|
+
}
|
|
72307
|
+
function toOpenAPIParameters(schema, parameterIn) {
|
|
72308
|
+
const parameters = [];
|
|
72309
|
+
for (const key in schema.properties) {
|
|
72310
|
+
const keySchema = schema.properties[key];
|
|
72311
|
+
let isDeepObjectStyle = true;
|
|
72312
|
+
if (parameterIn !== "query") {
|
|
72313
|
+
isDeepObjectStyle = false;
|
|
72314
|
+
} else if (isPrimitiveSchema(keySchema)) {
|
|
72315
|
+
isDeepObjectStyle = false;
|
|
72316
|
+
} else {
|
|
72317
|
+
const [item] = expandArrayableSchema(keySchema) ?? [];
|
|
72318
|
+
if (item !== void 0 && isPrimitiveSchema(item)) {
|
|
72319
|
+
isDeepObjectStyle = false;
|
|
72320
|
+
}
|
|
72321
|
+
}
|
|
72322
|
+
parameters.push({
|
|
72323
|
+
name: key,
|
|
72324
|
+
in: parameterIn,
|
|
72325
|
+
required: schema.required?.includes(key),
|
|
72326
|
+
schema: toOpenAPISchema(keySchema),
|
|
72327
|
+
style: isDeepObjectStyle ? "deepObject" : void 0,
|
|
72328
|
+
explode: isDeepObjectStyle ? true : void 0,
|
|
72329
|
+
allowEmptyValue: parameterIn === "query" ? true : void 0,
|
|
72330
|
+
allowReserved: parameterIn === "query" ? true : void 0
|
|
72331
|
+
});
|
|
72332
|
+
}
|
|
72333
|
+
return parameters;
|
|
72334
|
+
}
|
|
72335
|
+
function checkParamsSchema(schema, params) {
|
|
72336
|
+
const properties = Object.keys(schema.properties ?? {});
|
|
72337
|
+
const required2 = schema.required ?? [];
|
|
72338
|
+
if (properties.length !== params.length || properties.some((v) => !params.includes(v))) {
|
|
72339
|
+
return false;
|
|
72340
|
+
}
|
|
72341
|
+
if (required2.length !== params.length || required2.some((v) => !params.includes(v))) {
|
|
72342
|
+
return false;
|
|
72343
|
+
}
|
|
72344
|
+
return true;
|
|
72345
|
+
}
|
|
72346
|
+
function toOpenAPISchema(schema) {
|
|
72347
|
+
return schema === true ? {} : schema === false ? { not: {} } : schema;
|
|
72348
|
+
}
|
|
72349
|
+
var OPENAPI_JSON_SCHEMA_REF_PREFIX = "#/components/schemas/";
|
|
72350
|
+
function resolveOpenAPIJsonSchemaRef(doc, schema) {
|
|
72351
|
+
if (typeof schema !== "object" || !schema.$ref?.startsWith(OPENAPI_JSON_SCHEMA_REF_PREFIX)) {
|
|
72352
|
+
return schema;
|
|
72353
|
+
}
|
|
72354
|
+
const name = schema.$ref.slice(OPENAPI_JSON_SCHEMA_REF_PREFIX.length);
|
|
72355
|
+
const resolved = doc.components?.schemas?.[name];
|
|
72356
|
+
return resolved ?? schema;
|
|
72357
|
+
}
|
|
72358
|
+
function simplifyComposedObjectJsonSchemasAndRefs(schema, doc) {
|
|
72359
|
+
if (doc) {
|
|
72360
|
+
schema = resolveOpenAPIJsonSchemaRef(doc, schema);
|
|
72361
|
+
}
|
|
72362
|
+
if (typeof schema !== "object" || !schema.anyOf && !schema.oneOf && !schema.allOf) {
|
|
72363
|
+
return schema;
|
|
72364
|
+
}
|
|
72365
|
+
const unionSchemas = [
|
|
72366
|
+
...toArray(schema.anyOf?.map((s) => simplifyComposedObjectJsonSchemasAndRefs(s, doc))),
|
|
72367
|
+
...toArray(schema.oneOf?.map((s) => simplifyComposedObjectJsonSchemasAndRefs(s, doc)))
|
|
72368
|
+
];
|
|
72369
|
+
const objectUnionSchemas = [];
|
|
72370
|
+
for (const u3 of unionSchemas) {
|
|
72371
|
+
if (!isObjectSchema(u3)) {
|
|
72372
|
+
return schema;
|
|
72373
|
+
}
|
|
72374
|
+
objectUnionSchemas.push(u3);
|
|
72375
|
+
}
|
|
72376
|
+
const mergedUnionPropertyMap = /* @__PURE__ */ new Map();
|
|
72377
|
+
for (const u3 of objectUnionSchemas) {
|
|
72378
|
+
if (u3.properties) {
|
|
72379
|
+
for (const [key, value2] of Object.entries(u3.properties)) {
|
|
72380
|
+
let entry = mergedUnionPropertyMap.get(key);
|
|
72381
|
+
if (!entry) {
|
|
72382
|
+
const required2 = objectUnionSchemas.every((s) => s.required?.includes(key));
|
|
72383
|
+
entry = { required: required2, schemas: [] };
|
|
72384
|
+
mergedUnionPropertyMap.set(key, entry);
|
|
72385
|
+
}
|
|
72386
|
+
entry.schemas.push(value2);
|
|
72387
|
+
}
|
|
72388
|
+
}
|
|
72389
|
+
}
|
|
72390
|
+
const intersectionSchemas = toArray(schema.allOf?.map((s) => simplifyComposedObjectJsonSchemasAndRefs(s, doc)));
|
|
72391
|
+
const objectIntersectionSchemas = [];
|
|
72392
|
+
for (const u3 of intersectionSchemas) {
|
|
72393
|
+
if (!isObjectSchema(u3)) {
|
|
72394
|
+
return schema;
|
|
72395
|
+
}
|
|
72396
|
+
objectIntersectionSchemas.push(u3);
|
|
72397
|
+
}
|
|
72398
|
+
if (isObjectSchema(schema)) {
|
|
72399
|
+
objectIntersectionSchemas.push(schema);
|
|
72400
|
+
}
|
|
72401
|
+
const mergedInteractionPropertyMap = /* @__PURE__ */ new Map();
|
|
72402
|
+
for (const u3 of objectIntersectionSchemas) {
|
|
72403
|
+
if (u3.properties) {
|
|
72404
|
+
for (const [key, value2] of Object.entries(u3.properties)) {
|
|
72405
|
+
let entry = mergedInteractionPropertyMap.get(key);
|
|
72406
|
+
if (!entry) {
|
|
72407
|
+
const required2 = objectIntersectionSchemas.some((s) => s.required?.includes(key));
|
|
72408
|
+
entry = { required: required2, schemas: [] };
|
|
72409
|
+
mergedInteractionPropertyMap.set(key, entry);
|
|
72410
|
+
}
|
|
72411
|
+
entry.schemas.push(value2);
|
|
72412
|
+
}
|
|
72413
|
+
}
|
|
72414
|
+
}
|
|
72415
|
+
const resultObjectSchema = { type: "object", properties: {}, required: [] };
|
|
72416
|
+
const keys = /* @__PURE__ */ new Set([
|
|
72417
|
+
...mergedUnionPropertyMap.keys(),
|
|
72418
|
+
...mergedInteractionPropertyMap.keys()
|
|
72419
|
+
]);
|
|
72420
|
+
if (keys.size === 0) {
|
|
72421
|
+
return schema;
|
|
72422
|
+
}
|
|
72423
|
+
const deduplicateSchemas = (schemas) => {
|
|
72424
|
+
const seen = /* @__PURE__ */ new Set();
|
|
72425
|
+
const result = [];
|
|
72426
|
+
for (const schema2 of schemas) {
|
|
72427
|
+
const key = stringifyJSON(schema2);
|
|
72428
|
+
if (!seen.has(key)) {
|
|
72429
|
+
seen.add(key);
|
|
72430
|
+
result.push(schema2);
|
|
72431
|
+
}
|
|
72432
|
+
}
|
|
72433
|
+
return result;
|
|
72434
|
+
};
|
|
72435
|
+
for (const key of keys) {
|
|
72436
|
+
const unionEntry = mergedUnionPropertyMap.get(key);
|
|
72437
|
+
const intersectionEntry = mergedInteractionPropertyMap.get(key);
|
|
72438
|
+
resultObjectSchema.properties[key] = (() => {
|
|
72439
|
+
const dedupedUnionSchemas = unionEntry ? deduplicateSchemas(unionEntry.schemas) : [];
|
|
72440
|
+
const dedupedIntersectionSchemas = intersectionEntry ? deduplicateSchemas(intersectionEntry.schemas) : [];
|
|
72441
|
+
if (!dedupedUnionSchemas.length) {
|
|
72442
|
+
return dedupedIntersectionSchemas.length === 1 ? dedupedIntersectionSchemas[0] : { allOf: dedupedIntersectionSchemas };
|
|
72443
|
+
}
|
|
72444
|
+
if (!dedupedIntersectionSchemas.length) {
|
|
72445
|
+
return dedupedUnionSchemas.length === 1 ? dedupedUnionSchemas[0] : { anyOf: dedupedUnionSchemas };
|
|
72446
|
+
}
|
|
72447
|
+
const allOf = deduplicateSchemas([
|
|
72448
|
+
...dedupedIntersectionSchemas,
|
|
72449
|
+
dedupedUnionSchemas.length === 1 ? dedupedUnionSchemas[0] : { anyOf: dedupedUnionSchemas }
|
|
72450
|
+
]);
|
|
72451
|
+
return allOf.length === 1 ? allOf[0] : { allOf };
|
|
72452
|
+
})();
|
|
72453
|
+
if (unionEntry?.required || intersectionEntry?.required) {
|
|
72454
|
+
resultObjectSchema.required.push(key);
|
|
72455
|
+
}
|
|
72456
|
+
}
|
|
72457
|
+
return resultObjectSchema;
|
|
72458
|
+
}
|
|
72459
|
+
var CompositeSchemaConverter = class {
|
|
72460
|
+
converters;
|
|
72461
|
+
constructor(converters) {
|
|
72462
|
+
this.converters = converters;
|
|
72463
|
+
}
|
|
72464
|
+
async convert(schema, options) {
|
|
72465
|
+
for (const converter of this.converters) {
|
|
72466
|
+
if (await converter.condition(schema, options)) {
|
|
72467
|
+
return converter.convert(schema, options);
|
|
72468
|
+
}
|
|
72469
|
+
}
|
|
72470
|
+
return [false, {}];
|
|
72471
|
+
}
|
|
72472
|
+
};
|
|
72473
|
+
var OpenAPIGeneratorError = class extends Error {
|
|
72474
|
+
};
|
|
72475
|
+
var OpenAPIGenerator = class {
|
|
72476
|
+
serializer;
|
|
72477
|
+
converter;
|
|
72478
|
+
constructor(options = {}) {
|
|
72479
|
+
this.serializer = new StandardOpenAPIJsonSerializer(options);
|
|
72480
|
+
this.converter = new CompositeSchemaConverter(toArray(options.schemaConverters));
|
|
72481
|
+
}
|
|
72482
|
+
/**
|
|
72483
|
+
* Generates OpenAPI specifications from oRPC routers/contracts.
|
|
72484
|
+
*
|
|
72485
|
+
* @see {@link https://orpc.dev/docs/openapi/openapi-specification OpenAPI Specification Docs}
|
|
72486
|
+
*/
|
|
72487
|
+
async generate(router, { customErrorResponseBodySchema, commonSchemas, filter: baseFilter, exclude, ...baseDoc } = {}) {
|
|
72488
|
+
const filter = baseFilter ?? (({ contract, path: path46 }) => {
|
|
72489
|
+
return !(exclude?.(contract, path46) ?? false);
|
|
72490
|
+
});
|
|
72491
|
+
const doc = {
|
|
72492
|
+
...clone2(baseDoc),
|
|
72493
|
+
info: baseDoc.info ?? { title: "API Reference", version: "0.0.0" },
|
|
72494
|
+
openapi: "3.1.1"
|
|
72495
|
+
};
|
|
72496
|
+
const { baseSchemaConvertOptions, undefinedErrorJsonSchema } = await this.#resolveCommonSchemas(doc, commonSchemas);
|
|
72497
|
+
const contracts = [];
|
|
72498
|
+
await resolveContractProcedures({ path: [], router }, (traverseOptions) => {
|
|
72499
|
+
if (!value(filter, traverseOptions)) {
|
|
72500
|
+
return;
|
|
72501
|
+
}
|
|
72502
|
+
contracts.push(traverseOptions);
|
|
72503
|
+
});
|
|
72504
|
+
const errors = [];
|
|
72505
|
+
for (const { contract, path: path46 } of contracts) {
|
|
72506
|
+
const stringPath = path46.join(".");
|
|
72507
|
+
try {
|
|
72508
|
+
const def = contract["~orpc"];
|
|
72509
|
+
const method = toOpenAPIMethod(fallbackContractConfig("defaultMethod", def.route.method));
|
|
72510
|
+
const httpPath = toOpenAPIPath(def.route.path ?? toHttpPath(path46));
|
|
72511
|
+
let operationObjectRef;
|
|
72512
|
+
if (def.route.spec !== void 0 && typeof def.route.spec !== "function") {
|
|
72513
|
+
operationObjectRef = def.route.spec;
|
|
72514
|
+
} else {
|
|
72515
|
+
operationObjectRef = {
|
|
72516
|
+
operationId: def.route.operationId ?? stringPath,
|
|
72517
|
+
summary: def.route.summary,
|
|
72518
|
+
description: def.route.description,
|
|
72519
|
+
deprecated: def.route.deprecated,
|
|
72520
|
+
tags: def.route.tags?.map((tag) => tag)
|
|
72521
|
+
};
|
|
72522
|
+
await this.#request(doc, operationObjectRef, def, baseSchemaConvertOptions);
|
|
72523
|
+
await this.#successResponse(doc, operationObjectRef, def, baseSchemaConvertOptions);
|
|
72524
|
+
await this.#errorResponse(operationObjectRef, def, baseSchemaConvertOptions, undefinedErrorJsonSchema, customErrorResponseBodySchema);
|
|
72525
|
+
}
|
|
72526
|
+
if (typeof def.route.spec === "function") {
|
|
72527
|
+
operationObjectRef = def.route.spec(operationObjectRef);
|
|
72528
|
+
}
|
|
72529
|
+
doc.paths ??= {};
|
|
72530
|
+
doc.paths[httpPath] ??= {};
|
|
72531
|
+
doc.paths[httpPath][method] = applyCustomOpenAPIOperation(operationObjectRef, contract);
|
|
72532
|
+
} catch (e) {
|
|
72533
|
+
if (!(e instanceof OpenAPIGeneratorError)) {
|
|
72534
|
+
throw e;
|
|
72535
|
+
}
|
|
72536
|
+
errors.push(
|
|
72537
|
+
`[OpenAPIGenerator] Error occurred while generating OpenAPI for procedure at path: ${stringPath}
|
|
72538
|
+
${e.message}`
|
|
72539
|
+
);
|
|
72540
|
+
}
|
|
72541
|
+
}
|
|
72542
|
+
if (errors.length) {
|
|
72543
|
+
throw new OpenAPIGeneratorError(
|
|
72544
|
+
`Some error occurred during OpenAPI generation:
|
|
72545
|
+
|
|
72546
|
+
${errors.join("\n\n")}`
|
|
72547
|
+
);
|
|
72548
|
+
}
|
|
72549
|
+
return this.serializer.serialize(doc)[0];
|
|
72550
|
+
}
|
|
72551
|
+
async #resolveCommonSchemas(doc, commonSchemas) {
|
|
72552
|
+
let undefinedErrorJsonSchema = {
|
|
72553
|
+
type: "object",
|
|
72554
|
+
properties: {
|
|
72555
|
+
defined: { const: false },
|
|
72556
|
+
code: { type: "string" },
|
|
72557
|
+
status: { type: "number" },
|
|
72558
|
+
message: { type: "string" },
|
|
72559
|
+
data: {}
|
|
72560
|
+
},
|
|
72561
|
+
required: ["defined", "code", "status", "message"]
|
|
72562
|
+
};
|
|
72563
|
+
const baseSchemaConvertOptions = {};
|
|
72564
|
+
if (commonSchemas) {
|
|
72565
|
+
baseSchemaConvertOptions.components = [];
|
|
72566
|
+
for (const key in commonSchemas) {
|
|
72567
|
+
const options = commonSchemas[key];
|
|
72568
|
+
if (options.schema === void 0) {
|
|
72569
|
+
continue;
|
|
72570
|
+
}
|
|
72571
|
+
const { schema, strategy = "input" } = options;
|
|
72572
|
+
const [required2, json2] = await this.converter.convert(schema, { strategy });
|
|
72573
|
+
const allowedStrategies = [strategy];
|
|
72574
|
+
if (strategy === "input") {
|
|
72575
|
+
const [outputRequired, outputJson] = await this.converter.convert(schema, { strategy: "output" });
|
|
72576
|
+
if (outputRequired === required2 && stringifyJSON(outputJson) === stringifyJSON(json2)) {
|
|
72577
|
+
allowedStrategies.push("output");
|
|
72578
|
+
}
|
|
72579
|
+
} else if (strategy === "output") {
|
|
72580
|
+
const [inputRequired, inputJson] = await this.converter.convert(schema, { strategy: "input" });
|
|
72581
|
+
if (inputRequired === required2 && stringifyJSON(inputJson) === stringifyJSON(json2)) {
|
|
72582
|
+
allowedStrategies.push("input");
|
|
72583
|
+
}
|
|
72584
|
+
}
|
|
72585
|
+
baseSchemaConvertOptions.components.push({
|
|
72586
|
+
schema,
|
|
72587
|
+
required: required2,
|
|
72588
|
+
ref: `#/components/schemas/${key}`,
|
|
72589
|
+
allowedStrategies
|
|
72590
|
+
});
|
|
72591
|
+
}
|
|
72592
|
+
doc.components ??= {};
|
|
72593
|
+
doc.components.schemas ??= {};
|
|
72594
|
+
for (const key in commonSchemas) {
|
|
72595
|
+
const options = commonSchemas[key];
|
|
72596
|
+
if (options.schema === void 0) {
|
|
72597
|
+
if (options.error === "UndefinedError") {
|
|
72598
|
+
doc.components.schemas[key] = toOpenAPISchema(undefinedErrorJsonSchema);
|
|
72599
|
+
undefinedErrorJsonSchema = { $ref: `#/components/schemas/${key}` };
|
|
72600
|
+
}
|
|
72601
|
+
continue;
|
|
72602
|
+
}
|
|
72603
|
+
const { schema, strategy = "input" } = options;
|
|
72604
|
+
const [, json2] = await this.converter.convert(
|
|
72605
|
+
schema,
|
|
72606
|
+
{
|
|
72607
|
+
...baseSchemaConvertOptions,
|
|
72608
|
+
strategy,
|
|
72609
|
+
minStructureDepthForRef: 1
|
|
72610
|
+
// not allow use $ref for root schemas
|
|
72611
|
+
}
|
|
72612
|
+
);
|
|
72613
|
+
doc.components.schemas[key] = toOpenAPISchema(json2);
|
|
72614
|
+
}
|
|
72615
|
+
}
|
|
72616
|
+
return { baseSchemaConvertOptions, undefinedErrorJsonSchema };
|
|
72617
|
+
}
|
|
72618
|
+
async #request(doc, ref, def, baseSchemaConvertOptions) {
|
|
72619
|
+
const method = fallbackContractConfig("defaultMethod", def.route.method);
|
|
72620
|
+
const details = getEventIteratorSchemaDetails(def.inputSchema);
|
|
72621
|
+
if (details) {
|
|
72622
|
+
ref.requestBody = {
|
|
72623
|
+
required: true,
|
|
72624
|
+
content: toOpenAPIEventIteratorContent(
|
|
72625
|
+
await this.converter.convert(details.yields, { ...baseSchemaConvertOptions, strategy: "input" }),
|
|
72626
|
+
await this.converter.convert(details.returns, { ...baseSchemaConvertOptions, strategy: "input" })
|
|
72627
|
+
)
|
|
72628
|
+
};
|
|
72629
|
+
return;
|
|
72630
|
+
}
|
|
72631
|
+
const dynamicParams = getDynamicParams(def.route.path)?.map((v) => v.name);
|
|
72632
|
+
const inputStructure = fallbackContractConfig("defaultInputStructure", def.route.inputStructure);
|
|
72633
|
+
let [required2, schema] = await this.converter.convert(
|
|
72634
|
+
def.inputSchema,
|
|
72635
|
+
{
|
|
72636
|
+
...baseSchemaConvertOptions,
|
|
72637
|
+
strategy: "input"
|
|
72638
|
+
}
|
|
72639
|
+
);
|
|
72640
|
+
let omitResponseBody = false;
|
|
72641
|
+
if (isAnySchema(schema) && !dynamicParams?.length) {
|
|
72642
|
+
return;
|
|
72643
|
+
}
|
|
72644
|
+
if (inputStructure === "detailed" || inputStructure === "compact" && (dynamicParams?.length || method === "GET")) {
|
|
72645
|
+
schema = simplifyComposedObjectJsonSchemasAndRefs(schema, doc);
|
|
72646
|
+
}
|
|
72647
|
+
if (inputStructure === "compact") {
|
|
72648
|
+
if (dynamicParams?.length) {
|
|
72649
|
+
const error210 = new OpenAPIGeneratorError(
|
|
72650
|
+
'When input structure is "compact", and path has dynamic params, input schema must be an object with all dynamic params as required.'
|
|
72651
|
+
);
|
|
72652
|
+
if (!isObjectSchema(schema)) {
|
|
72653
|
+
throw error210;
|
|
72654
|
+
}
|
|
72655
|
+
const [paramsSchema, rest] = separateObjectSchema(schema, dynamicParams);
|
|
72656
|
+
schema = rest;
|
|
72657
|
+
required2 = rest.required ? rest.required.length !== 0 : false;
|
|
72658
|
+
omitResponseBody = !required2 && !rest.properties;
|
|
72659
|
+
if (!checkParamsSchema(paramsSchema, dynamicParams)) {
|
|
72660
|
+
throw error210;
|
|
72661
|
+
}
|
|
72662
|
+
ref.parameters ??= [];
|
|
72663
|
+
ref.parameters.push(...toOpenAPIParameters(paramsSchema, "path"));
|
|
72664
|
+
}
|
|
72665
|
+
if (method === "GET") {
|
|
72666
|
+
if (!isObjectSchema(schema)) {
|
|
72667
|
+
throw new OpenAPIGeneratorError(
|
|
72668
|
+
'When method is "GET", input schema must satisfy: object | any | unknown'
|
|
72669
|
+
);
|
|
72670
|
+
}
|
|
72671
|
+
ref.parameters ??= [];
|
|
72672
|
+
ref.parameters.push(...toOpenAPIParameters(schema, "query"));
|
|
72673
|
+
} else if (!omitResponseBody) {
|
|
72674
|
+
ref.requestBody = {
|
|
72675
|
+
required: required2,
|
|
72676
|
+
content: toOpenAPIContent(schema)
|
|
72677
|
+
};
|
|
72678
|
+
}
|
|
72679
|
+
return;
|
|
72680
|
+
}
|
|
72681
|
+
const error62 = new OpenAPIGeneratorError(
|
|
72682
|
+
'When input structure is "detailed", input schema must satisfy: { params?: Record<string, unknown>, query?: Record<string, unknown>, headers?: Record<string, unknown>, body?: unknown }'
|
|
72683
|
+
);
|
|
72684
|
+
if (!isObjectSchema(schema)) {
|
|
72685
|
+
throw error62;
|
|
72686
|
+
}
|
|
72687
|
+
const resolvedParamSchema = schema.properties?.params !== void 0 ? simplifyComposedObjectJsonSchemasAndRefs(schema.properties.params, doc) : void 0;
|
|
72688
|
+
if (dynamicParams?.length && (resolvedParamSchema === void 0 || !isObjectSchema(resolvedParamSchema) || !checkParamsSchema(resolvedParamSchema, dynamicParams))) {
|
|
72689
|
+
throw new OpenAPIGeneratorError(
|
|
72690
|
+
'When input structure is "detailed" and path has dynamic params, the "params" schema must be an object with all dynamic params as required.'
|
|
72691
|
+
);
|
|
72692
|
+
}
|
|
72693
|
+
for (const from of ["params", "query", "headers"]) {
|
|
72694
|
+
const fromSchema = schema.properties?.[from];
|
|
72695
|
+
if (fromSchema !== void 0) {
|
|
72696
|
+
const resolvedSchema = simplifyComposedObjectJsonSchemasAndRefs(fromSchema, doc);
|
|
72697
|
+
if (!isObjectSchema(resolvedSchema)) {
|
|
72698
|
+
throw error62;
|
|
72699
|
+
}
|
|
72700
|
+
const parameterIn = from === "params" ? "path" : from === "headers" ? "header" : "query";
|
|
72701
|
+
ref.parameters ??= [];
|
|
72702
|
+
ref.parameters.push(...toOpenAPIParameters(resolvedSchema, parameterIn));
|
|
72703
|
+
}
|
|
72704
|
+
}
|
|
72705
|
+
if (schema.properties?.body !== void 0) {
|
|
72706
|
+
ref.requestBody = {
|
|
72707
|
+
required: schema.required?.includes("body"),
|
|
72708
|
+
content: toOpenAPIContent(schema.properties.body)
|
|
72709
|
+
};
|
|
72710
|
+
}
|
|
72711
|
+
}
|
|
72712
|
+
async #successResponse(doc, ref, def, baseSchemaConvertOptions) {
|
|
72713
|
+
const outputSchema = def.outputSchema;
|
|
72714
|
+
const status = fallbackContractConfig("defaultSuccessStatus", def.route.successStatus);
|
|
72715
|
+
const description = fallbackContractConfig("defaultSuccessDescription", def.route?.successDescription);
|
|
72716
|
+
const eventIteratorSchemaDetails = getEventIteratorSchemaDetails(outputSchema);
|
|
72717
|
+
const outputStructure = fallbackContractConfig("defaultOutputStructure", def.route.outputStructure);
|
|
72718
|
+
if (eventIteratorSchemaDetails) {
|
|
72719
|
+
ref.responses ??= {};
|
|
72720
|
+
ref.responses[status] = {
|
|
72721
|
+
description,
|
|
72722
|
+
content: toOpenAPIEventIteratorContent(
|
|
72723
|
+
await this.converter.convert(eventIteratorSchemaDetails.yields, { ...baseSchemaConvertOptions, strategy: "output" }),
|
|
72724
|
+
await this.converter.convert(eventIteratorSchemaDetails.returns, { ...baseSchemaConvertOptions, strategy: "output" })
|
|
72725
|
+
)
|
|
72726
|
+
};
|
|
72727
|
+
return;
|
|
72728
|
+
}
|
|
72729
|
+
const [required2, json2] = await this.converter.convert(
|
|
72730
|
+
outputSchema,
|
|
72731
|
+
{
|
|
72732
|
+
...baseSchemaConvertOptions,
|
|
72733
|
+
strategy: "output",
|
|
72734
|
+
minStructureDepthForRef: outputStructure === "detailed" ? 1 : 0
|
|
72735
|
+
}
|
|
72736
|
+
);
|
|
72737
|
+
if (outputStructure === "compact") {
|
|
72738
|
+
ref.responses ??= {};
|
|
72739
|
+
ref.responses[status] = {
|
|
72740
|
+
description
|
|
72741
|
+
};
|
|
72742
|
+
ref.responses[status].content = toOpenAPIContent(applySchemaOptionality(required2, json2));
|
|
72743
|
+
return;
|
|
72744
|
+
}
|
|
72745
|
+
const handledStatuses = /* @__PURE__ */ new Set();
|
|
72746
|
+
for (const item of expandUnionSchema(json2)) {
|
|
72747
|
+
const error62 = new OpenAPIGeneratorError(`
|
|
72748
|
+
When output structure is "detailed", output schema must satisfy:
|
|
72749
|
+
{
|
|
72750
|
+
status?: number, // must be a literal number and in the range of 200-399
|
|
72751
|
+
headers?: Record<string, unknown>,
|
|
72752
|
+
body?: unknown
|
|
72753
|
+
}
|
|
72754
|
+
|
|
72755
|
+
But got: ${stringifyJSON(item)}
|
|
72756
|
+
`);
|
|
72757
|
+
const simplifiedItem = simplifyComposedObjectJsonSchemasAndRefs(item, doc);
|
|
72758
|
+
if (!isObjectSchema(simplifiedItem)) {
|
|
72759
|
+
throw error62;
|
|
72760
|
+
}
|
|
72761
|
+
let schemaStatus;
|
|
72762
|
+
let schemaDescription;
|
|
72763
|
+
if (simplifiedItem.properties?.status !== void 0) {
|
|
72764
|
+
const statusSchema = resolveOpenAPIJsonSchemaRef(doc, simplifiedItem.properties.status);
|
|
72765
|
+
if (typeof statusSchema !== "object" || statusSchema.const === void 0 || typeof statusSchema.const !== "number" || !Number.isInteger(statusSchema.const) || isORPCErrorStatus(statusSchema.const)) {
|
|
72766
|
+
throw error62;
|
|
72767
|
+
}
|
|
72768
|
+
schemaStatus = statusSchema.const;
|
|
72769
|
+
schemaDescription = statusSchema.description;
|
|
72770
|
+
}
|
|
72771
|
+
const itemStatus = schemaStatus ?? status;
|
|
72772
|
+
const itemDescription = schemaDescription ?? description;
|
|
72773
|
+
if (handledStatuses.has(itemStatus)) {
|
|
72774
|
+
throw new OpenAPIGeneratorError(`
|
|
72775
|
+
When output structure is "detailed", each success status must be unique.
|
|
72776
|
+
But got status: ${itemStatus} used more than once.
|
|
72777
|
+
`);
|
|
72778
|
+
}
|
|
72779
|
+
handledStatuses.add(itemStatus);
|
|
72780
|
+
ref.responses ??= {};
|
|
72781
|
+
ref.responses[itemStatus] = {
|
|
72782
|
+
description: itemDescription
|
|
72783
|
+
};
|
|
72784
|
+
if (simplifiedItem.properties?.headers !== void 0) {
|
|
72785
|
+
const headersSchema = simplifyComposedObjectJsonSchemasAndRefs(simplifiedItem.properties.headers, doc);
|
|
72786
|
+
if (!isObjectSchema(headersSchema)) {
|
|
72787
|
+
throw error62;
|
|
72788
|
+
}
|
|
72789
|
+
for (const key in headersSchema.properties) {
|
|
72790
|
+
const headerSchema = headersSchema.properties[key];
|
|
72791
|
+
if (headerSchema !== void 0) {
|
|
72792
|
+
ref.responses[itemStatus].headers ??= {};
|
|
72793
|
+
ref.responses[itemStatus].headers[key] = {
|
|
72794
|
+
schema: toOpenAPISchema(headerSchema),
|
|
72795
|
+
required: simplifiedItem.required?.includes("headers") && headersSchema.required?.includes(key)
|
|
72796
|
+
};
|
|
72797
|
+
}
|
|
72798
|
+
}
|
|
72799
|
+
}
|
|
72800
|
+
if (simplifiedItem.properties?.body !== void 0) {
|
|
72801
|
+
ref.responses[itemStatus].content = toOpenAPIContent(
|
|
72802
|
+
applySchemaOptionality(simplifiedItem.required?.includes("body") ?? false, simplifiedItem.properties.body)
|
|
72803
|
+
);
|
|
72804
|
+
}
|
|
72805
|
+
}
|
|
72806
|
+
}
|
|
72807
|
+
async #errorResponse(ref, def, baseSchemaConvertOptions, undefinedErrorSchema, customErrorResponseBodySchema) {
|
|
72808
|
+
const errorMap = def.errorMap;
|
|
72809
|
+
const errorResponsesByStatus = {};
|
|
72810
|
+
for (const code in errorMap) {
|
|
72811
|
+
const config2 = errorMap[code];
|
|
72812
|
+
if (!config2) {
|
|
72813
|
+
continue;
|
|
72814
|
+
}
|
|
72815
|
+
const status = fallbackORPCErrorStatus(code, config2.status);
|
|
72816
|
+
const defaultMessage = fallbackORPCErrorMessage(code, config2.message);
|
|
72817
|
+
errorResponsesByStatus[status] ??= { status, definedErrorDefinitions: [], errorSchemaVariants: [] };
|
|
72818
|
+
const [dataRequired, dataSchema] = await this.converter.convert(config2.data, { ...baseSchemaConvertOptions, strategy: "output" });
|
|
72819
|
+
errorResponsesByStatus[status].definedErrorDefinitions.push([code, defaultMessage, dataRequired, dataSchema]);
|
|
72820
|
+
errorResponsesByStatus[status].errorSchemaVariants.push({
|
|
72821
|
+
type: "object",
|
|
72822
|
+
properties: {
|
|
72823
|
+
defined: { const: true },
|
|
72824
|
+
code: { const: code },
|
|
72825
|
+
status: { const: status },
|
|
72826
|
+
message: { type: "string", default: defaultMessage },
|
|
72827
|
+
data: dataSchema
|
|
72828
|
+
},
|
|
72829
|
+
required: dataRequired ? ["defined", "code", "status", "message", "data"] : ["defined", "code", "status", "message"]
|
|
72830
|
+
});
|
|
72831
|
+
}
|
|
72832
|
+
ref.responses ??= {};
|
|
72833
|
+
for (const statusString in errorResponsesByStatus) {
|
|
72834
|
+
const errorResponse2 = errorResponsesByStatus[statusString];
|
|
72835
|
+
const customBodySchema = value(customErrorResponseBodySchema, errorResponse2.definedErrorDefinitions, errorResponse2.status);
|
|
72836
|
+
ref.responses[statusString] = {
|
|
72837
|
+
description: statusString,
|
|
72838
|
+
content: toOpenAPIContent(customBodySchema ?? {
|
|
72839
|
+
oneOf: [
|
|
72840
|
+
...errorResponse2.errorSchemaVariants,
|
|
72841
|
+
undefinedErrorSchema
|
|
72842
|
+
]
|
|
72843
|
+
})
|
|
72844
|
+
};
|
|
72845
|
+
}
|
|
72846
|
+
}
|
|
72847
|
+
};
|
|
72848
|
+
|
|
71631
72849
|
// node_modules/.pnpm/@orpc+standard-server-node@1.15.4/node_modules/@orpc/standard-server-node/dist/index.mjs
|
|
71632
72850
|
var import_node_buffer = require("node:buffer");
|
|
71633
72851
|
var import_node_stream = require("node:stream");
|
|
@@ -72156,21 +73374,386 @@ var RPCHandler = class extends NodeHttpHandler {
|
|
|
72156
73374
|
}
|
|
72157
73375
|
};
|
|
72158
73376
|
|
|
73377
|
+
// node_modules/.pnpm/rou3@0.7.12/node_modules/rou3/dist/index.mjs
|
|
73378
|
+
var NullProtoObj2 = /* @__PURE__ */ (() => {
|
|
73379
|
+
const e = function() {
|
|
73380
|
+
};
|
|
73381
|
+
return e.prototype = /* @__PURE__ */ Object.create(null), Object.freeze(e.prototype), e;
|
|
73382
|
+
})();
|
|
73383
|
+
function createRouter() {
|
|
73384
|
+
return {
|
|
73385
|
+
root: { key: "" },
|
|
73386
|
+
static: new NullProtoObj2()
|
|
73387
|
+
};
|
|
73388
|
+
}
|
|
73389
|
+
function splitPath(path46) {
|
|
73390
|
+
const [_, ...s] = path46.split("/");
|
|
73391
|
+
return s[s.length - 1] === "" ? s.slice(0, -1) : s;
|
|
73392
|
+
}
|
|
73393
|
+
function getMatchParams(segments, paramsMap) {
|
|
73394
|
+
const params = new NullProtoObj2();
|
|
73395
|
+
for (const [index, name] of paramsMap) {
|
|
73396
|
+
const segment = index < 0 ? segments.slice(-(index + 1)).join("/") : segments[index];
|
|
73397
|
+
if (typeof name === "string") params[name] = segment;
|
|
73398
|
+
else {
|
|
73399
|
+
const match = segment.match(name);
|
|
73400
|
+
if (match) for (const key in match.groups) params[key] = match.groups[key];
|
|
73401
|
+
}
|
|
73402
|
+
}
|
|
73403
|
+
return params;
|
|
73404
|
+
}
|
|
73405
|
+
function addRoute(ctx, method = "", path46, data) {
|
|
73406
|
+
method = method.toUpperCase();
|
|
73407
|
+
if (path46.charCodeAt(0) !== 47) path46 = `/${path46}`;
|
|
73408
|
+
path46 = path46.replace(/\\:/g, "%3A");
|
|
73409
|
+
const segments = splitPath(path46);
|
|
73410
|
+
let node2 = ctx.root;
|
|
73411
|
+
let _unnamedParamIndex = 0;
|
|
73412
|
+
const paramsMap = [];
|
|
73413
|
+
const paramsRegexp = [];
|
|
73414
|
+
for (let i2 = 0; i2 < segments.length; i2++) {
|
|
73415
|
+
let segment = segments[i2];
|
|
73416
|
+
if (segment.startsWith("**")) {
|
|
73417
|
+
if (!node2.wildcard) node2.wildcard = { key: "**" };
|
|
73418
|
+
node2 = node2.wildcard;
|
|
73419
|
+
paramsMap.push([
|
|
73420
|
+
-(i2 + 1),
|
|
73421
|
+
segment.split(":")[1] || "_",
|
|
73422
|
+
segment.length === 2
|
|
73423
|
+
]);
|
|
73424
|
+
break;
|
|
73425
|
+
}
|
|
73426
|
+
if (segment === "*" || segment.includes(":")) {
|
|
73427
|
+
if (!node2.param) node2.param = { key: "*" };
|
|
73428
|
+
node2 = node2.param;
|
|
73429
|
+
if (segment === "*") paramsMap.push([
|
|
73430
|
+
i2,
|
|
73431
|
+
`_${_unnamedParamIndex++}`,
|
|
73432
|
+
true
|
|
73433
|
+
]);
|
|
73434
|
+
else if (segment.includes(":", 1)) {
|
|
73435
|
+
const regexp = getParamRegexp(segment);
|
|
73436
|
+
paramsRegexp[i2] = regexp;
|
|
73437
|
+
node2.hasRegexParam = true;
|
|
73438
|
+
paramsMap.push([
|
|
73439
|
+
i2,
|
|
73440
|
+
regexp,
|
|
73441
|
+
false
|
|
73442
|
+
]);
|
|
73443
|
+
} else paramsMap.push([
|
|
73444
|
+
i2,
|
|
73445
|
+
segment.slice(1),
|
|
73446
|
+
false
|
|
73447
|
+
]);
|
|
73448
|
+
continue;
|
|
73449
|
+
}
|
|
73450
|
+
if (segment === "\\*") segment = segments[i2] = "*";
|
|
73451
|
+
else if (segment === "\\*\\*") segment = segments[i2] = "**";
|
|
73452
|
+
const child = node2.static?.[segment];
|
|
73453
|
+
if (child) node2 = child;
|
|
73454
|
+
else {
|
|
73455
|
+
const staticNode = { key: segment };
|
|
73456
|
+
if (!node2.static) node2.static = new NullProtoObj2();
|
|
73457
|
+
node2.static[segment] = staticNode;
|
|
73458
|
+
node2 = staticNode;
|
|
73459
|
+
}
|
|
73460
|
+
}
|
|
73461
|
+
const hasParams = paramsMap.length > 0;
|
|
73462
|
+
if (!node2.methods) node2.methods = new NullProtoObj2();
|
|
73463
|
+
node2.methods[method] ??= [];
|
|
73464
|
+
node2.methods[method].push({
|
|
73465
|
+
data: data || null,
|
|
73466
|
+
paramsRegexp,
|
|
73467
|
+
paramsMap: hasParams ? paramsMap : void 0
|
|
73468
|
+
});
|
|
73469
|
+
if (!hasParams) ctx.static["/" + segments.join("/")] = node2;
|
|
73470
|
+
}
|
|
73471
|
+
function getParamRegexp(segment) {
|
|
73472
|
+
const regex = segment.replace(/:(\w+)/g, (_, id) => `(?<${id}>[^/]+)`).replace(/\./g, "\\.");
|
|
73473
|
+
return /* @__PURE__ */ new RegExp(`^${regex}$`);
|
|
73474
|
+
}
|
|
73475
|
+
function findRoute(ctx, method = "", path46, opts) {
|
|
73476
|
+
if (path46.charCodeAt(path46.length - 1) === 47) path46 = path46.slice(0, -1);
|
|
73477
|
+
const staticNode = ctx.static[path46];
|
|
73478
|
+
if (staticNode && staticNode.methods) {
|
|
73479
|
+
const staticMatch = staticNode.methods[method] || staticNode.methods[""];
|
|
73480
|
+
if (staticMatch !== void 0) return staticMatch[0];
|
|
73481
|
+
}
|
|
73482
|
+
const segments = splitPath(path46);
|
|
73483
|
+
const match = _lookupTree(ctx, ctx.root, method, segments, 0)?.[0];
|
|
73484
|
+
if (match === void 0) return;
|
|
73485
|
+
if (opts?.params === false) return match;
|
|
73486
|
+
return {
|
|
73487
|
+
data: match.data,
|
|
73488
|
+
params: match.paramsMap ? getMatchParams(segments, match.paramsMap) : void 0
|
|
73489
|
+
};
|
|
73490
|
+
}
|
|
73491
|
+
function _lookupTree(ctx, node2, method, segments, index) {
|
|
73492
|
+
if (index === segments.length) {
|
|
73493
|
+
if (node2.methods) {
|
|
73494
|
+
const match = node2.methods[method] || node2.methods[""];
|
|
73495
|
+
if (match) return match;
|
|
73496
|
+
}
|
|
73497
|
+
if (node2.param && node2.param.methods) {
|
|
73498
|
+
const match = node2.param.methods[method] || node2.param.methods[""];
|
|
73499
|
+
if (match) {
|
|
73500
|
+
const pMap = match[0].paramsMap;
|
|
73501
|
+
if (pMap?.[pMap?.length - 1]?.[2]) return match;
|
|
73502
|
+
}
|
|
73503
|
+
}
|
|
73504
|
+
if (node2.wildcard && node2.wildcard.methods) {
|
|
73505
|
+
const match = node2.wildcard.methods[method] || node2.wildcard.methods[""];
|
|
73506
|
+
if (match) {
|
|
73507
|
+
const pMap = match[0].paramsMap;
|
|
73508
|
+
if (pMap?.[pMap?.length - 1]?.[2]) return match;
|
|
73509
|
+
}
|
|
73510
|
+
}
|
|
73511
|
+
return;
|
|
73512
|
+
}
|
|
73513
|
+
const segment = segments[index];
|
|
73514
|
+
if (node2.static) {
|
|
73515
|
+
const staticChild = node2.static[segment];
|
|
73516
|
+
if (staticChild) {
|
|
73517
|
+
const match = _lookupTree(ctx, staticChild, method, segments, index + 1);
|
|
73518
|
+
if (match) return match;
|
|
73519
|
+
}
|
|
73520
|
+
}
|
|
73521
|
+
if (node2.param) {
|
|
73522
|
+
const match = _lookupTree(ctx, node2.param, method, segments, index + 1);
|
|
73523
|
+
if (match) {
|
|
73524
|
+
if (node2.param.hasRegexParam) {
|
|
73525
|
+
const exactMatch = match.find((m2) => m2.paramsRegexp[index]?.test(segment)) || match.find((m2) => !m2.paramsRegexp[index]);
|
|
73526
|
+
return exactMatch ? [exactMatch] : void 0;
|
|
73527
|
+
}
|
|
73528
|
+
return match;
|
|
73529
|
+
}
|
|
73530
|
+
}
|
|
73531
|
+
if (node2.wildcard && node2.wildcard.methods) return node2.wildcard.methods[method] || node2.wildcard.methods[""];
|
|
73532
|
+
}
|
|
73533
|
+
|
|
73534
|
+
// node_modules/.pnpm/@orpc+openapi@1.15.4/node_modules/@orpc/openapi/dist/shared/openapi.DPiCV5hl.mjs
|
|
73535
|
+
var StandardOpenAPICodec = class {
|
|
73536
|
+
constructor(serializer, options = {}) {
|
|
73537
|
+
this.serializer = serializer;
|
|
73538
|
+
this.customErrorResponseBodyEncoder = options.customErrorResponseBodyEncoder;
|
|
73539
|
+
}
|
|
73540
|
+
customErrorResponseBodyEncoder;
|
|
73541
|
+
async decode(request7, params, procedure) {
|
|
73542
|
+
const inputStructure = fallbackContractConfig("defaultInputStructure", procedure["~orpc"].route.inputStructure);
|
|
73543
|
+
if (inputStructure === "compact") {
|
|
73544
|
+
const data = request7.method === "GET" ? this.serializer.deserialize(request7.url.searchParams) : this.serializer.deserialize(await request7.body());
|
|
73545
|
+
if (data === void 0) {
|
|
73546
|
+
return params;
|
|
73547
|
+
}
|
|
73548
|
+
if (isObject4(data)) {
|
|
73549
|
+
return {
|
|
73550
|
+
...params,
|
|
73551
|
+
...data
|
|
73552
|
+
};
|
|
73553
|
+
}
|
|
73554
|
+
return data;
|
|
73555
|
+
}
|
|
73556
|
+
const deserializeSearchParams = () => {
|
|
73557
|
+
return this.serializer.deserialize(request7.url.searchParams);
|
|
73558
|
+
};
|
|
73559
|
+
return {
|
|
73560
|
+
params,
|
|
73561
|
+
get query() {
|
|
73562
|
+
const value2 = deserializeSearchParams();
|
|
73563
|
+
Object.defineProperty(this, "query", { value: value2, writable: true });
|
|
73564
|
+
return value2;
|
|
73565
|
+
},
|
|
73566
|
+
set query(value2) {
|
|
73567
|
+
Object.defineProperty(this, "query", { value: value2, writable: true });
|
|
73568
|
+
},
|
|
73569
|
+
headers: request7.headers,
|
|
73570
|
+
body: this.serializer.deserialize(await request7.body())
|
|
73571
|
+
};
|
|
73572
|
+
}
|
|
73573
|
+
encode(output2, procedure) {
|
|
73574
|
+
const successStatus = fallbackContractConfig("defaultSuccessStatus", procedure["~orpc"].route.successStatus);
|
|
73575
|
+
const outputStructure = fallbackContractConfig("defaultOutputStructure", procedure["~orpc"].route.outputStructure);
|
|
73576
|
+
if (outputStructure === "compact") {
|
|
73577
|
+
if (output2 instanceof ReadableStream) {
|
|
73578
|
+
return {
|
|
73579
|
+
status: successStatus,
|
|
73580
|
+
headers: {},
|
|
73581
|
+
body: output2
|
|
73582
|
+
};
|
|
73583
|
+
}
|
|
73584
|
+
return {
|
|
73585
|
+
status: successStatus,
|
|
73586
|
+
headers: {},
|
|
73587
|
+
body: this.serializer.serialize(output2)
|
|
73588
|
+
};
|
|
73589
|
+
}
|
|
73590
|
+
if (!this.#isDetailedOutput(output2)) {
|
|
73591
|
+
throw new Error(`
|
|
73592
|
+
Invalid "detailed" output structure:
|
|
73593
|
+
\u2022 Expected an object with optional properties:
|
|
73594
|
+
- status (number 200-399)
|
|
73595
|
+
- headers (Record<string, string | string[]>)
|
|
73596
|
+
- body (any)
|
|
73597
|
+
\u2022 No extra keys allowed.
|
|
73598
|
+
|
|
73599
|
+
Actual value:
|
|
73600
|
+
${stringifyJSON(output2)}
|
|
73601
|
+
`);
|
|
73602
|
+
}
|
|
73603
|
+
if (output2.body instanceof ReadableStream) {
|
|
73604
|
+
return {
|
|
73605
|
+
status: output2.status ?? successStatus,
|
|
73606
|
+
headers: output2.headers ?? {},
|
|
73607
|
+
body: output2.body
|
|
73608
|
+
};
|
|
73609
|
+
}
|
|
73610
|
+
return {
|
|
73611
|
+
status: output2.status ?? successStatus,
|
|
73612
|
+
headers: output2.headers ?? {},
|
|
73613
|
+
body: this.serializer.serialize(output2.body)
|
|
73614
|
+
};
|
|
73615
|
+
}
|
|
73616
|
+
encodeError(error62) {
|
|
73617
|
+
const body = this.customErrorResponseBodyEncoder?.(error62) ?? error62.toJSON();
|
|
73618
|
+
return {
|
|
73619
|
+
status: error62.status,
|
|
73620
|
+
headers: {},
|
|
73621
|
+
body: this.serializer.serialize(body, { outputFormat: "plain" })
|
|
73622
|
+
};
|
|
73623
|
+
}
|
|
73624
|
+
#isDetailedOutput(output2) {
|
|
73625
|
+
if (!isObject4(output2)) {
|
|
73626
|
+
return false;
|
|
73627
|
+
}
|
|
73628
|
+
if (output2.headers && !isObject4(output2.headers)) {
|
|
73629
|
+
return false;
|
|
73630
|
+
}
|
|
73631
|
+
if (output2.status !== void 0 && (typeof output2.status !== "number" || !Number.isInteger(output2.status) || isORPCErrorStatus(output2.status))) {
|
|
73632
|
+
return false;
|
|
73633
|
+
}
|
|
73634
|
+
return true;
|
|
73635
|
+
}
|
|
73636
|
+
};
|
|
73637
|
+
function toRou3Pattern(path46) {
|
|
73638
|
+
return standardizeHTTPPath(path46).replace(/\/\{\+([^}]+)\}/g, "/**:$1").replace(/\/\{([^}]+)\}/g, "/:$1");
|
|
73639
|
+
}
|
|
73640
|
+
function decodeParams(params) {
|
|
73641
|
+
return Object.fromEntries(Object.entries(params).map(([key, value2]) => [key, tryDecodeURIComponent(value2)]));
|
|
73642
|
+
}
|
|
73643
|
+
var StandardOpenAPIMatcher = class {
|
|
73644
|
+
filter;
|
|
73645
|
+
tree = createRouter();
|
|
73646
|
+
pendingRouters = [];
|
|
73647
|
+
constructor(options = {}) {
|
|
73648
|
+
this.filter = options.filter ?? true;
|
|
73649
|
+
}
|
|
73650
|
+
init(router, path46 = []) {
|
|
73651
|
+
const laziedOptions = traverseContractProcedures({ router, path: path46 }, (traverseOptions) => {
|
|
73652
|
+
if (!value(this.filter, traverseOptions)) {
|
|
73653
|
+
return;
|
|
73654
|
+
}
|
|
73655
|
+
const { path: path210, contract } = traverseOptions;
|
|
73656
|
+
const method = fallbackContractConfig("defaultMethod", contract["~orpc"].route.method);
|
|
73657
|
+
const httpPath = toRou3Pattern(contract["~orpc"].route.path ?? toHttpPath(path210));
|
|
73658
|
+
if (isProcedure(contract)) {
|
|
73659
|
+
addRoute(this.tree, method, httpPath, {
|
|
73660
|
+
path: path210,
|
|
73661
|
+
contract,
|
|
73662
|
+
procedure: contract,
|
|
73663
|
+
// this mean dev not used contract-first so we can used contract as procedure directly
|
|
73664
|
+
router
|
|
73665
|
+
});
|
|
73666
|
+
} else {
|
|
73667
|
+
addRoute(this.tree, method, httpPath, {
|
|
73668
|
+
path: path210,
|
|
73669
|
+
contract,
|
|
73670
|
+
procedure: void 0,
|
|
73671
|
+
router
|
|
73672
|
+
});
|
|
73673
|
+
}
|
|
73674
|
+
});
|
|
73675
|
+
this.pendingRouters.push(...laziedOptions.map((option) => ({
|
|
73676
|
+
...option,
|
|
73677
|
+
httpPathPrefix: toHttpPath(option.path),
|
|
73678
|
+
laziedPrefix: getLazyMeta(option.router).prefix
|
|
73679
|
+
})));
|
|
73680
|
+
}
|
|
73681
|
+
async match(method, pathname) {
|
|
73682
|
+
while (true) {
|
|
73683
|
+
const pendingRouter = this.pendingRouters.find(
|
|
73684
|
+
(pendingRouter2) => !pendingRouter2.laziedPrefix || pathname.startsWith(pendingRouter2.laziedPrefix) || pathname.startsWith(pendingRouter2.httpPathPrefix)
|
|
73685
|
+
);
|
|
73686
|
+
if (!pendingRouter) {
|
|
73687
|
+
break;
|
|
73688
|
+
}
|
|
73689
|
+
pendingRouter.initPromise ??= unlazy(pendingRouter.router).then(({ default: router }) => {
|
|
73690
|
+
this.init(router, pendingRouter.path);
|
|
73691
|
+
this.pendingRouters.splice(this.pendingRouters.indexOf(pendingRouter), 1);
|
|
73692
|
+
}).catch((error62) => {
|
|
73693
|
+
pendingRouter.initPromise = void 0;
|
|
73694
|
+
throw error62;
|
|
73695
|
+
});
|
|
73696
|
+
await pendingRouter.initPromise;
|
|
73697
|
+
}
|
|
73698
|
+
const match = findRoute(this.tree, method, pathname);
|
|
73699
|
+
if (!match) {
|
|
73700
|
+
return void 0;
|
|
73701
|
+
}
|
|
73702
|
+
if (!match.data.procedure) {
|
|
73703
|
+
const { default: maybeProcedure } = await unlazy(getRouter(match.data.router, match.data.path));
|
|
73704
|
+
if (!isProcedure(maybeProcedure)) {
|
|
73705
|
+
throw new Error(`
|
|
73706
|
+
[Contract-First] Missing or invalid implementation for procedure at path: ${toHttpPath(match.data.path)}.
|
|
73707
|
+
Ensure that the procedure is correctly defined and matches the expected contract.
|
|
73708
|
+
`);
|
|
73709
|
+
}
|
|
73710
|
+
match.data.procedure = createContractedProcedure(maybeProcedure, match.data.contract);
|
|
73711
|
+
}
|
|
73712
|
+
return {
|
|
73713
|
+
path: match.data.path,
|
|
73714
|
+
procedure: match.data.procedure,
|
|
73715
|
+
params: match.params ? decodeParams(match.params) : void 0
|
|
73716
|
+
};
|
|
73717
|
+
}
|
|
73718
|
+
};
|
|
73719
|
+
var StandardOpenAPIHandler = class extends StandardHandler {
|
|
73720
|
+
constructor(router, options) {
|
|
73721
|
+
const jsonSerializer = new StandardOpenAPIJsonSerializer(options);
|
|
73722
|
+
const bracketNotationSerializer = new StandardBracketNotationSerializer(options);
|
|
73723
|
+
const serializer = new StandardOpenAPISerializer(jsonSerializer, bracketNotationSerializer);
|
|
73724
|
+
const matcher = new StandardOpenAPIMatcher(options);
|
|
73725
|
+
const codec2 = new StandardOpenAPICodec(serializer, options);
|
|
73726
|
+
super(router, matcher, codec2, options);
|
|
73727
|
+
}
|
|
73728
|
+
};
|
|
73729
|
+
|
|
73730
|
+
// node_modules/.pnpm/@orpc+openapi@1.15.4/node_modules/@orpc/openapi/dist/adapters/node/index.mjs
|
|
73731
|
+
var OpenAPIHandler = class extends NodeHttpHandler {
|
|
73732
|
+
constructor(router, options = {}) {
|
|
73733
|
+
super(new StandardOpenAPIHandler(router, options), options);
|
|
73734
|
+
}
|
|
73735
|
+
};
|
|
73736
|
+
|
|
72159
73737
|
// src/frontdoor/rcApi.ts
|
|
72160
73738
|
var import_undici2 = __toESM(require_undici(), 1);
|
|
72161
73739
|
var RC_ORPC_PATH_PREFIX = "/__agent-shim/orpc";
|
|
73740
|
+
var RC_OPENAPI_DOC_PATH = "/openapi.json";
|
|
72162
73741
|
var RC_SUBSCRIBER_BUFFER_EVENTS = 100;
|
|
73742
|
+
function doorApiBearer(headers) {
|
|
73743
|
+
const presented = headers.authorization;
|
|
73744
|
+
const bearerPrefix = "bearer ".length;
|
|
73745
|
+
return typeof presented === "string" && presented.slice(0, bearerPrefix).toLowerCase() === "bearer " ? presented.slice(bearerPrefix) : void 0;
|
|
73746
|
+
}
|
|
72163
73747
|
function doorApiAuth(expectedToken) {
|
|
72164
73748
|
return os7.$context().use(({ context, next }) => {
|
|
72165
|
-
const
|
|
72166
|
-
const bearerPrefix = "bearer ".length;
|
|
72167
|
-
const token = typeof presented === "string" && presented.slice(0, bearerPrefix).toLowerCase() === "bearer " ? presented.slice(bearerPrefix) : void 0;
|
|
73749
|
+
const token = doorApiBearer(context.headers);
|
|
72168
73750
|
if (token === void 0 || !isLiveCapability(token, [expectedToken])) {
|
|
72169
73751
|
throw new ORPCError("UNAUTHORIZED", { message: "the front door's typed API demands this generation's control token as a Bearer credential" });
|
|
72170
73752
|
}
|
|
72171
73753
|
return next();
|
|
72172
73754
|
});
|
|
72173
73755
|
}
|
|
73756
|
+
var RC_API_TAG = "remote-control";
|
|
72174
73757
|
function createRcApiRouter(deps) {
|
|
72175
73758
|
const authed = doorApiAuth(deps.expectedToken);
|
|
72176
73759
|
const delivered = (sessionId, result) => {
|
|
@@ -72190,41 +73773,41 @@ function createRcApiRouter(deps) {
|
|
|
72190
73773
|
};
|
|
72191
73774
|
return {
|
|
72192
73775
|
rc: {
|
|
72193
|
-
list: authed.output(RcListOutputSchema).handler(() => ({ sessions: deps.list() })),
|
|
72194
|
-
status: authed.input(RcSessionQuerySchema).output(RcStatusOutputSchema).handler(({ input: input2 }) => {
|
|
73776
|
+
list: authed.route({ method: "GET", path: "/rest/rc/sessions", summary: "List the observed Remote Control sessions", tags: [RC_API_TAG] }).output(RcListOutputSchema).handler(() => ({ sessions: deps.list() })),
|
|
73777
|
+
status: authed.route({ method: "GET", path: "/rest/rc/status", summary: "Read session status, one session's when named", tags: [RC_API_TAG] }).input(RcSessionQuerySchema).output(RcStatusOutputSchema).handler(({ input: input2 }) => {
|
|
72195
73778
|
const statuses = deps.statusOf(input2.session);
|
|
72196
73779
|
if (input2.session !== void 0 && !statuses.some((entry) => entry.id === input2.session)) {
|
|
72197
73780
|
throw new ORPCError("NOT_FOUND", { message: rcSessionNotObservedMessage(input2.session) });
|
|
72198
73781
|
}
|
|
72199
73782
|
return { statuses };
|
|
72200
73783
|
}),
|
|
72201
|
-
pending: authed.input(RcSessionQuerySchema).output(RcPendingOutputSchema).handler(({ input: input2 }) => {
|
|
73784
|
+
pending: authed.route({ method: "GET", path: "/rest/rc/pending", summary: "Read the control requests awaiting an answer", tags: [RC_API_TAG] }).input(RcSessionQuerySchema).output(RcPendingOutputSchema).handler(({ input: input2 }) => {
|
|
72202
73785
|
const pending = deps.pendingOf(input2.session);
|
|
72203
73786
|
if (input2.session !== void 0 && deps.statusOf(input2.session).length === 0) {
|
|
72204
73787
|
throw new ORPCError("NOT_FOUND", { message: rcSessionNotObservedMessage(input2.session) });
|
|
72205
73788
|
}
|
|
72206
73789
|
return { pending };
|
|
72207
73790
|
}),
|
|
72208
|
-
send: authed.input(RcSendInputSchema).output(RcWriteOutputSchema).handler(async ({ input: input2 }) => ({ session: input2.session, sequenceNums: delivered(input2.session, await deps.inject(input2.session, input2.text)) })),
|
|
72209
|
-
answer: authed.input(RcAnswerInputSchema).output(RcAnswerOutputSchema).handler(async ({ input: input2 }) => {
|
|
73791
|
+
send: authed.route({ method: "POST", path: "/rest/rc/send", summary: "Send one message into a session", tags: [RC_API_TAG] }).input(RcSendInputSchema).output(RcWriteOutputSchema).handler(async ({ input: input2 }) => ({ session: input2.session, sequenceNums: delivered(input2.session, await deps.inject(input2.session, input2.text)) })),
|
|
73792
|
+
answer: authed.route({ method: "POST", path: "/rest/rc/answer", summary: "Answer one pending control request", tags: [RC_API_TAG] }).input(RcAnswerInputSchema).output(RcAnswerOutputSchema).handler(async ({ input: input2 }) => {
|
|
72210
73793
|
const decision = { approve: input2.approve, message: input2.approve || input2.text === void 0 ? void 0 : input2.text };
|
|
72211
73794
|
return { session: input2.session, request: input2.request, sequenceNums: delivered(input2.session, await deps.answer(input2.session, input2.request, decision)) };
|
|
72212
73795
|
}),
|
|
72213
|
-
interrupt: authed.input(RcInterruptInputSchema).output(RcControlWriteOutputSchema).handler(async ({ input: input2 }) => ({ session: input2.session, ...deliveredControl(input2.session, await deps.interrupt(input2.session)) })),
|
|
72214
|
-
setModel: authed.input(RcSetModelInputSchema).output(RcControlWriteOutputSchema).handler(async ({ input: input2 }) => ({ session: input2.session, ...deliveredControl(input2.session, await deps.setModel(input2.session, input2.model)) })),
|
|
72215
|
-
setPermissionMode: authed.input(RcSetPermissionModeInputSchema).output(RcControlWriteOutputSchema).handler(async ({ input: input2 }) => ({ session: input2.session, ...deliveredControl(input2.session, await deps.setPermissionMode(input2.session, input2.mode)) })),
|
|
72216
|
-
endSession: authed.input(RcEndSessionInputSchema).output(RcControlWriteOutputSchema).handler(async ({ input: input2 }) => ({ session: input2.session, ...deliveredControl(input2.session, await deps.endSession(input2.session, input2.reason)) })),
|
|
72217
|
-
getUsage: authed.input(RcGetUsageInputSchema).output(RcControlWriteOutputSchema).handler(async ({ input: input2 }) => ({ session: input2.session, ...deliveredControl(input2.session, await deps.getUsage(input2.session, input2.skipBehaviors)) })),
|
|
72218
|
-
getContextUsage: authed.input(RcGetContextUsageInputSchema).output(RcControlWriteOutputSchema).handler(async ({ input: input2 }) => ({ session: input2.session, ...deliveredControl(input2.session, await deps.getContextUsage(input2.session, input2.detail)) })),
|
|
72219
|
-
readFile: authed.input(RcReadFileInputSchema).output(RcControlWriteOutputSchema).handler(async ({ input: input2 }) => ({ session: input2.session, ...deliveredControl(input2.session, await deps.readFile(input2.session, input2.path, { ...input2.maxBytes === void 0 ? {} : { maxBytes: input2.maxBytes }, ...input2.encoding === void 0 ? {} : { encoding: input2.encoding } })) })),
|
|
72220
|
-
fileSuggestions: authed.input(RcFileSuggestionsInputSchema).output(RcControlWriteOutputSchema).handler(async ({ input: input2 }) => ({ session: input2.session, ...deliveredControl(input2.session, await deps.fileSuggestions(input2.session, input2.query)) })),
|
|
72221
|
-
keepAlive: authed.input(RcKeepAliveInputSchema).output(RcWriteOutputSchema).handler(async ({ input: input2 }) => ({ session: input2.session, sequenceNums: delivered(input2.session, await deps.keepAlive(input2.session)) })),
|
|
72222
|
-
mcpStatus: authed.input(RcMcpStatusInputSchema).output(RcControlWriteOutputSchema).handler(async ({ input: input2 }) => ({ session: input2.session, ...deliveredControl(input2.session, await deps.mcpStatus(input2.session)) })),
|
|
72223
|
-
mcpReconnect: authed.input(RcMcpReconnectInputSchema).output(RcControlWriteOutputSchema).handler(async ({ input: input2 }) => ({ session: input2.session, ...deliveredControl(input2.session, await deps.mcpReconnect(input2.session, input2.serverName)) })),
|
|
72224
|
-
mcpAuthenticate: authed.input(RcMcpAuthenticateInputSchema).output(RcControlWriteOutputSchema).handler(async ({ input: input2 }) => ({ session: input2.session, ...deliveredControl(input2.session, await deps.mcpAuthenticate(input2.session, input2.serverName, input2.redirectUri)) })),
|
|
72225
|
-
mcpOAuthCallbackUrl: authed.input(RcMcpOAuthCallbackUrlInputSchema).output(RcControlWriteOutputSchema).handler(async ({ input: input2 }) => ({ session: input2.session, ...deliveredControl(input2.session, await deps.mcpOAuthCallbackUrl(input2.session, input2.serverName, input2.callbackUrl)) })),
|
|
72226
|
-
teleport: authed.input(RcTeleportInputSchema).output(RcWriteOutputSchema).handler(async ({ input: input2 }) => ({ session: input2.session, sequenceNums: delivered(input2.session, await deps.teleport(input2.session, input2.marker)) })),
|
|
72227
|
-
subscribe: authed.input(RcSessionQuerySchema).output(eventIterator(RcStreamEventSchema)).handler(async function* ({ input: input2, signal }) {
|
|
73796
|
+
interrupt: authed.route({ method: "POST", path: "/rest/rc/interrupt", summary: "Interrupt a session's running turn", tags: [RC_API_TAG] }).input(RcInterruptInputSchema).output(RcControlWriteOutputSchema).handler(async ({ input: input2 }) => ({ session: input2.session, ...deliveredControl(input2.session, await deps.interrupt(input2.session)) })),
|
|
73797
|
+
setModel: authed.route({ method: "POST", path: "/rest/rc/set-model", summary: "Switch a session's model", tags: [RC_API_TAG] }).input(RcSetModelInputSchema).output(RcControlWriteOutputSchema).handler(async ({ input: input2 }) => ({ session: input2.session, ...deliveredControl(input2.session, await deps.setModel(input2.session, input2.model)) })),
|
|
73798
|
+
setPermissionMode: authed.route({ method: "POST", path: "/rest/rc/set-permission-mode", summary: "Switch a session's permission mode", tags: [RC_API_TAG] }).input(RcSetPermissionModeInputSchema).output(RcControlWriteOutputSchema).handler(async ({ input: input2 }) => ({ session: input2.session, ...deliveredControl(input2.session, await deps.setPermissionMode(input2.session, input2.mode)) })),
|
|
73799
|
+
endSession: authed.route({ method: "POST", path: "/rest/rc/end-session", summary: "End a session", tags: [RC_API_TAG] }).input(RcEndSessionInputSchema).output(RcControlWriteOutputSchema).handler(async ({ input: input2 }) => ({ session: input2.session, ...deliveredControl(input2.session, await deps.endSession(input2.session, input2.reason)) })),
|
|
73800
|
+
getUsage: authed.route({ method: "POST", path: "/rest/rc/get-usage", summary: "Ask a session for its usage snapshot", tags: [RC_API_TAG] }).input(RcGetUsageInputSchema).output(RcControlWriteOutputSchema).handler(async ({ input: input2 }) => ({ session: input2.session, ...deliveredControl(input2.session, await deps.getUsage(input2.session, input2.skipBehaviors)) })),
|
|
73801
|
+
getContextUsage: authed.route({ method: "POST", path: "/rest/rc/get-context-usage", summary: "Ask a session for its context usage", tags: [RC_API_TAG] }).input(RcGetContextUsageInputSchema).output(RcControlWriteOutputSchema).handler(async ({ input: input2 }) => ({ session: input2.session, ...deliveredControl(input2.session, await deps.getContextUsage(input2.session, input2.detail)) })),
|
|
73802
|
+
readFile: authed.route({ method: "POST", path: "/rest/rc/read-file", summary: "Ask a session to read one file", tags: [RC_API_TAG] }).input(RcReadFileInputSchema).output(RcControlWriteOutputSchema).handler(async ({ input: input2 }) => ({ session: input2.session, ...deliveredControl(input2.session, await deps.readFile(input2.session, input2.path, { ...input2.maxBytes === void 0 ? {} : { maxBytes: input2.maxBytes }, ...input2.encoding === void 0 ? {} : { encoding: input2.encoding } })) })),
|
|
73803
|
+
fileSuggestions: authed.route({ method: "POST", path: "/rest/rc/file-suggestions", summary: "Ask a session for file-path suggestions", tags: [RC_API_TAG] }).input(RcFileSuggestionsInputSchema).output(RcControlWriteOutputSchema).handler(async ({ input: input2 }) => ({ session: input2.session, ...deliveredControl(input2.session, await deps.fileSuggestions(input2.session, input2.query)) })),
|
|
73804
|
+
keepAlive: authed.route({ method: "POST", path: "/rest/rc/keep-alive", summary: "Keep a session's bridge alive", tags: [RC_API_TAG] }).input(RcKeepAliveInputSchema).output(RcWriteOutputSchema).handler(async ({ input: input2 }) => ({ session: input2.session, sequenceNums: delivered(input2.session, await deps.keepAlive(input2.session)) })),
|
|
73805
|
+
mcpStatus: authed.route({ method: "POST", path: "/rest/rc/mcp-status", summary: "Ask a session for its MCP servers' status", tags: [RC_API_TAG] }).input(RcMcpStatusInputSchema).output(RcControlWriteOutputSchema).handler(async ({ input: input2 }) => ({ session: input2.session, ...deliveredControl(input2.session, await deps.mcpStatus(input2.session)) })),
|
|
73806
|
+
mcpReconnect: authed.route({ method: "POST", path: "/rest/rc/mcp-reconnect", summary: "Ask a session to reconnect one MCP server", tags: [RC_API_TAG] }).input(RcMcpReconnectInputSchema).output(RcControlWriteOutputSchema).handler(async ({ input: input2 }) => ({ session: input2.session, ...deliveredControl(input2.session, await deps.mcpReconnect(input2.session, input2.serverName)) })),
|
|
73807
|
+
mcpAuthenticate: authed.route({ method: "POST", path: "/rest/rc/mcp-authenticate", summary: "Start OAuth for one MCP server on a session", tags: [RC_API_TAG] }).input(RcMcpAuthenticateInputSchema).output(RcControlWriteOutputSchema).handler(async ({ input: input2 }) => ({ session: input2.session, ...deliveredControl(input2.session, await deps.mcpAuthenticate(input2.session, input2.serverName, input2.redirectUri)) })),
|
|
73808
|
+
mcpOAuthCallbackUrl: authed.route({ method: "POST", path: "/rest/rc/mcp-oauth-callback-url", summary: "Hand a completed MCP OAuth callback to a session", tags: [RC_API_TAG] }).input(RcMcpOAuthCallbackUrlInputSchema).output(RcControlWriteOutputSchema).handler(async ({ input: input2 }) => ({ session: input2.session, ...deliveredControl(input2.session, await deps.mcpOAuthCallbackUrl(input2.session, input2.serverName, input2.callbackUrl)) })),
|
|
73809
|
+
teleport: authed.route({ method: "POST", path: "/rest/rc/teleport", summary: "Teleport a session to a conversation marker", tags: [RC_API_TAG] }).input(RcTeleportInputSchema).output(RcWriteOutputSchema).handler(async ({ input: input2 }) => ({ session: input2.session, sequenceNums: delivered(input2.session, await deps.teleport(input2.session, input2.marker)) })),
|
|
73810
|
+
subscribe: authed.route({ method: "GET", path: "/rest/rc/events", summary: "Stream a session's Remote Control events (SSE)", tags: [RC_API_TAG] }).input(RcSessionQuerySchema).output(eventIterator(RcStreamEventSchema)).handler(async function* ({ input: input2, signal }) {
|
|
72228
73811
|
const queue = [];
|
|
72229
73812
|
let wake;
|
|
72230
73813
|
const detach = deps.fanout.subscribe(input2.session, (event) => {
|
|
@@ -72261,11 +73844,40 @@ function createRcApiRouter(deps) {
|
|
|
72261
73844
|
}
|
|
72262
73845
|
};
|
|
72263
73846
|
}
|
|
72264
|
-
function doorApiNodeHandlerOf(router) {
|
|
72265
|
-
const
|
|
73847
|
+
function doorApiNodeHandlerOf(router, expectedToken) {
|
|
73848
|
+
const plugins = [new BodyLimitPlugin({ maxBodySize: CONTROL_BODY_CAP_BYTES })];
|
|
73849
|
+
const rpcHandler = new RPCHandler(router, { plugins });
|
|
73850
|
+
const restHandler = new OpenAPIHandler(router, { plugins });
|
|
73851
|
+
let document;
|
|
73852
|
+
const documentOf = async () => document ??= new OpenAPIGenerator().generate(router, { info: { title: "agent-shim front door API", version: package_default.version } });
|
|
72266
73853
|
return {
|
|
72267
73854
|
pathPrefix: RC_ORPC_PATH_PREFIX,
|
|
72268
|
-
handle: async (request7, response) =>
|
|
73855
|
+
handle: async (request7, response) => {
|
|
73856
|
+
if (request7.method === "GET" && request7.url === `${RC_ORPC_PATH_PREFIX}${RC_OPENAPI_DOC_PATH}`) {
|
|
73857
|
+
const token = doorApiBearer(request7.headers);
|
|
73858
|
+
if (token === void 0 || !isLiveCapability(token, [expectedToken])) {
|
|
73859
|
+
const refusal = new ORPCError("UNAUTHORIZED", { message: "the front door's OpenAPI document demands this generation's control token as a Bearer credential" });
|
|
73860
|
+
response.writeHead(HTTP_STATUS.unauthorized, { "content-type": "application/json" });
|
|
73861
|
+
response.end(JSON.stringify(refusal.toJSON()));
|
|
73862
|
+
return { matched: true };
|
|
73863
|
+
}
|
|
73864
|
+
try {
|
|
73865
|
+
const doc = await documentOf();
|
|
73866
|
+
response.writeHead(HTTP_STATUS.ok, { "content-type": "application/json" });
|
|
73867
|
+
response.end(JSON.stringify(doc));
|
|
73868
|
+
} catch (error62) {
|
|
73869
|
+
const refusal = new ORPCError("INTERNAL_SERVER_ERROR", { message: `the OpenAPI document could not be generated from the door's own router: ${error62 instanceof Error ? error62.message : String(error62)}` });
|
|
73870
|
+
response.writeHead(HTTP_STATUS.internalServerError, { "content-type": "application/json" });
|
|
73871
|
+
response.end(JSON.stringify(refusal.toJSON()));
|
|
73872
|
+
}
|
|
73873
|
+
return { matched: true };
|
|
73874
|
+
}
|
|
73875
|
+
const rest = await restHandler.handle(request7, response, { context: { headers: request7.headers }, prefix: RC_ORPC_PATH_PREFIX });
|
|
73876
|
+
if (rest.matched) {
|
|
73877
|
+
return rest;
|
|
73878
|
+
}
|
|
73879
|
+
return await rpcHandler.handle(request7, response, { context: { headers: request7.headers }, prefix: RC_ORPC_PATH_PREFIX });
|
|
73880
|
+
}
|
|
72269
73881
|
};
|
|
72270
73882
|
}
|
|
72271
73883
|
function frontDoorApiLink(port, ca, token) {
|
|
@@ -72311,11 +73923,12 @@ var LaunchLifecycleEventSchema = external_exports.strictObject({
|
|
|
72311
73923
|
});
|
|
72312
73924
|
|
|
72313
73925
|
// src/frontdoor/eventsApi.ts
|
|
73926
|
+
var EVENTS_API_TAG = "events";
|
|
72314
73927
|
function createEventsApiRouter(deps) {
|
|
72315
73928
|
const authed = doorApiAuth(deps.expectedToken);
|
|
72316
73929
|
return {
|
|
72317
73930
|
events: {
|
|
72318
|
-
subscribe: authed.input(DoorEventSourceQuerySchema).output(eventIterator(DoorEventSchema)).handler(async function* ({ input: input2, signal }) {
|
|
73931
|
+
subscribe: authed.route({ method: "GET", path: "/rest/events", summary: "Stream the door's every event source (SSE)", tags: [EVENTS_API_TAG] }).input(DoorEventSourceQuerySchema).output(eventIterator(DoorEventSchema)).handler(async function* ({ input: input2, signal }) {
|
|
72319
73932
|
if (input2.sources !== void 0) {
|
|
72320
73933
|
const live = deps.events.sources();
|
|
72321
73934
|
const unknown2 = input2.sources.filter((source) => !live.includes(source));
|
|
@@ -72348,12 +73961,16 @@ function createEventsApiRouter(deps) {
|
|
|
72348
73961
|
}
|
|
72349
73962
|
|
|
72350
73963
|
// src/frontdoor/controlApi.ts
|
|
73964
|
+
var USAGE_API_TAG = "usage";
|
|
73965
|
+
var FRONTDOOR_API_TAG = "frontdoor";
|
|
73966
|
+
var CHECK_API_TAG = "check";
|
|
73967
|
+
var DOCTOR_API_TAG = "doctor";
|
|
72351
73968
|
function createControlApiRouter(deps) {
|
|
72352
73969
|
const authed = doorApiAuth(deps.expectedToken);
|
|
72353
73970
|
return {
|
|
72354
73971
|
usage: {
|
|
72355
|
-
list: authed.output(UsageListOutputSchema).handler(() => ({ snapshots: deps.usageSnapshots() })),
|
|
72356
|
-
effectiveWindow: authed.input(UsageWindowsInputSchema).output(UsageWindowsOutputSchema).handler(({ input: input2 }) => {
|
|
73972
|
+
list: authed.route({ method: "GET", path: "/rest/usage/snapshots", summary: "List every identity's usage snapshot", tags: [USAGE_API_TAG] }).output(UsageListOutputSchema).handler(() => ({ snapshots: deps.usageSnapshots() })),
|
|
73973
|
+
effectiveWindow: authed.route({ method: "GET", path: "/rest/usage/windows", summary: "Read one identity's effective quota windows", tags: [USAGE_API_TAG] }).input(UsageWindowsInputSchema).output(UsageWindowsOutputSchema).handler(({ input: input2 }) => {
|
|
72357
73974
|
const snapshot = deps.usageSnapshotOf(input2.identity);
|
|
72358
73975
|
if (snapshot === void 0) {
|
|
72359
73976
|
throw new ORPCError("NOT_FOUND", { message: `identity ${input2.identity} has no usage snapshot yet, so no quota window has been observed for it` });
|
|
@@ -72370,7 +73987,7 @@ function createControlApiRouter(deps) {
|
|
|
72370
73987
|
...unified?.sevenDay === void 0 ? {} : { sevenDay: effectiveWindow(unified.sevenDay, now) }
|
|
72371
73988
|
};
|
|
72372
73989
|
}),
|
|
72373
|
-
live: authed.input(RcSessionQuerySchema).output(UsageLiveOutputSchema).handler(({ input: input2 }) => {
|
|
73990
|
+
live: authed.route({ method: "GET", path: "/rest/usage/live", summary: "Read the live rate-limit observations the event backbone files", tags: [USAGE_API_TAG] }).input(RcSessionQuerySchema).output(UsageLiveOutputSchema).handler(({ input: input2 }) => {
|
|
72374
73991
|
const sessions = deps.liveRateLimits(input2.session);
|
|
72375
73992
|
if (input2.session !== void 0 && sessions.length === 0) {
|
|
72376
73993
|
if (deps.list().some((session) => session.id === input2.session)) {
|
|
@@ -72382,15 +73999,15 @@ function createControlApiRouter(deps) {
|
|
|
72382
73999
|
})
|
|
72383
74000
|
},
|
|
72384
74001
|
frontdoor: {
|
|
72385
|
-
status: authed.output(FrontDoorStatusOutputSchema).handler(() => deps.frontDoorStatus()),
|
|
72386
|
-
sessions: authed.output(FrontDoorSessionsOutputSchema).handler(() => ({ sessions: deps.frontDoorStatus().sessions }))
|
|
74002
|
+
status: authed.route({ method: "GET", path: "/rest/frontdoor/status", summary: "Read the front door's status", tags: [FRONTDOOR_API_TAG] }).output(FrontDoorStatusOutputSchema).handler(() => deps.frontDoorStatus()),
|
|
74003
|
+
sessions: authed.route({ method: "GET", path: "/rest/frontdoor/sessions", summary: "Read the front door's session registry", tags: [FRONTDOOR_API_TAG] }).output(FrontDoorSessionsOutputSchema).handler(() => ({ sessions: deps.frontDoorStatus().sessions }))
|
|
72387
74004
|
},
|
|
72388
74005
|
check: {
|
|
72389
74006
|
// The report's own JSON shape is the contract (the same one `check --json` prints and `checkReportSchema.ts` defines), so the procedure returns exactly that conversion.
|
|
72390
|
-
run: authed.input(CheckRunInputSchema).output(CheckReportJsonSchema).handler(({ input: input2 }) => checkReportToJson(deps.checkReport(input2.path, input2.identity)))
|
|
74007
|
+
run: authed.route({ method: "GET", path: "/rest/check", summary: "Run the check report for one directory", tags: [CHECK_API_TAG] }).input(CheckRunInputSchema).output(CheckReportJsonSchema).handler(({ input: input2 }) => checkReportToJson(deps.checkReport(input2.path, input2.identity)))
|
|
72391
74008
|
},
|
|
72392
74009
|
doctor: {
|
|
72393
|
-
run: authed.output(DoctorRunOutputSchema).handler(() => deps.doctorReport())
|
|
74010
|
+
run: authed.route({ method: "GET", path: "/rest/doctor", summary: "Run the doctor report", tags: [DOCTOR_API_TAG] }).output(DoctorRunOutputSchema).handler(() => deps.doctorReport())
|
|
72394
74011
|
}
|
|
72395
74012
|
};
|
|
72396
74013
|
}
|
|
@@ -72398,7 +74015,7 @@ function createDoorApiRouter(deps) {
|
|
|
72398
74015
|
return { ...createRcApiRouter(deps), ...createControlApiRouter(deps), ...createEventsApiRouter(deps) };
|
|
72399
74016
|
}
|
|
72400
74017
|
function createDoorApiNodeHandler(deps) {
|
|
72401
|
-
return doorApiNodeHandlerOf(createDoorApiRouter(deps));
|
|
74018
|
+
return doorApiNodeHandlerOf(createDoorApiRouter(deps), deps.expectedToken);
|
|
72402
74019
|
}
|
|
72403
74020
|
|
|
72404
74021
|
// src/frontdoor/eventHub.ts
|
|
@@ -72689,10 +74306,10 @@ function createRoutedResponse(response, context) {
|
|
|
72689
74306
|
let headersSent = false;
|
|
72690
74307
|
let bodyObservers = [];
|
|
72691
74308
|
let finished = false;
|
|
72692
|
-
const observeBody = (
|
|
74309
|
+
const observeBody = (call2) => {
|
|
72693
74310
|
bodyObservers = bodyObservers.filter((observer) => {
|
|
72694
74311
|
try {
|
|
72695
|
-
|
|
74312
|
+
call2(observer);
|
|
72696
74313
|
return true;
|
|
72697
74314
|
} catch (error62) {
|
|
72698
74315
|
deps.log(`front door: response body observer threw for ${route}: ${describeThrown(error62)}`);
|