imean-service-engine 1.2.1 → 1.2.2
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/dist/mod.cjs +14 -8
- package/dist/mod.js +14 -8
- package/package.json +1 -1
package/dist/mod.cjs
CHANGED
@@ -284,6 +284,9 @@ function getZodTypeString(schema, defaultOptional = false) {
|
|
284
284
|
case "ZodObject": {
|
285
285
|
const shape = def.shape();
|
286
286
|
const props = Object.entries(shape).map(([key, value]) => {
|
287
|
+
if (key.includes("-")) {
|
288
|
+
key = `'${key}'`;
|
289
|
+
}
|
287
290
|
const fieldDef = value._def;
|
288
291
|
const isOptional = fieldDef.typeName === "ZodOptional";
|
289
292
|
const isDefault = defaultOptional && fieldDef.typeName === "ZodDefault";
|
@@ -310,10 +313,14 @@ function getZodTypeString(schema, defaultOptional = false) {
|
|
310
313
|
return "void";
|
311
314
|
}
|
312
315
|
case "ZodRecord": {
|
313
|
-
return `Record<${processType(def.keyType)}, ${processType(
|
316
|
+
return `Record<${processType(def.keyType)}, ${processType(
|
317
|
+
def.valueType
|
318
|
+
)}>`;
|
314
319
|
}
|
315
320
|
case "ZodMap": {
|
316
|
-
return `Map<${processType(def.keyType)}, ${processType(
|
321
|
+
return `Map<${processType(def.keyType)}, ${processType(
|
322
|
+
def.valueType
|
323
|
+
)}>`;
|
317
324
|
}
|
318
325
|
case "ZodAny": {
|
319
326
|
return "any";
|
@@ -354,7 +361,10 @@ async function generateClientCode(modules) {
|
|
354
361
|
}
|
355
362
|
const params = action.params.map((param, index) => {
|
356
363
|
const name2 = param.description || `arg${index}`;
|
357
|
-
return `${name2}${param.isOptional() ? "?" : ""}: ${getZodTypeString(
|
364
|
+
return `${name2}${param.isOptional() ? "?" : ""}: ${getZodTypeString(
|
365
|
+
param,
|
366
|
+
true
|
367
|
+
)}`;
|
358
368
|
}).join(", ");
|
359
369
|
const returnType = action.returns ? getZodTypeString(action.returns) : "void";
|
360
370
|
return `
|
@@ -378,11 +388,7 @@ async function generateClientCode(modules) {
|
|
378
388
|
});`;
|
379
389
|
}).join("\n\n ")}
|
380
390
|
}`;
|
381
|
-
return await formatCode([
|
382
|
-
imports,
|
383
|
-
interfaces,
|
384
|
-
clientClass
|
385
|
-
].join("\n\n"));
|
391
|
+
return await formatCode([imports, interfaces, clientClass].join("\n\n"));
|
386
392
|
}
|
387
393
|
function hashText(text) {
|
388
394
|
const hash = crypto2__default.default.createHash("sha256");
|
package/dist/mod.js
CHANGED
@@ -275,6 +275,9 @@ function getZodTypeString(schema, defaultOptional = false) {
|
|
275
275
|
case "ZodObject": {
|
276
276
|
const shape = def.shape();
|
277
277
|
const props = Object.entries(shape).map(([key, value]) => {
|
278
|
+
if (key.includes("-")) {
|
279
|
+
key = `'${key}'`;
|
280
|
+
}
|
278
281
|
const fieldDef = value._def;
|
279
282
|
const isOptional = fieldDef.typeName === "ZodOptional";
|
280
283
|
const isDefault = defaultOptional && fieldDef.typeName === "ZodDefault";
|
@@ -301,10 +304,14 @@ function getZodTypeString(schema, defaultOptional = false) {
|
|
301
304
|
return "void";
|
302
305
|
}
|
303
306
|
case "ZodRecord": {
|
304
|
-
return `Record<${processType(def.keyType)}, ${processType(
|
307
|
+
return `Record<${processType(def.keyType)}, ${processType(
|
308
|
+
def.valueType
|
309
|
+
)}>`;
|
305
310
|
}
|
306
311
|
case "ZodMap": {
|
307
|
-
return `Map<${processType(def.keyType)}, ${processType(
|
312
|
+
return `Map<${processType(def.keyType)}, ${processType(
|
313
|
+
def.valueType
|
314
|
+
)}>`;
|
308
315
|
}
|
309
316
|
case "ZodAny": {
|
310
317
|
return "any";
|
@@ -345,7 +352,10 @@ async function generateClientCode(modules) {
|
|
345
352
|
}
|
346
353
|
const params = action.params.map((param, index) => {
|
347
354
|
const name2 = param.description || `arg${index}`;
|
348
|
-
return `${name2}${param.isOptional() ? "?" : ""}: ${getZodTypeString(
|
355
|
+
return `${name2}${param.isOptional() ? "?" : ""}: ${getZodTypeString(
|
356
|
+
param,
|
357
|
+
true
|
358
|
+
)}`;
|
349
359
|
}).join(", ");
|
350
360
|
const returnType = action.returns ? getZodTypeString(action.returns) : "void";
|
351
361
|
return `
|
@@ -369,11 +379,7 @@ async function generateClientCode(modules) {
|
|
369
379
|
});`;
|
370
380
|
}).join("\n\n ")}
|
371
381
|
}`;
|
372
|
-
return await formatCode([
|
373
|
-
imports,
|
374
|
-
interfaces,
|
375
|
-
clientClass
|
376
|
-
].join("\n\n"));
|
382
|
+
return await formatCode([imports, interfaces, clientClass].join("\n\n"));
|
377
383
|
}
|
378
384
|
function hashText(text) {
|
379
385
|
const hash = crypto2.createHash("sha256");
|