@ember-data/store 4.10.0-alpha.2 → 4.10.0-alpha.21

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 (39) hide show
  1. package/addon/-private.js +1 -0
  2. package/addon/-private.js.map +1 -0
  3. package/addon/index-12e1fcb9.js +7660 -0
  4. package/addon/index-12e1fcb9.js.map +1 -0
  5. package/addon/index.js +1 -0
  6. package/addon/index.js.map +1 -0
  7. package/addon-main.js +90 -0
  8. package/package.json +44 -15
  9. package/addon/-private/caches/identifier-cache.ts +0 -686
  10. package/addon/-private/caches/instance-cache.ts +0 -695
  11. package/addon/-private/caches/record-data-for.ts +0 -34
  12. package/addon/-private/index.ts +0 -59
  13. package/addon/-private/legacy-model-support/record-reference.ts +0 -240
  14. package/addon/-private/legacy-model-support/schema-definition-service.ts +0 -148
  15. package/addon/-private/legacy-model-support/shim-model-class.ts +0 -97
  16. package/addon/-private/managers/record-array-manager.ts +0 -379
  17. package/addon/-private/managers/record-data-manager.ts +0 -845
  18. package/addon/-private/managers/record-data-store-wrapper.ts +0 -425
  19. package/addon/-private/managers/record-notification-manager.ts +0 -111
  20. package/addon/-private/network/fetch-manager.ts +0 -567
  21. package/addon/-private/network/finders.js +0 -104
  22. package/addon/-private/network/request-cache.ts +0 -132
  23. package/addon/-private/network/snapshot-record-array.ts +0 -209
  24. package/addon/-private/network/snapshot.ts +0 -563
  25. package/addon/-private/proxies/promise-proxies.ts +0 -228
  26. package/addon/-private/proxies/promise-proxy-base.js +0 -7
  27. package/addon/-private/record-arrays/identifier-array.ts +0 -929
  28. package/addon/-private/store-service.ts +0 -2896
  29. package/addon/-private/utils/coerce-id.ts +0 -41
  30. package/addon/-private/utils/common.js +0 -65
  31. package/addon/-private/utils/construct-resource.ts +0 -61
  32. package/addon/-private/utils/identifer-debug-consts.ts +0 -3
  33. package/addon/-private/utils/is-non-empty-string.ts +0 -3
  34. package/addon/-private/utils/normalize-model-name.ts +0 -21
  35. package/addon/-private/utils/promise-record.ts +0 -15
  36. package/addon/-private/utils/serializer-response.ts +0 -86
  37. package/addon/-private/utils/uuid-polyfill.ts +0 -73
  38. package/addon/index.ts +0 -14
  39. package/index.js +0 -49
