@memberjunction/generic-database-provider 6.2.0-edge.5 → 6.2.0-edge.7

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.
Files changed (100) hide show
  1. package/README.md +165 -1
  2. package/dist/GenericDatabaseProvider.d.ts +599 -69
  3. package/dist/GenericDatabaseProvider.d.ts.map +1 -1
  4. package/dist/GenericDatabaseProvider.js +2055 -403
  5. package/dist/GenericDatabaseProvider.js.map +1 -1
  6. package/dist/SqlLogger.d.ts +26 -0
  7. package/dist/SqlLogger.d.ts.map +1 -1
  8. package/dist/SqlLogger.js +77 -20
  9. package/dist/SqlLogger.js.map +1 -1
  10. package/dist/clientClauseScreen.d.ts +44 -75
  11. package/dist/clientClauseScreen.d.ts.map +1 -1
  12. package/dist/clientClauseScreen.js +129 -267
  13. package/dist/clientClauseScreen.js.map +1 -1
  14. package/dist/composition/compositionAssembler.d.ts +33 -0
  15. package/dist/composition/compositionAssembler.d.ts.map +1 -0
  16. package/dist/composition/compositionAssembler.js +270 -0
  17. package/dist/composition/compositionAssembler.js.map +1 -0
  18. package/dist/composition/compositionInfo.d.ts +7 -0
  19. package/dist/composition/compositionInfo.d.ts.map +1 -0
  20. package/dist/composition/compositionInfo.js +31 -0
  21. package/dist/composition/compositionInfo.js.map +1 -0
  22. package/dist/composition/compositionLookup.d.ts +44 -0
  23. package/dist/composition/compositionLookup.d.ts.map +1 -0
  24. package/dist/composition/compositionLookup.js +122 -0
  25. package/dist/composition/compositionLookup.js.map +1 -0
  26. package/dist/composition/compositionRender.d.ts +136 -0
  27. package/dist/composition/compositionRender.d.ts.map +1 -0
  28. package/dist/composition/compositionRender.js +264 -0
  29. package/dist/composition/compositionRender.js.map +1 -0
  30. package/dist/composition/compositionTypes.d.ts +40 -0
  31. package/dist/composition/compositionTypes.d.ts.map +1 -0
  32. package/dist/composition/compositionTypes.js +2 -0
  33. package/dist/composition/compositionTypes.js.map +1 -0
  34. package/dist/composition/quotedTagRefusal.d.ts +44 -0
  35. package/dist/composition/quotedTagRefusal.d.ts.map +1 -0
  36. package/dist/composition/quotedTagRefusal.js +132 -0
  37. package/dist/composition/quotedTagRefusal.js.map +1 -0
  38. package/dist/composition/renderSteps.d.ts +16 -0
  39. package/dist/composition/renderSteps.d.ts.map +1 -0
  40. package/dist/composition/renderSteps.js +42 -0
  41. package/dist/composition/renderSteps.js.map +1 -0
  42. package/dist/composition/safetyGate.d.ts +46 -0
  43. package/dist/composition/safetyGate.d.ts.map +1 -0
  44. package/dist/composition/safetyGate.js +61 -0
  45. package/dist/composition/safetyGate.js.map +1 -0
  46. package/dist/composition/templateUnit.d.ts +95 -0
  47. package/dist/composition/templateUnit.d.ts.map +1 -0
  48. package/dist/composition/templateUnit.js +189 -0
  49. package/dist/composition/templateUnit.js.map +1 -0
  50. package/dist/describeStatement.d.ts +51 -0
  51. package/dist/describeStatement.d.ts.map +1 -0
  52. package/dist/describeStatement.js +19 -0
  53. package/dist/describeStatement.js.map +1 -0
  54. package/dist/fieldSecurity/projectionStars.d.ts +15 -0
  55. package/dist/fieldSecurity/projectionStars.d.ts.map +1 -0
  56. package/dist/fieldSecurity/projectionStars.js +116 -0
  57. package/dist/fieldSecurity/projectionStars.js.map +1 -0
  58. package/dist/fieldSecurity/queryColumnSecurity.d.ts +35 -0
  59. package/dist/fieldSecurity/queryColumnSecurity.d.ts.map +1 -0
  60. package/dist/fieldSecurity/queryColumnSecurity.js +84 -0
  61. package/dist/fieldSecurity/queryColumnSecurity.js.map +1 -0
  62. package/dist/index.d.ts +9 -2
  63. package/dist/index.d.ts.map +1 -1
  64. package/dist/index.js +6 -1
  65. package/dist/index.js.map +1 -1
  66. package/dist/pagingLayout.d.ts +68 -0
  67. package/dist/pagingLayout.d.ts.map +1 -0
  68. package/dist/pagingLayout.js +190 -0
  69. package/dist/pagingLayout.js.map +1 -0
  70. package/dist/queryCompositionEngine.d.ts +22 -222
  71. package/dist/queryCompositionEngine.d.ts.map +1 -1
  72. package/dist/queryCompositionEngine.js +35 -729
  73. package/dist/queryCompositionEngine.js.map +1 -1
  74. package/dist/queryPagingEngine.d.ts +26 -5
  75. package/dist/queryPagingEngine.d.ts.map +1 -1
  76. package/dist/queryPagingEngine.js +51 -15
  77. package/dist/queryPagingEngine.js.map +1 -1
  78. package/dist/recordChangeSnapshot.d.ts +43 -0
  79. package/dist/recordChangeSnapshot.d.ts.map +1 -0
  80. package/dist/recordChangeSnapshot.js +85 -0
  81. package/dist/recordChangeSnapshot.js.map +1 -0
  82. package/dist/renderPipeline.d.ts +91 -72
  83. package/dist/renderPipeline.d.ts.map +1 -1
  84. package/dist/renderPipeline.js +71 -179
  85. package/dist/renderPipeline.js.map +1 -1
  86. package/dist/statementMemo.d.ts +29 -0
  87. package/dist/statementMemo.d.ts.map +1 -0
  88. package/dist/statementMemo.js +61 -0
  89. package/dist/statementMemo.js.map +1 -0
  90. package/dist/systemUserFieldAccess.d.ts +16 -1
  91. package/dist/systemUserFieldAccess.d.ts.map +1 -1
  92. package/dist/systemUserFieldAccess.js +39 -8
  93. package/dist/systemUserFieldAccess.js.map +1 -1
  94. package/dist/typedQueryParameter.d.ts +55 -0
  95. package/dist/typedQueryParameter.d.ts.map +1 -0
  96. package/dist/typedQueryParameter.js +122 -0
  97. package/dist/typedQueryParameter.js.map +1 -0
  98. package/dist/types.d.ts +47 -2
  99. package/dist/types.d.ts.map +1 -1
  100. 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 |
