@artil-ai/server 0.1.0 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +53 -21
- package/bin/main.js +561 -109
- package/bin/main.js.map +7 -7
- package/package.json +2 -3
package/bin/main.js
CHANGED
|
@@ -22187,11 +22187,15 @@ class TelegramChannel extends Channel {
|
|
|
22187
22187
|
name = "Telegram";
|
|
22188
22188
|
recipients = "the id of someone who wrote to the agent's bot first, or a bot's @username";
|
|
22189
22189
|
senders = "a person's @username or Telegram user id, or a bot's @username";
|
|
22190
|
-
credentials = "
|
|
22190
|
+
credentials = "Bot token";
|
|
22191
22191
|
credentialsGuide = [
|
|
22192
|
-
"
|
|
22193
|
-
"
|
|
22194
|
-
"
|
|
22192
|
+
"Open @BotFather in Telegram.",
|
|
22193
|
+
"Send /newbot to make a bot, or /mybots to pick one you have.",
|
|
22194
|
+
"Tap API Token and copy it.",
|
|
22195
|
+
"",
|
|
22196
|
+
"Messages to the bot reach this account from now on.",
|
|
22197
|
+
"People write to the bot first, in private chats.",
|
|
22198
|
+
"Then the agent can answer."
|
|
22195
22199
|
].join(`
|
|
22196
22200
|
`);
|
|
22197
22201
|
#provider;
|
|
@@ -22322,7 +22326,7 @@ var channel = {
|
|
|
22322
22326
|
create: ({ webhookUrl, secret, fetch: fetch2 }) => new TelegramChannel(createBotApi({ webhook: webhookUrl ? { url: webhookUrl, secret } : undefined, fetch: fetch2 }))
|
|
22323
22327
|
};
|
|
22324
22328
|
// package.json
|
|
22325
|
-
var version2 = "0.1.
|
|
22329
|
+
var version2 = "0.1.2";
|
|
22326
22330
|
|
|
22327
22331
|
// src/app/cli.ts
|
|
22328
22332
|
import { parseArgs } from "util";
|
|
@@ -24560,14 +24564,108 @@ var findTargetHandler = (handler) => {
|
|
|
24560
24564
|
return handler["__COMPOSED_HANDLER"] ? findTargetHandler(handler[COMPOSED_HANDLER]) : handler;
|
|
24561
24565
|
};
|
|
24562
24566
|
|
|
24563
|
-
// ../../node_modules/.bun/hono-openapi@1.
|
|
24567
|
+
// ../../node_modules/.bun/hono-openapi@1.5.0+498ad4f22b3f3380/node_modules/hono-openapi/dist/index.js
|
|
24564
24568
|
init_dist2();
|
|
24565
24569
|
|
|
24566
24570
|
// ../../node_modules/.bun/@standard-community+standard-openapi@0.2.11+eb0485ab6460c735/node_modules/@standard-community/standard-openapi/dist/index.js
|
|
24567
24571
|
init_index_CKGGDjCx();
|
|
24568
24572
|
|
|
24569
|
-
// ../../node_modules/.bun/hono-openapi@1.
|
|
24570
|
-
var
|
|
24573
|
+
// ../../node_modules/.bun/hono-openapi@1.5.0+498ad4f22b3f3380/node_modules/hono-openapi/dist/index.js
|
|
24574
|
+
var COMPONENTS_PREFIX = "#/components/";
|
|
24575
|
+
var SCHEMA_REF = `${COMPONENTS_PREFIX}schemas/`;
|
|
24576
|
+
var decodeName = (name) => name.replaceAll("~1", "/").replaceAll("~0", "~");
|
|
24577
|
+
var encodeName = (name) => name.replaceAll("~", "~0").replaceAll("/", "~1");
|
|
24578
|
+
var renameRef = (ref, rename) => {
|
|
24579
|
+
if (!ref.startsWith(SCHEMA_REF)) {
|
|
24580
|
+
return ref;
|
|
24581
|
+
}
|
|
24582
|
+
const renamed = rename(decodeName(ref.slice(SCHEMA_REF.length)));
|
|
24583
|
+
return renamed === undefined ? ref : `${SCHEMA_REF}${encodeName(renamed)}`;
|
|
24584
|
+
};
|
|
24585
|
+
var renameMappingTarget = (target, rename) => {
|
|
24586
|
+
if (target.startsWith(SCHEMA_REF)) {
|
|
24587
|
+
return renameRef(target, rename);
|
|
24588
|
+
}
|
|
24589
|
+
if (target.includes("/") || target.includes("#")) {
|
|
24590
|
+
return target;
|
|
24591
|
+
}
|
|
24592
|
+
return rename(target) ?? target;
|
|
24593
|
+
};
|
|
24594
|
+
var isDiscriminator = (value) => value != null && typeof value === "object" && typeof value.propertyName === "string";
|
|
24595
|
+
var LITERAL_FIELDS = /* @__PURE__ */ new Set([
|
|
24596
|
+
"example",
|
|
24597
|
+
"default",
|
|
24598
|
+
"enum",
|
|
24599
|
+
"const",
|
|
24600
|
+
"value"
|
|
24601
|
+
]);
|
|
24602
|
+
var REFERENCE_MAPS = /* @__PURE__ */ new Set([
|
|
24603
|
+
"paths",
|
|
24604
|
+
"webhooks",
|
|
24605
|
+
"examples",
|
|
24606
|
+
"schemas",
|
|
24607
|
+
"parameters",
|
|
24608
|
+
"responses",
|
|
24609
|
+
"requestBodies",
|
|
24610
|
+
"headers",
|
|
24611
|
+
"content",
|
|
24612
|
+
"encoding",
|
|
24613
|
+
"links",
|
|
24614
|
+
"callbacks",
|
|
24615
|
+
"pathItems",
|
|
24616
|
+
"properties",
|
|
24617
|
+
"patternProperties",
|
|
24618
|
+
"$defs",
|
|
24619
|
+
"definitions",
|
|
24620
|
+
"dependentSchemas",
|
|
24621
|
+
"dependencies"
|
|
24622
|
+
]);
|
|
24623
|
+
var mapReferences = (value, reference, isMap = false) => {
|
|
24624
|
+
if (Array.isArray(value)) {
|
|
24625
|
+
return value.map((item) => mapReferences(item, reference));
|
|
24626
|
+
}
|
|
24627
|
+
if (value == null || typeof value !== "object") {
|
|
24628
|
+
return value;
|
|
24629
|
+
}
|
|
24630
|
+
return Object.fromEntries(Object.entries(value).map(([key, item]) => {
|
|
24631
|
+
if (isMap) {
|
|
24632
|
+
return [key, mapReferences(item, reference)];
|
|
24633
|
+
}
|
|
24634
|
+
if (LITERAL_FIELDS.has(key) || key.startsWith("x-") || key === "examples" && Array.isArray(item)) {
|
|
24635
|
+
return [key, item];
|
|
24636
|
+
}
|
|
24637
|
+
if (key === "$ref" && typeof item === "string") {
|
|
24638
|
+
return [key, reference(item, false)];
|
|
24639
|
+
}
|
|
24640
|
+
if (key === "discriminator" && isDiscriminator(item) && item.mapping) {
|
|
24641
|
+
return [
|
|
24642
|
+
key,
|
|
24643
|
+
{
|
|
24644
|
+
...item,
|
|
24645
|
+
mapping: Object.fromEntries(Object.entries(item.mapping).map(([name, target]) => [
|
|
24646
|
+
name,
|
|
24647
|
+
reference(target, true)
|
|
24648
|
+
]))
|
|
24649
|
+
}
|
|
24650
|
+
];
|
|
24651
|
+
}
|
|
24652
|
+
return [key, mapReferences(item, reference, REFERENCE_MAPS.has(key))];
|
|
24653
|
+
}));
|
|
24654
|
+
};
|
|
24655
|
+
var renameSchemaRefs = (value, rename, isMap = false) => mapReferences(value, (target, mapping) => mapping ? renameMappingTarget(target, rename) : renameRef(target, rename), isMap);
|
|
24656
|
+
var componentRefs = (value) => {
|
|
24657
|
+
const refs = [];
|
|
24658
|
+
mapReferences(value, (target, mapping) => {
|
|
24659
|
+
if (target.startsWith(COMPONENTS_PREFIX)) {
|
|
24660
|
+
refs.push(target.slice(COMPONENTS_PREFIX.length));
|
|
24661
|
+
} else if (mapping && !target.includes("/") && !target.includes("#")) {
|
|
24662
|
+
refs.push(`schemas/${encodeName(target)}`);
|
|
24663
|
+
}
|
|
24664
|
+
return target;
|
|
24665
|
+
});
|
|
24666
|
+
return refs;
|
|
24667
|
+
};
|
|
24668
|
+
var uniqueSymbol = Symbol.for("hono-openapi");
|
|
24571
24669
|
var VALIDATION_MARKER = "__HonoOpenAPIValidator__";
|
|
24572
24670
|
var ALLOWED_METHODS = [
|
|
24573
24671
|
"GET",
|
|
@@ -24611,6 +24709,40 @@ var generateOperationId = (route) => {
|
|
|
24611
24709
|
}
|
|
24612
24710
|
return operationId;
|
|
24613
24711
|
};
|
|
24712
|
+
var generatedOperationIds = /* @__PURE__ */ new WeakMap;
|
|
24713
|
+
var derivedOperationIds = /* @__PURE__ */ new WeakMap;
|
|
24714
|
+
var pathParameterNames = (path) => path.split("/").filter((segment) => segment.startsWith(":")).map((segment) => toOpenAPIPathSegment(segment).slice(1, -1));
|
|
24715
|
+
var expandOptionalParameters = (route) => {
|
|
24716
|
+
const paths = checkOptionalParameter(route.path);
|
|
24717
|
+
if (!paths) {
|
|
24718
|
+
return [{ route, omitted: undefined }];
|
|
24719
|
+
}
|
|
24720
|
+
const names = pathParameterNames(route.path);
|
|
24721
|
+
return paths.map((path) => {
|
|
24722
|
+
const kept = pathParameterNames(path);
|
|
24723
|
+
return {
|
|
24724
|
+
route: { ...route, path },
|
|
24725
|
+
omitted: names.filter((name) => !kept.includes(name))
|
|
24726
|
+
};
|
|
24727
|
+
});
|
|
24728
|
+
};
|
|
24729
|
+
var withOmittedParameters = (specs, omitted) => {
|
|
24730
|
+
if (!omitted || !specs) {
|
|
24731
|
+
return specs;
|
|
24732
|
+
}
|
|
24733
|
+
const expanded = {
|
|
24734
|
+
...specs,
|
|
24735
|
+
...omitted.length && typeof specs.operationId === "string" ? {
|
|
24736
|
+
operationId: `${specs.operationId}Without${omitted.map(toPascalCase).join("And")}`
|
|
24737
|
+
} : {}
|
|
24738
|
+
};
|
|
24739
|
+
if (omitted.length && typeof expanded.operationId === "string") {
|
|
24740
|
+
derivedOperationIds.set(expanded, expanded.operationId);
|
|
24741
|
+
}
|
|
24742
|
+
setSpecComponents(expanded, getSpecComponents(specs));
|
|
24743
|
+
expandedOperations.add(expanded);
|
|
24744
|
+
return expanded;
|
|
24745
|
+
};
|
|
24614
24746
|
var paramKey = (param) => ("$ref" in param) ? param.$ref : `${param.in} ${param.name}`;
|
|
24615
24747
|
function mergeParameters(...params) {
|
|
24616
24748
|
const merged = params.flatMap((x) => x ?? []).reduce((acc, param) => {
|
|
@@ -24619,6 +24751,11 @@ function mergeParameters(...params) {
|
|
|
24619
24751
|
}, /* @__PURE__ */ new Map);
|
|
24620
24752
|
return Array.from(merged.values());
|
|
24621
24753
|
}
|
|
24754
|
+
var specComponents = /* @__PURE__ */ new WeakMap;
|
|
24755
|
+
var setSpecComponents = (spec, components) => specComponents.set(spec, components);
|
|
24756
|
+
var getSpecComponents = (spec) => spec != null && typeof spec === "object" && specComponents.get(spec) || [];
|
|
24757
|
+
var expandedOperations = /* @__PURE__ */ new WeakSet;
|
|
24758
|
+
var isExpandedOperation = (spec) => spec != null && typeof spec === "object" && expandedOperations.has(spec);
|
|
24622
24759
|
var specsByPathContext = /* @__PURE__ */ new Map;
|
|
24623
24760
|
function getPathContext(path, pathContext) {
|
|
24624
24761
|
const context = [];
|
|
@@ -24632,13 +24769,14 @@ function getPathContext(path, pathContext) {
|
|
|
24632
24769
|
}
|
|
24633
24770
|
return context;
|
|
24634
24771
|
}
|
|
24635
|
-
function mergeRequestBodies(previous, current) {
|
|
24772
|
+
function mergeRequestBodies(previous, current, fromValidator = false) {
|
|
24636
24773
|
if (!previous || !current || "$ref" in previous || "$ref" in current) {
|
|
24637
24774
|
return current;
|
|
24638
24775
|
}
|
|
24639
24776
|
return {
|
|
24640
24777
|
...previous,
|
|
24641
24778
|
...current,
|
|
24779
|
+
...fromValidator && previous.required !== undefined ? { required: previous.required } : {},
|
|
24642
24780
|
content: {
|
|
24643
24781
|
...previous.content,
|
|
24644
24782
|
...current.content
|
|
@@ -24646,12 +24784,17 @@ function mergeRequestBodies(previous, current) {
|
|
|
24646
24784
|
};
|
|
24647
24785
|
}
|
|
24648
24786
|
function mergeSpecs(route, ...specs) {
|
|
24649
|
-
|
|
24787
|
+
const generatedOperationId = generateOperationId(route);
|
|
24788
|
+
const operationIdSpec = specs.findLast((spec) => spec?.operationId != null && generatedOperationIds.get(spec) !== spec.operationId);
|
|
24789
|
+
const merged = specs.reduce((prev, spec) => {
|
|
24650
24790
|
if (!spec || !prev)
|
|
24651
24791
|
return prev;
|
|
24652
24792
|
for (const [key, value] of Object.entries(spec)) {
|
|
24653
24793
|
if (value == null)
|
|
24654
24794
|
continue;
|
|
24795
|
+
if (key === "operationId" && generatedOperationIds.get(spec) === value) {
|
|
24796
|
+
continue;
|
|
24797
|
+
}
|
|
24655
24798
|
if (key in prev && (typeof value === "object" || typeof value === "function" && key === "operationId")) {
|
|
24656
24799
|
if (Array.isArray(value)) {
|
|
24657
24800
|
const values = [...prev[key] ?? [], ...value];
|
|
@@ -24668,7 +24811,7 @@ function mergeSpecs(route, ...specs) {
|
|
|
24668
24811
|
if (key === "parameters") {
|
|
24669
24812
|
prev[key] = mergeParameters(prev[key], value);
|
|
24670
24813
|
} else if (key === "requestBody") {
|
|
24671
|
-
prev.requestBody = mergeRequestBodies(prev.requestBody, value);
|
|
24814
|
+
prev.requestBody = mergeRequestBodies(prev.requestBody, value, spec[VALIDATION_MARKER] === true);
|
|
24672
24815
|
} else {
|
|
24673
24816
|
prev[key] = {
|
|
24674
24817
|
...prev[key],
|
|
@@ -24682,8 +24825,18 @@ function mergeSpecs(route, ...specs) {
|
|
|
24682
24825
|
}
|
|
24683
24826
|
return prev;
|
|
24684
24827
|
}, {
|
|
24685
|
-
operationId:
|
|
24828
|
+
operationId: generatedOperationId
|
|
24686
24829
|
});
|
|
24830
|
+
if (!operationIdSpec) {
|
|
24831
|
+
generatedOperationIds.set(merged, generatedOperationId);
|
|
24832
|
+
} else if (derivedOperationIds.get(operationIdSpec) === merged.operationId) {
|
|
24833
|
+
derivedOperationIds.set(merged, merged.operationId);
|
|
24834
|
+
}
|
|
24835
|
+
setSpecComponents(merged, specs.flatMap(getSpecComponents));
|
|
24836
|
+
if (specs.some(isExpandedOperation)) {
|
|
24837
|
+
expandedOperations.add(merged);
|
|
24838
|
+
}
|
|
24839
|
+
return merged;
|
|
24687
24840
|
}
|
|
24688
24841
|
function registerSchemaPath({ route, specs, paths }, pathContext = specsByPathContext) {
|
|
24689
24842
|
const path = toOpenAPIPath(route.path);
|
|
@@ -24707,6 +24860,42 @@ function registerSchemaPath({ route, specs, paths }, pathContext = specsByPathCo
|
|
|
24707
24860
|
}
|
|
24708
24861
|
}
|
|
24709
24862
|
}
|
|
24863
|
+
var uniqueOperationIds = (paths) => {
|
|
24864
|
+
const methods = ALLOWED_METHODS.map((method) => method.toLowerCase());
|
|
24865
|
+
const operations = Object.values(paths).flatMap((item) => methods.flatMap((method) => {
|
|
24866
|
+
const operation = item?.[method];
|
|
24867
|
+
return typeof operation?.operationId === "string" ? [operation] : [];
|
|
24868
|
+
}));
|
|
24869
|
+
const isGenerated = (operation) => generatedOperationIds.get(operation) === operation.operationId || derivedOperationIds.get(operation) === operation.operationId;
|
|
24870
|
+
const reserved = new Set(operations.map(({ operationId }) => operationId));
|
|
24871
|
+
const explicit = operations.filter((operation) => !isGenerated(operation));
|
|
24872
|
+
operations.filter(isGenerated).reduce((taken, operation) => {
|
|
24873
|
+
const operationId = operation.operationId;
|
|
24874
|
+
if (taken.has(operationId)) {
|
|
24875
|
+
operation.operationId = withFreeSuffix(operationId, (id) => taken.has(id) || reserved.has(id));
|
|
24876
|
+
}
|
|
24877
|
+
return taken.add(operation.operationId);
|
|
24878
|
+
}, new Set(explicit.map(({ operationId }) => operationId)));
|
|
24879
|
+
};
|
|
24880
|
+
var withFreeSuffix = (operationId, isUsed) => {
|
|
24881
|
+
let suffix = 2;
|
|
24882
|
+
while (isUsed(`${operationId}${suffix}`))
|
|
24883
|
+
suffix++;
|
|
24884
|
+
return `${operationId}${suffix}`;
|
|
24885
|
+
};
|
|
24886
|
+
var parameterComponent = (ref, ctx) => {
|
|
24887
|
+
const prefix = "#/components/parameters/";
|
|
24888
|
+
if (!ref.$ref.startsWith(prefix)) {
|
|
24889
|
+
return;
|
|
24890
|
+
}
|
|
24891
|
+
const name = ref.$ref.slice(prefix.length);
|
|
24892
|
+
const generated = ctx.components.parameters?.[name];
|
|
24893
|
+
if (generated) {
|
|
24894
|
+
return { generated: true, name, parameter: generated };
|
|
24895
|
+
}
|
|
24896
|
+
const documented = ctx.options.documentation?.components?.parameters?.[name];
|
|
24897
|
+
return documented && { generated: false, name, parameter: documented };
|
|
24898
|
+
};
|
|
24710
24899
|
function removeExcludedPaths(paths, ctx) {
|
|
24711
24900
|
const { exclude, excludeStaticFile } = ctx.options;
|
|
24712
24901
|
const newPaths = {};
|
|
@@ -24738,6 +24927,29 @@ function removeExcludedPaths(paths, ctx) {
|
|
|
24738
24927
|
continue;
|
|
24739
24928
|
const hasValidation = schema[VALIDATION_MARKER] === true;
|
|
24740
24929
|
delete schema[VALIDATION_MARKER];
|
|
24930
|
+
if (schema.parameters && isExpandedOperation(schema)) {
|
|
24931
|
+
const names = key.split("/").filter((x) => x.startsWith("{")).map((x) => x.slice(1, -1));
|
|
24932
|
+
schema.parameters = schema.parameters.flatMap((x) => {
|
|
24933
|
+
const component = "$ref" in x ? parameterComponent(x, ctx) : undefined;
|
|
24934
|
+
const parameter = component?.parameter ?? x;
|
|
24935
|
+
if ("$ref" in parameter || parameter.in !== "path") {
|
|
24936
|
+
return [x];
|
|
24937
|
+
}
|
|
24938
|
+
if (!names.includes(parameter.name)) {
|
|
24939
|
+
return [];
|
|
24940
|
+
}
|
|
24941
|
+
if (!component) {
|
|
24942
|
+
return [{ ...parameter, required: true }];
|
|
24943
|
+
}
|
|
24944
|
+
if (component.generated && !parameter.required) {
|
|
24945
|
+
ctx.components.parameters = {
|
|
24946
|
+
...ctx.components.parameters,
|
|
24947
|
+
[component.name]: { ...parameter, required: true }
|
|
24948
|
+
};
|
|
24949
|
+
}
|
|
24950
|
+
return [x];
|
|
24951
|
+
});
|
|
24952
|
+
}
|
|
24741
24953
|
if (key.includes("{")) {
|
|
24742
24954
|
schema.parameters = schema.parameters ? [...schema.parameters] : [];
|
|
24743
24955
|
const pathParameters = key.split("/").filter((x) => x.startsWith("{") && !schema.parameters.find((params) => params.in === "path" && params.name === x.slice(1, x.length - 1)));
|
|
@@ -24745,12 +24957,9 @@ function removeExcludedPaths(paths, ctx) {
|
|
|
24745
24957
|
const paramName = param.slice(1, param.length - 1);
|
|
24746
24958
|
const index = schema.parameters.findIndex((x) => {
|
|
24747
24959
|
if ("$ref" in x) {
|
|
24748
|
-
const
|
|
24749
|
-
if (
|
|
24750
|
-
|
|
24751
|
-
if (param2 && !("$ref" in param2)) {
|
|
24752
|
-
return param2.in === "path" && param2.name === paramName;
|
|
24753
|
-
}
|
|
24960
|
+
const param2 = parameterComponent(x, ctx)?.parameter;
|
|
24961
|
+
if (param2 && !("$ref" in param2)) {
|
|
24962
|
+
return param2.in === "path" && param2.name === paramName;
|
|
24754
24963
|
}
|
|
24755
24964
|
return false;
|
|
24756
24965
|
}
|
|
@@ -24766,9 +24975,9 @@ function removeExcludedPaths(paths, ctx) {
|
|
|
24766
24975
|
}
|
|
24767
24976
|
}
|
|
24768
24977
|
}
|
|
24769
|
-
if (!schema.responses) {
|
|
24978
|
+
if (!schema.responses || Object.keys(schema.responses).length === 0) {
|
|
24770
24979
|
schema.responses = {
|
|
24771
|
-
200: {}
|
|
24980
|
+
200: { description: "Successful response" }
|
|
24772
24981
|
};
|
|
24773
24982
|
}
|
|
24774
24983
|
if (hasValidation && ctx.options.defaultValidationErrorResponse !== false && !schema.responses["400"]) {
|
|
@@ -24792,6 +25001,23 @@ function removeExcludedPaths(paths, ctx) {
|
|
|
24792
25001
|
}
|
|
24793
25002
|
return newPaths;
|
|
24794
25003
|
}
|
|
25004
|
+
var componentKey = (type, name) => `${type}/${encodeName(name)}`;
|
|
25005
|
+
var reachableRefs = (refs, components, reached) => refs.reduce((seen, ref) => {
|
|
25006
|
+
if (seen.has(ref)) {
|
|
25007
|
+
return seen;
|
|
25008
|
+
}
|
|
25009
|
+
const [type, ...name] = ref.split("/");
|
|
25010
|
+
const component = components[type]?.[decodeName(name.join("/"))];
|
|
25011
|
+
return reachableRefs(componentRefs(component), components, seen.add(ref));
|
|
25012
|
+
}, reached);
|
|
25013
|
+
function documentedComponents(components, paths, documentation) {
|
|
25014
|
+
const contributed = new Set(Object.values(paths).flatMap((item) => item == null ? [] : Object.values(item)).flatMap(getSpecComponents).flatMap((operationComponents) => Object.entries(operationComponents).flatMap(([type, entries]) => Object.keys(entries ?? {}).map((name) => componentKey(type, name)))));
|
|
25015
|
+
const kept = reachableRefs([...componentRefs(paths), ...componentRefs(documentation)], components, contributed);
|
|
25016
|
+
return Object.fromEntries(Object.entries(components).flatMap(([type, entries]) => {
|
|
25017
|
+
const remaining = Object.entries(entries ?? {}).filter(([name]) => kept.has(componentKey(type, name)));
|
|
25018
|
+
return remaining.length > 0 ? [[type, Object.fromEntries(remaining)]] : [];
|
|
25019
|
+
}));
|
|
25020
|
+
}
|
|
24795
25021
|
var DEFAULT_OPTIONS = {
|
|
24796
25022
|
documentation: {},
|
|
24797
25023
|
excludeStaticFile: true,
|
|
@@ -24851,7 +25077,9 @@ async function generateSpecs(hono, options = DEFAULT_OPTIONS, c3) {
|
|
|
24851
25077
|
if (resolvedDocumentation && documentation.components) {
|
|
24852
25078
|
documentation.components.responses = resolvedDocumentation.responses;
|
|
24853
25079
|
}
|
|
24854
|
-
const
|
|
25080
|
+
const documentedPaths = removeExcludedPaths(paths, ctx);
|
|
25081
|
+
uniqueOperationIds({ ...documentedPaths, ...documentation.paths });
|
|
25082
|
+
const { components, paths: outputPaths } = splitOutputComponents(mergeComponentsObjects(documentation.components, resolvedDocumentation?.components, documentedComponents(ctx.components, documentedPaths, withOutputRefs([documentation, resolvedDocumentation?.components], ctx))), documentedPaths);
|
|
24855
25083
|
return {
|
|
24856
25084
|
openapi: "3.1.0",
|
|
24857
25085
|
...documentation,
|
|
@@ -24863,7 +25091,7 @@ async function generateSpecs(hono, options = DEFAULT_OPTIONS, c3) {
|
|
|
24863
25091
|
...documentation.info
|
|
24864
25092
|
},
|
|
24865
25093
|
paths: {
|
|
24866
|
-
...
|
|
25094
|
+
...outputPaths,
|
|
24867
25095
|
...documentation.paths
|
|
24868
25096
|
},
|
|
24869
25097
|
components
|
|
@@ -24872,14 +25100,15 @@ async function generateSpecs(hono, options = DEFAULT_OPTIONS, c3) {
|
|
|
24872
25100
|
async function generatePaths(hono, ctx) {
|
|
24873
25101
|
const paths = {};
|
|
24874
25102
|
const pathContext = /* @__PURE__ */ new Map;
|
|
25103
|
+
const defaulted = /* @__PURE__ */ new Set;
|
|
24875
25104
|
for (const route of hono.routes) {
|
|
24876
25105
|
const middlewareHandler = findTargetHandler(route.handler)[uniqueSymbol];
|
|
24877
25106
|
if (!middlewareHandler) {
|
|
24878
25107
|
if (ctx.options.includeEmptyPaths) {
|
|
24879
|
-
registerSchemaPath({
|
|
24880
|
-
route,
|
|
25108
|
+
expandOptionalParameters(route).forEach((expanded) => registerSchemaPath({
|
|
25109
|
+
route: expanded.route,
|
|
24881
25110
|
paths
|
|
24882
|
-
}, pathContext);
|
|
25111
|
+
}, pathContext));
|
|
24883
25112
|
}
|
|
24884
25113
|
continue;
|
|
24885
25114
|
}
|
|
@@ -24892,14 +25121,23 @@ async function generatePaths(hono, ctx) {
|
|
|
24892
25121
|
continue;
|
|
24893
25122
|
}
|
|
24894
25123
|
}
|
|
24895
|
-
const
|
|
24896
|
-
const
|
|
24897
|
-
|
|
24898
|
-
|
|
24899
|
-
|
|
24900
|
-
|
|
25124
|
+
const operation = `${routeMethod} ${route.path}`;
|
|
25125
|
+
const defaultOptionsForThisMethod = !defaulted.has(operation) && ctx.options.defaultOptions?.[routeMethod] && {
|
|
25126
|
+
...ctx.options.defaultOptions[routeMethod]
|
|
25127
|
+
};
|
|
25128
|
+
defaulted.add(operation);
|
|
25129
|
+
const {
|
|
25130
|
+
schema: routeSpecs,
|
|
25131
|
+
components = {},
|
|
25132
|
+
unreferencedComponents
|
|
25133
|
+
} = await getSpec(middlewareHandler, defaultOptionsForThisMethod, ctx.components.parameters);
|
|
25134
|
+
ctx.components = mergeComponentsObjects(ctx.components, components, unreferencedComponents);
|
|
25135
|
+
setSpecComponents(routeSpecs, [components]);
|
|
25136
|
+
expandOptionalParameters(route).forEach((expanded) => registerSchemaPath({
|
|
25137
|
+
route: expanded.route,
|
|
25138
|
+
specs: withOmittedParameters(routeSpecs, expanded.omitted),
|
|
24901
25139
|
paths
|
|
24902
|
-
}, pathContext);
|
|
25140
|
+
}, pathContext));
|
|
24903
25141
|
}
|
|
24904
25142
|
return paths;
|
|
24905
25143
|
}
|
|
@@ -24915,6 +25153,15 @@ function getHiddenValue(options) {
|
|
|
24915
25153
|
}
|
|
24916
25154
|
return false;
|
|
24917
25155
|
}
|
|
25156
|
+
var COMBINING_KEYWORDS = ["allOf", "anyOf", "oneOf", "not", "if"];
|
|
25157
|
+
var needsBody = (schema, components) => {
|
|
25158
|
+
const resolved = "$ref" in schema ? components?.schemas?.[schema.$ref.split("/").at(-1) ?? ""] : schema;
|
|
25159
|
+
if (!resolved || "$ref" in resolved) {
|
|
25160
|
+
return true;
|
|
25161
|
+
}
|
|
25162
|
+
const types = [resolved.type].flat();
|
|
25163
|
+
return !types.includes("object") || COMBINING_KEYWORDS.some((keyword) => (keyword in resolved)) || (resolved.required?.length ?? 0) > 0 || (resolved.minProperties ?? 0) > 0;
|
|
25164
|
+
};
|
|
24918
25165
|
async function getSpec(middlewareHandler, defaultOptions, parameterComponents) {
|
|
24919
25166
|
if ("spec" in middlewareHandler) {
|
|
24920
25167
|
const tmp = {
|
|
@@ -24925,42 +25172,30 @@ async function getSpec(middlewareHandler, defaultOptions, parameterComponents) {
|
|
|
24925
25172
|
...middlewareHandler.spec.responses
|
|
24926
25173
|
}
|
|
24927
25174
|
};
|
|
24928
|
-
|
|
24929
|
-
|
|
24930
|
-
|
|
24931
|
-
|
|
24932
|
-
components = resolved.components;
|
|
24933
|
-
}
|
|
24934
|
-
if (tmp.requestBody && "content" in tmp.requestBody) {
|
|
24935
|
-
const resolved = await resolveContentSchemas(tmp.requestBody.content);
|
|
24936
|
-
tmp.requestBody = {
|
|
24937
|
-
...tmp.requestBody,
|
|
24938
|
-
content: resolved.content
|
|
24939
|
-
};
|
|
24940
|
-
components = mergeComponentsObjects(components, resolved.components);
|
|
24941
|
-
}
|
|
24942
|
-
return { schema: tmp, components };
|
|
25175
|
+
return {
|
|
25176
|
+
...await resolveSpecSchemas(tmp),
|
|
25177
|
+
unreferencedComponents: undefined
|
|
25178
|
+
};
|
|
24943
25179
|
}
|
|
24944
25180
|
const result = await middlewareHandler.toOpenAPISchema();
|
|
24945
25181
|
liftSchemaDefs(result);
|
|
25182
|
+
let unreferencedComponents;
|
|
24946
25183
|
const docs = {
|
|
24947
25184
|
...defaultOptions,
|
|
24948
25185
|
[VALIDATION_MARKER]: true
|
|
24949
25186
|
};
|
|
24950
25187
|
if (middlewareHandler.target === "form" || middlewareHandler.target === "json") {
|
|
24951
|
-
const
|
|
25188
|
+
const mediaTypes = middlewareHandler.options?.media ? [middlewareHandler.options.media] : middlewareHandler.target === "json" ? ["application/json"] : ["application/x-www-form-urlencoded", "multipart/form-data"];
|
|
25189
|
+
const content = Object.fromEntries(mediaTypes.map((media) => [media, { schema: result.schema }]));
|
|
24952
25190
|
if (!docs.requestBody || !("content" in docs.requestBody) || !docs.requestBody.content) {
|
|
24953
25191
|
docs.requestBody = {
|
|
24954
|
-
required: true,
|
|
24955
|
-
content
|
|
24956
|
-
[media]: {
|
|
24957
|
-
schema: result.schema
|
|
24958
|
-
}
|
|
24959
|
-
}
|
|
25192
|
+
...needsBody(result.schema, result.components) ? { required: true } : {},
|
|
25193
|
+
content
|
|
24960
25194
|
};
|
|
24961
25195
|
} else {
|
|
24962
|
-
docs.requestBody
|
|
24963
|
-
|
|
25196
|
+
docs.requestBody = {
|
|
25197
|
+
...docs.requestBody,
|
|
25198
|
+
content: { ...docs.requestBody.content, ...content }
|
|
24964
25199
|
};
|
|
24965
25200
|
}
|
|
24966
25201
|
} else {
|
|
@@ -24980,6 +25215,8 @@ async function getSpec(middlewareHandler, defaultOptions, parameterComponents) {
|
|
|
24980
25215
|
delete result.components.schemas[pos];
|
|
24981
25216
|
} else {
|
|
24982
25217
|
parameters = generatedParameters;
|
|
25218
|
+
unreferencedComponents = { schemas: { [pos]: schema } };
|
|
25219
|
+
delete result.components.schemas[pos];
|
|
24983
25220
|
}
|
|
24984
25221
|
}
|
|
24985
25222
|
} else {
|
|
@@ -24987,7 +25224,27 @@ async function getSpec(middlewareHandler, defaultOptions, parameterComponents) {
|
|
|
24987
25224
|
}
|
|
24988
25225
|
docs.parameters = parameters;
|
|
24989
25226
|
}
|
|
24990
|
-
|
|
25227
|
+
const resolved = await resolveSpecSchemas(docs);
|
|
25228
|
+
return {
|
|
25229
|
+
schema: resolved.schema,
|
|
25230
|
+
components: mergeComponentsObjects(result.components, resolved.components),
|
|
25231
|
+
unreferencedComponents
|
|
25232
|
+
};
|
|
25233
|
+
}
|
|
25234
|
+
async function resolveSpecSchemas(spec) {
|
|
25235
|
+
const schema = { ...spec };
|
|
25236
|
+
let components = {};
|
|
25237
|
+
if (schema.responses) {
|
|
25238
|
+
const resolved = await resolveResponseSchemas(schema.responses);
|
|
25239
|
+
schema.responses = resolved.responses;
|
|
25240
|
+
components = resolved.components;
|
|
25241
|
+
}
|
|
25242
|
+
if (schema.requestBody && "content" in schema.requestBody) {
|
|
25243
|
+
const resolved = await resolveContentSchemas(schema.requestBody.content);
|
|
25244
|
+
schema.requestBody = { ...schema.requestBody, content: resolved.content };
|
|
25245
|
+
components = mergeComponentsObjects(components, resolved.components);
|
|
25246
|
+
}
|
|
25247
|
+
return { schema, components };
|
|
24991
25248
|
}
|
|
24992
25249
|
function generateParameters(target, schema, schemas4) {
|
|
24993
25250
|
const parameters = [];
|
|
@@ -25004,59 +25261,134 @@ function generateParameters(target, schema, schemas4) {
|
|
|
25004
25261
|
def.description = def.schema.description;
|
|
25005
25262
|
def.schema = { ...def.schema, description: undefined };
|
|
25006
25263
|
}
|
|
25264
|
+
if (def.schema && "deprecated" in def.schema && def.schema.deprecated) {
|
|
25265
|
+
def.deprecated = true;
|
|
25266
|
+
def.schema = { ...def.schema, deprecated: undefined };
|
|
25267
|
+
}
|
|
25268
|
+
const referenced = def.schema && "$ref" in def.schema ? referencedSchema(def.schema.$ref, schemas4) : undefined;
|
|
25269
|
+
if (referenced?.description && !def.description) {
|
|
25270
|
+
def.description = referenced.description;
|
|
25271
|
+
}
|
|
25272
|
+
if (referenced?.deprecated) {
|
|
25273
|
+
def.deprecated = true;
|
|
25274
|
+
}
|
|
25007
25275
|
parameters.push(def);
|
|
25008
25276
|
}
|
|
25009
25277
|
return parameters;
|
|
25010
25278
|
}
|
|
25011
|
-
|
|
25279
|
+
var referencedSchema = ($ref, schemas4) => {
|
|
25280
|
+
const prefix = "#/components/schemas/";
|
|
25281
|
+
if (!$ref.startsWith(prefix)) {
|
|
25282
|
+
return;
|
|
25283
|
+
}
|
|
25284
|
+
const name = $ref.slice(prefix.length).replaceAll("~1", "/").replaceAll("~0", "~");
|
|
25285
|
+
return schemas4?.[name];
|
|
25286
|
+
};
|
|
25287
|
+
var intersect = (entries) => {
|
|
25012
25288
|
const properties = /* @__PURE__ */ new Map;
|
|
25013
|
-
const
|
|
25014
|
-
|
|
25015
|
-
|
|
25016
|
-
|
|
25017
|
-
|
|
25018
|
-
|
|
25019
|
-
|
|
25020
|
-
|
|
25021
|
-
|
|
25022
|
-
|
|
25023
|
-
|
|
25024
|
-
|
|
25025
|
-
|
|
25026
|
-
|
|
25027
|
-
|
|
25028
|
-
|
|
25029
|
-
|
|
25030
|
-
|
|
25031
|
-
|
|
25032
|
-
resolvingRefs.delete(name);
|
|
25033
|
-
}
|
|
25034
|
-
} else {
|
|
25035
|
-
collect(member);
|
|
25289
|
+
for (const [key, property] of entries) {
|
|
25290
|
+
const existing = properties.get(key);
|
|
25291
|
+
properties.set(key, existing ? {
|
|
25292
|
+
required: existing.required || property.required,
|
|
25293
|
+
schema: { allOf: [existing.schema, property.schema] }
|
|
25294
|
+
} : property);
|
|
25295
|
+
}
|
|
25296
|
+
return properties;
|
|
25297
|
+
};
|
|
25298
|
+
var unite = (variants) => {
|
|
25299
|
+
const keys = new Set(variants.flatMap((variant) => [...variant.keys()]));
|
|
25300
|
+
return new Map([...keys].map((key) => {
|
|
25301
|
+
const found = variants.map((variant) => variant.get(key));
|
|
25302
|
+
const [first, ...others] = new Map(found.filter((property) => property !== undefined).map(({ schema }) => [JSON.stringify(schema), schema])).values();
|
|
25303
|
+
return [
|
|
25304
|
+
key,
|
|
25305
|
+
{
|
|
25306
|
+
required: found.every((property) => property?.required),
|
|
25307
|
+
schema: others.length ? { anyOf: [first, ...others] } : first
|
|
25036
25308
|
}
|
|
25309
|
+
];
|
|
25310
|
+
}));
|
|
25311
|
+
};
|
|
25312
|
+
var collectParameterProperties = (schema, schemas4) => {
|
|
25313
|
+
const collectMember = (member, resolving) => {
|
|
25314
|
+
if (!("$ref" in member))
|
|
25315
|
+
return collect(member, resolving);
|
|
25316
|
+
const prefix = "#/components/schemas/";
|
|
25317
|
+
if (!member.$ref.startsWith(prefix))
|
|
25318
|
+
return /* @__PURE__ */ new Map;
|
|
25319
|
+
const name = member.$ref.slice(prefix.length).replaceAll("~1", "/").replaceAll("~0", "~");
|
|
25320
|
+
const referencedSchema2 = schemas4?.[name];
|
|
25321
|
+
if (!referencedSchema2 || resolving.has(name))
|
|
25322
|
+
return /* @__PURE__ */ new Map;
|
|
25323
|
+
return collect(referencedSchema2, new Set(resolving).add(name));
|
|
25324
|
+
};
|
|
25325
|
+
const collect = (current, resolving) => intersect([
|
|
25326
|
+
...Object.entries(current.properties ?? {}).map(([key, value]) => [
|
|
25327
|
+
key,
|
|
25328
|
+
{ required: Boolean(current.required?.includes(key)), schema: value }
|
|
25329
|
+
]),
|
|
25330
|
+
...(current.allOf ?? []).flatMap((member) => [
|
|
25331
|
+
...collectMember(member, resolving)
|
|
25332
|
+
]),
|
|
25333
|
+
...[current.anyOf, current.oneOf].filter((variants) => variants?.length).flatMap((variants = []) => [
|
|
25334
|
+
...unite(variants.map((variant) => collectMember(variant, resolving)))
|
|
25335
|
+
])
|
|
25336
|
+
]);
|
|
25337
|
+
return collect(schema, /* @__PURE__ */ new Set);
|
|
25338
|
+
};
|
|
25339
|
+
var resolveHeaders = async (headers, direction) => {
|
|
25340
|
+
const resolved = await Promise.all(Object.entries(headers).map(async ([name, header]) => {
|
|
25341
|
+
if ("$ref" in header || typeof header.schema !== "object" || header.schema === null || !("toOpenAPISchema" in header.schema)) {
|
|
25342
|
+
return { components: undefined, entry: [name, header] };
|
|
25037
25343
|
}
|
|
25344
|
+
const result = await header.schema.toOpenAPISchema(undefined, direction);
|
|
25345
|
+
liftSchemaDefs(result);
|
|
25346
|
+
return {
|
|
25347
|
+
components: result.components,
|
|
25348
|
+
entry: [name, { ...header, schema: result.schema }]
|
|
25349
|
+
};
|
|
25350
|
+
}));
|
|
25351
|
+
return {
|
|
25352
|
+
components: mergeComponentsObjects({}, ...resolved.map(({ components }) => components)),
|
|
25353
|
+
headers: Object.fromEntries(resolved.map(({ entry }) => entry))
|
|
25038
25354
|
};
|
|
25039
|
-
|
|
25040
|
-
|
|
25041
|
-
|
|
25042
|
-
|
|
25355
|
+
};
|
|
25356
|
+
var resolveEncoding = async (encoding, direction) => {
|
|
25357
|
+
const resolved = await Promise.all(Object.entries(encoding).map(async ([property, entry]) => {
|
|
25358
|
+
if (!entry.headers) {
|
|
25359
|
+
return { components: undefined, entry: [property, entry] };
|
|
25360
|
+
}
|
|
25361
|
+
const { components, headers } = await resolveHeaders(entry.headers, direction);
|
|
25362
|
+
return { components, entry: [property, { ...entry, headers }] };
|
|
25363
|
+
}));
|
|
25364
|
+
return {
|
|
25365
|
+
components: mergeComponentsObjects({}, ...resolved.map(({ components }) => components)),
|
|
25366
|
+
encoding: Object.fromEntries(resolved.map(({ entry }) => entry))
|
|
25367
|
+
};
|
|
25368
|
+
};
|
|
25369
|
+
async function resolveContentSchemas(content, direction) {
|
|
25043
25370
|
let components = {};
|
|
25044
25371
|
const resolvedContent = {};
|
|
25045
25372
|
for (const [contentKey, raw] of Object.entries(content)) {
|
|
25046
25373
|
if (!raw)
|
|
25047
25374
|
continue;
|
|
25048
|
-
|
|
25049
|
-
|
|
25375
|
+
const encoding = raw.encoding ? await resolveEncoding(raw.encoding, direction) : undefined;
|
|
25376
|
+
const media = encoding ? { ...raw, encoding: encoding.encoding } : raw;
|
|
25377
|
+
if (encoding) {
|
|
25378
|
+
components = mergeComponentsObjects(components, encoding.components);
|
|
25379
|
+
}
|
|
25380
|
+
if (media.schema != null && typeof media.schema === "object" && "toOpenAPISchema" in media.schema) {
|
|
25381
|
+
const result = await media.schema.toOpenAPISchema(undefined, direction);
|
|
25050
25382
|
liftSchemaDefs(result);
|
|
25051
25383
|
resolvedContent[contentKey] = {
|
|
25052
|
-
...
|
|
25384
|
+
...media,
|
|
25053
25385
|
schema: result.schema
|
|
25054
25386
|
};
|
|
25055
25387
|
if (result.components) {
|
|
25056
25388
|
components = mergeComponentsObjects(components, result.components);
|
|
25057
25389
|
}
|
|
25058
25390
|
} else {
|
|
25059
|
-
resolvedContent[contentKey] =
|
|
25391
|
+
resolvedContent[contentKey] = media;
|
|
25060
25392
|
}
|
|
25061
25393
|
}
|
|
25062
25394
|
return { content: resolvedContent, components };
|
|
@@ -25065,18 +25397,20 @@ async function resolveResponseSchemas(responses) {
|
|
|
25065
25397
|
let components = {};
|
|
25066
25398
|
const resolvedResponses = {};
|
|
25067
25399
|
for (const [key, response] of Object.entries(responses)) {
|
|
25068
|
-
if (!response ||
|
|
25400
|
+
if (!response || "$ref" in response || !response.content && !response.headers) {
|
|
25069
25401
|
resolvedResponses[key] = response;
|
|
25070
25402
|
continue;
|
|
25071
25403
|
}
|
|
25072
|
-
const
|
|
25404
|
+
const content = response.content ? await resolveContentSchemas(response.content, "output") : undefined;
|
|
25405
|
+
const headers = response.headers ? await resolveHeaders(response.headers, "output") : undefined;
|
|
25073
25406
|
resolvedResponses[key] = {
|
|
25074
25407
|
...response,
|
|
25075
|
-
content:
|
|
25408
|
+
...content && { content: content.content },
|
|
25409
|
+
...headers && { headers: headers.headers }
|
|
25076
25410
|
};
|
|
25077
|
-
components = mergeComponentsObjects(components,
|
|
25411
|
+
components = mergeComponentsObjects(components, content?.components, headers?.components);
|
|
25078
25412
|
}
|
|
25079
|
-
return
|
|
25413
|
+
return markAsOutput(resolvedResponses, components);
|
|
25080
25414
|
}
|
|
25081
25415
|
function liftSchemaDefs(result) {
|
|
25082
25416
|
const defs = result.schema.$defs;
|
|
@@ -25108,6 +25442,96 @@ function mergeComponentsObjects(...components) {
|
|
|
25108
25442
|
return prev;
|
|
25109
25443
|
}, components[0] ?? {});
|
|
25110
25444
|
}
|
|
25445
|
+
var OUTPUT_MARK = "\x00output";
|
|
25446
|
+
var isOutput = (name) => name.endsWith(OUTPUT_MARK);
|
|
25447
|
+
var inputName = (output3) => output3.slice(0, -OUTPUT_MARK.length);
|
|
25448
|
+
var markAsOutput = (responses, components) => {
|
|
25449
|
+
const schemas4 = components.schemas ?? {};
|
|
25450
|
+
const mark = (name) => Object.hasOwn(schemas4, name) ? `${name}${OUTPUT_MARK}` : undefined;
|
|
25451
|
+
return {
|
|
25452
|
+
responses: renameSchemaRefs(responses, mark, true),
|
|
25453
|
+
components: {
|
|
25454
|
+
...components,
|
|
25455
|
+
...components.schemas && {
|
|
25456
|
+
schemas: Object.fromEntries(Object.entries(schemas4).map(([name, schema]) => [
|
|
25457
|
+
`${name}${OUTPUT_MARK}`,
|
|
25458
|
+
renameSchemaRefs(schema, mark)
|
|
25459
|
+
]))
|
|
25460
|
+
}
|
|
25461
|
+
}
|
|
25462
|
+
};
|
|
25463
|
+
};
|
|
25464
|
+
var withOutputRefs = (documentation, ctx) => [
|
|
25465
|
+
documentation,
|
|
25466
|
+
componentRefs(documentation).filter((ref) => ref.startsWith("schemas/")).map((ref) => decodeName(ref.slice("schemas/".length))).filter((name) => !Object.hasOwn(ctx.components.schemas ?? {}, name) && Object.hasOwn(ctx.components.schemas ?? {}, `${name}${OUTPUT_MARK}`)).map((name) => ({
|
|
25467
|
+
$ref: `${SCHEMA_REF}${encodeName(`${name}${OUTPUT_MARK}`)}`
|
|
25468
|
+
}))
|
|
25469
|
+
];
|
|
25470
|
+
var canonical = (value) => JSON.stringify(value, (_key, item) => item && typeof item === "object" && !Array.isArray(item) ? Object.fromEntries(Object.entries(item).toSorted(([a2], [b2]) => a2.localeCompare(b2))) : item);
|
|
25471
|
+
var freeName = (name, used) => {
|
|
25472
|
+
let candidate = name;
|
|
25473
|
+
for (let suffix = 2;used.has(candidate); suffix++) {
|
|
25474
|
+
candidate = `${name}${suffix}`;
|
|
25475
|
+
}
|
|
25476
|
+
return candidate;
|
|
25477
|
+
};
|
|
25478
|
+
var assignOutputNames = (outputs, taken) => {
|
|
25479
|
+
const used = new Set(taken);
|
|
25480
|
+
const names = /* @__PURE__ */ new Map;
|
|
25481
|
+
for (const output3 of outputs) {
|
|
25482
|
+
const name = freeName(`${inputName(output3)}Output`, used);
|
|
25483
|
+
used.add(name);
|
|
25484
|
+
names.set(output3, name);
|
|
25485
|
+
}
|
|
25486
|
+
return names;
|
|
25487
|
+
};
|
|
25488
|
+
var splitOutputComponents = (components, paths) => {
|
|
25489
|
+
const { schemas: schemas4 = {}, ...otherComponents } = components;
|
|
25490
|
+
const outputs = Object.keys(schemas4).filter(isOutput);
|
|
25491
|
+
if (outputs.length === 0) {
|
|
25492
|
+
return { components, paths };
|
|
25493
|
+
}
|
|
25494
|
+
const asInput = (name) => isOutput(name) ? inputName(name) : undefined;
|
|
25495
|
+
const shared = new Set(outputs.filter((output3) => Object.hasOwn(schemas4, inputName(output3))));
|
|
25496
|
+
const outputRefs = new Map([...shared].map((output3) => [
|
|
25497
|
+
output3,
|
|
25498
|
+
componentRefs(schemas4[output3]).filter((ref) => ref.startsWith("schemas/")).map((ref) => decodeName(ref.slice("schemas/".length)))
|
|
25499
|
+
]));
|
|
25500
|
+
const refersTo = (output3, split2) => outputRefs.get(output3)?.some((name) => split2.has(name));
|
|
25501
|
+
const split = new Set([...shared].filter((output3) => canonical(renameSchemaRefs(schemas4[output3], asInput)) !== canonical(schemas4[inputName(output3)])));
|
|
25502
|
+
let previousSize;
|
|
25503
|
+
do {
|
|
25504
|
+
previousSize = split.size;
|
|
25505
|
+
for (const output3 of shared) {
|
|
25506
|
+
if (!split.has(output3) && refersTo(output3, split)) {
|
|
25507
|
+
split.add(output3);
|
|
25508
|
+
}
|
|
25509
|
+
}
|
|
25510
|
+
} while (split.size !== previousSize);
|
|
25511
|
+
const taken = [
|
|
25512
|
+
...Object.keys(schemas4).filter((name) => !isOutput(name)),
|
|
25513
|
+
...outputs.filter((output3) => !shared.has(output3)).map(inputName)
|
|
25514
|
+
];
|
|
25515
|
+
const outputNames = assignOutputNames([...split].toSorted(), taken);
|
|
25516
|
+
const rename = (name) => isOutput(name) ? outputNames.get(name) ?? inputName(name) : undefined;
|
|
25517
|
+
return {
|
|
25518
|
+
components: {
|
|
25519
|
+
...renameSchemaRefs(otherComponents, rename),
|
|
25520
|
+
schemas: Object.fromEntries(Object.entries(schemas4).flatMap(([name, schema]) => {
|
|
25521
|
+
const renamed = renameSchemaRefs(schema, rename);
|
|
25522
|
+
if (!isOutput(name)) {
|
|
25523
|
+
return [[name, renamed]];
|
|
25524
|
+
}
|
|
25525
|
+
const output3 = outputNames.get(name);
|
|
25526
|
+
if (output3) {
|
|
25527
|
+
return [[output3, renamed]];
|
|
25528
|
+
}
|
|
25529
|
+
return Object.hasOwn(schemas4, inputName(name)) ? [] : [[inputName(name), renamed]];
|
|
25530
|
+
}))
|
|
25531
|
+
},
|
|
25532
|
+
paths: renameSchemaRefs(paths, rename, true)
|
|
25533
|
+
};
|
|
25534
|
+
};
|
|
25111
25535
|
var arktypeMorphFallback = (ctx) => ctx.base;
|
|
25112
25536
|
var zodV4DateOverride = (ctx) => {
|
|
25113
25537
|
if (ctx.zodSchema._zod.def.type === "date") {
|
|
@@ -25121,14 +25545,34 @@ function resolver(schema, userDefinedOptions) {
|
|
|
25121
25545
|
vendor,
|
|
25122
25546
|
validate: schema["~standard"].validate,
|
|
25123
25547
|
toJSONSchema: (customOptions) => toJsonSchema(schema, { ...userDefinedOptions, ...customOptions }),
|
|
25124
|
-
toOpenAPISchema: (customOptions) =>
|
|
25125
|
-
|
|
25126
|
-
|
|
25127
|
-
|
|
25128
|
-
|
|
25129
|
-
|
|
25548
|
+
toOpenAPISchema: (customOptions, direction) => {
|
|
25549
|
+
const context = {
|
|
25550
|
+
...userDefinedOptions,
|
|
25551
|
+
...customOptions,
|
|
25552
|
+
...vendor === "arktype" ? injectArktypeFallback(userDefinedOptions, customOptions) : undefined,
|
|
25553
|
+
...vendor === "zod" ? injectZodV4DateOverride(schema, userDefinedOptions, customOptions) : undefined
|
|
25554
|
+
};
|
|
25555
|
+
const directionOptions = direction === "output" ? outputOptions(schema) : undefined;
|
|
25556
|
+
return toOpenAPISchema(schema, directionOptions ? {
|
|
25557
|
+
...context,
|
|
25558
|
+
options: {
|
|
25559
|
+
...directionOptions,
|
|
25560
|
+
...context.options
|
|
25561
|
+
}
|
|
25562
|
+
} : context);
|
|
25563
|
+
}
|
|
25130
25564
|
};
|
|
25131
25565
|
}
|
|
25566
|
+
var outputOptions = (schema) => {
|
|
25567
|
+
switch (schema["~standard"].vendor) {
|
|
25568
|
+
case "zod":
|
|
25569
|
+
return "_zod" in schema ? { io: "output" } : { schemaType: "output" };
|
|
25570
|
+
case "valibot":
|
|
25571
|
+
return { typeMode: "output" };
|
|
25572
|
+
default:
|
|
25573
|
+
return;
|
|
25574
|
+
}
|
|
25575
|
+
};
|
|
25132
25576
|
function injectArktypeFallback(userDefined, custom3) {
|
|
25133
25577
|
const userNested = userDefined?.options;
|
|
25134
25578
|
const customNested = custom3?.options;
|
|
@@ -28538,12 +28982,12 @@ function createSetOperator(type, isAll) {
|
|
|
28538
28982
|
var getSQLiteSetOperators = () => ({
|
|
28539
28983
|
union: union3,
|
|
28540
28984
|
unionAll,
|
|
28541
|
-
intersect,
|
|
28985
|
+
intersect: intersect2,
|
|
28542
28986
|
except
|
|
28543
28987
|
});
|
|
28544
28988
|
var union3 = createSetOperator("union", false);
|
|
28545
28989
|
var unionAll = createSetOperator("union", true);
|
|
28546
|
-
var
|
|
28990
|
+
var intersect2 = createSetOperator("intersect", false);
|
|
28547
28991
|
var except = createSetOperator("except", false);
|
|
28548
28992
|
|
|
28549
28993
|
// ../../node_modules/.bun/drizzle-orm@0.45.4+6458dd716b2a29fa/node_modules/drizzle-orm/sqlite-core/query-builders/query-builder.js
|
|
@@ -32336,8 +32780,12 @@ function setHeaders(ctx, headersToSet) {
|
|
|
32336
32780
|
}
|
|
32337
32781
|
|
|
32338
32782
|
// src/platform/http/openapi.ts
|
|
32783
|
+
var openObjects = { options: { io: "input" } };
|
|
32339
32784
|
function jsonResponse(description, schema) {
|
|
32340
|
-
return {
|
|
32785
|
+
return {
|
|
32786
|
+
description,
|
|
32787
|
+
content: { "application/json": { schema: resolver(schema, openObjects) } }
|
|
32788
|
+
};
|
|
32341
32789
|
}
|
|
32342
32790
|
var methods = ["GET", "POST", "PUT", "PATCH", "DELETE"];
|
|
32343
32791
|
var failure2 = {
|
|
@@ -51691,12 +52139,14 @@ async function createAgents(context) {
|
|
|
51691
52139
|
}
|
|
51692
52140
|
}
|
|
51693
52141
|
async function setUpChannel({ context, channel: channel2 }) {
|
|
51694
|
-
|
|
51695
|
-
|
|
51696
|
-
|
|
51697
|
-
|
|
52142
|
+
function accountsWithout() {
|
|
52143
|
+
return context.agents.list().filter(({ id: id2 }) => !context.addresses.findByAgent({ agentId: id2, channel: channel2.kind }));
|
|
52144
|
+
}
|
|
52145
|
+
let connected = false;
|
|
52146
|
+
let agents2 = accountsWithout();
|
|
52147
|
+
while (agents2.length > 0) {
|
|
51698
52148
|
const connectNow = requireAnswer(await confirm({
|
|
51699
|
-
message: `Connect a ${channel2.name} address to an account?`,
|
|
52149
|
+
message: `Connect a ${channel2.name} address to ${connected ? "another" : "an"} account?`,
|
|
51700
52150
|
initialValue: false
|
|
51701
52151
|
}));
|
|
51702
52152
|
if (!connectNow)
|
|
@@ -51720,10 +52170,12 @@ async function setUpChannel({ context, channel: channel2 }) {
|
|
|
51720
52170
|
credentials: credentials.trim()
|
|
51721
52171
|
});
|
|
51722
52172
|
progressSpinner.stop(`${address.value} now reaches ${agent.name} on ${channel2.name}`);
|
|
52173
|
+
connected = true;
|
|
51723
52174
|
} catch (cause) {
|
|
51724
52175
|
progressSpinner.error(messageOf(cause, `Could not connect the ${channel2.name} address`));
|
|
51725
52176
|
continue;
|
|
51726
52177
|
}
|
|
52178
|
+
agents2 = accountsWithout();
|
|
51727
52179
|
const sender = requireAnswer(await text({
|
|
51728
52180
|
message: `Who may wake ${agent.name} on ${channel2.name}? Give ${channel2.senders}, or leave it empty for only the server's agents`,
|
|
51729
52181
|
defaultValue: ""
|
|
@@ -52158,5 +52610,5 @@ try {
|
|
|
52158
52610
|
process.exitCode = 1;
|
|
52159
52611
|
}
|
|
52160
52612
|
|
|
52161
|
-
//# debugId=
|
|
52613
|
+
//# debugId=E162EED6D52D865664756E2164756E21
|
|
52162
52614
|
//# sourceMappingURL=main.js.map
|