cogfy-data-exchange 1.0.17 → 1.0.19

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.
@@ -7,11 +7,14 @@ type ExtractScreenById<T, Id extends string> = T extends {
7
7
  } ? Screens extends readonly unknown[] ? Extract<Screens[number], {
8
8
  id: Id;
9
9
  }> : never : never;
10
+ type FlattenListItems<C> = C extends {
11
+ 'list-items': infer Items;
12
+ } ? Items extends readonly unknown[] ? C | Items[number] : C : C;
10
13
  type FlattenIfChildren<C> = C extends {
11
14
  type: 'If';
12
15
  then: infer Then;
13
16
  else?: infer Else;
14
- } ? (Then extends readonly unknown[] ? FlattenIfChildren<Then[number]> : never) | (Else extends readonly unknown[] ? FlattenIfChildren<Else[number]> : never) : C;
17
+ } ? (Then extends readonly unknown[] ? FlattenIfChildren<Then[number]> : never) | (Else extends readonly unknown[] ? FlattenIfChildren<Else[number]> : never) : FlattenListItems<C>;
15
18
  type ExtractChildren<T> = T extends {
16
19
  layout: {
17
20
  children: infer C;
@@ -35,6 +38,19 @@ type ExtractScreenData<T> = T extends {
35
38
  type ExtractDataSourceIds<DS> = DS extends readonly {
36
39
  id: infer Id;
37
40
  }[] ? Id : string;
41
+ type DocumentPickerFile = {
42
+ file_name: string;
43
+ media_id: string;
44
+ cdn_url: string;
45
+ encryption_metadata: {
46
+ encryption_key: string;
47
+ hmac_key: string;
48
+ hmac: string;
49
+ iv: string;
50
+ plaintext_hash: string;
51
+ encrypted_hash: string;
52
+ };
53
+ };
38
54
  type ComponentFormValue<C> = C extends {
39
55
  type: 'RadioButtonsGroup' | 'Dropdown';
40
56
  'data-source': infer DS;
@@ -45,7 +61,9 @@ type ComponentFormValue<C> = C extends {
45
61
  type: 'TextInput' | 'TextArea' | 'DatePicker';
46
62
  } ? string : C extends {
47
63
  type: 'OptIn';
48
- } ? boolean : string;
64
+ } ? boolean : C extends {
65
+ type: 'DocumentPicker';
66
+ } ? DocumentPickerFile[] : string;
49
67
  type ResolvePayloadValue<V, Children, ScreenData> = V extends `$${'{'}form.${infer FieldName}}` ? [Extract<Children, {
50
68
  name: FieldName;
51
69
  }>] extends [never] ? string : ComponentFormValue<Extract<Children, {
@@ -1,11 +1,14 @@
1
1
  import type { FlowJson } from './flow-json';
2
2
  import type { ScreenName } from './screen';
3
3
  export type ScreenTrigger<S extends string> = `screen.${S}`;
4
+ type FlattenListItems<C> = C extends {
5
+ 'list-items': infer Items;
6
+ } ? Items extends readonly unknown[] ? C | Items[number] : C : C;
4
7
  type FlattenIfChildren<C> = C extends {
5
8
  type: 'If';
6
9
  then: infer Then;
7
10
  else?: infer Else;
8
- } ? (Then extends readonly unknown[] ? FlattenIfChildren<Then[number]> : never) | (Else extends readonly unknown[] ? FlattenIfChildren<Else[number]> : never) : C;
11
+ } ? (Then extends readonly unknown[] ? FlattenIfChildren<Then[number]> : never) | (Else extends readonly unknown[] ? FlattenIfChildren<Else[number]> : never) : FlattenListItems<C>;
9
12
  type AllChildTriggers<F extends FlowJson> = F['screens'][number] extends infer S ? S extends {
10
13
  layout: {
11
14
  children: readonly (infer C)[];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cogfy-data-exchange",
3
- "version": "1.0.17",
3
+ "version": "1.0.19",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -11,10 +11,16 @@ type ExtractScreenById<T, Id extends string> = T extends {
11
11
  : never
12
12
  : never
13
13
 
14
+ type FlattenListItems<C> = C extends { 'list-items': infer Items }
15
+ ? Items extends readonly unknown[]
16
+ ? C | Items[number]
17
+ : C
18
+ : C
19
+
14
20
  type FlattenIfChildren<C> = C extends { type: 'If'; then: infer Then; else?: infer Else }
15
21
  ? (Then extends readonly unknown[] ? FlattenIfChildren<Then[number]> : never) |
16
22
  (Else extends readonly unknown[] ? FlattenIfChildren<Else[number]> : never)
17
- : C
23
+ : FlattenListItems<C>
18
24
 
19
25
  type ExtractChildren<T> = T extends { layout: { children: infer C } }
20
26
  ? C extends readonly unknown[]
@@ -34,6 +40,20 @@ type ExtractScreenData<T> = T extends { data: infer D } ? D : never
34
40
 
35
41
  type ExtractDataSourceIds<DS> = DS extends readonly { id: infer Id }[] ? Id : string
36
42
 
43
+ type DocumentPickerFile = {
44
+ file_name: string
45
+ media_id: string
46
+ cdn_url: string
47
+ encryption_metadata: {
48
+ encryption_key: string
49
+ hmac_key: string
50
+ hmac: string
51
+ iv: string
52
+ plaintext_hash: string
53
+ encrypted_hash: string
54
+ }
55
+ }
56
+
37
57
  type ComponentFormValue<C> = C extends {
38
58
  type: 'RadioButtonsGroup' | 'Dropdown'
39
59
  'data-source': infer DS
@@ -48,7 +68,9 @@ type ComponentFormValue<C> = C extends {
48
68
  ? string
49
69
  : C extends { type: 'OptIn' }
50
70
  ? boolean
51
- : string
71
+ : C extends { type: 'DocumentPicker' }
72
+ ? DocumentPickerFile[]
73
+ : string
52
74
 
53
75
  type ResolvePayloadValue<V, Children, ScreenData> = V extends `$${'{'}form.${infer FieldName}}`
54
76
  ? [Extract<Children, { name: FieldName }>] extends [never]
@@ -3,10 +3,16 @@ import type { ScreenName } from './screen'
3
3
 
4
4
  export type ScreenTrigger<S extends string> = `screen.${S}`
5
5
 
6
+ type FlattenListItems<C> = C extends { 'list-items': infer Items }
7
+ ? Items extends readonly unknown[]
8
+ ? C | Items[number]
9
+ : C
10
+ : C
11
+
6
12
  type FlattenIfChildren<C> = C extends { type: 'If'; then: infer Then; else?: infer Else }
7
13
  ? (Then extends readonly unknown[] ? FlattenIfChildren<Then[number]> : never) |
8
14
  (Else extends readonly unknown[] ? FlattenIfChildren<Else[number]> : never)
9
- : C
15
+ : FlattenListItems<C>
10
16
 
11
17
  type AllChildTriggers<F extends FlowJson> = F['screens'][number] extends infer S
12
18
  ? S extends { layout: { children: readonly (infer C)[] } }