@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.
Files changed (120) hide show
  1. package/declarations/graph/-private/-diff.d.ts +7 -20
  2. package/declarations/graph/-private/-edge-definition.d.ts +3 -12
  3. package/declarations/graph/-private/-state.d.ts +2 -2
  4. package/declarations/graph/-private/-utils.d.ts +5 -5
  5. package/declarations/graph/-private/debug/assert-polymorphic-type.d.ts +3 -3
  6. package/declarations/graph/-private/edges/collection.d.ts +10 -10
  7. package/declarations/graph/-private/edges/implicit.d.ts +5 -5
  8. package/declarations/graph/-private/edges/resource.d.ts +6 -7
  9. package/declarations/graph/-private/graph.d.ts +17 -15
  10. package/declarations/graph/-private/operations/replace-related-records.d.ts +4 -4
  11. package/declarations/graph/-private/operations/update-relationship.d.ts +3 -3
  12. package/declarations/index.d.ts +1 -1
  13. package/declarations/reactive/-private/default-mode.d.ts +73 -0
  14. package/declarations/reactive/-private/document.d.ts +11 -27
  15. package/declarations/reactive/-private/fields/get-field-key.d.ts +8 -0
  16. package/declarations/reactive/-private/fields/managed-array.d.ts +7 -10
  17. package/declarations/reactive/-private/fields/managed-object.d.ts +7 -9
  18. package/declarations/reactive/-private/fields/many-array-manager.d.ts +2 -2
  19. package/declarations/reactive/-private/hooks.d.ts +2 -2
  20. package/declarations/reactive/-private/kind/alias-field.d.ts +4 -0
  21. package/declarations/reactive/-private/kind/array-field.d.ts +4 -0
  22. package/declarations/reactive/-private/kind/attribute-field.d.ts +4 -0
  23. package/declarations/reactive/-private/kind/belongs-to-field.d.ts +4 -0
  24. package/declarations/reactive/-private/kind/collection-field.d.ts +4 -0
  25. package/declarations/reactive/-private/kind/derived-field.d.ts +4 -0
  26. package/declarations/reactive/-private/kind/generic-field.d.ts +4 -0
  27. package/declarations/reactive/-private/kind/has-many-field.d.ts +4 -0
  28. package/declarations/reactive/-private/kind/hash-field.d.ts +4 -0
  29. package/declarations/reactive/-private/kind/identity-field.d.ts +4 -0
  30. package/declarations/reactive/-private/kind/local-field.d.ts +4 -0
  31. package/declarations/reactive/-private/kind/object-field.d.ts +4 -0
  32. package/declarations/reactive/-private/kind/resource-field.d.ts +4 -0
  33. package/declarations/reactive/-private/kind/schema-array-field.d.ts +4 -0
  34. package/declarations/reactive/-private/kind/schema-object-field.d.ts +4 -0
  35. package/declarations/reactive/-private/record.d.ts +44 -33
  36. package/declarations/reactive/-private/schema.d.ts +50 -66
  37. package/declarations/reactive/-private/symbols.d.ts +2 -7
  38. package/declarations/reactive/-private.d.ts +1 -1
  39. package/declarations/reactive.d.ts +278 -1
  40. package/declarations/request/-private/context.d.ts +3 -5
  41. package/declarations/request/-private/fetch.d.ts +2 -0
  42. package/declarations/request/-private/manager.d.ts +24 -28
  43. package/declarations/request/-private/types.d.ts +22 -23
  44. package/declarations/request/-private/utils.d.ts +44 -2
  45. package/declarations/store/-private/cache-handler/handler.d.ts +2 -8
  46. package/declarations/store/-private/cache-handler/types.d.ts +10 -10
  47. package/declarations/store/-private/cache-handler/utils.d.ts +4 -4
  48. package/declarations/store/-private/caches/instance-cache.d.ts +22 -27
  49. package/declarations/store/-private/debug/utils.d.ts +1 -0
  50. package/declarations/store/-private/default-cache-policy.d.ts +25 -38
  51. package/declarations/store/-private/managers/cache-capabilities-manager.d.ts +24 -15
  52. package/declarations/store/-private/{caches/identifier-cache.d.ts → managers/cache-key-manager.d.ts} +38 -52
  53. package/declarations/store/-private/managers/cache-manager.d.ts +46 -95
  54. package/declarations/store/-private/managers/notification-manager.d.ts +30 -43
  55. package/declarations/store/-private/managers/record-array-manager.d.ts +44 -41
  56. package/declarations/store/-private/network/request-cache.d.ts +21 -24
  57. package/declarations/store/-private/new-core-tmp/expensive-subscription.d.ts +24 -0
  58. package/declarations/store/-private/new-core-tmp/reactivity/configure.d.ts +3 -41
  59. package/declarations/store/-private/new-core-tmp/reactivity/internal.d.ts +14 -29
  60. package/declarations/store/-private/new-core-tmp/reactivity/signal.d.ts +24 -3
  61. package/declarations/store/-private/new-core-tmp/request-state.d.ts +133 -37
  62. package/declarations/store/-private/new-core-tmp/request-subscription.d.ts +51 -133
  63. package/declarations/store/-private/record-arrays/-utils.d.ts +80 -0
  64. package/declarations/store/-private/record-arrays/legacy-live-array.d.ts +81 -0
  65. package/declarations/store/-private/record-arrays/legacy-many-array.d.ts +133 -0
  66. package/declarations/store/-private/record-arrays/legacy-query.d.ts +81 -0
  67. package/declarations/store/-private/record-arrays/native-proxy-type-fix.d.ts +1 -124
  68. package/declarations/store/-private/record-arrays/resource-array.d.ts +75 -0
  69. package/declarations/store/-private/store-service.d.ts +167 -872
  70. package/declarations/store/-private.d.ts +14 -10
  71. package/declarations/store/-types/q/cache-capabilities-manager.d.ts +15 -24
  72. package/declarations/store/-types/q/identifier.d.ts +9 -6
  73. package/declarations/store/-types/q/record-instance.d.ts +0 -1
  74. package/declarations/store/-types/q/schema-service.d.ts +64 -40
  75. package/declarations/store/-types/q/store.d.ts +6 -7
  76. package/declarations/store/deprecated/-private.d.ts +224 -0
  77. package/declarations/store/deprecated/store.d.ts +787 -0
  78. package/declarations/types/-private.d.ts +1 -1
  79. package/declarations/types/cache/aliases.d.ts +2 -2
  80. package/declarations/types/cache/change.d.ts +2 -2
  81. package/declarations/types/cache/mutations.d.ts +13 -13
  82. package/declarations/types/cache/operations.d.ts +115 -32
  83. package/declarations/types/cache/relationship.d.ts +4 -4
  84. package/declarations/types/cache.d.ts +51 -115
  85. package/declarations/types/graph.d.ts +12 -12
  86. package/declarations/types/identifier.d.ts +52 -76
  87. package/declarations/types/params.d.ts +2 -3
  88. package/declarations/types/request.d.ts +69 -42
  89. package/declarations/types/schema/concepts.d.ts +2 -2
  90. package/declarations/types/schema/fields.d.ts +391 -14
  91. package/declarations/types/spec/document.d.ts +6 -6
  92. package/declarations/types/spec/json-api-raw.d.ts +6 -8
  93. package/declarations/types.d.ts +2 -1
  94. package/declarations/utils/string.d.ts +2 -2
  95. package/dist/{configure-B48bFHOl.js → configure-C3x8YXzL.js} +5 -5
  96. package/dist/configure.js +1 -1
  97. package/dist/{context-COmAnXUQ.js → context-C_7OLieY.js} +48 -6
  98. package/dist/graph/-private.js +137 -144
  99. package/dist/index.js +25 -14
  100. package/dist/reactive/-private.js +1 -1
  101. package/dist/reactive.js +337 -1422
  102. package/dist/{request-state-CjLph1LP.js → request-state-C955e0AL.js} +8352 -5912
  103. package/dist/request.js +1 -1
  104. package/dist/store/-private.js +2 -3
  105. package/dist/store.js +32 -44
  106. package/dist/{symbols-SIstXMLI.js → symbols-sql1_mdx.js} +3 -8
  107. package/dist/types/-private.js +1 -1
  108. package/dist/types/identifier.js +19 -45
  109. package/dist/types/request.js +45 -3
  110. package/dist/types/schema/fields.js +23 -2
  111. package/dist/utils/string.js +2 -2
  112. package/package.json +10 -10
  113. package/declarations/reactive/-private/fields/compute.d.ts +0 -43
  114. package/declarations/store/-private/caches/cache-utils.d.ts +0 -12
  115. package/declarations/store/-private/legacy-model-support/record-reference.d.ts +0 -159
  116. package/declarations/store/-private/legacy-model-support/shim-model-class.d.ts +0 -17
  117. package/declarations/store/-private/record-arrays/identifier-array.d.ts +0 -147
  118. package/declarations/store/-private/record-arrays/many-array.d.ts +0 -197
  119. package/declarations/store/-types/q/ds-model.d.ts +0 -21
  120. package/dist/handler-C2T-IyJK.js +0 -339
