@ember-data/model 5.4.0-beta.2 → 5.4.0-beta.21

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 (106) hide show
  1. package/LICENSE.md +19 -7
  2. package/README.md +21 -2
  3. package/addon-main.cjs +5 -0
  4. package/blueprints/model/index.js +18 -5
  5. package/blueprints/model-test/index.js +16 -10
  6. package/blueprints/model-test/qunit-files/__root__/__path__/__test__.js +4 -5
  7. package/dist/-private.js +3 -0
  8. package/{addon → dist}/-private.js.map +1 -1
  9. package/dist/has-many-DT3JBYYG.js +674 -0
  10. package/dist/has-many-DT3JBYYG.js.map +1 -0
  11. package/dist/hooks-CNY5g4Ab.js +75 -0
  12. package/dist/hooks-CNY5g4Ab.js.map +1 -0
  13. package/dist/hooks.js +2 -0
  14. package/{addon → dist}/hooks.js.map +1 -1
  15. package/dist/index.js +5 -0
  16. package/{addon → dist}/index.js.map +1 -1
  17. package/dist/migration-support.js +213 -0
  18. package/dist/migration-support.js.map +1 -0
  19. package/{addon/model-YsOraZ6y.js → dist/model-rk3atPqV.js} +899 -936
  20. package/dist/model-rk3atPqV.js.map +1 -0
  21. package/dist/schema-provider-Bvogtzx9.js +259 -0
  22. package/dist/schema-provider-Bvogtzx9.js.map +1 -0
  23. package/logos/NCC-1701-a-blue.svg +4 -0
  24. package/logos/NCC-1701-a-gold.svg +4 -0
  25. package/logos/NCC-1701-a-gold_100.svg +1 -0
  26. package/logos/NCC-1701-a-gold_base-64.txt +1 -0
  27. package/logos/NCC-1701-a.svg +4 -0
  28. package/logos/README.md +4 -0
  29. package/logos/docs-badge.svg +2 -0
  30. package/logos/ember-data-logo-dark.svg +12 -0
  31. package/logos/ember-data-logo-light.svg +12 -0
  32. package/logos/github-header.svg +444 -0
  33. package/logos/social1.png +0 -0
  34. package/logos/social2.png +0 -0
  35. package/logos/warp-drive-logo-dark.svg +4 -0
  36. package/logos/warp-drive-logo-gold.svg +4 -0
  37. package/package.json +58 -103
  38. package/unstable-preview-types/-private/attr.d.ts +175 -0
  39. package/unstable-preview-types/-private/attr.d.ts.map +1 -0
  40. package/unstable-preview-types/-private/attr.type-test.d.ts +4 -0
  41. package/unstable-preview-types/-private/attr.type-test.d.ts.map +1 -0
  42. package/unstable-preview-types/-private/belongs-to.d.ts +181 -0
  43. package/unstable-preview-types/-private/belongs-to.d.ts.map +1 -0
  44. package/unstable-preview-types/-private/belongs-to.type-test.d.ts +4 -0
  45. package/unstable-preview-types/-private/belongs-to.type-test.d.ts.map +1 -0
  46. package/unstable-preview-types/-private/debug/assert-polymorphic-type.d.ts +8 -0
  47. package/unstable-preview-types/-private/debug/assert-polymorphic-type.d.ts.map +1 -0
  48. package/unstable-preview-types/-private/errors.d.ts +303 -0
  49. package/unstable-preview-types/-private/errors.d.ts.map +1 -0
  50. package/unstable-preview-types/-private/has-many.d.ts +169 -0
  51. package/unstable-preview-types/-private/has-many.d.ts.map +1 -0
  52. package/unstable-preview-types/-private/has-many.type-test.d.ts +4 -0
  53. package/unstable-preview-types/-private/has-many.type-test.d.ts.map +1 -0
  54. package/unstable-preview-types/-private/hooks.d.ts +13 -0
  55. package/unstable-preview-types/-private/hooks.d.ts.map +1 -0
  56. package/unstable-preview-types/-private/legacy-relationships-support.d.ts +60 -0
  57. package/unstable-preview-types/-private/legacy-relationships-support.d.ts.map +1 -0
  58. package/unstable-preview-types/-private/model-for-mixin.d.ts +6 -0
  59. package/unstable-preview-types/-private/model-for-mixin.d.ts.map +1 -0
  60. package/unstable-preview-types/-private/model-methods.d.ts +37 -0
  61. package/unstable-preview-types/-private/model-methods.d.ts.map +1 -0
  62. package/unstable-preview-types/-private/model.d.ts +1303 -0
  63. package/unstable-preview-types/-private/model.d.ts.map +1 -0
  64. package/unstable-preview-types/-private/model.type-test.d.ts +4 -0
  65. package/unstable-preview-types/-private/model.type-test.d.ts.map +1 -0
  66. package/unstable-preview-types/-private/notify-changes.d.ts +8 -0
  67. package/unstable-preview-types/-private/notify-changes.d.ts.map +1 -0
  68. package/unstable-preview-types/-private/promise-belongs-to.d.ts +46 -0
  69. package/unstable-preview-types/-private/promise-belongs-to.d.ts.map +1 -0
  70. package/unstable-preview-types/-private/promise-many-array.d.ts +131 -0
  71. package/unstable-preview-types/-private/promise-many-array.d.ts.map +1 -0
  72. package/unstable-preview-types/-private/promise-proxy-base.d.ts +5 -0
  73. package/unstable-preview-types/-private/promise-proxy-base.d.ts.map +1 -0
  74. package/unstable-preview-types/-private/record-state.d.ts +80 -0
  75. package/unstable-preview-types/-private/record-state.d.ts.map +1 -0
  76. package/unstable-preview-types/-private/references/belongs-to.d.ts +503 -0
  77. package/unstable-preview-types/-private/references/belongs-to.d.ts.map +1 -0
  78. package/unstable-preview-types/-private/references/has-many.d.ts +515 -0
  79. package/unstable-preview-types/-private/references/has-many.d.ts.map +1 -0
  80. package/unstable-preview-types/-private/schema-provider.d.ts +65 -0
  81. package/unstable-preview-types/-private/schema-provider.d.ts.map +1 -0
  82. package/unstable-preview-types/-private/type-utils.d.ts +64 -0
  83. package/unstable-preview-types/-private/type-utils.d.ts.map +1 -0
  84. package/unstable-preview-types/-private/util.d.ts +8 -0
  85. package/unstable-preview-types/-private/util.d.ts.map +1 -0
  86. package/unstable-preview-types/-private.d.ts +13 -0
  87. package/unstable-preview-types/-private.d.ts.map +1 -0
  88. package/unstable-preview-types/hooks.d.ts +5 -0
  89. package/unstable-preview-types/hooks.d.ts.map +1 -0
  90. package/unstable-preview-types/index.d.ts +76 -0
  91. package/unstable-preview-types/index.d.ts.map +1 -0
  92. package/unstable-preview-types/migration-support.d.ts +64 -0
  93. package/unstable-preview-types/migration-support.d.ts.map +1 -0
  94. package/addon/-private.js +0 -2
  95. package/addon/has-many-PdQBns8a.js +0 -323
  96. package/addon/has-many-PdQBns8a.js.map +0 -1
  97. package/addon/hooks-dXmQbIOF.js +0 -176
  98. package/addon/hooks-dXmQbIOF.js.map +0 -1
  99. package/addon/hooks.js +0 -1
  100. package/addon/index.js +0 -3
  101. package/addon/migration-support.js +0 -118
  102. package/addon/migration-support.js.map +0 -1
  103. package/addon/model-YsOraZ6y.js.map +0 -1
  104. package/addon/util-3DHZJC9h.js +0 -38
  105. package/addon/util-3DHZJC9h.js.map +0 -1
  106. package/addon-main.js +0 -93
