@ember-data/legacy-compat 5.6.0-beta.0 → 5.6.0-beta.2

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 (50) hide show
  1. package/addon-main.cjs +1 -1
  2. package/dist/-private.js +1 -1
  3. package/dist/builders.js +1 -323
  4. package/dist/index.js +1 -1011
  5. package/dist/utils.js +1 -246
  6. package/package.json +7 -34
  7. package/unstable-preview-types/-private.d.ts +7 -14
  8. package/unstable-preview-types/builders.d.ts +9 -13
  9. package/unstable-preview-types/index.d.ts +4 -159
  10. package/unstable-preview-types/utils.d.ts +9 -159
  11. package/dist/-private-Bnt-3W7M.js +0 -1207
  12. package/dist/-private-Bnt-3W7M.js.map +0 -1
  13. package/dist/-private.js.map +0 -1
  14. package/dist/builders.js.map +0 -1
  15. package/dist/index.js.map +0 -1
  16. package/dist/utils.js.map +0 -1
  17. package/unstable-preview-types/-private.d.ts.map +0 -1
  18. package/unstable-preview-types/builders/find-all.d.ts +0 -41
  19. package/unstable-preview-types/builders/find-all.d.ts.map +0 -1
  20. package/unstable-preview-types/builders/find-record.d.ts +0 -62
  21. package/unstable-preview-types/builders/find-record.d.ts.map +0 -1
  22. package/unstable-preview-types/builders/query.d.ts +0 -72
  23. package/unstable-preview-types/builders/query.d.ts.map +0 -1
  24. package/unstable-preview-types/builders/save-record.d.ts +0 -40
  25. package/unstable-preview-types/builders/save-record.d.ts.map +0 -1
  26. package/unstable-preview-types/builders/utils.d.ts +0 -6
  27. package/unstable-preview-types/builders/utils.d.ts.map +0 -1
  28. package/unstable-preview-types/builders.d.ts.map +0 -1
  29. package/unstable-preview-types/index.d.ts.map +0 -1
  30. package/unstable-preview-types/legacy-network-handler/fetch-manager.d.ts +0 -49
  31. package/unstable-preview-types/legacy-network-handler/fetch-manager.d.ts.map +0 -1
  32. package/unstable-preview-types/legacy-network-handler/identifier-has-id.d.ts +0 -5
  33. package/unstable-preview-types/legacy-network-handler/identifier-has-id.d.ts.map +0 -1
  34. package/unstable-preview-types/legacy-network-handler/legacy-data-fetch.d.ts +0 -14
  35. package/unstable-preview-types/legacy-network-handler/legacy-data-fetch.d.ts.map +0 -1
  36. package/unstable-preview-types/legacy-network-handler/legacy-data-utils.d.ts +0 -8
  37. package/unstable-preview-types/legacy-network-handler/legacy-data-utils.d.ts.map +0 -1
  38. package/unstable-preview-types/legacy-network-handler/legacy-network-handler.d.ts +0 -5
  39. package/unstable-preview-types/legacy-network-handler/legacy-network-handler.d.ts.map +0 -1
  40. package/unstable-preview-types/legacy-network-handler/minimum-adapter-interface.d.ts +0 -549
  41. package/unstable-preview-types/legacy-network-handler/minimum-adapter-interface.d.ts.map +0 -1
  42. package/unstable-preview-types/legacy-network-handler/minimum-serializer-interface.d.ts +0 -235
  43. package/unstable-preview-types/legacy-network-handler/minimum-serializer-interface.d.ts.map +0 -1
  44. package/unstable-preview-types/legacy-network-handler/serializer-response.d.ts +0 -9
  45. package/unstable-preview-types/legacy-network-handler/serializer-response.d.ts.map +0 -1
  46. package/unstable-preview-types/legacy-network-handler/snapshot-record-array.d.ts +0 -96
  47. package/unstable-preview-types/legacy-network-handler/snapshot-record-array.d.ts.map +0 -1
  48. package/unstable-preview-types/legacy-network-handler/snapshot.d.ts +0 -248
  49. package/unstable-preview-types/legacy-network-handler/snapshot.d.ts.map +0 -1
  50. package/unstable-preview-types/utils.d.ts.map +0 -1
package/addon-main.cjs CHANGED
@@ -1,5 +1,5 @@
1
1
  'use strict';
2
2
 
3
- const { addonShim } = require('@warp-drive/build-config/addon-shim.cjs');
3
+ const { addonShim } = require('@warp-drive/core/addon-shim.cjs');
4
4
 
5
5
  module.exports = addonShim(__dirname);
