@incodetech/core 2.0.0-alpha.2 → 2.0.0-alpha.4

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 (154) hide show
  1. package/dist/OpenViduLogger-BdPfiZO6.esm.js +3 -0
  2. package/dist/OpenViduLogger-CQyDxBvM.esm.js +803 -0
  3. package/dist/{addEvent-1Mi5CEiq.esm.js → addEvent-9v4w5iO-.esm.js} +1 -1
  4. package/dist/email.d.ts +1 -1
  5. package/dist/email.esm.js +2 -2
  6. package/dist/{endpoints-D_pUMaqA.esm.js → endpoints-Dn1t57hJ.esm.js} +8 -3
  7. package/dist/flow.d.ts +3 -3
  8. package/dist/flow.esm.js +1 -1
  9. package/dist/index.d.ts +2 -2
  10. package/dist/index.esm.js +2 -2
  11. package/dist/{lib-CyIAFRfr.esm.js → lib-Bu9XGMBW.esm.js} +1 -800
  12. package/dist/{permissionServices-CVR0Pq38.esm.js → permissionServices-CCpxd8le.esm.js} +1 -1
  13. package/dist/phone.d.ts +1 -1
  14. package/dist/phone.esm.js +2 -2
  15. package/dist/selfie.d.ts +5 -4
  16. package/dist/selfie.esm.js +27 -10
  17. package/package.json +4 -1
  18. package/.turbo/turbo-build.log +0 -33
  19. package/.turbo/turbo-coverage.log +0 -22
  20. package/.turbo/turbo-format.log +0 -6
  21. package/.turbo/turbo-lint$colon$fix.log +0 -77
  22. package/.turbo/turbo-lint.log +0 -95
  23. package/.turbo/turbo-test.log +0 -870
  24. package/.turbo/turbo-typecheck.log +0 -5
  25. package/coverage/base.css +0 -224
  26. package/coverage/block-navigation.js +0 -87
  27. package/coverage/favicon.png +0 -0
  28. package/coverage/index.html +0 -221
  29. package/coverage/prettify.css +0 -1
  30. package/coverage/prettify.js +0 -2
  31. package/coverage/sort-arrow-sprite.png +0 -0
  32. package/coverage/sorter.js +0 -210
  33. package/coverage/src/camera/cameraService.ts.html +0 -580
  34. package/coverage/src/camera/cameraServices.ts.html +0 -163
  35. package/coverage/src/camera/cameraStateMachine.ts.html +0 -877
  36. package/coverage/src/camera/index.html +0 -146
  37. package/coverage/src/email/emailActor.ts.html +0 -130
  38. package/coverage/src/email/emailManager.ts.html +0 -1366
  39. package/coverage/src/email/emailStateMachine.ts.html +0 -1186
  40. package/coverage/src/email/index.html +0 -146
  41. package/coverage/src/flow/flowActor.ts.html +0 -124
  42. package/coverage/src/flow/flowAnalyzer.ts.html +0 -196
  43. package/coverage/src/flow/flowManager.ts.html +0 -790
  44. package/coverage/src/flow/flowServices.ts.html +0 -124
  45. package/coverage/src/flow/flowStateMachine.ts.html +0 -631
  46. package/coverage/src/flow/index.html +0 -221
  47. package/coverage/src/flow/moduleLoader.ts.html +0 -304
  48. package/coverage/src/flow/orchestratedFlowManager.ts.html +0 -778
  49. package/coverage/src/flow/orchestratedFlowStateMachine.ts.html +0 -1060
  50. package/coverage/src/http/api.ts.html +0 -355
  51. package/coverage/src/http/endpoints.ts.html +0 -136
  52. package/coverage/src/http/index.html +0 -131
  53. package/coverage/src/index.html +0 -116
  54. package/coverage/src/phone/index.html +0 -146
  55. package/coverage/src/phone/phoneActor.ts.html +0 -130
  56. package/coverage/src/phone/phoneManager.ts.html +0 -1459
  57. package/coverage/src/phone/phoneStateMachine.ts.html +0 -1351
  58. package/coverage/src/recordings/index.html +0 -116
  59. package/coverage/src/recordings/recordingsRepository.ts.html +0 -229
  60. package/coverage/src/selfie/index.html +0 -191
  61. package/coverage/src/selfie/selfieActor.ts.html +0 -136
  62. package/coverage/src/selfie/selfieErrorUtils.ts.html +0 -283
  63. package/coverage/src/selfie/selfieManager.ts.html +0 -988
  64. package/coverage/src/selfie/selfieStateMachine.ts.html +0 -2497
  65. package/coverage/src/selfie/selfieUploadService.ts.html +0 -328
  66. package/coverage/src/selfie/types.ts.html +0 -394
  67. package/coverage/src/setup.ts.html +0 -598
  68. package/src/camera/cameraActor.ts +0 -21
  69. package/src/camera/cameraService.test.ts +0 -437
  70. package/src/camera/cameraService.ts +0 -165
  71. package/src/camera/cameraServices.test.ts +0 -66
  72. package/src/camera/cameraServices.ts +0 -26
  73. package/src/camera/cameraStateMachine.test.ts +0 -602
  74. package/src/camera/cameraStateMachine.ts +0 -264
  75. package/src/camera/index.ts +0 -5
  76. package/src/camera/types.ts +0 -17
  77. package/src/device/getBrowser.ts +0 -31
  78. package/src/device/getDeviceClass.ts +0 -29
  79. package/src/device/index.ts +0 -2
  80. package/src/email/__mocks__/emailMocks.ts +0 -59
  81. package/src/email/emailActor.ts +0 -15
  82. package/src/email/emailManager.test.ts +0 -573
  83. package/src/email/emailManager.ts +0 -427
  84. package/src/email/emailServices.ts +0 -66
  85. package/src/email/emailStateMachine.test.ts +0 -741
  86. package/src/email/emailStateMachine.ts +0 -367
  87. package/src/email/index.ts +0 -39
  88. package/src/email/types.ts +0 -60
  89. package/src/events/addEvent.ts +0 -20
  90. package/src/events/types.ts +0 -7
  91. package/src/flow/__mocks__/flowMocks.ts +0 -84
  92. package/src/flow/flowActor.ts +0 -13
  93. package/src/flow/flowAnalyzer.test.ts +0 -266
  94. package/src/flow/flowAnalyzer.ts +0 -37
  95. package/src/flow/flowCompletionService.ts +0 -21
  96. package/src/flow/flowManager.test.ts +0 -560
  97. package/src/flow/flowManager.ts +0 -235
  98. package/src/flow/flowServices.test.ts +0 -109
  99. package/src/flow/flowServices.ts +0 -13
  100. package/src/flow/flowStateMachine.test.ts +0 -334
  101. package/src/flow/flowStateMachine.ts +0 -182
  102. package/src/flow/index.ts +0 -21
  103. package/src/flow/moduleLoader.test.ts +0 -136
  104. package/src/flow/moduleLoader.ts +0 -73
  105. package/src/flow/orchestratedFlowManager.test.ts +0 -240
  106. package/src/flow/orchestratedFlowManager.ts +0 -231
  107. package/src/flow/orchestratedFlowStateMachine.test.ts +0 -199
  108. package/src/flow/orchestratedFlowStateMachine.ts +0 -325
  109. package/src/flow/types.ts +0 -434
  110. package/src/http/__mocks__/api.ts +0 -88
  111. package/src/http/api.test.ts +0 -231
  112. package/src/http/api.ts +0 -90
  113. package/src/http/endpoints.ts +0 -17
  114. package/src/index.ts +0 -33
  115. package/src/permissions/index.ts +0 -2
  116. package/src/permissions/permissionServices.ts +0 -31
  117. package/src/permissions/types.ts +0 -3
  118. package/src/phone/__mocks__/phoneMocks.ts +0 -71
  119. package/src/phone/index.ts +0 -39
  120. package/src/phone/phoneActor.ts +0 -15
  121. package/src/phone/phoneManager.test.ts +0 -393
  122. package/src/phone/phoneManager.ts +0 -458
  123. package/src/phone/phoneServices.ts +0 -98
  124. package/src/phone/phoneStateMachine.test.ts +0 -918
  125. package/src/phone/phoneStateMachine.ts +0 -422
  126. package/src/phone/types.ts +0 -83
  127. package/src/recordings/recordingsRepository.test.ts +0 -87
  128. package/src/recordings/recordingsRepository.ts +0 -48
  129. package/src/recordings/streamingEvents.ts +0 -10
  130. package/src/selfie/__mocks__/selfieMocks.ts +0 -26
  131. package/src/selfie/index.ts +0 -14
  132. package/src/selfie/selfieActor.ts +0 -17
  133. package/src/selfie/selfieErrorUtils.test.ts +0 -116
  134. package/src/selfie/selfieErrorUtils.ts +0 -66
  135. package/src/selfie/selfieManager.test.ts +0 -297
  136. package/src/selfie/selfieManager.ts +0 -301
  137. package/src/selfie/selfieServices.ts +0 -362
  138. package/src/selfie/selfieStateMachine.test.ts +0 -283
  139. package/src/selfie/selfieStateMachine.ts +0 -804
  140. package/src/selfie/selfieUploadService.test.ts +0 -90
  141. package/src/selfie/selfieUploadService.ts +0 -81
  142. package/src/selfie/types.ts +0 -103
  143. package/src/session/index.ts +0 -5
  144. package/src/session/sessionService.ts +0 -78
  145. package/src/setup.test.ts +0 -61
  146. package/src/setup.ts +0 -171
  147. package/tsconfig.json +0 -13
  148. package/tsdown.config.ts +0 -22
  149. package/vitest.config.ts +0 -37
  150. package/vitest.setup.ts +0 -135
  151. /package/dist/{Manager-6BwbaI_H.d.ts → Manager-BGfxEmyv.d.ts} +0 -0
  152. /package/dist/{StateMachine-7c1gcu94.d.ts → StateMachine-DRE1oH2B.d.ts} +0 -0
  153. /package/dist/{types-tq1ypYSL.d.ts → types-kWlqshfM.d.ts} +0 -0
  154. /package/dist/{warmup-Dr7OcFND.d.ts → warmup-CEJTfxQr.d.ts} +0 -0
