@zmdb/orm 1.0.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (87) hide show
  1. package/LICENSE +674 -0
  2. package/README.md +30 -0
  3. package/dist/cache/index.d.ts +34 -0
  4. package/dist/cache/index.d.ts.map +1 -0
  5. package/dist/cache/index.js +149 -0
  6. package/dist/cache/index.js.map +1 -0
  7. package/dist/drivers/transactional.d.ts +6 -0
  8. package/dist/drivers/transactional.d.ts.map +1 -0
  9. package/dist/drivers/transactional.js +2 -0
  10. package/dist/drivers/transactional.js.map +1 -0
  11. package/dist/dto/index.d.ts +41 -0
  12. package/dist/dto/index.d.ts.map +1 -0
  13. package/dist/dto/index.js +334 -0
  14. package/dist/dto/index.js.map +1 -0
  15. package/dist/entity-modeling/index.d.ts +18 -0
  16. package/dist/entity-modeling/index.d.ts.map +1 -0
  17. package/dist/entity-modeling/index.js +26 -0
  18. package/dist/entity-modeling/index.js.map +1 -0
  19. package/dist/filters/index.d.ts +62 -0
  20. package/dist/filters/index.d.ts.map +1 -0
  21. package/dist/filters/index.js +163 -0
  22. package/dist/filters/index.js.map +1 -0
  23. package/dist/index.d.ts +413 -0
  24. package/dist/index.d.ts.map +1 -0
  25. package/dist/index.js +2003 -0
  26. package/dist/index.js.map +1 -0
  27. package/dist/loaders/index.d.ts +38 -0
  28. package/dist/loaders/index.d.ts.map +1 -0
  29. package/dist/loaders/index.js +164 -0
  30. package/dist/loaders/index.js.map +1 -0
  31. package/dist/outbox/index.d.ts +59 -0
  32. package/dist/outbox/index.d.ts.map +1 -0
  33. package/dist/outbox/index.js +323 -0
  34. package/dist/outbox/index.js.map +1 -0
  35. package/dist/outbox/sql.d.ts +52 -0
  36. package/dist/outbox/sql.d.ts.map +1 -0
  37. package/dist/outbox/sql.js +115 -0
  38. package/dist/outbox/sql.js.map +1 -0
  39. package/dist/relations/index.d.ts +38 -0
  40. package/dist/relations/index.d.ts.map +1 -0
  41. package/dist/relations/index.js +164 -0
  42. package/dist/relations/index.js.map +1 -0
  43. package/dist/replicas/index.d.ts +10 -0
  44. package/dist/replicas/index.d.ts.map +1 -0
  45. package/dist/replicas/index.js +42 -0
  46. package/dist/replicas/index.js.map +1 -0
  47. package/dist/seeding/index.d.ts +18 -0
  48. package/dist/seeding/index.d.ts.map +1 -0
  49. package/dist/seeding/index.js +66 -0
  50. package/dist/seeding/index.js.map +1 -0
  51. package/dist/streaming/index.d.ts +7 -0
  52. package/dist/streaming/index.d.ts.map +1 -0
  53. package/dist/streaming/index.js +67 -0
  54. package/dist/streaming/index.js.map +1 -0
  55. package/dist/testing/official-dialects.fixture.d.ts +16 -0
  56. package/dist/testing/official-dialects.fixture.d.ts.map +1 -0
  57. package/dist/testing/official-dialects.fixture.js +21 -0
  58. package/dist/testing/official-dialects.fixture.js.map +1 -0
  59. package/dist/testing/repository.fixture.d.ts +11 -0
  60. package/dist/testing/repository.fixture.d.ts.map +1 -0
  61. package/dist/testing/repository.fixture.js +33 -0
  62. package/dist/testing/repository.fixture.js.map +1 -0
  63. package/dist/transactions/index.d.ts +40 -0
  64. package/dist/transactions/index.d.ts.map +1 -0
  65. package/dist/transactions/index.js +249 -0
  66. package/dist/transactions/index.js.map +1 -0
  67. package/dist/typed-populate/nested.fixtures.d.ts +34 -0
  68. package/dist/typed-populate/nested.fixtures.d.ts.map +1 -0
  69. package/dist/typed-populate/nested.fixtures.js +4 -0
  70. package/dist/typed-populate/nested.fixtures.js.map +1 -0
  71. package/package.json +78 -0
  72. package/src/cache/index.ts +188 -0
  73. package/src/drivers/transactional.ts +6 -0
  74. package/src/dto/index.ts +379 -0
  75. package/src/entity-modeling/index.ts +38 -0
  76. package/src/filters/index.ts +267 -0
  77. package/src/index.ts +2757 -0
  78. package/src/loaders/index.ts +256 -0
  79. package/src/outbox/index.ts +409 -0
  80. package/src/outbox/sql.ts +179 -0
  81. package/src/relations/index.ts +221 -0
  82. package/src/replicas/index.ts +51 -0
  83. package/src/seeding/index.ts +72 -0
  84. package/src/streaming/index.ts +67 -0
  85. package/src/testing/repository.fixture.ts +44 -0
  86. package/src/transactions/index.ts +315 -0
  87. package/src/typed-populate/nested.fixtures.ts +59 -0
