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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (54) hide show
  1. package/README.md +6 -3
  2. package/declarations/adapter/json-api.d.ts +4 -6
  3. package/declarations/adapter/rest.d.ts +5 -8
  4. package/declarations/adapter.d.ts +4 -6
  5. package/declarations/compat/-private.d.ts +1 -1
  6. package/declarations/compat/extensions.d.ts +1 -1
  7. package/declarations/compat/legacy-network-handler/minimum-adapter-interface.d.ts +7 -9
  8. package/declarations/compat/legacy-network-handler/minimum-serializer-interface.d.ts +20 -30
  9. package/declarations/compat/utils.d.ts +17 -17
  10. package/declarations/compat.d.ts +32 -8
  11. package/declarations/index.d.ts +53 -0
  12. package/declarations/model/-private/attr.d.ts +5 -6
  13. package/declarations/model/-private/belongs-to.d.ts +4 -5
  14. package/declarations/model/-private/has-many.d.ts +4 -5
  15. package/declarations/model/-private/hooks.d.ts +1 -1
  16. package/declarations/model/-private/model.d.ts +8 -8
  17. package/declarations/model/-private/record-state.d.ts +1 -1
  18. package/declarations/model/-private/references/belongs-to.d.ts +1 -1
  19. package/declarations/model/-private/references/has-many.d.ts +1 -1
  20. package/declarations/model/migration-support.d.ts +4 -2
  21. package/declarations/serializer/-private/embedded-records-mixin.d.ts +0 -5
  22. package/declarations/serializer/-private/transforms/boolean.d.ts +2 -2
  23. package/declarations/serializer/-private/transforms/date.d.ts +2 -2
  24. package/declarations/serializer/-private/transforms/number.d.ts +1 -1
  25. package/declarations/serializer/-private/transforms/string.d.ts +1 -1
  26. package/declarations/serializer/json-api.d.ts +4 -6
  27. package/declarations/serializer/json.d.ts +6 -8
  28. package/declarations/serializer/rest.d.ts +4 -6
  29. package/declarations/serializer.d.ts +8 -11
  30. package/dist/{-private-8UmnAf9J.js → -private-B1pSSN52.js} +1 -1
  31. package/dist/adapter/-private.js +1 -1
  32. package/dist/adapter/error.js +5 -6
  33. package/dist/adapter/json-api.js +4 -1
  34. package/dist/adapter/rest.js +6 -9
  35. package/dist/adapter.js +4 -6
  36. package/dist/compat/-private.js +1 -1
  37. package/dist/compat/utils.js +17 -17
  38. package/dist/compat.js +55 -38
  39. package/dist/{errors-8kD2mSe_.js → errors-COviC59J.js} +3 -3
  40. package/dist/hooks-Bp8SIQBU.js +74 -0
  41. package/dist/index.js +178 -0
  42. package/dist/{json-Et4mt_LM.js → json-BHxlccxF.js} +8 -12
  43. package/dist/model/-private.js +1 -1
  44. package/dist/model/migration-support.js +6 -4
  45. package/dist/model.js +18 -90
  46. package/dist/{schema-provider-DQu4Rjco.js → schema-provider-JlCneqZH.js} +8 -10
  47. package/dist/{serialize-into-hash-CS0MIv4F.js → serialize-into-hash-BnYvPex3.js} +1 -1
  48. package/dist/serializer/json-api.js +11 -38
  49. package/dist/serializer/json.js +1 -1
  50. package/dist/serializer/rest.js +5 -12
  51. package/dist/serializer/transform.js +15 -6
  52. package/dist/serializer.js +8 -12
  53. package/dist/store.js +3 -0
  54. package/package.json +7 -7
@@ -2,7 +2,7 @@ import { Context } from '@warp-drive/core/reactive/-private';
2
2
  import { memoized, defineSignal, assertPrivateStore, defineNonEnumerableSignal, isResourceKey, recordIdentifierFor, isPrivateStore, storeFor, fastPush, createLegacyManyArray, notifyInternalSignal } from '@warp-drive/core/store/-private';
