@memberjunction/core 5.12.0 → 5.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/generic/QueryCacheManager.d.ts +12 -2
- package/dist/generic/QueryCacheManager.d.ts.map +1 -1
- package/dist/generic/QueryCacheManager.js +17 -3
- package/dist/generic/QueryCacheManager.js.map +1 -1
- package/dist/generic/baseEntity.js +2 -2
- package/dist/generic/baseEntity.js.map +1 -1
- package/dist/generic/dataHooks.d.ts +56 -0
- package/dist/generic/dataHooks.d.ts.map +1 -0
- package/dist/generic/dataHooks.js +56 -0
- package/dist/generic/dataHooks.js.map +1 -0
- package/dist/generic/databaseProviderBase.d.ts +7 -1
- package/dist/generic/databaseProviderBase.d.ts.map +1 -1
- package/dist/generic/databaseProviderBase.js.map +1 -1
- package/dist/generic/interfaces.d.ts +10 -0
- package/dist/generic/interfaces.d.ts.map +1 -1
- package/dist/generic/interfaces.js.map +1 -1
- package/dist/generic/providerBase.d.ts +15 -18
- package/dist/generic/providerBase.d.ts.map +1 -1
- package/dist/generic/providerBase.js +19 -33
- package/dist/generic/providerBase.js.map +1 -1
- package/dist/generic/queryExecutionSpec.d.ts +68 -0
- package/dist/generic/queryExecutionSpec.d.ts.map +1 -0
- package/dist/generic/queryExecutionSpec.js +45 -0
- package/dist/generic/queryExecutionSpec.js.map +1 -0
- package/dist/generic/runQuery.d.ts +10 -0
- package/dist/generic/runQuery.d.ts.map +1 -1
- package/dist/generic/runQuery.js +11 -0
- package/dist/generic/runQuery.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/dist/generic/hookRegistry.d.ts +0 -83
- package/dist/generic/hookRegistry.d.ts.map +0 -1
- package/dist/generic/hookRegistry.js +0 -87
- package/dist/generic/hookRegistry.js.map +0 -1
- package/dist/generic/queryCompositionEngine.d.ts +0 -165
- package/dist/generic/queryCompositionEngine.d.ts.map +0 -1
- package/dist/generic/queryCompositionEngine.js +0 -464
- package/dist/generic/queryCompositionEngine.js.map +0 -1
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
import type { RunViewResult } from './interfaces.js';
|
|
2
|
-
import type { RunViewParams } from '../views/runView.js';
|
|
3
|
-
import type { UserInfo } from './securityInfo.js';
|
|
4
|
-
import type { BaseEntity } from './baseEntity.js';
|
|
5
|
-
/**
|
|
6
|
-
* Hook that runs before a RunView operation. Can modify the RunViewParams
|
|
7
|
-
* (e.g., injecting tenant filters) before execution.
|
|
8
|
-
* Return the (possibly modified) params to continue, or throw to abort.
|
|
9
|
-
*/
|
|
10
|
-
export type PreRunViewHook = (params: RunViewParams, contextUser: UserInfo | undefined) => RunViewParams | Promise<RunViewParams>;
|
|
11
|
-
/**
|
|
12
|
-
* Hook that runs after a RunView operation completes. Can modify the result
|
|
13
|
-
* (e.g., filtering or augmenting data) before it is returned to the caller.
|
|
14
|
-
*/
|
|
15
|
-
export type PostRunViewHook = (params: RunViewParams, results: RunViewResult, contextUser: UserInfo | undefined) => RunViewResult | Promise<RunViewResult>;
|
|
16
|
-
/**
|
|
17
|
-
* Hook that runs before a Save operation on a BaseEntity.
|
|
18
|
-
* Return `true` to allow the save, `false` to reject silently,
|
|
19
|
-
* or a string to reject with that error message.
|
|
20
|
-
*/
|
|
21
|
-
export type PreSaveHook = (entity: BaseEntity, contextUser: UserInfo | undefined) => boolean | string | Promise<boolean | string>;
|
|
22
|
-
/** Well-known hook names used by the registry */
|
|
23
|
-
export type HookName = 'PreRunView' | 'PostRunView' | 'PreSave';
|
|
24
|
-
/**
|
|
25
|
-
* Options for controlling hook registration behavior.
|
|
26
|
-
*/
|
|
27
|
-
export interface HookRegistrationOptions {
|
|
28
|
-
/**
|
|
29
|
-
* Numeric priority. Lower numbers run first. Default: 100.
|
|
30
|
-
*
|
|
31
|
-
* Convention:
|
|
32
|
-
* - MJ built-in hooks: 50
|
|
33
|
-
* - Middle-layer hooks (e.g., SaaS layer): 100
|
|
34
|
-
* - Application-level hooks: 200+
|
|
35
|
-
*/
|
|
36
|
-
Priority?: number;
|
|
37
|
-
/**
|
|
38
|
-
* Unique namespace for this hook (e.g., 'mj:tenantFilter', 'bcsaas:tenantFilter').
|
|
39
|
-
*
|
|
40
|
-
* When registering with a namespace that already exists for this hook name,
|
|
41
|
-
* the old hook is **replaced** rather than appended. This allows a middle layer
|
|
42
|
-
* to override MJ's generic hook without causing double execution.
|
|
43
|
-
*/
|
|
44
|
-
Namespace?: string;
|
|
45
|
-
}
|
|
46
|
-
/**
|
|
47
|
-
* Global hook registry backed by GetGlobalObjectStore() so it works
|
|
48
|
-
* reliably across bundler code-splits (same pattern as BaseSingleton).
|
|
49
|
-
*
|
|
50
|
-
* Lives in @memberjunction/core so both ProviderBase and BaseEntity can
|
|
51
|
-
* consume it without circular dependencies on @memberjunction/server.
|
|
52
|
-
*/
|
|
53
|
-
export declare class HookRegistry {
|
|
54
|
-
/**
|
|
55
|
-
* Returns the backing store map, creating it lazily on first access.
|
|
56
|
-
*/
|
|
57
|
-
private static get _store();
|
|
58
|
-
/**
|
|
59
|
-
* Register a hook function under the given name.
|
|
60
|
-
*
|
|
61
|
-
* When `options.Namespace` is provided and a hook with the same namespace already
|
|
62
|
-
* exists for this hook name, the old hook is replaced. Otherwise the hook is appended.
|
|
63
|
-
*
|
|
64
|
-
* Hooks are returned by `GetHooks` in ascending priority order (lower = first).
|
|
65
|
-
* The default priority is 100.
|
|
66
|
-
*/
|
|
67
|
-
static Register<T>(hookName: HookName | string, hook: T, options?: HookRegistrationOptions): void;
|
|
68
|
-
/**
|
|
69
|
-
* Retrieve all hooks registered under the given name, in priority order (lowest first).
|
|
70
|
-
* Returns an empty array if none are registered (safe for iteration).
|
|
71
|
-
*/
|
|
72
|
-
static GetHooks<T>(hookName: HookName | string): T[];
|
|
73
|
-
/**
|
|
74
|
-
* Remove all hooks registered under the given name.
|
|
75
|
-
* Useful for testing or server restart scenarios.
|
|
76
|
-
*/
|
|
77
|
-
static Clear(hookName: HookName | string): void;
|
|
78
|
-
/**
|
|
79
|
-
* Remove all hooks from all names.
|
|
80
|
-
*/
|
|
81
|
-
static ClearAll(): void;
|
|
82
|
-
}
|
|
83
|
-
//# sourceMappingURL=hookRegistry.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"hookRegistry.d.ts","sourceRoot":"","sources":["../../src/generic/hookRegistry.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE/C;;;;GAIG;AACH,MAAM,MAAM,cAAc,GAAG,CAC3B,MAAM,EAAE,aAAa,EACrB,WAAW,EAAE,QAAQ,GAAG,SAAS,KAC9B,aAAa,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC;AAE5C;;;GAGG;AACH,MAAM,MAAM,eAAe,GAAG,CAC5B,MAAM,EAAE,aAAa,EACrB,OAAO,EAAE,aAAa,EACtB,WAAW,EAAE,QAAQ,GAAG,SAAS,KAC9B,aAAa,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC;AAE5C;;;;GAIG;AACH,MAAM,MAAM,WAAW,GAAG,CACxB,MAAM,EAAE,UAAU,EAClB,WAAW,EAAE,QAAQ,GAAG,SAAS,KAC9B,OAAO,GAAG,MAAM,GAAG,OAAO,CAAC,OAAO,GAAG,MAAM,CAAC,CAAC;AAElD,iDAAiD;AACjD,MAAM,MAAM,QAAQ,GAAG,YAAY,GAAG,aAAa,GAAG,SAAS,CAAC;AAEhE;;GAEG;AACH,MAAM,WAAW,uBAAuB;IACtC;;;;;;;OAOG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB;;;;;;OAMG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAWD;;;;;;GAMG;AACH,qBAAa,YAAY;IACvB;;OAEG;IACH,OAAO,CAAC,MAAM,KAAK,MAAM,GASxB;IAED;;;;;;;;OAQG;IACH,MAAM,CAAC,QAAQ,CAAC,CAAC,EAAE,QAAQ,EAAE,QAAQ,GAAG,MAAM,EAAE,IAAI,EAAE,CAAC,EAAE,OAAO,CAAC,EAAE,uBAAuB,GAAG,IAAI;IA8BjG;;;OAGG;IACH,MAAM,CAAC,QAAQ,CAAC,CAAC,EAAE,QAAQ,EAAE,QAAQ,GAAG,MAAM,GAAG,CAAC,EAAE;IAMpD;;;OAGG;IACH,MAAM,CAAC,KAAK,CAAC,QAAQ,EAAE,QAAQ,GAAG,MAAM,GAAG,IAAI;IAK/C;;OAEG;IACH,MAAM,CAAC,QAAQ,IAAI,IAAI;CAMxB"}
|
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
import { GetGlobalObjectStore } from '@memberjunction/global';
|
|
2
|
-
const REGISTRY_KEY = '__mj_hookRegistry';
|
|
3
|
-
/**
|
|
4
|
-
* Global hook registry backed by GetGlobalObjectStore() so it works
|
|
5
|
-
* reliably across bundler code-splits (same pattern as BaseSingleton).
|
|
6
|
-
*
|
|
7
|
-
* Lives in @memberjunction/core so both ProviderBase and BaseEntity can
|
|
8
|
-
* consume it without circular dependencies on @memberjunction/server.
|
|
9
|
-
*/
|
|
10
|
-
export class HookRegistry {
|
|
11
|
-
/**
|
|
12
|
-
* Returns the backing store map, creating it lazily on first access.
|
|
13
|
-
*/
|
|
14
|
-
static get _store() {
|
|
15
|
-
const gos = GetGlobalObjectStore();
|
|
16
|
-
if (!gos) {
|
|
17
|
-
throw new Error('HookRegistry: GlobalObjectStore is not available');
|
|
18
|
-
}
|
|
19
|
-
if (!gos[REGISTRY_KEY]) {
|
|
20
|
-
gos[REGISTRY_KEY] = {};
|
|
21
|
-
}
|
|
22
|
-
return gos[REGISTRY_KEY];
|
|
23
|
-
}
|
|
24
|
-
/**
|
|
25
|
-
* Register a hook function under the given name.
|
|
26
|
-
*
|
|
27
|
-
* When `options.Namespace` is provided and a hook with the same namespace already
|
|
28
|
-
* exists for this hook name, the old hook is replaced. Otherwise the hook is appended.
|
|
29
|
-
*
|
|
30
|
-
* Hooks are returned by `GetHooks` in ascending priority order (lower = first).
|
|
31
|
-
* The default priority is 100.
|
|
32
|
-
*/
|
|
33
|
-
static Register(hookName, hook, options) {
|
|
34
|
-
const store = HookRegistry._store;
|
|
35
|
-
if (!store[hookName]) {
|
|
36
|
-
store[hookName] = [];
|
|
37
|
-
}
|
|
38
|
-
const entry = {
|
|
39
|
-
hook,
|
|
40
|
-
priority: options?.Priority ?? 100,
|
|
41
|
-
namespace: options?.Namespace,
|
|
42
|
-
};
|
|
43
|
-
const hooks = store[hookName];
|
|
44
|
-
// If namespace is provided and already exists, replace it
|
|
45
|
-
if (entry.namespace) {
|
|
46
|
-
const existingIndex = hooks.findIndex(h => h.namespace === entry.namespace);
|
|
47
|
-
if (existingIndex >= 0) {
|
|
48
|
-
hooks[existingIndex] = entry;
|
|
49
|
-
}
|
|
50
|
-
else {
|
|
51
|
-
hooks.push(entry);
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
else {
|
|
55
|
-
hooks.push(entry);
|
|
56
|
-
}
|
|
57
|
-
// Sort by priority (lower first), stable for equal priorities
|
|
58
|
-
hooks.sort((a, b) => a.priority - b.priority);
|
|
59
|
-
}
|
|
60
|
-
/**
|
|
61
|
-
* Retrieve all hooks registered under the given name, in priority order (lowest first).
|
|
62
|
-
* Returns an empty array if none are registered (safe for iteration).
|
|
63
|
-
*/
|
|
64
|
-
static GetHooks(hookName) {
|
|
65
|
-
const store = HookRegistry._store;
|
|
66
|
-
const entries = store[hookName] ?? [];
|
|
67
|
-
return entries.map(e => e.hook);
|
|
68
|
-
}
|
|
69
|
-
/**
|
|
70
|
-
* Remove all hooks registered under the given name.
|
|
71
|
-
* Useful for testing or server restart scenarios.
|
|
72
|
-
*/
|
|
73
|
-
static Clear(hookName) {
|
|
74
|
-
const store = HookRegistry._store;
|
|
75
|
-
delete store[hookName];
|
|
76
|
-
}
|
|
77
|
-
/**
|
|
78
|
-
* Remove all hooks from all names.
|
|
79
|
-
*/
|
|
80
|
-
static ClearAll() {
|
|
81
|
-
const gos = GetGlobalObjectStore();
|
|
82
|
-
if (gos) {
|
|
83
|
-
gos[REGISTRY_KEY] = {};
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
//# sourceMappingURL=hookRegistry.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"hookRegistry.js","sourceRoot":"","sources":["../../src/generic/hookRegistry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAsE9D,MAAM,YAAY,GAAG,mBAAmB,CAAC;AAEzC;;;;;;GAMG;AACH,MAAM,OAAO,YAAY;IACvB;;OAEG;IACK,MAAM,KAAK,MAAM;QACvB,MAAM,GAAG,GAAG,oBAAoB,EAAE,CAAC;QACnC,IAAI,CAAC,GAAG,EAAE,CAAC;YACT,MAAM,IAAI,KAAK,CAAC,kDAAkD,CAAC,CAAC;QACtE,CAAC;QACD,IAAI,CAAC,GAAG,CAAC,YAAY,CAAC,EAAE,CAAC;YACvB,GAAG,CAAC,YAAY,CAAC,GAAG,EAAE,CAAC;QACzB,CAAC;QACD,OAAO,GAAG,CAAC,YAAY,CAAgC,CAAC;IAC1D,CAAC;IAED;;;;;;;;OAQG;IACH,MAAM,CAAC,QAAQ,CAAI,QAA2B,EAAE,IAAO,EAAE,OAAiC;QACxF,MAAM,KAAK,GAAG,YAAY,CAAC,MAAM,CAAC;QAClC,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,EAAE,CAAC;YACrB,KAAK,CAAC,QAAQ,CAAC,GAAG,EAAE,CAAC;QACvB,CAAC;QAED,MAAM,KAA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Q;QACb,MAAM,GAAG,GAAG,oBAAoB,EAAE,CAAC;QACnC,IAAI,GAAG,EAAE,CAAC;YACR,GAAG,CAAC,YAAY,CAAC,GAAG,EAAE,CAAC;QACzB,CAAC;IACH,CAAC;CACF"}
|
|
@@ -1,165 +0,0 @@
|
|
|
1
|
-
import { DatabasePlatform } from "./platformSQL.js";
|
|
2
|
-
import { UserInfo } from "./securityInfo.js";
|
|
3
|
-
/**
|
|
4
|
-
* Metadata about a single CTE generated during composition resolution.
|
|
5
|
-
*/
|
|
6
|
-
export interface CompositionCTEInfo {
|
|
7
|
-
/** ID of the referenced query */
|
|
8
|
-
QueryID: string;
|
|
9
|
-
/** Name of the referenced query */
|
|
10
|
-
QueryName: string;
|
|
11
|
-
/** Category path as written in the reference */
|
|
12
|
-
CategoryPath: string;
|
|
13
|
-
/** Generated CTE alias name */
|
|
14
|
-
CTEName: string;
|
|
15
|
-
/** Original SQL of the referenced query before parameter resolution */
|
|
16
|
-
OriginalSQL: string;
|
|
17
|
-
/** SQL after parameter values have been substituted */
|
|
18
|
-
ResolvedSQL: string;
|
|
19
|
-
/** Parameter values applied (key → resolved value) */
|
|
20
|
-
Parameters: Record<string, string>;
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* Result returned by the composition engine after resolving all {{query:"..."}} tokens.
|
|
24
|
-
*/
|
|
25
|
-
export interface CompositionResult {
|
|
26
|
-
/** The fully resolved SQL with CTEs prepended */
|
|
27
|
-
ResolvedSQL: string;
|
|
28
|
-
/** Metadata about each CTE generated */
|
|
29
|
-
CTEs: CompositionCTEInfo[];
|
|
30
|
-
/** Directed dependency graph: queryId → [dependsOnQueryIds] */
|
|
31
|
-
DependencyGraph: Map<string, string[]>;
|
|
32
|
-
/** Whether any composition tokens were found and resolved */
|
|
33
|
-
HasCompositions: boolean;
|
|
34
|
-
}
|
|
35
|
-
/**
|
|
36
|
-
* Parsed representation of a single {{query:"..."}} token found in SQL.
|
|
37
|
-
*/
|
|
38
|
-
interface ParsedCompositionToken {
|
|
39
|
-
/** The full original token text including {{ and }} */
|
|
40
|
-
FullToken: string;
|
|
41
|
-
/** Category path segments (everything before the query name) */
|
|
42
|
-
CategorySegments: string[];
|
|
43
|
-
/** The query name (last path segment) */
|
|
44
|
-
QueryName: string;
|
|
45
|
-
/** Full path as written (CategorySegments joined with /) */
|
|
46
|
-
FullPath: string;
|
|
47
|
-
/** Parsed parameter mappings */
|
|
48
|
-
Parameters: ParsedParameter[];
|
|
49
|
-
}
|
|
50
|
-
/**
|
|
51
|
-
* A single parameter from a composition reference.
|
|
52
|
-
*/
|
|
53
|
-
interface ParsedParameter {
|
|
54
|
-
/** Parameter name */
|
|
55
|
-
Name: string;
|
|
56
|
-
/** If quoted literal: the static value. Otherwise null. */
|
|
57
|
-
StaticValue: string | null;
|
|
58
|
-
/** If bare name: the pass-through parameter name from the outer query. Otherwise null. */
|
|
59
|
-
PassThroughName: string | null;
|
|
60
|
-
}
|
|
61
|
-
/**
|
|
62
|
-
* QueryCompositionEngine resolves {{query:"CategoryPath/QueryName(params)"}} tokens
|
|
63
|
-
* in query SQL into Common Table Expressions (CTEs). It handles:
|
|
64
|
-
*
|
|
65
|
-
* - Recursive resolution of nested compositions
|
|
66
|
-
* - Cycle detection via an in-progress set
|
|
67
|
-
* - Parameter modes: static literals and pass-through from outer query
|
|
68
|
-
* - Deduplication of identical query+params references
|
|
69
|
-
* - Platform-aware SQL resolution via QueryInfo.GetPlatformSQL()
|
|
70
|
-
*
|
|
71
|
-
* This engine runs BEFORE Nunjucks template processing, so regular {{param}}
|
|
72
|
-
* tokens are preserved for later substitution.
|
|
73
|
-
*/
|
|
74
|
-
export declare class QueryCompositionEngine {
|
|
75
|
-
/**
|
|
76
|
-
* Checks whether SQL contains any {{query:"..."}} composition tokens.
|
|
77
|
-
* Use this as a fast guard before calling ResolveComposition().
|
|
78
|
-
* Only considers tokens outside of SQL comments.
|
|
79
|
-
*/
|
|
80
|
-
HasCompositionTokens(sql: string): boolean;
|
|
81
|
-
/**
|
|
82
|
-
* Parses all {{query:"..."}} tokens from SQL without resolving them.
|
|
83
|
-
* Useful for dependency extraction during the save pipeline.
|
|
84
|
-
* Only considers tokens outside of SQL comments.
|
|
85
|
-
*
|
|
86
|
-
* @param sql - The SQL text to parse
|
|
87
|
-
* @returns Array of parsed token metadata
|
|
88
|
-
*/
|
|
89
|
-
ParseCompositionTokens(sql: string): ParsedCompositionToken[];
|
|
90
|
-
/**
|
|
91
|
-
* Resolves all {{query:"..."}} composition tokens in the given SQL into CTEs.
|
|
92
|
-
*
|
|
93
|
-
* @param sql - The SQL containing composition tokens
|
|
94
|
-
* @param platform - Target database platform for SQL resolution
|
|
95
|
-
* @param contextUser - User context for permission checks on referenced queries
|
|
96
|
-
* @param outerParams - Parameter values from the outer/parent query (for pass-through resolution)
|
|
97
|
-
* @returns CompositionResult with fully resolved SQL and provenance metadata
|
|
98
|
-
* @throws Error if a referenced query is not found, not composable, or creates a cycle
|
|
99
|
-
*/
|
|
100
|
-
ResolveComposition(sql: string, platform: DatabasePlatform, contextUser: UserInfo, outerParams?: Record<string, string>): CompositionResult;
|
|
101
|
-
/**
|
|
102
|
-
* Recursively resolves composition tokens in SQL, building up CTE entries.
|
|
103
|
-
*/
|
|
104
|
-
private resolveTokensRecursive;
|
|
105
|
-
/**
|
|
106
|
-
* Parses the content inside a {{query:"..."}} token.
|
|
107
|
-
*/
|
|
108
|
-
private parseTokenContent;
|
|
109
|
-
/**
|
|
110
|
-
* Splits parameter string by commas, respecting quoted values.
|
|
111
|
-
*/
|
|
112
|
-
private splitParams;
|
|
113
|
-
/**
|
|
114
|
-
* Looks up a query by category path + name in the metadata provider.
|
|
115
|
-
*/
|
|
116
|
-
private lookupQuery;
|
|
117
|
-
/**
|
|
118
|
-
* Validates that a referenced query is eligible for composition.
|
|
119
|
-
*/
|
|
120
|
-
private validateQueryComposable;
|
|
121
|
-
/**
|
|
122
|
-
* Resolves parameter values for a composition reference.
|
|
123
|
-
* Static values are used directly; pass-through values are looked up from outer params.
|
|
124
|
-
*/
|
|
125
|
-
private resolveParameters;
|
|
126
|
-
/**
|
|
127
|
-
* Substitutes resolved parameter values into a query's SQL.
|
|
128
|
-
* - Static values: replaces {{paramName}} with 'value'
|
|
129
|
-
* - Pass-through values: renames {{paramName}} to {{outerParamName}} so
|
|
130
|
-
* the downstream Nunjucks processor can resolve it from the outer query's parameters.
|
|
131
|
-
*/
|
|
132
|
-
private substituteStaticParams;
|
|
133
|
-
/**
|
|
134
|
-
* Builds a deduplication key for a CTE based on query ID and sorted parameter values.
|
|
135
|
-
*/
|
|
136
|
-
private buildDeduplicationKey;
|
|
137
|
-
/**
|
|
138
|
-
* Generates a SQL-safe CTE name from the query name + short hash for uniqueness.
|
|
139
|
-
*/
|
|
140
|
-
private generateCTEName;
|
|
141
|
-
/**
|
|
142
|
-
* Simple string hash for generating short, deterministic suffixes.
|
|
143
|
-
*/
|
|
144
|
-
private simpleHash;
|
|
145
|
-
/**
|
|
146
|
-
* Assembles CTE entries into a WITH clause prepended to the main SQL.
|
|
147
|
-
*/
|
|
148
|
-
private assembleCTEs;
|
|
149
|
-
/**
|
|
150
|
-
* Strips a trailing ORDER BY clause from SQL that will be wrapped in a CTE.
|
|
151
|
-
* SQL Server (and the SQL standard) disallows ORDER BY inside CTEs unless
|
|
152
|
-
* TOP, OFFSET, or FOR XML is also present. Since reusable queries often
|
|
153
|
-
* include ORDER BY for standalone use, we must remove it when composing.
|
|
154
|
-
*/
|
|
155
|
-
private stripTrailingOrderBy;
|
|
156
|
-
/**
|
|
157
|
-
* Strips SQL comments from the input string so that composition tokens
|
|
158
|
-
* inside comments are not treated as real references.
|
|
159
|
-
* Handles both single-line (-- ...) and multi-line block comments.
|
|
160
|
-
* Preserves string literals (single-quoted) to avoid stripping inside them.
|
|
161
|
-
*/
|
|
162
|
-
private stripSQLComments;
|
|
163
|
-
}
|
|
164
|
-
export {};
|
|
165
|
-
//# sourceMappingURL=queryCompositionEngine.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"queryCompositionEngine.d.ts","sourceRoot":"","sources":["../../src/generic/queryCompositionEngine.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACjD,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AA0B1C;;GAEG;AACH,MAAM,WAAW,kBAAkB;IAC/B,iCAAiC;IACjC,OAAO,EAAE,MAAM,CAAC;IAChB,mCAAmC;IACnC,SAAS,EAAE,MAAM,CAAC;IAClB,gDAAgD;IAChD,YAAY,EAAE,MAAM,CAAC;IACrB,+BAA+B;IAC/B,OAAO,EAAE,MAAM,CAAC;IAChB,uEAAuE;IACvE,WAAW,EAAE,MAAM,CAAC;IACpB,uDAAuD;IACvD,WAAW,EAAE,MAAM,CAAC;IACpB,sDAAsD;IACtD,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACtC;AAED;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAC9B,iDAAiD;IACjD,WAAW,EAAE,MAAM,CAAC;IACpB,wCAAwC;IACxC,IAAI,EAAE,kBAAkB,EAAE,CAAC;IAC3B,+DAA+D;IAC/D,eAAe,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;IACvC,6DAA6D;IAC7D,eAAe,EAAE,OAAO,CAAC;CAC5B;AAED;;GAEG;AACH,UAAU,sBAAsB;IAC5B,uDAAuD;IACvD,SAAS,EAAE,MAAM,CAAC;IAClB,gEAAgE;IAChE,gBAAgB,EAAE,MAAM,EAAE,CAAC;IAC3B,yCAAyC;IACzC,SAAS,EAAE,MAAM,CAAC;IAClB,4DAA4D;IAC5D,QAAQ,EAAE,MAAM,CAAC;IACjB,gCAAgC;IAChC,UAAU,EAAE,eAAe,EAAE,CAAC;CACjC;AAED;;GAEG;AACH,UAAU,eAAe;IACrB,qBAAqB;IACrB,IAAI,EAAE,MAAM,CAAC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