@ember-data/model 5.5.0-alpha.22 → 5.5.0-alpha.24
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 +1 -1
- package/dist/-private.js +2 -2
- package/dist/{has-many-CwEZBhUG.js → has-many-BXU96bZ9.js} +5 -5
- package/dist/{has-many-CwEZBhUG.js.map → has-many-BXU96bZ9.js.map} +1 -1
- package/dist/{hooks-C6_7V3O3.js → hooks-o1U_cEA3.js} +2 -2
- package/dist/{hooks-C6_7V3O3.js.map → hooks-o1U_cEA3.js.map} +1 -1
- package/dist/hooks.js +2 -2
- package/dist/index.js +4 -4
- package/dist/migration-support.js +177 -2
- package/dist/migration-support.js.map +1 -1
- package/dist/{model-B9PHp6Pe.js → model-Dkk-TZlL.js} +22 -12
- package/dist/model-Dkk-TZlL.js.map +1 -0
- package/dist/{schema-provider-WdyaNQ3o.js → schema-provider-DyG6fJXt.js} +1 -1
- package/dist/{schema-provider-WdyaNQ3o.js.map → schema-provider-DyG6fJXt.js.map} +1 -1
- package/package.json +16 -16
- package/unstable-preview-types/-private/belongs-to.d.ts +2 -2
- package/unstable-preview-types/-private/errors.d.ts +2 -2
- package/unstable-preview-types/-private/has-many.d.ts +2 -2
- package/unstable-preview-types/-private/promise-many-array.d.ts +8 -4
- package/unstable-preview-types/-private/promise-many-array.d.ts.map +1 -1
- package/unstable-preview-types/-private/references/belongs-to.d.ts +6 -3
- package/unstable-preview-types/-private/references/belongs-to.d.ts.map +1 -1
- package/unstable-preview-types/-private/references/has-many.d.ts +6 -3
- package/unstable-preview-types/-private/references/has-many.d.ts.map +1 -1
- package/unstable-preview-types/index.d.ts +1 -0
- package/unstable-preview-types/migration-support.d.ts +210 -3
- package/unstable-preview-types/migration-support.d.ts.map +1 -1
- package/unstable-preview-types/migration-support.type-test.d.ts +4 -0
- package/unstable-preview-types/migration-support.type-test.d.ts.map +1 -0
- package/dist/model-B9PHp6Pe.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"migration-support.js","sources":["../src/migration-support.ts"],"sourcesContent":["import type Store from '@ember-data/store';\nimport { recordIdentifierFor } 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 { StableRecordIdentifier } from '@warp-drive/core-types';\nimport { getOrSetGlobal } from '@warp-drive/core-types/-private';\nimport type { ObjectValue } from '@warp-drive/core-types/json/raw';\nimport type { TypedRecordInstance } from '@warp-drive/core-types/record';\nimport type { Derivation, HashFn, Transformation } from '@warp-drive/core-types/schema/concepts';\nimport type {\n ArrayField,\n DerivedField,\n FieldSchema,\n GenericField,\n HashField,\n ObjectField,\n ObjectSchema,\n ResourceSchema,\n} from '@warp-drive/core-types/schema/fields';\nimport { Type } from '@warp-drive/core-types/symbols';\nimport type { WithPartial } from '@warp-drive/core-types/utils';\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';\nimport { buildSchema } from './hooks';\n\nexport type WithLegacyDerivations<T extends TypedRecordInstance> = T &\n MinimalLegacyRecord & {\n belongsTo: typeof belongsTo;\n hasMany: typeof hasMany;\n };\n\ntype AttributesSchema = ReturnType<Exclude<SchemaService['attributesDefinitionFor'], undefined>>;\ntype RelationshipsSchema = ReturnType<Exclude<SchemaService['relationshipsDefinitionFor'], undefined>>;\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 = getOrSetGlobal('LegacySupport', new WeakMap<MinimalLegacyRecord, Record<string, unknown>>());\n\nfunction legacySupport(record: MinimalLegacyRecord, options: ObjectValue | 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}\nlegacySupport[Type] = '@legacy';\n\nexport function withDefaults(schema: WithPartial<ResourceSchema, 'legacy' | 'identity'>): ResourceSchema {\n schema.legacy = true;\n schema.identity = { kind: '@id', name: 'id' };\n\n LegacyFields.forEach((field) => {\n schema.fields.push({\n type: '@legacy',\n name: field,\n kind: 'derived',\n });\n });\n schema.fields.push({\n name: 'isReloading',\n kind: '@local',\n type: 'boolean',\n options: { defaultValue: false },\n });\n schema.fields.push({\n name: 'isDestroying',\n kind: '@local',\n type: 'boolean',\n options: { defaultValue: false },\n });\n schema.fields.push({\n name: 'isDestroyed',\n kind: '@local',\n type: 'boolean',\n options: { defaultValue: false },\n });\n return schema as ResourceSchema;\n}\n\nexport function registerDerivations(schema: SchemaService) {\n schema.registerDerivation(legacySupport);\n}\n\nexport interface DelegatingSchemaService {\n attributesDefinitionFor?(resource: StableRecordIdentifier | { type: string }): AttributesSchema;\n relationshipsDefinitionFor?(resource: StableRecordIdentifier | { type: string }): RelationshipsSchema;\n doesTypeExist?(type: string): boolean;\n}\nexport class DelegatingSchemaService implements SchemaService {\n _preferred!: SchemaService;\n _secondary!: SchemaService;\n\n constructor(store: Store, schema: SchemaService) {\n this._preferred = schema;\n this._secondary = buildSchema(store);\n }\n\n resourceTypes(): Readonly<string[]> {\n return Array.from(new Set(this._preferred.resourceTypes().concat(this._secondary.resourceTypes())));\n }\n\n hasResource(resource: StableRecordIdentifier | { type: string }): boolean {\n return this._preferred.hasResource(resource) || this._secondary.hasResource(resource);\n }\n hasTrait(type: string): boolean {\n if (this._preferred.hasResource({ type })) {\n return this._preferred.hasTrait(type);\n }\n return this._secondary.hasTrait(type);\n }\n resourceHasTrait(resource: StableRecordIdentifier | { type: string }, trait: string): boolean {\n if (this._preferred.hasResource(resource)) {\n return this._preferred.resourceHasTrait(resource, trait);\n }\n return this._secondary.resourceHasTrait(resource, trait);\n }\n fields(resource: StableRecordIdentifier | { type: string }): Map<string, FieldSchema> {\n if (this._preferred.hasResource(resource)) {\n return this._preferred.fields(resource);\n }\n return this._secondary.fields(resource);\n }\n transformation(field: GenericField | ObjectField | ArrayField | { type: string }): Transformation {\n return this._preferred.transformation(field);\n }\n hashFn(field: HashField | { type: string }): HashFn {\n return this._preferred.hashFn(field);\n }\n derivation(field: DerivedField | { type: string }): Derivation {\n return this._preferred.derivation(field);\n }\n resource(resource: StableRecordIdentifier | { type: string }): ResourceSchema | ObjectSchema {\n if (this._preferred.hasResource(resource)) {\n return this._preferred.resource(resource);\n }\n return this._secondary.resource(resource);\n }\n registerResources(schemas: Array<ResourceSchema | ObjectSchema>): void {\n this._preferred.registerResources(schemas);\n }\n registerResource(schema: ResourceSchema | ObjectSchema): void {\n this._preferred.registerResource(schema);\n }\n registerTransformation(transform: Transformation): void {\n this._preferred.registerTransformation(transform);\n }\n registerDerivation<R, T, FM extends ObjectValue | null>(derivation: Derivation<R, T, FM>): void {\n this._preferred.registerDerivation(derivation);\n }\n registerHashFn(hashFn: HashFn): void {\n this._preferred.registerHashFn(hashFn);\n }\n}\n\nif (ENABLE_LEGACY_SCHEMA_SERVICE) {\n DelegatingSchemaService.prototype.attributesDefinitionFor = function (\n resource: StableRecordIdentifier | { type: string }\n ) {\n if (this._preferred.hasResource(resource)) {\n return this._preferred.attributesDefinitionFor!(resource);\n }\n\n return this._secondary.attributesDefinitionFor!(resource);\n };\n DelegatingSchemaService.prototype.relationshipsDefinitionFor = function (\n resource: StableRecordIdentifier | { type: string }\n ) {\n if (this._preferred.hasResource(resource)) {\n return this._preferred.relationshipsDefinitionFor!(resource);\n }\n\n return this._secondary.relationshipsDefinitionFor!(resource);\n };\n DelegatingSchemaService.prototype.doesTypeExist = function (type: string) {\n return this._preferred.doesTypeExist?.(type) || this._secondary.doesTypeExist?.(type) || false;\n };\n}\n"],"names":["LegacyFields","LegacySupport","getOrSetGlobal","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","macroCondition","getGlobalConfig","WarpDrive","env","DEBUG","test","Error","Type","withDefaults","schema","legacy","identity","kind","forEach","field","fields","push","defaultValue","registerDerivations","registerDerivation","DelegatingSchemaService","_preferred","_secondary","constructor","store","buildSchema","resourceTypes","Array","from","Set","concat","hasResource","resource","hasTrait","resourceHasTrait","trait","transformation","hashFn","derivation","registerResources","schemas","registerResource","registerTransformation","transform","registerHashFn","deprecations","ENABLE_LEGACY_SCHEMA_SERVICE","prototype","attributesDefinitionFor","relationshipsDefinitionFor","doesTypeExist"],"mappings":";;;;;;;;;;;;AAkDA;AACA,MAAMA,YAAY,GAAG,CACnB,iBAAiB,EACjB,cAAc,EACd,WAAW,EACX,mBAAmB,EACnB,aAAa,EACb,cAAc,EACd,cAAc,EACd,eAAe,EACf,WAAW,EACX,QAAQ,EACR,oBAAoB,EACpB,SAAS,EACT,WAAW,EACX,SAAS,EACT,SAAS,EACT,UAAU,EACV,WAAW,EACX,OAAO,EACP,UAAU,EACV,SAAS,EACT,QAAQ,EACR,oBAAoB,EACpB,MAAM,EACN,WAAW,EACX,cAAc,CACf;AAED,MAAMC,aAAa,GAAGC,cAAc,CAAC,eAAe,EAAE,IAAIC,OAAO,EAAgD,CAAC;AAElH,SAASC,aAAaA,CAACC,MAA2B,EAAEC,OAA2B,EAAEC,IAAY,EAAW;AACtG,EAAA,IAAIC,KAAK,GAAGP,aAAa,CAACQ,GAAG,CAACJ,MAAM,CAAC;EACrC,IAAI,CAACG,KAAK,EAAE;IACVA,KAAK,GAAG,EAAE;AACVP,IAAAA,aAAa,CAACS,GAAG,CAACL,MAAM,EAAEG,KAAK,CAAC;AAClC;AAEA,EAAA,QAAQD,IAAI;AACV,IAAA,KAAK,iBAAiB;AACpB,MAAA,OAAOI,cAAc;AACvB,IAAA,KAAK,cAAc;AACjB,MAAA,OAAON,MA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AAQ,CAAC,EAAE;AACzC,MAAA,OAAO,IAAI,CAACX,UAAU,CAAC2B,uBAAuB,CAAEhB,QAAQ,CAAC;AAC3D;AAEA,IAAA,OAAO,IAAI,CAACV,UAAU,CAAC0B,uBAAuB,CAAEhB,QAAQ,CAAC;GAC1D;AACDZ,EAAAA,uBAAuB,CAAC2B,SAAS,CAACE,0BAA0B,GAAG,UAC7DjB,QAAmD,EACnD;IACA,IAAI,IAAI,CAACX,UAAU,CAACU,WAAW,CAACC,QAAQ,CAAC,EAAE;AACzC,MAAA,OAAO,IAAI,CAACX,UAAU,CAAC4B,0BAA0B,CAAEjB,QAAQ,CAAC;AAC9D;AAEA,IAAA,OAAO,IAAI,CAACV,UAAU,CAAC2B,0BAA0B,CAAEjB,QAAQ,CAAC;GAC7D;AACDZ,EAAAA,uBAAuB,CAAC2B,SAAS,CAACG,aAAa,GAAG,UAAU5E,IAAY,EAAE;AACxE,IAAA,OAAO,IAAI,CAAC+C,UAAU,CAAC6B,aAAa,GAAG5E,IAAI,CAAC,IAAI,IAAI,CAACgD,UAAU,CAAC4B,aAAa,GAAG5E,IAAI,CAAC,IAAI,KAAK;GAC/F;AACH;;;;"}
|
|
1
|
+
{"version":3,"file":"migration-support.js","sources":["../src/migration-support.ts"],"sourcesContent":["/**\n * This module provides support for migrating away from @ember-data/model\n * to @warp-drive/schema-record.\n *\n * It includes:\n *\n * - A `withDefaults` function to assist in creating a schema in LegacyMode\n * - A `registerDerivations` function to register the derivations necessary to support LegacyMode\n * - A `DelegatingSchemaService` that can be used to provide a schema service that works with both\n * @ember-data/model and @warp-drive/schema-record simultaneously for migration purposes.\n * - A `WithLegacy` type util that can be used to create a type that includes the legacy\n * properties and methods of a record.\n *\n * Using LegacyMode features on a SchemaRecord *requires* the use of these derivations and schema\n * additions. LegacyMode is not intended to be a long-term solution, but rather a stepping stone\n * to assist in more rapidly adopting modern WarpDrive features.\n *\n * @module @ember-data/model/migration-support\n * @main @ember-data/model/migration-support\n */\nimport type { Snapshot } from '@ember-data/legacy-compat/-private';\nimport type Store from '@ember-data/store';\nimport { recordIdentifierFor } 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 { StableRecordIdentifier } from '@warp-drive/core-types';\nimport { getOrSetGlobal } from '@warp-drive/core-types/-private';\nimport type { ChangedAttributesHash } from '@warp-drive/core-types/cache';\nimport type { ObjectValue } from '@warp-drive/core-types/json/raw';\nimport type { TypedRecordInstance, TypeFromInstance } from '@warp-drive/core-types/record';\nimport type { Derivation, HashFn, Transformation } from '@warp-drive/core-types/schema/concepts';\nimport type {\n ArrayField,\n DerivedField,\n FieldSchema,\n GenericField,\n HashField,\n LegacyResourceSchema,\n ObjectField,\n ObjectSchema,\n ResourceSchema,\n} from '@warp-drive/core-types/schema/fields';\nimport { Type } from '@warp-drive/core-types/symbols';\nimport type { WithPartial } from '@warp-drive/core-types/utils';\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';\nimport type BelongsToReference from './-private/references/belongs-to';\nimport type HasManyReference from './-private/references/has-many';\nimport type { _MaybeBelongsToFields, MaybeHasManyFields } from './-private/type-utils';\nimport { buildSchema } from './hooks';\n\nexport type WithLegacyDerivations<T extends TypedRecordInstance> = T &\n MinimalLegacyRecord & {\n belongsTo: typeof belongsTo;\n hasMany: typeof hasMany;\n };\n\ntype AttributesSchema = ReturnType<Exclude<SchemaService['attributesDefinitionFor'], undefined>>;\ntype RelationshipsSchema = ReturnType<Exclude<SchemaService['relationshipsDefinitionFor'], undefined>>;\n\ninterface LegacyModeRecord<T extends TypedRecordInstance> {\n id: string | null;\n\n serialize(options?: Record<string, unknown>): unknown;\n destroyRecord(options?: Record<string, unknown>): Promise<this>;\n unloadRecord(): void;\n changedAttributes(): ChangedAttributesHash;\n rollbackAttributes(): void;\n _createSnapshot(): Snapshot<T>;\n save(options?: Record<string, unknown>): Promise<this>;\n reload(options?: Record<string, unknown>): Promise<T>;\n belongsTo<K extends _MaybeBelongsToFields<T>>(prop: K): BelongsToReference<T, K>;\n hasMany<K extends MaybeHasManyFields<T>>(prop: K): HasManyReference<T, K>;\n deleteRecord(): void;\n\n adapterError: unknown;\n constructor: { modelName: TypeFromInstance<T> };\n currentState: RecordState;\n dirtyType: 'deleted' | 'created' | 'updated' | '';\n errors: unknown;\n hasDirtyAttributes: boolean;\n isDeleted: boolean;\n isEmpty: boolean;\n isError: boolean;\n isLoaded: boolean;\n isLoading: boolean;\n isDestroying: boolean;\n isDestroyed: boolean;\n isNew: boolean;\n isSaving: boolean;\n isValid: boolean;\n}\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] as const;\n\n/**\n * A Type utility that enables quickly adding type information for the fields\n * defined by `import { withDefaults } from '@ember-data/model/migration-support'`.\n *\n * Example:\n *\n * ```ts\n * import { withDefaults, WithLegacy } from '@ember-data/model/migration-support';\n * import { Type } from '@warp-drive/core-types/symbols';\n * import type { HasMany } from '@ember-data/model';\n *\n * export const UserSchema = withDefaults({\n * type: 'user',\n * fields: [\n * { name: 'firstName', kind: 'attribute' },\n * { name: 'lastName', kind: 'attribute' },\n * { name: 'age', kind: 'attribute' },\n * { name: 'friends',\n * kind: 'hasMany',\n * type: 'user',\n * options: { inverse: 'friends', async: false }\n * },\n * { name: 'bestFriend',\n * kind: 'belongsTo',\n * type: 'user',\n * options: { inverse: null, async: false }\n * },\n * ],\n * });\n *\n * export type User = WithLegacy<{\n * firstName: string;\n * lastName: string;\n * age: number;\n * friends: HasMany<User>;\n * bestFriend: User | null;\n * [Type]: 'user';\n * }>\n * ```\n *\n * @typedoc\n */\nexport type WithLegacy<T extends TypedRecordInstance> = T & LegacyModeRecord<T>;\n\nconst LegacySupport = getOrSetGlobal('LegacySupport', new WeakMap<MinimalLegacyRecord, Record<string, unknown>>());\n\nfunction legacySupport(record: MinimalLegacyRecord, options: ObjectValue | 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}\nlegacySupport[Type] = '@legacy';\n\n/**\n * A function which adds the necessary fields to a schema and marks it as\n * being in LegacyMode. This is used to support the legacy features of\n * @ember-data/model while migrating to WarpDrive.\n *\n * Example:\n *\n * ```ts\n * import { withDefaults, WithLegacy } from '@ember-data/model/migration-support';\n * import { Type } from '@warp-drive/core-types/symbols';\n * import type { HasMany } from '@ember-data/model';\n *\n * export const UserSchema = withDefaults({\n * type: 'user',\n * fields: [\n * { name: 'firstName', kind: 'attribute' },\n * { name: 'lastName', kind: 'attribute' },\n * { name: 'age', kind: 'attribute' },\n * { name: 'friends',\n * kind: 'hasMany',\n * type: 'user',\n * options: { inverse: 'friends', async: false }\n * },\n * { name: 'bestFriend',\n * kind: 'belongsTo',\n * type: 'user',\n * options: { inverse: null, async: false }\n * },\n * ],\n * });\n *\n * export type User = WithLegacy<{\n * firstName: string;\n * lastName: string;\n * age: number;\n * friends: HasMany<User>;\n * bestFriend: User | null;\n * [Type]: 'user';\n * }>\n * ```\n *\n * Using this function require registering the derivations\n * it requires with the schema service.\n *\n * ```ts\n * import { registerDerivations } from '@ember-data/model/migration-support';\n *\n * registerDerivations(schema);\n * ```\n *\n * @method withDefaults\n * @for @ember-data/model/migration-support\n * @static\n * @param {LegacyResourceSchema} schema The schema to add legacy support to.\n * @return {LegacyResourceSchema} The schema with legacy support added.\n * @public\n */\nexport function withDefaults(schema: WithPartial<LegacyResourceSchema, 'legacy' | 'identity'>): LegacyResourceSchema {\n schema.legacy = true;\n schema.identity = { kind: '@id', name: 'id' };\n\n LegacyFields.forEach((field) => {\n schema.fields.push({\n type: '@legacy',\n name: field,\n kind: 'derived',\n });\n });\n schema.fields.push({\n name: 'isReloading',\n kind: '@local',\n type: 'boolean',\n options: { defaultValue: false },\n });\n schema.fields.push({\n name: 'isDestroying',\n kind: '@local',\n type: 'boolean',\n options: { defaultValue: false },\n });\n schema.fields.push({\n name: 'isDestroyed',\n kind: '@local',\n type: 'boolean',\n options: { defaultValue: false },\n });\n return schema as LegacyResourceSchema;\n}\n\n/**\n * A function which registers the necessary derivations to support\n * the LegacyMode features of @ember-data/model while migrating to WarpDrive.\n *\n * This must be called in order to use the fields added by:\n *\n * ```ts\n * import { withDefaults } from '@ember-data/model/migration-support';\n * ```\n *\n * @method registerDerivations\n * @for @ember-data/model/migration-support\n * @static\n * @param {SchemaService} schema The schema service to register the derivations with.\n * @return {void}\n * @public\n */\nexport function registerDerivations(schema: SchemaService) {\n schema.registerDerivation(legacySupport);\n}\n\n/**\n * A class which provides a schema service that delegates between\n * a primary schema service and one that supports legacy model\n * classes as its schema source.\n *\n * When the primary schema service has a schema for the given\n * resource, it will be used. Otherwise, the fallback schema\n * service will be used.\n *\n * This can be used when incrementally migrating from Models to\n * SchemaRecords by enabling unmigrated Models to continue to\n * provide their own schema information to the application.\n *\n * ```ts\n * import { DelegatingSchemaService } from '@ember-data/model/migration-support';\n * import { SchemaService } from '@warp-drive/schema-record';\n *\n * class AppStore extends Store {\n * createSchemaService() {\n * const schema = new SchemaService();\n * return new DelegatingSchemaService(this, schema);\n * }\n * }\n * ```\n *\n * All calls to register resources, derivations, transformations, hash functions\n * etc. will be delegated to the primary schema service.\n *\n * @class DelegatingSchemaService\n * @extends SchemaService\n * @public\n */\nexport interface DelegatingSchemaService {\n attributesDefinitionFor?(resource: StableRecordIdentifier | { type: string }): AttributesSchema;\n relationshipsDefinitionFor?(resource: StableRecordIdentifier | { type: string }): RelationshipsSchema;\n doesTypeExist?(type: string): boolean;\n}\nexport class DelegatingSchemaService implements SchemaService {\n _preferred!: SchemaService;\n _secondary!: SchemaService;\n\n constructor(store: Store, schema: SchemaService) {\n this._preferred = schema;\n this._secondary = buildSchema(store);\n }\n\n resourceTypes(): Readonly<string[]> {\n return Array.from(new Set(this._preferred.resourceTypes().concat(this._secondary.resourceTypes())));\n }\n\n hasResource(resource: StableRecordIdentifier | { type: string }): boolean {\n return this._preferred.hasResource(resource) || this._secondary.hasResource(resource);\n }\n hasTrait(type: string): boolean {\n if (this._preferred.hasResource({ type })) {\n return this._preferred.hasTrait(type);\n }\n return this._secondary.hasTrait(type);\n }\n resourceHasTrait(resource: StableRecordIdentifier | { type: string }, trait: string): boolean {\n if (this._preferred.hasResource(resource)) {\n return this._preferred.resourceHasTrait(resource, trait);\n }\n return this._secondary.resourceHasTrait(resource, trait);\n }\n fields(resource: StableRecordIdentifier | { type: string }): Map<string, FieldSchema> {\n if (this._preferred.hasResource(resource)) {\n return this._preferred.fields(resource);\n }\n return this._secondary.fields(resource);\n }\n transformation(field: GenericField | ObjectField | ArrayField | { type: string }): Transformation {\n return this._preferred.transformation(field);\n }\n hashFn(field: HashField | { type: string }): HashFn {\n return this._preferred.hashFn(field);\n }\n derivation(field: DerivedField | { type: string }): Derivation {\n return this._preferred.derivation(field);\n }\n resource(resource: StableRecordIdentifier | { type: string }): ResourceSchema | ObjectSchema {\n if (this._preferred.hasResource(resource)) {\n return this._preferred.resource(resource);\n }\n return this._secondary.resource(resource);\n }\n registerResources(schemas: Array<ResourceSchema | ObjectSchema>): void {\n this._preferred.registerResources(schemas);\n }\n registerResource(schema: ResourceSchema | ObjectSchema): void {\n this._preferred.registerResource(schema);\n }\n registerTransformation(transform: Transformation): void {\n this._preferred.registerTransformation(transform);\n }\n registerDerivation<R, T, FM extends ObjectValue | null>(derivation: Derivation<R, T, FM>): void {\n this._preferred.registerDerivation(derivation);\n }\n registerHashFn(hashFn: HashFn): void {\n this._preferred.registerHashFn(hashFn);\n }\n}\n\nif (ENABLE_LEGACY_SCHEMA_SERVICE) {\n DelegatingSchemaService.prototype.attributesDefinitionFor = function (\n resource: StableRecordIdentifier | { type: string }\n ) {\n if (this._preferred.hasResource(resource)) {\n return this._preferred.attributesDefinitionFor!(resource);\n }\n\n return this._secondary.attributesDefinitionFor!(resource);\n };\n DelegatingSchemaService.prototype.relationshipsDefinitionFor = function (\n resource: StableRecordIdentifier | { type: string }\n ) {\n if (this._preferred.hasResource(resource)) {\n return this._preferred.relationshipsDefinitionFor!(resource);\n }\n\n return this._secondary.relationshipsDefinitionFor!(resource);\n };\n DelegatingSchemaService.prototype.doesTypeExist = function (type: string) {\n return this._preferred.doesTypeExist?.(type) || this._secondary.doesTypeExist?.(type) || false;\n };\n}\n"],"names":["LegacyFields","LegacySupport","getOrSetGlobal","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","macroCondition","getGlobalConfig","WarpDrive","env","DEBUG","test","Error","Type","withDefaults","schema","legacy","identity","kind","forEach","field","fields","push","defaultValue","registerDerivations","registerDerivation","DelegatingSchemaService","_preferred","_secondary","constructor","store","buildSchema","resourceTypes","Array","from","Set","concat","hasResource","resource","hasTrait","resourceHasTrait","trait","transformation","hashFn","derivation","registerResources","schemas","registerResource","registerTransformation","transform","registerHashFn","deprecations","ENABLE_LEGACY_SCHEMA_SERVICE","prototype","attributesDefinitionFor","relationshipsDefinitionFor","doesTypeExist"],"mappings":";;;;;;;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AA0FA;AACA,MAAMA,YAAY,GAAG,CACnB,iBAAiB,EACjB,cAAc,EACd,WAAW,EACX,mBAAmB,EACnB,aAAa,EACb,cAAc,EACd,cAAc,EACd,eAAe,EACf,WAAW,EACX,QAAQ,EACR,oBAAoB,EACpB,SAAS,EACT,WAAW,EACX,SAAS,EACT,SAAS,EACT,UAAU,EACV,WAAW,EACX,OAA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AAI,CAACX,UAAU,CAACU,WAAW,CAACC,QAAQ,CAAC,EAAE;AACzC,MAAA,OAAO,IAAI,CAACX,UAAU,CAAC2B,uBAAuB,CAAEhB,QAAQ,CAAC;AAC3D;AAEA,IAAA,OAAO,IAAI,CAACV,UAAU,CAAC0B,uBAAuB,CAAEhB,QAAQ,CAAC;GAC1D;AACDZ,EAAAA,uBAAuB,CAAC2B,SAAS,CAACE,0BAA0B,GAAG,UAC7DjB,QAAmD,EACnD;IACA,IAAI,IAAI,CAACX,UAAU,CAACU,WAAW,CAACC,QAAQ,CAAC,EAAE;AACzC,MAAA,OAAO,IAAI,CAACX,UAAU,CAAC4B,0BAA0B,CAAEjB,QAAQ,CAAC;AAC9D;AAEA,IAAA,OAAO,IAAI,CAACV,UAAU,CAAC2B,0BAA0B,CAAEjB,QAAQ,CAAC;GAC7D;AACDZ,EAAAA,uBAAuB,CAAC2B,SAAS,CAACG,aAAa,GAAG,UAAU5E,IAAY,EAAE;AACxE,IAAA,OAAO,IAAI,CAAC+C,UAAU,CAAC6B,aAAa,GAAG5E,IAAI,CAAC,IAAI,IAAI,CAACgD,UAAU,CAAC4B,aAAa,GAAG5E,IAAI,CAAC,IAAI,KAAK;GAC/F;AACH;;;;"}
|
|
@@ -271,28 +271,32 @@ class PromiseManyArray {
|
|
|
271
271
|
/**
|
|
272
272
|
* Whether the loading promise is still pending
|
|
273
273
|
*
|
|
274
|
-
* @property
|
|
274
|
+
* @property isPending
|
|
275
|
+
* @type {Boolean}
|
|
275
276
|
* @public
|
|
276
277
|
*/
|
|
277
278
|
|
|
278
279
|
/**
|
|
279
280
|
* Whether the loading promise rejected
|
|
280
281
|
*
|
|
281
|
-
* @property
|
|
282
|
+
* @property isRejected
|
|
283
|
+
* @type {Boolean}
|
|
282
284
|
* @public
|
|
283
285
|
*/
|
|
284
286
|
|
|
285
287
|
/**
|
|
286
288
|
* Whether the loading promise succeeded
|
|
287
289
|
*
|
|
288
|
-
* @property
|
|
290
|
+
* @property isFulfilled
|
|
291
|
+
* @type {Boolean}
|
|
289
292
|
* @public
|
|
290
293
|
*/
|
|
291
294
|
|
|
292
295
|
/**
|
|
293
296
|
* Whether the loading promise completed (resolved or rejected)
|
|
294
297
|
*
|
|
295
|
-
* @property
|
|
298
|
+
* @property isSettled
|
|
299
|
+
* @type {Boolean}
|
|
296
300
|
* @public
|
|
297
301
|
*/
|
|
298
302
|
|
|
@@ -477,14 +481,16 @@ class HasManyReference {
|
|
|
477
481
|
/**
|
|
478
482
|
* The field name on the parent record for this has-many relationship.
|
|
479
483
|
*
|
|
480
|
-
* @property
|
|
484
|
+
* @property key
|
|
485
|
+
* @type {String}
|
|
481
486
|
* @public
|
|
482
487
|
*/
|
|
483
488
|
|
|
484
489
|
/**
|
|
485
490
|
* The type of resource this relationship will contain.
|
|
486
491
|
*
|
|
487
|
-
* @property
|
|
492
|
+
* @property type
|
|
493
|
+
* @type {String}
|
|
488
494
|
* @public
|
|
489
495
|
*/
|
|
490
496
|
|
|
@@ -524,7 +530,8 @@ class HasManyReference {
|
|
|
524
530
|
/**
|
|
525
531
|
* An array of identifiers for the records that this reference refers to.
|
|
526
532
|
*
|
|
527
|
-
* @property
|
|
533
|
+
* @property identifiers
|
|
534
|
+
* @type {StableRecordIdentifier[]}
|
|
528
535
|
* @public
|
|
529
536
|
*/
|
|
530
537
|
get identifiers() {
|
|
@@ -1088,14 +1095,16 @@ class BelongsToReference {
|
|
|
1088
1095
|
/**
|
|
1089
1096
|
* The field name on the parent record for this has-many relationship.
|
|
1090
1097
|
*
|
|
1091
|
-
* @property
|
|
1098
|
+
* @property key
|
|
1099
|
+
* @type {String}
|
|
1092
1100
|
* @public
|
|
1093
1101
|
*/
|
|
1094
1102
|
|
|
1095
1103
|
/**
|
|
1096
1104
|
* The type of resource this relationship will contain.
|
|
1097
1105
|
*
|
|
1098
|
-
* @property
|
|
1106
|
+
* @property type
|
|
1107
|
+
* @type {String}
|
|
1099
1108
|
* @public
|
|
1100
1109
|
*/
|
|
1101
1110
|
|
|
@@ -1132,7 +1141,8 @@ class BelongsToReference {
|
|
|
1132
1141
|
* The identifier of the record that this reference refers to.
|
|
1133
1142
|
* `null` if no related record is known.
|
|
1134
1143
|
*
|
|
1135
|
-
* @property
|
|
1144
|
+
* @property identifier
|
|
1145
|
+
* @type {StableRecordIdentifier | null}
|
|
1136
1146
|
* @public
|
|
1137
1147
|
*/
|
|
1138
1148
|
get identifier() {
|
|
@@ -2519,7 +2529,7 @@ class Errors extends ArrayProxyWithCustomOverrides {
|
|
|
2519
2529
|
```
|
|
2520
2530
|
@method add
|
|
2521
2531
|
@public
|
|
2522
|
-
@param {
|
|
2532
|
+
@param {String} attribute - the property name of an attribute or relationship
|
|
2523
2533
|
@param {string[]|string} messages - an error message or array of error messages for the attribute
|
|
2524
2534
|
*/
|
|
2525
2535
|
add(attribute, messages) {
|
|
@@ -2573,7 +2583,7 @@ class Errors extends ArrayProxyWithCustomOverrides {
|
|
|
2573
2583
|
```
|
|
2574
2584
|
@method remove
|
|
2575
2585
|
@public
|
|
2576
|
-
@param {
|
|
2586
|
+
@param {String} member - the property name of an attribute or relationship
|
|
2577
2587
|
*/
|
|
2578
2588
|
remove(attribute) {
|
|
2579
2589
|
if (this.isEmpty) {
|