Binary file
Binary file
@@ -0,0 +1,4 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 324 32">
2
+ <path fill="#110819"
3
+ d="M321.58 29.54a41.7 41.7 0 0 1-7.26 1.72c-2.4.36-4.87.53-7.4.53-3.21 0-6.09-.34-8.6-1.03a18.5 18.5 0 0 1-6.34-3.03 13.07 13.07 0 0 1-3.94-4.83c-.9-1.9-1.35-4.06-1.35-6.47a14.32 14.32 0 0 1 5.22-11.19 18.14 18.14 0 0 1 6.06-3.3c2.36-.81 5-1.21 7.9-1.21 2.68 0 5.13.36 7.35 1.1 2.24.71 4.15 1.78 5.74 3.2a14.28 14.28 0 0 1 3.72 5.24 18.12 18.12 0 0 1 1.33 7.17v1.98h-29.1a7.5 7.5 0 0 0 1.28 2.56c.6.77 1.4 1.43 2.42 1.97 1.02.55 2.27.97 3.74 1.27 1.5.3 3.27.45 5.33.45a35.35 35.35 0 0 0 8.23-.96c1.22-.3 2.31-.64 3.29-1 .99-.35 1.78-.7 2.38-1.07v6.9Zm-5.5-15.96a6.73 6.73 0 0 0-.66-2.26 5.82 5.82 0 0 0-1.72-2.13 9.46 9.46 0 0 0-3.1-1.54 15.6 15.6 0 0 0-4.77-.63c-1.79 0-3.33.23-4.64.67-1.3.44-2.4 1-3.29 1.65a8.37 8.37 0 0 0-2.04 2.13c-.48.76-.8 1.46-.94 2.1h21.16ZM271.84 31h-9.28L247.63 1.48h8.9l10.74 22.22 10.72-22.22h8.9L271.83 31ZM234.8 31V1.48h7.97V31h-7.97ZM229.73 8.16l-.94-.28c-.4-.13-.88-.25-1.42-.36a17.88 17.88 0 0 0-3.8-.45c-1.44 0-2.78.18-4.02.53-1.23.35-2.39.81-3.46 1.4a19.48 19.48 0 0 0-3 1.98c-.92.73-1.77 1.48-2.54 2.25V31h-7.97V1.48h7.97v4.8c.96-.72 1.94-1.41 2.94-2.07a25.36 25.36 0 0 1 3.16-1.78 18.9 18.9 0 0 1 3.48-1.23 15.39 15.39 0 0 1 5.44-.39 25 25 0 0 1 4.16.67v6.68ZM197.05 16.22c0 1.89-.2 3.57-.62 5.05a12.7 12.7 0 0 1-1.76 3.82 11.07 11.07 0 0 1-2.7 2.77 13.77 13.77 0 0 1-3.51 1.83c-1.29.46-2.68.8-4.17 1-1.49.21-3.04.31-4.66.31H160.9V1.48h18.69c1.62 0 3.17.1 4.66.32 1.49.2 2.88.53 4.17 1 1.3.45 2.48 1.06 3.54 1.82 1.06.74 1.96 1.67 2.7 2.77a12.7 12.7 0 0 1 1.77 3.82c.42 1.46.62 3.13.62 5Zm-8.03 0c0-1.42-.19-2.65-.56-3.7a5.64 5.64 0 0 0-1.76-2.57 7.66 7.66 0 0 0-3.16-1.53c-1.3-.34-2.9-.52-4.77-.52h-9.9v16.68h9.9c1.88 0 3.47-.17 4.77-.5a7.86 7.86 0 0 0 3.16-1.54c.81-.7 1.4-1.58 1.76-2.63.37-1.04.56-2.27.56-3.7ZM153.98 10.55c0 1.47-.25 2.78-.73 3.9a6.82 6.82 0 0 1-2.26 2.86 10.95 10.95 0 0 1-4 1.77 25.6 25.6 0 0 1-5.86.58h-13.26V31h-2.68V1.48h15.94c2.3 0 4.25.2 5.87.6 1.63.39 2.96.96 4 1.72a6.67 6.67 0 0 1 2.25 2.84c.48 1.13.73 2.43.73 3.9Zm-2.77 0c0-1.4-.24-2.54-.71-3.4a4.53 4.53 0 0 0-2.15-1.97c-.96-.48-2.19-.8-3.68-.95a50.43 50.43 0 0 0-5.26-.24h-11.54v13.15h11.54l2.51.02c.9 0 1.8-.04 2.67-.12.87-.1 1.7-.27 2.5-.5.8-.24 1.5-.6 2.1-1.1a5.05 5.05 0 0 0 1.46-1.9 7 7 0 0 0 .56-3ZM119.76 3.76c-.41-.13-1-.27-1.74-.41-.73-.16-1.67-.24-2.83-.24-1.6 0-3.12.2-4.54.6a17.94 17.94 0 0 0-7.28 3.96 23.73 23.73 0 0 0-2.8 2.83V31H97.9V1.48h2.69V7.5c.96-1 2-1.9 3.11-2.73a21.54 21.54 0 0 1 7.48-3.53 17.47 17.47 0 0 1 5.6-.47c.4.02.77.04 1.1.09a16.6 16.6 0 0 1 1.9.26v2.64ZM85.52 31v-3.27c-1.03.56-2.2 1.08-3.53 1.55a40.4 40.4 0 0 1-13.13 2.3c-1.91 0-3.64-.17-5.17-.52a12.2 12.2 0 0 1-3.87-1.52A7.38 7.38 0 0 1 57.37 27a7.06 7.06 0 0 1-.86-3.52c0-1.32.33-2.48 1-3.48a8.81 8.81 0 0 1 2.85-2.64c1.23-.76 2.71-1.4 4.45-1.91 1.74-.53 3.7-.98 5.84-1.34 2.15-.37 4.47-.67 6.96-.9 2.5-.24 5.14-.44 7.9-.6v-2.26c0-.91-.16-1.72-.5-2.42a5.54 5.54 0 0 0-1.45-1.83 7.97 7.97 0 0 0-2.17-1.31c-.83-.36-1.73-.65-2.7-.86a33.97 33.97 0 0 0-13.54.21c-1.03.25-2.02.53-2.96.86-.95.33-1.9.68-2.86 1.06V2.92c1.99-.53 4.1-.99 6.36-1.38 2.26-.4 4.66-.6 7.2-.6 2.14 0 4.15.19 6.01.56 1.86.36 3.48.94 4.86 1.74A9.16 9.16 0 0 1 87 6.36a8.55 8.55 0 0 1 1.18 4.62V31h-2.66Zm0-16c-4.69.25-8.69.62-12.01 1.09-3.31.47-6.02 1.05-8.12 1.74-2.1.69-3.66 1.49-4.64 2.4a4.18 4.18 0 0 0-1.46 3.12c0 .95.23 1.78.7 2.52a5.86 5.86 0 0 0 2.09 1.84c.9.49 2 .86 3.29 1.12 1.28.24 2.73.37 4.34.37a29.36 29.36 0 0 0 5.95-.6 36.6 36.6 0 0 0 5.71-1.57c.86-.32 1.64-.66 2.34-1.01a11.3 11.3 0 0 0 1.8-1.1v-9.93ZM28.65 1.48l10.53 27.37L50.09 1.48h2.99L41.2 31h-4L26.84 4.34 16.51 31h-4L.63 1.48h2.99l10.91 27.37 10.5-27.37h3.62Z" />
4
+ </svg>
@@ -0,0 +1,4 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 324 32">
2
+ <path fill="#FFC474"
3
+ d="M321.58 29.54a41.7 41.7 0 0 1-7.26 1.72c-2.4.36-4.87.53-7.4.53-3.21 0-6.09-.34-8.6-1.03a18.5 18.5 0 0 1-6.34-3.03 13.07 13.07 0 0 1-3.94-4.83c-.9-1.9-1.35-4.06-1.35-6.47a14.32 14.32 0 0 1 5.22-11.19 18.14 18.14 0 0 1 6.06-3.3c2.36-.81 5-1.21 7.9-1.21 2.68 0 5.13.36 7.35 1.1 2.24.71 4.15 1.78 5.74 3.2a14.28 14.28 0 0 1 3.72 5.24 18.12 18.12 0 0 1 1.33 7.17v1.98h-29.1a7.5 7.5 0 0 0 1.28 2.56c.6.77 1.4 1.43 2.42 1.97 1.02.55 2.27.97 3.74 1.27 1.5.3 3.27.45 5.33.45a35.35 35.35 0 0 0 8.23-.96c1.22-.3 2.31-.64 3.29-1 .99-.35 1.78-.7 2.38-1.07v6.9Zm-5.5-15.96a6.73 6.73 0 0 0-.66-2.26 5.82 5.82 0 0 0-1.72-2.13 9.46 9.46 0 0 0-3.1-1.54 15.6 15.6 0 0 0-4.77-.63c-1.79 0-3.33.23-4.64.67-1.3.44-2.4 1-3.29 1.65a8.37 8.37 0 0 0-2.04 2.13c-.48.76-.8 1.46-.94 2.1h21.16ZM271.84 31h-9.28L247.63 1.48h8.9l10.74 22.22 10.72-22.22h8.9L271.83 31ZM234.8 31V1.48h7.97V31h-7.97ZM229.73 8.16l-.94-.28c-.4-.13-.88-.25-1.42-.36a17.88 17.88 0 0 0-3.8-.45c-1.44 0-2.78.18-4.02.53-1.23.35-2.39.81-3.46 1.4a19.48 19.48 0 0 0-3 1.98c-.92.73-1.77 1.48-2.54 2.25V31h-7.97V1.48h7.97v4.8c.96-.72 1.94-1.41 2.94-2.07a25.36 25.36 0 0 1 3.16-1.78 18.9 18.9 0 0 1 3.48-1.23 15.39 15.39 0 0 1 5.44-.39 25 25 0 0 1 4.16.67v6.68ZM197.05 16.22c0 1.89-.2 3.57-.62 5.05a12.7 12.7 0 0 1-1.76 3.82 11.07 11.07 0 0 1-2.7 2.77 13.77 13.77 0 0 1-3.51 1.83c-1.29.46-2.68.8-4.17 1-1.49.21-3.04.31-4.66.31H160.9V1.48h18.69c1.62 0 3.17.1 4.66.32 1.49.2 2.88.53 4.17 1 1.3.45 2.48 1.06 3.54 1.82 1.06.74 1.96 1.67 2.7 2.77a12.7 12.7 0 0 1 1.77 3.82c.42 1.46.62 3.13.62 5Zm-8.03 0c0-1.42-.19-2.65-.56-3.7a5.64 5.64 0 0 0-1.76-2.57 7.66 7.66 0 0 0-3.16-1.53c-1.3-.34-2.9-.52-4.77-.52h-9.9v16.68h9.9c1.88 0 3.47-.17 4.77-.5a7.86 7.86 0 0 0 3.16-1.54c.81-.7 1.4-1.58 1.76-2.63.37-1.04.56-2.27.56-3.7ZM153.98 10.55c0 1.47-.25 2.78-.73 3.9a6.82 6.82 0 0 1-2.26 2.86 10.95 10.95 0 0 1-4 1.77 25.6 25.6 0 0 1-5.86.58h-13.26V31h-2.68V1.48h15.94c2.3 0 4.25.2 5.87.6 1.63.39 2.96.96 4 1.72a6.67 6.67 0 0 1 2.25 2.84c.48 1.13.73 2.43.73 3.9Zm-2.77 0c0-1.4-.24-2.54-.71-3.4a4.53 4.53 0 0 0-2.15-1.97c-.96-.48-2.19-.8-3.68-.95a50.43 50.43 0 0 0-5.26-.24h-11.54v13.15h11.54l2.51.02c.9 0 1.8-.04 2.67-.12.87-.1 1.7-.27 2.5-.5.8-.24 1.5-.6 2.1-1.1a5.05 5.05 0 0 0 1.46-1.9 7 7 0 0 0 .56-3ZM119.76 3.76c-.41-.13-1-.27-1.74-.41-.73-.16-1.67-.24-2.83-.24-1.6 0-3.12.2-4.54.6a17.94 17.94 0 0 0-7.28 3.96 23.73 23.73 0 0 0-2.8 2.83V31H97.9V1.48h2.69V7.5c.96-1 2-1.9 3.11-2.73a21.54 21.54 0 0 1 7.48-3.53 17.47 17.47 0 0 1 5.6-.47c.4.02.77.04 1.1.09a16.6 16.6 0 0 1 1.9.26v2.64ZM85.52 31v-3.27c-1.03.56-2.2 1.08-3.53 1.55a40.4 40.4 0 0 1-13.13 2.3c-1.91 0-3.64-.17-5.17-.52a12.2 12.2 0 0 1-3.87-1.52A7.38 7.38 0 0 1 57.37 27a7.06 7.06 0 0 1-.86-3.52c0-1.32.33-2.48 1-3.48a8.81 8.81 0 0 1 2.85-2.64c1.23-.76 2.71-1.4 4.45-1.91 1.74-.53 3.7-.98 5.84-1.34 2.15-.37 4.47-.67 6.96-.9 2.5-.24 5.14-.44 7.9-.6v-2.26c0-.91-.16-1.72-.5-2.42a5.54 5.54 0 0 0-1.45-1.83 7.97 7.97 0 0 0-2.17-1.31c-.83-.36-1.73-.65-2.7-.86a33.97 33.97 0 0 0-13.54.21c-1.03.25-2.02.53-2.96.86-.95.33-1.9.68-2.86 1.06V2.92c1.99-.53 4.1-.99 6.36-1.38 2.26-.4 4.66-.6 7.2-.6 2.14 0 4.15.19 6.01.56 1.86.36 3.48.94 4.86 1.74A9.16 9.16 0 0 1 87 6.36a8.55 8.55 0 0 1 1.18 4.62V31h-2.66Zm0-16c-4.69.25-8.69.62-12.01 1.09-3.31.47-6.02 1.05-8.12 1.74-2.1.69-3.66 1.49-4.64 2.4a4.18 4.18 0 0 0-1.46 3.12c0 .95.23 1.78.7 2.52a5.86 5.86 0 0 0 2.09 1.84c.9.49 2 .86 3.29 1.12 1.28.24 2.73.37 4.34.37a29.36 29.36 0 0 0 5.95-.6 36.6 36.6 0 0 0 5.71-1.57c.86-.32 1.64-.66 2.34-1.01a11.3 11.3 0 0 0 1.8-1.1v-9.93ZM28.65 1.48l10.53 27.37L50.09 1.48h2.99L41.2 31h-4L26.84 4.34 16.51 31h-4L.63 1.48h2.99l10.91 27.37 10.5-27.37h3.62Z" />
4
+ </svg>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ember-data/model",
3
- "version": "5.4.0-beta.2",
3
+ "version": "5.4.0-beta.21",
4
4
  "description": "A basic Ember implementation of a resource presentation layer for use with @ember-data/store",
