@guardian/commercial-core 0.34.0 → 0.34.1
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.
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
declare type
|
|
3
|
-
[K in keyof T]-?: ValidTargeting<T[K], K>;
|
|
4
|
-
}[keyof T];
|
|
5
|
-
declare type ObjectWithDefinedValues<T> = Pick<T, DefinedKeys<T>>;
|
|
1
|
+
import type { ConditionalExcept } from 'type-fest';
|
|
2
|
+
declare type ValidTargetingObject<Base> = ConditionalExcept<Base, null | undefined | '' | readonly [] | readonly [''] | boolean | number>;
|
|
6
3
|
/**
|
|
7
4
|
* Picks only keys with targeting values from an object.
|
|
8
5
|
* A targeting values is defined as either:
|
|
@@ -24,5 +21,5 @@ declare type ObjectWithDefinedValues<T> = Pick<T, DefinedKeys<T>>;
|
|
|
24
21
|
* clean.invalid
|
|
25
22
|
* ```
|
|
26
23
|
*/
|
|
27
|
-
export declare const pickTargetingValues: <T extends Record<string, string | readonly string[] | undefined>>(obj: T) =>
|
|
24
|
+
export declare const pickTargetingValues: <T extends Record<string, string | readonly string[] | undefined>>(obj: T) => import("type-fest").Except<T, NonNullable<{ [Key in keyof T]: T[Key] extends number | boolean | "" | readonly [] | readonly [""] | null | undefined ? Key : never; }[keyof T]>>;
|
|
28
25
|
export {};
|
|
@@ -37,7 +37,9 @@ const pickTargetingValues = (obj) => {
|
|
|
37
37
|
return Object.entries(obj).reduce((valid, [key, value]) => {
|
|
38
38
|
if (isValidTargeting(value)) {
|
|
39
39
|
// @ts-expect-error -- isValidTargeting checks this
|
|
40
|
-
valid[key] = value
|
|
40
|
+
valid[key] = Array.isArray(value)
|
|
41
|
+
? value.filter(isTargetingString)
|
|
42
|
+
: value;
|
|
41
43
|
}
|
|
42
44
|
return valid;
|
|
43
45
|
}, initialValue);
|
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
declare type
|
|
3
|
-
[K in keyof T]-?: ValidTargeting<T[K], K>;
|
|
4
|
-
}[keyof T];
|
|
5
|
-
declare type ObjectWithDefinedValues<T> = Pick<T, DefinedKeys<T>>;
|
|
1
|
+
import type { ConditionalExcept } from 'type-fest';
|
|
2
|
+
declare type ValidTargetingObject<Base> = ConditionalExcept<Base, null | undefined | '' | readonly [] | readonly [''] | boolean | number>;
|
|
6
3
|
/**
|
|
7
4
|
* Picks only keys with targeting values from an object.
|
|
8
5
|
* A targeting values is defined as either:
|
|
@@ -24,5 +21,5 @@ declare type ObjectWithDefinedValues<T> = Pick<T, DefinedKeys<T>>;
|
|
|
24
21
|
* clean.invalid
|
|
25
22
|
* ```
|
|
26
23
|
*/
|
|
27
|
-
export declare const pickTargetingValues: <T extends Record<string, string | readonly string[] | undefined>>(obj: T) =>
|
|
24
|
+
export declare const pickTargetingValues: <T extends Record<string, string | readonly string[] | undefined>>(obj: T) => import("type-fest").Except<T, NonNullable<{ [Key in keyof T]: T[Key] extends number | boolean | "" | readonly [] | readonly [""] | null | undefined ? Key : never; }[keyof T]>>;
|
|
28
25
|
export {};
|
|
@@ -34,7 +34,9 @@ export const pickTargetingValues = (obj) => {
|
|
|
34
34
|
return Object.entries(obj).reduce((valid, [key, value]) => {
|
|
35
35
|
if (isValidTargeting(value)) {
|
|
36
36
|
// @ts-expect-error -- isValidTargeting checks this
|
|
37
|
-
valid[key] = value
|
|
37
|
+
valid[key] = Array.isArray(value)
|
|
38
|
+
? value.filter(isTargetingString)
|
|
39
|
+
: value;
|
|
38
40
|
}
|
|
39
41
|
return valid;
|
|
40
42
|
}, initialValue);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@guardian/commercial-core",
|
|
3
|
-
"version": "0.34.
|
|
3
|
+
"version": "0.34.1",
|
|
4
4
|
"description": "Guardian advertising business logic",
|
|
5
5
|
"homepage": "https://github.com/guardian/commercial-core#readme",
|
|
6
6
|
"bugs": {
|
|
@@ -71,6 +71,7 @@
|
|
|
71
71
|
"prettier": "^2.5.0",
|
|
72
72
|
"semantic-release": "^18.0.1",
|
|
73
73
|
"ts-jest": "^27.0.7",
|
|
74
|
+
"type-fest": "^2.8.0",
|
|
74
75
|
"typescript": "^4.5.2",
|
|
75
76
|
"web-vitals": "^2.1.2"
|
|
76
77
|
},
|