@proseql/node 0.1.0 → 0.2.2
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/convenience.d.ts +37 -0
- package/dist/convenience.d.ts.map +1 -0
- package/dist/convenience.js +41 -0
- package/dist/convenience.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Convenience wrappers that eliminate manual codec/layer wiring.
|
|
3
|
+
*
|
|
4
|
+
* These functions infer codecs from the database config's file extensions
|
|
5
|
+
* and format overrides, so users don't need to manually select and wire codecs.
|
|
6
|
+
*/
|
|
7
|
+
import type { PluginError } from "@proseql/core";
|
|
8
|
+
import { type DatabaseConfig, type EffectDatabaseOptions, type EffectDatabasePersistenceConfig, type FormatCodec, type GenerateDatabaseWithPersistence, type MigrationError, type SerializationError, type SerializerRegistryService, type StorageAdapterService, type StorageError, type UnsupportedFormatError, type ValidationError } from "@proseql/core";
|
|
9
|
+
import { Effect, Layer, type Scope } from "effect";
|
|
10
|
+
/**
|
|
11
|
+
* Build a persistence Layer from a database config.
|
|
12
|
+
*
|
|
13
|
+
* Infers codecs from file extensions and `format` overrides, combines with
|
|
14
|
+
* NodeStorageLayer. Optionally accepts extra codecs to merge in.
|
|
15
|
+
*
|
|
16
|
+
* @param config - Database configuration to infer codecs from
|
|
17
|
+
* @param options - Optional extra codecs to include alongside inferred ones
|
|
18
|
+
* @returns A Layer providing StorageAdapter + SerializerRegistry
|
|
19
|
+
*/
|
|
20
|
+
export declare const makeNodePersistenceLayer: <Config extends DatabaseConfig>(config: Config, options?: {
|
|
21
|
+
readonly codecs?: ReadonlyArray<FormatCodec>;
|
|
22
|
+
}) => Layer.Layer<StorageAdapterService | SerializerRegistryService>;
|
|
23
|
+
/**
|
|
24
|
+
* Create a persistent database with Node.js file storage — no manual layer wiring.
|
|
25
|
+
*
|
|
26
|
+
* Codecs are inferred from file extensions and `format` overrides in the config.
|
|
27
|
+
* The returned Effect only requires `Scope` (for cleanup); storage and serialization
|
|
28
|
+
* are provided internally.
|
|
29
|
+
*
|
|
30
|
+
* @param config - Database configuration (schemas, file paths, relationships, etc.)
|
|
31
|
+
* @param initialData - Optional initial data arrays per collection
|
|
32
|
+
* @param persistenceConfig - Optional persistence tuning (debounce, plugin codecs)
|
|
33
|
+
* @param options - Optional database options (plugins)
|
|
34
|
+
* @returns Effect yielding a fully wired persistent database
|
|
35
|
+
*/
|
|
36
|
+
export declare const createNodeDatabase: <Config extends DatabaseConfig>(config: Config, initialData?: { readonly [K in keyof Config]?: ReadonlyArray<Record<string, unknown>>; }, persistenceConfig?: EffectDatabasePersistenceConfig, options?: EffectDatabaseOptions) => Effect.Effect<GenerateDatabaseWithPersistence<Config>, MigrationError | StorageError | SerializationError | UnsupportedFormatError | ValidationError | PluginError, Scope.Scope>;
|
|
37
|
+
//# sourceMappingURL=convenience.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"convenience.d.ts","sourceRoot":"","sources":["../src/convenience.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AACjD,OAAO,EAEN,KAAK,cAAc,EACnB,KAAK,qBAAqB,EAC1B,KAAK,+BAA+B,EACpC,KAAK,WAAW,EAChB,KAAK,+BAA+B,EAEpC,KAAK,cAAc,EAEnB,KAAK,kBAAkB,EACvB,KAAK,yBAAyB,EAC9B,KAAK,qBAAqB,EAC1B,KAAK,YAAY,EACjB,KAAK,sBAAsB,EAC3B,KAAK,eAAe,EACpB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,KAAK,EAAE,MAAM,QAAQ,CAAC;AAGnD;;;;;;;;;GASG;AACH,eAAO,MAAM,wBAAwB,GAAI,MAAM,SAAS,cAAc,EACrE,QAAQ,MAAM,EACd,UAAU;IAAE,QAAQ,CAAC,MAAM,CAAC,EAAE,aAAa,CAAC,WAAW,CAAC,CAAA;CAAE,KACxD,KAAK,CAAC,KAAK,CAAC,qBAAqB,GAAG,yBAAyB,CAG/D,CAAC;AAEF;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,kBAAkB,GAAI,MAAM,SAAS,cAAc,EAC/D,QAAQ,MAAM,EACd,cAAc,EACb,QAAQ,EAAE,CAAC,IAAI,MAAM,MAAM,CAAC,CAAC,EAAE,aAAa,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GACrE,EACD,oBAAoB,+BAA+B,EACnD,UAAU,qBAAqB,KAC7B,MAAM,CAAC,MAAM,CACf,+BAA+B,CAAC,MAAM,CAAC,EACrC,cAAc,GACd,YAAY,GACZ,kBAAkB,GAClB,sBAAsB,GACtB,eAAe,GACf,WAAW,EACb,KAAK,CAAC,KAAK,CASX,CAAC"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Convenience wrappers that eliminate manual codec/layer wiring.
|
|
3
|
+
*
|
|
4
|
+
* These functions infer codecs from the database config's file extensions
|
|
5
|
+
* and format overrides, so users don't need to manually select and wire codecs.
|
|
6
|
+
*/
|
|
7
|
+
import { createPersistentEffectDatabase, inferCodecsFromConfig, makeSerializerLayer, } from "@proseql/core";
|
|
8
|
+
import { Effect, Layer } from "effect";
|
|
9
|
+
import { NodeStorageLayer } from "./node-adapter-layer.js";
|
|
10
|
+
/**
|
|
11
|
+
* Build a persistence Layer from a database config.
|
|
12
|
+
*
|
|
13
|
+
* Infers codecs from file extensions and `format` overrides, combines with
|
|
14
|
+
* NodeStorageLayer. Optionally accepts extra codecs to merge in.
|
|
15
|
+
*
|
|
16
|
+
* @param config - Database configuration to infer codecs from
|
|
17
|
+
* @param options - Optional extra codecs to include alongside inferred ones
|
|
18
|
+
* @returns A Layer providing StorageAdapter + SerializerRegistry
|
|
19
|
+
*/
|
|
20
|
+
export const makeNodePersistenceLayer = (config, options) => {
|
|
21
|
+
const codecs = options?.codecs ?? inferCodecsFromConfig(config);
|
|
22
|
+
return Layer.merge(NodeStorageLayer, makeSerializerLayer(codecs));
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* Create a persistent database with Node.js file storage — no manual layer wiring.
|
|
26
|
+
*
|
|
27
|
+
* Codecs are inferred from file extensions and `format` overrides in the config.
|
|
28
|
+
* The returned Effect only requires `Scope` (for cleanup); storage and serialization
|
|
29
|
+
* are provided internally.
|
|
30
|
+
*
|
|
31
|
+
* @param config - Database configuration (schemas, file paths, relationships, etc.)
|
|
32
|
+
* @param initialData - Optional initial data arrays per collection
|
|
33
|
+
* @param persistenceConfig - Optional persistence tuning (debounce, plugin codecs)
|
|
34
|
+
* @param options - Optional database options (plugins)
|
|
35
|
+
* @returns Effect yielding a fully wired persistent database
|
|
36
|
+
*/
|
|
37
|
+
export const createNodeDatabase = (config, initialData, persistenceConfig, options) => {
|
|
38
|
+
const layer = makeNodePersistenceLayer(config);
|
|
39
|
+
return createPersistentEffectDatabase(config, initialData, persistenceConfig, options).pipe(Effect.provide(layer));
|
|
40
|
+
};
|
|
41
|
+
//# sourceMappingURL=convenience.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"convenience.js","sourceRoot":"","sources":["../src/convenience.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EACN,8BAA8B,EAM9B,qBAAqB,EAErB,mBAAmB,GAOnB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,MAAM,EAAE,KAAK,EAAc,MAAM,QAAQ,CAAC;AACnD,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAE3D;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG,CACvC,MAAc,EACd,OAA0D,EACO,EAAE;IACnE,MAAM,MAAM,GAAG,OAAO,EAAE,MAAM,IAAI,qBAAqB,CAAC,MAAM,CAAC,CAAC;IAChE,OAAO,KAAK,CAAC,KAAK,CAAC,gBAAgB,EAAE,mBAAmB,CAAC,MAAM,CAAC,CAAC,CAAC;AACnE,CAAC,CAAC;AAEF;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,CACjC,MAAc,EACd,WAEC,EACD,iBAAmD,EACnD,OAA+B,EAU9B,EAAE;IACH,MAAM,KAAK,GAAG,wBAAwB,CAAC,MAAM,CAAC,CAAC;IAC/C,OAAO,8BAA8B,CACpC,MAAM,EACN,WAAW,EACX,iBAAiB,EACjB,OAAO,CACP,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC;AAC/B,CAAC,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
* Re-exports everything from @proseql/core plus Node.js filesystem storage.
|
|
5
5
|
*/
|
|
6
6
|
export * from "@proseql/core";
|
|
7
|
+
export { createNodeDatabase, makeNodePersistenceLayer, } from "./convenience.js";
|
|
7
8
|
export type { NodeAdapterConfig } from "./node-adapter-layer.js";
|
|
8
9
|
export { makeNodeStorageLayer, NodeStorageLayer, } from "./node-adapter-layer.js";
|
|
9
10
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,cAAc,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,cAAc,eAAe,CAAC;AAE9B,OAAO,EACN,kBAAkB,EAClB,wBAAwB,GACxB,MAAM,kBAAkB,CAAC;AAC1B,YAAY,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAEjE,OAAO,EACN,oBAAoB,EACpB,gBAAgB,GAChB,MAAM,yBAAyB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -5,6 +5,8 @@
|
|
|
5
5
|
*/
|
|
6
6
|
// Re-export everything from core
|
|
7
7
|
export * from "@proseql/core";
|
|
8
|
+
// Convenience wrappers (config-driven, no manual layer wiring)
|
|
9
|
+
export { createNodeDatabase, makeNodePersistenceLayer, } from "./convenience.js";
|
|
8
10
|
// Export Node.js storage adapter
|
|
9
11
|
export { makeNodeStorageLayer, NodeStorageLayer, } from "./node-adapter-layer.js";
|
|
10
12
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,iCAAiC;AACjC,cAAc,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,iCAAiC;AACjC,cAAc,eAAe,CAAC;AAC9B,+DAA+D;AAC/D,OAAO,EACN,kBAAkB,EAClB,wBAAwB,GACxB,MAAM,kBAAkB,CAAC;AAE1B,iCAAiC;AACjC,OAAO,EACN,oBAAoB,EACpB,gBAAgB,GAChB,MAAM,yBAAyB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@proseql/node",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.2",
|
|
4
4
|
"description": "Node.js file system adapter for ProseQL, re-exports core plus NodeStorageLayer",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"scripts": {
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
},
|
|
49
49
|
"sideEffects": false,
|
|
50
50
|
"dependencies": {
|
|
51
|
-
"@proseql/core": "
|
|
51
|
+
"@proseql/core": "^0.2.2"
|
|
52
52
|
},
|
|
53
53
|
"peerDependencies": {
|
|
54
54
|
"effect": "^3.15.2"
|