@warp-drive/core 5.7.0-alpha.3 → 5.7.0-alpha.5

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.
Files changed (34) hide show
  1. package/declarations/reactive/-private/default-mode.d.ts +73 -0
  2. package/declarations/reactive/-private/fields/get-field-key.d.ts +8 -0
  3. package/declarations/reactive/-private/fields/managed-array.d.ts +3 -5
  4. package/declarations/reactive/-private/fields/managed-object.d.ts +5 -3
  5. package/declarations/reactive/-private/kind/alias-field.d.ts +4 -0
  6. package/declarations/reactive/-private/kind/array-field.d.ts +4 -0
  7. package/declarations/reactive/-private/kind/attribute-field.d.ts +4 -0
  8. package/declarations/reactive/-private/kind/belongs-to-field.d.ts +4 -0
  9. package/declarations/reactive/-private/kind/collection-field.d.ts +4 -0
  10. package/declarations/reactive/-private/kind/derived-field.d.ts +4 -0
  11. package/declarations/reactive/-private/kind/generic-field.d.ts +4 -0
  12. package/declarations/reactive/-private/kind/has-many-field.d.ts +4 -0
  13. package/declarations/reactive/-private/kind/hash-field.d.ts +4 -0
  14. package/declarations/reactive/-private/kind/identity-field.d.ts +4 -0
  15. package/declarations/reactive/-private/kind/local-field.d.ts +4 -0
  16. package/declarations/reactive/-private/kind/object-field.d.ts +4 -0
  17. package/declarations/reactive/-private/kind/resource-field.d.ts +4 -0
  18. package/declarations/reactive/-private/kind/schema-array-field.d.ts +4 -0
  19. package/declarations/reactive/-private/kind/schema-object-field.d.ts +4 -0
  20. package/declarations/reactive/-private/record.d.ts +2 -4
  21. package/declarations/reactive/-private/schema.d.ts +6 -2
  22. package/declarations/reactive.d.ts +1 -0
  23. package/declarations/store/-types/q/schema-service.d.ts +20 -32
  24. package/declarations/types/schema/fields.d.ts +348 -11
  25. package/dist/graph/-private.js +1 -1
  26. package/dist/{handler-D2jjnIA-.js → handler-SdXlte1w.js} +1 -1
  27. package/dist/index.js +2 -2
  28. package/dist/reactive.js +1156 -584
  29. package/dist/{request-state-CejVJgdj.js → request-state-CeN66aML.js} +12 -10
  30. package/dist/store/-private.js +2 -2
  31. package/dist/types/-private.js +1 -1
  32. package/dist/types/schema/fields.js +17 -2
  33. package/package.json +3 -3
  34. package/declarations/reactive/-private/fields/compute.d.ts +0 -43
@@ -29,6 +29,29 @@ export interface GenericField {
29
29
  */
30
30
  name: string;
31
31
  /**
32
+ * The name of the field as returned by the API
33
+ * and inserted into the {@link Cache} if it differs
34
+ * from {@link GenericField.name}
35
+ *
36
+ * For instance, if the API returns:
37
+ *
38
+ * ```ts
39
+ * {
40
+ * attributes: {
41
+ * 'first-name': 'Chris'
42
+ * }
43
+ * }
44
+ * ```
45
+ *
46
+ * But the app desires to use `record.firstName; // 'Chris'`
47
+ *
48
+ * Then `name` would be set to `'firstName'` and
49
+ * `sourceKey` would be set to `'first-name'`.
50
+ *
51
+ * This option is only needed when the value differs from name.
52
+ */
53
+ sourceKey?: string;
54
+ /**
32
55
  * the name of the transform to use, if any
33
56
  *
34
57
  * @public
@@ -234,6 +257,27 @@ export interface IdentityField {
234
257
  * @public
235
258
  */
236
259
  name: string;
260
+ /**
261
+ * The name of the field as returned by the API
262
+ * and inserted into the {@link Cache} if it differs
263
+ * from {@link IdentityField.name}
264
+ *
265
+ * For instance, if the API returns:
266
+ *
267
+ * ```ts
268
+ * {
269
+ * entityUrn: '324523-sadf34-345'
270
+ * }
271
+ * ```
272
+ *
273
+ * But the app desires to use `record.id; // '324523-sadf34-345'`
274
+ *
275
+ * Then `name` would be set to `'id'` and
276
+ * `sourceKey` would be set to `'entityUrn'`.
277
+ *
278
+ * This option is only needed when the value differs from name.
279
+ */
280
+ sourceKey?: string;
237
281
  }
