velocious 1.0.448 → 1.0.449
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/build/database/record/index.js +13 -8
- package/build/environment-handlers/node/cli/commands/generate/base-models.js +1 -16
- package/build/environment-handlers/node/cli/commands/generate/frontend-models.js +125 -73
- package/build/frontend-model-controller.js +9 -0
- package/build/frontend-model-resource/base-resource.js +266 -53
- package/build/frontend-models/base.js +241 -97
- package/build/frontend-models/preloader.js +3 -2
- package/build/src/background-jobs/job-record.d.ts +2 -1
- package/build/src/background-jobs/job-record.d.ts.map +1 -1
- package/build/src/database/query/preloader/belongs-to.d.ts +2 -2
- package/build/src/database/query/preloader/belongs-to.d.ts.map +1 -1
- package/build/src/database/query/preloader/has-many.d.ts +1 -1
- package/build/src/database/query/preloader/has-many.d.ts.map +1 -1
- package/build/src/database/query/preloader/has-one.d.ts +2 -2
- package/build/src/database/query/preloader/has-one.d.ts.map +1 -1
- package/build/src/database/query/preloader.d.ts +1 -1
- package/build/src/database/query/preloader.d.ts.map +1 -1
- package/build/src/database/record/attachments/handle.d.ts +1 -1
- package/build/src/database/record/attachments/handle.d.ts.map +1 -1
- package/build/src/database/record/index.d.ts +23 -13
- package/build/src/database/record/index.d.ts.map +1 -1
- package/build/src/database/record/index.js +14 -9
- package/build/src/environment-handlers/node/cli/commands/generate/base-models.d.ts.map +1 -1
- package/build/src/environment-handlers/node/cli/commands/generate/base-models.js +2 -15
- package/build/src/environment-handlers/node/cli/commands/generate/frontend-models.d.ts +89 -32
- package/build/src/environment-handlers/node/cli/commands/generate/frontend-models.d.ts.map +1 -1
- package/build/src/environment-handlers/node/cli/commands/generate/frontend-models.js +123 -72
- package/build/src/frontend-model-controller.d.ts.map +1 -1
- package/build/src/frontend-model-controller.js +8 -1
- package/build/src/frontend-model-resource/base-resource.d.ts +203 -64
- package/build/src/frontend-model-resource/base-resource.d.ts.map +1 -1
- package/build/src/frontend-model-resource/base-resource.js +237 -54
- package/build/src/frontend-models/base.d.ts +173 -110
- package/build/src/frontend-models/base.d.ts.map +1 -1
- package/build/src/frontend-models/base.js +218 -102
- package/build/src/frontend-models/preloader.d.ts.map +1 -1
- package/build/src/frontend-models/preloader.js +4 -3
- package/build/src/testing/browser-frontend-model-event-hook-scenarios.js +2 -2
- package/build/src/testing/expect.d.ts +6 -0
- package/build/src/testing/expect.d.ts.map +1 -1
- package/build/src/testing/expect.js +9 -1
- package/build/testing/browser-frontend-model-event-hook-scenarios.js +1 -1
- package/build/testing/expect.js +9 -0
- package/package.json +1 -1
- package/src/database/record/index.js +13 -8
- package/src/environment-handlers/node/cli/commands/generate/base-models.js +1 -16
- package/src/environment-handlers/node/cli/commands/generate/frontend-models.js +125 -73
- package/src/frontend-model-controller.js +9 -0
- package/src/frontend-model-resource/base-resource.js +266 -53
- package/src/frontend-models/base.js +241 -97
- package/src/frontend-models/preloader.js +3 -2
- package/src/testing/browser-frontend-model-event-hook-scenarios.js +1 -1
- package/src/testing/expect.js +9 -0
|
@@ -9,28 +9,30 @@ export class AttributeNotSelectedError extends Error {
|
|
|
9
9
|
}
|
|
10
10
|
/**
|
|
11
11
|
* Lightweight singular relationship state holder for frontend model instances.
|
|
12
|
-
* @template {
|
|
13
|
-
* @template {
|
|
12
|
+
* @template {FrontendModelBase} S
|
|
13
|
+
* @template {FrontendModelBase} T
|
|
14
|
+
* @template {Record<string, FrontendModelAttributeValue>} [TargetCreateAttributes=Record<string, FrontendModelAttributeValue>]
|
|
14
15
|
*/
|
|
15
|
-
export class FrontendModelSingularRelationship<S extends
|
|
16
|
+
export class FrontendModelSingularRelationship<S extends FrontendModelBase, T extends FrontendModelBase, TargetCreateAttributes extends Record<string, FrontendModelAttributeValue> = Record<string, FrontendModelTransportValue>> {
|
|
16
17
|
/**
|
|
17
18
|
* Runs constructor.
|
|
18
|
-
* @param {
|
|
19
|
+
* @param {S} model - Parent model.
|
|
19
20
|
* @param {string} relationshipName - Relationship name.
|
|
20
|
-
* @param {T | null} targetModelClass - Target model class.
|
|
21
|
+
* @param {FrontendModelClass<T, Record<string, FrontendModelAttributeValue>, TargetCreateAttributes> | null} targetModelClass - Target model class.
|
|
21
22
|
*/
|
|
22
|
-
constructor(model:
|
|
23
|
-
model:
|
|
23
|
+
constructor(model: S, relationshipName: string, targetModelClass: FrontendModelClass<T, Record<string, FrontendModelAttributeValue>, TargetCreateAttributes> | null);
|
|
24
|
+
model: S;
|
|
24
25
|
relationshipName: string;
|
|
25
|
-
targetModelClass: T | null;
|
|
26
|
+
targetModelClass: FrontendModelClass<T, Record<string, FrontendModelTransportValue>, TargetCreateAttributes> | null;
|
|
26
27
|
_preloaded: boolean;
|
|
27
|
-
|
|
28
|
+
/** @type {T | null} */
|
|
29
|
+
_loadedValue: T | null;
|
|
28
30
|
/**
|
|
29
31
|
* Runs set loaded.
|
|
30
|
-
* @param {
|
|
32
|
+
* @param {T | null | undefined} loadedValue - Loaded relationship value.
|
|
31
33
|
* @returns {void}
|
|
32
34
|
*/
|
|
33
|
-
setLoaded(loadedValue:
|
|
35
|
+
setLoaded(loadedValue: T | null | undefined): void;
|
|
34
36
|
/**
|
|
35
37
|
* Runs get preloaded.
|
|
36
38
|
* @returns {boolean} - Whether relationship is preloaded.
|
|
@@ -38,43 +40,60 @@ export class FrontendModelSingularRelationship<S extends FrontendModelClass, T e
|
|
|
38
40
|
getPreloaded(): boolean;
|
|
39
41
|
/**
|
|
40
42
|
* Runs loaded.
|
|
41
|
-
* @returns {
|
|
43
|
+
* @returns {T | null} - Loaded relationship value.
|
|
42
44
|
*/
|
|
43
|
-
loaded():
|
|
45
|
+
loaded(): T | null;
|
|
46
|
+
/**
|
|
47
|
+
* Copies loaded value from another singular relationship helper.
|
|
48
|
+
* @param {FrontendModelRelationship} sourceRelationship - Source relationship helper.
|
|
49
|
+
* @returns {void}
|
|
50
|
+
*/
|
|
51
|
+
copyLoadedFrom(sourceRelationship: FrontendModelRelationship): void;
|
|
44
52
|
/**
|
|
45
53
|
* Runs build.
|
|
46
|
-
* @param {
|
|
47
|
-
* @returns {
|
|
54
|
+
* @param {TargetCreateAttributes} [attributes] - New model attributes.
|
|
55
|
+
* @returns {T} - Built model.
|
|
56
|
+
*/
|
|
57
|
+
build(attributes?: TargetCreateAttributes): T;
|
|
58
|
+
/**
|
|
59
|
+
* Force-reload the relationship.
|
|
60
|
+
* @returns {Promise<T | null>} - Loaded relationship model.
|
|
61
|
+
*/
|
|
62
|
+
load(): Promise<T | null>;
|
|
63
|
+
/**
|
|
64
|
+
* Returns the loaded relationship or loads it.
|
|
65
|
+
* @returns {Promise<T | null>} - Loaded relationship model.
|
|
48
66
|
*/
|
|
49
|
-
|
|
67
|
+
orLoad(): Promise<T | null>;
|
|
50
68
|
}
|
|
51
69
|
/**
|
|
52
70
|
* Lightweight has-many relationship state holder for frontend model instances.
|
|
53
|
-
* @template {
|
|
54
|
-
* @template {
|
|
71
|
+
* @template {FrontendModelBase} S
|
|
72
|
+
* @template {FrontendModelBase} T
|
|
73
|
+
* @template {Record<string, FrontendModelAttributeValue>} [TargetCreateAttributes=Record<string, FrontendModelAttributeValue>]
|
|
55
74
|
*/
|
|
56
|
-
export class FrontendModelHasManyRelationship<S extends
|
|
75
|
+
export class FrontendModelHasManyRelationship<S extends FrontendModelBase, T extends FrontendModelBase, TargetCreateAttributes extends Record<string, FrontendModelAttributeValue> = Record<string, FrontendModelTransportValue>> {
|
|
57
76
|
/**
|
|
58
77
|
* Runs constructor.
|
|
59
|
-
* @param {
|
|
78
|
+
* @param {S} model - Parent model.
|
|
60
79
|
* @param {string} relationshipName - Relationship name.
|
|
61
|
-
* @param {T | null} targetModelClass - Target model class.
|
|
80
|
+
* @param {FrontendModelClass<T, Record<string, FrontendModelAttributeValue>, TargetCreateAttributes> | null} targetModelClass - Target model class.
|
|
62
81
|
*/
|
|
63
|
-
constructor(model:
|
|
82
|
+
constructor(model: S, relationshipName: string, targetModelClass: FrontendModelClass<T, Record<string, FrontendModelAttributeValue>, TargetCreateAttributes> | null);
|
|
64
83
|
/**
|
|
65
84
|
* Narrows the runtime value to the documented type.
|
|
66
|
-
@type {Array<
|
|
67
|
-
_loadedValue: Array<
|
|
68
|
-
model:
|
|
85
|
+
@type {Array<T>} */
|
|
86
|
+
_loadedValue: Array<T>;
|
|
87
|
+
model: S;
|
|
69
88
|
relationshipName: string;
|
|
70
|
-
targetModelClass: T | null;
|
|
89
|
+
targetModelClass: FrontendModelClass<T, Record<string, FrontendModelTransportValue>, TargetCreateAttributes> | null;
|
|
71
90
|
_preloaded: boolean;
|
|
72
91
|
/**
|
|
73
92
|
* Runs set loaded.
|
|
74
|
-
* @param {Array<
|
|
93
|
+
* @param {Array<T>} loadedValue - Loaded relationship value.
|
|
75
94
|
* @returns {void}
|
|
76
95
|
*/
|
|
77
|
-
setLoaded(loadedValue: Array<
|
|
96
|
+
setLoaded(loadedValue: Array<T>): void;
|
|
78
97
|
/**
|
|
79
98
|
* Runs get preloaded.
|
|
80
99
|
* @returns {boolean} - Whether relationship is preloaded.
|
|
@@ -82,35 +101,41 @@ export class FrontendModelHasManyRelationship<S extends FrontendModelClass, T ex
|
|
|
82
101
|
getPreloaded(): boolean;
|
|
83
102
|
/**
|
|
84
103
|
* Runs loaded.
|
|
85
|
-
* @returns {Array<
|
|
104
|
+
* @returns {Array<T>} - Loaded relationship values.
|
|
86
105
|
*/
|
|
87
|
-
loaded(): Array<
|
|
106
|
+
loaded(): Array<T>;
|
|
107
|
+
/**
|
|
108
|
+
* Copies loaded value from another has-many relationship helper.
|
|
109
|
+
* @param {FrontendModelRelationship} sourceRelationship - Source relationship helper.
|
|
110
|
+
* @returns {void}
|
|
111
|
+
*/
|
|
112
|
+
copyLoadedFrom(sourceRelationship: FrontendModelRelationship): void;
|
|
88
113
|
/**
|
|
89
114
|
* Runs add to loaded.
|
|
90
|
-
* @param {Array<
|
|
115
|
+
* @param {Array<T>} models - Models to append.
|
|
91
116
|
* @returns {void}
|
|
92
117
|
*/
|
|
93
|
-
addToLoaded(models: Array<
|
|
118
|
+
addToLoaded(models: Array<T>): void;
|
|
94
119
|
/**
|
|
95
120
|
* Runs build.
|
|
96
|
-
* @param {
|
|
97
|
-
* @returns {
|
|
121
|
+
* @param {TargetCreateAttributes} [attributes] - New model attributes.
|
|
122
|
+
* @returns {T} - Built model.
|
|
98
123
|
*/
|
|
99
|
-
build(attributes?:
|
|
124
|
+
build(attributes?: TargetCreateAttributes): T;
|
|
100
125
|
/**
|
|
101
126
|
* Force-reload the relationship. When the parent record was loaded as part
|
|
102
127
|
* of a batch, siblings that have not preloaded this relationship get
|
|
103
128
|
* batched into one request via the cohort preloader. The scoped query path
|
|
104
129
|
* (`Model.where(...).preload([name]).toArray()` directly from user code)
|
|
105
130
|
* bypasses cohort batching by design.
|
|
106
|
-
* @returns {Promise<Array<
|
|
131
|
+
* @returns {Promise<Array<T>>} - Loaded relationship models.
|
|
107
132
|
*/
|
|
108
|
-
load(): Promise<Array<
|
|
133
|
+
load(): Promise<Array<T>>;
|
|
109
134
|
/**
|
|
110
135
|
* Runs to array.
|
|
111
|
-
* @returns {Promise<Array<
|
|
136
|
+
* @returns {Promise<Array<T>>} - Loaded relationship models.
|
|
112
137
|
*/
|
|
113
|
-
toArray(): Promise<Array<
|
|
138
|
+
toArray(): Promise<Array<T>>;
|
|
114
139
|
}
|
|
115
140
|
/**
|
|
116
141
|
* Downloaded frontend-model attachment payload wrapper.
|
|
@@ -190,7 +215,7 @@ export class FrontendModelAttachmentHandle {
|
|
|
190
215
|
* @type {FrontendModelAttachmentInput[]}
|
|
191
216
|
*/
|
|
192
217
|
pendingInputs: FrontendModelAttachmentInput[];
|
|
193
|
-
model: FrontendModelBase
|
|
218
|
+
model: FrontendModelBase<Record<string, FrontendModelTransportValue>, Record<string, FrontendModelTransportValue>, Record<string, FrontendModelTransportValue>>;
|
|
194
219
|
attachmentName: string;
|
|
195
220
|
/**
|
|
196
221
|
* Queue attachment input for the parent model's next save.
|
|
@@ -234,8 +259,13 @@ export class FrontendModelAttachmentHandle {
|
|
|
234
259
|
*/
|
|
235
260
|
downloadUrl(): string;
|
|
236
261
|
}
|
|
237
|
-
/**
|
|
238
|
-
|
|
262
|
+
/**
|
|
263
|
+
* Base frontend model.
|
|
264
|
+
* @template {Record<string, FrontendModelAttributeValue>} [Attributes=Record<string, FrontendModelAttributeValue>]
|
|
265
|
+
* @template {Record<string, FrontendModelAttributeValue>} [CreateAttributes=Record<string, FrontendModelAttributeValue>]
|
|
266
|
+
* @template {Record<string, FrontendModelAttributeValue>} [UpdateAttributes=Record<string, FrontendModelAttributeValue>]
|
|
267
|
+
*/
|
|
268
|
+
export default class FrontendModelBase<Attributes extends Record<string, FrontendModelAttributeValue> = Record<string, FrontendModelTransportValue>, CreateAttributes extends Record<string, FrontendModelAttributeValue> = Record<string, FrontendModelTransportValue>, UpdateAttributes extends Record<string, FrontendModelAttributeValue> = Record<string, FrontendModelTransportValue>> {
|
|
239
269
|
/**
|
|
240
270
|
* Narrows the runtime value to the documented type.
|
|
241
271
|
@type {string | undefined} */
|
|
@@ -261,7 +291,7 @@ export default class FrontendModelBase {
|
|
|
261
291
|
* @this {FrontendModelClass}
|
|
262
292
|
* @returns {void} - Ensures attachment helper methods exist on the prototype.
|
|
263
293
|
*/
|
|
264
|
-
static ensureGeneratedAttachmentMethods(this: FrontendModelClass): void;
|
|
294
|
+
static ensureGeneratedAttachmentMethods(this: FrontendModelClass<FrontendModelBase<Record<string, FrontendModelTransportValue>, Record<string, FrontendModelTransportValue>, Record<string, FrontendModelTransportValue>>, Record<string, FrontendModelTransportValue>, Record<string, FrontendModelTransportValue>>): void;
|
|
265
295
|
/**
|
|
266
296
|
* Runs resource config.
|
|
267
297
|
* @returns {FrontendModelResourceConfig} - Resource configuration.
|
|
@@ -272,7 +302,7 @@ export default class FrontendModelBase {
|
|
|
272
302
|
* @this {FrontendModelClass}
|
|
273
303
|
* @returns {Record<string, FrontendModelClass | string>} - Relationship model classes (or class name strings) keyed by relationship name.
|
|
274
304
|
*/
|
|
275
|
-
static relationshipModelClasses(this: FrontendModelClass): Record<string, FrontendModelClass | string>;
|
|
305
|
+
static relationshipModelClasses(this: FrontendModelClass<FrontendModelBase<Record<string, FrontendModelTransportValue>, Record<string, FrontendModelTransportValue>, Record<string, FrontendModelTransportValue>>, Record<string, FrontendModelTransportValue>, Record<string, FrontendModelTransportValue>>): Record<string, FrontendModelClass | string>;
|
|
276
306
|
/**
|
|
277
307
|
* Register a frontend model class so it can be resolved by name in relationship lookups.
|
|
278
308
|
* @param {FrontendModelClass} modelClass - Model class to register.
|
|
@@ -298,7 +328,7 @@ export default class FrontendModelBase {
|
|
|
298
328
|
* @this {FrontendModelClass}
|
|
299
329
|
* @returns {Record<string, {type: "belongsTo" | "hasOne" | "hasMany", autoload?: boolean}>} - Relationship definitions keyed by relationship name.
|
|
300
330
|
*/
|
|
301
|
-
static relationshipDefinitions(this: FrontendModelClass): Record<string, {
|
|
331
|
+
static relationshipDefinitions(this: FrontendModelClass<FrontendModelBase<Record<string, FrontendModelTransportValue>, Record<string, FrontendModelTransportValue>, Record<string, FrontendModelTransportValue>>, Record<string, FrontendModelTransportValue>, Record<string, FrontendModelTransportValue>>): Record<string, {
|
|
302
332
|
type: "belongsTo" | "hasOne" | "hasMany";
|
|
303
333
|
autoload?: boolean;
|
|
304
334
|
}>;
|
|
@@ -307,21 +337,21 @@ export default class FrontendModelBase {
|
|
|
307
337
|
* @this {FrontendModelClass}
|
|
308
338
|
* @returns {Record<string, FrontendModelAttachmentDefinition>} - Attachment definitions keyed by attachment name.
|
|
309
339
|
*/
|
|
310
|
-
static attachmentDefinitions(this: FrontendModelClass): Record<string, FrontendModelAttachmentDefinition>;
|
|
340
|
+
static attachmentDefinitions(this: FrontendModelClass<FrontendModelBase<Record<string, FrontendModelTransportValue>, Record<string, FrontendModelTransportValue>, Record<string, FrontendModelTransportValue>>, Record<string, FrontendModelTransportValue>, Record<string, FrontendModelTransportValue>>): Record<string, FrontendModelAttachmentDefinition>;
|
|
311
341
|
/**
|
|
312
342
|
* Runs attachment definition.
|
|
313
343
|
* @this {FrontendModelClass}
|
|
314
344
|
* @param {string} attachmentName - Attachment name.
|
|
315
345
|
* @returns {FrontendModelAttachmentDefinition | null} - Attachment definition.
|
|
316
346
|
*/
|
|
317
|
-
static attachmentDefinition(this: FrontendModelClass, attachmentName: string): FrontendModelAttachmentDefinition | null;
|
|
347
|
+
static attachmentDefinition(this: FrontendModelClass<FrontendModelBase<Record<string, FrontendModelTransportValue>, Record<string, FrontendModelTransportValue>, Record<string, FrontendModelTransportValue>>, Record<string, FrontendModelTransportValue>, Record<string, FrontendModelTransportValue>>, attachmentName: string): FrontendModelAttachmentDefinition | null;
|
|
318
348
|
/**
|
|
319
349
|
* Runs relationship definition.
|
|
320
350
|
* @this {FrontendModelClass}
|
|
321
351
|
* @param {string} relationshipName - Relationship name.
|
|
322
352
|
* @returns {{type: "belongsTo" | "hasOne" | "hasMany", autoload?: boolean} | null} - Relationship definition.
|
|
323
353
|
*/
|
|
324
|
-
static relationshipDefinition(this: FrontendModelClass, relationshipName: string): {
|
|
354
|
+
static relationshipDefinition(this: FrontendModelClass<FrontendModelBase<Record<string, FrontendModelTransportValue>, Record<string, FrontendModelTransportValue>, Record<string, FrontendModelTransportValue>>, Record<string, FrontendModelTransportValue>, Record<string, FrontendModelTransportValue>>, relationshipName: string): {
|
|
325
355
|
type: "belongsTo" | "hasOne" | "hasMany";
|
|
326
356
|
autoload?: boolean;
|
|
327
357
|
} | null;
|
|
@@ -331,40 +361,40 @@ export default class FrontendModelBase {
|
|
|
331
361
|
* @param {string} attributeName - Candidate attribute name, such as `tasksAttributes`.
|
|
332
362
|
* @returns {string | null} Relationship name when nested attributes are configured.
|
|
333
363
|
*/
|
|
334
|
-
static nestedAttributesRelationshipName(this: FrontendModelClass, attributeName: string): string | null;
|
|
364
|
+
static nestedAttributesRelationshipName(this: FrontendModelClass<FrontendModelBase<Record<string, FrontendModelTransportValue>, Record<string, FrontendModelTransportValue>, Record<string, FrontendModelTransportValue>>, Record<string, FrontendModelTransportValue>, Record<string, FrontendModelTransportValue>>, attributeName: string): string | null;
|
|
335
365
|
/**
|
|
336
366
|
* Runs relationship model class.
|
|
337
367
|
* @this {FrontendModelClass}
|
|
338
368
|
* @param {string} relationshipName - Relationship name.
|
|
339
369
|
* @returns {FrontendModelClass | null} - Target relationship model class.
|
|
340
370
|
*/
|
|
341
|
-
static relationshipModelClass(this: FrontendModelClass, relationshipName: string): FrontendModelClass | null;
|
|
371
|
+
static relationshipModelClass(this: FrontendModelClass<FrontendModelBase<Record<string, FrontendModelTransportValue>, Record<string, FrontendModelTransportValue>, Record<string, FrontendModelTransportValue>>, Record<string, FrontendModelTransportValue>, Record<string, FrontendModelTransportValue>>, relationshipName: string): FrontendModelClass | null;
|
|
342
372
|
/**
|
|
343
373
|
* Runs primary key.
|
|
344
374
|
* @this {FrontendModelClass}
|
|
345
375
|
* @returns {string} - Primary key name.
|
|
346
376
|
*/
|
|
347
|
-
static primaryKey(this: FrontendModelClass): string;
|
|
377
|
+
static primaryKey(this: FrontendModelClass<FrontendModelBase<Record<string, FrontendModelTransportValue>, Record<string, FrontendModelTransportValue>, Record<string, FrontendModelTransportValue>>, Record<string, FrontendModelTransportValue>, Record<string, FrontendModelTransportValue>>): string;
|
|
348
378
|
/**
|
|
349
379
|
* Runs resource path.
|
|
350
380
|
* @this {FrontendModelClass}
|
|
351
381
|
* @returns {string} - Derived resource path.
|
|
352
382
|
*/
|
|
353
|
-
static resourcePath(this: FrontendModelClass): string;
|
|
383
|
+
static resourcePath(this: FrontendModelClass<FrontendModelBase<Record<string, FrontendModelTransportValue>, Record<string, FrontendModelTransportValue>, Record<string, FrontendModelTransportValue>>, Record<string, FrontendModelTransportValue>, Record<string, FrontendModelTransportValue>>): string;
|
|
354
384
|
/**
|
|
355
385
|
* Runs command name.
|
|
356
386
|
* @this {FrontendModelClass}
|
|
357
387
|
* @param {FrontendModelCommandType} commandType - Command type.
|
|
358
388
|
* @returns {string} - Resolved command name.
|
|
359
389
|
*/
|
|
360
|
-
static commandName(this: FrontendModelClass, commandType: FrontendModelCommandType): string;
|
|
390
|
+
static commandName(this: FrontendModelClass<FrontendModelBase<Record<string, FrontendModelTransportValue>, Record<string, FrontendModelTransportValue>, Record<string, FrontendModelTransportValue>>, Record<string, FrontendModelTransportValue>, Record<string, FrontendModelTransportValue>>, commandType: FrontendModelCommandType): string;
|
|
361
391
|
/**
|
|
362
392
|
* Runs normalize custom command payload arguments.
|
|
363
393
|
* @this {FrontendModelClass}
|
|
364
394
|
* @param {Array<?>} args - Command arguments.
|
|
365
395
|
* @returns {Record<string, ?>} - Command payload.
|
|
366
396
|
*/
|
|
367
|
-
static normalizeCustomCommandPayloadArguments(this: FrontendModelClass, args: Array<unknown>): Record<string, unknown>;
|
|
397
|
+
static normalizeCustomCommandPayloadArguments(this: FrontendModelClass<FrontendModelBase<Record<string, FrontendModelTransportValue>, Record<string, FrontendModelTransportValue>, Record<string, FrontendModelTransportValue>>, Record<string, FrontendModelTransportValue>, Record<string, FrontendModelTransportValue>>, args: Array<unknown>): Record<string, unknown>;
|
|
368
398
|
/**
|
|
369
399
|
* Returns the model name, preferring an explicit `static modelName` declaration
|
|
370
400
|
* over the JavaScript class `.name` property. This allows minified builds to
|
|
@@ -372,7 +402,7 @@ export default class FrontendModelBase {
|
|
|
372
402
|
* @this {FrontendModelClass}
|
|
373
403
|
* @returns {string} - The model name.
|
|
374
404
|
*/
|
|
375
|
-
static getModelName(this: FrontendModelClass): string;
|
|
405
|
+
static getModelName(this: FrontendModelClass<FrontendModelBase<Record<string, FrontendModelTransportValue>, Record<string, FrontendModelTransportValue>, Record<string, FrontendModelTransportValue>>, Record<string, FrontendModelTransportValue>, Record<string, FrontendModelTransportValue>>): string;
|
|
376
406
|
/**
|
|
377
407
|
* Runs configure transport.
|
|
378
408
|
* @param {FrontendModelTransportConfig} config - Frontend model transport configuration.
|
|
@@ -484,21 +514,21 @@ export default class FrontendModelBase {
|
|
|
484
514
|
* Runs attributes from response.
|
|
485
515
|
* @this {FrontendModelClass}
|
|
486
516
|
* @param {object} response - Response payload.
|
|
487
|
-
* @returns {Record<string,
|
|
517
|
+
* @returns {Record<string, FrontendModelAttributeValue>} - Attributes from payload.
|
|
488
518
|
*/
|
|
489
|
-
static attributesFromResponse(this: FrontendModelClass, response: object): Record<string,
|
|
519
|
+
static attributesFromResponse(this: FrontendModelClass<FrontendModelBase<Record<string, FrontendModelTransportValue>, Record<string, FrontendModelTransportValue>, Record<string, FrontendModelTransportValue>>, Record<string, FrontendModelTransportValue>, Record<string, FrontendModelTransportValue>>, response: object): Record<string, FrontendModelAttributeValue>;
|
|
490
520
|
/**
|
|
491
521
|
* Runs model data from response.
|
|
492
522
|
* @this {FrontendModelClass}
|
|
493
523
|
* @param {object} response - Response payload.
|
|
494
|
-
* @returns {{abilities: Record<string, boolean>, attributes: Record<string,
|
|
524
|
+
* @returns {{abilities: Record<string, boolean>, attributes: Record<string, FrontendModelAttributeValue>, associationCounts: Record<string, number>, queryData: Record<string, FrontendModelAttributeValue>, preloadedRelationships: Record<string, FrontendModelAttributeValue>, selectedAttributes: Set<string>}} - Attributes, preloaded relationships, association counts, queryData, abilities, and the selected-attributes set.
|
|
495
525
|
*/
|
|
496
|
-
static modelDataFromResponse(this: FrontendModelClass, response: object): {
|
|
526
|
+
static modelDataFromResponse(this: FrontendModelClass<FrontendModelBase<Record<string, FrontendModelTransportValue>, Record<string, FrontendModelTransportValue>, Record<string, FrontendModelTransportValue>>, Record<string, FrontendModelTransportValue>, Record<string, FrontendModelTransportValue>>, response: object): {
|
|
497
527
|
abilities: Record<string, boolean>;
|
|
498
|
-
attributes: Record<string,
|
|
528
|
+
attributes: Record<string, FrontendModelAttributeValue>;
|
|
499
529
|
associationCounts: Record<string, number>;
|
|
500
|
-
queryData: Record<string,
|
|
501
|
-
preloadedRelationships: Record<string,
|
|
530
|
+
queryData: Record<string, FrontendModelAttributeValue>;
|
|
531
|
+
preloadedRelationships: Record<string, FrontendModelAttributeValue>;
|
|
502
532
|
selectedAttributes: Set<string>;
|
|
503
533
|
};
|
|
504
534
|
/**
|
|
@@ -508,7 +538,7 @@ export default class FrontendModelBase {
|
|
|
508
538
|
* @param {Record<string, ?>} preloadedRelationships - Preloaded relationship payload.
|
|
509
539
|
* @returns {void}
|
|
510
540
|
*/
|
|
511
|
-
static applyPreloadedRelationships(this: FrontendModelClass, model: FrontendModelBase, preloadedRelationships: Record<string, unknown>): void;
|
|
541
|
+
static applyPreloadedRelationships(this: FrontendModelClass<FrontendModelBase<Record<string, FrontendModelTransportValue>, Record<string, FrontendModelTransportValue>, Record<string, FrontendModelTransportValue>>, Record<string, FrontendModelTransportValue>, Record<string, FrontendModelTransportValue>>, model: FrontendModelBase, preloadedRelationships: Record<string, unknown>): void;
|
|
512
542
|
/**
|
|
513
543
|
* Runs instantiate relationship value.
|
|
514
544
|
* @this {FrontendModelClass}
|
|
@@ -516,7 +546,7 @@ export default class FrontendModelBase {
|
|
|
516
546
|
* @param {FrontendModelClass | null} targetModelClass - Target model class.
|
|
517
547
|
* @returns {?} - Instantiated relationship value.
|
|
518
548
|
*/
|
|
519
|
-
static instantiateRelationshipValue(this: FrontendModelClass, relationshipPayload: unknown, targetModelClass: FrontendModelClass | null): unknown;
|
|
549
|
+
static instantiateRelationshipValue(this: FrontendModelClass<FrontendModelBase<Record<string, FrontendModelTransportValue>, Record<string, FrontendModelTransportValue>, Record<string, FrontendModelTransportValue>>, Record<string, FrontendModelTransportValue>, Record<string, FrontendModelTransportValue>>, relationshipPayload: unknown, targetModelClass: FrontendModelClass | null): unknown;
|
|
520
550
|
/**
|
|
521
551
|
* Runs instantiate from response.
|
|
522
552
|
* @template {FrontendModelClass} T
|
|
@@ -636,7 +666,7 @@ export default class FrontendModelBase {
|
|
|
636
666
|
* @param {import("./query.js").FrontendModelEventOptions} [options] - Event query or record projection options.
|
|
637
667
|
* @returns {Promise<() => void>} - Unsubscribe callback.
|
|
638
668
|
*/
|
|
639
|
-
static onCreate(this: FrontendModelClass, callback: (payload: {
|
|
669
|
+
static onCreate(this: FrontendModelClass<FrontendModelBase<Record<string, FrontendModelTransportValue>, Record<string, FrontendModelTransportValue>, Record<string, FrontendModelTransportValue>>, Record<string, FrontendModelTransportValue>, Record<string, FrontendModelTransportValue>>, callback: (payload: {
|
|
640
670
|
id: string;
|
|
641
671
|
model: FrontendModelBase;
|
|
642
672
|
}) => void, options?: import("./query.js").FrontendModelEventOptions): Promise<() => void>;
|
|
@@ -647,7 +677,7 @@ export default class FrontendModelBase {
|
|
|
647
677
|
* @param {import("./query.js").FrontendModelEventOptions} [options] - Event query or record projection options.
|
|
648
678
|
* @returns {Promise<() => void>} - Unsubscribe callback.
|
|
649
679
|
*/
|
|
650
|
-
static onUpdate(this: FrontendModelClass, callback: (payload: {
|
|
680
|
+
static onUpdate(this: FrontendModelClass<FrontendModelBase<Record<string, FrontendModelTransportValue>, Record<string, FrontendModelTransportValue>, Record<string, FrontendModelTransportValue>>, Record<string, FrontendModelTransportValue>, Record<string, FrontendModelTransportValue>>, callback: (payload: {
|
|
651
681
|
id: string;
|
|
652
682
|
model: FrontendModelBase;
|
|
653
683
|
}) => void, options?: import("./query.js").FrontendModelEventOptions): Promise<() => void>;
|
|
@@ -658,7 +688,7 @@ export default class FrontendModelBase {
|
|
|
658
688
|
* @param {import("./query.js").FrontendModelEventOptions} [options] - Accepted for API symmetry; destroy events carry ids only.
|
|
659
689
|
* @returns {Promise<() => void>} - Unsubscribe callback.
|
|
660
690
|
*/
|
|
661
|
-
static onDestroy(this: FrontendModelClass, callback: (payload: {
|
|
691
|
+
static onDestroy(this: FrontendModelClass<FrontendModelBase<Record<string, FrontendModelTransportValue>, Record<string, FrontendModelTransportValue>, Record<string, FrontendModelTransportValue>>, Record<string, FrontendModelTransportValue>, Record<string, FrontendModelTransportValue>>, callback: (payload: {
|
|
662
692
|
id: string;
|
|
663
693
|
}) => void, options?: import("./query.js").FrontendModelEventOptions): Promise<() => void>;
|
|
664
694
|
/**
|
|
@@ -784,19 +814,21 @@ export default class FrontendModelBase {
|
|
|
784
814
|
static findOrCreateBy<T extends FrontendModelClass>(this: T, conditions: Record<string, unknown>, callback?: (model: InstanceType<T>) => Promise<void> | void): Promise<InstanceType<T>>;
|
|
785
815
|
/**
|
|
786
816
|
* Runs create.
|
|
787
|
-
* @template {
|
|
788
|
-
* @
|
|
789
|
-
* @
|
|
790
|
-
* @
|
|
817
|
+
* @template {FrontendModelBase} Model
|
|
818
|
+
* @template {Record<string, FrontendModelAttributeValue>} ModelAttributes
|
|
819
|
+
* @template {Record<string, FrontendModelAttributeValue>} ModelCreateAttributes
|
|
820
|
+
* @this {FrontendModelClass<Model, ModelAttributes, ModelCreateAttributes>}
|
|
821
|
+
* @param {ModelCreateAttributes} [attributes] - Initial attributes.
|
|
822
|
+
* @returns {Promise<Model>} - Persisted model.
|
|
791
823
|
*/
|
|
792
|
-
static create<
|
|
824
|
+
static create<Model extends FrontendModelBase, ModelAttributes extends Record<string, FrontendModelAttributeValue>, ModelCreateAttributes extends Record<string, FrontendModelAttributeValue>>(this: FrontendModelClass<Model, ModelAttributes, ModelCreateAttributes>, attributes?: ModelCreateAttributes): Promise<Model>;
|
|
793
825
|
/**
|
|
794
826
|
* Runs assert find by conditions.
|
|
795
827
|
* @this {FrontendModelClass}
|
|
796
828
|
* @param {Record<string, ?>} conditions - findBy conditions.
|
|
797
829
|
* @returns {void}
|
|
798
830
|
*/
|
|
799
|
-
static assertFindByConditions(this: FrontendModelClass, conditions: Record<string, unknown>): void;
|
|
831
|
+
static assertFindByConditions(this: FrontendModelClass<FrontendModelBase<Record<string, FrontendModelTransportValue>, Record<string, FrontendModelTransportValue>, Record<string, FrontendModelTransportValue>>, Record<string, FrontendModelTransportValue>, Record<string, FrontendModelTransportValue>>, conditions: Record<string, unknown>): void;
|
|
800
832
|
/**
|
|
801
833
|
* Runs matches find by conditions.
|
|
802
834
|
* @this {FrontendModelClass}
|
|
@@ -804,7 +836,7 @@ export default class FrontendModelBase {
|
|
|
804
836
|
* @param {Record<string, ?>} conditions - Match conditions.
|
|
805
837
|
* @returns {boolean} - Whether the model matches all conditions.
|
|
806
838
|
*/
|
|
807
|
-
static matchesFindByConditions(this: FrontendModelClass, model: FrontendModelBase, conditions: Record<string, unknown>): boolean;
|
|
839
|
+
static matchesFindByConditions(this: FrontendModelClass<FrontendModelBase<Record<string, FrontendModelTransportValue>, Record<string, FrontendModelTransportValue>, Record<string, FrontendModelTransportValue>>, Record<string, FrontendModelTransportValue>, Record<string, FrontendModelTransportValue>>, model: FrontendModelBase, conditions: Record<string, unknown>): boolean;
|
|
808
840
|
/**
|
|
809
841
|
* Runs find by condition value matches.
|
|
810
842
|
* @this {FrontendModelClass}
|
|
@@ -812,7 +844,7 @@ export default class FrontendModelBase {
|
|
|
812
844
|
* @param {?} expectedValue - Expected find condition value.
|
|
813
845
|
* @returns {boolean} - Whether values match.
|
|
814
846
|
*/
|
|
815
|
-
static findByConditionValueMatches(this: FrontendModelClass, actualValue: unknown, expectedValue: unknown): boolean;
|
|
847
|
+
static findByConditionValueMatches(this: FrontendModelClass<FrontendModelBase<Record<string, FrontendModelTransportValue>, Record<string, FrontendModelTransportValue>, Record<string, FrontendModelTransportValue>>, Record<string, FrontendModelTransportValue>, Record<string, FrontendModelTransportValue>>, actualValue: unknown, expectedValue: unknown): boolean;
|
|
816
848
|
/**
|
|
817
849
|
* Runs find by primitive values match.
|
|
818
850
|
* @this {FrontendModelClass}
|
|
@@ -820,7 +852,7 @@ export default class FrontendModelBase {
|
|
|
820
852
|
* @param {?} expectedValue - Expected find condition value.
|
|
821
853
|
* @returns {boolean} - Whether primitive values match after safe coercion.
|
|
822
854
|
*/
|
|
823
|
-
static findByPrimitiveValuesMatch(this: FrontendModelClass, actualValue: unknown, expectedValue: unknown): boolean;
|
|
855
|
+
static findByPrimitiveValuesMatch(this: FrontendModelClass<FrontendModelBase<Record<string, FrontendModelTransportValue>, Record<string, FrontendModelTransportValue>, Record<string, FrontendModelTransportValue>>, Record<string, FrontendModelTransportValue>, Record<string, FrontendModelTransportValue>>, actualValue: unknown, expectedValue: unknown): boolean;
|
|
824
856
|
/**
|
|
825
857
|
* Runs find by numeric string matches number.
|
|
826
858
|
* @this {FrontendModelClass}
|
|
@@ -828,7 +860,7 @@ export default class FrontendModelBase {
|
|
|
828
860
|
* @param {number} expectedNumber - Number value.
|
|
829
861
|
* @returns {boolean} - Whether values represent the same number.
|
|
830
862
|
*/
|
|
831
|
-
static findByNumericStringMatchesNumber(this: FrontendModelClass, numericString: string, expectedNumber: number): boolean;
|
|
863
|
+
static findByNumericStringMatchesNumber(this: FrontendModelClass<FrontendModelBase<Record<string, FrontendModelTransportValue>, Record<string, FrontendModelTransportValue>, Record<string, FrontendModelTransportValue>>, Record<string, FrontendModelTransportValue>, Record<string, FrontendModelTransportValue>>, numericString: string, expectedNumber: number): boolean;
|
|
832
864
|
/**
|
|
833
865
|
* Runs execute command.
|
|
834
866
|
* @this {FrontendModelClass}
|
|
@@ -836,7 +868,7 @@ export default class FrontendModelBase {
|
|
|
836
868
|
* @param {Record<string, ?>} payload - Command payload.
|
|
837
869
|
* @returns {Promise<Record<string, ?>>} - Parsed JSON response.
|
|
838
870
|
*/
|
|
839
|
-
static executeCommand(this: FrontendModelClass, commandType: FrontendModelCommandType, payload: Record<string, unknown>): Promise<Record<string, unknown>>;
|
|
871
|
+
static executeCommand(this: FrontendModelClass<FrontendModelBase<Record<string, FrontendModelTransportValue>, Record<string, FrontendModelTransportValue>, Record<string, FrontendModelTransportValue>>, Record<string, FrontendModelTransportValue>, Record<string, FrontendModelTransportValue>>, commandType: FrontendModelCommandType, payload: Record<string, unknown>): Promise<Record<string, unknown>>;
|
|
840
872
|
/**
|
|
841
873
|
* Runs execute custom command.
|
|
842
874
|
* @this {FrontendModelClass}
|
|
@@ -848,7 +880,7 @@ export default class FrontendModelBase {
|
|
|
848
880
|
* @param {string} args.resourcePath - Direct resource path.
|
|
849
881
|
* @returns {Promise<Record<string, ?>>} - Decoded response payload.
|
|
850
882
|
*/
|
|
851
|
-
static executeCustomCommand(this: FrontendModelClass, { commandName, commandType, memberId, payload, resourcePath }: {
|
|
883
|
+
static executeCustomCommand(this: FrontendModelClass<FrontendModelBase<Record<string, FrontendModelTransportValue>, Record<string, FrontendModelTransportValue>, Record<string, FrontendModelTransportValue>>, Record<string, FrontendModelTransportValue>, Record<string, FrontendModelTransportValue>>, { commandName, commandType, memberId, payload, resourcePath }: {
|
|
852
884
|
commandName: string;
|
|
853
885
|
commandType: FrontendModelRequestCommandType;
|
|
854
886
|
memberId?: string | number | null | undefined;
|
|
@@ -863,7 +895,7 @@ export default class FrontendModelBase {
|
|
|
863
895
|
* @param {Record<string, ?>} args.response - Decoded response.
|
|
864
896
|
* @returns {void}
|
|
865
897
|
*/
|
|
866
|
-
static throwOnErrorFrontendModelResponse(this: FrontendModelClass, { commandType, response }: {
|
|
898
|
+
static throwOnErrorFrontendModelResponse(this: FrontendModelClass<FrontendModelBase<Record<string, FrontendModelTransportValue>, Record<string, FrontendModelTransportValue>, Record<string, FrontendModelTransportValue>>, Record<string, FrontendModelTransportValue>, Record<string, FrontendModelTransportValue>>, { commandType, response }: {
|
|
867
899
|
commandType: FrontendModelRequestCommandType;
|
|
868
900
|
response: Record<string, unknown>;
|
|
869
901
|
}): void;
|
|
@@ -872,20 +904,20 @@ export default class FrontendModelBase {
|
|
|
872
904
|
* @this {FrontendModelClass}
|
|
873
905
|
* @returns {Set<string>} - Configured frontend model attribute names.
|
|
874
906
|
*/
|
|
875
|
-
static configuredFrontendModelAttributeNames(this: FrontendModelClass): Set<string>;
|
|
907
|
+
static configuredFrontendModelAttributeNames(this: FrontendModelClass<FrontendModelBase<Record<string, FrontendModelTransportValue>, Record<string, FrontendModelTransportValue>, Record<string, FrontendModelTransportValue>>, Record<string, FrontendModelTransportValue>, Record<string, FrontendModelTransportValue>>): Set<string>;
|
|
876
908
|
/**
|
|
877
909
|
* Runs constructor.
|
|
878
|
-
* @param {
|
|
910
|
+
* @param {Attributes | CreateAttributes} [attributes] - Initial attributes.
|
|
879
911
|
*/
|
|
880
|
-
constructor(attributes?:
|
|
912
|
+
constructor(attributes?: Attributes | CreateAttributes);
|
|
881
913
|
/**
|
|
882
914
|
* Narrows the runtime value to the documented type.
|
|
883
|
-
@type {Record<string,
|
|
884
|
-
_attributes: Record<string,
|
|
915
|
+
@type {Record<string, FrontendModelAttributeValue>} */
|
|
916
|
+
_attributes: Record<string, FrontendModelAttributeValue>;
|
|
885
917
|
/**
|
|
886
918
|
* Narrows the runtime value to the documented type.
|
|
887
|
-
@type {Record<string, FrontendModelHasManyRelationship<
|
|
888
|
-
_relationships: Record<string, FrontendModelHasManyRelationship<
|
|
919
|
+
@type {Record<string, FrontendModelHasManyRelationship<FrontendModelBase, FrontendModelBase, Record<string, FrontendModelAttributeValue>> | FrontendModelSingularRelationship<FrontendModelBase, FrontendModelBase, Record<string, FrontendModelAttributeValue>>>} */
|
|
920
|
+
_relationships: Record<string, FrontendModelHasManyRelationship<FrontendModelBase, FrontendModelBase, Record<string, FrontendModelAttributeValue>> | FrontendModelSingularRelationship<FrontendModelBase, FrontendModelBase, Record<string, FrontendModelAttributeValue>>>;
|
|
889
921
|
/**
|
|
890
922
|
* Narrows the runtime value to the documented type.
|
|
891
923
|
@type {Record<string, FrontendModelAttachmentHandle>} */
|
|
@@ -909,8 +941,8 @@ export default class FrontendModelBase {
|
|
|
909
941
|
_markedForDestruction: boolean;
|
|
910
942
|
/**
|
|
911
943
|
* Narrows the runtime value to the documented type.
|
|
912
|
-
@type {Record<string,
|
|
913
|
-
_persistedAttributes: Record<string,
|
|
944
|
+
@type {Record<string, FrontendModelAttributeValue>} */
|
|
945
|
+
_persistedAttributes: Record<string, FrontendModelAttributeValue>;
|
|
914
946
|
/**
|
|
915
947
|
* Narrows the runtime value to the documented type.
|
|
916
948
|
* @type {Array<FrontendModelBase> | undefined} - Shared reference to sibling records loaded in the same batch. Used by auto-batch-preload.
|
|
@@ -918,9 +950,9 @@ export default class FrontendModelBase {
|
|
|
918
950
|
_loadCohort: Array<FrontendModelBase> | undefined;
|
|
919
951
|
/**
|
|
920
952
|
* Runs attributes.
|
|
921
|
-
* @returns {
|
|
953
|
+
* @returns {Attributes} - Attributes hash.
|
|
922
954
|
*/
|
|
923
|
-
attributes():
|
|
955
|
+
attributes(): Attributes;
|
|
924
956
|
/**
|
|
925
957
|
* Runs is new record.
|
|
926
958
|
* @returns {boolean} - Whether this model has not yet been persisted.
|
|
@@ -962,9 +994,9 @@ export default class FrontendModelBase {
|
|
|
962
994
|
/**
|
|
963
995
|
* Runs get relationship by name.
|
|
964
996
|
* @param {string} relationshipName - Relationship name.
|
|
965
|
-
* @returns {
|
|
997
|
+
* @returns {FrontendModelRelationship} - Relationship state object.
|
|
966
998
|
*/
|
|
967
|
-
getRelationshipByName(relationshipName: string):
|
|
999
|
+
getRelationshipByName(relationshipName: string): FrontendModelRelationship;
|
|
968
1000
|
/**
|
|
969
1001
|
* Runs get attachment by name.
|
|
970
1002
|
* @param {string} attachmentName - Attachment name.
|
|
@@ -974,9 +1006,9 @@ export default class FrontendModelBase {
|
|
|
974
1006
|
/**
|
|
975
1007
|
* Runs load relationship.
|
|
976
1008
|
* @param {string} relationshipName - Relationship name.
|
|
977
|
-
* @returns {Promise
|
|
1009
|
+
* @returns {Promise<FrontendModelBase | Array<FrontendModelBase> | null>} - Loaded relationship value.
|
|
978
1010
|
*/
|
|
979
|
-
loadRelationship(relationshipName: string): Promise<
|
|
1011
|
+
loadRelationship(relationshipName: string): Promise<FrontendModelBase | Array<FrontendModelBase> | null>;
|
|
980
1012
|
/**
|
|
981
1013
|
* Preloads relationship(s) onto this already-loaded record. Accepts either a
|
|
982
1014
|
* query built via `Model.preload(...).select(...)` or a raw preload spec
|
|
@@ -994,9 +1026,9 @@ export default class FrontendModelBase {
|
|
|
994
1026
|
/**
|
|
995
1027
|
* Runs relationship or load.
|
|
996
1028
|
* @param {string} relationshipName - Relationship name.
|
|
997
|
-
* @returns {Promise
|
|
1029
|
+
* @returns {Promise<FrontendModelBase | Array<FrontendModelBase> | null>} - Loaded relationship value.
|
|
998
1030
|
*/
|
|
999
|
-
relationshipOrLoad(relationshipName: string): Promise<
|
|
1031
|
+
relationshipOrLoad(relationshipName: string): Promise<FrontendModelBase | Array<FrontendModelBase> | null>;
|
|
1000
1032
|
/**
|
|
1001
1033
|
* Attempts to batch-load `relationshipName` across cohort siblings via a
|
|
1002
1034
|
* single `preload([name]).where({pk: [ids]}).toArray()` request, then copies
|
|
@@ -1012,16 +1044,16 @@ export default class FrontendModelBase {
|
|
|
1012
1044
|
/**
|
|
1013
1045
|
* Runs set relationship.
|
|
1014
1046
|
* @param {string} relationshipName - Relationship name.
|
|
1015
|
-
* @param {
|
|
1016
|
-
* @returns {
|
|
1047
|
+
* @param {FrontendModelBase | null | undefined} relationshipValue - Relationship value.
|
|
1048
|
+
* @returns {FrontendModelBase | null | undefined} - Assigned relationship value.
|
|
1017
1049
|
*/
|
|
1018
|
-
setRelationship(relationshipName: string, relationshipValue:
|
|
1050
|
+
setRelationship(relationshipName: string, relationshipValue: FrontendModelBase | null | undefined): FrontendModelBase | null | undefined;
|
|
1019
1051
|
/**
|
|
1020
1052
|
* Runs assign attributes.
|
|
1021
|
-
* @param {Record<string,
|
|
1053
|
+
* @param {Attributes | CreateAttributes | UpdateAttributes | Record<string, FrontendModelAttributeValue>} attributes - Attributes to assign.
|
|
1022
1054
|
* @returns {void} - No return value.
|
|
1023
1055
|
*/
|
|
1024
|
-
assignAttributes(attributes: Record<string,
|
|
1056
|
+
assignAttributes(attributes: Attributes | CreateAttributes | UpdateAttributes | Record<string, FrontendModelAttributeValue>): void;
|
|
1025
1057
|
/**
|
|
1026
1058
|
* Runs clear relationship cache.
|
|
1027
1059
|
* @returns {void} - Clears cached relationship state.
|
|
@@ -1148,10 +1180,10 @@ export default class FrontendModelBase {
|
|
|
1148
1180
|
}) => void, options?: import("./query.js").FrontendModelEventOptions): Promise<() => void>;
|
|
1149
1181
|
/**
|
|
1150
1182
|
* Runs update.
|
|
1151
|
-
* @param {
|
|
1183
|
+
* @param {UpdateAttributes} [newAttributes] - New values to assign before update.
|
|
1152
1184
|
* @returns {Promise<this>} - Updated model.
|
|
1153
1185
|
*/
|
|
1154
|
-
update(newAttributes?:
|
|
1186
|
+
update(newAttributes?: UpdateAttributes): Promise<this>;
|
|
1155
1187
|
/**
|
|
1156
1188
|
* Runs attach.
|
|
1157
1189
|
* @param {?} attachmentInput - Attachment input or named attachment payload.
|
|
@@ -1169,9 +1201,9 @@ export default class FrontendModelBase {
|
|
|
1169
1201
|
* fields the caller actually changed — avoiding strict permit rejections on
|
|
1170
1202
|
* framework-managed fields like `id`, `createdAt`, `updatedAt`, or owner
|
|
1171
1203
|
* foreign keys that the resource never lists in `permittedParams`.
|
|
1172
|
-
* @returns {Record<string,
|
|
1204
|
+
* @returns {Record<string, FrontendModelAttributeValue>} - Changed attributes hash.
|
|
1173
1205
|
*/
|
|
1174
|
-
_changedAttributesForSave(): Record<string,
|
|
1206
|
+
_changedAttributesForSave(): Record<string, FrontendModelAttributeValue>;
|
|
1175
1207
|
/**
|
|
1176
1208
|
* Marks the current value for an attribute as already persisted so the next
|
|
1177
1209
|
* save does not send it unless the caller changes it again.
|
|
@@ -1247,6 +1279,10 @@ export default class FrontendModelBase {
|
|
|
1247
1279
|
*/
|
|
1248
1280
|
_reconcileNestedAttributesFromResponse(response: Record<string, unknown>): void;
|
|
1249
1281
|
}
|
|
1282
|
+
/**
|
|
1283
|
+
* Frontend model relationship helper type.
|
|
1284
|
+
*/
|
|
1285
|
+
export type FrontendModelRelationship = FrontendModelHasManyRelationship<FrontendModelBase, FrontendModelBase, Record<string, FrontendModelAttributeValue>> | FrontendModelSingularRelationship<FrontendModelBase, FrontendModelBase, Record<string, FrontendModelAttributeValue>>;
|
|
1250
1286
|
/**
|
|
1251
1287
|
* Defines this typedef.
|
|
1252
1288
|
*/
|
|
@@ -1275,6 +1311,30 @@ export type FrontendModelCommandType = "create" | "find" | "index" | "update" |
|
|
|
1275
1311
|
* FrontendModelRequestCommandType type.
|
|
1276
1312
|
*/
|
|
1277
1313
|
export type FrontendModelRequestCommandType = FrontendModelCommandType | string;
|
|
1314
|
+
/**
|
|
1315
|
+
* Model-like instance value supported by frontend-model transport.
|
|
1316
|
+
*/
|
|
1317
|
+
export type FrontendModelTransportModelValue = {
|
|
1318
|
+
attributes: () => Record<string, unknown>;
|
|
1319
|
+
};
|
|
1320
|
+
/**
|
|
1321
|
+
* Special scalar values restored by frontend-model transport.
|
|
1322
|
+
*/
|
|
1323
|
+
export type FrontendModelTransportScalarValue = undefined | null | boolean | number | string | bigint | Date | FrontendModelTransportModelValue;
|
|
1324
|
+
/**
|
|
1325
|
+
* Plain object supported by frontend-model transport values.
|
|
1326
|
+
* Nested values are intentionally opaque because TypeScript rejects recursive
|
|
1327
|
+
* JSDoc typedefs for this transport value contract.
|
|
1328
|
+
*/
|
|
1329
|
+
export type FrontendModelTransportObject = Record<string, unknown>;
|
|
1330
|
+
/**
|
|
1331
|
+
* Value supported by frontend-model transport serialization and deserialization.
|
|
1332
|
+
*/
|
|
1333
|
+
export type FrontendModelTransportValue = FrontendModelTransportScalarValue | FrontendModelTransportObject | Array<unknown>;
|
|
1334
|
+
/**
|
|
1335
|
+
* Frontend model attribute value used when generated metadata cannot infer a narrower type.
|
|
1336
|
+
*/
|
|
1337
|
+
export type FrontendModelAttributeValue = FrontendModelTransportValue;
|
|
1278
1338
|
/**
|
|
1279
1339
|
* Defines this typedef.
|
|
1280
1340
|
*/
|
|
@@ -1311,13 +1371,16 @@ export type FrontendModelResourceConfig = {
|
|
|
1311
1371
|
/**
|
|
1312
1372
|
* Frontend model constructor type.
|
|
1313
1373
|
*/
|
|
1314
|
-
export type FrontendModelConstructor = {
|
|
1315
|
-
new (attributes?: Record<string,
|
|
1374
|
+
export type FrontendModelConstructor<T extends FrontendModelBase = FrontendModelBase<Record<string, FrontendModelTransportValue>, Record<string, FrontendModelTransportValue>, Record<string, FrontendModelTransportValue>>> = {
|
|
1375
|
+
new (attributes?: Record<string, FrontendModelAttributeValue>): T;
|
|
1316
1376
|
};
|
|
1317
1377
|
/**
|
|
1318
|
-
* Frontend model static side
|
|
1378
|
+
* Frontend model static side.
|
|
1319
1379
|
*/
|
|
1320
|
-
export type FrontendModelClass =
|
|
1380
|
+
export type FrontendModelClass<T extends FrontendModelBase = FrontendModelBase<Record<string, FrontendModelTransportValue>, Record<string, FrontendModelTransportValue>, Record<string, FrontendModelTransportValue>>, Attributes extends Record<string, FrontendModelAttributeValue> = Record<string, FrontendModelTransportValue>, CreateAttributes extends Record<string, FrontendModelAttributeValue> = Record<string, FrontendModelTransportValue>> = {
|
|
1381
|
+
new (attributes?: Attributes | CreateAttributes): T;
|
|
1382
|
+
create(attributes?: CreateAttributes): Promise<T>;
|
|
1383
|
+
} & Omit<typeof FrontendModelBase, "create">;
|
|
1321
1384
|
/**
|
|
1322
1385
|
* FrontendModelTransportConfig type.
|
|
1323
1386
|
*/
|