5
5
  "keywords": [
6
6
  "ember-addon"
@@ -14,37 +14,42 @@
14
14
  "author": "",
15
15
  "directories": {},
16
16
  "ember-addon": {
17
- "main": "addon-main.js",
17
+ "main": "addon-main.cjs",
18
18
  "type": "addon",
19
- "version": 1
19
+ "version": 2
20
20
  },
21
21
  "files": [
22
+ "unstable-preview-types",
22
23
  "blueprints",
23
- "addon-main.js",
24
- "addon",
24
+ "addon-main.cjs",
25
+ "dist",
25
26
  "README.md",
26
27
  "LICENSE.md",
27
- "ember-data-logo-dark.svg",
28
- "ember-data-logo-light.svg"
28
+ "logos"
29
29
  ],
30
30
  "exports": {
31
31
  ".": {
32
- "default": "./addon/index.js"
32
+ "default": "./dist/index.js"
33
+ },
34
+ "./blueprints/*": {
35
+ "default": "./blueprints/*.js"
33
36
  },
34
37
  "./*": {
35
- "default": "./addon/*.js"
38
+ "default": "./dist/*.js"
39
+ },
40
+ "./unstable-preview-types": {
41
+ "types": "./unstable-preview-types/index.d.ts"
36
42
  }
37
43
  },
38
44
  "peerDependencies": {
39
- "@ember-data/debug": "5.4.0-beta.2",
40
- "@ember-data/graph": "5.4.0-beta.2",
41
- "@ember-data/json-api": "5.4.0-beta.2",
42
- "@ember-data/legacy-compat": "5.4.0-beta.2",
43
- "@ember-data/store": "5.4.0-beta.2",
44
- "@ember-data/tracking": "5.4.0-beta.2",
45
- "@ember/string": "^3.1.1",
46
- "@warp-drive/core-types": "0.0.0-beta.2",
47
- "ember-inflector": "^4.0.2"
45
+ "ember-source": "3.28.12 || ^4.0.4 || ^5.0.0 || ^6.0.0",
46
+ "@ember-data/graph": "5.4.0-beta.21",
47
+ "@ember-data/json-api": "5.4.0-beta.21",
48
+ "@ember-data/legacy-compat": "5.4.0-beta.21",
49
+ "@ember-data/store": "5.4.0-beta.21",
50
+ "@ember-data/tracking": "5.4.0-beta.21",
51
+ "@ember-data/request-utils": "5.4.0-beta.21",
52
+ "@warp-drive/core-types": "0.0.0-beta.21"
48
53
  },
49
54
  "peerDependenciesMeta": {
50
55
  "@ember-data/json-api": {
@@ -52,105 +57,55 @@
52
57
  },
53
58
  "@ember-data/graph": {
54
59
  "optional": true
55
- },
56
- "@ember-data/debug": {
57
- "optional": true
58
- }
59
- },
60
- "dependenciesMeta": {
61
- "@ember-data/private-build-infra": {
62
- "injected": true
63
- },
64
- "@ember-data/store": {
65
- "injected": true
66
- },
67
- "@ember-data/tracking": {
68
- "injected": true
69
- },
70
- "@ember-data/graph": {
71
- "injected": true
72
- },
73
- "@ember-data/json-api": {
74
- "injected": true
75
- },
76
- "@ember-data/legacy-compat": {
77
- "injected": true
78
- },
79
- "@ember-data/debug": {
80
- "injected": true
81
- },
82
- "@warp-drive/core-types": {
83
- "injected": true
84
- },
85
- "@ember/string": {
86
- "injected": true
87
- },
88
- "ember-inflector": {
89
- "injected": true
90
- },
91
- "@ember-data/request": {
92
- "injected": true
93
- },
94
- "@ember-data/request-utils": {
95
- "injected": true
96
60
  }
97
61
  },
98
62
  "dependencies": {
99
- "@ember-data/private-build-infra": "5.4.0-beta.2",
100
63
  "@ember/edition-utils": "^1.2.0",
101
- "@embroider/macros": "^1.13.4",
102
- "ember-cli-babel": "^8.2.0",
64
+ "@embroider/macros": "^1.16.12",
103
65
  "ember-cli-string-utils": "^1.1.0",
104
66
  "ember-cli-test-info": "^1.0.0",
105
- "inflection": "~3.0.0",
106
- "pnpm-sync-dependencies-meta-injected": "0.0.10"
67
+ "inflection": "~3.0.2",
68
+ "@warp-drive/build-config": "0.0.0-beta.16"
107
69
  },
108
70
  "devDependencies": {
109
- "@babel/cli": "^7.23.4",
110
- "@babel/core": "^7.23.7",
111
- "@babel/plugin-proposal-decorators": "^7.23.7",
112
- "@babel/plugin-transform-class-properties": "^7.23.3",
113
- "@babel/plugin-transform-private-methods": "^7.23.3",
114
- "@babel/plugin-transform-runtime": "^7.23.7",
115
- "@babel/plugin-transform-typescript": "^7.23.6",
116
- "@babel/preset-env": "^7.23.8",
117
- "@babel/preset-typescript": "^7.23.3",
118
- "@babel/runtime": "^7.23.8",
119
- "@ember-data/debug": "5.4.0-beta.2",
120
- "@ember-data/graph": "5.4.0-beta.2",
121
- "@ember-data/json-api": "5.4.0-beta.2",
122
- "@ember-data/legacy-compat": "5.4.0-beta.2",
123
- "@ember-data/request": "5.4.0-beta.2",
124
- "@ember-data/request-utils": "5.4.0-beta.2",
125
- "@ember-data/store": "5.4.0-beta.2",
126
- "@ember-data/tracking": "5.4.0-beta.2",
127
- "@ember/string": "^3.1.1",
128
- "@embroider/addon-dev": "^4.1.2",
129
- "@glimmer/component": "^1.1.2",
130
- "@rollup/plugin-babel": "^6.0.4",
131
- "@rollup/plugin-node-resolve": "^15.2.3",
132
- "@warp-drive/core-types": "0.0.0-beta.2",
133
- "@warp-drive/internal-config": "5.4.0-beta.2",
134
- "ember-inflector": "^4.0.2",
135
- "ember-source": "~5.6.0",
136
- "rollup": "^4.9.6",
137
- "typescript": "^5.3.3",
138
- "walk-sync": "^3.0.0",
139
- "webpack": "^5.89.0"
71
+ "@babel/core": "^7.26.10",
72
+ "@babel/plugin-transform-typescript": "^7.27.0",
73
+ "@babel/preset-env": "^7.26.9",
74
+ "@babel/preset-typescript": "^7.27.0",
75
+ "@ember-data/graph": "5.4.0-beta.21",
76
+ "@ember-data/json-api": "5.4.0-beta.21",
77
+ "@ember-data/legacy-compat": "5.4.0-beta.21",
78
+ "@ember-data/request": "5.4.0-beta.21",
79
+ "@ember-data/request-utils": "5.4.0-beta.21",
80
+ "@ember-data/store": "5.4.0-beta.21",
81
+ "@ember-data/tracking": "5.4.0-beta.21",
82
+ "@ember/test-waiters": "^4.1.0",
83
+ "@glimmer/component": "^2.0.0",
84
+ "@warp-drive/core-types": "0.0.0-beta.21",
85
+ "@warp-drive/internal-config": "5.4.0-beta.21",
86
+ "decorator-transforms": "^2.3.0",
87
+ "ember-source": "~6.3.0",
88
+ "expect-type": "^1.2.1",
89
+ "typescript": "^5.8.3",
90
+ "vite": "^5.4.15"
140
91
  },
141
92
  "engines": {
142
- "node": ">= 18.19.1"
93
+ "node": ">= 18.20.8"
143
94
  },
144
95
  "volta": {
145
96
  "extends": "../../package.json"
146
97
  },
147
- "packageManager": "pnpm@8.6.0",
98
+ "typesVersions": {
99
+ "*": {
100
+ "unstable-preview-types": [
101
+ "./unstable-preview-types"
102
+ ]
103
+ }
104
+ },
148
105
  "scripts": {
149
- "lint": "eslint . --quiet --cache --cache-strategy=content --ext .js,.ts,.mjs,.cjs --report-unused-disable-directives",
150
- "move-dts": "bun ../../scripts/copy-declarations.mjs src",
151
- "build:types": "echo \"Types are private\" && exit 0",
152
- "build:client": "rollup --config && babel ./addon --out-dir addon --plugins=../private-build-infra/src/transforms/babel-plugin-transform-ext.js",
153
- "_build": "bun run build:client && bun run build:types",
154
- "_syncPnpm": "bun run sync-dependencies-meta-injected"
106
+ "lint": "eslint . --quiet --cache --cache-strategy=content",
107
+ "build:pkg": "vite build;",
108
+ "sync": "echo \"syncing\"",
109
+ "start": "vite"
155
110
  }
156
111
  }
