File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ // @see https://stackoverflow.com/a/51365037/2391359
2+ export type RecursivePartial < T > = {
3+ [ P in keyof T ] ?: T [ P ] extends ( infer U ) [ ]
4+ ? RecursivePartial < U > [ ]
5+ : T [ P ] extends object | undefined
6+ ? RecursivePartial < T [ P ] >
7+ : T [ P ] ;
8+ } ;
Original file line number Diff line number Diff line change 1+ import { RecursivePartial } from '../../core/utils/types' ;
2+
13export interface V2Translations {
24 consentModal : {
35 title : string ;
@@ -8,7 +10,7 @@ export interface V2Translations {
810 } ;
911 } ;
1012 consentNotice : {
11- title ? : string ;
13+ title : string ;
1214 description : string ;
1315 changeDescription : string ;
1416 learnMore : string ;
@@ -47,40 +49,42 @@ export interface V2Consents {
4749export interface V2App {
4850 name : string ;
4951 title : string ;
50- description : string ;
51- cookies : string [ ] ;
52+ description ?: string ;
53+ cookies : Array <
54+ string | RegExp | [ name : string , path : string , domain : string ]
55+ > ;
5256 purposes : string [ ] ;
53- callback : ( consent : boolean , app : V2App ) => void ;
54- required : boolean ;
55- optOut : boolean ;
56- default : boolean ;
57- onlyOnce : boolean ;
57+ callback ? : ( consent : boolean , app : V2App ) => void ;
58+ required ? : boolean ;
59+ optOut ? : boolean ;
60+ default ? : boolean ;
61+ onlyOnce ? : boolean ;
5862}
5963
6064export interface V2Category {
6165 name : string ;
6266 title : string ;
63- description : string ;
67+ description ? : string ;
6468 apps : string [ ] ;
6569}
6670
6771export interface V2Config {
6872 elementID : string ;
6973 appElement : string ;
70- stylePrefix : string ;
71- cookieName : string ;
72- cookieExpiresAfterDays : 365 ;
73- cookieDomain : undefined ;
74- stringifyCookie : ( consents : V2Consents ) => string ;
75- parseCookie : ( consents : string ) => V2Consents ;
74+ stylePrefix ? : string ;
75+ cookieName ? : string ;
76+ cookieExpiresAfterDays ?: number ;
77+ cookieDomain ?: string ;
78+ stringifyCookie ? : ( consents : V2Consents ) => string ;
79+ parseCookie ? : ( consents : string ) => V2Consents ;
7680 privacyPolicy : string ;
77- default : boolean ;
78- mustConsent : boolean ;
79- mustNotice : boolean ;
80- logo : boolean ;
81+ default ? : boolean ;
82+ mustConsent ? : boolean ;
83+ mustNotice ? : boolean ;
84+ logo ? : boolean ;
8185 lang : string ;
82- translations : Record < string , V2Translations > ;
86+ translations ? : Record < string , RecursivePartial < V2Translations > > ;
8387 apps : V2App [ ] ;
84- categories : V2Category [ ] ;
85- debug : boolean ;
88+ categories ? : V2Category [ ] ;
89+ debug ? : boolean ;
8690}
Original file line number Diff line number Diff line change 11import cleanDeep from 'clean-deep' ;
22import type { Translations } from '../../ui/types' ;
33import type { V2Translations } from '../v2/types' ;
4+ import { RecursivePartial } from '../../core/utils/types' ;
45
56const join = ( strings : string [ ] , separator = ' ' ) =>
67 strings . filter ( ( string ) => ! ! string ) . join ( separator ) ;
78
89export const migrateTranslations = (
9- translations : Partial < V2Translations >
10+ translations : RecursivePartial < V2Translations >
1011) : Translations =>
1112 cleanDeep ( {
1213 banner : {
You can’t perform that action at this time.
0 commit comments