@deessejs/collections 0.0.35 → 0.0.37
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/config/index.d.ts +3 -7
- package/dist/config/index.js +2 -19
- package/dist/config/types.d.ts +1 -2
- package/dist/worker/index.d.ts +1 -0
- package/dist/worker/index.js +32 -4
- package/package.json +2 -1
package/dist/config/index.d.ts
CHANGED
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
import { InferSchema } from "../fields/types";
|
|
2
1
|
import { Config } from "./types";
|
|
3
|
-
export declare const defineConfig:
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
update: (id: string, data: Partial<InferSchema<Col["fields"]>>) => Promise<any>;
|
|
7
|
-
delete: (id: string) => Promise<void>;
|
|
8
|
-
}; };
|
|
2
|
+
export declare const defineConfig: (config: Config) => import("drizzle-orm/node-postgres").NodePgDatabase<Record<string, never>> & {
|
|
3
|
+
$client: import("pg").Pool;
|
|
4
|
+
};
|
package/dist/config/index.js
CHANGED
|
@@ -1,26 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.defineConfig = void 0;
|
|
4
|
-
const
|
|
4
|
+
const node_postgres_1 = require("drizzle-orm/node-postgres");
|
|
5
5
|
const defineConfig = (config) => {
|
|
6
|
-
|
|
7
|
-
const db = {};
|
|
8
|
-
for (const col of config.collections) {
|
|
9
|
-
db[col.slug] = {
|
|
10
|
-
create: async (data) => {
|
|
11
|
-
return (0, orchestrator_1.runOperation)("create", col, config.provider, { data });
|
|
12
|
-
},
|
|
13
|
-
read: async (id) => {
|
|
14
|
-
return (0, orchestrator_1.runOperation)("read", col, config.provider, { id });
|
|
15
|
-
},
|
|
16
|
-
update: async (id, data) => {
|
|
17
|
-
return (0, orchestrator_1.runOperation)("update", col, config.provider, { id, data });
|
|
18
|
-
},
|
|
19
|
-
delete: async (id) => {
|
|
20
|
-
return (0, orchestrator_1.runOperation)("delete", col, config.provider, { id });
|
|
21
|
-
},
|
|
22
|
-
};
|
|
23
|
-
}
|
|
6
|
+
const db = (0, node_postgres_1.drizzle)(config.databaseUrl);
|
|
24
7
|
return db;
|
|
25
8
|
};
|
|
26
9
|
exports.defineConfig = defineConfig;
|
package/dist/config/types.d.ts
CHANGED
|
@@ -2,10 +2,9 @@ import { Collection } from "../collections/types";
|
|
|
2
2
|
import { CollectionsCrud } from "../database/types";
|
|
3
3
|
import { Field, FieldTypeFinal } from "../fields";
|
|
4
4
|
import { Plugin } from "../plugins/types";
|
|
5
|
-
import { Provider } from "../providers/types";
|
|
6
5
|
import { UnionToIntersection } from "../utils/union-intersection";
|
|
7
6
|
export type Config = {
|
|
8
|
-
|
|
7
|
+
databaseUrl: string;
|
|
9
8
|
readonly collections: Collection[];
|
|
10
9
|
plugins?: Plugin[];
|
|
11
10
|
};
|
package/dist/worker/index.d.ts
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/worker/index.js
CHANGED
|
@@ -1,5 +1,33 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
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
|
+
const chokidar_1 = __importDefault(require("chokidar"));
|
|
7
|
+
const path_1 = __importDefault(require("path"));
|
|
8
|
+
const collectionsDir = path_1.default.join(process.cwd(), "src", "collections");
|
|
9
|
+
console.log(`[worker] Watching collections folder: ${collectionsDir}`);
|
|
10
|
+
const watcher = chokidar_1.default.watch(collectionsDir, {
|
|
11
|
+
persistent: true,
|
|
12
|
+
ignoreInitial: false,
|
|
13
|
+
depth: 2,
|
|
14
|
+
awaitWriteFinish: {
|
|
15
|
+
stabilityThreshold: 100,
|
|
16
|
+
pollInterval: 50,
|
|
17
|
+
},
|
|
18
|
+
});
|
|
19
|
+
watcher
|
|
20
|
+
.on("add", (filePath) => {
|
|
21
|
+
console.log(`[worker] File added: ${filePath}`);
|
|
22
|
+
})
|
|
23
|
+
.on("change", (filePath) => {
|
|
24
|
+
console.log(`[worker] File changed: ${filePath}`);
|
|
25
|
+
})
|
|
26
|
+
.on("unlink", (filePath) => {
|
|
27
|
+
console.log(`[worker] File removed: ${filePath}`);
|
|
28
|
+
})
|
|
29
|
+
.on("error", (err) => {
|
|
30
|
+
const error = err instanceof Error ? err : new Error(String(err));
|
|
31
|
+
console.error("[worker] Watcher error:", error);
|
|
32
|
+
});
|
|
33
|
+
console.log("[worker] Watcher started");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@deessejs/collections",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.37",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -63,6 +63,7 @@
|
|
|
63
63
|
"zod": "^4.1.12"
|
|
64
64
|
},
|
|
65
65
|
"dependencies": {
|
|
66
|
+
"chokidar": "^5.0.0",
|
|
66
67
|
"dotenv": "^17.2.3",
|
|
67
68
|
"drizzle-orm": "^0.45.0",
|
|
68
69
|
"pg": "^8.16.3"
|