@warp-drive/core-types 4.13.0-alpha.5 → 4.13.0-alpha.7

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  import { macroCondition, getGlobalConfig } from '@embroider/macros';
2
2
  const name = "@warp-drive/core-types";
3
- const version = "4.13.0-alpha.5";
3
+ const version = "4.13.0-alpha.7";
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
@@ -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":"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"}
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":"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"}
@@ -7,12 +7,12 @@ import { macroCondition, getGlobalConfig } from '@embroider/macros';
7
7
  const DEBUG_CLIENT_ORIGINATED = Symbol('record-originated-on-client');
8
8
  const DEBUG_IDENTIFIER_BUCKET = Symbol('identifier-bucket');
9
9
  const DEBUG_STALE_CACHE_OWNER = Symbol('warpDriveStaleCache');
10
- function ProdSymbol(str) {
11
- return macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? Symbol(str) : str;
10
+ function ProdSymbol(str, debugStr) {
11
+ return macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? Symbol(debugStr) : str;
12
12
  }
13
13
 
14
14
  // also present in production
15
- const CACHE_OWNER = ProdSymbol('__$co');
15
+ const CACHE_OWNER = ProdSymbol('__$co', 'CACHE_OWNER');
16
16
 
17
17
  /**
18
18
  * An Identifier specific to a record which may or may not
@@ -1 +1 @@
1
- {"version":3,"file":"identifier.js","sources":["../src/identifier.ts"],"sourcesContent":["/**\n @module @ember-data/store\n*/\n\nimport { DEBUG } from '@warp-drive/build-config/env';\n\n// provided for additional debuggability\nexport const DEBUG_CLIENT_ORIGINATED: unique symbol = Symbol('record-originated-on-client');\nexport const DEBUG_IDENTIFIER_BUCKET: unique symbol = Symbol('identifier-bucket');\nexport const DEBUG_STALE_CACHE_OWNER: unique symbol = Symbol('warpDriveStaleCache');\n\nfunction ProdSymbol<T extends string>(str: T): T {\n return DEBUG ? (Symbol(str) as unknown as T) : str;\n}\n\n// also present in production\nexport const CACHE_OWNER: '__$co' = ProdSymbol('__$co');\n\nexport type IdentifierBucket = 'record' | 'document';\n\nexport interface Identifier {\n lid: string;\n clientId?: string;\n}\n\nexport interface ExistingRecordIdentifier<T extends string = string> extends Identifier {\n id: string;\n type: T;\n}\n\nexport interface NewRecordIdentifier<T extends string = string> extends Identifier {\n id: string | null;\n type: T;\n}\n\nexport type StableDocumentIdentifier = {\n lid: string;\n};\n\n/**\n * An Identifier specific to a record which may or may not\n * be present in the cache.\n *\n * The absence of an `id` DOES NOT indicate that this\n * Identifier is for a new client-created record as it\n * may also indicate that it was generated for a secondary\n * index and the primary `id` index is not yet known.\n *\n * @internal\n */\nexport type RecordIdentifier<T extends string = string> = ExistingRecordIdentifier<T> | NewRecordIdentifier<T>;\n\n/**\n * Used when an Identifier is known to be the stable version\n *\n * @internal\n */\nexport interface StableIdentifier extends Identifier {\n [DEBUG_IDENTIFIER_BUCKET]?: string;\n}\n\n/**\n * Used when a StableRecordIdentifier was not created locally as part\n * of a call to store.createRecord\n *\n * Distinguishing between this Identifier and one for a client created\n * record that was created with an ID is generally speaking not possible\n * at runtime, so anything with an ID typically narrows to this.\n *\n * @internal\n */\nexport interface StableExistingRecordIdentifier<T extends string = string> extends StableIdentifier {\n id: string;\n type: T;\n [DEBUG_CLIENT_ORIGINATED]?: boolean;\n [CACHE_OWNER]: number | undefined;\n [DEBUG_STALE_CACHE_OWNER]?: number | undefined;\n}\n\n/**\n * Used when a StableRecordIdentifier was created locally\n * (by a call to store.createRecord).\n *\n * It is possible in rare circumstances to have a StableRecordIdentifier\n * that is not for a new record but does not have an ID. This would\n * happen if a user intentionally created one for use with a secondary-index\n * prior to the record having been fully loaded.\n *\n * @internal\n */\nexport interface StableNewRecordIdentifier<T extends string = string> extends StableIdentifier {\n id: string | null;\n type: T;\n [DEBUG_CLIENT_ORIGINATED]?: boolean;\n [CACHE_OWNER]: number | undefined;\n [DEBUG_STALE_CACHE_OWNER]?: number | undefined;\n}\n\n/**\n * A referentially stable object with a unique string (lid) that can be used\n * as a reference to data in the cache.\n *\n * Every record instance has a unique identifier, and identifiers may refer\n * to data that has never been loaded (for instance, in an async relationship).\n *\n * @class StableRecordIdentifier\n * @public\n */\n\n/**\n * A string representing a unique identity.\n *\n * @property {string} lid\n * @public\n */\n/**\n * the primary resource `type` or `modelName` this identity belongs to.\n *\n * @property {string} type\n * @public\n */\n/**\n * the primary id for the record this identity belongs to. `null`\n * if not yet assigned an id.\n *\n * @property {string | null} id\n * @public\n */\nexport type StableRecordIdentifier<T extends string = string> =\n | StableExistingRecordIdentifier<T>\n | StableNewRecordIdentifier<T>;\n"],"names":["DEBUG_CLIENT_ORIGINATED","Symbol","DEBUG_IDENTIFIER_BUCKET","DEBUG_STALE_CACHE_OWNER","ProdSymbol","str","macroCondition","getGlobalConfig","WarpDrive","env","DEBUG","CACHE_OWNER"],"mappings":";;AAAA;AACA;AACA;AAIA;MACaA,uBAAsC,GAAGC,MAAM,CAAC,6BAA6B;MAC7EC,uBAAsC,GAAGD,MAAM,CAAC,mBAAmB;MACnEE,uBAAsC,GAAGF,MAAM,CAAC,qBAAqB;AAElF,SAASG,UAAUA,CAAmBC,GAAM,EAAK;AAC/C,EAAA,OAAOC,cAAA,CAAAC,eAAA,EAAA,CAAAC,SAAA,CAAAC,GAAA,CAAAC,KAAA,IAAST,MAAM,CAACI,GAAG,CAAC,GAAoBA,GAAG;AACpD;;AAEA;MACaM,WAAoB,GAAGP,UAAU,CAAC,OAAO;;AAuBtD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;;AAKA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AASA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AASA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;"}
1
+ {"version":3,"file":"identifier.js","sources":["../src/identifier.ts"],"sourcesContent":["/**\n @module @ember-data/store\n*/\n\nimport { DEBUG } from '@warp-drive/build-config/env';\n\n// provided for additional debuggability\nexport const DEBUG_CLIENT_ORIGINATED: unique symbol = Symbol('record-originated-on-client');\nexport const DEBUG_IDENTIFIER_BUCKET: unique symbol = Symbol('identifier-bucket');\nexport const DEBUG_STALE_CACHE_OWNER: unique symbol = Symbol('warpDriveStaleCache');\n\nfunction ProdSymbol<T extends string>(str: T, debugStr: string): T {\n return DEBUG ? (Symbol(debugStr) as unknown as T) : str;\n}\n\n// also present in production\nexport const CACHE_OWNER: '__$co' = ProdSymbol('__$co', 'CACHE_OWNER');\n\nexport type IdentifierBucket = 'record' | 'document';\n\nexport interface Identifier {\n lid: string;\n clientId?: string;\n}\n\nexport interface ExistingRecordIdentifier<T extends string = string> extends Identifier {\n id: string;\n type: T;\n}\n\nexport interface NewRecordIdentifier<T extends string = string> extends Identifier {\n id: string | null;\n type: T;\n}\n\nexport type StableDocumentIdentifier = {\n lid: string;\n};\n\n/**\n * An Identifier specific to a record which may or may not\n * be present in the cache.\n *\n * The absence of an `id` DOES NOT indicate that this\n * Identifier is for a new client-created record as it\n * may also indicate that it was generated for a secondary\n * index and the primary `id` index is not yet known.\n *\n * @internal\n */\nexport type RecordIdentifier<T extends string = string> = ExistingRecordIdentifier<T> | NewRecordIdentifier<T>;\n\n/**\n * Used when an Identifier is known to be the stable version\n *\n * @internal\n */\nexport interface StableIdentifier extends Identifier {\n [DEBUG_IDENTIFIER_BUCKET]?: string;\n}\n\n/**\n * Used when a StableRecordIdentifier was not created locally as part\n * of a call to store.createRecord\n *\n * Distinguishing between this Identifier and one for a client created\n * record that was created with an ID is generally speaking not possible\n * at runtime, so anything with an ID typically narrows to this.\n *\n * @internal\n */\nexport interface StableExistingRecordIdentifier<T extends string = string> extends StableIdentifier {\n id: string;\n type: T;\n [DEBUG_CLIENT_ORIGINATED]?: boolean;\n [CACHE_OWNER]: number | undefined;\n [DEBUG_STALE_CACHE_OWNER]?: number | undefined;\n}\n\n/**\n * Used when a StableRecordIdentifier was created locally\n * (by a call to store.createRecord).\n *\n * It is possible in rare circumstances to have a StableRecordIdentifier\n * that is not for a new record but does not have an ID. This would\n * happen if a user intentionally created one for use with a secondary-index\n * prior to the record having been fully loaded.\n *\n * @internal\n */\nexport interface StableNewRecordIdentifier<T extends string = string> extends StableIdentifier {\n id: string | null;\n type: T;\n [DEBUG_CLIENT_ORIGINATED]?: boolean;\n [CACHE_OWNER]: number | undefined;\n [DEBUG_STALE_CACHE_OWNER]?: number | undefined;\n}\n\n/**\n * A referentially stable object with a unique string (lid) that can be used\n * as a reference to data in the cache.\n *\n * Every record instance has a unique identifier, and identifiers may refer\n * to data that has never been loaded (for instance, in an async relationship).\n *\n * @class StableRecordIdentifier\n * @public\n */\n\n/**\n * A string representing a unique identity.\n *\n * @property {string} lid\n * @public\n */\n/**\n * the primary resource `type` or `modelName` this identity belongs to.\n *\n * @property {string} type\n * @public\n */\n/**\n * the primary id for the record this identity belongs to. `null`\n * if not yet assigned an id.\n *\n * @property {string | null} id\n * @public\n */\nexport type StableRecordIdentifier<T extends string = string> =\n | StableExistingRecordIdentifier<T>\n | StableNewRecordIdentifier<T>;\n"],"names":["DEBUG_CLIENT_ORIGINATED","Symbol","DEBUG_IDENTIFIER_BUCKET","DEBUG_STALE_CACHE_OWNER","ProdSymbol","str","debugStr","macroCondition","getGlobalConfig","WarpDrive","env","DEBUG","CACHE_OWNER"],"mappings":";;AAAA;AACA;AACA;AAIA;MACaA,uBAAsC,GAAGC,MAAM,CAAC,6BAA6B;MAC7EC,uBAAsC,GAAGD,MAAM,CAAC,mBAAmB;MACnEE,uBAAsC,GAAGF,MAAM,CAAC,qBAAqB;AAElF,SAASG,UAAUA,CAAmBC,GAAM,EAAEC,QAAgB,EAAK;AACjE,EAAA,OAAOC,cAAA,CAAAC,eAAA,EAAA,CAAAC,SAAA,CAAAC,GAAA,CAAAC,KAAA,IAASV,MAAM,CAACK,QAAQ,CAAC,GAAoBD,GAAG;AACzD;;AAEA;AACO,MAAMO,WAAoB,GAAGR,UAAU,CAAC,OAAO,EAAE,aAAa;;AAuBrE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;;AAKA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AASA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AASA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;"}
@@ -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;;;;"}
@@ -0,0 +1,520 @@
1
+ /**
2
+ * @module @warp-drive/core-types
3
+ */
4
+
5
+ /**
6
+ * A generic "field" that can be used to define
7
+ * primitive value fields.
8
+ *
9
+ * Replaces "attribute" for primitive value fields.
10
+ * Can also be used to eject from deep-tracking of
11
+ * objects or arrays.
12
+ *
13
+ * A major difference between "field" and "attribute"
14
+ * is that "type" points to a legacy transform on
15
+ * "attribute" that a serializer *might* use, while
16
+ * "type" points to a new-style transform on "field"
17
+ * that a record implmentation *must* use.
18
+ *
19
+ * @class <Type> GenericField
20
+ * @public
21
+ */
22
+
23
+ /**
24
+ * A field that can be used to alias one key to another
25
+ * key present in the cache version of the resource.
26
+ *
27
+ * Unlike DerivedField, an AliasField may write to its
28
+ * source when a record is in an editable mode.
29
+ *
30
+ * AliasFields may utilize a transform, specified by type,
31
+ * to pre/post process the field.
32
+ *
33
+ * An AliasField may also specify a `kind` via options.
34
+ * `kind` may be any other valid field kind other than
35
+ *
36
+ * - `@hash`
37
+ * - `@id`
38
+ * - `@local`
39
+ * - `derived`
40
+ *
41
+ * This allows an AliasField to rename any field in the cache.
42
+ *
43
+ * Alias fields are generally intended to be used to support migrating
44
+ * between different schemas, though there are times where they are useful
45
+ * as a form of advanced derivation when used with a transform. For instance,
46
+ * an AliasField could be used to expose both a string and a Date version of the
47
+ * same field, with both being capable of being written to.
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
111
+ */
112
+
113
+ /**
114
+ * Represents a field whose value is the primary
115
+ * key of the resource.
116
+ *
117
+ * This allows any field to serve as the primary
118
+ * key while still being able to drive identity
119
+ * needs within the system.
120
+ *
121
+ * This is useful for resources that use for instance
122
+ * 'uuid', 'urn' or 'entityUrn' or 'primaryKey' as their
123
+ * primary key field instead of 'id'.
124
+ *
125
+ * @class <Type> IdentityField
126
+ * @public
127
+ */
128
+
129
+ /**
130
+ * Represents a specialized field whose computed value
131
+ * will be used as the primary key of a schema-object
132
+ * for serializability and comparison purposes.
133
+ *
134
+ * This field functions similarly to derived fields in that
135
+ * it is non-settable, derived state but differs in that
136
+ * it is only able to compute off of cache state and is given
137
+ * no access to a record instance.
138
+ *
139
+ * This means that if a hashing function wants to compute its value
140
+ * taking into account transformations and derivations it must
141
+ * perform those itself.
142
+ *
143
+ * A schema-array can declare its "key" value to be `@hash` if
144
+ * a schema-object has such a field.
145
+ *
146
+ * Only one hash field is permittable per schema-object, and
147
+ * it should be placed in the `ResourceSchema`'s `@id` field
148
+ * in place of an `IdentityField`.
149
+ *
150
+ * @class <Type> HashField
151
+ * @public
152
+ */
153
+
154
+ /**
155
+ * Represents a field whose value is a local
156
+ * value that is not stored in the cache, nor
157
+ * is it sent to the server.
158
+ *
159
+ * Local fields can be written to, and their
160
+ * value is both memoized and reactive (though
161
+ * not deep-tracked).
162
+ *
163
+ * Because their state is not derived from the cache
164
+ * data or the server, they represent a divorced
165
+ * uncanonical source of state.
166
+ *
167
+ * For this reason Local fields should be used sparingly.
168
+ *
169
+ * Currently, while we document this feature here,
170
+ * only allow our own SchemaRecord default fields to
171
+ * utilize them and the feature should be considered private.
172
+ *
173
+ * Example use cases that drove the creation of local
174
+ * fields are states like `isDestroying` and `isDestroyed`
175
+ * which are specific to a record instance but not
176
+ * stored in the cache. We wanted to be able to drive
177
+ * these fields from schema the same as all other fields.
178
+ *
179
+ * Don't make us regret this decision.
180
+ *
181
+ * @class <Type> LocalField
182
+ * @public
183
+ */
184
+
185
+ /**
186
+ * Represents a field whose value is an object
187
+ * with keys pointing to values that are primitive
188
+ * values.
189
+ *
190
+ * If values of the keys are not primitives, or
191
+ * if the key/value pairs have well-defined shape,
192
+ * use 'schema-object' instead.
193
+ *
194
+ * @class <Type> ObjectField
195
+ * @public
196
+ */
197
+
198
+ /**
199
+ * Represents a field whose value is an object
200
+ * with a well-defined structure described by
201
+ * a non-resource schema.
202
+ *
203
+ * If the object's structure is not well-defined,
204
+ * use 'object' instead.
205
+ *
206
+ * @class <Type> SchemaObjectField
207
+ * @public
208
+ */
209
+
210
+ /**
211
+ * Represents a field whose value is an array
212
+ * of primitive values.
213
+ *
214
+ * If the array's elements are not primitive
215
+ * values, use 'schema-array' instead.
216
+ *
217
+ * @class <Type> ArrayField
218
+ * @public
219
+ */
220
+
221
+ /**
222
+ * Represents a field whose value is an array
223
+ * of objects with a well-defined structure
224
+ * described by a non-resource schema.
225
+ *
226
+ * If the array's elements are not well-defined,
227
+ * use 'array' instead.
228
+ *
229
+ * @class <Type> SchemaArrayField
230
+ * @public
231
+ */
232
+
233
+ /**
234
+ * Represents a field whose value is derived
235
+ * from other fields in the schema.
236
+ *
237
+ * The value is read-only, and is not stored
238
+ * in the cache, nor is it sent to the server.
239
+ *
240
+ * Usage of derived fields should be minimized
241
+ * to scenarios where the derivation is known
242
+ * to be safe. For instance, derivations that
243
+ * required fields that are not always loaded
244
+ * or that require access to related resources
245
+ * that may not be loaded should be avoided.
246
+ *
247
+ * @class <Type> DerivedField
248
+ * @public
249
+ */
250
+
251
+ /**
252
+ * Represents a field that is a reference to
253
+ * another resource.
254
+ *
255
+ * SUPPORT FOR THIS FEATURE IS NOT YET IMPLEMENTED
256
+ * BY SchemaRecord
257
+ *
258
+ * @class <Type> ResourceField
259
+ * @public
260
+ */
261
+
262
+ /**
263
+ * Represents a field that is a reference to
264
+ * a collection of other resources, potentially
265
+ * paginate.
266
+ *
267
+ * SUPPORT FOR THIS FEATURE IS NOT YET IMPLEMENTED
268
+ * BY SchemaRecord
269
+ *
270
+ * @class <Type> CollectionField
271
+ * @public
272
+ */
273
+
274
+ /**
275
+ * > [!CAUTION]
276
+ * > This Field is LEGACY
277
+ * > It cannot be used with PolarisMode
278
+ *
279
+ * A generic "field" that can be used to define
280
+ * primitive value fields.
281
+ *
282
+ * If the field points to an object or array,
283
+ * it will not be deep-tracked.
284
+ *
285
+ * Transforms when defined are legacy transforms
286
+ * that a serializer *might* use, but their usage
287
+ * is not guaranteed.
288
+ *
289
+ * @class <Type> LegacyAttributeField
290
+ * @public
291
+ */
292
+
293
+ /**
294
+ * > [!CAUTION]
295
+ * > This Field is LEGACY
296
+ *
297
+ * Represents a field that is a reference to
298
+ * another resource.
299
+ *
300
+ * This is the legacy version of the `ResourceField`.
301
+ *
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
317
+ */
318
+
319
+ /**
320
+ * > [!CAUTION]
321
+ * > This Field is LEGACY
322
+ *
323
+ * Represents a field that is a reference to
324
+ * a collection of other resources.
325
+ *
326
+ * This is the legacy version of the `CollectionField`.
327
+ *
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
366
+ */
367
+
368
+ /**
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.
413
+ *
414
+ * Primary resources are objects with a unique identity of their
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.
441
+ *
442
+ * @typedoc
443
+ */
444
+
445
+ /**
446
+ * Represents a schema for an object that is not
447
+ * a primary resource (has no unique identity of its own).
448
+ *
449
+ * ObjectSchemas may not currently contain relationships.
450
+ *
451
+ * @class <Type> ObjectSchema
452
+ * @public
453
+ */
454
+
455
+ /**
456
+ * A no-op type utility that enables type-checking resource schema
457
+ * definitions.
458
+ *
459
+ * Will return the passed in schema.
460
+ *
461
+ * This will not validate relationship inverses or related types,
462
+ * as doing so would require a full schema graph to be passed in
463
+ * and no cycles in the graph to be present.
464
+ *
465
+ * @method resourceSchema
466
+ * @static
467
+ * @for @warp-drive/core-types
468
+ * @param {ResourceSchema} schema
469
+ * @return {ResourceSchema} the passed in schema
470
+ * @public
471
+ */
472
+ function resourceSchema(schema) {
473
+ return schema;
474
+ }
475
+
476
+ /**
477
+ * A no-op type utility that enables type-checking object schema
478
+ * definitions.
479
+ *
480
+ * Will return the passed in schema.
481
+ *
482
+ * @method objectSchema
483
+ * @static
484
+ * @for @warp-drive/core-types
485
+ * @param {ObjectSchema} schema
486
+ * @return {ObjectSchema} the passed in schema
487
+ * @public
488
+ */
489
+ function objectSchema(schema) {
490
+ return schema;
491
+ }
492
+
493
+ /**
494
+ * A type utility to narrow a schema to a ResourceSchema
495
+ *
496
+ * @method isResourceSchema
497
+ * @static
498
+ * @for @warp-drive/core-types
499
+ * @param schema
500
+ * @return {boolean}
501
+ * @public
502
+ */
503
+ function isResourceSchema(schema) {
504
+ return schema?.identity?.kind === '@id';
505
+ }
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 };