@warp-drive/core-types 5.4.0-alpha.149 → 5.4.0-alpha.151
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/-private.js.map +1 -1
- package/dist/runtime.js +35 -0
- package/dist/runtime.js.map +1 -0
- package/dist/schema/fields.js +238 -25
- package/dist/schema/fields.js.map +1 -1
- package/dist/schema/fields.type-test.js +0 -0
- package/dist/schema/fields.type-test.js.map +1 -0
- package/package.json +3 -3
- package/unstable-preview-types/-private.d.ts +1 -1
- package/unstable-preview-types/-private.d.ts.map +1 -1
- package/unstable-preview-types/index.d.ts +2 -0
- package/unstable-preview-types/runtime.d.ts +18 -0
- package/unstable-preview-types/runtime.d.ts.map +1 -0
- package/unstable-preview-types/schema/fields.d.ts +922 -101
- package/unstable-preview-types/schema/fields.d.ts.map +1 -1
- package/unstable-preview-types/schema/fields.type-test.d.ts +4 -0
- package/unstable-preview-types/schema/fields.type-test.d.ts.map +1 -0
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 = "5.4.0-alpha.
|
|
3
|
+
const version = "5.4.0-alpha.151";
|
|
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/-private.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"-private.js","sources":["../src/-private.ts"],"sourcesContent":["// in testing mode, we utilize globals to ensure only one copy exists of\n// these maps, due to bugs in ember-auto-import\nimport { DEBUG, TESTING } from '@warp-drive/build-config/env';\n\nimport { name, version } from '../package.json';\n\ntype UniversalTransientKey =\n // @ember-data/request\n 'REQ_ID';\n\ntype UniversalKey =\n | `(transient) ${UniversalTransientKey}`\n // @ember-data/request\n | 'RequestMap'\n | 'PromiseCache'\n | 'RequestCache'\n // @warp-drive/core-types/request\n | 'SkipCache'\n | 'EnableHydration';\n\ntype TransientKey =\n // @ember-data/tracking\n | 'TRANSACTION'\n // @ember-data/graph\n | 'transactionRef'\n // @ember-data/store\n | 'configuredGenerationMethod'\n | 'configuredUpdateMethod'\n | 'configuredForgetMethod'\n | 'configuredResetMethod'\n | 'configuredKeyInfoMethod';\n\ntype GlobalKey =\n | `(transient) ${TransientKey}`\n // @ember-data/adapter\n | 'AdapterError'\n | 'InvalidError'\n | 'TimeoutError'\n | 'AbortError'\n | 'UnauthorizedError'\n | 'ForbiddenError'\n | 'NotFoundError'\n | 'ConflictError'\n | 'ServerError'\n // @ember-data/tracking\n | 'Signals'\n // @ember-data/store LegacySupport\n | 'AvailableShims'\n // @ember-data/store RecordArrayManager\n | 'FAKE_ARR'\n // @ember-data/store IdentifierArray\n | '#signal'\n | '#source'\n | '#update'\n | '#notify'\n | 'IS_COLLECTION'\n // @ember-data/store RequestCache\n | 'Touching'\n | 'RequestPromise'\n // @ember-data/legacy-compat FetchManager\n | 'SaveOp'\n // @ember-data/model\n | 'LEGACY_SUPPORT'\n | 'LegacySupport'\n // @ember-data/graph\n | 'Graphs'\n // @ember-data/request\n | 'IS_FROZEN'\n | 'IS_CACHE_HANDLER'\n // @ember-data/request-utils\n | 'CONFIG'\n // @ember-data/store IdentityCache\n | 'DEBUG_MAP'\n | 'IDENTIFIERS'\n | 'DOCUMENTS'\n // @ember-data/store InstanceCache\n | 'CacheForIdentifierCache'\n | 'RecordCache'\n | 'StoreMap'\n // @warp-drive/core-types/symbols\n | 'Store'\n | '$type'\n | 'TransformName'\n | 'RequestSignature'\n // @warp-drive/core-types/request\n | 'IS_FUTURE'\n | 'DOC'\n // @warp-drive/schema-record\n | 'ManagedArrayMap'\n | 'ManagedObjectMap'\n | 'Support'\n | 'SOURCE'\n | 'MUTATE'\n | 'ARRAY_SIGNAL'\n | 'OBJECT_SIGNAL'\n | 'NOTIFY'\n | 'Destroy'\n | 'Identifier'\n | 'Editable'\n | 'EmbeddedPath'\n | 'EmbeddedType'\n | 'Parent'\n | 'Checkout'\n | 'Legacy';\n\ntype ModuleScopedCaches = Record<GlobalKey, unknown>;\n\nconst GlobalRef = globalThis as unknown as Record<\n string,\n {\n __warpDrive_ModuleScopedCaches?: ModuleScopedCaches;\n __warpDrive_hasOtherCopy?: boolean;\n __version: string;\n }\n> & {\n __warpDrive_universalCache: Record<UniversalKey, unknown>;\n};\nconst UniversalCache = (GlobalRef.__warpDrive_universalCache =\n GlobalRef.__warpDrive_universalCache ?? ({} as Record<UniversalKey, unknown>));\n\n// in order to support mirror packages, we ensure that each\n// unique package name has its own global cache\nGlobalRef[name] = GlobalRef[name] ?? { __version: version };\nconst GlobalSink = GlobalRef[name];\n\nif (DEBUG) {\n if (GlobalSink.__version !== version) {\n throw new Error('Multiple versions of WarpDrive detected, the application will malfunction.');\n }\n}\n\nconst ModuleScopedCaches = GlobalSink.__warpDrive_ModuleScopedCaches ?? ({} as ModuleScopedCaches);\nif (TESTING) {\n if (!GlobalSink.__warpDrive_ModuleScopedCaches) {\n GlobalSink.__warpDrive_ModuleScopedCaches = ModuleScopedCaches;\n } else {\n // eslint-disable-next-line no-console\n console.warn(`\nMultiple copies of EmberData have been detected. This may be due to a bug in ember-auto-import\n in which test assets get their own copy of some v2-addons. This can cause the application to\n malfunction as each copy will maintain its own separate state.`);\n }\n} else {\n if (GlobalSink.__warpDrive_hasOtherCopy) {\n throw new Error('Multiple copies of EmberData detected, the application will malfunction.');\n }\n GlobalSink.__warpDrive_hasOtherCopy = true;\n}\n\ntype UniqueSymbol<T extends string> = `___(unique) Symbol(${T})`;\ntype UniqueSymbolOr<T, K extends string> = T extends symbol ? UniqueSymbol<K> : T;\n\nexport function getOrSetGlobal<T, K extends GlobalKey>(key: K, value: T): UniqueSymbolOr<T, K> {\n if (TESTING) {\n const existing = ModuleScopedCaches[key];\n if (existing === undefined) {\n return (ModuleScopedCaches[key] = value) as UniqueSymbolOr<T, K>;\n } else {\n return existing as UniqueSymbolOr<T, K>;\n }\n } else {\n return value as UniqueSymbolOr<T, K>;\n }\n}\n\nexport function peekTransient<T>(key: TransientKey): T | null {\n const globalKey: `(transient) ${TransientKey}` = `(transient) ${key}`;\n return (ModuleScopedCaches[globalKey] as T) ?? null;\n}\n\nexport function setTransient<T>(key: TransientKey, value: T): T {\n const globalKey: `(transient) ${TransientKey}` = `(transient) ${key}`;\n return (ModuleScopedCaches[globalKey] = value);\n}\n\nexport function getOrSetUniversal<T, K extends UniversalKey>(key: K, value: T): UniqueSymbolOr<T, K> {\n if (TESTING) {\n const existing = UniversalCache[key];\n if (existing === undefined) {\n return (UniversalCache[key] = value) as UniqueSymbolOr<T, K>;\n } else {\n return existing as UniqueSymbolOr<T, K>;\n }\n } else {\n return value as UniqueSymbolOr<T, K>;\n }\n}\n\nexport function peekUniversalTransient<T>(key: UniversalTransientKey): T | null {\n const globalKey: `(transient) ${UniversalTransientKey}` = `(transient) ${key}`;\n return (UniversalCache[globalKey] as T) ?? null;\n}\n\nexport function setUniversalTransient<T>(key: UniversalTransientKey, value: T): T {\n const globalKey: `(transient) ${UniversalTransientKey}` = `(transient) ${key}`;\n return (UniversalCache[globalKey] = value);\n}\n"],"names":["GlobalRef","globalThis","UniversalCache","__warpDrive_universalCache","name","__version","version","GlobalSink","macroCondition","getGlobalConfig","WarpDrive","env","DEBUG","Error","ModuleScopedCaches","__warpDrive_ModuleScopedCaches","TESTING","console","warn","__warpDrive_hasOtherCopy","getOrSetGlobal","key","value","existing","undefined","peekTransient","globalKey","setTransient","getOrSetUniversal","peekUniversalTransient","setUniversalTransient"],"mappings":";;;;;AAAA;AACA;;
|
|
1
|
+
{"version":3,"file":"-private.js","sources":["../src/-private.ts"],"sourcesContent":["// in testing mode, we utilize globals to ensure only one copy exists of\n// these maps, due to bugs in ember-auto-import\nimport { DEBUG, TESTING } from '@warp-drive/build-config/env';\n\nimport { name, version } from '../package.json';\n\ntype UniversalTransientKey =\n // @ember-data/request\n 'REQ_ID';\n\ntype UniversalKey =\n | `(transient) ${UniversalTransientKey}`\n // @ember-data/request\n | 'RequestMap'\n | 'PromiseCache'\n | 'RequestCache'\n // @warp-drive/core-types/request\n | 'SkipCache'\n | 'EnableHydration'\n // @warp-drive/core-types/runtime\n | 'WarpDriveRuntimeConfig';\n\ntype TransientKey =\n // @ember-data/tracking\n | 'TRANSACTION'\n // @ember-data/graph\n | 'transactionRef'\n // @ember-data/store\n | 'configuredGenerationMethod'\n | 'configuredUpdateMethod'\n | 'configuredForgetMethod'\n | 'configuredResetMethod'\n | 'configuredKeyInfoMethod';\n\ntype GlobalKey =\n | `(transient) ${TransientKey}`\n // @ember-data/adapter\n | 'AdapterError'\n | 'InvalidError'\n | 'TimeoutError'\n | 'AbortError'\n | 'UnauthorizedError'\n | 'ForbiddenError'\n | 'NotFoundError'\n | 'ConflictError'\n | 'ServerError'\n // @ember-data/tracking\n | 'Signals'\n // @ember-data/store LegacySupport\n | 'AvailableShims'\n // @ember-data/store RecordArrayManager\n | 'FAKE_ARR'\n // @ember-data/store IdentifierArray\n | '#signal'\n | '#source'\n | '#update'\n | '#notify'\n | 'IS_COLLECTION'\n // @ember-data/store RequestCache\n | 'Touching'\n | 'RequestPromise'\n // @ember-data/legacy-compat FetchManager\n | 'SaveOp'\n // @ember-data/model\n | 'LEGACY_SUPPORT'\n | 'LegacySupport'\n // @ember-data/graph\n | 'Graphs'\n // @ember-data/request\n | 'IS_FROZEN'\n | 'IS_CACHE_HANDLER'\n // @ember-data/request-utils\n | 'CONFIG'\n // @ember-data/store IdentityCache\n | 'DEBUG_MAP'\n | 'IDENTIFIERS'\n | 'DOCUMENTS'\n // @ember-data/store InstanceCache\n | 'CacheForIdentifierCache'\n | 'RecordCache'\n | 'StoreMap'\n // @warp-drive/core-types/symbols\n | 'Store'\n | '$type'\n | 'TransformName'\n | 'RequestSignature'\n // @warp-drive/core-types/request\n | 'IS_FUTURE'\n | 'DOC'\n // @warp-drive/schema-record\n | 'ManagedArrayMap'\n | 'ManagedObjectMap'\n | 'Support'\n | 'SOURCE'\n | 'MUTATE'\n | 'ARRAY_SIGNAL'\n | 'OBJECT_SIGNAL'\n | 'NOTIFY'\n | 'Destroy'\n | 'Identifier'\n | 'Editable'\n | 'EmbeddedPath'\n | 'EmbeddedType'\n | 'Parent'\n | 'Checkout'\n | 'Legacy';\n\ntype ModuleScopedCaches = Record<GlobalKey, unknown>;\n\nconst GlobalRef = globalThis as unknown as Record<\n string,\n {\n __warpDrive_ModuleScopedCaches?: ModuleScopedCaches;\n __warpDrive_hasOtherCopy?: boolean;\n __version: string;\n }\n> & {\n __warpDrive_universalCache: Record<UniversalKey, unknown>;\n};\nconst UniversalCache = (GlobalRef.__warpDrive_universalCache =\n GlobalRef.__warpDrive_universalCache ?? ({} as Record<UniversalKey, unknown>));\n\n// in order to support mirror packages, we ensure that each\n// unique package name has its own global cache\nGlobalRef[name] = GlobalRef[name] ?? { __version: version };\nconst GlobalSink = GlobalRef[name];\n\nif (DEBUG) {\n if (GlobalSink.__version !== version) {\n throw new Error('Multiple versions of WarpDrive detected, the application will malfunction.');\n }\n}\n\nconst ModuleScopedCaches = GlobalSink.__warpDrive_ModuleScopedCaches ?? ({} as ModuleScopedCaches);\nif (TESTING) {\n if (!GlobalSink.__warpDrive_ModuleScopedCaches) {\n GlobalSink.__warpDrive_ModuleScopedCaches = ModuleScopedCaches;\n } else {\n // eslint-disable-next-line no-console\n console.warn(`\nMultiple copies of EmberData have been detected. This may be due to a bug in ember-auto-import\n in which test assets get their own copy of some v2-addons. This can cause the application to\n malfunction as each copy will maintain its own separate state.`);\n }\n} else {\n if (GlobalSink.__warpDrive_hasOtherCopy) {\n throw new Error('Multiple copies of EmberData detected, the application will malfunction.');\n }\n GlobalSink.__warpDrive_hasOtherCopy = true;\n}\n\ntype UniqueSymbol<T extends string> = `___(unique) Symbol(${T})`;\ntype UniqueSymbolOr<T, K extends string> = T extends symbol ? UniqueSymbol<K> : T;\n\nexport function getOrSetGlobal<T, K extends GlobalKey>(key: K, value: T): UniqueSymbolOr<T, K> {\n if (TESTING) {\n const existing = ModuleScopedCaches[key];\n if (existing === undefined) {\n return (ModuleScopedCaches[key] = value) as UniqueSymbolOr<T, K>;\n } else {\n return existing as UniqueSymbolOr<T, K>;\n }\n } else {\n return value as UniqueSymbolOr<T, K>;\n }\n}\n\nexport function peekTransient<T>(key: TransientKey): T | null {\n const globalKey: `(transient) ${TransientKey}` = `(transient) ${key}`;\n return (ModuleScopedCaches[globalKey] as T) ?? null;\n}\n\nexport function setTransient<T>(key: TransientKey, value: T): T {\n const globalKey: `(transient) ${TransientKey}` = `(transient) ${key}`;\n return (ModuleScopedCaches[globalKey] = value);\n}\n\nexport function getOrSetUniversal<T, K extends UniversalKey>(key: K, value: T): UniqueSymbolOr<T, K> {\n if (TESTING) {\n const existing = UniversalCache[key];\n if (existing === undefined) {\n return (UniversalCache[key] = value) as UniqueSymbolOr<T, K>;\n } else {\n return existing as UniqueSymbolOr<T, K>;\n }\n } else {\n return value as UniqueSymbolOr<T, K>;\n }\n}\n\nexport function peekUniversalTransient<T>(key: UniversalTransientKey): T | null {\n const globalKey: `(transient) ${UniversalTransientKey}` = `(transient) ${key}`;\n return (UniversalCache[globalKey] as T) ?? null;\n}\n\nexport function setUniversalTransient<T>(key: UniversalTransientKey, value: T): T {\n const globalKey: `(transient) ${UniversalTransientKey}` = `(transient) ${key}`;\n return (UniversalCache[globalKey] = value);\n}\n"],"names":["GlobalRef","globalThis","UniversalCache","__warpDrive_universalCache","name","__version","version","GlobalSink","macroCondition","getGlobalConfig","WarpDrive","env","DEBUG","Error","ModuleScopedCaches","__warpDrive_ModuleScopedCaches","TESTING","console","warn","__warpDrive_hasOtherCopy","getOrSetGlobal","key","value","existing","undefined","peekTransient","globalKey","setTransient","getOrSetUniversal","peekUniversalTransient","setUniversalTransient"],"mappings":";;;;;AAAA;AACA;;AA4GA,MAAMA,SAAS,GAAGC,UASjB;AACD,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A;AAC9E,EAAA,OAAQnB,cAAc,CAACwB,SAAS,CAAC,GAAGJ,KAAK;AAC3C;;;;"}
|
package/dist/runtime.js
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { getOrSetUniversal } from "./-private.js";
|
|
2
|
+
const RuntimeConfig = getOrSetUniversal('WarpDriveRuntimeConfig', {
|
|
3
|
+
debug: {}
|
|
4
|
+
});
|
|
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');
|
|
16
|
+
if (settings) {
|
|
17
|
+
Object.assign(RuntimeConfig, JSON.parse(settings));
|
|
18
|
+
}
|
|
19
|
+
function getRuntimeConfig() {
|
|
20
|
+
return RuntimeConfig;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Upserts the specified logging configuration into the runtime
|
|
25
|
+
* config.
|
|
26
|
+
*
|
|
27
|
+
* globalThis.setWarpDriveLogging({ LOG_PAYLOADS: true } });
|
|
28
|
+
*
|
|
29
|
+
* @typedoc
|
|
30
|
+
*/
|
|
31
|
+
function setLogging(config) {
|
|
32
|
+
Object.assign(RuntimeConfig.debug, config);
|
|
33
|
+
storage?.setItem('WarpDriveRuntimeConfig', JSON.stringify(RuntimeConfig));
|
|
34
|
+
}
|
|
35
|
+
export { getRuntimeConfig, setLogging };
|
|
@@ -0,0 +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\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_PAYLOADS: 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,68 @@
|
|
|
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
|
|
51
|
+
*/
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* A field that can be used to alias one key to another
|
|
55
|
+
* key present in the cache version of the resource.
|
|
56
|
+
*
|
|
57
|
+
* Unlike DerivedField, an AliasField may write to its
|
|
58
|
+
* source when a record is in an editable mode.
|
|
59
|
+
*
|
|
60
|
+
* AliasFields may utilize a transform, specified by type,
|
|
61
|
+
* to pre/post process the field.
|
|
62
|
+
*
|
|
63
|
+
* An AliasField may also specify a `kind` via options.
|
|
64
|
+
* `kind` may be any other valid field kind other than
|
|
65
|
+
*
|
|
66
|
+
* - `@hash`
|
|
67
|
+
* - `@id`
|
|
68
|
+
* - `@local`
|
|
69
|
+
* - `derived`
|
|
70
|
+
*
|
|
71
|
+
* This allows an AliasField to rename any field in the cache.
|
|
72
|
+
*
|
|
73
|
+
* Alias fields are generally intended to be used to support migrating
|
|
74
|
+
* between different schemas, though there are times where they are useful
|
|
75
|
+
* as a form of advanced derivation when used with a transform. For instance,
|
|
76
|
+
* an AliasField could be used to expose both a string and a Date version of the
|
|
77
|
+
* same field, with both being capable of being written to.
|
|
78
|
+
*
|
|
79
|
+
* @class <Type> PolarisAliasField
|
|
80
|
+
* @public
|
|
81
|
+
*/
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* A field that can be used to alias one key to another
|
|
85
|
+
* key present in the cache version of the resource.
|
|
86
|
+
*
|
|
87
|
+
* Unlike DerivedField, an AliasField may write to its
|
|
88
|
+
* source when a record is in an editable mode.
|
|
89
|
+
*
|
|
90
|
+
* AliasFields may utilize a transform, specified by type,
|
|
91
|
+
* to pre/post process the field.
|
|
92
|
+
*
|
|
93
|
+
* An AliasField may also specify a `kind` via options.
|
|
94
|
+
* `kind` may be any other valid field kind other than
|
|
95
|
+
*
|
|
96
|
+
* - `@hash`
|
|
97
|
+
* - `@id`
|
|
98
|
+
* - `@local`
|
|
99
|
+
* - `derived`
|
|
100
|
+
*
|
|
101
|
+
* This allows an AliasField to rename any field in the cache.
|
|
102
|
+
*
|
|
103
|
+
* Alias fields are generally intended to be used to support migrating
|
|
104
|
+
* between different schemas, though there are times where they are useful
|
|
105
|
+
* as a form of advanced derivation when used with a transform. For instance,
|
|
106
|
+
* an AliasField could be used to expose both a string and a Date version of the
|
|
107
|
+
* same field, with both being capable of being written to.
|
|
108
|
+
*
|
|
109
|
+
* @class <Type> ObjectAliasField
|
|
110
|
+
* @public
|
|
49
111
|
*/
|
|
50
112
|
|
|
51
113
|
/**
|
|
@@ -60,7 +122,8 @@
|
|
|
60
122
|
* 'uuid', 'urn' or 'entityUrn' or 'primaryKey' as their
|
|
61
123
|
* primary key field instead of 'id'.
|
|
62
124
|
*
|
|
63
|
-
* @
|
|
125
|
+
* @class <Type> IdentityField
|
|
126
|
+
* @public
|
|
64
127
|
*/
|
|
65
128
|
|
|
66
129
|
/**
|
|
@@ -84,7 +147,8 @@
|
|
|
84
147
|
* it should be placed in the `ResourceSchema`'s `@id` field
|
|
85
148
|
* in place of an `IdentityField`.
|
|
86
149
|
*
|
|
87
|
-
* @
|
|
150
|
+
* @class <Type> HashField
|
|
151
|
+
* @public
|
|
88
152
|
*/
|
|
89
153
|
|
|
90
154
|
/**
|
|
@@ -103,8 +167,8 @@
|
|
|
103
167
|
* For this reason Local fields should be used sparingly.
|
|
104
168
|
*
|
|
105
169
|
* Currently, while we document this feature here,
|
|
106
|
-
* only allow our own SchemaRecord
|
|
107
|
-
* 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.
|
|
108
172
|
*
|
|
109
173
|
* Example use cases that drove the creation of local
|
|
110
174
|
* fields are states like `isDestroying` and `isDestroyed`
|
|
@@ -114,7 +178,8 @@
|
|
|
114
178
|
*
|
|
115
179
|
* Don't make us regret this decision.
|
|
116
180
|
*
|
|
117
|
-
* @
|
|
181
|
+
* @class <Type> LocalField
|
|
182
|
+
* @public
|
|
118
183
|
*/
|
|
119
184
|
|
|
120
185
|
/**
|
|
@@ -126,7 +191,8 @@
|
|
|
126
191
|
* if the key/value pairs have well-defined shape,
|
|
127
192
|
* use 'schema-object' instead.
|
|
128
193
|
*
|
|
129
|
-
* @
|
|
194
|
+
* @class <Type> ObjectField
|
|
195
|
+
* @public
|
|
130
196
|
*/
|
|
131
197
|
|
|
132
198
|
/**
|
|
@@ -137,7 +203,8 @@
|
|
|
137
203
|
* If the object's structure is not well-defined,
|
|
138
204
|
* use 'object' instead.
|
|
139
205
|
*
|
|
140
|
-
* @
|
|
206
|
+
* @class <Type> SchemaObjectField
|
|
207
|
+
* @public
|
|
141
208
|
*/
|
|
142
209
|
|
|
143
210
|
/**
|
|
@@ -147,7 +214,8 @@
|
|
|
147
214
|
* If the array's elements are not primitive
|
|
148
215
|
* values, use 'schema-array' instead.
|
|
149
216
|
*
|
|
150
|
-
* @
|
|
217
|
+
* @class <Type> ArrayField
|
|
218
|
+
* @public
|
|
151
219
|
*/
|
|
152
220
|
|
|
153
221
|
/**
|
|
@@ -158,7 +226,8 @@
|
|
|
158
226
|
* If the array's elements are not well-defined,
|
|
159
227
|
* use 'array' instead.
|
|
160
228
|
*
|
|
161
|
-
* @
|
|
229
|
+
* @class <Type> SchemaArrayField
|
|
230
|
+
* @public
|
|
162
231
|
*/
|
|
163
232
|
|
|
164
233
|
/**
|
|
@@ -175,14 +244,19 @@
|
|
|
175
244
|
* or that require access to related resources
|
|
176
245
|
* that may not be loaded should be avoided.
|
|
177
246
|
*
|
|
178
|
-
* @
|
|
247
|
+
* @class <Type> DerivedField
|
|
248
|
+
* @public
|
|
179
249
|
*/
|
|
180
250
|
|
|
181
251
|
/**
|
|
182
252
|
* Represents a field that is a reference to
|
|
183
253
|
* another resource.
|
|
184
254
|
*
|
|
185
|
-
*
|
|
255
|
+
* SUPPORT FOR THIS FEATURE IS NOT YET IMPLEMENTED
|
|
256
|
+
* BY SchemaRecord
|
|
257
|
+
*
|
|
258
|
+
* @class <Type> ResourceField
|
|
259
|
+
* @public
|
|
186
260
|
*/
|
|
187
261
|
|
|
188
262
|
/**
|
|
@@ -190,12 +264,17 @@
|
|
|
190
264
|
* a collection of other resources, potentially
|
|
191
265
|
* paginate.
|
|
192
266
|
*
|
|
193
|
-
*
|
|
267
|
+
* SUPPORT FOR THIS FEATURE IS NOT YET IMPLEMENTED
|
|
268
|
+
* BY SchemaRecord
|
|
269
|
+
*
|
|
270
|
+
* @class <Type> CollectionField
|
|
271
|
+
* @public
|
|
194
272
|
*/
|
|
195
273
|
|
|
196
274
|
/**
|
|
197
275
|
* > [!CAUTION]
|
|
198
276
|
* > This Field is LEGACY
|
|
277
|
+
* > It cannot be used with PolarisMode
|
|
199
278
|
*
|
|
200
279
|
* A generic "field" that can be used to define
|
|
201
280
|
* primitive value fields.
|
|
@@ -207,7 +286,8 @@
|
|
|
207
286
|
* that a serializer *might* use, but their usage
|
|
208
287
|
* is not guaranteed.
|
|
209
288
|
*
|
|
210
|
-
* @
|
|
289
|
+
* @class <Type> LegacyAttributeField
|
|
290
|
+
* @public
|
|
211
291
|
*/
|
|
212
292
|
|
|
213
293
|
/**
|
|
@@ -219,7 +299,21 @@
|
|
|
219
299
|
*
|
|
220
300
|
* This is the legacy version of the `ResourceField`.
|
|
221
301
|
*
|
|
222
|
-
* @
|
|
302
|
+
* @class <Type> LegacyBelongsToField
|
|
303
|
+
* @public
|
|
304
|
+
*/
|
|
305
|
+
|
|
306
|
+
/**
|
|
307
|
+
* > [!CAUTION]
|
|
308
|
+
* > This Field is LEGACY
|
|
309
|
+
*
|
|
310
|
+
* Represents a field that is a reference to
|
|
311
|
+
* another resource.
|
|
312
|
+
*
|
|
313
|
+
* This is the legacy version of the `ResourceField`.
|
|
314
|
+
*
|
|
315
|
+
* @class <Type> LinksModeBelongsToField
|
|
316
|
+
* @public
|
|
223
317
|
*/
|
|
224
318
|
|
|
225
319
|
/**
|
|
@@ -231,15 +325,119 @@
|
|
|
231
325
|
*
|
|
232
326
|
* This is the legacy version of the `CollectionField`.
|
|
233
327
|
*
|
|
234
|
-
* @
|
|
328
|
+
* @class <Type> LegacyHasManyField
|
|
329
|
+
* @public
|
|
330
|
+
*/
|
|
331
|
+
|
|
332
|
+
/**
|
|
333
|
+
* > [!CAUTION]
|
|
334
|
+
* > This Field is LEGACY
|
|
335
|
+
*
|
|
336
|
+
* Represents a field that is a reference to
|
|
337
|
+
* a collection of other resources.
|
|
338
|
+
*
|
|
339
|
+
* This is the legacy version of the `CollectionField`.
|
|
340
|
+
*
|
|
341
|
+
* @class <Type> LinksModeHasManyField
|
|
342
|
+
* @public
|
|
343
|
+
*/
|
|
344
|
+
|
|
345
|
+
/**
|
|
346
|
+
* A union of all possible LegacyMode field schemas.
|
|
347
|
+
*
|
|
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
|
|
235
366
|
*/
|
|
236
367
|
|
|
237
368
|
/**
|
|
238
|
-
*
|
|
369
|
+
* A union of all possible PolarisMode field schemas.
|
|
370
|
+
*
|
|
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
|
|
388
|
+
*/
|
|
389
|
+
|
|
390
|
+
/**
|
|
391
|
+
* A union of all possible LegacyMode and PolarisMode
|
|
392
|
+
* field schemas.
|
|
393
|
+
*
|
|
394
|
+
* You likely will want to use PolarisModeFieldSchema,
|
|
395
|
+
* LegacyModeFieldSchema, or ObjectFieldSchema instead
|
|
396
|
+
* as appropriate as they are more specific and will
|
|
397
|
+
* provide better guidance around what is valid.
|
|
398
|
+
*
|
|
399
|
+
* @class <Type> FieldSchema
|
|
400
|
+
* @public
|
|
401
|
+
*/
|
|
402
|
+
|
|
403
|
+
/**
|
|
404
|
+
* A union of all possible field schemas that can be
|
|
405
|
+
* used in an ObjectSchema.
|
|
406
|
+
*
|
|
407
|
+
* @class <Type> ObjectFieldSchema
|
|
408
|
+
* @public
|
|
409
|
+
*/
|
|
410
|
+
|
|
411
|
+
/**
|
|
412
|
+
* Represents a schema for a primary resource in PolarisMode.
|
|
239
413
|
*
|
|
240
414
|
* Primary resources are objects with a unique identity of their
|
|
241
|
-
* own which may allow them to appear in relationships, or
|
|
242
|
-
* response
|
|
415
|
+
* own which may allow them to appear in relationships, or in multiple
|
|
416
|
+
* response documents.
|
|
417
|
+
*
|
|
418
|
+
* @class <Type> PolarisResourceSchema
|
|
419
|
+
* @public
|
|
420
|
+
*/
|
|
421
|
+
|
|
422
|
+
/**
|
|
423
|
+
* Represents a schema for a primary resource in LegacyMode
|
|
424
|
+
*
|
|
425
|
+
* Primary resources are objects with a unique identity of their
|
|
426
|
+
* own which may allow them to appear in relationships, or in multiple
|
|
427
|
+
* response documents.
|
|
428
|
+
*
|
|
429
|
+
* @class <Type> LegacyResourceSchema
|
|
430
|
+
* @public
|
|
431
|
+
*/
|
|
432
|
+
|
|
433
|
+
/**
|
|
434
|
+
* A type which represents a valid JSON schema
|
|
435
|
+
* definition for either a PolarisMode or a
|
|
436
|
+
* LegacyMode resource.
|
|
437
|
+
*
|
|
438
|
+
* Note, this is separate from the type returned
|
|
439
|
+
* by the SchemaService which provides fields as a Map
|
|
440
|
+
* instead of as an Array.
|
|
243
441
|
*
|
|
244
442
|
* @typedoc
|
|
245
443
|
*/
|
|
@@ -250,7 +448,8 @@
|
|
|
250
448
|
*
|
|
251
449
|
* ObjectSchemas may not currently contain relationships.
|
|
252
450
|
*
|
|
253
|
-
* @
|
|
451
|
+
* @class <Type> ObjectSchema
|
|
452
|
+
* @public
|
|
254
453
|
*/
|
|
255
454
|
|
|
256
455
|
/**
|
|
@@ -267,7 +466,7 @@
|
|
|
267
466
|
* @static
|
|
268
467
|
* @for @warp-drive/core-types
|
|
269
468
|
* @param {ResourceSchema} schema
|
|
270
|
-
* @
|
|
469
|
+
* @return {ResourceSchema} the passed in schema
|
|
271
470
|
* @public
|
|
272
471
|
*/
|
|
273
472
|
function resourceSchema(schema) {
|
|
@@ -284,7 +483,7 @@ function resourceSchema(schema) {
|
|
|
284
483
|
* @static
|
|
285
484
|
* @for @warp-drive/core-types
|
|
286
485
|
* @param {ObjectSchema} schema
|
|
287
|
-
* @
|
|
486
|
+
* @return {ObjectSchema} the passed in schema
|
|
288
487
|
* @public
|
|
289
488
|
*/
|
|
290
489
|
function objectSchema(schema) {
|
|
@@ -298,10 +497,24 @@ function objectSchema(schema) {
|
|
|
298
497
|
* @static
|
|
299
498
|
* @for @warp-drive/core-types
|
|
300
499
|
* @param schema
|
|
301
|
-
* @
|
|
500
|
+
* @return {boolean}
|
|
302
501
|
* @public
|
|
303
502
|
*/
|
|
304
503
|
function isResourceSchema(schema) {
|
|
305
504
|
return schema?.identity?.kind === '@id';
|
|
306
505
|
}
|
|
307
|
-
|
|
506
|
+
|
|
507
|
+
/**
|
|
508
|
+
* A type utility to narrow a schema to LegacyResourceSchema
|
|
509
|
+
*
|
|
510
|
+
* @method isLegacyResourceSchema
|
|
511
|
+
* @static
|
|
512
|
+
* @for @warp-drive/core-types
|
|
513
|
+
* @param schema
|
|
514
|
+
* @return {boolean}
|
|
515
|
+
* @public
|
|
516
|
+
*/
|
|
517
|
+
function isLegacyResourceSchema(schema) {
|
|
518
|
+
return isResourceSchema(schema) && schema.legacy === true;
|
|
519
|
+
}
|
|
520
|
+
export { isLegacyResourceSchema, isResourceSchema, objectSchema, resourceSchema };
|