@incodetech/core 2.0.0-alpha.1 → 2.0.0-alpha.3

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 (104) hide show
  1. package/dist/Manager-6BwbaI_H.d.ts +19 -0
  2. package/dist/StateMachine-7c1gcu94.d.ts +2 -0
  3. package/dist/addEvent-1Mi5CEiq.esm.js +16 -0
  4. package/dist/chunk-C_Yo44FK.esm.js +49 -0
  5. package/dist/email.d.ts +264 -0
  6. package/dist/email.esm.js +479 -0
  7. package/dist/endpoints-D_pUMaqA.esm.js +1701 -0
  8. package/dist/flow.d.ts +578 -0
  9. package/dist/flow.esm.js +628 -0
  10. package/dist/index.d.ts +226 -0
  11. package/dist/index.esm.js +155 -0
  12. package/dist/lib-CyIAFRfr.esm.js +12499 -0
  13. package/dist/permissionServices-CVR0Pq38.esm.js +72 -0
  14. package/dist/phone.d.ts +292 -0
  15. package/dist/phone.esm.js +550 -0
  16. package/dist/selfie.d.ts +758 -0
  17. package/dist/selfie.esm.js +978 -0
  18. package/dist/types-tq1ypYSL.d.ts +5 -0
  19. package/dist/warmup-Dr7OcFND.d.ts +55 -0
  20. package/dist/xstate.esm-B_rda9yU.esm.js +3261 -0
  21. package/package.json +14 -11
  22. package/src/camera/cameraActor.ts +0 -21
  23. package/src/camera/cameraService.test.ts +0 -437
  24. package/src/camera/cameraService.ts +0 -165
  25. package/src/camera/cameraServices.test.ts +0 -66
  26. package/src/camera/cameraServices.ts +0 -26
  27. package/src/camera/cameraStateMachine.test.ts +0 -602
  28. package/src/camera/cameraStateMachine.ts +0 -264
  29. package/src/camera/index.ts +0 -5
  30. package/src/camera/types.ts +0 -17
  31. package/src/device/getBrowser.ts +0 -31
  32. package/src/device/getDeviceClass.ts +0 -29
  33. package/src/device/index.ts +0 -2
  34. package/src/email/__mocks__/emailMocks.ts +0 -59
  35. package/src/email/emailActor.ts +0 -15
  36. package/src/email/emailManager.test.ts +0 -573
  37. package/src/email/emailManager.ts +0 -427
  38. package/src/email/emailServices.ts +0 -66
  39. package/src/email/emailStateMachine.test.ts +0 -741
  40. package/src/email/emailStateMachine.ts +0 -367
  41. package/src/email/index.ts +0 -39
  42. package/src/email/types.ts +0 -60
  43. package/src/events/addEvent.ts +0 -20
  44. package/src/events/types.ts +0 -7
  45. package/src/flow/__mocks__/flowMocks.ts +0 -84
  46. package/src/flow/flowActor.ts +0 -13
  47. package/src/flow/flowAnalyzer.test.ts +0 -266
  48. package/src/flow/flowAnalyzer.ts +0 -37
  49. package/src/flow/flowCompletionService.ts +0 -21
  50. package/src/flow/flowManager.test.ts +0 -560
  51. package/src/flow/flowManager.ts +0 -235
  52. package/src/flow/flowServices.test.ts +0 -109
  53. package/src/flow/flowServices.ts +0 -13
  54. package/src/flow/flowStateMachine.test.ts +0 -334
  55. package/src/flow/flowStateMachine.ts +0 -182
  56. package/src/flow/index.ts +0 -21
  57. package/src/flow/moduleLoader.test.ts +0 -136
  58. package/src/flow/moduleLoader.ts +0 -73
  59. package/src/flow/orchestratedFlowManager.test.ts +0 -240
  60. package/src/flow/orchestratedFlowManager.ts +0 -231
  61. package/src/flow/orchestratedFlowStateMachine.test.ts +0 -199
  62. package/src/flow/orchestratedFlowStateMachine.ts +0 -325
  63. package/src/flow/types.ts +0 -434
  64. package/src/http/__mocks__/api.ts +0 -88
  65. package/src/http/api.test.ts +0 -231
  66. package/src/http/api.ts +0 -90
  67. package/src/http/endpoints.ts +0 -17
  68. package/src/index.ts +0 -33
  69. package/src/permissions/index.ts +0 -2
  70. package/src/permissions/permissionServices.ts +0 -31
  71. package/src/permissions/types.ts +0 -3
  72. package/src/phone/__mocks__/phoneMocks.ts +0 -71
  73. package/src/phone/index.ts +0 -39
  74. package/src/phone/phoneActor.ts +0 -15
  75. package/src/phone/phoneManager.test.ts +0 -393
  76. package/src/phone/phoneManager.ts +0 -458
  77. package/src/phone/phoneServices.ts +0 -98
  78. package/src/phone/phoneStateMachine.test.ts +0 -918
  79. package/src/phone/phoneStateMachine.ts +0 -422
  80. package/src/phone/types.ts +0 -83
  81. package/src/recordings/recordingsRepository.test.ts +0 -87
  82. package/src/recordings/recordingsRepository.ts +0 -48
  83. package/src/recordings/streamingEvents.ts +0 -10
  84. package/src/selfie/__mocks__/selfieMocks.ts +0 -26
  85. package/src/selfie/index.ts +0 -14
  86. package/src/selfie/selfieActor.ts +0 -17
  87. package/src/selfie/selfieErrorUtils.test.ts +0 -116
  88. package/src/selfie/selfieErrorUtils.ts +0 -66
  89. package/src/selfie/selfieManager.test.ts +0 -297
  90. package/src/selfie/selfieManager.ts +0 -301
  91. package/src/selfie/selfieServices.ts +0 -362
  92. package/src/selfie/selfieStateMachine.test.ts +0 -283
  93. package/src/selfie/selfieStateMachine.ts +0 -804
  94. package/src/selfie/selfieUploadService.test.ts +0 -90
  95. package/src/selfie/selfieUploadService.ts +0 -81
  96. package/src/selfie/types.ts +0 -103
  97. package/src/session/index.ts +0 -5
  98. package/src/session/sessionService.ts +0 -78
  99. package/src/setup.test.ts +0 -61
  100. package/src/setup.ts +0 -171
  101. package/tsconfig.json +0 -13
  102. package/tsdown.config.ts +0 -22
  103. package/vitest.config.ts +0 -37
  104. package/vitest.setup.ts +0 -135
