@warp-drive/legacy 5.6.0-alpha.14 → 5.6.0-alpha.17

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 (191) hide show
  1. package/declarations/adapter/-private/build-url-mixin.d.ts +41 -29
  2. package/declarations/adapter/-private/fastboot-interface.d.ts +4 -5
  3. package/declarations/adapter/-private/utils/continue-on-reject.d.ts +5 -6
  4. package/declarations/adapter/-private/utils/determine-body-promise.d.ts +1 -2
  5. package/declarations/adapter/-private/utils/fetch.d.ts +2 -3
  6. package/declarations/adapter/-private/utils/parse-response-headers.d.ts +0 -1
  7. package/declarations/adapter/-private/utils/serialize-into-hash.d.ts +5 -6
  8. package/declarations/adapter/-private/utils/serialize-query-params.d.ts +5 -2
  9. package/declarations/adapter/-private.d.ts +5 -6
  10. package/declarations/adapter/error.d.ts +206 -178
  11. package/declarations/adapter/json-api.d.ts +206 -207
  12. package/declarations/adapter/rest.d.ts +805 -808
  13. package/declarations/adapter.d.ts +742 -766
  14. package/declarations/compat/-private.d.ts +10 -11
  15. package/declarations/compat/builders/find-all.d.ts +26 -24
  16. package/declarations/compat/builders/find-record.d.ts +41 -39
  17. package/declarations/compat/builders/query.d.ts +50 -45
  18. package/declarations/compat/builders/save-record.d.ts +26 -24
  19. package/declarations/compat/builders/utils.d.ts +1 -2
  20. package/declarations/compat/builders.d.ts +10 -11
  21. package/declarations/compat/extensions.d.ts +59 -0
  22. package/declarations/compat/legacy-network-handler/fetch-manager.d.ts +39 -38
  23. package/declarations/compat/legacy-network-handler/identifier-has-id.d.ts +1 -2
  24. package/declarations/compat/legacy-network-handler/legacy-data-fetch.d.ts +9 -10
  25. package/declarations/compat/legacy-network-handler/legacy-data-utils.d.ts +1 -2
  26. package/declarations/compat/legacy-network-handler/legacy-network-handler.d.ts +1 -2
  27. package/declarations/compat/legacy-network-handler/minimum-adapter-interface.d.ts +521 -517
  28. package/declarations/compat/legacy-network-handler/minimum-serializer-interface.d.ts +214 -215
  29. package/declarations/compat/legacy-network-handler/serializer-response.d.ts +5 -6
  30. package/declarations/compat/legacy-network-handler/snapshot-record-array.d.ts +83 -84
  31. package/declarations/compat/legacy-network-handler/snapshot.d.ts +228 -229
  32. package/declarations/compat/utils.d.ts +118 -119
  33. package/declarations/compat.d.ts +106 -104
  34. package/declarations/model/-private/attr.d.ts +164 -145
  35. package/declarations/model/-private/belongs-to.d.ts +135 -122
  36. package/declarations/model/-private/debug/assert-polymorphic-type.d.ts +15 -4
  37. package/declarations/model/-private/errors.d.ts +272 -267
  38. package/declarations/model/-private/has-many.d.ts +119 -116
  39. package/declarations/model/-private/hooks.d.ts +5 -6
  40. package/declarations/model/-private/legacy-relationships-support.d.ts +51 -52
  41. package/declarations/model/-private/model-for-mixin.d.ts +18 -3
  42. package/declarations/model/-private/model-methods.d.ts +29 -24
  43. package/declarations/model/-private/model.d.ts +1306 -1254
  44. package/declarations/model/-private/notify-changes.d.ts +3 -4
  45. package/declarations/model/-private/promise-belongs-to.d.ts +33 -27
  46. package/declarations/model/-private/promise-many-array.d.ts +125 -116
  47. package/declarations/model/-private/record-state.d.ts +63 -60
  48. package/declarations/model/-private/references/belongs-to.d.ts +491 -487
  49. package/declarations/model/-private/references/has-many.d.ts +495 -492
  50. package/declarations/model/-private/schema-provider.d.ts +53 -56
  51. package/declarations/model/-private/type-utils.d.ts +41 -41
  52. package/declarations/model/-private/util.d.ts +1 -2
  53. package/declarations/model/-private.d.ts +8 -8
  54. package/declarations/model/migration-support.d.ts +281 -271
  55. package/declarations/model.d.ts +48 -49
  56. package/declarations/serializer/-private/embedded-records-mixin.d.ts +70 -71
  57. package/declarations/serializer/-private/transforms/boolean.d.ts +37 -37
  58. package/declarations/serializer/-private/transforms/date.d.ts +22 -22
  59. package/declarations/serializer/-private/transforms/number.d.ts +22 -22
  60. package/declarations/serializer/-private/transforms/string.d.ts +22 -22
  61. package/declarations/serializer/-private/transforms/transform.d.ts +109 -110
  62. package/declarations/serializer/-private/utils.d.ts +0 -1
  63. package/declarations/serializer/json-api.d.ts +124 -494
  64. package/declarations/serializer/json.d.ts +62 -1031
  65. package/declarations/serializer/rest.d.ts +52 -552
  66. package/declarations/serializer/transform.d.ts +5 -6
  67. package/declarations/serializer.d.ts +217 -218
  68. package/dist/{-private-DFfBszo5.js → -private-CKrP0ogQ.js} +1 -1
  69. package/dist/adapter/-private.js +1 -1
  70. package/dist/adapter/error.js +17 -0
  71. package/dist/adapter/json-api.js +1 -1
  72. package/dist/adapter/rest.js +5 -7
  73. package/dist/adapter.js +6 -35
  74. package/dist/compat/-private.js +1 -1
  75. package/dist/compat/extensions.js +243 -0
  76. package/dist/compat.js +3 -4
  77. package/dist/{errors-D74uk36r.js → errors-BX5wowuz.js} +12 -10
  78. package/dist/{json-DSOlH9A8.js → json-Et4mt_LM.js} +84 -157
  79. package/dist/model/-private.js +1 -1
  80. package/dist/model/migration-support.js +15 -4
  81. package/dist/model.js +3 -3
  82. package/dist/{schema-provider-CXFLTMjg.js → schema-provider-BdQhkT-Q.js} +20 -13
  83. package/dist/{serialize-into-hash-BxfqWC8u.js → serialize-into-hash-Bp58npke.js} +1 -1
  84. package/dist/serializer/json-api.js +42 -2
  85. package/dist/serializer/json.js +1 -1
  86. package/dist/serializer/rest.js +46 -41
  87. package/dist/serializer/transform.js +0 -44
  88. package/package.json +7 -7
  89. package/declarations/adapter/-private/build-url-mixin.d.ts.map +0 -1
  90. package/declarations/adapter/-private/fastboot-interface.d.ts.map +0 -1
  91. package/declarations/adapter/-private/utils/continue-on-reject.d.ts.map +0 -1
  92. package/declarations/adapter/-private/utils/determine-body-promise.d.ts.map +0 -1
  93. package/declarations/adapter/-private/utils/fetch.d.ts.map +0 -1
  94. package/declarations/adapter/-private/utils/parse-response-headers.d.ts.map +0 -1
  95. package/declarations/adapter/-private/utils/serialize-into-hash.d.ts.map +0 -1
  96. package/declarations/adapter/-private/utils/serialize-query-params.d.ts.map +0 -1
  97. package/declarations/adapter/-private.d.ts.map +0 -1
  98. package/declarations/adapter/error.d.ts.map +0 -1
  99. package/declarations/adapter/json-api.d.ts.map +0 -1
  100. package/declarations/adapter/rest.d.ts.map +0 -1
  101. package/declarations/adapter.d.ts.map +0 -1
  102. package/declarations/compat/-private.d.ts.map +0 -1
  103. package/declarations/compat/builders/find-all.d.ts.map +0 -1
  104. package/declarations/compat/builders/find-record.d.ts.map +0 -1
  105. package/declarations/compat/builders/query.d.ts.map +0 -1
  106. package/declarations/compat/builders/save-record.d.ts.map +0 -1
  107. package/declarations/compat/builders/utils.d.ts.map +0 -1
  108. package/declarations/compat/builders.d.ts.map +0 -1
  109. package/declarations/compat/legacy-network-handler/fetch-manager.d.ts.map +0 -1
  110. package/declarations/compat/legacy-network-handler/identifier-has-id.d.ts.map +0 -1
  111. package/declarations/compat/legacy-network-handler/legacy-data-fetch.d.ts.map +0 -1
  112. package/declarations/compat/legacy-network-handler/legacy-data-utils.d.ts.map +0 -1
  113. package/declarations/compat/legacy-network-handler/legacy-network-handler.d.ts.map +0 -1
  114. package/declarations/compat/legacy-network-handler/minimum-adapter-interface.d.ts.map +0 -1
  115. package/declarations/compat/legacy-network-handler/minimum-serializer-interface.d.ts.map +0 -1
  116. package/declarations/compat/legacy-network-handler/serializer-response.d.ts.map +0 -1
  117. package/declarations/compat/legacy-network-handler/snapshot-record-array.d.ts.map +0 -1
  118. package/declarations/compat/legacy-network-handler/snapshot.d.ts.map +0 -1
  119. package/declarations/compat/utils.d.ts.map +0 -1
  120. package/declarations/compat.d.ts.map +0 -1
  121. package/declarations/model/-private/attr.d.ts.map +0 -1
  122. package/declarations/model/-private/attr.type-test.d.ts +0 -2
  123. package/declarations/model/-private/attr.type-test.d.ts.map +0 -1
  124. package/declarations/model/-private/belongs-to.d.ts.map +0 -1
  125. package/declarations/model/-private/belongs-to.type-test.d.ts +0 -2
  126. package/declarations/model/-private/belongs-to.type-test.d.ts.map +0 -1
  127. package/declarations/model/-private/debug/assert-polymorphic-type.d.ts.map +0 -1
  128. package/declarations/model/-private/errors.d.ts.map +0 -1
  129. package/declarations/model/-private/has-many.d.ts.map +0 -1
  130. package/declarations/model/-private/has-many.type-test.d.ts +0 -2
  131. package/declarations/model/-private/has-many.type-test.d.ts.map +0 -1
  132. package/declarations/model/-private/hooks.d.ts.map +0 -1
  133. package/declarations/model/-private/legacy-relationships-support.d.ts.map +0 -1
  134. package/declarations/model/-private/model-for-mixin.d.ts.map +0 -1
  135. package/declarations/model/-private/model-methods.d.ts.map +0 -1
  136. package/declarations/model/-private/model.d.ts.map +0 -1
  137. package/declarations/model/-private/model.type-test.d.ts +0 -2
  138. package/declarations/model/-private/model.type-test.d.ts.map +0 -1
  139. package/declarations/model/-private/notify-changes.d.ts.map +0 -1
  140. package/declarations/model/-private/promise-belongs-to.d.ts.map +0 -1
  141. package/declarations/model/-private/promise-many-array.d.ts.map +0 -1
  142. package/declarations/model/-private/promise-proxy-base.d.ts +0 -3
  143. package/declarations/model/-private/promise-proxy-base.d.ts.map +0 -1
  144. package/declarations/model/-private/record-state.d.ts.map +0 -1
  145. package/declarations/model/-private/references/belongs-to.d.ts.map +0 -1
  146. package/declarations/model/-private/references/has-many.d.ts.map +0 -1
  147. package/declarations/model/-private/schema-provider.d.ts.map +0 -1
  148. package/declarations/model/-private/type-utils.d.ts.map +0 -1
  149. package/declarations/model/-private/util.d.ts.map +0 -1
  150. package/declarations/model/-private.d.ts.map +0 -1
  151. package/declarations/model/migration-support.d.ts.map +0 -1
  152. package/declarations/model/migration-support.type-test.d.ts +0 -2
  153. package/declarations/model/migration-support.type-test.d.ts.map +0 -1
  154. package/declarations/model.d.ts.map +0 -1
  155. package/declarations/serializer/-private/embedded-records-mixin.d.ts.map +0 -1
  156. package/declarations/serializer/-private/transforms/boolean.d.ts.map +0 -1
  157. package/declarations/serializer/-private/transforms/boolean.type-test.d.ts +0 -2
  158. package/declarations/serializer/-private/transforms/boolean.type-test.d.ts.map +0 -1
  159. package/declarations/serializer/-private/transforms/date.d.ts.map +0 -1
  160. package/declarations/serializer/-private/transforms/number.d.ts.map +0 -1
  161. package/declarations/serializer/-private/transforms/string.d.ts.map +0 -1
  162. package/declarations/serializer/-private/transforms/transform.d.ts.map +0 -1
  163. package/declarations/serializer/-private/utils.d.ts.map +0 -1
  164. package/declarations/serializer/json-api.d.ts.map +0 -1
  165. package/declarations/serializer/json.d.ts.map +0 -1
  166. package/declarations/serializer/rest.d.ts.map +0 -1
  167. package/declarations/serializer/transform.d.ts.map +0 -1
  168. package/declarations/serializer.d.ts.map +0 -1
  169. package/dist/-private-DFfBszo5.js.map +0 -1
  170. package/dist/adapter/-private.js.map +0 -1
  171. package/dist/adapter/error.js.map +0 -1
  172. package/dist/adapter/json-api.js.map +0 -1
  173. package/dist/adapter/rest.js.map +0 -1
  174. package/dist/adapter.js.map +0 -1
  175. package/dist/compat/-private.js.map +0 -1
  176. package/dist/compat/builders.js.map +0 -1
  177. package/dist/compat/utils.js.map +0 -1
  178. package/dist/compat.js.map +0 -1
  179. package/dist/errors-D74uk36r.js.map +0 -1
  180. package/dist/json-DSOlH9A8.js.map +0 -1
  181. package/dist/model/-private.js.map +0 -1
  182. package/dist/model/migration-support.js.map +0 -1
  183. package/dist/model.js.map +0 -1
  184. package/dist/runtime-BPCpkOf1-BKOwiRJp.js.map +0 -1
  185. package/dist/schema-provider-CXFLTMjg.js.map +0 -1
  186. package/dist/serialize-into-hash-BxfqWC8u.js.map +0 -1
  187. package/dist/serializer/json-api.js.map +0 -1
  188. package/dist/serializer/json.js.map +0 -1
  189. package/dist/serializer/rest.js.map +0 -1
  190. package/dist/serializer/transform.js.map +0 -1
  191. package/dist/serializer.js.map +0 -1
