@getstrata/core 3.0.5 → 3.0.7

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 (83) hide show
  1. package/CHANGELOG.md +18 -9
  2. package/README.md +17 -9
  3. package/dist/core/auth/policy.d.ts +4 -1
  4. package/dist/core/auth/saml/samlServiceProvider.d.ts +2 -3
  5. package/dist/core/cache/store.d.ts +2 -2
  6. package/dist/core/cache/tokens.d.ts +1 -1
  7. package/dist/core/config/envSchema.d.ts +13 -0
  8. package/dist/core/contracts/application.d.ts +4 -0
  9. package/dist/core/contracts/di.d.ts +2 -2
  10. package/dist/core/contracts/provider.d.ts +13 -0
  11. package/dist/core/contracts/serviceTokens.d.ts +12 -11
  12. package/dist/core/database/factory.d.ts +3 -0
  13. package/dist/core/database/index.d.ts +1 -1
  14. package/dist/core/database/migrations/declaration.d.ts +11 -0
  15. package/dist/core/database/migrations/runner.d.ts +2 -0
  16. package/dist/core/database/model.d.ts +16 -3
  17. package/dist/core/database/modelQuery.d.ts +1 -10
  18. package/dist/core/database/modelRelationLoader.d.ts +31 -0
  19. package/dist/core/database/mysqlConnection.d.ts +2 -2
  20. package/dist/core/database/mysqlNative.d.ts +2 -0
  21. package/dist/core/database/ormRuntime.d.ts +1 -1
  22. package/dist/core/database/rawMysql.d.ts +1 -1
  23. package/dist/core/events/eventBusClass.d.ts +6 -3
  24. package/dist/core/events/index.d.ts +1 -1
  25. package/dist/core/http/formRequest.d.ts +2 -0
  26. package/dist/core/http/loginThrottleMiddleware.d.ts +1 -2
  27. package/dist/core/http/memoryThrottleMiddleware.d.ts +1 -3
  28. package/dist/core/http/webFormRequest.d.ts +3 -5
  29. package/dist/core/mail/mailer.d.ts +6 -3
  30. package/dist/core/mail/markdownMailable.d.ts +2 -2
  31. package/dist/core/notifications/dispatcher.d.ts +5 -5
  32. package/dist/core/notifications/index.d.ts +1 -1
  33. package/dist/core/notifications/types.d.ts +9 -2
  34. package/dist/core/queue/index.d.ts +8 -3
  35. package/dist/core/queue/queueHandoff.d.ts +2 -2
  36. package/dist/core/runtime/application.d.ts +2 -0
  37. package/dist/core/security/oauthState.d.ts +12 -2
  38. package/dist/core/security/safeUrl.d.ts +1 -11
  39. package/dist/core/storage/storage.d.ts +23 -6
  40. package/dist/core/testing.d.ts +5 -0
  41. package/dist/core/testingState.d.ts +22 -0
  42. package/dist/entries/audit/exportAuditLogs.js +1 -0
  43. package/dist/entries/auth/intendedUrlCookie.js +68 -2
  44. package/dist/entries/auth/jwt.js +68 -6
  45. package/dist/entries/auth/jwtGuard.js +76 -12
  46. package/dist/entries/auth/oauth/samlProvider.js +4 -5
  47. package/dist/entries/auth/passwordConfirmCookie.js +69 -3
  48. package/dist/entries/auth/saml/samlServiceProvider.js +5 -7
  49. package/dist/entries/auth/sessionCookie.js +69 -6
  50. package/dist/entries/auth/sessionGuard.js +69 -6
  51. package/dist/entries/cache/repository.js +4 -5
  52. package/dist/entries/config/envSchema.js +13 -0
  53. package/dist/entries/contracts/serviceTokens.js +2 -0
  54. package/dist/entries/database/bindings.js +18 -90
  55. package/dist/entries/database/factory.js +4 -0
  56. package/dist/entries/database/migrations.js +714 -1
  57. package/dist/entries/http/formRequest.js +12 -6
  58. package/dist/entries/http/memoryThrottleMiddleware.js +7 -9
  59. package/dist/entries/http/pagination.js +4 -4
  60. package/dist/entries/http/parseMultipartUpload.js +62 -9
  61. package/dist/entries/http/routeModelBinding.js +4 -4
  62. package/dist/entries/http/securedRouteModelBinding.js +4 -4
  63. package/dist/entries/http/uploads.js +62 -9
  64. package/dist/entries/http/validation.js +4 -4
  65. package/dist/entries/http/webFormRequest.js +74 -95
  66. package/dist/entries/jobs/exportAuditLogsJob.js +9 -4
  67. package/dist/entries/jobs/invalidateCacheTagsJob.js +9 -4
  68. package/dist/entries/queue/createAppQueue.js +10 -5
  69. package/dist/entries/queue/publicQueue.js +10 -5
  70. package/dist/entries/queue/queueWorkerTransport.js +10 -5
  71. package/dist/entries/queue.js +9 -4
  72. package/dist/entries/runtime/application.js +50 -3
  73. package/dist/entries/security/oauthState.js +61 -2
  74. package/dist/entries/security/tokenExpiry.js +62 -9
  75. package/dist/entries/storage/storage.js +102 -1
  76. package/dist/entries/testing.js +18 -0
  77. package/dist/framework/public-api.d.ts +16 -13
  78. package/dist/index.js +316 -222
  79. package/dist/internal/mysqlNative.js +97 -0
  80. package/dist/internal/ormRuntime.js +41 -4
  81. package/dist/internal/testingState.js +31 -0
  82. package/dist/types/services.d.ts +4 -1
  83. package/package.json +17 -4
package/CHANGELOG.md CHANGED
@@ -1,5 +1,22 @@
1
1
  # @getstrata/core changelog
2
2
 
