@venizia/ignis-kernel 0.4.8-15 → 0.4.8-16
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.
- package/dist/esm/base/applications/artifact-index.d.ts +3 -3
- package/dist/esm/base/applications/artifact-index.js.map +1 -1
- package/dist/esm/base/applications/body-limit.js +1 -1
- package/dist/esm/base/applications/body-limit.js.map +1 -1
- package/dist/esm/base/applications/rest.js.map +1 -1
- package/dist/esm/base/auth/authenticate/common/types/strategy.d.ts +1 -2
- package/dist/esm/base/auth/authenticate/common/types/strategy.js.map +1 -1
- package/dist/esm/base/auth/authorize/providers/request-domain.js +2 -1
- package/dist/esm/base/auth/authorize/providers/request-domain.js.map +1 -1
- package/dist/esm/base/controllers/common/types/route.d.ts +13 -4
- package/dist/esm/base/controllers/common/types/route.js.map +1 -1
- package/dist/esm/base/controllers/factory/controller.d.ts +3 -4
- package/dist/esm/base/controllers/factory/controller.js +0 -1
- package/dist/esm/base/controllers/factory/controller.js.map +1 -1
- package/dist/esm/base/controllers/factory/crud/abstract.d.ts +3 -4
- package/dist/esm/base/controllers/factory/crud/abstract.js.map +1 -1
- package/dist/esm/base/controllers/factory/index.d.ts +1 -0
- package/dist/esm/base/controllers/factory/index.js +1 -0
- package/dist/esm/base/controllers/factory/index.js.map +1 -1
- package/dist/esm/base/controllers/factory/injection.d.ts +38 -0
- package/dist/esm/base/controllers/factory/injection.js +54 -0
- package/dist/esm/base/controllers/factory/injection.js.map +1 -0
- package/dist/esm/base/controllers/rest/base.d.ts +3 -3
- package/dist/esm/base/controllers/rest/base.js.map +1 -1
- package/dist/esm/base/datasources/common/types.d.ts +2 -2
- package/dist/esm/base/datasources/common/types.js.map +1 -1
- package/dist/esm/base/datasources/root.d.ts +2 -2
- package/dist/esm/base/datasources/root.js.map +1 -1
- package/dist/esm/base/events/event-bus.js.map +1 -1
- package/dist/esm/base/metadata/index.d.ts +1 -1
- package/dist/esm/base/metadata/index.js +1 -1
- package/dist/esm/base/metadata/injectors.d.ts +1 -1
- package/dist/esm/base/metadata/persistents/datasource.d.ts +21 -0
- package/dist/esm/base/metadata/persistents/datasource.js +46 -0
- package/dist/esm/base/metadata/persistents/datasource.js.map +1 -0
- package/dist/esm/base/metadata/persistents/index.d.ts +5 -0
- package/dist/esm/base/metadata/persistents/index.js +5 -0
- package/dist/esm/base/metadata/persistents/index.js.map +1 -0
- package/dist/esm/base/metadata/persistents/model.d.ts +18 -0
- package/dist/esm/base/metadata/persistents/model.js +64 -0
- package/dist/esm/base/metadata/persistents/model.js.map +1 -0
- package/dist/esm/base/metadata/persistents/repository/index.d.ts +19 -0
- package/dist/esm/base/metadata/persistents/repository/index.js +32 -0
- package/dist/esm/base/metadata/persistents/repository/index.js.map +1 -0
- package/dist/esm/base/metadata/persistents/repository/injection.d.ts +15 -0
- package/dist/esm/base/metadata/persistents/repository/injection.js +64 -0
- package/dist/esm/base/metadata/persistents/repository/injection.js.map +1 -0
- package/dist/esm/base/metadata/persistents/repository/resolve.d.ts +15 -0
- package/dist/esm/base/metadata/persistents/repository/resolve.js +76 -0
- package/dist/esm/base/metadata/persistents/repository/resolve.js.map +1 -0
- package/dist/esm/base/metadata/persistents/repository/validate.d.ts +15 -0
- package/dist/esm/base/metadata/persistents/repository/validate.js +50 -0
- package/dist/esm/base/metadata/persistents/repository/validate.js.map +1 -0
- package/dist/esm/base/models/common/utilities.d.ts +1 -1
- package/dist/esm/base/repositories/common/types/options.d.ts +2 -2
- package/dist/esm/base/repositories/common/types/options.js.map +1 -1
- package/dist/esm/base/repositories/common/types/query.d.ts +6 -15
- package/dist/esm/base/repositories/common/types/query.js.map +1 -1
- package/dist/esm/base/repositories/query-schemas/index.js +7 -0
- package/dist/esm/base/repositories/query-schemas/index.js.map +1 -1
- package/dist/esm/helpers/inversion/mixins/artifact.mixin.d.ts +3 -3
- package/dist/esm/helpers/inversion/mixins/controllers/controller.d.ts +3 -3
- package/dist/esm/helpers/inversion/mixins/controllers/grpc.d.ts +3 -3
- package/dist/esm/helpers/inversion/mixins/controllers/rest.d.ts +3 -3
- package/dist/esm/helpers/inversion/mixins/datasource.mixin.d.ts +3 -3
- package/dist/esm/helpers/inversion/mixins/model.mixin.d.ts +3 -3
- package/dist/esm/helpers/inversion/mixins/repository.mixin.d.ts +8 -8
- package/dist/esm/helpers/inversion/mixins/repository.mixin.js +5 -6
- package/dist/esm/helpers/inversion/mixins/repository.mixin.js.map +1 -1
- package/dist/esm/helpers/inversion/registry.d.ts +26 -26
- package/dist/esm/helpers/inversion/registry.js.map +1 -1
- package/dist/esm/helpers/singleton-realm.js +5 -4
- package/dist/esm/helpers/singleton-realm.js.map +1 -1
- package/dist/esm/metadata.d.ts +1 -1
- package/dist/esm/metadata.js +1 -1
- package/dist/esm/utilities/index.d.ts +1 -0
- package/dist/esm/utilities/index.js +1 -0
- package/dist/esm/utilities/index.js.map +1 -1
- package/dist/esm/utilities/toggle.utility.d.ts +22 -0
- package/dist/esm/utilities/toggle.utility.js +16 -0
- package/dist/esm/utilities/toggle.utility.js.map +1 -0
- package/package.json +5 -5
- package/dist/esm/base/metadata/persistents.d.ts +0 -55
- package/dist/esm/base/metadata/persistents.js +0 -303
- package/dist/esm/base/metadata/persistents.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"event-bus.js","sourceRoot":"","sources":["../../../../src/base/events/event-bus.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAG9D,OAAO,EACL,UAAU,EACV,QAAQ,EACR,sBAAsB,EACtB,WAAW,EACX,gBAAgB,GACjB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAqB3E;;;;;;;+EAO+E;AAC/E,MAAM,OAAO,QAAqC,SAAQ,UAAU;IAOlE,YAAY,IAA8C;QACxD,KAAK,CAAC,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK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Content":["import { ObjectUtility } from '@venizia/ignis-helpers/common';\nimport type { Container } from '@/helpers/inversion/container';\nimport type { AnyType, ValueOrPromise } from '@venizia/ignis-helpers/common';\nimport {\n BaseHelper,\n getError,\n RetryBackoffStrategies,\n RetryHelper,\n RetryJitterModes,\n} from '@venizia/ignis-helpers/core';\nimport { EventDispatchRetry, EventHandlerTypes } from './common/constants';\nimport type {\n IDomainEvent,\n IEventHandler,\n IEventHandlerRetryOptions,\n TEventHandlerReference,\n} from './common/types';\n\ntype TEventHandlerInvoker = (opts: { event: IDomainEvent<unknown> }) => ValueOrPromise<void>;\n\n/** One `register`ed handler, resolved to concrete retry numbers and a ready-to-call invoker -\n * `EventDispatchRetry`'s defaults already applied and `handler`'s shape already resolved, so\n * `dispatch` never has to branch on either. */\ninterface IResolvedEventRegistration {\n invokeHandler: TEventHandlerInvoker;\n /** For the exhaustion log line only - a binding key or `<function fn.name>`. */\n description: string;\n maxAttempts: number;\n baseDelayMs: number;\n}\n\n/** In-process, fire-and-forget domain event bus. `TPayloadMap` keys the event names, so a wrong name\n * or payload shape is a compile error. Delivery is always async. Retry timing is a property of the\n * handler's own failure mode, not of the event, so `register` may tune it per registration. But\n * nobody awaits a fire-and-forget dispatch, so an unbounded window would let one event hold a\n * handler - and whatever it holds open, e.g. a database connection - for an unbounded time with no\n * one to report it. What the bus guarantees instead: a bounded MAXIMUM time a single dispatch can\n * occupy, enforced as a hard ceiling at `register()` - see `EventDispatchRetry`. Retry makes\n * delivery at-least-once: handlers must be idempotent, see `IEventHandler`. */\nexport class EventBus<TPayloadMap extends object> extends BaseHelper {\n private readonly container: Container;\n\n /** `register` appends, never replaces - two handlers may share an event name, and replacing would\n * drop the first with no way for the caller to notice. */\n private readonly registrationsByName: Map<string, IResolvedEventRegistration[]>;\n\n constructor(opts: { scope?: string; container: Container }) {\n super({ scope: opts.scope ?? EventBus.name });\n this.container = opts.container;\n this.registrationsByName = new Map();\n }\n\n /** The pre-jitter total of every inter-attempt delay `maxAttempts`/`baseDelayMs` would produce -\n * jitter (always on, see `dispatch`) only ever shrinks a delay, so this is a true upper bound. */\n private static computeTotalWindowMs(opts: { maxAttempts: number; baseDelayMs: number }): number {\n const { maxAttempts, baseDelayMs } = opts;\n let totalWindowMs = 0;\n\n for (let attempt = 1; attempt < maxAttempts; attempt++) {\n totalWindowMs += RetryHelper.computeBackoffDelayMs({\n attempt,\n backoff: {\n strategy: RetryBackoffStrategies.EXPONENTIAL,\n initialDelayMs: baseDelayMs,\n jitter: RetryJitterModes.NONE,\n },\n });\n }\n\n return totalWindowMs;\n }\n\n /** Loud rejection, never a silent clamp: a caller who believes a number the bus does not honour is\n * worse off than one who sees the ceiling at boot. */\n private static assertValidRetry(opts: {\n name: string;\n maxAttempts: number;\n baseDelayMs: number;\n }): void {\n const { name, maxAttempts, baseDelayMs } = opts;\n\n if (!Number.isInteger(maxAttempts) || maxAttempts < 1) {\n throw getError({\n message: `[EventBus][register] retry.maxAttempts must be a positive integer | name: ${name} | Got: ${maxAttempts}`,\n });\n }\n\n if (!Number.isInteger(baseDelayMs) || baseDelayMs < 1) {\n throw getError({\n message: `[EventBus][register] retry.baseDelayMs must be a positive integer | name: ${name} | Got: ${baseDelayMs}`,\n });\n }\n\n if (maxAttempts > EventDispatchRetry.MAX_ATTEMPTS_CEILING) {\n throw getError({\n message: `[EventBus][register] retry.maxAttempts exceeds the ceiling | name: ${name} | Got: ${maxAttempts} | Ceiling: ${EventDispatchRetry.MAX_ATTEMPTS_CEILING} | Lower retry.maxAttempts`,\n });\n }\n\n const totalWindowMs = EventBus.computeTotalWindowMs({ maxAttempts, baseDelayMs });\n\n if (totalWindowMs > EventDispatchRetry.MAX_TOTAL_WINDOW_MS) {\n throw getError({\n message: `[EventBus][register] retry window exceeds the ceiling | name: ${name} | Got: ${totalWindowMs}ms | Ceiling: ${EventDispatchRetry.MAX_TOTAL_WINDOW_MS}ms | Lower retry.maxAttempts or retry.baseDelayMs`,\n });\n }\n }\n\n /**\n * Turns `handler` into a uniform invoker plus a description for the exhaustion log line.\n * `BINDING_KEY` resolves through the container INSIDE the returned closure, so every call re-reads\n * the current binding; `FUNCTION` calls `fn` directly, so the closure IS the resolution - there is\n * nothing left to re-read on a later attempt. The tag (`handler.type`) is what this switches on,\n * not which field happens to be present - see `EventHandlerTypes`' doc.\n */\n private static buildHandlerInvoker(opts: {\n container: Container;\n handler: TEventHandlerReference<AnyType>;\n name: string;\n }): { invokeHandler: TEventHandlerInvoker; description: string } {\n const { container, handler, name } = opts;\n\n if (ObjectUtility.isEmpty({ value: handler })) {\n throw getError({\n message: `[EventBus][register] Invalid handler | name: ${name} | Got: ${handler}`,\n });\n }\n\n switch (handler.type) {\n case EventHandlerTypes.BINDING_KEY: {\n const { key } = handler;\n\n if (ObjectUtility.isEmpty({ value: key })) {\n throw getError({\n message: `[EventBus][register] Invalid handler.key | name: ${name} | Got: ${key}`,\n });\n }\n\n return {\n invokeHandler: ({ event }) => container.get<IEventHandler>({ key }).handle({ event }),\n description: `binding-key:${key}`,\n };\n }\n\n case EventHandlerTypes.FUNCTION: {\n const { fn } = handler;\n\n if (typeof fn !== 'function') {\n throw getError({\n message: `[EventBus][register] Invalid handler.fn | name: ${name} | Expected a function | Got: ${typeof fn}`,\n });\n }\n\n return {\n invokeHandler: ({ event }) => fn({ event }),\n description: `function:${fn.name || 'anonymous'}`,\n };\n }\n\n default: {\n throw getError({\n message: `[EventBus][register] Unknown handler.type | name: ${name} | Expected one of: ${[...EventHandlerTypes.SCHEME_SET].join(', ')} | Got: ${(handler as { type?: unknown }).type}`,\n });\n }\n }\n }\n\n /**\n * `retry` is optional and per REGISTRATION, not per publish: the right window belongs to the\n * handler's own failure mode, and two handlers on the same event name may each pick their own.\n * Omitting it reproduces today's `EventDispatchRetry` defaults exactly. Both `maxAttempts` and the\n * total backoff window it implies are bounded - see `EventDispatchRetry` - and exceeding either\n * throws here, at boot where a human sees it, rather than being silently clamped at dispatch time.\n */\n register<K extends keyof TPayloadMap & string>(opts: {\n name: K;\n /** A `BINDING_KEY` reference re-resolves through the container on every retry attempt, so a\n * rebind reaches a dispatch already in flight. A `FUNCTION` reference is captured as-is: a\n * rebind has nothing to reach, and every attempt in a long retry window calls the exact `fn`\n * registered here. */\n handler: TEventHandlerReference<TPayloadMap[K]>;\n retry?: IEventHandlerRetryOptions;\n }): void {\n const { name, handler, retry } = opts;\n\n if (ObjectUtility.isEmpty({ value: name })) {\n throw getError({\n message: `[EventBus][register] Invalid registration | name: ${String(name)}`,\n });\n }\n\n const maxAttempts = retry?.maxAttempts ?? EventDispatchRetry.MAX_ATTEMPTS;\n const baseDelayMs = retry?.baseDelayMs ?? EventDispatchRetry.BASE_DELAY_MS;\n EventBus.assertValidRetry({ name, maxAttempts, baseDelayMs });\n\n const { invokeHandler, description } = EventBus.buildHandlerInvoker({\n container: this.container,\n handler,\n name,\n });\n\n const registration: IResolvedEventRegistration = {\n invokeHandler,\n description,\n maxAttempts,\n baseDelayMs,\n };\n\n const existing = this.registrationsByName.get(name);\n\n if (existing) {\n existing.push(registration);\n\n return;\n }\n\n this.registrationsByName.set(name, [registration]);\n }\n\n /**\n * Never blocks and never throws back to the caller: dispatch runs outside this call's flow via\n * `queueMicrotask`, and a handler failure is caught and logged where it happens (`dispatch`),\n * never here.\n */\n publish<K extends keyof TPayloadMap & string>(opts: {\n name: K;\n payload: TPayloadMap[K];\n traceId?: string;\n }): void {\n const { name, payload, traceId } = opts;\n\n const event: IDomainEvent<TPayloadMap[K]> = {\n name,\n payload,\n occurredAt: new Date().toISOString(),\n traceId,\n };\n\n const registrations = this.registrationsByName.get(name);\n\n if (!registrations?.length) {\n // A typo is already a compile error, so at runtime this only means nobody is listening yet -\n // a legitimate state on a fire-and-forget bus, not an incident.\n this.logger.debug('[publish] No handler registered | name: %s | traceId: %s', name, traceId);\n\n return;\n }\n\n for (const registration of registrations) {\n queueMicrotask(() => {\n // `dispatch` catches every failure path itself and never rejects - this `.catch` is an\n // unreachable backstop, kept (and logged) rather than left floating, for the day it isn't.\n this.dispatch({ event, registration }).catch((error: unknown) => {\n this.logger.error(\n '[publish] Unexpected dispatch failure | name: %s | Error: %s',\n event.name,\n error,\n );\n });\n });\n }\n }\n\n /**\n * Attempts/backoff come from the registration (`EventDispatchRetry`'s defaults when omitted),\n * always with full jitter - `RetryJitterModes.FULL` decorrelates a shared-resource pile-up hardest,\n * so many handlers retrying the same lock do not collide on the same instant a second and third\n * time. `invokeHandler` already encodes whether that re-resolves (`BINDING_KEY`) or was captured\n * once (`FUNCTION`) - see `buildHandlerInvoker` - so this method calls it uniformly. A handler that\n * throws synchronously is caught exactly like one that returns a rejected promise: `execution`\n * here is itself `async`, and JS converts a synchronous throw inside an async function body into a\n * rejection of that function's own promise - `RetryHelper.executeWithRetry`'s attempt loop never\n * sees the difference.\n *\n * `RetryHelper.executeWithRetry` is used without its own `logger` - its internal per-attempt/exhaustion\n * logging knows nothing about the event name or `traceId`, so it cannot be the trace anyone\n * relies on. The one line below, logged only on final failure, is.\n */\n private async dispatch(opts: {\n event: IDomainEvent<unknown>;\n registration: IResolvedEventRegistration;\n }): Promise<void> {\n const { event, registration } = opts;\n const { invokeHandler, description, maxAttempts, baseDelayMs } = registration;\n let lastAttempt = 0;\n\n try {\n await RetryHelper.executeWithRetry({\n operation: `EventBus.dispatch:${event.name}`,\n maxAttempts,\n backoff: {\n strategy: RetryBackoffStrategies.EXPONENTIAL,\n initialDelayMs: baseDelayMs,\n jitter: RetryJitterModes.FULL,\n },\n execution: async ({ attempt }) => {\n lastAttempt = attempt;\n await invokeHandler({ event });\n },\n });\n } catch (error) {\n // The only trace this failure leaves: it is caught here and never reaches the publisher, so\n // the event name, traceId and attempt count all have to be on this one line.\n this.logger.error(\n '[dispatch] Handler exhausted retries | name: %s | traceId: %s | attempts: %d | handler: %s | Error: %s',\n event.name,\n event.traceId,\n lastAttempt,\n description,\n error,\n );\n }\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"event-bus.js","sourceRoot":"","sources":["../../../../src/base/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AAO,EAAE,EAAE,EAAE;oBAC/B,WAAW,GAAG,OAAO,CAAC;oBACtB,MAAM,aAAa,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC;gBACjC,CAAC;aACF,CAAC,CAAC;QACL,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,4FAA4F;YAC5F,6EAA6E;YAC7E,IAAI,CAAC,MAAM,CAAC,KAAK,CACf,wGAAwG,EACxG,KAAK,CAAC,IAAI,EACV,KAAK,CAAC,OAAO,EACb,WAAW,EACX,WAAW,EACX,KAAK,CACN,CAAC;QACJ,CAAC;IACH,CAAC;CACF","sourcesContent":["import { ObjectUtility } from '@venizia/ignis-helpers/common';\nimport type { Container } from '@/helpers/inversion/container';\nimport type { ValueOrPromise } from '@venizia/ignis-helpers/common';\nimport {\n BaseHelper,\n getError,\n RetryBackoffStrategies,\n RetryHelper,\n RetryJitterModes,\n} from '@venizia/ignis-helpers/core';\nimport { EventDispatchRetry, EventHandlerTypes } from './common/constants';\nimport type {\n IDomainEvent,\n IEventHandler,\n IEventHandlerRetryOptions,\n TEventHandlerReference,\n} from './common/types';\n\n/** One `register`ed handler, resolved to concrete retry numbers and a ready-to-call invoker -\n * `EventDispatchRetry`'s defaults already applied and `handler`'s shape already resolved, so\n * `dispatch` never has to branch on either. */\ninterface IResolvedEventRegistration {\n // A method signature on purpose: its parameter is bivariant, so a registration holds the invoker of any payload type, which the registry cannot tell apart.\n invokeHandler(opts: { event: IDomainEvent<unknown> }): ValueOrPromise<void>;\n /** For the exhaustion log line only - a binding key or `<function fn.name>`. */\n description: string;\n maxAttempts: number;\n baseDelayMs: number;\n}\n\n/** In-process, fire-and-forget domain event bus. `TPayloadMap` keys the event names, so a wrong name\n * or payload shape is a compile error. Delivery is always async. Retry timing is a property of the\n * handler's own failure mode, not of the event, so `register` may tune it per registration. But\n * nobody awaits a fire-and-forget dispatch, so an unbounded window would let one event hold a\n * handler - and whatever it holds open, e.g. a database connection - for an unbounded time with no\n * one to report it. What the bus guarantees instead: a bounded MAXIMUM time a single dispatch can\n * occupy, enforced as a hard ceiling at `register()` - see `EventDispatchRetry`. Retry makes\n * delivery at-least-once: handlers must be idempotent, see `IEventHandler`. */\nexport class EventBus<TPayloadMap extends object> extends BaseHelper {\n private readonly container: Container;\n\n /** `register` appends, never replaces - two handlers may share an event name, and replacing would\n * drop the first with no way for the caller to notice. */\n private readonly registrationsByName: Map<string, IResolvedEventRegistration[]>;\n\n constructor(opts: { scope?: string; container: Container }) {\n super({ scope: opts.scope ?? EventBus.name });\n this.container = opts.container;\n this.registrationsByName = new Map();\n }\n\n /** The pre-jitter total of every inter-attempt delay `maxAttempts`/`baseDelayMs` would produce -\n * jitter (always on, see `dispatch`) only ever shrinks a delay, so this is a true upper bound. */\n private static computeTotalWindowMs(opts: { maxAttempts: number; baseDelayMs: number }): number {\n const { maxAttempts, baseDelayMs } = opts;\n let totalWindowMs = 0;\n\n for (let attempt = 1; attempt < maxAttempts; attempt++) {\n totalWindowMs += RetryHelper.computeBackoffDelayMs({\n attempt,\n backoff: {\n strategy: RetryBackoffStrategies.EXPONENTIAL,\n initialDelayMs: baseDelayMs,\n jitter: RetryJitterModes.NONE,\n },\n });\n }\n\n return totalWindowMs;\n }\n\n /** Loud rejection, never a silent clamp: a caller who believes a number the bus does not honour is\n * worse off than one who sees the ceiling at boot. */\n private static assertValidRetry(opts: {\n name: string;\n maxAttempts: number;\n baseDelayMs: number;\n }): void {\n const { name, maxAttempts, baseDelayMs } = opts;\n\n if (!Number.isInteger(maxAttempts) || maxAttempts < 1) {\n throw getError({\n message: `[EventBus][register] retry.maxAttempts must be a positive integer | name: ${name} | Got: ${maxAttempts}`,\n });\n }\n\n if (!Number.isInteger(baseDelayMs) || baseDelayMs < 1) {\n throw getError({\n message: `[EventBus][register] retry.baseDelayMs must be a positive integer | name: ${name} | Got: ${baseDelayMs}`,\n });\n }\n\n if (maxAttempts > EventDispatchRetry.MAX_ATTEMPTS_CEILING) {\n throw getError({\n message: `[EventBus][register] retry.maxAttempts exceeds the ceiling | name: ${name} | Got: ${maxAttempts} | Ceiling: ${EventDispatchRetry.MAX_ATTEMPTS_CEILING} | Lower retry.maxAttempts`,\n });\n }\n\n const totalWindowMs = EventBus.computeTotalWindowMs({ maxAttempts, baseDelayMs });\n\n if (totalWindowMs > EventDispatchRetry.MAX_TOTAL_WINDOW_MS) {\n throw getError({\n message: `[EventBus][register] retry window exceeds the ceiling | name: ${name} | Got: ${totalWindowMs}ms | Ceiling: ${EventDispatchRetry.MAX_TOTAL_WINDOW_MS}ms | Lower retry.maxAttempts or retry.baseDelayMs`,\n });\n }\n }\n\n /**\n * Turns `handler` into a uniform invoker plus a description for the exhaustion log line.\n * `BINDING_KEY` resolves through the container INSIDE the returned closure, so every call re-reads\n * the current binding; `FUNCTION` calls `fn` directly, so the closure IS the resolution - there is\n * nothing left to re-read on a later attempt. The tag (`handler.type`) is what this switches on,\n * not which field happens to be present - see `EventHandlerTypes`' doc.\n */\n private static buildHandlerInvoker<TPayload>(opts: {\n container: Container;\n handler: TEventHandlerReference<TPayload>;\n name: string;\n }): {\n invokeHandler: (opts: { event: IDomainEvent<TPayload> }) => ValueOrPromise<void>;\n description: string;\n } {\n const { container, handler, name } = opts;\n\n if (ObjectUtility.isEmpty({ value: handler })) {\n throw getError({\n message: `[EventBus][register] Invalid handler | name: ${name} | Got: ${handler}`,\n });\n }\n\n switch (handler.type) {\n case EventHandlerTypes.BINDING_KEY: {\n const { key } = handler;\n\n if (ObjectUtility.isEmpty({ value: key })) {\n throw getError({\n message: `[EventBus][register] Invalid handler.key | name: ${name} | Got: ${key}`,\n });\n }\n\n return {\n invokeHandler: ({ event }) => container.get<IEventHandler>({ key }).handle({ event }),\n description: `binding-key:${key}`,\n };\n }\n\n case EventHandlerTypes.FUNCTION: {\n const { fn } = handler;\n\n if (typeof fn !== 'function') {\n throw getError({\n message: `[EventBus][register] Invalid handler.fn | name: ${name} | Expected a function | Got: ${typeof fn}`,\n });\n }\n\n return {\n invokeHandler: ({ event }) => fn({ event }),\n description: `function:${fn.name || 'anonymous'}`,\n };\n }\n\n default: {\n throw getError({\n message: `[EventBus][register] Unknown handler.type | name: ${name} | Expected one of: ${[...EventHandlerTypes.SCHEME_SET].join(', ')} | Got: ${(handler as { type?: unknown }).type}`,\n });\n }\n }\n }\n\n /**\n * `retry` is optional and per REGISTRATION, not per publish: the right window belongs to the\n * handler's own failure mode, and two handlers on the same event name may each pick their own.\n * Omitting it reproduces today's `EventDispatchRetry` defaults exactly. Both `maxAttempts` and the\n * total backoff window it implies are bounded - see `EventDispatchRetry` - and exceeding either\n * throws here, at boot where a human sees it, rather than being silently clamped at dispatch time.\n */\n register<K extends keyof TPayloadMap & string>(opts: {\n name: K;\n /** A `BINDING_KEY` reference re-resolves through the container on every retry attempt, so a\n * rebind reaches a dispatch already in flight. A `FUNCTION` reference is captured as-is: a\n * rebind has nothing to reach, and every attempt in a long retry window calls the exact `fn`\n * registered here. */\n handler: TEventHandlerReference<TPayloadMap[K]>;\n retry?: IEventHandlerRetryOptions;\n }): void {\n const { name, handler, retry } = opts;\n\n if (ObjectUtility.isEmpty({ value: name })) {\n throw getError({\n message: `[EventBus][register] Invalid registration | name: ${String(name)}`,\n });\n }\n\n const maxAttempts = retry?.maxAttempts ?? EventDispatchRetry.MAX_ATTEMPTS;\n const baseDelayMs = retry?.baseDelayMs ?? EventDispatchRetry.BASE_DELAY_MS;\n EventBus.assertValidRetry({ name, maxAttempts, baseDelayMs });\n\n const { invokeHandler, description } = EventBus.buildHandlerInvoker({\n container: this.container,\n handler,\n name,\n });\n\n const registration: IResolvedEventRegistration = {\n invokeHandler,\n description,\n maxAttempts,\n baseDelayMs,\n };\n\n const existing = this.registrationsByName.get(name);\n\n if (existing) {\n existing.push(registration);\n\n return;\n }\n\n this.registrationsByName.set(name, [registration]);\n }\n\n /**\n * Never blocks and never throws back to the caller: dispatch runs outside this call's flow via\n * `queueMicrotask`, and a handler failure is caught and logged where it happens (`dispatch`),\n * never here.\n */\n publish<K extends keyof TPayloadMap & string>(opts: {\n name: K;\n payload: TPayloadMap[K];\n traceId?: string;\n }): void {\n const { name, payload, traceId } = opts;\n\n const event: IDomainEvent<TPayloadMap[K]> = {\n name,\n payload,\n occurredAt: new Date().toISOString(),\n traceId,\n };\n\n const registrations = this.registrationsByName.get(name);\n\n if (!registrations?.length) {\n // A typo is already a compile error, so at runtime this only means nobody is listening yet -\n // a legitimate state on a fire-and-forget bus, not an incident.\n this.logger.debug('[publish] No handler registered | name: %s | traceId: %s', name, traceId);\n\n return;\n }\n\n for (const registration of registrations) {\n queueMicrotask(() => {\n // `dispatch` catches every failure path itself and never rejects - this `.catch` is an\n // unreachable backstop, kept (and logged) rather than left floating, for the day it isn't.\n this.dispatch({ event, registration }).catch((error: unknown) => {\n this.logger.error(\n '[publish] Unexpected dispatch failure | name: %s | Error: %s',\n event.name,\n error,\n );\n });\n });\n }\n }\n\n /**\n * Attempts/backoff come from the registration (`EventDispatchRetry`'s defaults when omitted),\n * always with full jitter - `RetryJitterModes.FULL` decorrelates a shared-resource pile-up hardest,\n * so many handlers retrying the same lock do not collide on the same instant a second and third\n * time. `invokeHandler` already encodes whether that re-resolves (`BINDING_KEY`) or was captured\n * once (`FUNCTION`) - see `buildHandlerInvoker` - so this method calls it uniformly. A handler that\n * throws synchronously is caught exactly like one that returns a rejected promise: `execution`\n * here is itself `async`, and JS converts a synchronous throw inside an async function body into a\n * rejection of that function's own promise - `RetryHelper.executeWithRetry`'s attempt loop never\n * sees the difference.\n *\n * `RetryHelper.executeWithRetry` is used without its own `logger` - its internal per-attempt/exhaustion\n * logging knows nothing about the event name or `traceId`, so it cannot be the trace anyone\n * relies on. The one line below, logged only on final failure, is.\n */\n private async dispatch(opts: {\n event: IDomainEvent<unknown>;\n registration: IResolvedEventRegistration;\n }): Promise<void> {\n const { event, registration } = opts;\n const { invokeHandler, description, maxAttempts, baseDelayMs } = registration;\n let lastAttempt = 0;\n\n try {\n await RetryHelper.executeWithRetry({\n operation: `EventBus.dispatch:${event.name}`,\n maxAttempts,\n backoff: {\n strategy: RetryBackoffStrategies.EXPONENTIAL,\n initialDelayMs: baseDelayMs,\n jitter: RetryJitterModes.FULL,\n },\n execution: async ({ attempt }) => {\n lastAttempt = attempt;\n await invokeHandler({ event });\n },\n });\n } catch (error) {\n // The only trace this failure leaves: it is caught here and never reaches the publisher, so\n // the event name, traceId and attempt count all have to be on this one line.\n this.logger.error(\n '[dispatch] Handler exhausted retries | name: %s | traceId: %s | attempts: %d | handler: %s | Error: %s',\n event.name,\n event.traceId,\n lastAttempt,\n description,\n error,\n );\n }\n }\n}\n"]}
|
|
@@ -11,6 +11,6 @@ export type TInjectOptions = TWithoutRegistry<TCoreInjectOptions>;
|
|
|
11
11
|
* `MetadataRegistry.getInstance()` (`helpers/inversion/container.ts`), while inversion's own
|
|
12
12
|
* `inject` writes to its module-level registry - metadata written there is never read back.
|
|
13
13
|
*/
|
|
14
|
-
export declare const inject: (opts: TInjectOptions) => (target:
|
|
14
|
+
export declare const inject: (opts: TInjectOptions) => (target: object, propertyName: string | symbol | undefined, parameterIndex?: number) => void;
|
|
15
15
|
export {};
|
|
16
16
|
//# sourceMappingURL=injectors.d.ts.map
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { IDataSourceMetadata } from '../../../helpers/inversion/index.js';
|
|
2
|
+
/**
|
|
3
|
+
* Registers a datasource with driver and auto-discovery settings.
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* ```typescript
|
|
7
|
+
* import { datasource } from '@venizia/ignis';
|
|
8
|
+
* import { BasePostgresDataSource } from '@venizia/ignis-connectors/postgres';
|
|
9
|
+
* import { NodePostgresDriver } from '@venizia/ignis-connectors/postgres/node-postgres';
|
|
10
|
+
* import { Pool } from 'pg';
|
|
11
|
+
*
|
|
12
|
+
* export @datasource({ driver: NodePostgresDriver })
|
|
13
|
+
* class AppDataSource extends BasePostgresDataSource<{ connectionString: string }> {
|
|
14
|
+
* constructor() { super({ name: AppDataSource.name, config: { connectionString: 'postgres://localhost/app' } }); }
|
|
15
|
+
* override configure(): void { this.client = new Pool(this.settings); }
|
|
16
|
+
* override getConnectionString(): string { return this.settings.connectionString; }
|
|
17
|
+
* }
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
export declare const datasource: (metadata?: IDataSourceMetadata) => ClassDecorator;
|
|
21
|
+
//# sourceMappingURL=datasource.d.ts.map
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { ArtifactTypes, MetadataRegistry } from '../../../helpers/inversion/index.js';
|
|
2
|
+
import { getError } from '@venizia/ignis-helpers/core';
|
|
3
|
+
import { DataSourceOpenModes } from '../../datasources/index.js';
|
|
4
|
+
import { injectable, InjectableUtility } from '../injectable.js';
|
|
5
|
+
/**
|
|
6
|
+
* Registers a datasource with driver and auto-discovery settings.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```typescript
|
|
10
|
+
* import { datasource } from '@venizia/ignis';
|
|
11
|
+
* import { BasePostgresDataSource } from '@venizia/ignis-connectors/postgres';
|
|
12
|
+
* import { NodePostgresDriver } from '@venizia/ignis-connectors/postgres/node-postgres';
|
|
13
|
+
* import { Pool } from 'pg';
|
|
14
|
+
*
|
|
15
|
+
* export @datasource({ driver: NodePostgresDriver })
|
|
16
|
+
* class AppDataSource extends BasePostgresDataSource<{ connectionString: string }> {
|
|
17
|
+
* constructor() { super({ name: AppDataSource.name, config: { connectionString: 'postgres://localhost/app' } }); }
|
|
18
|
+
* override configure(): void { this.client = new Pool(this.settings); }
|
|
19
|
+
* override getConnectionString(): string { return this.settings.connectionString; }
|
|
20
|
+
* }
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
export const datasource = (metadata) => {
|
|
24
|
+
return (target) => {
|
|
25
|
+
const openTimeout = metadata?.open?.timeoutMs;
|
|
26
|
+
if (openTimeout !== undefined &&
|
|
27
|
+
(typeof openTimeout !== 'number' || !Number.isInteger(openTimeout) || openTimeout < 0)) {
|
|
28
|
+
throw getError({
|
|
29
|
+
message: `[datasource][@datasource][${target.name}] Invalid metadata | 'open.timeoutMs' must be a non-negative integer (ms; 0 waits for ever) | Got: ${String(openTimeout)}`,
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
const openMode = metadata?.open?.on;
|
|
33
|
+
// Untyped JS callers: a misspelt mode would silently mean "start", so it is refused where it is written.
|
|
34
|
+
if (openMode !== undefined && !DataSourceOpenModes.isValid(openMode)) {
|
|
35
|
+
throw getError({
|
|
36
|
+
message: `[datasource][@datasource][${target.name}] Invalid metadata | Unknown 'open.on': ${String(openMode)} | Expected one of: ${[...DataSourceOpenModes.SCHEME_SET].join(', ')}`,
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
injectable({
|
|
40
|
+
type: ArtifactTypes.DATASOURCE,
|
|
41
|
+
...InjectableUtility.pickRegistrationOptions({ metadata: metadata ?? {} }),
|
|
42
|
+
})(target);
|
|
43
|
+
MetadataRegistry.getInstance().setDataSourceMetadata({ target, metadata });
|
|
44
|
+
};
|
|
45
|
+
};
|
|
46
|
+
//# sourceMappingURL=datasource.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"datasource.js","sourceRoot":"","sources":["../../../../../src/base/metadata/persistents/datasource.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAEtE,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AACvD,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AACxD,OAAO,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAE9D;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,QAA8B,EAAkB,EAAE;IAC3E,OAAO,CAAC,MAAM,EAAE,EAAE;QAChB,MAAM,WAAW,GAAG,QAAQ,EAAE,IAAI,EAAE,SAAS,CAAC;QAE9C,IACE,WAAW,KAAK,SAAS;YACzB,CAAC,OAAO,WAAW,KAAK,QAAQ,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,WAAW,CAAC,IAAI,WAAW,GAAG,CAAC,CAAC,EACtF,CAAC;YACD,MAAM,QAAQ,CAAC;gBACb,OAAO,EAAE,6BAA6B,MAAM,CAAC,IAAI,sGAAsG,MAAM,CAAC,WAAW,CAAC,EAAE;aAC7K,CAAC,CAAC;QACL,CAAC;QAED,MAAM,QAAQ,GAAG,QAAQ,EAAE,IAAI,EAAE,EAAE,CAAC;QAEpC,yGAAyG;QACzG,IAAI,QAAQ,KAAK,SAAS,IAAI,CAAC,mBAAmB,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAC;YACrE,MAAM,QAAQ,CAAC;gBACb,OAAO,EAAE,6BAA6B,MAAM,CAAC,IAAI,2CAA2C,MAAM,CAAC,QAAQ,CAAC,uBAAuB,CAAC,GAAG,mBAAmB,CAAC,UAAU,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE;aACpL,CAAC,CAAC;QACL,CAAC;QAED,UAAU,CAAC;YACT,IAAI,EAAE,aAAa,CAAC,UAAU;YAC9B,GAAG,iBAAiB,CAAC,uBAAuB,CAAC,EAAE,QAAQ,EAAE,QAAQ,IAAI,EAAE,EAAE,CAAC;SAC3E,CAAC,CAAC,MAAM,CAAC,CAAC;QACX,gBAAgB,CAAC,WAAW,EAAE,CAAC,qBAAqB,CAAC,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,CAAC;IAC7E,CAAC,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import { ArtifactTypes, MetadataRegistry } from '@/helpers/inversion';\nimport type { IDataSourceMetadata } from '@/helpers/inversion';\nimport { getError } from '@venizia/ignis-helpers/core';\nimport { DataSourceOpenModes } from '../../datasources';\nimport { injectable, InjectableUtility } from '../injectable';\n\n/**\n * Registers a datasource with driver and auto-discovery settings.\n *\n * @example\n * ```typescript\n * import { datasource } from '@venizia/ignis';\n * import { BasePostgresDataSource } from '@venizia/ignis-connectors/postgres';\n * import { NodePostgresDriver } from '@venizia/ignis-connectors/postgres/node-postgres';\n * import { Pool } from 'pg';\n *\n * export @datasource({ driver: NodePostgresDriver })\n * class AppDataSource extends BasePostgresDataSource<{ connectionString: string }> {\n * constructor() { super({ name: AppDataSource.name, config: { connectionString: 'postgres://localhost/app' } }); }\n * override configure(): void { this.client = new Pool(this.settings); }\n * override getConnectionString(): string { return this.settings.connectionString; }\n * }\n * ```\n */\nexport const datasource = (metadata?: IDataSourceMetadata): ClassDecorator => {\n return (target) => {\n const openTimeout = metadata?.open?.timeoutMs;\n\n if (\n openTimeout !== undefined &&\n (typeof openTimeout !== 'number' || !Number.isInteger(openTimeout) || openTimeout < 0)\n ) {\n throw getError({\n message: `[datasource][@datasource][${target.name}] Invalid metadata | 'open.timeoutMs' must be a non-negative integer (ms; 0 waits for ever) | Got: ${String(openTimeout)}`,\n });\n }\n\n const openMode = metadata?.open?.on;\n\n // Untyped JS callers: a misspelt mode would silently mean \"start\", so it is refused where it is written.\n if (openMode !== undefined && !DataSourceOpenModes.isValid(openMode)) {\n throw getError({\n message: `[datasource][@datasource][${target.name}] Invalid metadata | Unknown 'open.on': ${String(openMode)} | Expected one of: ${[...DataSourceOpenModes.SCHEME_SET].join(', ')}`,\n });\n }\n\n injectable({\n type: ArtifactTypes.DATASOURCE,\n ...InjectableUtility.pickRegistrationOptions({ metadata: metadata ?? {} }),\n })(target);\n MetadataRegistry.getInstance().setDataSourceMetadata({ target, metadata });\n };\n};\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/base/metadata/persistents/index.ts"],"names":[],"mappings":"AAAA,OAAO,kBAAkB,CAAC;AAE1B,cAAc,cAAc,CAAC;AAC7B,cAAc,SAAS,CAAC;AACxB,cAAc,cAAc,CAAC","sourcesContent":["import 'reflect-metadata';\n\nexport * from './datasource';\nexport * from './model';\nexport * from './repository';\n"]}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { IModelMetadata } from '../../../helpers/inversion/index.js';
|
|
2
|
+
/**
|
|
3
|
+
* Registers a model class with its static schema and relations.
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* ```typescript
|
|
7
|
+
* import { model } from '@venizia/ignis';
|
|
8
|
+
* import { ModelFactory } from '@venizia/ignis-connectors/postgres';
|
|
9
|
+
* import { pgTable, serial, text } from 'drizzle-orm/pg-core';
|
|
10
|
+
*
|
|
11
|
+
* const noteTable = pgTable('Note', { id: serial('id').primaryKey(), body: text('body') });
|
|
12
|
+
*
|
|
13
|
+
* export @model({ settings: { query: { limit: { default: 20 } } } })
|
|
14
|
+
* class Note extends ModelFactory.defineEntity({ table: noteTable }) {}
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
17
|
+
export declare const model: (input?: IModelMetadata) => ClassDecorator;
|
|
18
|
+
//# sourceMappingURL=model.d.ts.map
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { ArtifactTypes, MetadataRegistry } from '../../../helpers/inversion/index.js';
|
|
2
|
+
import { getError } from '@venizia/ignis-helpers/core';
|
|
3
|
+
import { injectable, InjectableUtility } from '../injectable.js';
|
|
4
|
+
import { ModelMetadataUtility } from '../model-metadata.js';
|
|
5
|
+
/**
|
|
6
|
+
* Registers a model class with its static schema and relations.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```typescript
|
|
10
|
+
* import { model } from '@venizia/ignis';
|
|
11
|
+
* import { ModelFactory } from '@venizia/ignis-connectors/postgres';
|
|
12
|
+
* import { pgTable, serial, text } from 'drizzle-orm/pg-core';
|
|
13
|
+
*
|
|
14
|
+
* const noteTable = pgTable('Note', { id: serial('id').primaryKey(), body: text('body') });
|
|
15
|
+
*
|
|
16
|
+
* export @model({ settings: { query: { limit: { default: 20 } } } })
|
|
17
|
+
* class Note extends ModelFactory.defineEntity({ table: noteTable }) {}
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
export const model = (input = {}) => {
|
|
21
|
+
return (target) => {
|
|
22
|
+
injectable({
|
|
23
|
+
type: ArtifactTypes.MODEL,
|
|
24
|
+
...InjectableUtility.pickRegistrationOptions({ metadata: input }),
|
|
25
|
+
})(target);
|
|
26
|
+
const metadata = ModelMetadataUtility.normalizeModelMetadata({
|
|
27
|
+
model: target.name,
|
|
28
|
+
metadata: input,
|
|
29
|
+
});
|
|
30
|
+
const { settings } = metadata;
|
|
31
|
+
if (settings && Reflect.has(settings, 'hiddenProperties')) {
|
|
32
|
+
throw getError({
|
|
33
|
+
message: `[model][${target.name}] hiddenProperties was replaced by properties.hidden`,
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
const defaultLimit = settings?.query?.limit?.default;
|
|
37
|
+
if (defaultLimit !== undefined && (!Number.isInteger(defaultLimit) || defaultLimit <= 0)) {
|
|
38
|
+
throw getError({
|
|
39
|
+
message: `[model][${target.name}] Invalid 'query.limit.default' | Expected a positive integer | Got: ${defaultLimit}`,
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
// Validated at DECORATION time, like the default limit: a bad ceiling is a wiring mistake, and
|
|
43
|
+
// catching it at boot beats catching it on the one request that happens to reach the limit.
|
|
44
|
+
const maxLimit = settings?.query?.limit?.max;
|
|
45
|
+
if (maxLimit !== undefined && (!Number.isInteger(maxLimit) || maxLimit <= 0)) {
|
|
46
|
+
throw getError({
|
|
47
|
+
message: `[model][${target.name}] Invalid 'query.limit.max' | Expected a positive integer | Got: ${maxLimit}`,
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
// Auto-populate AUTHORIZATION_SUBJECT from authorize.principal if not already set
|
|
51
|
+
const principal = settings?.authorize?.principal;
|
|
52
|
+
if (principal && !Object.hasOwn(target, 'AUTHORIZATION_SUBJECT')) {
|
|
53
|
+
// Assigning to a read-only or getter-only inherited property, or on a non-extensible class, threw;
|
|
54
|
+
// `Reflect.set` only answers false, so keep the throw.
|
|
55
|
+
if (!Reflect.set(target, 'AUTHORIZATION_SUBJECT', principal)) {
|
|
56
|
+
throw getError({
|
|
57
|
+
message: `[model][${target.name}] Cannot set 'AUTHORIZATION_SUBJECT' | The class has a read-only or getter-only 'AUTHORIZATION_SUBJECT', or is not extensible`,
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
MetadataRegistry.getInstance().registerModel({ target, metadata });
|
|
62
|
+
};
|
|
63
|
+
};
|
|
64
|
+
//# sourceMappingURL=model.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"model.js","sourceRoot":"","sources":["../../../../../src/base/metadata/persistents/model.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAEtE,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AACvD,OAAO,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAC9D,OAAO,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAEzD;;;;;;;;;;;;;;GAcG;AACH,MAAM,CAAC,MAAM,KAAK,GAAG,CAAC,QAAwB,EAAE,EAAkB,EAAE;IAClE,OAAO,CAAC,MAAM,EAAE,EAAE;QAChB,UAAU,CAAC;YACT,IAAI,EAAE,aAAa,CAAC,KAAK;YACzB,GAAG,iBAAiB,CAAC,uBAAuB,CAAC,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC;SAClE,CAAC,CAAC,MAAM,CAAC,CAAC;QAEX,MAAM,QAAQ,GAAG,oBAAoB,CAAC,sBAAsB,CAAC;YAC3D,KAAK,EAAE,MAAM,CAAC,IAAI;YAClB,QAAQ,EAAE,KAAK;SAChB,CAAC,CAAC;QAEH,MAAM,EAAE,QAAQ,EAAE,GAAG,QAAQ,CAAC;QAE9B,IAAI,QAAQ,IAAI,OAAO,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C;QACH,CAAC;QAED,gBAAgB,CAAC,WAAW,EAAE,CAAC,aAAa,CAAC,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,CAAC;IACrE,CAAC,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import { ArtifactTypes, MetadataRegistry } from '@/helpers/inversion';\nimport type { IModelMetadata } from '@/helpers/inversion';\nimport { getError } from '@venizia/ignis-helpers/core';\nimport { injectable, InjectableUtility } from '../injectable';\nimport { ModelMetadataUtility } from '../model-metadata';\n\n/**\n * Registers a model class with its static schema and relations.\n *\n * @example\n * ```typescript\n * import { model } from '@venizia/ignis';\n * import { ModelFactory } from '@venizia/ignis-connectors/postgres';\n * import { pgTable, serial, text } from 'drizzle-orm/pg-core';\n *\n * const noteTable = pgTable('Note', { id: serial('id').primaryKey(), body: text('body') });\n *\n * export @model({ settings: { query: { limit: { default: 20 } } } })\n * class Note extends ModelFactory.defineEntity({ table: noteTable }) {}\n * ```\n */\nexport const model = (input: IModelMetadata = {}): ClassDecorator => {\n return (target) => {\n injectable({\n type: ArtifactTypes.MODEL,\n ...InjectableUtility.pickRegistrationOptions({ metadata: input }),\n })(target);\n\n const metadata = ModelMetadataUtility.normalizeModelMetadata({\n model: target.name,\n metadata: input,\n });\n\n const { settings } = metadata;\n\n if (settings && Reflect.has(settings, 'hiddenProperties')) {\n throw getError({\n message: `[model][${target.name}] hiddenProperties was replaced by properties.hidden`,\n });\n }\n\n const defaultLimit = settings?.query?.limit?.default;\n\n if (defaultLimit !== undefined && (!Number.isInteger(defaultLimit) || defaultLimit <= 0)) {\n throw getError({\n message: `[model][${target.name}] Invalid 'query.limit.default' | Expected a positive integer | Got: ${defaultLimit}`,\n });\n }\n\n // Validated at DECORATION time, like the default limit: a bad ceiling is a wiring mistake, and\n // catching it at boot beats catching it on the one request that happens to reach the limit.\n const maxLimit = settings?.query?.limit?.max;\n\n if (maxLimit !== undefined && (!Number.isInteger(maxLimit) || maxLimit <= 0)) {\n throw getError({\n message: `[model][${target.name}] Invalid 'query.limit.max' | Expected a positive integer | Got: ${maxLimit}`,\n });\n }\n\n // Auto-populate AUTHORIZATION_SUBJECT from authorize.principal if not already set\n const principal = settings?.authorize?.principal;\n\n if (principal && !Object.hasOwn(target, 'AUTHORIZATION_SUBJECT')) {\n // Assigning to a read-only or getter-only inherited property, or on a non-extensible class, threw;\n // `Reflect.set` only answers false, so keep the throw.\n if (!Reflect.set(target, 'AUTHORIZATION_SUBJECT', principal)) {\n throw getError({\n message: `[model][${target.name}] Cannot set 'AUTHORIZATION_SUBJECT' | The class has a read-only or getter-only 'AUTHORIZATION_SUBJECT', or is not extensible`,\n });\n }\n }\n\n MetadataRegistry.getInstance().registerModel({ target, metadata });\n };\n};\n"]}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { TRepositoryMetadata } from '../../../../helpers/inversion/index.js';
|
|
2
|
+
import type { IDataSource } from '../../../datasources/index.js';
|
|
3
|
+
import type { AbstractEntity } from '../../../models/index.js';
|
|
4
|
+
/**
|
|
5
|
+
* Class decorator that registers a repository and binds it to a model (or, for a remote repository, only a datasource). Called without arguments on a subclass it reuses the type, model and datasource of its nearest decorated parent; registration options are not inherited.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```typescript
|
|
9
|
+
* import { repository } from '@venizia/ignis';
|
|
10
|
+
* import { DefaultCRUDRepository } from '@venizia/ignis-connectors/postgres';
|
|
11
|
+
* import { AppDataSource } from './app.datasource';
|
|
12
|
+
* import { Note, noteTable } from './note.model';
|
|
13
|
+
*
|
|
14
|
+
* export @repository({ model: Note, dataSource: AppDataSource })
|
|
15
|
+
* class NoteRepository extends DefaultCRUDRepository<typeof noteTable> {}
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
export declare const repository: <Model extends AbstractEntity = AbstractEntity, DataSource extends IDataSource = IDataSource>(metadata?: TRepositoryMetadata<Model, DataSource>) => ClassDecorator;
|
|
19
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { MetadataRegistry } from '../../../../helpers/inversion/index.js';
|
|
2
|
+
import { applyRepositoryMetadata, inheritRepositoryMetadata } from './resolve.js';
|
|
3
|
+
/**
|
|
4
|
+
* Class decorator that registers a repository and binds it to a model (or, for a remote repository, only a datasource). Called without arguments on a subclass it reuses the type, model and datasource of its nearest decorated parent; registration options are not inherited.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```typescript
|
|
8
|
+
* import { repository } from '@venizia/ignis';
|
|
9
|
+
* import { DefaultCRUDRepository } from '@venizia/ignis-connectors/postgres';
|
|
10
|
+
* import { AppDataSource } from './app.datasource';
|
|
11
|
+
* import { Note, noteTable } from './note.model';
|
|
12
|
+
*
|
|
13
|
+
* export @repository({ model: Note, dataSource: AppDataSource })
|
|
14
|
+
* class NoteRepository extends DefaultCRUDRepository<typeof noteTable> {}
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
17
|
+
export const repository = (metadata) => {
|
|
18
|
+
return (target) => {
|
|
19
|
+
const registry = MetadataRegistry.getInstance();
|
|
20
|
+
if (!metadata) {
|
|
21
|
+
applyRepositoryMetadata({
|
|
22
|
+
metadata: inheritRepositoryMetadata({ target, registry }),
|
|
23
|
+
registration: {},
|
|
24
|
+
target,
|
|
25
|
+
registry,
|
|
26
|
+
});
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
applyRepositoryMetadata({ metadata, registration: metadata, target, registry });
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../src/base/metadata/persistents/repository/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAIvD,OAAO,EAAE,uBAAuB,EAAE,yBAAyB,EAAE,MAAM,WAAW,CAAC;AAE/E;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,CAIxB,QAAiD,EACjC,EAAE;IAClB,OAAO,CAAC,MAAM,EAAE,EAAE;QAChB,MAAM,QAAQ,GAAG,gBAAgB,CAAC,WAAW,EAAE,CAAC;QAEhD,IAAI,CAAC,QAAQ,EAAE,CAAC;YACd,uBAAuB,CAAC;gBACtB,QAAQ,EAAE,yBAAyB,CAAC,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC;gBACzD,YAAY,EAAE,EAAE;gBAChB,MAAM;gBACN,QAAQ;aACT,CAAC,CAAC;YAEH,OAAO;QACT,CAAC;QAED,uBAAuB,CAAC,EAAE,QAAQ,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,CAAC;IAClF,CAAC,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import { MetadataRegistry } from '@/helpers/inversion';\nimport type { TRepositoryMetadata } from '@/helpers/inversion';\nimport type { IDataSource } from '../../../datasources';\nimport type { AbstractEntity } from '../../../models';\nimport { applyRepositoryMetadata, inheritRepositoryMetadata } from './resolve';\n\n/**\n * Class decorator that registers a repository and binds it to a model (or, for a remote repository, only a datasource). Called without arguments on a subclass it reuses the type, model and datasource of its nearest decorated parent; registration options are not inherited.\n *\n * @example\n * ```typescript\n * import { repository } from '@venizia/ignis';\n * import { DefaultCRUDRepository } from '@venizia/ignis-connectors/postgres';\n * import { AppDataSource } from './app.datasource';\n * import { Note, noteTable } from './note.model';\n *\n * export @repository({ model: Note, dataSource: AppDataSource })\n * class NoteRepository extends DefaultCRUDRepository<typeof noteTable> {}\n * ```\n */\nexport const repository = <\n Model extends AbstractEntity = AbstractEntity,\n DataSource extends IDataSource = IDataSource,\n>(\n metadata?: TRepositoryMetadata<Model, DataSource>,\n): ClassDecorator => {\n return (target) => {\n const registry = MetadataRegistry.getInstance();\n\n if (!metadata) {\n applyRepositoryMetadata({\n metadata: inheritRepositoryMetadata({ target, registry }),\n registration: {},\n target,\n registry,\n });\n\n return;\n }\n\n applyRepositoryMetadata({ metadata, registration: metadata, target, registry });\n };\n};\n"]}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import 'reflect-metadata';
|
|
2
|
+
import type { TRepositoryMetadata } from '../../../../helpers/inversion/index.js';
|
|
3
|
+
import type { MetadataRegistry } from '../../../../helpers/inversion/index.js';
|
|
4
|
+
/**
|
|
5
|
+
* Auto-injects dataSource at constructor param[0] unless explicit @inject exists. A class is injected
|
|
6
|
+
* by the class itself, so the container reads the key its registration recorded: a pinned
|
|
7
|
+
* `binding` and a minified class name both resolve. Only a string reference is a key.
|
|
8
|
+
*/
|
|
9
|
+
export declare const registerDataSourceInjection: (opts: {
|
|
10
|
+
target: Function;
|
|
11
|
+
registry: MetadataRegistry;
|
|
12
|
+
dataSourceRef: TRepositoryMetadata["dataSource"];
|
|
13
|
+
resolvedDataSource: string | Function;
|
|
14
|
+
}) => void;
|
|
15
|
+
//# sourceMappingURL=injection.d.ts.map
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import 'reflect-metadata';
|
|
2
|
+
import { BindingNamespaces } from '../../../../common/bindings.js';
|
|
3
|
+
import { BindingKeys, MetadataKeys } from '../../../../helpers/inversion/index.js';
|
|
4
|
+
import { ResolverUtility } from '@venizia/ignis-helpers/common';
|
|
5
|
+
import { getError } from '@venizia/ignis-helpers/core';
|
|
6
|
+
import { isDataSourceClass } from '../../../datasources/index.js';
|
|
7
|
+
import { validateFirstConstructorParameter } from './validate.js';
|
|
8
|
+
/**
|
|
9
|
+
* Auto-injects dataSource at constructor param[0] unless explicit @inject exists. A class is injected
|
|
10
|
+
* by the class itself, so the container reads the key its registration recorded: a pinned
|
|
11
|
+
* `binding` and a minified class name both resolve. Only a string reference is a key.
|
|
12
|
+
*/
|
|
13
|
+
export const registerDataSourceInjection = (opts) => {
|
|
14
|
+
const { target, registry, dataSourceRef, resolvedDataSource } = opts;
|
|
15
|
+
// Own metadata only: `getInjectMetadata` walks the prototype chain, so a repository extending another @repository class would see the BASE's injection at param[0] and silently resolve the base's dataSource.
|
|
16
|
+
const ownInjects = Reflect.getOwnMetadata(MetadataKeys.INJECT, target);
|
|
17
|
+
const injectAtIndex0 = ownInjects?.find((entry) => entry?.index === 0);
|
|
18
|
+
if (injectAtIndex0) {
|
|
19
|
+
// `@inject({ target })` carries no key; read the one recorded on the class. The function form
|
|
20
|
+
// resolves through the same helper the container uses, so both paths read one class.
|
|
21
|
+
const injectedTarget = injectAtIndex0.target
|
|
22
|
+
? ResolverUtility.resolveInjectTarget({ target: injectAtIndex0.target })
|
|
23
|
+
: undefined;
|
|
24
|
+
const injectKey = injectAtIndex0.key ??
|
|
25
|
+
(injectedTarget ? registry.getBindingKey({ target: injectedTarget }) : undefined);
|
|
26
|
+
// A class is judged by its brand: its key may sit under any namespace a `binding` pinned, and
|
|
27
|
+
// a provisional key may still change at registration. Only a bare key is judged by its prefix.
|
|
28
|
+
const isDataSourceTarget = injectedTarget
|
|
29
|
+
? isDataSourceClass(injectedTarget)
|
|
30
|
+
: typeof injectKey === 'string' && injectKey.startsWith(`${BindingNamespaces.DATASOURCE}.`);
|
|
31
|
+
if (!isDataSourceTarget) {
|
|
32
|
+
throw getError({
|
|
33
|
+
message: `[@repository][${target.name}] Invalid constructor | First parameter must be a DataSource | Found @inject with key: '${String(injectKey)}' | Expected a key starting with '${BindingNamespaces.DATASOURCE}.' or a DataSource class`,
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
// Checked only when this decorator writes the injection: an explicit @inject decides for itself.
|
|
39
|
+
// An interface emits `Object` and a type-only class import emits `Function` under tsc (`Object`
|
|
40
|
+
// under bun); neither names the class, so neither is judged.
|
|
41
|
+
const firstParamType = Reflect.getMetadata('design:paramtypes', target)?.[0];
|
|
42
|
+
if (firstParamType && firstParamType !== Object && firstParamType !== Function) {
|
|
43
|
+
validateFirstConstructorParameter({ target, firstParamType, resolvedDataSource });
|
|
44
|
+
}
|
|
45
|
+
// The inherited list is the base repository's own, and setInjectMetadata may write straight into it.
|
|
46
|
+
if (!ownInjects) {
|
|
47
|
+
Reflect.defineMetadata(MetadataKeys.INJECT, [...(registry.getInjectMetadata({ target }) ?? [])], target);
|
|
48
|
+
}
|
|
49
|
+
const derivedKey = BindingKeys.build({
|
|
50
|
+
namespace: BindingNamespaces.DATASOURCE,
|
|
51
|
+
key: typeof resolvedDataSource === 'string' ? resolvedDataSource : resolvedDataSource.name,
|
|
52
|
+
});
|
|
53
|
+
// The class first, decided when the repository is resolved: by then any registration - decorated,
|
|
54
|
+
// `bindingList()`, or `dataSource(X, { binding })` - has recorded its key on the class. The derived
|
|
55
|
+
// key is the fallback for a class nothing recorded, bound by hand under exactly that key.
|
|
56
|
+
registry.setInjectMetadata({
|
|
57
|
+
target,
|
|
58
|
+
index: 0,
|
|
59
|
+
metadata: typeof dataSourceRef === 'string'
|
|
60
|
+
? { key: derivedKey, index: 0, isOptional: false }
|
|
61
|
+
: { target: dataSourceRef, key: derivedKey, index: 0, isOptional: false },
|
|
62
|
+
});
|
|
63
|
+
};
|
|
64
|
+
//# sourceMappingURL=injection.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"injection.js","sourceRoot":"","sources":["../../../../../../src/base/metadata/persistents/repository/injection.ts"],"names":[],"mappings":"AAAA,OAAO,kBAAkB,CAAC;AAE1B,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAEtD,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAEhE,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAEhE,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AACvD,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,EAAE,iCAAiC,EAAE,MAAM,YAAY,CAAC;AAE/D;;;;GAIG;AACH,MAAM,CAAC,MAAM,2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/helpers/inversion';\nimport { BindingKeys, MetadataKeys } from '@/helpers/inversion';\nimport type { MetadataRegistry } from '@/helpers/inversion';\nimport { ResolverUtility } from '@venizia/ignis-helpers/common';\nimport type { IInjectMetadata } from '@venizia/ignis-inversion';\nimport { getError } from '@venizia/ignis-helpers/core';\nimport { isDataSourceClass } from '../../../datasources';\nimport { validateFirstConstructorParameter } from './validate';\n\n/**\n * Auto-injects dataSource at constructor param[0] unless explicit @inject exists. A class is injected\n * by the class itself, so the container reads the key its registration recorded: a pinned\n * `binding` and a minified class name both resolve. Only a string reference is a key.\n */\nexport const registerDataSourceInjection = (opts: {\n target: Function;\n registry: MetadataRegistry;\n dataSourceRef: TRepositoryMetadata['dataSource'];\n resolvedDataSource: string | Function;\n}): void => {\n const { target, registry, dataSourceRef, resolvedDataSource } = opts;\n\n // Own metadata only: `getInjectMetadata` walks the prototype chain, so a repository extending another @repository class would see the BASE's injection at param[0] and silently resolve the base's dataSource.\n const ownInjects: IInjectMetadata[] | undefined = Reflect.getOwnMetadata(\n MetadataKeys.INJECT,\n target,\n );\n const injectAtIndex0 = ownInjects?.find((entry) => entry?.index === 0);\n\n if (injectAtIndex0) {\n // `@inject({ target })` carries no key; read the one recorded on the class. The function form\n // resolves through the same helper the container uses, so both paths read one class.\n const injectedTarget = injectAtIndex0.target\n ? ResolverUtility.resolveInjectTarget({ target: injectAtIndex0.target })\n : undefined;\n const injectKey =\n injectAtIndex0.key ??\n (injectedTarget ? registry.getBindingKey({ target: injectedTarget }) : undefined);\n\n // A class is judged by its brand: its key may sit under any namespace a `binding` pinned, and\n // a provisional key may still change at registration. Only a bare key is judged by its prefix.\n const isDataSourceTarget = injectedTarget\n ? isDataSourceClass(injectedTarget)\n : typeof injectKey === 'string' && injectKey.startsWith(`${BindingNamespaces.DATASOURCE}.`);\n\n if (!isDataSourceTarget) {\n throw getError({\n message: `[@repository][${target.name}] Invalid constructor | First parameter must be a DataSource | Found @inject with key: '${String(injectKey)}' | Expected a key starting with '${BindingNamespaces.DATASOURCE}.' or a DataSource class`,\n });\n }\n\n return;\n }\n\n // Checked only when this decorator writes the injection: an explicit @inject decides for itself.\n // An interface emits `Object` and a type-only class import emits `Function` under tsc (`Object`\n // under bun); neither names the class, so neither is judged.\n const firstParamType = Reflect.getMetadata('design:paramtypes', target)?.[0];\n\n if (firstParamType && firstParamType !== Object && firstParamType !== Function) {\n validateFirstConstructorParameter({ target, firstParamType, resolvedDataSource });\n }\n\n // The inherited list is the base repository's own, and setInjectMetadata may write straight into it.\n if (!ownInjects) {\n Reflect.defineMetadata(\n MetadataKeys.INJECT,\n [...(registry.getInjectMetadata({ target }) ?? [])],\n target,\n );\n }\n\n const derivedKey = BindingKeys.build({\n namespace: BindingNamespaces.DATASOURCE,\n key: typeof resolvedDataSource === 'string' ? resolvedDataSource : resolvedDataSource.name,\n });\n\n // The class first, decided when the repository is resolved: by then any registration - decorated,\n // `bindingList()`, or `dataSource(X, { binding })` - has recorded its key on the class. The derived\n // key is the fallback for a class nothing recorded, bound by hand under exactly that key.\n registry.setInjectMetadata({\n target,\n index: 0,\n metadata:\n typeof dataSourceRef === 'string'\n ? { key: derivedKey, index: 0, isOptional: false }\n : { target: dataSourceRef, key: derivedKey, index: 0, isOptional: false },\n });\n};\n"]}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { IArtifactRegistrationOptions, MetadataRegistry, TRepositoryMetadata } from '../../../../helpers/inversion/index.js';
|
|
2
|
+
import type { IDataSource } from '../../../datasources/index.js';
|
|
3
|
+
import type { AbstractEntity } from '../../../models/index.js';
|
|
4
|
+
/** A bare `@repository()` on a subclass reuses the type, model and datasource its nearest decorated parent declared; the registration options (`binding`, `when`, ...) are never inherited, so the subclass registers under its own name. */
|
|
5
|
+
export declare const inheritRepositoryMetadata: (opts: {
|
|
6
|
+
target: Function;
|
|
7
|
+
registry: MetadataRegistry;
|
|
8
|
+
}) => TRepositoryMetadata;
|
|
9
|
+
export declare const applyRepositoryMetadata: <Model extends AbstractEntity = AbstractEntity, DataSource extends IDataSource = IDataSource>(opts: {
|
|
10
|
+
metadata: TRepositoryMetadata<Model, DataSource>;
|
|
11
|
+
registration: IArtifactRegistrationOptions;
|
|
12
|
+
target: Function;
|
|
13
|
+
registry: MetadataRegistry;
|
|
14
|
+
}) => void;
|
|
15
|
+
//# sourceMappingURL=resolve.d.ts.map
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { ArtifactTypes } from '../../../../helpers/inversion/index.js';
|
|
2
|
+
import { ClassResolver, ResolverUtility } from '@venizia/ignis-helpers/common';
|
|
3
|
+
import { getError } from '@venizia/ignis-helpers/core';
|
|
4
|
+
import { RepositoryTypes } from '../../../repositories/common/constants.js';
|
|
5
|
+
import { injectable, InjectableUtility } from '../../injectable.js';
|
|
6
|
+
import { registerDataSourceInjection } from './injection.js';
|
|
7
|
+
import { validateRepositoryMetadata } from './validate.js';
|
|
8
|
+
/** Resolves repository metadata and registers bindings for schema auto-discovery. */
|
|
9
|
+
const resolveRepositoryMetadata = (opts) => {
|
|
10
|
+
const { metadata, target, registry } = opts;
|
|
11
|
+
validateRepositoryMetadata({ metadata, target });
|
|
12
|
+
const resolvedDataSource = ClassResolver.resolveClass({ ref: metadata.dataSource });
|
|
13
|
+
if (!resolvedDataSource) {
|
|
14
|
+
throw getError({
|
|
15
|
+
message: `[@repository][${target.name}] The dataSource resolver returned nothing at decoration time | An import cycle leaves the datasource class undefined here; import it without the cycle, or name it as a string`,
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
// No model, so no binding: the datasource owns no schema through this repository.
|
|
19
|
+
if (metadata.type === RepositoryTypes.REMOTE) {
|
|
20
|
+
registerDataSourceInjection({
|
|
21
|
+
target,
|
|
22
|
+
registry,
|
|
23
|
+
dataSourceRef: metadata.dataSource,
|
|
24
|
+
resolvedDataSource,
|
|
25
|
+
});
|
|
26
|
+
return {
|
|
27
|
+
type: RepositoryTypes.REMOTE,
|
|
28
|
+
dataSource: resolvedDataSource,
|
|
29
|
+
operationScope: metadata.operationScope,
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
const resolvedModel = ResolverUtility.resolveValue({ value: metadata.model });
|
|
33
|
+
registry.registerRepositoryBinding({
|
|
34
|
+
repository: target,
|
|
35
|
+
model: resolvedModel,
|
|
36
|
+
dataSource: resolvedDataSource,
|
|
37
|
+
});
|
|
38
|
+
registerDataSourceInjection({
|
|
39
|
+
target,
|
|
40
|
+
registry,
|
|
41
|
+
dataSourceRef: metadata.dataSource,
|
|
42
|
+
resolvedDataSource,
|
|
43
|
+
});
|
|
44
|
+
return {
|
|
45
|
+
type: RepositoryTypes.MODEL,
|
|
46
|
+
model: resolvedModel,
|
|
47
|
+
dataSource: resolvedDataSource,
|
|
48
|
+
operationScope: metadata.operationScope,
|
|
49
|
+
};
|
|
50
|
+
};
|
|
51
|
+
/** A bare `@repository()` on a subclass reuses the type, model and datasource its nearest decorated parent declared; the registration options (`binding`, `when`, ...) are never inherited, so the subclass registers under its own name. */
|
|
52
|
+
export const inheritRepositoryMetadata = (opts) => {
|
|
53
|
+
// Own metadata does not exist yet at decoration time, so this read walks the prototype chain.
|
|
54
|
+
const inherited = opts.registry.getRepositoryMetadata({ target: opts.target });
|
|
55
|
+
if (!inherited) {
|
|
56
|
+
throw getError({
|
|
57
|
+
message: `[@repository][${opts.target.name}] No metadata given and no decorated repository above it in the prototype chain | pass { model, dataSource } or decorate the parent`,
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
if (inherited.type === RepositoryTypes.REMOTE) {
|
|
61
|
+
const { type, dataSource, operationScope } = inherited;
|
|
62
|
+
return { type, dataSource, operationScope };
|
|
63
|
+
}
|
|
64
|
+
const { type, model: parentModel, dataSource, operationScope } = inherited;
|
|
65
|
+
return { type, model: parentModel, dataSource, operationScope };
|
|
66
|
+
};
|
|
67
|
+
export const applyRepositoryMetadata = (opts) => {
|
|
68
|
+
const { metadata, registration, target, registry } = opts;
|
|
69
|
+
injectable({
|
|
70
|
+
type: ArtifactTypes.REPOSITORY,
|
|
71
|
+
...InjectableUtility.pickRegistrationOptions({ metadata: registration }),
|
|
72
|
+
})(target);
|
|
73
|
+
const resolved = resolveRepositoryMetadata({ metadata, target, registry });
|
|
74
|
+
registry.setRepositoryMetadata({ target, metadata: { ...metadata, _resolved: resolved } });
|
|
75
|
+
};
|
|
76
|
+
//# sourceMappingURL=resolve.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolve.js","sourceRoot":"","sources":["../../../../../../src/base/metadata/persistents/repository/resolve.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAC/E,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AAGvD,OAAO,EAAE,eAAe,EAAE,MAAM,wCAAwC,CAAC;AACzE,OAAO,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACjE,OAAO,EAAE,2BAA2B,EAAE,MAAM,aAAa,CAAC;AAC1D,OAAO,EAAE,0BAA0B,EAAE,MAAM,YAAY,CAAC;AAExD,qFAAqF;AACrF,MAAM,yBAAyB,GAAG,CAGhC,IAID,EAAkD,EAAE;IACnD,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,GAAG,IAAI,CAAC;IAE5C,0BAA0B,CAAC,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAC,CAAC;IAEjD,MAAM,kBAAkB,GAAG,aAAa,CAAC,YAAY,CAAC,EAAE,GAAG,EAAE,QAAQ,CAAC,UAAU,EAAE,CAAC,CAAC;IAEpF,IAAI,CAAC,kBAAkB,EAAE,CAAC;QACxB,MAAM,QAAQ,CAAC;YACb,OAAO,EAAE,iBAAiB,MAAM,CAAC,IAAI,iLAAiL;SACvN,CAAC,CAAC;IACL,CAAC;IAED,kFAAkF;IAClF,IAAI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AAC,MAAM,EAAE,CAAC;QAC9C,MAAM,EAAE,IAAI,EAAE,UAAU,EAAE,cAAc,EAAE,GAAG,SAAS,CAAC;QAEvD,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,cAAc,EAAE,CAAC;IAC9C,CAAC;IAED,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,WAAW,EAAE,UAAU,EAAE,cAAc,EAAE,GAAG,SAAS,CAAC;IAE3E,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,WAAW,EAAE,UAAU,EAAE,cAAc,EAAE,CAAC;AAClE,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,uBAAuB,GAAG,CAGrC,IAKD,EAAQ,EAAE;IACT,MAAM,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,EAAE,QAAQ,EAAE,GAAG,IAAI,CAAC;IAE1D,UAAU,CAAC;QACT,IAAI,EAAE,aAAa,CAAC,UAAU;QAC9B,GAAG,iBAAiB,CAAC,uBAAuB,CAAC,EAAE,QAAQ,EAAE,YAAY,EAAE,CAAC;KACzE,CAAC,CAAC,MAAM,CAAC,CAAC;IAEX,MAAM,QAAQ,GAAG,yBAAyB,CAAC,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,CAAC;IAE3E,QAAQ,CAAC,qBAAqB,CAAC,EAAE,MAAM,EAAE,QAAQ,EAAE,EAAE,GAAG,QAAQ,EAAE,SAAS,EAAE,QAAQ,EAAE,EAAE,CAAC,CAAC;AAC7F,CAAC,CAAC","sourcesContent":["import type {\n IArtifactRegistrationOptions,\n IResolvedRepositoryMetadata,\n MetadataRegistry,\n TRepositoryMetadata,\n} from '@/helpers/inversion';\nimport { ArtifactTypes } from '@/helpers/inversion';\nimport { ClassResolver, ResolverUtility } from '@venizia/ignis-helpers/common';\nimport { getError } from '@venizia/ignis-helpers/core';\nimport type { IDataSource } from '../../../datasources';\nimport type { AbstractEntity } from '../../../models';\nimport { RepositoryTypes } from '../../../repositories/common/constants';\nimport { injectable, InjectableUtility } from '../../injectable';\nimport { registerDataSourceInjection } from './injection';\nimport { validateRepositoryMetadata } from './validate';\n\n/** Resolves repository metadata and registers bindings for schema auto-discovery. */\nconst resolveRepositoryMetadata = <\n Model extends AbstractEntity = AbstractEntity,\n DataSource extends IDataSource = IDataSource,\n>(opts: {\n metadata: TRepositoryMetadata<Model, DataSource>;\n target: Function;\n registry: MetadataRegistry;\n}): IResolvedRepositoryMetadata<Model, DataSource> => {\n const { metadata, target, registry } = opts;\n\n validateRepositoryMetadata({ metadata, target });\n\n const resolvedDataSource = ClassResolver.resolveClass({ ref: metadata.dataSource });\n\n if (!resolvedDataSource) {\n throw getError({\n message: `[@repository][${target.name}] The dataSource resolver returned nothing at decoration time | An import cycle leaves the datasource class undefined here; import it without the cycle, or name it as a string`,\n });\n }\n\n // No model, so no binding: the datasource owns no schema through this repository.\n if (metadata.type === RepositoryTypes.REMOTE) {\n registerDataSourceInjection({\n target,\n registry,\n dataSourceRef: metadata.dataSource,\n resolvedDataSource,\n });\n\n return {\n type: RepositoryTypes.REMOTE,\n dataSource: resolvedDataSource,\n operationScope: metadata.operationScope,\n };\n }\n\n const resolvedModel = ResolverUtility.resolveValue({ value: metadata.model });\n\n registry.registerRepositoryBinding({\n repository: target,\n model: resolvedModel,\n dataSource: resolvedDataSource,\n });\n\n registerDataSourceInjection({\n target,\n registry,\n dataSourceRef: metadata.dataSource,\n resolvedDataSource,\n });\n\n return {\n type: RepositoryTypes.MODEL,\n model: resolvedModel,\n dataSource: resolvedDataSource,\n operationScope: metadata.operationScope,\n };\n};\n\n/** A bare `@repository()` on a subclass reuses the type, model and datasource its nearest decorated parent declared; the registration options (`binding`, `when`, ...) are never inherited, so the subclass registers under its own name. */\nexport const inheritRepositoryMetadata = (opts: {\n target: Function;\n registry: MetadataRegistry;\n}): TRepositoryMetadata => {\n // Own metadata does not exist yet at decoration time, so this read walks the prototype chain.\n const inherited = opts.registry.getRepositoryMetadata({ target: opts.target });\n\n if (!inherited) {\n throw getError({\n message: `[@repository][${opts.target.name}] No metadata given and no decorated repository above it in the prototype chain | pass { model, dataSource } or decorate the parent`,\n });\n }\n\n if (inherited.type === RepositoryTypes.REMOTE) {\n const { type, dataSource, operationScope } = inherited;\n\n return { type, dataSource, operationScope };\n }\n\n const { type, model: parentModel, dataSource, operationScope } = inherited;\n\n return { type, model: parentModel, dataSource, operationScope };\n};\n\nexport const applyRepositoryMetadata = <\n Model extends AbstractEntity = AbstractEntity,\n DataSource extends IDataSource = IDataSource,\n>(opts: {\n metadata: TRepositoryMetadata<Model, DataSource>;\n registration: IArtifactRegistrationOptions;\n target: Function;\n registry: MetadataRegistry;\n}): void => {\n const { metadata, registration, target, registry } = opts;\n\n injectable({\n type: ArtifactTypes.REPOSITORY,\n ...InjectableUtility.pickRegistrationOptions({ metadata: registration }),\n })(target);\n\n const resolved = resolveRepositoryMetadata({ metadata, target, registry });\n\n registry.setRepositoryMetadata({ target, metadata: { ...metadata, _resolved: resolved } });\n};\n"]}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { TRepositoryMetadata } from '../../../../helpers/inversion/index.js';
|
|
2
|
+
import type { IDataSource } from '../../../datasources/index.js';
|
|
3
|
+
import type { AbstractEntity } from '../../../models/index.js';
|
|
4
|
+
/** Mirrors the `TRepositoryMetadata` union for JavaScript callers: a known type, a dataSource always, a model exactly when the type is RepositoryTypes.MODEL. */
|
|
5
|
+
export declare const validateRepositoryMetadata: <Model extends AbstractEntity = AbstractEntity, DataSource extends IDataSource = IDataSource>(opts: {
|
|
6
|
+
metadata: TRepositoryMetadata<Model, DataSource>;
|
|
7
|
+
target: Function;
|
|
8
|
+
}) => void;
|
|
9
|
+
/** Asserts the constructor's first parameter is a datasource class (`AbstractDataSource` or the `DataSourceRoot` it extends) compatible with what @repository declared. */
|
|
10
|
+
export declare const validateFirstConstructorParameter: (opts: {
|
|
11
|
+
target: Function;
|
|
12
|
+
firstParamType: Function;
|
|
13
|
+
resolvedDataSource: string | Function;
|
|
14
|
+
}) => void;
|
|
15
|
+
//# sourceMappingURL=validate.d.ts.map
|