@ember-data/legacy-compat 5.6.0-alpha.5 → 5.6.0-beta.1

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 -292
  4. package/dist/index.js +1 -1002
  5. package/dist/utils.js +1 -224
  6. package/package.json +7 -30
  7. package/unstable-preview-types/-private.d.ts +7 -13
  8. package/unstable-preview-types/builders.d.ts +9 -12
  9. package/unstable-preview-types/index.d.ts +2 -149
  10. package/unstable-preview-types/utils.d.ts +9 -138
  11. package/dist/-private-CVvkihLY.js +0 -1188
  12. package/dist/-private-CVvkihLY.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 -35
  19. package/unstable-preview-types/builders/find-all.d.ts.map +0 -1
  20. package/unstable-preview-types/builders/find-record.d.ts +0 -56
  21. package/unstable-preview-types/builders/find-record.d.ts.map +0 -1
  22. package/unstable-preview-types/builders/query.d.ts +0 -63
  23. package/unstable-preview-types/builders/query.d.ts.map +0 -1
  24. package/unstable-preview-types/builders/save-record.d.ts +0 -34
  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 -529
  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 -226
  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 -91
  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 -239
  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/dist/utils.js CHANGED
@@ -1,224 +1 @@
1
- import { singularize, dasherize } from '@ember-data/request-utils/string';
2
- import { macroCondition, getGlobalConfig } from '@embroider/macros';
3
-
4
- /**
5
- Utilities for helping to migrate to stricter
6
- and more consistent use of IDs and types.
7
-
8
- @module
9
- @deprecated
10
- */
11
- let MismatchReporter = function () {};
12
-
13
- // TODO: @runspired This pattern prevents AssertFn from being removed in production builds
14
- // but we should enable that if we can.
15
- let _AssertFn = function () {};
16
- const AssertFn = (message, condition) => {
17
- if (!condition) {
18
- _AssertFn(message, condition);
19
- }
20
- macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
21
- if (!test) {
22
- throw new Error(message);
23
- }
24
- })(condition) : {};
25
- };
26
- let NormalizedType = str => {
27
- return singularize(dasherize(str));
28
- };
29
-
30
- /**
31
- * Configure a function to be called when an id or type
32
- * changes during normalization. This is useful for instrumenting
33
- * to discover places where usage in the app is not consistent.
34
- *
35
- * @param method a function which takes a mismatch-type ('formatted-id' | 'formatted-type'), actual, and expected value
36
- * @public
37
- */
38
- function configureMismatchReporter(fn) {
39
- MismatchReporter = fn;
40
- }
41
-
42
- /**
43
- * Configure a function to be called when an id or type
44
- * fails validation. This is useful for instrumenting
45
- * to discover places where usage in the app is not consistent.
46
- *
47
- * @param method a function which takes a message and a condition
48
- * @public
49
- */
50
- function configureAssertFn(fn) {
51
- _AssertFn = fn;
52
- }
53
-
54
- /**
55
- * Configure a function to be called to normalize
56
- * a resource type string. Used by both formattedType
57
- * and isEquivType to ensure consistent normalization
58
- * during comparison.
59
- *
60
- * If validation fails or the type turns out be unnormalized
61
- * the configured mismatch reporter and assert functions will
62
- * be called.
63
- *
64
- * @param method a function which takes a string and returns a string
65
- * @public
66
- */
67
- function configureTypeNormalization(fn) {
68
- NormalizedType = fn;
69
- }
70
- const NORMALIZED_TYPES = new Map();
71
-
72
- /**
73
- * Converts a potentially unnormalized type into the format expected
74
- * by our EmberData Cache. Currently this is singular-dasherized.
75
- *
76
- * you should not rely on this function to give you an exact format
77
- * for display purposes. Formatting for display should be handled
78
- * differently if the exact format matters.
79
- *
80
- * Asserts invalid types (undefined, null, '') in dev.
81
- *
82
- * **Usage**
83
- *
84
- * ```js
85
- * import formattedType from 'soxhub-client/helpers/formatted-type';
86
- *
87
- * formattedType('post'); // => 'post'
88
- * formattedType('posts'); // => 'post'
89
- * formattedType('Posts'); // => 'post'
90
- * formattedType('post-comment'); // => 'post-comment'
91
- * formattedType('post-comments'); // => 'post-comment'
92
- * formattedType('post_comment'); // => 'post-comment'
93
- * formattedType('postComment'); // => 'post-comment'
94
- * formattedType('PostComment'); // => 'post-comment'
95
- * ```
96
- *
97
- * @param {String} type the potentially un-normalized type
98
- * @return {String} the normalized type
99
- * @public
100
- */
101
- function formattedType(type) {
102
- AssertFn('formattedType: type must not be null', type !== null);
103
- AssertFn('formattedType: type must not be undefined', type !== undefined);
104
- AssertFn('formattedType: type must be a string', typeof type === 'string');
105
- AssertFn('formattedType: type must not be empty', type.length > 0);
106
- let normalized = NORMALIZED_TYPES.get(type);
107
- if (normalized === undefined) {
108
- normalized = NormalizedType(type);
109
- NORMALIZED_TYPES.set(type, normalized);
110
- }
111
- if (normalized !== type) {
112
- MismatchReporter('formatted-type', type, normalized);
113
- }
114
- return normalized;
115
- }
116
-
117
- /**
118
- * Format an id to the format expected by the EmberData Cache.
119
- * Currently this means that id should be `string | null`.
120
- *
121
- * Asserts invalid IDs (undefined, '', 0, '0') in dev.
122
- *
123
- * **Usage**
124
- *
125
- * ```js
126
- * import formattedId from 'client/utils/formatted-id';
127
- *
128
- * formattedId('1'); // => '1'
129
- * formattedId(1); // => '1'
130
- * formattedId(null); // => null
131
- * ```
132
- *
133
- * @param {String | Number | null} id the potentially un-normalized id
134
- * @return {String | null} the normalized id
135
- * @public
136
- */
137
-
138
- function formattedId(id) {
139
- AssertFn('formattedId: id must not be undefined', id !== undefined);
140
- AssertFn('formattedId: id must be a number, string or null', typeof id === 'number' || typeof id === 'string' || id === null);
141
- AssertFn('formattedId: id must not be empty', typeof id === 'number' || id === null || typeof id === 'string' && id.length > 0);
142
- AssertFn('formattedId: id must not be 0', id !== '0' && id !== 0);
143
- const formatted = id === null ? null : String(id);
144
- if (formatted !== id) {
145
- MismatchReporter('formatted-id', id, formatted);
146
- }
147
- return id === null ? null : String(id);
148
- }
149
- function expectId(id) {
150
- AssertFn('expectId: id must not be null', id !== null);
151
- return formattedId(id);
152
- }
153
-
154
- /**
155
- * Compares two types for strict equality, converting them to
156
- * the format expected by the EmberData Cache to ensure
157
- * differences in format are accounted for in the comparison.
158
- *
159
- * Asserts when expected or actual are invalid types in dev.
160
- * Expected may never be null.
161
- *
162
- * ```js
163
- * isEquivType('posts', 'post'); // true
164
- * isEquivType('post', 'post'); // true
165
- * isEquivType('posts', 'posts'); // true
166
- * isEquivType('post-comment', 'postComment'); // true
167
- * isEquivType('post-comment', 'PostComment'); // true
168
- * isEquivType('post-comment', 'post_comment'); // true
169
- * isEquivType('post-comment', 'post-comment'); // true
170
- * isEquivType('post-comment', 'post'); // false
171
- * isEquivType('posts', null); // false
172
- * ```
173
- *
174
- * @param {String} expected a potentially unnormalized type to match against
175
- * @param {String} actual a potentially unnormalized type to match against
176
- * @return {Boolean} true if the types are equivalent
177
- * @public
178
- */
179
- function isEquivType(expected, actual) {
180
- AssertFn('isEquivType: Expected type must not be null', expected !== null);
181
- AssertFn('isEquivType: Expected type must not be undefined', expected !== undefined);
182
- AssertFn('isEquivType: Expected type must be a string', typeof expected === 'string');
183
- AssertFn('isEquivType: Expected type must not be empty', expected.length > 0);
184
- AssertFn('isEquivType: Actual type must not be null', actual !== null);
185
- AssertFn('isEquivType: Actual type must not be undefined', actual !== undefined);
186
- AssertFn('isEquivType: Actual type must be a string', typeof actual === 'string');
187
- AssertFn('isEquivType: Actual type must not be empty', actual.length > 0);
188
- return expected === actual || formattedType(expected) === formattedType(actual);
189
- }
190
-
191
- /**
192
- * Compares two IDs for strict equality, converting them to
193
- * the format expected by the EmberData Cache to ensure
194
- * differences in format are accounted for in the comparison.
195
- *
196
- * Asserts when expected or actual are invalid IDs in dev.
197
- * Expected may never be null.
198
- *
199
- * ```js
200
- * isEquivId('1', 1); // true
201
- * isEquivId('2', '2'); // true
202
- * isEquivId(3, '3'); // true
203
- * isEquivId(4, '3'); // false
204
- * isEquivId(1, null); // false
205
- * ```
206
- *
207
- * @param {string | number} expected a potentially un-normalized id to match against
208
- * @param {string | number} actual a potentially un-normalized id to match against
209
- * @return {Boolean} true if the ids are equivalent
210
- * @public
211
- */
212
- function isEquivId(expected, actual) {
213
- AssertFn('isEquivId: Expected id must not be null', expected !== null);
214
- AssertFn('isEquivId: Expected id must not be undefined', expected !== undefined);
215
- AssertFn('isEquivId: Expected id must be a number or string', typeof expected === 'number' || typeof expected === 'string');
216
- AssertFn('isEquivId: Expected id must not be empty', typeof expected === 'number' || typeof expected === 'string' && expected.length > 0);
217
- AssertFn('isEquivId: Expected id must not be 0', expected !== '0' && expected !== 0);
218
- AssertFn('isEquivId: Actual id must not be undefined', actual !== undefined);
219
- AssertFn('isEquivId: Actual id must be a number, string or null', typeof actual === 'number' || typeof actual === 'string' || actual === null);
220
- AssertFn('isEquivId: Actual id must not be empty', actual === null || typeof actual === 'number' || typeof actual === 'string' && actual.length > 0);
221
- AssertFn('isEquivId: Actual id must not be 0', actual !== '0' && actual !== 0);
222
- return expected === actual || formattedId(expected) === formattedId(actual);
223
- }
224
- export { configureAssertFn, configureMismatchReporter, configureTypeNormalization, expectId, formattedId, formattedType, isEquivId, isEquivType };
1
+ export * from '@warp-drive/legacy/compat/utils';
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@ember-data/legacy-compat",
3
3
  "description": "Compatibility Shims for Older EmberData",
