@latticecms/store-mongo 0.0.0-stage → 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 (53) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +171 -2
  3. package/dist/errors.d.ts +28 -0
  4. package/dist/errors.d.ts.map +1 -0
  5. package/dist/errors.js +40 -0
  6. package/dist/errors.js.map +1 -0
  7. package/dist/filter.d.ts +20 -0
  8. package/dist/filter.d.ts.map +1 -0
  9. package/dist/filter.js +113 -0
  10. package/dist/filter.js.map +1 -0
  11. package/dist/index.d.ts +5 -0
  12. package/dist/index.d.ts.map +1 -0
  13. package/dist/index.js +5 -0
  14. package/dist/index.js.map +1 -0
  15. package/dist/mapper.d.ts +33 -0
  16. package/dist/mapper.d.ts.map +1 -0
  17. package/dist/mapper.js +23 -0
  18. package/dist/mapper.js.map +1 -0
  19. package/dist/migrate.d.ts +51 -0
  20. package/dist/migrate.d.ts.map +1 -0
  21. package/dist/migrate.js +126 -0
  22. package/dist/migrate.js.map +1 -0
  23. package/dist/migration-error.d.ts +55 -0
  24. package/dist/migration-error.d.ts.map +1 -0
  25. package/dist/migration-error.js +42 -0
  26. package/dist/migration-error.js.map +1 -0
  27. package/dist/migration-lock.d.ts +30 -0
  28. package/dist/migration-lock.d.ts.map +1 -0
  29. package/dist/migration-lock.js +107 -0
  30. package/dist/migration-lock.js.map +1 -0
  31. package/dist/mongo-store.d.ts +58 -0
  32. package/dist/mongo-store.d.ts.map +1 -0
  33. package/dist/mongo-store.js +190 -0
  34. package/dist/mongo-store.js.map +1 -0
  35. package/dist/operations.d.ts +23 -0
  36. package/dist/operations.d.ts.map +1 -0
  37. package/dist/operations.js +149 -0
  38. package/dist/operations.js.map +1 -0
  39. package/dist/tracing.d.ts +14 -0
  40. package/dist/tracing.d.ts.map +1 -0
  41. package/dist/tracing.js +54 -0
  42. package/dist/tracing.js.map +1 -0
  43. package/package.json +74 -4
  44. package/src/errors.ts +43 -0
  45. package/src/filter.ts +127 -0
  46. package/src/index.ts +10 -0
  47. package/src/mapper.ts +30 -0
  48. package/src/migrate.ts +185 -0
  49. package/src/migration-error.ts +41 -0
  50. package/src/migration-lock.ts +146 -0
  51. package/src/mongo-store.ts +303 -0
  52. package/src/operations.ts +213 -0
  53. package/src/tracing.ts +64 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Cory Robinson
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 CHANGED
@@ -1,3 +1,172 @@
1
- # Temporary Holding Version
1
+ # @latticecms/store-mongo
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ The MongoDB `CollectionStore` for [`@latticecms/core`](../core). Each collection is a Mongo collection of the same name, and a document's `id` is its `_id`. Filters translate one to one into Mongo queries, and the store passes the conformance suite every Lattice store passes. It also runs the app's data migrations.
4
+
5
+ Status: before 1.0, not yet published.
6
+
7
+ ## Install
8
+
9
+ ```bash
10
+ npm install @latticecms/store-mongo @latticecms/core hexok @ts-pf/contract @ts-pf/protocol @ts-pf/server @ts-pf/docs @ts-pf/mcp zod @hexok/logger @opentelemetry/api
11
+ ```
12
+
13
+ `@latticecms/core`, `hexok`, `zod`, `@hexok/logger` and `@opentelemetry/api` are peer dependencies, shared with the app for the reasons [core's README](../core#install) gives. Install core's own peers too, as above. The `mongodb` driver is this package's own dependency: the store owns its client.
14
+
15
+ The tests run against MongoDB 8.0. Transactions need a replica set or a sharded cluster; see [Transactions](#transactions).
16
+
17
+ ## Wiring
18
+
19
+ Create the store. The crm reads its settings in one place, for the server, the worker and its scripts:
20
+
21
+ ```ts
22
+ // examples/crm/src/infra/store.ts
23
+ export function mongoStore(env: NodeJS.ProcessEnv): MongoStore {
24
+ const url = env.MONGODB_URL;
25
+ if (url === undefined) throw new Error('Set MONGODB_URL');
26
+ return new MongoStore({ url, database: env.MONGODB_DATABASE ?? 'crm' });
27
+ }
28
+ ```
29
+
30
+ Start it, migrate, create the indexes, then serve:
31
+
32
+ ```ts
33
+ // examples/crm/src/servers/http/server.ts
34
+ const crm = createApp({ store, events: deps.events });
35
+ await store.start();
36
+ await migrate(store, migrations, { logger });
37
+ await crm.ensure();
38
+ ```
39
+
40
+ On shutdown, stop the server taking requests, then the store:
41
+
42
+ ```ts
43
+ // examples/crm/src/servers/http/server.ts
44
+ await server.close();
45
+ await store.stop();
46
+ ```
47
+
48
+ `new MongoStore({ url, database, client? })` (`MongoStoreOptions`) takes a connection string, the database every collection lives in, and `MongoClientOptions` for its client. `serverSelectionTimeoutMS` bounds how long `start()` waits for the server.
49
+
50
+ ## Lifecycle
51
+
52
+ The store owns its `MongoClient`.
53
+
54
+ - `start()` connects and pings the server. A `start()` while one is pending joins it. A `start()` after `stop()` opens a new client. A failed start closes its client, and a later `start()` begins clean.
55
+ - `stop()` closes the client. A pending `start()` rejects with `Stopped`.
56
+ - A call before `start()` rejects with `MongoStoreError` `NotStarted`, during it with `Starting`, and after `stop()` with `Stopped`. These are the codes of hexok's Redis adapters, so an app matches every adapter on `error.code`. They mean the call came at the wrong time: fix the call order, and do not retry.
57
+
58
+ Start the store before the app serves traffic, and stop it after the server closes.
59
+
60
+ ## Transactions
61
+
62
+ Lattice uses `store.transaction(work)` for a delete that cascades or nullifies refs, and for a relation's `set`.
63
+
64
+ - On a replica set or a mongos, `work` runs in one Mongo transaction, with a view of the store whose every call carries the session. It commits, or on a throw writes nothing. The driver's `withTransaction` may run `work` again on a transient error.
65
+ - A standalone server has no transactions, so there `work` runs in order, on the store itself, without atomicity. Lattice's deletes write the parent last, so a failure partway leaves the parent in place, and the children already changed stay changed. Run production on a replica set; a single-node replica set is enough.
66
+ - An index is never built inside a transaction.
67
+
68
+ ## Queries
69
+
70
+ - `where` translates operator by operator: `eq`, `ne`, `in`, `nin`, `gt`, `gte`, `lt` and `lte` become their `$` operators. `contains` is a case-insensitive regex with every metacharacter escaped. `exists: true` is `{ $ne: null }` and `exists: false` is `{ $eq: null }`, because in Lattice null does not exist. `and` and `or` become `$and` and `$or`.
71
+ - Filters are combined with `$and`, never merged into one object, so a filter on `id` cannot replace the call's own id match.
72
+ - `find` sorts by the sort keys and then `_id`, and applies the cursor as one more filter.
73
+ - A duplicate key on `insert` or `update`, from the id or a unique index, is Lattice's `CONFLICT` with `{ collection, id }` of the document being written.
74
+ - `ensure(collection, indexes)` creates each index with `createIndex` and never drops one. `build().ensure()` calls it for every collection that declares indexes. An index with the same keys and other options rejects, and so does a unique index over existing duplicates: changing an index is a migration.
75
+ - `count` is `countDocuments`.
76
+ - `has` is equality on the array field, which Mongo matches against any element.
77
+
78
+ ## Migrations
79
+
80
+ A data migration changes stored documents once, such as backfilling a new field. Mongo has no schema to migrate; a breaking field change is a data migration. Migrations run forward only: a bad one is fixed by a new one.
81
+
82
+ ```ts
83
+ // examples/crm/src/infra/migrations/0001-backfill-deal-archived.ts
84
+ import type { Migration } from '@latticecms/store-mongo';
85
+
86
+ /**
87
+ * Deals written before `archived` existed have no such field, and the read
88
+ * filter `archived: { eq: false }` would hide them. Every organization's
89
+ * deals: a migration is system work, outside access and tenancy. The
90
+ * filter skips the deals already done, so a second run changes nothing.
91
+ */
92
+ export default {
93
+ id: 1,
94
+ name: 'backfill-deal-archived',
95
+ async up({ db, logger }) {
96
+ const { modifiedCount } = await db
97
+ .collection('deals')
98
+ .updateMany(
99
+ { archived: { $exists: false } },
100
+ { $set: { archived: false } },
101
+ );
102
+ logger.info('deals backfilled', { modifiedCount });
103
+ },
104
+ } satisfies Migration;
105
+ ```
106
+
107
+ `up` receives `{ db, session?, signal, logger }`. `db` is the store's raw Mongo database, because a migration reads documents in their old shape, which the collection's types no longer describe. `logger` is a child with the migration's `id` and `name`. The types are `Migration`, `MigrationContext` (what `up` receives), `MigrateOptions` and `Ran`.
108
+
109
+ The app lists its migrations explicitly, in id order:
110
+
111
+ ```ts
112
+ // examples/crm/src/infra/migrations/index.ts
113
+ import m0001 from './0001-backfill-deal-archived.js';
114
+
115
+ /** The app's data migrations, in id order. `migrate()` runs each once. */
116
+ export const migrations = [m0001];
117
+ ```
118
+
119
+ At startup, start the store, then migrate, then create indexes, as in [Wiring](#wiring), so a migration can fix duplicates before a unique index is built.
120
+
121
+ `migrate(store, migrations, { logger, lock? })` runs each pending migration once, in order, and returns `{ ran }`: each `{ id, name, durationMs }` that ran. Each one that runs is recorded in `_migrations` with its id, name, `ranAt` and `durationMs`, and logs one line with `id`, `name` and `durationMs`. When nothing is pending, it logs `migrations up to date`.
122
+
123
+ - **The list is checked first.** Ids run 1, 2, 3 … in list order. A gap, a duplicate, a recorded migration missing from the list, or a recorded one with another name throws a `MigrationError` (`Gap`, `Duplicate`, `Unknown`, `Renamed`) before any migration runs. File names such as `0002-rename-stage.ts` are a convention; the runner reads `id` and `name`.
124
+ - **A failure stops the run.** The migration is not recorded, its error passes through after one error log line, and the next run starts again at that migration. So write `up` to be safe to run twice. Filter on what is not done yet, as the CRM's backfill does with `archived: { $exists: false }`.
125
+
126
+ - **Transactions are opt-in.** With `transaction: true`, `up` gets a `session`, and its writes and its record commit together or not at all. Pass `{ session }` to every write. It needs a replica set, or the run throws `NoTransactions` before anything runs. A long migration can exceed Mongo's transaction limits, which is why it is not the default. The driver may run a transaction's callback again on a transient error, which `up` handles, since it is safe to re-run.
127
+ - **One process at a time.** A lease in `_migrations_lock` keeps two processes from migrating together. It is taken on the server's clock, renewed every third of `lock.ttlMs` (60 s by default), and released by a token, so a process never releases another's lease. A lease whose holder died expires and is taken over. A second process logs `migrations waiting for lock`, waits up to `lock.waitMs` (10 minutes by default), and then finds nothing left to run; past `waitMs` it rejects with `LockTimeout`. If the lease is lost while a migration runs, `signal` aborts, and the run stops with `LockLost` without recording that migration. Pass `signal` to long loops.
128
+
129
+ ### As a deploy step
130
+
131
+ An app that migrates before it starts, rather than at startup, runs `npx lattice migrate` from [`@latticecms/cli`](../cli#lattice-migrate) after its build. It imports a built module that exports the store, not started, and the list; the crm's is built from:
132
+
133
+ ```ts
134
+ // examples/crm/src/servers/scripts/migrate.ts
135
+ export const store = mongoStore(process.env);
136
+ export { migrations };
137
+ ```
138
+
139
+ The command starts the store, runs `migrate()` with a `ConsoleLogger`, stops the store, and exits 1 on a `MigrationError`. Its output is `migrate()`'s log. `lattice migration <name>` writes the next migration and appends it to the list; its `up()` throws until it is written, so an unwritten migration is never recorded as done.
140
+
141
+ ## Tracing
142
+
143
+ Each store call is one OpenTelemetry client span, a child of the active span, through `@opentelemetry/api`. With no SDK registered it is a no-op. The tracer is `@latticecms/store-mongo`.
144
+
145
+ - The span is named `{operation} {collection}`, such as `find deals`, after the Mongo command the call runs: `find` (find, get, getMany), `aggregate` (count), `insert`, `findAndModify` (update, remove) and `createIndexes` (ensure).
146
+ - Attributes: `db.system.name` (`mongodb`), `db.namespace` (the database), `db.operation.name` and `db.collection.name`.
147
+ - A transaction is one `transaction` span, and the calls in it are its children.
148
+ - A failed call sets status ERROR and `error.type`: Lattice's code, such as `CONFLICT`, or the error's name. It records no exception event, since a driver's message can quote a document's values, such as a duplicate key.
149
+ - There is no `db.query.text`. A Mongo filter has no parameters, so its text would carry the values it matches.
150
+
151
+ ## Errors
152
+
153
+ | Error | Code | When |
154
+ | --- | --- | --- |
155
+ | `LatticeError` | `CONFLICT` | A duplicate key on `insert` or `update`, from the id or a unique index. `data` is `{ collection, id }` of the document being written; the driver's message is never parsed or sent |
156
+ | `MongoStoreError` | `NotStarted`, `Starting`, `Stopped` | A call before `start()`, during it, or after `stop()`. Fix the call order; do not retry |
157
+ | `MigrationError` | `Gap`, `Duplicate`, `Unknown`, `Renamed` | The migration list does not match itself or what ran. Thrown before any migration runs |
158
+ | `MigrationError` | `NoTransactions` | A migration asks for a transaction on a deployment without them. Thrown before any migration runs |
159
+ | `MigrationError` | `LockTimeout`, `LockLost` | Another process held the lock past `waitMs`, or the lease was lost while a migration ran |
160
+
161
+ Each is a hexok `Errors` catalog, so `MongoStoreError.is(error)` and `error.code` narrow it. Anything else, such as a network error, passes through from the driver.
162
+
163
+ ## Known differences from `MemoryStore`
164
+
165
+ Both follow MongoDB's null and missing rules, and both pass the same conformance suite. Two differences remain, and the suite does not cover them:
166
+
167
+ - **String order.** MongoDB compares strings by their UTF-8 bytes, which is code point order. JavaScript compares UTF-16 code units. They agree on everything except U+E000–U+FFFF against characters above U+FFFF, which sort the other way. ASCII and ISO timestamps sort the same.
168
+ - **Case folding in `contains`.** MongoDB's case-insensitive regex and JavaScript's `toLowerCase` can disagree outside ASCII, such as for `ß` and the Turkish `İ`.
169
+
170
+ ## Tests
171
+
172
+ The package's tests run on [mongodb-memory-server](https://github.com/typegoose/mongodb-memory-server): one single-node replica set and one standalone server per run, started in vitest's `globalSetup`, and a fresh database per test. The standalone server runs the conformance cases that need no transactions. Nothing needs to be installed. The first run downloads `mongod` (about 100 MB) into `~/.cache/mongodb-binaries`, and later runs reuse it. The server version is pinned in `package.json` (`config.mongodbMemoryServer.version`), and `MONGOMS_VERSION` overrides it. Linux on musl, such as Alpine, has no `mongod` build.
@@ -0,0 +1,28 @@
1
+ declare const MongoStoreError_base: import("hexok").ErrorsHandle<"store-mongo", {
2
+ readonly NotStarted: {
3
+ readonly message: "MongoStore: start() has not been called. Await start() first.";
4
+ };
5
+ readonly Starting: {
6
+ readonly message: "MongoStore: start() has not finished. Await start() first.";
7
+ };
8
+ readonly Stopped: {
9
+ readonly message: "MongoStore: stop() was called. Start it again to use it.";
10
+ };
11
+ }>;
12
+ /**
13
+ * A call at the wrong time in the store's lifecycle. The codes are
14
+ * ioredis-lifecycle's, so an app matches every adapter's on `code`. Fix
15
+ * the call order; do not retry.
16
+ */
17
+ export declare class MongoStoreError extends MongoStoreError_base {
18
+ }
19
+ /** A duplicate key on a write: an id clash or a unique index. */
20
+ export declare function isDuplicateKey(error: unknown): boolean;
21
+ /**
22
+ * Runs a write of the document `id`, turning a duplicate key into Lattice's
23
+ * CONFLICT for that document. `id` is the document being written, which
24
+ * the caller always knows, so the driver's message is never parsed.
25
+ */
26
+ export declare function writing<T>(collection: string, id: string, write: () => Promise<T>): Promise<T>;
27
+ export {};
28
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":";;;;;;;;;;;AAIA;;;;GAIG;AACH,qBAAa,eAAgB,SAAQ,oBAUnC;CAAG;AAEL,iEAAiE;AACjE,wBAAgB,cAAc,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAEtD;AAED;;;;GAIG;AACH,wBAAsB,OAAO,CAAC,CAAC,EAC7B,UAAU,EAAE,MAAM,EAClB,EAAE,EAAE,MAAM,EACV,KAAK,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GACtB,OAAO,CAAC,CAAC,CAAC,CAOZ"}
package/dist/errors.js ADDED
@@ -0,0 +1,40 @@
1
+ import { LatticeError } from '@latticecms/core';
2
+ import { Errors } from 'hexok';
3
+ import { MongoServerError } from 'mongodb';
4
+ /**
5
+ * A call at the wrong time in the store's lifecycle. The codes are
6
+ * ioredis-lifecycle's, so an app matches every adapter's on `code`. Fix
7
+ * the call order; do not retry.
8
+ */
9
+ export class MongoStoreError extends Errors('store-mongo', {
10
+ NotStarted: {
11
+ message: 'MongoStore: start() has not been called. Await start() first.',
12
+ },
13
+ Starting: {
14
+ message: 'MongoStore: start() has not finished. Await start() first.',
15
+ },
16
+ Stopped: {
17
+ message: 'MongoStore: stop() was called. Start it again to use it.',
18
+ },
19
+ }) {
20
+ }
21
+ /** A duplicate key on a write: an id clash or a unique index. */
22
+ export function isDuplicateKey(error) {
23
+ return error instanceof MongoServerError && error.code === 11000;
24
+ }
25
+ /**
26
+ * Runs a write of the document `id`, turning a duplicate key into Lattice's
27
+ * CONFLICT for that document. `id` is the document being written, which
28
+ * the caller always knows, so the driver's message is never parsed.
29
+ */
30
+ export async function writing(collection, id, write) {
31
+ try {
32
+ return await write();
33
+ }
34
+ catch (error) {
35
+ if (isDuplicateKey(error))
36
+ throw LatticeError.CONFLICT({ collection, id });
37
+ throw error;
38
+ }
39
+ }
40
+ //# sourceMappingURL=errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAE3C;;;;GAIG;AACH,MAAM,OAAO,eAAgB,SAAQ,MAAM,CAAC,aAAa,EAAE;IACzD,UAAU,EAAE;QACV,OAAO,EAAE,+DAA+D;KACzE;IACD,QAAQ,EAAE;QACR,OAAO,EAAE,4DAA4D;KACtE;IACD,OAAO,EAAE;QACP,OAAO,EAAE,0DAA0D;KACpE;CACF,CAAC;CAAG;AAEL,iEAAiE;AACjE,MAAM,UAAU,cAAc,CAAC,KAAc;IAC3C,OAAO,KAAK,YAAY,gBAAgB,IAAI,KAAK,CAAC,IAAI,KAAK,KAAK,CAAC;AACnE,CAAC;AAED;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,OAAO,CAC3B,UAAkB,EAClB,EAAU,EACV,KAAuB;IAEvB,IAAI,CAAC;QACH,OAAO,MAAM,KAAK,EAAE,CAAC;IACvB,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAI,cAAc,CAAC,KAAK,CAAC;YAAE,MAAM,YAAY,CAAC,QAAQ,CAAC,EAAE,UAAU,EAAE,EAAE,EAAE,CAAC,CAAC;QAC3E,MAAM,KAAK,CAAC;IACd,CAAC;AACH,CAAC"}
@@ -0,0 +1,20 @@
1
+ import type { AnyWhere, Order } from '@latticecms/core/store';
2
+ import type { Document } from 'mongodb';
3
+ /** The Mongo field that holds a Lattice field: `id` is kept in `_id`. */
4
+ export declare function mongoField(field: string): string;
5
+ /** `text` with every regex metacharacter escaped, so it matches literally. */
6
+ export declare function escapeRegex(text: string): string;
7
+ /**
8
+ * Both filters. Never merged by spreading: two filters can name the same
9
+ * field, and a spread would let one replace the other's condition.
10
+ */
11
+ export declare function and(...filters: readonly (Document | undefined)[]): Document;
12
+ /**
13
+ * A parsed `Where` as a Mongo filter, one to one: the matcher already
14
+ * follows Mongo's null and missing rules. Fields become one object, which
15
+ * Mongo ANDs; `and` and `or` become `$and` and `$or`.
16
+ */
17
+ export declare function toFilter(where: AnyWhere | undefined): Document;
18
+ /** A Lattice order as a Mongo sort spec, in key order. */
19
+ export declare function toSort(order: Order): [string, 1 | -1][];
20
+ //# sourceMappingURL=filter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"filter.d.ts","sourceRoot":"","sources":["../src/filter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAY,KAAK,EAAE,MAAM,wBAAwB,CAAC;AACxE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAExC,yEAAyE;AACzE,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAEhD;AAED,8EAA8E;AAC9E,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAEhD;AAED;;;GAGG;AACH,wBAAgB,GAAG,CAAC,GAAG,OAAO,EAAE,SAAS,CAAC,QAAQ,GAAG,SAAS,CAAC,EAAE,GAAG,QAAQ,CAQ3E;AAuED;;;;GAIG;AACH,wBAAgB,QAAQ,CAAC,KAAK,EAAE,QAAQ,GAAG,SAAS,GAAG,QAAQ,CAoB9D;AAED,0DAA0D;AAC1D,wBAAgB,MAAM,CAAC,KAAK,EAAE,KAAK,GAAG,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAEvD"}
package/dist/filter.js ADDED
@@ -0,0 +1,113 @@
1
+ /** The Mongo field that holds a Lattice field: `id` is kept in `_id`. */
2
+ export function mongoField(field) {
3
+ return field === 'id' ? '_id' : field;
4
+ }
5
+ /** `text` with every regex metacharacter escaped, so it matches literally. */
6
+ export function escapeRegex(text) {
7
+ return text.replace(/[.*+?^${}()|[\]\\/-]/g, '\\$&');
8
+ }
9
+ /**
10
+ * Both filters. Never merged by spreading: two filters can name the same
11
+ * field, and a spread would let one replace the other's condition.
12
+ */
13
+ export function and(...filters) {
14
+ const present = filters.filter((filter) => filter !== undefined && Object.keys(filter).length > 0);
15
+ if (present.length === 0)
16
+ return {};
17
+ if (present.length === 1)
18
+ return present[0] ?? {};
19
+ return { $and: present };
20
+ }
21
+ /** Matches no document. Mongo rejects an empty `$or`; the matcher finds nothing. */
22
+ const nothing = { $expr: false };
23
+ /** The Mongo conditions of one field's operators, each as `[operator, value]`. */
24
+ function conditions(ops) {
25
+ const out = [];
26
+ for (const [op, value] of Object.entries(ops)) {
27
+ if (value === undefined)
28
+ continue;
29
+ switch (op) {
30
+ case 'eq':
31
+ case 'ne':
32
+ case 'in':
33
+ case 'nin':
34
+ case 'gt':
35
+ case 'gte':
36
+ case 'lt':
37
+ case 'lte':
38
+ out.push([`$${op}`, value]);
39
+ break;
40
+ case 'contains':
41
+ // Case-insensitive and literal, never a pattern. A regex matches
42
+ // strings only, as `contains` does.
43
+ out.push(['$regex', escapeRegex(String(value))], ['$options', 'i']);
44
+ break;
45
+ case 'has':
46
+ // On an array field, Mongo's equality matches any element.
47
+ out.push(['$eq', value]);
48
+ break;
49
+ case 'exists':
50
+ // Lattice's exists asks whether a field has a value, so null does
51
+ // not exist. Mongo's $exists would count null as present.
52
+ out.push(value === true ? ['$ne', null] : ['$eq', null]);
53
+ break;
54
+ default:
55
+ throw new Error(`MongoStore: unknown operator "${op}"`);
56
+ }
57
+ }
58
+ return out;
59
+ }
60
+ /**
61
+ * The filter for one field. Its operators share one object, unless two map
62
+ * to the same Mongo operator (`ne` with `exists: true`), when each gets its
63
+ * own clause.
64
+ */
65
+ function fieldFilter(field, ops) {
66
+ const name = mongoField(field);
67
+ const pairs = conditions(ops);
68
+ const operators = pairs.map(([op]) => op);
69
+ if (new Set(operators).size === operators.length) {
70
+ return { [name]: Object.fromEntries(pairs) };
71
+ }
72
+ return and(...pairs
73
+ .filter(([op]) => op !== '$options')
74
+ .map(([op, value]) => op === '$regex'
75
+ ? { [name]: { $regex: value, $options: 'i' } }
76
+ : { [name]: { [op]: value } }));
77
+ }
78
+ function isClauses(condition) {
79
+ return Array.isArray(condition);
80
+ }
81
+ /**
82
+ * A parsed `Where` as a Mongo filter, one to one: the matcher already
83
+ * follows Mongo's null and missing rules. Fields become one object, which
84
+ * Mongo ANDs; `and` and `or` become `$and` and `$or`.
85
+ */
86
+ export function toFilter(where) {
87
+ if (where === undefined)
88
+ return {};
89
+ const fields = [];
90
+ const clauses = [];
91
+ for (const [field, condition] of Object.entries(where)) {
92
+ if (condition === undefined)
93
+ continue;
94
+ if (!isClauses(condition)) {
95
+ fields.push(fieldFilter(field, condition));
96
+ }
97
+ else if (field === 'and') {
98
+ clauses.push(...condition.map(toFilter));
99
+ }
100
+ else {
101
+ clauses.push(condition.length === 0 ? nothing : { $or: condition.map(toFilter) });
102
+ }
103
+ }
104
+ // Each field is named once, so field filters without `$and` merge.
105
+ const simple = fields.filter((filter) => !('$and' in filter));
106
+ const nested = fields.filter((filter) => '$and' in filter);
107
+ return and(Object.assign({}, ...simple), ...nested, ...clauses);
108
+ }
109
+ /** A Lattice order as a Mongo sort spec, in key order. */
110
+ export function toSort(order) {
111
+ return order.map(({ field, direction }) => [mongoField(field), direction]);
112
+ }
113
+ //# sourceMappingURL=filter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"filter.js","sourceRoot":"","sources":["../src/filter.ts"],"names":[],"mappings":"AAGA,yEAAyE;AACzE,MAAM,UAAU,UAAU,CAAC,KAAa;IACtC,OAAO,KAAK,KAAK,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC;AACxC,CAAC;AAED,8EAA8E;AAC9E,MAAM,UAAU,WAAW,CAAC,IAAY;IACtC,OAAO,IAAI,CAAC,OAAO,CAAC,uBAAuB,EAAE,MAAM,CAAC,CAAC;AACvD,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,GAAG,CAAC,GAAG,OAA0C;IAC/D,MAAM,OAAO,GAAG,OAAO,CAAC,MAAM,CAC5B,CAAC,MAAM,EAAsB,EAAE,CAC7B,MAAM,KAAK,SAAS,IAAI,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,MAAM,GAAG,CAAC,CACzD,CAAC;IACF,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,EAAE,CAAC;IACpC,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,OAAO,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;IAClD,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;AAC3B,CAAC;AAED,oFAAoF;AACpF,MAAM,OAAO,GAAa,EA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@@
1
+ export { MongoStoreError } from './errors.js';
2
+ export { type MigrateOptions, type Migration, type MigrationContext, migrate, type Ran, } from './migrate.js';
3
+ export { MigrationError } from './migration-error.js';
4
+ export { MongoStore, type MongoStoreOptions } from './mongo-store.js';
5
+ //# 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,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EACL,KAAK,cAAc,EACnB,KAAK,SAAS,EACd,KAAK,gBAAgB,EACrB,OAAO,EACP,KAAK,GAAG,GACT,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,UAAU,EAAE,KAAK,iBAAiB,EAAE,MAAM,kBAAkB,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,5 @@
1
+ export { MongoStoreError } from './errors.js';
2
+ export { migrate, } from './migrate.js';
3
+ export { MigrationError } from './migration-error.js';
4
+ export { MongoStore } from './mongo-store.js';
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EAIL,OAAO,GAER,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,UAAU,EAA0B,MAAM,kBAAkB,CAAC"}
@@ -0,0 +1,33 @@
1
+ import type { StoredDoc } from '@latticecms/core/store';
2
+ import { z } from 'zod';
3
+ /** The same document in MongoDB: `id` kept in `_id`, as a string. */
4
+ declare const mongoDoc: z.ZodObject<{
5
+ _id: z.ZodString;
6
+ }, z.core.$loose>;
7
+ /** A Mongo document as the driver reads and writes it. */
8
+ export type MongoDocument = z.output<typeof mongoDoc>;
9
+ declare const MongoDoc_base: (abstract new () => import("hexok").MapperClass<"mongo.StoredDoc", z.ZodObject<{
10
+ id: z.ZodString;
11
+ }, z.core.$loose>, z.ZodObject<{
12
+ _id: z.ZodString;
13
+ }, z.core.$loose>>) & {
14
+ readonly token: "mongo.StoredDoc";
15
+ readonly schema: z.ZodObject<{
16
+ _id: z.ZodString;
17
+ }, z.core.$loose>;
18
+ readonly source: z.ZodObject<{
19
+ id: z.ZodString;
20
+ }, z.core.$loose>;
21
+ };
22
+ /**
23
+ * Maps a `StoredDoc` to its Mongo document and back. Only `id` moves; every
24
+ * other field keeps its name and value. Each direction builds a new object,
25
+ * so the driver's insert, which adds `_id` to what it is given, never
26
+ * touches the caller's document.
27
+ */
28
+ export declare class MongoDoc extends MongoDoc_base {
29
+ protected fromSource(doc: StoredDoc): MongoDocument;
30
+ protected toSource(doc: MongoDocument): StoredDoc;
31
+ }
32
+ export {};
33
+ //# sourceMappingURL=mapper.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mapper.d.ts","sourceRoot":"","sources":["../src/mapper.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAExD,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAKxB,qEAAqE;AACrE,QAAA,MAAM,QAAQ;;iBAAqC,CAAC;AAEpD,0DAA0D;AAC1D,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,QAAQ,CAAC,CAAC;;;;;;;;;;;;;;AAEtD;;;;;GAKG;AACH,qBAAa,QAAS,SAAQ,aAA8C;IAC1E,SAAS,CAAC,UAAU,CAAC,GAAG,EAAE,SAAS,GAAG,aAAa;IAKnD,SAAS,CAAC,QAAQ,CAAC,GAAG,EAAE,aAAa,GAAG,SAAS;CAIlD"}
package/dist/mapper.js ADDED
@@ -0,0 +1,23 @@
1
+ import { Mapper } from 'hexok';
2
+ import { z } from 'zod';
3
+ /** A document as Lattice stores it: `id` and any fields. */
4
+ const storedDoc = z.looseObject({ id: z.string() });
5
+ /** The same document in MongoDB: `id` kept in `_id`, as a string. */
6
+ const mongoDoc = z.looseObject({ _id: z.string() });
7
+ /**
8
+ * Maps a `StoredDoc` to its Mongo document and back. Only `id` moves; every
9
+ * other field keeps its name and value. Each direction builds a new object,
10
+ * so the driver's insert, which adds `_id` to what it is given, never
11
+ * touches the caller's document.
12
+ */
13
+ export class MongoDoc extends Mapper('mongo.StoredDoc', storedDoc, mongoDoc) {
14
+ fromSource(doc) {
15
+ const { id, ...fields } = doc;
16
+ return { ...fields, _id: id };
17
+ }
18
+ toSource(doc) {
19
+ const { _id, ...fields } = doc;
20
+ return { ...fields, id: _id };
21
+ }
22
+ }
23
+ //# sourceMappingURL=mapper.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mapper.js","sourceRoot":"","sources":["../src/mapper.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,4DAA4D;AAC5D,MAAM,SAAS,GAAG,CAAC,CAAC,WAAW,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;AAEpD,qEAAqE;AACrE,MAAM,QAAQ,GAAG,CAAC,CAAC,WAAW,CAAC,EAAE,GAAG,EAAE,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;AAKpD;;;;;GAKG;AACH,MAAM,OAAO,QAAS,SAAQ,MAAM,CAAC,iBAAiB,EAAE,SAAS,EAAE,QAAQ,CAAC;IAChE,UAAU,CAAC,GAAc;QACjC,MAAM,EAAE,EAAE,EAAE,GAAG,MAAM,EAAE,GAAG,GAAG,CAAC;QAC9B,OAAO,EAAE,GAAG,MAAM,EAAE,GAAG,EAAE,EAAE,EAAE,CAAC;IAChC,CAAC;IAES,QAAQ,CAAC,GAAkB;QACnC,MAAM,EAAE,GAAG,EAAE,GAAG,MAAM,EAAE,GAAG,GAAG,CAAC;QAC/B,OAAO,EAAE,GAAG,MAAM,EAAE,EAAE,EAAE,GAAG,EAAE,CAAC;IAChC,CAAC;CACF"}
@@ -0,0 +1,51 @@
1
+ import type { Logger } from '@hexok/logger';
2
+ import type { ClientSession, Db } from 'mongodb';
3
+ import { type MongoStore } from './mongo-store.js';
4
+ /** What a migration's `up` receives. */
5
+ export type MigrationContext = {
6
+ /** The store's database, raw: a migration reads documents in their old shape. */
7
+ readonly db: Db;
8
+ /** The transaction's session, when the migration sets `transaction: true`. */
9
+ readonly session?: ClientSession;
10
+ /** Aborts when the migrations lock is lost. Pass it to long loops. */
11
+ readonly signal: AbortSignal;
12
+ /** A child of the runner's logger, with the migration's id and name. */
13
+ readonly logger: Logger;
14
+ };
15
+ /**
16
+ * One data migration. Forward only. `up` must be safe to run again after it
17
+ * failed partway: the next run retries it.
18
+ */
19
+ export type Migration = {
20
+ /** 1, 2, 3 … in list order. */
21
+ readonly id: number;
22
+ readonly name: string;
23
+ /** Runs `up` and its record in one transaction. Needs a replica set. */
24
+ readonly transaction?: boolean;
25
+ up(context: MigrationContext): Promise<void>;
26
+ };
27
+ export type MigrateOptions = {
28
+ readonly logger: Logger;
29
+ readonly lock?: {
30
+ /** A lease's lifetime without renewal. Default 60 000. */
31
+ readonly ttlMs?: number;
32
+ /** How long to wait for another process's lease. Default 600 000. */
33
+ readonly waitMs?: number;
34
+ };
35
+ };
36
+ export type Ran = {
37
+ readonly id: number;
38
+ readonly name: string;
39
+ readonly durationMs: number;
40
+ };
41
+ /**
42
+ * Runs each pending migration once, in id order, under a lease lock in the
43
+ * store's database (0027). The store must be started. A second process
44
+ * waits for the lock, then finds nothing left to run. A migration that
45
+ * throws is not recorded: the error passes through, and the next run
46
+ * retries it.
47
+ */
48
+ export declare function migrate(store: MongoStore, migrations: readonly Migration[], options: MigrateOptions): Promise<{
49
+ readonly ran: readonly Ran[];
50
+ }>;
51
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