@venizia/ignis-connectors 0.4.8-1 → 0.4.8-2
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/README.md +4 -2
- package/dist/esm/relational/core/repositories/core/base.js +2 -1
- package/dist/esm/relational/core/repositories/core/base.js.map +1 -1
- package/dist/esm/relational/core/repositories/dialect/filter.d.ts +2 -1
- package/dist/esm/relational/core/repositories/dialect/filter.js +19 -2
- package/dist/esm/relational/core/repositories/dialect/filter.js.map +1 -1
- package/package.json +6 -6
package/README.md
CHANGED
|
@@ -4,8 +4,8 @@ The datasources, drivers, entity bases and repositories IGNIS uses to reach a ba
|
|
|
4
4
|
through Drizzle (Postgres, PGlite, SQLite), search engines (Typesense, Meilisearch), and another
|
|
5
5
|
IGNIS server over HTTP.
|
|
6
6
|
|
|
7
|
-
Server applications get
|
|
8
|
-
directly when you use the connectors without the server, for example in a browser Worker.
|
|
7
|
+
Server applications get the Postgres entry through `@venizia/ignis`; every other entry is imported from this
|
|
8
|
+
package. Install it directly when you use the connectors without the server, for example in a browser Worker.
|
|
9
9
|
|
|
10
10
|
## Install
|
|
11
11
|
|
|
@@ -123,6 +123,8 @@ styles can live in one application.
|
|
|
123
123
|
| `/typesense/controllers` | The same search controllers as `/search/controllers` | `hono`, `@hono/zod-openapi` |
|
|
124
124
|
| `/meilisearch` | `MeilisearchDataSource`, `MeilisearchConnector`, `MeilisearchQueryDialect` | `meilisearch` |
|
|
125
125
|
| `/http` | `HttpDataSource` and `HttpRepository` - read another IGNIS server's REST routes with the same filter vocabulary | none |
|
|
126
|
+
| `/raw-sql` | `BaseRawSqlDataSource`, `BaseRawSqlRepository`, `RawSqlEntity` - an engine that only runs raw SQL and returns rows, with no dialect and no transactions; you supply the connector and the driver | none to load (`drizzle-orm` for the `SQLWrapper` type) |
|
|
127
|
+
| `/testing` | Test-only: `RepositoryDouble`, `TransactionDouble`, `PostgresTransactionDouble`, `SqliteTransactionDouble`; never imported from a production barrel | none |
|
|
126
128
|
|
|
127
129
|
The root entry imports no driver and no engine client. A driver loads only when you import its
|
|
128
130
|
entry and name its class in `@datasource({ driver })`.
|
|
@@ -200,7 +200,8 @@ export class RelationalBaseRepository extends AbstractRepository {
|
|
|
200
200
|
}
|
|
201
201
|
if (scopeWhere !== null && scopeWhere !== undefined) {
|
|
202
202
|
// A write reaches only the rows it may write: the shared (null) rows a read scope allows need `write.sharedRows`.
|
|
203
|
-
// A `through` scope is one foreign key set,
|
|
203
|
+
// A `through` scope is one foreign key set, but the parent's scope inside it can still carry a null branch: that is
|
|
204
|
+
// narrowed on the hop (`resolveThrough`), so this level has nothing left to narrow.
|
|
204
205
|
const effectiveWhere = mutation === undefined || scopeFilterSettings.through
|
|
205
206
|
? scopeWhere
|
|
206
207
|
: ScopeWriteGuard.mutationWhere({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base.js","sourceRoot":"","sources":["../../../../../../src/relational/core/repositories/core/base.ts"],"names":[],"mappings":"AAsBA,OAAO,EACL,kBAAkB,EAClB,aAAa,EACb,2BAA2B,EAC3B,YAAY,EACZ,eAAe,GAChB,MAAM,uBAAuB,CAAC;AAG/B,OAAO,EAAE,uBAAuB,EAAE,MAAM,sCAAsC,CAAC;AAC/E,OAAO,EAAE,oBAAoB,EAAE,MAAM,qDAAqD,CAAC;AAQ3F,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AACvD,OAAO,EAAE,GAAG,EAAE,eAAe,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAS5D,OAAO,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAC9C,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAE9D,iTAAiT;AACjT,MAAM,OAAgB,wBAOpB,SAAQ,kBAA2D;IAGnE;;;;;;OAMG;IACO,SAAS,CAAC,IAA8B;QAChD,OAAO,EAAE,EAAE,EAAE,IAAI,CAAC,EAAE,EAAE,CAAC;IACz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AI,CAAC,SAAS,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE,GAAG,OAAO,EAAE,YAAY,EAAE,KAAK,EAAE,EAAE,CAAC,CAAC;QACjF,CAAC;QAED,OAAO,IAAI,CAAC,SAAS,CAAI,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC,CAAC;IAC/C,CAAC;CACF","sourcesContent":["import type {\n IdType,\n IExtraOptions,\n IPersistableRepository,\n IModelAccessThroughSettings,\n TModelAccessSettings,\n ITransaction,\n TCount,\n TByIdFilter,\n TDataRange,\n TDrizzleQueryOptions,\n TFields,\n TFilter,\n TFindOneOptions,\n TFindOptions,\n TFindRangeOptions,\n TLockOptions,\n TRepositoryOperationScope,\n TRow,\n TScopeOperation,\n TWhere,\n} from '@venizia/ignis-kernel';\nimport {\n AbstractRepository,\n LockStrengths,\n ScopeFilterMissingBehaviors,\n ScopeFilters,\n ScopeOperations,\n} from '@venizia/ignis-kernel';\n// Deep import, not the `@/relational/core/datasources` barrel: the barrel pulls the datasource classes, which import the engine branch's dialect and executor - an init cycle back into this tier.\nimport type { IRelationalDataSource } from '@/relational/core/datasources/common';\nimport { isRelationalTransaction } from '@/relational/core/datasources/common';\nimport { TransactionLifecycle } from '@/relational/core/datasources/transaction-lifecycle';\nimport type {\n BaseRelationalEntity,\n TTableInsert,\n TTableObject,\n TTableSchemaWithId,\n} from '@/relational/core/models';\nimport type { TClass, TNullable } from '@venizia/ignis-helpers/common';\nimport { getError } from '@venizia/ignis-helpers/core';\nimport { and, getTableColumns, inArray } from 'drizzle-orm';\nimport type {\n IRelationalExtraOptions,\n IRelationalQueryDialect,\n IRelationalQueryExecutor,\n TRelationalConnectorOf,\n TRelationalTransactionOf,\n TRelationalTransactionOptionsOf,\n} from '../common';\nimport { ScopeFilterDenial } from '../common';\nimport { ScopeWriteGuard } from '../common/scope-write-guard';\n\n/** Relational implementation of `AbstractRepository`: adds the query dialect + hidden-column exclusion on top of the neutral base, and reaches the database only through `IRelationalQueryExecutor`. Both engine-facing parameters default to the neutral SQL contracts; an engine binds them by subclassing. */\nexport abstract class RelationalBaseRepository<\n EntitySchema extends TTableSchemaWithId = TTableSchemaWithId,\n DataObject extends TTableObject<EntitySchema> = TTableObject<EntitySchema>,\n PersistObject extends TTableInsert<EntitySchema> = TTableInsert<EntitySchema>,\n ExtraOptions extends IExtraOptions = IRelationalExtraOptions,\n TDataSource extends IRelationalDataSource = IRelationalDataSource,\n>\n extends AbstractRepository<DataObject, PersistObject, ExtraOptions>\n implements IPersistableRepository<DataObject, PersistObject, ExtraOptions>\n{\n /**\n * The `Pick` return type is load-bearing, not decoration. `TWhere<DataObject>` is a homomorphic\n * mapped type over an unresolved type parameter, and TypeScript cannot check a one-key literal\n * against it - `{ id }` fails even though `id` is a real key. `Pick<..., 'id'>` resolves that one\n * key, and the result still assigns to `TWhere<DataObject>` because every key there is optional.\n * Without it every `*ById` method needs a cast, which would hide a genuinely wrong id type.\n */\n protected whereById(opts: { id: DataObject['id'] }): Pick<TWhere<DataObject>, 'id'> {\n return { id: opts.id };\n }\n\n /** Memoized Set view of the base's `hiddenFields` array - built once on first access. */\n private _hiddenPropertySet: Set<string> | null = null;\n\n /** Memoized Drizzle column-selection map derived from hidden fields. `null` = not yet computed; `undefined` = computed, no hidden fields. */\n private _visibleColumns: Record<string, unknown> | null | undefined = null;\n\n constructor(\n dataSource?: TDataSource,\n opts?: {\n scope?: string;\n entityClass?: TClass<BaseRelationalEntity<EntitySchema>>;\n operationScope?: TRepositoryOperationScope;\n },\n ) {\n super(dataSource, opts);\n }\n\n override get dataSource(): TDataSource {\n return super.dataSource as TDataSource;\n }\n\n override set dataSource(value: TDataSource) {\n super.dataSource = value;\n }\n\n override get entity(): BaseRelationalEntity<EntitySchema> {\n return super.entity as BaseRelationalEntity<EntitySchema>;\n }\n\n override set entity(value: BaseRelationalEntity<EntitySchema>) {\n super.entity = value;\n }\n\n get queryDialect(): IRelationalQueryDialect {\n return this.dataSource.getQueryDialect();\n }\n\n /** Every Drizzle call the repository tier makes goes through this port, supplied by the engine branch via the datasource. */\n protected get queryExecutor(): IRelationalQueryExecutor<TRelationalConnectorOf<TDataSource>> {\n return this.dataSource.getQueryExecutor() as IRelationalQueryExecutor<\n TRelationalConnectorOf<TDataSource>\n >;\n }\n\n get connector(): TRelationalConnectorOf<TDataSource> {\n return this.dataSource.getConnector() as TRelationalConnectorOf<TDataSource>;\n }\n\n override setDataSource(opts: { dataSource: TDataSource }): void {\n super.setDataSource(opts);\n }\n\n getEntitySchema(): EntitySchema {\n return this.entity.schema;\n }\n\n /** Hidden fields as a memoized Set, derived from the base's class-keyed `hiddenFields` array. */\n getHiddenProperties(): Set<string> {\n this._hiddenPropertySet ??= new Set(this.hiddenFields);\n\n return this._hiddenPropertySet;\n }\n\n hasHiddenProperties(): boolean {\n return this.getHiddenProperties().size > 0;\n }\n\n /** Drizzle select/returning column map excluding hidden properties. Undefined if none hidden. Memoized. */\n getVisibleProperties(): Record<string, any> | undefined {\n if (this._visibleColumns !== null) {\n return this._visibleColumns;\n }\n\n const hiddenProps = this.getHiddenProperties();\n\n if (hiddenProps.size === 0) {\n this._visibleColumns = undefined;\n\n return undefined;\n }\n\n const columns = getTableColumns(this.entity.schema);\n const visibleProperties: Record<string, any> = {};\n\n for (const key in columns) {\n if (!hiddenProps.has(key)) {\n visibleProperties[key] = columns[key];\n }\n }\n\n this._visibleColumns = visibleProperties;\n\n return this._visibleColumns;\n }\n\n getDefaultFilter(): TFilter | undefined {\n return this.modelSettings?.query?.filter;\n }\n\n getDefaultLimit(): number | undefined {\n return this.defaultLimit;\n }\n\n hasDefaultFilter(): boolean {\n const defaultFilter = this.getDefaultFilter();\n\n return defaultFilter !== undefined && Object.keys(defaultFilter).length > 0;\n }\n\n /**\n * The model's `access` settings. Same override seam as `getDefaultFilter()` - a repository with no\n * resolvable `@model` entity (a synthetic test double, a hand-built stub) overrides this to avoid\n * touching `modelSettings`/`entity` at all.\n */\n getAccessSettings(): TModelAccessSettings | undefined {\n return this.modelSettings?.access;\n }\n\n /**\n * Holds written rows to the resolved row scope (`access.write`): refuses a row outside\n * it, and for `assign` returns copies with the scope columns filled in. Nothing is written when it\n * throws. Like the read scope, it is not skippable by `shouldSkipDefaultFilter`; a caller that is\n * trusted to write across scopes resolves to `ScopeFilters.UNRESTRICTED`.\n */\n protected async guardScopedWrite<Row extends Record<string, unknown>>(opts: {\n rows: Row[];\n operation: TScopeOperation;\n transaction?: ITransaction;\n }): Promise<Row[]> {\n const settings = this.getAccessSettings();\n\n if (!settings) {\n return opts.rows;\n }\n\n if (settings.through) {\n await this.assertParentsInScope({ ...opts, settings });\n\n return opts.rows;\n }\n\n return ScopeWriteGuard.apply({\n settings,\n model: this.entity.name,\n rows: opts.rows,\n operation: opts.operation,\n });\n }\n\n /**\n * A write to a model scoped through its parent: every parent key the rows name must be one the parent's own scope\n * allows for this operation. One query for the batch, read in the write's transaction (with `FOR SHARE` where the\n * engine can lock a row, so a parent that moves tenant after the check cannot be missed). A key that is null, absent,\n * missing from the parent table or outside the scope is the same refusal. An update names a key only to move the\n * row, so a payload without it checks nothing.\n */\n protected async assertParentsInScope(opts: {\n settings: IModelAccessThroughSettings;\n rows: Array<Record<string, unknown>>;\n operation: TScopeOperation;\n transaction?: ITransaction;\n }): Promise<void> {\n const { settings, operation, transaction } = opts;\n const { link, scope } = this.queryDialect.resolveThrough({\n settings,\n schema: this.entity.schema,\n operation,\n });\n const property = link.childProperty;\n const named =\n operation === ScopeOperations.CREATE ? opts.rows : opts.rows.filter((row) => property in row);\n\n if (named.length === 0) {\n return;\n }\n\n const denied = ScopeWriteGuard.parentDenied({\n model: this.entity.name,\n operation,\n column: property,\n });\n const keys = [...new Set(named.map((row) => row[property]))];\n const isUnresolved = scope === null || scope === undefined;\n\n if (keys.some((key) => key === null || key === undefined)) {\n throw denied;\n }\n\n // A parent that resolves no scope always denies its child: there is no onMissing to open it.\n if (isUnresolved) {\n throw denied;\n }\n\n const parentScope =\n scope === ScopeFilters.UNRESTRICTED\n ? undefined\n : this.queryDialect.toParentWhere({ link, scope });\n const found = await this.queryExecutor.select<{ key: unknown }>({\n connector: this.resolveConnector({ transaction }),\n table: link.parentSchema,\n columns: { key: link.parentColumn },\n where: and(inArray(link.parentColumn, keys), parentScope),\n lock: this.queryExecutor.supportsRowLock ? { strength: LockStrengths.SHARE } : undefined,\n });\n\n // Distinct keys, not rows: a parent column that is not unique can return two rows for one key and hide a missing one.\n if (new Set(found.map((row) => row.key)).size !== keys.length) {\n throw denied;\n }\n }\n\n /**\n * Row scope from `@model` settings.access - AND-composed like a default filter, but never\n * skippable via `shouldSkipDefaultFilter`: that flag serves `restore()`'s deliberate reach past\n * soft-delete, which must not also reach past tenant/ownership scoping.\n *\n * `dangerouslySkipScopeFilter` is framework-internal only, never part of `IExtraOptions` and never\n * wire-reachable: it exists so a filter this repository already scoped (find()'s own recursive\n * call) is not scoped a second time, and for explicitly-unscoped administrative code written and\n * reviewed at the repository - never inferable from a request.\n */\n protected applyScopeFilter<DO = any>(opts: {\n userFilter?: TFilter<DO>;\n dangerouslySkipScopeFilter?: boolean;\n mutation?: TScopeOperation;\n }): TFilter<DO> {\n const { userFilter, dangerouslySkipScopeFilter, mutation } = opts;\n\n if (dangerouslySkipScopeFilter) {\n return userFilter ?? {};\n }\n\n const scopeFilterSettings = this.getAccessSettings();\n\n if (!scopeFilterSettings) {\n return userFilter ?? {};\n }\n\n const scopeWhere = this.queryDialect.resolveAccessScope({\n settings: scopeFilterSettings,\n schema: this.entity.schema,\n operation: mutation ?? ScopeOperations.READ,\n });\n\n // Checked by exact symbol identity, before the null/undefined branch below: only this literal\n // value can skip scoping. A resolver that forgets a `return` on some branch produces\n // `undefined`, which is NOT this symbol and falls through to `onMissing` (deny by default).\n if (scopeWhere === ScopeFilters.UNRESTRICTED) {\n return userFilter ?? {};\n }\n\n if (scopeWhere !== null && scopeWhere !== undefined) {\n // A write reaches only the rows it may write: the shared (null) rows a read scope allows need `write.sharedRows`.\n // A `through` scope is one foreign key set, with no null branch for `sharedRows` to open, so it needs no narrowing.\n const effectiveWhere =\n mutation === undefined || scopeFilterSettings.through\n ? scopeWhere\n : ScopeWriteGuard.mutationWhere({\n settings: scopeFilterSettings,\n model: this.entity.name,\n operation: mutation,\n scopeWhere,\n });\n\n return this.queryDialect.mergeFilter({\n defaultFilter: { where: effectiveWhere },\n userFilter,\n });\n }\n\n if (scopeFilterSettings.onMissing === ScopeFilterMissingBehaviors.ALLOW) {\n return userFilter ?? {};\n }\n\n // 'deny' (default): an unresolved scope means the framework does not know what this caller may\n // see, and the safe reading of \"I do not know\" is \"nothing\" - never \"everything\".\n return this.queryDialect.mergeFilter({\n defaultFilter: { where: ScopeFilterDenial.where<DO>() },\n userFilter,\n });\n }\n\n /** Merges default filter with user filter. Skippable via shouldSkipDefaultFilter - the row scope from applyScopeFilter is not. */\n applyDefaultFilter<DO = any>(opts: {\n userFilter?: TFilter<DO>;\n shouldSkipDefaultFilter?: boolean;\n dangerouslySkipScopeFilter?: boolean;\n /** The name of the write (`update`, `delete`) when the filter selects rows to change: the row scope then leaves out the shared rows unless `write.sharedRows`. */\n mutation?: TScopeOperation;\n }): TFilter<DO> {\n const { userFilter, shouldSkipDefaultFilter, dangerouslySkipScopeFilter, mutation } = opts;\n\n const scopedFilter = this.applyScopeFilter<DO>({\n userFilter,\n dangerouslySkipScopeFilter,\n mutation,\n });\n\n if (shouldSkipDefaultFilter) {\n return scopedFilter;\n }\n\n const defaultFilter = this.getDefaultFilter();\n\n if (!defaultFilter) {\n return scopedFilter;\n }\n\n return this.queryDialect.mergeFilter({ defaultFilter, userFilter: scopedFilter });\n }\n\n async beginTransaction(\n opts?: TRelationalTransactionOptionsOf<TDataSource>,\n ): Promise<TRelationalTransactionOf<TDataSource>> {\n return this.dataSource.beginTransaction(opts) as Promise<TRelationalTransactionOf<TDataSource>>;\n }\n\n /**\n * Runs `execute` inside a transaction. Given a `transaction`, joins it: its owner commits or rolls\n * back, so this never does. Given none, owns one: begins it, commits when `execute` resolves, and\n * rolls back when `execute` or the commit throws - rethrowing the original error either way. An\n * owned transaction that `execute` already ended is never ended a second time.\n */\n async runInTransaction<ResultType>(opts: {\n transaction?: TRelationalTransactionOf<TDataSource>;\n transactionOptions?: TRelationalTransactionOptionsOf<TDataSource>;\n execute: (opts: { transaction: TRelationalTransactionOf<TDataSource> }) => Promise<ResultType>;\n }): Promise<ResultType> {\n const { transaction, transactionOptions, execute } = opts;\n\n if (transaction) {\n if (!transaction.isActive) {\n throw getError({\n message: `[${this.constructor.name}][runInTransaction] Transaction is no longer active`,\n });\n }\n\n if (transactionOptions) {\n this.logger\n .for('runInTransaction')\n .debug('Joined transaction | transactionOptions ignored: %j', transactionOptions);\n }\n\n return execute({ transaction });\n }\n\n const ownedTransaction = await this.beginTransaction(transactionOptions);\n\n let result: ResultType;\n\n try {\n const result2 = await execute({ transaction: ownedTransaction });\n result = result2;\n } catch (error) {\n if (ownedTransaction.isActive) {\n await this.rollbackOwnedTransaction({ transaction: ownedTransaction });\n }\n\n throw error;\n }\n\n if (!ownedTransaction.isActive) {\n return this.resolveEndedByExecute({ transaction: ownedTransaction, result });\n }\n\n try {\n await ownedTransaction.commit();\n } catch (error) {\n await this.rollbackOwnedTransaction({ transaction: ownedTransaction });\n throw error;\n }\n\n return result;\n }\n\n /** `execute` resolved after ending the owned transaction itself: its work stands only if it committed. */\n private resolveEndedByExecute<ResultType>(opts: {\n transaction: ITransaction;\n result: ResultType;\n }): ResultType {\n const { transaction, result } = opts;\n\n if (TransactionLifecycle.isCommitted({ transaction })) {\n this.logger\n .for('runInTransaction')\n .warn('execute committed the owned transaction itself | Skipped the commit');\n\n return result;\n }\n\n throw getError({\n message: `[${this.constructor.name}][runInTransaction] execute ended the owned transaction before it could be committed`,\n });\n }\n\n /** A rollback failure is only logged: the caller needs the error that made the rollback necessary. */\n private async rollbackOwnedTransaction(opts: { transaction: ITransaction }): Promise<void> {\n try {\n await opts.transaction.rollback();\n } catch (rollbackError) {\n this.logger\n .for('runInTransaction')\n .error(\n 'Rollback failed, rethrowing the original error | Rollback error: %s',\n rollbackError,\n );\n }\n }\n\n /** Builds Drizzle query options from a filter, excluding hidden properties. */\n buildQuery(opts: { filter: TFilter<DataObject> }): TDrizzleQueryOptions {\n const result = this.queryDialect.build({\n tableName: this.entity.name,\n schema: this.entity.schema,\n // The dialect reads the filter against the table object; `DataObject` is the same row.\n filter: opts.filter as TFilter,\n });\n\n if (!this.hasHiddenProperties()) {\n return result;\n }\n\n const hiddenProps = this.getHiddenProperties();\n\n if (result.columns) {\n result.columns = this.omitHiddenColumns({ columns: result.columns, hiddenProps });\n\n return result;\n }\n\n const visibleProps = this.getVisibleProperties();\n\n if (visibleProps) {\n const filteredColumns: Record<string, boolean> = {};\n\n for (const key in visibleProps) {\n filteredColumns[key] = true;\n }\n\n result.columns = filteredColumns;\n }\n\n return result;\n }\n\n /** Copy of a Drizzle column selection with hidden properties dropped. */\n private omitHiddenColumns(opts: {\n columns: Record<string, boolean>;\n hiddenProps: Set<string>;\n }): Record<string, boolean> {\n const { columns, hiddenProps } = opts;\n const filteredColumns: Record<string, boolean> = {};\n\n for (const key in columns) {\n if (hiddenProps.has(key)) {\n continue;\n }\n\n filteredColumns[key] = columns[key];\n }\n\n return filteredColumns;\n }\n\n /** Resolves the database connector, using the transaction's connector if provided. */\n protected resolveConnector(opts?: {\n transaction?: ITransaction;\n }): TRelationalConnectorOf<TDataSource> {\n const { transaction } = opts ?? {};\n\n if (!transaction) {\n return this.dataSource.getConnector() as TRelationalConnectorOf<TDataSource>;\n }\n\n if (!transaction.isActive) {\n throw getError({\n message: `[${this.constructor.name}][resolveConnector] Transaction is no longer active`,\n });\n }\n\n if (!isRelationalTransaction(transaction)) {\n throw getError({\n message: `[${this.constructor.name}][resolveConnector] Transaction is not a relational transaction`,\n });\n }\n\n return transaction.connector as TRelationalConnectorOf<TDataSource>;\n }\n\n /** Validates lock options: requires transaction, incompatible with Query API (include/fields). */\n protected validateLockOptions(opts: {\n lock?: TLockOptions;\n transaction?: ITransaction;\n usesQueryAPI?: boolean;\n }): void {\n if (!opts.lock) {\n return;\n }\n\n if (!opts.transaction) {\n throw getError({\n message: `[${this.constructor.name}][validateLockOptions] Row-level locking requires a transaction`,\n });\n }\n\n if (opts.usesQueryAPI) {\n throw getError({\n message: `[${this.constructor.name}][validateLockOptions] Row-level locking is incompatible with Query API`,\n });\n }\n }\n\n abstract override count(opts: {\n where: TWhere<DataObject>;\n options?: ExtraOptions;\n }): Promise<TCount>;\n\n abstract override existsWith(opts: {\n where: TWhere<DataObject>;\n options?: ExtraOptions;\n }): Promise<boolean>;\n\n abstract override find<\n R = unknown,\n const F extends TFields<DataObject> = TFields<DataObject>,\n >(opts: {\n filter: TFilter<DataObject, F>;\n options: TFindRangeOptions<ExtraOptions, TRow<DataObject, R, F>>;\n }): Promise<{ data: Array<TRow<DataObject, R, F>>; range: TDataRange }>;\n\n abstract override find<\n R = unknown,\n const F extends TFields<DataObject> = TFields<DataObject>,\n >(opts: {\n filter: TFilter<DataObject, F>;\n options?: TFindOptions<ExtraOptions, TRow<DataObject, R, F>>;\n }): Promise<Array<TRow<DataObject, R, F>>>;\n\n abstract override findOne<\n R = unknown,\n const F extends TFields<DataObject> = TFields<DataObject>,\n >(opts: {\n filter: TFilter<DataObject, F>;\n options?: TFindOneOptions<ExtraOptions, TRow<DataObject, R, F>>;\n }): Promise<TNullable<TRow<DataObject, R, F>>>;\n\n abstract override findById<\n R = unknown,\n const F extends TFields<DataObject> = TFields<DataObject>,\n >(opts: {\n id: IdType;\n filter?: TByIdFilter<DataObject, F>;\n options?: TFindOneOptions<ExtraOptions, TRow<DataObject, R, F>>;\n }): Promise<TNullable<TRow<DataObject, R, F>>>;\n\n abstract override create(opts: {\n data: PersistObject;\n options: ExtraOptions & { shouldReturn: false };\n }): Promise<TCount & { data: undefined | null }>;\n\n abstract override create<R = DataObject>(opts: {\n data: PersistObject;\n options?: ExtraOptions & { shouldReturn?: true };\n }): Promise<TCount & { data: R }>;\n\n abstract override createAll(opts: {\n data: Array<PersistObject>;\n options: ExtraOptions & { shouldReturn: false };\n }): Promise<TCount & { data: undefined | null }>;\n\n abstract override createAll<R = DataObject>(opts: {\n data: Array<PersistObject>;\n options?: ExtraOptions & { shouldReturn?: true };\n }): Promise<TCount & { data: Array<R> }>;\n\n abstract override updateById(opts: {\n id: IdType;\n data: Partial<PersistObject>;\n options: ExtraOptions & { shouldReturn: false };\n }): Promise<TCount & { data: undefined | null }>;\n\n abstract override updateById<R = DataObject>(opts: {\n id: IdType;\n data: Partial<PersistObject>;\n options?: ExtraOptions & { shouldReturn?: true };\n }): Promise<TCount & { data: R }>;\n\n abstract override updateAll(opts: {\n data: Partial<PersistObject>;\n where: TWhere<DataObject>;\n options: ExtraOptions & { shouldReturn: false; force?: boolean };\n }): Promise<TCount & { data: undefined | null }>;\n\n abstract override updateAll<R = DataObject>(opts: {\n data: Partial<PersistObject>;\n where: TWhere<DataObject>;\n options?: ExtraOptions & { shouldReturn?: true; force?: boolean };\n }): Promise<TCount & { data: Array<R> }>;\n\n // Re-declared, not inherited: the base alias is `Array<R> | null` to cover the search family, but SQL engines have RETURNING so this surface must stay exactly `Array<R>`.\n override updateBy(opts: {\n data: Partial<PersistObject>;\n where: TWhere<DataObject>;\n options: ExtraOptions & { shouldReturn: false; force?: boolean };\n }): Promise<TCount & { data: undefined | null }>;\n override updateBy<R = DataObject>(opts: {\n data: Partial<PersistObject>;\n where: TWhere<DataObject>;\n options?: ExtraOptions & { shouldReturn?: true; force?: boolean };\n }): Promise<TCount & { data: Array<R> }>;\n override updateBy<R = DataObject>(opts: {\n data: Partial<PersistObject>;\n where: TWhere<DataObject>;\n options?: ExtraOptions & { shouldReturn?: boolean; force?: boolean };\n }): Promise<TCount & { data: TNullable<Array<R>> }> {\n const { data, where, options } = opts;\n\n if (options?.shouldReturn === false) {\n return this.updateAll({ data, where, options: { ...options, shouldReturn: false } });\n }\n\n return this.updateAll<R>({ data, where, options });\n }\n\n abstract override deleteById(opts: {\n id: IdType;\n options: ExtraOptions & { shouldReturn: false };\n }): Promise<TCount & { data: undefined | null }>;\n\n abstract override deleteById<R = DataObject>(opts: {\n id: IdType;\n options?: ExtraOptions & { shouldReturn?: true };\n }): Promise<TCount & { data: R }>;\n\n abstract override deleteAll(opts: {\n where?: TWhere<DataObject>;\n options: ExtraOptions & { shouldReturn: false; force?: boolean };\n }): Promise<TCount & { data: undefined | null }>;\n\n abstract override deleteAll<R = DataObject>(opts: {\n where?: TWhere<DataObject>;\n options?: ExtraOptions & { shouldReturn?: true; force?: boolean };\n }): Promise<TCount & { data: Array<R> }>;\n\n // Same rationale as updateBy above: keep this alias surface at `Array<R>`.\n override deleteBy(opts: {\n where?: TWhere<DataObject>;\n options: ExtraOptions & { shouldReturn: false; force?: boolean };\n }): Promise<TCount & { data: undefined | null }>;\n override deleteBy<R = DataObject>(opts: {\n where?: TWhere<DataObject>;\n options?: ExtraOptions & { shouldReturn?: true; force?: boolean };\n }): Promise<TCount & { data: Array<R> }>;\n override deleteBy<R = DataObject>(opts: {\n where?: TWhere<DataObject>;\n options?: ExtraOptions & { shouldReturn?: boolean; force?: boolean };\n }): Promise<TCount & { data: TNullable<Array<R>> }> {\n const { where, options } = opts;\n\n if (options?.shouldReturn === false) {\n return this.deleteAll({ where, options: { ...options, shouldReturn: false } });\n }\n\n return this.deleteAll<R>({ where, options });\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"base.js","sourceRoot":"","sources":["../../../../../../src/relational/core/repositories/core/base.ts"],"names":[],"mappings":"AAsBA,OAAO,EACL,kBAAkB,EAClB,aAAa,EACb,2BAA2B,EAC3B,YAAY,EACZ,eAAe,GAChB,MAAM,uBAAuB,CAAC;AAG/B,OAAO,EAAE,uBAAuB,EAAE,MAAM,sCAAsC,CAAC;AAC/E,OAAO,EAAE,oBAAoB,EAAE,MAAM,qDAAqD,CAAC;AAQ3F,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AACvD,OAAO,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EAAE,EAAE,GAAG,OAAO,EAAE,YAAY,EAAE,KAAK,EAAE,EAAE,CAAC,CAAC;QACvF,CAAC;QAED,OAAO,IAAI,CAAC,SAAS,CAAI,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC,CAAC;IACrD,CAAC;IA+BQ,QAAQ,CAAiB,IAGjC;QACC,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC;QAEhC,IAAI,OAAO,EAAE,YAAY,KAAK,KAAK,EAAE,CAAC;YACpC,OAAO,IAAI,CAAC,SAAS,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE,GAAG,OAAO,EAAE,YAAY,EAAE,KAAK,EAAE,EAAE,CAAC,CAAC;QACjF,CAAC;QAED,OAAO,IAAI,CAAC,SAAS,CAAI,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC,CAAC;IAC/C,CAAC;CACF","sourcesContent":["import type {\n IdType,\n IExtraOptions,\n IPersistableRepository,\n IModelAccessThroughSettings,\n TModelAccessSettings,\n ITransaction,\n TCount,\n TByIdFilter,\n TDataRange,\n TDrizzleQueryOptions,\n TFields,\n TFilter,\n TFindOneOptions,\n TFindOptions,\n TFindRangeOptions,\n TLockOptions,\n TRepositoryOperationScope,\n TRow,\n TScopeOperation,\n TWhere,\n} from '@venizia/ignis-kernel';\nimport {\n AbstractRepository,\n LockStrengths,\n ScopeFilterMissingBehaviors,\n ScopeFilters,\n ScopeOperations,\n} from '@venizia/ignis-kernel';\n// Deep import, not the `@/relational/core/datasources` barrel: the barrel pulls the datasource classes, which import the engine branch's dialect and executor - an init cycle back into this tier.\nimport type { IRelationalDataSource } from '@/relational/core/datasources/common';\nimport { isRelationalTransaction } from '@/relational/core/datasources/common';\nimport { TransactionLifecycle } from '@/relational/core/datasources/transaction-lifecycle';\nimport type {\n BaseRelationalEntity,\n TTableInsert,\n TTableObject,\n TTableSchemaWithId,\n} from '@/relational/core/models';\nimport type { TClass, TNullable } from '@venizia/ignis-helpers/common';\nimport { getError } from '@venizia/ignis-helpers/core';\nimport { and, getTableColumns, inArray } from 'drizzle-orm';\nimport type {\n IRelationalExtraOptions,\n IRelationalQueryDialect,\n IRelationalQueryExecutor,\n TRelationalConnectorOf,\n TRelationalTransactionOf,\n TRelationalTransactionOptionsOf,\n} from '../common';\nimport { ScopeFilterDenial } from '../common';\nimport { ScopeWriteGuard } from '../common/scope-write-guard';\n\n/** Relational implementation of `AbstractRepository`: adds the query dialect + hidden-column exclusion on top of the neutral base, and reaches the database only through `IRelationalQueryExecutor`. Both engine-facing parameters default to the neutral SQL contracts; an engine binds them by subclassing. */\nexport abstract class RelationalBaseRepository<\n EntitySchema extends TTableSchemaWithId = TTableSchemaWithId,\n DataObject extends TTableObject<EntitySchema> = TTableObject<EntitySchema>,\n PersistObject extends TTableInsert<EntitySchema> = TTableInsert<EntitySchema>,\n ExtraOptions extends IExtraOptions = IRelationalExtraOptions,\n TDataSource extends IRelationalDataSource = IRelationalDataSource,\n>\n extends AbstractRepository<DataObject, PersistObject, ExtraOptions>\n implements IPersistableRepository<DataObject, PersistObject, ExtraOptions>\n{\n /**\n * The `Pick` return type is load-bearing, not decoration. `TWhere<DataObject>` is a homomorphic\n * mapped type over an unresolved type parameter, and TypeScript cannot check a one-key literal\n * against it - `{ id }` fails even though `id` is a real key. `Pick<..., 'id'>` resolves that one\n * key, and the result still assigns to `TWhere<DataObject>` because every key there is optional.\n * Without it every `*ById` method needs a cast, which would hide a genuinely wrong id type.\n */\n protected whereById(opts: { id: DataObject['id'] }): Pick<TWhere<DataObject>, 'id'> {\n return { id: opts.id };\n }\n\n /** Memoized Set view of the base's `hiddenFields` array - built once on first access. */\n private _hiddenPropertySet: Set<string> | null = null;\n\n /** Memoized Drizzle column-selection map derived from hidden fields. `null` = not yet computed; `undefined` = computed, no hidden fields. */\n private _visibleColumns: Record<string, unknown> | null | undefined = null;\n\n constructor(\n dataSource?: TDataSource,\n opts?: {\n scope?: string;\n entityClass?: TClass<BaseRelationalEntity<EntitySchema>>;\n operationScope?: TRepositoryOperationScope;\n },\n ) {\n super(dataSource, opts);\n }\n\n override get dataSource(): TDataSource {\n return super.dataSource as TDataSource;\n }\n\n override set dataSource(value: TDataSource) {\n super.dataSource = value;\n }\n\n override get entity(): BaseRelationalEntity<EntitySchema> {\n return super.entity as BaseRelationalEntity<EntitySchema>;\n }\n\n override set entity(value: BaseRelationalEntity<EntitySchema>) {\n super.entity = value;\n }\n\n get queryDialect(): IRelationalQueryDialect {\n return this.dataSource.getQueryDialect();\n }\n\n /** Every Drizzle call the repository tier makes goes through this port, supplied by the engine branch via the datasource. */\n protected get queryExecutor(): IRelationalQueryExecutor<TRelationalConnectorOf<TDataSource>> {\n return this.dataSource.getQueryExecutor() as IRelationalQueryExecutor<\n TRelationalConnectorOf<TDataSource>\n >;\n }\n\n get connector(): TRelationalConnectorOf<TDataSource> {\n return this.dataSource.getConnector() as TRelationalConnectorOf<TDataSource>;\n }\n\n override setDataSource(opts: { dataSource: TDataSource }): void {\n super.setDataSource(opts);\n }\n\n getEntitySchema(): EntitySchema {\n return this.entity.schema;\n }\n\n /** Hidden fields as a memoized Set, derived from the base's class-keyed `hiddenFields` array. */\n getHiddenProperties(): Set<string> {\n this._hiddenPropertySet ??= new Set(this.hiddenFields);\n\n return this._hiddenPropertySet;\n }\n\n hasHiddenProperties(): boolean {\n return this.getHiddenProperties().size > 0;\n }\n\n /** Drizzle select/returning column map excluding hidden properties. Undefined if none hidden. Memoized. */\n getVisibleProperties(): Record<string, any> | undefined {\n if (this._visibleColumns !== null) {\n return this._visibleColumns;\n }\n\n const hiddenProps = this.getHiddenProperties();\n\n if (hiddenProps.size === 0) {\n this._visibleColumns = undefined;\n\n return undefined;\n }\n\n const columns = getTableColumns(this.entity.schema);\n const visibleProperties: Record<string, any> = {};\n\n for (const key in columns) {\n if (!hiddenProps.has(key)) {\n visibleProperties[key] = columns[key];\n }\n }\n\n this._visibleColumns = visibleProperties;\n\n return this._visibleColumns;\n }\n\n getDefaultFilter(): TFilter | undefined {\n return this.modelSettings?.query?.filter;\n }\n\n getDefaultLimit(): number | undefined {\n return this.defaultLimit;\n }\n\n hasDefaultFilter(): boolean {\n const defaultFilter = this.getDefaultFilter();\n\n return defaultFilter !== undefined && Object.keys(defaultFilter).length > 0;\n }\n\n /**\n * The model's `access` settings. Same override seam as `getDefaultFilter()` - a repository with no\n * resolvable `@model` entity (a synthetic test double, a hand-built stub) overrides this to avoid\n * touching `modelSettings`/`entity` at all.\n */\n getAccessSettings(): TModelAccessSettings | undefined {\n return this.modelSettings?.access;\n }\n\n /**\n * Holds written rows to the resolved row scope (`access.write`): refuses a row outside\n * it, and for `assign` returns copies with the scope columns filled in. Nothing is written when it\n * throws. Like the read scope, it is not skippable by `shouldSkipDefaultFilter`; a caller that is\n * trusted to write across scopes resolves to `ScopeFilters.UNRESTRICTED`.\n */\n protected async guardScopedWrite<Row extends Record<string, unknown>>(opts: {\n rows: Row[];\n operation: TScopeOperation;\n transaction?: ITransaction;\n }): Promise<Row[]> {\n const settings = this.getAccessSettings();\n\n if (!settings) {\n return opts.rows;\n }\n\n if (settings.through) {\n await this.assertParentsInScope({ ...opts, settings });\n\n return opts.rows;\n }\n\n return ScopeWriteGuard.apply({\n settings,\n model: this.entity.name,\n rows: opts.rows,\n operation: opts.operation,\n });\n }\n\n /**\n * A write to a model scoped through its parent: every parent key the rows name must be one the parent's own scope\n * allows for this operation. One query for the batch, read in the write's transaction (with `FOR SHARE` where the\n * engine can lock a row, so a parent that moves tenant after the check cannot be missed). A key that is null, absent,\n * missing from the parent table or outside the scope is the same refusal. An update names a key only to move the\n * row, so a payload without it checks nothing.\n */\n protected async assertParentsInScope(opts: {\n settings: IModelAccessThroughSettings;\n rows: Array<Record<string, unknown>>;\n operation: TScopeOperation;\n transaction?: ITransaction;\n }): Promise<void> {\n const { settings, operation, transaction } = opts;\n const { link, scope } = this.queryDialect.resolveThrough({\n settings,\n schema: this.entity.schema,\n operation,\n });\n const property = link.childProperty;\n const named =\n operation === ScopeOperations.CREATE ? opts.rows : opts.rows.filter((row) => property in row);\n\n if (named.length === 0) {\n return;\n }\n\n const denied = ScopeWriteGuard.parentDenied({\n model: this.entity.name,\n operation,\n column: property,\n });\n const keys = [...new Set(named.map((row) => row[property]))];\n const isUnresolved = scope === null || scope === undefined;\n\n if (keys.some((key) => key === null || key === undefined)) {\n throw denied;\n }\n\n // A parent that resolves no scope always denies its child: there is no onMissing to open it.\n if (isUnresolved) {\n throw denied;\n }\n\n const parentScope =\n scope === ScopeFilters.UNRESTRICTED\n ? undefined\n : this.queryDialect.toParentWhere({ link, scope });\n const found = await this.queryExecutor.select<{ key: unknown }>({\n connector: this.resolveConnector({ transaction }),\n table: link.parentSchema,\n columns: { key: link.parentColumn },\n where: and(inArray(link.parentColumn, keys), parentScope),\n lock: this.queryExecutor.supportsRowLock ? { strength: LockStrengths.SHARE } : undefined,\n });\n\n // Distinct keys, not rows: a parent column that is not unique can return two rows for one key and hide a missing one.\n if (new Set(found.map((row) => row.key)).size !== keys.length) {\n throw denied;\n }\n }\n\n /**\n * Row scope from `@model` settings.access - AND-composed like a default filter, but never\n * skippable via `shouldSkipDefaultFilter`: that flag serves `restore()`'s deliberate reach past\n * soft-delete, which must not also reach past tenant/ownership scoping.\n *\n * `dangerouslySkipScopeFilter` is framework-internal only, never part of `IExtraOptions` and never\n * wire-reachable: it exists so a filter this repository already scoped (find()'s own recursive\n * call) is not scoped a second time, and for explicitly-unscoped administrative code written and\n * reviewed at the repository - never inferable from a request.\n */\n protected applyScopeFilter<DO = any>(opts: {\n userFilter?: TFilter<DO>;\n dangerouslySkipScopeFilter?: boolean;\n mutation?: TScopeOperation;\n }): TFilter<DO> {\n const { userFilter, dangerouslySkipScopeFilter, mutation } = opts;\n\n if (dangerouslySkipScopeFilter) {\n return userFilter ?? {};\n }\n\n const scopeFilterSettings = this.getAccessSettings();\n\n if (!scopeFilterSettings) {\n return userFilter ?? {};\n }\n\n const scopeWhere = this.queryDialect.resolveAccessScope({\n settings: scopeFilterSettings,\n schema: this.entity.schema,\n operation: mutation ?? ScopeOperations.READ,\n });\n\n // Checked by exact symbol identity, before the null/undefined branch below: only this literal\n // value can skip scoping. A resolver that forgets a `return` on some branch produces\n // `undefined`, which is NOT this symbol and falls through to `onMissing` (deny by default).\n if (scopeWhere === ScopeFilters.UNRESTRICTED) {\n return userFilter ?? {};\n }\n\n if (scopeWhere !== null && scopeWhere !== undefined) {\n // A write reaches only the rows it may write: the shared (null) rows a read scope allows need `write.sharedRows`.\n // A `through` scope is one foreign key set, but the parent's scope inside it can still carry a null branch: that is\n // narrowed on the hop (`resolveThrough`), so this level has nothing left to narrow.\n const effectiveWhere =\n mutation === undefined || scopeFilterSettings.through\n ? scopeWhere\n : ScopeWriteGuard.mutationWhere({\n settings: scopeFilterSettings,\n model: this.entity.name,\n operation: mutation,\n scopeWhere,\n });\n\n return this.queryDialect.mergeFilter({\n defaultFilter: { where: effectiveWhere },\n userFilter,\n });\n }\n\n if (scopeFilterSettings.onMissing === ScopeFilterMissingBehaviors.ALLOW) {\n return userFilter ?? {};\n }\n\n // 'deny' (default): an unresolved scope means the framework does not know what this caller may\n // see, and the safe reading of \"I do not know\" is \"nothing\" - never \"everything\".\n return this.queryDialect.mergeFilter({\n defaultFilter: { where: ScopeFilterDenial.where<DO>() },\n userFilter,\n });\n }\n\n /** Merges default filter with user filter. Skippable via shouldSkipDefaultFilter - the row scope from applyScopeFilter is not. */\n applyDefaultFilter<DO = any>(opts: {\n userFilter?: TFilter<DO>;\n shouldSkipDefaultFilter?: boolean;\n dangerouslySkipScopeFilter?: boolean;\n /** The name of the write (`update`, `delete`) when the filter selects rows to change: the row scope then leaves out the shared rows unless `write.sharedRows`. */\n mutation?: TScopeOperation;\n }): TFilter<DO> {\n const { userFilter, shouldSkipDefaultFilter, dangerouslySkipScopeFilter, mutation } = opts;\n\n const scopedFilter = this.applyScopeFilter<DO>({\n userFilter,\n dangerouslySkipScopeFilter,\n mutation,\n });\n\n if (shouldSkipDefaultFilter) {\n return scopedFilter;\n }\n\n const defaultFilter = this.getDefaultFilter();\n\n if (!defaultFilter) {\n return scopedFilter;\n }\n\n return this.queryDialect.mergeFilter({ defaultFilter, userFilter: scopedFilter });\n }\n\n async beginTransaction(\n opts?: TRelationalTransactionOptionsOf<TDataSource>,\n ): Promise<TRelationalTransactionOf<TDataSource>> {\n return this.dataSource.beginTransaction(opts) as Promise<TRelationalTransactionOf<TDataSource>>;\n }\n\n /**\n * Runs `execute` inside a transaction. Given a `transaction`, joins it: its owner commits or rolls\n * back, so this never does. Given none, owns one: begins it, commits when `execute` resolves, and\n * rolls back when `execute` or the commit throws - rethrowing the original error either way. An\n * owned transaction that `execute` already ended is never ended a second time.\n */\n async runInTransaction<ResultType>(opts: {\n transaction?: TRelationalTransactionOf<TDataSource>;\n transactionOptions?: TRelationalTransactionOptionsOf<TDataSource>;\n execute: (opts: { transaction: TRelationalTransactionOf<TDataSource> }) => Promise<ResultType>;\n }): Promise<ResultType> {\n const { transaction, transactionOptions, execute } = opts;\n\n if (transaction) {\n if (!transaction.isActive) {\n throw getError({\n message: `[${this.constructor.name}][runInTransaction] Transaction is no longer active`,\n });\n }\n\n if (transactionOptions) {\n this.logger\n .for('runInTransaction')\n .debug('Joined transaction | transactionOptions ignored: %j', transactionOptions);\n }\n\n return execute({ transaction });\n }\n\n const ownedTransaction = await this.beginTransaction(transactionOptions);\n\n let result: ResultType;\n\n try {\n const result2 = await execute({ transaction: ownedTransaction });\n result = result2;\n } catch (error) {\n if (ownedTransaction.isActive) {\n await this.rollbackOwnedTransaction({ transaction: ownedTransaction });\n }\n\n throw error;\n }\n\n if (!ownedTransaction.isActive) {\n return this.resolveEndedByExecute({ transaction: ownedTransaction, result });\n }\n\n try {\n await ownedTransaction.commit();\n } catch (error) {\n await this.rollbackOwnedTransaction({ transaction: ownedTransaction });\n throw error;\n }\n\n return result;\n }\n\n /** `execute` resolved after ending the owned transaction itself: its work stands only if it committed. */\n private resolveEndedByExecute<ResultType>(opts: {\n transaction: ITransaction;\n result: ResultType;\n }): ResultType {\n const { transaction, result } = opts;\n\n if (TransactionLifecycle.isCommitted({ transaction })) {\n this.logger\n .for('runInTransaction')\n .warn('execute committed the owned transaction itself | Skipped the commit');\n\n return result;\n }\n\n throw getError({\n message: `[${this.constructor.name}][runInTransaction] execute ended the owned transaction before it could be committed`,\n });\n }\n\n /** A rollback failure is only logged: the caller needs the error that made the rollback necessary. */\n private async rollbackOwnedTransaction(opts: { transaction: ITransaction }): Promise<void> {\n try {\n await opts.transaction.rollback();\n } catch (rollbackError) {\n this.logger\n .for('runInTransaction')\n .error(\n 'Rollback failed, rethrowing the original error | Rollback error: %s',\n rollbackError,\n );\n }\n }\n\n /** Builds Drizzle query options from a filter, excluding hidden properties. */\n buildQuery(opts: { filter: TFilter<DataObject> }): TDrizzleQueryOptions {\n const result = this.queryDialect.build({\n tableName: this.entity.name,\n schema: this.entity.schema,\n // The dialect reads the filter against the table object; `DataObject` is the same row.\n filter: opts.filter as TFilter,\n });\n\n if (!this.hasHiddenProperties()) {\n return result;\n }\n\n const hiddenProps = this.getHiddenProperties();\n\n if (result.columns) {\n result.columns = this.omitHiddenColumns({ columns: result.columns, hiddenProps });\n\n return result;\n }\n\n const visibleProps = this.getVisibleProperties();\n\n if (visibleProps) {\n const filteredColumns: Record<string, boolean> = {};\n\n for (const key in visibleProps) {\n filteredColumns[key] = true;\n }\n\n result.columns = filteredColumns;\n }\n\n return result;\n }\n\n /** Copy of a Drizzle column selection with hidden properties dropped. */\n private omitHiddenColumns(opts: {\n columns: Record<string, boolean>;\n hiddenProps: Set<string>;\n }): Record<string, boolean> {\n const { columns, hiddenProps } = opts;\n const filteredColumns: Record<string, boolean> = {};\n\n for (const key in columns) {\n if (hiddenProps.has(key)) {\n continue;\n }\n\n filteredColumns[key] = columns[key];\n }\n\n return filteredColumns;\n }\n\n /** Resolves the database connector, using the transaction's connector if provided. */\n protected resolveConnector(opts?: {\n transaction?: ITransaction;\n }): TRelationalConnectorOf<TDataSource> {\n const { transaction } = opts ?? {};\n\n if (!transaction) {\n return this.dataSource.getConnector() as TRelationalConnectorOf<TDataSource>;\n }\n\n if (!transaction.isActive) {\n throw getError({\n message: `[${this.constructor.name}][resolveConnector] Transaction is no longer active`,\n });\n }\n\n if (!isRelationalTransaction(transaction)) {\n throw getError({\n message: `[${this.constructor.name}][resolveConnector] Transaction is not a relational transaction`,\n });\n }\n\n return transaction.connector as TRelationalConnectorOf<TDataSource>;\n }\n\n /** Validates lock options: requires transaction, incompatible with Query API (include/fields). */\n protected validateLockOptions(opts: {\n lock?: TLockOptions;\n transaction?: ITransaction;\n usesQueryAPI?: boolean;\n }): void {\n if (!opts.lock) {\n return;\n }\n\n if (!opts.transaction) {\n throw getError({\n message: `[${this.constructor.name}][validateLockOptions] Row-level locking requires a transaction`,\n });\n }\n\n if (opts.usesQueryAPI) {\n throw getError({\n message: `[${this.constructor.name}][validateLockOptions] Row-level locking is incompatible with Query API`,\n });\n }\n }\n\n abstract override count(opts: {\n where: TWhere<DataObject>;\n options?: ExtraOptions;\n }): Promise<TCount>;\n\n abstract override existsWith(opts: {\n where: TWhere<DataObject>;\n options?: ExtraOptions;\n }): Promise<boolean>;\n\n abstract override find<\n R = unknown,\n const F extends TFields<DataObject> = TFields<DataObject>,\n >(opts: {\n filter: TFilter<DataObject, F>;\n options: TFindRangeOptions<ExtraOptions, TRow<DataObject, R, F>>;\n }): Promise<{ data: Array<TRow<DataObject, R, F>>; range: TDataRange }>;\n\n abstract override find<\n R = unknown,\n const F extends TFields<DataObject> = TFields<DataObject>,\n >(opts: {\n filter: TFilter<DataObject, F>;\n options?: TFindOptions<ExtraOptions, TRow<DataObject, R, F>>;\n }): Promise<Array<TRow<DataObject, R, F>>>;\n\n abstract override findOne<\n R = unknown,\n const F extends TFields<DataObject> = TFields<DataObject>,\n >(opts: {\n filter: TFilter<DataObject, F>;\n options?: TFindOneOptions<ExtraOptions, TRow<DataObject, R, F>>;\n }): Promise<TNullable<TRow<DataObject, R, F>>>;\n\n abstract override findById<\n R = unknown,\n const F extends TFields<DataObject> = TFields<DataObject>,\n >(opts: {\n id: IdType;\n filter?: TByIdFilter<DataObject, F>;\n options?: TFindOneOptions<ExtraOptions, TRow<DataObject, R, F>>;\n }): Promise<TNullable<TRow<DataObject, R, F>>>;\n\n abstract override create(opts: {\n data: PersistObject;\n options: ExtraOptions & { shouldReturn: false };\n }): Promise<TCount & { data: undefined | null }>;\n\n abstract override create<R = DataObject>(opts: {\n data: PersistObject;\n options?: ExtraOptions & { shouldReturn?: true };\n }): Promise<TCount & { data: R }>;\n\n abstract override createAll(opts: {\n data: Array<PersistObject>;\n options: ExtraOptions & { shouldReturn: false };\n }): Promise<TCount & { data: undefined | null }>;\n\n abstract override createAll<R = DataObject>(opts: {\n data: Array<PersistObject>;\n options?: ExtraOptions & { shouldReturn?: true };\n }): Promise<TCount & { data: Array<R> }>;\n\n abstract override updateById(opts: {\n id: IdType;\n data: Partial<PersistObject>;\n options: ExtraOptions & { shouldReturn: false };\n }): Promise<TCount & { data: undefined | null }>;\n\n abstract override updateById<R = DataObject>(opts: {\n id: IdType;\n data: Partial<PersistObject>;\n options?: ExtraOptions & { shouldReturn?: true };\n }): Promise<TCount & { data: R }>;\n\n abstract override updateAll(opts: {\n data: Partial<PersistObject>;\n where: TWhere<DataObject>;\n options: ExtraOptions & { shouldReturn: false; force?: boolean };\n }): Promise<TCount & { data: undefined | null }>;\n\n abstract override updateAll<R = DataObject>(opts: {\n data: Partial<PersistObject>;\n where: TWhere<DataObject>;\n options?: ExtraOptions & { shouldReturn?: true; force?: boolean };\n }): Promise<TCount & { data: Array<R> }>;\n\n // Re-declared, not inherited: the base alias is `Array<R> | null` to cover the search family, but SQL engines have RETURNING so this surface must stay exactly `Array<R>`.\n override updateBy(opts: {\n data: Partial<PersistObject>;\n where: TWhere<DataObject>;\n options: ExtraOptions & { shouldReturn: false; force?: boolean };\n }): Promise<TCount & { data: undefined | null }>;\n override updateBy<R = DataObject>(opts: {\n data: Partial<PersistObject>;\n where: TWhere<DataObject>;\n options?: ExtraOptions & { shouldReturn?: true; force?: boolean };\n }): Promise<TCount & { data: Array<R> }>;\n override updateBy<R = DataObject>(opts: {\n data: Partial<PersistObject>;\n where: TWhere<DataObject>;\n options?: ExtraOptions & { shouldReturn?: boolean; force?: boolean };\n }): Promise<TCount & { data: TNullable<Array<R>> }> {\n const { data, where, options } = opts;\n\n if (options?.shouldReturn === false) {\n return this.updateAll({ data, where, options: { ...options, shouldReturn: false } });\n }\n\n return this.updateAll<R>({ data, where, options });\n }\n\n abstract override deleteById(opts: {\n id: IdType;\n options: ExtraOptions & { shouldReturn: false };\n }): Promise<TCount & { data: undefined | null }>;\n\n abstract override deleteById<R = DataObject>(opts: {\n id: IdType;\n options?: ExtraOptions & { shouldReturn?: true };\n }): Promise<TCount & { data: R }>;\n\n abstract override deleteAll(opts: {\n where?: TWhere<DataObject>;\n options: ExtraOptions & { shouldReturn: false; force?: boolean };\n }): Promise<TCount & { data: undefined | null }>;\n\n abstract override deleteAll<R = DataObject>(opts: {\n where?: TWhere<DataObject>;\n options?: ExtraOptions & { shouldReturn?: true; force?: boolean };\n }): Promise<TCount & { data: Array<R> }>;\n\n // Same rationale as updateBy above: keep this alias surface at `Array<R>`.\n override deleteBy(opts: {\n where?: TWhere<DataObject>;\n options: ExtraOptions & { shouldReturn: false; force?: boolean };\n }): Promise<TCount & { data: undefined | null }>;\n override deleteBy<R = DataObject>(opts: {\n where?: TWhere<DataObject>;\n options?: ExtraOptions & { shouldReturn?: true; force?: boolean };\n }): Promise<TCount & { data: Array<R> }>;\n override deleteBy<R = DataObject>(opts: {\n where?: TWhere<DataObject>;\n options?: ExtraOptions & { shouldReturn?: boolean; force?: boolean };\n }): Promise<TCount & { data: TNullable<Array<R>> }> {\n const { where, options } = opts;\n\n if (options?.shouldReturn === false) {\n return this.deleteAll({ where, options: { ...options, shouldReturn: false } });\n }\n\n return this.deleteAll<R>({ where, options });\n }\n}\n"]}
|
|
@@ -69,7 +69,8 @@ export declare abstract class FilterBuilder extends BaseHelper {
|
|
|
69
69
|
}): TModelAccessSettings | undefined;
|
|
70
70
|
/**
|
|
71
71
|
* The foreign key link of a `through` model and the scope its parent resolves for `operation` (the same operation
|
|
72
|
-
* at every hop). The parent's default filter is not applied: scope only.
|
|
72
|
+
* at every hop). The parent's default filter is not applied: scope only. For a write the parent's scope is narrowed as a
|
|
73
|
+
* direct write to the parent is (`ScopeWriteGuard.mutationWhere`), so its `write.sharedRows` holds on the hop.
|
|
73
74
|
*/
|
|
74
75
|
resolveThrough(opts: {
|
|
75
76
|
settings: IModelAccessThroughSettings;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { EchoUtility } from '../../../../common/internal/index.js';
|
|
2
2
|
import { ScopeThroughLink } from '../common/scope-through.js';
|
|
3
|
+
import { ScopeWriteGuard } from '../common/scope-write-guard.js';
|
|
3
4
|
import { DEFAULT_LIMIT, QueryOperators, RelationTypes, ScopeFilterMissingBehaviors, ScopeFilters, ScopeOperations, Sorts, } from '@venizia/ignis-kernel';
|
|
4
5
|
import { BaseHelper, getError } from '@venizia/ignis-helpers/core';
|
|
5
6
|
import { ObjectUtility } from '@venizia/ignis-helpers/common';
|
|
@@ -160,7 +161,8 @@ export class FilterBuilder extends BaseHelper {
|
|
|
160
161
|
}
|
|
161
162
|
/**
|
|
162
163
|
* The foreign key link of a `through` model and the scope its parent resolves for `operation` (the same operation
|
|
163
|
-
* at every hop). The parent's default filter is not applied: scope only.
|
|
164
|
+
* at every hop). The parent's default filter is not applied: scope only. For a write the parent's scope is narrowed as a
|
|
165
|
+
* direct write to the parent is (`ScopeWriteGuard.mutationWhere`), so its `write.sharedRows` holds on the hop.
|
|
164
166
|
*/
|
|
165
167
|
resolveThrough(opts) {
|
|
166
168
|
const { settings, schema, operation, depth = 1 } = opts;
|
|
@@ -180,12 +182,27 @@ export class FilterBuilder extends BaseHelper {
|
|
|
180
182
|
message: `[resolveThrough] ${getTableName(link.parentSchema)} has no access setting, so ${getTableName(schema)} cannot be scoped through it`,
|
|
181
183
|
});
|
|
182
184
|
}
|
|
183
|
-
const
|
|
185
|
+
const parentScope = this.resolveAccessScope({
|
|
184
186
|
settings: parentSettings,
|
|
185
187
|
schema: link.parentSchema,
|
|
186
188
|
operation,
|
|
187
189
|
depth: depth + 1,
|
|
188
190
|
});
|
|
191
|
+
// A write to the child reaches the parent the way a write to the parent itself does: the shared (null) rows its read scope
|
|
192
|
+
// opens need the parent's `write.sharedRows`. A parent that is itself `through` narrowed its own parent on its hop.
|
|
193
|
+
const isNarrowed = ScopeOperations.includes({ group: ScopeOperations.WRITE, operation }) &&
|
|
194
|
+
!parentSettings.through &&
|
|
195
|
+
parentScope !== ScopeFilters.UNRESTRICTED &&
|
|
196
|
+
parentScope !== null &&
|
|
197
|
+
parentScope !== undefined;
|
|
198
|
+
const scope = isNarrowed
|
|
199
|
+
? ScopeWriteGuard.mutationWhere({
|
|
200
|
+
settings: parentSettings,
|
|
201
|
+
model: getTableName(link.parentSchema),
|
|
202
|
+
operation,
|
|
203
|
+
scopeWhere: parentScope,
|
|
204
|
+
})
|
|
205
|
+
: parentScope;
|
|
189
206
|
return { link, scope };
|
|
190
207
|
}
|
|
191
208
|
/** The parent's scope as a `where` on the parent table: the part both the read subquery and the write check build. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"filter.js","sourceRoot":"","sources":["../../../../../../src/relational/core/repositories/dialect/filter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAc3D,OAAO,EACL,aAAa,EACb,cAAc,EACd,aAAa,EACb,2BAA2B,EAC3B,YAAY,EACZ,eAAe,EACf,KAAK,GACN,MAAM,uBAAuB,CAAC;AAI/B,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;A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C5E,CAAC,CAAC,eAAe;gBACjB,CAAC,CAAC,QAAQ,CAAC;YAEb,MAAM,MAAM,GAAG,IAAI,CAAC,EAAE,MAAM,EAAE,UAAU,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC,CAAC;YAE5D,IAAI,MAAM,EAAE,CAAC;gBACX,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;YAC1B,CAAC;QACH,CAAC;QAED,OAAO,UAAU,CAAC;IACpB,CAAC;CAYF","sourcesContent":["import { EchoUtility } from '@/common/internal';\nimport { ScopeThroughLink } from '../common/scope-through';\nimport type {\n TDrizzleQueryOptions,\n TFields,\n TFilter,\n TInclusion,\n IModelAccessThroughSettings,\n TModelAccessSettings,\n TParsedOrderEntry,\n TQueryOperatorHandlers,\n TScopeOperation,\n TSortDirection,\n TWhere,\n} from '@venizia/ignis-kernel';\nimport {\n DEFAULT_LIMIT,\n QueryOperators,\n RelationTypes,\n ScopeFilterMissingBehaviors,\n ScopeFilters,\n ScopeOperations,\n Sorts,\n} from '@venizia/ignis-kernel';\nimport type { TTableObject, TTableSchemaWithId } from '@/relational/core/models/common';\nimport { type MetadataRegistry } from '@venizia/ignis-kernel';\nimport type { TConstValue, TNullable } from '@venizia/ignis-helpers/common';\nimport { BaseHelper, getError } from '@venizia/ignis-helpers/core';\nimport { ObjectUtility } from '@venizia/ignis-helpers/common';\nimport {\n and,\n asc,\n desc,\n eq,\n getTableName,\n inArray,\n isNull,\n not,\n or,\n sql,\n type AnyColumn,\n type SQL,\n type SQLWrapper,\n} from 'drizzle-orm';\nimport type { TRelationConfig, TTableColumns } from '../common';\nimport { ScopeFilterDenial, TableColumnCache } from '../common';\nimport { JsonPathUtility } from './internal';\n\n/** Operators whose scalar operand determines the JSON numeric-cast need in jsonNeedsNumericCast. */\n/** What one registry lookup yields - named so the three setting readers can accept an already-resolved entry instead of each repeating the lookup. */\ntype TResolvedModelEntry = ReturnType<MetadataRegistry['getModelEntry']>;\n\n/** Most order entries an instance remembers; entries come from requests, so the cache is bounded. */\nconst ORDER_ENTRY_CACHE_CAP = 1024;\n\n/** Longest order entry the cache keeps, so its memory is bounded by bytes as well as by count. */\nconst ORDER_ENTRY_CACHE_MAX_LENGTH = 256;\n\nconst SCALAR_EQUALITY_OPERATORS = new Set<string>([\n QueryOperators.EQ,\n QueryOperators.NE,\n QueryOperators.NEQ,\n]);\n\n/** Operators whose array operand determines the JSON numeric-cast need in jsonNeedsNumericCast. */\nconst MEMBERSHIP_OPERATORS = new Set<string>([\n QueryOperators.IN,\n QueryOperators.INQ,\n QueryOperators.NIN,\n]);\n\n/**\n * Converts filter objects into Drizzle query options (where, order, columns, relations). The\n * operator table and both JSON extractions are abstract rather than defaulted, so this tier\n * emits no engine-specific SQL.\n */\n// No `implements IRelationalQueryDialect` here: that clause belongs on each engine's query dialect,\n// which adds the JSON-path update methods.\nexport abstract class FilterBuilder extends BaseHelper {\n /**\n * Per-schema memo of resolved relations. `@model` settings are\n * immutable after boot, so the lookup and resolver run once per schema.\n */\n private readonly _relationsCache = new WeakMap<\n TTableSchemaWithId,\n Record<string, TRelationConfig>\n >();\n\n /** `asc`/`desc` allocate an SQL node (~75 ns) that drizzle never mutates - built once per column or expression. */\n private readonly _orderNodeCache = new WeakMap<AnyColumn | SQLWrapper, { asc: SQL; desc: SQL }>();\n\n /** A freshly sliced field is hashed again on every column lookup; a remembered one is hashed once. */\n private readonly _orderEntryCache = new Map<string, TParsedOrderEntry>();\n\n constructor() {\n super({ scope: FilterBuilder.name });\n }\n\n /** Handler table for `where` translation. Abstract so this class names no engine. */\n protected abstract get operators(): TQueryOperatorHandlers;\n\n /**\n * Merges default and user filters. `where` merges at the TOP KEY LEVEL, never index-wise - that\n * corrupts operator arrays. Operator-object collisions AND-compose, so a default scope can only\n * be narrowed, and a user `undefined` never overrides a defined default. Other parts user-wins.\n */\n mergeFilter<T = any>(opts: { defaultFilter?: TFilter<T>; userFilter?: TFilter<T> }): TFilter<T> {\n const { defaultFilter, userFilter } = opts;\n\n if (!defaultFilter) {\n return userFilter ?? {};\n }\n\n if (!userFilter) {\n return { ...defaultFilter };\n }\n\n const defaultWhere = defaultFilter.where;\n const userWhere = userFilter.where;\n let mergedWhere: TWhere<T> | undefined;\n\n if (defaultWhere && userWhere) {\n mergedWhere = this.mergeWhere({ defaultWhere, userWhere });\n } else {\n mergedWhere = userWhere ?? defaultWhere;\n }\n\n return {\n where: mergedWhere,\n order: userFilter.order ?? defaultFilter.order,\n limit: userFilter.limit ?? defaultFilter.limit,\n offset: userFilter.offset ?? defaultFilter.offset,\n skip: userFilter.skip ?? defaultFilter.skip,\n fields: userFilter.fields ?? defaultFilter.fields,\n include: userFilter.include ?? defaultFilter.include,\n };\n }\n\n /**\n * Top-key merge: operator-object collisions AND-compose under the reserved `and` key, merging\n * with an existing `and` rather than clobbering it. Every other collision is user-wins.\n */\n private mergeWhere<T = any>(opts: { defaultWhere: TWhere<T>; userWhere: TWhere<T> }): TWhere<T> {\n const { defaultWhere, userWhere } = opts;\n\n // Read by runtime key, which the column-keyed `TWhere<T>` does not index.\n const defaults: TWhere = defaultWhere;\n const users: TWhere = userWhere;\n\n const merged: TWhere = { ...defaultWhere };\n const composed: TWhere[] = [];\n\n for (const key in users) {\n const userValue = users[key];\n\n if (userValue === undefined) {\n continue;\n }\n\n const defaultValue = defaults[key];\n\n // Scalar-over-scalar is a plain override - the soft-delete opt-out. Everything else\n // AND-composes, so a user operator object cannot swallow a scalar default.\n const isCollision = defaultValue !== undefined;\n\n // `and`/`or` are how a SCOPE is written and both sides are arrays, which `isPrimitiveValue`\n // counts as scalar - without these branches the caller's group replaces the default outright.\n if (isCollision && key === QueryOperators.AND) {\n // Both conjunct lists must hold: concatenating them IS the AND of the two groups.\n merged.and = [...defaultValue, ...userValue];\n continue;\n }\n\n if (isCollision && key === QueryOperators.OR) {\n // Two disjunctions cannot be concatenated - that would UNION them, widening\n // the query. Each group has to hold on its own, so they become two conjuncts.\n delete merged[key];\n composed.push({ [key]: defaultValue }, { [key]: userValue });\n continue;\n }\n\n const isScalarOverride =\n !this.isOperatorObject({ value: defaultValue }) &&\n !this.isOperatorObject({ value: userValue });\n\n if (isCollision && !isScalarOverride) {\n delete merged[key];\n composed.push({ [key]: defaultValue }, { [key]: userValue });\n continue;\n }\n\n merged[key] = userValue;\n }\n\n if (composed.length) {\n merged.and = merged.and ? [...merged.and, ...composed] : composed;\n }\n\n return merged as TWhere<T>;\n }\n\n /**\n * Registry lookup shared by the resolvers below. A failure degrades to no settings rather than\n * failing the query, and is never silent - a degraded `resolveHiddenProperties` would stop\n * hidden columns being omitted.\n */\n private resolveModelEntry(opts: { schema: TTableSchemaWithId; methodName: string }) {\n const { schema, methodName } = opts;\n\n try {\n return ScopeThroughLink.entryOf({ schema });\n } catch (error) {\n this.logger.warn(\n '[%s] Model metadata lookup failed - continuing without model settings | %s',\n methodName,\n error,\n );\n\n return undefined;\n }\n }\n\n /**\n * Resolves hidden properties from the relation's SCHEMA object, falling back to its SQL table name -\n * `toInclude` has the schema and no class reference. A table claimed by two models answers by name\n * only, since the schema no longer names one of them.\n */\n resolveHiddenProperties(opts: {\n schema: TTableSchemaWithId;\n modelEntry?: TResolvedModelEntry;\n }): Set<string> {\n const modelEntry =\n opts.modelEntry ??\n this.resolveModelEntry({ schema: opts.schema, methodName: 'resolveHiddenProperties' });\n\n return new Set(modelEntry?.metadata?.settings?.hiddenProperties ?? []);\n }\n\n /** Resolves default filter for a schema from MetadataRegistry. */\n resolveDefaultFilter(opts: {\n schema: TTableSchemaWithId;\n modelEntry?: TResolvedModelEntry;\n }): TFilter | undefined {\n const modelEntry =\n opts.modelEntry ??\n this.resolveModelEntry({ schema: opts.schema, methodName: 'resolveDefaultFilter' });\n\n return modelEntry?.metadata?.settings?.query?.filter;\n }\n\n /** Resolves row-scope settings for a schema from MetadataRegistry - the relation's OWN `@model` entry, never the parent's. */\n resolveScopeFilter(opts: {\n schema: TTableSchemaWithId;\n modelEntry?: TResolvedModelEntry;\n }): TModelAccessSettings | undefined {\n const modelEntry =\n opts.modelEntry ??\n this.resolveModelEntry({ schema: opts.schema, methodName: 'resolveScopeFilter' });\n\n return modelEntry?.metadata?.settings?.access;\n }\n\n /**\n * The foreign key link of a `through` model and the scope its parent resolves for `operation` (the same operation\n * at every hop). The parent's default filter is not applied: scope only.\n */\n resolveThrough(opts: {\n settings: IModelAccessThroughSettings;\n schema: TTableSchemaWithId;\n operation: TScopeOperation;\n depth?: number;\n }): {\n link: ReturnType<typeof ScopeThroughLink.of>;\n scope: TNullable<TWhere> | typeof ScopeFilters.UNRESTRICTED;\n } {\n const { settings, schema, operation, depth = 1 } = opts;\n\n if (depth > ScopeThroughLink.MAX_DEPTH) {\n throw getError({\n message: `[resolveThrough] access.through is deeper than ${ScopeThroughLink.MAX_DEPTH} hops at ${getTableName(schema)}`,\n });\n }\n\n const link = ScopeThroughLink.of({\n schema,\n relation: settings.through.relation,\n relations: this.resolveRelations({ schema }),\n });\n const parentSettings = link.parentEntry?.metadata?.settings?.access;\n\n if (!parentSettings) {\n throw getError({\n message: `[resolveThrough] ${getTableName(link.parentSchema)} has no access setting, so ${getTableName(schema)} cannot be scoped through it`,\n });\n }\n\n const scope = this.resolveAccessScope({\n settings: parentSettings,\n schema: link.parentSchema,\n operation,\n depth: depth + 1,\n });\n\n return { link, scope };\n }\n\n /** The parent's scope as a `where` on the parent table: the part both the read subquery and the write check build. */\n toParentWhere(opts: { link: ReturnType<typeof ScopeThroughLink.of>; scope: TWhere }) {\n const { link, scope } = opts;\n\n return this.toWhere({\n tableName: getTableName(link.parentSchema),\n schema: link.parentSchema,\n where: scope,\n });\n }\n\n /**\n * The scope of a model for one call. A `through` model keeps the child rows whose foreign key is in the set of\n * parent keys the parent's scope allows: `child.fk IN (SELECT parent.pk FROM parent WHERE <parent scope>)`, built with\n * the existing `inSql` operator.\n */\n resolveAccessScope(opts: {\n settings: TModelAccessSettings;\n schema: TTableSchemaWithId;\n operation: TScopeOperation;\n depth?: number;\n }): TNullable<TWhere> | typeof ScopeFilters.UNRESTRICTED {\n const { settings, schema, operation, depth } = opts;\n\n if (!settings.through) {\n return settings.resolve({ operation });\n }\n\n const { link, scope } = this.resolveThrough({ settings, schema, operation, depth });\n\n if (scope === ScopeFilters.UNRESTRICTED || scope === null || scope === undefined) {\n return scope;\n }\n\n const where = this.toParentWhere({ link, scope });\n const keys = sql`select ${link.parentColumn} from ${link.parentSchema}`;\n const subquery = where ? sql`${keys} where ${where}` : keys;\n\n // Opaque on purpose: drizzle's relational query rewrites every column it finds in a `where` to the relation's alias,\n // the parent's columns inside this subquery included. A wrapper it does not look into keeps them qualified.\n return { [link.childProperty]: { inSql: { getSQL: () => subquery } } };\n }\n\n /**\n * Row scope for an included relation, mirroring `applyScopeFilter` in the repository tier\n * exactly: unconditional - never gated by `shouldSkipDefaultFilter` - and deny-by-default when\n * `resolve()` cannot determine a scope. A throwing `resolve()` is never caught here, so it\n * propagates the same way it does on the parent.\n */\n private applyRelationScopeFilter(opts: {\n userFilter?: TFilter;\n scopeFilterSettings?: TModelAccessSettings;\n schema: TTableSchemaWithId;\n }): TFilter {\n const { userFilter, scopeFilterSettings, schema } = opts;\n\n if (!scopeFilterSettings) {\n return userFilter ?? {};\n }\n\n const scopeWhere = this.resolveAccessScope({\n settings: scopeFilterSettings,\n schema,\n operation: ScopeOperations.READ,\n });\n\n // Same ordering as the repository tier's `applyScopeFilter`: exact symbol identity, checked\n // before null/undefined, so a forgotten `return` (which produces `undefined`) still denies\n // rather than un-scoping this relation. Each relation resolves its OWN `scopeFilterSettings`, so\n // an unrestricted parent never widens a still-scoped child, and vice versa.\n if (scopeWhere === ScopeFilters.UNRESTRICTED) {\n return userFilter ?? {};\n }\n\n if (scopeWhere !== null && scopeWhere !== undefined) {\n return this.mergeFilter({ defaultFilter: { where: scopeWhere }, userFilter });\n }\n\n if (scopeFilterSettings.onMissing === ScopeFilterMissingBehaviors.ALLOW) {\n return userFilter ?? {};\n }\n\n return this.mergeFilter({ defaultFilter: { where: ScopeFilterDenial.where() }, userFilter });\n }\n\n /** Resolves default row limit for a schema from MetadataRegistry. */\n resolveDefaultLimit(opts: {\n schema: TTableSchemaWithId;\n modelEntry?: TResolvedModelEntry;\n }): number | undefined {\n const modelEntry =\n opts.modelEntry ??\n this.resolveModelEntry({ schema: opts.schema, methodName: 'resolveDefaultLimit' });\n\n return modelEntry?.metadata?.settings?.query?.limit?.default;\n }\n\n /** Resolves relation configurations for a schema from MetadataRegistry. Memoized per schema. */\n resolveRelations(opts: { schema: TTableSchemaWithId }): Record<string, TRelationConfig> {\n const { schema } = opts;\n\n const cached = this._relationsCache.get(schema);\n\n if (cached) {\n return cached;\n }\n\n const resolved = this.resolveRelationsUncached({ schema });\n this._relationsCache.set(schema, resolved);\n\n return resolved;\n }\n\n private resolveRelationsUncached(opts: {\n schema: TTableSchemaWithId;\n }): Record<string, TRelationConfig> {\n const { schema } = opts;\n const modelEntry = this.resolveModelEntry({ schema, methodName: 'resolveRelationsUncached' });\n\n if (!modelEntry?.relationsResolver) {\n return {};\n }\n\n try {\n return ScopeThroughLink.relationsOf({ entry: modelEntry });\n } catch (error) {\n this.logger.warn(\n '[resolveRelationsUncached] Relations resolver failed - continuing without relations | %s',\n error,\n );\n\n return {};\n }\n }\n\n /** Builds Drizzle query options from a filter object. */\n build<Schema extends TTableSchemaWithId>(opts: {\n tableName: string;\n schema: Schema;\n filter: TFilter<TTableObject<Schema>>;\n }): TDrizzleQueryOptions {\n if (!opts.filter) {\n return {};\n }\n\n const { tableName, schema, filter } = opts;\n const { limit, skip, offset, order, fields, where, include } = filter;\n\n const effectiveOffset = skip ?? offset;\n\n return {\n ...(limit !== undefined && { limit }),\n ...(effectiveOffset !== undefined && { offset: effectiveOffset }),\n ...(fields && { columns: this.toColumns({ fields }) }),\n ...(order && { orderBy: this.toOrderBy({ tableName, schema, order }) }),\n ...(where && { where: this.toWhere({ tableName, schema, where }) }),\n ...(include && {\n with: this.toInclude({ include, relations: this.resolveRelations({ schema }) }),\n }),\n };\n }\n\n /** Converts fields selection to Drizzle columns format. */\n toColumns(opts: { fields: TFields }): Record<string, boolean> {\n const { fields } = opts;\n const result: Record<string, boolean> = {};\n\n if (Array.isArray(fields)) {\n for (const field of fields) {\n // Plain assignment, not `lodash/set`: drizzle's `columns` is a FLAT map of column name to\n // boolean, so a dotted field would have nested into a shape it cannot read anyway.\n // `String`, because `keyof any` admits a symbol and drizzle keys by name - which is what\n // `lodash/set` did internally with every path part anyway.\n result[String(field)] = true;\n }\n\n return result;\n }\n\n for (const key in fields) {\n if (fields[key] === true) {\n result[key] = true;\n }\n }\n\n return result;\n }\n\n /**\n * Converts a where clause to a Drizzle SQL condition (supports operators, JSON paths, AND/OR).\n */\n toWhere<Schema extends TTableSchemaWithId>(opts: {\n tableName: string;\n schema: Schema;\n where: TWhere<TTableObject<Schema>>;\n }): SQL | undefined {\n const { tableName, schema, where } = opts;\n const columns = this.getColumns(schema);\n\n if (!columns || ObjectUtility.isEmpty({ value: columns })) {\n throw getError({\n message: `[FilterBuilder][toWhere] Table: ${tableName} | Failed to get table columns`,\n });\n }\n\n const conditions: SQL[] = [];\n\n for (const key in where) {\n const value = where[key];\n\n if (value === undefined) {\n continue;\n }\n\n conditions.push(...this.buildWhereKeyConditions({ key, value, columns, tableName, schema }));\n }\n\n if (conditions.length === 0) {\n return undefined;\n }\n\n return conditions.length === 1 ? conditions[0] : and(...conditions);\n }\n\n /**\n * Conditions contributed by a single where key: a logical\n * group, a JSON path, a bare value or an operator object.\n */\n private buildWhereKeyConditions<Schema extends TTableSchemaWithId>(opts: {\n key: string;\n value: any;\n columns: TTableColumns;\n tableName: string;\n schema: Schema;\n }): SQL[] {\n const { key, value, columns, tableName, schema } = opts;\n\n if (QueryOperators.LOGICAL_GROUP_OPERATORS.has(key)) {\n const condition = this.buildLogicalGroupCondition({ key, value, tableName, schema });\n\n return condition ? [condition] : [];\n }\n\n if (JsonPathUtility.isJsonPath({ key })) {\n return this.buildJsonWhereCondition({ key, value, columns, tableName });\n }\n\n const column = columns[key];\n\n if (!column) {\n throw getError({\n message: `[FilterBuilder][toWhere] Table: ${tableName} | Column NOT FOUND | key: '${EchoUtility.toSafeEcho({ value: key })}'`,\n });\n }\n\n if (!this.isOperatorObject({ value })) {\n return [this.buildValueCondition({ column, value })];\n }\n\n return this.buildOperatorConditions({ column, value });\n }\n\n /**\n * Converts order entries to Drizzle SQL order nodes. A key resolves against `expressions` first\n * (a joined column or a computed `SQL`), then as a JSON path, then as a schema column.\n */\n toOrderBy<Schema extends TTableSchemaWithId>(opts: {\n tableName: string;\n schema: Schema;\n order: string[];\n expressions?: Readonly<Record<string, AnyColumn | SQLWrapper>>;\n }): SQL[] {\n const { tableName, schema, order, expressions } = opts;\n\n if (!Array.isArray(order) || order.length === 0) {\n return [];\n }\n\n const columns = this.getColumns(schema);\n\n const idColumn = columns.id;\n const orderBy: SQL[] = [];\n let namesId = false;\n\n for (const entry of order) {\n const { field: key, direction } = this.readOrderEntry({ entry });\n\n // The key comes from the request: an inherited name like `constructor` must not resolve.\n if (expressions && Object.hasOwn(expressions, key)) {\n orderBy.push(this.getOrderNode({ target: expressions[key], direction }));\n continue;\n }\n\n if (JsonPathUtility.isJsonPath({ key })) {\n orderBy.push(this.buildJsonOrderBy({ key, direction, columns, tableName }));\n continue;\n }\n\n const column = columns[key];\n\n if (!column) {\n throw getError({\n message: `[FilterBuilder][toOrderBy] Table: ${tableName} | Column NOT FOUND | key: '${EchoUtility.toSafeEcho({ value: key })}'`,\n });\n }\n\n namesId ||= column === idColumn;\n orderBy.push(this.getOrderNode({ target: column, direction }));\n }\n\n // A tie left to the engine is broken per page, so paging repeats and skips rows.\n if (idColumn && !namesId) {\n orderBy.push(this.getOrderNode({ target: idColumn, direction: Sorts.ASC }));\n }\n\n return orderBy;\n }\n\n private readOrderEntry(opts: { entry: string }): TParsedOrderEntry {\n const { entry } = opts;\n let parsed = this._orderEntryCache.get(entry);\n\n if (!parsed) {\n parsed = Sorts.parseEntry({ entry });\n\n if (entry.length <= ORDER_ENTRY_CACHE_MAX_LENGTH) {\n // Clearing, not evicting the oldest: deleting from the front of a JSC Map is slow.\n if (this._orderEntryCache.size >= ORDER_ENTRY_CACHE_CAP) {\n this._orderEntryCache.clear();\n }\n\n this._orderEntryCache.set(entry, parsed);\n }\n }\n\n return parsed;\n }\n\n private getOrderNode(opts: { target: AnyColumn | SQLWrapper; direction: TSortDirection }): SQL {\n const { target, direction } = opts;\n let pair = this._orderNodeCache.get(target);\n\n if (!pair) {\n pair = { asc: asc(target), desc: desc(target) };\n this._orderNodeCache.set(target, pair);\n }\n\n return direction === Sorts.DESC ? pair.desc : pair.asc;\n }\n\n /**\n * Converts include clause to Drizzle 'with' options\n * with nested filtering and hidden prop exclusion.\n */\n toInclude(opts: {\n include: TInclusion[];\n relations: { [relationName: string]: TRelationConfig };\n }): Record<string, true | TDrizzleQueryOptions> {\n const { include, relations } = opts;\n const result: Record<string, true | TDrizzleQueryOptions> = {};\n\n for (const inc of include) {\n const relationName = typeof inc === 'string' ? inc : inc.relation;\n const scope = typeof inc === 'string' ? undefined : inc.scope;\n const shouldSkipDefaultFilter = typeof inc === 'string' ? false : inc.shouldSkipDefaultFilter;\n\n if (!relationName) {\n throw getError({\n message: `[FilterBuilder][toInclude] Invalid include format | include: ${JSON.stringify(inc)}`,\n });\n }\n\n const relationConfig = relations[relationName];\n\n if (!relationConfig) {\n throw getError({\n message: `[FilterBuilder][toInclude] Relation NOT FOUND | relation: '${relationName}'`,\n });\n }\n\n // Resolved ONCE and handed to all four readers: they ask the registry the same question\n // about the same schema, and the lookup - `getTableName` plus a registry read - is the\n // measured cost of this loop, not the reads off the entry.\n const modelEntry = this.resolveModelEntry({\n schema: relationConfig.schema,\n methodName: 'toInclude',\n });\n\n const hiddenProps = this.resolveHiddenProperties({\n schema: relationConfig.schema,\n modelEntry,\n });\n\n // Row scope is this relation's OWN `@model` setting - never the parent's - and is applied\n // BEFORE `defaultFilter` so it survives `shouldSkipDefaultFilter` exactly like the parent.\n const scopeFilterSettings = this.resolveScopeFilter({\n schema: relationConfig.schema,\n modelEntry,\n });\n const scopedUserFilter = this.applyRelationScopeFilter({\n userFilter: scope,\n scopeFilterSettings,\n schema: relationConfig.schema,\n });\n\n const defaultFilter = shouldSkipDefaultFilter\n ? undefined\n : this.resolveDefaultFilter({ schema: relationConfig.schema, modelEntry });\n\n const mergedScope = this.mergeFilter({ defaultFilter, userFilter: scopedUserFilter });\n const scopedFilter: TFilter =\n relationConfig.type === RelationTypes.MANY\n ? {\n ...mergedScope,\n limit:\n mergedScope.limit ??\n this.resolveDefaultLimit({ schema: relationConfig.schema, modelEntry }) ??\n DEFAULT_LIMIT,\n }\n : mergedScope;\n\n const hasNoEffectiveFilter =\n ObjectUtility.isEmpty({ value: scopedFilter }) || Object.keys(scopedFilter).length === 0;\n\n if (hasNoEffectiveFilter && hiddenProps.size === 0) {\n result[relationName] = true;\n continue;\n }\n\n const nestedQuery = this.build<TTableSchemaWithId>({\n tableName: relationName,\n schema: relationConfig.schema,\n filter: scopedFilter,\n });\n\n if (hiddenProps.size > 0) {\n nestedQuery.columns = this.omitHiddenColumns({\n columns: nestedQuery.columns,\n schema: relationConfig.schema,\n hiddenProps,\n });\n }\n\n result[relationName] = nestedQuery;\n }\n\n return result;\n }\n\n /**\n * Column selection with hidden properties removed;\n * a nullish `columns` means \"every schema column\".\n */\n private omitHiddenColumns(opts: {\n columns?: Record<string, boolean>;\n schema: TTableSchemaWithId;\n hiddenProps: Set<string>;\n }): Record<string, boolean> {\n const { columns, schema, hiddenProps } = opts;\n const source = columns ?? TableColumnCache.get(schema);\n const filteredColumns: Record<string, boolean> = {};\n\n for (const key in source) {\n if (hiddenProps.has(key)) {\n continue;\n }\n\n filteredColumns[key] = columns ? columns[key] : true;\n }\n\n return filteredColumns;\n }\n\n private getColumns<Schema extends TTableSchemaWithId>(schema: Schema) {\n return TableColumnCache.get(schema);\n }\n\n private isPrimitiveValue(opts: { value: any }): boolean {\n const { value } = opts;\n\n return (\n value === null || Array.isArray(value) || value instanceof Date || typeof value !== 'object'\n );\n }\n\n /**\n * Protected, not private: an engine overriding `buildJsonWhereCondition` must tell an operator\n * object from a bare value, and cannot reach the base's own walk to do it.\n */\n protected isOperatorObject(opts: { value: any }): boolean {\n const { value } = opts;\n\n if (this.isPrimitiveValue({ value })) {\n return false;\n }\n\n const keys = Object.keys(value);\n\n if (keys.length === 0) {\n return false;\n }\n\n return keys.every((key) => QueryOperators.isValid(key));\n }\n\n /**\n * Builds a SQL condition for a simple value (null, array, or\n * equality). Protected for the same reason as `isOperatorObject`: an\n * overridden `buildJsonWhereCondition` needs the bare-value branch.\n */\n protected buildValueCondition(opts: { column: any; value: any }): SQL {\n const { column, value } = opts;\n\n if (value === null) {\n return isNull(column);\n }\n\n if (Array.isArray(value)) {\n return value.length === 0 ? sql`false` : inArray(column, value);\n }\n\n return eq(column, value);\n }\n\n protected buildOperatorConditions(opts: { column: any; value: Record<string, any> }): SQL[] {\n const { column, value } = opts;\n const conditions: SQL[] = [];\n\n for (const op in value) {\n // `not` recurses into a nested condition, out of reach of the static operator handlers\n // - built here where buildOperatorConditions and buildValueCondition are in scope.\n if (op === QueryOperators.NOT) {\n conditions.push(this.buildNotCondition({ column, value: value[op] }));\n continue;\n }\n\n const opFn = this.operators[op];\n\n if (!opFn) {\n throw getError({\n message: `[FilterBuilder][buildOperatorConditions] Invalid query operator | operator: '${op}'`,\n });\n }\n\n const result = opFn({ column, value: value[op] });\n\n if (result) {\n conditions.push(result);\n }\n }\n\n return conditions;\n }\n\n /**\n * Negates a nested condition: `not: <operatorObject>` recurses into the\n * operators, `not: <bareValue>` negates that value equality/array/null condition.\n */\n private buildNotCondition(opts: { column: any; value: any }): SQL {\n const { column, value } = opts;\n\n if (this.isOperatorObject({ value })) {\n const nested = this.buildOperatorConditions({ column, value });\n const combined = nested.length === 1 ? nested[0] : and(...nested)!;\n\n return not(combined);\n }\n\n return not(this.buildValueCondition({ column, value }));\n }\n\n /** Builds SQL conditions for logical groups (AND/OR). */\n private buildLogicalGroupCondition<Schema extends TTableSchemaWithId>(opts: {\n key: string;\n value: any;\n tableName: string;\n schema: Schema;\n }): SQL | undefined {\n const { key, value, tableName, schema } = opts;\n\n const clauses = (Array.isArray(value) ? value : [value])\n .map((inner) => this.toWhere({ tableName, schema, where: inner }))\n .filter((c): c is SQL => !!c);\n\n if (clauses.length === 0) {\n // An empty conjunction is vacuously TRUE so dropping it is correct, but an empty DISJUNCTION\n // is FALSE and dropping it WIDENS the query: `or: permittedOrgIds.map(...)` on an empty\n // permission list must return nothing, not everything.\n return key === QueryOperators.AND ? undefined : sql`false`;\n }\n\n return key === QueryOperators.AND ? and(...clauses)! : or(...clauses)!;\n }\n\n protected validateJsonColumn(opts: {\n key: string;\n columns: TTableColumns;\n tableName: string;\n methodName: string;\n }): { column: TTableColumns[string]; path: string[] } {\n const { key, columns, tableName, methodName } = opts;\n\n const parsed = JsonPathUtility.parseJsonPath({ key });\n\n const column = columns[parsed.columnName];\n\n if (!column) {\n throw getError({\n message: `[FilterBuilder][${methodName}] Table: ${tableName} | Column NOT FOUND | key: '${EchoUtility.toSafeEcho({ value: parsed.columnName })}'`,\n });\n }\n\n JsonPathUtility.validateJsonColumnType({\n column,\n columnName: parsed.columnName,\n tableName,\n methodName: `FilterBuilder.${methodName}`,\n });\n\n JsonPathUtility.validateJsonPathComponents({\n path: parsed.path,\n tableName,\n methodName: `FilterBuilder.${methodName}`,\n });\n\n return { column, path: parsed.path };\n }\n\n /**\n * Whether a JSON operand needs the engine's numeric extraction: numeric comparisons, eq/ne/neq\n * with a number, in/inq/nin with an all-number array. Only picks between the two fragments the\n * engine passed in, so an engine with already-typed extraction returns false.\n */\n protected jsonNeedsNumericCast(opts: { operators: Record<string, any> }): boolean {\n const { operators } = opts;\n\n if (QueryOperators.hasNumericComparison({ operators })) {\n return true;\n }\n\n for (const op in operators) {\n const operand = operators[op];\n\n if (SCALAR_EQUALITY_OPERATORS.has(op) && typeof operand === 'number') {\n return true;\n }\n\n if (\n MEMBERSHIP_OPERATORS.has(op) &&\n Array.isArray(operand) &&\n operand.length > 0 &&\n operand.every((entry) => typeof entry === 'number')\n ) {\n return true;\n }\n }\n\n return false;\n }\n\n /**\n * Emits the engine JSON extraction for one where key. Abstract because the syntax is\n * engine-owned: a default would hand the next engine one branch's SQL with no compile error.\n */\n protected abstract buildJsonWhereCondition(opts: {\n key: string;\n value: any;\n columns: TTableColumns;\n tableName: string;\n }): SQL[];\n\n /**\n * A bare JSON operand IS its operator equivalent - `isOperatorObject` counts an array\n * as primitive, so `[10, 20]` must take the same cast `{ inq: [10, 20] }` does.\n */\n protected toBareJsonOperators(opts: { value: any }): Record<string, any> {\n const { value } = opts;\n\n return Array.isArray(value) ? { [QueryOperators.INQ]: value } : { [QueryOperators.EQ]: value };\n }\n\n /**\n * The cast belongs to each OPERATOR, not the object: one object-wide cast misses the operand in\n * `{ not: { gt: 50 } }` (-> `text > integer`) and over-casts the extraction `like` shares in\n * `{ gte: 1, like: '%a%' }` (-> `numeric ~~ text`).\n */\n protected buildJsonOperatorConditions(opts: {\n jsonPath: string | SQL;\n safeNumericCast: string | SQL;\n operators: Record<string, any>;\n }): SQL[] {\n const { operators } = opts;\n // Raw text stays accepted for subclasses; wrapped once so every operator shares one fragment.\n const jsonPath = typeof opts.jsonPath === 'string' ? sql.raw(opts.jsonPath) : opts.jsonPath;\n const safeNumericCast =\n typeof opts.safeNumericCast === 'string'\n ? sql.raw(opts.safeNumericCast)\n : opts.safeNumericCast;\n const conditions: SQL[] = [];\n\n for (const op in operators) {\n const operand = operators[op];\n\n if (op === QueryOperators.NOT) {\n if (this.isOperatorObject({ value: operand })) {\n const nested = this.buildJsonOperatorConditions({\n jsonPath,\n safeNumericCast,\n operators: operand,\n });\n\n conditions.push(not(nested.length === 1 ? nested[0] : and(...nested)!));\n continue;\n }\n\n // The choice must come from `jsonNeedsNumericCast`, never a bare `typeof`: an engine that\n // neutralises the cast by overriding the predicate would still be cast through this branch.\n const negatedExtraction = this.jsonNeedsNumericCast({\n operators: this.toBareJsonOperators({ value: operand }),\n })\n ? safeNumericCast\n : jsonPath;\n\n conditions.push(\n not(this.buildValueCondition({ column: negatedExtraction, value: operand })),\n );\n continue;\n }\n\n const opFn = this.operators[op];\n\n if (!opFn) {\n throw getError({\n message: `[FilterBuilder][buildJsonOperatorConditions] Invalid query operator | operator: '${op}'`,\n });\n }\n\n const extraction = this.jsonNeedsNumericCast({ operators: { [op]: operand } })\n ? safeNumericCast\n : jsonPath;\n\n const result = opFn({ column: extraction, value: operand });\n\n if (result) {\n conditions.push(result);\n }\n }\n\n return conditions;\n }\n\n /**\n * Emits the engine's JSON extraction for one order key.\n * Abstract for the same reason as `buildJsonWhereCondition`.\n */\n protected abstract buildJsonOrderBy(opts: {\n key: string;\n direction: TConstValue<typeof Sorts>;\n columns: TTableColumns;\n tableName: string;\n }): SQL;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"filter.js","sourceRoot":"","sources":["../../../../../../src/relational/core/repositories/dialect/filter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAc9D,OAAO,EACL,aAAa,EACb,cAAc,EACd,aAAa,EACb,2BAA2B,EAC3B,YAAY,EACZ,eAAe,EACf,KAAK,GACN,MAAM,uBAAuB,CAAC;AAI/B,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AACnE,OAAO,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAC9D,OAAO,EACL,GAAG,EACH,GAAG,EACH,IAAI,EACJ,EAAE,EACF,YAAY,EACZ,OAAO,EACP,MAAM,EACN,GAAG,EACH,EAAE,EACF,GAAG,GAIJ,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,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C;YAEhC,IAAI,CAAC,IAAI,EAAE,CAAC;gBACV,MAAM,QAAQ,CAAC;oBACb,OAAO,EAAE,oFAAoF,EAAE,GAAG;iBACnG,CAAC,CAAC;YACL,CAAC;YAED,MAAM,UAAU,GAAG,IAAI,CAAC,oBAAoB,CAAC,EAAE,SAAS,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,OAAO,EAAE,EAAE,CAAC;gBAC5E,CAAC,CAAC,eAAe;gBACjB,CAAC,CAAC,QAAQ,CAAC;YAEb,MAAM,MAAM,GAAG,IAAI,CAAC,EAAE,MAAM,EAAE,UAAU,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC,CAAC;YAE5D,IAAI,MAAM,EAAE,CAAC;gBACX,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;YAC1B,CAAC;QACH,CAAC;QAED,OAAO,UAAU,CAAC;IACpB,CAAC;CAYF","sourcesContent":["import { EchoUtility } from '@/common/internal';\nimport { ScopeThroughLink } from '../common/scope-through';\nimport { ScopeWriteGuard } from '../common/scope-write-guard';\nimport type {\n TDrizzleQueryOptions,\n TFields,\n TFilter,\n TInclusion,\n IModelAccessThroughSettings,\n TModelAccessSettings,\n TParsedOrderEntry,\n TQueryOperatorHandlers,\n TScopeOperation,\n TSortDirection,\n TWhere,\n} from '@venizia/ignis-kernel';\nimport {\n DEFAULT_LIMIT,\n QueryOperators,\n RelationTypes,\n ScopeFilterMissingBehaviors,\n ScopeFilters,\n ScopeOperations,\n Sorts,\n} from '@venizia/ignis-kernel';\nimport type { TTableObject, TTableSchemaWithId } from '@/relational/core/models/common';\nimport { type MetadataRegistry } from '@venizia/ignis-kernel';\nimport type { TConstValue, TNullable } from '@venizia/ignis-helpers/common';\nimport { BaseHelper, getError } from '@venizia/ignis-helpers/core';\nimport { ObjectUtility } from '@venizia/ignis-helpers/common';\nimport {\n and,\n asc,\n desc,\n eq,\n getTableName,\n inArray,\n isNull,\n not,\n or,\n sql,\n type AnyColumn,\n type SQL,\n type SQLWrapper,\n} from 'drizzle-orm';\nimport type { TRelationConfig, TTableColumns } from '../common';\nimport { ScopeFilterDenial, TableColumnCache } from '../common';\nimport { JsonPathUtility } from './internal';\n\n/** Operators whose scalar operand determines the JSON numeric-cast need in jsonNeedsNumericCast. */\n/** What one registry lookup yields - named so the three setting readers can accept an already-resolved entry instead of each repeating the lookup. */\ntype TResolvedModelEntry = ReturnType<MetadataRegistry['getModelEntry']>;\n\n/** Most order entries an instance remembers; entries come from requests, so the cache is bounded. */\nconst ORDER_ENTRY_CACHE_CAP = 1024;\n\n/** Longest order entry the cache keeps, so its memory is bounded by bytes as well as by count. */\nconst ORDER_ENTRY_CACHE_MAX_LENGTH = 256;\n\nconst SCALAR_EQUALITY_OPERATORS = new Set<string>([\n QueryOperators.EQ,\n QueryOperators.NE,\n QueryOperators.NEQ,\n]);\n\n/** Operators whose array operand determines the JSON numeric-cast need in jsonNeedsNumericCast. */\nconst MEMBERSHIP_OPERATORS = new Set<string>([\n QueryOperators.IN,\n QueryOperators.INQ,\n QueryOperators.NIN,\n]);\n\n/**\n * Converts filter objects into Drizzle query options (where, order, columns, relations). The\n * operator table and both JSON extractions are abstract rather than defaulted, so this tier\n * emits no engine-specific SQL.\n */\n// No `implements IRelationalQueryDialect` here: that clause belongs on each engine's query dialect,\n// which adds the JSON-path update methods.\nexport abstract class FilterBuilder extends BaseHelper {\n /**\n * Per-schema memo of resolved relations. `@model` settings are\n * immutable after boot, so the lookup and resolver run once per schema.\n */\n private readonly _relationsCache = new WeakMap<\n TTableSchemaWithId,\n Record<string, TRelationConfig>\n >();\n\n /** `asc`/`desc` allocate an SQL node (~75 ns) that drizzle never mutates - built once per column or expression. */\n private readonly _orderNodeCache = new WeakMap<AnyColumn | SQLWrapper, { asc: SQL; desc: SQL }>();\n\n /** A freshly sliced field is hashed again on every column lookup; a remembered one is hashed once. */\n private readonly _orderEntryCache = new Map<string, TParsedOrderEntry>();\n\n constructor() {\n super({ scope: FilterBuilder.name });\n }\n\n /** Handler table for `where` translation. Abstract so this class names no engine. */\n protected abstract get operators(): TQueryOperatorHandlers;\n\n /**\n * Merges default and user filters. `where` merges at the TOP KEY LEVEL, never index-wise - that\n * corrupts operator arrays. Operator-object collisions AND-compose, so a default scope can only\n * be narrowed, and a user `undefined` never overrides a defined default. Other parts user-wins.\n */\n mergeFilter<T = any>(opts: { defaultFilter?: TFilter<T>; userFilter?: TFilter<T> }): TFilter<T> {\n const { defaultFilter, userFilter } = opts;\n\n if (!defaultFilter) {\n return userFilter ?? {};\n }\n\n if (!userFilter) {\n return { ...defaultFilter };\n }\n\n const defaultWhere = defaultFilter.where;\n const userWhere = userFilter.where;\n let mergedWhere: TWhere<T> | undefined;\n\n if (defaultWhere && userWhere) {\n mergedWhere = this.mergeWhere({ defaultWhere, userWhere });\n } else {\n mergedWhere = userWhere ?? defaultWhere;\n }\n\n return {\n where: mergedWhere,\n order: userFilter.order ?? defaultFilter.order,\n limit: userFilter.limit ?? defaultFilter.limit,\n offset: userFilter.offset ?? defaultFilter.offset,\n skip: userFilter.skip ?? defaultFilter.skip,\n fields: userFilter.fields ?? defaultFilter.fields,\n include: userFilter.include ?? defaultFilter.include,\n };\n }\n\n /**\n * Top-key merge: operator-object collisions AND-compose under the reserved `and` key, merging\n * with an existing `and` rather than clobbering it. Every other collision is user-wins.\n */\n private mergeWhere<T = any>(opts: { defaultWhere: TWhere<T>; userWhere: TWhere<T> }): TWhere<T> {\n const { defaultWhere, userWhere } = opts;\n\n // Read by runtime key, which the column-keyed `TWhere<T>` does not index.\n const defaults: TWhere = defaultWhere;\n const users: TWhere = userWhere;\n\n const merged: TWhere = { ...defaultWhere };\n const composed: TWhere[] = [];\n\n for (const key in users) {\n const userValue = users[key];\n\n if (userValue === undefined) {\n continue;\n }\n\n const defaultValue = defaults[key];\n\n // Scalar-over-scalar is a plain override - the soft-delete opt-out. Everything else\n // AND-composes, so a user operator object cannot swallow a scalar default.\n const isCollision = defaultValue !== undefined;\n\n // `and`/`or` are how a SCOPE is written and both sides are arrays, which `isPrimitiveValue`\n // counts as scalar - without these branches the caller's group replaces the default outright.\n if (isCollision && key === QueryOperators.AND) {\n // Both conjunct lists must hold: concatenating them IS the AND of the two groups.\n merged.and = [...defaultValue, ...userValue];\n continue;\n }\n\n if (isCollision && key === QueryOperators.OR) {\n // Two disjunctions cannot be concatenated - that would UNION them, widening\n // the query. Each group has to hold on its own, so they become two conjuncts.\n delete merged[key];\n composed.push({ [key]: defaultValue }, { [key]: userValue });\n continue;\n }\n\n const isScalarOverride =\n !this.isOperatorObject({ value: defaultValue }) &&\n !this.isOperatorObject({ value: userValue });\n\n if (isCollision && !isScalarOverride) {\n delete merged[key];\n composed.push({ [key]: defaultValue }, { [key]: userValue });\n continue;\n }\n\n merged[key] = userValue;\n }\n\n if (composed.length) {\n merged.and = merged.and ? [...merged.and, ...composed] : composed;\n }\n\n return merged as TWhere<T>;\n }\n\n /**\n * Registry lookup shared by the resolvers below. A failure degrades to no settings rather than\n * failing the query, and is never silent - a degraded `resolveHiddenProperties` would stop\n * hidden columns being omitted.\n */\n private resolveModelEntry(opts: { schema: TTableSchemaWithId; methodName: string }) {\n const { schema, methodName } = opts;\n\n try {\n return ScopeThroughLink.entryOf({ schema });\n } catch (error) {\n this.logger.warn(\n '[%s] Model metadata lookup failed - continuing without model settings | %s',\n methodName,\n error,\n );\n\n return undefined;\n }\n }\n\n /**\n * Resolves hidden properties from the relation's SCHEMA object, falling back to its SQL table name -\n * `toInclude` has the schema and no class reference. A table claimed by two models answers by name\n * only, since the schema no longer names one of them.\n */\n resolveHiddenProperties(opts: {\n schema: TTableSchemaWithId;\n modelEntry?: TResolvedModelEntry;\n }): Set<string> {\n const modelEntry =\n opts.modelEntry ??\n this.resolveModelEntry({ schema: opts.schema, methodName: 'resolveHiddenProperties' });\n\n return new Set(modelEntry?.metadata?.settings?.hiddenProperties ?? []);\n }\n\n /** Resolves default filter for a schema from MetadataRegistry. */\n resolveDefaultFilter(opts: {\n schema: TTableSchemaWithId;\n modelEntry?: TResolvedModelEntry;\n }): TFilter | undefined {\n const modelEntry =\n opts.modelEntry ??\n this.resolveModelEntry({ schema: opts.schema, methodName: 'resolveDefaultFilter' });\n\n return modelEntry?.metadata?.settings?.query?.filter;\n }\n\n /** Resolves row-scope settings for a schema from MetadataRegistry - the relation's OWN `@model` entry, never the parent's. */\n resolveScopeFilter(opts: {\n schema: TTableSchemaWithId;\n modelEntry?: TResolvedModelEntry;\n }): TModelAccessSettings | undefined {\n const modelEntry =\n opts.modelEntry ??\n this.resolveModelEntry({ schema: opts.schema, methodName: 'resolveScopeFilter' });\n\n return modelEntry?.metadata?.settings?.access;\n }\n\n /**\n * The foreign key link of a `through` model and the scope its parent resolves for `operation` (the same operation\n * at every hop). The parent's default filter is not applied: scope only. For a write the parent's scope is narrowed as a\n * direct write to the parent is (`ScopeWriteGuard.mutationWhere`), so its `write.sharedRows` holds on the hop.\n */\n resolveThrough(opts: {\n settings: IModelAccessThroughSettings;\n schema: TTableSchemaWithId;\n operation: TScopeOperation;\n depth?: number;\n }): {\n link: ReturnType<typeof ScopeThroughLink.of>;\n scope: TNullable<TWhere> | typeof ScopeFilters.UNRESTRICTED;\n } {\n const { settings, schema, operation, depth = 1 } = opts;\n\n if (depth > ScopeThroughLink.MAX_DEPTH) {\n throw getError({\n message: `[resolveThrough] access.through is deeper than ${ScopeThroughLink.MAX_DEPTH} hops at ${getTableName(schema)}`,\n });\n }\n\n const link = ScopeThroughLink.of({\n schema,\n relation: settings.through.relation,\n relations: this.resolveRelations({ schema }),\n });\n const parentSettings = link.parentEntry?.metadata?.settings?.access;\n\n if (!parentSettings) {\n throw getError({\n message: `[resolveThrough] ${getTableName(link.parentSchema)} has no access setting, so ${getTableName(schema)} cannot be scoped through it`,\n });\n }\n\n const parentScope = this.resolveAccessScope({\n settings: parentSettings,\n schema: link.parentSchema,\n operation,\n depth: depth + 1,\n });\n\n // A write to the child reaches the parent the way a write to the parent itself does: the shared (null) rows its read scope\n // opens need the parent's `write.sharedRows`. A parent that is itself `through` narrowed its own parent on its hop.\n const isNarrowed =\n ScopeOperations.includes({ group: ScopeOperations.WRITE, operation }) &&\n !parentSettings.through &&\n parentScope !== ScopeFilters.UNRESTRICTED &&\n parentScope !== null &&\n parentScope !== undefined;\n const scope = isNarrowed\n ? ScopeWriteGuard.mutationWhere({\n settings: parentSettings,\n model: getTableName(link.parentSchema),\n operation,\n scopeWhere: parentScope,\n })\n : parentScope;\n\n return { link, scope };\n }\n\n /** The parent's scope as a `where` on the parent table: the part both the read subquery and the write check build. */\n toParentWhere(opts: { link: ReturnType<typeof ScopeThroughLink.of>; scope: TWhere }) {\n const { link, scope } = opts;\n\n return this.toWhere({\n tableName: getTableName(link.parentSchema),\n schema: link.parentSchema,\n where: scope,\n });\n }\n\n /**\n * The scope of a model for one call. A `through` model keeps the child rows whose foreign key is in the set of\n * parent keys the parent's scope allows: `child.fk IN (SELECT parent.pk FROM parent WHERE <parent scope>)`, built with\n * the existing `inSql` operator.\n */\n resolveAccessScope(opts: {\n settings: TModelAccessSettings;\n schema: TTableSchemaWithId;\n operation: TScopeOperation;\n depth?: number;\n }): TNullable<TWhere> | typeof ScopeFilters.UNRESTRICTED {\n const { settings, schema, operation, depth } = opts;\n\n if (!settings.through) {\n return settings.resolve({ operation });\n }\n\n const { link, scope } = this.resolveThrough({ settings, schema, operation, depth });\n\n if (scope === ScopeFilters.UNRESTRICTED || scope === null || scope === undefined) {\n return scope;\n }\n\n const where = this.toParentWhere({ link, scope });\n const keys = sql`select ${link.parentColumn} from ${link.parentSchema}`;\n const subquery = where ? sql`${keys} where ${where}` : keys;\n\n // Opaque on purpose: drizzle's relational query rewrites every column it finds in a `where` to the relation's alias,\n // the parent's columns inside this subquery included. A wrapper it does not look into keeps them qualified.\n return { [link.childProperty]: { inSql: { getSQL: () => subquery } } };\n }\n\n /**\n * Row scope for an included relation, mirroring `applyScopeFilter` in the repository tier\n * exactly: unconditional - never gated by `shouldSkipDefaultFilter` - and deny-by-default when\n * `resolve()` cannot determine a scope. A throwing `resolve()` is never caught here, so it\n * propagates the same way it does on the parent.\n */\n private applyRelationScopeFilter(opts: {\n userFilter?: TFilter;\n scopeFilterSettings?: TModelAccessSettings;\n schema: TTableSchemaWithId;\n }): TFilter {\n const { userFilter, scopeFilterSettings, schema } = opts;\n\n if (!scopeFilterSettings) {\n return userFilter ?? {};\n }\n\n const scopeWhere = this.resolveAccessScope({\n settings: scopeFilterSettings,\n schema,\n operation: ScopeOperations.READ,\n });\n\n // Same ordering as the repository tier's `applyScopeFilter`: exact symbol identity, checked\n // before null/undefined, so a forgotten `return` (which produces `undefined`) still denies\n // rather than un-scoping this relation. Each relation resolves its OWN `scopeFilterSettings`, so\n // an unrestricted parent never widens a still-scoped child, and vice versa.\n if (scopeWhere === ScopeFilters.UNRESTRICTED) {\n return userFilter ?? {};\n }\n\n if (scopeWhere !== null && scopeWhere !== undefined) {\n return this.mergeFilter({ defaultFilter: { where: scopeWhere }, userFilter });\n }\n\n if (scopeFilterSettings.onMissing === ScopeFilterMissingBehaviors.ALLOW) {\n return userFilter ?? {};\n }\n\n return this.mergeFilter({ defaultFilter: { where: ScopeFilterDenial.where() }, userFilter });\n }\n\n /** Resolves default row limit for a schema from MetadataRegistry. */\n resolveDefaultLimit(opts: {\n schema: TTableSchemaWithId;\n modelEntry?: TResolvedModelEntry;\n }): number | undefined {\n const modelEntry =\n opts.modelEntry ??\n this.resolveModelEntry({ schema: opts.schema, methodName: 'resolveDefaultLimit' });\n\n return modelEntry?.metadata?.settings?.query?.limit?.default;\n }\n\n /** Resolves relation configurations for a schema from MetadataRegistry. Memoized per schema. */\n resolveRelations(opts: { schema: TTableSchemaWithId }): Record<string, TRelationConfig> {\n const { schema } = opts;\n\n const cached = this._relationsCache.get(schema);\n\n if (cached) {\n return cached;\n }\n\n const resolved = this.resolveRelationsUncached({ schema });\n this._relationsCache.set(schema, resolved);\n\n return resolved;\n }\n\n private resolveRelationsUncached(opts: {\n schema: TTableSchemaWithId;\n }): Record<string, TRelationConfig> {\n const { schema } = opts;\n const modelEntry = this.resolveModelEntry({ schema, methodName: 'resolveRelationsUncached' });\n\n if (!modelEntry?.relationsResolver) {\n return {};\n }\n\n try {\n return ScopeThroughLink.relationsOf({ entry: modelEntry });\n } catch (error) {\n this.logger.warn(\n '[resolveRelationsUncached] Relations resolver failed - continuing without relations | %s',\n error,\n );\n\n return {};\n }\n }\n\n /** Builds Drizzle query options from a filter object. */\n build<Schema extends TTableSchemaWithId>(opts: {\n tableName: string;\n schema: Schema;\n filter: TFilter<TTableObject<Schema>>;\n }): TDrizzleQueryOptions {\n if (!opts.filter) {\n return {};\n }\n\n const { tableName, schema, filter } = opts;\n const { limit, skip, offset, order, fields, where, include } = filter;\n\n const effectiveOffset = skip ?? offset;\n\n return {\n ...(limit !== undefined && { limit }),\n ...(effectiveOffset !== undefined && { offset: effectiveOffset }),\n ...(fields && { columns: this.toColumns({ fields }) }),\n ...(order && { orderBy: this.toOrderBy({ tableName, schema, order }) }),\n ...(where && { where: this.toWhere({ tableName, schema, where }) }),\n ...(include && {\n with: this.toInclude({ include, relations: this.resolveRelations({ schema }) }),\n }),\n };\n }\n\n /** Converts fields selection to Drizzle columns format. */\n toColumns(opts: { fields: TFields }): Record<string, boolean> {\n const { fields } = opts;\n const result: Record<string, boolean> = {};\n\n if (Array.isArray(fields)) {\n for (const field of fields) {\n // Plain assignment, not `lodash/set`: drizzle's `columns` is a FLAT map of column name to\n // boolean, so a dotted field would have nested into a shape it cannot read anyway.\n // `String`, because `keyof any` admits a symbol and drizzle keys by name - which is what\n // `lodash/set` did internally with every path part anyway.\n result[String(field)] = true;\n }\n\n return result;\n }\n\n for (const key in fields) {\n if (fields[key] === true) {\n result[key] = true;\n }\n }\n\n return result;\n }\n\n /**\n * Converts a where clause to a Drizzle SQL condition (supports operators, JSON paths, AND/OR).\n */\n toWhere<Schema extends TTableSchemaWithId>(opts: {\n tableName: string;\n schema: Schema;\n where: TWhere<TTableObject<Schema>>;\n }): SQL | undefined {\n const { tableName, schema, where } = opts;\n const columns = this.getColumns(schema);\n\n if (!columns || ObjectUtility.isEmpty({ value: columns })) {\n throw getError({\n message: `[FilterBuilder][toWhere] Table: ${tableName} | Failed to get table columns`,\n });\n }\n\n const conditions: SQL[] = [];\n\n for (const key in where) {\n const value = where[key];\n\n if (value === undefined) {\n continue;\n }\n\n conditions.push(...this.buildWhereKeyConditions({ key, value, columns, tableName, schema }));\n }\n\n if (conditions.length === 0) {\n return undefined;\n }\n\n return conditions.length === 1 ? conditions[0] : and(...conditions);\n }\n\n /**\n * Conditions contributed by a single where key: a logical\n * group, a JSON path, a bare value or an operator object.\n */\n private buildWhereKeyConditions<Schema extends TTableSchemaWithId>(opts: {\n key: string;\n value: any;\n columns: TTableColumns;\n tableName: string;\n schema: Schema;\n }): SQL[] {\n const { key, value, columns, tableName, schema } = opts;\n\n if (QueryOperators.LOGICAL_GROUP_OPERATORS.has(key)) {\n const condition = this.buildLogicalGroupCondition({ key, value, tableName, schema });\n\n return condition ? [condition] : [];\n }\n\n if (JsonPathUtility.isJsonPath({ key })) {\n return this.buildJsonWhereCondition({ key, value, columns, tableName });\n }\n\n const column = columns[key];\n\n if (!column) {\n throw getError({\n message: `[FilterBuilder][toWhere] Table: ${tableName} | Column NOT FOUND | key: '${EchoUtility.toSafeEcho({ value: key })}'`,\n });\n }\n\n if (!this.isOperatorObject({ value })) {\n return [this.buildValueCondition({ column, value })];\n }\n\n return this.buildOperatorConditions({ column, value });\n }\n\n /**\n * Converts order entries to Drizzle SQL order nodes. A key resolves against `expressions` first\n * (a joined column or a computed `SQL`), then as a JSON path, then as a schema column.\n */\n toOrderBy<Schema extends TTableSchemaWithId>(opts: {\n tableName: string;\n schema: Schema;\n order: string[];\n expressions?: Readonly<Record<string, AnyColumn | SQLWrapper>>;\n }): SQL[] {\n const { tableName, schema, order, expressions } = opts;\n\n if (!Array.isArray(order) || order.length === 0) {\n return [];\n }\n\n const columns = this.getColumns(schema);\n\n const idColumn = columns.id;\n const orderBy: SQL[] = [];\n let namesId = false;\n\n for (const entry of order) {\n const { field: key, direction } = this.readOrderEntry({ entry });\n\n // The key comes from the request: an inherited name like `constructor` must not resolve.\n if (expressions && Object.hasOwn(expressions, key)) {\n orderBy.push(this.getOrderNode({ target: expressions[key], direction }));\n continue;\n }\n\n if (JsonPathUtility.isJsonPath({ key })) {\n orderBy.push(this.buildJsonOrderBy({ key, direction, columns, tableName }));\n continue;\n }\n\n const column = columns[key];\n\n if (!column) {\n throw getError({\n message: `[FilterBuilder][toOrderBy] Table: ${tableName} | Column NOT FOUND | key: '${EchoUtility.toSafeEcho({ value: key })}'`,\n });\n }\n\n namesId ||= column === idColumn;\n orderBy.push(this.getOrderNode({ target: column, direction }));\n }\n\n // A tie left to the engine is broken per page, so paging repeats and skips rows.\n if (idColumn && !namesId) {\n orderBy.push(this.getOrderNode({ target: idColumn, direction: Sorts.ASC }));\n }\n\n return orderBy;\n }\n\n private readOrderEntry(opts: { entry: string }): TParsedOrderEntry {\n const { entry } = opts;\n let parsed = this._orderEntryCache.get(entry);\n\n if (!parsed) {\n parsed = Sorts.parseEntry({ entry });\n\n if (entry.length <= ORDER_ENTRY_CACHE_MAX_LENGTH) {\n // Clearing, not evicting the oldest: deleting from the front of a JSC Map is slow.\n if (this._orderEntryCache.size >= ORDER_ENTRY_CACHE_CAP) {\n this._orderEntryCache.clear();\n }\n\n this._orderEntryCache.set(entry, parsed);\n }\n }\n\n return parsed;\n }\n\n private getOrderNode(opts: { target: AnyColumn | SQLWrapper; direction: TSortDirection }): SQL {\n const { target, direction } = opts;\n let pair = this._orderNodeCache.get(target);\n\n if (!pair) {\n pair = { asc: asc(target), desc: desc(target) };\n this._orderNodeCache.set(target, pair);\n }\n\n return direction === Sorts.DESC ? pair.desc : pair.asc;\n }\n\n /**\n * Converts include clause to Drizzle 'with' options\n * with nested filtering and hidden prop exclusion.\n */\n toInclude(opts: {\n include: TInclusion[];\n relations: { [relationName: string]: TRelationConfig };\n }): Record<string, true | TDrizzleQueryOptions> {\n const { include, relations } = opts;\n const result: Record<string, true | TDrizzleQueryOptions> = {};\n\n for (const inc of include) {\n const relationName = typeof inc === 'string' ? inc : inc.relation;\n const scope = typeof inc === 'string' ? undefined : inc.scope;\n const shouldSkipDefaultFilter = typeof inc === 'string' ? false : inc.shouldSkipDefaultFilter;\n\n if (!relationName) {\n throw getError({\n message: `[FilterBuilder][toInclude] Invalid include format | include: ${JSON.stringify(inc)}`,\n });\n }\n\n const relationConfig = relations[relationName];\n\n if (!relationConfig) {\n throw getError({\n message: `[FilterBuilder][toInclude] Relation NOT FOUND | relation: '${relationName}'`,\n });\n }\n\n // Resolved ONCE and handed to all four readers: they ask the registry the same question\n // about the same schema, and the lookup - `getTableName` plus a registry read - is the\n // measured cost of this loop, not the reads off the entry.\n const modelEntry = this.resolveModelEntry({\n schema: relationConfig.schema,\n methodName: 'toInclude',\n });\n\n const hiddenProps = this.resolveHiddenProperties({\n schema: relationConfig.schema,\n modelEntry,\n });\n\n // Row scope is this relation's OWN `@model` setting - never the parent's - and is applied\n // BEFORE `defaultFilter` so it survives `shouldSkipDefaultFilter` exactly like the parent.\n const scopeFilterSettings = this.resolveScopeFilter({\n schema: relationConfig.schema,\n modelEntry,\n });\n const scopedUserFilter = this.applyRelationScopeFilter({\n userFilter: scope,\n scopeFilterSettings,\n schema: relationConfig.schema,\n });\n\n const defaultFilter = shouldSkipDefaultFilter\n ? undefined\n : this.resolveDefaultFilter({ schema: relationConfig.schema, modelEntry });\n\n const mergedScope = this.mergeFilter({ defaultFilter, userFilter: scopedUserFilter });\n const scopedFilter: TFilter =\n relationConfig.type === RelationTypes.MANY\n ? {\n ...mergedScope,\n limit:\n mergedScope.limit ??\n this.resolveDefaultLimit({ schema: relationConfig.schema, modelEntry }) ??\n DEFAULT_LIMIT,\n }\n : mergedScope;\n\n const hasNoEffectiveFilter =\n ObjectUtility.isEmpty({ value: scopedFilter }) || Object.keys(scopedFilter).length === 0;\n\n if (hasNoEffectiveFilter && hiddenProps.size === 0) {\n result[relationName] = true;\n continue;\n }\n\n const nestedQuery = this.build<TTableSchemaWithId>({\n tableName: relationName,\n schema: relationConfig.schema,\n filter: scopedFilter,\n });\n\n if (hiddenProps.size > 0) {\n nestedQuery.columns = this.omitHiddenColumns({\n columns: nestedQuery.columns,\n schema: relationConfig.schema,\n hiddenProps,\n });\n }\n\n result[relationName] = nestedQuery;\n }\n\n return result;\n }\n\n /**\n * Column selection with hidden properties removed;\n * a nullish `columns` means \"every schema column\".\n */\n private omitHiddenColumns(opts: {\n columns?: Record<string, boolean>;\n schema: TTableSchemaWithId;\n hiddenProps: Set<string>;\n }): Record<string, boolean> {\n const { columns, schema, hiddenProps } = opts;\n const source = columns ?? TableColumnCache.get(schema);\n const filteredColumns: Record<string, boolean> = {};\n\n for (const key in source) {\n if (hiddenProps.has(key)) {\n continue;\n }\n\n filteredColumns[key] = columns ? columns[key] : true;\n }\n\n return filteredColumns;\n }\n\n private getColumns<Schema extends TTableSchemaWithId>(schema: Schema) {\n return TableColumnCache.get(schema);\n }\n\n private isPrimitiveValue(opts: { value: any }): boolean {\n const { value } = opts;\n\n return (\n value === null || Array.isArray(value) || value instanceof Date || typeof value !== 'object'\n );\n }\n\n /**\n * Protected, not private: an engine overriding `buildJsonWhereCondition` must tell an operator\n * object from a bare value, and cannot reach the base's own walk to do it.\n */\n protected isOperatorObject(opts: { value: any }): boolean {\n const { value } = opts;\n\n if (this.isPrimitiveValue({ value })) {\n return false;\n }\n\n const keys = Object.keys(value);\n\n if (keys.length === 0) {\n return false;\n }\n\n return keys.every((key) => QueryOperators.isValid(key));\n }\n\n /**\n * Builds a SQL condition for a simple value (null, array, or\n * equality). Protected for the same reason as `isOperatorObject`: an\n * overridden `buildJsonWhereCondition` needs the bare-value branch.\n */\n protected buildValueCondition(opts: { column: any; value: any }): SQL {\n const { column, value } = opts;\n\n if (value === null) {\n return isNull(column);\n }\n\n if (Array.isArray(value)) {\n return value.length === 0 ? sql`false` : inArray(column, value);\n }\n\n return eq(column, value);\n }\n\n protected buildOperatorConditions(opts: { column: any; value: Record<string, any> }): SQL[] {\n const { column, value } = opts;\n const conditions: SQL[] = [];\n\n for (const op in value) {\n // `not` recurses into a nested condition, out of reach of the static operator handlers\n // - built here where buildOperatorConditions and buildValueCondition are in scope.\n if (op === QueryOperators.NOT) {\n conditions.push(this.buildNotCondition({ column, value: value[op] }));\n continue;\n }\n\n const opFn = this.operators[op];\n\n if (!opFn) {\n throw getError({\n message: `[FilterBuilder][buildOperatorConditions] Invalid query operator | operator: '${op}'`,\n });\n }\n\n const result = opFn({ column, value: value[op] });\n\n if (result) {\n conditions.push(result);\n }\n }\n\n return conditions;\n }\n\n /**\n * Negates a nested condition: `not: <operatorObject>` recurses into the\n * operators, `not: <bareValue>` negates that value equality/array/null condition.\n */\n private buildNotCondition(opts: { column: any; value: any }): SQL {\n const { column, value } = opts;\n\n if (this.isOperatorObject({ value })) {\n const nested = this.buildOperatorConditions({ column, value });\n const combined = nested.length === 1 ? nested[0] : and(...nested)!;\n\n return not(combined);\n }\n\n return not(this.buildValueCondition({ column, value }));\n }\n\n /** Builds SQL conditions for logical groups (AND/OR). */\n private buildLogicalGroupCondition<Schema extends TTableSchemaWithId>(opts: {\n key: string;\n value: any;\n tableName: string;\n schema: Schema;\n }): SQL | undefined {\n const { key, value, tableName, schema } = opts;\n\n const clauses = (Array.isArray(value) ? value : [value])\n .map((inner) => this.toWhere({ tableName, schema, where: inner }))\n .filter((c): c is SQL => !!c);\n\n if (clauses.length === 0) {\n // An empty conjunction is vacuously TRUE so dropping it is correct, but an empty DISJUNCTION\n // is FALSE and dropping it WIDENS the query: `or: permittedOrgIds.map(...)` on an empty\n // permission list must return nothing, not everything.\n return key === QueryOperators.AND ? undefined : sql`false`;\n }\n\n return key === QueryOperators.AND ? and(...clauses)! : or(...clauses)!;\n }\n\n protected validateJsonColumn(opts: {\n key: string;\n columns: TTableColumns;\n tableName: string;\n methodName: string;\n }): { column: TTableColumns[string]; path: string[] } {\n const { key, columns, tableName, methodName } = opts;\n\n const parsed = JsonPathUtility.parseJsonPath({ key });\n\n const column = columns[parsed.columnName];\n\n if (!column) {\n throw getError({\n message: `[FilterBuilder][${methodName}] Table: ${tableName} | Column NOT FOUND | key: '${EchoUtility.toSafeEcho({ value: parsed.columnName })}'`,\n });\n }\n\n JsonPathUtility.validateJsonColumnType({\n column,\n columnName: parsed.columnName,\n tableName,\n methodName: `FilterBuilder.${methodName}`,\n });\n\n JsonPathUtility.validateJsonPathComponents({\n path: parsed.path,\n tableName,\n methodName: `FilterBuilder.${methodName}`,\n });\n\n return { column, path: parsed.path };\n }\n\n /**\n * Whether a JSON operand needs the engine's numeric extraction: numeric comparisons, eq/ne/neq\n * with a number, in/inq/nin with an all-number array. Only picks between the two fragments the\n * engine passed in, so an engine with already-typed extraction returns false.\n */\n protected jsonNeedsNumericCast(opts: { operators: Record<string, any> }): boolean {\n const { operators } = opts;\n\n if (QueryOperators.hasNumericComparison({ operators })) {\n return true;\n }\n\n for (const op in operators) {\n const operand = operators[op];\n\n if (SCALAR_EQUALITY_OPERATORS.has(op) && typeof operand === 'number') {\n return true;\n }\n\n if (\n MEMBERSHIP_OPERATORS.has(op) &&\n Array.isArray(operand) &&\n operand.length > 0 &&\n operand.every((entry) => typeof entry === 'number')\n ) {\n return true;\n }\n }\n\n return false;\n }\n\n /**\n * Emits the engine JSON extraction for one where key. Abstract because the syntax is\n * engine-owned: a default would hand the next engine one branch's SQL with no compile error.\n */\n protected abstract buildJsonWhereCondition(opts: {\n key: string;\n value: any;\n columns: TTableColumns;\n tableName: string;\n }): SQL[];\n\n /**\n * A bare JSON operand IS its operator equivalent - `isOperatorObject` counts an array\n * as primitive, so `[10, 20]` must take the same cast `{ inq: [10, 20] }` does.\n */\n protected toBareJsonOperators(opts: { value: any }): Record<string, any> {\n const { value } = opts;\n\n return Array.isArray(value) ? { [QueryOperators.INQ]: value } : { [QueryOperators.EQ]: value };\n }\n\n /**\n * The cast belongs to each OPERATOR, not the object: one object-wide cast misses the operand in\n * `{ not: { gt: 50 } }` (-> `text > integer`) and over-casts the extraction `like` shares in\n * `{ gte: 1, like: '%a%' }` (-> `numeric ~~ text`).\n */\n protected buildJsonOperatorConditions(opts: {\n jsonPath: string | SQL;\n safeNumericCast: string | SQL;\n operators: Record<string, any>;\n }): SQL[] {\n const { operators } = opts;\n // Raw text stays accepted for subclasses; wrapped once so every operator shares one fragment.\n const jsonPath = typeof opts.jsonPath === 'string' ? sql.raw(opts.jsonPath) : opts.jsonPath;\n const safeNumericCast =\n typeof opts.safeNumericCast === 'string'\n ? sql.raw(opts.safeNumericCast)\n : opts.safeNumericCast;\n const conditions: SQL[] = [];\n\n for (const op in operators) {\n const operand = operators[op];\n\n if (op === QueryOperators.NOT) {\n if (this.isOperatorObject({ value: operand })) {\n const nested = this.buildJsonOperatorConditions({\n jsonPath,\n safeNumericCast,\n operators: operand,\n });\n\n conditions.push(not(nested.length === 1 ? nested[0] : and(...nested)!));\n continue;\n }\n\n // The choice must come from `jsonNeedsNumericCast`, never a bare `typeof`: an engine that\n // neutralises the cast by overriding the predicate would still be cast through this branch.\n const negatedExtraction = this.jsonNeedsNumericCast({\n operators: this.toBareJsonOperators({ value: operand }),\n })\n ? safeNumericCast\n : jsonPath;\n\n conditions.push(\n not(this.buildValueCondition({ column: negatedExtraction, value: operand })),\n );\n continue;\n }\n\n const opFn = this.operators[op];\n\n if (!opFn) {\n throw getError({\n message: `[FilterBuilder][buildJsonOperatorConditions] Invalid query operator | operator: '${op}'`,\n });\n }\n\n const extraction = this.jsonNeedsNumericCast({ operators: { [op]: operand } })\n ? safeNumericCast\n : jsonPath;\n\n const result = opFn({ column: extraction, value: operand });\n\n if (result) {\n conditions.push(result);\n }\n }\n\n return conditions;\n }\n\n /**\n * Emits the engine's JSON extraction for one order key.\n * Abstract for the same reason as `buildJsonWhereCondition`.\n */\n protected abstract buildJsonOrderBy(opts: {\n key: string;\n direction: TConstValue<typeof Sorts>;\n columns: TTableColumns;\n tableName: string;\n }): SQL;\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@venizia/ignis-connectors",
|
|
3
|
-
"version": "0.4.8-
|
|
3
|
+
"version": "0.4.8-2",
|
|
4
4
|
"description": "Datasource and repository connectors for the IGNIS framework: the engine-neutral relational and search tiers, plus Postgres, SQLite, PGlite, Typesense and Meilisearch behind sub-paths.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -97,16 +97,16 @@
|
|
|
97
97
|
"force-update": "sh ../../scripts/build/force-update.sh"
|
|
98
98
|
},
|
|
99
99
|
"dependencies": {
|
|
100
|
-
"@venizia/ignis-filter": "0.4.7-
|
|
101
|
-
"@venizia/ignis-helpers": "0.4.8-
|
|
102
|
-
"@venizia/ignis-inversion": "0.4.7-
|
|
103
|
-
"@venizia/ignis-kernel": "0.4.8-
|
|
100
|
+
"@venizia/ignis-filter": "0.4.7-2",
|
|
101
|
+
"@venizia/ignis-helpers": "0.4.8-2",
|
|
102
|
+
"@venizia/ignis-inversion": "0.4.7-2",
|
|
103
|
+
"@venizia/ignis-kernel": "0.4.8-2",
|
|
104
104
|
"zod": "^4.6.7"
|
|
105
105
|
},
|
|
106
106
|
"devDependencies": {
|
|
107
107
|
"@types/bun": "^1.4.3",
|
|
108
108
|
"@types/pg": "^8.23.1",
|
|
109
|
-
"@venizia/dev-configs": "0.4.8-
|
|
109
|
+
"@venizia/dev-configs": "0.4.8-2",
|
|
110
110
|
"eslint": "^10.13.0",
|
|
111
111
|
"oxlint": "1.89.0",
|
|
112
112
|
"oxlint-tsgolint": "7.0.2004",
|