4
- "version": "5.6.0-alpha.5",
4
+ "version": "5.6.0-beta.1",
5
5
  "license": "MIT",
6
6
  "author": "Chris Thoburn <runspired@users.noreply.github.com>",
7
7
  "repository": {
@@ -41,44 +41,21 @@
41
41
  "type": "addon",
42
42
  "version": 2
43
43
  },
44
- "peerDependenciesMeta": {
45
- "@ember-data/graph": {
46
- "optional": true
47
- },
48
- "@ember-data/json-api": {
49
- "optional": true
50
- }
51
- },
52
44
  "dependencies": {
53
45
  "@embroider/macros": "^1.16.12",
54
- "@warp-drive/build-config": "5.6.0-alpha.5"
55
- },
56
- "peerDependencies": {
57
- "@ember-data/graph": "5.6.0-alpha.5",
58
- "@ember-data/json-api": "5.6.0-alpha.5",
59
- "@ember-data/request": "5.6.0-alpha.5",
60
- "@ember-data/request-utils": "5.6.0-alpha.5",
61
- "@ember-data/store": "5.6.0-alpha.5",
62
- "@ember/test-waiters": "^3.1.0 || >= 4.0.0",
63
- "@warp-drive/core-types": "5.6.0-alpha.5"
46
+ "@warp-drive/core": "5.6.0-beta.0",
47
+ "@warp-drive/legacy": "5.6.0-beta.0",
48
+ "@warp-drive/utilities": "5.6.0-beta.0"
64
49
  },
