@nxgt/janus 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 (112) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +554 -0
  3. package/dist/auth/config.d.ts +201 -0
  4. package/dist/auth/config.d.ts.map +1 -0
  5. package/dist/auth/context.d.ts +87 -0
  6. package/dist/auth/context.d.ts.map +1 -0
  7. package/dist/auth/hashers.d.ts +35 -0
  8. package/dist/auth/hashers.d.ts.map +1 -0
  9. package/dist/auth/index.d.ts +9 -0
  10. package/dist/auth/index.d.ts.map +1 -0
  11. package/dist/auth/janus.d.ts +38 -0
  12. package/dist/auth/janus.d.ts.map +1 -0
  13. package/dist/auth/outage.d.ts +61 -0
  14. package/dist/auth/outage.d.ts.map +1 -0
  15. package/dist/auth/port/assert-stores.d.ts +16 -0
  16. package/dist/auth/port/assert-stores.d.ts.map +1 -0
  17. package/dist/auth/port/memory.d.ts +25 -0
  18. package/dist/auth/port/memory.d.ts.map +1 -0
  19. package/dist/auth/port/types.d.ts +393 -0
  20. package/dist/auth/port/types.d.ts.map +1 -0
  21. package/dist/auth/secrets.d.ts +17 -0
  22. package/dist/auth/secrets.d.ts.map +1 -0
  23. package/dist/auth/sessions.d.ts +31 -0
  24. package/dist/auth/sessions.d.ts.map +1 -0
  25. package/dist/auth/standard-schema.d.ts +41 -0
  26. package/dist/auth/standard-schema.d.ts.map +1 -0
  27. package/dist/auth/types.d.ts +353 -0
  28. package/dist/auth/types.d.ts.map +1 -0
  29. package/dist/auth/users.d.ts +9 -0
  30. package/dist/auth/users.d.ts.map +1 -0
  31. package/dist/chunks/index-658b6mr2.js +269 -0
  32. package/dist/chunks/index-658b6mr2.js.map +11 -0
  33. package/dist/chunks/index-6dytvy3h.js +93 -0
  34. package/dist/chunks/index-6dytvy3h.js.map +11 -0
  35. package/dist/chunks/index-6p56fpbe.js +147 -0
  36. package/dist/chunks/index-6p56fpbe.js.map +12 -0
  37. package/dist/chunks/index-fgb3t64y.js +77 -0
  38. package/dist/chunks/index-fgb3t64y.js.map +10 -0
  39. package/dist/conformance/assert.d.ts +36 -0
  40. package/dist/conformance/assert.d.ts.map +1 -0
  41. package/dist/conformance/cases/outage.d.ts +3 -0
  42. package/dist/conformance/cases/outage.d.ts.map +1 -0
  43. package/dist/conformance/cases/sessions.d.ts +3 -0
  44. package/dist/conformance/cases/sessions.d.ts.map +1 -0
  45. package/dist/conformance/cases/tokens.d.ts +3 -0
  46. package/dist/conformance/cases/tokens.d.ts.map +1 -0
  47. package/dist/conformance/cases/users.d.ts +3 -0
  48. package/dist/conformance/cases/users.d.ts.map +1 -0
  49. package/dist/conformance/describe.d.ts +74 -0
  50. package/dist/conformance/describe.d.ts.map +1 -0
  51. package/dist/conformance/fixtures.d.ts +11 -0
  52. package/dist/conformance/fixtures.d.ts.map +1 -0
  53. package/dist/conformance/index.d.ts +33 -0
  54. package/dist/conformance/index.d.ts.map +1 -0
  55. package/dist/conformance/index.js +1113 -0
  56. package/dist/conformance/index.js.map +18 -0
  57. package/dist/conformance/reference.d.ts +13 -0
  58. package/dist/conformance/reference.d.ts.map +1 -0
  59. package/dist/conformance/relations.d.ts +67 -0
  60. package/dist/conformance/relations.d.ts.map +1 -0
  61. package/dist/conformance/types.d.ts +71 -0
  62. package/dist/conformance/types.d.ts.map +1 -0
  63. package/dist/errors/janus-error.d.ts +259 -0
  64. package/dist/errors/janus-error.d.ts.map +1 -0
  65. package/dist/ids/id.d.ts +55 -0
  66. package/dist/ids/id.d.ts.map +1 -0
  67. package/dist/index.d.ts +30 -0
  68. package/dist/index.d.ts.map +1 -0
  69. package/dist/index.js +962 -0
  70. package/dist/index.js.map +19 -0
  71. package/dist/pagination/cursor-page.d.ts +53 -0
  72. package/dist/pagination/cursor-page.d.ts.map +1 -0
  73. package/dist/permissions/engine.d.ts +46 -0
  74. package/dist/permissions/engine.d.ts.map +1 -0
  75. package/dist/permissions/index.d.ts +24 -0
  76. package/dist/permissions/index.d.ts.map +1 -0
  77. package/dist/permissions/index.js +685 -0
  78. package/dist/permissions/index.js.map +15 -0
  79. package/dist/permissions/input.d.ts +29 -0
  80. package/dist/permissions/input.d.ts.map +1 -0
  81. package/dist/permissions/model.d.ts +368 -0
  82. package/dist/permissions/model.d.ts.map +1 -0
  83. package/dist/permissions/port/memory.d.ts +17 -0
  84. package/dist/permissions/port/memory.d.ts.map +1 -0
  85. package/dist/permissions/port/types.d.ts +84 -0
  86. package/dist/permissions/port/types.d.ts.map +1 -0
  87. package/dist/permissions/resolve.d.ts +59 -0
  88. package/dist/permissions/resolve.d.ts.map +1 -0
  89. package/dist/permissions/reverse.d.ts +53 -0
  90. package/dist/permissions/reverse.d.ts.map +1 -0
  91. package/dist/permissions/walk.d.ts +29 -0
  92. package/dist/permissions/walk.d.ts.map +1 -0
  93. package/dist/subjects/notation.d.ts +35 -0
  94. package/dist/subjects/notation.d.ts.map +1 -0
  95. package/dist/subjects/subject.d.ts +75 -0
  96. package/dist/subjects/subject.d.ts.map +1 -0
  97. package/dist/time/clock.d.ts +31 -0
  98. package/dist/time/clock.d.ts.map +1 -0
  99. package/dist/time/duration.d.ts +23 -0
  100. package/dist/time/duration.d.ts.map +1 -0
  101. package/docs/README.md +17 -0
  102. package/docs/guide/adapters.md +296 -0
  103. package/docs/guide/email-flows.md +146 -0
  104. package/docs/guide/errors.md +146 -0
  105. package/docs/guide/passwords.md +136 -0
  106. package/docs/guide/permissions.md +347 -0
  107. package/docs/guide/sessions.md +211 -0
  108. package/docs/guide/users.md +277 -0
  109. package/docs/guide/vocabulary.md +163 -0
  110. package/docs/roadmap.md +93 -0
  111. package/docs/troubleshooting.md +648 -0
  112. package/package.json +70 -0
