@warp-drive/legacy 5.8.0-alpha.4 → 5.8.0-alpha.41

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 (214) hide show
  1. package/README.md +14 -27
  2. package/declarations/adapter/error.d.ts +7 -7
  3. package/declarations/adapter/json-api.d.ts +6 -8
  4. package/declarations/adapter/rest.d.ts +26 -112
  5. package/declarations/adapter.d.ts +6 -8
  6. package/declarations/compat/-private.d.ts +1 -1
  7. package/declarations/compat/builders/find-all.d.ts +6 -6
  8. package/declarations/compat/builders/find-record.d.ts +8 -8
  9. package/declarations/compat/builders/query.d.ts +12 -12
  10. package/declarations/compat/extensions.d.ts +1 -1
  11. package/declarations/compat/legacy-network-handler/minimum-adapter-interface.d.ts +7 -9
  12. package/declarations/compat/legacy-network-handler/minimum-serializer-interface.d.ts +20 -30
  13. package/declarations/compat/utils.d.ts +17 -17
  14. package/declarations/compat.d.ts +35 -11
  15. package/declarations/index.d.ts +70 -0
  16. package/declarations/model/-private/attr.d.ts +5 -6
  17. package/declarations/model/-private/belongs-to.d.ts +4 -5
  18. package/declarations/model/-private/has-many.d.ts +4 -5
  19. package/declarations/model/-private/hooks.d.ts +1 -1
  20. package/declarations/model/-private/legacy-relationships-support.d.ts +2 -2
  21. package/declarations/model/-private/model.d.ts +18 -59
  22. package/declarations/model/-private/promise-many-array.d.ts +0 -18
  23. package/declarations/model/-private/record-state.d.ts +1 -1
  24. package/declarations/model/-private/references/belongs-to.d.ts +19 -29
  25. package/declarations/model/-private/references/has-many.d.ts +14 -16
  26. package/declarations/model/migration-support.d.ts +46 -21
  27. package/declarations/model-fragments/extensions/fragment-array.d.ts +16 -0
  28. package/declarations/model-fragments/extensions/fragment.d.ts +15 -0
  29. package/declarations/model-fragments/hooks/model-for.d.ts +20 -0
  30. package/declarations/model-fragments/index.d.ts +5 -0
  31. package/declarations/model-fragments/instance-initializers/fragment-extensions.d.ts +9 -0
  32. package/declarations/model-fragments/utilities/with-array-defaults.d.ts +15 -0
  33. package/declarations/model-fragments/utilities/with-fragment-array-defaults.d.ts +20 -0
  34. package/declarations/model-fragments/utilities/with-fragment-defaults.d.ts +19 -0
  35. package/declarations/model-fragments/utilities/with-legacy.d.ts +3 -0
  36. package/declarations/model-fragments.d.ts +9 -0
  37. package/declarations/model.d.ts +2 -2
  38. package/declarations/serializer/-private/embedded-records-mixin.d.ts +1 -6
  39. package/declarations/serializer/-private/transforms/boolean.d.ts +2 -2
  40. package/declarations/serializer/-private/transforms/date.d.ts +2 -2
  41. package/declarations/serializer/-private/transforms/number.d.ts +1 -1
  42. package/declarations/serializer/-private/transforms/string.d.ts +1 -1
  43. package/declarations/serializer/json-api.d.ts +11 -12
  44. package/declarations/serializer/json.d.ts +9 -11
  45. package/declarations/serializer/rest.d.ts +4 -6
  46. package/declarations/serializer.d.ts +9 -12
  47. package/dist/{-private-8UmnAf9J.js → -private-BG3bMiKp.js} +3 -2
  48. package/dist/adapter/-private.js +1 -1
  49. package/dist/adapter/error.js +14 -15
  50. package/dist/adapter/json-api.js +4 -1
  51. package/dist/adapter/rest.js +38 -125
  52. package/dist/adapter.js +6 -8
  53. package/dist/compat/-private.js +1 -1
  54. package/dist/compat/builders.js +26 -26
  55. package/dist/compat/utils.js +17 -18
  56. package/dist/compat.js +61 -43
  57. package/dist/{errors-8kD2mSe_.js → errors-Cz5KrzBk.js} +115 -122
  58. package/dist/hooks-D6diaM34.js +74 -0
  59. package/dist/index.js +195 -0
  60. package/dist/{json-DziiodPf.js → json-ChdEfB0X.js} +18 -35
  61. package/dist/model/-private.js +1 -1
  62. package/dist/model/migration-support.js +57 -25
  63. package/dist/model-for-CqXsIKws.js +221 -0
  64. package/dist/model-fragments.js +76 -0
  65. package/dist/model.js +18 -90
  66. package/dist/{schema-provider-DQu4Rjco.js → schema-provider-DJCV_6AF.js} +50 -95
  67. package/dist/{serialize-into-hash-CS0MIv4F.js → serialize-into-hash-DPZYoF-i.js} +1 -1
  68. package/dist/serializer/json-api.js +18 -45
  69. package/dist/serializer/json.js +1 -1
  70. package/dist/serializer/rest.js +14 -21
  71. package/dist/serializer/transform.js +15 -6
  72. package/dist/serializer.js +9 -13
  73. package/dist/store.js +5 -1
  74. package/dist/unpkg/dev/-private-DtjBbEgy.js +1206 -0
  75. package/dist/unpkg/dev/adapter/-private.js +1 -0
  76. package/dist/unpkg/dev/adapter/error.js +335 -0
  77. package/dist/unpkg/dev/adapter/json-api.js +271 -0
  78. package/dist/unpkg/dev/adapter/rest.js +1171 -0
  79. package/dist/unpkg/dev/adapter.js +1252 -0
  80. package/dist/unpkg/dev/compat/-private.js +1 -0
  81. package/dist/unpkg/dev/compat/builders.js +275 -0
  82. package/dist/unpkg/dev/compat/extensions.js +242 -0
  83. package/dist/unpkg/dev/compat/utils.js +223 -0
  84. package/dist/unpkg/dev/compat.js +1147 -0
  85. package/dist/unpkg/dev/errors-DmGGJr3T.js +2562 -0
  86. package/dist/unpkg/dev/hooks-CkYiE6Ud.js +73 -0
  87. package/dist/unpkg/dev/index.js +197 -0
  88. package/dist/unpkg/dev/json-Cu1LNgmQ.js +1256 -0
  89. package/dist/unpkg/dev/model/-private.js +1 -0
  90. package/dist/unpkg/dev/model/migration-support.js +553 -0
  91. package/dist/unpkg/dev/model-for-CqXsIKws.js +221 -0
  92. package/dist/unpkg/dev/model-fragments.js +76 -0
  93. package/dist/unpkg/dev/model.js +678 -0
  94. package/dist/unpkg/dev/runtime-BPCpkOf1-BKOwiRJp.js +65 -0
  95. package/dist/unpkg/dev/schema-provider-DDVYxmUV.js +2186 -0
  96. package/dist/unpkg/dev/serialize-into-hash-B2xDbuo5.js +259 -0
  97. package/dist/unpkg/dev/serializer/json-api.js +649 -0
  98. package/dist/unpkg/dev/serializer/json.js +4 -0
  99. package/dist/unpkg/dev/serializer/rest.js +1242 -0
  100. package/dist/unpkg/dev/serializer/transform.js +278 -0
  101. package/dist/unpkg/dev/serializer.js +248 -0
  102. package/dist/unpkg/dev/store.js +637 -0
  103. package/dist/unpkg/dev/util-DvanW33H.js +20 -0
  104. package/dist/unpkg/dev/utils-BhvS1iTS.js +8 -0
  105. package/dist/unpkg/dev-deprecated/-private-DtjBbEgy.js +1206 -0
  106. package/dist/unpkg/dev-deprecated/adapter/-private.js +1 -0
  107. package/dist/unpkg/dev-deprecated/adapter/error.js +335 -0
  108. package/dist/unpkg/dev-deprecated/adapter/json-api.js +271 -0
  109. package/dist/unpkg/dev-deprecated/adapter/rest.js +1171 -0
  110. package/dist/unpkg/dev-deprecated/adapter.js +1252 -0
  111. package/dist/unpkg/dev-deprecated/compat/-private.js +1 -0
  112. package/dist/unpkg/dev-deprecated/compat/builders.js +275 -0
  113. package/dist/unpkg/dev-deprecated/compat/extensions.js +242 -0
  114. package/dist/unpkg/dev-deprecated/compat/utils.js +223 -0
  115. package/dist/unpkg/dev-deprecated/compat.js +1147 -0
  116. package/dist/unpkg/dev-deprecated/errors-Spt6ubMd.js +2565 -0
  117. package/dist/unpkg/dev-deprecated/hooks-DOXegvhL.js +73 -0
  118. package/dist/unpkg/dev-deprecated/index.js +196 -0
  119. package/dist/unpkg/dev-deprecated/json-Cu1LNgmQ.js +1256 -0
  120. package/dist/unpkg/dev-deprecated/model/-private.js +1 -0
  121. package/dist/unpkg/dev-deprecated/model/migration-support.js +570 -0
  122. package/dist/unpkg/dev-deprecated/model-for-CqXsIKws.js +221 -0
  123. package/dist/unpkg/dev-deprecated/model-fragments.js +76 -0
  124. package/dist/unpkg/dev-deprecated/model.js +682 -0
  125. package/dist/unpkg/dev-deprecated/runtime-BPCpkOf1-BKOwiRJp.js +65 -0
  126. package/dist/unpkg/dev-deprecated/schema-provider-BP6_8N-V.js +2211 -0
  127. package/dist/unpkg/dev-deprecated/serialize-into-hash-B2xDbuo5.js +259 -0
  128. package/dist/unpkg/dev-deprecated/serializer/json-api.js +649 -0
  129. package/dist/unpkg/dev-deprecated/serializer/json.js +4 -0
  130. package/dist/unpkg/dev-deprecated/serializer/rest.js +1242 -0
  131. package/dist/unpkg/dev-deprecated/serializer/transform.js +278 -0
  132. package/dist/unpkg/dev-deprecated/serializer.js +248 -0
  133. package/dist/unpkg/dev-deprecated/store.js +637 -0
  134. package/dist/unpkg/dev-deprecated/util-CWr5WQOT.js +24 -0
  135. package/dist/unpkg/dev-deprecated/utils-C9PJehtL.js +12 -0
  136. package/dist/unpkg/prod/-private-BdyZaGEh.js +971 -0
  137. package/dist/unpkg/prod/adapter/-private.js +1 -0
  138. package/dist/unpkg/prod/adapter/error.js +330 -0
  139. package/dist/unpkg/prod/adapter/json-api.js +266 -0
  140. package/dist/unpkg/prod/adapter/rest.js +1134 -0
  141. package/dist/unpkg/prod/adapter.js +1219 -0
  142. package/dist/unpkg/prod/compat/-private.js +1 -0
  143. package/dist/unpkg/prod/compat/builders.js +210 -0
  144. package/dist/unpkg/prod/compat/extensions.js +232 -0
  145. package/dist/unpkg/prod/compat/utils.js +218 -0
  146. package/dist/unpkg/prod/compat.js +727 -0
  147. package/dist/unpkg/prod/errors-BGVFCBmi.js +2314 -0
  148. package/dist/unpkg/prod/hooks-BztVA_x0.js +41 -0
  149. package/dist/unpkg/prod/index.js +151 -0
  150. package/dist/unpkg/prod/json-BWrZ5546.js +1243 -0
  151. package/dist/unpkg/prod/model/-private.js +1 -0
  152. package/dist/unpkg/prod/model/migration-support.js +546 -0
  153. package/dist/unpkg/prod/model-for-CqXsIKws.js +221 -0
  154. package/dist/unpkg/prod/model-fragments.js +76 -0
  155. package/dist/unpkg/prod/model.js +593 -0
  156. package/dist/unpkg/prod/runtime-BPCpkOf1-BKOwiRJp.js +65 -0
  157. package/dist/unpkg/prod/schema-provider-DJtD_8jZ.js +1861 -0
  158. package/dist/unpkg/prod/serialize-into-hash-DGlzQteF.js +215 -0
  159. package/dist/unpkg/prod/serializer/json-api.js +592 -0
  160. package/dist/unpkg/prod/serializer/json.js +4 -0
  161. package/dist/unpkg/prod/serializer/rest.js +1210 -0
  162. package/dist/unpkg/prod/serializer/transform.js +278 -0
  163. package/dist/unpkg/prod/serializer.js +248 -0
  164. package/dist/unpkg/prod/store.js +505 -0
  165. package/dist/unpkg/prod/util-DvanW33H.js +20 -0
  166. package/dist/unpkg/prod/utils-BhvS1iTS.js +8 -0
  167. package/dist/unpkg/prod-deprecated/-private-BdyZaGEh.js +971 -0
  168. package/dist/unpkg/prod-deprecated/adapter/-private.js +1 -0
  169. package/dist/unpkg/prod-deprecated/adapter/error.js +330 -0
  170. package/dist/unpkg/prod-deprecated/adapter/json-api.js +266 -0
  171. package/dist/unpkg/prod-deprecated/adapter/rest.js +1134 -0
  172. package/dist/unpkg/prod-deprecated/adapter.js +1219 -0
  173. package/dist/unpkg/prod-deprecated/compat/-private.js +1 -0
  174. package/dist/unpkg/prod-deprecated/compat/builders.js +210 -0
  175. package/dist/unpkg/prod-deprecated/compat/extensions.js +232 -0
  176. package/dist/unpkg/prod-deprecated/compat/utils.js +218 -0
  177. package/dist/unpkg/prod-deprecated/compat.js +727 -0
  178. package/dist/unpkg/prod-deprecated/errors-CdDaK81x.js +2317 -0
  179. package/dist/unpkg/prod-deprecated/hooks-yId87yyG.js +41 -0
  180. package/dist/unpkg/prod-deprecated/index.js +150 -0
  181. package/dist/unpkg/prod-deprecated/json-BWrZ5546.js +1243 -0
  182. package/dist/unpkg/prod-deprecated/model/-private.js +1 -0
  183. package/dist/unpkg/prod-deprecated/model/migration-support.js +563 -0
  184. package/dist/unpkg/prod-deprecated/model-for-CqXsIKws.js +221 -0
  185. package/dist/unpkg/prod-deprecated/model-fragments.js +76 -0
  186. package/dist/unpkg/prod-deprecated/model.js +596 -0
  187. package/dist/unpkg/prod-deprecated/runtime-BPCpkOf1-BKOwiRJp.js +65 -0
  188. package/dist/unpkg/prod-deprecated/schema-provider-CjX55uSY.js +1904 -0
  189. package/dist/unpkg/prod-deprecated/serialize-into-hash-DGlzQteF.js +215 -0
  190. package/dist/unpkg/prod-deprecated/serializer/json-api.js +592 -0
  191. package/dist/unpkg/prod-deprecated/serializer/json.js +4 -0
  192. package/dist/unpkg/prod-deprecated/serializer/rest.js +1210 -0
  193. package/dist/unpkg/prod-deprecated/serializer/transform.js +278 -0
  194. package/dist/unpkg/prod-deprecated/serializer.js +248 -0
  195. package/dist/unpkg/prod-deprecated/store.js +505 -0
  196. package/dist/unpkg/prod-deprecated/util-B6cn-i93.js +23 -0
  197. package/dist/unpkg/prod-deprecated/utils-BUWwQwCh.js +11 -0
  198. package/logos/README.md +2 -2
  199. package/logos/logo-yellow-slab.svg +1 -0
  200. package/logos/word-mark-black.svg +1 -0
  201. package/logos/word-mark-white.svg +1 -0
  202. package/package.json +14 -6
  203. package/logos/NCC-1701-a-blue.svg +0 -4
  204. package/logos/NCC-1701-a-gold.svg +0 -4
  205. package/logos/NCC-1701-a-gold_100.svg +0 -1
  206. package/logos/NCC-1701-a-gold_base-64.txt +0 -1
  207. package/logos/NCC-1701-a.svg +0 -4
  208. package/logos/docs-badge.svg +0 -2
  209. package/logos/ember-data-logo-dark.svg +0 -12
  210. package/logos/ember-data-logo-light.svg +0 -12
  211. package/logos/social1.png +0 -0
  212. package/logos/social2.png +0 -0
  213. package/logos/warp-drive-logo-dark.svg +0 -4
  214. package/logos/warp-drive-logo-gold.svg +0 -4
