@c9up/ream 0.2.3 → 0.2.5

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 (71) hide show
  1. package/dist/Application.d.ts +85 -5
  2. package/dist/Application.d.ts.map +1 -1
  3. package/dist/Application.js +171 -21
  4. package/dist/Application.js.map +1 -1
  5. package/dist/ErrorBoundary.d.ts +1 -7
  6. package/dist/ErrorBoundary.d.ts.map +1 -1
  7. package/dist/ErrorBoundary.js +31 -31
  8. package/dist/ErrorBoundary.js.map +1 -1
  9. package/dist/Ignitor.d.ts +15 -46
  10. package/dist/Ignitor.d.ts.map +1 -1
  11. package/dist/Ignitor.js +178 -173
  12. package/dist/Ignitor.js.map +1 -1
  13. package/dist/env/Env.d.ts +6 -0
  14. package/dist/env/Env.d.ts.map +1 -1
  15. package/dist/env/Env.js +6 -0
  16. package/dist/env/Env.js.map +1 -1
  17. package/dist/events/Emitter.d.ts +2 -6
  18. package/dist/events/Emitter.d.ts.map +1 -1
  19. package/dist/events/Emitter.js +45 -42
  20. package/dist/events/Emitter.js.map +1 -1
  21. package/dist/events/native.d.ts +13 -11
  22. package/dist/events/native.d.ts.map +1 -1
  23. package/dist/events/native.js.map +1 -1
  24. package/dist/http/HttpContext.d.ts +1 -1
  25. package/dist/http/HttpContext.d.ts.map +1 -1
  26. package/dist/http/Request.js +0 -13
  27. package/dist/http/Request.js.map +1 -1
  28. package/dist/index.d.ts +3 -2
  29. package/dist/index.d.ts.map +1 -1
  30. package/dist/index.js +1 -2
  31. package/dist/index.js.map +1 -1
  32. package/dist/native/generated.d.ts +243 -0
  33. package/dist/native/generated.d.ts.map +1 -0
  34. package/dist/native/generated.js +7 -0
  35. package/dist/native/generated.js.map +1 -0
  36. package/dist/session/drivers/CookieDriver.d.ts +1 -1
  37. package/dist/session/drivers/CookieDriver.d.ts.map +1 -1
  38. package/dist/session/drivers/CookieDriver.js +4 -4
  39. package/dist/session/drivers/CookieDriver.js.map +1 -1
  40. package/dist/types/index.d.ts +88 -5
  41. package/dist/types/index.d.ts.map +1 -1
  42. package/dist/types/index.js +8 -3
  43. package/dist/types/index.js.map +1 -1
  44. package/events.win32-x64-msvc.node +0 -0
  45. package/index.win32-x64-msvc.node +0 -0
  46. package/package.json +3 -2
  47. package/scheduler.win32-x64-msvc.node +0 -0
  48. package/scripts/build-napi-types.mjs +68 -0
  49. package/scripts/generate-napi-types.mjs +171 -0
  50. package/src/Application.ts +221 -21
  51. package/src/ErrorBoundary.ts +31 -31
  52. package/src/Ignitor.ts +185 -172
  53. package/src/env/Env.ts +6 -0
  54. package/src/events/Emitter.ts +45 -42
  55. package/src/events/native.ts +21 -14
  56. package/src/http/HttpContext.ts +1 -1
  57. package/src/http/Request.ts +0 -13
  58. package/src/index.ts +2 -2
  59. package/src/native/generated.ts +291 -0
  60. package/src/session/drivers/CookieDriver.ts +4 -4
  61. package/src/types/index.ts +92 -5
  62. package/dist/types/authenticators.d.ts +0 -24
  63. package/dist/types/authenticators.d.ts.map +0 -1
  64. package/dist/types/authenticators.js +0 -2
  65. package/dist/types/authenticators.js.map +0 -1
  66. package/dist/types/container.d.ts +0 -64
  67. package/dist/types/container.d.ts.map +0 -1
  68. package/dist/types/container.js +0 -23
  69. package/dist/types/container.js.map +0 -1
  70. package/src/types/authenticators.ts +0 -24
  71. package/src/types/container.ts +0 -66
@@ -7,7 +7,7 @@ import type { SessionDriver } from '../Session.js'
7
7
  * Requires a secret for encryption.
8
8
  */
