@warp-drive/core 5.7.0-alpha.13 → 5.7.0-alpha.14
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/reactive/-private/symbols.d.ts +0 -1
- package/declarations/request/-private/fetch.d.ts +2 -2
- package/declarations/request/-private/utils.d.ts +44 -2
- package/declarations/store/-private/cache-handler/types.d.ts +1 -1
- package/declarations/store/-private/managers/notification-manager.d.ts +4 -7
- package/declarations/store/-private/managers/record-array-manager.d.ts +72 -21
- package/declarations/store/-private/new-core-tmp/reactivity/signal.d.ts +1 -0
- package/declarations/store/-private/record-arrays/-utils.d.ts +82 -0
- package/declarations/store/-private/record-arrays/legacy-live-array.d.ts +89 -0
- package/declarations/store/-private/record-arrays/{many-array.d.ts → legacy-many-array.d.ts} +43 -101
- package/declarations/store/-private/record-arrays/legacy-query.d.ts +103 -0
- package/declarations/store/-private/record-arrays/resource-array.d.ts +82 -0
- package/declarations/store/-private/store-service.d.ts +3 -3
- package/declarations/store/-private.d.ts +4 -2
- package/declarations/store/deprecated/store.d.ts +8 -9
- package/declarations/types/-private.d.ts +1 -1
- package/declarations/types/cache/operations.d.ts +97 -14
- package/declarations/types/request.d.ts +21 -0
- package/declarations/types/schema/fields.d.ts +1 -1
- package/dist/{context-COmAnXUQ.js → context-kQXhkeBj.js} +13 -0
- package/dist/graph/-private.js +4 -4
- package/dist/index.js +6 -2
- package/dist/reactive/-private.js +1 -1
- package/dist/reactive.js +3 -3
- package/dist/{request-state-BWYju5O9.js → request-state-CCrTjb0Z.js} +861 -799
- package/dist/request.js +1 -1
- package/dist/store/-private.js +1 -1
- package/dist/store.js +2 -1
- package/dist/{symbols-BoONANuz.js → symbols-C5p2hcy9.js} +0 -1
- package/dist/types/-private.js +1 -1
- package/dist/types/request.js +27 -0
- package/dist/types/schema/fields.js +2 -0
- package/package.json +3 -3
- package/declarations/store/-private/record-arrays/identifier-array.d.ts +0 -147
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import type { ImmutableRequestInfo } from "../../../types/request.js";
|
|
2
|
+
import type { Links, Meta, PaginationLinks } from "../../../types/spec/json-api-raw.js";
|
|
3
|
+
import type { LegacyLiveArray, LegacyLiveArrayCreateOptions } from "./legacy-live-array.js";
|
|
4
|
+
/**
|
|
5
|
+
* QueryArrays contain the primary records returned when querying
|
|
6
|
+
* for records by `ResourceType`.
|
|
7
|
+
*
|
|
8
|
+
* ### Basic Example
|
|
9
|
+
*
|
|
10
|
+
* For instance, if an application were to have a `'user'` type:
|
|
11
|
+
*
|
|
12
|
+
* ```ts
|
|
13
|
+
* const users = await store.query('user', { name: 'Chris' });
|
|
14
|
+
* ```
|
|
15
|
+
*
|
|
16
|
+
* ---
|
|
17
|
+
*
|
|
18
|
+
*
|
|
19
|
+
*
|
|
20
|
+
* ### QueryArrays are Arrays
|
|
21
|
+
*
|
|
22
|
+
* QueryArrays have all array APIs, and will report `true`
|
|
23
|
+
* for both `queryArray instanceof Array` and `Array.isArray(queryArray)`
|
|
24
|
+
*
|
|
25
|
+
* However, any mutation of the array will throw an error.
|
|
26
|
+
*
|
|
27
|
+
* ---
|
|
28
|
+
*
|
|
29
|
+
*
|
|
30
|
+
*
|
|
31
|
+
* ### Reactive
|
|
32
|
+
*
|
|
33
|
+
* If a record in a QueryArray is deleted and unloaded, it will be
|
|
34
|
+
* automatically removed from the array.
|
|
35
|
+
*
|
|
36
|
+
* ---
|
|
37
|
+
*
|
|
38
|
+
*
|
|
39
|
+
*
|
|
40
|
+
* ### Immutable
|
|
41
|
+
*
|
|
42
|
+
* Records cannot be directly added to or removed from a QueryArray.
|
|
43
|
+
*
|
|
44
|
+
* ---
|
|
45
|
+
*
|
|
46
|
+
*
|
|
47
|
+
*
|
|
48
|
+
* ### Polymorphism
|
|
49
|
+
*
|
|
50
|
+
* QueryArrays are not intended to be polymorphic. If your application has
|
|
51
|
+
* an abstract type "car" with concrete types "ferrari" and "bmw", a query
|
|
52
|
+
* which returns primary data containing both ferraris and bmws will *likely*
|
|
53
|
+
* work, but it is not guaranteed.
|
|
54
|
+
*
|
|
55
|
+
* In contrast, the {@link ReactiveResourceArray} returned when using {@link Store.request}
|
|
56
|
+
* is guaranteed to work with polymorphic responses.
|
|
57
|
+
*
|
|
58
|
+
* ---
|
|
59
|
+
*
|
|
60
|
+
*
|
|
61
|
+
*
|
|
62
|
+
* ### Memory Leaks
|
|
63
|
+
*
|
|
64
|
+
* QueryArrays are meant to be long lived. They can be refreshed using
|
|
65
|
+
* `array.update()`, and destroyed via `array.destroy()`.
|
|
66
|
+
*
|
|
67
|
+
* Unlike most Reactive state in WarpDrive, applications must choose to call
|
|
68
|
+
* `destroy` when the `QueryArray` is no longer needed, else the array instance
|
|
69
|
+
* will be retained until either the application or the store which created it
|
|
70
|
+
* are destroyed. Destroying a QueryArray does not remove its records
|
|
71
|
+
* from the cache, but it does remove the array as well as the overhead it requires
|
|
72
|
+
* from the store for book-keeping.
|
|
73
|
+
*
|
|
74
|
+
* @legacy we recommend againt using QueryArrays. Use {@link Store.request} instead
|
|
75
|
+
*/
|
|
76
|
+
export interface LegacyQueryArray<T = unknown> extends LegacyLiveArray<T> {
|
|
77
|
+
query: ImmutableRequestInfo | Record<string, unknown> | null;
|
|
78
|
+
destroy(): void;
|
|
79
|
+
links: PaginationLinks | Links | null;
|
|
80
|
+
meta: Meta | null;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* The options for {@link createLegacyQueryArray}
|
|
84
|
+
*
|
|
85
|
+
* See also {@link LegacyLiveArrayCreateOptions} which
|
|
86
|
+
* this extends.
|
|
87
|
+
*
|
|
88
|
+
* @internal
|
|
89
|
+
*/
|
|
90
|
+
export interface LegacyQueryArrayCreateOptions extends LegacyLiveArrayCreateOptions {
|
|
91
|
+
query: ImmutableRequestInfo | Record<string, unknown> | null;
|
|
92
|
+
isLoaded: boolean;
|
|
93
|
+
links: PaginationLinks | Links | null;
|
|
94
|
+
meta: Meta | null;
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Creates a {@link LegacyQueryArray}
|
|
98
|
+
*
|
|
99
|
+
* Options: {@link LegacyQueryArrayCreateOptions}
|
|
100
|
+
*
|
|
101
|
+
* @internal
|
|
102
|
+
*/
|
|
103
|
+
export declare function createLegacyQueryArray<T = unknown>(options: LegacyQueryArrayCreateOptions): LegacyQueryArray<T>;
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import type { ExtensionDef } from "../../../reactive.js";
|
|
2
|
+
import { Context } from "../../../reactive/-private.js";
|
|
3
|
+
import type { StableDocumentIdentifier, StableRecordIdentifier } from "../../../types/identifier.js";
|
|
4
|
+
import type { ObjectValue } from "../../../types/json/raw.js";
|
|
5
|
+
import type { CollectionField } from "../../../types/schema/fields.js";
|
|
6
|
+
import type { SignalStore, WarpDriveSignal } from "../new-core-tmp/reactivity/internal.js";
|
|
7
|
+
import type { Store } from "../store-service.js";
|
|
8
|
+
import type { KeyType, MinimumManager } from "./-utils.js";
|
|
9
|
+
import { NativeProxy } from "./native-proxy-type-fix.js";
|
|
10
|
+
declare const IS_COLLECTION: "___(unique) Symbol(IS_COLLECTION)";
|
|
11
|
+
type ProxiedMethod = (...args: unknown[]) => unknown;
|
|
12
|
+
interface ReactiveResourceArrayCreateOptions {
|
|
13
|
+
// passed in
|
|
14
|
+
store: Store;
|
|
15
|
+
manager: MinimumManager;
|
|
16
|
+
editable: boolean;
|
|
17
|
+
source: StableRecordIdentifier[];
|
|
18
|
+
// reactive, passed in
|
|
19
|
+
data: ObjectValue | null;
|
|
20
|
+
// non-reactive, passed in
|
|
21
|
+
features: Record<string | symbol, unknown> | null;
|
|
22
|
+
extensions: Map<string | symbol, ExtensionDef> | null;
|
|
23
|
+
// not-accessible except by the context
|
|
24
|
+
options: Record<string, unknown> | null;
|
|
25
|
+
destroy: null | ((this: ReactiveResourceArray, clear: boolean) => void);
|
|
26
|
+
mutate: null | ((target: StableRecordIdentifier[], receiver: typeof NativeProxy<StableRecordIdentifier[], unknown[]>, prop: string, args: unknown[], _SIGNAL: WarpDriveSignal) => unknown);
|
|
27
|
+
}
|
|
28
|
+
interface ReactiveResourceArrayContext extends ReactiveResourceArrayCreateOptions {
|
|
29
|
+
destroy: (this: ReactiveResourceArray, clear: boolean) => void;
|
|
30
|
+
mutate: (target: StableRecordIdentifier[], receiver: typeof NativeProxy<StableRecordIdentifier[], unknown[]>, prop: string, args: unknown[], _SIGNAL: WarpDriveSignal) => unknown;
|
|
31
|
+
// generated
|
|
32
|
+
signals: SignalStore;
|
|
33
|
+
signal: WarpDriveSignal;
|
|
34
|
+
isDestroying: boolean;
|
|
35
|
+
isDestroyed: boolean;
|
|
36
|
+
transaction: boolean;
|
|
37
|
+
boundFns: Map<KeyType, ProxiedMethod>;
|
|
38
|
+
}
|
|
39
|
+
export interface ReactiveResourceArray<T = unknown> extends Omit<Array<T>, "[]"> {
|
|
40
|
+
/** @internal */
|
|
41
|
+
isDestroying: boolean;
|
|
42
|
+
/** @internal */
|
|
43
|
+
isDestroyed: boolean;
|
|
44
|
+
/** @internal */
|
|
45
|
+
destroy: (this: ReactiveResourceArray, clear: boolean) => void;
|
|
46
|
+
/** @internal */
|
|
47
|
+
[IS_COLLECTION]: boolean;
|
|
48
|
+
/** @internal */
|
|
49
|
+
[Context]: ReactiveResourceArrayContext;
|
|
50
|
+
}
|
|
51
|
+
export interface TargetArray extends Array<StableRecordIdentifier> {
|
|
52
|
+
/** @internal */
|
|
53
|
+
[Context]: ReactiveResourceArrayContext;
|
|
54
|
+
}
|
|
55
|
+
export declare function createReactiveResourceArray<T>(options: ReactiveResourceArrayCreateOptions): ReactiveResourceArray<T>;
|
|
56
|
+
export declare function destroy(this: ReactiveResourceArray, clear: boolean): void;
|
|
57
|
+
export interface ReactiveRequestCollectionCreateArgs {
|
|
58
|
+
// passed in
|
|
59
|
+
store: Store;
|
|
60
|
+
manager: MinimumManager;
|
|
61
|
+
source: StableRecordIdentifier[];
|
|
62
|
+
options: {
|
|
63
|
+
requestKey: StableDocumentIdentifier;
|
|
64
|
+
} | null;
|
|
65
|
+
}
|
|
66
|
+
export declare function createRequestCollection(config: ReactiveRequestCollectionCreateArgs): ReactiveResourceArray;
|
|
67
|
+
export interface ReactiveRelatedCollectionCreateArgs {
|
|
68
|
+
// passed in
|
|
69
|
+
store: Store;
|
|
70
|
+
manager: MinimumManager;
|
|
71
|
+
source: StableRecordIdentifier[];
|
|
72
|
+
// not-accessible except by the context
|
|
73
|
+
options: {
|
|
74
|
+
resourceKey: StableRecordIdentifier;
|
|
75
|
+
path: string[];
|
|
76
|
+
field: CollectionField;
|
|
77
|
+
};
|
|
78
|
+
editable: boolean;
|
|
79
|
+
extensions: Map<string | symbol, ExtensionDef> | null;
|
|
80
|
+
}
|
|
81
|
+
export declare function createRelatedCollection(config: ReactiveRelatedCollectionCreateArgs): ReactiveResourceArray;
|
|
82
|
+
export {};
|
|
@@ -16,7 +16,7 @@ import { InstanceCache, storeFor } from "./caches/instance-cache.js";
|
|
|
16
16
|
import NotificationManager from "./managers/notification-manager.js";
|
|
17
17
|
import { RecordArrayManager } from "./managers/record-array-manager.js";
|
|
18
18
|
import { RequestStateService } from "./network/request-cache.js";
|
|
19
|
-
import type {
|
|
19
|
+
import type { LegacyLiveArray } from "./record-arrays/legacy-live-array.js";
|
|
20
20
|
export { storeFor };
|
|
21
21
|
// We inline this list of methods to avoid importing EmberObject
|
|
22
22
|
type EmberObjectKey = "_debugContainerKey" | "_super" | "addObserver" | "cacheFor" | "concatenatedProperties" | "decrementProperty" | "destroy" | "get" | "getProperties" | "incrementProperty" | "init" | "isDestroyed" | "isDestroying" | "mergedProperties" | "notifyPropertyChange" | "removeObserver" | "reopen" | "set" | "setProperties" | "toggleProperty" | "toString" | "willDestroy";
|
|
@@ -687,8 +687,8 @@ export declare class Store extends BaseClass {
|
|
|
687
687
|
@param {String} type the name of the resource
|
|
688
688
|
@return {RecordArray}
|
|
689
689
|
*/
|
|
690
|
-
peekAll<T>(type: TypeFromInstance<T>):
|
|
691
|
-
peekAll(type: string):
|
|
690
|
+
peekAll<T>(type: TypeFromInstance<T>): LegacyLiveArray<T>;
|
|
691
|
+
peekAll(type: string): LegacyLiveArray;
|
|
692
692
|
/**
|
|
693
693
|
This method unloads all records in the store.
|
|
694
694
|
It schedules unloading to happen during the next run loop.
|
|
@@ -12,7 +12,9 @@ export type { CreateRecordProperties } from "./-private/store-service.js";
|
|
|
12
12
|
// to also eliminate
|
|
13
13
|
export { coerceId, ensureStringId } from "./-private/utils/coerce-id.js";
|
|
14
14
|
export type { NativeProxy } from "./-private/record-arrays/native-proxy-type-fix.js";
|
|
15
|
-
export {
|
|
15
|
+
export { type ReactiveResourceArray } from "./-private/record-arrays/resource-array.js";
|
|
16
|
+
export { type LegacyLiveArray, type LegacyLiveArray as LiveArray } from "./-private/record-arrays/legacy-live-array.js";
|
|
17
|
+
export { type LegacyQueryArray, type LegacyQueryArray as CollectionRecordArray } from "./-private/record-arrays/legacy-query.js";
|
|
16
18
|
export { RecordArrayManager, fastPush } from "./-private/managers/record-array-manager.js";
|
|
17
19
|
// leaked for private use / test use, should investigate removing
|
|
18
20
|
export { _clearCaches } from "./-private/caches/instance-cache.js";
|
|
@@ -20,7 +22,7 @@ export { _clearCaches } from "./-private/caches/instance-cache.js";
|
|
|
20
22
|
export { setRecordIdentifier, StoreMap } from "./-private/caches/instance-cache.js";
|
|
21
23
|
export { normalizeModelName as _deprecatingNormalize } from "./-private/utils/normalize-model-name.js";
|
|
22
24
|
export type { StoreRequestInput } from "./-private/cache-handler/handler.js";
|
|
23
|
-
export { RelatedCollection } from "./-private/record-arrays/many-array.js";
|
|
25
|
+
export { type LegacyManyArray, type LegacyManyArray as RelatedCollection, createLegacyManyArray } from "./-private/record-arrays/legacy-many-array.js";
|
|
24
26
|
export { log, logGroup } from "./-private/debug/utils.js";
|
|
25
27
|
export { getPromiseState, type PromiseState } from "./-private/new-core-tmp/promise-state.js";
|
|
26
28
|
export { DISPOSE, createRequestSubscription, type SubscriptionArgs, type RequestSubscription } from "./-private/new-core-tmp/request-subscription.js";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { TypeFromInstance } from "../../types/record.js";
|
|
2
2
|
import type { ResourceIdentifierObject } from "../../types/spec/json-api-raw.js";
|
|
3
|
-
import type {
|
|
3
|
+
import type { LegacyLiveArray, LegacyQueryArray } from "../-private.js";
|
|
4
4
|
import { Store } from "../-private/store-service.js";
|
|
5
5
|
import type { FindAllOptions, FindRecordOptions, LegacyResourceQuery, ModelSchema, QueryOptions } from "./-private.js";
|
|
6
6
|
import { RecordReference } from "./-private.js";
|
|
@@ -548,9 +548,9 @@ declare module "../-private/store-service" {
|
|
|
548
548
|
@param type the name of the resource
|
|
549
549
|
@param options
|
|
550
550
|
*/
|
|
551
|
-
findAll<T>(type: TypeFromInstance<T>, options?: FindAllOptions): Promise<
|
|
551
|
+
findAll<T>(type: TypeFromInstance<T>, options?: FindAllOptions): Promise<LegacyLiveArray<T>>;
|
|
552
552
|
/** @deprecated */
|
|
553
|
-
findAll(type: string, options?: FindAllOptions): Promise<
|
|
553
|
+
findAll(type: string, options?: FindAllOptions): Promise<LegacyLiveArray>;
|
|
554
554
|
/**
|
|
555
555
|
This method delegates a query to the adapter. This is the one place where
|
|
556
556
|
adapter-level semantics are exposed to the application.
|
|
@@ -565,13 +565,13 @@ declare module "../-private/store-service" {
|
|
|
565
565
|
|
|
566
566
|
If you do something like this:
|
|
567
567
|
|
|
568
|
-
```
|
|
568
|
+
```js
|
|
569
569
|
store.query('person', { page: 1 });
|
|
570
570
|
```
|
|
571
571
|
|
|
572
572
|
The request made to the server will look something like this:
|
|
573
573
|
|
|
574
|
-
```
|
|
574
|
+
```http
|
|
575
575
|
GET "/api/v1/person?page=1"
|
|
576
576
|
```
|
|
577
577
|
|
|
@@ -591,8 +591,7 @@ declare module "../-private/store-service" {
|
|
|
591
591
|
```
|
|
592
592
|
|
|
593
593
|
This method returns a promise, which is resolved with a
|
|
594
|
-
|
|
595
|
-
once the server returns.
|
|
594
|
+
{@link LegacyQueryArray} once the server returns.
|
|
596
595
|
|
|
597
596
|
@public
|
|
598
597
|
@deprecated use {@link Store.request} instead
|
|
@@ -602,9 +601,9 @@ declare module "../-private/store-service" {
|
|
|
602
601
|
@param query a query to be used by the adapter
|
|
603
602
|
@param options optional, may include `adapterOptions` hash which will be passed to adapter.query
|
|
604
603
|
*/
|
|
605
|
-
query<T>(type: TypeFromInstance<T>, query: LegacyResourceQuery, options?: QueryOptions): Promise<
|
|
604
|
+
query<T>(type: TypeFromInstance<T>, query: LegacyResourceQuery, options?: QueryOptions): Promise<LegacyQueryArray<T>>;
|
|
606
605
|
/** @deprecated */
|
|
607
|
-
query(type: string, query: LegacyResourceQuery, options?: QueryOptions): Promise<
|
|
606
|
+
query(type: string, query: LegacyResourceQuery, options?: QueryOptions): Promise<LegacyQueryArray>;
|
|
608
607
|
/**
|
|
609
608
|
This method makes a request for one record, where the `id` is not known
|
|
610
609
|
beforehand (if the `id` is known, use [`findRecord`](../methods/findRecord?anchor=findRecord)
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
type UniversalTransientKey = "REQ_ID";
|
|
2
2
|
type UniversalKey = `(transient) ${UniversalTransientKey}` | "RequestMap" | "PromiseCache" | "RequestCache" | "SkipCache" | "EnableHydration" | "WarpDriveRuntimeConfig";
|
|
3
3
|
type TransientKey = "transactionRef" | "configuredGenerationMethod" | "configuredUpdateMethod" | "configuredForgetMethod" | "configuredResetMethod" | "configuredKeyInfoMethod" | "signalHooks";
|
|
4
|
-
type GlobalKey = `(transient) ${TransientKey}` | "AdapterError" | "InvalidError" | "TimeoutError" | "AbortError" | "UnauthorizedError" | "ForbiddenError" | "NotFoundError" | "ConflictError" | "ServerError" | "#{}" | "#[]" | "Signals" | "AvailableShims" | "FAKE_ARR" | "#source" | "#update" | "#notify" | "IS_COLLECTION" | "Touching" | "RequestPromise" | "SaveOp" | "LEGACY_SUPPORT" | "LegacySupport" | "Graphs" | "IS_FROZEN" | "IS_CACHE_HANDLER" | "CONFIG" | "DEBUG_MAP" | "IDENTIFIERS" | "DOCUMENTS" | "RecordCache" | "StoreMap" | "Store" | "$type" | "TransformName" | "RequestSignature" | "IS_FUTURE" | "DOC" | "ManagedArrayMap" | "ManagedObjectMap" | "Support" | "SOURCE" | "
|
|
4
|
+
type GlobalKey = `(transient) ${TransientKey}` | "AdapterError" | "InvalidError" | "TimeoutError" | "AbortError" | "UnauthorizedError" | "ForbiddenError" | "NotFoundError" | "ConflictError" | "ServerError" | "#{}" | "#[]" | "Signals" | "AvailableShims" | "FAKE_ARR" | "#source" | "#update" | "#notify" | "IS_COLLECTION" | "Touching" | "RequestPromise" | "SaveOp" | "LEGACY_SUPPORT" | "LegacySupport" | "Graphs" | "IS_FROZEN" | "IS_CACHE_HANDLER" | "CONFIG" | "DEBUG_MAP" | "IDENTIFIERS" | "DOCUMENTS" | "RecordCache" | "StoreMap" | "Store" | "$type" | "TransformName" | "RequestSignature" | "IS_FUTURE" | "DOC" | "ManagedArrayMap" | "ManagedObjectMap" | "Support" | "SOURCE" | "Destroy" | "Checkout" | "Context";
|
|
5
5
|
type UniqueSymbol<T extends string> = `___(unique) Symbol(${T})`;
|
|
6
6
|
type UniqueSymbolOr<
|
|
7
7
|
T,
|
|
@@ -2,54 +2,106 @@ import type { StableDocumentIdentifier, StableExistingRecordIdentifier, StableRe
|
|
|
2
2
|
import type { Value } from "../json/raw.js";
|
|
3
3
|
import type { ExistingResourceObject } from "../spec/json-api-raw.js";
|
|
4
4
|
import type { Relationship } from "./relationship.js";
|
|
5
|
+
/**
|
|
6
|
+
* All operations are objects with at least one property,
|
|
7
|
+
* `op` which contains a string with the name of the operation
|
|
8
|
+
* to perform.
|
|
9
|
+
*/
|
|
5
10
|
export interface Op {
|
|
11
|
+
/**
|
|
12
|
+
* The name of the {@link Op | operation}
|
|
13
|
+
*/
|
|
6
14
|
op: string;
|
|
7
15
|
}
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
+
/**
|
|
17
|
+
* Occasionally the Store discovers that two previously
|
|
18
|
+
* thought to be distinct resources refer to the same resource.
|
|
19
|
+
*
|
|
20
|
+
* This operation will be performed, giving the Cache the chance
|
|
21
|
+
* to cleanup and merge internal state as desired when this discovery
|
|
22
|
+
* is made.
|
|
23
|
+
*/
|
|
16
24
|
export interface MergeOperation extends Op {
|
|
17
25
|
op: "mergeIdentifiers";
|
|
18
|
-
|
|
26
|
+
/**
|
|
27
|
+
* The stale {@link StableRecordIdentifier | ResourceKey} that
|
|
28
|
+
* the cache should eliminate in favor of {@link MergeOperation.value | value}
|
|
29
|
+
*/
|
|
19
30
|
record: StableRecordIdentifier;
|
|
20
|
-
|
|
31
|
+
/**
|
|
32
|
+
* The kept {@link StableRecordIdentifier | ResourceKey} that
|
|
33
|
+
* the cache should also keep and merge {@link MergeOperation.record | record} into.
|
|
34
|
+
*/
|
|
21
35
|
value: StableRecordIdentifier;
|
|
22
36
|
}
|
|
37
|
+
/**
|
|
38
|
+
* Removes a document and its associated request from
|
|
39
|
+
* the cache.
|
|
40
|
+
*/
|
|
23
41
|
export interface RemoveDocumentOperation extends Op {
|
|
24
42
|
op: "remove";
|
|
43
|
+
/**
|
|
44
|
+
* The cache key for the request
|
|
45
|
+
*/
|
|
25
46
|
record: StableDocumentIdentifier;
|
|
26
47
|
}
|
|
48
|
+
/**
|
|
49
|
+
* Removes a resource from the cache. This is treated
|
|
50
|
+
* as if a remote deletion has occurred, and all references
|
|
51
|
+
* to the resource should be eliminated.
|
|
52
|
+
*/
|
|
27
53
|
export interface RemoveResourceOperation extends Op {
|
|
28
54
|
op: "remove";
|
|
55
|
+
/**
|
|
56
|
+
* The cache key for the resource
|
|
57
|
+
*/
|
|
29
58
|
record: StableExistingRecordIdentifier;
|
|
30
59
|
}
|
|
60
|
+
/**
|
|
61
|
+
* Adds a resource to the cache.
|
|
62
|
+
*/
|
|
31
63
|
export interface AddResourceOperation extends Op {
|
|
32
64
|
op: "add";
|
|
65
|
+
/**
|
|
66
|
+
* The cache key for the resource
|
|
67
|
+
*/
|
|
33
68
|
record: StableExistingRecordIdentifier;
|
|
69
|
+
/**
|
|
70
|
+
* The data for the resource
|
|
71
|
+
*/
|
|
34
72
|
value: ExistingResourceObject;
|
|
35
73
|
}
|
|
74
|
+
/**
|
|
75
|
+
* Upserts (merges) new state for a resource
|
|
76
|
+
*/
|
|
36
77
|
export interface UpdateResourceOperation extends Op {
|
|
37
78
|
op: "update";
|
|
38
79
|
record: StableExistingRecordIdentifier;
|
|
39
80
|
value: ExistingResourceObject;
|
|
40
81
|
}
|
|
82
|
+
/**
|
|
83
|
+
* Replaces the state of a field with a new state
|
|
84
|
+
*/
|
|
41
85
|
export interface UpdateResourceFieldOperation extends Op {
|
|
42
86
|
op: "update";
|
|
43
87
|
record: StableExistingRecordIdentifier;
|
|
44
88
|
field: string;
|
|
45
89
|
value: Value;
|
|
46
90
|
}
|
|
91
|
+
/**
|
|
92
|
+
* Replaces the state of a relationship with a new state
|
|
93
|
+
*/
|
|
47
94
|
export interface UpdateResourceRelationshipOperation extends Op {
|
|
48
95
|
op: "update";
|
|
49
96
|
record: StableExistingRecordIdentifier;
|
|
50
97
|
field: string;
|
|
51
98
|
value: Relationship<StableExistingRecordIdentifier>;
|
|
52
99
|
}
|
|
100
|
+
/**
|
|
101
|
+
* Adds a resource to a request document, optionally
|
|
102
|
+
* at a specific index. This can be used to update the
|
|
103
|
+
* result of a request.
|
|
104
|
+
*/
|
|
53
105
|
export interface AddToDocumentOperation extends Op {
|
|
54
106
|
op: "add";
|
|
55
107
|
record: StableDocumentIdentifier;
|
|
@@ -57,6 +109,9 @@ export interface AddToDocumentOperation extends Op {
|
|
|
57
109
|
value: StableExistingRecordIdentifier | StableExistingRecordIdentifier[];
|
|
58
110
|
index?: number;
|
|
59
111
|
}
|
|
112
|
+
/**
|
|
113
|
+
* Adds the specified ResourceKeys to a relationship
|
|
114
|
+
*/
|
|
60
115
|
export interface AddToResourceRelationshipOperation extends Op {
|
|
61
116
|
op: "add";
|
|
62
117
|
record: StableExistingRecordIdentifier;
|
|
@@ -64,6 +119,9 @@ export interface AddToResourceRelationshipOperation extends Op {
|
|
|
64
119
|
value: StableExistingRecordIdentifier | StableExistingRecordIdentifier[];
|
|
65
120
|
index?: number;
|
|
66
121
|
}
|
|
122
|
+
/**
|
|
123
|
+
* Removes the specified ResourceKeys from a relationship
|
|
124
|
+
*/
|
|
67
125
|
export interface RemoveFromResourceRelationshipOperation extends Op {
|
|
68
126
|
op: "remove";
|
|
69
127
|
record: StableExistingRecordIdentifier;
|
|
@@ -71,6 +129,11 @@ export interface RemoveFromResourceRelationshipOperation extends Op {
|
|
|
71
129
|
value: StableExistingRecordIdentifier | StableExistingRecordIdentifier[];
|
|
72
130
|
index?: number;
|
|
73
131
|
}
|
|
132
|
+
/**
|
|
133
|
+
* Removes a resource from a request document, optionally
|
|
134
|
+
* at a specific index. This can be used to update the
|
|
135
|
+
* result of a request.
|
|
136
|
+
*/
|
|
74
137
|
export interface RemoveFromDocumentOperation extends Op {
|
|
75
138
|
op: "remove";
|
|
76
139
|
record: StableDocumentIdentifier;
|
|
@@ -78,8 +141,28 @@ export interface RemoveFromDocumentOperation extends Op {
|
|
|
78
141
|
value: StableExistingRecordIdentifier | StableExistingRecordIdentifier[];
|
|
79
142
|
index?: number;
|
|
80
143
|
}
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
144
|
+
/**
|
|
145
|
+
* {@link Cache} Operations perform updates to the
|
|
146
|
+
* Cache's "remote" (or clean) state to reflect external
|
|
147
|
+
* changes.
|
|
148
|
+
*
|
|
149
|
+
* Usually operations represent the result of a {@link WebSocket} or
|
|
150
|
+
* {@link EventSource | ServerEvent} message, though they can also be used to carefully
|
|
151
|
+
* patch the state of the cache with information known by the
|
|
152
|
+
* application or developer.
|
|
153
|
+
*
|
|
154
|
+
* Operations are applied via {@link Cache.patch}.
|
|
155
|
+
*
|
|
156
|
+
* See also:
|
|
157
|
+
* - {@link MergeOperation}
|
|
158
|
+
* - {@link RemoveResourceOperation}
|
|
159
|
+
* - {@link RemoveDocumentOperation}
|
|
160
|
+
* - {@link AddResourceOperation}
|
|
161
|
+
* - {@link UpdateResourceOperation}
|
|
162
|
+
* - {@link UpdateResourceFieldOperation}
|
|
163
|
+
* - {@link AddToResourceRelationshipOperation}
|
|
164
|
+
* - {@link RemoveFromResourceRelationshipOperation}
|
|
165
|
+
* - {@link AddToDocumentOperation}
|
|
166
|
+
* - {@link RemoveFromDocumentOperation}
|
|
167
|
+
*/
|
|
85
168
|
export type Operation = MergeOperation | RemoveResourceOperation | RemoveDocumentOperation | AddResourceOperation | UpdateResourceOperation | UpdateResourceFieldOperation | AddToResourceRelationshipOperation | RemoveFromResourceRelationshipOperation | AddToDocumentOperation | RemoveFromDocumentOperation;
|
|
@@ -163,6 +163,11 @@ export interface ConstrainedRequestOptions {
|
|
|
163
163
|
export interface FindRecordOptions extends ConstrainedRequestOptions {
|
|
164
164
|
include?: string | string[];
|
|
165
165
|
}
|
|
166
|
+
/**
|
|
167
|
+
* When a handler chain resolves, it returns an object
|
|
168
|
+
* containing the original request, the response set by the handler
|
|
169
|
+
* chain (if any), and the processed content.
|
|
170
|
+
*/
|
|
166
171
|
export interface StructuredDataDocument<T> {
|
|
167
172
|
[STRUCTURED]?: true;
|
|
168
173
|
/**
|
|
@@ -172,6 +177,14 @@ export interface StructuredDataDocument<T> {
|
|
|
172
177
|
response: Response | ResponseInfo | null;
|
|
173
178
|
content: T;
|
|
174
179
|
}
|
|
180
|
+
/**
|
|
181
|
+
* When a handler chain rejects, it throws an Error that maintains the
|
|
182
|
+
* `{ request, response, content }` shape but is also an Error instance
|
|
183
|
+
* itself.
|
|
184
|
+
*
|
|
185
|
+
* If using the error originates from the {@link Fetch | Fetch Handler}
|
|
186
|
+
* the error will be a {@link FetchError}
|
|
187
|
+
*/
|
|
175
188
|
export interface StructuredErrorDocument<T = unknown> extends Error {
|
|
176
189
|
[STRUCTURED]?: true;
|
|
177
190
|
request: ImmutableRequestInfo;
|
|
@@ -179,6 +192,14 @@ export interface StructuredErrorDocument<T = unknown> extends Error {
|
|
|
179
192
|
error: string | object;
|
|
180
193
|
content?: T;
|
|
181
194
|
}
|
|
195
|
+
/**
|
|
196
|
+
* A union of the resolve/reject data types for a request.
|
|
197
|
+
*
|
|
198
|
+
* See the docs for:
|
|
199
|
+
*
|
|
200
|
+
* - {@link StructuredDataDocument} (resolved/successful requests)
|
|
201
|
+
* - {@link StructuredErrorDocument} (rejected/failed requests)
|
|
202
|
+
*/
|
|
182
203
|
export type StructuredDocument<T> = StructuredDataDocument<T> | StructuredErrorDocument<T>;
|
|
183
204
|
/**
|
|
184
205
|
* JavaScript's native Request class.
|
|
@@ -473,7 +473,7 @@ export interface ObjectField {
|
|
|
473
473
|
* Configures which extensions this object should use.
|
|
474
474
|
*
|
|
475
475
|
* Extensions are registered with the store's schema service
|
|
476
|
-
* via {@link SchemaService.
|
|
476
|
+
* via {@link SchemaService.CAUTION_MEGA_DANGER_ZONE_registerExtension}
|
|
477
477
|
*
|
|
478
478
|
* Extensions should only be used for temporary enhancements
|
|
479
479
|
* to objects to support migrating away from deprecated patterns
|
|
@@ -306,6 +306,19 @@ function ensureDoc(owner, content, isError) {
|
|
|
306
306
|
content: content
|
|
307
307
|
};
|
|
308
308
|
}
|
|
309
|
+
|
|
310
|
+
/**
|
|
311
|
+
* Additional properties exposed on errors thrown by the
|
|
312
|
+
* {@link Fetch | Fetch Handler}.
|
|
313
|
+
*
|
|
314
|
+
* In the case of an Abort or system/browser level issue,
|
|
315
|
+
* this extends {@link DOMException}.
|
|
316
|
+
*
|
|
317
|
+
* Else it extends from {@link AggregateError} if the
|
|
318
|
+
* response includes an array of errors, falling back
|
|
319
|
+
* to {@link Error} as its base.
|
|
320
|
+
*/
|
|
321
|
+
|
|
309
322
|
function enhanceReason(reason) {
|
|
310
323
|
return new DOMException(reason || 'The user aborted a request.', 'AbortError');
|
|
311
324
|
}
|
package/dist/graph/-private.js
CHANGED
|
@@ -3122,11 +3122,11 @@ class Graph {
|
|
|
3122
3122
|
}
|
|
3123
3123
|
}
|
|
3124
3124
|
function flushPending(graph, ops) {
|
|
3125
|
-
ops.
|
|
3126
|
-
type.
|
|
3125
|
+
for (const type of ops.values()) {
|
|
3126
|
+
for (const opList of type.values()) {
|
|
3127
3127
|
flushPendingList(graph, opList);
|
|
3128
|
-
}
|
|
3129
|
-
}
|
|
3128
|
+
}
|
|
3129
|
+
}
|
|
3130
3130
|
}
|
|
3131
3131
|
function flushPendingList(graph, opList) {
|
|
3132
3132
|
for (let i = 0; i < opList.length; i++) {
|
package/dist/index.js
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { setLogging, getRuntimeConfig } from './types/runtime.js';
|
|
2
|
-
import { a as cloneResponseProperties, I as IS_CACHE_HANDLER, b as assertValidRequest, e as executeNextHandler, d as getRequestResult, u as upgradePromise, s as setPromiseResult, f as clearRequestResult } from "./context-
|
|
2
|
+
import { a as cloneResponseProperties, I as IS_CACHE_HANDLER, b as assertValidRequest, e as executeNextHandler, d as getRequestResult, u as upgradePromise, s as setPromiseResult, f as clearRequestResult } from "./context-kQXhkeBj.js";
|
|
3
3
|
import { macroCondition, getGlobalConfig } from '@embroider/macros';
|
|
4
4
|
import { w as waitFor } from "./configure-B48bFHOl.js";
|
|
5
5
|
import { peekUniversalTransient, setUniversalTransient } from './types/-private.js';
|
|
6
|
-
export { C as CacheHandler, S as Store, r as recordIdentifierFor,
|
|
6
|
+
export { C as CacheHandler, S as Store, r as recordIdentifierFor, K as setIdentifierForgetMethod, I as setIdentifierGenerationMethod, L as setIdentifierResetMethod, J as setIdentifierUpdateMethod, M as setKeyInfoForResource, s as storeFor } from "./request-state-CCrTjb0Z.js";
|
|
7
7
|
import '@ember/debug';
|
|
8
8
|
import './utils/string.js';
|
|
9
|
+
import "./symbols-C5p2hcy9.js";
|
|
9
10
|
|
|
10
11
|
// Lazily close over fetch to avoid breaking Mirage
|
|
11
12
|
const _fetch = typeof fetch !== 'undefined' ? (...args) => fetch(...args) : typeof FastBoot !== 'undefined' ? (...args) => FastBoot.require('node-fetch')(...args) : () => {
|
|
@@ -60,6 +61,9 @@ const Fetch = {
|
|
|
60
61
|
} else {
|
|
61
62
|
e.statusText = 'Unknown Network Error';
|
|
62
63
|
e.status = 0;
|
|
64
|
+
if (!(e instanceof DOMException)) {
|
|
65
|
+
e.code = 0;
|
|
66
|
+
}
|
|
63
67
|
e.isRequestError = true;
|
|
64
68
|
}
|
|
65
69
|
throw e;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { C as Context } from "../symbols-
|
|
1
|
+
export { C as Context } from "../symbols-C5p2hcy9.js";
|
package/dist/reactive.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { isResourceSchema } from './types/schema/fields.js';
|
|
2
|
-
import {
|
|
3
|
-
import { D as Destroy, C as Context } from "./symbols-
|
|
4
|
-
export { a as Checkout } from "./symbols-
|
|
2
|
+
import { F as ReactiveResource, G as isNonIdentityCacheableField, H as getFieldCacheKeyStrict, r as recordIdentifierFor, z as withSignalStore } from "./request-state-CCrTjb0Z.js";
|
|
3
|
+
import { D as Destroy, C as Context } from "./symbols-C5p2hcy9.js";
|
|
4
|
+
export { a as Checkout } from "./symbols-C5p2hcy9.js";
|
|
5
5
|
import { macroCondition, getGlobalConfig } from '@embroider/macros';
|
|
6
6
|
import { warn, deprecate } from '@ember/debug';
|
|
7
7
|
import './index.js';
|