@atscript/db 0.1.54 → 0.1.55
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/db-error-Cepx-RsQ.mjs +29 -0
- package/dist/db-error-D8tQhNgM.cjs +40 -0
- package/dist/{db-readable-ktHqF277.d.cts → db-readable-DtrC0BGF.d.cts} +122 -115
- package/dist/{db-readable-GBjlsJXR.d.mts → db-readable-RTtqL7H4.d.mts} +123 -116
- package/dist/{db-space-DB0MT6B3.d.cts → db-space-BqVLHVq7.d.cts} +14 -1
- package/dist/{db-space-DpaXOdRp.d.mts → db-space-D3QSKx2B.d.mts} +14 -1
- package/dist/{db-validator-plugin-Cz4QoDWg.d.cts → db-validator-plugin-DDvYyv5t.d.mts} +10 -0
- package/dist/{db-validator-plugin-KC4aNIQq.d.mts → db-validator-plugin-DRGMCEn3.d.cts} +10 -0
- package/dist/{db-view-DjDKgytJ.cjs → db-view-DIGN4079.cjs} +81 -19
- package/dist/{db-view-B1j_IKSf.mjs → db-view-DNwX6_4x.mjs} +72 -10
- package/dist/index.cjs +5 -4
- package/dist/index.d.cts +4 -4
- package/dist/index.d.mts +6 -6
- package/dist/index.mjs +4 -3
- package/dist/{nested-writer-CNDyhg2L.mjs → nested-writer-CT2rLURx.mjs} +9 -16
- package/dist/{nested-writer-BIQ6EfaR.cjs → nested-writer-v_LPR1yJ.cjs} +14 -27
- package/dist/ops.d.mts +1 -1
- package/dist/plugin.cjs +99 -9
- package/dist/plugin.mjs +99 -9
- package/dist/rel.cjs +1 -1
- package/dist/rel.d.cts +2 -2
- package/dist/rel.d.mts +2 -2
- package/dist/rel.mjs +1 -1
- package/dist/shared.cjs +1 -1
- package/dist/shared.mjs +1 -1
- package/dist/sync.cjs +5 -5
- package/dist/sync.d.cts +2 -2
- package/dist/sync.d.mts +2 -2
- package/dist/sync.mjs +5 -5
- package/dist/{validator-D_7Fqzs4.mjs → validator-BB5h1Le3.mjs} +42 -0
- package/dist/{validator-0iGuvGOD.cjs → validator-BIuw_T0k.cjs} +42 -0
- package/dist/validator.cjs +1 -1
- package/dist/validator.d.cts +1 -1
- package/dist/validator.d.mts +3 -3
- package/dist/validator.mjs +1 -1
- package/package.json +6 -6
- /package/dist/{control-D1QdBO21.cjs → control-CDnwVj4q.cjs} +0 -0
- /package/dist/{control-DBd_ff5-.mjs → control-ExEKWYBE.mjs} +0 -0
- /package/dist/{ops-DcHDxrjX.d.mts → ops-C61kelof.d.mts} +0 -0
- /package/dist/{validation-utils-BiG3pLP0.cjs → validation-utils-B9WJv9aH.cjs} +0 -0
- /package/dist/{validation-utils-aNrgK-cj.mjs → validation-utils-Bh7RVrVl.mjs} +0 -0
- /package/dist/{validator-BeXlQISk.d.mts → validator-DttN2e5_.d.mts} +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { B as TFkLookupResolver, I as TDbUpdateResult, M as TDbInsertResult, T as TDbDeleteResult, Y as TTableResolver, Z as TWriteTableResolver, it as TGenericLogger, j as TDbInsertManyResult, nt as TableMetadata, o as BaseDbAdapter, t as AtscriptDbReadable, y as TCascadeResolver } from "./db-readable-RTtqL7H4.mjs";
|
|
2
2
|
import { AtscriptQueryComparison, AtscriptQueryFieldRef, AtscriptQueryFieldRef as AtscriptQueryFieldRef$1, AtscriptQueryNode, AtscriptQueryNode as AtscriptQueryNode$1, AtscriptRef, FlatOf, NavPropsOf, OwnPropsOf, PrimaryKeyOf, TAtscriptAnnotatedType, TAtscriptDataType, Validator } from "@atscript/typescript/utils";
|
|
3
3
|
import { FilterExpr } from "@uniqu/core";
|
|
4
4
|
|
|
@@ -29,6 +29,7 @@ declare class AtscriptDbTable<T extends TAtscriptAnnotatedType = TAtscriptAnnota
|
|
|
29
29
|
protected _fkLookupResolver?: TFkLookupResolver;
|
|
30
30
|
protected readonly _integrity: IntegrityStrategy;
|
|
31
31
|
protected readonly validators: Map<string, Validator<T, DataType>>;
|
|
32
|
+
private _fromDepthMap?;
|
|
32
33
|
constructor(_type: T, adapter: A, logger?: TGenericLogger, _tableResolver?: TTableResolver, _writeTableResolver?: TWriteTableResolver);
|
|
33
34
|
/**
|
|
34
35
|
* Sets the cascade resolver for application-level cascade deletes.
|
|
@@ -141,6 +142,18 @@ declare class AtscriptDbTable<T extends TAtscriptAnnotatedType = TAtscriptAnnota
|
|
|
141
142
|
*/
|
|
142
143
|
protected _extractRecordFilter(payload: Record<string, unknown>): FilterExpr;
|
|
143
144
|
private _prepareFilterValue;
|
|
145
|
+
/**
|
|
146
|
+
* Lazy — builds a `normalized-path → from-depth` map from `this._meta.flatMap`
|
|
147
|
+
* on first use. Only paths reachable through an unbroken chain of `db.rel.from`
|
|
148
|
+
* nav fields from the root are included (chains crossing `to`/`via` are excluded).
|
|
149
|
+
*/
|
|
150
|
+
private _getFromDepthMap;
|
|
151
|
+
/**
|
|
152
|
+
* Populate the depth-limit bundle on a `DbValidationContext`. Only the root
|
|
153
|
+
* write call (`depth === 0`) enforces — nested re-entries leave `depthCheck`
|
|
154
|
+
* unset so the full tree is validated once at the root.
|
|
155
|
+
*/
|
|
156
|
+
private _applyDepthCtx;
|
|
144
157
|
/**
|
|
145
158
|
* Pre-validate items (type validation + FK constraints) without inserting them.
|
|
146
159
|
* Used by parent tables to validate FROM children before the main insert,
|
|
@@ -7,6 +7,16 @@ interface DbValidationContext {
|
|
|
7
7
|
flatMap?: Map<string, TAtscriptAnnotatedType>;
|
|
8
8
|
/** Precomputed nav field names — used to skip field-op validation inside TO/FROM/VIA relations. */
|
|
9
9
|
navFields?: ReadonlySet<string>;
|
|
10
|
+
/**
|
|
11
|
+
* Depth-limit enforcement bundle. Set only on the root write call; nested
|
|
12
|
+
* re-entries leave it unset so the root's check isn't repeated. `limit` is
|
|
13
|
+
* `@db.depth.limit N`; `fromDepthMap` maps normalized paths (no array
|
|
14
|
+
* indices) to from-chain depth.
|
|
15
|
+
*/
|
|
16
|
+
depthCheck?: {
|
|
17
|
+
limit: number;
|
|
18
|
+
fromDepthMap: ReadonlyMap<string, number>;
|
|
19
|
+
};
|
|
10
20
|
}
|
|
11
21
|
/**
|
|
12
22
|
* Validator plugin for database operations.
|
|
@@ -7,6 +7,16 @@ interface DbValidationContext {
|
|
|
7
7
|
flatMap?: Map<string, TAtscriptAnnotatedType>;
|
|
8
8
|
/** Precomputed nav field names — used to skip field-op validation inside TO/FROM/VIA relations. */
|
|
9
9
|
navFields?: ReadonlySet<string>;
|
|
10
|
+
/**
|
|
11
|
+
* Depth-limit enforcement bundle. Set only on the root write call; nested
|
|
12
|
+
* re-entries leave it unset so the root's check isn't repeated. `limit` is
|
|
13
|
+
* `@db.depth.limit N`; `fromDepthMap` maps normalized paths (no array
|
|
14
|
+
* indices) to from-chain depth.
|
|
15
|
+
*/
|
|
16
|
+
depthCheck?: {
|
|
17
|
+
limit: number;
|
|
18
|
+
fromDepthMap: ReadonlyMap<string, number>;
|
|
19
|
+
};
|
|
10
20
|
}
|
|
11
21
|
/**
|
|
12
22
|
* Validator plugin for database operations.
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
const
|
|
1
|
+
const require_db_error = require("./db-error-D8tQhNgM.cjs");
|
|
2
2
|
const require_agg = require("./agg.cjs");
|
|
3
3
|
const require_relation_helpers = require("./relation-helpers-BYvsE1tR.cjs");
|
|
4
4
|
const require_ops = require("./ops.cjs");
|
|
5
|
-
const require_validator = require("./validator-
|
|
5
|
+
const require_validator = require("./validator-BIuw_T0k.cjs");
|
|
6
|
+
const require_nested_writer = require("./nested-writer-v_LPR1yJ.cjs");
|
|
6
7
|
let _atscript_typescript_utils = require("@atscript/typescript/utils");
|
|
7
8
|
let node_async_hooks = require("node:async_hooks");
|
|
8
9
|
//#region src/logger.ts
|
|
@@ -1096,8 +1097,17 @@ var AtscriptDbReadable = class {
|
|
|
1096
1097
|
_ensureBuilt() {
|
|
1097
1098
|
if (!this._meta.isBuilt) this._meta.build(this.type, this.adapter, this.logger);
|
|
1098
1099
|
}
|
|
1100
|
+
/**
|
|
1101
|
+
* Built table metadata. Triggers a lazy build on first access — safe to call
|
|
1102
|
+
* from peer tables that need this one's relations / nav fields before any
|
|
1103
|
+
* operation has run against it directly.
|
|
1104
|
+
*/
|
|
1105
|
+
getMetadata() {
|
|
1106
|
+
this._ensureBuilt();
|
|
1107
|
+
return this._meta;
|
|
1108
|
+
}
|
|
1099
1109
|
_ensureSearchable() {
|
|
1100
|
-
if (!this.adapter.isSearchable()) throw new
|
|
1110
|
+
if (!this.adapter.isSearchable()) throw new require_db_error.DbError("INVALID_QUERY", [{
|
|
1101
1111
|
path: "$search",
|
|
1102
1112
|
message: `Table "${this.tableName}" has no search indexes defined`
|
|
1103
1113
|
}]);
|
|
@@ -1295,7 +1305,7 @@ var AtscriptDbReadable = class {
|
|
|
1295
1305
|
const { $groupBy, $select } = query.controls;
|
|
1296
1306
|
if ($select) {
|
|
1297
1307
|
const groupBySet = new Set($groupBy);
|
|
1298
|
-
for (const item of $select) if (typeof item === "string" && !groupBySet.has(item)) throw new
|
|
1308
|
+
for (const item of $select) if (typeof item === "string" && !groupBySet.has(item)) throw new require_db_error.DbError("INVALID_QUERY", [{
|
|
1299
1309
|
path: "$select",
|
|
1300
1310
|
message: `Plain field "${item}" in $select must also appear in $groupBy`
|
|
1301
1311
|
}]);
|
|
@@ -1304,12 +1314,12 @@ var AtscriptDbReadable = class {
|
|
|
1304
1314
|
if (dimensions.length > 0 || measures.length > 0) {
|
|
1305
1315
|
const dimSet = new Set(dimensions);
|
|
1306
1316
|
const measSet = new Set(measures);
|
|
1307
|
-
for (const field of $groupBy) if (!dimSet.has(field)) throw new
|
|
1317
|
+
for (const field of $groupBy) if (!dimSet.has(field)) throw new require_db_error.DbError("INVALID_QUERY", [{
|
|
1308
1318
|
path: "$groupBy",
|
|
1309
1319
|
message: `Field "${field}" is not a dimension`
|
|
1310
1320
|
}]);
|
|
1311
1321
|
if ($select) {
|
|
1312
|
-
for (const item of $select) if (typeof item !== "string" && item.$field !== "*" && !measSet.has(item.$field)) throw new
|
|
1322
|
+
for (const item of $select) if (typeof item !== "string" && item.$field !== "*" && !measSet.has(item.$field)) throw new require_db_error.DbError("INVALID_QUERY", [{
|
|
1313
1323
|
path: "$select",
|
|
1314
1324
|
message: `Aggregate field "${item.$field}" is not a measure`
|
|
1315
1325
|
}]);
|
|
@@ -1977,7 +1987,7 @@ var ApplicationIntegrity = class extends IntegrityStrategy {
|
|
|
1977
1987
|
if (await target.count(filter) < expectedCount) {
|
|
1978
1988
|
const sample = firstValues.slice(0, 3).join(", ");
|
|
1979
1989
|
const suffix = firstValues.length > 3 ? `, ... (${firstValues.length} total)` : "";
|
|
1980
|
-
throw new
|
|
1990
|
+
throw new require_db_error.DbError("FK_VIOLATION", [{
|
|
1981
1991
|
path: fk.fields.join(", "),
|
|
1982
1992
|
message: `FK constraint violation: "${fk.fields.join(", ")}" references non-existent record in "${fk.targetTable}" (values: ${sample}${suffix})`
|
|
1983
1993
|
}]);
|
|
@@ -1998,7 +2008,7 @@ var ApplicationIntegrity = class extends IntegrityStrategy {
|
|
|
1998
2008
|
const parentCtx = cascadeStorage.getStore();
|
|
1999
2009
|
const visited = parentCtx?.visited ?? /* @__PURE__ */ new Set();
|
|
2000
2010
|
const depth = (parentCtx?.depth ?? 0) + 1;
|
|
2001
|
-
if (depth > MAX_CASCADE_DEPTH) throw new
|
|
2011
|
+
if (depth > MAX_CASCADE_DEPTH) throw new require_db_error.DbError("CASCADE_CYCLE", [{
|
|
2002
2012
|
path: tableName,
|
|
2003
2013
|
message: `Cascade delete aborted: chain exceeded ${MAX_CASCADE_DEPTH} levels, likely caused by a circular or deeply nested cascade relationship`
|
|
2004
2014
|
}]);
|
|
@@ -2046,7 +2056,7 @@ var ApplicationIntegrity = class extends IntegrityStrategy {
|
|
|
2046
2056
|
const childFilter = this.buildCascadeChildFilter(records, target.fk);
|
|
2047
2057
|
if (!childFilter) continue;
|
|
2048
2058
|
restrictChecks.push(target.count(childFilter).then((count) => {
|
|
2049
|
-
if (count > 0) throw new
|
|
2059
|
+
if (count > 0) throw new require_db_error.DbError("CONFLICT", [{
|
|
2050
2060
|
path: tableName,
|
|
2051
2061
|
message: `Cannot delete from "${tableName}": ${count} record(s) in "${target.childTable}" (${target.fk.fields.join(", ")}) reference it (RESTRICT)`
|
|
2052
2062
|
}]);
|
|
@@ -2358,6 +2368,7 @@ var AtscriptDbTable = class extends AtscriptDbReadable {
|
|
|
2358
2368
|
_fkLookupResolver;
|
|
2359
2369
|
_integrity;
|
|
2360
2370
|
validators = /* @__PURE__ */ new Map();
|
|
2371
|
+
_fromDepthMap;
|
|
2361
2372
|
constructor(_type, adapter, logger, _tableResolver, _writeTableResolver) {
|
|
2362
2373
|
super(_type, adapter, logger, _tableResolver);
|
|
2363
2374
|
if (_writeTableResolver) this._writeTableResolver = _writeTableResolver;
|
|
@@ -2411,16 +2422,20 @@ var AtscriptDbTable = class extends AtscriptDbReadable {
|
|
|
2411
2422
|
*/
|
|
2412
2423
|
async insertMany(payloads, opts) {
|
|
2413
2424
|
this._ensureBuilt();
|
|
2414
|
-
const maxDepth = opts
|
|
2415
|
-
const
|
|
2425
|
+
const { _depth, maxDepth: userMax } = opts ?? {};
|
|
2426
|
+
const maxDepth = userMax ?? 3;
|
|
2427
|
+
const depth = _depth ?? 0;
|
|
2416
2428
|
const canNest = depth < maxDepth && this._writeTableResolver && this._meta.navFields.size > 0;
|
|
2417
2429
|
if (!canNest && this._meta.navFields.size > 0) require_nested_writer.checkDepthOverflow(payloads, maxDepth, this._meta);
|
|
2418
2430
|
return require_nested_writer.enrichFkViolation(this._meta, () => this.adapter.withTransaction(async () => {
|
|
2419
2431
|
const items = payloads.map((p) => this._applyDefaults({ ...p }));
|
|
2420
|
-
|
|
2432
|
+
const validator = this.getValidator("insert");
|
|
2433
|
+
const ctx = {
|
|
2421
2434
|
mode: "insert",
|
|
2422
2435
|
navFields: this._meta.navFields
|
|
2423
|
-
}
|
|
2436
|
+
};
|
|
2437
|
+
this._applyDepthCtx(ctx, depth);
|
|
2438
|
+
require_nested_writer.validateBatch(validator, items, ctx);
|
|
2424
2439
|
const host = this;
|
|
2425
2440
|
if (canNest) await require_nested_writer.batchInsertNestedTo(host, items, maxDepth, depth);
|
|
2426
2441
|
const prepared = [];
|
|
@@ -2460,10 +2475,13 @@ var AtscriptDbTable = class extends AtscriptDbReadable {
|
|
|
2460
2475
|
return require_nested_writer.enrichFkViolation(this._meta, () => this.adapter.withTransaction(async () => {
|
|
2461
2476
|
const items = payloads.map((p) => this._applyDefaults({ ...p }));
|
|
2462
2477
|
const originals = canNest ? payloads.map((p) => ({ ...p })) : [];
|
|
2463
|
-
|
|
2478
|
+
const validator = this.getValidator("bulkReplace");
|
|
2479
|
+
const ctx = {
|
|
2464
2480
|
mode: "replace",
|
|
2465
2481
|
navFields: this._meta.navFields
|
|
2466
|
-
}
|
|
2482
|
+
};
|
|
2483
|
+
this._applyDepthCtx(ctx, depth);
|
|
2484
|
+
require_nested_writer.validateBatch(validator, items, ctx);
|
|
2467
2485
|
const host = this;
|
|
2468
2486
|
if (canNest) await require_nested_writer.batchReplaceNestedTo(host, items, maxDepth, depth);
|
|
2469
2487
|
await this._integrity.validateForeignKeys(items, this._meta, this._fkLookupResolver, this._writeTableResolver);
|
|
@@ -2507,11 +2525,14 @@ var AtscriptDbTable = class extends AtscriptDbReadable {
|
|
|
2507
2525
|
const canNest = depth < maxDepth && this._writeTableResolver && this._meta.navFields.size > 0;
|
|
2508
2526
|
if (!canNest && this._meta.navFields.size > 0) require_nested_writer.checkDepthOverflow(payloads, maxDepth, this._meta);
|
|
2509
2527
|
return require_nested_writer.enrichFkViolation(this._meta, () => this.adapter.withTransaction(async () => {
|
|
2510
|
-
|
|
2528
|
+
const validator = this.getValidator("bulkUpdate");
|
|
2529
|
+
const ctx = {
|
|
2511
2530
|
mode: "patch",
|
|
2512
2531
|
flatMap: this.flatMap,
|
|
2513
2532
|
navFields: this._meta.navFields
|
|
2514
|
-
}
|
|
2533
|
+
};
|
|
2534
|
+
this._applyDepthCtx(ctx, depth);
|
|
2535
|
+
require_nested_writer.validateBatch(validator, payloads, ctx);
|
|
2515
2536
|
const originals = canNest ? payloads.map((p) => ({ ...p })) : [];
|
|
2516
2537
|
const host = this;
|
|
2517
2538
|
if (canNest) await require_nested_writer.batchPatchNestedTo(host, payloads, maxDepth, depth);
|
|
@@ -2673,11 +2694,11 @@ var AtscriptDbTable = class extends AtscriptDbReadable {
|
|
|
2673
2694
|
return filter;
|
|
2674
2695
|
}
|
|
2675
2696
|
}
|
|
2676
|
-
if (pkFields.length === 0) throw new
|
|
2697
|
+
if (pkFields.length === 0) throw new require_db_error.DbError("NOT_FOUND", [{
|
|
2677
2698
|
path: "",
|
|
2678
2699
|
message: "No primary key defined — cannot extract filter"
|
|
2679
2700
|
}]);
|
|
2680
|
-
throw new
|
|
2701
|
+
throw new require_db_error.DbError("NOT_FOUND", [{
|
|
2681
2702
|
path: pkFields[0],
|
|
2682
2703
|
message: `Missing primary key field "${pkFields[0]}" in payload`
|
|
2683
2704
|
}]);
|
|
@@ -2687,6 +2708,47 @@ var AtscriptDbTable = class extends AtscriptDbReadable {
|
|
|
2687
2708
|
return fieldType ? this.adapter.prepareId(value, fieldType) : value;
|
|
2688
2709
|
}
|
|
2689
2710
|
/**
|
|
2711
|
+
* Lazy — builds a `normalized-path → from-depth` map from `this._meta.flatMap`
|
|
2712
|
+
* on first use. Only paths reachable through an unbroken chain of `db.rel.from`
|
|
2713
|
+
* nav fields from the root are included (chains crossing `to`/`via` are excluded).
|
|
2714
|
+
*/
|
|
2715
|
+
_getFromDepthMap() {
|
|
2716
|
+
if (!this._fromDepthMap) {
|
|
2717
|
+
const out = /* @__PURE__ */ new Map();
|
|
2718
|
+
for (const [path, def] of this._meta.flatMap) {
|
|
2719
|
+
if (!def.metadata?.has("db.rel.from")) continue;
|
|
2720
|
+
const segments = path.split(".");
|
|
2721
|
+
let prefix = "";
|
|
2722
|
+
let depth = 0;
|
|
2723
|
+
let valid = true;
|
|
2724
|
+
for (let i = 0; i < segments.length; i++) {
|
|
2725
|
+
prefix = prefix ? `${prefix}.${segments[i]}` : segments[i];
|
|
2726
|
+
const pmd = this._meta.flatMap.get(prefix)?.metadata;
|
|
2727
|
+
if (pmd?.has("db.rel.to") || pmd?.has("db.rel.via")) {
|
|
2728
|
+
valid = false;
|
|
2729
|
+
break;
|
|
2730
|
+
}
|
|
2731
|
+
if (pmd?.has("db.rel.from")) depth++;
|
|
2732
|
+
}
|
|
2733
|
+
if (valid) out.set(path, depth);
|
|
2734
|
+
}
|
|
2735
|
+
this._fromDepthMap = out;
|
|
2736
|
+
}
|
|
2737
|
+
return this._fromDepthMap;
|
|
2738
|
+
}
|
|
2739
|
+
/**
|
|
2740
|
+
* Populate the depth-limit bundle on a `DbValidationContext`. Only the root
|
|
2741
|
+
* write call (`depth === 0`) enforces — nested re-entries leave `depthCheck`
|
|
2742
|
+
* unset so the full tree is validated once at the root.
|
|
2743
|
+
*/
|
|
2744
|
+
_applyDepthCtx(ctx, depth) {
|
|
2745
|
+
if (depth !== 0 || this._meta.navFields.size === 0) return;
|
|
2746
|
+
ctx.depthCheck = {
|
|
2747
|
+
limit: this.type.metadata.get("db.depth.limit") ?? 0,
|
|
2748
|
+
fromDepthMap: this._getFromDepthMap()
|
|
2749
|
+
};
|
|
2750
|
+
}
|
|
2751
|
+
/**
|
|
2690
2752
|
* Pre-validate items (type validation + FK constraints) without inserting them.
|
|
2691
2753
|
* Used by parent tables to validate FROM children before the main insert,
|
|
2692
2754
|
* ensuring errors are caught before the parent is committed.
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { t as DbError } from "./db-error-Cepx-RsQ.mjs";
|
|
2
2
|
import { resolveAlias } from "./agg.mjs";
|
|
3
3
|
import { n as findRemoteFK, t as findFKForRelation } from "./relation-helpers-CLasawQq.mjs";
|
|
4
4
|
import { separateFieldOps } from "./ops.mjs";
|
|
5
|
-
import { i as forceNavNonOptional, r as dbPlugin, s as getKeyProps, t as buildDbValidator } from "./validator-
|
|
5
|
+
import { i as forceNavNonOptional, r as dbPlugin, s as getKeyProps, t as buildDbValidator } from "./validator-BB5h1Le3.mjs";
|
|
6
|
+
import { a as batchPatchNestedTo, c as batchReplaceNestedTo, d as preValidateNestedFrom, f as validateBatch, i as batchPatchNestedFrom, l as batchReplaceNestedVia, m as remapDeleteFkViolation, n as batchInsertNestedTo, o as batchPatchNestedVia, p as enrichFkViolation, r as batchInsertNestedVia, s as batchReplaceNestedFrom, t as batchInsertNestedFrom, u as checkDepthOverflow } from "./nested-writer-CT2rLURx.mjs";
|
|
6
7
|
import { flattenAnnotatedType, isAnnotatedType } from "@atscript/typescript/utils";
|
|
7
8
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
8
9
|
//#region src/logger.ts
|
|
@@ -1096,6 +1097,15 @@ var AtscriptDbReadable = class {
|
|
|
1096
1097
|
_ensureBuilt() {
|
|
1097
1098
|
if (!this._meta.isBuilt) this._meta.build(this.type, this.adapter, this.logger);
|
|
1098
1099
|
}
|
|
1100
|
+
/**
|
|
1101
|
+
* Built table metadata. Triggers a lazy build on first access — safe to call
|
|
1102
|
+
* from peer tables that need this one's relations / nav fields before any
|
|
1103
|
+
* operation has run against it directly.
|
|
1104
|
+
*/
|
|
1105
|
+
getMetadata() {
|
|
1106
|
+
this._ensureBuilt();
|
|
1107
|
+
return this._meta;
|
|
1108
|
+
}
|
|
1099
1109
|
_ensureSearchable() {
|
|
1100
1110
|
if (!this.adapter.isSearchable()) throw new DbError("INVALID_QUERY", [{
|
|
1101
1111
|
path: "$search",
|
|
@@ -2358,6 +2368,7 @@ var AtscriptDbTable = class extends AtscriptDbReadable {
|
|
|
2358
2368
|
_fkLookupResolver;
|
|
2359
2369
|
_integrity;
|
|
2360
2370
|
validators = /* @__PURE__ */ new Map();
|
|
2371
|
+
_fromDepthMap;
|
|
2361
2372
|
constructor(_type, adapter, logger, _tableResolver, _writeTableResolver) {
|
|
2362
2373
|
super(_type, adapter, logger, _tableResolver);
|
|
2363
2374
|
if (_writeTableResolver) this._writeTableResolver = _writeTableResolver;
|
|
@@ -2411,16 +2422,20 @@ var AtscriptDbTable = class extends AtscriptDbReadable {
|
|
|
2411
2422
|
*/
|
|
2412
2423
|
async insertMany(payloads, opts) {
|
|
2413
2424
|
this._ensureBuilt();
|
|
2414
|
-
const maxDepth = opts
|
|
2415
|
-
const
|
|
2425
|
+
const { _depth, maxDepth: userMax } = opts ?? {};
|
|
2426
|
+
const maxDepth = userMax ?? 3;
|
|
2427
|
+
const depth = _depth ?? 0;
|
|
2416
2428
|
const canNest = depth < maxDepth && this._writeTableResolver && this._meta.navFields.size > 0;
|
|
2417
2429
|
if (!canNest && this._meta.navFields.size > 0) checkDepthOverflow(payloads, maxDepth, this._meta);
|
|
2418
2430
|
return enrichFkViolation(this._meta, () => this.adapter.withTransaction(async () => {
|
|
2419
2431
|
const items = payloads.map((p) => this._applyDefaults({ ...p }));
|
|
2420
|
-
|
|
2432
|
+
const validator = this.getValidator("insert");
|
|
2433
|
+
const ctx = {
|
|
2421
2434
|
mode: "insert",
|
|
2422
2435
|
navFields: this._meta.navFields
|
|
2423
|
-
}
|
|
2436
|
+
};
|
|
2437
|
+
this._applyDepthCtx(ctx, depth);
|
|
2438
|
+
validateBatch(validator, items, ctx);
|
|
2424
2439
|
const host = this;
|
|
2425
2440
|
if (canNest) await batchInsertNestedTo(host, items, maxDepth, depth);
|
|
2426
2441
|
const prepared = [];
|
|
@@ -2460,10 +2475,13 @@ var AtscriptDbTable = class extends AtscriptDbReadable {
|
|
|
2460
2475
|
return enrichFkViolation(this._meta, () => this.adapter.withTransaction(async () => {
|
|
2461
2476
|
const items = payloads.map((p) => this._applyDefaults({ ...p }));
|
|
2462
2477
|
const originals = canNest ? payloads.map((p) => ({ ...p })) : [];
|
|
2463
|
-
|
|
2478
|
+
const validator = this.getValidator("bulkReplace");
|
|
2479
|
+
const ctx = {
|
|
2464
2480
|
mode: "replace",
|
|
2465
2481
|
navFields: this._meta.navFields
|
|
2466
|
-
}
|
|
2482
|
+
};
|
|
2483
|
+
this._applyDepthCtx(ctx, depth);
|
|
2484
|
+
validateBatch(validator, items, ctx);
|
|
2467
2485
|
const host = this;
|
|
2468
2486
|
if (canNest) await batchReplaceNestedTo(host, items, maxDepth, depth);
|
|
2469
2487
|
await this._integrity.validateForeignKeys(items, this._meta, this._fkLookupResolver, this._writeTableResolver);
|
|
@@ -2507,11 +2525,14 @@ var AtscriptDbTable = class extends AtscriptDbReadable {
|
|
|
2507
2525
|
const canNest = depth < maxDepth && this._writeTableResolver && this._meta.navFields.size > 0;
|
|
2508
2526
|
if (!canNest && this._meta.navFields.size > 0) checkDepthOverflow(payloads, maxDepth, this._meta);
|
|
2509
2527
|
return enrichFkViolation(this._meta, () => this.adapter.withTransaction(async () => {
|
|
2510
|
-
|
|
2528
|
+
const validator = this.getValidator("bulkUpdate");
|
|
2529
|
+
const ctx = {
|
|
2511
2530
|
mode: "patch",
|
|
2512
2531
|
flatMap: this.flatMap,
|
|
2513
2532
|
navFields: this._meta.navFields
|
|
2514
|
-
}
|
|
2533
|
+
};
|
|
2534
|
+
this._applyDepthCtx(ctx, depth);
|
|
2535
|
+
validateBatch(validator, payloads, ctx);
|
|
2515
2536
|
const originals = canNest ? payloads.map((p) => ({ ...p })) : [];
|
|
2516
2537
|
const host = this;
|
|
2517
2538
|
if (canNest) await batchPatchNestedTo(host, payloads, maxDepth, depth);
|
|
@@ -2687,6 +2708,47 @@ var AtscriptDbTable = class extends AtscriptDbReadable {
|
|
|
2687
2708
|
return fieldType ? this.adapter.prepareId(value, fieldType) : value;
|
|
2688
2709
|
}
|
|
2689
2710
|
/**
|
|
2711
|
+
* Lazy — builds a `normalized-path → from-depth` map from `this._meta.flatMap`
|
|
2712
|
+
* on first use. Only paths reachable through an unbroken chain of `db.rel.from`
|
|
2713
|
+
* nav fields from the root are included (chains crossing `to`/`via` are excluded).
|
|
2714
|
+
*/
|
|
2715
|
+
_getFromDepthMap() {
|
|
2716
|
+
if (!this._fromDepthMap) {
|
|
2717
|
+
const out = /* @__PURE__ */ new Map();
|
|
2718
|
+
for (const [path, def] of this._meta.flatMap) {
|
|
2719
|
+
if (!def.metadata?.has("db.rel.from")) continue;
|
|
2720
|
+
const segments = path.split(".");
|
|
2721
|
+
let prefix = "";
|
|
2722
|
+
let depth = 0;
|
|
2723
|
+
let valid = true;
|
|
2724
|
+
for (let i = 0; i < segments.length; i++) {
|
|
2725
|
+
prefix = prefix ? `${prefix}.${segments[i]}` : segments[i];
|
|
2726
|
+
const pmd = this._meta.flatMap.get(prefix)?.metadata;
|
|
2727
|
+
if (pmd?.has("db.rel.to") || pmd?.has("db.rel.via")) {
|
|
2728
|
+
valid = false;
|
|
2729
|
+
break;
|
|
2730
|
+
}
|
|
2731
|
+
if (pmd?.has("db.rel.from")) depth++;
|
|
2732
|
+
}
|
|
2733
|
+
if (valid) out.set(path, depth);
|
|
2734
|
+
}
|
|
2735
|
+
this._fromDepthMap = out;
|
|
2736
|
+
}
|
|
2737
|
+
return this._fromDepthMap;
|
|
2738
|
+
}
|
|
2739
|
+
/**
|
|
2740
|
+
* Populate the depth-limit bundle on a `DbValidationContext`. Only the root
|
|
2741
|
+
* write call (`depth === 0`) enforces — nested re-entries leave `depthCheck`
|
|
2742
|
+
* unset so the full tree is validated once at the root.
|
|
2743
|
+
*/
|
|
2744
|
+
_applyDepthCtx(ctx, depth) {
|
|
2745
|
+
if (depth !== 0 || this._meta.navFields.size === 0) return;
|
|
2746
|
+
ctx.depthCheck = {
|
|
2747
|
+
limit: this.type.metadata.get("db.depth.limit") ?? 0,
|
|
2748
|
+
fromDepthMap: this._getFromDepthMap()
|
|
2749
|
+
};
|
|
2750
|
+
}
|
|
2751
|
+
/**
|
|
2690
2752
|
* Pre-validate items (type validation + FK constraints) without inserting them.
|
|
2691
2753
|
* Used by parent tables to validate FROM children before the main insert,
|
|
2692
2754
|
* ensuring errors are caught before the parent is committed.
|
package/dist/index.cjs
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const
|
|
3
|
-
const require_db_view = require("./db-view-
|
|
2
|
+
const require_db_error = require("./db-error-D8tQhNgM.cjs");
|
|
3
|
+
const require_db_view = require("./db-view-DIGN4079.cjs");
|
|
4
4
|
const require_ops = require("./ops.cjs");
|
|
5
|
-
const require_validator = require("./validator-
|
|
5
|
+
const require_validator = require("./validator-BIuw_T0k.cjs");
|
|
6
|
+
require("./nested-writer-v_LPR1yJ.cjs");
|
|
6
7
|
let _uniqu_core = require("@uniqu/core");
|
|
7
8
|
//#region src/table/db-space.ts
|
|
8
9
|
/**
|
|
@@ -152,7 +153,7 @@ exports.AtscriptDbReadable = require_db_view.AtscriptDbReadable;
|
|
|
152
153
|
exports.AtscriptDbTable = require_db_view.AtscriptDbTable;
|
|
153
154
|
exports.AtscriptDbView = require_db_view.AtscriptDbView;
|
|
154
155
|
exports.BaseDbAdapter = require_db_view.BaseDbAdapter;
|
|
155
|
-
exports.DbError =
|
|
156
|
+
exports.DbError = require_db_error.DbError;
|
|
156
157
|
exports.DbSpace = DbSpace;
|
|
157
158
|
exports.DocumentFieldMapper = require_db_view.DocumentFieldMapper;
|
|
158
159
|
exports.FieldMappingStrategy = require_db_view.FieldMappingStrategy;
|
package/dist/index.d.cts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { $ as
|
|
1
|
+
import { $ as Uniquery, A as TDbIndexType, B as TFkLookupResolver, C as TDbDefaultFn, D as TDbForeignKey, E as TDbFieldMeta, F as TDbStorageType, G as TRelationInfo, H as TIdDescriptor, I as TDbUpdateResult, J as TTableOptionDiff, K as TSearchIndexInfo, L as TExistingColumn, M as TDbInsertResult, N as TDbReferentialAction, O as TDbIndex, P as TDbRelation, Q as TypedWithRelation, R as TExistingTableOption, S as TDbCollation, T as TDbDeleteResult, U as TMetaResponse, V as TFkLookupTarget, W as TMetadataOverrides, X as TValueFormatterPair, Y as TTableResolver, Z as TWriteTableResolver, _ as NavPropsOf, a as FieldMappingStrategy, at as UniquSelect, b as TCascadeTarget, c as AggregateExpr, d as AggregateResult, et as UniqueryControls, f as AtscriptDbWritable, g as FilterExpr, h as FieldOpsFor, i as DocumentFieldMapper, it as TGenericLogger, j as TDbInsertManyResult, k as TDbIndexField, l as AggregateFn, m as DbQuery, n as DbResponse, nt as TableMetadata, o as BaseDbAdapter, p as DbControls, q as TSyncColumnResult, r as resolveDesignType, rt as NoopLogger, s as AggregateControls, t as AtscriptDbReadable, tt as WithRelation, u as AggregateQuery, v as OwnPropsOf, w as TDbDefaultValue, x as TColumnDiff, y as TCascadeResolver, z as TFieldMeta } from "./db-readable-DtrC0BGF.cjs";
|
|
2
2
|
import { a as $remove, c as $upsert, d as getDbFieldOp, f as isDbFieldOp, i as $mul, l as TDbFieldOp, n as $inc, o as $replace, p as separateFieldOps, r as $insert, s as $update, t as $dec, 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-
|
|
4
|
-
import { n as createDbValidatorPlugin, t as DbValidationContext } from "./db-validator-plugin-
|
|
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-BqVLHVq7.cjs";
|
|
4
|
+
import { n as createDbValidatorPlugin, t as DbValidationContext } from "./db-validator-plugin-DRGMCEn3.cjs";
|
|
5
5
|
import { c as TArrayPatch, i as buildValidationContext, l as TDbPatch, n as ValidatorMode, o as forceNavNonOptional, r as buildDbValidator, s as isNavRelation, t as ValidationContext, u as getKeyProps } from "./validator-_z_A3cKa.cjs";
|
|
6
6
|
import { AggregateQuery as AggregateQuery$1, FilterExpr as FilterExpr$1, FilterVisitor, Uniquery as Uniquery$1, computeInsights, isPrimitive, walkFilter } from "@uniqu/core";
|
|
7
7
|
|
|
@@ -81,7 +81,7 @@ declare class ApplicationIntegrity extends IntegrityStrategy {
|
|
|
81
81
|
}
|
|
82
82
|
//#endregion
|
|
83
83
|
//#region src/db-error.d.ts
|
|
84
|
-
type DbErrorCode = "CONFLICT" | "FK_VIOLATION" | "NOT_FOUND" | "CASCADE_CYCLE" | "INVALID_QUERY";
|
|
84
|
+
type DbErrorCode = "CONFLICT" | "FK_VIOLATION" | "NOT_FOUND" | "CASCADE_CYCLE" | "INVALID_QUERY" | "DEPTH_EXCEEDED";
|
|
85
85
|
declare class DbError extends Error {
|
|
86
86
|
readonly code: DbErrorCode;
|
|
87
87
|
readonly errors: Array<{
|
package/dist/index.d.mts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { $ as
|
|
2
|
-
import { a as $remove, c as $upsert, d as getDbFieldOp, f as isDbFieldOp, i as $mul, l as TDbFieldOp, n as $inc, o as $replace, p as separateFieldOps, r as $insert, s as $update, t as $dec, u as TFieldOps } from "./ops-
|
|
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-
|
|
4
|
-
import { n as createDbValidatorPlugin, t as DbValidationContext } from "./db-validator-plugin-
|
|
5
|
-
import { c as TArrayPatch, i as buildValidationContext, l as TDbPatch, n as ValidatorMode, o as forceNavNonOptional, r as buildDbValidator, s as isNavRelation, t as ValidationContext, u as getKeyProps } from "./validator-
|
|
1
|
+
import { $ as Uniquery, A as TDbIndexType, B as TFkLookupResolver, C as TDbDefaultFn, D as TDbForeignKey, E as TDbFieldMeta, F as TDbStorageType, G as TRelationInfo, H as TIdDescriptor, I as TDbUpdateResult, J as TTableOptionDiff, K as TSearchIndexInfo, L as TExistingColumn, M as TDbInsertResult, N as TDbReferentialAction, O as TDbIndex, P as TDbRelation, Q as TypedWithRelation, R as TExistingTableOption, S as TDbCollation, T as TDbDeleteResult, U as TMetaResponse, V as TFkLookupTarget, W as TMetadataOverrides, X as TValueFormatterPair, Y as TTableResolver, Z as TWriteTableResolver, _ as NavPropsOf, a as FieldMappingStrategy, at as UniquSelect, b as TCascadeTarget, c as AggregateExpr, d as AggregateResult, et as UniqueryControls, f as AtscriptDbWritable, g as FilterExpr, h as FieldOpsFor, i as DocumentFieldMapper, it as TGenericLogger, j as TDbInsertManyResult, k as TDbIndexField, l as AggregateFn, m as DbQuery, n as DbResponse, nt as TableMetadata, o as BaseDbAdapter, p as DbControls, q as TSyncColumnResult, r as resolveDesignType, rt as NoopLogger, s as AggregateControls, t as AtscriptDbReadable, tt as WithRelation, u as AggregateQuery, v as OwnPropsOf, w as TDbDefaultValue, x as TColumnDiff, y as TCascadeResolver, z as TFieldMeta } from "./db-readable-RTtqL7H4.mjs";
|
|
2
|
+
import { a as $remove, c as $upsert, d as getDbFieldOp, f as isDbFieldOp, i as $mul, l as TDbFieldOp, n as $inc, o as $replace, p as separateFieldOps, r as $insert, s as $update, t as $dec, u as TFieldOps } from "./ops-C61kelof.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-D3QSKx2B.mjs";
|
|
4
|
+
import { n as createDbValidatorPlugin, t as DbValidationContext } from "./db-validator-plugin-DDvYyv5t.mjs";
|
|
5
|
+
import { c as TArrayPatch, i as buildValidationContext, l as TDbPatch, n as ValidatorMode, o as forceNavNonOptional, r as buildDbValidator, s as isNavRelation, t as ValidationContext, u as getKeyProps } from "./validator-DttN2e5_.mjs";
|
|
6
6
|
import { AggregateQuery as AggregateQuery$1, FilterExpr as FilterExpr$1, FilterVisitor, Uniquery as Uniquery$1, computeInsights, isPrimitive, walkFilter } from "@uniqu/core";
|
|
7
7
|
|
|
8
8
|
//#region src/strategies/relational-field-mapper.d.ts
|
|
@@ -81,7 +81,7 @@ declare class ApplicationIntegrity extends IntegrityStrategy {
|
|
|
81
81
|
}
|
|
82
82
|
//#endregion
|
|
83
83
|
//#region src/db-error.d.ts
|
|
84
|
-
type DbErrorCode = "CONFLICT" | "FK_VIOLATION" | "NOT_FOUND" | "CASCADE_CYCLE" | "INVALID_QUERY";
|
|
84
|
+
type DbErrorCode = "CONFLICT" | "FK_VIOLATION" | "NOT_FOUND" | "CASCADE_CYCLE" | "INVALID_QUERY" | "DEPTH_EXCEEDED";
|
|
85
85
|
declare class DbError extends Error {
|
|
86
86
|
readonly code: DbErrorCode;
|
|
87
87
|
readonly errors: Array<{
|
package/dist/index.mjs
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { a as BaseDbAdapter, c as AtscriptDbReadable, d as DocumentFieldMapper, f as FieldMappingStrategy, h as NoopLogger, i as ApplicationIntegrity, l as resolveDesignType, m as TableMetadata, n as AtscriptDbTable, o as IntegrityStrategy, p as UniquSelect, r as decomposePatch, s as NativeIntegrity, t as AtscriptDbView, u as RelationalFieldMapper } from "./db-view-
|
|
1
|
+
import { t as DbError } from "./db-error-Cepx-RsQ.mjs";
|
|
2
|
+
import { a as BaseDbAdapter, c as AtscriptDbReadable, d as DocumentFieldMapper, f as FieldMappingStrategy, h as NoopLogger, i as ApplicationIntegrity, l as resolveDesignType, m as TableMetadata, n as AtscriptDbTable, o as IntegrityStrategy, p as UniquSelect, r as decomposePatch, s as NativeIntegrity, t as AtscriptDbView, u as RelationalFieldMapper } from "./db-view-DNwX6_4x.mjs";
|
|
3
3
|
import { $dec, $inc, $insert, $mul, $remove, $replace, $update, $upsert, getDbFieldOp, isDbFieldOp, separateFieldOps } from "./ops.mjs";
|
|
4
|
-
import { a as isNavRelation, i as forceNavNonOptional, n as buildValidationContext, o as createDbValidatorPlugin, s as getKeyProps, t as buildDbValidator } from "./validator-
|
|
4
|
+
import { a as isNavRelation, i as forceNavNonOptional, n as buildValidationContext, o as createDbValidatorPlugin, s as getKeyProps, t as buildDbValidator } from "./validator-BB5h1Le3.mjs";
|
|
5
|
+
import "./nested-writer-CT2rLURx.mjs";
|
|
5
6
|
import { computeInsights, isPrimitive, walkFilter } from "@uniqu/core";
|
|
6
7
|
//#region src/table/db-space.ts
|
|
7
8
|
/**
|
|
@@ -1,16 +1,6 @@
|
|
|
1
|
+
import { n as DepthLimitExceededError, t as DbError } from "./db-error-Cepx-RsQ.mjs";
|
|
1
2
|
import { r as resolveRelationTargetTable } from "./relation-helpers-CLasawQq.mjs";
|
|
2
3
|
import { ValidatorError } from "@atscript/typescript/utils";
|
|
3
|
-
//#region src/db-error.ts
|
|
4
|
-
var DbError = class extends Error {
|
|
5
|
-
name = "DbError";
|
|
6
|
-
constructor(code, errors, message) {
|
|
7
|
-
super(message ?? errors[0]?.message ?? "Database error");
|
|
8
|
-
this.code = code;
|
|
9
|
-
this.errors = errors;
|
|
10
|
-
this.stack = void 0;
|
|
11
|
-
}
|
|
12
|
-
};
|
|
13
|
-
//#endregion
|
|
14
4
|
//#region src/table/error-utils.ts
|
|
15
5
|
/**
|
|
16
6
|
* Prefixes error paths with a nav field context.
|
|
@@ -89,10 +79,13 @@ function validateBatch(validator, items, ctx) {
|
|
|
89
79
|
for (let i = 0; i < items.length; i++) try {
|
|
90
80
|
validator.validate(items[i], false, ctx);
|
|
91
81
|
} catch (error) {
|
|
92
|
-
if (
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
82
|
+
if (items.length > 1) {
|
|
83
|
+
if (error instanceof ValidatorError) throw new ValidatorError(error.errors.map((err) => ({
|
|
84
|
+
...err,
|
|
85
|
+
path: `[${i}].${err.path}`
|
|
86
|
+
})));
|
|
87
|
+
if (error instanceof DepthLimitExceededError) throw new DepthLimitExceededError(`[${i}].${error.field}`, error.declared, error.actual);
|
|
88
|
+
}
|
|
96
89
|
throw error;
|
|
97
90
|
}
|
|
98
91
|
}
|
|
@@ -621,4 +614,4 @@ async function viaReplace(targetTable, junctionTable, targets, parentPK, targetP
|
|
|
621
614
|
}
|
|
622
615
|
}
|
|
623
616
|
//#endregion
|
|
624
|
-
export { batchPatchNestedTo as a, batchReplaceNestedTo as c, preValidateNestedFrom as d, validateBatch as f,
|
|
617
|
+
export { batchPatchNestedTo as a, batchReplaceNestedTo as c, preValidateNestedFrom as d, validateBatch as f, batchPatchNestedFrom as i, batchReplaceNestedVia as l, remapDeleteFkViolation as m, batchInsertNestedTo as n, batchPatchNestedVia as o, enrichFkViolation as p, batchInsertNestedVia as r, batchReplaceNestedFrom as s, batchInsertNestedFrom as t, checkDepthOverflow as u };
|