@@ -0,0 +1,19 @@
1
+ //#region ../infra/src/manager/Manager.d.ts
2
+ /**
3
+ * Base manager interface providing state access, subscriptions, and lifecycle control.
4
+ * @template TPublicState - The public state type exposed to consumers
5
+ */
6
+ type Manager<TPublicState> = {
7
+ /** Returns the current mapped public state */
8
+ getState(): TPublicState;
9
+ /**
10
+ * Subscribes to state changes.
11
+ * @param listener - Callback invoked on every state change
12
+ * @returns Unsubscribe function to stop receiving updates
13
+ */
14
+ subscribe(listener: (state: TPublicState) => void): () => void;
15
+ /** Stops the underlying actor and cleans up resources */
16
+ stop(): void;
17
+ };
18
+ //#endregion
19
+ export { Manager as t };
@@ -0,0 +1,2 @@
1
+ import { AnyStateMachine, StateMachine } from "xstate";
2
+ export { StateMachine as n, AnyStateMachine as t };
@@ -0,0 +1,16 @@
1
+ import { n as api, t as endpoints } from "./endpoints-D_pUMaqA.esm.js";
2
+
3
+ //#region src/events/addEvent.ts
4
+ function addEvent(event) {
5
+ const { code, module, screen, clientTimestamp, payload = {} } = event;
6
+ return api.post(endpoints.events, [{
7
+ code,
8
+ module,
9
+ screen,
10
+ clientTimestamp: clientTimestamp ?? Date.now(),
11
+ payload
12
+ }]).then(() => void 0).catch(() => void 0);
13
+ }
14
+
15
+ //#endregion
16
+ export { addEvent as t };
@@ -0,0 +1,49 @@
1
+ //#region rolldown:runtime
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __esm = (fn, res) => function() {
9
+ return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
10
+ };
11
+ var __commonJS = (cb, mod) => function() {
12
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
13
+ };
14
+ var __export = (all, symbols) => {
15
+ let target = {};
16
+ for (var name in all) {
17
+ __defProp(target, name, {
18
+ get: all[name],
19
+ enumerable: true
20
+ });
21
+ }
22
+ if (symbols) {
23
+ __defProp(target, Symbol.toStringTag, { value: "Module" });
24
+ }
25
+ return target;
26
+ };
27
+ var __copyProps = (to, from, except, desc) => {
28
+ if (from && typeof from === "object" || typeof from === "function") {
29
+ for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
30
+ key = keys[i];
31
+ if (!__hasOwnProp.call(to, key) && key !== except) {
32
+ __defProp(to, key, {
33
+ get: ((k) => from[k]).bind(null, key),
34
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
35
+ });
36
+ }
37
+ }
38
+ }
39
+ return to;
40
+ };
41
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
42
+ value: mod,
43
+ enumerable: true
44
+ }) : target, mod));
45
+ var __toCommonJS = (mod) => __hasOwnProp.call(mod, "module.exports") ? mod["module.exports"] : __copyProps(__defProp({}, "__esModule", { value: true }), mod);
46
+ var __toDynamicImportESM = (isNodeMode) => (mod) => __toESM(mod.default, isNodeMode);
47
+
48
+ //#endregion
49
+ export { __toDynamicImportESM as a, __toCommonJS as i, __esm as n, __export as r, __commonJS as t };
@@ -0,0 +1,264 @@
1
+ import { t as Manager } from "./Manager-6BwbaI_H.js";
2
+
3
+ //#region src/email/types.d.ts
4
+
5
+ /**
6
+ * Configuration options for email verification.
7
+ *
8
+ * @example Standard OTP verification
9
+ * ```typescript
10
+ * const config: EmailConfig = {
11
+ * otpVerification: true,
12
+ * otpExpirationInMinutes: 5,
13
+ * prefill: false,
14
+ * };
15
+ * ```
16
+ *
17
+ * @example With all options
18
+ * ```typescript
19
+ * const config: EmailConfig = {
20
+ * otpVerification: true,
21
+ * otpExpirationInMinutes: 10,
22
+ * prefill: true,
23
+ * maxOtpAttempts: 3,
24
+ * };
25
+ * ```
26
+ */
27
+ type EmailConfig = {
28
+ /**
29
+ * Whether to require OTP (email code) verification.
30
+ * If false, email is verified immediately after submission.
31
+ */
32
+ otpVerification: boolean;
33
+ /**
34
+ * How long the OTP code remains valid, in minutes.
35
+ * After expiration, user must request a new code.
36
+ */
37
+ otpExpirationInMinutes: number;
38
+ /**
39
+ * Whether to pre-populate with user's previously stored email address.
40
+ * Useful for returning users.
41
+ */
42
+ prefill: boolean;
43
+ /**
44
+ * Maximum number of OTP verification attempts before lockout.
45
+ * After exhausting attempts, user sees an error state.
46
+ * @default 3
47
+ */
48
+ maxOtpAttempts?: number;
49
+ };
50
+ //#endregion
51
+ //#region src/email/emailStateMachine.d.ts
52
+
53
+ declare const emailMachine: any;
54
+ //#endregion
55
+ //#region src/email/emailActor.d.ts
56
+ type CreateEmailActorOptions = {
57
+ config: EmailConfig;
58
+ };
59
+ //#endregion
60
+ //#region src/email/emailManager.d.ts
61
+ /** Email manager is in initial state, waiting for `load()` to be called */
62
+ type EmailIdleState = {
63
+ status: 'idle';
64
+ };
65
+ /** Loading prefilled email address from backend (if prefill is enabled) */
66
+ type EmailLoadingPrefillState = {
67
+ status: 'loadingPrefill';
68
+ };
69
+ /**
70
+ * Ready for email input - use `setEmail()` and `submit()`
71
+ * @property prefilledEmail - Pre-populated email address (if prefill enabled)
72
+ * @property emailError - Validation error message if email was rejected
73
+ */
74
+ type EmailInputtingState = {
75
+ status: 'inputting';
76
+ prefilledEmail?: string;
77
+ emailError?: string;
78
+ };
79
+ /** Email address is being submitted to the backend */
80
+ type EmailSubmittingState = {
81
+ status: 'submitting';
82
+ };
83
+ /** OTP is being sent to the email address */
84
+ type EmailSendingOtpState = {
85
+ status: 'sendingOtp';
86
+ };
87
+ /**
88
+ * Waiting for OTP code - use `submitOtp()`, `resendOtp()`, or `back()`
89
+ * @property resendTimer - Seconds remaining before resend is allowed
90
+ * @property canResend - Whether the resend button should be enabled
91
+ * @property attemptsRemaining - Number of OTP verification attempts left
92
+ */
93
+ type EmailAwaitingOtpState = {
94
+ status: 'awaitingOtp';
95
+ resendTimer: number;
96
+ canResend: boolean;
97
+ attemptsRemaining: number;
98
+ };
99
+ /** OTP code is being verified against the backend */
100
+ type EmailVerifyingOtpState = {
101
+ status: 'verifyingOtp';
102
+ };
103
+ /**
104
+ * OTP verification failed - user can retry with `submitOtp()`
105
+ * @property error - Error message describing why verification failed
106
+ * @property attemptsRemaining - Number of remaining attempts before lockout
107
+ */
108
+ type EmailOtpErrorState = {
109
+ status: 'otpError';
110
+ error: string;
111
+ attemptsRemaining: number;
112
+ };
113
+ /** Email verification completed successfully - call `reset()` to start over */
114
+ type EmailSuccessState = {
115
+ status: 'success';
116
+ };
117
+ /**
118
+ * Fatal error occurred - call `reset()` to start over
119
+ * @property error - Error message describing what went wrong
120
+ */
121
+ type EmailErrorState = {
122
+ status: 'error';
123
+ error: string;
124
+ };
125
+ /**
126
+ * Union of all possible email manager states.
127
+ * Use discriminated union pattern to narrow the type:
128
+ *
129
+ * @example
130
+ * ```typescript
131
+ * const state = emailManager.getState();
132
+ * if (state.status === 'inputting') {
133
+ * // TypeScript knows state has prefilledEmail, emailError, etc.
134
+ * console.log(state.prefilledEmail);
135
+ * }
136
+ * ```
137
+ */
138
+ type EmailState = EmailIdleState | EmailLoadingPrefillState | EmailInputtingState | EmailSubmittingState | EmailSendingOtpState | EmailAwaitingOtpState | EmailVerifyingOtpState | EmailOtpErrorState | EmailSuccessState | EmailErrorState;
139
+ /**
140
+ * Creates an email verification manager for headless or UI-driven usage.
141
+ *
142
+ * The manager provides a state machine-based API for email address verification
143
+ * with optional OTP (one-time password) verification.
144
+ *
145
+ * @param options - Configuration options
146
+ * @param options.config - Email verification configuration
147
+ * @param options.config.otpVerification - Whether to require OTP verification
148
+ * @param options.config.otpExpirationInMinutes - How long the OTP is valid
149
+ * @param options.config.prefill - Whether to fetch a pre-filled email address
150
+ * @param options.config.maxOtpAttempts - Maximum OTP verification attempts (default: 3)
151
+ *
152
+ * @returns Email manager with state, API methods, and subscription
153
+ *
154
+ * @example Headless usage
155
+ * ```typescript
156
+ * const manager = createEmailManager({
157
+ * config: { otpVerification: true, otpExpirationInMinutes: 5, prefill: false },
158
+ * });
159
+ *
160
+ * manager.subscribe((state) => console.log(state.status));
161
+ * manager.load();
162
+ * manager.setEmail('user@example.com', true);
163
+ * manager.submit();
164
+ * // ... wait for 'awaitingOtp' state ...
165
+ * manager.submitOtp('ABC123');
166
+ * manager.stop();
167
+ * ```
168
+ *
169
+ * @example With React/Preact UI hook
170
+ * ```tsx
171
+ * const [state, manager] = useManager(() => createEmailManager({ config }));
172
+ *
173
+ * if (state.status === 'inputting') {
174
+ * return <input onChange={(e) => manager.setEmail(e.target.value, true)} />;
175
+ * }
176
+ * ```
177
+ */
178
+ declare function createEmailManager(options: CreateEmailActorOptions): Manager<EmailState> & {
179
+ /**
180
+ * Initializes the email verification flow.
181
+ * Transitions from 'idle' to 'loadingPrefill' or 'inputting'.
182
+ * Must be called before any other method.
183
+ */
184
+ load(): void;
185
+ /**
186
+ * Sets the email address for verification.
187
+ * Should be called when state is 'inputting'.
188
+ *
189
+ * @param email - Email address (e.g., 'user@example.com')
190
+ * @param isValid - Whether the email address passes validation
191
+ *
192
+ * @example
193
+ * ```typescript
194
+ * // Using regex for validation
195
+ * const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
196
+ * const email = 'user@example.com';
197
+ * emailManager.setEmail(email, emailRegex.test(email));
198
+ * ```
199
+ */
200
+ setEmail(email: string, isValid: boolean): void;
201
+ /**
202
+ * Submits the email address for verification.
203
+ * Requires a valid email address to be set via `setEmail()`.
204
+ * Transitions to 'submitting', then to 'sendingOtp' or 'success' (if no OTP).
205
+ */
206
+ submit(): void;
207
+ /**
208
+ * Sets the OTP code without submitting.
209
+ * Use this for controlled input components.
210
+ *
211
+ * @param code - The OTP code entered by the user
212
+ */
213
+ setOtpCode(code: string): void;
214
+ /**
215
+ * Sets and submits the OTP code in one call.
216
+ * Should be called when state is 'awaitingOtp' or 'otpError'.
217
+ *
218
+ * @param code - The complete OTP code (typically 6 alphanumeric characters)
219
+ *
220
+ * @example
221
+ * ```typescript
222
+ * // Submit OTP when user completes entry
223
+ * emailManager.submitOtp('HH36LP');
224
+ * ```
225
+ */
226
+ submitOtp(code: string): void;
227
+ /**
228
+ * Requests a new OTP code to be sent.
229
+ * Only works when state is 'awaitingOtp' and `canResend` is true.
230
+ * Resets the resend timer.
231
+ */
232
+ resendOtp(): void;
233
+ /**
234
+ * Returns to the email input screen from OTP entry.
235
+ * Allows the user to change their email address.
236
+ * Transitions from 'awaitingOtp' or 'otpError' back to 'inputting'.
237
+ */
238
+ back(): void;
239
+ /**
240
+ * Resets the manager to initial state.
241
+ * Can be called from 'success' or 'error' states to start over.
242
+ * Clears all stored data including email address and OTP.
243
+ */
244
+ reset(): void;
245
+ };
246
+ /**
247
+ * Type representing an email manager instance.
248
+ * Includes state access, API methods, and lifecycle management.
249
+ *
250
+ * @property getState - Returns the current EmailState
251
+ * @property subscribe - Subscribes to state changes, returns unsubscribe function
252
+ * @property stop - Stops the manager and cleans up resources
253
+ * @property load - Initializes the verification flow
254
+ * @property setEmail - Sets the email address
255
+ * @property submit - Submits the email address
256
+ * @property setOtpCode - Sets OTP code without submitting
257
+ * @property submitOtp - Sets and submits OTP code
258
+ * @property resendOtp - Requests new OTP code
259
+ * @property back - Returns to email input from OTP screen
260
+ * @property reset - Resets to initial state
261
+ */
262
+ type EmailManager = ReturnType<typeof createEmailManager>;
263
+ //#endregion
264
+ export { type EmailConfig, type EmailManager, type EmailState, createEmailManager, emailMachine };