@fanfare-io/fanfare-sdk-core 0.1.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 (170) hide show
  1. package/LICENSE +202 -0
  2. package/README.md +44 -0
  3. package/dist/adapters/google-analytics.d.ts +12 -0
  4. package/dist/adapters/google-analytics.js +1 -0
  5. package/dist/adapters/index.d.ts +9 -0
  6. package/dist/adapters/index.js +1 -0
  7. package/dist/adapters/types.d.ts +9 -0
  8. package/dist/appointments/appointment.module.d.ts +32 -0
  9. package/dist/appointments/appointment.module.js +1 -0
  10. package/dist/appointments/index.d.ts +2 -0
  11. package/dist/appointments/public.d.ts +1 -0
  12. package/dist/appointments/public.js +1 -0
  13. package/dist/appointments/types.d.ts +47 -0
  14. package/dist/auctions/auction.module.d.ts +58 -0
  15. package/dist/auctions/auction.module.js +1 -0
  16. package/dist/auctions/index.d.ts +5 -0
  17. package/dist/auctions/public.d.ts +5 -0
  18. package/dist/auctions/public.js +1 -0
  19. package/dist/auctions/types.d.ts +97 -0
  20. package/dist/auth/auth.module.d.ts +71 -0
  21. package/dist/auth/auth.module.js +1 -0
  22. package/dist/auth/index.d.ts +1 -0
  23. package/dist/auth/index.js +1 -0
  24. package/dist/auth/types.d.ts +112 -0
  25. package/dist/beacon/batching.d.ts +52 -0
  26. package/dist/beacon/batching.js +1 -0
  27. package/dist/beacon/beacon.module.d.ts +58 -0
  28. package/dist/beacon/beacon.module.js +1 -0
  29. package/dist/beacon/enrichment.d.ts +16 -0
  30. package/dist/beacon/enrichment.js +1 -0
  31. package/dist/beacon/index.d.ts +12 -0
  32. package/dist/beacon/public.d.ts +9 -0
  33. package/dist/beacon/public.js +1 -0
  34. package/dist/beacon/types.d.ts +103 -0
  35. package/dist/beacon/validation.d.ts +24 -0
  36. package/dist/beacon/validation.js +1 -0
  37. package/dist/challenges/challenge.module.d.ts +9 -0
  38. package/dist/challenges/challenge.module.js +1 -0
  39. package/dist/challenges/index.d.ts +3 -0
  40. package/dist/challenges/public.d.ts +9 -0
  41. package/dist/challenges/public.js +1 -0
  42. package/dist/challenges/types.d.ts +33 -0
  43. package/dist/config/index.d.ts +44 -0
  44. package/dist/config/index.js +1 -0
  45. package/dist/core/client.d.ts +15 -0
  46. package/dist/core/client.js +2 -0
  47. package/dist/core/errors.d.ts +175 -0
  48. package/dist/core/errors.js +1 -0
  49. package/dist/core/http.d.ts +87 -0
  50. package/dist/core/http.js +1 -0
  51. package/dist/core/logger.d.ts +46 -0
  52. package/dist/core/logger.js +1 -0
  53. package/dist/core/money.d.ts +10 -0
  54. package/dist/core/money.js +1 -0
  55. package/dist/core/parse-response.d.ts +62 -0
  56. package/dist/core/parse-response.js +1 -0
  57. package/dist/core/utils.d.ts +67 -0
  58. package/dist/core/utils.js +1 -0
  59. package/dist/draws/draw.module.d.ts +40 -0
  60. package/dist/draws/draw.module.js +1 -0
  61. package/dist/draws/index.d.ts +5 -0
  62. package/dist/draws/public.d.ts +6 -0
  63. package/dist/draws/public.js +1 -0
  64. package/dist/draws/types.d.ts +90 -0
  65. package/dist/draws/types.js +1 -0
  66. package/dist/errors.d.ts +5 -0
  67. package/dist/errors.js +1 -0
  68. package/dist/events.d.ts +5 -0
  69. package/dist/events.js +1 -0
  70. package/dist/experiences/distribution-monitor.runtime.d.ts +12 -0
  71. package/dist/experiences/distribution-monitor.runtime.js +1 -0
  72. package/dist/experiences/distribution-monitor.types.d.ts +62 -0
  73. package/dist/experiences/experience.module.d.ts +88 -0
  74. package/dist/experiences/experience.module.js +1 -0
  75. package/dist/experiences/index.d.ts +3 -0
  76. package/dist/experiences/index.js +1 -0
  77. package/dist/experiences/journey-contract.fixtures.d.ts +9 -0
  78. package/dist/experiences/journey-view.d.ts +22 -0
  79. package/dist/experiences/journey-view.js +1 -0
  80. package/dist/experiences/journey.d.ts +89 -0
  81. package/dist/experiences/journey.js +1 -0
  82. package/dist/experiences/journey.machine.d.ts +79 -0
  83. package/dist/experiences/journey.machine.js +1 -0
  84. package/dist/experiences/journey.types.d.ts +395 -0
  85. package/dist/experiences/public.d.ts +13 -0
  86. package/dist/experiences/public.js +1 -0
  87. package/dist/experiences/types.d.ts +161 -0
  88. package/dist/handoff/handoff.module.d.ts +184 -0
  89. package/dist/handoff/handoff.module.js +1 -0
  90. package/dist/handoff/index.d.ts +5 -0
  91. package/dist/handoff/index.js +1 -0
  92. package/dist/index.d.ts +11 -0
  93. package/dist/index.js +1 -0
  94. package/dist/internals.d.ts +11 -0
  95. package/dist/internals.js +1 -0
  96. package/dist/queues/index.d.ts +5 -0
  97. package/dist/queues/index.js +1 -0
  98. package/dist/queues/qualitative-bucket.d.ts +12 -0
  99. package/dist/queues/qualitative-bucket.js +1 -0
  100. package/dist/queues/queue.module.d.ts +42 -0
  101. package/dist/queues/queue.module.js +1 -0
  102. package/dist/queues/types.d.ts +112 -0
  103. package/dist/queues/types.js +1 -0
  104. package/dist/security/admission-proof.d.ts +15 -0
  105. package/dist/security/admission-proof.js +1 -0
  106. package/dist/state/capability-token-registry.d.ts +44 -0
  107. package/dist/state/capability-token-registry.js +1 -0
  108. package/dist/state/events.d.ts +342 -0
  109. package/dist/state/events.js +1 -0
  110. package/dist/state/store.d.ts +48 -0
  111. package/dist/state/store.js +1 -0
  112. package/dist/sync/broadcast-transport.d.ts +19 -0
  113. package/dist/sync/broadcast-transport.js +1 -0
  114. package/dist/sync/cross-tab-coordinator.d.ts +44 -0
  115. package/dist/sync/cross-tab-coordinator.js +1 -0
  116. package/dist/sync/index.d.ts +8 -0
  117. package/dist/sync/localstorage-transport.d.ts +32 -0
  118. package/dist/sync/localstorage-transport.js +1 -0
  119. package/dist/sync/protocol-transport.d.ts +51 -0
  120. package/dist/sync/protocol-transport.js +1 -0
  121. package/dist/sync/protocol.d.ts +254 -0
  122. package/dist/sync/protocol.js +1 -0
  123. package/dist/sync/recovery.d.ts +68 -0
  124. package/dist/sync/transport-factory.d.ts +16 -0
  125. package/dist/sync/transport-factory.js +1 -0
  126. package/dist/sync/transport-interface.d.ts +33 -0
  127. package/dist/sync/transport.d.ts +49 -0
  128. package/dist/sync/transport.js +1 -0
  129. package/dist/test-utils/harness-scenarios.d.ts +71 -0
  130. package/dist/test-utils/harness-scenarios.js +1 -0
  131. package/dist/test-utils/index.d.ts +12 -0
  132. package/dist/test-utils/index.js +1 -0
  133. package/dist/test-utils/mock-journey.d.ts +63 -0
  134. package/dist/test-utils/mock-journey.js +1 -0
  135. package/dist/test-utils/mock-sdk-vitest.d.ts +80 -0
  136. package/dist/test-utils/mock-sdk-vitest.js +1 -0
  137. package/dist/test-utils/mock-sdk.d.ts +22 -0
  138. package/dist/test-utils/mock-sdk.js +1 -0
  139. package/dist/test-utils/mock-server.d.ts +105 -0
  140. package/dist/test-utils/mock-server.js +1 -0
  141. package/dist/test-utils/sdk-factory.d.ts +3 -0
  142. package/dist/test-utils/sdk-factory.js +1 -0
  143. package/dist/test-utils/verification-scenarios.d.ts +43 -0
  144. package/dist/test-utils/verification-scenarios.js +1 -0
  145. package/dist/test-utils/verification-state.d.ts +1 -0
  146. package/dist/test-utils/verification-state.js +1 -0
  147. package/dist/theme.d.ts +8 -0
  148. package/dist/theme.js +1 -0
  149. package/dist/timed-releases/index.d.ts +6 -0
  150. package/dist/timed-releases/public.d.ts +6 -0
  151. package/dist/timed-releases/public.js +1 -0
  152. package/dist/timed-releases/timed-release.module.d.ts +31 -0
  153. package/dist/timed-releases/timed-release.module.js +1 -0
  154. package/dist/timed-releases/types.d.ts +70 -0
  155. package/dist/timed-releases/types.js +1 -0
  156. package/dist/types/distribution-type.d.ts +45 -0
  157. package/dist/types/index.d.ts +178 -0
  158. package/dist/utils/fingerprint.module.d.ts +27 -0
  159. package/dist/utils/fingerprint.module.js +1 -0
  160. package/dist/utils/index.d.ts +4 -0
  161. package/dist/version.d.ts +5 -0
  162. package/dist/version.js +1 -0
  163. package/dist/waitlists/index.d.ts +2 -0
  164. package/dist/waitlists/public.d.ts +6 -0
  165. package/dist/waitlists/public.js +1 -0
  166. package/dist/waitlists/types.d.ts +50 -0
  167. package/dist/waitlists/types.js +1 -0
  168. package/dist/waitlists/waitlist.module.d.ts +17 -0
  169. package/dist/waitlists/waitlist.module.js +1 -0
  170. package/package.json +205 -0
