@warp-drive/core 5.6.0-alpha.15 → 5.6.0-alpha.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/declarations/build-config/babel-macros.d.ts +1 -2
- package/declarations/build-config/canary-features.d.ts +1 -2
- package/declarations/build-config/debugging.d.ts +1 -2
- package/declarations/build-config/deprecations.d.ts +1 -2
- package/declarations/build-config/env.d.ts +1 -2
- package/declarations/build-config/macros.d.ts +1 -2
- package/declarations/build-config.d.ts +1 -2
- package/declarations/configure.d.ts +6 -7
- package/declarations/graph/-private/-diff.d.ts +21 -22
- package/declarations/graph/-private/-edge-definition.d.ts +134 -135
- package/declarations/graph/-private/-state.d.ts +93 -7
- package/declarations/graph/-private/-utils.d.ts +18 -13
- package/declarations/graph/-private/coerce-id.d.ts +6 -1
- package/declarations/graph/-private/debug/assert-polymorphic-type.d.ts +15 -4
- package/declarations/graph/-private/edges/collection.d.ts +35 -36
- package/declarations/graph/-private/edges/implicit.d.ts +28 -29
- package/declarations/graph/-private/edges/resource.d.ts +19 -20
- package/declarations/graph/-private/graph.d.ts +83 -48
- package/declarations/graph/-private/normalize-link.d.ts +7 -2
- package/declarations/graph/-private/operations/add-to-related-records.d.ts +3 -4
- package/declarations/graph/-private/operations/merge-identifier.d.ts +2 -3
- package/declarations/graph/-private/operations/remove-from-related-records.d.ts +3 -4
- package/declarations/graph/-private/operations/replace-related-record.d.ts +2 -3
- package/declarations/graph/-private/operations/replace-related-records.d.ts +58 -4
- package/declarations/graph/-private/operations/update-relationship.d.ts +11 -9
- package/declarations/graph/-private.d.ts +9 -10
- package/declarations/index.d.ts +11 -12
- package/declarations/reactive/-private/document.d.ts +143 -144
- package/declarations/reactive/-private/fields/compute.d.ts +31 -28
- package/declarations/reactive/-private/fields/extension.d.ts +2 -3
- package/declarations/reactive/-private/fields/managed-array.d.ts +19 -20
- package/declarations/reactive/-private/fields/managed-object.d.ts +16 -16
- package/declarations/reactive/-private/fields/many-array-manager.d.ts +15 -16
- package/declarations/reactive/-private/hooks.d.ts +3 -4
- package/declarations/reactive/-private/record.d.ts +61 -59
- package/declarations/reactive/-private/schema.d.ts +242 -224
- package/declarations/reactive/-private/symbols.d.ts +26 -1
- package/declarations/reactive/-private.d.ts +1 -2
- package/declarations/reactive.d.ts +4 -5
- package/declarations/request/-private/context.d.ts +34 -35
- package/declarations/request/-private/debug.d.ts +2 -3
- package/declarations/request/-private/fetch.d.ts +23 -24
- package/declarations/request/-private/future.d.ts +3 -4
- package/declarations/request/-private/manager.d.ts +159 -157
- package/declarations/request/-private/promise-cache.d.ts +21 -13
- package/declarations/request/-private/types.d.ts +124 -124
- package/declarations/request/-private/utils.d.ts +8 -9
- package/declarations/request.d.ts +5 -6
- package/declarations/store/-private/cache-handler/handler.d.ts +57 -52
- package/declarations/store/-private/cache-handler/types.d.ts +95 -96
- package/declarations/store/-private/cache-handler/utils.d.ts +16 -16
- package/declarations/store/-private/caches/cache-utils.d.ts +7 -4
- package/declarations/store/-private/caches/identifier-cache.d.ts +234 -246
- package/declarations/store/-private/caches/instance-cache.d.ts +47 -47
- package/declarations/store/-private/caches/resource-utils.d.ts +3 -4
- package/declarations/store/-private/debug/utils.d.ts +6 -7
- package/declarations/store/-private/default-cache-policy.d.ts +362 -361
- package/declarations/store/-private/legacy-model-support/record-reference.d.ts +154 -159
- package/declarations/store/-private/legacy-model-support/shim-model-class.d.ts +14 -14
- package/declarations/store/-private/managers/cache-capabilities-manager.d.ts +21 -22
- package/declarations/store/-private/managers/cache-manager.d.ts +440 -425
- package/declarations/store/-private/managers/notification-manager.d.ts +88 -83
- package/declarations/store/-private/managers/record-array-manager.d.ts +89 -90
- package/declarations/store/-private/network/request-cache.d.ts +86 -83
- package/declarations/store/-private/new-core-tmp/promise-state.d.ts +252 -244
- package/declarations/store/-private/new-core-tmp/reactivity/configure.d.ts +154 -155
- package/declarations/store/-private/new-core-tmp/reactivity/internal.d.ts +148 -149
- package/declarations/store/-private/new-core-tmp/reactivity/signal.d.ts +28 -23
- package/declarations/store/-private/new-core-tmp/request-state.d.ts +263 -241
- package/declarations/store/-private/new-core-tmp/request-subscription.d.ts +253 -223
- package/declarations/store/-private/record-arrays/identifier-array.d.ts +125 -121
- package/declarations/store/-private/record-arrays/many-array.d.ts +180 -184
- package/declarations/store/-private/record-arrays/native-proxy-type-fix.d.ts +120 -110
- package/declarations/store/-private/store-service.d.ts +1594 -1586
- package/declarations/store/-private/utils/coerce-id.d.ts +6 -1
- package/declarations/store/-private/utils/construct-resource.d.ts +1 -2
- package/declarations/store/-private/utils/is-non-empty-string.d.ts +0 -1
- package/declarations/store/-private/utils/normalize-model-name.d.ts +0 -1
- package/declarations/store/-private/utils/uuid-polyfill.d.ts +0 -1
- package/declarations/store/-private.d.ts +31 -28
- package/declarations/store/-types/q/cache-capabilities-manager.d.ts +96 -97
- package/declarations/store/-types/q/ds-model.d.ts +17 -18
- package/declarations/store/-types/q/identifier.d.ts +11 -12
- package/declarations/store/-types/q/record-instance.d.ts +16 -17
- package/declarations/store/-types/q/schema-service.d.ts +346 -343
- package/declarations/store/-types/q/store.d.ts +25 -28
- package/declarations/store.d.ts +1 -2
- package/declarations/types/-private.d.ts +16 -8
- package/declarations/types/cache/aliases.d.ts +11 -1
- package/declarations/types/cache/change.d.ts +4 -5
- package/declarations/types/cache/mutations.d.ts +51 -28
- package/declarations/types/cache/operations.d.ts +60 -47
- package/declarations/types/cache/relationship.d.ts +11 -9
- package/declarations/types/cache.d.ts +495 -484
- package/declarations/types/graph.d.ts +31 -32
- package/declarations/types/identifier.d.ts +83 -82
- package/declarations/types/json/raw.d.ts +1 -2
- package/declarations/types/params.d.ts +4 -5
- package/declarations/types/record.d.ts +117 -76
- package/declarations/types/request.d.ts +289 -266
- package/declarations/types/runtime.d.ts +8 -9
- package/declarations/types/schema/concepts.d.ts +19 -13
- package/declarations/types/schema/fields.d.ts +1712 -1713
- package/declarations/types/schema/fields.type-test.d.ts +0 -1
- package/declarations/types/spec/document.d.ts +28 -22
- package/declarations/types/spec/error.d.ts +16 -17
- package/declarations/types/spec/json-api-raw.d.ts +102 -102
- package/declarations/types/symbols.d.ts +74 -75
- package/declarations/types/utils.d.ts +5 -5
- package/declarations/types.d.ts +10 -11
- package/declarations/utils/string.d.ts +43 -40
- package/dist/graph/-private.js +1 -1
- package/dist/{handler-D1C3Innj.js → handler-C2T-IyJK.js} +1 -1
- package/dist/index.js +2 -2
- package/dist/reactive/-private.js +1 -1
- package/dist/reactive.js +42 -73
- package/dist/{request-state-CCOJIj5i.js → request-state-CjLph1LP.js} +275 -261
- package/dist/store/-private.js +2 -2
- package/dist/{symbols-epHW0Vm9.js → symbols-SIstXMLI.js} +1 -1
- package/dist/types/-private.js +1 -1
- package/package.json +4 -4
- package/declarations/build-config/babel-macros.d.ts.map +0 -1
- package/declarations/build-config/canary-features.d.ts.map +0 -1
- package/declarations/build-config/debugging.d.ts.map +0 -1
- package/declarations/build-config/deprecations.d.ts.map +0 -1
- package/declarations/build-config/env.d.ts.map +0 -1
- package/declarations/build-config/macros.d.ts.map +0 -1
- package/declarations/build-config.d.ts.map +0 -1
- package/declarations/configure.d.ts.map +0 -1
- package/declarations/graph/-private/-diff.d.ts.map +0 -1
- package/declarations/graph/-private/-edge-definition.d.ts.map +0 -1
- package/declarations/graph/-private/-state.d.ts.map +0 -1
- package/declarations/graph/-private/-utils.d.ts.map +0 -1
- package/declarations/graph/-private/coerce-id.d.ts.map +0 -1
- package/declarations/graph/-private/debug/assert-polymorphic-type.d.ts.map +0 -1
- package/declarations/graph/-private/edges/collection.d.ts.map +0 -1
- package/declarations/graph/-private/edges/implicit.d.ts.map +0 -1
- package/declarations/graph/-private/edges/resource.d.ts.map +0 -1
- package/declarations/graph/-private/graph.d.ts.map +0 -1
- package/declarations/graph/-private/normalize-link.d.ts.map +0 -1
- package/declarations/graph/-private/operations/add-to-related-records.d.ts.map +0 -1
- package/declarations/graph/-private/operations/merge-identifier.d.ts.map +0 -1
- package/declarations/graph/-private/operations/remove-from-related-records.d.ts.map +0 -1
- package/declarations/graph/-private/operations/replace-related-record.d.ts.map +0 -1
- package/declarations/graph/-private/operations/replace-related-records.d.ts.map +0 -1
- package/declarations/graph/-private/operations/update-relationship.d.ts.map +0 -1
- package/declarations/graph/-private.d.ts.map +0 -1
- package/declarations/index.d.ts.map +0 -1
- package/declarations/reactive/-private/document.d.ts.map +0 -1
- package/declarations/reactive/-private/fields/compute.d.ts.map +0 -1
- package/declarations/reactive/-private/fields/extension.d.ts.map +0 -1
- package/declarations/reactive/-private/fields/managed-array.d.ts.map +0 -1
- package/declarations/reactive/-private/fields/managed-object.d.ts.map +0 -1
- package/declarations/reactive/-private/fields/many-array-manager.d.ts.map +0 -1
- package/declarations/reactive/-private/hooks.d.ts.map +0 -1
- package/declarations/reactive/-private/record.d.ts.map +0 -1
- package/declarations/reactive/-private/schema.d.ts.map +0 -1
- package/declarations/reactive/-private/symbols.d.ts.map +0 -1
- package/declarations/reactive/-private.d.ts.map +0 -1
- package/declarations/reactive.d.ts.map +0 -1
- package/declarations/request/-private/context.d.ts.map +0 -1
- package/declarations/request/-private/debug.d.ts.map +0 -1
- package/declarations/request/-private/fetch.d.ts.map +0 -1
- package/declarations/request/-private/future.d.ts.map +0 -1
- package/declarations/request/-private/manager.d.ts.map +0 -1
- package/declarations/request/-private/promise-cache.d.ts.map +0 -1
- package/declarations/request/-private/types.d.ts.map +0 -1
- package/declarations/request/-private/utils.d.ts.map +0 -1
- package/declarations/request.d.ts.map +0 -1
- package/declarations/store/-private/cache-handler/handler.d.ts.map +0 -1
- package/declarations/store/-private/cache-handler/types.d.ts.map +0 -1
- package/declarations/store/-private/cache-handler/utils.d.ts.map +0 -1
- package/declarations/store/-private/caches/cache-utils.d.ts.map +0 -1
- package/declarations/store/-private/caches/identifier-cache.d.ts.map +0 -1
- package/declarations/store/-private/caches/instance-cache.d.ts.map +0 -1
- package/declarations/store/-private/caches/resource-utils.d.ts.map +0 -1
- package/declarations/store/-private/debug/utils.d.ts.map +0 -1
- package/declarations/store/-private/default-cache-policy.d.ts.map +0 -1
- package/declarations/store/-private/legacy-model-support/record-reference.d.ts.map +0 -1
- package/declarations/store/-private/legacy-model-support/shim-model-class.d.ts.map +0 -1
- package/declarations/store/-private/managers/cache-capabilities-manager.d.ts.map +0 -1
- package/declarations/store/-private/managers/cache-manager.d.ts.map +0 -1
- package/declarations/store/-private/managers/notification-manager.d.ts.map +0 -1
- package/declarations/store/-private/managers/record-array-manager.d.ts.map +0 -1
- package/declarations/store/-private/network/request-cache.d.ts.map +0 -1
- package/declarations/store/-private/new-core-tmp/promise-state.d.ts.map +0 -1
- package/declarations/store/-private/new-core-tmp/reactivity/configure.d.ts.map +0 -1
- package/declarations/store/-private/new-core-tmp/reactivity/internal.d.ts.map +0 -1
- package/declarations/store/-private/new-core-tmp/reactivity/signal.d.ts.map +0 -1
- package/declarations/store/-private/new-core-tmp/request-state.d.ts.map +0 -1
- package/declarations/store/-private/new-core-tmp/request-subscription.d.ts.map +0 -1
- package/declarations/store/-private/record-arrays/identifier-array.d.ts.map +0 -1
- package/declarations/store/-private/record-arrays/many-array.d.ts.map +0 -1
- package/declarations/store/-private/record-arrays/native-proxy-type-fix.d.ts.map +0 -1
- package/declarations/store/-private/store-service.d.ts.map +0 -1
- package/declarations/store/-private/store-service.type-test.d.ts +0 -2
- package/declarations/store/-private/store-service.type-test.d.ts.map +0 -1
- package/declarations/store/-private/utils/coerce-id.d.ts.map +0 -1
- package/declarations/store/-private/utils/construct-resource.d.ts.map +0 -1
- package/declarations/store/-private/utils/is-non-empty-string.d.ts.map +0 -1
- package/declarations/store/-private/utils/normalize-model-name.d.ts.map +0 -1
- package/declarations/store/-private/utils/uuid-polyfill.d.ts.map +0 -1
- package/declarations/store/-private.d.ts.map +0 -1
- package/declarations/store/-types/q/cache-capabilities-manager.d.ts.map +0 -1
- package/declarations/store/-types/q/ds-model.d.ts.map +0 -1
- package/declarations/store/-types/q/identifier.d.ts.map +0 -1
- package/declarations/store/-types/q/promise-proxies.d.ts +0 -2
- package/declarations/store/-types/q/promise-proxies.d.ts.map +0 -1
- package/declarations/store/-types/q/record-data-json-api.d.ts +0 -31
- package/declarations/store/-types/q/record-data-json-api.d.ts.map +0 -1
- package/declarations/store/-types/q/record-instance.d.ts.map +0 -1
- package/declarations/store/-types/q/schema-service.d.ts.map +0 -1
- package/declarations/store/-types/q/store.d.ts.map +0 -1
- package/declarations/store.d.ts.map +0 -1
- package/declarations/types/-private.d.ts.map +0 -1
- package/declarations/types/cache/aliases.d.ts.map +0 -1
- package/declarations/types/cache/change.d.ts.map +0 -1
- package/declarations/types/cache/mutations.d.ts.map +0 -1
- package/declarations/types/cache/operations.d.ts.map +0 -1
- package/declarations/types/cache/relationship.d.ts.map +0 -1
- package/declarations/types/cache.d.ts.map +0 -1
- package/declarations/types/graph.d.ts.map +0 -1
- package/declarations/types/identifier.d.ts.map +0 -1
- package/declarations/types/json/raw.d.ts.map +0 -1
- package/declarations/types/params.d.ts.map +0 -1
- package/declarations/types/record.d.ts.map +0 -1
- package/declarations/types/record.type-test.d.ts +0 -2
- package/declarations/types/record.type-test.d.ts.map +0 -1
- package/declarations/types/request.d.ts.map +0 -1
- package/declarations/types/request.type-test.d.ts +0 -2
- package/declarations/types/request.type-test.d.ts.map +0 -1
- package/declarations/types/runtime.d.ts.map +0 -1
- package/declarations/types/schema/concepts.d.ts.map +0 -1
- package/declarations/types/schema/fields.d.ts.map +0 -1
- package/declarations/types/schema/fields.type-test.d.ts.map +0 -1
- package/declarations/types/spec/document.d.ts.map +0 -1
- package/declarations/types/spec/error.d.ts.map +0 -1
- package/declarations/types/spec/json-api-raw.d.ts.map +0 -1
- package/declarations/types/symbols.d.ts.map +0 -1
- package/declarations/types/utils.d.ts.map +0 -1
- package/declarations/types.d.ts.map +0 -1
- package/declarations/utils/string.d.ts.map +0 -1
- package/dist/build-config/babel-macros.js.map +0 -1
- package/dist/build-config/canary-features.js.map +0 -1
- package/dist/build-config/debugging.js.map +0 -1
- package/dist/build-config/deprecations.js.map +0 -1
- package/dist/build-config/env.js.map +0 -1
- package/dist/build-config/macros.js.map +0 -1
- package/dist/build-config.js.map +0 -1
- package/dist/configure-B48bFHOl.js.map +0 -1
- package/dist/configure.js.map +0 -1
- package/dist/context-COmAnXUQ.js.map +0 -1
- package/dist/graph/-private.js.map +0 -1
- package/dist/handler-D1C3Innj.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/reactive/-private.js.map +0 -1
- package/dist/reactive.js.map +0 -1
- package/dist/request-state-CCOJIj5i.js.map +0 -1
- package/dist/request.js.map +0 -1
- package/dist/store/-private.js.map +0 -1
- package/dist/store.js.map +0 -1
- package/dist/symbols-epHW0Vm9.js.map +0 -1
- package/dist/types/-private.js.map +0 -1
- package/dist/types/cache/aliases.js.map +0 -1
- package/dist/types/cache/change.js.map +0 -1
- package/dist/types/cache/mutations.js.map +0 -1
- package/dist/types/cache/operations.js.map +0 -1
- package/dist/types/cache/relationship.js.map +0 -1
- package/dist/types/cache.js.map +0 -1
- package/dist/types/graph.js.map +0 -1
- package/dist/types/identifier.js.map +0 -1
- package/dist/types/json/raw.js.map +0 -1
- package/dist/types/params.js.map +0 -1
- package/dist/types/record.js.map +0 -1
- package/dist/types/request.js.map +0 -1
- package/dist/types/runtime.js.map +0 -1
- package/dist/types/schema/concepts.js.map +0 -1
- package/dist/types/schema/fields.js.map +0 -1
- package/dist/types/schema/fields.type-test.js.map +0 -1
- package/dist/types/spec/document.js.map +0 -1
- package/dist/types/spec/error.js.map +0 -1
- package/dist/types/spec/json-api-raw.js.map +0 -1
- package/dist/types/symbols.js.map +0 -1
- package/dist/types/utils.js.map +0 -1
- package/dist/types.js.map +0 -1
- package/dist/utils/string.js.map +0 -1
|
@@ -1,316 +1,304 @@
|
|
|
1
|
-
import { type Identifier, type RecordIdentifier, type StableDocumentIdentifier, type StableExistingRecordIdentifier, type StableRecordIdentifier } from
|
|
2
|
-
import type { ImmutableRequestInfo } from
|
|
3
|
-
import type { ExistingResourceIdentifierObject, ResourceIdentifierObject } from
|
|
4
|
-
import type { ForgetMethod, GenerationMethod, KeyInfo, KeyInfoMethod, ResetMethod, UpdateMethod } from
|
|
1
|
+
import { type Identifier, type RecordIdentifier, type StableDocumentIdentifier, type StableExistingRecordIdentifier, type StableRecordIdentifier } from "../../../types/identifier.js";
|
|
2
|
+
import type { ImmutableRequestInfo } from "../../../types/request.js";
|
|
3
|
+
import type { ExistingResourceIdentifierObject, ResourceIdentifierObject } from "../../../types/spec/json-api-raw.js";
|
|
4
|
+
import type { ForgetMethod, GenerationMethod, KeyInfo, KeyInfoMethod, ResetMethod, UpdateMethod } from "../../-types/q/identifier.js";
|
|
5
5
|
type TypeFromIdentifier<T> = T extends {
|
|
6
|
-
|
|
6
|
+
type: infer U;
|
|
7
7
|
} ? U : string;
|
|
8
8
|
type NarrowIdentifierIfPossible<T> = T extends ExistingResourceIdentifierObject ? StableExistingRecordIdentifier<TypeFromIdentifier<T>> : StableRecordIdentifier;
|
|
9
9
|
export declare function isStableIdentifier(identifier: unknown): identifier is StableRecordIdentifier;
|
|
10
10
|
export declare function isDocumentIdentifier(identifier: unknown): identifier is StableDocumentIdentifier;
|
|
11
11
|
interface KeyOptions {
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
lid: IdentifierMap;
|
|
13
|
+
id: IdentifierMap;
|
|
14
14
|
}
|
|
15
15
|
type TypeMap = {
|
|
16
|
-
|
|
16
|
+
[key: string]: KeyOptions;
|
|
17
17
|
};
|
|
18
|
+
// type IdentifierTypeLookup = { all: Set<StableRecordIdentifier>; id: Map<string, StableRecordIdentifier> };
|
|
19
|
+
// type IdentifiersByType = Map<string, IdentifierTypeLookup>;
|
|
18
20
|
type IdentifierMap = Map<string, StableRecordIdentifier>;
|
|
19
21
|
type StableCache = {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
22
|
+
resources: IdentifierMap;
|
|
23
|
+
documents: Map<string, StableDocumentIdentifier>;
|
|
24
|
+
resourcesByType: TypeMap;
|
|
25
|
+
polymorphicLidBackMap: Map<string, string[]>;
|
|
24
26
|
};
|
|
25
27
|
export type MergeMethod = (targetIdentifier: StableRecordIdentifier, matchedIdentifier: StableRecordIdentifier, resourceData: unknown) => StableRecordIdentifier;
|
|
26
28
|
/**
|
|
27
|
-
|
|
29
|
+
Configures how unique identifier lid strings are generated by @ember-data/store.
|
|
28
30
|
|
|
29
|
-
|
|
31
|
+
This configuration MUST occur prior to the store instance being created.
|
|
30
32
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
+
Takes a method which can expect to receive various data as its first argument
|
|
34
|
+
and the name of a bucket as its second argument.
|
|
33
35
|
|
|
34
|
-
|
|
36
|
+
Currently there are two buckets, 'record' and 'document'.
|
|
35
37
|
|
|
36
|
-
|
|
38
|
+
### Resource (`Record`) Identity
|
|
37
39
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
40
|
+
If the bucket is `record` the method must return a unique (to at-least
|
|
41
|
+
the given bucket) string identifier for the given data as a string to be
|
|
42
|
+
used as the `lid` of an `Identifier` token.
|
|
41
43
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
44
|
+
This method will only be called by either `getOrCreateRecordIdentifier` or
|
|
45
|
+
`createIdentifierForNewRecord` when an identifier for the supplied data
|
|
46
|
+
is not already known via `lid` or `type + id` combo and one needs to be
|
|
47
|
+
generated or retrieved from a proprietary cache.
|
|
46
48
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
49
|
+
`data` will be the same data argument provided to `getOrCreateRecordIdentifier`
|
|
50
|
+
and in the `createIdentifierForNewRecord` case will be an object with
|
|
51
|
+
only `type` as a key.
|
|
50
52
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
+
```ts
|
|
54
|
+
import { setIdentifierGenerationMethod } from '@warp-drive/core';
|
|
53
55
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
56
|
+
export function initialize(applicationInstance) {
|
|
57
|
+
// note how `count` here is now scoped to the application instance
|
|
58
|
+
// for our generation method by being inside the closure provided
|
|
59
|
+
// by the initialize function
|
|
60
|
+
let count = 0;
|
|
59
61
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
62
|
+
setIdentifierGenerationMethod((resource, bucket) => {
|
|
63
|
+
return resource.lid || `my-key-${count++}`;
|
|
64
|
+
});
|
|
65
|
+
}
|
|
64
66
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
67
|
+
export default {
|
|
68
|
+
name: 'configure-ember-data-identifiers',
|
|
69
|
+
initialize
|
|
70
|
+
};
|
|
71
|
+
```
|
|
70
72
|
|
|
71
|
-
|
|
73
|
+
### Document Identity
|
|
72
74
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
75
|
+
If the bucket is `document` the method will receive the associated
|
|
76
|
+
immutable `request` passed to `store.request` as its first argument
|
|
77
|
+
and should return a unique string for the given request if the document
|
|
78
|
+
should be cached, and `null` if it should not be cached.
|
|
77
79
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
80
|
+
Note, the request result will still be passed to the cache via `Cache.put`,
|
|
81
|
+
but caches should take this as a signal that the document should not itself
|
|
82
|
+
be cached, while its contents may still be used to update other cache state.
|
|
81
83
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
84
|
+
The presence of `cacheOptions.key` on the request will take precedence
|
|
85
|
+
for the document cache key, and this method will not be called if it is
|
|
86
|
+
present.
|
|
85
87
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
88
|
+
The default method implementation for this bucket is to return `null`
|
|
89
|
+
for all requests whose method is not `GET`, and to return the `url` for
|
|
90
|
+
those where it is.
|
|
89
91
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
+
This means that queries via `POST` MUST provide `cacheOptions.key` or
|
|
93
|
+
implement this hook.
|
|
92
94
|
|
|
93
|
-
|
|
95
|
+
⚠️ Caution: Requests that do not have a `method` assigned are assumed to be `GET`
|
|
94
96
|
|
|
95
|
-
|
|
97
|
+
@public
|
|
96
98
|
*/
|
|
97
99
|
export declare function setIdentifierGenerationMethod(method: GenerationMethod | null): void;
|
|
98
100
|
/**
|
|
99
|
-
|
|
100
|
-
|
|
101
|
+
Configure a callback for when the identifier cache encounters new resource
|
|
102
|
+
data for an existing resource.
|
|
101
103
|
|
|
102
|
-
|
|
104
|
+
This configuration MUST occur prior to the store instance being created.
|
|
103
105
|
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
106
|
+
```js
|
|
107
|
+
import { setIdentifierUpdateMethod } from '@warp-drive/core';
|
|
108
|
+
```
|
|
107
109
|
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
110
|
+
Takes a method which can expect to receive an existing `Identifier` alongside
|
|
111
|
+
some new data to consider as a second argument. This is an opportunity
|
|
112
|
+
for secondary lookup tables and caches associated with the identifier
|
|
113
|
+
to be amended.
|
|
112
114
|
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
115
|
+
This method is called everytime `updateRecordIdentifier` is called and
|
|
116
|
+
with the same arguments. It provides the opportunity to update secondary
|
|
117
|
+
lookup tables for existing identifiers.
|
|
116
118
|
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
119
|
+
It will always be called after an identifier created with `createIdentifierForNewRecord`
|
|
120
|
+
has been committed, or after an update to the `record` a `RecordIdentifier`
|
|
121
|
+
is assigned to has been committed. Committed here meaning that the server
|
|
122
|
+
has acknowledged the update (for instance after a call to `.save()`)
|
|
121
123
|
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
124
|
+
If `id` has not previously existed, it will be assigned to the `Identifier`
|
|
125
|
+
prior to this `UpdateMethod` being called; however, calls to the parent method
|
|
126
|
+
`updateRecordIdentifier` that attempt to change the `id` or calling update
|
|
127
|
+
without providing an `id` when one is missing will throw an error.
|
|
126
128
|
|
|
127
|
-
|
|
129
|
+
@public
|
|
128
130
|
*/
|
|
129
131
|
export declare function setIdentifierUpdateMethod(method: UpdateMethod | null): void;
|
|
130
132
|
/**
|
|
131
|
-
|
|
133
|
+
Configure a callback for when the identifier cache is going to release an identifier.
|
|
132
134
|
|
|
133
|
-
|
|
135
|
+
This configuration MUST occur prior to the store instance being created.
|
|
134
136
|
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
137
|
+
```js
|
|
138
|
+
import { setIdentifierForgetMethod } from '@warp-drive/core';
|
|
139
|
+
```
|
|
138
140
|
|
|
139
|
-
|
|
140
|
-
|
|
141
|
+
Takes method which can expect to receive an existing `Identifier` that should be eliminated
|
|
142
|
+
from any secondary lookup tables or caches that the user has populated for it.
|
|
141
143
|
|
|
142
|
-
|
|
144
|
+
@public
|
|
143
145
|
*/
|
|
144
146
|
export declare function setIdentifierForgetMethod(method: ForgetMethod | null): void;
|
|
145
147
|
/**
|
|
146
|
-
|
|
148
|
+
Configure a callback for when the identifier cache is being torn down.
|
|
147
149
|
|
|
148
|
-
|
|
150
|
+
This configuration MUST occur prior to the store instance being created.
|
|
149
151
|
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
152
|
+
```js
|
|
153
|
+
import { setIdentifierResetMethod } from '@warp-drive/core';
|
|
154
|
+
```
|
|
153
155
|
|
|
154
|
-
|
|
156
|
+
Takes a method which can expect to be called when the parent application is destroyed.
|
|
155
157
|
|
|
156
|
-
|
|
157
|
-
|
|
158
|
+
If you have properly used a WeakMap to encapsulate the state of your customization
|
|
159
|
+
to the application instance, you may not need to implement the `resetMethod`.
|
|
158
160
|
|
|
159
|
-
|
|
161
|
+
@public
|
|
160
162
|
*/
|
|
161
163
|
export declare function setIdentifierResetMethod(method: ResetMethod | null): void;
|
|
162
164
|
/**
|
|
163
|
-
|
|
164
|
-
|
|
165
|
+
Configure a callback for when the identifier cache is generating a new
|
|
166
|
+
StableRecordIdentifier for a resource.
|
|
165
167
|
|
|
166
|
-
|
|
167
|
-
|
|
168
|
+
This method controls the `type` and `id` that will be assigned to the
|
|
169
|
+
`StableRecordIdentifier` that is created.
|
|
168
170
|
|
|
169
|
-
|
|
171
|
+
This configuration MUST occur prior to the store instance being created.
|
|
170
172
|
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
173
|
+
```js
|
|
174
|
+
import { setKeyInfoForResource } from '@warp-drive/core';
|
|
175
|
+
```
|
|
174
176
|
|
|
175
|
-
|
|
176
|
-
|
|
177
|
+
@public
|
|
178
|
+
*/
|
|
177
179
|
export declare function setKeyInfoForResource(method: KeyInfoMethod | null): void;
|
|
178
180
|
/**
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
181
|
+
* Each instance of {@link Store} receives a unique instance of a IdentifierCache.
|
|
182
|
+
*
|
|
183
|
+
* This cache is responsible for assigning or retrieving the unique identify
|
|
184
|
+
* for arbitrary resource data encountered by the store. Data representing
|
|
185
|
+
* a unique resource or record should always be represented by the same
|
|
186
|
+
* identifier.
|
|
187
|
+
*
|
|
188
|
+
* It can be configured by consuming applications.
|
|
189
|
+
*
|
|
190
|
+
* @hideconstructor
|
|
191
|
+
* @public
|
|
192
|
+
*/
|
|
191
193
|
export declare class IdentifierCache {
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
/**
|
|
302
|
-
Provides the opportunity to eliminate an identifier from secondary lookup tables
|
|
303
|
-
as well as eliminates it from ember-data's own lookup tables and book keeping.
|
|
304
|
-
|
|
305
|
-
Useful when a record has been deleted and the deletion has been persisted and
|
|
306
|
-
we do not care about the record anymore. Especially useful when an `id` of a
|
|
307
|
-
deleted record might be reused later for a new record.
|
|
308
|
-
|
|
309
|
-
@param identifierObject
|
|
310
|
-
@public
|
|
311
|
-
*/
|
|
312
|
-
forgetRecordIdentifier(identifierObject: RecordIdentifier): void;
|
|
313
|
-
destroy(): void;
|
|
194
|
+
/** @internal */
|
|
195
|
+
_cache: StableCache;
|
|
196
|
+
private _generate;
|
|
197
|
+
private _update;
|
|
198
|
+
private _forget;
|
|
199
|
+
private _reset;
|
|
200
|
+
private _merge;
|
|
201
|
+
private _keyInfoForResource;
|
|
202
|
+
private _id;
|
|
203
|
+
constructor();
|
|
204
|
+
/**
|
|
205
|
+
* Internal hook to allow management of merge conflicts with identifiers.
|
|
206
|
+
*
|
|
207
|
+
* we allow late binding of this private internal merge so that
|
|
208
|
+
* the cache can insert itself here to handle elimination of duplicates
|
|
209
|
+
*
|
|
210
|
+
* @private
|
|
211
|
+
*/
|
|
212
|
+
__configureMerge(method: MergeMethod | null): void;
|
|
213
|
+
/** @internal */
|
|
214
|
+
upgradeIdentifier(resource: {
|
|
215
|
+
type: string;
|
|
216
|
+
id: string | null;
|
|
217
|
+
lid?: string;
|
|
218
|
+
}): StableRecordIdentifier;
|
|
219
|
+
/**
|
|
220
|
+
* @private
|
|
221
|
+
*/
|
|
222
|
+
private _getRecordIdentifier;
|
|
223
|
+
private _getRecordIdentifier;
|
|
224
|
+
private _getRecordIdentifier;
|
|
225
|
+
/**
|
|
226
|
+
* allows us to peek without generating when needed
|
|
227
|
+
* useful for the "create" case when we need to see if
|
|
228
|
+
* we are accidentally overwritting something
|
|
229
|
+
*
|
|
230
|
+
* @private
|
|
231
|
+
*/
|
|
232
|
+
peekRecordIdentifier(resource: ResourceIdentifierObject | Identifier): StableRecordIdentifier | undefined;
|
|
233
|
+
/**
|
|
234
|
+
Returns the DocumentIdentifier for the given Request, creates one if it does not yet exist.
|
|
235
|
+
Returns `null` if the request does not have a `cacheKey` or `url`.
|
|
236
|
+
|
|
237
|
+
@public
|
|
238
|
+
*/
|
|
239
|
+
getOrCreateDocumentIdentifier(request: ImmutableRequestInfo): StableDocumentIdentifier | null;
|
|
240
|
+
/**
|
|
241
|
+
Returns the Identifier for the given Resource, creates one if it does not yet exist.
|
|
242
|
+
|
|
243
|
+
Specifically this means that we:
|
|
244
|
+
|
|
245
|
+
- validate the `id` `type` and `lid` combo against known identifiers
|
|
246
|
+
- return an object with an `lid` that is stable (repeated calls with the same
|
|
247
|
+
`id` + `type` or `lid` will return the same `lid` value)
|
|
248
|
+
- this referential stability of the object itself is guaranteed
|
|
249
|
+
|
|
250
|
+
@public
|
|
251
|
+
*/
|
|
252
|
+
getOrCreateRecordIdentifier<T>(resource: T): NarrowIdentifierIfPossible<T>;
|
|
253
|
+
/**
|
|
254
|
+
Returns a new Identifier for the supplied data. Call this method to generate
|
|
255
|
+
an identifier when a new resource is being created local to the client and
|
|
256
|
+
potentially does not have an `id`.
|
|
257
|
+
|
|
258
|
+
Delegates generation to the user supplied `GenerateMethod` if one has been provided
|
|
259
|
+
with the signature `generateMethod({ type }, 'record')`.
|
|
260
|
+
|
|
261
|
+
@public
|
|
262
|
+
*/
|
|
263
|
+
createIdentifierForNewRecord(data: {
|
|
264
|
+
type: string;
|
|
265
|
+
id?: string | null;
|
|
266
|
+
}): StableRecordIdentifier;
|
|
267
|
+
/**
|
|
268
|
+
Provides the opportunity to update secondary lookup tables for existing identifiers
|
|
269
|
+
Called after an identifier created with `createIdentifierForNewRecord` has been
|
|
270
|
+
committed.
|
|
271
|
+
|
|
272
|
+
Assigned `id` to an `Identifier` if `id` has not previously existed; however,
|
|
273
|
+
attempting to change the `id` or calling update without providing an `id` when
|
|
274
|
+
one is missing will throw an error.
|
|
275
|
+
|
|
276
|
+
- sets `id` (if `id` was previously `null`)
|
|
277
|
+
- `lid` and `type` MUST NOT be altered post creation
|
|
278
|
+
|
|
279
|
+
If a merge occurs, it is possible the returned identifier does not match the originally
|
|
280
|
+
provided identifier. In this case the abandoned identifier will go through the usual
|
|
281
|
+
`forgetRecordIdentifier` codepaths.
|
|
282
|
+
|
|
283
|
+
@public
|
|
284
|
+
*/
|
|
285
|
+
updateRecordIdentifier(identifierObject: RecordIdentifier, data: unknown): StableRecordIdentifier;
|
|
286
|
+
/**
|
|
287
|
+
* @private
|
|
288
|
+
*/
|
|
289
|
+
_mergeRecordIdentifiers(keyInfo: KeyInfo, identifier: StableRecordIdentifier, existingIdentifier: StableRecordIdentifier, data: unknown): StableRecordIdentifier;
|
|
290
|
+
/**
|
|
291
|
+
Provides the opportunity to eliminate an identifier from secondary lookup tables
|
|
292
|
+
as well as eliminates it from ember-data's own lookup tables and book keeping.
|
|
293
|
+
|
|
294
|
+
Useful when a record has been deleted and the deletion has been persisted and
|
|
295
|
+
we do not care about the record anymore. Especially useful when an `id` of a
|
|
296
|
+
deleted record might be reused later for a new record.
|
|
297
|
+
|
|
298
|
+
@public
|
|
299
|
+
*/
|
|
300
|
+
forgetRecordIdentifier(identifierObject: RecordIdentifier): void;
|
|
301
|
+
/** @internal */
|
|
302
|
+
destroy(): void;
|
|
314
303
|
}
|
|
315
304
|
export {};
|
|
316
|
-
//# sourceMappingURL=identifier-cache.d.ts.map
|