api-core-lib 12.0.82 → 12.0.84

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 +36 -9
  2. package/package.json +1 -1
package/dist/cli.cjs CHANGED
@@ -141,17 +141,22 @@ ${shape}
141
141
  return zodChain;
142
142
  }
143
143
 
144
- // src/generator/index.ts
145
- var DEBUG_MODE = process.env.DEBUG === "true";
146
- var debugLog = (title, data) => DEBUG_MODE && console.log(import_chalk.default.yellow(`
147
- [DEBUG: ${title}]`), import_util.default.inspect(data, { depth: 5, colors: true }));
148
- var toPascalCase = (str) => str.replace(/[^a-zA-Z0-9_]/g, " ").replace(/(?:^\w|[A-Z]|\b\w)/g, (w) => w.toUpperCase()).replace(/\s+/g, "");
144
+ // src/generator/utils/index.ts
145
+ var getActionName = (opId) => {
146
+ const cleanOpId = opId.replace(/_v\d+$/, "");
147
+ const parts = cleanOpId.split("_");
148
+ if (parts.length > 1) {
149
+ const actionPart = parts.slice(1).join("_");
150
+ return toCamelCase(actionPart);
151
+ }
152
+ return toCamelCase(cleanOpId);
153
+ };
149
154
  var toCamelCase = (str) => {
150
155
  const s = toPascalCase(str);
151
156
  return s.charAt(0).toLowerCase() + s.slice(1);
152
157
  };
158
+ var toPascalCase = (str) => str.replace(/[^a-zA-Z0-9_]/g, " ").replace(/(?:^\w|[A-Z]|\b\w)/g, (w) => w.toUpperCase()).replace(/\s+/g, "");
153
159
  var sanitizeForModuleName = (tagName) => `${toPascalCase(tagName.replace(/[^a-zA-Z0-9]/g, " "))}Api`;
154
- var getActionName = (opId) => toCamelCase(opId.replace(/^(central|tenant)/i, "").replace(/_v\d+$/, ""));
155
160
  var findCommonPath = (paths) => {
156
161
  if (!paths || paths.length === 0) return "/";
157
162
  const sorted = [...paths].sort();
@@ -162,6 +167,11 @@ var findCommonPath = (paths) => {
162
167
  const prefix = first.substring(0, i);
163
168
  return prefix.substring(0, prefix.lastIndexOf("/") + 1) || "/";
164
169
  };
170
+
171
+ // src/generator/index.ts
172
+ var DEBUG_MODE = process.env.DEBUG === "true";
173
+ var debugLog = (title, data) => DEBUG_MODE && console.log(import_chalk.default.yellow(`
174
+ [DEBUG: ${title}]`), import_util.default.inspect(data, { depth: 5, colors: true }));
165
175
  function parseSchema(name, schema, allEnums) {
166
176
  const properties = [];
167
177
  const enums = {};
@@ -299,7 +309,22 @@ async function generateModuleFiles(module2, allSchemas, allEnums, outputDir) {
299
309
  if (!import_fs.default.existsSync(moduleOutputPath)) import_fs.default.mkdirSync(moduleOutputPath, { recursive: true });
300
310
  console.log(import_chalk.default.cyan(`
301
311
  Generating module: ${import_chalk.default.bold(module2.moduleName)}`));
302
- const schemasToImport = [...module2.schemas].sort();
312
+ const BUILT_IN_TYPES = /* @__PURE__ */ new Set([
313
+ "string",
314
+ "number",
315
+ "boolean",
316
+ "void",
317
+ "undefined",
318
+ "unknown",
319
+ "any",
320
+ "Date",
321
+ "Promise",
322
+ "QueryOptions",
323
+ "Record<string, any>",
324
+ "Record<string, unknown>"
325
+ ]);
326
+ const allCustomSchemaNames = [...module2.schemas].sort();
327
+ const schemasToImport = allCustomSchemaNames.filter((name) => !BUILT_IN_TYPES.has(name));
303
328
  const enumsToImport = [...module2.enums].sort();
304
329
  const indexContent = [`// This file is auto-generated. Do not edit directly.
305
330
 
@@ -308,8 +333,10 @@ export * from './config';`];
308
333
 
309
334
  import type { ApiModuleConfig, ActionConfigModule } from 'api-core-lib';
310
335
  `;
311
- if (schemasToImport.length > 0) configContent += `import type { ${schemasToImport.join(", ")} } from './types';
336
+ if (schemasToImport.length > 0) {
337
+ configContent += `import type { ${schemasToImport.join(", ")} } from './types';
312
338
  `;
339
+ }
313
340
  const actionsType = Object.values(module2.actions).map((a) => ` ${a.name}: ActionConfigModule<${a.inputType}, ${a.outputType}>;`).join("\n");
314
341
  const actionsValue = Object.values(module2.actions).map((a) => {
315
342
  const { inputType, outputType, name, ...c } = a;
@@ -327,7 +354,7 @@ ${actionsValue}
327
354
  `;
328
355
  import_fs.default.writeFileSync(import_path.default.join(moduleOutputPath, "config.ts"), configContent.trim());
329
356
  console.log(import_chalk.default.gray(` \u2713 config.ts`));
330
- if (schemasToImport.length > 0) {
357
+ if (allCustomSchemaNames.length > 0) {
331
358
  if (enumsToImport.length > 0) {
332
359
  let enumsContent = `// This file is auto-generated. Do not edit directly.
333
360
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "api-core-lib",
3
- "version": "12.0.82",
3
+ "version": "12.0.84",
4
4
  "description": "A flexible and powerful API client library for modern web applications.",
5
5
  "type": "module",
6
6
  "exports": {