@memberjunction/core 5.51.3 → 5.51.4

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 (47) hide show
  1. package/dist/generic/InMemoryLocalStorageProvider.d.ts +5 -0
  2. package/dist/generic/InMemoryLocalStorageProvider.d.ts.map +1 -1
  3. package/dist/generic/InMemoryLocalStorageProvider.js +5 -0
  4. package/dist/generic/InMemoryLocalStorageProvider.js.map +1 -1
  5. package/dist/generic/baseEngine.d.ts +5 -0
  6. package/dist/generic/baseEngine.d.ts.map +1 -1
  7. package/dist/generic/baseEngine.js +6 -1
  8. package/dist/generic/baseEngine.js.map +1 -1
  9. package/dist/generic/baseEntity.d.ts +35 -0
  10. package/dist/generic/baseEntity.d.ts.map +1 -1
  11. package/dist/generic/baseEntity.js +66 -13
  12. package/dist/generic/baseEntity.js.map +1 -1
  13. package/dist/generic/databaseProviderBase.d.ts +41 -8
  14. package/dist/generic/databaseProviderBase.d.ts.map +1 -1
  15. package/dist/generic/databaseProviderBase.js +67 -30
  16. package/dist/generic/databaseProviderBase.js.map +1 -1
  17. package/dist/generic/entityInfo.d.ts +18 -2
  18. package/dist/generic/entityInfo.d.ts.map +1 -1
  19. package/dist/generic/entityInfo.js +26 -10
  20. package/dist/generic/entityInfo.js.map +1 -1
  21. package/dist/generic/interfaces.d.ts +38 -0
  22. package/dist/generic/interfaces.d.ts.map +1 -1
  23. package/dist/generic/interfaces.js.map +1 -1
  24. package/dist/generic/providerBase.d.ts +66 -5
  25. package/dist/generic/providerBase.d.ts.map +1 -1
  26. package/dist/generic/providerBase.js +147 -13
  27. package/dist/generic/providerBase.js.map +1 -1
  28. package/dist/generic/remoteEventRow.d.ts +55 -0
  29. package/dist/generic/remoteEventRow.d.ts.map +1 -0
  30. package/dist/generic/remoteEventRow.js +110 -0
  31. package/dist/generic/remoteEventRow.js.map +1 -0
  32. package/dist/generic/runQuery.d.ts +18 -1
  33. package/dist/generic/runQuery.d.ts.map +1 -1
  34. package/dist/generic/runQuery.js.map +1 -1
  35. package/dist/generic/runQuerySQLFilterImplementations.d.ts +7 -1
  36. package/dist/generic/runQuerySQLFilterImplementations.d.ts.map +1 -1
  37. package/dist/generic/runQuerySQLFilterImplementations.js +64 -139
  38. package/dist/generic/runQuerySQLFilterImplementations.js.map +1 -1
  39. package/dist/generic/telemetryManager.d.ts +11 -0
  40. package/dist/generic/telemetryManager.d.ts.map +1 -1
  41. package/dist/generic/telemetryManager.js +40 -0
  42. package/dist/generic/telemetryManager.js.map +1 -1
  43. package/dist/index.d.ts +1 -0
  44. package/dist/index.d.ts.map +1 -1
  45. package/dist/index.js +1 -0
  46. package/dist/index.js.map +1 -1
  47. package/package.json +3 -3
