@atscript/db 0.1.155 → 0.1.157
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/agg.d.cts +1 -1
- package/dist/agg.d.mts +1 -1
- package/dist/{buckets-goCoky8v.d.mts → buckets-8mG67Mtw.d.mts} +49 -7
- package/dist/{buckets-DcWm3SLt.d.cts → buckets-B4T_alUe.d.cts} +49 -7
- package/dist/{column-diff-C68V_eYM.mjs → column-diff-DR1glykD.mjs} +74 -11
- package/dist/{column-diff-DMkGYAGM.cjs → column-diff-DpeUbhEI.cjs} +74 -11
- package/dist/{fk-diff-BYLNWoF9.d.mts → fk-diff-5gX42hBt.d.mts} +1 -1
- package/dist/{fk-diff-DblOPBLS.d.cts → fk-diff-BWdQ7kRZ.d.cts} +1 -1
- package/dist/index.cjs +3 -3
- package/dist/index.d.cts +9 -8
- package/dist/index.d.mts +9 -8
- package/dist/index.mjs +3 -3
- package/dist/plugin.cjs +19 -2
- package/dist/plugin.mjs +19 -2
- package/dist/rel.d.cts +2 -2
- package/dist/rel.d.mts +2 -2
- package/dist/{relation-helpers-B9MVBrtx.d.mts → relation-helpers-17_2f5hX.d.mts} +1 -1
- package/dist/{relation-helpers-D9kMFfum.d.cts → relation-helpers-BLBrLQYi.d.cts} +1 -1
- package/dist/{search-fields-DBIZKwyb.mjs → search-fields-CE8cmj9X.mjs} +1 -0
- package/dist/{search-fields-DwrsJUC1.cjs → search-fields-CT_UZ9fg.cjs} +1 -0
- package/dist/shared.cjs +1 -1
- package/dist/shared.mjs +1 -1
- package/dist/sync.cjs +35 -9
- package/dist/sync.d.cts +2 -2
- package/dist/sync.d.mts +2 -2
- package/dist/sync.mjs +35 -9
- package/dist/{validation-utils-DxHIqa36.mjs → validation-utils-BGjqc2jU.mjs} +1 -1
- package/dist/{validation-utils-_PA7iSLm.cjs → validation-utils-CtLNlBtB.cjs} +1 -1
- package/dist/{validator-BC3nwFi4.mjs → validator-B3fPJjS1.mjs} +2 -2
- package/dist/{validator-DHwSyBej.cjs → validator-B4YDLUkj.cjs} +2 -2
- package/dist/validator.cjs +1 -1
- package/dist/validator.mjs +1 -1
- package/package.json +6 -6
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
const require_db_error = require("./db-error-JcfJqqpk.cjs");
|
|
2
2
|
const require_aggregate_fns = require("./aggregate-fns-DFtKAv7Q.cjs");
|
|
3
3
|
const require_nested_writer = require("./nested-writer-Bl1SZS7x.cjs");
|
|
4
|
-
const require_validator = require("./validator-
|
|
5
|
-
const require_search_fields = require("./search-fields-
|
|
4
|
+
const require_validator = require("./validator-B4YDLUkj.cjs");
|
|
5
|
+
const require_search_fields = require("./search-fields-CT_UZ9fg.cjs");
|
|
6
6
|
const require_object = require("./object-Djg28csK.cjs");
|
|
7
7
|
require("./agg.cjs");
|
|
8
8
|
const require_aggregate_rules = require("./aggregate-rules-D_bsCpUI.cjs");
|
|
@@ -503,6 +503,12 @@ var TableMetadata = class {
|
|
|
503
503
|
/** Adapter-contributed multi-field unique keys (logical paths) — see `TMetadataOverrides.addUniqueKeys`. */
|
|
504
504
|
uniqueKeys = [];
|
|
505
505
|
defaults = /* @__PURE__ */ new Map();
|
|
506
|
+
/**
|
|
507
|
+
* Logical paths annotated with `@db.onUpdate.now` (`number.timestamp.updated`
|
|
508
|
+
* applies it): set to the current time by every update and replace.
|
|
509
|
+
* @since 0.1.156
|
|
510
|
+
*/
|
|
511
|
+
onUpdateNow = /* @__PURE__ */ new Set();
|
|
506
512
|
/** Logical path → `@db.column` override (top-level keys only on document storage). */
|
|
507
513
|
columnMap = /* @__PURE__ */ new Map();
|
|
508
514
|
dimensions = [];
|
|
@@ -827,6 +833,7 @@ var TableMetadata = class {
|
|
|
827
833
|
if (columnFrom && renamable) this._columnFromMap.set(fieldName, columnFrom);
|
|
828
834
|
const resolvedDefault = resolveDefaultFromMetadata(metadata);
|
|
829
835
|
if (resolvedDefault) this.defaults.set(fieldName, resolvedDefault);
|
|
836
|
+
if (metadata.has("db.onUpdate.now")) this.onUpdateNow.add(fieldName);
|
|
830
837
|
if (metadata.has("db.ignore")) this.ignoredFields.add(fieldName);
|
|
831
838
|
if (isNavRelation(metadata)) {
|
|
832
839
|
this.navFields.add(fieldName);
|
|
@@ -996,6 +1003,7 @@ var TableMetadata = class {
|
|
|
996
1003
|
if (metadata.has("db.search.vector") || metadata.has("db.search.filter")) reject("@db.search.*", "search over ciphertext is impossible");
|
|
997
1004
|
if (metadata.has("db.mongo.search.text") || metadata.has("db.mongo.search.autocomplete")) reject("@db.mongo.search.*", "Atlas Search over ciphertext is impossible");
|
|
998
1005
|
if (metadata.has("db.column.version")) reject("@db.column.version", "the OCC filter needs cleartext equality");
|
|
1006
|
+
if (metadata.has("db.onUpdate.now")) reject("@db.onUpdate.now", "the update time is set after the encryption transform");
|
|
999
1007
|
if (metadata.has("db.default.increment") || metadata.has("db.default.now")) reject("@db.default.increment / @db.default.now", "engine-side defaults bypass the encryption transform");
|
|
1000
1008
|
if (metadata.get("db.patch.strategy") === "merge") reject("@db.patch.strategy \"merge\"", "ciphertext is opaque — partial merges would silently drop omitted keys");
|
|
1001
1009
|
}
|
|
@@ -6809,10 +6817,11 @@ function assertNoVersionWrites(data, versionColumn) {
|
|
|
6809
6817
|
* Whether a logical (pre-decomposition) patch writes ONLY version-exempt
|
|
6810
6818
|
* fields (`@db.column.version.exempt`). `data` has nav fields, filter keys and
|
|
6811
6819
|
* derived fields removed and `$cas` separated. Mirrors `flattenPatchPayload`
|
|
6812
|
-
* (keep the two side by side): PK keys
|
|
6813
|
-
*
|
|
6814
|
-
* array ops, object); a non-exempt
|
|
6815
|
-
* supplied children are written);
|
|
6820
|
+
* (keep the two side by side): PK keys and `@db.onUpdate.now` fields are
|
|
6821
|
+
* skipped; an exempt path (or one under an exempt ancestor) is covered
|
|
6822
|
+
* whatever its value (scalar, field op, array ops, object); a non-exempt
|
|
6823
|
+
* merge-strategy object recurses (only the supplied children are written);
|
|
6824
|
+
* anything else is a non-exempt write.
|
|
6816
6825
|
* True iff at least one key is covered and none is not.
|
|
6817
6826
|
* @since 0.1.150
|
|
6818
6827
|
*/
|
|
@@ -6821,11 +6830,12 @@ function isVersionExemptPatch(data, table) {
|
|
|
6821
6830
|
if (meta.versionExemptPaths.size === 0) return false;
|
|
6822
6831
|
const primaryKeys = meta.primaryKeys;
|
|
6823
6832
|
const flatMap = meta.flatMap;
|
|
6833
|
+
const stamps = meta.onUpdateNow;
|
|
6824
6834
|
const walk = (obj, prefix) => {
|
|
6825
6835
|
let result = "none";
|
|
6826
6836
|
for (const [k, value] of Object.entries(obj)) {
|
|
6827
6837
|
const key = prefix ? `${prefix}.${k}` : k;
|
|
6828
|
-
if (primaryKeys.includes(key)) continue;
|
|
6838
|
+
if (primaryKeys.includes(key) || stamps.has(key)) continue;
|
|
6829
6839
|
if (meta.isVersionExemptPath(key)) {
|
|
6830
6840
|
result = "exempt";
|
|
6831
6841
|
continue;
|
|
@@ -7138,7 +7148,8 @@ var AtscriptDbTable = class extends AtscriptDbReadable {
|
|
|
7138
7148
|
const singleStatement = !ignore && this._isSingleStatementWrite(payloads, depth, guard, check);
|
|
7139
7149
|
return require_nested_writer.enrichFkViolation(this._meta, () => this._inWriteTransaction(singleStatement, async () => {
|
|
7140
7150
|
const clone = depth === 0 ? _cloneWritePayload : _shallowPrunedClone;
|
|
7141
|
-
|
|
7151
|
+
const now = Date.now();
|
|
7152
|
+
let items = payloads.map((p) => this._applyDefaults(clone(p), now));
|
|
7142
7153
|
if (ignore) this._linkToByKeyInIgnoreMode(items);
|
|
7143
7154
|
let originals = canNest ? items.map((item) => ({ ...item })) : [];
|
|
7144
7155
|
const validator = this.getValidator("insert");
|
|
@@ -7214,10 +7225,12 @@ var AtscriptDbTable = class extends AtscriptDbReadable {
|
|
|
7214
7225
|
const versionColumn = this.versionColumn;
|
|
7215
7226
|
const expectedVersions = Array.from({ length: payloads.length });
|
|
7216
7227
|
const clone = depth === 0 ? _cloneWritePayload : _shallowPrunedClone;
|
|
7228
|
+
const now = Date.now();
|
|
7217
7229
|
const items = payloads.map((p, i) => {
|
|
7218
7230
|
const c = clone(p);
|
|
7219
7231
|
expectedVersions[i] = require_ops.separateCas(c, versionColumn);
|
|
7220
|
-
|
|
7232
|
+
this._stampOnUpdate(c, now, true);
|
|
7233
|
+
return this._applyDefaults(c, now);
|
|
7221
7234
|
});
|
|
7222
7235
|
const originals = canNest ? items.map((item) => ({ ...item })) : [];
|
|
7223
7236
|
const validator = this.getValidator("bulkReplace");
|
|
@@ -7301,9 +7314,11 @@ var AtscriptDbTable = class extends AtscriptDbReadable {
|
|
|
7301
7314
|
const versionColumn = this.versionColumn;
|
|
7302
7315
|
const expectedVersions = Array.from({ length: payloads.length });
|
|
7303
7316
|
const clone = depth === 0 ? _cloneWritePayload : _shallowPrunedClone;
|
|
7317
|
+
const now = Date.now();
|
|
7304
7318
|
const cloned = payloads.map((p, i) => {
|
|
7305
7319
|
const c = clone(p);
|
|
7306
7320
|
expectedVersions[i] = require_ops.separateCas(c, versionColumn);
|
|
7321
|
+
this._stampOnUpdate(c, now, false);
|
|
7307
7322
|
return c;
|
|
7308
7323
|
});
|
|
7309
7324
|
const validator = this.getValidator("bulkUpdate");
|
|
@@ -7350,6 +7365,7 @@ var AtscriptDbTable = class extends AtscriptDbReadable {
|
|
|
7350
7365
|
continue;
|
|
7351
7366
|
}
|
|
7352
7367
|
const updateOpts = expectedVersion === void 0 && versionColumn !== void 0 && isVersionExemptPatch(data, this) ? [KEEP_VERSION] : [];
|
|
7368
|
+
this._stampTopLevel(data, now);
|
|
7353
7369
|
let result;
|
|
7354
7370
|
if (this.adapter.supportsNativePatch()) {
|
|
7355
7371
|
const ops = require_ops.separateFieldOps(data);
|
|
@@ -7509,6 +7525,8 @@ var AtscriptDbTable = class extends AtscriptDbReadable {
|
|
|
7509
7525
|
await this._integrity.validateForeignKeys([data], this._meta, this._fkLookupResolver, this._writeTableResolver, true);
|
|
7510
7526
|
const dataCopy = _cloneWritePayload(data);
|
|
7511
7527
|
this._meta.stripDerived(dataCopy);
|
|
7528
|
+
const now = Date.now();
|
|
7529
|
+
this._stampOnUpdate(dataCopy, now, false);
|
|
7512
7530
|
const versionColumn = this.versionColumn;
|
|
7513
7531
|
if ("$cas" in dataCopy) throw new require_db_error.DbError("INVALID_QUERY", [{
|
|
7514
7532
|
path: "$cas",
|
|
@@ -7516,6 +7534,7 @@ var AtscriptDbTable = class extends AtscriptDbReadable {
|
|
|
7516
7534
|
}]);
|
|
7517
7535
|
if (versionColumn !== void 0) assertNoVersionWrites(dataCopy, versionColumn);
|
|
7518
7536
|
const updateOpts = versionColumn !== void 0 && isVersionExemptPatch(dataCopy, this) ? [KEEP_VERSION] : [];
|
|
7537
|
+
this._stampTopLevel(dataCopy, now);
|
|
7519
7538
|
await this._encryptItems([dataCopy], "patch");
|
|
7520
7539
|
const update = decomposePatch(dataCopy, this);
|
|
7521
7540
|
const ops = require_ops.separateFieldOps(update);
|
|
@@ -7536,6 +7555,7 @@ var AtscriptDbTable = class extends AtscriptDbReadable {
|
|
|
7536
7555
|
this._guardMutationFilter(filter);
|
|
7537
7556
|
await this._integrity.validateForeignKeys([data], this._meta, this._fkLookupResolver, this._writeTableResolver);
|
|
7538
7557
|
const dataCopy = _cloneWritePayload(data);
|
|
7558
|
+
this._stampOnUpdate(dataCopy, Date.now(), true);
|
|
7539
7559
|
await this._encryptItems([dataCopy], "write");
|
|
7540
7560
|
return require_nested_writer.enrichFkViolation(this._meta, () => this.adapter.replaceMany(this._fieldMapper.translateFilter(filter, this._meta), this._fieldMapper.prepareForWrite(dataCopy, this._meta, this.adapter)));
|
|
7541
7561
|
}
|
|
@@ -7910,8 +7930,10 @@ var AtscriptDbTable = class extends AtscriptDbReadable {
|
|
|
7910
7930
|
* that object is present (an absent or `null` embedded object stays so), and
|
|
7911
7931
|
* in every object of an array on the way; a field inside a JSON value or an
|
|
7912
7932
|
* array has no column default, so the SDK fills its function default too.
|
|
7933
|
+
* Every `now` default the SDK fills gets the one time `now` (one per write
|
|
7934
|
+
* call, so `createdAt` / `updatedAt` of a new row are equal).
|
|
7913
7935
|
*/
|
|
7914
|
-
_applyDefaults(data) {
|
|
7936
|
+
_applyDefaults(data, now = Date.now()) {
|
|
7915
7937
|
const nativeFns = this.adapter.nativeDefaultFns();
|
|
7916
7938
|
const versionField = this._meta.versionField;
|
|
7917
7939
|
for (const [field, def] of this._meta.defaults.entries()) {
|
|
@@ -7919,7 +7941,7 @@ var AtscriptDbTable = class extends AtscriptDbReadable {
|
|
|
7919
7941
|
let make;
|
|
7920
7942
|
if (def.kind === "value") make = () => this._valueDefault(field, def.value);
|
|
7921
7943
|
else if (def.kind === "fn" && (!nativeFns.has(def.fn) || require_object.findAncestorInSet(field, this._meta.jsonParents) !== void 0)) {
|
|
7922
|
-
if (def.fn === "now") make =
|
|
7944
|
+
if (def.fn === "now") make = () => now;
|
|
7923
7945
|
else if (def.fn === "uuid") make = () => crypto.randomUUID();
|
|
7924
7946
|
}
|
|
7925
7947
|
if (!make) continue;
|
|
@@ -7929,6 +7951,26 @@ var AtscriptDbTable = class extends AtscriptDbReadable {
|
|
|
7929
7951
|
}
|
|
7930
7952
|
return data;
|
|
7931
7953
|
}
|
|
7954
|
+
/**
|
|
7955
|
+
* `@db.onUpdate.now` (since 0.1.156): sets each such field of a replace /
|
|
7956
|
+
* patch payload to `now`, overriding the caller's value. A nested field
|
|
7957
|
+
* (`audit.updatedAt`) is set inside its object only when the payload
|
|
7958
|
+
* carries that object — in every item of an array on the way and of the
|
|
7959
|
+
* items an array patch operator adds or updates — like
|
|
7960
|
+
* {@link _applyDefaults}. `topLevel: false` (a patch) instead drops the
|
|
7961
|
+
* caller's values of the table's own columns: {@link _stampTopLevel} sets
|
|
7962
|
+
* them once the patch is known to write something.
|
|
7963
|
+
*/
|
|
7964
|
+
_stampOnUpdate(data, now, topLevel) {
|
|
7965
|
+
for (const field of this._meta.onUpdateNow) if (!field.includes(".")) if (topLevel) data[field] = now;
|
|
7966
|
+
else delete data[field];
|
|
7967
|
+
else if (this._nestedDefaultFillable(field)) stampNested(data, field.split("."), 0, now);
|
|
7968
|
+
}
|
|
7969
|
+
/** Sets the top-level `@db.onUpdate.now` columns of a non-empty patch to `now`. */
|
|
7970
|
+
_stampTopLevel(data, now) {
|
|
7971
|
+
if (require_object.isEmptyObject(data)) return;
|
|
7972
|
+
for (const field of this._meta.onUpdateNow) if (!field.includes(".")) data[field] = now;
|
|
7973
|
+
}
|
|
7932
7974
|
/** {@link _nestedDefaultFillable} per nested default path. */
|
|
7933
7975
|
_fillableDefaults;
|
|
7934
7976
|
/**
|
|
@@ -8122,6 +8164,27 @@ var AtscriptDbTable = class extends AtscriptDbReadable {
|
|
|
8122
8164
|
}
|
|
8123
8165
|
};
|
|
8124
8166
|
/**
|
|
8167
|
+
* Sets `segs` below `value` to `now` (see `_stampOnUpdate`), through
|
|
8168
|
+
* arrays and the item lists of array patch operators (`$insert`, `$upsert`,
|
|
8169
|
+
* `$replace`, `$update` — not `$remove`).
|
|
8170
|
+
*/
|
|
8171
|
+
function stampNested(value, segs, i, now) {
|
|
8172
|
+
if (Array.isArray(value)) {
|
|
8173
|
+
for (const item of value) stampNested(item, segs, i, now);
|
|
8174
|
+
return;
|
|
8175
|
+
}
|
|
8176
|
+
if (!require_object.isPlainObject(value)) return;
|
|
8177
|
+
const key = segs[i];
|
|
8178
|
+
if (i === segs.length - 1) {
|
|
8179
|
+
value[key] = now;
|
|
8180
|
+
return;
|
|
8181
|
+
}
|
|
8182
|
+
const next = value[key];
|
|
8183
|
+
if (require_object.isPlainObject(next) && Object.keys(next).some((k) => k.startsWith("$"))) {
|
|
8184
|
+
for (const [op, items] of Object.entries(next)) if (op !== "$remove") stampNested(items, segs, i + 1, now);
|
|
8185
|
+
} else stampNested(next, segs, i + 1, now);
|
|
8186
|
+
}
|
|
8187
|
+
/**
|
|
8125
8188
|
* Sets `segs[i..]` to `make()` where it is `undefined`, inside present plain
|
|
8126
8189
|
* objects only — fanned out over the objects of every array on the way.
|
|
8127
8190
|
*/
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { A as TColumnDiff, B as TDbDefaultFn,
|
|
1
|
+
import { A as TColumnDiff, B as TDbDefaultFn, En as AtscriptDbReadable, U as TDbFieldMeta, V as TDbDefaultValue, W as TDbForeignKey, _t as TExistingColumn, an as AtscriptDbView, at as TDbStorageType, hn as AtscriptQueryNode, ht as TDerivedColumn, mn as AtscriptQueryFieldRef, yt as TExistingTableOption, z as TDbCollation } from "./buckets-8mG67Mtw.mjs";
|
|
2
2
|
|
|
3
3
|
//#region src/schema/schema-hash.d.ts
|
|
4
4
|
interface TFieldSnapshot {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { A as TColumnDiff, B as TDbDefaultFn,
|
|
1
|
+
import { A as TColumnDiff, B as TDbDefaultFn, En as AtscriptDbReadable, U as TDbFieldMeta, V as TDbDefaultValue, W as TDbForeignKey, _t as TExistingColumn, an as AtscriptDbView, at as TDbStorageType, hn as AtscriptQueryNode, ht as TDerivedColumn, mn as AtscriptQueryFieldRef, yt as TExistingTableOption, z as TDbCollation } from "./buckets-B4T_alUe.cjs";
|
|
2
2
|
|
|
3
3
|
//#region src/schema/schema-hash.d.ts
|
|
4
4
|
interface TFieldSnapshot {
|
package/dist/index.cjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
const require_db_error = require("./db-error-JcfJqqpk.cjs");
|
|
3
|
-
const require_column_diff = require("./column-diff-
|
|
3
|
+
const require_column_diff = require("./column-diff-DpeUbhEI.cjs");
|
|
4
4
|
const require_aggregate_fns = require("./aggregate-fns-DFtKAv7Q.cjs");
|
|
5
5
|
const require_nested_writer = require("./nested-writer-Bl1SZS7x.cjs");
|
|
6
|
-
const require_validator = require("./validator-
|
|
7
|
-
const require_search_fields = require("./search-fields-
|
|
6
|
+
const require_validator = require("./validator-B4YDLUkj.cjs");
|
|
7
|
+
const require_search_fields = require("./search-fields-CT_UZ9fg.cjs");
|
|
8
8
|
const require_object = require("./object-Djg28csK.cjs");
|
|
9
9
|
const require_consts = require("./consts-BzRfCcH2.cjs");
|
|
10
10
|
const require_ops = require("./ops.cjs");
|
package/dist/index.d.cts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { $ as TDbInsertResult, $t as
|
|
1
|
+
import { $ as TDbInsertResult, $t as ALL_VIEW_CAPABILITIES, A as TColumnDiff, An as REL_FILTER_MAX_NODES, At as TPrimaryKeyChange, B as TDbDefaultFn, Bn as isResolvedRelationFilter, Bt as TValueFormatterPair, C as NavPropsOf, Cn as IntegrityStrategy, Ct as TIdDescriptor, D as PrimaryKeyOf, Dn as DbResponse, Dt as TJsonCopyTarget, E as OwnPropsOf, En as AtscriptDbReadable, Et as TInsertOptions, F as TDbActionLevel, Fn as TRelationStaticFilter, Ft as TSyncColumnResult, G as TDbIndex, Gn as FieldMappingStrategy, Gt as Uniquery, H as TDbDeleteResult, Hn as DbEncryption, Ht as TWriteOptions, I as TDbActionProcessor, In as andFilters, It as TSyncIndexesOptions, J as TDbInsertIgnoreOptions, Jn as TGenericLogger, Jt as TableMetadata, K as TDbIndexField, Kn as TReadControls, Kt as UniqueryControls, L as TDbActionTargetSummary, Ln as containsRelationFilter, Lt as TTableOptionDiff, M as TCrudPermissions, Mn as TRelGuardState, Mt as TRelationInfo, N as TDbActionInfo, Nn as TRelationFilterJunction, Nt as TRowResolveOptions, O as TCascadeResolver, On as resolveDesignType, Ot as TMetaResponse, P as TDbActionIntent, Pn as TRelationFilterTable, Pt as TSearchIndexInfo, Q as TDbInsertManyResult, Qn as UniquSelect, Qt as ALL_BUCKET_UNITS, R as TDbAvailableActions, Rn as forEachResolvedRelation, Rt as TTableResolver, S as FlatOf, Sn as AtscriptDbTable, St as TFkLookupTarget, T as NullsPlacement, Tn as TCascadePin, Tt as TIdentification, U as TDbFieldMeta, Un as TDbEncryptionOptions, Ut as TWriteTableResolver, V as TDbDefaultValue, Vn as relationStaticFilter, Vt as TViewJsonType, W as TDbForeignKey, Wn as DocumentFieldMapper, Wt as TypedWithRelation, X as TDbInsertIgnoreSlot, Xn as TFirstLast, Xt as isGeoPointType, Y as TDbInsertIgnoreResult, Yn as TExprAggregate, Yt as isGeoIndexableType, Z as TDbInsertManyIgnoreResult, Zn as TRowOrderKey, Zt as TPathPresence, _ as DbPatch, _n as TViewJoin, _t as TExistingColumn, a as isJsonValueField, an as AtscriptDbView, at as TDbStorageType, b as FieldOpsFor, bn as isFieldRef, bt as TFieldMeta, c as resolveCalendarBuckets, cn as isViewType, ct as TDbWriteAction, d as AggregateFn, dn as AtscriptExprNode, dt as TDbWriteGuard, en as BaseDbAdapter, et as TDbObjectKind, f as AggregateQuery, fn as AtscriptOrderItem, ft as TDbWriteGuardContext, g as DbControls, gn as AtscriptRef, gt as TEnsureTableOptions, h as AtscriptDbWritable, hn as AtscriptQueryNode, ht as TDerivedColumn, i as isBucketableField, in as TDbSpaceOptions, it as TDbRemoveGuardContext, j as TCrudOp, jn as ResolvedRelationFilter, jt as TReferencingForeignKey, k as TCascadeTarget, kn as REL_FILTER_MAX_DEPTH, kt as TMetadataOverrides, l as AggregateControls, ln as TViewReadPlan, lt as TDbWriteCheck, mn as AtscriptQueryFieldRef, mt as TDerivedChangeReason, n as TComputedSelect, nn as DbSpace, nt as TDbRelation, o as jsonValueAncestor, on as TViewColumnMapping, ot as TDbUpdateOptions, p as AggregateResult, pn as AtscriptQueryComparison, pt as TDeleteOptions, q as TDbIndexType, qn as NoopLogger, qt as WithRelation, r as TResolvedBucket, rn as TAdapterFactory, rt as TDbRemoveGuard, s as normalizeComputedSelect, sn as isAtscriptDbView, st as TDbUpdateResult, t as TBucketFieldSource, tn as TViewCapability, tt as TDbReferentialAction, u as AggregateExpr, un as aliasTargetOf, ut as TDbWriteCheckContext, v as DbQuery, vn as TViewPlan, vt as TExistingForeignKey, w as NullableOptional, wn as NativeIntegrity, wt as TIdResolveOptions, x as FilterExpr, xn as translateQueryTree, xt as TFkLookupResolver, y as DbRow, yn as evaluateExpr, yt as TExistingTableOption, z as TDbCollation, zn as hasRelationOp, zt as TTouchManyOptions } from "./buckets-B4T_alUe.cjs";
|
|
2
2
|
import { _ as separateFieldOps, a as $mul, c as $update, d as TDbFieldOp, f as TFieldOps, g as separateCas, h as reconcileCas, i as $insert, l as $upsert, m as isDbFieldOp, n as $dec, o as $remove, p as getDbFieldOp, r as $inc, s as $replace, t as $cas, u as TDbCas } from "./ops-AqhV7s9o.cjs";
|
|
3
3
|
import { a as isPlainObject, i as isEmptyObject, n as findAncestorInSet, o as selfOrAncestor, r as getPath, t as deletePath } from "./object-CtPYTIvy.cjs";
|
|
4
4
|
import { c as CalendarBucketLabel, d as WeekStart, g as ALL_AGGREGATE_FNS, l as ComputedExpr, o as BucketExpr, s as BucketUnit, u as ResolvedBucket } from "./agg-42CSpGDR.cjs";
|
|
5
5
|
import { _ as aggregateFailure, a as buildValidationContext, b as isRetryableDbError, c as isNavRelation, d as getKeyProps, f as CasExhaustedError, g as aggregateExpressionsNotSupported, h as DbErrorCode, l as TArrayPatch, m as DbError, n as ValidatorMode, p as CasMismatchError, r as buildDbValidator, s as forceNavNonOptional, t as ValidationContext, u as TDbPatch, v as bucketTimeZoneUnavailable, y as isConflict } from "./validator-B3xlbrWf.cjs";
|
|
6
6
|
import { n as createDbValidatorPlugin, t as DbValidationContext } from "./db-validator-plugin-BWy60OvG.cjs";
|
|
7
|
-
import { r as fkColumns, s as isColumnTypeChanged } from "./fk-diff-
|
|
8
|
-
import { i as tableNameOf } from "./relation-helpers-
|
|
7
|
+
import { r as fkColumns, s as isColumnTypeChanged } from "./fk-diff-BWdQ7kRZ.cjs";
|
|
8
|
+
import { i as tableNameOf } from "./relation-helpers-BLBrLQYi.cjs";
|
|
9
9
|
import { AggregateQuery as AggregateQuery$1, FilterExpr as FilterExpr$1, FilterVisitor, RELATION_OPS, RelationOp, RelationOp as RelationOp$1, ResolvedRowOrderKey, ResolvedSelectExpr, Uniquery as Uniquery$1, computeInsights, isPrimitive, isRelationOp, walkFilter } from "@uniqu/core";
|
|
10
10
|
import { AtscriptExprNode as AtscriptExprNode$1, TAtscriptAnnotatedType } from "@atscript/typescript/utils";
|
|
11
11
|
|
|
@@ -641,10 +641,11 @@ declare function assertNoVersionWrites(data: Record<string, unknown>, versionCol
|
|
|
641
641
|
* Whether a logical (pre-decomposition) patch writes ONLY version-exempt
|
|
642
642
|
* fields (`@db.column.version.exempt`). `data` has nav fields, filter keys and
|
|
643
643
|
* derived fields removed and `$cas` separated. Mirrors `flattenPatchPayload`
|
|
644
|
-
* (keep the two side by side): PK keys
|
|
645
|
-
*
|
|
646
|
-
* array ops, object); a non-exempt
|
|
647
|
-
* supplied children are written);
|
|
644
|
+
* (keep the two side by side): PK keys and `@db.onUpdate.now` fields are
|
|
645
|
+
* skipped; an exempt path (or one under an exempt ancestor) is covered
|
|
646
|
+
* whatever its value (scalar, field op, array ops, object); a non-exempt
|
|
647
|
+
* merge-strategy object recurses (only the supplied children are written);
|
|
648
|
+
* anything else is a non-exempt write.
|
|
648
649
|
* True iff at least one key is covered and none is not.
|
|
649
650
|
* @since 0.1.150
|
|
650
651
|
*/
|
|
@@ -691,4 +692,4 @@ declare function createFailureCollector(what: string): {
|
|
|
691
692
|
*/
|
|
692
693
|
declare function numericOperandProblem(fd: TDbFieldMeta): string | undefined;
|
|
693
694
|
//#endregion
|
|
694
|
-
export { $cas, $dec, $inc, $insert, $mul, $remove, $replace, $update, $upsert, ADAPTER_FILTER_REASON, ALL_AGGREGATE_FNS, ALL_BUCKET_UNITS, ALL_VIEW_CAPABILITIES, type AggregateControls, type AggregateExpr, type AggregateFn, type AggregateQuery, type AggregateResult, ApplicationIntegrity, AtscriptDbReadable, AtscriptDbTable, AtscriptDbView, type AtscriptDbWritable, type AtscriptExprNode, type AtscriptOrderItem, type AtscriptQueryComparison, type AtscriptQueryFieldRef, type AtscriptQueryNode, type AtscriptRef, BaseDbAdapter, type BucketExpr, type BucketUnit, type CalendarBucketLabel, CasExhaustedError, CasMismatchError, type ComputedExpr, DEFAULT_DB_SPACE, type DbControls, DbEncryption, DbError, type DbErrorCode, type DbPatch, type DbQuery, type DbResponse, type DbRow, DbSpace, type DbValidationContext, DocumentFieldMapper, ENCRYPTED_REASON, FieldMappingStrategy, type FieldOpsFor, type FilterExpr, type FilterVisitor, type FlatOf, INTEGER_REGEX_OP, IntegrityStrategy, NativeIntegrity, type NavPropsOf, NoopLogger, type NullableOptional, type NullsPlacement, type OwnPropsOf, type PrimaryKeyOf, RELATION_OPS, REL_FILTER_MAX_DEPTH, REL_FILTER_MAX_NODES, type RelationOp, RelationalFieldMapper, type ResolvedBucket, ResolvedRelationFilter, type TAdapterFactory, type TArrayPatch, type TBucketFieldSource, type TBucketSourceTable, type TBucketSourceVerdict, type TCascadeResolver, type TCascadeTarget, type TColumnDiff, type TCrudOp, type TCrudPermissions, type TDbActionInfo, type TDbActionIntent, type TDbActionLevel, type TDbActionProcessor, type TDbActionTargetSummary, type TDbAvailableActions, type TDbCas, type TDbCollation, type TDbDefaultFn, type TDbDefaultValue, type TDbDeleteResult, type TDbEncryptionOptions, type TDbFieldMeta, type TDbFieldOp, type TDbForeignKey, type TDbIndex, type TDbIndexField, type TDbIndexType, type TDbInsertIgnoreOptions, type TDbInsertIgnoreResult, type TDbInsertIgnoreSlot, type TDbInsertManyIgnoreResult, type TDbInsertManyResult, type TDbInsertResult, type TDbObjectKind, type TDbPatch, type TDbReferentialAction, type TDbRelation, type TDbRemoveGuard, type TDbRemoveGuardContext, type TDbSpaceOptions, type TDbStorageType, type TDbUpdateOptions, type TDbUpdateResult, type TDbWriteAction, type TDbWriteCheck, type TDbWriteCheckContext, type TDbWriteGuard, type TDbWriteGuardContext, type TDeleteOptions, type TDerivedChangeReason, type TDerivedColumn, type TEnsureTableOptions, type TExistingColumn, type TExistingForeignKey, type TExistingTableOption, type TExprAggregate, type TFieldMeta, type TFieldOps, type TFilterPredicate, type TFilterRef, type TFirstLast, type TFkLookupResolver, type TFkLookupTarget, type TGenericLogger, type TGroupSourceVerdict, type TGuardedQuery, type TIdDescriptor, type TIdResolveOptions, type TIdentification, type TInsertOptions, type TJsonCopyTarget, type TMetaResponse, type TMetadataOverrides, type TPathPresence, type TPrimaryKeyChange, type TQueryPathKind, type TQueryPathOp, type TQueryPathRefs, type TQueryPathSource, type TReadColumnsKind, type TReadControls, type TReferencingForeignKey, type TRelationFilterJunction, type TRelationFilterTable, type TRelationInfo, type TRelationStaticFilter, type TResolvedBucket, type TRowOrderKey, type TRowResolveOptions, type TSearchIndexInfo, type TSearchMemberKind, type TSyncColumnResult, type TTableOptionDiff, type TTableResolver, type TTouchManyOptions, type TValueFormatterPair, type TViewCapability, type TViewColumnMapping, type TViewJoin, type TViewJsonType, type TViewPlan, type TViewReadPlan, type TWriteOptions, type TWriteTableResolver, TableMetadata, type TypedWithRelation, UniquSelect, type Uniquery, type UniqueryControls, type ValidationContext, type ValidatorMode, type WeekStart, type WithOptimisticRetryOptions, type WithRelation, acceptedOperatorsHint, aggregateExpressionsNotSupported, aggregateFailure, aliasTargetOf, andFilters, assertGeoPoint, assertNoVersionWrites, bucketSourceVerdict, bucketTimeZoneUnavailable, buildDbValidator, buildValidationContext, canFilterLeaf, checkHavingKeys, classifyQueryPath, collectQueryPaths, computeInsights, containsRelationFilter, createDbValidatorPlugin, createFailureCollector, decomposePatch, defaultFulltextIndex, deletePath, describeFulltext, evaluateExpr, findAncestorInSet, fkColumns, forEachResolvedRelation, forceNavNonOptional, geoIndexNotFoundMessage, getDbFieldOp, getKeyProps, getPath, groupSourceVerdict, guardAggregate, guardFilter, guardPath, guardPaths, guardQuery, hasRelationOp, isAtscriptDbView, isBucketableField, isColumnTypeChanged, isConflict, isDbEntityType, isDbFieldOp, isEmptyObject, isFieldRef, isGeoIndexableType, isGeoPointType, isJsonValueField, isNavRelation, isPlainObject, isPrimitive, isRelationOp, isResolvedRelationFilter, isRetryableDbError, isVersionExemptPatch, isViewType, jsonValueAncestor, narrowerFilterOps, normalizeComputedSelect, numericOperandProblem, queryReadColumns, reconcileCas, relationStaticFilter, resolveCalendarBuckets, resolveDesignType, searchIndexNotFoundMessage, searchMemberKind, searchTermInteger, selfOrAncestor, separateCas, separateFieldOps, sortFieldNames, splitFulltextFields, tableNameOf, translateQueryTree, uniqueKeyTuple, unsupportedOperatorMessage, vectorIndexNotFoundMessage, walkFilter, withOptimisticRetry };
|
|
695
|
+
export { $cas, $dec, $inc, $insert, $mul, $remove, $replace, $update, $upsert, ADAPTER_FILTER_REASON, ALL_AGGREGATE_FNS, ALL_BUCKET_UNITS, ALL_VIEW_CAPABILITIES, type AggregateControls, type AggregateExpr, type AggregateFn, type AggregateQuery, type AggregateResult, ApplicationIntegrity, AtscriptDbReadable, AtscriptDbTable, AtscriptDbView, type AtscriptDbWritable, type AtscriptExprNode, type AtscriptOrderItem, type AtscriptQueryComparison, type AtscriptQueryFieldRef, type AtscriptQueryNode, type AtscriptRef, BaseDbAdapter, type BucketExpr, type BucketUnit, type CalendarBucketLabel, CasExhaustedError, CasMismatchError, type ComputedExpr, DEFAULT_DB_SPACE, type DbControls, DbEncryption, DbError, type DbErrorCode, type DbPatch, type DbQuery, type DbResponse, type DbRow, DbSpace, type DbValidationContext, DocumentFieldMapper, ENCRYPTED_REASON, FieldMappingStrategy, type FieldOpsFor, type FilterExpr, type FilterVisitor, type FlatOf, INTEGER_REGEX_OP, IntegrityStrategy, NativeIntegrity, type NavPropsOf, NoopLogger, type NullableOptional, type NullsPlacement, type OwnPropsOf, type PrimaryKeyOf, RELATION_OPS, REL_FILTER_MAX_DEPTH, REL_FILTER_MAX_NODES, type RelationOp, RelationalFieldMapper, type ResolvedBucket, ResolvedRelationFilter, type TAdapterFactory, type TArrayPatch, type TBucketFieldSource, type TBucketSourceTable, type TBucketSourceVerdict, type TCascadeResolver, type TCascadeTarget, type TColumnDiff, type TCrudOp, type TCrudPermissions, type TDbActionInfo, type TDbActionIntent, type TDbActionLevel, type TDbActionProcessor, type TDbActionTargetSummary, type TDbAvailableActions, type TDbCas, type TDbCollation, type TDbDefaultFn, type TDbDefaultValue, type TDbDeleteResult, type TDbEncryptionOptions, type TDbFieldMeta, type TDbFieldOp, type TDbForeignKey, type TDbIndex, type TDbIndexField, type TDbIndexType, type TDbInsertIgnoreOptions, type TDbInsertIgnoreResult, type TDbInsertIgnoreSlot, type TDbInsertManyIgnoreResult, type TDbInsertManyResult, type TDbInsertResult, type TDbObjectKind, type TDbPatch, type TDbReferentialAction, type TDbRelation, type TDbRemoveGuard, type TDbRemoveGuardContext, type TDbSpaceOptions, type TDbStorageType, type TDbUpdateOptions, type TDbUpdateResult, type TDbWriteAction, type TDbWriteCheck, type TDbWriteCheckContext, type TDbWriteGuard, type TDbWriteGuardContext, type TDeleteOptions, type TDerivedChangeReason, type TDerivedColumn, type TEnsureTableOptions, type TExistingColumn, type TExistingForeignKey, type TExistingTableOption, type TExprAggregate, type TFieldMeta, type TFieldOps, type TFilterPredicate, type TFilterRef, type TFirstLast, type TFkLookupResolver, type TFkLookupTarget, type TGenericLogger, type TGroupSourceVerdict, type TGuardedQuery, type TIdDescriptor, type TIdResolveOptions, type TIdentification, type TInsertOptions, type TJsonCopyTarget, type TMetaResponse, type TMetadataOverrides, type TPathPresence, type TPrimaryKeyChange, type TQueryPathKind, type TQueryPathOp, type TQueryPathRefs, type TQueryPathSource, type TReadColumnsKind, type TReadControls, type TReferencingForeignKey, type TRelationFilterJunction, type TRelationFilterTable, type TRelationInfo, type TRelationStaticFilter, type TResolvedBucket, type TRowOrderKey, type TRowResolveOptions, type TSearchIndexInfo, type TSearchMemberKind, type TSyncColumnResult, type TSyncIndexesOptions, type TTableOptionDiff, type TTableResolver, type TTouchManyOptions, type TValueFormatterPair, type TViewCapability, type TViewColumnMapping, type TViewJoin, type TViewJsonType, type TViewPlan, type TViewReadPlan, type TWriteOptions, type TWriteTableResolver, TableMetadata, type TypedWithRelation, UniquSelect, type Uniquery, type UniqueryControls, type ValidationContext, type ValidatorMode, type WeekStart, type WithOptimisticRetryOptions, type WithRelation, acceptedOperatorsHint, aggregateExpressionsNotSupported, aggregateFailure, aliasTargetOf, andFilters, assertGeoPoint, assertNoVersionWrites, bucketSourceVerdict, bucketTimeZoneUnavailable, buildDbValidator, buildValidationContext, canFilterLeaf, checkHavingKeys, classifyQueryPath, collectQueryPaths, computeInsights, containsRelationFilter, createDbValidatorPlugin, createFailureCollector, decomposePatch, defaultFulltextIndex, deletePath, describeFulltext, evaluateExpr, findAncestorInSet, fkColumns, forEachResolvedRelation, forceNavNonOptional, geoIndexNotFoundMessage, getDbFieldOp, getKeyProps, getPath, groupSourceVerdict, guardAggregate, guardFilter, guardPath, guardPaths, guardQuery, hasRelationOp, isAtscriptDbView, isBucketableField, isColumnTypeChanged, isConflict, isDbEntityType, isDbFieldOp, isEmptyObject, isFieldRef, isGeoIndexableType, isGeoPointType, isJsonValueField, isNavRelation, isPlainObject, isPrimitive, isRelationOp, isResolvedRelationFilter, isRetryableDbError, isVersionExemptPatch, isViewType, jsonValueAncestor, narrowerFilterOps, normalizeComputedSelect, numericOperandProblem, queryReadColumns, reconcileCas, relationStaticFilter, resolveCalendarBuckets, resolveDesignType, searchIndexNotFoundMessage, searchMemberKind, searchTermInteger, selfOrAncestor, separateCas, separateFieldOps, sortFieldNames, splitFulltextFields, tableNameOf, translateQueryTree, uniqueKeyTuple, unsupportedOperatorMessage, vectorIndexNotFoundMessage, walkFilter, withOptimisticRetry };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { $ as TDbInsertResult, $t as
|
|
1
|
+
import { $ as TDbInsertResult, $t as ALL_VIEW_CAPABILITIES, A as TColumnDiff, An as REL_FILTER_MAX_NODES, At as TPrimaryKeyChange, B as TDbDefaultFn, Bn as isResolvedRelationFilter, Bt as TValueFormatterPair, C as NavPropsOf, Cn as IntegrityStrategy, Ct as TIdDescriptor, D as PrimaryKeyOf, Dn as DbResponse, Dt as TJsonCopyTarget, E as OwnPropsOf, En as AtscriptDbReadable, Et as TInsertOptions, F as TDbActionLevel, Fn as TRelationStaticFilter, Ft as TSyncColumnResult, G as TDbIndex, Gn as FieldMappingStrategy, Gt as Uniquery, H as TDbDeleteResult, Hn as DbEncryption, Ht as TWriteOptions, I as TDbActionProcessor, In as andFilters, It as TSyncIndexesOptions, J as TDbInsertIgnoreOptions, Jn as TGenericLogger, Jt as TableMetadata, K as TDbIndexField, Kn as TReadControls, Kt as UniqueryControls, L as TDbActionTargetSummary, Ln as containsRelationFilter, Lt as TTableOptionDiff, M as TCrudPermissions, Mn as TRelGuardState, Mt as TRelationInfo, N as TDbActionInfo, Nn as TRelationFilterJunction, Nt as TRowResolveOptions, O as TCascadeResolver, On as resolveDesignType, Ot as TMetaResponse, P as TDbActionIntent, Pn as TRelationFilterTable, Pt as TSearchIndexInfo, Q as TDbInsertManyResult, Qn as UniquSelect, Qt as ALL_BUCKET_UNITS, R as TDbAvailableActions, Rn as forEachResolvedRelation, Rt as TTableResolver, S as FlatOf, Sn as AtscriptDbTable, St as TFkLookupTarget, T as NullsPlacement, Tn as TCascadePin, Tt as TIdentification, U as TDbFieldMeta, Un as TDbEncryptionOptions, Ut as TWriteTableResolver, V as TDbDefaultValue, Vn as relationStaticFilter, Vt as TViewJsonType, W as TDbForeignKey, Wn as DocumentFieldMapper, Wt as TypedWithRelation, X as TDbInsertIgnoreSlot, Xn as TFirstLast, Xt as isGeoPointType, Y as TDbInsertIgnoreResult, Yn as TExprAggregate, Yt as isGeoIndexableType, Z as TDbInsertManyIgnoreResult, Zn as TRowOrderKey, Zt as TPathPresence, _ as DbPatch, _n as TViewJoin, _t as TExistingColumn, a as isJsonValueField, an as AtscriptDbView, at as TDbStorageType, b as FieldOpsFor, bn as isFieldRef, bt as TFieldMeta, c as resolveCalendarBuckets, cn as isViewType, ct as TDbWriteAction, d as AggregateFn, dn as AtscriptExprNode, dt as TDbWriteGuard, en as BaseDbAdapter, et as TDbObjectKind, f as AggregateQuery, fn as AtscriptOrderItem, ft as TDbWriteGuardContext, g as DbControls, gn as AtscriptRef, gt as TEnsureTableOptions, h as AtscriptDbWritable, hn as AtscriptQueryNode, ht as TDerivedColumn, i as isBucketableField, in as TDbSpaceOptions, it as TDbRemoveGuardContext, j as TCrudOp, jn as ResolvedRelationFilter, jt as TReferencingForeignKey, k as TCascadeTarget, kn as REL_FILTER_MAX_DEPTH, kt as TMetadataOverrides, l as AggregateControls, ln as TViewReadPlan, lt as TDbWriteCheck, mn as AtscriptQueryFieldRef, mt as TDerivedChangeReason, n as TComputedSelect, nn as DbSpace, nt as TDbRelation, o as jsonValueAncestor, on as TViewColumnMapping, ot as TDbUpdateOptions, p as AggregateResult, pn as AtscriptQueryComparison, pt as TDeleteOptions, q as TDbIndexType, qn as NoopLogger, qt as WithRelation, r as TResolvedBucket, rn as TAdapterFactory, rt as TDbRemoveGuard, s as normalizeComputedSelect, sn as isAtscriptDbView, st as TDbUpdateResult, t as TBucketFieldSource, tn as TViewCapability, tt as TDbReferentialAction, u as AggregateExpr, un as aliasTargetOf, ut as TDbWriteCheckContext, v as DbQuery, vn as TViewPlan, vt as TExistingForeignKey, w as NullableOptional, wn as NativeIntegrity, wt as TIdResolveOptions, x as FilterExpr, xn as translateQueryTree, xt as TFkLookupResolver, y as DbRow, yn as evaluateExpr, yt as TExistingTableOption, z as TDbCollation, zn as hasRelationOp, zt as TTouchManyOptions } from "./buckets-8mG67Mtw.mjs";
|
|
2
2
|
import { _ as separateFieldOps, a as $mul, c as $update, d as TDbFieldOp, f as TFieldOps, g as separateCas, h as reconcileCas, i as $insert, l as $upsert, m as isDbFieldOp, n as $dec, o as $remove, p as getDbFieldOp, r as $inc, s as $replace, t as $cas, u as TDbCas } from "./ops-AqhV7s9o.mjs";
|
|
3
3
|
import { a as isPlainObject, i as isEmptyObject, n as findAncestorInSet, o as selfOrAncestor, r as getPath, t as deletePath } from "./object-CtPYTIvy.mjs";
|
|
4
4
|
import { c as CalendarBucketLabel, d as WeekStart, g as ALL_AGGREGATE_FNS, l as ComputedExpr, o as BucketExpr, s as BucketUnit, u as ResolvedBucket } from "./agg-Wo-smrYV.mjs";
|
|
5
5
|
import { _ as aggregateFailure, a as buildValidationContext, b as isRetryableDbError, c as isNavRelation, d as getKeyProps, f as CasExhaustedError, g as aggregateExpressionsNotSupported, h as DbErrorCode, l as TArrayPatch, m as DbError, n as ValidatorMode, p as CasMismatchError, r as buildDbValidator, s as forceNavNonOptional, t as ValidationContext, u as TDbPatch, v as bucketTimeZoneUnavailable, y as isConflict } from "./validator-B3xlbrWf.mjs";
|
|
6
6
|
import { n as createDbValidatorPlugin, t as DbValidationContext } from "./db-validator-plugin-BWy60OvG.mjs";
|
|
7
|
-
import { r as fkColumns, s as isColumnTypeChanged } from "./fk-diff-
|
|
8
|
-
import { i as tableNameOf } from "./relation-helpers-
|
|
7
|
+
import { r as fkColumns, s as isColumnTypeChanged } from "./fk-diff-5gX42hBt.mjs";
|
|
8
|
+
import { i as tableNameOf } from "./relation-helpers-17_2f5hX.mjs";
|
|
9
9
|
import { AtscriptExprNode as AtscriptExprNode$1, TAtscriptAnnotatedType } from "@atscript/typescript/utils";
|
|
10
10
|
import { AggregateQuery as AggregateQuery$1, FilterExpr as FilterExpr$1, FilterVisitor, RELATION_OPS, RelationOp, RelationOp as RelationOp$1, ResolvedRowOrderKey, ResolvedSelectExpr, Uniquery as Uniquery$1, computeInsights, isPrimitive, isRelationOp, walkFilter } from "@uniqu/core";
|
|
11
11
|
|
|
@@ -641,10 +641,11 @@ declare function assertNoVersionWrites(data: Record<string, unknown>, versionCol
|
|
|
641
641
|
* Whether a logical (pre-decomposition) patch writes ONLY version-exempt
|
|
642
642
|
* fields (`@db.column.version.exempt`). `data` has nav fields, filter keys and
|
|
643
643
|
* derived fields removed and `$cas` separated. Mirrors `flattenPatchPayload`
|
|
644
|
-
* (keep the two side by side): PK keys
|
|
645
|
-
*
|
|
646
|
-
* array ops, object); a non-exempt
|
|
647
|
-
* supplied children are written);
|
|
644
|
+
* (keep the two side by side): PK keys and `@db.onUpdate.now` fields are
|
|
645
|
+
* skipped; an exempt path (or one under an exempt ancestor) is covered
|
|
646
|
+
* whatever its value (scalar, field op, array ops, object); a non-exempt
|
|
647
|
+
* merge-strategy object recurses (only the supplied children are written);
|
|
648
|
+
* anything else is a non-exempt write.
|
|
648
649
|
* True iff at least one key is covered and none is not.
|
|
649
650
|
* @since 0.1.150
|
|
650
651
|
*/
|
|
@@ -691,4 +692,4 @@ declare function createFailureCollector(what: string): {
|
|
|
691
692
|
*/
|
|
692
693
|
declare function numericOperandProblem(fd: TDbFieldMeta): string | undefined;
|
|
693
694
|
//#endregion
|
|
694
|
-
export { $cas, $dec, $inc, $insert, $mul, $remove, $replace, $update, $upsert, ADAPTER_FILTER_REASON, ALL_AGGREGATE_FNS, ALL_BUCKET_UNITS, ALL_VIEW_CAPABILITIES, type AggregateControls, type AggregateExpr, type AggregateFn, type AggregateQuery, type AggregateResult, ApplicationIntegrity, AtscriptDbReadable, AtscriptDbTable, AtscriptDbView, type AtscriptDbWritable, type AtscriptExprNode, type AtscriptOrderItem, type AtscriptQueryComparison, type AtscriptQueryFieldRef, type AtscriptQueryNode, type AtscriptRef, BaseDbAdapter, type BucketExpr, type BucketUnit, type CalendarBucketLabel, CasExhaustedError, CasMismatchError, type ComputedExpr, DEFAULT_DB_SPACE, type DbControls, DbEncryption, DbError, type DbErrorCode, type DbPatch, type DbQuery, type DbResponse, type DbRow, DbSpace, type DbValidationContext, DocumentFieldMapper, ENCRYPTED_REASON, FieldMappingStrategy, type FieldOpsFor, type FilterExpr, type FilterVisitor, type FlatOf, INTEGER_REGEX_OP, IntegrityStrategy, NativeIntegrity, type NavPropsOf, NoopLogger, type NullableOptional, type NullsPlacement, type OwnPropsOf, type PrimaryKeyOf, RELATION_OPS, REL_FILTER_MAX_DEPTH, REL_FILTER_MAX_NODES, type RelationOp, RelationalFieldMapper, type ResolvedBucket, ResolvedRelationFilter, type TAdapterFactory, type TArrayPatch, type TBucketFieldSource, type TBucketSourceTable, type TBucketSourceVerdict, type TCascadeResolver, type TCascadeTarget, type TColumnDiff, type TCrudOp, type TCrudPermissions, type TDbActionInfo, type TDbActionIntent, type TDbActionLevel, type TDbActionProcessor, type TDbActionTargetSummary, type TDbAvailableActions, type TDbCas, type TDbCollation, type TDbDefaultFn, type TDbDefaultValue, type TDbDeleteResult, type TDbEncryptionOptions, type TDbFieldMeta, type TDbFieldOp, type TDbForeignKey, type TDbIndex, type TDbIndexField, type TDbIndexType, type TDbInsertIgnoreOptions, type TDbInsertIgnoreResult, type TDbInsertIgnoreSlot, type TDbInsertManyIgnoreResult, type TDbInsertManyResult, type TDbInsertResult, type TDbObjectKind, type TDbPatch, type TDbReferentialAction, type TDbRelation, type TDbRemoveGuard, type TDbRemoveGuardContext, type TDbSpaceOptions, type TDbStorageType, type TDbUpdateOptions, type TDbUpdateResult, type TDbWriteAction, type TDbWriteCheck, type TDbWriteCheckContext, type TDbWriteGuard, type TDbWriteGuardContext, type TDeleteOptions, type TDerivedChangeReason, type TDerivedColumn, type TEnsureTableOptions, type TExistingColumn, type TExistingForeignKey, type TExistingTableOption, type TExprAggregate, type TFieldMeta, type TFieldOps, type TFilterPredicate, type TFilterRef, type TFirstLast, type TFkLookupResolver, type TFkLookupTarget, type TGenericLogger, type TGroupSourceVerdict, type TGuardedQuery, type TIdDescriptor, type TIdResolveOptions, type TIdentification, type TInsertOptions, type TJsonCopyTarget, type TMetaResponse, type TMetadataOverrides, type TPathPresence, type TPrimaryKeyChange, type TQueryPathKind, type TQueryPathOp, type TQueryPathRefs, type TQueryPathSource, type TReadColumnsKind, type TReadControls, type TReferencingForeignKey, type TRelationFilterJunction, type TRelationFilterTable, type TRelationInfo, type TRelationStaticFilter, type TResolvedBucket, type TRowOrderKey, type TRowResolveOptions, type TSearchIndexInfo, type TSearchMemberKind, type TSyncColumnResult, type TTableOptionDiff, type TTableResolver, type TTouchManyOptions, type TValueFormatterPair, type TViewCapability, type TViewColumnMapping, type TViewJoin, type TViewJsonType, type TViewPlan, type TViewReadPlan, type TWriteOptions, type TWriteTableResolver, TableMetadata, type TypedWithRelation, UniquSelect, type Uniquery, type UniqueryControls, type ValidationContext, type ValidatorMode, type WeekStart, type WithOptimisticRetryOptions, type WithRelation, acceptedOperatorsHint, aggregateExpressionsNotSupported, aggregateFailure, aliasTargetOf, andFilters, assertGeoPoint, assertNoVersionWrites, bucketSourceVerdict, bucketTimeZoneUnavailable, buildDbValidator, buildValidationContext, canFilterLeaf, checkHavingKeys, classifyQueryPath, collectQueryPaths, computeInsights, containsRelationFilter, createDbValidatorPlugin, createFailureCollector, decomposePatch, defaultFulltextIndex, deletePath, describeFulltext, evaluateExpr, findAncestorInSet, fkColumns, forEachResolvedRelation, forceNavNonOptional, geoIndexNotFoundMessage, getDbFieldOp, getKeyProps, getPath, groupSourceVerdict, guardAggregate, guardFilter, guardPath, guardPaths, guardQuery, hasRelationOp, isAtscriptDbView, isBucketableField, isColumnTypeChanged, isConflict, isDbEntityType, isDbFieldOp, isEmptyObject, isFieldRef, isGeoIndexableType, isGeoPointType, isJsonValueField, isNavRelation, isPlainObject, isPrimitive, isRelationOp, isResolvedRelationFilter, isRetryableDbError, isVersionExemptPatch, isViewType, jsonValueAncestor, narrowerFilterOps, normalizeComputedSelect, numericOperandProblem, queryReadColumns, reconcileCas, relationStaticFilter, resolveCalendarBuckets, resolveDesignType, searchIndexNotFoundMessage, searchMemberKind, searchTermInteger, selfOrAncestor, separateCas, separateFieldOps, sortFieldNames, splitFulltextFields, tableNameOf, translateQueryTree, uniqueKeyTuple, unsupportedOperatorMessage, vectorIndexNotFoundMessage, walkFilter, withOptimisticRetry };
|
|
695
|
+
export { $cas, $dec, $inc, $insert, $mul, $remove, $replace, $update, $upsert, ADAPTER_FILTER_REASON, ALL_AGGREGATE_FNS, ALL_BUCKET_UNITS, ALL_VIEW_CAPABILITIES, type AggregateControls, type AggregateExpr, type AggregateFn, type AggregateQuery, type AggregateResult, ApplicationIntegrity, AtscriptDbReadable, AtscriptDbTable, AtscriptDbView, type AtscriptDbWritable, type AtscriptExprNode, type AtscriptOrderItem, type AtscriptQueryComparison, type AtscriptQueryFieldRef, type AtscriptQueryNode, type AtscriptRef, BaseDbAdapter, type BucketExpr, type BucketUnit, type CalendarBucketLabel, CasExhaustedError, CasMismatchError, type ComputedExpr, DEFAULT_DB_SPACE, type DbControls, DbEncryption, DbError, type DbErrorCode, type DbPatch, type DbQuery, type DbResponse, type DbRow, DbSpace, type DbValidationContext, DocumentFieldMapper, ENCRYPTED_REASON, FieldMappingStrategy, type FieldOpsFor, type FilterExpr, type FilterVisitor, type FlatOf, INTEGER_REGEX_OP, IntegrityStrategy, NativeIntegrity, type NavPropsOf, NoopLogger, type NullableOptional, type NullsPlacement, type OwnPropsOf, type PrimaryKeyOf, RELATION_OPS, REL_FILTER_MAX_DEPTH, REL_FILTER_MAX_NODES, type RelationOp, RelationalFieldMapper, type ResolvedBucket, ResolvedRelationFilter, type TAdapterFactory, type TArrayPatch, type TBucketFieldSource, type TBucketSourceTable, type TBucketSourceVerdict, type TCascadeResolver, type TCascadeTarget, type TColumnDiff, type TCrudOp, type TCrudPermissions, type TDbActionInfo, type TDbActionIntent, type TDbActionLevel, type TDbActionProcessor, type TDbActionTargetSummary, type TDbAvailableActions, type TDbCas, type TDbCollation, type TDbDefaultFn, type TDbDefaultValue, type TDbDeleteResult, type TDbEncryptionOptions, type TDbFieldMeta, type TDbFieldOp, type TDbForeignKey, type TDbIndex, type TDbIndexField, type TDbIndexType, type TDbInsertIgnoreOptions, type TDbInsertIgnoreResult, type TDbInsertIgnoreSlot, type TDbInsertManyIgnoreResult, type TDbInsertManyResult, type TDbInsertResult, type TDbObjectKind, type TDbPatch, type TDbReferentialAction, type TDbRelation, type TDbRemoveGuard, type TDbRemoveGuardContext, type TDbSpaceOptions, type TDbStorageType, type TDbUpdateOptions, type TDbUpdateResult, type TDbWriteAction, type TDbWriteCheck, type TDbWriteCheckContext, type TDbWriteGuard, type TDbWriteGuardContext, type TDeleteOptions, type TDerivedChangeReason, type TDerivedColumn, type TEnsureTableOptions, type TExistingColumn, type TExistingForeignKey, type TExistingTableOption, type TExprAggregate, type TFieldMeta, type TFieldOps, type TFilterPredicate, type TFilterRef, type TFirstLast, type TFkLookupResolver, type TFkLookupTarget, type TGenericLogger, type TGroupSourceVerdict, type TGuardedQuery, type TIdDescriptor, type TIdResolveOptions, type TIdentification, type TInsertOptions, type TJsonCopyTarget, type TMetaResponse, type TMetadataOverrides, type TPathPresence, type TPrimaryKeyChange, type TQueryPathKind, type TQueryPathOp, type TQueryPathRefs, type TQueryPathSource, type TReadColumnsKind, type TReadControls, type TReferencingForeignKey, type TRelationFilterJunction, type TRelationFilterTable, type TRelationInfo, type TRelationStaticFilter, type TResolvedBucket, type TRowOrderKey, type TRowResolveOptions, type TSearchIndexInfo, type TSearchMemberKind, type TSyncColumnResult, type TSyncIndexesOptions, type TTableOptionDiff, type TTableResolver, type TTouchManyOptions, type TValueFormatterPair, type TViewCapability, type TViewColumnMapping, type TViewJoin, type TViewJsonType, type TViewPlan, type TViewReadPlan, type TWriteOptions, type TWriteTableResolver, TableMetadata, type TypedWithRelation, UniquSelect, type Uniquery, type UniqueryControls, type ValidationContext, type ValidatorMode, type WeekStart, type WithOptimisticRetryOptions, type WithRelation, acceptedOperatorsHint, aggregateExpressionsNotSupported, aggregateFailure, aliasTargetOf, andFilters, assertGeoPoint, assertNoVersionWrites, bucketSourceVerdict, bucketTimeZoneUnavailable, buildDbValidator, buildValidationContext, canFilterLeaf, checkHavingKeys, classifyQueryPath, collectQueryPaths, computeInsights, containsRelationFilter, createDbValidatorPlugin, createFailureCollector, decomposePatch, defaultFulltextIndex, deletePath, describeFulltext, evaluateExpr, findAncestorInSet, fkColumns, forEachResolvedRelation, forceNavNonOptional, geoIndexNotFoundMessage, getDbFieldOp, getKeyProps, getPath, groupSourceVerdict, guardAggregate, guardFilter, guardPath, guardPaths, guardQuery, hasRelationOp, isAtscriptDbView, isBucketableField, isColumnTypeChanged, isConflict, isDbEntityType, isDbFieldOp, isEmptyObject, isFieldRef, isGeoIndexableType, isGeoPointType, isJsonValueField, isNavRelation, isPlainObject, isPrimitive, isRelationOp, isResolvedRelationFilter, isRetryableDbError, isVersionExemptPatch, isViewType, jsonValueAncestor, narrowerFilterOps, normalizeComputedSelect, numericOperandProblem, queryReadColumns, reconcileCas, relationStaticFilter, resolveCalendarBuckets, resolveDesignType, searchIndexNotFoundMessage, searchMemberKind, searchTermInteger, selfOrAncestor, separateCas, separateFieldOps, sortFieldNames, splitFulltextFields, tableNameOf, translateQueryTree, uniqueKeyTuple, unsupportedOperatorMessage, vectorIndexNotFoundMessage, walkFilter, withOptimisticRetry };
|
package/dist/index.mjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { a as aggregateExpressionsNotSupported, c as isConflict, l as isRetryableDbError, n as CasMismatchError, o as aggregateFailure, r as DbError, s as bucketTimeZoneUnavailable, t as CasExhaustedError, u as spaceClosedError } from "./db-error-eSsQX7rt.mjs";
|
|
2
|
-
import { $ as RelationalFieldMapper, A as AtscriptDbReadable, B as canFilterLeaf, C as ApplicationIntegrity, D as createFailureCollector, E as BaseDbAdapter, F as ADAPTER_FILTER_REASON, G as guardAggregate, H as classifyQueryPath, I as ENCRYPTED_REASON, J as guardPaths, K as guardFilter, L as acceptedOperatorsHint, M as geoIndexNotFoundMessage, N as searchIndexNotFoundMessage, O as IntegrityStrategy, P as vectorIndexNotFoundMessage, Q as unsupportedOperatorMessage, R as assertGeoPoint, S as decomposePatch, T as ALL_VIEW_CAPABILITIES, U as collectQueryPaths, V as checkHavingKeys, W as groupSourceVerdict, X as narrowerFilterOps, Y as guardQuery, Z as sortFieldNames, _ as isAtscriptDbView, _t as normalizeComputedSelect, at as defaultFulltextIndex, b as isVersionExemptPatch, ct as splitFulltextFields, dt as isGeoPointType, et as DocumentFieldMapper, g as AtscriptDbView, gt as jsonValueAncestor, ht as isJsonValueField, it as INTEGER_REGEX_OP, j as resolveDesignType, k as NativeIntegrity, lt as TableMetadata, mt as isBucketableField, n as isColumnTypeChanged, nt as UniquSelect, ot as describeFulltext, p as fkColumns, pt as aliasTargetOf, q as guardPath, rt as numericOperandProblem, st as searchTermInteger, tt as FieldMappingStrategy, ut as isGeoIndexableType, v as isViewType, vt as resolveCalendarBuckets, w as ALL_BUCKET_UNITS, x as assertNoVersionWrites, y as AtscriptDbTable, yt as NoopLogger, z as bucketSourceVerdict } from "./column-diff-
|
|
2
|
+
import { $ as RelationalFieldMapper, A as AtscriptDbReadable, B as canFilterLeaf, C as ApplicationIntegrity, D as createFailureCollector, E as BaseDbAdapter, F as ADAPTER_FILTER_REASON, G as guardAggregate, H as classifyQueryPath, I as ENCRYPTED_REASON, J as guardPaths, K as guardFilter, L as acceptedOperatorsHint, M as geoIndexNotFoundMessage, N as searchIndexNotFoundMessage, O as IntegrityStrategy, P as vectorIndexNotFoundMessage, Q as unsupportedOperatorMessage, R as assertGeoPoint, S as decomposePatch, T as ALL_VIEW_CAPABILITIES, U as collectQueryPaths, V as checkHavingKeys, W as groupSourceVerdict, X as narrowerFilterOps, Y as guardQuery, Z as sortFieldNames, _ as isAtscriptDbView, _t as normalizeComputedSelect, at as defaultFulltextIndex, b as isVersionExemptPatch, ct as splitFulltextFields, dt as isGeoPointType, et as DocumentFieldMapper, g as AtscriptDbView, gt as jsonValueAncestor, ht as isJsonValueField, it as INTEGER_REGEX_OP, j as resolveDesignType, k as NativeIntegrity, lt as TableMetadata, mt as isBucketableField, n as isColumnTypeChanged, nt as UniquSelect, ot as describeFulltext, p as fkColumns, pt as aliasTargetOf, q as guardPath, rt as numericOperandProblem, st as searchTermInteger, tt as FieldMappingStrategy, ut as isGeoIndexableType, v as isViewType, vt as resolveCalendarBuckets, w as ALL_BUCKET_UNITS, x as assertNoVersionWrites, y as AtscriptDbTable, yt as NoopLogger, z as bucketSourceVerdict } from "./column-diff-DR1glykD.mjs";
|
|
3
3
|
import { n as ALL_AGGREGATE_FNS } from "./aggregate-fns-B_sgl4mB.mjs";
|
|
4
4
|
import { A as hasRelationOp, C as REL_FILTER_MAX_DEPTH, D as containsRelationFilter, E as andFilters, G as evaluateExpr, H as tableNameOf, K as isFieldRef, P as relationStaticFilter, S as uniqueKeyTuple, T as ResolvedRelationFilter, j as isResolvedRelationFilter, k as forEachResolvedRelation, q as translateQueryTree, w as REL_FILTER_MAX_NODES } from "./nested-writer-BOj_c_lI.mjs";
|
|
5
|
-
import { a as forceNavNonOptional, c as getKeyProps, o as isNavRelation, r as buildValidationContext, s as createDbValidatorPlugin, t as buildDbValidator } from "./validator-
|
|
6
|
-
import { i as DB_ENTITY_ANNOTATIONS, n as searchMemberKind } from "./search-fields-
|
|
5
|
+
import { a as forceNavNonOptional, c as getKeyProps, o as isNavRelation, r as buildValidationContext, s as createDbValidatorPlugin, t as buildDbValidator } from "./validator-B3fPJjS1.mjs";
|
|
6
|
+
import { i as DB_ENTITY_ANNOTATIONS, n as searchMemberKind } from "./search-fields-CE8cmj9X.mjs";
|
|
7
7
|
import { a as isPlainObject, i as isEmptyObject, n as findAncestorInSet, o as selfOrAncestor, r as getPath, t as deletePath } from "./object-TkiJQ-Dp.mjs";
|
|
8
8
|
import { t as DEFAULT_DB_SPACE } from "./consts-C_-5_pFq.mjs";
|
|
9
9
|
import { $cas, $dec, $inc, $insert, $mul, $remove, $replace, $update, $upsert, getDbFieldOp, isDbFieldOp, reconcileCas, separateCas, separateFieldOps } from "./ops.mjs";
|
package/dist/plugin.cjs
CHANGED
|
@@ -34,9 +34,9 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
34
34
|
}) : target, mod));
|
|
35
35
|
//#endregion
|
|
36
36
|
const require_aggregate_fns = require("./aggregate-fns-DFtKAv7Q.cjs");
|
|
37
|
-
const require_search_fields = require("./search-fields-
|
|
37
|
+
const require_search_fields = require("./search-fields-CT_UZ9fg.cjs");
|
|
38
38
|
require("./consts-BzRfCcH2.cjs");
|
|
39
|
-
const require_validation_utils = require("./validation-utils-
|
|
39
|
+
const require_validation_utils = require("./validation-utils-CtLNlBtB.cjs");
|
|
40
40
|
let node_path = require("node:path");
|
|
41
41
|
node_path = __toESM(node_path, 1);
|
|
42
42
|
let node_url = require("node:url");
|
|
@@ -873,6 +873,21 @@ const dbColumnAnnotations = {
|
|
|
873
873
|
}
|
|
874
874
|
})
|
|
875
875
|
},
|
|
876
|
+
onUpdate: { now: new _atscript_core.AnnotationSpec({
|
|
877
|
+
description: "Sets the field to the current time (epoch ms) on every update: patches (`updateOne`, `bulkUpdate`, `updateMany`, HTTP `PATCH`) and replaces (`replaceOne`, `bulkReplace`, `replaceMany`, HTTP `PUT`). The value is written by the SDK in the same statement on every adapter and overrides a value the payload carries. Inserts are not affected — combine with `@db.default.now` (`number.timestamp.updated` applies both). Writes outside the SDK (raw SQL) do not set it.\n\n**Example:**\n```atscript\n@db.default.now\n@db.onUpdate.now\nupdatedAt: number.timestamp\n```\n",
|
|
878
|
+
nodeType: ["prop"],
|
|
879
|
+
passedWhenReferred: false,
|
|
880
|
+
validate(token, args, doc) {
|
|
881
|
+
const errors = require_validation_utils.validateFieldBaseType(token, doc, "@db.onUpdate.now", "number");
|
|
882
|
+
const field = token.parentNode;
|
|
883
|
+
for (const [name, why] of [["meta.id", "the primary key identifies the row and is never updated"], ["db.column.version", "the version column is adapter-managed"]]) if (field.countAnnotations(name) > 0) errors.push({
|
|
884
|
+
message: `@db.onUpdate.now cannot coexist with @${name} — ${why}`,
|
|
885
|
+
severity: 1,
|
|
886
|
+
range: token.range
|
|
887
|
+
});
|
|
888
|
+
return errors;
|
|
889
|
+
}
|
|
890
|
+
}) },
|
|
876
891
|
json: new _atscript_core.AnnotationSpec({
|
|
877
892
|
description: "Forces a field to be stored as a single JSON column instead of being flattened into separate columns. Use on nested object fields that should remain as JSON in the database.\n\n**Example:**\n```atscript\n@db.json\nmetadata: { key: string, value: string }\n```\n",
|
|
878
893
|
nodeType: ["prop"],
|
|
@@ -925,6 +940,7 @@ const dbColumnAnnotations = {
|
|
|
925
940
|
["db.column.version", "the OCC filter needs cleartext equality"],
|
|
926
941
|
["db.default.increment", "engine-side defaults bypass the encryption transform"],
|
|
927
942
|
["db.default.now", "engine-side defaults bypass the encryption transform"],
|
|
943
|
+
["db.onUpdate.now", "the update time is set after the encryption transform"],
|
|
928
944
|
["db.mongo.search.text", "Atlas Search over ciphertext is impossible"],
|
|
929
945
|
["db.mongo.search.autocomplete", "Atlas Search over ciphertext is impossible"]
|
|
930
946
|
]) if (field.countAnnotations(name) > 0) errors.push({
|
|
@@ -2319,6 +2335,7 @@ const dbPlugin = (options) => ({
|
|
|
2319
2335
|
index: dbIndexAnnotations.index,
|
|
2320
2336
|
column: dbColumnAnnotations.column,
|
|
2321
2337
|
default: dbColumnAnnotations.default,
|
|
2338
|
+
onUpdate: dbColumnAnnotations.onUpdate,
|
|
2322
2339
|
json: dbColumnAnnotations.json,
|
|
2323
2340
|
ignore: dbColumnAnnotations.ignore,
|
|
2324
2341
|
encrypted: dbColumnAnnotations.encrypted,
|
package/dist/plugin.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { i as NULL_WHEN_EMPTY_AGGREGATE_FNS, o as SUPPORTED_AGGREGATE_FNS, t as AGG_ANNOTATIONS } from "./aggregate-fns-B_sgl4mB.mjs";
|
|
2
|
-
import { a as DERIVED_INCOMPATIBLE, i as DB_ENTITY_ANNOTATIONS, o as JSON_LEAF_TYPES, r as numericTypeProblem } from "./search-fields-
|
|
2
|
+
import { a as DERIVED_INCOMPATIBLE, i as DB_ENTITY_ANNOTATIONS, o as JSON_LEAF_TYPES, r as numericTypeProblem } from "./search-fields-CE8cmj9X.mjs";
|
|
3
3
|
import "./consts-C_-5_pFq.mjs";
|
|
4
|
-
import { C as validateExclusiveWith, S as searchFieldVerdict, T as validateSiblingStringField, _ as getParentTypeName, a as hasAnyViewAnnotation, b as primitiveBaseType, d as viewJoins, f as viewScopeTypes, g as getParentStruct, h as getNavTargetTypeName, i as forEachFieldRef, l as validateQueryScope, m as getDbTableOwner, n as findFKFieldsPointingTo, o as isAliasDecl, p as getAnnotationAlias, r as findViewCycle, s as isDbSourceDecl, t as earlierJoinTargets, u as validateRefArgument, v as integerMemberIndexProblem, w as validateFieldBaseType, x as refActionAnnotation, y as isNullableUnion } from "./validation-utils-
|
|
4
|
+
import { C as validateExclusiveWith, S as searchFieldVerdict, T as validateSiblingStringField, _ as getParentTypeName, a as hasAnyViewAnnotation, b as primitiveBaseType, d as viewJoins, f as viewScopeTypes, g as getParentStruct, h as getNavTargetTypeName, i as forEachFieldRef, l as validateQueryScope, m as getDbTableOwner, n as findFKFieldsPointingTo, o as isAliasDecl, p as getAnnotationAlias, r as findViewCycle, s as isDbSourceDecl, t as earlierJoinTargets, u as validateRefArgument, v as integerMemberIndexProblem, w as validateFieldBaseType, x as refActionAnnotation, y as isNullableUnion } from "./validation-utils-BGjqc2jU.mjs";
|
|
5
5
|
import path from "node:path";
|
|
6
6
|
import { fileURLToPath } from "node:url";
|
|
7
7
|
import { AnnotationSpec, DEFAULT_FORMAT, getFieldsForType, isArray, isInterface, isPrimitive, isProp, isQueryComparison, isQueryLogical, isRef, isStructure } from "@atscript/core";
|
|
@@ -837,6 +837,21 @@ const dbColumnAnnotations = {
|
|
|
837
837
|
}
|
|
838
838
|
})
|
|
839
839
|
},
|
|
840
|
+
onUpdate: { now: new AnnotationSpec({
|
|
841
|
+
description: "Sets the field to the current time (epoch ms) on every update: patches (`updateOne`, `bulkUpdate`, `updateMany`, HTTP `PATCH`) and replaces (`replaceOne`, `bulkReplace`, `replaceMany`, HTTP `PUT`). The value is written by the SDK in the same statement on every adapter and overrides a value the payload carries. Inserts are not affected — combine with `@db.default.now` (`number.timestamp.updated` applies both). Writes outside the SDK (raw SQL) do not set it.\n\n**Example:**\n```atscript\n@db.default.now\n@db.onUpdate.now\nupdatedAt: number.timestamp\n```\n",
|
|
842
|
+
nodeType: ["prop"],
|
|
843
|
+
passedWhenReferred: false,
|
|
844
|
+
validate(token, args, doc) {
|
|
845
|
+
const errors = validateFieldBaseType(token, doc, "@db.onUpdate.now", "number");
|
|
846
|
+
const field = token.parentNode;
|
|
847
|
+
for (const [name, why] of [["meta.id", "the primary key identifies the row and is never updated"], ["db.column.version", "the version column is adapter-managed"]]) if (field.countAnnotations(name) > 0) errors.push({
|
|
848
|
+
message: `@db.onUpdate.now cannot coexist with @${name} — ${why}`,
|
|
849
|
+
severity: 1,
|
|
850
|
+
range: token.range
|
|
851
|
+
});
|
|
852
|
+
return errors;
|
|
853
|
+
}
|
|
854
|
+
}) },
|
|
840
855
|
json: new AnnotationSpec({
|
|
841
856
|
description: "Forces a field to be stored as a single JSON column instead of being flattened into separate columns. Use on nested object fields that should remain as JSON in the database.\n\n**Example:**\n```atscript\n@db.json\nmetadata: { key: string, value: string }\n```\n",
|
|
842
857
|
nodeType: ["prop"],
|
|
@@ -889,6 +904,7 @@ const dbColumnAnnotations = {
|
|
|
889
904
|
["db.column.version", "the OCC filter needs cleartext equality"],
|
|
890
905
|
["db.default.increment", "engine-side defaults bypass the encryption transform"],
|
|
891
906
|
["db.default.now", "engine-side defaults bypass the encryption transform"],
|
|
907
|
+
["db.onUpdate.now", "the update time is set after the encryption transform"],
|
|
892
908
|
["db.mongo.search.text", "Atlas Search over ciphertext is impossible"],
|
|
893
909
|
["db.mongo.search.autocomplete", "Atlas Search over ciphertext is impossible"]
|
|
894
910
|
]) if (field.countAnnotations(name) > 0) errors.push({
|
|
@@ -2283,6 +2299,7 @@ const dbPlugin = (options) => ({
|
|
|
2283
2299
|
index: dbIndexAnnotations.index,
|
|
2284
2300
|
column: dbColumnAnnotations.column,
|
|
2285
2301
|
default: dbColumnAnnotations.default,
|
|
2302
|
+
onUpdate: dbColumnAnnotations.onUpdate,
|
|
2286
2303
|
json: dbColumnAnnotations.json,
|
|
2287
2304
|
ignore: dbColumnAnnotations.ignore,
|
|
2288
2305
|
encrypted: dbColumnAnnotations.encrypted,
|
package/dist/rel.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Jn as TGenericLogger, Jt as TableMetadata, Rt as TTableResolver, Ut as TWriteTableResolver, W as TDbForeignKey, en as BaseDbAdapter, h as AtscriptDbWritable, m as AtscriptDbTableLike, nt as TDbRelation } from "./buckets-B4T_alUe.cjs";
|
|
2
2
|
import { t as DbValidationContext } from "./db-validator-plugin-BWy60OvG.cjs";
|
|
3
|
-
import { n as findRemoteFK, r as resolveRelationTargetTable, t as findFKForRelation } from "./relation-helpers-
|
|
3
|
+
import { n as findRemoteFK, r as resolveRelationTargetTable, t as findFKForRelation } from "./relation-helpers-BLBrLQYi.cjs";
|
|
4
4
|
import { FilterExpr, WithRelation } from "@uniqu/core";
|
|
5
5
|
import { Validator } from "@atscript/typescript/utils";
|
|
6
6
|
|
package/dist/rel.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Jn as TGenericLogger, Jt as TableMetadata, Rt as TTableResolver, Ut as TWriteTableResolver, W as TDbForeignKey, en as BaseDbAdapter, h as AtscriptDbWritable, m as AtscriptDbTableLike, nt as TDbRelation } from "./buckets-8mG67Mtw.mjs";
|
|
2
2
|
import { t as DbValidationContext } from "./db-validator-plugin-BWy60OvG.mjs";
|
|
3
|
-
import { n as findRemoteFK, r as resolveRelationTargetTable, t as findFKForRelation } from "./relation-helpers-
|
|
3
|
+
import { n as findRemoteFK, r as resolveRelationTargetTable, t as findFKForRelation } from "./relation-helpers-17_2f5hX.mjs";
|
|
4
4
|
import { Validator } from "@atscript/typescript/utils";
|
|
5
5
|
import { FilterExpr, WithRelation } from "@uniqu/core";
|
|
6
6
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { W as TDbForeignKey, nt as TDbRelation } from "./buckets-
|
|
1
|
+
import { W as TDbForeignKey, nt as TDbRelation } from "./buckets-8mG67Mtw.mjs";
|
|
2
2
|
import { TAtscriptAnnotatedType } from "@atscript/typescript/utils";
|
|
3
3
|
|
|
4
4
|
//#region src/rel/relation-helpers.d.ts
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { W as TDbForeignKey, nt as TDbRelation } from "./buckets-
|
|
1
|
+
import { W as TDbForeignKey, nt as TDbRelation } from "./buckets-B4T_alUe.cjs";
|
|
2
2
|
import { TAtscriptAnnotatedType } from "@atscript/typescript/utils";
|
|
3
3
|
|
|
4
4
|
//#region src/rel/relation-helpers.d.ts
|
|
@@ -29,6 +29,7 @@ const DERIVED_INCOMPATIBLE = [
|
|
|
29
29
|
["db.default.increment", "the value is computed, never defaulted"],
|
|
30
30
|
["db.default.uuid", "the value is computed, never defaulted"],
|
|
31
31
|
["db.default.now", "the value is computed, never defaulted"],
|
|
32
|
+
["db.onUpdate.now", "a derived column is never written"],
|
|
32
33
|
["db.column.version", "the version column is adapter-managed"],
|
|
33
34
|
["db.column.version.exempt", "a derived column is never written"],
|
|
34
35
|
["db.encrypted", "the value is a cleartext extraction of its source"],
|
|
@@ -29,6 +29,7 @@ const DERIVED_INCOMPATIBLE = [
|
|
|
29
29
|
["db.default.increment", "the value is computed, never defaulted"],
|
|
30
30
|
["db.default.uuid", "the value is computed, never defaulted"],
|
|
31
31
|
["db.default.now", "the value is computed, never defaulted"],
|
|
32
|
+
["db.onUpdate.now", "a derived column is never written"],
|
|
32
33
|
["db.column.version", "the version column is adapter-managed"],
|
|
33
34
|
["db.column.version.exempt", "a derived column is never written"],
|
|
34
35
|
["db.encrypted", "the value is a cleartext extraction of its source"],
|
package/dist/shared.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
const require_aggregate_rules = require("./aggregate-rules-D_bsCpUI.cjs");
|
|
3
|
-
const require_validation_utils = require("./validation-utils-
|
|
3
|
+
const require_validation_utils = require("./validation-utils-CtLNlBtB.cjs");
|
|
4
4
|
exports.NOT_DIMENSION_REASON = require_aggregate_rules.NOT_DIMENSION_REASON;
|
|
5
5
|
exports.earlierJoinTargets = require_validation_utils.earlierJoinTargets;
|
|
6
6
|
exports.findFKFieldsPointingTo = require_validation_utils.findFKFieldsPointingTo;
|
package/dist/shared.mjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { n as isStrictAggregateStruct, t as NOT_DIMENSION_REASON } from "./aggregate-rules-jdPrxqWa.mjs";
|
|
2
|
-
import { C as validateExclusiveWith, S as searchFieldVerdict, T as validateSiblingStringField, _ as getParentTypeName, a as hasAnyViewAnnotation, b as primitiveBaseType, c as joinTargets, d as viewJoins, f as viewScopeTypes, g as getParentStruct, h as getNavTargetTypeName, i as forEachFieldRef, l as validateQueryScope, m as getDbTableOwner, n as findFKFieldsPointingTo, o as isAliasDecl, p as getAnnotationAlias, r as findViewCycle, s as isDbSourceDecl, t as earlierJoinTargets, u as validateRefArgument, v as integerMemberIndexProblem, w as validateFieldBaseType, x as refActionAnnotation, y as isNullableUnion } from "./validation-utils-
|
|
2
|
+
import { C as validateExclusiveWith, S as searchFieldVerdict, T as validateSiblingStringField, _ as getParentTypeName, a as hasAnyViewAnnotation, b as primitiveBaseType, c as joinTargets, d as viewJoins, f as viewScopeTypes, g as getParentStruct, h as getNavTargetTypeName, i as forEachFieldRef, l as validateQueryScope, m as getDbTableOwner, n as findFKFieldsPointingTo, o as isAliasDecl, p as getAnnotationAlias, r as findViewCycle, s as isDbSourceDecl, t as earlierJoinTargets, u as validateRefArgument, v as integerMemberIndexProblem, w as validateFieldBaseType, x as refActionAnnotation, y as isNullableUnion } from "./validation-utils-BGjqc2jU.mjs";
|
|
3
3
|
export { NOT_DIMENSION_REASON, earlierJoinTargets, findFKFieldsPointingTo, findViewCycle, forEachFieldRef, getAnnotationAlias, getDbTableOwner, getNavTargetTypeName, getParentStruct, getParentTypeName, hasAnyViewAnnotation, integerMemberIndexProblem, isAliasDecl, isDbSourceDecl, isNullableUnion, isStrictAggregateStruct, joinTargets, primitiveBaseType, refActionAnnotation, searchFieldVerdict, validateExclusiveWith, validateFieldBaseType, validateQueryScope, validateRefArgument, validateSiblingStringField, viewJoins, viewScopeTypes };
|