@@ -2,8 +2,8 @@ import { recordIdentifierFor } from '@warp-drive/core';
2
2
  import { notifyInternalSignal, ARRAY_SIGNAL } from '@warp-drive/core/store/-private';
3
3
  import { getOrSetGlobal } from '@warp-drive/core/types/-private';
4
4
  import { Type } from '@warp-drive/core/types/symbols';
5
- import { l as lookupLegacySupport, E as Errors } from "../errors-D74uk36r.js";
6
- import { b as buildSchema, u as unloadRecord, s as serialize, a as save, r as rollbackAttributes, c as reload, h as hasMany, d as destroyRecord, e as deleteRecord, R as RecordState, f as changedAttributes, g as belongsTo, i as createSnapshot } from "../schema-provider-CXFLTMjg.js";
5
+ import { l as lookupLegacySupport, E as Errors } from "../errors-BX5wowuz.js";
6
+ import { b as buildSchema, u as unloadRecord, s as serialize, a as save, r as rollbackAttributes, c as reload, h as hasMany, d as destroyRecord, e as deleteRecord, R as RecordState, f as changedAttributes, g as belongsTo, i as createSnapshot } from "../schema-provider-BdQhkT-Q.js";
7
7
  import { macroCondition, getGlobalConfig } from '@embroider/macros';