@@ -0,0 +1,413 @@
1
+ import { type CoreSchema, type CreateDTO, type DeclaredTable, type Entity, type PrimaryKeyOf, type TaggedSchema, type UpdateDTO } from '@zmdb/schema';
2
+ import { type KeysCarrying, type Populated, type RelationKeys, type RelationPath } from '@zmdb/schema/derive';
3
+ import { type WhereDTO, type ListDTO, type ListResult, type AggregateSpec } from '@zmdb/schema/dto';
4
+ import { type Sql } from '@zmdb/schema/tags';
5
+ import { type CompiledQuery, type DialectTarget, type SetValue, type SqlDialect } from '@zmdb/sql';
6
+ import { createQueryCompiler, dialectCapabilities, dialectTraits } from '@zmdb/sql';
7
+ import { aggregateSelectFrom, type AggregateSelect } from '@zmdb/sql/aggregations';
8
+ import { type JoinCondition } from '@zmdb/sql/joins';
9
+ import { type RoutineDef } from '@zmdb/sql/schema-objects';
10
+ import { ValidationError, type ValidationIssue } from '@zmdb/validator';
11
+ import { type CacheInvalidationOptions, type CacheOptions, type CacheStore } from './cache/index.js';
12
+ import { type FilterDef, type FilterOverrides } from './filters/index.js';
13
+ import { LOADER_ENTITY_BATCH, LOADER_ENTITY_KEY, LOADER_FOR_SCOPE, LOADER_RELATION_BATCH, LOADER_RELATION_KEY, RELATION_LOADER_FOR_SCOPE, type EntityLoader, type RelationLoader, type RelationValueOf } from './loaders/index.js';
14
+ import { type JoinRow } from './relations/index.js';
15
+ export interface ExecuteOptions {
16
+ readonly signal?: AbortSignal;
17
+ /** Rows per round trip. A driver may clamp it; zero or negative is refused. */
18
+ readonly batchSize?: number;
19
+ }
20
+ export interface Driver<Name extends string = string> {
21
+ readonly dialect: DialectTarget<Name>;
22
+ /** Enables compile-time query attributes when an execution wrapper consumes them. */
23
+ readonly queryTelemetry?: true;
24
+ execute(query: CompiledQuery, opts?: ExecuteOptions): Promise<readonly Record<string, unknown>[]>;
25
+ stream?(query: CompiledQuery, opts?: ExecuteOptions): AsyncIterable<Record<string, unknown>>;
26
+ }
27
+ export type SelectedDriver<Name extends string = string> = Driver<Name>;
28
+ export interface TransactionalDriver<Name extends string = string> extends SelectedDriver<Name> {
29
+ transaction<Result>(run: (driver: SelectedDriver<Name>) => Promise<Result>): Promise<Result>;
30
+ }
31
+ export interface DatabaseVertical<Name extends string, Connection, Options = undefined> {
32
+ readonly dialect: SqlDialect<Name>;
33
+ driver(connection: Connection, options?: Options): TransactionalDriver<Name>;
34
+ }
35
+ export interface QueryMeta {
36
+ readonly filters: readonly string[];
37
+ /** The driver had no cursor, so this stream was served by one buffered execute. */
38
+ readonly buffered?: boolean;
39
+ }
40
+ export interface RepositoryOptions {
41
+ readonly cacheStore?: CacheStore;
42
+ readonly filters?: readonly FilterDef<unknown>[];
43
+ /** Schemas referenced by relations whose declared and physical names may differ. */
44
+ readonly schemas?: readonly CoreSchema<string>[];
45
+ readonly onQuery?: (query: CompiledQuery, meta: QueryMeta) => void;
46
+ }
47
+ export interface ReadOptions<Defs extends readonly FilterDef<unknown>[] = readonly FilterDef<unknown>[]> {
48
+ readonly cache?: CacheOptions | false;
49
+ readonly filters?: FilterOverrides<Defs>;
50
+ readonly signal?: AbortSignal;
51
+ }
52
+ export interface WriteOptions<Defs extends readonly FilterDef<unknown>[] = readonly FilterDef<unknown>[]> extends CacheInvalidationOptions {
53
+ readonly filters?: FilterOverrides<Defs>;
54
+ }
55
+ export interface StreamOptions<Defs extends readonly FilterDef<unknown>[] = readonly FilterDef<unknown>[]> extends ExecuteOptions {
56
+ readonly filters?: FilterOverrides<Defs>;
57
+ /** Refuse rather than buffer when the driver has no cursor. Default false. */
58
+ readonly requireCursor?: boolean;
59
+ }
60
+ type PopulateReadOptions<K extends string> = ReadOptions & {
61
+ readonly populate: readonly K[];
62
+ };
63
+ export interface RepositoryAggregateBuilder extends ReturnType<typeof aggregateSelectFrom> {
64
+ joinRelation(relationName: string, kind?: 'inner' | 'left' | 'right'): RepositoryAggregateBuilder;
65
+ }
66
+ export { ValidationError, type ValidationIssue };
67
+ type KeyedMethod = 'findById' | 'update' | 'delete' | 'hardDelete' | 'restore';
68
+ /** A composite key omitted one or more required own properties. */
69
+ export declare class IncompleteKeyError extends ValidationError {
70
+ readonly table: string;
71
+ readonly missing: readonly string[];
72
+ constructor(table: string, method: KeyedMethod, missing: readonly string[]);
73
+ }
74
+ /** A literal value or a compiler-owned expression, per updatable column. */
75
+ export type UpdatePatch<T extends DeclaredTable> = {
76
+ readonly [K in keyof UpdateDTO<T>]?: SetValue<UpdateDTO<T>[K]>;
77
+ };
78
+ type NumericSqlKeys<T extends DeclaredTable> = KeysCarrying<T, Sql<'integer'>> | KeysCarrying<T, Sql<'bigint'>> | KeysCarrying<T, Sql<'numeric'>>;
79
+ type NumericAppKeys<T extends DeclaredTable> = {
80
+ [K in keyof T]-?: NonNullable<T[K]> extends number | bigint ? K : never;
81
+ }[keyof T];
82
+ /** Updatable columns whose declared app value and SQL storage are both numeric. */
83
+ export type NumericColumnOf<T extends DeclaredTable> = Extract<NumericSqlKeys<T>, NumericAppKeys<T> & keyof UpdateDTO<T> & string>;
84
+ type NumericOperandOf<T extends DeclaredTable, K extends NumericColumnOf<T>> = Exclude<UpdateDTO<T>[K], null | undefined>;
85
+ type UpsertUpdateFields<T extends DeclaredTable> = [T] extends [never] ? readonly string[] | Record<string, unknown> : readonly (keyof UpdateDTO<T> & string)[] | UpdatePatch<T>;
86
+ export interface UpsertOptions<T extends DeclaredTable = never> extends CacheInvalidationOptions {
87
+ readonly target?: string | readonly string[] | undefined;
88
+ readonly updateFields?: UpsertUpdateFields<T> | undefined;
89
+ }
90
+ type RoutineType = RoutineDef['params'][number]['type'];
91
+ type RoutineAppType<T extends RoutineType | 'void'> = T extends 'serial' | 'integer' | 'numeric' ? number : T extends 'bigint' ? bigint : T extends 'boolean' ? boolean : T extends 'timestamp' ? Date : T extends 'text' | 'varchar' | 'jsonEnum' ? string : T extends 'json' ? unknown : void;
92
+ type RoutineAppTypeOfParam<P> = P extends {
93
+ readonly type: infer T extends RoutineType;
94
+ } ? RoutineAppType<T> : never;
95
+ type ArgsFromRoutineParams<P extends readonly RoutineDef['params'][number][]> = P extends readonly [] ? readonly [] : P extends readonly [infer Head, ...infer Tail extends readonly RoutineDef['params'][number][]] ? readonly [RoutineAppTypeOfParam<Head>, ...ArgsFromRoutineParams<Tail>] : readonly RoutineAppTypeOfParam<P[number]>[];
96
+ /** The app-layer argument tuple derived from a routine declaration. */
97
+ export type ArgsOf<D extends RoutineDef> = ArgsFromRoutineParams<D['params']>;
98
+ /** The app-layer result derived from a routine declaration. */
99
+ export type ResultOf<D extends RoutineDef> = D['kind'] extends 'procedure' ? void : D['returns'] extends {
100
+ readonly type: infer T extends RoutineType | 'void';
101
+ readonly setof: true;
102
+ } ? readonly RoutineAppType<T>[] : D['returns'] extends {
103
+ readonly type: infer T extends RoutineType | 'void';
104
+ } ? RoutineAppType<T> : void;
105
+ /**
106
+ * The base repository.
107
+ *
108
+ * `T` is the **declared type** — the interface the table was written as — and every DTO on
109
+ * this class derives from it. It is not the schema value: a repository is handed one of
110
+ * those at construction, and `defineRepository` recovers `T` from its phantom, but nothing
111
+ * here reads a column map to work out what a row looks like.
112
+ *
113
+ * Relations come from `T` as well. There used to be a second type parameter for them,
114
+ * paired with a static `relations` map, because `Entity<T>` was derived from a schema value
115
+ * and a schema value carries no relations — so the map was the only place the runtime could
116
+ * learn that `orders` means `orders.userId`. The declaration says it:
117
+ *
118
+ * ```ts
119
+ * interface User extends Table<'users'> {
120
+ * id: number & Sql<'integer'> & Serial & PrimaryKey;
121
+ * orders?: Order[] & OneToMany<'orders', 'userId'>;
122
+ * }
123
+ *
124
+ * class Users extends BaseRepository<User> {
125
+ * static override readonly schema = UserSchema;
126
+ * }
127
+ * ```
128
+ *
129
+ * `populate: ['orders']` is checked against `RelationKeys<User>` and the batched select it
130
+ * runs comes from the same tag. `defineRepository` needs no subclass at all.
131
+ */
132
+ export declare abstract class BaseRepository<T extends DeclaredTable> {
133
+ #private;
134
+ static readonly schema: CoreSchema<string>;
135
+ protected driver: Driver;
136
+ protected readonly qb: ReturnType<typeof createQueryCompiler>;
137
+ protected readonly dialect: DialectTarget;
138
+ protected readonly dialectCapabilities: ReturnType<typeof dialectCapabilities>;
139
+ protected readonly dialectTraits: ReturnType<typeof dialectTraits>;
140
+ /** Ordered primary-key columns, resolved once because a repository's schema cannot change. */
141
+ private readonly keyColumns;
142
+ private readonly physicalKeyColumns;
143
+ constructor(driver: Driver, dialect?: DialectTarget | undefined, options?: RepositoryOptions);
144
+ [LOADER_FOR_SCOPE](scope: object): EntityLoader<T>;
145
+ [RELATION_LOADER_FOR_SCOPE]<K extends RelationKeys<T> & string>(scope: object, relation: K): RelationLoader<T, K>;
146
+ withTransaction(tx: Pick<Driver, 'execute' | 'stream'>): this;
147
+ /**
148
+ * Call one declared stored function or procedure.
149
+ *
150
+ * A repository rebound with `withTransaction` uses that transaction's driver
151
+ * here too. The routine body is opaque, so zmdb cannot detect transaction
152
+ * control inside it; callers must not put an internally committing procedure
153
+ * inside an outer transaction.
154
+ */
155
+ protected call<D extends RoutineDef>(definition: D, args: ArgsOf<D>): Promise<ResultOf<D>>;
156
+ private get schema();
157
+ /**
158
+ * One relation, by name, resolved from the declaration.
159
+ *
160
+ * No assertion, which is the difference from the static `relations` map this replaced:
161
+ * `schema.ir.relations` is a field of the schema value every repository is handed, so
162
+ * there is nothing to claim about `this.constructor`. The resolution itself lives in
163
+ * `@zmdb/schema` because `compilePopulate` needs the same answer, and two resolvers
164
+ * over one declaration is how the join and the batched select came to disagree before.
165
+ */
166
+ private relation;
167
+ private get tableName();
168
+ private sqlNamesForTable;
169
+ private relationSqlNames;
170
+ private physicalColumn;
171
+ private aggregateColumn;
172
+ private aggregateSelection;
173
+ private selectEntity;
174
+ private selectProperties;
175
+ private entityReturning;
176
+ private physicalRecord;
177
+ private physicalFields;
178
+ private filterDefinitionsFor;
179
+ private knownFilterNames;
180
+ private rootFilterNames;
181
+ private allDeclaredFilterNames;
182
+ private populatePlan;
183
+ private populateFilterNames;
184
+ private resolveReadFilters;
185
+ /**
186
+ * The only place a repository read becomes a CompiledQuery.
187
+ *
188
+ * Filter parameters are resolved before `build` runs, the resolved predicates
189
+ * are conjoined unless a structurally richer builder already placed them, and
190
+ * the same point reports the final SQL plus the applied names.
191
+ */
192
+ private compileRead;
193
+ private resolveWriteFilters;
194
+ /**
195
+ * The only place a repository UPDATE or DELETE becomes a CompiledQuery.
196
+ *
197
+ * Write filters default on, are resolved before compilation, and are reported
198
+ * through the same query-observation hook as reads.
199
+ */
200
+ private compileWrite;
201
+ private resolvePopulateFilters;
202
+ private requiredKeyColumns;
203
+ /**
204
+ * The one row-shape trust boundary in this package (ARCHITECTURE §2.1).
205
+ *
206
+ * A driver or configured cache store hands back structurally opaque values;
207
+ * the compiled query and schema fingerprint decide their shape, so exactly one
208
+ * assertion re-types them for the caller. Every read method funnels through
209
+ * here instead of asserting at its own return statement.
210
+ */
211
+ private executeRead;
212
+ private rows;
213
+ /**
214
+ * The repository's one row-shape assertion, shared by buffered and streamed
215
+ * reads. The compiler that produced the query establishes the public shape;
216
+ * drivers deliberately return opaque records.
217
+ */
218
+ private trusted;
219
+ private cachedRows;
220
+ private invalidateCache;
221
+ private reportCacheFailure;
222
+ /**
223
+ * The db→app crossing on the way out (plan D3).
224
+ *
225
+ * `Entity<T>` says a `timestamp` column is a `Date`, a `bigint` column is a `bigint`, and
226
+ * an extension vector is a number array. A driver may or may not agree: `pg` returns a
227
+ * `Date` for a `timestamptz`, a string for an `int8`, and pgvector's text form when its
228
+ * parser is absent; SQLite returns the `TEXT` it stored. So a raw row can disagree with
229
+ * the declared app type silently unless this boundary converts it.
230
+ *
231
+ * A schema without a `timestamp`, `bigint`, or extension vector skips the walk entirely
232
+ * rather than copying every row to no effect. Only `timestamp` and `bigint` need distinct
233
+ * JSON wire forms; vector decoding is specific to the db→app crossing.
234
+ */
235
+ private decodeRows;
236
+ private decodeRow;
237
+ private get decodedColumns();
238
+ private keyValues;
239
+ private keyWhere;
240
+ /** Add the deterministic order required by dialects whose pagination grammar needs one. */
241
+ private limitOne;
242
+ /** Validate a typed key and return its values in schema declaration order. */
243
+ private loaderKeyValues;
244
+ [LOADER_ENTITY_KEY](id: PrimaryKeyOf<T>): string;
245
+ /**
246
+ * Find a primary-key batch through the repository's compiler, decoder and
247
+ * dialect parameter ceiling. Composite tuples use OR-of-AND groups; SQL's
248
+ * AND-before-OR precedence keeps every tuple boundary intact.
249
+ */
250
+ [LOADER_ENTITY_BATCH](ids: readonly PrimaryKeyOf<T>[]): Promise<readonly (Entity<T> | undefined)[]>;
251
+ findById(id: PrimaryKeyOf<T>): Promise<Entity<T> | undefined>;
252
+ findById<K extends string>(id: PrimaryKeyOf<T>, opts: PopulateReadOptions<K & RelationPath<T, K>>): Promise<Populated<T, RelationPath<T, K>> | undefined>;
253
+ findById(id: PrimaryKeyOf<T>, opts: ReadOptions): Promise<Entity<T> | undefined>;
254
+ /** The shared body of `findById` and `findOne`: first row for a where clause, relations attached if asked for. */
255
+ private firstMatching;
256
+ private firstResult;
257
+ /** The children of every parent in parameter-bounded queries, grouped by the ordered target key. */
258
+ private childrenByParent;
259
+ /** Batch-load and attach named relations to parent rows without mutating inputs. */
260
+ private attachRelations;
261
+ private populateRows;
262
+ populate<K extends string>(rows: readonly Entity<T>[], paths: readonly (K & RelationPath<T, K>)[], options?: ReadOptions): Promise<readonly Populated<T, RelationPath<T, K>>[]>;
263
+ populate<K extends string>(row: Entity<T>, paths: readonly (K & RelationPath<T, K>)[], options?: ReadOptions): Promise<Populated<T, RelationPath<T, K>>>;
264
+ [LOADER_RELATION_KEY]<K extends RelationKeys<T> & string>(parent: Entity<T>, relation: K): string;
265
+ [LOADER_RELATION_BATCH]<K extends RelationKeys<T> & string>(parents: readonly Entity<T>[], relation: K): Promise<readonly RelationValueOf<T, K>[]>;
266
+ findOne<K extends string>(where: WhereDTO<T>, opts: PopulateReadOptions<K & RelationPath<T, K>>): Promise<Populated<T, RelationPath<T, K>> | undefined>;
267
+ findOne(where: WhereDTO<T>): Promise<Entity<T> | undefined>;
268
+ findOne(where: WhereDTO<T>, opts: ReadOptions): Promise<Entity<T> | undefined>;
269
+ find(where: WhereDTO<T>): Promise<readonly Entity<T>[]>;
270
+ find<K extends string>(where: WhereDTO<T>, opts: PopulateReadOptions<K & RelationPath<T, K>>): Promise<readonly Populated<T, RelationPath<T, K>>[]>;
271
+ find(where: WhereDTO<T>, opts: ReadOptions): Promise<readonly Entity<T>[]>;
272
+ findAll<K extends string>(opts: PopulateReadOptions<K & RelationPath<T, K>>): Promise<readonly Populated<T, RelationPath<T, K>>[]>;
273
+ findAll(): Promise<readonly Entity<T>[]>;
274
+ findAll(opts: ReadOptions): Promise<readonly Entity<T>[]>;
275
+ count(where?: WhereDTO<T>, options?: ReadOptions): Promise<number>;
276
+ exists(where?: WhereDTO<T>, options?: ReadOptions): Promise<boolean>;
277
+ list<K extends string>(query: ListDTO<T> | undefined, opts: PopulateReadOptions<K & RelationPath<T, K>>): Promise<ListResult<Populated<T, RelationPath<T, K>>>>;
278
+ list(query?: ListDTO<T>): Promise<ListResult<Entity<T>>>;
279
+ list(query: ListDTO<T> | undefined, opts: ReadOptions): Promise<ListResult<Entity<T>>>;
280
+ stream(where?: WhereDTO<T>, options?: StreamOptions): AsyncIterable<Entity<T>> & AsyncDisposable;
281
+ findByFullText(column: string, term: string, options?: ReadOptions): Promise<readonly Record<string, unknown>[]>;
282
+ findJoined<Target extends DeclaredTable, Kind extends 'inner' | 'left' = 'left'>(join: {
283
+ target: TaggedSchema<Target>;
284
+ leftCol: string;
285
+ rightCol: string;
286
+ kind?: Kind;
287
+ }, where?: {
288
+ col: string;
289
+ op: string;
290
+ value: unknown;
291
+ }, options?: ReadOptions): Promise<readonly JoinRow<Entity<T>, Entity<Target>, Kind>[]>;
292
+ findJoined<Joined = Record<string, unknown>, Kind extends 'inner' | 'left' = 'left'>(join: {
293
+ target: string;
294
+ leftCol: string;
295
+ rightCol: string;
296
+ kind?: Kind;
297
+ }, where?: {
298
+ col: string;
299
+ op: string;
300
+ value: unknown;
301
+ }, options?: ReadOptions): Promise<readonly JoinRow<Entity<T>, Joined, Kind>[]>;
302
+ /**
303
+ * A relation as a join: the target table, aliased to the relation name, and its ordered column pairs.
304
+ *
305
+ * One expression for both directions, where the map-driven version needed a branch per
306
+ * cardinality — the two spellings put the joining column under a different key depending
307
+ * on which side owned it (`fk` on the owning side, `mappedBy` on the inverse), and each
308
+ * arm then had a fallback that guessed a column name from the table name. `parentKey` and
309
+ * `targetKey` are already the answer to "which column on which side", so there is nothing
310
+ * left to guess and no default to be wrong about.
311
+ */
312
+ protected resolveRelationJoin(relationName: string): {
313
+ targetTable: string;
314
+ filterTable: string;
315
+ targetReference: string;
316
+ conditions: readonly JoinCondition[];
317
+ };
318
+ private filteredRelationJoin;
319
+ private createRepositoryAggregateBuilder;
320
+ aggregate<Out extends Record<string, unknown> = Record<string, unknown>>(specOrBuild: AggregateSpec<T> | ((agg: RepositoryAggregateBuilder) => AggregateSelect | void), options?: ReadOptions): Promise<readonly Out[]>;
321
+ findAllWithMany<K extends RelationKeys<T> & string>(relationName: K, options?: ReadOptions): Promise<readonly Populated<T, K>[]>;
322
+ findAllWithMany(relationName: string, childTable: string, childFk: string, parentKey?: string, options?: ReadOptions): Promise<readonly Record<string, unknown>[]>;
323
+ create(dto: CreateDTO<T>, options?: CacheInvalidationOptions): Promise<Entity<T>>;
324
+ upsert(dto: CreateDTO<T>, opts?: UpsertOptions<T>): Promise<Entity<T> | undefined>;
325
+ update(id: PrimaryKeyOf<T>, patch: UpdatePatch<T>, options?: WriteOptions): Promise<Entity<T> | undefined>;
326
+ updateMany(where: WhereDTO<T>, patch: UpdatePatch<T>, options?: WriteOptions): Promise<number | undefined>;
327
+ increment<K extends NumericColumnOf<T>>(id: PrimaryKeyOf<T>, column: K, by?: NumericOperandOf<T, K>, options?: WriteOptions): Promise<Entity<T> | undefined>;
328
+ private updateOne;
329
+ /**
330
+ * Refuse a keyed write that lost its `WHERE`.
331
+ *
332
+ * `update` and `delete` build the where clause themselves out of a primary key, so
333
+ * neither has a legitimate unkeyed form and an empty clause is always a bug. The
334
+ * check is here rather than only in the layers that can produce one because the cost
335
+ * of being wrong is the whole table, and it survives a new operator, a new caller, or
336
+ * a fourth way of folding a spec down to nothing (#608).
337
+ */
338
+ private assertKeyed;
339
+ delete(id: PrimaryKeyOf<T>, options?: WriteOptions): Promise<boolean>;
340
+ deleteMany(where: WhereDTO<T>, options?: WriteOptions): Promise<number | undefined>;
341
+ hardDelete(id: PrimaryKeyOf<T>, options?: WriteOptions): Promise<boolean>;
342
+ restore(id: PrimaryKeyOf<T>, options?: WriteOptions): Promise<boolean>;
343
+ private writeMatched;
344
+ private softDeleteUpsertFields;
345
+ protected preInsert(_row: Record<string, unknown>): void;
346
+ protected postInsert(_row: Record<string, unknown>): void;
347
+ protected preUpdate(_patch: Record<string, unknown>): void;
348
+ protected preDelete(_id: PrimaryKeyOf<T>): void;
349
+ protected postSelect(rows: readonly Record<string, unknown>[]): readonly Record<string, unknown>[];
350
+ private sanitizePayload;
351
+ /**
352
+ * One write variant's columns, and the object type they add up to.
353
+ *
354
+ * Built once per repository instance per variant. `this.schema` is a static and never
355
+ * changes, so neither can the IR; without the cache every `create` would walk the
356
+ * columns again to rebuild an identical object graph.
357
+ */
358
+ private payloadShape;
359
+ /**
360
+ * One issue per key the payload has and this variant does not accept (REQ-RP-3).
361
+ *
362
+ * These used to be dropped in silence, which made two mistakes invisible. A misspelled
363
+ * column — `{ emial: 'a@b.co' }` — reported only that `email` was missing, and a
364
+ * supplied `id` on a serial key reported nothing at all: the insert went through with a
365
+ * key the database was about to generate, so the payload the caller wrote and the row
366
+ * that came back disagreed and nothing said so.
367
+ *
368
+ * Reported alongside the structural issues rather than only when there are none, which
369
+ * is where this deliberately differs from `assertEquals`'s excess check. Its rule is
370
+ * that "you also passed `extra`" is noise next to "`email` is not a string", and at a
371
+ * table boundary it usually is not noise: the excess key is a typo *of* the column the
372
+ * other issue is complaining about, and suppressing it hides the answer.
373
+ */
374
+ private excessIssues;
375
+ /**
376
+ * Runtime validation of a write payload — the type of the payload, checked by the one
377
+ * runtime walker.
378
+ *
379
+ * This used to be a walk of its own over `ColumnMeta`, and it was the fourth of the
380
+ * four that `@zmdb/schema/ir` exists to collapse: it accepted `Date | string` for
381
+ * a `timestamp` while the published document said ISO string and `Entity<T>` said
382
+ * `Date`, and it had no notion of `Min`/`Max`/`Pattern` at all, so a repository write
383
+ * skipped every bound the schema declared and the same value was rejected only later,
384
+ * at the HTTP edge, by a different validator. What it needed was not a walk but the
385
+ * *type* of a `CreateDTO`, which `objectTypeFromShape` produces from the same IR the
386
+ * documents come from.
387
+ *
388
+ * The app layer, not the wire layer: a caller here holds a `Date`, having decoded the
389
+ * request body already. A handler that has not is the boundary case `Wire<T>` is for.
390
+ *
391
+ * A key the variant does not accept is an issue, not something to drop — see
392
+ * `excessIssues`.
393
+ */
394
+ private validatePayload;
395
+ /**
396
+ * Validate a patch without teaching the DTO validator that arbitrary objects are
397
+ * column values. Plain values still cross the unchanged UpdateDTO object check;
398
+ * branded expressions are omitted from that object and their one operand is
399
+ * checked against the same column IR separately.
400
+ */
401
+ private validateUpdatePatch;
402
+ private validatedColumns;
403
+ private hasColumnExpression;
404
+ }
405
+ export interface DefineRepositoryOptions extends RepositoryOptions {
406
+ readonly dialect?: SqlDialect;
407
+ }
408
+ export declare function defineRepository<T extends DeclaredTable>(schema: TaggedSchema<T>, driver: Driver, opts?: DefineRepositoryOptions): BaseRepository<T>;
409
+ export { memoryStore, type CacheInvalidationOptions, type CacheOptions, type CacheStore } from './cache/index.js';
410
+ export type { FilterDef, FilterOverride, FilterOverrides, FilterParams, FilterPredicate } from './filters/index.js';
411
+ export { createLoaderScope, type EntityLoader, type LoaderScope, type RelationLoader, type RelationValueOf, } from './loaders/index.js';
412
+ export * from './transactions/index.js';
413
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,UAAU,EACf,KAAK,SAAS,EACd,KAAK,aAAa,EAClB,KAAK,MAAM,EACX,KAAK,YAAY,EACjB,KAAK,YAAY,EACjB,KAAK,SAAS,EAEf,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,KAAK,YAAY,EAAE,KAAK,SAAS,EAAE,KAAK,YAAY,EAAE,KAAK,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAC9G,OAAO,EAGL,KAAK,QAAQ,EACb,KAAK,OAAO,EACZ,KAAK,UAAU,EAEf,KAAK,aAAa,EACnB,MAAM,kBAAkB,CAAC;AAc1B,OAAO,EAAE,KAAK,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EAIL,KAAK,aAAa,EAClB,KAAK,aAAa,EAGlB,KAAK,QAAQ,EACb,KAAK,UAAU,EAChB,MAAM,WAAW,CAAC;AACnB,OAAO,EAEL,mBAAmB,EACnB,mBAAmB,EACnB,aAAa,EAKd,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,mBAAmB,EAAE,KAAK,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAEnF,OAAO,EAAsB,KAAK,aAAa,EAAE,MAAM,iBAAiB,CAAC;AACzE,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAM3D,OAAO,EAAa,eAAe,EAAE,KAAK,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAEnF,OAAO,EAKL,KAAK,wBAAwB,EAC7B,KAAK,YAAY,EACjB,KAAK,UAAU,EAChB,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EAIL,KAAK,SAAS,EACd,KAAK,eAAe,EAGrB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAGL,mBAAmB,EACnB,iBAAiB,EACjB,gBA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