@forgerock/davinci-client 1.0.0 → 1.2.0

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.
Files changed (124) hide show
  1. package/LICENSE +21 -0
  2. package/dist/src/index.d.ts.map +1 -0
  3. package/dist/src/index.js +9 -0
  4. package/dist/src/index.js.map +1 -0
  5. package/dist/src/lib/client.store.d.ts +352 -0
  6. package/dist/src/lib/client.store.d.ts.map +1 -0
  7. package/dist/src/lib/client.store.js +300 -0
  8. package/dist/src/lib/client.store.js.map +1 -0
  9. package/dist/src/lib/client.store.utils.d.ts +74 -0
  10. package/dist/src/lib/client.store.utils.d.ts.map +1 -0
  11. package/dist/src/lib/client.store.utils.js +48 -0
  12. package/dist/src/lib/client.store.utils.js.map +1 -0
  13. package/dist/src/lib/client.types.d.ts +19 -0
  14. package/dist/src/lib/client.types.d.ts.map +1 -0
  15. package/dist/src/lib/client.types.js +2 -0
  16. package/dist/src/lib/client.types.js.map +1 -0
  17. package/dist/src/lib/collector.types.d.ts +360 -0
  18. package/dist/src/lib/collector.types.d.ts.map +1 -0
  19. package/dist/src/lib/collector.types.js +8 -0
  20. package/dist/src/lib/collector.types.js.map +1 -0
  21. package/dist/src/lib/collector.utils.d.ts +117 -0
  22. package/dist/src/lib/collector.utils.d.ts.map +1 -0
  23. package/dist/src/lib/collector.utils.js +463 -0
  24. package/dist/src/lib/collector.utils.js.map +1 -0
  25. package/dist/{lib → src/lib}/config.slice.d.ts +12 -5
  26. package/dist/src/lib/config.slice.d.ts.map +1 -0
  27. package/dist/src/lib/config.slice.js +59 -0
  28. package/dist/src/lib/config.slice.js.map +1 -0
  29. package/dist/src/lib/config.types.d.ts +12 -0
  30. package/dist/src/lib/config.types.d.ts.map +1 -0
  31. package/dist/src/lib/config.types.js +2 -0
  32. package/dist/src/lib/config.types.js.map +1 -0
  33. package/dist/src/lib/davinci.api.d.ts +31 -0
  34. package/dist/src/lib/davinci.api.d.ts.map +1 -0
  35. package/dist/src/lib/davinci.api.js +346 -0
  36. package/dist/src/lib/davinci.api.js.map +1 -0
  37. package/dist/{lib → src/lib}/davinci.types.d.ts +101 -8
  38. package/dist/src/lib/davinci.types.d.ts.map +1 -0
  39. package/dist/src/lib/davinci.types.js +11 -0
  40. package/dist/src/lib/davinci.types.js.map +1 -0
  41. package/dist/{lib → src/lib}/davinci.utils.d.ts +10 -6
  42. package/dist/src/lib/davinci.utils.d.ts.map +1 -0
  43. package/dist/src/lib/davinci.utils.js +168 -0
  44. package/dist/src/lib/davinci.utils.js.map +1 -0
  45. package/dist/src/lib/error.types.d.ts.map +1 -0
  46. package/dist/src/lib/error.types.js +2 -0
  47. package/dist/src/lib/error.types.js.map +1 -0
  48. package/dist/src/lib/index.d.ts.map +1 -0
  49. package/dist/src/lib/index.js +9 -0
  50. package/dist/src/lib/index.js.map +1 -0
  51. package/dist/src/lib/node.reducer.d.ts +27 -0
  52. package/dist/src/lib/node.reducer.d.ts.map +1 -0
  53. package/dist/src/lib/node.reducer.js +193 -0
  54. package/dist/src/lib/node.reducer.js.map +1 -0
  55. package/dist/{lib → src/lib}/node.slice.d.ts +55 -26
  56. package/dist/src/lib/node.slice.d.ts.map +1 -0
  57. package/dist/src/lib/node.slice.js +261 -0
  58. package/dist/src/lib/node.slice.js.map +1 -0
  59. package/dist/{lib → src/lib}/node.types.d.ts +17 -8
  60. package/dist/src/lib/node.types.d.ts.map +1 -0
  61. package/dist/src/lib/node.types.js +2 -0
  62. package/dist/src/lib/node.types.js.map +1 -0
  63. package/dist/src/lib/node.utils.d.ts +4 -0
  64. package/dist/src/lib/node.utils.d.ts.map +1 -0
  65. package/dist/src/lib/node.utils.js +32 -0
  66. package/dist/src/lib/node.utils.js.map +1 -0
  67. package/dist/src/lib/wellknown.api.d.ts +5 -0
  68. package/dist/src/lib/wellknown.api.d.ts.map +1 -0
  69. package/dist/src/lib/wellknown.api.js +22 -0
  70. package/dist/src/lib/wellknown.api.js.map +1 -0
  71. package/dist/src/lib/wellknown.types.d.ts.map +1 -0
  72. package/dist/src/lib/wellknown.types.js +2 -0
  73. package/dist/src/lib/wellknown.types.js.map +1 -0
  74. package/dist/src/types.d.ts +40 -0
  75. package/dist/src/types.d.ts.map +1 -0
  76. package/dist/src/types.js +7 -0
  77. package/dist/src/types.js.map +1 -0
  78. package/package.json +39 -20
  79. package/dist/index.d.ts.map +0 -1
  80. package/dist/index.js +0 -4
  81. package/dist/lib/authorize.utils.d.ts +0 -22
  82. package/dist/lib/authorize.utils.d.ts.map +0 -1
  83. package/dist/lib/authorize.utils.js +0 -23
  84. package/dist/lib/client.store.d.ts +0 -149
  85. package/dist/lib/client.store.d.ts.map +0 -1
  86. package/dist/lib/client.store.js +0 -131
  87. package/dist/lib/client.store.utils.d.ts +0 -46
  88. package/dist/lib/client.store.utils.d.ts.map +0 -1
  89. package/dist/lib/client.store.utils.js +0 -19
  90. package/dist/lib/client.types.d.ts +0 -9
  91. package/dist/lib/client.types.d.ts.map +0 -1
  92. package/dist/lib/collector.types.d.ts +0 -78
  93. package/dist/lib/collector.types.d.ts.map +0 -1
  94. package/dist/lib/collector.utils.d.ts +0 -54
  95. package/dist/lib/collector.utils.d.ts.map +0 -1
  96. package/dist/lib/collector.utils.js +0 -88
  97. package/dist/lib/config.slice.d.ts.map +0 -1
  98. package/dist/lib/config.slice.js +0 -40
  99. package/dist/lib/config.types.d.ts +0 -9
  100. package/dist/lib/config.types.d.ts.map +0 -1
  101. package/dist/lib/davinci.api.d.ts +0 -20
  102. package/dist/lib/davinci.api.d.ts.map +0 -1
  103. package/dist/lib/davinci.api.js +0 -172
  104. package/dist/lib/davinci.types.d.ts.map +0 -1
  105. package/dist/lib/davinci.utils.d.ts.map +0 -1
  106. package/dist/lib/davinci.utils.js +0 -102
  107. package/dist/lib/error.types.d.ts.map +0 -1
  108. package/dist/lib/index.d.ts.map +0 -1
  109. package/dist/lib/node.reducer.d.ts +0 -22
  110. package/dist/lib/node.reducer.d.ts.map +0 -1
  111. package/dist/lib/node.reducer.js +0 -31
  112. package/dist/lib/node.slice.d.ts.map +0 -1
  113. package/dist/lib/node.slice.js +0 -160
  114. package/dist/lib/node.types.d.ts.map +0 -1
  115. package/dist/lib/wellknown.api.d.ts +0 -5
  116. package/dist/lib/wellknown.api.d.ts.map +0 -1
  117. package/dist/lib/wellknown.api.js +0 -15
  118. package/dist/lib/wellknown.types.d.ts.map +0 -1
  119. package/dist/types.d.ts +0 -23
  120. package/dist/types.d.ts.map +0 -1
  121. /package/dist/{index.d.ts → src/index.d.ts} +0 -0
  122. /package/dist/{lib → src/lib}/error.types.d.ts +0 -0
  123. /package/dist/{lib → src/lib}/index.d.ts +0 -0
  124. /package/dist/{lib → src/lib}/wellknown.types.d.ts +0 -0