3
3
  import { getOrSetGlobal } from '@warp-drive/core/types/-private';
4
4
  import { EnableHydration } from '@warp-drive/core/types/request';
5
- import { u as upgradeStore } from "./-private-8UmnAf9J.js";
5
+ import { u as upgradeStore } from "./-private-B1pSSN52.js";
6
6
  import { computed, get } from '@ember/object';
7
7
  import PromiseProxyMixin from '@ember/object/promise-proxy-mixin';
8
8
  import ObjectProxy from '@ember/object/proxy';
@@ -632,7 +632,7 @@ class HasManyReference {
632
632
  }
633
633
 
634
634
  /**
635
- `push` can be used to update the data in the relationship and EmberData
635
+ `push` can be used to update the data in the relationship and WarpDrive
636
636
  will treat the new data as the canonical value of this relationship on
637
637
  the backend. An empty array will signify the canonical value should be
638
638
  empty.
@@ -1231,7 +1231,7 @@ class BelongsToReference {
1231
1231
  }
1232
1232
 
1233
1233
  /**
1234
- `push` can be used to update the data in the relationship and EmberData
1234
+ `push` can be used to update the data in the relationship and WarpDrive
1235
1235
  will treat the new data as the canonical value of this relationship on
1236
1236
  the backend. A value of `null` (e.g. `{ data: null }`) can be passed to
1237
1237
  clear the relationship.
@@ -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-JlCneqZH.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,178 @@
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-COviC59J.js";
13
+ import "./schema-provider-JlCneqZH.js";
14
+ import { i as instantiateRecord, t as teardownRecord, m as modelFor } from "./hooks-Bp8SIQBU.js";
15
+ import { registerDerivations as registerDerivations$1, DelegatingSchemaService } from './model/migration-support.js';
16
+ import { restoreDeprecatedStoreBehaviors } from './store.js';
17
+
18
+ /**
19
+ * @module
20
+ * @mergeModuleWith <project>
21
+ */
22
+
23
+ /**
24
+ * Use the legacy store with the given options.
25
+ */
26
+ function useLegacyStore(options, StoreKlass = Store) {
27
+ macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
28
+ if (!test) {
29
+ throw new Error(`If legacyRequests is true, linksMode must be false`);
30
+ }
31
+ })(!(options.linksMode && options.legacyRequests)) : {};
32
+ class LegacyConfiguredStore extends StoreKlass {
33
+ requestManager = new RequestManager().use([options.linksMode ? null : LegacyNetworkHandler, ...(options.handlers ?? []), Fetch].filter(Boolean)).useCache(CacheHandler);
34
+ lifetimes = options.policy ?? new DefaultCachePolicy({
35
+ apiCacheHardExpires: 15 * 60 * 1000,
36
+ // 15 minutes
37
+ apiCacheSoftExpires: 1 * 30 * 1000,
38
+ // 30 seconds
39
+ constraints: {
40
+ headers: {
41
+ 'X-WarpDrive-Expires': true,
42
+ 'Cache-Control': true,
43
+ Expires: true
44
+ }
45
+ }
46
+ });
47
+ createSchemaService() {
48
+ // prepare for PolarisMode
49
+ const schema = new SchemaService();
50
+ registerDerivations(schema);
51
+ if (options.schemas) schema.registerResources(options.schemas);
52
+ if (options.traits) {
53
+ for (const trait of options.traits) {
54
+ schema.registerTrait(trait);
55
+ }
56
+ }
57
+ if (options.derivations) {
58
+ for (const derivation of options.derivations) {
59
+ schema.registerDerivation(derivation);
60
+ }
61
+ }
62
+ if (options.transformations) {
63
+ for (const transformation of options.transformations) {
64
+ schema.registerTransformation(transformation);
65
+ }
66
+ }
67
+ if (options.hashFns) {
68
+ for (const hashFn of options.hashFns) {
69
+ schema.registerHashFn(hashFn);
70
+ }
71
+ }
72
+ if (options.CAUTION_MEGA_DANGER_ZONE_extensions) {
73
+ for (const extension of options.CAUTION_MEGA_DANGER_ZONE_extensions) {
74
+ schema.CAUTION_MEGA_DANGER_ZONE_registerExtension(extension);
75
+ }
76
+ }
77
+
78
+ // Add support for LegacyMode ReactiveResource with Maximal coverage
79
+ // for upgrading from 4.x
80
+ registerDerivations$1(schema);
81
+ schema.CAUTION_MEGA_DANGER_ZONE_registerExtension(EmberArrayLikeExtension);
82
+ schema.CAUTION_MEGA_DANGER_ZONE_registerExtension(EmberObjectArrayExtension);
83
+ schema.CAUTION_MEGA_DANGER_ZONE_registerExtension(EmberObjectExtension);
84
+
85
+ // Add fallback for Models
86
+ return new DelegatingSchemaService(this, schema);
87
+ }
88
+ createCache(capabilities) {
89
+ // eslint-disable-next-line new-cap
90
+ return new options.cache(capabilities);
91
+ }
92
+ instantiateRecord(key, createArgs) {
93
+ if (this.schema.isDelegated(key)) {
94
+ return instantiateRecord.call(this, key, createArgs);
95
+ }
96
+ return instantiateRecord$1(this, key, createArgs);
97
+ }
98
+ teardownRecord(record) {
99
+ const key = recordIdentifierFor(record);
100
+ if (this.schema.isDelegated(key)) {
101
+ return teardownRecord.call(this, record);
102
+ }
103
+ return teardownRecord$1(record);
104
+ }
105
+ modelFor(type) {
106
+ assertType(this.schema, type);
107
+ macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
108
+ if (!test) {
109
+ throw new Error(`modelFor should only be used to lookup legacy models when in linksMode`);
110
+ }
111
+ })(!options.linksMode || this.schema.isDelegated({
112
+ type
113
+ })) : {};
114
+ return modelFor.call(this, type) || super.modelFor(type);
115
+ }
116
+ adapterFor(modelName, _allowMissing) {
117
+ macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
118
+ if (!test) {
119
+ throw new Error(`useLegacyStore was setup in linksMode. linksMode assumes that all requests have been migrated away from adapters and serializers.`);
120
+ }
121
+ })(!options.linksMode) : {};
122
+ // @ts-expect-error
123
+ return adapterFor.call(this, modelName, _allowMissing);
124
+ }
125
+ serializerFor(...args) {
126
+ macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
127
+ if (!test) {
128
+ throw new Error(`useLegacyStore was setup in linksMode. linksMode assumes that all requests have been migrated away from adapters and serializers.`);
129
+ }
130
+ })(!options.linksMode) : {};
131
+ return serializerFor.call(this, ...args);
132
+ }
133
+ pushPayload(...args) {
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
+ return pushPayload.call(this, ...args);
140
+ }
141
+ normalize(...args) {
142
+ macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
143
+ if (!test) {
144
+ throw new Error(`useLegacyStore was setup in linksMode. linksMode assumes that all requests have been migrated away from adapters and serializers.`);
145
+ }
146
+ })(!options.linksMode) : {};
147
+ return normalize.call(this, ...args);
148
+ }
149
+ serializeRecord(...args) {
150
+ macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
151
+ if (!test) {
152
+ throw new Error(`useLegacyStore was setup in linksMode. linksMode assumes that all requests have been migrated away from adapters and serializers.`);
153
+ }
154
+ })(!options.linksMode) : {};
155
+ return serializeRecord.call(this, ...args);
156
+ }
157
+ destroy() {
158
+ if (!options.linksMode) {
159
+ cleanup.call(this);
160
+ }
161
+ super.destroy();
162
+ }
163
+ }
164
+ if (options.legacyRequests) {
165
+ restoreDeprecatedStoreBehaviors(LegacyConfiguredStore);
166
+ }
167
+ return LegacyConfiguredStore;
168
+ }
169
+ function assertType(schema, type) {
170
+ macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
171
+ if (!test) {
172
+ throw new Error(`Expected type ${type} to be a valid ResourceType`);
173
+ }
174
+ })(schema.hasResource({
175
+ type
176
+ })) : {};
177
+ }
178
+ 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/emberjs/data/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.
@@ -159,7 +157,7 @@ const JSONSerializer = Serializer.extend({
159
157
  }
160
158
  ```
161
159
  When serialized:
162
- ```javascript
160
+ ```js
163
161
  {
164
162
  "firstName": "Harry",
165
163
  "lastName": "Houdini",
@@ -170,9 +168,7 @@ const JSONSerializer = Serializer.extend({
170
168
  Setting `serialize` to `true` enforces serialization for hasMany
171
169
  relationships even if it's neither a many-to-many nor many-to-none
172
170
  relationship.
173
- @property attrs
174
- @public
175
- @type {Object}
171
+ @public
176
172
  */
177
173
  mergedProperties: ['attrs'],
178
174
  /**
@@ -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-COviC59J.js";
@@ -4,8 +4,8 @@ import { Context } from '@warp-drive/core/reactive/-private';
4
4
  import { notifyInternalSignal, assertPrivateStore } from '@warp-drive/core/store/-private';
5
5
  import { getOrSetGlobal } from '@warp-drive/core/types/-private';
6
6
  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";
7
+ import { l as lookupLegacySupport, E as Errors } from "../errors-COviC59J.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, i as deleteRecord, R as RecordState, j as changedAttributes, k as belongsTo, l as createSnapshot } from "../schema-provider-JlCneqZH.js";
9
9
  import { macroCondition, getGlobalConfig } from '@embroider/macros';
10
10
 
11
11
  /**
@@ -417,7 +417,9 @@ function registerDerivations(schema) {
417
417
  */
418
418
 
419
419
  class DelegatingSchemaService {
420
+ /** @internal */
420
421
  _preferred;
422
+ /** @internal */
421
423
  _secondary;
422
424
  constructor(store, schema) {
423
425
  this._preferred = schema;
@@ -502,7 +504,7 @@ class DelegatingSchemaService {
502
504
  * We do think a generalized `kind` registration system would be useful,
503
505
  * but we have not yet designed it.
504
506
  *
505
- * See https://github.com/emberjs/data/issues/9534
507
+ * See https://github.com/warp-drive-data/warp-drive/issues/9534
506
508
  *
507
509
  * @internal
508
510
  */
@@ -519,7 +521,7 @@ class DelegatingSchemaService {
519
521
  * We do think a generalized `kind` registration system would be useful,
520
522
  * but we have not yet designed it.
521
523
  *
522
- * See https://github.com/emberjs/data/issues/9534
524
+ * See https://github.com/warp-drive-data/warp-drive/issues/9534
523
525
  *
524
526
  * @internal
525
527
  */
package/dist/model.js CHANGED
@@ -4,12 +4,11 @@ import { RecordStore } from '@warp-drive/core/types/symbols';
4
4
  import { i as isElementDescriptor, n as normalizeModelName } from "./util-Dul6TZts.js";
5
5
  import { macroCondition, getGlobalConfig } from '@embroider/macros';
6
6
  import { warn, deprecate } from '@ember/debug';
7
- import { assertPrivateStore, setRecordIdentifier, StoreMap } from '@warp-drive/core/store/-private';
8
- import { l as lookupLegacySupport } from "./errors-8kD2mSe_.js";
7
+ import { assertPrivateStore } from '@warp-drive/core/store/-private';
8
+ import { l as lookupLegacySupport } from "./errors-COviC59J.js";
9
9
  import { singularize, dasherize } from '@warp-drive/utilities/string';
10
- import { l as getModelFactory } from "./schema-provider-DQu4Rjco.js";
11
- export { M as Model, b as buildSchema, M as default, m as restoreDeprecatedModelRequestBehaviors } from "./schema-provider-DQu4Rjco.js";
12
- import { setOwner, getOwner } from '@ember/application';
10
+ export { M as Model, b as buildSchema, M as default, m as restoreDeprecatedModelRequestBehaviors } from "./schema-provider-JlCneqZH.js";
11
+ export { i as instantiateRecord, m as modelFor, t as teardownRecord } from "./hooks-Bp8SIQBU.js";
13
12
  function _attr(type, options) {
14
13
  if (typeof type === 'object') {
15
14
  options = type;
@@ -87,12 +86,12 @@ function _attr(type, options) {
87
86
  */
88
87
 
89
88
  /**
90
- `attr` defines an attribute on a [Model](/ember-data/release/classes/Model).
89
+ `attr` defines an attribute on a {@link Model}.
91
90
  By default, attributes are passed through as-is, however you can specify an
92
91
  optional type to have the value automatically transformed.
93
- EmberData ships with four basic transform types: `string`, `number`,
92
+ WarpDrive ships with four basic transform types: `string`, `number`,
94
93
  `boolean` and `date`. You can define your own transforms by subclassing
95
- [Transform](/ember-data/release/classes/Transform).
94
+ {@link Transform}.
96
95
 
97
96
  Note that you cannot use `attr` to define an attribute of `id`.
98
97
 
@@ -169,9 +168,8 @@ function _attr(type, options) {
169
168
  ```
170
169
 
171
170
  @public
172
- @param {String|Object} type the attribute type
173
- @param {Object} options a hash of options
174
- @return {Attribute}
171
+ @param type the attribute type
172
+ @param options a hash of options
175
173
  */
176
174
 
177
175
  // see note on DataDecorator for why void
@@ -258,7 +256,7 @@ function _belongsTo(type, options) {
258
256
 
259
257
  /**
260
258
  `belongsTo` is used to define One-To-One and One-To-Many, and One-To-None
261
- relationships on a [Model](/ember-data/release/classes/Model).
259
+ relationships on a {@link Model}.
262
260
 
263
261
  `belongsTo` takes a configuration hash as a second parameter, currently
264
262
  supported options are:
@@ -340,7 +338,7 @@ function _belongsTo(type, options) {
340
338
 
341
339
  #### Sync vs Async Relationships
342
340
 
343
- EmberData fulfills relationships using resource data available in
341
+ WarpDrive fulfills relationships using resource data available in
344
342
  the cache.
345
343
 
346
344
  Sync relationships point directly to the known related resources.
@@ -408,9 +406,8 @@ function _belongsTo(type, options) {
408
406
  type each record satisfies on both sides.
409
407
 
410
408
  @public
411
- @param {String} type (optional) the name of the related resource
412
- @param {Object} options (optional) a hash of options
413
- @return {PropertyDescriptor} relationship
409
+ @param type the name of the related resource
410
+ @param options a hash of options
414
411
  */
415
412
 
416
413
  // export function belongsTo<K extends Promise<unknown>, T extends Awaited<K> = Awaited<K>>(
@@ -497,7 +494,7 @@ function _hasMany(type, options) {
497
494
 
498
495
  /**
499
496
  `hasMany` is used to define Many-To-One and Many-To-Many, and Many-To-None
500
- relationships on a [Model](/ember-data/release/classes/Model).
497
+ relationships on a {@link Model}.
501
498
 
502
499
  `hasMany` takes a configuration hash as a second parameter, currently
503
500
  supported options are:
@@ -580,7 +577,7 @@ function _hasMany(type, options) {
580
577
 
581
578
  #### Sync vs Async Relationships
582
579
 
583
- EmberData fulfills relationships using resource data available in
580
+ WarpDrive fulfills relationships using resource data available in
584
581
  the cache.
585
582
 
586
583
  Sync relationships point directly to the known related resources.
@@ -648,9 +645,8 @@ function _hasMany(type, options) {
648
645
  type each record satisfies on both sides.
649
646
 
650
647
  @public
651
- @param {String} type (optional) the name of the related resource
652
- @param {Object} options (optional) a hash of options
653
- @return {PropertyDescriptor} relationship
648
+ @param type the name of the related resource
649
+ @param options a hash of options
654
650
  */
655
651
 
656
652
  // export function hasMany<K extends Promise<unknown>, T extends Awaited<K> = Awaited<K>>(
@@ -668,72 +664,4 @@ function hasMany(type, options) {
668
664
  }
669
665
  return _hasMany(type, options);
670
666
  }
671
- function instantiateRecord(identifier, createRecordArgs) {
672
- const type = identifier.type;
673
-
674
- // TODO deprecate allowing unknown args setting
675
- const createOptions = {
676
- _createProps: createRecordArgs,
677
- // TODO @deprecate consider deprecating accessing record properties during init which the below is necessary for
678
- _secretInit: {
679
- identifier,
680
- store: this,
681
- cb: secretInit
682
- }
683
- };
684
-
685
- // ensure that `getOwner(this)` works inside a model instance
686
- setOwner(createOptions, getOwner(this));
687
- const factory = getModelFactory(this, type);
688
- macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
689
- if (!test) {
690
- throw new Error(`No model was found for '${type}'`);
691
- }
692
- })(factory) : {};
693
- return factory.class.create(createOptions);
694
- }
695
- function teardownRecord(record) {
696
- macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
697
- if (!test) {
698
- throw new Error(`expected to receive an instance of Model from @ember-data/model. If using a custom model make sure you implement teardownRecord`);
699
- }
700
- })('destroy' in record) : {};
701
- record.destroy();
702
- }
703
- function modelFor(modelName) {
704
- assertPrivateStore(this);
705
- macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
706
- if (!test) {
707
- throw new Error(`Attempted to call store.modelFor(), but the store instance has already been destroyed.`);
708
- }
709
- })(!this.isDestroyed && !this.isDestroying) : {};
710
- macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
711
- if (!test) {
712
- throw new Error(`You need to pass a model name to the store's modelFor method`);
713
- }
714
- })(modelName) : {};
715
- macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
716
- if (!test) {
717
- throw new Error(`Please pass a proper model name to the store's modelFor method`);
718
- }
719
- })(typeof modelName === 'string' && modelName.length) : {};
720
- const type = normalizeModelName(modelName);
721
- const maybeFactory = getModelFactory(this, type);
722
- const klass = maybeFactory && maybeFactory.class ? maybeFactory.class : null;
723
- const ignoreType = !klass || !klass.isModel || this._forceShim;
724
- if (!ignoreType) {
725
- return klass;
726
- }
727
- macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
728
- if (!test) {
729
- throw new Error(`No model was found for '${type}' and no schema handles the type`);
730
- }
731
- })(this.schema.hasResource({
732
- type
733
- })) : {};
734
- }
735
- function secretInit(record, identifier, store) {
736
- setRecordIdentifier(record, identifier);
737
- StoreMap.set(record, store);
738
- }
739
- export { attr, belongsTo, hasMany, instantiateRecord, modelFor, teardownRecord };
667
+ export { attr, belongsTo, hasMany };
@@ -4,8 +4,8 @@ import EmberObject from '@ember/object';
4
4
  import { recordIdentifierFor, storeFor } from '@warp-drive/core';