@@ -0,0 +1,74 @@
1
+ import { setOwner, getOwner } from '@ember/application';
2
+ import { assertPrivateStore, setRecordIdentifier, StoreMap } from '@warp-drive/core/store/-private';
3
+ import { g as getModelFactory } from "./schema-provider-DJCV_6AF.js";
4
+ import { n as normalizeModelName } from "./util-Dul6TZts.js";
5
+ import { macroCondition, getGlobalConfig } from '@embroider/macros';
6
+ function instantiateRecord(identifier, createRecordArgs) {
7
+ const type = identifier.type;
8
+
9
+ // TODO deprecate allowing unknown args setting
10
+ const createOptions = {
11
+ _createProps: createRecordArgs ?? {},
12
+ // TODO @deprecate consider deprecating accessing record properties during init which the below is necessary for
13
+ _secretInit: {
14
+ identifier,
15
+ store: this,
16
+ cb: secretInit
17
+ }
18
+ };
19
+
20
+ // ensure that `getOwner(this)` works inside a model instance
21
+ setOwner(createOptions, getOwner(this));
22
+ const factory = getModelFactory(this, type);
23
+ macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
24
+ if (!test) {
25
+ throw new Error(`No model was found for '${type}'`);
26
+ }
27
+ })(factory) : {};
28
+ return factory.class.create(createOptions);
29
+ }
30
+ function teardownRecord(record) {
31
+ macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
32
+ if (!test) {
33
+ throw new Error(`expected to receive an instance of Model from @ember-data/model. If using a custom model make sure you implement teardownRecord`);
34
+ }
35
+ })('destroy' in record) : {};
36
+ record.destroy();
37
+ }
38
+ function modelFor(modelName) {
39
+ assertPrivateStore(this);
40
+ macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
41
+ if (!test) {
42
+ throw new Error(`Attempted to call store.modelFor(), but the store instance has already been destroyed.`);
43
+ }
44
+ })(!this.isDestroyed && !this.isDestroying) : {};
45
+ macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
46
+ if (!test) {
47
+ throw new Error(`You need to pass a model name to the store's modelFor method`);
48
+ }
49
+ })(modelName) : {};
50
+ macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
51
+ if (!test) {
52
+ throw new Error(`Please pass a proper model name to the store's modelFor method`);
53
+ }
54
+ })(typeof modelName === 'string' && modelName.length) : {};
55
+ const type = normalizeModelName(modelName);
56
+ const maybeFactory = getModelFactory(this, type);
57
+ const klass = maybeFactory && maybeFactory.class ? maybeFactory.class : null;
58
+ const ignoreType = !klass || !klass.isModel || this._forceShim;
59
+ if (!ignoreType) {
60
+ return klass;
61
+ }
62
+ macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
63
+ if (!test) {
64
+ throw new Error(`No model was found for '${type}' and no schema handles the type`);
65
+ }
66
+ })(this.schema.hasResource({
67
+ type
68
+ })) : {};
69
+ }
70
+ function secretInit(record, identifier, store) {
71
+ setRecordIdentifier(record, identifier);
72
+ StoreMap.set(record, store);
73
+ }
74
+ export { instantiateRecord as i, modelFor as m, teardownRecord as t };
package/dist/index.js ADDED
@@ -0,0 +1,195 @@
1
+ import { Store, RequestManager, Fetch, CacheHandler, recordIdentifierFor } from '@warp-drive/core';
2
+ import { SchemaService, registerDerivations, instantiateRecord as instantiateRecord$1, teardownRecord as teardownRecord$1 } from '@warp-drive/core/reactive';
3
+ import { DefaultCachePolicy } from '@warp-drive/core/store';
4
+ import { LegacyNetworkHandler, adapterFor, serializerFor, pushPayload, normalize, serializeRecord, cleanup } from './compat.js';
5
+ import { EmberArrayLikeExtension, EmberObjectArrayExtension, EmberObjectExtension } from './compat/extensions.js';
6
+ import '@ember/object';
7
+ import '@warp-drive/core/types/symbols';
8
+ import '@ember/debug';
9
+ import '@warp-drive/utilities/string';
10
+ import { macroCondition, getGlobalConfig } from '@embroider/macros';
11
+ import '@warp-drive/core/store/-private';
12
+ import "./errors-Cz5KrzBk.js";
13
+ import "./schema-provider-DJCV_6AF.js";
14
+ import { i as instantiateRecord, t as teardownRecord, m as modelFor } from "./hooks-D6diaM34.js";
15
+ import { registerDerivations as registerDerivations$1, DelegatingSchemaService } from './model/migration-support.js';
16
+ import { F as FragmentExtension, a as FragmentArrayExtension, f as fragmentsModelFor } from "./model-for-CqXsIKws.js";
17
+ import { restoreDeprecatedStoreBehaviors } from './store.js';
18
+
19
+ /**
20
+ * @module
21
+ * @mergeModuleWith <project>
22
+ */
23
+
24
+ /**
25
+ * Use the legacy store with the given options.
26
+ */
27
+ function useLegacyStore(options, StoreKlass = Store) {
28
+ macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
29
+ if (!test) {
30
+ throw new Error(`If legacyRequests is true, linksMode must be false`);
31
+ }
32
+ })(!(options.linksMode && options.legacyRequests)) : {};
33
+ // we extend the store to ensure we don't leak our prototype overrides to other stores below.
34
+ class BaseKlass extends StoreKlass {}
35
+ class LegacyConfiguredStore extends BaseKlass {
36
+ requestManager = new RequestManager().use([options.linksMode ? null : LegacyNetworkHandler, ...(options.handlers ?? []), Fetch].filter(Boolean)).useCache(CacheHandler);
37
+ lifetimes = options.policy ?? new DefaultCachePolicy({
38
+ apiCacheHardExpires: 15 * 60 * 1000,
39
+ // 15 minutes
40
+ apiCacheSoftExpires: 1 * 30 * 1000,
41
+ // 30 seconds
42
+ constraints: {
43
+ headers: {
44
+ 'X-WarpDrive-Expires': true,
45
+ 'Cache-Control': true,
46
+ Expires: true
47
+ }
48
+ }
49
+ });
50
+ createSchemaService() {
51
+ // prepare for PolarisMode
52
+ const schema = new SchemaService();
53
+ registerDerivations(schema);
54
+ if (options.schemas) schema.registerResources(options.schemas);
55
+ if (options.traits) {
56
+ for (const trait of options.traits) {
57
+ schema.registerTrait(trait);
58
+ }
59
+ }
60
+ if (options.derivations) {
61
+ for (const derivation of options.derivations) {
62
+ schema.registerDerivation(derivation);
63
+ }
64
+ }
65
+ if (options.transformations) {
66
+ for (const transformation of options.transformations) {
67
+ schema.registerTransformation(transformation);
68
+ }
69
+ }
70
+ if (options.hashFns) {
71
+ for (const hashFn of options.hashFns) {
72
+ schema.registerHashFn(hashFn);
73
+ }
74
+ }
75
+ if (options.CAUTION_MEGA_DANGER_ZONE_extensions) {
76
+ for (const extension of options.CAUTION_MEGA_DANGER_ZONE_extensions) {
77
+ schema.CAUTION_MEGA_DANGER_ZONE_registerExtension(extension);
78
+ }
79
+ }
80
+
81
+ // Add support for LegacyMode ReactiveResource with Maximal coverage
82
+ // for upgrading from 4.x
83
+ registerDerivations$1(schema);
84
+ schema.CAUTION_MEGA_DANGER_ZONE_registerExtension(EmberArrayLikeExtension);
85
+ schema.CAUTION_MEGA_DANGER_ZONE_registerExtension(EmberObjectArrayExtension);
86
+ schema.CAUTION_MEGA_DANGER_ZONE_registerExtension(EmberObjectExtension);
87
+
88
+ // add support for fragments
89
+ if (options.modelFragments) {
90
+ schema.CAUTION_MEGA_DANGER_ZONE_registerExtension?.(FragmentExtension);
91
+ schema.CAUTION_MEGA_DANGER_ZONE_registerExtension?.(FragmentArrayExtension);
92
+ }
93
+
94
+ // Add fallback for Models
95
+ return new DelegatingSchemaService(this, schema);
96
+ }
97
+ createCache(capabilities) {
98
+ // eslint-disable-next-line new-cap
99
+ return new options.cache(capabilities);
100
+ }
101
+ instantiateRecord(key, createArgs) {
102
+ if (this.schema.isDelegated(key)) {
103
+ return instantiateRecord.call(this, key, createArgs);
104
+ }
105
+ return instantiateRecord$1(this, key, createArgs);
106
+ }
107
+ teardownRecord(record) {
108
+ const key = recordIdentifierFor(record);
109
+ if (this.schema.isDelegated(key)) {
110
+ return teardownRecord.call(this, record);
111
+ }
112
+ return teardownRecord$1(record);
113
+ }
114
+ modelFor(type) {
115
+ assertType(this.schema, type);
116
+ // TODO I'm not sure this is right
117
+ macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
118
+ if (!test) {
119
+ throw new Error(`modelFor should only be used to lookup legacy models when in linksMode: false`);
120
+ }
121
+ })(!options.linksMode || !this.schema.isDelegated({
122
+ type
123
+ })) : {};
124
+ const klass =
125
+ // prefer real models if present
126
+ modelFor.call(this, type) || (
127
+ // fallback to ShimModelClass specific to fragments if fragments support in use
128
+ options.modelFragments ? fragmentsModelFor.call(this, type) : false) ||
129
+ // fallback to ShimModelClass
130
+ super.modelFor(type);
131
+ return klass;
132
+ }
133
+ adapterFor(modelName, _allowMissing) {
134
+ macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
135
+ if (!test) {
136
+ throw new Error(`useLegacyStore was setup in linksMode. linksMode assumes that all requests have been migrated away from adapters and serializers.`);
137
+ }
138
+ })(!options.linksMode) : {};
139
+ // @ts-expect-error
140
+ return adapterFor.call(this, modelName, _allowMissing);
141
+ }
142
+ serializerFor(...args) {
143
+ macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
144
+ if (!test) {
145
+ throw new Error(`useLegacyStore was setup in linksMode. linksMode assumes that all requests have been migrated away from adapters and serializers.`);
146
+ }
147
+ })(!options.linksMode) : {};
148
+ return serializerFor.call(this, ...args);
149
+ }
150
+ pushPayload(...args) {
151
+ macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
152
+ if (!test) {
153
+ throw new Error(`useLegacyStore was setup in linksMode. linksMode assumes that all requests have been migrated away from adapters and serializers.`);
154
+ }
155
+ })(!options.linksMode) : {};
156
+ return pushPayload.call(this, ...args);
157
+ }
158
+ normalize(...args) {
159
+ macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
160
+ if (!test) {
161
+ throw new Error(`useLegacyStore was setup in linksMode. linksMode assumes that all requests have been migrated away from adapters and serializers.`);
162
+ }
163
+ })(!options.linksMode) : {};
164
+ return normalize.call(this, ...args);
165
+ }
166
+ serializeRecord(...args) {
167
+ macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
168
+ if (!test) {
169
+ throw new Error(`useLegacyStore was setup in linksMode. linksMode assumes that all requests have been migrated away from adapters and serializers.`);
170
+ }
171
+ })(!options.linksMode) : {};
172
+ return serializeRecord.call(this, ...args);
173
+ }
174
+ destroy() {
175
+ if (!options.linksMode) {
176
+ cleanup.call(this);
177
+ }
178
+ super.destroy();
179
+ }
180
+ }
181
+ if (options.legacyRequests) {
182
+ restoreDeprecatedStoreBehaviors(BaseKlass);
183
+ }
184
+ return LegacyConfiguredStore;
185
+ }
186
+ function assertType(schema, type) {
187
+ macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
188
+ if (!test) {
189
+ throw new Error(`Expected type ${type} to be a valid ResourceType`);
190
+ }
191
+ })(schema.hasResource({
192
+ type
193
+ })) : {};
194
+ }
195
+ export { useLegacyStore };
@@ -25,20 +25,18 @@ const SOURCE_POINTER_PRIMARY_REGEXP = /^\/?data/;
25
25
  const PRIMARY_ATTRIBUTE_KEY = 'base';