@@ -0,0 +1,74 @@
1
+ import type { ConformanceCase, ConformanceHarness, ConformanceRunner } from './types';
2
+ /** Every case, in the order they are described. */
3
+ export declare const allCases: readonly ConformanceCase[];
4
+ /** Why a case did not run. A skip is always reported with its reason, never silent. */
5
+ export declare const SKIP_REASONS: {
6
+ readonly faults: "faults not provided: the outage invariant is not proven for this adapter";
7
+ readonly deleteExpiredSessions: "stores.sessions does not implement the optional deleteExpiredSessions";
8
+ };
9
+ /**
10
+ * Runs one case against one freshly opened set of stores, and closes them,
11
+ * pass or fail. Answers the reason when the case cannot run on these stores.
12
+ *
13
+ * The runner-less layer: a loop over `allCases` calling this is a conformance
14
+ * run with no test framework at all.
15
+ */
16
+ export declare function runCase(conformanceCase: ConformanceCase, harness: ConformanceHarness): Promise<{
17
+ readonly skipped: string;
18
+ } | {
19
+ readonly passed: true;
20
+ }>;
21
+ /**
22
+ * Describes the whole suite under the adapter's test runner.
23
+ *
24
+ * ```ts
25
+ * import { describe, it } from 'bun:test';
26
+ * describeJanusStores({ name: 'my adapter', harness, runner: { describe, it } });
27
+ * ```
28
+ *
29
+ * `runner` may be left out under jest, or vitest with `globals: true`: the
30
+ * suite then reads `describe` and `it` from `globalThis`. **Not under `bun
31
+ * test`**, measured: Bun gives a test file `describe` and `it` as bare
32
+ * identifiers, and not as properties of `globalThis` — so pass them.
33
+ *
34
+ * Whether a case can run depends on the stores its harness opens, which is only
35
+ * known once they are open. So every case is described as a test; one that
36
+ * cannot run passes **and says so in its name**, and a run without `faults`
37
+ * is written above the suite, where it cannot be scrolled past.
38
+ */
39
+ export declare function describeJanusStores(options: {
40
+ readonly name: string;
41
+ readonly harness: ConformanceHarness;
42
+ readonly runner?: ConformanceRunner;
43
+ /** Case ids to skip, each with the reason — reported, never silent. */
44
+ readonly skip?: Readonly<Record<string, string>>;
45
+ /** Declared up front, so the report can say so before the first case runs. */
46
+ readonly faults?: boolean;
47
+ }): void;
48
+ /** What any suite's case declares, as far as describing it goes. */
49
+ interface DescribedCase {
50
+ readonly id: string;
51
+ readonly group: string;
52
+ readonly name: string;
53
+ readonly needs?: string;
54
+ }
55
+ /**
56
+ * Describes one suite's cases, grouped, under a runner. Shared by every suite
57
+ * this module exports, so a skip, an unproven outage and a missing runner read
58
+ * the same in each.
59
+ */
60
+ export declare function describeSuite<C extends DescribedCase>(options: {
61
+ readonly title: string;
62
+ readonly cases: readonly C[];
63
+ readonly run: (conformanceCase: C) => Promise<{
64
+ readonly skipped: string;
65
+ } | {
66
+ readonly passed: true;
67
+ }>;
68
+ readonly runner: ConformanceRunner;
69
+ readonly skip: Readonly<Record<string, string>>;
70
+ readonly faults: boolean | undefined;
71
+ }): void;
72
+ export declare function fromGlobals(where: string): ConformanceRunner;
73
+ export {};
74
+ //# sourceMappingURL=describe.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"describe.d.ts","sourceRoot":"","sources":["../../src/conformance/describe.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EACX,eAAe,EACf,kBAAkB,EAClB,iBAAiB,EAEjB,MAAM,SAAS,CAAC;AAEjB,mDAAmD;AACnD,eAAO,MAAM,QAAQ,EAAE,SAAS,eAAe,EAK9C,CAAC;AAEF,uFAAuF;AACvF,eAAO,MAAM,YAAY;;;CAKf,CAAC;AAEX;;;;;;GAMG;AACH,wBAAsB,OAAO,CAC5B,eAAe,EAAE,eAAe,EAChC,OAAO,EAAE,kBAAkB,GACzB,OAAO,CAAC;IAAE,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;CAAE,GAAG;IAAE,QAAQ,CAAC,MAAM,EAAE,IAAI,CAAA;CAAE,CAAC,CAsBnE;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE;IAC5C,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,OAAO,EAAE,kBAAkB,CAAC;IACrC,QAAQ,CAAC,MAAM,CAAC,EAAE,iBAAiB,CAAC;IACpC,uEAAuE;IACvE,QAAQ,CAAC,IAAI,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IACjD,8EAA8E;IAC9E,QAAQ,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC;CAC1B,GAAG,IAAI,CASP;AAED,oEAAoE;AACpE,UAAU,aAAa;IACtB,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;CACxB;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,CAAC,SAAS,aAAa,EAAE,OAAO,EAAE;IAC/D,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,KAAK,EAAE,SAAS,CAAC,EAAE,CAAC;IAC7B,QAAQ,CAAC,GAAG,EAAE,CACb,eAAe,EAAE,CAAC,KACd,OAAO,CAAC;QAAE,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;KAAE,GAAG;QAAE,QAAQ,CAAC,MAAM,EAAE,IAAI,CAAA;KAAE,CAAC,CAAC;IACvE,QAAQ,CAAC,MAAM,EAAE,iBAAiB,CAAC;IACnC,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IAChD,QAAQ,CAAC,MAAM,EAAE,OAAO,GAAG,SAAS,CAAC;CACrC,GAAG,IAAI,CA0CP;AAED,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,iBAAiB,CAgB5D"}
@@ -0,0 +1,11 @@
1
+ import type { SessionRecord, TokenRecord, UserRecord } from '../auth/port/types';
2
+ /**
3
+ * Records the cases write. Every id is minted, so no two cases — and no two
4
+ * records of one case — ever collide by accident; every collision a case
5
+ * tests is one it wrote on purpose.
6
+ */
7
+ export declare const at: (iso: string) => Date;
8
+ export declare function userRecord(overrides?: Partial<UserRecord>): UserRecord;
9
+ export declare function sessionRecord(overrides?: Partial<SessionRecord>): SessionRecord;
10
+ export declare function tokenRecord(overrides?: Partial<TokenRecord>): TokenRecord;
11
+ //# sourceMappingURL=fixtures.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fixtures.d.ts","sourceRoot":"","sources":["../../src/conformance/fixtures.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACX,aAAa,EACb,WAAW,EACX,UAAU,EACV,MAAM,oBAAoB,CAAC;AAG5B;;;;GAIG;AAEH,eAAO,MAAM,EAAE,GAAI,KAAK,MAAM,KAAG,IAAqB,CAAC;AAKvD,wBAAgB,UAAU,CAAC,SAAS,GAAE,OAAO,CAAC,UAAU,CAAM,GAAG,UAAU,CAmB1E;AAED,wBAAgB,aAAa,CAC5B,SAAS,GAAE,OAAO,CAAC,aAAa,CAAM,GACpC,aAAa,CAWf;AAED,wBAAgB,WAAW,CAAC,SAAS,GAAE,OAAO,CAAC,WAAW,CAAM,GAAG,WAAW,CAW7E"}
@@ -0,0 +1,33 @@
1
+ /**
2
+ * `@nxgt/janus/conformance` — **what makes the port's contract checkable.**
3
+ *
4
+ * An adapter author runs this against their stores, and it fails an adapter
5
+ * that breaks one of the port's six rules — above all the one this package is
6
+ * built around: *an absence is `null`, a failure throws*. In an HTTP SDK that
7
+ * rule lives in one unwrapping function; in an embedded core it lives in the
8
+ * contract of the port, and this is where the contract is checked. That is why
9
+ * it is a published entry point, and not a page of documentation.
10
+ *
11
+ * Three layers, and the lowest depends on no test runner:
12
+ *
13
+ * - the cases, as data — `userStoreCases`, `sessionStoreCases`,
14
+ * `tokenStoreCases`, `outageCases`, `allCases`;
15
+ * - `runCase`, which runs one against a harness;
16
+ * - `describeJanusStores`, which describes them all under bun:test, vitest
17
+ * or jest.
18
+ *
19
+ * The same three for a relation store, the port `@nxgt/janus/permissions`
20
+ * reads: `relationStoreCases`, `relationOutageCases`, `allRelationCases`;
21
+ * `runRelationCase`; `describeRelationStores`.
22
+ *
23
+ * It imports no test framework and no assertion library.
24
+ */
25
+ export { outageCases } from './cases/outage';
26
+ export { sessionStoreCases } from './cases/sessions';
27
+ export { tokenStoreCases } from './cases/tokens';
28
+ export { userStoreCases } from './cases/users';
29
+ export { allCases, describeJanusStores, runCase, SKIP_REASONS, } from './describe';
30
+ export { referenceHarness } from './reference';
31
+ export { allRelationCases, describeRelationStores, type OpenedRelations, type RelationCase, type RelationContext, type RelationFaults, type RelationHarness, type RelationMethod, referenceRelationHarness, relationOutageCases, relationStoreCases, runRelationCase, } from './relations';
32
+ export type { CaseContext, ConformanceCase, ConformanceHarness, ConformanceRunner, OpenedStores, PortMethod, StoreFaults, } from './types';
33
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/conformance/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACjD,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,EACN,QAAQ,EACR,mBAAmB,EACnB,OAAO,EACP,YAAY,GACZ,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EACN,gBAAgB,EAChB,sBAAsB,EACtB,KAAK,eAAe,EACpB,KAAK,YAAY,EACjB,KAAK,eAAe,EACpB,KAAK,cAAc,EACnB,KAAK,eAAe,EACpB,KAAK,cAAc,EACnB,wBAAwB,EACxB,mBAAmB,EACnB,kBAAkB,EAClB,eAAe,GACf,MAAM,aAAa,CAAC;AACrB,YAAY,EACX,WAAW,EACX,eAAe,EACf,kBAAkB,EAClB,iBAAiB,EACjB,YAAY,EACZ,UAAU,EACV,WAAW,GACX,MAAM,SAAS,CAAC"}