typedapi-client-helpers 0.3.1 → 0.3.3
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/CHANGELOG.md +0 -1
- package/README.md +6 -7
- package/dist/cjs/index.js +0 -4
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/utils/handleApiResponse.js +10 -6
- package/dist/cjs/utils/handleApiResponse.js.map +1 -1
- package/dist/esm/index.js +0 -4
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/utils/handleApiResponse.js +10 -6
- package/dist/esm/utils/handleApiResponse.js.map +1 -1
- package/dist/types/index.d.ts +0 -4
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/interfaces/ApiResult.d.ts +1 -1
- package/dist/types/interfaces/ApiResult.d.ts.map +1 -1
- package/dist/types/types/ApiMethodOptions.d.ts +2 -2
- package/dist/types/types/ApiMethodOptions.d.ts.map +1 -1
- package/dist/types/utils/handleApiResponse.d.ts +1 -0
- package/dist/types/utils/handleApiResponse.d.ts.map +1 -1
- package/package.json +2 -1
- package/scripts/generate-api-minimal.mjs +30 -1
- package/scripts/openapi-generator/index.mjs +7 -26
- package/scripts/openapi-generator/method-template.mjs +14 -40
- package/scripts/openapi-generator/openapi-utils.mjs +411 -411
- package/scripts/openapi-generator/schema.mjs +0 -156
- package/dist/cjs/types/ApiMethodArguments.js +0 -3
- package/dist/cjs/types/ApiMethodArguments.js.map +0 -1
- package/dist/cjs/types/HttpResponse.js +0 -3
- package/dist/cjs/types/HttpResponse.js.map +0 -1
- package/dist/cjs/utils/extractArgsCallbacksAndParams.js +0 -51
- package/dist/cjs/utils/extractArgsCallbacksAndParams.js.map +0 -1
- package/dist/cjs/utils/extractArgsToastsAndParams.js +0 -49
- package/dist/cjs/utils/extractArgsToastsAndParams.js.map +0 -1
- package/dist/cjs/utils/wireMapping.js +0 -123
- package/dist/cjs/utils/wireMapping.js.map +0 -1
- package/dist/esm/types/ApiMethodArguments.js +0 -2
- package/dist/esm/types/ApiMethodArguments.js.map +0 -1
- package/dist/esm/types/HttpResponse.js +0 -2
- package/dist/esm/types/HttpResponse.js.map +0 -1
- package/dist/esm/utils/extractArgsCallbacksAndParams.js +0 -48
- package/dist/esm/utils/extractArgsCallbacksAndParams.js.map +0 -1
- package/dist/esm/utils/extractArgsToastsAndParams.js +0 -46
- package/dist/esm/utils/extractArgsToastsAndParams.js.map +0 -1
- package/dist/esm/utils/wireMapping.js +0 -119
- package/dist/esm/utils/wireMapping.js.map +0 -1
- package/dist/types/types/ApiMethodArguments.d.ts +0 -6
- package/dist/types/types/ApiMethodArguments.d.ts.map +0 -1
- package/dist/types/types/HttpResponse.d.ts +0 -2
- package/dist/types/types/HttpResponse.d.ts.map +0 -1
- package/dist/types/utils/extractArgsCallbacksAndParams.d.ts +0 -22
- package/dist/types/utils/extractArgsCallbacksAndParams.d.ts.map +0 -1
- package/dist/types/utils/extractArgsToastsAndParams.d.ts +0 -20
- package/dist/types/utils/extractArgsToastsAndParams.d.ts.map +0 -1
- package/dist/types/utils/wireMapping.d.ts +0 -30
- package/dist/types/utils/wireMapping.d.ts.map +0 -1
|
@@ -70,144 +70,6 @@ function assertUniqueTypePropertyNames(entries, contextName) {
|
|
|
70
70
|
}
|
|
71
71
|
}
|
|
72
72
|
|
|
73
|
-
function escapeJsonPointerPart(value) {
|
|
74
|
-
return String(value).replace(/~/g, "~0").replace(/\//g, "~1");
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
function componentWireSchemaKey(rawName) {
|
|
78
|
-
return `#/components/schemas/${escapeJsonPointerPart(rawName)}`;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
function operationWireSchemaKey(operationId, kind) {
|
|
82
|
-
return `operation:${operationId}:${kind}`;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
function wireSchemaDescriptor(openApi, schemaOrRef) {
|
|
86
|
-
if (!schemaOrRef) return { kind: "identity" };
|
|
87
|
-
if (schemaOrRef.$ref) return { kind: "ref", ref: String(schemaOrRef.$ref) };
|
|
88
|
-
|
|
89
|
-
const schema =
|
|
90
|
-
dereference(openApi, schemaOrRef, "Wire schema reference") ?? schemaOrRef;
|
|
91
|
-
|
|
92
|
-
if (schema.allOf) {
|
|
93
|
-
const schemas = schema.allOf.map((item) =>
|
|
94
|
-
wireSchemaDescriptor(openApi, item),
|
|
95
|
-
);
|
|
96
|
-
const localSchema = schemaWithoutComposition(schema);
|
|
97
|
-
if (hasObjectShape(localSchema))
|
|
98
|
-
schemas.push(wireSchemaDescriptor(openApi, localSchema));
|
|
99
|
-
return { kind: "allOf", schemas };
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
if (schema.oneOf || schema.anyOf) {
|
|
103
|
-
return {
|
|
104
|
-
kind: "union",
|
|
105
|
-
schemas: (schema.oneOf ?? schema.anyOf).map((item) =>
|
|
106
|
-
wireSchemaDescriptor(openApi, item),
|
|
107
|
-
),
|
|
108
|
-
};
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
const schemaType = Array.isArray(schema.type)
|
|
112
|
-
? schema.type.find((item) => item !== "null")
|
|
113
|
-
: schema.type;
|
|
114
|
-
|
|
115
|
-
if (schemaType === "array") {
|
|
116
|
-
return {
|
|
117
|
-
kind: "array",
|
|
118
|
-
items: wireSchemaDescriptor(openApi, schema.items ?? {}),
|
|
119
|
-
};
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
if (
|
|
123
|
-
schemaType === "object" ||
|
|
124
|
-
schema.properties ||
|
|
125
|
-
schema.additionalProperties
|
|
126
|
-
) {
|
|
127
|
-
const rawPropertyNames = Object.keys(schema.properties ?? {});
|
|
128
|
-
assertUniqueTypePropertyNames(rawPropertyNames, "an OpenAPI object schema");
|
|
129
|
-
const properties = {};
|
|
130
|
-
|
|
131
|
-
for (const [wireName, propertySchema] of Object.entries(
|
|
132
|
-
schema.properties ?? {},
|
|
133
|
-
)) {
|
|
134
|
-
const localName = typePropertyName(wireName);
|
|
135
|
-
const nested = wireSchemaDescriptor(openApi, propertySchema);
|
|
136
|
-
properties[localName] = {
|
|
137
|
-
wireName,
|
|
138
|
-
...(nested.kind === "identity" ? {} : { schema: nested }),
|
|
139
|
-
};
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
let additionalProperties;
|
|
143
|
-
if (schema.additionalProperties === true) additionalProperties = true;
|
|
144
|
-
else if (schema.additionalProperties) {
|
|
145
|
-
additionalProperties = wireSchemaDescriptor(
|
|
146
|
-
openApi,
|
|
147
|
-
schema.additionalProperties,
|
|
148
|
-
);
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
return {
|
|
152
|
-
kind: "object",
|
|
153
|
-
...(Object.keys(properties).length > 0 ? { properties } : {}),
|
|
154
|
-
...(additionalProperties !== undefined ? { additionalProperties } : {}),
|
|
155
|
-
};
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
return { kind: "identity" };
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
function generateWireSchemaRegistry(openApi, operations, options = {}) {
|
|
162
|
-
const registry = {};
|
|
163
|
-
|
|
164
|
-
for (const [rawName, schema] of Object.entries(
|
|
165
|
-
openApi.components?.schemas ?? {},
|
|
166
|
-
)) {
|
|
167
|
-
registry[componentWireSchemaKey(rawName)] = wireSchemaDescriptor(
|
|
168
|
-
openApi,
|
|
169
|
-
schema,
|
|
170
|
-
);
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
for (const operationInfo of operations) {
|
|
174
|
-
const operationId = operationInfo.operationId;
|
|
175
|
-
const requestBody = getRequestBodyContent(
|
|
176
|
-
openApi,
|
|
177
|
-
operationInfo.operation.requestBody,
|
|
178
|
-
);
|
|
179
|
-
const requestSchema = requestBody?.mediaType?.schema;
|
|
180
|
-
if (requestSchema) {
|
|
181
|
-
registry[operationWireSchemaKey(operationId, "body")] =
|
|
182
|
-
wireSchemaDescriptor(openApi, requestSchema);
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
const successResponse = getSuccessResponse(
|
|
186
|
-
openApi,
|
|
187
|
-
operationInfo.operation,
|
|
188
|
-
options.defaultResponseAsSuccess,
|
|
189
|
-
);
|
|
190
|
-
const responseSchema = getResponseContent(successResponse?.response)
|
|
191
|
-
?.mediaType?.schema;
|
|
192
|
-
if (responseSchema) {
|
|
193
|
-
registry[operationWireSchemaKey(operationId, "response")] =
|
|
194
|
-
wireSchemaDescriptor(openApi, responseSchema);
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
const errorSchemas = getErrorResponses(openApi, operationInfo.operation)
|
|
198
|
-
.map(({ response }) => getResponseContent(response)?.mediaType?.schema)
|
|
199
|
-
.filter(Boolean)
|
|
200
|
-
.map((schema) => wireSchemaDescriptor(openApi, schema));
|
|
201
|
-
if (errorSchemas.length > 0) {
|
|
202
|
-
registry[operationWireSchemaKey(operationId, "error")] =
|
|
203
|
-
errorSchemas.length === 1
|
|
204
|
-
? errorSchemas[0]
|
|
205
|
-
: { kind: "union", schemas: errorSchemas };
|
|
206
|
-
}
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
return registry;
|
|
210
|
-
}
|
|
211
73
|
|
|
212
74
|
export class TypeResolver {
|
|
213
75
|
constructor(openApi, options = {}) {
|
|
@@ -578,10 +440,6 @@ export function getOperationTypes(
|
|
|
578
440
|
.filter(Boolean);
|
|
579
441
|
const usesHttpErrorFallback = errorTypes.length === 0;
|
|
580
442
|
const errorType = unionTypes(errorTypes, "ApiHttpError");
|
|
581
|
-
const responseSchema = responseContent?.mediaType?.schema;
|
|
582
|
-
const errorSchemas = errorResponses
|
|
583
|
-
.map(({ response }) => getResponseContent(response)?.mediaType?.schema)
|
|
584
|
-
.filter(Boolean);
|
|
585
443
|
|
|
586
444
|
const hasNonBodyInput = parameters.length > 0;
|
|
587
445
|
const paginated =
|
|
@@ -618,19 +476,9 @@ export function getOperationTypes(
|
|
|
618
476
|
),
|
|
619
477
|
bodyType,
|
|
620
478
|
bodyRequired: Boolean(requestBodyContent?.requestBody?.required),
|
|
621
|
-
bodyWireSchemaKey: requestBodySchema
|
|
622
|
-
? operationWireSchemaKey(operationId, "body")
|
|
623
|
-
: undefined,
|
|
624
479
|
responseType,
|
|
625
|
-
responseWireSchemaKey: responseSchema
|
|
626
|
-
? operationWireSchemaKey(operationId, "response")
|
|
627
|
-
: undefined,
|
|
628
480
|
errorType,
|
|
629
481
|
usesHttpErrorFallback,
|
|
630
|
-
errorWireSchemaKey:
|
|
631
|
-
errorSchemas.length > 0
|
|
632
|
-
? operationWireSchemaKey(operationId, "error")
|
|
633
|
-
: undefined,
|
|
634
482
|
contentType: requestBodyContent?.contentType,
|
|
635
483
|
responseContentType: responseContent?.contentType,
|
|
636
484
|
hasPathParams: parametersByLocation.path.length > 0,
|
|
@@ -714,10 +562,6 @@ export function generateDataContracts(openApi, operations, options = {}) {
|
|
|
714
562
|
declarations.push(resolver.createDeclaration(name, schema));
|
|
715
563
|
}
|
|
716
564
|
|
|
717
|
-
const wireSchemas = generateWireSchemaRegistry(openApi, operations, options);
|
|
718
|
-
declarations.push(
|
|
719
|
-
`export const typedApiWireSchemas = ${JSON.stringify(wireSchemas, null, 2)} as const;`,
|
|
720
|
-
);
|
|
721
565
|
|
|
722
566
|
return `${generatedFileHeader()}\n\n${declarations.join("\n\n")}\n`;
|
|
723
567
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ApiMethodArguments.js","sourceRoot":"","sources":["../../../src/types/ApiMethodArguments.ts"],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"HttpResponse.js","sourceRoot":"","sources":["../../../src/types/HttpResponse.ts"],"names":[],"mappings":""}
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.extractArgsCallbacksAndParams = extractArgsCallbacksAndParams;
|
|
4
|
-
/**
|
|
5
|
-
* Checks whether a value can be used as a generated wrapper callback.
|
|
6
|
-
*/
|
|
7
|
-
function isCallback(value) {
|
|
8
|
-
return typeof value === "function";
|
|
9
|
-
}
|
|
10
|
-
/**
|
|
11
|
-
* Checks whether a value is the optional request-params object accepted as the final wrapper argument.
|
|
12
|
-
*/
|
|
13
|
-
function isRequestParams(value) {
|
|
14
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
15
|
-
}
|
|
16
|
-
/**
|
|
17
|
-
* Extracts wrapper arguments in this order:
|
|
18
|
-
*
|
|
19
|
-
* 1. Original API arguments
|
|
20
|
-
* 2. Optional success callback
|
|
21
|
-
* 3. Optional error callback
|
|
22
|
-
* 4. Optional request params
|
|
23
|
-
*/
|
|
24
|
-
function extractArgsCallbacksAndParams(argsWithCallbacks) {
|
|
25
|
-
const values = [...argsWithCallbacks];
|
|
26
|
-
let onSuccess;
|
|
27
|
-
let onError;
|
|
28
|
-
let params;
|
|
29
|
-
let lastArgument = values[values.length - 1];
|
|
30
|
-
if (isRequestParams(lastArgument)) {
|
|
31
|
-
params = lastArgument;
|
|
32
|
-
values.pop();
|
|
33
|
-
}
|
|
34
|
-
lastArgument = values[values.length - 1];
|
|
35
|
-
if (isCallback(lastArgument)) {
|
|
36
|
-
onError = lastArgument;
|
|
37
|
-
values.pop();
|
|
38
|
-
}
|
|
39
|
-
lastArgument = values[values.length - 1];
|
|
40
|
-
if (isCallback(lastArgument)) {
|
|
41
|
-
onSuccess = lastArgument;
|
|
42
|
-
values.pop();
|
|
43
|
-
}
|
|
44
|
-
return {
|
|
45
|
-
args: values,
|
|
46
|
-
onSuccess,
|
|
47
|
-
onError,
|
|
48
|
-
params,
|
|
49
|
-
};
|
|
50
|
-
}
|
|
51
|
-
//# sourceMappingURL=extractArgsCallbacksAndParams.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"extractArgsCallbacksAndParams.js","sourceRoot":"","sources":["../../../src/utils/extractArgsCallbacksAndParams.ts"],"names":[],"mappings":";;AA6BA,sEAoDC;A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: true });
|
|
3
|
-
exports.extractArgsToastsAndParams = extractArgsToastsAndParams;
|
|
4
|
-
/**
|
|
5
|
-
* Checks whether a value can be used as a generated wrapper callback.
|
|
6
|
-
*/
|
|
7
|
-
function isCallback(value) {
|
|
8
|
-
return typeof value === "function";
|
|
9
|
-
}
|
|
10
|
-
/**
|
|
11
|
-
* Checks whether a value is the optional request-params object accepted as the final wrapper argument.
|
|
12
|
-
*/
|
|
13
|
-
function isRequestParams(value) {
|
|
14
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
15
|
-
}
|
|
16
|
-
/**
|
|
17
|
-
* Extracts wrapper-only arguments in this order:
|
|
18
|
-
* original API arguments, onSuccess, onError, request params.
|
|
19
|
-
*
|
|
20
|
-
* Kept for backwards compatibility with generated files that used toast-oriented naming.
|
|
21
|
-
*/
|
|
22
|
-
function extractArgsToastsAndParams(argsWithCallbacks) {
|
|
23
|
-
const values = [...argsWithCallbacks];
|
|
24
|
-
let onSuccess;
|
|
25
|
-
let onError;
|
|
26
|
-
let params;
|
|
27
|
-
let lastArgument = values[values.length - 1];
|
|
28
|
-
if (isRequestParams(lastArgument)) {
|
|
29
|
-
params = lastArgument;
|
|
30
|
-
values.pop();
|
|
31
|
-
}
|
|
32
|
-
lastArgument = values[values.length - 1];
|
|
33
|
-
if (isCallback(lastArgument)) {
|
|
34
|
-
onError = lastArgument;
|
|
35
|
-
values.pop();
|
|
36
|
-
}
|
|
37
|
-
lastArgument = values[values.length - 1];
|
|
38
|
-
if (isCallback(lastArgument)) {
|
|
39
|
-
onSuccess = lastArgument;
|
|
40
|
-
values.pop();
|
|
41
|
-
}
|
|
42
|
-
return {
|
|
43
|
-
args: values,
|
|
44
|
-
onSuccess,
|
|
45
|
-
onError,
|
|
46
|
-
params,
|
|
47
|
-
};
|
|
48
|
-
}
|
|
49
|
-
//# sourceMappingURL=extractArgsToastsAndParams.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"extractArgsToastsAnd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|
@@ -1,123 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.toWireValue = toWireValue;
|
|
4
|
-
exports.fromWireValue = fromWireValue;
|
|
5
|
-
function isFile(value) {
|
|
6
|
-
return typeof File !== "undefined" && value instanceof File;
|
|
7
|
-
}
|
|
8
|
-
function isBlob(value) {
|
|
9
|
-
return typeof Blob !== "undefined" && value instanceof Blob;
|
|
10
|
-
}
|
|
11
|
-
function isFormData(value) {
|
|
12
|
-
return typeof FormData !== "undefined" && value instanceof FormData;
|
|
13
|
-
}
|
|
14
|
-
function isMappableObject(value) {
|
|
15
|
-
if (typeof value !== "object" || value === null || Array.isArray(value))
|
|
16
|
-
return false;
|
|
17
|
-
if (value instanceof Date || isFile(value) || isBlob(value) || isFormData(value))
|
|
18
|
-
return false;
|
|
19
|
-
return true;
|
|
20
|
-
}
|
|
21
|
-
function resolveSchema(schema, registry) {
|
|
22
|
-
let current = schema;
|
|
23
|
-
const visited = new Set();
|
|
24
|
-
while (current?.kind === "ref") {
|
|
25
|
-
if (visited.has(current.ref))
|
|
26
|
-
return { kind: "identity" };
|
|
27
|
-
visited.add(current.ref);
|
|
28
|
-
current = registry[current.ref] ?? { kind: "identity" };
|
|
29
|
-
}
|
|
30
|
-
return current;
|
|
31
|
-
}
|
|
32
|
-
function mergeObjectSchemas(schema, registry, visitedRefs = new Set()) {
|
|
33
|
-
if (schema.kind === "ref") {
|
|
34
|
-
if (visitedRefs.has(schema.ref))
|
|
35
|
-
return undefined;
|
|
36
|
-
const nextVisited = new Set(visitedRefs);
|
|
37
|
-
nextVisited.add(schema.ref);
|
|
38
|
-
const resolved = registry[schema.ref];
|
|
39
|
-
return resolved ? mergeObjectSchemas(resolved, registry, nextVisited) : undefined;
|
|
40
|
-
}
|
|
41
|
-
if (schema.kind === "object")
|
|
42
|
-
return schema;
|
|
43
|
-
if (schema.kind !== "allOf" && schema.kind !== "union")
|
|
44
|
-
return undefined;
|
|
45
|
-
const properties = {};
|
|
46
|
-
let additionalProperties;
|
|
47
|
-
let foundObject = false;
|
|
48
|
-
for (const part of schema.schemas) {
|
|
49
|
-
const objectPart = mergeObjectSchemas(part, registry, visitedRefs);
|
|
50
|
-
if (!objectPart)
|
|
51
|
-
continue;
|
|
52
|
-
foundObject = true;
|
|
53
|
-
Object.assign(properties, objectPart.properties ?? {});
|
|
54
|
-
if (objectPart.additionalProperties !== undefined) {
|
|
55
|
-
additionalProperties = objectPart.additionalProperties;
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
return foundObject
|
|
59
|
-
? { kind: "object", properties, ...(additionalProperties !== undefined ? { additionalProperties } : {}) }
|
|
60
|
-
: undefined;
|
|
61
|
-
}
|
|
62
|
-
function mapValue(value, schema, registry, direction, seen) {
|
|
63
|
-
if (value === null || value === undefined || !schema)
|
|
64
|
-
return value;
|
|
65
|
-
const resolved = resolveSchema(schema, registry);
|
|
66
|
-
if (!resolved || resolved.kind === "identity")
|
|
67
|
-
return value;
|
|
68
|
-
if (resolved.kind === "array") {
|
|
69
|
-
if (!Array.isArray(value))
|
|
70
|
-
return value;
|
|
71
|
-
const existing = seen.get(value);
|
|
72
|
-
if (existing)
|
|
73
|
-
return existing;
|
|
74
|
-
const output = [];
|
|
75
|
-
seen.set(value, output);
|
|
76
|
-
for (const item of value) {
|
|
77
|
-
output.push(mapValue(item, resolved.items, registry, direction, seen));
|
|
78
|
-
}
|
|
79
|
-
return output;
|
|
80
|
-
}
|
|
81
|
-
if (resolved.kind === "allOf" || resolved.kind === "union") {
|
|
82
|
-
const merged = mergeObjectSchemas(resolved, registry);
|
|
83
|
-
if (merged)
|
|
84
|
-
return mapValue(value, merged, registry, direction, seen);
|
|
85
|
-
return value;
|
|
86
|
-
}
|
|
87
|
-
if (!isMappableObject(value))
|
|
88
|
-
return value;
|
|
89
|
-
const existing = seen.get(value);
|
|
90
|
-
if (existing)
|
|
91
|
-
return existing;
|
|
92
|
-
const output = {};
|
|
93
|
-
seen.set(value, output);
|
|
94
|
-
const properties = resolved.properties ?? {};
|
|
95
|
-
const byWireName = new Map(Object.entries(properties).map(([localName, property]) => [property.wireName, [localName, property]]));
|
|
96
|
-
for (const [inputName, inputValue] of Object.entries(value)) {
|
|
97
|
-
const propertyEntry = direction === "toWire"
|
|
98
|
-
? properties[inputName]
|
|
99
|
-
? [inputName, properties[inputName]]
|
|
100
|
-
: undefined
|
|
101
|
-
: byWireName.get(inputName);
|
|
102
|
-
if (propertyEntry) {
|
|
103
|
-
const [localName, property] = propertyEntry;
|
|
104
|
-
const outputName = direction === "toWire" ? property.wireName : localName;
|
|
105
|
-
output[outputName] = mapValue(inputValue, property.schema, registry, direction, seen);
|
|
106
|
-
continue;
|
|
107
|
-
}
|
|
108
|
-
const additionalSchema = resolved.additionalProperties === true
|
|
109
|
-
? undefined
|
|
110
|
-
: resolved.additionalProperties;
|
|
111
|
-
output[inputName] = mapValue(inputValue, additionalSchema, registry, direction, seen);
|
|
112
|
-
}
|
|
113
|
-
return output;
|
|
114
|
-
}
|
|
115
|
-
/** Converts generated lower-first member names to their exact OpenAPI wire names. */
|
|
116
|
-
function toWireValue(value, schema, registry = {}) {
|
|
117
|
-
return mapValue(value, schema, registry, "toWire", new WeakMap());
|
|
118
|
-
}
|
|
119
|
-
/** Converts exact OpenAPI wire names to generated lower-first member names. */
|
|
120
|
-
function fromWireValue(value, schema, registry = {}) {
|
|
121
|
-
return mapValue(value, schema, registry, "fromWire", new WeakMap());
|
|
122
|
-
}
|
|
123
|
-
//# sourceMappingURL=wireMapping.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"wireMapping.js","sourceRoot":"","sources":["../../../src/utils/wireMapping.ts"],"names":[],"mappings":";;AA0JA,kCAMC;AAGD,sCAMC;AAnJD,SAAS,MAAM,CAAC,KAAc;IAC5B,OAAO,OAAO,IAAI,KAAK,WAAW,IAAI,KAAK,YAAY,IAAI,CAAC;AAC9D,CAA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AE,QAAQ,CAAC,MAAM,EAAE,QAAQ,EAAE,SAAS,EAAE,IAAI,CAAC,CAAC;YACtF,SAAS;QACX,CAAC;QAED,MAAM,gBAAgB,GAAG,QAAQ,CAAC,oBAAoB,KAAK,IAAI;YAC7D,CAAC,CAAC,SAAS;YACX,CAAC,CAAC,QAAQ,CAAC,oBAAoB,CAAC;QAClC,MAAM,CAAC,SAAS,CAAC,GAAG,QAAQ,CAAC,UAAU,EAAE,gBAAgB,EAAE,QAAQ,EAAE,SAAS,EAAE,IAAI,CAAC,CAAC;IACxF,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,qFAAqF;AACrF,SAAgB,WAAW,CACzB,KAAQ,EACR,MAA8B,EAC9B,WAA+B,EAAE;IAEjC,OAAO,QAAQ,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,IAAI,OAAO,EAAE,CAAC,CAAC;AACpE,CAAC;AAED,+EAA+E;AAC/E,SAAgB,aAAa,CAC3B,KAAQ,EACR,MAA8B,EAC9B,WAA+B,EAAE;IAEjC,OAAO,QAAQ,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,UAAU,EAAE,IAAI,OAAO,EAAE,CAAC,CAAC;AACtE,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ApiMethodArguments.js","sourceRoot":"","sources":["../../../src/types/ApiMethodArguments.ts"],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"HttpResponse.js","sourceRoot":"","sources":["../../../src/types/HttpResponse.ts"],"names":[],"mappings":""}
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Checks whether a value can be used as a generated wrapper callback.
|
|
3
|
-
*/
|
|
4
|
-
function isCallback(value) {
|
|
5
|
-
return typeof value === "function";
|
|
6
|
-
}
|
|
7
|
-
/**
|
|
8
|
-
* Checks whether a value is the optional request-params object accepted as the final wrapper argument.
|
|
9
|
-
*/
|
|
10
|
-
function isRequestParams(value) {
|
|
11
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
12
|
-
}
|
|
13
|
-
/**
|
|
14
|
-
* Extracts wrapper arguments in this order:
|
|
15
|
-
*
|
|
16
|
-
* 1. Original API arguments
|
|
17
|
-
* 2. Optional success callback
|
|
18
|
-
* 3. Optional error callback
|
|
19
|
-
* 4. Optional request params
|
|
20
|
-
*/
|
|
21
|
-
export function extractArgsCallbacksAndParams(argsWithCallbacks) {
|
|
22
|
-
const values = [...argsWithCallbacks];
|
|
23
|
-
let onSuccess;
|
|
24
|
-
let onError;
|
|
25
|
-
let params;
|
|
26
|
-
let lastArgument = values[values.length - 1];
|
|
27
|
-
if (isRequestParams(lastArgument)) {
|
|
28
|
-
params = lastArgument;
|
|
29
|
-
values.pop();
|
|
30
|
-
}
|
|
31
|
-
lastArgument = values[values.length - 1];
|
|
32
|
-
if (isCallback(lastArgument)) {
|
|
33
|
-
onError = lastArgument;
|
|
34
|
-
values.pop();
|
|
35
|
-
}
|
|
36
|
-
lastArgument = values[values.length - 1];
|
|
37
|
-
if (isCallback(lastArgument)) {
|
|
38
|
-
onSuccess = lastArgument;
|
|
39
|
-
values.pop();
|
|
40
|
-
}
|
|
41
|
-
return {
|
|
42
|
-
args: values,
|
|
43
|
-
onSuccess,
|
|
44
|
-
onError,
|
|
45
|
-
params,
|
|
46
|
-
};
|
|
47
|
-
}
|
|
48
|
-
//# sourceMappingURL=extractArgsCallbacksAndParams.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"extractArgsCallbacksAndParams.js","sourceRoot":"","sources":["../../../src/utils/extractArgsCallbacksAndParams.ts"],"names":[],"mappings":"AAOA;;GAEG;AACH,SAAS,UAAU,CAAC,KAAc;IAChC,OAAO,OAAO,KAAK,KAAK,UAAU,CAAC;AACrC,CAAC;AAED;;GAEG;AACH,SAAS,eAAe,CAAC,KAAc;IACrC,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AAC9E,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,6BAA6B,CAO3C,iBAKC;IAOD,MAAM,MAAM,GAAG,CAAC,GAAG,iBAAiB,CAAc,CAAC;IAEnD,IAAI,SAAmD,CAAC;IACxD,IAAI,OAA+C,CAAC;IACpD,IAAI,MAAwC,CAAC;IAE7C,IAAI,YAAY,GAAG,MAAM,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;IAE7C,IAAI,eAAe,CAAC,YAAY,CAAC,EAAE,CAAC;QAClC,MAAM,GAAG,YAAY,CAAC;QACtB,MAAM,CAAC,GAAG,EAAE,CAAC;IACf,CAAC;IAED,YAAY,GAAG,MAAM,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;IAEzC,IAAI,UAAU,CAAC,YAAY,CAAC,EAAE,CAAC;QAC7B,OAAO,GAAG,YAA0C,CAAC;QACrD,MAAM,CAAC,GAAG,EAAE,CAAC;IACf,CAAC;IAED,YAAY,GAAG,MAAM,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;IAEzC,IAAI,UAAU,CAAC,YAAY,CAAC,EAAE,CAAC;QAC7B,SAAS,GAAG,YAA4C,CAAC;QACzD,MAAM,CAAC,GAAG,EAAE,CAAC;IACf,CAAC;IAED,OAAO;QACL,IAAI,EAAE,MAAe;QACrB,SAAS;QACT,OAAO;QACP,MAAM;KACP,CAAC;AACJ,CAAC"}
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Checks whether a value can be used as a generated wrapper callback.
|
|
3
|
-
*/
|
|
4
|
-
function isCallback(value) {
|
|
5
|
-
return typeof value === "function";
|
|
6
|
-
}
|
|
7
|
-
/**
|
|
8
|
-
* Checks whether a value is the optional request-params object accepted as the final wrapper argument.
|
|
9
|
-
*/
|
|
10
|
-
function isRequestParams(value) {
|
|
11
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
12
|
-
}
|
|
13
|
-
/**
|
|
14
|
-
* Extracts wrapper-only arguments in this order:
|
|
15
|
-
* original API arguments, onSuccess, onError, request params.
|
|
16
|
-
*
|
|
17
|
-
* Kept for backwards compatibility with generated files that used toast-oriented naming.
|
|
18
|
-
*/
|
|
19
|
-
export function extractArgsToastsAndParams(argsWithCallbacks) {
|
|
20
|
-
const values = [...argsWithCallbacks];
|
|
21
|
-
let onSuccess;
|
|
22
|
-
let onError;
|
|
23
|
-
let params;
|
|
24
|
-
let lastArgument = values[values.length - 1];
|
|
25
|
-
if (isRequestParams(lastArgument)) {
|
|
26
|
-
params = lastArgument;
|
|
27
|
-
values.pop();
|
|
28
|
-
}
|
|
29
|
-
lastArgument = values[values.length - 1];
|
|
30
|
-
if (isCallback(lastArgument)) {
|
|
31
|
-
onError = lastArgument;
|
|
32
|
-
values.pop();
|
|
33
|
-
}
|
|
34
|
-
lastArgument = values[values.length - 1];
|
|
35
|
-
if (isCallback(lastArgument)) {
|
|
36
|
-
onSuccess = lastArgument;
|
|
37
|
-
values.pop();
|
|
38
|
-
}
|
|
39
|
-
return {
|
|
40
|
-
args: values,
|
|
41
|
-
onSuccess,
|
|
42
|
-
onError,
|
|
43
|
-
params,
|
|
44
|
-
};
|
|
45
|
-
}
|
|
46
|
-
//# sourceMappingURL=extractArgsToastsAndParams.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"extractArgsToastsAndParams.js","sourceRoot":"","sources":["../../../src/utils/extractArgsToastsAndParams.ts"],"names":[],"mappings":"AAMA;;GAEG;AACH,SAAS,UAAU,CAAC,KAAc;IAChC,OAAO,OAAO,KAAK,KAAK,UAAU,CAAC;AACrC,CAAC;AAED;;GAEG;AACH,SAAS,eAAe,CAAC,KAAc;IACrC,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK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