@@ -0,0 +1,168 @@
1
+ import { nodeSlice } from './node.slice.js';
2
+ /**
3
+ * @function transformSubmitRequest - Transforms a NextNode into a DaVinciRequest for form submissions
4
+ * @param {ContinueNode} node - The node to transform into a DaVinciRequest
5
+ * @returns {DaVinciRequest} - The transformed request object
6
+ */
7
+ export function transformSubmitRequest(node, logger) {
8
+ // Filter out ActionCollectors as they are not used in form submissions
9
+ const collectors = node.client?.collectors?.filter((collector) => collector.category === 'MultiValueCollector' ||
10
+ collector.category === 'SingleValueCollector' ||
11
+ collector.category === 'ValidatedSingleValueCollector' ||
12
+ collector.category === 'ObjectValueCollector');
13
+ const formData = collectors?.reduce((acc, collector) => {
14
+ acc[collector.input.key] = collector.input.value;
15
+ return acc;
16
+ }, {});
17
+ logger.debug('Transforming submit request', { node, formData });
18
+ return {
19
+ id: node.server.id || '',
20
+ eventName: node.server.eventName || '',
21
+ interactionId: node.server.interactionId || '',
22
+ parameters: {
23
+ eventType: 'submit',
24
+ data: {
25
+ actionKey: node.client?.action || '',
26
+ formData: formData || {},
27
+ },
28
+ },
29
+ };
30
+ }
31
+ /**
32
+ * @function transformActionRequest - Transforms a NextNode into a DaVinciRequest for action requests
33
+ * @param {ContinueNode} node - The node to transform into a DaVinciRequest
34
+ * @param {string} action - The action to transform into a DaVinciRequest
35
+ * @returns {DaVinciRequest} - The transformed request object
36
+ */
37
+ export function transformActionRequest(node, action, logger) {
38
+ logger.debug('Transforming action request', { node, action });
39
+ return {
40
+ id: node.server.id || '',
41
+ eventName: node.server.eventName || '',
42
+ interactionId: node.server.interactionId || '',
43
+ parameters: {
44
+ eventType: 'action',
45
+ data: {
46
+ actionKey: action,
47
+ },
48
+ },
49
+ };
50
+ }
51
+ export function handleResponse(cacheEntry, dispatch, status, logger) {
52
+ /**
53
+ * 5XX errors are treated as unrecoverable failures
54
+ */
55
+ if (cacheEntry.isError && cacheEntry.error.status >= 500) {
56
+ logger.error('Response of 5XX indicates unrecoverable failure');
57
+ const data = cacheEntry.error.data;
58
+ const requestId = cacheEntry.requestId;
59
+ dispatch(nodeSlice.actions.failure({ data, requestId, httpStatus: cacheEntry.error.status }));
60
+ return; // Filter out 5XX's
61
+ }
62
+ /**
63
+ * Check for 4XX errors that are unrecoverable
64
+ */
65
+ if (cacheEntry.isError && cacheEntry.error.status >= 400 && cacheEntry.error.status < 500) {
66
+ const data = cacheEntry.error.data;
67
+ const requestId = cacheEntry.requestId;
68
+ // Filter out client-side "timeout" related unrecoverable failures
69
+ if (data.code === 1999 || data.code === 'requestTimedOut') {
70
+ logger.error('Error is a client-side timeout');
71
+ dispatch(nodeSlice.actions.failure({ data, requestId, httpStatus: cacheEntry.error.status }));
72
+ return; // Filter out timeouts
73
+ }
74
+ // Filter our "PingOne Authentication Connector" unrecoverable failures
75
+ if (data.connectorId === 'pingOneAuthenticationConnector' &&
76
+ (data.capabilityName === 'returnSuccessResponseRedirect' ||
77
+ data.capabilityName === 'setSession')) {
78
+ logger.error('Error is a PingOne Authentication Connector unrecoverable failure');
79
+ dispatch(nodeSlice.actions.failure({ data, requestId, httpStatus: cacheEntry.error.status }));
80
+ return;
81
+ }
82
+ logger.debug('Response with this error type should be recoverable');
83
+ // If we're still here, we have a 4XX failure that should be recoverable
84
+ dispatch(nodeSlice.actions.error({ data, requestId, httpStatus: cacheEntry.error.status }));
85
+ return;
86
+ }
87
+ /**
88
+ * Check for 3XX errors that result in CORS errors, reported as FETCH_ERROR
89
+ */
90
+ if (cacheEntry.isError && cacheEntry.error.status === 'FETCH_ERROR') {
91
+ logger.error('Response with FETCH_ERROR indicates configuration failure. Please ensure a correct Client ID for your OAuth application.');
92
+ const data = {
93
+ code: cacheEntry.error.status,
94
+ message: 'Fetch Error: Please ensure a correct Client ID for your OAuth application.',
95
+ };
96
+ const requestId = cacheEntry.requestId;
97
+ dispatch(nodeSlice.actions.failure({ data, requestId, httpStatus: cacheEntry.error.status }));
98
+ return;
99
+ }
100
+ /**
101
+ * If the response's HTTP status is a success (2XX), but the DaVinci API has returned an error,
102
+ * we need to handle this as a failure or return as unknown.
103
+ */
104
+ if (cacheEntry.isSuccess && 'error' in cacheEntry.data) {
105
+ logger.error('Response with `isSuccess` but `error` property indicates unrecoverable failure');
106
+ const data = cacheEntry.data;
107
+ const requestId = cacheEntry.requestId;
108
+ dispatch(nodeSlice.actions.failure({
109
+ data: data.error,
110
+ requestId,
111
+ httpStatus: status,
112
+ }));
113
+ return; // Filter out 2XX errors
114
+ }
115
+ /**
116
+ * If the response's HTTP status is a success (2XX), but the DaVinci API has returned an error,
117
+ * we need to handle this as a failure or return as unknown.
118
+ */
119
+ if (cacheEntry.isSuccess && 'status' in cacheEntry.data) {
120
+ const status = cacheEntry.data.status.toLowerCase();
121
+ if (status === 'failure') {
122
+ logger.error('Response with `isSuccess` and `status` of "failure" indicates unrecoverable failure');
123
+ const data = cacheEntry.data;
124
+ const requestId = cacheEntry.requestId;
125
+ dispatch(nodeSlice.actions.failure({
126
+ data: data.error,
127
+ requestId,
128
+ httpStatus: status,
129
+ }));
130
+ return; // Filter out 2XX errors with 'failure' status
131
+ }
132
+ else {
133
+ // Do nothing
134
+ }
135
+ }
136
+ /**
137
+ * If we've made it here, we have a successful response and do not have an error property.
138
+ * Parse for state of the flow and dispatch appropriate action.
139
+ */
140
+ if (cacheEntry.isSuccess) {
141
+ const requestId = cacheEntry.requestId;
142
+ const hasNextUrl = () => {
143
+ const data = cacheEntry.data;
144
+ if ('_links' in data) {
145
+ if ('next' in data._links) {
146
+ if ('href' in data._links.next) {
147
+ return true;
148
+ }
149
+ }
150
+ }
151
+ return false;
152
+ };
153
+ if ('session' in cacheEntry.data || 'authorizeResponse' in cacheEntry.data) {
154
+ const data = cacheEntry.data;
155
+ dispatch(nodeSlice.actions.success({ data, requestId, httpStatus: status }));
156
+ }
157
+ else if (hasNextUrl()) {
158
+ const data = cacheEntry.data;
159
+ dispatch(nodeSlice.actions.next({ data, requestId, httpStatus: status }));
160
+ }
161
+ else {
162
+ // If we got here, the response type is unknown and therefore an unrecoverable failure
163
+ const data = cacheEntry.data;
164
+ dispatch(nodeSlice.actions.failure({ data, requestId, httpStatus: status }));
165
+ }
166
+ }
167
+ }
168
+ //# sourceMappingURL=davinci.utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"davinci.utils.js","sourceRoot":"","sources":["../../../src/lib/davinci.utils.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAY5C;;;;GAIG;AACH,MAAM,UAAU,sBAAsB,CACpC,IAAkB,EAClB,MAAmC;IAEnC,uEAAuE;IACvE,MAAM,UAAU,GAAG,IAAI,CAAC,MAAM,EAAE,UAAU,EAAE,MAAM,CAChD,CAAC,SAAS,EAAE,EAAE,CACZ,SAAS,CAAC,QAAQ,KAAK,qBAAqB;QAC5C,SAAS,CAAC,QAAQ,KAAK,sBAAsB;QAC7C,SAAS,CAAC,QAAQ,KAAK,+BAA+B;QACtD,SAAS,CAAC,QAAQ,KAAK,sBAAsB,CAChD,CAAC;IAEF,MAAM,QAAQ,GAAG,UAAU,EAAE,MAAM,CAQhC,CAAC,GAAG,EAAE,SAAS,EAAE,EAAE;QACpB,GAAG,CAAC,SAAS,CAAC,KAAK,CAAC,GAAG,CAAC,G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QAAQ,CAAC,SAAS,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC;QAC/E,CAAC;aAAM,IAAI,UAAU,EAAE,EAAE,CAAC;YACxB,MAAM,IAAI,GAAG,UAAU,CAAC,IAA2B,CAAC;YACpD,QAAQ,CAAC,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC;QAC5E,CAAC;aAAM,CAAC;YACN,sFAAsF;YACtF,MAAM,IAAI,GAAG,UAAU,CAAC,IAA8B,CAAC;YACvD,QAAQ,CAAC,SAAS,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC;QAC/E,CAAC;IACH,CAAC;AACH,CAAC"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"error.types.d.ts","sourceRoot":"","sources":["../../../src/lib/error.types.ts"],"names":[],"mappings":"AAMA,MAAM,WAAW,YAAY;IAC3B,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACvB,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EACA,gBAAgB,GAChB,eAAe,GACf,gBAAgB,GAChB,eAAe,GACf,aAAa,GACb,eAAe,CAAC;CACrB"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=error.types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"error.types.js","sourceRoot":"","sources":["../../../src/lib/error.types.ts"],"names":[],"mappings":""}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/lib/index.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAE5C,OAAO,EAAE,OAAO,EAAE,CAAC"}
@@ -0,0 +1,9 @@
1
+ /*
2
+ * Copyright (c) 2025 Ping Identity Corporation. All rights reserved.
3
+ *
4
+ * This software may be modified and distributed under the terms
5
+ * of the MIT license. See the LICENSE file for details.
6
+ */
7
+ import { davinci } from './client.store.js';
8
+ export { davinci };
9
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/lib/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAE5C,OAAO,EAAE,OAAO,EAAE,CAAC"}
@@ -0,0 +1,27 @@
1
+ import type { DaVinciField } from './davinci.types.js';
2
+ import { ActionCollector, MultiSelectCollector, SingleSelectCollector, FlowCollector, PasswordCollector, SingleValueCollector, IdpCollector, SubmitCollector, TextCollector, ReadOnlyCollector, ValidatedTextCollector, DeviceAuthenticationCollector, DeviceRegistrationCollector, PhoneNumberCollector, PhoneNumberInputValue, UnknownCollector } from './collector.types.js';
3
+ /**
4
+ * @const nextCollectorValues - Action for setting the next collector values
5
+ * @see https://redux-toolkit.js.org/api/createAction
6
+ *
7
+ * This is for internal "collector" setup for handling the state of the current node
8
+ */
9
+ export declare const nextCollectorValues: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
10
+ fields: DaVinciField[];
11
+ formData: {
12
+ value: Record<string, unknown>;
13
+ };
14
+ }, string>;
15
+ export declare const updateCollectorValues: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
16
+ id: string;
17
+ value: string | string[] | PhoneNumberInputValue;
18
+ index?: number;
19
+ }, string>;
20
+ /**
21
+ * @const nodeCollectorReducer - Reducer for handling the collector values
22
+ * @see https://redux-toolkit.js.org/api/createReducer
23
+ */
24
+ export declare const nodeCollectorReducer: import("@reduxjs/toolkit").Reducer<(TextCollector | SingleSelectCollector | ValidatedTextCollector | PasswordCollector | MultiSelectCollector | DeviceAuthenticationCollector | DeviceRegistrationCollector | PhoneNumberCollector | IdpCollector | SubmitCollector | FlowCollector | ReadOnlyCollector | UnknownCollector | ActionCollector<"ActionCollector"> | SingleValueCollector<"SingleValueCollector">)[]> & {
25
+ getInitialState: () => (TextCollector | SingleSelectCollector | ValidatedTextCollector | PasswordCollector | MultiSelectCollector | DeviceAuthenticationCollector | DeviceRegistrationCollector | PhoneNumberCollector | IdpCollector | SubmitCollector | FlowCollector | ReadOnlyCollector | UnknownCollector | ActionCollector<"ActionCollector"> | SingleValueCollector<"SingleValueCollector">)[];
26
+ };
27
+ //# sourceMappingURL=node.reducer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"node.reducer.d.ts","sourceRoot":"","sources":["../../../src/lib/node.reducer.ts"],"names":[],"mappings":"AA4BA,OAAO,KAAK,EAAE,YAAY,EAAgB,MAAM,oBAAoB,CAAC;AACrE,OAAO,EACL,eAAe,EACf,oBAAoB,EACpB,qBAAqB,EACrB,aAAa,EACb,iBAAiB,EACjB,oBAAoB,EACpB,YAAY,EACZ,eAAe,EACf,aAAa,EACb,iBAAiB,EACjB,sBAAsB,EACtB,6BAA6B,EAC7B,2BAA2B,EAC3B,oBAAoB,EACpB,qBAAqB,EACrB,gBAAgB,EACjB,MAAM,sBAAsB,CAAC;AAE9B;;;;;GAKG;AACH,eAAO,MAAM,mBAAmB;YACtB,YAAY,EAAE;cACZ;QAAE,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;KAAE;UAC/B,CAAC;AAChB,eAAO,MAAM,qBAAqB;QAC5B,MAAM;WACH,MAAM,GAAG,MAAM,EAAE,GAAG,qBAAqB;YACxC,MAAM;UACC,CAAC;AAuBlB;;;GAGG;AACH,eAAO,MAAM,oBAAoB;;CAqL/B,CAAC"}
@@ -0,0 +1,193 @@
1
+ /*
2
+ * Copyright (c) 2025 Ping Identity Corporation. All rights reserved.
3
+ *
4
+ * This software may be modified and distributed under the terms
5
+ * of the MIT license. See the LICENSE file for details.
6
+ */
7
+ /**
8
+ * Import the required utilities from Redux Toolkit
9
+ */
10
+ import { createAction, createReducer } from '@reduxjs/toolkit';
11
+ /**
12
+ * Import the collector utilities
13
+ */
14
+ import { returnActionCollector, returnFlowCollector, returnPasswordCollector, returnIdpCollector, returnSubmitCollector, returnTextCollector, returnSingleSelectCollector, returnMultiSelectCollector, returnReadOnlyCollector, returnObjectSelectCollector, returnObjectValueCollector, returnUnknownCollector, } from './collector.utils.js';
15
+ /**
16
+ * @const nextCollectorValues - Action for setting the next collector values
17
+ * @see https://redux-toolkit.js.org/api/createAction
18
+ *
19
+ * This is for internal "collector" setup for handling the state of the current node
20
+ */
21
+ export const nextCollectorValues = createAction('node/next');
22
+ export const updateCollectorValues = createAction('node/update');
23
+ /**
24
+ * @const initialCollectorValues - Initial state for the collector values
25
+ */
26
+ const initialCollectorValues = [];
27
+ /**
28
+ * @const nodeCollectorReducer - Reducer for handling the collector values
29
+ * @see https://redux-toolkit.js.org/api/createReducer
30
+ */
31
+ export const nodeCollectorReducer = createReducer(initialCollectorValues, (builder) => {
32
+ builder
33
+ /**
34
+ * Using the `nextCollectorValues` const (e.g. `'node/next'`) to add the case
35
+ * 'node/next' is essentially derived `createSlice` below. `node.next()` is
36
+ * transformed to `'node/next'` for the action type.
37
+ */
38
+ .addCase(nextCollectorValues, (_, action) => {
39
+ const fields = action.payload.fields;
40
+ // Map the fields to the initial state with the schema of Generic Collector
41
+ const collectors = Array.isArray(fields)
42
+ ? fields.map((field, idx) => {
43
+ /**
44
+ * Some collectors may not have the same properties as others;
45
+ * LABEL field types are one of them, so let's catch them first.
46
+ */
47
+ if (field.type === 'LABEL') {
48
+ return returnReadOnlyCollector(field, idx);
49
+ }
50
+ // *Some* collectors may have default or existing data to display
51
+ const data = action.payload.formData &&
52
+ action.payload.formData.value &&
53
+ action.payload.formData.value[field.key];
54
+ // Match specific collectors
55
+ switch (field.type) {
56
+ case 'CHECKBOX':
57
+ case 'COMBOBOX': {
58
+ // Intentional fall-through
59
+ const strArr = data;
60
+ return returnMultiSelectCollector(field, idx, strArr);
61
+ }
62
+ case 'DROPDOWN':
63
+ case 'RADIO': {
64
+ // Intentional fall-through
65
+ const str = data;
66
+ return returnSingleSelectCollector(field, idx, str);
67
+ }
68
+ case 'FLOW_BUTTON':
69
+ case 'FLOW_LINK': {
70
+ // Intentional fall-through
71
+ // No data to send
72
+ return returnFlowCollector(field, idx);
73
+ }
74
+ case 'DEVICE_AUTHENTICATION':
75
+ case 'DEVICE_REGISTRATION': {
76
+ // Intentional fall-through
77
+ return returnObjectSelectCollector(field, idx);
78
+ }
79
+ case 'PASSWORD':
80
+ case 'PASSWORD_VERIFY': {
81
+ // No data to send
82
+ return returnPasswordCollector(field, idx);
83
+ }
84
+ case 'PHONE_NUMBER': {
85
+ // No data to send
86
+ return returnObjectValueCollector(field, idx);
87
+ }
88
+ case 'TEXT': {
89
+ const str = data;
90
+ return returnTextCollector(field, idx, str);
91
+ }
92
+ case 'SOCIAL_LOGIN_BUTTON': {
93
+ // No data to send
94
+ return returnIdpCollector(field, idx);
95
+ }
96
+ case 'SUBMIT_BUTTON': {
97
+ // No data to send
98
+ return returnSubmitCollector(field, idx);
99
+ }
100
+ default:
101
+ // Default is handled below
102
+ }
103
+ // Generic Collectors
104
+ if (field.type.includes('BUTTON') || field.type.includes('LINK')) {
105
+ // No data to send
106
+ return returnActionCollector(field, idx, 'ActionCollector');
107
+ }
108
+ return returnUnknownCollector(field, idx);
109
+ })
110
+ : [];
111
+ return collectors || [];
112
+ })
113
+ /**
114
+ * Using the `updateCollectorValues` const (e.g. `'node/update'`) to add the case
115
+ * 'node/next' is essentially derived `createSlice` below. `node.next()` is
116
+ * transformed to `'node/next'` for the action type.
117
+ */
118
+ .addCase(updateCollectorValues, (state, action) => {
119
+ const collector = state.find((collector) => collector.id === action.payload.id);
120
+ if (!collector) {
121
+ throw new Error('No collector found to update');
122
+ }
123
+ if (collector.category === 'ActionCollector') {
124
+ throw new Error('ActionCollectors are read-only');
125
+ }
126
+ if (collector.category === 'NoValueCollector') {
127
+ throw new Error('NoValueCollectors, like ReadOnlyCollectors, are read-only');
128
+ }
129
+ if (action.payload.value === undefined) {
130
+ throw new Error('Value argument cannot be undefined');
131
+ }
132
+ if (collector.category === 'SingleValueCollector' ||
133
+ collector.category === 'ValidatedSingleValueCollector') {
134
+ if (typeof action.payload.value !== 'string') {
135
+ throw new Error('SingleValueCollector does not accept an array');
136
+ }
137
+ collector.input.value = action.payload.value;
138
+ return;
139
+ }
140
+ if (collector.category === 'MultiValueCollector') {
141
+ if (typeof action.payload.value !== 'string' && !Array.isArray(action.payload.value)) {
142
+ throw new Error('MultiValueCollector does not accept an object');
143
+ }
144
+ if (Array.isArray(action.payload.value)) {
145
+ collector.input.value = [...action.payload.value];
146
+ }
147
+ else {
148
+ collector.input.value.push(action.payload.value);
149
+ }
150
+ return;
151
+ }
152
+ if (collector.type === 'DeviceAuthenticationCollector') {
153
+ if (typeof action.payload.id !== 'string') {
154
+ throw new Error('Index argument must be a string');
155
+ }
156
+ // Iterate through the options object and find option to update
157
+ const option = collector.output.options.find((option) => option.value === action.payload.value);
158
+ if (!option) {
159
+ throw new Error('No option found matching value to update');
160
+ }
161
+ // Remap values back to DaVinci spec
162
+ collector.input.value = {
163
+ type: option.type,
164
+ id: option.value,
165
+ value: option.content,
166
+ };
167
+ }
168
+ if (collector.type === 'DeviceRegistrationCollector') {
169
+ if (typeof action.payload.id !== 'string') {
170
+ throw new Error('Index argument must be a string');
171
+ }
172
+ // Iterate through the options object and find option to update
173
+ const option = collector.output.options.find((option) => option.value === action.payload.value);
174
+ if (!option) {
175
+ throw new Error('No option found matching value to update');
176
+ }
177
+ collector.input.value = option.type;
178
+ }
179
+ if (collector.type === 'PhoneNumberCollector') {
180
+ if (typeof action.payload.id !== 'string') {
181
+ throw new Error('Index argument must be a string');
182
+ }
183
+ if (typeof action.payload.value !== 'object') {
184
+ throw new Error('Value argument must be an object');
185
+ }
186
+ if (!('phoneNumber' in action.payload.value) || !('countryCode' in action.payload.value)) {
187
+ throw new Error('Value argument must contain a phoneNumber and countryCode property');
188
+ }
189
+ collector.input.value = action.payload.value;
190
+ }
191
+ });
192
+ });
193
+ //# sourceMappingURL=node.reducer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"node.reducer.js","sourceRoot":"","sources":["../../../src/lib/node.reducer.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH;;GAEG;AACH,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAE/D;;GAEG;AACH,OAAO,EACL,qBAAqB,EACrB,mBAAmB,EACnB,uBAAuB,EACvB,kBAAkB,EAClB,qBAAqB,EACrB,mBAAmB,EACnB,2BAA2B,EAC3B,0BAA0B,EAC1B,uBAAuB,EACvB,2BAA2B,EAC3B,0BAA0B,EAC1B,sBAAsB,GACvB,MAAM,sBAAsB,CAAC;AAqB9B;;;;;GAKG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,YAAY,CAG5C,WAAW,CAAC,CAAC;AAChB,MAAM,CAAC,MAAM,qBAAqB,GAAG,YAAY,CAI9C,aAAa,CAAC,CAAC;AAElB;;GAEG;AACH,MAAM,sBAAsB,GAgBtB,EAAE,CAAC;AAET;;;GAGG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,aAAa,CAAC,sBAAsB,EAAE,CAAC,OAAO,EAAE,EAAE;IACpF,OAAO;QACL;;;;WAIG;SACF,OAAO,CAAC,mBAAmB,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,EAAE;QAC1C,MAAM,MAAM,GAAG,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC;QACrC,2EAA2E;QAC3E,MAAM,UAAU,GAAG,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC;YACtC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,KAAmB,EAAE,GAAW,EAAE,EAAE;gBAC9C;;;mBAGG;gBACH,IAAI,KAAK,CAAC,IAAI,KAAK,OAAO,EAAE,CAAC;oBAC3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AK,CAAC,0CAA0C,CAAC,CAAC;YAC9D,CAAC;YAED,SAAS,CAAC,KAAK,CAAC,KAAK,GAAG,MAAM,CAAC,IAAI,CAAC;QACtC,CAAC;QAED,IAAI,SAAS,CAAC,IAAI,KAAK,sBAAsB,EAAE,CAAC;YAC9C,IAAI,OAAO,MAAM,CAAC,OAAO,CAAC,EAAE,KAAK,QAAQ,EAAE,CAAC;gBAC1C,MAAM,IAAI,KAAK,CAAC,iCAAiC,CAAC,CAAC;YACrD,CAAC;YACD,IAAI,OAAO,MAAM,CAAC,OAAO,CAAC,KAAK,KAAK,QAAQ,EAAE,CAAC;gBAC7C,MAAM,IAAI,KAAK,CAAC,kCAAkC,CAAC,CAAC;YACtD,CAAC;YACD,IAAI,CAAC,CAAC,aAAa,IAAI,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,aAAa,IAAI,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;gBACzF,MAAM,IAAI,KAAK,CAAC,oEAAoE,CAAC,CAAC;YACxF,CAAC;YACD,SAAS,CAAC,KAAK,CAAC,KAAK,GAAG,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC;QAC/C,CAAC;IACH,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC"}
@@ -1,85 +1,95 @@
1
- import { updateCollectorValues } from './node.reducer';
2
- import { PayloadAction } from '@reduxjs/toolkit';
3
- import { SubmitCollector } from './collector.types';
4
- import { DavinciErrorResponse, DaVinciFailureResponse, DaVinciNextResponse, DaVinciSuccessResponse } from './davinci.types';
5
- import { ContinueNode, SuccessNode, ErrorNode, StartNode, FailureNode } from './node.types';
1
+ /**
2
+ * Import the needed reducers
3
+ */
4
+ import { updateCollectorValues } from './node.reducer.js';
5
+ /**
6
+ * Import the types
7
+ */
8
+ import type { PayloadAction } from '@reduxjs/toolkit';
9
+ import type { GenericError } from './error.types.js';
10
+ import type { DavinciErrorResponse, DaVinciFailureResponse, DaVinciNextResponse, DaVinciSuccessResponse } from './davinci.types.js';
11
+ import type { ContinueNode, SuccessNode, ErrorNode, StartNode, FailureNode } from './node.types.js';
6
12
  /**
7
13
  * @const initialNodeState - Initial state for the node slice
8
14
  */
