@warp-drive/core-types 5.6.0-alpha.1 → 5.6.0-alpha.11
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/addon-main.cjs +1 -1
- package/dist/-private.js +1 -79
- package/dist/-private.js.map +1 -1
- package/dist/identifier.js +1 -92
- package/dist/identifier.js.map +1 -1
- package/dist/record.js +1 -74
- package/dist/record.js.map +1 -1
- package/dist/request.js +1 -34
- package/dist/request.js.map +1 -1
- package/dist/runtime.js +1 -35
- package/dist/runtime.js.map +1 -1
- package/dist/schema/fields.js +1 -520
- package/dist/schema/fields.js.map +1 -1
- package/dist/symbols.js +1 -92
- package/dist/symbols.js.map +1 -1
- package/package.json +3 -6
- package/unstable-preview-types/-private.d.ts +1 -13
- package/unstable-preview-types/-private.d.ts.map +1 -1
- package/unstable-preview-types/cache/aliases.d.ts +1 -1
- package/unstable-preview-types/cache/aliases.d.ts.map +1 -1
- package/unstable-preview-types/cache/change.d.ts +1 -6
- package/unstable-preview-types/cache/change.d.ts.map +1 -1
- package/unstable-preview-types/cache/mutations.d.ts +1 -38
- package/unstable-preview-types/cache/mutations.d.ts.map +1 -1
- package/unstable-preview-types/cache/operations.d.ts +1 -71
- package/unstable-preview-types/cache/operations.d.ts.map +1 -1
- package/unstable-preview-types/cache/relationship.d.ts +1 -13
- package/unstable-preview-types/cache/relationship.d.ts.map +1 -1
- package/unstable-preview-types/cache.d.ts +1 -528
- package/unstable-preview-types/cache.d.ts.map +1 -1
- package/unstable-preview-types/graph.d.ts +1 -55
- package/unstable-preview-types/graph.d.ts.map +1 -1
- package/unstable-preview-types/identifier.d.ts +1 -111
- package/unstable-preview-types/identifier.d.ts.map +1 -1
- package/unstable-preview-types/index.d.ts +12 -21
- package/unstable-preview-types/index.d.ts.map +1 -1
- package/unstable-preview-types/json/raw.d.ts +1 -6
- package/unstable-preview-types/json/raw.d.ts.map +1 -1
- package/unstable-preview-types/params.d.ts +1 -9
- package/unstable-preview-types/params.d.ts.map +1 -1
- package/unstable-preview-types/record.d.ts +1 -102
- package/unstable-preview-types/record.d.ts.map +1 -1
- package/unstable-preview-types/request.d.ts +1 -336
- package/unstable-preview-types/request.d.ts.map +1 -1
- package/unstable-preview-types/runtime.d.ts +1 -15
- package/unstable-preview-types/runtime.d.ts.map +1 -1
- package/unstable-preview-types/schema/concepts.d.ts +1 -16
- package/unstable-preview-types/schema/concepts.d.ts.map +1 -1
- package/unstable-preview-types/schema/fields.d.ts +1 -1884
- package/unstable-preview-types/schema/fields.d.ts.map +1 -1
- package/unstable-preview-types/spec/document.d.ts +1 -30
- package/unstable-preview-types/spec/document.d.ts.map +1 -1
- package/unstable-preview-types/spec/error.d.ts +1 -18
- package/unstable-preview-types/spec/error.d.ts.map +1 -1
- package/unstable-preview-types/spec/json-api-raw.d.ts +1 -141
- package/unstable-preview-types/spec/json-api-raw.d.ts.map +1 -1
- package/unstable-preview-types/symbols.d.ts +1 -82
- package/unstable-preview-types/symbols.d.ts.map +1 -1
- package/unstable-preview-types/utils.d.ts +1 -4
- package/unstable-preview-types/utils.d.ts.map +1 -1
- package/dist/schema/fields.type-test.js +0 -0
- package/dist/schema/fields.type-test.js.map +0 -1
- package/unstable-preview-types/record.type-test.d.ts +0 -4
- package/unstable-preview-types/record.type-test.d.ts.map +0 -1
- package/unstable-preview-types/schema/fields.type-test.d.ts +0 -4
- package/unstable-preview-types/schema/fields.type-test.d.ts.map +0 -1
package/addon-main.cjs
CHANGED
package/dist/-private.js
CHANGED
|
@@ -1,79 +1 @@
|
|
|
1
|
-
|
|
2
|
-
const name = "@warp-drive/core-types";
|
|
3
|
-
const version = "5.6.0-alpha.1";
|
|
4
|
-
|
|
5
|
-
// in testing mode, we utilize globals to ensure only one copy exists of
|
|
6
|
-
// these maps, due to bugs in ember-auto-import
|
|
7
|
-
|
|
8
|
-
const GlobalRef = globalThis;
|
|
9
|
-
const UniversalCache = GlobalRef.__warpDrive_universalCache = GlobalRef.__warpDrive_universalCache ?? {};
|
|
10
|
-
|
|
11
|
-
// in order to support mirror packages, we ensure that each
|
|
12
|
-
// unique package name has its own global cache
|
|
13
|
-
GlobalRef[name] = GlobalRef[name] ?? {
|
|
14
|
-
__version: version
|
|
15
|
-
};
|
|
16
|
-
const GlobalSink = GlobalRef[name];
|
|
17
|
-
if (macroCondition(getGlobalConfig().WarpDrive.env.DEBUG)) {
|
|
18
|
-
if (GlobalSink.__version !== version) {
|
|
19
|
-
throw new Error('Multiple versions of WarpDrive detected, the application will malfunction.');
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
const ModuleScopedCaches = GlobalSink.__warpDrive_ModuleScopedCaches ?? {};
|
|
23
|
-
if (macroCondition(getGlobalConfig().WarpDrive.env.TESTING)) {
|
|
24
|
-
if (!GlobalSink.__warpDrive_ModuleScopedCaches) {
|
|
25
|
-
GlobalSink.__warpDrive_ModuleScopedCaches = ModuleScopedCaches;
|
|
26
|
-
} else {
|
|
27
|
-
// eslint-disable-next-line no-console
|
|
28
|
-
console.warn(`
|
|
29
|
-
Multiple copies of EmberData have been detected. This may be due to a bug in ember-auto-import
|
|
30
|
-
in which test assets get their own copy of some v2-addons. This can cause the application to
|
|
31
|
-
malfunction as each copy will maintain its own separate state.`);
|
|
32
|
-
}
|
|
33
|
-
} else {
|
|
34
|
-
if (GlobalSink.__warpDrive_hasOtherCopy) {
|
|
35
|
-
throw new Error('Multiple copies of EmberData detected, the application will malfunction.');
|
|
36
|
-
}
|
|
37
|
-
GlobalSink.__warpDrive_hasOtherCopy = true;
|
|
38
|
-
}
|
|
39
|
-
function getOrSetGlobal(key, value) {
|
|
40
|
-
if (macroCondition(getGlobalConfig().WarpDrive.env.TESTING)) {
|
|
41
|
-
const existing = ModuleScopedCaches[key];
|
|
42
|
-
if (existing === undefined) {
|
|
43
|
-
return ModuleScopedCaches[key] = value;
|
|
44
|
-
} else {
|
|
45
|
-
return existing;
|
|
46
|
-
}
|
|
47
|
-
} else {
|
|
48
|
-
return value;
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
function peekTransient(key) {
|
|
52
|
-
const globalKey = `(transient) ${key}`;
|
|
53
|
-
return ModuleScopedCaches[globalKey] ?? null;
|
|
54
|
-
}
|
|
55
|
-
function setTransient(key, value) {
|
|
56
|
-
const globalKey = `(transient) ${key}`;
|
|
57
|
-
return ModuleScopedCaches[globalKey] = value;
|
|
58
|
-
}
|
|
59
|
-
function getOrSetUniversal(key, value) {
|
|
60
|
-
if (macroCondition(getGlobalConfig().WarpDrive.env.TESTING)) {
|
|
61
|
-
const existing = UniversalCache[key];
|
|
62
|
-
if (existing === undefined) {
|
|
63
|
-
return UniversalCache[key] = value;
|
|
64
|
-
} else {
|
|
65
|
-
return existing;
|
|
66
|
-
}
|
|
67
|
-
} else {
|
|
68
|
-
return value;
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
function peekUniversalTransient(key) {
|
|
72
|
-
const globalKey = `(transient) ${key}`;
|
|
73
|
-
return UniversalCache[globalKey] ?? null;
|
|
74
|
-
}
|
|
75
|
-
function setUniversalTransient(key, value) {
|
|
76
|
-
const globalKey = `(transient) ${key}`;
|
|
77
|
-
return UniversalCache[globalKey] = value;
|
|
78
|
-
}
|
|
79
|
-
export { getOrSetGlobal, getOrSetUniversal, peekTransient, peekUniversalTransient, setTransient, setUniversalTransient };
|
|
1
|
+
export * from '@warp-drive/core/types/-private';
|
package/dist/-private.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"-private.js","sources":[
|
|
1
|
+
{"version":3,"file":"-private.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
package/dist/identifier.js
CHANGED
|
@@ -1,92 +1 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
@module @ember-data/store
|
|
5
|
-
*/
|
|
6
|
-
// provided for additional debuggability
|
|
7
|
-
const DEBUG_CLIENT_ORIGINATED = Symbol('record-originated-on-client');
|
|
8
|
-
const DEBUG_IDENTIFIER_BUCKET = Symbol('identifier-bucket');
|
|
9
|
-
const DEBUG_STALE_CACHE_OWNER = Symbol('warpDriveStaleCache');
|
|
10
|
-
function ProdSymbol(str, debugStr) {
|
|
11
|
-
return macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? Symbol(debugStr) : str;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
// also present in production
|
|
15
|
-
const CACHE_OWNER = ProdSymbol('__$co', 'CACHE_OWNER');
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* An Identifier specific to a record which may or may not
|
|
19
|
-
* be present in the cache.
|
|
20
|
-
*
|
|
21
|
-
* The absence of an `id` DOES NOT indicate that this
|
|
22
|
-
* Identifier is for a new client-created record as it
|
|
23
|
-
* may also indicate that it was generated for a secondary
|
|
24
|
-
* index and the primary `id` index is not yet known.
|
|
25
|
-
*
|
|
26
|
-
* @internal
|
|
27
|
-
*/
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* Used when an Identifier is known to be the stable version
|
|
31
|
-
*
|
|
32
|
-
* @internal
|
|
33
|
-
*/
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* Used when a StableRecordIdentifier was not created locally as part
|
|
37
|
-
* of a call to store.createRecord
|
|
38
|
-
*
|
|
39
|
-
* Distinguishing between this Identifier and one for a client created
|
|
40
|
-
* record that was created with an ID is generally speaking not possible
|
|
41
|
-
* at runtime, so anything with an ID typically narrows to this.
|
|
42
|
-
*
|
|
43
|
-
* @internal
|
|
44
|
-
*/
|
|
45
|
-
|
|
46
|
-
/**
|
|
47
|
-
* Used when a StableRecordIdentifier was created locally
|
|
48
|
-
* (by a call to store.createRecord).
|
|
49
|
-
*
|
|
50
|
-
* It is possible in rare circumstances to have a StableRecordIdentifier
|
|
51
|
-
* that is not for a new record but does not have an ID. This would
|
|
52
|
-
* happen if a user intentionally created one for use with a secondary-index
|
|
53
|
-
* prior to the record having been fully loaded.
|
|
54
|
-
*
|
|
55
|
-
* @internal
|
|
56
|
-
*/
|
|
57
|
-
|
|
58
|
-
/**
|
|
59
|
-
* A referentially stable object with a unique string (lid) that can be used
|
|
60
|
-
* as a reference to data in the cache.
|
|
61
|
-
*
|
|
62
|
-
* Every record instance has a unique identifier, and identifiers may refer
|
|
63
|
-
* to data that has never been loaded (for instance, in an async relationship).
|
|
64
|
-
*
|
|
65
|
-
* @class StableRecordIdentifier
|
|
66
|
-
* @public
|
|
67
|
-
*/
|
|
68
|
-
|
|
69
|
-
/**
|
|
70
|
-
* A string representing a unique identity.
|
|
71
|
-
*
|
|
72
|
-
* @property lid
|
|
73
|
-
* @type {String}
|
|
74
|
-
* @public
|
|
75
|
-
*/
|
|
76
|
-
/**
|
|
77
|
-
* the primary resource `type` or `modelName` this identity belongs to.
|
|
78
|
-
*
|
|
79
|
-
* @property type
|
|
80
|
-
* @type {String}
|
|
81
|
-
* @public
|
|
82
|
-
*/
|
|
83
|
-
/**
|
|
84
|
-
* the primary id for the record this identity belongs to. `null`
|
|
85
|
-
* if not yet assigned an id.
|
|
86
|
-
*
|
|
87
|
-
* @property id
|
|
88
|
-
* @type {String | null}
|
|
89
|
-
* @public
|
|
90
|
-
*/
|
|
91
|
-
|
|
92
|
-
export { CACHE_OWNER, DEBUG_CLIENT_ORIGINATED, DEBUG_IDENTIFIER_BUCKET, DEBUG_STALE_CACHE_OWNER };
|
|
1
|
+
export * from '@warp-drive/core/types/identifier';
|
package/dist/identifier.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"identifier.js","sources":[
|
|
1
|
+
{"version":3,"file":"identifier.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
package/dist/record.js
CHANGED
|
@@ -1,74 +1 @@
|
|
|
1
|
-
|
|
2
|
-
* @module @warp-drive/core-types
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Records may be anything, They don't even
|
|
7
|
-
* have to be objects.
|
|
8
|
-
*
|
|
9
|
-
* Whatever they are, if they have a Type
|
|
10
|
-
* property, that property will be used by EmberData
|
|
11
|
-
* and WarpDrive to provide better type safety and
|
|
12
|
-
* intellisense.
|
|
13
|
-
*
|
|
14
|
-
* @class TypedRecordInstance
|
|
15
|
-
* @typedoc
|
|
16
|
-
*/
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* A type utility that extracts the Type if available,
|
|
20
|
-
* otherwise it returns never.
|
|
21
|
-
*
|
|
22
|
-
* @typedoc
|
|
23
|
-
*/
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* A type utility that extracts the Type if available,
|
|
27
|
-
* otherwise it returns string
|
|
28
|
-
*
|
|
29
|
-
* @typedoc
|
|
30
|
-
*/
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* A Utility that extracts either resource types or resource paths from a TypedRecordInstance.
|
|
34
|
-
*
|
|
35
|
-
* Its limitations are mostly around its intentional non-recursiveness. It presumes that APIs which
|
|
36
|
-
* implement includes will not allow cyclical include paths, and will collapse includes by type.
|
|
37
|
-
*
|
|
38
|
-
* This follows closer to the JSON:API fields spec than to the includes spec in nature, but in
|
|
39
|
-
* practice it is so impracticle for an API to allow z-algo include paths that this is probably
|
|
40
|
-
* reasonable.
|
|
41
|
-
*
|
|
42
|
-
* We may need to revisit this in the future, opting to either make this restriction optional or
|
|
43
|
-
* to allow for other strategies.
|
|
44
|
-
*
|
|
45
|
-
* There's a 90% chance this particular implementation belongs being in the JSON:API package instead
|
|
46
|
-
* of core-types, but it's here for now.
|
|
47
|
-
*
|
|
48
|
-
* @typedoc
|
|
49
|
-
*/
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
* A utility that provides the union of all ResourceName for all potential
|
|
53
|
-
* includes for the given TypedRecordInstance.
|
|
54
|
-
*
|
|
55
|
-
* @typedoc
|
|
56
|
-
*/
|
|
57
|
-
|
|
58
|
-
// ToPaths<ExpandIgnore<T, true>, false>;
|
|
59
|
-
|
|
60
|
-
/**
|
|
61
|
-
* A utility that provides the union type of all valid include paths for the given
|
|
62
|
-
* TypedRecordInstance.
|
|
63
|
-
*
|
|
64
|
-
* Cyclical paths are filtered out.
|
|
65
|
-
*
|
|
66
|
-
* @typedoc
|
|
67
|
-
*/
|
|
68
|
-
|
|
69
|
-
function createIncludeValidator() {
|
|
70
|
-
return function validateIncludes(includes) {
|
|
71
|
-
return includes;
|
|
72
|
-
};
|
|
73
|
-
}
|
|
74
|
-
export { createIncludeValidator };
|
|
1
|
+
export * from '@warp-drive/core/types/record';
|
package/dist/record.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"record.js","sources":[
|
|
1
|
+
{"version":3,"file":"record.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
package/dist/request.js
CHANGED
|
@@ -1,34 +1 @@
|
|
|
1
|
-
|
|
2
|
-
const SkipCache = getOrSetUniversal('SkipCache', Symbol.for('wd:skip-cache'));
|
|
3
|
-
const EnableHydration = getOrSetUniversal('EnableHydration', Symbol.for('wd:enable-hydration'));
|
|
4
|
-
const IS_FUTURE = getOrSetGlobal('IS_FUTURE', Symbol('IS_FUTURE'));
|
|
5
|
-
const STRUCTURED = getOrSetGlobal('DOC', Symbol('DOC'));
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Use these options to adjust CacheHandler behavior for a request.
|
|
9
|
-
*
|
|
10
|
-
* @typedoc
|
|
11
|
-
*/
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* JavaScript's native Request class.
|
|
15
|
-
*
|
|
16
|
-
* EmberData provides our own typings due to incompleteness in the native typings.
|
|
17
|
-
*
|
|
18
|
-
* @typedoc
|
|
19
|
-
*/
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* Extends JavaScript's native {@link Request} object with additional
|
|
23
|
-
* properties specific to the RequestManager's capabilities.
|
|
24
|
-
*
|
|
25
|
-
* @typedoc
|
|
26
|
-
*/
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* Immutable version of {@link RequestInfo}. This is what is passed to handlers.
|
|
30
|
-
*
|
|
31
|
-
* @typedoc
|
|
32
|
-
*/
|
|
33
|
-
|
|
34
|
-
export { EnableHydration, IS_FUTURE, STRUCTURED, SkipCache };
|
|
1
|
+
export * from '@warp-drive/core/types/request';
|
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":[],"sourcesContent":[],"names":[],"mappings":""}
|
package/dist/runtime.js
CHANGED
|
@@ -1,35 +1 @@
|
|
|
1
|
-
|
|
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_CACHE: 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 };
|
|
1
|
+
export * from '@warp-drive/core/types/runtime';
|
package/dist/runtime.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtime.js","sources":[
|
|
1
|
+
{"version":3,"file":"runtime.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|