5
5
  import { assertPrivateStore, notifyInternalSignal, peekInternalSignal, withSignalStore, recordIdentifierFor as recordIdentifierFor$1, gate, memoized, defineSignal, coerceId, entangleSignal, defineGate } from '@warp-drive/core/store/-private';
6
6
  import { RecordStore } from '@warp-drive/core/types/symbols';
7
- import { l as lookupLegacySupport, L as LEGACY_SUPPORT, E as Errors } from "./errors-8kD2mSe_.js";
8
- import { u as upgradeStore, F as FetchManager } from "./-private-8UmnAf9J.js";
7
+ import { l as lookupLegacySupport, L as LEGACY_SUPPORT, E as Errors } from "./errors-COviC59J.js";
8
+ import { u as upgradeStore, F as FetchManager } from "./-private-B1pSSN52.js";
9
9
  import { macroCondition, getGlobalConfig } from '@embroider/macros';
10
10
  import { cacheFor } from '@ember/object/internals';
11
11
  import { Context } from '@warp-drive/core/reactive/-private';
@@ -254,7 +254,7 @@ function isInvalidError(error) {
254
254
  }
255
255
 
256
256
  /**
257
- Historically EmberData managed a state machine
257
+ Historically WarpDrive managed a state machine
258
258
  for each record, the localState for which
259
259
  was reflected onto Model.
260
260
 
@@ -680,11 +680,6 @@ function computeOnce(target, propertyName, desc) {
680
680
  };
681
681
  return desc;
682
682
  }
683
-
684
- /**
685
- * @noInheritDoc
686
- */
687
-
688
683
  /**
689
684
  * Base class from which Models can be defined.
690
685
  *
@@ -727,7 +722,10 @@ function computeOnce(target, propertyName, desc) {
727
722
  * the class to use as the reactive object for data of resource
728
723
  * of that type.
729
724
  *
725
+ * @public
730
726
  * @noInheritDoc
727
+ * @hideconstructor
728
+ * @legacy
731
729
  */
