@warp-drive/legacy 5.8.0-alpha.0 → 5.8.0-alpha.10

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 (54) hide show
  1. package/README.md +6 -3
  2. package/declarations/adapter/json-api.d.ts +4 -6
  3. package/declarations/adapter/rest.d.ts +5 -8
  4. package/declarations/adapter.d.ts +4 -6
  5. package/declarations/compat/-private.d.ts +1 -1
  6. package/declarations/compat/extensions.d.ts +1 -1
  7. package/declarations/compat/legacy-network-handler/minimum-adapter-interface.d.ts +7 -9
  8. package/declarations/compat/legacy-network-handler/minimum-serializer-interface.d.ts +20 -30
  9. package/declarations/compat/utils.d.ts +17 -17
  10. package/declarations/compat.d.ts +32 -8
  11. package/declarations/index.d.ts +53 -0
  12. package/declarations/model/-private/attr.d.ts +5 -6
  13. package/declarations/model/-private/belongs-to.d.ts +4 -5
  14. package/declarations/model/-private/has-many.d.ts +4 -5
  15. package/declarations/model/-private/hooks.d.ts +1 -1
  16. package/declarations/model/-private/model.d.ts +8 -8
  17. package/declarations/model/-private/record-state.d.ts +1 -1
  18. package/declarations/model/-private/references/belongs-to.d.ts +1 -1
  19. package/declarations/model/-private/references/has-many.d.ts +1 -1
  20. package/declarations/model/migration-support.d.ts +4 -2
  21. package/declarations/serializer/-private/embedded-records-mixin.d.ts +0 -5
  22. package/declarations/serializer/-private/transforms/boolean.d.ts +2 -2
  23. package/declarations/serializer/-private/transforms/date.d.ts +2 -2
  24. package/declarations/serializer/-private/transforms/number.d.ts +1 -1
  25. package/declarations/serializer/-private/transforms/string.d.ts +1 -1
  26. package/declarations/serializer/json-api.d.ts +4 -6
  27. package/declarations/serializer/json.d.ts +6 -8
  28. package/declarations/serializer/rest.d.ts +4 -6
  29. package/declarations/serializer.d.ts +8 -11
  30. package/dist/{-private-8UmnAf9J.js → -private-B1pSSN52.js} +1 -1
  31. package/dist/adapter/-private.js +1 -1
  32. package/dist/adapter/error.js +5 -6
  33. package/dist/adapter/json-api.js +4 -1
  34. package/dist/adapter/rest.js +6 -9
  35. package/dist/adapter.js +4 -6
  36. package/dist/compat/-private.js +1 -1
  37. package/dist/compat/utils.js +17 -17
  38. package/dist/compat.js +55 -38
  39. package/dist/{errors-8kD2mSe_.js → errors-COviC59J.js} +3 -3
  40. package/dist/hooks-Bp8SIQBU.js +74 -0
  41. package/dist/index.js +178 -0
  42. package/dist/{json-Et4mt_LM.js → json-BHxlccxF.js} +8 -12
  43. package/dist/model/-private.js +1 -1
  44. package/dist/model/migration-support.js +6 -4
  45. package/dist/model.js +18 -90
  46. package/dist/{schema-provider-DQu4Rjco.js → schema-provider-JlCneqZH.js} +8 -10
  47. package/dist/{serialize-into-hash-CS0MIv4F.js → serialize-into-hash-BnYvPex3.js} +1 -1
  48. package/dist/serializer/json-api.js +11 -38
  49. package/dist/serializer/json.js +1 -1
  50. package/dist/serializer/rest.js +5 -12
  51. package/dist/serializer/transform.js +15 -6
  52. package/dist/serializer.js +8 -12
  53. package/dist/store.js +3 -0
  54. package/package.json +7 -7
@@ -1,6 +1,6 @@
1
1
  import { warn } from '@ember/debug';
2
2
  import { dasherize, pluralize, singularize } from '@warp-drive/utilities/string';
3
- import { J as JSONSerializer } from "../json-Et4mt_LM.js";
3
+ import { J as JSONSerializer } from "../json-BHxlccxF.js";
4
4
  import { macroCondition, getGlobalConfig } from '@embroider/macros';
5
5
 
6
6
  /* eslint-disable @typescript-eslint/no-unsafe-return */
@@ -10,8 +10,6 @@ import { macroCondition, getGlobalConfig } from '@embroider/macros';
10
10
  /* eslint-disable @typescript-eslint/no-unsafe-call */
