@memberjunction/core 6.1.0-edge.2 → 6.1.0-edge.3
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/LICENSE +180 -4
- package/dist/generic/JSONType-interfaces/IEntityConfiguration.d.ts +120 -0
- package/dist/generic/JSONType-interfaces/IEntityConfiguration.d.ts.map +1 -0
- package/dist/generic/JSONType-interfaces/IEntityConfiguration.js +6 -0
- package/dist/generic/JSONType-interfaces/IEntityConfiguration.js.map +1 -0
- package/dist/generic/JSONType-interfaces/IEntityFieldConfiguration.d.ts +31 -0
- package/dist/generic/JSONType-interfaces/IEntityFieldConfiguration.d.ts.map +1 -0
- package/dist/generic/JSONType-interfaces/IEntityFieldConfiguration.js +6 -0
- package/dist/generic/JSONType-interfaces/IEntityFieldConfiguration.js.map +1 -0
- package/dist/generic/JSONType-interfaces/IEntityRelationshipConfiguration.d.ts +75 -0
- package/dist/generic/JSONType-interfaces/IEntityRelationshipConfiguration.d.ts.map +1 -0
- package/dist/generic/JSONType-interfaces/IEntityRelationshipConfiguration.js +6 -0
- package/dist/generic/JSONType-interfaces/IEntityRelationshipConfiguration.js.map +1 -0
- package/dist/generic/JSONType-interfaces/IFileStorageProviderConfiguration.d.ts +19 -0
- package/dist/generic/JSONType-interfaces/IFileStorageProviderConfiguration.d.ts.map +1 -0
- package/dist/generic/JSONType-interfaces/IFileStorageProviderConfiguration.js +6 -0
- package/dist/generic/JSONType-interfaces/IFileStorageProviderConfiguration.js.map +1 -0
- package/dist/generic/authTypes.d.ts +69 -0
- package/dist/generic/authTypes.d.ts.map +1 -1
- package/dist/generic/baseEngine.d.ts +14 -0
- package/dist/generic/baseEngine.d.ts.map +1 -1
- package/dist/generic/baseEngine.js +53 -13
- package/dist/generic/baseEngine.js.map +1 -1
- package/dist/generic/baseEntity.d.ts +113 -20
- package/dist/generic/baseEntity.d.ts.map +1 -1
- package/dist/generic/baseEntity.js +351 -49
- package/dist/generic/baseEntity.js.map +1 -1
- package/dist/generic/baseInfo.d.ts.map +1 -1
- package/dist/generic/baseInfo.js +16 -4
- package/dist/generic/baseInfo.js.map +1 -1
- package/dist/generic/compositeKey.d.ts +30 -0
- package/dist/generic/compositeKey.d.ts.map +1 -1
- package/dist/generic/compositeKey.js +97 -0
- package/dist/generic/compositeKey.js.map +1 -1
- package/dist/generic/databaseProviderBase.d.ts.map +1 -1
- package/dist/generic/databaseProviderBase.js +9 -5
- package/dist/generic/databaseProviderBase.js.map +1 -1
- package/dist/generic/embeddedRecord.d.ts +123 -0
- package/dist/generic/embeddedRecord.d.ts.map +1 -0
- package/dist/generic/embeddedRecord.js +356 -0
- package/dist/generic/embeddedRecord.js.map +1 -0
- package/dist/generic/entityCompanion.d.ts +20 -2
- package/dist/generic/entityCompanion.d.ts.map +1 -1
- package/dist/generic/entityCompanion.js +17 -1
- package/dist/generic/entityCompanion.js.map +1 -1
- package/dist/generic/entityConfiguration.d.ts +131 -0
- package/dist/generic/entityConfiguration.d.ts.map +1 -0
- package/dist/generic/entityConfiguration.js +346 -0
- package/dist/generic/entityConfiguration.js.map +1 -0
- package/dist/generic/entityInfo.d.ts +274 -4
- package/dist/generic/entityInfo.d.ts.map +1 -1
- package/dist/generic/entityInfo.js +502 -14
- package/dist/generic/entityInfo.js.map +1 -1
- package/dist/generic/entitySavePlan.d.ts +40 -11
- package/dist/generic/entitySavePlan.d.ts.map +1 -1
- package/dist/generic/entitySavePlan.js +70 -2
- package/dist/generic/entitySavePlan.js.map +1 -1
- package/dist/generic/interfaces.d.ts +6 -24
- package/dist/generic/interfaces.d.ts.map +1 -1
- package/dist/generic/interfaces.js +6 -24
- package/dist/generic/interfaces.js.map +1 -1
- package/dist/generic/localCacheManager.d.ts.map +1 -1
- package/dist/generic/localCacheManager.js +10 -0
- package/dist/generic/localCacheManager.js.map +1 -1
- package/dist/generic/providerBase.d.ts +19 -0
- package/dist/generic/providerBase.d.ts.map +1 -1
- package/dist/generic/providerBase.js +71 -6
- package/dist/generic/providerBase.js.map +1 -1
- package/dist/generic/relatedRecordCollection.d.ts +25 -3
- package/dist/generic/relatedRecordCollection.d.ts.map +1 -1
- package/dist/generic/relatedRecordCollection.js +53 -7
- package/dist/generic/relatedRecordCollection.js.map +1 -1
- package/dist/generic/runQuery.d.ts +14 -0
- package/dist/generic/runQuery.d.ts.map +1 -1
- package/dist/generic/runQuery.js.map +1 -1
- package/dist/generic/saveEntityGraphOperation.js +1 -1
- package/dist/generic/saveEntityGraphOperation.js.map +1 -1
- package/dist/generic/securityInfo.d.ts.map +1 -1
- package/dist/generic/securityInfo.js +15 -5
- package/dist/generic/securityInfo.js.map +1 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -1
- package/dist/views/runView.d.ts +23 -0
- package/dist/views/runView.d.ts.map +1 -1
- package/dist/views/runView.js +20 -0
- package/dist/views/runView.js.map +1 -1
- package/package.json +5 -4
- package/readme.md +20 -1
|
@@ -0,0 +1,356 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview `EmbeddedRecord<T>` — a 1:1 peer `BaseEntity` that loads, validates
|
|
3
|
+
* and persists as one unit with its owner, joined by an **owner-held** foreign key.
|
|
4
|
+
*
|
|
5
|
+
* This is the third composition axis on `BaseEntity`, next to IS-A (shared PK) and
|
|
6
|
+
* related-record collections (FK on the related row). The FK lives on the owner
|
|
7
|
+
* (`Deal.OrderID`), so the save order inverts: the peer persists first, the owner
|
|
8
|
+
* stamps the FK, then the owner persists.
|
|
9
|
+
*
|
|
10
|
+
* Callers never hold this class. They see `owner.OrderID_Object` (the entity) and
|
|
11
|
+
* `owner.OrderID_EnsureObject()` (sync provision for a nullable FK).
|
|
12
|
+
*
|
|
13
|
+
* @module @memberjunction/core
|
|
14
|
+
*/
|
|
15
|
+
import { CompositeKey, KeyValuePair } from './compositeKey.js';
|
|
16
|
+
import { EntityCompanion } from './entityCompanion.js';
|
|
17
|
+
import { ValidationErrorInfo, ValidationErrorType } from './entityInfo.js';
|
|
18
|
+
/**
|
|
19
|
+
* Internal companion for one owner-held 1:1 peer.
|
|
20
|
+
*
|
|
21
|
+
* @typeParam T - The embedded entity type.
|
|
22
|
+
*/
|
|
23
|
+
export class EmbeddedRecord extends EntityCompanion {
|
|
24
|
+
constructor(owner, options) {
|
|
25
|
+
super(owner);
|
|
26
|
+
this.instance = null;
|
|
27
|
+
this.exposed = false;
|
|
28
|
+
this.cleared = false;
|
|
29
|
+
this.constructing = false;
|
|
30
|
+
this.ForeignKeyField = options.ForeignKeyField;
|
|
31
|
+
this.RelatedEntityName = options.RelatedEntity;
|
|
32
|
+
const fieldInfo = owner.EntityInfo?.Fields.find(f => f.Name === options.ForeignKeyField);
|
|
33
|
+
this.Name = `${fieldInfo?.CodeName ?? options.ForeignKeyField}_Object`;
|
|
34
|
+
this.ClearMode = options.OnClear ?? 'orphan';
|
|
35
|
+
this.LoadNested = options.LoadNested ?? 'inherit';
|
|
36
|
+
}
|
|
37
|
+
/** The live peer, or `null` when a nullable FK is not yet provisioned. */
|
|
38
|
+
get Value() {
|
|
39
|
+
return this.exposed ? this.instance : null;
|
|
40
|
+
}
|
|
41
|
+
/** True when the getter will return an object. */
|
|
42
|
+
get IsProvisioned() {
|
|
43
|
+
return this.exposed && this.instance !== null;
|
|
44
|
+
}
|
|
45
|
+
/** True when the owner's FK column refuses null. */
|
|
46
|
+
get IsRequired() {
|
|
47
|
+
const field = this.Owner.GetFieldByName(this.ForeignKeyField);
|
|
48
|
+
return field?.EntityFieldInfo.AllowsNull === false;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Constructs the related entity instance without `NewRecord` / `Load`.
|
|
52
|
+
* Called from `BaseEntity.InitializeEmbeddedRecords` during `GetEntityObject`.
|
|
53
|
+
*
|
|
54
|
+
* @param visited - Entity names already being constructed, for cycle detection.
|
|
55
|
+
*/
|
|
56
|
+
async InitializeInstance(visited) {
|
|
57
|
+
if (this.instance || this.constructing) {
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
// Path-set, not a global set: a sibling targeting the same entity
|
|
61
|
+
// (BillTo + ShipTo) is not a cycle — InitializeEmbeddedRecords copies
|
|
62
|
+
// `visited` per sibling so they never see each other in-flight. A
|
|
63
|
+
// self-FK or A→B→A ancestor is on this path and must stop here, or
|
|
64
|
+
// ConstructUninitializedEntity's recurse would construct forever.
|
|
65
|
+
if (visited.has(this.RelatedEntityName)) {
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
this.constructing = true;
|
|
69
|
+
visited.add(this.RelatedEntityName);
|
|
70
|
+
try {
|
|
71
|
+
this.instance = await this.Owner.ConstructUninitializedEntity(this.RelatedEntityName, visited);
|
|
72
|
+
}
|
|
73
|
+
finally {
|
|
74
|
+
visited.delete(this.RelatedEntityName);
|
|
75
|
+
this.constructing = false;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Sync provision. Idempotent. For a required FK this is a no-op after `NewRecord`.
|
|
80
|
+
*/
|
|
81
|
+
Ensure() {
|
|
82
|
+
if (!this.instance) {
|
|
83
|
+
throw new Error(`EmbeddedRecord '${this.Name}' on ${this.Owner.EntityInfo?.Name}: the related ` +
|
|
84
|
+
`'${this.RelatedEntityName}' instance was not constructed. GetEntityObject must ` +
|
|
85
|
+
`run InitializeEmbeddedRecords before Ensure().`);
|
|
86
|
+
}
|
|
87
|
+
if (this.exposed) {
|
|
88
|
+
return this.instance;
|
|
89
|
+
}
|
|
90
|
+
// Always mint a new peer. After Clear()+Save() the leftover instance is
|
|
91
|
+
// the orphaned row (still IsSaved). Restamping its PK would silently
|
|
92
|
+
// re-attach it. Re-attachment is an explicit FK set, not Ensure's job.
|
|
93
|
+
this.instance.NewRecord();
|
|
94
|
+
this.stampOwnerKey();
|
|
95
|
+
this.exposed = true;
|
|
96
|
+
this.cleared = false;
|
|
97
|
+
return this.instance;
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Marks the relationship for removal on the next save. Does not persist by itself.
|
|
101
|
+
*/
|
|
102
|
+
Clear() {
|
|
103
|
+
if (this.ClearMode === 'refuse') {
|
|
104
|
+
throw new Error(`EmbeddedRecord '${this.Name}' on ${this.Owner.EntityInfo?.Name}: Clear() is refused ` +
|
|
105
|
+
`(OnClear: 'refuse'). Detaching this relationship is not allowed.`);
|
|
106
|
+
}
|
|
107
|
+
this.exposed = false;
|
|
108
|
+
this.cleared = true;
|
|
109
|
+
this.Owner.Set(this.ForeignKeyField, null);
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Called from the owner's `NewRecord()`. Required FKs are provisioned here so
|
|
113
|
+
* `owner.OrderID_Object` is usable immediately after `GetEntityObject`.
|
|
114
|
+
*/
|
|
115
|
+
OnOwnerNewRecord() {
|
|
116
|
+
this.cleared = false;
|
|
117
|
+
if (!this.instance) {
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
if (this.IsRequired) {
|
|
121
|
+
const existingFk = this.Owner.Get(this.ForeignKeyField);
|
|
122
|
+
if (existingFk !== null && existingFk !== undefined && existingFk !== '') {
|
|
123
|
+
// Caller passed NewRecord({ [FK]: existingId }). Do not mint a
|
|
124
|
+
// new peer and overwrite that FK. The owner points at an existing
|
|
125
|
+
// row; Load() will hydrate it.
|
|
126
|
+
this.exposed = false;
|
|
127
|
+
}
|
|
128
|
+
else {
|
|
129
|
+
this.instance.NewRecord();
|
|
130
|
+
this.stampOwnerKey();
|
|
131
|
+
this.exposed = true;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
else {
|
|
135
|
+
this.exposed = false;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
/** @inheritdoc */
|
|
139
|
+
get Dirty() {
|
|
140
|
+
if (this.cleared) {
|
|
141
|
+
return true;
|
|
142
|
+
}
|
|
143
|
+
if (!this.exposed || !this.instance) {
|
|
144
|
+
return false;
|
|
145
|
+
}
|
|
146
|
+
return this.instance.Dirty;
|
|
147
|
+
}
|
|
148
|
+
/** @inheritdoc */
|
|
149
|
+
Validate(result) {
|
|
150
|
+
if (!this.exposed || !this.instance) {
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
153
|
+
const inner = this.instance.Validate();
|
|
154
|
+
if (!inner.Success) {
|
|
155
|
+
result.Success = false;
|
|
156
|
+
for (const err of inner.Errors) {
|
|
157
|
+
result.Errors.push(this.prefixError(err));
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
/** @inheritdoc */
|
|
162
|
+
async ValidateAsync(result) {
|
|
163
|
+
if (!this.exposed || !this.instance) {
|
|
164
|
+
return;
|
|
165
|
+
}
|
|
166
|
+
const inner = await this.instance.ValidateAsync();
|
|
167
|
+
if (!inner.Success) {
|
|
168
|
+
result.Success = false;
|
|
169
|
+
for (const err of inner.Errors) {
|
|
170
|
+
result.Errors.push(this.prefixError(err));
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
/** @inheritdoc */
|
|
175
|
+
ContributeSaveWork(plan, options) {
|
|
176
|
+
if (this.cleared) {
|
|
177
|
+
this.contributeClearWork(plan);
|
|
178
|
+
return;
|
|
179
|
+
}
|
|
180
|
+
if (!this.exposed || !this.instance) {
|
|
181
|
+
return;
|
|
182
|
+
}
|
|
183
|
+
if (this.instance.IsSaved && !this.instance.Dirty && !options?.IgnoreDirtyState) {
|
|
184
|
+
return;
|
|
185
|
+
}
|
|
186
|
+
plan.AddSaveBeforeRoot(this.instance, this.Name);
|
|
187
|
+
plan.AddRootPrepare(() => this.stampOwnerKey());
|
|
188
|
+
}
|
|
189
|
+
/** @inheritdoc */
|
|
190
|
+
ContributePostDeleteWork(plan) {
|
|
191
|
+
if (this.ClearMode !== 'delete') {
|
|
192
|
+
return;
|
|
193
|
+
}
|
|
194
|
+
if (!this.instance || !this.instance.IsSaved) {
|
|
195
|
+
return;
|
|
196
|
+
}
|
|
197
|
+
plan.AddDelete(this.instance, `${this.Name}.OnOwnerDelete`);
|
|
198
|
+
}
|
|
199
|
+
/** @inheritdoc */
|
|
200
|
+
async LoadEager(visited = new Set()) {
|
|
201
|
+
if (!this.instance) {
|
|
202
|
+
return;
|
|
203
|
+
}
|
|
204
|
+
const fk = this.Owner.Get(this.ForeignKeyField);
|
|
205
|
+
if (fk === null || fk === undefined || fk === '') {
|
|
206
|
+
this.exposed = false;
|
|
207
|
+
this.cleared = false;
|
|
208
|
+
// A reused owner instance can still hold the previous record's
|
|
209
|
+
// saved peer. Reset it so Ensure() does not restamp that PK and
|
|
210
|
+
// OnClear:'delete' does not delete the previous peer.
|
|
211
|
+
if (this.instance.IsSaved) {
|
|
212
|
+
this.instance.NewRecord();
|
|
213
|
+
}
|
|
214
|
+
return;
|
|
215
|
+
}
|
|
216
|
+
const token = `${this.RelatedEntityName}:${String(fk)}`;
|
|
217
|
+
if (visited.has(token)) {
|
|
218
|
+
throw new Error(`EmbeddedRecord '${this.Name}' on ${this.Owner.EntityInfo?.Name}: load cycle at ` +
|
|
219
|
+
`${token}. A self-parented or mutually-referential embed cannot inherit forever.`);
|
|
220
|
+
}
|
|
221
|
+
const next = new Set(visited);
|
|
222
|
+
next.add(token);
|
|
223
|
+
// Nested embeds of a different entity were constructed with the owner.
|
|
224
|
+
// Self-FK / cycle peers stay unconstructed until this load walk; init
|
|
225
|
+
// them now so InnerLoad's loadEagerCompanions can inherit.
|
|
226
|
+
await this.instance.InitializeEmbeddedRecords();
|
|
227
|
+
this.instance.SetEmbeddedLoadVisited(next);
|
|
228
|
+
try {
|
|
229
|
+
const loaded = await this.instance.InnerLoad(this.keyFromForeignKey(fk));
|
|
230
|
+
if (!loaded) {
|
|
231
|
+
if (this.IsRequired) {
|
|
232
|
+
throw new Error(`EmbeddedRecord '${this.Name}' on ${this.Owner.EntityInfo?.Name}: required ` +
|
|
233
|
+
`FK ${this.ForeignKeyField}='${fk}' does not resolve to a ${this.RelatedEntityName} row.`);
|
|
234
|
+
}
|
|
235
|
+
this.exposed = false;
|
|
236
|
+
return;
|
|
237
|
+
}
|
|
238
|
+
this.exposed = true;
|
|
239
|
+
this.cleared = false;
|
|
240
|
+
if (this.LoadNested === 'related') {
|
|
241
|
+
await this.instance.LoadRelatedRecords();
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
finally {
|
|
245
|
+
this.instance.SetEmbeddedLoadVisited(undefined);
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
/** @inheritdoc */
|
|
249
|
+
AcceptChanges() {
|
|
250
|
+
this.cleared = false;
|
|
251
|
+
}
|
|
252
|
+
/** @inheritdoc */
|
|
253
|
+
async Serialize(mode = 'request') {
|
|
254
|
+
if (this.cleared) {
|
|
255
|
+
return { Fields: {}, IsNew: false, Cleared: true, Companions: null };
|
|
256
|
+
}
|
|
257
|
+
if (!this.exposed || !this.instance) {
|
|
258
|
+
return null;
|
|
259
|
+
}
|
|
260
|
+
// Request: omit a clean saved peer so a header-only edit does not ship it.
|
|
261
|
+
// Result: always ship an exposed peer so the client can mark it saved.
|
|
262
|
+
// Skipping result-serialize left the client IsSaved=false; the next Save
|
|
263
|
+
// re-sent IsNew:true and the server re-INSERTed the same UUID.
|
|
264
|
+
if (mode !== 'result' && this.instance.IsSaved && !this.instance.Dirty) {
|
|
265
|
+
return null;
|
|
266
|
+
}
|
|
267
|
+
const companions = await this.instance.SerializeCompanions(mode);
|
|
268
|
+
return {
|
|
269
|
+
EntityName: this.instance.EntityInfo?.Name ?? this.RelatedEntityName,
|
|
270
|
+
Fields: this.instance.GetAll(),
|
|
271
|
+
IsNew: !this.instance.IsSaved,
|
|
272
|
+
Cleared: false,
|
|
273
|
+
Companions: companions.length > 0 ? companions : null,
|
|
274
|
+
};
|
|
275
|
+
}
|
|
276
|
+
/** @inheritdoc */
|
|
277
|
+
async Deserialize(data, mode = 'request') {
|
|
278
|
+
if (!data) {
|
|
279
|
+
return;
|
|
280
|
+
}
|
|
281
|
+
if (data.Cleared) {
|
|
282
|
+
this.exposed = false;
|
|
283
|
+
this.cleared = true;
|
|
284
|
+
this.Owner.Set(this.ForeignKeyField, null);
|
|
285
|
+
return;
|
|
286
|
+
}
|
|
287
|
+
if (data.EntityName && data.EntityName !== this.RelatedEntityName && (!this.instance || this.instance.EntityInfo?.Name !== data.EntityName)) {
|
|
288
|
+
const provider = this.Owner.ProviderToUse;
|
|
289
|
+
if (provider) {
|
|
290
|
+
this.instance = (await provider.GetEntityObject(data.EntityName, this.Owner.ContextCurrentUser));
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
if (!this.instance) {
|
|
294
|
+
await this.InitializeInstance(new Set());
|
|
295
|
+
}
|
|
296
|
+
if (!this.instance) {
|
|
297
|
+
throw new Error(`EmbeddedRecord '${this.Name}': cannot deserialize — no instance of ${data.EntityName ?? this.RelatedEntityName}.`);
|
|
298
|
+
}
|
|
299
|
+
await this.applyWire(data, mode);
|
|
300
|
+
this.exposed = true;
|
|
301
|
+
this.cleared = false;
|
|
302
|
+
}
|
|
303
|
+
async applyWire(data, mode) {
|
|
304
|
+
const target = this.instance;
|
|
305
|
+
if (mode === 'result') {
|
|
306
|
+
await target.LoadFromData(data.Fields, true);
|
|
307
|
+
if (data.Companions && data.Companions.length > 0) {
|
|
308
|
+
await target.DeserializeCompanions(data.Companions, 'result');
|
|
309
|
+
}
|
|
310
|
+
return;
|
|
311
|
+
}
|
|
312
|
+
if (data.IsNew) {
|
|
313
|
+
target.NewRecord();
|
|
314
|
+
target.SetMany(data.Fields, true);
|
|
315
|
+
}
|
|
316
|
+
else {
|
|
317
|
+
await this.loadExistingThenApply(target, data.Fields);
|
|
318
|
+
}
|
|
319
|
+
if (data.Companions && data.Companions.length > 0) {
|
|
320
|
+
await target.DeserializeCompanions(data.Companions, mode);
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
async loadExistingThenApply(target, fields) {
|
|
324
|
+
const key = new CompositeKey(target.EntityInfo.PrimaryKeys.map(pk => new KeyValuePair(pk.Name, fields[pk.Name])));
|
|
325
|
+
const loaded = await target.InnerLoad(key);
|
|
326
|
+
if (!loaded) {
|
|
327
|
+
throw new Error(`EmbeddedRecord '${this.Name}': cannot load existing ${this.RelatedEntityName} ` +
|
|
328
|
+
`record ${key.ToString()} referenced by the incoming payload.`);
|
|
329
|
+
}
|
|
330
|
+
target.SetMany(fields, true);
|
|
331
|
+
}
|
|
332
|
+
contributeClearWork(plan) {
|
|
333
|
+
plan.AddRootPrepare(() => this.Owner.Set(this.ForeignKeyField, null));
|
|
334
|
+
if (this.ClearMode === 'delete' && this.instance?.IsSaved) {
|
|
335
|
+
plan.AddDelete(this.instance, `${this.Name}.Cleared`);
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
stampOwnerKey() {
|
|
339
|
+
const key = this.instance?.FirstPrimaryKey?.Value;
|
|
340
|
+
if (key === null || key === undefined || key === '') {
|
|
341
|
+
return;
|
|
342
|
+
}
|
|
343
|
+
this.Owner.Set(this.ForeignKeyField, key);
|
|
344
|
+
}
|
|
345
|
+
keyFromForeignKey(fk) {
|
|
346
|
+
const pks = this.instance.EntityInfo.PrimaryKeys;
|
|
347
|
+
if (pks.length === 1) {
|
|
348
|
+
return CompositeKey.FromID(fk);
|
|
349
|
+
}
|
|
350
|
+
return new CompositeKey(pks.map(pk => new KeyValuePair(pk.Name, fk)));
|
|
351
|
+
}
|
|
352
|
+
prefixError(err) {
|
|
353
|
+
return new ValidationErrorInfo(`${this.Name}.${err.Source ?? ''}`.replace(/\.$/, ''), err.Message, err.Value, err.Type ?? ValidationErrorType.Failure);
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
//# sourceMappingURL=embeddedRecord.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"embeddedRecord.js","sourceRoot":"","sources":["../../src/generic/embeddedRecord.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAGH,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,gBAAgB,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AAe,EAAE,KAAK,CAAC;QAClD,IAAI,GAAG,KAAK,IAAI,IAAI,GAAG,KAAK,SAAS,IAAI,GAAG,KAAK,EAAE,EAAE,CAAC;YAClD,OAAO;QACX,CAAC;QACD,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,eAAe,EAAE,GAAG,CAAC,CAAC;IAC9C,CAAC;IAEO,iBAAiB,CAAC,EAAW;QACjC,MAAM,GAAG,GAAG,IAAI,CAAC,QAAS,CAAC,UAAU,CAAC,WAAW,CAAC;QAClD,IAAI,GAAG,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACnB,OAAO,YAAY,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;QACnC,CAAC;QACD,OAAO,IAAI,YAAY,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,CAAC,IAAI,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC;IAC1E,CAAC;IAEO,WAAW,CAAC,GAAwB;QACxC,OAAO,IAAI,mBAAmB,CAC1B,GAAG,IAAI,CAAC,IAAI,IAAI,GAAG,CAAC,MAAM,IAAI,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,EACrD,GAAG,CAAC,OAAO,EACX,GAAG,CAAC,KAAK,EACT,GAAG,CAAC,IAAI,IAAI,mBAAmB,CAAC,OAAO,CAC1C,CAAC;IACN,CAAC;CACJ"}
|
|
@@ -127,9 +127,13 @@ export declare abstract class EntityCompanion<TWire = unknown> {
|
|
|
127
127
|
* touches only header fields should not ship an empty children array and pay for it on every
|
|
128
128
|
* request.
|
|
129
129
|
*
|
|
130
|
+
* @param mode - `'request'` (default) is the caller's intent — omit a clean saved
|
|
131
|
+
* companion so a header-only edit does not ship it. `'result'` is
|
|
132
|
+
* post-save state the client must adopt so the next save does not
|
|
133
|
+
* re-INSERT a peer the server already persisted.
|
|
130
134
|
* @returns The wire payload, or `null` to omit this companion.
|
|
131
135
|
*/
|
|
132
|
-
abstract Serialize(): Promise<TWire | null>;
|
|
136
|
+
abstract Serialize(mode?: EntityCompanionDeserializeMode): Promise<TWire | null>;
|
|
133
137
|
/**
|
|
134
138
|
* Restores this companion's state from a wire payload produced by {@link Serialize} on the
|
|
135
139
|
* other tier.
|
|
@@ -200,6 +204,16 @@ export declare abstract class EntityCompanion<TWire = unknown> {
|
|
|
200
204
|
* @param _plan - The plan being assembled for this unit of work.
|
|
201
205
|
*/
|
|
202
206
|
ContributeDeleteWork(_plan: EntitySavePlan): void;
|
|
207
|
+
/**
|
|
208
|
+
* Contributes work that must run **after** the owner's own delete node.
|
|
209
|
+
*
|
|
210
|
+
* Related-record collections delete first (they point at the owner). Embedded
|
|
211
|
+
* records delete last (the owner points at them — the FK dies with the owner
|
|
212
|
+
* row, then the peer can go). Default is a no-op.
|
|
213
|
+
*
|
|
214
|
+
* @param _plan - The plan being assembled; the owner's delete node already exists.
|
|
215
|
+
*/
|
|
216
|
+
ContributePostDeleteWork(_plan: EntitySavePlan): void;
|
|
203
217
|
/**
|
|
204
218
|
* Populates this companion from the database, when it is configured to load eagerly.
|
|
205
219
|
*
|
|
@@ -207,8 +221,12 @@ export declare abstract class EntityCompanion<TWire = unknown> {
|
|
|
207
221
|
* from `LoadFromData()` — that is the row-materialization path for
|
|
208
222
|
* `RunView(ResultType:'entity_object')`, so loading children there turns one view into an N+1
|
|
209
223
|
* storm. Set-oriented eager loading is handled by `RunView`'s batched child loading instead.
|
|
224
|
+
*
|
|
225
|
+
* @param _visited - EntityName:PK tokens already on this load walk. Embedded
|
|
226
|
+
* records use it to fail a self-parented / cyclic inherit
|
|
227
|
+
* instead of recursing until the stack dies.
|
|
210
228
|
*/
|
|
211
|
-
LoadEager(): Promise<void>;
|
|
229
|
+
LoadEager(_visited?: Set<string>): Promise<void>;
|
|
212
230
|
/**
|
|
213
231
|
* Resets the companion to its post-save state — clearing pending removals, rebasing dirty
|
|
214
232
|
* tracking, and so on. Called after the graph commits successfully.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"entityCompanion.d.ts","sourceRoot":"","sources":["../../src/generic/entityCompanion.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAEtD;;;;;GAKG;AACH,MAAM,MAAM,sBAAsB,GAAG;IACjC,2DAA2D;IAC3D,IAAI,EAAE,MAAM,CAAC;IACb,uDAAuD;IACvD,IAAI,EAAE,OAAO,CAAC;CACjB,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,qBAAqB,kBAAkB,CAAC;AAErD;;;;;;;;;;;GAWG;AACH,MAAM,MAAM,8BAA8B,GAAG,SAAS,GAAG,QAAQ,CAAC;AAElE;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,8BAAsB,eAAe,CAAC,KAAK,GAAG,OAAO;IACjD;;OAEG;IACH,SAAgB,KAAK,EAAE,UAAU,CAAC;IAElC;;OAEG;gBACS,KAAK,EAAE,UAAU;IAI7B;;;;;;OAMG;IACH,kBAAyB,IAAI,EAAE,MAAM,CAAC;IAEtC
|
|
1
|
+
{"version":3,"file":"entityCompanion.d.ts","sourceRoot":"","sources":["../../src/generic/entityCompanion.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AACvD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,CAAC,KAAK,EAAE,cAAc,GAAG,IAAI;IAI5D;;;;;;;;;;;OAWG;IACU,SAAS,CAAC,QAAQ,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;IAI7D;;;OAGG;IACI,aAAa,IAAI,IAAI;CAG/B"}
|
|
@@ -148,6 +148,18 @@ export class EntityCompanion {
|
|
|
148
148
|
ContributeDeleteWork(_plan) {
|
|
149
149
|
/* no-op by default */
|
|
150
150
|
}
|
|
151
|
+
/**
|
|
152
|
+
* Contributes work that must run **after** the owner's own delete node.
|
|
153
|
+
*
|
|
154
|
+
* Related-record collections delete first (they point at the owner). Embedded
|
|
155
|
+
* records delete last (the owner points at them — the FK dies with the owner
|
|
156
|
+
* row, then the peer can go). Default is a no-op.
|
|
157
|
+
*
|
|
158
|
+
* @param _plan - The plan being assembled; the owner's delete node already exists.
|
|
159
|
+
*/
|
|
160
|
+
ContributePostDeleteWork(_plan) {
|
|
161
|
+
/* no-op by default */
|
|
162
|
+
}
|
|
151
163
|
/**
|
|
152
164
|
* Populates this companion from the database, when it is configured to load eagerly.
|
|
153
165
|
*
|
|
@@ -155,8 +167,12 @@ export class EntityCompanion {
|
|
|
155
167
|
* from `LoadFromData()` — that is the row-materialization path for
|
|
156
168
|
* `RunView(ResultType:'entity_object')`, so loading children there turns one view into an N+1
|
|
157
169
|
* storm. Set-oriented eager loading is handled by `RunView`'s batched child loading instead.
|
|
170
|
+
*
|
|
171
|
+
* @param _visited - EntityName:PK tokens already on this load walk. Embedded
|
|
172
|
+
* records use it to fail a self-parented / cyclic inherit
|
|
173
|
+
* instead of recursing until the stack dies.
|
|
158
174
|
*/
|
|
159
|
-
async LoadEager() {
|
|
175
|
+
async LoadEager(_visited) {
|
|
160
176
|
/* no-op by default */
|
|
161
177
|
}
|
|
162
178
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"entityCompanion.js","sourceRoot":"","sources":["../../src/generic/entityCompanion.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AAoBH;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,eAAe,CAAC;AAgBrD;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAM,OAAgB,eAAe;IAMjC;;OAEG;IACH,YAAY,KAAiB;QACzB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACvB,CAAC;
|
|
1
|
+
{"version":3,"file":"entityCompanion.js","sourceRoot":"","sources":["../../src/generic/entityCompanion.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AAoBH;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,eAAe,CAAC;AAgBrD;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAM,OAAgB,eAAe;IAMjC;;OAEG;IACH,YAAY,KAAiB;QACzB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACvB,CAAC;IAwCD;;;;;;;;OAQG;IACH,IAAW,KAAK;QACZ,OAAO,KAAK,CAAC;IACjB,CAAC;IAED;;;;;;;;;;OAUG;IACI,QAAQ,CAAC,OAAyB;QACrC,sBAAsB;IAC1B,CAAC;IAED;;;;;;;;;;;OAWG;IACI,KAAK,CAAC,aAAa,CAAC,OAAyB;QAChD,sBAAsB;IAC1B,CAAC;IAED;;;;;;;;;;;OAWG;IACI,kBAAkB,CAAC,KAAqB,EAAE,QAA4B;QACzE,sBAAsB;IAC1B,CAAC;IAED;;;;;;;;OAQG;IACI,oBAAoB,CAAC,KAAqB;QAC7C,sBAAsB;IAC1B,CAAC;IAED;;;;;;;;OAQG;IACI,wBAAwB,CAAC,KAAqB;QACjD,sBAAsB;IAC1B,CAAC;IAED;;;;;;;;;;;OAWG;IACI,KAAK,CAAC,SAAS,CAAC,QAAsB;QACzC,sBAAsB;IAC1B,CAAC;IAED;;;OAGG;IACI,aAAa;QAChB,sBAAsB;IAC1B,CAAC;CACJ"}
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
export declare const DEFAULT_AUTO_LEFT_NAV_AT = 8;
|
|
2
|
+
export declare const DEFAULT_PRIMARY_RELATED_BUDGET = 6;
|
|
3
|
+
export declare const RELATED_ROLE_SCORE: {
|
|
4
|
+
readonly RelatedRecordCollection: 200;
|
|
5
|
+
readonly CustomDisplayComponent: 150;
|
|
6
|
+
readonly SameSchema: 100;
|
|
7
|
+
readonly OneToMany: 50;
|
|
8
|
+
readonly BeforeFieldTabs: 40;
|
|
9
|
+
/**
|
|
10
|
+
* Cap for the inbound-relationship hub boost. A related entity that many
|
|
11
|
+
* other entities point at (Order Headers) outranks a satellite with two
|
|
12
|
+
* incoming keys (Task Activities). Applied as `min(cap, 20 * log2(count))`.
|
|
13
|
+
*/
|
|
14
|
+
readonly InboundHubCap: 120;
|
|
15
|
+
readonly CreatedByJoin: -90;
|
|
16
|
+
readonly SatelliteName: -70;
|
|
17
|
+
readonly PlatformSchema: -80;
|
|
18
|
+
};
|
|
19
|
+
export declare const PLATFORM_SCHEMA_NAME = "__mj";
|
|
20
|
+
export type FormLayout = 'accordion' | 'left-nav' | 'auto';
|
|
21
|
+
export type RelatedRolePolicy = 'keep-all-primary' | 'smart';
|
|
22
|
+
export type FormRole = 'Primary' | 'Detail';
|
|
23
|
+
/** L1 membership on a parent form. None never reaches the ranker. */
|
|
24
|
+
export type FormInclusion = 'Primary' | 'More' | 'None';
|
|
25
|
+
import { IEntityConfiguration, IEntityFormConfiguration } from './JSONType-interfaces/IEntityConfiguration.js';
|
|
26
|
+
import { IEntityFieldConfiguration } from './JSONType-interfaces/IEntityFieldConfiguration.js';
|
|
27
|
+
import { IEntityRelationshipConfiguration } from './JSONType-interfaces/IEntityRelationshipConfiguration.js';
|
|
28
|
+
export * from './JSONType-interfaces/IEntityConfiguration.js';
|
|
29
|
+
export * from './JSONType-interfaces/IEntityFieldConfiguration.js';
|
|
30
|
+
export * from './JSONType-interfaces/IEntityRelationshipConfiguration.js';
|
|
31
|
+
export interface IEntityRelationshipJoin {
|
|
32
|
+
mode: 'any';
|
|
33
|
+
fields: string[];
|
|
34
|
+
}
|
|
35
|
+
export type RelatedFormRoleReason = 'explicit-primary' | 'explicit-detail' | 'explicit-none' | 'join-sibling-none' | 'ranked-primary' | 'ranked-detail' | 'keep-all-primary' | 'under-budget' | 'install-primary' | 'install-more' | 'install-none';
|
|
36
|
+
export type FormChromeRuleTargetKind = 'Relationship' | 'Contribution';
|
|
37
|
+
/**
|
|
38
|
+
* One install-overlay (L3) pin. Loaded from `MJ: Form Chrome Rules`.
|
|
39
|
+
* Keyed by (parent entity, related entity) or (parent entity, contributionKey).
|
|
40
|
+
*/
|
|
41
|
+
export interface FormChromeRule {
|
|
42
|
+
EntityID: string;
|
|
43
|
+
TargetKind: FormChromeRuleTargetKind;
|
|
44
|
+
RelatedEntityID?: string | null;
|
|
45
|
+
ContributionKey?: string | null;
|
|
46
|
+
Inclusion: FormInclusion;
|
|
47
|
+
JoinFields?: string[] | null;
|
|
48
|
+
Sequence?: number | null;
|
|
49
|
+
/**
|
|
50
|
+
* Admin display title. Null / blank keeps the L1 DisplayName or
|
|
51
|
+
* humanized entity name. Keyed with the rule, not the previous label,
|
|
52
|
+
* so an OpenApp upgrade that renames the related entity does not
|
|
53
|
+
* overwrite a site-specific title.
|
|
54
|
+
*/
|
|
55
|
+
Title?: string | null;
|
|
56
|
+
}
|
|
57
|
+
export interface RelatedFormRoleCandidate {
|
|
58
|
+
ID: string;
|
|
59
|
+
RelatedEntity: string;
|
|
60
|
+
RelatedEntityID: string;
|
|
61
|
+
RelatedEntityJoinField: string;
|
|
62
|
+
RelatedEntitySchemaName: string;
|
|
63
|
+
DisplayInForm: boolean;
|
|
64
|
+
DisplayLocation?: 'After Field Tabs' | 'Before Field Tabs' | null;
|
|
65
|
+
DisplayComponentID?: string | null;
|
|
66
|
+
RelatedRecordCollection?: string | null;
|
|
67
|
+
JoinView?: string | null;
|
|
68
|
+
Type?: string | null;
|
|
69
|
+
Sequence?: number | null;
|
|
70
|
+
/**
|
|
71
|
+
* The relationship's configuration bag, either raw JSON or already parsed.
|
|
72
|
+
* `EntityRelationshipInfo.Configuration` parses lazily and hands back
|
|
73
|
+
* {@link IEntityRelationshipConfiguration}, while callers reading straight
|
|
74
|
+
* from a row still supply the raw string — so both are accepted, matching
|
|
75
|
+
* what {@link ReadRelationshipInclusion}, {@link ReadRelationshipSortKey}
|
|
76
|
+
* and {@link ReadRelationshipJoinFields} already take.
|
|
77
|
+
*/
|
|
78
|
+
Configuration?: string | IEntityRelationshipConfiguration | null;
|
|
79
|
+
/**
|
|
80
|
+
* How many EntityRelationships across metadata point at this related
|
|
81
|
+
* entity. Runtime-only — the ranker uses it as graph in-degree.
|
|
82
|
+
*/
|
|
83
|
+
InboundRelationshipCount?: number | null;
|
|
84
|
+
}
|
|
85
|
+
export interface RelatedFormRoleAssignment {
|
|
86
|
+
RelationshipID: string;
|
|
87
|
+
RelatedEntity: string;
|
|
88
|
+
RelatedEntityID: string;
|
|
89
|
+
RelatedEntityJoinField: string;
|
|
90
|
+
Role: FormRole;
|
|
91
|
+
Inclusion: FormInclusion;
|
|
92
|
+
Score: number;
|
|
93
|
+
Reason: RelatedFormRoleReason;
|
|
94
|
+
ExplicitFormRole: FormRole | null;
|
|
95
|
+
ExplicitInclusion: FormInclusion | null;
|
|
96
|
+
JoinFields: string[] | null;
|
|
97
|
+
}
|
|
98
|
+
export interface RelatedFormRoleResolution {
|
|
99
|
+
Policy: RelatedRolePolicy;
|
|
100
|
+
Budget: number;
|
|
101
|
+
Assignments: RelatedFormRoleAssignment[];
|
|
102
|
+
}
|
|
103
|
+
export declare function ParseEntityConfiguration(raw: string | IEntityConfiguration | null | undefined): IEntityConfiguration | null;
|
|
104
|
+
export declare function ParseEntityRelationshipConfiguration(raw: string | IEntityRelationshipConfiguration | null | undefined): IEntityRelationshipConfiguration | null;
|
|
105
|
+
export declare function ResolveFormLayout(formConfig: IEntityFormConfiguration | null | undefined, firstClassSectionCount: number): Exclude<FormLayout, 'auto'>;
|
|
106
|
+
/**
|
|
107
|
+
* Read L1 inclusion from a relationship Configuration bag.
|
|
108
|
+
* `inclusion` wins. `FormRole: 'Detail'` maps to More. `FormRole: 'Primary'` maps to Primary.
|
|
109
|
+
*/
|
|
110
|
+
export declare function ReadRelationshipInclusion(raw: string | IEntityRelationshipConfiguration | null | undefined): FormInclusion | null;
|
|
111
|
+
/** Higher = earlier among first-class related rail items. Omit / invalid = null. */
|
|
112
|
+
export declare function ReadRelationshipSortKey(raw: string | IEntityRelationshipConfiguration | null | undefined): number | null;
|
|
113
|
+
export declare function ReadRelationshipJoinFields(raw: string | IEntityRelationshipConfiguration | null | undefined): string[] | null;
|
|
114
|
+
/**
|
|
115
|
+
* Score a DisplayInForm relationship for the smart ranker. Explicit inclusion
|
|
116
|
+
* is not applied here — callers separate the L1 pool first.
|
|
117
|
+
*/
|
|
118
|
+
export declare function ScoreRelatedFormRole(candidate: RelatedFormRoleCandidate, parentSchemaName: string): number;
|
|
119
|
+
export declare function ResolveRelatedFormRoles(parentSchemaName: string, formConfig: IEntityFormConfiguration | null | undefined, candidates: readonly RelatedFormRoleCandidate[]): RelatedFormRoleResolution;
|
|
120
|
+
/**
|
|
121
|
+
* L3 install overlay. Pins Inclusion / JoinFields on matching relationship
|
|
122
|
+
* assignments. Later Sequence wins. Contribution rules are applied by the
|
|
123
|
+
* chrome resolver (they are not ranker assignments).
|
|
124
|
+
*/
|
|
125
|
+
export declare function ApplyFormChromeRules(parentEntityId: string, assignments: readonly RelatedFormRoleAssignment[], rules: readonly FormChromeRule[]): RelatedFormRoleAssignment[];
|
|
126
|
+
export declare function ContributionInclusionFromRules(parentEntityId: string, contributionKey: string, rules: readonly FormChromeRule[]): FormInclusion | null;
|
|
127
|
+
/**
|
|
128
|
+
* Safely parses an `EntityField.Configuration` JSON string or returns the object.
|
|
129
|
+
*/
|
|
130
|
+
export declare function ParseEntityFieldConfiguration(raw: string | IEntityFieldConfiguration | null | undefined): IEntityFieldConfiguration | null;
|
|
131
|
+
//# sourceMappingURL=entityConfiguration.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"entityConfiguration.d.ts","sourceRoot":"","sources":["../../src/generic/entityConfiguration.ts"],"names":[],"mappings":"AAqBA,eAAO,MAAM,wBAAwB,IAAI,CAAC;AAC1C,eAAO,MAAM,8BAA8B,IAAI,CAAC;AAEhD,eAAO,MAAM,kBAAkB;;;;;;IAM3B;;;;OAIG;;;;;CAKG,CAAC;AAEX,eAAO,MAAM,oBAAoB,SAAS,CAAC;AAE3C,MAAM,MAAM,UAAU,GAAG,WAAW,GAAG,UAAU,GAAG,MAAM,CAAC;AAC3D,MAAM,MAAM,iBAAiB,GAAG,kBAAkB,GAAG,OAAO,CAAC;AAC7D,MAAM,MAAM,QAAQ,GAAG,SAAS,GAAG,QAAQ,CAAC;AAC5C,qEAAqE;AACrE,MAAM,MAAM,aAAa,GAAG,SAAS,GAAG,MAAM,GAAG,MAAM,CAAC;AAExD,OAAO,EACH,oBAAoB,EAEpB,wBAAwB,EAC3B,MAAM,4CAA4C,CAAC;AACpD,OAAO,EACH,yBAAyB,EAE5B,MAAM,iDAAiD,CAAC;AACzD,OAAO,EACH,gCAAgC,EAEnC,MAAM,wDAAwD,CAAC;AAEhE,cAAc,4CAA4C,CAAC;AAC3D,cAAc,iDAAiD,CAAC;AAChE,cAAc,wDAAwD,CAAC;AAEvE,MAAM,WAAW,uBAAuB;IACpC,IAAI,EAAE,KAAK,CAAC;IACZ,MAAM,EAAE,MAAM,EAAE,CAAC;CACpB;AAED,MAAM,MAAM,qBAAqB,GAC3B,kBAAkB,GAClB,iBAAiB,GACjB,eAAe,GACf,mBAAmB,GACnB,gBAAgB,GAChB,eAAe,GACf,kBAAkB,GAClB,cAAc,GACd,iBAAiB,GACjB,cAAc,GACd,cAAc,CAA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