@ember-data/store 5.4.0-alpha.32 → 5.4.0-alpha.33

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. package/package.json +9 -9
  2. package/unstable-preview-types/-private/cache-handler.d.ts +101 -99
  3. package/unstable-preview-types/-private/caches/cache-utils.d.ts +11 -9
  4. package/unstable-preview-types/-private/caches/identifier-cache.d.ts +181 -179
  5. package/unstable-preview-types/-private/caches/instance-cache.d.ts +63 -61
  6. package/unstable-preview-types/-private/caches/resource-utils.d.ts +12 -10
  7. package/unstable-preview-types/-private/document.d.ts +146 -144
  8. package/unstable-preview-types/-private/index.d.ts +18 -16
  9. package/unstable-preview-types/-private/legacy-model-support/record-reference.d.ts +178 -176
  10. package/unstable-preview-types/-private/legacy-model-support/shim-model-class.d.ts +19 -17
  11. package/unstable-preview-types/-private/managers/cache-capabilities-manager.d.ts +29 -27
  12. package/unstable-preview-types/-private/managers/cache-manager.d.ts +442 -440
  13. package/unstable-preview-types/-private/managers/notification-manager.d.ts +98 -96
  14. package/unstable-preview-types/-private/managers/record-array-manager.d.ts +97 -95
  15. package/unstable-preview-types/-private/network/request-cache.d.ts +109 -107
  16. package/unstable-preview-types/-private/record-arrays/identifier-array.d.ts +134 -132
  17. package/unstable-preview-types/-private/store-service.d.ts +1503 -1501
  18. package/unstable-preview-types/-private/utils/coerce-id.d.ts +10 -8
  19. package/unstable-preview-types/-private/utils/construct-resource.d.ts +10 -8
  20. package/unstable-preview-types/-private/utils/identifier-debug-consts.d.ts +7 -5
  21. package/unstable-preview-types/-private/utils/is-non-empty-string.d.ts +4 -2
  22. package/unstable-preview-types/-private/utils/normalize-model-name.d.ts +4 -2
  23. package/unstable-preview-types/-private/utils/uuid-polyfill.d.ts +4 -2
  24. package/unstable-preview-types/-private.d.ts +4 -2
  25. package/unstable-preview-types/-types/overview.d.ts +21 -19
  26. package/unstable-preview-types/-types/q/cache-store-wrapper.d.ts +107 -105
  27. package/unstable-preview-types/-types/q/cache.d.ts +47 -45
  28. package/unstable-preview-types/-types/q/ds-model.d.ts +15 -13
  29. package/unstable-preview-types/-types/q/identifier.d.ts +169 -167
  30. package/unstable-preview-types/-types/q/promise-proxies.d.ts +4 -2
  31. package/unstable-preview-types/-types/q/record-data-json-api.d.ts +36 -34
  32. package/unstable-preview-types/-types/q/record-instance.d.ts +29 -27
  33. package/unstable-preview-types/-types/q/schema-service.d.ts +214 -212
  34. package/unstable-preview-types/-types/q/store.d.ts +17 -15
  35. package/unstable-preview-types/index.d.ts +220 -185