26
26
 
27
27
  /**
28
- * <blockquote style="margin: 1em; padding: .1em 1em .1em 1em; border-left: solid 1em #E34C32; background: #e0e0e0;">
29
- <p>
30
- ⚠️ <strong>This is LEGACY documentation</strong> for a feature that is no longer encouraged to be used.
28
+ * :::danger
29
+ ⚠️ **This is LEGACY documentation** for a feature that is no longer encouraged to be used.
31
30
  If starting a new app or thinking of implementing a new adapter, consider writing a
32
- <a href="/ember-data/release/classes/%3CInterface%3E%20Handler">Handler</a> instead to be used with the <a href="https://github.com/warp-drive-data/warp-drive/tree/main/packages/request#readme">RequestManager</a>
33
- </p>
34
- </blockquote>
31
+ {@link Handler} instead to be used with the {@link RequestManager}
32
+ :::
35
33
 
36
- In EmberData a Serializer is used to serialize and deserialize
34
+ In WarpDrive a Serializer is used to serialize and deserialize
37
35
  records when they are transferred in and out of an external source.
38
36
  This process involves normalizing property names, transforming
39
37
  attribute values and serializing relationships.
40
38
 
41
- By default, EmberData uses and recommends the `JSONAPISerializer`.
39
+ By default, WarpDrive uses and recommends the `JSONAPISerializer`.
42
40
 
43
41
  `JSONSerializer` is useful for simpler or legacy backends that may
44
42
  not support the http://jsonapi.org/ spec.
@@ -46,7 +44,7 @@ const PRIMARY_ATTRIBUTE_KEY = 'base';
46
44
  For example, given the following `User` model and JSON payload:
47
45
 
48
46
  ```js [app/models/user.js]
49
- import Model, { attr, belongsTo, hasMany } from '@ember-data/model';
47
+ import Model, { attr, belongsTo, hasMany } from '@warp-drive/legacy/model';
50
48
 
51
49
  export default class UserModel extends Model {
52
50
  @hasMany('user') friends;
@@ -67,8 +65,8 @@ const PRIMARY_ATTRIBUTE_KEY = 'base';
67
65
  }
68
66
  ```
69
67
 
70
- `JSONSerializer` will normalize the JSON payload to the JSON API format that the
71
- Ember Data store expects.
68
+ `JSONSerializer` will normalize the JSON payload to the {json:api} format that the
69
+ JSONAPICache uses to cache data in the Store.
72
70
 
73
71
  You can customize how JSONSerializer processes its payload by passing options in
74
72
  the `attrs` hash or by subclassing the `JSONSerializer` and overriding hooks:
@@ -103,7 +101,7 @@ const PRIMARY_ATTRIBUTE_KEY = 'base';
103
101
  const JSONSerializer = Serializer.extend({
104
102
  /**
105
103
  The `primaryKey` is used when serializing and deserializing
106
- data. Ember Data always uses the `id` property to store the id of
104
+ data. WarpDrive always uses the `id` property to store the id of
107
105
  the record. The external source may not always follow this
108
106
  convention. In these cases it is useful to override the
109
107
  `primaryKey` property to match the `primaryKey` of your external
@@ -115,9 +113,7 @@ const JSONSerializer = Serializer.extend({
115
113
  primaryKey = '_id'
116
114
  }
117
115
  ```
118
- @property primaryKey
119
- @type {String}
120
- @public
116
+ @public
121
117
  @default 'id'
122
118
  */
