@kubb/plugin-oas 3.0.0-alpha.15 → 3.0.0-alpha.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{OperationGenerator-BqfyX5-8.d.cts → OperationGenerator-B5CoXmjA.d.cts} +22 -20
- package/dist/{OperationGenerator-BqfyX5-8.d.ts → OperationGenerator-B5CoXmjA.d.ts} +22 -20
- package/dist/{Schema-BgpIlA79.d.cts → Schema-BsgDay0E.d.cts} +1 -12
- package/dist/{Schema-ExMIJOhD.d.ts → Schema-Dvt6i_X3.d.ts} +1 -12
- package/dist/{chunk-PZTS5YZV.js → chunk-AWRVBD2X.js} +15 -13
- package/dist/chunk-AWRVBD2X.js.map +1 -0
- package/dist/chunk-BEKIIF6H.cjs +1110 -0
- package/dist/chunk-BEKIIF6H.cjs.map +1 -0
- package/dist/chunk-CQMUJN22.cjs +42 -0
- package/dist/chunk-CQMUJN22.cjs.map +1 -0
- package/dist/chunk-FGOPORE3.js +38 -0
- package/dist/chunk-FGOPORE3.js.map +1 -0
- package/dist/{chunk-AAIEMW6V.cjs → chunk-FZABPEYO.cjs} +28 -798
- package/dist/chunk-FZABPEYO.cjs.map +1 -0
- package/dist/{chunk-M3V3WMCW.js → chunk-I6N3YPCE.js} +11 -773
- package/dist/chunk-I6N3YPCE.js.map +1 -0
- package/dist/chunk-IVSE3A7W.cjs +84 -0
- package/dist/chunk-IVSE3A7W.cjs.map +1 -0
- package/dist/chunk-VLHK3XAR.js +1098 -0
- package/dist/chunk-VLHK3XAR.js.map +1 -0
- package/dist/chunk-XIFGKAM3.js +76 -0
- package/dist/chunk-XIFGKAM3.js.map +1 -0
- package/dist/{chunk-I3ZL3GUQ.cjs → chunk-XON3FUPP.cjs} +19 -17
- package/dist/chunk-XON3FUPP.cjs.map +1 -0
- package/dist/components.cjs +5 -6
- package/dist/components.d.cts +2 -2
- package/dist/components.d.ts +2 -2
- package/dist/components.js +2 -3
- package/dist/generators.cjs +4 -5
- package/dist/generators.d.cts +1 -1
- package/dist/generators.d.ts +1 -1
- package/dist/generators.js +3 -4
- package/dist/hooks.cjs +102 -31
- package/dist/hooks.cjs.map +1 -1
- package/dist/hooks.d.cts +39 -6
- package/dist/hooks.d.ts +39 -6
- package/dist/hooks.js +92 -20
- package/dist/hooks.js.map +1 -1
- package/dist/index.cjs +25 -410
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +5 -400
- package/dist/index.js.map +1 -1
- package/dist/utils.cjs +12 -12
- package/dist/utils.cjs.map +1 -1
- package/dist/utils.d.cts +2 -2
- package/dist/utils.d.ts +2 -2
- package/dist/utils.js +2 -3
- package/dist/utils.js.map +1 -1
- package/package.json +10 -10
- package/src/OperationGenerator.ts +11 -15
- package/src/SchemaGenerator.ts +15 -6
- package/src/components/Schema.tsx +1 -98
- package/src/generator.tsx +22 -14
- package/src/generators/jsonGenerator.ts +4 -4
- package/src/hooks/index.ts +2 -0
- package/src/hooks/useOperationManager.ts +76 -29
- package/src/hooks/useSchemaManager.ts +76 -0
- package/src/utils/getParams.ts +1 -1
- package/dist/chunk-2PMRS7PB.cjs +0 -8
- package/dist/chunk-2PMRS7PB.cjs.map +0 -1
- package/dist/chunk-2V64GHQ4.js +0 -32
- package/dist/chunk-2V64GHQ4.js.map +0 -1
- package/dist/chunk-4JIFKRM5.js +0 -6
- package/dist/chunk-4JIFKRM5.js.map +0 -1
- package/dist/chunk-5ULY3TQB.cjs +0 -90
- package/dist/chunk-5ULY3TQB.cjs.map +0 -1
- package/dist/chunk-AAIEMW6V.cjs.map +0 -1
- package/dist/chunk-CFU6KMOB.cjs +0 -38
- package/dist/chunk-CFU6KMOB.cjs.map +0 -1
- package/dist/chunk-GAPWY2CE.js +0 -84
- package/dist/chunk-GAPWY2CE.js.map +0 -1
- package/dist/chunk-I3ZL3GUQ.cjs.map +0 -1
- package/dist/chunk-M3V3WMCW.js.map +0 -1
- package/dist/chunk-PZTS5YZV.js.map +0 -1
|
@@ -1,21 +1,12 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var core = require('@kubb/core');
|
|
5
|
-
var transformers = require('@kubb/core/transformers');
|
|
6
|
-
var utils = require('@kubb/core/utils');
|
|
7
|
-
var oas = require('@kubb/oas');
|
|
8
|
-
var remeda = require('remeda');
|
|
3
|
+
var chunkCQMUJN22_cjs = require('./chunk-CQMUJN22.cjs');
|
|
9
4
|
var react = require('@kubb/react');
|
|
10
5
|
|
|
11
|
-
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
12
|
-
|
|
13
|
-
var transformers__default = /*#__PURE__*/_interopDefault(transformers);
|
|
14
|
-
|
|
15
6
|
// ../../node_modules/.pnpm/react@18.3.1/node_modules/react/cjs/react.production.min.js
|
|
16
|
-
var require_react_production_min =
|
|
7
|
+
var require_react_production_min = chunkCQMUJN22_cjs.__commonJS({
|
|
17
8
|
"../../node_modules/.pnpm/react@18.3.1/node_modules/react/cjs/react.production.min.js"(exports) {
|
|
18
|
-
|
|
9
|
+
chunkCQMUJN22_cjs.init_cjs_shims();
|
|
19
10
|
var l = Symbol.for("react.element");
|
|
20
11
|
var n = Symbol.for("react.portal");
|
|
21
12
|
var p = Symbol.for("react.fragment");
|
|
@@ -286,9 +277,9 @@ var require_react_production_min = chunk5ULY3TQB_cjs.__commonJS({
|
|
|
286
277
|
});
|
|
287
278
|
|
|
288
279
|
// ../../node_modules/.pnpm/react@18.3.1/node_modules/react/cjs/react.development.js
|
|
289
|
-
var require_react_development =
|
|
280
|
+
var require_react_development = chunkCQMUJN22_cjs.__commonJS({
|
|
290
281
|
"../../node_modules/.pnpm/react@18.3.1/node_modules/react/cjs/react.development.js"(exports, module) {
|
|
291
|
-
|
|
282
|
+
chunkCQMUJN22_cjs.init_cjs_shims();
|
|
292
283
|
if (process.env.NODE_ENV !== "production") {
|
|
293
284
|
(function() {
|
|
294
285
|
if (typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== "undefined" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart === "function") {
|
|
@@ -1329,7 +1320,7 @@ var require_react_development = chunk5ULY3TQB_cjs.__commonJS({
|
|
|
1329
1320
|
}
|
|
1330
1321
|
return dispatcher;
|
|
1331
1322
|
}
|
|
1332
|
-
function
|
|
1323
|
+
function useContext(Context) {
|
|
1333
1324
|
var dispatcher = resolveDispatcher();
|
|
1334
1325
|
{
|
|
1335
1326
|
if (Context._context !== void 0) {
|
|
@@ -2135,7 +2126,7 @@ var require_react_development = chunk5ULY3TQB_cjs.__commonJS({
|
|
|
2135
2126
|
exports.startTransition = startTransition;
|
|
2136
2127
|
exports.unstable_act = act;
|
|
2137
2128
|
exports.useCallback = useCallback;
|
|
2138
|
-
exports.useContext =
|
|
2129
|
+
exports.useContext = useContext;
|
|
2139
2130
|
exports.useDebugValue = useDebugValue;
|
|
2140
2131
|
exports.useDeferredValue = useDeferredValue;
|
|
2141
2132
|
exports.useEffect = useEffect;
|
|
@@ -2159,9 +2150,9 @@ var require_react_development = chunk5ULY3TQB_cjs.__commonJS({
|
|
|
2159
2150
|
});
|
|
2160
2151
|
|
|
2161
2152
|
// ../../node_modules/.pnpm/react@18.3.1/node_modules/react/index.js
|
|
2162
|
-
var require_react =
|
|
2153
|
+
var require_react = chunkCQMUJN22_cjs.__commonJS({
|
|
2163
2154
|
"../../node_modules/.pnpm/react@18.3.1/node_modules/react/index.js"(exports, module) {
|
|
2164
|
-
|
|
2155
|
+
chunkCQMUJN22_cjs.init_cjs_shims();
|
|
2165
2156
|
if (process.env.NODE_ENV === "production") {
|
|
2166
2157
|
module.exports = require_react_production_min();
|
|
2167
2158
|
} else {
|
|
@@ -2171,9 +2162,9 @@ var require_react = chunk5ULY3TQB_cjs.__commonJS({
|
|
|
2171
2162
|
});
|
|
2172
2163
|
|
|
2173
2164
|
// ../../node_modules/.pnpm/react@18.3.1/node_modules/react/cjs/react-jsx-runtime.production.min.js
|
|
2174
|
-
var require_react_jsx_runtime_production_min =
|
|
2165
|
+
var require_react_jsx_runtime_production_min = chunkCQMUJN22_cjs.__commonJS({
|
|
2175
2166
|
"../../node_modules/.pnpm/react@18.3.1/node_modules/react/cjs/react-jsx-runtime.production.min.js"(exports) {
|
|
2176
|
-
|
|
2167
|
+
chunkCQMUJN22_cjs.init_cjs_shims();
|
|
2177
2168
|
var f = require_react();
|
|
2178
2169
|
var k = Symbol.for("react.element");
|
|
2179
2170
|
var l = Symbol.for("react.fragment");
|
|
@@ -2196,9 +2187,9 @@ var require_react_jsx_runtime_production_min = chunk5ULY3TQB_cjs.__commonJS({
|
|
|
2196
2187
|
});
|
|
2197
2188
|
|
|
2198
2189
|
// ../../node_modules/.pnpm/react@18.3.1/node_modules/react/cjs/react-jsx-runtime.development.js
|
|
2199
|
-
var require_react_jsx_runtime_development =
|
|
2190
|
+
var require_react_jsx_runtime_development = chunkCQMUJN22_cjs.__commonJS({
|
|
2200
2191
|
"../../node_modules/.pnpm/react@18.3.1/node_modules/react/cjs/react-jsx-runtime.development.js"(exports) {
|
|
2201
|
-
|
|
2192
|
+
chunkCQMUJN22_cjs.init_cjs_shims();
|
|
2202
2193
|
if (process.env.NODE_ENV !== "production") {
|
|
2203
2194
|
(function() {
|
|
2204
2195
|
var React = require_react();
|
|
@@ -3073,19 +3064,19 @@ var require_react_jsx_runtime_development = chunk5ULY3TQB_cjs.__commonJS({
|
|
|
3073
3064
|
}
|
|
3074
3065
|
}
|
|
3075
3066
|
var jsx4 = jsxWithValidationDynamic;
|
|
3076
|
-
var
|
|
3067
|
+
var jsxs = jsxWithValidationStatic;
|
|
3077
3068
|
exports.Fragment = REACT_FRAGMENT_TYPE;
|
|
3078
3069
|
exports.jsx = jsx4;
|
|
3079
|
-
exports.jsxs =
|
|
3070
|
+
exports.jsxs = jsxs;
|
|
3080
3071
|
})();
|
|
3081
3072
|
}
|
|
3082
3073
|
}
|
|
3083
3074
|
});
|
|
3084
3075
|
|
|
3085
3076
|
// ../../node_modules/.pnpm/react@18.3.1/node_modules/react/jsx-runtime.js
|
|
3086
|
-
var require_jsx_runtime =
|
|
3077
|
+
var require_jsx_runtime = chunkCQMUJN22_cjs.__commonJS({
|
|
3087
3078
|
"../../node_modules/.pnpm/react@18.3.1/node_modules/react/jsx-runtime.js"(exports, module) {
|
|
3088
|
-
|
|
3079
|
+
chunkCQMUJN22_cjs.init_cjs_shims();
|
|
3089
3080
|
if (process.env.NODE_ENV === "production") {
|
|
3090
3081
|
module.exports = require_react_jsx_runtime_production_min();
|
|
3091
3082
|
} else {
|
|
@@ -3094,708 +3085,24 @@ var require_jsx_runtime = chunk5ULY3TQB_cjs.__commonJS({
|
|
|
3094
3085
|
}
|
|
3095
3086
|
});
|
|
3096
3087
|
|
|
3097
|
-
// src/
|
|
3098
|
-
|
|
3099
|
-
var schemaKeywords = {
|
|
3100
|
-
any: "any",
|
|
3101
|
-
strict: "strict",
|
|
3102
|
-
unknown: "unknown",
|
|
3103
|
-
number: "number",
|
|
3104
|
-
integer: "integer",
|
|
3105
|
-
string: "string",
|
|
3106
|
-
boolean: "boolean",
|
|
3107
|
-
undefined: "undefined",
|
|
3108
|
-
nullable: "nullable",
|
|
3109
|
-
null: "null",
|
|
3110
|
-
nullish: "nullish",
|
|
3111
|
-
array: "array",
|
|
3112
|
-
tuple: "tuple",
|
|
3113
|
-
enum: "enum",
|
|
3114
|
-
union: "union",
|
|
3115
|
-
datetime: "datetime",
|
|
3116
|
-
date: "date",
|
|
3117
|
-
email: "email",
|
|
3118
|
-
uuid: "uuid",
|
|
3119
|
-
url: "url",
|
|
3120
|
-
/* intersection */
|
|
3121
|
-
default: "default",
|
|
3122
|
-
const: "const",
|
|
3123
|
-
and: "and",
|
|
3124
|
-
describe: "describe",
|
|
3125
|
-
min: "min",
|
|
3126
|
-
max: "max",
|
|
3127
|
-
optional: "optional",
|
|
3128
|
-
readOnly: "readOnly",
|
|
3129
|
-
// custom ones
|
|
3130
|
-
object: "object",
|
|
3131
|
-
ref: "ref",
|
|
3132
|
-
matches: "matches",
|
|
3133
|
-
firstName: "firstName",
|
|
3134
|
-
lastName: "lastName",
|
|
3135
|
-
password: "password",
|
|
3136
|
-
phone: "phone",
|
|
3137
|
-
blob: "blob",
|
|
3138
|
-
deprecated: "deprecated",
|
|
3139
|
-
example: "example",
|
|
3140
|
-
schema: "schema",
|
|
3141
|
-
catchall: "catchall",
|
|
3142
|
-
time: "time",
|
|
3143
|
-
name: "name"
|
|
3144
|
-
};
|
|
3145
|
-
function isKeyword(meta, keyword) {
|
|
3146
|
-
return meta.keyword === keyword;
|
|
3147
|
-
}
|
|
3088
|
+
// src/components/index.ts
|
|
3089
|
+
chunkCQMUJN22_cjs.init_cjs_shims();
|
|
3148
3090
|
|
|
3149
|
-
// src/
|
|
3150
|
-
|
|
3151
|
-
var SchemaGenerator = class _SchemaGenerator extends core.BaseGenerator {
|
|
3152
|
-
// Collect the types of all referenced schemas, so we can export them later
|
|
3153
|
-
refs = {};
|
|
3154
|
-
// Keep track of already used type aliases
|
|
3155
|
-
#usedAliasNames = {};
|
|
3156
|
-
/**
|
|
3157
|
-
* Creates a type node from a given schema.
|
|
3158
|
-
* Delegates to getBaseTypeFromSchema internally and
|
|
3159
|
-
* optionally adds a union with null.
|
|
3160
|
-
*/
|
|
3161
|
-
parse(props) {
|
|
3162
|
-
const options = this.#getOptions(props);
|
|
3163
|
-
const defaultSchemas = this.#parseSchemaObject(props);
|
|
3164
|
-
const schemas = options.transformers?.schema?.(props, defaultSchemas) || defaultSchemas || [];
|
|
3165
|
-
return remeda.uniqueWith(schemas, remeda.isDeepEqual);
|
|
3166
|
-
}
|
|
3167
|
-
deepSearch(tree, keyword) {
|
|
3168
|
-
return _SchemaGenerator.deepSearch(tree, keyword);
|
|
3169
|
-
}
|
|
3170
|
-
find(tree, keyword) {
|
|
3171
|
-
return _SchemaGenerator.find(tree, keyword);
|
|
3172
|
-
}
|
|
3173
|
-
static deepSearch(tree, keyword) {
|
|
3174
|
-
const foundItems = [];
|
|
3175
|
-
tree?.forEach((schema) => {
|
|
3176
|
-
if (schema.keyword === keyword) {
|
|
3177
|
-
foundItems.push(schema);
|
|
3178
|
-
}
|
|
3179
|
-
if (schema.keyword === schemaKeywords.object) {
|
|
3180
|
-
const subItem = schema;
|
|
3181
|
-
Object.values(subItem.args?.properties || {}).forEach((entrySchema) => {
|
|
3182
|
-
foundItems.push(..._SchemaGenerator.deepSearch(entrySchema, keyword));
|
|
3183
|
-
});
|
|
3184
|
-
Object.values(subItem.args?.additionalProperties || {}).forEach((entrySchema) => {
|
|
3185
|
-
foundItems.push(..._SchemaGenerator.deepSearch([entrySchema], keyword));
|
|
3186
|
-
});
|
|
3187
|
-
}
|
|
3188
|
-
if (schema.keyword === schemaKeywords.array) {
|
|
3189
|
-
const subItem = schema;
|
|
3190
|
-
subItem.args.items.forEach((entrySchema) => {
|
|
3191
|
-
foundItems.push(..._SchemaGenerator.deepSearch([entrySchema], keyword));
|
|
3192
|
-
});
|
|
3193
|
-
}
|
|
3194
|
-
if (schema.keyword === schemaKeywords.and) {
|
|
3195
|
-
const subItem = schema;
|
|
3196
|
-
subItem.args.forEach((entrySchema) => {
|
|
3197
|
-
foundItems.push(..._SchemaGenerator.deepSearch([entrySchema], keyword));
|
|
3198
|
-
});
|
|
3199
|
-
}
|
|
3200
|
-
if (schema.keyword === schemaKeywords.tuple) {
|
|
3201
|
-
const subItem = schema;
|
|
3202
|
-
subItem.args.items.forEach((entrySchema) => {
|
|
3203
|
-
foundItems.push(..._SchemaGenerator.deepSearch([entrySchema], keyword));
|
|
3204
|
-
});
|
|
3205
|
-
}
|
|
3206
|
-
if (schema.keyword === schemaKeywords.union) {
|
|
3207
|
-
const subItem = schema;
|
|
3208
|
-
subItem.args.forEach((entrySchema) => {
|
|
3209
|
-
foundItems.push(..._SchemaGenerator.deepSearch([entrySchema], keyword));
|
|
3210
|
-
});
|
|
3211
|
-
}
|
|
3212
|
-
});
|
|
3213
|
-
return foundItems;
|
|
3214
|
-
}
|
|
3215
|
-
static findInObject(tree, keyword) {
|
|
3216
|
-
let foundItem = void 0;
|
|
3217
|
-
tree?.forEach((schema) => {
|
|
3218
|
-
if (!foundItem && schema.keyword === keyword) {
|
|
3219
|
-
foundItem = schema;
|
|
3220
|
-
}
|
|
3221
|
-
if (schema.keyword === schemaKeywords.object) {
|
|
3222
|
-
const subItem = schema;
|
|
3223
|
-
Object.values(subItem.args?.properties || {}).forEach((entrySchema) => {
|
|
3224
|
-
if (!foundItem) {
|
|
3225
|
-
foundItem = _SchemaGenerator.find(entrySchema, keyword);
|
|
3226
|
-
}
|
|
3227
|
-
});
|
|
3228
|
-
Object.values(subItem.args?.additionalProperties || {}).forEach((entrySchema) => {
|
|
3229
|
-
if (!foundItem) {
|
|
3230
|
-
foundItem = _SchemaGenerator.find([entrySchema], keyword);
|
|
3231
|
-
}
|
|
3232
|
-
});
|
|
3233
|
-
}
|
|
3234
|
-
});
|
|
3235
|
-
return foundItem;
|
|
3236
|
-
}
|
|
3237
|
-
static find(tree, keyword) {
|
|
3238
|
-
let foundItem = void 0;
|
|
3239
|
-
tree?.forEach((schema) => {
|
|
3240
|
-
if (!foundItem && schema.keyword === keyword) {
|
|
3241
|
-
foundItem = schema;
|
|
3242
|
-
}
|
|
3243
|
-
if (schema.keyword === schemaKeywords.array) {
|
|
3244
|
-
const subItem = schema;
|
|
3245
|
-
subItem.args.items.forEach((entrySchema) => {
|
|
3246
|
-
if (!foundItem) {
|
|
3247
|
-
foundItem = _SchemaGenerator.find([entrySchema], keyword);
|
|
3248
|
-
}
|
|
3249
|
-
});
|
|
3250
|
-
}
|
|
3251
|
-
if (schema.keyword === schemaKeywords.and) {
|
|
3252
|
-
const subItem = schema;
|
|
3253
|
-
subItem.args.forEach((entrySchema) => {
|
|
3254
|
-
if (!foundItem) {
|
|
3255
|
-
foundItem = _SchemaGenerator.find([entrySchema], keyword);
|
|
3256
|
-
}
|
|
3257
|
-
});
|
|
3258
|
-
}
|
|
3259
|
-
if (schema.keyword === schemaKeywords.tuple) {
|
|
3260
|
-
const subItem = schema;
|
|
3261
|
-
subItem.args.items.forEach((entrySchema) => {
|
|
3262
|
-
if (!foundItem) {
|
|
3263
|
-
foundItem = _SchemaGenerator.find([entrySchema], keyword);
|
|
3264
|
-
}
|
|
3265
|
-
});
|
|
3266
|
-
}
|
|
3267
|
-
if (schema.keyword === schemaKeywords.union) {
|
|
3268
|
-
const subItem = schema;
|
|
3269
|
-
subItem.args.forEach((entrySchema) => {
|
|
3270
|
-
if (!foundItem) {
|
|
3271
|
-
foundItem = _SchemaGenerator.find([entrySchema], keyword);
|
|
3272
|
-
}
|
|
3273
|
-
});
|
|
3274
|
-
}
|
|
3275
|
-
});
|
|
3276
|
-
return foundItem;
|
|
3277
|
-
}
|
|
3278
|
-
#getUsedEnumNames(props) {
|
|
3279
|
-
const options = this.#getOptions(props);
|
|
3280
|
-
return options.usedEnumNames || {};
|
|
3281
|
-
}
|
|
3282
|
-
#getOptions({ name }) {
|
|
3283
|
-
const { override = [] } = this.context;
|
|
3284
|
-
return {
|
|
3285
|
-
...this.options,
|
|
3286
|
-
...override.find(({ pattern, type }) => {
|
|
3287
|
-
if (name && type === "schemaName") {
|
|
3288
|
-
return !!name.match(pattern);
|
|
3289
|
-
}
|
|
3290
|
-
return false;
|
|
3291
|
-
})?.options || {}
|
|
3292
|
-
};
|
|
3293
|
-
}
|
|
3294
|
-
#getUnknownReturn(props) {
|
|
3295
|
-
const options = this.#getOptions(props);
|
|
3296
|
-
if (options.unknownType === "any") {
|
|
3297
|
-
return schemaKeywords.any;
|
|
3298
|
-
}
|
|
3299
|
-
return schemaKeywords.unknown;
|
|
3300
|
-
}
|
|
3301
|
-
/**
|
|
3302
|
-
* Recursively creates a type literal with the given props.
|
|
3303
|
-
*/
|
|
3304
|
-
#parseProperties({ schema, name }) {
|
|
3305
|
-
const properties = schema?.properties || {};
|
|
3306
|
-
const additionalProperties = schema?.additionalProperties;
|
|
3307
|
-
const required = schema?.required;
|
|
3308
|
-
const propertiesSchemas = Object.keys(properties).map((propertyName) => {
|
|
3309
|
-
const validationFunctions = [];
|
|
3310
|
-
const propertySchema = properties[propertyName];
|
|
3311
|
-
const isRequired = Array.isArray(required) ? required?.includes(propertyName) : !!required;
|
|
3312
|
-
const nullable = propertySchema.nullable ?? propertySchema["x-nullable"] ?? false;
|
|
3313
|
-
validationFunctions.push(...this.parse({ schema: propertySchema, name: propertyName, parentName: name }));
|
|
3314
|
-
validationFunctions.push({
|
|
3315
|
-
keyword: schemaKeywords.name,
|
|
3316
|
-
args: propertyName
|
|
3317
|
-
});
|
|
3318
|
-
if (!isRequired && nullable) {
|
|
3319
|
-
validationFunctions.push({ keyword: schemaKeywords.nullish });
|
|
3320
|
-
} else if (!isRequired) {
|
|
3321
|
-
validationFunctions.push({ keyword: schemaKeywords.optional });
|
|
3322
|
-
}
|
|
3323
|
-
return {
|
|
3324
|
-
[propertyName]: validationFunctions
|
|
3325
|
-
};
|
|
3326
|
-
}).reduce((acc, curr) => ({ ...acc, ...curr }), {});
|
|
3327
|
-
let additionalPropertiesSchemas = [];
|
|
3328
|
-
if (additionalProperties) {
|
|
3329
|
-
additionalPropertiesSchemas = additionalProperties === true ? [{ keyword: this.#getUnknownReturn({ schema, name }) }] : this.parse({ schema: additionalProperties, parentName: name });
|
|
3330
|
-
}
|
|
3331
|
-
return [
|
|
3332
|
-
{
|
|
3333
|
-
keyword: schemaKeywords.object,
|
|
3334
|
-
args: {
|
|
3335
|
-
properties: propertiesSchemas,
|
|
3336
|
-
additionalProperties: additionalPropertiesSchemas
|
|
3337
|
-
}
|
|
3338
|
-
}
|
|
3339
|
-
];
|
|
3340
|
-
}
|
|
3341
|
-
/**
|
|
3342
|
-
* Create a type alias for the schema referenced by the given ReferenceObject
|
|
3343
|
-
*/
|
|
3344
|
-
#getRefAlias(obj) {
|
|
3345
|
-
const { $ref } = obj;
|
|
3346
|
-
let ref = this.refs[$ref];
|
|
3347
|
-
const originalName = utils.getUniqueName($ref.replace(/.+\//, ""), this.#usedAliasNames);
|
|
3348
|
-
const propertyName = this.context.pluginManager.resolveName({
|
|
3349
|
-
name: originalName,
|
|
3350
|
-
pluginKey: this.context.plugin.key,
|
|
3351
|
-
type: "function"
|
|
3352
|
-
});
|
|
3353
|
-
if (ref) {
|
|
3354
|
-
return [
|
|
3355
|
-
{
|
|
3356
|
-
keyword: schemaKeywords.ref,
|
|
3357
|
-
args: { name: ref.propertyName, path: ref.path }
|
|
3358
|
-
}
|
|
3359
|
-
];
|
|
3360
|
-
}
|
|
3361
|
-
const fileName = this.context.pluginManager.resolveName({
|
|
3362
|
-
name: originalName,
|
|
3363
|
-
pluginKey: this.context.plugin.key,
|
|
3364
|
-
type: "file"
|
|
3365
|
-
});
|
|
3366
|
-
const file = this.context.pluginManager.getFile({
|
|
3367
|
-
name: fileName,
|
|
3368
|
-
pluginKey: this.context.plugin.key,
|
|
3369
|
-
extName: ".ts"
|
|
3370
|
-
});
|
|
3371
|
-
ref = this.refs[$ref] = {
|
|
3372
|
-
propertyName,
|
|
3373
|
-
originalName,
|
|
3374
|
-
path: file.path
|
|
3375
|
-
};
|
|
3376
|
-
return [
|
|
3377
|
-
{
|
|
3378
|
-
keyword: schemaKeywords.ref,
|
|
3379
|
-
args: { name: ref.propertyName, path: ref?.path }
|
|
3380
|
-
}
|
|
3381
|
-
];
|
|
3382
|
-
}
|
|
3383
|
-
#getParsedSchemaObject(schema) {
|
|
3384
|
-
const parsedSchema = chunk5ULY3TQB_cjs.getSchemaFactory(this.context.oas)(schema);
|
|
3385
|
-
return parsedSchema;
|
|
3386
|
-
}
|
|
3387
|
-
/**
|
|
3388
|
-
* This is the very core of the OpenAPI to TS conversion - it takes a
|
|
3389
|
-
* schema and returns the appropriate type.
|
|
3390
|
-
*/
|
|
3391
|
-
#parseSchemaObject({ schema: _schema, name, parentName }) {
|
|
3392
|
-
const options = this.#getOptions({ schema: _schema, name });
|
|
3393
|
-
const unknownReturn = this.#getUnknownReturn({ schema: _schema, name });
|
|
3394
|
-
const { schema, version } = this.#getParsedSchemaObject(_schema);
|
|
3395
|
-
if (!schema) {
|
|
3396
|
-
return [{ keyword: unknownReturn }];
|
|
3397
|
-
}
|
|
3398
|
-
const baseItems = [
|
|
3399
|
-
{
|
|
3400
|
-
keyword: schemaKeywords.schema,
|
|
3401
|
-
args: {
|
|
3402
|
-
type: schema.type,
|
|
3403
|
-
format: schema.format
|
|
3404
|
-
}
|
|
3405
|
-
}
|
|
3406
|
-
];
|
|
3407
|
-
const min = schema.minimum ?? schema.minLength ?? schema.minItems ?? void 0;
|
|
3408
|
-
const max = schema.maximum ?? schema.maxLength ?? schema.maxItems ?? void 0;
|
|
3409
|
-
const nullable = schema.nullable ?? schema["x-nullable"] ?? false;
|
|
3410
|
-
if (schema.default !== void 0 && !Array.isArray(schema.default)) {
|
|
3411
|
-
if (typeof schema.default === "string") {
|
|
3412
|
-
baseItems.push({
|
|
3413
|
-
keyword: schemaKeywords.default,
|
|
3414
|
-
args: transformers__default.default.stringify(schema.default)
|
|
3415
|
-
});
|
|
3416
|
-
} else if (typeof schema.default === "boolean") {
|
|
3417
|
-
baseItems.push({
|
|
3418
|
-
keyword: schemaKeywords.default,
|
|
3419
|
-
args: schema.default ?? false
|
|
3420
|
-
});
|
|
3421
|
-
} else {
|
|
3422
|
-
baseItems.push({
|
|
3423
|
-
keyword: schemaKeywords.default,
|
|
3424
|
-
args: schema.default
|
|
3425
|
-
});
|
|
3426
|
-
}
|
|
3427
|
-
}
|
|
3428
|
-
if (schema.description) {
|
|
3429
|
-
baseItems.push({
|
|
3430
|
-
keyword: schemaKeywords.describe,
|
|
3431
|
-
args: schema.description
|
|
3432
|
-
});
|
|
3433
|
-
}
|
|
3434
|
-
if (schema.pattern) {
|
|
3435
|
-
baseItems.unshift({
|
|
3436
|
-
keyword: schemaKeywords.matches,
|
|
3437
|
-
args: schema.pattern
|
|
3438
|
-
});
|
|
3439
|
-
}
|
|
3440
|
-
if (max !== void 0) {
|
|
3441
|
-
baseItems.unshift({ keyword: schemaKeywords.max, args: max });
|
|
3442
|
-
}
|
|
3443
|
-
if (min !== void 0) {
|
|
3444
|
-
baseItems.unshift({ keyword: schemaKeywords.min, args: min });
|
|
3445
|
-
}
|
|
3446
|
-
if (nullable) {
|
|
3447
|
-
baseItems.push({ keyword: schemaKeywords.nullable });
|
|
3448
|
-
}
|
|
3449
|
-
if (schema.type && Array.isArray(schema.type)) {
|
|
3450
|
-
const [_schema2, nullable2] = schema.type;
|
|
3451
|
-
if (nullable2 === "null") {
|
|
3452
|
-
baseItems.push({ keyword: schemaKeywords.nullable });
|
|
3453
|
-
}
|
|
3454
|
-
}
|
|
3455
|
-
if (schema.readOnly) {
|
|
3456
|
-
baseItems.push({ keyword: schemaKeywords.readOnly });
|
|
3457
|
-
}
|
|
3458
|
-
if (oas.isReference(schema)) {
|
|
3459
|
-
return [
|
|
3460
|
-
...this.#getRefAlias(schema),
|
|
3461
|
-
nullable && { keyword: schemaKeywords.nullable },
|
|
3462
|
-
{
|
|
3463
|
-
keyword: schemaKeywords.schema,
|
|
3464
|
-
args: {
|
|
3465
|
-
type: schema.type,
|
|
3466
|
-
format: schema.format
|
|
3467
|
-
}
|
|
3468
|
-
}
|
|
3469
|
-
].filter(Boolean);
|
|
3470
|
-
}
|
|
3471
|
-
if (schema.oneOf) {
|
|
3472
|
-
const schemaWithoutOneOf = { ...schema, oneOf: void 0 };
|
|
3473
|
-
const union = {
|
|
3474
|
-
keyword: schemaKeywords.union,
|
|
3475
|
-
args: schema.oneOf.map((item) => {
|
|
3476
|
-
return item && this.parse({ schema: item, name, parentName })[0];
|
|
3477
|
-
}).filter(Boolean).filter((item) => {
|
|
3478
|
-
return item && item.keyword !== unknownReturn;
|
|
3479
|
-
})
|
|
3480
|
-
};
|
|
3481
|
-
if (schemaWithoutOneOf.properties) {
|
|
3482
|
-
return [...this.parse({ schema: schemaWithoutOneOf, name, parentName }), union, ...baseItems];
|
|
3483
|
-
}
|
|
3484
|
-
return [union, ...baseItems];
|
|
3485
|
-
}
|
|
3486
|
-
if (schema.anyOf) {
|
|
3487
|
-
const schemaWithoutAnyOf = { ...schema, anyOf: void 0 };
|
|
3488
|
-
const union = {
|
|
3489
|
-
keyword: schemaKeywords.union,
|
|
3490
|
-
args: schema.anyOf.map((item) => {
|
|
3491
|
-
return item && this.parse({ schema: item, name, parentName })[0];
|
|
3492
|
-
}).filter(Boolean).filter((item) => {
|
|
3493
|
-
return item && item.keyword !== unknownReturn;
|
|
3494
|
-
}).map((item) => {
|
|
3495
|
-
if (isKeyword(item, schemaKeywords.object)) {
|
|
3496
|
-
return {
|
|
3497
|
-
...item,
|
|
3498
|
-
args: {
|
|
3499
|
-
...item.args,
|
|
3500
|
-
strict: true
|
|
3501
|
-
}
|
|
3502
|
-
};
|
|
3503
|
-
}
|
|
3504
|
-
return item;
|
|
3505
|
-
})
|
|
3506
|
-
};
|
|
3507
|
-
if (schemaWithoutAnyOf.properties) {
|
|
3508
|
-
return [...this.parse({ schema: schemaWithoutAnyOf, name, parentName }), union, ...baseItems];
|
|
3509
|
-
}
|
|
3510
|
-
return [union, ...baseItems];
|
|
3511
|
-
}
|
|
3512
|
-
if (schema.allOf) {
|
|
3513
|
-
const schemaWithoutAllOf = { ...schema, allOf: void 0 };
|
|
3514
|
-
const and = {
|
|
3515
|
-
keyword: schemaKeywords.and,
|
|
3516
|
-
args: schema.allOf.map((item) => {
|
|
3517
|
-
return item && this.parse({ schema: item, name, parentName })[0];
|
|
3518
|
-
}).filter(Boolean).filter((item) => {
|
|
3519
|
-
return item && item.keyword !== unknownReturn;
|
|
3520
|
-
})
|
|
3521
|
-
};
|
|
3522
|
-
if (schemaWithoutAllOf.properties) {
|
|
3523
|
-
return [
|
|
3524
|
-
{
|
|
3525
|
-
...and,
|
|
3526
|
-
args: [...and.args || [], ...this.parse({ schema: schemaWithoutAllOf, name, parentName })]
|
|
3527
|
-
},
|
|
3528
|
-
...baseItems
|
|
3529
|
-
];
|
|
3530
|
-
}
|
|
3531
|
-
return [and, ...baseItems];
|
|
3532
|
-
}
|
|
3533
|
-
if (schema.enum) {
|
|
3534
|
-
const enumName = utils.getUniqueName(transformers.pascalCase([parentName, name, options.enumSuffix].join(" ")), this.#getUsedEnumNames({ schema, name }));
|
|
3535
|
-
const typeName = this.context.pluginManager.resolveName({
|
|
3536
|
-
name: enumName,
|
|
3537
|
-
pluginKey: this.context.plugin.key,
|
|
3538
|
-
type: "type"
|
|
3539
|
-
});
|
|
3540
|
-
const nullableEnum = schema.enum.includes(null);
|
|
3541
|
-
if (nullableEnum) {
|
|
3542
|
-
baseItems.push({ keyword: schemaKeywords.nullable });
|
|
3543
|
-
}
|
|
3544
|
-
const filteredValues = schema.enum.filter((value) => value !== null);
|
|
3545
|
-
const extensionEnums = ["x-enumNames", "x-enum-varnames"].filter((extensionKey) => extensionKey in schema).map((extensionKey) => {
|
|
3546
|
-
return [
|
|
3547
|
-
{
|
|
3548
|
-
keyword: schemaKeywords.enum,
|
|
3549
|
-
args: {
|
|
3550
|
-
name,
|
|
3551
|
-
typeName,
|
|
3552
|
-
asConst: false,
|
|
3553
|
-
items: [...new Set(schema[extensionKey])].map((name2, index) => ({
|
|
3554
|
-
name: transformers__default.default.stringify(name2),
|
|
3555
|
-
value: schema.enum?.[index],
|
|
3556
|
-
format: remeda.isNumber(schema.enum?.[index]) ? "number" : "string"
|
|
3557
|
-
}))
|
|
3558
|
-
}
|
|
3559
|
-
},
|
|
3560
|
-
...baseItems.filter(
|
|
3561
|
-
(item) => item.keyword !== schemaKeywords.min && item.keyword !== schemaKeywords.max && item.keyword !== schemaKeywords.matches
|
|
3562
|
-
)
|
|
3563
|
-
];
|
|
3564
|
-
});
|
|
3565
|
-
if (schema.type === "number" || schema.type === "integer") {
|
|
3566
|
-
const enumNames = extensionEnums[0]?.find((item) => isKeyword(item, schemaKeywords.enum));
|
|
3567
|
-
return [
|
|
3568
|
-
{
|
|
3569
|
-
keyword: schemaKeywords.enum,
|
|
3570
|
-
args: {
|
|
3571
|
-
name: enumName,
|
|
3572
|
-
typeName,
|
|
3573
|
-
asConst: true,
|
|
3574
|
-
items: enumNames?.args?.items ? [...new Set(enumNames.args.items)].map(({ name: name2, value }) => ({
|
|
3575
|
-
name: name2,
|
|
3576
|
-
value,
|
|
3577
|
-
format: "number"
|
|
3578
|
-
})) : [...new Set(filteredValues)].map((value) => {
|
|
3579
|
-
return {
|
|
3580
|
-
name: value,
|
|
3581
|
-
value,
|
|
3582
|
-
format: "number"
|
|
3583
|
-
};
|
|
3584
|
-
})
|
|
3585
|
-
}
|
|
3586
|
-
},
|
|
3587
|
-
...baseItems.filter((item) => item.keyword !== schemaKeywords.min && item.keyword !== schemaKeywords.max && item.keyword !== schemaKeywords.matches)
|
|
3588
|
-
];
|
|
3589
|
-
}
|
|
3590
|
-
if (extensionEnums.length > 0 && extensionEnums[0]) {
|
|
3591
|
-
return extensionEnums[0];
|
|
3592
|
-
}
|
|
3593
|
-
return [
|
|
3594
|
-
{
|
|
3595
|
-
keyword: schemaKeywords.enum,
|
|
3596
|
-
args: {
|
|
3597
|
-
name: enumName,
|
|
3598
|
-
typeName,
|
|
3599
|
-
asConst: false,
|
|
3600
|
-
items: [...new Set(filteredValues)].map((value) => ({
|
|
3601
|
-
name: transformers__default.default.stringify(value),
|
|
3602
|
-
value,
|
|
3603
|
-
format: remeda.isNumber(value) ? "number" : "string"
|
|
3604
|
-
}))
|
|
3605
|
-
}
|
|
3606
|
-
},
|
|
3607
|
-
...baseItems.filter((item) => item.keyword !== schemaKeywords.min && item.keyword !== schemaKeywords.max && item.keyword !== schemaKeywords.matches)
|
|
3608
|
-
];
|
|
3609
|
-
}
|
|
3610
|
-
if ("prefixItems" in schema) {
|
|
3611
|
-
const prefixItems = schema.prefixItems;
|
|
3612
|
-
const min2 = schema.minimum ?? schema.minLength ?? schema.minItems ?? void 0;
|
|
3613
|
-
const max2 = schema.maximum ?? schema.maxLength ?? schema.maxItems ?? void 0;
|
|
3614
|
-
return [
|
|
3615
|
-
{
|
|
3616
|
-
keyword: schemaKeywords.tuple,
|
|
3617
|
-
args: {
|
|
3618
|
-
min: min2,
|
|
3619
|
-
max: max2,
|
|
3620
|
-
items: prefixItems.map((item) => {
|
|
3621
|
-
return this.parse({ schema: item, name, parentName })[0];
|
|
3622
|
-
}).filter(Boolean)
|
|
3623
|
-
}
|
|
3624
|
-
},
|
|
3625
|
-
...baseItems.filter((item) => item.keyword !== schemaKeywords.min && item.keyword !== schemaKeywords.max)
|
|
3626
|
-
];
|
|
3627
|
-
}
|
|
3628
|
-
if (version === "3.1" && "const" in schema) {
|
|
3629
|
-
if (schema["const"]) {
|
|
3630
|
-
return [
|
|
3631
|
-
{
|
|
3632
|
-
keyword: schemaKeywords.const,
|
|
3633
|
-
args: {
|
|
3634
|
-
name: schema["const"],
|
|
3635
|
-
format: typeof schema["const"] === "number" ? "number" : "string",
|
|
3636
|
-
value: schema["const"]
|
|
3637
|
-
}
|
|
3638
|
-
},
|
|
3639
|
-
...baseItems
|
|
3640
|
-
];
|
|
3641
|
-
}
|
|
3642
|
-
return [{ keyword: schemaKeywords.null }];
|
|
3643
|
-
}
|
|
3644
|
-
if (schema.format) {
|
|
3645
|
-
switch (schema.format) {
|
|
3646
|
-
case "binary":
|
|
3647
|
-
baseItems.push({ keyword: schemaKeywords.blob });
|
|
3648
|
-
return baseItems;
|
|
3649
|
-
case "date-time":
|
|
3650
|
-
if (options.dateType) {
|
|
3651
|
-
if (options.dateType === "date") {
|
|
3652
|
-
baseItems.unshift({ keyword: schemaKeywords.date, args: { type: "date" } });
|
|
3653
|
-
return baseItems;
|
|
3654
|
-
}
|
|
3655
|
-
if (options.dateType === "stringOffset") {
|
|
3656
|
-
baseItems.unshift({ keyword: schemaKeywords.datetime, args: { offset: true } });
|
|
3657
|
-
return baseItems;
|
|
3658
|
-
}
|
|
3659
|
-
if (options.dateType === "stringLocal") {
|
|
3660
|
-
baseItems.unshift({ keyword: schemaKeywords.datetime, args: { local: true } });
|
|
3661
|
-
return baseItems;
|
|
3662
|
-
}
|
|
3663
|
-
baseItems.unshift({ keyword: schemaKeywords.datetime, args: { offset: false } });
|
|
3664
|
-
return baseItems;
|
|
3665
|
-
}
|
|
3666
|
-
break;
|
|
3667
|
-
case "date":
|
|
3668
|
-
if (options.dateType) {
|
|
3669
|
-
if (options.dateType === "date") {
|
|
3670
|
-
baseItems.unshift({ keyword: schemaKeywords.date, args: { type: "date" } });
|
|
3671
|
-
return baseItems;
|
|
3672
|
-
}
|
|
3673
|
-
baseItems.unshift({ keyword: schemaKeywords.date, args: { type: "string" } });
|
|
3674
|
-
return baseItems;
|
|
3675
|
-
}
|
|
3676
|
-
break;
|
|
3677
|
-
case "time":
|
|
3678
|
-
if (options.dateType) {
|
|
3679
|
-
if (options.dateType === "date") {
|
|
3680
|
-
baseItems.unshift({ keyword: schemaKeywords.time, args: { type: "date" } });
|
|
3681
|
-
return baseItems;
|
|
3682
|
-
}
|
|
3683
|
-
baseItems.unshift({ keyword: schemaKeywords.time, args: { type: "string" } });
|
|
3684
|
-
return baseItems;
|
|
3685
|
-
}
|
|
3686
|
-
break;
|
|
3687
|
-
case "uuid":
|
|
3688
|
-
baseItems.unshift({ keyword: schemaKeywords.uuid });
|
|
3689
|
-
break;
|
|
3690
|
-
case "email":
|
|
3691
|
-
case "idn-email":
|
|
3692
|
-
baseItems.unshift({ keyword: schemaKeywords.email });
|
|
3693
|
-
break;
|
|
3694
|
-
case "uri":
|
|
3695
|
-
case "ipv4":
|
|
3696
|
-
case "ipv6":
|
|
3697
|
-
case "uri-reference":
|
|
3698
|
-
case "hostname":
|
|
3699
|
-
case "idn-hostname":
|
|
3700
|
-
baseItems.unshift({ keyword: schemaKeywords.url });
|
|
3701
|
-
break;
|
|
3702
|
-
}
|
|
3703
|
-
}
|
|
3704
|
-
if ("items" in schema || schema.type === "array") {
|
|
3705
|
-
const min2 = schema.minimum ?? schema.minLength ?? schema.minItems ?? void 0;
|
|
3706
|
-
const max2 = schema.maximum ?? schema.maxLength ?? schema.maxItems ?? void 0;
|
|
3707
|
-
const items = this.parse({ schema: "items" in schema ? schema.items : [], name, parentName });
|
|
3708
|
-
return [
|
|
3709
|
-
{
|
|
3710
|
-
keyword: schemaKeywords.array,
|
|
3711
|
-
args: {
|
|
3712
|
-
items,
|
|
3713
|
-
min: min2,
|
|
3714
|
-
max: max2
|
|
3715
|
-
}
|
|
3716
|
-
},
|
|
3717
|
-
...baseItems.filter((item) => item.keyword !== schemaKeywords.min && item.keyword !== schemaKeywords.max)
|
|
3718
|
-
];
|
|
3719
|
-
}
|
|
3720
|
-
if (schema.properties || schema.additionalProperties) {
|
|
3721
|
-
return [...this.#parseProperties({ schema, name }), ...baseItems];
|
|
3722
|
-
}
|
|
3723
|
-
if (schema.type) {
|
|
3724
|
-
if (Array.isArray(schema.type)) {
|
|
3725
|
-
const [type] = schema.type;
|
|
3726
|
-
return [
|
|
3727
|
-
...this.parse({
|
|
3728
|
-
schema: {
|
|
3729
|
-
...schema,
|
|
3730
|
-
type
|
|
3731
|
-
},
|
|
3732
|
-
name,
|
|
3733
|
-
parentName
|
|
3734
|
-
}),
|
|
3735
|
-
...baseItems
|
|
3736
|
-
].filter(Boolean);
|
|
3737
|
-
}
|
|
3738
|
-
if (!["boolean", "object", "number", "string", "integer"].includes(schema.type)) {
|
|
3739
|
-
this.context.pluginManager.logger.emit("warning", `Schema type '${schema.type}' is not valid for schema ${parentName}.${name}`);
|
|
3740
|
-
}
|
|
3741
|
-
return [{ keyword: schema.type }, ...baseItems];
|
|
3742
|
-
}
|
|
3743
|
-
return [{ keyword: unknownReturn }];
|
|
3744
|
-
}
|
|
3745
|
-
async build(...generators) {
|
|
3746
|
-
const { oas, contentType, include } = this.context;
|
|
3747
|
-
const schemas = chunk5ULY3TQB_cjs.getSchemas({ oas, contentType, includes: include });
|
|
3748
|
-
const promises = Object.entries(schemas).reduce((acc, [name, schema]) => {
|
|
3749
|
-
const options = this.#getOptions({ name });
|
|
3750
|
-
const promiseOperation = this.schema.call(this, name, schema, {
|
|
3751
|
-
...this.options,
|
|
3752
|
-
...options
|
|
3753
|
-
});
|
|
3754
|
-
if (promiseOperation) {
|
|
3755
|
-
acc.push(promiseOperation);
|
|
3756
|
-
}
|
|
3757
|
-
generators?.forEach((generator) => {
|
|
3758
|
-
const promise = generator.schema?.({
|
|
3759
|
-
instance: this,
|
|
3760
|
-
name,
|
|
3761
|
-
schema,
|
|
3762
|
-
options: {
|
|
3763
|
-
...this.options,
|
|
3764
|
-
...options
|
|
3765
|
-
}
|
|
3766
|
-
});
|
|
3767
|
-
if (promise) {
|
|
3768
|
-
acc.push(promise);
|
|
3769
|
-
}
|
|
3770
|
-
});
|
|
3771
|
-
return acc;
|
|
3772
|
-
}, []);
|
|
3773
|
-
const files = await Promise.all(promises);
|
|
3774
|
-
return files.flat().filter(Boolean);
|
|
3775
|
-
}
|
|
3776
|
-
/**
|
|
3777
|
-
* Schema
|
|
3778
|
-
*/
|
|
3779
|
-
async schema(name, object, options) {
|
|
3780
|
-
return [];
|
|
3781
|
-
}
|
|
3782
|
-
};
|
|
3091
|
+
// src/components/Oas.tsx
|
|
3092
|
+
chunkCQMUJN22_cjs.init_cjs_shims();
|
|
3783
3093
|
|
|
3784
3094
|
// src/components/Operation.tsx
|
|
3785
|
-
|
|
3786
|
-
var import_jsx_runtime =
|
|
3095
|
+
chunkCQMUJN22_cjs.init_cjs_shims();
|
|
3096
|
+
var import_jsx_runtime = chunkCQMUJN22_cjs.__toESM(require_jsx_runtime(), 1);
|
|
3787
3097
|
var OperationContext = react.createContext({});
|
|
3788
3098
|
function Operation({ operation, children }) {
|
|
3789
3099
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(OperationContext.Provider, { value: { operation }, children });
|
|
3790
3100
|
}
|
|
3791
3101
|
Operation.Context = OperationContext;
|
|
3792
3102
|
|
|
3793
|
-
// src/hooks/useSchema.ts
|
|
3794
|
-
chunk5ULY3TQB_cjs.init_cjs_shims();
|
|
3795
|
-
|
|
3796
3103
|
// src/components/Schema.tsx
|
|
3797
|
-
|
|
3798
|
-
var import_jsx_runtime2 =
|
|
3104
|
+
chunkCQMUJN22_cjs.init_cjs_shims();
|
|
3105
|
+
var import_jsx_runtime2 = chunkCQMUJN22_cjs.__toESM(require_jsx_runtime(), 1);
|
|
3799
3106
|
var SchemaContext = react.createContext({
|
|
3800
3107
|
name: "unknown",
|
|
3801
3108
|
tree: []
|
|
@@ -3803,83 +3110,10 @@ var SchemaContext = react.createContext({
|
|
|
3803
3110
|
function Schema({ name, value, tree = [], children }) {
|
|
3804
3111
|
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(SchemaContext.Provider, { value: { name, schema: value, tree }, children });
|
|
3805
3112
|
}
|
|
3806
|
-
Schema.File = function({ isTypeOnly, children }) {
|
|
3807
|
-
const { plugin, pluginManager, mode } = react.useApp();
|
|
3808
|
-
const { name } = useSchema();
|
|
3809
|
-
if (mode === "single") {
|
|
3810
|
-
const baseName2 = `${pluginManager.resolveName({
|
|
3811
|
-
name,
|
|
3812
|
-
pluginKey: plugin.key,
|
|
3813
|
-
type: "file"
|
|
3814
|
-
})}.ts`;
|
|
3815
|
-
const resolvedPath2 = pluginManager.resolvePath({
|
|
3816
|
-
baseName: "",
|
|
3817
|
-
pluginKey: plugin.key
|
|
3818
|
-
});
|
|
3819
|
-
if (!resolvedPath2) {
|
|
3820
|
-
return null;
|
|
3821
|
-
}
|
|
3822
|
-
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
3823
|
-
react.File,
|
|
3824
|
-
{
|
|
3825
|
-
baseName: baseName2,
|
|
3826
|
-
path: resolvedPath2,
|
|
3827
|
-
meta: {
|
|
3828
|
-
pluginKey: plugin.key
|
|
3829
|
-
},
|
|
3830
|
-
children
|
|
3831
|
-
}
|
|
3832
|
-
);
|
|
3833
|
-
}
|
|
3834
|
-
const baseName = `${pluginManager.resolveName({
|
|
3835
|
-
name,
|
|
3836
|
-
pluginKey: plugin.key,
|
|
3837
|
-
type: "file"
|
|
3838
|
-
})}.ts`;
|
|
3839
|
-
const resolvedPath = pluginManager.resolvePath({
|
|
3840
|
-
baseName,
|
|
3841
|
-
pluginKey: plugin.key
|
|
3842
|
-
});
|
|
3843
|
-
if (!resolvedPath) {
|
|
3844
|
-
return null;
|
|
3845
|
-
}
|
|
3846
|
-
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
|
|
3847
|
-
react.File,
|
|
3848
|
-
{
|
|
3849
|
-
baseName,
|
|
3850
|
-
path: resolvedPath,
|
|
3851
|
-
meta: {
|
|
3852
|
-
pluginKey: plugin.key
|
|
3853
|
-
},
|
|
3854
|
-
children: [
|
|
3855
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Schema.Imports, { isTypeOnly }),
|
|
3856
|
-
children
|
|
3857
|
-
]
|
|
3858
|
-
}
|
|
3859
|
-
);
|
|
3860
|
-
};
|
|
3861
|
-
Schema.Imports = ({ isTypeOnly }) => {
|
|
3862
|
-
const { tree } = useSchema();
|
|
3863
|
-
const { path: root } = react.useFile();
|
|
3864
|
-
const refs = SchemaGenerator.deepSearch(tree, schemaKeywords.ref);
|
|
3865
|
-
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_jsx_runtime2.Fragment, { children: refs?.map((item, i) => {
|
|
3866
|
-
if (!item.args.path) {
|
|
3867
|
-
return void 0;
|
|
3868
|
-
}
|
|
3869
|
-
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(react.File.Import, { root, name: [item.args.name], path: item.args.path, isTypeOnly }, i);
|
|
3870
|
-
}).filter(Boolean) });
|
|
3871
|
-
};
|
|
3872
3113
|
Schema.Context = SchemaContext;
|
|
3873
3114
|
|
|
3874
|
-
// src/hooks/useSchema.ts
|
|
3875
|
-
function useSchema() {
|
|
3876
|
-
const props = react.useContext(Schema.Context);
|
|
3877
|
-
return props;
|
|
3878
|
-
}
|
|
3879
|
-
|
|
3880
3115
|
// src/components/Oas.tsx
|
|
3881
|
-
|
|
3882
|
-
var import_jsx_runtime3 = chunk5ULY3TQB_cjs.__toESM(require_jsx_runtime(), 1);
|
|
3116
|
+
var import_jsx_runtime3 = chunkCQMUJN22_cjs.__toESM(require_jsx_runtime(), 1);
|
|
3883
3117
|
var OasContext = react.createContext({});
|
|
3884
3118
|
function Oas({ oas, children, operations, generator }) {
|
|
3885
3119
|
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(OasContext.Provider, { value: { oas, generator, operations }, children });
|
|
@@ -3937,10 +3171,6 @@ react/cjs/react-jsx-runtime.development.js:
|
|
|
3937
3171
|
exports.Oas = Oas;
|
|
3938
3172
|
exports.Operation = Operation;
|
|
3939
3173
|
exports.Schema = Schema;
|
|
3940
|
-
exports.SchemaGenerator = SchemaGenerator;
|
|
3941
|
-
exports.isKeyword = isKeyword;
|
|
3942
3174
|
exports.require_jsx_runtime = require_jsx_runtime;
|
|
3943
|
-
|
|
3944
|
-
|
|
3945
|
-
//# sourceMappingURL=chunk-AAIEMW6V.cjs.map
|
|
3946
|
-
//# sourceMappingURL=chunk-AAIEMW6V.cjs.map
|
|
3175
|
+
//# sourceMappingURL=chunk-FZABPEYO.cjs.map
|
|
3176
|
+
//# sourceMappingURL=chunk-FZABPEYO.cjs.map
|