238
282
  /**
239
283
  * Represents a specialized field whose computed value
@@ -250,7 +294,7 @@ export interface IdentityField {
250
294
  * perform those itself.
251
295
  *
252
296
  * A schema-array can declare its "key" value to be `@hash` if
253
- * a schema-object has such a field.
297
+ * the schema-objects it contains have such a field.
254
298
  *
255
299
  * Only one hash field is permittable per schema-object, and
256
300
  * it should be placed in the `ResourceSchema`'s `@id` field
@@ -374,6 +418,29 @@ export interface ObjectField {
374
418
  */
375
419
  name: string;
376
420
  /**
421
+ * The name of the field as returned by the API
422
+ * and inserted into the {@link Cache} if it differs
423
+ * from {@link ObjectField.name}
424
+ *
425
+ * For instance, if the API returns:
426
+ *
427
+ * ```ts
428
+ * {
429
+ * attributes: {
430
+ * 'first-name': 'Chris'
431
+ * }
432
+ * }
433
+ * ```
434
+ *
435
+ * But the app desires to use `record.firstName; // 'Chris'`
436
+ *
437
+ * Then `name` would be set to `'firstName'` and
438
+ * `sourceKey` would be set to `'first-name'`.
439
+ *
440
+ * This option is only needed when the value differs from name.
441
+ */
442
+ sourceKey?: string;
443
+ /**
377
444
  * The name of a transform to pass the entire object
378
445
  * through before displaying or serializing it.
379
446
  *
@@ -409,11 +476,13 @@ export interface ObjectField {
409
476
  /**
410
477
  * Represents a field whose value is an object
411
478
  * with a well-defined structure described by
412
- * a non-resource schema.
479
+ * a schema-object (a non-resource schema).
413
480
  *
414
481
  * If the object's structure is not well-defined,
415
482
  * use 'object' instead.
416
483
  *
484
+ * By default, a SchemaObject within
485
+ *
417
486
  * @public
418
487
  */
