@warp-drive/core 5.6.0-alpha.5 → 5.6.0-beta.0

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 (219) hide show
  1. package/README.md +8 -7
  2. package/cjs-dist/addon-shim.cjs +1 -0
  3. package/cjs-dist/cjs-set-config.cjs +1 -0
  4. package/declarations/build-config/babel-macros.d.ts +1 -0
  5. package/declarations/build-config/canary-features.d.ts +1 -0
  6. package/declarations/build-config/debugging.d.ts +1 -0
  7. package/declarations/build-config/deprecations.d.ts +1 -0
  8. package/declarations/build-config/env.d.ts +1 -0
  9. package/declarations/build-config/macros.d.ts +1 -0
  10. package/declarations/build-config.d.ts +1 -0
  11. package/declarations/configure.d.ts +7 -0
  12. package/declarations/graph/-private/-diff.d.ts +32 -0
  13. package/declarations/graph/-private/-edge-definition.d.ts +148 -0
  14. package/declarations/graph/-private/-state.d.ts +96 -0
  15. package/declarations/graph/-private/-utils.d.ts +31 -0
  16. package/declarations/graph/-private/coerce-id.d.ts +10 -0
  17. package/declarations/graph/-private/debug/assert-polymorphic-type.d.ts +18 -0
  18. package/declarations/graph/-private/edges/collection.d.ts +39 -0
  19. package/declarations/graph/-private/edges/implicit.d.ts +43 -0
  20. package/declarations/graph/-private/edges/resource.d.ts +24 -0
  21. package/declarations/graph/-private/graph.d.ts +90 -0
  22. package/declarations/graph/-private/normalize-link.d.ts +8 -0
  23. package/declarations/graph/-private/operations/add-to-related-records.d.ts +4 -0
  24. package/declarations/graph/-private/operations/merge-identifier.d.ts +3 -0
  25. package/declarations/graph/-private/operations/remove-from-related-records.d.ts +4 -0
  26. package/declarations/graph/-private/operations/replace-related-record.d.ts +3 -0
  27. package/declarations/graph/-private/operations/replace-related-records.d.ts +62 -0
  28. package/declarations/graph/-private/operations/update-relationship.d.ts +13 -0
  29. package/declarations/graph/-private.d.ts +13 -0
  30. package/declarations/index.d.ts +14 -3
  31. package/declarations/reactive/-private/document.d.ts +146 -0
  32. package/declarations/reactive/-private/fields/compute.d.ts +43 -0
  33. package/declarations/reactive/-private/fields/extension.d.ts +8 -0
  34. package/declarations/reactive/-private/fields/managed-array.d.ts +22 -0
  35. package/declarations/reactive/-private/fields/managed-object.d.ts +21 -0
  36. package/declarations/reactive/-private/fields/many-array-manager.d.ts +19 -0
  37. package/declarations/reactive/-private/hooks.d.ts +5 -0
  38. package/declarations/reactive/-private/record.d.ts +64 -0
  39. package/declarations/reactive/-private/schema.d.ts +271 -0
  40. package/declarations/reactive/-private/symbols.d.ts +36 -0
  41. package/declarations/reactive/-private.d.ts +1 -0
  42. package/declarations/reactive.d.ts +4 -0
  43. package/declarations/request/-private/context.d.ts +34 -35
  44. package/declarations/request/-private/debug.d.ts +2 -3
  45. package/declarations/request/-private/fetch.d.ts +24 -36
  46. package/declarations/request/-private/future.d.ts +3 -4
  47. package/declarations/request/-private/manager.d.ts +159 -132
  48. package/declarations/request/-private/promise-cache.d.ts +21 -13
  49. package/declarations/request/-private/types.d.ts +124 -123
  50. package/declarations/request/-private/utils.d.ts +8 -9
  51. package/declarations/request.d.ts +5 -433
  52. package/declarations/store/-private/cache-handler/handler.d.ts +62 -0
  53. package/declarations/store/-private/cache-handler/types.d.ts +98 -0
  54. package/declarations/store/-private/cache-handler/utils.d.ts +32 -0
  55. package/declarations/store/-private/caches/cache-utils.d.ts +12 -0
  56. package/declarations/store/-private/caches/identifier-cache.d.ts +304 -0
  57. package/declarations/store/-private/caches/instance-cache.d.ts +65 -0
  58. package/declarations/store/-private/caches/resource-utils.d.ts +9 -0
  59. package/declarations/store/-private/debug/utils.d.ts +6 -0
  60. package/declarations/store/-private/default-cache-policy.d.ts +384 -0
  61. package/declarations/store/-private/legacy-model-support/record-reference.d.ts +159 -0
  62. package/declarations/store/-private/legacy-model-support/shim-model-class.d.ts +17 -0
  63. package/declarations/store/-private/managers/cache-capabilities-manager.d.ts +25 -0
  64. package/declarations/store/-private/managers/cache-manager.d.ts +443 -0
  65. package/declarations/store/-private/managers/notification-manager.d.ts +98 -0
  66. package/declarations/store/-private/managers/record-array-manager.d.ts +97 -0
  67. package/declarations/store/-private/network/request-cache.d.ts +107 -0
  68. package/declarations/store/-private/new-core-tmp/promise-state.d.ts +263 -0
  69. package/declarations/store/-private/new-core-tmp/reactivity/configure.d.ts +176 -0
  70. package/declarations/store/-private/new-core-tmp/reactivity/internal.d.ts +169 -0
  71. package/declarations/store/-private/new-core-tmp/reactivity/signal.d.ts +35 -0
  72. package/declarations/store/-private/new-core-tmp/request-state.d.ts +277 -0
  73. package/declarations/store/-private/new-core-tmp/request-subscription.d.ts +261 -0
  74. package/declarations/store/-private/record-arrays/identifier-array.d.ts +147 -0
  75. package/declarations/store/-private/record-arrays/many-array.d.ts +197 -0
  76. package/declarations/store/-private/record-arrays/native-proxy-type-fix.d.ts +126 -0
  77. package/declarations/store/-private/store-service.d.ts +1605 -0
  78. package/declarations/store/-private/utils/coerce-id.d.ts +10 -0
  79. package/declarations/store/-private/utils/construct-resource.d.ts +6 -0
  80. package/declarations/store/-private/utils/is-non-empty-string.d.ts +1 -0
  81. package/declarations/store/-private/utils/normalize-model-name.d.ts +1 -0
  82. package/declarations/store/-private/utils/uuid-polyfill.d.ts +1 -0
  83. package/declarations/store/-private.d.ts +31 -0
  84. package/declarations/store/-types/q/cache-capabilities-manager.d.ts +99 -0
  85. package/declarations/store/-types/q/ds-model.d.ts +21 -0
  86. package/declarations/store/-types/q/identifier.d.ts +20 -0
  87. package/declarations/store/-types/q/record-instance.d.ts +23 -0
  88. package/declarations/store/-types/q/schema-service.d.ts +354 -0
  89. package/declarations/store/-types/q/store.d.ts +32 -0
  90. package/declarations/store.d.ts +1 -0
  91. package/declarations/types/-private.d.ts +16 -8
  92. package/declarations/types/cache/aliases.d.ts +11 -1
  93. package/declarations/types/cache/change.d.ts +4 -5
  94. package/declarations/types/cache/mutations.d.ts +51 -28
  95. package/declarations/types/cache/operations.d.ts +60 -47
  96. package/declarations/types/cache/relationship.d.ts +11 -9
  97. package/declarations/types/cache.d.ts +495 -484
  98. package/declarations/types/graph.d.ts +31 -40
  99. package/declarations/types/identifier.d.ts +83 -82
  100. package/declarations/types/json/raw.d.ts +1 -2
  101. package/declarations/types/params.d.ts +4 -5
  102. package/declarations/types/record.d.ts +117 -76
  103. package/declarations/types/request.d.ts +289 -266
  104. package/declarations/types/runtime.d.ts +8 -9
  105. package/declarations/types/schema/concepts.d.ts +19 -13
  106. package/declarations/types/schema/fields.d.ts +1712 -1741
  107. package/declarations/types/schema/fields.type-test.d.ts +0 -1
  108. package/declarations/types/spec/document.d.ts +28 -22
  109. package/declarations/types/spec/error.d.ts +16 -17
  110. package/declarations/types/spec/json-api-raw.d.ts +102 -102
  111. package/declarations/types/symbols.d.ts +74 -75
  112. package/declarations/types/utils.d.ts +5 -5
  113. package/declarations/types.d.ts +10 -7
  114. package/declarations/utils/string.d.ts +48 -0
  115. package/dist/build-config/babel-macros.js +1 -0
  116. package/dist/build-config/canary-features.js +1 -0
  117. package/dist/build-config/debugging.js +1 -0
  118. package/dist/build-config/deprecations.js +1 -0
  119. package/dist/build-config/env.js +1 -0
  120. package/dist/build-config/macros.js +1 -0
  121. package/dist/build-config.js +1 -0
  122. package/dist/configure-B48bFHOl.js +181 -0
  123. package/dist/configure.js +1 -0
  124. package/dist/{context-DE5sFezZ.js → context-COmAnXUQ.js} +2 -2
  125. package/dist/graph/-private.js +3372 -0
  126. package/dist/handler-C2T-IyJK.js +339 -0
  127. package/dist/index.js +37 -104
  128. package/dist/reactive/-private.js +1 -0
  129. package/dist/reactive.js +1988 -0
  130. package/dist/request-state-CjLph1LP.js +8139 -0
  131. package/dist/request.js +1 -1
  132. package/dist/store/-private.js +3 -0
  133. package/dist/store.js +545 -0
  134. package/dist/symbols-SIstXMLI.js +44 -0
  135. package/dist/types/-private.js +3 -3
  136. package/dist/types/record.js +1 -1
  137. package/dist/types/request.js +2 -2
  138. package/dist/types/runtime.js +1 -1
  139. package/dist/types/schema/fields.js +8 -41
  140. package/dist/types/symbols.js +3 -3
  141. package/dist/utils/string.js +92 -0
  142. package/logos/NCC-1701-a-blue.svg +4 -0
  143. package/logos/NCC-1701-a-gold.svg +4 -0
  144. package/logos/NCC-1701-a-gold_100.svg +1 -0
  145. package/logos/NCC-1701-a-gold_base-64.txt +1 -0
  146. package/logos/NCC-1701-a.svg +4 -0
  147. package/logos/README.md +4 -0
  148. package/logos/docs-badge.svg +2 -0
  149. package/logos/ember-data-logo-dark.svg +12 -0
  150. package/logos/ember-data-logo-light.svg +12 -0
  151. package/logos/github-header.svg +444 -0
  152. package/logos/social1.png +0 -0
  153. package/logos/social2.png +0 -0
  154. package/logos/warp-drive-logo-dark.svg +4 -0
  155. package/logos/warp-drive-logo-gold.svg +4 -0
  156. package/package.json +11 -8
  157. package/declarations/index.d.ts.map +0 -1
  158. package/declarations/request/-private/context.d.ts.map +0 -1
  159. package/declarations/request/-private/debug.d.ts.map +0 -1
  160. package/declarations/request/-private/fetch.d.ts.map +0 -1
  161. package/declarations/request/-private/future.d.ts.map +0 -1
  162. package/declarations/request/-private/manager.d.ts.map +0 -1
  163. package/declarations/request/-private/promise-cache.d.ts.map +0 -1
  164. package/declarations/request/-private/types.d.ts.map +0 -1
  165. package/declarations/request/-private/utils.d.ts.map +0 -1
  166. package/declarations/request.d.ts.map +0 -1
  167. package/declarations/types/-private.d.ts.map +0 -1
  168. package/declarations/types/cache/aliases.d.ts.map +0 -1
  169. package/declarations/types/cache/change.d.ts.map +0 -1
  170. package/declarations/types/cache/mutations.d.ts.map +0 -1
  171. package/declarations/types/cache/operations.d.ts.map +0 -1
  172. package/declarations/types/cache/relationship.d.ts.map +0 -1
  173. package/declarations/types/cache.d.ts.map +0 -1
  174. package/declarations/types/graph.d.ts.map +0 -1
  175. package/declarations/types/identifier.d.ts.map +0 -1
  176. package/declarations/types/json/raw.d.ts.map +0 -1
  177. package/declarations/types/params.d.ts.map +0 -1
  178. package/declarations/types/record.d.ts.map +0 -1
  179. package/declarations/types/record.type-test.d.ts +0 -2
  180. package/declarations/types/record.type-test.d.ts.map +0 -1
  181. package/declarations/types/request.d.ts.map +0 -1
  182. package/declarations/types/request.type-test.d.ts +0 -2
  183. package/declarations/types/request.type-test.d.ts.map +0 -1
  184. package/declarations/types/runtime.d.ts.map +0 -1
  185. package/declarations/types/schema/concepts.d.ts.map +0 -1
  186. package/declarations/types/schema/fields.d.ts.map +0 -1
  187. package/declarations/types/schema/fields.type-test.d.ts.map +0 -1
  188. package/declarations/types/spec/document.d.ts.map +0 -1
  189. package/declarations/types/spec/error.d.ts.map +0 -1
  190. package/declarations/types/spec/json-api-raw.d.ts.map +0 -1
  191. package/declarations/types/symbols.d.ts.map +0 -1
  192. package/declarations/types/utils.d.ts.map +0 -1
  193. package/declarations/types.d.ts.map +0 -1
  194. package/dist/context-DE5sFezZ.js.map +0 -1
  195. package/dist/index.js.map +0 -1
  196. package/dist/request.js.map +0 -1
  197. package/dist/types/-private.js.map +0 -1
  198. package/dist/types/cache/aliases.js.map +0 -1
  199. package/dist/types/cache/change.js.map +0 -1
  200. package/dist/types/cache/mutations.js.map +0 -1
  201. package/dist/types/cache/operations.js.map +0 -1
  202. package/dist/types/cache/relationship.js.map +0 -1
  203. package/dist/types/cache.js.map +0 -1
  204. package/dist/types/graph.js.map +0 -1
  205. package/dist/types/identifier.js.map +0 -1
  206. package/dist/types/json/raw.js.map +0 -1
  207. package/dist/types/params.js.map +0 -1
  208. package/dist/types/record.js.map +0 -1
  209. package/dist/types/request.js.map +0 -1
  210. package/dist/types/runtime.js.map +0 -1
  211. package/dist/types/schema/concepts.js.map +0 -1
  212. package/dist/types/schema/fields.js.map +0 -1
  213. package/dist/types/schema/fields.type-test.js.map +0 -1
  214. package/dist/types/spec/document.js.map +0 -1
  215. package/dist/types/spec/error.js.map +0 -1
  216. package/dist/types/spec/json-api-raw.js.map +0 -1
  217. package/dist/types/symbols.js.map +0 -1
  218. package/dist/types/utils.js.map +0 -1
  219. package/dist/types.js.map +0 -1
