@warp-drive/core-types 0.0.2 → 0.0.3
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/dist/-private.js +1 -1
- package/dist/runtime.js +13 -3
- package/dist/runtime.js.map +1 -1
- package/dist/schema/fields.js +89 -32
- package/dist/schema/fields.js.map +1 -1
- package/package.json +10 -10
- package/unstable-preview-types/cache/mutations.d.ts +5 -5
- package/unstable-preview-types/cache/mutations.d.ts.map +1 -1
- package/unstable-preview-types/cache/operations.d.ts +62 -5
- package/unstable-preview-types/cache/operations.d.ts.map +1 -1
- package/unstable-preview-types/cache/relationship.d.ts +5 -5
- package/unstable-preview-types/cache/relationship.d.ts.map +1 -1
- package/unstable-preview-types/cache.d.ts +2 -5
- package/unstable-preview-types/cache.d.ts.map +1 -1
- package/unstable-preview-types/graph.d.ts +4 -16
- package/unstable-preview-types/graph.d.ts.map +1 -1
- package/unstable-preview-types/runtime.d.ts +1 -1
- package/unstable-preview-types/runtime.d.ts.map +1 -1
- package/unstable-preview-types/schema/fields.d.ts +464 -82
- package/unstable-preview-types/schema/fields.d.ts.map +1 -1
- package/unstable-preview-types/spec/json-api-raw.d.ts +2 -2
- package/unstable-preview-types/spec/json-api-raw.d.ts.map +1 -1
- package/unstable-preview-types/utils.d.ts +3 -0
- package/unstable-preview-types/utils.d.ts.map +1 -1
package/dist/-private.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { macroCondition, getGlobalConfig } from '@embroider/macros';
|
|
2
2
|
const name = "@warp-drive/core-types";
|
|
3
|
-
const version = "0.0.
|
|
3
|
+
const version = "0.0.3";
|
|
4
4
|
|
|
5
5
|
// in testing mode, we utilize globals to ensure only one copy exists of
|
|
6
6
|
// these maps, due to bugs in ember-auto-import
|
package/dist/runtime.js
CHANGED
|
@@ -2,7 +2,17 @@ import { getOrSetUniversal } from "./-private.js";
|
|
|
2
2
|
const RuntimeConfig = getOrSetUniversal('WarpDriveRuntimeConfig', {
|
|
3
3
|
debug: {}
|
|
4
4
|
});
|
|
5
|
-
|
|
5
|
+
function trySessionStorage() {
|
|
6
|
+
// This works even when sessionStorage is not available.
|
|
7
|
+
// See https://github.com/emberjs/data/issues/9784
|
|
8
|
+
try {
|
|
9
|
+
return globalThis.sessionStorage;
|
|
10
|
+
} catch {
|
|
11
|
+
return undefined;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
const storage = trySessionStorage();
|
|
15
|
+
const settings = storage?.getItem('WarpDriveRuntimeConfig');
|
|
6
16
|
if (settings) {
|
|
7
17
|
Object.assign(RuntimeConfig, JSON.parse(settings));
|
|
8
18
|
}
|
|
@@ -14,12 +24,12 @@ function getRuntimeConfig() {
|
|
|
14
24
|
* Upserts the specified logging configuration into the runtime
|
|
15
25
|
* config.
|
|
16
26
|
*
|
|
17
|
-
* globalThis.setWarpDriveLogging({
|
|
27
|
+
* globalThis.setWarpDriveLogging({ LOG_CACHE: true } });
|
|
18
28
|
*
|
|
19
29
|
* @typedoc
|
|
20
30
|
*/
|
|
21
31
|
function setLogging(config) {
|
|
22
32
|
Object.assign(RuntimeConfig.debug, config);
|
|
23
|
-
|
|
33
|
+
storage?.setItem('WarpDriveRuntimeConfig', JSON.stringify(RuntimeConfig));
|
|
24
34
|
}
|
|
25
35
|
export { getRuntimeConfig, setLogging };
|
package/dist/runtime.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtime.js","sources":["../src/runtime.ts"],"sourcesContent":["import type { LOG_CONFIG } from '@warp-drive/build-config/-private/utils/logging';\n\nimport { getOrSetUniversal } from './-private';\n\nconst RuntimeConfig: { debug: Partial<LOG_CONFIG> } = getOrSetUniversal('WarpDriveRuntimeConfig', {\n debug: {},\n});\n\nconst settings =
|
|
1
|
+
{"version":3,"file":"runtime.js","sources":["../src/runtime.ts"],"sourcesContent":["import type { LOG_CONFIG } from '@warp-drive/build-config/-private/utils/logging';\n\nimport { getOrSetUniversal } from './-private';\n\nconst RuntimeConfig: { debug: Partial<LOG_CONFIG> } = getOrSetUniversal('WarpDriveRuntimeConfig', {\n debug: {},\n});\n\nfunction trySessionStorage() {\n // This works even when sessionStorage is not available.\n // See https://github.com/emberjs/data/issues/9784\n try {\n return globalThis.sessionStorage;\n } catch {\n return undefined;\n }\n}\n\nconst storage = trySessionStorage();\nconst settings = storage?.getItem('WarpDriveRuntimeConfig');\nif (settings) {\n Object.assign(RuntimeConfig, JSON.parse(settings));\n}\n\nexport function getRuntimeConfig(): typeof RuntimeConfig {\n return RuntimeConfig;\n}\n\n/**\n * Upserts the specified logging configuration into the runtime\n * config.\n *\n * globalThis.setWarpDriveLogging({ LOG_CACHE: true } });\n *\n * @typedoc\n */\nexport function setLogging(config: Partial<LOG_CONFIG>): void {\n Object.assign(RuntimeConfig.debug, config);\n storage?.setItem('WarpDriveRuntimeConfig', JSON.stringify(RuntimeConfig));\n}\n"],"names":["RuntimeConfig","getOrSetUniversal","debug","trySessionStorage","globalThis","sessionStorage","undefined","storage","settings","getItem","Object","assign","JSON","parse","getRuntimeConfig","setLogging","config","setItem","stringify"],"mappings":";;AAIA,MAAMA,aAA6C,GAAGC,iBAAiB,CAAC,wBAAwB,EAAE;AAChGC,EAAAA,KAAK,EAAE;AACT,CAAC,CAAC;AAEF,SAASC,iBAAiBA,GAAG;AAC3B;AACA;EACA,IAAI;IACF,OAAOC,UAAU,CAACC,cAAc;AAClC,GAAC,CAAC,MAAM;AACN,IAAA,OAAOC,SAAS;AAClB;AACF;AAEA,MAAMC,OAAO,GAAGJ,iBAAiB,EAAE;AACnC,MAAMK,QAAQ,GAAGD,OAAO,EAAEE,OAAO,CAAC,wBAAwB,CAAC;AAC3D,IAAID,QAAQ,EAAE;EACZE,MAAM,CAACC,MAAM,CAACX,aAAa,EAAEY,IAAI,CAACC,KAAK,CAACL,QAAQ,CAAC,CAAC;AACpD;AAEO,SAASM,gBAAgBA,GAAyB;AACvD,EAAA,OAAOd,aAAa;AACtB;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASe,UAAUA,CAACC,MAA2B,EAAQ;EAC5DN,MAAM,CAACC,MAAM,CAACX,aAAa,CAACE,KAAK,EAAEc,MAAM,CAAC;EAC1CT,OAAO,EAAEU,OAAO,CAAC,wBAAwB,EAAEL,IAAI,CAACM,SAAS,CAAClB,aAAa,CAAC,CAAC;AAC3E;;;;"}
|
package/dist/schema/fields.js
CHANGED
|
@@ -16,7 +16,8 @@
|
|
|
16
16
|
* "type" points to a new-style transform on "field"
|
|
17
17
|
* that a record implmentation *must* use.
|
|
18
18
|
*
|
|
19
|
-
* @
|
|
19
|
+
* @class <Type> GenericField
|
|
20
|
+
* @public
|
|
20
21
|
*/
|
|
21
22
|
|
|
22
23
|
/**
|
|
@@ -45,7 +46,8 @@
|
|
|
45
46
|
* an AliasField could be used to expose both a string and a Date version of the
|
|
46
47
|
* same field, with both being capable of being written to.
|
|
47
48
|
*
|
|
48
|
-
* @
|
|
49
|
+
* @class <Type> LegacyAliasField
|
|
50
|
+
* @public
|
|
49
51
|
*/
|
|
50
52
|
|
|
51
53
|
/**
|
|
@@ -74,7 +76,8 @@
|
|
|
74
76
|
* an AliasField could be used to expose both a string and a Date version of the
|
|
75
77
|
* same field, with both being capable of being written to.
|
|
76
78
|
*
|
|
77
|
-
* @
|
|
79
|
+
* @class <Type> PolarisAliasField
|
|
80
|
+
* @public
|
|
78
81
|
*/
|
|
79
82
|
|
|
80
83
|
/**
|
|
@@ -103,7 +106,8 @@
|
|
|
103
106
|
* an AliasField could be used to expose both a string and a Date version of the
|
|
104
107
|
* same field, with both being capable of being written to.
|
|
105
108
|
*
|
|
106
|
-
* @
|
|
109
|
+
* @class <Type> ObjectAliasField
|
|
110
|
+
* @public
|
|
107
111
|
*/
|
|
108
112
|
|
|
109
113
|
/**
|
|
@@ -118,7 +122,8 @@
|
|
|
118
122
|
* 'uuid', 'urn' or 'entityUrn' or 'primaryKey' as their
|
|
119
123
|
* primary key field instead of 'id'.
|
|
120
124
|
*
|
|
121
|
-
* @
|
|
125
|
+
* @class <Type> IdentityField
|
|
126
|
+
* @public
|
|
122
127
|
*/
|
|
123
128
|
|
|
124
129
|
/**
|
|
@@ -142,7 +147,8 @@
|
|
|
142
147
|
* it should be placed in the `ResourceSchema`'s `@id` field
|
|
143
148
|
* in place of an `IdentityField`.
|
|
144
149
|
*
|
|
145
|
-
* @
|
|
150
|
+
* @class <Type> HashField
|
|
151
|
+
* @public
|
|
146
152
|
*/
|
|
147
153
|
|
|
148
154
|
/**
|
|
@@ -161,8 +167,8 @@
|
|
|
161
167
|
* For this reason Local fields should be used sparingly.
|
|
162
168
|
*
|
|
163
169
|
* Currently, while we document this feature here,
|
|
164
|
-
* only allow our own SchemaRecord
|
|
165
|
-
* and the feature should be considered private.
|
|
170
|
+
* only allow our own SchemaRecord default fields to
|
|
171
|
+
* utilize them and the feature should be considered private.
|
|
166
172
|
*
|
|
167
173
|
* Example use cases that drove the creation of local
|
|
168
174
|
* fields are states like `isDestroying` and `isDestroyed`
|
|
@@ -172,7 +178,8 @@
|
|
|
172
178
|
*
|
|
173
179
|
* Don't make us regret this decision.
|
|
174
180
|
*
|
|
175
|
-
* @
|
|
181
|
+
* @class <Type> LocalField
|
|
182
|
+
* @public
|
|
176
183
|
*/
|
|
177
184
|
|
|
178
185
|
/**
|
|
@@ -184,7 +191,8 @@
|
|
|
184
191
|
* if the key/value pairs have well-defined shape,
|
|
185
192
|
* use 'schema-object' instead.
|
|
186
193
|
*
|
|
187
|
-
* @
|
|
194
|
+
* @class <Type> ObjectField
|
|
195
|
+
* @public
|
|
188
196
|
*/
|
|
189
197
|
|
|
190
198
|
/**
|
|
@@ -195,7 +203,8 @@
|
|
|
195
203
|
* If the object's structure is not well-defined,
|
|
196
204
|
* use 'object' instead.
|
|
197
205
|
*
|
|
198
|
-
* @
|
|
206
|
+
* @class <Type> SchemaObjectField
|
|
207
|
+
* @public
|
|
199
208
|
*/
|
|
200
209
|
|
|
201
210
|
/**
|
|
@@ -205,7 +214,8 @@
|
|
|
205
214
|
* If the array's elements are not primitive
|
|
206
215
|
* values, use 'schema-array' instead.
|
|
207
216
|
*
|
|
208
|
-
* @
|
|
217
|
+
* @class <Type> ArrayField
|
|
218
|
+
* @public
|
|
209
219
|
*/
|
|
210
220
|
|
|
211
221
|
/**
|
|
@@ -216,7 +226,8 @@
|
|
|
216
226
|
* If the array's elements are not well-defined,
|
|
217
227
|
* use 'array' instead.
|
|
218
228
|
*
|
|
219
|
-
* @
|
|
229
|
+
* @class <Type> SchemaArrayField
|
|
230
|
+
* @public
|
|
220
231
|
*/
|
|
221
232
|
|
|
222
233
|
/**
|
|
@@ -233,7 +244,8 @@
|
|
|
233
244
|
* or that require access to related resources
|
|
234
245
|
* that may not be loaded should be avoided.
|
|
235
246
|
*
|
|
236
|
-
* @
|
|
247
|
+
* @class <Type> DerivedField
|
|
248
|
+
* @public
|
|
237
249
|
*/
|
|
238
250
|
|
|
239
251
|
/**
|
|
@@ -243,7 +255,8 @@
|
|
|
243
255
|
* SUPPORT FOR THIS FEATURE IS NOT YET IMPLEMENTED
|
|
244
256
|
* BY SchemaRecord
|
|
245
257
|
*
|
|
246
|
-
* @
|
|
258
|
+
* @class <Type> ResourceField
|
|
259
|
+
* @public
|
|
247
260
|
*/
|
|
248
261
|
|
|
249
262
|
/**
|
|
@@ -254,7 +267,8 @@
|
|
|
254
267
|
* SUPPORT FOR THIS FEATURE IS NOT YET IMPLEMENTED
|
|
255
268
|
* BY SchemaRecord
|
|
256
269
|
*
|
|
257
|
-
* @
|
|
270
|
+
* @class <Type> CollectionField
|
|
271
|
+
* @public
|
|
258
272
|
*/
|
|
259
273
|
|
|
260
274
|
/**
|
|
@@ -272,7 +286,8 @@
|
|
|
272
286
|
* that a serializer *might* use, but their usage
|
|
273
287
|
* is not guaranteed.
|
|
274
288
|
*
|
|
275
|
-
* @
|
|
289
|
+
* @class <Type> LegacyAttributeField
|
|
290
|
+
* @public
|
|
276
291
|
*/
|
|
277
292
|
|
|
278
293
|
/**
|
|
@@ -284,7 +299,8 @@
|
|
|
284
299
|
*
|
|
285
300
|
* This is the legacy version of the `ResourceField`.
|
|
286
301
|
*
|
|
287
|
-
* @
|
|
302
|
+
* @class <Type> LegacyBelongsToField
|
|
303
|
+
* @public
|
|
288
304
|
*/
|
|
289
305
|
|
|
290
306
|
/**
|
|
@@ -296,7 +312,8 @@
|
|
|
296
312
|
*
|
|
297
313
|
* This is the legacy version of the `ResourceField`.
|
|
298
314
|
*
|
|
299
|
-
* @
|
|
315
|
+
* @class <Type> LinksModeBelongsToField
|
|
316
|
+
* @public
|
|
300
317
|
*/
|
|
301
318
|
|
|
302
319
|
/**
|
|
@@ -308,7 +325,8 @@
|
|
|
308
325
|
*
|
|
309
326
|
* This is the legacy version of the `CollectionField`.
|
|
310
327
|
*
|
|
311
|
-
* @
|
|
328
|
+
* @class <Type> LegacyHasManyField
|
|
329
|
+
* @public
|
|
312
330
|
*/
|
|
313
331
|
|
|
314
332
|
/**
|
|
@@ -320,19 +338,53 @@
|
|
|
320
338
|
*
|
|
321
339
|
* This is the legacy version of the `CollectionField`.
|
|
322
340
|
*
|
|
323
|
-
* @
|
|
341
|
+
* @class <Type> LinksModeHasManyField
|
|
342
|
+
* @public
|
|
324
343
|
*/
|
|
325
344
|
|
|
326
345
|
/**
|
|
327
346
|
* A union of all possible LegacyMode field schemas.
|
|
328
347
|
*
|
|
329
|
-
*
|
|
348
|
+
* Available field schemas are:
|
|
349
|
+
*
|
|
350
|
+
* - [GenericField](../classes/<Type>%20GenericField)
|
|
351
|
+
* - [LegacyAliasField](../classes/<Type>%20LegacyAliasField)
|
|
352
|
+
* - [LocalField](../classes/<Type>%20LocalField)
|
|
353
|
+
* - [ObjectField](../classes/<Type>%20ObjectField)
|
|
354
|
+
* - [SchemaObjectField](../classes/<Type>%20SchemaObjectField)
|
|
355
|
+
* - [ArrayField](../classes/<Type>%20ArrayField)
|
|
356
|
+
* - [SchemaArrayField](../classes/<Type>%20SchemaArrayField)
|
|
357
|
+
* - [DerivedField](../classes/<Type>%20DerivedField)
|
|
358
|
+
* - [ResourceField (not yet implemented)](../classes/<Type>%20ResourceField)
|
|
359
|
+
* - [CollectionField (not yet implemented)](../classes/<Type>%20CollectionField)
|
|
360
|
+
* - [LegacyAttributeField](../classes/<Type>%20LegacyAttributeField)
|
|
361
|
+
* - [LegacyBelongsToField](../classes/<Type>%20LegacyBelongsToField)
|
|
362
|
+
* - [LegacyHasManyField](../classes/<Type>%20LegacyHasManyField)
|
|
363
|
+
*
|
|
364
|
+
* @class <Type> LegacyModeFieldSchema
|
|
365
|
+
* @public
|
|
330
366
|
*/
|
|
331
367
|
|
|
332
368
|
/**
|
|
333
369
|
* A union of all possible PolarisMode field schemas.
|
|
334
370
|
*
|
|
335
|
-
*
|
|
371
|
+
* Available field schemas are:
|
|
372
|
+
*
|
|
373
|
+
* - [GenericField](../classes/<Type>%20GenericField)
|
|
374
|
+
* - [PolarisAliasField](../classes/<Type>%20PolarisAliasField)
|
|
375
|
+
* - [LocalField](../classes/<Type>%20LocalField)
|
|
376
|
+
* - [ObjectField](../classes/<Type>%20ObjectField)
|
|
377
|
+
* - [SchemaObjectField](../classes/<Type>%20SchemaObjectField)
|
|
378
|
+
* - [ArrayField](../classes/<Type>%20ArrayField)
|
|
379
|
+
* - [SchemaArrayField](../classes/<Type>%20SchemaArrayField)
|
|
380
|
+
* - [DerivedField](../classes/<Type>%20DerivedField)
|
|
381
|
+
* - [ResourceField (not yet implemented)](../classes/<Type>%20ResourceField)
|
|
382
|
+
* - [CollectionField (not yet implemented)](../classes/<Type>%20CollectionField)
|
|
383
|
+
* - [LinksModeBelongsToField](../classes/<Type>%20LinksModeBelongsToField)
|
|
384
|
+
* - [LinksModeHasManyField](../classes/<Type>%20LinksModeHasManyField)
|
|
385
|
+
*
|
|
386
|
+
* @class <Type> PolarisModeFieldSchema
|
|
387
|
+
* @public
|
|
336
388
|
*/
|
|
337
389
|
|
|
338
390
|
/**
|
|
@@ -344,14 +396,16 @@
|
|
|
344
396
|
* as appropriate as they are more specific and will
|
|
345
397
|
* provide better guidance around what is valid.
|
|
346
398
|
*
|
|
347
|
-
* @
|
|
399
|
+
* @class <Type> FieldSchema
|
|
400
|
+
* @public
|
|
348
401
|
*/
|
|
349
402
|
|
|
350
403
|
/**
|
|
351
404
|
* A union of all possible field schemas that can be
|
|
352
405
|
* used in an ObjectSchema.
|
|
353
406
|
*
|
|
354
|
-
* @
|
|
407
|
+
* @class <Type> ObjectFieldSchema
|
|
408
|
+
* @public
|
|
355
409
|
*/
|
|
356
410
|
|
|
357
411
|
/**
|
|
@@ -361,7 +415,8 @@
|
|
|
361
415
|
* own which may allow them to appear in relationships, or in multiple
|
|
362
416
|
* response documents.
|
|
363
417
|
*
|
|
364
|
-
* @
|
|
418
|
+
* @class <Type> PolarisResourceSchema
|
|
419
|
+
* @public
|
|
365
420
|
*/
|
|
366
421
|
|
|
367
422
|
/**
|
|
@@ -371,7 +426,8 @@
|
|
|
371
426
|
* own which may allow them to appear in relationships, or in multiple
|
|
372
427
|
* response documents.
|
|
373
428
|
*
|
|
374
|
-
* @
|
|
429
|
+
* @class <Type> LegacyResourceSchema
|
|
430
|
+
* @public
|
|
375
431
|
*/
|
|
376
432
|
|
|
377
433
|
/**
|
|
@@ -392,7 +448,8 @@
|
|
|
392
448
|
*
|
|
393
449
|
* ObjectSchemas may not currently contain relationships.
|
|
394
450
|
*
|
|
395
|
-
* @
|
|
451
|
+
* @class <Type> ObjectSchema
|
|
452
|
+
* @public
|
|
396
453
|
*/
|
|
397
454
|
|
|
398
455
|
/**
|
|
@@ -409,7 +466,7 @@
|
|
|
409
466
|
* @static
|
|
410
467
|
* @for @warp-drive/core-types
|
|
411
468
|
* @param {ResourceSchema} schema
|
|
412
|
-
* @
|
|
469
|
+
* @return {ResourceSchema} the passed in schema
|
|
413
470
|
* @public
|
|
414
471
|
*/
|
|
415
472
|
function resourceSchema(schema) {
|
|
@@ -426,7 +483,7 @@ function resourceSchema(schema) {
|
|
|
426
483
|
* @static
|
|
427
484
|
* @for @warp-drive/core-types
|
|
428
485
|
* @param {ObjectSchema} schema
|
|
429
|
-
* @
|
|
486
|
+
* @return {ObjectSchema} the passed in schema
|
|
430
487
|
* @public
|
|
431
488
|
*/
|
|
432
489
|
function objectSchema(schema) {
|
|
@@ -440,7 +497,7 @@ function objectSchema(schema) {
|
|
|
440
497
|
* @static
|
|
441
498
|
* @for @warp-drive/core-types
|
|
442
499
|
* @param schema
|
|
443
|
-
* @
|
|
500
|
+
* @return {boolean}
|
|
444
501
|
* @public
|
|
445
502
|
*/
|
|
446
503
|
function isResourceSchema(schema) {
|
|
@@ -454,7 +511,7 @@ function isResourceSchema(schema) {
|
|
|
454
511
|
* @static
|
|
455
512
|
* @for @warp-drive/core-types
|
|
456
513
|
* @param schema
|
|
457
|
-
* @
|
|
514
|
+
* @return {boolean}
|
|
458
515
|
* @public
|
|
459
516
|
*/
|
|
460
517
|
function isLegacyResourceSchema(schema) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fields.js","sources":["../../src/schema/fields.ts"],"sourcesContent":["/**\n * @module @warp-drive/core-types\n */\nimport type { ObjectValue, PrimitiveValue } from '../json/raw';\n\n/**\n * A generic \"field\" that can be used to define\n * primitive value fields.\n *\n * Replaces \"attribute\" for primitive value fields.\n * Can also be used to eject from deep-tracking of\n * objects or arrays.\n *\n * A major difference between \"field\" and \"attribute\"\n * is that \"type\" points to a legacy transform on\n * \"attribute\" that a serializer *might* use, while\n * \"type\" points to a new-style transform on \"field\"\n * that a record implmentation *must* use.\n *\n * @typedoc\n */\nexport interface GenericField {\n kind: 'field';\n name: string;\n /**\n * the name of the transform to use, if any\n * @typedoc\n */\n type?: string;\n /**\n * Options to pass to the transform, if any\n *\n * Must comply to the specific transform's options\n * schema.\n *\n * @typedoc\n */\n options?: ObjectValue;\n}\n\n/**\n * A field that can be used to alias one key to another\n * key present in the cache version of the resource.\n *\n * Unlike DerivedField, an AliasField may write to its\n * source when a record is in an editable mode.\n *\n * AliasFields may utilize a transform, specified by type,\n * to pre/post process the field.\n *\n * An AliasField may also specify a `kind` via options.\n * `kind` may be any other valid field kind other than\n *\n * - `@hash`\n * - `@id`\n * - `@local`\n * - `derived`\n *\n * This allows an AliasField to rename any field in the cache.\n *\n * Alias fields are generally intended to be used to support migrating\n * between different schemas, though there are times where they are useful\n * as a form of advanced derivation when used with a transform. For instance,\n * an AliasField could be used to expose both a string and a Date version of the\n * same field, with both being capable of being written to.\n *\n * @typedoc\n */\nexport interface LegacyAliasField {\n kind: 'alias';\n name: string;\n type: null; // should always be null\n\n /**\n * The field def for which this is an alias.\n *\n * @typedoc\n */\n options:\n | GenericField\n | ObjectField\n | SchemaObjectField\n | ArrayField\n | SchemaArrayField\n // | ResourceField\n // | CollectionField\n | LegacyAttributeField\n | LegacyBelongsToField\n | LegacyHasManyField;\n}\n\n/**\n * A field that can be used to alias one key to another\n * key present in the cache version of the resource.\n *\n * Unlike DerivedField, an AliasField may write to its\n * source when a record is in an editable mode.\n *\n * AliasFields may utilize a transform, specified by type,\n * to pre/post process the field.\n *\n * An AliasField may also specify a `kind` via options.\n * `kind` may be any other valid field kind other than\n *\n * - `@hash`\n * - `@id`\n * - `@local`\n * - `derived`\n *\n * This allows an AliasField to rename any field in the cache.\n *\n * Alias fields are generally intended to be used to support migrating\n * between different schemas, though there are times where they are useful\n * as a form of advanced derivation when used with a transform. For instance,\n * an AliasField could be used to expose both a string and a Date version of the\n * same field, with both being capable of being written to.\n *\n * @typedoc\n */\nexport interface PolarisAliasField {\n kind: 'alias';\n name: string;\n type: null; // should always be null\n\n /**\n * The field def for which this is an alias.\n *\n * @typedoc\n */\n options:\n | GenericField\n | ObjectField\n | SchemaObjectField\n | ArrayField\n | SchemaArrayField\n // | ResourceField\n // | CollectionField\n | LinksModeBelongsToField\n | LinksModeHasManyField;\n}\n\n/**\n * A field that can be used to alias one key to another\n * key present in the cache version of the resource.\n *\n * Unlike DerivedField, an AliasField may write to its\n * source when a record is in an editable mode.\n *\n * AliasFields may utilize a transform, specified by type,\n * to pre/post process the field.\n *\n * An AliasField may also specify a `kind` via options.\n * `kind` may be any other valid field kind other than\n *\n * - `@hash`\n * - `@id`\n * - `@local`\n * - `derived`\n *\n * This allows an AliasField to rename any field in the cache.\n *\n * Alias fields are generally intended to be used to support migrating\n * between different schemas, though there are times where they are useful\n * as a form of advanced derivation when used with a transform. For instance,\n * an AliasField could be used to expose both a string and a Date version of the\n * same field, with both being capable of being written to.\n *\n * @typedoc\n */\nexport interface ObjectAliasField {\n kind: 'alias';\n name: string;\n type: null; // should always be null\n\n /**\n * The field def for which this is an alias.\n *\n * @typedoc\n */\n options: GenericField | ObjectField | SchemaObjectField | ArrayField | SchemaArrayField;\n}\n\n/**\n * Represents a field whose value is the primary\n * key of the resource.\n *\n * This allows any field to serve as the primary\n * key while still being able to drive identity\n * needs within the system.\n *\n * This is useful for resources that use for instance\n * 'uuid', 'urn' or 'entityUrn' or 'primaryKey' as their\n * primary key field instead of 'id'.\n *\n * @typedoc\n */\nexport interface IdentityField {\n kind: '@id';\n\n /**\n * The name of the field that serves as the\n * primary key for the resource.\n *\n * @typedoc\n */\n name: string;\n}\n\n/**\n * Represents a specialized field whose computed value\n * will be used as the primary key of a schema-object\n * for serializability and comparison purposes.\n *\n * This field functions similarly to derived fields in that\n * it is non-settable, derived state but differs in that\n * it is only able to compute off of cache state and is given\n * no access to a record instance.\n *\n * This means that if a hashing function wants to compute its value\n * taking into account transformations and derivations it must\n * perform those itself.\n *\n * A schema-array can declare its \"key\" value to be `@hash` if\n * a schema-object has such a field.\n *\n * Only one hash field is permittable per schema-object, and\n * it should be placed in the `ResourceSchema`'s `@id` field\n * in place of an `IdentityField`.\n *\n * @typedoc\n */\nexport interface HashField {\n kind: '@hash';\n\n /**\n * The name of the field that serves as the\n * hash for the resource.\n *\n * Only required if access to this value by\n * the UI is desired, it can be `null` otherwise.\n *\n * @typedoc\n */\n name: string | null;\n\n /**\n * The name of a function to run to compute the hash.\n * The function will only have access to the cached\n * data for the record.\n *\n * @typedoc\n */\n type: string;\n\n /**\n * Any options that should be provided to the hash\n * function.\n *\n * @typedoc\n */\n options?: ObjectValue;\n}\n\n/**\n * Represents a field whose value is a local\n * value that is not stored in the cache, nor\n * is it sent to the server.\n *\n * Local fields can be written to, and their\n * value is both memoized and reactive (though\n * not deep-tracked).\n *\n * Because their state is not derived from the cache\n * data or the server, they represent a divorced\n * uncanonical source of state.\n *\n * For this reason Local fields should be used sparingly.\n *\n * Currently, while we document this feature here,\n * only allow our own SchemaRecord should utilize them\n * and the feature should be considered private.\n *\n * Example use cases that drove the creation of local\n * fields are states like `isDestroying` and `isDestroyed`\n * which are specific to a record instance but not\n * stored in the cache. We wanted to be able to drive\n * these fields from schema the same as all other fields.\n *\n * Don't make us regret this decision.\n *\n * @typedoc\n */\nexport interface LocalField {\n kind: '@local';\n name: string;\n /**\n * Not currently utilized, we are considering\n * allowing transforms to operate on local fields\n *\n * @typedoc\n */\n type?: string;\n options?: { defaultValue?: PrimitiveValue };\n}\n\n/**\n * Represents a field whose value is an object\n * with keys pointing to values that are primitive\n * values.\n *\n * If values of the keys are not primitives, or\n * if the key/value pairs have well-defined shape,\n * use 'schema-object' instead.\n *\n * @typedoc\n */\nexport interface ObjectField {\n kind: 'object';\n name: string;\n\n /**\n * The name of a transform to pass the entire object\n * through before displaying or serializing it.\n *\n * @typedoc\n */\n type?: string;\n\n /**\n * Options to pass to the transform, if any\n *\n * Must comply to the specific transform's options\n * schema.\n *\n * @typedoc\n */\n options?: ObjectValue;\n}\n\n/**\n * Represents a field whose value is an object\n * with a well-defined structure described by\n * a non-resource schema.\n *\n * If the object's structure is not well-defined,\n * use 'object' instead.\n *\n * @typedoc\n */\nexport interface SchemaObjectField {\n kind: 'schema-object';\n name: string;\n\n /**\n * The name of the schema that describes the\n * structure of the object.\n *\n * These schemas\n *\n * @typedoc\n */\n type: string;\n\n options?: {\n /**\n * Whether this SchemaObject is Polymorphic.\n *\n * If the SchemaObject is polymorphic, `options.type` must also be supplied.\n *\n * @typedoc\n */\n polymorphic?: boolean;\n\n /**\n * If the SchemaObject is Polymorphic, the key on the raw cache data to use\n * as the \"resource-type\" value for the schema-object.\n *\n * Defaults to \"type\".\n *\n * @typedoc\n */\n type?: string;\n };\n}\n\n/**\n * Represents a field whose value is an array\n * of primitive values.\n *\n * If the array's elements are not primitive\n * values, use 'schema-array' instead.\n *\n * @typedoc\n */\nexport interface ArrayField {\n kind: 'array';\n name: string;\n\n /**\n * The name of a transform to pass each item\n * in the array through before displaying or\n * or serializing it.\n *\n * @typedoc\n */\n type?: string;\n\n /**\n * Options to pass to the transform, if any\n *\n * Must comply to the specific transform's options\n * schema.\n *\n * @typedoc\n */\n options?: ObjectValue;\n}\n\n/**\n * Represents a field whose value is an array\n * of objects with a well-defined structure\n * described by a non-resource schema.\n *\n * If the array's elements are not well-defined,\n * use 'array' instead.\n *\n * @typedoc\n */\nexport interface SchemaArrayField {\n kind: 'schema-array';\n name: string;\n\n /**\n * The name of the schema that describes the\n * structure of the objects in the array.\n *\n * @typedoc\n */\n type: string;\n\n /**\n * Options for configuring the behavior of the\n * SchemaArray.\n *\n * @typedoc\n */\n\n /**\n * Options for configuring the behavior of the\n * SchemaArray.\n *\n * @typedoc\n */\n options?: {\n /**\n * Configures how the SchemaArray determines whether\n * an object in the cache is the same as an object\n * previously used to instantiate one of the schema-objects\n * it contains.\n *\n * The default is `'@identity'`.\n *\n * Valid options are:\n *\n * - `'@identity'` (default) : the cached object's referential identity will be used.\n * This may result in significant instability when resource data is updated from the API\n * - `'@index'` : the cached object's index in the array will be used.\n * This is only a good choice for arrays that rarely if ever change membership\n * - `'@hash'` : will lookup the `@hash` function supplied in the ResourceSchema for\n * The contained schema-object and use the computed result to determine and compare identity.\n * - <field-name> (string) : the name of a field to use as the key, only GenericFields (kind `field`)\n * Are valid field names for this purpose. The cache state without transforms applied will be\n * used when comparing values. The field value should be unique enough to guarantee two schema-objects\n * of the same type will not collide.\n *\n * @typedoc\n */\n key?: '@identity' | '@index' | '@hash' | string;\n\n /**\n * Whether this SchemaArray is Polymorphic.\n *\n * If the SchemaArray is polymorphic, `options.type` must also be supplied.\n *\n * @typedoc\n */\n polymorphic?: boolean;\n\n /**\n * If the SchemaArray is Polymorphic, the key on the raw cache data to use\n * as the \"resource-type\" value for the schema-object.\n *\n * Defaults to \"type\".\n *\n * @typedoc\n */\n type?: string;\n };\n}\n\n/**\n * Represents a field whose value is derived\n * from other fields in the schema.\n *\n * The value is read-only, and is not stored\n * in the cache, nor is it sent to the server.\n *\n * Usage of derived fields should be minimized\n * to scenarios where the derivation is known\n * to be safe. For instance, derivations that\n * required fields that are not always loaded\n * or that require access to related resources\n * that may not be loaded should be avoided.\n *\n * @typedoc\n */\nexport interface DerivedField {\n kind: 'derived';\n name: string;\n\n /**\n * The name of the derivation to use.\n *\n * Derivations are functions that take the\n * record, options, and the name of the field\n * as arguments, and return the derived value.\n *\n * Derivations are memoized, and are only\n * recomputed when the fields they depend on\n * change.\n *\n * Derivations are not stored in the cache,\n * and are not sent to the server.\n *\n * Derivation functions must be explicitly\n * registered with the schema service.\n *\n * @typedoc\n */\n type: string;\n\n /**\n * Options to pass to the derivation, if any\n *\n * Must comply to the specific derivation's\n * options schema.\n *\n * @typedoc\n */\n options?: ObjectValue;\n}\n\n/**\n * Represents a field that is a reference to\n * another resource.\n *\n * SUPPORT FOR THIS FEATURE IS NOT YET IMPLEMENTED\n * BY SchemaRecord\n *\n * @typedoc\n */\nexport interface ResourceField {\n kind: 'resource';\n name: string;\n\n /**\n * The name of the resource that this field\n * refers to. In the case of a polymorphic\n * relationship, this should be the trait\n * or abstract type.\n *\n * @typedoc\n */\n type: string;\n\n /**\n * Options for resources are optional. If\n * not present, all options are presumed\n * to be falsey\n *\n * @typedoc\n */\n options?: {\n /**\n * Whether the relationship is async\n *\n * If true, it is expected that the cache\n * data for this field will contain a link\n * that can be used to fetch the related\n * resource when needed.\n *\n * @typedoc\n */\n async?: boolean;\n\n /**\n * The name of the inverse field on the\n * related resource that points back to\n * this field on this resource to form a\n * bidirectional relationship.\n *\n * If null, the relationship is unidirectional.\n *\n * @typedoc\n */\n inverse?: string | null;\n\n /**\n * If this field is satisfying a polymorphic\n * relationship on another resource, then this\n * should be set to the trait or abstract type\n * that this resource implements.\n *\n * @typedoc\n */\n as?: string;\n\n /**\n * Whether this field is a polymorphic relationship,\n * meaning that it can point to multiple types of\n * resources so long as they implement the trait\n * or abstract type specified in `type`.\n *\n * @typedoc\n */\n polymorphic?: boolean;\n };\n}\n\n/**\n * Represents a field that is a reference to\n * a collection of other resources, potentially\n * paginate.\n *\n * SUPPORT FOR THIS FEATURE IS NOT YET IMPLEMENTED\n * BY SchemaRecord\n *\n * @typedoc\n */\nexport interface CollectionField {\n kind: 'collection';\n name: string;\n\n /**\n * The name of the resource that this field\n * refers to. In the case of a polymorphic\n * relationship, this should be the trait\n * or abstract type.\n *\n * @typedoc\n */\n type: string;\n\n /**\n * Options for resources are optional. If\n * not present, all options are presumed\n * to be falsey\n *\n * @typedoc\n */\n options?: {\n /**\n * Whether the relationship is async\n *\n * If true, it is expected that the cache\n * data for this field will contain links\n * that can be used to fetch the related\n * resources when needed.\n *\n * When false, it is expected that all related\n * resources are loaded together with this resource,\n * and that the cache data for this field will\n * contain the full list of pointers.\n *\n * When true, it is expected that the relationship\n * is paginated. If the relationship is not paginated,\n * then the cache data for \"page 1\" would contain the\n * full list of pointers, and loading \"page 1\" would\n * load all related resources.\n *\n * @typedoc\n */\n async?: boolean;\n\n /**\n * The name of the inverse field on the\n * related resource that points back to\n * this field on this resource to form a\n * bidirectional relationship.\n *\n * If null, the relationship is unidirectional.\n *\n * @typedoc\n */\n inverse?: string | null;\n\n /**\n * If this field is satisfying a polymorphic\n * relationship on another resource, then this\n * should be set to the trait or abstract type\n * that this resource implements.\n *\n * @typedoc\n */\n as?: string;\n\n /**\n * Whether this field is a polymorphic relationship,\n * meaning that it can point to multiple types of\n * resources so long as they implement the trait\n * or abstract type specified in `type`.\n *\n * @typedoc\n */\n polymorphic?: boolean;\n };\n}\n\n/**\n * > [!CAUTION]\n * > This Field is LEGACY\n * > It cannot be used with PolarisMode\n *\n * A generic \"field\" that can be used to define\n * primitive value fields.\n *\n * If the field points to an object or array,\n * it will not be deep-tracked.\n *\n * Transforms when defined are legacy transforms\n * that a serializer *might* use, but their usage\n * is not guaranteed.\n *\n * @typedoc\n */\nexport interface LegacyAttributeField {\n kind: 'attribute';\n name: string;\n /**\n * The name of the transform to use, if any\n *\n * @typedoc\n */\n type?: string | null;\n /**\n * Options to pass to the transform, if any\n *\n * Must comply to the specific transform's options\n * schema.\n *\n * @typedoc\n */\n options?: ObjectValue;\n}\n\n/**\n * > [!CAUTION]\n * > This Field is LEGACY\n *\n * Represents a field that is a reference to\n * another resource.\n *\n * This is the legacy version of the `ResourceField`.\n *\n * @typedoc\n */\nexport interface LegacyBelongsToField {\n kind: 'belongsTo';\n name: string;\n\n /**\n * The name of the resource that this field\n * refers to. In the case of a polymorphic\n * relationship, this should be the trait\n * or abstract type.\n *\n * @typedoc\n */\n type: string;\n\n /**\n * Options for belongsTo are mandatory.\n *\n * @typedoc\n */\n options: {\n /**\n * Whether the relationship is async\n *\n * If true, it is expected that the cache\n * data for this field will contain a link\n * or a pointer that can be used to fetch\n * the related resource when needed.\n *\n * Pointers are highly discouraged.\n *\n * @typedoc\n */\n async: boolean;\n\n /**\n * The name of the inverse field on the\n * related resource that points back to\n * this field on this resource to form a\n * bidirectional relationship.\n *\n * If null, the relationship is unidirectional.\n *\n * @typedoc\n */\n inverse: string | null;\n\n /**\n * If this field is satisfying a polymorphic\n * relationship on another resource, then this\n * should be set to the trait or abstract type\n * that this resource implements.\n *\n * @typedoc\n */\n as?: string;\n\n /**\n * Whether this field is a polymorphic relationship,\n * meaning that it can point to multiple types of\n * resources so long as they implement the trait\n * or abstract type specified in `type`.\n *\n * @typedoc\n */\n polymorphic?: boolean;\n\n /**\n * Whether this field should ever make use of the legacy support infra\n * from @ember-data/model and the LegacyNetworkMiddleware for adapters and serializers.\n *\n * When true, none of the legacy support will be utilized. Sync relationships\n * will be expected to already have all their data. When reloading a sync relationship\n * you would be expected to have a `related link` available from a prior relationship\n * payload e.g.\n *\n * ```ts\n * {\n * data: {\n * type: 'user',\n * id: '2',\n * attributes: { name: 'Chris' },\n * relationships: {\n * bestFriend: {\n * links: { related: \"/users/1/bestFriend\" },\n * data: { type: 'user', id: '1' },\n * }\n * }\n * },\n * included: [\n * { type: 'user', id: '1', attributes: { name: 'Krystan' } }\n * ]\n * }\n * ```\n *\n * Async relationships will be loaded via their link if needed.\n *\n * @typedoc\n */\n linksMode?: true;\n\n /**\n * When omitted, the cache data for this field will\n * clear local state of all changes except for the\n * addition of records still in the \"new\" state any\n * time the remote data for this field is updated.\n *\n * When set to `false`, the cache data for this field\n * will instead intelligently commit any changes from\n * local state that are present in the remote data,\n * leaving any remaining changes in local state still.\n *\n * @typedoc\n */\n resetOnRemoteUpdate?: false;\n };\n}\n\n/**\n * > [!CAUTION]\n * > This Field is LEGACY\n *\n * Represents a field that is a reference to\n * another resource.\n *\n * This is the legacy version of the `ResourceField`.\n *\n * @typedoc\n */\nexport interface LinksModeBelongsToField {\n kind: 'belongsTo';\n name: string;\n\n /**\n * The name of the resource that this field\n * refers to. In the case of a polymorphic\n * relationship, this should be the trait\n * or abstract type.\n *\n * @typedoc\n */\n type: string;\n\n /**\n * Options for belongsTo are mandatory.\n *\n * @typedoc\n */\n options: {\n /**\n * Whether the relationship is async\n *\n * MUST be false for PolarisMode + LinksMode\n *\n * @typedoc\n */\n async: false;\n\n /**\n * The name of the inverse field on the\n * related resource that points back to\n * this field on this resource to form a\n * bidirectional relationship.\n *\n * If null, the relationship is unidirectional.\n *\n * @typedoc\n */\n inverse: string | null;\n\n /**\n * If this field is satisfying a polymorphic\n * relationship on another resource, then this\n * should be set to the trait or abstract type\n * that this resource implements.\n *\n * @typedoc\n */\n as?: string;\n\n /**\n * Whether this field is a polymorphic relationship,\n * meaning that it can point to multiple types of\n * resources so long as they implement the trait\n * or abstract type specified in `type`.\n *\n * @typedoc\n */\n polymorphic?: boolean;\n\n /**\n * Whether this field should ever make use of the legacy support infra\n * from @ember-data/model and the LegacyNetworkMiddleware for adapters and serializers.\n *\n * MUST be true for PolarisMode + LinksMode\n *\n * When true, none of the legacy support will be utilized. Sync relationships\n * will be expected to already have all their data. When reloading a sync relationship\n * you would be expected to have a `related link` available from a prior relationship\n * payload e.g.\n *\n * ```ts\n * {\n * data: {\n * type: 'user',\n * id: '2',\n * attributes: { name: 'Chris' },\n * relationships: {\n * bestFriend: {\n * links: { related: \"/users/1/bestFriend\" },\n * data: { type: 'user', id: '1' },\n * }\n * }\n * },\n * included: [\n * { type: 'user', id: '1', attributes: { name: 'Krystan' } }\n * ]\n * }\n * ```\n *\n * Async relationships will be loaded via their link if needed.\n *\n * @typedoc\n */\n linksMode: true;\n\n /**\n * When omitted, the cache data for this field will\n * clear local state of all changes except for the\n * addition of records still in the \"new\" state any\n * time the remote data for this field is updated.\n *\n * When set to `false`, the cache data for this field\n * will instead intelligently commit any changes from\n * local state that are present in the remote data,\n * leaving any remaining changes in local state still.\n *\n * MUST be false for PolarisMode + LinksMode\n *\n * @typedoc\n */\n resetOnRemoteUpdate: false;\n };\n}\n\n/**\n * > [!CAUTION]\n * > This Field is LEGACY\n *\n * Represents a field that is a reference to\n * a collection of other resources.\n *\n * This is the legacy version of the `CollectionField`.\n *\n * @typedoc\n */\nexport interface LegacyHasManyField {\n kind: 'hasMany';\n name: string;\n type: string;\n\n /**\n * Options for hasMany are mandatory.\n *\n * @typedoc\n */\n options: {\n /**\n * Whether the relationship is async\n *\n * If true, it is expected that the cache\n * data for this field will contain links\n * or pointers that can be used to fetch\n * the related resources when needed.\n *\n * When false, it is expected that all related\n * resources are loaded together with this resource,\n * and that the cache data for this field will\n * contain the full list of pointers.\n *\n * hasMany relationships do not support pagination.\n *\n * @typedoc\n */\n async: boolean;\n\n /**\n * The name of the inverse field on the\n * related resource that points back to\n * this field on this resource to form a\n * bidirectional relationship.\n *\n * If null, the relationship is unidirectional.\n *\n * @typedoc\n */\n inverse: string | null;\n\n /**\n * If this field is satisfying a polymorphic\n * relationship on another resource, then this\n * should be set to the trait or abstract type\n * that this resource implements.\n *\n * @typedoc\n */\n as?: string;\n\n /**\n * Whether this field is a polymorphic relationship,\n * meaning that it can point to multiple types of\n * resources so long as they implement the trait\n * or abstract type specified in `type`.\n *\n * @typedoc\n */\n polymorphic?: boolean;\n\n /**\n * Whether this field should ever make use of the legacy support infra\n * from @ember-data/model and the LegacyNetworkMiddleware for adapters and serializers.\n *\n * When true, none of the legacy support will be utilized. Sync relationships\n * will be expected to already have all their data. When reloading a sync relationship\n * you would be expected to have a `related link` available from a prior relationship\n * payload e.g.\n *\n * ```ts\n * {\n * data: {\n * type: 'user',\n * id: '2',\n * attributes: { name: 'Chris' },\n * relationships: {\n * bestFriends: {\n * links: { related: \"/users/1/bestFriends\" },\n * data: [ { type: 'user', id: '1' } ],\n * }\n * }\n * },\n * included: [\n * { type: 'user', id: '1', attributes: { name: 'Krystan' } }\n * ]\n * }\n * ```\n *\n * Async relationships will be loaded via their link if needed.\n *\n * @typedoc\n */\n linksMode?: true;\n\n /**\n * When omitted, the cache data for this field will\n * clear local state of all changes except for the\n * addition of records still in the \"new\" state any\n * time the remote data for this field is updated.\n *\n * When set to `false`, the cache data for this field\n * will instead intelligently commit any changes from\n * local state that are present in the remote data,\n * leaving any remaining changes in local state still.\n *\n * @typedoc\n */\n resetOnRemoteUpdate?: false;\n };\n}\n\n/**\n * > [!CAUTION]\n * > This Field is LEGACY\n *\n * Represents a field that is a reference to\n * a collection of other resources.\n *\n * This is the legacy version of the `CollectionField`.\n *\n * @typedoc\n */\nexport interface LinksModeHasManyField {\n kind: 'hasMany';\n name: string;\n type: string;\n\n /**\n * Options for hasMany are mandatory.\n *\n * @typedoc\n */\n options: {\n /**\n * Whether the relationship is async\n *\n * MUST be false for PolarisMode + LinksMode\n *\n * If true, it is expected that the cache\n * data for this field will contain links\n * or pointers that can be used to fetch\n * the related resources when needed.\n *\n * When false, it is expected that all related\n * resources are loaded together with this resource,\n * and that the cache data for this field will\n * contain the full list of pointers.\n *\n * hasMany relationships do not support pagination.\n *\n * @typedoc\n */\n async: false;\n\n /**\n * The name of the inverse field on the\n * related resource that points back to\n * this field on this resource to form a\n * bidirectional relationship.\n *\n * If null, the relationship is unidirectional.\n *\n * @typedoc\n */\n inverse: string | null;\n\n /**\n * If this field is satisfying a polymorphic\n * relationship on another resource, then this\n * should be set to the trait or abstract type\n * that this resource implements.\n *\n * @typedoc\n */\n as?: string;\n\n /**\n * Whether this field is a polymorphic relationship,\n * meaning that it can point to multiple types of\n * resources so long as they implement the trait\n * or abstract type specified in `type`.\n *\n * @typedoc\n */\n polymorphic?: boolean;\n\n /**\n * Whether this field should ever make use of the legacy support infra\n * from @ember-data/model and the LegacyNetworkMiddleware for adapters and serializers.\n *\n * MUST be true for PolarisMode + LinksMode\n *\n * When true, none of the legacy support will be utilized. Sync relationships\n * will be expected to already have all their data. When reloading a sync relationship\n * you would be expected to have a `related link` available from a prior relationship\n * payload e.g.\n *\n * ```ts\n * {\n * data: {\n * type: 'user',\n * id: '2',\n * attributes: { name: 'Chris' },\n * relationships: {\n * bestFriends: {\n * links: { related: \"/users/1/bestFriends\" },\n * data: [ { type: 'user', id: '1' } ],\n * }\n * }\n * },\n * included: [\n * { type: 'user', id: '1', attributes: { name: 'Krystan' } }\n * ]\n * }\n * ```\n *\n * Async relationships will be loaded via their link if needed.\n *\n * @typedoc\n */\n linksMode: true;\n\n /**\n * When omitted, the cache data for this field will\n * clear local state of all changes except for the\n * addition of records still in the \"new\" state any\n * time the remote data for this field is updated.\n *\n * When set to `false`, the cache data for this field\n * will instead intelligently commit any changes from\n * local state that are present in the remote data,\n * leaving any remaining changes in local state still.\n *\n * MUST be false for PolarisMode + LinksMode\n *\n * @typedoc\n */\n resetOnRemoteUpdate: false;\n };\n}\n\n/**\n * A union of all possible LegacyMode field schemas.\n *\n * @typedoc\n */\nexport type LegacyModeFieldSchema =\n | GenericField\n | LegacyAliasField\n | LocalField\n | ObjectField\n | SchemaObjectField\n | ArrayField\n | SchemaArrayField\n | DerivedField\n // | ResourceField\n // | CollectionField\n | LegacyAttributeField\n | LegacyBelongsToField\n | LegacyHasManyField;\n\n/**\n * A union of all possible PolarisMode field schemas.\n *\n * @typedoc\n */\nexport type PolarisModeFieldSchema =\n | GenericField\n | PolarisAliasField\n | LocalField\n | ObjectField\n | SchemaObjectField\n | ArrayField\n | SchemaArrayField\n | DerivedField\n // | ResourceField\n // | CollectionField\n | LinksModeBelongsToField\n | LinksModeHasManyField;\n\n/**\n * A union of all possible LegacyMode and PolarisMode\n * field schemas.\n *\n * You likely will want to use PolarisModeFieldSchema,\n * LegacyModeFieldSchema, or ObjectFieldSchema instead\n * as appropriate as they are more specific and will\n * provide better guidance around what is valid.\n *\n * @typedoc\n */\nexport type FieldSchema =\n | GenericField\n | LegacyAliasField\n | PolarisAliasField\n | LocalField\n | ObjectField\n | SchemaObjectField\n | ArrayField\n | SchemaArrayField\n | DerivedField\n | ResourceField\n | CollectionField\n | LegacyAttributeField\n | LegacyBelongsToField\n | LegacyHasManyField\n | LinksModeBelongsToField\n | LinksModeHasManyField;\n\n/**\n * A union of all possible field schemas that can be\n * used in an ObjectSchema.\n *\n * @typedoc\n */\nexport type ObjectFieldSchema =\n | GenericField\n | ObjectAliasField\n | LocalField\n | ObjectField\n | SchemaObjectField\n | ArrayField\n | SchemaArrayField\n | DerivedField;\n\n/**\n * Represents a schema for a primary resource in PolarisMode.\n *\n * Primary resources are objects with a unique identity of their\n * own which may allow them to appear in relationships, or in multiple\n * response documents.\n *\n * @typedoc\n */\nexport interface PolarisResourceSchema {\n legacy?: false;\n\n /**\n * For primary resources, this should be an IdentityField\n *\n * for schema-objects, this should be either a HashField or null\n *\n * @typedoc\n */\n identity: IdentityField;\n\n /**\n * The name of the schema\n *\n * For cacheable resources, this should be the\n * primary resource type.\n *\n * For object schemas, this should be the name\n * of the object schema.\n *\n * The names of object and resource schemas share\n * a single namespace and must not conflict.\n *\n * We recommend a naming convention for object schemas\n * such as below for ensuring uniqueness:\n *\n * - for globally shared objects: The pattern `$field:${KlassName}` e.g. `$field:AddressObject`\n * - for resource-specific objects: The pattern `$${ResourceKlassName}:$field:${KlassName}` e.g. `$User:$field:ReusableAddress`\n * - for inline objects: The pattern `$${ResourceKlassName}.${fieldPath}:$field:anonymous` e.g. `$User.shippingAddress:$field:anonymous`\n *\n * @typedoc\n */\n type: string;\n\n /**\n * The fields that make up the shape of the resource\n *\n * @typedoc\n */\n fields: PolarisModeFieldSchema[];\n\n /**\n * A list of traits that this resource implements. The fields for these\n * traits should still be defined in the fields array.\n *\n * Each trait should be a string that matches the `type` of another\n * resource schema. The trait can be abstract and reference a resource\n * type that is never defined as a schema.\n *\n * @typedoc\n */\n traits?: string[];\n}\n\n/**\n * Represents a schema for a primary resource in LegacyMode\n *\n * Primary resources are objects with a unique identity of their\n * own which may allow them to appear in relationships, or in multiple\n * response documents.\n *\n * @typedoc\n */\nexport interface LegacyResourceSchema {\n legacy: true;\n\n /**\n * For primary resources, this should be an IdentityField\n *\n * for schema-objects, this should be either a HashField or null\n *\n * @typedoc\n */\n identity: IdentityField;\n\n /**\n * The name of the schema\n *\n * For cacheable resources, this should be the\n * primary resource type.\n *\n * For object schemas, this should be the name\n * of the object schema.\n *\n * The names of object and resource schemas share\n * a single namespace and must not conflict.\n *\n * We recommend a naming convention for object schemas\n * such as below for ensuring uniqueness:\n *\n * - for globally shared objects: The pattern `$field:${KlassName}` e.g. `$field:AddressObject`\n * - for resource-specific objects: The pattern `$${ResourceKlassName}:$field:${KlassName}` e.g. `$User:$field:ReusableAddress`\n * - for inline objects: The pattern `$${ResourceKlassName}.${fieldPath}:$field:anonymous` e.g. `$User.shippingAddress:$field:anonymous`\n *\n * @typedoc\n */\n type: string;\n\n /**\n * The fields that make up the shape of the resource\n *\n * @typedoc\n */\n fields: LegacyModeFieldSchema[];\n\n /**\n * A list of traits that this resource implements. The fields for these\n * traits should still be defined in the fields array.\n *\n * Each trait should be a string that matches the `type` of another\n * resource schema. The trait can be abstract and reference a resource\n * type that is never defined as a schema.\n *\n * @typedoc\n */\n traits?: string[];\n}\n\n/**\n * A type which represents a valid JSON schema\n * definition for either a PolarisMode or a\n * LegacyMode resource.\n *\n * Note, this is separate from the type returned\n * by the SchemaService which provides fields as a Map\n * instead of as an Array.\n *\n * @typedoc\n */\nexport type ResourceSchema = PolarisResourceSchema | LegacyResourceSchema;\n\n/**\n * Represents a schema for an object that is not\n * a primary resource (has no unique identity of its own).\n *\n * ObjectSchemas may not currently contain relationships.\n *\n * @typedoc\n */\nexport interface ObjectSchema {\n /**\n * Either a HashField from which to calculate an identity or null\n *\n * In the case of `null`, the object's identity will be based\n * on the referential identity of the object in the cache itself\n * when an identity is needed.\n *\n * @typedoc\n */\n identity: HashField | null;\n\n /**\n * The name of the schema\n *\n * The names of object and resource schemas share\n * a single namespace and must not conflict.\n *\n * We recommend a naming convention for object schemas\n * such as below for ensuring uniqueness:\n *\n * - for globally shared objects: The pattern `$field:${KlassName}` e.g. `$field:AddressObject`\n * - for resource-specific objects: The pattern `$${ResourceKlassName}:$field:${KlassName}` e.g. `$User:$field:ReusableAddress`\n * - for inline objects: The pattern `$${ResourceKlassName}.${fieldPath}:$field:anonymous` e.g. `$User.shippingAddress:$field:anonymous`\n *\n * @typedoc\n */\n type: string;\n\n /**\n * The fields that make up the shape of the object\n *\n * @typedoc\n */\n fields: ObjectFieldSchema[];\n}\n\nexport type Schema = ResourceSchema | ObjectSchema;\n\n/**\n * A no-op type utility that enables type-checking resource schema\n * definitions.\n *\n * Will return the passed in schema.\n *\n * This will not validate relationship inverses or related types,\n * as doing so would require a full schema graph to be passed in\n * and no cycles in the graph to be present.\n *\n * @method resourceSchema\n * @static\n * @for @warp-drive/core-types\n * @param {ResourceSchema} schema\n * @returns {ResourceSchema} the passed in schema\n * @public\n */\nexport function resourceSchema<T extends ResourceSchema>(schema: T): T {\n return schema;\n}\n\n/**\n * A no-op type utility that enables type-checking object schema\n * definitions.\n *\n * Will return the passed in schema.\n *\n * @method objectSchema\n * @static\n * @for @warp-drive/core-types\n * @param {ObjectSchema} schema\n * @returns {ObjectSchema} the passed in schema\n * @public\n */\nexport function objectSchema<T extends ObjectSchema>(schema: T): T {\n return schema;\n}\n\n/**\n * A type utility to narrow a schema to a ResourceSchema\n *\n * @method isResourceSchema\n * @static\n * @for @warp-drive/core-types\n * @param schema\n * @returns {boolean}\n * @public\n */\nexport function isResourceSchema(schema: ResourceSchema | ObjectSchema): schema is ResourceSchema {\n return schema?.identity?.kind === '@id';\n}\n\n/**\n * A type utility to narrow a schema to LegacyResourceSchema\n *\n * @method isLegacyResourceSchema\n * @static\n * @for @warp-drive/core-types\n * @param schema\n * @returns {boolean}\n * @public\n */\nexport function isLegacyResourceSchema(schema: ResourceSchema | ObjectSchema): schema is LegacyResourceSchema {\n return isResourceSchema(schema) && schema.legacy === true;\n}\n\nexport type LegacyField =\n | LegacyAttributeField\n | LegacyBelongsToField\n | LegacyHasManyField\n | LinksModeBelongsToField\n | LinksModeHasManyField;\nexport type LegacyRelationshipField =\n | LegacyBelongsToField\n | LegacyHasManyField\n | LinksModeBelongsToField\n | LinksModeHasManyField;\n"],"names":["resourceSchema","schema","objectSchema","isResourceSchema","identity","kind","isLegacyResourceSchema","legacy"],"mappings":"AAAA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAoBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAwBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAuBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAcA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAaA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAiCA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAcA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAwBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAqCA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAyBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAyEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAqCA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAqEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAgFA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAqBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAsHA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAqHA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAkHA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAwHA;AACA;AACA;AACA;AACA;;AAgBA;AACA;AACA;AACA;AACA;;AAeA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAmBA;AACA;AACA;AACA;AACA;AACA;;AAWA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAwDA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAwDA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAwCA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,cAAcA,CAA2BC,MAAS,EAAK;AACrE,EAAA,OAAOA,MAAM;AACf;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASC,YAAYA,CAAyBD,MAAS,EAAK;AACjE,EAAA,OAAOA,MAAM;AACf;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASE,gBAAgBA,CAACF,MAAqC,EAA4B;AAChG,EAAA,OAAOA,MAAM,EAAEG,QAAQ,EAAEC,IAAI,KAAK,KAAK;AACzC;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASC,sBAAsBA,CAACL,MAAqC,EAAkC;EAC5G,OAAOE,gBAAgB,CAACF,MAAM,CAAC,IAAIA,MAAM,CAACM,MAAM,KAAK,IAAI;AAC3D;;;;"}
|
|
1
|
+
{"version":3,"file":"fields.js","sources":["../../src/schema/fields.ts"],"sourcesContent":["/**\n * @module @warp-drive/core-types\n */\nimport type { ObjectValue, PrimitiveValue } from '../json/raw';\n\n/**\n * A generic \"field\" that can be used to define\n * primitive value fields.\n *\n * Replaces \"attribute\" for primitive value fields.\n * Can also be used to eject from deep-tracking of\n * objects or arrays.\n *\n * A major difference between \"field\" and \"attribute\"\n * is that \"type\" points to a legacy transform on\n * \"attribute\" that a serializer *might* use, while\n * \"type\" points to a new-style transform on \"field\"\n * that a record implmentation *must* use.\n *\n * @class <Type> GenericField\n * @public\n */\nexport interface GenericField {\n /**\n * The kind of field this is.\n *\n * @property {'field'} kind\n * @public\n */\n kind: 'field';\n\n /**\n * The name of the field.\n *\n * @property {string} name\n * @public\n */\n name: string;\n\n /**\n * the name of the transform to use, if any\n *\n * @property {string | undefined} type\n * @public\n */\n type?: string;\n\n /**\n * Options to pass to the transform, if any\n *\n * Must comply to the specific transform's options\n * schema.\n *\n * @property {ObjectValue | undefined} options\n * @public\n */\n options?: ObjectValue;\n}\n\n/**\n * A field that can be used to alias one key to another\n * key present in the cache version of the resource.\n *\n * Unlike DerivedField, an AliasField may write to its\n * source when a record is in an editable mode.\n *\n * AliasFields may utilize a transform, specified by type,\n * to pre/post process the field.\n *\n * An AliasField may also specify a `kind` via options.\n * `kind` may be any other valid field kind other than\n *\n * - `@hash`\n * - `@id`\n * - `@local`\n * - `derived`\n *\n * This allows an AliasField to rename any field in the cache.\n *\n * Alias fields are generally intended to be used to support migrating\n * between different schemas, though there are times where they are useful\n * as a form of advanced derivation when used with a transform. For instance,\n * an AliasField could be used to expose both a string and a Date version of the\n * same field, with both being capable of being written to.\n *\n * @class <Type> LegacyAliasField\n * @public\n */\nexport interface LegacyAliasField {\n /**\n * The kind of field this is.\n *\n * @property {'alias'} kind\n * @public\n */\n kind: 'alias';\n\n /**\n * The name of the field.\n *\n * @property {string} name\n * @public\n */\n name: string;\n\n /**\n * Always null (for now)\n *\n * @property {null} type\n * @public\n */\n type: null; // should always be null\n\n /**\n * The field def for which this is an alias.\n *\n * @property {GenericField | ObjectField | SchemaObjectField | ArrayField | SchemaArrayField | LegacyAttributeField | LegacyBelongsToField | LegacyHasManyField} options\n * @public\n */\n options:\n | GenericField\n | ObjectField\n | SchemaObjectField\n | ArrayField\n | SchemaArrayField\n // | ResourceField\n // | CollectionField\n | LegacyAttributeField\n | LegacyBelongsToField\n | LegacyHasManyField;\n}\n\n/**\n * A field that can be used to alias one key to another\n * key present in the cache version of the resource.\n *\n * Unlike DerivedField, an AliasField may write to its\n * source when a record is in an editable mode.\n *\n * AliasFields may utilize a transform, specified by type,\n * to pre/post process the field.\n *\n * An AliasField may also specify a `kind` via options.\n * `kind` may be any other valid field kind other than\n *\n * - `@hash`\n * - `@id`\n * - `@local`\n * - `derived`\n *\n * This allows an AliasField to rename any field in the cache.\n *\n * Alias fields are generally intended to be used to support migrating\n * between different schemas, though there are times where they are useful\n * as a form of advanced derivation when used with a transform. For instance,\n * an AliasField could be used to expose both a string and a Date version of the\n * same field, with both being capable of being written to.\n *\n * @class <Type> PolarisAliasField\n * @public\n */\nexport interface PolarisAliasField {\n /**\n * The kind of field this is.\n *\n * @property {'alias'} kind\n * @public\n */\n kind: 'alias';\n\n /**\n * The name of the field.\n *\n * @property {string} name\n * @public\n */\n name: string;\n\n /**\n * Always null (for now)\n *\n * @property {null} type\n * @public\n */\n type: null; // should always be null\n\n /**\n * The field def for which this is an alias.\n *\n * @property {GenericField | ObjectField | SchemaObjectField | ArrayField | SchemaArrayField | LinksModeBelongsToField | LinksModeHasManyField} options\n * @public\n */\n options:\n | GenericField\n | ObjectField\n | SchemaObjectField\n | ArrayField\n | SchemaArrayField\n // | ResourceField\n // | CollectionField\n | LinksModeBelongsToField\n | LinksModeHasManyField;\n}\n\n/**\n * A field that can be used to alias one key to another\n * key present in the cache version of the resource.\n *\n * Unlike DerivedField, an AliasField may write to its\n * source when a record is in an editable mode.\n *\n * AliasFields may utilize a transform, specified by type,\n * to pre/post process the field.\n *\n * An AliasField may also specify a `kind` via options.\n * `kind` may be any other valid field kind other than\n *\n * - `@hash`\n * - `@id`\n * - `@local`\n * - `derived`\n *\n * This allows an AliasField to rename any field in the cache.\n *\n * Alias fields are generally intended to be used to support migrating\n * between different schemas, though there are times where they are useful\n * as a form of advanced derivation when used with a transform. For instance,\n * an AliasField could be used to expose both a string and a Date version of the\n * same field, with both being capable of being written to.\n *\n * @class <Type> ObjectAliasField\n * @public\n */\nexport interface ObjectAliasField {\n /**\n * The kind of field this is.\n *\n * @property {'alias'} kind\n * @public\n */\n kind: 'alias';\n\n /**\n * The name of the field.\n *\n * @property {string} name\n * @public\n */\n name: string;\n\n /**\n * Always null (for now)\n *\n * @property {null} type\n * @public\n */\n type: null; // should always be null\n\n /**\n * The field def for which this is an alias.\n *\n * @property {GenericField | ObjectField | SchemaObjectField | ArrayField | SchemaArrayField} options\n * @public\n */\n options: GenericField | ObjectField | SchemaObjectField | ArrayField | SchemaArrayField;\n}\n\n/**\n * Represents a field whose value is the primary\n * key of the resource.\n *\n * This allows any field to serve as the primary\n * key while still being able to drive identity\n * needs within the system.\n *\n * This is useful for resources that use for instance\n * 'uuid', 'urn' or 'entityUrn' or 'primaryKey' as their\n * primary key field instead of 'id'.\n *\n * @class <Type> IdentityField\n * @public\n */\nexport interface IdentityField {\n /**\n * The kind of field this is.\n *\n * @property {'@id'} kind\n * @public\n */\n kind: '@id';\n\n /**\n * The name of the field that serves as the\n * primary key for the resource.\n *\n * @property {string} name\n * @public\n */\n name: string;\n}\n\n/**\n * Represents a specialized field whose computed value\n * will be used as the primary key of a schema-object\n * for serializability and comparison purposes.\n *\n * This field functions similarly to derived fields in that\n * it is non-settable, derived state but differs in that\n * it is only able to compute off of cache state and is given\n * no access to a record instance.\n *\n * This means that if a hashing function wants to compute its value\n * taking into account transformations and derivations it must\n * perform those itself.\n *\n * A schema-array can declare its \"key\" value to be `@hash` if\n * a schema-object has such a field.\n *\n * Only one hash field is permittable per schema-object, and\n * it should be placed in the `ResourceSchema`'s `@id` field\n * in place of an `IdentityField`.\n *\n * @class <Type> HashField\n * @public\n */\nexport interface HashField {\n /**\n * The kind of field this is.\n *\n * @property {'@hash'} kind\n * @public\n */\n kind: '@hash';\n\n /**\n * The name of the field that serves as the\n * hash for the resource.\n *\n * Only required if access to this value by\n * the UI is desired, it can be `null` otherwise.\n *\n * @property {string | null} name\n * @public\n */\n name: string | null;\n\n /**\n * The name of a function to run to compute the hash.\n * The function will only have access to the cached\n * data for the record.\n *\n * @property {string} type\n * @public\n */\n type: string;\n\n /**\n * Any options that should be provided to the hash\n * function.\n *\n * @property {ObjectValue | undefined} options\n * @public\n */\n options?: ObjectValue;\n}\n\n/**\n * Represents a field whose value is a local\n * value that is not stored in the cache, nor\n * is it sent to the server.\n *\n * Local fields can be written to, and their\n * value is both memoized and reactive (though\n * not deep-tracked).\n *\n * Because their state is not derived from the cache\n * data or the server, they represent a divorced\n * uncanonical source of state.\n *\n * For this reason Local fields should be used sparingly.\n *\n * Currently, while we document this feature here,\n * only allow our own SchemaRecord default fields to\n * utilize them and the feature should be considered private.\n *\n * Example use cases that drove the creation of local\n * fields are states like `isDestroying` and `isDestroyed`\n * which are specific to a record instance but not\n * stored in the cache. We wanted to be able to drive\n * these fields from schema the same as all other fields.\n *\n * Don't make us regret this decision.\n *\n * @class <Type> LocalField\n * @public\n */\nexport interface LocalField {\n /**\n * The kind of field this is.\n *\n * @property {'@local'} kind\n * @public\n */\n kind: '@local';\n\n /**\n * The name of the field.\n *\n * @property {string} name\n * @public\n */\n name: string;\n /**\n * Not currently utilized, we are considering\n * allowing transforms to operate on local fields\n *\n * @property {string | undefined} type\n * @public\n */\n type?: string;\n\n /**\n * Options for the field.\n *\n * @property {ObjectValue | undefined} options\n * @public\n */\n options?: { defaultValue?: PrimitiveValue };\n}\n\n/**\n * Represents a field whose value is an object\n * with keys pointing to values that are primitive\n * values.\n *\n * If values of the keys are not primitives, or\n * if the key/value pairs have well-defined shape,\n * use 'schema-object' instead.\n *\n * @class <Type> ObjectField\n * @public\n */\nexport interface ObjectField {\n /**\n * The kind of field this is.\n *\n * @property {'object'} kind\n * @public\n */\n kind: 'object';\n\n /**\n * The name of the field.\n *\n * @property {string} name\n * @public\n */\n name: string;\n\n /**\n * The name of a transform to pass the entire object\n * through before displaying or serializing it.\n *\n * @property {string | undefined} type\n * @public\n */\n type?: string;\n\n /**\n * Options to pass to the transform, if any\n *\n * Must comply to the specific transform's options\n * schema.\n *\n * @property {ObjectValue | undefined} options\n * @public\n */\n options?: ObjectValue;\n}\n\n/**\n * Represents a field whose value is an object\n * with a well-defined structure described by\n * a non-resource schema.\n *\n * If the object's structure is not well-defined,\n * use 'object' instead.\n *\n * @class <Type> SchemaObjectField\n * @public\n */\nexport interface SchemaObjectField {\n /**\n * The kind of field this is.\n *\n * @property {'schema-object'} kind\n * @public\n */\n kind: 'schema-object';\n\n /**\n * The name of the field.\n *\n * @property {string} name\n * @public\n */\n name: string;\n\n /**\n * The name of the ObjectSchema that describes the\n * structure of the object.\n *\n * @property {string} type\n * @public\n */\n type: string;\n\n /**\n * Options for configuring the behavior of the\n * SchemaObject.\n *\n * - `polymorphic` : Whether this SchemaObject is Polymorphic.\n * - `type` : If the SchemaObject is Polymorphic, the key on the raw cache data to use as the \"resource-type\" value for the schema-object.\n *\n * @property {ObjectValue | undefined} options\n * @public\n */\n options?: {\n /**\n * Whether this SchemaObject is Polymorphic.\n *\n * If the SchemaObject is polymorphic, `options.type` must also be supplied.\n *\n * @typedoc\n */\n polymorphic?: boolean;\n\n /**\n * If the SchemaObject is Polymorphic, the key on the raw cache data to use\n * as the \"resource-type\" value for the schema-object.\n *\n * Defaults to \"type\".\n *\n * @typedoc\n */\n type?: string;\n };\n}\n\n/**\n * Represents a field whose value is an array\n * of primitive values.\n *\n * If the array's elements are not primitive\n * values, use 'schema-array' instead.\n *\n * @class <Type> ArrayField\n * @public\n */\nexport interface ArrayField {\n /**\n * The kind of field this is.\n *\n * @property {'array'} kind\n * @public\n */\n kind: 'array';\n\n /**\n * The name of the field.\n *\n * @property {string} name\n * @public\n */\n name: string;\n\n /**\n * The name of a transform to pass each item\n * in the array through before displaying or\n * or serializing it.\n *\n * @property {string | undefined} type\n * @public\n */\n type?: string;\n\n /**\n * Options to pass to the transform, if any\n *\n * Must comply to the specific transform's options\n * schema.\n *\n * @property {ObjectValue | undefined} options\n * @public\n */\n options?: ObjectValue;\n}\n\n/**\n * Represents a field whose value is an array\n * of objects with a well-defined structure\n * described by a non-resource schema.\n *\n * If the array's elements are not well-defined,\n * use 'array' instead.\n *\n * @class <Type> SchemaArrayField\n * @public\n */\nexport interface SchemaArrayField {\n /**\n * The kind of field this is.\n *\n * @property {'schema-array'} kind\n * @public\n */\n kind: 'schema-array';\n\n /**\n * The name of the field.\n *\n * @property {string} name\n * @public\n */\n name: string;\n\n /**\n * The name of the ObjectSchema that describes the\n * structure of the objects in the array.\n *\n * @property {string} type\n * @public\n */\n type: string;\n\n /**\n * Options for configuring the behavior of the\n * SchemaArray.\n *\n * - `key`\n *\n * Configures how the SchemaArray determines whether an object in the cache is the same\n * as an object previously used to instantiate one of the schema-objects it contains.\n *\n * The default is `'@identity'`.\n *\n * Valid options are:\n *\n * - `'@identity'` (default) : the cached object's referential identity will be used.\n * This may result in significant instability when resource data is updated from the API\n * - `'@index'` : the cached object's index in the array will be used.\n * This is only a good choice for arrays that rarely if ever change membership\n * - `'@hash'` : will lookup the `@hash` function supplied in the ResourceSchema for\n * The contained schema-object and use the computed result to determine and compare identity.\n * - <field-name> (string) : the name of a field to use as the key, only GenericFields (kind `field`)\n * Are valid field names for this purpose. The cache state without transforms applied will be\n * used when comparing values. The field value should be unique enough to guarantee two schema-objects\n * of the same type will not collide.\n *\n * - `polymorphic` : Whether this SchemaArray is Polymorphic.\n * - `type` : If the SchemaArray is Polymorphic, the key on the raw cache data to use as the \"resource-type\" value for the schema-object.\n *\n * @property {ObjectValue | undefined} options\n * @public\n */\n options?: {\n /**\n * Configures how the SchemaArray determines whether\n * an object in the cache is the same as an object\n * previously used to instantiate one of the schema-objects\n * it contains.\n *\n * The default is `'@identity'`.\n *\n * Valid options are:\n *\n * - `'@identity'` (default) : the cached object's referential identity will be used.\n * This may result in significant instability when resource data is updated from the API\n * - `'@index'` : the cached object's index in the array will be used.\n * This is only a good choice for arrays that rarely if ever change membership\n * - `'@hash'` : will lookup the `@hash` function supplied in the ResourceSchema for\n * The contained schema-object and use the computed result to determine and compare identity.\n * - <field-name> (string) : the name of a field to use as the key, only GenericFields (kind `field`)\n * Are valid field names for this purpose. The cache state without transforms applied will be\n * used when comparing values. The field value should be unique enough to guarantee two schema-objects\n * of the same type will not collide.\n *\n * @typedoc\n */\n key?: '@identity' | '@index' | '@hash' | string;\n\n /**\n * Whether this SchemaArray is Polymorphic.\n *\n * If the SchemaArray is polymorphic, `options.type` must also be supplied.\n *\n * @typedoc\n */\n polymorphic?: boolean;\n\n /**\n * If the SchemaArray is Polymorphic, the key on the raw cache data to use\n * as the \"resource-type\" value for the schema-object.\n *\n * Defaults to \"type\".\n *\n * @typedoc\n */\n type?: string;\n };\n}\n\n/**\n * Represents a field whose value is derived\n * from other fields in the schema.\n *\n * The value is read-only, and is not stored\n * in the cache, nor is it sent to the server.\n *\n * Usage of derived fields should be minimized\n * to scenarios where the derivation is known\n * to be safe. For instance, derivations that\n * required fields that are not always loaded\n * or that require access to related resources\n * that may not be loaded should be avoided.\n *\n * @class <Type> DerivedField\n * @public\n */\nexport interface DerivedField {\n /**\n * The kind of field this is.\n *\n * @property {'derived'} kind\n * @public\n */\n kind: 'derived';\n\n /**\n * The name of the field.\n *\n * @property {string} name\n * @public\n */\n name: string;\n\n /**\n * The name of the derivation to use.\n *\n * Derivations are functions that take the\n * record, options, and the name of the field\n * as arguments, and return the derived value.\n *\n * Derivations are memoized, and are only\n * recomputed when the fields they depend on\n * change.\n *\n * Derivations are not stored in the cache,\n * and are not sent to the server.\n *\n * Derivation functions must be explicitly\n * registered with the schema service.\n *\n * @property {string} type\n * @public\n */\n type: string;\n\n /**\n * Options to pass to the derivation, if any\n *\n * Must comply to the specific derivation's\n * options schema.\n *\n * @property {ObjectValue | undefined} options\n * @public\n */\n options?: ObjectValue;\n}\n\n/**\n * Represents a field that is a reference to\n * another resource.\n *\n * SUPPORT FOR THIS FEATURE IS NOT YET IMPLEMENTED\n * BY SchemaRecord\n *\n * @class <Type> ResourceField\n * @public\n */\nexport interface ResourceField {\n /**\n * The kind of field this is.\n *\n * @property {'resource'} kind\n * @public\n */\n kind: 'resource';\n\n /**\n * The name of the field.\n *\n * @property {string} name\n * @public\n */\n name: string;\n\n /**\n * The name of the resource that this field\n * refers to. In the case of a polymorphic\n * relationship, this should be the trait\n * or abstract type.\n *\n * @property {string} type\n * @public\n */\n type: string;\n\n /**\n * Options for resources are optional. If\n * not present, all options are presumed\n * to be falsey\n *\n * @property {ObjectValue | undefined} options\n * @public\n */\n options?: {\n /**\n * Whether the relationship is async\n *\n * If true, it is expected that the cache\n * data for this field will contain a link\n * that can be used to fetch the related\n * resource when needed.\n *\n * @typedoc\n */\n async?: boolean;\n\n /**\n * The name of the inverse field on the\n * related resource that points back to\n * this field on this resource to form a\n * bidirectional relationship.\n *\n * If null, the relationship is unidirectional.\n *\n * @typedoc\n */\n inverse?: string | null;\n\n /**\n * If this field is satisfying a polymorphic\n * relationship on another resource, then this\n * should be set to the trait or abstract type\n * that this resource implements.\n *\n * @typedoc\n */\n as?: string;\n\n /**\n * Whether this field is a polymorphic relationship,\n * meaning that it can point to multiple types of\n * resources so long as they implement the trait\n * or abstract type specified in `type`.\n *\n * @typedoc\n */\n polymorphic?: boolean;\n };\n}\n\n/**\n * Represents a field that is a reference to\n * a collection of other resources, potentially\n * paginate.\n *\n * SUPPORT FOR THIS FEATURE IS NOT YET IMPLEMENTED\n * BY SchemaRecord\n *\n * @class <Type> CollectionField\n * @public\n */\nexport interface CollectionField {\n /**\n * The kind of field this is.\n *\n * @property {'collection'} kind\n * @public\n */\n kind: 'collection';\n\n /**\n * The name of the field.\n *\n * @property {string} name\n * @public\n */\n name: string;\n\n /**\n * The name of the resource that this field\n * refers to. In the case of a polymorphic\n * relationship, this should be the trait\n * or abstract type.\n *\n * @property {string} type\n * @public\n */\n type: string;\n\n /**\n * Options for resources are optional. If\n * not present, all options are presumed\n * to be falsey\n *\n * @typedoc\n */\n options?: {\n /**\n * Whether the relationship is async\n *\n * If true, it is expected that the cache\n * data for this field will contain links\n * that can be used to fetch the related\n * resources when needed.\n *\n * When false, it is expected that all related\n * resources are loaded together with this resource,\n * and that the cache data for this field will\n * contain the full list of pointers.\n *\n * When true, it is expected that the relationship\n * is paginated. If the relationship is not paginated,\n * then the cache data for \"page 1\" would contain the\n * full list of pointers, and loading \"page 1\" would\n * load all related resources.\n *\n * @typedoc\n */\n async?: boolean;\n\n /**\n * The name of the inverse field on the\n * related resource that points back to\n * this field on this resource to form a\n * bidirectional relationship.\n *\n * If null, the relationship is unidirectional.\n *\n * @typedoc\n */\n inverse?: string | null;\n\n /**\n * If this field is satisfying a polymorphic\n * relationship on another resource, then this\n * should be set to the trait or abstract type\n * that this resource implements.\n *\n * @typedoc\n */\n as?: string;\n\n /**\n * Whether this field is a polymorphic relationship,\n * meaning that it can point to multiple types of\n * resources so long as they implement the trait\n * or abstract type specified in `type`.\n *\n * @typedoc\n */\n polymorphic?: boolean;\n };\n}\n\n/**\n * > [!CAUTION]\n * > This Field is LEGACY\n * > It cannot be used with PolarisMode\n *\n * A generic \"field\" that can be used to define\n * primitive value fields.\n *\n * If the field points to an object or array,\n * it will not be deep-tracked.\n *\n * Transforms when defined are legacy transforms\n * that a serializer *might* use, but their usage\n * is not guaranteed.\n *\n * @class <Type> LegacyAttributeField\n * @public\n */\nexport interface LegacyAttributeField {\n /**\n * The kind of field this is.\n *\n * @property {'attribute'} kind\n * @public\n */\n kind: 'attribute';\n\n /**\n * The name of the field.\n *\n * @property {string} name\n * @public\n */\n name: string;\n /**\n * The name of the transform to use, if any\n *\n * @property {string | undefined | null} type\n * @public\n */\n type?: string | null;\n /**\n * Options to pass to the transform, if any\n *\n * Must comply to the specific transform's options\n * schema.\n *\n * @typedoc\n */\n options?: ObjectValue;\n}\n\n/**\n * > [!CAUTION]\n * > This Field is LEGACY\n *\n * Represents a field that is a reference to\n * another resource.\n *\n * This is the legacy version of the `ResourceField`.\n *\n * @class <Type> LegacyBelongsToField\n * @public\n */\nexport interface LegacyBelongsToField {\n /**\n * The kind of field this is.\n *\n * @property {'belongsTo'} kind\n * @public\n */\n kind: 'belongsTo';\n\n /**\n * The name of the field.\n *\n * @property {string} name\n * @public\n */\n name: string;\n\n /**\n * The name of the resource that this field\n * refers to. In the case of a polymorphic\n * relationship, this should be the trait\n * or abstract type.\n *\n * @property {string} type\n * @public\n */\n type: string;\n\n /**\n * Options for belongsTo are mandatory.\n *\n * @typedoc\n */\n options: {\n /**\n * Whether the relationship is async\n *\n * If true, it is expected that the cache\n * data for this field will contain a link\n * or a pointer that can be used to fetch\n * the related resource when needed.\n *\n * Pointers are highly discouraged.\n *\n * @typedoc\n */\n async: boolean;\n\n /**\n * The name of the inverse field on the\n * related resource that points back to\n * this field on this resource to form a\n * bidirectional relationship.\n *\n * If null, the relationship is unidirectional.\n *\n * @typedoc\n */\n inverse: string | null;\n\n /**\n * If this field is satisfying a polymorphic\n * relationship on another resource, then this\n * should be set to the trait or abstract type\n * that this resource implements.\n *\n * @typedoc\n */\n as?: string;\n\n /**\n * Whether this field is a polymorphic relationship,\n * meaning that it can point to multiple types of\n * resources so long as they implement the trait\n * or abstract type specified in `type`.\n *\n * @typedoc\n */\n polymorphic?: boolean;\n\n /**\n * Whether this field should ever make use of the legacy support infra\n * from @ember-data/model and the LegacyNetworkMiddleware for adapters and serializers.\n *\n * When true, none of the legacy support will be utilized. Sync relationships\n * will be expected to already have all their data. When reloading a sync relationship\n * you would be expected to have a `related link` available from a prior relationship\n * payload e.g.\n *\n * ```ts\n * {\n * data: {\n * type: 'user',\n * id: '2',\n * attributes: { name: 'Chris' },\n * relationships: {\n * bestFriend: {\n * links: { related: \"/users/1/bestFriend\" },\n * data: { type: 'user', id: '1' },\n * }\n * }\n * },\n * included: [\n * { type: 'user', id: '1', attributes: { name: 'Krystan' } }\n * ]\n * }\n * ```\n *\n * Async relationships will be loaded via their link if needed.\n *\n * @typedoc\n */\n linksMode?: true;\n\n /**\n * When omitted, the cache data for this field will\n * clear local state of all changes except for the\n * addition of records still in the \"new\" state any\n * time the remote data for this field is updated.\n *\n * When set to `false`, the cache data for this field\n * will instead intelligently commit any changes from\n * local state that are present in the remote data,\n * leaving any remaining changes in local state still.\n *\n * @typedoc\n */\n resetOnRemoteUpdate?: false;\n };\n}\n\n/**\n * > [!CAUTION]\n * > This Field is LEGACY\n *\n * Represents a field that is a reference to\n * another resource.\n *\n * This is the legacy version of the `ResourceField`.\n *\n * @class <Type> LinksModeBelongsToField\n * @public\n */\nexport interface LinksModeBelongsToField {\n /**\n * The kind of field this is.\n *\n * @property {'belongsTo'} kind\n * @public\n */\n kind: 'belongsTo';\n\n /**\n * The name of the field.\n *\n * @property {string} name\n * @public\n */\n name: string;\n\n /**\n * The name of the resource that this field\n * refers to. In the case of a polymorphic\n * relationship, this should be the trait\n * or abstract type.\n *\n * @property {string} type\n * @public\n */\n type: string;\n\n /**\n * Options for belongsTo are mandatory.\n *\n * @typedoc\n */\n options: {\n /**\n * Whether the relationship is async\n *\n * MUST be false for PolarisMode + LinksMode\n *\n * @typedoc\n */\n async: false;\n\n /**\n * The name of the inverse field on the\n * related resource that points back to\n * this field on this resource to form a\n * bidirectional relationship.\n *\n * If null, the relationship is unidirectional.\n *\n * @typedoc\n */\n inverse: string | null;\n\n /**\n * If this field is satisfying a polymorphic\n * relationship on another resource, then this\n * should be set to the trait or abstract type\n * that this resource implements.\n *\n * @typedoc\n */\n as?: string;\n\n /**\n * Whether this field is a polymorphic relationship,\n * meaning that it can point to multiple types of\n * resources so long as they implement the trait\n * or abstract type specified in `type`.\n *\n * @typedoc\n */\n polymorphic?: boolean;\n\n /**\n * Whether this field should ever make use of the legacy support infra\n * from @ember-data/model and the LegacyNetworkMiddleware for adapters and serializers.\n *\n * MUST be true for PolarisMode + LinksMode\n *\n * When true, none of the legacy support will be utilized. Sync relationships\n * will be expected to already have all their data. When reloading a sync relationship\n * you would be expected to have a `related link` available from a prior relationship\n * payload e.g.\n *\n * ```ts\n * {\n * data: {\n * type: 'user',\n * id: '2',\n * attributes: { name: 'Chris' },\n * relationships: {\n * bestFriend: {\n * links: { related: \"/users/1/bestFriend\" },\n * data: { type: 'user', id: '1' },\n * }\n * }\n * },\n * included: [\n * { type: 'user', id: '1', attributes: { name: 'Krystan' } }\n * ]\n * }\n * ```\n *\n * Async relationships will be loaded via their link if needed.\n *\n * @typedoc\n */\n linksMode: true;\n\n /**\n * When omitted, the cache data for this field will\n * clear local state of all changes except for the\n * addition of records still in the \"new\" state any\n * time the remote data for this field is updated.\n *\n * When set to `false`, the cache data for this field\n * will instead intelligently commit any changes from\n * local state that are present in the remote data,\n * leaving any remaining changes in local state still.\n *\n * MUST be false for PolarisMode + LinksMode\n *\n * @typedoc\n */\n resetOnRemoteUpdate: false;\n };\n}\n\n/**\n * > [!CAUTION]\n * > This Field is LEGACY\n *\n * Represents a field that is a reference to\n * a collection of other resources.\n *\n * This is the legacy version of the `CollectionField`.\n *\n * @class <Type> LegacyHasManyField\n * @public\n */\nexport interface LegacyHasManyField {\n /**\n * The kind of field this is.\n *\n * @property {'hasMany'} kind\n * @public\n */\n kind: 'hasMany';\n\n /**\n * The name of the field.\n *\n * @property {string} name\n * @public\n */\n name: string;\n\n /**\n * the name of the resource that this field\n * refers to. In the case of a polymorphic\n * relationship, this should be the trait\n * or abstract type.\n *\n * @property {string} type\n * @public\n */\n type: string;\n\n /**\n * Options for hasMany are mandatory.\n *\n * @typedoc\n */\n options: {\n /**\n * Whether the relationship is async\n *\n * If true, it is expected that the cache\n * data for this field will contain links\n * or pointers that can be used to fetch\n * the related resources when needed.\n *\n * When false, it is expected that all related\n * resources are loaded together with this resource,\n * and that the cache data for this field will\n * contain the full list of pointers.\n *\n * hasMany relationships do not support pagination.\n *\n * @typedoc\n */\n async: boolean;\n\n /**\n * The name of the inverse field on the\n * related resource that points back to\n * this field on this resource to form a\n * bidirectional relationship.\n *\n * If null, the relationship is unidirectional.\n *\n * @typedoc\n */\n inverse: string | null;\n\n /**\n * If this field is satisfying a polymorphic\n * relationship on another resource, then this\n * should be set to the trait or abstract type\n * that this resource implements.\n *\n * @typedoc\n */\n as?: string;\n\n /**\n * Whether this field is a polymorphic relationship,\n * meaning that it can point to multiple types of\n * resources so long as they implement the trait\n * or abstract type specified in `type`.\n *\n * @typedoc\n */\n polymorphic?: boolean;\n\n /**\n * Whether this field should ever make use of the legacy support infra\n * from @ember-data/model and the LegacyNetworkMiddleware for adapters and serializers.\n *\n * When true, none of the legacy support will be utilized. Sync relationships\n * will be expected to already have all their data. When reloading a sync relationship\n * you would be expected to have a `related link` available from a prior relationship\n * payload e.g.\n *\n * ```ts\n * {\n * data: {\n * type: 'user',\n * id: '2',\n * attributes: { name: 'Chris' },\n * relationships: {\n * bestFriends: {\n * links: { related: \"/users/1/bestFriends\" },\n * data: [ { type: 'user', id: '1' } ],\n * }\n * }\n * },\n * included: [\n * { type: 'user', id: '1', attributes: { name: 'Krystan' } }\n * ]\n * }\n * ```\n *\n * Async relationships will be loaded via their link if needed.\n *\n * @typedoc\n */\n linksMode?: true;\n\n /**\n * When omitted, the cache data for this field will\n * clear local state of all changes except for the\n * addition of records still in the \"new\" state any\n * time the remote data for this field is updated.\n *\n * When set to `false`, the cache data for this field\n * will instead intelligently commit any changes from\n * local state that are present in the remote data,\n * leaving any remaining changes in local state still.\n *\n * @typedoc\n */\n resetOnRemoteUpdate?: false;\n };\n}\n\n/**\n * > [!CAUTION]\n * > This Field is LEGACY\n *\n * Represents a field that is a reference to\n * a collection of other resources.\n *\n * This is the legacy version of the `CollectionField`.\n *\n * @class <Type> LinksModeHasManyField\n * @public\n */\nexport interface LinksModeHasManyField {\n /**\n * The kind of field this is.\n *\n * @property {'hasMany'} kind\n * @public\n */\n kind: 'hasMany';\n\n /**\n * The name of the field.\n *\n * @property {string} name\n * @public\n */\n name: string;\n\n /**\n * the name of the resource that this field\n * refers to. In the case of a polymorphic\n * relationship, this should be the trait\n * or abstract type.\n *\n * @property {string} type\n * @public\n */\n type: string;\n\n /**\n * Options for hasMany are mandatory.\n *\n * @typedoc\n */\n options: {\n /**\n * Whether the relationship is async\n *\n * MUST be false for PolarisMode + LinksMode\n *\n * If true, it is expected that the cache\n * data for this field will contain links\n * or pointers that can be used to fetch\n * the related resources when needed.\n *\n * When false, it is expected that all related\n * resources are loaded together with this resource,\n * and that the cache data for this field will\n * contain the full list of pointers.\n *\n * hasMany relationships do not support pagination.\n *\n * @typedoc\n */\n async: false;\n\n /**\n * The name of the inverse field on the\n * related resource that points back to\n * this field on this resource to form a\n * bidirectional relationship.\n *\n * If null, the relationship is unidirectional.\n *\n * @typedoc\n */\n inverse: string | null;\n\n /**\n * If this field is satisfying a polymorphic\n * relationship on another resource, then this\n * should be set to the trait or abstract type\n * that this resource implements.\n *\n * @typedoc\n */\n as?: string;\n\n /**\n * Whether this field is a polymorphic relationship,\n * meaning that it can point to multiple types of\n * resources so long as they implement the trait\n * or abstract type specified in `type`.\n *\n * @typedoc\n */\n polymorphic?: boolean;\n\n /**\n * Whether this field should ever make use of the legacy support infra\n * from @ember-data/model and the LegacyNetworkMiddleware for adapters and serializers.\n *\n * MUST be true for PolarisMode + LinksMode\n *\n * When true, none of the legacy support will be utilized. Sync relationships\n * will be expected to already have all their data. When reloading a sync relationship\n * you would be expected to have a `related link` available from a prior relationship\n * payload e.g.\n *\n * ```ts\n * {\n * data: {\n * type: 'user',\n * id: '2',\n * attributes: { name: 'Chris' },\n * relationships: {\n * bestFriends: {\n * links: { related: \"/users/1/bestFriends\" },\n * data: [ { type: 'user', id: '1' } ],\n * }\n * }\n * },\n * included: [\n * { type: 'user', id: '1', attributes: { name: 'Krystan' } }\n * ]\n * }\n * ```\n *\n * Async relationships will be loaded via their link if needed.\n *\n * @typedoc\n */\n linksMode: true;\n\n /**\n * When omitted, the cache data for this field will\n * clear local state of all changes except for the\n * addition of records still in the \"new\" state any\n * time the remote data for this field is updated.\n *\n * When set to `false`, the cache data for this field\n * will instead intelligently commit any changes from\n * local state that are present in the remote data,\n * leaving any remaining changes in local state still.\n *\n * MUST be false for PolarisMode + LinksMode\n *\n * @typedoc\n */\n resetOnRemoteUpdate: false;\n };\n}\n\n/**\n * A union of all possible LegacyMode field schemas.\n *\n * Available field schemas are:\n *\n * - [GenericField](../classes/<Type>%20GenericField)\n * - [LegacyAliasField](../classes/<Type>%20LegacyAliasField)\n * - [LocalField](../classes/<Type>%20LocalField)\n * - [ObjectField](../classes/<Type>%20ObjectField)\n * - [SchemaObjectField](../classes/<Type>%20SchemaObjectField)\n * - [ArrayField](../classes/<Type>%20ArrayField)\n * - [SchemaArrayField](../classes/<Type>%20SchemaArrayField)\n * - [DerivedField](../classes/<Type>%20DerivedField)\n * - [ResourceField (not yet implemented)](../classes/<Type>%20ResourceField)\n * - [CollectionField (not yet implemented)](../classes/<Type>%20CollectionField)\n * - [LegacyAttributeField](../classes/<Type>%20LegacyAttributeField)\n * - [LegacyBelongsToField](../classes/<Type>%20LegacyBelongsToField)\n * - [LegacyHasManyField](../classes/<Type>%20LegacyHasManyField)\n *\n * @class <Type> LegacyModeFieldSchema\n * @public\n */\nexport type LegacyModeFieldSchema =\n | GenericField\n | LegacyAliasField\n | LocalField\n | ObjectField\n | SchemaObjectField\n | ArrayField\n | SchemaArrayField\n | DerivedField\n // | ResourceField // not yet implemented\n // | CollectionField // not yet implemented\n | LegacyAttributeField\n | LegacyBelongsToField\n | LegacyHasManyField;\n\n/**\n * A union of all possible PolarisMode field schemas.\n *\n * Available field schemas are:\n *\n * - [GenericField](../classes/<Type>%20GenericField)\n * - [PolarisAliasField](../classes/<Type>%20PolarisAliasField)\n * - [LocalField](../classes/<Type>%20LocalField)\n * - [ObjectField](../classes/<Type>%20ObjectField)\n * - [SchemaObjectField](../classes/<Type>%20SchemaObjectField)\n * - [ArrayField](../classes/<Type>%20ArrayField)\n * - [SchemaArrayField](../classes/<Type>%20SchemaArrayField)\n * - [DerivedField](../classes/<Type>%20DerivedField)\n * - [ResourceField (not yet implemented)](../classes/<Type>%20ResourceField)\n * - [CollectionField (not yet implemented)](../classes/<Type>%20CollectionField)\n * - [LinksModeBelongsToField](../classes/<Type>%20LinksModeBelongsToField)\n * - [LinksModeHasManyField](../classes/<Type>%20LinksModeHasManyField)\n *\n * @class <Type> PolarisModeFieldSchema\n * @public\n */\nexport type PolarisModeFieldSchema =\n | GenericField\n | PolarisAliasField\n | LocalField\n | ObjectField\n | SchemaObjectField\n | ArrayField\n | SchemaArrayField\n | DerivedField\n // | ResourceField\n // | CollectionField\n | LinksModeBelongsToField\n | LinksModeHasManyField;\n\n/**\n * A union of all possible LegacyMode and PolarisMode\n * field schemas.\n *\n * You likely will want to use PolarisModeFieldSchema,\n * LegacyModeFieldSchema, or ObjectFieldSchema instead\n * as appropriate as they are more specific and will\n * provide better guidance around what is valid.\n *\n * @class <Type> FieldSchema\n * @public\n */\nexport type FieldSchema =\n | GenericField\n | LegacyAliasField\n | PolarisAliasField\n | LocalField\n | ObjectField\n | SchemaObjectField\n | ArrayField\n | SchemaArrayField\n | DerivedField\n | ResourceField\n | CollectionField\n | LegacyAttributeField\n | LegacyBelongsToField\n | LegacyHasManyField\n | LinksModeBelongsToField\n | LinksModeHasManyField;\n\n/**\n * A union of all possible field schemas that can be\n * used in an ObjectSchema.\n *\n * @class <Type> ObjectFieldSchema\n * @public\n */\nexport type ObjectFieldSchema =\n | GenericField\n | ObjectAliasField\n | LocalField\n | ObjectField\n | SchemaObjectField\n | ArrayField\n | SchemaArrayField\n | DerivedField;\n\n/**\n * Represents a schema for a primary resource in PolarisMode.\n *\n * Primary resources are objects with a unique identity of their\n * own which may allow them to appear in relationships, or in multiple\n * response documents.\n *\n * @class <Type> PolarisResourceSchema\n * @public\n */\nexport interface PolarisResourceSchema {\n legacy?: false;\n\n /**\n * For primary resources, this should be an IdentityField\n *\n * for schema-objects, this should be either a HashField or null\n *\n * @property {IdentityField} identity\n * @public\n */\n identity: IdentityField;\n\n /**\n * The name of the schema\n *\n * For cacheable resources, this should be the\n * primary resource type.\n *\n * For object schemas, this should be the name\n * of the object schema.\n *\n * The names of object and resource schemas share\n * a single namespace and must not conflict.\n *\n * We recommend a naming convention for object schemas\n * such as below for ensuring uniqueness:\n *\n * - for globally shared objects: The pattern `$field:${KlassName}` e.g. `$field:AddressObject`\n * - for resource-specific objects: The pattern `$${ResourceKlassName}:$field:${KlassName}` e.g. `$User:$field:ReusableAddress`\n * - for inline objects: The pattern `$${ResourceKlassName}.${fieldPath}:$field:anonymous` e.g. `$User.shippingAddress:$field:anonymous`\n *\n * @property {string} type\n * @public\n */\n type: string;\n\n /**\n * The fields that make up the shape of the resource\n *\n * @property {PolarisModeFieldSchema[]} fields\n * @public\n */\n fields: PolarisModeFieldSchema[];\n\n /**\n * A list of traits that this resource implements. The fields for these\n * traits should still be defined in the fields array.\n *\n * Each trait should be a string that matches the `type` of another\n * resource schema. The trait can be abstract and reference a resource\n * type that is never defined as a schema.\n *\n * @property {string[]} traits\n * @public\n */\n traits?: string[];\n}\n\n/**\n * Represents a schema for a primary resource in LegacyMode\n *\n * Primary resources are objects with a unique identity of their\n * own which may allow them to appear in relationships, or in multiple\n * response documents.\n *\n * @class <Type> LegacyResourceSchema\n * @public\n */\nexport interface LegacyResourceSchema {\n /**\n * A flag indicating that this is a legacy resource schema\n *\n * @property {true} legacy\n * @public\n */\n legacy: true;\n\n /**\n * This should be an IdentityField.\n *\n * To maximize compatibility with Model where `id` was the\n * name of the identity field, we recommend using `{ kind: '@id', name: 'id' }`\n * for records in legacy mode, but this is not required.\n *\n * @property {IdentityField} identity\n * @public\n */\n identity: IdentityField;\n\n /**\n * The name of the schema\n *\n * For cacheable resources, this should be the\n * primary resource type.\n *\n * The names of object and resource schemas share\n * a single namespace and must not conflict.\n *\n * We recommend a naming convention for object schemas\n * such as below for ensuring uniqueness:\n *\n * - for globally shared objects: The pattern `$field:${KlassName}` e.g. `$field:AddressObject`\n * - for resource-specific objects: The pattern `$${ResourceKlassName}:$field:${KlassName}` e.g. `$User:$field:ReusableAddress`\n * - for inline objects: The pattern `$${ResourceKlassName}.${fieldPath}:$field:anonymous` e.g. `$User.shippingAddress:$field:anonymous`\n *\n * @property {string} type\n * @public\n */\n type: string;\n\n /**\n * The fields that make up the shape of the resource\n *\n * @property {LegacyModeFieldSchema[]} fields\n * @public\n */\n fields: LegacyModeFieldSchema[];\n\n /**\n * A list of traits that this resource implements. The fields for these\n * traits should still be defined in the fields array.\n *\n * Each trait should be a string that matches the `type` of another\n * resource schema. The trait can be abstract and reference a resource\n * type that is never defined as a schema.\n *\n * @property {string[]} traits\n * @public\n */\n traits?: string[];\n}\n\n/**\n * A type which represents a valid JSON schema\n * definition for either a PolarisMode or a\n * LegacyMode resource.\n *\n * Note, this is separate from the type returned\n * by the SchemaService which provides fields as a Map\n * instead of as an Array.\n *\n * @typedoc\n */\nexport type ResourceSchema = PolarisResourceSchema | LegacyResourceSchema;\n\n/**\n * Represents a schema for an object that is not\n * a primary resource (has no unique identity of its own).\n *\n * ObjectSchemas may not currently contain relationships.\n *\n * @class <Type> ObjectSchema\n * @public\n */\nexport interface ObjectSchema {\n /**\n * Either a HashField from which to calculate an identity or null\n *\n * In the case of `null`, the object's identity will be based\n * on the referential identity of the object in the cache itself\n * when an identity is needed.\n *\n * @property {HashField | null} identity\n * @public\n */\n identity: HashField | null;\n\n /**\n * The name of the schema\n *\n * The names of object and resource schemas share\n * a single namespace and must not conflict.\n *\n * We recommend a naming convention for object schemas\n * such as below for ensuring uniqueness:\n *\n * - for globally shared objects: The pattern `$field:${KlassName}` e.g. `$field:AddressObject`\n * - for resource-specific objects: The pattern `$${ResourceKlassName}:$field:${KlassName}` e.g. `$User:$field:ReusableAddress`\n * - for inline objects: The pattern `$${ResourceKlassName}.${fieldPath}:$field:anonymous` e.g. `$User.shippingAddress:$field:anonymous`\n *\n * @property {string} type\n * @public\n */\n type: string;\n\n /**\n * The fields that make up the shape of the object\n *\n * @property {ObjectFieldSchema[]} fields\n * @public\n */\n fields: ObjectFieldSchema[];\n}\n\nexport type Schema = ResourceSchema | ObjectSchema;\n\n/**\n * A no-op type utility that enables type-checking resource schema\n * definitions.\n *\n * Will return the passed in schema.\n *\n * This will not validate relationship inverses or related types,\n * as doing so would require a full schema graph to be passed in\n * and no cycles in the graph to be present.\n *\n * @method resourceSchema\n * @static\n * @for @warp-drive/core-types\n * @param {ResourceSchema} schema\n * @return {ResourceSchema} the passed in schema\n * @public\n */\nexport function resourceSchema<T extends ResourceSchema>(schema: T): T {\n return schema;\n}\n\n/**\n * A no-op type utility that enables type-checking object schema\n * definitions.\n *\n * Will return the passed in schema.\n *\n * @method objectSchema\n * @static\n * @for @warp-drive/core-types\n * @param {ObjectSchema} schema\n * @return {ObjectSchema} the passed in schema\n * @public\n */\nexport function objectSchema<T extends ObjectSchema>(schema: T): T {\n return schema;\n}\n\n/**\n * A type utility to narrow a schema to a ResourceSchema\n *\n * @method isResourceSchema\n * @static\n * @for @warp-drive/core-types\n * @param schema\n * @return {boolean}\n * @public\n */\nexport function isResourceSchema(schema: ResourceSchema | ObjectSchema): schema is ResourceSchema {\n return schema?.identity?.kind === '@id';\n}\n\n/**\n * A type utility to narrow a schema to LegacyResourceSchema\n *\n * @method isLegacyResourceSchema\n * @static\n * @for @warp-drive/core-types\n * @param schema\n * @return {boolean}\n * @public\n */\nexport function isLegacyResourceSchema(schema: ResourceSchema | ObjectSchema): schema is LegacyResourceSchema {\n return isResourceSchema(schema) && schema.legacy === true;\n}\n\nexport type LegacyField =\n | LegacyAttributeField\n | LegacyBelongsToField\n | LegacyHasManyField\n | LinksModeBelongsToField\n | LinksModeHasManyField;\nexport type LegacyRelationshipField =\n | LegacyBelongsToField\n | LegacyHasManyField\n | LinksModeBelongsToField\n | LinksModeHasManyField;\n"],"names":["resourceSchema","schema","objectSchema","isResourceSchema","identity","kind","isLegacyResourceSchema","legacy"],"mappings":"AAAA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAsCA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AA6CA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AA4CA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAmCA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAoBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AA0CA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAmCA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAuCA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AA2DA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAwCA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAwGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAoDA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAoFA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AA8FA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAmCA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAoIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAmIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAyIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AA+IA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAgBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAeA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAmBA;AACA;AACA;AACA;AACA;AACA;AACA;;AAWA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AA4DA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAiEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AA2CA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,cAAcA,CAA2BC,MAAS,EAAK;AACrE,EAAA,OAAOA,MAAM;AACf;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASC,YAAYA,CAAyBD,MAAS,EAAK;AACjE,EAAA,OAAOA,MAAM;AACf;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASE,gBAAgBA,CAACF,MAAqC,EAA4B;AAChG,EAAA,OAAOA,MAAM,EAAEG,QAAQ,EAAEC,IAAI,KAAK,KAAK;AACzC;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASC,sBAAsBA,CAACL,MAAqC,EAAkC;EAC5G,OAAOE,gBAAgB,CAACF,MAAM,CAAC,IAAIA,MAAM,CAACM,MAAM,KAAK,IAAI;AAC3D;;;;"}
|