@ember-data/legacy-compat 5.3.3 → 5.3.4

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 (55) hide show
  1. package/README.md +8 -0
  2. package/addon-main.cjs +5 -0
  3. package/{addon/-private-1aicprWG.js → dist/-private-DVN28hvw.js} +176 -63
  4. package/dist/-private-DVN28hvw.js.map +1 -0
  5. package/dist/-private.js +1 -0
  6. package/dist/builders.js +323 -0
  7. package/dist/builders.js.map +1 -0
  8. package/{addon → dist}/index.js +244 -72
  9. package/dist/index.js.map +1 -0
  10. package/dist/utils.js +246 -0
  11. package/dist/utils.js.map +1 -0
  12. package/package.json +53 -62
  13. package/unstable-preview-types/-private.d.ts +17 -0
  14. package/unstable-preview-types/-private.d.ts.map +1 -0
  15. package/unstable-preview-types/builders/find-all.d.ts +41 -0
  16. package/unstable-preview-types/builders/find-all.d.ts.map +1 -0
  17. package/unstable-preview-types/builders/find-record.d.ts +62 -0
  18. package/unstable-preview-types/builders/find-record.d.ts.map +1 -0
  19. package/unstable-preview-types/builders/query.d.ts +72 -0
  20. package/unstable-preview-types/builders/query.d.ts.map +1 -0
  21. package/unstable-preview-types/builders/save-record.d.ts +40 -0
  22. package/unstable-preview-types/builders/save-record.d.ts.map +1 -0
  23. package/unstable-preview-types/builders/utils.d.ts +6 -0
  24. package/unstable-preview-types/builders/utils.d.ts.map +1 -0
  25. package/unstable-preview-types/builders.d.ts +18 -0
  26. package/unstable-preview-types/builders.d.ts.map +1 -0
  27. package/unstable-preview-types/index.d.ts +162 -0
  28. package/unstable-preview-types/index.d.ts.map +1 -0
  29. package/unstable-preview-types/legacy-network-handler/fetch-manager.d.ts +49 -0
  30. package/unstable-preview-types/legacy-network-handler/fetch-manager.d.ts.map +1 -0
  31. package/unstable-preview-types/legacy-network-handler/identifier-has-id.d.ts +5 -0
  32. package/unstable-preview-types/legacy-network-handler/identifier-has-id.d.ts.map +1 -0
  33. package/unstable-preview-types/legacy-network-handler/legacy-data-fetch.d.ts +14 -0
  34. package/unstable-preview-types/legacy-network-handler/legacy-data-fetch.d.ts.map +1 -0
  35. package/unstable-preview-types/legacy-network-handler/legacy-data-utils.d.ts +8 -0
  36. package/unstable-preview-types/legacy-network-handler/legacy-data-utils.d.ts.map +1 -0
  37. package/unstable-preview-types/legacy-network-handler/legacy-network-handler.d.ts +5 -0
  38. package/unstable-preview-types/legacy-network-handler/legacy-network-handler.d.ts.map +1 -0
  39. package/unstable-preview-types/legacy-network-handler/minimum-adapter-interface.d.ts +549 -0
  40. package/unstable-preview-types/legacy-network-handler/minimum-adapter-interface.d.ts.map +1 -0
  41. package/unstable-preview-types/legacy-network-handler/minimum-serializer-interface.d.ts +235 -0
  42. package/unstable-preview-types/legacy-network-handler/minimum-serializer-interface.d.ts.map +1 -0
  43. package/unstable-preview-types/legacy-network-handler/serializer-response.d.ts +9 -0
  44. package/unstable-preview-types/legacy-network-handler/serializer-response.d.ts.map +1 -0
  45. package/unstable-preview-types/legacy-network-handler/snapshot-record-array.d.ts +96 -0
  46. package/unstable-preview-types/legacy-network-handler/snapshot-record-array.d.ts.map +1 -0
  47. package/unstable-preview-types/legacy-network-handler/snapshot.d.ts +248 -0
  48. package/unstable-preview-types/legacy-network-handler/snapshot.d.ts.map +1 -0
  49. package/unstable-preview-types/utils.d.ts +161 -0
  50. package/unstable-preview-types/utils.d.ts.map +1 -0
  51. package/addon/-private-1aicprWG.js.map +0 -1
  52. package/addon/-private.js +0 -1
  53. package/addon/index.js.map +0 -1
  54. package/addon-main.js +0 -93
  55. /package/{addon → dist}/-private.js.map +0 -0