@@ -1,8 +1,9 @@
1
- export { Store, storeFor } from "./-private/store-service.js";
1
+ export { Store } from "./deprecated/store.js";
2
+ export { storeFor } from "./-private/store-service.js";
2
3
  export { recordIdentifierFor } from "./-private/caches/instance-cache.js";
3
4
  export { CacheHandler, type StoreRequestContext } from "./-private/cache-handler/handler.js";
4
5
  export { type CachePolicy } from "./-private/cache-handler/types.js";
5
- export { isStableIdentifier, isDocumentIdentifier } from "./-private/caches/identifier-cache.js";
6
+ export { isResourceKey, isRequestKey } from "./-private/managers/cache-key-manager.js";
6
7
  export { constructResource } from "./-private/utils/construct-resource.js";
7
8
  export type { InstanceCache } from "./-private/caches/instance-cache.js";
8
9
  export type { FindRecordQuery, Request, SaveRecordMutation, RequestCacheRequestState, RequestStateService } from "./-private/network/request-cache.js";
@@ -11,21 +12,24 @@ export type { CreateRecordProperties } from "./-private/store-service.js";
11
12
  // to also eliminate
12
13
  export { coerceId, ensureStringId } from "./-private/utils/coerce-id.js";
13
14
  export type { NativeProxy } from "./-private/record-arrays/native-proxy-type-fix.js";