123
119
  primaryKey: 'id',
@@ -129,7 +125,7 @@ const JSONSerializer = Serializer.extend({
129
125
  the response payload.
130
126
  Example
131
127
  ```js [app/models/person.js]
132
- import Model, { attr } from '@ember-data/model';
128
+ import Model, { attr } from '@warp-drive/legacy/model';
133
129
  export default class PersonModel extends Model {
134
130
  @attr('string') firstName;
135
131
  @attr('string') lastName;
@@ -159,7 +155,7 @@ const JSONSerializer = Serializer.extend({
159
155
  }
160
156
  ```
161
157
  When serialized:
162
- ```javascript
158
+ ```js
163
159
  {
164
160
  "firstName": "Harry",
165
161
  "lastName": "Houdini",
@@ -170,9 +166,7 @@ const JSONSerializer = Serializer.extend({
170
166
  Setting `serialize` to `true` enforces serialization for hasMany
171
167
  relationships even if it's neither a many-to-many nor many-to-none
172
168
  relationship.
173
- @property attrs
174
- @public
175
- @type {Object}
169
+ @public
176
170
  */
177
171
  mergedProperties: ['attrs'],
178
172
  /**
@@ -457,9 +451,6 @@ const JSONSerializer = Serializer.extend({
457
451
  }
458
452
  ```
459
453
  @public
460
- @param {Model} typeClass
461
- @param {Object} hash
462
- @return {Object}
463
454
  */
464
455
  normalize(modelClass, resourceHash) {
465
456
  let data = null;
@@ -505,9 +496,6 @@ const JSONSerializer = Serializer.extend({
505
496
  Returns the resource's attributes formatted as a JSON-API "attributes object".
506
497
  http://jsonapi.org/format/#document-resource-object-attributes
507
498
  @public
508
- @param {Object} modelClass
509
- @param {Object} resourceHash
510
- @return {Object}
511
499
  */
512
500
  extractAttributes(modelClass, resourceHash) {
513
501
  let attributeKey;
@@ -648,8 +636,7 @@ const JSONSerializer = Serializer.extend({
648
636
  /**
649
637
  Dasherizes the model name in the payload
650
638
  @public
651
- @param {String} key
652
- @return {String} the model's modelName
639
+ @return the model's modelName
653
640
  */
654
641
  modelNameFromPayloadKey(key) {
655
642
  return dasherize(singularize(key));
@@ -773,7 +760,7 @@ const JSONSerializer = Serializer.extend({
773
760
  each attribute and belongsTo relationship.
774
761
  For example, consider this model:
775
762
  ```js [app/models/comment.js]
776
- import Model, { attr, belongsTo } from '@ember-data/model';
763
+ import Model, { attr, belongsTo } from '@warp-drive/legacy/model';
777
764
  export default class CommentModel extends Model {
778
765
  @attr title;
779
766
  @attr body;
@@ -908,7 +895,7 @@ const JSONSerializer = Serializer.extend({
908
895
  The hash property should be modified by reference.
909
896
  For example, your server may expect underscored root objects.
910
897
  ```js [app/serializers/application.js]
911
- import RESTSerializer from '@ember-data/serializer/rest';
898
+ import RESTSerializer from '@warp-drive/legacy/serializer/rest';
912
899
  import { underscoren} from '<app-name>/utils/string-utils';
913
900
  export default class ApplicationSerializer extends RESTSerializer {
914
901
  serializeIntoHash(data, type, snapshot, options) {
@@ -1162,11 +1149,7 @@ const JSONSerializer = Serializer.extend({
1162
1149
  }
1163
1150
  ```
1164
1151
  @public
1165
- @param {Store} store
1166
- @param {Model} typeClass
1167
- @param {Object} payload
1168
- @param {(String|Number)} id
1169
- @return {Object} json The deserialized errors
1152
+ @return json The deserialized errors
1170
1153
  */
1171
1154
  extractErrors(store, typeClass, payload, id) {
1172
1155
  // @ts-expect-error
@@ -1 +1 @@
1
- export { E as Errors, L as LEGACY_SUPPORT, P as PromiseBelongsTo, a as PromiseManyArray, l as lookupLegacySupport } from "../errors-8kD2mSe_.js";
1
+ export { E as Errors, L as LEGACY_SUPPORT, P as PromiseBelongsTo, a as PromiseManyArray, l as lookupLegacySupport } from "../errors-Cz5KrzBk.js";
@@ -1,23 +1,24 @@
1
1
  import { deprecate } from '@ember/debug';
2
2
  import { recordIdentifierFor } from '@warp-drive/core';
3
3
  import { Context } from '@warp-drive/core/reactive/-private';
4
- import { notifyInternalSignal, assertPrivateStore } from '@warp-drive/core/store/-private';
4
+ import { notifyInternalSignal } from '@warp-drive/core/signals/-leaked';
5
+ import { assertPrivateStore } from '@warp-drive/core/store/-private';
5
6
  import { getOrSetGlobal } from '@warp-drive/core/types/-private';
6
7
  import { Type } from '@warp-drive/core/types/symbols';
7
- import { l as lookupLegacySupport, E as Errors } from "../errors-8kD2mSe_.js";
8
- import { b as buildSchema, u as unloadRecord, s as serialize, _ as _save, a as save, r as rollbackAttributes, c as _reload, d as reload, h as hasMany, e as _destroyRecord, f as destroyRecord, g as deleteRecord, R as RecordState, i as changedAttributes, j as belongsTo, k as createSnapshot } from "../schema-provider-DQu4Rjco.js";
8
+ import { l as lookupLegacySupport, E as Errors } from "../errors-Cz5KrzBk.js";
9
+ import { b as buildSchema, u as unloadRecord, s as serialize, _ as _save, a as save, r as rollbackAttributes, c as _reload, d as reload, h as hasMany, e as _destroyRecord, f as destroyRecord, i as deleteRecord, R as RecordState, j as changedAttributes, k as belongsTo, l as createSnapshot } from "../schema-provider-DJCV_6AF.js";
9
10
  import { macroCondition, getGlobalConfig } from '@embroider/macros';
10
11
 
11
12
  /**
12
- * This module provides support for migrating away from @ember-data/model
13
- * to @warp-drive/schema-record.
13
+ * This module provides support for migrating away from @warp-drive/legacy/model
14
+ * to ReactiveResource from @warp-drive/core/reactive.
14
15
  *
15
16
  * It includes:
16
17
  *
17
18
  * - A `withDefaults` function to assist in creating a schema in LegacyMode
18
19
  * - A `registerDerivations` function to register the derivations necessary to support LegacyMode
19
20
  * - A `DelegatingSchemaService` that can be used to provide a schema service that works with both
20
- * @ember-data/model and @warp-drive/schema-record simultaneously for migration purposes.
21
+ * @warp-drive/legacy/model and @warp-drive/core/reactive simultaneously for migration purposes.
21
22
  * - A `WithLegacy` type util that can be used to create a type that includes the legacy
22
23
  * properties and methods of a record.
23
24
  *
@@ -32,14 +33,14 @@ const LegacyFields = ['_createSnapshot', 'adapterError', 'belongsTo', 'changedAt
32
33
 
33
34
  /**
34
35
  * A Type utility that enables quickly adding type information for the fields
35
- * defined by `import { withDefaults } from '@ember-data/model/migration-support'`.
36
+ * defined by `import { withDefaults } from '@warp-drive/legacy/model/migration-support'`.
36
37
  *
37
38
  * Example:
38
39
  *
39
40
  * ```ts
40
- * import { withDefaults, WithLegacy } from '@ember-data/model/migration-support';
41
- * import { Type } from '@warp-drive/core-types/symbols';
42
- * import type { HasMany } from '@ember-data/model';
41
+ * import { withDefaults, WithLegacy } from '@warp-drive/legacy/model/migration-support';
42
+ * import { Type } from '@warp-drive/core/types/symbols';
43
+ * import type { HasMany } from '@@warp-drive/legacy/model';
43
44
  *
44
45
  * export const UserSchema = withDefaults({
45
46
  * type: 'user',
@@ -156,14 +157,14 @@ legacySupport[Type] = '@legacy';
156
157
  /**
157
158
  * A function which adds the necessary fields to a schema and marks it as
158
159
  * being in LegacyMode. This is used to support the legacy features of
159
- * @ember-data/model while migrating to WarpDrive.
160
+ * @warp-drive/legacy/model while migrating to WarpDrive.
160
161
  *
161
162
  * Example:
162
163
  *
163
164
  * ```ts
164
- * import { withDefaults, WithLegacy } from '@ember-data/model/migration-support';
165
- * import { Type } from '@warp-drive/core-types/symbols';
166
- * import type { HasMany } from '@ember-data/model';
165
+ * import { withDefaults, WithLegacy } from '@warp-drive/legacy/model/migration-support';
166
+ * import { Type } from '@warp-drive/core/types/symbols';
167
+ * import type { HasMany } from '@warp-drive/legacy/model';
167
168
  *
168
169
  * export const UserSchema = withDefaults({
169
170
  * type: 'user',
@@ -198,13 +199,13 @@ legacySupport[Type] = '@legacy';
198
199
  * it requires with the schema service.
199
200
  *
200
201
  * ```ts
201
- * import { registerDerivations } from '@ember-data/model/migration-support';
202
+ * import { registerDerivations } from '@warp-drive/legacy/model/migration-support';
202
203
  *
203
204
  * registerDerivations(schema);
204
205
  * ```
205
206
  *
206
- * @param {LegacyResourceSchema} schema The schema to add legacy support to.
207
- * @return {LegacyResourceSchema} The schema with legacy support added.
207
+ * @param schema The schema to add legacy support to.
208
+ * @return The schema with legacy support added.
208
209
  * @public
209
210
  */
210
211
  function withDefaults(schema) {
@@ -248,6 +249,26 @@ function withDefaults(schema) {
248
249
  schema.objectExtensions.push('deprecated-model-behaviors');
249
250
  return schema;
250
251
  }
252
+
253
+ /**
254
+ * Adds the necessasary fields to the schema for supporting
255
+ * the deprecated request methods on LegacyMode schemas.
256
+ *
257
+ * Use this instead of `withDefaults` to add the fields
258
+ * and behaviors necessary to support Model-Like capabilities.
259
+ *
260
+ * ```ts
261
+ * import { withRestoredDeprecatedModelRequestBehaviors } from '@warp-drive/legacy/model/migration-support';
262
+ *
263
+ * export const UserSchema = withRestoredDeprecatedModelRequestBehaviors({
264
+ * type: 'user',
265
+ * fields: [
266
+ * { name: 'firstName', kind: 'attribute' },
267
+ * { name: 'lastName', kind: 'attribute' },
268
+ * ]
269
+ * });
270
+ * ```
271
+ */
251
272
  function withRestoredDeprecatedModelRequestBehaviors(schema) {
252
273
  schema.legacy = true;
253
274
  schema.identity = {
@@ -293,13 +314,10 @@ function withRestoredDeprecatedModelRequestBehaviors(schema) {
293
314
 
294
315
  /**
295
316
  * A function which registers the necessary derivations to support
296
- * the LegacyMode features of @ember-data/model while migrating to WarpDrive.
297
- *
298
- * This must be called in order to use the fields added by:
317
+ * the LegacyMode features of @warp-drive/legacy/model while migrating to WarpDrive.
299
318
  *
300
- * ```ts
301
- * import { withDefaults } from '@ember-data/model/migration-support';
302
- * ```
319
+ * This must be called in order to use the fields added by {@link withDefaults} or
320
+ * {@link withRestoredDeprecatedModelRequestBehaviors}.
303
321
  *
304
322
  * @param schema The schema service to register the derivations with.
305
323
  * @public
@@ -398,8 +416,8 @@ function registerDerivations(schema) {
398
416
  * provide their own schema information to the application.
399
417
  *
400
418
  * ```ts
401
- * import { DelegatingSchemaService } from '@ember-data/model/migration-support';
402
- * import { SchemaService } from '@warp-drive/schema-record';
419
+ * import { DelegatingSchemaService } from '@warp-drive/legacy/model/migration-support';
420
+ * import { SchemaService } from '@warp-drive/core/reactive';
403
421
  *
404
422
  * class AppStore extends Store {
405
423
  * createSchemaService() {
@@ -417,7 +435,9 @@ function registerDerivations(schema) {
417
435
  */
418
436
 
419
437
  class DelegatingSchemaService {
438
+ /** @internal */
420
439
  _preferred;
440
+ /** @internal */
421
441
  _secondary;
422
442
  constructor(store, schema) {
423
443
  this._preferred = schema;
@@ -452,6 +472,15 @@ class DelegatingSchemaService {
452
472
  }
453
473
  return this._secondary.fields(resource);
454
474
  }
475
+ cacheFields(resource) {
476
+ if (this._preferred.hasResource?.(resource)) {
477
+ // @ts-expect-error
478
+ return this._preferred.cacheFields?.(resource);
479
+ }
480
+
481
+ // @ts-expect-error
482
+ return this._secondary.cacheFields?.(resource);
483
+ }
455
484
  transformation(field) {
456
485
  return this._preferred.transformation(field);
457
486
  }
@@ -482,6 +511,9 @@ class DelegatingSchemaService {
482
511
  registerHashFn(hashFn) {
483
512
  this._preferred.registerHashFn(hashFn);
484
513
  }
514
+ CAUTION_MEGA_DANGER_ZONE_hasExtension(ext) {
515
+ return this._preferred.CAUTION_MEGA_DANGER_ZONE_hasExtension(ext);
516
+ }
485
517
  CAUTION_MEGA_DANGER_ZONE_registerExtension(extension) {
486
518
  this._preferred.CAUTION_MEGA_DANGER_ZONE_registerExtension(extension);
487
519
  }