velocious 1.0.446 → 1.0.447
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/build/configuration-types.js +2 -2
- package/build/database/pool/async-tracked-multi-connection.js +3 -1
- package/build/database/record/index.js +10 -10
- package/build/frontend-models/base.js +99 -91
- package/build/frontend-models/preloader.js +7 -7
- package/build/frontend-models/query.js +18 -18
- package/build/frontend-models/use-created-event.js +1 -1
- package/build/frontend-models/use-destroyed-event.js +1 -1
- package/build/frontend-models/use-model-class-event.js +1 -1
- package/build/frontend-models/use-updated-event.js +1 -1
- package/build/routes/resolver.js +17 -14
- package/build/src/configuration-types.d.ts +6 -6
- package/build/src/configuration-types.js +3 -3
- package/build/src/database/pool/async-tracked-multi-connection.d.ts.map +1 -1
- package/build/src/database/pool/async-tracked-multi-connection.js +5 -2
- package/build/src/database/record/index.d.ts +19 -19
- package/build/src/database/record/index.d.ts.map +1 -1
- package/build/src/database/record/index.js +11 -11
- package/build/src/frontend-models/base.d.ts +163 -153
- package/build/src/frontend-models/base.d.ts.map +1 -1
- package/build/src/frontend-models/base.js +100 -92
- package/build/src/frontend-models/preloader.d.ts +10 -10
- package/build/src/frontend-models/preloader.d.ts.map +1 -1
- package/build/src/frontend-models/preloader.js +8 -8
- package/build/src/frontend-models/query.d.ts +8 -8
- package/build/src/frontend-models/query.d.ts.map +1 -1
- package/build/src/frontend-models/query.js +19 -19
- package/build/src/frontend-models/use-created-event.d.ts +2 -2
- package/build/src/frontend-models/use-created-event.d.ts.map +1 -1
- package/build/src/frontend-models/use-created-event.js +2 -2
- package/build/src/frontend-models/use-destroyed-event.d.ts +1 -1
- package/build/src/frontend-models/use-destroyed-event.d.ts.map +1 -1
- package/build/src/frontend-models/use-destroyed-event.js +2 -2
- package/build/src/frontend-models/use-model-class-event.d.ts +1 -1
- package/build/src/frontend-models/use-model-class-event.d.ts.map +1 -1
- package/build/src/frontend-models/use-model-class-event.js +2 -2
- package/build/src/frontend-models/use-updated-event.d.ts +1 -1
- package/build/src/frontend-models/use-updated-event.d.ts.map +1 -1
- package/build/src/frontend-models/use-updated-event.js +2 -2
- package/build/src/routes/resolver.d.ts.map +1 -1
- package/build/src/routes/resolver.js +7 -4
- package/build/src/utils/model-scope.d.ts +4 -4
- package/build/src/utils/model-scope.d.ts.map +1 -1
- package/build/src/utils/model-scope.js +3 -3
- package/build/src/utils/ransack.d.ts +1 -1
- package/build/src/utils/ransack.d.ts.map +1 -1
- package/build/src/utils/ransack.js +2 -2
- package/build/utils/model-scope.js +2 -2
- package/build/utils/ransack.js +1 -1
- package/package.json +1 -1
- package/src/configuration-types.js +2 -2
- package/src/database/pool/async-tracked-multi-connection.js +3 -1
- package/src/database/record/index.js +10 -10
- package/src/frontend-models/base.js +99 -91
- package/src/frontend-models/preloader.js +7 -7
- package/src/frontend-models/query.js +18 -18
- package/src/frontend-models/use-created-event.js +1 -1
- package/src/frontend-models/use-destroyed-event.js +1 -1
- package/src/frontend-models/use-model-class-event.js +1 -1
- package/src/frontend-models/use-updated-event.js +1 -1
- package/src/routes/resolver.js +17 -14
- package/src/utils/model-scope.js +2 -2
- package/src/utils/ransack.js +1 -1
|
@@ -9,10 +9,10 @@ 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 {FrontendModelClass} S
|
|
13
|
+
* @template {FrontendModelClass} T
|
|
14
14
|
*/
|
|
15
|
-
export class FrontendModelSingularRelationship<S extends
|
|
15
|
+
export class FrontendModelSingularRelationship<S extends FrontendModelClass, T extends FrontendModelClass> {
|
|
16
16
|
/**
|
|
17
17
|
* Runs constructor.
|
|
18
18
|
* @param {InstanceType<S>} model - Parent model.
|
|
@@ -50,10 +50,10 @@ export class FrontendModelSingularRelationship<S extends typeof FrontendModelBas
|
|
|
50
50
|
}
|
|
51
51
|
/**
|
|
52
52
|
* Lightweight has-many relationship state holder for frontend model instances.
|
|
53
|
-
* @template {
|
|
54
|
-
* @template {
|
|
53
|
+
* @template {FrontendModelClass} S
|
|
54
|
+
* @template {FrontendModelClass} T
|
|
55
55
|
*/
|
|
56
|
-
export class FrontendModelHasManyRelationship<S extends
|
|
56
|
+
export class FrontendModelHasManyRelationship<S extends FrontendModelClass, T extends FrontendModelClass> {
|
|
57
57
|
/**
|
|
58
58
|
* Runs constructor.
|
|
59
59
|
* @param {InstanceType<S>} model - Parent model.
|
|
@@ -258,10 +258,10 @@ export default class FrontendModelBase {
|
|
|
258
258
|
static setAutoload(newValue: boolean): void;
|
|
259
259
|
/**
|
|
260
260
|
* Runs ensure generated attachment methods.
|
|
261
|
-
* @this {
|
|
261
|
+
* @this {FrontendModelClass}
|
|
262
262
|
* @returns {void} - Ensures attachment helper methods exist on the prototype.
|
|
263
263
|
*/
|
|
264
|
-
static ensureGeneratedAttachmentMethods(this:
|
|
264
|
+
static ensureGeneratedAttachmentMethods(this: FrontendModelClass): void;
|
|
265
265
|
/**
|
|
266
266
|
* Runs resource config.
|
|
267
267
|
* @returns {FrontendModelResourceConfig} - Resource configuration.
|
|
@@ -269,110 +269,110 @@ export default class FrontendModelBase {
|
|
|
269
269
|
static resourceConfig(): FrontendModelResourceConfig;
|
|
270
270
|
/**
|
|
271
271
|
* Runs relationship model classes.
|
|
272
|
-
* @this {
|
|
273
|
-
* @returns {Record<string,
|
|
272
|
+
* @this {FrontendModelClass}
|
|
273
|
+
* @returns {Record<string, FrontendModelClass | string>} - Relationship model classes (or class name strings) keyed by relationship name.
|
|
274
274
|
*/
|
|
275
|
-
static relationshipModelClasses(this:
|
|
275
|
+
static relationshipModelClasses(this: FrontendModelClass): Record<string, FrontendModelClass | string>;
|
|
276
276
|
/**
|
|
277
277
|
* Register a frontend model class so it can be resolved by name in relationship lookups.
|
|
278
|
-
* @param {
|
|
278
|
+
* @param {FrontendModelClass} modelClass - Model class to register.
|
|
279
279
|
* @returns {void}
|
|
280
280
|
*/
|
|
281
|
-
static registerModel(modelClass:
|
|
281
|
+
static registerModel(modelClass: FrontendModelClass): void;
|
|
282
282
|
/**
|
|
283
283
|
* Runs define scope.
|
|
284
284
|
* @param {(...args: Array<?>) => ?} callback - Scope callback.
|
|
285
|
-
* @returns {((...args: Array<?>) => import("./query.js").default<
|
|
285
|
+
* @returns {((...args: Array<?>) => import("./query.js").default<FrontendModelClass>) & {scope: (...args: Array<?>) => import("../utils/model-scope.js").ModelScopeDescriptor}} - Scope helper.
|
|
286
286
|
*/
|
|
287
|
-
static defineScope(callback: (...args: Array<unknown>) => unknown): ((...args: Array<unknown>) => import("./query.js").default<
|
|
287
|
+
static defineScope(callback: (...args: Array<unknown>) => unknown): ((...args: Array<unknown>) => import("./query.js").default<FrontendModelClass>) & {
|
|
288
288
|
scope: (...args: Array<unknown>) => import("../utils/model-scope.js").ModelScopeDescriptor;
|
|
289
289
|
};
|
|
290
290
|
/**
|
|
291
291
|
* Resolve a relationship model class value that may be a class reference or a string name.
|
|
292
|
-
* @param {
|
|
293
|
-
* @returns {
|
|
292
|
+
* @param {FrontendModelClass | string | null | undefined} value - Class or class name.
|
|
293
|
+
* @returns {FrontendModelClass | null} - Resolved model class.
|
|
294
294
|
*/
|
|
295
|
-
static resolveModelClass(value:
|
|
295
|
+
static resolveModelClass(value: FrontendModelClass | string | null | undefined): FrontendModelClass | null;
|
|
296
296
|
/**
|
|
297
297
|
* Runs relationship definitions.
|
|
298
|
-
* @this {
|
|
298
|
+
* @this {FrontendModelClass}
|
|
299
299
|
* @returns {Record<string, {type: "belongsTo" | "hasOne" | "hasMany", autoload?: boolean}>} - Relationship definitions keyed by relationship name.
|
|
300
300
|
*/
|
|
301
|
-
static relationshipDefinitions(this:
|
|
301
|
+
static relationshipDefinitions(this: FrontendModelClass): Record<string, {
|
|
302
302
|
type: "belongsTo" | "hasOne" | "hasMany";
|
|
303
303
|
autoload?: boolean;
|
|
304
304
|
}>;
|
|
305
305
|
/**
|
|
306
306
|
* Runs attachment definitions.
|
|
307
|
-
* @this {
|
|
307
|
+
* @this {FrontendModelClass}
|
|
308
308
|
* @returns {Record<string, FrontendModelAttachmentDefinition>} - Attachment definitions keyed by attachment name.
|
|
309
309
|
*/
|
|
310
|
-
static attachmentDefinitions(this:
|
|
310
|
+
static attachmentDefinitions(this: FrontendModelClass): Record<string, FrontendModelAttachmentDefinition>;
|
|
311
311
|
/**
|
|
312
312
|
* Runs attachment definition.
|
|
313
|
-
* @this {
|
|
313
|
+
* @this {FrontendModelClass}
|
|
314
314
|
* @param {string} attachmentName - Attachment name.
|
|
315
315
|
* @returns {FrontendModelAttachmentDefinition | null} - Attachment definition.
|
|
316
316
|
*/
|
|
317
|
-
static attachmentDefinition(this:
|
|
317
|
+
static attachmentDefinition(this: FrontendModelClass, attachmentName: string): FrontendModelAttachmentDefinition | null;
|
|
318
318
|
/**
|
|
319
319
|
* Runs relationship definition.
|
|
320
|
-
* @this {
|
|
320
|
+
* @this {FrontendModelClass}
|
|
321
321
|
* @param {string} relationshipName - Relationship name.
|
|
322
322
|
* @returns {{type: "belongsTo" | "hasOne" | "hasMany", autoload?: boolean} | null} - Relationship definition.
|
|
323
323
|
*/
|
|
324
|
-
static relationshipDefinition(this:
|
|
324
|
+
static relationshipDefinition(this: FrontendModelClass, relationshipName: string): {
|
|
325
325
|
type: "belongsTo" | "hasOne" | "hasMany";
|
|
326
326
|
autoload?: boolean;
|
|
327
327
|
} | null;
|
|
328
328
|
/**
|
|
329
329
|
* Resolves a Rails-style nested attributes key to a configured relationship.
|
|
330
|
-
* @this {
|
|
330
|
+
* @this {FrontendModelClass}
|
|
331
331
|
* @param {string} attributeName - Candidate attribute name, such as `tasksAttributes`.
|
|
332
332
|
* @returns {string | null} Relationship name when nested attributes are configured.
|
|
333
333
|
*/
|
|
334
|
-
static nestedAttributesRelationshipName(this:
|
|
334
|
+
static nestedAttributesRelationshipName(this: FrontendModelClass, attributeName: string): string | null;
|
|
335
335
|
/**
|
|
336
336
|
* Runs relationship model class.
|
|
337
|
-
* @this {
|
|
337
|
+
* @this {FrontendModelClass}
|
|
338
338
|
* @param {string} relationshipName - Relationship name.
|
|
339
|
-
* @returns {
|
|
339
|
+
* @returns {FrontendModelClass | null} - Target relationship model class.
|
|
340
340
|
*/
|
|
341
|
-
static relationshipModelClass(this:
|
|
341
|
+
static relationshipModelClass(this: FrontendModelClass, relationshipName: string): FrontendModelClass | null;
|
|
342
342
|
/**
|
|
343
343
|
* Runs primary key.
|
|
344
|
-
* @this {
|
|
344
|
+
* @this {FrontendModelClass}
|
|
345
345
|
* @returns {string} - Primary key name.
|
|
346
346
|
*/
|
|
347
|
-
static primaryKey(this:
|
|
347
|
+
static primaryKey(this: FrontendModelClass): string;
|
|
348
348
|
/**
|
|
349
349
|
* Runs resource path.
|
|
350
|
-
* @this {
|
|
350
|
+
* @this {FrontendModelClass}
|
|
351
351
|
* @returns {string} - Derived resource path.
|
|
352
352
|
*/
|
|
353
|
-
static resourcePath(this:
|
|
353
|
+
static resourcePath(this: FrontendModelClass): string;
|
|
354
354
|
/**
|
|
355
355
|
* Runs command name.
|
|
356
|
-
* @this {
|
|
356
|
+
* @this {FrontendModelClass}
|
|
357
357
|
* @param {FrontendModelCommandType} commandType - Command type.
|
|
358
358
|
* @returns {string} - Resolved command name.
|
|
359
359
|
*/
|
|
360
|
-
static commandName(this:
|
|
360
|
+
static commandName(this: FrontendModelClass, commandType: FrontendModelCommandType): string;
|
|
361
361
|
/**
|
|
362
362
|
* Runs normalize custom command payload arguments.
|
|
363
|
-
* @this {
|
|
363
|
+
* @this {FrontendModelClass}
|
|
364
364
|
* @param {Array<?>} args - Command arguments.
|
|
365
365
|
* @returns {Record<string, ?>} - Command payload.
|
|
366
366
|
*/
|
|
367
|
-
static normalizeCustomCommandPayloadArguments(this:
|
|
367
|
+
static normalizeCustomCommandPayloadArguments(this: FrontendModelClass, args: Array<unknown>): Record<string, unknown>;
|
|
368
368
|
/**
|
|
369
369
|
* Returns the model name, preferring an explicit `static modelName` declaration
|
|
370
370
|
* over the JavaScript class `.name` property. This allows minified builds to
|
|
371
371
|
* preserve correct model names without relying on `keep_classnames`.
|
|
372
|
-
* @this {
|
|
372
|
+
* @this {FrontendModelClass}
|
|
373
373
|
* @returns {string} - The model name.
|
|
374
374
|
*/
|
|
375
|
-
static getModelName(this:
|
|
375
|
+
static getModelName(this: FrontendModelClass): string;
|
|
376
376
|
/**
|
|
377
377
|
* Runs configure transport.
|
|
378
378
|
* @param {FrontendModelTransportConfig} config - Frontend model transport configuration.
|
|
@@ -482,18 +482,18 @@ export default class FrontendModelBase {
|
|
|
482
482
|
static installWebsocketTestHooks(): void;
|
|
483
483
|
/**
|
|
484
484
|
* Runs attributes from response.
|
|
485
|
-
* @this {
|
|
485
|
+
* @this {FrontendModelClass}
|
|
486
486
|
* @param {object} response - Response payload.
|
|
487
487
|
* @returns {Record<string, ?>} - Attributes from payload.
|
|
488
488
|
*/
|
|
489
|
-
static attributesFromResponse(this:
|
|
489
|
+
static attributesFromResponse(this: FrontendModelClass, response: object): Record<string, unknown>;
|
|
490
490
|
/**
|
|
491
491
|
* Runs model data from response.
|
|
492
|
-
* @this {
|
|
492
|
+
* @this {FrontendModelClass}
|
|
493
493
|
* @param {object} response - Response payload.
|
|
494
494
|
* @returns {{abilities: Record<string, boolean>, attributes: Record<string, ?>, associationCounts: Record<string, number>, queryData: Record<string, ?>, preloadedRelationships: Record<string, ?>, selectedAttributes: Set<string>}} - Attributes, preloaded relationships, association counts, queryData, abilities, and the selected-attributes set.
|
|
495
495
|
*/
|
|
496
|
-
static modelDataFromResponse(this:
|
|
496
|
+
static modelDataFromResponse(this: FrontendModelClass, response: object): {
|
|
497
497
|
abilities: Record<string, boolean>;
|
|
498
498
|
attributes: Record<string, unknown>;
|
|
499
499
|
associationCounts: Record<string, number>;
|
|
@@ -503,175 +503,175 @@ export default class FrontendModelBase {
|
|
|
503
503
|
};
|
|
504
504
|
/**
|
|
505
505
|
* Runs apply preloaded relationships.
|
|
506
|
-
* @this {
|
|
506
|
+
* @this {FrontendModelClass}
|
|
507
507
|
* @param {FrontendModelBase} model - Model instance.
|
|
508
508
|
* @param {Record<string, ?>} preloadedRelationships - Preloaded relationship payload.
|
|
509
509
|
* @returns {void}
|
|
510
510
|
*/
|
|
511
|
-
static applyPreloadedRelationships(this:
|
|
511
|
+
static applyPreloadedRelationships(this: FrontendModelClass, model: FrontendModelBase, preloadedRelationships: Record<string, unknown>): void;
|
|
512
512
|
/**
|
|
513
513
|
* Runs instantiate relationship value.
|
|
514
|
-
* @this {
|
|
514
|
+
* @this {FrontendModelClass}
|
|
515
515
|
* @param {?} relationshipPayload - Relationship payload value.
|
|
516
|
-
* @param {
|
|
516
|
+
* @param {FrontendModelClass | null} targetModelClass - Target model class.
|
|
517
517
|
* @returns {?} - Instantiated relationship value.
|
|
518
518
|
*/
|
|
519
|
-
static instantiateRelationshipValue(this:
|
|
519
|
+
static instantiateRelationshipValue(this: FrontendModelClass, relationshipPayload: unknown, targetModelClass: FrontendModelClass | null): unknown;
|
|
520
520
|
/**
|
|
521
521
|
* Runs instantiate from response.
|
|
522
|
-
* @template {
|
|
522
|
+
* @template {FrontendModelClass} T
|
|
523
523
|
* @this {T}
|
|
524
524
|
* @param {Record<string, ?> | InstanceType<T>} response - Response payload, or an already-hydrated instance of this class.
|
|
525
525
|
* @returns {InstanceType<T>} - New model instance, or the same instance unchanged if it was already hydrated.
|
|
526
526
|
*/
|
|
527
|
-
static instantiateFromResponse<T extends
|
|
527
|
+
static instantiateFromResponse<T extends FrontendModelClass>(this: T, response: Record<string, unknown> | InstanceType<T>): InstanceType<T>;
|
|
528
528
|
/**
|
|
529
529
|
* Runs find.
|
|
530
|
-
* @template {
|
|
530
|
+
* @template {FrontendModelClass} T
|
|
531
531
|
* @this {T}
|
|
532
532
|
* @param {number | string} id - Record identifier.
|
|
533
533
|
* @returns {Promise<InstanceType<T>>} - Resolved model.
|
|
534
534
|
*/
|
|
535
|
-
static find<T extends
|
|
535
|
+
static find<T extends FrontendModelClass>(this: T, id: number | string): Promise<InstanceType<T>>;
|
|
536
536
|
/**
|
|
537
537
|
* Runs find by.
|
|
538
|
-
* @template {
|
|
538
|
+
* @template {FrontendModelClass} T
|
|
539
539
|
* @this {T}
|
|
540
540
|
* @param {Record<string, ?>} conditions - Attribute match conditions.
|
|
541
541
|
* @returns {Promise<InstanceType<T> | null>} - Found model or null.
|
|
542
542
|
*/
|
|
543
|
-
static findBy<T extends
|
|
543
|
+
static findBy<T extends FrontendModelClass>(this: T, conditions: Record<string, unknown>): Promise<InstanceType<T> | null>;
|
|
544
544
|
/**
|
|
545
545
|
* Runs find by or fail.
|
|
546
|
-
* @template {
|
|
546
|
+
* @template {FrontendModelClass} T
|
|
547
547
|
* @this {T}
|
|
548
548
|
* @param {Record<string, ?>} conditions - Attribute match conditions.
|
|
549
549
|
* @returns {Promise<InstanceType<T>>} - Found model.
|
|
550
550
|
*/
|
|
551
|
-
static findByOrFail<T extends
|
|
551
|
+
static findByOrFail<T extends FrontendModelClass>(this: T, conditions: Record<string, unknown>): Promise<InstanceType<T>>;
|
|
552
552
|
/**
|
|
553
553
|
* Runs to array.
|
|
554
|
-
* @template {
|
|
554
|
+
* @template {FrontendModelClass} T
|
|
555
555
|
* @this {T}
|
|
556
556
|
* @returns {Promise<InstanceType<T>[]>} - Loaded model instances.
|
|
557
557
|
*/
|
|
558
|
-
static toArray<T extends
|
|
558
|
+
static toArray<T extends FrontendModelClass>(this: T): Promise<InstanceType<T>[]>;
|
|
559
559
|
/**
|
|
560
560
|
* Runs load.
|
|
561
|
-
* @template {
|
|
561
|
+
* @template {FrontendModelClass} T
|
|
562
562
|
* @this {T}
|
|
563
563
|
* @returns {Promise<InstanceType<T>[]>} - Loaded model instances.
|
|
564
564
|
*/
|
|
565
|
-
static load<T extends
|
|
565
|
+
static load<T extends FrontendModelClass>(this: T): Promise<InstanceType<T>[]>;
|
|
566
566
|
/**
|
|
567
567
|
* Runs all.
|
|
568
|
-
* @template {
|
|
568
|
+
* @template {FrontendModelClass} T
|
|
569
569
|
* @this {T}
|
|
570
570
|
* @returns {FrontendModelQuery<T>} - Query builder.
|
|
571
571
|
*/
|
|
572
|
-
static all<T extends
|
|
572
|
+
static all<T extends FrontendModelClass>(this: T): FrontendModelQuery<T>;
|
|
573
573
|
/**
|
|
574
574
|
* Runs where.
|
|
575
|
-
* @template {
|
|
575
|
+
* @template {FrontendModelClass} T
|
|
576
576
|
* @this {T}
|
|
577
577
|
* @param {Record<string, ?>} conditions - Root-model where conditions.
|
|
578
578
|
* @returns {import("./query.js").default<T>} - Query with where conditions.
|
|
579
579
|
*/
|
|
580
|
-
static where<T extends
|
|
580
|
+
static where<T extends FrontendModelClass>(this: T, conditions: Record<string, unknown>): import("./query.js").default<T>;
|
|
581
581
|
/**
|
|
582
582
|
* Runs joins.
|
|
583
|
-
* @template {
|
|
583
|
+
* @template {FrontendModelClass} T
|
|
584
584
|
* @this {T}
|
|
585
585
|
* @param {Record<string, ?> | Array<Record<string, ?>>} joins - Relationship descriptor joins.
|
|
586
586
|
* @returns {import("./query.js").default<T>} - Query with joins.
|
|
587
587
|
*/
|
|
588
|
-
static joins<T extends
|
|
588
|
+
static joins<T extends FrontendModelClass>(this: T, joins: Record<string, unknown> | Array<Record<string, unknown>>): import("./query.js").default<T>;
|
|
589
589
|
/**
|
|
590
590
|
* Runs limit.
|
|
591
|
-
* @template {
|
|
591
|
+
* @template {FrontendModelClass} T
|
|
592
592
|
* @this {T}
|
|
593
593
|
* @param {number} value - Maximum number of records.
|
|
594
594
|
* @returns {import("./query.js").default<T>} - Query with limit.
|
|
595
595
|
*/
|
|
596
|
-
static limit<T extends
|
|
596
|
+
static limit<T extends FrontendModelClass>(this: T, value: number): import("./query.js").default<T>;
|
|
597
597
|
/**
|
|
598
598
|
* Runs offset.
|
|
599
|
-
* @template {
|
|
599
|
+
* @template {FrontendModelClass} T
|
|
600
600
|
* @this {T}
|
|
601
601
|
* @param {number} value - Number of records to skip.
|
|
602
602
|
* @returns {import("./query.js").default<T>} - Query with offset.
|
|
603
603
|
*/
|
|
604
|
-
static offset<T extends
|
|
604
|
+
static offset<T extends FrontendModelClass>(this: T, value: number): import("./query.js").default<T>;
|
|
605
605
|
/**
|
|
606
606
|
* Runs page.
|
|
607
|
-
* @template {
|
|
607
|
+
* @template {FrontendModelClass} T
|
|
608
608
|
* @this {T}
|
|
609
609
|
* @param {number} pageNumber - 1-based page number.
|
|
610
610
|
* @returns {import("./query.js").default<T>} - Query with page applied.
|
|
611
611
|
*/
|
|
612
|
-
static page<T extends
|
|
612
|
+
static page<T extends FrontendModelClass>(this: T, pageNumber: number): import("./query.js").default<T>;
|
|
613
613
|
/**
|
|
614
614
|
* Runs per page.
|
|
615
|
-
* @template {
|
|
615
|
+
* @template {FrontendModelClass} T
|
|
616
616
|
* @this {T}
|
|
617
617
|
* @param {number} value - Number of records per page.
|
|
618
618
|
* @returns {import("./query.js").default<T>} - Query with page size.
|
|
619
619
|
*/
|
|
620
|
-
static perPage<T extends
|
|
620
|
+
static perPage<T extends FrontendModelClass>(this: T, value: number): import("./query.js").default<T>;
|
|
621
621
|
/**
|
|
622
622
|
* Runs count.
|
|
623
|
-
* @template {
|
|
623
|
+
* @template {FrontendModelClass} T
|
|
624
624
|
* @this {T}
|
|
625
625
|
* @returns {Promise<number>} - Number of loaded model instances.
|
|
626
626
|
*/
|
|
627
|
-
static count<T extends
|
|
627
|
+
static count<T extends FrontendModelClass>(this: T): Promise<number>;
|
|
628
628
|
/**
|
|
629
629
|
* Class-level hook fired when any record of this model is created.
|
|
630
630
|
* Subscribe-time authorization only — once a subscription is
|
|
631
631
|
* accepted, future `create` events for this model are delivered
|
|
632
632
|
* without re-checking per-record visibility. Query options can still
|
|
633
633
|
* narrow which events reach this callback.
|
|
634
|
-
* @this {
|
|
635
|
-
* @param {(payload: {id: string, model:
|
|
634
|
+
* @this {FrontendModelClass}
|
|
635
|
+
* @param {(payload: {id: string, model: FrontendModelBase}) => void} callback - Event callback.
|
|
636
636
|
* @param {import("./query.js").FrontendModelEventOptions} [options] - Event query or record projection options.
|
|
637
637
|
* @returns {Promise<() => void>} - Unsubscribe callback.
|
|
638
638
|
*/
|
|
639
|
-
static onCreate(this:
|
|
639
|
+
static onCreate(this: FrontendModelClass, callback: (payload: {
|
|
640
640
|
id: string;
|
|
641
|
-
model:
|
|
641
|
+
model: FrontendModelBase;
|
|
642
642
|
}) => void, options?: import("./query.js").FrontendModelEventOptions): Promise<() => void>;
|
|
643
643
|
/**
|
|
644
644
|
* Class-level hook fired when any record of this model is updated.
|
|
645
|
-
* @this {
|
|
646
|
-
* @param {(payload: {id: string, model:
|
|
645
|
+
* @this {FrontendModelClass}
|
|
646
|
+
* @param {(payload: {id: string, model: FrontendModelBase}) => void} callback - Event callback.
|
|
647
647
|
* @param {import("./query.js").FrontendModelEventOptions} [options] - Event query or record projection options.
|
|
648
648
|
* @returns {Promise<() => void>} - Unsubscribe callback.
|
|
649
649
|
*/
|
|
650
|
-
static onUpdate(this:
|
|
650
|
+
static onUpdate(this: FrontendModelClass, callback: (payload: {
|
|
651
651
|
id: string;
|
|
652
|
-
model:
|
|
652
|
+
model: FrontendModelBase;
|
|
653
653
|
}) => void, options?: import("./query.js").FrontendModelEventOptions): Promise<() => void>;
|
|
654
654
|
/**
|
|
655
655
|
* Class-level hook fired when any record of this model is destroyed.
|
|
656
|
-
* @this {
|
|
656
|
+
* @this {FrontendModelClass}
|
|
657
657
|
* @param {(payload: {id: string}) => void} callback - Event callback.
|
|
658
658
|
* @param {import("./query.js").FrontendModelEventOptions} [options] - Accepted for API symmetry; destroy events carry ids only.
|
|
659
659
|
* @returns {Promise<() => void>} - Unsubscribe callback.
|
|
660
660
|
*/
|
|
661
|
-
static onDestroy(this:
|
|
661
|
+
static onDestroy(this: FrontendModelClass, callback: (payload: {
|
|
662
662
|
id: string;
|
|
663
663
|
}) => void, options?: import("./query.js").FrontendModelEventOptions): Promise<() => void>;
|
|
664
664
|
/**
|
|
665
665
|
* Runs pluck.
|
|
666
|
-
* @template {
|
|
666
|
+
* @template {FrontendModelClass} T
|
|
667
667
|
* @this {T}
|
|
668
668
|
* @param {...(string | string[] | Record<string, ?> | Array<Record<string, ?>>)} columns - Pluck definition(s).
|
|
669
669
|
* @returns {Promise<Array<?>>} - Plucked values.
|
|
670
670
|
*/
|
|
671
|
-
static pluck<T extends
|
|
671
|
+
static pluck<T extends FrontendModelClass>(this: T, ...columns: (string | string[] | Record<string, unknown> | Array<Record<string, unknown>>)[]): Promise<Array<unknown>>;
|
|
672
672
|
/**
|
|
673
673
|
* Runs search.
|
|
674
|
-
* @template {
|
|
674
|
+
* @template {FrontendModelClass} T
|
|
675
675
|
* @this {T}
|
|
676
676
|
* @param {string[]} path - Relationship path.
|
|
677
677
|
* @param {string} column - Column or attribute name.
|
|
@@ -679,167 +679,167 @@ export default class FrontendModelBase {
|
|
|
679
679
|
* @param {?} value - Search value.
|
|
680
680
|
* @returns {FrontendModelQuery<T>} - Query builder with search filter.
|
|
681
681
|
*/
|
|
682
|
-
static search<T extends
|
|
682
|
+
static search<T extends FrontendModelClass>(this: T, path: string[], column: string, operator: "eq" | "like" | "notEq" | "gt" | "gteq" | "lt" | "lteq" | ">" | ">=" | "<" | "<=", value: unknown): FrontendModelQuery<T>;
|
|
683
683
|
/**
|
|
684
684
|
* Runs ransack.
|
|
685
|
-
* @template {
|
|
685
|
+
* @template {FrontendModelClass} T
|
|
686
686
|
* @this {T}
|
|
687
687
|
* @param {Record<string, ?>} params - Ransack-style params hash.
|
|
688
688
|
* @returns {FrontendModelQuery<T>} - Query builder with Ransack filters applied.
|
|
689
689
|
*/
|
|
690
|
-
static ransack<T extends
|
|
690
|
+
static ransack<T extends FrontendModelClass>(this: T, params: Record<string, unknown>): FrontendModelQuery<T>;
|
|
691
691
|
/**
|
|
692
692
|
* Runs sort.
|
|
693
|
-
* @template {
|
|
693
|
+
* @template {FrontendModelClass} T
|
|
694
694
|
* @this {T}
|
|
695
695
|
* @param {string | string[] | string[][] | [string, string] | Array<[string, string]> | Record<string, ?> | Array<Record<string, ?>>} sort - Sort definition(s).
|
|
696
696
|
* @returns {FrontendModelQuery<T>} - Query builder with sort definitions.
|
|
697
697
|
*/
|
|
698
|
-
static sort<T extends
|
|
698
|
+
static sort<T extends FrontendModelClass>(this: T, sort: string | string[] | string[][] | [string, string] | Array<[string, string]> | Record<string, unknown> | Array<Record<string, unknown>>): FrontendModelQuery<T>;
|
|
699
699
|
/**
|
|
700
700
|
* Runs order.
|
|
701
|
-
* @template {
|
|
701
|
+
* @template {FrontendModelClass} T
|
|
702
702
|
* @this {T}
|
|
703
703
|
* @param {string | string[] | string[][] | [string, string] | Array<[string, string]> | Record<string, ?> | Array<Record<string, ?>>} sort - Sort definition(s).
|
|
704
704
|
* @returns {FrontendModelQuery<T>} - Query builder with sort definitions.
|
|
705
705
|
*/
|
|
706
|
-
static order<T extends
|
|
706
|
+
static order<T extends FrontendModelClass>(this: T, sort: string | string[] | string[][] | [string, string] | Array<[string, string]> | Record<string, unknown> | Array<Record<string, unknown>>): FrontendModelQuery<T>;
|
|
707
707
|
/**
|
|
708
708
|
* Runs group.
|
|
709
|
-
* @template {
|
|
709
|
+
* @template {FrontendModelClass} T
|
|
710
710
|
* @this {T}
|
|
711
711
|
* @param {string | string[] | Record<string, ?> | Array<Record<string, ?>>} group - Group definition(s).
|
|
712
712
|
* @returns {FrontendModelQuery<T>} - Query builder with group definitions.
|
|
713
713
|
*/
|
|
714
|
-
static group<T extends
|
|
714
|
+
static group<T extends FrontendModelClass>(this: T, group: string | string[] | Record<string, unknown> | Array<Record<string, unknown>>): FrontendModelQuery<T>;
|
|
715
715
|
/**
|
|
716
716
|
* Runs distinct.
|
|
717
|
-
* @template {
|
|
717
|
+
* @template {FrontendModelClass} T
|
|
718
718
|
* @this {T}
|
|
719
719
|
* @param {boolean} [value] - Whether to request distinct rows.
|
|
720
720
|
* @returns {FrontendModelQuery<T>} - Query builder with distinct flag.
|
|
721
721
|
*/
|
|
722
|
-
static distinct<T extends
|
|
722
|
+
static distinct<T extends FrontendModelClass>(this: T, value?: boolean): FrontendModelQuery<T>;
|
|
723
723
|
/**
|
|
724
724
|
* Runs query.
|
|
725
|
-
* @template {
|
|
725
|
+
* @template {FrontendModelClass} T
|
|
726
726
|
* @this {T}
|
|
727
727
|
* @returns {FrontendModelQuery<T>} - Query builder.
|
|
728
728
|
*/
|
|
729
|
-
static query<T extends
|
|
729
|
+
static query<T extends FrontendModelClass>(this: T): FrontendModelQuery<T>;
|
|
730
730
|
/**
|
|
731
731
|
* Runs preload.
|
|
732
|
-
* @template {
|
|
732
|
+
* @template {FrontendModelClass} T
|
|
733
733
|
* @this {T}
|
|
734
734
|
* @param {import("../database/query/index.js").NestedPreloadRecord | string | Array<string | import("../database/query/index.js").NestedPreloadRecord>} preload - Preload graph.
|
|
735
735
|
* @returns {FrontendModelQuery<T>} - Query with preload.
|
|
736
736
|
*/
|
|
737
|
-
static preload<T extends
|
|
737
|
+
static preload<T extends FrontendModelClass>(this: T, preload: import("../database/query/index.js").NestedPreloadRecord | string | Array<string | import("../database/query/index.js").NestedPreloadRecord>): FrontendModelQuery<T>;
|
|
738
738
|
/**
|
|
739
739
|
* Runs select.
|
|
740
|
-
* @template {
|
|
740
|
+
* @template {FrontendModelClass} T
|
|
741
741
|
* @this {T}
|
|
742
742
|
* @param {Record<string, string[] | string> | string | string[]} select - Model-aware attribute select map or root-model shorthand.
|
|
743
743
|
* @returns {FrontendModelQuery<T>} - Query with selected attributes.
|
|
744
744
|
*/
|
|
745
|
-
static select<T extends
|
|
745
|
+
static select<T extends FrontendModelClass>(this: T, select: Record<string, string[] | string> | string | string[]): FrontendModelQuery<T>;
|
|
746
746
|
/**
|
|
747
747
|
* Runs selects extra.
|
|
748
|
-
* @template {
|
|
748
|
+
* @template {FrontendModelClass} T
|
|
749
749
|
* @this {T}
|
|
750
750
|
* @param {Record<string, string[] | string> | string | string[]} select - Extra attributes to load in addition to the defaults, keyed by model name or root-model shorthand.
|
|
751
751
|
* @returns {FrontendModelQuery<T>} - Query with extra selected attributes.
|
|
752
752
|
*/
|
|
753
|
-
static selectsExtra<T extends
|
|
753
|
+
static selectsExtra<T extends FrontendModelClass>(this: T, select: Record<string, string[] | string> | string | string[]): FrontendModelQuery<T>;
|
|
754
754
|
/**
|
|
755
755
|
* Runs first.
|
|
756
|
-
* @template {
|
|
756
|
+
* @template {FrontendModelClass} T
|
|
757
757
|
* @this {T}
|
|
758
758
|
* @returns {Promise<InstanceType<T> | null>} - First model or null.
|
|
759
759
|
*/
|
|
760
|
-
static first<T extends
|
|
760
|
+
static first<T extends FrontendModelClass>(this: T): Promise<InstanceType<T> | null>;
|
|
761
761
|
/**
|
|
762
762
|
* Runs last.
|
|
763
|
-
* @template {
|
|
763
|
+
* @template {FrontendModelClass} T
|
|
764
764
|
* @this {T}
|
|
765
765
|
* @returns {Promise<InstanceType<T> | null>} - Last model or null.
|
|
766
766
|
*/
|
|
767
|
-
static last<T extends
|
|
767
|
+
static last<T extends FrontendModelClass>(this: T): Promise<InstanceType<T> | null>;
|
|
768
768
|
/**
|
|
769
769
|
* Runs find or initialize by.
|
|
770
|
-
* @template {
|
|
770
|
+
* @template {FrontendModelClass} T
|
|
771
771
|
* @this {T}
|
|
772
772
|
* @param {Record<string, ?>} conditions - Attribute match conditions.
|
|
773
773
|
* @returns {Promise<InstanceType<T>>} - Existing or initialized model.
|
|
774
774
|
*/
|
|
775
|
-
static findOrInitializeBy<T extends
|
|
775
|
+
static findOrInitializeBy<T extends FrontendModelClass>(this: T, conditions: Record<string, unknown>): Promise<InstanceType<T>>;
|
|
776
776
|
/**
|
|
777
777
|
* Runs find or create by.
|
|
778
|
-
* @template {
|
|
778
|
+
* @template {FrontendModelClass} T
|
|
779
779
|
* @this {T}
|
|
780
780
|
* @param {Record<string, ?>} conditions - Attribute match conditions.
|
|
781
781
|
* @param {(model: InstanceType<T>) => Promise<void> | void} [callback] - Optional callback before save when created.
|
|
782
782
|
* @returns {Promise<InstanceType<T>>} - Existing or newly created model.
|
|
783
783
|
*/
|
|
784
|
-
static findOrCreateBy<T extends
|
|
784
|
+
static findOrCreateBy<T extends FrontendModelClass>(this: T, conditions: Record<string, unknown>, callback?: (model: InstanceType<T>) => Promise<void> | void): Promise<InstanceType<T>>;
|
|
785
785
|
/**
|
|
786
786
|
* Runs create.
|
|
787
|
-
* @template {
|
|
787
|
+
* @template {FrontendModelClass} T
|
|
788
788
|
* @this {T}
|
|
789
789
|
* @param {Record<string, ?>} [attributes] - Initial attributes.
|
|
790
790
|
* @returns {Promise<InstanceType<T>>} - Persisted model.
|
|
791
791
|
*/
|
|
792
|
-
static create<T extends
|
|
792
|
+
static create<T extends FrontendModelClass>(this: T, attributes?: Record<string, unknown>): Promise<InstanceType<T>>;
|
|
793
793
|
/**
|
|
794
794
|
* Runs assert find by conditions.
|
|
795
|
-
* @this {
|
|
795
|
+
* @this {FrontendModelClass}
|
|
796
796
|
* @param {Record<string, ?>} conditions - findBy conditions.
|
|
797
797
|
* @returns {void}
|
|
798
798
|
*/
|
|
799
|
-
static assertFindByConditions(this:
|
|
799
|
+
static assertFindByConditions(this: FrontendModelClass, conditions: Record<string, unknown>): void;
|
|
800
800
|
/**
|
|
801
801
|
* Runs matches find by conditions.
|
|
802
|
-
* @this {
|
|
802
|
+
* @this {FrontendModelClass}
|
|
803
803
|
* @param {FrontendModelBase} model - Candidate model.
|
|
804
804
|
* @param {Record<string, ?>} conditions - Match conditions.
|
|
805
805
|
* @returns {boolean} - Whether the model matches all conditions.
|
|
806
806
|
*/
|
|
807
|
-
static matchesFindByConditions(this:
|
|
807
|
+
static matchesFindByConditions(this: FrontendModelClass, model: FrontendModelBase, conditions: Record<string, unknown>): boolean;
|
|
808
808
|
/**
|
|
809
809
|
* Runs find by condition value matches.
|
|
810
|
-
* @this {
|
|
810
|
+
* @this {FrontendModelClass}
|
|
811
811
|
* @param {?} actualValue - Actual model value.
|
|
812
812
|
* @param {?} expectedValue - Expected find condition value.
|
|
813
813
|
* @returns {boolean} - Whether values match.
|
|
814
814
|
*/
|
|
815
|
-
static findByConditionValueMatches(this:
|
|
815
|
+
static findByConditionValueMatches(this: FrontendModelClass, actualValue: unknown, expectedValue: unknown): boolean;
|
|
816
816
|
/**
|
|
817
817
|
* Runs find by primitive values match.
|
|
818
|
-
* @this {
|
|
818
|
+
* @this {FrontendModelClass}
|
|
819
819
|
* @param {?} actualValue - Actual model value.
|
|
820
820
|
* @param {?} expectedValue - Expected find condition value.
|
|
821
821
|
* @returns {boolean} - Whether primitive values match after safe coercion.
|
|
822
822
|
*/
|
|
823
|
-
static findByPrimitiveValuesMatch(this:
|
|
823
|
+
static findByPrimitiveValuesMatch(this: FrontendModelClass, actualValue: unknown, expectedValue: unknown): boolean;
|
|
824
824
|
/**
|
|
825
825
|
* Runs find by numeric string matches number.
|
|
826
|
-
* @this {
|
|
826
|
+
* @this {FrontendModelClass}
|
|
827
827
|
* @param {string} numericString - Numeric string value.
|
|
828
828
|
* @param {number} expectedNumber - Number value.
|
|
829
829
|
* @returns {boolean} - Whether values represent the same number.
|
|
830
830
|
*/
|
|
831
|
-
static findByNumericStringMatchesNumber(this:
|
|
831
|
+
static findByNumericStringMatchesNumber(this: FrontendModelClass, numericString: string, expectedNumber: number): boolean;
|
|
832
832
|
/**
|
|
833
833
|
* Runs execute command.
|
|
834
|
-
* @this {
|
|
834
|
+
* @this {FrontendModelClass}
|
|
835
835
|
* @param {FrontendModelCommandType} commandType - Command type.
|
|
836
836
|
* @param {Record<string, ?>} payload - Command payload.
|
|
837
837
|
* @returns {Promise<Record<string, ?>>} - Parsed JSON response.
|
|
838
838
|
*/
|
|
839
|
-
static executeCommand(this:
|
|
839
|
+
static executeCommand(this: FrontendModelClass, commandType: FrontendModelCommandType, payload: Record<string, unknown>): Promise<Record<string, unknown>>;
|
|
840
840
|
/**
|
|
841
841
|
* Runs execute custom command.
|
|
842
|
-
* @this {
|
|
842
|
+
* @this {FrontendModelClass}
|
|
843
843
|
* @param {object} args - Command arguments.
|
|
844
844
|
* @param {string} args.commandName - Raw command path segment.
|
|
845
845
|
* @param {FrontendModelRequestCommandType} args.commandType - Logical command type for error handling.
|
|
@@ -848,7 +848,7 @@ export default class FrontendModelBase {
|
|
|
848
848
|
* @param {string} args.resourcePath - Direct resource path.
|
|
849
849
|
* @returns {Promise<Record<string, ?>>} - Decoded response payload.
|
|
850
850
|
*/
|
|
851
|
-
static executeCustomCommand(this:
|
|
851
|
+
static executeCustomCommand(this: FrontendModelClass, { commandName, commandType, memberId, payload, resourcePath }: {
|
|
852
852
|
commandName: string;
|
|
853
853
|
commandType: FrontendModelRequestCommandType;
|
|
854
854
|
memberId?: string | number | null | undefined;
|
|
@@ -857,22 +857,22 @@ export default class FrontendModelBase {
|
|
|
857
857
|
}): Promise<Record<string, unknown>>;
|
|
858
858
|
/**
|
|
859
859
|
* Runs throw on error frontend model response.
|
|
860
|
-
* @this {
|
|
860
|
+
* @this {FrontendModelClass}
|
|
861
861
|
* @param {object} args - Arguments.
|
|
862
862
|
* @param {FrontendModelRequestCommandType} args.commandType - Command type.
|
|
863
863
|
* @param {Record<string, ?>} args.response - Decoded response.
|
|
864
864
|
* @returns {void}
|
|
865
865
|
*/
|
|
866
|
-
static throwOnErrorFrontendModelResponse(this:
|
|
866
|
+
static throwOnErrorFrontendModelResponse(this: FrontendModelClass, { commandType, response }: {
|
|
867
867
|
commandType: FrontendModelRequestCommandType;
|
|
868
868
|
response: Record<string, unknown>;
|
|
869
869
|
}): void;
|
|
870
870
|
/**
|
|
871
871
|
* Runs configured frontend model attribute names.
|
|
872
|
-
* @this {
|
|
872
|
+
* @this {FrontendModelClass}
|
|
873
873
|
* @returns {Set<string>} - Configured frontend model attribute names.
|
|
874
874
|
*/
|
|
875
|
-
static configuredFrontendModelAttributeNames(this:
|
|
875
|
+
static configuredFrontendModelAttributeNames(this: FrontendModelClass): Set<string>;
|
|
876
876
|
/**
|
|
877
877
|
* Runs constructor.
|
|
878
878
|
* @param {Record<string, ?>} [attributes] - Initial attributes.
|
|
@@ -884,8 +884,8 @@ export default class FrontendModelBase {
|
|
|
884
884
|
_attributes: Record<string, unknown>;
|
|
885
885
|
/**
|
|
886
886
|
* Narrows the runtime value to the documented type.
|
|
887
|
-
@type {Record<string, FrontendModelHasManyRelationship<
|
|
888
|
-
_relationships: Record<string, FrontendModelHasManyRelationship<
|
|
887
|
+
@type {Record<string, FrontendModelHasManyRelationship<FrontendModelClass, FrontendModelClass> | FrontendModelSingularRelationship<FrontendModelClass, FrontendModelClass>>} */
|
|
888
|
+
_relationships: Record<string, FrontendModelHasManyRelationship<FrontendModelClass, FrontendModelClass> | FrontendModelSingularRelationship<FrontendModelClass, FrontendModelClass>>;
|
|
889
889
|
/**
|
|
890
890
|
* Narrows the runtime value to the documented type.
|
|
891
891
|
@type {Record<string, FrontendModelAttachmentHandle>} */
|
|
@@ -962,9 +962,9 @@ export default class FrontendModelBase {
|
|
|
962
962
|
/**
|
|
963
963
|
* Runs get relationship by name.
|
|
964
964
|
* @param {string} relationshipName - Relationship name.
|
|
965
|
-
* @returns {FrontendModelHasManyRelationship<
|
|
965
|
+
* @returns {FrontendModelHasManyRelationship<FrontendModelClass, FrontendModelClass> | FrontendModelSingularRelationship<FrontendModelClass, FrontendModelClass>} - Relationship state object.
|
|
966
966
|
*/
|
|
967
|
-
getRelationshipByName(relationshipName: string): FrontendModelHasManyRelationship<
|
|
967
|
+
getRelationshipByName(relationshipName: string): FrontendModelHasManyRelationship<FrontendModelClass, FrontendModelClass> | FrontendModelSingularRelationship<FrontendModelClass, FrontendModelClass>;
|
|
968
968
|
/**
|
|
969
969
|
* Runs get attachment by name.
|
|
970
970
|
* @param {string} attachmentName - Attachment name.
|
|
@@ -984,11 +984,11 @@ export default class FrontendModelBase {
|
|
|
984
984
|
* required columns present are left untouched unless `force` is set. Carries
|
|
985
985
|
* the query's preload graph, select, selectsExtra, withCount, abilities, and
|
|
986
986
|
* queryData when re-fetching.
|
|
987
|
-
* @param {import("./query.js").default<
|
|
987
|
+
* @param {import("./query.js").default<FrontendModelClass> | import("../database/query/index.js").NestedPreloadRecord | string | Array<string | import("../database/query/index.js").NestedPreloadRecord>} queryOrSpec - Preload source.
|
|
988
988
|
* @param {{force?: boolean}} [options] - Options.
|
|
989
989
|
* @returns {Promise<void>} - Resolves when preloading completes.
|
|
990
990
|
*/
|
|
991
|
-
preload(queryOrSpec: import("./query.js").default<
|
|
991
|
+
preload(queryOrSpec: import("./query.js").default<FrontendModelClass> | import("../database/query/index.js").NestedPreloadRecord | string | Array<string | import("../database/query/index.js").NestedPreloadRecord>, options?: {
|
|
992
992
|
force?: boolean;
|
|
993
993
|
}): Promise<void>;
|
|
994
994
|
/**
|
|
@@ -1129,13 +1129,13 @@ export default class FrontendModelBase {
|
|
|
1129
1129
|
* instance's attributes are auto-merged with the broadcast payload
|
|
1130
1130
|
* before the callback runs, so callers can read fresh values via
|
|
1131
1131
|
* `this.someAttr()` without re-fetching.
|
|
1132
|
-
* @param {(payload: {id: string, model:
|
|
1132
|
+
* @param {(payload: {id: string, model: FrontendModelBase}) => void} callback - Event callback.
|
|
1133
1133
|
* @param {import("./query.js").FrontendModelEventOptions} [options] - Event query or record projection options.
|
|
1134
1134
|
* @returns {Promise<() => void>} - Unsubscribe callback.
|
|
1135
1135
|
*/
|
|
1136
1136
|
onUpdate(callback: (payload: {
|
|
1137
1137
|
id: string;
|
|
1138
|
-
model:
|
|
1138
|
+
model: FrontendModelBase;
|
|
1139
1139
|
}) => void, options?: import("./query.js").FrontendModelEventOptions): Promise<() => void>;
|
|
1140
1140
|
/**
|
|
1141
1141
|
* Instance-level hook fired when THIS record is destroyed.
|
|
@@ -1215,27 +1215,27 @@ export default class FrontendModelBase {
|
|
|
1215
1215
|
_nestedAttributesEntryForParentSave(): Promise<Record<string, unknown> | null>;
|
|
1216
1216
|
/**
|
|
1217
1217
|
* Builds nested entries from a Rails-style submitted `*Attributes` value.
|
|
1218
|
-
* @param {
|
|
1218
|
+
* @param {FrontendModelClass} ModelClass - Parent model class.
|
|
1219
1219
|
* @param {string} relationshipName - Nested relationship name.
|
|
1220
1220
|
* @param {?} value - Submitted nested attributes value.
|
|
1221
1221
|
* @returns {Promise<Array<Record<string, ?>>>} Nested entries for the transport payload.
|
|
1222
1222
|
*/
|
|
1223
|
-
_nestedAttributesPayloadForSubmittedValue(ModelClass:
|
|
1223
|
+
_nestedAttributesPayloadForSubmittedValue(ModelClass: FrontendModelClass, relationshipName: string, value: unknown): Promise<Array<Record<string, unknown>>>;
|
|
1224
1224
|
/**
|
|
1225
1225
|
* Converts one submitted Rails-style nested attributes object into transport payload shape.
|
|
1226
|
-
* @param {
|
|
1226
|
+
* @param {FrontendModelClass} ModelClass - Nested child model class.
|
|
1227
1227
|
* @param {?} submittedEntry - Submitted nested attributes entry.
|
|
1228
1228
|
* @returns {Promise<Record<string, ?>>} Transport nested-attributes entry.
|
|
1229
1229
|
*/
|
|
1230
|
-
_nestedAttributesEntryPayloadForSubmittedValue(ModelClass:
|
|
1230
|
+
_nestedAttributesEntryPayloadForSubmittedValue(ModelClass: FrontendModelClass, submittedEntry: unknown): Promise<Record<string, unknown>>;
|
|
1231
1231
|
/**
|
|
1232
1232
|
* Normalizes a submitted attachment value for transport.
|
|
1233
|
-
* @param {
|
|
1233
|
+
* @param {FrontendModelClass} ModelClass - Model class owning the attachment.
|
|
1234
1234
|
* @param {string} attachmentName - Attachment name.
|
|
1235
1235
|
* @param {?} value - Submitted attachment value.
|
|
1236
1236
|
* @returns {Promise<Record<string, ?> | Record<string, ?>[]>} Normalized attachment payload.
|
|
1237
1237
|
*/
|
|
1238
|
-
_attachmentPayloadForSubmittedValue(ModelClass:
|
|
1238
|
+
_attachmentPayloadForSubmittedValue(ModelClass: FrontendModelClass, attachmentName: string, value: unknown): Promise<Record<string, unknown> | Record<string, unknown>[]>;
|
|
1239
1239
|
/**
|
|
1240
1240
|
* After a parent save with `nestedAttributes`, the server response includes
|
|
1241
1241
|
* preloaded versions of the affected relationships. This replaces the local
|
|
@@ -1253,7 +1253,7 @@ export default class FrontendModelBase {
|
|
|
1253
1253
|
export type FrontendModelModelEventCallbackEntry = {
|
|
1254
1254
|
callback: (payload: {
|
|
1255
1255
|
id: string;
|
|
1256
|
-
model:
|
|
1256
|
+
model: FrontendModelBase;
|
|
1257
1257
|
}) => void;
|
|
1258
1258
|
eventFilterKey: string | null;
|
|
1259
1259
|
eventFilterPayload: import("./query.js").FrontendModelEventFilterPayload | null;
|
|
@@ -1308,6 +1308,16 @@ export type FrontendModelResourceConfig = {
|
|
|
1308
1308
|
primaryKey?: string;
|
|
1309
1309
|
relationships?: string[];
|
|
1310
1310
|
};
|
|
1311
|
+
/**
|
|
1312
|
+
* Frontend model constructor type.
|
|
1313
|
+
*/
|
|
1314
|
+
export type FrontendModelConstructor = {
|
|
1315
|
+
new (attributes?: Record<string, unknown>): FrontendModelBase;
|
|
1316
|
+
};
|
|
1317
|
+
/**
|
|
1318
|
+
* Frontend model static side without generated per-model create overloads.
|
|
1319
|
+
*/
|
|
1320
|
+
export type FrontendModelClass = FrontendModelConstructor & Omit<typeof FrontendModelBase, "create">;
|
|
1311
1321
|
/**
|
|
1312
1322
|
* FrontendModelTransportConfig type.
|
|
1313
1323
|
*/
|