14
- export { IdentifierArray as LiveArray, Collection as CollectionRecordArray, SOURCE, MUTATE } from "./-private/record-arrays/identifier-array.js";
15
+ export { type ReactiveResourceArray, type PrivateReactiveResourceArray } from "./-private/record-arrays/resource-array.js";
16
+ export { type LegacyLiveArray, type LegacyLiveArray as LiveArray } from "./-private/record-arrays/legacy-live-array.js";
17
+ export { type LegacyQueryArray, type LegacyQueryArray as CollectionRecordArray } from "./-private/record-arrays/legacy-query.js";
15
18
  export { RecordArrayManager, fastPush } from "./-private/managers/record-array-manager.js";
19
+ // leaked for test/legacy use. You will get in trouble for this.
20
+ export { assertPrivateStore, isPrivateStore, type PrivateStore } from "./-private/store-service.js";
21
+ export { assertPrivateCapabilities, type PrivateCacheCapabilitiesManager } from "./-private/managers/cache-capabilities-manager.js";
16
22
  // leaked for private use / test use, should investigate removing
17
23
  export { _clearCaches } from "./-private/caches/instance-cache.js";
18
- export { peekCache, removeRecordDataFor } from "./-private/caches/cache-utils.js";
19
24
  // @ember-data/model needs these temporarily
20
25
  export { setRecordIdentifier, StoreMap } from "./-private/caches/instance-cache.js";
21
- export { setCacheFor } from "./-private/caches/cache-utils.js";
22
26
  export { normalizeModelName as _deprecatingNormalize } from "./-private/utils/normalize-model-name.js";
23
27
  export type { StoreRequestInput } from "./-private/cache-handler/handler.js";
24
- export { RelatedCollection } from "./-private/record-arrays/many-array.js";
28
+ export { type LegacyManyArray, type LegacyManyArray as RelatedCollection, createLegacyManyArray } from "./-private/record-arrays/legacy-many-array.js";
25
29
  export { log, logGroup } from "./-private/debug/utils.js";
26
30
  export { getPromiseState, type PromiseState } from "./-private/new-core-tmp/promise-state.js";
27
- export { DISPOSE, createRequestSubscription, type SubscriptionArgs, type RequestSubscription } from "./-private/new-core-tmp/request-subscription.js";
31
+ export { DISPOSE, createRequestSubscription, type RequestArgs, type SubscriptionArgs, type RequestComponentArgs, type RequestSubscription, type ContentFeatures, type RecoveryFeatures, type AutorefreshBehaviorCombos, type AutorefreshBehaviorType } from "./-private/new-core-tmp/request-subscription.js";
28
32
  export { getRequestState, type RequestLoadingState, type RequestCacheRequestState as RequestState } from "./-private/new-core-tmp/request-state.js";