50
+ "peerDependencies": {},
65
51
  "devDependencies": {
66
52
  "@babel/core": "^7.26.10",
67
53
  "@babel/plugin-transform-typescript": "^7.27.0",
68
54
  "@babel/preset-env": "^7.26.9",
69
55
  "@babel/preset-typescript": "^7.27.0",
70
- "@ember-data/graph": "5.6.0-alpha.5",
71
- "@ember-data/json-api": "5.6.0-alpha.5",
72
- "@ember-data/request": "5.6.0-alpha.5",
73
- "@ember-data/request-utils": "5.6.0-alpha.5",
74
- "@ember-data/store": "5.6.0-alpha.5",
75
- "@ember/test-waiters": "^4.1.0",
76
- "@glimmer/component": "^2.0.0",
77
- "@warp-drive/core-types": "5.6.0-alpha.5",
78
- "@warp-drive/internal-config": "5.6.0-alpha.5",
79
- "ember-source": "~6.3.0",
56
+ "@warp-drive/internal-config": "5.6.0-beta.1",
80
57
  "typescript": "^5.8.3",
81
- "vite": "^5.4.15"
58
+ "vite": "^7.0.0"
82
59
  },
83
60
  "ember": {
84
61
  "edition": "octane"
@@ -1,16 +1,10 @@
1
1
  declare module '@ember-data/legacy-compat/-private' {
2
- import type Store from '@ember-data/store';
3
- import type { CompatStore } from '@ember-data/legacy-compat';
4
2
  /**
5
- * Utilities - often temporary - for maintaining backwards compatibility with
6
- * older parts of EmberData.
7
- *
8
- @module
3
+ * Utilities - often temporary - for maintaining backwards compatibility with
4
+ * older parts of EmberData.
5
+ *
6
+ @module
9
7
  */
10
- export { SnapshotRecordArray } from '@ember-data/legacy-compat/legacy-network-handler/snapshot-record-array';
11
- export { SaveOp } from '@ember-data/legacy-compat/legacy-network-handler/fetch-manager';
12
- export { FetchManager } from '@ember-data/legacy-compat/legacy-network-handler/fetch-manager';
13
- export { Snapshot } from '@ember-data/legacy-compat/legacy-network-handler/snapshot';
14
- export function upgradeStore(store: Store): asserts store is CompatStore;
15
- }
16
- //# sourceMappingURL=-private.d.ts.map
8
+ export * from "@warp-drive/legacy/compat/-private";
9
+
10
+ }
@@ -1,17 +1,14 @@
1
1
  declare module '@ember-data/legacy-compat/builders' {
2
2
  /**
3
- Builders for migrating from `store` methods to `store.request`.
3
+ Builders for migrating from `store` methods to `store.request`.
4
4
 
5
- These builders enable you to migrate your codebase to using the correct syntax for `store.request` while temporarily preserving legacy behaviors.
6
- 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.
7
- To that end, these builders are deprecated and will be removed in a future version of Ember Data.
5
+ These builders enable you to migrate your codebase to using the correct syntax for `store.request` while temporarily preserving legacy behaviors.
6
+ 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.
7
+ To that end, these builders are deprecated and will be removed in a future version of Ember Data.
8
8
 
9
- @module
10
- @deprecated
9
+ @module
10
+ @deprecated
11
11
  */
12
- export { findAllBuilder as findAll } from '@ember-data/legacy-compat/builders/find-all';
13
- export { findRecordBuilder as findRecord } from '@ember-data/legacy-compat/builders/find-record';
14
- export { queryBuilder as query, queryRecordBuilder as queryRecord } from '@ember-data/legacy-compat/builders/query';
15
- export { saveRecordBuilder as saveRecord } from '@ember-data/legacy-compat/builders/save-record';
16
- }
17
- //# sourceMappingURL=builders.d.ts.map
12
+ export * from "@warp-drive/legacy/compat/builders";
13
+
14
+ }
@@ -1,154 +1,7 @@
1
1
  /// <reference path="./builders.d.ts" />
