@atscript/db 0.1.140 → 0.1.142
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-C-27xmtq.d.cts → buckets-Bv4pah66.d.cts} +225 -22
- package/dist/{buckets-BFG2RYRW.d.mts → buckets-CjL7F-hp.d.mts} +225 -22
- package/dist/{column-diff-CgxgFKzx.cjs → column-diff-CfPNcP6e.cjs} +663 -239
- package/dist/{column-diff-BwOA5101.mjs → column-diff-CmFNXV8C.mjs} +638 -220
- package/dist/column-diff-DiBbXyLA.d.cts +211 -0
- package/dist/column-diff-n-k5KY0u.d.mts +211 -0
- package/dist/derived-rules-0sKn4f5C.mjs +44 -0
- package/dist/derived-rules-YstgIxG-.cjs +67 -0
- package/dist/index.cjs +38 -4
- package/dist/index.d.cts +23 -6
- package/dist/index.d.mts +23 -6
- package/dist/index.mjs +34 -4
- package/dist/{nested-writer-FWD5oOYh.mjs → nested-writer-BO3vhbkP.mjs} +8 -4
- package/dist/{nested-writer-BZNCuqI6.cjs → nested-writer-DYsRxZ5f.cjs} +8 -4
- package/dist/object-DSN0h9lB.d.cts +30 -0
- package/dist/object-DSN0h9lB.d.mts +30 -0
- package/dist/plugin.cjs +392 -139
- package/dist/plugin.mjs +392 -139
- package/dist/rel.cjs +2 -2
- package/dist/rel.d.cts +2 -2
- package/dist/rel.d.mts +2 -2
- package/dist/rel.mjs +2 -2
- package/dist/{relation-helpers-D3Zu0Mta.d.mts → relation-helpers-B59to_dG.d.mts} +5 -4
- package/dist/{relation-helpers-DxrvS6ar.d.cts → relation-helpers-DQ_nRsV9.d.cts} +5 -4
- package/dist/{relation-loader-6ZB_5KFq.cjs → relation-loader-CgJ8bK6X.cjs} +1 -1
- package/dist/{relation-loader-CTFaZpVa.mjs → relation-loader-CuhEBzFU.mjs} +1 -1
- package/dist/shared.cjs +6 -1
- package/dist/shared.d.cts +48 -9
- package/dist/shared.d.mts +48 -9
- package/dist/shared.mjs +2 -2
- package/dist/sync.cjs +331 -105
- package/dist/sync.d.cts +62 -163
- package/dist/sync.d.mts +62 -163
- package/dist/sync.mjs +331 -105
- package/dist/{validation-utils-B4h-GW4d.mjs → validation-utils-CMR4fe2M.mjs} +99 -34
- package/dist/{validation-utils-Dg0hW6dn.cjs → validation-utils-DOsB4e6G.cjs} +128 -33
- package/dist/{validator-Drb2N-YL.d.cts → validator-Bw6ks9Hy.d.cts} +1 -11
- package/dist/{validator-Drb2N-YL.d.mts → validator-Bw6ks9Hy.d.mts} +1 -11
- package/dist/{validator-Ch7UIQl9.mjs → validator-D8bPsXPN.mjs} +54 -2
- package/dist/{validator-BtZbcLN2.cjs → validator-DASnXf1j.cjs} +77 -1
- package/dist/validator.cjs +1 -1
- package/dist/validator.d.cts +2 -1
- package/dist/validator.d.mts +2 -1
- package/dist/validator.mjs +1 -1
- package/package.json +6 -6
- package/dist/column-diff-BmqvgBWw.d.cts +0 -24
- package/dist/column-diff-DPkbZIVE.d.mts +0 -24
package/dist/index.d.cts
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
|
-
import { $ as TDbWriteGuard, $t as
|
|
1
|
+
import { $ as TDbWriteGuard, $t as IntegrityStrategy, A as TDbActionInfo, At as UniqueryControls, B as TDbIndex, Bt as AtscriptDbView, C as OwnPropsOf, Ct as TTouchManyOptions, D as TColumnDiff, Dt as TWriteTableResolver, E as TCascadeTarget, Et as TWriteOptions, F as TDbDefaultFn, Ft as ALL_BUCKET_UNITS, G as TDbObjectKind, Gt as AtscriptQueryFieldRef, H as TDbIndexType, Ht as isAtscriptDbView, I as TDbDefaultValue, It as BaseDbAdapter, J as TDbRemoveGuard, Jt as TViewJoin, K as TDbReferentialAction, Kt as AtscriptQueryNode, L as TDbDeleteResult, Lt as DbSpace, M as TDbActionLevel, Mt as TableMetadata, N as TDbActionProcessor, Nt as isGeoIndexableType, O as TCrudOp, Ot as TypedWithRelation, P as TDbCollation, Pt as isGeoPointType, Q as TDbWriteAction, Qt as AtscriptDbTable, R as TDbFieldMeta, Rt as TAdapterFactory, S as NullableOptional, St as TTableResolver, T as TCascadeResolver, Tt as TViewJsonType, U as TDbInsertManyResult, Ut as aliasTargetOf, V as TDbIndexField, Vt as TViewColumnMapping, W as TDbInsertResult, Wt as AtscriptQueryComparison, X as TDbStorageType, Xt as isFieldRef, Y as TDbRemoveGuardContext, Yt as TViewPlan, Z as TDbUpdateResult, Zt as translateQueryTree, _ as DbRow, _t as TReferencingForeignKey, a as jsonValueAncestor, an as TDbEncryptionOptions, at as TExistingColumn, b as FlatOf, bt as TSyncColumnResult, c as AggregateControls, cn as TReadControls, ct as TFieldMeta, d as AggregateQuery, dn as UniquSelect, dt as TIdDescriptor, en as NativeIntegrity, et as TDbWriteGuardContext, f as AggregateResult, ft as TIdResolveOptions, g as DbQuery, gt as TPrimaryKeyChange, h as DbPatch, ht as TMetadataOverrides, i as isJsonValueField, in as DbEncryption, it as TEnsureTableOptions, j as TDbActionIntent, jt as WithRelation, k as TCrudPermissions, kt as Uniquery, l as AggregateExpr, ln as NoopLogger, lt as TFkLookupResolver, m as DbControls, mt as TMetaResponse, n as TResolvedBucket, nn as DbResponse, nt as TDerivedChangeReason, o as normalizeComputedSelect, on as DocumentFieldMapper, ot as TExistingForeignKey, p as AtscriptDbWritable, pt as TIdentification, q as TDbRelation, qt as AtscriptRef, r as isBucketableField, rn as resolveDesignType, rt as TDerivedColumn, s as resolveCalendarBuckets, sn as FieldMappingStrategy, st as TExistingTableOption, t as TBucketFieldSource, tn as AtscriptDbReadable, tt as TDeleteOptions, u as AggregateFn, un as TGenericLogger, ut as TFkLookupTarget, v as FieldOpsFor, vt as TRelationInfo, w as PrimaryKeyOf, wt as TValueFormatterPair, x as NavPropsOf, xt as TTableOptionDiff, y as FilterExpr, yt as TSearchIndexInfo, z as TDbForeignKey, zt as TDbSpaceOptions } from "./buckets-Bv4pah66.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
|
+
import { a as isPlainObject, i as isEmptyObject, n as findAncestorInSet, r as getPath, t as deletePath } from "./object-DSN0h9lB.cjs";
|
|
3
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-CV7y8nC6.cjs";
|
|
4
|
-
import {
|
|
5
|
+
import { a as buildValidationContext, c as isNavRelation, d as getKeyProps, f as CasExhaustedError, g as bucketTimeZoneUnavailable, 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 } from "./validator-Bw6ks9Hy.cjs";
|
|
5
6
|
import { n as createDbValidatorPlugin, t as DbValidationContext } from "./db-validator-plugin-BWy60OvG.cjs";
|
|
6
|
-
import { n as isColumnTypeChanged } from "./column-diff-
|
|
7
|
-
import { i as tableNameOf } from "./relation-helpers-
|
|
7
|
+
import { n as isColumnTypeChanged } from "./column-diff-DiBbXyLA.cjs";
|
|
8
|
+
import { i as tableNameOf } from "./relation-helpers-DQ_nRsV9.cjs";
|
|
8
9
|
import { AggregateQuery as AggregateQuery$1, FilterExpr as FilterExpr$1, FilterVisitor, ResolvedBucket as ResolvedBucket$1, Uniquery as Uniquery$1, computeInsights, isPrimitive, walkFilter } from "@uniqu/core";
|
|
10
|
+
import { TAtscriptAnnotatedType } from "@atscript/typescript/utils";
|
|
9
11
|
|
|
10
12
|
//#region src/shared/consts.d.ts
|
|
11
13
|
/**
|
|
@@ -23,7 +25,7 @@ declare const DEFAULT_DB_SPACE = "default";
|
|
|
23
25
|
* for queries, filters, and controls.
|
|
24
26
|
*/
|
|
25
27
|
declare class RelationalFieldMapper extends FieldMappingStrategy {
|
|
26
|
-
reconstructFromRead(row: Record<string, unknown>, meta: TableMetadata): Record<string, unknown>;
|
|
28
|
+
reconstructFromRead(row: Record<string, unknown>, meta: TableMetadata, _controls?: TReadControls): Record<string, unknown>;
|
|
27
29
|
translateQuery(query: Uniquery$1, meta: TableMetadata): DbQuery;
|
|
28
30
|
/** The flattened column of a logical path (`contact.email` → `contact__email`). */
|
|
29
31
|
protected physicalPath(logical: string, meta: TableMetadata): string;
|
|
@@ -475,6 +477,21 @@ declare function decomposePatch(payload: Record<string, unknown>, table: Atscrip
|
|
|
475
477
|
*/
|
|
476
478
|
declare function assertNoVersionWrites(data: Record<string, unknown>, versionColumn: string): void;
|
|
477
479
|
//#endregion
|
|
480
|
+
//#region src/table/db-entity.d.ts
|
|
481
|
+
/**
|
|
482
|
+
* Whether `value` is a compiled type a `DbSpace` accepts: an annotated type
|
|
483
|
+
* whose own declaration carries `@db.table`, `@db.view` or `@db.view.for`.
|
|
484
|
+
* A `@db.alias` type is not one, and neither is a plain `export type X = Table`
|
|
485
|
+
* or a field typed with a table (`customer: Customer`) — since 0.1.141 the
|
|
486
|
+
* entity annotations stay on the declaring interface instead of travelling
|
|
487
|
+
* with every reference.
|
|
488
|
+
*
|
|
489
|
+
* Filters a module namespace before a sync:
|
|
490
|
+
* `syncSchema(db, Object.values(models).filter(isDbEntityType))`.
|
|
491
|
+
* @since 0.1.141
|
|
492
|
+
*/
|
|
493
|
+
declare function isDbEntityType(value: unknown): value is TAtscriptAnnotatedType;
|
|
494
|
+
//#endregion
|
|
478
495
|
//#region src/shared/failure-collector.d.ts
|
|
479
496
|
/**
|
|
480
497
|
* Collects failures from a batch of independent operations so one failing
|
|
@@ -489,4 +506,4 @@ declare function createFailureCollector(what: string): {
|
|
|
489
506
|
throwIfAny: () => void;
|
|
490
507
|
};
|
|
491
508
|
//#endregion
|
|
492
|
-
export { $cas, $dec, $inc, $insert, $mul, $remove, $replace, $update, $upsert, ADAPTER_FILTER_REASON, ALL_AGGREGATE_FNS, ALL_BUCKET_UNITS, type AggregateControls, type AggregateExpr, type AggregateFn, type AggregateQuery, type AggregateResult, ApplicationIntegrity, AtscriptDbReadable, AtscriptDbTable, AtscriptDbView, type AtscriptDbWritable, type AtscriptQueryComparison, type AtscriptQueryFieldRef, type AtscriptQueryNode, type AtscriptRef, BaseDbAdapter, type 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, IntegrityStrategy, NativeIntegrity, type NavPropsOf, NoopLogger, type NullableOptional, type OwnPropsOf, type PrimaryKeyOf, RelationalFieldMapper, type ResolvedBucket, 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 TDbCas, type TDbCollation, type TDbDefaultFn, type TDbDefaultValue, type TDbDeleteResult, type TDbEncryptionOptions, type TDbFieldMeta, type TDbFieldOp, type TDbForeignKey, type TDbIndex, type TDbIndexField, type TDbIndexType, type TDbInsertManyResult, type TDbInsertResult, type TDbObjectKind, type TDbPatch, type TDbReferentialAction, type TDbRelation, type TDbRemoveGuard, type TDbRemoveGuardContext, type TDbSpaceOptions, type TDbStorageType, type TDbUpdateResult, type TDbWriteAction, type TDbWriteGuard, type TDbWriteGuardContext, type TDeleteOptions, type TEnsureTableOptions, type TExistingColumn, type TExistingForeignKey, type TExistingTableOption, type TFieldMeta, type TFieldOps, type TFilterPredicate, type TFilterRef, type TFkLookupResolver, type TFkLookupTarget, type TGenericLogger, type TGuardedQuery, type TIdDescriptor, type TIdResolveOptions, type TIdentification, type TMetaResponse, type TMetadataOverrides, type TPrimaryKeyChange, type TQueryPathKind, type TQueryPathOp, type TQueryPathRefs, type TQueryPathSource, type TReferencingForeignKey, type TRelationInfo, type TResolvedBucket, type TSearchIndexInfo, type TSyncColumnResult, type TTableOptionDiff, type TTableResolver, type TTouchManyOptions, type TValueFormatterPair, type TViewColumnMapping, type TViewJoin, type TViewJsonType, type TViewPlan, type TWriteOptions, type TWriteTableResolver, TableMetadata, type TypedWithRelation, UniquSelect, type Uniquery, type UniqueryControls, type ValidationContext, type ValidatorMode, type WeekStart, type WithOptimisticRetryOptions, type WithRelation, acceptedOperatorsHint, assertGeoPoint, assertNoVersionWrites, bucketSourceVerdict, bucketTimeZoneUnavailable, buildDbValidator, buildValidationContext, canFilterLeaf, checkHavingKeys, classifyQueryPath, collectQueryPaths, computeInsights, createDbValidatorPlugin, createFailureCollector, decomposePatch, findAncestorInSet, forceNavNonOptional, getDbFieldOp, getKeyProps, guardAggregate, guardFilter, guardPath, guardPaths, guardQuery, isAtscriptDbView, isBucketableField, isColumnTypeChanged, isDbFieldOp, isEmptyObject, isFieldRef, isGeoIndexableType, isGeoPointType, isJsonValueField, isNavRelation, isPlainObject, isPrimitive, jsonValueAncestor, narrowerFilterOps, normalizeComputedSelect, reconcileCas, resolveCalendarBuckets, resolveDesignType, separateCas, separateFieldOps, sortFieldNames, tableNameOf, translateQueryTree, unsupportedOperatorMessage, walkFilter, withOptimisticRetry };
|
|
509
|
+
export { $cas, $dec, $inc, $insert, $mul, $remove, $replace, $update, $upsert, ADAPTER_FILTER_REASON, ALL_AGGREGATE_FNS, ALL_BUCKET_UNITS, type AggregateControls, type AggregateExpr, type AggregateFn, type AggregateQuery, type AggregateResult, ApplicationIntegrity, AtscriptDbReadable, AtscriptDbTable, AtscriptDbView, type AtscriptDbWritable, type AtscriptQueryComparison, type AtscriptQueryFieldRef, type AtscriptQueryNode, type AtscriptRef, BaseDbAdapter, type 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, IntegrityStrategy, NativeIntegrity, type NavPropsOf, NoopLogger, type NullableOptional, type OwnPropsOf, type PrimaryKeyOf, RelationalFieldMapper, type ResolvedBucket, 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 TDbCas, type TDbCollation, type TDbDefaultFn, type TDbDefaultValue, type TDbDeleteResult, type TDbEncryptionOptions, type TDbFieldMeta, type TDbFieldOp, type TDbForeignKey, type TDbIndex, type TDbIndexField, type TDbIndexType, type TDbInsertManyResult, type TDbInsertResult, type TDbObjectKind, type TDbPatch, type TDbReferentialAction, type TDbRelation, type TDbRemoveGuard, type TDbRemoveGuardContext, type TDbSpaceOptions, type TDbStorageType, type TDbUpdateResult, type TDbWriteAction, type TDbWriteGuard, type TDbWriteGuardContext, type TDeleteOptions, type TDerivedChangeReason, type TDerivedColumn, type TEnsureTableOptions, type TExistingColumn, type TExistingForeignKey, type TExistingTableOption, type TFieldMeta, type TFieldOps, type TFilterPredicate, type TFilterRef, type TFkLookupResolver, type TFkLookupTarget, type TGenericLogger, type TGuardedQuery, type TIdDescriptor, type TIdResolveOptions, type TIdentification, type TMetaResponse, type TMetadataOverrides, type TPrimaryKeyChange, type TQueryPathKind, type TQueryPathOp, type TQueryPathRefs, type TQueryPathSource, type TReadControls, type TReferencingForeignKey, type TRelationInfo, type TResolvedBucket, type TSearchIndexInfo, type TSyncColumnResult, type TTableOptionDiff, type TTableResolver, type TTouchManyOptions, type TValueFormatterPair, type TViewColumnMapping, type TViewJoin, type TViewJsonType, type TViewPlan, type TWriteOptions, type TWriteTableResolver, TableMetadata, type TypedWithRelation, UniquSelect, type Uniquery, type UniqueryControls, type ValidationContext, type ValidatorMode, type WeekStart, type WithOptimisticRetryOptions, type WithRelation, acceptedOperatorsHint, aliasTargetOf, assertGeoPoint, assertNoVersionWrites, bucketSourceVerdict, bucketTimeZoneUnavailable, buildDbValidator, buildValidationContext, canFilterLeaf, checkHavingKeys, classifyQueryPath, collectQueryPaths, computeInsights, createDbValidatorPlugin, createFailureCollector, decomposePatch, deletePath, findAncestorInSet, forceNavNonOptional, getDbFieldOp, getKeyProps, getPath, guardAggregate, guardFilter, guardPath, guardPaths, guardQuery, isAtscriptDbView, isBucketableField, isColumnTypeChanged, isDbEntityType, isDbFieldOp, isEmptyObject, isFieldRef, isGeoIndexableType, isGeoPointType, isJsonValueField, isNavRelation, isPlainObject, isPrimitive, jsonValueAncestor, narrowerFilterOps, normalizeComputedSelect, reconcileCas, resolveCalendarBuckets, resolveDesignType, separateCas, separateFieldOps, sortFieldNames, tableNameOf, translateQueryTree, unsupportedOperatorMessage, walkFilter, withOptimisticRetry };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
import { $ as TDbWriteGuard, $t as
|
|
1
|
+
import { $ as TDbWriteGuard, $t as IntegrityStrategy, A as TDbActionInfo, At as UniqueryControls, B as TDbIndex, Bt as AtscriptDbView, C as OwnPropsOf, Ct as TTouchManyOptions, D as TColumnDiff, Dt as TWriteTableResolver, E as TCascadeTarget, Et as TWriteOptions, F as TDbDefaultFn, Ft as ALL_BUCKET_UNITS, G as TDbObjectKind, Gt as AtscriptQueryFieldRef, H as TDbIndexType, Ht as isAtscriptDbView, I as TDbDefaultValue, It as BaseDbAdapter, J as TDbRemoveGuard, Jt as TViewJoin, K as TDbReferentialAction, Kt as AtscriptQueryNode, L as TDbDeleteResult, Lt as DbSpace, M as TDbActionLevel, Mt as TableMetadata, N as TDbActionProcessor, Nt as isGeoIndexableType, O as TCrudOp, Ot as TypedWithRelation, P as TDbCollation, Pt as isGeoPointType, Q as TDbWriteAction, Qt as AtscriptDbTable, R as TDbFieldMeta, Rt as TAdapterFactory, S as NullableOptional, St as TTableResolver, T as TCascadeResolver, Tt as TViewJsonType, U as TDbInsertManyResult, Ut as aliasTargetOf, V as TDbIndexField, Vt as TViewColumnMapping, W as TDbInsertResult, Wt as AtscriptQueryComparison, X as TDbStorageType, Xt as isFieldRef, Y as TDbRemoveGuardContext, Yt as TViewPlan, Z as TDbUpdateResult, Zt as translateQueryTree, _ as DbRow, _t as TReferencingForeignKey, a as jsonValueAncestor, an as TDbEncryptionOptions, at as TExistingColumn, b as FlatOf, bt as TSyncColumnResult, c as AggregateControls, cn as TReadControls, ct as TFieldMeta, d as AggregateQuery, dn as UniquSelect, dt as TIdDescriptor, en as NativeIntegrity, et as TDbWriteGuardContext, f as AggregateResult, ft as TIdResolveOptions, g as DbQuery, gt as TPrimaryKeyChange, h as DbPatch, ht as TMetadataOverrides, i as isJsonValueField, in as DbEncryption, it as TEnsureTableOptions, j as TDbActionIntent, jt as WithRelation, k as TCrudPermissions, kt as Uniquery, l as AggregateExpr, ln as NoopLogger, lt as TFkLookupResolver, m as DbControls, mt as TMetaResponse, n as TResolvedBucket, nn as DbResponse, nt as TDerivedChangeReason, o as normalizeComputedSelect, on as DocumentFieldMapper, ot as TExistingForeignKey, p as AtscriptDbWritable, pt as TIdentification, q as TDbRelation, qt as AtscriptRef, r as isBucketableField, rn as resolveDesignType, rt as TDerivedColumn, s as resolveCalendarBuckets, sn as FieldMappingStrategy, st as TExistingTableOption, t as TBucketFieldSource, tn as AtscriptDbReadable, tt as TDeleteOptions, u as AggregateFn, un as TGenericLogger, ut as TFkLookupTarget, v as FieldOpsFor, vt as TRelationInfo, w as PrimaryKeyOf, wt as TValueFormatterPair, x as NavPropsOf, xt as TTableOptionDiff, y as FilterExpr, yt as TSearchIndexInfo, z as TDbForeignKey, zt as TDbSpaceOptions } from "./buckets-CjL7F-hp.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
|
+
import { a as isPlainObject, i as isEmptyObject, n as findAncestorInSet, r as getPath, t as deletePath } from "./object-DSN0h9lB.mjs";
|
|
3
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-D5DHsAby.mjs";
|
|
4
|
-
import {
|
|
5
|
+
import { a as buildValidationContext, c as isNavRelation, d as getKeyProps, f as CasExhaustedError, g as bucketTimeZoneUnavailable, 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 } from "./validator-Bw6ks9Hy.mjs";
|
|
5
6
|
import { n as createDbValidatorPlugin, t as DbValidationContext } from "./db-validator-plugin-BWy60OvG.mjs";
|
|
6
|
-
import { n as isColumnTypeChanged } from "./column-diff-
|
|
7
|
-
import { i as tableNameOf } from "./relation-helpers-
|
|
7
|
+
import { n as isColumnTypeChanged } from "./column-diff-n-k5KY0u.mjs";
|
|
8
|
+
import { i as tableNameOf } from "./relation-helpers-B59to_dG.mjs";
|
|
9
|
+
import { TAtscriptAnnotatedType } from "@atscript/typescript/utils";
|
|
8
10
|
import { AggregateQuery as AggregateQuery$1, FilterExpr as FilterExpr$1, FilterVisitor, ResolvedBucket as ResolvedBucket$1, Uniquery as Uniquery$1, computeInsights, isPrimitive, walkFilter } from "@uniqu/core";
|
|
9
11
|
|
|
10
12
|
//#region src/shared/consts.d.ts
|
|
@@ -23,7 +25,7 @@ declare const DEFAULT_DB_SPACE = "default";
|
|
|
23
25
|
* for queries, filters, and controls.
|
|
24
26
|
*/
|
|
25
27
|
declare class RelationalFieldMapper extends FieldMappingStrategy {
|
|
26
|
-
reconstructFromRead(row: Record<string, unknown>, meta: TableMetadata): Record<string, unknown>;
|
|
28
|
+
reconstructFromRead(row: Record<string, unknown>, meta: TableMetadata, _controls?: TReadControls): Record<string, unknown>;
|
|
27
29
|
translateQuery(query: Uniquery$1, meta: TableMetadata): DbQuery;
|
|
28
30
|
/** The flattened column of a logical path (`contact.email` → `contact__email`). */
|
|
29
31
|
protected physicalPath(logical: string, meta: TableMetadata): string;
|
|
@@ -475,6 +477,21 @@ declare function decomposePatch(payload: Record<string, unknown>, table: Atscrip
|
|
|
475
477
|
*/
|
|
476
478
|
declare function assertNoVersionWrites(data: Record<string, unknown>, versionColumn: string): void;
|
|
477
479
|
//#endregion
|
|
480
|
+
//#region src/table/db-entity.d.ts
|
|
481
|
+
/**
|
|
482
|
+
* Whether `value` is a compiled type a `DbSpace` accepts: an annotated type
|
|
483
|
+
* whose own declaration carries `@db.table`, `@db.view` or `@db.view.for`.
|
|
484
|
+
* A `@db.alias` type is not one, and neither is a plain `export type X = Table`
|
|
485
|
+
* or a field typed with a table (`customer: Customer`) — since 0.1.141 the
|
|
486
|
+
* entity annotations stay on the declaring interface instead of travelling
|
|
487
|
+
* with every reference.
|
|
488
|
+
*
|
|
489
|
+
* Filters a module namespace before a sync:
|
|
490
|
+
* `syncSchema(db, Object.values(models).filter(isDbEntityType))`.
|
|
491
|
+
* @since 0.1.141
|
|
492
|
+
*/
|
|
493
|
+
declare function isDbEntityType(value: unknown): value is TAtscriptAnnotatedType;
|
|
494
|
+
//#endregion
|
|
478
495
|
//#region src/shared/failure-collector.d.ts
|
|
479
496
|
/**
|
|
480
497
|
* Collects failures from a batch of independent operations so one failing
|
|
@@ -489,4 +506,4 @@ declare function createFailureCollector(what: string): {
|
|
|
489
506
|
throwIfAny: () => void;
|
|
490
507
|
};
|
|
491
508
|
//#endregion
|
|
492
|
-
export { $cas, $dec, $inc, $insert, $mul, $remove, $replace, $update, $upsert, ADAPTER_FILTER_REASON, ALL_AGGREGATE_FNS, ALL_BUCKET_UNITS, type AggregateControls, type AggregateExpr, type AggregateFn, type AggregateQuery, type AggregateResult, ApplicationIntegrity, AtscriptDbReadable, AtscriptDbTable, AtscriptDbView, type AtscriptDbWritable, type AtscriptQueryComparison, type AtscriptQueryFieldRef, type AtscriptQueryNode, type AtscriptRef, BaseDbAdapter, type 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, IntegrityStrategy, NativeIntegrity, type NavPropsOf, NoopLogger, type NullableOptional, type OwnPropsOf, type PrimaryKeyOf, RelationalFieldMapper, type ResolvedBucket, 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 TDbCas, type TDbCollation, type TDbDefaultFn, type TDbDefaultValue, type TDbDeleteResult, type TDbEncryptionOptions, type TDbFieldMeta, type TDbFieldOp, type TDbForeignKey, type TDbIndex, type TDbIndexField, type TDbIndexType, type TDbInsertManyResult, type TDbInsertResult, type TDbObjectKind, type TDbPatch, type TDbReferentialAction, type TDbRelation, type TDbRemoveGuard, type TDbRemoveGuardContext, type TDbSpaceOptions, type TDbStorageType, type TDbUpdateResult, type TDbWriteAction, type TDbWriteGuard, type TDbWriteGuardContext, type TDeleteOptions, type TEnsureTableOptions, type TExistingColumn, type TExistingForeignKey, type TExistingTableOption, type TFieldMeta, type TFieldOps, type TFilterPredicate, type TFilterRef, type TFkLookupResolver, type TFkLookupTarget, type TGenericLogger, type TGuardedQuery, type TIdDescriptor, type TIdResolveOptions, type TIdentification, type TMetaResponse, type TMetadataOverrides, type TPrimaryKeyChange, type TQueryPathKind, type TQueryPathOp, type TQueryPathRefs, type TQueryPathSource, type TReferencingForeignKey, type TRelationInfo, type TResolvedBucket, type TSearchIndexInfo, type TSyncColumnResult, type TTableOptionDiff, type TTableResolver, type TTouchManyOptions, type TValueFormatterPair, type TViewColumnMapping, type TViewJoin, type TViewJsonType, type TViewPlan, type TWriteOptions, type TWriteTableResolver, TableMetadata, type TypedWithRelation, UniquSelect, type Uniquery, type UniqueryControls, type ValidationContext, type ValidatorMode, type WeekStart, type WithOptimisticRetryOptions, type WithRelation, acceptedOperatorsHint, assertGeoPoint, assertNoVersionWrites, bucketSourceVerdict, bucketTimeZoneUnavailable, buildDbValidator, buildValidationContext, canFilterLeaf, checkHavingKeys, classifyQueryPath, collectQueryPaths, computeInsights, createDbValidatorPlugin, createFailureCollector, decomposePatch, findAncestorInSet, forceNavNonOptional, getDbFieldOp, getKeyProps, guardAggregate, guardFilter, guardPath, guardPaths, guardQuery, isAtscriptDbView, isBucketableField, isColumnTypeChanged, isDbFieldOp, isEmptyObject, isFieldRef, isGeoIndexableType, isGeoPointType, isJsonValueField, isNavRelation, isPlainObject, isPrimitive, jsonValueAncestor, narrowerFilterOps, normalizeComputedSelect, reconcileCas, resolveCalendarBuckets, resolveDesignType, separateCas, separateFieldOps, sortFieldNames, tableNameOf, translateQueryTree, unsupportedOperatorMessage, walkFilter, withOptimisticRetry };
|
|
509
|
+
export { $cas, $dec, $inc, $insert, $mul, $remove, $replace, $update, $upsert, ADAPTER_FILTER_REASON, ALL_AGGREGATE_FNS, ALL_BUCKET_UNITS, type AggregateControls, type AggregateExpr, type AggregateFn, type AggregateQuery, type AggregateResult, ApplicationIntegrity, AtscriptDbReadable, AtscriptDbTable, AtscriptDbView, type AtscriptDbWritable, type AtscriptQueryComparison, type AtscriptQueryFieldRef, type AtscriptQueryNode, type AtscriptRef, BaseDbAdapter, type 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, IntegrityStrategy, NativeIntegrity, type NavPropsOf, NoopLogger, type NullableOptional, type OwnPropsOf, type PrimaryKeyOf, RelationalFieldMapper, type ResolvedBucket, 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 TDbCas, type TDbCollation, type TDbDefaultFn, type TDbDefaultValue, type TDbDeleteResult, type TDbEncryptionOptions, type TDbFieldMeta, type TDbFieldOp, type TDbForeignKey, type TDbIndex, type TDbIndexField, type TDbIndexType, type TDbInsertManyResult, type TDbInsertResult, type TDbObjectKind, type TDbPatch, type TDbReferentialAction, type TDbRelation, type TDbRemoveGuard, type TDbRemoveGuardContext, type TDbSpaceOptions, type TDbStorageType, type TDbUpdateResult, type TDbWriteAction, type TDbWriteGuard, type TDbWriteGuardContext, type TDeleteOptions, type TDerivedChangeReason, type TDerivedColumn, type TEnsureTableOptions, type TExistingColumn, type TExistingForeignKey, type TExistingTableOption, type TFieldMeta, type TFieldOps, type TFilterPredicate, type TFilterRef, type TFkLookupResolver, type TFkLookupTarget, type TGenericLogger, type TGuardedQuery, type TIdDescriptor, type TIdResolveOptions, type TIdentification, type TMetaResponse, type TMetadataOverrides, type TPrimaryKeyChange, type TQueryPathKind, type TQueryPathOp, type TQueryPathRefs, type TQueryPathSource, type TReadControls, type TReferencingForeignKey, type TRelationInfo, type TResolvedBucket, type TSearchIndexInfo, type TSyncColumnResult, type TTableOptionDiff, type TTableResolver, type TTouchManyOptions, type TValueFormatterPair, type TViewColumnMapping, type TViewJoin, type TViewJsonType, type TViewPlan, type TWriteOptions, type TWriteTableResolver, TableMetadata, type TypedWithRelation, UniquSelect, type Uniquery, type UniqueryControls, type ValidationContext, type ValidatorMode, type WeekStart, type WithOptimisticRetryOptions, type WithRelation, acceptedOperatorsHint, aliasTargetOf, assertGeoPoint, assertNoVersionWrites, bucketSourceVerdict, bucketTimeZoneUnavailable, buildDbValidator, buildValidationContext, canFilterLeaf, checkHavingKeys, classifyQueryPath, collectQueryPaths, computeInsights, createDbValidatorPlugin, createFailureCollector, decomposePatch, deletePath, findAncestorInSet, forceNavNonOptional, getDbFieldOp, getKeyProps, getPath, guardAggregate, guardFilter, guardPath, guardPaths, guardQuery, isAtscriptDbView, isBucketableField, isColumnTypeChanged, isDbEntityType, isDbFieldOp, isEmptyObject, isFieldRef, isGeoIndexableType, isGeoPointType, isJsonValueField, isNavRelation, isPlainObject, isPrimitive, jsonValueAncestor, narrowerFilterOps, normalizeComputedSelect, reconcileCas, resolveCalendarBuckets, resolveDesignType, separateCas, separateFieldOps, sortFieldNames, tableNameOf, translateQueryTree, unsupportedOperatorMessage, walkFilter, withOptimisticRetry };
|
package/dist/index.mjs
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { a as bucketTimeZoneUnavailable, n as CasMismatchError, r as DbError, t as CasExhaustedError } from "./db-error-D5uilS_A.mjs";
|
|
2
|
-
import { $ as
|
|
2
|
+
import { $ as isJsonValueField, A as assertGeoPoint, B as guardQuery, C as IntegrityStrategy, D as ADAPTER_FILTER_REASON, E as resolveDesignType, F as collectQueryPaths, G as DocumentFieldMapper, H as sortFieldNames, I as guardAggregate, J as TableMetadata, K as FieldMappingStrategy, L as guardFilter, M as canFilterLeaf, N as checkHavingKeys, O as ENCRYPTED_REASON, P as classifyQueryPath, Q as isBucketableField, R as guardPath, S as createFailureCollector, T as AtscriptDbReadable, U as unsupportedOperatorMessage, V as narrowerFilterOps, W as RelationalFieldMapper, X as isGeoPointType, Y as isGeoIndexableType, Z as aliasTargetOf, _ as assertNoVersionWrites, b as ALL_BUCKET_UNITS, et as jsonValueAncestor, g as AtscriptDbTable, h as isAtscriptDbView, j as bucketSourceVerdict, k as acceptedOperatorsHint, m as AtscriptDbView, n as isColumnTypeChanged, nt as resolveCalendarBuckets, q as UniquSelect, rt as NoopLogger, tt as normalizeComputedSelect, v as decomposePatch, w as NativeIntegrity, x as BaseDbAdapter, y as ApplicationIntegrity, z as guardPaths } from "./column-diff-CmFNXV8C.mjs";
|
|
3
3
|
import { t as ALL_AGGREGATE_FNS } from "./aggregate-fns-CfsveE1w.mjs";
|
|
4
|
-
import { v as tableNameOf } from "./nested-writer-
|
|
5
|
-
import {
|
|
4
|
+
import { v as tableNameOf } from "./nested-writer-BO3vhbkP.mjs";
|
|
5
|
+
import { t as DB_ENTITY_ANNOTATIONS } from "./derived-rules-0sKn4f5C.mjs";
|
|
6
|
+
import { a as forceNavNonOptional, c as getKeyProps, d as getPath, f as isEmptyObject, l as deletePath, o as isNavRelation, p as isPlainObject, r as buildValidationContext, s as createDbValidatorPlugin, t as buildDbValidator, u as findAncestorInSet } from "./validator-D8bPsXPN.mjs";
|
|
6
7
|
import { t as DEFAULT_DB_SPACE } from "./consts-C_-5_pFq.mjs";
|
|
7
8
|
import { $cas, $dec, $inc, $insert, $mul, $remove, $replace, $update, $upsert, getDbFieldOp, isDbFieldOp, reconcileCas, separateCas, separateFieldOps } from "./ops.mjs";
|
|
9
|
+
import { isAnnotatedType } from "@atscript/typescript/utils";
|
|
8
10
|
import { computeInsights, isPrimitive, walkFilter } from "@uniqu/core";
|
|
9
11
|
import { createCipheriv, createDecipheriv, randomBytes } from "node:crypto";
|
|
10
12
|
//#region src/encryption.ts
|
|
@@ -202,6 +204,14 @@ async function withOptimisticRetry(table, filter, mutator, opts) {
|
|
|
202
204
|
//#endregion
|
|
203
205
|
//#region src/table/db-space.ts
|
|
204
206
|
/**
|
|
207
|
+
* A `@db.alias` type only names a join scope inside a view definition — it
|
|
208
|
+
* is never a table or view of its own (since 0.1.141).
|
|
209
|
+
*/
|
|
210
|
+
function assertNotAlias(type) {
|
|
211
|
+
const target = aliasTargetOf(type);
|
|
212
|
+
if (target) throw new Error(`"${type.id ?? ""}" is a @db.alias of "${target.id ?? ""}" — a join scope, not a table or view; register "${target.id ?? ""}" instead`);
|
|
213
|
+
}
|
|
214
|
+
/**
|
|
205
215
|
* A database space — a registry of tables and views sharing the same adapter type and driver.
|
|
206
216
|
*
|
|
207
217
|
* `DbSpace` solves the cross-table discovery problem: when table A has a relation
|
|
@@ -258,6 +268,7 @@ var DbSpace = class {
|
|
|
258
268
|
getTable(type, logger) {
|
|
259
269
|
let readable = this._readables.get(type);
|
|
260
270
|
if (!readable) {
|
|
271
|
+
assertNotAlias(type);
|
|
261
272
|
readable = new AtscriptDbTable(type, this._createAdapter(), logger || this.logger, (t) => this.get(t), (t) => {
|
|
262
273
|
const resolved = this.get(t);
|
|
263
274
|
return resolved instanceof AtscriptDbTable ? resolved : void 0;
|
|
@@ -277,6 +288,7 @@ var DbSpace = class {
|
|
|
277
288
|
getView(type, logger) {
|
|
278
289
|
let readable = this._readables.get(type);
|
|
279
290
|
if (!readable) {
|
|
291
|
+
assertNotAlias(type);
|
|
280
292
|
readable = new AtscriptDbView(type, this._createAdapter(), logger || this.logger, (t) => this.get(t));
|
|
281
293
|
readable.setEncryption(this._encryption);
|
|
282
294
|
this._readables.set(type, readable);
|
|
@@ -391,4 +403,22 @@ function translateQueryTree(node, resolveField) {
|
|
|
391
403
|
return { [leftField]: { [comp.op]: comp.right } };
|
|
392
404
|
}
|
|
393
405
|
//#endregion
|
|
394
|
-
|
|
406
|
+
//#region src/table/db-entity.ts
|
|
407
|
+
/**
|
|
408
|
+
* Whether `value` is a compiled type a `DbSpace` accepts: an annotated type
|
|
409
|
+
* whose own declaration carries `@db.table`, `@db.view` or `@db.view.for`.
|
|
410
|
+
* A `@db.alias` type is not one, and neither is a plain `export type X = Table`
|
|
411
|
+
* or a field typed with a table (`customer: Customer`) — since 0.1.141 the
|
|
412
|
+
* entity annotations stay on the declaring interface instead of travelling
|
|
413
|
+
* with every reference.
|
|
414
|
+
*
|
|
415
|
+
* Filters a module namespace before a sync:
|
|
416
|
+
* `syncSchema(db, Object.values(models).filter(isDbEntityType))`.
|
|
417
|
+
* @since 0.1.141
|
|
418
|
+
*/
|
|
419
|
+
function isDbEntityType(value) {
|
|
420
|
+
if (!isAnnotatedType(value)) return false;
|
|
421
|
+
return DB_ENTITY_ANNOTATIONS.some((name) => value.metadata.has(name));
|
|
422
|
+
}
|
|
423
|
+
//#endregion
|
|
424
|
+
export { $cas, $dec, $inc, $insert, $mul, $remove, $replace, $update, $upsert, ADAPTER_FILTER_REASON, ALL_AGGREGATE_FNS, ALL_BUCKET_UNITS, ApplicationIntegrity, AtscriptDbReadable, AtscriptDbTable, AtscriptDbView, BaseDbAdapter, CasExhaustedError, CasMismatchError, DEFAULT_DB_SPACE, DbEncryption, DbError, DbSpace, DocumentFieldMapper, ENCRYPTED_REASON, FieldMappingStrategy, IntegrityStrategy, NativeIntegrity, NoopLogger, RelationalFieldMapper, TableMetadata, UniquSelect, acceptedOperatorsHint, aliasTargetOf, assertGeoPoint, assertNoVersionWrites, bucketSourceVerdict, bucketTimeZoneUnavailable, buildDbValidator, buildValidationContext, canFilterLeaf, checkHavingKeys, classifyQueryPath, collectQueryPaths, computeInsights, createDbValidatorPlugin, createFailureCollector, decomposePatch, deletePath, findAncestorInSet, forceNavNonOptional, getDbFieldOp, getKeyProps, getPath, guardAggregate, guardFilter, guardPath, guardPaths, guardQuery, isAtscriptDbView, isBucketableField, isColumnTypeChanged, isDbEntityType, isDbFieldOp, isEmptyObject, isFieldRef, isGeoIndexableType, isGeoPointType, isJsonValueField, isNavRelation, isPlainObject, isPrimitive, jsonValueAncestor, narrowerFilterOps, normalizeComputedSelect, reconcileCas, resolveCalendarBuckets, resolveDesignType, separateCas, separateFieldOps, sortFieldNames, tableNameOf, translateQueryTree, unsupportedOperatorMessage, walkFilter, withOptimisticRetry };
|
|
@@ -26,13 +26,17 @@ function findRemoteFK(targetTable, thisTableName, alias) {
|
|
|
26
26
|
}
|
|
27
27
|
}
|
|
28
28
|
/**
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
29
|
+
* Physical name of an annotated type — its `@db.table`, else its `@db.view`
|
|
30
|
+
* name (a view is a readable source too, since 0.1.141), else its type id
|
|
31
|
+
* (`""` when none is set). The rule relations, foreign keys and view plans
|
|
32
|
+
* use to name a referenced table or view.
|
|
32
33
|
* @since 0.1.136
|
|
33
34
|
*/
|
|
34
35
|
function tableNameOf(type) {
|
|
35
|
-
|
|
36
|
+
const table = type?.metadata?.get("db.table");
|
|
37
|
+
if (table) return table;
|
|
38
|
+
const view = type?.metadata?.get("db.view");
|
|
39
|
+
return typeof view === "string" && view || type?.id || "";
|
|
36
40
|
}
|
|
37
41
|
/**
|
|
38
42
|
* Resolves the target table name from a relation's target type metadata.
|
|
@@ -26,13 +26,17 @@ function findRemoteFK(targetTable, thisTableName, alias) {
|
|
|
26
26
|
}
|
|
27
27
|
}
|
|
28
28
|
/**
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
29
|
+
* Physical name of an annotated type — its `@db.table`, else its `@db.view`
|
|
30
|
+
* name (a view is a readable source too, since 0.1.141), else its type id
|
|
31
|
+
* (`""` when none is set). The rule relations, foreign keys and view plans
|
|
32
|
+
* use to name a referenced table or view.
|
|
32
33
|
* @since 0.1.136
|
|
33
34
|
*/
|
|
34
35
|
function tableNameOf(type) {
|
|
35
|
-
|
|
36
|
+
const table = type?.metadata?.get("db.table");
|
|
37
|
+
if (table) return table;
|
|
38
|
+
const view = type?.metadata?.get("db.view");
|
|
39
|
+
return typeof view === "string" && view || type?.id || "";
|
|
36
40
|
}
|
|
37
41
|
/**
|
|
38
42
|
* Resolves the target table name from a relation's target type metadata.
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
//#region src/shared/object.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Plain object: prototype is `Object.prototype` or `null` — never a class
|
|
4
|
+
* instance (`Date`, `Uint8Array`, `ObjectId`, …) and never an array.
|
|
5
|
+
* Browser-safe; shared by the write paths, the HTTP shape gate and the client.
|
|
6
|
+
*/
|
|
7
|
+
declare function isPlainObject(value: unknown): value is Record<string, unknown>;
|
|
8
|
+
/** Zero-allocation emptiness check for a plain object (`{}` → `true`). */
|
|
9
|
+
declare function isEmptyObject(obj: Record<string, unknown>): boolean;
|
|
10
|
+
/**
|
|
11
|
+
* Finds the nearest ancestor of `path` that belongs to `set`.
|
|
12
|
+
* Used by both the build pipeline (in `_classifyFields`) and
|
|
13
|
+
* runtime reconstruction on the Readable.
|
|
14
|
+
*/
|
|
15
|
+
declare function findAncestorInSet(path: string, set: ReadonlySet<string>): string | undefined;
|
|
16
|
+
/**
|
|
17
|
+
* Reads a dot-path (or its segments) off a nested plain object: `undefined`
|
|
18
|
+
* past a missing step, or a step that is not a plain object (arrays are not
|
|
19
|
+
* descended into — no positional indexing).
|
|
20
|
+
* @since 0.1.141
|
|
21
|
+
*/
|
|
22
|
+
declare function getPath(row: Record<string, unknown>, path: string | readonly string[]): unknown;
|
|
23
|
+
/**
|
|
24
|
+
* Deletes a dot-path (or its segments) from a nested plain object; a no-op
|
|
25
|
+
* when an intermediate step is missing or not a plain object.
|
|
26
|
+
* @since 0.1.141
|
|
27
|
+
*/
|
|
28
|
+
declare function deletePath(target: Record<string, unknown>, path: string | readonly string[]): void;
|
|
29
|
+
//#endregion
|
|
30
|
+
export { isPlainObject as a, isEmptyObject as i, findAncestorInSet as n, getPath as r, deletePath as t };
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
//#region src/shared/object.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Plain object: prototype is `Object.prototype` or `null` — never a class
|
|
4
|
+
* instance (`Date`, `Uint8Array`, `ObjectId`, …) and never an array.
|
|
5
|
+
* Browser-safe; shared by the write paths, the HTTP shape gate and the client.
|
|
6
|
+
*/
|
|
7
|
+
declare function isPlainObject(value: unknown): value is Record<string, unknown>;
|
|
8
|
+
/** Zero-allocation emptiness check for a plain object (`{}` → `true`). */
|
|
9
|
+
declare function isEmptyObject(obj: Record<string, unknown>): boolean;
|
|
10
|
+
/**
|
|
11
|
+
* Finds the nearest ancestor of `path` that belongs to `set`.
|
|
12
|
+
* Used by both the build pipeline (in `_classifyFields`) and
|
|
13
|
+
* runtime reconstruction on the Readable.
|
|
14
|
+
*/
|
|
15
|
+
declare function findAncestorInSet(path: string, set: ReadonlySet<string>): string | undefined;
|
|
16
|
+
/**
|
|
17
|
+
* Reads a dot-path (or its segments) off a nested plain object: `undefined`
|
|
18
|
+
* past a missing step, or a step that is not a plain object (arrays are not
|
|
19
|
+
* descended into — no positional indexing).
|
|
20
|
+
* @since 0.1.141
|
|
21
|
+
*/
|
|
22
|
+
declare function getPath(row: Record<string, unknown>, path: string | readonly string[]): unknown;
|
|
23
|
+
/**
|
|
24
|
+
* Deletes a dot-path (or its segments) from a nested plain object; a no-op
|
|
25
|
+
* when an intermediate step is missing or not a plain object.
|
|
26
|
+
* @since 0.1.141
|
|
27
|
+
*/
|
|
28
|
+
declare function deletePath(target: Record<string, unknown>, path: string | readonly string[]): void;
|
|
29
|
+
//#endregion
|
|
30
|
+
export { isPlainObject as a, isEmptyObject as i, findAncestorInSet as n, getPath as r, deletePath as t };
|