29
- export { createMemo, type SignalHooks, waitFor } from "./-private/new-core-tmp/reactivity/configure.js";
30
- export { memoized, gate, entangleSignal, defineSignal, defineNonEnumerableSignal } from "./-private/new-core-tmp/reactivity/signal.js";
31
- export { ARRAY_SIGNAL, OBJECT_SIGNAL, Signals, type WarpDriveSignal, peekInternalSignal, withSignalStore, notifyInternalSignal, consumeInternalSignal, getOrCreateInternalSignal } from "./-private/new-core-tmp/reactivity/internal.js";
33
+ export { type SignalHooks, waitFor } from "./-private/new-core-tmp/reactivity/configure.js";
34
+ export { signal, memoized, gate, entangleSignal, entangleInitiallyStaleSignal, defineSignal, defineGate, defineNonEnumerableSignal } from "./-private/new-core-tmp/reactivity/signal.js";
35
+ export { ARRAY_SIGNAL, OBJECT_SIGNAL, Signals, type WarpDriveSignal, peekInternalSignal, createInternalMemo, withSignalStore, notifyInternalSignal, consumeInternalSignal, getOrCreateInternalSignal } from "./-private/new-core-tmp/reactivity/internal.js";
@@ -1,5 +1,5 @@
1
- import type { StableDocumentIdentifier, StableRecordIdentifier } from "../../../types/identifier.js";
2
- import type { IdentifierCache } from "../../-private/caches/identifier-cache.js";
1
+ import type { RequestKey, ResourceKey } from "../../../types/identifier.js";
2
+ import type { CacheKeyManager } from "../../-private/managers/cache-key-manager.js";
3
3
  import type { NotificationType } from "../../-private/managers/notification-manager.js";
4
4
  import type { SchemaService } from "./schema-service.js";
5
5
  /**
@@ -11,22 +11,21 @@ import type { SchemaService } from "./schema-service.js";
11
11
  *
12
12
  * This class cannot be directly instantiated.
13
13
  *
14
- * @class CacheCapabilitiesManager
15
14
  * @public
16
15
  */