package/README.md CHANGED
@@ -24,3 +24,11 @@ Install using your javascript package manager of choice. For instance with [pnpm
24
24
  ```no-highlight
25
25
  pnpm add @ember-data/legacy-compat
26
26
  ```
27
+
28
+ **Tagged Releases**
29
+
30
+ - ![NPM Canary Version](https://img.shields.io/npm/v/%40ember-data/legacy-compat/canary?label=%40canary&color=FFBF00)
31
+ - ![NPM Beta Version](https://img.shields.io/npm/v/%40ember-data/legacy-compat/beta?label=%40beta&color=ff00ff)
32
+ - ![NPM Stable Version](https://img.shields.io/npm/v/%40ember-data/legacy-compat/latest?label=%40latest&color=90EE90)
33
+ - ![NPM LTS Version](https://img.shields.io/npm/v/%40ember-data/legacy-compat/lts?label=%40lts&color=0096FF)
34
+ - ![NPM LTS 4.12 Version](https://img.shields.io/npm/v/%40ember-data/legacy-compat/lts-4-12?label=%40lts-4-12&color=bbbbbb)
package/addon-main.cjs ADDED
@@ -0,0 +1,5 @@
1
+ 'use strict';
2
+
3
+ const { addonShim } = require('@warp-drive/build-config/addon-shim.cjs');
4
+
5
+ module.exports = addonShim(__dirname);
@@ -1,7 +1,8 @@
1
1
  import { SOURCE, coerceId } from '@ember-data/store/-private';
2
- import { assert, warn } from '@ember/debug';
3
- import { macroCondition, getOwnConfig, importSync } from '@embroider/macros';
2
+ import { warn } from '@ember/debug';
3
+ import { macroCondition, getGlobalConfig, dependencySatisfies, importSync } from '@embroider/macros';
4
4
  import { createDeferred } from '@ember-data/request';
5
+ import { getOrSetGlobal } from '@warp-drive/core-types/-private';
5
6
 
6
7
  /**
7
8
  @module @ember-data/legacy-compat
@@ -10,7 +11,7 @@ import { createDeferred } from '@ember-data/request';
10
11
  /**
11
12
  SnapshotRecordArray is not directly instantiable.
12
13
  Instances are provided to consuming application's
13
- adapters for certain requests.
14
+ adapters for certain `findAll` requests.
14
15
 
15
16
  @class SnapshotRecordArray
16
17
  @public
@@ -149,13 +150,17 @@ class SnapshotRecordArray {
149
150
  }
150
151
  }
151
152
  function assertIdentifierHasId(identifier) {
152
- assert(`Attempted to schedule a fetch for a record without an id.`, identifier && identifier.id !== null);
153
+ macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
154
+ if (!test) {
155
+ throw new Error(`Attempted to schedule a fetch for a record without an id.`);
156
+ }
157
+ })(identifier && identifier.id !== null) : {};
153
158
  }
154
159
  function iterateData(data, fn) {
155
160
  if (Array.isArray(data)) {
156
161
  return data.map(fn);
157
162
  } else {
158
- return fn(data);
163
+ return fn(data, 0);
159
164
  }
160
165
  }
161
166
  function payloadIsNotBlank(adapterPayload) {
@@ -175,7 +180,7 @@ function payloadIsNotBlank(adapterPayload) {
175
180
  @internal
176
181
  */
177
182
  function validateDocumentStructure(doc) {
178
- if (macroCondition(getOwnConfig().env.DEBUG)) {
183
+ if (macroCondition(getGlobalConfig().WarpDrive.env.DEBUG)) {
179
184
  const errors = [];
180
185
  if (!doc || typeof doc !== 'object') {
181
186
  errors.push('Top level of a JSON API document must be an object');
@@ -218,7 +223,11 @@ function validateDocumentStructure(doc) {
218
223
  }
219
224
  }
220
225
  }
221
- assert(`Response must be normalized to a valid JSON API document:\n\t* ${errors.join('\n\t* ')}`, errors.length === 0);
226
+ macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
227
+ if (!test) {
228
+ throw new Error(`Response must be normalized to a valid JSON API document:\n\t* ${errors.join('\n\t* ')}`);
229
+ }
230
+ })(errors.length === 0) : {};
222
231
  }
223
232
  }
224
233
  function normalizeResponseHelper(serializer, store, modelClass, payload, id, requestType) {
@@ -335,7 +344,11 @@ class Snapshot {
335
344
  */
336
345
  get record() {
337
346
  const record = this._store.peekRecord(this.identifier);
338
- assert(`Record ${this.identifier.type} ${this.identifier.id} (${this.identifier.lid}) is not yet loaded and thus cannot be accessed from the Snapshot during serialization`, record !== null);
347
+ macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
348
+ if (!test) {
349
+ throw new Error(`Record ${this.identifier.type} ${this.identifier.id} (${this.identifier.lid}) is not yet loaded and thus cannot be accessed from the Snapshot during serialization`);
350
+ }
351
+ })(record !== null) : {};
339
352
  return record;
340
353
  }
341
354
  get _attributes() {
@@ -346,10 +359,12 @@ class Snapshot {
346
359
  const {
347
360
  identifier
348
361
  } = this;
349
- const attrs = Object.keys(this._store.getSchemaDefinitionService().attributesDefinitionFor(identifier));
362
+ const attrs = this._store.schema.fields(identifier);
350
363
  const cache = this._store.cache;
351
- attrs.forEach(keyName => {
352
- attributes[keyName] = cache.getAttr(identifier, keyName);
364
+ attrs.forEach((field, keyName) => {
365
+ if (field.kind === 'attribute') {
366
+ attributes[keyName] = cache.getAttr(identifier, keyName);
367
+ }
353
368
  });
354
369
  return attributes;
355
370
  }
@@ -376,7 +391,11 @@ class Snapshot {
376
391
  if (keyName in this._attributes) {
377
392
  return this._attributes[keyName];
378
393
  }
379
- assert(`Model '${this.identifier.lid}' has no attribute named '${keyName}' defined.`, false);
394
+ macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
395
+ {
396
+ throw new Error(`Model '${this.identifier.lid}' has no attribute named '${keyName}' defined.`);
397
+ }
398
+ })() : {};
380
399
  }
381
400
 
382
401
  /**
@@ -459,27 +478,35 @@ class Snapshot {
459
478
  if (returnModeIsId === false && keyName in this._belongsToRelationships) {
460
479
  return this._belongsToRelationships[keyName];
461
480
  }
462
- const relationshipMeta = store.getSchemaDefinitionService().relationshipsDefinitionFor({
481
+ const relationshipMeta = store.schema.fields({
463
482
  type: this.modelName
464
- })[keyName];
465
- assert(`Model '${this.identifier.lid}' has no belongsTo relationship named '${keyName}' defined.`, relationshipMeta && relationshipMeta.kind === 'belongsTo');
466
-
467
- // TODO @runspired it seems this code branch would not work with CUSTOM_MODEL_CLASSes
468
- // this check is not a regression in behavior because relationships don't currently
469
- // function without access to intimate API contracts between RecordData and Model.
470
- // This is a requirement we should fix as soon as the relationship layer does not require
471
- // this intimate API usage.
472
- if (macroCondition(!getOwnConfig().packages.HAS_JSON_API_PACKAGE)) {
473
- assert(`snapshot.belongsTo only supported when using the package @ember-data/json-api`);
474
- }
483
+ }).get(keyName);
484
+ macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
485
+ if (!test) {
486
+ throw new Error(`Model '${this.identifier.lid}' has no belongsTo relationship named '${keyName}' defined.`);
487
+ }
488
+ })(relationshipMeta && relationshipMeta.kind === 'belongsTo') : {};
489
+ macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
490
+ if (!test) {
491
+ throw new Error(`snapshot.belongsTo only supported when using the package @ember-data/graph`);
492
+ }
493
+ })(dependencySatisfies('@ember-data/graph', '*')) : {};
475
494
  const graphFor = importSync('@ember-data/graph/-private').graphFor;
476
495
  const {
477
496
  identifier
478
497
  } = this;
479
- if (macroCondition(getOwnConfig().env.DEBUG)) {
498
+ if (macroCondition(getGlobalConfig().WarpDrive.env.DEBUG)) {
480
499
  const relationship = graphFor(this._store).get(identifier, keyName);
481
- assert(`You looked up the ${keyName} belongsTo relationship for { type: ${identifier.type}, id: ${identifier.id || ''}, lid: ${identifier.lid} but no such relationship was found.`, relationship);
482
- assert(`You looked up the ${keyName} belongsTo relationship for { type: ${identifier.type}, id: ${identifier.id || ''}, lid: ${identifier.lid} but that relationship is a hasMany.`, relationship.definition.kind === 'belongsTo');
500
+ macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
501
+ if (!test) {
502
+ throw new Error(`You looked up the ${keyName} belongsTo relationship for { type: ${identifier.type}, id: ${identifier.id || ''}, lid: ${identifier.lid} but no such relationship was found.`);
503
+ }
504
+ })(relationship) : {};
505
+ macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
506
+ if (!test) {
507
+ throw new Error(`You looked up the ${keyName} belongsTo relationship for { type: ${identifier.type}, id: ${identifier.id || ''}, lid: ${identifier.lid} but that relationship is a hasMany.`);
508
+ }
509
+ })(relationship.definition.kind === 'belongsTo') : {};
483
510
  }
484
511
  const value = graphFor(this._store).getData(identifier, keyName);
485
512
  const data = value && value.data;
@@ -539,27 +566,41 @@ class Snapshot {
539
566
  return cachedSnapshots;
540
567
  }
541
568
  const store = this._store;
542
- const relationshipMeta = store.getSchemaDefinitionService().relationshipsDefinitionFor({
569
+ const relationshipMeta = store.schema.fields({
543
570
  type: this.modelName
544
- })[keyName];
545
- assert(`Model '${this.identifier.lid}' has no hasMany relationship named '${keyName}' defined.`, relationshipMeta && relationshipMeta.kind === 'hasMany');
571
+ }).get(keyName);
572
+ macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
573
+ if (!test) {
574
+ throw new Error(`Model '${this.identifier.lid}' has no hasMany relationship named '${keyName}' defined.`);
575
+ }
576
+ })(relationshipMeta && relationshipMeta.kind === 'hasMany') : {};
546
577
 
547
578
  // TODO @runspired it seems this code branch would not work with CUSTOM_MODEL_CLASSes
548
579
  // this check is not a regression in behavior because relationships don't currently
549
580
  // function without access to intimate API contracts between RecordData and Model.
550
581
  // This is a requirement we should fix as soon as the relationship layer does not require
551
582
  // this intimate API usage.
552
- if (macroCondition(!getOwnConfig().packages.HAS_JSON_API_PACKAGE)) {
553
- assert(`snapshot.hasMany only supported when using the package @ember-data/json-api`);
554
- }
583
+ macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
584
+ if (!test) {
585
+ throw new Error(`snapshot.hasMany only supported when using the package @ember-data/graph`);
586
+ }
587
+ })(dependencySatisfies('@ember-data/graph', '*')) : {};
555
588
  const graphFor = importSync('@ember-data/graph/-private').graphFor;
556
589
  const {
557
590
  identifier
558
591
  } = this;
559
- if (macroCondition(getOwnConfig().env.DEBUG)) {
592
+ if (macroCondition(getGlobalConfig().WarpDrive.env.DEBUG)) {
560
593
  const relationship = graphFor(this._store).get(identifier, keyName);
561
- assert(`You looked up the ${keyName} hasMany relationship for { type: ${identifier.type}, id: ${identifier.id || ''}, lid: ${identifier.lid} but no such relationship was found.`, relationship);
562
- assert(`You looked up the ${keyName} hasMany relationship for { type: ${identifier.type}, id: ${identifier.id || ''}, lid: ${identifier.lid} but that relationship is a belongsTo.`, relationship.definition.kind === 'hasMany');
594
+ macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
595
+ if (!test) {
596
+ throw new Error(`You looked up the ${keyName} hasMany relationship for { type: ${identifier.type}, id: ${identifier.id || ''}, lid: ${identifier.lid} but no such relationship was found.`);
597
+ }
598
+ })(relationship) : {};
599
+ macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
600
+ if (!test) {
601
+ throw new Error(`You looked up the ${keyName} hasMany relationship for { type: ${identifier.type}, id: ${identifier.id || ''}, lid: ${identifier.lid} but that relationship is a belongsTo.`);
602
+ }
603
+ })(relationship.definition.kind === 'hasMany') : {};
563
604
  }
564
605
  const value = graphFor(this._store).getData(identifier, keyName);
565
606
  if (value.data) {
@@ -602,9 +643,11 @@ class Snapshot {
602
643
  @public
603
644
  */
604
645
  eachAttribute(callback, binding) {
605
- const attrDefs = this._store.getSchemaDefinitionService().attributesDefinitionFor(this.identifier);
606
- Object.keys(attrDefs).forEach(key => {
607
- callback.call(binding, key, attrDefs[key]);
646
+ const fields = this._store.schema.fields(this.identifier);
647
+ fields.forEach((field, key) => {
648
+ if (field.kind === 'attribute') {
649
+ callback.call(binding, key, field);
650
+ }
608
651
  });
609
652
  }
610
653
 
@@ -623,9 +666,11 @@ class Snapshot {
623
666
  @public
624
667
  */
625
668
  eachRelationship(callback, binding) {
626
- const relationshipDefs = this._store.getSchemaDefinitionService().relationshipsDefinitionFor(this.identifier);
627
- Object.keys(relationshipDefs).forEach(key => {
628
- callback.call(binding, key, relationshipDefs[key]);
669
+ const fields = this._store.schema.fields(this.identifier);
670
+ fields.forEach((field, key) => {
671
+ if (field.kind === 'belongsTo' || field.kind === 'hasMany') {
672
+ callback.call(binding, key, field);
673
+ }
629
674
  });
630
675
  }
631
676
 
@@ -653,11 +698,15 @@ class Snapshot {
653
698
  serialize(options) {
654
699
  upgradeStore(this._store);
655
700
  const serializer = this._store.serializerFor(this.modelName);
656
- assert(`Cannot serialize record, no serializer found`, serializer);
701
+ macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
702
+ if (!test) {
703
+ throw new Error(`Cannot serialize record, no serializer found`);
704
+ }
705
+ })(serializer) : {};
657
706
  return serializer.serialize(this, options);
658
707
  }
659
708
  }
660
- const SaveOp = Symbol('SaveOp');
709
+ const SaveOp = getOrSetGlobal('SaveOp', Symbol('SaveOp'));
661
710
  class FetchManager {
662
711
  // fetches pending in the runloop, waiting to be coalesced
663
712
 
@@ -740,11 +789,15 @@ class FetchManager {
740
789
  }
741
790
  return identifier;
742
791
  }, error => {
743
- assert(`Async Leak Detected: Expected the store to not be destroyed`, !store.isDestroyed);
792
+ macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
793
+ if (!test) {
794
+ throw new Error(`Async Leak Detected: Expected the store to not be destroyed`);
795
+ }
796
+ })(!store.isDestroyed) : {};
744
797
  const cache = store.cache;
745
798
  if (!cache || cache.isEmpty(identifier) || isInitialLoad) {
746
799
  let isReleasable = true;
747
- if (macroCondition(getOwnConfig().packages.HAS_GRAPH_PACKAGE)) {
800
+ if (macroCondition(dependencySatisfies('@ember-data/graph', '*'))) {
748
801
  if (!cache) {
749
802
  const graphFor = importSync('@ember-data/graph/-private').graphFor;
750
803
  const graph = graphFor(store);
@@ -779,7 +832,7 @@ class FetchManager {
779
832
  fetchesById.set(identifier, requestsForIdentifier);
780
833
  }
781
834
  requestsForIdentifier.push(pendingFetchItem);
782
- if (macroCondition(getOwnConfig().env.TESTING)) {
835
+ if (macroCondition(getGlobalConfig().WarpDrive.env.TESTING)) {
783
836
  if (!request.disableTestWaiter) {
784
837
  const {
785
838
  waitForPromise
@@ -816,7 +869,7 @@ class FetchManager {
816
869
  let promise;
817
870
  if (isEmpty) {
818
871
  assertIdentifierHasId(identifier);
819
- if (macroCondition(getOwnConfig().env.DEBUG)) {
872
+ if (macroCondition(getGlobalConfig().WarpDrive.env.DEBUG)) {
820
873
  promise = this.scheduleFetch(identifier, Object.assign({}, options, {
821
874
  reload: true
822
875
  }), request);
@@ -826,7 +879,11 @@ class FetchManager {
826
879
  }
827
880
  } else if (isLoading) {
828
881
  promise = this.getPendingFetch(identifier, options);
829
- assert(`Expected to find a pending request for a record in the loading state, but found none`, promise);
882
+ macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
883
+ if (!test) {
884
+ throw new Error(`Expected to find a pending request for a record in the loading state, but found none`);
885
+ }
886
+ })(promise) : {};
830
887
  } else {
831
888
  promise = Promise.resolve(identifier);
832
889
  }
@@ -894,15 +951,31 @@ function _findMany(store, adapter, modelName, snapshots) {
894
951
  const modelClass = store.modelFor(modelName); // `adapter.findMany` gets the modelClass still
895
952
  const promise = Promise.resolve().then(() => {
896
953
  const ids = snapshots.map(s => s.id);
897
- assert(`Cannot fetch a record without an id`, ids.every(v => v !== null));
954
+ macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
955
+ if (!test) {
956
+ throw new Error(`Cannot fetch a record without an id`);
957
+ }
958
+ })(ids.every(v => v !== null)) : {};
898
959
  // eslint-disable-next-line @typescript-eslint/unbound-method
899
- assert(`Expected this adapter to implement findMany for coalescing`, adapter.findMany);
960
+ macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
961
+ if (!test) {
962
+ throw new Error(`Expected this adapter to implement findMany for coalescing`);
963
+ }
964
+ })(adapter.findMany) : {};
900
965
  const ret = adapter.findMany(store, modelClass, ids, snapshots);
901
- assert('adapter.findMany returned undefined, this was very likely a mistake', ret !== undefined);
966
+ macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
967
+ if (!test) {
968
+ throw new Error('adapter.findMany returned undefined, this was very likely a mistake');
969
+ }
970
+ })(ret !== undefined) : {};
902
971
  return ret;
903
972
  });
904
973
  return promise.then(adapterPayload => {
905
- assert(`You made a 'findMany' request for '${modelName}' records with ids '[${snapshots.map(s => s.id).join(',')}]', but the adapter's response did not have any data`, !!payloadIsNotBlank(adapterPayload));
974
+ macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
975
+ if (!test) {
976
+ throw new Error(`You made a 'findMany' request for '${modelName}' records with ids '[${snapshots.map(s => s.id).join(',')}]', but the adapter's response did not have any data`);
977
+ }
978
+ })(!!payloadIsNotBlank(adapterPayload)) : {};
906
979
  const serializer = store.serializerFor(modelName);
907
980
  const payload = normalizeResponseHelper(serializer, store, modelClass, adapterPayload, null, 'findMany');
908
981
  return payload;
@@ -981,8 +1054,16 @@ function handleFoundRecords(store, fetchMap, snapshots, coalescedPayload) {
981
1054
  function _fetchRecord(store, adapter, fetchItem) {
982
1055
  const identifier = fetchItem.identifier;
983
1056
  const modelName = identifier.type;
984
- assert(`You tried to find a record but you have no adapter (for ${modelName})`, adapter);
985
- assert(`You tried to find a record but your adapter (for ${modelName}) does not implement 'findRecord'`, typeof adapter.findRecord === 'function');
1057
+ macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
1058
+ if (!test) {
1059
+ throw new Error(`You tried to find a record but you have no adapter (for ${modelName})`);
1060
+ }
1061
+ })(adapter) : {};
1062
+ macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
1063
+ if (!test) {
1064
+ throw new Error(`You tried to find a record but your adapter (for ${modelName}) does not implement 'findRecord'`);
1065
+ }
1066
+ })(typeof adapter.findRecord === 'function') : {};
986
1067
  const snapshot = store._fetchManager.createSnapshot(identifier, fetchItem.options);
987
1068
  const klass = store.modelFor(identifier.type);
988
1069
  const id = identifier.id;
@@ -990,12 +1071,28 @@ function _fetchRecord(store, adapter, fetchItem) {
990
1071
  return adapter.findRecord(store, klass, identifier.id, snapshot);
991
1072
  });
992
1073
  promise = promise.then(adapterPayload => {
993
- assert(`Async Leak Detected: Expected the store to not be destroyed`, !(store.isDestroyed || store.isDestroying));
994
- assert(`You made a 'findRecord' request for a '${modelName}' with id '${id}', but the adapter's response did not have any data`, !!payloadIsNotBlank(adapterPayload));
1074
+ macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
1075
+ if (!test) {
1076
+ throw new Error(`Async Leak Detected: Expected the store to not be destroyed`);
1077
+ }
1078
+ })(!(store.isDestroyed || store.isDestroying)) : {};
1079
+ macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
1080
+ if (!test) {
1081
+ throw new Error(`You made a 'findRecord' request for a '${modelName}' with id '${id}', but the adapter's response did not have any data`);
1082
+ }
1083
+ })(!!payloadIsNotBlank(adapterPayload)) : {};
995
1084
  const serializer = store.serializerFor(modelName);
996
1085
  const payload = normalizeResponseHelper(serializer, store, klass, adapterPayload, id, 'findRecord');
997
- assert(`Ember Data expected the primary data returned from a 'findRecord' response to be an object but instead it found an array.`, !Array.isArray(payload.data));
998
- assert(`The 'findRecord' request for ${modelName}:${id} resolved indicating success but contained no primary data. To indicate a 404 not found you should either reject the promise returned by the adapter's findRecord method or throw a NotFoundError.`, 'data' in payload && payload.data !== null && typeof payload.data === 'object');
1086
+ macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
1087
+ if (!test) {
1088
+ throw new Error(`Ember Data expected the primary data returned from a 'findRecord' response to be an object but instead it found an array.`);
1089
+ }
1090
+ })(!Array.isArray(payload.data)) : {};
1091
+ macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
1092
+ if (!test) {
1093
+ throw new Error(`The 'findRecord' request for ${modelName}:${id} resolved indicating success but contained no primary data. To indicate a 404 not found you should either reject the promise returned by the adapter's findRecord method or throw a NotFoundError.`);
1094
+ }
1095
+ })('data' in payload && payload.data !== null && typeof payload.data === 'object') : {};
999
1096
  warn(`You requested a record of type '${modelName}' with id '${id}' but the adapter returned a payload with primary data having an id of '${payload.data.id}'. Use 'store.findRecord()' when the requested id is the same as the one returned by the adapter. In other cases use 'store.queryRecord()' instead.`, coerceId(payload.data.id) === coerceId(id), {
1000
1097
  id: 'ds.store.findRecord.id-mismatch'
1001
1098
  });
@@ -1013,7 +1110,11 @@ function _processCoalescedGroup(store, fetchMap, group, adapter, modelName) {
1013
1110
  } else if (group.length === 1) {
1014
1111
  _fetchRecord(store, adapter, fetchMap.get(group[0]));
1015
1112
  } else {
1016
- assert("You cannot return an empty array from adapter's method groupRecordsForFindMany", false);
1113
+ macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
1114
+ {
1115
+ throw new Error("You cannot return an empty array from adapter's method groupRecordsForFindMany");
1116
+ }
1117
+ })() : {};
1017
1118
  }