@@ -66,6 +66,14 @@ DatabaseProviderBase (@memberjunction/core — no heavy deps, abstract)
66
66
  | `getUpdatedRowsSince()` | Virtual: queries entity view for rows updated since a timestamp |
67
67
  | `resolveQuery()` | Resolves query from RunQueryParams (by ID or Name+CategoryPath) via QueryEngine |
68
68
  | `resolveCategoryPath()` | Resolves hierarchical category path to CategoryID |
69
+ | `InternalRunQuery()` | Runs a saved query (or routes ad hoc `SQL` to `ExecuteAdhocQuery`): render, authorize the rendered statement, optional materialized read, paging, field-level security column filtering. See [Running Queries](#running-queries) |
70
+ | `InternalExecuteQueryFromSpec()` | Runs a transient query spec (SQL, parameter definitions, inline dependencies) through the same render pipeline and safety gate |
71
+ | `ExecuteAdhocQuery()` | Runs caller-supplied SQL; it must be a single read statement |
72
+ | `processQueryParameters()` | Renders a saved query with `RenderPipeline.Run` for this provider's platform (or an external data source's dialect) |
73
+ | `ValidateRenderedQueryForExecution()` | Authorizes the rendered statement for the user, including field-level security; reports whether denied columns must be dropped from a `*` |
74
+ | `DescribeStatement()` | Asks the database to describe a statement's result columns without returning rows. Base implementation reports a failure; SQL Server and PostgreSQL override it |
75
+ | `buildMaterializedReadQuery()` | Static, pure builder for a read from a materialized snapshot, with every filter value bound as a parameter |
76
+ | `QueryUnavailableMessage()` / `RequestedQueryLabel()` | Static: the single refusal message used both for a query that does not exist and for one the caller may not run |
69
77
  | `BuildParameterPlaceholder()` | Virtual: PG-style $1/$2 by default; SQL Server overrides to @p0/@p1 |
