@ember-data/model 5.3.3 → 5.3.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +19 -0
- 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/dist/has-many-78F2FHCC.js +674 -0
- package/dist/has-many-78F2FHCC.js.map +1 -0
- package/dist/hooks-BgrTI_ff.js +75 -0
- package/dist/hooks-BgrTI_ff.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 +210 -0
- package/dist/migration-support.js.map +1 -0
- package/{addon/model-YsOraZ6y.js → dist/model-BFnMMaye.js} +889 -424
- package/dist/model-BFnMMaye.js.map +1 -0
- package/dist/schema-provider-Cgpcwfn7.js +256 -0
- package/dist/schema-provider-Cgpcwfn7.js.map +1 -0
- package/ember-data-logo-dark.svg +12 -0
- package/ember-data-logo-light.svg +12 -0
- package/package.json +54 -74
- package/unstable-preview-types/-private/attr.d.ts +174 -0
- package/unstable-preview-types/-private/attr.d.ts.map +1 -0
- package/unstable-preview-types/-private/attr.type-test.d.ts +4 -0
- package/unstable-preview-types/-private/attr.type-test.d.ts.map +1 -0
- package/unstable-preview-types/-private/belongs-to.d.ts +180 -0
- package/unstable-preview-types/-private/belongs-to.d.ts.map +1 -0
- package/unstable-preview-types/-private/belongs-to.type-test.d.ts +4 -0
- package/unstable-preview-types/-private/belongs-to.type-test.d.ts.map +1 -0
- package/unstable-preview-types/-private/debug/assert-polymorphic-type.d.ts +8 -0
- package/unstable-preview-types/-private/debug/assert-polymorphic-type.d.ts.map +1 -0
- package/unstable-preview-types/-private/errors.d.ts +305 -0
- package/unstable-preview-types/-private/errors.d.ts.map +1 -0
- package/unstable-preview-types/-private/has-many.d.ts +169 -0
- package/unstable-preview-types/-private/has-many.d.ts.map +1 -0
- package/unstable-preview-types/-private/has-many.type-test.d.ts +4 -0
- package/unstable-preview-types/-private/has-many.type-test.d.ts.map +1 -0
- package/unstable-preview-types/-private/hooks.d.ts +13 -0
- package/unstable-preview-types/-private/hooks.d.ts.map +1 -0
- package/unstable-preview-types/-private/legacy-relationships-support.d.ts +60 -0
- package/unstable-preview-types/-private/legacy-relationships-support.d.ts.map +1 -0
- package/unstable-preview-types/-private/many-array.d.ts +196 -0
- package/unstable-preview-types/-private/many-array.d.ts.map +1 -0
- package/unstable-preview-types/-private/model-for-mixin.d.ts +6 -0
- package/unstable-preview-types/-private/model-for-mixin.d.ts.map +1 -0
- package/unstable-preview-types/-private/model-methods.d.ts +37 -0
- package/unstable-preview-types/-private/model-methods.d.ts.map +1 -0
- package/unstable-preview-types/-private/model.d.ts +1306 -0
- package/unstable-preview-types/-private/model.d.ts.map +1 -0
- package/unstable-preview-types/-private/model.type-test.d.ts +4 -0
- package/unstable-preview-types/-private/model.type-test.d.ts.map +1 -0
- package/unstable-preview-types/-private/notify-changes.d.ts +8 -0
- package/unstable-preview-types/-private/notify-changes.d.ts.map +1 -0
- package/unstable-preview-types/-private/promise-belongs-to.d.ts +48 -0
- package/unstable-preview-types/-private/promise-belongs-to.d.ts.map +1 -0
- package/unstable-preview-types/-private/promise-many-array.d.ts +131 -0
- package/unstable-preview-types/-private/promise-many-array.d.ts.map +1 -0
- package/unstable-preview-types/-private/record-state.d.ts +90 -0
- package/unstable-preview-types/-private/record-state.d.ts.map +1 -0
- package/unstable-preview-types/-private/references/belongs-to.d.ts +503 -0
- package/unstable-preview-types/-private/references/belongs-to.d.ts.map +1 -0
- package/unstable-preview-types/-private/references/has-many.d.ts +515 -0
- package/unstable-preview-types/-private/references/has-many.d.ts.map +1 -0
- package/unstable-preview-types/-private/schema-provider.d.ts +64 -0
- package/unstable-preview-types/-private/schema-provider.d.ts.map +1 -0
- 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/util.d.ts +11 -0
- package/unstable-preview-types/-private/util.d.ts.map +1 -0
- package/unstable-preview-types/-private.d.ts +13 -0
- package/unstable-preview-types/-private.d.ts.map +1 -0
- package/unstable-preview-types/hooks.d.ts +5 -0
- package/unstable-preview-types/hooks.d.ts.map +1 -0
- package/unstable-preview-types/index.d.ts +76 -0
- package/unstable-preview-types/index.d.ts.map +1 -0
- package/unstable-preview-types/migration-support.d.ts +56 -0
- package/unstable-preview-types/migration-support.d.ts.map +1 -0
- package/addon/has-many-PdQBns8a.js +0 -323
- package/addon/has-many-PdQBns8a.js.map +0 -1
- package/addon/hooks-dXmQbIOF.js +0 -176
- package/addon/hooks-dXmQbIOF.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-YsOraZ6y.js.map +0 -1
- package/addon/util-3DHZJC9h.js +0 -38
- package/addon/util-3DHZJC9h.js.map +0 -1
- package/addon-main.js +0 -93
- /package/{addon → dist}/-private.js.map +0 -0
package/addon/hooks-dXmQbIOF.js
DELETED
|
@@ -1,176 +0,0 @@
|
|
|
1
|
-
import { getOwner, setOwner } from '@ember/application';
|
|
2
|
-
import { assert } from '@ember/debug';
|
|
3
|
-
import { setRecordIdentifier, StoreMap, setCacheFor } from '@ember-data/store/-private';
|
|
4
|
-
import { M as Model } from "./model-YsOraZ6y";
|
|
5
|
-
import { n as normalizeModelName } from "./util-3DHZJC9h";
|
|
6
|
-
|
|
7
|
-
/*
|
|
8
|
-
In case someone defined a relationship to a mixin, for example:
|
|
9
|
-
```ts
|
|
10
|
-
class CommentModel extends Model {
|
|
11
|
-
@belongsTo('commentable', { polymorphic: true }) owner;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
let Commentable = Mixin.create({
|
|
15
|
-
@hasMany('comment') comments;
|
|
16
|
-
});
|
|
17
|
-
```
|
|
18
|
-
we want to look up a Commentable class which has all the necessary
|
|
19
|
-
relationship meta data. Thus, we look up the mixin and create a mock
|
|
20
|
-
Model, so we can access the relationship CPs of the mixin (`comments`)
|
|
21
|
-
in this case
|
|
22
|
-
*/
|
|
23
|
-
function modelForMixin(store, normalizedModelName) {
|
|
24
|
-
const owner = getOwner(store);
|
|
25
|
-
const MaybeMixin = owner.factoryFor(`mixin:${normalizedModelName}`);
|
|
26
|
-
const mixin = MaybeMixin && MaybeMixin.class;
|
|
27
|
-
if (mixin) {
|
|
28
|
-
const ModelForMixin = Model.extend(mixin);
|
|
29
|
-
ModelForMixin.__isMixin = true;
|
|
30
|
-
ModelForMixin.__mixin = mixin;
|
|
31
|
-
//Cache the class as a model
|
|
32
|
-
owner.register(`model:${normalizedModelName}`, ModelForMixin);
|
|
33
|
-
}
|
|
34
|
-
return owner.factoryFor(`model:${normalizedModelName}`);
|
|
35
|
-
}
|
|
36
|
-
class ModelSchemaProvider {
|
|
37
|
-
constructor(store) {
|
|
38
|
-
this.store = store;
|
|
39
|
-
this._relationshipsDefCache = Object.create(null);
|
|
40
|
-
this._attributesDefCache = Object.create(null);
|
|
41
|
-
this._fieldsDefCache = Object.create(null);
|
|
42
|
-
}
|
|
43
|
-
fields(identifier) {
|
|
44
|
-
const {
|
|
45
|
-
type
|
|
46
|
-
} = identifier;
|
|
47
|
-
let fieldDefs = this._fieldsDefCache[type];
|
|
48
|
-
if (fieldDefs === undefined) {
|
|
49
|
-
fieldDefs = new Map();
|
|
50
|
-
this._fieldsDefCache[type] = fieldDefs;
|
|
51
|
-
const attributes = this.attributesDefinitionFor(identifier);
|
|
52
|
-
const relationships = this.relationshipsDefinitionFor(identifier);
|
|
53
|
-
for (const attr of Object.values(attributes)) {
|
|
54
|
-
fieldDefs.set(attr.name, attr);
|
|
55
|
-
}
|
|
56
|
-
for (const rel of Object.values(relationships)) {
|
|
57
|
-
fieldDefs.set(rel.name, rel);
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
return fieldDefs;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
// Following the existing RD implementation
|
|
64
|
-
attributesDefinitionFor(identifier) {
|
|
65
|
-
const {
|
|
66
|
-
type
|
|
67
|
-
} = identifier;
|
|
68
|
-
let attributes;
|
|
69
|
-
attributes = this._attributesDefCache[type];
|
|
70
|
-
if (attributes === undefined) {
|
|
71
|
-
const modelClass = this.store.modelFor(type);
|
|
72
|
-
const attributeMap = modelClass.attributes;
|
|
73
|
-
attributes = Object.create(null);
|
|
74
|
-
attributeMap.forEach((meta, name) => attributes[name] = meta);
|
|
75
|
-
this._attributesDefCache[type] = attributes;
|
|
76
|
-
}
|
|
77
|
-
return attributes;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
// Following the existing RD implementation
|
|
81
|
-
relationshipsDefinitionFor(identifier) {
|
|
82
|
-
const {
|
|
83
|
-
type
|
|
84
|
-
} = identifier;
|
|
85
|
-
let relationships;
|
|
86
|
-
relationships = this._relationshipsDefCache[type];
|
|
87
|
-
if (relationships === undefined) {
|
|
88
|
-
const modelClass = this.store.modelFor(type);
|
|
89
|
-
relationships = modelClass.relationshipsObject || null;
|
|
90
|
-
this._relationshipsDefCache[type] = relationships;
|
|
91
|
-
}
|
|
92
|
-
return relationships;
|
|
93
|
-
}
|
|
94
|
-
doesTypeExist(modelName) {
|
|
95
|
-
const type = normalizeModelName(modelName);
|
|
96
|
-
const factory = getModelFactory(this.store, type);
|
|
97
|
-
return factory !== null;
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
function buildSchema(store) {
|
|
101
|
-
return new ModelSchemaProvider(store);
|
|
102
|
-
}
|
|
103
|
-
function getModelFactory(store, type) {
|
|
104
|
-
if (!store._modelFactoryCache) {
|
|
105
|
-
store._modelFactoryCache = Object.create(null);
|
|
106
|
-
}
|
|
107
|
-
const cache = store._modelFactoryCache;
|
|
108
|
-
let factory = cache[type];
|
|
109
|
-
if (!factory) {
|
|
110
|
-
const owner = getOwner(store);
|
|
111
|
-
factory = owner.factoryFor(`model:${type}`);
|
|
112
|
-
if (!factory) {
|
|
113
|
-
//Support looking up mixins as base types for polymorphic relationships
|
|
114
|
-
factory = modelForMixin(store, type);
|
|
115
|
-
}
|
|
116
|
-
if (!factory) {
|
|
117
|
-
// we don't cache misses in case someone wants to register a missing model
|
|
118
|
-
return null;
|
|
119
|
-
}
|
|
120
|
-
const klass = factory.class;
|
|
121
|
-
if (klass.isModel) {
|
|
122
|
-
const hasOwnModelNameSet = klass.modelName && Object.prototype.hasOwnProperty.call(klass, 'modelName');
|
|
123
|
-
if (!hasOwnModelNameSet) {
|
|
124
|
-
Object.defineProperty(klass, 'modelName', {
|
|
125
|
-
value: type
|
|
126
|
-
});
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
cache[type] = factory;
|
|
130
|
-
}
|
|
131
|
-
return factory;
|
|
132
|
-
}
|
|
133
|
-
function instantiateRecord(identifier, createRecordArgs) {
|
|
134
|
-
const type = identifier.type;
|
|
135
|
-
const cache = this.cache;
|
|
136
|
-
// TODO deprecate allowing unknown args setting
|
|
137
|
-
const createOptions = {
|
|
138
|
-
_createProps: createRecordArgs,
|
|
139
|
-
// TODO @deprecate consider deprecating accessing record properties during init which the below is necessary for
|
|
140
|
-
_secretInit: {
|
|
141
|
-
identifier,
|
|
142
|
-
cache,
|
|
143
|
-
store: this,
|
|
144
|
-
cb: secretInit
|
|
145
|
-
}
|
|
146
|
-
};
|
|
147
|
-
|
|
148
|
-
// ensure that `getOwner(this)` works inside a model instance
|
|
149
|
-
setOwner(createOptions, getOwner(this));
|
|
150
|
-
const factory = getModelFactory(this, type);
|
|
151
|
-
assert(`No model was found for '${type}'`, factory);
|
|
152
|
-
return factory.class.create(createOptions);
|
|
153
|
-
}
|
|
154
|
-
function teardownRecord(record) {
|
|
155
|
-
assert(`expected to receive an instance of Model from @ember-data/model. If using a custom model make sure you implement teardownRecord`, 'destroy' in record);
|
|
156
|
-
record.destroy();
|
|
157
|
-
}
|
|
158
|
-
function modelFor(modelName) {
|
|
159
|
-
assert(`Attempted to call store.modelFor(), but the store instance has already been destroyed.`, !this.isDestroyed && !this.isDestroying);
|
|
160
|
-
assert(`You need to pass a model name to the store's modelFor method`, modelName);
|
|
161
|
-
assert(`Please pass a proper model name to the store's modelFor method`, typeof modelName === 'string' && modelName.length);
|
|
162
|
-
const type = normalizeModelName(modelName);
|
|
163
|
-
const maybeFactory = getModelFactory(this, type);
|
|
164
|
-
const klass = maybeFactory && maybeFactory.class ? maybeFactory.class : null;
|
|
165
|
-
const ignoreType = !klass || !klass.isModel || this._forceShim;
|
|
166
|
-
if (!ignoreType) {
|
|
167
|
-
return klass;
|
|
168
|
-
}
|
|
169
|
-
assert(`No model was found for '${type}' and no schema handles the type`, this.getSchemaDefinitionService().doesTypeExist(type));
|
|
170
|
-
}
|
|
171
|
-
function secretInit(record, cache, identifier, store) {
|
|
172
|
-
setRecordIdentifier(record, identifier);
|
|
173
|
-
StoreMap.set(record, store);
|
|
174
|
-
setCacheFor(record, cache);
|
|
175
|
-
}
|
|
176
|
-
export { ModelSchemaProvider as M, buildSchema as b, instantiateRecord as i, modelFor as m, teardownRecord as t };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"hooks-dXmQbIOF.js","sources":["../src/-private/model-for-mixin.ts","../src/-private/schema-provider.ts","../src/-private/hooks.ts"],"sourcesContent":["import { getOwner } from '@ember/application';\n\nimport type Store from '@ember-data/store';\n\nimport Model, { type ModelFactory } from './model';\n\n/*\n In case someone defined a relationship to a mixin, for example:\n ```ts\n class CommentModel extends Model {\n @belongsTo('commentable', { polymorphic: true }) owner;\n }\n\n let Commentable = Mixin.create({\n @hasMany('comment') comments;\n });\n ```\n we want to look up a Commentable class which has all the necessary\n relationship meta data. Thus, we look up the mixin and create a mock\n Model, so we can access the relationship CPs of the mixin (`comments`)\n in this case\n */\nexport default function modelForMixin(store: Store, normalizedModelName: string): ModelFactory | undefined {\n const owner = getOwner(store)!;\n const MaybeMixin = owner.factoryFor(`mixin:${normalizedModelName}`);\n const mixin = MaybeMixin && MaybeMixin.class;\n if (mixin) {\n const ModelForMixin = Model.extend(mixin);\n ModelForMixin.__isMixin = true;\n ModelForMixin.__mixin = mixin;\n //Cache the class as a model\n owner.register(`model:${normalizedModelName}`, ModelForMixin);\n }\n return owner.factoryFor(`model:${normalizedModelName}`) as ModelFactory | undefined;\n}\n","import { getOwner } from '@ember/application';\n\nimport type Store from '@ember-data/store';\nimport type { FieldSchema } from '@ember-data/store/-types/q/schema-service';\nimport type { RecordIdentifier } from '@warp-drive/core-types/identifier';\nimport type { AttributesSchema, RelationshipsSchema } from '@warp-drive/core-types/schema';\n\nimport type { FactoryCache, ModelFactory, ModelStore } from './model';\nimport type Model from './model';\nimport _modelForMixin from './model-for-mixin';\nimport { normalizeModelName } from './util';\n\nexport class ModelSchemaProvider {\n declare store: ModelStore;\n declare _relationshipsDefCache: Record<string, RelationshipsSchema>;\n declare _attributesDefCache: Record<string, AttributesSchema>;\n declare _fieldsDefCache: Record<string, Map<string, FieldSchema>>;\n\n constructor(store: ModelStore) {\n this.store = store;\n this._relationshipsDefCache = Object.create(null) as Record<string, RelationshipsSchema>;\n this._attributesDefCache = Object.create(null) as Record<string, AttributesSchema>;\n this._fieldsDefCache = Object.create(null) as Record<string, Map<string, FieldSchema>>;\n }\n\n fields(identifier: RecordIdentifier | { type: string }): Map<string, FieldSchema> {\n const { type } = identifier;\n let fieldDefs: Map<string, FieldSchema> | undefined = this._fieldsDefCache[type];\n\n if (fieldDefs === undefined) {\n fieldDefs = new Map();\n this._fieldsDefCache[type] = fieldDefs;\n\n const attributes = this.attributesDefinitionFor(identifier);\n const relationships = this.relationshipsDefinitionFor(identifier);\n\n for (const attr of Object.values(attributes)) {\n fieldDefs.set(attr.name, attr);\n }\n\n for (const rel of Object.values(relationships)) {\n fieldDefs.set(rel.name, rel);\n }\n }\n\n return fieldDefs;\n }\n\n // Following the existing RD implementation\n attributesDefinitionFor(identifier: RecordIdentifier | { type: string }): AttributesSchema {\n const { type } = identifier;\n let attributes: AttributesSchema;\n\n attributes = this._attributesDefCache[type];\n\n if (attributes === undefined) {\n const modelClass = this.store.modelFor(type);\n const attributeMap = modelClass.attributes;\n\n attributes = Object.create(null) as AttributesSchema;\n attributeMap.forEach((meta, name) => (attributes[name] = meta));\n this._attributesDefCache[type] = attributes;\n }\n\n return attributes;\n }\n\n // Following the existing RD implementation\n relationshipsDefinitionFor(identifier: RecordIdentifier | { type: string }): RelationshipsSchema {\n const { type } = identifier;\n let relationships: RelationshipsSchema;\n\n relationships = this._relationshipsDefCache[type];\n\n if (relationships === undefined) {\n const modelClass = this.store.modelFor(type) as typeof Model;\n relationships = modelClass.relationshipsObject || null;\n this._relationshipsDefCache[type] = relationships;\n }\n\n return relationships;\n }\n\n doesTypeExist(modelName: string): boolean {\n const type = normalizeModelName(modelName);\n const factory = getModelFactory(this.store, type);\n\n return factory !== null;\n }\n}\n\nexport function buildSchema(store: Store) {\n return new ModelSchemaProvider(store as ModelStore);\n}\n\nexport function getModelFactory(store: ModelStore, type: string): ModelFactory | null {\n if (!store._modelFactoryCache) {\n store._modelFactoryCache = Object.create(null) as FactoryCache;\n }\n const cache = store._modelFactoryCache;\n let factory: ModelFactory | undefined = cache[type];\n\n if (!factory) {\n const owner = getOwner(store)!;\n factory = owner.factoryFor(`model:${type}`) as ModelFactory | undefined;\n\n if (!factory) {\n //Support looking up mixins as base types for polymorphic relationships\n factory = _modelForMixin(store, type);\n }\n\n if (!factory) {\n // we don't cache misses in case someone wants to register a missing model\n return null;\n }\n\n const klass = factory.class;\n\n if (klass.isModel) {\n const hasOwnModelNameSet = klass.modelName && Object.prototype.hasOwnProperty.call(klass, 'modelName');\n if (!hasOwnModelNameSet) {\n Object.defineProperty(klass, 'modelName', { value: type });\n }\n }\n\n cache[type] = factory;\n }\n\n return factory;\n}\n","import { getOwner, setOwner } from '@ember/application';\nimport { assert } from '@ember/debug';\n\nimport { setCacheFor, setRecordIdentifier, type Store, StoreMap } from '@ember-data/store/-private';\nimport type { StableRecordIdentifier } from '@warp-drive/core-types';\nimport type { Cache } from '@warp-drive/core-types/cache';\n\nimport type { ModelStore } from './model';\nimport type Model 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(this: Store, modelName: string): 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(\n `No model was found for '${type}' and no schema handles the type`,\n this.getSchemaDefinitionService().doesTypeExist(type)\n );\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":["modelForMixin","store","normalizedModelName","owner","getOwner","MaybeMixin","factoryFor","mixin","class","ModelForMixin","Model","extend","__isMixin","__mixin","register","ModelSchemaProvider","constructor","_relationshipsDefCache","Object","create","_attributesDefCache","_fieldsDefCache","fields","identifier","type","fieldDefs","undefined","Map","attributes","attributesDefinitionFor","relationships","relationshipsDefinitionFor","attr","values","set","name","rel","modelClass","modelFor","attributeMap","forEach","meta","relationshipsObject","doesTypeExist","modelName","normalizeModelName","factory","getModelFactory","buildSchema","_modelFactoryCache","cache","_modelForMixin","klass","isModel","hasOwnModelNameSet","prototype","hasOwnProperty","call","defineProperty","value","instantiateRecord","createRecordArgs","createOptions","_createProps","_secretInit","cb","secretInit","setOwner","assert","teardownRecord","record","destroy","isDestroyed","isDestroying","length","maybeFactory","ignoreType","_forceShim","getSchemaDefinitionService","setRecordIdentifier","StoreMap","setCacheFor"],"mappings":";;;;;;AAMA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACe,SAASA,aAAaA,CAACC,KAAY,EAAEC,mBAA2B,EAA4B;AACzG,EAAA,MAAMC,KAAK,GAAGC,QAAQ,CAACH,KAAK,CAAE,CAAA;EAC9B,MAAMI,UAAU,GAAGF,KAAK,CAACG,UAAU,CAAE,CAAA,MAAA,EAAQJ,mBAAoB,CAAA,CAAC,CAAC,CAAA;AACnE,EAAA,MAAMK,KAAK,GAAGF,UAAU,IAAIA,UAAU,CAACG,KAAK,CAAA;AAC5C,EAAA,IAAID,KAAK,EAAE;AACT,IAAA,MAAME,aAAa,GAAGC,KAAK,CAACC,MAAM,CAACJ,KAAK,CAAC,CAAA;IACzCE,aAAa,CAACG,SAAS,GAAG,IAAI,CAAA;IAC9BH,aAAa,CAACI,OAAO,GAAGN,KAAK,CAAA;AAC7B;IACAJ,KAAK,CAACW,QA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;AAEA,SAAS0C,UAAUA,CAACI,MAAa,EAAEpB,KAAY,EAAE3B,UAAkC,EAAEtB,KAAY,EAAQ;AACvG8E,EAAAA,mBAAmB,CAACT,MAAM,EAAE/C,UAAU,CAAC,CAAA;AACvCyD,EAAAA,QAAQ,CAAC9C,GAAG,CAACoC,MAAM,EAAErE,KAAK,CAAC,CAAA;AAC3BgF,EAAAA,WAAW,CAACX,MAAM,EAAEpB,KAAK,CAAC,CAAA;AAC5B;;;;"}
|
package/addon/hooks.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { b as buildSchema, i as instantiateRecord, m as modelFor, t as teardownRecord } from "./hooks-dXmQbIOF";
|
package/addon/index.js
DELETED
|
@@ -1,118 +0,0 @@
|
|
|
1
|
-
import { assert } from '@ember/debug';
|
|
2
|
-
import { recordIdentifierFor } from '@ember-data/store';
|
|
3
|
-
import { u as unloadRecord, s as serialize, b as save, r as rollbackAttributes, c as reload, h as hasMany, E as Errors, d as destroyRecord, e as deleteRecord, f as RecordState, g as changedAttributes, i as belongsTo, j as createSnapshot } from "./model-YsOraZ6y";
|
|
4
|
-
// 'isDestroying', 'isDestroyed'
|
|
5
|
-
const LegacyFields = ['_createSnapshot', 'adapterError', 'belongsTo', 'changedAttributes', 'constructor', 'currentState', 'deleteRecord', 'destroyRecord', 'dirtyType', 'errors', 'hasDirtyAttributes', 'hasMany', 'isDeleted', 'isEmpty', 'isError', 'isLoaded', 'isLoading', 'isNew', 'isSaving', 'isValid', 'reload', 'rollbackAttributes', 'save', 'serialize', 'unloadRecord'];
|
|
6
|
-
const LegacySupport = new WeakMap();
|
|
7
|
-
function legacySupport(record, options, prop) {
|
|
8
|
-
let state = LegacySupport.get(record);
|
|
9
|
-
if (!state) {
|
|
10
|
-
state = {};
|
|
11
|
-
LegacySupport.set(record, state);
|
|
12
|
-
}
|
|
13
|
-
switch (prop) {
|
|
14
|
-
case '_createSnapshot':
|
|
15
|
-
return createSnapshot;
|
|
16
|
-
case 'adapterError':
|
|
17
|
-
return record.currentState.adapterError;
|
|
18
|
-
case 'belongsTo':
|
|
19
|
-
return belongsTo;
|
|
20
|
-
case 'changedAttributes':
|
|
21
|
-
return changedAttributes;
|
|
22
|
-
case 'constructor':
|
|
23
|
-
return state._constructor = state._constructor || {
|
|
24
|
-
isModel: true,
|
|
25
|
-
name: `Record<${recordIdentifierFor(record).type}>`,
|
|
26
|
-
modelName: recordIdentifierFor(record).type
|
|
27
|
-
};
|
|
28
|
-
case 'currentState':
|
|
29
|
-
return state.recordState = state.recordState || new RecordState(record);
|
|
30
|
-
case 'deleteRecord':
|
|
31
|
-
return deleteRecord;
|
|
32
|
-
case 'destroyRecord':
|
|
33
|
-
return destroyRecord;
|
|
34
|
-
case 'dirtyType':
|
|
35
|
-
return record.currentState.dirtyType;
|
|
36
|
-
case 'errors':
|
|
37
|
-
// @ts-expect-error
|
|
38
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
|
|
39
|
-
return state.errors = state.errors || Errors.create({
|
|
40
|
-
__record: record
|
|
41
|
-
});
|
|
42
|
-
case 'hasDirtyAttributes':
|
|
43
|
-
return record.currentState.isDirty;
|
|
44
|
-
case 'hasMany':
|
|
45
|
-
return hasMany;
|
|
46
|
-
case 'isDeleted':
|
|
47
|
-
return record.currentState.isDeleted;
|
|
48
|
-
case 'isEmpty':
|
|
49
|
-
return record.currentState.isEmpty;
|
|
50
|
-
case 'isError':
|
|
51
|
-
return record.currentState.isError;
|
|
52
|
-
case 'isLoaded':
|
|
53
|
-
return record.currentState.isLoaded;
|
|
54
|
-
case 'isLoading':
|
|
55
|
-
return record.currentState.isLoading;
|
|
56
|
-
case 'isNew':
|
|
57
|
-
return record.currentState.isNew;
|
|
58
|
-
case 'isSaving':
|
|
59
|
-
return record.currentState.isSaving;
|
|
60
|
-
case 'isValid':
|
|
61
|
-
return record.currentState.isValid;
|
|
62
|
-
case 'reload':
|
|
63
|
-
return reload;
|
|
64
|
-
case 'rollbackAttributes':
|
|
65
|
-
return rollbackAttributes;
|
|
66
|
-
case 'save':
|
|
67
|
-
return save;
|
|
68
|
-
case 'serialize':
|
|
69
|
-
return serialize;
|
|
70
|
-
case 'unloadRecord':
|
|
71
|
-
return unloadRecord;
|
|
72
|
-
default:
|
|
73
|
-
assert(`${prop} is not a supported legacy field`, false);
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
function withFields(fields) {
|
|
77
|
-
LegacyFields.forEach(field => {
|
|
78
|
-
fields.push({
|
|
79
|
-
type: '@legacy',
|
|
80
|
-
name: field,
|
|
81
|
-
kind: 'derived'
|
|
82
|
-
});
|
|
83
|
-
});
|
|
84
|
-
fields.push({
|
|
85
|
-
name: 'id',
|
|
86
|
-
kind: '@id',
|
|
87
|
-
type: null
|
|
88
|
-
});
|
|
89
|
-
fields.push({
|
|
90
|
-
name: 'isReloading',
|
|
91
|
-
kind: '@local',
|
|
92
|
-
type: 'boolean',
|
|
93
|
-
options: {
|
|
94
|
-
defaultValue: false
|
|
95
|
-
}
|
|
96
|
-
});
|
|
97
|
-
fields.push({
|
|
98
|
-
name: 'isDestroying',
|
|
99
|
-
kind: '@local',
|
|
100
|
-
type: 'boolean',
|
|
101
|
-
options: {
|
|
102
|
-
defaultValue: false
|
|
103
|
-
}
|
|
104
|
-
});
|
|
105
|
-
fields.push({
|
|
106
|
-
name: 'isDestroyed',
|
|
107
|
-
kind: '@local',
|
|
108
|
-
type: 'boolean',
|
|
109
|
-
options: {
|
|
110
|
-
defaultValue: false
|
|
111
|
-
}
|
|
112
|
-
});
|
|
113
|
-
return fields;
|
|
114
|
-
}
|
|
115
|
-
function registerDerivations(schema) {
|
|
116
|
-
schema.registerDerivation('@legacy', legacySupport);
|
|
117
|
-
}
|
|
118
|
-
export { registerDerivations, withFields };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"migration-support.js","sources":["../src/migration-support.ts"],"sourcesContent":["import { assert } from '@ember/debug';\n\nimport { recordIdentifierFor } from '@ember-data/store';\nimport type { FieldSchema } from '@ember-data/store/-types/q/schema-service';\n\nimport { Errors } from './-private';\nimport type { MinimalLegacyRecord } from './-private/model-methods';\nimport {\n belongsTo,\n changedAttributes,\n createSnapshot,\n deleteRecord,\n destroyRecord,\n hasMany,\n reload,\n rollbackAttributes,\n save,\n serialize,\n unloadRecord,\n} from './-private/model-methods';\nimport RecordState from './-private/record-state';\n\ntype Derivation<R, T> = (record: R, options: Record<string, unknown> | null, prop: string) => T;\ntype SchemaService = {\n registerDerivation(name: string, derivation: Derivation<unknown, unknown>): void;\n};\n// 'isDestroying', 'isDestroyed'\nconst LegacyFields = [\n '_createSnapshot',\n 'adapterError',\n 'belongsTo',\n 'changedAttributes',\n 'constructor',\n 'currentState',\n 'deleteRecord',\n 'destroyRecord',\n 'dirtyType',\n 'errors',\n 'hasDirtyAttributes',\n 'hasMany',\n 'isDeleted',\n 'isEmpty',\n 'isError',\n 'isLoaded',\n 'isLoading',\n 'isNew',\n 'isSaving',\n 'isValid',\n 'reload',\n 'rollbackAttributes',\n 'save',\n 'serialize',\n 'unloadRecord',\n];\n\nconst LegacySupport = new WeakMap<MinimalLegacyRecord, Record<string, unknown>>();\n\nfunction legacySupport(record: MinimalLegacyRecord, options: Record<string, unknown> | null, prop: string): unknown {\n let state = LegacySupport.get(record);\n if (!state) {\n state = {};\n LegacySupport.set(record, state);\n }\n\n switch (prop) {\n case '_createSnapshot':\n return createSnapshot;\n case 'adapterError':\n return record.currentState.adapterError;\n case 'belongsTo':\n return belongsTo;\n case 'changedAttributes':\n return changedAttributes;\n case 'constructor':\n return (state._constructor = state._constructor || {\n isModel: true,\n name: `Record<${recordIdentifierFor(record).type}>`,\n modelName: recordIdentifierFor(record).type,\n });\n case 'currentState':\n return (state.recordState = state.recordState || new RecordState(record));\n case 'deleteRecord':\n return deleteRecord;\n case 'destroyRecord':\n return destroyRecord;\n case 'dirtyType':\n return record.currentState.dirtyType;\n case 'errors':\n // @ts-expect-error\n // eslint-disable-next-line @typescript-eslint/no-unsafe-call\n return (state.errors = state.errors || Errors.create({ __record: record }));\n case 'hasDirtyAttributes':\n return record.currentState.isDirty;\n case 'hasMany':\n return hasMany;\n case 'isDeleted':\n return record.currentState.isDeleted;\n case 'isEmpty':\n return record.currentState.isEmpty;\n case 'isError':\n return record.currentState.isError;\n case 'isLoaded':\n return record.currentState.isLoaded;\n case 'isLoading':\n return record.currentState.isLoading;\n case 'isNew':\n return record.currentState.isNew;\n case 'isSaving':\n return record.currentState.isSaving;\n case 'isValid':\n return record.currentState.isValid;\n case 'reload':\n return reload;\n case 'rollbackAttributes':\n return rollbackAttributes;\n case 'save':\n return save;\n case 'serialize':\n return serialize;\n case 'unloadRecord':\n return unloadRecord;\n default:\n assert(`${prop} is not a supported legacy field`, false);\n }\n}\n\nexport function withFields(fields: FieldSchema[]) {\n LegacyFields.forEach((field) => {\n fields.push({\n type: '@legacy',\n name: field,\n kind: 'derived',\n });\n });\n fields.push({\n name: 'id',\n kind: '@id',\n type: null,\n });\n fields.push({\n name: 'isReloading',\n kind: '@local',\n type: 'boolean',\n options: { defaultValue: false },\n });\n fields.push({\n name: 'isDestroying',\n kind: '@local',\n type: 'boolean',\n options: { defaultValue: false },\n });\n fields.push({\n name: 'isDestroyed',\n kind: '@local',\n type: 'boolean',\n options: { defaultValue: false },\n });\n return fields;\n}\n\nexport function registerDerivations(schema: SchemaService) {\n schema.registerDerivation('@legacy', legacySupport as Derivation<unknown, unknown>);\n}\n"],"names":["LegacyFields","LegacySupport","WeakMap","legacySupport","record","options","prop","state","get","set","createSnapshot","currentState","adapterError","belongsTo","changedAttributes","_constructor","isModel","name","recordIdentifierFor","type","modelName","recordState","RecordState","deleteRecord","destroyRecord","dirtyType","errors","Errors","create","__record","isDirty","hasMany","isDeleted","isEmpty","isError","isLoaded","isLoading","isNew","isSaving","isValid","reload","rollbackAttributes","save","serialize","unloadRecord","assert","withFields","fields","forEach","field","push","kind","defaultValue","registerDerivations","schema","registerDerivation"],"mappings":";;;;;;;;;;A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