3
+ ## 3.0.7
4
+
5
+ Carry forward the 3.0.6 application-authoring and correctness changes after its release stopped before publication. Correct SAML release acceptance to require browser-bound state while preserving assertion validation, successful login and MFA. See docs/releases/3.0.7.md for upgrade notes.
6
+
7
+ ## 3.0.6
8
+
9
+ - Add concise `createModel` declarations and declarative `defineProvider` bindings with phased setup/boot, preserving explicit persistence ownership, observers and scopes.
10
+ - Add `defineMigration` authoring, Bun-backed local/S3 streaming storage, structural mail/storage ports and application-owned notification channels.
11
+ - Share form-request validation, parse bodies by Content-Type, require explicit authorization and reject malformed integer query parameters. Require atomic tagged-cache loading; preserve notification HTML and validate database notification IDs.
12
+ - Preserve exact oversized MySQL integers without changing safe numeric IDs. Keep `mysql2` as the qualified optional MySQL adapter; it remains lazily loaded.
13
+ - Prevent closed MySQL connections from reopening, drain admitted transactions through both SQL entrypoints, and seal raw MySQL/PostgreSQL pool admission while native cleanup is pending. Concurrent close shares one cleanup result.
14
+ - Drain synchronous and asynchronous production queue jobs, including jobs that initiate shutdown, while preserving dispatch failures. Fix immediate outbox worker start/stop admission races.
15
+ - Bind password-confirmation signatures to their purpose. Require matching browser state for OAuth callbacks and add dedicated secure SAML state-cookie helpers; OIDC retains its PKCE binding.
16
+ - Keep valid short JWT lifetimes, reject malformed numeric settings and name the correct session TTL setting in validation errors. Narrow consumer capabilities and move test controls to `@getstrata/core/testing`.
17
+
18
+ **Upgrade:** This release includes consumer API changes. Custom cache stores must implement `getOrSetTagged`; missing/unknown notification channels now fail explicitly, and the built-in database channel requires positive safe-integer user IDs. Move removed test-control imports to the dedicated testing entrypoint. Existing password-confirmation cookies require one fresh confirmation; normal sessions remain valid. Custom callers of `verifyOAuthState` must issue the matching browser-state cookie. SAML browser flows require HTTPS. See [the release notes](../../docs/releases/3.0.6.md) and [migration decisions](../../docs/architecture/solid-laravel-bun-followup.md).
19
+
3
20
  ## 3.0.5
4
21
 
5
22
  - Fixed SQLite queries returning no rows when SQL begins with comments, including VALUES, PRAGMA, EXPLAIN, and compact RETURNING statements.
@@ -9,15 +26,7 @@
9
26
  - Fixed malformed intended-URL and flash cookies throwing errors.
10
27
  - Fixed CI package dry-runs failing when the package version was already published.
11
28
 
12
- **Migration:** Replace Redis TTL 0 used for permanent storage with forever(). For a permanent configured default, use . TTL units remain milliseconds.
13
-
14
- ## Unreleased
15
-
16
- Align array and Redis expiration semantics: positive safe-integer millisecond TTLs expire; zero/negative TTLs remove entries and fence pending fills; omitted TTLs use the configured default. Add `put` and `forever` to repositories, tagged caches and execution-scoped caches. Explicit low-level `null` means forever. Redis callers using TTL zero for persistence must switch to `forever` (or a null configured default). Invalid numeric TTLs reject before effects.
17
-
18
- Reject control characters that can turn internal redirects into external destinations and preserve repeated query parameters. Prevent malformed intended-URL and flash cookies from throwing by using the shared cookie reader, including Bun's native cookie-map path. Fence old memory-cache fills after explicit writes, enforce capacity for empty keys, and reject invalid per-call TTLs before mutation or loader execution.
19
-
20
- Fix SQLite row detection using native prepared-statement column metadata. Leading comments no longer discard SELECT, CTE, PRAGMA or EXPLAIN results; VALUES and compact RETURNING forms also return their rows. Non-returning mutations still execute once and return an empty result.
29
+ **Migration:** Replace Redis TTL 0 used for permanent storage with forever(). For a permanent configured default, use `null`. TTL units remain milliseconds.
21
30
 
22
31
  ## 3.0.4
23
32
 
package/README.md CHANGED
@@ -14,7 +14,8 @@ Apps, and anything they import, should use subpaths:
14
14
 
15
15
  ```typescript
16
16
  import { createAuthMiddleware } from "@getstrata/core/http/authMiddleware";
17
- import { bindDatabaseConnection } from "@getstrata/core/database/bindConnection";
17
+ import { createModel } from "@getstrata/core/database/model";
18
+ import { defineTable } from "@getstrata/core/database/table";
18
19
  import { BaseRepository } from "@getstrata/core/database/baseRepository";
19
20
  import { FormRequest } from "@getstrata/core/http/formRequest";
20
21
  import { Policy } from "@getstrata/core/auth/policy";
@@ -23,17 +24,20 @@ import { ValidationError } from "@getstrata/core/errors/http";
23
24
  import type { Migration } from "@getstrata/core/database/migrations/types";
24
25
  ```
25
26
 
26
- The root `@getstrata/core` import resolves, but nothing stops you from ending up with two copies of process-wide state: the database pool, the dialect override, async-local auth and tenant context, and the `HttpError` base class used with `instanceof`. Some subpaths re-export the main bundle for exactly that reason. Prefer subpaths everywhere and the problem does not arise.
27
+ Prefer focused subpaths for application imports and keep test seams on
28
+ `@getstrata/core/testing`.
27
29
 
28
30
  ## Database
29
31
 
30
- Set `DATABASE_URL` before the first query; the connection is created lazily.
32
+ The application owns its connection and execution sessions. Configure its selected
33
+ engine at startup, then use `database.model(definition)` or
34
+ `database.repository(definition)` from the current execution. Transactions select
35
+ models and repositories from their supplied transaction session. Global default
36
+ pools, named-connection registries and `bindBunSql` are retired.
31
37
 