@@ -1,367 +0,0 @@
1
- import { assign, fromCallback, fromPromise, setup } from '@incodetech/infra';
2
- import { addEvent } from '../events/addEvent';
3
- import {
4
- addEmail,
5
- fetchEmail,
6
- sendEmailOtp,
7
- verifyEmailOtp,
8
- } from './emailServices';
9
- import type { EmailConfig } from './types';
10
-
11
- export type EmailContext = {
12
- config: EmailConfig;
13
- email: string;
14
- isValid: boolean;
15
- emailError: string | undefined;
16
- prefilledEmail: string | undefined;
17
- error: string | undefined;
18
- otpCode: string;
19
- otpError: string | undefined;
20
- attemptsRemaining: number;
21
- resendTimer: number;
22
- resendTimerActive: boolean;
23
- };
24
-
25
- export type EmailEvent =
26
- | { type: 'LOAD' }
27
- | { type: 'EMAIL_CHANGED'; email: string; isValid: boolean }
28
- | { type: 'SUBMIT' }
29
- | { type: 'OTP_CHANGED'; code: string }
30
- | { type: 'VERIFY_OTP' }
31
- | { type: 'RESEND_OTP' }
32
- | { type: 'BACK' }
33
- | { type: 'RESET' }
34
- | { type: 'TICK' };
35
-
36
- export type EmailInput = {
37
- config: EmailConfig;
38
- };
39
-
40
- const RESEND_TIMER_SECONDS = 30;
41
-
42
- export const emailMachine = setup({
43
- types: {
44
- context: {} as EmailContext,
45
- events: {} as EmailEvent,
46
- input: {} as EmailInput,
47
- },
48
- actors: {
49
- fetchEmail: fromPromise<{ email: string }, void>(async ({ signal }) => {
50
- return fetchEmail(signal);
51
- }),
52
- submitEmail: fromPromise<{ success: boolean }, { email: string }>(
53
- async ({ input, signal }) => {
54
- return addEmail({ email: input.email }, signal);
55
- },
56
- ),
57
- sendOtp: fromPromise<void, void>(async ({ signal }) => {
58
- return sendEmailOtp(signal);
59
- }),
60
- verifyOtp: fromPromise<{ success: boolean }, { code: string }>(
61
- async ({ input, signal }) => {
62
- return verifyEmailOtp(input.code, signal);
63
- },
64
- ),
65
- resendTimer: fromCallback(({ sendBack }) => {
66
- let seconds = RESEND_TIMER_SECONDS;
67
- const interval = setInterval(() => {
68
- seconds -= 1;
69
- sendBack({ type: 'TICK' });
70
- if (seconds <= 0) {
71
- clearInterval(interval);
72
- }
73
- }, 1000);
74
- return () => clearInterval(interval);
75
- }),
76
- },
77
- actions: {
78
- setPrefilledEmail: assign(({ event }) => {
79
- const email = (event as unknown as { output: { email: string } }).output
80
- .email;
81
- return {
82
- prefilledEmail: email,
83
- email,
84
- };
85
- }),
86
- setEmail: assign(({ event }) => {
87
- const e = event as {
88
- type: 'EMAIL_CHANGED';
89
- email: string;
90
- isValid: boolean;
91
- };
92
- return {
93
- email: e.email,
94
- isValid: e.isValid,
95
- emailError: e.isValid ? undefined : 'Invalid email address',
96
- };
97
- }),
98
- setEmailError: assign(({ event }) => ({
99
- emailError: String((event as unknown as { error: unknown }).error),
100
- })),
101
- setError: assign(({ event }) => ({
102
- error: String((event as unknown as { error: unknown }).error),
103
- })),
104
- clearError: assign({
105
- error: () => undefined,
106
- }),
107
- clearEmailError: assign({
108
- emailError: () => undefined,
109
- }),
110
- setOtpCode: assign(({ event }) => ({
111
- otpCode: (event as { type: 'OTP_CHANGED'; code: string }).code,
112
- otpError: undefined,
113
- })),
114
- setOtpError: assign(({ context, event }) => ({
115
- otpError: String((event as unknown as { error: unknown }).error),
116
- attemptsRemaining: context.attemptsRemaining - 1,
117
- })),
118
- clearOtpError: assign({
119
- otpError: () => undefined,
120
- otpCode: () => '',
121
- }),
122
- startResendTimer: assign({
123
- resendTimer: () => RESEND_TIMER_SECONDS,
124
- resendTimerActive: () => true,
125
- }),
126
- tickResendTimer: assign(({ context }) => {
127
- const newTimer = Math.max(0, context.resendTimer - 1);
128
- return {
129
- resendTimer: newTimer,
130
- resendTimerActive: newTimer > 0,
131
- };
132
- }),
133
- stopResendTimer: assign({
134
- resendTimerActive: () => false,
135
- }),
136
- resetContext: assign(({ context }) => ({
137
- config: context.config,
138
- email: '',
139
- isValid: false,
140
- emailError: undefined,
141
- prefilledEmail: undefined,
142
- error: undefined,
143
- otpCode: '',
144
- otpError: undefined,
145
- attemptsRemaining: context.config.maxOtpAttempts ?? 3,
146
- resendTimer: 0,
147
- resendTimerActive: false,
148
- })),
149
- sendEmailSubmitEvent: () => {
150
- addEvent({
151
- code: 'continue',
152
- module: 'email',
153
- screen: 'emailInput',
154
- });
155
- },
156
- },
157
- guards: {
158
- hasPrefill: ({ context }): boolean => context.config.prefill,
159
- hasOtpVerification: ({ context }): boolean =>
160
- context.config.otpVerification,
161
- isValidEmail: ({ context }): boolean => context.isValid,
162
- hasAttemptsRemaining: ({ context }): boolean =>
163
- context.attemptsRemaining > 0,
164
- canResend: ({ context }): boolean => !context.resendTimerActive,
165
- },
166
- }).createMachine({
167
- id: 'email',
168
- initial: 'idle',
169
- context: ({ input }) => ({
170
- config: input.config,
171
- email: '',
172
- isValid: false,
173
- emailError: undefined,
174
- prefilledEmail: undefined,
175
- error: undefined,
176
- otpCode: '',
177
- otpError: undefined,
178
- attemptsRemaining: input.config.maxOtpAttempts ?? 3,
179
- resendTimer: 0,
180
- resendTimerActive: false,
181
- }),
182
- states: {
183
- idle: {
184
- on: {
185
- LOAD: [
186
- {
187
- target: 'loadingPrefill',
188
- guard: 'hasPrefill',
189
- },
190
- {
191
- target: 'inputting',
192
- },
193
- ],
194
- },
195
- },
196
-
197
- loadingPrefill: {
198
- invoke: {
199
- id: 'fetchEmail',
200
- src: 'fetchEmail',
201
- onDone: {
202
- target: 'inputting',
203
- actions: 'setPrefilledEmail',
204
- },
205
- onError: {
206
- target: 'inputting',
207
- },
208
- },
209
- },
210
-
211
- inputting: {
212
- entry: 'clearEmailError',
213
- on: {
214
- EMAIL_CHANGED: {
215
- actions: 'setEmail',
216
- },
217
- SUBMIT: {
218
- target: 'submitting',
219
- guard: 'isValidEmail',
220
- },
221
- },
222
- },
223
-
224
- submitting: {
225
- invoke: {
226
- id: 'submitEmail',
227
- src: 'submitEmail',
228
- input: ({ context }) => ({
229
- email: context.email,
230
- }),
231
- onDone: [
232
- {
233
- target: 'sendingOtp',
234
- guard: 'hasOtpVerification',
235
- actions: 'sendEmailSubmitEvent',
236
- },
237
- {
238
- target: 'success',
239
- actions: 'sendEmailSubmitEvent',
240
- },
241
- ],
242
- onError: {
243
- target: 'inputting',
244
- actions: 'setEmailError',
245
- },
246
- },
247
- },
248
-
249
- sendingOtp: {
250
- invoke: {
251
- id: 'sendOtp',
252
- src: 'sendOtp',
253
- onDone: {
254
- target: 'awaitingOtp',
255
- },
256
- onError: {
257
- target: 'awaitingOtp',
258
- actions: 'setError',
259
- },
260
- },
261
- },
262
-
263
- awaitingOtp: {
264
- entry: 'startResendTimer',
265
- invoke: {
266
- id: 'resendTimer',
267
- src: 'resendTimer',
268
- },
269
- on: {
270
- TICK: {
271
- actions: 'tickResendTimer',
272
- },
273
- OTP_CHANGED: {
274
- actions: 'setOtpCode',
275
- },
276
- VERIFY_OTP: {
277
- target: 'verifyingOtp',
278
- },
279
- RESEND_OTP: {
280
- target: 'sendingOtp',
281
- guard: 'canResend',
282
- },
283
- BACK: {
284
- target: 'inputting',
285
- },
286
- },
287
- },
288
-
289
- verifyingOtp: {
290
- invoke: {
291
- id: 'verifyOtp',
292
- src: 'verifyOtp',
293
- input: ({ context }) => ({
294
- code: context.otpCode,
295
- }),
296
- onDone: [
297
- {
298
- target: 'success',
299
- guard: ({ event }) => event.output.success === true,
300
- },
301
- {
302
- target: 'otpError',
303
- guard: 'hasAttemptsRemaining',
304
- actions: assign(({ context }) => ({
305
- otpError: 'Invalid OTP code',
306
- attemptsRemaining: context.attemptsRemaining - 1,
307
- })),
308
- },
309
- {
310
- target: 'error',
311
- actions: assign({
312
- error: () => 'Maximum OTP attempts exceeded',
313
- }),
314
- },
315
- ],
316
- onError: [
317
- {
318
- target: 'otpError',
319
- guard: 'hasAttemptsRemaining',
320
- actions: 'setOtpError',
321
- },
322
- {
323
- target: 'error',
324
- actions: 'setError',
325
- },
326
- ],
327
- },
328
- },
329
-
330
- otpError: {
331
- on: {
332
- OTP_CHANGED: {
333
- target: 'awaitingOtp',
334
- actions: 'setOtpCode',
335
- },
336
- RESEND_OTP: {
337
- target: 'sendingOtp',
338
- guard: 'canResend',
339
- },
340
- BACK: {
341
- target: 'inputting',
342
- },
343
- },
344
- },
345
-
346
- success: {
347
- on: {
348
- RESET: {
349
- target: 'idle',
350
- actions: 'resetContext',
351
- },
352
- },
353
- },
354
-
355
- error: {
356
- on: {
357
- RESET: {
358
- target: 'idle',
359
- actions: 'resetContext',
360
- },
361
- },
362
- },
363
- },
364
- // biome-ignore lint/suspicious/noExplicitAny: XState type inference issue with guards in declaration files
365
- }) as any;
366
-
367
- export type EmailMachine = typeof emailMachine;
@@ -1,39 +0,0 @@
1
- /**
2
- * Email verification module - supports headless and UI-driven usage.
3
- *
4
- * ## Headless Usage (Programmatic)
5
- *
6
- * Use `createEmailManager` to control email verification without any UI.
7
- * Perfect for custom UI implementations, backend integrations, or automated testing.
8
- *
9
- * ```typescript
10
- * import { createEmailManager } from '@incodetech/core/email';
11
- *
12
- * const manager = createEmailManager({
13
- * config: { otpVerification: true, otpExpirationInMinutes: 5, prefill: false },
14
- * });
15
- *
16
- * manager.subscribe((state) => console.log(state.status));
17
- * manager.load();
18
- * manager.setEmail('user@example.com', true);
19
- * manager.submit();
20
- * manager.submitOtp('ABC123');
21
- * manager.stop();
22
- * ```
23
- *
24
- * ## UI Usage
25
- *
26
- * For a ready-to-use UI, import the Email component from `@incodetech/ui/email`.
27
- *
28
- * @module @incodetech/core/email
29
- * @see {@link createEmailManager} for headless API documentation
30
- * @see {@link EmailConfig} for configuration options
31
- * @see {@link EmailState} for state machine states
32
- */
33
- export {
34
- createEmailManager,
35
- type EmailManager,
36
- type EmailState,
37
- } from './emailManager';
38
- export { emailMachine } from './emailStateMachine';
39
- export type { EmailConfig } from './types';
@@ -1,60 +0,0 @@
1
- /**
2
- * Configuration options for email verification.
3
- *
4
- * @example Standard OTP verification
5
- * ```typescript
6
- * const config: EmailConfig = {
7
- * otpVerification: true,
8
- * otpExpirationInMinutes: 5,
9
- * prefill: false,
10
- * };
11
- * ```
12
- *
13
- * @example With all options
14
- * ```typescript
15
- * const config: EmailConfig = {
16
- * otpVerification: true,
17
- * otpExpirationInMinutes: 10,
18
- * prefill: true,
19
- * maxOtpAttempts: 3,
20
- * };
21
- * ```
22
- */
23
- export type EmailConfig = {
24
- /**
25
- * Whether to require OTP (email code) verification.
26
- * If false, email is verified immediately after submission.
27
- */
28
- otpVerification: boolean;
29
-
30
- /**
31
- * How long the OTP code remains valid, in minutes.
32
- * After expiration, user must request a new code.
33
- */
34
- otpExpirationInMinutes: number;
35
-
36
- /**
37
- * Whether to pre-populate with user's previously stored email address.
38
- * Useful for returning users.
39
- */
40
- prefill: boolean;
41
-
42
- /**
43
- * Maximum number of OTP verification attempts before lockout.
44
- * After exhausting attempts, user sees an error state.
45
- * @default 3
46
- */
47
- maxOtpAttempts?: number;
48
- };
49
-
50
- export type AddEmailResponse = {
51
- success: boolean;
52
- };
53
-
54
- export type VerifyOtpResponse = {
55
- success: boolean;
56
- };
57
-
58
- export type AddEmailParams = {
59
- email: string;
60
- };
@@ -1,20 +0,0 @@
1
- import { api } from '../http/api';
2
- import { endpoints } from '../http/endpoints';
3
- import type { Event } from './types';
4
-
5
- export function addEvent(event: Event): Promise<void> {
6
- const { code, module, screen, clientTimestamp, payload = {} } = event;
7
-
8
- return api
9
- .post(endpoints.events, [
10
- {
11
- code,
12
- module,
13
- screen,
14
- clientTimestamp: clientTimestamp ?? Date.now(),
15
- payload,
16
- },
17
- ])
18
- .then(() => undefined)
19
- .catch(() => undefined);
20
- }
@@ -1,7 +0,0 @@
1
- export type Event = {
2
- code: string;
3
- module?: string;
4
- screen?: string;
5
- payload?: Record<string, unknown>;
6
- clientTimestamp?: number;
7
- };
@@ -1,84 +0,0 @@
1
- import { vi } from 'vitest';
2
- import type { Flow, FlowModule } from '../types';
3
-
4
- export const mockTutorialIdModule: FlowModule = {
5
- key: 'TUTORIAL_ID',
6
- configuration: {
7
- showTutorial: true,
8
- enableId: true,
9
- enablePassport: false,
10
- onlyFront: false,
11
- onlyBack: false,
12
- barcodeCapture: false,
13
- fetchAdditionalPage: false,
14
- secondId: false,
15
- thirdId: false,
16
- autoCaptureTimeout: 30,
17
- deviceIdleTimeout: 60,
18
- captureAttempts: 3,
19
- manualUploadIdCapture: false,
20
- digitalIdsUpload: false,
21
- showDocumentChooserScreen: false,
22
- enableIdRecording: false,
23
- usSmartCapture: false,
24
- perCountryPerDocOverrides: {},
25
- },
26
- };
27
-
28
- export const mockSelfieModule: FlowModule = {
29
- key: 'SELFIE',
30
- configuration: {
31
- showTutorial: false,
32
- showPreview: true,
33
- assistedOnboarding: false,
34
- enableFaceRecording: false,
35
- autoCaptureTimeout: 30,
36
- captureAttempts: 3,
37
- validateLenses: false,
38
- validateFaceMask: false,
39
- validateHeadCover: false,
40
- validateClosedEyes: false,
41
- validateBrightness: false,
42
- deepsightLiveness: 'SINGLE_FRAME',
43
- },
44
- };
45
-
46
- export const mockFaceMatchModule: FlowModule = {
47
- key: 'FACE_MATCH',
48
- configuration: {
49
- matchingType: 'selfieVsId',
50
- disableFaceMatchAnimation: false,
51
- },
52
- };
53
-
54
- export const mockModules: FlowModule[] = [
55
- mockTutorialIdModule,
56
- mockSelfieModule,
57
- mockFaceMatchModule,
58
- ];
59
-
60
- export function createMockFlow(modules: FlowModule[] = mockModules): Flow {
61
- return {
62
- flowId: 'test-flow-id',
63
- name: 'Test Flow',
64
- flowModules: modules,
65
- };
66
- }
67
-
68
- export const mockFlow = createMockFlow();
69
-
70
- export function createMockGetFlow(flow: Flow = mockFlow) {
71
- return vi.fn().mockResolvedValue(flow);
72
- }
73
-
74
- export function createFailingGetFlow(error: string) {
75
- return vi.fn().mockRejectedValue(new Error(error));
76
- }
77
-
78
- export function createDelayedGetFlow(flow: Flow = mockFlow, delayMs = 1000) {
79
- return vi
80
- .fn()
81
- .mockImplementation(
82
- () => new Promise((resolve) => setTimeout(() => resolve(flow), delayMs)),
83
- );
84
- }
@@ -1,13 +0,0 @@
1
- import { createActor } from '@incodetech/infra';
2
- import { getFlow as defaultGetFlow, type GetFlow } from './flowServices';
3
- import { flowMachine } from './flowStateMachine';
4
-
5
- export type CreateFlowActorOptions = {
6
- getFlow?: GetFlow;
7
- };
8
-
9
- export function createFlowActor(options?: CreateFlowActorOptions) {
10
- const getFlow = options?.getFlow ?? defaultGetFlow;
11
-
12
- return createActor(flowMachine, { input: { getFlow } }).start();
13
- }