@reboot-dev/reboot 0.41.0 → 0.43.0
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/package.json +2 -2
- package/reboot_native.cc +492 -665
- package/version.d.ts +1 -1
- package/version.js +1 -1
- package/zod-to-proto.js +35 -35
package/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const REBOOT_VERSION = "0.
|
|
1
|
+
export declare const REBOOT_VERSION = "0.43.0";
|
package/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const REBOOT_VERSION = "0.
|
|
1
|
+
export const REBOOT_VERSION = "0.43.0";
|
package/zod-to-proto.js
CHANGED
|
@@ -262,85 +262,85 @@ const generate = (proto, { schema, path, name, state = false, }) => {
|
|
|
262
262
|
proto.write(`map <string, ${typeName}> record = 1;`);
|
|
263
263
|
}
|
|
264
264
|
else if (schema instanceof z.ZodArray) {
|
|
265
|
-
const
|
|
266
|
-
if (
|
|
267
|
-
console.error(chalk.stderr.bold.red(`Array at '${path}' has _optional_
|
|
265
|
+
const item = schema.element;
|
|
266
|
+
if (item instanceof z.ZodOptional) {
|
|
267
|
+
console.error(chalk.stderr.bold.red(`Array at '${path}' has _optional_ item type which is not supported`));
|
|
268
268
|
process.exit(-1);
|
|
269
269
|
}
|
|
270
|
-
else if (
|
|
271
|
-
console.error(chalk.stderr.bold.red(`Array at '${path}' has _default_
|
|
270
|
+
else if (item instanceof z.ZodDefault) {
|
|
271
|
+
console.error(chalk.stderr.bold.red(`Array at '${path}' has _default_ item type which is not supported`));
|
|
272
272
|
process.exit(-1);
|
|
273
273
|
}
|
|
274
274
|
const typeName = (() => {
|
|
275
275
|
// To account for all possible "string" types in Zod, e.g.,
|
|
276
276
|
// `z.uuid()`, `z.email()`, etc, we can't use `instanceof`.
|
|
277
|
-
if (
|
|
277
|
+
if (item._zod.def.type === "string") {
|
|
278
278
|
return "string";
|
|
279
279
|
}
|
|
280
|
-
else if (
|
|
280
|
+
else if (item instanceof z.ZodNumber) {
|
|
281
281
|
return "double";
|
|
282
282
|
}
|
|
283
|
-
else if (
|
|
283
|
+
else if (item instanceof z.ZodBigInt) {
|
|
284
284
|
return "int64";
|
|
285
285
|
}
|
|
286
|
-
else if (
|
|
286
|
+
else if (item instanceof z.ZodBoolean) {
|
|
287
287
|
return "bool";
|
|
288
288
|
}
|
|
289
|
-
else if (
|
|
290
|
-
return "
|
|
289
|
+
else if (item instanceof z.ZodObject) {
|
|
290
|
+
return "Item";
|
|
291
291
|
}
|
|
292
|
-
else if (
|
|
293
|
-
return "
|
|
292
|
+
else if (item instanceof z.ZodRecord) {
|
|
293
|
+
return "Item";
|
|
294
294
|
}
|
|
295
|
-
else if (
|
|
296
|
-
return "
|
|
295
|
+
else if (item instanceof z.ZodArray) {
|
|
296
|
+
return "Item";
|
|
297
297
|
}
|
|
298
|
-
else if (
|
|
299
|
-
return "
|
|
298
|
+
else if (item instanceof z.ZodDiscriminatedUnion) {
|
|
299
|
+
return "Item";
|
|
300
300
|
}
|
|
301
|
-
else if (
|
|
302
|
-
const meta =
|
|
303
|
-
if (
|
|
301
|
+
else if (item instanceof z.ZodCustom) {
|
|
302
|
+
const meta = item.meta();
|
|
303
|
+
if (item instanceof z.ZodCustom && "protobuf" in meta) {
|
|
304
304
|
return meta.protobuf;
|
|
305
305
|
}
|
|
306
306
|
}
|
|
307
|
-
else if (iszjson(
|
|
307
|
+
else if (iszjson(item)) {
|
|
308
308
|
return "google.protobuf.Value";
|
|
309
309
|
}
|
|
310
|
-
console.error(chalk.stderr.bold.red(`Array at '${path}' has
|
|
310
|
+
console.error(chalk.stderr.bold.red(`Array at '${path}' has item type '${item._zod.def.type}' which is not (yet) supported`));
|
|
311
311
|
process.exit(-1);
|
|
312
312
|
})();
|
|
313
|
-
if (
|
|
313
|
+
if (item instanceof z.ZodObject) {
|
|
314
314
|
generate(proto, {
|
|
315
|
-
schema:
|
|
316
|
-
path: `${path}.[
|
|
315
|
+
schema: item,
|
|
316
|
+
path: `${path}.[item]`,
|
|
317
317
|
name: typeName,
|
|
318
318
|
});
|
|
319
319
|
}
|
|
320
|
-
else if (
|
|
320
|
+
else if (item instanceof z.ZodRecord) {
|
|
321
321
|
proto.write(`message ${typeName} {`);
|
|
322
322
|
generate(proto, {
|
|
323
|
-
schema:
|
|
324
|
-
path: `${path}.[
|
|
323
|
+
schema: item,
|
|
324
|
+
path: `${path}.[item]`,
|
|
325
325
|
});
|
|
326
326
|
proto.write(`}`);
|
|
327
327
|
}
|
|
328
|
-
else if (
|
|
328
|
+
else if (item instanceof z.ZodArray) {
|
|
329
329
|
proto.write(`message ${typeName} {`);
|
|
330
330
|
generate(proto, {
|
|
331
|
-
schema:
|
|
332
|
-
path: `${path}.[
|
|
331
|
+
schema: item,
|
|
332
|
+
path: `${path}.[item]`,
|
|
333
333
|
});
|
|
334
334
|
proto.write(`}`);
|
|
335
335
|
}
|
|
336
|
-
else if (
|
|
336
|
+
else if (item instanceof z.ZodDiscriminatedUnion) {
|
|
337
337
|
generate(proto, {
|
|
338
|
-
schema:
|
|
339
|
-
path: `${path}.[
|
|
338
|
+
schema: item,
|
|
339
|
+
path: `${path}.[item]`,
|
|
340
340
|
name: typeName,
|
|
341
341
|
});
|
|
342
342
|
}
|
|
343
|
-
proto.write(`repeated ${typeName}
|
|
343
|
+
proto.write(`repeated ${typeName} items = 1;`);
|
|
344
344
|
}
|
|
345
345
|
else if (schema instanceof z.ZodDiscriminatedUnion) {
|
|
346
346
|
assert(name !== undefined);
|