32
- ```typescript
33
- process.env.DATABASE_URL ??= "postgresql://postgres:postgres@localhost:5432/myapp";
34
- ```
35
-
36
- The engine is your choice, and an app should have one primary engine. Postgres apps use Bun's built-in `Bun.sql` through `createBunSqlPool()`, then `registerDefaultDatabasePool()` and `bindDatabaseConnection()`; `bindBunSql()` registers both. SQLite and MySQL register through `database/sqliteConnection` and `database/mysqlConnection`, or `registerNamedConnection` from `database/namedConnections`.
38
+ Use `createModel` and `defineTable` for ordinary models. Custom repository,
39
+ connection and adapter APIs remain available for advanced integrations; see the
40
+ [database guide](https://github.com/EyK-26/strata/blob/main/docs/DATABASE.md).
37
41
 
38
42
  `orderBy` takes `{ column, direction }` objects or column shorthand such as `{ published_at: "desc" }`. `{ ilike }` uses the value as-is, so pass `%term%` yourself.
39
43
 
@@ -49,7 +53,7 @@ Full-text `tsMatch` is PostgreSQL only.
49
53
 
50
54
  - `AdminResourceRegistry`, `formatAdminValue`: read-only resource browsers
51
55
  - `createFailedJobService`, `FailedJobService.delete()`: failed job persistence and cleanup
52
- - `runQueueJob`, `jobRegistry`: dispatch retried jobs from admin UIs
56
+ - `runQueueJob` with an application-owned job registry: dispatch retried jobs from admin UIs
53
57
 
54
58
  Generated apps do not include an admin dashboard, and the registry is optional.
55
59
 
@@ -62,3 +66,7 @@ Generated apps do not include an admin dashboard, and the registry is optional.
62
66
  - [Production](https://github.com/EyK-26/strata/blob/main/docs/PRODUCTION.md)
63
67
 
64
68
  Contributing to the framework itself: [CONTRIBUTING.md](https://github.com/EyK-26/strata/blob/main/CONTRIBUTING.md).
69
+
70
+ Test fixtures import loader, DNS and throttle controls from `@getstrata/core/testing`.
71
+ These controls share the package's private runtime state and are absent from the root
72
+ and every production subpath. Restore changed controls after each test.
@@ -24,5 +24,8 @@ declare class PolicyGate<Policies extends {
24
24
  allows<Resource extends keyof Policies & string, Action extends PolicyAction<Policies[Resource]>>(resource: Resource, action: Action, user: PolicyArguments<Policies[Resource][Action]>[0], ...model: PolicyArguments<Policies[Resource][Action]> extends [unknown?, ...infer Rest] ? Rest : never): Promise<boolean>;
25
25
  authorize<Resource extends keyof Policies & string, Action extends PolicyAction<Policies[Resource]>>(resource: Resource, action: Action, user: PolicyArguments<Policies[Resource][Action]>[0], ...model: PolicyArguments<Policies[Resource][Action]> extends [unknown?, ...infer Rest] ? Rest : never): Promise<void>;
26
26
  }
27
- export type { PolicyAction, PolicyDecision };
27
+ /** Consumer decisions and composition registration are separate capabilities. */
28
+ type PolicyAuthorizer = Pick<PolicyGate, "allows" | "authorize">;
29
+ type PolicyRegistry = Pick<PolicyGate, "register">;
30
+ export type { PolicyAction, PolicyAuthorizer, PolicyDecision, PolicyRegistry };
28
31
  export { Policy, PolicyDeniedError, PolicyGate };
@@ -53,10 +53,9 @@ type NodeSamlClient = {
53
53
  }>;
54
54
  };
55
55
  declare function readSamlEnvOptions(env?: Readonly<Record<string, string | undefined>>): SamlServiceProviderConfig;
56
- type NodeSamlModule = {
56
+ export type NodeSamlModule = {
57
57
  SAML: new (options: Record<string, unknown>) => NodeSamlClient;
58
58
  };
59
- declare function setNodeSamlLoaderForTests(loader: (() => Promise<NodeSamlModule>) | null): void;
60
59
  declare class SamlServiceProvider {
61
60
  private client;
62
61
  private readonly options;
@@ -68,4 +67,4 @@ declare class SamlServiceProvider {
68
67
  }
69
68
  declare function createSamlServiceProvider(options: SamlServiceProviderOptions): SamlServiceProvider;
70
69
  export type { SamlAssertionReplayStore, SamlServiceProviderConfig, SamlServiceProviderOptions };
71
- export { createSamlServiceProvider, createSqlSamlAssertionReplayStore, InMemorySamlAssertionReplayStore, REPLAY_RETENTION_MS, readSamlEnvOptions, SamlServiceProvider, setNodeSamlLoaderForTests, };
70
+ export { createSamlServiceProvider, createSqlSamlAssertionReplayStore, InMemorySamlAssertionReplayStore, REPLAY_RETENTION_MS, readSamlEnvOptions, SamlServiceProvider, };
@@ -4,8 +4,8 @@ interface CacheStore {
4
4
  /** null is forever; nonpositive TTLs remove the key and fence pending fills. */
5
5
  set<T>(key: string, value: T, ttlMs?: number | null, tags?: string[]): Promise<void>;
6
6
  getOrSet<T>(key: string, loader: (signal?: AbortSignal) => Promise<T>, ttlMs?: number | null): Promise<T>;
7
- /** Shared stores can bind tags before starting a fill. */
8
- getOrSetTagged?<T>(key: string, loader: (signal?: AbortSignal) => Promise<T>, tags: string[], ttlMs?: number | null): Promise<T>;
7
+ /** Bind tags before loading; publication and invalidation must share ownership. */
8
+ getOrSetTagged<T>(key: string, loader: (signal?: AbortSignal) => Promise<T>, tags: string[], ttlMs?: number | null): Promise<T>;
9
9
  attachTags(key: string, tags: string[]): Promise<void>;
10
10
  flushTags(tags: string[]): Promise<number>;
11
11
  invalidate(key: string): Promise<boolean>;
@@ -4,5 +4,5 @@ import type { CacheRepository } from "./repository";
4
4
  declare const CORE_CACHE_TOKEN: import("@getstrata/core/contracts/token").ServiceToken<CacheLike>;
5
5
  /** Internal application backend; execution consumers depend on CORE_CACHE_TOKEN. */
6
6
  declare const CORE_CACHE_BACKEND_TOKEN: import("@getstrata/core/contracts/token").ServiceToken<CacheRepository>;
7
- export type { CacheLike };
7
+ export type { CacheLike, CacheReader, CacheWriter } from "../../types/services";
8
8
  export { CORE_CACHE_BACKEND_TOKEN, CORE_CACHE_TOKEN };
@@ -11,3 +11,16 @@ declare function defineEnvSchema<const Schema extends EnvSchema>(schema: Schema)
11
11
  declare function validateEnv(schema: EnvSchema, env?: Readonly<Record<string, string | undefined>>): Record<string, string>;
12
12
  export type { EnvRule, EnvSchema };
13
13
  export { defineEnvSchema, validateEnv };
14
+ type BlankDefault<Value extends string> = Value extends `${" " | "\t" | "\r" | "\n"}${infer Rest}` ? BlankDefault<Rest> : Value extends "" ? true : false;
15
+ type ResolvedRule<Rule extends EnvRule> = Rule extends {
16
+ integer: true;
17
+ } ? number : string;
18
+ export type ResolvedEnv<Schema extends EnvSchema> = Readonly<{
19
+ [Name in keyof Schema]: Schema[Name] extends {
20
+ required: true;
21
+ } ? ResolvedRule<Schema[Name]> : Schema[Name] extends {
22
+ default: infer Default extends string;
23
+ } ? BlankDefault<Default> extends true ? ResolvedRule<Schema[Name]> | undefined : ResolvedRule<Schema[Name]> : ResolvedRule<Schema[Name]> | undefined;
24
+ }>;
25
+ /** Validate once and freeze a typed snapshot; blanks keep validateEnv's default semantics. */
26
+ export declare function resolveEnv<const Schema extends EnvSchema>(schema: Schema, env?: Readonly<Record<string, string | undefined>>): ResolvedEnv<Schema>;
@@ -75,8 +75,12 @@ interface ProviderScope {
75
75
  }
76
76
  interface ProviderDefinition {
77
77
  readonly name: string;
78
+ /** Declarative bindings compiled into the application graph before any setup runs. */
79
+ readonly services?: readonly ServiceDeclaration[];
78
80
  readonly requires?: readonly string[];
79
81
  readonly setup: (scope: ProviderScope) => void | Promise<void>;
82
+ /** Runs after every provider setup, before transports start. */
83
+ readonly boot?: (scope: ProviderScope) => void | Promise<void>;
80
84
  }
81
85
  /** Uses the same owner as providers and starts after all providers have finished setup. */
82
86
  type TransportDefinition = ProviderDefinition;
@@ -1,5 +1,5 @@
1
1
  import type { CacheLike } from "../../types/services";
2
- import type { StorageManager } from "../storage/storage";
2
+ import type { Storage } from "../storage/storage";
3
3
  import type { ConfigStore, ConfigStoreLike, ServiceContainer, ServiceFactory, ServiceToken } from "./container";
4
4
  import type { PersistenceInvocation } from "./persistence";
5
5
  type AppRouteMap = Record<string, any>;
@@ -8,7 +8,7 @@ interface AppDependencies {
8
8
  readonly invoke: PersistenceInvocation;
9
9
  container: ServiceContainer;
10
10
  cache: CacheLike;
11
- storage: StorageManager;
11
+ storage: Storage;
12
12
  }
13
13
  type MutableAppDependencies = Partial<Omit<AppDependencies, "container">> & Pick<AppDependencies, "container">;
14
14
  interface ProviderContext {
@@ -0,0 +1,13 @@
1
+ import type { ProviderDefinition, ProviderScope } from "./application";
2
+ import type { ServiceDeclaration } from "./services";
3
+ interface ApplicationProviderOptions {
4
+ readonly name: string;
5
+ readonly requires?: readonly string[];
6
+ readonly services?: readonly ServiceDeclaration[];
7
+ readonly setup?: (scope: ProviderScope) => void | Promise<void>;
8
+ readonly boot?: (scope: ProviderScope) => void | Promise<void>;
9
+ }
10
+ /** Group declarative bindings and startup hooks without introducing a mutable container. */
11
+ declare function defineProvider(options: ApplicationProviderOptions): ProviderDefinition;
12
+ export type { ApplicationProviderOptions };
13
+ export { defineProvider };
@@ -1,12 +1,12 @@
1
1
  import type { AbilityChecker } from "../auth/abilityChecker";
2
2
  import type { AuthReader } from "../auth/authReader";
3
- import type { PolicyGate } from "../auth/policy";
4
- import type { EventBus } from "../events/eventBusClass";
3
+ import type { PolicyAuthorizer, PolicyRegistry } from "../auth/policy";
4
+ import type { EventDispatcher } from "../events/eventBusClass";
5
5
  import type { ThrottleQuotaPolicy } from "../http/throttleMiddleware";
6
- import type { Mailer } from "../mail/mailer";
7
- import type { Queue } from "../queue/index";
6
+ import type { MailSender } from "../mail/mailer";
7
+ import type { QueueDispatcher } from "../queue/index";
8
8
  import type { QueueServices } from "../queue/queueServices";
9
- import type { StorageManager } from "../storage/storage";
9
+ import type { Storage } from "../storage/storage";
10
10
  import type { PublicTenancyOptions, TenantResolver } from "../tenant/tenantMiddleware";
11
11
  import type { TracingRuntime } from "../tracing/otel";
12
12
  import type { AuthAccountLookup } from "./authUserDirectory";
@@ -17,16 +17,17 @@ declare const CORE_PUBLIC_TENANCY_TOKEN: import("@getstrata/core/contracts/token
17
17
  declare const CORE_TENANT_RESOLVER_TOKEN: import("@getstrata/core/contracts/token").ServiceToken<TenantResolver>;
18
18
  declare const CORE_HTTP_CLEANUP_TOKEN: import("@getstrata/core/contracts/token").ServiceToken<(cleanup: () => void) => void>;
19
19
  declare const CORE_TRACING_RUNTIME_TOKEN: import("@getstrata/core/contracts/token").ServiceToken<TracingRuntime>;
20
- declare const CORE_MAIL_TOKEN: import("@getstrata/core/contracts/token").ServiceToken<Mailer>;
21
- declare const CORE_STORAGE_TOKEN: import("@getstrata/core/contracts/token").ServiceToken<StorageManager>;
20
+ declare const CORE_MAIL_TOKEN: import("@getstrata/core/contracts/token").ServiceToken<MailSender>;
21
+ declare const CORE_STORAGE_TOKEN: import("@getstrata/core/contracts/token").ServiceToken<Storage>;
22
22
  declare const CORE_JSON_RESPONSE_POLICY_TOKEN: import("@getstrata/core/contracts/token").ServiceToken<Readonly<{
23
23
  etagEnabled: boolean;
24
24
  }>>;
25
25
  declare const CORE_CONFIG_TOKEN: import("@getstrata/core/contracts/token").ServiceToken<ConfigStoreLike>;
26
26
  declare const FAILED_JOB_SERVICE_TOKEN: import("@getstrata/core/contracts/token").ServiceToken<QueueServices>;
27
- declare const CORE_QUEUE_TOKEN: import("@getstrata/core/contracts/token").ServiceToken<Queue>;
28
- declare const CORE_EVENT_BUS_TOKEN: import("@getstrata/core/contracts/token").ServiceToken<EventBus>;
29
- declare const CORE_POLICY_GATE_TOKEN: import("@getstrata/core/contracts/token").ServiceToken<Pick<PolicyGate<Record<string, import("../auth/policy").Policy>>, "allows" | "authorize" | "register">>;
27
+ declare const CORE_QUEUE_TOKEN: import("@getstrata/core/contracts/token").ServiceToken<QueueDispatcher>;
28
+ declare const CORE_EVENT_BUS_TOKEN: import("@getstrata/core/contracts/token").ServiceToken<EventDispatcher>;
29
+ declare const CORE_POLICY_GATE_TOKEN: import("@getstrata/core/contracts/token").ServiceToken<PolicyAuthorizer>;
30
+ declare const CORE_POLICY_REGISTRY_TOKEN: import("@getstrata/core/contracts/token").ServiceToken<PolicyRegistry>;
30
31
  declare const CORE_AUTH_TOKEN: import("@getstrata/core/contracts/token").ServiceToken<AuthReader>;
31
32
  declare const CORE_ABILITY_CHECKER_TOKEN: import("@getstrata/core/contracts/token").ServiceToken<AbilityChecker>;
32
33
  declare const CORE_AUTH_USER_DIRECTORY_TOKEN: import("@getstrata/core/contracts/token").ServiceToken<AuthAccountLookup>;
@@ -34,4 +35,4 @@ declare function isAbilityChecker(value: unknown): value is AbilityChecker;
34
35
  declare function isAuthUserDirectory(value: unknown): value is AuthAccountLookup;
35
36
  declare function resolveAbilityChecker(container: ServiceContainerLike): AbilityChecker;
36
37
  declare function resolveAuthUserDirectory(container: ServiceContainerLike): AuthAccountLookup | null;
37
- export { CORE_ABILITY_CHECKER_TOKEN, CORE_AUTH_TOKEN, CORE_AUTH_USER_DIRECTORY_TOKEN, CORE_CONFIG_TOKEN, CORE_EVENT_BUS_TOKEN, CORE_HTTP_CLEANUP_TOKEN, CORE_JSON_RESPONSE_POLICY_TOKEN, CORE_MAIL_TOKEN, CORE_POLICY_GATE_TOKEN, CORE_PUBLIC_TENANCY_TOKEN, CORE_QUEUE_TOKEN, CORE_STORAGE_TOKEN, CORE_TENANT_RESOLVER_TOKEN, CORE_THROTTLE_QUOTA_POLICY_TOKEN, CORE_TRACING_RUNTIME_TOKEN, FAILED_JOB_SERVICE_TOKEN, isAbilityChecker, isAuthUserDirectory, resolveAbilityChecker, resolveAuthUserDirectory, };
38
+ export { CORE_ABILITY_CHECKER_TOKEN, CORE_AUTH_TOKEN, CORE_AUTH_USER_DIRECTORY_TOKEN, CORE_CONFIG_TOKEN, CORE_EVENT_BUS_TOKEN, CORE_HTTP_CLEANUP_TOKEN, CORE_JSON_RESPONSE_POLICY_TOKEN, CORE_MAIL_TOKEN, CORE_POLICY_GATE_TOKEN, CORE_POLICY_REGISTRY_TOKEN, CORE_PUBLIC_TENANCY_TOKEN, CORE_QUEUE_TOKEN, CORE_STORAGE_TOKEN, CORE_TENANT_RESOLVER_TOKEN, CORE_THROTTLE_QUOTA_POLICY_TOKEN, CORE_TRACING_RUNTIME_TOKEN, FAILED_JOB_SERVICE_TOKEN, isAbilityChecker, isAuthUserDirectory, resolveAbilityChecker, resolveAuthUserDirectory, };
@@ -70,3 +70,6 @@ declare class Factory<TRecord extends object, Counted extends boolean = false> {
70
70
  }
71
71
  export type { FactoryBehavior, FactoryConstruction, FactoryDefinition, FactoryMakeResult, FactoryParent, FactoryPersist, StatelessFactoryConstruction, };
72
72
  export { defineFactory, Factory };
73
+ /** Create a factory with explicit persistence supplied by the active invocation. */
74
+ declare function createFactory<R extends object>(behavior: FactoryBehavior<R>): Factory<R>;
75
+ export { createFactory };
@@ -3,7 +3,7 @@ export { defineModel, defineRepository, repositoryEffects, } from "@getstrata/co
3
3
  export { mapDatabaseError, RecordNotFoundError, withDatabaseErrorHandling, } from "@getstrata/core/database/errors";
4
4
  export type { FactoryBehavior, FactoryConstruction, FactoryDefinition, FactoryMakeResult, FactoryParent, FactoryPersist, StatelessFactoryConstruction, } from "@getstrata/core/database/factory";
5
5
  export { defineFactory, Factory } from "@getstrata/core/database/factory";
6
- export { BaseRepository, BelongsToManyRelationQuery, BelongsToRelationQuery, HasManyRelationQuery, HasManyThroughRelationQuery, HasOneRelationQuery, Model, ModelQuery, MorphManyRelationQuery, MorphOneRelationQuery, MorphToRelationQuery, RepositoryQuery, } from "#strata-orm-runtime";
6
+ export { BaseRepository, BelongsToManyRelationQuery, BelongsToRelationQuery, createModel, HasManyRelationQuery, HasManyThroughRelationQuery, HasOneRelationQuery, Model, ModelQuery, MorphManyRelationQuery, MorphOneRelationQuery, MorphToRelationQuery, RepositoryQuery, } from "#strata-orm-runtime";
7
7
  export { createDatabaseConnection } from "./connection.ts";
8
8
  export type { ActiveDatabaseHandle } from "./connectionContext.ts";
9
9
  export { getActiveDatabaseConnection, hasActiveDatabaseConnection, runWithDatabaseConnection, } from "./connectionContext.ts";
@@ -0,0 +1,11 @@
1
+ import { type SchemaBuilder } from "../schema/schema";
2
+ import type { Migration, MigrationDatabase, MigrationDownContext } from "./types";
3
+ interface MigrationDeclaration {
4
+ readonly name: string;
5
+ readonly up: (schema: SchemaBuilder, db: MigrationDatabase) => void | Promise<void>;
6
+ readonly down: (schema: SchemaBuilder, db: MigrationDatabase, context?: MigrationDownContext) => void | Promise<void>;
7
+ }
8
+ /** The runner owns the database and dialect; declarations describe only schema changes. */
9
+ declare function defineMigration(declaration: MigrationDeclaration): Migration;
10
+ export type { MigrationDeclaration };
11
+ export { defineMigration };
@@ -21,7 +21,9 @@ declare function freshDatabase(db: MigrationDatabase, migrations: Migration[], o
21
21
  advisoryLock?: boolean;
22
22
  onMigration?: (name: string) => void;
23
23
  destructive?: boolean;
24
+ environment?: Readonly<Record<string, string | undefined>>;
24
25
  }): Promise<void>;
25
26
  export { withMigrationLock } from "./advisoryLock.ts";
27
+ export { defineMigration, type MigrationDeclaration } from "./declaration";
26
28
  export { guardMigrationRollback, type MigrationRollbackGuard } from "./rollbackGuard.ts";
27
29
  export { ensureMigrationsTable, freshDatabase, getAppliedMigrations, getMigrationStatus, loadMigrationsFromDirectory, migrateDatabase, rollbackDatabase, runPendingMigrations, };
@@ -1,12 +1,14 @@
1
- import type { AnyModelDefinition, ModelBinding, ModelDefinition, ModelObserver, ModelState } from "@getstrata/core/database/definitions";
1
+ import type { AnyModelDefinition, ModelAttributeOptions, ModelBinding, ModelDefinition, ModelObserver, ModelState, RepositoryDefinition } from "@getstrata/core/database/definitions";
2
+ import type { ServiceToken } from "../contracts/token";
2
3
  import type { KeysetOptions } from "../pagination/index.ts";
3
- import type BaseRepository from "./baseRepository.ts";
4
+ import BaseRepository from "./baseRepository.ts";
4
5
  import { applyCasts, type CastType, dehydrateValue, filterMassAssignable, hydrateValue, type LoadedAttributes, type ModelCasts } from "./modelAttributes.ts";
5
6
  import { type AnyModel, type ModelAttributes, type ModelIdentifier, type ModelProjection, ModelQuery, type RelationNameInput } from "./modelQuery.ts";
6
7
  import type { AnyRelationQuery, RelatedModelClass } from "./relationQuery.ts";
7
8
  import { BelongsToManyRelationQuery, BelongsToRelationQuery, HasManyRelationQuery, HasManyThroughRelationQuery, HasOneRelationQuery, MorphManyRelationQuery, MorphOneRelationQuery, MorphToRelationQuery } from "./relationQuery.ts";
8
9
  import type { BelongsToManyRelation, BelongsToRelation, HasManyRelation, HasOneRelation } from "./relationships.ts";
9
10
  import type { RepositoryQuery } from "./repositoryQuery.ts";
11
+ import type { TableDefinition } from "./table";
10
12
  import type { ModelWhere, ModelWriteValues, QueryOptions } from "./types.ts";
11
13
  type RelatedRef<TRelated extends object, RelatedKey extends keyof TRelated & string, M extends Model<TRelated, RelatedKey> = Model<TRelated, RelatedKey>> = ModelDefinition<TRelated, RelatedKey, M> | string | (() => ModelDefinition<TRelated, RelatedKey, M>);
12
14
  declare let saveRelatedModel: (entity: AnyModel, forced: LoadedAttributes) => Promise<AnyModel>;
@@ -167,7 +169,18 @@ declare class BoundModelFacade<R extends object, K extends keyof R & string, M e
167
169
  }, where: NoInfer<ModelWhere<ModelAttributes<TModel>>>, values?: NoInfer<ModelWriteValues<ModelAttributes<TModel>>>): Promise<TModel>;
168
170
  }
169
171
  declare function createBoundModel<R extends object, K extends keyof R & string, M extends Model<R, K>>(binding: ModelBinding<R, K, BaseRepository<R, K>>): BoundModelFacade<R, K, M>;
172
+ /** Declare an ordinary model without selecting a database session or constructing entities. */
173
+ declare function createModel<R extends object, K extends keyof R & string>(options: {
174
+ name: string;
175
+ table: TableDefinition<R, K>;
176
+ attributes: ModelAttributeOptions<R>;
177
+ aliases?: readonly string[];
178
+ observers?: readonly ServiceToken<ModelObserver<Model<R, K>>>[];
179
+ scopes?: readonly ((query: RepositoryQuery<R, K>) => RepositoryQuery<R, K>)[];
180
+ }): ModelDefinition<R, K, Model<R, K>> & {
181
+ readonly repository: RepositoryDefinition<R, K, BaseRepository<R, K>>;
182
+ };
170
183
  export { defineModel } from "@getstrata/core/database/definitions";
171
184
  export { BelongsToManyRelationQuery, BelongsToRelationQuery, HasManyRelationQuery, HasManyThroughRelationQuery, HasOneRelationQuery, MorphManyRelationQuery, MorphOneRelationQuery, MorphToRelationQuery, } from "./relationQuery.ts";
172
185
  export type { CastType, ModelAttributes, ModelProjection, RelatedRef };
173
- export { applyCasts, BoundModelFacade, createBoundModel, dehydrateValue, filterMassAssignable, getModelBinding, hydrateValue, Model, ModelQuery, modelFacade, runObservers, saveRelatedModel, };
186
+ export { applyCasts, BoundModelFacade, createBoundModel, createModel, dehydrateValue, filterMassAssignable, getModelBinding, hydrateValue, Model, ModelQuery, modelFacade, runObservers, saveRelatedModel, };
@@ -1,6 +1,7 @@
1
1
  import type { CursorPaginatedResult, KeysetCursor, KeysetOptions } from "../pagination/index.ts";
2
2
  import type BaseRepository from "./baseRepository.ts";
3
3
  import { type Model } from "./model.ts";
4
+ import { flattenRelationNames, loadNested, type RelationNameInput } from "./modelRelationLoader";
4
5
  import type { AnyRelationQuery } from "./relationQuery.ts";
5
6
  import type { BelongsToManyRelation, BelongsToRelation, HasManyRelation, HasManyThroughRelation, MorphManyRelation, MorphOneRelation, MorphToRelation } from "./relationships.ts";
6
7
  import { type RepositoryQuery } from "./repositoryQuery.ts";
@@ -17,16 +18,6 @@ type WithModelCount<TModel, TCount extends string> = {
17
18
  get<K extends keyof (Omit<ModelAttributes<TModel>, TCount> & Record<TCount, unknown>)>(key: K): (Omit<ModelAttributes<TModel>, TCount> & Record<TCount, unknown>)[K];
18
19
  } & TModel;
19
20
  type ModelQueryResult<TModel, TCounts extends string> = [TCounts] extends [never] ? TModel : WithModelCount<TModel, TCounts>;
20
- type RelationNameInput = string | readonly string[];
21
- declare function flattenRelationNames(relations: ReadonlyArray<RelationNameInput>): string[];
22
- declare function loadNested(model: {
23
- load: (...names: string[]) => Promise<unknown>;
24
- loaded: (name: string) => unknown;
25
- constructor: object;
26
- getRepository: () => BaseRepository<Record<string, unknown>, "id">;
27
- toObject: () => object;
28
- setLoaded: (name: string, value: unknown) => unknown;
29
- }, path: string, preparedRoot?: AnyRelationQuery): Promise<void>;
30
21
  /** Read-only plain records; partial selection never acquires model mutation methods. */
31
22
  declare class ModelProjection<TEntity extends object, K extends keyof TEntity & string> {
32
23
  private readonly load;
@@ -0,0 +1,31 @@
1
+ import type BaseRepository from "./baseRepository";
2
+ import type { AnyRelationQuery } from "./relationQuery";
3
+ /** Private nested relation loading: preserves concrete owners and absent morph targets. */
4
+ type RelationNameInput = string | readonly string[];
5
+ declare function flattenRelationNames(relations: ReadonlyArray<RelationNameInput>): string[];
6
+ declare function isLoadableModel(value: unknown): value is {
7
+ load: (...names: string[]) => Promise<unknown>;
8
+ loaded: (name: string) => unknown;
9
+ constructor: object;
10
+ getRepository: () => BaseRepository<Record<string, unknown>, "id">;
11
+ toObject: () => object;
12
+ setLoaded: (name: string, value: unknown) => unknown;
13
+ };
14
+ declare function eagerLoadOnModels(models: Array<{
15
+ loaded: (name: string) => unknown;
16
+ constructor: object;
17
+ getRepository: () => BaseRepository<Record<string, unknown>, "id">;
18
+ toObject: () => object;
19
+ setLoaded: (name: string, value: unknown) => unknown;
20
+ load: (...names: string[]) => Promise<unknown>;
21
+ }>, paths: string[], knownAbsentMorphRoots?: ReadonlyMap<object, ReadonlySet<string>>, preparedRoots?: ReadonlyMap<object, ReadonlyMap<string, AnyRelationQuery>>): Promise<void>;
22
+ declare function loadNested(model: {
23
+ load: (...names: string[]) => Promise<unknown>;
24
+ loaded: (name: string) => unknown;
25
+ constructor: object;
26
+ getRepository: () => BaseRepository<Record<string, unknown>, "id">;
27
+ toObject: () => object;
28
+ setLoaded: (name: string, value: unknown) => unknown;
29
+ }, path: string, preparedRoot?: AnyRelationQuery): Promise<void>;
30
+ export type { RelationNameInput };
31
+ export { eagerLoadOnModels, flattenRelationNames, isLoadableModel, loadNested };
@@ -1,7 +1,7 @@
1
+ import { createMysqlPool, type MysqlExecutable, type MysqlPool, type MysqlPoolConnection } from "#strata-mysql-native";
1
2
  import { type ActiveDatabaseHandle } from "./connectionContext.ts";
2
3
  import type { DatabaseConnection } from "./connectionContracts.ts";
3
4
  import { type ReadOnlyObservationOptions } from "./isolatedReadOnlyObservation.ts";
4
- import { createMysqlPool, type MysqlExecutable, type MysqlPool, type MysqlPoolConnection, resetMysqlLoaderForTests } from "./mysqlNative";
5
5
  type MysqlConnection = ActiveDatabaseHandle & {
6
6
  begin<T>(callback: (transaction: ActiveDatabaseHandle) => Promise<T>): Promise<T>;
7
7
  close(): Promise<void>;
@@ -10,4 +10,4 @@ type MysqlConnection = ActiveDatabaseHandle & {
10
10
  declare function createMysqlConnectionFromPool(pool: MysqlExecutable): MysqlConnection;
11
11
  declare function createMysqlConnection(url: string): MysqlConnection;
12
12
  export type { MysqlConnection, MysqlExecutable, MysqlPool, MysqlPoolConnection };
13
- export { createMysqlConnection, createMysqlConnectionFromPool, createMysqlPool, resetMysqlLoaderForTests, };
13
+ export { createMysqlConnection, createMysqlConnectionFromPool, createMysqlPool };
@@ -2,6 +2,8 @@ type MysqlPromiseModule = {
2
2
  createPool: (config: {
3
3
  uri: string;
4
4
  timezone: string;
5
+ supportBigNumbers: true;
6
+ bigNumberStrings: false;
5
7
  connectionLimit?: number;
6
8
  }) => MysqlPool;
7
9
  };
@@ -1,4 +1,4 @@
1
1
  /** Canonical ORM classes and private construction accessors; package-private entry. */
2
2
  export { default as BaseRepository, getRepositoryBinding } from "./baseRepository";
3
- export { BelongsToManyRelationQuery, BelongsToRelationQuery, BoundModelFacade, createBoundModel, getModelBinding, HasManyRelationQuery, HasManyThroughRelationQuery, HasOneRelationQuery, Model, ModelQuery, MorphManyRelationQuery, MorphOneRelationQuery, MorphToRelationQuery, modelFacade, runObservers, } from "./model";
3
+ export { BelongsToManyRelationQuery, BelongsToRelationQuery, BoundModelFacade, createBoundModel, createModel, getModelBinding, HasManyRelationQuery, HasManyThroughRelationQuery, HasOneRelationQuery, Model, ModelQuery, MorphManyRelationQuery, MorphOneRelationQuery, MorphToRelationQuery, modelFacade, runObservers, } from "./model";
4
4
  export { RepositoryQuery, snapshotRepositoryQuery } from "./repositoryQuery";
@@ -1,5 +1,5 @@
1
+ import { type MysqlPoolConnection } from "#strata-mysql-native";
1
2
  import type { DisposeAck, MysqlDatabaseOptions, RawPin, RawPool } from "./driverPorts";
2
- import { type MysqlPoolConnection } from "./mysqlNative";
3
3
  /** mysql2 destroy() only calls stream.end(); its void return is not socket closure. */
4
4
  declare function destroyMysqlConnection(connection: MysqlPoolConnection): Promise<DisposeAck>;
5
5
  declare function createMysqlPin(connection: MysqlPoolConnection): RawPin;
@@ -1,6 +1,9 @@
1
1
  type EventListener = (payload: unknown) => void | Promise<void>;
2
- declare class EventBus {
3
- constructor();
2
+ /** Capability for publishing application events; listener ownership stays with composition. */
3
+ interface EventDispatcher {
4
+ dispatch(event: string, payload: unknown): Promise<void>;
5
+ }
6
+ declare class EventBus implements EventDispatcher {
4
7
  private readonly transactionalListeners;
5
8
  listenTransactional(event: string, listener: EventListener): () => void;
6
9
  hasTransactionalListeners(event: string): boolean;
@@ -11,5 +14,5 @@ declare class EventBus {
11
14
  emit(event: string, payload: unknown): Promise<void>;
12
15
  dispatch(event: string, payload: unknown): Promise<void>;
13
16
  }
14
- export type { EventListener };
17
+ export type { EventDispatcher, EventListener };
15
18
  export { EventBus };
@@ -1,4 +1,4 @@
1
- export type { EventListener } from "./eventBusClass";
1
+ export type { EventDispatcher, EventListener } from "./eventBusClass";
2
2
  export { EventBus } from "./eventBusClass";
3
3
  declare function modelEventName(tableName: string, action: string): string;
4
4
  export { modelEventName };
@@ -1,6 +1,8 @@
1
1
  declare abstract class FormRequest<TOutput> {
2
2
  authorize(_request: Request): boolean | Promise<boolean>;
3
3
  protected abstract parse(payload: unknown): TOutput;
4
+ validatePayload(payload: unknown): TOutput;
5
+ protected readPayload(request: Request): Promise<unknown>;
4
6
  validate(request: Request): Promise<TOutput>;
5
7
  }
6
8
  declare abstract class QueryFormRequest<TOutput> {
@@ -13,6 +13,5 @@ declare function resolveLoginIdentity(request: Request, trustForwardedFor?: bool
13
13
  declare function resolveLoginEmail(request: Request): Promise<string>;
14
14
  declare function createMemoryLoginThrottleMiddleware(options: LoginThrottleOptions): DisposableMemoryThrottle;
15
15
  declare function createLoginThrottleMiddleware(options: LoginThrottleOptions): DisposableThrottle;
16
- declare function resetMemoryLoginThrottleForTests(): void;
17
16
  export type { LoginThrottleOptions };
18
- export { createLoginThrottleMiddleware, createMemoryLoginThrottleMiddleware, resetMemoryLoginThrottleForTests, resolveLoginEmail, resolveLoginIdentity, };
17
+ export { createLoginThrottleMiddleware, createMemoryLoginThrottleMiddleware, resolveLoginEmail, resolveLoginIdentity, };
@@ -12,7 +12,5 @@ type DisposableMemoryThrottle = Middleware & {
12
12
  stats(): MemoryThrottleStats;
13
13
  };
14
14
  declare function createMemoryThrottleMiddleware(options: MemoryThrottleOptions): DisposableMemoryThrottle;
15
- /** Lazy generation reset avoids retaining middleware instances in a global test registry. */
16
- declare function resetMemoryThrottleForTests(): void;
17
15
  export type { DisposableMemoryThrottle, MemoryThrottleOptions, MemoryThrottleStats, MemoryThrottleStorageOptions, };
18
- export { createMemoryThrottleMiddleware, resetMemoryThrottleForTests };
16
+ export { createMemoryThrottleMiddleware };
@@ -1,10 +1,8 @@
1
+ import { FormRequest } from "./formRequest";
1
2
  import { type FormBodyOptions } from "./parseFormBody";
2
- declare abstract class WebFormRequest<TOutput> {
3
+ declare abstract class WebFormRequest<TOutput> extends FormRequest<TOutput> {
3
4
  #private;
4
5
  constructor(options?: FormBodyOptions);
5
- authorize(_request: Request): boolean | Promise<boolean>;
6
- protected abstract parse(payload: unknown): TOutput;
7
- validatePayload(payload: unknown): TOutput;
8
- validate(request: Request): Promise<TOutput>;
6
+ protected readPayload(request: Request): Promise<unknown>;
9
7
  }
10
8
  export { WebFormRequest };
@@ -8,9 +8,12 @@ interface MailMessage {
8
8
  html?: string;
9
9
  signal?: AbortSignal;
10
10
  }
11
- interface MailDriver {
11
+ interface MailSender {
12
12
  send(message: MailMessage): Promise<void>;
13
13
  }
14
+ /** A mail transport implements the same minimal sending capability. */
15
+ interface MailDriver extends MailSender {
16
+ }
14
17
  interface SmtpConfig {
15
18
  host: string;
16
19
  port: number;
@@ -36,11 +39,11 @@ declare class SmtpMailDriver implements MailDriver {
36
39
  constructor(config: SmtpConfig, transport?: SmtpTransport);
37
40
  send(message: MailMessage): Promise<void>;
38
41
  }
39
- declare class Mailer {
42
+ declare class Mailer implements MailSender {
40
43
  private readonly driver;
41
44
  constructor(driver: MailDriver);
42
45
  send(message: MailMessage): Promise<void>;
43
46
  }
44
47
  declare function createMailDriver(env?: Readonly<Record<string, string | undefined>>): MailDriver;
45
- export type { MailDriver, MailMessage, SmtpConfig, SmtpTransport };
48
+ export type { MailDriver, MailMessage, MailSender, SmtpConfig, SmtpTransport };
46
49
  export { assertSafeSmtpAddress, assertSafeSmtpField, buildSmtpPayload, CORE_MAIL_TOKEN, createMailDriver, defaultSmtpTransport, LogMailDriver, Mailer, redactMailBody, resolveSmtpConfig, SmtpMailDriver, smtpEnvelopeAddress, snapshotSmtpConfig, };
@@ -1,4 +1,4 @@
1
- import type { Mailer, MailMessage } from "./mailer.ts";
1
+ import type { MailMessage, MailSender } from "./mailer.ts";
2
2
  import { type MarkdownMailLayoutOptions } from "./markdownMail.ts";
3
3
  interface MarkdownMailableInput {
4
4
  to: string;
@@ -7,6 +7,6 @@ interface MarkdownMailableInput {
7
7
  layout?: MarkdownMailLayoutOptions;
8
8
  }
9
9
  declare function buildMarkdownMailMessage(input: MarkdownMailableInput): MailMessage;
10
- declare function sendMarkdownMail(mailer: Mailer, input: MarkdownMailableInput): Promise<void>;
10
+ declare function sendMarkdownMail(mailer: MailSender, input: MarkdownMailableInput): Promise<void>;
11
11
  export type { MarkdownMailableInput };
12
12
  export { buildMarkdownMailMessage, sendMarkdownMail };
@@ -1,13 +1,13 @@
1
- import type { Mailer } from "../mail/mailer.ts";
1
+ import type { MailSender } from "../mail/mailer.ts";
2
2
  import type { Notification } from "./notification.ts";
3
- import type { DatabaseNotificationStore, Notifiable } from "./types.ts";
3
+ import type { DatabaseNotificationStore, Notifiable, NotificationChannels } from "./types.ts";
4
4
  declare class NotificationDispatcher {
5
5
  private readonly mailer;
6
- private readonly databaseStore;
7
- constructor(mailer: Mailer, databaseStore?: DatabaseNotificationStore | null);
6
+ private readonly channels;
7
+ constructor(mailer: MailSender, databaseStore?: DatabaseNotificationStore | null, channels?: NotificationChannels);
8
8
  send(notifiable: Notifiable, notification: Notification): Promise<void>;
9
9
  private sendMail;
10
10
  private sendDatabase;
11
11
  }
12
- declare function createNotificationDispatcher(mailer: Mailer, databaseStore?: DatabaseNotificationStore): NotificationDispatcher;
12
+ declare function createNotificationDispatcher(mailer: MailSender, databaseStore?: DatabaseNotificationStore, channels?: NotificationChannels): NotificationDispatcher;
13
13
  export { createNotificationDispatcher, NotificationDispatcher };
@@ -1,3 +1,3 @@
1
1
  export { createNotificationDispatcher, NotificationDispatcher } from "./dispatcher.ts";
2
2
  export { Notification } from "./notification.ts";
3
- export type { DatabaseNotificationPayload, DatabaseNotificationStore, MailNotificationMessage, Notifiable, NotificationChannelName, } from "./types.ts";
3
+ export type { DatabaseNotificationPayload, DatabaseNotificationStore, MailNotificationMessage, Notifiable, NotificationChannel, NotificationChannelName, NotificationChannels, } from "./types.ts";
@@ -1,4 +1,11 @@
1
- type NotificationChannelName = "mail" | "database";
1
+ import type { Notification } from "./notification.ts";
2
+ /** Channel names belong to the application; built-ins retain editor completion. */
3
+ type NotificationChannelName = "mail" | "database" | (string & {});
4
+ /** An application-owned delivery capability. Failures propagate to the caller. */
5
+ interface NotificationChannel {
6
+ send(notifiable: Notifiable, notification: Notification): Promise<void>;
7
+ }
8
+ type NotificationChannels = Readonly<Record<string, NotificationChannel>>;
2
9
  interface MailNotificationMessage {
3
10
  subject: string;
4
11
  markdown?: string;
@@ -22,4 +29,4 @@ interface Notifiable {
22
29
  getNotificationKey(): string | number;
23
30
  routeNotificationFor(channel: NotificationChannelName): string | number | null;
24
31
  }
25
- export type { DatabaseNotificationPayload, DatabaseNotificationStore, MailNotificationMessage, Notifiable, NotificationChannelName, };
32
+ export type { DatabaseNotificationPayload, DatabaseNotificationStore, MailNotificationMessage, Notifiable, NotificationChannel, NotificationChannelName, NotificationChannels, };