@warp-drive/legacy 5.10.0-alpha.18 → 5.10.0-alpha.19

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.
@@ -1,3 +1,8 @@
1
+ /**
2
+ * @module
3
+ * @summary Legacy `JSONAPIAdapter`, which turns store requests into HTTP requests following JSON:API URL, verb and
4
+ * header conventions.
5
+ */
1
6
  import { _ as AdapterPayload, m as Snapshot, p as SnapshotRecordArray } from "../compat-BZlQ-5eI.js";
2
7
  import { i as RESTAdapter, n as JQueryRequestInit, r as QueryState, t as FetchRequestInit } from "../rest-ddU-K5eS.js";
3
8
  import { Store } from "@warp-drive/core";
@@ -1 +1 @@
1
- {"version":3,"file":"json-api.d.ts","names":[],"sources":["../../src/adapter/json-api.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAmKM,uBAAuB;;;;;EAK3B;;;;;;;;EASA,YACE,aACA,MAAM,YACN,UAAS,qBAAqB,cAC7B,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MAgEnB;MAQA,qBAAqB;EAIzB,SAAS,OAAO,OAAO,MAAM,aAAa,eAAe,WAAW,aAAa,QAAQ;;;;;;;;EAYzF,YAAY;EAKZ,aAAa,OAAO,OAAO,QAAQ,aAAa,UAAU,WAAW,QAAQ;;;;;;;;;;EAoB7E,WAAW,UAAU,WAAW,sBAAsB"}
1
+ {"version":3,"file":"json-api.d.ts","names":[],"sources":["../../src/adapter/json-api.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAmKM,uBAAuB;;;;;EAK3B;;;;;;;;EASA,YACE,aACA,MAAM,YACN,UAAS,qBAAqB,cAC7B,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MAgEnB;MAQA,qBAAqB;EAIzB,SAAS,OAAO,OAAO,MAAM,aAAa,eAAe,WAAW,aAAa,QAAQ;;;;;;;;EAYzF,YAAY;EAKZ,aAAa,OAAO,OAAO,QAAQ,aAAa,UAAU,WAAW,QAAQ;;;;;;;;;;EAoB7E,WAAW,UAAU,WAAW,sBAAsB"}
package/dist/adapter.d.ts CHANGED
@@ -1,2 +1,220 @@
1
+ /**
2
+ * ## Overview
3
+ *
4
+ * :::danger
5
+ * ⚠️ **This is LEGACY documentation** for a feature that is no longer encouraged to be used.
6
+ * If starting a new app or thinking of implementing a new adapter, consider writing a
7
+ * {@link Handler} instead to be used with the {@link RequestManager}
8
+ * ::::
9
+ *
10
+ * In order to properly fetch and update data, @warp-drive/legacy
11
+ * needs to understand how to connect to your API.
12
+ *
13
+ * `Adapters` accept various kinds of requests from the store
14
+ * and manage fulfillment of the request from your API.
15
+ *
16
+ * ### Why It's Legacy
17
+ *
18
+ * The Adapter pattern was designed for class-based architectures in which each resource type
19
+ * could have its own data-fetching logic:
20
+ *
21
+ * - `store.adapterFor` resolves an adapter by resource type at runtime, looking up
22
+ * `adapter:<type>` and then `adapter:application` through Ember's owner.
23
+ * - Each request is fulfilled by a single adapter, so sharing behavior across resource types
24
+ * means extending a common base class rather than composing request logic.
25
+ * - The provided adapter classes extend `EmberObject`, which, together with the owner lookup,
26
+ * ties the pattern to Ember.
27
+ * - Adapter methods resolve with an untyped `AdapterPayload`, so nothing ties the response's
28
+ * type to the request that produced it.
29
+ *
30
+ * ### Modern Alternative
31
+ *
32
+ * Use [Handlers](/api/@warp-drive/core/request/types/Handler) with the {@link RequestManager}.
33
+ * Each request passes through a chain of handlers, any of which can fulfill it, modify it or
34
+ * pass it along. Handlers support:
35
+ *
36
+ * - request builders, which return a request typed with its expected response, so
37
+ * `store.request` resolves with that type
38
+ * - composition: `RequestManager.use` takes a list of handlers, such as the built-in `Fetch`
39
+ * handler, and wrappers such as `Gate` from `@warp-drive/utilities/handlers` run another
40
+ * handler only for the requests it accepts
41
+ * - explicit imports rather than lookup by name at runtime
42
+ * - any framework ***Warp*Drive** supports, since `@warp-drive/core` has no runtime
43
+ * dependency on Ember (see [Installation](/guides/installation/))
44
+ *
45
+ * For an alternative modern pattern to Adapters, see the
46
+ * [Request Handlers Guide](/guides/the-manual/requests/handlers).
47
+ *
48
+ * ### Request Flow
49
+ *
50
+ * When the store decides it needs to issue a request it uses the following flow to manage the request and process the data.
51
+ *
52
+ * - find the appropriate adapter
53
+ * - issue the request to the adapter
54
+ * - await the adapter's response
55
+ * - if an error occurs reject with the error
56
+ * - if no error
57
+ * - if there is response data
58
+ * - pass the response data to the appropriate serializer
59
+ * - update the cache using the JSON:API formatted data from the serializer's response
60
+ * - return the primary record(s) associated with the request
61
+ *
62
+ * ### Request Errors
63
+ *
64
+ * When a request errors and your adapter does not have the ability to recover from the error,
65
+ * you may either reject the promise returned by your adapter method with the error or simply
66
+ * throw the error.
67
+ *
68
+ * If the request was for a `createRecord` `updateRecord` or `deleteRecord` special rules
69
+ * apply to how this error will affect the state of the store and additional properties on
70
+ * the `Error` class may be used. See the documentation for these methods in
71
+ * {@link MinimumAdapterInterface} for more information.
72
+ *
73
+ * ### Implementing an Adapter
74
+ *
75
+ * There are seven required adapter methods, one for each of
76
+ * the primary request types that @warp-drive/legacy issues.
77
+ *
78
+ * They are:
79
+ *
80
+ * - findRecord
81
+ * - findAll
82
+ * - queryRecord
83
+ * - query
84
+ * - createRecord
85
+ * - updateRecord
86
+ * - deleteRecord
87
+ *
88
+ * Each of these request types has a matching store method that triggers it
89
+ * and matching `requestType` that is passed to the serializer's
90
+ * `normalizeResponse` method.
91
+ *
92
+ * If your app only reads data but never writes data, it is not necessary
93
+ * to implement the methods for create, update, and delete. This extends to
94
+ * all of the store's find methods with the exception of `findRecord` (`findAll`,
95
+ * `query`, `queryRecord`): if you do not use the store method in your app then
96
+ * your Adapter does not need the method.
97
+ *
98
+ * ```ts
99
+ * async function fetchData(url, options = {}) {
100
+ * let response = await fetch(url, options);
101
+ * return response.toJSON();
102
+ * }
103
+ *
104
+ * export default class ApplicationAdapter {
105
+ * findRecord(_, { modelName }, id) {
106
+ * return fetchData(`./${modelName}s/${id}`);
107
+ * }
108
+ *
109
+ * static create() {
110
+ * return new this();
111
+ * }
112
+ * }
113
+ * ```
114
+ *
115
+ * ### Adapter Resolution
116
+ *
117
+ * `store.adapterFor(name)` will lookup adapters defined in `app/adapters/` and
118
+ * return an instance.
119
+ *
120
+ * `adapterFor` first attempts to find an adapter with an exact match on `name`,
121
+ then falls back to checking for the presence of an adapter named `application`.
122
+
123
+ If no adapter is found, an error will be thrown.
124
+
125
+ ```ts
126
+ store.adapterFor('author');
127
+
128
+ // lookup paths (in order) =>
129
+ // app/adapters/author.js
130
+ // app/adapters/application.js
131
+ ```
132
+
133
+ Most requests in @warp-drive/legacy are made with respect to a particular `type` (or `modelName`)
134
+ (e.g., "get me the full collection of **books**" or "get me the **employee** whose id is 37"). We
135
+ refer to this as the **primary** resource `type`.
136
+
137
+ `adapterFor` is used by the store to find an adapter with a name matching that of the primary
138
+ resource `type` for the request, which then falls back to the `application` adapter.
139
+
140
+ It is recommended that applications define only a single `application` adapter and serializer
141
+ where possible, only implementing an adapter specific to the `type` when absolutely necessary.
142
+
143
+ If you need to support multiple API versions for the same type, the per-type strategy for
144
+ defining adapters might not be adequate.
145
+
146
+ If you have multiple APIs or multiple API versions and the single application adapter and per-type
147
+ strategy does not suite your needs, one strategy is to write an `application` adapter and serializer
148
+ that make use of `options` to specify the desired format when making a request, then forwards to the
149
+ request to the desired adapter or serializer as needed.
150
+
151
+ ```js [app/adapters/application.js]
152
+ export default class Adapter extends EmberObject {
153
+ findRecord(store, schema, id, snapshot) {
154
+ let { apiVersion } = snapshot.adapterOptions;
155
+ return this.adapterFor(`-api-${apiVersion}`).findRecord(store, schema, id, snapshot);
156
+ }
157
+ }
158
+ ```
159
+
160
+ ### Overriding `Store.adapterFor`
161
+
162
+ ```js
163
+ import Store from '@ember-data/store';
164
+ import Adapter from '@ember-data/adapter/json-api';
165
+
166
+ class extends Store {
167
+ #adapter = new Adapter();
168
+
169
+ adapterFor() {
170
+ return this.#adapter;
171
+ }
172
+ }
173
+ ```
174
+
175
+
176
+ Note: If you are using Ember and would like to make use of `service` injections in your adapter, you will want to additionally `setOwner` for the Adapter.
177
+
178
+ ```js
179
+ import Store from '@ember-data/store';
180
+ import Adapter from '@ember-data/adapter/json-api';
181
+ import { getOwner, setOwner } from '@ember/owner';
182
+
183
+ class extends Store {
184
+ #adapter = null;
185
+
186
+ adapterFor() {
187
+ let adapter = this.#adapter;
188
+ if (!adapter) {
189
+ const owner = getOwner(this);
190
+ adapter = new Adapter();
191
+ setOwner(adapter, owner);
192
+ this.#adapter = adapter;
193
+ }
194
+
195
+ return adapter;
196
+ }
197
+ }
198
+ ```
199
+
200
+ By default when using with Ember you only need to implement this hook if you want your adapter usage to be statically analyzeable. *Ember***Data** will attempt to resolve adapters using Ember's resolver. To provide a single Adapter for your application like the above you would provide it as the default export of the file `app/adapters/application.{js/ts}`
201
+
202
+ ### Using an Adapter
203
+
204
+ Any adapter in `app/adapters/` can be looked up by `name` using `store.adapterFor(name)`.
205
+
206
+ ### Default Adapters
207
+
208
+ Applications whose API's structure endpoint URLs *very close to* or *exactly* the **REST**
209
+ or **JSON:API** convention, the `@ember-data/adapter` package contains implementations
210
+ these applications can extend.
211
+
212
+ Many applications will find writing their own adapter to be allow greater flexibility,
213
+ customization, and maintenance than attempting to override methods in these adapters.
214
+
215
+ @summary Legacy adapter layer through which the store fetches and saves data from an API, superseded by
216
+ `RequestManager` handlers.
217
+ @module
218
+ */
1
219
  import { n as BuildURLMixin, t as Adapter } from "./adapter-D3A8ixjz.js";
2
220
  export { Adapter, BuildURLMixin };
@@ -1,3 +1,15 @@
1
+ /**
2
+ Builders for migrating from `store` methods to `store.request`.
3
+
4
+ These builders enable you to migrate your codebase to using the correct syntax for `store.request` while temporarily preserving legacy behaviors.
5
+ This is useful for quickly upgrading an entire app to a unified syntax while a longer incremental migration is made to shift off of adapters and serializers.
6
+ To that end, these builders are deprecated and will be removed in a future version of Ember Data.
7
+
8
+ @summary Deprecated request builders that move `findRecord`, `query`, and `saveRecord` calls to `store.request`
9
+ while still using adapters and serializers.
10
+ @module
11
+ @deprecated
12
+ */
1
13
  import { StoreRequestInput } from "@warp-drive/core";
2
14
  import { RequestSignature } from "@warp-drive/core/types/symbols";
3
15
  import { FindAllOptions, FindRecordOptions, LegacyResourceQuery, QueryOptions, ResourceKey } from "@warp-drive/core/types";
@@ -1 +1 @@
1
- {"version":3,"file":"builders.d.ts","names":[],"sources":["../../src/compat/builders/find-all.ts","../../src/compat/builders/find-record.ts","../../src/compat/builders/query.ts","../../src/compat/builders/save-record.ts"],"mappings":";;;;;;KASK,oBAAoB,2BAA2B,kBAAkB;EACpE;EACA;IACE,MAAM;IACN,SAAS;;GAEV,oBAAoB;;KAGlB,wBAAwB;;;;;;;;;;;;;;;;;;iBAmBb,eAAe,UAAU,qBACvC,MAAM,iBAAiB,IACvB,UAAU,wBACT,oBAAoB,iBAAiB,IAAI;iBAC5B,eAAe,cAAc,UAAU,wBAAwB;;;KC9B1E,uBAAuB,2BAA2B,gBAAgB;EACrE;EACA;IACE,QAAQ,yBAAyB;IACjC,SAAS;;GAEV,oBAAoB;;KAGlB,2BAA2B,KAAK;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAsCrB,kBAAkB,UAAU,qBAC1C,MAAM,iBAAiB,IACvB,YACA,UAAU,2BACT,uBAAuB,iBAAiB,IAAI;iBAC/B,kBAAkB,cAAc,YAAY,UAAU,2BAA2B;iBACjF,kBAAkB,UAAU,qBAC1C,UAAU,yBAAyB,iBAAiB,KACpD,UAAU,2BACT,uBAAuB,iBAAiB,IAAI;iBAC/B,kBACd,UAAU,0BACV,UAAU,2BACT;;;KC9DE,kBAAkB,2BAA2B,kBAAkB;EAClE;EACA;IACE,MAAM;IACN,OAAO;IACP,SAAS;;GAEV,oBAAoB;;KAGlB,sBAAsB;;;;;;;;;;;;;;;;;;;iBAoBX,aAAa,UAAU,qBACrC,MAAM,iBAAiB,IACvB,OAAO,qBACP,UAAU,sBACT,kBAAkB,iBAAiB,IAAI;iBAC1B,aACd,cACA,OAAO,qBACP,UAAU,sBACT;KAwBE,wBAAwB,2BAA2B,gBAAgB;EACtE;EACA;IACE,MAAM;IACN,OAAO;IACP,SAAS;;GAEV,oBAAoB;;;;;;;;;;;;;;;;;;;;iBAqBP,mBAAmB,UAAU,qBAC3C,MAAM,iBAAiB,IACvB,OAAO,qBACP,UAAU,sBACT,wBAAwB,iBAAiB,IAAI;iBAChC,mBACd,cACA,OAAO,qBACP,UAAU,sBACT;;;KCpGE,uBAAuB,2BAA2B,gBAAgB;EACrE;EACA;IACE,QAAQ,YAAY;IACpB,SAAS;;EAEX,UAAU,YAAY;GACrB,oBAAoB;;KAGlB,2BAA2B;;;;;;;;;;;;;;;;;;iBA4BhB,kBAAkB,UAAU,qBAC1C,QAAQ,GACR,UAAS,0BACR,uBAAuB,iBAAiB,IAAI"}
1
+ {"version":3,"file":"builders.d.ts","names":[],"sources":["../../src/compat/builders/find-all.ts","../../src/compat/builders/find-record.ts","../../src/compat/builders/query.ts","../../src/compat/builders/save-record.ts"],"mappings":";;;;;;;;;;;;;;;;;;KASK,oBAAoB,2BAA2B,kBAAkB;EACpE;EACA;IACE,MAAM;IACN,SAAS;;GAEV,oBAAoB;;KAGlB,wBAAwB;;;;;;;;;;;;;;;;;;iBAmBb,eAAe,UAAU,qBACvC,MAAM,iBAAiB,IACvB,UAAU,wBACT,oBAAoB,iBAAiB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2 +1,7 @@
1
+ /**
2
+ * @module
3
+ * @summary Legacy schema extensions that give reactive objects and arrays the classic `EmberObject` and Ember array
4
+ * APIs, such as `get`, `set` and `mapBy`, plus matching types.
5
+ */
1
6
  import { a as WithArrayLike, i as EmberObjectExtension, n as EmberArrayLikeExtension, o as WithEmberObject, r as EmberObjectArrayExtension, t as ArrayType } from "../extensions-fwdnX9n4.js";
2
7
  export { ArrayType, EmberArrayLikeExtension, EmberObjectArrayExtension, EmberObjectExtension, WithArrayLike, WithEmberObject };
package/dist/index.d.ts CHANGED
@@ -1,3 +1,9 @@
1
+ /**
2
+ * @summary Legacy `Model`, adapter, and serializer support for WarpDrive, including `useLegacyStore` to configure a
3
+ * store that uses them.
4
+ * @module
5
+ * @mergeModuleWith <project>
6
+ */
1
7
  import { Store, StoreSetupOptions } from "@warp-drive/core";
2
8
  import { CacheCapabilitiesManager } from "@warp-drive/core/types";
3
9
  import { Cache } from "@warp-drive/core/types/cache";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","names":[],"sources":["../src/index.ts"],"mappings":";;;;;UA6CU,yBAAyB,UAAU,eAAe,KAAK,kBAAkB;;;;;;;;;;;EAWjF,UAAU,MAAM,iBAAiB;;;;;;EAOjC;;;;;;;;;;iBAWe,6BAA6B,UAAU,eAAe,yBAAyB;;;;;;;;;EAS9F;;;;;;;;;EASA;;;;;;;;;;;iBAYe,uCAAuC,UAAU,eAAe,yBAAyB;;;;;;;EAOxG;;;;;;;;;EASA;;;;;;;;;;;iBAYe,iDAAiD,UAAU,eAAe,yBAAyB;;;;;;;EAOlH;;;;;;;;;EASA;;;;;;;;;;;;;YAgBU,wBAAwB,UAAU,QAAQ,SAClD,6BAA6B,KAC7B,uCAAuC,KACvC,iDAAiD;qBAEhC,gBACnB;;;;EAIE,OAAO;WAED;EAER,YAAY,cAAc,2BAA2B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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AAe,QAAQ;EAIvB,sCAAsC;IAAO;IAA0B;;EAIvE,2CAA2C,WAAW;EAItD,4CACE,UAAUA;IAAgB;aAClB;EAIV,0CACE,OAAO,iBACP,qCACQ;EAIV,yCAAyC,OAAO,yBAAyB;;;;;;;;;;;;EAezE,cAAc,cAAc;;;;;;;;;;;;EAiB5B,MAAM,cAAc;;;;;iBAUL,uCAAuC;EACtD,YAAYD;EACZ,YAAYA"}
@@ -340,8 +340,9 @@ function registerDerivations(schema) {
340
340
  },
341
341
  notify(store, record, cacheKey, field) {
342
342
  const support = lookupLegacySupport(record);
343
- const manyArray = support && support._manyArrayCache[field.name];
344
- const hasPromise = support && support._relationshipPromisesCache[field.name];
343
+ const key = field.sourceKey ?? field.name;
344
+ const manyArray = support && support._manyArrayCache[key];
345
+ const hasPromise = support && support._relationshipPromisesCache[key];
345
346
  if (manyArray && hasPromise) return false;
346
347
  if (manyArray) {
347
348
  notifyInternalSignal(manyArray[Context].signal);
@@ -1 +1 @@
1
- {"version":3,"file":"migration-support.js","names":["deprecate","recordIdentifierFor","Context","notifyInternalSignal","assertPrivateStore","getOrSetGlobal","Type","Errors","lookupLegacySupport","_destroyRecord","_reload","_save","belongsTo","changedAttributes","createSnapshot","deleteRecord","destroyRecord","hasMany","reload","rollbackAttributes","save","serialize","unloadRecord","RecordState","buildSchema","getGlobalConfig","macroCondition","LegacyFields","LegacySupport","WeakMap","legacySupport","record","options","prop","state","get","set","suppressDeprecation","Boolean","currentState","adapterError","_constructor","isModel","name","type","modelName","recordState","dirtyType","errors","create","__record","isDirty","isDeleted","isEmpty","isError","isLoaded","isLoading","isNew","isSaving","isValid","WarpDrive","env","DEBUG","test","Error","withDefaults","schema","legacy","identity","kind","forEach","field","fields","push","defaultValue","objectExtensions","withRestoredDeprecatedModelRequestBehaviors","registerDerivations","registerDerivation","_registerMode","store","cacheKey","getBelongsTo","value","_join","setDirtyBelongsTo","getHasMany","support","manyArray","getManyArray","splice","length","notify","_manyArrayCache","hasPromise","_relationshipPromisesCache","signal","CAUTION_MEGA_DANGER_ZONE_registerExtension","features","isReloading","id","until","for","url","since","enabled","available","_isReloading","v","DelegatingSchemaService","_preferred","_secondary","constructor","isDelegated","resource","hasResource","resourceTypes","Array","from","Set","concat","hasTrait","resourceHasTrait","trait","cacheFields","transformation","hashFn","derivation","registerResources","schemas","registerResource","registerTransformation","transform","registerHashFn","CAUTION_MEGA_DANGER_ZONE_hasExtension","ext","extension","CAUTION_MEGA_DANGER_ZONE_resourceExtensions","CAUTION_MEGA_DANGER_ZONE_objectExtensions","resolvedType","CAUTION_MEGA_DANGER_ZONE_arrayExtensions","mode","kinds","_kind","assertPrivate","service","deprecations","ENABLE_LEGACY_SCHEMA_SERVICE","prototype","attributesDefinitionFor","relationshipsDefinitionFor","doesTypeExist"],"sources":["../../src/model/migration-support.ts"],"sourcesContent":["/**\n * This module provides support for migrating away from @warp-drive/legacy/model\n * to ReactiveResource from @warp-drive/core/reactive.\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 * @warp-drive/legacy/model and @warp-drive/core/reactive 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 ReactiveResource *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 * @summary Legacy helpers for migrating from `Model` to `ReactiveResource`: LegacyMode schema defaults, derivations,\n * types, and a schema service that serves both at once.\n * @module\n */\nimport { deprecate } from '@ember/debug';\n\nimport type { Store } from '@warp-drive/core';\nimport { recordIdentifierFor } from '@warp-drive/core';\nimport { ENABLE_LEGACY_SCHEMA_SERVICE } from '@warp-drive/core/build-config/deprecations';\nimport { assert } from '@warp-drive/core/build-config/macros';\nimport type { CAUTION_MEGA_DANGER_ZONE_Extension, ProcessedExtension } from '@warp-drive/core/reactive';\nimport type { ExtensibleField } from '@warp-drive/core/reactive/-private';\nimport { Context } from '@warp-drive/core/reactive/-private';\nimport { notifyInternalSignal } from '@warp-drive/core/signals/-leaked';\nimport type { PrivateReactiveResourceArray } from '@warp-drive/core/store/-private';\nimport { assertPrivateStore } from '@warp-drive/core/store/-private';\nimport type { SchemaService } from '@warp-drive/core/types';\nimport { getOrSetGlobal } from '@warp-drive/core/types/-private';\nimport type { ChangedAttributesHash } from '@warp-drive/core/types/cache';\nimport type { ResourceKey } from '@warp-drive/core/types/identifier';\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 CacheableFieldSchema,\n DerivedField,\n FieldSchema,\n GenericField,\n HashField,\n IdentityField,\n LegacyBelongsToField,\n LegacyHasManyField,\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 type { Snapshot } from '../compat/-private.ts';\nimport { Errors, lookupLegacySupport } from './-private.ts';\nimport type { MinimalLegacyRecord } from './-private/model-methods.ts';\nimport {\n _destroyRecord,\n _reload,\n _save,\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.ts';\nimport RecordState from './-private/record-state.ts';\nimport type BelongsToReference from './-private/references/belongs-to.ts';\nimport type HasManyReference from './-private/references/has-many.ts';\nimport { buildSchema } from './-private/schema-provider.ts';\nimport type { _MaybeBelongsToFields, MaybeHasManyFields } from './-private/type-utils.ts';\n\n/**\n * Adds the `Model`-style `belongsTo`/`hasMany` reference methods to a\n * {@link TypedRecordInstance}, for use when migrating a resource from\n * `Model` to a schema-based record while preserving these APIs.\n *\n * @summary Legacy type that adds the `Model`-style `belongsTo` and `hasMany` reference methods to a typed record\n * migrating from `Model` to a schema-based record.\n */\nexport type WithLegacyDerivations<T extends TypedRecordInstance> = T &\n MinimalLegacyRecord & {\n /**\n * see {@link belongsTo}\n */\n belongsTo: typeof belongsTo;\n /**\n * see {@link hasMany}\n */\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 '@warp-drive/legacy/model/migration-support'`.\n *\n * Example:\n *\n * ```ts\n * import { withDefaults, WithLegacy } from '@warp-drive/legacy/model/migration-support';\n * import { Type } from '@warp-drive/core/types/symbols';\n * import type { HasMany } from '@@warp-drive/legacy/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 * @summary Legacy type that adds the `Model`-style state flags and methods (`save`, `isNew`, `errors`, etc.) that\n * `withDefaults` provides to a LegacyMode record type.\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 const suppressDeprecation = Boolean(options && options.suppressDeprecation);\n\n switch (prop) {\n case '_createSnapshot':\n // FIXME should be deprecated too?\n return createSnapshot;\n case 'adapterError':\n // FIXME should be deprecated too?\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 suppressDeprecation ? _destroyRecord : destroyRecord;\n case 'dirtyType':\n return record.currentState.dirtyType;\n case 'errors':\n // FIXME should be deprecated too?\n // @ts-expect-error\n // oxlint-disable-next-line typescript/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 suppressDeprecation ? _reload : reload;\n case 'rollbackAttributes':\n return rollbackAttributes;\n case 'save':\n return suppressDeprecation ? _save : save;\n case 'serialize':\n // FIXME should be deprecated too? (is somewhat deprecated via store.serializeRecord)\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 * @warp-drive/legacy/model while migrating to WarpDrive.\n *\n * Example:\n *\n * ```ts\n * import { withDefaults, WithLegacy } from '@warp-drive/legacy/model/migration-support';\n * import { Type } from '@warp-drive/core/types/symbols';\n * import type { HasMany } from '@warp-drive/legacy/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 '@warp-drive/legacy/model/migration-support';\n *\n * registerDerivations(schema);\n * ```\n *\n * @summary Legacy helper that marks a resource schema as LegacyMode and adds the fields that give its records\n * `Model`-like state and methods.\n * @param schema The schema to add legacy support to.\n * @return 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 schema.objectExtensions = schema.objectExtensions || [];\n schema.objectExtensions.push('deprecated-model-behaviors');\n return schema as LegacyResourceSchema;\n}\n\n/**\n * Adds the necessasary fields to the schema for supporting\n * the deprecated request methods on LegacyMode schemas.\n *\n * Use this instead of `withDefaults` to add the fields\n * and behaviors necessary to support Model-Like capabilities.\n *\n * ```ts\n * import { withRestoredDeprecatedModelRequestBehaviors } from '@warp-drive/legacy/model/migration-support';\n *\n * export const UserSchema = withRestoredDeprecatedModelRequestBehaviors({\n * type: 'user',\n * fields: [\n * { name: 'firstName', kind: 'attribute' },\n * { name: 'lastName', kind: 'attribute' },\n * ]\n * });\n * ```\n *\n * @summary Legacy alternative to `withDefaults` that makes a LegacyMode schema whose `save`, `reload`, and\n * `destroyRecord` run without deprecation warnings.\n */\nexport function withRestoredDeprecatedModelRequestBehaviors(\n schema: WithPartial<LegacyResourceSchema, 'legacy' | 'identity'>\n): 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 options: { suppressDeprecation: true },\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 @warp-drive/legacy/model while migrating to WarpDrive.\n *\n * This must be called in order to use the fields added by {@link withDefaults} or\n * {@link withRestoredDeprecatedModelRequestBehaviors}.\n *\n * @summary Legacy setup that registers the derivation, relationship behaviors, and extension a schema service needs to\n * support LegacyMode records.\n * @param schema The schema service to register the derivations with.\n * @public\n */\nexport function registerDerivations(schema: SchemaService): void {\n schema.registerDerivation(legacySupport);\n // @ts-expect-error\n // oxlint-disable-next-line typescript/no-unsafe-call\n schema._registerMode('@legacy', {\n belongsTo: {\n get(store: Store, record: object, cacheKey: ResourceKey, field: LegacyBelongsToField) {\n // FIXME field.name here should likely be field.sourceKey || field.name\n return lookupLegacySupport(record as unknown as MinimalLegacyRecord).getBelongsTo(field.name);\n },\n set(store: Store, record: object, cacheKey: ResourceKey, field: LegacyBelongsToField, value: unknown) {\n assertPrivateStore(store);\n store._join(() => {\n // FIXME field.name here should likely be field.sourceKey || field.name\n lookupLegacySupport(record as unknown as MinimalLegacyRecord).setDirtyBelongsTo(field.name, value);\n });\n },\n },\n hasMany: {\n get(store: Store, record: object, cacheKey: ResourceKey, field: LegacyHasManyField) {\n // FIXME field.name here should likely be field.sourceKey || field.name\n return lookupLegacySupport(record as unknown as MinimalLegacyRecord).getHasMany(field.name);\n },\n set(store: Store, record: object, cacheKey: ResourceKey, field: LegacyHasManyField, value: unknown[]) {\n assertPrivateStore(store);\n store._join(() => {\n const support = lookupLegacySupport(record as unknown as MinimalLegacyRecord);\n // FIXME field.name here should likely be field.sourceKey || field.name\n const manyArray = support.getManyArray(field.name);\n\n manyArray.splice(0, manyArray.length, ...value);\n });\n },\n notify(store: Store, record: object, cacheKey: ResourceKey, field: LegacyHasManyField): boolean {\n const support = lookupLegacySupport(record as unknown as MinimalLegacyRecord);\n // FIXME field.name here should likely be field.sourceKey || field.name\n const manyArray = support && support._manyArrayCache[field.name];\n const hasPromise = support && (support._relationshipPromisesCache[field.name] as Promise<unknown> | undefined);\n\n if (manyArray && hasPromise) {\n // do nothing, we will notify the ManyArray directly\n // once the fetch has completed.\n return false;\n }\n\n if (manyArray) {\n notifyInternalSignal((manyArray as unknown as PrivateReactiveResourceArray)[Context].signal);\n\n return true;\n }\n\n return false;\n },\n },\n });\n\n schema.CAUTION_MEGA_DANGER_ZONE_registerExtension!({\n name: 'deprecated-model-behaviors',\n kind: 'object',\n features: {\n // oxlint-disable-next-line typescript/no-unsafe-assignment\n get isReloading() {\n deprecate(\n `record.isReloading is deprecated, please use store.request and either <Request> or getRequuestState to keep track of the request state instead.`,\n false,\n {\n id: 'warp-drive:deprecate-legacy-request-methods',\n until: '6.0',\n for: '@warp-drive/core',\n url: 'https://warp-drive.io/api/@warp-drive/core/build-config/deprecations/variables/ENABLE_LEGACY_REQUEST_METHODS',\n since: {\n enabled: '5.7',\n available: '5.7',\n },\n }\n );\n // @ts-expect-error\n // oxlint-disable-next-line typescript/no-unsafe-return\n return this._isReloading;\n },\n // oxlint-disable-next-line typescript/no-unsafe-assignment\n set isReloading(v) {\n // @ts-expect-error\n // oxlint-disable-next-line typescript/no-unsafe-assignment\n this._isReloading = v;\n },\n },\n });\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 * ReactiveResources by enabling unmigrated Models to continue to\n * provide their own schema information to the application.\n *\n * ```ts\n * import { DelegatingSchemaService } from '@warp-drive/legacy/model/migration-support';\n * import { SchemaService } from '@warp-drive/core/reactive';\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 * @summary Legacy schema service that serves a resource's schema from the primary service when it has one, and\n * otherwise from its `Model` class, for incremental migration.\n * @class DelegatingSchemaService\n * @public\n */\nexport interface DelegatingSchemaService {\n /**\n * Delegates to whichever of the primary/fallback schema services has a\n * schema for the resource, preferring the primary. See {@link DelegatingSchemaService.isDelegated | isDelegated}.\n */\n attributesDefinitionFor?(resource: ResourceKey | { type: string }): AttributesSchema;\n /**\n * Delegates to whichever of the primary/fallback schema services has a\n * schema for the resource, preferring the primary. See {@link DelegatingSchemaService.isDelegated | isDelegated}.\n */\n relationshipsDefinitionFor?(resource: ResourceKey | { type: string }): RelationshipsSchema;\n /**\n * Whether either the primary or fallback schema service has a schema\n * for the given type.\n */\n doesTypeExist?(type: string): boolean;\n}\n/**\n * See the {@link DelegatingSchemaService | class documentation above} for usage.\n * @summary Legacy schema service that serves a resource's schema from the primary service when it has one, and\n * otherwise from its `Model` class, for incremental migration.\n */\nexport class DelegatingSchemaService implements SchemaService {\n /** @internal */\n _preferred!: SchemaService;\n /** @internal */\n _secondary!: SchemaService;\n\n constructor(store: Store, schema: SchemaService) {\n this._preferred = schema;\n this._secondary = buildSchema(store);\n }\n\n /**\n * Whether the given resource's schema is being served by the fallback\n * (legacy Model-derived) schema service rather than the primary one.\n */\n isDelegated(resource: ResourceKey | { type: string }): boolean {\n return !this._preferred.hasResource(resource) && this._secondary.hasResource(resource);\n }\n\n resourceTypes(): Readonly<string[]> {\n return Array.from(new Set(this._preferred.resourceTypes().concat(this._secondary.resourceTypes())));\n }\n\n hasResource(resource: ResourceKey | { 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: ResourceKey | { 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: ResourceKey | { 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 cacheFields?(resource: { type: string }): Map<string, Exclude<CacheableFieldSchema, IdentityField>> {\n if (this._preferred.hasResource?.(resource)) {\n // @ts-expect-error\n return this._preferred.cacheFields?.(resource);\n }\n\n // @ts-expect-error\n return this._secondary.cacheFields?.(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: ResourceKey | { 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 CAUTION_MEGA_DANGER_ZONE_hasExtension(ext: { kind: 'object' | 'array'; name: string }): boolean {\n return this._preferred.CAUTION_MEGA_DANGER_ZONE_hasExtension!(ext);\n }\n\n CAUTION_MEGA_DANGER_ZONE_registerExtension(extension: CAUTION_MEGA_DANGER_ZONE_Extension): void {\n this._preferred.CAUTION_MEGA_DANGER_ZONE_registerExtension!(extension);\n }\n\n CAUTION_MEGA_DANGER_ZONE_resourceExtensions(\n resource: ResourceKey | { type: string }\n ): null | ProcessedExtension['features'] {\n return this._preferred.CAUTION_MEGA_DANGER_ZONE_resourceExtensions!(resource);\n }\n\n CAUTION_MEGA_DANGER_ZONE_objectExtensions(\n field: ExtensibleField,\n resolvedType: string | null\n ): null | ProcessedExtension['features'] {\n return this._preferred.CAUTION_MEGA_DANGER_ZONE_objectExtensions!(field, resolvedType);\n }\n\n CAUTION_MEGA_DANGER_ZONE_arrayExtensions(field: ExtensibleField): null | ProcessedExtension['features'] {\n return this._preferred.CAUTION_MEGA_DANGER_ZONE_arrayExtensions!(field);\n }\n\n /**\n * This is an internal method used to register behaviors for legacy mode.\n * It is not intended for public use.\n *\n * We do think a generalized `kind` registration system would be useful,\n * but we have not yet designed it.\n *\n * See https://github.com/warp-drive-data/warp-drive/issues/9534\n *\n * @internal\n */\n _registerMode(mode: string, kinds: unknown): void {\n // @ts-expect-error\n // oxlint-disable-next-line typescript/no-unsafe-call\n this._preferred._registerMode(mode, kinds);\n }\n\n /**\n * This is an internal method used to enable legacy behaviors for legacy mode.\n * It is not intended for public use.\n *\n * We do think a generalized `kind` registration system would be useful,\n * but we have not yet designed it.\n *\n * See https://github.com/warp-drive-data/warp-drive/issues/9534\n *\n * @internal\n */\n _kind(mode: string, kind: 'belongsTo' | 'hasMany'): () => unknown {\n // @ts-expect-error\n // oxlint-disable-next-line typescript/no-unsafe-call\n return this._preferred._kind(mode, kind) as () => unknown;\n }\n}\n\n/**\n * @internal\n */\nexport interface PrivateDelegatingSchemaService extends DelegatingSchemaService {\n _preferred: SchemaService;\n _secondary: SchemaService;\n}\nfunction assertPrivate(service: DelegatingSchemaService): asserts service is PrivateDelegatingSchemaService {}\n\nif (ENABLE_LEGACY_SCHEMA_SERVICE) {\n DelegatingSchemaService.prototype.attributesDefinitionFor = function (resource: ResourceKey | { type: string }) {\n assertPrivate(this);\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 (resource: ResourceKey | { type: string }) {\n assertPrivate(this);\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 assertPrivate(this);\n return this._preferred.doesTypeExist?.(type) || this._secondary.doesTypeExist?.(type) || false;\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4IA,MAAM2B,eAAe;CACnB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgDhB,MAAMC,gBAAgBvB,eAAe,iCAAiB,IAAIwB,QAAsD,CAAC;AAEjH,SAASC,cAAcC,QAA6BC,SAA6BC,MAAuB;CACtG,IAAIC,QAAQN,cAAcO,IAAIJ,MAAM;CACpC,IAAI,CAACG,OAAO;EACVA,QAAQ,CAAC;EACTN,cAAcQ,IAAIL,QAAQG,KAAK;CACjC;CACA,MAAMG,sBAAsBC,QA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;AACF"}
1
+ {"version":3,"file":"migration-support.js","names":["deprecate","recordIdentifierFor","Context","notifyInternalSignal","assertPrivateStore","getOrSetGlobal","Type","Errors","lookupLegacySupport","_destroyRecord","_reload","_save","belongsTo","changedAttributes","createSnapshot","deleteRecord","destroyRecord","hasMany","reload","rollbackAttributes","save","serialize","unloadRecord","RecordState","buildSchema","getGlobalConfig","macroCondition","LegacyFields","LegacySupport","WeakMap","legacySupport","record","options","prop","state","get","set","suppressDeprecation","Boolean","currentState","adapterError","_constructor","isModel","name","type","modelName","recordState","dirtyType","errors","create","__record","isDirty","isDeleted","isEmpty","isError","isLoaded","isLoading","isNew","isSaving","isValid","WarpDrive","env","DEBUG","test","Error","withDefaults","schema","legacy","identity","kind","forEach","field","fields","push","defaultValue","objectExtensions","withRestoredDeprecatedModelRequestBehaviors","registerDerivations","registerDerivation","_registerMode","store","cacheKey","getBelongsTo","value","_join","setDirtyBelongsTo","getHasMany","support","manyArray","getManyArray","splice","length","notify","key","sourceKey","_manyArrayCache","hasPromise","_relationshipPromisesCache","signal","CAUTION_MEGA_DANGER_ZONE_registerExtension","features","isReloading","id","until","for","url","since","enabled","available","_isReloading","v","DelegatingSchemaService","_preferred","_secondary","constructor","isDelegated","resource","hasResource","resourceTypes","Array","from","Set","concat","hasTrait","resourceHasTrait","trait","cacheFields","transformation","hashFn","derivation","registerResources","schemas","registerResource","registerTransformation","transform","registerHashFn","CAUTION_MEGA_DANGER_ZONE_hasExtension","ext","extension","CAUTION_MEGA_DANGER_ZONE_resourceExtensions","CAUTION_MEGA_DANGER_ZONE_objectExtensions","resolvedType","CAUTION_MEGA_DANGER_ZONE_arrayExtensions","mode","kinds","_kind","assertPrivate","service","deprecations","ENABLE_LEGACY_SCHEMA_SERVICE","prototype","attributesDefinitionFor","relationshipsDefinitionFor","doesTypeExist"],"sources":["../../src/model/migration-support.ts"],"sourcesContent":["/**\n * This module provides support for migrating away from @warp-drive/legacy/model\n * to ReactiveResource from @warp-drive/core/reactive.\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 * @warp-drive/legacy/model and @warp-drive/core/reactive 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 ReactiveResource *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 * @summary Legacy helpers for migrating from `Model` to `ReactiveResource`: LegacyMode schema defaults, derivations,\n * types, and a schema service that serves both at once.\n * @module\n */\nimport { deprecate } from '@ember/debug';\n\nimport type { Store } from '@warp-drive/core';\nimport { recordIdentifierFor } from '@warp-drive/core';\nimport { ENABLE_LEGACY_SCHEMA_SERVICE } from '@warp-drive/core/build-config/deprecations';\nimport { assert } from '@warp-drive/core/build-config/macros';\nimport type { CAUTION_MEGA_DANGER_ZONE_Extension, ProcessedExtension } from '@warp-drive/core/reactive';\nimport type { ExtensibleField } from '@warp-drive/core/reactive/-private';\nimport { Context } from '@warp-drive/core/reactive/-private';\nimport { notifyInternalSignal } from '@warp-drive/core/signals/-leaked';\nimport type { PrivateReactiveResourceArray } from '@warp-drive/core/store/-private';\nimport { assertPrivateStore } from '@warp-drive/core/store/-private';\nimport type { SchemaService } from '@warp-drive/core/types';\nimport { getOrSetGlobal } from '@warp-drive/core/types/-private';\nimport type { ChangedAttributesHash } from '@warp-drive/core/types/cache';\nimport type { ResourceKey } from '@warp-drive/core/types/identifier';\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 CacheableFieldSchema,\n DerivedField,\n FieldSchema,\n GenericField,\n HashField,\n IdentityField,\n LegacyBelongsToField,\n LegacyHasManyField,\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 type { Snapshot } from '../compat/-private.ts';\nimport { Errors, lookupLegacySupport } from './-private.ts';\nimport type { MinimalLegacyRecord } from './-private/model-methods.ts';\nimport {\n _destroyRecord,\n _reload,\n _save,\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.ts';\nimport RecordState from './-private/record-state.ts';\nimport type BelongsToReference from './-private/references/belongs-to.ts';\nimport type HasManyReference from './-private/references/has-many.ts';\nimport { buildSchema } from './-private/schema-provider.ts';\nimport type { _MaybeBelongsToFields, MaybeHasManyFields } from './-private/type-utils.ts';\n\n/**\n * Adds the `Model`-style `belongsTo`/`hasMany` reference methods to a\n * {@link TypedRecordInstance}, for use when migrating a resource from\n * `Model` to a schema-based record while preserving these APIs.\n *\n * @summary Legacy type that adds the `Model`-style `belongsTo` and `hasMany` reference methods to a typed record\n * migrating from `Model` to a schema-based record.\n */\nexport type WithLegacyDerivations<T extends TypedRecordInstance> = T &\n MinimalLegacyRecord & {\n /**\n * see {@link belongsTo}\n */\n belongsTo: typeof belongsTo;\n /**\n * see {@link hasMany}\n */\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 '@warp-drive/legacy/model/migration-support'`.\n *\n * Example:\n *\n * ```ts\n * import { withDefaults, WithLegacy } from '@warp-drive/legacy/model/migration-support';\n * import { Type } from '@warp-drive/core/types/symbols';\n * import type { HasMany } from '@@warp-drive/legacy/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 * @summary Legacy type that adds the `Model`-style state flags and methods (`save`, `isNew`, `errors`, etc.) that\n * `withDefaults` provides to a LegacyMode record type.\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 const suppressDeprecation = Boolean(options && options.suppressDeprecation);\n\n switch (prop) {\n case '_createSnapshot':\n // FIXME should be deprecated too?\n return createSnapshot;\n case 'adapterError':\n // FIXME should be deprecated too?\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 suppressDeprecation ? _destroyRecord : destroyRecord;\n case 'dirtyType':\n return record.currentState.dirtyType;\n case 'errors':\n // FIXME should be deprecated too?\n // @ts-expect-error\n // oxlint-disable-next-line typescript/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 suppressDeprecation ? _reload : reload;\n case 'rollbackAttributes':\n return rollbackAttributes;\n case 'save':\n return suppressDeprecation ? _save : save;\n case 'serialize':\n // FIXME should be deprecated too? (is somewhat deprecated via store.serializeRecord)\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 * @warp-drive/legacy/model while migrating to WarpDrive.\n *\n * Example:\n *\n * ```ts\n * import { withDefaults, WithLegacy } from '@warp-drive/legacy/model/migration-support';\n * import { Type } from '@warp-drive/core/types/symbols';\n * import type { HasMany } from '@warp-drive/legacy/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 '@warp-drive/legacy/model/migration-support';\n *\n * registerDerivations(schema);\n * ```\n *\n * @summary Legacy helper that marks a resource schema as LegacyMode and adds the fields that give its records\n * `Model`-like state and methods.\n * @param schema The schema to add legacy support to.\n * @return 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 schema.objectExtensions = schema.objectExtensions || [];\n schema.objectExtensions.push('deprecated-model-behaviors');\n return schema as LegacyResourceSchema;\n}\n\n/**\n * Adds the necessasary fields to the schema for supporting\n * the deprecated request methods on LegacyMode schemas.\n *\n * Use this instead of `withDefaults` to add the fields\n * and behaviors necessary to support Model-Like capabilities.\n *\n * ```ts\n * import { withRestoredDeprecatedModelRequestBehaviors } from '@warp-drive/legacy/model/migration-support';\n *\n * export const UserSchema = withRestoredDeprecatedModelRequestBehaviors({\n * type: 'user',\n * fields: [\n * { name: 'firstName', kind: 'attribute' },\n * { name: 'lastName', kind: 'attribute' },\n * ]\n * });\n * ```\n *\n * @summary Legacy alternative to `withDefaults` that makes a LegacyMode schema whose `save`, `reload`, and\n * `destroyRecord` run without deprecation warnings.\n */\nexport function withRestoredDeprecatedModelRequestBehaviors(\n schema: WithPartial<LegacyResourceSchema, 'legacy' | 'identity'>\n): 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 options: { suppressDeprecation: true },\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 @warp-drive/legacy/model while migrating to WarpDrive.\n *\n * This must be called in order to use the fields added by {@link withDefaults} or\n * {@link withRestoredDeprecatedModelRequestBehaviors}.\n *\n * @summary Legacy setup that registers the derivation, relationship behaviors, and extension a schema service needs to\n * support LegacyMode records.\n * @param schema The schema service to register the derivations with.\n * @public\n */\nexport function registerDerivations(schema: SchemaService): void {\n schema.registerDerivation(legacySupport);\n // @ts-expect-error\n // oxlint-disable-next-line typescript/no-unsafe-call\n schema._registerMode('@legacy', {\n belongsTo: {\n get(store: Store, record: object, cacheKey: ResourceKey, field: LegacyBelongsToField) {\n // FIXME field.name here should likely be field.sourceKey || field.name\n return lookupLegacySupport(record as unknown as MinimalLegacyRecord).getBelongsTo(field.name);\n },\n set(store: Store, record: object, cacheKey: ResourceKey, field: LegacyBelongsToField, value: unknown) {\n assertPrivateStore(store);\n store._join(() => {\n // FIXME field.name here should likely be field.sourceKey || field.name\n lookupLegacySupport(record as unknown as MinimalLegacyRecord).setDirtyBelongsTo(field.name, value);\n });\n },\n },\n hasMany: {\n get(store: Store, record: object, cacheKey: ResourceKey, field: LegacyHasManyField) {\n // FIXME field.name here should likely be field.sourceKey || field.name\n return lookupLegacySupport(record as unknown as MinimalLegacyRecord).getHasMany(field.name);\n },\n set(store: Store, record: object, cacheKey: ResourceKey, field: LegacyHasManyField, value: unknown[]) {\n assertPrivateStore(store);\n store._join(() => {\n const support = lookupLegacySupport(record as unknown as MinimalLegacyRecord);\n // FIXME field.name here should likely be field.sourceKey || field.name\n const manyArray = support.getManyArray(field.name);\n\n manyArray.splice(0, manyArray.length, ...value);\n });\n },\n notify(store: Store, record: object, cacheKey: ResourceKey, field: LegacyHasManyField): boolean {\n const support = lookupLegacySupport(record as unknown as MinimalLegacyRecord);\n // LegacySupport caches relationships by `sourceKey ?? name`\n const key = field.sourceKey ?? field.name;\n const manyArray = support && support._manyArrayCache[key];\n const hasPromise = support && (support._relationshipPromisesCache[key] as Promise<unknown> | undefined);\n\n if (manyArray && hasPromise) {\n // do nothing, we will notify the ManyArray directly\n // once the fetch has completed.\n return false;\n }\n\n if (manyArray) {\n notifyInternalSignal((manyArray as unknown as PrivateReactiveResourceArray)[Context].signal);\n\n return true;\n }\n\n return false;\n },\n },\n });\n\n schema.CAUTION_MEGA_DANGER_ZONE_registerExtension!({\n name: 'deprecated-model-behaviors',\n kind: 'object',\n features: {\n // oxlint-disable-next-line typescript/no-unsafe-assignment\n get isReloading() {\n deprecate(\n `record.isReloading is deprecated, please use store.request and either <Request> or getRequuestState to keep track of the request state instead.`,\n false,\n {\n id: 'warp-drive:deprecate-legacy-request-methods',\n until: '6.0',\n for: '@warp-drive/core',\n url: 'https://warp-drive.io/api/@warp-drive/core/build-config/deprecations/variables/ENABLE_LEGACY_REQUEST_METHODS',\n since: {\n enabled: '5.7',\n available: '5.7',\n },\n }\n );\n // @ts-expect-error\n // oxlint-disable-next-line typescript/no-unsafe-return\n return this._isReloading;\n },\n // oxlint-disable-next-line typescript/no-unsafe-assignment\n set isReloading(v) {\n // @ts-expect-error\n // oxlint-disable-next-line typescript/no-unsafe-assignment\n this._isReloading = v;\n },\n },\n });\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 * ReactiveResources by enabling unmigrated Models to continue to\n * provide their own schema information to the application.\n *\n * ```ts\n * import { DelegatingSchemaService } from '@warp-drive/legacy/model/migration-support';\n * import { SchemaService } from '@warp-drive/core/reactive';\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 * @summary Legacy schema service that serves a resource's schema from the primary service when it has one, and\n * otherwise from its `Model` class, for incremental migration.\n * @class DelegatingSchemaService\n * @public\n */\nexport interface DelegatingSchemaService {\n /**\n * Delegates to whichever of the primary/fallback schema services has a\n * schema for the resource, preferring the primary. See {@link DelegatingSchemaService.isDelegated | isDelegated}.\n */\n attributesDefinitionFor?(resource: ResourceKey | { type: string }): AttributesSchema;\n /**\n * Delegates to whichever of the primary/fallback schema services has a\n * schema for the resource, preferring the primary. See {@link DelegatingSchemaService.isDelegated | isDelegated}.\n */\n relationshipsDefinitionFor?(resource: ResourceKey | { type: string }): RelationshipsSchema;\n /**\n * Whether either the primary or fallback schema service has a schema\n * for the given type.\n */\n doesTypeExist?(type: string): boolean;\n}\n/**\n * See the {@link DelegatingSchemaService | class documentation above} for usage.\n * @summary Legacy schema service that serves a resource's schema from the primary service when it has one, and\n * otherwise from its `Model` class, for incremental migration.\n */\nexport class DelegatingSchemaService implements SchemaService {\n /** @internal */\n _preferred!: SchemaService;\n /** @internal */\n _secondary!: SchemaService;\n\n constructor(store: Store, schema: SchemaService) {\n this._preferred = schema;\n this._secondary = buildSchema(store);\n }\n\n /**\n * Whether the given resource's schema is being served by the fallback\n * (legacy Model-derived) schema service rather than the primary one.\n */\n isDelegated(resource: ResourceKey | { type: string }): boolean {\n return !this._preferred.hasResource(resource) && this._secondary.hasResource(resource);\n }\n\n resourceTypes(): Readonly<string[]> {\n return Array.from(new Set(this._preferred.resourceTypes().concat(this._secondary.resourceTypes())));\n }\n\n hasResource(resource: ResourceKey | { 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: ResourceKey | { 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: ResourceKey | { 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 cacheFields?(resource: { type: string }): Map<string, Exclude<CacheableFieldSchema, IdentityField>> {\n if (this._preferred.hasResource?.(resource)) {\n // @ts-expect-error\n return this._preferred.cacheFields?.(resource);\n }\n\n // @ts-expect-error\n return this._secondary.cacheFields?.(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: ResourceKey | { 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 CAUTION_MEGA_DANGER_ZONE_hasExtension(ext: { kind: 'object' | 'array'; name: string }): boolean {\n return this._preferred.CAUTION_MEGA_DANGER_ZONE_hasExtension!(ext);\n }\n\n CAUTION_MEGA_DANGER_ZONE_registerExtension(extension: CAUTION_MEGA_DANGER_ZONE_Extension): void {\n this._preferred.CAUTION_MEGA_DANGER_ZONE_registerExtension!(extension);\n }\n\n CAUTION_MEGA_DANGER_ZONE_resourceExtensions(\n resource: ResourceKey | { type: string }\n ): null | ProcessedExtension['features'] {\n return this._preferred.CAUTION_MEGA_DANGER_ZONE_resourceExtensions!(resource);\n }\n\n CAUTION_MEGA_DANGER_ZONE_objectExtensions(\n field: ExtensibleField,\n resolvedType: string | null\n ): null | ProcessedExtension['features'] {\n return this._preferred.CAUTION_MEGA_DANGER_ZONE_objectExtensions!(field, resolvedType);\n }\n\n CAUTION_MEGA_DANGER_ZONE_arrayExtensions(field: ExtensibleField): null | ProcessedExtension['features'] {\n return this._preferred.CAUTION_MEGA_DANGER_ZONE_arrayExtensions!(field);\n }\n\n /**\n * This is an internal method used to register behaviors for legacy mode.\n * It is not intended for public use.\n *\n * We do think a generalized `kind` registration system would be useful,\n * but we have not yet designed it.\n *\n * See https://github.com/warp-drive-data/warp-drive/issues/9534\n *\n * @internal\n */\n _registerMode(mode: string, kinds: unknown): void {\n // @ts-expect-error\n // oxlint-disable-next-line typescript/no-unsafe-call\n this._preferred._registerMode(mode, kinds);\n }\n\n /**\n * This is an internal method used to enable legacy behaviors for legacy mode.\n * It is not intended for public use.\n *\n * We do think a generalized `kind` registration system would be useful,\n * but we have not yet designed it.\n *\n * See https://github.com/warp-drive-data/warp-drive/issues/9534\n *\n * @internal\n */\n _kind(mode: string, kind: 'belongsTo' | 'hasMany'): () => unknown {\n // @ts-expect-error\n // oxlint-disable-next-line typescript/no-unsafe-call\n return this._preferred._kind(mode, kind) as () => unknown;\n }\n}\n\n/**\n * @internal\n */\nexport interface PrivateDelegatingSchemaService extends DelegatingSchemaService {\n _preferred: SchemaService;\n _secondary: SchemaService;\n}\nfunction assertPrivate(service: DelegatingSchemaService): asserts service is PrivateDelegatingSchemaService {}\n\nif (ENABLE_LEGACY_SCHEMA_SERVICE) {\n DelegatingSchemaService.prototype.attributesDefinitionFor = function (resource: ResourceKey | { type: string }) {\n assertPrivate(this);\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 (resource: ResourceKey | { type: string }) {\n assertPrivate(this);\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 assertPrivate(this);\n return this._preferred.doesTypeExist?.(type) || this._secondary.doesTypeExist?.(type) || false;\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4IA,MAAM2B,eAAe;CACnB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgDhB,MAAMC,gBAAgBvB,eAAe,iCAAiB,IAAIwB,QAAsD,CAAC;AAEjH,SAASC,cAAcC,QAA6BC,SAA6BC,MAAuB;CACtG,IAAIC,QAAQN,cAAcO,IAAIJ,MAAM;CACpC,IAAI,CAACG,OAAO;EACVA,QAAQ,CAAC;EACTN,cAAcQ,IAAIL,QAAQG,KAAK;CACjC;CACA,MAAMG,sBAAsBC,QAAQN,WAAWA,QAAQK,mBAAmB;CAE1E,QAAQJ,MAAR;EACE,KAAK,mBAEH,OAAOnB;EACT,KAAK,gBAEH,OAAOiB,OAAOQ,aAAaC;EAC7B,KAAK,aACH,OAAO5B;EACT,KAAK,qBACH,OAAOC;EACT,KAAK,eACH,OAAQqB,MAAMO,eAAeP,MAAMO,gBAAgB;GACjDC,SAAS;GACTC,MAAM,UAAU1C,oBAAoB8B,MAAM,CAAC,CAACa,KAAI;GAChDC,WAAW5C,oBAAoB8B,MAAM,CAAC,CAACa;EACzC;EACF,KAAK,gBACH,OAAQV,MAAMY,cAAcZ,MAAMY,eAAe,IAAIvB,YAAYQ,MAAM;EACzE,KAAK,gBACH,OAAOhB;EACT,KAAK,iBACH,OAAOsB,sBAAsB5B,iBAAiBO;EAChD,KAAK,aACH,OAAOe,OAAOQ,aAAaQ;EAC7B,KAAK,UAIH,OAAQb,MAAMc,SAASd,MAAMc,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1E,MAA8C;EAGhE,OAAO,KAAK2C,WAAWiC,MAAMF,MAAM1E,IAAI;CACzC;AACF;AAWA,IAAA3C,eAAAD,gBAAA,CAAA,CAAAmC,UAAAwF,aAAAC,4BAAA,GAAkC;CAChCtC,wBAAwBuC,UAAUC,0BAA0B,SAAUnC,UAA0C;EAE9G,IAAI,KAAKJ,WAAWK,YAAYD,QAAQ,GACtC,OAAO,KAAKJ,WAAWuC,wBAAyBnC,QAAQ;EAG1D,OAAO,KAAKH,WAAWsC,wBAAyBnC,QAAQ;CAC1D;CACAL,wBAAwBuC,UAAUE,6BAA6B,SAAUpC,UAA0C;EAEjH,IAAI,KAAKJ,WAAWK,YAAYD,QAAQ,GACtC,OAAO,KAAKJ,WAAWwC,2BAA4BpC,QAAQ;EAG7D,OAAO,KAAKH,WAAWuC,2BAA4BpC,QAAQ;CAC7D;CACAL,wBAAwBuC,UAAUG,gBAAgB,SAAU7G,MAAc;EAExE,OAAO,KAAKoE,WAAWyC,gBAAgB7G,IAAI,KAAK,KAAKqE,WAAWwC,gBAAgB7G,IAAI,KAAK;CAC3F;AACF"}
@@ -1,3 +1,8 @@
1
+ /**
2
+ * @module
3
+ * @summary Legacy helpers for migrating ember-data-model-fragments to WarpDrive schemas, including `withLegacy`,
4
+ * `withFragmentDefaults` and the `Fragment` and `FragmentArray` extensions.
5
+ */
1
6
  import { a as WithArrayLike, o as WithEmberObject } from "./extensions-fwdnX9n4.js";
2
7
  import { Store } from "@warp-drive/core";
3
8
  import { PrivateReactiveResource } from "@warp-drive/core/reactive/-private";
@@ -1 +1 @@
1
- {"version":3,"file":"model-fragments.d.ts","names":[],"sources":["../src/model-fragments/utilities/with-array-defaults.ts","../src/model-fragments/utilities/with-fragment-defaults.ts","../src/model-fragments/utilities/with-fragment-array-defaults.ts","../src/model-fragments/utilities/with-legacy.ts","../src/model-fragments/instance-initializers/fragment-extensions.ts","../src/model-fragments/hooks/model-for.ts","../src/model-fragments/extensions/fragment.ts","../src/model-fragments/extens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OA;;;;EAQJ,mBAAA,MAAyB;;;;;;;;;qBAiBd;;;;EAIX;;;;EAIA;;;;EAIA,iBAAiB;;;;;;;;;;;qBC1EN,cAAc,UAAU;;;;EAKnC;;;;EAIA;;;;MAMI;;;;EAiBJ,YAAY,WAAW,IAAI;;;;EAW3B,eAAe,WAAW,IAAI;;;;EAW9B,eAAe,WAAW;;;;EAe1B;;;;;;;;;qBAeW;;;;EAIX;;;;EAIA;;;;EAIA,iBAAiB;;;;;;;;;;;KCrGP,aAAa,KAAK,IAAI,gBAAgB,KAAK;;;;;;;;KAQ3C,kBAAkB,UAAU,YAAY,IAAI,cAAc,KAAK,cAAc"}
1
+ {"version":3,"file":"model-fragments.d.ts","names":[],"sources":["../src/model-fragments/utilities/with-array-defaults.ts","../src/model-fragments/utilities/with-fragment-defaults.ts","../src/model-fragments/utilities/with-fragment-array-defaults.ts","../src/model-fragments/utilities/with-legacy.ts","../src/model-fragments/instance-initializers/fragment-extensions.ts","../src/model-fragments/hooks/model-for.ts","../src/model-fragments/extensions/fragment.ts","../src/model-fragments/extensions/fragment-array.ts","../src/model-fragments/index.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;wBAUgB,kBAAkB,0BAA0B,8BAC1D,WAAW,WACX,gBAAgB,gBACf;;;;EAKG;;;;EAIA,MAAM;;;;EAIN;;;;EAIA;;;;IAIE;;;;;;EAOF;;;;EAIA,MAAM;;;;EAIN,eAAe;;;;EAIf;;;;IAIE;;;;;;;;;;;;;;;wBC/CQ,qBAAqB,6BAA6B,6BAChE,cAAc,cACd,eAAe;;;;EAKf;;;;EAIA,kBAAkB;;;;EAIlB,MAAM,eAAe;;;;EAIrB;;;;IAIE;;;;;;;;;;;;;;;wBCrBY,0BAA0B,kCAAkC,kCAC1E,mBAAmB,mBACnB,oBAAoB;;;;EAKpB;;;;EAIA;;;;EAIA;;;;EAIA;;;;IAIE;;;;IAIA;;;;;;;;;;;;;;;wBCxBY,WAAW,QAAQ,YAAY,+CAA+C;;;;;;;;;;;wBCC9E,2BAA2B,QAAQ;;;KCV9C,YAAY,WAAW,0CAA0C;cA4BzD,eAAe,wBAAwB,YAAY;EAC9D,SAAiB;EACjB,WAAmB,UAAU,sBAAsB,iBAAiB;EACpE,YAAY,OAAO,OAAO,WAAW,UAAU,sBAAsB,iBAAiB;MAKlF,UAAU,IAAI,YAAY;MAgB1B,cAAc,IAAI,YAAY,IAAI;MAqBlC,uBAAuB,IAAI,YAAY,IAAI;EAa/C,cAAc,UAAU,YAAY,IAClC,WAAW,KAAK,GAAG,WAAW,+BAC9B,UAAU;EAOZ,iBAAiB,UAAU,YAAY,IACrC,WAAW,KAAK,GAAG,cAAc,kCACjC,UAAU;EASZ,yBAAyB,UAAU,YAAY,IAC7C,WAAW,KAAK,GAAG,8BACnB,UAAU;;iBAWE,kBAAkB,UAAU,qBAAA,MACpC,OACN,WAAW,UAAU,sBAAsB,iBAAiB,cAC3D,eAAe;;;;;;;;;;qBAaL,iBAAiB;;;;;;;;;;qBC7HjB;;;;EAKX;;;;EAIA;;;;MAMI;;;;MAeA;;;;MAOA;;;;EAQJ,mBAAA,MAAyB;;;;;;;;;qBAiBd;;;;EAIX;;;;EAIA;;;;EAIA,iBAAiB;;;;;;;;;;;qBC1EN,cAAc,UAAU;;;;EAKnC;;;;EAIA;;;;MAMI;;;;EAiBJ,YAAY,WAAW,IAAI;;;;EAW3B,eAAe,WAAW,IAAI;;;;EAW9B,eAAe,WAAW;;;;EAe1B;;;;;;;;;qBAeW;;;;EAIX;;;;EAIA;;;;EAIA,iBAAiB;;;;;;;;;;;KCrGP,aAAa,KAAK,IAAI,gBAAgB,KAAK;;;;;;;;KAQ3C,kBAAkB,UAAU,YAAY,IAAI,cAAc,KAAK,cAAc"}
package/dist/model.d.ts CHANGED
@@ -1,3 +1,71 @@
1
+ /**
2
+ * This package provides a Presentation Model for resource data in an WarpDrive Cache.
3
+ *
4
+ * Models are defined as classes extending from `import Model from '@warp-drive/legacy/model';` and the
5
+ * attributes and relationships on these classes are parsed at runtime to supply static "schema"
6
+ * to WarpDrive's SchemaService.
7
+ *
8
+ * Resource data for individual resources fetched from your API is presented to the UI via instances
9
+ * of the `Model`s you define. An instantiated `Model` is referred to as a `record`.
10
+
11
+ When we refer to the `ModelClass` as opposed to a `Model` or `Record` we are referring
12
+ specifically to the class definition and the static schema methods present on it.
13
+
14
+ When we refer to a `record` we refer to a specific class instance presenting
15
+ the resource data for a given `type` and `id`.
16
+
17
+ ### Why It's Legacy
18
+
19
+ The `Model` pattern uses class inheritance and decorators to define your data schema:
20
+
21
+ - The `attr`, `belongsTo` and `hasMany` decorators are Ember computed properties, and the
22
+ schema is read at runtime by walking each Model class's computed properties.
23
+ - Every record is an instance of its own `Model` subclass, and `Model` extends `EmberObject`,
24
+ which ties your data layer to Ember and its object model.
25
+
26
+ ### Modern Alternative
27
+
28
+ Use **schemas** with `@warp-drive/core`. Modern ***Warp*Drive**:
29
+
30
+ - defines each resource's schema as a plain object, a `ResourceSchema`, registered with the
31
+ store's SchemaService, with no class or decorators
32
+ - presents every resource type through one record implementation,
33
+ [ReactiveResource](/api/@warp-drive/core/reactive/types/ReactiveResource), which reads
34
+ its fields from the registered schema
35
+ - shares fields across schemas with [traits](/guides/the-manual/schemas/traits), and adds
36
+ memoized read-only fields with [derivations](/guides/the-manual/schemas/derivations) and
37
+ value conversions with [transformations](/guides/the-manual/schemas/transformations),
38
+ instead of inheritance
39
+ - works in any framework ***Warp*Drive** supports, since `@warp-drive/core` has no runtime
40
+ dependency on Ember (see [Installation](/guides/installation/))
41
+
42
+ For guidance on migrating from Model classes to schemas, see the
43
+ [Schemas Guide](/guides/the-manual/schemas/) and the [Migration Guide](/upgrading/v5/).
44
+
45
+ ### Defining a Model
46
+
47
+ ```js [app/models/person.js]
48
+ import Model, { attr, belongsTo, hasMany } from '@warp-drive/legacy/model';
49
+
50
+ export default class PersonModel extends Model {
51
+ @attr name;
52
+
53
+ @belongsTo('pet', { inverse: 'owners', async: false }) dog;
54
+
55
+ @hasMany('person', { inverse: 'friends', async: true }) friends;
56
+ }
57
+ ```
58
+
59
+ ### modelName convention
60
+
61
+ By convention, the name of a given model (its `type`) matches the name
62
+ of the file in the `app/models` folder and should be lowercase, singular
63
+ and dasherized.
64
+
65
+ @summary Legacy `Model` base class and `attr`, `belongsTo`, and `hasMany` decorators that define resource schemas
66
+ as classes and present records.
67
+ @module
68
+ */
1
69
  import { S as belongsTo, b as RelationshipDecorator, m as PromiseBelongsTo, r as restoreDeprecatedModelRequestBehaviors, t as Model, v as PromiseManyArray, x as RelationshipOptions, y as NoNull } from "./model-BPVLf-rp.js";
2
70
  import { Store } from "@warp-drive/core";
3
71
  import { RelatedCollection as HasMany, RelatedCollection as ManyArray, Store as Store$1 } from "@warp-drive/core/store/-private";
@@ -1 +1 @@
1
- {"version":3,"file":"model.d.ts","names":["TypeFromInstance","Store","ResourceKey"],"sources":["../src/model/-private/util.ts","../src/model/-private/attr.ts","../src/model/-private/has-many.ts","../src/model/-private/hooks.ts","../src/model/-private/schema-provider.ts"],"mappings":";;;;;;;;;;;KAKY,+BAA+B;EAAuB;;;;;;;;;;;;;;;;;;;;;;;;;;;KC+BtD,YAAY,KAAK;;;;;;;;;;;EAW3B,eAAe,WAAW,iBAAiB,WAAW;;;;;;;;;;;;;;;;;;;;;EAsBtD;;KA8EG,uBAAuB,GAAG,KAAK;;;;;EAOlC,YAAY,OAAO,GAAG,iBAAiB;;;;;EAOvC,cAAc,OAAO,KAAK,iBAAiB;GAE1C,gBAAgB;;KAEP;GAAsB;;KAEtB,uBAAuB,GAAG,oBAClC,uBAAuB,WAAW,KAClC,uBAAuB,WAAW,KAClC,uBAAuB,YAAY,KACnC,uBAAuB,SAAS,KAChC,uBAAuB,GAAG,aAAa,KACvC,uBAAuB,GAAG,YAAY,KACtC,uBAAuB,kBAAkB,KACzC,uBAAuB,kBAAkB,KACzC,uBAAuB,mBAAmB,KAC1C,uBAAuB,GAAG,oBAAoB,KAC9C,uBAAuB,GAAG,mB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/util.ts","../src/model/-private/attr.ts","../src/model/-private/has-many.ts","../src/model/-private/hooks.ts","../src/model/-private/schema-provider.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAKY,+BAA+B;EAAuB;;;;;;;;;;;;;;;;;;;;;;;;;;;KC+BtD,YAAY,KAAK;;;;;;;;;;;EAW3B,eAAe,WAAW,iBAAiB,WAAW;;;;;;;;;;;;;;;;;;;;;EAsBtD;;KA8EG,uBAAuB,GAAG,KAAK;;;;;EAOlC,YAAY,OAAO,GAAG,iBAAiB;;;;;EAOvC,cAAc,OAAO,KAAK,iBAAiB;GAE1C,gBAAgB;;KAEP;GAAsB;;KAEtB,uBAAuB,GAAG,oBAClC,uBAAuB,WAAW,KAClC,uBAAuB,WAAW,KAClC,uBAAuB,YAAY,KACnC,uBAAuB,SAAS,KAChC,uBAAuB,GAAG,aAAa,KACvC,uBAAuB,GAAG,YAAY,KACtC,uBAAuB,kBAAkB,KACzC,uBAAuB,kBAAkB,KACzC,uBAAuB,mBAAmB,KAC1C,uBAAuB,GAAG,oBAAoB,KAC9C,uBAAuB,GAAG,mBAAmB;KAIrC,yBAAyB,KAAK;EAAY,iBAAiB;IACnE,WAAW;KAGHA,mBAAiB,KAAK,UAAU,mBAAmB,SAAS;KAG5D,oBAAoB,KAC9BA,mBAAiB,2BAEb,yBAAyB,2BAEvB,UAAU,uBAAuB,yBAAyB,IAAIA,mBAAiB,MAC7E,WAAW,uBAAuB,WAAW,qBAAqB,YAAY,WAAW;;;;;;;KASvF,iBAAiB,gBAAgB,aAAa,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wBA0FjD,QAAQ;wBACR,KAAK,GAAG,MAAMA,mBAAiB,KAAK;wBACpC,KAAK,eAAe;wBACpB,KAAK,SAAS,cAAc;wBAC5B,KAAK,GAAG,MAAMA,mBAAiB,IAAI,UAAU,oBAAoB,KAAK;wBACtE,KAAK,cAAc,UAAU,uBAAuB;wBACpD,KAAK,gBAAgB,sBAAsB,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wBC9ClD;wBACA,QAAQ;wBACR,QAAQ,GACtB,MAAM,iBAAiB,OAAO,KAC9B,SAAS,oBAAoB,cAC5B,sBAAsB;wBAKT,QAAQ,cAAc,SAAS,wCAAwC;;;;;;;;;;;;wBClPvE,kBAAA,MACRC,SACN,YAAYC,eACZ;;IACC;;;;;;;;;wBAgCa,eAAe,QAAQ;;;;;;;;;;wBAiBvB,SAAS,GAAG,MAAM,iBAAiB,YAAY;;;;;;wBAM/C,SAAS,sBAAsB;;;;;;;;;;;;wBCkM/B,YAAY,OAAO,QAAQ"}
@@ -1,3 +1,8 @@
1
+ /**
2
+ * @module
3
+ * @summary Legacy transforms that serialize and deserialize attribute values: the `Transform` base class plus the
4
+ * boolean, date, number and string transforms.
5
+ */
1
6
  import EmberObject from "@ember/object";
2
7
  import { TransformName } from "@warp-drive/core/types/symbols";
3
8
  import { LegacyAttributeField } from "@warp-drive/core/types/schema/fields";