@@ -1,228 +0,0 @@
1
- import { deprecate } from '@ember/debug';
2
- import { get } from '@ember/object';
3
- import type ComputedProperty from '@ember/object/computed';
4
- import { reads } from '@ember/object/computed';
5
- import { DEBUG } from '@glimmer/env';
6
-
7
- import { resolve } from 'rsvp';
8
-
9
- import type { Dict } from '@ember-data/types/q/utils';
10
-
11
- import { PromiseArrayProxy, PromiseObjectProxy } from './promise-proxy-base';
12
-
13
- /**
14
- @module @ember-data/store
15
- */
16
-
17
- /**
18
- A `PromiseArray` is an object that acts like both an `Ember.Array`
19
- and a promise. When the promise is resolved the resulting value
20
- will be set to the `PromiseArray`'s `content` property. This makes
21
- it easy to create data bindings with the `PromiseArray` that will be
22
- updated when the promise resolves.
23
-
24
- This class should not be imported and instantiated directly.
25
-
26
- For more information see the [Ember.PromiseProxyMixin
27
- documentation](/ember/release/classes/PromiseProxyMixin).
28
-
29
- Example
30
-
31
- ```javascript
32
- let promiseArray = PromiseArray.create({
33
- promise: $.getJSON('/some/remote/data.json')
34
- });
35
-
36
- promiseArray.length; // 0
37
-
38
- promiseArray.then(function() {
39
- promiseArray.length; // 100
40
- });
41
- ```
42
-
43
- @class PromiseArray
44
- @public
45
- @extends Ember.ArrayProxy
46
- @uses Ember.PromiseProxyMixin
47
- */
48
- interface EmberNativeArrayLike<T> {
49
- length: number | ComputedProperty<number>;
50
- objectAt(idx: number): T | undefined;
51
- }
52
- interface EmberArrayProxyLike<T> {
53
- length: number | ComputedProperty<number>;
54
- objectAtContent(idx: number): T | undefined;
55
- }
56
- type EmberArrayLike<T> = EmberNativeArrayLike<T> | EmberArrayProxyLike<T>;
57
-
58
- export class PromiseArray<I, T extends EmberArrayLike<I>> extends PromiseArrayProxy<I, T> {
59
- @reads('content.meta')
60
- declare meta?: Dict<unknown>;
61
- }
62
-
63
- /**
64
- A `PromiseObject` is an object that acts like both an `EmberObject`
65
- and a promise. When the promise is resolved, then the resulting value
66
- will be set to the `PromiseObject`'s `content` property. This makes
67
- it easy to create data bindings with the `PromiseObject` that will
68
- be updated when the promise resolves.
69
-
70
- This class should not be imported and instantiated directly.
71
-
72
- For more information see the [Ember.PromiseProxyMixin
73
- documentation](/ember/release/classes/PromiseProxyMixin.html).
74
-
75
- Example
76
-
77
- ```javascript
78
- let promiseObject = PromiseObject.create({
79
- promise: $.getJSON('/some/remote/data.json')
80
- });
81
-
82
- promiseObject.name; // null
83
-
84
- promiseObject.then(function() {
85
- promiseObject.name; // 'Tomster'
86
- });
87
- ```
88
-
89
- @class PromiseObject
90
- @public
91
- @extends Ember.ObjectProxy
92
- @uses Ember.PromiseProxyMixin
93
- */
94
- export { PromiseObjectProxy as PromiseObject };
95
-
96
- function _promiseObject<T>(promise: Promise<T>, label?: string): PromiseObjectProxy<T> {
97
- return PromiseObjectProxy.create({
98
- promise: resolve(promise, label),
99
- }) as PromiseObjectProxy<T>;
100
- }
101
-
102
- function _promiseArray<I, T extends EmberArrayLike<I>>(promise: Promise<T>, label?: string): PromiseArray<I, T> {
103
- return PromiseArray.create({
104
- promise: resolve(promise, label),
105
- }) as unknown as PromiseArray<I, T>;
106
- }
107
-
108
- // constructor is accessed in some internals but not including it in the copyright for the deprecation
109
- const ALLOWABLE_METHODS = ['constructor', 'then', 'catch', 'finally'];
110
- const ALLOWABLE_PROPS = ['__ec_yieldable__', '__ec_cancel__'];
111
- const PROXIED_ARRAY_PROPS = [
112
- 'length',
113
- '[]',
114
- 'firstObject',
115
- 'lastObject',
116
- 'meta',
117
- 'content',
118
- 'isPending',
119
- 'isSettled',
120
- 'isRejected',
121
- 'isFulfilled',
122
- 'promise',
123
- 'reason',
124
- ];
125
- const PROXIED_OBJECT_PROPS = ['content', 'isPending', 'isSettled', 'isRejected', 'isFulfilled', 'promise', 'reason'];
126
-
127
- export function promiseArray<I, T extends EmberArrayLike<I>>(promise: Promise<T>): PromiseArray<I, T> {
128
- const promiseObjectProxy: PromiseArray<I, T> = _promiseArray(promise);
129
- if (!DEBUG) {
130
- return promiseObjectProxy;
131
- }
132
- const handler = {
133
- get(target: object, prop: string, receiver: object): unknown {
134
- if (typeof prop === 'symbol') {
135
- return Reflect.get(target, prop, receiver);
136
- }
137
- if (ALLOWABLE_PROPS.includes(prop)) {
138
- return receiver[prop];
139
- }
140
- if (!ALLOWABLE_METHODS.includes(prop)) {
141
- deprecate(
142
- `Accessing ${prop} on this PromiseArray is deprecated. The return type is being changed from PromiseArray to a Promise. The only available methods to access on this promise are .then, .catch and .finally`,
143
- false,
144
- {
145
- id: 'ember-data:deprecate-promise-proxies',
146
- until: '5.0',
147
- for: '@ember-data/store',
148
- since: {
149
- available: '4.7',
150
- enabled: '4.7',
151
- },
152
- }
153
- );
154
- }
155
-
156
- const value: unknown = target[prop];
157
- if (value && typeof value === 'function' && typeof value.bind === 'function') {
158
- return value.bind(target);
159
- }
160
-
161
- if (PROXIED_ARRAY_PROPS.includes(prop)) {
162
- return value;
163
- }
164
-
165
- return undefined;
166
- },
167
- };
168
-
169
- return new Proxy(promiseObjectProxy, handler);
170
- }
171
-
172
- const ProxySymbolString = String(Symbol.for('PROXY_CONTENT'));
173
-
174
- export function promiseObject<T>(promise: Promise<T>): PromiseObjectProxy<T> {
175
- const promiseObjectProxy: PromiseObjectProxy<T> = _promiseObject(promise);
176
- if (!DEBUG) {
177
- return promiseObjectProxy;
178
- }
179
- const handler = {
180
- get(target: object, prop: string, receiver: object): unknown {
181
- if (typeof prop === 'symbol') {
182
- if (String(prop) === ProxySymbolString) {
183
- return;
184
- }
185
- return Reflect.get(target, prop, receiver);
186
- }
187
-
188
- if (prop === 'constructor') {
189
- return target.constructor;
190
- }
191
-
192
- if (ALLOWABLE_PROPS.includes(prop)) {
193
- return receiver[prop];
194
- }
195
-
196
- if (!ALLOWABLE_METHODS.includes(prop)) {
197
- deprecate(
198
- `Accessing ${prop} on this PromiseObject is deprecated. The return type is being changed from PromiseObject to a Promise. The only available methods to access on this promise are .then, .catch and .finally`,
199
- false,
200
- {
201
- id: 'ember-data:deprecate-promise-proxies',
202
- until: '5.0',
203
- for: '@ember-data/store',
204
- since: {
205
- available: '4.7',
206
- enabled: '4.7',
207
- },
208
- }
209
- );
210
- } else {
211
- return (target[prop] as () => unknown).bind(target);
212
- }
213
-
214
- if (PROXIED_OBJECT_PROPS.includes(prop)) {
215
- return target[prop];
216
- }
217
-
218
- const value: unknown = get(target, prop);
219
- if (value && typeof value === 'function' && typeof value.bind === 'function') {
220
- return value.bind(receiver);
221
- }
222
-
223
- return undefined;
224
- },
225
- };
226
-
227
- return new Proxy(promiseObjectProxy, handler);
228
- }
@@ -1,7 +0,0 @@
1
- import ArrayProxy from '@ember/array/proxy';
2
- import PromiseProxyMixin from '@ember/object/promise-proxy-mixin';
3
- import ObjectProxy from '@ember/object/proxy';
4
-
5
- export const PromiseArrayProxy = ArrayProxy.extend(PromiseProxyMixin);
6
-
7
- export const PromiseObjectProxy = ObjectProxy.extend(PromiseProxyMixin);