api-core-lib 12.0.81 → 12.0.82

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.
Files changed (2) hide show
  1. package/dist/cli.cjs +24 -3
  2. package/package.json +1 -1
package/dist/cli.cjs CHANGED
@@ -212,6 +212,21 @@ function parseSpecToModules(spec) {
212
212
  const allSchemas = /* @__PURE__ */ new Map();
213
213
  const allEnums = /* @__PURE__ */ new Map();
214
214
  const modulePaths = /* @__PURE__ */ new Map();
215
+ const BUILT_IN_TYPES = /* @__PURE__ */ new Set([
216
+ "string",
217
+ "number",
218
+ "boolean",
219
+ "void",
220
+ "undefined",
221
+ "unknown",
222
+ "any",
223
+ "Date",
224
+ "Promise",
225
+ "QueryOptions",
226
+ "Record<string, any>",
227
+ "Record<string, unknown>"
228
+ // <-- Add our fallback type here
229
+ ]);
215
230
  const registerSchema = (schema, baseName) => {
216
231
  if (!schema) return "Record<string, any>";
217
232
  if (schema.type === "array" && schema.items) {
@@ -224,6 +239,9 @@ function parseSpecToModules(spec) {
224
239
  return `${primitiveType}[]`;
225
240
  }
226
241
  if (schema.type === "object" || schema.properties || schema.allOf || !schema.type) {
242
+ if (!schema.properties && !schema.allOf) {
243
+ return "Record<string, any>";
244
+ }
227
245
  const typeName = toPascalCase(baseName.replace(/_v\d+(Request|Response)$/, "$1"));
228
246
  if (!allSchemas.has(typeName)) {
229
247
  allSchemas.set(typeName, parseSchema(typeName, schema, allEnums));
@@ -252,11 +270,14 @@ function parseSpecToModules(spec) {
252
270
  const outputType = successKey === "204" ? "void" : registerSchema(successRes?.content?.["application/json"]?.schema, `${endpoint.operationId}Response`);
253
271
  const reqBody = endpoint.requestBody;
254
272
  let inputType = "undefined";
255
- if (reqBody?.content?.["application/json"]?.schema) inputType = registerSchema(reqBody.content["application/json"].schema, `${endpoint.operationId}Request`);
256
- else if ((endpoint.parameters || []).some((p) => p.in === "query")) inputType = "QueryOptions";
273
+ if (reqBody?.content?.["application/json"]?.schema) {
274
+ inputType = registerSchema(reqBody.content["application/json"].schema, `${endpoint.operationId}Request`);
275
+ } else if ((endpoint.parameters || []).some((p) => p.in === "query")) {
276
+ inputType = "QueryOptions";
277
+ }
257
278
  [inputType, outputType].forEach((t) => {
258
279
  const cleanType = t.replace("[]", "");
259
- if (cleanType && !["unknown", "undefined", "void", "any", "QueryOptions", "Promise"].includes(cleanType)) {
280
+ if (cleanType && !BUILT_IN_TYPES.has(cleanType)) {
260
281
  currentModule.schemas.add(cleanType);
261
282
  const schemaDef = allSchemas.get(cleanType);
262
283
  if (schemaDef) Object.keys(schemaDef.enums).forEach((propName) => currentModule.enums.add(`${toPascalCase(cleanType)}${toPascalCase(propName)}Enum`));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "api-core-lib",
3
- "version": "12.0.81",
3
+ "version": "12.0.82",
4
4
  "description": "A flexible and powerful API client library for modern web applications.",
5
5
  "type": "module",
6
6
  "exports": {