package/dist/-private.js CHANGED
@@ -1 +1 @@
1
- export { F as FetchManager, S as SaveOp, c as Snapshot, b as SnapshotRecordArray, u as upgradeStore } from "./-private-Bnt-3W7M.js";
1
+ export * from '@warp-drive/legacy/compat/-private';
package/dist/builders.js CHANGED
@@ -1,323 +1 @@
1
- import { SkipCache } from '@warp-drive/core-types/request';
2
- import { deprecate } from '@ember/debug';
3
- import { dasherize } from '@ember-data/request-utils/string';
4
- import { macroCondition, getGlobalConfig } from '@embroider/macros';
5
- import { ensureStringId, constructResource } from '@ember-data/store/-private';
6
- import { storeFor, recordIdentifierFor } from '@ember-data/store';
7
- function isMaybeIdentifier(maybeIdentifier) {
8
- return Boolean(maybeIdentifier !== null && typeof maybeIdentifier === 'object' && ('id' in maybeIdentifier && 'type' in maybeIdentifier && maybeIdentifier.id && maybeIdentifier.type || maybeIdentifier.lid));
9
- }
10
- function normalizeModelName(type) {
11
- if (macroCondition(getGlobalConfig().WarpDrive.deprecations.DEPRECATE_NON_STRICT_TYPES)) {
12
- const result = dasherize(type);
13
- deprecate(`The resource type '${type}' is not normalized. Update your application code to use '${result}' instead of '${type}'.`, result === type, {
14
- id: 'ember-data:deprecate-non-strict-types',
15
- until: '6.0',
16
- for: 'ember-data',
17
- since: {
18
- available: '4.13',
19
- enabled: '5.3'
20
- }
21
- });
22
- return result;
23
- }
24
- return type;
25
- }
26
-
27
- /**
28
- * @module @ember-data/legacy-compat/builders
29
- */
30
-
31
- /**
32
- This function builds a request config to perform a `findAll` request for the given type.
33
- When passed to `store.request`, this config will result in the same behavior as a `store.findAll` request.
34
- Additionally, it takes the same options as `store.findAll`.
35
-
36
- All `@ember-data/legacy-compat` builders exist to enable you to migrate your codebase to using the correct syntax for `store.request` while temporarily preserving legacy behaviors.
37
- This is useful for quickly upgrading an entire app to a unified syntax while a longer incremental migration is made to shift off of adapters and serializers.
38
- To that end, these builders are deprecated and will be removed in a future version of Ember Data.
39
-
40
- @method findAll
41
- @deprecated
42
- @public
43
- @static
44
- @for @ember-data/legacy-compat/builders
45
- @param {String} type the name of the resource
46
- @param {Object} query a query to be used by the adapter
47
- @param {FindAllBuilderOptions} [options] optional, may include `adapterOptions` hash which will be passed to adapter.findAll
48
- @return {FindAllRequestInput} request config
49
- */
50
- function findAllBuilder(type, options = {}) {
51
- macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
52
- if (!test) {
53
- throw new Error(`You need to pass a model name to the findAll builder`);
54
- }
55
- })(type) : {};
56
- macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
57
- if (!test) {
58
- throw new Error(`Model name passed to the findAll builder must be a dasherized string instead of ${type}`);
59
- }
60
- })(typeof type === 'string') : {};
61
- return {
62
- op: 'findAll',
63
- data: {
64
- type: normalizeModelName(type),
65
- options: options || {}
66
- },
67
- cacheOptions: {
68
- [SkipCache]: true
69
- }
70
- };
71
- }
72
-
73
- /**
74
- * @module @ember-data/legacy-compat/builders
75
- */
76
-
77
- /**
78
- This function builds a request config to find the record for a given identifier or type and id combination.
79
- When passed to `store.request`, this config will result in the same behavior as a `store.findRecord` request.
80
- Additionally, it takes the same options as `store.findRecord`, with the exception of `preload` (which is unsupported).
81
-
82
- **Example 1**
83
-
84
- ```ts
85
- import { findRecord } from '@ember-data/legacy-compat/builders';
86
- const { content: post } = await store.request<Post>(findRecord<Post>('post', '1'));
87
- ```
88
-
89
- **Example 2**
90
-
91
- `findRecord` can be called with a single identifier argument instead of the combination
92
- of `type` (modelName) and `id` as separate arguments. You may recognize this combo as
93
- the typical pairing from [JSON:API](https://jsonapi.org/format/#document-resource-object-identification)
94
-
95
- ```ts
96
- import { findRecord } from '@ember-data/legacy-compat/builders';
97
- const { content: post } = await store.request<Post>(findRecord<Post>({ type: 'post', id }));
98
- ```
99
-
100
- All `@ember-data/legacy-compat` builders exist to enable you to migrate your codebase to using the correct syntax for `store.request` while temporarily preserving legacy behaviors.
101
- This is useful for quickly upgrading an entire app to a unified syntax while a longer incremental migration is made to shift off of adapters and serializers.
102
- To that end, these builders are deprecated and will be removed in a future version of Ember Data.
103
-
104
- @method findRecord
105
- @deprecated
106
- @public
107
- @static
108
- @for @ember-data/legacy-compat/builders
109
- @param {string|object} resource - either a string representing the name of the resource or a ResourceIdentifier object containing both the type (a string) and the id (a string) for the record or an lid (a string) of an existing record
110
- @param {string|number|object} id - optional object with options for the request only if the first param is a ResourceIdentifier, else the string id of the record to be retrieved
111
- @param {FindRecordBuilderOptions} [options] - if the first param is a string this will be the optional options for the request. See examples for available options.
112
- @return {FindRecordRequestInput} request config
113
- */
114
- function findRecordBuilder(resource, idOrOptions, options) {
115
- macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
116
- if (!test) {
117
- throw new Error(`You need to pass a modelName or resource identifier as the first argument to the findRecord builder`);
118
- }
119
- })(resource) : {};
120
- if (isMaybeIdentifier(resource)) {
121
- options = idOrOptions;
122
- } else {
123
- macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
124
- if (!test) {
125
- throw new Error(`You need to pass a modelName or resource identifier as the first argument to the findRecord builder (passed ${resource})`);
126
- }
127
- })(typeof resource === 'string') : {};
128
- const type = normalizeModelName(resource);
129
- const normalizedId = ensureStringId(idOrOptions);
130
- resource = constructResource(type, normalizedId);
131
- }
132
- options = options || {};
133
- macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
134
- if (!test) {
135
- throw new Error('findRecord builder does not support options.preload');
136
- }
137
- })(!options.preload) : {};
138
- return {
139
- op: 'findRecord',
140
- data: {
141
- record: resource,
142
- options
143
- },
144
- cacheOptions: {
145
- [SkipCache]: true
146
- }
147
- };
148
- }
149
-
150
- /**
151
- * @module @ember-data/legacy-compat/builders
152
- */
153
-
154
- /**
155
- This function builds a request config for a given type and query object.
156
- When passed to `store.request`, this config will result in the same behavior as a `store.query` request.
157
- Additionally, it takes the same options as `store.query`.
158
-
159
- All `@ember-data/legacy-compat` builders exist to enable you to migrate your codebase to using the correct syntax for `store.request` while temporarily preserving legacy behaviors.
160
- This is useful for quickly upgrading an entire app to a unified syntax while a longer incremental migration is made to shift off of adapters and serializers.
161
- To that end, these builders are deprecated and will be removed in a future version of Ember Data.
162
-
163
- @method query
164
- @deprecated
165
- @public
166
- @static
167
- @for @ember-data/legacy-compat/builders
168
- @param {String} type the name of the resource
169
- @param {Object} query a query to be used by the adapter
170
- @param {QueryBuilderOptions} [options] optional, may include `adapterOptions` hash which will be passed to adapter.query
171
- @return {QueryRequestInput} request config
172
- */
173
- function queryBuilder(type, query, options = {}) {
174
- macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
175
- if (!test) {
176
- throw new Error(`You need to pass a model name to the query builder`);
177
- }
178
- })(type) : {};
179
- macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
180
- if (!test) {
181
- throw new Error(`You need to pass a query hash to the query builder`);
182
- }
183
- })(query) : {};
184
- macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
185
- if (!test) {
186
- throw new Error(`Model name passed to the query builder must be a dasherized string instead of ${type}`);
187
- }
188
- })(typeof type === 'string') : {};
189
- return {
190
- op: 'query',
191
- data: {
192
- type: normalizeModelName(type),
193
- query,
194
- options: options
195
- },
196
- cacheOptions: {
197
- [SkipCache]: true
198
- }
199
- };
200
- }
201
-
202
- /**
203
- This function builds a request config for a given type and query object.
204
- When passed to `store.request`, this config will result in the same behavior as a `store.queryRecord` request.
205
- Additionally, it takes the same options as `store.queryRecord`.
206
-
207
- All `@ember-data/legacy-compat` builders exist to enable you to migrate your codebase to using the correct syntax for `store.request` while temporarily preserving legacy behaviors.
208
- This is useful for quickly upgrading an entire app to a unified syntax while a longer incremental migration is made to shift off of adapters and serializers.
209
- To that end, these builders are deprecated and will be removed in a future version of Ember Data.
210
-
211
- @method queryRecord
212
- @deprecated
213
- @public
214
- @static
215
- @for @ember-data/legacy-compat/builders
216
- @param {String} type the name of the resource
217
- @param {Object} query a query to be used by the adapter
218
- @param {QueryBuilderOptions} [options] optional, may include `adapterOptions` hash which will be passed to adapter.query
219
- @return {QueryRecordRequestInput} request config
220
- */
221
-
222
- function queryRecordBuilder(type, query, options) {
223
- macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
224
- if (!test) {
225
- throw new Error(`You need to pass a model name to the queryRecord builder`);
226
- }
227
- })(type) : {};
228
- macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
229
- if (!test) {
230
- throw new Error(`You need to pass a query hash to the queryRecord builder`);
231
- }
232
- })(query) : {};
233
- macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
234
- if (!test) {
235
- throw new Error(`Model name passed to the queryRecord builder must be a dasherized string instead of ${type}`);
236
- }
237
- })(typeof type === 'string') : {};
238
- return {
239
- op: 'queryRecord',
240
- data: {
241
- type: normalizeModelName(type),
242
- query,
243
- options: options || {}
244
- },
245
- cacheOptions: {
246
- [SkipCache]: true
247
- }
248
- };
249
- }
250
-
251
- /**
252
- * @module @ember-data/legacy-compat/builders
253
- */
254
- function _resourceIsFullDeleted(identifier, cache) {
255
- return cache.isDeletionCommitted(identifier) || cache.isNew(identifier) && cache.isDeleted(identifier);
256
- }
257
- function resourceIsFullyDeleted(instanceCache, identifier) {
258
- const cache = instanceCache.cache;
259
- return !cache || _resourceIsFullDeleted(identifier, cache);
260
- }
261
-
262
- /**
263
- This function builds a request config for saving the given record (e.g. creating, updating, or deleting the record).
264
- When passed to `store.request`, this config will result in the same behavior as a legacy `store.saveRecord` request.
265
- Additionally, it takes the same options as `store.saveRecord`.
266
-
267
- All `@ember-data/legacy-compat` builders exist to enable you to migrate your codebase to using the correct syntax for `store.request` while temporarily preserving legacy behaviors.
268
- This is useful for quickly upgrading an entire app to a unified syntax while a longer incremental migration is made to shift off of adapters and serializers.
269
- To that end, these builders are deprecated and will be removed in a future version of Ember Data.
270
-
271
- @method saveRecord
272
- @deprecated
273
- @public
274
- @static
275
- @for @ember-data/legacy-compat/builders
276
- @param {Object} record a record to save
277
- @param {SaveRecordBuilderOptions} options optional, may include `adapterOptions` hash which will be passed to adapter.saveRecord
278
- @return {SaveRecordRequestInput} request config
279
- */
280
- function saveRecordBuilder(record, options = {}) {
281
- const store = storeFor(record);
282
- macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
283
- if (!test) {
284
- throw new Error(`Unable to initiate save for a record in a disconnected state`);
285
- }
286
- })(store) : {};
287
- const identifier = recordIdentifierFor(record);
288
- if (!identifier) {
289
- // this commonly means we're disconnected
290
- // but just in case we throw here to prevent bad things.
291
- throw new Error(`Record Is Disconnected`);
292
- }
293
- macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
294
- if (!test) {
295
- throw new Error(`Cannot initiate a save request for an unloaded record: ${identifier.lid}`);
296
- }
297
- })(store._instanceCache.recordIsLoaded(identifier)) : {};
298
- if (resourceIsFullyDeleted(store._instanceCache, identifier)) {
299
- throw new Error('cannot build saveRecord request for deleted record');
300
- }
301
- if (!options) {
302
- options = {};
303
- }
304
- let operation = 'updateRecord';
305
- const cache = store.cache;
306
- if (cache.isNew(identifier)) {
307
- operation = 'createRecord';
308
- } else if (cache.isDeleted(identifier)) {
309
- operation = 'deleteRecord';
310
- }
311
- return {
312
- op: operation,
313
- data: {
314
- options,
315
- record: identifier
316
- },
317
- records: [identifier],
318
- cacheOptions: {
319
- [SkipCache]: true
320
- }
321
- };
322
- }
323
- export { findAllBuilder as findAll, findRecordBuilder as findRecord, queryBuilder as query, queryRecordBuilder as queryRecord, saveRecordBuilder as saveRecord };
1
+ export * from '@warp-drive/legacy/compat/builders';