@deessejs/collections 0.0.33 → 0.0.34
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/collections/define.d.ts +7 -7
- package/dist/collections/define.js +1 -1
- package/dist/collections/index.d.ts +1 -0
- package/dist/collections/index.js +1 -0
- package/dist/fields/constraints.d.ts +0 -1
- package/dist/fields/constraints.js +1 -15
- package/dist/fields/core.d.ts +8 -21
- package/dist/fields/core.js +2 -7
- package/dist/fields/field.d.ts +4 -4
- package/dist/fields/types.d.ts +1 -3
- package/dist/index.d.ts +2 -5
- package/dist/index.js +2 -5
- package/package.json +3 -11
- package/dist/drizzle/index.d.ts +0 -31
- package/dist/drizzle/index.js +0 -24
- package/dist/drizzle/types.d.ts +0 -0
- package/dist/drizzle/types.js +0 -1
- package/dist/dsl/collections.d.ts +0 -13
- package/dist/dsl/collections.js +0 -14
- package/dist/dsl/index.d.ts +0 -1
- package/dist/dsl/index.js +0 -17
- package/dist/dsl/types.d.ts +0 -1
- package/dist/dsl/types.js +0 -2
- package/dist/next/index.d.ts +0 -5
- package/dist/next/index.js +0 -24
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { Field } from "../fields";
|
|
2
2
|
import { Collection } from "./types";
|
|
3
3
|
export declare const collection: <const Slug extends string, const Fields extends Record<string, Field>>(config: Collection<Slug, Fields>) => Collection<Slug, Fields & {
|
|
4
|
-
readonly id:
|
|
5
|
-
kind:
|
|
4
|
+
readonly id: import("../fields").FieldChain<{
|
|
5
|
+
kind: string;
|
|
6
6
|
params: unknown;
|
|
7
7
|
dsl: {
|
|
8
|
-
kind:
|
|
8
|
+
kind: string;
|
|
9
9
|
isPrimary: boolean;
|
|
10
10
|
isUnique: boolean;
|
|
11
11
|
canBeNull: boolean;
|
|
@@ -15,10 +15,10 @@ export declare const collection: <const Slug extends string, const Fields extend
|
|
|
15
15
|
};
|
|
16
16
|
}>;
|
|
17
17
|
readonly createdAt: import("../fields").FieldChain<{
|
|
18
|
-
kind:
|
|
18
|
+
kind: string;
|
|
19
19
|
params: unknown;
|
|
20
20
|
dsl: {
|
|
21
|
-
kind:
|
|
21
|
+
kind: string;
|
|
22
22
|
isPrimary: boolean;
|
|
23
23
|
isUnique: boolean;
|
|
24
24
|
canBeNull: boolean;
|
|
@@ -28,10 +28,10 @@ export declare const collection: <const Slug extends string, const Fields extend
|
|
|
28
28
|
};
|
|
29
29
|
}>;
|
|
30
30
|
readonly updatedAt: import("../fields").FieldChain<{
|
|
31
|
-
kind:
|
|
31
|
+
kind: string;
|
|
32
32
|
params: unknown;
|
|
33
33
|
dsl: {
|
|
34
|
-
kind:
|
|
34
|
+
kind: string;
|
|
35
35
|
isPrimary: boolean;
|
|
36
36
|
isUnique: boolean;
|
|
37
37
|
canBeNull: boolean;
|
|
@@ -5,7 +5,7 @@ const fields_1 = require("../fields");
|
|
|
5
5
|
const extend_fields_1 = require("./extend-fields");
|
|
6
6
|
const collection = (config) => {
|
|
7
7
|
return (0, extend_fields_1.extendFields)(config, {
|
|
8
|
-
id: (0, fields_1.
|
|
8
|
+
id: (0, fields_1.field)({ type: (0, fields_1.uuid)() }),
|
|
9
9
|
createdAt: (0, fields_1.field)({ type: (0, fields_1.timestamp)() }),
|
|
10
10
|
updatedAt: (0, fields_1.field)({ type: (0, fields_1.timestamp)() }),
|
|
11
11
|
});
|
|
@@ -2,5 +2,4 @@ import { Field, FieldChain, FieldTypeFinal } from "./types";
|
|
|
2
2
|
export declare const unique: <TType extends FieldTypeFinal>(field: Field<TType>) => Field<TType>;
|
|
3
3
|
export declare const required: <TType extends FieldTypeFinal>(field: Field<TType>) => Field<TType>;
|
|
4
4
|
export declare const optional: <TType extends FieldTypeFinal>(field: Field<TType>) => Field<TType>;
|
|
5
|
-
export declare const primary: <TType extends FieldTypeFinal>(field: Field<TType>) => Field<TType>;
|
|
6
5
|
export declare const attachChain: <TType extends FieldTypeFinal>(f: Field<TType>) => FieldChain<TType>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.attachChain = exports.
|
|
3
|
+
exports.attachChain = exports.optional = exports.required = exports.unique = void 0;
|
|
4
4
|
const unique = (field) => {
|
|
5
5
|
return {
|
|
6
6
|
...field,
|
|
@@ -36,17 +36,6 @@ const optional = (field) => ({
|
|
|
36
36
|
},
|
|
37
37
|
});
|
|
38
38
|
exports.optional = optional;
|
|
39
|
-
const primary = (field) => ({
|
|
40
|
-
...field,
|
|
41
|
-
type: {
|
|
42
|
-
...field.type,
|
|
43
|
-
dsl: {
|
|
44
|
-
...field.type.dsl,
|
|
45
|
-
isPrimary: true,
|
|
46
|
-
},
|
|
47
|
-
},
|
|
48
|
-
});
|
|
49
|
-
exports.primary = primary;
|
|
50
39
|
const attachChain = (f) => {
|
|
51
40
|
return {
|
|
52
41
|
...f,
|
|
@@ -59,9 +48,6 @@ const attachChain = (f) => {
|
|
|
59
48
|
optional() {
|
|
60
49
|
return (0, exports.attachChain)((0, exports.optional)(f));
|
|
61
50
|
},
|
|
62
|
-
primary() {
|
|
63
|
-
return (0, exports.attachChain)((0, exports.primary)(f));
|
|
64
|
-
},
|
|
65
51
|
};
|
|
66
52
|
};
|
|
67
53
|
exports.attachChain = attachChain;
|
package/dist/fields/core.d.ts
CHANGED
|
@@ -2,10 +2,10 @@ export declare const number: (params?: {
|
|
|
2
2
|
min?: number | undefined;
|
|
3
3
|
max?: number | undefined;
|
|
4
4
|
} | undefined) => {
|
|
5
|
-
kind:
|
|
5
|
+
kind: string;
|
|
6
6
|
params: unknown;
|
|
7
7
|
dsl: {
|
|
8
|
-
kind:
|
|
8
|
+
kind: string;
|
|
9
9
|
isPrimary: boolean;
|
|
10
10
|
isUnique: boolean;
|
|
11
11
|
canBeNull: boolean;
|
|
@@ -18,10 +18,10 @@ export declare const text: (params?: {
|
|
|
18
18
|
min?: number | undefined;
|
|
19
19
|
max?: number | undefined;
|
|
20
20
|
} | undefined) => {
|
|
21
|
-
kind:
|
|
21
|
+
kind: string;
|
|
22
22
|
params: unknown;
|
|
23
23
|
dsl: {
|
|
24
|
-
kind:
|
|
24
|
+
kind: string;
|
|
25
25
|
isPrimary: boolean;
|
|
26
26
|
isUnique: boolean;
|
|
27
27
|
canBeNull: boolean;
|
|
@@ -31,10 +31,10 @@ export declare const text: (params?: {
|
|
|
31
31
|
};
|
|
32
32
|
};
|
|
33
33
|
export declare const uuid: (params?: void | undefined) => {
|
|
34
|
-
kind:
|
|
34
|
+
kind: string;
|
|
35
35
|
params: unknown;
|
|
36
36
|
dsl: {
|
|
37
|
-
kind:
|
|
37
|
+
kind: string;
|
|
38
38
|
isPrimary: boolean;
|
|
39
39
|
isUnique: boolean;
|
|
40
40
|
canBeNull: boolean;
|
|
@@ -44,23 +44,10 @@ export declare const uuid: (params?: void | undefined) => {
|
|
|
44
44
|
};
|
|
45
45
|
};
|
|
46
46
|
export declare const timestamp: (params?: void | undefined) => {
|
|
47
|
-
kind:
|
|
47
|
+
kind: string;
|
|
48
48
|
params: unknown;
|
|
49
49
|
dsl: {
|
|
50
|
-
kind:
|
|
51
|
-
isPrimary: boolean;
|
|
52
|
-
isUnique: boolean;
|
|
53
|
-
canBeNull: boolean;
|
|
54
|
-
};
|
|
55
|
-
admin: {
|
|
56
|
-
component: any;
|
|
57
|
-
};
|
|
58
|
-
};
|
|
59
|
-
export declare const serial: (params?: void | undefined) => {
|
|
60
|
-
kind: import("./types").FieldKind;
|
|
61
|
-
params: unknown;
|
|
62
|
-
dsl: {
|
|
63
|
-
kind: import("./types").FieldKind;
|
|
50
|
+
kind: string;
|
|
64
51
|
isPrimary: boolean;
|
|
65
52
|
isUnique: boolean;
|
|
66
53
|
canBeNull: boolean;
|
package/dist/fields/core.js
CHANGED
|
@@ -3,12 +3,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.
|
|
6
|
+
exports.timestamp = exports.uuid = exports.text = exports.number = void 0;
|
|
7
7
|
const zod_1 = __importDefault(require("zod"));
|
|
8
8
|
const field_1 = require("./field");
|
|
9
9
|
exports.number = (0, field_1.fieldType)({
|
|
10
10
|
schema: zod_1.default.object({ min: zod_1.default.number().optional(), max: zod_1.default.number().optional() }),
|
|
11
|
-
dsl: { kind: "
|
|
11
|
+
dsl: { kind: "number" },
|
|
12
12
|
admin: { component: undefined },
|
|
13
13
|
});
|
|
14
14
|
exports.text = (0, field_1.fieldType)({
|
|
@@ -26,8 +26,3 @@ exports.timestamp = (0, field_1.fieldType)({
|
|
|
26
26
|
dsl: { kind: "timestamp" },
|
|
27
27
|
admin: { component: undefined },
|
|
28
28
|
});
|
|
29
|
-
exports.serial = (0, field_1.fieldType)({
|
|
30
|
-
schema: zod_1.default.void(),
|
|
31
|
-
dsl: { kind: "serial" },
|
|
32
|
-
admin: { component: undefined },
|
|
33
|
-
});
|
package/dist/fields/field.d.ts
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import z from "zod";
|
|
2
|
-
import { FieldChain, FieldConfig,
|
|
2
|
+
import { FieldChain, FieldConfig, FieldTypeFinal } from "./types";
|
|
3
3
|
export declare const fieldType: <TOutput, TParams extends z.ZodType | undefined>(config: {
|
|
4
4
|
schema?: TParams;
|
|
5
5
|
dsl: {
|
|
6
|
-
kind:
|
|
6
|
+
kind: string;
|
|
7
7
|
};
|
|
8
8
|
admin: {
|
|
9
9
|
component: any;
|
|
10
10
|
};
|
|
11
11
|
}) => (params?: TParams extends z.ZodType ? z.infer<TParams> : undefined) => {
|
|
12
|
-
kind:
|
|
12
|
+
kind: string;
|
|
13
13
|
params: unknown;
|
|
14
14
|
dsl: {
|
|
15
|
-
kind:
|
|
15
|
+
kind: string;
|
|
16
16
|
isPrimary: boolean;
|
|
17
17
|
isUnique: boolean;
|
|
18
18
|
canBeNull: boolean;
|
package/dist/fields/types.d.ts
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
export type FieldKind = "integer" | "serial" | "boolean" | "text" | "varchar" | "char" | "numeric" | "decimal" | "json" | "uuid" | "timestamp";
|
|
3
2
|
export type FieldTypeConfig<TParams extends z.ZodType = z.ZodType> = {
|
|
4
3
|
schema?: TParams;
|
|
5
4
|
dsl: {
|
|
6
|
-
kind:
|
|
5
|
+
kind: string;
|
|
7
6
|
};
|
|
8
7
|
admin: {
|
|
9
8
|
component: any;
|
|
@@ -44,5 +43,4 @@ export type FieldChain<TType extends FieldTypeFinal> = Field<TType> & {
|
|
|
44
43
|
unique(): FieldChain<TType>;
|
|
45
44
|
required(): FieldChain<TType>;
|
|
46
45
|
optional(): FieldChain<TType>;
|
|
47
|
-
primary(): FieldChain<TType>;
|
|
48
46
|
};
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
export * from "./collections";
|
|
2
1
|
export * from "./config";
|
|
3
|
-
export * from "./
|
|
4
|
-
export * from "./dsl";
|
|
2
|
+
export * from "./collections";
|
|
5
3
|
export * from "./fields";
|
|
6
|
-
export * from "./next";
|
|
7
|
-
export * from "./plugins";
|
|
8
4
|
export * from "./providers";
|
|
5
|
+
export * from "./plugins";
|
package/dist/index.js
CHANGED
|
@@ -14,11 +14,8 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./collections"), exports);
|
|
18
17
|
__exportStar(require("./config"), exports);
|
|
19
|
-
__exportStar(require("./
|
|
20
|
-
__exportStar(require("./dsl"), exports);
|
|
18
|
+
__exportStar(require("./collections"), exports);
|
|
21
19
|
__exportStar(require("./fields"), exports);
|
|
22
|
-
__exportStar(require("./next"), exports);
|
|
23
|
-
__exportStar(require("./plugins"), exports);
|
|
24
20
|
__exportStar(require("./providers"), exports);
|
|
21
|
+
__exportStar(require("./plugins"), exports);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@deessejs/collections",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.34",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -40,31 +40,23 @@
|
|
|
40
40
|
},
|
|
41
41
|
"homepage": "https://github.com/Developers-Secrets-Inc/collections#readme",
|
|
42
42
|
"devDependencies": {
|
|
43
|
+
"zod": "^4.1.12",
|
|
43
44
|
"@testing-library/dom": "^10.4.1",
|
|
44
45
|
"@testing-library/user-event": "^14.6.1",
|
|
45
46
|
"@types/jsdom": "^27.0.0",
|
|
46
47
|
"@types/node": "^20.0.0",
|
|
47
|
-
"@types/pg": "^8.15.6",
|
|
48
48
|
"@types/sinon": "^21.0.0",
|
|
49
49
|
"@typescript-eslint/eslint-plugin": "^6.0.0",
|
|
50
50
|
"@typescript-eslint/parser": "^6.0.0",
|
|
51
51
|
"@vitest/coverage-v8": "^4.0.13",
|
|
52
52
|
"@vitest/ui": "^4.0.13",
|
|
53
|
-
"drizzle-kit": "^0.31.8",
|
|
54
53
|
"eslint": "^8.0.0",
|
|
55
54
|
"jsdom": "^27.2.0",
|
|
56
55
|
"sinon": "^21.0.0",
|
|
57
|
-
"tsx": "^4.21.0",
|
|
58
56
|
"typescript": "^5.0.0",
|
|
59
|
-
"vitest": "^4.0.13"
|
|
60
|
-
"zod": "^4.1.12"
|
|
57
|
+
"vitest": "^4.0.13"
|
|
61
58
|
},
|
|
62
59
|
"peerDependencies": {
|
|
63
60
|
"zod": "^4.1.12"
|
|
64
|
-
},
|
|
65
|
-
"dependencies": {
|
|
66
|
-
"dotenv": "^17.2.3",
|
|
67
|
-
"drizzle-orm": "^0.45.0",
|
|
68
|
-
"pg": "^8.16.3"
|
|
69
61
|
}
|
|
70
62
|
}
|
package/dist/drizzle/index.d.ts
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { Collection } from "../collections/types";
|
|
2
|
-
import { FieldKind } from "../fields";
|
|
3
|
-
export declare const DrizzleTypes: Record<FieldKind, () => any>;
|
|
4
|
-
export declare const toDrizzle: (collection: Collection) => import("drizzle-orm/pg-core").PgTableWithColumns<{
|
|
5
|
-
name: string;
|
|
6
|
-
schema: undefined;
|
|
7
|
-
columns: {
|
|
8
|
-
[x: string]: import("drizzle-orm/pg-core").PgColumn<{
|
|
9
|
-
name: any;
|
|
10
|
-
tableName: string;
|
|
11
|
-
dataType: any;
|
|
12
|
-
columnType: any;
|
|
13
|
-
data: any;
|
|
14
|
-
driverParam: any;
|
|
15
|
-
notNull: false;
|
|
16
|
-
hasDefault: false;
|
|
17
|
-
isPrimaryKey: false;
|
|
18
|
-
isAutoincrement: false;
|
|
19
|
-
hasRuntimeDefault: false;
|
|
20
|
-
enumValues: any;
|
|
21
|
-
baseColumn: never;
|
|
22
|
-
identity: undefined;
|
|
23
|
-
generated: undefined;
|
|
24
|
-
}, {}, {
|
|
25
|
-
[x: string]: any;
|
|
26
|
-
[x: number]: any;
|
|
27
|
-
[x: symbol]: any;
|
|
28
|
-
}>;
|
|
29
|
-
};
|
|
30
|
-
dialect: "pg";
|
|
31
|
-
}>;
|
package/dist/drizzle/index.js
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.toDrizzle = exports.DrizzleTypes = void 0;
|
|
4
|
-
const pg_core_1 = require("drizzle-orm/pg-core");
|
|
5
|
-
exports.DrizzleTypes = {
|
|
6
|
-
boolean: () => (0, pg_core_1.boolean)(),
|
|
7
|
-
integer: () => (0, pg_core_1.integer)(),
|
|
8
|
-
serial: () => (0, pg_core_1.serial)(),
|
|
9
|
-
text: () => (0, pg_core_1.text)(),
|
|
10
|
-
varchar: () => (0, pg_core_1.varchar)(),
|
|
11
|
-
char: () => (0, pg_core_1.char)(),
|
|
12
|
-
numeric: () => (0, pg_core_1.numeric)(),
|
|
13
|
-
decimal: () => (0, pg_core_1.decimal)(),
|
|
14
|
-
json: () => (0, pg_core_1.json)(),
|
|
15
|
-
uuid: () => (0, pg_core_1.uuid)(),
|
|
16
|
-
timestamp: () => (0, pg_core_1.timestamp)(),
|
|
17
|
-
};
|
|
18
|
-
const toDrizzle = (collection) => {
|
|
19
|
-
return (0, pg_core_1.pgTable)(collection.slug, Object.fromEntries(Object.entries(collection.fields).map(([name, field]) => {
|
|
20
|
-
const kind = field.type.dsl.kind;
|
|
21
|
-
return [name, exports.DrizzleTypes[kind]()];
|
|
22
|
-
})));
|
|
23
|
-
};
|
|
24
|
-
exports.toDrizzle = toDrizzle;
|
package/dist/drizzle/types.d.ts
DELETED
|
File without changes
|
package/dist/drizzle/types.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { Collection } from "../collections/types";
|
|
2
|
-
export declare const dsl: (collection: Collection) => {
|
|
3
|
-
slug: string;
|
|
4
|
-
fields: {
|
|
5
|
-
name: string;
|
|
6
|
-
dsl: {
|
|
7
|
-
kind: string;
|
|
8
|
-
isPrimary: boolean;
|
|
9
|
-
isUnique: boolean;
|
|
10
|
-
canBeNull: boolean;
|
|
11
|
-
};
|
|
12
|
-
}[];
|
|
13
|
-
};
|
package/dist/dsl/collections.js
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.dsl = void 0;
|
|
4
|
-
const dsl = (collection) => {
|
|
5
|
-
const { slug, fields } = collection;
|
|
6
|
-
return {
|
|
7
|
-
slug,
|
|
8
|
-
fields: Object.entries(fields).map(([name, field]) => ({
|
|
9
|
-
name,
|
|
10
|
-
dsl: field.type.dsl,
|
|
11
|
-
})),
|
|
12
|
-
};
|
|
13
|
-
};
|
|
14
|
-
exports.dsl = dsl;
|
package/dist/dsl/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './collections';
|
package/dist/dsl/index.js
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./collections"), exports);
|
package/dist/dsl/types.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export type DataKind = 'integer' | 'smallint';
|
package/dist/dsl/types.js
DELETED
package/dist/next/index.d.ts
DELETED
package/dist/next/index.js
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.withCollections = void 0;
|
|
7
|
-
const child_process_1 = require("child_process");
|
|
8
|
-
const constants_1 = require("next/constants");
|
|
9
|
-
const path_1 = __importDefault(require("path"));
|
|
10
|
-
const withCollections = (phase, config) => {
|
|
11
|
-
const isDev = phase === constants_1.PHASE_DEVELOPMENT_SERVER;
|
|
12
|
-
if (isDev && !global.__collections_worker_started) {
|
|
13
|
-
global.__collections_worker_started = true;
|
|
14
|
-
const workerPath = path_1.default.join(__dirname, "../worker/index.js");
|
|
15
|
-
console.log("[withCollections] Spawning background worker:", workerPath);
|
|
16
|
-
(0, child_process_1.spawn)("node", [workerPath], {
|
|
17
|
-
stdio: "inherit",
|
|
18
|
-
});
|
|
19
|
-
}
|
|
20
|
-
return {
|
|
21
|
-
...config,
|
|
22
|
-
};
|
|
23
|
-
};
|
|
24
|
-
exports.withCollections = withCollections;
|