@warp-drive-mirror/utilities 5.7.0-alpha.2 → 5.7.0-alpha.21
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/declarations/-private/active-record/find-record.d.ts +2 -2
- package/declarations/-private/json-api/find-record.d.ts +2 -2
- package/declarations/-private/json-api/query.d.ts +2 -2
- package/declarations/-private/json-api/serialize.d.ts +6 -6
- package/declarations/-private/rest/find-record.d.ts +2 -2
- package/declarations/derivations.d.ts +27 -0
- package/dist/derivations.js +30 -0
- package/dist/json-api.js +2 -2
- package/package.json +4 -4
|
@@ -59,7 +59,7 @@ export type FindRecordResultDocument<T> = Omit<SingleResourceDataDocument<T>, "d
|
|
|
59
59
|
* @param identifier
|
|
60
60
|
* @param options
|
|
61
61
|
*/
|
|
62
|
-
export declare function findRecord<T>(identifier: RemotelyAccessibleIdentifier<TypeFromInstance<T>>, options?: FindRecordOptions
|
|
62
|
+
export declare function findRecord<T>(identifier: RemotelyAccessibleIdentifier<TypeFromInstance<T>>, options?: FindRecordOptions): FindRecordRequestOptions<FindRecordResultDocument<T>, T>;
|
|
63
63
|
export declare function findRecord(identifier: RemotelyAccessibleIdentifier, options?: FindRecordOptions): FindRecordRequestOptions;
|
|
64
|
-
export declare function findRecord<T>(type: TypeFromInstance<T>, id: string, options?: FindRecordOptions
|
|
64
|
+
export declare function findRecord<T>(type: TypeFromInstance<T>, id: string, options?: FindRecordOptions): FindRecordRequestOptions<FindRecordResultDocument<T>, T>;
|
|
65
65
|
export declare function findRecord(type: string, id: string, options?: FindRecordOptions): FindRecordRequestOptions;
|
|
@@ -59,7 +59,7 @@ import type { SingleResourceDataDocument } from "@warp-drive-mirror/core/types/s
|
|
|
59
59
|
export type FindRecordResultDocument<T> = Omit<SingleResourceDataDocument<T>, "data"> & {
|
|
60
60
|
data: T;
|
|
61
61
|
};
|
|
62
|
-
export declare function findRecord<T>(identifier: RemotelyAccessibleIdentifier<TypeFromInstance<T>>, options?: FindRecordOptions
|
|
62
|
+
export declare function findRecord<T>(identifier: RemotelyAccessibleIdentifier<TypeFromInstance<T>>, options?: FindRecordOptions): FindRecordRequestOptions<FindRecordResultDocument<T>, T>;
|
|
63
63
|
export declare function findRecord(identifier: RemotelyAccessibleIdentifier, options?: FindRecordOptions): FindRecordRequestOptions;
|
|
64
|
-
export declare function findRecord<T>(type: TypeFromInstance<T>, id: string, options?: FindRecordOptions
|
|
64
|
+
export declare function findRecord<T>(type: TypeFromInstance<T>, id: string, options?: FindRecordOptions): FindRecordRequestOptions<FindRecordResultDocument<T>, T>;
|
|
65
65
|
export declare function findRecord(type: string, id: string, options?: FindRecordOptions): FindRecordRequestOptions;
|
|
@@ -53,7 +53,7 @@ import type { CollectionResourceDataDocument } from "@warp-drive-mirror/core/typ
|
|
|
53
53
|
* @param query
|
|
54
54
|
* @param options
|
|
55
55
|
*/
|
|
56
|
-
export declare function query<T extends TypedRecordInstance>(type: TypeFromInstance<T>, query?: QueryParamsSource
|
|
56
|
+
export declare function query<T extends TypedRecordInstance>(type: TypeFromInstance<T>, query?: QueryParamsSource, options?: ConstrainedRequestOptions): QueryRequestOptions<CollectionResourceDataDocument<T>>;
|
|
57
57
|
export declare function query(type: string, query?: QueryParamsSource, options?: ConstrainedRequestOptions): QueryRequestOptions;
|
|
58
58
|
/**
|
|
59
59
|
* Builds request options to query for resources, usually by a primary
|
|
@@ -99,5 +99,5 @@ export declare function query(type: string, query?: QueryParamsSource, options?:
|
|
|
99
99
|
* @param query
|
|
100
100
|
* @param options
|
|
101
101
|
*/
|
|
102
|
-
export declare function postQuery<T>(type: TypeFromInstance<T>, query?: QueryParamsSource, options?: ConstrainedRequestOptions): PostQueryRequestOptions<CollectionResourceDataDocument<T
|
|
102
|
+
export declare function postQuery<T>(type: TypeFromInstance<T>, query?: QueryParamsSource, options?: ConstrainedRequestOptions): PostQueryRequestOptions<CollectionResourceDataDocument<T>>;
|
|
103
103
|
export declare function postQuery(type: string, query?: QueryParamsSource, options?: ConstrainedRequestOptions): PostQueryRequestOptions;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Cache } from "@warp-drive-mirror/core/types/cache";
|
|
2
|
-
import type {
|
|
2
|
+
import type { ResourceKey } from "@warp-drive-mirror/core/types/identifier";
|
|
3
3
|
import type { Value } from "@warp-drive-mirror/core/types/json/raw";
|
|
4
4
|
import type { InnerRelationshipDocument, ResourceObject } from "@warp-drive-mirror/core/types/spec/json-api-raw";
|
|
5
5
|
type ChangedRelationshipData = InnerRelationshipDocument;
|
|
@@ -20,13 +20,13 @@ export type JsonApiResourcePatch = {
|
|
|
20
20
|
*
|
|
21
21
|
* @public
|
|
22
22
|
* @param {Cache} cache}
|
|
23
|
-
* @param {
|
|
23
|
+
* @param {ResourceKey} identifier
|
|
24
24
|
* @return {Object} An object with a `data` property containing the serialized resource patch
|
|
25
25
|
*/
|
|
26
|
-
export declare function serializeResources(cache: Cache, identifiers:
|
|
26
|
+
export declare function serializeResources(cache: Cache, identifiers: ResourceKey): {
|
|
27
27
|
data: ResourceObject;
|
|
28
28
|
};
|
|
29
|
-
export declare function serializeResources(cache: Cache, identifiers:
|
|
29
|
+
export declare function serializeResources(cache: Cache, identifiers: ResourceKey[]): {
|
|
30
30
|
data: ResourceObject[];
|
|
31
31
|
};
|
|
32
32
|
/**
|
|
@@ -47,10 +47,10 @@ export declare function serializeResources(cache: Cache, identifiers: StableReco
|
|
|
47
47
|
*
|
|
48
48
|
* @public
|
|
49
49
|
* @param {Cache} cache}
|
|
50
|
-
* @param {
|
|
50
|
+
* @param {ResourceKey} identifier
|
|
51
51
|
* @return {Object} An object with a `data` property containing the serialized resource patch
|
|
52
52
|
*/
|
|
53
|
-
export declare function serializePatch(cache: Cache, identifier:
|
|
53
|
+
export declare function serializePatch(cache: Cache, identifier: ResourceKey): {
|
|
54
54
|
data: JsonApiResourcePatch;
|
|
55
55
|
};
|
|
56
56
|
export {};
|
|
@@ -59,7 +59,7 @@ import type { SingleResourceDataDocument } from "@warp-drive-mirror/core/types/s
|
|
|
59
59
|
export type FindRecordResultDocument<T> = Omit<SingleResourceDataDocument<T>, "data"> & {
|
|
60
60
|
data: T;
|
|
61
61
|
};
|
|
62
|
-
export declare function findRecord<T>(identifier: RemotelyAccessibleIdentifier<TypeFromInstance<T>>, options?: FindRecordOptions
|
|
62
|
+
export declare function findRecord<T>(identifier: RemotelyAccessibleIdentifier<TypeFromInstance<T>>, options?: FindRecordOptions): FindRecordRequestOptions<FindRecordResultDocument<T>, T>;
|
|
63
63
|
export declare function findRecord(identifier: RemotelyAccessibleIdentifier, options?: FindRecordOptions): FindRecordRequestOptions;
|
|
64
|
-
export declare function findRecord<T>(type: TypeFromInstance<T>, id: string, options?: FindRecordOptions
|
|
64
|
+
export declare function findRecord<T>(type: TypeFromInstance<T>, id: string, options?: FindRecordOptions): FindRecordRequestOptions<FindRecordResultDocument<T>, T>;
|
|
65
65
|
export declare function findRecord(type: string, id: string, options?: FindRecordOptions): FindRecordRequestOptions;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { ReactiveResource } from "@warp-drive-mirror/core/reactive";
|
|
2
|
+
import { Type } from "@warp-drive-mirror/core/types/symbols";
|
|
3
|
+
interface ConcatDerivation {
|
|
4
|
+
(record: ReactiveResource & {
|
|
5
|
+
[key: string]: unknown;
|
|
6
|
+
}, options: Record<string, unknown> | null, _prop: string): string;
|
|
7
|
+
[Type]: "concat";
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* A derivation for use by {@link ReactiveResource} that joins the given fields
|
|
11
|
+
* with the optional separator (or '' if no separator is provided).
|
|
12
|
+
*
|
|
13
|
+
* Generally you should not need to import and use this function directly.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* {
|
|
17
|
+
* name: 'fullName',
|
|
18
|
+
* kind: 'derived',
|
|
19
|
+
* type: 'concat',
|
|
20
|
+
* options: {
|
|
21
|
+
* fields: ['firstName', 'lastName'],
|
|
22
|
+
* separator: ' ',
|
|
23
|
+
* },
|
|
24
|
+
* }
|
|
25
|
+
*/
|
|
26
|
+
export declare const concat: ConcatDerivation;
|
|
27
|
+
export {};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { Type } from '@warp-drive-mirror/core/types/symbols';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* A derivation for use by {@link ReactiveResource} that joins the given fields
|
|
5
|
+
* with the optional separator (or '' if no separator is provided).
|
|
6
|
+
*
|
|
7
|
+
* Generally you should not need to import and use this function directly.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* {
|
|
11
|
+
* name: 'fullName',
|
|
12
|
+
* kind: 'derived',
|
|
13
|
+
* type: 'concat',
|
|
14
|
+
* options: {
|
|
15
|
+
* fields: ['firstName', 'lastName'],
|
|
16
|
+
* separator: ' ',
|
|
17
|
+
* },
|
|
18
|
+
* }
|
|
19
|
+
*/
|
|
20
|
+
const concat = (record, options, _prop) => {
|
|
21
|
+
if (!options) {
|
|
22
|
+
throw new Error(`options is required`);
|
|
23
|
+
}
|
|
24
|
+
// SAFETY: we cast internally to a more specific type, for our own use
|
|
25
|
+
// SAFETY: but provide the more general signature to the schema service
|
|
26
|
+
const opts = options;
|
|
27
|
+
return opts.fields.map(field => record[field]).join(opts.separator ?? '');
|
|
28
|
+
};
|
|
29
|
+
concat[Type] = 'concat';
|
|
30
|
+
export { concat };
|
package/dist/json-api.js
CHANGED
|
@@ -538,7 +538,7 @@ function updateRecord(record, options = {}) {
|
|
|
538
538
|
*
|
|
539
539
|
* @public
|
|
540
540
|
* @param {Cache} cache}
|
|
541
|
-
* @param {
|
|
541
|
+
* @param {ResourceKey} identifier
|
|
542
542
|
* @return {Object} An object with a `data` property containing the serialized resource patch
|
|
543
543
|
*/
|
|
544
544
|
function serializeResources(cache, identifiers) {
|
|
@@ -623,7 +623,7 @@ function _serializeResource(cache, identifier) {
|
|
|
623
623
|
*
|
|
624
624
|
* @public
|
|
625
625
|
* @param {Cache} cache}
|
|
626
|
-
* @param {
|
|
626
|
+
* @param {ResourceKey} identifier
|
|
627
627
|
* @return {Object} An object with a `data` property containing the serialized resource patch
|
|
628
628
|
*/
|
|
629
629
|
function serializePatch(cache, identifier) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@warp-drive-mirror/utilities",
|
|
3
|
-
"version": "5.7.0-alpha.
|
|
3
|
+
"version": "5.7.0-alpha.21",
|
|
4
4
|
"description": "Utilities package for WarpDrive | Things your app might find useful",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ember-addon"
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
}
|
|
37
37
|
},
|
|
38
38
|
"peerDependencies": {
|
|
39
|
-
"@warp-drive-mirror/core": "5.7.0-alpha.
|
|
39
|
+
"@warp-drive-mirror/core": "5.7.0-alpha.21"
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
42
|
"@embroider/macros": "^1.16.12"
|
|
@@ -45,8 +45,8 @@
|
|
|
45
45
|
"@babel/core": "^7.26.10",
|
|
46
46
|
"@babel/plugin-transform-typescript": "^7.27.0",
|
|
47
47
|
"@babel/preset-typescript": "^7.27.0",
|
|
48
|
-
"@warp-drive/internal-config": "5.7.0-alpha.
|
|
49
|
-
"@warp-drive-mirror/core": "5.7.0-alpha.
|
|
48
|
+
"@warp-drive/internal-config": "5.7.0-alpha.21",
|
|
49
|
+
"@warp-drive-mirror/core": "5.7.0-alpha.21",
|
|
50
50
|
"decorator-transforms": "^2.3.0",
|
|
51
51
|
"expect-type": "^1.2.1",
|
|
52
52
|
"typescript": "^5.8.3",
|