@warp-drive/core 5.6.0-beta.0 → 5.6.0-beta.2
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/declarations/graph/-private/-diff.d.ts +7 -20
- package/declarations/graph/-private/-edge-definition.d.ts +3 -12
- package/declarations/graph/-private/-state.d.ts +2 -2
- package/declarations/graph/-private/-utils.d.ts +5 -5
- package/declarations/graph/-private/debug/assert-polymorphic-type.d.ts +3 -3
- package/declarations/graph/-private/edges/collection.d.ts +10 -10
- package/declarations/graph/-private/edges/implicit.d.ts +5 -5
- package/declarations/graph/-private/edges/resource.d.ts +6 -7
- package/declarations/graph/-private/graph.d.ts +17 -15
- package/declarations/graph/-private/operations/replace-related-records.d.ts +4 -4
- package/declarations/graph/-private/operations/update-relationship.d.ts +3 -3
- package/declarations/index.d.ts +1 -1
- package/declarations/reactive/-private/default-mode.d.ts +73 -0
- package/declarations/reactive/-private/document.d.ts +11 -27
- package/declarations/reactive/-private/fields/get-field-key.d.ts +8 -0
- package/declarations/reactive/-private/fields/managed-array.d.ts +7 -10
- package/declarations/reactive/-private/fields/managed-object.d.ts +7 -9
- package/declarations/reactive/-private/fields/many-array-manager.d.ts +2 -2
- package/declarations/reactive/-private/hooks.d.ts +2 -2
- package/declarations/reactive/-private/kind/alias-field.d.ts +4 -0
- package/declarations/reactive/-private/kind/array-field.d.ts +4 -0
- package/declarations/reactive/-private/kind/attribute-field.d.ts +4 -0
- package/declarations/reactive/-private/kind/belongs-to-field.d.ts +4 -0
- package/declarations/reactive/-private/kind/collection-field.d.ts +4 -0
- package/declarations/reactive/-private/kind/derived-field.d.ts +4 -0
- package/declarations/reactive/-private/kind/generic-field.d.ts +4 -0
- package/declarations/reactive/-private/kind/has-many-field.d.ts +4 -0
- package/declarations/reactive/-private/kind/hash-field.d.ts +4 -0
- package/declarations/reactive/-private/kind/identity-field.d.ts +4 -0
- package/declarations/reactive/-private/kind/local-field.d.ts +4 -0
- package/declarations/reactive/-private/kind/object-field.d.ts +4 -0
- package/declarations/reactive/-private/kind/resource-field.d.ts +4 -0
- package/declarations/reactive/-private/kind/schema-array-field.d.ts +4 -0
- package/declarations/reactive/-private/kind/schema-object-field.d.ts +4 -0
- package/declarations/reactive/-private/record.d.ts +44 -33
- package/declarations/reactive/-private/schema.d.ts +50 -66
- package/declarations/reactive/-private/symbols.d.ts +2 -7
- package/declarations/reactive/-private.d.ts +1 -1
- package/declarations/reactive.d.ts +278 -1
- package/declarations/request/-private/context.d.ts +3 -5
- package/declarations/request/-private/fetch.d.ts +2 -0
- package/declarations/request/-private/manager.d.ts +24 -28
- package/declarations/request/-private/types.d.ts +22 -23
- package/declarations/request/-private/utils.d.ts +44 -2
- package/declarations/store/-private/cache-handler/handler.d.ts +2 -8
- package/declarations/store/-private/cache-handler/types.d.ts +10 -10
- package/declarations/store/-private/cache-handler/utils.d.ts +4 -4
- package/declarations/store/-private/caches/instance-cache.d.ts +22 -27
- package/declarations/store/-private/debug/utils.d.ts +1 -0
- package/declarations/store/-private/default-cache-policy.d.ts +25 -38
- package/declarations/store/-private/managers/cache-capabilities-manager.d.ts +24 -15
- package/declarations/store/-private/{caches/identifier-cache.d.ts → managers/cache-key-manager.d.ts} +38 -52
- package/declarations/store/-private/managers/cache-manager.d.ts +46 -95
- package/declarations/store/-private/managers/notification-manager.d.ts +30 -43
- package/declarations/store/-private/managers/record-array-manager.d.ts +44 -41
- package/declarations/store/-private/network/request-cache.d.ts +21 -24
- package/declarations/store/-private/new-core-tmp/expensive-subscription.d.ts +24 -0
- package/declarations/store/-private/new-core-tmp/reactivity/configure.d.ts +3 -41
- package/declarations/store/-private/new-core-tmp/reactivity/internal.d.ts +14 -29
- package/declarations/store/-private/new-core-tmp/reactivity/signal.d.ts +24 -3
- package/declarations/store/-private/new-core-tmp/request-state.d.ts +133 -37
- package/declarations/store/-private/new-core-tmp/request-subscription.d.ts +51 -133
- package/declarations/store/-private/record-arrays/-utils.d.ts +80 -0
- package/declarations/store/-private/record-arrays/legacy-live-array.d.ts +81 -0
- package/declarations/store/-private/record-arrays/legacy-many-array.d.ts +133 -0
- package/declarations/store/-private/record-arrays/legacy-query.d.ts +81 -0
- package/declarations/store/-private/record-arrays/native-proxy-type-fix.d.ts +1 -124
- package/declarations/store/-private/record-arrays/resource-array.d.ts +75 -0
- package/declarations/store/-private/store-service.d.ts +167 -872
- package/declarations/store/-private.d.ts +14 -10
- package/declarations/store/-types/q/cache-capabilities-manager.d.ts +15 -24
- package/declarations/store/-types/q/identifier.d.ts +9 -6
- package/declarations/store/-types/q/record-instance.d.ts +0 -1
- package/declarations/store/-types/q/schema-service.d.ts +64 -40
- package/declarations/store/-types/q/store.d.ts +6 -7
- package/declarations/store/deprecated/-private.d.ts +224 -0
- package/declarations/store/deprecated/store.d.ts +787 -0
- package/declarations/types/-private.d.ts +1 -1
- package/declarations/types/cache/aliases.d.ts +2 -2
- package/declarations/types/cache/change.d.ts +2 -2
- package/declarations/types/cache/mutations.d.ts +13 -13
- package/declarations/types/cache/operations.d.ts +115 -32
- package/declarations/types/cache/relationship.d.ts +4 -4
- package/declarations/types/cache.d.ts +51 -115
- package/declarations/types/graph.d.ts +12 -12
- package/declarations/types/identifier.d.ts +52 -76
- package/declarations/types/params.d.ts +2 -3
- package/declarations/types/request.d.ts +69 -42
- package/declarations/types/schema/concepts.d.ts +2 -2
- package/declarations/types/schema/fields.d.ts +391 -14
- package/declarations/types/spec/document.d.ts +6 -6
- package/declarations/types/spec/json-api-raw.d.ts +6 -8
- package/declarations/types.d.ts +2 -1
- package/declarations/utils/string.d.ts +2 -2
- package/dist/{configure-B48bFHOl.js → configure-C3x8YXzL.js} +5 -5
- package/dist/configure.js +1 -1
- package/dist/{context-COmAnXUQ.js → context-C_7OLieY.js} +48 -6
- package/dist/graph/-private.js +137 -144
- package/dist/index.js +25 -14
- package/dist/reactive/-private.js +1 -1
- package/dist/reactive.js +337 -1422
- package/dist/{request-state-CjLph1LP.js → request-state-C955e0AL.js} +8352 -5912
- package/dist/request.js +1 -1
- package/dist/store/-private.js +2 -3
- package/dist/store.js +32 -44
- package/dist/{symbols-SIstXMLI.js → symbols-sql1_mdx.js} +3 -8
- package/dist/types/-private.js +1 -1
- package/dist/types/identifier.js +19 -45
- package/dist/types/request.js +45 -3
- package/dist/types/schema/fields.js +23 -2
- package/dist/utils/string.js +2 -2
- package/package.json +10 -10
- package/declarations/reactive/-private/fields/compute.d.ts +0 -43
- package/declarations/store/-private/caches/cache-utils.d.ts +0 -12
- package/declarations/store/-private/legacy-model-support/record-reference.d.ts +0 -159
- package/declarations/store/-private/legacy-model-support/shim-model-class.d.ts +0 -17
- package/declarations/store/-private/record-arrays/identifier-array.d.ts +0 -147
- package/declarations/store/-private/record-arrays/many-array.d.ts +0 -197
- package/declarations/store/-types/q/ds-model.d.ts +0 -21
- package/dist/handler-C2T-IyJK.js +0 -339
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
import type { ObjectValue, PrimitiveValue, Value } from "../json/raw.js";
|
|
2
2
|
/**
|
|
3
|
+
* Options signature for Legacy Attributes.
|
|
4
|
+
*/
|
|
5
|
+
export interface AttrOptions {
|
|
6
|
+
/**
|
|
7
|
+
* A primitive value or a function which produces a value.
|
|
8
|
+
*/
|
|
9
|
+
defaultValue?: PrimitiveValue | (() => Value);
|
|
10
|
+
[key: string]: Value | (() => Value) | undefined;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
3
13
|
* A generic "field" that can be used to define
|
|
4
14
|
* primitive value fields.
|
|
5
15
|
*
|
|
@@ -29,7 +39,30 @@ export interface GenericField {
|
|
|
29
39
|
*/
|
|
30
40
|
name: string;
|
|
31
41
|
/**
|
|
32
|
-
*
|
|
42
|
+
* The name of the field as returned by the API
|
|
43
|
+
* and inserted into the {@link Cache} if it differs
|
|
44
|
+
* from {@link GenericField.name}
|
|
45
|
+
*
|
|
46
|
+
* For instance, if the API returns:
|
|
47
|
+
*
|
|
48
|
+
* ```ts
|
|
49
|
+
* {
|
|
50
|
+
* attributes: {
|
|
51
|
+
* 'first-name': 'Chris'
|
|
52
|
+
* }
|
|
53
|
+
* }
|
|
54
|
+
* ```
|
|
55
|
+
*
|
|
56
|
+
* But the app desires to use `record.firstName; // 'Chris'`
|
|
57
|
+
*
|
|
58
|
+
* Then `name` would be set to `'firstName'` and
|
|
59
|
+
* `sourceKey` would be set to `'first-name'`.
|
|
60
|
+
*
|
|
61
|
+
* This option is only needed when the value differs from name.
|
|
62
|
+
*/
|
|
63
|
+
sourceKey?: string;
|
|
64
|
+
/**
|
|
65
|
+
* the name of the {@link Transformation} to use, if any
|
|
33
66
|
*
|
|
34
67
|
* @public
|
|
35
68
|
*/
|
|
@@ -234,6 +267,27 @@ export interface IdentityField {
|
|
|
234
267
|
* @public
|
|
235
268
|
*/
|
|
236
269
|
name: string;
|
|
270
|
+
/**
|
|
271
|
+
* The name of the field as returned by the API
|
|
272
|
+
* and inserted into the {@link Cache} if it differs
|
|
273
|
+
* from {@link IdentityField.name}
|
|
274
|
+
*
|
|
275
|
+
* For instance, if the API returns:
|
|
276
|
+
*
|
|
277
|
+
* ```ts
|
|
278
|
+
* {
|
|
279
|
+
* entityUrn: '324523-sadf34-345'
|
|
280
|
+
* }
|
|
281
|
+
* ```
|
|
282
|
+
*
|
|
283
|
+
* But the app desires to use `record.id; // '324523-sadf34-345'`
|
|
284
|
+
*
|
|
285
|
+
* Then `name` would be set to `'id'` and
|
|
286
|
+
* `sourceKey` would be set to `'entityUrn'`.
|
|
287
|
+
*
|
|
288
|
+
* This option is only needed when the value differs from name.
|
|
289
|
+
*/
|
|
290
|
+
sourceKey?: string;
|
|
237
291
|
}
|
|
238
292
|
/**
|
|
239
293
|
* Represents a specialized field whose computed value
|
|
@@ -250,7 +304,7 @@ export interface IdentityField {
|
|
|
250
304
|
* perform those itself.
|
|
251
305
|
*
|
|
252
306
|
* A schema-array can declare its "key" value to be `@hash` if
|
|
253
|
-
*
|
|
307
|
+
* the schema-objects it contains have such a field.
|
|
254
308
|
*
|
|
255
309
|
* Only one hash field is permittable per schema-object, and
|
|
256
310
|
* it should be placed in the `ResourceSchema`'s `@id` field
|
|
@@ -374,6 +428,29 @@ export interface ObjectField {
|
|
|
374
428
|
*/
|
|
375
429
|
name: string;
|
|
376
430
|
/**
|
|
431
|
+
* The name of the field as returned by the API
|
|
432
|
+
* and inserted into the {@link Cache} if it differs
|
|
433
|
+
* from {@link ObjectField.name}
|
|
434
|
+
*
|
|
435
|
+
* For instance, if the API returns:
|
|
436
|
+
*
|
|
437
|
+
* ```ts
|
|
438
|
+
* {
|
|
439
|
+
* attributes: {
|
|
440
|
+
* 'first-name': 'Chris'
|
|
441
|
+
* }
|
|
442
|
+
* }
|
|
443
|
+
* ```
|
|
444
|
+
*
|
|
445
|
+
* But the app desires to use `record.firstName; // 'Chris'`
|
|
446
|
+
*
|
|
447
|
+
* Then `name` would be set to `'firstName'` and
|
|
448
|
+
* `sourceKey` would be set to `'first-name'`.
|
|
449
|
+
*
|
|
450
|
+
* This option is only needed when the value differs from name.
|
|
451
|
+
*/
|
|
452
|
+
sourceKey?: string;
|
|
453
|
+
/**
|
|
377
454
|
* The name of a transform to pass the entire object
|
|
378
455
|
* through before displaying or serializing it.
|
|
379
456
|
*
|
|
@@ -396,7 +473,7 @@ export interface ObjectField {
|
|
|
396
473
|
* Configures which extensions this object should use.
|
|
397
474
|
*
|
|
398
475
|
* Extensions are registered with the store's schema service
|
|
399
|
-
* via {@link SchemaService.
|
|
476
|
+
* via {@link SchemaService.CAUTION_MEGA_DANGER_ZONE_registerExtension}
|
|
400
477
|
*
|
|
401
478
|
* Extensions should only be used for temporary enhancements
|
|
402
479
|
* to objects to support migrating away from deprecated patterns
|
|
@@ -409,11 +486,13 @@ export interface ObjectField {
|
|
|
409
486
|
/**
|
|
410
487
|
* Represents a field whose value is an object
|
|
411
488
|
* with a well-defined structure described by
|
|
412
|
-
* a non-resource schema.
|
|
489
|
+
* a schema-object (a non-resource schema).
|
|
413
490
|
*
|
|
414
491
|
* If the object's structure is not well-defined,
|
|
415
492
|
* use 'object' instead.
|
|
416
493
|
*
|
|
494
|
+
* By default, a SchemaObject within
|
|
495
|
+
*
|
|
417
496
|
* @public
|
|
418
497
|
*/
|
|
419
498
|
export interface SchemaObjectField {
|
|
@@ -430,12 +509,42 @@ export interface SchemaObjectField {
|
|
|
430
509
|
*/
|
|
431
510
|
name: string;
|
|
432
511
|
/**
|
|
512
|
+
* The name of the field as returned by the API
|
|
513
|
+
* and inserted into the {@link Cache} if it differs
|
|
514
|
+
* from {@link SchemaObjectField.name}
|
|
515
|
+
*
|
|
516
|
+
* For instance, if the API returns:
|
|
517
|
+
*
|
|
518
|
+
* ```ts
|
|
519
|
+
* {
|
|
520
|
+
* attributes: {
|
|
521
|
+
* 'first-name': 'Chris'
|
|
522
|
+
* }
|
|
523
|
+
* }
|
|
524
|
+
* ```
|
|
525
|
+
*
|
|
526
|
+
* But the app desires to use `record.firstName; // 'Chris'`
|
|
527
|
+
*
|
|
528
|
+
* Then `name` would be set to `'firstName'` and
|
|
529
|
+
* `sourceKey` would be set to `'first-name'`.
|
|
530
|
+
*
|
|
531
|
+
* This option is only needed when the value differs from name.
|
|
532
|
+
*/
|
|
533
|
+
sourceKey?: string;
|
|
534
|
+
/**
|
|
535
|
+
* If the field is not polymorphic:
|
|
536
|
+
*
|
|
433
537
|
* The name of the ObjectSchema that describes the
|
|
434
538
|
* structure of the object.
|
|
435
539
|
*
|
|
540
|
+
* If the field is polymorphic:
|
|
541
|
+
*
|
|
542
|
+
* The name of the hashFn to use to extract
|
|
543
|
+
* the type from the contained value or null.
|
|
544
|
+
*
|
|
436
545
|
* @public
|
|
437
546
|
*/
|
|
438
|
-
type: string;
|
|
547
|
+
type: string | null;
|
|
439
548
|
/**
|
|
440
549
|
* Options for configuring the behavior of the
|
|
441
550
|
* SchemaObject.
|
|
@@ -446,6 +555,15 @@ export interface SchemaObjectField {
|
|
|
446
555
|
* @public
|
|
447
556
|
*/
|
|
448
557
|
options?: {
|
|
558
|
+
/**
|
|
559
|
+
* If true, if no value for this field exists in the cache,
|
|
560
|
+
* an empty `{}` will be used as the source for a new SchemaObject
|
|
561
|
+
* of the associated schema type, as opposed to the field's
|
|
562
|
+
* value being `null`.
|
|
563
|
+
*
|
|
564
|
+
* If `polymorphic` is `true`, defaultValue will be considered `false`.
|
|
565
|
+
*/
|
|
566
|
+
defaultValue?: boolean;
|
|
449
567
|
/**
|
|
450
568
|
* ::: warning ⚠️ Dangerous Feature Ahead
|
|
451
569
|
* :::
|
|
@@ -472,7 +590,15 @@ export interface SchemaObjectField {
|
|
|
472
590
|
* If the SchemaObject is Polymorphic, the key on the raw cache data to use
|
|
473
591
|
* as the "resource-type" value for the schema-object.
|
|
474
592
|
*
|
|
475
|
-
*
|
|
593
|
+
* The default is `'type'`.
|
|
594
|
+
*
|
|
595
|
+
* Valid options are:
|
|
596
|
+
*
|
|
597
|
+
* - `'@hash'` : will lookup the `@hash` function specified by
|
|
598
|
+
* SchemaObjectField.type and use it to calculate the type for each value.
|
|
599
|
+
* - \<field-name> (string) : the name of a field to use as the key, only GenericFields (kind `field`)
|
|
600
|
+
* Are valid field names for this purpose. The cache state without transforms applied will be
|
|
601
|
+
* used when comparing values.
|
|
476
602
|
*
|
|
477
603
|
* @public
|
|
478
604
|
*/
|
|
@@ -502,6 +628,29 @@ export interface ArrayField {
|
|
|
502
628
|
*/
|
|
503
629
|
name: string;
|
|
504
630
|
/**
|
|
631
|
+
* The name of the field as returned by the API
|
|
632
|
+
* and inserted into the {@link Cache} if it differs
|
|
633
|
+
* from {@link ArrayField.name}
|
|
634
|
+
*
|
|
635
|
+
* For instance, if the API returns:
|
|
636
|
+
*
|
|
637
|
+
* ```ts
|
|
638
|
+
* {
|
|
639
|
+
* attributes: {
|
|
640
|
+
* 'first-name': 'Chris'
|
|
641
|
+
* }
|
|
642
|
+
* }
|
|
643
|
+
* ```
|
|
644
|
+
*
|
|
645
|
+
* But the app desires to use `record.firstName; // 'Chris'`
|
|
646
|
+
*
|
|
647
|
+
* Then `name` would be set to `'firstName'` and
|
|
648
|
+
* `sourceKey` would be set to `'first-name'`.
|
|
649
|
+
*
|
|
650
|
+
* This option is only needed when the value differs from name.
|
|
651
|
+
*/
|
|
652
|
+
sourceKey?: string;
|
|
653
|
+
/**
|
|
505
654
|
* The name of a transform to pass each item
|
|
506
655
|
* in the array through before displaying or
|
|
507
656
|
* or serializing it.
|
|
@@ -558,12 +707,42 @@ export interface SchemaArrayField {
|
|
|
558
707
|
*/
|
|
559
708
|
name: string;
|
|
560
709
|
/**
|
|
710
|
+
* The name of the field as returned by the API
|
|
711
|
+
* and inserted into the {@link Cache} if it differs
|
|
712
|
+
* from {@link SchemaArrayField.name}
|
|
713
|
+
*
|
|
714
|
+
* For instance, if the API returns:
|
|
715
|
+
*
|
|
716
|
+
* ```ts
|
|
717
|
+
* {
|
|
718
|
+
* attributes: {
|
|
719
|
+
* 'first-name': 'Chris'
|
|
720
|
+
* }
|
|
721
|
+
* }
|
|
722
|
+
* ```
|
|
723
|
+
*
|
|
724
|
+
* But the app desires to use `record.firstName; // 'Chris'`
|
|
725
|
+
*
|
|
726
|
+
* Then `name` would be set to `'firstName'` and
|
|
727
|
+
* `sourceKey` would be set to `'first-name'`.
|
|
728
|
+
*
|
|
729
|
+
* This option is only needed when the value differs from name.
|
|
730
|
+
*/
|
|
731
|
+
sourceKey?: string;
|
|
732
|
+
/**
|
|
733
|
+
* If the SchemaArray is not polymorphic:
|
|
734
|
+
*
|
|
561
735
|
* The name of the ObjectSchema that describes the
|
|
562
736
|
* structure of the objects in the array.
|
|
563
737
|
*
|
|
738
|
+
* If the SchemaArray is polymorphic:
|
|
739
|
+
*
|
|
740
|
+
* The name of the hashFn to use to extract
|
|
741
|
+
* the type from contained members or null.
|
|
742
|
+
*
|
|
564
743
|
* @public
|
|
565
744
|
*/
|
|
566
|
-
type: string;
|
|
745
|
+
type: string | null;
|
|
567
746
|
/**
|
|
568
747
|
* Options for configuring the behavior of the
|
|
569
748
|
* SchemaArray.
|
|
@@ -577,13 +756,13 @@ export interface SchemaArrayField {
|
|
|
577
756
|
*
|
|
578
757
|
* Valid options are:
|
|
579
758
|
*
|
|
580
|
-
* - `'@identity'`
|
|
759
|
+
* - `'@identity'`(default) : the cached object's referential identity will be used.
|
|
581
760
|
* This may result in significant instability when resource data is updated from the API
|
|
582
761
|
* - `'@index'` : the cached object's index in the array will be used.
|
|
583
762
|
* This is only a good choice for arrays that rarely if ever change membership
|
|
584
763
|
* - `'@hash'` : will lookup the `@hash` function supplied in the ResourceSchema for
|
|
585
764
|
* The contained schema-object and use the computed result to determine and compare identity.
|
|
586
|
-
* - \<field-name> (string)
|
|
765
|
+
* - \<field-name> (string) : the name of a field to use as the key, only GenericFields (kind `field`)
|
|
587
766
|
* Are valid field names for this purpose. The cache state without transforms applied will be
|
|
588
767
|
* used when comparing values. The field value should be unique enough to guarantee two schema-objects
|
|
589
768
|
* of the same type will not collide.
|
|
@@ -594,6 +773,13 @@ export interface SchemaArrayField {
|
|
|
594
773
|
* @public
|
|
595
774
|
*/
|
|
596
775
|
options?: {
|
|
776
|
+
/**
|
|
777
|
+
* If true, if no value for this field exists in the cache,
|
|
778
|
+
* an empty `[]` will be used as the value of the field,
|
|
779
|
+
* as opposed to the field's value being `null`.
|
|
780
|
+
*
|
|
781
|
+
*/
|
|
782
|
+
defaultValue?: boolean;
|
|
597
783
|
/**
|
|
598
784
|
* ::: warning ⚠️ Dangerous Feature Ahead
|
|
599
785
|
* :::
|
|
@@ -655,8 +841,15 @@ export interface SchemaArrayField {
|
|
|
655
841
|
* If the SchemaArray is Polymorphic, the key on the raw cache data to use
|
|
656
842
|
* as the "resource-type" value for the schema-object.
|
|
657
843
|
*
|
|
658
|
-
*
|
|
844
|
+
* The default is `'type'`.
|
|
659
845
|
*
|
|
846
|
+
* Valid options are:
|
|
847
|
+
*
|
|
848
|
+
* - `'@hash'` : will lookup the `@hash` function specified by
|
|
849
|
+
* SchemaArrayField.type and use it to calculate the type for each value.
|
|
850
|
+
* - \<field-name> (string) : the name of a field to use as the key, only GenericFields (kind `field`)
|
|
851
|
+
* Are valid field names for this purpose. The cache state without transforms applied will be
|
|
852
|
+
* used when comparing values.
|
|
660
853
|
*/
|
|
661
854
|
type?: string;
|
|
662
855
|
};
|
|
@@ -743,6 +936,29 @@ export interface ResourceField {
|
|
|
743
936
|
*/
|
|
744
937
|
name: string;
|
|
745
938
|
/**
|
|
939
|
+
* The name of the field as returned by the API
|
|
940
|
+
* and inserted into the {@link Cache} if it differs
|
|
941
|
+
* from {@link ResourceField.name}
|
|
942
|
+
*
|
|
943
|
+
* For instance, if the API returns:
|
|
944
|
+
*
|
|
945
|
+
* ```ts
|
|
946
|
+
* {
|
|
947
|
+
* attributes: {
|
|
948
|
+
* 'first-name': 'Chris'
|
|
949
|
+
* }
|
|
950
|
+
* }
|
|
951
|
+
* ```
|
|
952
|
+
*
|
|
953
|
+
* But the app desires to use `record.firstName; // 'Chris'`
|
|
954
|
+
*
|
|
955
|
+
* Then `name` would be set to `'firstName'` and
|
|
956
|
+
* `sourceKey` would be set to `'first-name'`.
|
|
957
|
+
*
|
|
958
|
+
* This option is only needed when the value differs from name.
|
|
959
|
+
*/
|
|
960
|
+
sourceKey?: string;
|
|
961
|
+
/**
|
|
746
962
|
* The name of the resource that this field
|
|
747
963
|
* refers to. In the case of a polymorphic
|
|
748
964
|
* relationship, this should be the trait
|
|
@@ -825,6 +1041,29 @@ export interface CollectionField {
|
|
|
825
1041
|
*/
|
|
826
1042
|
name: string;
|
|
827
1043
|
/**
|
|
1044
|
+
* The name of the field as returned by the API
|
|
1045
|
+
* and inserted into the {@link Cache} if it differs
|
|
1046
|
+
* from {@link CollectionField.name}
|
|
1047
|
+
*
|
|
1048
|
+
* For instance, if the API returns:
|
|
1049
|
+
*
|
|
1050
|
+
* ```ts
|
|
1051
|
+
* {
|
|
1052
|
+
* attributes: {
|
|
1053
|
+
* 'first-name': 'Chris'
|
|
1054
|
+
* }
|
|
1055
|
+
* }
|
|
1056
|
+
* ```
|
|
1057
|
+
*
|
|
1058
|
+
* But the app desires to use `record.firstName; // 'Chris'`
|
|
1059
|
+
*
|
|
1060
|
+
* Then `name` would be set to `'firstName'` and
|
|
1061
|
+
* `sourceKey` would be set to `'first-name'`.
|
|
1062
|
+
*
|
|
1063
|
+
* This option is only needed when the value differs from name.
|
|
1064
|
+
*/
|
|
1065
|
+
sourceKey?: string;
|
|
1066
|
+
/**
|
|
828
1067
|
* The name of the resource that this field
|
|
829
1068
|
* refers to. In the case of a polymorphic
|
|
830
1069
|
* relationship, this should be the trait
|
|
@@ -925,6 +1164,29 @@ export interface LegacyAttributeField {
|
|
|
925
1164
|
*/
|
|
926
1165
|
name: string;
|
|
927
1166
|
/**
|
|
1167
|
+
* The name of the field as returned by the API
|
|
1168
|
+
* and inserted into the {@link Cache} if it differs
|
|
1169
|
+
* from {@link LegacyAttributeField.name}
|
|
1170
|
+
*
|
|
1171
|
+
* For instance, if the API returns:
|
|
1172
|
+
*
|
|
1173
|
+
* ```ts
|
|
1174
|
+
* {
|
|
1175
|
+
* attributes: {
|
|
1176
|
+
* 'first-name': 'Chris'
|
|
1177
|
+
* }
|
|
1178
|
+
* }
|
|
1179
|
+
* ```
|
|
1180
|
+
*
|
|
1181
|
+
* But the app desires to use `record.firstName; // 'Chris'`
|
|
1182
|
+
*
|
|
1183
|
+
* Then `name` would be set to `'firstName'` and
|
|
1184
|
+
* `sourceKey` would be set to `'first-name'`.
|
|
1185
|
+
*
|
|
1186
|
+
* This option is only needed when the value differs from name.
|
|
1187
|
+
*/
|
|
1188
|
+
sourceKey?: string;
|
|
1189
|
+
/**
|
|
928
1190
|
* The name of the transform to use, if any
|
|
929
1191
|
*
|
|
930
1192
|
* @public
|
|
@@ -936,8 +1198,9 @@ export interface LegacyAttributeField {
|
|
|
936
1198
|
* Must comply to the specific transform's options
|
|
937
1199
|
* schema.
|
|
938
1200
|
*
|
|
1201
|
+
* See {@link AttrOptions} for more info.
|
|
939
1202
|
*/
|
|
940
|
-
options?:
|
|
1203
|
+
options?: AttrOptions;
|
|
941
1204
|
}
|
|
942
1205
|
/**
|
|
943
1206
|
* > [!CAUTION]
|
|
@@ -964,6 +1227,29 @@ export interface LegacyBelongsToField {
|
|
|
964
1227
|
*/
|
|
965
1228
|
name: string;
|
|
966
1229
|
/**
|
|
1230
|
+
* The name of the field as returned by the API
|
|
1231
|
+
* and inserted into the {@link Cache} if it differs
|
|
1232
|
+
* from {@link LegacyBelongsToField.name}
|
|
1233
|
+
*
|
|
1234
|
+
* For instance, if the API returns:
|
|
1235
|
+
*
|
|
1236
|
+
* ```ts
|
|
1237
|
+
* {
|
|
1238
|
+
* attributes: {
|
|
1239
|
+
* 'first-name': 'Chris'
|
|
1240
|
+
* }
|
|
1241
|
+
* }
|
|
1242
|
+
* ```
|
|
1243
|
+
*
|
|
1244
|
+
* But the app desires to use `record.firstName; // 'Chris'`
|
|
1245
|
+
*
|
|
1246
|
+
* Then `name` would be set to `'firstName'` and
|
|
1247
|
+
* `sourceKey` would be set to `'first-name'`.
|
|
1248
|
+
*
|
|
1249
|
+
* This option is only needed when the value differs from name.
|
|
1250
|
+
*/
|
|
1251
|
+
sourceKey?: string;
|
|
1252
|
+
/**
|
|
967
1253
|
* The name of the resource that this field
|
|
968
1254
|
* refers to. In the case of a polymorphic
|
|
969
1255
|
* relationship, this should be the trait
|
|
@@ -1094,6 +1380,29 @@ export interface LinksModeBelongsToField {
|
|
|
1094
1380
|
*/
|
|
1095
1381
|
name: string;
|
|
1096
1382
|
/**
|
|
1383
|
+
* The name of the field as returned by the API
|
|
1384
|
+
* and inserted into the {@link Cache} if it differs
|
|
1385
|
+
* from {@link LinksModeBelongsToField.name}
|
|
1386
|
+
*
|
|
1387
|
+
* For instance, if the API returns:
|
|
1388
|
+
*
|
|
1389
|
+
* ```ts
|
|
1390
|
+
* {
|
|
1391
|
+
* attributes: {
|
|
1392
|
+
* 'first-name': 'Chris'
|
|
1393
|
+
* }
|
|
1394
|
+
* }
|
|
1395
|
+
* ```
|
|
1396
|
+
*
|
|
1397
|
+
* But the app desires to use `record.firstName; // 'Chris'`
|
|
1398
|
+
*
|
|
1399
|
+
* Then `name` would be set to `'firstName'` and
|
|
1400
|
+
* `sourceKey` would be set to `'first-name'`.
|
|
1401
|
+
*
|
|
1402
|
+
* This option is only needed when the value differs from name.
|
|
1403
|
+
*/
|
|
1404
|
+
sourceKey?: string;
|
|
1405
|
+
/**
|
|
1097
1406
|
* The name of the resource that this field
|
|
1098
1407
|
* refers to. In the case of a polymorphic
|
|
1099
1408
|
* relationship, this should be the trait
|
|
@@ -1219,6 +1528,29 @@ export interface LegacyHasManyField {
|
|
|
1219
1528
|
*/
|
|
1220
1529
|
name: string;
|
|
1221
1530
|
/**
|
|
1531
|
+
* The name of the field as returned by the API
|
|
1532
|
+
* and inserted into the {@link Cache} if it differs
|
|
1533
|
+
* from {@link LegacyHasManyField.name}
|
|
1534
|
+
*
|
|
1535
|
+
* For instance, if the API returns:
|
|
1536
|
+
*
|
|
1537
|
+
* ```ts
|
|
1538
|
+
* {
|
|
1539
|
+
* attributes: {
|
|
1540
|
+
* 'first-name': 'Chris'
|
|
1541
|
+
* }
|
|
1542
|
+
* }
|
|
1543
|
+
* ```
|
|
1544
|
+
*
|
|
1545
|
+
* But the app desires to use `record.firstName; // 'Chris'`
|
|
1546
|
+
*
|
|
1547
|
+
* Then `name` would be set to `'firstName'` and
|
|
1548
|
+
* `sourceKey` would be set to `'first-name'`.
|
|
1549
|
+
*
|
|
1550
|
+
* This option is only needed when the value differs from name.
|
|
1551
|
+
*/
|
|
1552
|
+
sourceKey?: string;
|
|
1553
|
+
/**
|
|
1222
1554
|
* the name of the resource that this field
|
|
1223
1555
|
* refers to. In the case of a polymorphic
|
|
1224
1556
|
* relationship, this should be the trait
|
|
@@ -1367,6 +1699,29 @@ export interface LinksModeHasManyField {
|
|
|
1367
1699
|
*/
|
|
1368
1700
|
name: string;
|
|
1369
1701
|
/**
|
|
1702
|
+
* The name of the field as returned by the API
|
|
1703
|
+
* and inserted into the {@link Cache} if it differs
|
|
1704
|
+
* from {@link LinksModeHasManyField.name}
|
|
1705
|
+
*
|
|
1706
|
+
* For instance, if the API returns:
|
|
1707
|
+
*
|
|
1708
|
+
* ```ts
|
|
1709
|
+
* {
|
|
1710
|
+
* attributes: {
|
|
1711
|
+
* 'first-name': 'Chris'
|
|
1712
|
+
* }
|
|
1713
|
+
* }
|
|
1714
|
+
* ```
|
|
1715
|
+
*
|
|
1716
|
+
* But the app desires to use `record.firstName; // 'Chris'`
|
|
1717
|
+
*
|
|
1718
|
+
* Then `name` would be set to `'firstName'` and
|
|
1719
|
+
* `sourceKey` would be set to `'first-name'`.
|
|
1720
|
+
*
|
|
1721
|
+
* This option is only needed when the value differs from name.
|
|
1722
|
+
*/
|
|
1723
|
+
sourceKey?: string;
|
|
1724
|
+
/**
|
|
1370
1725
|
* the name of the resource that this field
|
|
1371
1726
|
* refers to. In the case of a polymorphic
|
|
1372
1727
|
* relationship, this should be the trait
|
|
@@ -1548,12 +1903,23 @@ export type PolarisModeFieldSchema = GenericField | PolarisAliasField | LocalFie
|
|
|
1548
1903
|
*/
|
|
1549
1904
|
export type FieldSchema = GenericField | LegacyAliasField | PolarisAliasField | LocalField | ObjectField | SchemaObjectField | ArrayField | SchemaArrayField | DerivedField | ResourceField | CollectionField | LegacyAttributeField | LegacyBelongsToField | LegacyHasManyField | LinksModeBelongsToField | LinksModeHasManyField;
|
|
1550
1905
|
/**
|
|
1906
|
+
* A union of all possible LegacyMode and PolarisMode
|
|
1907
|
+
* field schemas that represent data that could be in
|
|
1908
|
+
* the cache.
|
|
1909
|
+
*
|
|
1910
|
+
* In other words this will not include types like alias
|
|
1911
|
+
* fields, local fields, or derived fields.
|
|
1912
|
+
*
|
|
1913
|
+
* @public
|
|
1914
|
+
*/
|
|
1915
|
+
export type CacheableFieldSchema = IdentityField | GenericField | ObjectField | SchemaObjectField | ArrayField | SchemaArrayField | ResourceField | CollectionField | LegacyAttributeField | LegacyBelongsToField | LegacyHasManyField | LinksModeBelongsToField | LinksModeHasManyField;
|
|
1916
|
+
/**
|
|
1551
1917
|
* A union of all possible field schemas that can be
|
|
1552
1918
|
* used in an ObjectSchema.
|
|
1553
1919
|
*
|
|
1554
1920
|
* @public
|
|
1555
1921
|
*/
|
|
1556
|
-
export type ObjectFieldSchema = GenericField | ObjectAliasField | LocalField | ObjectField | SchemaObjectField | ArrayField | SchemaArrayField | DerivedField;
|
|
1922
|
+
export type ObjectFieldSchema = LegacyAttributeField | GenericField | ObjectAliasField | LocalField | ObjectField | SchemaObjectField | ArrayField | SchemaArrayField | DerivedField;
|
|
1557
1923
|
/**
|
|
1558
1924
|
* Represents a schema for a primary resource in PolarisMode.
|
|
1559
1925
|
*
|
|
@@ -1570,8 +1936,6 @@ export interface PolarisResourceSchema {
|
|
|
1570
1936
|
*
|
|
1571
1937
|
* for schema-objects, this should be either a HashField or null
|
|
1572
1938
|
*
|
|
1573
|
-
* @property identity
|
|
1574
|
-
* @type {IdentityField}
|
|
1575
1939
|
* @public
|
|
1576
1940
|
*/
|
|
1577
1941
|
identity: IdentityField;
|
|
@@ -1761,6 +2125,19 @@ export interface ObjectSchema {
|
|
|
1761
2125
|
objectExtensions?: string[];
|
|
1762
2126
|
}
|
|
1763
2127
|
export type Schema = ResourceSchema | ObjectSchema;
|
|
2128
|
+
export interface PolarisTrait {
|
|
2129
|
+
name: string;
|
|
2130
|
+
mode: "polaris";
|
|
2131
|
+
fields: PolarisModeFieldSchema[];
|
|
2132
|
+
traits?: string[];
|
|
2133
|
+
}
|
|
2134
|
+
export interface LegacyTrait {
|
|
2135
|
+
name: string;
|
|
2136
|
+
mode: "legacy";
|
|
2137
|
+
fields: LegacyModeFieldSchema[];
|
|
2138
|
+
traits?: string[];
|
|
2139
|
+
}
|
|
2140
|
+
export type Trait = LegacyTrait | PolarisTrait;
|
|
1764
2141
|
/**
|
|
1765
2142
|
* A no-op type utility that enables type-checking resource schema
|
|
1766
2143
|
* definitions.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { PersistedResourceKey } from "../identifier.js";
|
|
2
2
|
import type { ApiError } from "./error.js";
|
|
3
3
|
import type { Links, Meta, PaginationLinks } from "./json-api-raw.js";
|
|
4
4
|
export interface ResourceMetaDocument {
|
|
@@ -8,8 +8,8 @@ export interface ResourceMetaDocument {
|
|
|
8
8
|
links?: Links | PaginationLinks;
|
|
9
9
|
}
|
|
10
10
|
export interface SingleResourceDataDocument<
|
|
11
|
-
T =
|
|
12
|
-
R =
|
|
11
|
+
T = PersistedResourceKey,
|
|
12
|
+
R = PersistedResourceKey
|
|
13
13
|
> {
|
|
14
14
|
// the url or cache-key associated with the structured document
|
|
15
15
|
lid?: string;
|
|
@@ -18,7 +18,7 @@ export interface SingleResourceDataDocument<
|
|
|
18
18
|
data: T | null;
|
|
19
19
|
included?: R[];
|
|
20
20
|
}
|
|
21
|
-
export interface CollectionResourceDataDocument<T =
|
|
21
|
+
export interface CollectionResourceDataDocument<T = PersistedResourceKey> {
|
|
22
22
|
// the url or cache-key associated with the structured document
|
|
23
23
|
lid?: string;
|
|
24
24
|
links?: Links | PaginationLinks;
|
|
@@ -26,7 +26,7 @@ export interface CollectionResourceDataDocument<T = StableExistingRecordIdentifi
|
|
|
26
26
|
data: T[];
|
|
27
27
|
included?: T[];
|
|
28
28
|
}
|
|
29
|
-
export type ResourceDataDocument<T =
|
|
29
|
+
export type ResourceDataDocument<T = PersistedResourceKey> = SingleResourceDataDocument<T> | CollectionResourceDataDocument<T>;
|
|
30
30
|
export interface ResourceErrorDocument {
|
|
31
31
|
// the url or cache-key associated with the structured document
|
|
32
32
|
lid?: string;
|
|
@@ -34,4 +34,4 @@ export interface ResourceErrorDocument {
|
|
|
34
34
|
meta?: Meta;
|
|
35
35
|
errors: ApiError[];
|
|
36
36
|
}
|
|
37
|
-
export type ResourceDocument<T =
|
|
37
|
+
export type ResourceDocument<T = PersistedResourceKey> = ResourceMetaDocument | SingleResourceDataDocument<T> | CollectionResourceDataDocument<T> | ResourceErrorDocument;
|
|
@@ -23,7 +23,8 @@ export interface PaginationLinks extends Links {
|
|
|
23
23
|
* to address data that may not be available synchronously.
|
|
24
24
|
*
|
|
25
25
|
* [JSON:API Spec](https://jsonapi.org/format/#document-resource-identifier-objects)
|
|
26
|
-
*
|
|
26
|
+
*
|
|
27
|
+
* @private
|
|
27
28
|
*/
|
|
28
29
|
export interface ExistingResourceIdentifierObject<T extends string = string> {
|
|
29
30
|
id: string;
|
|
@@ -42,7 +43,7 @@ export interface ExistingResourceIdentifierObject<T extends string = string> {
|
|
|
42
43
|
* is `lid` considered optional.
|
|
43
44
|
*
|
|
44
45
|
* [Identifiers RFC](https://github.com/emberjs/rfcs/blob/main/text/0403-ember-data-identifiers.md#ember-data--identifiers)
|
|
45
|
-
*
|
|
46
|
+
*
|
|
46
47
|
*/
|
|
47
48
|
lid?: string;
|
|
48
49
|
/**
|
|
@@ -50,7 +51,7 @@ export interface ExistingResourceIdentifierObject<T extends string = string> {
|
|
|
50
51
|
* `ember-data` ignores `meta` on `ResourceIdentifierObjects`
|
|
51
52
|
*
|
|
52
53
|
* @ignored this property goes un-utilized and will be lost
|
|
53
|
-
* @
|
|
54
|
+
* @private
|
|
54
55
|
*/
|
|
55
56
|
meta?: Meta;
|
|
56
57
|
}
|
|
@@ -58,7 +59,7 @@ export interface ExistingResourceIdentifierObject<T extends string = string> {
|
|
|
58
59
|
* Serves as a reference to a resource created on the client
|
|
59
60
|
* but not yet persisted.
|
|
60
61
|
*
|
|
61
|
-
* @
|
|
62
|
+
* @private
|
|
62
63
|
*/
|
|
63
64
|
export interface NewResourceIdentifierObject<T extends string = string> {
|
|
64
65
|
/**
|
|
@@ -68,14 +69,12 @@ export interface NewResourceIdentifierObject<T extends string = string> {
|
|
|
68
69
|
*
|
|
69
70
|
* `id` will be `null` in this case.
|
|
70
71
|
*
|
|
71
|
-
* @internal
|
|
72
72
|
*/
|
|
73
73
|
id: string | null;
|
|
74
74
|
type: T;
|
|
75
75
|
/**
|
|
76
76
|
* Resources newly created on the client _will always_
|
|
77
77
|
* have an `lid` assigned immediately and available.
|
|
78
|
-
* @internal
|
|
79
78
|
*/
|
|
80
79
|
lid: string;
|
|
81
80
|
}
|
|
@@ -98,7 +97,6 @@ export type InnerRelationshipDocument<T = ExistingResourceIdentifierObject | New
|
|
|
98
97
|
export type ResourceRelationshipsObject<T = ExistingResourceIdentifierObject | NewResourceIdentifierObject> = Record<string, InnerRelationshipDocument<T>>;
|
|
99
98
|
/**
|
|
100
99
|
* Contains the data for an existing resource in JSON:API format
|
|
101
|
-
* @internal
|
|
102
100
|
*/
|
|
103
101
|
export interface ExistingResourceObject<T extends string = string> extends ExistingResourceIdentifierObject<T> {
|
|
104
102
|
meta?: Meta;
|
|
@@ -136,7 +134,7 @@ export type CollectionResourceDocument<T extends string = string> = Document & {
|
|
|
136
134
|
* These documents should follow the JSON:API spec but do not
|
|
137
135
|
* have the same level of guarantees as their `spec` counterparts.
|
|
138
136
|
*
|
|
139
|
-
* @
|
|
137
|
+
* @private
|
|
140
138
|
*/
|
|
141
139
|
export type JsonApiDocument<T extends string = string> = EmptyResourceDocument | SingleResourceDocument<T> | CollectionResourceDocument<T>;
|
|
142
140
|
export {};
|