@memberjunction/global 5.37.0 → 5.39.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/README.md +43 -0
- package/dist/ClassFactory.d.ts +36 -1
- package/dist/ClassFactory.d.ts.map +1 -1
- package/dist/ClassFactory.js +59 -1
- package/dist/ClassFactory.js.map +1 -1
- package/dist/RegisterClass.d.ts +74 -7
- package/dist/RegisterClass.d.ts.map +1 -1
- package/dist/RegisterClass.js +54 -9
- package/dist/RegisterClass.js.map +1 -1
- package/dist/SQLExpressionValidator.d.ts +1 -1
- package/dist/SQLExpressionValidator.d.ts.map +1 -1
- package/dist/SQLExpressionValidator.js +5 -0
- package/dist/SQLExpressionValidator.js.map +1 -1
- package/dist/__tests__/ClassFactory.test.js +80 -0
- package/dist/__tests__/ClassFactory.test.js.map +1 -1
- package/dist/__tests__/SQLExpressionValidator.test.js +8 -0
- package/dist/__tests__/SQLExpressionValidator.test.js.map +1 -1
- package/dist/__tests__/SerializationUtils.test.d.ts +2 -0
- package/dist/__tests__/SerializationUtils.test.d.ts.map +1 -0
- package/dist/__tests__/SerializationUtils.test.js +34 -0
- package/dist/__tests__/SerializationUtils.test.js.map +1 -0
- package/dist/__tests__/detectRichTextFormat.test.d.ts +2 -0
- package/dist/__tests__/detectRichTextFormat.test.d.ts.map +1 -0
- package/dist/__tests__/detectRichTextFormat.test.js +77 -0
- package/dist/__tests__/detectRichTextFormat.test.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/util/SerializationUtils.d.ts +16 -0
- package/dist/util/SerializationUtils.d.ts.map +1 -0
- package/dist/util/SerializationUtils.js +40 -0
- package/dist/util/SerializationUtils.js.map +1 -0
- package/dist/util.d.ts +31 -0
- package/dist/util.d.ts.map +1 -1
- package/dist/util.js +89 -0
- package/dist/util.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -169,6 +169,49 @@ const entity = MJGlobal.Instance.ClassFactory.CreateInstance<BaseEntity>(
|
|
|
169
169
|
// Returns an instance of the highest-priority registered subclass for 'Users'
|
|
170
170
|
```
|
|
171
171
|
|
|
172
|
+
### Structured registration: `@RegisterClassEx` + metadata
|
|
173
|
+
|
|
174
|
+
When a registration needs anything beyond `(baseClass, key, priority)` — toggling the rarely-used flags, or attaching **metadata** for runtime filtering — reach for `@RegisterClassEx`. It's the same registration under the hood, but accepts a typed options bag instead of trailing positional booleans:
|
|
175
|
+
|
|
176
|
+
```typescript
|
|
177
|
+
import { RegisterClassEx } from '@memberjunction/global';
|
|
178
|
+
|
|
179
|
+
@RegisterClassEx(BaseFormPanel, {
|
|
180
|
+
key: 'content-sources:tag-pipeline',
|
|
181
|
+
skipNullKeyWarning: true,
|
|
182
|
+
metadata: {
|
|
183
|
+
entity: 'MJ: Content Sources',
|
|
184
|
+
slot: 'after-fields',
|
|
185
|
+
sortKey: 100,
|
|
186
|
+
},
|
|
187
|
+
})
|
|
188
|
+
export class TagPipelinePanel extends BaseFormPanel { /* ... */ }
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
The `metadata` field is stored on the `ClassRegistration` and is purely a runtime aid for discovery — it has no effect on the priority / key lookup. Pair it with one of the discovery helpers below:
|
|
192
|
+
|
|
193
|
+
| Helper | Use when … |
|
|
194
|
+
|------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------|
|
|
195
|
+
| `GetAllRegistrationsByMetadata(base, predicate)` | You have structured discriminators (`entity`, `slot`, `sortKey`, etc.) and want to filter on multiple fields. Recommended default. |
|
|
196
|
+
| `GetAllRegistrationsByKeyPrefix(base, prefix)` | Registrations share a structured key prefix (e.g. `"breed:..."` / `"<EntityName>:..."`) and you want everything below that prefix. |
|
|
197
|
+
| `GetAllRegistrationsByKeyPattern(base, regex)` | More nuanced key matching than a prefix can express. |
|
|
198
|
+
|
|
199
|
+
```typescript
|
|
200
|
+
// Discover every panel that should appear in a given form's slot
|
|
201
|
+
const panels = MJGlobal.Instance.ClassFactory.GetAllRegistrationsByMetadata(
|
|
202
|
+
BaseFormPanel,
|
|
203
|
+
(m) => m?.entity === 'MJ: Content Sources' && m?.slot === 'after-fields',
|
|
204
|
+
);
|
|
205
|
+
// Sort by metadata.sortKey, then by Priority, then by registration order
|
|
206
|
+
panels.sort((a, b) => {
|
|
207
|
+
const aSort = (a.Metadata?.sortKey as number) ?? 0;
|
|
208
|
+
const bSort = (b.Metadata?.sortKey as number) ?? 0;
|
|
209
|
+
return bSort !== aSort ? bSort - aSort : b.Priority - a.Priority;
|
|
210
|
+
});
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
`@RegisterClass` also accepts an optional sixth positional `metadata` arg for parity, but the options-bag form scales better past three arguments and reads better at call sites — prefer `@RegisterClassEx` for new code.
|
|
214
|
+
|
|
172
215
|
### Event System
|
|
173
216
|
|
|
174
217
|
MJGlobal provides a publish/subscribe event bus built on RxJS. Events can be observed in real-time or with replay (a `ReplaySubject` buffering up to 100 events for 30 seconds).
|
package/dist/ClassFactory.d.ts
CHANGED
|
@@ -14,6 +14,16 @@ export declare class ClassRegistration {
|
|
|
14
14
|
RootClass: any;
|
|
15
15
|
Key: string | null;
|
|
16
16
|
Priority: number;
|
|
17
|
+
/**
|
|
18
|
+
* Optional structured metadata. Useful when callers want to attach
|
|
19
|
+
* filterable/sortable attributes to a registration without polluting the
|
|
20
|
+
* Key string (e.g. form-panel slots: { entity, slot, sortKey }).
|
|
21
|
+
*
|
|
22
|
+
* Pair with `ClassFactory.GetAllRegistrationsByMetadata()` /
|
|
23
|
+
* `GetAllRegistrationsByKeyPrefix()` / `GetAllRegistrationsByKeyPattern()`
|
|
24
|
+
* to discover registrations beyond exact-key matching.
|
|
25
|
+
*/
|
|
26
|
+
Metadata?: Record<string, unknown>;
|
|
17
27
|
}
|
|
18
28
|
/**
|
|
19
29
|
* ClassFactory is used to register and create instances of classes. It is a singleton class that can be used to register a sub-class for a given base class and key. Do NOT directly attempt to instantiate this class,
|
|
@@ -73,7 +83,7 @@ export declare class ClassFactory {
|
|
|
73
83
|
* @param skipNullKeyWarning If true, will not print a warning if the key is null or undefined. This is useful for cases where you know that the key is not needed and you don't want to see the warning in the console.
|
|
74
84
|
* @param autoRegisterWithRootClass If true, will automatically register the subclass with the root class of the baseClass hierarchy. This ensures proper priority ordering when multiple subclasses are registered in a hierarchy. Defaults to false to preserve the original registration contract where classes are stored under the baseClass you specify.
|
|
75
85
|
*/
|
|
76
|
-
Register(baseClass: unknown, subClass: unknown, key?: string | null, priority?: number, skipNullKeyWarning?: boolean, autoRegisterWithRootClass?: boolean): void;
|
|
86
|
+
Register(baseClass: unknown, subClass: unknown, key?: string | null, priority?: number, skipNullKeyWarning?: boolean, autoRegisterWithRootClass?: boolean, metadata?: Record<string, unknown>): void;
|
|
77
87
|
/**
|
|
78
88
|
* Creates an instance of the class registered for the given base class and key.
|
|
79
89
|
* If no registration is found, will return an instance of the base class.
|
|
@@ -86,6 +96,31 @@ export declare class ClassFactory {
|
|
|
86
96
|
* @returns
|
|
87
97
|
*/
|
|
88
98
|
GetAllRegistrations(baseClass: unknown, key?: string | null): ClassRegistration[];
|
|
99
|
+
/**
|
|
100
|
+
* Returns all registrations for a given base class whose `Key` STARTS WITH the
|
|
101
|
+
* provided prefix (case-insensitive, trimmed). Useful when registrations follow
|
|
102
|
+
* a naming convention with a structured prefix (e.g. `"<EntityName>:..."`).
|
|
103
|
+
*
|
|
104
|
+
* Prefer `GetAllRegistrationsByMetadata` when the discriminating data is
|
|
105
|
+
* structured — putting tuples in the key string is fragile.
|
|
106
|
+
*/
|
|
107
|
+
GetAllRegistrationsByKeyPrefix(baseClass: unknown, keyPrefix: string): ClassRegistration[];
|
|
108
|
+
/**
|
|
109
|
+
* Returns all registrations for a given base class whose `Key` matches the
|
|
110
|
+
* provided regex (tested against the trimmed-but-original-case key). Use for
|
|
111
|
+
* more nuanced discovery patterns than the prefix helper handles.
|
|
112
|
+
*/
|
|
113
|
+
GetAllRegistrationsByKeyPattern(baseClass: unknown, pattern: RegExp): ClassRegistration[];
|
|
114
|
+
/**
|
|
115
|
+
* Returns all registrations for a given base class whose attached `Metadata`
|
|
116
|
+
* bag satisfies the predicate. Registrations with no metadata are passed
|
|
117
|
+
* `undefined` to the predicate.
|
|
118
|
+
*
|
|
119
|
+
* This is the recommended discovery path for structured per-registration
|
|
120
|
+
* data (e.g. form-panel slots that filter by `{ entity, slot }`). It avoids
|
|
121
|
+
* the brittleness of encoding tuples into the Key string.
|
|
122
|
+
*/
|
|
123
|
+
GetAllRegistrationsByMetadata(baseClass: unknown, predicate: (metadata: Record<string, unknown> | undefined, registration: ClassRegistration) => boolean): ClassRegistration[];
|
|
89
124
|
/**
|
|
90
125
|
* Returns the registration with the highest priority for a given base class and key. If key is not provided, will return the registration with the highest priority for the base class.
|
|
91
126
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ClassFactory.d.ts","sourceRoot":"","sources":["../src/ClassFactory.ts"],"names":[],"mappings":"AAAA;;;;;;wGAMwG;AASxG;;GAEG;AACH,qBAAa,iBAAiB;IAE1B,SAAS,EAAE,GAAG,CAAC;IAEf,QAAQ,EAAE,GAAG,CAAC;IAEd,SAAS,EAAE,GAAG,CAAC;IACf,GAAG,EAAE,MAAM,GAAG,IAAI,CAAQ;IAE1B,QAAQ,EAAE,MAAM,CAAK;
|
|
1
|
+
{"version":3,"file":"ClassFactory.d.ts","sourceRoot":"","sources":["../src/ClassFactory.ts"],"names":[],"mappings":"AAAA;;;;;;wGAMwG;AASxG;;GAEG;AACH,qBAAa,iBAAiB;IAE1B,SAAS,EAAE,GAAG,CAAC;IAEf,QAAQ,EAAE,GAAG,CAAC;IAEd,SAAS,EAAE,GAAG,CAAC;IACf,GAAG,EAAE,MAAM,GAAG,IAAI,CAAQ;IAE1B,QAAQ,EAAE,MAAM,CAAK;IACrB;;;;;;;;OAQG;IACH,QAAQ,CAAC,EA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OG;IACI,8BAA8B,CAAC,SAAS,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,GAAG,iBAAiB,EAAE;IAWjG;;;;OAIG;IACI,+BAA+B,CAAC,SAAS,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,GAAG,iBAAiB,EAAE;IAUhG;;;;;;;;OAQG;IACI,6BAA6B,CAChC,SAAS,EAAE,OAAO,EAClB,SAAS,EAAE,CAAC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,EAAE,YAAY,EAAE,iBAAiB,KAAK,OAAO,GACvG,iBAAiB,EAAE;IAUtB;;OAEG;IACI,eAAe,CAAC,SAAS,EAAE,OAAO,EAAE,GAAG,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,iBAAiB,GAAG,IAAI;IAoBzF;;;;;;OAMG;IACI,2BAA2B,CAAC,SAAS,EAAE,OAAO,EAAE,GAAG,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,iBAAiB,EAAE;CAWnG"}
|
package/dist/ClassFactory.js
CHANGED
|
@@ -111,7 +111,7 @@ export class ClassFactory {
|
|
|
111
111
|
* @param skipNullKeyWarning If true, will not print a warning if the key is null or undefined. This is useful for cases where you know that the key is not needed and you don't want to see the warning in the console.
|
|
112
112
|
* @param autoRegisterWithRootClass If true, will automatically register the subclass with the root class of the baseClass hierarchy. This ensures proper priority ordering when multiple subclasses are registered in a hierarchy. Defaults to false to preserve the original registration contract where classes are stored under the baseClass you specify.
|
|
113
113
|
*/
|
|
114
|
-
Register(baseClass, subClass, key = null, priority = 0, skipNullKeyWarning = false, autoRegisterWithRootClass = false) {
|
|
114
|
+
Register(baseClass, subClass, key = null, priority = 0, skipNullKeyWarning = false, autoRegisterWithRootClass = false, metadata) {
|
|
115
115
|
if (baseClass && subClass) {
|
|
116
116
|
const baseClassName = baseClass.name;
|
|
117
117
|
const subClassName = subClass.name;
|
|
@@ -155,6 +155,8 @@ export class ClassFactory {
|
|
|
155
155
|
reg.RootClass = rootClass;
|
|
156
156
|
reg.Key = key;
|
|
157
157
|
reg.Priority = priority;
|
|
158
|
+
if (metadata !== undefined)
|
|
159
|
+
reg.Metadata = metadata;
|
|
158
160
|
this._registrations.push(reg);
|
|
159
161
|
}
|
|
160
162
|
}
|
|
@@ -200,6 +202,62 @@ export class ClassFactory {
|
|
|
200
202
|
else
|
|
201
203
|
return [];
|
|
202
204
|
}
|
|
205
|
+
/**
|
|
206
|
+
* Returns all registrations for a given base class whose `Key` STARTS WITH the
|
|
207
|
+
* provided prefix (case-insensitive, trimmed). Useful when registrations follow
|
|
208
|
+
* a naming convention with a structured prefix (e.g. `"<EntityName>:..."`).
|
|
209
|
+
*
|
|
210
|
+
* Prefer `GetAllRegistrationsByMetadata` when the discriminating data is
|
|
211
|
+
* structured — putting tuples in the key string is fragile.
|
|
212
|
+
*/
|
|
213
|
+
GetAllRegistrationsByKeyPrefix(baseClass, keyPrefix) {
|
|
214
|
+
if (!baseClass || keyPrefix == null)
|
|
215
|
+
return [];
|
|
216
|
+
const baseClassName = baseClass.name;
|
|
217
|
+
const needle = keyPrefix.trim().toLowerCase();
|
|
218
|
+
return this._registrations.filter(r => {
|
|
219
|
+
const regBaseClassName = r.BaseClass.name;
|
|
220
|
+
if (regBaseClassName !== baseClassName)
|
|
221
|
+
return false;
|
|
222
|
+
return r.Key != null && r.Key.trim().toLowerCase().startsWith(needle);
|
|
223
|
+
});
|
|
224
|
+
}
|
|
225
|
+
/**
|
|
226
|
+
* Returns all registrations for a given base class whose `Key` matches the
|
|
227
|
+
* provided regex (tested against the trimmed-but-original-case key). Use for
|
|
228
|
+
* more nuanced discovery patterns than the prefix helper handles.
|
|
229
|
+
*/
|
|
230
|
+
GetAllRegistrationsByKeyPattern(baseClass, pattern) {
|
|
231
|
+
if (!baseClass || !pattern)
|
|
232
|
+
return [];
|
|
233
|
+
const baseClassName = baseClass.name;
|
|
234
|
+
return this._registrations.filter(r => {
|
|
235
|
+
const regBaseClassName = r.BaseClass.name;
|
|
236
|
+
if (regBaseClassName !== baseClassName)
|
|
237
|
+
return false;
|
|
238
|
+
return r.Key != null && pattern.test(r.Key.trim());
|
|
239
|
+
});
|
|
240
|
+
}
|
|
241
|
+
/**
|
|
242
|
+
* Returns all registrations for a given base class whose attached `Metadata`
|
|
243
|
+
* bag satisfies the predicate. Registrations with no metadata are passed
|
|
244
|
+
* `undefined` to the predicate.
|
|
245
|
+
*
|
|
246
|
+
* This is the recommended discovery path for structured per-registration
|
|
247
|
+
* data (e.g. form-panel slots that filter by `{ entity, slot }`). It avoids
|
|
248
|
+
* the brittleness of encoding tuples into the Key string.
|
|
249
|
+
*/
|
|
250
|
+
GetAllRegistrationsByMetadata(baseClass, predicate) {
|
|
251
|
+
if (!baseClass || typeof predicate !== 'function')
|
|
252
|
+
return [];
|
|
253
|
+
const baseClassName = baseClass.name;
|
|
254
|
+
return this._registrations.filter(r => {
|
|
255
|
+
const regBaseClassName = r.BaseClass.name;
|
|
256
|
+
if (regBaseClassName !== baseClassName)
|
|
257
|
+
return false;
|
|
258
|
+
return predicate(r.Metadata, r);
|
|
259
|
+
});
|
|
260
|
+
}
|
|
203
261
|
/**
|
|
204
262
|
* Returns the registration with the highest priority for a given base class and key. If key is not provided, will return the registration with the highest priority for the base class.
|
|
205
263
|
*/
|
package/dist/ClassFactory.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ClassFactory.js","sourceRoot":"","sources":["../src/ClassFactory.ts"],"names":[],"mappings":"AAAA;;;;;;wGAMwG;AAExG,OAAO,EAAE,YAAY,EAAe,MAAM,cAAc,CAAC;AAOzD;;GAEG;AACH,MAAM,OAAO,iBAAiB;IAA9B;QAOI,QAAG,GAAkB,IAAI,CAAC,CAAC,gMAAgM;QAC/M,uGAAuG;QACnH,aAAQ,GAAW,CAAC,CAAC,CAAC,kMAAkM;
|
|
1
|
+
{"version":3,"file":"ClassFactory.js","sourceRoot":"","sources":["../src/ClassFactory.ts"],"names":[],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+1,78 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Options bag accepted by `RegisterClassEx`. Use this when you want named
|
|
3
|
+
* fields instead of a long positional argument list — especially when
|
|
4
|
+
* attaching `metadata` for structured discovery via
|
|
5
|
+
* `ClassFactory.GetAllRegistrationsByMetadata`.
|
|
6
|
+
*
|
|
7
|
+
* Adding a field here is the right way to extend the registration contract
|
|
8
|
+
* going forward — no more "yet another positional parameter."
|
|
9
|
+
*/
|
|
10
|
+
export interface RegisterClassOptions {
|
|
11
|
+
/** Discriminator key used to look up registrations by `GetRegistration` etc. */
|
|
12
|
+
key?: string | null;
|
|
13
|
+
/** Higher = wins ties. See `ClassFactory.Register` for the auto-increment behavior. */
|
|
14
|
+
priority?: number;
|
|
15
|
+
/** Suppress the "registration has no key" console warning. */
|
|
16
|
+
skipNullKeyWarning?: boolean;
|
|
17
|
+
/** Auto-register against the hierarchy root class in addition to `baseClass`. */
|
|
18
|
+
autoRegisterWithRootClass?: boolean;
|
|
19
|
+
/**
|
|
20
|
+
* Arbitrary structured metadata persisted on the `ClassRegistration`. Pair
|
|
21
|
+
* with `ClassFactory.GetAllRegistrationsByMetadata` for structured discovery.
|
|
22
|
+
* Common shapes include `{ entity, slot, sortKey }` for form-panel slots.
|
|
23
|
+
*/
|
|
24
|
+
metadata?: Record<string, unknown>;
|
|
25
|
+
}
|
|
1
26
|
/**
|
|
2
27
|
* Decorate your class with this to register it with the MJGlobal class factory.
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
* @
|
|
8
|
-
*
|
|
28
|
+
*
|
|
29
|
+
* Classic positional form. The fifth and earlier parameters are unchanged from
|
|
30
|
+
* the original signature — existing call sites keep working byte-for-byte.
|
|
31
|
+
*
|
|
32
|
+
* @remarks **Prefer `RegisterClassEx` for new code** when you have anything
|
|
33
|
+
* beyond `(baseClass, key, priority)` to specify — the options-bag signature
|
|
34
|
+
* scales much better than positional booleans, and it's the natural place to
|
|
35
|
+
* attach the structured `metadata` bag used by dynamic discovery features
|
|
36
|
+
* (form-panel slots, etc.). The `metadata` positional param here is provided
|
|
37
|
+
* for parity and brevity, but reads worse than `{ metadata: {...} }` once the
|
|
38
|
+
* decorator wraps onto multiple lines.
|
|
39
|
+
*
|
|
40
|
+
* @param baseClass A reference to the base class you are registering a sub-class for
|
|
41
|
+
* @param key A string used to retrieve a given registration. Should be unique per baseClass/key combination; if multiple registrations exist for a given baseClass/key, the highest priority registration wins at lookup time.
|
|
42
|
+
* @param priority Higher priority registrations beat lower. If unset (or 0), the priority is auto-incremented based on the highest existing priority for the same baseClass/key — so later registrations naturally win, which is the standard dependency-injection-by-import-order pattern.
|
|
43
|
+
* @param skipNullKeyWarning If true, suppresses the "registration has no key" console warning. Useful when null keys are intentional.
|
|
44
|
+
* @param autoRegisterWithRootClass If true, also registers against the root class of the hierarchy in addition to `baseClass`.
|
|
45
|
+
* @param metadata Optional structured metadata persisted on the `ClassRegistration`. Used for filterable / sortable discovery via `ClassFactory.GetAllRegistrationsByMetadata`. Common shape: `{ entity, slot, sortKey }` for form-panel slots. For new code, prefer the {@link RegisterClassEx} options-bag form.
|
|
46
|
+
*/
|
|
47
|
+
export declare function RegisterClass(baseClass: unknown, key?: string | null, priority?: number, skipNullKeyWarning?: boolean, autoRegisterWithRootClass?: boolean, metadata?: Record<string, unknown>): (constructor: Function) => void;
|
|
48
|
+
/**
|
|
49
|
+
* Decorate your class with this to register it with the MJGlobal class factory
|
|
50
|
+
* using a structured options bag. The `Ex` suffix follows MJ's existing
|
|
51
|
+
* `Foo` / `FooAsync` / `FooEx` naming convention for "same thing, modern variant."
|
|
52
|
+
*
|
|
53
|
+
* **Prefer this over `RegisterClass` for new code** when you have anything
|
|
54
|
+
* beyond `(baseClass, key, priority)` to specify. The positional form gets
|
|
55
|
+
* unwieldy past three args and the boolean flags read as anonymous magic.
|
|
56
|
+
*
|
|
57
|
+
* Same registration semantics as `RegisterClass` under the hood — pick the
|
|
58
|
+
* shape that reads best at the call site.
|
|
59
|
+
*
|
|
60
|
+
* @example Structured panel registration with metadata
|
|
61
|
+
* ```ts
|
|
62
|
+
* @RegisterClassEx(BaseFormPanel, {
|
|
63
|
+
* key: 'content-sources:tag-pipeline',
|
|
64
|
+
* skipNullKeyWarning: true,
|
|
65
|
+
* metadata: {
|
|
66
|
+
* entity: 'MJ: Content Sources',
|
|
67
|
+
* slot: 'after-fields',
|
|
68
|
+
* sortKey: 100,
|
|
69
|
+
* },
|
|
70
|
+
* })
|
|
71
|
+
* export class TagPipelinePanel extends BaseFormPanel { ... }
|
|
72
|
+
* ```
|
|
73
|
+
*
|
|
74
|
+
* @param baseClass A reference to the base class you are registering a sub-class for
|
|
75
|
+
* @param options Structured options — see {@link RegisterClassOptions}. All fields optional.
|
|
9
76
|
*/
|
|
10
|
-
export declare function
|
|
77
|
+
export declare function RegisterClassEx(baseClass: unknown, options?: RegisterClassOptions): (constructor: Function) => void;
|
|
11
78
|
//# sourceMappingURL=RegisterClass.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RegisterClass.d.ts","sourceRoot":"","sources":["../src/RegisterClass.ts"],"names":[],"mappings":"AAEA;;;;;;;;GAQG;AACH,wBAAgB,aAAa,
|
|
1
|
+
{"version":3,"file":"RegisterClass.d.ts","sourceRoot":"","sources":["../src/RegisterClass.ts"],"names":[],"mappings":"AAEA;;;;;;;;GAQG;AACH,MAAM,WAAW,oBAAoB;IACjC,gFAAgF;IAChF,GAAG,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB,uFAAuF;IACvF,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,8DAA8D;IAC9D,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,iFAAiF;IACjF,yBAAyB,CAAC,EAAE,OAAO,CAAC;IACpC;;;;OAIG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACtC;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,aAAa,CACzB,SAAS,EAAE,OAAO,EAClB,GAAG,GAAE,MAAM,GAAG,IAAW,EACzB,QAAQ,GAAE,MAAU,EACpB,kBAAkB,GAAE,OAAe,EACnC,yBAAyB,GAAE,OAAe,EAC1C,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GACnC,CAAC,WAAW,EAAE,QAAQ,KAAK,IAAI,CAIjC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,wBAAgB,eAAe,CAAC,SAAS,EAAE,OAAO,EAAE,OAAO,GAAE,oBAAyB,GAAG,CAAC,WAAW,EAAE,QAAQ,KAAK,IAAI,CAYvH"}
|
package/dist/RegisterClass.js
CHANGED
|
@@ -1,17 +1,62 @@
|
|
|
1
1
|
import { MJGlobal } from './Global.js';
|
|
2
2
|
/**
|
|
3
3
|
* Decorate your class with this to register it with the MJGlobal class factory.
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* @
|
|
9
|
-
*
|
|
4
|
+
*
|
|
5
|
+
* Classic positional form. The fifth and earlier parameters are unchanged from
|
|
6
|
+
* the original signature — existing call sites keep working byte-for-byte.
|
|
7
|
+
*
|
|
8
|
+
* @remarks **Prefer `RegisterClassEx` for new code** when you have anything
|
|
9
|
+
* beyond `(baseClass, key, priority)` to specify — the options-bag signature
|
|
10
|
+
* scales much better than positional booleans, and it's the natural place to
|
|
11
|
+
* attach the structured `metadata` bag used by dynamic discovery features
|
|
12
|
+
* (form-panel slots, etc.). The `metadata` positional param here is provided
|
|
13
|
+
* for parity and brevity, but reads worse than `{ metadata: {...} }` once the
|
|
14
|
+
* decorator wraps onto multiple lines.
|
|
15
|
+
*
|
|
16
|
+
* @param baseClass A reference to the base class you are registering a sub-class for
|
|
17
|
+
* @param key A string used to retrieve a given registration. Should be unique per baseClass/key combination; if multiple registrations exist for a given baseClass/key, the highest priority registration wins at lookup time.
|
|
18
|
+
* @param priority Higher priority registrations beat lower. If unset (or 0), the priority is auto-incremented based on the highest existing priority for the same baseClass/key — so later registrations naturally win, which is the standard dependency-injection-by-import-order pattern.
|
|
19
|
+
* @param skipNullKeyWarning If true, suppresses the "registration has no key" console warning. Useful when null keys are intentional.
|
|
20
|
+
* @param autoRegisterWithRootClass If true, also registers against the root class of the hierarchy in addition to `baseClass`.
|
|
21
|
+
* @param metadata Optional structured metadata persisted on the `ClassRegistration`. Used for filterable / sortable discovery via `ClassFactory.GetAllRegistrationsByMetadata`. Common shape: `{ entity, slot, sortKey }` for form-panel slots. For new code, prefer the {@link RegisterClassEx} options-bag form.
|
|
10
22
|
*/
|
|
11
|
-
export function RegisterClass(baseClass, key = null, priority = 0, skipNullKeyWarning = false, autoRegisterWithRootClass = false) {
|
|
23
|
+
export function RegisterClass(baseClass, key = null, priority = 0, skipNullKeyWarning = false, autoRegisterWithRootClass = false, metadata) {
|
|
12
24
|
return function (constructor) {
|
|
13
|
-
|
|
14
|
-
|
|
25
|
+
MJGlobal.Instance.ClassFactory.Register(baseClass, constructor, key, priority, skipNullKeyWarning, autoRegisterWithRootClass, metadata);
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Decorate your class with this to register it with the MJGlobal class factory
|
|
30
|
+
* using a structured options bag. The `Ex` suffix follows MJ's existing
|
|
31
|
+
* `Foo` / `FooAsync` / `FooEx` naming convention for "same thing, modern variant."
|
|
32
|
+
*
|
|
33
|
+
* **Prefer this over `RegisterClass` for new code** when you have anything
|
|
34
|
+
* beyond `(baseClass, key, priority)` to specify. The positional form gets
|
|
35
|
+
* unwieldy past three args and the boolean flags read as anonymous magic.
|
|
36
|
+
*
|
|
37
|
+
* Same registration semantics as `RegisterClass` under the hood — pick the
|
|
38
|
+
* shape that reads best at the call site.
|
|
39
|
+
*
|
|
40
|
+
* @example Structured panel registration with metadata
|
|
41
|
+
* ```ts
|
|
42
|
+
* @RegisterClassEx(BaseFormPanel, {
|
|
43
|
+
* key: 'content-sources:tag-pipeline',
|
|
44
|
+
* skipNullKeyWarning: true,
|
|
45
|
+
* metadata: {
|
|
46
|
+
* entity: 'MJ: Content Sources',
|
|
47
|
+
* slot: 'after-fields',
|
|
48
|
+
* sortKey: 100,
|
|
49
|
+
* },
|
|
50
|
+
* })
|
|
51
|
+
* export class TagPipelinePanel extends BaseFormPanel { ... }
|
|
52
|
+
* ```
|
|
53
|
+
*
|
|
54
|
+
* @param baseClass A reference to the base class you are registering a sub-class for
|
|
55
|
+
* @param options Structured options — see {@link RegisterClassOptions}. All fields optional.
|
|
56
|
+
*/
|
|
57
|
+
export function RegisterClassEx(baseClass, options = {}) {
|
|
58
|
+
return function (constructor) {
|
|
59
|
+
MJGlobal.Instance.ClassFactory.Register(baseClass, constructor, options.key ?? null, options.priority ?? 0, options.skipNullKeyWarning ?? false, options.autoRegisterWithRootClass ?? false, options.metadata);
|
|
15
60
|
};
|
|
16
61
|
}
|
|
17
62
|
//# sourceMappingURL=RegisterClass.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RegisterClass.js","sourceRoot":"","sources":["../src/RegisterClass.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"RegisterClass.js","sourceRoot":"","sources":["../src/RegisterClass.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AA4BpC;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,UAAU,aAAa,CACzB,SAAkB,EAClB,MAAqB,IAAI,EACzB,WAAmB,CAAC,EACpB,qBAA8B,KAAK,EACnC,4BAAqC,KAAK,EAC1C,QAAkC;IAElC,OAAO,UAAU,WAAqB;QAClC,QAAQ,CAAC,QAAQ,CAAC,YAAY,CAAC,QAAQ,CAAC,SAAS,EAAE,WAAW,EAAE,GAAG,EAAE,QAAQ,EAAE,kBAAkB,EAAE,yBAAyB,EAAE,QAAQ,CAAC,CAAC;IAC5I,CAAC,CAAA;AACL,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,MAAM,UAAU,eAAe,CAAC,SAAkB,EAAE,UAAgC,EAAE;IAClF,OAAO,UAAU,WAAqB;QAClC,QAAQ,CAAC,QAAQ,CAAC,YAAY,CAAC,QAAQ,CACnC,SAAS,EACT,WAAW,EACX,OAAO,CAAC,GAAG,IAAI,IAAI,EACnB,OAAO,CAAC,QAAQ,IAAI,CAAC,EACrB,OAAO,CAAC,kBAAkB,IAAI,KAAK,EACnC,OAAO,CAAC,yBAAyB,IAAI,KAAK,EAC1C,OAAO,CAAC,QAAQ,CACnB,CAAC;IACN,CAAC,CAAC;AACN,CAAC"}
|
|
@@ -18,7 +18,7 @@ export declare const DANGEROUS_SQL_KEYWORDS: readonly ["DROP", "CREATE", "ALTER"
|
|
|
18
18
|
* Keywords from DANGEROUS_SQL_KEYWORDS that are legitimate in full SELECT queries.
|
|
19
19
|
* These are only unblocked when context is 'full_query'.
|
|
20
20
|
*/
|
|
21
|
-
export declare const FULL_QUERY_ALLOWED_KEYWORDS: readonly ["EXISTS", "ANY", "ALL", "SOME", "UNION", "INTERSECT", "EXCEPT", "IF"];
|
|
21
|
+
export declare const FULL_QUERY_ALLOWED_KEYWORDS: readonly ["EXISTS", "ANY", "ALL", "SOME", "UNION", "INTERSECT", "EXCEPT", "IF", "FOR"];
|
|
22
22
|
/**
|
|
23
23
|
* Safe SQL functions allowed in expressions, organized by category
|
|
24
24
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SQLExpressionValidator.d.ts","sourceRoot":"","sources":["../src/SQLExpressionValidator.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAEhD;;GAEG;AACH,eAAO,MAAM,sBAAsB,2gBA0CzB,CAAC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AkB,QAAQ,IAAI,sBAAsB,CAEnD;IAED;;;;;;OAMG;IACI,QAAQ,CAAC,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE,oBAAoB,GAAG,mBAAmB;IAoCvF;;;OAGG;IACH,OAAO,CAAC,oBAAoB;IAM5B;;OAEG;IACH,OAAO,CAAC,sBAAsB;IAoE9B;;OAEG;IACH,OAAO,CAAC,kBAAkB;IA2B1B;;OAEG;IACH,OAAO,CAAC,iBAAiB;IAiCzB;;OAEG;IACH,OAAO,CAAC,oBAAoB;IA4B5B;;;;OAIG;IACH,OAAO,CAAC,gBAAgB;IAMxB;;OAEG;IACH,OAAO,CAAC,WAAW;IAInB;;;;;;;OAOG;IACH,OAAO,CAAC,sBAAsB;IAQ9B;;;;OAIG;IACI,iBAAiB,CAAC,GAAG,EAAE,MAAM,GAAG,mBAAmB;CAO3D"}
|
|
@@ -54,6 +54,11 @@ export const FULL_QUERY_ALLOWED_KEYWORDS = [
|
|
|
54
54
|
'UNION', 'INTERSECT', 'EXCEPT',
|
|
55
55
|
// IIF() uses IF internally, CASE WHEN patterns are common
|
|
56
56
|
'IF',
|
|
57
|
+
// FOR JSON / FOR XML — legitimate trailing clauses on a full SELECT. The
|
|
58
|
+
// control-flow `FOR` loop this keyword guards against cannot appear in a
|
|
59
|
+
// standalone SELECT statement, so allowing FOR in full-query context is safe.
|
|
60
|
+
// (FOR UPDATE remains blocked via the independent UPDATE keyword.)
|
|
61
|
+
'FOR',
|
|
57
62
|
];
|
|
58
63
|
/**
|
|
59
64
|
* Safe SQL functions allowed in expressions, organized by category
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SQLExpressionValidator.js","sourceRoot":"","sources":["../src/SQLExpressionValidator.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAEhD;;GAEG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG;IACpC,iCAAiC;IACj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AA0E;QAC1E,IAAI,aAAa,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAC7B,0DAA0D;YAC1D,+BAA+B;QACjC,CAAC;IACH,CAAC;IAED;;;;OAIG;IACK,gBAAgB,CAAC,GAAW;QAClC,OAAO,GAAG;aACP,OAAO,CAAC,WAAW,EAAE,EAAE,CAAC,CAAU,uBAAuB;aACzD,OAAO,CAAC,mBAAmB,EAAE,EAAE,CAAC,CAAC,CAAC,iBAAiB;IACxD,CAAC;IAED;;OAEG;IACK,WAAW,CAAC,GAAW;QAC7B,OAAO,GAAG,CAAC,OAAO,CAAC,qBAAqB,EAAE,MAAM,CAAC,CAAC;IACpD,CAAC;IAED;;;;;;;OAOG;IACK,sBAAsB,CAAC,GAAW;QACxC,OAAO,GAAG;aACP,OAAO,CAAC,SAAS,EAAE,IAAI,CAAC,CAAE,yBAAyB;aACnD,OAAO,CAAC,MAAM,EAAE,IAAI,CAAC,CAAK,uBAAuB;aACjD,OAAO,CAAC,MAAM,EAAE,IAAI,CAAC,CAAK,+BAA+B;aACzD,OAAO,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC,CAAI,mBAAmB;IAClD,CAAC;IAED;;;;OAIG;IACI,iBAAiB,CAAC,GAAW;QAClC,yEAAyE;QACzE,wEAAwE;QACxE,4DAA4D;QAC5D,MAAM,UAAU,GAAG,IAAI,CAAC,sBAAsB,CAAC,GAAG,CAAC,CAAC;QACpD,OAAO,IAAI,CAAC,QAAQ,CAAC,UAAU,EAAE,EAAE,OAAO,EAAE,YAAY,EAAE,CAAC,CAAC;IAC9D,CAAC;CACF"}
|
|
@@ -444,5 +444,85 @@ describe('ClassFactory', () => {
|
|
|
444
444
|
expect(instance).toBeNull();
|
|
445
445
|
});
|
|
446
446
|
});
|
|
447
|
+
describe('Metadata on registrations', () => {
|
|
448
|
+
it('persists metadata on the ClassRegistration when provided to Register()', () => {
|
|
449
|
+
factory.Register(Animal, Dog, 'fido', 0, true, false, { trainer: 'alice', tags: ['indoor'] });
|
|
450
|
+
const regs = factory.GetAllRegistrations(Animal, 'fido');
|
|
451
|
+
expect(regs).toHaveLength(1);
|
|
452
|
+
expect(regs[0].Metadata).toEqual({ trainer: 'alice', tags: ['indoor'] });
|
|
453
|
+
});
|
|
454
|
+
it('leaves Metadata undefined when not provided (backwards compat)', () => {
|
|
455
|
+
factory.Register(Animal, Dog, 'pre-metadata');
|
|
456
|
+
const reg = factory.GetRegistration(Animal, 'pre-metadata');
|
|
457
|
+
expect(reg?.Metadata).toBeUndefined();
|
|
458
|
+
});
|
|
459
|
+
});
|
|
460
|
+
describe('GetAllRegistrationsByKeyPrefix', () => {
|
|
461
|
+
beforeEach(() => {
|
|
462
|
+
factory.Register(Animal, Dog, 'breed:retriever');
|
|
463
|
+
factory.Register(Animal, Dog, 'breed:poodle');
|
|
464
|
+
factory.Register(Animal, Cat, 'breed:tabby');
|
|
465
|
+
factory.Register(Animal, Cat, 'color:black');
|
|
466
|
+
});
|
|
467
|
+
it('returns only registrations whose key starts with the prefix', () => {
|
|
468
|
+
const breed = factory.GetAllRegistrationsByKeyPrefix(Animal, 'breed:');
|
|
469
|
+
expect(breed.map(r => r.Key).sort()).toEqual(['breed:poodle', 'breed:retriever', 'breed:tabby']);
|
|
470
|
+
});
|
|
471
|
+
it('is case-insensitive and trims whitespace on the prefix', () => {
|
|
472
|
+
const breed = factory.GetAllRegistrationsByKeyPrefix(Animal, ' BREED: ');
|
|
473
|
+
expect(breed).toHaveLength(3);
|
|
474
|
+
});
|
|
475
|
+
it('returns empty array when nothing matches', () => {
|
|
476
|
+
expect(factory.GetAllRegistrationsByKeyPrefix(Animal, 'zzz:')).toEqual([]);
|
|
477
|
+
});
|
|
478
|
+
it('returns empty array when baseClass is falsy', () => {
|
|
479
|
+
expect(factory.GetAllRegistrationsByKeyPrefix(null, 'breed:')).toEqual([]);
|
|
480
|
+
});
|
|
481
|
+
it('scopes to the requested base class', () => {
|
|
482
|
+
factory.Register(Vehicle, Car, 'breed:something-weird');
|
|
483
|
+
const animalBreed = factory.GetAllRegistrationsByKeyPrefix(Animal, 'breed:');
|
|
484
|
+
expect(animalBreed.every(r => r.BaseClass === Animal)).toBe(true);
|
|
485
|
+
});
|
|
486
|
+
});
|
|
487
|
+
describe('GetAllRegistrationsByKeyPattern', () => {
|
|
488
|
+
beforeEach(() => {
|
|
489
|
+
factory.Register(Animal, Dog, 'panel-a');
|
|
490
|
+
factory.Register(Animal, Cat, 'panel-b');
|
|
491
|
+
factory.Register(Animal, GoldenRetriever, 'widget-1');
|
|
492
|
+
});
|
|
493
|
+
it('returns registrations whose key matches the regex', () => {
|
|
494
|
+
const panels = factory.GetAllRegistrationsByKeyPattern(Animal, /^panel-/);
|
|
495
|
+
expect(panels.map(r => r.Key).sort()).toEqual(['panel-a', 'panel-b']);
|
|
496
|
+
});
|
|
497
|
+
it('returns empty array when baseClass or pattern is falsy', () => {
|
|
498
|
+
expect(factory.GetAllRegistrationsByKeyPattern(null, /./)).toEqual([]);
|
|
499
|
+
// null pattern intentionally caught by truthy check
|
|
500
|
+
expect(factory.GetAllRegistrationsByKeyPattern(Animal, null)).toEqual([]);
|
|
501
|
+
});
|
|
502
|
+
});
|
|
503
|
+
describe('GetAllRegistrationsByMetadata', () => {
|
|
504
|
+
beforeEach(() => {
|
|
505
|
+
factory.Register(Animal, Dog, 'fido', 0, true, false, { entity: 'X', slot: 'after-fields', sortKey: 100 });
|
|
506
|
+
factory.Register(Animal, Cat, 'whiskers', 0, true, false, { entity: 'X', slot: 'after-fields', sortKey: 50 });
|
|
507
|
+
factory.Register(Animal, GoldenRetriever, 'goldie', 0, true, false, { entity: 'Y', slot: 'after-fields' });
|
|
508
|
+
factory.Register(Animal, Dog, 'rex'); // no metadata at all
|
|
509
|
+
});
|
|
510
|
+
it('passes the metadata bag (or undefined) to the predicate', () => {
|
|
511
|
+
const matches = factory.GetAllRegistrationsByMetadata(Animal, (m) => m?.entity === 'X' && m?.slot === 'after-fields');
|
|
512
|
+
expect(matches.map(r => r.Key).sort()).toEqual(['fido', 'whiskers']);
|
|
513
|
+
});
|
|
514
|
+
it('handles registrations with no metadata (passes undefined)', () => {
|
|
515
|
+
const noMeta = factory.GetAllRegistrationsByMetadata(Animal, (m) => m === undefined);
|
|
516
|
+
expect(noMeta.map(r => r.Key)).toEqual(['rex']);
|
|
517
|
+
});
|
|
518
|
+
it('also exposes the full registration to the predicate', () => {
|
|
519
|
+
const highPriority = factory.GetAllRegistrationsByMetadata(Animal, (m, r) => (m?.sortKey ?? 0) >= 100 && r.Key === 'fido');
|
|
520
|
+
expect(highPriority).toHaveLength(1);
|
|
521
|
+
});
|
|
522
|
+
it('returns empty array when baseClass or predicate is missing', () => {
|
|
523
|
+
expect(factory.GetAllRegistrationsByMetadata(null, () => true)).toEqual([]);
|
|
524
|
+
expect(factory.GetAllRegistrationsByMetadata(Animal, null)).toEqual([]);
|
|
525
|
+
});
|
|
526
|
+
});
|
|
447
527
|
});
|
|
448
528
|
//# sourceMappingURL=ClassFactory.test.js.map
|