@warp-drive-mirror/utilities 5.7.0-alpha.2 → 5.7.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/declarations/derivations.d.ts +27 -0
- package/dist/derivations.js +30 -0
- package/package.json +4 -4
|
@@ -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/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.4",
|
|
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.4"
|
|
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.4",
|
|
49
|
+
"@warp-drive-mirror/core": "5.7.0-alpha.4",
|
|
50
50
|
"decorator-transforms": "^2.3.0",
|
|
51
51
|
"expect-type": "^1.2.1",
|
|
52
52
|
"typescript": "^5.8.3",
|