@ember-data/store 5.4.0-alpha.30 → 5.4.0-alpha.31

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 (70) hide show
  1. package/addon/cache-handler-oB00-31L.js.map +1 -1
  2. package/package.json +11 -10
  3. package/unstable-preview-types/-private/cache-handler.d.ts +99 -0
  4. package/unstable-preview-types/-private/cache-handler.d.ts.map +1 -0
  5. package/unstable-preview-types/-private/caches/cache-utils.d.ts +9 -0
  6. package/unstable-preview-types/-private/caches/cache-utils.d.ts.map +1 -0
  7. package/unstable-preview-types/-private/caches/identifier-cache.d.ts +180 -0
  8. package/unstable-preview-types/-private/caches/identifier-cache.d.ts.map +1 -0
  9. package/unstable-preview-types/-private/caches/instance-cache.d.ts +61 -0
  10. package/unstable-preview-types/-private/caches/instance-cache.d.ts.map +1 -0
  11. package/unstable-preview-types/-private/caches/resource-utils.d.ts +10 -0
  12. package/unstable-preview-types/-private/caches/resource-utils.d.ts.map +1 -0
  13. package/unstable-preview-types/-private/document.d.ts +144 -0
  14. package/unstable-preview-types/-private/document.d.ts.map +1 -0
  15. package/unstable-preview-types/-private/index.d.ts +16 -0
  16. package/unstable-preview-types/-private/index.d.ts.map +1 -0
  17. package/unstable-preview-types/-private/legacy-model-support/record-reference.d.ts +177 -0
  18. package/unstable-preview-types/-private/legacy-model-support/record-reference.d.ts.map +1 -0
  19. package/unstable-preview-types/-private/legacy-model-support/shim-model-class.d.ts +17 -0
  20. package/unstable-preview-types/-private/legacy-model-support/shim-model-class.d.ts.map +1 -0
  21. package/unstable-preview-types/-private/managers/cache-capabilities-manager.d.ts +27 -0
  22. package/unstable-preview-types/-private/managers/cache-capabilities-manager.d.ts.map +1 -0
  23. package/unstable-preview-types/-private/managers/cache-manager.d.ts +440 -0
  24. package/unstable-preview-types/-private/managers/cache-manager.d.ts.map +1 -0
  25. package/unstable-preview-types/-private/managers/notification-manager.d.ts +96 -0
  26. package/unstable-preview-types/-private/managers/notification-manager.d.ts.map +1 -0
  27. package/unstable-preview-types/-private/managers/record-array-manager.d.ts +95 -0
  28. package/unstable-preview-types/-private/managers/record-array-manager.d.ts.map +1 -0
  29. package/unstable-preview-types/-private/network/request-cache.d.ts +107 -0
  30. package/unstable-preview-types/-private/network/request-cache.d.ts.map +1 -0
  31. package/unstable-preview-types/-private/record-arrays/identifier-array.d.ts +135 -0
  32. package/unstable-preview-types/-private/record-arrays/identifier-array.d.ts.map +1 -0
  33. package/unstable-preview-types/-private/store-service.d.ts +1552 -0
  34. package/unstable-preview-types/-private/store-service.d.ts.map +1 -0
  35. package/unstable-preview-types/-private/utils/coerce-id.d.ts +8 -0
  36. package/unstable-preview-types/-private/utils/coerce-id.d.ts.map +1 -0
  37. package/unstable-preview-types/-private/utils/construct-resource.d.ts +8 -0
  38. package/unstable-preview-types/-private/utils/construct-resource.d.ts.map +1 -0
  39. package/unstable-preview-types/-private/utils/identifier-debug-consts.d.ts +5 -0
  40. package/unstable-preview-types/-private/utils/identifier-debug-consts.d.ts.map +1 -0
  41. package/unstable-preview-types/-private/utils/is-non-empty-string.d.ts +2 -0
  42. package/unstable-preview-types/-private/utils/is-non-empty-string.d.ts.map +1 -0
  43. package/unstable-preview-types/-private/utils/normalize-model-name.d.ts +2 -0
  44. package/unstable-preview-types/-private/utils/normalize-model-name.d.ts.map +1 -0
  45. package/unstable-preview-types/-private/utils/uuid-polyfill.d.ts +2 -0
  46. package/unstable-preview-types/-private/utils/uuid-polyfill.d.ts.map +1 -0
  47. package/unstable-preview-types/-private.d.ts +2 -0
  48. package/unstable-preview-types/-private.d.ts.map +1 -0
  49. package/unstable-preview-types/-types/overview.d.ts +19 -0
  50. package/unstable-preview-types/-types/overview.d.ts.map +1 -0
  51. package/unstable-preview-types/-types/q/cache-store-wrapper.d.ts +105 -0
  52. package/unstable-preview-types/-types/q/cache-store-wrapper.d.ts.map +1 -0
  53. package/unstable-preview-types/-types/q/cache.d.ts +45 -0
  54. package/unstable-preview-types/-types/q/cache.d.ts.map +1 -0
  55. package/unstable-preview-types/-types/q/ds-model.d.ts +13 -0
  56. package/unstable-preview-types/-types/q/ds-model.d.ts.map +1 -0
  57. package/unstable-preview-types/-types/q/identifier.d.ts +169 -0
  58. package/unstable-preview-types/-types/q/identifier.d.ts.map +1 -0
  59. package/unstable-preview-types/-types/q/promise-proxies.d.ts +2 -0
  60. package/unstable-preview-types/-types/q/promise-proxies.d.ts.map +1 -0
  61. package/unstable-preview-types/-types/q/record-data-json-api.d.ts +34 -0
  62. package/unstable-preview-types/-types/q/record-data-json-api.d.ts.map +1 -0
  63. package/unstable-preview-types/-types/q/record-instance.d.ts +27 -0
  64. package/unstable-preview-types/-types/q/record-instance.d.ts.map +1 -0
  65. package/unstable-preview-types/-types/q/schema-service.d.ts +212 -0
  66. package/unstable-preview-types/-types/q/schema-service.d.ts.map +1 -0
  67. package/unstable-preview-types/-types/q/store.d.ts +15 -0
  68. package/unstable-preview-types/-types/q/store.d.ts.map +1 -0
  69. package/unstable-preview-types/index.d.ts +185 -0
  70. package/unstable-preview-types/index.d.ts.map +1 -0