419
488
  export interface SchemaObjectField {
@@ -430,12 +499,42 @@ export interface SchemaObjectField {
430
499
  */
431
500
  name: string;
432
501
  /**
502
+ * The name of the field as returned by the API
503
+ * and inserted into the {@link Cache} if it differs
504
+ * from {@link SchemaObjectField.name}
505
+ *
506
+ * For instance, if the API returns:
507
+ *
508
+ * ```ts
509
+ * {
510
+ * attributes: {
511
+ * 'first-name': 'Chris'
512
+ * }
513
+ * }
514
+ * ```
515
+ *
516
+ * But the app desires to use `record.firstName; // 'Chris'`
517
+ *
518
+ * Then `name` would be set to `'firstName'` and
519
+ * `sourceKey` would be set to `'first-name'`.
520
+ *
521
+ * This option is only needed when the value differs from name.
522
+ */
523
+ sourceKey?: string;
524
+ /**
525
+ * If the field is not polymorphic:
526
+ *
433
527
  * The name of the ObjectSchema that describes the
434
528
  * structure of the object.
435
529
  *
530
+ * If the field is polymorphic:
531
+ *
532
+ * The name of the hashFn to use to extract
533
+ * the type from the contained value or null.
534
+ *
436
535
  * @public
437
536
  */
438
- type: string;
537
+ type: string | null;
439
538
  /**
440
539
  * Options for configuring the behavior of the
441
540
  * SchemaObject.
@@ -472,7 +571,15 @@ export interface SchemaObjectField {
472
571
  * If the SchemaObject is Polymorphic, the key on the raw cache data to use
473
572
  * as the "resource-type" value for the schema-object.
474
573
  *
475
- * Defaults to "type".
574
+ * The default is `'type'`.
575
+ *
576
+ * Valid options are:
577
+ *
578
+ * - `'@hash'` : will lookup the `@hash` function specified by
579
+ * SchemaObjectField.type and use it to calculate the type for each value.
580
+ * - \<field-name> (string) : the name of a field to use as the key, only GenericFields (kind `field`)
581
+ * Are valid field names for this purpose. The cache state without transforms applied will be
582
+ * used when comparing values.
476
583
  *
477
584
  * @public
478
585
  */
@@ -502,6 +609,29 @@ export interface ArrayField {
502
609
  */
503
610
  name: string;
504
611
  /**
612
+ * The name of the field as returned by the API
613
+ * and inserted into the {@link Cache} if it differs
614
+ * from {@link ArrayField.name}
615
+ *
616
+ * For instance, if the API returns:
617
+ *
618
+ * ```ts
619
+ * {
620
+ * attributes: {
621
+ * 'first-name': 'Chris'
622
+ * }
623
+ * }
624
+ * ```
625
+ *
626
+ * But the app desires to use `record.firstName; // 'Chris'`
627
+ *
628
+ * Then `name` would be set to `'firstName'` and
629
+ * `sourceKey` would be set to `'first-name'`.
630
+ *
631
+ * This option is only needed when the value differs from name.
632
+ */
633
+ sourceKey?: string;
634
+ /**
505
635
  * The name of a transform to pass each item
506
636
  * in the array through before displaying or
507
637
  * or serializing it.
@@ -558,12 +688,42 @@ export interface SchemaArrayField {
558
688
  */
559
689
  name: string;
560
690
  /**
691
+ * The name of the field as returned by the API
692
+ * and inserted into the {@link Cache} if it differs
693
+ * from {@link SchemaArrayField.name}
694
+ *
695
+ * For instance, if the API returns:
696
+ *
697
+ * ```ts
698
+ * {
699
+ * attributes: {
700
+ * 'first-name': 'Chris'
701
+ * }
702
+ * }
703
+ * ```
704
+ *
705
+ * But the app desires to use `record.firstName; // 'Chris'`
706
+ *
707
+ * Then `name` would be set to `'firstName'` and
708
+ * `sourceKey` would be set to `'first-name'`.
709
+ *
710
+ * This option is only needed when the value differs from name.
711
+ */
712
+ sourceKey?: string;
713
+ /**
714
+ * If the SchemaArray is not polymorphic:
715
+ *
561
716
  * The name of the ObjectSchema that describes the
562
717
  * structure of the objects in the array.
563
718
  *
719
+ * If the SchemaArray is polymorphic:
720
+ *
721
+ * The name of the hashFn to use to extract
722
+ * the type from contained members or null.
723
+ *
564
724
  * @public
565
725
  */
566
- type: string;
726
+ type: string | null;
567
727
  /**
568
728
  * Options for configuring the behavior of the
569
729
  * SchemaArray.
@@ -577,13 +737,13 @@ export interface SchemaArrayField {
577
737
  *
578
738
  * Valid options are:
579
739
  *
580
- * - `'@identity'` (default) : the cached object's referential identity will be used.
740
+ * - `'@identity'`(default) : the cached object's referential identity will be used.
581
741
  * This may result in significant instability when resource data is updated from the API
582
742
  * - `'@index'` : the cached object's index in the array will be used.
583
743
  * This is only a good choice for arrays that rarely if ever change membership
584
744
  * - `'@hash'` : will lookup the `@hash` function supplied in the ResourceSchema for
585
745
  * The contained schema-object and use the computed result to determine and compare identity.
586
- * - \<field-name> (string) : the name of a field to use as the key, only GenericFields (kind `field`)
746
+ * - \<field-name> (string) : the name of a field to use as the key, only GenericFields (kind `field`)
587
747
  * Are valid field names for this purpose. The cache state without transforms applied will be
588
748
  * used when comparing values. The field value should be unique enough to guarantee two schema-objects
589
749
  * of the same type will not collide.
@@ -655,8 +815,15 @@ export interface SchemaArrayField {
655
815
  * If the SchemaArray is Polymorphic, the key on the raw cache data to use
656
816
  * as the "resource-type" value for the schema-object.
657
817
  *
658
- * Defaults to "type".
818
+ * The default is `'type'`.
819
+ *
820
+ * Valid options are:
659
821
  *
822
+ * - `'@hash'` : will lookup the `@hash` function specified by
823
+ * SchemaArrayField.type and use it to calculate the type for each value.
824
+ * - \<field-name> (string) : the name of a field to use as the key, only GenericFields (kind `field`)
825
+ * Are valid field names for this purpose. The cache state without transforms applied will be
826
+ * used when comparing values.
660
827
  */
661
828
  type?: string;
662
829
  };
@@ -743,6 +910,29 @@ export interface ResourceField {
743
910
  */
744
911
  name: string;
745
912
  /**
913
+ * The name of the field as returned by the API
914
+ * and inserted into the {@link Cache} if it differs
915
+ * from {@link ResourceField.name}
916
+ *
917
+ * For instance, if the API returns:
918
+ *
919
+ * ```ts
920
+ * {
921
+ * attributes: {
922
+ * 'first-name': 'Chris'
923
+ * }
924
+ * }
925
+ * ```
926
+ *
927
+ * But the app desires to use `record.firstName; // 'Chris'`
928
+ *
929
+ * Then `name` would be set to `'firstName'` and
930
+ * `sourceKey` would be set to `'first-name'`.
931
+ *
932
+ * This option is only needed when the value differs from name.
933
+ */
934
+ sourceKey?: string;
935
+ /**
746
936
  * The name of the resource that this field
747
937
  * refers to. In the case of a polymorphic
748
938
  * relationship, this should be the trait
@@ -825,6 +1015,29 @@ export interface CollectionField {
825
1015
  */
826
1016
  name: string;
827
1017
  /**
1018
+ * The name of the field as returned by the API
1019
+ * and inserted into the {@link Cache} if it differs
1020
+ * from {@link CollectionField.name}
1021
+ *
1022
+ * For instance, if the API returns:
1023
+ *
1024
+ * ```ts
1025
+ * {
1026
+ * attributes: {
1027
+ * 'first-name': 'Chris'
1028
+ * }
1029
+ * }
1030
+ * ```
1031
+ *
1032
+ * But the app desires to use `record.firstName; // 'Chris'`
1033
+ *
1034
+ * Then `name` would be set to `'firstName'` and
1035
+ * `sourceKey` would be set to `'first-name'`.
1036
+ *
1037
+ * This option is only needed when the value differs from name.
1038
+ */
1039
+ sourceKey?: string;
1040
+ /**
828
1041
  * The name of the resource that this field
829
1042
  * refers to. In the case of a polymorphic
830
1043
  * relationship, this should be the trait
@@ -925,6 +1138,29 @@ export interface LegacyAttributeField {
925
1138
  */
926
1139
  name: string;
927
1140
  /**
1141
+ * The name of the field as returned by the API
1142
+ * and inserted into the {@link Cache} if it differs
1143
+ * from {@link LegacyAttributeField.name}
1144
+ *
1145
+ * For instance, if the API returns:
1146
+ *
1147
+ * ```ts
1148
+ * {
1149
+ * attributes: {
1150
+ * 'first-name': 'Chris'
1151
+ * }
1152
+ * }
1153
+ * ```
1154
+ *
1155
+ * But the app desires to use `record.firstName; // 'Chris'`
1156
+ *
1157
+ * Then `name` would be set to `'firstName'` and
1158
+ * `sourceKey` would be set to `'first-name'`.
1159
+ *
1160
+ * This option is only needed when the value differs from name.
1161
+ */
1162
+ sourceKey?: string;
1163
+ /**
928
1164
  * The name of the transform to use, if any
929
1165
  *
930
1166
  * @public
@@ -964,6 +1200,29 @@ export interface LegacyBelongsToField {
964
1200
  */
965
1201
  name: string;
966
1202
  /**
1203
+ * The name of the field as returned by the API
1204
+ * and inserted into the {@link Cache} if it differs
1205
+ * from {@link LegacyBelongsToField.name}
1206
+ *
1207
+ * For instance, if the API returns:
1208
+ *
1209
+ * ```ts
1210
+ * {
1211
+ * attributes: {
1212
+ * 'first-name': 'Chris'
1213
+ * }
1214
+ * }
1215
+ * ```
1216
+ *
1217
+ * But the app desires to use `record.firstName; // 'Chris'`
1218
+ *
1219
+ * Then `name` would be set to `'firstName'` and
1220
+ * `sourceKey` would be set to `'first-name'`.
1221
+ *
1222
+ * This option is only needed when the value differs from name.
1223
+ */
1224
+ sourceKey?: string;
1225
+ /**
967
1226
  * The name of the resource that this field
968
1227
  * refers to. In the case of a polymorphic
969
1228
  * relationship, this should be the trait
@@ -1094,6 +1353,29 @@ export interface LinksModeBelongsToField {
1094
1353
  */
1095
1354
  name: string;
1096
1355
  /**
1356
+ * The name of the field as returned by the API
1357
+ * and inserted into the {@link Cache} if it differs
1358
+ * from {@link LinksModeBelongsToField.name}
1359
+ *
1360
+ * For instance, if the API returns:
1361
+ *
1362
+ * ```ts
1363
+ * {
1364
+ * attributes: {
1365
+ * 'first-name': 'Chris'
1366
+ * }
1367
+ * }
1368
+ * ```
1369
+ *
1370
+ * But the app desires to use `record.firstName; // 'Chris'`
1371
+ *
1372
+ * Then `name` would be set to `'firstName'` and
1373
+ * `sourceKey` would be set to `'first-name'`.
1374
+ *
1375
+ * This option is only needed when the value differs from name.
1376
+ */
1377
+ sourceKey?: string;
1378
+ /**
1097
1379
  * The name of the resource that this field
1098
1380
  * refers to. In the case of a polymorphic
1099
1381
  * relationship, this should be the trait
@@ -1219,6 +1501,29 @@ export interface LegacyHasManyField {
1219
1501
  */
1220
1502
  name: string;
1221
1503
  /**
1504
+ * The name of the field as returned by the API
1505
+ * and inserted into the {@link Cache} if it differs
1506
+ * from {@link LegacyHasManyField.name}
1507
+ *
1508
+ * For instance, if the API returns:
1509
+ *
1510
+ * ```ts
1511
+ * {
1512
+ * attributes: {
1513
+ * 'first-name': 'Chris'
1514
+ * }
1515
+ * }
1516
+ * ```
1517
+ *
1518
+ * But the app desires to use `record.firstName; // 'Chris'`
1519
+ *
1520
+ * Then `name` would be set to `'firstName'` and
1521
+ * `sourceKey` would be set to `'first-name'`.
1522
+ *
1523
+ * This option is only needed when the value differs from name.
1524
+ */
1525
+ sourceKey?: string;
1526
+ /**
1222
1527
  * the name of the resource that this field
1223
1528
  * refers to. In the case of a polymorphic
1224
1529
  * relationship, this should be the trait
@@ -1367,6 +1672,29 @@ export interface LinksModeHasManyField {
1367
1672
  */
1368
1673
  name: string;
1369
1674
  /**
1675
+ * The name of the field as returned by the API
1676
+ * and inserted into the {@link Cache} if it differs
1677
+ * from {@link LinksModeHasManyField.name}
1678
+ *
1679
+ * For instance, if the API returns:
1680
+ *
1681
+ * ```ts
1682
+ * {
1683
+ * attributes: {
1684
+ * 'first-name': 'Chris'
1685
+ * }
1686
+ * }
1687
+ * ```
1688
+ *
1689
+ * But the app desires to use `record.firstName; // 'Chris'`
1690
+ *
1691
+ * Then `name` would be set to `'firstName'` and
1692
+ * `sourceKey` would be set to `'first-name'`.
1693
+ *
1694
+ * This option is only needed when the value differs from name.
1695
+ */
1696
+ sourceKey?: string;
1697
+ /**
1370
1698
  * the name of the resource that this field
1371
1699
  * refers to. In the case of a polymorphic
1372
1700
  * relationship, this should be the trait
@@ -1548,12 +1876,23 @@ export type PolarisModeFieldSchema = GenericField | PolarisAliasField | LocalFie
1548
1876
  */
1549
1877
  export type FieldSchema = GenericField | LegacyAliasField | PolarisAliasField | LocalField | ObjectField | SchemaObjectField | ArrayField | SchemaArrayField | DerivedField | ResourceField | CollectionField | LegacyAttributeField | LegacyBelongsToField | LegacyHasManyField | LinksModeBelongsToField | LinksModeHasManyField;
1550
1878
  /**
1879
+ * A union of all possible LegacyMode and PolarisMode
1880
+ * field schemas that represent data that could be in
1881
+ * the cache.
1882
+ *
1883
+ * In other words this will not include types like alias
1884
+ * fields, local fields, or derived fields.
1885
+ *
1886
+ * @public
1887
+ */
1888
+ export type CacheableFieldSchema = IdentityField | GenericField | ObjectField | SchemaObjectField | ArrayField | SchemaArrayField | ResourceField | CollectionField | LegacyAttributeField | LegacyBelongsToField | LegacyHasManyField | LinksModeBelongsToField | LinksModeHasManyField;
1889
+ /**
1551
1890
  * A union of all possible field schemas that can be
1552
1891
  * used in an ObjectSchema.
1553
1892
  *
1554
1893
  * @public
1555
1894
  */
1556
- export type ObjectFieldSchema = GenericField | ObjectAliasField | LocalField | ObjectField | SchemaObjectField | ArrayField | SchemaArrayField | DerivedField;
1895
+ export type ObjectFieldSchema = LegacyAttributeField | GenericField | ObjectAliasField | LocalField | ObjectField | SchemaObjectField | ArrayField | SchemaArrayField | DerivedField;
1557
1896
  /**
1558
1897
  * Represents a schema for a primary resource in PolarisMode.
1559
1898
  *
@@ -1570,8 +1909,6 @@ export interface PolarisResourceSchema {
1570
1909
  *
1571
1910
  * for schema-objects, this should be either a HashField or null
1572
1911
  *
1573
- * @property identity
1574
- * @type {IdentityField}
1575
1912
  * @public
1576
1913
  */
1577
1914
  identity: IdentityField;
@@ -1,5 +1,5 @@
1
1
  import { deprecate, warn } from '@ember/debug';
2
- import { p as peekCache } from "../request-state-CejVJgdj.js";
2
+ import { p as peekCache } from "../request-state-CeN66aML.js";
3
3
  import '../types/request.js';
4
4
  import { macroCondition, getGlobalConfig } from '@embroider/macros';
5
5
  import '../utils/string.js';
@@ -1,4 +1,4 @@
1
- import { K as ReactiveDocument } from "./request-state-CejVJgdj.js";
1
+ import { K as ReactiveDocument } from "./request-state-CeN66aML.js";
2
2
  import { SkipCache, EnableHydration } from './types/request.js';
3
3
  import { macroCondition, getGlobalConfig } from '@embroider/macros';
4
4
  const MUTATION_OPS = new Set(['createRecord', 'updateRecord', 'deleteRecord']);
package/dist/index.js CHANGED
@@ -3,8 +3,8 @@ import { a as cloneResponseProperties, I as IS_CACHE_HANDLER, b as assertValidRe
3
3
  import { macroCondition, getGlobalConfig } from '@embroider/macros';
4
4
  import { w as waitFor } from "./configure-B48bFHOl.js";
5
5
  import { peekUniversalTransient, setUniversalTransient } from './types/-private.js';
6
- export { S as Store, r as recordIdentifierFor, O as setIdentifierForgetMethod, L as setIdentifierGenerationMethod, P as setIdentifierResetMethod, N as setIdentifierUpdateMethod, Q as setKeyInfoForResource, s as storeFor } from "./request-state-CejVJgdj.js";
7
- export { C as CacheHandler } from "./handler-D2jjnIA-.js";
6
+ export { S as Store, r as recordIdentifierFor, O as setIdentifierForgetMethod, L as setIdentifierGenerationMethod, P as setIdentifierResetMethod, N as setIdentifierUpdateMethod, Q as setKeyInfoForResource, s as storeFor } from "./request-state-CeN66aML.js";
7
+ export { C as CacheHandler } from "./handler-SdXlte1w.js";
8
8
  import '@ember/debug';
9
9
  import './utils/string.js';
10
10