@warp-drive/core 5.6.0-alpha.11
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/CHANGELOG.md +1 -0
- package/LICENSE.md +23 -0
- package/README.md +70 -0
- package/addon-main.cjs +5 -0
- package/cjs-dist/addon-shim.cjs +1 -0
- package/cjs-dist/cjs-set-config.cjs +1 -0
- package/declarations/build-config/babel-macros.d.ts +2 -0
- package/declarations/build-config/babel-macros.d.ts.map +1 -0
- package/declarations/build-config/canary-features.d.ts +2 -0
- package/declarations/build-config/canary-features.d.ts.map +1 -0
- package/declarations/build-config/debugging.d.ts +2 -0
- package/declarations/build-config/debugging.d.ts.map +1 -0
- package/declarations/build-config/deprecations.d.ts +2 -0
- package/declarations/build-config/deprecations.d.ts.map +1 -0
- package/declarations/build-config/env.d.ts +2 -0
- package/declarations/build-config/env.d.ts.map +1 -0
- package/declarations/build-config/macros.d.ts +2 -0
- package/declarations/build-config/macros.d.ts.map +1 -0
- package/declarations/build-config.d.ts +2 -0
- package/declarations/build-config.d.ts.map +1 -0
- package/declarations/configure.d.ts +8 -0
- package/declarations/configure.d.ts.map +1 -0
- package/declarations/graph/-private/-diff.d.ts +33 -0
- package/declarations/graph/-private/-diff.d.ts.map +1 -0
- package/declarations/graph/-private/-edge-definition.d.ts +149 -0
- package/declarations/graph/-private/-edge-definition.d.ts.map +1 -0
- package/declarations/graph/-private/-state.d.ts +10 -0
- package/declarations/graph/-private/-state.d.ts.map +1 -0
- package/declarations/graph/-private/-utils.d.ts +26 -0
- package/declarations/graph/-private/-utils.d.ts.map +1 -0
- package/declarations/graph/-private/coerce-id.d.ts +5 -0
- package/declarations/graph/-private/coerce-id.d.ts.map +1 -0
- package/declarations/graph/-private/debug/assert-polymorphic-type.d.ts +7 -0
- package/declarations/graph/-private/debug/assert-polymorphic-type.d.ts.map +1 -0
- package/declarations/graph/-private/edges/collection.d.ts +40 -0
- package/declarations/graph/-private/edges/collection.d.ts.map +1 -0
- package/declarations/graph/-private/edges/implicit.d.ts +14 -0
- package/declarations/graph/-private/edges/implicit.d.ts.map +1 -0
- package/declarations/graph/-private/edges/resource.d.ts +25 -0
- package/declarations/graph/-private/edges/resource.d.ts.map +1 -0
- package/declarations/graph/-private/graph.d.ts +55 -0
- package/declarations/graph/-private/graph.d.ts.map +1 -0
- package/declarations/graph/-private/normalize-link.d.ts +3 -0
- package/declarations/graph/-private/normalize-link.d.ts.map +1 -0
- package/declarations/graph/-private/operations/add-to-related-records.d.ts +5 -0
- package/declarations/graph/-private/operations/add-to-related-records.d.ts.map +1 -0
- package/declarations/graph/-private/operations/merge-identifier.d.ts +4 -0
- package/declarations/graph/-private/operations/merge-identifier.d.ts.map +1 -0
- package/declarations/graph/-private/operations/remove-from-related-records.d.ts +5 -0
- package/declarations/graph/-private/operations/remove-from-related-records.d.ts.map +1 -0
- package/declarations/graph/-private/operations/replace-related-record.d.ts +4 -0
- package/declarations/graph/-private/operations/replace-related-record.d.ts.map +1 -0
- package/declarations/graph/-private/operations/replace-related-records.d.ts +8 -0
- package/declarations/graph/-private/operations/replace-related-records.d.ts.map +1 -0
- package/declarations/graph/-private/operations/update-relationship.d.ts +11 -0
- package/declarations/graph/-private/operations/update-relationship.d.ts.map +1 -0
- package/declarations/graph/-private.d.ts +14 -0
- package/declarations/graph/-private.d.ts.map +1 -0
- package/declarations/index.d.ts +15 -0
- package/declarations/index.d.ts.map +1 -0
- package/declarations/reactive/-private/document.d.ts +147 -0
- package/declarations/reactive/-private/document.d.ts.map +1 -0
- package/declarations/reactive/-private/fields/compute.d.ts +40 -0
- package/declarations/reactive/-private/fields/compute.d.ts.map +1 -0
- package/declarations/reactive/-private/fields/managed-array.d.ts +23 -0
- package/declarations/reactive/-private/fields/managed-array.d.ts.map +1 -0
- package/declarations/reactive/-private/fields/managed-object.d.ts +21 -0
- package/declarations/reactive/-private/fields/managed-object.d.ts.map +1 -0
- package/declarations/reactive/-private/fields/many-array-manager.d.ts +20 -0
- package/declarations/reactive/-private/fields/many-array-manager.d.ts.map +1 -0
- package/declarations/reactive/-private/hooks.d.ts +6 -0
- package/declarations/reactive/-private/hooks.d.ts.map +1 -0
- package/declarations/reactive/-private/record.d.ts +61 -0
- package/declarations/reactive/-private/record.d.ts.map +1 -0
- package/declarations/reactive/-private/schema.d.ts +180 -0
- package/declarations/reactive/-private/schema.d.ts.map +1 -0
- package/declarations/reactive/-private/symbols.d.ts +11 -0
- package/declarations/reactive/-private/symbols.d.ts.map +1 -0
- package/declarations/reactive/-private.d.ts +2 -0
- package/declarations/reactive/-private.d.ts.map +1 -0
- package/declarations/reactive.d.ts +5 -0
- package/declarations/reactive.d.ts.map +1 -0
- package/declarations/request/-private/context.d.ts +42 -0
- package/declarations/request/-private/context.d.ts.map +1 -0
- package/declarations/request/-private/debug.d.ts +5 -0
- package/declarations/request/-private/debug.d.ts.map +1 -0
- package/declarations/request/-private/fetch.d.ts +40 -0
- package/declarations/request/-private/fetch.d.ts.map +1 -0
- package/declarations/request/-private/future.d.ts +8 -0
- package/declarations/request/-private/future.d.ts.map +1 -0
- package/declarations/request/-private/manager.d.ts +160 -0
- package/declarations/request/-private/manager.d.ts.map +1 -0
- package/declarations/request/-private/promise-cache.d.ts +20 -0
- package/declarations/request/-private/promise-cache.d.ts.map +1 -0
- package/declarations/request/-private/types.d.ts +236 -0
- package/declarations/request/-private/types.d.ts.map +1 -0
- package/declarations/request/-private/utils.d.ts +16 -0
- package/declarations/request/-private/utils.d.ts.map +1 -0
- package/declarations/request.d.ts +6 -0
- package/declarations/request.d.ts.map +1 -0
- package/declarations/store/-private/cache-handler/handler.d.ts +57 -0
- package/declarations/store/-private/cache-handler/handler.d.ts.map +1 -0
- package/declarations/store/-private/cache-handler/types.d.ts +99 -0
- package/declarations/store/-private/cache-handler/types.d.ts.map +1 -0
- package/declarations/store/-private/cache-handler/utils.d.ts +32 -0
- package/declarations/store/-private/cache-handler/utils.d.ts.map +1 -0
- package/declarations/store/-private/caches/cache-utils.d.ts +9 -0
- package/declarations/store/-private/caches/cache-utils.d.ts.map +1 -0
- package/declarations/store/-private/caches/identifier-cache.d.ts +316 -0
- package/declarations/store/-private/caches/identifier-cache.d.ts.map +1 -0
- package/declarations/store/-private/caches/instance-cache.d.ts +65 -0
- package/declarations/store/-private/caches/instance-cache.d.ts.map +1 -0
- package/declarations/store/-private/caches/resource-utils.d.ts +10 -0
- package/declarations/store/-private/caches/resource-utils.d.ts.map +1 -0
- package/declarations/store/-private/debug/utils.d.ts +7 -0
- package/declarations/store/-private/debug/utils.d.ts.map +1 -0
- package/declarations/store/-private/default-cache-policy.d.ts +383 -0
- package/declarations/store/-private/default-cache-policy.d.ts.map +1 -0
- package/declarations/store/-private/legacy-model-support/record-reference.d.ts +164 -0
- package/declarations/store/-private/legacy-model-support/record-reference.d.ts.map +1 -0
- package/declarations/store/-private/legacy-model-support/shim-model-class.d.ts +17 -0
- package/declarations/store/-private/legacy-model-support/shim-model-class.d.ts.map +1 -0
- package/declarations/store/-private/managers/cache-capabilities-manager.d.ts +26 -0
- package/declarations/store/-private/managers/cache-capabilities-manager.d.ts.map +1 -0
- package/declarations/store/-private/managers/cache-manager.d.ts +428 -0
- package/declarations/store/-private/managers/cache-manager.d.ts.map +1 -0
- package/declarations/store/-private/managers/notification-manager.d.ts +93 -0
- package/declarations/store/-private/managers/notification-manager.d.ts.map +1 -0
- package/declarations/store/-private/managers/record-array-manager.d.ts +98 -0
- package/declarations/store/-private/managers/record-array-manager.d.ts.map +1 -0
- package/declarations/store/-private/network/request-cache.d.ts +104 -0
- package/declarations/store/-private/network/request-cache.d.ts.map +1 -0
- package/declarations/store/-private/new-core-tmp/promise-state.d.ts +255 -0
- package/declarations/store/-private/new-core-tmp/promise-state.d.ts.map +1 -0
- package/declarations/store/-private/new-core-tmp/reactivity/configure.d.ts +93 -0
- package/declarations/store/-private/new-core-tmp/reactivity/configure.d.ts.map +1 -0
- package/declarations/store/-private/new-core-tmp/reactivity/internal.d.ts +170 -0
- package/declarations/store/-private/new-core-tmp/reactivity/internal.d.ts.map +1 -0
- package/declarations/store/-private/new-core-tmp/reactivity/signal.d.ts +30 -0
- package/declarations/store/-private/new-core-tmp/reactivity/signal.d.ts.map +1 -0
- package/declarations/store/-private/new-core-tmp/request-state.d.ts +255 -0
- package/declarations/store/-private/new-core-tmp/request-state.d.ts.map +1 -0
- package/declarations/store/-private/record-arrays/identifier-array.d.ts +141 -0
- package/declarations/store/-private/record-arrays/identifier-array.d.ts.map +1 -0
- package/declarations/store/-private/record-arrays/many-array.d.ts +199 -0
- package/declarations/store/-private/record-arrays/many-array.d.ts.map +1 -0
- package/declarations/store/-private/record-arrays/native-proxy-type-fix.d.ts +116 -0
- package/declarations/store/-private/record-arrays/native-proxy-type-fix.d.ts.map +1 -0
- package/declarations/store/-private/store-service.d.ts +1597 -0
- package/declarations/store/-private/store-service.d.ts.map +1 -0
- package/declarations/store/-private/store-service.type-test.d.ts +2 -0
- package/declarations/store/-private/store-service.type-test.d.ts.map +1 -0
- package/declarations/store/-private/utils/coerce-id.d.ts +5 -0
- package/declarations/store/-private/utils/coerce-id.d.ts.map +1 -0
- package/declarations/store/-private/utils/construct-resource.d.ts +7 -0
- package/declarations/store/-private/utils/construct-resource.d.ts.map +1 -0
- package/declarations/store/-private/utils/is-non-empty-string.d.ts +2 -0
- package/declarations/store/-private/utils/is-non-empty-string.d.ts.map +1 -0
- package/declarations/store/-private/utils/normalize-model-name.d.ts +2 -0
- package/declarations/store/-private/utils/normalize-model-name.d.ts.map +1 -0
- package/declarations/store/-private/utils/uuid-polyfill.d.ts +2 -0
- package/declarations/store/-private/utils/uuid-polyfill.d.ts.map +1 -0
- package/declarations/store/-private.d.ts +27 -0
- package/declarations/store/-private.d.ts.map +1 -0
- package/declarations/store/-types/q/cache-capabilities-manager.d.ts +100 -0
- package/declarations/store/-types/q/cache-capabilities-manager.d.ts.map +1 -0
- package/declarations/store/-types/q/ds-model.d.ts +22 -0
- package/declarations/store/-types/q/ds-model.d.ts.map +1 -0
- package/declarations/store/-types/q/identifier.d.ts +21 -0
- package/declarations/store/-types/q/identifier.d.ts.map +1 -0
- package/declarations/store/-types/q/promise-proxies.d.ts +2 -0
- package/declarations/store/-types/q/promise-proxies.d.ts.map +1 -0
- package/declarations/store/-types/q/record-data-json-api.d.ts +31 -0
- package/declarations/store/-types/q/record-data-json-api.d.ts.map +1 -0
- package/declarations/store/-types/q/record-instance.d.ts +24 -0
- package/declarations/store/-types/q/record-instance.d.ts.map +1 -0
- package/declarations/store/-types/q/schema-service.d.ts +331 -0
- package/declarations/store/-types/q/schema-service.d.ts.map +1 -0
- package/declarations/store/-types/q/store.d.ts +35 -0
- package/declarations/store/-types/q/store.d.ts.map +1 -0
- package/declarations/store.d.ts +2 -0
- package/declarations/store.d.ts.map +1 -0
- package/declarations/types/-private.d.ts +14 -0
- package/declarations/types/-private.d.ts.map +1 -0
- package/declarations/types/cache/aliases.d.ts +2 -0
- package/declarations/types/cache/aliases.d.ts.map +1 -0
- package/declarations/types/cache/change.d.ts +7 -0
- package/declarations/types/cache/change.d.ts.map +1 -0
- package/declarations/types/cache/mutations.d.ts +39 -0
- package/declarations/types/cache/mutations.d.ts.map +1 -0
- package/declarations/types/cache/operations.d.ts +72 -0
- package/declarations/types/cache/operations.d.ts.map +1 -0
- package/declarations/types/cache/relationship.d.ts +14 -0
- package/declarations/types/cache/relationship.d.ts.map +1 -0
- package/declarations/types/cache.d.ts +492 -0
- package/declarations/types/cache.d.ts.map +1 -0
- package/declarations/types/graph.d.ts +48 -0
- package/declarations/types/graph.d.ts.map +1 -0
- package/declarations/types/identifier.d.ts +111 -0
- package/declarations/types/identifier.d.ts.map +1 -0
- package/declarations/types/json/raw.d.ts +7 -0
- package/declarations/types/json/raw.d.ts.map +1 -0
- package/declarations/types/params.d.ts +10 -0
- package/declarations/types/params.d.ts.map +1 -0
- package/declarations/types/record.d.ts +96 -0
- package/declarations/types/record.d.ts.map +1 -0
- package/declarations/types/record.type-test.d.ts +2 -0
- package/declarations/types/record.type-test.d.ts.map +1 -0
- package/declarations/types/request.d.ts +308 -0
- package/declarations/types/request.d.ts.map +1 -0
- package/declarations/types/request.type-test.d.ts +2 -0
- package/declarations/types/request.type-test.d.ts.map +1 -0
- package/declarations/types/runtime.d.ts +15 -0
- package/declarations/types/runtime.d.ts.map +1 -0
- package/declarations/types/schema/concepts.d.ts +17 -0
- package/declarations/types/schema/concepts.d.ts.map +1 -0
- package/declarations/types/schema/fields.d.ts +1674 -0
- package/declarations/types/schema/fields.d.ts.map +1 -0
- package/declarations/types/schema/fields.type-test.d.ts +2 -0
- package/declarations/types/schema/fields.type-test.d.ts.map +1 -0
- package/declarations/types/spec/document.d.ts +31 -0
- package/declarations/types/spec/document.d.ts.map +1 -0
- package/declarations/types/spec/error.d.ts +19 -0
- package/declarations/types/spec/error.d.ts.map +1 -0
- package/declarations/types/spec/json-api-raw.d.ts +142 -0
- package/declarations/types/spec/json-api-raw.d.ts.map +1 -0
- package/declarations/types/symbols.d.ts +79 -0
- package/declarations/types/symbols.d.ts.map +1 -0
- package/declarations/types/utils.d.ts +5 -0
- package/declarations/types/utils.d.ts.map +1 -0
- package/declarations/types.d.ts +12 -0
- package/declarations/types.d.ts.map +1 -0
- package/declarations/utils/string.d.ts +45 -0
- package/declarations/utils/string.d.ts.map +1 -0
- package/dist/build-config/babel-macros.js +1 -0
- package/dist/build-config/babel-macros.js.map +1 -0
- package/dist/build-config/canary-features.js +1 -0
- package/dist/build-config/canary-features.js.map +1 -0
- package/dist/build-config/debugging.js +1 -0
- package/dist/build-config/debugging.js.map +1 -0
- package/dist/build-config/deprecations.js +1 -0
- package/dist/build-config/deprecations.js.map +1 -0
- package/dist/build-config/env.js +1 -0
- package/dist/build-config/env.js.map +1 -0
- package/dist/build-config/macros.js +1 -0
- package/dist/build-config/macros.js.map +1 -0
- package/dist/build-config.js +1 -0
- package/dist/build-config.js.map +1 -0
- package/dist/configure-Bz49BEZQ.js +145 -0
- package/dist/configure-Bz49BEZQ.js.map +1 -0
- package/dist/configure.js +1 -0
- package/dist/configure.js.map +1 -0
- package/dist/context-DE5sFezZ.js +636 -0
- package/dist/context-DE5sFezZ.js.map +1 -0
- package/dist/graph/-private.js +3364 -0
- package/dist/graph/-private.js.map +1 -0
- package/dist/handler-DYUefHNU.js +339 -0
- package/dist/handler-DYUefHNU.js.map +1 -0
- package/dist/index.js +382 -0
- package/dist/index.js.map +1 -0
- package/dist/reactive/-private.js +1 -0
- package/dist/reactive/-private.js.map +1 -0
- package/dist/reactive.js +1802 -0
- package/dist/reactive.js.map +1 -0
- package/dist/request-state-Bv5CY_H0.js +7358 -0
- package/dist/request-state-Bv5CY_H0.js.map +1 -0
- package/dist/request.js +1 -0
- package/dist/request.js.map +1 -0
- package/dist/store/-private.js +3 -0
- package/dist/store/-private.js.map +1 -0
- package/dist/store.js +545 -0
- package/dist/store.js.map +1 -0
- package/dist/symbols-DyqeYQTe.js +44 -0
- package/dist/symbols-DyqeYQTe.js.map +1 -0
- package/dist/types/-private.js +79 -0
- package/dist/types/-private.js.map +1 -0
- package/dist/types/cache/aliases.js +0 -0
- package/dist/types/cache/aliases.js.map +1 -0
- package/dist/types/cache/change.js +0 -0
- package/dist/types/cache/change.js.map +1 -0
- package/dist/types/cache/mutations.js +0 -0
- package/dist/types/cache/mutations.js.map +1 -0
- package/dist/types/cache/operations.js +0 -0
- package/dist/types/cache/operations.js.map +1 -0
- package/dist/types/cache/relationship.js +0 -0
- package/dist/types/cache/relationship.js.map +1 -0
- package/dist/types/cache.js +0 -0
- package/dist/types/cache.js.map +1 -0
- package/dist/types/graph.js +0 -0
- package/dist/types/graph.js.map +1 -0
- package/dist/types/identifier.js +89 -0
- package/dist/types/identifier.js.map +1 -0
- package/dist/types/json/raw.js +0 -0
- package/dist/types/json/raw.js.map +1 -0
- package/dist/types/params.js +0 -0
- package/dist/types/params.js.map +1 -0
- package/dist/types/record.js +64 -0
- package/dist/types/record.js.map +1 -0
- package/dist/types/request.js +33 -0
- package/dist/types/request.js.map +1 -0
- package/dist/types/runtime.js +34 -0
- package/dist/types/runtime.js.map +1 -0
- package/dist/types/schema/concepts.js +0 -0
- package/dist/types/schema/concepts.js.map +1 -0
- package/dist/types/schema/fields.js +470 -0
- package/dist/types/schema/fields.js.map +1 -0
- package/dist/types/schema/fields.type-test.js +0 -0
- package/dist/types/schema/fields.type-test.js.map +1 -0
- package/dist/types/spec/document.js +0 -0
- package/dist/types/spec/document.js.map +1 -0
- package/dist/types/spec/error.js +0 -0
- package/dist/types/spec/error.js.map +1 -0
- package/dist/types/spec/json-api-raw.js +0 -0
- package/dist/types/spec/json-api-raw.js.map +1 -0
- package/dist/types/symbols.js +84 -0
- package/dist/types/symbols.js.map +1 -0
- package/dist/types/utils.js +0 -0
- package/dist/types/utils.js.map +1 -0
- package/dist/types.js +0 -0
- package/dist/types.js.map +1 -0
- package/dist/utils/string.js +92 -0
- package/dist/utils/string.js.map +1 -0
- package/logos/NCC-1701-a-blue.svg +4 -0
- package/logos/NCC-1701-a-gold.svg +4 -0
- package/logos/NCC-1701-a-gold_100.svg +1 -0
- package/logos/NCC-1701-a-gold_base-64.txt +1 -0
- package/logos/NCC-1701-a.svg +4 -0
- package/logos/README.md +4 -0
- package/logos/docs-badge.svg +2 -0
- package/logos/ember-data-logo-dark.svg +12 -0
- package/logos/ember-data-logo-light.svg +12 -0
- package/logos/github-header.svg +444 -0
- package/logos/social1.png +0 -0
- package/logos/social2.png +0 -0
- package/logos/warp-drive-logo-dark.svg +4 -0
- package/logos/warp-drive-logo-gold.svg +4 -0
- package/package.json +70 -0
|
@@ -0,0 +1,383 @@
|
|
|
1
|
+
import type { Cache } from '@warp-drive/core/types/cache';
|
|
2
|
+
import type { StableDocumentIdentifier, StableRecordIdentifier } from '@warp-drive/core/types/identifier';
|
|
3
|
+
import type { ImmutableRequestInfo, ResponseInfo, StructuredDocument } from '@warp-drive/core/types/request';
|
|
4
|
+
import type { ResourceDocument } from '@warp-drive/core/types/spec/document';
|
|
5
|
+
type UnsubscribeToken = object;
|
|
6
|
+
type CacheOperation = 'added' | 'removed' | 'updated' | 'state';
|
|
7
|
+
type DocumentCacheOperation = 'invalidated' | 'added' | 'removed' | 'updated' | 'state';
|
|
8
|
+
export interface NotificationCallback {
|
|
9
|
+
(identifier: StableRecordIdentifier, notificationType: 'attributes' | 'relationships', key?: string): void;
|
|
10
|
+
(identifier: StableRecordIdentifier, notificationType: 'errors' | 'meta' | 'identity' | 'state'): void;
|
|
11
|
+
}
|
|
12
|
+
interface ResourceOperationCallback {
|
|
13
|
+
(identifier: StableRecordIdentifier, notificationType: CacheOperation): void;
|
|
14
|
+
}
|
|
15
|
+
interface DocumentOperationCallback {
|
|
16
|
+
(identifier: StableDocumentIdentifier, notificationType: DocumentCacheOperation): void;
|
|
17
|
+
}
|
|
18
|
+
type NotificationManager = {
|
|
19
|
+
subscribe(identifier: StableRecordIdentifier, callback: NotificationCallback): UnsubscribeToken;
|
|
20
|
+
subscribe(identifier: 'resource', callback: ResourceOperationCallback): UnsubscribeToken;
|
|
21
|
+
subscribe(identifier: 'document' | StableDocumentIdentifier, callback: DocumentOperationCallback): UnsubscribeToken;
|
|
22
|
+
notify(identifier: StableRecordIdentifier, value: 'attributes' | 'relationships', key?: string): boolean;
|
|
23
|
+
notify(identifier: StableRecordIdentifier, value: 'errors' | 'meta' | 'identity' | 'state'): boolean;
|
|
24
|
+
notify(identifier: StableRecordIdentifier, value: CacheOperation): boolean;
|
|
25
|
+
notify(identifier: StableDocumentIdentifier, value: DocumentCacheOperation): boolean;
|
|
26
|
+
};
|
|
27
|
+
type Store = {
|
|
28
|
+
cache: Cache;
|
|
29
|
+
notifications: NotificationManager;
|
|
30
|
+
};
|
|
31
|
+
export interface CacheControlValue {
|
|
32
|
+
immutable?: boolean;
|
|
33
|
+
'max-age'?: number;
|
|
34
|
+
'must-revalidate'?: boolean;
|
|
35
|
+
'must-understand'?: boolean;
|
|
36
|
+
'no-cache'?: boolean;
|
|
37
|
+
'no-store'?: boolean;
|
|
38
|
+
'no-transform'?: boolean;
|
|
39
|
+
'only-if-cached'?: boolean;
|
|
40
|
+
private?: boolean;
|
|
41
|
+
'proxy-revalidate'?: boolean;
|
|
42
|
+
public?: boolean;
|
|
43
|
+
's-maxage'?: number;
|
|
44
|
+
'stale-if-error'?: number;
|
|
45
|
+
'stale-while-revalidate'?: number;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Parses a string Cache-Control header value into an object with the following structure:
|
|
49
|
+
*
|
|
50
|
+
* ```ts
|
|
51
|
+
* interface CacheControlValue {
|
|
52
|
+
* immutable?: boolean;
|
|
53
|
+
* 'max-age'?: number;
|
|
54
|
+
* 'must-revalidate'?: boolean;
|
|
55
|
+
* 'must-understand'?: boolean;
|
|
56
|
+
* 'no-cache'?: boolean;
|
|
57
|
+
* 'no-store'?: boolean;
|
|
58
|
+
* 'no-transform'?: boolean;
|
|
59
|
+
* 'only-if-cached'?: boolean;
|
|
60
|
+
* private?: boolean;
|
|
61
|
+
* 'proxy-revalidate'?: boolean;
|
|
62
|
+
* public?: boolean;
|
|
63
|
+
* 's-maxage'?: number;
|
|
64
|
+
* 'stale-if-error'?: number;
|
|
65
|
+
* 'stale-while-revalidate'?: number;
|
|
66
|
+
* }
|
|
67
|
+
* ```
|
|
68
|
+
*
|
|
69
|
+
* @public
|
|
70
|
+
* @param {String} header
|
|
71
|
+
* @return {CacheControlValue}
|
|
72
|
+
*/
|
|
73
|
+
export declare function parseCacheControl(header: string): CacheControlValue;
|
|
74
|
+
/**
|
|
75
|
+
* The configuration options for the {@link DefaultCachePolicy}
|
|
76
|
+
*
|
|
77
|
+
* ```ts
|
|
78
|
+
* import { DefaultCachePolicy } from '@warp-drive/core/store';
|
|
79
|
+
*
|
|
80
|
+
* new DefaultCachePolicy({
|
|
81
|
+
* // ... PolicyConfig Settings ... //
|
|
82
|
+
* });
|
|
83
|
+
* ```
|
|
84
|
+
*
|
|
85
|
+
*/
|
|
86
|
+
export type PolicyConfig = {
|
|
87
|
+
/**
|
|
88
|
+
* the number of milliseconds after which a request is considered
|
|
89
|
+
* stale. If a request is issued again after this time, the request
|
|
90
|
+
* will respond from cache immediately while a background request
|
|
91
|
+
* is made to update the cache.
|
|
92
|
+
*
|
|
93
|
+
* This is calculated against the `date` header of the response.
|
|
94
|
+
*
|
|
95
|
+
* If your API does not provide a `date` header, the `Fetch` handler
|
|
96
|
+
* provided by `@warp-drive/core` will automatically add
|
|
97
|
+
* it to responses if it is not present. Responses without a `date`
|
|
98
|
+
* header will be considered stale immediately.
|
|
99
|
+
*
|
|
100
|
+
*/
|
|
101
|
+
apiCacheSoftExpires: number;
|
|
102
|
+
/**
|
|
103
|
+
* the number of milliseconds after which a request is considered
|
|
104
|
+
* expired and should be re-fetched. If a request is issued again
|
|
105
|
+
* after this time, the request will disregard the cache and
|
|
106
|
+
* wait for a fresh response from the API.
|
|
107
|
+
*
|
|
108
|
+
* This is calculated against the `date` header of the response.
|
|
109
|
+
*
|
|
110
|
+
* If your API does not provide a `date` header, the `Fetch` handler
|
|
111
|
+
* provided by `@warp-drive/core` will automatically add
|
|
112
|
+
* it to responses if it is not present. Responses without a `date`
|
|
113
|
+
* header will be considered hard expired immediately.
|
|
114
|
+
*
|
|
115
|
+
*/
|
|
116
|
+
apiCacheHardExpires: number;
|
|
117
|
+
/**
|
|
118
|
+
* In Testing environments, the `apiCacheSoftExpires` will always be `false`
|
|
119
|
+
* and `apiCacheHardExpires` will use the `apiCacheSoftExpires` value.
|
|
120
|
+
*
|
|
121
|
+
* This helps reduce flakiness and produce predictably rendered results in test suites.
|
|
122
|
+
*
|
|
123
|
+
* Requests that specifically set `cacheOptions.backgroundReload = true` will
|
|
124
|
+
* still be background reloaded in tests.
|
|
125
|
+
*
|
|
126
|
+
* This behavior can be opted out of by setting this value to `true`.
|
|
127
|
+
*
|
|
128
|
+
*/
|
|
129
|
+
disableTestOptimization?: boolean;
|
|
130
|
+
/**
|
|
131
|
+
* In addition to the simple time-based expiration strategy, CachePolicy
|
|
132
|
+
* supports various common server-supplied expiration strategies via
|
|
133
|
+
* headers, as well as custom expiration strategies via the `isExpired`
|
|
134
|
+
* function.
|
|
135
|
+
*
|
|
136
|
+
* Requests will be validated for expiration against these constraints.
|
|
137
|
+
* If any of these constraints are not met, the request will be considered
|
|
138
|
+
* expired. If all constraints are met, the request will be considered
|
|
139
|
+
* valid and the time based expiration strategy will NOT be used.
|
|
140
|
+
*
|
|
141
|
+
* Meeting a constraint means BOTH that the properties the constraint
|
|
142
|
+
* requires are present AND that the expiration time indicated by those
|
|
143
|
+
* properties has not been exceeded.
|
|
144
|
+
*
|
|
145
|
+
* In other words, if the properties for a constraint are not present,
|
|
146
|
+
* this does not count either as meeting or as not meeting the constraint,
|
|
147
|
+
* the constraint simply does not apply.
|
|
148
|
+
*
|
|
149
|
+
* The `isExpired` function is called with the request and should return
|
|
150
|
+
* `true` if the request is expired, `false` if it is not expired, and
|
|
151
|
+
* `null` if the expiration status is unknown.
|
|
152
|
+
*
|
|
153
|
+
* In order constraints are checked:
|
|
154
|
+
*
|
|
155
|
+
* - isExpired function
|
|
156
|
+
* - ↳ (if null) X-WarpDrive-Expires header
|
|
157
|
+
* - ↳ (if null) Cache-Control header
|
|
158
|
+
* - ↳ (if null) Expires header
|
|
159
|
+
*
|
|
160
|
+
*/
|
|
161
|
+
constraints?: {
|
|
162
|
+
/**
|
|
163
|
+
* Headers that should be checked for expiration.
|
|
164
|
+
*
|
|
165
|
+
*/
|
|
166
|
+
headers?: {
|
|
167
|
+
/**
|
|
168
|
+
* Whether the `Cache-Control` header should be checked for expiration.
|
|
169
|
+
* If `true`, then the `max-age` and `s-maxage` directives are used alongside
|
|
170
|
+
* the `Age` and `Date` headers to determine if the expiration time has passed.
|
|
171
|
+
*
|
|
172
|
+
* Other directives are ignored.
|
|
173
|
+
*
|
|
174
|
+
* 'Cache-Control' will take precedence over 'Expires' if both are present
|
|
175
|
+
* and both configured to be checked.
|
|
176
|
+
*
|
|
177
|
+
*/
|
|
178
|
+
'Cache-Control'?: boolean;
|
|
179
|
+
/**
|
|
180
|
+
* Whether the `Expires` header should be checked for expiration.
|
|
181
|
+
*
|
|
182
|
+
* If `true`, then the `Expires` header is used to caclulate the expiration time
|
|
183
|
+
* and determine if the expiration time has passed.
|
|
184
|
+
*
|
|
185
|
+
* 'Cache-Control' will take precedence over 'Expires' if both are present.
|
|
186
|
+
*
|
|
187
|
+
*/
|
|
188
|
+
Expires?: boolean;
|
|
189
|
+
/**
|
|
190
|
+
* Whether the `X-WarpDrive-Expires` header should be checked for expiration.
|
|
191
|
+
*
|
|
192
|
+
* If `true`, then the `X-WarpDrive-Expires` header is used to caclulate the expiration time
|
|
193
|
+
* and determine if the expiration time has passed.
|
|
194
|
+
*
|
|
195
|
+
* This header will take precedence over 'Cache-Control' and 'Expires' if all three are present.
|
|
196
|
+
*
|
|
197
|
+
* The header's value should be a [UTC date string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toUTCString).
|
|
198
|
+
*
|
|
199
|
+
*/
|
|
200
|
+
'X-WarpDrive-Expires'?: boolean;
|
|
201
|
+
};
|
|
202
|
+
/**
|
|
203
|
+
* A function that should be called to determine if the request is expired.
|
|
204
|
+
*
|
|
205
|
+
* If present, this function will be called with the request and should return
|
|
206
|
+
* `true` if the request is expired, `false` if it is not expired, and
|
|
207
|
+
* `null` if the expiration status is unknown.
|
|
208
|
+
*
|
|
209
|
+
* If the function does not return `null`,
|
|
210
|
+
*
|
|
211
|
+
*/
|
|
212
|
+
isExpired?: (request: StructuredDocument<ResourceDocument>) => boolean | null;
|
|
213
|
+
};
|
|
214
|
+
};
|
|
215
|
+
/**
|
|
216
|
+
* A basic CachePolicy that can be added to the Store service.
|
|
217
|
+
*
|
|
218
|
+
* Determines staleness based on time since the request was last received from the API
|
|
219
|
+
* using the `date` header.
|
|
220
|
+
*
|
|
221
|
+
* Determines expiration based on configured constraints as well as a time based
|
|
222
|
+
* expiration strategy based on the `date` header.
|
|
223
|
+
*
|
|
224
|
+
* In order expiration is determined by:
|
|
225
|
+
*
|
|
226
|
+
* - Is explicitly invalidated
|
|
227
|
+
* - ↳ (if null) isExpired function \<IF Constraint Active>
|
|
228
|
+
* - ↳ (if null) X-WarpDrive-Expires header \<IF Constraint Active>
|
|
229
|
+
* - ↳ (if null) Cache-Control header \<IF Constraint Active>
|
|
230
|
+
* - ↳ (if null) Expires header \<IF Constraint Active>
|
|
231
|
+
* - ↳ (if null) Date header + apiCacheHardExpires \< current time
|
|
232
|
+
*
|
|
233
|
+
* Invalidates any request for which `cacheOptions.types` was provided when a createRecord
|
|
234
|
+
* request for that type is successful.
|
|
235
|
+
*
|
|
236
|
+
* For this to work, the `createRecord` request must include the `cacheOptions.types` array
|
|
237
|
+
* with the types that should be invalidated, or its request should specify the identifiers
|
|
238
|
+
* of the records that are being created via `records`. Providing both is valid.
|
|
239
|
+
*
|
|
240
|
+
* > [!NOTE]
|
|
241
|
+
* > only requests that had specified `cacheOptions.types` and occurred prior to the
|
|
242
|
+
* > createRecord request will be invalidated. This means that a given request should always
|
|
243
|
+
* > specify the types that would invalidate it to opt into this behavior. Abstracting this
|
|
244
|
+
* > behavior via builders is recommended to ensure consistency.
|
|
245
|
+
*
|
|
246
|
+
* This allows the Store's CacheHandler to determine if a request is expired and
|
|
247
|
+
* should be refetched upon next request.
|
|
248
|
+
*
|
|
249
|
+
* The `Fetch` handler provided by `@warp-drive/core` will automatically
|
|
250
|
+
* add the `date` header to responses if it is not present.
|
|
251
|
+
*
|
|
252
|
+
* > [!NOTE]
|
|
253
|
+
* > Date headers do not have millisecond precision, so expiration times should
|
|
254
|
+
* > generally be larger than 1000ms.
|
|
255
|
+
*
|
|
256
|
+
* Usage:
|
|
257
|
+
*
|
|
258
|
+
* ```ts
|
|
259
|
+
* import { Store } from '@warp-drive/core';
|
|
260
|
+
* import { DefaultCachePolicy } from '@warp-drive/core/store';
|
|
261
|
+
*
|
|
262
|
+
* export class AppStore extends Store {
|
|
263
|
+
* lifetimes = new DefaultCachePolicy({
|
|
264
|
+
* apiCacheSoftExpires: 30_000,
|
|
265
|
+
* apiCacheHardExpires: 60_000
|
|
266
|
+
* });
|
|
267
|
+
* }
|
|
268
|
+
* ```
|
|
269
|
+
*
|
|
270
|
+
* In Testing environments, the `apiCacheSoftExpires` will always be `false`
|
|
271
|
+
* and `apiCacheHardExpires` will use the `apiCacheSoftExpires` value.
|
|
272
|
+
*
|
|
273
|
+
* This helps reduce flakiness and produce predictably rendered results in test suites.
|
|
274
|
+
*
|
|
275
|
+
* Requests that specifically set `cacheOptions.backgroundReload = true` will
|
|
276
|
+
* still be background reloaded in tests.
|
|
277
|
+
*
|
|
278
|
+
* This behavior can be opted out of by setting `disableTestOptimization = true`
|
|
279
|
+
* in the policy config.
|
|
280
|
+
*
|
|
281
|
+
* @public
|
|
282
|
+
*/
|
|
283
|
+
export declare class DefaultCachePolicy {
|
|
284
|
+
config: PolicyConfig;
|
|
285
|
+
_stores: WeakMap<Store, {
|
|
286
|
+
invalidated: Set<StableDocumentIdentifier>;
|
|
287
|
+
types: Map<string, Set<StableDocumentIdentifier>>;
|
|
288
|
+
}>;
|
|
289
|
+
_getStore(store: Store): {
|
|
290
|
+
invalidated: Set<StableDocumentIdentifier>;
|
|
291
|
+
types: Map<string, Set<StableDocumentIdentifier>>;
|
|
292
|
+
};
|
|
293
|
+
constructor(config: PolicyConfig);
|
|
294
|
+
/**
|
|
295
|
+
* Invalidate a request by its identifier for a given store instance.
|
|
296
|
+
*
|
|
297
|
+
* While the store argument may seem redundant, the CachePolicy
|
|
298
|
+
* is designed to be shared across multiple stores / forks
|
|
299
|
+
* of the store.
|
|
300
|
+
*
|
|
301
|
+
* ```ts
|
|
302
|
+
* store.lifetimes.invalidateRequest(store, identifier);
|
|
303
|
+
* ```
|
|
304
|
+
*
|
|
305
|
+
* @public
|
|
306
|
+
* @param {StableDocumentIdentifier} identifier
|
|
307
|
+
* @param {Store} store
|
|
308
|
+
*/
|
|
309
|
+
invalidateRequest(identifier: StableDocumentIdentifier, store: Store): void;
|
|
310
|
+
/**
|
|
311
|
+
* Invalidate all requests associated to a specific type
|
|
312
|
+
* for a given store instance.
|
|
313
|
+
*
|
|
314
|
+
* While the store argument may seem redundant, the CachePolicy
|
|
315
|
+
* is designed to be shared across multiple stores / forks
|
|
316
|
+
* of the store.
|
|
317
|
+
*
|
|
318
|
+
* This invalidation is done automatically when using this service
|
|
319
|
+
* for both the CacheHandler and the LegacyNetworkHandler.
|
|
320
|
+
*
|
|
321
|
+
* ```ts
|
|
322
|
+
* store.lifetimes.invalidateRequestsForType(store, 'person');
|
|
323
|
+
* ```
|
|
324
|
+
*
|
|
325
|
+
* @public
|
|
326
|
+
* @param {String} type
|
|
327
|
+
* @param {Store} store
|
|
328
|
+
*/
|
|
329
|
+
invalidateRequestsForType(type: string, store: Store): void;
|
|
330
|
+
/**
|
|
331
|
+
* Invoked when a request has been fulfilled from the configured request handlers.
|
|
332
|
+
* This is invoked by the CacheHandler for both foreground and background requests
|
|
333
|
+
* once the cache has been updated.
|
|
334
|
+
*
|
|
335
|
+
* Note, this is invoked by the CacheHandler regardless of whether
|
|
336
|
+
* the request has a cache-key.
|
|
337
|
+
*
|
|
338
|
+
* This method should not be invoked directly by consumers.
|
|
339
|
+
*
|
|
340
|
+
* @public
|
|
341
|
+
* @param {ImmutableRequestInfo} request
|
|
342
|
+
* @param {ImmutableResponse} response
|
|
343
|
+
* @param {Store} store
|
|
344
|
+
* @param {StableDocumentIdentifier | null} identifier
|
|
345
|
+
* @return {void}
|
|
346
|
+
*/
|
|
347
|
+
didRequest(request: ImmutableRequestInfo, response: Response | ResponseInfo | null, identifier: StableDocumentIdentifier | null, store: Store): void;
|
|
348
|
+
/**
|
|
349
|
+
* Invoked to determine if the request may be fulfilled from cache
|
|
350
|
+
* if possible.
|
|
351
|
+
*
|
|
352
|
+
* Note, this is only invoked by the CacheHandler if the request has
|
|
353
|
+
* a cache-key.
|
|
354
|
+
*
|
|
355
|
+
* If no cache entry is found or the entry is hard expired,
|
|
356
|
+
* the request will be fulfilled from the configured request handlers
|
|
357
|
+
* and the cache will be updated before returning the response.
|
|
358
|
+
*
|
|
359
|
+
* @public
|
|
360
|
+
* @param {StableDocumentIdentifier} identifier
|
|
361
|
+
* @param {Store} store
|
|
362
|
+
* @return {Boolean} true if the request is considered hard expired
|
|
363
|
+
*/
|
|
364
|
+
isHardExpired(identifier: StableDocumentIdentifier, store: Store): boolean;
|
|
365
|
+
/**
|
|
366
|
+
* Invoked if `isHardExpired` is false to determine if the request
|
|
367
|
+
* should be update behind the scenes if cache data is already available.
|
|
368
|
+
*
|
|
369
|
+
* Note, this is only invoked by the CacheHandler if the request has
|
|
370
|
+
* a cache-key.
|
|
371
|
+
*
|
|
372
|
+
* If true, the request will be fulfilled from cache while a backgrounded
|
|
373
|
+
* request is made to update the cache via the configured request handlers.
|
|
374
|
+
*
|
|
375
|
+
* @public
|
|
376
|
+
* @param {StableDocumentIdentifier} identifier
|
|
377
|
+
* @param {Store} store
|
|
378
|
+
* @return {Boolean} true if the request is considered soft expired
|
|
379
|
+
*/
|
|
380
|
+
isSoftExpired(identifier: StableDocumentIdentifier, store: Store): boolean;
|
|
381
|
+
}
|
|
382
|
+
export {};
|
|
383
|
+
//# sourceMappingURL=default-cache-policy.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"default-cache-policy.d.ts","sourceRoot":"","sources":["../../../src/store/-private/default-cache-policy.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,8BAA8B,CAAC;AAC1D,OAAO,KAAK,EAAE,wBAAwB,EAAE,sBAAsB,EAAE,MAAM,mCAAmC,CAAC;AAC1G,OAAO,KAAK,EAAE,oBAAoB,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AAC7G,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sCAAsC,CAAC;AAI7E,KAAK,gBAAgB,GA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AwB,GAAG,IAAI,EAC3C,KAAK,EAAE,KAAK,GACX,IAAI;IAgCP;;;;;;;;;;;;;;;OAeG;IACH,aAAa,CAAC,UAAU,EAAE,wBAAwB,EAAE,KAAK,EAAE,KAAK,GAAG,OAAO;IAoB1E;;;;;;;;;;;;;;OAcG;IACH,aAAa,CAAC,UAAU,EAAE,wBAAwB,EAAE,KAAK,EAAE,KAAK,GAAG,OAAO;CA0C3E"}
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
import type { StableRecordIdentifier } from '../../../types/identifier.ts';
|
|
2
|
+
import type { SingleResourceDocument } from '../../../types/spec/json-api-raw.ts';
|
|
3
|
+
import type { OpaqueRecordInstance } from '../../-types/q/record-instance.ts';
|
|
4
|
+
import type { Store } from '../store-service.ts';
|
|
5
|
+
/**
|
|
6
|
+
A `RecordReference` is a low-level API that allows users and
|
|
7
|
+
addon authors to perform meta-operations on a record.
|
|
8
|
+
|
|
9
|
+
@class RecordReference
|
|
10
|
+
@public
|
|
11
|
+
*/
|
|
12
|
+
export default class RecordReference {
|
|
13
|
+
store: Store;
|
|
14
|
+
___token: object;
|
|
15
|
+
___identifier: StableRecordIdentifier;
|
|
16
|
+
_ref: number;
|
|
17
|
+
constructor(store: Store, identifier: StableRecordIdentifier);
|
|
18
|
+
destroy(): void;
|
|
19
|
+
get type(): string;
|
|
20
|
+
/**
|
|
21
|
+
The `id` of the record that this reference refers to.
|
|
22
|
+
|
|
23
|
+
Together, the `type` and `id` properties form a composite key for
|
|
24
|
+
the identity map.
|
|
25
|
+
|
|
26
|
+
Example
|
|
27
|
+
|
|
28
|
+
```javascript
|
|
29
|
+
let userRef = store.getReference('user', 1);
|
|
30
|
+
|
|
31
|
+
userRef.id(); // '1'
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
@public
|
|
35
|
+
@return {String} The id of the record.
|
|
36
|
+
*/
|
|
37
|
+
id(): string | null;
|
|
38
|
+
/**
|
|
39
|
+
The `identifier` of the record that this reference refers to.
|
|
40
|
+
|
|
41
|
+
Together, the `type` and `id` properties form a composite key for
|
|
42
|
+
the identity map.
|
|
43
|
+
|
|
44
|
+
Example
|
|
45
|
+
|
|
46
|
+
```javascript
|
|
47
|
+
let userRef = store.getReference('user', 1);
|
|
48
|
+
|
|
49
|
+
userRef.identifier(); // '1'
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
@public
|
|
53
|
+
@return {String} The identifier of the record.
|
|
54
|
+
*/
|
|
55
|
+
identifier(): StableRecordIdentifier;
|
|
56
|
+
/**
|
|
57
|
+
How the reference will be looked up when it is loaded. Currently
|
|
58
|
+
this always returns `identity` to signify that a record will be
|
|
59
|
+
loaded by its `type` and `id`.
|
|
60
|
+
|
|
61
|
+
Example
|
|
62
|
+
|
|
63
|
+
```javascript
|
|
64
|
+
const userRef = store.getReference('user', 1);
|
|
65
|
+
|
|
66
|
+
userRef.remoteType(); // 'identity'
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
@public
|
|
70
|
+
@return {String} 'identity'
|
|
71
|
+
*/
|
|
72
|
+
remoteType(): 'identity';
|
|
73
|
+
/**
|
|
74
|
+
This API allows you to provide a reference with new data. The
|
|
75
|
+
simplest usage of this API is similar to `store.push`: you provide a
|
|
76
|
+
normalized hash of data and the object represented by the reference
|
|
77
|
+
will update.
|
|
78
|
+
|
|
79
|
+
If you pass a promise to `push`, Ember Data will not ask the adapter
|
|
80
|
+
for the data if another attempt to fetch it is made in the
|
|
81
|
+
interim. When the promise resolves, the underlying object is updated
|
|
82
|
+
with the new data, and the promise returned by *this function* is resolved
|
|
83
|
+
with that object.
|
|
84
|
+
|
|
85
|
+
For example, `recordReference.push(promise)` will be resolved with a
|
|
86
|
+
record.
|
|
87
|
+
|
|
88
|
+
Example
|
|
89
|
+
|
|
90
|
+
```javascript
|
|
91
|
+
let userRef = store.getReference('user', 1);
|
|
92
|
+
|
|
93
|
+
// provide data for reference
|
|
94
|
+
userRef.push({
|
|
95
|
+
data: {
|
|
96
|
+
id: "1",
|
|
97
|
+
type: "user",
|
|
98
|
+
attributes: {
|
|
99
|
+
username: "@user"
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}).then(function(user) {
|
|
103
|
+
userRef.value() === user;
|
|
104
|
+
});
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
@public
|
|
108
|
+
@param objectOrPromise a JSON:API ResourceDocument or a promise resolving to one
|
|
109
|
+
@return a promise for the value (record or relationship)
|
|
110
|
+
*/
|
|
111
|
+
push(objectOrPromise: SingleResourceDocument | Promise<SingleResourceDocument>): Promise<OpaqueRecordInstance>;
|
|
112
|
+
/**
|
|
113
|
+
If the entity referred to by the reference is already loaded, it is
|
|
114
|
+
present as `reference.value`. Otherwise the value returned by this function
|
|
115
|
+
is `null`.
|
|
116
|
+
|
|
117
|
+
Example
|
|
118
|
+
|
|
119
|
+
```javascript
|
|
120
|
+
let userRef = store.getReference('user', 1);
|
|
121
|
+
|
|
122
|
+
userRef.value(); // user
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
@public
|
|
126
|
+
@return {Model} the record for this RecordReference
|
|
127
|
+
*/
|
|
128
|
+
value(): OpaqueRecordInstance | null;
|
|
129
|
+
/**
|
|
130
|
+
Triggers a fetch for the backing entity based on its `remoteType`
|
|
131
|
+
(see `remoteType` definitions per reference type).
|
|
132
|
+
|
|
133
|
+
Example
|
|
134
|
+
|
|
135
|
+
```javascript
|
|
136
|
+
let userRef = store.getReference('user', 1);
|
|
137
|
+
|
|
138
|
+
// load user (via store.find)
|
|
139
|
+
userRef.load().then(...)
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
@public
|
|
143
|
+
@return {Promise<record>} the record for this RecordReference
|
|
144
|
+
*/
|
|
145
|
+
load(): Promise<unknown>;
|
|
146
|
+
/**
|
|
147
|
+
Reloads the record if it is already loaded. If the record is not
|
|
148
|
+
loaded it will load the record via `store.findRecord`
|
|
149
|
+
|
|
150
|
+
Example
|
|
151
|
+
|
|
152
|
+
```javascript
|
|
153
|
+
let userRef = store.getReference('user', 1);
|
|
154
|
+
|
|
155
|
+
// or trigger a reload
|
|
156
|
+
userRef.reload().then(...)
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
@public
|
|
160
|
+
@return {Promise<record>} the record for this RecordReference
|
|
161
|
+
*/
|
|
162
|
+
reload(): Promise<unknown>;
|
|
163
|
+
}
|
|
164
|
+
//# sourceMappingURL=record-reference.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"record-reference.d.ts","sourceRoot":"","sources":["../../../../src/store/-private/legacy-model-support/record-reference.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,8BAA8B,CAAC;AAC3E,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,qCAAqC,CAAC;AAClF,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,mCAAmC,CAAC;AAG9E,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAEjD;;;;;;EAME;AACF,MAAM,CAAC,OAAO,OAAO,eAAe;IAC1B,KAAK,EAAE,KAAK,CAAC;IAErB,QAAQ,EAAG,MAAM,CAAC;IAClB,aAAa,EAAE,sBAAsB,CAAC;IAE9B,IAAI,EAAE,MAAM,CAAC;gBAET,KAAK,EAAE,KAAK,EAAE,UAAU,EAAE,sBAAsB;IAa5D,OAAO;IAIP,IAAI,IAAI,IAAI,MAAM,CAEjB;IAED;;;;;;;;;;;;;;;;MAgBE;IACF,EAAE;IAMF;;;;;;;;;;;;;;;;MAgBE;IACF,UAAU,IAAI,sBAAsB;IAIpC;;;;;;;;;;;;;;;MAeE;IACF,UAAU,IAAI,UAAU;IAIxB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MAqCE;IACF,IAAI,CAAC,eAAe,EAAE,sBAAsB,GAAG,OAAO,CAAC,sBAAsB,CAAC,GAAG,OAAO,CAAC,oBAAoB,CAAC;IAO9G;;;;;;;;;;;;;;;MAeE;IACF,KAAK,IAAI,oBAAoB,GAAG,IAAI;IAIpC;;;;;;;;;;;;;;;MAeE;IACF,IAAI;IAQJ;;;;;;;;;;;;;;;MAeE;IACF,MAAM;CAOP"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { TypedRecordInstance, TypeFromInstance } from '../../../types/record.ts';
|
|
2
|
+
import type { LegacyAttributeField, LegacyRelationshipField } from '../../../types/schema/fields.ts';
|
|
3
|
+
import type { KeyOrString, ModelSchema } from '../../-types/q/ds-model.ts';
|
|
4
|
+
import type { Store } from '../store-service.ts';
|
|
5
|
+
export declare function getShimClass<T>(store: Store, modelName: T extends TypedRecordInstance ? TypeFromInstance<T> : string): ShimModelClass<T>;
|
|
6
|
+
export default class ShimModelClass<T = unknown> implements ModelSchema<T> {
|
|
7
|
+
__store: Store;
|
|
8
|
+
modelName: T extends TypedRecordInstance ? TypeFromInstance<T> : string;
|
|
9
|
+
constructor(store: Store, modelName: T extends TypedRecordInstance ? TypeFromInstance<T> : string);
|
|
10
|
+
get fields(): Map<KeyOrString<T>, 'attribute' | 'belongsTo' | 'hasMany'>;
|
|
11
|
+
get attributes(): Map<KeyOrString<T>, LegacyAttributeField>;
|
|
12
|
+
get relationshipsByName(): Map<KeyOrString<T>, LegacyRelationshipField>;
|
|
13
|
+
eachAttribute<K extends KeyOrString<T>>(callback: (key: K, attribute: LegacyAttributeField) => void, binding?: T): void;
|
|
14
|
+
eachRelationship<K extends KeyOrString<T>>(callback: (key: K, relationship: LegacyRelationshipField) => void, binding?: T): void;
|
|
15
|
+
eachTransformedAttribute<K extends KeyOrString<T>>(callback: (key: K, type: string | null) => void, binding?: T): void;
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=shim-model-class.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shim-model-class.d.ts","sourceRoot":"","sources":["../../../../src/store/-private/legacy-model-support/shim-model-class.ts"],"names":[],"mappings":"A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BAAgB,CAAC,CAAC,SAAS,WAAW,CAAC,CAAC,CAAC,EACvC,QAAQ,EAAE,CAAC,GAAG,EAAE,CAAC,EAAE,YAAY,EAAE,uBAAuB,KAAK,IAAI,EACjE,OAAO,CAAC,EAAE,CAAC;IASb,wBAAwB,CAAC,CAAC,SAAS,WAAW,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC,GAAG,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI,KAAK,IAAI,EAAE,OAAO,CAAC,EAAE,CAAC;CAQhH"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { StableDocumentIdentifier, StableRecordIdentifier } from '../../../types/identifier.ts';
|
|
2
|
+
import type { CacheCapabilitiesManager as StoreWrapper } from '../../-types/q/cache-capabilities-manager.ts';
|
|
3
|
+
import type { SchemaService } from '../../-types/q/schema-service.ts';
|
|
4
|
+
import type { IdentifierCache } from '../caches/identifier-cache.ts';
|
|
5
|
+
import type { Store } from '../store-service.ts';
|
|
6
|
+
import type { NotificationType } from './notification-manager.ts';
|
|
7
|
+
export interface CacheCapabilitiesManager {
|
|
8
|
+
getSchemaDefinitionService(): SchemaService;
|
|
9
|
+
}
|
|
10
|
+
export declare class CacheCapabilitiesManager implements StoreWrapper {
|
|
11
|
+
_willNotify: boolean;
|
|
12
|
+
_pendingNotifies: Map<StableRecordIdentifier, Set<string>>;
|
|
13
|
+
_store: Store;
|
|
14
|
+
constructor(_store: Store);
|
|
15
|
+
get identifierCache(): IdentifierCache;
|
|
16
|
+
_scheduleNotification(identifier: StableRecordIdentifier, key: string): void;
|
|
17
|
+
_flushNotifications(): void;
|
|
18
|
+
notifyChange(identifier: StableRecordIdentifier, namespace: 'added' | 'removed', key: null): void;
|
|
19
|
+
notifyChange(identifier: StableDocumentIdentifier, namespace: 'added' | 'updated' | 'removed', key: null): void;
|
|
20
|
+
notifyChange(identifier: StableRecordIdentifier, namespace: NotificationType, key: string | null): void;
|
|
21
|
+
get schema(): SchemaService;
|
|
22
|
+
setRecordId(identifier: StableRecordIdentifier, id: string): void;
|
|
23
|
+
hasRecord(identifier: StableRecordIdentifier): boolean;
|
|
24
|
+
disconnectRecord(identifier: StableRecordIdentifier): void;
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=cache-capabilities-manager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cache-capabilities-manager.d.ts","sourceRoot":"","sources":["../../../../src/store/-private/managers/cache-capabilities-manager.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,wBAAwB,EAAE,sBAAsB,EAAE,MAAM,8BAA8B,CAAC;AACrG,OAAO,KAAK,EAAE,wBAAwB,IAAI,YAAY,EAAE,MAAM,8CAA8C,CAAC;AAC7G,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kCAAkC,CAAC;AACtE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAErE,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAElE,MAAM,WAAW,wBAAwB;IACvC,0BAA0B,IAAI,aAAa,CAAC;CAC7C;AACD,qBAAa,wBAAyB,YAAW,YAAY;IACnD,WAAW,EAAE,OAAO,CAAC;IACrB,gBAAgB,EAAE,GAAG,CAAC,sBAAsB,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC;IAC3D,MAAM,EAAE,KAAK,CAAC;gBAEV,MAAM,EAAE,KAAK;IAMzB,IAAI,eAAe,IAAI,eAAe,CAErC;IAED,qBAAqB,CAAC,UAAU,EAAE,sBAAsB,EAAE,GAAG,EAAE,MAAM;IAyBrE,mBAAmB,IAAI,IAAI;IAgB3B,YAAY,CAAC,UAAU,EAAE,sBAAsB,EAAE,SAAS,EAAE,OAAO,GAAG,SAAS,EAAE,GAAG,EAAE,IAAI,GAAG,IAAI;IACjG,YAAY,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