@@ -0,0 +1,96 @@
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
@@ -0,0 +1 @@
1
+ {"version":3,"file":"notification-manager.d.ts","sourceRoot":"","sources":["../../../src/-private/managers/notification-manager.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,wBAAwB,EAAE,sBAAsB,EAAE,MAAM,mCAAmC,CAAC;AAG1G,OAAO,KAAK,KAAK,MAAM,kBAAkB,CAAC;AAE1C,MAAM,MAAM,gBAAgB,GAAG,MAAM,CAAC;AAItC,MAAM,MAAM,cAAc,GAAG,OAAO,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AAwB,EAAE,KAAK,EAAE,cAAc,GAAG,OAAO;IAoCjH,OAAO;CAKR"}
@@ -0,0 +1,95 @@
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
@@ -0,0 +1 @@
1
+ {"version":3,"file":"record-array-manager.d.ts","sourceRoot":"","sources":["../../../src/-private/managers/record-array-manager.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,mCAAmC,CAAC;AAChF,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,gCAAgC,CAAC;AAC3E,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,iCAAiC,CAAC;AAGlF,OAAO,eAAe,EAAE,EAEtB,UAAU,EAIX,MAAM,mCAAmC,CAAC;AAC3C,OAAO,KAAK,KAAK,MAAM,kBAAkB,CAAC;AAC1C,OAAO,KAAK,EAAkB,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAI/E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AACH,wBAAgB,QAAQ,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,EAAE,MAAM,EAAE,CAAC,EAAE,QAUnD;AAED,KAAK,SAAS,GAAG,GAAG,CAAC,sBAAsB,EAAE,KAAK,GAAG,KAAK,CAAC,CAAC;AAE5D;;;EAGE;AACF,cAAM,kBAAkB;IACd,KAAK,EAAE,KAAK,CAAC;IACb,YAAY,EAAE,OAAO,CAAC;IACtB,WAAW,EAAE,OAAO,CAAC;IACrB,IAAI,EAAE,GAAG,CAAC,eAAe,EAAE,GAAG,CAAC,sBAAsB,CAAC,CAAC,CAAC;IACxD,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC;IACpC,QAAQ,EAAE,GAAG,CAAC,eAAe,CAAC,CAAC;IAC/B,QAAQ,EAAE,GAAG,CAAC,eAAe,EAAE,SAAS,CAAC,CAAC;IAC1C,YAAY,EAAE,GAAG,CAAC,sBAAsB,EAAE,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC;IAC3D,OAAO,EAAE,GAAG,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;IAChC,a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EAAE,sBAAsB,QAMnC;AAuDD,eAAe,kBAAkB,CAAC"}
@@ -0,0 +1,107 @@
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
@@ -0,0 +1 @@
1
+ {"version":3,"file":"request-cache.d.ts","sourceRoot":"","sources":["../../../src/-private/network/request-cache.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,mC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QAAQ,EAAE,GAAG,CAAC,sBAAsB,EAAE,eAAe,EAAE,CAAC,CAAa;IACrE,KAAK,EAAE,GAAG,CAAC,sBAAsB,EAAE,eAAe,EAAE,CAAC,CAAa;IAClE,cAAc,EAAE,GAAG,CAAC,sBAAsB,EAAE,mBAAmB,EAAE,CAAC,CAAa;IAC/E,QAAQ,EAAE,eAAe,EAAE,CAAM;IACjC,MAAM,EAAE,KAAK,CAAC;gBAEF,KAAK,EAAE,KAAK;IAIxB,aAAa,CAAC,UAAU,EAAE,sBAAsB;IAIhD,QAAQ,CAAC,CAAC,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,EAAE,YAAY,EAAE,OAAO,GAAG,OAAO,CAAC,CAAC,CAAC;IAiDnE,qBAAqB,CAAC,GAAG,EAAE,eAAe,GAAG,IAAI;IAcjD,MAAM,IAAI,IAAI;IAOd,aAAa,CAAC,GAAG,EAAE,eAAe,GAAG,IAAI;IASzC,QAAQ,CAAC,UAAU,EAAE,sBAAsB,EAAE,OAAO,EAAE,eAAe;IAQrE,QAAQ,CAAC,OAAO,EAAE,eAAe;IAwBjC;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA4BG;IACH,kBAAkB,CAAC,UAAU,EAAE,sBAAsB,EAAE,QAAQ,EAAE,mBAAmB;IASpF;;;;;;;OAOG;IACH,2BAA2B,CAAC,UAAU,EAAE,sBAAsB,GAAG,YAAY,EAAE;IAI/E;;;;;;;OAOG;IACH,uBAAuB,CAAC,UAAU,EAAE,sBAAsB,GAAG,YAAY,GAAG,IAAI;CAOjF"}
@@ -0,0 +1,135 @@
1
+ import type { Signal } from '@ember-data/tracking/-private';
2
+ import type { StableRecordIdentifier } from '@warp-drive/core-types/identifier';
3
+ import type { TypedRecordInstance, TypeFromInstance } from '@warp-drive/core-types/record';
4
+ import type { ImmutableRequestInfo } from '@warp-drive/core-types/request';
5
+ import type { Links, PaginationLinks } from '@warp-drive/core-types/spec/raw';
6
+ import type RecordArrayManager from '../managers/record-array-manager';
7
+ import type Store from '../store-service';
8
+ export declare const ARRAY_SIGNAL: unique symbol;
9
+ export declare const SOURCE: unique symbol;
10
+ export declare const MUTATE: unique symbol;
11
+ export declare const NOTIFY: unique symbol;
12
+ declare const IS_COLLECTION: unique symbol;
13
+ export declare function notifyArray(arr: IdentifierArray): void;
14
+ declare global {
15
+ interface ProxyConstructor {
16
+ new <TSource extends object, TTarget extends object>(target: TSource, handler: ProxyHandler<TSource>): TTarget;
17
+ }
18
+ }
19
+ export type IdentifierArrayCreateOptions<T = unknown> = {
20
+ identifiers: StableRecordIdentifier[];
21
+ type?: T extends TypedRecordInstance ? TypeFromInstance<T> : string;
22
+ store: Store;
23
+ allowMutation: boolean;
24
+ manager: RecordArrayManager;
25
+ links?: Links | PaginationLinks | null;
26
+ meta?: Record<string, unknown> | null;
27
+ };
28
+ /**
29
+ A record array is an array that contains records of a certain type (or modelName).
30
+ The record array materializes records as needed when they are retrieved for the first
31
+ time. You should not create record arrays yourself. Instead, an instance of
32
+ `RecordArray` or its subclasses will be returned by your application's store
33
+ in response to queries.
34
+
35
+ This class should not be imported and instantiated by consuming applications.
36
+
37
+ @class RecordArray
38
+ @public
39
+ */
40
+ interface IdentifierArray<T = unknown> extends Omit<Array<T>, '[]'> {
41
+ [MUTATE]?(target: StableRecordIdentifier[], receiver: typeof Proxy<StableRecordIdentifier[], T[]>, prop: string, args: unknown[], _SIGNAL: Signal): unknown;
42
+ }
43
+ declare class IdentifierArray<T = unknown> {
44
+ DEPRECATED_CLASS_NAME: string;
45
+ /**
46
+ The flag to signal a `RecordArray` is currently loading data.
47
+ Example
48
+ ```javascript
49
+ let people = store.peekAll('person');
50
+ people.isUpdating; // false
51
+ people.update();
52
+ people.isUpdating; // true
53
+ ```
54
+ @property isUpdating
55
+ @public
56
+ @type Boolean
57
+ */
58
+ isUpdating: boolean;
59
+ isLoaded: boolean;
60
+ isDestroying: boolean;
61
+ isDestroyed: boolean;
62
+ _updatingPromise: Promise<IdentifierArray<T>> | null;
63
+ [IS_COLLECTION]: boolean;
64
+ [ARRAY_SIGNAL]: Signal;
65
+ [SOURCE]: StableRecordIdentifier[];
66
+ [NOTIFY](): void;
67
+ links: Links | PaginationLinks | null;
68
+ meta: Record<string, unknown> | null;
69
+ modelName?: T extends TypedRecordInstance ? TypeFromInstance<T> : string;
70
+ /**
71
+ The store that created this record array.
72
+
73
+ @property store
74
+ @private
75
+ @type Store
76
+ */
77
+ store: Store;
78
+ _manager: RecordArrayManager;
79
+ destroy(clear: boolean): void;
80
+ get length(): number;
81
+ set length(value: number);
82
+ constructor(options: IdentifierArrayCreateOptions<T>);
83
+ /**
84
+ Used to get the latest version of all of the records in this array
85
+ from the adapter.
86
+
87
+ Example
88
+
89
+ ```javascript
90
+ let people = store.peekAll('person');
91
+ people.isUpdating; // false
92
+
93
+ people.update().then(function() {
94
+ people.isUpdating; // false
95
+ });
96
+
97
+ people.isUpdating; // true
98
+ ```
99
+
100
+ @method update
101
+ @public
102
+ */
103
+ update(): Promise<IdentifierArray<T>>;
104
+ _update(): Promise<IdentifierArray<T>>;
105
+ /**
106
+ Saves all of the records in the `RecordArray`.
107
+
108
+ Example
109
+
110
+ ```javascript
111
+ let messages = store.peekAll('message');
112
+ messages.forEach(function(message) {
113
+ message.hasBeenSeen = true;
114
+ });
115
+ messages.save();
116
+ ```
117
+
118
+ @method save
119
+ @public
120
+ @return {Promise<IdentifierArray>} promise
121
+ */
122
+ save(): Promise<IdentifierArray>;
123
+ }
124
+ export default IdentifierArray;
125
+ export type CollectionCreateOptions = IdentifierArrayCreateOptions & {
126
+ query: ImmutableRequestInfo | Record<string, unknown> | null;
127
+ isLoaded: boolean;
128
+ };
129
+ export declare class Collection<T = unknown> extends IdentifierArray<T> {
130
+ query: ImmutableRequestInfo | Record<string, unknown> | null;
131
+ constructor(options: CollectionCreateOptions);
132
+ _update(): Promise<Collection<T>>;
133
+ destroy(clear: boolean): void;
134
+ }
135
+ //# sourceMappingURL=identifier-array.d.ts.map
@@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