@memberjunction/core 6.2.0-edge.4 → 6.2.0-edge.6
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/BaseEntitySaveQueue.d.ts +22 -0
- package/dist/generic/BaseEntitySaveQueue.d.ts.map +1 -1
- package/dist/generic/BaseEntitySaveQueue.js +43 -4
- package/dist/generic/BaseEntitySaveQueue.js.map +1 -1
- package/dist/generic/JSONType-interfaces/IEntityConfiguration.d.ts +18 -0
- package/dist/generic/JSONType-interfaces/IEntityConfiguration.d.ts.map +1 -1
- package/dist/generic/alternateBaseViews.d.ts +119 -0
- package/dist/generic/alternateBaseViews.d.ts.map +1 -0
- package/dist/generic/alternateBaseViews.js +223 -0
- package/dist/generic/alternateBaseViews.js.map +1 -0
- package/dist/generic/baseEngine.d.ts +82 -14
- package/dist/generic/baseEngine.d.ts.map +1 -1
- package/dist/generic/baseEngine.js +311 -46
- package/dist/generic/baseEngine.js.map +1 -1
- package/dist/generic/baseEngineRegistry.d.ts.map +1 -1
- package/dist/generic/baseEngineRegistry.js +2 -1
- package/dist/generic/baseEngineRegistry.js.map +1 -1
- package/dist/generic/baseEntity.d.ts +194 -14
- package/dist/generic/baseEntity.d.ts.map +1 -1
- package/dist/generic/baseEntity.js +638 -218
- package/dist/generic/baseEntity.js.map +1 -1
- package/dist/generic/baseInfo.d.ts +31 -3
- package/dist/generic/baseInfo.d.ts.map +1 -1
- package/dist/generic/baseInfo.js +138 -40
- package/dist/generic/baseInfo.js.map +1 -1
- package/dist/generic/contextTokens.d.ts +136 -0
- package/dist/generic/contextTokens.d.ts.map +1 -0
- package/dist/generic/contextTokens.js +319 -0
- package/dist/generic/contextTokens.js.map +1 -0
- package/dist/generic/databaseProviderBase.d.ts +103 -13
- package/dist/generic/databaseProviderBase.d.ts.map +1 -1
- package/dist/generic/databaseProviderBase.js +321 -77
- package/dist/generic/databaseProviderBase.js.map +1 -1
- package/dist/generic/embeddedRecord.d.ts +6 -0
- package/dist/generic/embeddedRecord.d.ts.map +1 -1
- package/dist/generic/embeddedRecord.js +15 -1
- package/dist/generic/embeddedRecord.js.map +1 -1
- package/dist/generic/entityCompanion.d.ts +7 -0
- package/dist/generic/entityCompanion.d.ts.map +1 -1
- package/dist/generic/entityCompanion.js +8 -0
- package/dist/generic/entityCompanion.js.map +1 -1
- package/dist/generic/entityConfiguration.d.ts +8 -2
- package/dist/generic/entityConfiguration.d.ts.map +1 -1
- package/dist/generic/entityConfiguration.js +9 -0
- package/dist/generic/entityConfiguration.js.map +1 -1
- package/dist/generic/entityInfo.d.ts +306 -12
- package/dist/generic/entityInfo.d.ts.map +1 -1
- package/dist/generic/entityInfo.js +894 -92
- package/dist/generic/entityInfo.js.map +1 -1
- package/dist/generic/entityValueFieldSecurity.d.ts +139 -0
- package/dist/generic/entityValueFieldSecurity.d.ts.map +1 -0
- package/dist/generic/entityValueFieldSecurity.js +250 -0
- package/dist/generic/entityValueFieldSecurity.js.map +1 -0
- package/dist/generic/fieldSecuritySQLGate.d.ts +350 -0
- package/dist/generic/fieldSecuritySQLGate.d.ts.map +1 -0
- package/dist/generic/fieldSecuritySQLGate.js +898 -0
- package/dist/generic/fieldSecuritySQLGate.js.map +1 -0
- package/dist/generic/indexRestrictedFields.d.ts +47 -0
- package/dist/generic/indexRestrictedFields.d.ts.map +1 -0
- package/dist/generic/indexRestrictedFields.js +129 -0
- package/dist/generic/indexRestrictedFields.js.map +1 -0
- package/dist/generic/infoProviderResolution.d.ts +16 -0
- package/dist/generic/infoProviderResolution.d.ts.map +1 -0
- package/dist/generic/infoProviderResolution.js +17 -0
- package/dist/generic/infoProviderResolution.js.map +1 -0
- package/dist/generic/interfaces.d.ts +39 -2
- package/dist/generic/interfaces.d.ts.map +1 -1
- package/dist/generic/interfaces.js.map +1 -1
- package/dist/generic/localCacheManager.d.ts +318 -51
- package/dist/generic/localCacheManager.d.ts.map +1 -1
- package/dist/generic/localCacheManager.js +675 -109
- package/dist/generic/localCacheManager.js.map +1 -1
- package/dist/generic/logging.d.ts.map +1 -1
- package/dist/generic/logging.js +7 -1
- package/dist/generic/logging.js.map +1 -1
- package/dist/generic/metadata.d.ts +3 -2
- package/dist/generic/metadata.d.ts.map +1 -1
- package/dist/generic/metadata.js +5 -2
- package/dist/generic/metadata.js.map +1 -1
- package/dist/generic/mjapiUrl.d.ts +21 -0
- package/dist/generic/mjapiUrl.d.ts.map +1 -0
- package/dist/generic/mjapiUrl.js +25 -0
- package/dist/generic/mjapiUrl.js.map +1 -0
- package/dist/generic/platformSQL.d.ts +54 -0
- package/dist/generic/platformSQL.d.ts.map +1 -1
- package/dist/generic/platformSQL.js +55 -0
- package/dist/generic/platformSQL.js.map +1 -1
- package/dist/generic/providerBase.d.ts +370 -57
- package/dist/generic/providerBase.d.ts.map +1 -1
- package/dist/generic/providerBase.js +1085 -284
- package/dist/generic/providerBase.js.map +1 -1
- package/dist/generic/queryInfo.d.ts +23 -9
- package/dist/generic/queryInfo.d.ts.map +1 -1
- package/dist/generic/queryInfo.js +73 -33
- package/dist/generic/queryInfo.js.map +1 -1
- package/dist/generic/queryInfoInterfaces.d.ts +8 -0
- package/dist/generic/queryInfoInterfaces.d.ts.map +1 -1
- package/dist/generic/queryTemplateContext.d.ts +49 -0
- package/dist/generic/queryTemplateContext.d.ts.map +1 -0
- package/dist/generic/queryTemplateContext.js +113 -0
- package/dist/generic/queryTemplateContext.js.map +1 -0
- package/dist/generic/recordChangeFieldSecurity.d.ts.map +1 -1
- package/dist/generic/recordChangeFieldSecurity.js +13 -2
- package/dist/generic/recordChangeFieldSecurity.js.map +1 -1
- package/dist/generic/relatedRecordCollection.d.ts +13 -0
- package/dist/generic/relatedRecordCollection.d.ts.map +1 -1
- package/dist/generic/relatedRecordCollection.js +44 -5
- package/dist/generic/relatedRecordCollection.js.map +1 -1
- package/dist/generic/runQuery.d.ts +42 -0
- package/dist/generic/runQuery.d.ts.map +1 -1
- package/dist/generic/runQuery.js +14 -0
- package/dist/generic/runQuery.js.map +1 -1
- package/dist/generic/runQuerySQLFilterImplementations.d.ts.map +1 -1
- package/dist/generic/runQuerySQLFilterImplementations.js +38 -2
- package/dist/generic/runQuerySQLFilterImplementations.js.map +1 -1
- package/dist/generic/saveEntityGraphOperation.d.ts.map +1 -1
- package/dist/generic/saveEntityGraphOperation.js +3 -0
- package/dist/generic/saveEntityGraphOperation.js.map +1 -1
- package/dist/generic/scoring/ReciprocalRankFusion.d.ts.map +1 -1
- package/dist/generic/scoring/ReciprocalRankFusion.js +10 -3
- package/dist/generic/scoring/ReciprocalRankFusion.js.map +1 -1
- package/dist/generic/securityInfo.d.ts +17 -6
- package/dist/generic/securityInfo.d.ts.map +1 -1
- package/dist/generic/securityInfo.js +25 -10
- package/dist/generic/securityInfo.js.map +1 -1
- package/dist/generic/telemetryManager.d.ts +9 -0
- package/dist/generic/telemetryManager.d.ts.map +1 -1
- package/dist/generic/telemetryManager.js +5 -1
- package/dist/generic/telemetryManager.js.map +1 -1
- package/dist/generic/util.d.ts.map +1 -1
- package/dist/generic/util.js +3 -0
- package/dist/generic/util.js.map +1 -1
- package/dist/generic/wellKnownUserSource.d.ts +3 -2
- package/dist/generic/wellKnownUserSource.d.ts.map +1 -1
- package/dist/generic/wellKnownUserSource.js +18 -9
- package/dist/generic/wellKnownUserSource.js.map +1 -1
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -0
- package/dist/index.js.map +1 -1
- package/dist/views/runView.d.ts +89 -0
- package/dist/views/runView.d.ts.map +1 -1
- package/dist/views/runView.js +36 -0
- package/dist/views/runView.js.map +1 -1
- package/dist/views/viewProperties.d.ts +55 -0
- package/dist/views/viewProperties.d.ts.map +1 -0
- package/dist/views/viewProperties.js +258 -0
- package/dist/views/viewProperties.js.map +1 -0
- package/package.json +3 -3
- package/readme.md +29 -4
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { IMetadataProvider } from "./interfaces.js";
|
|
1
2
|
/**
|
|
2
3
|
* Base class for all MemberJunction metadata info classes.
|
|
3
4
|
* Provides common functionality for copying initialization data and handling default values.
|
|
@@ -9,7 +10,28 @@ export declare abstract class BaseInfo {
|
|
|
9
10
|
*/
|
|
10
11
|
ID: any;
|
|
11
12
|
/**
|
|
12
|
-
*
|
|
13
|
+
* The metadata provider that built this Info object, when known.
|
|
14
|
+
*
|
|
15
|
+
* Info getters that resolve sibling metadata (an entity's IS-A children, a permission's RLS
|
|
16
|
+
* filter, a query's fields, an authorization's roles, …) must read from the SAME provider the
|
|
17
|
+
* object came from. In a multi-provider process — several `GraphQLDataProvider` instances with
|
|
18
|
+
* `separateConnection`, or a server servicing several connections — the global
|
|
19
|
+
* `Metadata.Provider` is a different provider or not set at all. Providers pass themselves to
|
|
20
|
+
* every Info constructor (`new m.class(row, provider)`), and container Info objects hand it to
|
|
21
|
+
* the child Info objects they construct.
|
|
22
|
+
*
|
|
23
|
+
* `undefined` for an Info object built outside a provider (tests, ad-hoc construction). Callers
|
|
24
|
+
* then fall back to the global provider, which is exactly the pre-existing behavior.
|
|
25
|
+
*/
|
|
26
|
+
get OwningProvider(): IMetadataProvider | undefined;
|
|
27
|
+
/**
|
|
28
|
+
* Records the provider that owns this Info object. A null/undefined provider is ignored, so
|
|
29
|
+
* passing an optional constructor argument straight through is always safe.
|
|
30
|
+
* @param provider - the provider whose metadata this object belongs to
|
|
31
|
+
*/
|
|
32
|
+
SetOwningProvider(provider: IMetadataProvider | null | undefined): void;
|
|
33
|
+
/**
|
|
34
|
+
* Returns the cached set of settable accessor names on `instance`'s prototype chain.
|
|
13
35
|
*
|
|
14
36
|
* A `@deprecated` alias for a renamed field is a get/set pair on the prototype, not an own
|
|
15
37
|
* property, so `hasOwnProperty` does not see it. Without this the incoming value is silently
|
|
@@ -19,14 +41,20 @@ export declare abstract class BaseInfo {
|
|
|
19
41
|
* Only accessors that can be WRITTEN qualify. A read-only getter has nothing to assign to, and
|
|
20
42
|
* requiring a setter keeps inherited methods out of the copy.
|
|
21
43
|
*/
|
|
22
|
-
private
|
|
44
|
+
private static getSettableAccessorsForInstance;
|
|
45
|
+
/**
|
|
46
|
+
* Resolves and caches the public getter name on `instance`'s prototype chain corresponding
|
|
47
|
+
* to a `_`-prefixed backing field (or `null` if no matching getter exists).
|
|
48
|
+
*/
|
|
49
|
+
private static resolveBackingGetterKey;
|
|
23
50
|
/**
|
|
24
51
|
* Copies initialization data from a plain object to the class instance.
|
|
25
52
|
* Only copies properties that already exist on the class to prevent creating new fields.
|
|
26
53
|
* Special handling for DefaultValue fields to extract actual values from SQL Server syntax.
|
|
27
54
|
* @param initData - The initialization data object
|
|
55
|
+
* @param skipKeys - Optional set of property keys handled directly by the subclass constructor
|
|
28
56
|
*/
|
|
29
|
-
protected copyInitData(initData: any): void;
|
|
57
|
+
protected copyInitData(initData: any, skipKeys?: ReadonlySet<string>): void;
|
|
30
58
|
/**
|
|
31
59
|
* Creates a new instance of the BaseInfo-derived class.
|
|
32
60
|
* @param initData - Optional initialization data to populate the instance
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"baseInfo.d.ts","sourceRoot":"","sources":["../../src/generic/baseInfo.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"baseInfo.d.ts","sourceRoot":"","sources":["../../src/generic/baseInfo.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAuBtD;;;;GAIG;AACH,8BAAsB,QAAQ;IAC1B;;OAEG;IACH,EAAE,EAAE,GAAG,CAAO;IAEd;;;;;;;;;;;;;OAaG;IACH,IAAW,cAAc,IAAI,iBAAiB,GAAG,SAAS,CAEzD;IAED;;;;OAIG;IACI,iBAAiB,CAAC,QAAQ,EAAE,iBAAiB,GAAG,IAAI,GAAG,SAAS,GAAG,IAAI;IAM9E;;;;;;;;;;OAUG;IACH,OAAO,CAAC,MAAM,CAAC,+BAA+B;IA0B9C;;;OAGG;IACH,OAAO,CAAC,MAAM,CAAC,uBAAuB;IA+BtC;;;;;;OAMG;IACH,SAAS,CAAC,YAAY,CAAC,QAAQ,EAAE,GAAG,EAAE,QAAQ,CAAC,EAAE,WAAW,CAAC,MAAM,CAAC;IA4CpE;;;OAGG;gBACS,QAAQ,GAAE,GAAU;IAMhC;;;;;;;;;;;;;;;;;;;OAmBG;IACH,MAAM,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;CAgCpC"}
|
package/dist/generic/baseInfo.js
CHANGED
|
@@ -1,4 +1,22 @@
|
|
|
1
1
|
import { ExtractActualDefaultValue } from "./util.js";
|
|
2
|
+
/**
|
|
3
|
+
* Back-references from Info objects to the metadata provider that built them. Held OUTSIDE the
|
|
4
|
+
* instances (a WeakMap rather than a field) so the reference can never leak into `toJSON()`,
|
|
5
|
+
* `Object.keys()`, `copyInitData` of a clone, or the local metadata cache — and so an Info object
|
|
6
|
+
* never keeps its provider reachable on its own account.
|
|
7
|
+
*/
|
|
8
|
+
const owningProviders = new WeakMap();
|
|
9
|
+
/**
|
|
10
|
+
* Per-constructor cache of property names that resolve to a settable accessor (`set` function)
|
|
11
|
+
* on the subclass prototype chain. Avoids repeated prototype walks during `copyInitData`.
|
|
12
|
+
*/
|
|
13
|
+
const settableAccessorsByClass = new WeakMap();
|
|
14
|
+
/**
|
|
15
|
+
* Per-constructor cache mapping `_`-prefixed private backing field names (e.g. `_fields`) to
|
|
16
|
+
* their public getter name on the prototype chain (e.g. `Fields`), or `null` when no public
|
|
17
|
+
* getter exists. Avoids repeated prototype walks during `toJSON()` serialization.
|
|
18
|
+
*/
|
|
19
|
+
const backingGetterByClass = new WeakMap();
|
|
2
20
|
/**
|
|
3
21
|
* Base class for all MemberJunction metadata info classes.
|
|
4
22
|
* Provides common functionality for copying initialization data and handling default values.
|
|
@@ -6,7 +24,34 @@ import { ExtractActualDefaultValue } from "./util.js";
|
|
|
6
24
|
*/
|
|
7
25
|
export class BaseInfo {
|
|
8
26
|
/**
|
|
9
|
-
*
|
|
27
|
+
* The metadata provider that built this Info object, when known.
|
|
28
|
+
*
|
|
29
|
+
* Info getters that resolve sibling metadata (an entity's IS-A children, a permission's RLS
|
|
30
|
+
* filter, a query's fields, an authorization's roles, …) must read from the SAME provider the
|
|
31
|
+
* object came from. In a multi-provider process — several `GraphQLDataProvider` instances with
|
|
32
|
+
* `separateConnection`, or a server servicing several connections — the global
|
|
33
|
+
* `Metadata.Provider` is a different provider or not set at all. Providers pass themselves to
|
|
34
|
+
* every Info constructor (`new m.class(row, provider)`), and container Info objects hand it to
|
|
35
|
+
* the child Info objects they construct.
|
|
36
|
+
*
|
|
37
|
+
* `undefined` for an Info object built outside a provider (tests, ad-hoc construction). Callers
|
|
38
|
+
* then fall back to the global provider, which is exactly the pre-existing behavior.
|
|
39
|
+
*/
|
|
40
|
+
get OwningProvider() {
|
|
41
|
+
return owningProviders.get(this);
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Records the provider that owns this Info object. A null/undefined provider is ignored, so
|
|
45
|
+
* passing an optional constructor argument straight through is always safe.
|
|
46
|
+
* @param provider - the provider whose metadata this object belongs to
|
|
47
|
+
*/
|
|
48
|
+
SetOwningProvider(provider) {
|
|
49
|
+
if (provider) {
|
|
50
|
+
owningProviders.set(this, provider);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Returns the cached set of settable accessor names on `instance`'s prototype chain.
|
|
10
55
|
*
|
|
11
56
|
* A `@deprecated` alias for a renamed field is a get/set pair on the prototype, not an own
|
|
12
57
|
* property, so `hasOwnProperty` does not see it. Without this the incoming value is silently
|
|
@@ -16,50 +61,111 @@ export class BaseInfo {
|
|
|
16
61
|
* Only accessors that can be WRITTEN qualify. A read-only getter has nothing to assign to, and
|
|
17
62
|
* requiring a setter keeps inherited methods out of the copy.
|
|
18
63
|
*/
|
|
19
|
-
|
|
20
|
-
|
|
64
|
+
static getSettableAccessorsForInstance(instance) {
|
|
65
|
+
const ctor = instance.constructor;
|
|
66
|
+
let cached = settableAccessorsByClass.get(ctor);
|
|
67
|
+
if (cached) {
|
|
68
|
+
return cached;
|
|
69
|
+
}
|
|
70
|
+
cached = new Set();
|
|
71
|
+
const seen = new Set();
|
|
72
|
+
let target = Object.getPrototypeOf(instance);
|
|
21
73
|
while (target && target !== Object.prototype) {
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
|
|
74
|
+
const descriptors = Object.getOwnPropertyDescriptors(target);
|
|
75
|
+
const names = Object.keys(descriptors);
|
|
76
|
+
for (let i = 0; i < names.length; i++) {
|
|
77
|
+
const name = names[i];
|
|
78
|
+
if (seen.has(name))
|
|
79
|
+
continue;
|
|
80
|
+
seen.add(name);
|
|
81
|
+
if (typeof descriptors[name].set === 'function') {
|
|
82
|
+
cached.add(name);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
25
85
|
target = Object.getPrototypeOf(target);
|
|
26
86
|
}
|
|
27
|
-
|
|
87
|
+
settableAccessorsByClass.set(ctor, cached);
|
|
88
|
+
return cached;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Resolves and caches the public getter name on `instance`'s prototype chain corresponding
|
|
92
|
+
* to a `_`-prefixed backing field (or `null` if no matching getter exists).
|
|
93
|
+
*/
|
|
94
|
+
static resolveBackingGetterKey(instance, backingKey) {
|
|
95
|
+
const ctor = instance.constructor;
|
|
96
|
+
let map = backingGetterByClass.get(ctor);
|
|
97
|
+
if (!map) {
|
|
98
|
+
map = new Map();
|
|
99
|
+
backingGetterByClass.set(ctor, map);
|
|
100
|
+
}
|
|
101
|
+
const existing = map.get(backingKey);
|
|
102
|
+
if (existing !== undefined) {
|
|
103
|
+
return existing;
|
|
104
|
+
}
|
|
105
|
+
const lowerKey = backingKey.slice(1);
|
|
106
|
+
if (!lowerKey) {
|
|
107
|
+
map.set(backingKey, null);
|
|
108
|
+
return null;
|
|
109
|
+
}
|
|
110
|
+
const pascalKey = lowerKey.charAt(0).toUpperCase() + lowerKey.slice(1);
|
|
111
|
+
let proto = Object.getPrototypeOf(instance);
|
|
112
|
+
while (proto && proto !== Object.prototype) {
|
|
113
|
+
const targetKey = Object.prototype.hasOwnProperty.call(proto, pascalKey) ? pascalKey : lowerKey;
|
|
114
|
+
const desc = Object.getOwnPropertyDescriptor(proto, targetKey);
|
|
115
|
+
if (desc && typeof desc.get === 'function') {
|
|
116
|
+
map.set(backingKey, targetKey);
|
|
117
|
+
return targetKey;
|
|
118
|
+
}
|
|
119
|
+
proto = Object.getPrototypeOf(proto);
|
|
120
|
+
}
|
|
121
|
+
map.set(backingKey, null);
|
|
122
|
+
return null;
|
|
28
123
|
}
|
|
29
124
|
/**
|
|
30
125
|
* Copies initialization data from a plain object to the class instance.
|
|
31
126
|
* Only copies properties that already exist on the class to prevent creating new fields.
|
|
32
127
|
* Special handling for DefaultValue fields to extract actual values from SQL Server syntax.
|
|
33
128
|
* @param initData - The initialization data object
|
|
129
|
+
* @param skipKeys - Optional set of property keys handled directly by the subclass constructor
|
|
34
130
|
*/
|
|
35
|
-
copyInitData(initData) {
|
|
131
|
+
copyInitData(initData, skipKeys) {
|
|
36
132
|
if (initData) {
|
|
133
|
+
const self = this;
|
|
134
|
+
let settableAccessors;
|
|
37
135
|
// copy the properties from the init data to the new class instance we are constructing
|
|
38
136
|
const keys = Object.keys(initData);
|
|
39
137
|
for (let j = 0; j < keys.length; j++) {
|
|
40
138
|
const key = keys[j];
|
|
139
|
+
if (skipKeys && skipKeys.has(key)) {
|
|
140
|
+
continue;
|
|
141
|
+
}
|
|
142
|
+
const val = initData[key];
|
|
143
|
+
const isOwn = Object.prototype.hasOwnProperty.call(this, key);
|
|
144
|
+
if (isOwn && val === null && self[key] === null) {
|
|
145
|
+
continue;
|
|
146
|
+
}
|
|
41
147
|
// make sure it is one of our keys, we don't want to create NEW fields
|
|
42
|
-
if (
|
|
148
|
+
if (isOwn || (settableAccessors ??= BaseInfo.getSettableAccessorsForInstance(this)).has(key)) {
|
|
43
149
|
// fast path for exact match first, fallback to length check + lowercasing
|
|
44
|
-
if ((key === 'DefaultValue' || (key.length === 12 && key.toLowerCase() === 'defaultvalue')) &&
|
|
150
|
+
if ((key === 'DefaultValue' || (key.length === 12 && key.toLowerCase() === 'defaultvalue')) && val) {
|
|
45
151
|
// strip parens from default value from the DB, if they exist, for example defaults might be ((1)) or (getdate())
|
|
46
152
|
// could also be something like (('Pending')) in which case we'll want to remove the SYMMETRIC parens
|
|
47
|
-
const initialValue =
|
|
153
|
+
const initialValue = val;
|
|
48
154
|
const trueDefault = ExtractActualDefaultValue(initialValue);
|
|
49
|
-
|
|
155
|
+
self[key] = trueDefault;
|
|
50
156
|
}
|
|
51
157
|
else {
|
|
52
|
-
|
|
158
|
+
self[key] = val;
|
|
53
159
|
}
|
|
54
160
|
}
|
|
55
161
|
else {
|
|
56
162
|
const lowerUnderscoreKey = `_${key.charAt(0).toLowerCase()}${key.slice(1)}`;
|
|
57
163
|
const underscoreKey = `_${key}`;
|
|
58
164
|
if (Object.prototype.hasOwnProperty.call(this, lowerUnderscoreKey)) {
|
|
59
|
-
|
|
165
|
+
self[lowerUnderscoreKey] = val;
|
|
60
166
|
}
|
|
61
167
|
else if (Object.prototype.hasOwnProperty.call(this, underscoreKey)) {
|
|
62
|
-
|
|
168
|
+
self[underscoreKey] = val;
|
|
63
169
|
}
|
|
64
170
|
}
|
|
65
171
|
}
|
|
@@ -101,37 +207,29 @@ export class BaseInfo {
|
|
|
101
207
|
toJSON() {
|
|
102
208
|
const result = {};
|
|
103
209
|
const self = this;
|
|
104
|
-
|
|
210
|
+
const keys = Object.keys(this);
|
|
211
|
+
for (let i = 0; i < keys.length; i++) {
|
|
212
|
+
const key = keys[i];
|
|
105
213
|
if (!key.startsWith('_')) {
|
|
106
214
|
result[key] = self[key];
|
|
107
215
|
continue;
|
|
108
216
|
}
|
|
109
217
|
// Private backing field — expose via its public getter if one exists with the same name minus the underscore
|
|
110
|
-
const
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
//
|
|
124
|
-
// better than losing the entire snapshot: the value is recomputed lazily on
|
|
125
|
-
// the next access, and the local metadata cache still gets written.
|
|
126
|
-
try {
|
|
127
|
-
result[targetKey] = self[targetKey];
|
|
128
|
-
}
|
|
129
|
-
catch {
|
|
130
|
-
// intentionally omitted from the serialized shape
|
|
131
|
-
}
|
|
132
|
-
break;
|
|
218
|
+
const targetKey = BaseInfo.resolveBackingGetterKey(this, key);
|
|
219
|
+
if (targetKey !== null) {
|
|
220
|
+
// A getter reached through a backing field must not abort the whole
|
|
221
|
+
// serialization. The contract above already says computed getters can throw
|
|
222
|
+
// when their sources are not ready; a `_`-backed getter can too — e.g.
|
|
223
|
+
// QueryInfo.CategoryPath walks Metadata.Provider.QueryCategories, which does
|
|
224
|
+
// not exist yet during the initial metadata load. Omitting one key is strictly
|
|
225
|
+
// better than losing the entire snapshot: the value is recomputed lazily on
|
|
226
|
+
// the next access, and the local metadata cache still gets written.
|
|
227
|
+
try {
|
|
228
|
+
result[targetKey] = self[targetKey];
|
|
229
|
+
}
|
|
230
|
+
catch {
|
|
231
|
+
// intentionally omitted from the serialized shape
|
|
133
232
|
}
|
|
134
|
-
proto = Object.getPrototypeOf(proto);
|
|
135
233
|
}
|
|
136
234
|
}
|
|
137
235
|
return result;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"baseInfo.js","sourceRoot":"","sources":["../../src/generic/baseInfo.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,MAAM,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"baseInfo.js","sourceRoot":"","sources":["../../src/generic/baseInfo.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,MAAM,QAAQ,CAAC;AAGnD;;;;;GAKG;AACH,MAAM,eAAe,GAAG,IAAI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C,CAAC;gBACD,MAAM,CAAC;oBACH,kDAAkD;gBACtD,CAAC;YACL,CAAC;QACL,CAAC;QAED,OAAO,MAAM,CAAC;IAClB,CAAC;CACJ"}
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Context tokens and property defaults.
|
|
3
|
+
*
|
|
4
|
+
* A property (a User View property, a dashboard property, a query's server-set variable) can
|
|
5
|
+
* default to a fixed value or to a context token: a name from a closed list, worked out from the
|
|
6
|
+
* context user and the clock alone. The same resolver runs in the browser and on the server, so
|
|
7
|
+
* the two can differ only in the time zone they are given.
|
|
8
|
+
*
|
|
9
|
+
* - User tokens (`Context.UserID`, `Context.UserEmail`, `Context.UserName`) need a context user;
|
|
10
|
+
* without one they throw rather than resolve to a blank.
|
|
11
|
+
* - **WARNING — SQL template escaping (`| sqlString`):** `Context.UserEmail` and `Context.UserName`
|
|
12
|
+
* resolve to raw, unescaped strings (for example `O'Brien`) and reach Nunjucks query templates with
|
|
13
|
+
* `autoescape: false`. Query templates **must** pipe them through `| sqlString`
|
|
14
|
+
* (e.g. `WHERE Email = {{ Context.UserEmail | sqlString }}` or
|
|
15
|
+
* `WHERE Name = {{ Context.UserName | sqlString }}`). Rendering `{{ Context.UserEmail }}` or
|
|
16
|
+
* `{{ Context.UserName }}` bare produces broken SQL on apostrophes and opens SQL injection.
|
|
17
|
+
* (User View properties are escaped automatically by `UserViewPropertyWhereClause`.)
|
|
18
|
+
* - Date tokens give a `YYYY-MM-DD` date in the given zone (`Context.Today`, `Context.StartOf*`),
|
|
19
|
+
* or an ISO 8601 instant (`Context.Now`). Only date tokens take an offset.
|
|
20
|
+
* - The zone is an IANA name, `'UTC'` when none is given. Weeks start on Monday (ISO 8601) unless
|
|
21
|
+
* the context says Sunday.
|
|
22
|
+
*/
|
|
23
|
+
/** Every context token. The list is closed: an app's own context is a property value, never a token. */
|
|
24
|
+
export declare const CONTEXT_TOKENS: readonly ["Context.UserID", "Context.UserEmail", "Context.UserName", "Context.Now", "Context.Today", "Context.StartOfWeek", "Context.StartOfMonth", "Context.StartOfQuarter", "Context.StartOfYear"];
|
|
25
|
+
/** A context token: one of {@link CONTEXT_TOKENS}. */
|
|
26
|
+
export type ContextToken = typeof CONTEXT_TOKENS[number];
|
|
27
|
+
/**
|
|
28
|
+
* The version of what {@link CONTEXT_TOKENS} means. Approval fingerprints include it, so an approval
|
|
29
|
+
* given under one meaning is stale under another. Bump it whenever a token is added, removed or
|
|
30
|
+
* worked out differently (a new week start, a different date format, a different user field).
|
|
31
|
+
*/
|
|
32
|
+
export declare const CONTEXT_TOKEN_CONTRACT_VERSION = 1;
|
|
33
|
+
/** The value types a property can declare. */
|
|
34
|
+
export declare const PROPERTY_VALUE_TYPES: readonly ["string", "number", "boolean", "date", "uuid"];
|
|
35
|
+
/** A property's value type: one of {@link PROPERTY_VALUE_TYPES}. */
|
|
36
|
+
export type PropertyValueType = typeof PROPERTY_VALUE_TYPES[number];
|
|
37
|
+
/** The units an offset can move a date token by. */
|
|
38
|
+
export declare const PROPERTY_OFFSET_UNITS: readonly ["day", "week", "month", "quarter", "year"];
|
|
39
|
+
/** An offset unit: one of {@link PROPERTY_OFFSET_UNITS}. */
|
|
40
|
+
export type PropertyOffsetUnit = typeof PROPERTY_OFFSET_UNITS[number];
|
|
41
|
+
/** Moves a date token: `{ Amount: -30, Unit: 'day' }` is thirty days earlier. */
|
|
42
|
+
export interface PropertyDefaultOffset {
|
|
43
|
+
/** A whole number; negative moves back. */
|
|
44
|
+
Amount: number;
|
|
45
|
+
Unit: PropertyOffsetUnit;
|
|
46
|
+
}
|
|
47
|
+
/** A property value, fixed or resolved. */
|
|
48
|
+
export type PropertyValue = string | number | boolean | null;
|
|
49
|
+
/**
|
|
50
|
+
* A property's default: a fixed value, or a token worked out when the value is used. Set exactly
|
|
51
|
+
* one of `Value` and `Token`. This is the shape the `MJ: User Views.Properties` JSON stores.
|
|
52
|
+
*/
|
|
53
|
+
export interface PropertyDefault {
|
|
54
|
+
/** A fixed value. Set this or Token, not both. */
|
|
55
|
+
Value?: PropertyValue;
|
|
56
|
+
/** A context token. Set this or Value, not both. */
|
|
57
|
+
Token?: ContextToken;
|
|
58
|
+
/** Moves a date token; refused on a user token and on a fixed value. */
|
|
59
|
+
Offset?: PropertyDefaultOffset;
|
|
60
|
+
}
|
|
61
|
+
/** The comparison a User View property's value drives. */
|
|
62
|
+
export type UserViewPropertyOperator = '=' | '<>' | 'IN' | '>' | '>=' | '<' | '<=';
|
|
63
|
+
/** The field a User View property filters, and how. */
|
|
64
|
+
export interface UserViewPropertyTarget {
|
|
65
|
+
/** A field of the view's entity. */
|
|
66
|
+
Field: string;
|
|
67
|
+
Operator: UserViewPropertyOperator;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* One declared property of a User View: a named, typed input that adds one predicate on its
|
|
71
|
+
* target field when a run gives it a value or it has a default. Stored as a JSON array in the
|
|
72
|
+
* `Properties` column of `MJ: User Views`.
|
|
73
|
+
*/
|
|
74
|
+
export interface UserViewProperty {
|
|
75
|
+
/** Unique within the view. */
|
|
76
|
+
Name: string;
|
|
77
|
+
/** The value's type. A value of another type is refused. */
|
|
78
|
+
Type: PropertyValueType;
|
|
79
|
+
/** Shown to whoever sets the property. */
|
|
80
|
+
Description?: string;
|
|
81
|
+
/** Used when a run gives no value: a fixed value or a context token. */
|
|
82
|
+
Default?: PropertyDefault;
|
|
83
|
+
/** True: a run with no value and no default is refused. */
|
|
84
|
+
IsRequired?: boolean;
|
|
85
|
+
/** False: only server code may set it, and a client value is refused. Default true. */
|
|
86
|
+
AllowOverride?: boolean;
|
|
87
|
+
/** The predicate the value drives. */
|
|
88
|
+
Target: UserViewPropertyTarget;
|
|
89
|
+
}
|
|
90
|
+
/** What a token is worked out from. */
|
|
91
|
+
export interface PropertyResolutionContext {
|
|
92
|
+
/** The context user. Required by the user tokens. `UserInfo` fits. */
|
|
93
|
+
User?: {
|
|
94
|
+
ID: string;
|
|
95
|
+
Email?: string;
|
|
96
|
+
Name?: string;
|
|
97
|
+
};
|
|
98
|
+
/** The clock. Defaults to the current time. */
|
|
99
|
+
Now?: Date;
|
|
100
|
+
/** IANA time zone the date tokens are worked out in. Defaults to `'UTC'`. */
|
|
101
|
+
TimeZone?: string;
|
|
102
|
+
/** First day of the week for `Context.StartOfWeek`: 1 = Monday (default, ISO 8601), 0 = Sunday. */
|
|
103
|
+
WeekStartsOn?: 0 | 1;
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* The request header that carries the caller's IANA time zone. `GraphQLDataProvider` sends it;
|
|
107
|
+
* MJServer reads it into `UserPayload.TimeZone`.
|
|
108
|
+
*/
|
|
109
|
+
export declare const TIME_ZONE_HEADER = "x-mj-timezone";
|
|
110
|
+
/** True when `name` is a time zone this runtime's `Intl` accepts (an IANA name such as `'Europe/Paris'`). */
|
|
111
|
+
export declare function IsValidTimeZone(name: string | null | undefined): boolean;
|
|
112
|
+
/** This runtime's own IANA time zone, or undefined where `Intl` gives none. */
|
|
113
|
+
export declare function GetLocalTimeZone(): string | undefined;
|
|
114
|
+
/** True when `token` is one of {@link CONTEXT_TOKENS}. */
|
|
115
|
+
export declare function IsContextToken(token: string | null | undefined): token is ContextToken;
|
|
116
|
+
/**
|
|
117
|
+
* Works out a property default: the fixed value, or the token resolved by {@link ResolveContextToken}.
|
|
118
|
+
* @throws when the default is malformed (see {@link ValidatePropertyDefault}) or the token cannot be resolved
|
|
119
|
+
*/
|
|
120
|
+
export declare function ResolvePropertyDefault(def: PropertyDefault, ctx: PropertyResolutionContext): PropertyValue;
|
|
121
|
+
/**
|
|
122
|
+
* Works out one context token.
|
|
123
|
+
* @returns the user's ID, email or name; a `YYYY-MM-DD` date in the context's zone; or, for
|
|
124
|
+
* `Context.Now`, an ISO 8601 instant
|
|
125
|
+
* @throws on an unknown token, a bad offset, an offset on a user token, a user token with no
|
|
126
|
+
* context user, or an invalid time zone
|
|
127
|
+
*/
|
|
128
|
+
export declare function ResolveContextToken(token: ContextToken, offset: PropertyDefaultOffset | undefined, ctx: PropertyResolutionContext): string;
|
|
129
|
+
/**
|
|
130
|
+
* Checks a property default against the property's type, as when the definition is saved.
|
|
131
|
+
* @returns the problems found; empty when the default is valid
|
|
132
|
+
*/
|
|
133
|
+
export declare function ValidatePropertyDefault(def: PropertyDefault, type: PropertyValueType): string[];
|
|
134
|
+
/** True when a value fits the property type: a finite number, a boolean, a valid UUID or ISO date, or a string. Null fits every type. */
|
|
135
|
+
export declare function IsPropertyValueOfType(value: PropertyValue, type: PropertyValueType): boolean;
|
|
136
|
+
//# sourceMappingURL=contextTokens.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contextTokens.d.ts","sourceRoot":"","sources":["../../src/generic/contextTokens.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAIH,wGAAwG;AACxG,eAAO,MAAM,cAAc,sMAUjB,CAAC;AAEX,sDAAsD;AACtD,MAAM,MAAM,YAAY,GAAG,OAAO,cAAc,CAAC,MAAM,CAAC,CAAC;AAEzD;;;;GAIG;AACH,eAAO,MAAM,8BAA8B,IAAI,CAAC;AAEhD,8CAA8C;AAC9C,eAAO,MAAM,oBAAoB,0DAA2D,CAAC;AAE7F,oEAAoE;AACpE,MAAM,MAAM,iBAAiB,GAAG,OAAO,oBAAoB,CAAC,MAAM,CAAC,CAAC;AAEpE,oDAAoD;AACpD,eAAO,MAAM,qBAAqB,sDAAuD,CAAC;AAE1F,4DAA4D;AAC5D,MAAM,MAAM,kBAAkB,GAAG,OAAO,qBAAqB,CAAC,MAAM,CAAC,CAAC;AAEtE,iFAAiF;AACjF,MAAM,WAAW,qBAAqB;IAClC,2CAA2C;IAC3C,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,kBAAkB,CAAC;CAC5B;AAED,2CAA2C;AAC3C,MAAM,MAAM,aAAa,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,CAAC;AAE7D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