@memberjunction/core 5.11.0 → 5.13.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/QueryCache.d.ts +41 -7
- package/dist/generic/QueryCache.d.ts.map +1 -1
- package/dist/generic/QueryCache.js +146 -12
- package/dist/generic/QueryCache.js.map +1 -1
- package/dist/generic/QueryCacheManager.d.ts +105 -0
- package/dist/generic/QueryCacheManager.d.ts.map +1 -0
- package/dist/generic/QueryCacheManager.js +314 -0
- package/dist/generic/QueryCacheManager.js.map +1 -0
- 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/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.js +3 -3
- package/dist/generic/providerBase.js.map +1 -1
- package/dist/generic/queryCompositionEngine.d.ts +7 -0
- package/dist/generic/queryCompositionEngine.d.ts.map +1 -1
- package/dist/generic/queryCompositionEngine.js +41 -5
- package/dist/generic/queryCompositionEngine.js.map +1 -1
- package/dist/generic/queryInfoInterfaces.d.ts +6 -0
- package/dist/generic/queryInfoInterfaces.d.ts.map +1 -1
- package/dist/generic/queryPagingEngine.d.ts +110 -0
- package/dist/generic/queryPagingEngine.d.ts.map +1 -0
- package/dist/generic/queryPagingEngine.js +335 -0
- package/dist/generic/queryPagingEngine.js.map +1 -0
- package/dist/generic/runQuery.d.ts +8 -0
- package/dist/generic/runQuery.d.ts.map +1 -1
- package/dist/generic/runQuery.js.map +1 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -1
- 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
|
@@ -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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