@memberjunction/generic-database-provider 6.2.0-edge.5 → 6.2.0-edge.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +15 -1
- package/dist/GenericDatabaseProvider.d.ts +362 -37
- package/dist/GenericDatabaseProvider.d.ts.map +1 -1
- package/dist/GenericDatabaseProvider.js +1425 -216
- package/dist/GenericDatabaseProvider.js.map +1 -1
- package/dist/SqlLogger.d.ts +26 -0
- package/dist/SqlLogger.d.ts.map +1 -1
- package/dist/SqlLogger.js +77 -20
- package/dist/SqlLogger.js.map +1 -1
- package/dist/clientClauseScreen.d.ts +28 -3
- package/dist/clientClauseScreen.d.ts.map +1 -1
- package/dist/clientClauseScreen.js +112 -6
- package/dist/clientClauseScreen.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/recordChangeSnapshot.d.ts +43 -0
- package/dist/recordChangeSnapshot.d.ts.map +1 -0
- package/dist/recordChangeSnapshot.js +85 -0
- package/dist/recordChangeSnapshot.js.map +1 -0
- package/dist/renderPipeline.d.ts +27 -0
- package/dist/renderPipeline.d.ts.map +1 -1
- package/dist/renderPipeline.js +45 -3
- package/dist/renderPipeline.js.map +1 -1
- package/dist/systemUserFieldAccess.d.ts +16 -1
- package/dist/systemUserFieldAccess.d.ts.map +1 -1
- package/dist/systemUserFieldAccess.js +39 -8
- package/dist/systemUserFieldAccess.js.map +1 -1
- package/dist/types.d.ts +47 -2
- package/dist/types.d.ts.map +1 -1
- package/package.json +14 -14
package/README.md
CHANGED
|
@@ -40,7 +40,7 @@ DatabaseProviderBase (@memberjunction/core — no heavy deps, abstract)
|
|
|
40
40
|
| `DisposeAllSqlLoggingSessions()` | Disposes all active logging sessions (used on shutdown) |
|
|
41
41
|
| `LogSQLStatement()` | Static method to log SQL from external sources (e.g., transaction groups) |
|
|
42
42
|
| `RenderViewWhereClause()` | Resolves `{%UserView "id"%}` templates in saved view WHERE clauses |
|
|
43
|
-
| `InternalRunView()` | Shared view execution engine: view resolution, permissions, field selection, WHERE clause, ORDER BY, OFFSET *or* keyset (`AfterKey`) pagination, aggregates, audit logging |
|
|
43
|
+
| `InternalRunView()` | Shared view execution engine: view resolution, permissions, field selection, WHERE clause, ORDER BY, OFFSET *or* keyset (`AfterKey`) pagination, aggregates, audit logging. When a view requires multiple SQL statements (e.g., rows + total row count + aggregates), executes them in a single `ExecuteSQLBatch` call to collapse round-trips on providers that support multi-result-set batching (such as SQL Server) |
|
|
44
44
|
| `InternalRunViews()` | Parallel wrapper for multiple InternalRunView calls |
|
|
45
45
|
| `getRunTimeViewFieldString()` | Builds dialect-neutral field list string for view queries |
|
|
46
46
|
| `getRunTimeViewFieldArray()` | Resolves EntityFieldInfo list from params/view/entity |
|
|
@@ -124,6 +124,20 @@ Validation enforced by `BuildKeysetSeekClause`:
|
|
|
124
124
|
|
|
125
125
|
See **[KEYSET_PAGINATION_GUIDE.md](../../guides/KEYSET_PAGINATION_GUIDE.md)** for the full pattern and reference implementations.
|
|
126
126
|
|
|
127
|
+
## Single-Flight `RunView` Coalescing & Bounded Batch Concurrency
|
|
128
|
+
|
|
129
|
+
To prevent connection pool starvation and thundering-herd SQL queries when multiple concurrent requests or engines query the same uncached view simultaneously, `GenericDatabaseProvider` provides two built-in safeguards:
|
|
130
|
+
|
|
131
|
+
1. **Single-Flight In-Flight `RunView` Coalescing (`EnableInflightRunViewCoalescing`)**:
|
|
132
|
+
- Concurrent `InternalRunView` calls on the same non-transactional provider (`TransactionDepth === 0`) with identical canonical fingerprints (`EntityName`/`ViewID`/`ViewName`, `ExtraFilter`, `OrderBy`, `Fields`, `UserSearchString`, `MaxRows`, `StartRow`, `ResultType`, `Aggregates`, and user role/ID scope when RLS applies) share a single database execution.
|
|
133
|
+
- Each caller receives an isolated deep clone of the `Results` array and row objects (`cloneRunViewResultForCoalescedCaller`) so in-place caller mutations never bleed across requests.
|
|
134
|
+
- Eligible only when `ResultType` is `'simple'` or `'count_only'` and `SaveViewResults` / `ForceAuditLog` are not set.
|
|
135
|
+
|
|
136
|
+
2. **Bounded Batch Concurrency (`MaxConcurrentViewsPerBatch = 8`)**:
|
|
137
|
+
- `InternalRunViews` deduplicates identical view items within the batch and limits concurrent physical database executions to `GenericDatabaseProvider.MaxConcurrentViewsPerBatch` (default `8`), preventing large `RunViews` batches from exhausting the connection pool.
|
|
138
|
+
|
|
139
|
+
See the **[Server Scaling and Broadcast Architecture Guide](../../guides/SERVER_SCALING_AND_BROADCAST_ARCHITECTURE.md)** for full details.
|
|
140
|
+
|
|
127
141
|
## Server-Side Cache Backend
|
|
128
142
|
|
|
129
143
|
`GenericDatabaseProvider` owns the `LocalStorageProvider` property that all database providers (SQL Server, PostgreSQL) inherit. This is the cache backend used by `LocalCacheManager`, metadata persistence, and all server-side caching operations.
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
*
|
|
16
16
|
* @module @memberjunction/generic-database-provider
|
|
17
17
|
*/
|
|
18
|
-
import { BaseEntity, DatabaseProviderBase, EntityInfo, EntityFieldInfo, EntitySaveOptions, EntityDeleteOptions, EntityPermissionType, ExecuteSQLOptions, ILocalStorageProvider, RunViewParams, RunViewResult, RunViewWithCacheCheckParams, RunViewDatabaseStatus, RunViewsWithCacheCheckResponse, RunViewWithCacheCheckResult, RunQueryParams, RunQueryResult, RunQueryWithCacheCheckParams, RunQueriesWithCacheCheckResponse, RunQueryWithCacheCheckResult, QueryCacheAuthorization, QueryDefinitionSignature, AggregateResult, CompositeKey, DatasetItemFilterType, DatasetResultType, DatasetStatusResultType, IMetadataProvider, ProviderConfigDataBase, UserInfo, PostCommitTask, PostCommitToken, QueryExecutionSpec, SaveContext, SaveSQLResult, ExternalDataSourceReadRouter } from '@memberjunction/core';
|
|
18
|
+
import { BaseEntity, DatabaseProviderBase, EntityInfo, EntityFieldInfo, EntitySaveOptions, EntityDeleteOptions, EntityPermissionType, ExecuteSQLOptions, ILocalStorageProvider, RunViewParams, RunViewResult, RunViewWithCacheCheckParams, RunViewDatabaseStatus, RunViewsWithCacheCheckResponse, RunViewWithCacheCheckResult, RunQueryParams, RunQueryResult, RunQueryWithCacheCheckParams, RunQueriesWithCacheCheckResponse, RunQueryWithCacheCheckResult, QueryCacheAuthorization, QueryDefinitionSignature, AggregateResult, CompositeKey, DatasetItemFilterType, DatasetResultType, DatasetStatusResultType, IMetadataProvider, ProviderConfigDataBase, UserInfo, PostCommitTask, PostCommitToken, QueryExecutionSpec, SaveContext, SaveSQLResult, ExternalDataSourceReadRouter, UserViewProperty, ViewPropertyValues } from '@memberjunction/core';
|
|
19
19
|
import { SqlLoggingOptions, SqlLoggingSession } from './types.js';
|
|
20
20
|
import { SQLDialect } from '@memberjunction/sql-dialect';
|
|
21
21
|
import { type BalancedFragmentOptions } from '@memberjunction/sql-parser';
|
|
@@ -29,6 +29,7 @@ import { ScoredCandidate } from '@memberjunction/core';
|
|
|
29
29
|
import { ActionResult } from '@memberjunction/actions-base';
|
|
30
30
|
import { CountOnlyRow } from './countOnlyBatch.js';
|
|
31
31
|
import { type ClientClauseScreeningProvider } from './clientClauseScreen.js';
|
|
32
|
+
import { RecordChangeSnapshots } from './recordChangeSnapshot.js';
|
|
32
33
|
/**
|
|
33
34
|
* Configuration options for batch SQL execution.
|
|
34
35
|
* Shared between GenericDatabaseProvider and platform-specific providers.
|
|
@@ -121,6 +122,28 @@ export declare abstract class GenericDatabaseProvider extends DatabaseProviderBa
|
|
|
121
122
|
* each querying the database and broadcasting what they loaded.
|
|
122
123
|
*/
|
|
123
124
|
Config(data: ProviderConfigDataBase, providerToUse?: IMetadataProvider): Promise<boolean>;
|
|
125
|
+
/**
|
|
126
|
+
* Bounded freshness window (in milliseconds) for server-side `LocalCacheManager` RunView
|
|
127
|
+
* and Dataset slots. Within this window after a slot was written or last verified against
|
|
128
|
+
* SQL, `RunViewsWithCacheCheck` and `GetDatasetByName` can trust the in-memory slot with
|
|
129
|
+
* zero DB hits. Once this window elapses, the next check performs a lightweight batched
|
|
130
|
+
* SQL status probe (`COUNT(*)` + `MAX(__mj_UpdatedAt)`) to auto-reconcile any out-of-band
|
|
131
|
+
* SQL mutations (e.g., migrations, `mj sync push`, external scripts) without requiring a
|
|
132
|
+
* server restart.
|
|
133
|
+
*/
|
|
134
|
+
protected ServerCacheVerificationTTLMs: number;
|
|
135
|
+
/**
|
|
136
|
+
* Public accessor for {@link ServerCacheVerificationTTLMs}.
|
|
137
|
+
* Set to `0` to force SQL status verification on every cache check.
|
|
138
|
+
*/
|
|
139
|
+
get ServerCacheVerificationTTL(): number;
|
|
140
|
+
set ServerCacheVerificationTTL(value: number);
|
|
141
|
+
/**
|
|
142
|
+
* Most recent authoritative SQL status result per dataset key (`datasetName + filterKey`),
|
|
143
|
+
* populated by `GetDatasetStatusByName` and consumed by `GetDatasetByName` to reconcile
|
|
144
|
+
* cached dataset item slots against live SQL row counts and timestamps.
|
|
145
|
+
*/
|
|
146
|
+
private _lastDatasetStatusByName;
|
|
124
147
|
/**************************************************************************/
|
|
125
148
|
/**************************************************************************/
|
|
126
149
|
private static _sqlLoggingSessionsKey;
|
|
@@ -584,6 +607,67 @@ export declare abstract class GenericDatabaseProvider extends DatabaseProviderBa
|
|
|
584
607
|
* the design and the rev-3 lesson that motivated this shape.
|
|
585
608
|
*/
|
|
586
609
|
protected GenerateSaveSQL(entity: BaseEntity, isNew: boolean, user: UserInfo, options?: EntitySaveOptions): Promise<SaveSQLResult>;
|
|
610
|
+
/**
|
|
611
|
+
* The old and new snapshots a save's Record Change is built from. The audit trail stores
|
|
612
|
+
* whole payloads and projects them per reader, so both snapshots describe the whole record
|
|
613
|
+
* whoever saves it.
|
|
614
|
+
*
|
|
615
|
+
* - **A user denied nothing** (unrestricted and system-user saves): the object's own values.
|
|
616
|
+
* No query, even when the object was loaded without some columns.
|
|
617
|
+
* - **A restricted user's update** (their object never holds the fields they cannot read):
|
|
618
|
+
* the stored values of those fields are read once and the snapshots are widened with them.
|
|
619
|
+
* The diff is unchanged, because a field the object never held has the same stored value
|
|
620
|
+
* on both sides.
|
|
621
|
+
* - **Create**: there is no stored row yet. A field the INSERT omits because the user may
|
|
622
|
+
* not supply it is left out rather than recorded with a value the record never got.
|
|
623
|
+
*
|
|
624
|
+
* The read runs on the save's connection: inside an open transaction it reads that
|
|
625
|
+
* transaction's state. A save queued in a transaction group is generated when `Save()` is
|
|
626
|
+
* called, so its snapshot reflects the row as of then — the same moment the object's own
|
|
627
|
+
* old values describe.
|
|
628
|
+
*/
|
|
629
|
+
protected BuildRecordChangeSnapshots(entity: BaseEntity, isUpdate: boolean, user: UserInfo): Promise<RecordChangeSnapshots>;
|
|
630
|
+
/**
|
|
631
|
+
* Connections a save's SQL is being generated for, by entity object: the transaction a
|
|
632
|
+
* transaction group runs its items on. Set only for the duration of
|
|
633
|
+
* {@link GenerateSaveSQLReadingOn}.
|
|
634
|
+
*/
|
|
635
|
+
private readonly _snapshotConnections;
|
|
636
|
+
/**
|
|
637
|
+
* Generates a save's SQL with any stored-row read its Record Change snapshot needs run on
|
|
638
|
+
* `connectionSource`. A transaction group that regenerates an item's SQL while its own
|
|
639
|
+
* transaction is open passes that transaction, so the read sees the group's earlier writes and
|
|
640
|
+
* never waits on the locks the group itself holds.
|
|
641
|
+
*/
|
|
642
|
+
protected GenerateSaveSQLReadingOn(entity: BaseEntity, isNew: boolean, user: UserInfo, connectionSource?: object): Promise<SaveSQLResult>;
|
|
643
|
+
/** Full-width delete snapshots captured by {@link Delete}, consumed by `GenerateDeleteSQL`. */
|
|
644
|
+
private readonly _deleteSnapshots;
|
|
645
|
+
/**
|
|
646
|
+
* Deletes a record. Before the shared orchestration runs, a restricted user's delete reads the
|
|
647
|
+
* stored values of the fields their object never held, so the delete's `FullRecordJSON` — the
|
|
648
|
+
* snapshot a deleted record is restored from — is full width. `GenerateDeleteSQL` is
|
|
649
|
+
* synchronous, so the snapshot is captured here and handed to it through
|
|
650
|
+
* {@link RecordChangeDeleteSnapshot}. A user denied nothing costs no extra query.
|
|
651
|
+
*/
|
|
652
|
+
Delete(entity: BaseEntity, options: EntityDeleteOptions, user: UserInfo): Promise<boolean>;
|
|
653
|
+
/** Reads and stores the full-width delete snapshot when one is needed; true when it stored one. */
|
|
654
|
+
private captureDeleteSnapshot;
|
|
655
|
+
/**
|
|
656
|
+
* The record snapshot a delete's Record Change carries: the full-width snapshot {@link Delete}
|
|
657
|
+
* captured, else `narrow` (the object's own values, which are already full width whenever no
|
|
658
|
+
* snapshot was needed).
|
|
659
|
+
*/
|
|
660
|
+
protected RecordChangeDeleteSnapshot(entity: BaseEntity, narrow: Record<string, unknown>): Record<string, unknown>;
|
|
661
|
+
/**
|
|
662
|
+
* Reads the stored values of `columns` — the fields a snapshot lacks — for a Record Change
|
|
663
|
+
* snapshot. Provider-internal: no row-level filter and no field-security check, because the
|
|
664
|
+
* payload is stored unprojected and projected for each reader. The row gets the same
|
|
665
|
+
* post-processing as a `Load` (binary to base64, datetime adjustment, decryption,
|
|
666
|
+
* fixed-width trimming). Runs on the connection the save is generated for when one was named
|
|
667
|
+
* ({@link GenerateSaveSQLReadingOn}), else on the save's usual connection. Kept out of the SQL
|
|
668
|
+
* log, which records the save itself.
|
|
669
|
+
*/
|
|
670
|
+
protected ReadStoredRowForRecordChange(entity: BaseEntity, user: UserInfo, columns: ReadonlySet<string>): Promise<Record<string, unknown> | null>;
|
|
587
671
|
/**
|
|
588
672
|
* Builds a platform-specific pagination clause.
|
|
589
673
|
* SQL Server: `OFFSET X ROWS FETCH NEXT Y ROWS ONLY`
|
|
@@ -626,37 +710,34 @@ export declare abstract class GenericDatabaseProvider extends DatabaseProviderBa
|
|
|
626
710
|
* `QuoteIdentifier` produces `"TotalRowCount"` on PG and `[TotalRowCount]` on SQL
|
|
627
711
|
* Server — both preserve case.
|
|
628
712
|
*/
|
|
629
|
-
protected BuildTotalRowCountSQL(entityInfo: EntityInfo, usingPagination: boolean, maxRowsForQuery: number, baseViewOverride?: string): string | null;
|
|
713
|
+
protected BuildTotalRowCountSQL(entityInfo: EntityInfo, usingPagination: boolean, maxRowsForQuery: number, baseViewOverride?: string, schemaNameOverride?: string): string | null;
|
|
630
714
|
/**
|
|
631
|
-
* Resolves the
|
|
632
|
-
*
|
|
633
|
-
*
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
*
|
|
638
|
-
*
|
|
639
|
-
*
|
|
640
|
-
* view (`materialized_vw<...>`), so there is no separate live source to swap — `'Materialized'` is a
|
|
641
|
-
* no-op and we return the entity's own base view. (Deriving `materialized_vw<CodeName>` here would be
|
|
642
|
-
* wrong: the minted entity's CodeName need not match the query-derived view name.)
|
|
643
|
-
*
|
|
644
|
-
* Convention-based for the base-view case: if the entity has no such materialization the wrapper view
|
|
645
|
-
* won't exist and the read will error — opting into `'Materialized'` asserts the snapshot exists.
|
|
715
|
+
* Resolves the effective semantic `AlternateBaseView` name for a `RunViewParams` object and
|
|
716
|
+
* optional loaded `MJUserViewEntityExtended`. An explicit empty string (`""`) on
|
|
717
|
+
* `params.AlternateBaseView` overrides any saved view pin back to `BaseView` (`undefined`).
|
|
718
|
+
*/
|
|
719
|
+
protected resolveEffectiveAbvNameFromParams(params: RunViewParams | undefined, viewEntity?: MJUserViewEntityExtended | null): string | undefined;
|
|
720
|
+
/**
|
|
721
|
+
* Resolves the view a RunView reads from: an explicit or pinned `AlternateBaseView` when present,
|
|
722
|
+
* the entity's materialized wrapper view when `DataSource: 'Materialized'`, or the entity's live
|
|
723
|
+
* `BaseView` by default.
|
|
646
724
|
*/
|
|
647
|
-
protected GetEffectiveBaseView(entityInfo: EntityInfo, params: RunViewParams): string;
|
|
725
|
+
protected GetEffectiveBaseView(entityInfo: EntityInfo, params: RunViewParams, viewEntity?: MJUserViewEntityExtended | null, suppressDeprecationWarning?: boolean): string;
|
|
648
726
|
/**
|
|
649
727
|
* Async status-aware wrapper around {@link GetEffectiveBaseView} for the BASE-VIEW materialization case.
|
|
650
|
-
* `GetEffectiveBaseView` name-swaps unconditionally, which (a) serves a `Building`/`DriftHold`/`Disabled`
|
|
651
|
-
* snapshot — defeating "flag and hold" (§13/§17.2), since a base-view materialization reuses the source
|
|
652
|
-
* entity and thus has no read-permission revoke to fall back on the way a minted query entity does — and
|
|
653
|
-
* (b) hard-errors on a `Materialized` read of a non-materialized entity (missing view). This gates the swap
|
|
654
|
-
* on an ACTIVE `MaterializedResult` and otherwise returns the LIVE base view (graceful fallback). The status
|
|
655
|
-
* read uses `BypassCache` because DriftHold/Disabled are written by CodeGen via direct SQL (no BaseEntity
|
|
656
|
-
* cache-invalidation event), so a cached status could otherwise be stale. Non-materialized reads and minted
|
|
657
|
-
* query virtual entities (BaseView already `materialized_vw…`) skip the lookup entirely (no extra query).
|
|
658
728
|
*/
|
|
659
|
-
protected resolveEffectiveBaseView(entityInfo: EntityInfo, params: RunViewParams, contextUser?: UserInfo): Promise<string>;
|
|
729
|
+
protected resolveEffectiveBaseView(entityInfo: EntityInfo, params: RunViewParams, contextUser?: UserInfo, viewEntity?: MJUserViewEntityExtended | null): Promise<string>;
|
|
730
|
+
/**
|
|
731
|
+
* Resolves both the effective `{ schemaName, viewName }` for a RunView call, honoring:
|
|
732
|
+
* 1. Explicit `params.AlternateBaseView` (including `""` to force `BaseView` over a saved view pin)
|
|
733
|
+
* 2. Saved `UserView.DisplayState.alternateBaseView` (from `viewEntity`, `params.ViewEntity`, or loaded by `ViewID`/`ViewName`)
|
|
734
|
+
* 3. `DataSource: 'Materialized'`
|
|
735
|
+
* 4. `entityInfo.BaseView`
|
|
736
|
+
*/
|
|
737
|
+
protected resolveEffectiveBaseViewTarget(entityInfo: EntityInfo, params: RunViewParams, contextUser?: UserInfo, viewEntity?: MJUserViewEntityExtended | null): Promise<{
|
|
738
|
+
schemaName: string;
|
|
739
|
+
viewName: string;
|
|
740
|
+
}>;
|
|
660
741
|
/**
|
|
661
742
|
* Reports whether a materialization-metadata `RunView` FAILED, logging the failure when it did.
|
|
662
743
|
*
|
|
@@ -744,10 +825,29 @@ export declare abstract class GenericDatabaseProvider extends DatabaseProviderBa
|
|
|
744
825
|
* SQL Server overrides to use spCreateUserViewRunWithDetail.
|
|
745
826
|
* Default: returns null (no view run logging).
|
|
746
827
|
*/
|
|
747
|
-
protected executeSQLForUserViewRunLogging(_viewId: number, _entityInfo: EntityInfo, _effectiveBaseView: string, _whereSQL: string, _orderBySQL: string, _user: UserInfo): Promise<{
|
|
828
|
+
protected executeSQLForUserViewRunLogging(_viewId: number, _entityInfo: EntityInfo, _effectiveBaseView: string, _whereSQL: string, _orderBySQL: string, _user: UserInfo, _schemaNameOverride?: string): Promise<{
|
|
748
829
|
executeViewSQL: string;
|
|
749
830
|
runID: string;
|
|
750
831
|
} | null>;
|
|
832
|
+
/**
|
|
833
|
+
* Maximum number of concurrent database view executions allowed within a single
|
|
834
|
+
* {@link InternalRunViews} batch. Prevents large `RunViews` batches from exhausting
|
|
835
|
+
* the connection pool in a single tick. Set to 0 or Infinity to disable the cap.
|
|
836
|
+
* Default: 8.
|
|
837
|
+
*/
|
|
838
|
+
static MaxConcurrentViewsPerBatch: number;
|
|
839
|
+
/**
|
|
840
|
+
* Process-wide single-flight coalescing registry for in-flight read-only RunView executions.
|
|
841
|
+
* When multiple concurrent requests (across any per-request provider instance on the same
|
|
842
|
+
* server process) execute an identical non-transactional RunView simultaneously, only the
|
|
843
|
+
* first caller queries the database; joiners await the same promise and receive a shallow-cloned
|
|
844
|
+
* result object and Results array.
|
|
845
|
+
*/
|
|
846
|
+
private static readonly _inFlightRunViews;
|
|
847
|
+
/**
|
|
848
|
+
* Number of currently in-flight coalesced RunView executions across this process.
|
|
849
|
+
*/
|
|
850
|
+
static get InFlightRunViewCount(): number;
|
|
751
851
|
/**
|
|
752
852
|
* Shared InternalRunView implementation.
|
|
753
853
|
* Handles: view resolution, permissions, field selection, WHERE clause building
|
|
@@ -755,6 +855,28 @@ export declare abstract class GenericDatabaseProvider extends DatabaseProviderBa
|
|
|
755
855
|
* aggregates, parallel query execution, post-processing, and audit logging.
|
|
756
856
|
*/
|
|
757
857
|
protected InternalRunView<T = unknown>(params: RunViewParams, contextUser?: UserInfo): Promise<RunViewResult<T>>;
|
|
858
|
+
/**
|
|
859
|
+
* Determines whether a RunView invocation is eligible for process-wide single-flight
|
|
860
|
+
* coalescing across concurrent requests.
|
|
861
|
+
*/
|
|
862
|
+
protected canCoalesceRunViewInFlight(params: RunViewParams | null | undefined, countExecutor?: (countSQL: string) => Promise<CountOnlyRow[]>): boolean;
|
|
863
|
+
/**
|
|
864
|
+
* Builds the deterministic single-flight key for an in-flight RunView execution.
|
|
865
|
+
* Includes connection string, entity/view identity, filter, orderBy, fields, resultType,
|
|
866
|
+
* pagination/keyset cursor, aggregates, and effective user role/row-filter security context.
|
|
867
|
+
*/
|
|
868
|
+
protected buildSingleFlightRunViewKey(params: RunViewParams, contextUser?: UserInfo): string | null;
|
|
869
|
+
/**
|
|
870
|
+
* Shallow-clones a shared single-flight RunViewResult and its row objects so concurrent
|
|
871
|
+
* callers cannot mutate each other's result arrays or row properties in place.
|
|
872
|
+
*/
|
|
873
|
+
protected cloneSingleFlightRunViewResult<T>(result: RunViewResult<unknown>): RunViewResult<T>;
|
|
874
|
+
/**
|
|
875
|
+
* Returns true when an identical read-only RunView is already in flight in the process-wide
|
|
876
|
+
* single-flight registry. Used by {@link InternalRunViews} so duplicate views in a batch can
|
|
877
|
+
* join an active query immediately without consuming a concurrency slot.
|
|
878
|
+
*/
|
|
879
|
+
protected hasInFlightSingleFlightView(params: RunViewParams, contextUser?: UserInfo): boolean;
|
|
758
880
|
/**
|
|
759
881
|
* The body of {@link InternalRunView}. `countExecutor`, when supplied, replaces the
|
|
760
882
|
* direct execution of a `count_only` view's COUNT query — {@link InternalRunViews} uses
|
|
@@ -762,6 +884,35 @@ export declare abstract class GenericDatabaseProvider extends DatabaseProviderBa
|
|
|
762
884
|
* Everything before that step — permissions, RLS, filter screening — is unchanged.
|
|
763
885
|
*/
|
|
764
886
|
protected RunViewCore<T = unknown>(params: RunViewParams, contextUser?: UserInfo, countExecutor?: (countSQL: string) => Promise<CountOnlyRow[]>): Promise<RunViewResult<T>>;
|
|
887
|
+
private executeRunViewCore;
|
|
888
|
+
/** The stored view a run names (ViewEntity, else ViewID, else ViewName), or null for an entity run. */
|
|
889
|
+
protected LoadRunViewEntity(params: RunViewParams, contextUser?: UserInfo): Promise<MJUserViewEntityExtended | null>;
|
|
890
|
+
/**
|
|
891
|
+
* Works out a stored view's property values before the cache lookup (see
|
|
892
|
+
* {@link ProviderBase.PrepareRunViewProperties}). The resolved values, token defaults included,
|
|
893
|
+
* replace `Properties` and `ServerProperties`, so the fingerprint keys on what the run will use,
|
|
894
|
+
* and RunViewCore resolving them again yields the same predicates. A run that would be refused
|
|
895
|
+
* is left as it is and kept out of the cache; RunViewCore refuses it with its message. A view
|
|
896
|
+
* that cannot be loaded is left to RunViewCore too, which reports it as it always has.
|
|
897
|
+
*/
|
|
898
|
+
protected PrepareRunViewProperties(params: RunViewParams, contextUser?: UserInfo): Promise<void>;
|
|
899
|
+
/**
|
|
900
|
+
* Checks a stored view's declared properties and works out each one's value for this run.
|
|
901
|
+
* @returns null when the view declares none and the run sends none
|
|
902
|
+
* @throws on a malformed definition, any refusal {@link ResolveViewPropertyValues} makes, or a
|
|
903
|
+
* property with a value whose target field the user cannot read
|
|
904
|
+
*/
|
|
905
|
+
protected ResolveRunViewPropertyValues(viewEntity: MJUserViewEntityExtended | null, entityInfo: EntityInfo, params: RunViewParams, user: UserInfo): {
|
|
906
|
+
Declared: UserViewProperty[];
|
|
907
|
+
Values: ViewPropertyValues;
|
|
908
|
+
} | null;
|
|
909
|
+
/**
|
|
910
|
+
* The WHERE clause a stored view's properties add to this run: '' when there are none.
|
|
911
|
+
* Screened like any caller clause, though it is built only from typed literals.
|
|
912
|
+
*/
|
|
913
|
+
protected BuildViewPropertyFilter(viewEntity: MJUserViewEntityExtended | null, entityInfo: EntityInfo, params: RunViewParams, user: UserInfo): string;
|
|
914
|
+
/** The field-security check other predicates get: a property with a value may not filter a field the user cannot read. */
|
|
915
|
+
private assertViewPropertyFieldsReadable;
|
|
765
916
|
protected InternalRunViews<T = unknown>(params: RunViewParams[], contextUser?: UserInfo): Promise<RunViewResult<T>[]>;
|
|
766
917
|
/**
|
|
767
918
|
* All-`count_only` batch: every view runs the normal per-view path (so every
|
|
@@ -771,6 +922,12 @@ export declare abstract class GenericDatabaseProvider extends DatabaseProviderBa
|
|
|
771
922
|
* failure is thrown, as on the per-view path.
|
|
772
923
|
*/
|
|
773
924
|
protected RunCoalescedCountBatch<T = unknown>(params: RunViewParams[], contextUser?: UserInfo): Promise<RunViewResult<T>[]>;
|
|
925
|
+
/**
|
|
926
|
+
* One view of a `RunViews` batch. A field-security refusal of this view becomes this view's
|
|
927
|
+
* `Success: false` result, carrying the refusal's message, so it does not fail the views
|
|
928
|
+
* batched with it. Any other error is thrown, as a single RunView throws it.
|
|
929
|
+
*/
|
|
930
|
+
protected runBatchedView<T = unknown>(params: RunViewParams, contextUser?: UserInfo): Promise<RunViewResult<T>>;
|
|
774
931
|
/**************************************************************************/
|
|
775
932
|
/**************************************************************************/
|
|
776
933
|
/**
|
|
@@ -832,8 +989,12 @@ export declare abstract class GenericDatabaseProvider extends DatabaseProviderBa
|
|
|
832
989
|
* - escapes LIKE metacharacters (%, _, [, ]) in user input with ESCAPE '\\',
|
|
833
990
|
* - skips fields that are not sensible text-search targets (non-text types,
|
|
834
991
|
* unbounded text columns when FTX is off).
|
|
992
|
+
*
|
|
993
|
+
* @param deniedFields - The request's denied set (see ResolveRequestDeniedReadFields), so the
|
|
994
|
+
* searched columns match the ones its cache key and SELECT list were built from. Read from
|
|
995
|
+
* the entity for `contextUser` when omitted.
|
|
835
996
|
*/
|
|
836
|
-
protected createViewUserSearchSQL(entityInfo: EntityInfo, userSearchString: string, contextUser?: UserInfo): string;
|
|
997
|
+
protected createViewUserSearchSQL(entityInfo: EntityInfo, userSearchString: string, contextUser?: UserInfo, deniedFields?: Set<string>): string;
|
|
837
998
|
/**
|
|
838
999
|
* ORDER BY column list covering EVERY primary key column of the entity, quoted for the dialect
|
|
839
1000
|
* — `[ID]` for a single-column key, `[OrderID], [LineNo]` for a composite one. Used as the
|
|
@@ -907,6 +1068,19 @@ export declare abstract class GenericDatabaseProvider extends DatabaseProviderBa
|
|
|
907
1068
|
* saved-view save gate (`MJUserViewEntityServer`).
|
|
908
1069
|
*/
|
|
909
1070
|
ScreenClientClause(clause: string | null | undefined, label: string, contextUser?: UserInfo, entityInfo?: EntityInfo): void;
|
|
1071
|
+
/**
|
|
1072
|
+
* The field-security error a failed RunView must raise, or null to report the failure as
|
|
1073
|
+
* usual: a {@link FieldSecurityError} raised along the way, or — for a caller denied fields on
|
|
1074
|
+
* `entity` — a database "no such column" rejection, rewritten into the error a denied column
|
|
1075
|
+
* gets ({@link FieldSecuritySQLGate.ErrorForInvalidColumn}).
|
|
1076
|
+
*/
|
|
1077
|
+
protected fieldSecurityErrorFor(error: unknown, entity: EntityInfo | null, user: UserInfo | undefined): Error | null;
|
|
1078
|
+
/**
|
|
1079
|
+
* For a caller denied fields on `entity`, throws the field-security error when an aggregate was
|
|
1080
|
+
* refused because it names a column the entity does not have. A denied column in an aggregate is
|
|
1081
|
+
* refused by the gate with that error, so an unknown one must not answer differently.
|
|
1082
|
+
*/
|
|
1083
|
+
protected assertAggregateRefusalsAreNotColumnProbes(errors: AggregateResult[], entity: EntityInfo, user: UserInfo): void;
|
|
910
1084
|
/**
|
|
911
1085
|
* SECURITY — screens a saved view's rendered WhereClause with the full client-clause screen.
|
|
912
1086
|
* Any user who can save a view can write its WhereClause, directly or through FilterState or a
|
|
@@ -968,6 +1142,18 @@ export declare abstract class GenericDatabaseProvider extends DatabaseProviderBa
|
|
|
968
1142
|
GetRunViewsDatabaseStatus(params: RunViewParams[], contextUser?: UserInfo): Promise<RunViewDatabaseStatus[]>;
|
|
969
1143
|
/** Status-query inputs for {@link GetRunViewsDatabaseStatus}; entries that cannot be built record their error. */
|
|
970
1144
|
private buildDatabaseStatusItems;
|
|
1145
|
+
/**
|
|
1146
|
+
* The field-security key of one request, built once per request (`params` object) and user.
|
|
1147
|
+
* A smart-cache-check item asks for it from each leg — its browser freshness check, the
|
|
1148
|
+
* server-cache lookup and the cache write — and the answer cannot change within the request:
|
|
1149
|
+
* the denied set it is built from is already resolved once per request.
|
|
1150
|
+
*/
|
|
1151
|
+
protected ComputeRunViewFLSFingerprintKey(params: RunViewParams, contextUser?: UserInfo): string;
|
|
1152
|
+
private readonly _requestFLSKeys;
|
|
1153
|
+
/** What a request's field-security key is about: its entity, or the saved view it names. */
|
|
1154
|
+
private static flsKeyTarget;
|
|
1155
|
+
/** The message refusing `user` Read on `entityInfo`, or null when the user may read it. */
|
|
1156
|
+
private readPermissionError;
|
|
971
1157
|
/**
|
|
972
1158
|
* Smart cache validation for batch RunViews.
|
|
973
1159
|
* For each view request, if cacheStatus is provided, checks if the cache is current
|
|
@@ -988,7 +1174,7 @@ export declare abstract class GenericDatabaseProvider extends DatabaseProviderBa
|
|
|
988
1174
|
* entity whose view does not carry it, instead of comparing by count alone the way
|
|
989
1175
|
* `BaseEngine.SweepAgainstDatabase` documents.
|
|
990
1176
|
*/
|
|
991
|
-
protected BuildCacheStatusSQL(entityInfo: EntityInfo, effectiveView: string, whereSQL: string): string;
|
|
1177
|
+
protected BuildCacheStatusSQL(entityInfo: EntityInfo, effectiveView: string, whereSQL: string, schemaNameOverride?: string): string;
|
|
992
1178
|
/**
|
|
993
1179
|
* Executes cache status checks for multiple views.
|
|
994
1180
|
* Default: parallel individual queries (works on all platforms).
|
|
@@ -1044,7 +1230,21 @@ export declare abstract class GenericDatabaseProvider extends DatabaseProviderBa
|
|
|
1044
1230
|
* infinite loop / duplicate processing in deep-pagination jobs. Aggregates and a non-empty
|
|
1045
1231
|
* UserSearchString likewise can't be evaluated remotely. Throws a clear error naming the param.
|
|
1046
1232
|
*/
|
|
1047
|
-
protected assertExternalRunViewParamsSupported(params: RunViewParams, entityName: string): void;
|
|
1233
|
+
protected assertExternalRunViewParamsSupported(params: RunViewParams, entityName: string, viewEntity?: MJUserViewEntityExtended | null): void;
|
|
1234
|
+
/**
|
|
1235
|
+
* Field-level security on the clauses an external-data-source read hands its driver: the
|
|
1236
|
+
* caller's own, merged with a saved view's stored ones. The same gates the SQL path applies to
|
|
1237
|
+
* the clauses it runs; the external dispatch returns before that path, and the driver runs
|
|
1238
|
+
* the clauses remotely, where nothing else checks them.
|
|
1239
|
+
*/
|
|
1240
|
+
protected assertExternalClausesRespectFieldSecurity(entityInfo: EntityInfo, params: RunViewParams, user: UserInfo): void;
|
|
1241
|
+
/**
|
|
1242
|
+
* An external driver's rows without the columns `user` may not read. The driver returns the
|
|
1243
|
+
* entity's columns at full width, and the result-path projection resolves the entity only from
|
|
1244
|
+
* an `EntityName` or a loaded `ViewEntity`, so a request naming only a `ViewID` would keep
|
|
1245
|
+
* them: the entity resolved here is named explicitly.
|
|
1246
|
+
*/
|
|
1247
|
+
protected projectExternalRowsForCaller<T>(rows: T[], entityInfo: EntityInfo, params: RunViewParams, user: UserInfo): T[];
|
|
1048
1248
|
/**
|
|
1049
1249
|
* Folds a saved view's stored WhereClause and OrderByClause into the RunView params before
|
|
1050
1250
|
* external dispatch. The external branch returns before the normal SQL path that applies
|
|
@@ -1054,10 +1254,19 @@ export declare abstract class GenericDatabaseProvider extends DatabaseProviderBa
|
|
|
1054
1254
|
* when there is no saved view.
|
|
1055
1255
|
*/
|
|
1056
1256
|
protected mergeExternalViewParams(params: RunViewParams, viewEntity: MJUserViewEntityExtended | null, user: UserInfo): Promise<RunViewParams>;
|
|
1257
|
+
/**
|
|
1258
|
+
* True when a browser's cache status carries a field-security key (see
|
|
1259
|
+
* `ProviderBase.ComputeFieldSecurityCacheStatusKey`) other than the one this server computes
|
|
1260
|
+
* for `user` and `params`: the browser's slot was filled for a different set of columns, so
|
|
1261
|
+
* its row count and newest timestamp say nothing about whether it is current. False when the
|
|
1262
|
+
* status carries no key.
|
|
1263
|
+
*/
|
|
1264
|
+
private cacheStatusFieldSecurityDiffers;
|
|
1057
1265
|
/**
|
|
1058
1266
|
* Checks the server's LocalCacheManager for cached data matching the client's request.
|
|
1059
|
-
* Returns the resolution if found (
|
|
1060
|
-
*
|
|
1267
|
+
* Returns the resolution if found ('current', 'stale' server-cached data to serve, or
|
|
1268
|
+
* 'needs_verification' when the server slot's freshness window has elapsed),
|
|
1269
|
+
* or null if the server cache doesn't have this data (or was evicted due to client monotonicity).
|
|
1061
1270
|
*/
|
|
1062
1271
|
private resolveFromServerCache;
|
|
1063
1272
|
/**
|
|
@@ -1092,6 +1301,14 @@ export declare abstract class GenericDatabaseProvider extends DatabaseProviderBa
|
|
|
1092
1301
|
* the query has no CacheValidationSQL configured.
|
|
1093
1302
|
*/
|
|
1094
1303
|
RunQueriesWithCacheCheck<T = unknown>(params: RunQueryWithCacheCheckParams[], contextUser?: UserInfo): Promise<RunQueriesWithCacheCheckResponse<T>>;
|
|
1304
|
+
/**
|
|
1305
|
+
* The authorization of one {@link RunQueriesWithCacheCheck} item before it is routed. An item
|
|
1306
|
+
* that may be answered "current" without running — it carries a cache status for this
|
|
1307
|
+
* definition and the query has validation SQL — is checked in full on its rendering here. Every
|
|
1308
|
+
* other item runs, and the run checks the rendering it executes, so only the render-free part
|
|
1309
|
+
* is checked here rather than rendering the query twice.
|
|
1310
|
+
*/
|
|
1311
|
+
private authorizeCacheCheckedQuery;
|
|
1095
1312
|
/**
|
|
1096
1313
|
* B45 override of the RunQuery cache-serve seam — enforce the SAME authorization on a
|
|
1097
1314
|
* cache HIT that the miss path enforces. Resolution uses `resolveQuery()` (QueryEngine as
|
|
@@ -1101,6 +1318,13 @@ export declare abstract class GenericDatabaseProvider extends DatabaseProviderBa
|
|
|
1101
1318
|
* applies before a real execution. The base's roles-only check would let a user read cached
|
|
1102
1319
|
* rows of a query whose underlying entities they cannot read.
|
|
1103
1320
|
*
|
|
1321
|
+
* The run-time checks (`UserCanRunRenderedSQL`: entities read by the SQL itself, and field-level
|
|
1322
|
+
* security) run against the query rendered with the request's own parameters: the SQL the miss
|
|
1323
|
+
* path would check and execute for this slot, since the slot's fingerprint carries those
|
|
1324
|
+
* parameters and its definition hash the query's SQL. A user the miss path would refuse is never
|
|
1325
|
+
* served the slot; a rendering that fails is treated as not authorized, so the request falls
|
|
1326
|
+
* through to execution and gets that path's error.
|
|
1327
|
+
*
|
|
1104
1328
|
* Non-throwing by contract: any resolution error degrades to `resolvable: false`, which the
|
|
1105
1329
|
* gate treats as "fall through to authorized execution" — one extra query run, never an
|
|
1106
1330
|
* unauthorized serve and never a crashed cache path.
|
|
@@ -1134,6 +1358,40 @@ export declare abstract class GenericDatabaseProvider extends DatabaseProviderBa
|
|
|
1134
1358
|
* @throws Error if the user does not have permission to run the query
|
|
1135
1359
|
*/
|
|
1136
1360
|
protected ValidateQueryForExecution(query: MJQueryEntityExtended, contextUser?: UserInfo): void;
|
|
1361
|
+
/**
|
|
1362
|
+
* For a `RequireApproved` run: refuses unless the query, and every query it composes, has a
|
|
1363
|
+
* current approval — status Approved and a stored fingerprint equal to the fingerprint of the
|
|
1364
|
+
* definition this run executes. The fingerprint is worked out here, from the same
|
|
1365
|
+
* `QueryEngine` metadata the run renders, never from a caller's value.
|
|
1366
|
+
*
|
|
1367
|
+
* @throws Error naming the first query whose approval is not current
|
|
1368
|
+
*/
|
|
1369
|
+
protected ValidateQueryApprovalAsync(query: MJQueryEntityExtended, render: RenderResult): Promise<void>;
|
|
1370
|
+
/** The context tokens a query reads, with every query it composes, as the `QueryEngine` holds them. */
|
|
1371
|
+
private queryContextTokens;
|
|
1372
|
+
/**
|
|
1373
|
+
* SECURITY — authorizes a saved query against the SQL the run will execute (fully composed and
|
|
1374
|
+
* rendered), after {@link ValidateQueryForExecution} has passed: the entities that SQL reads,
|
|
1375
|
+
* and field-level security on every column it references. A template that injects an
|
|
1376
|
+
* identifier, a `{% if %}` branch and a `{{query:"..."}}` composition are all checked as they
|
|
1377
|
+
* render. A query carrying `MJ: Query Permissions` rows is authorized by its role list alone.
|
|
1378
|
+
* The refusal does not say which field or clause caused it.
|
|
1379
|
+
*
|
|
1380
|
+
* @throws Error when the user may not run this rendering of the query
|
|
1381
|
+
*/
|
|
1382
|
+
protected ValidateRenderedQueryForExecution(query: MJQueryEntityExtended, renderedSQL: string, contextUser?: UserInfo): void;
|
|
1383
|
+
/** The refusal for a user who may not run `query`; names entities the user cannot read, never a field. */
|
|
1384
|
+
private queryRunRefusalMessage;
|
|
1385
|
+
/** The run-time checks of `query` for `user` on this provider's entities and dialect; logs a field-security refusal. */
|
|
1386
|
+
private checkRenderedQuery;
|
|
1387
|
+
/**
|
|
1388
|
+
* The full authorization of a saved query for one request: {@link MJQueryEntityExtended.UserCanRun}
|
|
1389
|
+
* and the run-time checks on the query rendered with `parameters`. A rendering that fails
|
|
1390
|
+
* refuses, carrying the rendering's error.
|
|
1391
|
+
*/
|
|
1392
|
+
private authorizeQueryRun;
|
|
1393
|
+
/** True when the query carries a role list (`MJ: Query Permissions` rows), which authorizes a run by itself. */
|
|
1394
|
+
private static roleListGrants;
|
|
1137
1395
|
/**
|
|
1138
1396
|
* Resolves a category path string to a QueryCategoryInfo ID.
|
|
1139
1397
|
*/
|
|
@@ -1269,7 +1527,7 @@ export declare abstract class GenericDatabaseProvider extends DatabaseProviderBa
|
|
|
1269
1527
|
* the live query (serving live is always correct — this is a transparent optimization, never a
|
|
1270
1528
|
* correctness dependency).
|
|
1271
1529
|
*/
|
|
1272
|
-
protected tryBuildMaterializedQueryPlan(query: MJQueryEntityExtended, params: RunQueryParams, contextUser?: UserInfo): Promise<{
|
|
1530
|
+
protected tryBuildMaterializedQueryPlan(query: MJQueryEntityExtended, params: RunQueryParams, contextUser?: UserInfo, contextValues?: Record<string, string>): Promise<{
|
|
1273
1531
|
sql: string;
|
|
1274
1532
|
parameters: unknown[];
|
|
1275
1533
|
} | null>;
|
|
@@ -1291,6 +1549,19 @@ export declare abstract class GenericDatabaseProvider extends DatabaseProviderBa
|
|
|
1291
1549
|
* when one is given. `TimeoutSeconds` limits every statement the run sends.
|
|
1292
1550
|
*/
|
|
1293
1551
|
private runAdhocSQL;
|
|
1552
|
+
/**
|
|
1553
|
+
* SECURITY — what ad-hoc SQL may read, checked in the provider so that every in-process caller
|
|
1554
|
+
* (agents, data contexts, actions) is covered, not only the API's resolvers. `sql` is the
|
|
1555
|
+
* rendered statement, before the server's own paging wrap. Every table it reads must be an
|
|
1556
|
+
* entity base view the caller can read unscoped: CanRead with no row-level filter and no denied
|
|
1557
|
+
* field, because raw SQL applies neither ({@link ClientClauseScreen.AssertStatementReadsUnscopedEntityViews}).
|
|
1558
|
+
* The system user runs the server's own SQL and is not checked, but only when passed
|
|
1559
|
+
* explicitly: no user at all refuses, rather than falling back to the provider's own user,
|
|
1560
|
+
* which on a server is the system user.
|
|
1561
|
+
*
|
|
1562
|
+
* @throws Error when the caller may not run `sql`
|
|
1563
|
+
*/
|
|
1564
|
+
protected AssertAdhocReadAllowed(sql: string, contextUser?: UserInfo): void;
|
|
1294
1565
|
/**
|
|
1295
1566
|
* The total row count for a page of ad-hoc SQL, or `null` when it cannot be had. A count that
|
|
1296
1567
|
* fails does not fail the run: some queries page fine but cannot be counted (duplicate column
|
|
@@ -1318,7 +1589,7 @@ export declare abstract class GenericDatabaseProvider extends DatabaseProviderBa
|
|
|
1318
1589
|
* Delegates to {@link RenderPipeline.Run} for the composition → template
|
|
1319
1590
|
* pipeline. Paging is handled separately by the caller (InternalRunQuery).
|
|
1320
1591
|
*/
|
|
1321
|
-
protected processQueryParameters(query: MJQueryEntityExtended, parameters?: Record<string, string>, contextUser?: UserInfo): {
|
|
1592
|
+
protected processQueryParameters(query: MJQueryEntityExtended, parameters?: Record<string, string>, contextUser?: UserInfo, serverSet?: Pick<RunQueryParams, 'ServerParameters' | 'TimeZone'>): {
|
|
1322
1593
|
finalSQL: string;
|
|
1323
1594
|
appliedParameters: Record<string, string>;
|
|
1324
1595
|
renderResult: RenderResult;
|
|
@@ -1345,7 +1616,13 @@ export declare abstract class GenericDatabaseProvider extends DatabaseProviderBa
|
|
|
1345
1616
|
* truth (a TTL of <= 0 disables caching for the source); field-drift warnings still apply to
|
|
1346
1617
|
* freshly-fetched rows. Ad-hoc SQL (params.SQL) is never cached.
|
|
1347
1618
|
*/
|
|
1348
|
-
protected runExternalQueryWithCache(query: MJQueryEntityExtended, finalSQL: string, params: RunQueryParams, router: ExternalDataSourceReadRouter, contextUser?: UserInfo): Promise<RunQueryResult>;
|
|
1619
|
+
protected runExternalQueryWithCache(query: MJQueryEntityExtended, finalSQL: string, params: RunQueryParams, router: ExternalDataSourceReadRouter, contextUser?: UserInfo, contextValues?: Record<string, string>): Promise<RunQueryResult>;
|
|
1620
|
+
/**
|
|
1621
|
+
* The result-cache fingerprint segment for what the server set on a run: its `ServerParameters`
|
|
1622
|
+
* and the `Context` values the template read. Empty when there are neither, so the fingerprint
|
|
1623
|
+
* is exactly what it was before either existed.
|
|
1624
|
+
*/
|
|
1625
|
+
private serverSetFingerprintSegment;
|
|
1349
1626
|
protected warnIfExternalQueryFieldsMissing(query: MJQueryEntityExtended, result: RunQueryResult): RunQueryResult;
|
|
1350
1627
|
/**
|
|
1351
1628
|
* Lower-layer execution: resolves composition, processes templates, executes SQL.
|
|
@@ -1429,6 +1706,18 @@ export declare abstract class GenericDatabaseProvider extends DatabaseProviderBa
|
|
|
1429
1706
|
protected cacheQueryResults(_query: MJQueryEntityExtended, _parameters: Record<string, string>, _results: Record<string, unknown>[]): Promise<void>;
|
|
1430
1707
|
/**************************************************************************/
|
|
1431
1708
|
/**************************************************************************/
|
|
1709
|
+
/**
|
|
1710
|
+
* The `WHERE` predicate that selects one record by its composite key, using dialect-neutral
|
|
1711
|
+
* quoting. Quoted key values have embedded single quotes escaped: a key value can contain
|
|
1712
|
+
* apostrophes (an object-valued soft key whose JSON carries free text), and an unescaped quote
|
|
1713
|
+
* both breaks the statement and is an injection vector.
|
|
1714
|
+
*/
|
|
1715
|
+
protected BuildPrimaryKeyWhereClause(entityInfo: EntityInfo, compositeKey: CompositeKey): string;
|
|
1716
|
+
/**
|
|
1717
|
+
* Trims the trailing pad from fixed-width char fields (char/nchar pad with spaces on both SQL
|
|
1718
|
+
* Server and PostgreSQL), in place, and returns the row.
|
|
1719
|
+
*/
|
|
1720
|
+
protected TrimFixedWidthValues(entityInfo: EntityInfo, row: Record<string, unknown>): Record<string, unknown>;
|
|
1432
1721
|
/**
|
|
1433
1722
|
* Loads a single entity record by composite key, with optional relationship loading.
|
|
1434
1723
|
* Uses dialect-neutral quoting for all SQL construction.
|
|
@@ -1522,6 +1811,30 @@ export declare abstract class GenericDatabaseProvider extends DatabaseProviderBa
|
|
|
1522
1811
|
* (widget guests, magic-link sessions) whose roles hold no read grant on the metadata entities.
|
|
1523
1812
|
*/
|
|
1524
1813
|
private resolveDatasetItemScope;
|
|
1814
|
+
/**
|
|
1815
|
+
* Why a caller's ItemFilter is refused by the field-level security gate — the same gate every
|
|
1816
|
+
* RunView filter passes — or null when it may run. The item's stored WhereClause is
|
|
1817
|
+
* administrator-defined dataset metadata, not a predicate the caller chose, so it is not checked.
|
|
1818
|
+
*/
|
|
1819
|
+
private datasetItemFilterFieldSecurityRefusal;
|
|
1820
|
+
/**
|
|
1821
|
+
* The fields of a dataset item's entity the caller may not read, lowercased; empty when none,
|
|
1822
|
+
* when there is no caller, or for MJ_Metadata, which every principal loads to learn the schema.
|
|
1823
|
+
*/
|
|
1824
|
+
private datasetItemDeniedFields;
|
|
1825
|
+
/**
|
|
1826
|
+
* The error a failed dataset batch reports to the caller. When the caller is denied fields on
|
|
1827
|
+
* an item's entity and the database rejected a column that does not exist, every item reports
|
|
1828
|
+
* the field-security error a denied column gets instead, so the two cannot be told apart.
|
|
1829
|
+
*/
|
|
1830
|
+
private datasetBatchErrorForCaller;
|
|
1831
|
+
/**
|
|
1832
|
+
* Dataset item rows as the caller may see them: denied columns removed, and Record Changes
|
|
1833
|
+
* payloads narrowed. Cached rows are shared and full width, so this always builds new rows
|
|
1834
|
+
* rather than narrowing the cached ones. MJ_Metadata is exempt for the reason given on
|
|
1835
|
+
* {@link datasetItemDeniedFields}.
|
|
1836
|
+
*/
|
|
1837
|
+
private projectDatasetRowsForCaller;
|
|
1525
1838
|
/**
|
|
1526
1839
|
* The WHERE text for a dataset item: the caller's row filter AND'd with the item's filter. The
|
|
1527
1840
|
* item's filter sits two parentheses deep because a client ItemFilter is screened inside one
|
|
@@ -1550,6 +1863,10 @@ export declare abstract class GenericDatabaseProvider extends DatabaseProviderBa
|
|
|
1550
1863
|
* status fails with the refusal and no status SQL runs.
|
|
1551
1864
|
*/
|
|
1552
1865
|
GetDatasetStatusByName(datasetName: string, itemFilters?: DatasetItemFilterType[], contextUser?: UserInfo, providerToUse?: IMetadataProvider): Promise<DatasetStatusResultType>;
|
|
1866
|
+
/**
|
|
1867
|
+
* Builds the lookup key for {@link _lastDatasetStatusByName} from dataset name and item filters.
|
|
1868
|
+
*/
|
|
1869
|
+
private buildDatasetStatusCacheKey;
|
|
1553
1870
|
/**************************************************************************/
|
|
1554
1871
|
/**************************************************************************/
|
|
1555
1872
|
/**
|
|
@@ -1561,8 +1878,16 @@ export declare abstract class GenericDatabaseProvider extends DatabaseProviderBa
|
|
|
1561
1878
|
* binary column can still be named explicitly. When the entity's metadata is not loaded yet —
|
|
1562
1879
|
* the first `MJ_Metadata` read at boot — the item falls back to `*`, and the rows' byte arrays
|
|
1563
1880
|
* are converted to base64 by the caller.
|
|
1881
|
+
*
|
|
1882
|
+
* `deniedFields` (lowercased) are the columns the caller may not read. They are never
|
|
1883
|
+
* selected: a named one is dropped, and an item that names none selects every readable column.
|
|
1884
|
+
*/
|
|
1885
|
+
protected getColumnsForDatasetItem(item: Record<string, unknown>, datasetName: string, deniedFields?: Set<string>): string | null;
|
|
1886
|
+
/**
|
|
1887
|
+
* `columns` without the denied ones, quoted and joined. When every one is denied, the primary
|
|
1888
|
+
* key columns are selected instead, which are never denied, so the read still has a shape.
|
|
1564
1889
|
*/
|
|
1565
|
-
|
|
1890
|
+
private readableDatasetColumns;
|
|
1566
1891
|
/**************************************************************************/
|
|
1567
1892
|
/**************************************************************************/
|
|
1568
1893
|
/**
|