1018
1119
  }
1019
1120
  function _flushPendingFetchForType(store, pendingFetchMap, modelName) {
@@ -1069,11 +1170,23 @@ function _flushPendingSave(store, pending) {
1069
1170
  const operation = options[SaveOp];
1070
1171
  const modelName = snapshot.modelName;
1071
1172
  const modelClass = store.modelFor(modelName);
1072
- assert(`You tried to update a record but you have no adapter (for ${modelName})`, adapter);
1073
- assert(`You tried to update a record but your adapter (for ${modelName}) does not implement '${operation}'`, typeof adapter[operation] === 'function');
1173
+ macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
1174
+ if (!test) {
1175
+ throw new Error(`You tried to update a record but you have no adapter (for ${modelName})`);
1176
+ }
1177
+ })(adapter) : {};
1178
+ macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
1179
+ if (!test) {
1180
+ throw new Error(`You tried to update a record but your adapter (for ${modelName}) does not implement '${operation}'`);
1181
+ }
1182
+ })(typeof adapter[operation] === 'function') : {};
1074
1183
  let promise = Promise.resolve().then(() => adapter[operation](store, modelClass, snapshot));
1075
1184
  const serializer = store.serializerFor(modelName);
1076
- assert(`Your adapter's '${operation}' method must return a value, but it returned 'undefined'`, promise !== undefined);
1185
+ macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
1186
+ if (!test) {
1187
+ throw new Error(`Your adapter's '${operation}' method must return a value, but it returned 'undefined'`);
1188
+ }
1189
+ })(promise !== undefined) : {};
1077
1190
  promise = promise.then(adapterPayload => {
1078
1191
  if (adapterPayload) {
1079
1192
  return normalizeResponseHelper(serializer, store, modelClass, adapterPayload, snapshot.id, operation);