732
730
  class Model extends EmberObject {
733
731
  /** @internal */
@@ -1255,7 +1253,7 @@ class Model extends EmberObject {
1255
1253
  /**
1256
1254
  Represents the model's class name as a string. This can be used to look up the model's class name through
1257
1255
  `Store`'s modelFor method.
1258
- `modelName` is generated for you by EmberData. It will be a lowercased, dasherized string.
1256
+ `modelName` is generated for you by WarpDrive. It will be a lowercased, dasherized string.
1259
1257
  For example:
1260
1258
  ```javascript
1261
1259
  store.modelFor('post').modelName; // 'post'
@@ -2337,4 +2335,4 @@ function getModelFactory(store, type) {
2337
2335
  }
2338
2336
  return factory;
2339
2337
  }
2340
- export { Model as M, RecordState as R, _save as _, save as a, buildSchema as b, _reload as c, reload as d, _destroyRecord as e, destroyRecord as f, deleteRecord as g, hasMany as h, changedAttributes as i, belongsTo as j, createSnapshot as k, getModelFactory as l, restoreDeprecatedModelRequestBehaviors as m, rollbackAttributes as r, serialize as s, unloadRecord as u };
2338
+ export { Model as M, RecordState as R, _save as _, save as a, buildSchema as b, _reload as c, reload as d, _destroyRecord as e, destroyRecord as f, getModelFactory as g, hasMany as h, deleteRecord as i, changedAttributes as j, belongsTo as k, createSnapshot as l, restoreDeprecatedModelRequestBehaviors as m, rollbackAttributes as r, serialize as s, unloadRecord as u };
@@ -1,7 +1,7 @@
1
1
  import { warn } from '@ember/debug';
2
2
  import { macroCondition, getGlobalConfig } from '@embroider/macros';
3
3
  import '@warp-drive/core/reactive/-private';
4
- import "./-private-8UmnAf9J.js";
4
+ import "./-private-B1pSSN52.js";
5
5
  import '@warp-drive/core/store/-private';
6
6
  const newline = /\r?\n/;
7
7
  function parseResponseHeaders(headersString) {