api-core-lib 12.12.106 → 12.12.107

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 -21
  2. package/package.json +1 -1
package/dist/cli.cjs CHANGED
@@ -92,22 +92,7 @@ var toCamelCase = (str) => {
92
92
  };
93
93
  var toPascalCase = (str) => str.replace(/[^a-zA-Z0-9_]/g, " ").replace(/(?:^\w|[A-Z]|\b\w)/g, (w) => w.toUpperCase()).replace(/\s+/g, "");
94
94
 
95
- // src/generator/v1.ts
96
- var DEBUG_MODE = process.env.DEBUG === "true";
97
- var debugLog = (title, data) => DEBUG_MODE && console.log(import_chalk.default.yellow(`
98
- [DEBUG: ${title}]`), import_util.default.inspect(data, { depth: 5, colors: true }));
99
- var toCamelCase2 = (str) => str.replace(/[-_\s]+(.)?/g, (_, c) => c ? c.toUpperCase() : "").replace(/^(.)/, (c) => c.toLowerCase());
100
- var toPascalCase2 = (str) => str.replace(/(?:^|[-_\s])(\w)/g, (_, c) => c.toUpperCase());
101
- var sanitizeForModuleName = (name) => toPascalCase2(name.replace(/api/gi, "").replace(/[^a-zA-Z0-9\s-]/g, ""));
102
- function findCommonPath(paths) {
103
- if (!paths || paths.length === 0) return "/";
104
- const sortedPaths = paths.sort();
105
- const first = sortedPaths[0].split("/");
106
- const last = sortedPaths[sortedPaths.length - 1].split("/");
107
- let i = 0;
108
- while (i < first.length && first[i] === last[i]) i++;
109
- return first.slice(0, i).join("/") || "/";
110
- }
95
+ // src/generator/core/_propToZod.ts
111
96
  function _propToZod(prop) {
112
97
  let zodChain;
113
98
  const getMsg = (key) => `{ "message": "validation.${key}" }`;
@@ -117,17 +102,24 @@ function _propToZod(prop) {
117
102
  zodChain = `z.enum(${prop.enumName})`;
118
103
  } else {
119
104
  zodChain = "z.string()";
120
- if (prop.isRequired) zodChain += `.min(1, ${getMsg("string.nonempty")})`;
105
+ if (prop.isRequired) {
106
+ zodChain += `.min(1, ${getMsg("string.nonempty")})`;
107
+ }
121
108
  if (prop.maxLength !== void 0) zodChain += `.max(${prop.maxLength}, ${getMsg("string.max")})`;
122
109
  if (prop.pattern) zodChain += `.regex(/${prop.pattern}/, ${getMsg("string.regex")})`;
123
110
  if (prop.format === "email") zodChain += `.email(${getMsg("string.email")})`;
124
111
  if (prop.format === "url") zodChain += `.url(${getMsg("string.url")})`;
125
112
  if (prop.format === "uuid") zodChain += `.uuid(${getMsg("string.uuid")})`;
113
+ if (prop.format === "datetime") zodChain += `.datetime(${getMsg("string.datetime")})`;
126
114
  }
127
115
  break;
128
116
  case "integer":
117
+ zodChain = `z.number().int(${getMsg("number.integer")})`;
118
+ if (prop.minimum !== void 0) zodChain += `.min(${prop.minimum}, ${getMsg("number.min")})`;
119
+ if (prop.maximum !== void 0) zodChain += `.max(${prop.maximum}, ${getMsg("number.max")})`;
120
+ break;
129
121
  case "number":
130
- zodChain = prop.type === "integer" ? `z.number().int(${getMsg("number.integer")})` : "z.number()";
122
+ zodChain = `z.number()`;
131
123
  if (prop.minimum !== void 0) zodChain += `.min(${prop.minimum}, ${getMsg("number.min")})`;
132
124
  if (prop.maximum !== void 0) zodChain += `.max(${prop.maximum}, ${getMsg("number.max")})`;
133
125
  break;
@@ -154,11 +146,34 @@ ${shape}
154
146
  zodChain = "z.any()";
155
147
  break;
156
148
  }
157
- if (prop.description) zodChain += `.describe(${JSON.stringify(prop.description)})`;
158
- if (!prop.isRequired) zodChain += ".optional()";
159
- if (prop.isNullable) zodChain += ".nullable()";
149
+ if (prop.description) {
150
+ zodChain += `.describe(${JSON.stringify(prop.description)})`;
151
+ }
152
+ if (!prop.isRequired) {
153
+ zodChain += ".optional()";
154
+ }
155
+ if (prop.isNullable) {
156
+ zodChain += ".nullable()";
157
+ }
160
158
  return zodChain;
161
159
  }
160
+
161
+ // src/generator/v1.ts
162
+ var DEBUG_MODE = process.env.DEBUG === "true";
163
+ var debugLog = (title, data) => DEBUG_MODE && console.log(import_chalk.default.yellow(`
164
+ [DEBUG: ${title}]`), import_util.default.inspect(data, { depth: 5, colors: true }));
165
+ var toCamelCase2 = (str) => str.replace(/[-_\s]+(.)?/g, (_, c) => c ? c.toUpperCase() : "").replace(/^(.)/, (c) => c.toLowerCase());
166
+ var toPascalCase2 = (str) => str.replace(/(?:^|[-_\s])(\w)/g, (_, c) => c.toUpperCase());
167
+ var sanitizeForModuleName = (name) => toPascalCase2(name.replace(/api/gi, "").replace(/[^a-zA-Z0-9\s-]/g, ""));
168
+ function findCommonPath(paths) {
169
+ if (!paths || paths.length === 0) return "/";
170
+ const sortedPaths = paths.sort();
171
+ const first = sortedPaths[0].split("/");
172
+ const last = sortedPaths[sortedPaths.length - 1].split("/");
173
+ let i = 0;
174
+ while (i < first.length && first[i] === last[i]) i++;
175
+ return first.slice(0, i).join("/") || "/";
176
+ }
162
177
  function _propToMock(prop) {
163
178
  if (prop.example) return prop.example;
164
179
  if (prop.name.match(/image|avatar|logo|url/i)) return "https://via.placeholder.com/150";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "api-core-lib",
3
- "version": "12.12.106",
3
+ "version": "12.12.107",
4
4
  "description": "A flexible and powerful API client library for modern web applications.",
5
5
  "type": "module",
6
6
  "exports": {