aether-cache 0.1.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.
Files changed (63) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +124 -0
  3. package/dist/cli/commands/init.d.ts +4 -0
  4. package/dist/cli/commands/init.d.ts.map +1 -0
  5. package/dist/cli/commands/init.js +17 -0
  6. package/dist/cli/commands/init.js.map +1 -0
  7. package/dist/cli/commands/insert.d.ts +4 -0
  8. package/dist/cli/commands/insert.d.ts.map +1 -0
  9. package/dist/cli/commands/insert.js +18 -0
  10. package/dist/cli/commands/insert.js.map +1 -0
  11. package/dist/cli/commands/new-schema.d.ts +4 -0
  12. package/dist/cli/commands/new-schema.d.ts.map +1 -0
  13. package/dist/cli/commands/new-schema.js +27 -0
  14. package/dist/cli/commands/new-schema.js.map +1 -0
  15. package/dist/cli/index.d.ts +3 -0
  16. package/dist/cli/index.d.ts.map +1 -0
  17. package/dist/cli/index.js +12 -0
  18. package/dist/cli/index.js.map +1 -0
  19. package/dist/database.d.ts +32 -0
  20. package/dist/database.d.ts.map +1 -0
  21. package/dist/database.js +178 -0
  22. package/dist/database.js.map +1 -0
  23. package/dist/errors.d.ts +27 -0
  24. package/dist/errors.d.ts.map +1 -0
  25. package/dist/errors.js +55 -0
  26. package/dist/errors.js.map +1 -0
  27. package/dist/index.d.ts +4 -0
  28. package/dist/index.d.ts.map +1 -0
  29. package/dist/index.js +16 -0
  30. package/dist/index.js.map +1 -0
  31. package/dist/internal/collections/CollectionManager.d.ts +19 -0
  32. package/dist/internal/collections/CollectionManager.d.ts.map +1 -0
  33. package/dist/internal/collections/CollectionManager.js +102 -0
  34. package/dist/internal/collections/CollectionManager.js.map +1 -0
  35. package/dist/internal/identity/RecordIdentityManager.d.ts +8 -0
  36. package/dist/internal/identity/RecordIdentityManager.d.ts.map +1 -0
  37. package/dist/internal/identity/RecordIdentityManager.js +54 -0
  38. package/dist/internal/identity/RecordIdentityManager.js.map +1 -0
  39. package/dist/internal/indexing/IndexManager.d.ts +14 -0
  40. package/dist/internal/indexing/IndexManager.d.ts.map +1 -0
  41. package/dist/internal/indexing/IndexManager.js +65 -0
  42. package/dist/internal/indexing/IndexManager.js.map +1 -0
  43. package/dist/internal/persistence/JsonPersistenceAdapter.d.ts +20 -0
  44. package/dist/internal/persistence/JsonPersistenceAdapter.d.ts.map +1 -0
  45. package/dist/internal/persistence/JsonPersistenceAdapter.js +85 -0
  46. package/dist/internal/persistence/JsonPersistenceAdapter.js.map +1 -0
  47. package/dist/internal/platform/storagePath.d.ts +2 -0
  48. package/dist/internal/platform/storagePath.d.ts.map +1 -0
  49. package/dist/internal/platform/storagePath.js +21 -0
  50. package/dist/internal/platform/storagePath.js.map +1 -0
  51. package/dist/internal/schema/SchemaManager.d.ts +11 -0
  52. package/dist/internal/schema/SchemaManager.d.ts.map +1 -0
  53. package/dist/internal/schema/SchemaManager.js +41 -0
  54. package/dist/internal/schema/SchemaManager.js.map +1 -0
  55. package/dist/internal/validation/schema.d.ts +3 -0
  56. package/dist/internal/validation/schema.d.ts.map +1 -0
  57. package/dist/internal/validation/schema.js +27 -0
  58. package/dist/internal/validation/schema.js.map +1 -0
  59. package/dist/types.d.ts +57 -0
  60. package/dist/types.d.ts.map +1 -0
  61. package/dist/types.js +3 -0
  62. package/dist/types.js.map +1 -0
  63. package/package.json +60 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Sarath
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,124 @@
1
+ # AetherCache
2
+
3
+ AetherCache is a lightweight embedded TypeScript database for learning and building
4
+ single-process storage engines. It supports collection-based records, schema
5
+ validation, primary-key indexing, and optional JSON persistence.
6
+
7
+ ## Install
8
+
9
+ ```sh
10
+ npm install aether-cache
11
+ ```
12
+
13
+ ## Quick Start
14
+
15
+ ```ts
16
+ import { AetherCache } from "aether-cache";
17
+
18
+ interface User {
19
+ name: string;
20
+ age: number;
21
+ email: string;
22
+ }
23
+
24
+ const db = new AetherCache<User>();
25
+
26
+ await db.createCollection("users", {
27
+ name: "string",
28
+ age: "number",
29
+ email: "string",
30
+ });
31
+
32
+ const id = await db.insert("users", {
33
+ name: "Ada Lovelace",
34
+ age: 36,
35
+ email: "ada@example.com",
36
+ });
37
+
38
+ const user = db.get("users", id as string);
39
+ console.log(user?.data);
40
+ ```
41
+
42
+ ## Persistence
43
+
44
+ Persistence is opt-in. When enabled, AetherCache writes JSON files using an
45
+ atomic temp-file-and-rename strategy.
46
+
47
+ ```ts
48
+ const db = new AetherCache<User>({
49
+ persist: true,
50
+ storageDir: "./.aether-cache",
51
+ });
52
+
53
+ await db.initialize();
54
+ ```
55
+
56
+ ## Public API
57
+
58
+ ### `new AetherCache<TRecord>(options?)`
59
+
60
+ Creates an embedded database instance.
61
+
62
+ Options:
63
+
64
+ - `persist`: enables JSON persistence when `true`.
65
+ - `storageDir`: overrides the default OS-specific storage directory.
66
+
67
+ ### `createCollection(name, schema, metadata?)`
68
+
69
+ Creates a collection and associates a schema with it.
70
+
71
+ ### `deleteCollection(name)`
72
+
73
+ Deletes a collection, its records, and its live indexes.
74
+
75
+ ### `getCollection(name)`
76
+
77
+ Returns collection metadata, schema, records, and index metadata.
78
+
79
+ ### `insert(collection, value, id?)`
80
+
81
+ Validates and inserts a record. Returns the primary key, or `false` when the
82
+ requested ID already exists.
83
+
84
+ ### `get(collection, id)`
85
+
86
+ Reads a record by primary key through the collection primary-key index.
87
+
88
+ ### `update(collection, id, value)`
89
+
90
+ Validates and replaces record data while preserving record identity.
91
+
92
+ ### `delete(collection, id)`
93
+
94
+ Deletes a record from storage and synchronizes the primary-key index.
95
+
96
+ ### `filter(collection, predicate)`
97
+
98
+ Filters records inside a single collection.
99
+
100
+ ## Features
101
+
102
+ - Collection/table-oriented storage model
103
+ - Collection-owned schemas
104
+ - Unique record identity with generated or explicit primary keys
105
+ - Hash-based primary-key indexing
106
+ - Optional JSON persistence
107
+ - Typed custom errors
108
+ - TypeScript declaration output
109
+ - Embedded single-process architecture
110
+
111
+ ## Package Notes
112
+
113
+ The public package entry point is `src/index.ts`, compiled to `dist/index.js`.
114
+ Only stable APIs, errors, and public types are exported. Implementation managers
115
+ live under `src/internal` and are not part of the public contract.
116
+
117
+ ## Versioning Recommendation
118
+
119
+ Use `0.x` versions while the educational API is still evolving. Move to `1.0.0`
120
+ after collection, CRUD, persistence, and query APIs are stable.
121
+
122
+ ## License
123
+
124
+ MIT
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env node
2
+ import { Command } from "commander";
3
+ export declare const instantiateCommand: Command;
4
+ //# sourceMappingURL=init.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/init.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAGpC,eAAO,MAAM,kBAAkB,SAS3B,CAAC"}
@@ -0,0 +1,17 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.instantiateCommand = void 0;
5
+ const commander_1 = require("commander");
6
+ const index_1 = require("../../index");
7
+ exports.instantiateCommand = new commander_1.Command()
8
+ .command("instantiate")
9
+ .alias("init")
10
+ .description("Instantiate database")
11
+ .action(async () => {
12
+ const db = new index_1.AetherCache({ persist: true });
13
+ await db.initialize();
14
+ await db.flush();
15
+ console.log("AetherCache initialized");
16
+ });
17
+ //# sourceMappingURL=init.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"init.js","sourceRoot":"","sources":["../../../src/cli/commands/init.ts"],"names":[],"mappings":";;;;AACA,yCAAoC;AACpC,uCAA0C;AAE7B,QAAA,kBAAkB,GAAG,IAAI,mBAAO,EAAE;KAC5C,OAAO,CAAC,aAAa,CAAC;KACtB,KAAK,CAAC,MAAM,CAAC;KACb,WAAW,CAAC,sBAAsB,CAAC;KACnC,MAAM,CAAC,KAAK,IAAI,EAAE;IACjB,MAAM,EAAE,GAAG,IAAI,mBAAW,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC;IAC9C,MAAM,EAAE,CAAC,UAAU,EAAE,CAAC;IACtB,MAAM,EAAE,CAAC,KAAK,EAAE,CAAC;IACjB,OAAO,CAAC,GAAG,CAAC,yBAAyB,CAAC,CAAC;AACzC,CAAC,CAAC,CAAC"}
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env node
2
+ import { Command } from "commander";
3
+ export declare const insertData: Command;
4
+ //# sourceMappingURL=insert.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"insert.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/insert.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAKpC,eAAO,MAAM,UAAU,SASnB,CAAC"}
@@ -0,0 +1,18 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.insertData = void 0;
5
+ const commander_1 = require("commander");
6
+ const index_1 = require("../../index");
7
+ const db = new index_1.AetherCache({ persist: true });
8
+ exports.insertData = new commander_1.Command()
9
+ .command("insert")
10
+ .argument("<table name>", "table name")
11
+ .argument("<...values>", "values")
12
+ .description("insert data into database")
13
+ .action(async (collection, values) => {
14
+ await db.initialize();
15
+ const id = await db.insert(collection, JSON.parse(values.join(" ")));
16
+ console.log(id);
17
+ });
18
+ //# sourceMappingURL=insert.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"insert.js","sourceRoot":"","sources":["../../../src/cli/commands/insert.ts"],"names":[],"mappings":";;;;AACA,yCAAoC;AACpC,uCAA0C;AAE1C,MAAM,EAAE,GAAG,IAAI,mBAAW,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC;AAEjC,QAAA,UAAU,GAAG,IAAI,mBAAO,EAAE;KACpC,OAAO,CAAC,QAAQ,CAAC;KACjB,QAAQ,CAAC,cAAc,EAAE,YAAY,CAAC;KACtC,QAAQ,CAAC,aAAa,EAAE,QAAQ,CAAC;KACjC,WAAW,CAAC,2BAA2B,CAAC;KACxC,MAAM,CAAC,KAAK,EAAE,UAAU,EAAE,MAAM,EAAE,EAAE;IACnC,MAAM,EAAE,CAAC,UAAU,EAAE,CAAC;IACtB,MAAM,EAAE,GAAG,MAAM,EAAE,CAAC,MAAM,CAAC,UAAU,EAAE,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;IACrE,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env node
2
+ import { Command } from "commander";
3
+ export declare const createNewSchema: Command;
4
+ //# sourceMappingURL=new-schema.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"new-schema.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/new-schema.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAKpC,eAAO,MAAM,eAAe,SAmBxB,CAAC"}
@@ -0,0 +1,27 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.createNewSchema = void 0;
5
+ const commander_1 = require("commander");
6
+ const index_1 = require("../../index");
7
+ const db = new index_1.AetherCache({ persist: true });
8
+ exports.createNewSchema = new commander_1.Command()
9
+ .command("schema")
10
+ .argument("<schema>", "collection schema name")
11
+ .argument("<...values>", "values")
12
+ .description("create or update collection schema")
13
+ .action(async (schema, values) => {
14
+ await db.initialize();
15
+ try {
16
+ await db.createCollection(schema, JSON.parse(values.join(" ")));
17
+ console.log(`Collection '${schema}' created`);
18
+ }
19
+ catch (error) {
20
+ if (error instanceof index_1.CollectionExistsError) {
21
+ console.log(`Collection '${schema}' already exists`);
22
+ return;
23
+ }
24
+ throw error;
25
+ }
26
+ });
27
+ //# sourceMappingURL=new-schema.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"new-schema.js","sourceRoot":"","sources":["../../../src/cli/commands/new-schema.ts"],"names":[],"mappings":";;;;AACA,yCAAoC;AACpC,uCAAiE;AAEjE,MAAM,EAAE,GAAG,IAAI,mBAAW,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC;AAEjC,QAAA,eAAe,GAAG,IAAI,mBAAO,EAAE;KACzC,OAAO,CAAC,QAAQ,CAAC;KACjB,QAAQ,CAAC,UAAU,EAAE,wBAAwB,CAAC;KAC9C,QAAQ,CAAC,aAAa,EAAE,QAAQ,CAAC;KACjC,WAAW,CAAC,oCAAoC,CAAC;KACjD,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,EAAE;IAC/B,MAAM,EAAE,CAAC,UAAU,EAAE,CAAC;IAEtB,IAAI,CAAC;QACH,MAAM,EAAE,CAAC,gBAAgB,CAAC,MAAM,EAAE,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;QAChE,OAAO,CAAC,GAAG,CAAC,eAAe,MAAM,WAAW,CAAC,CAAC;IAChD,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAI,KAAK,YAAY,6BAAqB,EAAE,CAAC;YAC3C,OAAO,CAAC,GAAG,CAAC,eAAe,MAAM,kBAAkB,CAAC,CAAC;YACrD,OAAO;QACT,CAAC;QAED,MAAM,KAAK,CAAC;IACd,CAAC;AACH,CAAC,CAAC,CAAC"}
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ export {};
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/cli/index.ts"],"names":[],"mappings":""}
@@ -0,0 +1,12 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ const commander_1 = require("commander");
5
+ const init_1 = require("./commands/init");
6
+ const new_schema_1 = require("./commands/new-schema");
7
+ const insert_1 = require("./commands/insert");
8
+ commander_1.program.addCommand(init_1.instantiateCommand);
9
+ commander_1.program.addCommand(new_schema_1.createNewSchema);
10
+ commander_1.program.addCommand(insert_1.insertData);
11
+ commander_1.program.parse(process.argv);
12
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/cli/index.ts"],"names":[],"mappings":";;;AAEA,yCAAoC;AACpC,0CAAqD;AACrD,sDAAwD;AACxD,8CAA+C;AAE/C,mBAAO,CAAC,UAAU,CAAC,yBAAkB,CAAC,CAAC;AACvC,mBAAO,CAAC,UAAU,CAAC,4BAAe,CAAC,CAAC;AACpC,mBAAO,CAAC,UAAU,CAAC,mBAAU,CAAC,CAAC;AAE/B,mBAAO,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC"}
@@ -0,0 +1,32 @@
1
+ import { AetherCacheOptions, Collection, CollectionName, CollectionMetadata, FilterPredicate, RecordId, RecordData, SchemaDefinition, SchemaRegistration, StoredRecord } from "./types";
2
+ export declare class AetherCache<TRecord extends RecordData = RecordData> {
3
+ private dataStore;
4
+ private readonly persist;
5
+ private readonly persistence?;
6
+ private readonly recordIdentityManager;
7
+ private readonly indexManager;
8
+ private readonly schemaManager;
9
+ private readonly collectionManager;
10
+ constructor(options?: AetherCacheOptions);
11
+ initialize(): Promise<void>;
12
+ createCollection(collectionName: CollectionName, schema: SchemaDefinition, metadata?: Partial<CollectionMetadata>): Promise<Collection<TRecord>>;
13
+ deleteCollection(collectionName: CollectionName): Promise<boolean>;
14
+ getCollection(collectionName: CollectionName): Collection<TRecord>;
15
+ listCollections(): Collection<TRecord>[];
16
+ listSchemas(): SchemaRegistration[];
17
+ insert(collectionName: CollectionName, value: TRecord, recordId?: RecordId): Promise<RecordId | false>;
18
+ get(collectionName: CollectionName, recordId: RecordId): StoredRecord<TRecord> | undefined;
19
+ update(collectionName: CollectionName, recordId: RecordId, value: TRecord): Promise<boolean>;
20
+ delete(collectionName: CollectionName, recordId: RecordId): Promise<boolean>;
21
+ filter(collectionName: CollectionName, filterFunction: FilterPredicate<TRecord>): Array<TRecord & {
22
+ id: RecordId;
23
+ }>;
24
+ flush(): Promise<void>;
25
+ private persistState;
26
+ private initializeIndexes;
27
+ private normalizeStore;
28
+ private isDatabaseStore;
29
+ private createEmptyCollection;
30
+ }
31
+ export { AetherCache as microDB };
32
+ //# sourceMappingURL=database.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"database.d.ts","sourceRoot":"","sources":["../src/database.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,EAClB,UAAU,EACV,cAAc,EACd,kBAAkB,EAElB,eAAe,EACf,QAAQ,EACR,UAAU,EACV,gBAAgB,EAChB,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AsBb,MAAM,CACV,cAAc,EAAE,cAAc,EAC9B,QAAQ,EAAE,QAAQ,GACjB,OAAO,CAAC,OAAO,CAAC;IAcnB,MAAM,CACJ,cAAc,EAAE,cAAc,EAC9B,cAAc,EAAE,eAAe,CAAC,OAAO,CAAC,GACvC,KAAK,CAAC,OAAO,GAAG;QAAE,EAAE,EAAE,QAAQ,CAAA;KAAE,CAAC;IAW9B,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;YAId,YAAY;IAY1B,OAAO,CAAC,iBAAiB;IAQzB,OAAO,CAAC,cAAc;IAmBtB,OAAO,CAAC,eAAe;IASvB,OAAO,CAAC,qBAAqB;CAkB9B;AAED,OAAO,EAAE,WAAW,IAAI,OAAO,EAAE,CAAC"}
@@ -0,0 +1,178 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.microDB = exports.AetherCache = void 0;
4
+ const errors_1 = require("./errors");
5
+ const CollectionManager_1 = require("./internal/collections/CollectionManager");
6
+ const IndexManager_1 = require("./internal/indexing/IndexManager");
7
+ const RecordIdentityManager_1 = require("./internal/identity/RecordIdentityManager");
8
+ const JsonPersistenceAdapter_1 = require("./internal/persistence/JsonPersistenceAdapter");
9
+ const SchemaManager_1 = require("./internal/schema/SchemaManager");
10
+ class AetherCache {
11
+ dataStore;
12
+ persist;
13
+ persistence;
14
+ recordIdentityManager;
15
+ indexManager;
16
+ schemaManager;
17
+ collectionManager;
18
+ constructor(options = {}) {
19
+ this.persist = options.persist ?? false;
20
+ this.persistence = this.persist
21
+ ? new JsonPersistenceAdapter_1.JsonPersistenceAdapter(options.storageDir)
22
+ : undefined;
23
+ this.dataStore = { collections: {} };
24
+ this.recordIdentityManager = new RecordIdentityManager_1.RecordIdentityManager();
25
+ this.indexManager = new IndexManager_1.IndexManager();
26
+ this.collectionManager = new CollectionManager_1.CollectionManager(this.dataStore.collections);
27
+ this.schemaManager = new SchemaManager_1.SchemaManager();
28
+ this.schemaManager.bindCollectionManager(this.collectionManager);
29
+ }
30
+ async initialize() {
31
+ if (!this.persistence) {
32
+ return;
33
+ }
34
+ const snapshot = await this.persistence.load();
35
+ this.dataStore = this.normalizeStore(snapshot.data, snapshot.schemas);
36
+ this.collectionManager.setCollections(this.dataStore.collections);
37
+ this.dataStore.collections = this.collectionManager.getCollections();
38
+ this.initializeIndexes();
39
+ this.schemaManager.bindCollectionManager(this.collectionManager);
40
+ }
41
+ async createCollection(collectionName, schema, metadata) {
42
+ const collection = this.collectionManager.createCollection(collectionName, schema, metadata);
43
+ this.indexManager.initializeCollection(collection);
44
+ await this.persistState();
45
+ return collection;
46
+ }
47
+ async deleteCollection(collectionName) {
48
+ const deleted = this.collectionManager.deleteCollection(collectionName);
49
+ if (deleted) {
50
+ this.indexManager.dropCollection(collectionName);
51
+ await this.persistState();
52
+ }
53
+ return deleted;
54
+ }
55
+ getCollection(collectionName) {
56
+ const collection = this.collectionManager.getCollection(collectionName);
57
+ this.indexManager.ensureCollection(collection);
58
+ return collection;
59
+ }
60
+ listCollections() {
61
+ return Object.values(this.collectionManager.getCollections());
62
+ }
63
+ listSchemas() {
64
+ return this.schemaManager.listSchemas();
65
+ }
66
+ async insert(collectionName, value, recordId) {
67
+ const collection = this.getCollection(collectionName);
68
+ this.schemaManager.validate(collectionName, value);
69
+ let record;
70
+ try {
71
+ record = this.recordIdentityManager.createRecord(collection, value, recordId);
72
+ }
73
+ catch (error) {
74
+ if (error instanceof errors_1.DuplicateRecordIdError) {
75
+ return false;
76
+ }
77
+ throw error;
78
+ }
79
+ collection.records[record.id] = record;
80
+ this.indexManager.indexRecord(collectionName, record);
81
+ this.collectionManager.touchCollection(collectionName);
82
+ await this.persistState();
83
+ return record.id;
84
+ }
85
+ get(collectionName, recordId) {
86
+ const collection = this.collectionManager.getCollection(collectionName);
87
+ this.indexManager.ensureCollection(collection);
88
+ return this.indexManager.getByPrimaryKey(collectionName, recordId);
89
+ }
90
+ async update(collectionName, recordId, value) {
91
+ const collection = this.getCollection(collectionName);
92
+ if (!this.indexManager.hasPrimaryKey(collectionName, recordId)) {
93
+ return false;
94
+ }
95
+ this.schemaManager.validate(collectionName, value);
96
+ collection.records[recordId] = this.recordIdentityManager.normalizeRecord(recordId, {
97
+ ...collection.records[recordId],
98
+ data: value,
99
+ });
100
+ this.indexManager.updateRecord(collectionName, collection.records[recordId]);
101
+ this.collectionManager.touchCollection(collectionName);
102
+ await this.persistState();
103
+ return true;
104
+ }
105
+ async delete(collectionName, recordId) {
106
+ const collection = this.getCollection(collectionName);
107
+ if (!this.indexManager.hasPrimaryKey(collectionName, recordId)) {
108
+ throw new errors_1.RecordNotFoundError(recordId);
109
+ }
110
+ delete collection.records[recordId];
111
+ this.indexManager.deleteRecord(collectionName, recordId);
112
+ this.collectionManager.touchCollection(collectionName);
113
+ await this.persistState();
114
+ return true;
115
+ }
116
+ filter(collectionName, filterFunction) {
117
+ const collection = this.getCollection(collectionName);
118
+ return Object.values(collection.records)
119
+ .map((record) => ({
120
+ id: record.id,
121
+ ...record.data,
122
+ }))
123
+ .filter(filterFunction);
124
+ }
125
+ async flush() {
126
+ await this.persistState();
127
+ }
128
+ async persistState() {
129
+ if (!this.persistence) {
130
+ return;
131
+ }
132
+ this.dataStore.collections = this.collectionManager.getCollections();
133
+ await this.persistence.save({
134
+ data: this.dataStore,
135
+ schemas: this.schemaManager.listSchemas(),
136
+ });
137
+ }
138
+ initializeIndexes() {
139
+ Object.values(this.collectionManager.getCollections()).forEach((collection) => {
140
+ this.indexManager.initializeCollection(collection);
141
+ });
142
+ }
143
+ normalizeStore(dataFromDisk, schemasFromDisk) {
144
+ const store = { collections: {} };
145
+ if (this.isDatabaseStore(dataFromDisk)) {
146
+ return dataFromDisk;
147
+ }
148
+ if (Array.isArray(schemasFromDisk)) {
149
+ schemasFromDisk.forEach(({ name, schema }) => {
150
+ store.collections[name] = this.createEmptyCollection(name, schema);
151
+ });
152
+ }
153
+ return store;
154
+ }
155
+ isDatabaseStore(value) {
156
+ return (typeof value === "object" &&
157
+ value !== null &&
158
+ "collections" in value &&
159
+ typeof value.collections === "object");
160
+ }
161
+ createEmptyCollection(name, schema) {
162
+ const now = new Date().toISOString();
163
+ return {
164
+ name,
165
+ schema,
166
+ metadata: {
167
+ createdAt: now,
168
+ updatedAt: now,
169
+ recordCount: 0,
170
+ },
171
+ records: {},
172
+ indexes: {},
173
+ };
174
+ }
175
+ }
176
+ exports.AetherCache = AetherCache;
177
+ exports.microDB = AetherCache;
178
+ //# sourceMappingURL=database.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"database.js","sourceRoot":"","sources":["../src/database.ts"],"names":[],"mappings":";;;AAaA,qCAAuE;AACvE,gFAA6E;AAC7E,mEAAgE;AAChE,qFAAkF;AAClF,0FAAuF;AACvF,mEAAgE;AAEhE,MAAa,WAAW;IACd,SAAS,CAAyB;IACzB,OAAO,CAAU;IACjB,WAAW,CAAmC;IAC9C,qBAAqB,CAAwB;IAC7C,YAAY,CAAwB;IACpC,aAAa,CAAyB;IACtC,iBAAiB,CAA6B;IAE/D,YAAY,UAA8B,EAAE;QAC1C,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,OAAO,IAAI,KAAK,CAAC;QACxC,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,OAAO;YAC7B,CAAC,CAAC,IAAI,+CAAsB,CAAU,OAAO,CAAC,UAAU,CAAC;YACzD,CAAC,CAAC,SAAS,CAAC;QACd,IAAI,CAAC,SAAS,GAAG,EAAE,WAAW,EAAE,EAAE,EAAE,CAAC;QACrC,IAAI,CAAC,qBAAqB,GAAG,IAAI,6CAAqB,EAAE,CAAC;QACzD,IAAI,CAAC,YAAY,GAAG,IAAI,2BAAY,EAAE,CAAC;QACvC,IAAI,CAAC,iBAAiB,GAAG,IAAI,qCAAiB,CAAC,IAAI,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC;QAC3E,IAAI,CAAC,aAAa,GAAG,IAAI,6BAAa,EAAE,CAAC;QACzC,IAAI,CAAC,aAAa,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RECORD_ID" | "RECORD_NOT_FOUND" | "SCHEMA_NOT_FOUND" | "VALIDATION_ERROR" | "PERSISTENCE_ERROR";
2
+ export declare class AetherCacheError extends Error {
3
+ readonly code: AetherCacheErrorCode;
4
+ constructor(code: AetherCacheErrorCode, message: string);
5
+ }
6
+ export declare class CollectionExistsError extends AetherCacheError {
7
+ constructor(collectionName: string);
8
+ }
9
+ export declare class CollectionNotFoundError extends AetherCacheError {
10
+ constructor(collectionName: string);
11
+ }
12
+ export declare class DuplicateRecordIdError extends AetherCacheError {
13
+ constructor(recordId: string);
14
+ }
15
+ export declare class RecordNotFoundError extends AetherCacheError {
16
+ constructor(recordId: string);
17
+ }
18
+ export declare class SchemaNotFoundError extends AetherCacheError {
19
+ constructor(collectionName: string);
20
+ }
21
+ export declare class ValidationError extends AetherCacheError {
22
+ constructor(message: string);
23
+ }
24
+ export declare class PersistenceError extends AetherCacheError {
25
+ constructor(message: string);
26
+ }
27
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,oBAAoB,GAC5B,mBAAmB,GACnB,sBAAsB,GACtB,qBAAqB,GACrB,kBAAkB,GAClB,kBAAkB,GAClB,kBAAkB,GAClB,mBAAmB,CAAC;AAExB,qBAAa,gBAAiB,SAAQ,KAAK;IACzC,QAAQ,CAAC,IAAI,EAAE,oBAAoB,CAAC;gBAExB,IAAI,EAAE,oBAAoB,EAAE,OAAO,EAAE,MAAM;CAKxD;AAED,qBAAa,qBAAsB,SAAQ,gBAAgB;gBAC7C,cAAc,EAAE,MAAM;CAGnC;AAED,qBAAa,uBAAwB,SAAQ,gBAAgB;gBAC/C,cAAc,EAAE,MAAM;CAGnC;AAED,qBAAa,sBAAuB,SAAQ,gBAAgB;gBAC9C,QAAQ,EAAE,MAAM;CAG7B;AAED,qBAAa,mBAAoB,SAAQ,gBAAgB;gBAC3C,QAAQ,EAAE,MAAM;CAG7B;AAED,qBAAa,mBAAoB,SAAQ,gBAAgB;gBAC3C,cAAc,EAAE,MAAM;CAMnC;AAED,qBAAa,eAAgB,SAAQ,gBAAgB;gBACvC,OAAO,EAAE,MAAM;CAG5B;AAED,qBAAa,gBAAiB,SAAQ,gBAAgB;gBACxC,OAAO,EAAE,MAAM;CAG5B"}
package/dist/errors.js ADDED
@@ -0,0 +1,55 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PersistenceError = exports.ValidationError = exports.SchemaNotFoundError = exports.RecordNotFoundError = exports.DuplicateRecordIdError = exports.CollectionNotFoundError = exports.CollectionExistsError = exports.AetherCacheError = void 0;
4
+ class AetherCacheError extends Error {
5
+ code;
6
+ constructor(code, message) {
7
+ super(message);
8
+ this.name = "AetherCacheError";
9
+ this.code = code;
10
+ }
11
+ }
12
+ exports.AetherCacheError = AetherCacheError;
13
+ class CollectionExistsError extends AetherCacheError {
14
+ constructor(collectionName) {
15
+ super("COLLECTION_EXISTS", `Collection '${collectionName}' already exists`);
16
+ }
17
+ }
18
+ exports.CollectionExistsError = CollectionExistsError;
19
+ class CollectionNotFoundError extends AetherCacheError {
20
+ constructor(collectionName) {
21
+ super("COLLECTION_NOT_FOUND", `Collection '${collectionName}' does not exist`);
22
+ }
23
+ }
24
+ exports.CollectionNotFoundError = CollectionNotFoundError;
25
+ class DuplicateRecordIdError extends AetherCacheError {
26
+ constructor(recordId) {
27
+ super("DUPLICATE_RECORD_ID", `Record '${recordId}' already exists`);
28
+ }
29
+ }
30
+ exports.DuplicateRecordIdError = DuplicateRecordIdError;
31
+ class RecordNotFoundError extends AetherCacheError {
32
+ constructor(recordId) {
33
+ super("RECORD_NOT_FOUND", `Record '${recordId}' does not exist`);
34
+ }
35
+ }
36
+ exports.RecordNotFoundError = RecordNotFoundError;
37
+ class SchemaNotFoundError extends AetherCacheError {
38
+ constructor(collectionName) {
39
+ super("SCHEMA_NOT_FOUND", `Schema for collection '${collectionName}' does not exist`);
40
+ }
41
+ }
42
+ exports.SchemaNotFoundError = SchemaNotFoundError;
43
+ class ValidationError extends AetherCacheError {
44
+ constructor(message) {
45
+ super("VALIDATION_ERROR", message);
46
+ }
47
+ }
48
+ exports.ValidationError = ValidationError;
49
+ class PersistenceError extends AetherCacheError {
50
+ constructor(message) {
51
+ super("PERSISTENCE_ERROR", message);
52
+ }
53
+ }
54
+ exports.PersistenceError = PersistenceError;
55
+ //# sourceMappingURL=errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":";;;AASA,MAAa,gBAAiB,SAAQ,KAAK;IAChC,IAAI,CAAuB;IAEpC,YAAY,IAA0B,EAAE,OAAe;QACrD,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,kBAAkB,CAAC;QAC/B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;CACF;AARD,4CAQC;AAED,MAAa,qBAAsB,SAAQ,gBAAgB;IACzD,YAAY,cAAsB;QAChC,KAAK,CAAC,mBAAmB,EAAE,eAAe,cAAc,kBAAkB,CAAC,CAAC;IAC9E,CAAC;CACF;AAJD,sDAIC;AAED,MAAa,uBAAwB,SAAQ,gBAAgB;IAC3D,YAAY,cAAsB;QAChC,KAAK,CAAC,sBAAsB,EAAE,eAAe,cAAc,kBAAkB,CAAC,CAAC;IACjF,CAAC;CACF;AAJD,0DAIC;AAED,MAAa,sBAAuB,SAAQ,gBAAgB;IAC1D,YAAY,QAAgB;QAC1B,KAAK,CAAC,qBAAqB,EAAE,WAAW,QAAQ,kBAAkB,CAAC,CAAC;IACtE,CAAC;CACF;AAJD,wDAIC;AAED,MAAa,mBAAoB,SAAQ,gBAAgB;IACvD,YAAY,QAAgB;QAC1B,KAAK,CAAC,kBAAkB,EAAE,WAAW,QAAQ,kBAAkB,CAAC,CAAC;IACnE,CAAC;CACF;AAJD,kDAIC;AAED,MAAa,mBAAoB,SAAQ,gBAAgB;IACvD,YAAY,cAAsB;QAChC,KAAK,CACH,kBAAkB,EAClB,0BAA0B,cAAc,kBAAkB,CAC3D,CAAC;IACJ,CAAC;CACF;AAPD,kDAOC;AAED,MAAa,eAAgB,SAAQ,gBAAgB;IACnD,YAAY,OAAe;QACzB,KAAK,CAAC,kBAAkB,EAAE,OAAO,CAAC,CAAC;IACrC,CAAC;CACF;AAJD,0CAIC;AAED,MAAa,gBAAiB,SAAQ,gBAAgB;IACpD,YAAY,OAAe;QACzB,KAAK,CAAC,mBAAmB,EAAE,OAAO,CAAC,CAAC;IACtC,CAAC;CACF;AAJD,4CAIC"}
@@ -0,0 +1,4 @@
1
+ export { AetherCache, microDB } from "./database";
2
+ export { AetherCacheError, CollectionExistsError, CollectionNotFoundError, DuplicateRecordIdError, PersistenceError, RecordNotFoundError, SchemaNotFoundError, ValidationError, } from "./errors";
3
+ export type { AetherCacheOptions, Collection, CollectionMetadata, CollectionName, DatabaseStore, FilterPredicate, IndexKind, IndexMetadata, PrimitiveSchemaType, RecordData, RecordId, RecordIdentity, SchemaDefinition, SchemaRegistration, StoredRecord, } from "./types";
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAClD,OAAO,EACL,gBAAgB,EAChB,qBAAqB,EACrB,uBAAuB,EACvB,sBAAsB,EACtB,gBAAgB,EAChB,mBAAmB,EACnB,mBAAmB,EACnB,eAAe,GAChB,MAAM,UAAU,CAAC;AAClB,YAAY,EACV,kBAAkB,EAClB,UAAU,EACV,kBAAkB,EAClB,cAAc,EACd,aAAa,EACb,eAAe,EACf,SAAS,EACT,aAAa,EACb,mBAAmB,EACnB,UAAU,EACV,QAAQ,EACR,cAAc,EACd,gBAAgB,EAChB,kBAAkB,EAClB,YAAY,GACb,MAAM,SAAS,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ValidationError = exports.SchemaNotFoundError = exports.RecordNotFoundError = exports.PersistenceError = exports.DuplicateRecordIdError = exports.CollectionNotFoundError = exports.CollectionExistsError = exports.AetherCacheError = exports.microDB = exports.AetherCache = void 0;
4
+ var database_1 = require("./database");
5
+ Object.defineProperty(exports, "AetherCache", { enumerable: true, get: function () { return database_1.AetherCache; } });
6
+ Object.defineProperty(exports, "microDB", { enumerable: true, get: function () { return database_1.microDB; } });
7
+ var errors_1 = require("./errors");
8
+ Object.defineProperty(exports, "AetherCacheError", { enumerable: true, get: function () { return errors_1.AetherCacheError; } });
9
+ Object.defineProperty(exports, "CollectionExistsError", { enumerable: true, get: function () { return errors_1.CollectionExistsError; } });
10
+ Object.defineProperty(exports, "CollectionNotFoundError", { enumerable: true, get: function () { return errors_1.CollectionNotFoundError; } });
11
+ Object.defineProperty(exports, "DuplicateRecordIdError", { enumerable: true, get: function () { return errors_1.DuplicateRecordIdError; } });
12
+ Object.defineProperty(exports, "PersistenceError", { enumerable: true, get: function () { return errors_1.PersistenceError; } });
13
+ Object.defineProperty(exports, "RecordNotFoundError", { enumerable: true, get: function () { return errors_1.RecordNotFoundError; } });
14
+ Object.defineProperty(exports, "SchemaNotFoundError", { enumerable: true, get: function () { return errors_1.SchemaNotFoundError; } });
15
+ Object.defineProperty(exports, "ValidationError", { enumerable: true, get: function () { return errors_1.ValidationError; } });
16
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,uCAAkD;AAAzC,uGAAA,WAAW,OAAA;AAAE,mGAAA,OAAO,OAAA;AAC7B,mCASkB;AARhB,0GAAA,gBAAgB,OAAA;AAChB,+GAAA,qBAAqB,OAAA;AACrB,iHAAA,uBAAuB,OAAA;AACvB,gHAAA,sBAAsB,OAAA;AACtB,0GAAA,gBAAgB,OAAA;AAChB,6GAAA,mBAAmB,OAAA;AACnB,6GAAA,mBAAmB,OAAA;AACnB,yGAAA,eAAe,OAAA"}