@nxgt/janus-mongo 0.4.3 → 0.5.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.
@@ -1,54 +0,0 @@
1
- import type { RelationStore } from '@nxgt/janus/permissions';
2
- import { type SyncOptions, type SyncReport } from '@nxgt/mongo';
3
- import type { Db } from 'mongodb';
4
- import { z } from 'zod';
5
- /**
6
- * The tuples, one document each, **keyed by the tuple itself**:
7
- * `{ _id: { object: { type, id }, relation, subject: { type, id, relation? } } }`.
8
- *
9
- * The key is the port's `RelationTuple`, as written, so uniqueness is the
10
- * `_id` index every collection has — a constraint, never a read — an insert
11
- * of a stored tuple is a retry, and a document read in a shell is the tuple
12
- * in the code. A subject set carries `relation`, an entity does not, so
13
- * `team:t1#members` and `team:t1` are two keys.
14
- *
15
- * The key is always built by {@link keyOf}, in one field order: MongoDB
16
- * compares embedded documents field by field, in order.
17
- */
18
- export declare const relations: import("@nxgt/mongo").CollectionDefinition<import("@nxgt/mongo").StampedSchema<{
19
- _id: z.ZodObject<{
20
- object: z.ZodObject<{
21
- type: z.ZodString;
22
- id: z.ZodString;
23
- }, z.core.$strip>;
24
- relation: z.ZodString;
25
- subject: z.ZodObject<{
26
- type: z.ZodString;
27
- id: z.ZodString;
28
- relation: z.ZodOptional<z.ZodString>;
29
- }, z.core.$strip>;
30
- }, z.core.$strip>;
31
- }, false, false, false, false>, import("@nxgt/mongo").StampNamesOf<false, false, false, false>>;
32
- /**
33
- * The relation store `permissions()` takes, over one MongoDB database — and
34
- * the one `janus({ relations })` deletes a user's tuples from.
35
- *
36
- * ```ts
37
- * await syncMongoRelations(db); // a deployment step: creates the indexes
38
- * const access = permissions({ model, store: createMongoRelations(db) });
39
- * ```
40
- *
41
- * **A write of more than one tuple is a transaction**, which MongoDB runs on
42
- * a replica set only — as every production deployment is. `grant` and
43
- * `revoke` write one tuple, and run anywhere. The transaction is not retried
44
- * here: the driver's `withTransaction` would retry an outage for two minutes
45
- * before answering, and a write is idempotent, so the caller retries.
46
- */
47
- export declare function createMongoRelations(db: Db): RelationStore;
48
- /**
49
- * Creates the collection and its indexes, and says what it changed. A
50
- * deployment step, as `syncMongoStores` is — and a separate one, because an
51
- * application that only authenticates keeps no tuples.
52
- */
53
- export declare function syncMongoRelations(db: Db, options?: SyncOptions): Promise<SyncReport[]>;
54
- //# sourceMappingURL=relations.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"relations.d.ts","sourceRoot":"","sources":["../src/relations.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAIN,KAAK,WAAW,EAChB,KAAK,UAAU,EAEf,MAAM,aAAa,CAAC;AACrB,OAAO,KAAK,EAAiB,EAAE,EAAU,MAAM,SAAS,CAAC;AACzD,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,SAAS;;;;;;;;;;;;;+FAqCpB,CAAC;AAKH;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,oBAAoB,CAAC,EAAE,EAAE,EAAE,GAAG,aAAa,CA+H1D;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CACjC,EAAE,EAAE,EAAE,EACN,OAAO,CAAC,EAAE,WAAW,GACnB,OAAO,CAAC,UAAU,EAAE,CAAC,CAEvB"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"stores.d.ts","sourceRoot":"","sources":["../src/stores.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACX,WAAW,EAQX,MAAM,aAAa,CAAC;AAErB,OAAO,EAGN,KAAK,WAAW,EAChB,KAAK,UAAU,EAEf,MAAM,aAAa,CAAC;AACrB,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,SAAS,CAAC;AAclC;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,iBAAiB,CAAC,EAAE,EAAE,EAAE,GAAG,WAAW,CAMrD;AAED;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAC9B,EAAE,EAAE,EAAE,EACN,OAAO,CAAC,EAAE,WAAW,GACnB,OAAO,CAAC,UAAU,EAAE,CAAC,CAEvB"}