9
15
  export declare const initialNodeState: {
10
16
  cache: null;
11
17
  client: {
12
- status: string;
18
+ status: "start";
13
19
  };
14
20
  error: null;
15
21
  server: {
16
- status: string;
22
+ status: "start";
17
23
  };
18
- status: string;
24
+ status: "start";
19
25
  };
20
26
  /**
21
27
  * @const nodeSlice - Slice for handling the node state
22
28
  * @see https://redux-toolkit.js.org/api/createSlice
23
29
  */
24
- export declare const nodeSlice: import('@reduxjs/toolkit').Slice<ContinueNode | ErrorNode | FailureNode | StartNode | SuccessNode, {
30
+ export declare const nodeSlice: import("@reduxjs/toolkit").Slice<ContinueNode | ErrorNode | FailureNode | StartNode | SuccessNode, {
25
31
  /**
26
32
  * @method error - Method for creating an error node
27
33
  * @param {Object} state - The current state of the slice
28
34
  * @param {PayloadAction<DaVinciErrorCacheEntry<DavinciErrorResponse>>} action - The action to be dispatched
29
35
  * @returns {ErrorNode} - The error node
30
36
  */
31
- error(state: import('immer').WritableDraft<ContinueNode> | import('immer').WritableDraft<ErrorNode> | import('immer').WritableDraft<FailureNode> | import('immer').WritableDraft<StartNode> | import('immer').WritableDraft<SuccessNode>, action: PayloadAction<{
37
+ error(state: import("immer").WritableDraft<ContinueNode> | import("immer").WritableDraft<ErrorNode> | import("immer").WritableDraft<FailureNode> | import("immer").WritableDraft<StartNode> | import("immer").WritableDraft<SuccessNode>, action: PayloadAction<{
32
38
  data: DavinciErrorResponse;
33
39
  requestId: string;
34
40
  httpStatus: number;
35
- }>): import('immer').WritableDraft<ErrorNode>;
41
+ }>): import("immer").WritableDraft<ErrorNode>;
36
42
  /**
37
43
  * @method failure - Method for creating an error node
38
44
  * @param {Object} state - The current state of the slice
39
45
  * @param {PayloadAction<DaVinciFailureResponse>} action - The action to be dispatched
40
46
  * @returns {FailureNode} - The error node
41
47
  */
42
- failure(state: import('immer').WritableDraft<ContinueNode> | import('immer').WritableDraft<ErrorNode> | import('immer').WritableDraft<FailureNode> | import('immer').WritableDraft<StartNode> | import('immer').WritableDraft<SuccessNode>, action: PayloadAction<{
48
+ failure(state: import("immer").WritableDraft<ContinueNode> | import("immer").WritableDraft<ErrorNode> | import("immer").WritableDraft<FailureNode> | import("immer").WritableDraft<StartNode> | import("immer").WritableDraft<SuccessNode>, action: PayloadAction<{
43
49
  data: DaVinciFailureResponse | unknown;
44
50
  requestId: string;
45
51
  httpStatus: number;
46
- }>): import('immer').WritableDraft<FailureNode>;
52
+ }>): import("immer").WritableDraft<FailureNode>;
47
53
  /**
48
54
  * @method next - Method for creating a next node
49
55
  * @param {Object} state - The current state of the slice
50
56
  * @param {PayloadAction<DaVinciNextResponse>} action - The action to be dispatched
51
57
  * @returns {ContinueNode} - The next node
52
58
  */
53
- next(state: import('immer').WritableDraft<ContinueNode> | import('immer').WritableDraft<ErrorNode> | import('immer').WritableDraft<FailureNode> | import('immer').WritableDraft<StartNode> | import('immer').WritableDraft<SuccessNode>, action: PayloadAction<{
59
+ next(state: import("immer").WritableDraft<ContinueNode> | import("immer").WritableDraft<ErrorNode> | import("immer").WritableDraft<FailureNode> | import("immer").WritableDraft<StartNode> | import("immer").WritableDraft<SuccessNode>, action: PayloadAction<{
54
60
  data: DaVinciNextResponse;
55
61
  requestId: string;
56
62
  httpStatus: number;
57
- }>): import('immer').WritableDraft<ContinueNode>;
63
+ }>): import("immer").WritableDraft<ContinueNode>;
58
64
  /**
59
65
  * @method start - Method for creating a start node
60
66
  * @param {Object} state - The current state of the slice
61
67
  * @returns {StartNode} - The start node
62
68
  */
63
- success(state: import('immer').WritableDraft<ContinueNode> | import('immer').WritableDraft<ErrorNode> | import('immer').WritableDraft<FailureNode> | import('immer').WritableDraft<StartNode> | import('immer').WritableDraft<SuccessNode>, action: PayloadAction<{
69
+ success(state: import("immer").WritableDraft<ContinueNode> | import("immer").WritableDraft<ErrorNode> | import("immer").WritableDraft<FailureNode> | import("immer").WritableDraft<StartNode> | import("immer").WritableDraft<SuccessNode>, action: PayloadAction<{
64
70
  data: DaVinciSuccessResponse;
65
71
  requestId: string;
66
72
  httpStatus: number;
67
- }>): import('immer').WritableDraft<SuccessNode>;
73
+ }>): import("immer").WritableDraft<SuccessNode>;
68
74
  /**
69
75
  * @method update - Method for updating collector values with the node
70
76
  * @param {Object} state - The current state of the slice
71
77
  * @param {PayloadAction<unknown>} action - The action to be dispatched
72
78
  * @returns {ContinueNode} - The next node
73
79
  */
74
- update(state: import('immer').WritableDraft<ContinueNode> | import('immer').WritableDraft<ErrorNode> | import('immer').WritableDraft<FailureNode> | import('immer').WritableDraft<StartNode> | import('immer').WritableDraft<SuccessNode>, action: ReturnType<typeof updateCollectorValues>): import('immer').WritableDraft<ContinueNode>;
80
+ update(state: import("immer").WritableDraft<ContinueNode> | import("immer").WritableDraft<ErrorNode> | import("immer").WritableDraft<FailureNode> | import("immer").WritableDraft<StartNode> | import("immer").WritableDraft<SuccessNode>, action: ReturnType<typeof updateCollectorValues>): import("immer").WritableDraft<ContinueNode>;
75
81
  }, "node", "node", {
76
82
  selectClient: (state: ContinueNode | ErrorNode | FailureNode | StartNode | SuccessNode) => {
77
83
  action: string;
78
- collectors: import('./node.types').Collectors[];
84
+ collectors: import("./node.types.js").Collectors[];
79
85
  description?: string;
80
86
  name?: string;
81
87
  status: "continue";
82
88
  } | {
89
+ action: string;
90
+ collectors: import("./node.types.js").Collectors[];
91
+ description?: string;
92
+ name?: string;
83
93
  status: "error";
84
94
  } | {
85
95
  status: "failure";
@@ -92,11 +102,30 @@ export declare const nodeSlice: import('@reduxjs/toolkit').Slice<ContinueNode |
92
102
  };
93
103
  status: "success";
94
104
  } | null;
95
- selectCollectors: (state: ContinueNode | ErrorNode | FailureNode | StartNode | SuccessNode) => import('./node.types').Collectors[];
96
- selectCollector: (state: ContinueNode | ErrorNode | FailureNode | StartNode | SuccessNode, id: string) => import('./collector.types').ActionCollectorNoUrl<"ActionCollector"> | import('./collector.types').FlowCollector | import('./collector.types').PasswordCollector | import('./collector.types').TextCollector | import('./collector.types').SocialLoginCollector | SubmitCollector | import('./collector.types').SingleValueCollectorNoValue<"SingleValueCollector"> | undefined;
97
- selectError: (state: ContinueNode | ErrorNode | FailureNode | StartNode | SuccessNode) => import('./node.types').DaVinciError | null;
105
+ selectCollectors: (state: ContinueNode | ErrorNode | FailureNode | StartNode | SuccessNode) => {
106
+ error: null;
107
+ state: import("./node.types.js").Collectors[];
108
+ } | {
109
+ error: GenericError;
110
+ state: never[];
111
+ };
112
+ selectCollector: (state: ContinueNode | ErrorNode | FailureNode | StartNode | SuccessNode, id: string) => {
113
+ error: null;
114
+ state: import("./node.types.js").Collectors | undefined;
115
+ } | {
116
+ error: GenericError;
117
+ state: null;
118
+ };
119
+ selectError: (state: ContinueNode | ErrorNode | FailureNode | StartNode | SuccessNode) => import("./node.types.js").DaVinciError | null;
120
+ selectErrorCollectors: (state: ContinueNode | ErrorNode | FailureNode | StartNode | SuccessNode) => {
121
+ error: null;
122
+ state: import("./node.types.js").CollectorErrors[];
123
+ } | {
124
+ error: GenericError;
125
+ state: never[];
126
+ };
98
127
  selectServer: (state: ContinueNode | ErrorNode | FailureNode | StartNode | SuccessNode) => {
99
- _links?: import('./davinci.types').Links;
128
+ _links?: import("./davinci.types.js").Links;
100
129
  id?: string;
101
130
  interactionId?: string;
102
131
  interactionToken?: string;
@@ -104,14 +133,14 @@ export declare const nodeSlice: import('@reduxjs/toolkit').Slice<ContinueNode |
104
133
  eventName?: string;
105
134
  status: "continue";
106
135
  } | {
107
- _links?: import('./davinci.types').Links;
136
+ _links?: import("./davinci.types.js").Links;
108
137
  eventName?: string;
109
138
  id?: string;
110
139
  interactionId?: string;
111
140
  interactionToken?: string;
112
141
  status: "error";
113
142
  } | {
114
- _links?: import('./davinci.types').Links;
143
+ _links?: import("./davinci.types.js").Links;
115
144
  eventName?: string;
116
145
  href?: string;
117
146
  id?: string;
@@ -121,7 +150,7 @@ export declare const nodeSlice: import('@reduxjs/toolkit').Slice<ContinueNode |
121
150
  } | {
122
151
  status: "start";
123
152
  } | {
124
- _links?: import('./davinci.types').Links;
153
+ _links?: import("./davinci.types.js").Links;
125
154
  eventName?: string;
126
155
  id?: string;
127
156
  interactionId?: string;
@@ -0,0 +1 @@
1
+ {"version":3,"file":"node.slice.d.ts","sourceRoot":"","sources":["../../../src/lib/node.slice.ts"],"names":[],"mappings":"AAWA;;GAEG;AACH,OAAO,EAAwB,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAGhF;;GAEG;AACH,OAAO,KAAK,EAAS,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAE7D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,KAAK,EACV,oBAAoB,EACpB,sBAAsB,EACtB,mBAAmB,EACnB,sBAAsB,EACvB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,KAAK,EAAE,YAAY,EAAE,WAAW,EAAE,SAAS,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAWpG;;GAEG;AACH,eAAO,MAAM,gBAAgB;;;;;;;;;;CAUR,CAAC;AAItB;;;GAGG;AACH,eAAO,MAAM,SAAS;IAIlB;;;;;OAKG;sPAGO,aAAa,CAAC;QAAE,IAAI,EAAE,oBAAoB,CAAC;QAAC,SAAS,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,MAAM,CAAA;KAAE,CAAC;IAsC9F;;;;;OAKG;wPAGO,aAAa,CAAC;QACpB,IAAI,EAAE,sBAAsB,GAAG,OAAO,CAAC;QACvC,SAAS,EAAE,MAAM,CAAC;QAClB,UAAU,EAAE,MAAM,CAAC;KACpB,CAAC;IA2CJ;;;;;OAKG;qPAGO,aAAa,CAAC;QACpB,IAAI,EAAE,mBAAmB,CAAC;QAC1B,SAAS,EAAE,MAAM,CAAC;QAClB,UAAU,EAAE,MAAM,CAAC;KACpB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