@ember-data/model 5.3.11 → 5.3.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (59) hide show
  1. package/LICENSE.md +19 -7
  2. package/README.md +2 -2
  3. package/dist/-private.js +3 -2
  4. package/dist/-private.js.map +1 -1
  5. package/dist/{has-many-BlJm_gf3.js → has-many-DZX7l2bT.js} +1 -1
  6. package/dist/{has-many-BlJm_gf3.js.map → has-many-DZX7l2bT.js.map} +1 -1
  7. package/dist/{hooks-CkH3DloZ.js → hooks-RqMlE4Jk.js} +2 -2
  8. package/dist/{hooks-CkH3DloZ.js.map → hooks-RqMlE4Jk.js.map} +1 -1
  9. package/dist/hooks.js +2 -2
  10. package/dist/index.js +5 -4
  11. package/dist/index.js.map +1 -1
  12. package/dist/migration-support.js +2 -2
  13. package/dist/migration-support.js.map +1 -1
  14. package/dist/{model-CGNpakSA.js → model-6Exz3e1N.js} +77 -515
  15. package/dist/model-6Exz3e1N.js.map +1 -0
  16. package/dist/{schema-provider-CAdwIBw4.js → schema-provider-B-FIifVG.js} +1 -1
  17. package/dist/schema-provider-B-FIifVG.js.map +1 -0
  18. package/logos/NCC-1701-a-blue.svg +4 -0
  19. package/logos/NCC-1701-a-gold.svg +4 -0
  20. package/logos/NCC-1701-a-gold_100.svg +1 -0
  21. package/logos/NCC-1701-a-gold_base-64.txt +1 -0
  22. package/logos/NCC-1701-a.svg +4 -0
  23. package/logos/README.md +4 -0
  24. package/logos/docs-badge.svg +2 -0
  25. package/logos/github-header.svg +444 -0
  26. package/logos/social1.png +0 -0
  27. package/logos/social2.png +0 -0
  28. package/logos/warp-drive-logo-dark.svg +4 -0
  29. package/logos/warp-drive-logo-gold.svg +4 -0
  30. package/package.json +32 -63
  31. package/unstable-preview-types/-private/debug/assert-polymorphic-type.d.ts.map +1 -1
  32. package/unstable-preview-types/-private/legacy-relationships-support.d.ts +1 -1
  33. package/unstable-preview-types/-private/legacy-relationships-support.d.ts.map +1 -1
  34. package/unstable-preview-types/-private/model.d.ts +21 -23
  35. package/unstable-preview-types/-private/model.d.ts.map +1 -1
  36. package/unstable-preview-types/-private/notify-changes.d.ts.map +1 -1
  37. package/unstable-preview-types/-private/promise-many-array.d.ts +1 -1
  38. package/unstable-preview-types/-private/promise-many-array.d.ts.map +1 -1
  39. package/unstable-preview-types/-private/promise-proxy-base.d.ts +5 -0
  40. package/unstable-preview-types/-private/promise-proxy-base.d.ts.map +1 -0
  41. package/unstable-preview-types/-private/record-state.d.ts +1 -1
  42. package/unstable-preview-types/-private/references/has-many.d.ts +1 -1
  43. package/unstable-preview-types/-private/references/has-many.d.ts.map +1 -1
  44. package/unstable-preview-types/-private/schema-provider.d.ts +7 -7
  45. package/unstable-preview-types/-private/schema-provider.d.ts.map +1 -1
  46. package/unstable-preview-types/-private/type-utils.d.ts +1 -1
  47. package/unstable-preview-types/-private/type-utils.d.ts.map +1 -1
  48. package/unstable-preview-types/-private.d.ts +1 -1
  49. package/unstable-preview-types/-private.d.ts.map +1 -1
  50. package/unstable-preview-types/index.d.ts +19 -19
  51. package/unstable-preview-types/index.d.ts.map +1 -1
  52. package/unstable-preview-types/migration-support.d.ts +4 -4
  53. package/unstable-preview-types/migration-support.d.ts.map +1 -1
  54. package/dist/model-CGNpakSA.js.map +0 -1
  55. package/dist/schema-provider-CAdwIBw4.js.map +0 -1
  56. package/unstable-preview-types/-private/many-array.d.ts +0 -196
  57. package/unstable-preview-types/-private/many-array.d.ts.map +0 -1
  58. /package/{ember-data-logo-dark.svg → logos/ember-data-logo-dark.svg} +0 -0
  59. /package/{ember-data-logo-light.svg → logos/ember-data-logo-light.svg} +0 -0