2
2
  /// <reference path="./-private.d.ts" />
3
3
  /// <reference path="./utils.d.ts" />
4
- /// <reference path="./builders/utils.d.ts" />
5
- /// <reference path="./builders/find-record.d.ts" />
6
- /// <reference path="./builders/save-record.d.ts" />
7
- /// <reference path="./builders/query.d.ts" />
8
- /// <reference path="./builders/find-all.d.ts" />
9
- /// <reference path="./legacy-network-handler/snapshot-record-array.d.ts" />
10
- /// <reference path="./legacy-network-handler/legacy-network-handler.d.ts" />
11
- /// <reference path="./legacy-network-handler/snapshot.d.ts" />
12
- /// <reference path="./legacy-network-handler/identifier-has-id.d.ts" />
13
- /// <reference path="./legacy-network-handler/minimum-serializer-interface.d.ts" />
14
- /// <reference path="./legacy-network-handler/fetch-manager.d.ts" />
15
- /// <reference path="./legacy-network-handler/serializer-response.d.ts" />
16
- /// <reference path="./legacy-network-handler/minimum-adapter-interface.d.ts" />
17
- /// <reference path="./legacy-network-handler/legacy-data-fetch.d.ts" />
18
- /// <reference path="./legacy-network-handler/legacy-data-utils.d.ts" />
19
4
  declare module '@ember-data/legacy-compat' {
20
- import type Store from '@ember-data/store';
21
- import type { ObjectValue } from '@warp-drive/core-types/json/raw';
22
- import { FetchManager } from '@ember-data/legacy-compat/-private';
23
- import type { AdapterPayload, MinimumAdapterInterface } from '@ember-data/legacy-compat/legacy-network-handler/minimum-adapter-interface';
24
- import type { MinimumSerializerInterface, SerializerOptions } from '@ember-data/legacy-compat/legacy-network-handler/minimum-serializer-interface';
25
- export { LegacyNetworkHandler } from '@ember-data/legacy-compat/legacy-network-handler/legacy-network-handler';
26
- export type { MinimumAdapterInterface, MinimumSerializerInterface, SerializerOptions, AdapterPayload };
27
- export type LegacyStoreCompat = {
28
- _fetchManager: FetchManager;
29
- adapterFor(this: Store, modelName: string): MinimumAdapterInterface;
30
- adapterFor(this: Store, modelName: string, _allowMissing: true): MinimumAdapterInterface | undefined;
31
- serializerFor<K extends string>(modelName: K, _allowMissing?: boolean): MinimumSerializerInterface | null;
32
- normalize(modelName: string, payload: ObjectValue): ObjectValue;
33
- pushPayload(modelName: string, payload: ObjectValue): void;
34
- serializeRecord(record: unknown, options?: SerializerOptions): unknown;
35
- _adapterCache: Record<string, MinimumAdapterInterface & {
36
- store: Store;
37
- }>;
38
- _serializerCache: Record<string, MinimumSerializerInterface & {
39
- store: Store;
40
- }>;
41
- };
42
- export type CompatStore = Store & LegacyStoreCompat;
43
- /**
44
- Returns an instance of the adapter for a given type. For
45
- example, `adapterFor('person')` will return an instance of
46
- the adapter located at `app/adapters/person.js`
5
+ export * from "@warp-drive/legacy/compat";
47
6
 
48
- If no `person` adapter is found, this method will look
49
- for an `application` adapter (the default adapter for
50
- your entire application).
51
-
52
- @public
53
- @param {String} modelName
54
- @return {Adapter}
55
- */
56
- export function adapterFor(this: Store, modelName: string): MinimumAdapterInterface;
57
- export function adapterFor(this: Store, modelName: string, _allowMissing: true): MinimumAdapterInterface | undefined;
58
- /**
59
- Returns an instance of the serializer for a given type. For
60
- example, `serializerFor('person')` will return an instance of
61
- `App.PersonSerializer`.
62
-
63
- If no `App.PersonSerializer` is found, this method will look
64
- for an `App.ApplicationSerializer` (the default serializer for
65
- your entire application).
66
-
67
- If a serializer cannot be found on the adapter, it will fall back
68
- to an instance of `JSONSerializer`.
69
-
70
- @public
71
- @param {String} modelName the record to serialize
72
- @return {Serializer}
73
- */
74
- export function serializerFor(this: Store, modelName: string): MinimumSerializerInterface | null;
75
- /**
76
- `normalize` converts a json payload into the normalized form that
77
- [push](../methods/push?anchor=push) expects.
78
-
79
- Example
80
-
81
- ```js
82
- socket.on('message', function(message) {
83
- let modelName = message.model;
84
- let data = message.data;
85
- store.push(store.normalize(modelName, data));
86
- });
87
- ```
88
-
89
- @public
90
- @param {String} modelName The name of the model type for this payload
91
- @param {Object} payload
92
- @return {Object} The normalized payload
93
- */
94
- export function normalize(this: Store, modelName: string, payload: ObjectValue): import("@warp-drive/core-types/spec/json-api-raw").SingleResourceDocument;
95
- /**
96
- Push some raw data into the store.
97
-
98
- This method can be used both to push in brand new
99
- records, as well as to update existing records. You
100
- can push in more than one type of object at once.
101
- All objects should be in the format expected by the
102
- serializer.
103
-
104
- ```js [app/serializers/application.js]
105
- import RESTSerializer from '@ember-data/serializer/rest';
106
-
107
- export default class ApplicationSerializer extends RESTSerializer;
108
- ```
109
-
110
- ```js
111
- let pushData = {
112
- posts: [
113
- { id: 1, postTitle: "Great post", commentIds: [2] }
114
- ],
115
- comments: [
116
- { id: 2, commentBody: "Insightful comment" }
117
- ]
118
- }
119
-
120
- store.pushPayload(pushData);
121
- ```
122
-
123
- By default, the data will be deserialized using a default
124
- serializer (the application serializer if it exists).
125
-
126
- Alternatively, `pushPayload` will accept a model type which
127
- will determine which serializer will process the payload.
128
-
129
- ```js [app/serializers/application.js]
130
- import RESTSerializer from '@ember-data/serializer/rest';
131
-
132
- export default class ApplicationSerializer extends RESTSerializer;
133
- ```
134
-
135
- ```js [app/serializers/post.js]
136
- import JSONSerializer from '@ember-data/serializer/json';
137
-
138
- export default JSONSerializer;
139
- ```
140
-
141
- ```js
142
- store.pushPayload(pushData); // Will use the application serializer
143
- store.pushPayload('post', pushData); // Will use the post serializer
144
- ```
145
-
146
- @public
147
- @param {String} modelName Optionally, a model type used to determine which serializer will be used
148
- @param {Object} inputPayload
149
- */
150
- export function pushPayload(this: Store, modelName: string, inputPayload: ObjectValue): void;
151
- export function serializeRecord(this: Store, record: unknown, options?: SerializerOptions): unknown;
152
- export function cleanup(this: Store): void;
153
- }
154
- //# sourceMappingURL=index.d.ts.map
7
+ }
@@ -1,140 +1,11 @@
1
1
  declare module '@ember-data/legacy-compat/utils' {
2
- type Reporter = (type: 'formatted-id' | 'formatted-type', actual: unknown, expected: unknown) => void;
3
2
  /**
4
- * Configure a function to be called when an id or type
5
- * changes during normalization. This is useful for instrumenting
6
- * to discover places where usage in the app is not consistent.
7
- *
8
- * @param method a function which takes a mismatch-type ('formatted-id' | 'formatted-type'), actual, and expected value
9
- * @public
10
- */
11
- export function configureMismatchReporter(fn: Reporter): void;
12
- /**
13
- * Configure a function to be called when an id or type
14
- * fails validation. This is useful for instrumenting
15
- * to discover places where usage in the app is not consistent.
16
- *
17
- * @param method a function which takes a message and a condition
18
- * @public
19
- */
20
- export function configureAssertFn(fn: (message: string, condition: unknown) => void): void;
21
- /**
22
- * Configure a function to be called to normalize
23
- * a resource type string. Used by both formattedType
24
- * and isEquivType to ensure consistent normalization
25
- * during comparison.
26
- *
27
- * If validation fails or the type turns out be unnormalized
28
- * the configured mismatch reporter and assert functions will
29
- * be called.
30
- *
31
- * @param method a function which takes a string and returns a string
32
- * @public
33
- */
34
- export function configureTypeNormalization(fn: (type: string) => string): void;
35
- /**
36
- * Converts a potentially unnormalized type into the format expected
37
- * by our EmberData Cache. Currently this is singular-dasherized.
38
- *
39
- * you should not rely on this function to give you an exact format
40
- * for display purposes. Formatting for display should be handled
41
- * differently if the exact format matters.
42
- *
43
- * Asserts invalid types (undefined, null, '') in dev.
44
- *
45
- * **Usage**
46
- *
47
- * ```js
48
- * import formattedType from 'soxhub-client/helpers/formatted-type';
49
- *
50
- * formattedType('post'); // => 'post'
51
- * formattedType('posts'); // => 'post'
52
- * formattedType('Posts'); // => 'post'
53
- * formattedType('post-comment'); // => 'post-comment'
54
- * formattedType('post-comments'); // => 'post-comment'
55
- * formattedType('post_comment'); // => 'post-comment'
56
- * formattedType('postComment'); // => 'post-comment'
57
- * formattedType('PostComment'); // => 'post-comment'
58
- * ```
59
- *
60
- * @param {String} type the potentially un-normalized type
61
- * @return {String} the normalized type
62
- * @public
63
- */
64
- export function formattedType<T extends string>(type: T | string): T;
65
- /**
66
- * Format an id to the format expected by the EmberData Cache.
67
- * Currently this means that id should be `string | null`.
68
- *
69
- * Asserts invalid IDs (undefined, '', 0, '0') in dev.
70
- *
71
- * **Usage**
72
- *
73
- * ```js
74
- * import formattedId from 'client/utils/formatted-id';
75
- *
76
- * formattedId('1'); // => '1'
77
- * formattedId(1); // => '1'
78
- * formattedId(null); // => null
79
- * ```
80
- *
81
- * @param {String | Number | null} id the potentially un-normalized id
82
- * @return {String | null} the normalized id
83
- * @public
84
- */
85
- export function formattedId(id: string | number): string;
86
- export function formattedId(id: null): null;
87
- export function formattedId(id: string | number | null): string | null;
88
- export function expectId(id: string | number): string;
89
- export function expectId(id: null): never;
90
- /**
91
- * Compares two types for strict equality, converting them to
92
- * the format expected by the EmberData Cache to ensure
93
- * differences in format are accounted for in the comparison.
94
- *
95
- * Asserts when expected or actual are invalid types in dev.
96
- * Expected may never be null.
97
- *
98
- * ```js
99
- * isEquivType('posts', 'post'); // true
100
- * isEquivType('post', 'post'); // true
101
- * isEquivType('posts', 'posts'); // true
102
- * isEquivType('post-comment', 'postComment'); // true
103
- * isEquivType('post-comment', 'PostComment'); // true
104
- * isEquivType('post-comment', 'post_comment'); // true
105
- * isEquivType('post-comment', 'post-comment'); // true
106
- * isEquivType('post-comment', 'post'); // false
107
- * isEquivType('posts', null); // false
108
- * ```
109
- *
110
- * @param {String} expected a potentially unnormalized type to match against
111
- * @param {String} actual a potentially unnormalized type to match against
112
- * @return {Boolean} true if the types are equivalent
113
- * @public
114
- */
115
- export function isEquivType(expected: string, actual: string): boolean;
116
- /**
117
- * Compares two IDs for strict equality, converting them to
118
- * the format expected by the EmberData Cache to ensure
119
- * differences in format are accounted for in the comparison.
120
- *
121
- * Asserts when expected or actual are invalid IDs in dev.
122
- * Expected may never be null.
123
- *
124
- * ```js
125
- * isEquivId('1', 1); // true
126
- * isEquivId('2', '2'); // true
127
- * isEquivId(3, '3'); // true
128
- * isEquivId(4, '3'); // false
129
- * isEquivId(1, null); // false
130
- * ```
131
- *
132
- * @param {string | number} expected a potentially un-normalized id to match against
133
- * @param {string | number} actual a potentially un-normalized id to match against
134
- * @return {Boolean} true if the ids are equivalent
135
- * @public
136
- */
137
- export function isEquivId(expected: string | number, actual: string | number | null): boolean;
138
- export {};
139
- }
140
- //# sourceMappingURL=utils.d.ts.map
3
+ Utilities for helping to migrate to stricter
4
+ and more consistent use of IDs and types.
5
+
6
+ @module
7
+ @deprecated
8
+ */
9
+ export * from "@warp-drive/legacy/compat/utils";
10
+
11
+ }