@warp-drive/core-types 5.6.0-alpha.2 → 5.6.0-alpha.4
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/identifier.js +0 -3
- package/dist/identifier.js.map +1 -1
- package/dist/record.js +0 -10
- package/dist/record.js.map +1 -1
- package/dist/request.js +4 -5
- package/dist/request.js.map +1 -1
- package/dist/runtime.js +0 -1
- package/dist/runtime.js.map +1 -1
- package/dist/schema/fields.js +53 -70
- package/dist/schema/fields.js.map +1 -1
- package/dist/symbols.js +0 -8
- package/dist/symbols.js.map +1 -1
- package/package.json +3 -6
- package/unstable-preview-types/cache.d.ts +4 -41
- package/unstable-preview-types/cache.d.ts.map +1 -1
- package/unstable-preview-types/identifier.d.ts +2 -3
- package/unstable-preview-types/identifier.d.ts.map +1 -1
- package/unstable-preview-types/index.d.ts +16 -16
- package/unstable-preview-types/index.d.ts.map +1 -1
- package/unstable-preview-types/record.d.ts +0 -7
- package/unstable-preview-types/record.d.ts.map +1 -1
- package/unstable-preview-types/request.d.ts +14 -43
- package/unstable-preview-types/request.d.ts.map +1 -1
- package/unstable-preview-types/request.type-test.d.ts +4 -0
- package/unstable-preview-types/request.type-test.d.ts.map +1 -0
- package/unstable-preview-types/runtime.d.ts +0 -1
- package/unstable-preview-types/runtime.d.ts.map +1 -1
- package/unstable-preview-types/schema/fields.d.ts +55 -112
- package/unstable-preview-types/schema/fields.d.ts.map +1 -1
- package/unstable-preview-types/spec/json-api-raw.d.ts.map +1 -1
- package/unstable-preview-types/symbols.d.ts +0 -4
- package/unstable-preview-types/symbols.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 = "5.6.0-alpha.
|
|
3
|
+
const version = "5.6.0-alpha.4";
|
|
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/identifier.js
CHANGED
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
import { macroCondition, getGlobalConfig } from '@embroider/macros';
|
|
2
2
|
|
|
3
|
-
/**
|
|
4
|
-
@module @ember-data/store
|
|
5
|
-
*/
|
|
6
3
|
// provided for additional debuggability
|
|
7
4
|
const DEBUG_CLIENT_ORIGINATED = Symbol('record-originated-on-client');
|
|
8
5
|
const DEBUG_IDENTIFIER_BUCKET = Symbol('identifier-bucket');
|
package/dist/identifier.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"identifier.js","sources":["../src/identifier.ts"],"sourcesContent":["
|
|
1
|
+
{"version":3,"file":"identifier.js","sources":["../src/identifier.ts"],"sourcesContent":["import { 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};\nexport type RequestKey = StableDocumentIdentifier;\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 lid\n * @type {String}\n * @public\n */\n/**\n * the primary resource `type` or `modelName` this identity belongs to.\n *\n * @property type\n * @type {String}\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 id\n * @type {String | null}\n * @public\n */\nexport type StableRecordIdentifier<T extends string = string> =\n | StableExistingRecordIdentifier<T>\n | StableNewRecordIdentifier<T>;\n\nexport type ResourceKey<T extends string = string> = StableRecordIdentifier<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":";;AAEA;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;;AAwBrE;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;AACA;AACA;AACA;;;;"}
|
package/dist/record.js
CHANGED
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* @module @warp-drive/core-types
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
1
|
/**
|
|
6
2
|
* Records may be anything, They don't even
|
|
7
3
|
* have to be objects.
|
|
@@ -12,21 +8,18 @@
|
|
|
12
8
|
* intellisense.
|
|
13
9
|
*
|
|
14
10
|
* @class TypedRecordInstance
|
|
15
|
-
* @typedoc
|
|
16
11
|
*/
|
|
17
12
|
|
|
18
13
|
/**
|
|
19
14
|
* A type utility that extracts the Type if available,
|
|
20
15
|
* otherwise it returns never.
|
|
21
16
|
*
|
|
22
|
-
* @typedoc
|
|
23
17
|
*/
|
|
24
18
|
|
|
25
19
|
/**
|
|
26
20
|
* A type utility that extracts the Type if available,
|
|
27
21
|
* otherwise it returns string
|
|
28
22
|
*
|
|
29
|
-
* @typedoc
|
|
30
23
|
*/
|
|
31
24
|
|
|
32
25
|
/**
|
|
@@ -45,14 +38,12 @@
|
|
|
45
38
|
* There's a 90% chance this particular implementation belongs being in the JSON:API package instead
|
|
46
39
|
* of core-types, but it's here for now.
|
|
47
40
|
*
|
|
48
|
-
* @typedoc
|
|
49
41
|
*/
|
|
50
42
|
|
|
51
43
|
/**
|
|
52
44
|
* A utility that provides the union of all ResourceName for all potential
|
|
53
45
|
* includes for the given TypedRecordInstance.
|
|
54
46
|
*
|
|
55
|
-
* @typedoc
|
|
56
47
|
*/
|
|
57
48
|
|
|
58
49
|
// ToPaths<ExpandIgnore<T, true>, false>;
|
|
@@ -63,7 +54,6 @@
|
|
|
63
54
|
*
|
|
64
55
|
* Cyclical paths are filtered out.
|
|
65
56
|
*
|
|
66
|
-
* @typedoc
|
|
67
57
|
*/
|
|
68
58
|
|
|
69
59
|
function createIncludeValidator() {
|
package/dist/record.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"record.js","sources":["../src/record.ts"],"sourcesContent":["
|
|
1
|
+
{"version":3,"file":"record.js","sources":["../src/record.ts"],"sourcesContent":["import type { Type } from './symbols';\n\n/**\n * Records may be anything, They don't even\n * have to be objects.\n *\n * Whatever they are, if they have a Type\n * property, that property will be used by EmberData\n * and WarpDrive to provide better type safety and\n * intellisense.\n *\n * @class TypedRecordInstance\n */\nexport interface TypedRecordInstance {\n /**\n * The type of the resource.\n *\n * This is an optional feature that can be used by\n * record implementations to provide a typescript\n * hint for the type of the resource.\n *\n * When used, EmberData and WarpDrive APIs can\n * take advantage of this to provide better type\n * safety and intellisense.\n *\n * @property [Type]\n * @type {Type}\n * @type {String}\n */\n [Type]: string;\n}\n\n/**\n * A type utility that extracts the Type if available,\n * otherwise it returns never.\n *\n */\nexport type TypeFromInstance<T> = T extends TypedRecordInstance ? T[typeof Type] : never;\n\n/**\n * A type utility that extracts the Type if available,\n * otherwise it returns string\n *\n */\nexport type TypeFromInstanceOrString<T> = T extends TypedRecordInstance ? T[typeof Type] : string;\n\ntype IsUniqueSymbol<T> = T extends `___(unique) Symbol(${string})` ? true : false;\ntype Unpacked<T> = T extends (infer U)[] ? U : T;\ntype NONE = { __NONE: never };\n\ntype __InternalExtract<\n MAX_DEPTH extends _DEPTHCOUNT,\n T extends TypedRecordInstance,\n V extends TypedRecordInstance,\n IncludePrefix extends boolean,\n Ignore,\n Pre extends string,\n DEPTH extends _DEPTHCOUNT,\n> =\n // if we extend T, we return the leaf value\n V extends T\n ? IncludePrefix extends false\n ? V[typeof Type]\n : Pre\n : // else if we are in Ignore we add the lead and exit\n V extends Ignore\n ? IncludePrefix extends false\n ? V[typeof Type]\n : Pre\n : // else if we are at max depth, we return never\n IS_MAX_DEPTH<DEPTH, MAX_DEPTH> extends true\n ? Pre\n : // else add T to Ignore and recurse\n ExtractUnion<MAX_DEPTH, V, IncludePrefix, Ignore | T, Pre, INC_DEPTH<DEPTH>>;\n\ntype __ExtractIfRecord<\n MAX_DEPTH extends _DEPTHCOUNT,\n T extends TypedRecordInstance,\n V,\n IncludePrefix extends boolean,\n Ignore,\n Pre extends string,\n DEPTH extends _DEPTHCOUNT,\n> = V extends TypedRecordInstance ? __InternalExtract<MAX_DEPTH, T, V, IncludePrefix, Ignore, Pre, DEPTH> : never;\n\ntype _ExtractUnion<\n MAX_DEPTH extends _DEPTHCOUNT,\n T extends TypedRecordInstance,\n IncludePrefix extends boolean,\n Ignore,\n Pre,\n DEPTH extends _DEPTHCOUNT,\n> = {\n // for each string key in the record,\n [K in keyof T]: IsUniqueSymbol<K> extends true\n ? never\n : K extends string\n ? // we recursively extract any values that resolve to a TypedRecordInstance\n __ExtractIfRecord<\n MAX_DEPTH,\n T,\n Unpacked<Awaited<T[K]>>,\n IncludePrefix,\n Ignore,\n Pre extends string ? `${Pre}.${K}` : K,\n DEPTH\n >\n : never;\n // then we return any value that is not 'never'\n}[keyof T];\n\n/**\n * A Utility that extracts either resource types or resource paths from a TypedRecordInstance.\n *\n * Its limitations are mostly around its intentional non-recursiveness. It presumes that APIs which\n * implement includes will not allow cyclical include paths, and will collapse includes by type.\n *\n * This follows closer to the JSON:API fields spec than to the includes spec in nature, but in\n * practice it is so impracticle for an API to allow z-algo include paths that this is probably\n * reasonable.\n *\n * We may need to revisit this in the future, opting to either make this restriction optional or\n * to allow for other strategies.\n *\n * There's a 90% chance this particular implementation belongs being in the JSON:API package instead\n * of core-types, but it's here for now.\n *\n */\ntype ExtractUnion<\n MAX_DEPTH extends _DEPTHCOUNT,\n T extends TypedRecordInstance,\n IncludePrefix extends boolean = false,\n Ignore = NONE,\n Pre = NONE,\n DEPTH extends _DEPTHCOUNT = 1,\n> = Exclude<\n IncludePrefix extends true\n ? // if we want to include prefix, we union with the prefix. Outer Exclude will filter any \"NONE\" types\n _ExtractUnion<MAX_DEPTH, T, IncludePrefix, Ignore, Pre, DEPTH> | Pre\n : // Else we just union the types.\n _ExtractUnion<MAX_DEPTH, T, IncludePrefix, Ignore, Pre, DEPTH> | T[typeof Type],\n NONE\n>;\n\ntype _DEPTHCOUNT = 1 | 2 | 3 | 4 | 5;\ntype INC_DEPTH<START extends _DEPTHCOUNT> = START extends 1 ? 2 : START extends 2 ? 3 : START extends 3 ? 4 : 5;\ntype IS_MAX_DEPTH<\n DEPTH extends _DEPTHCOUNT,\n MAX_DEPTH extends _DEPTHCOUNT = DEFAULT_MAX_DEPTH,\n> = DEPTH extends MAX_DEPTH ? true : false;\ntype DEFAULT_MAX_DEPTH = 3;\n/**\n * A utility that provides the union of all ResourceName for all potential\n * includes for the given TypedRecordInstance.\n *\n */\nexport type ExtractSuggestedCacheTypes<\n T extends TypedRecordInstance,\n MAX_DEPTH extends _DEPTHCOUNT = DEFAULT_MAX_DEPTH,\n> = ExtractUnion<MAX_DEPTH, T>; // ToPaths<ExpandIgnore<T, true>, false>;\n\n/**\n * A utility that provides the union type of all valid include paths for the given\n * TypedRecordInstance.\n *\n * Cyclical paths are filtered out.\n *\n */\nexport type Includes<T extends TypedRecordInstance, MAX_DEPTH extends _DEPTHCOUNT = DEFAULT_MAX_DEPTH> = ExtractUnion<\n MAX_DEPTH,\n T,\n true\n>;\n\nexport type OpaqueRecordInstance = unknown;\n\nexport type _StringSatisfiesIncludes<T extends string, SET extends string, FT extends string> = T extends SET\n ? FT\n : T extends `${infer U},${infer V}`\n ? U extends SET\n ? _StringSatisfiesIncludes<V, Exclude<SET, U>, FT>\n : never\n : never;\n\nexport type StringSatisfiesIncludes<T extends string, SET extends string> = _StringSatisfiesIncludes<T, SET, T>;\n\nexport function createIncludeValidator<T extends TypedRecordInstance>() {\n return function validateIncludes<U extends string>(includes: StringSatisfiesIncludes<U, Includes<T>>): U {\n return includes;\n };\n}\n"],"names":["createIncludeValidator","validateIncludes","includes"],"mappings":"AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAoBA;AACA;AACA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;;AAoEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAwBA;AACA;AACA;AACA;AACA;;AAIgC;;AAEhC;AACA;AACA;AACA;AACA;AACA;AACA;;AAmBO,SAASA,sBAAsBA,GAAkC;AACtE,EAAA,OAAO,SAASC,gBAAgBA,CAAmBC,QAAiD,EAAK;AACvG,IAAA,OAAOA,QAAQ;GAChB;AACH;;;;"}
|
package/dist/request.js
CHANGED
|
@@ -7,7 +7,6 @@ const STRUCTURED = getOrSetGlobal('DOC', Symbol('DOC'));
|
|
|
7
7
|
/**
|
|
8
8
|
* Use these options to adjust CacheHandler behavior for a request.
|
|
9
9
|
*
|
|
10
|
-
* @typedoc
|
|
11
10
|
*/
|
|
12
11
|
|
|
13
12
|
/**
|
|
@@ -15,20 +14,20 @@ const STRUCTURED = getOrSetGlobal('DOC', Symbol('DOC'));
|
|
|
15
14
|
*
|
|
16
15
|
* EmberData provides our own typings due to incompleteness in the native typings.
|
|
17
16
|
*
|
|
18
|
-
* @typedoc
|
|
19
17
|
*/
|
|
20
18
|
|
|
21
19
|
/**
|
|
22
20
|
* Extends JavaScript's native {@link Request} object with additional
|
|
23
21
|
* properties specific to the RequestManager's capabilities.
|
|
24
22
|
*
|
|
25
|
-
* @typedoc
|
|
26
23
|
*/
|
|
27
24
|
|
|
28
25
|
/**
|
|
29
26
|
* Immutable version of {@link RequestInfo}. This is what is passed to handlers.
|
|
30
27
|
*
|
|
31
|
-
* @typedoc
|
|
32
28
|
*/
|
|
33
29
|
|
|
34
|
-
|
|
30
|
+
function withBrand(obj) {
|
|
31
|
+
return obj;
|
|
32
|
+
}
|
|
33
|
+
export { EnableHydration, IS_FUTURE, STRUCTURED, SkipCache, withBrand };
|
package/dist/request.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"request.js","sources":["../src/request.ts"],"sourcesContent":["import { getOrSetGlobal, getOrSetUniversal } from './-private';\nimport type { StableRecordIdentifier } from './identifier';\nimport type { QueryParamsSerializationOptions } from './params';\nimport type { ExtractSuggestedCacheTypes, Includes, TypedRecordInstance, TypeFromInstanceOrString } from './record';\nimport type { ResourceIdentifierObject } from './spec/json-api-raw';\nimport type { RequestSignature } from './symbols';\n\ntype Store = unknown;\n\nexport const SkipCache: '___(unique) Symbol(SkipCache)' = getOrSetUniversal('SkipCache', Symbol.for('wd:skip-cache'));\nexport const EnableHydration: '___(unique) Symbol(EnableHydration)' = getOrSetUniversal(\n 'EnableHydration',\n Symbol.for('wd:enable-hydration')\n);\nexport const IS_FUTURE: '___(unique) Symbol(IS_FUTURE)' = getOrSetGlobal('IS_FUTURE', Symbol('IS_FUTURE'));\nexport const STRUCTURED: '___(unique) Symbol(DOC)' = getOrSetGlobal('DOC', Symbol('DOC'));\n\nexport type HTTPMethod =\n | 'QUERY'\n | 'GET'\n | 'OPTIONS'\n | 'POST'\n | 'PUT'\n | 'PATCH'\n | 'DELETE'\n | 'HEAD'\n | 'CONNECT'\n | 'TRACE';\n\n/**\n * Use these options to adjust CacheHandler behavior for a request.\n *\n * @typedoc\n */\nexport type CacheOptions<T = unknown> = {\n /**\n * A key that uniquely identifies this request. If not present, the url wil be used\n * as the key for any GET request, while all other requests will not be cached.\n *\n * @typedoc\n */\n key?: string;\n /**\n * If true, the request will be made even if a cached response is present\n * and not expired.\n *\n * @typedoc\n */\n reload?: boolean;\n /**\n * If true, and a cached response is present and not expired, the request\n * will be made in the background and the cached response will be returned.\n *\n * @typedoc\n */\n backgroundReload?: boolean;\n /**\n * Useful for metadata around when to invalidate the cache. Typically used\n * by strategies that invalidate requests by resource type when a new resource\n * of that type has been created. See the CachePolicy implementation\n * provided by `@ember-data/request-utils` for an example.\n *\n * It is recommended to only use this for query/queryRecord requests where\n * new records created later would affect the results, though using it for\n * findRecord requests is also supported if desired where it may be useful\n * when a create may affect the result of a sideloaded relationship.\n *\n * Generally it is better to patch the cache directly for relationship updates\n * than to invalidate findRecord requests for one.\n *\n * @typedoc\n */\n types?: T extends TypedRecordInstance ? ExtractSuggestedCacheTypes<T>[] : string[];\n\n /**\n * If true, the request will never be handled by the cache-manager and thus\n * will never resolve from cache nor update the cache.\n *\n * Generally this is only used for legacy request that manage resource cache\n * updates in a non-standard way via the LegacyNetworkHandler.\n *\n * @typedoc\n */\n [SkipCache]?: boolean;\n};\nexport type FindRecordRequestOptions<T = unknown, RT = unknown> = {\n url: string;\n method: 'GET';\n headers: Headers;\n cacheOptions?: CacheOptions<T>;\n op: 'findRecord';\n records: [ResourceIdentifierObject<TypeFromInstanceOrString<T>>];\n [RequestSignature]?: RT;\n};\n\nexport type QueryRequestOptions<T = unknown, RT = unknown> = {\n url: string;\n method: 'GET';\n headers: Headers;\n cacheOptions?: CacheOptions<T>;\n op: 'query';\n [RequestSignature]?: RT;\n};\n\nexport type PostQueryRequestOptions<T = unknown, RT = unknown> = {\n url: string;\n method: 'POST' | 'QUERY';\n headers: Headers;\n body?: string | BodyInit | FormData;\n cacheOptions: CacheOptions<T> & { key: string };\n op: 'query';\n [RequestSignature]?: RT;\n};\n\nexport type DeleteRequestOptions<T = unknown, RT = unknown> = {\n url: string;\n method: 'DELETE';\n headers: Headers;\n op: 'deleteRecord';\n body?: string | BodyInit | FormData;\n data: {\n record: StableRecordIdentifier<TypeFromInstanceOrString<T>>;\n };\n records: [ResourceIdentifierObject<TypeFromInstanceOrString<T>>];\n [RequestSignature]?: RT;\n};\n\ntype ImmutableRequest<T> = Readonly<T> & {\n readonly headers: ImmutableHeaders;\n readonly records: [StableRecordIdentifier];\n};\n\nexport type UpdateRequestOptions<T = unknown, RT = unknown> = {\n url: string;\n method: 'PATCH' | 'PUT';\n headers: Headers;\n op: 'updateRecord';\n body?: string | BodyInit | FormData;\n data: {\n record: StableRecordIdentifier<TypeFromInstanceOrString<T>>;\n };\n records: [ResourceIdentifierObject<TypeFromInstanceOrString<T>>];\n [RequestSignature]?: RT;\n};\n\nexport type CreateRequestOptions<T = unknown, RT = unknown> = {\n url: string;\n method: 'POST';\n headers: Headers;\n op: 'createRecord';\n body?: string | BodyInit | FormData;\n data: {\n record: StableRecordIdentifier<TypeFromInstanceOrString<T>>;\n };\n records: [ResourceIdentifierObject<TypeFromInstanceOrString<T>>];\n [RequestSignature]?: RT;\n};\n\nexport type ImmutableDeleteRequestOptions = ImmutableRequest<DeleteRequestOptions>;\nexport type ImmutableUpdateRequestOptions = ImmutableRequest<UpdateRequestOptions>;\nexport type ImmutableCreateRequestOptions = ImmutableRequest<CreateRequestOptions>;\n\nexport type RemotelyAccessibleIdentifier<T extends string = string> = {\n id: string;\n type: T;\n lid?: string;\n};\n\nexport type ConstrainedRequestOptions = {\n reload?: boolean;\n backgroundReload?: boolean;\n host?: string;\n namespace?: string;\n resourcePath?: string;\n urlParamsSettings?: QueryParamsSerializationOptions;\n};\n\nexport type FindRecordOptions<T = unknown> = ConstrainedRequestOptions & {\n include?: T extends TypedRecordInstance ? Includes<T>[] : string | string[];\n};\n\nexport interface StructuredDataDocument<T> {\n [STRUCTURED]?: true;\n /**\n * @see {@link ImmutableRequestInfo}\n * @typedoc\n */\n request: ImmutableRequestInfo;\n response: Response | ResponseInfo | null;\n content: T;\n}\nexport interface StructuredErrorDocument<T = unknown> extends Error {\n [STRUCTURED]?: true;\n request: ImmutableRequestInfo;\n response: Response | ResponseInfo | null;\n error: string | object;\n content?: T;\n}\nexport type StructuredDocument<T> = StructuredDataDocument<T> | StructuredErrorDocument<T>;\n\n/**\n * JavaScript's native Request class.\n *\n * EmberData provides our own typings due to incompleteness in the native typings.\n *\n * @typedoc\n */\ntype Request = {\n /** Returns the cache mode associated with request, which is a string indicating how the request will interact with the browser's cache when fetching.\n * @typedoc\n */\n cache?: RequestCache;\n /** Returns the credentials mode associated with request, which is a string indicating whether credentials will be sent with the request always, never, or only when sent to a same-origin URL.\n * @typedoc\n */\n credentials?: RequestCredentials;\n /** Returns the kind of resource requested by request, e.g., \"document\" or \"script\".\n * @typedoc\n */\n destination?: RequestDestination;\n /** Returns a Headers object consisting of the headers associated with request. Note that headers added in the network layer by the user agent will not be accounted for in this object, e.g., the \"Host\" header.\n * @typedoc\n */\n headers?: Headers;\n /** Returns request's subresource integrity metadata, which is a cryptographic hash of the resource being fetched. Its value consists of multiple hashes separated by whitespace. [SRI]\n * @typedoc\n */\n integrity?: string;\n /** Returns a boolean indicating whether or not request can outlive the global in which it was created.\n * @typedoc\n */\n keepalive?: boolean;\n /** Returns request's HTTP method, which is \"GET\" by default.\n * @typedoc\n */\n method?: HTTPMethod;\n /** Returns the mode associated with request, which is a string indicating whether the request will use CORS, or will be restricted to same-origin URLs.\n *\n * `no-cors` is not allowed for streaming request bodies.\n *\n * @typedoc\n */\n mode?: RequestMode;\n /** Returns the redirect mode associated with request, which is a string indicating how redirects for the request will be handled during fetching. A request will follow redirects by default.\n * @typedoc\n */\n redirect?: RequestRedirect;\n /** Returns the referrer of request. Its value can be a same-origin URL if explicitly set in init, the empty string to indicate no referrer, and \"about:client\" when defaulting to the global's default. This is used during fetching to determine the value of the `Referer` header of the request being made.\n * @typedoc\n */\n referrer?: string;\n /** Returns the referrer policy associated with request. This is used during fetching to compute the value of the request's referrer.\n * @typedoc\n */\n referrerPolicy?: ReferrerPolicy;\n /** Returns the signal associated with request, which is an AbortSignal object indicating whether or not request has been aborted, and its abort event handler.\n * @typedoc\n */\n signal?: AbortSignal;\n /** Returns the URL of request as a string.\n * @typedoc\n */\n url?: string;\n /** Any body that you want to add to your request. Note that a GET or HEAD request may not have a body.\n * @typedoc\n */\n body?: BodyInit | null;\n\n /**\n * When sending a ReadableStream as the body of a request, 'half' must be\n * specified.\n *\n * [Half Duplex Further Reading](https://developer.chrome.com/docs/capabilities/web-apis/fetch-streaming-requests#half_duplex)\n *\n * @typedoc\n */\n duplex?: 'half';\n};\n\nexport interface ImmutableHeaders extends Headers {\n clone?(): Headers;\n toJSON(): [string, string][];\n}\n\n/**\n * Extends JavaScript's native {@link Request} object with additional\n * properties specific to the RequestManager's capabilities.\n *\n * @typedoc\n */\nexport type RequestInfo<T = unknown, RT = unknown> = Request & {\n /**\n * If provided, used instead of the AbortController auto-configured for each request by the RequestManager\n *\n * @typedoc\n */\n controller?: AbortController;\n\n /**\n * @see {@link CacheOptions}\n * @typedoc\n */\n cacheOptions?: CacheOptions<T>;\n store?: Store;\n\n op?: string;\n\n /**\n * The identifiers of the primary resources involved in the request\n * (if any). This may be used by handlers to perform transactional\n * operations on the store.\n *\n * @typedoc\n */\n records?: StableRecordIdentifier[];\n\n disableTestWaiter?: boolean;\n /**\n * data that a handler should convert into\n * the query (GET) or body (POST).\n *\n * Note: It is recommended that builders set query params\n * and body directly in most scenarios.\n *\n * @typedoc\n */\n data?: Record<string, unknown>;\n /**\n * options specifically intended for handlers\n * to utilize to process the request\n *\n * @typedoc\n */\n options?: Record<string, unknown>;\n\n [RequestSignature]?: RT;\n\n [EnableHydration]?: boolean;\n};\n\n/**\n * Immutable version of {@link RequestInfo}. This is what is passed to handlers.\n *\n * @typedoc\n */\nexport type ImmutableRequestInfo<T = unknown, RT = unknown> = Readonly<Omit<RequestInfo<T, RT>, 'controller'>> & {\n readonly cacheOptions?: Readonly<CacheOptions<T>>;\n readonly headers?: ImmutableHeaders;\n readonly data?: Readonly<Record<string, unknown>>;\n readonly options?: Readonly<Record<string, unknown>>;\n\n /** Whether the request body has been read.\n * @typedoc\n */\n readonly bodyUsed?: boolean;\n};\n\nexport interface ResponseInfo {\n readonly headers: ImmutableHeaders; // to do, maybe not this?\n readonly ok: boolean;\n readonly redirected: boolean;\n readonly status: number;\n readonly statusText: string;\n readonly type: ResponseType;\n readonly url: string;\n}\n\nexport interface RequestContext {\n /**\n * @see {@link ImmutableRequestInfo}\n * @typedoc\n */\n request: ImmutableRequestInfo;\n id: number;\n\n setStream(stream: ReadableStream | Promise<ReadableStream | null>): void;\n setResponse(response: Response | ResponseInfo | null): void;\n}\n"],"names":["SkipCache","getOrSetUniversal","Symbol","for","EnableHydration","IS_FUTURE","getOrSetGlobal","STRUCTURED"],"mappings":";;AASaA,MAAAA,SAA0C,GAAGC,iBAAiB,CAAC,WAAW,EAAEC,MAAM,CAACC,GAAG,CAAC,eAAe,CAAC;AACvGC,MAAAA,eAAsD,GAAGH,iBAAiB,CACrF,iBAAiB,EACjBC,MAAM,CAACC,GAAG,CAAC,qBAAqB,CAClC;AACO,MAAME,SAA0C,GAAGC,cAAc,CAAC,WAAW,EAAEJ,MAAM,CAAC,WAAW,CAAC;AAClG,MAAMK,UAAqC,GAAGD,cAAc,CAAC,KAAK,EAAEJ,MAAM,CAAC,KAAK,CAAC;;AAcxF;AACA;AACA;AACA;AACA;;AAuKA;AACA;AACA;AACA;AACA;AACA;AACA;;AA8EA;AACA;AACA;AACA;AACA;AACA;;AAmDA;AACA;AACA;AACA;AACA;;;;"}
|
|
1
|
+
{"version":3,"file":"request.js","sources":["../src/request.ts"],"sourcesContent":["import { getOrSetGlobal, getOrSetUniversal } from './-private';\nimport type { StableRecordIdentifier } from './identifier';\nimport type { QueryParamsSerializationOptions } from './params';\nimport type { ExtractSuggestedCacheTypes, Includes, TypedRecordInstance, TypeFromInstanceOrString } from './record';\nimport type { ResourceIdentifierObject } from './spec/json-api-raw';\nimport type { RequestSignature } from './symbols';\n\ntype Store = unknown;\n\nexport const SkipCache: '___(unique) Symbol(SkipCache)' = getOrSetUniversal('SkipCache', Symbol.for('wd:skip-cache'));\nexport const EnableHydration: '___(unique) Symbol(EnableHydration)' = getOrSetUniversal(\n 'EnableHydration',\n Symbol.for('wd:enable-hydration')\n);\nexport const IS_FUTURE: '___(unique) Symbol(IS_FUTURE)' = getOrSetGlobal('IS_FUTURE', Symbol('IS_FUTURE'));\nexport const STRUCTURED: '___(unique) Symbol(DOC)' = getOrSetGlobal('DOC', Symbol('DOC'));\n\nexport type HTTPMethod =\n | 'QUERY'\n | 'GET'\n | 'OPTIONS'\n | 'POST'\n | 'PUT'\n | 'PATCH'\n | 'DELETE'\n | 'HEAD'\n | 'CONNECT'\n | 'TRACE';\n\n/**\n * Use these options to adjust CacheHandler behavior for a request.\n *\n */\nexport type CacheOptions<T = unknown> = {\n /**\n * A key that uniquely identifies this request. If not present, the url wil be used\n * as the key for any GET request, while all other requests will not be cached.\n *\n */\n key?: string;\n /**\n * If true, the request will be made even if a cached response is present\n * and not expired.\n *\n */\n reload?: boolean;\n /**\n * If true, and a cached response is present and not expired, the request\n * will be made in the background and the cached response will be returned.\n *\n */\n backgroundReload?: boolean;\n /**\n * Useful for metadata around when to invalidate the cache. Typically used\n * by strategies that invalidate requests by resource type when a new resource\n * of that type has been created. See the CachePolicy implementation\n * provided by `@ember-data/request-utils` for an example.\n *\n * It is recommended to only use this for query/queryRecord requests where\n * new records created later would affect the results, though using it for\n * findRecord requests is also supported if desired where it may be useful\n * when a create may affect the result of a sideloaded relationship.\n *\n * Generally it is better to patch the cache directly for relationship updates\n * than to invalidate findRecord requests for one.\n *\n */\n types?: T extends TypedRecordInstance ? ExtractSuggestedCacheTypes<T>[] : string[];\n\n /**\n * If true, the request will never be handled by the cache-manager and thus\n * will never resolve from cache nor update the cache.\n *\n * Generally this is only used for legacy request that manage resource cache\n * updates in a non-standard way via the LegacyNetworkHandler.\n *\n */\n [SkipCache]?: boolean;\n};\nexport type FindRecordRequestOptions<RT = unknown, T = unknown> = {\n url: string;\n method: 'GET';\n headers: Headers;\n cacheOptions?: CacheOptions<T>;\n op: 'findRecord';\n records: [ResourceIdentifierObject<TypeFromInstanceOrString<T>>];\n [RequestSignature]?: RT;\n};\n\nexport type QueryRequestOptions<RT = unknown, T = unknown> = {\n url: string;\n method: 'GET';\n headers: Headers;\n cacheOptions?: CacheOptions<T>;\n op: 'query';\n [RequestSignature]?: RT;\n};\n\nexport type PostQueryRequestOptions<RT = unknown, T = unknown> = {\n url: string;\n method: 'POST' | 'QUERY';\n headers: Headers;\n body?: string | BodyInit | FormData;\n cacheOptions: CacheOptions<T> & { key: string };\n op: 'query';\n [RequestSignature]?: RT;\n};\n\nexport type DeleteRequestOptions<RT = unknown, T = unknown> = {\n url: string;\n method: 'DELETE';\n headers: Headers;\n op: 'deleteRecord';\n body?: string | BodyInit | FormData;\n data: {\n record: StableRecordIdentifier<TypeFromInstanceOrString<T>>;\n };\n records: [ResourceIdentifierObject<TypeFromInstanceOrString<T>>];\n [RequestSignature]?: RT;\n};\n\ntype ImmutableRequest<T> = Readonly<T> & {\n readonly headers: ImmutableHeaders;\n readonly records: [StableRecordIdentifier];\n};\n\nexport type UpdateRequestOptions<RT = unknown, T = unknown> = {\n url: string;\n method: 'PATCH' | 'PUT';\n headers: Headers;\n op: 'updateRecord';\n body?: string | BodyInit | FormData;\n data: {\n record: StableRecordIdentifier<TypeFromInstanceOrString<T>>;\n };\n records: [ResourceIdentifierObject<TypeFromInstanceOrString<T>>];\n [RequestSignature]?: RT;\n};\n\nexport type CreateRequestOptions<RT = unknown, T = unknown> = {\n url: string;\n method: 'POST';\n headers: Headers;\n op: 'createRecord';\n body?: string | BodyInit | FormData;\n data: {\n record: StableRecordIdentifier<TypeFromInstanceOrString<T>>;\n };\n records: [ResourceIdentifierObject<TypeFromInstanceOrString<T>>];\n [RequestSignature]?: RT;\n};\n\nexport type ImmutableDeleteRequestOptions = ImmutableRequest<DeleteRequestOptions>;\nexport type ImmutableUpdateRequestOptions = ImmutableRequest<UpdateRequestOptions>;\nexport type ImmutableCreateRequestOptions = ImmutableRequest<CreateRequestOptions>;\n\nexport type RemotelyAccessibleIdentifier<T extends string = string> = {\n id: string;\n type: T;\n lid?: string;\n};\n\nexport type ConstrainedRequestOptions = {\n reload?: boolean;\n backgroundReload?: boolean;\n host?: string;\n namespace?: string;\n resourcePath?: string;\n urlParamsSettings?: QueryParamsSerializationOptions;\n};\n\nexport type FindRecordOptions<T = unknown> = ConstrainedRequestOptions & {\n include?: T extends TypedRecordInstance ? Includes<T>[] : string | string[];\n};\n\nexport interface StructuredDataDocument<T> {\n [STRUCTURED]?: true;\n /**\n * @see {@link ImmutableRequestInfo}\n */\n request: ImmutableRequestInfo;\n response: Response | ResponseInfo | null;\n content: T;\n}\nexport interface StructuredErrorDocument<T = unknown> extends Error {\n [STRUCTURED]?: true;\n request: ImmutableRequestInfo;\n response: Response | ResponseInfo | null;\n error: string | object;\n content?: T;\n}\nexport type StructuredDocument<T> = StructuredDataDocument<T> | StructuredErrorDocument<T>;\n\n/**\n * JavaScript's native Request class.\n *\n * EmberData provides our own typings due to incompleteness in the native typings.\n *\n */\ninterface Request {\n /** Returns the cache mode associated with request, which is a string indicating how the request will interact with the browser's cache when fetching.\n */\n cache?: RequestCache;\n /** Returns the credentials mode associated with request, which is a string indicating whether credentials will be sent with the request always, never, or only when sent to a same-origin URL.\n */\n credentials?: RequestCredentials;\n /** Returns the kind of resource requested by request, e.g., \"document\" or \"script\".\n */\n destination?: RequestDestination;\n /** Returns a Headers object consisting of the headers associated with request. Note that headers added in the network layer by the user agent will not be accounted for in this object, e.g., the \"Host\" header.\n */\n headers?: Headers;\n /** Returns request's subresource integrity metadata, which is a cryptographic hash of the resource being fetched. Its value consists of multiple hashes separated by whitespace. [SRI]\n */\n integrity?: string;\n /** Returns a boolean indicating whether or not request can outlive the global in which it was created.\n */\n keepalive?: boolean;\n /** Returns request's HTTP method, which is \"GET\" by default.\n */\n method?: HTTPMethod;\n /** Returns the mode associated with request, which is a string indicating whether the request will use CORS, or will be restricted to same-origin URLs.\n *\n * `no-cors` is not allowed for streaming request bodies.\n *\n */\n mode?: RequestMode;\n /** Returns the redirect mode associated with request, which is a string indicating how redirects for the request will be handled during fetching. A request will follow redirects by default.\n */\n redirect?: RequestRedirect;\n /** Returns the referrer of request. Its value can be a same-origin URL if explicitly set in init, the empty string to indicate no referrer, and \"about:client\" when defaulting to the global's default. This is used during fetching to determine the value of the `Referer` header of the request being made.\n */\n referrer?: string;\n /** Returns the referrer policy associated with request. This is used during fetching to compute the value of the request's referrer.\n */\n referrerPolicy?: ReferrerPolicy;\n /** Returns the signal associated with request, which is an AbortSignal object indicating whether or not request has been aborted, and its abort event handler.\n */\n signal?: AbortSignal;\n /** Returns the URL of request as a string.\n */\n url?: string;\n /** Any body that you want to add to your request. Note that a GET or HEAD request may not have a body.\n */\n body?: BodyInit | null;\n\n /**\n * When sending a ReadableStream as the body of a request, 'half' must be\n * specified.\n *\n * [Half Duplex Further Reading](https://developer.chrome.com/docs/capabilities/web-apis/fetch-streaming-requests#half_duplex)\n *\n */\n duplex?: 'half';\n}\n\nexport interface ImmutableHeaders extends Headers {\n clone?(): Headers;\n toJSON(): [string, string][];\n}\n\n/**\n * Extends JavaScript's native {@link Request} object with additional\n * properties specific to the RequestManager's capabilities.\n *\n */\nexport interface RequestInfo<RT = unknown, T = unknown> extends Request {\n /**\n * If provided, used instead of the AbortController auto-configured for each request by the RequestManager\n *\n */\n controller?: AbortController;\n\n /**\n * @see {@link CacheOptions}\n */\n cacheOptions?: CacheOptions<T>;\n store?: Store;\n\n op?: string;\n\n /**\n * The identifiers of the primary resources involved in the request\n * (if any). This may be used by handlers to perform transactional\n * operations on the store.\n *\n */\n records?: StableRecordIdentifier[];\n\n disableTestWaiter?: boolean;\n /**\n * data that a handler should convert into\n * the query (GET) or body (POST).\n *\n * Note: It is recommended that builders set query params\n * and body directly in most scenarios.\n *\n */\n data?: Record<string, unknown>;\n /**\n * options specifically intended for handlers\n * to utilize to process the request\n *\n */\n options?: Record<string, unknown>;\n\n [RequestSignature]?: RT;\n\n [EnableHydration]?: boolean;\n}\n\n/**\n * Immutable version of {@link RequestInfo}. This is what is passed to handlers.\n *\n */\nexport type ImmutableRequestInfo<RT = unknown, T = unknown> = Readonly<Omit<RequestInfo<RT, T>, 'controller'>> & {\n readonly cacheOptions?: Readonly<CacheOptions<T>>;\n readonly headers?: ImmutableHeaders;\n readonly data?: Readonly<Record<string, unknown>>;\n readonly options?: Readonly<Record<string, unknown>>;\n\n /** Whether the request body has been read.\n */\n readonly bodyUsed?: boolean;\n};\n\nexport interface ResponseInfo {\n readonly headers: ImmutableHeaders; // to do, maybe not this?\n readonly ok: boolean;\n readonly redirected: boolean;\n readonly status: number;\n readonly statusText: string;\n readonly type: ResponseType;\n readonly url: string;\n}\n\nexport interface RequestContext {\n /**\n * @see {@link ImmutableRequestInfo}\n */\n request: ImmutableRequestInfo;\n id: number;\n\n setStream(stream: ReadableStream | Promise<ReadableStream | null>): void;\n setResponse(response: Response | ResponseInfo | null): void;\n}\n\nexport function withBrand<T>(obj: RequestInfo): RequestInfo<T> & { [RequestSignature]: T } {\n return obj as RequestInfo<T> & {\n [RequestSignature]: T;\n };\n}\n"],"names":["SkipCache","getOrSetUniversal","Symbol","for","EnableHydration","IS_FUTURE","getOrSetGlobal","STRUCTURED","withBrand","obj"],"mappings":";;AASaA,MAAAA,SAA0C,GAAGC,iBAAiB,CAAC,WAAW,EAAEC,MAAM,CAACC,GAAG,CAAC,eAAe,CAAC;AACvGC,MAAAA,eAAsD,GAAGH,iBAAiB,CACrF,iBAAiB,EACjBC,MAAM,CAACC,GAAG,CAAC,qBAAqB,CAClC;AACO,MAAME,SAA0C,GAAGC,cAAc,CAAC,WAAW,EAAEJ,MAAM,CAAC,WAAW,CAAC;AAClG,MAAMK,UAAqC,GAAGD,cAAc,CAAC,KAAK,EAAEJ,MAAM,CAAC,KAAK,CAAC;;AAcxF;AACA;AACA;AACA;;AAiKA;AACA;AACA;AACA;AACA;AACA;;AA+DA;AACA;AACA;AACA;AACA;;AA8CA;AACA;AACA;AACA;;AAiCO,SAASM,SAASA,CAAIC,GAAgB,EAA8C;AACzF,EAAA,OAAOA,GAAG;AAGZ;;;;"}
|
package/dist/runtime.js
CHANGED
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\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
|
|
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 */\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;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
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @module @warp-drive/core-types
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
1
|
/**
|
|
6
2
|
* A generic "field" that can be used to define
|
|
7
3
|
* primitive value fields.
|
|
@@ -16,7 +12,7 @@
|
|
|
16
12
|
* "type" points to a new-style transform on "field"
|
|
17
13
|
* that a record implmentation *must* use.
|
|
18
14
|
*
|
|
19
|
-
* @class
|
|
15
|
+
* @class (Type) GenericField
|
|
20
16
|
* @public
|
|
21
17
|
*/
|
|
22
18
|
|
|
@@ -46,7 +42,7 @@
|
|
|
46
42
|
* an AliasField could be used to expose both a string and a Date version of the
|
|
47
43
|
* same field, with both being capable of being written to.
|
|
48
44
|
*
|
|
49
|
-
* @class
|
|
45
|
+
* @class (Type) LegacyAliasField
|
|
50
46
|
* @public
|
|
51
47
|
*/
|
|
52
48
|
|
|
@@ -76,7 +72,7 @@
|
|
|
76
72
|
* an AliasField could be used to expose both a string and a Date version of the
|
|
77
73
|
* same field, with both being capable of being written to.
|
|
78
74
|
*
|
|
79
|
-
* @class
|
|
75
|
+
* @class (Type) PolarisAliasField
|
|
80
76
|
* @public
|
|
81
77
|
*/
|
|
82
78
|
|
|
@@ -106,7 +102,7 @@
|
|
|
106
102
|
* an AliasField could be used to expose both a string and a Date version of the
|
|
107
103
|
* same field, with both being capable of being written to.
|
|
108
104
|
*
|
|
109
|
-
* @class
|
|
105
|
+
* @class (Type) ObjectAliasField
|
|
110
106
|
* @public
|
|
111
107
|
*/
|
|
112
108
|
|
|
@@ -122,7 +118,7 @@
|
|
|
122
118
|
* 'uuid', 'urn' or 'entityUrn' or 'primaryKey' as their
|
|
123
119
|
* primary key field instead of 'id'.
|
|
124
120
|
*
|
|
125
|
-
* @class
|
|
121
|
+
* @class (Type) IdentityField
|
|
126
122
|
* @public
|
|
127
123
|
*/
|
|
128
124
|
|
|
@@ -147,7 +143,7 @@
|
|
|
147
143
|
* it should be placed in the `ResourceSchema`'s `@id` field
|
|
148
144
|
* in place of an `IdentityField`.
|
|
149
145
|
*
|
|
150
|
-
* @class
|
|
146
|
+
* @class (Type) HashField
|
|
151
147
|
* @public
|
|
152
148
|
*/
|
|
153
149
|
|
|
@@ -178,7 +174,7 @@
|
|
|
178
174
|
*
|
|
179
175
|
* Don't make us regret this decision.
|
|
180
176
|
*
|
|
181
|
-
* @class
|
|
177
|
+
* @class (Type) LocalField
|
|
182
178
|
* @public
|
|
183
179
|
*/
|
|
184
180
|
|
|
@@ -191,7 +187,7 @@
|
|
|
191
187
|
* if the key/value pairs have well-defined shape,
|
|
192
188
|
* use 'schema-object' instead.
|
|
193
189
|
*
|
|
194
|
-
* @class
|
|
190
|
+
* @class (Type) ObjectField
|
|
195
191
|
* @public
|
|
196
192
|
*/
|
|
197
193
|
|
|
@@ -203,7 +199,7 @@
|
|
|
203
199
|
* If the object's structure is not well-defined,
|
|
204
200
|
* use 'object' instead.
|
|
205
201
|
*
|
|
206
|
-
* @class
|
|
202
|
+
* @class (Type) SchemaObjectField
|
|
207
203
|
* @public
|
|
208
204
|
*/
|
|
209
205
|
|
|
@@ -214,7 +210,7 @@
|
|
|
214
210
|
* If the array's elements are not primitive
|
|
215
211
|
* values, use 'schema-array' instead.
|
|
216
212
|
*
|
|
217
|
-
* @class
|
|
213
|
+
* @class (Type) ArrayField
|
|
218
214
|
* @public
|
|
219
215
|
*/
|
|
220
216
|
|
|
@@ -226,7 +222,7 @@
|
|
|
226
222
|
* If the array's elements are not well-defined,
|
|
227
223
|
* use 'array' instead.
|
|
228
224
|
*
|
|
229
|
-
* @class
|
|
225
|
+
* @class (Type) SchemaArrayField
|
|
230
226
|
* @public
|
|
231
227
|
*/
|
|
232
228
|
|
|
@@ -244,7 +240,7 @@
|
|
|
244
240
|
* or that require access to related resources
|
|
245
241
|
* that may not be loaded should be avoided.
|
|
246
242
|
*
|
|
247
|
-
* @class
|
|
243
|
+
* @class (Type) DerivedField
|
|
248
244
|
* @public
|
|
249
245
|
*/
|
|
250
246
|
|
|
@@ -255,7 +251,7 @@
|
|
|
255
251
|
* SUPPORT FOR THIS FEATURE IS NOT YET IMPLEMENTED
|
|
256
252
|
* BY SchemaRecord
|
|
257
253
|
*
|
|
258
|
-
* @class
|
|
254
|
+
* @class (Type) ResourceField
|
|
259
255
|
* @public
|
|
260
256
|
*/
|
|
261
257
|
|
|
@@ -267,7 +263,7 @@
|
|
|
267
263
|
* SUPPORT FOR THIS FEATURE IS NOT YET IMPLEMENTED
|
|
268
264
|
* BY SchemaRecord
|
|
269
265
|
*
|
|
270
|
-
* @class
|
|
266
|
+
* @class (Type) CollectionField
|
|
271
267
|
* @public
|
|
272
268
|
*/
|
|
273
269
|
|
|
@@ -286,7 +282,7 @@
|
|
|
286
282
|
* that a serializer *might* use, but their usage
|
|
287
283
|
* is not guaranteed.
|
|
288
284
|
*
|
|
289
|
-
* @class
|
|
285
|
+
* @class (Type) LegacyAttributeField
|
|
290
286
|
* @public
|
|
291
287
|
*/
|
|
292
288
|
|
|
@@ -299,7 +295,7 @@
|
|
|
299
295
|
*
|
|
300
296
|
* This is the legacy version of the `ResourceField`.
|
|
301
297
|
*
|
|
302
|
-
* @class
|
|
298
|
+
* @class (Type) LegacyBelongsToField
|
|
303
299
|
* @public
|
|
304
300
|
*/
|
|
305
301
|
|
|
@@ -312,7 +308,7 @@
|
|
|
312
308
|
*
|
|
313
309
|
* This is the legacy version of the `ResourceField`.
|
|
314
310
|
*
|
|
315
|
-
* @class
|
|
311
|
+
* @class (Type) LinksModeBelongsToField
|
|
316
312
|
* @public
|
|
317
313
|
*/
|
|
318
314
|
|
|
@@ -325,7 +321,7 @@
|
|
|
325
321
|
*
|
|
326
322
|
* This is the legacy version of the `CollectionField`.
|
|
327
323
|
*
|
|
328
|
-
* @class
|
|
324
|
+
* @class (Type) LegacyHasManyField
|
|
329
325
|
* @public
|
|
330
326
|
*/
|
|
331
327
|
|
|
@@ -338,7 +334,7 @@
|
|
|
338
334
|
*
|
|
339
335
|
* This is the legacy version of the `CollectionField`.
|
|
340
336
|
*
|
|
341
|
-
* @class
|
|
337
|
+
* @class (Type) LinksModeHasManyField
|
|
342
338
|
* @public
|
|
343
339
|
*/
|
|
344
340
|
|
|
@@ -347,21 +343,21 @@
|
|
|
347
343
|
*
|
|
348
344
|
* Available field schemas are:
|
|
349
345
|
*
|
|
350
|
-
* -
|
|
351
|
-
* -
|
|
352
|
-
* -
|
|
353
|
-
* -
|
|
354
|
-
* -
|
|
355
|
-
* -
|
|
356
|
-
* -
|
|
357
|
-
* -
|
|
358
|
-
* -
|
|
359
|
-
* -
|
|
360
|
-
* -
|
|
361
|
-
* -
|
|
362
|
-
* -
|
|
363
|
-
*
|
|
364
|
-
* @class
|
|
346
|
+
* - {@link GenericField}
|
|
347
|
+
* - {@link LegacyAliasField}
|
|
348
|
+
* - {@link LocalField}
|
|
349
|
+
* - {@link ObjectField}
|
|
350
|
+
* - {@link SchemaObjectField}
|
|
351
|
+
* - {@link ArrayField}
|
|
352
|
+
* - {@link SchemaArrayField}
|
|
353
|
+
* - {@link DerivedField}
|
|
354
|
+
* - {@link ResourceField | ResourceField (not yet implemented)}
|
|
355
|
+
* - {@link CollectionField | CollectionField (not yet implemented)}
|
|
356
|
+
* - {@link LegacyAttributeField}
|
|
357
|
+
* - {@link LegacyBelongsToField}
|
|
358
|
+
* - {@link LegacyHasManyField}
|
|
359
|
+
*
|
|
360
|
+
* @class (Type) LegacyModeFieldSchema
|
|
365
361
|
* @public
|
|
366
362
|
*/
|
|
367
363
|
|
|
@@ -370,20 +366,20 @@
|
|
|
370
366
|
*
|
|
371
367
|
* Available field schemas are:
|
|
372
368
|
*
|
|
373
|
-
* -
|
|
374
|
-
* -
|
|
375
|
-
* -
|
|
376
|
-
* -
|
|
377
|
-
* -
|
|
378
|
-
* -
|
|
379
|
-
* -
|
|
380
|
-
* -
|
|
381
|
-
* -
|
|
382
|
-
* -
|
|
383
|
-
* -
|
|
384
|
-
* -
|
|
385
|
-
*
|
|
386
|
-
* @class
|
|
369
|
+
* - {@link GenericField}
|
|
370
|
+
* - {@link PolarisAliasField}
|
|
371
|
+
* - {@link LocalField}
|
|
372
|
+
* - {@link ObjectField}
|
|
373
|
+
* - {@link SchemaObjectField}
|
|
374
|
+
* - {@link ArrayField}
|
|
375
|
+
* - {@link SchemaArrayField}
|
|
376
|
+
* - {@link DerivedField}
|
|
377
|
+
* - {@link ResourceField | ResourceField (not yet implemented)}
|
|
378
|
+
* - {@link CollectionField | CollectionField (not yet implemented)}
|
|
379
|
+
* - {@link LinksModeBelongsToField}
|
|
380
|
+
* - {@link LinksModeHasManyField}
|
|
381
|
+
*
|
|
382
|
+
* @class (Type) PolarisModeFieldSchema
|
|
387
383
|
* @public
|
|
388
384
|
*/
|
|
389
385
|
|
|
@@ -396,7 +392,7 @@
|
|
|
396
392
|
* as appropriate as they are more specific and will
|
|
397
393
|
* provide better guidance around what is valid.
|
|
398
394
|
*
|
|
399
|
-
* @class
|
|
395
|
+
* @class (Type) FieldSchema
|
|
400
396
|
* @public
|
|
401
397
|
*/
|
|
402
398
|
|
|
@@ -404,7 +400,7 @@
|
|
|
404
400
|
* A union of all possible field schemas that can be
|
|
405
401
|
* used in an ObjectSchema.
|
|
406
402
|
*
|
|
407
|
-
* @class
|
|
403
|
+
* @class (Type) ObjectFieldSchema
|
|
408
404
|
* @public
|
|
409
405
|
*/
|
|
410
406
|
|
|
@@ -415,7 +411,7 @@
|
|
|
415
411
|
* own which may allow them to appear in relationships, or in multiple
|
|
416
412
|
* response documents.
|
|
417
413
|
*
|
|
418
|
-
* @class
|
|
414
|
+
* @class (Type) PolarisResourceSchema
|
|
419
415
|
* @public
|
|
420
416
|
*/
|
|
421
417
|
|
|
@@ -426,7 +422,7 @@
|
|
|
426
422
|
* own which may allow them to appear in relationships, or in multiple
|
|
427
423
|
* response documents.
|
|
428
424
|
*
|
|
429
|
-
* @class
|
|
425
|
+
* @class (Type) LegacyResourceSchema
|
|
430
426
|
* @public
|
|
431
427
|
*/
|
|
432
428
|
|
|
@@ -439,7 +435,6 @@
|
|
|
439
435
|
* by the SchemaService which provides fields as a Map
|
|
440
436
|
* instead of as an Array.
|
|
441
437
|
*
|
|
442
|
-
* @typedoc
|
|
443
438
|
*/
|
|
444
439
|
|
|
445
440
|
/**
|
|
@@ -448,7 +443,7 @@
|
|
|
448
443
|
*
|
|
449
444
|
* ObjectSchemas may not currently contain relationships.
|
|
450
445
|
*
|
|
451
|
-
* @class
|
|
446
|
+
* @class (Type) ObjectSchema
|
|
452
447
|
* @public
|
|
453
448
|
*/
|
|
454
449
|
|
|
@@ -462,9 +457,6 @@
|
|
|
462
457
|
* as doing so would require a full schema graph to be passed in
|
|
463
458
|
* and no cycles in the graph to be present.
|
|
464
459
|
*
|
|
465
|
-
* @method resourceSchema
|
|
466
|
-
* @static
|
|
467
|
-
* @for @warp-drive/core-types
|
|
468
460
|
* @param {ResourceSchema} schema
|
|
469
461
|
* @return {ResourceSchema} the passed in schema
|
|
470
462
|
* @public
|
|
@@ -479,9 +471,6 @@ function resourceSchema(schema) {
|
|
|
479
471
|
*
|
|
480
472
|
* Will return the passed in schema.
|
|
481
473
|
*
|
|
482
|
-
* @method objectSchema
|
|
483
|
-
* @static
|
|
484
|
-
* @for @warp-drive/core-types
|
|
485
474
|
* @param {ObjectSchema} schema
|
|
486
475
|
* @return {ObjectSchema} the passed in schema
|
|
487
476
|
* @public
|
|
@@ -493,9 +482,6 @@ function objectSchema(schema) {
|
|
|
493
482
|
/**
|
|
494
483
|
* A type utility to narrow a schema to a ResourceSchema
|
|
495
484
|
*
|
|
496
|
-
* @method isResourceSchema
|
|
497
|
-
* @static
|
|
498
|
-
* @for @warp-drive/core-types
|
|
499
485
|
* @param schema
|
|
500
486
|
* @return {Boolean}
|
|
501
487
|
* @public
|
|
@@ -507,9 +493,6 @@ function isResourceSchema(schema) {
|
|
|
507
493
|
/**
|
|
508
494
|
* A type utility to narrow a schema to LegacyResourceSchema
|
|
509
495
|
*
|
|
510
|
-
* @method isLegacyResourceSchema
|
|
511
|
-
* @static
|
|
512
|
-
* @for @warp-drive/core-types
|
|
513
496
|
* @param schema
|
|
514
497
|
* @return {Boolean}
|
|
515
498
|
* @public
|