@forklaunch/implementation-worker-database 0.7.3 → 0.8.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.
@@ -28,7 +28,7 @@ module.exports = __toCommonJS(schemas_exports);
28
28
  // domain/schemas/databaseWorker.schema.ts
29
29
  var import_internal = require("@forklaunch/internal");
30
30
 
31
- // ../../../node_modules/.pnpm/@forklaunch+validator@0.10.14/node_modules/@forklaunch/validator/lib/src/typebox/index.mjs
31
+ // ../../../node_modules/.pnpm/@forklaunch+validator@0.10.17/node_modules/@forklaunch/validator/lib/src/typebox/index.mjs
32
32
  var typebox_exports = {};
33
33
  __export(typebox_exports, {
34
34
  SchemaValidator: () => SchemaValidator,
@@ -68,7 +68,79 @@ __export(typebox_exports, {
68
68
  });
69
69
  __reExport(typebox_exports, require("@sinclair/typebox"));
70
70
 
71
- // ../../../node_modules/.pnpm/@forklaunch+common@0.6.14/node_modules/@forklaunch/common/lib/index.mjs
71
+ // ../../../node_modules/.pnpm/@forklaunch+common@0.6.17/node_modules/@forklaunch/common/lib/index.mjs
72
+ function deepCloneWithoutUndefined(obj, seen = /* @__PURE__ */ new WeakMap()) {
73
+ if (obj === null || obj === void 0) {
74
+ return obj;
75
+ }
76
+ if (typeof obj !== "object" && typeof obj !== "function") {
77
+ return obj;
78
+ }
79
+ if (seen.has(obj)) {
80
+ return seen.get(obj);
81
+ }
82
+ if (obj instanceof Date) {
83
+ return new Date(obj.getTime());
84
+ }
85
+ if (obj instanceof RegExp) {
86
+ return new RegExp(obj.source, obj.flags);
87
+ }
88
+ if (obj instanceof Map) {
89
+ const clonedMap = /* @__PURE__ */ new Map();
90
+ seen.set(obj, clonedMap);
91
+ obj.forEach((value, key) => {
92
+ if (value !== void 0) {
93
+ clonedMap.set(key, deepCloneWithoutUndefined(value, seen));
94
+ }
95
+ });
96
+ return clonedMap;
97
+ }
98
+ if (obj instanceof Set) {
99
+ const clonedSet = /* @__PURE__ */ new Set();
100
+ seen.set(obj, clonedSet);
101
+ obj.forEach((value) => {
102
+ if (value !== void 0) {
103
+ clonedSet.add(deepCloneWithoutUndefined(value, seen));
104
+ }
105
+ });
106
+ return clonedSet;
107
+ }
108
+ if (Array.isArray(obj)) {
109
+ const clonedArray = [];
110
+ seen.set(obj, clonedArray);
111
+ for (const item of obj) {
112
+ if (item !== void 0) {
113
+ clonedArray.push(deepCloneWithoutUndefined(item, seen));
114
+ }
115
+ }
116
+ return clonedArray;
117
+ }
118
+ if (typeof obj === "function") {
119
+ return obj;
120
+ }
121
+ const proto = Object.getPrototypeOf(obj);
122
+ const cloned = Object.create(proto);
123
+ seen.set(obj, cloned);
124
+ const allKeys = [
125
+ ...Object.getOwnPropertyNames(obj),
126
+ ...Object.getOwnPropertySymbols(obj)
127
+ ];
128
+ for (const key of allKeys) {
129
+ const descriptor = Object.getOwnPropertyDescriptor(obj, key);
130
+ if (!descriptor) continue;
131
+ if ("value" in descriptor) {
132
+ if (descriptor.value !== void 0) {
133
+ Object.defineProperty(cloned, key, {
134
+ ...descriptor,
135
+ value: deepCloneWithoutUndefined(descriptor.value, seen)
136
+ });
137
+ }
138
+ } else {
139
+ Object.defineProperty(cloned, key, descriptor);
140
+ }
141
+ }
142
+ return cloned;
143
+ }
72
144
  var InMemoryBlob = class extends Blob {
73
145
  constructor(content) {
74
146
  super([content]);
@@ -76,7 +148,7 @@ var InMemoryBlob = class extends Blob {
76
148
  }
77
149
  };
78
150
 
79
- // ../../../node_modules/.pnpm/@forklaunch+validator@0.10.14/node_modules/@forklaunch/validator/lib/src/typebox/index.mjs
151
+ // ../../../node_modules/.pnpm/@forklaunch+validator@0.10.17/node_modules/@forklaunch/validator/lib/src/typebox/index.mjs
80
152
  var import_typebox = require("@sinclair/typebox");
81
153
  var import_compiler = require("@sinclair/typebox/compiler");
82
154
  var import_errors = require("@sinclair/typebox/errors");
@@ -273,14 +345,46 @@ var TypeboxSchemaValidator = class {
273
345
  return "";
274
346
  });
275
347
  file = import_typebox.Type.Transform(
276
- import_typebox.Type.Unsafe({
277
- errorType: "binary",
278
- format: "binary",
279
- example: "a raw buffer or file stream",
280
- title: "File"
281
- })
348
+ import_typebox.Type.Union([
349
+ import_typebox.Type.Unsafe({
350
+ errorType: "binary",
351
+ format: "binary",
352
+ example: "a raw buffer or file stream",
353
+ title: "File"
354
+ }),
355
+ import_typebox.Type.Unsafe({
356
+ errorType: "binary",
357
+ format: "binary",
358
+ example: "an array buffer",
359
+ title: "File"
360
+ }),
361
+ import_typebox.Type.Unsafe({
362
+ errorType: "binary",
363
+ format: "binary",
364
+ example: "a blob object",
365
+ title: "File"
366
+ }),
367
+ import_typebox.Type.String({
368
+ errorType: "binary",
369
+ format: "binary",
370
+ example: "a string content",
371
+ title: "File"
372
+ })
373
+ ])
282
374
  ).Decode((value) => {
283
- return new InMemoryBlob(value);
375
+ if (value instanceof Buffer) {
376
+ return new InMemoryBlob(value);
377
+ }
378
+ if (value instanceof ArrayBuffer) {
379
+ return new InMemoryBlob(Buffer.from(value));
380
+ }
381
+ if (value instanceof Blob) {
382
+ return value;
383
+ }
384
+ if (typeof value === "string") {
385
+ return new InMemoryBlob(Buffer.from(value));
386
+ }
387
+ return new InMemoryBlob(Buffer.from(value));
284
388
  }).Encode((value) => value.content);
285
389
  type = () => this.any;
286
390
  /**
@@ -320,7 +424,7 @@ var TypeboxSchemaValidator = class {
320
424
  }
321
425
  const newSchema = {};
322
426
  Object.getOwnPropertyNames(schema).forEach((key) => {
323
- if (import_typebox.KindGuard.IsSchema(schema[key])) {
427
+ if (import_typebox.KindGuard.IsSchema(schema[key]) || import_typebox.KindGuard.IsTransform(schema[key])) {
324
428
  newSchema[key] = schema[key];
325
429
  } else {
326
430
  const schemified = this.schemify(schema[key]);
@@ -538,20 +642,25 @@ var TypeboxSchemaValidator = class {
538
642
  * @returns {SchemaObject} The OpenAPI schema object.
539
643
  */
540
644
  openapi(schema) {
541
- let schemified = this.schemify(schema);
645
+ const schemified = this.schemify(schema);
646
+ let processedSchema;
542
647
  if (import_typebox.KindGuard.IsDate(schemified)) {
543
- schemified = import_typebox.Type.String({
648
+ processedSchema = import_typebox.Type.String({
544
649
  format: "date-time"
545
650
  });
651
+ } else {
652
+ processedSchema = deepCloneWithoutUndefined(schemified);
546
653
  }
547
- const newSchema = Object.assign({}, schemified);
654
+ const newSchema = Object.assign({}, processedSchema);
548
655
  if (Object.hasOwn(newSchema, "properties")) {
549
656
  if (newSchema.properties) {
550
- Object.entries({ ...schemified.properties }).forEach(([key, value]) => {
551
- if (import_typebox.KindGuard.IsSchema(value) && newSchema.properties) {
552
- newSchema.properties[key] = this.openapi(value);
657
+ Object.entries({ ...processedSchema.properties }).forEach(
658
+ ([key, value]) => {
659
+ if (import_typebox.KindGuard.IsSchema(value) && newSchema.properties) {
660
+ newSchema.properties[key] = this.openapi(value);
661
+ }
553
662
  }
554
- });
663
+ );
555
664
  }
556
665
  }
557
666
  if (Object.hasOwn(newSchema, "items")) {
@@ -614,7 +723,7 @@ var DatabaseWorkerOptionsSchema = {
614
723
  interval: number
615
724
  };
616
725
 
617
- // ../../../node_modules/.pnpm/@forklaunch+validator@0.10.14/node_modules/@forklaunch/validator/lib/src/zod/index.mjs
726
+ // ../../../node_modules/.pnpm/@forklaunch+validator@0.10.17/node_modules/@forklaunch/validator/lib/src/zod/index.mjs
618
727
  var import_v3 = require("zod/v3");
619
728
 
620
729
  // ../../../node_modules/.pnpm/ts-deepmerge@7.0.3/node_modules/ts-deepmerge/esm/index.js
@@ -664,7 +773,7 @@ merge.withOptions = (options, ...objects) => {
664
773
  return result;
665
774
  };
666
775
 
667
- // ../../../node_modules/.pnpm/@forklaunch+validator@0.10.14/node_modules/@forklaunch/validator/lib/src/zod/index.mjs
776
+ // ../../../node_modules/.pnpm/@forklaunch+validator@0.10.17/node_modules/@forklaunch/validator/lib/src/zod/index.mjs
668
777
  var import_v32 = require("zod/v3");
669
778
  function extendApi(schema, schemaObject = {}) {
670
779
  const This = schema.constructor;
@@ -1373,8 +1482,27 @@ var ZodSchemaValidator = class {
1373
1482
  format: "binary",
1374
1483
  example: "a base-64 encodable string"
1375
1484
  });
1376
- file = import_v3.z.instanceof(Buffer).transform((val) => {
1485
+ file = import_v3.z.union([
1486
+ import_v3.z.instanceof(Buffer),
1487
+ import_v3.z.instanceof(ArrayBuffer),
1488
+ import_v3.z.instanceof(Blob),
1489
+ import_v3.z.string()
1490
+ ]).transform((val) => {
1491
+ if (val instanceof Buffer) {
1492
+ return new Blob([val]);
1493
+ }
1494
+ if (val instanceof ArrayBuffer) {
1495
+ return new Blob([val]);
1496
+ }
1497
+ if (val instanceof Blob) {
1498
+ return val;
1499
+ }
1500
+ if (typeof val === "string") {
1501
+ return new Blob([val]);
1502
+ }
1377
1503
  return new Blob([val]);
1504
+ }).refine((val) => val instanceof Blob, {
1505
+ message: "Invalid file type: expected Buffer, ArrayBuffer, Blob, or string"
1378
1506
  }).openapi({
1379
1507
  title: "File",
1380
1508
  type: "string",
@@ -1559,7 +1687,8 @@ var ZodSchemaValidator = class {
1559
1687
  * @returns {SchemaObject} The OpenAPI schema object.
1560
1688
  */
1561
1689
  openapi(schema) {
1562
- return generateSchema(this.schemify(schema));
1690
+ const schemified = this.schemify(schema);
1691
+ return generateSchema(deepCloneWithoutUndefined(schemified));
1563
1692
  }
1564
1693
  };
1565
1694
  var SchemaValidator2 = () => new ZodSchemaValidator();
@@ -19,7 +19,7 @@ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "defau
19
19
  // domain/schemas/databaseWorker.schema.ts
20
20
  import { serviceSchemaResolver } from "@forklaunch/internal";
21
21
 
22
- // ../../../node_modules/.pnpm/@forklaunch+validator@0.10.14/node_modules/@forklaunch/validator/lib/src/typebox/index.mjs
22
+ // ../../../node_modules/.pnpm/@forklaunch+validator@0.10.17/node_modules/@forklaunch/validator/lib/src/typebox/index.mjs
23
23
  var typebox_exports = {};
24
24
  __export(typebox_exports, {
25
25
  SchemaValidator: () => SchemaValidator,
@@ -60,7 +60,79 @@ __export(typebox_exports, {
60
60
  __reExport(typebox_exports, typebox_star);
61
61
  import * as typebox_star from "@sinclair/typebox";
62
62
 
63
- // ../../../node_modules/.pnpm/@forklaunch+common@0.6.14/node_modules/@forklaunch/common/lib/index.mjs
63
+ // ../../../node_modules/.pnpm/@forklaunch+common@0.6.17/node_modules/@forklaunch/common/lib/index.mjs
64
+ function deepCloneWithoutUndefined(obj, seen = /* @__PURE__ */ new WeakMap()) {
65
+ if (obj === null || obj === void 0) {
66
+ return obj;
67
+ }
68
+ if (typeof obj !== "object" && typeof obj !== "function") {
69
+ return obj;
70
+ }
71
+ if (seen.has(obj)) {
72
+ return seen.get(obj);
73
+ }
74
+ if (obj instanceof Date) {
75
+ return new Date(obj.getTime());
76
+ }
77
+ if (obj instanceof RegExp) {
78
+ return new RegExp(obj.source, obj.flags);
79
+ }
80
+ if (obj instanceof Map) {
81
+ const clonedMap = /* @__PURE__ */ new Map();
82
+ seen.set(obj, clonedMap);
83
+ obj.forEach((value, key) => {
84
+ if (value !== void 0) {
85
+ clonedMap.set(key, deepCloneWithoutUndefined(value, seen));
86
+ }
87
+ });
88
+ return clonedMap;
89
+ }
90
+ if (obj instanceof Set) {
91
+ const clonedSet = /* @__PURE__ */ new Set();
92
+ seen.set(obj, clonedSet);
93
+ obj.forEach((value) => {
94
+ if (value !== void 0) {
95
+ clonedSet.add(deepCloneWithoutUndefined(value, seen));
96
+ }
97
+ });
98
+ return clonedSet;
99
+ }
100
+ if (Array.isArray(obj)) {
101
+ const clonedArray = [];
102
+ seen.set(obj, clonedArray);
103
+ for (const item of obj) {
104
+ if (item !== void 0) {
105
+ clonedArray.push(deepCloneWithoutUndefined(item, seen));
106
+ }
107
+ }
108
+ return clonedArray;
109
+ }
110
+ if (typeof obj === "function") {
111
+ return obj;
112
+ }
113
+ const proto = Object.getPrototypeOf(obj);
114
+ const cloned = Object.create(proto);
115
+ seen.set(obj, cloned);
116
+ const allKeys = [
117
+ ...Object.getOwnPropertyNames(obj),
118
+ ...Object.getOwnPropertySymbols(obj)
119
+ ];
120
+ for (const key of allKeys) {
121
+ const descriptor = Object.getOwnPropertyDescriptor(obj, key);
122
+ if (!descriptor) continue;
123
+ if ("value" in descriptor) {
124
+ if (descriptor.value !== void 0) {
125
+ Object.defineProperty(cloned, key, {
126
+ ...descriptor,
127
+ value: deepCloneWithoutUndefined(descriptor.value, seen)
128
+ });
129
+ }
130
+ } else {
131
+ Object.defineProperty(cloned, key, descriptor);
132
+ }
133
+ }
134
+ return cloned;
135
+ }
64
136
  var InMemoryBlob = class extends Blob {
65
137
  constructor(content) {
66
138
  super([content]);
@@ -68,7 +140,7 @@ var InMemoryBlob = class extends Blob {
68
140
  }
69
141
  };
70
142
 
71
- // ../../../node_modules/.pnpm/@forklaunch+validator@0.10.14/node_modules/@forklaunch/validator/lib/src/typebox/index.mjs
143
+ // ../../../node_modules/.pnpm/@forklaunch+validator@0.10.17/node_modules/@forklaunch/validator/lib/src/typebox/index.mjs
72
144
  import {
73
145
  FormatRegistry,
74
146
  Kind,
@@ -274,14 +346,46 @@ var TypeboxSchemaValidator = class {
274
346
  return "";
275
347
  });
276
348
  file = Type.Transform(
277
- Type.Unsafe({
278
- errorType: "binary",
279
- format: "binary",
280
- example: "a raw buffer or file stream",
281
- title: "File"
282
- })
349
+ Type.Union([
350
+ Type.Unsafe({
351
+ errorType: "binary",
352
+ format: "binary",
353
+ example: "a raw buffer or file stream",
354
+ title: "File"
355
+ }),
356
+ Type.Unsafe({
357
+ errorType: "binary",
358
+ format: "binary",
359
+ example: "an array buffer",
360
+ title: "File"
361
+ }),
362
+ Type.Unsafe({
363
+ errorType: "binary",
364
+ format: "binary",
365
+ example: "a blob object",
366
+ title: "File"
367
+ }),
368
+ Type.String({
369
+ errorType: "binary",
370
+ format: "binary",
371
+ example: "a string content",
372
+ title: "File"
373
+ })
374
+ ])
283
375
  ).Decode((value) => {
284
- return new InMemoryBlob(value);
376
+ if (value instanceof Buffer) {
377
+ return new InMemoryBlob(value);
378
+ }
379
+ if (value instanceof ArrayBuffer) {
380
+ return new InMemoryBlob(Buffer.from(value));
381
+ }
382
+ if (value instanceof Blob) {
383
+ return value;
384
+ }
385
+ if (typeof value === "string") {
386
+ return new InMemoryBlob(Buffer.from(value));
387
+ }
388
+ return new InMemoryBlob(Buffer.from(value));
285
389
  }).Encode((value) => value.content);
286
390
  type = () => this.any;
287
391
  /**
@@ -321,7 +425,7 @@ var TypeboxSchemaValidator = class {
321
425
  }
322
426
  const newSchema = {};
323
427
  Object.getOwnPropertyNames(schema).forEach((key) => {
324
- if (KindGuard.IsSchema(schema[key])) {
428
+ if (KindGuard.IsSchema(schema[key]) || KindGuard.IsTransform(schema[key])) {
325
429
  newSchema[key] = schema[key];
326
430
  } else {
327
431
  const schemified = this.schemify(schema[key]);
@@ -539,20 +643,25 @@ var TypeboxSchemaValidator = class {
539
643
  * @returns {SchemaObject} The OpenAPI schema object.
540
644
  */
541
645
  openapi(schema) {
542
- let schemified = this.schemify(schema);
646
+ const schemified = this.schemify(schema);
647
+ let processedSchema;
543
648
  if (KindGuard.IsDate(schemified)) {
544
- schemified = Type.String({
649
+ processedSchema = Type.String({
545
650
  format: "date-time"
546
651
  });
652
+ } else {
653
+ processedSchema = deepCloneWithoutUndefined(schemified);
547
654
  }
548
- const newSchema = Object.assign({}, schemified);
655
+ const newSchema = Object.assign({}, processedSchema);
549
656
  if (Object.hasOwn(newSchema, "properties")) {
550
657
  if (newSchema.properties) {
551
- Object.entries({ ...schemified.properties }).forEach(([key, value]) => {
552
- if (KindGuard.IsSchema(value) && newSchema.properties) {
553
- newSchema.properties[key] = this.openapi(value);
658
+ Object.entries({ ...processedSchema.properties }).forEach(
659
+ ([key, value]) => {
660
+ if (KindGuard.IsSchema(value) && newSchema.properties) {
661
+ newSchema.properties[key] = this.openapi(value);
662
+ }
554
663
  }
555
- });
664
+ );
556
665
  }
557
666
  }
558
667
  if (Object.hasOwn(newSchema, "items")) {
@@ -615,7 +724,7 @@ var DatabaseWorkerOptionsSchema = {
615
724
  interval: number
616
725
  };
617
726
 
618
- // ../../../node_modules/.pnpm/@forklaunch+validator@0.10.14/node_modules/@forklaunch/validator/lib/src/zod/index.mjs
727
+ // ../../../node_modules/.pnpm/@forklaunch+validator@0.10.17/node_modules/@forklaunch/validator/lib/src/zod/index.mjs
619
728
  import {
620
729
  z as z2,
621
730
  ZodType
@@ -668,7 +777,7 @@ merge.withOptions = (options, ...objects) => {
668
777
  return result;
669
778
  };
670
779
 
671
- // ../../../node_modules/.pnpm/@forklaunch+validator@0.10.14/node_modules/@forklaunch/validator/lib/src/zod/index.mjs
780
+ // ../../../node_modules/.pnpm/@forklaunch+validator@0.10.17/node_modules/@forklaunch/validator/lib/src/zod/index.mjs
672
781
  import { z } from "zod/v3";
673
782
  function extendApi(schema, schemaObject = {}) {
674
783
  const This = schema.constructor;
@@ -1377,8 +1486,27 @@ var ZodSchemaValidator = class {
1377
1486
  format: "binary",
1378
1487
  example: "a base-64 encodable string"
1379
1488
  });
1380
- file = z2.instanceof(Buffer).transform((val) => {
1489
+ file = z2.union([
1490
+ z2.instanceof(Buffer),
1491
+ z2.instanceof(ArrayBuffer),
1492
+ z2.instanceof(Blob),
1493
+ z2.string()
1494
+ ]).transform((val) => {
1495
+ if (val instanceof Buffer) {
1496
+ return new Blob([val]);
1497
+ }
1498
+ if (val instanceof ArrayBuffer) {
1499
+ return new Blob([val]);
1500
+ }
1501
+ if (val instanceof Blob) {
1502
+ return val;
1503
+ }
1504
+ if (typeof val === "string") {
1505
+ return new Blob([val]);
1506
+ }
1381
1507
  return new Blob([val]);
1508
+ }).refine((val) => val instanceof Blob, {
1509
+ message: "Invalid file type: expected Buffer, ArrayBuffer, Blob, or string"
1382
1510
  }).openapi({
1383
1511
  title: "File",
1384
1512
  type: "string",
@@ -1563,7 +1691,8 @@ var ZodSchemaValidator = class {
1563
1691
  * @returns {SchemaObject} The OpenAPI schema object.
1564
1692
  */
1565
1693
  openapi(schema) {
1566
- return generateSchema(this.schemify(schema));
1694
+ const schemified = this.schemify(schema);
1695
+ return generateSchema(deepCloneWithoutUndefined(schemified));
1567
1696
  }
1568
1697
  };
1569
1698
  var SchemaValidator2 = () => new ZodSchemaValidator();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@forklaunch/implementation-worker-database",
3
- "version": "0.7.3",
3
+ "version": "0.8.0",
4
4
  "description": "Database implementation for forklaunch workers",
5
5
  "homepage": "https://github.com/forklaunch/forklaunch-js#readme",
6
6
  "bugs": {
@@ -42,20 +42,20 @@
42
42
  "lib/**"
43
43
  ],
44
44
  "dependencies": {
45
- "@forklaunch/core": "^0.15.3",
46
- "@forklaunch/internal": "^0.3.14",
47
- "@mikro-orm/core": "^6.5.6",
45
+ "@forklaunch/core": "^0.15.6",
46
+ "@forklaunch/internal": "^0.3.17",
47
+ "@mikro-orm/core": "^6.5.7",
48
48
  "@sinclair/typebox": "^0.34.41",
49
- "zod": "^4.1.11",
50
- "@forklaunch/interfaces-worker": "0.6.3"
49
+ "zod": "^4.1.12",
50
+ "@forklaunch/interfaces-worker": "0.7.0"
51
51
  },
52
52
  "devDependencies": {
53
- "@typescript/native-preview": "7.0.0-dev.20250930.1",
53
+ "@typescript/native-preview": "7.0.0-dev.20251007.1",
54
54
  "depcheck": "^1.4.7",
55
- "eslint": "^9.36.0",
55
+ "eslint": "^9.37.0",
56
56
  "prettier": "^3.6.2",
57
57
  "typedoc": "^0.28.13",
58
- "typescript-eslint": "^8.45.0"
58
+ "typescript-eslint": "^8.46.0"
59
59
  },
60
60
  "scripts": {
61
61
  "build": "tsc --noEmit && tsup producers/index.ts consumers/index.ts domain/schemas/index.ts domain/types/index.ts --format cjs,esm --no-splitting --dts --tsconfig tsconfig.json --out-dir lib --clean && if [ -f eject-package.bash ]; then pnpm package:eject; fi",