8
8
 
9
9
  /**
@@ -251,8 +251,7 @@ function withDefaults(schema) {
251
251
  * import { withDefaults } from '@ember-data/model/migration-support';
252
252
  * ```
253
253
  *
254
- * @param {SchemaService} schema The schema service to register the derivations with.
255
- * @return {void}
254
+ * @param schema The schema service to register the derivations with.
256
255
  * @public
257
256
  */
258
257
  function registerDerivations(schema) {
@@ -398,6 +397,18 @@ class DelegatingSchemaService {
398
397
  registerHashFn(hashFn) {
399
398
  this._preferred.registerHashFn(hashFn);
400
399
  }
400
+ CAUTION_MEGA_DANGER_ZONE_registerExtension(extension) {
401
+ this._preferred.CAUTION_MEGA_DANGER_ZONE_registerExtension(extension);
402
+ }
403
+ CAUTION_MEGA_DANGER_ZONE_resourceExtensions(resource) {
404
+ return this._preferred.CAUTION_MEGA_DANGER_ZONE_resourceExtensions(resource);
405
+ }
406
+ CAUTION_MEGA_DANGER_ZONE_objectExtensions(field) {
407
+ return this._preferred.CAUTION_MEGA_DANGER_ZONE_objectExtensions(field);
408
+ }
409
+ CAUTION_MEGA_DANGER_ZONE_arrayExtensions(field) {
410
+ return this._preferred.CAUTION_MEGA_DANGER_ZONE_arrayExtensions(field);
411
+ }
401
412
 
402
413
  /**
403
414
  * This is an internal method used to register behaviors for legacy mode.
package/dist/model.js CHANGED
@@ -1,12 +1,12 @@
1
1
  import { computed } from '@ember/object';
2
2
  import { recordIdentifierFor } from '@warp-drive/core';
3
3
  import { peekCache, setRecordIdentifier, StoreMap, setCacheFor } from '@warp-drive/core/store/-private';
4
- import { j as isElementDescriptor, n as normalizeModelName, k as getModelFactory } from "./schema-provider-CXFLTMjg.js";
5
- export { M as Model, b as buildSchema, M as default } from "./schema-provider-CXFLTMjg.js";
4
+ import { j as isElementDescriptor, n as normalizeModelName, k as getModelFactory } from "./schema-provider-BdQhkT-Q.js";
5
+ export { M as Model, b as buildSchema, M as default } from "./schema-provider-BdQhkT-Q.js";
6
6
  import { macroCondition, getGlobalConfig } from '@embroider/macros';
7
7
  import { warn, deprecate } from '@ember/debug';
8
8
  import { RecordStore } from '@warp-drive/core/types/symbols';
9
- import { l as lookupLegacySupport } from "./errors-D74uk36r.js";
9
+ import { l as lookupLegacySupport } from "./errors-BX5wowuz.js";
10
10
  import { singularize, dasherize } from '@warp-drive/utilities/string';
11
11
  import { setOwner, getOwner } from '@ember/application';
12
12
  function _attr(type, options) {
@@ -4,8 +4,8 @@ import EmberObject from '@ember/object';
4
4
  import { recordIdentifierFor, storeFor } from '@warp-drive/core';
5
5
  import { peekCache, notifyInternalSignal, peekInternalSignal, withSignalStore, ARRAY_SIGNAL, recordIdentifierFor as recordIdentifierFor$1, gate, memoized, defineSignal, coerceId, entangleSignal } from '@warp-drive/core/store/-private';
6
6
  import { RecordStore } from '@warp-drive/core/types/symbols';
7
- import { l as lookupLegacySupport, L as LEGACY_SUPPORT, E as Errors } from "./errors-D74uk36r.js";
8
- import { u as upgradeStore, F as FetchManager } from "./-private-DFfBszo5.js";
7
+ import { l as lookupLegacySupport, L as LEGACY_SUPPORT, E as Errors } from "./errors-BX5wowuz.js";
8
+ import { u as upgradeStore, F as FetchManager } from "./-private-CKrP0ogQ.js";
9
9
  import { macroCondition, getGlobalConfig } from '@embroider/macros';
10
10
  import { cacheFor } from '@ember/object/internals';
11
11
  import { d as decorateMethodV2 } from "./runtime-BPCpkOf1-BKOwiRJp.js";
@@ -347,9 +347,13 @@ class RecordState {
347
347
  }
348
348
  });
349
349
  }
350
+
351
+ /** @internal */
350
352
  destroy() {
351
353
  storeFor(this.record).notifications.unsubscribe(this.handler);
352
354
  }
355
+
356
+ /** @internal */
353
357
  notify(key) {
354
358
  const signals = withSignalStore(this);
355
359
  const signal = peekInternalSignal(signals, key);
@@ -357,6 +361,8 @@ class RecordState {
357
361
  notifyInternalSignal(signal);
358
362
  }
359
363
  }
364
+
365
+ /** @internal */
360
366
  updateInvalidErrors(errors) {
361
367
  macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
362
368
  if (!test) {
@@ -387,6 +393,8 @@ class RecordState {
387
393
  }
388
394
  }
389
395
  }
396
+
397
+ /** @internal */
390
398
  cleanErrorRequests() {
391
399
  this.notify('isValid');
392
400
  this.notify('isError');
@@ -664,17 +672,6 @@ function computeOnce(target, propertyName, desc) {
664
672
  * @noInheritDoc
665
673
  */
666
674
  class Model extends EmberObject {
667
- // set during create by the store
668
- /**
669
- * The store service instance which created this record instance
670
- */
671
-
672
- /** @internal */
673
-
674
- /** @internal */
675
-
676
- /** @internal */
677
-
678
675
  /** @internal */
679
676
  init(options) {
680
677
  if (macroCondition(getGlobalConfig().WarpDrive.env.DEBUG)) {
@@ -2170,9 +2167,14 @@ if (macroCondition(getGlobalConfig().WarpDrive.deprecations.ENABLE_LEGACY_SCHEMA
2170
2167
  }
2171
2168
  });
2172
2169
  const type = normalizeModelName(resource.type);
2170
+
2171
+ // @ts-expect-error intentional use of internal API
2173
2172
  if (!this._schemas.has(type)) {
2173
+ // @ts-expect-error intentional use of internal API
2174
2174
  this._loadModelSchema(type);
2175
2175
  }
2176
+
2177
+ // @ts-expect-error intentional use of internal API
2176
2178
  return this._schemas.get(type).attributes;
2177
2179
  };
2178
2180
  ModelSchemaProvider.prototype.relationshipsDefinitionFor = function (resource) {
@@ -2186,9 +2188,14 @@ if (macroCondition(getGlobalConfig().WarpDrive.deprecations.ENABLE_LEGACY_SCHEMA
2186
2188
  }
2187
2189
  });
2188
2190
  const type = normalizeModelName(resource.type);
2191
+
2192
+ // @ts-expect-error intentional use of internal API
2189
2193
  if (!this._schemas.has(type)) {
2194
+ // @ts-expect-error intentional use of internal API
2190
2195
  this._loadModelSchema(type);
2191
2196
  }
2197
+
2198
+ // @ts-expect-error intentional use of internal API
2192
2199
  return this._schemas.get(type).relationships;
2193
2200
  };
2194
2201
  }
@@ -1,7 +1,7 @@
1
1
  import { warn } from '@ember/debug';
2
2
  import { macroCondition, getGlobalConfig } from '@embroider/macros';
3
3
  import '@warp-drive/core/store/-private';
4
- import "./-private-DFfBszo5.js";
4
+ import "./-private-CKrP0ogQ.js";
5
5
  const newline = /\r?\n/;
6
6
  function parseResponseHeaders(headersString) {
7
7
  const headers = Object.create(null);
@@ -1,7 +1,13 @@
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-DSOlH9A8.js";
3
+ import { J as JSONSerializer } from "../json-Et4mt_LM.js";
4
4
  import { macroCondition, getGlobalConfig } from '@embroider/macros';
5
+
6
+ /* eslint-disable @typescript-eslint/no-unsafe-return */
7
+ /* eslint-disable @typescript-eslint/no-unsafe-assignment */
8
+ /* eslint-disable @typescript-eslint/no-unsafe-argument */
9
+ /* eslint-disable @typescript-eslint/no-unsafe-member-access */
10
+ /* eslint-disable @typescript-eslint/no-unsafe-call */
5
11
  const JSONAPISerializer = JSONSerializer.extend({
6
12
  /**
7
13
  @param {Object} documentHash
@@ -20,11 +26,12 @@ const JSONAPISerializer = JSONSerializer.extend({
20
26
  documentHash.data = this._normalizeResourceHelper(documentHash.data);
21
27
  }
22
28
  if (Array.isArray(documentHash.included)) {
23
- const ret = new Array();
29
+ const ret = [];
24
30
  for (let i = 0; i < documentHash.included.length; i++) {
25
31
  const included = documentHash.included[i];
26
32
  const normalized = this._normalizeResourceHelper(included);
27
33
  if (normalized !== null) {
34
+ // @ts-expect-error untyped
28
35
  // can be null when unknown type is encountered
29
36
  ret.push(normalized);
30
37
  }
@@ -48,23 +55,30 @@ const JSONAPISerializer = JSONSerializer.extend({
48
55
  @private
49
56
  */
50
57
  _normalizeResourceHelper(resourceHash) {
58
+ // @ts-expect-error untyped
51
59
  macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
52
60
  if (!test) {
53
61
  throw new Error(this.warnMessageForUndefinedType());
54
62
  }
55
63
  })(resourceHash.type) : {};
56
64
  const type = this.modelNameFromPayloadKey(resourceHash.type);
65
+
66
+ // @ts-expect-error store is dynamically added
57
67
  if (!this.store.schema.hasResource({
58
68
  type
59
69
  })) {
60
70
  if (macroCondition(getGlobalConfig().WarpDrive.env.DEBUG)) {
71
+ // @ts-expect-error untyped
61
72
  warn(this.warnMessageNoModelForType(type, resourceHash.type, 'modelNameFromPayloadKey'), false, {
62
73
  id: 'ds.serializer.model-for-type-missing'
63
74
  });
64
75
  }
65
76
  return null;
66
77
  }
78
+
79
+ // @ts-expect-error store is dynamically added
67
80
  const modelClass = this.store.modelFor(type);
81
+ // @ts-expect-error store is dynamically added
68
82
  const serializer = this.store.serializerFor(type);
69
83
  const {
70
84
  data
@@ -96,6 +110,7 @@ const JSONAPISerializer = JSONSerializer.extend({
96
110
  return normalizedPayload;
97
111
  },
98
112
  normalizeQueryRecordResponse() {
113
+ // @ts-expect-error untyped
99
114
  const normalized = this._super(...arguments);
100
115
  macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
101
116
  if (!test) {
@@ -209,20 +224,26 @@ const JSONAPISerializer = JSONSerializer.extend({
209
224
  },
210
225
  normalize(modelClass, resourceHash) {
211
226
  if (resourceHash.attributes) {
227
+ // @ts-expect-error untyped
212
228
  this.normalizeUsingDeclaredMapping(modelClass, resourceHash.attributes);
213
229
  }
214
230
  if (resourceHash.relationships) {
231
+ // @ts-expect-error untyped
215
232
  this.normalizeUsingDeclaredMapping(modelClass, resourceHash.relationships);
216
233
  }
217
234
  const data = {
235
+ // @ts-expect-error untyped
218
236
  id: this.extractId(modelClass, resourceHash),
219
237
  type: this._extractType(modelClass, resourceHash),
220
238
  attributes: this.extractAttributes(modelClass, resourceHash),
221
239
  relationships: this.extractRelationships(modelClass, resourceHash)
222
240
  };
223
241
  if (resourceHash.lid) {
242
+ // @ts-expect-error untyped
224
243
  data.lid = resourceHash.lid;
225
244
  }
245
+
246
+ // @ts-expect-error untyped
226
247
  this.applyTransforms(modelClass, data.attributes);
227
248
  return {
228
249
  data
@@ -410,6 +431,7 @@ const JSONAPISerializer = JSONSerializer.extend({
410
431
  @return {Object} json
411
432
  */
412
433
  serialize(snapshot, options) {
434
+ // @ts-expect-error untyped
413
435
  const data = this._super(...arguments);
414
436
  data.type = this.payloadKeyFromModelName(snapshot.modelName);
415
437
  return {
@@ -418,14 +440,20 @@ const JSONAPISerializer = JSONSerializer.extend({
418
440
  },
419
441
  serializeAttribute(snapshot, json, key, attribute) {
420
442
  const type = attribute.type;
443
+
444
+ // @ts-expect-error untyped
421
445
  if (this._canSerialize(key)) {
422
446
  json.attributes = json.attributes || {};
423
447
  let value = snapshot.attr(key);
424
448
  if (type) {
449
+ // @ts-expect-error untyped
425
450
  const transform = this.transformFor(type);
426
451
  value = transform.serialize(value, attribute.options);
427
452
  }
453
+
454
+ // @ts-expect-error store is dynamically added
428
455
  const schema = this.store.modelFor(snapshot.modelName);
456
+ // @ts-expect-error untyped
429
457
  let payloadKey = this._getMappedKey(key, schema);
430
458
  if (payloadKey === key) {
431
459
  payloadKey = this.keyForAttribute(key, 'serialize');
@@ -435,12 +463,17 @@ const JSONAPISerializer = JSONSerializer.extend({
435
463
  },
436
464
  serializeBelongsTo(snapshot, json, relationship) {
437
465
  const name = relationship.name;
466
+
467
+ // @ts-expect-error untyped
438
468
  if (this._canSerialize(name)) {
439
469
  const belongsTo = snapshot.belongsTo(name);
440
470
  const belongsToIsNotNew = belongsTo && !belongsTo.isNew;
441
471
  if (belongsTo === null || belongsToIsNotNew) {
442
472
  json.relationships = json.relationships || {};
473
+
474
+ // @ts-expect-error store is dynamically added
443
475
  const schema = this.store.modelFor(snapshot.modelName);
476
+ // @ts-expect-error untyped
444
477
  let payloadKey = this._getMappedKey(name, schema);
445
478
  if (payloadKey === name) {
446
479
  payloadKey = this.keyForRelationship(name, 'belongsTo', 'serialize');
@@ -448,6 +481,8 @@ const JSONAPISerializer = JSONSerializer.extend({
448
481
  let data = null;
449
482
  if (belongsTo) {
450
483
  const payloadType = this.payloadKeyFromModelName(belongsTo.modelName);
484
+
485
+ // @ts-expect-error untyped
451
486
  data = {
452
487
  type: payloadType,
453
488
  id: belongsTo.id
@@ -461,11 +496,16 @@ const JSONAPISerializer = JSONSerializer.extend({
461
496
  },
462
497
  serializeHasMany(snapshot, json, relationship) {
463
498
  const name = relationship.name;
499
+
500
+ // @ts-expect-error untyped
464
501
  if (this.shouldSerializeHasMany(snapshot, name, relationship)) {
465
502
  const hasMany = snapshot.hasMany(name);
466
503
  if (hasMany !== undefined) {
467
504
  json.relationships = json.relationships || {};
505
+
506
+ // @ts-expect-error store is dynamically added
468
507
  const schema = this.store.modelFor(snapshot.modelName);
508
+ // @ts-expect-error untyped
469
509
  let payloadKey = this._getMappedKey(name, schema);
470
510
  if (payloadKey === name && this.keyForRelationship) {
471
511
  payloadKey = this.keyForRelationship(name, 'hasMany', 'serialize');
@@ -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-DSOlH9A8.js";
5
+ export { J as JSONSerializer } from "../json-Et4mt_LM.js";
6
6
  import '@embroider/macros';
@@ -1,9 +1,15 @@
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-DSOlH9A8.js";
3
+ import { J as JSONSerializer, c as coerceId } from "../json-Et4mt_LM.js";
4
4
  import { macroCondition, getGlobalConfig } from '@embroider/macros';
5
5
  import Mixin from '@ember/object/mixin';
6
6
 
7
+ /* eslint-disable @typescript-eslint/no-unsafe-argument */
8
+ /* eslint-disable @typescript-eslint/no-unsafe-return */
9
+ /* eslint-disable @typescript-eslint/no-unsafe-call */
10
+ /* eslint-disable @typescript-eslint/no-unsafe-member-access */
11
+ /* eslint-disable @typescript-eslint/no-unsafe-assignment */
12
+
7
13
  /**
8
14
  ## Using Embedded Records
9
15
 
@@ -547,6 +553,7 @@ const EmbeddedRecordsMixin = Mixin.create({
547
553
  data: belongsTo
548
554
  };
549
555
  if (data.lid) {
556
+ // @ts-expect-error
550
557
  belongsTo.lid = data.lid;
551
558
  }
552
559
  hash.data.relationships[key] = relationship;
@@ -565,6 +572,12 @@ const EmbeddedRecordsMixin = Mixin.create({
565
572
  },
566
573
  isEmbeddedRecordsMixin: true
567
574
  });
575
+
576
+ /* eslint-disable @typescript-eslint/no-unsafe-argument */
577
+ /* eslint-disable @typescript-eslint/no-unsafe-member-access */
578
+ /* eslint-disable @typescript-eslint/no-unsafe-assignment */
579
+ /* eslint-disable @typescript-eslint/no-unsafe-call */
580
+ /* eslint-disable @typescript-eslint/no-unsafe-return */
568
581
  function makeArray(value) {
569
582
  return Array.isArray(value) ? value : [value];
570
583
  }
@@ -619,6 +632,7 @@ function makeArray(value) {
619
632
  @class RESTSerializer
620
633
  @public
621
634
  */
635
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
622
636
  const RESTSerializer = JSONSerializer.extend({
623
637
  /**
624
638
  `keyForPolymorphicType` can be used to define a custom key when
@@ -635,12 +649,9 @@ const RESTSerializer = JSONSerializer.extend({
635
649
  }
636
650
  ```
637
651
  @public
638
- @param {String} key
639
- @param {String} typeClass
640
- @param {String} method
641
- @return {String} normalized key
642
652
  */
643
- keyForPolymorphicType(key, typeClass, method) {
653
+ keyForPolymorphicType(key, type, method) {
654
+ // @ts-expect-error
644
655
  const relationshipKey = this.keyForRelationship(key);
645
656
  return `${relationshipKey}Type`;
646
657
  },
@@ -702,12 +713,7 @@ const RESTSerializer = JSONSerializer.extend({
702
713
  /**
703
714
  Normalizes an array of resource payloads and returns a JSON-API Document
704
715
  with primary data and, if any, included data as `{ data, included }`.
705
- @param {Store} store
706
- @param {String} modelName
707
- @param {Object} arrayHash
708
- @param {String} prop
709
- @return {Object}
710
- @private
716
+ @private
711
717
  */
712
718
  _normalizeArray(store, modelName, arrayHash, prop) {
713
719
  const documentHash = {
@@ -717,10 +723,12 @@ const RESTSerializer = JSONSerializer.extend({
717
723
  const modelClass = store.modelFor(modelName);
718
724
  const serializer = store.serializerFor(modelName);
719
725
  makeArray(arrayHash).forEach(hash => {
726
+ // @ts-expect-error
720
727
  const {
721
728
  data,
722
729
  included
723
730
  } = this._normalizePolymorphicRecord(store, hash, prop, modelClass, serializer);
731
+ // @ts-expect-error
724
732
  documentHash.data.push(data);
725
733
  if (included) {
726
734
  documentHash.included = documentHash.included.concat(included);
@@ -732,8 +740,11 @@ const RESTSerializer = JSONSerializer.extend({
732
740
  let serializer = primarySerializer;
733
741
  let modelClass = primaryModelClass;
734
742
  const primaryHasTypeAttribute = primaryModelClass.fields.has('type');
743
+
744
+ // @ts-expect-error all the errors
735
745
  if (!primaryHasTypeAttribute && hash.type) {
736
746
  // Support polymorphic records in async relationships
747
+ // @ts-expect-error all the errors
737
748
  const type = this.modelNameFromPayloadKey(hash.type);
738
749
  if (store.schema.hasResource({
739
750
  type
@@ -742,16 +753,11 @@ const RESTSerializer = JSONSerializer.extend({
742
753
  modelClass = store.modelFor(type);
743
754
  }
744
755
  }
756
+
757
+ // @ts-expect-error all the errors
745
758
  return serializer.normalize(modelClass, hash, prop);
746
759
  },
747
760
  /**
748
- @param {Store} store
749
- @param {Model} primaryModelClass
750
- @param {Object} payload
751
- @param {String|Number} id
752
- @param {String} requestType
753
- @param {Boolean} isSingle
754
- @return {Object} JSON-API Document
755
761
  @private
756
762
  */
757
763
  _normalizeResponse(store, primaryModelClass, payload, id, requestType, isSingle) {
@@ -759,20 +765,21 @@ const RESTSerializer = JSONSerializer.extend({
759
765
  data: null,
760
766
  included: []
761
767
  };
768
+ // @ts-expect-error
762
769
  const meta = this.extractMeta(store, primaryModelClass, payload);
763
770
  if (meta) {
764
771
  macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
765
772
  if (!test) {
766
773
  throw new Error('The `meta` returned from `extractMeta` has to be an object, not "' + typeof meta + '".');
767
774
  }
768
- })(typeof meta === 'object') : {};
775
+ })(typeof meta === 'object') : {}; // @ts-expect-error
769
776
  documentHash.meta = meta;
770
777
  }
771
778
  const keys = Object.keys(payload);
772
- for (var i = 0, length = keys.length; i < length; i++) {
773
- var prop = keys[i];
774
- var modelName = prop;
775
- var forcedSecondary = false;
779
+ for (let i = 0, length = keys.length; i < length; i++) {
780
+ const prop = keys[i];
781
+ let modelName = prop;
782
+ let forcedSecondary = false;
776
783
 
777
784
  /*
778
785
  If you want to provide sideloaded records of the same type that the
@@ -800,14 +807,17 @@ const RESTSerializer = JSONSerializer.extend({
800
807
  type
801
808
  })) {
802
809
  if (macroCondition(getGlobalConfig().WarpDrive.env.DEBUG)) {
810
+ // @ts-expect-error
803
811
  warn(this.warnMessageNoModelForKey(modelName, type), false, {
804
812
  id: 'ds.serializer.model-for-key-missing'
805
813
  });
806
814
  }
807
815
  continue;
808
816
  }
817
+
818
+ // eslint-disable-next-line no-var
809
819
  var isPrimary = !forcedSecondary && this.isPrimaryType(store, type, primaryModelClass);
810
- var value = payload[prop];
820
+ const value = payload[prop];
811
821
  if (value === null) {
812
822
  continue;
813
823
  }
@@ -827,6 +837,7 @@ const RESTSerializer = JSONSerializer.extend({
827
837
  ```
828
838
  */
829
839
  if (isPrimary && !Array.isArray(value)) {
840
+ // @ts-expect-error
830
841
  const {
831
842
  data,
832
843
  included
@@ -837,6 +848,7 @@ const RESTSerializer = JSONSerializer.extend({
837
848
  }
838
849
  continue;
839
850
  }
851
+ // @ts-expect-error
840
852
  const {
841
853
  data,
842
854
  included
@@ -845,6 +857,7 @@ const RESTSerializer = JSONSerializer.extend({
845
857
  documentHash.included = documentHash.included.concat(included);
846
858
  }
847
859
  if (isSingle) {
860
+ // eslint-disable-next-line @typescript-eslint/no-loop-func
848
861
  data.forEach(resource => {
849
862
  /*
850
863
  Figures out if this is the primary record or not.
@@ -858,6 +871,7 @@ const RESTSerializer = JSONSerializer.extend({
858
871
  if (isFirstCreatedRecord || isUpdatedRecord) {
859
872
  documentHash.data = resource;
860
873
  } else {
874
+ // @ts-expect-error
861
875
  documentHash.included.push(resource);
862
876
  }
863
877
  });
@@ -901,8 +915,6 @@ const RESTSerializer = JSONSerializer.extend({
901
915
  in data streaming in from your server structured the same way
902
916
  that fetches and saves are structured.
903
917
  @public
904
- @param {Store} store
905
- @param {Object} payload
906
918
  */
907
919
  pushPayload(store, payload) {
908
920
  const documentHash = {
@@ -915,6 +927,7 @@ const RESTSerializer = JSONSerializer.extend({
915
927
  type
916
928
  })) {
917
929
  if (macroCondition(getGlobalConfig().WarpDrive.env.DEBUG)) {
930
+ // @ts-expect-error
918
931
  warn(this.warnMessageNoModelForKey(prop, type), false, {
919
932
  id: 'ds.serializer.model-for-key-missing'
920
933
  });
@@ -928,6 +941,7 @@ const RESTSerializer = JSONSerializer.extend({
928
941
  data,
929
942
  included
930
943
  } = typeSerializer.normalize(ModelSchema, hash, prop);
944
+ // @ts-expect-error
931
945
  documentHash.data.push(data);
932
946
  if (included) {
933
947
  documentHash.included = documentHash.included.concat(included);
@@ -979,8 +993,7 @@ const RESTSerializer = JSONSerializer.extend({
979
993
  can use the correct inflection to do this for you. Most of the time, you won't
980
994
  need to override `modelNameFromPayloadKey` for this purpose.
981
995
  @public
982
- @param {String} key
983
- @return {String} the model's modelName
996
+ @return the model's modelName
984
997
  */
985
998
  modelNameFromPayloadKey(key) {
986
999
  return dasherize(singularize(key));
@@ -1097,11 +1110,9 @@ const RESTSerializer = JSONSerializer.extend({
1097
1110
  }
1098
1111
  ```
1099
1112
  @public
1100
- @param {Snapshot} snapshot
1101
- @param {Object} options
1102
- @return {Object} json
1103
1113
  */
1104
1114
  serialize(snapshot, options) {
1115
+ // @ts-expect-error
1105
1116
  return this._super(...arguments);
1106
1117
  },
1107
1118
  /**
@@ -1121,10 +1132,6 @@ const RESTSerializer = JSONSerializer.extend({
1121
1132
  }
1122
1133
  ```
1123
1134
  @public
1124
- @param {Object} hash
1125
- @param {Model} typeClass
1126
- @param {Snapshot} snapshot
1127
- @param {Object} options
1128
1135
  */
1129
1136
  serializeIntoHash(hash, typeClass, snapshot, options) {
1130
1137
  const normalizedRootKey = this.payloadKeyFromModelName(typeClass.modelName);
@@ -1165,8 +1172,6 @@ const RESTSerializer = JSONSerializer.extend({
1165
1172
  }
1166
1173
  ```
1167
1174
  @public
1168
- @param {String} modelName
1169
- @return {String}
1170
1175
  */
1171
1176
  payloadKeyFromModelName(modelName) {
1172
1177
  return camelize(modelName);
@@ -1176,9 +1181,6 @@ const RESTSerializer = JSONSerializer.extend({
1176
1181
  By default the REST Serializer creates the key by appending `Type` to
1177
1182
  the attribute and value from the model's camelcased model name.
1178
1183
  @public
1179
- @param {Snapshot} snapshot
1180
- @param {Object} json
1181
- @param {Object} relationship
1182
1184
  */
1183
1185
  serializePolymorphicType(snapshot, json, relationship) {
1184
1186
  const name = relationship.name;
@@ -1187,6 +1189,7 @@ const RESTSerializer = JSONSerializer.extend({
1187
1189
  if (!belongsTo) {
1188
1190
  json[typeKey] = null;
1189
1191
  } else {
1192
+ // @ts-expect-error
1190
1193
  json[typeKey] = camelize(belongsTo.modelName);
1191
1194
  }
1192
1195
  },
@@ -1200,6 +1203,7 @@ const RESTSerializer = JSONSerializer.extend({
1200
1203
  @return {Object}
1201
1204
  */
1202
1205
  extractPolymorphicRelationship(relationshipType, relationshipHash, relationshipOptions) {
1206
+ // @ts-expect-error
1203
1207
  const {
1204
1208
  key,
1205
1209
  resourceHash,
@@ -1232,6 +1236,7 @@ const RESTSerializer = JSONSerializer.extend({
1232
1236
  type: type
1233
1237
  };
1234
1238
  }
1239
+ // @ts-expect-error
1235
1240
  return this._super(...arguments);
1236
1241
  }
1237
1242
  });