70
78
  | `getColumnsForDatasetItem()` | Validates and quotes column names for dataset item queries |
71
79
 
@@ -105,9 +113,148 @@ export class MyDatabaseProvider extends GenericDatabaseProvider {
105
113
  // Implement remaining abstract methods from DatabaseProviderBase
106
114
  // Override EnqueueAfterSaveAIAction if you need transaction-aware deferral
107
115
  // Override PostProcessRows if you need platform-specific row processing (call super first)
116
+ // Override DescribeStatement if your database can describe a statement's result columns
108
117
  }
109
118
  ```
110
119
 
120
+ ## Running Queries
121
+
122
+ Every query path in this package (saved queries, ad hoc SQL, transient specs used by `TestQuerySQL`, data contexts and materialized reads) turns query text into the SQL that runs through one entry point, `RenderPipeline.Run`. The query language itself (template tags, filters, `Context` tokens, composition syntax and save-time rules) is specified in **[MJ Query Language](../../guides/MJ_QUERY_LANGUAGE.md)**. This section covers what the provider does with it.
123
+
124
+ ### The render pipeline
125
+
126
+ `RenderPipeline.Run(sql, ctx)` runs these steps in a fixed order:
127
+
128
+ 1. SQL comments are removed, so a template tag inside a comment does nothing.
129
+ 2. A template must pass the MJ Query language check; a template with errors is refused.
130
+ 3. **Render, then compose.** The outer query is rendered once with the caller's values. Each composition it reaches, `{{query:"Category/Path/Name(Arg=Value)"}}`, becomes one *instance*: the composed query plus its arguments, evaluated in the outer query's scope. Each instance is then rendered on its own, with only its own arguments and its own parameter definitions, recursively (up to 10 levels; cycles are refused). The rendered pieces are assembled into one statement, each instance as a CTE. The assembled SQL is never rendered again, so a value that happens to look like a template tag stays a plain value.
131
+ 4. **Safety gate** (below).
132
+ 5. **Row cap or paging** (below), applied last because a template can decide whether the statement has an `ORDER BY`.
133
+
134
+ What this means for query authors:
135
+
136
+ - **Arguments are explicit, like a function call.** A composed query's parameter that is not passed has no value, even when the outer query has a parameter with the same name. Write `(Region=Region)` to pass it on.
137
+ - **A composed query's required parameters are checked.** Leaving one out is a parameter error, not a silently dropped filter.
138
+ - **A branch not taken emits nothing.** A composition inside an `{% if %}` that renders false produces no CTE.
139
+ - **Two uses of the same query with the same arguments share one CTE**; different arguments give separate CTEs.
140
+ - **Lookup is by category path and name.** There is no name-only fallback. A path that is a whole-segment suffix of exactly one query's full path still runs, with a warning logged once, but saving such a path is refused; write the full path.
141
+ - A saved composed query must be Reusable, Approved and runnable by the user. One the user may not run is refused with the same message as one that does not exist.
142
+ - **Dialect.** Template values render for the dialect of the provider handling the request (`RenderContext.Platform`, or `DialectKey` when it differs, as for a query on an external data source). Two providers on different platforms in one process each render with their own rules.
143
+
144
+ `RenderResult` carries `FinalSQL`, `AppliedParameters`, `ContextValues` (the `Context` members the template read), `HasCompositions`, `CTEs`, `PagingResult`, `RowCap`, and a `Trace`:
145
+
146
+ | `Trace` field | Contents |
147
+ |---|---|
148
+ | `AfterComposition` | The assembled statement: every template rendered, every composition emitted as a CTE. Before row caps and paging |
149
+ | `AfterTemplates` | The same text as `AfterComposition`. Authorization checks read it, so it always includes every composed query |
150
+ | `AfterPaging` | The final SQL when paging was applied, otherwise `null` |
151
+ | `Instances` | Each composed instance, dependencies first: query, path, CTE name, evaluated arguments and its own rendered SQL |
152
+ | `CompositionDiagnostics` | Per instance: CTE name, whether its `ORDER BY` was removed, how many inner CTEs were hoisted |
153
+
154
+ ```typescript
155
+ import { RenderPipeline, IsQuerySafetyError } from '@memberjunction/generic-database-provider';
156
+ import type { UserInfo } from '@memberjunction/core';
157
+
158
+ function renderPage(sql: string, user: UserInfo): string | null {
159
+ try {
160
+ const result = RenderPipeline.Run(sql, {
161
+ Platform: 'sqlserver',
162
+ ContextUser: user,
163
+ Parameters: { Region: 'West' },
164
+ Paging: { StartRow: 0, MaxRows: 50 },
165
+ RequireReadStatement: true, // the caller supplied this SQL
166
+ });
167
+ return result.FinalSQL;
168
+ } catch (e) {
169
+ if (IsQuerySafetyError(e)) return null; // not a single read query
170
+ throw e;
171
+ }
172
+ }
173
+ ```
174
+
175
+ `Paging` and `MaxRows` are mutually exclusive; passing both throws.
176
+
177
+ ### The safety gate
178
+
179
+ Every rendered statement, on every path, passes `SafetyGate` before it can run. The check reads the SQL with the dialect's lexer, not a full parser, so it works on any statement the database itself would accept. The statement must be exactly one read query, starting with `SELECT` or `WITH`, and may not call functions the dialect lists as forbidden (functions that run SQL given as text or read files or other databases). It fails closed: SQL it cannot read is refused, never passed. SQL with no statement at all is refused when `RequireReadStatement` is set, which the ad hoc and test paths do.
180
+
181
+ A refusal is a `QuerySafetyError`; use `IsQuerySafetyError(e)` to recognise one (it also matches an error thrown by a second loaded copy of the module). Saving a new or edited query applies the same check, so a query that writes or calls a forbidden function cannot be saved; a refresh of an existing one reports it, and it is refused whenever it runs.
182
+
183
+ ### Paging and row caps
184
+
185
+ `QueryPagingEngine` pages by editing the statement's text in place: it reads the statement's structure and changes only the clauses it must. It never regenerates SQL from a syntax tree, and it does not wrap the query, so column scopes, `ORDER BY` references and table aliases stay valid.
186
+
187
+ - **Data SQL** (`WrapWithPaging(sql, startRow, maxRows, platform)` returns `PagingWrappedSQL` with `DataSQL`, `CountSQL`, `Offset`, `PageSize`): `OFFSET … FETCH NEXT …` on SQL Server, `LIMIT … OFFSET …` on PostgreSQL, after the statement's `ORDER BY` and before clauses that must stay last, such as `OPTION (…)`. A statement with no `ORDER BY` gets a default one.
188
+ - **Count SQL** puts the query, without its `ORDER BY`, in a CTE and selects `COUNT(*) AS TotalRowCount`.
189
+ - **The query's own row cap counts.** A numeric `TOP n`, `LIMIT n` or `FETCH NEXT n` is folded into the page arithmetic, so the smaller limit wins and the total is the size of the capped result. Any other cap (`TOP … PERCENT`, `WITH TIES`, an expression) is kept, and the query is paged as a derived table.
190
+ - **Row caps without paging** (`ApplyMaxRows`) add `TOP n` on SQL Server or `LIMIT n` on PostgreSQL, keep a tighter cap already present, and fall back to a derived table only for shapes that cannot be capped in place. `RowCapOutcome` reports whether the cap holds and how (`RowCapMethod`); when it could not be applied the pipeline logs why.
191
+ - A statement ending in `FOR JSON` / `FOR XML` returns a document, not rows; asking to page it is an error.
192
+ - `ShouldPage(startRow, maxRows)` is true when `MaxRows` is set, even without a `StartRow`, so a plain cap is applied in SQL rather than by fetching everything.
193
+
194
+ ### Materialized reads and named parameters
195
+
196
+ A saved query with an active materialization can be served from its snapshot table when the caller asks for it and the read would return the same rows as the live query; on any doubt the provider runs the query live. `buildMaterializedReadQuery` builds that read, with every filter value **bound as a parameter**, never written into the SQL text. The read orders by the snapshot's stable row ID, so pages do not skip or repeat rows.
197
+
198
+ Parameters are typed from the snapshot's own columns. The provider describes the snapshot table (see `DescribeStatement` below), keeps the column types until the next refresh, and binds each value as a `TypedQueryParameter` with the type of the column it is compared with. On SQL Server that is a named, declared parameter, so a `varchar` column is compared with a `varchar` value and keeps its index seek; on PostgreSQL it is a positional parameter with a cast. A value the column type cannot hold sends the read back to the live query.
199
+
200
+ Two classes describe bind parameters for `ExecuteSQL`:
201
+
202
+ | Class | Use |
203
+ |---|---|
204
+ | `TypedQueryParameter(Name, SQLType, Value)` | A parameter with an explicit database type. `TypedBindValue(value, sqlType)` converts a value to what that type binds, or returns `undefined` when it cannot |
205
+ | `NamedQueryParameter(Name, Value)` | A parameter passed by name whose type the driver infers. SQL Server binds `@p0` as `p0` and leaves the statement text alone; PostgreSQL binds by position (`$1`) |
206
+
207
+ A plain array of values (`[value1, value2]`) is the **legacy positional form**: SQL Server providers bind it by rewriting every `?` in the text, including one inside a string literal or comment. Prefer named parameters in new code:
208
+
209
+ ```typescript
210
+ import { NamedQueryParameter, type GenericDatabaseProvider } from '@memberjunction/generic-database-provider';
211
+ import type { UserInfo } from '@memberjunction/core';
212
+
213
+ // SQL Server: @p0 is bound by name as p0
214
+ async function customerNames(provider: GenericDatabaseProvider, contextUser: UserInfo): Promise<string[]> {
215
+ const rows = await provider.ExecuteSQL<{ Name: string }>(
216
+ 'SELECT Name FROM [dbo].[Customer] WHERE Region = @p0',
217
+ [new NamedQueryParameter('p0', 'West')],
218
+ undefined,
219
+ contextUser,
220
+ );
221
+ return rows.map(r => r.Name);
222
+ }
223
+ ```
224
+
225
+ ### `DescribeStatement`
226
+
227
+ ```typescript
228
+ public async DescribeStatement(sql: string, contextUser?: UserInfo): Promise<DescribeStatementResult>
229
+ ```
230
+
231
+ Asks the database server to describe the result columns a statement would return, without returning its rows. SQL Server compiles the statement without running it; PostgreSQL runs it with no rows returned inside a transaction that is rolled back. The base class reports a failure, so a provider for a database that cannot describe statements needs no override.
232
+
233
+ The result has `Success`, `Columns` and `Diagnostics` (the server's error text on failure). Each `DescribedColumn` gives `Name`, `Ordinal`, `SQLBaseType`, `SQLFullType` (such as `nvarchar(100)`), `IsNullable` (`null` when the server does not say, as on PostgreSQL), `IsComputed`, and `Source`: the table or view column the value passes through unchanged, or `null`. Build results with `DescribeStatementSuccess` / `DescribeStatementFailure`; `BaseTypeOf('decimal(18,2)')` returns `decimal`.
234
+
235
+ It is used to record a query's output columns and types when the query is saved, to read a snapshot's column types for materialized reads, and by field-level security on `*` (below). Descriptions are cached per statement and dialect for a short time.
236
+
237
+ ### Field-level security on queries
238
+
239
+ When a user is denied read access to some fields, a saved query is checked against those permissions on the **rendered** statement, so composed queries and template branches are covered:
240
+
241
+ - A query that names a field the user may not read, anywhere in the statement, is refused before it runs. The message is the same as for a query that does not exist: `Query '<what you asked for>' does not exist or you do not have permission to run it.` It echoes only the identifier the caller supplied.
242
+ - A denied field that reaches the output only through a plain `*` or `alias.*` does not refuse the query. The query runs, and that column is removed from this user's results, so the result columns can differ between users. The columns to remove come from `DescribeStatement`; if the statement cannot be described, the run is refused rather than risk returning a denied column. A query on an external data source that would need this filtering is refused.
243
+ - A query authorized by its own `MJ: Query Permissions` rows runs with the rights its author granted, and field-level security does not change it.
244
+
245
+ ### Deprecated in this package
246
+
247
+ These still work and remain until 7.0. The last row is a legacy form rather than a marked deprecation:
248
+
249
+ | Deprecated | Use instead |
250
+ |---|---|
251
+ | `buildMaterializedReadQuery({ isPostgres })` | Pass `dialect` (and `columnTypes` for typed binding) |
252
+ | `buildMaterializedReadQuery` without `columnTypes` | Pass the snapshot's `columnTypes`, so values bind as `TypedQueryParameter` |
253
+ | `QueryPagingEngine.StripTopClause` / `stripTopClause` | `SqlDocument.Parse(sql, dialect).RowCaps()` from `@memberjunction/sql-parser` to find a `TOP`, and an `EditSet` to remove it |
254
+ | `QueryPagingEngine.extractOrderBy` | `QueryPagingEngine.ExtractOrderBy` |
255
+ | `ClientClauseScreen.AstContainsWriteNode` | `StrictFragmentValidator.ValidateReadOnlyStatement` from `@memberjunction/sql-parser` (its result reports `ContainsNestedWrite`) |
256
+ | Positional `?` parameter arrays | `NamedQueryParameter` or `TypedQueryParameter` lists |
257
+
111
258
  ## Keyset (Seek) Pagination
112
259
 
113
260
  `InternalRunView` honors `RunViewParams.AfterKey` (a `CompositeKey`) to emit keyset-style SQL — `WHERE pk > @lastSeen ORDER BY pk LIMIT N` — instead of `OFFSET ... FETCH NEXT N`. Keyset stays O(log N) regardless of depth, making it the right tool for background jobs iterating large entities.
@@ -124,6 +271,20 @@ Validation enforced by `BuildKeysetSeekClause`:
124
271
 
125
272
  See **[KEYSET_PAGINATION_GUIDE.md](../../guides/KEYSET_PAGINATION_GUIDE.md)** for the full pattern and reference implementations.
126
273
 
274
+ ## Single-Flight `RunView` Coalescing & Bounded Batch Concurrency
275
+
276
+ 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:
277
+
278
+ 1. **Single-Flight In-Flight `RunView` Coalescing (`EnableInflightRunViewCoalescing`)**:
279
+ - 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.
280
+ - Each caller receives an isolated deep clone of the `Results` array and row objects (`cloneRunViewResultForCoalescedCaller`) so in-place caller mutations never bleed across requests.
281
+ - Eligible only when `ResultType` is `'simple'` or `'count_only'` and `SaveViewResults` / `ForceAuditLog` are not set.
282
+
283
+ 2. **Bounded Batch Concurrency (`MaxConcurrentViewsPerBatch = 8`)**:
284
+ - `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.
285
+
286
+ See the **[Server Scaling and Broadcast Architecture Guide](../../guides/SERVER_SCALING_AND_BROADCAST_ARCHITECTURE.md)** for full details.
287
+
127
288
  ## Server-Side Cache Backend
128
289
 
129
290
  `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.
@@ -201,5 +362,8 @@ This package implements the `createViewUserSearchSQL()` method which generates p
201
362
  - `@memberjunction/encryption` — Field-level encryption/decryption
202
363
  - `@memberjunction/global` — Global object store, `ensureRegExps` for pattern filtering
203
364
  - `@memberjunction/queue` — Task queue for after-save AI actions
365
+ - `@memberjunction/sql-parser` — Lexer, structural reader and edits used by the safety gate, composition assembly and paging
366
+ - `@memberjunction/sql-dialect` — Per-platform quoting, parameter placeholders and forbidden-function lists
367
+ - `@memberjunction/query-processor` — Template rendering and parameter validation for queries
204
368
  - `sql-formatter` — SQL pretty-printing for log output
205
369
  - `uuid` — Session ID generation