11
11
  const JSONAPISerializer = JSONSerializer.extend({
12
12
  /**
13
- @param {Object} documentHash
14
- @return {Object}
15
13
  @private
16
14
  */
17
15
  _normalizeDocumentHelper(documentHash) {
@@ -41,8 +39,6 @@ const JSONAPISerializer = JSONSerializer.extend({
41
39
  return documentHash;
42
40
  },
43
41
  /**
44
- @param {Object} relationshipDataHash
45
- @return {Object}
46
42
  @private
47
43
  */
48
44
  _normalizeRelationshipDataHelper(relationshipDataHash) {
@@ -50,8 +46,6 @@ const JSONAPISerializer = JSONSerializer.extend({
50
46
  return relationshipDataHash;
51
47
  },
52
48
  /**
53
- @param {Object} resourceHash
54
- @return {Object}
55
49
  @private
56
50
  */
57
51
  _normalizeResourceHelper(resourceHash) {
@@ -88,21 +82,13 @@ const JSONAPISerializer = JSONSerializer.extend({
88
82
  /**
89
83
  Normalize some data and push it into the store.
90
84
  @public
91
- @param {Store} store
92
- @param {Object} payload
93
85
  */
94
86
  pushPayload(store, payload) {
95
87
  const normalizedPayload = this._normalizeDocumentHelper(payload);
96
88
  store.push(normalizedPayload);
97
89
  },
98
90
  /**
99
- @param {Store} store
100
- @param {Model} primaryModelClass
101
- @param {Object} payload
102
- @param {String|Number} id
103
- @param {String} requestType
104
- @param {Boolean} isSingle
105
- @return {Object} JSON-API Document
91
+ @return A {json:api} Document
106
92
  @private
107
93
  */
108
94
  _normalizeResponse(store, primaryModelClass, payload, id, requestType, isSingle) {
@@ -144,8 +130,6 @@ const JSONAPISerializer = JSONSerializer.extend({
144
130
  Returns a relationship formatted as a JSON-API "relationship object".
145
131
  http://jsonapi.org/format/#document-resource-object-relationships
146
132
  @public
147
- @param {Object} relationshipHash
148
- @return {Object}
149
133
  */
150
134
  extractRelationship(relationshipHash) {
151
135
  if (Array.isArray(relationshipHash.data)) {
@@ -164,9 +148,6 @@ const JSONAPISerializer = JSONSerializer.extend({
164
148
  Returns the resource's relationships formatted as a JSON-API "relationships object".
165
149
  http://jsonapi.org/format/#document-resource-object-relationships
166
150
  @public
167
- @param {Object} modelClass
168
- @param {Object} resourceHash
169
- @return {Object}
170
151
  */
171
152
  extractRelationships(modelClass, resourceHash) {
172
153
  const relationships = {};
@@ -191,9 +172,6 @@ const JSONAPISerializer = JSONSerializer.extend({
191
172
  return relationships;
192
173
  },
193
174
  /**
194
- @param {Model} modelClass
195
- @param {Object} resourceHash
196
- @return {String}
197
175
  @private
198
176
  */
199
177
  _extractType(modelClass, resourceHash) {
@@ -205,8 +183,7 @@ const JSONAPISerializer = JSONSerializer.extend({
205
183
  For example the key `posts` would be converted to `post` and the
206
184
  key `studentAssesments` would be converted to `student-assesment`.
207
185
  @public
208
- @param {String} key
209
- @return {String} the model's modelName
186
+ @return the model's modelName
210
187
  */
211
188
  modelNameFromPayloadKey(key) {
212
189
  return dasherize(singularize(key));
@@ -216,8 +193,6 @@ const JSONAPISerializer = JSONSerializer.extend({
216
193
  For example `post` would be converted to `posts` and
217
194
  `student-assesment` would be converted to `student-assesments`.
218
195
  @public
219
- @param {String} modelName
220
- @return {String}
221
196
  */
222
197
  payloadKeyFromModelName(modelName) {
223
198
  return pluralize(modelName);
@@ -267,9 +242,7 @@ const JSONAPISerializer = JSONSerializer.extend({
267
242
  }
268
243
  ```
269
244
  @public
270
- @param {String} key
271
- @param {String} method
272
- @return {String} normalized key
245
+ @return normalized key
273
246
  */
274
247
  keyForAttribute(key, method) {
275
248
  return dasherize(key);
@@ -292,10 +265,7 @@ const JSONAPISerializer = JSONSerializer.extend({
292
265
  }
293
266
  ```
294
267
  @public
295
- @param {String} key
296
- @param {String} typeClass
297
- @param {String} method
298
- @return {String} normalized key
268
+ @return the normalized key
299
269
  */
300
270
  keyForRelationship(key, typeClass, method) {
301
271
  return dasherize(key);
@@ -426,9 +396,6 @@ const JSONAPISerializer = JSONSerializer.extend({
426
396
  }
427
397
  ```
428
398
  @public
429
- @param {Snapshot} snapshot
430
- @param {Object} options
431
- @return {Object} json
432
399
  */
433
400
  serialize(snapshot, options) {
434
401
  // @ts-expect-error untyped
@@ -467,6 +434,7 @@ const JSONAPISerializer = JSONSerializer.extend({
467
434
  // @ts-expect-error untyped
468
435
  if (this._canSerialize(name)) {
469
436
  const belongsTo = snapshot.belongsTo(name);
437
+ // @ts-expect-error not narrowed
470
438
  const belongsToIsNotNew = belongsTo && !belongsTo.isNew;
471
439
  if (belongsTo === null || belongsToIsNotNew) {
472
440
  json.relationships = json.relationships || {};
@@ -480,11 +448,13 @@ const JSONAPISerializer = JSONSerializer.extend({
480
448
  }
481
449
  let data = null;
482
450
  if (belongsTo) {
451
+ // @ts-expect-error not narrowed
483
452
  const payloadType = this.payloadKeyFromModelName(belongsTo.modelName);
484
453
 
485
454
  // @ts-expect-error untyped
486
455
  data = {
487
456
  type: payloadType,
457
+ // @ts-expect-error not narrowed
488
458
  id: belongsTo.id
489
459
  };
490
460
  }
@@ -512,13 +482,16 @@ const JSONAPISerializer = JSONSerializer.extend({
512
482
  }
513
483
 
514
484
  // only serialize has many relationships that are not new
485
+ // @ts-expect-error not narrowed
515
486
  const nonNewHasMany = hasMany.filter(item => !item.isNew);
516
487
  const data = new Array(nonNewHasMany.length);
517
488
  for (let i = 0; i < nonNewHasMany.length; i++) {
518
489
  const item = hasMany[i];
490
+ // @ts-expect-error not narrowed
519
491
  const payloadType = this.payloadKeyFromModelName(item.modelName);
520
492
  data[i] = {
521
493
  type: payloadType,
494
+ // @ts-expect-error not narrowed
522
495
  id: item.id
523
496
  };
524
497
  }
@@ -2,5 +2,5 @@ import '@ember/application';
2
2
  import '@ember/debug';
3
3
  import '@warp-drive/utilities/string';
4
4
  import '../serializer.js';
5
- export { J as JSONSerializer } from "../json-Et4mt_LM.js";
5
+ export { J as JSONSerializer } from "../json-BHxlccxF.js";
6
6
  import '@embroider/macros';
@@ -1,6 +1,6 @@
1
1
  import { warn } from '@ember/debug';
2
2
  import { camelize, dasherize, singularize } from '@warp-drive/utilities/string';
3
- import { J as JSONSerializer, c as coerceId } from "../json-Et4mt_LM.js";
3
+ import { J as JSONSerializer, c as coerceId } from "../json-BHxlccxF.js";
4
4
  import { macroCondition, getGlobalConfig } from '@embroider/macros';
5
5
  import Mixin from '@ember/object/mixin';
6
6
 
@@ -96,11 +96,6 @@ import Mixin from '@ember/object/mixin';
96
96
  are. Please read the docs for the methods this mixin provides, in case you need
97
97
  to modify it to fit your specific needs.**
98
98
 
99
- For example, review the docs for each method of this mixin:
100
- * [normalize](/ember-data/release/classes/EmbeddedRecordsMixin/methods/normalize?anchor=normalize)
101
- * [serializeBelongsTo](/ember-data/release/classes/EmbeddedRecordsMixin/methods/serializeBelongsTo?anchor=serializeBelongsTo)
102
- * [serializeHasMany](/ember-data/release/classes/EmbeddedRecordsMixin/methods/serializeHasMany?anchor=serializeHasMany)
103
-
104
99
  @class EmbeddedRecordsMixin
105
100
  @public
106
101
  */
@@ -583,13 +578,11 @@ function makeArray(value) {
583
578
  }
584
579
 
585
580
  /**
586
- * <blockquote style="margin: 1em; padding: .1em 1em .1em 1em; border-left: solid 1em #E34C32; background: #e0e0e0;">
587
- <p>
588
- ⚠️ <strong>This is LEGACY documentation</strong> for a feature that is no longer encouraged to be used.
581
+ * :::danger
582
+ ⚠️ **This is LEGACY documentation** for a feature that is no longer encouraged to be used.
589
583
  If starting a new app or thinking of implementing a new adapter, consider writing a
590
- <a href="/ember-data/release/classes/%3CInterface%3E%20Handler">Handler</a> instead to be used with the <a href="https://github.com/emberjs/data/tree/main/packages/request#readme">RequestManager</a>
591
- </p>
592
- </blockquote>
584
+ {@link Handler} instead to be used with the {@link RequestManager}
585
+ :::
593
586
 
594
587
  Normally, applications will use the `RESTSerializer` by implementing
595
588
  the `normalize` method.
@@ -79,11 +79,13 @@ import EmberObject from '@ember/object';
79
79
  */
80
80
  const Transform = EmberObject;
81
81
 
82
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
83
+
82
84
  /**
83
85
  The `BooleanTransform` class is used to serialize and deserialize
84
86
  boolean attributes on Ember Data record objects. This transform is
85
- used when `boolean` is passed as the type parameter to the
86
- [attr](/ember-data/release/functions/@ember-data%2Fmodel/attr) function.
87
+ used when `'boolean'` is passed as the type parameter to the
88
+ {@link attr}function.
87
89
 
88
90
  Usage
89
91
 
@@ -139,11 +141,13 @@ class BooleanTransform {
139
141
  }
140
142
  }
141
143
 
144
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
145
+
142
146
  /**
143
147
  The `DateTransform` class is used to serialize and deserialize
144
148
  date attributes on Ember Data record objects. This transform is used
145
- when `date` is passed as the type parameter to the
146
- [attr](/ember-data/release/functions/@ember-data%2Fmodel/attr) function. It uses the [`ISO 8601`](https://en.wikipedia.org/wiki/ISO_8601)
149
+ when `'date'` is passed as the type parameter to the
150
+ {@link attr} function. It uses the [`ISO 8601`](https://en.wikipedia.org/wiki/ISO_8601)
147
151
  standard.
148
152
 
149
153
  ```js [app/models/score.js]
@@ -190,6 +194,9 @@ class DateTransform {
190
194
  return new this();
191
195
  }
192
196
  }
197
+
198
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
199
+
193
200
  function isNumber(value) {
194
201
  return value === value && value !== Infinity && value !== -Infinity;
195
202
  }
@@ -197,7 +204,7 @@ function isNumber(value) {
197
204
  The `NumberTransform` class is used to serialize and deserialize
198
205
  numeric attributes on Ember Data record objects. This transform is
199
206
  used when `number` is passed as the type parameter to the
200
- [attr](/ember-data/release/functions/@ember-data%2Fmodel/attr) function.
207
+ {@link attr} function.
201
208
 
202
209
  Usage
203
210
 
@@ -235,11 +242,13 @@ class NumberTransform {
235
242
  }
236
243
  }
237
244
 
245
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
246
+
238
247
  /**
239
248
  The `StringTransform` class is used to serialize and deserialize
240
249
  string attributes on Ember Data record objects. This transform is
241
250
  used when `string` is passed as the type parameter to the
242
- [attr](/ember-data/release/functions/@ember-data%2Fmodel/attr) function.
251
+ {@link attr} function.
243
252
 
244
253
  Usage
245
254
 
@@ -5,13 +5,11 @@ import { a as decorateFieldV2, i as initializeDeferredDecorator } from "./runtim
5
5
  /**
6
6
  ## Overview
7
7
 
8
- <blockquote style="margin: 1em; padding: .1em 1em .1em 1em; border-left: solid 1em #E34C32; background: #e0e0e0;">
9
- <p>
10
- ⚠️ <strong>This is LEGACY documentation</strong> for a feature that is no longer encouraged to be used.
8
+ :::danger
9
+ ⚠️ **This is LEGACY documentation** for a feature that is no longer encouraged to be used.
11
10
  If starting a new app or thinking of implementing a new serializer, consider writing a
12
- <a href="/ember-data/release/classes/%3CInterface%3E%20Handler">Handler</a> instead to be used with the <a href="https://github.com/emberjs/data/tree/main/packages/request#readme">RequestManager</a>
13
- </p>
14
- </blockquote>
11
+ {@link Handler} instead to be used with the {@link RequestManager}
12
+ :::
15
13
 
16
14
  In order to properly manage and present your data, WarpDrive
17
15
  needs to understand the structure of data it receives.
@@ -20,14 +18,14 @@ import { a as decorateFieldV2, i as initializeDeferredDecorator } from "./runtim
20
18
  the format WarpDrive understands.
21
19
 
22
20
  Data received from an API response is **normalized** into
23
- [JSON:API](https://jsonapi.org/) (the format used internally
21
+ [{json:api}](https://jsonapi.org/) (the format used internally
24
22
  by WarpDrive), while data sent to an API is **serialized**
25
23
  into the format the API expects.
26
24
 
27
25
  ### Implementing a Serializer
28
26
 
29
27
  There are only two required serializer methods, one for
30
- normalizing data from the server API format into JSON:API, and
28
+ normalizing data from the server API format into {json:api}, and
31
29
  another for serializing records via `Snapshots` into the expected
32
30
  server API format.
33
31
 
@@ -73,7 +71,7 @@ import { a as decorateFieldV2, i as initializeDeferredDecorator } from "./runtim
73
71
  // app/serializers/application.js
74
72
  ```
75
73
 
76
- Most requests in @warp-drive/legacy are made with respect to a particular `type` (or `modelName`)
74
+ Most requests in `@warp-drive/legacy` are made with respect to a particular `type` (or `modelName`)
77
75
  (e.g., "get me the full collection of **books**" or "get me the **employee** whose id is 37"). We
78
76
  refer to this as the **primary** resource `type`.
79
77
 
@@ -109,7 +107,6 @@ import { a as decorateFieldV2, i as initializeDeferredDecorator } from "./runtim
109
107
 
110
108
  @module
111
109
  */
112
-
113
110
  const service = s.service ?? s.inject;
114
111
 
115
112
  /**
@@ -127,8 +124,7 @@ const service = s.service ?? s.inject;
127
124
 
128
125
  * `normalize()`
129
126
 
130
- For an example implementation, see
131
- [JSONSerializer](JSONSerializer), the included JSON serializer.
127
+ For an example implementation, see the included {@link JSONSerializer}.
132
128
 
133
129
  @class Serializer
134
130
  @public
package/dist/store.js CHANGED
@@ -524,6 +524,9 @@ function restoreDeprecatedStoreBehaviors(StoreKlass) {
524
524
  });
525
525
  return promise.then(document => document.content);
526
526
  };
527
+
528
+ // do not put a ts-expect-error here, because typedoc will fail to
529
+ // build due to this error only occurring when references are in use in the editor
527
530
  StoreKlass.prototype.getReference = function (resource, id) {
528
531
  macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
529
532
  if (!test) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@warp-drive/legacy",
3
- "version": "5.8.0-alpha.0",
3
+ "version": "5.8.0-alpha.10",
4
4
  "description": "Decommissioned Packages for WarpDrive | Things your app might still want to maintain use of for a little longer.",
5
5
  "keywords": [
6
6
  "ember-addon"
@@ -9,7 +9,7 @@
9
9
  "author": "Chris Thoburn <runspired@users.noreply.github.com>",
10
10
  "repository": {
11
11
  "type": "git",
12
- "url": "git+ssh://git@github.com:emberjs/data.git",
12
+ "url": "git+ssh://git@github.com:warp-drive-data/warp-drive.git",
13
13
  "directory": "warp-drive-packages/legacy"
14
14
  },
15
15
  "files": [
@@ -32,8 +32,8 @@
32
32
  }
33
33
  },
34
34
  "peerDependencies": {
35
- "@warp-drive/core": "5.8.0-alpha.0",
36
- "@warp-drive/utilities": "5.8.0-alpha.0"
35
+ "@warp-drive/core": "5.8.0-alpha.10",
36
+ "@warp-drive/utilities": "5.8.0-alpha.10"
37
37
  },
38
38
  "dependencies": {
39
39
  "@embroider/macros": "^1.18.1"
@@ -43,9 +43,9 @@
43
43
  "@babel/plugin-transform-typescript": "^7.28.0",
44
44
  "@babel/preset-typescript": "^7.27.1",
45
45
  "@types/jquery": "^3.5.33",
46
- "@warp-drive/internal-config": "5.8.0-alpha.0",
47
- "@warp-drive/core": "5.8.0-alpha.0",
48
- "@warp-drive/utilities": "5.8.0-alpha.0",
46
+ "@warp-drive/internal-config": "5.8.0-alpha.10",
47
+ "@warp-drive/core": "5.8.0-alpha.10",
48
+ "@warp-drive/utilities": "5.8.0-alpha.10",
49
49
  "ember-source": "~6.6.0",
50
50
  "decorator-transforms": "^2.3.0",
51
51
  "expect-type": "^1.2.2",