@@ -1 +0,0 @@
1
- {"version":3,"file":"schema-provider-CAdwIBw4.js","sources":["../src/-private/model-for-mixin.ts","../src/-private/schema-provider.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) as unknown as { __isMixin: boolean; __mixin: typeof 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';\nimport { deprecate } from '@ember/debug';\n\nimport type Store from '@ember-data/store';\nimport type { SchemaService } from '@ember-data/store/types';\nimport { ENABLE_LEGACY_SCHEMA_SERVICE } from '@warp-drive/build-config/deprecations';\nimport { assert } from '@warp-drive/build-config/macros';\nimport type { RecordIdentifier, StableRecordIdentifier } from '@warp-drive/core-types/identifier';\nimport type { ObjectValue } from '@warp-drive/core-types/json/raw';\nimport type { Derivation, HashFn, Transformation } from '@warp-drive/core-types/schema/concepts';\nimport type {\n ArrayField,\n DerivedField,\n GenericField,\n HashField,\n LegacyAttributeField,\n LegacyFieldSchema,\n LegacyRelationshipSchema,\n ObjectField,\n ResourceSchema,\n} from '@warp-drive/core-types/schema/fields';\n\nimport type { FactoryCache, Model, ModelFactory, ModelStore } from './model';\nimport _modelForMixin from './model-for-mixin';\nimport { normalizeModelName } from './util';\n\ntype AttributesSchema = ReturnType<Exclude<SchemaService['attributesDefinitionFor'], undefined>>;\ntype RelationshipsSchema = ReturnType<Exclude<SchemaService['relationshipsDefinitionFor'], undefined>>;\n\ntype InternalSchema = {\n schema: ResourceSchema;\n fields: Map<string, LegacyAttributeField | LegacyRelationshipSchema>;\n attributes: Record<string, LegacyAttributeField>;\n relationships: Record<string, LegacyRelationshipSchema>;\n};\n\nexport interface ModelSchemaProvider {\n attributesDefinitionFor(resource: RecordIdentifier | { type: string }): AttributesSchema;\n\n relationshipsDefinitionFor(resource: RecordIdentifier | { type: string }): RelationshipsSchema;\n\n doesTypeExist(type: string): boolean;\n}\nexport class ModelSchemaProvider implements SchemaService {\n declare store: ModelStore;\n declare _schemas: Map<string, InternalSchema>;\n declare _typeMisses: Set<string>;\n\n constructor(store: ModelStore) {\n this.store = store;\n this._schemas = new Map();\n this._typeMisses = new Set();\n }\n\n hasTrait(type: string): boolean {\n assert(`hasTrait is not available with @ember-data/model's SchemaService`);\n return false;\n }\n resourceHasTrait(resource: StableRecordIdentifier | { type: string }, trait: string): boolean {\n assert(`resourceHasTrait is not available with @ember-data/model's SchemaService`);\n return false;\n }\n transformation(field: GenericField | ObjectField | ArrayField | { type: string }): Transformation {\n assert(`transformation is not available with @ember-data/model's SchemaService`);\n }\n derivation(field: DerivedField | { type: string }): Derivation {\n assert(`derivation is not available with @ember-data/model's SchemaService`);\n }\n hashFn(field: HashField | { type: string }): HashFn {\n assert(`hashFn is not available with @ember-data/model's SchemaService`);\n }\n resource(resource: StableRecordIdentifier | { type: string }): ResourceSchema {\n const type = normalizeModelName(resource.type);\n\n if (!this._schemas.has(type)) {\n this._loadModelSchema(type);\n }\n\n return this._schemas.get(type)!.schema;\n }\n registerResources(schemas: ResourceSchema[]): void {\n assert(`registerResources is not available with @ember-data/model's SchemaService`);\n }\n registerResource(schema: ResourceSchema): void {\n assert(`registerResource is not available with @ember-data/model's SchemaService`);\n }\n registerTransformation(transform: Transformation): void {\n assert(`registerTransformation is not available with @ember-data/model's SchemaService`);\n }\n registerDerivation<R, T, FM extends ObjectValue | null>(derivation: Derivation<R, T, FM>): void {\n assert(`registerDerivation is not available with @ember-data/model's SchemaService`);\n }\n registerHashFn(hashFn: HashFn): void {\n assert(`registerHashFn is not available with @ember-data/model's SchemaService`);\n }\n _loadModelSchema(type: string) {\n const modelClass = this.store.modelFor(type) as typeof Model;\n const attributeMap = modelClass.attributes;\n\n const attributes = Object.create(null) as AttributesSchema;\n attributeMap.forEach((meta, name) => (attributes[name] = meta));\n const relationships = modelClass.relationshipsObject || null;\n const fields = new Map<string, LegacyAttributeField | LegacyRelationshipSchema>();\n\n for (const attr of Object.values(attributes)) {\n fields.set(attr.name, attr);\n }\n\n for (const rel of Object.values(relationships)) {\n fields.set(rel.name, rel);\n }\n\n const schema: ResourceSchema = {\n legacy: true,\n identity: { name: 'id', kind: '@id' },\n type,\n fields: Array.from(fields.values()),\n };\n\n const internalSchema: InternalSchema = {\n schema,\n attributes,\n relationships,\n fields,\n };\n\n this._schemas.set(type, internalSchema);\n\n return internalSchema;\n }\n\n fields(resource: RecordIdentifier | { type: string }): Map<string, LegacyFieldSchema> {\n const type = normalizeModelName(resource.type);\n\n if (!this._schemas.has(type)) {\n this._loadModelSchema(type);\n }\n\n return this._schemas.get(type)!.fields;\n }\n\n hasResource(resource: { type: string }): boolean {\n const type = normalizeModelName(resource.type);\n\n if (this._schemas.has(type)) {\n return true;\n }\n\n if (this._typeMisses.has(type)) {\n return false;\n }\n\n const factory = getModelFactory(this.store, type);\n const exists = factory !== null;\n\n if (!exists) {\n this._typeMisses.add(type);\n return false;\n }\n\n return true;\n }\n}\n\nif (ENABLE_LEGACY_SCHEMA_SERVICE) {\n ModelSchemaProvider.prototype.doesTypeExist = function (type: string): boolean {\n deprecate(`Use \\`schema.hasResource({ type })\\` instead of \\`schema.doesTypeExist(type)\\``, false, {\n id: 'ember-data:schema-service-updates',\n until: '6.0',\n for: 'ember-data',\n since: {\n available: '4.13',\n enabled: '5.4',\n },\n });\n return this.hasResource({ type });\n };\n\n ModelSchemaProvider.prototype.attributesDefinitionFor = function (\n resource: RecordIdentifier | { type: string }\n ): AttributesSchema {\n deprecate(`Use \\`schema.fields({ type })\\` instead of \\`schema.attributesDefinitionFor({ type })\\``, false, {\n id: 'ember-data:schema-service-updates',\n until: '6.0',\n for: 'ember-data',\n since: {\n available: '4.13',\n enabled: '5.4',\n },\n });\n const type = normalizeModelName(resource.type);\n\n if (!this._schemas.has(type)) {\n this._loadModelSchema(type);\n }\n\n return this._schemas.get(type)!.attributes;\n };\n\n ModelSchemaProvider.prototype.relationshipsDefinitionFor = function (\n resource: RecordIdentifier | { type: string }\n ): RelationshipsSchema {\n deprecate(`Use \\`schema.fields({ type })\\` instead of \\`schema.relationshipsDefinitionFor({ type })\\``, false, {\n id: 'ember-data:schema-service-updates',\n until: '6.0',\n for: 'ember-data',\n since: {\n available: '4.13',\n enabled: '5.4',\n },\n });\n const type = normalizeModelName(resource.type);\n\n if (!this._schemas.has(type)) {\n this._loadModelSchema(type);\n }\n\n return this._schemas.get(type)!.relationships;\n };\n}\n\nexport function buildSchema(store: Store): SchemaService {\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"],"names":["modelForMixin","store","normalizedModelName","owner","getOwner","MaybeMixin","factoryFor","mixin","class","ModelForMixin","Model","extend","__isMixin","__mixin","register","ModelSchemaProvider","constructor","_schemas","Map","_typeMisses","Set","hasTrait","type","macroCondition","getGlobalConfig","WarpDrive","env","DEBUG","test","Error","resourceHasTrait","resource","trait","transformation","field","derivation","hashFn","normalizeModelName","has","_loadModelSchema","get","schema","registerResources","schemas","registerResource","registerTransformation","transform","registerDerivation","registerHashFn","modelClass","modelFor","attributeMap","attributes","Object","create","forEach","meta","name","relationships","relationshipsObject","fields","attr","values","set","rel","legacy","identity","kind","Array","from","internalSchema","hasResource","factory","getModelFactory","exists","add","deprecations","ENABLE_LEGACY_SCHEMA_SERVICE","prototype","doesTypeExist","deprecate","id","until","for","since","available","enabled","attributesDefinitionFor","relationshipsDefinitionFor","buildSchema","_modelFactoryCache","cache","_modelForMixin","klass","isModel","hasOwnModelNameSet","modelName","hasOwnProperty","call","defineProperty","value"],"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,CAAC,CAAA,MAAA,EAASJ,mBAAmB,CAAA,CAAE,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,CAA6D,CAAA;IACrGE,aAAa,CAACG,SAAS,GAAG,IAAI,CAAA;IAC9BH,aAAa,CAACI,OAAO,GAAGN,KAAK,CAAA;AAC7B;IACAJ,KAAK,CAACW,QAAQ,CAAC,CAAA,MAAA,EAASZ,mBAAmB,CAAE,CAAA,EAAEO,aAAa,CAAC,CAAA;AAC/D,GAAA;AACA,EAAA,OAAON,KAA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AA,OAAO,GAAGoB,aAAc,CAAC3F,KAAK,EAAEqB,IAAI,CAAC,CAAA;AACvC,KAAA;IAEA,IAAI,CAACkD,OAAO,EAAE;AACZ;AACA,MAAA,OAAO,IAAI,CAAA;AACb,KAAA;AAEA,IAAA,MAAMqB,KAAK,GAAGrB,OAAO,CAAChE,KAAK,CAAA;IAE3B,IAAIqF,KAAK,CAACC,OAAO,EAAE;AACjB,MAAA,MAAMC,kBAAkB,GAAGF,KAAK,CAACG,SAAS,IAAI3C,MAAM,CAACyB,SAAS,CAACmB,cAAc,CAACC,IAAI,CAACL,KAAK,EAAE,WAAW,CAAC,CAAA;MACtG,IAAI,CAACE,kBAAkB,EAAE;AACvB1C,QAAAA,MAAM,CAAC8C,cAAc,CAACN,KAAK,EAAE,WAAW,EAAE;AAAEO,UAAAA,KAAK,EAAE9E,IAAAA;AAAK,SAAC,CAAC,CAAA;AAC5D,OAAA;AACF,KAAA;AAEAqE,IAAAA,KAAK,CAACrE,IAAI,CAAC,GAAGkD,OAAO,CAAA;AACvB,GAAA;AAEA,EAAA,OAAOA,OAAO,CAAA;AAChB;;;;"}
@@ -1,196 +0,0 @@
1
- declare module '@ember-data/model/-private/many-array' {
2
- import type Store from '@ember-data/store';
3
- import type { CreateRecordProperties, NativeProxy } from '@ember-data/store/-private';
4
- import { LiveArray, MUTATE } from '@ember-data/store/-private';
5
- import type { BaseFinderOptions, ModelSchema } from '@ember-data/store/types';
6
- import type { Signal } from '@ember-data/tracking/-private';
7
- import type { StableRecordIdentifier } from '@warp-drive/core-types';
8
- import type { Cache } from '@warp-drive/core-types/cache';
9
- import type { TypedRecordInstance, TypeFromInstance, TypeFromInstanceOrString } from '@warp-drive/core-types/record';
10
- import type { Links, PaginationLinks } from '@warp-drive/core-types/spec/json-api-raw';
11
- import type { LegacySupport } from '@ember-data/model/-private/legacy-relationships-support';
12
- export interface ManyArrayCreateArgs<T> {
13
- identifiers: StableRecordIdentifier<TypeFromInstanceOrString<T>>[];
14
- type: TypeFromInstanceOrString<T>;
15
- store: Store;
16
- allowMutation: boolean;
17
- manager: LegacySupport;
18
- identifier: StableRecordIdentifier;
19
- cache: Cache;
20
- meta: Record<string, unknown> | null;
21
- links: Links | PaginationLinks | null;
22
- key: string;
23
- isPolymorphic: boolean;
24
- isAsync: boolean;
25
- _inverseIsAsync: boolean;
26
- isLoaded: boolean;
27
- }
28
- /**
29
- A `ManyArray` is a `MutableArray` that represents the contents of a has-many
30
- relationship.
31
-
32
- The `ManyArray` is instantiated lazily the first time the relationship is
33
- requested.
34
-
35
- This class is not intended to be directly instantiated by consuming applications.
36
-
37
- ### Inverses
38
-
39
- Often, the relationships in Ember Data applications will have
40
- an inverse. For example, imagine the following models are
41
- defined:
42
-
43
- ```app/models/post.js
44
- import Model, { hasMany } from '@ember-data/model';
45
-
46
- export default class PostModel extends Model {
47
- @hasMany('comment') comments;
48
- }
49
- ```
50
-
51
- ```app/models/comment.js
52
- import Model, { belongsTo } from '@ember-data/model';
53
-
54
- export default class CommentModel extends Model {
55
- @belongsTo('post') post;
56
- }
57
- ```
58
-
59
- If you created a new instance of `Post` and added
60
- a `Comment` record to its `comments` has-many
61
- relationship, you would expect the comment's `post`
62
- property to be set to the post that contained
63
- the has-many.
64
-
65
- We call the record to which a relationship belongs-to the
66
- relationship's _owner_.
67
-
68
- @class ManyArray
69
- @public
70
- */
71
- export class RelatedCollection<T = unknown> extends LiveArray<T> {
72
- isAsync: boolean;
73
- /**
74
- The loading state of this array
75
-
76
- @property {Boolean} isLoaded
77
- @public
78
- */
79
- isLoaded: boolean;
80
- /**
81
- `true` if the relationship is polymorphic, `false` otherwise.
82
-
83
- @property {Boolean} isPolymorphic
84
- @private
85
- */
86
- isPolymorphic: boolean;
87
- _inverseIsAsync: boolean;
88
- /**
89
- Metadata associated with the request for async hasMany relationships.
90
-
91
- Example
92
-
93
- Given that the server returns the following JSON payload when fetching a
94
- hasMany relationship:
95
-
96
- ```js
97
- {
98
- "comments": [{
99
- "id": 1,
100
- "comment": "This is the first comment",
101
- }, {
102
- // ...
103
- }],
104
-
105
- "meta": {
106
- "page": 1,
107
- "total": 5
108
- }
109
- }
110
- ```
111
-
112
- You can then access the meta data via the `meta` property:
113
-
114
- ```js
115
- let comments = await post.comments;
116
- let meta = comments.meta;
117
-
118
- // meta.page => 1
119
- // meta.total => 5
120
- ```
121
-
122
- @property {Object | null} meta
123
- @public
124
- */
125
- meta: Record<string, unknown> | null;
126
- /**
127
- * Retrieve the links for this relationship
128
- *
129
- @property {Object | null} links
130
- @public
131
- */
132
- links: Links | PaginationLinks | null;
133
- identifier: StableRecordIdentifier;
134
- cache: Cache;
135
- _manager: LegacySupport;
136
- store: Store;
137
- key: string;
138
- type: ModelSchema;
139
- modelName: T extends TypedRecordInstance ? TypeFromInstance<T> : string;
140
- constructor(options: ManyArrayCreateArgs<T>);
141
- [MUTATE](target: StableRecordIdentifier[], receiver: typeof NativeProxy<StableRecordIdentifier[], T[]>, prop: string, args: unknown[], _SIGNAL: Signal): unknown;
142
- notify(): void;
143
- /**
144
- Reloads all of the records in the manyArray. If the manyArray
145
- holds a relationship that was originally fetched using a links url
146
- EmberData will revisit the original links url to repopulate the
147
- relationship.
148
-
149
- If the ManyArray holds the result of a `store.query()` reload will
150
- re-run the original query.
151
-
152
- Example
153
-
154
- ```javascript
155
- let user = store.peekRecord('user', '1')
156
- await login(user);
157
-
158
- let permissions = await user.permissions;
159
- await permissions.reload();
160
- ```
161
-
162
- @method reload
163
- @public
164
- */
165
- reload(options?: BaseFinderOptions): Promise<this>;
166
- /**
167
- Saves all of the records in the `ManyArray`.
168
-
169
- Example
170
-
171
- ```javascript
172
- let inbox = await store.findRecord('inbox', '1');
173
- let messages = await inbox.messages;
174
- messages.forEach((message) => {
175
- message.isRead = true;
176
- });
177
- messages.save();
178
- ```
179
-
180
- @method save
181
- @public
182
- @return {PromiseArray} promise
183
- */
184
- /**
185
- Create a child record within the owner
186
-
187
- @method createRecord
188
- @public
189
- @param {Object} hash
190
- @return {Model} record
191
- */
192
- createRecord(hash: CreateRecordProperties<T>): T;
193
- destroy(): void;
194
- }
195
- }
196
- //# sourceMappingURL=many-array.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"many-array.d.ts","sourceRoot":"","sources":["../../src/-private/many-array.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,KAAK,MAAM,mBAAmB,CAAC;AAC3C,OAAO,KAAK,EAAE,sBAAsB,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AACtF,OAAO,EAGL,SAAS,EACT,MAAM,EAIP,MAAM,4BAA4B,CAAC;AACpC,OAAO,KAAK,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAC9E,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,+BAA+B,CAAC;AAI5D,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAC;AACrE,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,8BAA8B,CAAC;AAC1D,OAAO,KAAK,EAEV,mBAAmB,EACnB,gBAAgB,EAChB,wBAAwB,EACzB,MAAM,+BAA+B,CAAC;AACvC,OAAO,KAAK,EAAE,KAAK,EAAE,eAAe,EAAE,MAAM,0CAA0C,CAAC;AAEvF,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAC;AAIpE,MAAM,WAAW,mBAAmB,CAAC,CAAC;IACpC,WAAW,EAAE,sBAAsB,CAAC,wBAAwB,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;IACnE,IAAI,EAAE,wBAAwB,CAAC,CAAC,CAAC,CAAC;IAClC,KAAK,EAAE,KAAK,CAAC;IACb,aAAa,EAAE,OAAO,CAAC;IACvB,OAAO,EAAE,aAAa,CAAC;IAEvB,UAAU,EAAE,sBAAsB,CAAC;IACnC,KAAK,EAAE,KAAK,CAAC;IACb,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;IACrC,KAAK,E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