@atscript/db 0.1.39 → 0.1.40
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 +18 -18
- package/dist/agg.cjs +8 -3
- package/dist/agg.d.cts +7 -0
- package/dist/agg.d.mts +7 -0
- package/dist/agg.mjs +7 -3
- package/dist/control-DRgryKeg.cjs +14 -0
- package/dist/{control_as-bjmwe24C.mjs → control-IANbnfjG.mjs} +6 -18
- package/dist/db-readable-BQQzfguJ.d.cts +1249 -0
- package/dist/db-readable-Bbr4CjMb.d.mts +1249 -0
- package/dist/db-space-BUrQ5BFm.d.mts +309 -0
- package/dist/db-space-Vxpcnyt5.d.cts +309 -0
- package/dist/db-validator-plugin-07kDiis2.d.cts +22 -0
- package/dist/db-validator-plugin-CiqsHTI_.d.mts +22 -0
- package/dist/db-view-BntnAmXO.cjs +3071 -0
- package/dist/db-view-ZsoN91-q.mjs +2970 -0
- package/dist/index.cjs +95 -2801
- package/dist/index.d.cts +137 -0
- package/dist/index.d.mts +137 -0
- package/dist/index.mjs +55 -2761
- package/dist/{nested-writer-BkqL7cp3.cjs → nested-writer-BDXsDMPP.cjs} +196 -150
- package/dist/{nested-writer-NEN51mnR.mjs → nested-writer-Dmm1gbZV.mjs} +118 -70
- package/dist/ops-BdRAFLKY.d.mts +67 -0
- package/dist/ops-DXJ4Zw0P.d.cts +67 -0
- package/dist/ops.cjs +123 -0
- package/dist/ops.d.cts +2 -0
- package/dist/ops.d.mts +2 -0
- package/dist/ops.mjs +112 -0
- package/dist/plugin.cjs +90 -109
- package/dist/plugin.d.cts +6 -0
- package/dist/plugin.d.mts +6 -0
- package/dist/plugin.mjs +29 -49
- package/dist/rel.cjs +20 -20
- package/dist/rel.d.cts +119 -0
- package/dist/rel.d.mts +119 -0
- package/dist/rel.mjs +4 -5
- package/dist/{relation-helpers-guFL_oRf.cjs → relation-helpers-BYvsE1tR.cjs} +26 -22
- package/dist/{relation-helpers-DyBIlQnB.mjs → relation-helpers-CLasawQq.mjs} +11 -6
- package/dist/{relation-loader-Dv7qXYq7.mjs → relation-loader-BEOTXNcq.mjs} +63 -43
- package/dist/{relation-loader-CpnDRf9k.cjs → relation-loader-CRC5LcqM.cjs} +74 -49
- package/dist/shared.cjs +13 -13
- package/dist/{shared.d.ts → shared.d.cts} +14 -13
- package/dist/shared.d.mts +71 -0
- package/dist/shared.mjs +2 -3
- package/dist/sync.cjs +300 -252
- package/dist/sync.d.cts +369 -0
- package/dist/sync.d.mts +369 -0
- package/dist/sync.mjs +284 -233
- package/dist/{validation-utils-DEoCMmEb.cjs → validation-utils-DVJDijnB.cjs} +141 -109
- package/dist/{validation-utils-DhR_mtKa.mjs → validation-utils-DhjIjP1-.mjs} +71 -37
- package/package.json +30 -29
- package/LICENSE +0 -21
- package/dist/agg-BJFJ3dFQ.mjs +0 -8
- package/dist/agg-DnUWAOK8.cjs +0 -14
- package/dist/agg.d.ts +0 -13
- package/dist/chunk-CrpGerW8.cjs +0 -31
- package/dist/control_as-BFPERAF_.cjs +0 -28
- package/dist/index.d.ts +0 -1706
- package/dist/logger-B7oxCfLQ.mjs +0 -12
- package/dist/logger-Dt2v_-wb.cjs +0 -18
- package/dist/plugin.d.ts +0 -5
- package/dist/rel.d.ts +0 -1305
- package/dist/relation-loader-D4mTw6yH.cjs +0 -4
- package/dist/relation-loader-Ggy1ujwR.mjs +0 -4
- package/dist/sync.d.ts +0 -1878
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import { $ as Uniquery, A as TDbForeignKey, B as TExistingColumn, C as TCascadeTarget, D as TDbDefaultValue, E as TDbDefaultFn, F as TDbInsertResult, G as TMetadataOverrides, H as TFkLookupResolver, I as TDbReferentialAction, J as TTableOptionDiff, K as TSearchIndexInfo, L as TDbRelation, M as TDbIndexField, N as TDbIndexType, O as TDbDeleteResult, P as TDbInsertManyResult, Q as TypedWithRelation, R as TDbStorageType, S as TCascadeResolver, T as TDbCollation, U as TFkLookupTarget, V as TExistingTableOption, W as TIdDescriptor, X as TValueFormatterPair, Y as TTableResolver, Z as TWriteTableResolver, _ as DbQuery, a as FieldMappingStrategy, b as NavPropsOf, c as NoopLogger, d as AggregateExpr, et as UniqueryControls, f as AggregateFn, g as DbControls, h as AtscriptDbWritable, i as DocumentFieldMapper, j as TDbIndex, k as TDbFieldMeta, l as TGenericLogger, m as AggregateResult, n as DbResponse, nt as UniquSelect, o as BaseDbAdapter, p as AggregateQuery, q as TSyncColumnResult, r as resolveDesignType, s as TableMetadata, t as AtscriptDbReadable, tt as WithRelation, u as AggregateControls, v as FieldOpsFor, w as TColumnDiff, x as OwnPropsOf, y as FilterExpr, z as TDbUpdateResult } from "./db-readable-BQQzfguJ.cjs";
|
|
2
|
+
import { d as getDbFieldOp, f as isDbFieldOp, l as TDbFieldOp, p as separateFieldOps, u as TFieldOps } from "./ops-DXJ4Zw0P.cjs";
|
|
3
|
+
import { a as AtscriptQueryComparison, c as AtscriptRef, d as translateQueryTree, f as AtscriptDbTable, i as TViewColumnMapping, l as TViewJoin, m as NativeIntegrity, n as TAdapterFactory, o as AtscriptQueryFieldRef, p as IntegrityStrategy, r as AtscriptDbView, s as AtscriptQueryNode, t as DbSpace, u as TViewPlan } from "./db-space-Vxpcnyt5.cjs";
|
|
4
|
+
import { n as createDbValidatorPlugin, t as DbValidationContext } from "./db-validator-plugin-07kDiis2.cjs";
|
|
5
|
+
import { AggregateQuery as AggregateQuery$1, FilterExpr as FilterExpr$1, FilterVisitor, Uniquery as Uniquery$1, computeInsights, isPrimitive, walkFilter } from "@uniqu/core";
|
|
6
|
+
import { TAtscriptAnnotatedType, TAtscriptTypeArray } from "@atscript/typescript/utils";
|
|
7
|
+
|
|
8
|
+
//#region src/strategies/relational-field-mapper.d.ts
|
|
9
|
+
/**
|
|
10
|
+
* Field mapper for relational adapters (e.g. SQLite, MySQL).
|
|
11
|
+
* Flattens nested objects to `__`-separated column names and
|
|
12
|
+
* reconstructs them on read. Applies full physical-name translation
|
|
13
|
+
* for queries, filters, and controls.
|
|
14
|
+
*/
|
|
15
|
+
declare class RelationalFieldMapper extends FieldMappingStrategy {
|
|
16
|
+
reconstructFromRead(row: Record<string, unknown>, meta: TableMetadata): Record<string, unknown>;
|
|
17
|
+
translateQuery(query: Uniquery$1, meta: TableMetadata): DbQuery;
|
|
18
|
+
translateAggregateQuery(query: AggregateQuery$1, meta: TableMetadata): DbQuery;
|
|
19
|
+
/**
|
|
20
|
+
* Translates filter with key renaming from logical to physical names.
|
|
21
|
+
* Used by the relational query path where field paths must be mapped
|
|
22
|
+
* to `__`-separated column names.
|
|
23
|
+
*/
|
|
24
|
+
translateFilterWithRename(filter: FilterExpr$1, meta: TableMetadata): FilterExpr$1;
|
|
25
|
+
prepareForWrite(payload: Record<string, unknown>, meta: TableMetadata, adapter: BaseDbAdapter): Record<string, unknown>;
|
|
26
|
+
translatePatchKeys(update: Record<string, unknown>, meta: TableMetadata): Record<string, unknown>;
|
|
27
|
+
/**
|
|
28
|
+
* Translates field names in sort and projection controls from
|
|
29
|
+
* logical dot-paths to physical column names.
|
|
30
|
+
*/
|
|
31
|
+
private translateControls;
|
|
32
|
+
/**
|
|
33
|
+
* Flattens nested object fields into __-separated keys and
|
|
34
|
+
* JSON-stringifies @db.json / array fields.
|
|
35
|
+
*/
|
|
36
|
+
private flattenPayload;
|
|
37
|
+
/**
|
|
38
|
+
* Classifies and writes a single field to the result object.
|
|
39
|
+
* Recurses into nested objects that should be flattened.
|
|
40
|
+
*/
|
|
41
|
+
private writeFlattenedField;
|
|
42
|
+
/**
|
|
43
|
+
* When a parent object is null/undefined, set all its flattened children to null.
|
|
44
|
+
*/
|
|
45
|
+
private setFlattenedChildrenNull;
|
|
46
|
+
}
|
|
47
|
+
//#endregion
|
|
48
|
+
//#region src/strategies/application-integrity.d.ts
|
|
49
|
+
/**
|
|
50
|
+
* Integrity strategy for adapters without native FK support (e.g. MongoDB).
|
|
51
|
+
* Validates FK constraints and executes cascade/setNull actions at
|
|
52
|
+
* the application level.
|
|
53
|
+
*/
|
|
54
|
+
declare class ApplicationIntegrity extends IntegrityStrategy {
|
|
55
|
+
/**
|
|
56
|
+
* Validates FK constraints by querying target tables for referenced records.
|
|
57
|
+
* Collects unique FK values across items, batches them into target-table
|
|
58
|
+
* lookups, and throws FK_VIOLATION if any references are missing.
|
|
59
|
+
*/
|
|
60
|
+
validateForeignKeys(items: Array<Record<string, unknown>>, meta: TableMetadata, fkLookupResolver: TFkLookupResolver | undefined, writeTableResolver: TWriteTableResolver | undefined, partial?: boolean, excludeTargetTable?: string): Promise<void>;
|
|
61
|
+
/**
|
|
62
|
+
* Applies cascade/setNull actions on child tables before deleting parent records.
|
|
63
|
+
* Finds all records matching `filter`, extracts their PK values, then for each
|
|
64
|
+
* child table with a FK pointing to this table:
|
|
65
|
+
* - `restrict`: throws if any children exist
|
|
66
|
+
* - `cascade`: recursively deletes child records
|
|
67
|
+
* - `setNull`: sets FK fields to null
|
|
68
|
+
*/
|
|
69
|
+
cascadeBeforeDelete(filter: FilterExpr$1, tableName: string, meta: TableMetadata, cascadeResolver: TCascadeResolver, translateFilter: (f: FilterExpr$1) => FilterExpr$1, adapter: BaseDbAdapter): Promise<void>;
|
|
70
|
+
needsCascade(cascadeResolver: TCascadeResolver | undefined): boolean;
|
|
71
|
+
private recordKey;
|
|
72
|
+
/**
|
|
73
|
+
* Builds a filter for child records whose FK matches the deleted parent's PK values.
|
|
74
|
+
*/
|
|
75
|
+
private buildCascadeChildFilter;
|
|
76
|
+
}
|
|
77
|
+
//#endregion
|
|
78
|
+
//#region src/db-error.d.ts
|
|
79
|
+
type DbErrorCode = "CONFLICT" | "FK_VIOLATION" | "NOT_FOUND" | "CASCADE_CYCLE" | "INVALID_QUERY";
|
|
80
|
+
declare class DbError extends Error {
|
|
81
|
+
readonly code: DbErrorCode;
|
|
82
|
+
readonly errors: Array<{
|
|
83
|
+
path: string;
|
|
84
|
+
message: string;
|
|
85
|
+
}>;
|
|
86
|
+
name: string;
|
|
87
|
+
constructor(code: DbErrorCode, errors: Array<{
|
|
88
|
+
path: string;
|
|
89
|
+
message: string;
|
|
90
|
+
}>, message?: string);
|
|
91
|
+
}
|
|
92
|
+
//#endregion
|
|
93
|
+
//#region src/patch/patch-decomposer.d.ts
|
|
94
|
+
/**
|
|
95
|
+
* Decomposes a patch payload into a flat update object for adapters
|
|
96
|
+
* that don't support native patch operations.
|
|
97
|
+
*
|
|
98
|
+
* Handles:
|
|
99
|
+
* - Top-level array patches (`$replace`, `$insert`, `$upsert`, `$update`, `$remove`)
|
|
100
|
+
* - Merge strategy for nested objects
|
|
101
|
+
* - Simple field sets
|
|
102
|
+
*
|
|
103
|
+
* For adapters with native patch support (e.g., MongoDB aggregation pipelines),
|
|
104
|
+
* use {@link BaseDbAdapter.nativePatch} instead.
|
|
105
|
+
*
|
|
106
|
+
* @param payload - The patch payload from the user.
|
|
107
|
+
* @param table - The AtscriptDbTable instance for metadata access.
|
|
108
|
+
* @returns A flat update object suitable for a basic `updateOne` call.
|
|
109
|
+
*/
|
|
110
|
+
declare function decomposePatch(payload: Record<string, unknown>, table: AtscriptDbTable): Record<string, unknown>;
|
|
111
|
+
//#endregion
|
|
112
|
+
//#region src/patch/patch-types.d.ts
|
|
113
|
+
interface TArrayPatch<A extends readonly unknown[]> {
|
|
114
|
+
$replace?: A;
|
|
115
|
+
$insert?: A;
|
|
116
|
+
$upsert?: A;
|
|
117
|
+
$update?: Array<Partial<TArrayElement<A>>>;
|
|
118
|
+
$remove?: Array<Partial<TArrayElement<A>>>;
|
|
119
|
+
}
|
|
120
|
+
type TArrayElement<ArrayType extends readonly unknown[]> = ArrayType extends ReadonlyArray<infer ElementType> ? ElementType : never;
|
|
121
|
+
/**
|
|
122
|
+
* Maps each property of T into a patch payload:
|
|
123
|
+
* - Array properties become `TArrayPatch<T[K]>`
|
|
124
|
+
* - Non-array properties become `Partial<T[K]>`
|
|
125
|
+
*/
|
|
126
|
+
type TDbPatch<T> = { [K in keyof T]?: T[K] extends Array<infer _> ? TArrayPatch<T[K]> : Partial<T[K]> };
|
|
127
|
+
/**
|
|
128
|
+
* Extracts `@expect.array.key` properties from an array-of-objects type.
|
|
129
|
+
* These keys uniquely identify an element inside the array and are used
|
|
130
|
+
* for `$update`, `$remove`, and `$upsert` operations.
|
|
131
|
+
*
|
|
132
|
+
* @param def - Atscript array type definition.
|
|
133
|
+
* @returns Set of property names marked as keys; empty set if none.
|
|
134
|
+
*/
|
|
135
|
+
declare function getKeyProps(def: TAtscriptAnnotatedType<TAtscriptTypeArray>): Set<string>;
|
|
136
|
+
//#endregion
|
|
137
|
+
export { type AggregateControls, type AggregateExpr, type AggregateFn, type AggregateQuery, type AggregateResult, ApplicationIntegrity, AtscriptDbReadable, AtscriptDbTable, AtscriptDbView, type AtscriptDbWritable, type AtscriptQueryComparison, type AtscriptQueryFieldRef, type AtscriptQueryNode, type AtscriptRef, BaseDbAdapter, type DbControls, DbError, type DbErrorCode, type DbQuery, type DbResponse, DbSpace, type DbValidationContext, DocumentFieldMapper, FieldMappingStrategy, type FieldOpsFor, type FilterExpr, type FilterVisitor, IntegrityStrategy, NativeIntegrity, type NavPropsOf, NoopLogger, type OwnPropsOf, RelationalFieldMapper, type TAdapterFactory, type TArrayPatch, type TCascadeResolver, type TCascadeTarget, type TColumnDiff, type TDbCollation, type TDbDefaultFn, type TDbDefaultValue, type TDbDeleteResult, type TDbFieldMeta, type TDbFieldOp, type TDbForeignKey, type TDbIndex, type TDbIndexField, type TDbIndexType, type TDbInsertManyResult, type TDbInsertResult, type TDbPatch, type TDbReferentialAction, type TDbRelation, type TDbStorageType, type TDbUpdateResult, type TExistingColumn, type TExistingTableOption, type TFieldOps, type TFkLookupResolver, type TFkLookupTarget, type TGenericLogger, type TIdDescriptor, type TMetadataOverrides, type TSearchIndexInfo, type TSyncColumnResult, type TTableOptionDiff, type TTableResolver, type TValueFormatterPair, type TViewColumnMapping, type TViewJoin, type TViewPlan, type TWriteTableResolver, TableMetadata, type TypedWithRelation, UniquSelect, type Uniquery, type UniqueryControls, type WithRelation, computeInsights, createDbValidatorPlugin, decomposePatch, getDbFieldOp, getKeyProps, isDbFieldOp, isPrimitive, resolveDesignType, separateFieldOps, translateQueryTree, walkFilter };
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import { $ as Uniquery, A as TDbForeignKey, B as TExistingColumn, C as TCascadeTarget, D as TDbDefaultValue, E as TDbDefaultFn, F as TDbInsertResult, G as TMetadataOverrides, H as TFkLookupResolver, I as TDbReferentialAction, J as TTableOptionDiff, K as TSearchIndexInfo, L as TDbRelation, M as TDbIndexField, N as TDbIndexType, O as TDbDeleteResult, P as TDbInsertManyResult, Q as TypedWithRelation, R as TDbStorageType, S as TCascadeResolver, T as TDbCollation, U as TFkLookupTarget, V as TExistingTableOption, W as TIdDescriptor, X as TValueFormatterPair, Y as TTableResolver, Z as TWriteTableResolver, _ as DbQuery, a as FieldMappingStrategy, b as NavPropsOf, c as NoopLogger, d as AggregateExpr, et as UniqueryControls, f as AggregateFn, g as DbControls, h as AtscriptDbWritable, i as DocumentFieldMapper, j as TDbIndex, k as TDbFieldMeta, l as TGenericLogger, m as AggregateResult, n as DbResponse, nt as UniquSelect, o as BaseDbAdapter, p as AggregateQuery, q as TSyncColumnResult, r as resolveDesignType, s as TableMetadata, t as AtscriptDbReadable, tt as WithRelation, u as AggregateControls, v as FieldOpsFor, w as TColumnDiff, x as OwnPropsOf, y as FilterExpr, z as TDbUpdateResult } from "./db-readable-Bbr4CjMb.mjs";
|
|
2
|
+
import { d as getDbFieldOp, f as isDbFieldOp, l as TDbFieldOp, p as separateFieldOps, u as TFieldOps } from "./ops-BdRAFLKY.mjs";
|
|
3
|
+
import { a as AtscriptQueryComparison, c as AtscriptRef, d as translateQueryTree, f as AtscriptDbTable, i as TViewColumnMapping, l as TViewJoin, m as NativeIntegrity, n as TAdapterFactory, o as AtscriptQueryFieldRef, p as IntegrityStrategy, r as AtscriptDbView, s as AtscriptQueryNode, t as DbSpace, u as TViewPlan } from "./db-space-BUrQ5BFm.mjs";
|
|
4
|
+
import { n as createDbValidatorPlugin, t as DbValidationContext } from "./db-validator-plugin-CiqsHTI_.mjs";
|
|
5
|
+
import { TAtscriptAnnotatedType, TAtscriptTypeArray } from "@atscript/typescript/utils";
|
|
6
|
+
import { AggregateQuery as AggregateQuery$1, FilterExpr as FilterExpr$1, FilterVisitor, Uniquery as Uniquery$1, computeInsights, isPrimitive, walkFilter } from "@uniqu/core";
|
|
7
|
+
|
|
8
|
+
//#region src/strategies/relational-field-mapper.d.ts
|
|
9
|
+
/**
|
|
10
|
+
* Field mapper for relational adapters (e.g. SQLite, MySQL).
|
|
11
|
+
* Flattens nested objects to `__`-separated column names and
|
|
12
|
+
* reconstructs them on read. Applies full physical-name translation
|
|
13
|
+
* for queries, filters, and controls.
|
|
14
|
+
*/
|
|
15
|
+
declare class RelationalFieldMapper extends FieldMappingStrategy {
|
|
16
|
+
reconstructFromRead(row: Record<string, unknown>, meta: TableMetadata): Record<string, unknown>;
|
|
17
|
+
translateQuery(query: Uniquery$1, meta: TableMetadata): DbQuery;
|
|
18
|
+
translateAggregateQuery(query: AggregateQuery$1, meta: TableMetadata): DbQuery;
|
|
19
|
+
/**
|
|
20
|
+
* Translates filter with key renaming from logical to physical names.
|
|
21
|
+
* Used by the relational query path where field paths must be mapped
|
|
22
|
+
* to `__`-separated column names.
|
|
23
|
+
*/
|
|
24
|
+
translateFilterWithRename(filter: FilterExpr$1, meta: TableMetadata): FilterExpr$1;
|
|
25
|
+
prepareForWrite(payload: Record<string, unknown>, meta: TableMetadata, adapter: BaseDbAdapter): Record<string, unknown>;
|
|
26
|
+
translatePatchKeys(update: Record<string, unknown>, meta: TableMetadata): Record<string, unknown>;
|
|
27
|
+
/**
|
|
28
|
+
* Translates field names in sort and projection controls from
|
|
29
|
+
* logical dot-paths to physical column names.
|
|
30
|
+
*/
|
|
31
|
+
private translateControls;
|
|
32
|
+
/**
|
|
33
|
+
* Flattens nested object fields into __-separated keys and
|
|
34
|
+
* JSON-stringifies @db.json / array fields.
|
|
35
|
+
*/
|
|
36
|
+
private flattenPayload;
|
|
37
|
+
/**
|
|
38
|
+
* Classifies and writes a single field to the result object.
|
|
39
|
+
* Recurses into nested objects that should be flattened.
|
|
40
|
+
*/
|
|
41
|
+
private writeFlattenedField;
|
|
42
|
+
/**
|
|
43
|
+
* When a parent object is null/undefined, set all its flattened children to null.
|
|
44
|
+
*/
|
|
45
|
+
private setFlattenedChildrenNull;
|
|
46
|
+
}
|
|
47
|
+
//#endregion
|
|
48
|
+
//#region src/strategies/application-integrity.d.ts
|
|
49
|
+
/**
|
|
50
|
+
* Integrity strategy for adapters without native FK support (e.g. MongoDB).
|
|
51
|
+
* Validates FK constraints and executes cascade/setNull actions at
|
|
52
|
+
* the application level.
|
|
53
|
+
*/
|
|
54
|
+
declare class ApplicationIntegrity extends IntegrityStrategy {
|
|
55
|
+
/**
|
|
56
|
+
* Validates FK constraints by querying target tables for referenced records.
|
|
57
|
+
* Collects unique FK values across items, batches them into target-table
|
|
58
|
+
* lookups, and throws FK_VIOLATION if any references are missing.
|
|
59
|
+
*/
|
|
60
|
+
validateForeignKeys(items: Array<Record<string, unknown>>, meta: TableMetadata, fkLookupResolver: TFkLookupResolver | undefined, writeTableResolver: TWriteTableResolver | undefined, partial?: boolean, excludeTargetTable?: string): Promise<void>;
|
|
61
|
+
/**
|
|
62
|
+
* Applies cascade/setNull actions on child tables before deleting parent records.
|
|
63
|
+
* Finds all records matching `filter`, extracts their PK values, then for each
|
|
64
|
+
* child table with a FK pointing to this table:
|
|
65
|
+
* - `restrict`: throws if any children exist
|
|
66
|
+
* - `cascade`: recursively deletes child records
|
|
67
|
+
* - `setNull`: sets FK fields to null
|
|
68
|
+
*/
|
|
69
|
+
cascadeBeforeDelete(filter: FilterExpr$1, tableName: string, meta: TableMetadata, cascadeResolver: TCascadeResolver, translateFilter: (f: FilterExpr$1) => FilterExpr$1, adapter: BaseDbAdapter): Promise<void>;
|
|
70
|
+
needsCascade(cascadeResolver: TCascadeResolver | undefined): boolean;
|
|
71
|
+
private recordKey;
|
|
72
|
+
/**
|
|
73
|
+
* Builds a filter for child records whose FK matches the deleted parent's PK values.
|
|
74
|
+
*/
|
|
75
|
+
private buildCascadeChildFilter;
|
|
76
|
+
}
|
|
77
|
+
//#endregion
|
|
78
|
+
//#region src/db-error.d.ts
|
|
79
|
+
type DbErrorCode = "CONFLICT" | "FK_VIOLATION" | "NOT_FOUND" | "CASCADE_CYCLE" | "INVALID_QUERY";
|
|
80
|
+
declare class DbError extends Error {
|
|
81
|
+
readonly code: DbErrorCode;
|
|
82
|
+
readonly errors: Array<{
|
|
83
|
+
path: string;
|
|
84
|
+
message: string;
|
|
85
|
+
}>;
|
|
86
|
+
name: string;
|
|
87
|
+
constructor(code: DbErrorCode, errors: Array<{
|
|
88
|
+
path: string;
|
|
89
|
+
message: string;
|
|
90
|
+
}>, message?: string);
|
|
91
|
+
}
|
|
92
|
+
//#endregion
|
|
93
|
+
//#region src/patch/patch-decomposer.d.ts
|
|
94
|
+
/**
|
|
95
|
+
* Decomposes a patch payload into a flat update object for adapters
|
|
96
|
+
* that don't support native patch operations.
|
|
97
|
+
*
|
|
98
|
+
* Handles:
|
|
99
|
+
* - Top-level array patches (`$replace`, `$insert`, `$upsert`, `$update`, `$remove`)
|
|
100
|
+
* - Merge strategy for nested objects
|
|
101
|
+
* - Simple field sets
|
|
102
|
+
*
|
|
103
|
+
* For adapters with native patch support (e.g., MongoDB aggregation pipelines),
|
|
104
|
+
* use {@link BaseDbAdapter.nativePatch} instead.
|
|
105
|
+
*
|
|
106
|
+
* @param payload - The patch payload from the user.
|
|
107
|
+
* @param table - The AtscriptDbTable instance for metadata access.
|
|
108
|
+
* @returns A flat update object suitable for a basic `updateOne` call.
|
|
109
|
+
*/
|
|
110
|
+
declare function decomposePatch(payload: Record<string, unknown>, table: AtscriptDbTable): Record<string, unknown>;
|
|
111
|
+
//#endregion
|
|
112
|
+
//#region src/patch/patch-types.d.ts
|
|
113
|
+
interface TArrayPatch<A extends readonly unknown[]> {
|
|
114
|
+
$replace?: A;
|
|
115
|
+
$insert?: A;
|
|
116
|
+
$upsert?: A;
|
|
117
|
+
$update?: Array<Partial<TArrayElement<A>>>;
|
|
118
|
+
$remove?: Array<Partial<TArrayElement<A>>>;
|
|
119
|
+
}
|
|
120
|
+
type TArrayElement<ArrayType extends readonly unknown[]> = ArrayType extends ReadonlyArray<infer ElementType> ? ElementType : never;
|
|
121
|
+
/**
|
|
122
|
+
* Maps each property of T into a patch payload:
|
|
123
|
+
* - Array properties become `TArrayPatch<T[K]>`
|
|
124
|
+
* - Non-array properties become `Partial<T[K]>`
|
|
125
|
+
*/
|
|
126
|
+
type TDbPatch<T> = { [K in keyof T]?: T[K] extends Array<infer _> ? TArrayPatch<T[K]> : Partial<T[K]> };
|
|
127
|
+
/**
|
|
128
|
+
* Extracts `@expect.array.key` properties from an array-of-objects type.
|
|
129
|
+
* These keys uniquely identify an element inside the array and are used
|
|
130
|
+
* for `$update`, `$remove`, and `$upsert` operations.
|
|
131
|
+
*
|
|
132
|
+
* @param def - Atscript array type definition.
|
|
133
|
+
* @returns Set of property names marked as keys; empty set if none.
|
|
134
|
+
*/
|
|
135
|
+
declare function getKeyProps(def: TAtscriptAnnotatedType<TAtscriptTypeArray>): Set<string>;
|
|
136
|
+
//#endregion
|
|
137
|
+
export { type AggregateControls, type AggregateExpr, type AggregateFn, type AggregateQuery, type AggregateResult, ApplicationIntegrity, AtscriptDbReadable, AtscriptDbTable, AtscriptDbView, type AtscriptDbWritable, type AtscriptQueryComparison, type AtscriptQueryFieldRef, type AtscriptQueryNode, type AtscriptRef, BaseDbAdapter, type DbControls, DbError, type DbErrorCode, type DbQuery, type DbResponse, DbSpace, type DbValidationContext, DocumentFieldMapper, FieldMappingStrategy, type FieldOpsFor, type FilterExpr, type FilterVisitor, IntegrityStrategy, NativeIntegrity, type NavPropsOf, NoopLogger, type OwnPropsOf, RelationalFieldMapper, type TAdapterFactory, type TArrayPatch, type TCascadeResolver, type TCascadeTarget, type TColumnDiff, type TDbCollation, type TDbDefaultFn, type TDbDefaultValue, type TDbDeleteResult, type TDbFieldMeta, type TDbFieldOp, type TDbForeignKey, type TDbIndex, type TDbIndexField, type TDbIndexType, type TDbInsertManyResult, type TDbInsertResult, type TDbPatch, type TDbReferentialAction, type TDbRelation, type TDbStorageType, type TDbUpdateResult, type TExistingColumn, type TExistingTableOption, type TFieldOps, type TFkLookupResolver, type TFkLookupTarget, type TGenericLogger, type TIdDescriptor, type TMetadataOverrides, type TSearchIndexInfo, type TSyncColumnResult, type TTableOptionDiff, type TTableResolver, type TValueFormatterPair, type TViewColumnMapping, type TViewJoin, type TViewPlan, type TWriteTableResolver, TableMetadata, type TypedWithRelation, UniquSelect, type Uniquery, type UniqueryControls, type WithRelation, computeInsights, createDbValidatorPlugin, decomposePatch, getDbFieldOp, getKeyProps, isDbFieldOp, isPrimitive, resolveDesignType, separateFieldOps, translateQueryTree, walkFilter };
|