@@ -0,0 +1,395 @@
1
+ import { AdmissionGrant, AppointmentConsumerStatus, AuctionConsumerStatus, DistributionLifecycle, DistributionType, DrawConsumerStatus, JourneyStage, QueueConsumerStatus, SequenceOutcome, SequenceOutcomeType, SequencePhase, TimedReleaseConsumerStatus, WaitlistConsumerStatus } from '@fanfare-io/fanfare-sdk-contracts/consumer-me';
2
+ import { ReadableAtom } from 'nanostores';
3
+ import { BotMitigationState, RoutingChallenge } from '../challenges/types';
4
+ import { SdkJourneyParticipationType } from '../types/distribution-type';
5
+ import { AppointmentDisplayState, AuctionDisplayState, DrawDisplayState, QueueDisplayState, TimedReleaseDisplayState } from './distribution-monitor.types';
6
+ import { DistributionDetails, ExperienceSession, Sequence } from './types';
7
+ export type { AdmissionGrant, AppointmentConsumerStatus, AuctionConsumerStatus, DistributionLifecycle, DistributionType, DrawConsumerStatus, JourneyStage, QueueConsumerStatus, SequenceOutcome, SequenceOutcomeType, SequencePhase, TimedReleaseConsumerStatus, WaitlistConsumerStatus, };
8
+ export type SequenceMechanism = DistributionType | "waitlist";
9
+ export type PrimarySequenceMechanism = DistributionType;
10
+ export type GrantProducingSequenceMechanism = Exclude<PrimarySequenceMechanism, "appointment">;
11
+ export type SettlingSequenceMechanism = "draw" | "auction";
12
+ export interface DistributionSummary {
13
+ type: DistributionType;
14
+ id: string;
15
+ sequenceId?: string;
16
+ lifecycle: DistributionLifecycle;
17
+ startsAt?: string;
18
+ opensAt?: string;
19
+ closesAt?: string;
20
+ settlesAt?: string;
21
+ waitlistId?: string;
22
+ details?: DistributionDetails;
23
+ updatedAt?: number;
24
+ }
25
+ export interface DistributionTarget {
26
+ type: DistributionType;
27
+ id: string;
28
+ sequenceId?: string;
29
+ lifecycle: DistributionLifecycle;
30
+ opensAt?: string;
31
+ closesAt?: string;
32
+ waitlistId?: string;
33
+ details?: Record<string, unknown>;
34
+ updatedAt?: number;
35
+ }
36
+ export type SequenceDistributionState = DistributionSummary;
37
+ export type SequenceTargetState = DistributionTarget;
38
+ export interface QueueSequenceConsumerState {
39
+ status: QueueConsumerStatus;
40
+ id?: string;
41
+ distributionId?: string;
42
+ enteredAt?: string;
43
+ admissionGrant?: string;
44
+ grantedAt?: string;
45
+ deniedReason?: string;
46
+ position?: number;
47
+ }
48
+ export interface DrawSequenceConsumerState {
49
+ status: DrawConsumerStatus;
50
+ id?: string;
51
+ distributionId?: string;
52
+ enteredAt?: string;
53
+ admissionGrant?: string;
54
+ grantedAt?: string;
55
+ deniedReason?: string;
56
+ }
57
+ export interface AuctionSequenceConsumerState {
58
+ status: AuctionConsumerStatus;
59
+ id?: string;
60
+ distributionId?: string;
61
+ enteredAt?: string;
62
+ admissionGrant?: string;
63
+ grantedAt?: string;
64
+ deniedReason?: string;
65
+ highestBid?: string;
66
+ currentBid?: string;
67
+ }
68
+ export interface TimedReleaseSequenceConsumerState {
69
+ status: TimedReleaseConsumerStatus;
70
+ id?: string;
71
+ distributionId?: string;
72
+ enteredAt?: string;
73
+ admissionGrant?: string;
74
+ grantedAt?: string;
75
+ deniedReason?: string;
76
+ }
77
+ export interface AppointmentSequenceConsumerState {
78
+ status: AppointmentConsumerStatus;
79
+ id?: string;
80
+ distributionId?: string;
81
+ slotId?: string;
82
+ locationId?: string;
83
+ bookedAt?: string;
84
+ checkedInAt?: string;
85
+ completedAt?: string;
86
+ cancelledAt?: string;
87
+ noShowAt?: string;
88
+ }
89
+ export interface WaitlistSequenceConsumerState {
90
+ status: WaitlistConsumerStatus;
91
+ id?: string;
92
+ waitlistId?: string;
93
+ enteredAt?: string;
94
+ notifiedAt?: string;
95
+ }
96
+ export type ConsumerSequenceState = QueueSequenceConsumerState | DrawSequenceConsumerState | AuctionSequenceConsumerState | TimedReleaseSequenceConsumerState | AppointmentSequenceConsumerState | WaitlistSequenceConsumerState;
97
+ export type SequenceConsumerFor<M extends SequenceMechanism> = M extends "queue" ? QueueSequenceConsumerState : M extends "draw" ? DrawSequenceConsumerState : M extends "auction" ? AuctionSequenceConsumerState : M extends "timed_release" ? TimedReleaseSequenceConsumerState : M extends "appointment" ? AppointmentSequenceConsumerState : WaitlistSequenceConsumerState;
98
+ export type MechanismConsumerState = (QueueSequenceConsumerState & {
99
+ mechanism: "queue";
100
+ }) | (DrawSequenceConsumerState & {
101
+ mechanism: "draw";
102
+ }) | (AuctionSequenceConsumerState & {
103
+ mechanism: "auction";
104
+ }) | (TimedReleaseSequenceConsumerState & {
105
+ mechanism: "timed_release";
106
+ }) | (AppointmentSequenceConsumerState & {
107
+ mechanism: "appointment";
108
+ }) | (WaitlistSequenceConsumerState & {
109
+ mechanism: "waitlist";
110
+ });
111
+ interface PrimarySequenceContext<M extends PrimarySequenceMechanism> {
112
+ mechanism: M;
113
+ distribution: DistributionSummary & {
114
+ type: M;
115
+ };
116
+ consumer: SequenceConsumerFor<M>;
117
+ }
118
+ interface WaitlistSequenceContext {
119
+ mechanism: "waitlist";
120
+ target: DistributionTarget;
121
+ consumer: WaitlistSequenceConsumerState;
122
+ }
123
+ export type UnavailableSequenceState = {
124
+ phase: "unavailable";
125
+ reason?: string;
126
+ };
127
+ export type ScheduledSequenceState = {
128
+ [M in PrimarySequenceMechanism]: {
129
+ phase: "scheduled";
130
+ } & PrimarySequenceContext<M>;
131
+ }[PrimarySequenceMechanism];
132
+ export type EnterableSequenceState = {
133
+ [M in PrimarySequenceMechanism]: {
134
+ phase: "enterable";
135
+ } & PrimarySequenceContext<M>;
136
+ }[PrimarySequenceMechanism] | ({
137
+ phase: "enterable";
138
+ } & WaitlistSequenceContext);
139
+ export type ParticipatingSequenceState = {
140
+ [M in PrimarySequenceMechanism]: {
141
+ phase: "participating";
142
+ } & PrimarySequenceContext<M>;
143
+ }[PrimarySequenceMechanism] | ({
144
+ phase: "participating";
145
+ } & WaitlistSequenceContext);
146
+ export type SettlingSequenceState = {
147
+ [M in SettlingSequenceMechanism]: {
148
+ phase: "settling";
149
+ } & PrimarySequenceContext<M>;
150
+ }[SettlingSequenceMechanism];
151
+ export type GrantedSequenceState = {
152
+ [M in GrantProducingSequenceMechanism]: {
153
+ phase: "granted";
154
+ grant: AdmissionGrant;
155
+ } & PrimarySequenceContext<M>;
156
+ }[GrantProducingSequenceMechanism];
157
+ export type EndedSequenceState = {
158
+ [M in PrimarySequenceMechanism]: {
159
+ phase: "ended";
160
+ outcome: SequenceOutcome;
161
+ } & PrimarySequenceContext<M>;
162
+ }[PrimarySequenceMechanism] | ({
163
+ phase: "ended";
164
+ outcome: SequenceOutcome;
165
+ } & WaitlistSequenceContext);
166
+ export type SequenceState = UnavailableSequenceState | ScheduledSequenceState | EnterableSequenceState | ParticipatingSequenceState | SettlingSequenceState | GrantedSequenceState | EndedSequenceState;
167
+ export type ActiveSequenceState = Exclude<SequenceState, UnavailableSequenceState>;
168
+ export type SequenceStateFor<M extends SequenceMechanism> = Extract<ActiveSequenceState, {
169
+ mechanism: M;
170
+ }>;
171
+ export type PrimarySequenceState = Extract<ActiveSequenceState, {
172
+ distribution: DistributionSummary;
173
+ }>;
174
+ export type ConsumerJourneyState = {
175
+ journeyStage: "ready";
176
+ experienceId: string;
177
+ updatedAt?: string;
178
+ } | {
179
+ journeyStage: "routing";
180
+ experienceId: string;
181
+ updatedAt?: string;
182
+ } | {
183
+ journeyStage: "gated";
184
+ experienceId: string;
185
+ updatedAt?: string;
186
+ gates: unknown[];
187
+ selected?: {
188
+ sequenceId: string;
189
+ };
190
+ } | {
191
+ journeyStage: "routed";
192
+ experienceId: string;
193
+ updatedAt?: string;
194
+ sequenceId: string;
195
+ sequence: SequenceState;
196
+ offers?: unknown[];
197
+ };
198
+ export type ServiceJourneyState = Extract<ConsumerJourneyState, {
199
+ journeyStage: "gated" | "routed";
200
+ }>;
201
+ export type ServiceJourneyStage = ServiceJourneyState["journeyStage"];
202
+ export type RoutingGate = {
203
+ type: "authentication";
204
+ status: "required";
205
+ } | {
206
+ type: "access_code";
207
+ status: "missing" | "invalid";
208
+ } | {
209
+ type: "bot_check";
210
+ status: "required" | "blocked";
211
+ challenge?: RoutingChallenge;
212
+ mitigation?: BotMitigationState;
213
+ };
214
+ export interface RoutingOffer {
215
+ sequence: Sequence;
216
+ status: "gated";
217
+ gates: RoutingGate[];
218
+ }
219
+ export interface Participation {
220
+ id: string;
221
+ type: SdkJourneyParticipationType;
222
+ }
223
+ export type JourneyEventKind = "reroute" | "sequence_change" | "distribution_change" | "requirement" | "error" | "info";
224
+ export type JourneyEventSeverity = "info" | "success" | "warning" | "error";
225
+ export type JourneyEventAudience = "user" | "system" | "analytics";
226
+ export interface JourneyEvent {
227
+ id: string;
228
+ ts: number;
229
+ kind: JourneyEventKind;
230
+ severity: JourneyEventSeverity;
231
+ audience: JourneyEventAudience;
232
+ message: string;
233
+ detail?: Record<string, unknown>;
234
+ }
235
+ interface JourneyBase {
236
+ revision: number;
237
+ updatedAt: number;
238
+ experienceId: string;
239
+ accessCode?: string;
240
+ experience?: ExperienceSession;
241
+ events: JourneyEvent[];
242
+ lastSeenEventId?: string;
243
+ }
244
+ export interface ReadySnapshot extends JourneyBase {
245
+ journeyStage: "ready";
246
+ }
247
+ export interface RoutingSnapshot extends JourneyBase {
248
+ journeyStage: "routing";
249
+ }
250
+ export interface GatedSnapshot extends JourneyBase {
251
+ journeyStage: "gated";
252
+ gates: RoutingGate[];
253
+ selected?: {
254
+ sequence: Sequence;
255
+ status: "gated";
256
+ };
257
+ }
258
+ export interface RoutedSnapshot extends JourneyBase {
259
+ journeyStage: "routed";
260
+ sequenceId: string;
261
+ offers: RoutingOffer[];
262
+ sequence: SequenceState;
263
+ }
264
+ export type JourneySnapshot = ReadySnapshot | RoutingSnapshot | GatedSnapshot | RoutedSnapshot;
265
+ export interface ReadyView {
266
+ journeyStage: "ready";
267
+ start(opts?: {
268
+ accessCode?: string;
269
+ }): Promise<void>;
270
+ }
271
+ export interface RoutingView {
272
+ journeyStage: "routing";
273
+ }
274
+ export interface GatedView {
275
+ journeyStage: "gated";
276
+ gates: RoutingGate[];
277
+ selected?: {
278
+ sequence: Sequence;
279
+ status: "gated";
280
+ };
281
+ reroute(opts?: {
282
+ accessCode?: string;
283
+ }): Promise<void>;
284
+ retry(): Promise<void>;
285
+ }
286
+ export interface RoutedView {
287
+ journeyStage: "routed";
288
+ sequenceId: string;
289
+ offers: RoutingOffer[];
290
+ reroute(): Promise<void>;
291
+ retry(): Promise<void>;
292
+ sequence: SequenceView;
293
+ }
294
+ export type ParticipatingSequenceView = {
295
+ phase: "participating";
296
+ mechanism: "queue";
297
+ consumer: QueueSequenceConsumerState;
298
+ state$: ReadableAtom<QueueDisplayState>;
299
+ leave(): Promise<void>;
300
+ } | {
301
+ phase: "participating";
302
+ mechanism: "draw";
303
+ consumer: DrawSequenceConsumerState;
304
+ state$: ReadableAtom<DrawDisplayState>;
305
+ leave(): Promise<void>;
306
+ } | {
307
+ phase: "participating";
308
+ mechanism: "auction";
309
+ consumer: AuctionSequenceConsumerState;
310
+ state$: ReadableAtom<AuctionDisplayState>;
311
+ bid(amount: string): Promise<void>;
312
+ leave(): Promise<void>;
313
+ } | {
314
+ phase: "participating";
315
+ mechanism: "timed_release";
316
+ consumer: TimedReleaseSequenceConsumerState;
317
+ state$: ReadableAtom<TimedReleaseDisplayState>;
318
+ leave(): Promise<void>;
319
+ complete(): Promise<void>;
320
+ } | {
321
+ phase: "participating";
322
+ mechanism: "appointment";
323
+ consumer: AppointmentSequenceConsumerState;
324
+ state$: ReadableAtom<AppointmentDisplayState>;
325
+ cancel(reason?: string): Promise<void>;
326
+ reschedule(newSlotId: string, newLocationId?: string): Promise<void>;
327
+ } | {
328
+ phase: "participating";
329
+ mechanism: "waitlist";
330
+ consumer: WaitlistSequenceConsumerState;
331
+ leave(): Promise<void>;
332
+ };
333
+ export type EnterableSequenceView = {
334
+ phase: "enterable";
335
+ mechanism: Exclude<PrimarySequenceMechanism, "appointment" | "auction">;
336
+ distribution: DistributionSummary;
337
+ consumer: Exclude<ConsumerSequenceState, AppointmentSequenceConsumerState | WaitlistSequenceConsumerState>;
338
+ enter(): Promise<void>;
339
+ } | {
340
+ phase: "enterable";
341
+ mechanism: "auction";
342
+ distribution: DistributionSummary;
343
+ consumer: AuctionSequenceConsumerState;
344
+ bid(amount: string): Promise<void>;
345
+ } | {
346
+ phase: "enterable";
347
+ mechanism: "appointment";
348
+ distribution: DistributionSummary;
349
+ consumer: AppointmentSequenceConsumerState;
350
+ book(slotId: string, locationId?: string): Promise<void>;
351
+ } | {
352
+ phase: "enterable";
353
+ mechanism: "waitlist";
354
+ target: DistributionTarget;
355
+ consumer: WaitlistSequenceConsumerState;
356
+ enter(): Promise<void>;
357
+ };
358
+ export type ScheduledSequenceView = {
359
+ phase: "scheduled";
360
+ mechanism: PrimarySequenceMechanism;
361
+ distribution: DistributionSummary;
362
+ consumer: Exclude<ConsumerSequenceState, WaitlistSequenceConsumerState>;
363
+ startsAt?: string;
364
+ };
365
+ export type SequenceView = {
366
+ phase: "unavailable";
367
+ reason?: string;
368
+ } | ScheduledSequenceView | EnterableSequenceView | ParticipatingSequenceView | {
369
+ phase: "settling";
370
+ mechanism: SettlingSequenceMechanism;
371
+ distribution: DistributionSummary;
372
+ consumer: DrawSequenceConsumerState | AuctionSequenceConsumerState;
373
+ } | {
374
+ phase: "granted";
375
+ mechanism: GrantProducingSequenceMechanism;
376
+ distribution: DistributionSummary;
377
+ consumer: QueueSequenceConsumerState | DrawSequenceConsumerState | AuctionSequenceConsumerState | TimedReleaseSequenceConsumerState;
378
+ grant: AdmissionGrant;
379
+ claim(): AdmissionGrant;
380
+ } | {
381
+ phase: "ended";
382
+ mechanism: SequenceMechanism;
383
+ consumer: ConsumerSequenceState;
384
+ outcome: SequenceOutcome;
385
+ };
386
+ export type JourneyView = ReadyView | RoutingView | GatedView | RoutedView;
387
+ export interface JourneyHandle {
388
+ view$: ReadableAtom<JourneyView>;
389
+ events$: ReadableAtom<JourneyEvent[]>;
390
+ latestEvent$: ReadableAtom<JourneyEvent | null>;
391
+ snapshot$: ReadableAtom<JourneySnapshot>;
392
+ ackEvent(eventId: string): void;
393
+ ackAllEvents(): void;
394
+ destroy(): void;
395
+ }
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Public experience/journey type surface.
3
+ *
4
+ * Mirrors exactly the experience symbols on the root barrel — the runtime
5
+ * `ExperienceManagementModule`/`ExperienceJourney`/error classes from
6
+ * `experience.module`/`journey` are deliberately not re-exported here.
7
+ *
8
+ * Internal routing responses from `ExperienceManagementModule` are deliberately
9
+ * omitted; public consumers route through `JourneyView` and `JourneySnapshot`.
10
+ */
11
+ export type { JourneysModule } from '../types';
12
+ export type { AdmissionGrant, AppointmentConsumerStatus, AuctionConsumerStatus, ConsumerJourneyState, ConsumerSequenceState, DistributionLifecycle, DistributionSummary, DistributionTarget, DistributionType, DrawConsumerStatus, EnterableSequenceView, GatedSnapshot, GatedView, JourneyEvent, JourneyEventAudience, JourneyEventKind, JourneyEventSeverity, JourneyHandle, JourneySnapshot, JourneyStage, JourneyView, ParticipatingSequenceView, Participation, PrimarySequenceMechanism, QueueConsumerStatus, ReadySnapshot, ReadyView, RoutedSnapshot, RoutedView, RoutingGate, RoutingOffer, RoutingSnapshot, RoutingView, SequenceMechanism, SequenceOutcome, SequenceOutcomeType, SequencePhase, SequenceState, SequenceTargetState, SequenceView, ServiceJourneyStage, ServiceJourneyState, TimedReleaseConsumerStatus, WaitlistConsumerStatus, } from './journey.types';
13
+ export type { ConsumerMe, Distribution, DistributionContext, Experience, ExperienceDetails, ExperienceSession, JourneyDistributionType, JourneyParticipationType, Sequence, } from './types';
@@ -0,0 +1 @@
1
+
@@ -0,0 +1,161 @@
1
+ import { ConsumerMeResponse } from '@fanfare-io/fanfare-sdk-contracts/consumer-me';
2
+ import { BrandTheme } from '../theme';
3
+ import { SdkDistributionEntryType, SdkJourneyAdmissionType, SdkJourneyParticipationType } from '../types/distribution-type';
4
+ /**
5
+ * Experience Module Types
6
+ * Orchestrates experience-centric customer journeys
7
+ */
8
+ export interface Experience {
9
+ id: string;
10
+ name: string;
11
+ description?: string;
12
+ imageUrl?: string;
13
+ /** Organization-level currency code (ISO 4217), when available */
14
+ currencyCode?: string;
15
+ createdAt: string;
16
+ updatedAt: string;
17
+ }
18
+ export interface ExperienceDetails extends Experience {
19
+ sequences?: Sequence[];
20
+ metadata?: Record<string, unknown>;
21
+ i18n?: Record<string, Record<string, string>>;
22
+ theme?: BrandTheme;
23
+ }
24
+ export interface ExperienceSession {
25
+ experienceId: string;
26
+ enteredAt: string;
27
+ assignedSequenceId?: string;
28
+ waitlistId?: string;
29
+ currentDistribution?: {
30
+ type: SdkDistributionEntryType;
31
+ id: string;
32
+ status: "upcoming" | "active" | "ended";
33
+ };
34
+ /** Full experience details including theme and i18n, returned from enter endpoint */
35
+ experience?: ExperienceDetails;
36
+ }
37
+ export interface Sequence {
38
+ id: string;
39
+ name: string;
40
+ experienceId: string;
41
+ priority: number;
42
+ color: string;
43
+ requiresAccessCode?: boolean;
44
+ audienceId?: string;
45
+ }
46
+ export type { RoutingGate, RoutingOffer } from './journey.types';
47
+ /**
48
+ * Structured routing result from `findSequence()`.
49
+ *
50
+ * Server bot-risk assessment is validated as part of the routing response contract,
51
+ * but is intentionally not exposed here; gates carry the actionable client state.
52
+ */
53
+ export interface RoutingResult {
54
+ outcome: "routed" | "gated" | "no_access";
55
+ selected?: {
56
+ sequence: Sequence;
57
+ status: "admissible" | "gated";
58
+ gates: import('./journey.types').RoutingGate[];
59
+ capabilityGrant?: string;
60
+ capabilityGrantExpiresAt?: string;
61
+ };
62
+ offers: import('./journey.types').RoutingOffer[];
63
+ }
64
+ export interface SequenceAccessResult {
65
+ sequenceId: string;
66
+ hasAccess: boolean;
67
+ accessReasons: string[];
68
+ deniedReasons: string[];
69
+ }
70
+ export interface Distribution {
71
+ id: string;
72
+ type: SdkDistributionEntryType;
73
+ sequenceId: string;
74
+ status: "scheduled" | "active" | "ended";
75
+ openAt?: string;
76
+ closeAt?: string;
77
+ }
78
+ export interface DistributionContext {
79
+ recentPast?: {
80
+ type: SdkDistributionEntryType;
81
+ id: string;
82
+ endedAt: string;
83
+ result?: "won" | "lost" | "participated";
84
+ };
85
+ active?: {
86
+ type: SdkDistributionEntryType;
87
+ id: string;
88
+ status: "active";
89
+ details: DistributionDetails;
90
+ };
91
+ upcoming?: {
92
+ type: SdkDistributionEntryType;
93
+ id: string;
94
+ startsAt: string;
95
+ waitlistId?: string;
96
+ };
97
+ }
98
+ export interface BaseDistributionDetails {
99
+ id: string;
100
+ type: SdkDistributionEntryType;
101
+ openAt?: string;
102
+ closeAt?: string;
103
+ metadata?: Record<string, unknown>;
104
+ }
105
+ export interface QueueDetails extends BaseDistributionDetails {
106
+ type: "queue";
107
+ estimatedWaitTime?: number;
108
+ queueLength?: number;
109
+ }
110
+ export interface DrawDetails extends BaseDistributionDetails {
111
+ type: "draw";
112
+ drawTime?: string;
113
+ entryDeadline?: string;
114
+ maxEntries?: number;
115
+ }
116
+ export interface AuctionDetails extends BaseDistributionDetails {
117
+ type: "auction";
118
+ startsAt?: string;
119
+ endsAt?: string;
120
+ currentBid?: string;
121
+ reservePrice?: string;
122
+ bidIncrement?: string;
123
+ minNextBid?: string;
124
+ currencyCode?: string;
125
+ }
126
+ export interface AppointmentDetails extends BaseDistributionDetails {
127
+ type: "appointment";
128
+ slotDurationMinutes?: number;
129
+ bookingWindowOpenAt?: string;
130
+ bookingWindowCloseAt?: string;
131
+ timezone?: string;
132
+ locationId?: string;
133
+ totalSlots?: number;
134
+ availableSlots?: number;
135
+ }
136
+ export interface TimedReleaseDetails extends BaseDistributionDetails {
137
+ type: "timed_release";
138
+ openAt?: string;
139
+ closeAt?: string;
140
+ }
141
+ export type DistributionDetails = QueueDetails | DrawDetails | AuctionDetails | AppointmentDetails | TimedReleaseDetails;
142
+ export interface ExperienceModule {
143
+ get(experienceId: string): Promise<ExperienceDetails>;
144
+ enter(experienceId: string): Promise<ExperienceSession>;
145
+ leave(experienceId: string): Promise<void>;
146
+ findSequence(experienceId: string, accessCode?: string): Promise<RoutingResult>;
147
+ validateSequenceAccess(sequenceId: string, accessCode?: string): Promise<SequenceAccessResult>;
148
+ selectSequence(sequenceId: string): Promise<void>;
149
+ getCurrentDistributions(sequenceId: string): Promise<DistributionContext>;
150
+ enterDistribution(distribution: DistributionContext["active"]): Promise<void>;
151
+ getActiveSession(): ExperienceSession | null;
152
+ isInExperience(experienceId: string): boolean;
153
+ getSelectedSequence(): Sequence | null;
154
+ /** Fetch authenticated consumer participations for resume flows */
155
+ getMe(): Promise<ConsumerMe>;
156
+ destroy(): void;
157
+ }
158
+ export type JourneyParticipationType = SdkJourneyParticipationType;
159
+ export type JourneyDistributionType = SdkJourneyAdmissionType;
160
+ export type ConsumerMe = ConsumerMeResponse;
161
+ export type ResumeJourneysResult = string[];