9
9
  export class CookieDriver implements SessionDriver {
10
- private signer: CookieSigner
10
+ #signer: CookieSigner
11
11
 
12
12
  constructor(secret: string) {
13
13
  if (!secret) {
@@ -15,12 +15,12 @@ export class CookieDriver implements SessionDriver {
15
15
  'CookieDriver requires a secret for session encryption. Set session.secret in your config.',
16
16
  )
17
17
  }
18
- this.signer = new CookieSigner(secret)
18
+ this.#signer = new CookieSigner(secret)
19
19
  }
20
20
 
21
21
  async read(sessionId: string): Promise<Record<string, unknown> | null> {
22
22
  if (!sessionId) return null
23
- const decrypted = this.signer.decrypt(sessionId)
23
+ const decrypted = this.#signer.decrypt(sessionId)
24
24
  if (!decrypted) return null
25
25
  try {
26
26
  return JSON.parse(decrypted)
@@ -43,6 +43,6 @@ export class CookieDriver implements SessionDriver {
43
43
 
44
44
  /** Encode session data for cookie storage (encrypted). */
45
45
  encode(data: Record<string, unknown>): string {
46
- return this.signer.encrypt(JSON.stringify(data))
46
+ return this.#signer.encrypt(JSON.stringify(data))
47
47
  }
48
48
  }
@@ -1,10 +1,97 @@
1
1
  /**
2
- * The interfaces an application or a package augments.
2
+ * The interfaces an application or a package augments — `@c9up/ream/types`.
3
3
  *
4
4
  * Resolving from the container and picking an auth guard are both string
5
- * lookups; without a shared interface to augment, every call site casts. This
6
- * is the module those interfaces live in — `@c9up/ream/types`.
5
+ * lookups; without a shared interface to augment, every call site casts.
6
+ *
7
+ * The augmentable interfaces are DECLARED here rather than re-exported from a
8
+ * neighbouring file, and that is load-bearing: TypeScript augments the module
9
+ * that declares an interface, so a re-export makes
10
+ * `declare module '@c9up/ream/types' { interface Authenticators { … } }` a
11
+ * duplicate declaration instead of an augmentation. warden hit exactly that.
12
+ */
13
+
14
+ import type { Application } from '../Application.js'
15
+ import type { ConfigStore } from '../ConfigLoader.js'
16
+ import type { Console } from '../console/Console.js'
17
+ import type { Kernel } from '../console/Kernel.js'
18
+ import type { Emitter } from '../events/Emitter.js'
19
+ import type { HttpContext } from '../http/HttpContext.js'
20
+ import type { MiddlewareRegistry } from '../middleware/Pipeline.js'
21
+ import type { MigrationRegistry } from '../migrations/MigrationRegistry.js'
22
+ import type { Router } from '../router/Router.js'
23
+ import type { CookieSigner } from '../security/CookieSigner.js'
24
+ import type { SignedUrl } from '../security/SignedUrl.js'
25
+ import type { Server } from '../server/Server.js'
26
+
27
+ /**
28
+ * Guard name → what `auth.use(name)` hands back.
29
+ *
30
+ * Empty here, and deliberately: ream owns no auth package, so it cannot know
31
+ * the guards an app configured. The auth package fills it in:
32
+ *
33
+ * ```ts
34
+ * declare module '@c9up/ream/types' {
35
+ * interface Authenticators {
36
+ * session: SessionGuard
37
+ * }
38
+ * }
39
+ * ```
40
+ *
41
+ * Until something augments it, `keyof Authenticators` is `never` and `use()`
42
+ * falls through to its `unknown` signature — the previous behaviour kept as
43
+ * the floor rather than the ceiling.
44
+ */
45
+ /**
46
+ * An EMPTY INTERFACE is the whole mechanism here, not an oversight. Rewritten
47
+ * as `type Authenticators = {}` the declaration stops being augmentable:
48
+ * `declare module '@c9up/ream/types' { interface Authenticators { … } }`
49
+ * becomes a duplicate identifier instead of a merge, and warden cannot type
50
+ * `ctx.auth.use()`. That is exactly what shipped in 0.2.3, where the formatter
51
+ * had rewritten it.
52
+ */
53
+ // biome-ignore lint/suspicious/noEmptyInterface: it must stay an interface to be augmentable — see above
54
+ export interface Authenticators {}
55
+
56
+ /** A guard name this application knows about. */
57
+ export type AuthenticatorName = keyof Authenticators
58
+
59
+ /**
60
+ * The container's known bindings.
61
+ *
62
+ * Ream core registers the entries below; anything else — `auth` (warden),
63
+ * `logger` (spectrum), `db` (atlas) — reaches this interface by augmentation
64
+ * from the package that owns it, which is why it is open rather than a closed
65
+ * union.
7
66
  */
67
+ export interface ContainerBindings {
68
+ /** The application instance. */
69
+ app: Application
70
+ /** Absolute path to the application root. */
71
+ appRoot: string
72
+ /** The config store built from `config/*.ts`. */
73
+ config: ConfigStore
74
+ /** The console application (AdonisJS calls its equivalent `ace`). */
75
+ console: Console
76
+ /** The console kernel that dispatches commands. */
77
+ consoleKernel: Kernel
78
+ /** The event emitter. */
79
+ emitter: Emitter
80
+ /** Cookie/value signing and encryption, backed by `APP_KEY`. */
81
+ encryption: CookieSigner
82
+ /** The `HttpContext` class itself — for `HttpContext.getOrFail()` style access. */
83
+ HttpContext: typeof HttpContext
84
+ /** Named middleware registered by the app kernel. */
85
+ middleware: MiddlewareRegistry
86
+ /** Migration sources contributed by data packages (atlas, eon, ...). */
87
+ migrations: MigrationRegistry
88
+ /** The HTTP router. */
89
+ router: Router
90
+ /** The HTTP server. */
91
+ server: Server
92
+ /** Signed-URL generation and verification. */
93
+ signedUrl: SignedUrl
94
+ }
8
95
 
9
- export type { AuthenticatorName, Authenticators } from './authenticators.js'
10
- export type { ContainerBinding, ContainerBindings } from './container.js'
96
+ /** A token this container knows how to resolve. */
97
+ export type ContainerBinding = keyof ContainerBindings
@@ -1,24 +0,0 @@
1
- /**
2
- * Guard name → what `auth.use(name)` hands back.
3
- *
4
- * Empty here, and deliberately: ream owns no auth package, so it cannot know
5
- * the guards an app configured. The auth package fills it in, exactly as
6
- * AdonisJS does with `Authenticators`:
7
- *
8
- * ```ts
9
- * declare module '@c9up/ream/types' {
10
- * interface Authenticators {
11
- * session: SessionGuard
12
- * jwt: JwtGuard
13
- * }
14
- * }
15
- * ```
16
- *
17
- * Until something augments it, `keyof Authenticators` is `never` and `use()`
18
- * falls through to its `unknown` signature — the behaviour ream had before,
19
- * kept as the floor rather than as the ceiling.
20
- */
21
- export type Authenticators = {};
22
- /** A guard name this application knows about. */
23
- export type AuthenticatorName = keyof Authenticators;
24
- //# sourceMappingURL=authenticators.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"authenticators.d.ts","sourceRoot":"","sources":["../../src/types/authenticators.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,MAAM,cAAc,GAAG,EAAE,CAAA;AAE/B,iDAAiD;AACjD,MAAM,MAAM,iBAAiB,GAAG,MAAM,cAAc,CAAA"}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=authenticators.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"authenticators.js","sourceRoot":"","sources":["../../src/types/authenticators.ts"],"names":[],"mappings":""}
@@ -1,64 +0,0 @@
1
- /**
2
- * The container's known bindings, as a type.
3
- *
4
- * Resolving from the container is a string lookup, so without a shared
5
- * interface every `container.make('router')` returns `unknown` and every app
6
- * casts. AdonisJS solves it with an augmentable `ContainerBindings`, and every
7
- * package in its ecosystem adds its own token to it:
8
- *
9
- * ```ts
10
- * declare module '@c9up/ream/types' {
11
- * interface ContainerBindings {
12
- * auth: AuthManager
13
- * }
14
- * }
15
- * ```
16
- *
17
- * Ream core registers the entries below; anything else — `auth` (warden),
18
- * `logger` (spectrum), `db` (atlas) — reaches this interface by augmentation
19
- * from the package that owns it, which is why the interface is open rather
20
- * than a closed union.
21
- */
22
- import type { Application } from '../Application.js';
23
- import type { ConfigStore } from '../ConfigLoader.js';
24
- import type { Console } from '../console/Console.js';
25
- import type { Kernel } from '../console/Kernel.js';
26
- import type { Emitter } from '../events/Emitter.js';
27
- import type { HttpContext } from '../http/HttpContext.js';
28
- import type { MiddlewareRegistry } from '../middleware/Pipeline.js';
29
- import type { MigrationRegistry } from '../migrations/MigrationRegistry.js';
30
- import type { Router } from '../router/Router.js';
31
- import type { CookieSigner } from '../security/CookieSigner.js';
32
- import type { SignedUrl } from '../security/SignedUrl.js';
33
- import type { Server } from '../server/Server.js';
34
- export interface ContainerBindings {
35
- /** The application instance. */
36
- app: Application;
37
- /** Absolute path to the application root. */
38
- appRoot: string;
39
- /** The config store built from `config/*.ts`. */
40
- config: ConfigStore;
41
- /** The console application (AdonisJS calls its equivalent `ace`). */
42
- console: Console;
43
- /** The console kernel that dispatches commands. */
44
- consoleKernel: Kernel;
45
- /** The event emitter. */
46
- emitter: Emitter;
47
- /** Cookie/value signing and encryption, backed by `APP_KEY`. */
48
- encryption: CookieSigner;
49
- /** The `HttpContext` class itself — for `HttpContext.getOrFail()` style access. */
50
- HttpContext: typeof HttpContext;
51
- /** Named middleware registered by the app kernel. */
52
- middleware: MiddlewareRegistry;
53
- /** Migration sources contributed by data packages (atlas, eon, ...). */
54
- migrations: MigrationRegistry;
55
- /** The HTTP router. */
56
- router: Router;
57
- /** The HTTP server. */
58
- server: Server;
59
- /** Signed-URL generation and verification. */
60
- signedUrl: SignedUrl;
61
- }
62
- /** A token this container knows how to resolve. */
63
- export type ContainerBinding = keyof ContainerBindings;
64
- //# sourceMappingURL=container.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"container.d.ts","sourceRoot":"","sources":["../../src/types/container.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AACpD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAA;AACrD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAA;AACpD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAA;AAClD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAA;AACnD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAA;AACzD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAA;AACnE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,oCAAoC,CAAA;AAC3E,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAA;AACjD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAA;AAC/D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAA;AACzD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAA;AAEjD,MAAM,WAAW,iBAAiB;IAChC,gCAAgC;IAChC,GAAG,EAAE,WAAW,CAAA;IAChB,6CAA6C;IAC7C,OAAO,EAAE,MAAM,CAAA;IACf,iDAAiD;IACjD,MAAM,EAAE,WAAW,CAAA;IACnB,qEAAqE;IACrE,OAAO,EAAE,OAAO,CAAA;IAChB,mDAAmD;IACnD,aAAa,EAAE,MAAM,CAAA;IACrB,yBAAyB;IACzB,OAAO,EAAE,OAAO,CAAA;IAChB,gEAAgE;IAChE,UAAU,EAAE,YAAY,CAAA;IACxB,mFAAmF;IACnF,WAAW,EAAE,OAAO,WAAW,CAAA;IAC/B,qDAAqD;IACrD,UAAU,EAAE,kBAAkB,CAAA;IAC9B,wEAAwE;IACxE,UAAU,EAAE,iBAAiB,CAAA;IAC7B,uBAAuB;IACvB,MAAM,EAAE,MAAM,CAAA;IACd,uBAAuB;IACvB,MAAM,EAAE,MAAM,CAAA;IACd,8CAA8C;IAC9C,SAAS,EAAE,SAAS,CAAA;CACrB;AAED,mDAAmD;AACnD,MAAM,MAAM,gBAAgB,GAAG,MAAM,iBAAiB,CAAA"}
@@ -1,23 +0,0 @@
1
- /**
2
- * The container's known bindings, as a type.
3
- *
4
- * Resolving from the container is a string lookup, so without a shared
5
- * interface every `container.make('router')` returns `unknown` and every app
6
- * casts. AdonisJS solves it with an augmentable `ContainerBindings`, and every
7
- * package in its ecosystem adds its own token to it:
8
- *
9
- * ```ts
10
- * declare module '@c9up/ream/types' {
11
- * interface ContainerBindings {
12
- * auth: AuthManager
13
- * }
14
- * }
15
- * ```
16
- *
17
- * Ream core registers the entries below; anything else — `auth` (warden),
18
- * `logger` (spectrum), `db` (atlas) — reaches this interface by augmentation
19
- * from the package that owns it, which is why the interface is open rather
20
- * than a closed union.
21
- */
22
- export {};
23
- //# sourceMappingURL=container.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"container.js","sourceRoot":"","sources":["../../src/types/container.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG"}
@@ -1,24 +0,0 @@
1
- /**
2
- * Guard name → what `auth.use(name)` hands back.
3
- *
4
- * Empty here, and deliberately: ream owns no auth package, so it cannot know
5
- * the guards an app configured. The auth package fills it in, exactly as
6
- * AdonisJS does with `Authenticators`:
7
- *
8
- * ```ts
9
- * declare module '@c9up/ream/types' {
10
- * interface Authenticators {
11
- * session: SessionGuard
12
- * jwt: JwtGuard
13
- * }
14
- * }
15
- * ```
16
- *
17
- * Until something augments it, `keyof Authenticators` is `never` and `use()`
18
- * falls through to its `unknown` signature — the behaviour ream had before,
19
- * kept as the floor rather than as the ceiling.
20
- */
21
- export type Authenticators = {}
22
-
23
- /** A guard name this application knows about. */
24
- export type AuthenticatorName = keyof Authenticators
@@ -1,66 +0,0 @@
1
- /**
2
- * The container's known bindings, as a type.
3
- *
4
- * Resolving from the container is a string lookup, so without a shared
5
- * interface every `container.make('router')` returns `unknown` and every app
6
- * casts. AdonisJS solves it with an augmentable `ContainerBindings`, and every
7
- * package in its ecosystem adds its own token to it:
8
- *
9
- * ```ts
10
- * declare module '@c9up/ream/types' {
11
- * interface ContainerBindings {
12
- * auth: AuthManager
13
- * }
14
- * }
15
- * ```
16
- *
17
- * Ream core registers the entries below; anything else — `auth` (warden),
18
- * `logger` (spectrum), `db` (atlas) — reaches this interface by augmentation
19
- * from the package that owns it, which is why the interface is open rather
20
- * than a closed union.
21
- */
22
-
23
- import type { Application } from '../Application.js'
24
- import type { ConfigStore } from '../ConfigLoader.js'
25
- import type { Console } from '../console/Console.js'
26
- import type { Kernel } from '../console/Kernel.js'
27
- import type { Emitter } from '../events/Emitter.js'
28
- import type { HttpContext } from '../http/HttpContext.js'
29
- import type { MiddlewareRegistry } from '../middleware/Pipeline.js'
30
- import type { MigrationRegistry } from '../migrations/MigrationRegistry.js'
31
- import type { Router } from '../router/Router.js'
32
- import type { CookieSigner } from '../security/CookieSigner.js'
33
- import type { SignedUrl } from '../security/SignedUrl.js'
34
- import type { Server } from '../server/Server.js'
35
-
36
- export interface ContainerBindings {
37
- /** The application instance. */
38
- app: Application
39
- /** Absolute path to the application root. */
40
- appRoot: string
41
- /** The config store built from `config/*.ts`. */
42
- config: ConfigStore
43
- /** The console application (AdonisJS calls its equivalent `ace`). */
44
- console: Console
45
- /** The console kernel that dispatches commands. */
46
- consoleKernel: Kernel
47
- /** The event emitter. */
48
- emitter: Emitter
49
- /** Cookie/value signing and encryption, backed by `APP_KEY`. */
50
- encryption: CookieSigner
51
- /** The `HttpContext` class itself — for `HttpContext.getOrFail()` style access. */
52
- HttpContext: typeof HttpContext
53
- /** Named middleware registered by the app kernel. */
54
- middleware: MiddlewareRegistry
55
- /** Migration sources contributed by data packages (atlas, eon, ...). */
56
- migrations: MigrationRegistry
57
- /** The HTTP router. */
58
- router: Router
59
- /** The HTTP server. */
60
- server: Server
61
- /** Signed-URL generation and verification. */
62
- signedUrl: SignedUrl
63
- }
64
-
65
- /** A token this container knows how to resolve. */
66
- export type ContainerBinding = keyof ContainerBindings