@forklaunch/implementation-worker-database 0.7.3 → 0.8.1
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/lib/domain/schemas/index.js +161 -23
- package/lib/domain/schemas/index.mjs +163 -24
- package/package.json +9 -9
|
@@ -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.
|
|
31
|
+
// ../../../node_modules/.pnpm/@forklaunch+validator@0.10.18/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.
|
|
71
|
+
// ../../../node_modules/.pnpm/@forklaunch+common@0.6.18/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,12 +148,18 @@ var InMemoryBlob = class extends Blob {
|
|
|
76
148
|
}
|
|
77
149
|
};
|
|
78
150
|
|
|
79
|
-
// ../../../node_modules/.pnpm/@forklaunch+validator@0.10.
|
|
151
|
+
// ../../../node_modules/.pnpm/@forklaunch+validator@0.10.18/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");
|
|
83
155
|
var import_value = require("@sinclair/typebox/value");
|
|
84
156
|
import_typebox.FormatRegistry.Set("binary", (value) => typeof value === "string");
|
|
157
|
+
import_typebox.TypeRegistry.Set("Blob", (_schema, value) => value instanceof Blob);
|
|
158
|
+
import_typebox.TypeRegistry.Set(
|
|
159
|
+
"ArrayBuffer",
|
|
160
|
+
(_schema, value) => value instanceof ArrayBuffer
|
|
161
|
+
);
|
|
162
|
+
import_typebox.TypeRegistry.Set("Buffer", (_schema, value) => value instanceof Buffer);
|
|
85
163
|
(0, import_errors.SetErrorFunction)((params) => {
|
|
86
164
|
switch (params.errorType) {
|
|
87
165
|
case import_errors.ValueErrorType.Union:
|
|
@@ -273,14 +351,49 @@ var TypeboxSchemaValidator = class {
|
|
|
273
351
|
return "";
|
|
274
352
|
});
|
|
275
353
|
file = import_typebox.Type.Transform(
|
|
276
|
-
import_typebox.Type.
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
354
|
+
import_typebox.Type.Union([
|
|
355
|
+
import_typebox.Type.Unsafe({
|
|
356
|
+
[import_typebox.Kind]: "Buffer",
|
|
357
|
+
errorType: "binary",
|
|
358
|
+
format: "binary",
|
|
359
|
+
example: "a raw buffer or file stream",
|
|
360
|
+
title: "File"
|
|
361
|
+
}),
|
|
362
|
+
import_typebox.Type.Unsafe({
|
|
363
|
+
[import_typebox.Kind]: "ArrayBuffer",
|
|
364
|
+
errorType: "binary",
|
|
365
|
+
format: "binary",
|
|
366
|
+
example: "an array buffer",
|
|
367
|
+
title: "File"
|
|
368
|
+
}),
|
|
369
|
+
import_typebox.Type.Unsafe({
|
|
370
|
+
[import_typebox.Kind]: "Blob",
|
|
371
|
+
errorType: "binary",
|
|
372
|
+
format: "binary",
|
|
373
|
+
example: "a blob object",
|
|
374
|
+
title: "File"
|
|
375
|
+
}),
|
|
376
|
+
import_typebox.Type.String({
|
|
377
|
+
errorType: "binary",
|
|
378
|
+
format: "binary",
|
|
379
|
+
example: "a string content",
|
|
380
|
+
title: "File"
|
|
381
|
+
})
|
|
382
|
+
])
|
|
282
383
|
).Decode((value) => {
|
|
283
|
-
|
|
384
|
+
if (value instanceof Buffer) {
|
|
385
|
+
return new InMemoryBlob(value);
|
|
386
|
+
}
|
|
387
|
+
if (value instanceof ArrayBuffer) {
|
|
388
|
+
return new InMemoryBlob(Buffer.from(value));
|
|
389
|
+
}
|
|
390
|
+
if (value instanceof Blob) {
|
|
391
|
+
return value;
|
|
392
|
+
}
|
|
393
|
+
if (typeof value === "string") {
|
|
394
|
+
return new InMemoryBlob(Buffer.from(value));
|
|
395
|
+
}
|
|
396
|
+
return new InMemoryBlob(Buffer.from(value));
|
|
284
397
|
}).Encode((value) => value.content);
|
|
285
398
|
type = () => this.any;
|
|
286
399
|
/**
|
|
@@ -320,7 +433,7 @@ var TypeboxSchemaValidator = class {
|
|
|
320
433
|
}
|
|
321
434
|
const newSchema = {};
|
|
322
435
|
Object.getOwnPropertyNames(schema).forEach((key) => {
|
|
323
|
-
if (import_typebox.KindGuard.IsSchema(schema[key])) {
|
|
436
|
+
if (import_typebox.KindGuard.IsSchema(schema[key]) || import_typebox.KindGuard.IsTransform(schema[key])) {
|
|
324
437
|
newSchema[key] = schema[key];
|
|
325
438
|
} else {
|
|
326
439
|
const schemified = this.schemify(schema[key]);
|
|
@@ -510,7 +623,7 @@ var TypeboxSchemaValidator = class {
|
|
|
510
623
|
} : {
|
|
511
624
|
ok: false,
|
|
512
625
|
errors: errors.flatMap((error) => {
|
|
513
|
-
if (error.type === import_errors.ValueErrorType.Union && error.schema.errorType
|
|
626
|
+
if (error.type === import_errors.ValueErrorType.Union && error.schema.errorType?.includes("any of")) {
|
|
514
627
|
return error.errors.flatMap(
|
|
515
628
|
(e, idx) => Array.from(e).map((e2) => ({
|
|
516
629
|
path: [
|
|
@@ -538,20 +651,25 @@ var TypeboxSchemaValidator = class {
|
|
|
538
651
|
* @returns {SchemaObject} The OpenAPI schema object.
|
|
539
652
|
*/
|
|
540
653
|
openapi(schema) {
|
|
541
|
-
|
|
654
|
+
const schemified = this.schemify(schema);
|
|
655
|
+
let processedSchema;
|
|
542
656
|
if (import_typebox.KindGuard.IsDate(schemified)) {
|
|
543
|
-
|
|
657
|
+
processedSchema = import_typebox.Type.String({
|
|
544
658
|
format: "date-time"
|
|
545
659
|
});
|
|
660
|
+
} else {
|
|
661
|
+
processedSchema = deepCloneWithoutUndefined(schemified);
|
|
546
662
|
}
|
|
547
|
-
const newSchema = Object.assign({},
|
|
663
|
+
const newSchema = Object.assign({}, processedSchema);
|
|
548
664
|
if (Object.hasOwn(newSchema, "properties")) {
|
|
549
665
|
if (newSchema.properties) {
|
|
550
|
-
Object.entries({ ...
|
|
551
|
-
|
|
552
|
-
|
|
666
|
+
Object.entries({ ...processedSchema.properties }).forEach(
|
|
667
|
+
([key, value]) => {
|
|
668
|
+
if (import_typebox.KindGuard.IsSchema(value) && newSchema.properties) {
|
|
669
|
+
newSchema.properties[key] = this.openapi(value);
|
|
670
|
+
}
|
|
553
671
|
}
|
|
554
|
-
|
|
672
|
+
);
|
|
555
673
|
}
|
|
556
674
|
}
|
|
557
675
|
if (Object.hasOwn(newSchema, "items")) {
|
|
@@ -614,7 +732,7 @@ var DatabaseWorkerOptionsSchema = {
|
|
|
614
732
|
interval: number
|
|
615
733
|
};
|
|
616
734
|
|
|
617
|
-
// ../../../node_modules/.pnpm/@forklaunch+validator@0.10.
|
|
735
|
+
// ../../../node_modules/.pnpm/@forklaunch+validator@0.10.18/node_modules/@forklaunch/validator/lib/src/zod/index.mjs
|
|
618
736
|
var import_v3 = require("zod/v3");
|
|
619
737
|
|
|
620
738
|
// ../../../node_modules/.pnpm/ts-deepmerge@7.0.3/node_modules/ts-deepmerge/esm/index.js
|
|
@@ -664,7 +782,7 @@ merge.withOptions = (options, ...objects) => {
|
|
|
664
782
|
return result;
|
|
665
783
|
};
|
|
666
784
|
|
|
667
|
-
// ../../../node_modules/.pnpm/@forklaunch+validator@0.10.
|
|
785
|
+
// ../../../node_modules/.pnpm/@forklaunch+validator@0.10.18/node_modules/@forklaunch/validator/lib/src/zod/index.mjs
|
|
668
786
|
var import_v32 = require("zod/v3");
|
|
669
787
|
function extendApi(schema, schemaObject = {}) {
|
|
670
788
|
const This = schema.constructor;
|
|
@@ -1373,8 +1491,27 @@ var ZodSchemaValidator = class {
|
|
|
1373
1491
|
format: "binary",
|
|
1374
1492
|
example: "a base-64 encodable string"
|
|
1375
1493
|
});
|
|
1376
|
-
file = import_v3.z.
|
|
1494
|
+
file = import_v3.z.union([
|
|
1495
|
+
import_v3.z.instanceof(Buffer),
|
|
1496
|
+
import_v3.z.instanceof(ArrayBuffer),
|
|
1497
|
+
import_v3.z.instanceof(Blob),
|
|
1498
|
+
import_v3.z.string()
|
|
1499
|
+
]).transform((val) => {
|
|
1500
|
+
if (val instanceof Buffer) {
|
|
1501
|
+
return new Blob([val]);
|
|
1502
|
+
}
|
|
1503
|
+
if (val instanceof ArrayBuffer) {
|
|
1504
|
+
return new Blob([val]);
|
|
1505
|
+
}
|
|
1506
|
+
if (val instanceof Blob) {
|
|
1507
|
+
return val;
|
|
1508
|
+
}
|
|
1509
|
+
if (typeof val === "string") {
|
|
1510
|
+
return new Blob([val]);
|
|
1511
|
+
}
|
|
1377
1512
|
return new Blob([val]);
|
|
1513
|
+
}).refine((val) => val instanceof Blob, {
|
|
1514
|
+
message: "Invalid file type: expected Buffer, ArrayBuffer, Blob, or string"
|
|
1378
1515
|
}).openapi({
|
|
1379
1516
|
title: "File",
|
|
1380
1517
|
type: "string",
|
|
@@ -1559,7 +1696,8 @@ var ZodSchemaValidator = class {
|
|
|
1559
1696
|
* @returns {SchemaObject} The OpenAPI schema object.
|
|
1560
1697
|
*/
|
|
1561
1698
|
openapi(schema) {
|
|
1562
|
-
|
|
1699
|
+
const schemified = this.schemify(schema);
|
|
1700
|
+
return generateSchema(deepCloneWithoutUndefined(schemified));
|
|
1563
1701
|
}
|
|
1564
1702
|
};
|
|
1565
1703
|
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.
|
|
22
|
+
// ../../../node_modules/.pnpm/@forklaunch+validator@0.10.18/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.
|
|
63
|
+
// ../../../node_modules/.pnpm/@forklaunch+common@0.6.18/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,12 +140,13 @@ var InMemoryBlob = class extends Blob {
|
|
|
68
140
|
}
|
|
69
141
|
};
|
|
70
142
|
|
|
71
|
-
// ../../../node_modules/.pnpm/@forklaunch+validator@0.10.
|
|
143
|
+
// ../../../node_modules/.pnpm/@forklaunch+validator@0.10.18/node_modules/@forklaunch/validator/lib/src/typebox/index.mjs
|
|
72
144
|
import {
|
|
73
145
|
FormatRegistry,
|
|
74
146
|
Kind,
|
|
75
147
|
KindGuard,
|
|
76
|
-
Type
|
|
148
|
+
Type,
|
|
149
|
+
TypeRegistry
|
|
77
150
|
} from "@sinclair/typebox";
|
|
78
151
|
import { TypeCheck, TypeCompiler } from "@sinclair/typebox/compiler";
|
|
79
152
|
import {
|
|
@@ -83,6 +156,12 @@ import {
|
|
|
83
156
|
} from "@sinclair/typebox/errors";
|
|
84
157
|
import { Value } from "@sinclair/typebox/value";
|
|
85
158
|
FormatRegistry.Set("binary", (value) => typeof value === "string");
|
|
159
|
+
TypeRegistry.Set("Blob", (_schema, value) => value instanceof Blob);
|
|
160
|
+
TypeRegistry.Set(
|
|
161
|
+
"ArrayBuffer",
|
|
162
|
+
(_schema, value) => value instanceof ArrayBuffer
|
|
163
|
+
);
|
|
164
|
+
TypeRegistry.Set("Buffer", (_schema, value) => value instanceof Buffer);
|
|
86
165
|
SetErrorFunction((params) => {
|
|
87
166
|
switch (params.errorType) {
|
|
88
167
|
case ValueErrorType.Union:
|
|
@@ -274,14 +353,49 @@ var TypeboxSchemaValidator = class {
|
|
|
274
353
|
return "";
|
|
275
354
|
});
|
|
276
355
|
file = Type.Transform(
|
|
277
|
-
Type.
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
356
|
+
Type.Union([
|
|
357
|
+
Type.Unsafe({
|
|
358
|
+
[Kind]: "Buffer",
|
|
359
|
+
errorType: "binary",
|
|
360
|
+
format: "binary",
|
|
361
|
+
example: "a raw buffer or file stream",
|
|
362
|
+
title: "File"
|
|
363
|
+
}),
|
|
364
|
+
Type.Unsafe({
|
|
365
|
+
[Kind]: "ArrayBuffer",
|
|
366
|
+
errorType: "binary",
|
|
367
|
+
format: "binary",
|
|
368
|
+
example: "an array buffer",
|
|
369
|
+
title: "File"
|
|
370
|
+
}),
|
|
371
|
+
Type.Unsafe({
|
|
372
|
+
[Kind]: "Blob",
|
|
373
|
+
errorType: "binary",
|
|
374
|
+
format: "binary",
|
|
375
|
+
example: "a blob object",
|
|
376
|
+
title: "File"
|
|
377
|
+
}),
|
|
378
|
+
Type.String({
|
|
379
|
+
errorType: "binary",
|
|
380
|
+
format: "binary",
|
|
381
|
+
example: "a string content",
|
|
382
|
+
title: "File"
|
|
383
|
+
})
|
|
384
|
+
])
|
|
283
385
|
).Decode((value) => {
|
|
284
|
-
|
|
386
|
+
if (value instanceof Buffer) {
|
|
387
|
+
return new InMemoryBlob(value);
|
|
388
|
+
}
|
|
389
|
+
if (value instanceof ArrayBuffer) {
|
|
390
|
+
return new InMemoryBlob(Buffer.from(value));
|
|
391
|
+
}
|
|
392
|
+
if (value instanceof Blob) {
|
|
393
|
+
return value;
|
|
394
|
+
}
|
|
395
|
+
if (typeof value === "string") {
|
|
396
|
+
return new InMemoryBlob(Buffer.from(value));
|
|
397
|
+
}
|
|
398
|
+
return new InMemoryBlob(Buffer.from(value));
|
|
285
399
|
}).Encode((value) => value.content);
|
|
286
400
|
type = () => this.any;
|
|
287
401
|
/**
|
|
@@ -321,7 +435,7 @@ var TypeboxSchemaValidator = class {
|
|
|
321
435
|
}
|
|
322
436
|
const newSchema = {};
|
|
323
437
|
Object.getOwnPropertyNames(schema).forEach((key) => {
|
|
324
|
-
if (KindGuard.IsSchema(schema[key])) {
|
|
438
|
+
if (KindGuard.IsSchema(schema[key]) || KindGuard.IsTransform(schema[key])) {
|
|
325
439
|
newSchema[key] = schema[key];
|
|
326
440
|
} else {
|
|
327
441
|
const schemified = this.schemify(schema[key]);
|
|
@@ -511,7 +625,7 @@ var TypeboxSchemaValidator = class {
|
|
|
511
625
|
} : {
|
|
512
626
|
ok: false,
|
|
513
627
|
errors: errors.flatMap((error) => {
|
|
514
|
-
if (error.type === ValueErrorType.Union && error.schema.errorType
|
|
628
|
+
if (error.type === ValueErrorType.Union && error.schema.errorType?.includes("any of")) {
|
|
515
629
|
return error.errors.flatMap(
|
|
516
630
|
(e, idx) => Array.from(e).map((e2) => ({
|
|
517
631
|
path: [
|
|
@@ -539,20 +653,25 @@ var TypeboxSchemaValidator = class {
|
|
|
539
653
|
* @returns {SchemaObject} The OpenAPI schema object.
|
|
540
654
|
*/
|
|
541
655
|
openapi(schema) {
|
|
542
|
-
|
|
656
|
+
const schemified = this.schemify(schema);
|
|
657
|
+
let processedSchema;
|
|
543
658
|
if (KindGuard.IsDate(schemified)) {
|
|
544
|
-
|
|
659
|
+
processedSchema = Type.String({
|
|
545
660
|
format: "date-time"
|
|
546
661
|
});
|
|
662
|
+
} else {
|
|
663
|
+
processedSchema = deepCloneWithoutUndefined(schemified);
|
|
547
664
|
}
|
|
548
|
-
const newSchema = Object.assign({},
|
|
665
|
+
const newSchema = Object.assign({}, processedSchema);
|
|
549
666
|
if (Object.hasOwn(newSchema, "properties")) {
|
|
550
667
|
if (newSchema.properties) {
|
|
551
|
-
Object.entries({ ...
|
|
552
|
-
|
|
553
|
-
|
|
668
|
+
Object.entries({ ...processedSchema.properties }).forEach(
|
|
669
|
+
([key, value]) => {
|
|
670
|
+
if (KindGuard.IsSchema(value) && newSchema.properties) {
|
|
671
|
+
newSchema.properties[key] = this.openapi(value);
|
|
672
|
+
}
|
|
554
673
|
}
|
|
555
|
-
|
|
674
|
+
);
|
|
556
675
|
}
|
|
557
676
|
}
|
|
558
677
|
if (Object.hasOwn(newSchema, "items")) {
|
|
@@ -615,7 +734,7 @@ var DatabaseWorkerOptionsSchema = {
|
|
|
615
734
|
interval: number
|
|
616
735
|
};
|
|
617
736
|
|
|
618
|
-
// ../../../node_modules/.pnpm/@forklaunch+validator@0.10.
|
|
737
|
+
// ../../../node_modules/.pnpm/@forklaunch+validator@0.10.18/node_modules/@forklaunch/validator/lib/src/zod/index.mjs
|
|
619
738
|
import {
|
|
620
739
|
z as z2,
|
|
621
740
|
ZodType
|
|
@@ -668,7 +787,7 @@ merge.withOptions = (options, ...objects) => {
|
|
|
668
787
|
return result;
|
|
669
788
|
};
|
|
670
789
|
|
|
671
|
-
// ../../../node_modules/.pnpm/@forklaunch+validator@0.10.
|
|
790
|
+
// ../../../node_modules/.pnpm/@forklaunch+validator@0.10.18/node_modules/@forklaunch/validator/lib/src/zod/index.mjs
|
|
672
791
|
import { z } from "zod/v3";
|
|
673
792
|
function extendApi(schema, schemaObject = {}) {
|
|
674
793
|
const This = schema.constructor;
|
|
@@ -1377,8 +1496,27 @@ var ZodSchemaValidator = class {
|
|
|
1377
1496
|
format: "binary",
|
|
1378
1497
|
example: "a base-64 encodable string"
|
|
1379
1498
|
});
|
|
1380
|
-
file = z2.
|
|
1499
|
+
file = z2.union([
|
|
1500
|
+
z2.instanceof(Buffer),
|
|
1501
|
+
z2.instanceof(ArrayBuffer),
|
|
1502
|
+
z2.instanceof(Blob),
|
|
1503
|
+
z2.string()
|
|
1504
|
+
]).transform((val) => {
|
|
1505
|
+
if (val instanceof Buffer) {
|
|
1506
|
+
return new Blob([val]);
|
|
1507
|
+
}
|
|
1508
|
+
if (val instanceof ArrayBuffer) {
|
|
1509
|
+
return new Blob([val]);
|
|
1510
|
+
}
|
|
1511
|
+
if (val instanceof Blob) {
|
|
1512
|
+
return val;
|
|
1513
|
+
}
|
|
1514
|
+
if (typeof val === "string") {
|
|
1515
|
+
return new Blob([val]);
|
|
1516
|
+
}
|
|
1381
1517
|
return new Blob([val]);
|
|
1518
|
+
}).refine((val) => val instanceof Blob, {
|
|
1519
|
+
message: "Invalid file type: expected Buffer, ArrayBuffer, Blob, or string"
|
|
1382
1520
|
}).openapi({
|
|
1383
1521
|
title: "File",
|
|
1384
1522
|
type: "string",
|
|
@@ -1563,7 +1701,8 @@ var ZodSchemaValidator = class {
|
|
|
1563
1701
|
* @returns {SchemaObject} The OpenAPI schema object.
|
|
1564
1702
|
*/
|
|
1565
1703
|
openapi(schema) {
|
|
1566
|
-
|
|
1704
|
+
const schemified = this.schemify(schema);
|
|
1705
|
+
return generateSchema(deepCloneWithoutUndefined(schemified));
|
|
1567
1706
|
}
|
|
1568
1707
|
};
|
|
1569
1708
|
var SchemaValidator2 = () => new ZodSchemaValidator();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@forklaunch/implementation-worker-database",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.1",
|
|
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.
|
|
46
|
-
"@forklaunch/internal": "^0.3.
|
|
47
|
-
"@mikro-orm/core": "^6.5.
|
|
45
|
+
"@forklaunch/core": "^0.15.7",
|
|
46
|
+
"@forklaunch/internal": "^0.3.18",
|
|
47
|
+
"@mikro-orm/core": "^6.5.7",
|
|
48
48
|
"@sinclair/typebox": "^0.34.41",
|
|
49
|
-
"zod": "^4.1.
|
|
50
|
-
"@forklaunch/interfaces-worker": "0.
|
|
49
|
+
"zod": "^4.1.12",
|
|
50
|
+
"@forklaunch/interfaces-worker": "0.7.1"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
|
-
"@typescript/native-preview": "7.0.0-dev.
|
|
53
|
+
"@typescript/native-preview": "7.0.0-dev.20251008.1",
|
|
54
54
|
"depcheck": "^1.4.7",
|
|
55
|
-
"eslint": "^9.
|
|
55
|
+
"eslint": "^9.37.0",
|
|
56
56
|
"prettier": "^3.6.2",
|
|
57
57
|
"typedoc": "^0.28.13",
|
|
58
|
-
"typescript-eslint": "^8.
|
|
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",
|