anchordb-angular 0.2.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.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 AnchorDB contributors
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,57 @@
1
+ # anchordb-angular
2
+
3
+ Angular and Ionic bindings for [AnchorDB](https://www.npmjs.com/package/anchordb) — the same
4
+ module and injection shape as `@nestjs/mongoose`.
5
+
6
+ ```bash
7
+ npm install anchordb-angular
8
+ ```
9
+
10
+ ```ts
11
+ @NgModule({
12
+ providers: [
13
+ ...AnchorModule.forRoot({ name: "my-app" }).providers,
14
+ ...AnchorModule.forFeature([{ name: "User", schema: UserSchema }]).providers,
15
+ ],
16
+ })
17
+ export class AppModule {}
18
+
19
+ @Injectable({ providedIn: "root" })
20
+ export class UserService {
21
+ users$ = this.anchor.find$<User>("User", { age: { $gt: 18 } }, { sort: "-createdAt" });
22
+ status$ = this.anchor.syncStatus$();
23
+
24
+ constructor(private anchor: AnchorService) {}
25
+ }
26
+ ```
27
+
28
+ `forRoot` / `forFeature` / `getModelToken` mirror `@nestjs/mongoose` deliberately: a developer
29
+ moving between a NestJS backend and an Ionic app writes the same wiring in both places.
30
+
31
+ ## Observables
32
+
33
+ `find$`, `findOne$`, `count$`, `aggregate$`, `syncStatus$` and `on$` return an `AnchorObservable`,
34
+ which satisfies the RxJS contract structurally — including the `Symbol.observable` interop hook — so
35
+ `from(...)`, the `async` pipe, `toSignal()` and every RxJS operator work on it.
36
+
37
+ ## Why Angular is not imported
38
+
39
+ **`@angular/core` and `rxjs` are optional peer dependencies and are never imported.** Two reasons:
40
+ the package must install cleanly for React Native users who will never touch Angular, and a copy of
41
+ Angular compiled into a library can disagree with the app's own — the classic "two copies of
42
+ @angular/core" failure.
43
+
44
+ Providers are therefore plain objects that your app passes to its own `NgModule` or
45
+ `bootstrapApplication`, using its own Angular.
46
+
47
+ ## Storage on Ionic
48
+
49
+ | Target | Adapter |
50
+ | --- | --- |
51
+ | `ionic serve`, PWA | `anchordb/storage/indexeddb` |
52
+ | iOS / Android native | `anchordb/storage/capacitor-sqlite` |
53
+
54
+ ## Status
55
+
56
+ **0.1.0.** The Capacitor adapter is typechecked but **not executed** — it needs a device. The
57
+ IndexedDB adapter is covered by the shared storage conformance suite. MIT.
@@ -0,0 +1,136 @@
1
+ import { AnchorDB, type AnchorDBConfig, type Filter, type ModelConstructor, type Schema, type SyncStatus } from "anchordb";
2
+ /**
3
+ * Angular / Ionic bindings.
4
+ *
5
+ * The module and injection shape mirrors `@nestjs/mongoose` — `forRoot`, `forFeature`,
6
+ * `@InjectModel` — on purpose. A developer moving between a NestJS backend and an Ionic app writes
7
+ * the same wiring in both places, which is the whole point of principle 1.
8
+ *
9
+ * ## Why Angular is not imported here
10
+ *
11
+ * `@angular/core` is an optional peer dependency and is never imported. Two reasons:
12
+ *
13
+ * - The package must install cleanly for React Native users who will never touch Angular.
14
+ * - Angular decorators are version-sensitive; a copy compiled into this library could disagree
15
+ * with the app's own Angular and produce the notorious "two copies of @angular/core" failure.
16
+ *
17
+ * So the provider factories below are plain functions returning plain provider objects. The app
18
+ * passes them to its own `NgModule` or `bootstrapApplication`, using its own Angular.
19
+ */
20
+ export interface Subscribable<T> {
21
+ subscribe(observer: Partial<Observer<T>> | ((value: T) => void)): Unsubscribable;
22
+ }
23
+ export interface Observer<T> {
24
+ next: (value: T) => void;
25
+ error: (err: unknown) => void;
26
+ complete: () => void;
27
+ }
28
+ export interface Unsubscribable {
29
+ unsubscribe(): void;
30
+ }
31
+ /**
32
+ * A minimal cold observable that satisfies RxJS's contract.
33
+ *
34
+ * `Symbol.observable` interop means `from(anchorObservable)`, the `async` pipe, `toSignal()` and
35
+ * every RxJS operator work on it — without this package pinning a version of RxJS.
36
+ */
37
+ export declare class AnchorObservable<T> implements Subscribable<T> {
38
+ private readonly onSubscribe;
39
+ constructor(onSubscribe: (observer: Observer<T>) => Unsubscribable);
40
+ subscribe(observer: Partial<Observer<T>> | ((value: T) => void)): Unsubscribable;
41
+ map<R>(project: (value: T) => R): AnchorObservable<R>;
42
+ }
43
+ export declare const ANCHOR_DB = "ANCHOR_DB";
44
+ /** Token for a model, matching `@nestjs/mongoose`'s `getModelToken`. */
45
+ export declare function getModelToken(name: string): string;
46
+ export interface ModelDefinition {
47
+ name: string;
48
+ schema: Schema;
49
+ collection?: string;
50
+ }
51
+ export interface Provider {
52
+ provide: string;
53
+ useFactory?: (...deps: never[]) => unknown;
54
+ useValue?: unknown;
55
+ deps?: string[];
56
+ }
57
+ /**
58
+ * Root providers — the app passes these to its own NgModule or `bootstrapApplication`.
59
+ *
60
+ * ```ts
61
+ * @NgModule({ providers: [...provideAnchor({ name: "my-app" })] })
62
+ * ```
63
+ */
64
+ export declare function provideAnchor(config: AnchorDBConfig): Provider[];
65
+ /** Feature providers, mirroring `MongooseModule.forFeature([...])`. */
66
+ export declare function provideAnchorFeature(definitions: ModelDefinition[]): Provider[];
67
+ /**
68
+ * `AnchorModule.forRoot(...)` / `.forFeature(...)`.
69
+ *
70
+ * Returns a plain `{ providers }` object rather than a decorated NgModule, which every Angular
71
+ * version accepts as `ModuleWithProviders`-shaped without this package importing Angular.
72
+ */
73
+ export declare const AnchorModule: {
74
+ forRoot(config: AnchorDBConfig): {
75
+ providers: Provider[];
76
+ };
77
+ forFeature(definitions: ModelDefinition[]): {
78
+ providers: Provider[];
79
+ };
80
+ };
81
+ /**
82
+ * `@InjectModel(User.name)`, matching `@nestjs/mongoose`.
83
+ *
84
+ * Implemented as a parameter decorator that records the token; Angular's own `@Inject` is applied
85
+ * by the app. In practice apps write `@Inject(getModelToken(User.name))` or use this helper.
86
+ */
87
+ export declare function InjectModel(name: string): ParameterDecorator & {
88
+ token: string;
89
+ };
90
+ export interface FindOptions {
91
+ sort?: unknown;
92
+ skip?: number;
93
+ limit?: number;
94
+ select?: string | Record<string, 0 | 1>;
95
+ populate?: string | string[];
96
+ lean?: boolean;
97
+ debounceMs?: number;
98
+ }
99
+ /**
100
+ * Injectable facade over AnchorDB, with live queries as observables.
101
+ *
102
+ * ```ts
103
+ * export class UsersPage {
104
+ * users$ = this.anchor.find$<User>("User", { age: { $gt: 18 } }, { sort: "-createdAt" });
105
+ * status$ = this.anchor.syncStatus$();
106
+ * constructor(private anchor: AnchorService) {}
107
+ * }
108
+ * ```
109
+ */
110
+ export declare class AnchorService {
111
+ readonly db: AnchorDB;
112
+ constructor(db: AnchorDB);
113
+ model<T extends Record<string, unknown> = Record<string, unknown>>(name: string): ModelConstructor<T>;
114
+ get sync(): AnchorDB["sync"];
115
+ /** Live list query. Emits immediately, then on every matching change. */
116
+ find$<T extends Record<string, unknown>>(modelName: string, filter?: Filter, options?: FindOptions): AnchorObservable<T[]>;
117
+ findOne$<T extends Record<string, unknown>>(modelName: string, filter?: Filter, options?: FindOptions): AnchorObservable<T | null>;
118
+ count$(modelName: string, filter?: Filter, options?: {
119
+ debounceMs?: number;
120
+ }): AnchorObservable<number>;
121
+ aggregate$<R = Record<string, unknown>>(modelName: string, pipeline: unknown[], options?: {
122
+ debounceMs?: number;
123
+ }): AnchorObservable<R[]>;
124
+ /** Live sync status. Emits `"disabled"` in local-only mode rather than nothing. */
125
+ syncStatus$(): AnchorObservable<{
126
+ status: SyncStatus;
127
+ pending: number;
128
+ enabled: boolean;
129
+ }>;
130
+ /** Any AnchorDB event as an observable. */
131
+ on$<T = unknown>(event: Parameters<AnchorDB["on"]>[0]): AnchorObservable<T>;
132
+ }
133
+ /** Factory for the app's provider list. */
134
+ export declare function provideAnchorService(): Provider[];
135
+ export type { AnchorDB, AnchorDBConfig, ModelConstructor, Schema };
136
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAGR,KAAK,cAAc,EACnB,KAAK,MAAM,EACX,KAAK,gBAAgB,EACrB,KAAK,MAAM,EACX,KAAK,UAAU,EAChB,MAAM,UAAU,CAAC;AAElB;;;;;;;;;;;;;;;;;GAiBG;AAIH,MAAM,WAAW,YAAY,CAAC,CAAC;IAC7B,SAAS,CAAC,QAAQ,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,CAAC,KAAK,IAAI,CAAC,GAAG,cAAc,CAAC;CAClF;AAED,MAAM,WAAW,QAAQ,CAAC,CAAC;IACzB,IAAI,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,IAAI,CAAC;IACzB,KAAK,EAAE,CAAC,GAAG,EAAE,OAAO,KAAK,IAAI,CAAC;IAC9B,QAAQ,EAAE,MAAM,IAAI,CAAC;CACtB;AAED,MAAM,WAAW,cAAc;IAC7B,WAAW,IAAI,IAAI,CAAC;CACrB;AAED;;;;;GAKG;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MAAM,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,GAAE,MAAW,EAAE,OAAO,GAAE;QAAE,UAAU,CAAC,EAAE,MAAM,CAAA;KAAO,GAAG,gBAAgB,CAAC,MAAM,CAAC;IAa/G,UAAU,CAAC,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACpC,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,OAAO,EAAE,EACnB,OAAO,GAAE;QAAE,UAAU,CAAC,EAAE,MAAM,CAAA;KAAO,GACpC,gBAAgB,CAAC,CAAC,EAAE,CAAC;IAaxB,mFAAmF;IACnF,WAAW,IAAI,gBAAgB,CAAC;QAAE,MAAM,EAAE,UAAU,CAAC;QAAC,OAAO,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,OAAO,CAAA;KAAE,CAAC;IAa1F,2CAA2C;IAC3C,GAAG,CAAC,CAAC,GAAG,OAAO,EAAE,KAAK,EAAE,UAAU,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,gBAAgB,CAAC,CAAC,CAAC;CAM5E;AAED,2CAA2C;AAC3C,wBAAgB,oBAAoB,IAAI,QAAQ,EAAE,CAEjD;AAED,YAAY,EAAE,QAAQ,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,EAAE,CAAC"}
@@ -0,0 +1,186 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AnchorService = exports.AnchorModule = exports.ANCHOR_DB = exports.AnchorObservable = void 0;
4
+ exports.getModelToken = getModelToken;
5
+ exports.provideAnchor = provideAnchor;
6
+ exports.provideAnchorFeature = provideAnchorFeature;
7
+ exports.InjectModel = InjectModel;
8
+ exports.provideAnchorService = provideAnchorService;
9
+ const anchordb_1 = require("anchordb");
10
+ /**
11
+ * A minimal cold observable that satisfies RxJS's contract.
12
+ *
13
+ * `Symbol.observable` interop means `from(anchorObservable)`, the `async` pipe, `toSignal()` and
14
+ * every RxJS operator work on it — without this package pinning a version of RxJS.
15
+ */
16
+ class AnchorObservable {
17
+ constructor(onSubscribe) {
18
+ this.onSubscribe = onSubscribe;
19
+ }
20
+ subscribe(observer) {
21
+ const normalised = typeof observer === "function"
22
+ ? { next: observer, error: () => undefined, complete: () => undefined }
23
+ : {
24
+ next: observer.next ?? (() => undefined),
25
+ error: observer.error ?? (() => undefined),
26
+ complete: observer.complete ?? (() => undefined),
27
+ };
28
+ return this.onSubscribe(normalised);
29
+ }
30
+ /** Interop hook RxJS looks for, so `from(...)` accepts this directly. */
31
+ [Symbol.for("rxjs.observable")]() {
32
+ return this;
33
+ }
34
+ map(project) {
35
+ return new AnchorObservable((observer) => this.subscribe({
36
+ next: (value) => observer.next(project(value)),
37
+ error: (err) => observer.error(err),
38
+ complete: () => observer.complete(),
39
+ }));
40
+ }
41
+ }
42
+ exports.AnchorObservable = AnchorObservable;
43
+ // ---- DI tokens ---------------------------------------------------------------
44
+ exports.ANCHOR_DB = "ANCHOR_DB";
45
+ /** Token for a model, matching `@nestjs/mongoose`'s `getModelToken`. */
46
+ function getModelToken(name) {
47
+ return `AnchorModel:${name}`;
48
+ }
49
+ /**
50
+ * Root providers — the app passes these to its own NgModule or `bootstrapApplication`.
51
+ *
52
+ * ```ts
53
+ * @NgModule({ providers: [...provideAnchor({ name: "my-app" })] })
54
+ * ```
55
+ */
56
+ function provideAnchor(config) {
57
+ let instance = null;
58
+ return [
59
+ {
60
+ provide: exports.ANCHOR_DB,
61
+ // A single instance per application: two AnchorDB objects over one database would each hold
62
+ // their own model registry and their own HLC, and would not see each other's changes.
63
+ useFactory: () => (instance ??= new anchordb_1.AnchorDB(config)),
64
+ },
65
+ ];
66
+ }
67
+ /** Feature providers, mirroring `MongooseModule.forFeature([...])`. */
68
+ function provideAnchorFeature(definitions) {
69
+ return definitions.map((definition) => ({
70
+ provide: getModelToken(definition.name),
71
+ useFactory: (db) => db.model(definition.name, definition.schema, definition.collection ? { collection: definition.collection } : undefined),
72
+ deps: [exports.ANCHOR_DB],
73
+ }));
74
+ }
75
+ /**
76
+ * `AnchorModule.forRoot(...)` / `.forFeature(...)`.
77
+ *
78
+ * Returns a plain `{ providers }` object rather than a decorated NgModule, which every Angular
79
+ * version accepts as `ModuleWithProviders`-shaped without this package importing Angular.
80
+ */
81
+ exports.AnchorModule = {
82
+ forRoot(config) {
83
+ return { providers: provideAnchor(config) };
84
+ },
85
+ forFeature(definitions) {
86
+ return { providers: provideAnchorFeature(definitions) };
87
+ },
88
+ };
89
+ /**
90
+ * `@InjectModel(User.name)`, matching `@nestjs/mongoose`.
91
+ *
92
+ * Implemented as a parameter decorator that records the token; Angular's own `@Inject` is applied
93
+ * by the app. In practice apps write `@Inject(getModelToken(User.name))` or use this helper.
94
+ */
95
+ function InjectModel(name) {
96
+ const token = getModelToken(name);
97
+ const decorator = ((target, key, index) => {
98
+ const store = target;
99
+ (store.__anchorInjections ??= []).push({ index, token });
100
+ void key;
101
+ });
102
+ decorator.token = token;
103
+ return decorator;
104
+ }
105
+ /**
106
+ * Injectable facade over AnchorDB, with live queries as observables.
107
+ *
108
+ * ```ts
109
+ * export class UsersPage {
110
+ * users$ = this.anchor.find$<User>("User", { age: { $gt: 18 } }, { sort: "-createdAt" });
111
+ * status$ = this.anchor.syncStatus$();
112
+ * constructor(private anchor: AnchorService) {}
113
+ * }
114
+ * ```
115
+ */
116
+ class AnchorService {
117
+ constructor(db) {
118
+ this.db = db;
119
+ }
120
+ model(name) {
121
+ return this.db.model(name);
122
+ }
123
+ get sync() {
124
+ return this.db.sync;
125
+ }
126
+ /** Live list query. Emits immediately, then on every matching change. */
127
+ find$(modelName, filter = {}, options = {}) {
128
+ return new AnchorObservable((observer) => {
129
+ const model = this.db.model(modelName);
130
+ return (0, anchordb_1.observeQuery)(this.db, model.collectionName, async () => {
131
+ const query = model.find(filter);
132
+ if (options.sort)
133
+ query.sort(options.sort);
134
+ if (options.skip !== undefined)
135
+ query.skip(options.skip);
136
+ if (options.limit !== undefined)
137
+ query.limit(options.limit);
138
+ if (options.select)
139
+ query.select(options.select);
140
+ if (options.populate)
141
+ query.populate(options.populate);
142
+ if (options.lean)
143
+ query.lean();
144
+ return (await query.exec());
145
+ }, observer, options.debounceMs !== undefined ? { debounceMs: options.debounceMs } : {});
146
+ });
147
+ }
148
+ findOne$(modelName, filter = {}, options = {}) {
149
+ return this.find$(modelName, filter, { ...options, limit: 1 }).map((rows) => rows[0] ?? null);
150
+ }
151
+ count$(modelName, filter = {}, options = {}) {
152
+ return new AnchorObservable((observer) => {
153
+ const model = this.db.model(modelName);
154
+ return (0, anchordb_1.observeQuery)(this.db, model.collectionName, () => model.countDocuments(filter), observer, options.debounceMs !== undefined ? { debounceMs: options.debounceMs } : {});
155
+ });
156
+ }
157
+ aggregate$(modelName, pipeline, options = {}) {
158
+ return new AnchorObservable((observer) => {
159
+ const model = this.db.model(modelName);
160
+ return (0, anchordb_1.observeQuery)(this.db, model.collectionName, () => model.aggregate(pipeline), observer, options.debounceMs !== undefined ? { debounceMs: options.debounceMs } : {});
161
+ });
162
+ }
163
+ /** Live sync status. Emits `"disabled"` in local-only mode rather than nothing. */
164
+ syncStatus$() {
165
+ return new AnchorObservable((observer) => (0, anchordb_1.observeSyncStatus)(this.db, {
166
+ next: (value) => observer.next({
167
+ status: value.status,
168
+ pending: value.pending,
169
+ enabled: this.db.syncEnabled,
170
+ }),
171
+ }));
172
+ }
173
+ /** Any AnchorDB event as an observable. */
174
+ on$(event) {
175
+ return new AnchorObservable((observer) => {
176
+ const off = this.db.on(event, (payload) => observer.next(payload));
177
+ return { unsubscribe: off };
178
+ });
179
+ }
180
+ }
181
+ exports.AnchorService = AnchorService;
182
+ /** Factory for the app's provider list. */
183
+ function provideAnchorService() {
184
+ return [{ provide: "AnchorService", useFactory: (db) => new AnchorService(db), deps: [exports.ANCHOR_DB] }];
185
+ }
186
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../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I,CAAC,QAAQ,EAAE,EAAE;YAC1C,MAAM,GAAG,GAAG,IAAI,CAAC,EAAE,CAAC,EAAE,CAAC,KAAK,EAAE,CAAC,OAAO,EAAE,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAY,CAAC,CAAC,CAAC;YACxE,OAAO,EAAE,WAAW,EAAE,GAAG,EAAE,CAAC;QAC9B,CAAC,CAAC,CAAC;IACL,CAAC;CACF;AArGD,sCAqGC;AAED,2CAA2C;AAC3C,SAAgB,oBAAoB;IAClC,OAAO,CAAC,EAAE,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,CAAC,EAAY,EAAE,EAAE,CAAC,IAAI,aAAa,CAAC,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,iBAAS,CAAC,EAAE,CAAC,CAAC;AAChH,CAAC"}
@@ -0,0 +1,3 @@
1
+ {
2
+ "type": "commonjs"
3
+ }
@@ -0,0 +1,136 @@
1
+ import { AnchorDB, type AnchorDBConfig, type Filter, type ModelConstructor, type Schema, type SyncStatus } from "anchordb";
2
+ /**
3
+ * Angular / Ionic bindings.
4
+ *
5
+ * The module and injection shape mirrors `@nestjs/mongoose` — `forRoot`, `forFeature`,
6
+ * `@InjectModel` — on purpose. A developer moving between a NestJS backend and an Ionic app writes
7
+ * the same wiring in both places, which is the whole point of principle 1.
8
+ *
9
+ * ## Why Angular is not imported here
10
+ *
11
+ * `@angular/core` is an optional peer dependency and is never imported. Two reasons:
12
+ *
13
+ * - The package must install cleanly for React Native users who will never touch Angular.
14
+ * - Angular decorators are version-sensitive; a copy compiled into this library could disagree
15
+ * with the app's own Angular and produce the notorious "two copies of @angular/core" failure.
16
+ *
17
+ * So the provider factories below are plain functions returning plain provider objects. The app
18
+ * passes them to its own `NgModule` or `bootstrapApplication`, using its own Angular.
19
+ */
20
+ export interface Subscribable<T> {
21
+ subscribe(observer: Partial<Observer<T>> | ((value: T) => void)): Unsubscribable;
22
+ }
23
+ export interface Observer<T> {
24
+ next: (value: T) => void;
25
+ error: (err: unknown) => void;
26
+ complete: () => void;
27
+ }
28
+ export interface Unsubscribable {
29
+ unsubscribe(): void;
30
+ }
31
+ /**
32
+ * A minimal cold observable that satisfies RxJS's contract.
33
+ *
34
+ * `Symbol.observable` interop means `from(anchorObservable)`, the `async` pipe, `toSignal()` and
35
+ * every RxJS operator work on it — without this package pinning a version of RxJS.
36
+ */
37
+ export declare class AnchorObservable<T> implements Subscribable<T> {
38
+ private readonly onSubscribe;
39
+ constructor(onSubscribe: (observer: Observer<T>) => Unsubscribable);
40
+ subscribe(observer: Partial<Observer<T>> | ((value: T) => void)): Unsubscribable;
41
+ map<R>(project: (value: T) => R): AnchorObservable<R>;
42
+ }
43
+ export declare const ANCHOR_DB = "ANCHOR_DB";
44
+ /** Token for a model, matching `@nestjs/mongoose`'s `getModelToken`. */
45
+ export declare function getModelToken(name: string): string;
46
+ export interface ModelDefinition {
47
+ name: string;
48
+ schema: Schema;
49
+ collection?: string;
50
+ }
51
+ export interface Provider {
52
+ provide: string;
53
+ useFactory?: (...deps: never[]) => unknown;
54
+ useValue?: unknown;
55
+ deps?: string[];
56
+ }
57
+ /**
58
+ * Root providers — the app passes these to its own NgModule or `bootstrapApplication`.
59
+ *
60
+ * ```ts
61
+ * @NgModule({ providers: [...provideAnchor({ name: "my-app" })] })
62
+ * ```
63
+ */
64
+ export declare function provideAnchor(config: AnchorDBConfig): Provider[];
65
+ /** Feature providers, mirroring `MongooseModule.forFeature([...])`. */
66
+ export declare function provideAnchorFeature(definitions: ModelDefinition[]): Provider[];
67
+ /**
68
+ * `AnchorModule.forRoot(...)` / `.forFeature(...)`.
69
+ *
70
+ * Returns a plain `{ providers }` object rather than a decorated NgModule, which every Angular
71
+ * version accepts as `ModuleWithProviders`-shaped without this package importing Angular.
72
+ */
73
+ export declare const AnchorModule: {
74
+ forRoot(config: AnchorDBConfig): {
75
+ providers: Provider[];
76
+ };
77
+ forFeature(definitions: ModelDefinition[]): {
78
+ providers: Provider[];
79
+ };
80
+ };
81
+ /**
82
+ * `@InjectModel(User.name)`, matching `@nestjs/mongoose`.
83
+ *
84
+ * Implemented as a parameter decorator that records the token; Angular's own `@Inject` is applied
85
+ * by the app. In practice apps write `@Inject(getModelToken(User.name))` or use this helper.
86
+ */
87
+ export declare function InjectModel(name: string): ParameterDecorator & {
88
+ token: string;
89
+ };
90
+ export interface FindOptions {
91
+ sort?: unknown;
92
+ skip?: number;
93
+ limit?: number;
94
+ select?: string | Record<string, 0 | 1>;
95
+ populate?: string | string[];
96
+ lean?: boolean;
97
+ debounceMs?: number;
98
+ }
99
+ /**
100
+ * Injectable facade over AnchorDB, with live queries as observables.
101
+ *
102
+ * ```ts
103
+ * export class UsersPage {
104
+ * users$ = this.anchor.find$<User>("User", { age: { $gt: 18 } }, { sort: "-createdAt" });
105
+ * status$ = this.anchor.syncStatus$();
106
+ * constructor(private anchor: AnchorService) {}
107
+ * }
108
+ * ```
109
+ */
110
+ export declare class AnchorService {
111
+ readonly db: AnchorDB;
112
+ constructor(db: AnchorDB);
113
+ model<T extends Record<string, unknown> = Record<string, unknown>>(name: string): ModelConstructor<T>;
114
+ get sync(): AnchorDB["sync"];
115
+ /** Live list query. Emits immediately, then on every matching change. */
116
+ find$<T extends Record<string, unknown>>(modelName: string, filter?: Filter, options?: FindOptions): AnchorObservable<T[]>;
117
+ findOne$<T extends Record<string, unknown>>(modelName: string, filter?: Filter, options?: FindOptions): AnchorObservable<T | null>;
118
+ count$(modelName: string, filter?: Filter, options?: {
119
+ debounceMs?: number;
120
+ }): AnchorObservable<number>;
121
+ aggregate$<R = Record<string, unknown>>(modelName: string, pipeline: unknown[], options?: {
122
+ debounceMs?: number;
123
+ }): AnchorObservable<R[]>;
124
+ /** Live sync status. Emits `"disabled"` in local-only mode rather than nothing. */
125
+ syncStatus$(): AnchorObservable<{
126
+ status: SyncStatus;
127
+ pending: number;
128
+ enabled: boolean;
129
+ }>;
130
+ /** Any AnchorDB event as an observable. */
131
+ on$<T = unknown>(event: Parameters<AnchorDB["on"]>[0]): AnchorObservable<T>;
132
+ }
133
+ /** Factory for the app's provider list. */
134
+ export declare function provideAnchorService(): Provider[];
135
+ export type { AnchorDB, AnchorDBConfig, ModelConstructor, Schema };
136
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAGR,KAAK,cAAc,EACnB,KAAK,MAAM,EACX,KAAK,gBAAgB,EACrB,KAAK,MAAM,EACX,KAAK,UAAU,EAChB,MAAM,UAAU,CAAC;AAElB;;;;;;;;;;;;;;;;;GAiBG;AAIH,MAAM,WAAW,YAAY,CAAC,CAAC;IAC7B,SAAS,CAAC,QAAQ,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,CAAC,KAAK,IAAI,CAAC,GAAG,cAAc,CAAC;CAClF;AAED,MAAM,WAAW,QAAQ,CAAC,CAAC;IACzB,IAAI,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,IAAI,CAAC;IACzB,KAAK,EAAE,CAAC,GAAG,EAAE,OAAO,KAAK,IAAI,CAAC;IAC9B,QAAQ,EAAE,MAAM,IAAI,CAAC;CACtB;AAED,MAAM,WAAW,cAAc;IAC7B,WAAW,IAAI,IAAI,CAAC;CACrB;AAED;;;;;GAKG;AACH,qBAAa,gBAAgB,CAAC,CAAC,CAAE,YAAW,YAAY,CAAC,CAAC,CAAC;IACzD,OAAO,CAAC,QAAQ,CAAC,WAAW,CAA4C;gBAE5D,WAAW,EAAE,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAAC,KAAK,cAAc;IAIlE,SAAS,CAAC,QAAQ,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,CAAC,KAAK,IAAI,CAAC,GAAG,cAAc;IAiBhF,GAAG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AAC,CAAC,EAAE,CAAC;IAaxB,mFAAmF;IACnF,WAAW,IAAI,gBAAgB,CAAC;QAAE,MAAM,EAAE,UAAU,CAAC;QAAC,OAAO,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,OAAO,CAAA;KAAE,CAAC;IAa1F,2CAA2C;IAC3C,GAAG,CAAC,CAAC,GAAG,OAAO,EAAE,KAAK,EAAE,UAAU,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,gBAAgB,CAAC,CAAC,CAAC;CAM5E;AAED,2CAA2C;AAC3C,wBAAgB,oBAAoB,IAAI,QAAQ,EAAE,CAEjD;AAED,YAAY,EAAE,QAAQ,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,EAAE,CAAC"}
@@ -0,0 +1,176 @@
1
+ import { AnchorDB, observeQuery, observeSyncStatus, } from "anchordb";
2
+ /**
3
+ * A minimal cold observable that satisfies RxJS's contract.
4
+ *
5
+ * `Symbol.observable` interop means `from(anchorObservable)`, the `async` pipe, `toSignal()` and
6
+ * every RxJS operator work on it — without this package pinning a version of RxJS.
7
+ */
8
+ export class AnchorObservable {
9
+ constructor(onSubscribe) {
10
+ this.onSubscribe = onSubscribe;
11
+ }
12
+ subscribe(observer) {
13
+ const normalised = typeof observer === "function"
14
+ ? { next: observer, error: () => undefined, complete: () => undefined }
15
+ : {
16
+ next: observer.next ?? (() => undefined),
17
+ error: observer.error ?? (() => undefined),
18
+ complete: observer.complete ?? (() => undefined),
19
+ };
20
+ return this.onSubscribe(normalised);
21
+ }
22
+ /** Interop hook RxJS looks for, so `from(...)` accepts this directly. */
23
+ [Symbol.for("rxjs.observable")]() {
24
+ return this;
25
+ }
26
+ map(project) {
27
+ return new AnchorObservable((observer) => this.subscribe({
28
+ next: (value) => observer.next(project(value)),
29
+ error: (err) => observer.error(err),
30
+ complete: () => observer.complete(),
31
+ }));
32
+ }
33
+ }
34
+ // ---- DI tokens ---------------------------------------------------------------
35
+ export const ANCHOR_DB = "ANCHOR_DB";
36
+ /** Token for a model, matching `@nestjs/mongoose`'s `getModelToken`. */
37
+ export function getModelToken(name) {
38
+ return `AnchorModel:${name}`;
39
+ }
40
+ /**
41
+ * Root providers — the app passes these to its own NgModule or `bootstrapApplication`.
42
+ *
43
+ * ```ts
44
+ * @NgModule({ providers: [...provideAnchor({ name: "my-app" })] })
45
+ * ```
46
+ */
47
+ export function provideAnchor(config) {
48
+ let instance = null;
49
+ return [
50
+ {
51
+ provide: ANCHOR_DB,
52
+ // A single instance per application: two AnchorDB objects over one database would each hold
53
+ // their own model registry and their own HLC, and would not see each other's changes.
54
+ useFactory: () => (instance ??= new AnchorDB(config)),
55
+ },
56
+ ];
57
+ }
58
+ /** Feature providers, mirroring `MongooseModule.forFeature([...])`. */
59
+ export function provideAnchorFeature(definitions) {
60
+ return definitions.map((definition) => ({
61
+ provide: getModelToken(definition.name),
62
+ useFactory: (db) => db.model(definition.name, definition.schema, definition.collection ? { collection: definition.collection } : undefined),
63
+ deps: [ANCHOR_DB],
64
+ }));
65
+ }
66
+ /**
67
+ * `AnchorModule.forRoot(...)` / `.forFeature(...)`.
68
+ *
69
+ * Returns a plain `{ providers }` object rather than a decorated NgModule, which every Angular
70
+ * version accepts as `ModuleWithProviders`-shaped without this package importing Angular.
71
+ */
72
+ export const AnchorModule = {
73
+ forRoot(config) {
74
+ return { providers: provideAnchor(config) };
75
+ },
76
+ forFeature(definitions) {
77
+ return { providers: provideAnchorFeature(definitions) };
78
+ },
79
+ };
80
+ /**
81
+ * `@InjectModel(User.name)`, matching `@nestjs/mongoose`.
82
+ *
83
+ * Implemented as a parameter decorator that records the token; Angular's own `@Inject` is applied
84
+ * by the app. In practice apps write `@Inject(getModelToken(User.name))` or use this helper.
85
+ */
86
+ export function InjectModel(name) {
87
+ const token = getModelToken(name);
88
+ const decorator = ((target, key, index) => {
89
+ const store = target;
90
+ (store.__anchorInjections ??= []).push({ index, token });
91
+ void key;
92
+ });
93
+ decorator.token = token;
94
+ return decorator;
95
+ }
96
+ /**
97
+ * Injectable facade over AnchorDB, with live queries as observables.
98
+ *
99
+ * ```ts
100
+ * export class UsersPage {
101
+ * users$ = this.anchor.find$<User>("User", { age: { $gt: 18 } }, { sort: "-createdAt" });
102
+ * status$ = this.anchor.syncStatus$();
103
+ * constructor(private anchor: AnchorService) {}
104
+ * }
105
+ * ```
106
+ */
107
+ export class AnchorService {
108
+ constructor(db) {
109
+ this.db = db;
110
+ }
111
+ model(name) {
112
+ return this.db.model(name);
113
+ }
114
+ get sync() {
115
+ return this.db.sync;
116
+ }
117
+ /** Live list query. Emits immediately, then on every matching change. */
118
+ find$(modelName, filter = {}, options = {}) {
119
+ return new AnchorObservable((observer) => {
120
+ const model = this.db.model(modelName);
121
+ return observeQuery(this.db, model.collectionName, async () => {
122
+ const query = model.find(filter);
123
+ if (options.sort)
124
+ query.sort(options.sort);
125
+ if (options.skip !== undefined)
126
+ query.skip(options.skip);
127
+ if (options.limit !== undefined)
128
+ query.limit(options.limit);
129
+ if (options.select)
130
+ query.select(options.select);
131
+ if (options.populate)
132
+ query.populate(options.populate);
133
+ if (options.lean)
134
+ query.lean();
135
+ return (await query.exec());
136
+ }, observer, options.debounceMs !== undefined ? { debounceMs: options.debounceMs } : {});
137
+ });
138
+ }
139
+ findOne$(modelName, filter = {}, options = {}) {
140
+ return this.find$(modelName, filter, { ...options, limit: 1 }).map((rows) => rows[0] ?? null);
141
+ }
142
+ count$(modelName, filter = {}, options = {}) {
143
+ return new AnchorObservable((observer) => {
144
+ const model = this.db.model(modelName);
145
+ return observeQuery(this.db, model.collectionName, () => model.countDocuments(filter), observer, options.debounceMs !== undefined ? { debounceMs: options.debounceMs } : {});
146
+ });
147
+ }
148
+ aggregate$(modelName, pipeline, options = {}) {
149
+ return new AnchorObservable((observer) => {
150
+ const model = this.db.model(modelName);
151
+ return observeQuery(this.db, model.collectionName, () => model.aggregate(pipeline), observer, options.debounceMs !== undefined ? { debounceMs: options.debounceMs } : {});
152
+ });
153
+ }
154
+ /** Live sync status. Emits `"disabled"` in local-only mode rather than nothing. */
155
+ syncStatus$() {
156
+ return new AnchorObservable((observer) => observeSyncStatus(this.db, {
157
+ next: (value) => observer.next({
158
+ status: value.status,
159
+ pending: value.pending,
160
+ enabled: this.db.syncEnabled,
161
+ }),
162
+ }));
163
+ }
164
+ /** Any AnchorDB event as an observable. */
165
+ on$(event) {
166
+ return new AnchorObservable((observer) => {
167
+ const off = this.db.on(event, (payload) => observer.next(payload));
168
+ return { unsubscribe: off };
169
+ });
170
+ }
171
+ }
172
+ /** Factory for the app's provider list. */
173
+ export function provideAnchorService() {
174
+ return [{ provide: "AnchorService", useFactory: (db) => new AnchorService(db), deps: [ANCHOR_DB] }];
175
+ }
176
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EACR,YAAY,EACZ,iBAAiB,GAMlB,MAAM,UAAU,CAAC;AAqClB;;;;;GAKG;AACH,MAAM,OAAO,gBAAgB;IAG3B,YAAY,WAAsD;QAChE,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;IACjC,CAAC;IAED,SAAS,CAAC,QAAqD;QAC7D,MAAM,UAAU,GACd,OAAO,QAAQ,KAAK,UAAU;YAC5B,CAAC,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC,SAAS,EAAE,QAAQ,EAAE,GAAG,EAAE,CAAC,SAAS,EAAE;YACvE,CAAC,CAAC;gBACE,IAAI,EAAE,QAAQ,CAAC,IAAI,IAAI,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC;gBACxC,KAAK,EAAE,QAAQ,CAAC,KAAK,IAAI,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC;gBAC1C,QAAQ,EAAE,QAAQ,CAAC,QAAQ,IAAI,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC;aACj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E,OAAO,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC,EAAE,CAC3E,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC;IAED,mFAAmF;IACnF,WAAW;QACT,OAAO,IAAI,gBAAgB,CAAC,CAAC,QAAQ,EAAE,EAAE,CACvC,iBAAiB,CAAC,IAAI,CAAC,EAAE,EAAE;YACzB,IAAI,EAAE,CAAC,KAAK,EAAE,EAAE,CACd,QAAQ,CAAC,IAAI,CAAC;gBACZ,MAAM,EAAE,KAAK,CAAC,MAAoB;gBAClC,OAAO,EAAE,KAAK,CAAC,OAAO;gBACtB,OAAO,EAAE,IAAI,CAAC,EAAE,CAAC,WAAW;aAC7B,CAAC;SACL,CAAC,CACH,CAAC;IACJ,CAAC;IAED,2CAA2C;IAC3C,GAAG,CAAc,KAAoC;QACnD,OAAO,IAAI,gBAAgB,CAAI,CAAC,QAAQ,EAAE,EAAE;YAC1C,MAAM,GAAG,GAAG,IAAI,CAAC,EAAE,CAAC,EAAE,CAAC,KAAK,EAAE,CAAC,OAAO,EAAE,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAY,CAAC,CAAC,CAAC;YACxE,OAAO,EAAE,WAAW,EAAE,GAAG,EAAE,CAAC;QAC9B,CAAC,CAAC,CAAC;IACL,CAAC;CACF;AAED,2CAA2C;AAC3C,MAAM,UAAU,oBAAoB;IAClC,OAAO,CAAC,EAAE,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,CAAC,EAAY,EAAE,EAAE,CAAC,IAAI,aAAa,CAAC,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,SAAS,CAAC,EAAE,CAAC,CAAC;AAChH,CAAC"}
@@ -0,0 +1,3 @@
1
+ {
2
+ "type": "module"
3
+ }
package/package.json ADDED
@@ -0,0 +1,69 @@
1
+ {
2
+ "name": "anchordb-angular",
3
+ "version": "0.2.0",
4
+ "license": "MIT",
5
+ "type": "module",
6
+ "sideEffects": false,
7
+ "main": "./dist/cjs/index.js",
8
+ "module": "./dist/esm/index.js",
9
+ "types": "./dist/esm/index.d.ts",
10
+ "exports": {
11
+ ".": {
12
+ "import": {
13
+ "types": "./dist/esm/index.d.ts",
14
+ "default": "./dist/esm/index.js"
15
+ },
16
+ "require": {
17
+ "types": "./dist/cjs/index.d.ts",
18
+ "default": "./dist/cjs/index.js"
19
+ }
20
+ },
21
+ "./package.json": "./package.json"
22
+ },
23
+ "files": [
24
+ "dist",
25
+ "README.md",
26
+ "LICENSE"
27
+ ],
28
+ "scripts": {
29
+ "build": "rimraf dist && tsc -p tsconfig.build.json && tsc -p tsconfig.build.cjs.json && node ../core/scripts/finalize-dist.mjs",
30
+ "typecheck": "tsc --noEmit -p tsconfig.json",
31
+ "check:package": "publint && attw --pack . --profile node16",
32
+ "prepublishOnly": "npm run typecheck && npm run build"
33
+ },
34
+ "dependencies": {
35
+ "anchordb": "^0.2.0"
36
+ },
37
+ "devDependencies": {
38
+ "rimraf": "^6.0.1"
39
+ },
40
+ "publishConfig": {
41
+ "access": "public"
42
+ },
43
+ "description": "Angular/Ionic bindings for AnchorDB — NgModule, DI and RxJS observables.",
44
+ "peerDependencies": {
45
+ "@angular/core": ">=16",
46
+ "rxjs": ">=7"
47
+ },
48
+ "peerDependenciesMeta": {
49
+ "@angular/core": {
50
+ "optional": true
51
+ },
52
+ "rxjs": {
53
+ "optional": true
54
+ }
55
+ },
56
+ "repository": {
57
+ "type": "git",
58
+ "url": "git+https://github.com/knnadeera/anchordb.git",
59
+ "directory": "packages/angular"
60
+ },
61
+ "homepage": "https://github.com/knnadeera/anchordb#readme",
62
+ "bugs": {
63
+ "url": "https://github.com/knnadeera/anchordb/issues"
64
+ },
65
+ "engines": {
66
+ "node": ">=20"
67
+ },
68
+ "author": "Nisala Nadeera <knnadeera@gmail.com>"
69
+ }