@ember-data/model 5.4.0-alpha.64 → 5.4.0-alpha.70
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.
- package/addon-main.cjs +5 -0
- package/blueprints/model/index.js +18 -5
- package/blueprints/model-test/index.js +16 -10
- package/blueprints/model-test/qunit-files/__root__/__path__/__test__.js +4 -5
- package/{addon → dist}/-private.js +2 -2
- package/{addon/has-many-BuTJfT5a.js → dist/has-many-CR10J-rp.js} +49 -26
- package/dist/has-many-CR10J-rp.js.map +1 -0
- package/dist/hooks-BNw6VdLr.js +75 -0
- package/dist/hooks-BNw6VdLr.js.map +1 -0
- package/dist/hooks.js +2 -0
- package/{addon → dist}/hooks.js.map +1 -1
- package/dist/index.js +4 -0
- package/{addon → dist}/index.js.map +1 -1
- package/dist/migration-support.js +211 -0
- package/dist/migration-support.js.map +1 -0
- package/{addon/model-DJ9C4aZ-.js → dist/model-CsbDNxap.js} +821 -250
- package/dist/model-CsbDNxap.js.map +1 -0
- package/dist/schema-provider-C5vR7TBr.js +256 -0
- package/dist/schema-provider-C5vR7TBr.js.map +1 -0
- package/package.json +39 -59
- package/unstable-preview-types/-private/attr.d.ts.map +1 -1
- package/unstable-preview-types/-private/belongs-to.d.ts.map +1 -1
- package/unstable-preview-types/-private/debug/assert-polymorphic-type.d.ts +2 -2
- package/unstable-preview-types/-private/debug/assert-polymorphic-type.d.ts.map +1 -1
- package/unstable-preview-types/-private/errors.d.ts +2 -5
- package/unstable-preview-types/-private/errors.d.ts.map +1 -1
- package/unstable-preview-types/-private/has-many.d.ts.map +1 -1
- package/unstable-preview-types/-private/hooks.d.ts.map +1 -1
- package/unstable-preview-types/-private/legacy-relationships-support.d.ts +16 -20
- package/unstable-preview-types/-private/legacy-relationships-support.d.ts.map +1 -1
- package/unstable-preview-types/-private/many-array.d.ts +11 -13
- package/unstable-preview-types/-private/many-array.d.ts.map +1 -1
- package/unstable-preview-types/-private/model-methods.d.ts +6 -5
- package/unstable-preview-types/-private/model-methods.d.ts.map +1 -1
- package/unstable-preview-types/-private/model.d.ts +38 -35
- package/unstable-preview-types/-private/model.d.ts.map +1 -1
- package/unstable-preview-types/-private/notify-changes.d.ts +1 -1
- package/unstable-preview-types/-private/notify-changes.d.ts.map +1 -1
- package/unstable-preview-types/-private/promise-belongs-to.d.ts +1 -2
- package/unstable-preview-types/-private/promise-belongs-to.d.ts.map +1 -1
- package/unstable-preview-types/-private/promise-many-array.d.ts +4 -4
- package/unstable-preview-types/-private/promise-many-array.d.ts.map +1 -1
- package/unstable-preview-types/-private/record-state.d.ts +3 -4
- package/unstable-preview-types/-private/record-state.d.ts.map +1 -1
- package/unstable-preview-types/-private/references/belongs-to.d.ts +4 -4
- package/unstable-preview-types/-private/references/belongs-to.d.ts.map +1 -1
- package/unstable-preview-types/-private/references/has-many.d.ts +7 -7
- package/unstable-preview-types/-private/references/has-many.d.ts.map +1 -1
- package/unstable-preview-types/-private/schema-provider.d.ts +46 -15
- package/unstable-preview-types/-private/schema-provider.d.ts.map +1 -1
- package/unstable-preview-types/-private/type-utils.d.ts +64 -0
- package/unstable-preview-types/-private/type-utils.d.ts.map +1 -0
- package/unstable-preview-types/-private.d.ts +4 -3
- package/unstable-preview-types/-private.d.ts.map +1 -1
- package/unstable-preview-types/index.d.ts +20 -20
- package/unstable-preview-types/index.d.ts.map +1 -1
- package/unstable-preview-types/migration-support.d.ts +45 -6
- package/unstable-preview-types/migration-support.d.ts.map +1 -1
- package/addon/has-many-BuTJfT5a.js.map +0 -1
- package/addon/hooks-BMoEt0SI.js +0 -176
- package/addon/hooks-BMoEt0SI.js.map +0 -1
- package/addon/hooks.js +0 -1
- package/addon/index.js +0 -3
- package/addon/migration-support.js +0 -118
- package/addon/migration-support.js.map +0 -1
- package/addon/model-DJ9C4aZ-.js.map +0 -1
- package/addon/util-CSYkrwfb.js +0 -35
- package/addon/util-CSYkrwfb.js.map +0 -1
- package/addon-main.js +0 -94
- package/unstable-preview-types/-private/promise-proxy-base.d.ts +0 -35
- /package/{addon → dist}/-private.js.map +0 -0
package/addon-main.cjs
ADDED
|
@@ -1,17 +1,28 @@
|
|
|
1
|
+
const path = require('path');
|
|
1
2
|
const EOL = require('os').EOL;
|
|
2
3
|
|
|
4
|
+
const { has } = require('@ember/edition-utils');
|
|
5
|
+
|
|
3
6
|
const inflection = require('inflection');
|
|
4
7
|
const stringUtils = require('ember-cli-string-utils');
|
|
5
|
-
const useEditionDetector = require('@ember-data/private-build-infra/src/utilities/edition-detector');
|
|
6
|
-
const { has } = require('@ember/edition-utils');
|
|
7
8
|
|
|
8
|
-
module.exports =
|
|
9
|
-
description: 'Generates an ember-data
|
|
9
|
+
module.exports = {
|
|
10
|
+
description: 'Generates an ember-data Model.',
|
|
10
11
|
|
|
11
12
|
anonymousOptions: ['name', 'attr:type'],
|
|
12
13
|
|
|
13
14
|
root: __dirname,
|
|
14
15
|
|
|
16
|
+
filesPath() {
|
|
17
|
+
let hasOctane = has('octane');
|
|
18
|
+
if (hasOctane && process.env.EMBER_EDITION === 'classic') {
|
|
19
|
+
hasOctane = false; //forcible override
|
|
20
|
+
}
|
|
21
|
+
let rootPath = hasOctane ? 'native-files' : 'files';
|
|
22
|
+
return path.join(__dirname, rootPath);
|
|
23
|
+
},
|
|
24
|
+
|
|
25
|
+
|
|
15
26
|
locals(options) {
|
|
16
27
|
let attrs = [];
|
|
17
28
|
let needs = [];
|
|
@@ -109,7 +120,7 @@ module.exports = useEditionDetector({
|
|
|
109
120
|
needs,
|
|
110
121
|
};
|
|
111
122
|
},
|
|
112
|
-
}
|
|
123
|
+
}
|
|
113
124
|
|
|
114
125
|
function nativeAttr(attr) {
|
|
115
126
|
let name = attr.name,
|
|
@@ -148,3 +159,5 @@ function classicAttr(attr) {
|
|
|
148
159
|
}
|
|
149
160
|
return propertyName + ': ' + result;
|
|
150
161
|
}
|
|
162
|
+
|
|
163
|
+
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
const path = require('path');
|
|
2
2
|
|
|
3
3
|
const testInfo = require('ember-cli-test-info');
|
|
4
|
-
const
|
|
5
|
-
const modulePrefixForProject = require('@ember-data/private-build-infra/src/utilities/module-prefix-for-project');
|
|
4
|
+
const { dasherize } = require('ember-cli-string-utils');
|
|
6
5
|
|
|
7
6
|
const ModelBlueprint = require('../model');
|
|
8
7
|
|
|
9
|
-
module.exports =
|
|
10
|
-
description: 'Generates
|
|
8
|
+
module.exports = {
|
|
9
|
+
description: 'Generates an EmberData Model unit test',
|
|
10
|
+
supportsAddon() { return false; },
|
|
11
11
|
|
|
12
12
|
root: __dirname,
|
|
13
13
|
|
|
14
|
-
fileMapTokens(
|
|
14
|
+
fileMapTokens() {
|
|
15
15
|
return {
|
|
16
16
|
__root__() {
|
|
17
17
|
return 'tests';
|
|
@@ -24,10 +24,16 @@ module.exports = useTestFrameworkDetector({
|
|
|
24
24
|
|
|
25
25
|
locals(options) {
|
|
26
26
|
const result = ModelBlueprint.locals.apply(this, arguments);
|
|
27
|
+
const modulePrefix = dasherize(options.project.config().modulePrefix);
|
|
28
|
+
return {
|
|
29
|
+
...result,
|
|
30
|
+
friendlyTestDescription: testInfo.description(options.entity.name, 'Unit', 'Model'),
|
|
31
|
+
modulePrefix,
|
|
32
|
+
};
|
|
33
|
+
},
|
|
27
34
|
|
|
28
|
-
|
|
29
|
-
|
|
35
|
+
filesPath() {
|
|
36
|
+
return path.join(__dirname, 'qunit-files')
|
|
37
|
+
}
|
|
38
|
+
};
|
|
30
39
|
|
|
31
|
-
return result;
|
|
32
|
-
},
|
|
33
|
-
});
|
|
@@ -1,14 +1,13 @@
|
|
|
1
|
-
import { module, test } from 'qunit';
|
|
2
|
-
|
|
3
1
|
import { setupTest } from '<%= modulePrefix %>/tests/helpers';
|
|
2
|
+
import { module, test } from 'qunit';
|
|
4
3
|
|
|
5
4
|
module('<%= friendlyTestDescription %>', function (hooks) {
|
|
6
5
|
setupTest(hooks);
|
|
7
6
|
|
|
8
7
|
// Replace this with your real tests.
|
|
9
8
|
test('it exists', function (assert) {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
assert.ok(model);
|
|
9
|
+
const store = this.owner.lookup('service:store');
|
|
10
|
+
const model = store.createRecord('<%= dasherizedModuleName %>', {});
|
|
11
|
+
assert.ok(model, 'model exists');
|
|
13
12
|
});
|
|
14
13
|
});
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { a as attr, b as belongsTo, h as hasMany } from "./has-many-
|
|
2
|
-
export { E as Errors, L as LEGACY_SUPPORT, R as ManyArray, M as Model, P as PromiseBelongsTo, a as PromiseManyArray, l as lookupLegacySupport } from "./model-
|
|
1
|
+
export { a as attr, b as belongsTo, h as hasMany } from "./has-many-CR10J-rp";
|
|
2
|
+
export { E as Errors, L as LEGACY_SUPPORT, R as ManyArray, M as Model, P as PromiseBelongsTo, a as PromiseManyArray, l as lookupLegacySupport } from "./model-CsbDNxap";
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import { assert, warn, deprecate } from '@ember/debug';
|
|
2
1
|
import { computed } from '@ember/object';
|
|
3
2
|
import { recordIdentifierFor } from '@ember-data/store';
|
|
4
3
|
import { peekCache } from '@ember-data/store/-private';
|
|
5
|
-
import {
|
|
6
|
-
import { macroCondition,
|
|
4
|
+
import { k as isElementDescriptor, n as normalizeModelName, l as lookupLegacySupport } from "./model-CsbDNxap";
|
|
5
|
+
import { macroCondition, getGlobalConfig } from '@embroider/macros';
|
|
6
|
+
import { warn, deprecate } from '@ember/debug';
|
|
7
7
|
import { RecordStore } from '@warp-drive/core-types/symbols';
|
|
8
|
-
import { l as lookupLegacySupport } from "./model-DJ9C4aZ-";
|
|
9
8
|
import { dasherize } from '@ember/string';
|
|
10
9
|
import { singularize } from 'ember-inflector';
|
|
11
10
|
|
|
@@ -28,7 +27,7 @@ function _attr(type, options) {
|
|
|
28
27
|
};
|
|
29
28
|
return computed({
|
|
30
29
|
get(key) {
|
|
31
|
-
if (macroCondition(
|
|
30
|
+
if (macroCondition(getGlobalConfig().WarpDrive.env.DEBUG)) {
|
|
32
31
|
if (['currentState'].includes(key)) {
|
|
33
32
|
throw new Error(`'${key}' is a reserved property name on instances of classes extending Model. Please choose a different property name for your attr on ${this.constructor.toString()}`);
|
|
34
33
|
}
|
|
@@ -39,13 +38,17 @@ function _attr(type, options) {
|
|
|
39
38
|
return peekCache(this).getAttr(recordIdentifierFor(this), key);
|
|
40
39
|
},
|
|
41
40
|
set(key, value) {
|
|
42
|
-
if (macroCondition(
|
|
41
|
+
if (macroCondition(getGlobalConfig().WarpDrive.env.DEBUG)) {
|
|
43
42
|
if (['currentState'].includes(key)) {
|
|
44
43
|
throw new Error(`'${key}' is a reserved property name on instances of classes extending Model. Please choose a different property name for your attr on ${this.constructor.toString()}`);
|
|
45
44
|
}
|
|
46
45
|
}
|
|
47
46
|
const identifier = recordIdentifierFor(this);
|
|
48
|
-
|
|
47
|
+
macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
|
|
48
|
+
if (!test) {
|
|
49
|
+
throw new Error(`Attempted to set '${key}' on the deleted record ${identifier.type}:${identifier.id} (${identifier.lid})`);
|
|
50
|
+
}
|
|
51
|
+
})(!this.currentState.isDeleted) : {};
|
|
49
52
|
const cache = peekCache(this);
|
|
50
53
|
const currentValue = cache.getAttr(identifier, key);
|
|
51
54
|
if (currentValue !== value) {
|
|
@@ -191,15 +194,21 @@ function attr(type, options, desc) {
|
|
|
191
194
|
// BelongsToDecoratorObject<getT>;
|
|
192
195
|
|
|
193
196
|
function _belongsTo(type, options) {
|
|
194
|
-
|
|
195
|
-
|
|
197
|
+
macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
|
|
198
|
+
if (!test) {
|
|
199
|
+
throw new Error(`Expected options.async from @belongsTo('${type}', options) to be a boolean`);
|
|
200
|
+
}
|
|
201
|
+
})(options && typeof options.async === 'boolean') : {};
|
|
202
|
+
macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
|
|
203
|
+
if (!test) {
|
|
204
|
+
throw new Error(`Expected options.inverse from @belongsTo('${type}', options) to be either null or the string type of the related resource.`);
|
|
205
|
+
}
|
|
206
|
+
})(options.inverse === null || typeof options.inverse === 'string' && options.inverse.length > 0) : {};
|
|
196
207
|
const meta = {
|
|
197
208
|
type: normalizeModelName(type),
|
|
198
|
-
isRelationship: true,
|
|
199
209
|
options: options,
|
|
200
210
|
kind: 'belongsTo',
|
|
201
|
-
name: '<Unknown BelongsTo>'
|
|
202
|
-
key: null
|
|
211
|
+
name: '<Unknown BelongsTo>'
|
|
203
212
|
};
|
|
204
213
|
return computed({
|
|
205
214
|
get(key) {
|
|
@@ -210,7 +219,7 @@ function _belongsTo(type, options) {
|
|
|
210
219
|
return null;
|
|
211
220
|
}
|
|
212
221
|
const support = lookupLegacySupport(this);
|
|
213
|
-
if (macroCondition(
|
|
222
|
+
if (macroCondition(getGlobalConfig().WarpDrive.env.DEBUG)) {
|
|
214
223
|
if (['currentState'].includes(key)) {
|
|
215
224
|
throw new Error(`'${key}' is a reserved property name on instances of classes extending Model. Please choose a different property name for your belongsTo on ${this.constructor.toString()}`);
|
|
216
225
|
}
|
|
@@ -229,7 +238,7 @@ function _belongsTo(type, options) {
|
|
|
229
238
|
},
|
|
230
239
|
set(key, value) {
|
|
231
240
|
const support = lookupLegacySupport(this);
|
|
232
|
-
if (macroCondition(
|
|
241
|
+
if (macroCondition(getGlobalConfig().WarpDrive.env.DEBUG)) {
|
|
233
242
|
if (['currentState'].includes(key)) {
|
|
234
243
|
throw new Error(`'${key}' is a reserved property name on instances of classes extending Model. Please choose a different property name for your belongsTo on ${this.constructor.toString()}`);
|
|
235
244
|
}
|
|
@@ -408,8 +417,12 @@ function _belongsTo(type, options) {
|
|
|
408
417
|
// ): RelationshipDecorator<K>;
|
|
409
418
|
|
|
410
419
|
function belongsTo(type, options) {
|
|
411
|
-
if (macroCondition(
|
|
412
|
-
|
|
420
|
+
if (macroCondition(getGlobalConfig().WarpDrive.env.DEBUG)) {
|
|
421
|
+
macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
|
|
422
|
+
if (!test) {
|
|
423
|
+
throw new Error(`belongsTo must be invoked with a type and options. Did you mean \`@belongsTo(${type}, { async: false, inverse: null })\`?`);
|
|
424
|
+
}
|
|
425
|
+
})(!isElementDescriptor(arguments)) : {};
|
|
413
426
|
}
|
|
414
427
|
return _belongsTo(type, options);
|
|
415
428
|
}
|
|
@@ -418,7 +431,7 @@ function belongsTo(type, options) {
|
|
|
418
431
|
@module @ember-data/model
|
|
419
432
|
*/
|
|
420
433
|
function normalizeType(type) {
|
|
421
|
-
if (macroCondition(
|
|
434
|
+
if (macroCondition(getGlobalConfig().WarpDrive.deprecations.DEPRECATE_NON_STRICT_TYPES)) {
|
|
422
435
|
const result = singularize(dasherize(type));
|
|
423
436
|
deprecate(`The resource type '${type}' is not normalized. Update your application code to use '${result}' instead of '${type}'.`, result === type, {
|
|
424
437
|
id: 'ember-data:deprecate-non-strict-types',
|
|
@@ -434,7 +447,11 @@ function normalizeType(type) {
|
|
|
434
447
|
return type;
|
|
435
448
|
}
|
|
436
449
|
function _hasMany(type, options) {
|
|
437
|
-
|
|
450
|
+
macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
|
|
451
|
+
if (!test) {
|
|
452
|
+
throw new Error(`Expected hasMany options.async to be a boolean`);
|
|
453
|
+
}
|
|
454
|
+
})(options && typeof options.async === 'boolean') : {};
|
|
438
455
|
|
|
439
456
|
// Metadata about relationships is stored on the meta of
|
|
440
457
|
// the relationship. This is used for introspection and
|
|
@@ -443,14 +460,12 @@ function _hasMany(type, options) {
|
|
|
443
460
|
const meta = {
|
|
444
461
|
type: normalizeType(type),
|
|
445
462
|
options,
|
|
446
|
-
isRelationship: true,
|
|
447
463
|
kind: 'hasMany',
|
|
448
|
-
name: '<Unknown BelongsTo>'
|
|
449
|
-
key: null
|
|
464
|
+
name: '<Unknown BelongsTo>'
|
|
450
465
|
};
|
|
451
466
|
return computed({
|
|
452
467
|
get(key) {
|
|
453
|
-
if (macroCondition(
|
|
468
|
+
if (macroCondition(getGlobalConfig().WarpDrive.env.DEBUG)) {
|
|
454
469
|
if (['currentState'].includes(key)) {
|
|
455
470
|
throw new Error(`'${key}' is a reserved property name on instances of classes extending Model. Please choose a different property name for your hasMany on ${this.constructor.toString()}`);
|
|
456
471
|
}
|
|
@@ -461,14 +476,18 @@ function _hasMany(type, options) {
|
|
|
461
476
|
return lookupLegacySupport(this).getHasMany(key);
|
|
462
477
|
},
|
|
463
478
|
set(key, records) {
|
|
464
|
-
if (macroCondition(
|
|
479
|
+
if (macroCondition(getGlobalConfig().WarpDrive.env.DEBUG)) {
|
|
465
480
|
if (['currentState'].includes(key)) {
|
|
466
481
|
throw new Error(`'${key}' is a reserved property name on instances of classes extending Model. Please choose a different property name for your hasMany on ${this.constructor.toString()}`);
|
|
467
482
|
}
|
|
468
483
|
}
|
|
469
484
|
const support = lookupLegacySupport(this);
|
|
470
485
|
const manyArray = support.getManyArray(key);
|
|
471
|
-
|
|
486
|
+
macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
|
|
487
|
+
if (!test) {
|
|
488
|
+
throw new Error(`You must pass an array of records to set a hasMany relationship`);
|
|
489
|
+
}
|
|
490
|
+
})(Array.isArray(records)) : {};
|
|
472
491
|
this[RecordStore]._join(() => {
|
|
473
492
|
manyArray.splice(0, manyArray.length, ...records);
|
|
474
493
|
});
|
|
@@ -644,8 +663,12 @@ function _hasMany(type, options) {
|
|
|
644
663
|
// ): RelationshipDecorator<K>;
|
|
645
664
|
|
|
646
665
|
function hasMany(type, options) {
|
|
647
|
-
if (macroCondition(
|
|
648
|
-
|
|
666
|
+
if (macroCondition(getGlobalConfig().WarpDrive.env.DEBUG)) {
|
|
667
|
+
macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
|
|
668
|
+
if (!test) {
|
|
669
|
+
throw new Error(`hasMany must be invoked with a type and options. Did you mean \`@hasMany(${type}, { async: false, inverse: null })\`?`);
|
|
670
|
+
}
|
|
671
|
+
})(!isElementDescriptor(arguments)) : {};
|
|
649
672
|
}
|
|
650
673
|
return _hasMany(type, options);
|
|
651
674
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"has-many-CR10J-rp.js","sources":["../src/-private/attr.ts","../src/-private/belongs-to.ts","../src/-private/has-many.ts"],"sourcesContent":["/**\n @module @ember-data/model\n*/\nimport { computed } from '@ember/object';\n\nimport { recordIdentifierFor } from '@ember-data/store';\nimport { peekCache } from '@ember-data/store/-private';\nimport { DEBUG } from '@warp-drive/build-config/env';\nimport { assert } from '@warp-drive/build-config/macros';\nimport type { ArrayValue, ObjectValue, PrimitiveValue, Value } from '@warp-drive/core-types/json/raw';\nimport type { TransformName } from '@warp-drive/core-types/symbols';\n\nimport type { Model } from './model';\nimport type { DecoratorPropertyDescriptor } from './util';\nimport { isElementDescriptor } from './util';\n\n/**\n * Options provided to the attr decorator are\n * supplied to the associated transform. Any\n * key-value pair is valid; however, it is highly\n * recommended to only use statically defined values\n * that could be serialized to JSON.\n *\n * If no transform is provided, the only valid\n * option is `defaultValue`.\n *\n * Examples:\n *\n * ```ts\n * class User extends Model {\n * @attr('string', { defaultValue: 'Anonymous' }) name;\n * @attr('date', { defaultValue: () => new Date() }) createdAt;\n * @attr({ defaultValue: () => ({}) }) preferences;\n * @attr('boolean') hasVerifiedEmail;\n * @attr address;\n * }\n *\n * @class NOTATHING\n * @typedoc\n */\nexport type AttrOptions<DV = PrimitiveValue | object | unknown[]> = {\n /**\n * The default value for this attribute.\n *\n * Default values can be provided as a value or a function that will be\n * executed to generate the default value.\n *\n * Default values *should not* be stateful (object, arrays, etc.) as\n * they will be shared across all instances of the record.\n *\n * @typedoc\n */\n defaultValue?: DV extends PrimitiveValue ? DV : () => DV;\n};\n\nfunction _attr(type?: string | AttrOptions, options?: AttrOptions & object) {\n if (typeof type === 'object') {\n options = type;\n type = undefined;\n } else {\n options = options || {};\n }\n\n const meta = {\n type: type,\n kind: 'attribute',\n isAttribute: true,\n options: options,\n key: null,\n };\n\n return computed({\n get(this: Model, key: string) {\n if (DEBUG) {\n if (['currentState'].includes(key)) {\n throw new Error(\n `'${key}' is a reserved property name on instances of classes extending Model. Please choose a different property name for your attr on ${this.constructor.toString()}`\n );\n }\n }\n if (this.isDestroyed || this.isDestroying) {\n return;\n }\n return peekCache(this).getAttr(recordIdentifierFor(this), key);\n },\n set(this: Model, key: string, value: Value) {\n if (DEBUG) {\n if (['currentState'].includes(key)) {\n throw new Error(\n `'${key}' is a reserved property name on instances of classes extending Model. Please choose a different property name for your attr on ${this.constructor.toString()}`\n );\n }\n }\n const identifier = recordIdentifierFor(this);\n assert(\n `Attempted to set '${key}' on the deleted record ${identifier.type}:${identifier.id} (${identifier.lid})`,\n !this.currentState.isDeleted\n );\n const cache = peekCache(this);\n\n const currentValue = cache.getAttr(identifier, key);\n if (currentValue !== value) {\n cache.setAttr(identifier, key, value);\n\n if (!this.isValid) {\n const { errors } = this;\n\n if (errors.get(key)) {\n errors.remove(key);\n this.currentState.cleanErrorRequests();\n }\n }\n }\n\n return value;\n },\n }).meta(meta);\n}\n\n// NOTE: Usage of Explicit ANY\n// -------------------------------------------------------------------\n// any is required here because we are the maximal not the minimal\n// subset of options allowed. If we used unknown, object, or\n// Record<string, unknown> we would get type errors when we try to\n// assert against a more specific implementation with precise options.\n// -------------------------------------------------------------------\n\ntype LooseTransformInstance<V, Raw, Name extends string> = {\n /**\n * value type must match the return type of the deserialize method\n *\n * @typedoc\n */\n // see note on Explicit ANY above\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n serialize: (value: V, options: any) => Raw;\n /**\n * defaultValue type must match the return type of the deserialize method\n *\n * @typedoc\n */\n // see note on Explicit ANY above\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n deserialize: (value: Raw, options: any) => V;\n\n [TransformName]: Name;\n};\nexport type TransformHasType = { [TransformName]: string };\n\nexport type TypedTransformInstance<V, T extends string> =\n | LooseTransformInstance<V, string, T>\n | LooseTransformInstance<V, number, T>\n | LooseTransformInstance<V, boolean, T>\n | LooseTransformInstance<V, null, T>\n | LooseTransformInstance<V, ObjectValue, T>\n | LooseTransformInstance<V, ArrayValue, T>;\n\n// see note on Explicit ANY above\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type GetMaybeDeserializeValue<T> = T extends { deserialize: (...args: any[]) => unknown }\n ? ReturnType<T['deserialize']>\n : never;\n\nexport type TypeFromInstance<T> = T extends TransformHasType ? T[typeof TransformName] : never;\nexport type OptionsFromInstance<T> =\n TypeFromInstance<T> extends never\n ? never\n : GetMaybeDeserializeValue<T> extends never\n ? never\n : T extends TypedTransformInstance<GetMaybeDeserializeValue<T>, TypeFromInstance<T>>\n ? Parameters<T['deserialize']>[1] & Parameters<T['serialize']>[1] & AttrOptions<ReturnType<T['deserialize']>>\n : never;\n\n/**\n * The return type of `void` is a lie to appease TypeScript. The actual return type\n * is a descriptor, but typescript incorrectly insists that decorator functions return\n * `void` or `any`.\n *\n * @typedoc\n */\nexport type DataDecorator = (target: object, key: string, desc?: DecoratorPropertyDescriptor) => void;\n\n/**\n `attr` defines an attribute on a [Model](/ember-data/release/classes/Model).\n By default, attributes are passed through as-is, however you can specify an\n optional type to have the value automatically transformed.\n EmberData ships with four basic transform types: `string`, `number`,\n `boolean` and `date`. You can define your own transforms by subclassing\n [Transform](/ember-data/release/classes/Transform).\n\n Note that you cannot use `attr` to define an attribute of `id`.\n\n `attr` takes an optional hash as a second parameter, currently\n supported options are:\n\n - `defaultValue`: Pass a string or a function to be called to set the attribute\n to a default value if and only if the key is absent from the payload response.\n\n Example\n\n ```app/models/user.js\n import Model, { attr } from '@ember-data/model';\n\n export default class UserModel extends Model {\n @attr('string') username;\n @attr('string') email;\n @attr('boolean', { defaultValue: false }) verified;\n }\n ```\n\n Default value can also be a function. This is useful it you want to return\n a new object for each attribute.\n\n ```app/models/user.js\n import Model, { attr } from '@ember-data/model';\n\n export default class UserModel extends Model {\n @attr('string') username;\n @attr('string') email;\n\n @attr({\n defaultValue() {\n return {};\n }\n })\n settings;\n }\n ```\n\n The `options` hash is passed as second argument to a transforms'\n `serialize` and `deserialize` method. This allows to configure a\n transformation and adapt the corresponding value, based on the config:\n\n ```app/models/post.js\n import Model, { attr } from '@ember-data/model';\n\n export default class PostModel extends Model {\n @attr('text', {\n uppercase: true\n })\n text;\n }\n ```\n\n ```app/transforms/text.js\n export default class TextTransform {\n serialize(value, options) {\n if (options.uppercase) {\n return value.toUpperCase();\n }\n\n return value;\n }\n\n deserialize(value) {\n return value;\n }\n\n static create() {\n return new this();\n }\n }\n ```\n\n @method attr\n @public\n @static\n @for @ember-data/model\n @param {String|Object} type the attribute type\n @param {Object} options a hash of options\n @return {Attribute}\n*/\nexport function attr(): DataDecorator;\nexport function attr<T>(type: TypeFromInstance<T>): DataDecorator;\nexport function attr(type: string): DataDecorator;\nexport function attr(options: AttrOptions): DataDecorator;\nexport function attr<T>(type: TypeFromInstance<T>, options?: OptionsFromInstance<T>): DataDecorator;\nexport function attr(type: string, options?: AttrOptions & object): DataDecorator;\nexport function attr(target: object, key: string | symbol, desc?: PropertyDescriptor): void; // see note on DataDecorator for why void\nexport function attr(\n type?: string | AttrOptions | object,\n options?: (AttrOptions & object) | string | symbol,\n desc?: PropertyDescriptor\n): DataDecorator | void {\n const args = [type, options, desc];\n // see note on DataDecorator for why void\n return isElementDescriptor(args) ? (_attr()(...args) as void) : _attr(type, options as object);\n}\n","import { warn } from '@ember/debug';\nimport { computed } from '@ember/object';\n\nimport { DEBUG } from '@warp-drive/build-config/env';\nimport { assert } from '@warp-drive/build-config/macros';\nimport type { TypeFromInstance } from '@warp-drive/core-types/record';\nimport { RecordStore } from '@warp-drive/core-types/symbols';\n\nimport { lookupLegacySupport } from './legacy-relationships-support';\nimport type { MinimalLegacyRecord } from './model-methods';\nimport { isElementDescriptor, normalizeModelName } from './util';\n/**\n @module @ember-data/model\n*/\n\nexport type IsUnknown<T> = unknown extends T ? true : false;\n\nexport type RelationshipOptions<T, Async extends boolean> = {\n async: Async;\n inverse: null | (IsUnknown<T> extends true ? string : keyof NoNull<T> & string);\n polymorphic?: boolean;\n as?: string;\n resetOnRemoteUpdate?: boolean;\n};\n\nexport type NoNull<T> = Exclude<T, null>;\n// type BelongsToDecoratorObject<getT> = {\n// get: () => getT;\n// // set: (value: Awaited<getT>) => void;\n// set: (value: getT) => void;\n// // init: () => getT;\n// };\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nexport type RelationshipDecorator<T> = <This>(target: This, key: string, desc?: PropertyDescriptor) => void; // BelongsToDecoratorObject<getT>;\n\nfunction _belongsTo<T, Async extends boolean>(\n type: string,\n options: RelationshipOptions<T, Async>\n): RelationshipDecorator<T> {\n assert(\n `Expected options.async from @belongsTo('${type}', options) to be a boolean`,\n options && typeof options.async === 'boolean'\n );\n assert(\n `Expected options.inverse from @belongsTo('${type}', options) to be either null or the string type of the related resource.`,\n options.inverse === null || (typeof options.inverse === 'string' && options.inverse.length > 0)\n );\n\n const meta = {\n type: normalizeModelName(type),\n options: options,\n kind: 'belongsTo',\n name: '<Unknown BelongsTo>',\n };\n\n return computed({\n get<R extends MinimalLegacyRecord>(this: R, key: string) {\n // this is a legacy behavior we may not carry into a new model setup\n // it's better to error on disconnected records so users find errors\n // in their logic.\n if (this.isDestroying || this.isDestroyed) {\n return null;\n }\n const support = lookupLegacySupport(this);\n\n if (DEBUG) {\n if (['currentState'].includes(key)) {\n throw new Error(\n `'${key}' is a reserved property name on instances of classes extending Model. Please choose a different property name for your belongsTo on ${this.constructor.toString()}`\n );\n }\n if (Object.prototype.hasOwnProperty.call(options, 'serialize')) {\n warn(\n `You provided a serialize option on the \"${key}\" property in the \"${support.identifier.type}\" class, this belongs in the serializer. See Serializer and it's implementations https://api.emberjs.com/ember-data/release/classes/Serializer`,\n false,\n {\n id: 'ds.model.serialize-option-in-belongs-to',\n }\n );\n }\n\n if (Object.prototype.hasOwnProperty.call(options, 'embedded')) {\n warn(\n `You provided an embedded option on the \"${key}\" property in the \"${support.identifier.type}\" class, this belongs in the serializer. See EmbeddedRecordsMixin https://api.emberjs.com/ember-data/release/classes/EmbeddedRecordsMixin`,\n false,\n {\n id: 'ds.model.embedded-option-in-belongs-to',\n }\n );\n }\n }\n\n return support.getBelongsTo(key);\n },\n set<R extends MinimalLegacyRecord>(this: R, key: string, value: unknown) {\n const support = lookupLegacySupport(this);\n if (DEBUG) {\n if (['currentState'].includes(key)) {\n throw new Error(\n `'${key}' is a reserved property name on instances of classes extending Model. Please choose a different property name for your belongsTo on ${this.constructor.toString()}`\n );\n }\n }\n this[RecordStore]._join(() => {\n support.setDirtyBelongsTo(key, value);\n });\n\n return support.getBelongsTo(key);\n },\n }).meta(meta) as RelationshipDecorator<T>;\n}\n\n/**\n `belongsTo` is used to define One-To-One and One-To-Many, and One-To-None\n relationships on a [Model](/ember-data/release/classes/Model).\n\n `belongsTo` takes a configuration hash as a second parameter, currently\n supported options are:\n\n - `async`: (*required*) A boolean value used to declare whether this is a sync (false) or async (true) relationship.\n - `inverse`: (*required*) A string used to identify the inverse property on a related model, or `null`.\n - `polymorphic`: (*optional*) A boolean value to mark the relationship as polymorphic\n - `as`: (*optional*) A string used to declare the abstract type \"this\" record satisfies for polymorphism.\n\n ### Examples\n\n To declare a **one-to-many** (or many-to-many) relationship, use\n `belongsTo` in combination with `hasMany`:\n\n ```js\n // app/models/comment.js\n import Model, { belongsTo } from '@ember-data/model';\n\n export default class Comment extends Model {\n @belongsTo('post', { async: false, inverse: 'comments' }) post;\n }\n\n // app/models/post.js\n import Model, { hasMany } from '@ember-data/model';\n\n export default class Post extends Model {\n @hasMany('comment', { async: false, inverse: 'post' }) comments;\n }\n ```\n\n To declare a **one-to-one** relationship with managed inverses, use `belongsTo` for both sides:\n\n ```js\n // app/models/author.js\n import Model, { belongsTo } from '@ember-data/model';\n\n export default class Author extends Model {\n @belongsTo('address', { async: true, inverse: 'owner' }) address;\n }\n\n // app/models/address.js\n import Model, { belongsTo } from '@ember-data/model';\n\n export default class Address extends Model {\n @belongsTo('author', { async: true, inverse: 'address' }) owner;\n }\n ```\n\n To declare a **one-to-one** relationship without managed inverses, use `belongsTo` for both sides\n with `null` as the inverse:\n\n ```js\n // app/models/author.js\n import Model, { belongsTo } from '@ember-data/model';\n\n export default class Author extends Model {\n @belongsTo('address', { async: true, inverse: null }) address;\n }\n\n // app/models/address.js\n import Model, { belongsTo } from '@ember-data/model';\n\n export default class Address extends Model {\n @belongsTo('author', { async: true, inverse: null }) owner;\n }\n ```\n\n To declare a one-to-none relationship between two models, use\n `belongsTo` with inverse set to `null` on just one side::\n\n ```js\n // app/models/person.js\n import Model, { belongsTo } from '@ember-data/model';\n\n export default class Person extends Model {\n @belongsTo('person', { async: false, inverse: null }) bestFriend;\n }\n ```\n\n #### Sync vs Async Relationships\n\n EmberData fulfills relationships using resource data available in\n the cache.\n\n Sync relationships point directly to the known related resources.\n\n When a relationship is declared as async, if any of the known related\n resources have not been loaded, they will be fetched. The property\n on the record when accessed provides a promise that resolves once\n all resources are loaded.\n\n Async relationships may take advantage of links. On access, if the related\n link has not been loaded, or if any known resources are not available in\n the cache, the fresh state will be fetched using the link.\n\n In contrast to async relationship, accessing a sync relationship\n will error on access when any of the known related resources have\n not been loaded.\n\n If you are using `links` with sync relationships, you have to use\n the BelongsTo reference API to fetch or refresh related resources\n that aren't loaded. For instance, for a `bestFriend` relationship:\n\n ```js\n person.belongsTo('bestFriend').reload();\n ```\n\n #### Polymorphic Relationships\n\n To declare a polymorphic relationship, use `hasMany` with the `polymorphic`\n option set to `true`:\n\n ```js\n // app/models/comment.js\n import Model, { belongsTo } from '@ember-data/model';\n\n export default class Comment extends Model {\n @belongsTo('commentable', { async: false, inverse: 'comments', polymorphic: true }) parent;\n }\n ```\n\n `'commentable'` here is referred to as the \"abstract type\" for the polymorphic\n relationship.\n\n Polymorphic relationships with `inverse: null` will accept any type of record as their content.\n Polymorphic relationships with `inverse` set to a string will only accept records with a matching\n inverse relationships declaring itself as satisfying the abstract type.\n\n Below, 'as' is used to declare the that 'post' record satisfies the abstract type 'commentable'\n for this relationship.\n\n ```js\n // app/models/post.js\n import Model, { hasMany } from '@ember-data/model';\n\n export default class Post extends Model {\n @hasMany('comment', { async: false, inverse: 'parent', as: 'commentable' }) comments;\n }\n ```\n\n Note: every Model that declares an inverse to a polymorphic relationship must\n declare itself exactly the same. This is because polymorphism is based on structural\n traits.\n\n Polymorphic to polymorphic relationships are supported. Both sides of the relationship\n must be declared as polymorphic, and the `as` option must be used to declare the abstract\n type each record satisfies on both sides.\n\n @method belongsTo\n @public\n @static\n @for @ember-data/model\n @param {string} type (optional) the name of the related resource\n @param {object} options (optional) a hash of options\n @return {PropertyDescriptor} relationship\n*/\n\nexport function belongsTo(): never;\nexport function belongsTo(type: string): never;\nexport function belongsTo<T>(\n type: TypeFromInstance<NoNull<T>>,\n options: RelationshipOptions<T, boolean>\n): RelationshipDecorator<T>;\n// export function belongsTo<K extends Promise<unknown>, T extends Awaited<K> = Awaited<K>>(\n// type: TypeFromInstance<NoNull<T>>,\n// options: RelationshipOptions<T, true>\n// ): RelationshipDecorator<K>;\nexport function belongsTo(type: string, options: RelationshipOptions<unknown, boolean>): RelationshipDecorator<unknown>;\nexport function belongsTo<T>(\n type?: TypeFromInstance<NoNull<T>>,\n options?: RelationshipOptions<T, boolean>\n): RelationshipDecorator<T> {\n if (DEBUG) {\n assert(\n `belongsTo must be invoked with a type and options. Did you mean \\`@belongsTo(${type}, { async: false, inverse: null })\\`?`,\n !isElementDescriptor(arguments as unknown as unknown[])\n );\n }\n return _belongsTo(type!, options!);\n}\n","/**\n @module @ember-data/model\n*/\nimport { deprecate } from '@ember/debug';\nimport { computed } from '@ember/object';\nimport { dasherize } from '@ember/string';\n\nimport { singularize } from 'ember-inflector';\n\nimport { DEPRECATE_NON_STRICT_TYPES } from '@warp-drive/build-config/deprecations';\nimport { DEBUG } from '@warp-drive/build-config/env';\nimport { assert } from '@warp-drive/build-config/macros';\nimport type { TypeFromInstance } from '@warp-drive/core-types/record';\nimport { RecordStore } from '@warp-drive/core-types/symbols';\n\nimport type { NoNull, RelationshipDecorator, RelationshipOptions } from './belongs-to';\nimport { lookupLegacySupport } from './legacy-relationships-support';\nimport type { MinimalLegacyRecord } from './model-methods';\nimport { isElementDescriptor } from './util';\n\nfunction normalizeType(type: string) {\n if (DEPRECATE_NON_STRICT_TYPES) {\n const result = singularize(dasherize(type));\n\n deprecate(\n `The resource type '${type}' is not normalized. Update your application code to use '${result}' instead of '${type}'.`,\n result === type,\n {\n id: 'ember-data:deprecate-non-strict-types',\n until: '6.0',\n for: 'ember-data',\n since: {\n available: '5.3',\n enabled: '5.3',\n },\n }\n );\n\n return result;\n }\n\n return type;\n}\n\nfunction _hasMany<T, Async extends boolean>(\n type: string,\n options: RelationshipOptions<T, Async>\n): RelationshipDecorator<T> {\n assert(`Expected hasMany options.async to be a boolean`, options && typeof options.async === 'boolean');\n\n // Metadata about relationships is stored on the meta of\n // the relationship. This is used for introspection and\n // serialization. Note that `key` is populated lazily\n // the first time the CP is called.\n const meta = {\n type: normalizeType(type),\n options,\n kind: 'hasMany',\n name: '<Unknown BelongsTo>',\n };\n\n return computed({\n get<R extends MinimalLegacyRecord>(this: R, key: string) {\n if (DEBUG) {\n if (['currentState'].includes(key)) {\n throw new Error(\n `'${key}' is a reserved property name on instances of classes extending Model. Please choose a different property name for your hasMany on ${this.constructor.toString()}`\n );\n }\n }\n if (this.isDestroying || this.isDestroyed) {\n return [];\n }\n return lookupLegacySupport(this).getHasMany(key);\n },\n set<R extends MinimalLegacyRecord>(this: R, key: string, records: T[]) {\n if (DEBUG) {\n if (['currentState'].includes(key)) {\n throw new Error(\n `'${key}' is a reserved property name on instances of classes extending Model. Please choose a different property name for your hasMany on ${this.constructor.toString()}`\n );\n }\n }\n const support = lookupLegacySupport(this);\n const manyArray = support.getManyArray(key);\n assert(`You must pass an array of records to set a hasMany relationship`, Array.isArray(records));\n this[RecordStore]._join(() => {\n manyArray.splice(0, manyArray.length, ...records);\n });\n\n return support.getHasMany(key);\n },\n }).meta(meta);\n}\n\n/**\n `hasMany` is used to define Many-To-One and Many-To-Many, and Many-To-None\n relationships on a [Model](/ember-data/release/classes/Model).\n\n `hasMany` takes a configuration hash as a second parameter, currently\n supported options are:\n\n - `async`: (*required*) A boolean value used to declare whether this is a sync (false) or async (true) relationship.\n - `inverse`: (*required*) A string used to identify the inverse property on a related model, or `null`.\n - `polymorphic`: (*optional*) A boolean value to mark the relationship as polymorphic\n - `as`: (*optional*) A string used to declare the abstract type \"this\" record satisfies for polymorphism.\n\n ### Examples\n\n To declare a **many-to-one** (or one-to-many) relationship, use\n `belongsTo` in combination with `hasMany`:\n\n ```js\n // app/models/post.js\n import Model, { hasMany } from '@ember-data/model';\n\n export default class Post extends Model {\n @hasMany('comment', { async: false, inverse: 'post' }) comments;\n }\n\n\n // app/models/comment.js\n import Model, { belongsTo } from '@ember-data/model';\n\n export default class Comment extends Model {\n @belongsTo('post', { async: false, inverse: 'comments' }) post;\n }\n ```\n\n To declare a **many-to-many** relationship with managed inverses, use `hasMany` for both sides:\n\n ```js\n // app/models/post.js\n import Model, { hasMany } from '@ember-data/model';\n\n export default class Post extends Model {\n @hasMany('tag', { async: true, inverse: 'posts' }) tags;\n }\n\n // app/models/tag.js\n import Model, { hasMany } from '@ember-data/model';\n\n export default class Tag extends Model {\n @hasMany('post', { async: true, inverse: 'tags' }) posts;\n }\n ```\n\n To declare a **many-to-many** relationship without managed inverses, use `hasMany` for both sides\n with `null` as the inverse:\n\n ```js\n // app/models/post.js\n import Model, { hasMany } from '@ember-data/model';\n\n export default class Post extends Model {\n @hasMany('tag', { async: true, inverse: null }) tags;\n }\n\n // app/models/tag.js\n import Model, { hasMany } from '@ember-data/model';\n\n export default class Tag extends Model {\n @hasMany('post', { async: true, inverse: null }) posts;\n }\n ```\n\n To declare a many-to-none relationship between two models, use\n `hasMany` with inverse set to `null` on just one side::\n\n ```js\n // app/models/post.js\n import Model, { hasMany } from '@ember-data/model';\n\n export default class Post extends Model {\n @hasMany('category', { async: true, inverse: null }) categories;\n }\n ```\n\n #### Sync vs Async Relationships\n\n EmberData fulfills relationships using resource data available in\n the cache.\n\n Sync relationships point directly to the known related resources.\n\n When a relationship is declared as async, if any of the known related\n resources have not been loaded, they will be fetched. The property\n on the record when accessed provides a promise that resolves once\n all resources are loaded.\n\n Async relationships may take advantage of links. On access, if the related\n link has not been loaded, or if any known resources are not available in\n the cache, the fresh state will be fetched using the link.\n\n In contrast to async relationship, accessing a sync relationship\n will error on access when any of the known related resources have\n not been loaded.\n\n If you are using `links` with sync relationships, you have to use\n the HasMany reference API to fetch or refresh related resources\n that aren't loaded. For instance, for a `comments` relationship:\n\n ```js\n post.hasMany('comments').reload();\n ```\n\n #### Polymorphic Relationships\n\n To declare a polymorphic relationship, use `hasMany` with the `polymorphic`\n option set to `true`:\n\n ```js\n // app/models/comment.js\n import Model, { belongsTo } from '@ember-data/model';\n\n export default class Comment extends Model {\n @belongsTo('commentable', { async: false, inverse: 'comments', polymorphic: true }) parent;\n }\n ```\n\n `'commentable'` here is referred to as the \"abstract type\" for the polymorphic\n relationship.\n\n Polymorphic relationships with `inverse: null` will accept any type of record as their content.\n Polymorphic relationships with `inverse` set to a string will only accept records with a matching\n inverse relationships declaring itself as satisfying the abstract type.\n\n Below, 'as' is used to declare the that 'post' record satisfies the abstract type 'commentable'\n for this relationship.\n\n ```js\n // app/models/post.js\n import Model, { hasMany } from '@ember-data/model';\n\n export default class Post extends Model {\n @hasMany('comment', { async: false, inverse: 'parent', as: 'commentable' }) comments;\n }\n ```\n\n Note: every Model that declares an inverse to a polymorphic relationship must\n declare itself exactly the same. This is because polymorphism is based on structural\n traits.\n\n Polymorphic to polymorphic relationships are supported. Both sides of the relationship\n must be declared as polymorphic, and the `as` option must be used to declare the abstract\n type each record satisfies on both sides.\n\n @method hasMany\n @public\n @static\n @for @ember-data/model\n @param {string} type (optional) the name of the related resource\n @param {object} options (optional) a hash of options\n @return {PropertyDescriptor} relationship\n*/\nexport function hasMany(): never;\nexport function hasMany(type: string): never;\nexport function hasMany<T>(\n type: TypeFromInstance<NoNull<T>>,\n options: RelationshipOptions<T, boolean>\n): RelationshipDecorator<T>;\n// export function hasMany<K extends Promise<unknown>, T extends Awaited<K> = Awaited<K>>(\n// type: TypeFromInstance<NoNull<T>>,\n// options: RelationshipOptions<T, true>\n// ): RelationshipDecorator<K>;\nexport function hasMany(type: string, options: RelationshipOptions<unknown, boolean>): RelationshipDecorator<unknown>;\nexport function hasMany<T>(\n type?: TypeFromInstance<NoNull<T>>,\n options?: RelationshipOptions<T, boolean>\n): RelationshipDecorator<T> {\n if (DEBUG) {\n assert(\n `hasMany must be invoked with a type and options. Did you mean \\`@hasMany(${type}, { async: false, inverse: null })\\`?`,\n !isElementDescriptor(arguments as unknown as unknown[])\n );\n }\n return _hasMany(type!, options!);\n}\n"],"names":["_attr","type","options","undefined","meta","kind","isAttribute","key","computed","get","macroCondition","getGlobalConfig","WarpDrive","env","DEBUG","includes","Error","constructor","toString","isDestroyed","isDestroying","peekCache","getAttr","recordIdentifierFor","set","value","identifier","test","id","lid","currentState","isDeleted","cache","currentValue","setAttr","isValid","errors","remove","cleanErrorRequests","attr","desc","args","isElementDescriptor","_belongsTo","async","inverse","length","normalizeModelName","name","support","lookupLegacySupport","Object","prototype","hasOwnProperty","call","warn","getBelongsTo","RecordStore","_join","setDirtyBelongsTo","belongsTo","arguments","normalizeType","deprecations","DEPRECATE_NON_STRICT_TYPES","result","singularize","dasherize","deprecate","until","for","since","available","enabled","_hasMany","getHasMany","records","manyArray","getManyArray","Array","isArray","splice","hasMany"],"mappings":";;;;;;;;;;AAAA;AACA;AACA;AAqDA,SAASA,KAAKA,CAACC,IAA2B,EAAEC,OAA8B,EAAE;AAC1E,EAAA,IAAI,OAAOD,IAAI,KAAK,QAAQ,EAAE;AAC5BC,IAAAA,OAAO,GAAGD,IAAI,CAAA;AACdA,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IAAI,CAACA,IAAI,CAAC,CAAA;AACf,CAAA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAgCA;AACA;;AAeA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAO6F;AACtF,SAASmC,IAAIA,CAClBtC,IAAoC,EACpCC,OAAkD,EAClDsC,IAAyB,EACH;EACtB,MAAMC,IAAI,GAAG,CAACxC,IAAI,EAAEC,OAAO,EAAEsC,IAAI,CAAC,CAAA;AAClC;AACA,EAAA,OAAOE,mBAAmB,CAACD,IAAI,CAAC,GAAIzC,KAAK,EAAE,CAAC,GAAGyC,IAAI,CAAC,GAAYzC,KAAK,CAACC,IAAI,EAAEC,OAAiB,CAAC,CAAA;AAChG;;ACpQA;AACA;AACA;AACA;AACA;AACA;AAC6G;;AAE7G,SAASyC,UAAUA,CACjB1C,IAAY,EACZC,OAAsC,EACZ;EAC1BQ,cAAA,CAAAC,eAAA,EAAAC,CAAAA,SAAA,CAAAC,GAAA,CAAAC,KAAA,CAAA,GAAA,CAAAa,IAAA,IAAA;AAAA,IAAA,IAAA,CAAAA,IAAA,EAAA;AAAA,MAAA,MAAA,IAAAX,KAAA,CACG,CAA0Cf,wCAAAA,EAAAA,IAAK,CAA4B,2BAAA,CAAA,CAAA,CAAA;AAAA,KAAA;AAA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AACuC,WAAW,CAAC,CAACC,KAAK,CAAC,MAAM;AAC5BT,QAAAA,OAAO,CAACU,iBAAiB,CAACpD,GAAG,EAAEkB,KAAK,CAAC,CAAA;AACvC,OAAC,CAAC,CAAA;AAEF,MAAA,OAAOwB,OAAO,CAACO,YAAY,CAACjD,GAAG,CAAC,CAAA;AAClC,KAAA;AACF,GAAC,CAAC,CAACH,IAAI,CAACA,IAAI,CAAC,CAAA;AACf,CAAA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAQA;AACA;AACA;AACA;;AAEO,SAASwD,SAASA,CACvB3D,IAAkC,EAClCC,OAAyC,EACf;EAC1B,IAAAQ,cAAA,CAAAC,eAAA,EAAA,CAAAC,SAAA,CAAAC,GAAA,CAAAC,KAAA,CAAW,EAAA;IACTJ,cAAA,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;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAOA;AACA;AACA;AACA;;AAEO,SAAS8E,OAAOA,CACrBjF,IAAkC,EAClCC,OAAyC,EACf;EAC1B,IAAAQ,cAAA,CAAAC,eAAA,EAAA,CAAAC,SAAA,CAAAC,GAAA,CAAAC,KAAA,CAAW,EAAA;IACTJ,cAAA,CAAAC,eAAA,EAAAC,CAAAA,SAAA,CAAAC,GAAA,CAAAC,KAAA,CAAA,GAAA,CAAAa,IAAA,IAAA;AAAA,MAAA,IAAA,CAAAA,IAAA,EAAA;AAAA,QAAA,MAAA,IAAAX,KAAA,CACG,CAA2Ef,yEAAAA,EAAAA,IAAK,CAAsC,qCAAA,CAAA,CAAA,CAAA;AAAA,OAAA;AAAA,KAAA,EACvH,CAACyC,mBAAmB,CAACmB,SAAiC,CAAC,CAAA,GAAA,EAAA,CAAA;AAE3D,GAAA;AACA,EAAA,OAAOa,QAAQ,CAACzE,IAAI,EAAGC,OAAQ,CAAC,CAAA;AAClC;;;;"}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { setOwner, getOwner } from '@ember/application';
|
|
2
|
+
import { setRecordIdentifier, StoreMap, setCacheFor } from '@ember-data/store/-private';
|
|
3
|
+
import { g as getModelFactory } from "./schema-provider-C5vR7TBr";
|
|
4
|
+
import { n as normalizeModelName } from "./model-CsbDNxap";
|
|
5
|
+
import { macroCondition, getGlobalConfig } from '@embroider/macros';
|
|
6
|
+
function instantiateRecord(identifier, createRecordArgs) {
|
|
7
|
+
const type = identifier.type;
|
|
8
|
+
const cache = this.cache;
|
|
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
|
+
cache,
|
|
16
|
+
store: this,
|
|
17
|
+
cb: secretInit
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
// ensure that `getOwner(this)` works inside a model instance
|
|
22
|
+
setOwner(createOptions, getOwner(this));
|
|
23
|
+
const factory = getModelFactory(this, type);
|
|
24
|
+
macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
|
|
25
|
+
if (!test) {
|
|
26
|
+
throw new Error(`No model was found for '${type}'`);
|
|
27
|
+
}
|
|
28
|
+
})(factory) : {};
|
|
29
|
+
return factory.class.create(createOptions);
|
|
30
|
+
}
|
|
31
|
+
function teardownRecord(record) {
|
|
32
|
+
macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
|
|
33
|
+
if (!test) {
|
|
34
|
+
throw new Error(`expected to receive an instance of Model from @ember-data/model. If using a custom model make sure you implement teardownRecord`);
|
|
35
|
+
}
|
|
36
|
+
})('destroy' in record) : {};
|
|
37
|
+
record.destroy();
|
|
38
|
+
}
|
|
39
|
+
function modelFor(modelName) {
|
|
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, cache, identifier, store) {
|
|
71
|
+
setRecordIdentifier(record, identifier);
|
|
72
|
+
StoreMap.set(record, store);
|
|
73
|
+
setCacheFor(record, cache);
|
|
74
|
+
}
|
|
75
|
+
export { instantiateRecord as i, modelFor as m, teardownRecord as t };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hooks-BNw6VdLr.js","sources":["../src/-private/hooks.ts"],"sourcesContent":["import { getOwner, setOwner } from '@ember/application';\n\nimport { setCacheFor, setRecordIdentifier, type Store, StoreMap } from '@ember-data/store/-private';\nimport { assert } from '@warp-drive/build-config/macros';\nimport type { StableRecordIdentifier } from '@warp-drive/core-types';\nimport type { Cache } from '@warp-drive/core-types/cache';\nimport type { TypeFromInstance, TypeFromInstanceOrString } from '@warp-drive/core-types/record';\n\nimport type { Model, ModelStore } from './model';\nimport { getModelFactory } from './schema-provider';\nimport { normalizeModelName } from './util';\n\nfunction recast(context: Store): asserts context is ModelStore {}\n\nexport function instantiateRecord(\n this: Store,\n identifier: StableRecordIdentifier,\n createRecordArgs: { [key: string]: unknown }\n): Model {\n const type = identifier.type;\n\n recast(this);\n\n const cache = this.cache;\n // TODO deprecate allowing unknown args setting\n const createOptions = {\n _createProps: createRecordArgs,\n // TODO @deprecate consider deprecating accessing record properties during init which the below is necessary for\n _secretInit: {\n identifier,\n cache,\n store: this,\n cb: secretInit,\n },\n };\n\n // ensure that `getOwner(this)` works inside a model instance\n setOwner(createOptions, getOwner(this)!);\n const factory = getModelFactory(this, type);\n\n assert(`No model was found for '${type}'`, factory);\n return factory.class.create(createOptions);\n}\n\nexport function teardownRecord(record: Model): void {\n assert(\n `expected to receive an instance of Model from @ember-data/model. If using a custom model make sure you implement teardownRecord`,\n 'destroy' in record\n );\n record.destroy();\n}\n\nexport function modelFor<T>(type: TypeFromInstance<T>): typeof Model | void;\nexport function modelFor(type: string): typeof Model | void;\nexport function modelFor<T>(this: Store, modelName: TypeFromInstanceOrString<T>): typeof Model | void {\n assert(\n `Attempted to call store.modelFor(), but the store instance has already been destroyed.`,\n !this.isDestroyed && !this.isDestroying\n );\n assert(`You need to pass a model name to the store's modelFor method`, modelName);\n assert(\n `Please pass a proper model name to the store's modelFor method`,\n typeof modelName === 'string' && modelName.length\n );\n recast(this);\n\n const type = normalizeModelName(modelName);\n const maybeFactory = getModelFactory(this, type);\n const klass = maybeFactory && maybeFactory.class ? maybeFactory.class : null;\n\n const ignoreType = !klass || !klass.isModel || this._forceShim;\n if (!ignoreType) {\n return klass;\n }\n assert(`No model was found for '${type}' and no schema handles the type`, this.schema.hasResource({ type }));\n}\n\nfunction secretInit(record: Model, cache: Cache, identifier: StableRecordIdentifier, store: Store): void {\n setRecordIdentifier(record, identifier);\n StoreMap.set(record, store);\n setCacheFor(record, cache);\n}\n"],"names":["instantiateRecord","identifier","createRecordArgs","type","cache","createOptions","_createProps","_secretInit","store","cb","secretInit","setOwner","getOwner","factory","getModelFactory","macroCondition","getGlobalConfig","WarpDrive","env","DEBUG","test","Error","class","create","teardownRecord","record","destroy","modelFor","modelName","isDestroyed","isDestroying","length","normalizeModelName","maybeFactory","klass","ignoreType","isModel","_forceShim","schema","hasResource","setRecordIdentifier","StoreMap","set","setCacheFor"],"mappings":";;;;;;AAcO,SAASA,iBAAiBA,CAE/BC,UAAkC,EAClCC,gBAA4C,EACrC;AACP,EAAA,MAAMC,IAAI,GAAGF,UAAU,CAACE,IAAI,CAAA;AAI5B,EAAA,MAAMC,KAAK,GAAG,IAAI,CAACA,KAAK,CAAA;AACxB;AACA,EAAA,MAAMC,aAAa,GAAG;AACpBC,IAAAA,YAAY,EAAEJ,gBAAgB;AAC9B;AACAK,IAAAA,WAAW,EAAE;MACXN,UAAU;MACVG,KAAK;AACLI,MAAAA,KAAK,EAAE,IAAI;AACXC,MAAAA,EAAE,EAAEC,UAAAA;AACN,KAAA;GACD,CAAA;;AAED;AACAC,EAAAA,QAAQ,CAACN,aAAa,EAAEO,QAAQ,CAAC,IAAI,CAAE,CAAC,CAAA;AACxC,EAAA,MAAMC,OAAO,GAAGC,eAAe,CAAC,IAAI,EAAEX,IAAI,CAAC,CAAA;EAE3CY,cAAA,CAAAC,eAAA,EAAAC,CAAAA,SAAA,CAAAC,GAAA,CAAAC,KAAA,CAAA,GAAA,CAAAC,IAAA,IAAA;AAAA,IAAA,IAAA,CAAAA,IAAA,EAAA;AAAA,MAAA,MAAA,IAAAC,KAAA,CAAQ,CAA0BlB,wBAAAA,EAAAA,IAAK,CAAE,CAAA,CAAA,CAAA,CAAA;AAAA,KAAA;AAAA,GAAA,EAAEU,OAAO,CAAA,GAAA,EAAA,CAAA;AAClD,EAAA,OAAOA,OAAO,CAACS,KAAK,CAACC,MAAM,CAAClB,aAAa,C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1 @@
|
|
|
1
|
-
{"version":3,"file":"hooks.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"hooks.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { a as attr, b as belongsTo, h as hasMany } from "./has-many-CR10J-rp";
|
|
2
|
+
export { M as default } from "./model-CsbDNxap";
|
|
3
|
+
export { i as instantiateRecord, m as modelFor, t as teardownRecord } from "./hooks-BNw6VdLr";
|
|
4
|
+
export { M as ModelSchemaProvider } from "./schema-provider-C5vR7TBr";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;"}
|