17
16
  export type CacheCapabilitiesManager = {
18
17
  /**
19
- * Provides access to the IdentifierCache instance
18
+ * Provides access to the CacheKeyManager instance
20
19
  * for this Store instance.
21
20
  *
22
- * The IdentifierCache can be used to peek, generate or
21
+ * The CacheKeyManager can be used to peek, generate or
23
22
  * retrieve a stable unique identifier for any resource.
24
23
  *
25
- * @property identifierCache
26
- * @type {IdentifierCache}
27
24
  * @public
28
25
  */
29
- identifierCache: IdentifierCache;
26
+ cacheKeyManager: CacheKeyManager;
27
+ /** @deprecated use {@link CacheCapabilitiesManager.cacheKeyManager} */
28
+ identifierCache: CacheKeyManager;
30
29
  /**
31
30
  * DEPRECATED - use the schema property
32
31
  *
@@ -36,7 +35,7 @@ export type CacheCapabilitiesManager = {
36
35
  * The SchemaService can be used to query for
37
36
  * information about the schema of a resource.
38
37
  *
39
- * @deprecated
38
+ * @deprecated use {@link CacheCapabilitiesManager.schema}
40
39
  * @public
41
40
  */
42
41
  getSchemaDefinitionService(): SchemaService;
@@ -55,30 +54,25 @@ export type CacheCapabilitiesManager = {
55
54
  * Update the `id` for the record corresponding to the identifier
56
55
  * This operation can only be done for records whose `id` is `null`.
57
56
  *
58
- * @param {StableRecordIdentifier} identifier;
59
- * @param {String} id;
60
57
  * @public
61
58
  */
62
- setRecordId(identifier: StableRecordIdentifier, id: string): void;
59
+ setRecordId(identifier: ResourceKey, id: string): void;
63
60
  /**
64
61
  * Signal to the store that the specified record may be considered fully
65
62
  * removed from the cache. Generally this means that not only does no
66
63
  * data exist for the identified resource, no known relationships still
67
64
  * point to it either.
68
65
  *
69
- * @param {StableRecordIdentifier} identifier
70
66
  * @public
71
67
  */
72
- disconnectRecord(identifier: StableRecordIdentifier): void;
68
+ disconnectRecord(identifier: ResourceKey): void;
73
69
  /**
74
70
  * Use this method to determine if the Store has an instantiated record associated
75
71
  * with an identifier.
76
72
  *
77
- * @param identifier
78
- * @return {Boolean}
79
73
  * @public
80
74
  */
81
- hasRecord(identifier: StableRecordIdentifier): boolean;
75
+ hasRecord(identifier: ResourceKey): boolean;
82
76
  /**
83
77
  * Notify subscribers of the NotificationManager that cache state has changed.
84
78
  *
@@ -87,13 +81,10 @@ export type CacheCapabilitiesManager = {
87
81
  *
88
82
  * No other namespaces currently expect the `key` argument.
89
83
  *
90
- * @param {StableRecordIdentifier} identifier
91
- * @param {'attributes' | 'relationships' | 'identity' | 'errors' | 'meta' | 'state'} namespace
92
- * @param {string|undefined} key
93
84
  * @public
94
85
  */
95
- notifyChange(identifier: StableRecordIdentifier, namespace: "added" | "removed", key: null): void;
96
- notifyChange(identifier: StableDocumentIdentifier, namespace: "added" | "updated" | "removed", key: null): void;
97
- notifyChange(identifier: StableRecordIdentifier, namespace: NotificationType, key: string | null): void;
98
- notifyChange(identifier: StableRecordIdentifier | StableDocumentIdentifier, namespace: NotificationType | "added" | "removed" | "updated", key: string | null): void;
86
+ notifyChange(identifier: ResourceKey, namespace: "added" | "removed", key: null): void;
87
+ notifyChange(identifier: RequestKey, namespace: "added" | "updated" | "removed", key: null): void;
88
+ notifyChange(identifier: ResourceKey, namespace: NotificationType, key: string | null): void;
89
+ notifyChange(identifier: ResourceKey | RequestKey, namespace: NotificationType | "added" | "removed" | "updated", key: string | null): void;
99
90
  };
@@ -1,20 +1,23 @@
1
- import type { IdentifierBucket, StableIdentifier, StableRecordIdentifier } from "../../../types/identifier.js";
1
+ import type { CacheKeyType, RequestKey, ResourceKey } from "../../../types/identifier.js";
2
2
  import type { ImmutableRequestInfo } from "../../../types/request.js";
3
3
  export interface GenerationMethod {
4
4
  (data: ImmutableRequestInfo, bucket: "document"): string | null;
5
5
  (data: unknown | {
6
6
  type: string;
7
7
  }, bucket: "record"): string;
8
- (data: unknown, bucket: IdentifierBucket): string | null;
8
+ (data: unknown, bucket: CacheKeyType): string | null;
9
9
  }
10
10
  export type UpdateMethod = {
11
- (identifier: StableRecordIdentifier, newData: unknown, bucket: "record"): void;
12
- (identifier: StableIdentifier, newData: unknown, bucket: never): void;
11
+ (identifier: ResourceKey, newData: unknown, bucket: "record"): void;
12
+ (identifier: RequestKey, newData: unknown, bucket: "document"): void;
13
+ (identifier: {
14
+ lid: string;
15
+ }, newData: unknown, bucket: never): void;
13
16
  };
14
- export type ForgetMethod = (identifier: StableIdentifier | StableRecordIdentifier, bucket: IdentifierBucket) => void;
17
+ export type ForgetMethod = (identifier: RequestKey | ResourceKey, bucket: CacheKeyType) => void;
15
18
  export type ResetMethod = () => void;
16
19
  export type KeyInfo = {
17
20
  id: string | null;
18
21
  type: string;
19
22
  };
20
- export type KeyInfoMethod = (resource: unknown, known: StableRecordIdentifier | null) => KeyInfo;
23
+ export type KeyInfoMethod = (resource: unknown, known: ResourceKey | null) => KeyInfo;
@@ -18,6 +18,5 @@ also allows WarpDrive to provide typechecking and intellisense for the record
18
18
  based on a special symbol prsent on record instances that implement the
19
19
  `TypedRecordInstance` interface.
20
20
 
21
- @internal
22
21
  */
23
22
  export type OpaqueRecordInstance = unknown;
@@ -1,9 +1,9 @@
1
1
  import type { CAUTION_MEGA_DANGER_ZONE_Extension, ProcessedExtension } from "../../../reactive.js";
2
2
  import type { ExtensibleField } from "../../../reactive/-private/schema.js";
3
- import type { RecordIdentifier, StableRecordIdentifier } from "../../../types/identifier.js";
3
+ import type { ResourceKey } from "../../../types/identifier.js";
4
4
  import type { ObjectValue } from "../../../types/json/raw.js";
5
5
  import type { Derivation, HashFn, Transformation } from "../../../types/schema/concepts.js";
6
- import type { ArrayField, DerivedField, FieldSchema, GenericField, HashField, LegacyAttributeField, LegacyRelationshipField, ObjectField, Schema } from "../../../types/schema/fields.js";
6
+ import type { ArrayField, CacheableFieldSchema, DerivedField, FieldSchema, GenericField, HashField, IdentityField, LegacyAttributeField, LegacyRelationshipField, ObjectField, Schema, Trait } from "../../../types/schema/fields.js";
7
7
  export type AttributesSchema = Record<string, LegacyAttributeField>;
8
8
  export type RelationshipsSchema = Record<string, LegacyRelationshipField>;
9
9
  interface ObjectWithStringTypeProperty {
@@ -57,7 +57,6 @@ interface ObjectWithStringTypeProperty {
57
57
  * }
58
58
  * ```
59
59
  *
60
- * @class (Interface) SchemaService
61
60
  * @public
62
61
  */
63
62
  export interface SchemaService {
@@ -68,52 +67,47 @@ export interface SchemaService {
68
67
  *
69
68
  * @public
70
69
  * @deprecated
71
- * @param {String} type
72
- * @return {Boolean}
73
70
  */
74
71
  doesTypeExist?(type: string): boolean;
75
72
  /**
76
73
  * Queries whether the SchemaService recognizes `type` as a resource type
77
74
  *
78
75
  * @public
79
- * @param {StableRecordIdentifier|ObjectWithStringTypeProperty} resource
80
- * @return {Boolean}
81
76
  */
82
- hasResource(resource: ObjectWithStringTypeProperty | StableRecordIdentifier): boolean;
77
+ hasResource(resource: ObjectWithStringTypeProperty | ResourceKey): boolean;
83
78
  /**
84
79
  * Queries whether the SchemaService recognizes `type` as a resource trait
85
80
  *
86
81
  * @public
87
- * @param {String} type
88
- * @return {Boolean}
89
82
  */
90
83
  hasTrait(type: string): boolean;
91
84
  /**
92
85
  * Queries whether the given resource has the given trait
93
86
  *
94
87
  * @public
95
- * @param {StableRecordIdentifier|ObjectWithStringTypeProperty} resource
96
- * @param {String} trait
97
- * @return {Boolean}
98
88
  */
99
- resourceHasTrait(resource: ObjectWithStringTypeProperty | StableRecordIdentifier, trait: string): boolean;
89
+ resourceHasTrait(resource: ObjectWithStringTypeProperty | ResourceKey, trait: string): boolean;
100
90
  /**
101
91
  * Queries for the fields of a given resource type or resource identity.
102
92
  *
103
93
  * Should error if the resource type is not recognized.
104
94
  *
105
95
  * @public
106
- * @param {StableRecordIdentifier|ObjectWithStringTypeProperty} resource
107
- * @return {Map<string, FieldSchema>}
108
96
  */
109
- fields(resource: ObjectWithStringTypeProperty | StableRecordIdentifier): Map<string, FieldSchema>;
97
+ fields(resource: ObjectWithStringTypeProperty | ResourceKey): Map<string, FieldSchema>;
98
+ /**
99
+ * Queries for the fields of a given resource type or resource identity.
100
+ *
101
+ * Should error if the resource type is not recognized.
102
+ *
103
+ * @public
104
+ */
105
+ cacheFields?(resource: ObjectWithStringTypeProperty | ResourceKey): Map<string, Exclude<CacheableFieldSchema, IdentityField>>;
110
106
  /**
111
107
  * Returns the transformation registered with the name provided
112
108
  * by `field.type`. Validates that the field is a valid transformable.
113
109
  *
114
110
  * @public
115
- * @param {TransformableField|ObjectWithStringTypeProperty} field
116
- * @return {Transformation}
117
111
  */
118
112
  transformation(field: GenericField | ObjectField | ArrayField | ObjectWithStringTypeProperty): Transformation;
119
113
  /**
@@ -121,8 +115,6 @@ export interface SchemaService {
121
115
  * by `field.type`. Validates that the field is a valid HashField.
122
116
  *
123
117
  * @public
124
- * @param {HashField|ObjectWithStringTypeProperty} field
125
- * @return {HashFn}
126
118
  */
127
119
  hashFn(field: HashField | ObjectWithStringTypeProperty): HashFn;
128
120
  /**
@@ -130,18 +122,14 @@ export interface SchemaService {
130
122
  * by `field.type`. Validates that the field is a valid DerivedField.
131
123
  *
132
124
  * @public
133
- * @param {DerivedField|ObjectWithStringTypeProperty} field
134
- * @return {Derivation}
135
125
  */
136
126
  derivation(field: DerivedField | ObjectWithStringTypeProperty): Derivation;
137
127
  /**
138
128
  * Returns the schema for the provided resource type.
139
129
  *
140
130
  * @public
141
- * @param {StableRecordIdentifier|ObjectWithStringTypeProperty} resource
142
- * @return {ResourceSchema}
143
131
  */
144
- resource(resource: ObjectWithStringTypeProperty | StableRecordIdentifier): Schema;
132
+ resource(resource: ObjectWithStringTypeProperty | ResourceKey): Schema;
145
133
  /**
146
134
  * Enables registration of multiple Schemas at once.
147
135
  *
@@ -150,7 +138,6 @@ export interface SchemaService {
150
138
  * or other sources just-in-time.
151
139
  *
152
140
  * @public
153
- * @param {Schema[]} schemas
154
141
  */
155
142
  registerResources(schemas: Schema[]): void;
156
143
  /**
@@ -163,7 +150,6 @@ export interface SchemaService {
163
150
  * or other sources just-in-time.
164
151
  *
165
152
  * @public
166
- * @param {Schema} schema
167
153
  */
168
154
  registerResource(schema: Schema): void;
169
155
  /**
@@ -173,7 +159,6 @@ export interface SchemaService {
173
159
  * attached to it's `[Type]` property.
174
160
  *
175
161
  * @public
176
- * @param {Transformation} transform
177
162
  */
178
163
  registerTransformation(transform: Transformation): void;
179
164
  /**
@@ -183,7 +168,6 @@ export interface SchemaService {
183
168
  * attached to it's `[Type]` property.
184
169
  *
185
170
  * @public
186
- * @param {Derivation} derivation
187
171
  */
188
172
  registerDerivation<
189
173
  R,
@@ -197,10 +181,38 @@ export interface SchemaService {
197
181
  * attached to it's `[Type]` property.
198
182
  *
199
183
  * @public
200
- * @param {HashFn} hashfn
201
184
  */
202
185
  registerHashFn(hashFn: HashFn): void;
203
186
  /**
187
+ * Registers a {@link Trait} for use by resource schemas.
188
+ *
189
+ * Traits are re-usable collections of fields that can be composed to
190
+ * build up a resource schema. Often they represent polymorphic behaviors
191
+ * a resource should exhibit.
192
+ *
193
+ * When we finalize a resource, we walk its traits and apply their fields
194
+ * to the resource's fields. All specified traits must be registered by
195
+ * this time or an error will be thrown.
196
+ *
197
+ * Traits are applied left-to-right, with traits of traits being applied in the same
198
+ * way. Thus for the most part, application of traits is a post-order graph traversal
199
+ * problem.
200
+ *
201
+ * A trait is only ever processed once. If multiple traits (A, B, C) have the same
202
+ * trait (D) as a dependency, D will be included only once when first encountered by
203
+ * A.
204
+ *
205
+ * If a cycle exists such that trait A has trait B which has Trait A, trait A will
206
+ * be applied *after* trait B in production. In development a cycle error will be thrown.
207
+ *
208
+ * Fields are finalized on a "last wins principle". Thus traits appearing higher in
209
+ * the tree and further to the right of a traits array take precedence, with the
210
+ * resource's fields always being applied last and winning out.
211
+ *
212
+ * @public
213
+ */
214
+ registerTrait?(trait: Trait): void;
215
+ /**
204
216
  * DEPRECATED - use `fields` instead
205
217
  *
206
218
  * Returns definitions for all properties of the specified resource
@@ -240,10 +252,8 @@ export interface SchemaService {
240
252
  *
241
253
  * @public
242
254
  * @deprecated
243
- * @param {RecordIdentifier|ObjectWithStringTypeProperty} identifier
244
- * @return {AttributesSchema}
245
255
  */
246
- attributesDefinitionFor?(identifier: RecordIdentifier | ObjectWithStringTypeProperty): AttributesSchema;
256
+ attributesDefinitionFor?(key: ResourceKey | ObjectWithStringTypeProperty): AttributesSchema;
247
257
  /**
248
258
  * DEPRECATED - use `fields` instead
249
259
  *
@@ -321,34 +331,48 @@ export interface SchemaService {
321
331
  *
322
332
  * @public
323
333
  * @deprecated
324
- * @param {RecordIdentifier|ObjectWithStringTypeProperty} identifier
325
- * @return {RelationshipsSchema}
326
334
  */
327
- relationshipsDefinitionFor?(identifier: RecordIdentifier | ObjectWithStringTypeProperty): RelationshipsSchema;
335
+ relationshipsDefinitionFor?(key: ResourceKey | ObjectWithStringTypeProperty): RelationshipsSchema;
328
336
  /**
329
337
  * Returns all known resource types
330
338
  *
331
339
  * @public
332
- * @return {String[]}
333
340
  */
334
341
  resourceTypes(): Readonly<string[]>;
335
342
  /**
336
343
  * Register an extension for either objects or arrays
344
+ *
345
+ * @public
337
346
  */
338
347
  CAUTION_MEGA_DANGER_ZONE_registerExtension?(extension: CAUTION_MEGA_DANGER_ZONE_Extension): void;
339
348
  /**
340
349
  * Retrieve the extension map for a resource
350
+ *
351
+ * @public
341
352
  */
342
- CAUTION_MEGA_DANGER_ZONE_resourceExtensions?(resource: StableRecordIdentifier | {
353
+ CAUTION_MEGA_DANGER_ZONE_resourceExtensions?(resource: ResourceKey | {
343
354
  type: string;
344
355
  }): null | ProcessedExtension["features"];
345
356
  /**
346
357
  * Retrieve the extension map for an object field
358
+ *
359
+ * @public
347
360
  */
348
- CAUTION_MEGA_DANGER_ZONE_objectExtensions?(field: ExtensibleField): null | ProcessedExtension["features"];
361
+ CAUTION_MEGA_DANGER_ZONE_objectExtensions?(field: ExtensibleField, resolvedType: string | null): null | ProcessedExtension["features"];
349
362
  /**
350
363
  * Retrieve the extension map for an array field
364
+ *
365
+ * @public
351
366
  */
352
367
  CAUTION_MEGA_DANGER_ZONE_arrayExtensions?(field: ExtensibleField): null | ProcessedExtension["features"];
368
+ /**
369
+ * Check if a specific extension has been registered previously
370
+ *
371
+ * @public
372
+ */
373
+ CAUTION_MEGA_DANGER_ZONE_hasExtension?(ext: {
374
+ kind: "object" | "array";
375
+ name: string;
376
+ }): boolean;
353
377
  }
354
378
  export {};
@@ -1,12 +1,11 @@
1
1
  import type { Value } from "../../../types/json/raw.js";
2
- import type { Includes, TypedRecordInstance } from "../../../types/record.js";
3
- export interface BaseFinderOptions<T = unknown> {
2
+ export interface BaseFinderOptions {
4
3
  reload?: boolean;
5
4
  backgroundReload?: boolean;
6
- include?: T extends TypedRecordInstance ? Includes<T>[] : string | string[];
5
+ include?: string | string[];
7
6
  adapterOptions?: Record<string, unknown>;
8
7
  }
9
- export interface FindRecordOptions<T = unknown> extends BaseFinderOptions<T> {
8
+ export interface FindRecordOptions extends BaseFinderOptions {
10
9
  /**
11
10
  * Data to preload into the store before the request is made.
12
11
  * This feature is *highly* discouraged and has no corresponding
@@ -25,8 +24,8 @@ export interface FindRecordOptions<T = unknown> extends BaseFinderOptions<T> {
25
24
  preload?: Record<string, Value>;
26
25
  }
27
26
  export type QueryOptions = { [K in string | "adapterOptions"]? : K extends "adapterOptions" ? Record<string, unknown> : unknown };
28
- export type FindAllOptions<T = unknown> = BaseFinderOptions<T>;
29
- export type LegacyResourceQuery<T = unknown> = {
30
- include?: T extends TypedRecordInstance ? Includes<T>[] : string | string[];
27
+ export type FindAllOptions = BaseFinderOptions;
28
+ export type LegacyResourceQuery = {
29
+ include?: string | string[];
31
30
  [key: string]: Value | undefined;
32
31
  };