@@ -0,0 +1,55 @@
1
+ /**
2
+ * @fileoverview Resolving the row behind a `remote-invalidate` event.
3
+ *
4
+ * Cache-invalidation events reach every connected client on one unfiltered subscription, so the
5
+ * server only attaches the row (`recordData`) for entities a deployment has explicitly opted in
6
+ * — otherwise every session would receive rows it has no right to read. See
7
+ * `cacheSettings.recordDataBroadcastEntities` in `@memberjunction/server`.
8
+ *
9
+ * That leaves consumers needing a row they no longer receive. This module is the one way to get
10
+ * it: re-read that single record through the provider, as the signed-in user, so the server's
11
+ * access control decides what comes back. A user who may not read the row gets `null`, which is
12
+ * the correct answer rather than an error.
13
+ */
14
+ import type { BaseEntityEvent } from './baseEntity.js';
15
+ import { CompositeKey } from './compositeKey.js';
16
+ import type { IMetadataProvider } from './interfaces.js';
17
+ import type { UserInfo } from './securityInfo.js';
18
+ /**
19
+ * The row behind an entity event, however it has to be obtained.
20
+ *
21
+ * Three sources, in order:
22
+ * 1. **Local event** — `event.baseEntity` is the live instance; its fields are already in hand.
23
+ * 2. **Remote event carrying `recordData`** — the entity is on the broadcast allowlist; parse it.
24
+ * 3. **Remote event without `recordData`** — re-read the one record by primary key through
25
+ * `provider`, as `contextUser`. This is the access-controlled path, and it is the only one
26
+ * that can supply fields the primary key does not carry (a detail's `ConversationID`, say).
27
+ *
28
+ * @returns the row's fields, or `null` when there is no key to read by, the read is refused, or
29
+ * the record no longer exists. Callers should treat `null` as "not mine / nothing to do"
30
+ * rather than as a failure — a refused read is the expected outcome for a session that
31
+ * may not see the record.
32
+ */
33
+ export declare function ResolveEntityEventRow(event: BaseEntityEvent, provider?: IMetadataProvider, contextUser?: UserInfo): Promise<Record<string, unknown> | null>;
34
+ /**
35
+ * Can this event's row be obtained WITHOUT a provider round-trip?
36
+ *
37
+ * True for a local event — the row IS the live entity — and for a remote event whose payload
38
+ * already carries `recordData`, because the entity is on the server's broadcast allowlist.
39
+ *
40
+ * Callers that skip hydration to avoid a read must ask this FIRST. A free row is never worth
41
+ * skipping, and skipping one is indistinguishable, downstream, from a row that could not be read:
42
+ * the handler receives `null` and reads every field as `undefined`. Whether a handler *would* use
43
+ * the row and whether obtaining it *costs* anything are two different questions, and only the
44
+ * second justifies skipping.
45
+ */
46
+ export declare function EntityEventRowIsFree(event: BaseEntityEvent): boolean;
47
+ /**
48
+ * The identity of the record an event refers to, without needing the row.
49
+ *
50
+ * Available whatever the broadcast allowlist says — the primary key is never withheld, because it
51
+ * discloses nothing a client cannot already derive and it is what every consumer needs to know
52
+ * *which* record changed. Prefer this over reading an id out of the row.
53
+ */
54
+ export declare function ResolveEntityEventKey(event: BaseEntityEvent): CompositeKey | null;
55
+ //# sourceMappingURL=remoteEventRow.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"remoteEventRow.d.ts","sourceRoot":"","sources":["../../src/generic/remoteEventRow.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,KAAK,EAAc,eAAe,EAAE,MAAM,cAAc,CAAC;AAChE,OAAO,EAAE,YAAY,EAAgB,MAAM,gBAAgB,CAAC;AAC5D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AACtD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAU/C;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,qBAAqB,CACvC,KAAK,EAAE,eAAe,EACtB,QAAQ,CAAC,EAAE,iBAAiB,EAC5B,WAAW,CAAC,EAAE,QAAQ,GACvB,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC,CAgBzC;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,eAAe,GAAG,OAAO,CAMpE;AAED;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,eAAe,GAAG,YAAY,GAAG,IAAI,CAMjF"}
@@ -0,0 +1,110 @@
1
+ import { CompositeKey } from './compositeKey.js';
2
+ import { LogError } from './logging.js';
3
+ /**
4
+ * The row behind an entity event, however it has to be obtained.
5
+ *
6
+ * Three sources, in order:
7
+ * 1. **Local event** — `event.baseEntity` is the live instance; its fields are already in hand.
8
+ * 2. **Remote event carrying `recordData`** — the entity is on the broadcast allowlist; parse it.
9
+ * 3. **Remote event without `recordData`** — re-read the one record by primary key through
10
+ * `provider`, as `contextUser`. This is the access-controlled path, and it is the only one
11
+ * that can supply fields the primary key does not carry (a detail's `ConversationID`, say).
12
+ *
13
+ * @returns the row's fields, or `null` when there is no key to read by, the read is refused, or
14
+ * the record no longer exists. Callers should treat `null` as "not mine / nothing to do"
15
+ * rather than as a failure — a refused read is the expected outcome for a session that
16
+ * may not see the record.
17
+ */
18
+ export async function ResolveEntityEventRow(event, provider, contextUser) {
19
+ if (event.baseEntity) {
20
+ return event.baseEntity.GetAll();
21
+ }
22
+ const payload = event.payload;
23
+ if (payload?.recordData) {
24
+ try {
25
+ return JSON.parse(payload.recordData);
26
+ }
27
+ catch {
28
+ // Fall through to the re-read: a malformed payload is not a reason to give up on a
29
+ // row we can still fetch by key.
30
+ }
31
+ }
32
+ return await reReadByPrimaryKey(event, payload, provider, contextUser);
33
+ }
34
+ /**
35
+ * Can this event's row be obtained WITHOUT a provider round-trip?
36
+ *
37
+ * True for a local event — the row IS the live entity — and for a remote event whose payload
38
+ * already carries `recordData`, because the entity is on the server's broadcast allowlist.
39
+ *
40
+ * Callers that skip hydration to avoid a read must ask this FIRST. A free row is never worth
41
+ * skipping, and skipping one is indistinguishable, downstream, from a row that could not be read:
42
+ * the handler receives `null` and reads every field as `undefined`. Whether a handler *would* use
43
+ * the row and whether obtaining it *costs* anything are two different questions, and only the
44
+ * second justifies skipping.
45
+ */
46
+ export function EntityEventRowIsFree(event) {
47
+ if (event.baseEntity) {
48
+ return true;
49
+ }
50
+ const payload = event.payload;
51
+ return !!payload?.recordData;
52
+ }
53
+ /**
54
+ * The identity of the record an event refers to, without needing the row.
55
+ *
56
+ * Available whatever the broadcast allowlist says — the primary key is never withheld, because it
57
+ * discloses nothing a client cannot already derive and it is what every consumer needs to know
58
+ * *which* record changed. Prefer this over reading an id out of the row.
59
+ */
60
+ export function ResolveEntityEventKey(event) {
61
+ if (event.baseEntity) {
62
+ return event.baseEntity.PrimaryKey ?? null;
63
+ }
64
+ const payload = event.payload;
65
+ return parseKey(payload?.primaryKeyValues);
66
+ }
67
+ /** Re-read one record by key. Never throws — a consumer's event handler must not die on it. */
68
+ async function reReadByPrimaryKey(event, payload, provider, contextUser) {
69
+ const entityName = event.entityName;
70
+ // `event.provider` is populated for remote-invalidate specifically because `baseEntity` is
71
+ // null there and listeners have nothing else to read through.
72
+ const p = provider ?? event.provider;
73
+ const key = parseKey(payload?.primaryKeyValues);
74
+ if (!entityName || !p || !key) {
75
+ return null;
76
+ }
77
+ try {
78
+ const record = await p.GetEntityObject(entityName, key, contextUser);
79
+ // A refused read and a deleted record both land here, and both mean the same thing to a
80
+ // caller: there is no row to apply.
81
+ return record?.IsSaved ? record.GetAll() : null;
82
+ }
83
+ catch (e) {
84
+ LogError(`ResolveEntityEventRow: could not re-read ${entityName} by key: ${e instanceof Error ? e.message : String(e)}`);
85
+ return null;
86
+ }
87
+ }
88
+ /**
89
+ * Rebuild the key from the published `primaryKeyValues`.
90
+ *
91
+ * `FromKeyValuePairs` rather than `FromID`: the entity here is whatever the event names, so a
92
+ * composite key has to survive. See `.claude/rules/data-access.md` on not assuming a single
93
+ * `ID` column for an arbitrary entity.
94
+ */
95
+ function parseKey(primaryKeyValues) {
96
+ if (!primaryKeyValues) {
97
+ return null;
98
+ }
99
+ try {
100
+ const pairs = JSON.parse(primaryKeyValues);
101
+ if (!Array.isArray(pairs) || pairs.length === 0) {
102
+ return null;
103
+ }
104
+ return CompositeKey.FromKeyValuePairs(pairs);
105
+ }
106
+ catch {
107
+ return null;
108
+ }
109
+ }
110
+ //# sourceMappingURL=remoteEventRow.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"remoteEventRow.js","sourceRoot":"","sources":["../../src/generic/remoteEventRow.ts"],"names":[],"mappings":"AAcA,OAAO,EAAE,YAAY,EAAgB,MAAM,gBAAgB,CAAC;AAG5D,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AASrC;;;;;;;;;;;;;;GAcG;AACH,MAAM,CAAC,KAAK,UAAU,qBAAqB,CACvC,KAAsB,EACtB,QAA4B,EAC5B,WAAsB;IAEtB,IAAI,KAAK,CAAC,UAAU,EAAE,CAAC;QACnB,OAAO,KAAK,CAAC,UAAU,CAAC,MAAM,EAAE,CAAC;IACrC,CAAC;IAED,MAAM,OAAO,GAAG,KAAK,CAAC,OAA8C,CAAC;IACrE,IAAI,OAAO,EAAE,UAAU,EAAE,CAAC;QACtB,IAAI,CAAC;YACD,OAAO,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,UAAU,CAA4B,CAAC;QACrE,CAAC;QAAC,MAAM,CAAC;YACL,mFAAmF;YACnF,iCAAiC;QACrC,CAAC;IACL,CAAC;IAED,OAAO,MAAM,kBAAkB,CAAC,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,WAAW,CAAC,CAAC;AAC3E,CAAC;AAED;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,oBAAoB,CAAC,KAAsB;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AAK,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;QACzH,OAAO,IAAI,CAAC;IAChB,CAAC;AACL,CAAC;AAED;;;;;;GAMG;AACH,SAAS,QAAQ,CAAC,gBAA2C;IACzD,IAAI,CAAC,gBAAgB,EAAE,CAAC;QACpB,OAAO,IAAI,CAAC;IAChB,CAAC;IACD,IAAI,CAAC;QACD,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,gBAAgB,CAAmB,CAAC;QAC7D,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YAC9C,OAAO,IAAI,CAAC;QAChB,CAAC;QACD,OAAO,YAAY,CAAC,iBAAiB,CAAC,KAAK,CAAC,CAAC;IACjD,CAAC;IAAC,MAAM,CAAC;QACL,OAAO,IAAI,CAAC;IAChB,CAAC;AACL,CAAC"}
@@ -23,6 +23,13 @@ export type RunQueryParams = {
23
23
  * The query runs on a read-only connection with security validation.
24
24
  */
25
25
  SQL?: string;
26
+ /**
27
+ * For ad-hoc SQL ({@link SQL}) only: the longest the query may run, in seconds. When it is
28
+ * exceeded the database cancels the query and the run fails with a timeout error. Omitted
29
+ * means the connection's usual limit applies; a longer value does not lift that limit.
30
+ * Ignored for saved queries.
31
+ */
32
+ TimeoutSeconds?: number;
26
33
  /**
27
34
  * Optional, if provided, the query to be run will be selected to match the specified Category by hierarchical path
28
35
  * (e.g., "/MJ/AI/Agents/") or simple category name for backward compatibility
@@ -40,7 +47,17 @@ export type RunQueryParams = {
40
47
  Parameters?: Record<string, any>;
41
48
  /**
42
49
  * Optional maximum number of rows to return from the query.
43
- * If not provided, all rows will be returned.
50
+ *
51
+ * There is no default. Without `MaxRows`, and with no `TOP` / `LIMIT` in the query's own SQL,
52
+ * the query returns every row it matches: bounding the result is the caller's and the query
53
+ * author's job.
54
+ *
55
+ * `MaxRows` limits the rows returned, not the work the database does. The query still reads
56
+ * everything its SQL asks for, and with paging the total row count is computed over the whole
57
+ * result. When the query carries its own cap (`TOP n`, `LIMIT n`, `OFFSET … FETCH`), the
58
+ * smaller of the two applies and `TotalRowCount` counts the capped result. A query that returns
59
+ * a document (`FOR JSON` / `FOR XML`) cannot be paged; asking for a page of one fails with an
60
+ * error that says so.
44
61
  */
45
62
  MaxRows?: number;
46
63
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"runQuery.d.ts","sourceRoot":"","sources":["../../src/generic/runQuery.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AACjE,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAE3D;;;;GAIG;AACH,MAAM,MAAM,cAAc,GAAG;IACzB;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB;;;;;OAKG;IACH,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ;;;OAGG;IACH,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB;;;;OAIG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;IAChC;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB;;;OAGG;IACH,aAAa,CAAC,EAAE,OAAO,CAAA;IACvB;;;OAGG;IACH,mBAAmB,CAAC,EAAE,MAAM,CAAA;IAE5B;;;;;;;;;;;OAWG;IACH,UAAU,CAAC,EAAE,OAAO,CAAA;IAE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,UAAU,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;IAC9D,CAAC;IAED;;;;;;;OAOG;IACI,KAAK,CAAC,eAAe,CAAC,IAAwB,EAAE,WAAsB;QACzE,OAAO,IAAI,CAAC,aAAa,CAAC,oBAAoB,CAAC,IAAI,EAAE,WAAW,CAAC,CAAC;IACtE,CAAC;aAEc,uBAAkB,GAAW,qBAAqB,CAAC;IAClE;;;;;OAKG;IACI,MAAM,KAAK,QAAQ;QACtB,MAAM,CAAC,GAAG,QAAQ,CAAC,QAAQ,CAAC,oBAAoB,EAAE,CAAC;QACnD,IAAI,CAAC;YACD,OAAO,CAAC,CAAC,QAAQ,CAAC,kBAAkB,CAAC,CAAC;;YAEtC,MAAM,IAAI,KAAK,CAAC,4DAA4D,CAAC,CAAC;IACtF,CAAC;IACD;;;;;OAKG;IACI,MAAM,KAAK,QAAQ,CAAC,KAAwB;QAC/C,MAAM,CAAC,GAAG,QAAQ,CAAC,QAAQ,CAAC,oBAAoB,EAAE,CAAC;QACnD,IAAI,CAAC;YACD,CAAC,CAAC,QAAQ,CAAC,kBAAkB,CAAC,GAAG,KAAK,CAAC;;YAEvC,MAAM,IAAI,KAAK,CAAC,4DAA4D,CAAC,CAAC;IACtF,CAAC"}
@@ -9,6 +9,7 @@
9
9
  import { BaseSingleton } from '@memberjunction/global';
10
10
  import { RunQuerySQLFilter } from './querySQLFilters.js';
11
11
  import { DatabasePlatform } from './platformSQL.js';
12
+ import type { SQLDialect } from '@memberjunction/sql-dialect';
12
13
  /**
13
14
  * Complete SQL filters with implementations attached.
14
15
  * This is the array that should be used by the QueryParameterProcessor.
@@ -33,7 +34,7 @@ export declare class RunQuerySQLFilterManager extends BaseSingleton<RunQuerySQLF
33
34
  */
34
35
  private initializeFilters;
35
36
  /**
36
- * Applies platform-specific overrides for sqlBoolean and sqlIdentifier filters.
37
+ * Installs the dialect-sensitive filters for the current platform's dialect.
37
38
  */
38
39
  private applyPlatformOverrides;
39
40
  /**
@@ -44,6 +45,11 @@ export declare class RunQuerySQLFilterManager extends BaseSingleton<RunQuerySQLF
44
45
  * Gets the current database platform for this filter manager.
45
46
  */
46
47
  get Platform(): DatabasePlatform;
48
+ /**
49
+ * The SQL dialect of the current platform, for callers that render values the way these
50
+ * filters do (for example the value bound for a boolean parameter).
51
+ */
52
+ get Dialect(): SQLDialect;
47
53
  /**
48
54
  * Sets the database platform, updating platform-sensitive filters accordingly.
49
55
  * Call this during provider initialization to match the active database platform.
@@ -1 +1 @@
1
- {"version":3,"file":"runQuerySQLFilterImplementations.d.ts","sourceRoot":"","sources":["../../src/generic/runQuerySQLFilterImplementations.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,EAAyB,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAC7E,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAoNjD;;;GAGG;AACH,eAAO,MAAM,0CAA0C,EAAE,iBAAiB,EAInE,CAAC;AA4FR;;;;;;GAMG;AACH,qBAAa,wBAAyB,SAAQ,aAAa,CAAC,wBAAwB,CAAC;IACjF,OAAO,CAAC,QAAQ,CAA6C;IAC7D,OAAO,CAAC,SAAS,CAAiC;IAElD;;OAEG;;IAMH;;OAEG;IACH,OAAO,CAAC,iBAAiB;IAWzB;;OAEG;IACH,OAAO,CAAC,sBAAsB;IAuB9B;;OAEG;IACH,WAAkB,QAAQ,IAAI,wBAAwB,CAErD;IAED;;OAEG;IACH,IAAW,QAAQ,IAAI,gBAAgB,CAEtC;IAED;;;OAGG;IACI,WAAW,CAAC,QAAQ,EAAE,gBAAgB,GAAG,IAAI;IAOpD;;;;OAIG;IACI,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,iBAAiB,GAAG,SAAS;IAI7D;;;OAGG;IACI,cAAc,IAAI,MAAM,EAAE;IAIjC;;;OAGG;IACI,aAAa,IAAI,iBAAiB,EAAE;IAI3C;;;;;;OAMG;IACI,aAAa,CAAC,UAAU,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,OAAO;CAOpE"}
1
+ {"version":3,"file":"runQuerySQLFilterImplementations.d.ts","sourceRoot":"","sources":["../../src/generic/runQuerySQLFilterImplementations.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,EAAyB,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAC7E,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAEjD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AAoK9D;;;GAGG;AACH,eAAO,MAAM,0CAA0C,EAAE,iBAAiB,EAInE,CAAC;AAwER;;;;;;GAMG;AACH,qBAAa,wBAAyB,SAAQ,aAAa,CAAC,wBAAwB,CAAC;IACjF,OAAO,CAAC,QAAQ,CAA6C;IAC7D,OAAO,CAAC,SAAS,CAA6C;IAE9D;;OAEG;;IAMH;;OAEG;IACH,OAAO,CAAC,iBAAiB;IAWzB;;OAEG;IACH,OAAO,CAAC,sBAAsB;IAS9B;;OAEG;IACH,WAAkB,QAAQ,IAAI,wBAAwB,CAErD;IAED;;OAEG;IACH,IAAW,QAAQ,IAAI,gBAAgB,CAEtC;IAED;;;OAGG;IACH,IAAW,OAAO,IAAI,UAAU,CAE/B;IAED;;;OAGG;IACI,WAAW,CAAC,QAAQ,EAAE,gBAAgB,GAAG,IAAI;IAOpD;;;;OAIG;IACI,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,iBAAiB,GAAG,SAAS;IAI7D;;;OAGG;IACI,cAAc,IAAI,MAAM,EAAE;IAIjC;;;OAGG;IACI,aAAa,IAAI,iBAAiB,EAAE;IAI3C;;;;;;OAMG;IACI,aAAa,CAAC,UAAU,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,OAAO;CAOpE"}
@@ -8,6 +8,7 @@
8
8
  */
9
9
  import { BaseSingleton } from '@memberjunction/global';
10
10
  import { RUN_QUERY_SQL_FILTERS } from './querySQLFilters.js';
11
+ import { GetDialect } from '@memberjunction/sql-dialect';
11
12
  /**
12
13
  * Dangerous SQL keywords that should be blocked in expressions
13
14
  */
@@ -65,15 +66,16 @@ const ALLOWED_SQL_KEYWORDS = [
65
66
  // Comparison operators (as words)
66
67
  'BETWEEN', 'IN'
67
68
  ];
69
+ /** The platform filters render for until {@link RunQuerySQLFilterManager.SetPlatform} is called. */
70
+ const DEFAULT_FILTER_PLATFORM = 'sqlserver';
71
+ /** The dialect of {@link DEFAULT_FILTER_PLATFORM}, which the exported default implementations use. */
72
+ const DEFAULT_FILTER_DIALECT = GetDialect(DEFAULT_FILTER_PLATFORM);
68
73
  /**
69
- * SQL Filter implementation functions
74
+ * SQL Filter implementation functions. The filters whose output depends on the database come
75
+ * from {@link dialectFilterImplementations}.
70
76
  */
71
77
  const FILTER_IMPLEMENTATIONS = {
72
- sqlString: (value) => {
73
- if (value === null || value === undefined)
74
- return 'NULL';
75
- return `'${String(value).replace(/'/g, "''")}'`;
76
- },
78
+ ...dialectFilterImplementations(DEFAULT_FILTER_DIALECT),
77
79
  sqlNumber: (value) => {
78
80
  const num = Number(value);
79
81
  if (isNaN(num))
@@ -88,57 +90,6 @@ const FILTER_IMPLEMENTATIONS = {
88
90
  throw new Error(`Invalid date: ${value}`);
89
91
  return `'${date.toISOString()}'`;
90
92
  },
91
- sqlBoolean: (value) => {
92
- // Default SQL Server behavior; overridden by platform-aware version in RunQuerySQLFilterManager
93
- return value ? '1' : '0';
94
- },
95
- sqlIdentifier: (value) => {
96
- if (!value)
97
- throw new Error('Identifier cannot be empty');
98
- const identifier = String(value);
99
- // Basic SQL injection prevention for identifiers
100
- if (!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(identifier)) {
101
- throw new Error(`Invalid SQL identifier: ${identifier}`);
102
- }
103
- // Default SQL Server behavior; overridden by platform-aware version in RunQuerySQLFilterManager
104
- return `[${identifier}]`;
105
- },
106
- sqlIn: (values) => {
107
- if (!Array.isArray(values) || values.length === 0) {
108
- return '(NULL)'; // This will match nothing
109
- }
110
- const escaped = values.map(v => {
111
- if (typeof v === 'string') {
112
- return `'${v.replace(/'/g, "''")}'`;
113
- }
114
- else if (typeof v === 'number') {
115
- return v;
116
- }
117
- else if (v === null || v === undefined) {
118
- return 'NULL';
119
- }
120
- return `'${String(v).replace(/'/g, "''")}'`;
121
- });
122
- return `(${escaped.join(', ')})`;
123
- },
124
- sqlLikeContains: (value) => {
125
- if (value === null || value === undefined)
126
- return 'NULL';
127
- const stripped = stripBoundaryWildcards(String(value), 'both');
128
- return `'%${escapeLikeValue(stripped, 'sqlserver')}%'`;
129
- },
130
- sqlLikeBegins: (value) => {
131
- if (value === null || value === undefined)
132
- return 'NULL';
133
- const stripped = stripBoundaryWildcards(String(value), 'trailing');
134
- return `'${escapeLikeValue(stripped, 'sqlserver')}%'`;
135
- },
136
- sqlLikeEnds: (value) => {
137
- if (value === null || value === undefined)
138
- return 'NULL';
139
- const stripped = stripBoundaryWildcards(String(value), 'leading');
140
- return `'%${escapeLikeValue(stripped, 'sqlserver')}'`;
141
- },
142
93
  sqlNoKeywordsExpression: (value) => {
143
94
  if (!value) {
144
95
  throw new Error('SQL expression cannot be empty');
@@ -194,33 +145,33 @@ export const RUN_QUERY_SQL_FILTERS_WITH_IMPLEMENTATIONS = RUN_QUERY_SQL_FILTERS.
194
145
  implementation: FILTER_IMPLEMENTATIONS[filter.name]
195
146
  }));
196
147
  /**
197
- * Creates a platform-aware sqlBoolean filter implementation.
198
- * SQL Server uses 1/0, PostgreSQL uses true/false.
148
+ * The filters whose output depends on the database, rendered for one dialect: string and IN-list
149
+ * literals, booleans, identifiers and the three LIKE filters. Every platform difference comes
150
+ * from the dialect, so a new platform needs no change here.
199
151
  */
200
- function createPlatformSqlBoolean(platform) {
201
- return (value) => {
202
- if (platform === 'postgresql') {
203
- return value ? 'true' : 'false';
204
- }
205
- return value ? '1' : '0';
206
- };
207
- }
208
- /**
209
- * Creates a platform-aware sqlIdentifier filter implementation.
210
- * SQL Server uses [brackets], PostgreSQL uses "double quotes".
211
- */
212
- function createPlatformSqlIdentifier(platform) {
213
- return (value) => {
214
- if (!value)
215
- throw new Error('Identifier cannot be empty');
216
- const identifier = String(value);
217
- if (!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(identifier)) {
218
- throw new Error(`Invalid SQL identifier: ${identifier}`);
219
- }
220
- if (platform === 'postgresql') {
221
- return `"${identifier}"`;
222
- }
223
- return `[${identifier}]`;
152
+ function dialectFilterImplementations(dialect) {
153
+ return {
154
+ sqlString: (value) => (value === null || value === undefined ? 'NULL' : textLiteral(value, dialect)),
155
+ sqlIn: (values) => {
156
+ if (!Array.isArray(values) || values.length === 0) {
157
+ return '(NULL)'; // matches nothing
158
+ }
159
+ const items = values.map(v => typeof v === 'number' ? String(v) : v === null || v === undefined ? 'NULL' : textLiteral(v, dialect));
160
+ return `(${items.join(', ')})`;
161
+ },
162
+ sqlBoolean: (value) => dialect.BooleanLiteral(Boolean(value)),
163
+ sqlIdentifier: (value) => {
164
+ if (!value)
165
+ throw new Error('Identifier cannot be empty');
166
+ const identifier = String(value);
167
+ if (!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(identifier)) {
168
+ throw new Error(`Invalid SQL identifier: ${identifier}`);
169
+ }
170
+ return dialect.QuoteIdentifier(identifier);
171
+ },
172
+ sqlLikeContains: (value) => likeLiteral(value, 'both', dialect),
173
+ sqlLikeBegins: (value) => likeLiteral(value, 'trailing', dialect),
174
+ sqlLikeEnds: (value) => likeLiteral(value, 'leading', dialect),
224
175
  };
225
176
  }
226
177
  /**
@@ -242,43 +193,24 @@ function stripBoundaryWildcards(value, side) {
242
193
  }
243
194
  }
244
195
  /**
245
- * Escapes literal % and _ characters inside a LIKE value in a platform-aware way.
246
- * SQL Server uses bracket escaping [%] [_]; PostgreSQL uses backslash escaping \% \_.
247
- */
248
- function escapeLikeValue(value, platform) {
249
- const escaped = value.replace(/'/g, "''");
250
- if (platform === 'postgresql') {
251
- return escaped.replace(/%/g, '\\%').replace(/_/g, '\\_');
252
- }
253
- return escaped.replace(/%/g, '[%]').replace(/_/g, '[_]');
254
- }
255
- /**
256
- * Creates platform-aware sqlLike filter implementations.
257
- * SQL Server escapes with [%]/[_], PostgreSQL escapes with \%/\_.
196
+ * A LIKE pattern literal that matches `value` literally, with `%` added on the open side(s):
197
+ * `both` for contains, `trailing` for begins-with, `leading` for ends-with. User-supplied `%` on
198
+ * those sides is dropped first, and every other character LIKE treats specially is escaped by
199
+ * the dialect.
258
200
  */
259
- function createPlatformSqlLikeContains(platform) {
260
- return (value) => {
261
- if (value === null || value === undefined)
262
- return 'NULL';
263
- const stripped = stripBoundaryWildcards(String(value), 'both');
264
- return `'%${escapeLikeValue(stripped, platform)}%'`;
265
- };
201
+ function likeLiteral(value, wildcardSide, dialect) {
202
+ if (value === null || value === undefined)
203
+ return 'NULL';
204
+ const stripped = stripBoundaryWildcards(String(value), wildcardSide);
205
+ const pattern = dialect.EscapeLikePattern(stripped.replace(/'/g, "''"));
206
+ const before = wildcardSide === 'trailing' ? '' : '%';
207
+ const after = wildcardSide === 'leading' ? '' : '%';
208
+ return `${dialect.StringLiteralPrefix(stripped)}'${before}${pattern}${after}'`;
266
209
  }
267
- function createPlatformSqlLikeBegins(platform) {
268
- return (value) => {
269
- if (value === null || value === undefined)
270
- return 'NULL';
271
- const stripped = stripBoundaryWildcards(String(value), 'trailing');
272
- return `'${escapeLikeValue(stripped, platform)}%'`;
273
- };
274
- }
275
- function createPlatformSqlLikeEnds(platform) {
276
- return (value) => {
277
- if (value === null || value === undefined)
278
- return 'NULL';
279
- const stripped = stripBoundaryWildcards(String(value), 'leading');
280
- return `'%${escapeLikeValue(stripped, platform)}'`;
281
- };
210
+ /** A string literal for `value` with the dialect's prefix: quotes doubled, null bytes removed. */
211
+ function textLiteral(value, dialect) {
212
+ const text = String(value);
213
+ return `${dialect.StringLiteralPrefix(text)}'${text.replace(/\0/g, '').replace(/'/g, "''")}'`;
282
214
  }
283
215
  /**
284
216
  * Singleton class for managing RunQuery SQL filters with implementations.
@@ -294,7 +226,7 @@ export class RunQuerySQLFilterManager extends BaseSingleton {
294
226
  constructor() {
295
227
  super();
296
228
  this._filters = new Map();
297
- this._platform = 'sqlserver';
229
+ this._platform = DEFAULT_FILTER_PLATFORM;
298
230
  this.initializeFilters();
299
231
  }
300
232
  /**
@@ -311,28 +243,14 @@ export class RunQuerySQLFilterManager extends BaseSingleton {
311
243
  this.applyPlatformOverrides();
312
244
  }
313
245
  /**
314
- * Applies platform-specific overrides for sqlBoolean and sqlIdentifier filters.
246
+ * Installs the dialect-sensitive filters for the current platform's dialect.
315
247
  */
316
248
  applyPlatformOverrides() {
317
- const boolFilter = this._filters.get('sqlBoolean');
318
- if (boolFilter) {
319
- boolFilter.implementation = createPlatformSqlBoolean(this._platform);
320
- }
321
- const idFilter = this._filters.get('sqlIdentifier');
322
- if (idFilter) {
323
- idFilter.implementation = createPlatformSqlIdentifier(this._platform);
324
- }
325
- const likeContainsFilter = this._filters.get('sqlLikeContains');
326
- if (likeContainsFilter) {
327
- likeContainsFilter.implementation = createPlatformSqlLikeContains(this._platform);
328
- }
329
- const likeBeginsFilter = this._filters.get('sqlLikeBegins');
330
- if (likeBeginsFilter) {
331
- likeBeginsFilter.implementation = createPlatformSqlLikeBegins(this._platform);
332
- }
333
- const likeEndsFilter = this._filters.get('sqlLikeEnds');
334
- if (likeEndsFilter) {
335
- likeEndsFilter.implementation = createPlatformSqlLikeEnds(this._platform);
249
+ for (const [name, implementation] of Object.entries(dialectFilterImplementations(GetDialect(this._platform)))) {
250
+ const filter = this._filters.get(name);
251
+ if (filter) {
252
+ filter.implementation = implementation;
253
+ }
336
254
  }
337
255
  }
338
256
  /**
@@ -347,6 +265,13 @@ export class RunQuerySQLFilterManager extends BaseSingleton {
347
265
  get Platform() {
348
266
  return this._platform;
349
267
  }
268
+ /**
269
+ * The SQL dialect of the current platform, for callers that render values the way these
270
+ * filters do (for example the value bound for a boolean parameter).
271
+ */
272
+ get Dialect() {
273
+ return GetDialect(this._platform);
274
+ }
350
275
  /**
351
276
  * Sets the database platform, updating platform-sensitive filters accordingly.
352
277
  * Call this during provider initialization to match the active database platform.
@@ -1 +1 @@
1
- {"version":3,"file":"runQuerySQLFilterImplementations.js","sourceRoot":"","sources":["../../src/generic/runQuerySQLFilterImplementations.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,EAAE,qBAAqB,EAAqB,MAAM,mBAAmB,CAAC;AAG7E;;GAEG;AACH,MAAM,sBAAsB,GAAG;IAC3B,0DAA0D;IAC1D,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,UAAU,EAAE,QAAQ;IAE/C,yDAAyD;IACzD,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,OAAO,EAAE,SAAS;IAEhD,4CAA4C;IAC5C,OAAO,EAAE,QAAQ,EAAE,MAAM;IAEzB,2BAA2B;IAC3B,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,WAAW,EAAE,UAAU;IAElD,sBAAsB;IACtB,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,WAAW;IAE1C,6BAA6B;IAC7B,KAAK,EAAE,UAAU,EAAE,QAAQ;IAE3B,gDAAgD;IAChD,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM;IAEpC,iCAAiC;IACjC,QAAQ,EAAE,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,QAAQ;IAC9C,MAAM,EAAE,UAAU,EAAE,SAAS;IAE7B,uDAAuD;IACvD,OAAO,EAAE,WAAW,EAAE,QAAQ;IAE9B,4CAA4C;IAC5C,QAAQ,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM;IAE9B,yCAAyC;IACzC,IAAI,EAAE,IAAI,E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CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAC;IAC5C,CAAC;IAED;;;OAGG;IACI,aAAa;QAChB,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAC;IAC9C,CAAC;IAED;;;;;;OAMG;IACI,aAAa,CAAC,UAAkB,EAAE,KAAc;QACnD,MAAM,MAAM,GAAG,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;QAC7C,IAAI,CAAC,MAAM,IAAI,CAAC,MAAM,CAAC,cAAc,EAAE,CAAC;YACpC,MAAM,IAAI,KAAK,CAAC,WAAW,UAAU,sCAAsC,CAAC,CAAC;QACjF,CAAC;QACD,OAAO,MAAM,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC;IACxC,CAAC;CACJ"}
@@ -293,6 +293,11 @@ export interface TelemetrySettings {
293
293
  autoTrim: {
294
294
  enabled: boolean;
295
295
  maxEvents?: number;
296
+ /**
297
+ * Cap on retained analyzer insights. Like `maxEvents`, but for the derived collection:
298
+ * one insight is appended per emitted warning and they were never released.
299
+ */
300
+ maxInsights?: number;
296
301
  maxAgeMs?: number;
297
302
  };
298
303
  /** Duplicate detection settings */
@@ -442,6 +447,12 @@ export declare class TelemetryManager extends BaseSingleton<TelemetryManager> {
442
447
  private _analyzers;
443
448
  private _insights;
444
449
  private _insightDedupeWindow;
450
+ /**
451
+ * When the two map sweeps in {@link trimIfNeeded} last ran. They are O(n) over their maps,
452
+ * while `trimIfNeeded` itself runs on every recorded event, so they are throttled rather than
453
+ * paid per event.
454
+ */
455
+ private _lastDeepTrimAt;
445
456
  /**
446
457
  * Returns the singleton instance of TelemetryManager
447
458
  */