pwi-plata-type 0.4.207 → 0.4.209

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pwi-plata-type",
3
- "version": "0.4.207",
3
+ "version": "0.4.209",
4
4
  "main": "__BUILD__/index",
5
5
  "types": "src/@types/exported.d.ts",
6
6
  "bin": {
@@ -113,7 +113,9 @@ interface PlataEnvConfig {
113
113
 
114
114
  type DeepWritable<T extends {}> = Prettify<{
115
115
  -readonly [K in keyof T]: T[K] extends Dictionary<any> ?
116
- T[K] extends Date ? Date : DeepWritable<T[K]>
116
+ T[K] extends Date ? Date
117
+ : T[K] extends Brand<infer R> ? Brand<R>
118
+ : DeepWritable<T[K]>
117
119
  : T[K]
118
120
  }>
119
121
 
@@ -35,10 +35,15 @@ declare namespace Model {
35
35
  never
36
36
  ;
37
37
 
38
+ type HandleBrandTemplateEnvParamType<G extends unknown> =
39
+ G extends Brand<infer B> ? `${Brands[B]}` & { z__brand: B }
40
+ : `${G}`
41
+ ;
42
+
38
43
  type GetTemplateEnvParamType<const T extends PrimitiveValidationType<unknown, unknown>[]> =
39
- T extends readonly [ PrimitiveValidationType<infer G, infer H> ] ? `${G}` | H :
40
- T extends readonly [ PrimitiveValidationType<any, infer H>, PrimitiveValidationType<infer G, any> ] ? `${G}` | H :
41
- T extends readonly [ PrimitiveValidationType<any, infer H>, ...any[], PrimitiveValidationType<infer G, any> ] ? `${G}` | H :
44
+ T extends readonly [ PrimitiveValidationType<infer G, infer H> ] ? HandleBrandTemplateEnvParamType<G> | H :
45
+ T extends readonly [ PrimitiveValidationType<any, infer H>, PrimitiveValidationType<infer G, any> ] ? HandleBrandTemplateEnvParamType<G> | H :
46
+ T extends readonly [ PrimitiveValidationType<any, infer H>, ...any[], PrimitiveValidationType<infer G, any> ] ? HandleBrandTemplateEnvParamType<G> | H :
42
47
  never
43
48
  ;
44
49
 
@@ -34,6 +34,7 @@ describe('Brands', () => {
34
34
  | AssertType<typeof modelTest.type['brandString'], string, true>
35
35
  | AssertType<string, typeof modelTest.type['brandString'], false>
36
36
  | AssertType<typeof modelTest.type['brandString'], Brand<'testeModel'>, true>
37
+ | AssertType<DeepWritable<{ readonly value: Brand<'testBrand'> }>, { value: Brand<'testBrand'> }, true>
37
38
  ;
38
39
 
39
40
  it('preserva a referência e valor em runtime e altera apenas o tipo', () => {