@@ -0,0 +1,175 @@
1
+ declare module '@ember-data/model/-private/attr' {
2
+ import type { ArrayValue, ObjectValue, PrimitiveValue } from '@warp-drive/core-types/json/raw';
3
+ import type { TransformName } from '@warp-drive/core-types/symbols';
4
+ import type { DecoratorPropertyDescriptor } from '@ember-data/model/-private/util';
5
+ /**
6
+ * Options provided to the attr decorator are
7
+ * supplied to the associated transform. Any
8
+ * key-value pair is valid; however, it is highly
9
+ * recommended to only use statically defined values
10
+ * that could be serialized to JSON.
11
+ *
12
+ * If no transform is provided, the only valid
13
+ * option is `defaultValue`.
14
+ *
15
+ * Examples:
16
+ *
17
+ * ```ts
18
+ * class User extends Model {
19
+ * @attr('string', { defaultValue: 'Anonymous' }) name;
20
+ * @attr('date', { defaultValue: () => new Date() }) createdAt;
21
+ * @attr({ defaultValue: () => ({}) }) preferences;
22
+ * @attr('boolean') hasVerifiedEmail;
23
+ * @attr address;
24
+ * }
25
+ *
26
+ * @class NOTATHING
27
+ * @typedoc
28
+ */
29
+ export type AttrOptions<DV = PrimitiveValue | object | unknown[]> = {
30
+ /**
31
+ * The default value for this attribute.
32
+ *
33
+ * Default values can be provided as a value or a function that will be
34
+ * executed to generate the default value.
35
+ *
36
+ * Default values *should not* be stateful (object, arrays, etc.) as
37
+ * they will be shared across all instances of the record.
38
+ *
39
+ * @typedoc
40
+ */
41
+ defaultValue?: DV extends PrimitiveValue ? DV : () => DV;
42
+ };
43
+ type LooseTransformInstance<V, Raw, Name extends string> = {
44
+ /**
45
+ * value type must match the return type of the deserialize method
46
+ *
47
+ * @typedoc
48
+ */
49
+ serialize: (value: V, options: any) => Raw;
50
+ /**
51
+ * defaultValue type must match the return type of the deserialize method
52
+ *
53
+ * @typedoc
54
+ */
55
+ deserialize: (value: Raw, options: any) => V;
56
+ [TransformName]: Name;
57
+ };
58
+ export type TransformHasType = {
59
+ [TransformName]: string;
60
+ };
61
+ export type TypedTransformInstance<V, T extends string> = LooseTransformInstance<V, string, T> | LooseTransformInstance<V, number, T> | LooseTransformInstance<V, boolean, T> | LooseTransformInstance<V, null, T> | LooseTransformInstance<V, ObjectValue, T> | LooseTransformInstance<V, ArrayValue, T> | LooseTransformInstance<V, string | null, T> | LooseTransformInstance<V, number | null, T> | LooseTransformInstance<V, boolean | null, T> | LooseTransformInstance<V, ObjectValue | null, T> | LooseTransformInstance<V, ArrayValue | null, T>;
62
+ export type GetMaybeDeserializeValue<T> = T extends {
63
+ deserialize: (...args: any[]) => unknown;
64
+ } ? ReturnType<T['deserialize']> : never;
65
+ export type TypeFromInstance<T> = T extends TransformHasType ? T[typeof TransformName] : never;
66
+ export type ExtractOptions<T extends TypedTransformInstance<GetMaybeDeserializeValue<T>, TypeFromInstance<T>>> = Parameters<T['deserialize']>[1] & Parameters<T['serialize']>[1] & AttrOptions<ReturnType<T['deserialize']>>;
67
+ export type OptionsFromInstance<T> = TypeFromInstance<T> extends never ? never : GetMaybeDeserializeValue<T> extends never ? never : T extends TypedTransformInstance<GetMaybeDeserializeValue<T>, TypeFromInstance<T>> ? Parameters<T['deserialize']>[1] & Parameters<T['serialize']>[1] & AttrOptions<ReturnType<T['deserialize']>> : never;
68
+ /**
69
+ * The return type of `void` is a lie to appease TypeScript. The actual return type
70
+ * is a descriptor, but typescript incorrectly insists that decorator functions return
71
+ * `void` or `any`.
72
+ *
73
+ * @typedoc
74
+ */
75
+ export type DataDecorator = (target: object, key: string, desc?: DecoratorPropertyDescriptor) => void;
76
+ /**
77
+ `attr` defines an attribute on a [Model](/ember-data/release/classes/Model).
78
+ By default, attributes are passed through as-is, however you can specify an
79
+ optional type to have the value automatically transformed.
80
+ EmberData ships with four basic transform types: `string`, `number`,
81
+ `boolean` and `date`. You can define your own transforms by subclassing
82
+ [Transform](/ember-data/release/classes/Transform).
83
+
84
+ Note that you cannot use `attr` to define an attribute of `id`.
85
+
86
+ `attr` takes an optional hash as a second parameter, currently
87
+ supported options are:
88
+
89
+ - `defaultValue`: Pass a string or a function to be called to set the attribute
90
+ to a default value if and only if the key is absent from the payload response.
91
+
92
+ Example
93
+
94
+ ```app/models/user.js
95
+ import Model, { attr } from '@ember-data/model';
96
+
97
+ export default class UserModel extends Model {
98
+ @attr('string') username;
99
+ @attr('string') email;
100
+ @attr('boolean', { defaultValue: false }) verified;
101
+ }
102
+ ```
103
+
104
+ Default value can also be a function. This is useful it you want to return
105
+ a new object for each attribute.
106
+
107
+ ```app/models/user.js
108
+ import Model, { attr } from '@ember-data/model';
109
+
110
+ export default class UserModel extends Model {
111
+ @attr('string') username;
112
+ @attr('string') email;
113
+
114
+ @attr({
115
+ defaultValue() {
116
+ return {};
117
+ }
118
+ })
119
+ settings;
120
+ }
121
+ ```
122
+
123
+ The `options` hash is passed as second argument to a transforms'
124
+ `serialize` and `deserialize` method. This allows to configure a
125
+ transformation and adapt the corresponding value, based on the config:
126
+
127
+ ```app/models/post.js
128
+ import Model, { attr } from '@ember-data/model';
129
+
130
+ export default class PostModel extends Model {
131
+ @attr('text', {
132
+ uppercase: true
133
+ })
134
+ text;
135
+ }
136
+ ```
137
+
138
+ ```app/transforms/text.js
139
+ export default class TextTransform {
140
+ serialize(value, options) {
141
+ if (options.uppercase) {
142
+ return value.toUpperCase();
143
+ }
144
+
145
+ return value;
146
+ }
147
+
148
+ deserialize(value) {
149
+ return value;
150
+ }
151
+
152
+ static create() {
153
+ return new this();
154
+ }
155
+ }
156
+ ```
157
+
158
+ @method attr
159
+ @public
160
+ @static
161
+ @for @ember-data/model
162
+ @param {String|Object} type the attribute type
163
+ @param {Object} options a hash of options
164
+ @return {Attribute}
165
+ */
166
+ export function attr(): DataDecorator;
167
+ export function attr<T>(type: TypeFromInstance<T>): DataDecorator;
168
+ export function attr(type: string): DataDecorator;
169
+ export function attr(options: AttrOptions): DataDecorator;
170
+ export function attr<T>(type: TypeFromInstance<T>, options?: OptionsFromInstance<T>): DataDecorator;
171
+ export function attr(type: string, options?: AttrOptions & object): DataDecorator;
172
+ export function attr(target: object, key: string | symbol, desc?: PropertyDescriptor): void;
173
+ export {};
174
+ }
175
+ //# sourceMappingURL=attr.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"attr.d.ts","sourceRoot":"","sources":["../../src/-private/attr.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,UAAU,EAAE,WAAW,EAAE,cAAc,EAAS,MAAM,iCAAiC,CAAC;AACtG,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAC;AAGpE,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,QAAQ,CAAC;AAG1D;;;;;;;;;;;;;;;;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Aa,CAAC,CAAC,CAAC,GAC3G,KAAK,CAAC;AAEhB;;;;;;GAMG;AACH,MAAM,MAAM,aAAa,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,2BAA2B,KAAK,IAAI,CAAC;AAEtG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAyFE;AACF,wBAAgB,IAAI,IAAI,aAAa,CAAC;AACtC,wBAAgB,IAAI,CAAC,CAAC,EAAE,IAAI,EAAE,gBAAgB,CAAC,CAAC,CAAC,GAAG,aAAa,CAAC;AAClE,wBAAgB,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,aAAa,CAAC;AAClD,wBAAgB,IAAI,CAAC,OAAO,EAAE,WAAW,GAAG,aAAa,CAAC;AAC1D,wBAAgB,IAAI,CAAC,CAAC,EAAE,IAAI,EAAE,gBAAgB,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC,EAAE,mBAAmB,CAAC,CAAC,CAAC,GAAG,aAAa,CAAC;AACpG,wBAAgB,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,WAAW,GAAG,MAAM,GAAG,aAAa,CAAC;AAClF,wBAAgB,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,EAAE,IAAI,CAAC,EAAE,kBAAkB,GAAG,IAAI,CAAC"}
@@ -0,0 +1,4 @@
1
+ declare module '@ember-data/model/-private/attr.type-test' {
2
+ export {};
3
+ }
4
+ //# sourceMappingURL=attr.type-test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"attr.type-test.d.ts","sourceRoot":"","sources":["../../src/-private/attr.type-test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,181 @@
1
+ declare module '@ember-data/model/-private/belongs-to' {
2
+ import type { TypeFromInstance } from '@warp-drive/core-types/record';
3
+ /**
4
+ @module @ember-data/model
5
+ */
6
+ export type IsUnknown<T> = unknown extends T ? true : false;
7
+ export type RelationshipOptions<T, Async extends boolean> = {
8
+ async: Async;
9
+ inverse: null | (IsUnknown<T> extends true ? string : keyof NoNull<T> & string);
10
+ polymorphic?: boolean;
11
+ as?: string;
12
+ linksMode?: true;
13
+ resetOnRemoteUpdate?: boolean;
14
+ };
15
+ export type NoNull<T> = Exclude<T, null>;
16
+ export type RelationshipDecorator<T> = <This>(target: This, key: string, desc?: PropertyDescriptor) => void;
17
+ /**
18
+ `belongsTo` is used to define One-To-One and One-To-Many, and One-To-None
19
+ relationships on a [Model](/ember-data/release/classes/Model).
20
+
21
+ `belongsTo` takes a configuration hash as a second parameter, currently
22
+ supported options are:
23
+
24
+ - `async`: (*required*) A boolean value used to whether this is a sync (false) or async (true) relationship.
25
+ - `inverse`: (*required*) A string used to identify the inverse property on a related model, or `null`.
26
+ - `polymorphic`: (*optional*) A boolean value to mark the relationship as polymorphic
27
+ - `as`: (*optional*) A string used to the abstract type "this" record satisfies for polymorphism.
28
+
29
+ ### Examples
30
+
31
+ To a **one-to-many** (or many-to-many) relationship, use
32
+ `belongsTo` in combination with `hasMany`:
33
+
34
+ ```js
35
+ // app/models/comment.js
36
+ import Model, { belongsTo } from '@ember-data/model';
37
+
38
+ export default class Comment extends Model {
39
+ @belongsTo('post', { async: false, inverse: 'comments' }) post;
40
+ }
41
+
42
+ // app/models/post.js
43
+ import Model, { hasMany } from '@ember-data/model';
44
+
45
+ export default class Post extends Model {
46
+ @hasMany('comment', { async: false, inverse: 'post' }) comments;
47
+ }
48
+ ```
49
+
50
+ To a **one-to-one** relationship with managed inverses, use `belongsTo` for both sides:
51
+
52
+ ```js
53
+ // app/models/author.js
54
+ import Model, { belongsTo } from '@ember-data/model';
55
+
56
+ export default class Author extends Model {
57
+ @belongsTo('address', { async: true, inverse: 'owner' }) address;
58
+ }
59
+
60
+ // app/models/address.js
61
+ import Model, { belongsTo } from '@ember-data/model';
62
+
63
+ export default class Address extends Model {
64
+ @belongsTo('author', { async: true, inverse: 'address' }) owner;
65
+ }
66
+ ```
67
+
68
+ To a **one-to-one** relationship without managed inverses, use `belongsTo` for both sides
69
+ with `null` as the inverse:
70
+
71
+ ```js
72
+ // app/models/author.js
73
+ import Model, { belongsTo } from '@ember-data/model';
74
+
75
+ export default class Author extends Model {
76
+ @belongsTo('address', { async: true, inverse: null }) address;
77
+ }
78
+
79
+ // app/models/address.js
80
+ import Model, { belongsTo } from '@ember-data/model';
81
+
82
+ export default class Address extends Model {
83
+ @belongsTo('author', { async: true, inverse: null }) owner;
84
+ }
85
+ ```
86
+
87
+ To a one-to-none relationship between two models, use
88
+ `belongsTo` with inverse set to `null` on just one side::
89
+
90
+ ```js
91
+ // app/models/person.js
92
+ import Model, { belongsTo } from '@ember-data/model';
93
+
94
+ export default class Person extends Model {
95
+ @belongsTo('person', { async: false, inverse: null }) bestFriend;
96
+ }
97
+ ```
98
+
99
+ #### Sync vs Async Relationships
100
+
101
+ EmberData fulfills relationships using resource data available in
102
+ the cache.
103
+
104
+ Sync relationships point directly to the known related resources.
105
+
106
+ When a relationship is declared as async, if any of the known related
107
+ resources have not been loaded, they will be fetched. The property
108
+ on the record when accessed provides a promise that resolves once
109
+ all resources are loaded.
110
+
111
+ Async relationships may take advantage of links. On access, if the related
112
+ link has not been loaded, or if any known resources are not available in
113
+ the cache, the fresh state will be fetched using the link.
114
+
115
+ In contrast to async relationship, accessing a sync relationship
116
+ will error on access when any of the known related resources have
117
+ not been loaded.
118
+
119
+ If you are using `links` with sync relationships, you have to use
120
+ the BelongsTo reference API to fetch or refresh related resources
121
+ that aren't loaded. For instance, for a `bestFriend` relationship:
122
+
123
+ ```js
124
+ person.belongsTo('bestFriend').reload();
125
+ ```
126
+
127
+ #### Polymorphic Relationships
128
+
129
+ To a polymorphic relationship, use `hasMany` with the `polymorphic`
130
+ option set to `true`:
131
+
132
+ ```js
133
+ // app/models/comment.js
134
+ import Model, { belongsTo } from '@ember-data/model';
135
+
136
+ export default class Comment extends Model {
137
+ @belongsTo('commentable', { async: false, inverse: 'comments', polymorphic: true }) parent;
138
+ }
139
+ ```
140
+
141
+ `'commentable'` here is referred to as the "abstract type" for the polymorphic
142
+ relationship.
143
+
144
+ Polymorphic relationships with `inverse: null` will accept any type of record as their content.
145
+ Polymorphic relationships with `inverse` set to a string will only accept records with a matching
146
+ inverse relationships declaring itself as satisfying the abstract type.
147
+
148
+ Below, 'as' is used to the that 'post' record satisfies the abstract type 'commentable'
149
+ for this relationship.
150
+
151
+ ```js
152
+ // app/models/post.js
153
+ import Model, { hasMany } from '@ember-data/model';
154
+
155
+ export default class Post extends Model {
156
+ @hasMany('comment', { async: false, inverse: 'parent', as: 'commentable' }) comments;
157
+ }
158
+ ```
159
+
160
+ Note: every Model that declares an inverse to a polymorphic relationship must
161
+ itself exactly the same. This is because polymorphism is based on structural
162
+ traits.
163
+
164
+ Polymorphic to polymorphic relationships are supported. Both sides of the relationship
165
+ must be declared as polymorphic, and the `as` option must be used to the abstract
166
+ type each record satisfies on both sides.
167
+
168
+ @method belongsTo
169
+ @public
170
+ @static
171
+ @for @ember-data/model
172
+ @param {string} type (optional) the name of the related resource
173
+ @param {object} options (optional) a hash of options
174
+ @return {PropertyDescriptor} relationship
175
+ */
176
+ export function belongsTo(): never;
177
+ export function belongsTo(type: string): never;
178
+ export function belongsTo<T>(type: TypeFromInstance<NoNull<T>>, options: RelationshipOptions<T, boolean>): RelationshipDecorator<T>;
179
+ export function belongsTo(type: string, options: RelationshipOptions<unknown, boolean>): RelationshipDecorator<unknown>;
180
+ }
181
+ //# sourceMappingURL=belongs-to.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"belongs-to.d.ts","sourceRoot":"","sources":["../../src/-private/belongs-to.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AAMtE;;EAEE;AAEF,MAAM,MAAM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AAS,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,mBAAmB,CAAC,OAAO,EAAE,OAAO,CAAC,GAAG,qBAAqB,CAAC,OAAO,CAAC,CAAC"}
@@ -0,0 +1,4 @@
1
+ declare module '@ember-data/model/-private/belongs-to.type-test' {
2
+ export {};
3
+ }
4
+ //# sourceMappingURL=belongs-to.type-test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"belongs-to.type-test.d.ts","sourceRoot":"","sources":["../../src/-private/belongs-to.type-test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,8 @@
1
+ declare module '@ember-data/model/-private/debug/assert-polymorphic-type' {
2
+ import type { UpgradedMeta } from '@ember-data/graph/-private';
3
+ import type Store from '@ember-data/store';
4
+ import type { StableRecordIdentifier } from '@warp-drive/core-types';
5
+ let assertPolymorphicType: (parentIdentifier: StableRecordIdentifier, parentDefinition: UpgradedMeta, addedIdentifier: StableRecordIdentifier, store: Store) => void;
6
+ export { assertPolymorphicType };
7
+ }
8
+ //# sourceMappingURL=assert-polymorphic-type.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"assert-polymorphic-type.d.ts","sourceRoot":"","sources":["../../../src/-private/debug/assert-polymorphic-type.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC/D,OAAO,KAAK,KAAK,MAAM,mBAAmB,CAAC;AAG3C,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAC;AAcrE,QAAA,IAAI,qBAAqB,EAAE,CACzB,gBAAgB,EAAE,sBAAsB,EACxC,gBAAgB,EAAE,YAAY,EAC9B,eAAe,EAAE,sBAAsB,EACvC,KAAK,EAAE,KAAK,KACT,IAAI,CAAC;AA6BV,OAAO,EAAE,qBAAqB,EAAE,CAAC"}