@kollors/react-codegen 2.0.0-alpha.2 → 2.0.0-alpha.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +39 -1
- package/README.ru.md +39 -1
- package/dist/generate.js +6 -31
- package/dist/generate.js.map +1 -1
- package/dist/openapi/document.d.ts +15 -0
- package/dist/openapi/document.js +113 -0
- package/dist/openapi/document.js.map +1 -0
- package/dist/openapi/generate.d.ts +3 -0
- package/dist/openapi/generate.js +66 -0
- package/dist/openapi/generate.js.map +1 -0
- package/dist/openapi/names.d.ts +6 -0
- package/dist/openapi/names.js +24 -0
- package/dist/openapi/names.js.map +1 -0
- package/dist/openapi/operations.d.ts +11 -0
- package/dist/openapi/operations.js +328 -0
- package/dist/openapi/operations.js.map +1 -0
- package/dist/openapi/schema.d.ts +19 -0
- package/dist/openapi/schema.js +313 -0
- package/dist/openapi/schema.js.map +1 -0
- package/dist/openapi-fetcher.d.ts +3 -27
- package/dist/openapi-fetcher.js +2 -163
- package/dist/openapi-fetcher.js.map +1 -1
- package/dist/openapi-runtime.d.ts +45 -0
- package/dist/openapi-runtime.js +302 -0
- package/dist/openapi-runtime.js.map +1 -0
- package/dist/openapi-runtime.source +313 -0
- package/dist/types.d.ts +2 -7
- package/package.json +2 -3
- package/templates/graphql.template +1 -0
- package/templates/openapi.template +0 -45
|
@@ -0,0 +1,313 @@
|
|
|
1
|
+
import { list, object, pointer, string } from './document.js';
|
|
2
|
+
import { comment, identifier } from './names.js';
|
|
3
|
+
const unsupported = [
|
|
4
|
+
'$dynamicRef',
|
|
5
|
+
'$dynamicAnchor',
|
|
6
|
+
'$id',
|
|
7
|
+
'not',
|
|
8
|
+
'if',
|
|
9
|
+
'then',
|
|
10
|
+
'else',
|
|
11
|
+
'dependentSchemas',
|
|
12
|
+
'patternProperties',
|
|
13
|
+
'unevaluatedProperties',
|
|
14
|
+
'unevaluatedItems',
|
|
15
|
+
'prefixItems',
|
|
16
|
+
'contains',
|
|
17
|
+
];
|
|
18
|
+
export class Schemas {
|
|
19
|
+
document;
|
|
20
|
+
names;
|
|
21
|
+
models = new Map();
|
|
22
|
+
variants = new Map();
|
|
23
|
+
contexts = new Map();
|
|
24
|
+
constructor(document, names) {
|
|
25
|
+
this.document = document;
|
|
26
|
+
this.names = names;
|
|
27
|
+
for (const key of Object.keys(document.schemas).sort()) {
|
|
28
|
+
const name = names.reserve(identifier(key, true), pointer('components', 'schemas', key));
|
|
29
|
+
this.models.set(pointer('components', 'schemas', key), name);
|
|
30
|
+
}
|
|
31
|
+
for (const [ref, name] of this.models) {
|
|
32
|
+
this.checkAliases(document.reference(ref, ref), [ref]);
|
|
33
|
+
for (const mode of ['input', 'output']) {
|
|
34
|
+
if (this.needsVariant(document.reference(ref, ref), mode)) {
|
|
35
|
+
this.variants.set(mode + ref, names.reserve(name + (mode === 'input' ? 'Input' : 'Output'), `${ref} (${mode})`));
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
checkAliases(value, trail) {
|
|
41
|
+
if (typeof value === 'boolean')
|
|
42
|
+
return;
|
|
43
|
+
const schema = object(value, trail.at(-1) ?? '#/components/schemas');
|
|
44
|
+
if (typeof schema.$ref === 'string') {
|
|
45
|
+
const ref = this.document.canonicalReference(schema.$ref, trail.at(-1) ?? schema.$ref);
|
|
46
|
+
if (trail.includes(ref))
|
|
47
|
+
throw new Error(`${ref}: circular type aliases must pass through an object property or array item.`);
|
|
48
|
+
this.checkAliases(this.document.reference(ref, ref), [...trail, ref]);
|
|
49
|
+
}
|
|
50
|
+
for (const key of ['allOf', 'oneOf', 'anyOf']) {
|
|
51
|
+
if (Array.isArray(schema[key]))
|
|
52
|
+
for (const child of schema[key])
|
|
53
|
+
this.checkAliases(child, trail);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
needsVariant(value, mode, visited = new Set()) {
|
|
57
|
+
if (value === null || typeof value !== 'object' || visited.has(value))
|
|
58
|
+
return false;
|
|
59
|
+
visited.add(value);
|
|
60
|
+
if (Array.isArray(value))
|
|
61
|
+
return value.some((item) => this.needsVariant(item, mode, visited));
|
|
62
|
+
const schema = value;
|
|
63
|
+
if (schema[mode === 'input' ? 'readOnly' : 'writeOnly'] === true)
|
|
64
|
+
return true;
|
|
65
|
+
if (typeof schema.$ref === 'string' && this.needsVariant(this.document.reference(schema.$ref, schema.$ref), mode, visited))
|
|
66
|
+
return true;
|
|
67
|
+
// Only schema-bearing keywords are traversed; examples/defaults may contain arbitrary data.
|
|
68
|
+
return ['properties', 'items', 'additionalProperties', 'allOf', 'oneOf', 'anyOf'].some((key) => {
|
|
69
|
+
const child = schema[key];
|
|
70
|
+
if (key === 'properties' && child && typeof child === 'object') {
|
|
71
|
+
return Object.values(child).some((property) => this.needsVariant(property, mode, visited));
|
|
72
|
+
}
|
|
73
|
+
return this.needsVariant(child, mode, visited);
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
metadata(value, location, visited = new Set()) {
|
|
77
|
+
if (typeof value === 'boolean')
|
|
78
|
+
return {};
|
|
79
|
+
const schema = object(value, location);
|
|
80
|
+
if (visited.has(schema))
|
|
81
|
+
return {};
|
|
82
|
+
visited.add(schema);
|
|
83
|
+
const target = typeof schema.$ref === 'string' ? this.metadata(this.document.reference(schema.$ref, location), schema.$ref, visited) : {};
|
|
84
|
+
if (schema.$ref !== undefined && this.document.version === '3.0')
|
|
85
|
+
return target;
|
|
86
|
+
// Every allOf branch applies. Union branches may apply to different values, so their annotations cannot be combined here.
|
|
87
|
+
const members = schema.allOf === undefined
|
|
88
|
+
? []
|
|
89
|
+
: list(schema.allOf, `${location}/allOf`).map((member, index) => this.metadata(member, `${location}/allOf/${index}`, visited));
|
|
90
|
+
const annotations = [target, ...members, schema];
|
|
91
|
+
return {
|
|
92
|
+
description: schema.description ?? target.description ?? members.find((member) => member.description !== undefined)?.description,
|
|
93
|
+
readOnly: annotations.some((annotation) => annotation.readOnly === true),
|
|
94
|
+
writeOnly: annotations.some((annotation) => annotation.writeOnly === true),
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
excludedProperties(value, location, mode, visited = new Set()) {
|
|
98
|
+
const excluded = new Set();
|
|
99
|
+
if (mode === 'model' || typeof value === 'boolean' || visited.has(value))
|
|
100
|
+
return excluded;
|
|
101
|
+
visited.add(value);
|
|
102
|
+
const schema = object(value, location);
|
|
103
|
+
if (typeof schema.$ref === 'string') {
|
|
104
|
+
for (const name of this.excludedProperties(this.document.reference(schema.$ref, location), schema.$ref, mode, visited))
|
|
105
|
+
excluded.add(name);
|
|
106
|
+
if (this.document.version === '3.0')
|
|
107
|
+
return excluded;
|
|
108
|
+
}
|
|
109
|
+
for (const [name, property] of Object.entries(object(schema.properties ?? {}, `${location}/properties`))) {
|
|
110
|
+
const metadata = this.metadata(property, `${location}/properties/${name}`);
|
|
111
|
+
if (metadata[mode === 'input' ? 'readOnly' : 'writeOnly'] === true)
|
|
112
|
+
excluded.add(name);
|
|
113
|
+
}
|
|
114
|
+
if (schema.allOf !== undefined) {
|
|
115
|
+
for (const [index, member] of list(schema.allOf, `${location}/allOf`).entries()) {
|
|
116
|
+
for (const name of this.excludedProperties(member, `${location}/allOf/${index}`, mode, visited))
|
|
117
|
+
excluded.add(name);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
return excluded;
|
|
121
|
+
}
|
|
122
|
+
declarations() {
|
|
123
|
+
const result = [];
|
|
124
|
+
for (const [ref, name] of this.models) {
|
|
125
|
+
const value = this.document.reference(ref, ref);
|
|
126
|
+
const description = typeof value === 'object' && value !== null ? value.description : undefined;
|
|
127
|
+
result.push(`${comment(description)}export type ${name} = ${this.type(value, ref)};`);
|
|
128
|
+
for (const mode of ['input', 'output']) {
|
|
129
|
+
const variant = this.variants.get(mode + ref);
|
|
130
|
+
if (variant)
|
|
131
|
+
result.push(`export type ${variant} = ${this.type(value, ref, mode)};`);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
for (const context of this.contexts.values())
|
|
135
|
+
result.push(`type ${context.name} = ${context.type};`);
|
|
136
|
+
return result.join('\n\n');
|
|
137
|
+
}
|
|
138
|
+
contextualType(ref, mode, excluded, name, trail) {
|
|
139
|
+
const key = JSON.stringify([ref, mode, [...excluded].sort()]);
|
|
140
|
+
const existing = this.contexts.get(key);
|
|
141
|
+
if (existing)
|
|
142
|
+
return existing.name;
|
|
143
|
+
const context = {
|
|
144
|
+
name: this.names.reserve(`${name}Context${this.contexts.size + 1}`, `${ref} (${mode}, contextual fields)`),
|
|
145
|
+
type: '',
|
|
146
|
+
};
|
|
147
|
+
// Reserve the alias before rendering its body so recursive contextual references can use the same name.
|
|
148
|
+
this.contexts.set(key, context);
|
|
149
|
+
context.type = this.type(this.document.reference(ref, ref), ref, mode, [...trail, ref], excluded);
|
|
150
|
+
return context.name;
|
|
151
|
+
}
|
|
152
|
+
type(value, location, mode = 'model', trail = [], excluded = new Set()) {
|
|
153
|
+
if (typeof value === 'boolean') {
|
|
154
|
+
if (this.document.version === '3.0')
|
|
155
|
+
throw new Error(`${location}: boolean schemas require OpenAPI 3.1.`);
|
|
156
|
+
return value ? 'unknown' : 'never';
|
|
157
|
+
}
|
|
158
|
+
const schema = object(value, location);
|
|
159
|
+
const excludedHere = new Set([...excluded, ...this.excludedProperties(schema, location, mode)]);
|
|
160
|
+
for (const keyword of unsupported) {
|
|
161
|
+
if (schema[keyword] !== undefined)
|
|
162
|
+
throw new Error(`${location}: schema keyword "${keyword}" is not supported.`);
|
|
163
|
+
}
|
|
164
|
+
if (schema.$ref !== undefined) {
|
|
165
|
+
const ref = this.document.canonicalReference(string(schema.$ref, `${location}/$ref`), location);
|
|
166
|
+
const referenced = this.document.reference(ref, location);
|
|
167
|
+
const name = this.variants.get(mode + ref) ?? this.models.get(ref);
|
|
168
|
+
if (!name && trail.includes(ref))
|
|
169
|
+
throw new Error(`${location}: recursive schemas must be declared in components.schemas.`);
|
|
170
|
+
const excludedByReference = this.excludedProperties(referenced, ref, mode);
|
|
171
|
+
const hasContextExclusions = [...excludedHere].some((property) => !excludedByReference.has(property));
|
|
172
|
+
const type = name
|
|
173
|
+
? hasContextExclusions
|
|
174
|
+
? this.contextualType(ref, mode, excludedHere, name, trail)
|
|
175
|
+
: name
|
|
176
|
+
: this.type(referenced, ref, mode, [...trail, ref], excludedHere);
|
|
177
|
+
if (this.document.version === '3.0')
|
|
178
|
+
return type;
|
|
179
|
+
const siblings = { ...schema };
|
|
180
|
+
delete siblings.$ref;
|
|
181
|
+
const siblingType = this.type(siblings, location, mode, trail, excludedHere);
|
|
182
|
+
return siblingType === 'unknown' ? type : `(${type}) & (${siblingType})`;
|
|
183
|
+
}
|
|
184
|
+
const constraints = [];
|
|
185
|
+
for (const key of ['allOf', 'oneOf', 'anyOf']) {
|
|
186
|
+
if (schema[key] !== undefined) {
|
|
187
|
+
const members = list(schema[key], `${location}/${key}`);
|
|
188
|
+
if (!members.length)
|
|
189
|
+
throw new Error(`${location}/${key} must not be empty.`);
|
|
190
|
+
const types = members.map((member, index) => `(${this.type(member, `${location}/${key}/${index}`, mode, trail, excludedHere)})`);
|
|
191
|
+
constraints.push(types.join(key === 'allOf' ? ' & ' : ' | '));
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
let types = schema.type === undefined ? [] : Array.isArray(schema.type) ? schema.type : [schema.type];
|
|
195
|
+
if (Array.isArray(schema.type) && !schema.type.length)
|
|
196
|
+
throw new Error(`${location}/type must not be empty.`);
|
|
197
|
+
if (Array.isArray(schema.type) && this.document.version === '3.0')
|
|
198
|
+
throw new Error(`${location}: type arrays require OpenAPI 3.1.`);
|
|
199
|
+
if (!types.length && ['properties', 'additionalProperties', 'required', 'items'].some((keyword) => schema[keyword] !== undefined)) {
|
|
200
|
+
// These keywords constrain only objects/arrays; without type, other JSON values remain valid.
|
|
201
|
+
types = ['null', 'boolean', 'number', 'string', 'array', 'object'];
|
|
202
|
+
}
|
|
203
|
+
const primitives = types.map((kind) => {
|
|
204
|
+
switch (kind) {
|
|
205
|
+
case 'null':
|
|
206
|
+
if (this.document.version === '3.0' && schema.type !== undefined)
|
|
207
|
+
throw new Error(`${location}: use nullable in OpenAPI 3.0.`);
|
|
208
|
+
return 'null';
|
|
209
|
+
case 'string':
|
|
210
|
+
return schema.format === 'binary' ? 'Blob' : 'string';
|
|
211
|
+
case 'number':
|
|
212
|
+
case 'integer':
|
|
213
|
+
return 'number';
|
|
214
|
+
case 'boolean':
|
|
215
|
+
return 'boolean';
|
|
216
|
+
case 'array':
|
|
217
|
+
if (schema.items === undefined && this.document.version === '3.0' && schema.type !== undefined)
|
|
218
|
+
throw new Error(`${location}/items is required for arrays.`);
|
|
219
|
+
return `Array<${schema.items === undefined ? 'unknown' : this.type(schema.items, `${location}/items`, mode, trail)}>`;
|
|
220
|
+
case 'object':
|
|
221
|
+
return this.objectType(schema, location, mode, trail, excludedHere);
|
|
222
|
+
default:
|
|
223
|
+
throw new Error(`${location}: unsupported schema type ${JSON.stringify(kind)}.`);
|
|
224
|
+
}
|
|
225
|
+
});
|
|
226
|
+
if (primitives.length) {
|
|
227
|
+
if (this.document.version === '3.0' && schema.type !== undefined && schema.nullable === true)
|
|
228
|
+
primitives.push('null');
|
|
229
|
+
constraints.push([...new Set(primitives)].join(' | '));
|
|
230
|
+
}
|
|
231
|
+
if (schema.enum !== undefined) {
|
|
232
|
+
const values = list(schema.enum, `${location}/enum`);
|
|
233
|
+
if (!values.length)
|
|
234
|
+
throw new Error(`${location}/enum must not be empty.`);
|
|
235
|
+
constraints.push([...new Set(values.map((item) => literal(item, `${location}/enum`)))].join(' | '));
|
|
236
|
+
}
|
|
237
|
+
if (schema.const !== undefined || Object.hasOwn(schema, 'const')) {
|
|
238
|
+
if (this.document.version === '3.0')
|
|
239
|
+
throw new Error(`${location}: const requires OpenAPI 3.1.`);
|
|
240
|
+
constraints.push(literal(schema.const, `${location}/const`));
|
|
241
|
+
}
|
|
242
|
+
if (!constraints.length)
|
|
243
|
+
return 'unknown';
|
|
244
|
+
return constraints.length === 1 ? constraints[0] : constraints.map((part) => `(${part})`).join(' & ');
|
|
245
|
+
}
|
|
246
|
+
objectType(schema, location, mode, trail, excluded) {
|
|
247
|
+
const properties = schema.properties === undefined ? {} : object(schema.properties, `${location}/properties`);
|
|
248
|
+
const required = new Set(schema.required === undefined
|
|
249
|
+
? []
|
|
250
|
+
: list(schema.required, `${location}/required`).map((key, index) => {
|
|
251
|
+
if (typeof key !== 'string')
|
|
252
|
+
throw new Error(`${location}/required/${index} must be a string.`);
|
|
253
|
+
return key;
|
|
254
|
+
}));
|
|
255
|
+
const fields = [];
|
|
256
|
+
for (const [name, value] of Object.entries(properties)) {
|
|
257
|
+
if (excluded.has(name))
|
|
258
|
+
continue;
|
|
259
|
+
const metadata = this.metadata(value, `${location}/properties/${name}`);
|
|
260
|
+
const optional = required.has(name) ? '' : '?';
|
|
261
|
+
fields.push(`${comment(metadata.description)}${JSON.stringify(name)}${optional}: ${this.type(value, `${location}/properties/${name}`, mode, trail)};`);
|
|
262
|
+
}
|
|
263
|
+
for (const name of required) {
|
|
264
|
+
if (excluded.has(name))
|
|
265
|
+
continue;
|
|
266
|
+
if (!Object.hasOwn(properties, name)) {
|
|
267
|
+
const extra = schema.additionalProperties;
|
|
268
|
+
const type = extra === false
|
|
269
|
+
? 'never'
|
|
270
|
+
: extra === undefined || extra === true
|
|
271
|
+
? 'unknown'
|
|
272
|
+
: this.type(extra, `${location}/additionalProperties`, mode, trail);
|
|
273
|
+
fields.push(`${JSON.stringify(name)}: ${type};`);
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
const extra = schema.additionalProperties;
|
|
277
|
+
if (extra === undefined || extra === true) {
|
|
278
|
+
fields.push('[key: string]: unknown;');
|
|
279
|
+
}
|
|
280
|
+
else if (extra !== false) {
|
|
281
|
+
const type = this.type(extra, `${location}/additionalProperties`, mode, trail);
|
|
282
|
+
if (Object.keys(properties).length && type !== 'unknown') {
|
|
283
|
+
throw new Error(`${location}: typed additionalProperties alongside named properties cannot be represented exactly in TypeScript. Use a separate dictionary property.`);
|
|
284
|
+
}
|
|
285
|
+
fields.push(`[key: string]: ${type};`);
|
|
286
|
+
}
|
|
287
|
+
return fields.length
|
|
288
|
+
? `{\n${fields
|
|
289
|
+
.join('\n')
|
|
290
|
+
.split('\n')
|
|
291
|
+
.map((line) => ` ${line}`)
|
|
292
|
+
.join('\n')}\n}`
|
|
293
|
+
: 'Record<string, never>';
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
function literal(value, location) {
|
|
297
|
+
if (value === null || typeof value === 'string' || typeof value === 'boolean' || (typeof value === 'number' && Number.isFinite(value))) {
|
|
298
|
+
return JSON.stringify(value);
|
|
299
|
+
}
|
|
300
|
+
if (Array.isArray(value))
|
|
301
|
+
return `[${value.map((item) => literal(item, location)).join(', ')}]`;
|
|
302
|
+
if (value && typeof value === 'object') {
|
|
303
|
+
if (!Object.keys(value).length)
|
|
304
|
+
return 'Record<string, never>';
|
|
305
|
+
return ('{ ' +
|
|
306
|
+
Object.entries(value)
|
|
307
|
+
.map(([key, item]) => `${JSON.stringify(key)}: ${literal(item, location)}`)
|
|
308
|
+
.join('; ') +
|
|
309
|
+
' }');
|
|
310
|
+
}
|
|
311
|
+
throw new Error(`${location}: expected a JSON value.`);
|
|
312
|
+
}
|
|
313
|
+
//# sourceMappingURL=schema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.js","sourceRoot":"","sources":["../../src/openapi/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAwB,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AACpF,OAAO,EAAE,OAAO,EAAE,UAAU,EAAc,MAAM,YAAY,CAAC;AAI7D,MAAM,WAAW,GAAG;IAClB,aAAa;IACb,gBAAgB;IAChB,KAAK;IACL,KAAK;IACL,IAAI;IACJ,MAAM;IACN,MAAM;IACN,kBAAkB;IAClB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
|
-
pathParams?: TPathParams;
|
|
7
|
-
queryParams?: TQueryParams;
|
|
8
|
-
signal?: AbortSignal;
|
|
9
|
-
url: string;
|
|
10
|
-
}
|
|
11
|
-
export interface OpenapiFetcherConfiguration {
|
|
12
|
-
/** Custom value for the `Authorization` header. When omitted, no authorization header is added unless `auth` is configured. */
|
|
13
|
-
getToken?: () => string | null | undefined;
|
|
14
|
-
/** Base URL prepended to paths from the OpenAPI document. */
|
|
15
|
-
baseUrl?: string;
|
|
16
|
-
/** Token storage and fetch credential settings. */
|
|
17
|
-
auth?: AuthConfig;
|
|
18
|
-
}
|
|
19
|
-
export declare class OpenapiHttpError<TError = unknown> extends Error {
|
|
20
|
-
readonly status: number;
|
|
21
|
-
readonly statusText: string;
|
|
22
|
-
readonly url: string;
|
|
23
|
-
readonly data: TError;
|
|
24
|
-
constructor(status: number, statusText: string, url: string, data: TError);
|
|
25
|
-
}
|
|
26
|
-
export declare function createOpenapiFetcher(configuration?: OpenapiFetcherConfiguration): <TData, TError, TBody, THeaders, TQueryParams, TPathParams>(options: OpenapiFetcherOptions<TBody, THeaders, TQueryParams, TPathParams>) => Promise<TData>;
|
|
27
|
-
export declare const openapiFetcher: <TData, TError, TBody, THeaders, TQueryParams, TPathParams>(options: OpenapiFetcherOptions<TBody, THeaders, TQueryParams, TPathParams>) => Promise<TData>;
|
|
1
|
+
export type { OpenapiFetcherConfiguration, OpenapiFetcherOptions } from './openapi-runtime.js';
|
|
2
|
+
export { createOpenapiFetcher, OpenapiHttpError } from './openapi-runtime.js';
|
|
3
|
+
export declare const openapiFetcher: <TData, TError = unknown, TBody = unknown, THeaders = unknown, TQueryParams = unknown, TPathParams = unknown>(options: import("./openapi-runtime.js").OpenapiFetcherOptions<TBody, THeaders, TQueryParams, TPathParams>) => Promise<TData>;
|
package/dist/openapi-fetcher.js
CHANGED
|
@@ -1,165 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
return '';
|
|
4
|
-
if (auth.storage === 'cookie') {
|
|
5
|
-
if (typeof document === 'undefined' || !auth.key)
|
|
6
|
-
return '';
|
|
7
|
-
const cookie = document.cookie
|
|
8
|
-
.split(';')
|
|
9
|
-
.map((part) => part.trim())
|
|
10
|
-
.find((part) => part.startsWith(`${auth.key}=`));
|
|
11
|
-
if (!cookie)
|
|
12
|
-
return '';
|
|
13
|
-
const value = cookie.slice(auth.key.length + 1);
|
|
14
|
-
try {
|
|
15
|
-
return decodeURIComponent(value);
|
|
16
|
-
}
|
|
17
|
-
catch {
|
|
18
|
-
return value;
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
if (typeof globalThis[auth.storage] === 'undefined' || !auth.key)
|
|
22
|
-
return '';
|
|
23
|
-
return globalThis[auth.storage].getItem(auth.key) ?? '';
|
|
24
|
-
}
|
|
25
|
-
function authorizationValue(configuration) {
|
|
26
|
-
if (configuration.getToken)
|
|
27
|
-
return configuration.getToken() ?? '';
|
|
28
|
-
const auth = configuration.auth;
|
|
29
|
-
if (!auth)
|
|
30
|
-
return '';
|
|
31
|
-
const token = readConfiguredToken(auth);
|
|
32
|
-
if (!token || auth.scheme === false)
|
|
33
|
-
return token;
|
|
34
|
-
const scheme = auth.scheme ?? 'Bearer';
|
|
35
|
-
if (!scheme)
|
|
36
|
-
return token;
|
|
37
|
-
return token.toLowerCase().startsWith(`${scheme.toLowerCase()} `) ? token : `${scheme} ${token}`;
|
|
38
|
-
}
|
|
39
|
-
function withBaseUrl(baseUrl, url) {
|
|
40
|
-
if (!baseUrl || /^[a-z][a-z\d+.-]*:\/\//i.test(url))
|
|
41
|
-
return url;
|
|
42
|
-
return `${baseUrl.replace(/\/+$/, '')}/${url.replace(/^\/+/, '')}`;
|
|
43
|
-
}
|
|
44
|
-
export class OpenapiHttpError extends Error {
|
|
45
|
-
status;
|
|
46
|
-
statusText;
|
|
47
|
-
url;
|
|
48
|
-
data;
|
|
49
|
-
constructor(status, statusText, url, data) {
|
|
50
|
-
super(`HTTP ${status}${statusText ? ` ${statusText}` : ''} for ${url}.`);
|
|
51
|
-
this.status = status;
|
|
52
|
-
this.statusText = statusText;
|
|
53
|
-
this.url = url;
|
|
54
|
-
this.data = data;
|
|
55
|
-
this.name = 'OpenapiHttpError';
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
function serializeQueryParams(queryParams) {
|
|
59
|
-
const result = new URLSearchParams();
|
|
60
|
-
if (queryParams == null)
|
|
61
|
-
return result;
|
|
62
|
-
if (queryParams instanceof URLSearchParams)
|
|
63
|
-
return new URLSearchParams(queryParams);
|
|
64
|
-
if (typeof queryParams !== 'object' || Array.isArray(queryParams)) {
|
|
65
|
-
throw new TypeError('OpenAPI query parameters must be an object.');
|
|
66
|
-
}
|
|
67
|
-
for (const [key, value] of Object.entries(queryParams)) {
|
|
68
|
-
if (value === undefined || value === null)
|
|
69
|
-
continue;
|
|
70
|
-
const values = Array.isArray(value) ? value : [value];
|
|
71
|
-
for (const item of values) {
|
|
72
|
-
if (item === undefined || item === null)
|
|
73
|
-
continue;
|
|
74
|
-
result.append(key, typeof item === 'object' ? (JSON.stringify(item) ?? String(item)) : String(item));
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
return result;
|
|
78
|
-
}
|
|
79
|
-
function withQueryParams(url, queryParams) {
|
|
80
|
-
const serialized = queryParams.toString();
|
|
81
|
-
if (!serialized)
|
|
82
|
-
return url;
|
|
83
|
-
const hashIndex = url.indexOf('#');
|
|
84
|
-
const base = hashIndex === -1 ? url : url.slice(0, hashIndex);
|
|
85
|
-
const hash = hashIndex === -1 ? '' : url.slice(hashIndex);
|
|
86
|
-
const separator = base.includes('?') ? (base.endsWith('?') || base.endsWith('&') ? '' : '&') : '?';
|
|
87
|
-
return `${base}${separator}${serialized}${hash}`;
|
|
88
|
-
}
|
|
89
|
-
async function readResponse(response) {
|
|
90
|
-
if (response.status === 204 || response.status === 205 || response.body === null || response.headers.get('content-length') === '0')
|
|
91
|
-
return undefined;
|
|
92
|
-
const contentType = response.headers.get('content-type')?.toLowerCase() ?? '';
|
|
93
|
-
if (contentType.includes('json'))
|
|
94
|
-
return await response.json();
|
|
95
|
-
if (contentType.startsWith('text/') || contentType.includes('xml'))
|
|
96
|
-
return await response.text();
|
|
97
|
-
return await response.blob();
|
|
98
|
-
}
|
|
99
|
-
export function createOpenapiFetcher(configuration = {}) {
|
|
100
|
-
return async function openapiFetcher(options) {
|
|
101
|
-
try {
|
|
102
|
-
const headers = new Headers({ 'content-type': 'application/json' });
|
|
103
|
-
const token = authorizationValue(configuration);
|
|
104
|
-
if (token)
|
|
105
|
-
headers.set('authorization', token);
|
|
106
|
-
new Headers(options.headers).forEach((value, key) => {
|
|
107
|
-
headers.set(key, value);
|
|
108
|
-
});
|
|
109
|
-
const isFormData = typeof FormData !== 'undefined' && options.body instanceof FormData;
|
|
110
|
-
if (isFormData || headers.get('content-type')?.toLowerCase().includes('multipart/form-data'))
|
|
111
|
-
headers.delete('content-type');
|
|
112
|
-
const pathParams = options.pathParams;
|
|
113
|
-
const path = options.url.replace(/\{([^}]+)}/g, (_match, key) => {
|
|
114
|
-
const value = pathParams?.[key];
|
|
115
|
-
if (value === undefined || value === null)
|
|
116
|
-
throw new Error(`Missing required OpenAPI path parameter "${key}" for ${options.url}.`);
|
|
117
|
-
return encodeURIComponent(String(value));
|
|
118
|
-
});
|
|
119
|
-
const url = withBaseUrl(configuration.baseUrl, path);
|
|
120
|
-
const queryParams = serializeQueryParams(options.queryParams);
|
|
121
|
-
const requestUrl = withQueryParams(url, queryParams);
|
|
122
|
-
const body = isFormData ? options.body : options.body == null ? undefined : JSON.stringify(options.body);
|
|
123
|
-
let response;
|
|
124
|
-
try {
|
|
125
|
-
response = await fetch(requestUrl, {
|
|
126
|
-
body,
|
|
127
|
-
headers,
|
|
128
|
-
method: options.method.toUpperCase(),
|
|
129
|
-
signal: options.signal,
|
|
130
|
-
credentials: configuration.auth?.credentials,
|
|
131
|
-
});
|
|
132
|
-
}
|
|
133
|
-
catch (error) {
|
|
134
|
-
if (error instanceof Error && error.name === 'AbortError')
|
|
135
|
-
throw error;
|
|
136
|
-
throw new Error(`Could not reach OpenAPI endpoint ${requestUrl}: ${error instanceof Error ? error.message : String(error)}`, {
|
|
137
|
-
cause: error,
|
|
138
|
-
});
|
|
139
|
-
}
|
|
140
|
-
let result;
|
|
141
|
-
const errorResponse = response.ok ? undefined : response.clone();
|
|
142
|
-
try {
|
|
143
|
-
result = await readResponse(response);
|
|
144
|
-
}
|
|
145
|
-
catch (error) {
|
|
146
|
-
if (!response.ok) {
|
|
147
|
-
result = errorResponse ? await errorResponse.text().catch(() => undefined) : undefined;
|
|
148
|
-
throw new OpenapiHttpError(response.status, response.statusText, requestUrl, result);
|
|
149
|
-
}
|
|
150
|
-
throw new Error(`Could not read response from ${requestUrl}: ${error instanceof Error ? error.message : String(error)}`, {
|
|
151
|
-
cause: error,
|
|
152
|
-
});
|
|
153
|
-
}
|
|
154
|
-
if (!response.ok) {
|
|
155
|
-
throw new OpenapiHttpError(response.status, response.statusText, requestUrl, result);
|
|
156
|
-
}
|
|
157
|
-
return result;
|
|
158
|
-
}
|
|
159
|
-
catch (error) {
|
|
160
|
-
throw error instanceof Error ? error : new Error(String(error));
|
|
161
|
-
}
|
|
162
|
-
};
|
|
163
|
-
}
|
|
1
|
+
import { createOpenapiFetcher } from './openapi-runtime.js';
|
|
2
|
+
export { createOpenapiFetcher, OpenapiHttpError } from './openapi-runtime.js';
|
|
164
3
|
export const openapiFetcher = createOpenapiFetcher();
|
|
165
4
|
//# sourceMappingURL=openapi-fetcher.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"openapi-fetcher.js","sourceRoot":"","sources":["../src/openapi-fetcher.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"openapi-fetcher.js","sourceRoot":"","sources":["../src/openapi-fetcher.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAG5D,OAAO,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAE9E,MAAM,CAAC,MAAM,cAAc,GAAG,oBAAoB,EAAE,CAAC"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
export type TokenStorage = 'localStorage' | 'sessionStorage' | 'cookie' | 'none';
|
|
2
|
+
export interface AuthConfig {
|
|
3
|
+
storage: TokenStorage;
|
|
4
|
+
key?: string;
|
|
5
|
+
scheme?: string | false;
|
|
6
|
+
credentials?: RequestCredentials;
|
|
7
|
+
}
|
|
8
|
+
export interface OpenapiFetcherOptions<TBody, THeaders, TQueryParams, TPathParams> {
|
|
9
|
+
body?: TBody;
|
|
10
|
+
headers?: THeaders;
|
|
11
|
+
method: string;
|
|
12
|
+
pathParams?: TPathParams;
|
|
13
|
+
queryParams?: TQueryParams;
|
|
14
|
+
signal?: AbortSignal;
|
|
15
|
+
url: string;
|
|
16
|
+
contentType?: string;
|
|
17
|
+
accept?: string;
|
|
18
|
+
responseType?: 'blob';
|
|
19
|
+
/** Response status -> media type -> decoder. Exact statuses/media types take precedence over ranges and wildcards. */
|
|
20
|
+
responseTypes?: Record<string, Record<string, 'blob' | 'auto'>>;
|
|
21
|
+
parameters?: OpenapiParameter[];
|
|
22
|
+
}
|
|
23
|
+
export interface OpenapiParameter {
|
|
24
|
+
name: string;
|
|
25
|
+
in: 'path' | 'query' | 'header';
|
|
26
|
+
style: 'simple' | 'form' | 'deepObject' | 'spaceDelimited' | 'pipeDelimited';
|
|
27
|
+
explode: boolean;
|
|
28
|
+
required: boolean;
|
|
29
|
+
}
|
|
30
|
+
export interface OpenapiFetcherConfiguration {
|
|
31
|
+
/** Custom value for the `Authorization` header. When omitted, no authorization header is added unless `auth` is configured. */
|
|
32
|
+
getToken?: () => string | null | undefined;
|
|
33
|
+
/** Base URL prepended to paths from the OpenAPI document. */
|
|
34
|
+
baseUrl?: string;
|
|
35
|
+
/** Token storage and fetch credential settings. */
|
|
36
|
+
auth?: AuthConfig;
|
|
37
|
+
}
|
|
38
|
+
export declare class OpenapiHttpError<TError = unknown> extends Error {
|
|
39
|
+
readonly status: number;
|
|
40
|
+
readonly statusText: string;
|
|
41
|
+
readonly url: string;
|
|
42
|
+
readonly data: TError;
|
|
43
|
+
constructor(status: number, statusText: string, url: string, data: TError);
|
|
44
|
+
}
|
|
45
|
+
export declare function createOpenapiFetcher(configuration?: OpenapiFetcherConfiguration): <TData, TError = unknown, TBody = unknown, THeaders = unknown, TQueryParams = unknown, TPathParams = unknown>(options: OpenapiFetcherOptions<TBody, THeaders, TQueryParams, TPathParams>) => Promise<TData>;
|