@@ -0,0 +1,1605 @@
1
+ import type { Graph } from "../../graph/-private.js";
2
+ import type { Future } from "../../request.js";
3
+ import type { RequestManager } from "../../request/-private/manager.js";
4
+ import type { Cache } from "../../types/cache.js";
5
+ import type { StableExistingRecordIdentifier, StableRecordIdentifier } from "../../types/identifier.js";
6
+ import type { TypedRecordInstance, TypeFromInstance } from "../../types/record.js";
7
+ import type { CollectionResourceDocument, EmptyResourceDocument, JsonApiDocument, ResourceIdentifierObject, SingleResourceDocument } from "../../types/spec/json-api-raw.js";
8
+ import type { Type } from "../../types/symbols.js";
9
+ import type { CacheCapabilitiesManager } from "../-types/q/cache-capabilities-manager.js";
10
+ import type { ModelSchema } from "../-types/q/ds-model.js";
11
+ import type { OpaqueRecordInstance } from "../-types/q/record-instance.js";
12
+ import type { SchemaService } from "../-types/q/schema-service.js";
13
+ import type { FindAllOptions, FindRecordOptions, LegacyResourceQuery, QueryOptions } from "../-types/q/store.js";
14
+ import type { StoreRequestInput } from "./cache-handler/handler.js";
15
+ import type { CachePolicy } from "./cache-handler/types.js";
16
+ import { IdentifierCache } from "./caches/identifier-cache.js";
17
+ import { InstanceCache, storeFor } from "./caches/instance-cache.js";
18
+ import type RecordReference from "./legacy-model-support/record-reference.js";
19
+ import NotificationManager from "./managers/notification-manager.js";
20
+ import { RecordArrayManager } from "./managers/record-array-manager.js";
21
+ import { RequestStateService } from "./network/request-cache.js";
22
+ import type { Collection, IdentifierArray } from "./record-arrays/identifier-array.js";
23
+ export { storeFor };
24
+ // We inline this list of methods to avoid importing EmberObject
25
+ type EmberObjectKey = "_debugContainerKey" | "_super" | "addObserver" | "cacheFor" | "concatenatedProperties" | "decrementProperty" | "destroy" | "get" | "getProperties" | "incrementProperty" | "init" | "isDestroyed" | "isDestroying" | "mergedProperties" | "notifyPropertyChange" | "removeObserver" | "reopen" | "set" | "setProperties" | "toggleProperty" | "toString" | "willDestroy";
26
+ type DSModelKeys = "___(unique) Symbol(Store)" | "___private_notifications" | "___recordState" | "_createSnapshot" | "adapterError" | "attr" | "belongsTo" | "changedAttributes" | "currentState" | "deleteRecord" | "destroyRecord" | "dirtyType" | "eachAttribute" | "eachRelationship" | "errors" | "hasDirtyAttributes" | "hasMany" | "inverseFor" | "isDeleted" | "isEmpty" | "isError" | "isLoaded" | "isLoading" | "isNew" | "isReloading" | "isSaving" | "isValid" | "relationshipFor" | "reload" | "rollbackAttributes" | "save" | "serialize" | "store" | "unloadRecord";
27
+ type DownlevelArrays<T> = T extends Array<infer U> ? U[] : T;
28
+ type AwaitedKeys<T> = { [K in keyof T & string] : DownlevelArrays<Awaited<T[K]>> };
29
+ // `AwaitedKeys` is needed here to resolve any promise types like `PromiseBelongsTo`.
30
+ type FilteredKeys<T> = AwaitedKeys<Omit<T, typeof Type | EmberObjectKey | DSModelKeys | "constructor">>;
31
+ type MaybeHasId = {
32
+ id?: string | null;
33
+ };
34
+ /**
35
+ * Currently only records that extend object can be created via
36
+ * store.createRecord. This is a limitation of the current API,
37
+ * but can be worked around by creating a new identifier, running
38
+ * the cache.clientDidCreate method, and then peeking the record
39
+ * for the identifier.
40
+ *
41
+ * To assign primary key to a record during creation, only `id` will
42
+ * work correctly for `store.createRecord`, other primary key may be
43
+ * handled by updating the record after creation or using the flow
44
+ * described above.
45
+ *
46
+ * TODO: These are limitations we want to (and can) address. If you
47
+ * have need of lifting these limitations, please open an issue.
48
+ *
49
+ */
50
+ export type CreateRecordProperties<T = MaybeHasId & Record<string, unknown>> = T extends TypedRecordInstance ? Partial<FilteredKeys<T>> : T extends MaybeHasId ? MaybeHasId & Partial<FilteredKeys<T>> : MaybeHasId & Record<string, unknown>;
51
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
52
+ type ConstructorFunction = new (...args: any[]) => any;
53
+ // eslint-disable-next-line @typescript-eslint/no-extraneous-class
54
+ declare const EmptyClass: ConstructorFunction;
55
+ declare const BaseClass: typeof EmptyClass;
56
+ export interface Store {
57
+ createCache(capabilities: CacheCapabilitiesManager): Cache;
58
+ /**
59
+ * A hook which an app or addon may implement. Called when
60
+ * the Store is attempting to create a Record Instance for
61
+ * a resource.
62
+ *
63
+ * This hook can be used to select or instantiate any desired
64
+ * mechanism of presenting cache data to the ui for access
65
+ * mutation, and interaction.
66
+ *
67
+ * @param identifier - The Resource CacheKey
68
+ * @param createRecordArgs - An object containing any properties passed to `store.createRecord`
69
+ * @return A record instance
70
+ * @public
71
+ */
72
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
73
+ instantiateRecord<T>(identifier: StableRecordIdentifier, createRecordArgs: {
74
+ [key: string]: unknown;
75
+ }): OpaqueRecordInstance;
76
+ /**
77
+ * A hook which an app or addon may implement. Called when
78
+ * the Store is destroying a Record Instance. This hook should
79
+ * be used to teardown any custom record instances instantiated
80
+ * with `instantiateRecord`.
81
+ *
82
+ * @public
83
+ * @param record
84
+ */
85
+ teardownRecord(record: OpaqueRecordInstance): void;
86
+ /**
87
+ * This hook enables an app to supply a SchemaService
88
+ * for use when information about a resource's schema needs
89
+ * to be queried.
90
+ *
91
+ * This method will only be called once to instantiate the singleton
92
+ * service, which can then be accessed via `store.schema`.
93
+ *
94
+ * For Example, to use the default SchemaService for ReactiveResource
95
+ *
96
+ * ```ts
97
+ * import { SchemaService } from '@warp-drive/schema-record';
98
+ *
99
+ * class extends Store {
100
+ * createSchemaService() {
101
+ * return new SchemaService();
102
+ * }
103
+ * }
104
+ * ```
105
+ *
106
+ * Or to use the SchemaService for @ember-data/model
107
+ *
108
+ * ```ts
109
+ * import { buildSchema } from '@ember-data/model';
110
+ *
111
+ * class extends Store {
112
+ * createSchemaService() {
113
+ * return buildSchema(this);
114
+ * }
115
+ * }
116
+ * ```
117
+ *
118
+ * If you wish to chain services, you must either
119
+ * instantiate each schema source directly or super to retrieve
120
+ * an existing service. For convenience, when migrating from
121
+ * `@ember-data/model` to `@warp-drive/schema-record` a
122
+ * SchemaService is provided that handles this transition
123
+ * for you:
124
+ *
125
+ * ```ts
126
+ * import { DelegatingSchemaService } from '@ember-data/model/migration-support';
127
+ * import { SchemaService } from '@warp-drive/schema-record';
128
+ *
129
+ * class extends Store {
130
+ * createSchemaService() {
131
+ * const schema = new SchemaService();
132
+ * return new DelegatingSchemaService(this, schema);
133
+ * }
134
+ * }
135
+ * ```
136
+ *
137
+ * When using the DelegateSchemaService, the schema will first
138
+ * be sourced from directly registered schemas, then will fallback
139
+ * to sourcing a schema from available models if no schema is found.
140
+ *
141
+ * @return {SchemaService}
142
+ * @public
143
+ */
144
+ createSchemaService(): SchemaService;
145
+ /**
146
+ * DEPRECATED - Use the property `store.schema` instead.
147
+ *
148
+ * Provides access to the SchemaDefinitionService instance
149
+ * for this Store instance.
150
+ *
151
+ * The SchemaDefinitionService can be used to query for
152
+ * information about the schema of a resource.
153
+ *
154
+ * @deprecated
155
+ * @public
156
+ */
157
+ getSchemaDefinitionService(): SchemaService;
158
+ /**
159
+ * DEPRECATED - Use `createSchemaService` instead.
160
+ *
161
+ * Allows an app to register a custom SchemaService
162
+ * for use when information about a resource's schema needs
163
+ * to be queried.
164
+ *
165
+ * This method can only be called more than once, but only one schema
166
+ * definition service may exist. Therefore if you wish to chain services
167
+ * you must lookup the existing service and close over it with the new
168
+ * service by accessing `store.schema` prior to registration.
169
+ *
170
+ * For Example:
171
+ *
172
+ * ```ts
173
+ * import Store from '@ember-data/store';
174
+ *
175
+ * class SchemaDelegator {
176
+ * constructor(schema) {
177
+ * this._schema = schema;
178
+ * }
179
+ *
180
+ * hasResource(resource: { type: string }): boolean {
181
+ * if (AbstractSchemas.has(resource.type)) {
182
+ * return true;
183
+ * }
184
+ * return this._schema.hasResource(resource);
185
+ * }
186
+ *
187
+ * attributesDefinitionFor(identifier: RecordIdentifier | { type: string }): AttributesSchema {
188
+ * return this._schema.attributesDefinitionFor(identifier);
189
+ * }
190
+ *
191
+ * relationshipsDefinitionFor(identifier: RecordIdentifier | { type: string }): RelationshipsSchema {
192
+ * const schema = AbstractSchemas.get(identifier.type);
193
+ * return schema || this._schema.relationshipsDefinitionFor(identifier);
194
+ * }
195
+ * }
196
+ *
197
+ * export default class extends Store {
198
+ * constructor(...args) {
199
+ * super(...args);
200
+ *
201
+ * const schema = this.createSchemaService();
202
+ * this.registerSchemaDefinitionService(new SchemaDelegator(schema));
203
+ * }
204
+ * }
205
+ * ```
206
+ *
207
+ * @param {SchemaService} schema
208
+ * @deprecated
209
+ * @public
210
+ */
211
+ registerSchemaDefinitionService(schema: SchemaService): void;
212
+ /**
213
+ * DEPRECATED - Use `createSchemaService` instead.
214
+ *
215
+ * Allows an app to register a custom SchemaService
216
+ * for use when information about a resource's schema needs
217
+ * to be queried.
218
+ *
219
+ * This method can only be called more than once, but only one schema
220
+ * definition service may exist. Therefore if you wish to chain services
221
+ * you must lookup the existing service and close over it with the new
222
+ * service by accessing `store.schema` prior to registration.
223
+ *
224
+ * For Example:
225
+ *
226
+ * ```ts
227
+ * import Store from '@ember-data/store';
228
+ *
229
+ * class SchemaDelegator {
230
+ * constructor(schema) {
231
+ * this._schema = schema;
232
+ * }
233
+ *
234
+ * hasResource(resource: { type: string }): boolean {
235
+ * if (AbstractSchemas.has(resource.type)) {
236
+ * return true;
237
+ * }
238
+ * return this._schema.hasResource(resource);
239
+ * }
240
+ *
241
+ * attributesDefinitionFor(identifier: RecordIdentifier | { type: string }): AttributesSchema {
242
+ * return this._schema.attributesDefinitionFor(identifier);
243
+ * }
244
+ *
245
+ * relationshipsDefinitionFor(identifier: RecordIdentifier | { type: string }): RelationshipsSchema {
246
+ * const schema = AbstractSchemas.get(identifier.type);
247
+ * return schema || this._schema.relationshipsDefinitionFor(identifier);
248
+ * }
249
+ * }
250
+ *
251
+ * export default class extends Store {
252
+ * constructor(...args) {
253
+ * super(...args);
254
+ *
255
+ * const schema = this.schema;
256
+ * this.registerSchema(new SchemaDelegator(schema));
257
+ * }
258
+ * }
259
+ * ```
260
+ *
261
+ * @param {SchemaService} schema
262
+ * @deprecated
263
+ * @public
264
+ */
265
+ registerSchema(schema: SchemaService): void;
266
+ }
267
+ /**
268
+ * ```ts
269
+ * import { Store } from '@warp-drive/core';
270
+ * ```
271
+ *
272
+ * The `Store` is the central piece of the ***Warp*Drive** experience. It connects
273
+ * requests for data with schemas, caching and reactivity.
274
+ *
275
+ * While it's easy to use ***just*** ***Warp*Drive**'s request management, most projects will find they
276
+ * require far more than basic fetch management. For this reason it's often best to start with a `Store`
277
+ * even when you aren't sure yet.
278
+ *
279
+ * Most projects will only have a single `Store`, though using multiple distinct stores
280
+ * is possible.
281
+ *
282
+ * @public
283
+ * @hideconstructor
284
+ */
285
+ export declare class Store extends BaseClass {
286
+ /** @internal */
287
+ readonly recordArrayManager: RecordArrayManager;
288
+ /**
289
+ * Provides access to the NotificationManager associated
290
+ * with this Store instance.
291
+ *
292
+ * The NotificationManager can be used to subscribe to
293
+ * changes to the cache.
294
+ *
295
+ * @public
296
+ */
297
+ readonly notifications: NotificationManager;
298
+ /**
299
+ * Provides access to the SchemaService instance
300
+ * for this Store instance.
301
+ *
302
+ * The SchemaService can be used to query for
303
+ * information about the schema of a resource.
304
+ *
305
+ * @public
306
+ */
307
+ get schema(): ReturnType<this["createSchemaService"]>;
308
+ /** @internal */
309
+ _schema: SchemaService;
310
+ /**
311
+ * Provides access to the IdentifierCache instance
312
+ * for this store.
313
+ *
314
+ * The IdentifierCache can be used to generate or
315
+ * retrieve a stable unique identifier for any resource.
316
+ *
317
+ * @public
318
+ */
319
+ readonly identifierCache: IdentifierCache;
320
+ /**
321
+ * Provides access to the requestManager instance associated
322
+ * with this Store instance.
323
+ *
324
+ * When using `ember-data` this property is automatically
325
+ * set to an instance of `RequestManager`. When not using `ember-data`
326
+ * you must configure this property yourself, either by declaring
327
+ * it as a service or by initializing it.
328
+ *
329
+ * ```ts
330
+ * import Store, { CacheHandler } from '@ember-data/store';
331
+ * import RequestManager from '@ember-data/request';
332
+ * import Fetch from '@ember-data/request/fetch';
333
+ *
334
+ * class extends Store {
335
+ * requestManager = new RequestManager()
336
+ * .use([Fetch])
337
+ * .useCache(CacheHandler);
338
+ * }
339
+ * ```
340
+ *
341
+ * @public
342
+ */
343
+ requestManager: RequestManager;
344
+ /**
345
+ * A Property which an App may set to provide a CachePolicy
346
+ * to control when a cached request becomes stale.
347
+ *
348
+ * Note, when defined, these methods will only be invoked if a
349
+ * cache key exists for the request, either because the request
350
+ * contains `cacheOptions.key` or because the [IdentifierCache](/ember-data/release/classes/IdentifierCache)
351
+ * was able to generate a key for the request using the configured
352
+ * [generation method](/ember-data/release/functions/@ember-data%2Fstore/setIdentifierGenerationMethod).
353
+ *
354
+ * `isSoftExpired` will only be invoked if `isHardExpired` returns `false`.
355
+ *
356
+ * ```ts
357
+ * store.lifetimes = {
358
+ * // make the request and ignore the current cache state
359
+ * isHardExpired(identifier: StableDocumentIdentifier): boolean {
360
+ * return false;
361
+ * }
362
+ *
363
+ * // make the request in the background if true, return cache state
364
+ * isSoftExpired(identifier: StableDocumentIdentifier): boolean {
365
+ * return false;
366
+ * }
367
+ * }
368
+ * ```
369
+ *
370
+ * @public
371
+ */
372
+ lifetimes?: CachePolicy;
373
+ // Private
374
+ /** @internal */
375
+ _graph?: Graph;
376
+ /** @internal */
377
+ _requestCache: RequestStateService;
378
+ /** @internal */
379
+ _instanceCache: InstanceCache;
380
+ /** @internal */
381
+ _cbs: {
382
+ coalesce?: () => void;
383
+ sync?: () => void;
384
+ notify?: () => void;
385
+ } | null;
386
+ /** @internal */
387
+ _forceShim: boolean;
388
+ /**
389
+ * Async flush buffers notifications until flushed
390
+ * by finalization of a future configured by store.request
391
+ *
392
+ * This is useful for ensuring that notifications are delivered
393
+ * prior to the promise resolving but without risk of promise
394
+ * interleaving.
395
+ *
396
+ * @internal
397
+ */
398
+ _enableAsyncFlush: boolean | null;
399
+ // DEBUG-only properties
400
+ /** @internal */
401
+ DISABLE_WAITER?: boolean;
402
+ /** @internal */
403
+ _isDestroying: boolean;
404
+ /** @internal */
405
+ _isDestroyed: boolean;
406
+ /** @internal */
407
+ get isDestroying(): boolean;
408
+ /** @internal */
409
+ set isDestroying(value: boolean);
410
+ /** @internal */
411
+ get isDestroyed(): boolean;
412
+ /** @internal */
413
+ set isDestroyed(value: boolean);
414
+ /**
415
+ @private
416
+ */
417
+ constructor(createArgs?: unknown);
418
+ /** @internal */
419
+ _run(cb: () => void): void;
420
+ /**
421
+ * Executes the callback, ensurng that any work that calls
422
+ * store._schedule is executed after in the right order.
423
+ *
424
+ * When queues already exist, scheduled callbacks will
425
+ * join the existing queue.
426
+ *
427
+ * @internal
428
+ */
429
+ _join(cb: () => void): void;
430
+ /** @internal */
431
+ _schedule(name: "coalesce" | "sync" | "notify", cb: () => void): void;
432
+ /**
433
+ * Retrieve the RequestStateService instance
434
+ * associated with this Store.
435
+ *
436
+ * This can be used to query the status of requests
437
+ * that have been initiated for a given identifier.
438
+ *
439
+ * @return {RequestStateService}
440
+ * @public
441
+ */
442
+ getRequestStateService(): RequestStateService;
443
+ /** @internal */
444
+ _getAllPending(): (Promise<unknown[]> & {
445
+ length: number;
446
+ }) | void;
447
+ /**
448
+ * ::: tip 💡 For a more complete overview see the [Request Guide](/guides/2-requests/1-overview)
449
+ * :::
450
+ *
451
+ * Issue a request via the configured {@link RequestManager},
452
+ * inserting the response into the {@link Store.cache | cache} and handing
453
+ * back a {@link Future} which resolves to a {@link ReactiveDocument | ReactiveDocument}
454
+ *
455
+ * #### Request Cache Keys
456
+ *
457
+ * Only {@link https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Methods/GET | GET} requests with a url or requests with an explicit
458
+ * {@link CacheOptions.key | cache key} will have the request result
459
+ * and document cached.
460
+ *
461
+ * The cache key used is {@link RequestInfo.cacheOptions | RequestInfo.cacheOptions.key}
462
+ * if present, falling back to {@link RequestInfo.url}.
463
+ *
464
+ * Params are not serialized as part of the cache-key, so
465
+ * either ensure they are already in the url or utilize
466
+ * `requestConfig.cacheOptions.key`. For queries issued
467
+ * via the {@link https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Methods/POST | POST} method `requestConfig.cacheOptions.key`
468
+ * MUST be supplied for the document to be cached.
469
+ *
470
+ * #### Requesting Without a Cache Key
471
+ *
472
+ * Resource data within the request is always updated in the cache,
473
+ * regardless of whether a cache key is present for the request.
474
+ *
475
+ * #### Fulfilling From Cache
476
+ *
477
+ * When a cache-key is determined, the request may fulfill
478
+ * from cache provided the cache is not stale.
479
+ *
480
+ * Cache staleness is determined by the configured {@link CachePolicy}
481
+ * with priority given to the {@link CacheOptions.reload} and
482
+ * {@link CacheOptions.backgroundReload} on the request if present.
483
+ *
484
+ * If the cache data has soft expired or the request asks for a background
485
+ * reload, the request will fulfill from cache if possible and
486
+ * make a non-blocking request in the background to update the cache.
487
+ *
488
+ * If the cache data has hard expired or the request asks for a reload,
489
+ * the request will not fulfill from cache and will make a blocking
490
+ * request to update the cache.
491
+ *
492
+ * #### The Response
493
+ *
494
+ * The primary difference between {@link RequestManager.request} and `store.request`
495
+ * is that `store.request` will convert the response into a {@link ReactiveDocument}
496
+ * containing {@link Store.instantiateRecord | ReactiveResources}.
497
+ *
498
+ * @public
499
+ */
500
+ request<
501
+ RT,
502
+ T = unknown
503
+ >(requestConfig: StoreRequestInput<RT, T>): Future<RT>;
504
+ /**
505
+ Returns the schema for a particular resource type (modelName).
506
+
507
+ When used with Model from @ember-data/model the return is the model class,
508
+ but this is not guaranteed.
509
+
510
+ If looking to query attribute or relationship information it is
511
+ recommended to use `getSchemaDefinitionService` instead. This method
512
+ should be considered legacy and exists primarily to continue to support
513
+ Adapter/Serializer APIs which expect it's return value in their method
514
+ signatures.
515
+
516
+ The class of a model might be useful if you want to get a list of all the
517
+ relationship names of the model, see
518
+ [`relationshipNames`](/ember-data/release/classes/Model?anchor=relationshipNames)
519
+ for example.
520
+
521
+ @public
522
+ @deprecated
523
+ @param {String} type
524
+ @return {ModelSchema}
525
+ */
526
+ modelFor<T>(type: TypeFromInstance<T>): ModelSchema<T>;
527
+ modelFor(type: string): ModelSchema;
528
+ /**
529
+ Create a new record in the current store. The properties passed
530
+ to this method are set on the newly created record.
531
+
532
+ To create a new instance of a `Post`:
533
+
534
+ ```js
535
+ store.createRecord('post', {
536
+ title: 'Ember is awesome!'
537
+ });
538
+ ```
539
+
540
+ To create a new instance of a `Post` that has a relationship with a `User` record:
541
+
542
+ ```js
543
+ let user = this.store.peekRecord('user', '1');
544
+ store.createRecord('post', {
545
+ title: 'Ember is awesome!',
546
+ user: user
547
+ });
548
+ ```
549
+
550
+ @public
551
+ @param {String} type the name of the resource
552
+ @param {Object} inputProperties a hash of properties to set on the
553
+ newly created record.
554
+ @return {Model} record
555
+ */
556
+ createRecord<T>(type: TypeFromInstance<T>, inputProperties: CreateRecordProperties<T>): T;
557
+ createRecord(type: string, inputProperties: CreateRecordProperties): OpaqueRecordInstance;
558
+ /**
559
+ For symmetry, a record can be deleted via the store.
560
+
561
+ Example
562
+
563
+ ```javascript
564
+ let post = store.createRecord('post', {
565
+ title: 'Ember is awesome!'
566
+ });
567
+
568
+ store.deleteRecord(post);
569
+ ```
570
+
571
+ @public
572
+ @param {unknown} record
573
+ */
574
+ deleteRecord<T>(record: T): void;
575
+ /**
576
+ For symmetry, a record can be unloaded via the store.
577
+ This will cause the record to be destroyed and freed up for garbage collection.
578
+
579
+ Example
580
+
581
+ ```javascript
582
+ const { content: { data: post } } = await store.request(findRecord({ type: 'post', id: '1' }));
583
+ store.unloadRecord(post);
584
+ ```
585
+
586
+ @public
587
+ @param {Model} record
588
+ */
589
+ unloadRecord<T>(record: T): void;
590
+ /**
591
+ This method returns a record for a given identifier or type and id combination.
592
+
593
+ The `findRecord` method will always resolve its promise with the same
594
+ object for a given identifier or type and `id`.
595
+
596
+ The `findRecord` method will always return a **promise** that will be
597
+ resolved with the record.
598
+
599
+ **Example 1**
600
+
601
+ ```js [app/routes/post.js]
602
+ export default class PostRoute extends Route {
603
+ model({ post_id }) {
604
+ return this.store.findRecord('post', post_id);
605
+ }
606
+ }
607
+ ```
608
+
609
+ **Example 2**
610
+
611
+ `findRecord` can be called with a single identifier argument instead of the combination
612
+ of `type` (modelName) and `id` as separate arguments. You may recognize this combo as
613
+ the typical pairing from [JSON:API](https://jsonapi.org/format/#document-resource-object-identification)
614
+
615
+ ```js [app/routes/post.js]
616
+ export default class PostRoute extends Route {
617
+ model({ post_id: id }) {
618
+ return this.store.findRecord({ type: 'post', id });
619
+ }
620
+ }
621
+ ```
622
+
623
+ **Example 3**
624
+
625
+ If you have previously received an lid via an Identifier for this record, and the record
626
+ has already been assigned an id, you can find the record again using just the lid.
627
+
628
+ ```js [app/routes/post.js]
629
+ store.findRecord({ lid });
630
+ ```
631
+
632
+ If the record is not yet available, the store will ask the adapter's `findRecord`
633
+ method to retrieve and supply the necessary data. If the record is already present
634
+ in the store, it depends on the reload behavior _when_ the returned promise
635
+ resolves.
636
+
637
+ ### Preloading
638
+
639
+ You can optionally `preload` specific attributes and relationships that you know of
640
+ by passing them via the passed `options`.
641
+
642
+ For example, if your Ember route looks like `/posts/1/comments/2` and your API route
643
+ for the comment also looks like `/posts/1/comments/2` if you want to fetch the comment
644
+ without also fetching the post you can pass in the post to the `findRecord` call:
645
+
646
+ ```js [app/routes/post-comments.js]
647
+ export default class PostRoute extends Route {
648
+ model({ post_id, comment_id: id }) {
649
+ return this.store.findRecord({ type: 'comment', id, { preload: { post: post_id }} });
650
+ }
651
+ }
652
+ ```
653
+
654
+ In your adapter you can then access this id without triggering a network request via the
655
+ snapshot:
656
+
657
+ ```js [app/adapters/application.js]
658
+ export default class Adapter {
659
+
660
+ findRecord(store, schema, id, snapshot) {
661
+ let type = schema.modelName;
662
+
663
+ if (type === 'comment')
664
+ let postId = snapshot.belongsTo('post', { id: true });
665
+
666
+ return fetch(`./posts/${postId}/comments/${id}`)
667
+ .then(response => response.json())
668
+ }
669
+ }
670
+
671
+ static create() {
672
+ return new this();
673
+ }
674
+ }
675
+ ```
676
+
677
+ This could also be achieved by supplying the post id to the adapter via the adapterOptions
678
+ property on the options hash.
679
+
680
+ ```js [app/routes/post-comments.js]
681
+ export default class PostRoute extends Route {
682
+ model({ post_id, comment_id: id }) {
683
+ return this.store.findRecord({ type: 'comment', id, { adapterOptions: { post: post_id }} });
684
+ }
685
+ }
686
+ ```
687
+
688
+ ```js [app/adapters/application.js]
689
+ export default class Adapter {
690
+ findRecord(store, schema, id, snapshot) {
691
+ let type = schema.modelName;
692
+
693
+ if (type === 'comment')
694
+ let postId = snapshot.adapterOptions.post;
695
+
696
+ return fetch(`./posts/${postId}/comments/${id}`)
697
+ .then(response => response.json())
698
+ }
699
+ }
700
+
701
+ static create() {
702
+ return new this();
703
+ }
704
+ }
705
+ ```
706
+
707
+ If you have access to the post model you can also pass the model itself to preload:
708
+
709
+ ```javascript
710
+ let post = await store.findRecord('post', '1');
711
+ let comment = await store.findRecord('comment', '2', { post: myPostModel });
712
+ ```
713
+
714
+ ### Reloading
715
+
716
+ The reload behavior is configured either via the passed `options` hash or
717
+ the result of the adapter's `shouldReloadRecord`.
718
+
719
+ If `{ reload: true }` is passed or `adapter.shouldReloadRecord` evaluates
720
+ to `true`, then the returned promise resolves once the adapter returns
721
+ data, regardless if the requested record is already in the store:
722
+
723
+ ```js
724
+ store.push({
725
+ data: {
726
+ id: 1,
727
+ type: 'post',
728
+ revision: 1
729
+ }
730
+ });
731
+
732
+ // adapter#findRecord resolves with
733
+ // [
734
+ // {
735
+ // id: 1,
736
+ // type: 'post',
737
+ // revision: 2
738
+ // }
739
+ // ]
740
+ store.findRecord('post', '1', { reload: true }).then(function(post) {
741
+ post.revision; // 2
742
+ });
743
+ ```
744
+
745
+ If no reload is indicated via the above mentioned ways, then the promise
746
+ immediately resolves with the cached version in the store.
747
+
748
+ ### Background Reloading
749
+
750
+ Optionally, if `adapter.shouldBackgroundReloadRecord` evaluates to `true`,
751
+ then a background reload is started, which updates the records' data, once
752
+ it is available:
753
+
754
+ ```js
755
+ // app/adapters/post.js
756
+ import ApplicationAdapter from "./application";
757
+
758
+ export default class PostAdapter extends ApplicationAdapter {
759
+ shouldReloadRecord(store, snapshot) {
760
+ return false;
761
+ },
762
+
763
+ shouldBackgroundReloadRecord(store, snapshot) {
764
+ return true;
765
+ }
766
+ });
767
+
768
+ // ...
769
+
770
+ store.push({
771
+ data: {
772
+ id: 1,
773
+ type: 'post',
774
+ revision: 1
775
+ }
776
+ });
777
+
778
+ let blogPost = store.findRecord('post', '1').then(function(post) {
779
+ post.revision; // 1
780
+ });
781
+
782
+ // later, once adapter#findRecord resolved with
783
+ // [
784
+ // {
785
+ // id: 1,
786
+ // type: 'post',
787
+ // revision: 2
788
+ // }
789
+ // ]
790
+
791
+ blogPost.revision; // 2
792
+ ```
793
+
794
+ If you would like to force or prevent background reloading, you can set a
795
+ boolean value for `backgroundReload` in the options object for
796
+ `findRecord`.
797
+
798
+ ```js [app/routes/post/edit.js]
799
+ export default class PostEditRoute extends Route {
800
+ model(params) {
801
+ return this.store.findRecord('post', params.post_id, { backgroundReload: false });
802
+ }
803
+ }
804
+ ```
805
+
806
+ If you pass an object on the `adapterOptions` property of the options
807
+ argument it will be passed to your adapter via the snapshot
808
+
809
+ ```js [app/routes/post/edit.js]
810
+ export default class PostEditRoute extends Route {
811
+ model(params) {
812
+ return this.store.findRecord('post', params.post_id, {
813
+ adapterOptions: { subscribe: false }
814
+ });
815
+ }
816
+ }
817
+ ```
818
+
819
+ ```js [app/adapters/post.js]
820
+ import MyCustomAdapter from './custom-adapter';
821
+
822
+ export default class PostAdapter extends MyCustomAdapter {
823
+ findRecord(store, type, id, snapshot) {
824
+ if (snapshot.adapterOptions.subscribe) {
825
+ // ...
826
+ }
827
+ // ...
828
+ }
829
+ }
830
+ ```
831
+
832
+ See [peekRecord](../methods/peekRecord?anchor=peekRecord) to get the cached version of a record.
833
+
834
+ ### Retrieving Related Model Records
835
+
836
+ If you use an adapter such as Ember's default
837
+ [`JSONAPIAdapter`](/ember-data/release/classes/JSONAPIAdapter)
838
+ that supports the [JSON API specification](http://jsonapi.org/) and if your server
839
+ endpoint supports the use of an
840
+ ['include' query parameter](http://jsonapi.org/format/#fetching-includes),
841
+ you can use `findRecord()` or `findAll()` to automatically retrieve additional records related to
842
+ the one you request by supplying an `include` parameter in the `options` object.
843
+
844
+ For example, given a `post` model that has a `hasMany` relationship with a `comment`
845
+ model, when we retrieve a specific post we can have the server also return that post's
846
+ comments in the same request:
847
+
848
+ ```js [app/routes/post.js]
849
+ export default class PostRoute extends Route {
850
+ model(params) {
851
+ return this.store.findRecord('post', params.post_id, { include: ['comments'] });
852
+ }
853
+ }
854
+ ```
855
+
856
+ ```js [app/adapters/application.js]
857
+ export default class Adapter {
858
+ findRecord(store, schema, id, snapshot) {
859
+ let type = schema.modelName;
860
+
861
+ if (type === 'post')
862
+ let includes = snapshot.adapterOptions.include;
863
+
864
+ return fetch(`./posts/${postId}?include=${includes}`)
865
+ .then(response => response.json())
866
+ }
867
+ }
868
+
869
+ static create() {
870
+ return new this();
871
+ }
872
+ }
873
+ ```
874
+
875
+ In this case, the post's comments would then be available in your template as
876
+ `model.comments`.
877
+
878
+ Multiple relationships can be requested using an `include` parameter consisting of a
879
+ list of relationship names, while nested relationships can be specified
880
+ using a dot-separated sequence of relationship names. So to request both the post's
881
+ comments and the authors of those comments the request would look like this:
882
+
883
+ ```js [app/routes/post.js]
884
+ export default class PostRoute extends Route {
885
+ model(params) {
886
+ return this.store.findRecord('post', params.post_id, { include: ['comments','comments.author'] });
887
+ }
888
+ }
889
+ ```
890
+
891
+ ### Retrieving Specific Fields by Type
892
+
893
+ If your server endpoint supports the use of a ['fields' query parameter](https://jsonapi.org/format/#fetching-sparse-fieldsets),
894
+ you can use pass those fields through to your server. At this point in time, this requires a few manual steps on your part.
895
+
896
+ 1. Implement `buildQuery` in your adapter.
897
+
898
+ ```js [app/adapters/application.js]
899
+ buildQuery(snapshot) {
900
+ let query = super.buildQuery(...arguments);
901
+
902
+ let { fields } = snapshot.adapterOptions;
903
+
904
+ if (fields) {
905
+ query.fields = fields;
906
+ }
907
+
908
+ return query;
909
+ }
910
+ ```
911
+
912
+ 2. Then pass through the applicable fields to your `findRecord` request.
913
+
914
+ Given a `post` model with attributes body, title, publishDate and meta, you can retrieve a filtered list of attributes.
915
+
916
+ ```js [app/routes/post.js]
917
+ export default class extends Route {
918
+ model(params) {
919
+ return this.store.findRecord('post', params.post_id, { adapterOptions: { fields: { post: 'body,title' } });
920
+ }
921
+ }
922
+ ```
923
+
924
+ Moreover, you can filter attributes on related models as well. If a `post` has a `belongsTo` relationship to a user,
925
+ just include the relationship key and attributes.
926
+
927
+ ```js [app/routes/post.js]
928
+ export default class extends Route {
929
+ model(params) {
930
+ return this.store.findRecord('post', params.post_id, { adapterOptions: { fields: { post: 'body,title', user: 'name,email' } });
931
+ }
932
+ }
933
+ ```
934
+
935
+ @since 1.13.0
936
+ @public
937
+ @param {String|object} type - either a string representing the name of the resource or a ResourceIdentifier object containing both the type (a string) and the id (a string) for the record or an lid (a string) of an existing record
938
+ @param {(String|Integer|Object)} id - optional object with options for the request only if the first param is a ResourceIdentifier, else the string id of the record to be retrieved
939
+ @param {Object} [options] - if the first param is a string this will be the optional options for the request. See examples for available options.
940
+ @return {Promise} promise
941
+ */
942
+ findRecord<T>(type: TypeFromInstance<T>, id: string | number, options?: FindRecordOptions<T>): Promise<T>;
943
+ findRecord(type: string, id: string | number, options?: FindRecordOptions): Promise<unknown>;
944
+ findRecord<T>(resource: ResourceIdentifierObject<TypeFromInstance<T>>, options?: FindRecordOptions<T>): Promise<T>;
945
+ findRecord(resource: ResourceIdentifierObject, options?: FindRecordOptions): Promise<unknown>;
946
+ /**
947
+ Get the reference for the specified record.
948
+
949
+ Example
950
+
951
+ ```javascript
952
+ let userRef = store.getReference('user', '1');
953
+
954
+ // check if the user is loaded
955
+ let isLoaded = userRef.value() !== null;
956
+
957
+ // get the record of the reference (null if not yet available)
958
+ let user = userRef.value();
959
+
960
+ // get the identifier of the reference
961
+ if (userRef.remoteType() === 'id') {
962
+ let id = userRef.id();
963
+ }
964
+
965
+ // load user (via store.find)
966
+ userRef.load().then(...)
967
+
968
+ // or trigger a reload
969
+ userRef.reload().then(...)
970
+
971
+ // provide data for reference
972
+ userRef.push({ id: 1, username: '@user' }).then(function(user) {
973
+ userRef.value() === user;
974
+ });
975
+ ```
976
+
977
+ @public
978
+ @param {String|object} resource - modelName (string) or Identifier (object)
979
+ @param {String|Integer} id
980
+ @since 2.5.0
981
+ @return {RecordReference}
982
+ */
983
+ // TODO @deprecate getReference (and references generally)
984
+ getReference(resource: string | ResourceIdentifierObject, id: string | number): RecordReference;
985
+ /**
986
+ Get a record by a given type and ID without triggering a fetch.
987
+
988
+ This method will synchronously return the record if it is available in the store,
989
+ otherwise it will return `null`. A record is available if it has been fetched earlier, or
990
+ pushed manually into the store.
991
+
992
+ See [findRecord](../methods/findRecord?anchor=findRecord) if you would like to request this record from the backend.
993
+
994
+ _Note: This is a synchronous method and does not return a promise._
995
+
996
+ **Example 1**
997
+
998
+ ```js
999
+ let post = store.peekRecord('post', '1');
1000
+
1001
+ post.id; // '1'
1002
+ ```
1003
+
1004
+ `peekRecord` can be called with a single identifier argument instead of the combination
1005
+ of `type` (modelName) and `id` as separate arguments. You may recognize this combo as
1006
+ the typical pairing from [JSON:API](https://jsonapi.org/format/#document-resource-object-identification)
1007
+
1008
+ **Example 2**
1009
+
1010
+ ```js
1011
+ let post = store.peekRecord({ type: 'post', id });
1012
+ post.id; // '1'
1013
+ ```
1014
+
1015
+ If you have previously received an lid from an Identifier for this record, you can lookup the record again using
1016
+ just the lid.
1017
+
1018
+ **Example 3**
1019
+
1020
+ ```js
1021
+ let post = store.peekRecord({ lid });
1022
+ post.id; // '1'
1023
+ ```
1024
+
1025
+
1026
+ @since 1.13.0
1027
+ @public
1028
+ @param {String|object} modelName - either a string representing the modelName or a ResourceIdentifier object containing both the type (a string) and the id (a string) for the record or an lid (a string) of an existing record
1029
+ @param {String|Integer} id - optional only if the first param is a ResourceIdentifier, else the string id of the record to be retrieved.
1030
+ @return {Model|null} record
1031
+ */
1032
+ peekRecord<T>(type: TypeFromInstance<T>, id: string | number): T | null;
1033
+ peekRecord(type: string, id: string | number): unknown | null;
1034
+ peekRecord<T>(identifier: ResourceIdentifierObject<TypeFromInstance<T>>): T | null;
1035
+ peekRecord(identifier: ResourceIdentifierObject): unknown | null;
1036
+ /**
1037
+ This method delegates a query to the adapter. This is the one place where
1038
+ adapter-level semantics are exposed to the application.
1039
+
1040
+ Each time this method is called a new request is made through the adapter.
1041
+
1042
+ Exposing queries this way seems preferable to creating an abstract query
1043
+ language for all server-side queries, and then require all adapters to
1044
+ implement them.
1045
+
1046
+ ---
1047
+
1048
+ If you do something like this:
1049
+
1050
+ ```javascript
1051
+ store.query('person', { page: 1 });
1052
+ ```
1053
+
1054
+ The request made to the server will look something like this:
1055
+
1056
+ ```
1057
+ GET "/api/v1/person?page=1"
1058
+ ```
1059
+
1060
+ ---
1061
+
1062
+ If you do something like this:
1063
+
1064
+ ```javascript
1065
+ store.query('person', { ids: ['1', '2', '3'] });
1066
+ ```
1067
+
1068
+ The request made to the server will look something like this:
1069
+
1070
+ ```
1071
+ GET "/api/v1/person?ids%5B%5D=1&ids%5B%5D=2&ids%5B%5D=3"
1072
+ decoded: "/api/v1/person?ids[]=1&ids[]=2&ids[]=3"
1073
+ ```
1074
+
1075
+ This method returns a promise, which is resolved with a
1076
+ [`Collection`](/ember-data/release/classes/Collection)
1077
+ once the server returns.
1078
+
1079
+ @since 1.13.0
1080
+ @public
1081
+ @param {String} type the name of the resource
1082
+ @param {Object} query a query to be used by the adapter
1083
+ @param {Object} options optional, may include `adapterOptions` hash which will be passed to adapter.query
1084
+ @return {Promise} promise
1085
+ */
1086
+ query<T>(type: TypeFromInstance<T>, query: LegacyResourceQuery<T>, options?: QueryOptions): Promise<Collection<T>>;
1087
+ query(type: string, query: LegacyResourceQuery, options?: QueryOptions): Promise<Collection>;
1088
+ /**
1089
+ This method makes a request for one record, where the `id` is not known
1090
+ beforehand (if the `id` is known, use [`findRecord`](../methods/findRecord?anchor=findRecord)
1091
+ instead).
1092
+
1093
+ This method can be used when it is certain that the server will return a
1094
+ single object for the primary data.
1095
+
1096
+ Each time this method is called a new request is made through the adapter.
1097
+
1098
+ Let's assume our API provides an endpoint for the currently logged in user
1099
+ via:
1100
+
1101
+ ```
1102
+ // GET /api/current_user
1103
+ {
1104
+ user: {
1105
+ id: 1234,
1106
+ username: 'admin'
1107
+ }
1108
+ }
1109
+ ```
1110
+
1111
+ Since the specific `id` of the `user` is not known beforehand, we can use
1112
+ `queryRecord` to get the user:
1113
+
1114
+ ```javascript
1115
+ store.queryRecord('user', {}).then(function(user) {
1116
+ let username = user.username;
1117
+ // do thing
1118
+ });
1119
+ ```
1120
+
1121
+ The request is made through the adapters' `queryRecord`:
1122
+
1123
+ ```js [app/adapters/user.js]
1124
+ import Adapter from '@ember-data/adapter';
1125
+ import $ from 'jquery';
1126
+
1127
+ export default class UserAdapter extends Adapter {
1128
+ queryRecord(modelName, query) {
1129
+ return $.getJSON('/api/current_user');
1130
+ }
1131
+ }
1132
+ ```
1133
+
1134
+ Note: the primary use case for `store.queryRecord` is when a single record
1135
+ is queried and the `id` is not known beforehand. In all other cases
1136
+ `store.query` and using the first item of the array is likely the preferred
1137
+ way:
1138
+
1139
+ ```
1140
+ // GET /users?username=unique
1141
+ {
1142
+ data: [{
1143
+ id: 1234,
1144
+ type: 'user',
1145
+ attributes: {
1146
+ username: "unique"
1147
+ }
1148
+ }]
1149
+ }
1150
+ ```
1151
+
1152
+ ```javascript
1153
+ store.query('user', { username: 'unique' }).then(function(users) {
1154
+ return users.firstObject;
1155
+ }).then(function(user) {
1156
+ let id = user.id;
1157
+ });
1158
+ ```
1159
+
1160
+ This method returns a promise, which resolves with the found record.
1161
+
1162
+ If the adapter returns no data for the primary data of the payload, then
1163
+ `queryRecord` resolves with `null`:
1164
+
1165
+ ```
1166
+ // GET /users?username=unique
1167
+ {
1168
+ data: null
1169
+ }
1170
+ ```
1171
+
1172
+ ```javascript
1173
+ store.queryRecord('user', { username: 'unique' }).then(function(user) {
1174
+ // user is null
1175
+ });
1176
+ ```
1177
+
1178
+ @since 1.13.0
1179
+ @public
1180
+ @param {String} type
1181
+ @param {Object} query an opaque query to be used by the adapter
1182
+ @param {Object} options optional, may include `adapterOptions` hash which will be passed to adapter.queryRecord
1183
+ @return {Promise} promise which resolves with the found record or `null`
1184
+ */
1185
+ queryRecord<T>(type: TypeFromInstance<T>, query: LegacyResourceQuery<T>, options?: QueryOptions): Promise<T | null>;
1186
+ queryRecord(type: string, query: LegacyResourceQuery, options?: QueryOptions): Promise<unknown | null>;
1187
+ /**
1188
+ `findAll` asks the adapter's `findAll` method to find the records for the
1189
+ given type, and returns a promise which will resolve with all records of
1190
+ this type present in the store, even if the adapter only returns a subset
1191
+ of them.
1192
+
1193
+ ```js [app/routes/authors.js]
1194
+ export default class AuthorsRoute extends Route {
1195
+ model(params) {
1196
+ return this.store.findAll('author');
1197
+ }
1198
+ }
1199
+ ```
1200
+
1201
+ _When_ the returned promise resolves depends on the reload behavior,
1202
+ configured via the passed `options` hash and the result of the adapter's
1203
+ `shouldReloadAll` method.
1204
+
1205
+ ### Reloading
1206
+
1207
+ If `{ reload: true }` is passed or `adapter.shouldReloadAll` evaluates to
1208
+ `true`, then the returned promise resolves once the adapter returns data,
1209
+ regardless if there are already records in the store:
1210
+
1211
+ ```js
1212
+ store.push({
1213
+ data: {
1214
+ id: 'first',
1215
+ type: 'author'
1216
+ }
1217
+ });
1218
+
1219
+ // adapter#findAll resolves with
1220
+ // [
1221
+ // {
1222
+ // id: 'second',
1223
+ // type: 'author'
1224
+ // }
1225
+ // ]
1226
+ store.findAll('author', { reload: true }).then(function(authors) {
1227
+ authors.getEach('id'); // ['first', 'second']
1228
+ });
1229
+ ```
1230
+
1231
+ If no reload is indicated via the above mentioned ways, then the promise
1232
+ immediately resolves with all the records currently loaded in the store.
1233
+
1234
+ ### Background Reloading
1235
+
1236
+ Optionally, if `adapter.shouldBackgroundReloadAll` evaluates to `true`,
1237
+ then a background reload is started. Once this resolves, the array with
1238
+ which the promise resolves, is updated automatically so it contains all the
1239
+ records in the store:
1240
+
1241
+ ```js [app/adapters/application.js]
1242
+ import Adapter from '@ember-data/adapter';
1243
+
1244
+ export default class ApplicationAdapter extends Adapter {
1245
+ shouldReloadAll(store, snapshotsArray) {
1246
+ return false;
1247
+ },
1248
+
1249
+ shouldBackgroundReloadAll(store, snapshotsArray) {
1250
+ return true;
1251
+ }
1252
+ });
1253
+
1254
+ // ...
1255
+
1256
+ store.push({
1257
+ data: {
1258
+ id: 'first',
1259
+ type: 'author'
1260
+ }
1261
+ });
1262
+
1263
+ let allAuthors;
1264
+ store.findAll('author').then(function(authors) {
1265
+ authors.getEach('id'); // ['first']
1266
+
1267
+ allAuthors = authors;
1268
+ });
1269
+
1270
+ // later, once adapter#findAll resolved with
1271
+ // [
1272
+ // {
1273
+ // id: 'second',
1274
+ // type: 'author'
1275
+ // }
1276
+ // ]
1277
+
1278
+ allAuthors.getEach('id'); // ['first', 'second']
1279
+ ```
1280
+
1281
+ If you would like to force or prevent background reloading, you can set a
1282
+ boolean value for `backgroundReload` in the options object for
1283
+ `findAll`.
1284
+
1285
+ ```js [app/routes/post/edit.js]
1286
+ export default class PostEditRoute extends Route {
1287
+ model() {
1288
+ return this.store.findAll('post', { backgroundReload: false });
1289
+ }
1290
+ }
1291
+ ```
1292
+
1293
+ If you pass an object on the `adapterOptions` property of the options
1294
+ argument it will be passed to you adapter via the `snapshotRecordArray`
1295
+
1296
+ ```js [app/routes/posts.js]
1297
+ export default class PostsRoute extends Route {
1298
+ model(params) {
1299
+ return this.store.findAll('post', {
1300
+ adapterOptions: { subscribe: false }
1301
+ });
1302
+ }
1303
+ }
1304
+ ```
1305
+
1306
+ ```js [app/adapters/post.js]
1307
+ import MyCustomAdapter from './custom-adapter';
1308
+
1309
+ export default class UserAdapter extends MyCustomAdapter {
1310
+ findAll(store, type, sinceToken, snapshotRecordArray) {
1311
+ if (snapshotRecordArray.adapterOptions.subscribe) {
1312
+ // ...
1313
+ }
1314
+ // ...
1315
+ }
1316
+ }
1317
+ ```
1318
+
1319
+ See [peekAll](../methods/peekAll?anchor=peekAll) to get an array of current records in the
1320
+ store, without waiting until a reload is finished.
1321
+
1322
+ ### Retrieving Related Model Records
1323
+
1324
+ If you use an adapter such as Ember's default
1325
+ [`JSONAPIAdapter`](/ember-data/release/classes/JSONAPIAdapter)
1326
+ that supports the [JSON API specification](http://jsonapi.org/) and if your server
1327
+ endpoint supports the use of an
1328
+ ['include' query parameter](http://jsonapi.org/format/#fetching-includes),
1329
+ you can use `findAll()` to automatically retrieve additional records related to
1330
+ those requested by supplying an `include` parameter in the `options` object.
1331
+
1332
+ For example, given a `post` model that has a `hasMany` relationship with a `comment`
1333
+ model, when we retrieve all of the post records we can have the server also return
1334
+ all of the posts' comments in the same request:
1335
+
1336
+ ```js [app/routes/posts.js]
1337
+ export default class PostsRoute extends Route {
1338
+ model() {
1339
+ return this.store.findAll('post', { include: ['comments'] });
1340
+ }
1341
+ }
1342
+ ```
1343
+ Multiple relationships can be requested using an `include` parameter consisting of a
1344
+ list or relationship names, while nested relationships can be specified
1345
+ using a dot-separated sequence of relationship names. So to request both the posts'
1346
+ comments and the authors of those comments the request would look like this:
1347
+
1348
+ ```js [app/routes/posts.js]
1349
+ export default class PostsRoute extends Route {
1350
+ model() {
1351
+ return this.store.findAll('post', { include: ['comments','comments.author'] });
1352
+ }
1353
+ }
1354
+ ```
1355
+
1356
+ See [query](../methods/query?anchor=query) to only get a subset of records from the server.
1357
+
1358
+ @since 1.13.0
1359
+ @public
1360
+ @param {String} type the name of the resource
1361
+ @param {Object} options
1362
+ @return {Promise} promise
1363
+ */
1364
+ findAll<T>(type: TypeFromInstance<T>, options?: FindAllOptions<T>): Promise<IdentifierArray<T>>;
1365
+ findAll(type: string, options?: FindAllOptions): Promise<IdentifierArray>;
1366
+ /**
1367
+ This method returns a filtered array that contains all of the
1368
+ known records for a given type in the store.
1369
+
1370
+ Note that because it's just a filter, the result will contain any
1371
+ locally created records of the type, however, it will not make a
1372
+ request to the backend to retrieve additional records. If you
1373
+ would like to request all the records from the backend please use
1374
+ [store.findAll](../methods/findAll?anchor=findAll).
1375
+
1376
+ Also note that multiple calls to `peekAll` for a given type will always
1377
+ return the same `RecordArray`.
1378
+
1379
+ Example
1380
+
1381
+ ```javascript
1382
+ let localPosts = store.peekAll('post');
1383
+ ```
1384
+
1385
+ @since 1.13.0
1386
+ @public
1387
+ @param {String} type the name of the resource
1388
+ @return {RecordArray}
1389
+ */
1390
+ peekAll<T>(type: TypeFromInstance<T>): IdentifierArray<T>;
1391
+ peekAll(type: string): IdentifierArray;
1392
+ /**
1393
+ This method unloads all records in the store.
1394
+ It schedules unloading to happen during the next run loop.
1395
+
1396
+ Optionally you can pass a type which unload all records for a given type.
1397
+
1398
+ ```javascript
1399
+ store.unloadAll();
1400
+ store.unloadAll('post');
1401
+ ```
1402
+
1403
+ @param {String} type the name of the resource
1404
+ @public
1405
+ */
1406
+ unloadAll<T>(type: TypeFromInstance<T>): void;
1407
+ unloadAll(type?: string): void;
1408
+ /**
1409
+ Push some data for a given type into the store.
1410
+
1411
+ This method expects normalized [JSON API](http://jsonapi.org/) document. This means you have to follow [JSON API specification](http://jsonapi.org/format/) with few minor adjustments:
1412
+ - record's `type` should always be in singular, dasherized form
1413
+ - members (properties) should be camelCased
1414
+
1415
+ [Your primary data should be wrapped inside `data` property](http://jsonapi.org/format/#document-top-level):
1416
+
1417
+ ```js
1418
+ store.push({
1419
+ data: {
1420
+ // primary data for single record of type `Person`
1421
+ id: '1',
1422
+ type: 'person',
1423
+ attributes: {
1424
+ firstName: 'Daniel',
1425
+ lastName: 'Kmak'
1426
+ }
1427
+ }
1428
+ });
1429
+ ```
1430
+
1431
+ [Demo.](http://ember-twiddle.com/fb99f18cd3b4d3e2a4c7)
1432
+
1433
+ `data` property can also hold an array (of records):
1434
+
1435
+ ```js
1436
+ store.push({
1437
+ data: [
1438
+ // an array of records
1439
+ {
1440
+ id: '1',
1441
+ type: 'person',
1442
+ attributes: {
1443
+ firstName: 'Daniel',
1444
+ lastName: 'Kmak'
1445
+ }
1446
+ },
1447
+ {
1448
+ id: '2',
1449
+ type: 'person',
1450
+ attributes: {
1451
+ firstName: 'Tom',
1452
+ lastName: 'Dale'
1453
+ }
1454
+ }
1455
+ ]
1456
+ });
1457
+ ```
1458
+
1459
+ [Demo.](http://ember-twiddle.com/69cdbeaa3702159dc355)
1460
+
1461
+ There are some typical properties for `JSONAPI` payload:
1462
+ * `id` - mandatory, unique record's key
1463
+ * `type` - mandatory string which matches `model`'s dasherized name in singular form
1464
+ * `attributes` - object which holds data for record attributes - `attr`'s declared in model
1465
+ * `relationships` - object which must contain any of the following properties under each relationships' respective key (example path is `relationships.achievements.data`):
1466
+ - [`links`](http://jsonapi.org/format/#document-links)
1467
+ - [`data`](http://jsonapi.org/format/#document-resource-object-linkage) - place for primary data
1468
+ - [`meta`](http://jsonapi.org/format/#document-meta) - object which contains meta-information about relationship
1469
+
1470
+ For this model:
1471
+
1472
+ ```js [app/models/person.js]
1473
+ import Model, { attr, hasMany } from '@ember-data/model';
1474
+
1475
+ export default class PersonRoute extends Route {
1476
+ @attr('string') firstName;
1477
+ @attr('string') lastName;
1478
+
1479
+ @hasMany('person') children;
1480
+ }
1481
+ ```
1482
+
1483
+ To represent the children as IDs:
1484
+
1485
+ ```js
1486
+ {
1487
+ data: {
1488
+ id: '1',
1489
+ type: 'person',
1490
+ attributes: {
1491
+ firstName: 'Tom',
1492
+ lastName: 'Dale'
1493
+ },
1494
+ relationships: {
1495
+ children: {
1496
+ data: [
1497
+ {
1498
+ id: '2',
1499
+ type: 'person'
1500
+ },
1501
+ {
1502
+ id: '3',
1503
+ type: 'person'
1504
+ },
1505
+ {
1506
+ id: '4',
1507
+ type: 'person'
1508
+ }
1509
+ ]
1510
+ }
1511
+ }
1512
+ }
1513
+ }
1514
+ ```
1515
+
1516
+ [Demo.](http://ember-twiddle.com/343e1735e034091f5bde)
1517
+
1518
+ To represent the children relationship as a URL:
1519
+
1520
+ ```js
1521
+ {
1522
+ data: {
1523
+ id: '1',
1524
+ type: 'person',
1525
+ attributes: {
1526
+ firstName: 'Tom',
1527
+ lastName: 'Dale'
1528
+ },
1529
+ relationships: {
1530
+ children: {
1531
+ links: {
1532
+ related: '/people/1/children'
1533
+ }
1534
+ }
1535
+ }
1536
+ }
1537
+ }
1538
+ ```
1539
+
1540
+ If you're streaming data or implementing an adapter, make sure
1541
+ that you have converted the incoming data into this form. The
1542
+ store's [normalize](../methods/normalize?anchor=normalize) method is a convenience
1543
+ helper for converting a json payload into the form Ember Data
1544
+ expects.
1545
+
1546
+ ```js
1547
+ store.push(store.normalize('person', data));
1548
+ ```
1549
+
1550
+ This method can be used both to push in brand new
1551
+ records, as well as to update existing records.
1552
+
1553
+ @public
1554
+ @param {Object} data
1555
+ @return the record(s) that was created or
1556
+ updated.
1557
+ */
1558
+ push(data: EmptyResourceDocument): null;
1559
+ push<T>(data: SingleResourceDocument<TypeFromInstance<T>>): T;
1560
+ push(data: SingleResourceDocument): OpaqueRecordInstance;
1561
+ push<T>(data: CollectionResourceDocument<TypeFromInstance<T>>): T[];
1562
+ push(data: CollectionResourceDocument): OpaqueRecordInstance[];
1563
+ /**
1564
+ Push some data in the form of a json-api document into the store,
1565
+ without creating materialized records.
1566
+
1567
+ @private
1568
+ @param {Object} jsonApiDoc
1569
+ @return {StableRecordIdentifier|Array<StableRecordIdentifier>|null} identifiers for the primary records that had data loaded
1570
+ */
1571
+ _push(jsonApiDoc: JsonApiDocument, asyncFlush?: boolean): StableExistingRecordIdentifier | StableExistingRecordIdentifier[] | null;
1572
+ /**
1573
+ * Trigger a save for a Record.
1574
+ *
1575
+ * Returns a promise resolving with the same record when the save is complete.
1576
+ *
1577
+ * @public
1578
+ * @param {unknown} record
1579
+ * @param options
1580
+ * @return {Promise<record>}
1581
+ */
1582
+ saveRecord<T>(record: T, options?: Record<string, unknown>): Promise<T>;
1583
+ /**
1584
+ * Instantiation hook allowing applications or addons to configure the store
1585
+ * to utilize a custom Cache implementation.
1586
+ *
1587
+ * This hook should not be called directly by consuming applications or libraries.
1588
+ * Use `Store.cache` to access the Cache instance.
1589
+ *
1590
+ * @public
1591
+ * @param storeWrapper
1592
+ * @return {Cache}
1593
+ */
1594
+ /**
1595
+ * Returns the cache instance associated to this Store, instantiates the Cache
1596
+ * if necessary via `Store.createCache`
1597
+ *
1598
+ * @property cache
1599
+ * @type {Cache}
1600
+ * @public
1601
+ */
1602
+ get cache(): ReturnType<this["createCache"]>;
1603
+ destroy(): void;
1604
+ static create(args?: Record<string, unknown>): Store;
1605
+ }