@kubb/agent 5.0.0-alpha.22 → 5.0.0-alpha.24
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/.output/nitro.json +1 -1
- package/.output/server/chunks/nitro/nitro.mjs +1238 -1032
- package/.output/server/chunks/nitro/nitro.mjs.map +1 -1
- package/.output/server/node_modules/.nitro/{picomatch@4.0.3 → picomatch@4.0.4}/lib/constants.js +4 -0
- package/.output/server/node_modules/.nitro/{picomatch@4.0.3 → picomatch@4.0.4}/lib/parse.js +301 -0
- package/.output/server/node_modules/.nitro/{picomatch@4.0.3 → picomatch@4.0.4}/lib/picomatch.js +11 -3
- package/.output/server/node_modules/.nitro/{picomatch@4.0.3 → picomatch@4.0.4}/package.json +2 -3
- package/.output/server/node_modules/@redocly/config/lib/default-theme-config-schema.js +1 -0
- package/.output/server/node_modules/@redocly/config/lib/ex-theme-config-schemas.js +6 -1
- package/.output/server/node_modules/@redocly/config/lib/root-config-schema.js +1 -1
- package/.output/server/node_modules/@redocly/config/package.json +1 -1
- package/.output/server/node_modules/@redocly/openapi-core/lib/bundle/bundle-visitor.js +1 -1
- package/.output/server/node_modules/@redocly/openapi-core/lib/bundle/bundle.js +2 -2
- package/.output/server/node_modules/@redocly/openapi-core/lib/config/bundle-extends.js +1 -0
- package/.output/server/node_modules/@redocly/openapi-core/lib/config/config-resolvers.js +14 -5
- package/.output/server/node_modules/@redocly/openapi-core/lib/lint.js +1 -1
- package/.output/server/node_modules/@redocly/openapi-core/lib/types/json-schema-draft7.shared.js +1 -1
- package/.output/server/node_modules/@redocly/openapi-core/lib/types/oas2.js +1 -1
- package/.output/server/node_modules/@redocly/openapi-core/lib/types/oas3.js +1 -1
- package/.output/server/node_modules/@redocly/openapi-core/package.json +3 -3
- package/.output/server/node_modules/handlebars/dist/cjs/handlebars/base.js +2 -2
- package/.output/server/node_modules/handlebars/dist/cjs/handlebars/compiler/base.js +60 -1
- package/.output/server/node_modules/handlebars/dist/cjs/handlebars/compiler/javascript-compiler.js +25 -17
- package/.output/server/node_modules/handlebars/dist/cjs/handlebars/compiler/parser.js +2 -2
- package/.output/server/node_modules/handlebars/dist/cjs/handlebars/helpers.js +3 -2
- package/.output/server/node_modules/handlebars/dist/cjs/handlebars/internal/proto-access.js +17 -12
- package/.output/server/node_modules/handlebars/dist/cjs/handlebars/runtime.js +25 -18
- package/.output/server/node_modules/handlebars/package.json +5 -6
- package/.output/server/package.json +4 -4
- package/package.json +17 -17
- package/.output/server/node_modules/handlebars/dist/cjs/handlebars/internal/create-new-lookup-object.js +0 -22
- /package/.output/server/node_modules/.nitro/{picomatch@4.0.3 → picomatch@4.0.4}/index.js +0 -0
- /package/.output/server/node_modules/.nitro/{picomatch@4.0.3 → picomatch@4.0.4}/lib/scan.js +0 -0
- /package/.output/server/node_modules/.nitro/{picomatch@4.0.3 → picomatch@4.0.4}/lib/utils.js +0 -0
|
@@ -7,7 +7,7 @@ import https, { Server as Server$1 } from 'node:https';
|
|
|
7
7
|
import { EventEmitter } from 'node:events';
|
|
8
8
|
import { Buffer as Buffer$1 } from 'node:buffer';
|
|
9
9
|
import fs$1, { promises, existsSync, readFileSync } from 'node:fs';
|
|
10
|
-
import path$2, { resolve, dirname, relative, join, basename,
|
|
10
|
+
import path$2, { resolve, dirname, relative, join, basename, posix, extname } from 'node:path';
|
|
11
11
|
import anymatch from 'anymatch';
|
|
12
12
|
import { createHash, randomBytes } from 'node:crypto';
|
|
13
13
|
import process$1, { version as version$2 } from 'node:process';
|
|
@@ -4595,65 +4595,7 @@ const visitorDepths = {
|
|
|
4595
4595
|
};
|
|
4596
4596
|
const schemaTypes = {
|
|
4597
4597
|
enum: "enum"};
|
|
4598
|
-
function
|
|
4599
|
-
return text.trim().replace(/([a-z\d])([A-Z])/g, "$1 $2").replace(/([A-Z]+)([A-Z][a-z])/g, "$1 $2").replace(/(\d)([a-z])/g, "$1 $2").split(/[\s\-_./\\:]+/).filter(Boolean).map((word, i) => {
|
|
4600
|
-
if (word.length > 1 && word === word.toUpperCase()) return word;
|
|
4601
|
-
if (i === 0 && true) return word.charAt(0).toLowerCase() + word.slice(1);
|
|
4602
|
-
return word.charAt(0).toUpperCase() + word.slice(1);
|
|
4603
|
-
}).join("").replace(/[^a-zA-Z0-9]/g, "");
|
|
4604
|
-
}
|
|
4605
|
-
function applyToFileParts$f(text, transformPart) {
|
|
4606
|
-
const parts = text.split(/\.(?=[a-zA-Z])/);
|
|
4607
|
-
return parts.map((part, i) => transformPart(part, i === parts.length - 1)).join("/");
|
|
4608
|
-
}
|
|
4609
|
-
function camelCase$f(text, { isFile, prefix = "", suffix = "" } = {}) {
|
|
4610
|
-
if (isFile) return applyToFileParts$f(text, (part, isLast) => camelCase$f(part, isLast ? {
|
|
4611
|
-
prefix,
|
|
4612
|
-
suffix
|
|
4613
|
-
} : {}));
|
|
4614
|
-
return toCamelOrPascal$f(`${prefix} ${text} ${suffix}`);
|
|
4615
|
-
}
|
|
4616
|
-
function isValidVarName$c(name) {
|
|
4617
|
-
try {
|
|
4618
|
-
new Function(`var ${name}`);
|
|
4619
|
-
} catch {
|
|
4620
|
-
return false;
|
|
4621
|
-
}
|
|
4622
|
-
return true;
|
|
4623
|
-
}
|
|
4624
|
-
function narrowSchema(node, type) {
|
|
4625
|
-
return (node == null ? void 0 : node.type) === type ? node : void 0;
|
|
4626
|
-
}
|
|
4627
|
-
function isKind(kind) {
|
|
4628
|
-
return (node) => node.kind === kind;
|
|
4629
|
-
}
|
|
4630
|
-
const isOperationNode = isKind("Operation");
|
|
4631
|
-
const isSchemaNode = isKind("Schema");
|
|
4632
|
-
const plainStringTypes = /* @__PURE__ */ new Set([
|
|
4633
|
-
"string",
|
|
4634
|
-
"uuid",
|
|
4635
|
-
"email",
|
|
4636
|
-
"url",
|
|
4637
|
-
"datetime"
|
|
4638
|
-
]);
|
|
4639
|
-
function isStringType(node) {
|
|
4640
|
-
var _a;
|
|
4641
|
-
if (plainStringTypes.has(node.type)) return true;
|
|
4642
|
-
const temporal = (_a = narrowSchema(node, "date")) != null ? _a : narrowSchema(node, "time");
|
|
4643
|
-
if (temporal) return temporal.representation !== "date";
|
|
4644
|
-
return false;
|
|
4645
|
-
}
|
|
4646
|
-
function caseParams(params, casing) {
|
|
4647
|
-
if (!casing) return params;
|
|
4648
|
-
return params.map((param) => {
|
|
4649
|
-
const transformed = casing === "camelcase" || !isValidVarName$c(param.name) ? camelCase$f(param.name) : param.name;
|
|
4650
|
-
return {
|
|
4651
|
-
...param,
|
|
4652
|
-
name: transformed
|
|
4653
|
-
};
|
|
4654
|
-
});
|
|
4655
|
-
}
|
|
4656
|
-
function syncOptionality(required, schema) {
|
|
4598
|
+
function syncOptionality(schema, required) {
|
|
4657
4599
|
var _a;
|
|
4658
4600
|
const nullable = (_a = schema.nullable) != null ? _a : false;
|
|
4659
4601
|
return {
|
|
@@ -4680,7 +4622,7 @@ function createProperty(props) {
|
|
|
4680
4622
|
...props,
|
|
4681
4623
|
kind: "Property",
|
|
4682
4624
|
required,
|
|
4683
|
-
schema: syncOptionality(
|
|
4625
|
+
schema: syncOptionality(props.schema, required)
|
|
4684
4626
|
};
|
|
4685
4627
|
}
|
|
4686
4628
|
function createParameter(props) {
|
|
@@ -4690,9 +4632,43 @@ function createParameter(props) {
|
|
|
4690
4632
|
...props,
|
|
4691
4633
|
kind: "Parameter",
|
|
4692
4634
|
required,
|
|
4693
|
-
schema: syncOptionality(
|
|
4635
|
+
schema: syncOptionality(props.schema, required)
|
|
4636
|
+
};
|
|
4637
|
+
}
|
|
4638
|
+
function createFunctionParameter(props) {
|
|
4639
|
+
return {
|
|
4640
|
+
optional: false,
|
|
4641
|
+
...props,
|
|
4642
|
+
kind: "FunctionParameter"
|
|
4643
|
+
};
|
|
4644
|
+
}
|
|
4645
|
+
function createTypeNode(props) {
|
|
4646
|
+
return {
|
|
4647
|
+
...props,
|
|
4648
|
+
kind: "Type"
|
|
4649
|
+
};
|
|
4650
|
+
}
|
|
4651
|
+
function createParameterGroup(props) {
|
|
4652
|
+
return {
|
|
4653
|
+
...props,
|
|
4654
|
+
kind: "ParameterGroup"
|
|
4694
4655
|
};
|
|
4695
4656
|
}
|
|
4657
|
+
function createFunctionParameters(props = {}) {
|
|
4658
|
+
return {
|
|
4659
|
+
params: [],
|
|
4660
|
+
...props,
|
|
4661
|
+
kind: "FunctionParameters"
|
|
4662
|
+
};
|
|
4663
|
+
}
|
|
4664
|
+
function narrowSchema(node, type) {
|
|
4665
|
+
return (node == null ? void 0 : node.type) === type ? node : void 0;
|
|
4666
|
+
}
|
|
4667
|
+
function isKind(kind) {
|
|
4668
|
+
return (node) => node.kind === kind;
|
|
4669
|
+
}
|
|
4670
|
+
const isOperationNode = isKind("Operation");
|
|
4671
|
+
const isSchemaNode = isKind("Schema");
|
|
4696
4672
|
function definePrinter(build) {
|
|
4697
4673
|
return createPrinterFactory((node) => node.type)(build);
|
|
4698
4674
|
}
|
|
@@ -4719,6 +4695,32 @@ function createPrinterFactory(getKey) {
|
|
|
4719
4695
|
};
|
|
4720
4696
|
};
|
|
4721
4697
|
}
|
|
4698
|
+
function toCamelOrPascal$f(text, pascal) {
|
|
4699
|
+
return text.trim().replace(/([a-z\d])([A-Z])/g, "$1 $2").replace(/([A-Z]+)([A-Z][a-z])/g, "$1 $2").replace(/(\d)([a-z])/g, "$1 $2").split(/[\s\-_./\\:]+/).filter(Boolean).map((word, i) => {
|
|
4700
|
+
if (word.length > 1 && word === word.toUpperCase()) return word;
|
|
4701
|
+
if (i === 0 && true) return word.charAt(0).toLowerCase() + word.slice(1);
|
|
4702
|
+
return word.charAt(0).toUpperCase() + word.slice(1);
|
|
4703
|
+
}).join("").replace(/[^a-zA-Z0-9]/g, "");
|
|
4704
|
+
}
|
|
4705
|
+
function applyToFileParts$f(text, transformPart) {
|
|
4706
|
+
const parts = text.split(/\.(?=[a-zA-Z])/);
|
|
4707
|
+
return parts.map((part, i) => transformPart(part, i === parts.length - 1)).join("/");
|
|
4708
|
+
}
|
|
4709
|
+
function camelCase$f(text, { isFile, prefix = "", suffix = "" } = {}) {
|
|
4710
|
+
if (isFile) return applyToFileParts$f(text, (part, isLast) => camelCase$f(part, isLast ? {
|
|
4711
|
+
prefix,
|
|
4712
|
+
suffix
|
|
4713
|
+
} : {}));
|
|
4714
|
+
return toCamelOrPascal$f(`${prefix} ${text} ${suffix}`);
|
|
4715
|
+
}
|
|
4716
|
+
function isValidVarName$c(name) {
|
|
4717
|
+
try {
|
|
4718
|
+
new Function(`var ${name}`);
|
|
4719
|
+
} catch {
|
|
4720
|
+
return false;
|
|
4721
|
+
}
|
|
4722
|
+
return true;
|
|
4723
|
+
}
|
|
4722
4724
|
function createLimit(concurrency) {
|
|
4723
4725
|
let active = 0;
|
|
4724
4726
|
const queue = [];
|
|
@@ -4767,8 +4769,9 @@ function getChildren(node, recurse) {
|
|
|
4767
4769
|
case "Response":
|
|
4768
4770
|
return node.schema ? [node.schema] : [];
|
|
4769
4771
|
case "FunctionParameter":
|
|
4770
|
-
case "
|
|
4772
|
+
case "ParameterGroup":
|
|
4771
4773
|
case "FunctionParameters":
|
|
4774
|
+
case "Type":
|
|
4772
4775
|
return [];
|
|
4773
4776
|
}
|
|
4774
4777
|
}
|
|
@@ -4915,8 +4918,9 @@ function transform(node, options) {
|
|
|
4915
4918
|
};
|
|
4916
4919
|
}
|
|
4917
4920
|
case "FunctionParameter":
|
|
4918
|
-
case "
|
|
4921
|
+
case "ParameterGroup":
|
|
4919
4922
|
case "FunctionParameters":
|
|
4923
|
+
case "Type":
|
|
4920
4924
|
return node;
|
|
4921
4925
|
}
|
|
4922
4926
|
}
|
|
@@ -4993,12 +4997,228 @@ function collect(node, options) {
|
|
|
4993
4997
|
})) results.push(item);
|
|
4994
4998
|
return results;
|
|
4995
4999
|
}
|
|
5000
|
+
const plainStringTypes = /* @__PURE__ */ new Set([
|
|
5001
|
+
"string",
|
|
5002
|
+
"uuid",
|
|
5003
|
+
"email",
|
|
5004
|
+
"url",
|
|
5005
|
+
"datetime"
|
|
5006
|
+
]);
|
|
5007
|
+
function isStringType(node) {
|
|
5008
|
+
var _a;
|
|
5009
|
+
if (plainStringTypes.has(node.type)) return true;
|
|
5010
|
+
const temporal = (_a = narrowSchema(node, "date")) != null ? _a : narrowSchema(node, "time");
|
|
5011
|
+
if (temporal) return temporal.representation !== "date";
|
|
5012
|
+
return false;
|
|
5013
|
+
}
|
|
5014
|
+
function caseParams(params, casing) {
|
|
5015
|
+
if (!casing) return params;
|
|
5016
|
+
return params.map((param) => {
|
|
5017
|
+
const transformed = casing === "camelcase" || !isValidVarName$c(param.name) ? camelCase$f(param.name) : param.name;
|
|
5018
|
+
return {
|
|
5019
|
+
...param,
|
|
5020
|
+
name: transformed
|
|
5021
|
+
};
|
|
5022
|
+
});
|
|
5023
|
+
}
|
|
5024
|
+
function resolveType({ node, param, resolver }) {
|
|
5025
|
+
var _a;
|
|
5026
|
+
if (!resolver) return createTypeNode({
|
|
5027
|
+
variant: "reference",
|
|
5028
|
+
name: (_a = param.schema.primitive) != null ? _a : "unknown"
|
|
5029
|
+
});
|
|
5030
|
+
const individualName = resolver.resolveParamName(node, param);
|
|
5031
|
+
const groupLocation = param.in === "path" || param.in === "query" || param.in === "header" ? param.in : void 0;
|
|
5032
|
+
const groupResolvers = {
|
|
5033
|
+
path: resolver.resolvePathParamsName,
|
|
5034
|
+
query: resolver.resolveQueryParamsName,
|
|
5035
|
+
header: resolver.resolveHeaderParamsName
|
|
5036
|
+
};
|
|
5037
|
+
const groupName = groupLocation ? groupResolvers[groupLocation].call(resolver, node, param) : void 0;
|
|
5038
|
+
if (groupName && groupName !== individualName) return createTypeNode({
|
|
5039
|
+
variant: "member",
|
|
5040
|
+
base: groupName,
|
|
5041
|
+
key: param.name
|
|
5042
|
+
});
|
|
5043
|
+
return createTypeNode({
|
|
5044
|
+
variant: "reference",
|
|
5045
|
+
name: individualName
|
|
5046
|
+
});
|
|
5047
|
+
}
|
|
5048
|
+
function createOperationParams(node, options) {
|
|
5049
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i;
|
|
5050
|
+
const { paramsType, pathParamsType, paramsCasing, resolver, pathParamsDefault, extraParams = [], paramNames, typeWrapper } = options;
|
|
5051
|
+
const dataName = (_a = paramNames == null ? void 0 : paramNames.data) != null ? _a : "data";
|
|
5052
|
+
const paramsName = (_b = paramNames == null ? void 0 : paramNames.params) != null ? _b : "params";
|
|
5053
|
+
const headersName = (_c = paramNames == null ? void 0 : paramNames.headers) != null ? _c : "headers";
|
|
5054
|
+
const pathName = (_d = paramNames == null ? void 0 : paramNames.path) != null ? _d : "pathParams";
|
|
5055
|
+
const wrapType = (type) => createTypeNode({
|
|
5056
|
+
variant: "reference",
|
|
5057
|
+
name: typeWrapper ? typeWrapper(type) : type
|
|
5058
|
+
});
|
|
5059
|
+
const wrapTypeNode = (type) => type.variant === "reference" ? wrapType(type.name) : type;
|
|
5060
|
+
const casedParams = caseParams(node.parameters, paramsCasing);
|
|
5061
|
+
const pathParams = casedParams.filter((p) => p.in === "path");
|
|
5062
|
+
const queryParams = casedParams.filter((p) => p.in === "query");
|
|
5063
|
+
const headerParams = casedParams.filter((p) => p.in === "header");
|
|
5064
|
+
const bodyType = ((_e = node.requestBody) == null ? void 0 : _e.schema) ? wrapType((_f = resolver == null ? void 0 : resolver.resolveDataName(node)) != null ? _f : "unknown") : void 0;
|
|
5065
|
+
const bodyRequired = (_h = (_g = node.requestBody) == null ? void 0 : _g.required) != null ? _h : false;
|
|
5066
|
+
const queryGroupType = resolver ? resolveGroupType({
|
|
5067
|
+
node,
|
|
5068
|
+
params: queryParams,
|
|
5069
|
+
groupMethod: resolver.resolveQueryParamsName,
|
|
5070
|
+
resolver
|
|
5071
|
+
}) : void 0;
|
|
5072
|
+
const headerGroupType = resolver ? resolveGroupType({
|
|
5073
|
+
node,
|
|
5074
|
+
params: headerParams,
|
|
5075
|
+
groupMethod: resolver.resolveHeaderParamsName,
|
|
5076
|
+
resolver
|
|
5077
|
+
}) : void 0;
|
|
5078
|
+
const params = [];
|
|
5079
|
+
if (paramsType === "object") {
|
|
5080
|
+
const children = [
|
|
5081
|
+
...pathParams.map((p) => {
|
|
5082
|
+
const type = resolveType({
|
|
5083
|
+
node,
|
|
5084
|
+
param: p,
|
|
5085
|
+
resolver
|
|
5086
|
+
});
|
|
5087
|
+
return createFunctionParameter({
|
|
5088
|
+
name: p.name,
|
|
5089
|
+
type: wrapTypeNode(type),
|
|
5090
|
+
optional: !p.required
|
|
5091
|
+
});
|
|
5092
|
+
}),
|
|
5093
|
+
...bodyType ? [createFunctionParameter({
|
|
5094
|
+
name: dataName,
|
|
5095
|
+
type: bodyType,
|
|
5096
|
+
optional: !bodyRequired
|
|
5097
|
+
})] : [],
|
|
5098
|
+
...buildGroupParam({
|
|
5099
|
+
name: paramsName,
|
|
5100
|
+
node,
|
|
5101
|
+
params: queryParams,
|
|
5102
|
+
groupType: queryGroupType,
|
|
5103
|
+
resolver,
|
|
5104
|
+
wrapType
|
|
5105
|
+
}),
|
|
5106
|
+
...buildGroupParam({
|
|
5107
|
+
name: headersName,
|
|
5108
|
+
node,
|
|
5109
|
+
params: headerParams,
|
|
5110
|
+
groupType: headerGroupType,
|
|
5111
|
+
resolver,
|
|
5112
|
+
wrapType
|
|
5113
|
+
})
|
|
5114
|
+
];
|
|
5115
|
+
if (children.length) params.push(createParameterGroup({
|
|
5116
|
+
properties: children,
|
|
5117
|
+
default: children.every((c) => c.optional) ? "{}" : void 0
|
|
5118
|
+
}));
|
|
5119
|
+
} else {
|
|
5120
|
+
if (pathParams.length) if (pathParamsType === "inlineSpread") {
|
|
5121
|
+
const spreadType = (_i = resolver == null ? void 0 : resolver.resolvePathParamsName(node, pathParams[0])) != null ? _i : void 0;
|
|
5122
|
+
params.push(createFunctionParameter({
|
|
5123
|
+
name: pathName,
|
|
5124
|
+
type: spreadType ? wrapType(spreadType) : void 0,
|
|
5125
|
+
rest: true
|
|
5126
|
+
}));
|
|
5127
|
+
} else {
|
|
5128
|
+
const pathChildren = pathParams.map((p) => {
|
|
5129
|
+
const type = resolveType({
|
|
5130
|
+
node,
|
|
5131
|
+
param: p,
|
|
5132
|
+
resolver
|
|
5133
|
+
});
|
|
5134
|
+
return createFunctionParameter({
|
|
5135
|
+
name: p.name,
|
|
5136
|
+
type: wrapTypeNode(type),
|
|
5137
|
+
optional: !p.required
|
|
5138
|
+
});
|
|
5139
|
+
});
|
|
5140
|
+
params.push(createParameterGroup({
|
|
5141
|
+
properties: pathChildren,
|
|
5142
|
+
inline: pathParamsType === "inline",
|
|
5143
|
+
default: pathParamsDefault != null ? pathParamsDefault : pathChildren.every((c) => c.optional) ? "{}" : void 0
|
|
5144
|
+
}));
|
|
5145
|
+
}
|
|
5146
|
+
if (bodyType) params.push(createFunctionParameter({
|
|
5147
|
+
name: dataName,
|
|
5148
|
+
type: bodyType,
|
|
5149
|
+
optional: !bodyRequired
|
|
5150
|
+
}));
|
|
5151
|
+
params.push(...buildGroupParam({
|
|
5152
|
+
name: paramsName,
|
|
5153
|
+
node,
|
|
5154
|
+
params: queryParams,
|
|
5155
|
+
groupType: queryGroupType,
|
|
5156
|
+
resolver,
|
|
5157
|
+
wrapType
|
|
5158
|
+
}));
|
|
5159
|
+
params.push(...buildGroupParam({
|
|
5160
|
+
name: headersName,
|
|
5161
|
+
node,
|
|
5162
|
+
params: headerParams,
|
|
5163
|
+
groupType: headerGroupType,
|
|
5164
|
+
resolver,
|
|
5165
|
+
wrapType
|
|
5166
|
+
}));
|
|
5167
|
+
}
|
|
5168
|
+
params.push(...extraParams);
|
|
5169
|
+
return createFunctionParameters({ params });
|
|
5170
|
+
}
|
|
5171
|
+
function buildGroupParam({ name, node, params, groupType, resolver, wrapType }) {
|
|
5172
|
+
if (groupType) return [createFunctionParameter({
|
|
5173
|
+
name,
|
|
5174
|
+
type: groupType.type.variant === "reference" ? wrapType(groupType.type.name) : groupType.type,
|
|
5175
|
+
optional: groupType.optional
|
|
5176
|
+
})];
|
|
5177
|
+
if (params.length) return [createFunctionParameter({
|
|
5178
|
+
name,
|
|
5179
|
+
type: toStructType({
|
|
5180
|
+
node,
|
|
5181
|
+
params,
|
|
5182
|
+
resolver
|
|
5183
|
+
}),
|
|
5184
|
+
optional: params.every((p) => !p.required)
|
|
5185
|
+
})];
|
|
5186
|
+
return [];
|
|
5187
|
+
}
|
|
5188
|
+
function resolveGroupType({ node, params, groupMethod, resolver }) {
|
|
5189
|
+
if (!params.length) return;
|
|
5190
|
+
const firstParam = params[0];
|
|
5191
|
+
const groupName = groupMethod.call(resolver, node, firstParam);
|
|
5192
|
+
if (groupName === resolver.resolveParamName(node, firstParam)) return;
|
|
5193
|
+
const allOptional = params.every((p) => !p.required);
|
|
5194
|
+
return {
|
|
5195
|
+
type: createTypeNode({
|
|
5196
|
+
variant: "reference",
|
|
5197
|
+
name: groupName
|
|
5198
|
+
}),
|
|
5199
|
+
optional: allOptional
|
|
5200
|
+
};
|
|
5201
|
+
}
|
|
5202
|
+
function toStructType({ node, params, resolver }) {
|
|
5203
|
+
return createTypeNode({
|
|
5204
|
+
variant: "struct",
|
|
5205
|
+
properties: params.map((p) => ({
|
|
5206
|
+
name: p.name,
|
|
5207
|
+
optional: !p.required,
|
|
5208
|
+
type: resolveType({
|
|
5209
|
+
node,
|
|
5210
|
+
param: p,
|
|
5211
|
+
resolver
|
|
5212
|
+
})
|
|
5213
|
+
}))
|
|
5214
|
+
});
|
|
5215
|
+
}
|
|
4996
5216
|
|
|
4997
|
-
var __defProp$
|
|
5217
|
+
var __defProp$h = Object.defineProperty;
|
|
4998
5218
|
var __typeError$c = (msg) => {
|
|
4999
5219
|
throw TypeError(msg);
|
|
5000
5220
|
};
|
|
5001
|
-
var __defNormalProp$b = (obj, key, value) => key in obj ? __defProp$
|
|
5221
|
+
var __defNormalProp$b = (obj, key, value) => key in obj ? __defProp$h(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
5002
5222
|
var __publicField$b = (obj, key, value) => __defNormalProp$b(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
5003
5223
|
var __accessCheck$c = (obj, member, msg) => member.has(obj) || __typeError$c("Cannot " + msg);
|
|
5004
5224
|
var __privateGet$c = (obj, member, getter) => (__accessCheck$c(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
|
|
@@ -5013,9 +5233,7 @@ var __privateWrapper$1 = (obj, member, setter, getter) => ({
|
|
|
5013
5233
|
return __privateGet$c(obj, member, getter);
|
|
5014
5234
|
}
|
|
5015
5235
|
});
|
|
5016
|
-
var _emitter, _a$c, _options$c, _URLPath_instances$a, transformParam_fn$a, eachParam_fn$a, _b$2, _head$1, _tail$1, _size$1, _c, _studioIsOpen,
|
|
5017
|
-
var ValidationPluginError = class extends Error {
|
|
5018
|
-
};
|
|
5236
|
+
var _emitter, _a$c, _options$c, _URLPath_instances$a, transformParam_fn$a, eachParam_fn$a, _b$2, _head$1, _tail$1, _size$1, _c, _studioIsOpen, _PluginDriver_instances, emitProcessingEnd_fn, execute_fn, executeSync_fn, _d, _items, _FunctionParams_static, _e, orderItems_fn, addParams_fn, _cachedLeaves, _f;
|
|
5019
5237
|
function toError(value) {
|
|
5020
5238
|
return value instanceof Error ? value : new Error(String(value));
|
|
5021
5239
|
}
|
|
@@ -5190,15 +5408,6 @@ async function clean(path2) {
|
|
|
5190
5408
|
force: true
|
|
5191
5409
|
});
|
|
5192
5410
|
}
|
|
5193
|
-
function setUniqueName(originalName, data) {
|
|
5194
|
-
let used = data[originalName] || 0;
|
|
5195
|
-
if (used) {
|
|
5196
|
-
data[originalName] = ++used;
|
|
5197
|
-
return originalName;
|
|
5198
|
-
}
|
|
5199
|
-
data[originalName] = 1;
|
|
5200
|
-
return originalName;
|
|
5201
|
-
}
|
|
5202
5411
|
function isPromiseRejectedResult(result) {
|
|
5203
5412
|
return result.status === "rejected";
|
|
5204
5413
|
}
|
|
@@ -5674,8 +5883,10 @@ var PluginDriver = (_d = class {
|
|
|
5674
5883
|
__publicField$b(this, "rootNode");
|
|
5675
5884
|
__publicField$b(this, "adapter");
|
|
5676
5885
|
__privateAdd$c(this, _studioIsOpen, false);
|
|
5677
|
-
|
|
5678
|
-
|
|
5886
|
+
__publicField$b(this, "plugins", /* @__PURE__ */ new Map());
|
|
5887
|
+
/**
|
|
5888
|
+
* @deprecated use resolvers context instead
|
|
5889
|
+
*/
|
|
5679
5890
|
__publicField$b(this, "resolvePath", (params) => {
|
|
5680
5891
|
var _a2, _b2;
|
|
5681
5892
|
const defaultPath = resolve(resolve(this.config.root, this.config.output.path), params.baseName);
|
|
@@ -5697,42 +5908,46 @@ var PluginDriver = (_d = class {
|
|
|
5697
5908
|
]
|
|
5698
5909
|
})) == null ? void 0 : _b2.result) || defaultPath;
|
|
5699
5910
|
});
|
|
5911
|
+
/**
|
|
5912
|
+
* @deprecated use resolvers context instead
|
|
5913
|
+
*/
|
|
5700
5914
|
__publicField$b(this, "resolveName", (params) => {
|
|
5701
|
-
var _a2;
|
|
5702
|
-
if (params.pluginName) {
|
|
5703
|
-
|
|
5704
|
-
|
|
5705
|
-
|
|
5706
|
-
|
|
5707
|
-
|
|
5708
|
-
return transformReservedWord([...new Set(names)].at(0) || params.name);
|
|
5709
|
-
}
|
|
5710
|
-
const name = (_a2 = this.hookFirstSync({
|
|
5915
|
+
var _a2, _b2, _c2;
|
|
5916
|
+
if (params.pluginName) return transformReservedWord((_b2 = (_a2 = this.hookForPluginSync({
|
|
5917
|
+
pluginName: params.pluginName,
|
|
5918
|
+
hookName: "resolveName",
|
|
5919
|
+
parameters: [params.name.trim(), params.type]
|
|
5920
|
+
})) == null ? void 0 : _a2.at(0)) != null ? _b2 : params.name);
|
|
5921
|
+
const name = (_c2 = this.hookFirstSync({
|
|
5711
5922
|
hookName: "resolveName",
|
|
5712
5923
|
parameters: [params.name.trim(), params.type]
|
|
5713
|
-
})) == null ? void 0 :
|
|
5924
|
+
})) == null ? void 0 : _c2.result;
|
|
5714
5925
|
return transformReservedWord(name != null ? name : params.name);
|
|
5715
5926
|
});
|
|
5716
5927
|
this.config = config;
|
|
5717
5928
|
this.options = options;
|
|
5718
|
-
|
|
5719
|
-
|
|
5720
|
-
|
|
5929
|
+
config.plugins.map((plugin) => Object.assign({ install() {
|
|
5930
|
+
} }, plugin)).sort((a, b) => {
|
|
5931
|
+
var _a2, _b2;
|
|
5932
|
+
if ((_a2 = b.pre) == null ? void 0 : _a2.includes(a.name)) return 1;
|
|
5933
|
+
if ((_b2 = b.post) == null ? void 0 : _b2.includes(a.name)) return -1;
|
|
5934
|
+
return 0;
|
|
5935
|
+
}).forEach((plugin) => {
|
|
5936
|
+
this.plugins.set(plugin.name, plugin);
|
|
5721
5937
|
});
|
|
5722
5938
|
}
|
|
5723
5939
|
get events() {
|
|
5724
5940
|
return this.options.events;
|
|
5725
5941
|
}
|
|
5726
5942
|
getContext(plugin) {
|
|
5727
|
-
const plugins = [...__privateGet$c(this, _plugins)];
|
|
5728
5943
|
const driver = this;
|
|
5729
5944
|
const baseContext = {
|
|
5730
|
-
fabric:
|
|
5731
|
-
config:
|
|
5945
|
+
fabric: driver.options.fabric,
|
|
5946
|
+
config: driver.config,
|
|
5732
5947
|
plugin,
|
|
5733
|
-
|
|
5734
|
-
|
|
5735
|
-
|
|
5948
|
+
getPlugin: driver.getPlugin.bind(driver),
|
|
5949
|
+
events: driver.options.events,
|
|
5950
|
+
driver,
|
|
5736
5951
|
addFile: async (...files) => {
|
|
5737
5952
|
await this.options.fabric.addFile(...files);
|
|
5738
5953
|
},
|
|
@@ -5745,6 +5960,9 @@ var PluginDriver = (_d = class {
|
|
|
5745
5960
|
get adapter() {
|
|
5746
5961
|
return driver.adapter;
|
|
5747
5962
|
},
|
|
5963
|
+
get resolver() {
|
|
5964
|
+
return plugin.resolver;
|
|
5965
|
+
},
|
|
5748
5966
|
openInStudio(options) {
|
|
5749
5967
|
var _a2, _b2;
|
|
5750
5968
|
if (!driver.config.devtools || __privateGet$c(driver, _studioIsOpen)) return;
|
|
@@ -5756,8 +5974,8 @@ var PluginDriver = (_d = class {
|
|
|
5756
5974
|
}
|
|
5757
5975
|
};
|
|
5758
5976
|
const mergedExtras = {};
|
|
5759
|
-
for (const
|
|
5760
|
-
const result =
|
|
5977
|
+
for (const plugin2 of this.plugins.values()) if (typeof plugin2.inject === "function") {
|
|
5978
|
+
const result = plugin2.inject.call(baseContext, baseContext);
|
|
5761
5979
|
if (result !== null && typeof result === "object") Object.assign(mergedExtras, result);
|
|
5762
5980
|
}
|
|
5763
5981
|
return {
|
|
@@ -5765,9 +5983,9 @@ var PluginDriver = (_d = class {
|
|
|
5765
5983
|
...mergedExtras
|
|
5766
5984
|
};
|
|
5767
5985
|
}
|
|
5768
|
-
|
|
5769
|
-
|
|
5770
|
-
|
|
5986
|
+
/**
|
|
5987
|
+
* @deprecated use resolvers context instead
|
|
5988
|
+
*/
|
|
5771
5989
|
getFile({ name, mode, extname: extname2, pluginName, options }) {
|
|
5772
5990
|
const resolvedName = mode ? mode === "single" ? "" : this.resolveName({
|
|
5773
5991
|
name,
|
|
@@ -5794,44 +6012,41 @@ var PluginDriver = (_d = class {
|
|
|
5794
6012
|
* Run a specific hookName for plugin x.
|
|
5795
6013
|
*/
|
|
5796
6014
|
async hookForPlugin({ pluginName, hookName, parameters }) {
|
|
5797
|
-
const
|
|
6015
|
+
const plugin = this.plugins.get(pluginName);
|
|
6016
|
+
if (!plugin) return [null];
|
|
5798
6017
|
this.events.emit("plugins:hook:progress:start", {
|
|
5799
6018
|
hookName,
|
|
5800
|
-
plugins
|
|
6019
|
+
plugins: [plugin]
|
|
6020
|
+
});
|
|
6021
|
+
const result = await __privateMethod$c(this, _PluginDriver_instances, execute_fn).call(this, {
|
|
6022
|
+
strategy: "hookFirst",
|
|
6023
|
+
hookName,
|
|
6024
|
+
parameters,
|
|
6025
|
+
plugin
|
|
5801
6026
|
});
|
|
5802
|
-
const items = [];
|
|
5803
|
-
for (const plugin of plugins) {
|
|
5804
|
-
const result = await __privateMethod$c(this, _PluginDriver_instances, execute_fn).call(this, {
|
|
5805
|
-
strategy: "hookFirst",
|
|
5806
|
-
hookName,
|
|
5807
|
-
parameters,
|
|
5808
|
-
plugin
|
|
5809
|
-
});
|
|
5810
|
-
if (result !== void 0 && result !== null) items.push(result);
|
|
5811
|
-
}
|
|
5812
6027
|
this.events.emit("plugins:hook:progress:end", { hookName });
|
|
5813
|
-
return
|
|
6028
|
+
return [result];
|
|
5814
6029
|
}
|
|
5815
6030
|
/**
|
|
5816
6031
|
* Run a specific hookName for plugin x.
|
|
5817
6032
|
*/
|
|
5818
6033
|
hookForPluginSync({ pluginName, hookName, parameters }) {
|
|
5819
|
-
|
|
5820
|
-
|
|
5821
|
-
|
|
5822
|
-
|
|
5823
|
-
|
|
5824
|
-
|
|
5825
|
-
|
|
5826
|
-
})
|
|
6034
|
+
const plugin = this.plugins.get(pluginName);
|
|
6035
|
+
if (!plugin) return null;
|
|
6036
|
+
const result = __privateMethod$c(this, _PluginDriver_instances, executeSync_fn).call(this, {
|
|
6037
|
+
strategy: "hookFirst",
|
|
6038
|
+
hookName,
|
|
6039
|
+
parameters,
|
|
6040
|
+
plugin
|
|
6041
|
+
});
|
|
6042
|
+
return result !== null ? [result] : [];
|
|
5827
6043
|
}
|
|
5828
6044
|
/**
|
|
5829
6045
|
* Returns the first non-null result.
|
|
5830
6046
|
*/
|
|
5831
6047
|
async hookFirst({ hookName, parameters, skipped }) {
|
|
5832
|
-
const plugins =
|
|
5833
|
-
|
|
5834
|
-
});
|
|
6048
|
+
const plugins = [];
|
|
6049
|
+
for (const plugin of this.plugins.values()) if (hookName in plugin && (skipped ? !skipped.has(plugin) : true)) plugins.push(plugin);
|
|
5835
6050
|
this.events.emit("plugins:hook:progress:start", {
|
|
5836
6051
|
hookName,
|
|
5837
6052
|
plugins
|
|
@@ -5858,10 +6073,9 @@ var PluginDriver = (_d = class {
|
|
|
5858
6073
|
*/
|
|
5859
6074
|
hookFirstSync({ hookName, parameters, skipped }) {
|
|
5860
6075
|
let parseResult = null;
|
|
5861
|
-
const
|
|
5862
|
-
|
|
5863
|
-
|
|
5864
|
-
for (const plugin of plugins) {
|
|
6076
|
+
for (const plugin of this.plugins.values()) {
|
|
6077
|
+
if (!(hookName in plugin)) continue;
|
|
6078
|
+
if (skipped == null ? void 0 : skipped.has(plugin)) continue;
|
|
5865
6079
|
parseResult = {
|
|
5866
6080
|
result: __privateMethod$c(this, _PluginDriver_instances, executeSync_fn).call(this, {
|
|
5867
6081
|
strategy: "hookFirst",
|
|
@@ -5871,7 +6085,7 @@ var PluginDriver = (_d = class {
|
|
|
5871
6085
|
}),
|
|
5872
6086
|
plugin
|
|
5873
6087
|
};
|
|
5874
|
-
if (
|
|
6088
|
+
if (parseResult.result != null) break;
|
|
5875
6089
|
}
|
|
5876
6090
|
return parseResult;
|
|
5877
6091
|
}
|
|
@@ -5879,7 +6093,8 @@ var PluginDriver = (_d = class {
|
|
|
5879
6093
|
* Runs all plugins in parallel based on `this.plugin` order and `pre`/`post` settings.
|
|
5880
6094
|
*/
|
|
5881
6095
|
async hookParallel({ hookName, parameters }) {
|
|
5882
|
-
const plugins =
|
|
6096
|
+
const plugins = [];
|
|
6097
|
+
for (const plugin of this.plugins.values()) if (hookName in plugin) plugins.push(plugin);
|
|
5883
6098
|
this.events.emit("plugins:hook:progress:start", {
|
|
5884
6099
|
hookName,
|
|
5885
6100
|
plugins
|
|
@@ -5899,7 +6114,7 @@ var PluginDriver = (_d = class {
|
|
|
5899
6114
|
results.forEach((result, index) => {
|
|
5900
6115
|
var _a2;
|
|
5901
6116
|
if (isPromiseRejectedResult(result)) {
|
|
5902
|
-
const plugin =
|
|
6117
|
+
const plugin = plugins[index];
|
|
5903
6118
|
if (plugin) {
|
|
5904
6119
|
const startTime = (_a2 = pluginStartTimes.get(plugin)) != null ? _a2 : performance$1.now();
|
|
5905
6120
|
this.events.emit("error", result.reason, {
|
|
@@ -5922,7 +6137,8 @@ var PluginDriver = (_d = class {
|
|
|
5922
6137
|
* Chains plugins
|
|
5923
6138
|
*/
|
|
5924
6139
|
async hookSeq({ hookName, parameters }) {
|
|
5925
|
-
const plugins =
|
|
6140
|
+
const plugins = [];
|
|
6141
|
+
for (const plugin of this.plugins.values()) if (hookName in plugin) plugins.push(plugin);
|
|
5926
6142
|
this.events.emit("plugins:hook:progress:start", {
|
|
5927
6143
|
hookName,
|
|
5928
6144
|
plugins
|
|
@@ -5937,35 +6153,10 @@ var PluginDriver = (_d = class {
|
|
|
5937
6153
|
}));
|
|
5938
6154
|
this.events.emit("plugins:hook:progress:end", { hookName });
|
|
5939
6155
|
}
|
|
5940
|
-
|
|
5941
|
-
return
|
|
6156
|
+
getPlugin(pluginName) {
|
|
6157
|
+
return this.plugins.get(pluginName);
|
|
5942
6158
|
}
|
|
5943
|
-
|
|
5944
|
-
const plugins = [...this.plugins];
|
|
5945
|
-
const pluginByPluginName = plugins.filter((plugin) => hookName in plugin).filter((item) => item.name === pluginName);
|
|
5946
|
-
if (!(pluginByPluginName == null ? void 0 : pluginByPluginName.length)) {
|
|
5947
|
-
const corePlugin = plugins.find((plugin) => plugin.name === "core" && hookName in plugin);
|
|
5948
|
-
return corePlugin ? [corePlugin] : [];
|
|
5949
|
-
}
|
|
5950
|
-
return pluginByPluginName;
|
|
5951
|
-
}
|
|
5952
|
-
}, _studioIsOpen = new WeakMap(), _plugins = new WeakMap(), _usedPluginNames = new WeakMap(), _PluginDriver_instances = new WeakSet(), getSortedPlugins_fn = function(hookName) {
|
|
5953
|
-
const plugins = [...__privateGet$c(this, _plugins)];
|
|
5954
|
-
if (hookName) return plugins.filter((plugin) => hookName in plugin);
|
|
5955
|
-
return plugins.map((plugin) => {
|
|
5956
|
-
if (plugin.pre) {
|
|
5957
|
-
let missingPlugins = plugin.pre.filter((pluginName) => !plugins.find((pluginToFind) => pluginToFind.name === pluginName));
|
|
5958
|
-
if (missingPlugins.includes("plugin-oas") && this.adapter) missingPlugins = missingPlugins.filter((pluginName) => pluginName !== "plugin-oas");
|
|
5959
|
-
if (missingPlugins.length > 0) throw new ValidationPluginError(`The plugin '${plugin.name}' has a pre set that references missing plugins for '${missingPlugins.join(", ")}'`);
|
|
5960
|
-
}
|
|
5961
|
-
return plugin;
|
|
5962
|
-
}).sort((a, b) => {
|
|
5963
|
-
var _a2, _b2;
|
|
5964
|
-
if ((_a2 = b.pre) == null ? void 0 : _a2.includes(a.name)) return 1;
|
|
5965
|
-
if ((_b2 = b.post) == null ? void 0 : _b2.includes(a.name)) return -1;
|
|
5966
|
-
return 0;
|
|
5967
|
-
});
|
|
5968
|
-
}, /**
|
|
6159
|
+
}, _studioIsOpen = new WeakMap(), _PluginDriver_instances = new WeakSet(), /**
|
|
5969
6160
|
* Run an async plugin hook and return the result.
|
|
5970
6161
|
* @param hookName Name of the plugin hook. Must be either in `PluginHooks` or `OutputPluginValueHooks`.
|
|
5971
6162
|
* @param args Arguments passed to the plugin hook.
|
|
@@ -6048,16 +6239,6 @@ executeSync_fn = function({ strategy, hookName, parameters, plugin }) {
|
|
|
6048
6239
|
});
|
|
6049
6240
|
return null;
|
|
6050
6241
|
}
|
|
6051
|
-
}, parse_fn = function(plugin) {
|
|
6052
|
-
const usedPluginNames = __privateGet$c(this, _usedPluginNames);
|
|
6053
|
-
setUniqueName(plugin.name, usedPluginNames);
|
|
6054
|
-
const usageCount = usedPluginNames[plugin.name];
|
|
6055
|
-
if (usageCount && usageCount > 1) throw new ValidationPluginError(`Duplicate plugin "${plugin.name}" detected. Each plugin can only be used once. Use a different configuration instead of adding multiple instances of the same plugin.`);
|
|
6056
|
-
return {
|
|
6057
|
-
install() {
|
|
6058
|
-
},
|
|
6059
|
-
...plugin
|
|
6060
|
-
};
|
|
6061
6242
|
}, _d);
|
|
6062
6243
|
function createStorage(build2) {
|
|
6063
6244
|
return (options) => build2(options != null ? options : {});
|
|
@@ -6108,7 +6289,7 @@ const fsStorage = createStorage(() => ({
|
|
|
6108
6289
|
await clean(resolve(base));
|
|
6109
6290
|
}
|
|
6110
6291
|
}));
|
|
6111
|
-
var version$1 = "5.0.0-alpha.
|
|
6292
|
+
var version$1 = "5.0.0-alpha.24";
|
|
6112
6293
|
function getDiagnosticInfo() {
|
|
6113
6294
|
return {
|
|
6114
6295
|
nodeVersion: version$2,
|
|
@@ -6252,7 +6433,7 @@ async function safeBuild(options, overrides) {
|
|
|
6252
6433
|
const pluginTimings = /* @__PURE__ */ new Map();
|
|
6253
6434
|
const config = driver.config;
|
|
6254
6435
|
try {
|
|
6255
|
-
for (const plugin of driver.plugins) {
|
|
6436
|
+
for (const plugin of driver.plugins.values()) {
|
|
6256
6437
|
const context = driver.getContext(plugin);
|
|
6257
6438
|
const hrStart = process.hrtime();
|
|
6258
6439
|
const installer = plugin.install.bind(context);
|
|
@@ -6362,7 +6543,7 @@ async function safeBuild(options, overrides) {
|
|
|
6362
6543
|
}
|
|
6363
6544
|
function buildBarrelExports({ barrelFiles, rootDir, existingExports, config, driver }) {
|
|
6364
6545
|
const pluginNameMap = /* @__PURE__ */ new Map();
|
|
6365
|
-
for (const plugin of driver.plugins) pluginNameMap.set(plugin.name, plugin);
|
|
6546
|
+
for (const plugin of driver.plugins.values()) pluginNameMap.set(plugin.name, plugin);
|
|
6366
6547
|
return barrelFiles.flatMap((file) => {
|
|
6367
6548
|
var _a2, _b2;
|
|
6368
6549
|
const containsOnlyTypes = (_a2 = file.sources) == null ? void 0 : _a2.every((source) => source.isTypeOnly);
|
|
@@ -6403,9 +6584,6 @@ function inputToAdapterSource(config) {
|
|
|
6403
6584
|
function createPlugin(build2) {
|
|
6404
6585
|
return (options) => build2(options != null ? options : {});
|
|
6405
6586
|
}
|
|
6406
|
-
function defineBuilder(build2) {
|
|
6407
|
-
return build2();
|
|
6408
|
-
}
|
|
6409
6587
|
function defineGenerator(generator) {
|
|
6410
6588
|
if (generator.type === "react") return {
|
|
6411
6589
|
version: "2",
|
|
@@ -6434,14 +6612,6 @@ function defineGenerator(generator) {
|
|
|
6434
6612
|
...generator
|
|
6435
6613
|
};
|
|
6436
6614
|
}
|
|
6437
|
-
function definePreset(name, { resolvers, transformers, generators }) {
|
|
6438
|
-
return {
|
|
6439
|
-
name,
|
|
6440
|
-
resolvers,
|
|
6441
|
-
transformers,
|
|
6442
|
-
generators
|
|
6443
|
-
};
|
|
6444
|
-
}
|
|
6445
6615
|
function definePresets(presets) {
|
|
6446
6616
|
return presets;
|
|
6447
6617
|
}
|
|
@@ -6500,13 +6670,7 @@ function defaultResolveOptions(node, { options, exclude = [], include, override
|
|
|
6500
6670
|
}
|
|
6501
6671
|
function defaultResolvePath({ baseName, pathMode, tag, path: groupPath }, { root, output, group }) {
|
|
6502
6672
|
if ((pathMode != null ? pathMode : getMode(path$2.resolve(root, output.path))) === "single") return path$2.resolve(root, output.path);
|
|
6503
|
-
if (group && (groupPath || tag)) {
|
|
6504
|
-
const groupName = group.name ? group.name : (ctx) => {
|
|
6505
|
-
if (group.type === "path") return `${ctx.group.split("/")[1]}`;
|
|
6506
|
-
return `${camelCase$e(ctx.group)}Controller`;
|
|
6507
|
-
};
|
|
6508
|
-
return path$2.resolve(root, output.path, groupName({ group: group.type === "path" ? groupPath : tag }), baseName);
|
|
6509
|
-
}
|
|
6673
|
+
if (group && (groupPath || tag)) return path$2.resolve(root, output.path, group.name({ group: group.type === "path" ? groupPath : tag }), baseName);
|
|
6510
6674
|
return path$2.resolve(root, output.path, baseName);
|
|
6511
6675
|
}
|
|
6512
6676
|
function defaultResolveFile({ name, extname: extname2, tag, path: groupPath }, context) {
|
|
@@ -6582,19 +6746,15 @@ async function renderOperation$1(node, options) {
|
|
|
6582
6746
|
const { config, fabric, plugin, Component, adapter, driver } = options;
|
|
6583
6747
|
if (!Component) return;
|
|
6584
6748
|
const fabricChild = createReactFabric();
|
|
6585
|
-
await fabricChild.render(/* @__PURE__ */ jsx(Fabric, {
|
|
6586
|
-
|
|
6587
|
-
|
|
6588
|
-
|
|
6589
|
-
|
|
6590
|
-
|
|
6591
|
-
|
|
6592
|
-
|
|
6593
|
-
|
|
6594
|
-
node,
|
|
6595
|
-
options: options.options
|
|
6596
|
-
})
|
|
6597
|
-
}));
|
|
6749
|
+
await fabricChild.render(/* @__PURE__ */ jsx(Fabric, { children: /* @__PURE__ */ jsx(Component, {
|
|
6750
|
+
config,
|
|
6751
|
+
plugin,
|
|
6752
|
+
driver,
|
|
6753
|
+
adapter,
|
|
6754
|
+
node,
|
|
6755
|
+
options: options.options,
|
|
6756
|
+
resolver: options.resolver
|
|
6757
|
+
}) }));
|
|
6598
6758
|
fabric.context.fileManager.upsert(...fabricChild.files);
|
|
6599
6759
|
fabricChild.unmount();
|
|
6600
6760
|
}
|
|
@@ -6602,19 +6762,15 @@ async function renderSchema$1(node, options) {
|
|
|
6602
6762
|
const { config, fabric, plugin, Component, adapter, driver } = options;
|
|
6603
6763
|
if (!Component) return;
|
|
6604
6764
|
const fabricChild = createReactFabric();
|
|
6605
|
-
await fabricChild.render(/* @__PURE__ */ jsx(Fabric, {
|
|
6606
|
-
|
|
6607
|
-
|
|
6608
|
-
|
|
6609
|
-
|
|
6610
|
-
|
|
6611
|
-
|
|
6612
|
-
|
|
6613
|
-
|
|
6614
|
-
node,
|
|
6615
|
-
options: options.options
|
|
6616
|
-
})
|
|
6617
|
-
}));
|
|
6765
|
+
await fabricChild.render(/* @__PURE__ */ jsx(Fabric, { children: /* @__PURE__ */ jsx(Component, {
|
|
6766
|
+
config,
|
|
6767
|
+
plugin,
|
|
6768
|
+
driver,
|
|
6769
|
+
adapter,
|
|
6770
|
+
node,
|
|
6771
|
+
options: options.options,
|
|
6772
|
+
resolver: options.resolver
|
|
6773
|
+
}) }));
|
|
6618
6774
|
fabric.context.fileManager.upsert(...fabricChild.files);
|
|
6619
6775
|
fabricChild.unmount();
|
|
6620
6776
|
}
|
|
@@ -6967,7 +7123,10 @@ async function getBarrelFiles(files, { type, meta = {}, root, output }) {
|
|
|
6967
7123
|
}
|
|
6968
7124
|
async function getConfigs(config, args) {
|
|
6969
7125
|
const resolved = await (typeof config === "function" ? config(args) : config);
|
|
6970
|
-
return (Array.isArray(resolved) ? resolved : [resolved]).map((item) => ({
|
|
7126
|
+
return (Array.isArray(resolved) ? resolved : [resolved]).map((item) => ({
|
|
7127
|
+
plugins: [],
|
|
7128
|
+
...item
|
|
7129
|
+
}));
|
|
6971
7130
|
}
|
|
6972
7131
|
function mergeResolvers(...resolvers) {
|
|
6973
7132
|
return resolvers.reduce((acc, curr) => ({
|
|
@@ -6977,7 +7136,7 @@ function mergeResolvers(...resolvers) {
|
|
|
6977
7136
|
}
|
|
6978
7137
|
function getPreset(params) {
|
|
6979
7138
|
var _a2, _b2, _c2, _d2, _e2;
|
|
6980
|
-
const { preset: presetName, presets, resolvers, transformers: userTransformers, generators: userGenerators } = params;
|
|
7139
|
+
const { preset: presetName, presets, resolvers = [], transformers: userTransformers = [], generators: userGenerators = [] } = params;
|
|
6981
7140
|
const [defaultResolver2, ...userResolvers] = resolvers;
|
|
6982
7141
|
const preset = presets[presetName];
|
|
6983
7142
|
const resolver = mergeResolvers(mergeResolvers(defaultResolver2, ...(_a2 = preset == null ? void 0 : preset.resolvers) != null ? _a2 : []), ...userResolvers != null ? userResolvers : []);
|
|
@@ -7036,7 +7195,7 @@ function satisfiesDependency(dependency, version2, cwd) {
|
|
|
7036
7195
|
return satisfies(semVer, version2);
|
|
7037
7196
|
}
|
|
7038
7197
|
|
|
7039
|
-
var version = "5.0.0-alpha.
|
|
7198
|
+
var version = "5.0.0-alpha.24";
|
|
7040
7199
|
|
|
7041
7200
|
function isCommandMessage(msg) {
|
|
7042
7201
|
return msg.type === "command";
|
|
@@ -7227,8 +7386,8 @@ async function loadConfig(resolvedConfigPath) {
|
|
|
7227
7386
|
return configs[0];
|
|
7228
7387
|
}
|
|
7229
7388
|
|
|
7230
|
-
var __defProp$
|
|
7231
|
-
var __name$
|
|
7389
|
+
var __defProp$g = Object.defineProperty;
|
|
7390
|
+
var __name$5 = (target, value) => __defProp$g(target, "name", {
|
|
7232
7391
|
value,
|
|
7233
7392
|
configurable: true
|
|
7234
7393
|
});
|
|
@@ -7362,11 +7521,11 @@ function isKeyword(meta, keyword) {
|
|
|
7362
7521
|
return meta.keyword === keyword;
|
|
7363
7522
|
}
|
|
7364
7523
|
|
|
7365
|
-
var __defProp$
|
|
7524
|
+
var __defProp$f = Object.defineProperty;
|
|
7366
7525
|
var __typeError$b = (msg) => {
|
|
7367
7526
|
throw TypeError(msg);
|
|
7368
7527
|
};
|
|
7369
|
-
var __defNormalProp$a = (obj, key, value) => key in obj ? __defProp$
|
|
7528
|
+
var __defNormalProp$a = (obj, key, value) => key in obj ? __defProp$f(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
7370
7529
|
var __publicField$a = (obj, key, value) => __defNormalProp$a(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
7371
7530
|
var __accessCheck$b = (obj, member, msg) => member.has(obj) || __typeError$b("Cannot " + msg);
|
|
7372
7531
|
var __privateGet$b = (obj, member, getter) => (__accessCheck$b(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
|
|
@@ -8106,11 +8265,11 @@ function resolveServerUrl(server, overrides) {
|
|
|
8106
8265
|
return url;
|
|
8107
8266
|
}
|
|
8108
8267
|
|
|
8109
|
-
var __defProp$
|
|
8268
|
+
var __defProp$e = Object.defineProperty;
|
|
8110
8269
|
var __typeError$a = (msg) => {
|
|
8111
8270
|
throw TypeError(msg);
|
|
8112
8271
|
};
|
|
8113
|
-
var __defNormalProp$9 = (obj, key, value) => key in obj ? __defProp$
|
|
8272
|
+
var __defNormalProp$9 = (obj, key, value) => key in obj ? __defProp$e(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8114
8273
|
var __publicField$9 = (obj, key, value) => __defNormalProp$9(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
8115
8274
|
var __accessCheck$a = (obj, member, msg) => member.has(obj) || __typeError$a("Cannot " + msg);
|
|
8116
8275
|
var __privateGet$a = (obj, member, getter) => (__accessCheck$a(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
|
|
@@ -9344,11 +9503,11 @@ function withRequiredRequestBodySchema(operationSchema) {
|
|
|
9344
9503
|
};
|
|
9345
9504
|
}
|
|
9346
9505
|
|
|
9347
|
-
var __defProp$
|
|
9506
|
+
var __defProp$d = Object.defineProperty;
|
|
9348
9507
|
var __typeError$9 = (msg) => {
|
|
9349
9508
|
throw TypeError(msg);
|
|
9350
9509
|
};
|
|
9351
|
-
var __defNormalProp$8 = (obj, key, value) => key in obj ? __defProp$
|
|
9510
|
+
var __defNormalProp$8 = (obj, key, value) => key in obj ? __defProp$d(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
9352
9511
|
var __publicField$8 = (obj, key, value) => __defNormalProp$8(obj, key + "" , value);
|
|
9353
9512
|
var __accessCheck$9 = (obj, member, msg) => member.has(obj) || __typeError$9("Cannot " + msg);
|
|
9354
9513
|
var __privateGet$9 = (obj, member, getter) => (__accessCheck$9(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
|
|
@@ -9594,11 +9753,11 @@ function isParameterSchema(schemaName) {
|
|
|
9594
9753
|
return lowerName.includes("pathparams") || lowerName.includes("queryparams") || lowerName.includes("headerparams");
|
|
9595
9754
|
}
|
|
9596
9755
|
|
|
9597
|
-
var __defProp$
|
|
9756
|
+
var __defProp$c = Object.defineProperty;
|
|
9598
9757
|
var __typeError$8 = (msg) => {
|
|
9599
9758
|
throw TypeError(msg);
|
|
9600
9759
|
};
|
|
9601
|
-
var __defNormalProp$7 = (obj, key, value) => key in obj ? __defProp$
|
|
9760
|
+
var __defNormalProp$7 = (obj, key, value) => key in obj ? __defProp$c(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
9602
9761
|
var __publicField$7 = (obj, key, value) => __defNormalProp$7(obj, key + "" , value);
|
|
9603
9762
|
var __accessCheck$8 = (obj, member, msg) => member.has(obj) || __typeError$8("Cannot " + msg);
|
|
9604
9763
|
var __privateGet$8 = (obj, member, getter) => (__accessCheck$8(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
|
|
@@ -9802,7 +9961,7 @@ function getParams$1$5({ paramsType, paramsCasing, pathParamsType, typeSchemas }
|
|
|
9802
9961
|
default: getDefaultValue((_b = typeSchemas.pathParams) == null ? void 0 : _b.schema)
|
|
9803
9962
|
} : void 0 });
|
|
9804
9963
|
}
|
|
9805
|
-
__name$
|
|
9964
|
+
__name$5(getParams$1$5, "getParams");
|
|
9806
9965
|
function Url({ name, isExportable = true, isIndexable = true, typeSchemas, baseURL, paramsType, paramsCasing, pathParamsType, operation }) {
|
|
9807
9966
|
const path = new URLPath$7(operation.path);
|
|
9808
9967
|
const params = getParams$1$5({
|
|
@@ -9983,7 +10142,7 @@ Client.getParams = getParams$d;
|
|
|
9983
10142
|
function buildHeaders$1(contentType, hasHeaderParams) {
|
|
9984
10143
|
return [contentType !== "application/json" && contentType !== "multipart/form-data" ? `'Content-Type': '${contentType}'` : void 0, hasHeaderParams ? "...headers" : void 0].filter(Boolean);
|
|
9985
10144
|
}
|
|
9986
|
-
__name$
|
|
10145
|
+
__name$5(buildHeaders$1, "buildHeaders");
|
|
9987
10146
|
function buildGenerics$1(typeSchemas) {
|
|
9988
10147
|
var _a2, _b;
|
|
9989
10148
|
const TError = `ResponseErrorConfig<${((_a2 = typeSchemas.errors) == null ? void 0 : _a2.map((item) => item.name).join(" | ")) || "Error"}>`;
|
|
@@ -9993,7 +10152,7 @@ function buildGenerics$1(typeSchemas) {
|
|
|
9993
10152
|
((_b = typeSchemas.request) == null ? void 0 : _b.name) || "unknown"
|
|
9994
10153
|
].filter(Boolean);
|
|
9995
10154
|
}
|
|
9996
|
-
__name$
|
|
10155
|
+
__name$5(buildGenerics$1, "buildGenerics");
|
|
9997
10156
|
function buildClientParams$1({ operation, path, baseURL, typeSchemas, isFormData, headers }) {
|
|
9998
10157
|
var _a2, _b;
|
|
9999
10158
|
return FunctionParams.factory({ config: {
|
|
@@ -10009,25 +10168,25 @@ function buildClientParams$1({ operation, path, baseURL, typeSchemas, isFormData
|
|
|
10009
10168
|
}
|
|
10010
10169
|
} });
|
|
10011
10170
|
}
|
|
10012
|
-
__name$
|
|
10171
|
+
__name$5(buildClientParams$1, "buildClientParams");
|
|
10013
10172
|
function buildRequestDataLine$1({ parser, zodSchemas, typeSchemas }) {
|
|
10014
10173
|
var _a2, _b;
|
|
10015
10174
|
if (parser === "zod" && ((_a2 = zodSchemas == null ? void 0 : zodSchemas.request) == null ? void 0 : _a2.name)) return `const requestData = ${zodSchemas.request.name}.parse(data)`;
|
|
10016
10175
|
if ((_b = typeSchemas == null ? void 0 : typeSchemas.request) == null ? void 0 : _b.name) return "const requestData = data";
|
|
10017
10176
|
return "";
|
|
10018
10177
|
}
|
|
10019
|
-
__name$
|
|
10178
|
+
__name$5(buildRequestDataLine$1, "buildRequestDataLine");
|
|
10020
10179
|
function buildFormDataLine$1(isFormData, hasRequest) {
|
|
10021
10180
|
return isFormData && hasRequest ? "const formData = buildFormData(requestData)" : "";
|
|
10022
10181
|
}
|
|
10023
|
-
__name$
|
|
10182
|
+
__name$5(buildFormDataLine$1, "buildFormDataLine");
|
|
10024
10183
|
function buildReturnStatement$1({ dataReturnType, parser, zodSchemas }) {
|
|
10025
10184
|
if (dataReturnType === "full" && parser === "zod" && zodSchemas) return `return {...res, data: ${zodSchemas.response.name}.parse(res.data)}`;
|
|
10026
10185
|
if (dataReturnType === "data" && parser === "zod" && zodSchemas) return `return ${zodSchemas.response.name}.parse(res.data)`;
|
|
10027
10186
|
if (dataReturnType === "full" && parser === "client") return "return res";
|
|
10028
10187
|
return "return res.data";
|
|
10029
10188
|
}
|
|
10030
|
-
__name$
|
|
10189
|
+
__name$5(buildReturnStatement$1, "buildReturnStatement");
|
|
10031
10190
|
function generateMethod$1({ operation, name, typeSchemas, zodSchemas, baseURL, dataReturnType, parser, paramsType, paramsCasing, pathParamsType }) {
|
|
10032
10191
|
var _a2, _b;
|
|
10033
10192
|
const path = new URLPath$7(operation.path, { casing: paramsCasing });
|
|
@@ -10074,7 +10233,7 @@ function generateMethod$1({ operation, name, typeSchemas, zodSchemas, baseURL, d
|
|
|
10074
10233
|
${methodBody}
|
|
10075
10234
|
}`;
|
|
10076
10235
|
}
|
|
10077
|
-
__name$
|
|
10236
|
+
__name$5(generateMethod$1, "generateMethod");
|
|
10078
10237
|
function ClassClient({ name, isExportable = true, isIndexable = true, operations, baseURL, dataReturnType, parser, paramsType, paramsCasing, pathParamsType, children }) {
|
|
10079
10238
|
const classCode = `export class ${name} {
|
|
10080
10239
|
#config: Partial<RequestConfig> & { client?: Client }
|
|
@@ -11451,157 +11610,6 @@ function Zod({ name, typeName, tree, schema, inferTypeName, mapper, coercion, ke
|
|
|
11451
11610
|
})] });
|
|
11452
11611
|
}
|
|
11453
11612
|
|
|
11454
|
-
var __defProp$c = Object.defineProperty;
|
|
11455
|
-
var __name$5 = (target, value) => __defProp$c(target, "name", {
|
|
11456
|
-
value,
|
|
11457
|
-
configurable: true
|
|
11458
|
-
});
|
|
11459
|
-
|
|
11460
|
-
const builderTs = defineBuilder(() => ({
|
|
11461
|
-
name: "default",
|
|
11462
|
-
buildParams({ params, node, resolver }) {
|
|
11463
|
-
return createSchema({
|
|
11464
|
-
type: "object",
|
|
11465
|
-
properties: params.map((param) => createProperty({
|
|
11466
|
-
name: param.name,
|
|
11467
|
-
required: param.required,
|
|
11468
|
-
schema: createSchema({
|
|
11469
|
-
type: "ref",
|
|
11470
|
-
name: resolver.resolveParamName(node, param)
|
|
11471
|
-
})
|
|
11472
|
-
}))
|
|
11473
|
-
});
|
|
11474
|
-
},
|
|
11475
|
-
buildData({ node, resolver }) {
|
|
11476
|
-
var _a;
|
|
11477
|
-
const pathParams = node.parameters.filter((p) => p.in === "path");
|
|
11478
|
-
const queryParams = node.parameters.filter((p) => p.in === "query");
|
|
11479
|
-
const headerParams = node.parameters.filter((p) => p.in === "header");
|
|
11480
|
-
return createSchema({
|
|
11481
|
-
type: "object",
|
|
11482
|
-
deprecated: node.deprecated,
|
|
11483
|
-
properties: [
|
|
11484
|
-
createProperty({
|
|
11485
|
-
name: "data",
|
|
11486
|
-
schema: ((_a = node.requestBody) == null ? void 0 : _a.schema) ? createSchema({
|
|
11487
|
-
type: "ref",
|
|
11488
|
-
name: resolver.resolveDataTypedName(node),
|
|
11489
|
-
optional: true
|
|
11490
|
-
}) : createSchema({
|
|
11491
|
-
type: "never",
|
|
11492
|
-
optional: true
|
|
11493
|
-
})
|
|
11494
|
-
}),
|
|
11495
|
-
createProperty({
|
|
11496
|
-
name: "pathParams",
|
|
11497
|
-
required: pathParams.length > 0,
|
|
11498
|
-
schema: pathParams.length > 0 ? this.buildParams({
|
|
11499
|
-
params: pathParams,
|
|
11500
|
-
node,
|
|
11501
|
-
resolver
|
|
11502
|
-
}) : createSchema({ type: "never" })
|
|
11503
|
-
}),
|
|
11504
|
-
createProperty({
|
|
11505
|
-
name: "queryParams",
|
|
11506
|
-
schema: queryParams.length > 0 ? createSchema({
|
|
11507
|
-
...this.buildParams({
|
|
11508
|
-
params: queryParams,
|
|
11509
|
-
node,
|
|
11510
|
-
resolver
|
|
11511
|
-
}),
|
|
11512
|
-
optional: true
|
|
11513
|
-
}) : createSchema({
|
|
11514
|
-
type: "never",
|
|
11515
|
-
optional: true
|
|
11516
|
-
})
|
|
11517
|
-
}),
|
|
11518
|
-
createProperty({
|
|
11519
|
-
name: "headerParams",
|
|
11520
|
-
schema: headerParams.length > 0 ? createSchema({
|
|
11521
|
-
...this.buildParams({
|
|
11522
|
-
params: headerParams,
|
|
11523
|
-
node,
|
|
11524
|
-
resolver
|
|
11525
|
-
}),
|
|
11526
|
-
optional: true
|
|
11527
|
-
}) : createSchema({
|
|
11528
|
-
type: "never",
|
|
11529
|
-
optional: true
|
|
11530
|
-
})
|
|
11531
|
-
}),
|
|
11532
|
-
createProperty({
|
|
11533
|
-
name: "url",
|
|
11534
|
-
required: true,
|
|
11535
|
-
schema: createSchema({
|
|
11536
|
-
type: "url",
|
|
11537
|
-
path: node.path
|
|
11538
|
-
})
|
|
11539
|
-
})
|
|
11540
|
-
]
|
|
11541
|
-
});
|
|
11542
|
-
},
|
|
11543
|
-
buildResponses({ node, resolver }) {
|
|
11544
|
-
if (node.responses.length === 0) return null;
|
|
11545
|
-
return createSchema({
|
|
11546
|
-
type: "object",
|
|
11547
|
-
properties: node.responses.map((res) => createProperty({
|
|
11548
|
-
name: String(res.statusCode),
|
|
11549
|
-
required: true,
|
|
11550
|
-
schema: createSchema({
|
|
11551
|
-
type: "ref",
|
|
11552
|
-
name: resolver.resolveResponseStatusTypedName(node, res.statusCode)
|
|
11553
|
-
})
|
|
11554
|
-
}))
|
|
11555
|
-
});
|
|
11556
|
-
},
|
|
11557
|
-
buildResponseUnion({ node, resolver }) {
|
|
11558
|
-
const responsesWithSchema = node.responses.filter((res) => res.schema);
|
|
11559
|
-
if (responsesWithSchema.length === 0) return null;
|
|
11560
|
-
return createSchema({
|
|
11561
|
-
type: "union",
|
|
11562
|
-
members: responsesWithSchema.map((res) => createSchema({
|
|
11563
|
-
type: "ref",
|
|
11564
|
-
name: resolver.resolveResponseStatusTypedName(node, res.statusCode)
|
|
11565
|
-
}))
|
|
11566
|
-
});
|
|
11567
|
-
}
|
|
11568
|
-
}));
|
|
11569
|
-
|
|
11570
|
-
function toCamelOrPascal$a(text, pascal) {
|
|
11571
|
-
return text.trim().replace(/([a-z\d])([A-Z])/g, "$1 $2").replace(/([A-Z]+)([A-Z][a-z])/g, "$1 $2").replace(/(\d)([a-z])/g, "$1 $2").split(/[\s\-_./\\:]+/).filter(Boolean).map((word, i) => {
|
|
11572
|
-
if (word.length > 1 && word === word.toUpperCase()) return word;
|
|
11573
|
-
if (i === 0 && !pascal) return word.charAt(0).toLowerCase() + word.slice(1);
|
|
11574
|
-
return word.charAt(0).toUpperCase() + word.slice(1);
|
|
11575
|
-
}).join("").replace(/[^a-zA-Z0-9]/g, "");
|
|
11576
|
-
}
|
|
11577
|
-
function applyToFileParts$a(text, transformPart) {
|
|
11578
|
-
const parts = text.split(/\.(?=[a-zA-Z])/);
|
|
11579
|
-
return parts.map((part, i) => transformPart(part, i === parts.length - 1)).join("/");
|
|
11580
|
-
}
|
|
11581
|
-
function camelCase$a(text, { isFile, prefix = "", suffix = "" } = {}) {
|
|
11582
|
-
if (isFile) return applyToFileParts$a(text, (part, isLast) => camelCase$a(part, isLast ? {
|
|
11583
|
-
prefix,
|
|
11584
|
-
suffix
|
|
11585
|
-
} : {}));
|
|
11586
|
-
return toCamelOrPascal$a(`${prefix} ${text} ${suffix}`, false);
|
|
11587
|
-
}
|
|
11588
|
-
function pascalCase$6(text, { isFile, prefix = "", suffix = "" } = {}) {
|
|
11589
|
-
if (isFile) return applyToFileParts$a(text, (part, isLast) => isLast ? pascalCase$6(part, {
|
|
11590
|
-
prefix,
|
|
11591
|
-
suffix
|
|
11592
|
-
}) : camelCase$a(part));
|
|
11593
|
-
return toCamelOrPascal$a(`${prefix} ${text} ${suffix}`, true);
|
|
11594
|
-
}
|
|
11595
|
-
function snakeCase(text, { prefix = "", suffix = "" } = {}) {
|
|
11596
|
-
return `${prefix} ${text} ${suffix}`.trim().replace(/([a-z])([A-Z])/g, "$1_$2").replace(/[\s\-.]+/g, "_").replace(/[^a-zA-Z0-9_]/g, "").toLowerCase().split("_").filter(Boolean).join("_");
|
|
11597
|
-
}
|
|
11598
|
-
function screamingSnakeCase(text, { prefix = "", suffix = "" } = {}) {
|
|
11599
|
-
return snakeCase(text, {
|
|
11600
|
-
prefix,
|
|
11601
|
-
suffix
|
|
11602
|
-
}).toUpperCase();
|
|
11603
|
-
}
|
|
11604
|
-
|
|
11605
11613
|
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : "undefined" !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
|
11606
11614
|
|
|
11607
11615
|
function getDefaultExportFromCjs (x) {
|
|
@@ -209486,6 +209494,40 @@ Additional information: BADCLIENT: Bad error code, ${badCode} not found in range
|
|
|
209486
209494
|
var typescriptExports = typescript.exports;
|
|
209487
209495
|
const ts = /*@__PURE__*/getDefaultExportFromCjs(typescriptExports);
|
|
209488
209496
|
|
|
209497
|
+
function toCamelOrPascal$a(text, pascal) {
|
|
209498
|
+
return text.trim().replace(/([a-z\d])([A-Z])/g, "$1 $2").replace(/([A-Z]+)([A-Z][a-z])/g, "$1 $2").replace(/(\d)([a-z])/g, "$1 $2").split(/[\s\-_./\\:]+/).filter(Boolean).map((word, i) => {
|
|
209499
|
+
if (word.length > 1 && word === word.toUpperCase()) return word;
|
|
209500
|
+
if (i === 0 && !pascal) return word.charAt(0).toLowerCase() + word.slice(1);
|
|
209501
|
+
return word.charAt(0).toUpperCase() + word.slice(1);
|
|
209502
|
+
}).join("").replace(/[^a-zA-Z0-9]/g, "");
|
|
209503
|
+
}
|
|
209504
|
+
function applyToFileParts$a(text, transformPart) {
|
|
209505
|
+
const parts = text.split(/\.(?=[a-zA-Z])/);
|
|
209506
|
+
return parts.map((part, i) => transformPart(part, i === parts.length - 1)).join("/");
|
|
209507
|
+
}
|
|
209508
|
+
function camelCase$a(text, { isFile, prefix = "", suffix = "" } = {}) {
|
|
209509
|
+
if (isFile) return applyToFileParts$a(text, (part, isLast) => camelCase$a(part, isLast ? {
|
|
209510
|
+
prefix,
|
|
209511
|
+
suffix
|
|
209512
|
+
} : {}));
|
|
209513
|
+
return toCamelOrPascal$a(`${prefix} ${text} ${suffix}`, false);
|
|
209514
|
+
}
|
|
209515
|
+
function pascalCase$6(text, { isFile, prefix = "", suffix = "" } = {}) {
|
|
209516
|
+
if (isFile) return applyToFileParts$a(text, (part, isLast) => isLast ? pascalCase$6(part, {
|
|
209517
|
+
prefix,
|
|
209518
|
+
suffix
|
|
209519
|
+
}) : camelCase$a(part));
|
|
209520
|
+
return toCamelOrPascal$a(`${prefix} ${text} ${suffix}`, true);
|
|
209521
|
+
}
|
|
209522
|
+
function snakeCase(text, { prefix = "", suffix = "" } = {}) {
|
|
209523
|
+
return `${prefix} ${text} ${suffix}`.trim().replace(/([a-z])([A-Z])/g, "$1_$2").replace(/[\s\-.]+/g, "_").replace(/[^a-zA-Z0-9_]/g, "").toLowerCase().split("_").filter(Boolean).join("_");
|
|
209524
|
+
}
|
|
209525
|
+
function screamingSnakeCase(text, { prefix = "", suffix = "" } = {}) {
|
|
209526
|
+
return snakeCase(text, {
|
|
209527
|
+
prefix,
|
|
209528
|
+
suffix
|
|
209529
|
+
}).toUpperCase();
|
|
209530
|
+
}
|
|
209489
209531
|
function trimQuotes$1(text) {
|
|
209490
209532
|
if (text.length >= 2) {
|
|
209491
209533
|
const first = text[0];
|
|
@@ -209697,8 +209739,8 @@ const keywordTypeNodes = {
|
|
|
209697
209739
|
null: factory.createLiteralTypeNode(factory.createToken(ts.SyntaxKind.NullKeyword)),
|
|
209698
209740
|
never: factory.createKeywordTypeNode(ts.SyntaxKind.NeverKeyword)
|
|
209699
209741
|
};
|
|
209700
|
-
function createUrlTemplateType(
|
|
209701
|
-
const normalized =
|
|
209742
|
+
function createUrlTemplateType(path2) {
|
|
209743
|
+
const normalized = path2.replace(/:([^/]+)/g, "{$1}");
|
|
209702
209744
|
if (!normalized.includes("{")) return factory.createLiteralTypeNode(factory.createStringLiteral(normalized));
|
|
209703
209745
|
const segments = normalized.split(/(\{[^}]+\})/);
|
|
209704
209746
|
const parts = [];
|
|
@@ -209736,211 +209778,11 @@ const createFalse = factory.createFalse;
|
|
|
209736
209778
|
factory.createIndexedAccessTypeNode;
|
|
209737
209779
|
factory.createTypeOperatorNode;
|
|
209738
209780
|
const createPrefixUnaryExpression = factory.createPrefixUnaryExpression;
|
|
209739
|
-
function constToTypeNode(value, format) {
|
|
209740
|
-
if (format === "boolean") return createLiteralTypeNode(value === true ? createTrue() : createFalse());
|
|
209741
|
-
if (format === "number" && typeof value === "number") {
|
|
209742
|
-
if (value < 0) return createLiteralTypeNode(createPrefixUnaryExpression(SyntaxKind.MinusToken, createNumericLiteral(Math.abs(value))));
|
|
209743
|
-
return createLiteralTypeNode(createNumericLiteral(value));
|
|
209744
|
-
}
|
|
209745
|
-
return createLiteralTypeNode(createStringLiteral(String(value)));
|
|
209746
|
-
}
|
|
209747
|
-
function dateOrStringNode(node) {
|
|
209748
|
-
return node.representation === "date" ? createTypeReferenceNode(createIdentifier("Date")) : keywordTypeNodes.string;
|
|
209749
|
-
}
|
|
209750
|
-
function buildMemberNodes(members, print) {
|
|
209751
|
-
return (members != null ? members : []).map(print).filter(Boolean);
|
|
209752
|
-
}
|
|
209753
|
-
function buildTupleNode(node, print) {
|
|
209754
|
-
var _a, _b;
|
|
209755
|
-
let items = ((_a = node.items) != null ? _a : []).map(print).filter(Boolean);
|
|
209756
|
-
const restNode = node.rest ? (_b = print(node.rest)) != null ? _b : void 0 : void 0;
|
|
209757
|
-
const { min, max } = node;
|
|
209758
|
-
if (max !== void 0) {
|
|
209759
|
-
items = items.slice(0, max);
|
|
209760
|
-
if (items.length < max && restNode) items = [...items, ...Array(max - items.length).fill(restNode)];
|
|
209761
|
-
}
|
|
209762
|
-
if (min !== void 0) items = items.map((item, i) => i >= min ? createOptionalTypeNode(item) : item);
|
|
209763
|
-
if (max === void 0 && restNode) items.push(createRestTypeNode(createArrayTypeNode(restNode)));
|
|
209764
|
-
return createTupleTypeNode(items);
|
|
209765
|
-
}
|
|
209766
|
-
function buildPropertyType(schema, baseType, optionalType) {
|
|
209767
|
-
const addsUndefined = OPTIONAL_ADDS_UNDEFINED.has(optionalType);
|
|
209768
|
-
let type = baseType;
|
|
209769
|
-
if (schema.nullable) type = createUnionDeclaration({ nodes: [type, keywordTypeNodes.null] });
|
|
209770
|
-
if ((schema.nullish || schema.optional) && addsUndefined) type = createUnionDeclaration({ nodes: [type, keywordTypeNodes.undefined] });
|
|
209771
|
-
return type;
|
|
209772
|
-
}
|
|
209773
|
-
function buildPropertyJSDocComments(schema) {
|
|
209774
|
-
const isArray = schema.type === "array";
|
|
209775
|
-
return [
|
|
209776
|
-
"description" in schema && schema.description ? `@description ${jsStringEscape$1(schema.description)}` : void 0,
|
|
209777
|
-
"deprecated" in schema && schema.deprecated ? "@deprecated" : void 0,
|
|
209778
|
-
!isArray && "min" in schema && schema.min !== void 0 ? `@minLength ${schema.min}` : void 0,
|
|
209779
|
-
!isArray && "max" in schema && schema.max !== void 0 ? `@maxLength ${schema.max}` : void 0,
|
|
209780
|
-
"pattern" in schema && schema.pattern ? `@pattern ${schema.pattern}` : void 0,
|
|
209781
|
-
"default" in schema && schema.default !== void 0 ? `@default ${"primitive" in schema && schema.primitive === "string" ? stringify$1(schema.default) : schema.default}` : void 0,
|
|
209782
|
-
"example" in schema && schema.example !== void 0 ? `@example ${schema.example}` : void 0,
|
|
209783
|
-
"primitive" in schema && schema.primitive ? [`@type ${schema.primitive || "unknown"}`, "optional" in schema && schema.optional ? " | undefined" : void 0].filter(Boolean).join("") : void 0
|
|
209784
|
-
];
|
|
209785
|
-
}
|
|
209786
|
-
function buildIndexSignatures(node, propertyCount, print) {
|
|
209787
|
-
var _a, _b;
|
|
209788
|
-
const elements = [];
|
|
209789
|
-
if (node.additionalProperties && node.additionalProperties !== true) {
|
|
209790
|
-
const additionalType = (_a = print(node.additionalProperties)) != null ? _a : keywordTypeNodes.unknown;
|
|
209791
|
-
elements.push(createIndexSignature(propertyCount > 0 ? keywordTypeNodes.unknown : additionalType));
|
|
209792
|
-
} else if (node.additionalProperties === true) elements.push(createIndexSignature(keywordTypeNodes.unknown));
|
|
209793
|
-
if (node.patternProperties) {
|
|
209794
|
-
const first = Object.values(node.patternProperties)[0];
|
|
209795
|
-
if (first) {
|
|
209796
|
-
let patternType = (_b = print(first)) != null ? _b : keywordTypeNodes.unknown;
|
|
209797
|
-
if (first.nullable) patternType = createUnionDeclaration({ nodes: [patternType, keywordTypeNodes.null] });
|
|
209798
|
-
elements.push(createIndexSignature(patternType));
|
|
209799
|
-
}
|
|
209800
|
-
}
|
|
209801
|
-
return elements;
|
|
209802
|
-
}
|
|
209803
|
-
const printerTs = definePrinter((options) => {
|
|
209804
|
-
const addsUndefined = OPTIONAL_ADDS_UNDEFINED.has(options.optionalType);
|
|
209805
|
-
return {
|
|
209806
|
-
name: "typescript",
|
|
209807
|
-
options,
|
|
209808
|
-
nodes: {
|
|
209809
|
-
any: () => keywordTypeNodes.any,
|
|
209810
|
-
unknown: () => keywordTypeNodes.unknown,
|
|
209811
|
-
void: () => keywordTypeNodes.void,
|
|
209812
|
-
never: () => keywordTypeNodes.never,
|
|
209813
|
-
boolean: () => keywordTypeNodes.boolean,
|
|
209814
|
-
null: () => keywordTypeNodes.null,
|
|
209815
|
-
blob: () => createTypeReferenceNode("Blob", []),
|
|
209816
|
-
string: () => keywordTypeNodes.string,
|
|
209817
|
-
uuid: () => keywordTypeNodes.string,
|
|
209818
|
-
email: () => keywordTypeNodes.string,
|
|
209819
|
-
url: (node) => {
|
|
209820
|
-
if (node.path) return createUrlTemplateType(node.path);
|
|
209821
|
-
return keywordTypeNodes.string;
|
|
209822
|
-
},
|
|
209823
|
-
datetime: () => keywordTypeNodes.string,
|
|
209824
|
-
number: () => keywordTypeNodes.number,
|
|
209825
|
-
integer: () => keywordTypeNodes.number,
|
|
209826
|
-
bigint: () => keywordTypeNodes.bigint,
|
|
209827
|
-
date: dateOrStringNode,
|
|
209828
|
-
time: dateOrStringNode,
|
|
209829
|
-
ref(node) {
|
|
209830
|
-
var _a;
|
|
209831
|
-
if (!node.name) return;
|
|
209832
|
-
const refName = node.ref ? (_a = node.ref.split("/").at(-1)) != null ? _a : node.name : node.name;
|
|
209833
|
-
return createTypeReferenceNode(node.ref ? this.options.resolver.default(refName, "type") : refName, void 0);
|
|
209834
|
-
},
|
|
209835
|
-
enum(node) {
|
|
209836
|
-
var _a, _b, _c, _d;
|
|
209837
|
-
const values = (_c = (_b = (_a = node.namedEnumValues) == null ? void 0 : _a.map((v) => v.value)) != null ? _b : node.enumValues) != null ? _c : [];
|
|
209838
|
-
if (this.options.enumType === "inlineLiteral" || !node.name) return (_d = createUnionDeclaration({
|
|
209839
|
-
withParentheses: true,
|
|
209840
|
-
nodes: values.filter((v) => v !== null).map((value) => constToTypeNode(value, typeof value)).filter(Boolean)
|
|
209841
|
-
})) != null ? _d : void 0;
|
|
209842
|
-
return createTypeReferenceNode(ENUM_TYPES_WITH_KEY_SUFFIX.has(this.options.enumType) && this.options.enumTypeSuffix ? this.options.resolver.resolveEnumKeyTypedName(node, this.options.enumTypeSuffix) : this.options.resolver.default(node.name, "type"), void 0);
|
|
209843
|
-
},
|
|
209844
|
-
union(node) {
|
|
209845
|
-
var _a, _b, _c;
|
|
209846
|
-
const members = (_a = node.members) != null ? _a : [];
|
|
209847
|
-
const hasStringLiteral = members.some((m) => {
|
|
209848
|
-
var _a2;
|
|
209849
|
-
return ((_a2 = narrowSchema(m, schemaTypes.enum)) == null ? void 0 : _a2.primitive) === "string";
|
|
209850
|
-
});
|
|
209851
|
-
const hasPlainString = members.some((m) => isStringType(m));
|
|
209852
|
-
if (hasStringLiteral && hasPlainString) return (_b = createUnionDeclaration({
|
|
209853
|
-
withParentheses: true,
|
|
209854
|
-
nodes: members.map((m) => {
|
|
209855
|
-
if (isStringType(m)) return createIntersectionDeclaration({
|
|
209856
|
-
nodes: [keywordTypeNodes.string, createTypeLiteralNode([])],
|
|
209857
|
-
withParentheses: true
|
|
209858
|
-
});
|
|
209859
|
-
return this.transform(m);
|
|
209860
|
-
}).filter(Boolean)
|
|
209861
|
-
})) != null ? _b : void 0;
|
|
209862
|
-
return (_c = createUnionDeclaration({
|
|
209863
|
-
withParentheses: true,
|
|
209864
|
-
nodes: buildMemberNodes(members, this.transform)
|
|
209865
|
-
})) != null ? _c : void 0;
|
|
209866
|
-
},
|
|
209867
|
-
intersection(node) {
|
|
209868
|
-
var _a;
|
|
209869
|
-
return (_a = createIntersectionDeclaration({
|
|
209870
|
-
withParentheses: true,
|
|
209871
|
-
nodes: buildMemberNodes(node.members, this.transform)
|
|
209872
|
-
})) != null ? _a : void 0;
|
|
209873
|
-
},
|
|
209874
|
-
array(node) {
|
|
209875
|
-
var _a, _b;
|
|
209876
|
-
return (_b = createArrayDeclaration({
|
|
209877
|
-
nodes: ((_a = node.items) != null ? _a : []).map((item) => this.transform(item)).filter(Boolean),
|
|
209878
|
-
arrayType: this.options.arrayType
|
|
209879
|
-
})) != null ? _b : void 0;
|
|
209880
|
-
},
|
|
209881
|
-
tuple(node) {
|
|
209882
|
-
return buildTupleNode(node, this.transform);
|
|
209883
|
-
},
|
|
209884
|
-
object(node) {
|
|
209885
|
-
const { transform, options: options2 } = this;
|
|
209886
|
-
const addsQuestionToken = OPTIONAL_ADDS_QUESTION_TOKEN.has(options2.optionalType);
|
|
209887
|
-
const propertyNodes = node.properties.map((prop) => {
|
|
209888
|
-
var _a;
|
|
209889
|
-
const baseType = (_a = transform(prop.schema)) != null ? _a : keywordTypeNodes.unknown;
|
|
209890
|
-
const type = buildPropertyType(prop.schema, baseType, options2.optionalType);
|
|
209891
|
-
return appendJSDocToNode({
|
|
209892
|
-
node: createPropertySignature({
|
|
209893
|
-
questionToken: prop.schema.optional || prop.schema.nullish ? addsQuestionToken : false,
|
|
209894
|
-
name: prop.name,
|
|
209895
|
-
type,
|
|
209896
|
-
readOnly: prop.schema.readOnly
|
|
209897
|
-
}),
|
|
209898
|
-
comments: buildPropertyJSDocComments(prop.schema)
|
|
209899
|
-
});
|
|
209900
|
-
});
|
|
209901
|
-
const allElements = [...propertyNodes, ...buildIndexSignatures(node, propertyNodes.length, transform)];
|
|
209902
|
-
if (!allElements.length) return keywordTypeNodes.object;
|
|
209903
|
-
return createTypeLiteralNode(allElements);
|
|
209904
|
-
}
|
|
209905
|
-
},
|
|
209906
|
-
print(node) {
|
|
209907
|
-
let type = this.transform(node);
|
|
209908
|
-
if (!type) return null;
|
|
209909
|
-
if (node.nullable) type = createUnionDeclaration({ nodes: [type, keywordTypeNodes.null] });
|
|
209910
|
-
if ((node.nullish || node.optional) && addsUndefined) type = createUnionDeclaration({ nodes: [type, keywordTypeNodes.undefined] });
|
|
209911
|
-
const { typeName, syntaxType = "type", description, keysToOmit } = this.options;
|
|
209912
|
-
if (!typeName) return safePrint(type);
|
|
209913
|
-
const useTypeGeneration = syntaxType === "type" || type.kind === syntaxKind.union || !!(keysToOmit == null ? void 0 : keysToOmit.length);
|
|
209914
|
-
return safePrint(createTypeDeclaration({
|
|
209915
|
-
name: typeName,
|
|
209916
|
-
isExportable: true,
|
|
209917
|
-
type: (keysToOmit == null ? void 0 : keysToOmit.length) ? createOmitDeclaration({
|
|
209918
|
-
keys: keysToOmit,
|
|
209919
|
-
type,
|
|
209920
|
-
nonNullable: true
|
|
209921
|
-
}) : type,
|
|
209922
|
-
syntax: useTypeGeneration ? "type" : "interface",
|
|
209923
|
-
comments: [
|
|
209924
|
-
(node == null ? void 0 : node.title) ? jsStringEscape$1(node.title) : void 0,
|
|
209925
|
-
description ? `@description ${jsStringEscape$1(description)}` : void 0,
|
|
209926
|
-
(node == null ? void 0 : node.deprecated) ? "@deprecated" : void 0,
|
|
209927
|
-
node && "min" in node && node.min !== void 0 ? `@minLength ${node.min}` : void 0,
|
|
209928
|
-
node && "max" in node && node.max !== void 0 ? `@maxLength ${node.max}` : void 0,
|
|
209929
|
-
node && "pattern" in node && node.pattern ? `@pattern ${node.pattern}` : void 0,
|
|
209930
|
-
(node == null ? void 0 : node.default) ? `@default ${node.default}` : void 0,
|
|
209931
|
-
(node == null ? void 0 : node.example) ? `@example ${node.example}` : void 0
|
|
209932
|
-
]
|
|
209933
|
-
}));
|
|
209934
|
-
}
|
|
209935
|
-
};
|
|
209936
|
-
});
|
|
209937
|
-
|
|
209938
209781
|
function getEnumNames({ node, enumType, enumTypeSuffix, resolver }) {
|
|
209939
209782
|
const resolved = resolver.default(node.name, "type");
|
|
209940
209783
|
return {
|
|
209941
209784
|
enumName: enumType === "asPascalConst" ? resolved : camelCase$a(node.name),
|
|
209942
|
-
typeName: ENUM_TYPES_WITH_KEY_SUFFIX.has(enumType) ? resolver.
|
|
209943
|
-
refName: resolved
|
|
209785
|
+
typeName: ENUM_TYPES_WITH_KEY_SUFFIX.has(enumType) ? resolver.resolveEnumKeyName(node, enumTypeSuffix) : resolved
|
|
209944
209786
|
};
|
|
209945
209787
|
}
|
|
209946
209788
|
function Enum({ node, enumType, enumTypeSuffix, enumKeyCasing, resolver }) {
|
|
@@ -209972,7 +209814,205 @@ function Enum({ node, enumType, enumTypeSuffix, enumKeyCasing, resolver }) {
|
|
|
209972
209814
|
children: safePrint(typeNode)
|
|
209973
209815
|
})] });
|
|
209974
209816
|
}
|
|
209975
|
-
function
|
|
209817
|
+
function constToTypeNode(value, format) {
|
|
209818
|
+
if (format === "boolean") return createLiteralTypeNode(value === true ? createTrue() : createFalse());
|
|
209819
|
+
if (format === "number" && typeof value === "number") {
|
|
209820
|
+
if (value < 0) return createLiteralTypeNode(createPrefixUnaryExpression(SyntaxKind.MinusToken, createNumericLiteral(Math.abs(value))));
|
|
209821
|
+
return createLiteralTypeNode(createNumericLiteral(value));
|
|
209822
|
+
}
|
|
209823
|
+
return createLiteralTypeNode(createStringLiteral(String(value)));
|
|
209824
|
+
}
|
|
209825
|
+
function dateOrStringNode(node) {
|
|
209826
|
+
return node.representation === "date" ? createTypeReferenceNode(createIdentifier("Date")) : keywordTypeNodes.string;
|
|
209827
|
+
}
|
|
209828
|
+
function buildMemberNodes(members, print) {
|
|
209829
|
+
return (members != null ? members : []).map(print).filter(Boolean);
|
|
209830
|
+
}
|
|
209831
|
+
function buildTupleNode(node, print) {
|
|
209832
|
+
var _a, _b;
|
|
209833
|
+
let items = ((_a = node.items) != null ? _a : []).map(print).filter(Boolean);
|
|
209834
|
+
const restNode = node.rest ? (_b = print(node.rest)) != null ? _b : void 0 : void 0;
|
|
209835
|
+
const { min, max } = node;
|
|
209836
|
+
if (max !== void 0) {
|
|
209837
|
+
items = items.slice(0, max);
|
|
209838
|
+
if (items.length < max && restNode) items = [...items, ...Array(max - items.length).fill(restNode)];
|
|
209839
|
+
}
|
|
209840
|
+
if (min !== void 0) items = items.map((item, i) => i >= min ? createOptionalTypeNode(item) : item);
|
|
209841
|
+
if (max === void 0 && restNode) items.push(createRestTypeNode(createArrayTypeNode(restNode)));
|
|
209842
|
+
return createTupleTypeNode(items);
|
|
209843
|
+
}
|
|
209844
|
+
function buildPropertyType(schema, baseType, optionalType) {
|
|
209845
|
+
const addsUndefined = OPTIONAL_ADDS_UNDEFINED.has(optionalType);
|
|
209846
|
+
let type = baseType;
|
|
209847
|
+
if (schema.nullable) type = createUnionDeclaration({ nodes: [type, keywordTypeNodes.null] });
|
|
209848
|
+
if ((schema.nullish || schema.optional) && addsUndefined) type = createUnionDeclaration({ nodes: [type, keywordTypeNodes.undefined] });
|
|
209849
|
+
return type;
|
|
209850
|
+
}
|
|
209851
|
+
function buildPropertyJSDocComments(schema) {
|
|
209852
|
+
const isArray = schema.type === "array";
|
|
209853
|
+
return [
|
|
209854
|
+
"description" in schema && schema.description ? `@description ${jsStringEscape$1(schema.description)}` : void 0,
|
|
209855
|
+
"deprecated" in schema && schema.deprecated ? "@deprecated" : void 0,
|
|
209856
|
+
!isArray && "min" in schema && schema.min !== void 0 ? `@minLength ${schema.min}` : void 0,
|
|
209857
|
+
!isArray && "max" in schema && schema.max !== void 0 ? `@maxLength ${schema.max}` : void 0,
|
|
209858
|
+
"pattern" in schema && schema.pattern ? `@pattern ${schema.pattern}` : void 0,
|
|
209859
|
+
"default" in schema && schema.default !== void 0 ? `@default ${"primitive" in schema && schema.primitive === "string" ? stringify$1(schema.default) : schema.default}` : void 0,
|
|
209860
|
+
"example" in schema && schema.example !== void 0 ? `@example ${schema.example}` : void 0,
|
|
209861
|
+
"primitive" in schema && schema.primitive ? [`@type ${schema.primitive || "unknown"}`, "optional" in schema && schema.optional ? " | undefined" : void 0].filter(Boolean).join("") : void 0
|
|
209862
|
+
];
|
|
209863
|
+
}
|
|
209864
|
+
function buildIndexSignatures(node, propertyCount, print) {
|
|
209865
|
+
var _a, _b;
|
|
209866
|
+
const elements = [];
|
|
209867
|
+
if (node.additionalProperties && node.additionalProperties !== true) {
|
|
209868
|
+
const additionalType = (_a = print(node.additionalProperties)) != null ? _a : keywordTypeNodes.unknown;
|
|
209869
|
+
elements.push(createIndexSignature(propertyCount > 0 ? keywordTypeNodes.unknown : additionalType));
|
|
209870
|
+
} else if (node.additionalProperties === true) elements.push(createIndexSignature(keywordTypeNodes.unknown));
|
|
209871
|
+
if (node.patternProperties) {
|
|
209872
|
+
const first = Object.values(node.patternProperties)[0];
|
|
209873
|
+
if (first) {
|
|
209874
|
+
let patternType = (_b = print(first)) != null ? _b : keywordTypeNodes.unknown;
|
|
209875
|
+
if (first.nullable) patternType = createUnionDeclaration({ nodes: [patternType, keywordTypeNodes.null] });
|
|
209876
|
+
elements.push(createIndexSignature(patternType));
|
|
209877
|
+
}
|
|
209878
|
+
}
|
|
209879
|
+
return elements;
|
|
209880
|
+
}
|
|
209881
|
+
const printerTs = definePrinter((options) => {
|
|
209882
|
+
const addsUndefined = OPTIONAL_ADDS_UNDEFINED.has(options.optionalType);
|
|
209883
|
+
return {
|
|
209884
|
+
name: "typescript",
|
|
209885
|
+
options,
|
|
209886
|
+
nodes: {
|
|
209887
|
+
any: () => keywordTypeNodes.any,
|
|
209888
|
+
unknown: () => keywordTypeNodes.unknown,
|
|
209889
|
+
void: () => keywordTypeNodes.void,
|
|
209890
|
+
never: () => keywordTypeNodes.never,
|
|
209891
|
+
boolean: () => keywordTypeNodes.boolean,
|
|
209892
|
+
null: () => keywordTypeNodes.null,
|
|
209893
|
+
blob: () => createTypeReferenceNode("Blob", []),
|
|
209894
|
+
string: () => keywordTypeNodes.string,
|
|
209895
|
+
uuid: () => keywordTypeNodes.string,
|
|
209896
|
+
email: () => keywordTypeNodes.string,
|
|
209897
|
+
url: (node) => {
|
|
209898
|
+
if (node.path) return createUrlTemplateType(node.path);
|
|
209899
|
+
return keywordTypeNodes.string;
|
|
209900
|
+
},
|
|
209901
|
+
datetime: () => keywordTypeNodes.string,
|
|
209902
|
+
number: () => keywordTypeNodes.number,
|
|
209903
|
+
integer: () => keywordTypeNodes.number,
|
|
209904
|
+
bigint: () => keywordTypeNodes.bigint,
|
|
209905
|
+
date: dateOrStringNode,
|
|
209906
|
+
time: dateOrStringNode,
|
|
209907
|
+
ref(node) {
|
|
209908
|
+
var _a, _b;
|
|
209909
|
+
if (!node.name) return;
|
|
209910
|
+
const refName = node.ref ? (_a = node.ref.split("/").at(-1)) != null ? _a : node.name : node.name;
|
|
209911
|
+
return createTypeReferenceNode(node.ref && ENUM_TYPES_WITH_KEY_SUFFIX.has(this.options.enumType) && this.options.enumTypeSuffix && ((_b = this.options.enumSchemaNames) == null ? void 0 : _b.has(refName)) ? this.options.resolver.resolveEnumKeyName({ name: refName }, this.options.enumTypeSuffix) : node.ref ? this.options.resolver.default(refName, "type") : refName, void 0);
|
|
209912
|
+
},
|
|
209913
|
+
enum(node) {
|
|
209914
|
+
var _a, _b, _c, _d;
|
|
209915
|
+
const values = (_c = (_b = (_a = node.namedEnumValues) == null ? void 0 : _a.map((v) => v.value)) != null ? _b : node.enumValues) != null ? _c : [];
|
|
209916
|
+
if (this.options.enumType === "inlineLiteral" || !node.name) return (_d = createUnionDeclaration({
|
|
209917
|
+
withParentheses: true,
|
|
209918
|
+
nodes: values.filter((v) => v !== null).map((value) => constToTypeNode(value, typeof value)).filter(Boolean)
|
|
209919
|
+
})) != null ? _d : void 0;
|
|
209920
|
+
return createTypeReferenceNode(ENUM_TYPES_WITH_KEY_SUFFIX.has(this.options.enumType) && this.options.enumTypeSuffix ? this.options.resolver.resolveEnumKeyName(node, this.options.enumTypeSuffix) : this.options.resolver.default(node.name, "type"), void 0);
|
|
209921
|
+
},
|
|
209922
|
+
union(node) {
|
|
209923
|
+
var _a, _b, _c;
|
|
209924
|
+
const members = (_a = node.members) != null ? _a : [];
|
|
209925
|
+
const hasStringLiteral = members.some((m) => {
|
|
209926
|
+
var _a2;
|
|
209927
|
+
return ((_a2 = narrowSchema(m, schemaTypes.enum)) == null ? void 0 : _a2.primitive) === "string";
|
|
209928
|
+
});
|
|
209929
|
+
const hasPlainString = members.some((m) => isStringType(m));
|
|
209930
|
+
if (hasStringLiteral && hasPlainString) return (_b = createUnionDeclaration({
|
|
209931
|
+
withParentheses: true,
|
|
209932
|
+
nodes: members.map((m) => {
|
|
209933
|
+
if (isStringType(m)) return createIntersectionDeclaration({
|
|
209934
|
+
nodes: [keywordTypeNodes.string, createTypeLiteralNode([])],
|
|
209935
|
+
withParentheses: true
|
|
209936
|
+
});
|
|
209937
|
+
return this.transform(m);
|
|
209938
|
+
}).filter(Boolean)
|
|
209939
|
+
})) != null ? _b : void 0;
|
|
209940
|
+
return (_c = createUnionDeclaration({
|
|
209941
|
+
withParentheses: true,
|
|
209942
|
+
nodes: buildMemberNodes(members, this.transform)
|
|
209943
|
+
})) != null ? _c : void 0;
|
|
209944
|
+
},
|
|
209945
|
+
intersection(node) {
|
|
209946
|
+
var _a;
|
|
209947
|
+
return (_a = createIntersectionDeclaration({
|
|
209948
|
+
withParentheses: true,
|
|
209949
|
+
nodes: buildMemberNodes(node.members, this.transform)
|
|
209950
|
+
})) != null ? _a : void 0;
|
|
209951
|
+
},
|
|
209952
|
+
array(node) {
|
|
209953
|
+
var _a, _b;
|
|
209954
|
+
return (_b = createArrayDeclaration({
|
|
209955
|
+
nodes: ((_a = node.items) != null ? _a : []).map((item) => this.transform(item)).filter(Boolean),
|
|
209956
|
+
arrayType: this.options.arrayType
|
|
209957
|
+
})) != null ? _b : void 0;
|
|
209958
|
+
},
|
|
209959
|
+
tuple(node) {
|
|
209960
|
+
return buildTupleNode(node, this.transform);
|
|
209961
|
+
},
|
|
209962
|
+
object(node) {
|
|
209963
|
+
const { transform: transform2, options: options2 } = this;
|
|
209964
|
+
const addsQuestionToken = OPTIONAL_ADDS_QUESTION_TOKEN.has(options2.optionalType);
|
|
209965
|
+
const propertyNodes = node.properties.map((prop) => {
|
|
209966
|
+
var _a;
|
|
209967
|
+
const baseType = (_a = transform2(prop.schema)) != null ? _a : keywordTypeNodes.unknown;
|
|
209968
|
+
const type = buildPropertyType(prop.schema, baseType, options2.optionalType);
|
|
209969
|
+
return appendJSDocToNode({
|
|
209970
|
+
node: createPropertySignature({
|
|
209971
|
+
questionToken: prop.schema.optional || prop.schema.nullish ? addsQuestionToken : false,
|
|
209972
|
+
name: prop.name,
|
|
209973
|
+
type,
|
|
209974
|
+
readOnly: prop.schema.readOnly
|
|
209975
|
+
}),
|
|
209976
|
+
comments: buildPropertyJSDocComments(prop.schema)
|
|
209977
|
+
});
|
|
209978
|
+
});
|
|
209979
|
+
const allElements = [...propertyNodes, ...buildIndexSignatures(node, propertyNodes.length, transform2)];
|
|
209980
|
+
if (!allElements.length) return keywordTypeNodes.object;
|
|
209981
|
+
return createTypeLiteralNode(allElements);
|
|
209982
|
+
}
|
|
209983
|
+
},
|
|
209984
|
+
print(node) {
|
|
209985
|
+
let type = this.transform(node);
|
|
209986
|
+
if (!type) return null;
|
|
209987
|
+
if (node.nullable) type = createUnionDeclaration({ nodes: [type, keywordTypeNodes.null] });
|
|
209988
|
+
if ((node.nullish || node.optional) && addsUndefined) type = createUnionDeclaration({ nodes: [type, keywordTypeNodes.undefined] });
|
|
209989
|
+
const { name, syntaxType = "type", description, keysToOmit } = this.options;
|
|
209990
|
+
if (!name) return safePrint(type);
|
|
209991
|
+
const useTypeGeneration = syntaxType === "type" || type.kind === syntaxKind.union || !!(keysToOmit == null ? void 0 : keysToOmit.length);
|
|
209992
|
+
return safePrint(createTypeDeclaration({
|
|
209993
|
+
name,
|
|
209994
|
+
isExportable: true,
|
|
209995
|
+
type: (keysToOmit == null ? void 0 : keysToOmit.length) ? createOmitDeclaration({
|
|
209996
|
+
keys: keysToOmit,
|
|
209997
|
+
type,
|
|
209998
|
+
nonNullable: true
|
|
209999
|
+
}) : type,
|
|
210000
|
+
syntax: useTypeGeneration ? "type" : "interface",
|
|
210001
|
+
comments: [
|
|
210002
|
+
(node == null ? void 0 : node.title) ? jsStringEscape$1(node.title) : void 0,
|
|
210003
|
+
description ? `@description ${jsStringEscape$1(description)}` : void 0,
|
|
210004
|
+
(node == null ? void 0 : node.deprecated) ? "@deprecated" : void 0,
|
|
210005
|
+
node && "min" in node && node.min !== void 0 ? `@minLength ${node.min}` : void 0,
|
|
210006
|
+
node && "max" in node && node.max !== void 0 ? `@maxLength ${node.max}` : void 0,
|
|
210007
|
+
node && "pattern" in node && node.pattern ? `@pattern ${node.pattern}` : void 0,
|
|
210008
|
+
(node == null ? void 0 : node.default) ? `@default ${node.default}` : void 0,
|
|
210009
|
+
(node == null ? void 0 : node.example) ? `@example ${node.example}` : void 0
|
|
210010
|
+
]
|
|
210011
|
+
}));
|
|
210012
|
+
}
|
|
210013
|
+
};
|
|
210014
|
+
});
|
|
210015
|
+
function Type({ name, node, keysToOmit, optionalType, arrayType, syntaxType, enumType, enumTypeSuffix, enumKeyCasing, description, resolver, enumSchemaNames }) {
|
|
209976
210016
|
const resolvedDescription = description || (node == null ? void 0 : node.description);
|
|
209977
210017
|
const enumSchemaNodes = collect(node, { schema(n) {
|
|
209978
210018
|
const enumNode = narrowSchema(n, schemaTypes.enum);
|
|
@@ -209983,11 +210023,12 @@ function Type({ name, typedName, node, keysToOmit, optionalType, arrayType, synt
|
|
|
209983
210023
|
arrayType,
|
|
209984
210024
|
enumType,
|
|
209985
210025
|
enumTypeSuffix,
|
|
209986
|
-
|
|
210026
|
+
name,
|
|
209987
210027
|
syntaxType,
|
|
209988
210028
|
description: resolvedDescription,
|
|
209989
210029
|
keysToOmit,
|
|
209990
|
-
resolver
|
|
210030
|
+
resolver,
|
|
210031
|
+
enumSchemaNames
|
|
209991
210032
|
}).print(node);
|
|
209992
210033
|
if (!output) return;
|
|
209993
210034
|
const enums = [...new Map(enumSchemaNodes.map((n) => [n.name, n])).values()].map((node2) => {
|
|
@@ -210010,156 +210051,125 @@ function Type({ name, typedName, node, keysToOmit, optionalType, arrayType, synt
|
|
|
210010
210051
|
enumKeyCasing,
|
|
210011
210052
|
resolver
|
|
210012
210053
|
})), shouldExportType && /* @__PURE__ */ jsx(File.Source, {
|
|
210013
|
-
name
|
|
210054
|
+
name,
|
|
210014
210055
|
isTypeOnly: true,
|
|
210015
210056
|
isExportable: true,
|
|
210016
210057
|
isIndexable: true,
|
|
210017
210058
|
children: output
|
|
210018
210059
|
})] });
|
|
210019
210060
|
}
|
|
210020
|
-
|
|
210021
|
-
|
|
210022
|
-
|
|
210061
|
+
function buildParams({ params, node, resolver }) {
|
|
210062
|
+
return createSchema({
|
|
210063
|
+
type: "object",
|
|
210064
|
+
properties: params.map((param) => createProperty({
|
|
210065
|
+
name: param.name,
|
|
210066
|
+
required: param.required,
|
|
210067
|
+
schema: createSchema({
|
|
210068
|
+
type: "ref",
|
|
210069
|
+
name: resolver.resolveParamName(node, param)
|
|
210070
|
+
})
|
|
210071
|
+
}))
|
|
210072
|
+
});
|
|
210073
|
+
}
|
|
210074
|
+
function buildData({ node, resolver }) {
|
|
210075
|
+
var _a;
|
|
210076
|
+
const pathParams = node.parameters.filter((p) => p.in === "path");
|
|
210077
|
+
const queryParams = node.parameters.filter((p) => p.in === "query");
|
|
210078
|
+
const headerParams = node.parameters.filter((p) => p.in === "header");
|
|
210079
|
+
return createSchema({
|
|
210080
|
+
type: "object",
|
|
210081
|
+
deprecated: node.deprecated,
|
|
210082
|
+
properties: [
|
|
210083
|
+
createProperty({
|
|
210084
|
+
name: "data",
|
|
210085
|
+
schema: ((_a = node.requestBody) == null ? void 0 : _a.schema) ? createSchema({
|
|
210086
|
+
type: "ref",
|
|
210087
|
+
name: resolver.resolveDataName(node),
|
|
210088
|
+
optional: true
|
|
210089
|
+
}) : createSchema({
|
|
210090
|
+
type: "never",
|
|
210091
|
+
optional: true
|
|
210092
|
+
})
|
|
210093
|
+
}),
|
|
210094
|
+
createProperty({
|
|
210095
|
+
name: "pathParams",
|
|
210096
|
+
required: pathParams.length > 0,
|
|
210097
|
+
schema: pathParams.length > 0 ? buildParams({
|
|
210098
|
+
params: pathParams,
|
|
210099
|
+
node,
|
|
210100
|
+
resolver
|
|
210101
|
+
}) : createSchema({ type: "never" })
|
|
210102
|
+
}),
|
|
210103
|
+
createProperty({
|
|
210104
|
+
name: "queryParams",
|
|
210105
|
+
schema: queryParams.length > 0 ? createSchema({
|
|
210106
|
+
...buildParams({
|
|
210107
|
+
params: queryParams,
|
|
210108
|
+
node,
|
|
210109
|
+
resolver
|
|
210110
|
+
}),
|
|
210111
|
+
optional: true
|
|
210112
|
+
}) : createSchema({
|
|
210113
|
+
type: "never",
|
|
210114
|
+
optional: true
|
|
210115
|
+
})
|
|
210116
|
+
}),
|
|
210117
|
+
createProperty({
|
|
210118
|
+
name: "headerParams",
|
|
210119
|
+
schema: headerParams.length > 0 ? createSchema({
|
|
210120
|
+
...buildParams({
|
|
210121
|
+
params: headerParams,
|
|
210122
|
+
node,
|
|
210123
|
+
resolver
|
|
210124
|
+
}),
|
|
210125
|
+
optional: true
|
|
210126
|
+
}) : createSchema({
|
|
210127
|
+
type: "never",
|
|
210128
|
+
optional: true
|
|
210129
|
+
})
|
|
210130
|
+
}),
|
|
210131
|
+
createProperty({
|
|
210132
|
+
name: "url",
|
|
210133
|
+
required: true,
|
|
210134
|
+
schema: createSchema({
|
|
210135
|
+
type: "url",
|
|
210136
|
+
path: node.path
|
|
210137
|
+
})
|
|
210138
|
+
})
|
|
210139
|
+
]
|
|
210140
|
+
});
|
|
210141
|
+
}
|
|
210142
|
+
function buildResponses({ node, resolver }) {
|
|
210143
|
+
if (node.responses.length === 0) return null;
|
|
210144
|
+
return createSchema({
|
|
210145
|
+
type: "object",
|
|
210146
|
+
properties: node.responses.map((res) => createProperty({
|
|
210147
|
+
name: String(res.statusCode),
|
|
210148
|
+
required: true,
|
|
210149
|
+
schema: createSchema({
|
|
210150
|
+
type: "ref",
|
|
210151
|
+
name: resolver.resolveResponseStatusName(node, res.statusCode)
|
|
210152
|
+
})
|
|
210153
|
+
}))
|
|
210154
|
+
});
|
|
210155
|
+
}
|
|
210156
|
+
function buildResponseUnion({ node, resolver }) {
|
|
210157
|
+
const responsesWithSchema = node.responses.filter((res) => res.schema);
|
|
210158
|
+
if (responsesWithSchema.length === 0) return null;
|
|
210159
|
+
return createSchema({
|
|
210160
|
+
type: "union",
|
|
210161
|
+
members: responsesWithSchema.map((res) => createSchema({
|
|
210162
|
+
type: "ref",
|
|
210163
|
+
name: resolver.resolveResponseStatusName(node, res.statusCode)
|
|
210164
|
+
}))
|
|
210165
|
+
});
|
|
210023
210166
|
}
|
|
210024
|
-
const resolverTs = defineResolver(() => {
|
|
210025
|
-
return {
|
|
210026
|
-
name: "default",
|
|
210027
|
-
pluginName: "plugin-ts",
|
|
210028
|
-
default(name, type) {
|
|
210029
|
-
return resolveName(name, type);
|
|
210030
|
-
},
|
|
210031
|
-
resolveName(name) {
|
|
210032
|
-
return this.default(name, "function");
|
|
210033
|
-
},
|
|
210034
|
-
resolveTypedName(name) {
|
|
210035
|
-
return this.default(name, "type");
|
|
210036
|
-
},
|
|
210037
|
-
resolvePathName(name, type) {
|
|
210038
|
-
return this.default(name, type);
|
|
210039
|
-
},
|
|
210040
|
-
resolveParamName(node, param) {
|
|
210041
|
-
return this.resolveName(`${node.operationId} ${this.default(param.in)} ${param.name}`);
|
|
210042
|
-
},
|
|
210043
|
-
resolveParamTypedName(node, param) {
|
|
210044
|
-
return this.resolveTypedName(`${node.operationId} ${this.default(param.in)} ${param.name}`);
|
|
210045
|
-
},
|
|
210046
|
-
resolveResponseStatusName(node, statusCode) {
|
|
210047
|
-
return this.resolveName(`${node.operationId} Status ${statusCode}`);
|
|
210048
|
-
},
|
|
210049
|
-
resolveResponseStatusTypedName(node, statusCode) {
|
|
210050
|
-
return this.resolveTypedName(`${node.operationId} Status ${statusCode}`);
|
|
210051
|
-
},
|
|
210052
|
-
resolveDataName(node) {
|
|
210053
|
-
return this.resolveName(`${node.operationId} Data`);
|
|
210054
|
-
},
|
|
210055
|
-
resolveDataTypedName(node) {
|
|
210056
|
-
return this.resolveTypedName(`${node.operationId} Data`);
|
|
210057
|
-
},
|
|
210058
|
-
resolveRequestConfigName(node) {
|
|
210059
|
-
return this.resolveName(`${node.operationId} RequestConfig`);
|
|
210060
|
-
},
|
|
210061
|
-
resolveRequestConfigTypedName(node) {
|
|
210062
|
-
return this.resolveTypedName(`${node.operationId} RequestConfig`);
|
|
210063
|
-
},
|
|
210064
|
-
resolveResponsesName(node) {
|
|
210065
|
-
return this.resolveName(`${node.operationId} Responses`);
|
|
210066
|
-
},
|
|
210067
|
-
resolveResponsesTypedName(node) {
|
|
210068
|
-
return this.resolveTypedName(`${node.operationId} Responses`);
|
|
210069
|
-
},
|
|
210070
|
-
resolveResponseName(node) {
|
|
210071
|
-
return this.resolveName(`${node.operationId} Response`);
|
|
210072
|
-
},
|
|
210073
|
-
resolveResponseTypedName(node) {
|
|
210074
|
-
return this.resolveTypedName(`${node.operationId} Response`);
|
|
210075
|
-
},
|
|
210076
|
-
resolveEnumKeyTypedName(node, enumTypeSuffix = "key") {
|
|
210077
|
-
var _a;
|
|
210078
|
-
return `${this.resolveTypedName((_a = node.name) != null ? _a : "")}${enumTypeSuffix}`;
|
|
210079
|
-
},
|
|
210080
|
-
resolvePathParamsName(_node) {
|
|
210081
|
-
throw new Error("resolvePathParamsName is only available with compatibilityPreset: 'kubbV4'. Use resolveParamName per individual parameter instead.");
|
|
210082
|
-
},
|
|
210083
|
-
resolvePathParamsTypedName(_node) {
|
|
210084
|
-
throw new Error("resolvePathParamsTypedName is only available with compatibilityPreset: 'kubbV4'. Use resolveParamTypedName per individual parameter instead.");
|
|
210085
|
-
},
|
|
210086
|
-
resolveQueryParamsName(_node) {
|
|
210087
|
-
throw new Error("resolveQueryParamsName is only available with compatibilityPreset: 'kubbV4'. Use resolveParamName per individual parameter instead.");
|
|
210088
|
-
},
|
|
210089
|
-
resolveQueryParamsTypedName(_node) {
|
|
210090
|
-
throw new Error("resolveQueryParamsTypedName is only available with compatibilityPreset: 'kubbV4'. Use resolveParamTypedName per individual parameter instead.");
|
|
210091
|
-
},
|
|
210092
|
-
resolveHeaderParamsName(_node) {
|
|
210093
|
-
throw new Error("resolveHeaderParamsName is only available with compatibilityPreset: 'kubbV4'. Use resolveParamName per individual parameter instead.");
|
|
210094
|
-
},
|
|
210095
|
-
resolveHeaderParamsTypedName(_node) {
|
|
210096
|
-
throw new Error("resolveHeaderParamsTypedName is only available with compatibilityPreset: 'kubbV4'. Use resolveParamTypedName per individual parameter instead.");
|
|
210097
|
-
}
|
|
210098
|
-
};
|
|
210099
|
-
});
|
|
210100
|
-
const resolverTsLegacy = defineResolver(() => {
|
|
210101
|
-
return {
|
|
210102
|
-
...resolverTs,
|
|
210103
|
-
pluginName: "plugin-ts",
|
|
210104
|
-
resolveResponseStatusName(node, statusCode) {
|
|
210105
|
-
if (statusCode === "default") return this.resolveName(`${node.operationId} Error`);
|
|
210106
|
-
return this.resolveName(`${node.operationId} ${statusCode}`);
|
|
210107
|
-
},
|
|
210108
|
-
resolveResponseStatusTypedName(node, statusCode) {
|
|
210109
|
-
if (statusCode === "default") return this.resolveTypedName(`${node.operationId} Error`);
|
|
210110
|
-
return this.resolveTypedName(`${node.operationId} ${statusCode}`);
|
|
210111
|
-
},
|
|
210112
|
-
resolveDataName(node) {
|
|
210113
|
-
const suffix = node.method === "GET" ? "QueryRequest" : "MutationRequest";
|
|
210114
|
-
return this.resolveName(`${node.operationId} ${suffix}`);
|
|
210115
|
-
},
|
|
210116
|
-
resolveDataTypedName(node) {
|
|
210117
|
-
const suffix = node.method === "GET" ? "QueryRequest" : "MutationRequest";
|
|
210118
|
-
return this.resolveTypedName(`${node.operationId} ${suffix}`);
|
|
210119
|
-
},
|
|
210120
|
-
resolveResponsesName(node) {
|
|
210121
|
-
const suffix = node.method === "GET" ? "Query" : "Mutation";
|
|
210122
|
-
return `${this.default(node.operationId, "function")}${suffix}`;
|
|
210123
|
-
},
|
|
210124
|
-
resolveResponsesTypedName(node) {
|
|
210125
|
-
const suffix = node.method === "GET" ? "Query" : "Mutation";
|
|
210126
|
-
return `${this.default(node.operationId, "type")}${suffix}`;
|
|
210127
|
-
},
|
|
210128
|
-
resolveResponseName(node) {
|
|
210129
|
-
const suffix = node.method === "GET" ? "QueryResponse" : "MutationResponse";
|
|
210130
|
-
return this.resolveName(`${node.operationId} ${suffix}`);
|
|
210131
|
-
},
|
|
210132
|
-
resolveResponseTypedName(node) {
|
|
210133
|
-
const suffix = node.method === "GET" ? "QueryResponse" : "MutationResponse";
|
|
210134
|
-
return this.resolveTypedName(`${node.operationId} ${suffix}`);
|
|
210135
|
-
},
|
|
210136
|
-
resolvePathParamsName(node) {
|
|
210137
|
-
return this.resolveName(`${node.operationId} PathParams`);
|
|
210138
|
-
},
|
|
210139
|
-
resolvePathParamsTypedName(node) {
|
|
210140
|
-
return this.resolveTypedName(`${node.operationId} PathParams`);
|
|
210141
|
-
},
|
|
210142
|
-
resolveQueryParamsName(node) {
|
|
210143
|
-
return this.resolveName(`${node.operationId} QueryParams`);
|
|
210144
|
-
},
|
|
210145
|
-
resolveQueryParamsTypedName(node) {
|
|
210146
|
-
return this.resolveTypedName(`${node.operationId} QueryParams`);
|
|
210147
|
-
},
|
|
210148
|
-
resolveHeaderParamsName(node) {
|
|
210149
|
-
return this.resolveName(`${node.operationId} HeaderParams`);
|
|
210150
|
-
},
|
|
210151
|
-
resolveHeaderParamsTypedName(node) {
|
|
210152
|
-
return this.resolveTypedName(`${node.operationId} HeaderParams`);
|
|
210153
|
-
}
|
|
210154
|
-
};
|
|
210155
|
-
});
|
|
210156
|
-
|
|
210157
210167
|
const typeGenerator = defineGenerator({
|
|
210158
210168
|
name: "typescript",
|
|
210159
210169
|
type: "react",
|
|
210160
|
-
Operation({ node, adapter, options, config }) {
|
|
210161
|
-
var _a, _b, _c;
|
|
210162
|
-
const { enumType, enumTypeSuffix, enumKeyCasing, optionalType, arrayType, syntaxType, paramsCasing, group, output,
|
|
210170
|
+
Operation({ node, adapter, options, config, resolver }) {
|
|
210171
|
+
var _a, _b, _c, _d, _e;
|
|
210172
|
+
const { enumType, enumTypeSuffix, enumKeyCasing, optionalType, arrayType, syntaxType, paramsCasing, group, output, transformers = [] } = options;
|
|
210163
210173
|
const root = path$2.resolve(config.root, config.output.path);
|
|
210164
210174
|
const mode = getMode(path$2.resolve(root, output.path));
|
|
210165
210175
|
const file = resolver.resolveFile({
|
|
@@ -210173,11 +210183,16 @@ const typeGenerator = defineGenerator({
|
|
|
210173
210183
|
group
|
|
210174
210184
|
});
|
|
210175
210185
|
const params = caseParams(node.parameters, paramsCasing);
|
|
210176
|
-
|
|
210186
|
+
const enumSchemaNames = new Set(((_c = (_b = adapter.rootNode) == null ? void 0 : _b.schemas) != null ? _c : []).filter((s) => narrowSchema(s, schemaTypes.enum) && s.name).map((s) => s.name));
|
|
210187
|
+
function resolveImportName(schemaName) {
|
|
210188
|
+
if (ENUM_TYPES_WITH_KEY_SUFFIX.has(enumType) && enumTypeSuffix && enumSchemaNames.has(schemaName)) return resolver.resolveEnumKeyName({ name: schemaName }, enumTypeSuffix);
|
|
210189
|
+
return resolver.default(schemaName, "type");
|
|
210190
|
+
}
|
|
210191
|
+
function renderSchemaType({ node: schemaNode, name, description, keysToOmit }) {
|
|
210177
210192
|
if (!schemaNode) return null;
|
|
210178
210193
|
const transformedNode = transform(schemaNode, composeTransformers(...transformers));
|
|
210179
210194
|
const imports = adapter.getImports(transformedNode, (schemaName) => ({
|
|
210180
|
-
name:
|
|
210195
|
+
name: resolveImportName(schemaName),
|
|
210181
210196
|
path: resolver.resolveFile({
|
|
210182
210197
|
name: schemaName,
|
|
210183
210198
|
extname: ".ts"
|
|
@@ -210198,7 +210213,6 @@ const typeGenerator = defineGenerator({
|
|
|
210198
210213
|
imp.isTypeOnly
|
|
210199
210214
|
].join("-"))), /* @__PURE__ */ jsx(Type, {
|
|
210200
210215
|
name,
|
|
210201
|
-
typedName,
|
|
210202
210216
|
node: transformedNode,
|
|
210203
210217
|
description,
|
|
210204
210218
|
enumType,
|
|
@@ -210208,54 +210222,49 @@ const typeGenerator = defineGenerator({
|
|
|
210208
210222
|
arrayType,
|
|
210209
210223
|
syntaxType,
|
|
210210
210224
|
resolver,
|
|
210211
|
-
keysToOmit
|
|
210225
|
+
keysToOmit,
|
|
210226
|
+
enumSchemaNames
|
|
210212
210227
|
})] });
|
|
210213
210228
|
}
|
|
210214
210229
|
const paramTypes = params.map((param) => renderSchemaType({
|
|
210215
210230
|
node: param.schema,
|
|
210216
|
-
name: resolver.resolveParamName(node, param)
|
|
210217
|
-
typedName: resolver.resolveParamTypedName(node, param)
|
|
210231
|
+
name: resolver.resolveParamName(node, param)
|
|
210218
210232
|
}));
|
|
210219
|
-
const requestType = ((
|
|
210233
|
+
const requestType = ((_d = node.requestBody) == null ? void 0 : _d.schema) ? renderSchemaType({
|
|
210220
210234
|
node: node.requestBody.schema,
|
|
210221
210235
|
name: resolver.resolveDataName(node),
|
|
210222
|
-
|
|
210223
|
-
description: (_c = node.requestBody.description) != null ? _c : node.requestBody.schema.description,
|
|
210236
|
+
description: (_e = node.requestBody.description) != null ? _e : node.requestBody.schema.description,
|
|
210224
210237
|
keysToOmit: node.requestBody.keysToOmit
|
|
210225
210238
|
}) : null;
|
|
210226
210239
|
const responseTypes = node.responses.map((res) => renderSchemaType({
|
|
210227
210240
|
node: res.schema,
|
|
210228
210241
|
name: resolver.resolveResponseStatusName(node, res.statusCode),
|
|
210229
|
-
typedName: resolver.resolveResponseStatusTypedName(node, res.statusCode),
|
|
210230
210242
|
description: res.description,
|
|
210231
210243
|
keysToOmit: res.keysToOmit
|
|
210232
210244
|
}));
|
|
210233
210245
|
const dataType = renderSchemaType({
|
|
210234
|
-
node:
|
|
210246
|
+
node: buildData({
|
|
210235
210247
|
node: {
|
|
210236
210248
|
...node,
|
|
210237
210249
|
parameters: params
|
|
210238
210250
|
},
|
|
210239
210251
|
resolver
|
|
210240
210252
|
}),
|
|
210241
|
-
name: resolver.resolveRequestConfigName(node)
|
|
210242
|
-
typedName: resolver.resolveRequestConfigTypedName(node)
|
|
210253
|
+
name: resolver.resolveRequestConfigName(node)
|
|
210243
210254
|
});
|
|
210244
210255
|
const responsesType = renderSchemaType({
|
|
210245
|
-
node:
|
|
210256
|
+
node: buildResponses({
|
|
210246
210257
|
node,
|
|
210247
210258
|
resolver
|
|
210248
210259
|
}),
|
|
210249
|
-
name: resolver.resolveResponsesName(node)
|
|
210250
|
-
typedName: resolver.resolveResponsesTypedName(node)
|
|
210260
|
+
name: resolver.resolveResponsesName(node)
|
|
210251
210261
|
});
|
|
210252
210262
|
const responseType = renderSchemaType({
|
|
210253
|
-
node:
|
|
210263
|
+
node: buildResponseUnion({
|
|
210254
210264
|
node,
|
|
210255
210265
|
resolver
|
|
210256
210266
|
}),
|
|
210257
210267
|
name: resolver.resolveResponseName(node),
|
|
210258
|
-
typedName: resolver.resolveResponseTypedName(node),
|
|
210259
210268
|
description: "Union of all possible responses"
|
|
210260
210269
|
});
|
|
210261
210270
|
return /* @__PURE__ */ jsxs(File, {
|
|
@@ -210280,14 +210289,20 @@ const typeGenerator = defineGenerator({
|
|
|
210280
210289
|
]
|
|
210281
210290
|
});
|
|
210282
210291
|
},
|
|
210283
|
-
Schema({ node, adapter, options, config }) {
|
|
210284
|
-
|
|
210292
|
+
Schema({ node, adapter, options, config, resolver }) {
|
|
210293
|
+
var _a, _b;
|
|
210294
|
+
const { enumType, enumTypeSuffix, enumKeyCasing, syntaxType, optionalType, arrayType, output, group, transformers = [] } = options;
|
|
210285
210295
|
const root = path$2.resolve(config.root, config.output.path);
|
|
210286
210296
|
const mode = getMode(path$2.resolve(root, output.path));
|
|
210287
210297
|
if (!node.name) return;
|
|
210288
210298
|
const transformedNode = transform(node, composeTransformers(...transformers));
|
|
210299
|
+
const enumSchemaNames = new Set(((_b = (_a = adapter.rootNode) == null ? void 0 : _a.schemas) != null ? _b : []).filter((s) => narrowSchema(s, schemaTypes.enum) && s.name).map((s) => s.name));
|
|
210300
|
+
function resolveImportName(schemaName) {
|
|
210301
|
+
if (ENUM_TYPES_WITH_KEY_SUFFIX.has(enumType) && enumTypeSuffix && enumSchemaNames.has(schemaName)) return resolver.resolveEnumKeyName({ name: schemaName }, enumTypeSuffix);
|
|
210302
|
+
return resolver.default(schemaName, "type");
|
|
210303
|
+
}
|
|
210289
210304
|
const imports = adapter.getImports(transformedNode, (schemaName) => ({
|
|
210290
|
-
name:
|
|
210305
|
+
name: resolveImportName(schemaName),
|
|
210291
210306
|
path: resolver.resolveFile({
|
|
210292
210307
|
name: schemaName,
|
|
210293
210308
|
extname: ".ts"
|
|
@@ -210298,10 +210313,8 @@ const typeGenerator = defineGenerator({
|
|
|
210298
210313
|
}).path
|
|
210299
210314
|
}));
|
|
210300
210315
|
const isEnumSchema = !!narrowSchema(node, schemaTypes.enum);
|
|
210301
|
-
const typedName = ENUM_TYPES_WITH_KEY_SUFFIX.has(enumType) && isEnumSchema ? resolver.resolveEnumKeyTypedName(node, enumTypeSuffix) : resolver.resolveTypedName(node.name);
|
|
210302
210316
|
const type = {
|
|
210303
|
-
name: resolver.resolveName(node.name),
|
|
210304
|
-
typedName,
|
|
210317
|
+
name: ENUM_TYPES_WITH_KEY_SUFFIX.has(enumType) && isEnumSchema ? resolver.resolveEnumKeyName(node, enumTypeSuffix) : resolver.resolveName(node.name),
|
|
210305
210318
|
file: resolver.resolveFile({
|
|
210306
210319
|
name: node.name,
|
|
210307
210320
|
extname: ".ts"
|
|
@@ -210334,7 +210347,6 @@ const typeGenerator = defineGenerator({
|
|
|
210334
210347
|
imp.isTypeOnly
|
|
210335
210348
|
].join("-"))), /* @__PURE__ */ jsx(Type, {
|
|
210336
210349
|
name: type.name,
|
|
210337
|
-
typedName: type.typedName,
|
|
210338
210350
|
node: transformedNode,
|
|
210339
210351
|
enumType,
|
|
210340
210352
|
enumTypeSuffix,
|
|
@@ -210342,11 +210354,92 @@ const typeGenerator = defineGenerator({
|
|
|
210342
210354
|
optionalType,
|
|
210343
210355
|
arrayType,
|
|
210344
210356
|
syntaxType,
|
|
210345
|
-
resolver
|
|
210357
|
+
resolver,
|
|
210358
|
+
enumSchemaNames
|
|
210346
210359
|
})]
|
|
210347
210360
|
});
|
|
210348
210361
|
}
|
|
210349
210362
|
});
|
|
210363
|
+
function resolveName(name, type) {
|
|
210364
|
+
return pascalCase$6(name, { isFile: type === "file" });
|
|
210365
|
+
}
|
|
210366
|
+
const resolverTs = defineResolver(() => {
|
|
210367
|
+
return {
|
|
210368
|
+
name: "default",
|
|
210369
|
+
pluginName: "plugin-ts",
|
|
210370
|
+
default(name, type) {
|
|
210371
|
+
return resolveName(name, type);
|
|
210372
|
+
},
|
|
210373
|
+
resolveName(name) {
|
|
210374
|
+
return this.default(name, "function");
|
|
210375
|
+
},
|
|
210376
|
+
resolvePathName(name, type) {
|
|
210377
|
+
return this.default(name, type);
|
|
210378
|
+
},
|
|
210379
|
+
resolveParamName(node, param) {
|
|
210380
|
+
return this.resolveName(`${node.operationId} ${param.in} ${param.name}`);
|
|
210381
|
+
},
|
|
210382
|
+
resolveResponseStatusName(node, statusCode) {
|
|
210383
|
+
return this.resolveName(`${node.operationId} Status ${statusCode}`);
|
|
210384
|
+
},
|
|
210385
|
+
resolveDataName(node) {
|
|
210386
|
+
return this.resolveName(`${node.operationId} Data`);
|
|
210387
|
+
},
|
|
210388
|
+
resolveRequestConfigName(node) {
|
|
210389
|
+
return this.resolveName(`${node.operationId} RequestConfig`);
|
|
210390
|
+
},
|
|
210391
|
+
resolveResponsesName(node) {
|
|
210392
|
+
return this.resolveName(`${node.operationId} Responses`);
|
|
210393
|
+
},
|
|
210394
|
+
resolveResponseName(node) {
|
|
210395
|
+
return this.resolveName(`${node.operationId} Response`);
|
|
210396
|
+
},
|
|
210397
|
+
resolveEnumKeyName(node, enumTypeSuffix = "key") {
|
|
210398
|
+
var _a;
|
|
210399
|
+
return `${this.resolveName((_a = node.name) != null ? _a : "")}${enumTypeSuffix}`;
|
|
210400
|
+
},
|
|
210401
|
+
resolvePathParamsName(node, param) {
|
|
210402
|
+
return this.resolveParamName(node, param);
|
|
210403
|
+
},
|
|
210404
|
+
resolveQueryParamsName(node, param) {
|
|
210405
|
+
return this.resolveParamName(node, param);
|
|
210406
|
+
},
|
|
210407
|
+
resolveHeaderParamsName(node, param) {
|
|
210408
|
+
return this.resolveParamName(node, param);
|
|
210409
|
+
}
|
|
210410
|
+
};
|
|
210411
|
+
});
|
|
210412
|
+
const resolverTsLegacy = defineResolver(() => {
|
|
210413
|
+
return {
|
|
210414
|
+
...resolverTs,
|
|
210415
|
+
pluginName: "plugin-ts",
|
|
210416
|
+
resolveResponseStatusName(node, statusCode) {
|
|
210417
|
+
if (statusCode === "default") return this.resolveName(`${node.operationId} Error`);
|
|
210418
|
+
return this.resolveName(`${node.operationId} ${statusCode}`);
|
|
210419
|
+
},
|
|
210420
|
+
resolveDataName(node) {
|
|
210421
|
+
const suffix = node.method === "GET" ? "QueryRequest" : "MutationRequest";
|
|
210422
|
+
return this.resolveName(`${node.operationId} ${suffix}`);
|
|
210423
|
+
},
|
|
210424
|
+
resolveResponsesName(node) {
|
|
210425
|
+
const suffix = node.method === "GET" ? "Query" : "Mutation";
|
|
210426
|
+
return this.resolveName(`${node.operationId} ${suffix}`);
|
|
210427
|
+
},
|
|
210428
|
+
resolveResponseName(node) {
|
|
210429
|
+
const suffix = node.method === "GET" ? "QueryResponse" : "MutationResponse";
|
|
210430
|
+
return this.resolveName(`${node.operationId} ${suffix}`);
|
|
210431
|
+
},
|
|
210432
|
+
resolvePathParamsName(node, _param) {
|
|
210433
|
+
return this.resolveName(`${node.operationId} PathParams`);
|
|
210434
|
+
},
|
|
210435
|
+
resolveQueryParamsName(node, _param) {
|
|
210436
|
+
return this.resolveName(`${node.operationId} QueryParams`);
|
|
210437
|
+
},
|
|
210438
|
+
resolveHeaderParamsName(node, _param) {
|
|
210439
|
+
return this.resolveName(`${node.operationId} HeaderParams`);
|
|
210440
|
+
}
|
|
210441
|
+
};
|
|
210442
|
+
});
|
|
210350
210443
|
function buildGroupedParamsSchema({ params, parentName }) {
|
|
210351
210444
|
return createSchema({
|
|
210352
210445
|
type: "object",
|
|
@@ -210378,22 +210471,22 @@ function buildLegacyResponsesSchemaNode({ node, resolver }) {
|
|
|
210378
210471
|
const errorResponses = node.responses.filter((res) => res.statusCode === "default" || Number(res.statusCode) >= 400);
|
|
210379
210472
|
const responseSchema = successResponses.length > 0 ? successResponses.length === 1 ? createSchema({
|
|
210380
210473
|
type: "ref",
|
|
210381
|
-
name: resolver.
|
|
210474
|
+
name: resolver.resolveResponseStatusName(node, successResponses[0].statusCode)
|
|
210382
210475
|
}) : createSchema({
|
|
210383
210476
|
type: "union",
|
|
210384
210477
|
members: successResponses.map((res) => createSchema({
|
|
210385
210478
|
type: "ref",
|
|
210386
|
-
name: resolver.
|
|
210479
|
+
name: resolver.resolveResponseStatusName(node, res.statusCode)
|
|
210387
210480
|
}))
|
|
210388
210481
|
}) : createSchema({ type: "any" });
|
|
210389
210482
|
const errorsSchema = errorResponses.length > 0 ? errorResponses.length === 1 ? createSchema({
|
|
210390
210483
|
type: "ref",
|
|
210391
|
-
name: resolver.
|
|
210484
|
+
name: resolver.resolveResponseStatusName(node, errorResponses[0].statusCode)
|
|
210392
210485
|
}) : createSchema({
|
|
210393
210486
|
type: "union",
|
|
210394
210487
|
members: errorResponses.map((res) => createSchema({
|
|
210395
210488
|
type: "ref",
|
|
210396
|
-
name: resolver.
|
|
210489
|
+
name: resolver.resolveResponseStatusName(node, res.statusCode)
|
|
210397
210490
|
}))
|
|
210398
210491
|
}) : createSchema({ type: "any" });
|
|
210399
210492
|
const properties = [createProperty({
|
|
@@ -210406,31 +210499,34 @@ function buildLegacyResponsesSchemaNode({ node, resolver }) {
|
|
|
210406
210499
|
required: true,
|
|
210407
210500
|
schema: createSchema({
|
|
210408
210501
|
type: "ref",
|
|
210409
|
-
name: resolver.
|
|
210502
|
+
name: resolver.resolveDataName(node)
|
|
210410
210503
|
})
|
|
210411
210504
|
}));
|
|
210412
|
-
|
|
210505
|
+
const queryParam = node.parameters.find((p) => p.in === "query");
|
|
210506
|
+
if (queryParam) properties.push(createProperty({
|
|
210413
210507
|
name: "QueryParams",
|
|
210414
210508
|
required: true,
|
|
210415
210509
|
schema: createSchema({
|
|
210416
210510
|
type: "ref",
|
|
210417
|
-
name: resolver.
|
|
210511
|
+
name: resolver.resolveQueryParamsName(node, queryParam)
|
|
210418
210512
|
})
|
|
210419
210513
|
}));
|
|
210420
|
-
|
|
210514
|
+
const pathParam = node.parameters.find((p) => p.in === "path");
|
|
210515
|
+
if (pathParam) properties.push(createProperty({
|
|
210421
210516
|
name: "PathParams",
|
|
210422
210517
|
required: true,
|
|
210423
210518
|
schema: createSchema({
|
|
210424
210519
|
type: "ref",
|
|
210425
|
-
name: resolver.
|
|
210520
|
+
name: resolver.resolvePathParamsName(node, pathParam)
|
|
210426
210521
|
})
|
|
210427
210522
|
}));
|
|
210428
|
-
|
|
210523
|
+
const headerParam = node.parameters.find((p) => p.in === "header");
|
|
210524
|
+
if (headerParam) properties.push(createProperty({
|
|
210429
210525
|
name: "HeaderParams",
|
|
210430
210526
|
required: true,
|
|
210431
210527
|
schema: createSchema({
|
|
210432
210528
|
type: "ref",
|
|
210433
|
-
name: resolver.
|
|
210529
|
+
name: resolver.resolveHeaderParamsName(node, headerParam)
|
|
210434
210530
|
})
|
|
210435
210531
|
}));
|
|
210436
210532
|
properties.push(createProperty({
|
|
@@ -210451,13 +210547,13 @@ function buildLegacyResponseUnionSchemaNode({ node, resolver }) {
|
|
|
210451
210547
|
if (successResponses.length === 0) return createSchema({ type: "any" });
|
|
210452
210548
|
if (successResponses.length === 1) return createSchema({
|
|
210453
210549
|
type: "ref",
|
|
210454
|
-
name: resolver.
|
|
210550
|
+
name: resolver.resolveResponseStatusName(node, successResponses[0].statusCode)
|
|
210455
210551
|
});
|
|
210456
210552
|
return createSchema({
|
|
210457
210553
|
type: "union",
|
|
210458
210554
|
members: successResponses.map((res) => createSchema({
|
|
210459
210555
|
type: "ref",
|
|
210460
|
-
name: resolver.
|
|
210556
|
+
name: resolver.resolveResponseStatusName(node, res.statusCode)
|
|
210461
210557
|
}))
|
|
210462
210558
|
});
|
|
210463
210559
|
}
|
|
@@ -210489,9 +210585,9 @@ function nameUnnamedEnums(node, parentName) {
|
|
|
210489
210585
|
const typeGeneratorLegacy = defineGenerator({
|
|
210490
210586
|
name: "typescript-legacy",
|
|
210491
210587
|
type: "react",
|
|
210492
|
-
Operation({ node, adapter, options, config }) {
|
|
210588
|
+
Operation({ node, adapter, options, config, resolver }) {
|
|
210493
210589
|
var _a, _b, _c;
|
|
210494
|
-
const { enumType, enumTypeSuffix, enumKeyCasing, optionalType, arrayType, syntaxType, paramsCasing, group, output,
|
|
210590
|
+
const { enumType, enumTypeSuffix, enumKeyCasing, optionalType, arrayType, syntaxType, paramsCasing, group, output, transformers = [] } = options;
|
|
210495
210591
|
const root = path$2.resolve(config.root, config.output.path);
|
|
210496
210592
|
const mode = getMode(path$2.resolve(root, output.path));
|
|
210497
210593
|
const file = resolver.resolveFile({
|
|
@@ -210505,7 +210601,7 @@ const typeGeneratorLegacy = defineGenerator({
|
|
|
210505
210601
|
group
|
|
210506
210602
|
});
|
|
210507
210603
|
const params = caseParams(node.parameters, paramsCasing);
|
|
210508
|
-
function renderSchemaType({ node: schemaNode, name,
|
|
210604
|
+
function renderSchemaType({ node: schemaNode, name, description, keysToOmit }) {
|
|
210509
210605
|
if (!schemaNode) return null;
|
|
210510
210606
|
const transformedNode = transform(schemaNode, composeTransformers(...transformers));
|
|
210511
210607
|
const imports = adapter.getImports(transformedNode, (schemaName) => ({
|
|
@@ -210530,7 +210626,6 @@ const typeGeneratorLegacy = defineGenerator({
|
|
|
210530
210626
|
imp.isTypeOnly
|
|
210531
210627
|
].join("-"))), /* @__PURE__ */ jsx(Type, {
|
|
210532
210628
|
name,
|
|
210533
|
-
typedName,
|
|
210534
210629
|
node: transformedNode,
|
|
210535
210630
|
description,
|
|
210536
210631
|
enumType,
|
|
@@ -210552,7 +210647,6 @@ const typeGeneratorLegacy = defineGenerator({
|
|
|
210552
210647
|
return renderSchemaType({
|
|
210553
210648
|
node: res.schema ? nameUnnamedEnums(res.schema, baseResponseName) : res.schema,
|
|
210554
210649
|
name: responseName,
|
|
210555
|
-
typedName: resolver.resolveResponseStatusTypedName(node, res.statusCode),
|
|
210556
210650
|
description: res.description,
|
|
210557
210651
|
keysToOmit: res.keysToOmit
|
|
210558
210652
|
});
|
|
@@ -210560,7 +210654,6 @@ const typeGeneratorLegacy = defineGenerator({
|
|
|
210560
210654
|
const requestType = ((_b = node.requestBody) == null ? void 0 : _b.schema) ? renderSchemaType({
|
|
210561
210655
|
node: nameUnnamedEnums(node.requestBody.schema, resolverTsLegacy.resolveDataName(node)),
|
|
210562
210656
|
name: resolver.resolveDataName(node),
|
|
210563
|
-
typedName: resolver.resolveDataTypedName(node),
|
|
210564
210657
|
description: (_c = node.requestBody.description) != null ? _c : node.requestBody.schema.description,
|
|
210565
210658
|
keysToOmit: node.requestBody.keysToOmit
|
|
210566
210659
|
}) : null;
|
|
@@ -210568,26 +210661,23 @@ const typeGeneratorLegacy = defineGenerator({
|
|
|
210568
210661
|
pathParams.length > 0 ? renderSchemaType({
|
|
210569
210662
|
node: buildGroupedParamsSchema({
|
|
210570
210663
|
params: pathParams,
|
|
210571
|
-
parentName: resolverTsLegacy.resolvePathParamsName(node)
|
|
210664
|
+
parentName: resolverTsLegacy.resolvePathParamsName(node, pathParams[0])
|
|
210572
210665
|
}),
|
|
210573
|
-
name: resolver.resolvePathParamsName(node)
|
|
210574
|
-
typedName: resolver.resolvePathParamsTypedName(node)
|
|
210666
|
+
name: resolver.resolvePathParamsName(node, pathParams[0])
|
|
210575
210667
|
}) : null,
|
|
210576
210668
|
queryParams.length > 0 ? renderSchemaType({
|
|
210577
210669
|
node: buildGroupedParamsSchema({
|
|
210578
210670
|
params: queryParams,
|
|
210579
|
-
parentName: resolverTsLegacy.resolveQueryParamsName(node)
|
|
210671
|
+
parentName: resolverTsLegacy.resolveQueryParamsName(node, queryParams[0])
|
|
210580
210672
|
}),
|
|
210581
|
-
name: resolver.resolveQueryParamsName(node)
|
|
210582
|
-
typedName: resolver.resolveQueryParamsTypedName(node)
|
|
210673
|
+
name: resolver.resolveQueryParamsName(node, queryParams[0])
|
|
210583
210674
|
}) : null,
|
|
210584
210675
|
headerParams.length > 0 ? renderSchemaType({
|
|
210585
210676
|
node: buildGroupedParamsSchema({
|
|
210586
210677
|
params: headerParams,
|
|
210587
|
-
parentName: resolverTsLegacy.resolveHeaderParamsName(node)
|
|
210678
|
+
parentName: resolverTsLegacy.resolveHeaderParamsName(node, headerParams[0])
|
|
210588
210679
|
}),
|
|
210589
|
-
name: resolver.resolveHeaderParamsName(node)
|
|
210590
|
-
typedName: resolver.resolveHeaderParamsTypedName(node)
|
|
210680
|
+
name: resolver.resolveHeaderParamsName(node, headerParams[0])
|
|
210591
210681
|
}) : null
|
|
210592
210682
|
];
|
|
210593
210683
|
const legacyResponsesType = renderSchemaType({
|
|
@@ -210595,16 +210685,14 @@ const typeGeneratorLegacy = defineGenerator({
|
|
|
210595
210685
|
node,
|
|
210596
210686
|
resolver
|
|
210597
210687
|
}),
|
|
210598
|
-
name: resolver.resolveResponsesName(node)
|
|
210599
|
-
typedName: resolver.resolveResponsesTypedName(node)
|
|
210688
|
+
name: resolver.resolveResponsesName(node)
|
|
210600
210689
|
});
|
|
210601
210690
|
const legacyResponseType = renderSchemaType({
|
|
210602
210691
|
node: buildLegacyResponseUnionSchemaNode({
|
|
210603
210692
|
node,
|
|
210604
210693
|
resolver
|
|
210605
210694
|
}),
|
|
210606
|
-
name: resolver.resolveResponseName(node)
|
|
210607
|
-
typedName: resolver.resolveResponseTypedName(node)
|
|
210695
|
+
name: resolver.resolveResponseName(node)
|
|
210608
210696
|
});
|
|
210609
210697
|
return /* @__PURE__ */ jsxs(File, {
|
|
210610
210698
|
baseName: file.baseName,
|
|
@@ -210627,8 +210715,8 @@ const typeGeneratorLegacy = defineGenerator({
|
|
|
210627
210715
|
]
|
|
210628
210716
|
});
|
|
210629
210717
|
},
|
|
210630
|
-
Schema({ node, adapter, options, config }) {
|
|
210631
|
-
const { enumType, enumTypeSuffix, enumKeyCasing, syntaxType, optionalType, arrayType, output, group,
|
|
210718
|
+
Schema({ node, adapter, options, config, resolver }) {
|
|
210719
|
+
const { enumType, enumTypeSuffix, enumKeyCasing, syntaxType, optionalType, arrayType, output, group, transformers = [] } = options;
|
|
210632
210720
|
const root = path$2.resolve(config.root, config.output.path);
|
|
210633
210721
|
const mode = getMode(path$2.resolve(root, output.path));
|
|
210634
210722
|
if (!node.name) return;
|
|
@@ -210645,10 +210733,8 @@ const typeGeneratorLegacy = defineGenerator({
|
|
|
210645
210733
|
}).path
|
|
210646
210734
|
}));
|
|
210647
210735
|
const isEnumSchema = !!narrowSchema(node, schemaTypes.enum);
|
|
210648
|
-
const typedName = ENUM_TYPES_WITH_KEY_SUFFIX.has(enumType) && isEnumSchema ? resolver.resolveEnumKeyTypedName(node, enumTypeSuffix) : resolver.resolveTypedName(node.name);
|
|
210649
210736
|
const type = {
|
|
210650
|
-
name: resolver.resolveName(node.name),
|
|
210651
|
-
typedName,
|
|
210737
|
+
name: ENUM_TYPES_WITH_KEY_SUFFIX.has(enumType) && isEnumSchema ? resolver.resolveEnumKeyName(node, enumTypeSuffix) : resolver.resolveName(node.name),
|
|
210652
210738
|
file: resolver.resolveFile({
|
|
210653
210739
|
name: node.name,
|
|
210654
210740
|
extname: ".ts"
|
|
@@ -210681,7 +210767,6 @@ const typeGeneratorLegacy = defineGenerator({
|
|
|
210681
210767
|
imp.isTypeOnly
|
|
210682
210768
|
].join("-"))), /* @__PURE__ */ jsx(Type, {
|
|
210683
210769
|
name: type.name,
|
|
210684
|
-
typedName: type.typedName,
|
|
210685
210770
|
node: transformedNode,
|
|
210686
210771
|
enumType,
|
|
210687
210772
|
enumTypeSuffix,
|
|
@@ -210694,34 +210779,27 @@ const typeGeneratorLegacy = defineGenerator({
|
|
|
210694
210779
|
});
|
|
210695
210780
|
}
|
|
210696
210781
|
});
|
|
210697
|
-
|
|
210698
|
-
|
|
210699
|
-
|
|
210782
|
+
const presets$1 = definePresets({
|
|
210783
|
+
default: {
|
|
210784
|
+
name: "default",
|
|
210700
210785
|
resolvers: [resolverTs],
|
|
210701
210786
|
generators: [typeGenerator]
|
|
210702
|
-
}
|
|
210703
|
-
kubbV4:
|
|
210787
|
+
},
|
|
210788
|
+
kubbV4: {
|
|
210789
|
+
name: "kubbV4",
|
|
210704
210790
|
resolvers: [resolverTsLegacy],
|
|
210705
210791
|
generators: [typeGeneratorLegacy]
|
|
210706
|
-
}
|
|
210792
|
+
}
|
|
210707
210793
|
});
|
|
210708
|
-
function getPreset$1(preset, { resolvers, transformers, generators }) {
|
|
210709
|
-
return getPreset({
|
|
210710
|
-
preset,
|
|
210711
|
-
presets,
|
|
210712
|
-
resolvers: [resolverTs, ...resolvers != null ? resolvers : []],
|
|
210713
|
-
transformers,
|
|
210714
|
-
generators
|
|
210715
|
-
});
|
|
210716
|
-
}
|
|
210717
|
-
__name$5(getPreset$1, "getPreset");
|
|
210718
210794
|
const pluginTsName = "plugin-ts";
|
|
210719
210795
|
const pluginTs = createPlugin((options) => {
|
|
210720
210796
|
const { output = {
|
|
210721
210797
|
path: "types",
|
|
210722
210798
|
barrelType: "named"
|
|
210723
210799
|
}, group, exclude = [], include, override = [], enumType = "asConst", enumTypeSuffix = "Key", enumKeyCasing = "none", optionalType = "questionToken", arrayType = "array", syntaxType = "type", paramsCasing, compatibilityPreset = "default", resolvers: userResolvers = [], transformers: userTransformers = [], generators: userGenerators = [] } = options;
|
|
210724
|
-
const
|
|
210800
|
+
const preset = getPreset({
|
|
210801
|
+
preset: compatibilityPreset,
|
|
210802
|
+
presets: presets$1,
|
|
210725
210803
|
resolvers: userResolvers,
|
|
210726
210804
|
transformers: userTransformers,
|
|
210727
210805
|
generators: userGenerators
|
|
@@ -210730,26 +210808,37 @@ const pluginTs = createPlugin((options) => {
|
|
|
210730
210808
|
let resolvePathWarning = false;
|
|
210731
210809
|
return {
|
|
210732
210810
|
name: pluginTsName,
|
|
210733
|
-
|
|
210734
|
-
|
|
210735
|
-
|
|
210736
|
-
|
|
210737
|
-
|
|
210738
|
-
|
|
210739
|
-
|
|
210740
|
-
|
|
210741
|
-
|
|
210742
|
-
|
|
210743
|
-
|
|
210744
|
-
|
|
210811
|
+
get resolver() {
|
|
210812
|
+
return preset.resolver;
|
|
210813
|
+
},
|
|
210814
|
+
get options() {
|
|
210815
|
+
return {
|
|
210816
|
+
output,
|
|
210817
|
+
optionalType,
|
|
210818
|
+
group: group ? {
|
|
210819
|
+
...options.group,
|
|
210820
|
+
name: (ctx) => {
|
|
210821
|
+
var _a;
|
|
210822
|
+
if (((_a = options.group) == null ? void 0 : _a.type) === "path") return `${ctx.group.split("/")[1]}`;
|
|
210823
|
+
return `${camelCase$a(ctx.group)}Controller`;
|
|
210824
|
+
}
|
|
210825
|
+
} : void 0,
|
|
210826
|
+
arrayType,
|
|
210827
|
+
enumType,
|
|
210828
|
+
enumTypeSuffix,
|
|
210829
|
+
enumKeyCasing,
|
|
210830
|
+
syntaxType,
|
|
210831
|
+
paramsCasing,
|
|
210832
|
+
transformers: preset.transformers
|
|
210833
|
+
};
|
|
210745
210834
|
},
|
|
210746
210835
|
resolvePath(baseName, pathMode, options2) {
|
|
210747
210836
|
var _a, _b;
|
|
210748
210837
|
if (!resolvePathWarning) {
|
|
210749
|
-
this.
|
|
210838
|
+
this.events.emit("warn", "Do not use resolvePath for pluginTs, use resolverTs.resolvePath instead");
|
|
210750
210839
|
resolvePathWarning = true;
|
|
210751
210840
|
}
|
|
210752
|
-
return resolver.resolvePath({
|
|
210841
|
+
return this.plugin.resolver.resolvePath({
|
|
210753
210842
|
baseName,
|
|
210754
210843
|
pathMode,
|
|
210755
210844
|
tag: (_a = options2 == null ? void 0 : options2.group) == null ? void 0 : _a.tag,
|
|
@@ -210757,26 +210846,26 @@ const pluginTs = createPlugin((options) => {
|
|
|
210757
210846
|
}, {
|
|
210758
210847
|
root: path$2.resolve(this.config.root, this.config.output.path),
|
|
210759
210848
|
output,
|
|
210760
|
-
group
|
|
210849
|
+
group: this.plugin.options.group
|
|
210761
210850
|
});
|
|
210762
210851
|
},
|
|
210763
210852
|
resolveName(name, type) {
|
|
210764
210853
|
if (!resolveNameWarning) {
|
|
210765
|
-
this.
|
|
210854
|
+
this.events.emit("warn", "Do not use resolveName for pluginTs, use resolverTs.default instead");
|
|
210766
210855
|
resolveNameWarning = true;
|
|
210767
210856
|
}
|
|
210768
|
-
return resolver.default(name, type);
|
|
210857
|
+
return this.plugin.resolver.default(name, type);
|
|
210769
210858
|
},
|
|
210770
210859
|
async install() {
|
|
210771
210860
|
var _a;
|
|
210772
|
-
const { config, fabric, plugin, adapter, rootNode, driver, openInStudio } = this;
|
|
210861
|
+
const { config, fabric, plugin, adapter, rootNode, driver, openInStudio, resolver } = this;
|
|
210773
210862
|
const root = path$2.resolve(config.root, config.output.path);
|
|
210774
210863
|
if (!adapter) throw new Error("Plugin cannot work without adapter being set");
|
|
210775
210864
|
await openInStudio({ ast: true });
|
|
210776
210865
|
await walk(rootNode, {
|
|
210777
210866
|
depth: "shallow",
|
|
210778
210867
|
async schema(schemaNode) {
|
|
210779
|
-
const writeTasks = generators.map(async (generator) => {
|
|
210868
|
+
const writeTasks = preset.generators.map(async (generator) => {
|
|
210780
210869
|
if (generator.type === "react" && generator.version === "2") {
|
|
210781
210870
|
const options2 = resolver.resolveOptions(schemaNode, {
|
|
210782
210871
|
options: plugin.options,
|
|
@@ -210787,6 +210876,7 @@ const pluginTs = createPlugin((options) => {
|
|
|
210787
210876
|
if (options2 === null) return;
|
|
210788
210877
|
await renderSchema$1(schemaNode, {
|
|
210789
210878
|
options: options2,
|
|
210879
|
+
resolver,
|
|
210790
210880
|
adapter,
|
|
210791
210881
|
config,
|
|
210792
210882
|
fabric,
|
|
@@ -210799,7 +210889,7 @@ const pluginTs = createPlugin((options) => {
|
|
|
210799
210889
|
await Promise.all(writeTasks);
|
|
210800
210890
|
},
|
|
210801
210891
|
async operation(operationNode) {
|
|
210802
|
-
const writeTasks = generators.map(async (generator) => {
|
|
210892
|
+
const writeTasks = preset.generators.map(async (generator) => {
|
|
210803
210893
|
if (generator.type === "react" && generator.version === "2") {
|
|
210804
210894
|
const options2 = resolver.resolveOptions(operationNode, {
|
|
210805
210895
|
options: plugin.options,
|
|
@@ -210810,6 +210900,7 @@ const pluginTs = createPlugin((options) => {
|
|
|
210810
210900
|
if (options2 === null) return;
|
|
210811
210901
|
await renderOperation$1(operationNode, {
|
|
210812
210902
|
options: options2,
|
|
210903
|
+
resolver,
|
|
210813
210904
|
adapter,
|
|
210814
210905
|
config,
|
|
210815
210906
|
fabric,
|
|
@@ -210832,6 +210923,89 @@ const pluginTs = createPlugin((options) => {
|
|
|
210832
210923
|
}
|
|
210833
210924
|
};
|
|
210834
210925
|
});
|
|
210926
|
+
const kindToHandlerKey = {
|
|
210927
|
+
FunctionParameter: "functionParameter",
|
|
210928
|
+
ParameterGroup: "parameterGroup",
|
|
210929
|
+
FunctionParameters: "functionParameters",
|
|
210930
|
+
Type: "type"
|
|
210931
|
+
};
|
|
210932
|
+
const defineFunctionPrinter = createPrinterFactory((node) => kindToHandlerKey[node.kind]);
|
|
210933
|
+
function rank(param) {
|
|
210934
|
+
var _a;
|
|
210935
|
+
if (param.kind === "ParameterGroup") {
|
|
210936
|
+
if (param.default) return 2;
|
|
210937
|
+
return ((_a = param.optional) != null ? _a : param.properties.every((p) => p.optional || p.default !== void 0)) ? 1 : 0;
|
|
210938
|
+
}
|
|
210939
|
+
if (param.rest) return 3;
|
|
210940
|
+
if (param.default) return 2;
|
|
210941
|
+
return param.optional ? 1 : 0;
|
|
210942
|
+
}
|
|
210943
|
+
function sortParams(params) {
|
|
210944
|
+
return [...params].sort((a, b) => rank(a) - rank(b));
|
|
210945
|
+
}
|
|
210946
|
+
function sortChildParams(params) {
|
|
210947
|
+
return [...params].sort((a, b) => rank(a) - rank(b));
|
|
210948
|
+
}
|
|
210949
|
+
const functionPrinter = defineFunctionPrinter((options) => ({
|
|
210950
|
+
name: "functionParameters",
|
|
210951
|
+
options,
|
|
210952
|
+
nodes: {
|
|
210953
|
+
type(node) {
|
|
210954
|
+
if (node.variant === "member") return `${node.base}['${node.key}']`;
|
|
210955
|
+
if (node.variant === "struct") return `{ ${node.properties.map((p) => {
|
|
210956
|
+
const typeStr = this.transform(p.type);
|
|
210957
|
+
return p.optional ? `${p.name}?: ${typeStr}` : `${p.name}: ${typeStr}`;
|
|
210958
|
+
}).join("; ")} }`;
|
|
210959
|
+
if (node.variant === "reference") return node.name;
|
|
210960
|
+
return null;
|
|
210961
|
+
},
|
|
210962
|
+
functionParameter(node) {
|
|
210963
|
+
const { mode, transformName, transformType } = this.options;
|
|
210964
|
+
const name = transformName ? transformName(node.name) : node.name;
|
|
210965
|
+
const rawType = node.type ? this.transform(node.type) : void 0;
|
|
210966
|
+
const type = rawType != null && transformType ? transformType(rawType) : rawType;
|
|
210967
|
+
if (mode === "keys" || mode === "values") return node.rest ? `...${name}` : name;
|
|
210968
|
+
if (mode === "call") return node.rest ? `...${name}` : name;
|
|
210969
|
+
if (node.rest) return type ? `...${name}: ${type}` : `...${name}`;
|
|
210970
|
+
if (type) {
|
|
210971
|
+
if (node.optional) return `${name}?: ${type}`;
|
|
210972
|
+
return node.default ? `${name}: ${type} = ${node.default}` : `${name}: ${type}`;
|
|
210973
|
+
}
|
|
210974
|
+
return node.default ? `${name} = ${node.default}` : name;
|
|
210975
|
+
},
|
|
210976
|
+
parameterGroup(node) {
|
|
210977
|
+
var _a, _b, _c;
|
|
210978
|
+
const { mode, transformName, transformType } = this.options;
|
|
210979
|
+
const sorted = sortChildParams(node.properties);
|
|
210980
|
+
const isOptional = (_a = node.optional) != null ? _a : sorted.every((p) => p.optional || p.default !== void 0);
|
|
210981
|
+
if (node.inline) return sorted.map((p) => this.transform(p)).filter(Boolean).join(", ");
|
|
210982
|
+
if (mode === "keys" || mode === "values") return `{ ${sorted.map((p) => p.name).join(", ")} }`;
|
|
210983
|
+
if (mode === "call") return `{ ${sorted.map((p) => p.name).join(", ")} }`;
|
|
210984
|
+
const names = sorted.map((p) => {
|
|
210985
|
+
return transformName ? transformName(p.name) : p.name;
|
|
210986
|
+
});
|
|
210987
|
+
const nameStr = names.length ? `{ ${names.join(", ")} }` : void 0;
|
|
210988
|
+
if (!nameStr) return null;
|
|
210989
|
+
let typeAnnotation = node.type ? (_b = this.transform(node.type)) != null ? _b : void 0 : void 0;
|
|
210990
|
+
if (!typeAnnotation) {
|
|
210991
|
+
const typeParts = sorted.filter((p) => p.type).map((p) => {
|
|
210992
|
+
const rawT = p.type ? this.transform(p.type) : void 0;
|
|
210993
|
+
const t = rawT != null && transformType ? transformType(rawT) : rawT;
|
|
210994
|
+
return p.optional || p.default !== void 0 ? `${p.name}?: ${t}` : `${p.name}: ${t}`;
|
|
210995
|
+
});
|
|
210996
|
+
typeAnnotation = typeParts.length ? `{ ${typeParts.join("; ")} }` : void 0;
|
|
210997
|
+
}
|
|
210998
|
+
if (typeAnnotation) {
|
|
210999
|
+
if (isOptional) return `${nameStr}: ${typeAnnotation} = ${(_c = node.default) != null ? _c : "{}"}`;
|
|
211000
|
+
return node.default ? `${nameStr}: ${typeAnnotation} = ${node.default}` : `${nameStr}: ${typeAnnotation}`;
|
|
211001
|
+
}
|
|
211002
|
+
return node.default ? `${nameStr} = ${node.default}` : nameStr;
|
|
211003
|
+
},
|
|
211004
|
+
functionParameters(node) {
|
|
211005
|
+
return sortParams(node.params).map((p) => this.transform(p)).filter(Boolean).join(", ");
|
|
211006
|
+
}
|
|
211007
|
+
}
|
|
211008
|
+
}));
|
|
210835
211009
|
|
|
210836
211010
|
function useDriver() {
|
|
210837
211011
|
const { meta } = useFabric();
|
|
@@ -212282,14 +212456,14 @@ function isValidVarName$7(name) {
|
|
|
212282
212456
|
return true;
|
|
212283
212457
|
}
|
|
212284
212458
|
var URLPath$6 = (_a$6 = class {
|
|
212285
|
-
constructor(
|
|
212459
|
+
constructor(path2, options = {}) {
|
|
212286
212460
|
__privateAdd$6(this, _URLPath_instances$6);
|
|
212287
212461
|
/**
|
|
212288
212462
|
* The raw OpenAPI/Swagger path string, e.g. `/pet/{petId}`.
|
|
212289
212463
|
*/
|
|
212290
212464
|
__publicField$6(this, "path");
|
|
212291
212465
|
__privateAdd$6(this, _options$6);
|
|
212292
|
-
this.path =
|
|
212466
|
+
this.path = path2;
|
|
212293
212467
|
__privateSet$6(this, _options$6, options);
|
|
212294
212468
|
}
|
|
212295
212469
|
/** Converts the OpenAPI path to Express-style colon syntax, e.g. `/pet/{petId}` → `/pet/:petId`.
|
|
@@ -212416,80 +212590,63 @@ eachParam_fn$6 = function(fn) {
|
|
|
212416
212590
|
fn(raw, __privateMethod$6(this, _URLPath_instances$6, transformParam_fn$6).call(this, raw));
|
|
212417
212591
|
}
|
|
212418
212592
|
}, _a$6);
|
|
212419
|
-
|
|
212420
|
-
|
|
212421
|
-
|
|
212422
|
-
|
|
212423
|
-
|
|
212424
|
-
|
|
212425
|
-
|
|
212426
|
-
|
|
212427
|
-
|
|
212428
|
-
|
|
212429
|
-
|
|
212430
|
-
|
|
212431
|
-
|
|
212432
|
-
type: (_b = typeSchemas.request) == null ? void 0 : _b.name,
|
|
212433
|
-
optional: isOptional((_c = typeSchemas.request) == null ? void 0 : _c.schema)
|
|
212434
|
-
} : void 0,
|
|
212435
|
-
params: ((_d = typeSchemas.queryParams) == null ? void 0 : _d.name) ? {
|
|
212436
|
-
type: (_e = typeSchemas.queryParams) == null ? void 0 : _e.name,
|
|
212437
|
-
optional: isOptional((_f = typeSchemas.queryParams) == null ? void 0 : _f.schema)
|
|
212438
|
-
} : void 0,
|
|
212439
|
-
headers: ((_g = typeSchemas.headerParams) == null ? void 0 : _g.name) ? {
|
|
212440
|
-
type: (_h = typeSchemas.headerParams) == null ? void 0 : _h.name,
|
|
212441
|
-
optional: isOptional((_i = typeSchemas.headerParams) == null ? void 0 : _i.schema)
|
|
212442
|
-
} : void 0
|
|
212443
|
-
}
|
|
212444
|
-
},
|
|
212445
|
-
options: {
|
|
212446
|
-
type: "Partial<Cypress.RequestOptions>",
|
|
212447
|
-
default: "{}"
|
|
212448
|
-
}
|
|
212449
|
-
});
|
|
212450
|
-
}
|
|
212451
|
-
return FunctionParams.factory({
|
|
212452
|
-
pathParams: ((_j = typeSchemas.pathParams) == null ? void 0 : _j.name) ? {
|
|
212453
|
-
mode: pathParamsType === "object" ? "object" : "inlineSpread",
|
|
212454
|
-
children: getPathParams(typeSchemas.pathParams, {
|
|
212455
|
-
typed: true,
|
|
212456
|
-
casing: paramsCasing
|
|
212593
|
+
const declarationPrinter = functionPrinter({ mode: "declaration" });
|
|
212594
|
+
function getParams$c({ paramsType, pathParamsType, paramsCasing, resolver, node }) {
|
|
212595
|
+
var _a2;
|
|
212596
|
+
const paramsNode = createOperationParams(node, {
|
|
212597
|
+
paramsType,
|
|
212598
|
+
pathParamsType,
|
|
212599
|
+
paramsCasing,
|
|
212600
|
+
resolver,
|
|
212601
|
+
extraParams: [createFunctionParameter({
|
|
212602
|
+
name: "options",
|
|
212603
|
+
type: createTypeNode({
|
|
212604
|
+
variant: "reference",
|
|
212605
|
+
name: "Partial<Cypress.RequestOptions>"
|
|
212457
212606
|
}),
|
|
212458
|
-
default: isAllOptional((_k = typeSchemas.pathParams) == null ? void 0 : _k.schema) ? "{}" : void 0
|
|
212459
|
-
} : void 0,
|
|
212460
|
-
data: ((_l = typeSchemas.request) == null ? void 0 : _l.name) ? {
|
|
212461
|
-
type: (_m = typeSchemas.request) == null ? void 0 : _m.name,
|
|
212462
|
-
optional: isOptional((_n = typeSchemas.request) == null ? void 0 : _n.schema)
|
|
212463
|
-
} : void 0,
|
|
212464
|
-
params: ((_o = typeSchemas.queryParams) == null ? void 0 : _o.name) ? {
|
|
212465
|
-
type: (_p = typeSchemas.queryParams) == null ? void 0 : _p.name,
|
|
212466
|
-
optional: isOptional((_q = typeSchemas.queryParams) == null ? void 0 : _q.schema)
|
|
212467
|
-
} : void 0,
|
|
212468
|
-
headers: ((_r = typeSchemas.headerParams) == null ? void 0 : _r.name) ? {
|
|
212469
|
-
type: (_s = typeSchemas.headerParams) == null ? void 0 : _s.name,
|
|
212470
|
-
optional: isOptional((_t = typeSchemas.headerParams) == null ? void 0 : _t.schema)
|
|
212471
|
-
} : void 0,
|
|
212472
|
-
options: {
|
|
212473
|
-
type: "Partial<Cypress.RequestOptions>",
|
|
212474
212607
|
default: "{}"
|
|
212475
|
-
}
|
|
212608
|
+
})]
|
|
212476
212609
|
});
|
|
212610
|
+
return (_a2 = declarationPrinter.print(paramsNode)) != null ? _a2 : "";
|
|
212477
212611
|
}
|
|
212478
|
-
function Request({ baseURL = "", name, dataReturnType,
|
|
212479
|
-
var _a2
|
|
212480
|
-
const
|
|
212481
|
-
const params = getParams$c({
|
|
212612
|
+
function Request({ baseURL = "", name, dataReturnType, resolver, node, paramsType, pathParamsType, paramsCasing }) {
|
|
212613
|
+
var _a2;
|
|
212614
|
+
const paramsSignature = getParams$c({
|
|
212482
212615
|
paramsType,
|
|
212483
|
-
paramsCasing,
|
|
212484
212616
|
pathParamsType,
|
|
212485
|
-
|
|
212617
|
+
paramsCasing,
|
|
212618
|
+
resolver,
|
|
212619
|
+
node
|
|
212486
212620
|
});
|
|
212487
|
-
const
|
|
212488
|
-
const
|
|
212489
|
-
const
|
|
212490
|
-
|
|
212491
|
-
|
|
212492
|
-
|
|
212621
|
+
const responseType = resolver.resolveResponseName(node);
|
|
212622
|
+
const returnType = dataReturnType === "data" ? `Cypress.Chainable<${responseType}>` : `Cypress.Chainable<Cypress.Response<${responseType}>>`;
|
|
212623
|
+
const casedPathParams = caseParams(node.parameters.filter((p) => p.in === "path"), paramsCasing);
|
|
212624
|
+
const pathParamNameMap = new Map(casedPathParams.map((p) => [camelCase$8(p.name), p.name]));
|
|
212625
|
+
const urlTemplate = new URLPath$6(node.path, { casing: paramsCasing }).toTemplateString({
|
|
212626
|
+
prefix: baseURL,
|
|
212627
|
+
replacer: (param) => {
|
|
212628
|
+
var _a3;
|
|
212629
|
+
return (_a3 = pathParamNameMap.get(camelCase$8(param))) != null ? _a3 : param;
|
|
212630
|
+
}
|
|
212631
|
+
});
|
|
212632
|
+
const requestOptions = [`method: '${node.method}'`, `url: ${urlTemplate}`];
|
|
212633
|
+
const queryParams = node.parameters.filter((p) => p.in === "query");
|
|
212634
|
+
if (queryParams.length > 0) {
|
|
212635
|
+
const casedQueryParams = caseParams(queryParams, paramsCasing);
|
|
212636
|
+
if (casedQueryParams.some((p, i) => p.name !== queryParams[i].name)) {
|
|
212637
|
+
const pairs = queryParams.map((orig, i) => `${orig.name}: params.${casedQueryParams[i].name}`).join(", ");
|
|
212638
|
+
requestOptions.push(`qs: params ? { ${pairs} } : undefined`);
|
|
212639
|
+
} else requestOptions.push("qs: params");
|
|
212640
|
+
}
|
|
212641
|
+
const headerParams = node.parameters.filter((p) => p.in === "header");
|
|
212642
|
+
if (headerParams.length > 0) {
|
|
212643
|
+
const casedHeaderParams = caseParams(headerParams, paramsCasing);
|
|
212644
|
+
if (casedHeaderParams.some((p, i) => p.name !== headerParams[i].name)) {
|
|
212645
|
+
const pairs = headerParams.map((orig, i) => `'${orig.name}': headers.${casedHeaderParams[i].name}`).join(", ");
|
|
212646
|
+
requestOptions.push(`headers: headers ? { ${pairs} } : undefined`);
|
|
212647
|
+
} else requestOptions.push("headers");
|
|
212648
|
+
}
|
|
212649
|
+
if ((_a2 = node.requestBody) == null ? void 0 : _a2.schema) requestOptions.push("body: data");
|
|
212493
212650
|
requestOptions.push("...options");
|
|
212494
212651
|
return /* @__PURE__ */ jsx(File.Source, {
|
|
212495
212652
|
name,
|
|
@@ -212498,135 +212655,185 @@ function Request({ baseURL = "", name, dataReturnType, typeSchemas, url, method,
|
|
|
212498
212655
|
children: /* @__PURE__ */ jsx(Function$1, {
|
|
212499
212656
|
name,
|
|
212500
212657
|
export: true,
|
|
212501
|
-
params:
|
|
212658
|
+
params: paramsSignature,
|
|
212502
212659
|
returnType,
|
|
212503
|
-
children: dataReturnType === "data" ? `return cy.request<${
|
|
212660
|
+
children: dataReturnType === "data" ? `return cy.request<${responseType}>({
|
|
212504
212661
|
${requestOptions.join(",\n ")}
|
|
212505
|
-
}).then((res) => res.body)` : `return cy.request<${
|
|
212662
|
+
}).then((res) => res.body)` : `return cy.request<${responseType}>({
|
|
212506
212663
|
${requestOptions.join(",\n ")}
|
|
212507
212664
|
})`
|
|
212508
212665
|
})
|
|
212509
212666
|
});
|
|
212510
212667
|
}
|
|
212511
212668
|
Request.getParams = getParams$c;
|
|
212512
|
-
|
|
212513
|
-
const cypressGenerator = createReactGenerator({
|
|
212669
|
+
const cypressGenerator = defineGenerator({
|
|
212514
212670
|
name: "cypress",
|
|
212515
|
-
|
|
212516
|
-
|
|
212517
|
-
|
|
212518
|
-
const
|
|
212519
|
-
const
|
|
212520
|
-
const
|
|
212521
|
-
|
|
212522
|
-
|
|
212523
|
-
|
|
212524
|
-
|
|
212525
|
-
|
|
212526
|
-
|
|
212527
|
-
|
|
212528
|
-
|
|
212529
|
-
|
|
212530
|
-
|
|
212531
|
-
};
|
|
212671
|
+
type: "react",
|
|
212672
|
+
Operation({ node, adapter, options, config, driver, resolver }) {
|
|
212673
|
+
var _a2, _b, _c, _d, _e, _f;
|
|
212674
|
+
const { output, baseURL, dataReturnType, paramsCasing, paramsType, pathParamsType, group } = options;
|
|
212675
|
+
const root = path$2.resolve(config.root, config.output.path);
|
|
212676
|
+
const pluginTs = driver.getPlugin(pluginTsName);
|
|
212677
|
+
if (!pluginTs) return null;
|
|
212678
|
+
const file = resolver.resolveFile({
|
|
212679
|
+
name: node.operationId,
|
|
212680
|
+
extname: ".ts",
|
|
212681
|
+
tag: (_a2 = node.tags[0]) != null ? _a2 : "default",
|
|
212682
|
+
path: node.path
|
|
212683
|
+
}, {
|
|
212684
|
+
root,
|
|
212685
|
+
output,
|
|
212686
|
+
group
|
|
212687
|
+
});
|
|
212688
|
+
const tsFile = pluginTs.resolver.resolveFile({
|
|
212689
|
+
name: node.operationId,
|
|
212690
|
+
extname: ".ts",
|
|
212691
|
+
tag: (_b = node.tags[0]) != null ? _b : "default",
|
|
212692
|
+
path: node.path
|
|
212693
|
+
}, {
|
|
212694
|
+
root,
|
|
212695
|
+
output: (_d = (_c = pluginTs.options) == null ? void 0 : _c.output) != null ? _d : output,
|
|
212696
|
+
group: (_e = pluginTs.options) == null ? void 0 : _e.group
|
|
212697
|
+
});
|
|
212698
|
+
const name = resolver.resolveName(node.operationId);
|
|
212699
|
+
const casedParams = caseParams(node.parameters, paramsCasing);
|
|
212700
|
+
const tsResolver = pluginTs.resolver;
|
|
212701
|
+
const pathParams = casedParams.filter((p) => p.in === "path");
|
|
212702
|
+
const queryParams = casedParams.filter((p) => p.in === "query");
|
|
212703
|
+
const headerParams = casedParams.filter((p) => p.in === "header");
|
|
212704
|
+
const importedTypeNames = [
|
|
212705
|
+
...pathParams.length && tsResolver.resolvePathParamsName ? pathParams.map((p) => tsResolver.resolvePathParamsName(node, p)) : pathParams.map((p) => tsResolver.resolveParamName(node, p)),
|
|
212706
|
+
...queryParams.length && tsResolver.resolveQueryParamsName ? queryParams.map((p) => tsResolver.resolveQueryParamsName(node, p)) : queryParams.map((p) => tsResolver.resolveParamName(node, p)),
|
|
212707
|
+
...headerParams.length && tsResolver.resolveHeaderParamsName ? headerParams.map((p) => tsResolver.resolveHeaderParamsName(node, p)) : headerParams.map((p) => tsResolver.resolveParamName(node, p)),
|
|
212708
|
+
((_f = node.requestBody) == null ? void 0 : _f.schema) ? tsResolver.resolveDataName(node) : void 0,
|
|
212709
|
+
tsResolver.resolveResponseName(node)
|
|
212710
|
+
].filter(Boolean);
|
|
212532
212711
|
return /* @__PURE__ */ jsxs(File, {
|
|
212533
|
-
baseName:
|
|
212534
|
-
path:
|
|
212535
|
-
meta:
|
|
212536
|
-
banner:
|
|
212537
|
-
oas,
|
|
212712
|
+
baseName: file.baseName,
|
|
212713
|
+
path: file.path,
|
|
212714
|
+
meta: file.meta,
|
|
212715
|
+
banner: resolver.resolveBanner(adapter.rootNode, {
|
|
212538
212716
|
output,
|
|
212539
|
-
config
|
|
212717
|
+
config
|
|
212540
212718
|
}),
|
|
212541
|
-
footer:
|
|
212542
|
-
|
|
212543
|
-
|
|
212719
|
+
footer: resolver.resolveFooter(adapter.rootNode, {
|
|
212720
|
+
output,
|
|
212721
|
+
config
|
|
212544
212722
|
}),
|
|
212545
|
-
children: [/* @__PURE__ */ jsx(File.Import, {
|
|
212546
|
-
name:
|
|
212547
|
-
|
|
212548
|
-
|
|
212549
|
-
(_b = type.schemas.pathParams) == null ? void 0 : _b.name,
|
|
212550
|
-
(_c = type.schemas.queryParams) == null ? void 0 : _c.name,
|
|
212551
|
-
(_d = type.schemas.headerParams) == null ? void 0 : _d.name,
|
|
212552
|
-
...((_e = type.schemas.statusCodes) == null ? void 0 : _e.map((item) => item.name)) || []
|
|
212553
|
-
].filter(Boolean),
|
|
212554
|
-
root: request.file.path,
|
|
212555
|
-
path: type.file.path,
|
|
212723
|
+
children: [tsFile && importedTypeNames.length > 0 && /* @__PURE__ */ jsx(File.Import, {
|
|
212724
|
+
name: Array.from(new Set(importedTypeNames)),
|
|
212725
|
+
root: file.path,
|
|
212726
|
+
path: tsFile.path,
|
|
212556
212727
|
isTypeOnly: true
|
|
212557
212728
|
}), /* @__PURE__ */ jsx(Request, {
|
|
212558
|
-
name
|
|
212729
|
+
name,
|
|
212730
|
+
node,
|
|
212731
|
+
resolver: tsResolver,
|
|
212559
212732
|
dataReturnType,
|
|
212560
212733
|
paramsCasing,
|
|
212561
212734
|
paramsType,
|
|
212562
212735
|
pathParamsType,
|
|
212563
|
-
|
|
212564
|
-
method: operation.method,
|
|
212565
|
-
baseURL,
|
|
212566
|
-
url: operation.path
|
|
212736
|
+
baseURL
|
|
212567
212737
|
})]
|
|
212568
212738
|
});
|
|
212569
212739
|
}
|
|
212570
212740
|
});
|
|
212571
|
-
|
|
212741
|
+
const resolverCypress = defineResolver(() => ({
|
|
212742
|
+
name: "default",
|
|
212743
|
+
pluginName: "plugin-cypress",
|
|
212744
|
+
default(name, type) {
|
|
212745
|
+
return camelCase$8(name, { isFile: type === "file" });
|
|
212746
|
+
},
|
|
212747
|
+
resolveName(name) {
|
|
212748
|
+
return this.default(name, "function");
|
|
212749
|
+
}
|
|
212750
|
+
}));
|
|
212751
|
+
const presets = definePresets({
|
|
212752
|
+
default: {
|
|
212753
|
+
name: "default",
|
|
212754
|
+
resolvers: [resolverCypress],
|
|
212755
|
+
generators: [cypressGenerator]
|
|
212756
|
+
},
|
|
212757
|
+
kubbV4: {
|
|
212758
|
+
name: "kubbV4",
|
|
212759
|
+
resolvers: [resolverCypress],
|
|
212760
|
+
generators: [cypressGenerator]
|
|
212761
|
+
}
|
|
212762
|
+
});
|
|
212572
212763
|
const pluginCypressName = "plugin-cypress";
|
|
212573
212764
|
const pluginCypress = createPlugin((options) => {
|
|
212574
212765
|
const { output = {
|
|
212575
212766
|
path: "cypress",
|
|
212576
212767
|
barrelType: "named"
|
|
212577
|
-
}, group, dataReturnType = "data", exclude = [], include, override = [],
|
|
212768
|
+
}, group, dataReturnType = "data", exclude = [], include, override = [], baseURL, paramsCasing, paramsType = "inline", pathParamsType = paramsType === "object" ? "object" : options.pathParamsType || "inline", compatibilityPreset = "default", resolvers: userResolvers = [], transformers: userTransformers = [], generators: userGenerators = [] } = options;
|
|
212769
|
+
const preset = getPreset({
|
|
212770
|
+
preset: compatibilityPreset,
|
|
212771
|
+
presets,
|
|
212772
|
+
resolvers: [resolverCypress, ...userResolvers],
|
|
212773
|
+
transformers: userTransformers,
|
|
212774
|
+
generators: userGenerators
|
|
212775
|
+
});
|
|
212578
212776
|
return {
|
|
212579
212777
|
name: pluginCypressName,
|
|
212580
|
-
|
|
212581
|
-
|
|
212582
|
-
dataReturnType,
|
|
212583
|
-
group,
|
|
212584
|
-
baseURL,
|
|
212585
|
-
paramsCasing,
|
|
212586
|
-
paramsType,
|
|
212587
|
-
pathParamsType
|
|
212588
|
-
},
|
|
212589
|
-
pre: [pluginOasName, pluginTsName].filter(Boolean),
|
|
212590
|
-
resolvePath(baseName, pathMode, options2) {
|
|
212591
|
-
var _a, _b;
|
|
212592
|
-
const root = path$2.resolve(this.config.root, this.config.output.path);
|
|
212593
|
-
if ((pathMode != null ? pathMode : getMode(path$2.resolve(root, output.path))) === "single")
|
|
212594
|
-
return path$2.resolve(root, output.path);
|
|
212595
|
-
if (group && (((_a = options2 == null ? void 0 : options2.group) == null ? void 0 : _a.path) || ((_b = options2 == null ? void 0 : options2.group) == null ? void 0 : _b.tag))) {
|
|
212596
|
-
const groupName = (group == null ? void 0 : group.name) ? group.name : (ctx) => {
|
|
212597
|
-
if ((group == null ? void 0 : group.type) === "path") return `${ctx.group.split("/")[1]}`;
|
|
212598
|
-
return `${camelCase$8(ctx.group)}Requests`;
|
|
212599
|
-
};
|
|
212600
|
-
return path$2.resolve(root, output.path, groupName({ group: group.type === "path" ? options2.group.path : options2.group.tag }), baseName);
|
|
212601
|
-
}
|
|
212602
|
-
return path$2.resolve(root, output.path, baseName);
|
|
212778
|
+
get resolver() {
|
|
212779
|
+
return preset.resolver;
|
|
212603
212780
|
},
|
|
212604
|
-
|
|
212605
|
-
var
|
|
212606
|
-
|
|
212607
|
-
|
|
212608
|
-
|
|
212781
|
+
get options() {
|
|
212782
|
+
var _a2;
|
|
212783
|
+
return {
|
|
212784
|
+
output,
|
|
212785
|
+
dataReturnType,
|
|
212786
|
+
group: group ? {
|
|
212787
|
+
...options.group,
|
|
212788
|
+
name: ((_a2 = options.group) == null ? void 0 : _a2.name) ? options.group.name : (ctx) => {
|
|
212789
|
+
if (group.type === "path") return `${ctx.group.split("/")[1]}`;
|
|
212790
|
+
return `${camelCase$8(ctx.group)}Requests`;
|
|
212791
|
+
}
|
|
212792
|
+
} : void 0,
|
|
212793
|
+
baseURL,
|
|
212794
|
+
paramsCasing,
|
|
212795
|
+
paramsType,
|
|
212796
|
+
pathParamsType,
|
|
212797
|
+
resolver: preset.resolver,
|
|
212798
|
+
transformers: preset.transformers
|
|
212799
|
+
};
|
|
212609
212800
|
},
|
|
212801
|
+
pre: [pluginTsName].filter(Boolean),
|
|
212610
212802
|
async install() {
|
|
212611
|
-
var
|
|
212612
|
-
const
|
|
212613
|
-
const
|
|
212614
|
-
const
|
|
212615
|
-
|
|
212616
|
-
|
|
212617
|
-
|
|
212618
|
-
|
|
212619
|
-
|
|
212620
|
-
|
|
212621
|
-
|
|
212622
|
-
|
|
212623
|
-
|
|
212624
|
-
|
|
212625
|
-
|
|
212626
|
-
|
|
212627
|
-
|
|
212803
|
+
var _a2;
|
|
212804
|
+
const { config, fabric, plugin, adapter, rootNode, driver } = this;
|
|
212805
|
+
const root = path$2.resolve(config.root, config.output.path);
|
|
212806
|
+
const resolver = preset.resolver;
|
|
212807
|
+
if (!adapter) throw new Error("Plugin cannot work without adapter being set");
|
|
212808
|
+
await walk(rootNode, {
|
|
212809
|
+
depth: "shallow",
|
|
212810
|
+
async operation(operationNode) {
|
|
212811
|
+
const writeTasks = preset.generators.map(async (generator) => {
|
|
212812
|
+
if (generator.type === "react" && generator.version === "2") {
|
|
212813
|
+
const resolvedOptions = resolver.resolveOptions(operationNode, {
|
|
212814
|
+
options: plugin.options,
|
|
212815
|
+
exclude,
|
|
212816
|
+
include,
|
|
212817
|
+
override
|
|
212818
|
+
});
|
|
212819
|
+
if (resolvedOptions === null) return;
|
|
212820
|
+
await renderOperation$1(operationNode, {
|
|
212821
|
+
options: resolvedOptions,
|
|
212822
|
+
adapter,
|
|
212823
|
+
config,
|
|
212824
|
+
fabric,
|
|
212825
|
+
Component: generator.Operation,
|
|
212826
|
+
plugin,
|
|
212827
|
+
driver,
|
|
212828
|
+
resolver
|
|
212829
|
+
});
|
|
212830
|
+
}
|
|
212831
|
+
});
|
|
212832
|
+
await Promise.all(writeTasks);
|
|
212833
|
+
}
|
|
212834
|
+
});
|
|
212628
212835
|
const barrelFiles = await getBarrelFiles(this.fabric.files, {
|
|
212629
|
-
type: (
|
|
212836
|
+
type: (_a2 = output.barrelType) != null ? _a2 : "named",
|
|
212630
212837
|
root,
|
|
212631
212838
|
output,
|
|
212632
212839
|
meta: { pluginName: this.plugin.name }
|
|
@@ -213705,7 +213912,7 @@ const serverGenerator = createReactGenerator({
|
|
|
213705
213912
|
"${((_b = oas.api.info) == null ? void 0 : _b.title) || "server"}": {
|
|
213706
213913
|
"type": "stdio",
|
|
213707
213914
|
"command": "npx",
|
|
213708
|
-
"args": ["tsx", "${file.path}"]
|
|
213915
|
+
"args": ["tsx", "${path$2.relative(path$2.dirname(jsonFile.path), file.path)}"]
|
|
213709
213916
|
}
|
|
213710
213917
|
}
|
|
213711
213918
|
}
|
|
@@ -213772,7 +213979,7 @@ const pluginMcp = createPlugin((options) => {
|
|
|
213772
213979
|
const oas = await this.getOas();
|
|
213773
213980
|
const baseURL = await this.getBaseURL();
|
|
213774
213981
|
if (baseURL) this.plugin.options.client.baseURL = baseURL;
|
|
213775
|
-
const hasClientPlugin = !!this.
|
|
213982
|
+
const hasClientPlugin = !!this.getPlugin(pluginClientName);
|
|
213776
213983
|
if (this.plugin.options.client.bundle && !hasClientPlugin && !this.plugin.options.client.importPath) await this.addFile({
|
|
213777
213984
|
baseName: "fetch.ts",
|
|
213778
213985
|
path: path$2.resolve(root, ".kubb/fetch.ts"),
|
|
@@ -216138,7 +216345,7 @@ const infiniteQueryGenerator$1 = createReactGenerator({
|
|
|
216138
216345
|
suffix: "infinite"
|
|
216139
216346
|
})
|
|
216140
216347
|
};
|
|
216141
|
-
const shouldUseClientPlugin = !!driver.
|
|
216348
|
+
const shouldUseClientPlugin = !!driver.getPlugin(pluginClientName) && options.client.clientType !== "class";
|
|
216142
216349
|
const client = {
|
|
216143
216350
|
name: shouldUseClientPlugin ? getName(operation, {
|
|
216144
216351
|
type: "function",
|
|
@@ -216392,7 +216599,7 @@ const mutationGenerator$4 = createReactGenerator({
|
|
|
216392
216599
|
type: "function"
|
|
216393
216600
|
})
|
|
216394
216601
|
};
|
|
216395
|
-
const shouldUseClientPlugin = !!driver.
|
|
216602
|
+
const shouldUseClientPlugin = !!driver.getPlugin(pluginClientName) && options.client.clientType !== "class";
|
|
216396
216603
|
const client = {
|
|
216397
216604
|
name: shouldUseClientPlugin ? getName(operation, {
|
|
216398
216605
|
type: "function",
|
|
@@ -216588,7 +216795,7 @@ const queryGenerator$4 = createReactGenerator({
|
|
|
216588
216795
|
typeName: getName(operation, { type: "type" }),
|
|
216589
216796
|
file: getFile(operation, { prefix: "use" })
|
|
216590
216797
|
};
|
|
216591
|
-
const shouldUseClientPlugin = !!driver.
|
|
216798
|
+
const shouldUseClientPlugin = !!driver.getPlugin(pluginClientName) && options.client.clientType !== "class";
|
|
216592
216799
|
const client = {
|
|
216593
216800
|
name: shouldUseClientPlugin ? getName(operation, {
|
|
216594
216801
|
type: "function",
|
|
@@ -216807,7 +217014,7 @@ const suspenseInfiniteQueryGenerator = createReactGenerator({
|
|
|
216807
217014
|
suffix: "suspenseInfinite"
|
|
216808
217015
|
})
|
|
216809
217016
|
};
|
|
216810
|
-
const shouldUseClientPlugin = !!driver.
|
|
217017
|
+
const shouldUseClientPlugin = !!driver.getPlugin(pluginClientName) && options.client.clientType !== "class";
|
|
216811
217018
|
const client = {
|
|
216812
217019
|
name: shouldUseClientPlugin ? getName(operation, {
|
|
216813
217020
|
type: "function",
|
|
@@ -217041,7 +217248,7 @@ const suspenseQueryGenerator = createReactGenerator({
|
|
|
217041
217248
|
suffix: "suspense"
|
|
217042
217249
|
})
|
|
217043
217250
|
};
|
|
217044
|
-
const shouldUseClientPlugin = !!driver.
|
|
217251
|
+
const shouldUseClientPlugin = !!driver.getPlugin(pluginClientName) && options.client.clientType !== "class";
|
|
217045
217252
|
const client = {
|
|
217046
217253
|
name: shouldUseClientPlugin ? getName(operation, {
|
|
217047
217254
|
type: "function",
|
|
@@ -217339,7 +217546,7 @@ const pluginReactQuery = createPlugin((options) => {
|
|
|
217339
217546
|
const oas = await this.getOas();
|
|
217340
217547
|
const baseURL = await this.getBaseURL();
|
|
217341
217548
|
if (baseURL) this.plugin.options.client.baseURL = baseURL;
|
|
217342
|
-
const hasClientPlugin = !!this.
|
|
217549
|
+
const hasClientPlugin = !!this.getPlugin(pluginClientName);
|
|
217343
217550
|
if (this.plugin.options.client.bundle && !hasClientPlugin && !this.plugin.options.client.importPath) await this.upsertFile({
|
|
217344
217551
|
baseName: "fetch.ts",
|
|
217345
217552
|
path: path$2.resolve(root, ".kubb/fetch.ts"),
|
|
@@ -218143,7 +218350,7 @@ const mutationGenerator$3 = createReactGenerator({
|
|
|
218143
218350
|
type: "function"
|
|
218144
218351
|
})
|
|
218145
218352
|
};
|
|
218146
|
-
const shouldUseClientPlugin = !!driver.
|
|
218353
|
+
const shouldUseClientPlugin = !!driver.getPlugin(pluginClientName) && options.client.clientType !== "class";
|
|
218147
218354
|
const client = {
|
|
218148
218355
|
name: shouldUseClientPlugin ? getName(operation, {
|
|
218149
218356
|
type: "function",
|
|
@@ -218318,7 +218525,7 @@ const queryGenerator$3 = createReactGenerator({
|
|
|
218318
218525
|
typeName: getName(operation, { type: "type" }),
|
|
218319
218526
|
file: getFile(operation, { prefix: "create" })
|
|
218320
218527
|
};
|
|
218321
|
-
const shouldUseClientPlugin = !!driver.
|
|
218528
|
+
const shouldUseClientPlugin = !!driver.getPlugin(pluginClientName) && options.client.clientType !== "class";
|
|
218322
218529
|
const client = {
|
|
218323
218530
|
name: shouldUseClientPlugin ? getName(operation, {
|
|
218324
218531
|
type: "function",
|
|
@@ -218587,7 +218794,7 @@ const pluginSolidQuery = createPlugin((options) => {
|
|
|
218587
218794
|
const oas = await this.getOas();
|
|
218588
218795
|
const baseURL = await this.getBaseURL();
|
|
218589
218796
|
if (baseURL) this.plugin.options.client.baseURL = baseURL;
|
|
218590
|
-
const hasClientPlugin = !!this.
|
|
218797
|
+
const hasClientPlugin = !!this.getPlugin(pluginClientName);
|
|
218591
218798
|
if (this.plugin.options.client.bundle && !hasClientPlugin && !this.plugin.options.client.importPath) await this.upsertFile({
|
|
218592
218799
|
baseName: "fetch.ts",
|
|
218593
218800
|
path: path$2.resolve(root, ".kubb/fetch.ts"),
|
|
@@ -219337,7 +219544,7 @@ const mutationGenerator$2 = createReactGenerator({
|
|
|
219337
219544
|
type: "function"
|
|
219338
219545
|
})
|
|
219339
219546
|
};
|
|
219340
|
-
const shouldUseClientPlugin = !!driver.
|
|
219547
|
+
const shouldUseClientPlugin = !!driver.getPlugin(pluginClientName) && options.client.clientType !== "class";
|
|
219341
219548
|
const client = {
|
|
219342
219549
|
name: shouldUseClientPlugin ? getName(operation, {
|
|
219343
219550
|
type: "function",
|
|
@@ -219511,7 +219718,7 @@ const queryGenerator$2 = createReactGenerator({
|
|
|
219511
219718
|
typeName: getName(operation, { type: "type" }),
|
|
219512
219719
|
file: getFile(operation, { prefix: "create" })
|
|
219513
219720
|
};
|
|
219514
|
-
const shouldUseClientPlugin = !!driver.
|
|
219721
|
+
const shouldUseClientPlugin = !!driver.getPlugin(pluginClientName) && options.client.clientType !== "class";
|
|
219515
219722
|
const client = {
|
|
219516
219723
|
name: shouldUseClientPlugin ? getName(operation, {
|
|
219517
219724
|
type: "function",
|
|
@@ -219780,7 +219987,7 @@ const pluginSvelteQuery = createPlugin((options) => {
|
|
|
219780
219987
|
const oas = await this.getOas();
|
|
219781
219988
|
const baseURL = await this.getBaseURL();
|
|
219782
219989
|
if (baseURL) this.plugin.options.client.baseURL = baseURL;
|
|
219783
|
-
const hasClientPlugin = !!this.
|
|
219990
|
+
const hasClientPlugin = !!this.getPlugin(pluginClientName);
|
|
219784
219991
|
if (this.plugin.options.client.bundle && !hasClientPlugin && !this.plugin.options.client.importPath) await this.upsertFile({
|
|
219785
219992
|
baseName: "fetch.ts",
|
|
219786
219993
|
path: path$2.resolve(root, ".kubb/fetch.ts"),
|
|
@@ -220568,7 +220775,7 @@ const mutationGenerator$1 = createReactGenerator({
|
|
|
220568
220775
|
type: "function"
|
|
220569
220776
|
})
|
|
220570
220777
|
};
|
|
220571
|
-
const shouldUseClientPlugin = !!driver.
|
|
220778
|
+
const shouldUseClientPlugin = !!driver.getPlugin(pluginClientName) && options.client.clientType !== "class";
|
|
220572
220779
|
const client = {
|
|
220573
220780
|
name: shouldUseClientPlugin ? getName(operation, {
|
|
220574
220781
|
type: "function",
|
|
@@ -220738,7 +220945,7 @@ const queryGenerator$1 = createReactGenerator({
|
|
|
220738
220945
|
typeName: getName(operation, { type: "type" }),
|
|
220739
220946
|
file: getFile(operation, { prefix: "use" })
|
|
220740
220947
|
};
|
|
220741
|
-
const shouldUseClientPlugin = !!driver.
|
|
220948
|
+
const shouldUseClientPlugin = !!driver.getPlugin(pluginClientName) && options.client.clientType !== "class";
|
|
220742
220949
|
const client = {
|
|
220743
220950
|
name: shouldUseClientPlugin ? getName(operation, {
|
|
220744
220951
|
type: "function",
|
|
@@ -220995,7 +221202,7 @@ const pluginSwr = createPlugin((options) => {
|
|
|
220995
221202
|
const oas = await this.getOas();
|
|
220996
221203
|
const baseURL = await this.getBaseURL();
|
|
220997
221204
|
if (baseURL) this.plugin.options.client.baseURL = baseURL;
|
|
220998
|
-
const hasClientPlugin = !!this.
|
|
221205
|
+
const hasClientPlugin = !!this.getPlugin(pluginClientName);
|
|
220999
221206
|
if (this.plugin.options.client.bundle && !hasClientPlugin && !this.plugin.options.client.importPath) await this.upsertFile({
|
|
221000
221207
|
baseName: "fetch.ts",
|
|
221001
221208
|
path: path$2.resolve(root, ".kubb/fetch.ts"),
|
|
@@ -222090,7 +222297,7 @@ const infiniteQueryGenerator = createReactGenerator({
|
|
|
222090
222297
|
suffix: "infinite"
|
|
222091
222298
|
})
|
|
222092
222299
|
};
|
|
222093
|
-
const shouldUseClientPlugin = !!driver.
|
|
222300
|
+
const shouldUseClientPlugin = !!driver.getPlugin(pluginClientName) && options.client.clientType !== "class";
|
|
222094
222301
|
const client = {
|
|
222095
222302
|
name: shouldUseClientPlugin ? getName(operation, {
|
|
222096
222303
|
type: "function",
|
|
@@ -222335,7 +222542,7 @@ const mutationGenerator = createReactGenerator({
|
|
|
222335
222542
|
type: "function"
|
|
222336
222543
|
})
|
|
222337
222544
|
};
|
|
222338
|
-
const shouldUseClientPlugin = !!driver.
|
|
222545
|
+
const shouldUseClientPlugin = !!driver.getPlugin(pluginClientName) && options.client.clientType !== "class";
|
|
222339
222546
|
const client = {
|
|
222340
222547
|
name: shouldUseClientPlugin ? getName(operation, {
|
|
222341
222548
|
type: "function",
|
|
@@ -222510,7 +222717,7 @@ const queryGenerator = createReactGenerator({
|
|
|
222510
222717
|
typeName: getName(operation, { type: "type" }),
|
|
222511
222718
|
file: getFile(operation, { prefix: "use" })
|
|
222512
222719
|
};
|
|
222513
|
-
const shouldUseClientPlugin = !!driver.
|
|
222720
|
+
const shouldUseClientPlugin = !!driver.getPlugin(pluginClientName) && options.client.clientType !== "class";
|
|
222514
222721
|
const client = {
|
|
222515
222722
|
name: shouldUseClientPlugin ? getName(operation, {
|
|
222516
222723
|
type: "function",
|
|
@@ -222800,7 +223007,7 @@ const pluginVueQuery = createPlugin((options) => {
|
|
|
222800
223007
|
const oas = await this.getOas();
|
|
222801
223008
|
const baseURL = await this.getBaseURL();
|
|
222802
223009
|
if (baseURL) this.plugin.options.client.baseURL = baseURL;
|
|
222803
|
-
const hasClientPlugin = !!this.
|
|
223010
|
+
const hasClientPlugin = !!this.getPlugin(pluginClientName);
|
|
222804
223011
|
if (this.plugin.options.client.bundle && !hasClientPlugin && !this.plugin.options.client.importPath) await this.upsertFile({
|
|
222805
223012
|
baseName: "fetch.ts",
|
|
222806
223013
|
path: path$2.resolve(root, ".kubb/fetch.ts"),
|
|
@@ -223050,13 +223257,12 @@ function setupEventsStream(ws, events, getSource) {
|
|
|
223050
223257
|
});
|
|
223051
223258
|
});
|
|
223052
223259
|
events.on("generation:start", (config) => {
|
|
223053
|
-
var _a;
|
|
223054
223260
|
sendDataMessage({
|
|
223055
223261
|
type: "generation:start",
|
|
223056
223262
|
data: [
|
|
223057
223263
|
{
|
|
223058
223264
|
name: config.name,
|
|
223059
|
-
plugins:
|
|
223265
|
+
plugins: config.plugins.length
|
|
223060
223266
|
}
|
|
223061
223267
|
],
|
|
223062
223268
|
timestamp: Date.now()
|
|
@@ -223163,7 +223369,7 @@ async function connectToStudio(options) {
|
|
|
223163
223369
|
heartbeatTimer = setInterval(() => sendAgentMessage(ws, { type: "ping" }), heartbeatInterval);
|
|
223164
223370
|
setupEventsStream(ws, events, () => currentSource);
|
|
223165
223371
|
ws.addEventListener("message", async (message) => {
|
|
223166
|
-
var _a2, _b, _c, _d, _e, _f
|
|
223372
|
+
var _a2, _b, _c, _d, _e, _f;
|
|
223167
223373
|
try {
|
|
223168
223374
|
const data = JSON.parse(message.data);
|
|
223169
223375
|
logger.info(`[${maskedSessionId}] Received "${data.type}" from Studio`);
|
|
@@ -223225,7 +223431,7 @@ async function connectToStudio(options) {
|
|
|
223225
223431
|
configPath,
|
|
223226
223432
|
permissions: { allowAll: effectiveAllowAll, allowWrite: effectiveWrite, allowPublish: effectivePublish },
|
|
223227
223433
|
config: {
|
|
223228
|
-
plugins:
|
|
223434
|
+
plugins: config.plugins.map((plugin) => ({
|
|
223229
223435
|
name: `@kubb/${plugin.name}`,
|
|
223230
223436
|
options: serializePluginOptions(plugin.options)
|
|
223231
223437
|
}))
|
|
@@ -223242,7 +223448,7 @@ async function connectToStudio(options) {
|
|
|
223242
223448
|
}
|
|
223243
223449
|
currentSource = "publish";
|
|
223244
223450
|
const config = await loadConfig(resolvedConfigPath);
|
|
223245
|
-
const resolvedCommand = (
|
|
223451
|
+
const resolvedCommand = (_e = (_d = data.payload.command) != null ? _d : process.env.KUBB_AGENT_PUBLISH_COMMAND) != null ? _e : "npm publish";
|
|
223246
223452
|
await publish({
|
|
223247
223453
|
command: resolvedCommand,
|
|
223248
223454
|
outputPath: config.output.path,
|
|
@@ -223256,7 +223462,7 @@ async function connectToStudio(options) {
|
|
|
223256
223462
|
}
|
|
223257
223463
|
logger.warn(`[${maskedSessionId}] Unknown message type from Kubb Studio: ${message.data}`);
|
|
223258
223464
|
} catch (error) {
|
|
223259
|
-
logger.error(`[${maskedSessionId}] [unhandledRejection] ${(
|
|
223465
|
+
logger.error(`[${maskedSessionId}] [unhandledRejection] ${(_f = error == null ? void 0 : error.message) != null ? _f : error}`);
|
|
223260
223466
|
}
|
|
223261
223467
|
});
|
|
223262
223468
|
} catch (error) {
|