@@ -1,96 +1,98 @@
1
- import type { StableDocumentIdentifier, StableRecordIdentifier } from '@warp-drive/core-types/identifier';
2
- import type Store from '../store-service';
3
- export type UnsubscribeToken = object;
4
- export type CacheOperation = 'added' | 'removed' | 'updated' | 'state';
5
- export type NotificationType = 'attributes' | 'relationships' | 'identity' | 'errors' | 'meta' | 'state';
6
- export interface NotificationCallback {
7
- (identifier: StableRecordIdentifier, notificationType: 'attributes' | 'relationships', key?: string): void;
8
- (identifier: StableRecordIdentifier, notificationType: 'errors' | 'meta' | 'identity' | 'state'): void;
9
- (identifier: StableRecordIdentifier, notificationType: NotificationType, key?: string): void;
10
- }
11
- export interface ResourceOperationCallback {
12
- (identifier: StableRecordIdentifier, notificationType: CacheOperation): void;
13
- }
14
- export interface DocumentOperationCallback {
15
- (identifier: StableDocumentIdentifier, notificationType: CacheOperation): void;
16
- }
17
- /**
18
- * The NotificationManager provides the ability to subscribe to
19
- * changes to Cache state.
20
- *
21
- * This Feature is what allows EmberData to create subscriptions that
22
- * work with any framework or change-notification system.
23
- *
24
- * @class NotificationManager
25
- * @public
26
- */
27
- export default class NotificationManager {
28
- store: Store;
29
- isDestroyed: boolean;
30
- _buffered: Map<StableDocumentIdentifier | StableRecordIdentifier, [string, string | undefined][]>;
31
- _cache: Map<StableDocumentIdentifier | StableRecordIdentifier | 'resource' | 'document', Map<UnsubscribeToken, NotificationCallback | ResourceOperationCallback | DocumentOperationCallback>>;
32
- _tokens: Map<UnsubscribeToken, StableDocumentIdentifier | StableRecordIdentifier | 'resource' | 'document'>;
33
- _hasFlush: boolean;
34
- _onFlushCB?: () => void;
35
- constructor(store: Store);
36
- /**
37
- * Subscribe to changes for a given resource identifier, resource addition/removal, or document addition/removal.
38
- *
39
- * ```ts
40
- * export type CacheOperation = 'added' | 'removed' | 'updated' | 'state';
41
- *
42
- * export interface NotificationCallback {
43
- * (identifier: StableRecordIdentifier, notificationType: 'attributes' | 'relationships', key?: string): void;
44
- * (identifier: StableRecordIdentifier, notificationType: 'errors' | 'meta' | 'identity' | 'state'): void;
45
- * (identifier: StableRecordIdentifier, notificationType: NotificationType, key?: string): void;
46
- * }
47
- * export interface ResourceOperationCallback {
48
- * // resource updates
49
- * (identifier: StableRecordIdentifier, notificationType: CacheOperation): void;
50
- * }
51
- * export interface DocumentOperationCallback {
52
- * // document updates
53
- * (identifier: StableDocumentIdentifier, notificationType: CacheOperation): void;
54
- * }
55
- * ```
56
- *
57
- * @method subscribe
58
- * @public
59
- * @param {StableDocumentIdentifier | StableRecordIdentifier | 'resource' | 'document'} identifier
60
- * @param {NotificationCallback | ResourceOperationCallback | DocumentOperationCallback} callback
61
- * @return {UnsubscribeToken} an opaque token to be used with unsubscribe
62
- */
63
- subscribe(identifier: StableRecordIdentifier, callback: NotificationCallback): UnsubscribeToken;
64
- subscribe(identifier: 'resource', callback: ResourceOperationCallback): UnsubscribeToken;
65
- subscribe(identifier: StableDocumentIdentifier, callback: DocumentOperationCallback): UnsubscribeToken;
66
- subscribe(identifier: 'document', callback: DocumentOperationCallback): UnsubscribeToken;
67
- /**
68
- * remove a previous subscription
69
- *
70
- * @method unsubscribe
71
- * @public
72
- * @param {UnsubscribeToken} token
73
- */
74
- unsubscribe(token: UnsubscribeToken): void;
75
- /**
76
- * Custom Caches and Application Code should not call this method directly.
77
- *
78
- * @method notify
79
- * @param identifier
80
- * @param value
81
- * @param key
82
- * @return {Boolean} whether a notification was delivered to any subscribers
83
- * @private
84
- */
85
- notify(identifier: StableRecordIdentifier, value: 'attributes' | 'relationships', key?: string): boolean;
86
- notify(identifier: StableRecordIdentifier, value: 'errors' | 'meta' | 'identity' | 'state'): boolean;
87
- notify(identifier: StableRecordIdentifier | StableDocumentIdentifier, value: CacheOperation): boolean;
88
- _onNextFlush(cb: () => void): void;
89
- _scheduleNotify(): void;
90
- _flush(): void;
91
- _flushNotification(identifier: StableRecordIdentifier, value: 'attributes' | 'relationships', key?: string): boolean;
92
- _flushNotification(identifier: StableRecordIdentifier, value: 'errors' | 'meta' | 'identity' | 'state'): boolean;
93
- _flushNotification(identifier: StableRecordIdentifier | StableDocumentIdentifier, value: CacheOperation): boolean;
94
- destroy(): void;
95
- }
96
- //# sourceMappingURL=notification-manager.d.ts.map
1
+ declare module '@ember-data/store/-private/managers/notification-manager' {
2
+ import type { StableDocumentIdentifier, StableRecordIdentifier } from '@warp-drive/core-types/identifier';
3
+ import type Store from '@ember-data/store/-private/store-service';
4
+ export type UnsubscribeToken = object;
5
+ export type CacheOperation = 'added' | 'removed' | 'updated' | 'state';
6
+ export type NotificationType = 'attributes' | 'relationships' | 'identity' | 'errors' | 'meta' | 'state';
7
+ export interface NotificationCallback {
8
+ (identifier: StableRecordIdentifier, notificationType: 'attributes' | 'relationships', key?: string): void;
9
+ (identifier: StableRecordIdentifier, notificationType: 'errors' | 'meta' | 'identity' | 'state'): void;
10
+ (identifier: StableRecordIdentifier, notificationType: NotificationType, key?: string): void;
11
+ }
12
+ export interface ResourceOperationCallback {
13
+ (identifier: StableRecordIdentifier, notificationType: CacheOperation): void;
14
+ }
15
+ export interface DocumentOperationCallback {
16
+ (identifier: StableDocumentIdentifier, notificationType: CacheOperation): void;
17
+ }
18
+ /**
19
+ * The NotificationManager provides the ability to subscribe to
20
+ * changes to Cache state.
21
+ *
22
+ * This Feature is what allows EmberData to create subscriptions that
23
+ * work with any framework or change-notification system.
24
+ *
25
+ * @class NotificationManager
26
+ * @public
27
+ */
28
+ export default class NotificationManager {
29
+ store: Store;
30
+ isDestroyed: boolean;
31
+ _buffered: Map<StableDocumentIdentifier | StableRecordIdentifier, [string, string | undefined][]>;
32
+ _cache: Map<StableDocumentIdentifier | StableRecordIdentifier | 'resource' | 'document', Map<UnsubscribeToken, NotificationCallback | ResourceOperationCallback | DocumentOperationCallback>>;
33
+ _tokens: Map<UnsubscribeToken, StableDocumentIdentifier | StableRecordIdentifier | 'resource' | 'document'>;
34
+ _hasFlush: boolean;
35
+ _onFlushCB?: () => void;
36
+ constructor(store: Store);
37
+ /**
38
+ * Subscribe to changes for a given resource identifier, resource addition/removal, or document addition/removal.
39
+ *
40
+ * ```ts
41
+ * export type CacheOperation = 'added' | 'removed' | 'updated' | 'state';
42
+ *
43
+ * export interface NotificationCallback {
44
+ * (identifier: StableRecordIdentifier, notificationType: 'attributes' | 'relationships', key?: string): void;
45
+ * (identifier: StableRecordIdentifier, notificationType: 'errors' | 'meta' | 'identity' | 'state'): void;
46
+ * (identifier: StableRecordIdentifier, notificationType: NotificationType, key?: string): void;
47
+ * }
48
+ * export interface ResourceOperationCallback {
49
+ * // resource updates
50
+ * (identifier: StableRecordIdentifier, notificationType: CacheOperation): void;
51
+ * }
52
+ * export interface DocumentOperationCallback {
53
+ * // document updates
54
+ * (identifier: StableDocumentIdentifier, notificationType: CacheOperation): void;
55
+ * }
56
+ * ```
57
+ *
58
+ * @method subscribe
59
+ * @public
60
+ * @param {StableDocumentIdentifier | StableRecordIdentifier | 'resource' | 'document'} identifier
61
+ * @param {NotificationCallback | ResourceOperationCallback | DocumentOperationCallback} callback
62
+ * @return {UnsubscribeToken} an opaque token to be used with unsubscribe
63
+ */
64
+ subscribe(identifier: StableRecordIdentifier, callback: NotificationCallback): UnsubscribeToken;
65
+ subscribe(identifier: 'resource', callback: ResourceOperationCallback): UnsubscribeToken;
66
+ subscribe(identifier: StableDocumentIdentifier, callback: DocumentOperationCallback): UnsubscribeToken;
67
+ subscribe(identifier: 'document', callback: DocumentOperationCallback): UnsubscribeToken;
68
+ /**
69
+ * remove a previous subscription
70
+ *
71
+ * @method unsubscribe
72
+ * @public
73
+ * @param {UnsubscribeToken} token
74
+ */
75
+ unsubscribe(token: UnsubscribeToken): void;
76
+ /**
77
+ * Custom Caches and Application Code should not call this method directly.
78
+ *
79
+ * @method notify
80
+ * @param identifier
81
+ * @param value
82
+ * @param key
83
+ * @return {Boolean} whether a notification was delivered to any subscribers
84
+ * @private
85
+ */
86
+ notify(identifier: StableRecordIdentifier, value: 'attributes' | 'relationships', key?: string): boolean;
87
+ notify(identifier: StableRecordIdentifier, value: 'errors' | 'meta' | 'identity' | 'state'): boolean;
88
+ notify(identifier: StableRecordIdentifier | StableDocumentIdentifier, value: CacheOperation): boolean;
89
+ _onNextFlush(cb: () => void): void;
90
+ _scheduleNotify(): void;
91
+ _flush(): void;
92
+ _flushNotification(identifier: StableRecordIdentifier, value: 'attributes' | 'relationships', key?: string): boolean;
93
+ _flushNotification(identifier: StableRecordIdentifier, value: 'errors' | 'meta' | 'identity' | 'state'): boolean;
94
+ _flushNotification(identifier: StableRecordIdentifier | StableDocumentIdentifier, value: CacheOperation): boolean;
95
+ destroy(): void;
96
+ }
97
+ //# sourceMappingURL=notification-manager.d.ts.map
98
+ }
@@ -1,95 +1,97 @@
1
- import type { StableRecordIdentifier } from '@warp-drive/core-types/identifier';
2
- import type { ImmutableRequestInfo } from '@warp-drive/core-types/request';
3
- import type { CollectionResourceDocument } from '@warp-drive/core-types/spec/raw';
4
- import IdentifierArray, { Collection } from '../record-arrays/identifier-array';
5
- import type Store from '../store-service';
6
- import type { UnsubscribeToken } from './notification-manager';
7
- /**
8
- * This is a clever optimization.
9
- *
10
- * clever optimizations rarely stand the test of time, so if you're
11
- * ever curious or think something better is possible please benchmark
12
- * and discuss. The benchmark for this at the time of writing is in
13
- * `scripts/benchmark-push.js`
14
- *
15
- * This approach turns out to be 150x faster in Chrome and node than
16
- * simply using push or concat. It's highly susceptible to the specifics
17
- * of the batch size, and may require tuning.
18
- *
19
- * Clever optimizations should always come with a `why`. This optimization
20
- * exists for two reasons.
21
- *
22
- * 1) array.push(...objects) and Array.prototype.push.apply(arr, objects)
23
- * are susceptible to stack overflows. The size of objects at which this
24
- * occurs varies by environment, browser, and current stack depth and memory
25
- * pressure; however, it occurs in all browsers in fairly pristine conditions
26
- * somewhere around 125k to 200k elements. Since EmberData regularly encounters
27
- * arrays larger than this in size, we cannot use push.
28
- *
29
- * 2) `array.concat` or simply setting the array to a new reference is often an
30
- * easier approach; however, native Proxy to an array cannot swap it's target array
31
- * and attempts at juggling multiple array sources have proven to be victim to a number
32
- * of browser implementation bugs. Should these bugs be addressed then we could
33
- * simplify to using `concat`, however, do note this is currently 150x faster
34
- * than concat, and due to the overloaded signature of concat will likely always
35
- * be faster.
36
- *
37
- * Sincerely,
38
- * - runspired (Chris Thoburn) 08/21/2022
39
- *
40
- * @function fastPush
41
- * @internal
42
- * @param target the array to push into
43
- * @param source the items to push into target
44
- */
45
- export declare function fastPush<T>(target: T[], source: T[]): void;
46
- type ChangeSet = Map<StableRecordIdentifier, 'add' | 'del'>;
47
- /**
48
- @class RecordArrayManager
49
- @internal
50
- */
51
- declare class RecordArrayManager {
52
- store: Store;
53
- isDestroying: boolean;
54
- isDestroyed: boolean;
55
- _set: Map<IdentifierArray, Set<StableRecordIdentifier>>;
56
- _live: Map<string, IdentifierArray>;
57
- _managed: Set<IdentifierArray>;
58
- _pending: Map<IdentifierArray, ChangeSet>;
59
- _identifiers: Map<StableRecordIdentifier, Set<Collection>>;
60
- _staged: Map<string, ChangeSet>;
61
- _subscription: UnsubscribeToken;
62
- _keyedArrays: Map<string, Collection>;
63
- _visibilitySet: Map<StableRecordIdentifier, boolean>;
64
- constructor(options: {
65
- store: Store;
66
- });
67
- _syncArray(array: IdentifierArray): void;
68
- /**
69
- Get the `RecordArray` for a modelName, which contains all loaded records of
70
- given modelName.
71
-
72
- @method liveArrayFor
73
- @internal
74
- @param {String} modelName
75
- @return {RecordArray}
76
- */
77
- liveArrayFor(type: string): IdentifierArray;
78
- createArray(config: {
79
- type?: string;
80
- query?: ImmutableRequestInfo | Record<string, unknown>;
81
- identifiers?: StableRecordIdentifier[];
82
- doc?: CollectionResourceDocument;
83
- }): Collection;
84
- dirtyArray(array: IdentifierArray, delta: number): void;
85
- _getPendingFor(identifier: StableRecordIdentifier, includeManaged: boolean, isRemove?: boolean): Map<IdentifierArray, ChangeSet> | void;
86
- populateManagedArray(array: Collection, identifiers: StableRecordIdentifier[], payload: CollectionResourceDocument): void;
87
- identifierAdded(identifier: StableRecordIdentifier): void;
88
- identifierRemoved(identifier: StableRecordIdentifier): void;
89
- identifierChanged(identifier: StableRecordIdentifier): void;
90
- clear(isClear?: boolean): void;
91
- destroy(): void;
92
- }
93
- export declare function disassociateIdentifier(ArraysCache: Map<StableRecordIdentifier, Set<Collection>>, array: Collection, identifier: StableRecordIdentifier): void;
94
- export default RecordArrayManager;
95
- //# sourceMappingURL=record-array-manager.d.ts.map
1
+ declare module '@ember-data/store/-private/managers/record-array-manager' {
2
+ import type { StableRecordIdentifier } from '@warp-drive/core-types/identifier';
3
+ import type { ImmutableRequestInfo } from '@warp-drive/core-types/request';
4
+ import type { CollectionResourceDocument } from '@warp-drive/core-types/spec/raw';
5
+ import IdentifierArray, { Collection } from '@ember-data/store/-private/record-arrays/identifier-array';
6
+ import type Store from '@ember-data/store/-private/store-service';
7
+ import type { UnsubscribeToken } from '@ember-data/store/-private/managers/notification-manager';
8
+ /**
9
+ * This is a clever optimization.
10
+ *
11
+ * clever optimizations rarely stand the test of time, so if you're
12
+ * ever curious or think something better is possible please benchmark
13
+ * and discuss. The benchmark for this at the time of writing is in
14
+ * `scripts/benchmark-push.js`
15
+ *
16
+ * This approach turns out to be 150x faster in Chrome and node than
17
+ * simply using push or concat. It's highly susceptible to the specifics
18
+ * of the batch size, and may require tuning.
19
+ *
20
+ * Clever optimizations should always come with a `why`. This optimization
21
+ * exists for two reasons.
22
+ *
23
+ * 1) array.push(...objects) and Array.prototype.push.apply(arr, objects)
24
+ * are susceptible to stack overflows. The size of objects at which this
25
+ * occurs varies by environment, browser, and current stack depth and memory
26
+ * pressure; however, it occurs in all browsers in fairly pristine conditions
27
+ * somewhere around 125k to 200k elements. Since EmberData regularly encounters
28
+ * arrays larger than this in size, we cannot use push.
29
+ *
30
+ * 2) `array.concat` or simply setting the array to a new reference is often an
31
+ * easier approach; however, native Proxy to an array cannot swap it's target array
32
+ * and attempts at juggling multiple array sources have proven to be victim to a number
33
+ * of browser implementation bugs. Should these bugs be addressed then we could
34
+ * simplify to using `concat`, however, do note this is currently 150x faster
35
+ * than concat, and due to the overloaded signature of concat will likely always
36
+ * be faster.
37
+ *
38
+ * Sincerely,
39
+ * - runspired (Chris Thoburn) 08/21/2022
40
+ *
41
+ * @function fastPush
42
+ * @internal
43
+ * @param target the array to push into
44
+ * @param source the items to push into target
45
+ */
46
+ export declare function fastPush<T>(target: T[], source: T[]): void;
47
+ type ChangeSet = Map<StableRecordIdentifier, 'add' | 'del'>;
48
+ /**
49
+ @class RecordArrayManager
50
+ @internal
51
+ */
52
+ declare class RecordArrayManager {
53
+ store: Store;
54
+ isDestroying: boolean;
55
+ isDestroyed: boolean;
56
+ _set: Map<IdentifierArray, Set<StableRecordIdentifier>>;
57
+ _live: Map<string, IdentifierArray>;
58
+ _managed: Set<IdentifierArray>;
59
+ _pending: Map<IdentifierArray, ChangeSet>;
60
+ _identifiers: Map<StableRecordIdentifier, Set<Collection>>;
61
+ _staged: Map<string, ChangeSet>;
62
+ _subscription: UnsubscribeToken;
63
+ _keyedArrays: Map<string, Collection>;
64
+ _visibilitySet: Map<StableRecordIdentifier, boolean>;
65
+ constructor(options: {
66
+ store: Store;
67
+ });
68
+ _syncArray(array: IdentifierArray): void;
69
+ /**
70
+ Get the `RecordArray` for a modelName, which contains all loaded records of
71
+ given modelName.
72
+
73
+ @method liveArrayFor
74
+ @internal
75
+ @param {String} modelName
76
+ @return {RecordArray}
77
+ */
78
+ liveArrayFor(type: string): IdentifierArray;
79
+ createArray(config: {
80
+ type?: string;
81
+ query?: ImmutableRequestInfo | Record<string, unknown>;
82
+ identifiers?: StableRecordIdentifier[];
83
+ doc?: CollectionResourceDocument;
84
+ }): Collection;
85
+ dirtyArray(array: IdentifierArray, delta: number): void;
86
+ _getPendingFor(identifier: StableRecordIdentifier, includeManaged: boolean, isRemove?: boolean): Map<IdentifierArray, ChangeSet> | void;
87
+ populateManagedArray(array: Collection, identifiers: StableRecordIdentifier[], payload: CollectionResourceDocument): void;
88
+ identifierAdded(identifier: StableRecordIdentifier): void;
89
+ identifierRemoved(identifier: StableRecordIdentifier): void;
90
+ identifierChanged(identifier: StableRecordIdentifier): void;
91
+ clear(isClear?: boolean): void;
92
+ destroy(): void;
93
+ }
94
+ export declare function disassociateIdentifier(ArraysCache: Map<StableRecordIdentifier, Set<Collection>>, array: Collection, identifier: StableRecordIdentifier): void;
95
+ export default RecordArrayManager;
96
+ //# sourceMappingURL=record-array-manager.d.ts.map
97
+ }
@@ -1,107 +1,109 @@
1
- import type { StableRecordIdentifier } from '@warp-drive/core-types/identifier';
2
- import type { FindRecordOptions } from '../../-types/q/store';
3
- import type Store from '../store-service';
4
- declare const Touching: unique symbol;
5
- export declare const RequestPromise: unique symbol;
6
- export interface Operation {
7
- op: string;
8
- options: FindRecordOptions | undefined;
9
- recordIdentifier: StableRecordIdentifier;
10
- }
11
- export interface FindRecordQuery extends Operation {
12
- op: 'findRecord';
13
- }
14
- export interface SaveRecordMutation extends Operation {
15
- op: 'saveRecord';
16
- }
17
- export interface Request {
18
- data: Operation[];
19
- options?: Record<string, unknown>;
20
- }
21
- export type RequestStates = 'pending' | 'fulfilled' | 'rejected';
22
- export interface RequestState {
23
- state: RequestStates;
24
- type: 'query' | 'mutation';
25
- request: Request;
26
- response?: Response;
27
- }
28
- export interface Response {
29
- data: unknown;
30
- }
31
- interface InternalRequest extends RequestState {
32
- [Touching]: StableRecordIdentifier[];
33
- [RequestPromise]?: Promise<unknown>;
34
- }
35
- export type RequestSubscription = (requestState: RequestState) => void;
36
- /**
37
- * The RequestStateService is used to track the state of requests
38
- * for fetching or updating known resource identifies that are inflight.
39
- *
40
- * @class RequestStateService
41
- * @public
42
- */
43
- export default class RequestStateService {
44
- _pending: Map<StableRecordIdentifier, InternalRequest[]>;
45
- _done: Map<StableRecordIdentifier, InternalRequest[]>;
46
- _subscriptions: Map<StableRecordIdentifier, RequestSubscription[]>;
47
- _toFlush: InternalRequest[];
48
- _store: Store;
49
- constructor(store: Store);
50
- _clearEntries(identifier: StableRecordIdentifier): void;
51
- _enqueue<T>(promise: Promise<T>, queryRequest: Request): Promise<T>;
52
- _triggerSubscriptions(req: InternalRequest): void;
53
- _flush(): void;
54
- _flushRequest(req: InternalRequest): void;
55
- _dequeue(identifier: StableRecordIdentifier, request: InternalRequest): void;
56
- _addDone(request: InternalRequest): void;
57
- /**
58
- * Subscribe to requests for a given resource identity.
59
- *
60
- * The callback will receive the current state of the request.
61
- *
62
- * ```ts
63
- * interface RequestState {
64
- * state: 'pending' | 'fulfilled' | 'rejected';
65
- * type: 'query' | 'mutation';
66
- * request: Request;
67
- * response?: { data: unknown };
68
- * }
69
- * ```
70
- *
71
- * Note: It should be considered dangerous to use this API for more than simple
72
- * state derivation or debugging. The `request` and `response` properties are poorly
73
- * spec'd and may change unexpectedly when shifting what Handlers are in use or how
74
- * requests are issued from the Store.
75
- *
76
- * We expect to revisit this API in the near future as we continue to refine the
77
- * RequestManager ergonomics, as a simpler but more powerful direct integration
78
- * with the RequestManager for these purposes is likely to be a better long-term
79
- * design.
80
- *
81
- * @method subscribeForRecord
82
- * @public
83
- * @param {StableRecordIdentifier} identifier
84
- * @param {(state: RequestState) => void} callback
85
- */
86
- subscribeForRecord(identifier: StableRecordIdentifier, callback: RequestSubscription): void;
87
- /**
88
- * Retrieve all active requests for a given resource identity.
89
- *
90
- * @method getPendingRequestsForRecord
91
- * @public
92
- * @param {StableRecordIdentifier} identifier
93
- * @return {RequestState[]} an array of request states for any pending requests for the given identifier
94
- */
95
- getPendingRequestsForRecord(identifier: StableRecordIdentifier): RequestState[];
96
- /**
97
- * Retrieve the last completed request for a given resource identity.
98
- *
99
- * @method getLastRequestForRecord
100
- * @public
101
- * @param {StableRecordIdentifier} identifier
102
- * @return {RequestState | null} the state of the most recent request for the given identifier
103
- */
104
- getLastRequestForRecord(identifier: StableRecordIdentifier): RequestState | null;
105
- }
106
- export {};
107
- //# sourceMappingURL=request-cache.d.ts.map
1
+ declare module '@ember-data/store/-private/network/request-cache' {
2
+ import type { StableRecordIdentifier } from '@warp-drive/core-types/identifier';
3
+ import type { FindRecordOptions } from '@ember-data/store/-types/q/store';
4
+ import type Store from '@ember-data/store/-private/store-service';
5
+ declare const Touching: unique symbol;
6
+ export declare const RequestPromise: unique symbol;
7
+ export interface Operation {
8
+ op: string;
9
+ options: FindRecordOptions | undefined;
10
+ recordIdentifier: StableRecordIdentifier;
11
+ }
12
+ export interface FindRecordQuery extends Operation {
13
+ op: 'findRecord';
14
+ }
15
+ export interface SaveRecordMutation extends Operation {
16
+ op: 'saveRecord';
17
+ }
18
+ export interface Request {
19
+ data: Operation[];
20
+ options?: Record<string, unknown>;
21
+ }
22
+ export type RequestStates = 'pending' | 'fulfilled' | 'rejected';
23
+ export interface RequestState {
24
+ state: RequestStates;
25
+ type: 'query' | 'mutation';
26
+ request: Request;
27
+ response?: Response;
28
+ }
29
+ export interface Response {
30
+ data: unknown;
31
+ }
32
+ interface InternalRequest extends RequestState {
33
+ [Touching]: StableRecordIdentifier[];
34
+ [RequestPromise]?: Promise<unknown>;
35
+ }
36
+ export type RequestSubscription = (requestState: RequestState) => void;
37
+ /**
38
+ * The RequestStateService is used to track the state of requests
39
+ * for fetching or updating known resource identifies that are inflight.
40
+ *
41
+ * @class RequestStateService
42
+ * @public
43
+ */
44
+ export default class RequestStateService {
45
+ _pending: Map<StableRecordIdentifier, InternalRequest[]>;
46
+ _done: Map<StableRecordIdentifier, InternalRequest[]>;
47
+ _subscriptions: Map<StableRecordIdentifier, RequestSubscription[]>;
48
+ _toFlush: InternalRequest[];
49
+ _store: Store;
50
+ constructor(store: Store);
51
+ _clearEntries(identifier: StableRecordIdentifier): void;
52
+ _enqueue<T>(promise: Promise<T>, queryRequest: Request): Promise<T>;
53
+ _triggerSubscriptions(req: InternalRequest): void;
54
+ _flush(): void;
55
+ _flushRequest(req: InternalRequest): void;
56
+ _dequeue(identifier: StableRecordIdentifier, request: InternalRequest): void;
57
+ _addDone(request: InternalRequest): void;
58
+ /**
59
+ * Subscribe to requests for a given resource identity.
60
+ *
61
+ * The callback will receive the current state of the request.
62
+ *
63
+ * ```ts
64
+ * interface RequestState {
65
+ * state: 'pending' | 'fulfilled' | 'rejected';
66
+ * type: 'query' | 'mutation';
67
+ * request: Request;
68
+ * response?: { data: unknown };
69
+ * }
70
+ * ```
71
+ *
72
+ * Note: It should be considered dangerous to use this API for more than simple
73
+ * state derivation or debugging. The `request` and `response` properties are poorly
74
+ * spec'd and may change unexpectedly when shifting what Handlers are in use or how
75
+ * requests are issued from the Store.
76
+ *
77
+ * We expect to revisit this API in the near future as we continue to refine the
78
+ * RequestManager ergonomics, as a simpler but more powerful direct integration
79
+ * with the RequestManager for these purposes is likely to be a better long-term
80
+ * design.
81
+ *
82
+ * @method subscribeForRecord
83
+ * @public
84
+ * @param {StableRecordIdentifier} identifier
85
+ * @param {(state: RequestState) => void} callback
86
+ */
87
+ subscribeForRecord(identifier: StableRecordIdentifier, callback: RequestSubscription): void;
88
+ /**
89
+ * Retrieve all active requests for a given resource identity.
90
+ *
91
+ * @method getPendingRequestsForRecord
92
+ * @public
93
+ * @param {StableRecordIdentifier} identifier
94
+ * @return {RequestState[]} an array of request states for any pending requests for the given identifier
95
+ */
96
+ getPendingRequestsForRecord(identifier: StableRecordIdentifier): RequestState[];
97
+ /**
98
+ * Retrieve the last completed request for a given resource identity.
99
+ *
100
+ * @method getLastRequestForRecord
101
+ * @public
102
+ * @param {StableRecordIdentifier} identifier
103
+ * @return {RequestState | null} the state of the most recent request for the given identifier
104
+ */
105
+ getLastRequestForRecord(identifier: StableRecordIdentifier): RequestState | null;
106
+ }
107
+ export {};
108
+ //# sourceMappingURL=request-cache.d.ts.map
109
+ }