@parag.more.withsurface.com/forms-sdk 0.1.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 (177) hide show
  1. package/README.md +63 -0
  2. package/dist/index.cjs +2737 -0
  3. package/dist/index.cjs.map +7 -0
  4. package/dist/index.mjs +2714 -0
  5. package/dist/index.mjs.map +7 -0
  6. package/dist/react/index.cjs +44 -0
  7. package/dist/react/index.cjs.map +7 -0
  8. package/dist/react/index.mjs +21 -0
  9. package/dist/react/index.mjs.map +7 -0
  10. package/dist/surface-forms-sdk.min.js +2 -0
  11. package/dist/surface-forms-sdk.min.js.map +7 -0
  12. package/dist/types/bind/bindForm.d.ts +43 -0
  13. package/dist/types/bind/bindForm.d.ts.map +1 -0
  14. package/dist/types/bind/bindForm.test.d.ts +2 -0
  15. package/dist/types/bind/bindForm.test.d.ts.map +1 -0
  16. package/dist/types/bind/bookingWidget.d.ts +35 -0
  17. package/dist/types/bind/bookingWidget.d.ts.map +1 -0
  18. package/dist/types/bind/bookingWidget.test.d.ts +2 -0
  19. package/dist/types/bind/bookingWidget.test.d.ts.map +1 -0
  20. package/dist/types/core/client/emailValidation.d.ts +23 -0
  21. package/dist/types/core/client/emailValidation.d.ts.map +1 -0
  22. package/dist/types/core/client/emailValidation.test.d.ts +2 -0
  23. package/dist/types/core/client/emailValidation.test.d.ts.map +1 -0
  24. package/dist/types/core/client/responses.d.ts +35 -0
  25. package/dist/types/core/client/responses.d.ts.map +1 -0
  26. package/dist/types/core/client/responses.test.d.ts +2 -0
  27. package/dist/types/core/client/responses.test.d.ts.map +1 -0
  28. package/dist/types/core/client/runtimeConfig.contract.test.d.ts +2 -0
  29. package/dist/types/core/client/runtimeConfig.contract.test.d.ts.map +1 -0
  30. package/dist/types/core/client/runtimeConfig.d.ts +72 -0
  31. package/dist/types/core/client/runtimeConfig.d.ts.map +1 -0
  32. package/dist/types/core/client/runtimeConfig.test.d.ts +2 -0
  33. package/dist/types/core/client/runtimeConfig.test.d.ts.map +1 -0
  34. package/dist/types/core/client/scheduler.contract.test.d.ts +2 -0
  35. package/dist/types/core/client/scheduler.contract.test.d.ts.map +1 -0
  36. package/dist/types/core/client/scheduler.d.ts +121 -0
  37. package/dist/types/core/client/scheduler.d.ts.map +1 -0
  38. package/dist/types/core/client/scheduler.test.d.ts +2 -0
  39. package/dist/types/core/client/scheduler.test.d.ts.map +1 -0
  40. package/dist/types/core/client/transport.d.ts +56 -0
  41. package/dist/types/core/client/transport.d.ts.map +1 -0
  42. package/dist/types/core/client/transport.test.d.ts +2 -0
  43. package/dist/types/core/client/transport.test.d.ts.map +1 -0
  44. package/dist/types/core/engine/answerAudit.d.ts +21 -0
  45. package/dist/types/core/engine/answerAudit.d.ts.map +1 -0
  46. package/dist/types/core/engine/answerAudit.test.d.ts +2 -0
  47. package/dist/types/core/engine/answerAudit.test.d.ts.map +1 -0
  48. package/dist/types/core/engine/answerStates.contract.test.d.ts +2 -0
  49. package/dist/types/core/engine/answerStates.contract.test.d.ts.map +1 -0
  50. package/dist/types/core/engine/answerStates.d.ts +92 -0
  51. package/dist/types/core/engine/answerStates.d.ts.map +1 -0
  52. package/dist/types/core/engine/formEngine.d.ts +145 -0
  53. package/dist/types/core/engine/formEngine.d.ts.map +1 -0
  54. package/dist/types/core/engine/formEngine.test.d.ts +2 -0
  55. package/dist/types/core/engine/formEngine.test.d.ts.map +1 -0
  56. package/dist/types/core/engine/redirect.d.ts +36 -0
  57. package/dist/types/core/engine/redirect.d.ts.map +1 -0
  58. package/dist/types/core/engine/redirect.test.d.ts +2 -0
  59. package/dist/types/core/engine/redirect.test.d.ts.map +1 -0
  60. package/dist/types/core/engine/responsePayload.contract.test.d.ts +2 -0
  61. package/dist/types/core/engine/responsePayload.contract.test.d.ts.map +1 -0
  62. package/dist/types/core/engine/responsePayload.d.ts +74 -0
  63. package/dist/types/core/engine/responsePayload.d.ts.map +1 -0
  64. package/dist/types/core/engine/responsePayload.test.d.ts +2 -0
  65. package/dist/types/core/engine/responsePayload.test.d.ts.map +1 -0
  66. package/dist/types/core/engine/urlData.contract.test.d.ts +2 -0
  67. package/dist/types/core/engine/urlData.contract.test.d.ts.map +1 -0
  68. package/dist/types/core/engine/urlData.d.ts +30 -0
  69. package/dist/types/core/engine/urlData.d.ts.map +1 -0
  70. package/dist/types/core/engine/urlData.test.d.ts +2 -0
  71. package/dist/types/core/engine/urlData.test.d.ts.map +1 -0
  72. package/dist/types/core/engine/urlPrefill.d.ts +21 -0
  73. package/dist/types/core/engine/urlPrefill.d.ts.map +1 -0
  74. package/dist/types/core/engine/urlPrefill.test.d.ts +2 -0
  75. package/dist/types/core/engine/urlPrefill.test.d.ts.map +1 -0
  76. package/dist/types/core/events/dropoffDetection.d.ts +21 -0
  77. package/dist/types/core/events/dropoffDetection.d.ts.map +1 -0
  78. package/dist/types/core/events/dropoffDetection.test.d.ts +2 -0
  79. package/dist/types/core/events/dropoffDetection.test.d.ts.map +1 -0
  80. package/dist/types/core/events/emitter.d.ts +23 -0
  81. package/dist/types/core/events/emitter.d.ts.map +1 -0
  82. package/dist/types/core/events/emitter.test.d.ts +2 -0
  83. package/dist/types/core/events/emitter.test.d.ts.map +1 -0
  84. package/dist/types/core/events/formJourneyTracker.contract.test.d.ts +2 -0
  85. package/dist/types/core/events/formJourneyTracker.contract.test.d.ts.map +1 -0
  86. package/dist/types/core/events/formJourneyTracker.d.ts +69 -0
  87. package/dist/types/core/events/formJourneyTracker.d.ts.map +1 -0
  88. package/dist/types/core/events/formJourneyTracker.test.d.ts +2 -0
  89. package/dist/types/core/events/formJourneyTracker.test.d.ts.map +1 -0
  90. package/dist/types/core/events/pushEvents.contract.test.d.ts +2 -0
  91. package/dist/types/core/events/pushEvents.contract.test.d.ts.map +1 -0
  92. package/dist/types/core/events/pushEvents.d.ts +62 -0
  93. package/dist/types/core/events/pushEvents.d.ts.map +1 -0
  94. package/dist/types/core/events/pushEvents.test.d.ts +2 -0
  95. package/dist/types/core/events/pushEvents.test.d.ts.map +1 -0
  96. package/dist/types/core/events/startedDetection.d.ts +11 -0
  97. package/dist/types/core/events/startedDetection.d.ts.map +1 -0
  98. package/dist/types/core/events/startedDetection.test.d.ts +2 -0
  99. package/dist/types/core/events/startedDetection.test.d.ts.map +1 -0
  100. package/dist/types/core/events/viewDetection.d.ts +15 -0
  101. package/dist/types/core/events/viewDetection.d.ts.map +1 -0
  102. package/dist/types/core/events/viewDetection.test.d.ts +2 -0
  103. package/dist/types/core/events/viewDetection.test.d.ts.map +1 -0
  104. package/dist/types/core/identity/browserFingerprint.d.ts +40 -0
  105. package/dist/types/core/identity/browserFingerprint.d.ts.map +1 -0
  106. package/dist/types/core/identity/browserFingerprint.test.d.ts +2 -0
  107. package/dist/types/core/identity/browserFingerprint.test.d.ts.map +1 -0
  108. package/dist/types/core/identity/ensureIdentified.d.ts +27 -0
  109. package/dist/types/core/identity/ensureIdentified.d.ts.map +1 -0
  110. package/dist/types/core/identity/ensureIdentified.test.d.ts +2 -0
  111. package/dist/types/core/identity/ensureIdentified.test.d.ts.map +1 -0
  112. package/dist/types/core/identity/identify.contract.test.d.ts +2 -0
  113. package/dist/types/core/identity/identify.contract.test.d.ts.map +1 -0
  114. package/dist/types/core/identity/identify.d.ts +48 -0
  115. package/dist/types/core/identity/identify.d.ts.map +1 -0
  116. package/dist/types/core/identity/identify.test.d.ts +2 -0
  117. package/dist/types/core/identity/identify.test.d.ts.map +1 -0
  118. package/dist/types/core/identity/journey.contract.test.d.ts +2 -0
  119. package/dist/types/core/identity/journey.contract.test.d.ts.map +1 -0
  120. package/dist/types/core/identity/journey.d.ts +28 -0
  121. package/dist/types/core/identity/journey.d.ts.map +1 -0
  122. package/dist/types/core/identity/journey.test.d.ts +2 -0
  123. package/dist/types/core/identity/journey.test.d.ts.map +1 -0
  124. package/dist/types/core/identity/journey.testStubs.d.ts +5 -0
  125. package/dist/types/core/identity/journey.testStubs.d.ts.map +1 -0
  126. package/dist/types/core/identity/leadDataCache.d.ts +27 -0
  127. package/dist/types/core/identity/leadDataCache.d.ts.map +1 -0
  128. package/dist/types/core/identity/leadDataCache.test.d.ts +2 -0
  129. package/dist/types/core/identity/leadDataCache.test.d.ts.map +1 -0
  130. package/dist/types/enrichment/attachEnrichment.d.ts +35 -0
  131. package/dist/types/enrichment/attachEnrichment.d.ts.map +1 -0
  132. package/dist/types/enrichment/attachEnrichment.test.d.ts +2 -0
  133. package/dist/types/enrichment/attachEnrichment.test.d.ts.map +1 -0
  134. package/dist/types/index.d.ts +28 -0
  135. package/dist/types/index.d.ts.map +1 -0
  136. package/dist/types/react/index.d.ts +2 -0
  137. package/dist/types/react/index.d.ts.map +1 -0
  138. package/dist/types/react/ssr.test.d.ts +2 -0
  139. package/dist/types/react/ssr.test.d.ts.map +1 -0
  140. package/dist/types/react/useSurfaceForm.d.ts +25 -0
  141. package/dist/types/react/useSurfaceForm.d.ts.map +1 -0
  142. package/dist/types/react/useSurfaceForm.test.d.ts +2 -0
  143. package/dist/types/react/useSurfaceForm.test.d.ts.map +1 -0
  144. package/dist/types/surfaceForms.d.ts +120 -0
  145. package/dist/types/surfaceForms.d.ts.map +1 -0
  146. package/dist/types/surfaceForms.test.d.ts +2 -0
  147. package/dist/types/surfaceForms.test.d.ts.map +1 -0
  148. package/dist/types/tracking/attachTracking.d.ts +35 -0
  149. package/dist/types/tracking/attachTracking.d.ts.map +1 -0
  150. package/dist/types/tracking/attachTracking.test.d.ts +2 -0
  151. package/dist/types/tracking/attachTracking.test.d.ts.map +1 -0
  152. package/dist/types/tracking/conversionRules.contract.test.d.ts +2 -0
  153. package/dist/types/tracking/conversionRules.contract.test.d.ts.map +1 -0
  154. package/dist/types/tracking/conversionRules.d.ts +87 -0
  155. package/dist/types/tracking/conversionRules.d.ts.map +1 -0
  156. package/dist/types/tracking/conversionRules.test.d.ts +2 -0
  157. package/dist/types/tracking/conversionRules.test.d.ts.map +1 -0
  158. package/dist/types/tracking/vendors.d.ts +46 -0
  159. package/dist/types/tracking/vendors.d.ts.map +1 -0
  160. package/dist/types/tracking/vendors.test.d.ts +2 -0
  161. package/dist/types/tracking/vendors.test.d.ts.map +1 -0
  162. package/dist/types/validation/attachEmailValidation.d.ts +8 -0
  163. package/dist/types/validation/attachEmailValidation.d.ts.map +1 -0
  164. package/dist/types/validation/attachEmailValidation.test.d.ts +2 -0
  165. package/dist/types/validation/attachEmailValidation.test.d.ts.map +1 -0
  166. package/docs/api.md +310 -0
  167. package/docs/reference/binding.md +116 -0
  168. package/docs/reference/clients.md +212 -0
  169. package/docs/reference/engine.md +193 -0
  170. package/docs/reference/events.md +93 -0
  171. package/docs/reference/identity.md +116 -0
  172. package/llms.txt +317 -0
  173. package/package.json +25 -0
  174. package/skills/surface-forms-sdk/SKILL.md +153 -0
  175. package/skills/surface-forms-sdk/debugging.md +64 -0
  176. package/skills/surface-forms-sdk/editing.md +67 -0
  177. package/skills/surface-forms-sdk/patterns.md +222 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pushEvents.d.ts","sourceRoot":"","sources":["../../../../src/core/events/pushEvents.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAErD;;;;;;;;;;;;;GAaG;AAEH,MAAM,MAAM,gBAAgB,GACxB,aAAa,GACb,cAAc,GACd,gBAAgB,GAChB,kBAAkB,GAClB,qBAAqB,GACrB,mBAAmB,GACnB,yBAAyB,GACzB,6BAA6B,GAC7B,2BAA2B,GAC3B,kBAAkB,CAAC;AAEvB,MAAM,MAAM,sBAAsB,GAAG,MAAM,GAAG,WAAW,GAAG,UAAU,CAAC;AAEvE,MAAM,MAAM,iBAAiB,GAAG;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,OAAO,CAAA;CAAE,CAAC;AAEhE,MAAM,MAAM,gBAAgB,GAAG;IAC7B,IAAI,EAAE,gBAAgB,CAAC;IACvB,UAAU,EAAE,sBAAsB,CAAC;IACnC,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,aAAa,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,UAAU,CAAC,EAAE,iBAAiB,EAAE,CAAC;IACjC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB,CAAC;AAEF,0EAA0E;AAC1E,MAAM,MAAM,cAAc,GAAG;IAC3B,MAAM,EAAE;QACN,gBAAgB,GAAG;YAAE,IAAI,EAAE,qBAAqB,CAAC;YAAC,UAAU,EAAE,WAAW,CAAC;YAAC,MAAM,EAAE,MAAM,CAAA;SAAE;QAC3F,gBAAgB,GAAG;YAAE,IAAI,EAAE,kBAAkB,CAAC;YAAC,UAAU,EAAE,WAAW,CAAC;YAAC,MAAM,EAAE,MAAM,CAAA;SAAE;KACzF,CAAC;CACH,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG,gBAAgB,GAAG,cAAc,CAAC;AAgBjE,eAAO,MAAM,6BAA6B,0EAMvC;IACD,SAAS,EAAE,MAAM,GAAG,SAAS,CAAC;IAC9B,MAAM,EAAE,MAAM,CAAC;IACf,aAAa,EAAE,MAAM,CAAC;IACtB,UAAU,EAAE,MAAM,CAAC;IACnB,kBAAkB,EAAE,MAAM,CAAC;CAC5B,KAAG,cAmBF,CAAC;AAEH,MAAM,MAAM,eAAe,GAAG;IAC5B,IAAI,EAAE,CAAC,OAAO,EAAE,gBAAgB,KAAK,IAAI,CAAC;CAC3C,CAAC;AAEF,eAAO,MAAM,qBAAqB,4BAG/B;IACD,SAAS,EAAE,SAAS,CAAC;IACrB,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB,KAAG,eAWF,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=pushEvents.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pushEvents.test.d.ts","sourceRoot":"","sources":["../../../../src/core/events/pushEvents.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,11 @@
1
+ /**
2
+ * `form_started` detection (forms-sdk-plan.md row 22): native fires it on the
3
+ * first deep-inequality between the current answer state and the snapshot
4
+ * taken at mount, once per form instance (`DualPaneAdjustableForm`'s
5
+ * `startedForm` ref + lodash `isEqual`). The detector captures the snapshot at
6
+ * creation; `check(current)` returns true exactly once, on the first
7
+ * divergence. The local deep-equal covers the answer-state shape (plain
8
+ * objects, arrays, primitives) — key order insensitive, like lodash.
9
+ */
10
+ export declare const createStartedDetector: <T>(initial: T) => ((current: T) => boolean);
11
+ //# sourceMappingURL=startedDetection.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"startedDetection.d.ts","sourceRoot":"","sources":["../../../../src/core/events/startedDetection.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,eAAO,MAAM,qBAAqB,GAAI,CAAC,WAAW,CAAC,KAAG,CAAC,CAAC,OAAO,EAAE,CAAC,KAAK,OAAO,CAS7E,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=startedDetection.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"startedDetection.test.d.ts","sourceRoot":"","sources":["../../../../src/core/events/startedDetection.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,15 @@
1
+ /**
2
+ * `form_viewed` detection (forms-sdk-plan.md row 21): an IntersectionObserver
3
+ * on the bound form root, firing the callback exactly once per observer —
4
+ * form-render's `useDetectFormView` semantics with its React scaffolding
5
+ * removed. The once-guard replaces native's belt-and-braces 1 s throttle:
6
+ * with a single fire per instance there is nothing left to throttle. The
7
+ * caller (bind layer / engine) emits `form_viewed` + first-step
8
+ * `form_step_viewed`, exactly what native's throttled callback did.
9
+ *
10
+ * If `IntersectionObserver` is unavailable the callback fires immediately —
11
+ * losing view analytics entirely is worse than counting a below-fold mount,
12
+ * and native never handled this case (it would throw).
13
+ */
14
+ export declare const observeFormView: (element: Element, onViewed: () => void) => (() => void);
15
+ //# sourceMappingURL=viewDetection.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"viewDetection.d.ts","sourceRoot":"","sources":["../../../../src/core/events/viewDetection.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,eAAe,YAAa,OAAO,YAAY,MAAM,IAAI,KAAG,CAAC,MAAM,IAAI,CAgBnF,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=viewDetection.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"viewDetection.test.d.ts","sourceRoot":"","sources":["../../../../src/core/events/viewDetection.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,40 @@
1
+ /**
2
+ * Canonical browser-fingerprint implementation for Surface lead identity.
3
+ *
4
+ * The lead-identity pipeline keys on the SHA-256 of `JSON.stringify` over the
5
+ * collected fields, so the object's insertion order, value shapes, and falsy
6
+ * fallbacks (`||`, not `??`) ARE the wire contract: any deviation produces a
7
+ * different hash and splits one visitor into two leads. Do not reorder fields,
8
+ * rename keys, or change fallback behavior here without a coordinated
9
+ * migration.
10
+ *
11
+ * This module supersedes the two byte-identical copies it was lifted from —
12
+ * `packages/form-render/src/lib/client/leads/browserFingerprint.ts` and the
13
+ * public tag's `src/lead/fingerprint.ts` (trysurface/scripts) — which consume
14
+ * it over time (forms-sdk-plan.md, parity row 9). The identity test in this
15
+ * directory pins hash equality against the form-render copy.
16
+ */
17
+ export type Fingerprint = {
18
+ deviceType: "Mobile" | "Desktop";
19
+ screen: {
20
+ width: number;
21
+ height: number;
22
+ colorDepth: number;
23
+ };
24
+ userAgent: string;
25
+ browser: Array<{
26
+ brand: string;
27
+ version: string;
28
+ }>;
29
+ os: string;
30
+ language: string;
31
+ /** Absent (never null/empty) when `navigator.plugins` is null. */
32
+ plugins?: string[];
33
+ timezone: string;
34
+ environmentId: string;
35
+ /** SHA-256 hex of the serialized fields above. */
36
+ id: string;
37
+ };
38
+ export declare function getHash(input: string): Promise<string>;
39
+ export declare const getBrowserFingerprint: (environmentId: string) => Promise<Fingerprint>;
40
+ //# sourceMappingURL=browserFingerprint.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"browserFingerprint.d.ts","sourceRoot":"","sources":["../../../../src/core/identity/browserFingerprint.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAQH,MAAM,MAAM,WAAW,GAAG;IACxB,UAAU,EAAE,QAAQ,GAAG,SAAS,CAAC;IACjC,MAAM,EAAE;QACN,KAAK,EAAE,MAAM,CAAC;QACd,MAAM,EAAE,MAAM,CAAC;QACf,UAAU,EAAE,MAAM,CAAC;KACpB,CAAC;IACF,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,KAAK,CAAC;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACnD,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,EAAE,MAAM,CAAC;IACjB,kEAAkE;IAClE,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,aAAa,EAAE,MAAM,CAAC;IACtB,kDAAkD;IAClD,EAAE,EAAE,MAAM,CAAC;CACZ,CAAC;AAEF,wBAAsB,OAAO,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAM5D;AAED,eAAO,MAAM,qBAAqB,kBAAyB,MAAM,KAAG,OAAO,CAAC,WAAW,CAwBtF,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=browserFingerprint.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"browserFingerprint.test.d.ts","sourceRoot":"","sources":["../../../../src/core/identity/browserFingerprint.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,27 @@
1
+ import type { Transport } from "../client/transport";
2
+ import { type LeadSource } from "./identify";
3
+ import { type CachedLeadData } from "./leadDataCache";
4
+ /**
5
+ * The boot-sequence identity step (forms-sdk-plan.md §2.2): resolve the
6
+ * visitor before any response write, since attribute sync silently no-ops for
7
+ * responses whose lead was never identified (row 60). Mirrors the tag's
8
+ * `identifyLead` flow: a fresh cache entry with a session and fingerprint
9
+ * skips the network entirely; otherwise compute the fingerprint, carry any
10
+ * cached leadId/session forward so the server can preserve identity, and
11
+ * cache the result under the shared tag key.
12
+ *
13
+ * `preview: true` blocks the identify call outright — the preview contract
14
+ * (§2.2) is that drafts never create leads. Concurrent calls (multi-form
15
+ * pages) may race one identify each; that is safe — the server find-or-creates
16
+ * by fingerprint, so both resolve to the same lead — and avoids the tag's
17
+ * module-level in-flight flag, which the SDK's instance-scoped rule forbids.
18
+ */
19
+ export declare const ensureIdentified: ({ transport, environmentId, formId, pageUrl, source, preview, }: {
20
+ transport: Transport;
21
+ environmentId: string;
22
+ formId?: string;
23
+ pageUrl?: string;
24
+ source?: LeadSource;
25
+ preview?: boolean;
26
+ }) => Promise<CachedLeadData | null>;
27
+ //# sourceMappingURL=ensureIdentified.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ensureIdentified.d.ts","sourceRoot":"","sources":["../../../../src/core/identity/ensureIdentified.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAErD,OAAO,EAAsC,KAAK,UAAU,EAAE,MAAM,YAAY,CAAC;AACjF,OAAO,EAA+B,KAAK,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAEnF;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,gBAAgB,oEAO1B;IACD,SAAS,EAAE,SAAS,CAAC;IACrB,aAAa,EAAE,MAAM,CAAC;IACtB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,UAAU,CAAC;IACpB,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB,KAAG,OAAO,CAAC,cAAc,GAAG,IAAI,CAiChC,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=ensureIdentified.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ensureIdentified.test.d.ts","sourceRoot":"","sources":["../../../../src/core/identity/ensureIdentified.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=identify.contract.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"identify.contract.test.d.ts","sourceRoot":"","sources":["../../../../src/core/identity/identify.contract.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,48 @@
1
+ import type { Transport } from "../client/transport";
2
+ /**
3
+ * Wrapper for `POST /api/v1/lead/identify` (forms-sdk-plan.md row 10),
4
+ * mirroring form-render's `identifyLeadForFormRequest`: same payload fields,
5
+ * same URL normalization (trailing slashes stripped from href and pathname),
6
+ * same keepalive delivery, same `data.data` response unwrap, null on any
7
+ * failure. The wire types are structural mirrors of `ZLeadIdentifyPayload`
8
+ * (`@surface/types/v1/lead/app/types.ts`) — local because the SDK ships with
9
+ * zero runtime dependencies; the contract test validates them against the
10
+ * real schema.
11
+ *
12
+ * `source` defaults to `"sdkForm"` — the dedicated SDK value (Decisions #8),
13
+ * so SDK-originated leads stay distinguishable from the native runtime's
14
+ * `"surfaceForm"` in the leads hub and analytics.
15
+ */
16
+ export type LeadSource = "surfaceForm" | "htmlForm" | "websiteDeAnon" | "webhook" | "website" | "imported" | "scheduler" | "linkedin" | "sdkForm";
17
+ export type IdentifyPayload = {
18
+ environmentId: string;
19
+ source: LeadSource;
20
+ sourceURL: string;
21
+ sourceURLDomain: string;
22
+ sourceURLPath: string;
23
+ sourceUrlSearchParams: string;
24
+ leadId?: string | null;
25
+ formId?: string;
26
+ fingerprint?: string;
27
+ sessionIdFromParams?: string | null;
28
+ referrer?: string | null;
29
+ };
30
+ export type IdentifyResult = {
31
+ leadId: string;
32
+ sessionId: string;
33
+ existing: boolean;
34
+ leadHasExistingBookingAttr: boolean;
35
+ leadHasExistingEmailAttr: boolean;
36
+ };
37
+ export declare const buildIdentifyPayload: ({ environmentId, fingerprintId, pageUrl, source, formId, leadId, sessionIdFromParams, referrer, }: {
38
+ environmentId: string;
39
+ fingerprintId: string;
40
+ pageUrl: string;
41
+ source?: LeadSource;
42
+ formId?: string;
43
+ leadId?: string | null;
44
+ sessionIdFromParams?: string | null;
45
+ referrer?: string | null;
46
+ }) => IdentifyPayload;
47
+ export declare const identifyLead: (transport: Transport, payload: IdentifyPayload) => Promise<IdentifyResult | null>;
48
+ //# sourceMappingURL=identify.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"identify.d.ts","sourceRoot":"","sources":["../../../../src/core/identity/identify.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAErD;;;;;;;;;;;;;GAaG;AAEH,MAAM,MAAM,UAAU,GAClB,aAAa,GACb,UAAU,GACV,eAAe,GACf,SAAS,GACT,SAAS,GACT,UAAU,GACV,WAAW,GACX,UAAU,GACV,SAAS,CAAC;AAEd,MAAM,MAAM,eAAe,GAAG;IAC5B,aAAa,EAAE,MAAM,CAAC;IACtB,MAAM,EAAE,UAAU,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,eAAe,EAAE,MAAM,CAAC;IACxB,aAAa,EAAE,MAAM,CAAC;IACtB,qBAAqB,EAAE,MAAM,CAAC;IAC9B,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,mBAAmB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACpC,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC1B,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG;IAC3B,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,OAAO,CAAC;IAClB,0BAA0B,EAAE,OAAO,CAAC;IACpC,wBAAwB,EAAE,OAAO,CAAC;CACnC,CAAC;AAIF,eAAO,MAAM,oBAAoB,sGAS9B;IACD,aAAa,EAAE,MAAM,CAAC;IACtB,aAAa,EAAE,MAAM,CAAC;IACtB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,UAAU,CAAC;IACpB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,mBAAmB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACpC,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC1B,KAAG,eAeH,CAAC;AAIF,eAAO,MAAM,YAAY,cACZ,SAAS,WACX,eAAe,KACvB,OAAO,CAAC,cAAc,GAAG,IAAI,CAe/B,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=identify.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"identify.test.d.ts","sourceRoot":"","sources":["../../../../src/core/identity/identify.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=journey.contract.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"journey.contract.test.d.ts","sourceRoot":"","sources":["../../../../src/core/identity/journey.contract.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,28 @@
1
+ import type { Transport } from "../client/transport";
2
+ /**
3
+ * Opt-in user-journey page-view tracking (forms-sdk-plan.md row 16), the
4
+ * SDK's `journey: true` module. Mirrors the public tag's implementation
5
+ * (trysurface/scripts `src/store/{user-journey,journey-cookies}.ts`, verified
6
+ * at HEAD): same cookies (`surface_journey_id`, 60 d, eTLD+1 domain;
7
+ * `surface_recent_visit`, 1 d), same duplicate-URL skip, same delivery split —
8
+ * beacon when the journey id is already known (nothing to read back), fetch
9
+ * when it isn't so the server-issued id can be captured — and the same
10
+ * history-patching SPA route detection.
11
+ *
12
+ * Journey→response stitching stays server-side (UTM backfill on response
13
+ * create); the client's only job is delivering page views under a stable id.
14
+ */
15
+ export declare const JOURNEY_COOKIE_NAME = "surface_journey_id";
16
+ export declare const RECENT_VISIT_COOKIE_NAME = "surface_recent_visit";
17
+ export type JourneyTracker = {
18
+ trackPageView: (url?: string) => Promise<void>;
19
+ /** Patches history + popstate; returns a teardown restoring the originals. */
20
+ observeRouteChanges: () => () => void;
21
+ /** Deletes both journey cookies — the native clear-on-first-step-completion hook. */
22
+ clear: () => void;
23
+ };
24
+ export declare const createJourneyTracker: ({ transport, environmentId, }: {
25
+ transport: Transport;
26
+ environmentId: string;
27
+ }) => JourneyTracker;
28
+ //# sourceMappingURL=journey.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"journey.d.ts","sourceRoot":"","sources":["../../../../src/core/identity/journey.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAGrD;;;;;;;;;;;;GAYG;AAEH,eAAO,MAAM,mBAAmB,uBAAuB,CAAC;AACxD,eAAO,MAAM,wBAAwB,yBAAyB,CAAC;AAqD/D,MAAM,MAAM,cAAc,GAAG;IAC3B,aAAa,EAAE,CAAC,GAAG,CAAC,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAC/C,8EAA8E;IAC9E,mBAAmB,EAAE,MAAM,MAAM,IAAI,CAAC;IACtC,qFAAqF;IACrF,KAAK,EAAE,MAAM,IAAI,CAAC;CACnB,CAAC;AAEF,eAAO,MAAM,oBAAoB,kCAG9B;IACD,SAAS,EAAE,SAAS,CAAC;IACrB,aAAa,EAAE,MAAM,CAAC;CACvB,KAAG,cA6FH,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=journey.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"journey.test.d.ts","sourceRoot":"","sources":["../../../../src/core/identity/journey.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,5 @@
1
+ /** Minimal DOM stub for journey tests: cookie jar honoring max-age deletion, location, referrer. */
2
+ export declare const stubJourneyDom: ({ href }?: {
3
+ href?: string;
4
+ }) => Map<string, string>;
5
+ //# sourceMappingURL=journey.testStubs.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"journey.testStubs.d.ts","sourceRoot":"","sources":["../../../../src/core/identity/journey.testStubs.ts"],"names":[],"mappings":"AAEA,oGAAoG;AACpG,eAAO,MAAM,cAAc,cAA+C;IAAE,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE,wBAqB1F,CAAC"}
@@ -0,0 +1,27 @@
1
+ /**
2
+ * TTL-stamped lead-identity cache (forms-sdk-plan.md row 11), byte-compatible
3
+ * with the public tag's `surfaceLeadData` localStorage entry — same key, same
4
+ * shape, same 10-minute TTL, same remove-on-expiry read semantics
5
+ * (trysurface/scripts `src/lead/identify.ts`).
6
+ *
7
+ * Sharing the tag's key IS the interop rule (plan §4.1): on a page where the
8
+ * tag is also installed, the SDK reads the identity the tag already resolved
9
+ * and skips its own identify — and vice versa — so both agree on the visitor
10
+ * without any cross-component protocol.
11
+ *
12
+ * Every access is guarded: no localStorage (SSR) reads as a cache miss, and
13
+ * storage exceptions (Safari private mode, quota) are swallowed — cache loss
14
+ * only costs an extra identify round-trip.
15
+ */
16
+ export declare const LEAD_DATA_STORAGE_KEY = "surfaceLeadData";
17
+ export declare const LEAD_DATA_TTL_MS: number;
18
+ export type CachedLeadData = {
19
+ leadId: string | null;
20
+ leadSessionId: string | null;
21
+ fingerprint: string;
22
+ landingPageUrl?: string;
23
+ expiry?: number;
24
+ };
25
+ export declare const readLeadData: () => CachedLeadData | null;
26
+ export declare const writeLeadData: (data: Omit<CachedLeadData, "expiry">) => void;
27
+ //# sourceMappingURL=leadDataCache.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"leadDataCache.d.ts","sourceRoot":"","sources":["../../../../src/core/identity/leadDataCache.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,eAAO,MAAM,qBAAqB,oBAAoB,CAAC;AACvD,eAAO,MAAM,gBAAgB,QAAiB,CAAC;AAE/C,MAAM,MAAM,cAAc,GAAG;IAC3B,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,WAAW,EAAE,MAAM,CAAC;IACpB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,eAAO,MAAM,YAAY,QAAO,cAAc,GAAG,IAoBhD,CAAC;AAEF,eAAO,MAAM,aAAa,SAAU,IAAI,CAAC,cAAc,EAAE,QAAQ,CAAC,KAAG,IAUpE,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=leadDataCache.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"leadDataCache.test.d.ts","sourceRoot":"","sources":["../../../../src/core/identity/leadDataCache.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,35 @@
1
+ import type { Transport } from "../core/client/transport";
2
+ import type { FormEngine } from "../core/engine/formEngine";
3
+ /**
4
+ * Real-time identity enrichment for SDK forms (field-run finding 4.10): the
5
+ * native renderer fires `/api/v1/services/enrichment/realtime` on blur of the
6
+ * IdentityInfo `enrichmentSourceField` (or `websiteUrl`, or EmailForm's email)
7
+ * and stores the result as the `selfServeEnrichment` APOLLO_EMAIL_ENRICHMENT
8
+ * external state — which the response payload forwards as `enrichedFields`
9
+ * and which drives field autofill. The SDK has no blur moment (headless
10
+ * callers have no DOM at all), so the trigger is a debounced answer-watch: a
11
+ * candidate value that is a valid email/domain and has been stable for
12
+ * `DEBOUNCE_MS` fires once (deduped per value, native semantics); completing
13
+ * a step flushes the pending debounce so a type-then-advance never loses the
14
+ * window. The request is never awaited — submission must not block on the
15
+ * vendor API — so a result can resolve after the finishing write; the engine
16
+ * persists it anyway by amending the stored response on setExternalState.
17
+ * Results merge existing-keys-win, exactly like native's G2 rule — a later
18
+ * trigger only fills gaps.
19
+ *
20
+ * The provider key never reaches the page: the endpoint resolves it
21
+ * server-side and is rate-limited per-IP and per-form.
22
+ */
23
+ export type EnrichmentSource = {
24
+ questionId: string;
25
+ fieldNames: string[];
26
+ };
27
+ export declare const ENRICHMENT_STATE_ID = "selfServeEnrichment";
28
+ export type AttachEnrichmentOptions = {
29
+ engine: FormEngine;
30
+ transport: Transport;
31
+ formId: string;
32
+ sources: EnrichmentSource[];
33
+ };
34
+ export declare const attachEnrichment: ({ engine, transport, formId, sources, }: AttachEnrichmentOptions) => (() => void);
35
+ //# sourceMappingURL=attachEnrichment.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"attachEnrichment.d.ts","sourceRoot":"","sources":["../../../src/enrichment/attachEnrichment.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAE5D;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,MAAM,MAAM,gBAAgB,GAAG;IAAE,UAAU,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,MAAM,EAAE,CAAA;CAAE,CAAC;AAG5E,eAAO,MAAM,mBAAmB,wBAAwB,CAAC;AAazD,MAAM,MAAM,uBAAuB,GAAG;IACpC,MAAM,EAAE,UAAU,CAAC;IACnB,SAAS,EAAE,SAAS,CAAC;IACrB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,gBAAgB,EAAE,CAAC;CAC7B,CAAC;AAEF,eAAO,MAAM,gBAAgB,4CAK1B,uBAAuB,KAAG,CAAC,MAAM,IAAI,CAsFvC,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=attachEnrichment.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"attachEnrichment.test.d.ts","sourceRoot":"","sources":["../../../src/enrichment/attachEnrichment.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,28 @@
1
+ export { bindForm, type BindFormOptions } from "./bind/bindForm";
2
+ export { mountBookingWidget, type BookingWidgetOptions } from "./bind/bookingWidget";
3
+ export { createEmailValidator, type CreateEmailValidatorOptions, type EmailValidationResult, type EmailValidator, } from "./core/client/emailValidation";
4
+ export { submitResponse, updateResponse, type CreateResponseResult } from "./core/client/responses";
5
+ export { enrichmentSourcesOf, fetchRuntimeConfig, hasEnabledEnrichmentProvider, statefulQuestionIdsOf, statefulQuestionsOf, stepsOf, type RuntimeConfig, } from "./core/client/runtimeConfig";
6
+ export { createSchedulerClient, toSchedulerAnswerState, type AvailabilitySummary, type Booking, type BookingAttendee, type SchedulerClient, type TimeSlot, } from "./core/client/scheduler";
7
+ export { DEFAULT_API_BASE_URL, createTransport, type Transport, type TransportError, type TransportResult, } from "./core/client/transport";
8
+ export { IDENTITY_INFO_ANSWER_KEYS, type DisclaimerAnswer, type DropdownAnswer, type EmailFormAnswer, type FileUploaderAnswer, type GraphicOptionsAnswer, type IdentityInfoAnswer, type IdentityInfoAnswerKey, type KnownAnswerState, type LongInputAnswer, type MMChoiceAnswer, type MultipleChoiceAnswer, type MultipleChoiceSingleAnswerAnswer, type MultipleOptionsAnswer, type SchedulerAnswer, type ShortInputAnswer, } from "./core/engine/answerStates";
9
+ export { createFormEngine, type FormEngine, type FormEngineEvents, type FormEngineState, type ResolveNextStep, type ResolvedNextStep, } from "./core/engine/formEngine";
10
+ export { DEFAULT_REDIRECT_TIMEOUT_MS, buildRedirectUrl, performRedirect, type RedirectType, } from "./core/engine/redirect";
11
+ export { buildResponsesArray, createSubmitResponsePayload, createUpdateResponsePayload, type AnswerStates, type ExternalStates, type FormResponsePayload, type FormUpdateResponsePayload, type SingleFormResponse, } from "./core/engine/responsePayload";
12
+ export { buildUrlData, constructUrlParamsObject, parseCookiesObject, type UrlData, } from "./core/engine/urlData";
13
+ export { parsePrefillParams, parseQuestionId, type ParsedUrlQuestionId } from "./core/engine/urlPrefill";
14
+ export { observeDropoff } from "./core/events/dropoffDetection";
15
+ export { createEmitter, type Emitter, type Unsubscribe } from "./core/events/emitter";
16
+ export { createFormJourneyTracker, type FormJourneyOutcome, type FormJourneyTrackPayload, type FormJourneyTracker, type FormJourneyTransitionReason, type FormJourneyVisit, } from "./core/events/formJourneyTracker";
17
+ export { buildStepTransitionEventBatch, createPushEventClient, type PushEventBatch, type PushEventClient, type PushEventPayload, type PushEventProperty, type PushEventRequest, type SurfaceEventEntityType, type SurfaceEventType, } from "./core/events/pushEvents";
18
+ export { createStartedDetector } from "./core/events/startedDetection";
19
+ export { observeFormView } from "./core/events/viewDetection";
20
+ export { getBrowserFingerprint, getHash, type Fingerprint } from "./core/identity/browserFingerprint";
21
+ export { ensureIdentified } from "./core/identity/ensureIdentified";
22
+ export { buildIdentifyPayload, identifyLead, type IdentifyPayload, type IdentifyResult, type LeadSource, } from "./core/identity/identify";
23
+ export { JOURNEY_COOKIE_NAME, RECENT_VISIT_COOKIE_NAME, createJourneyTracker, type JourneyTracker, } from "./core/identity/journey";
24
+ export { LEAD_DATA_STORAGE_KEY, LEAD_DATA_TTL_MS, readLeadData, writeLeadData, type CachedLeadData, } from "./core/identity/leadDataCache";
25
+ export { ENRICHMENT_STATE_ID, attachEnrichment, type AttachEnrichmentOptions, type EnrichmentSource, } from "./enrichment/attachEnrichment";
26
+ export { SurfaceForms, type SurfaceForm, type SurfaceFormsInitOptions } from "./surfaceForms";
27
+ export { attachEmailValidation, type AttachEmailValidationOptions } from "./validation/attachEmailValidation";
28
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,KAAK,eAAe,EAA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AK,cAAc,EACnB,KAAK,UAAU,GAChB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EACL,mBAAmB,EACnB,wBAAwB,EACxB,oBAAoB,EACpB,KAAK,cAAc,GACpB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EACL,qBAAqB,EACrB,gBAAgB,EAChB,YAAY,EACZ,aAAa,EACb,KAAK,cAAc,GACpB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EACL,mBAAmB,EACnB,gBAAgB,EAChB,KAAK,uBAAuB,EAC5B,KAAK,gBAAgB,GACtB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,YAAY,EAAE,KAAK,WAAW,EAAE,KAAK,uBAAuB,EAAE,MAAM,gBAAgB,CAAC;AAC9F,OAAO,EAAE,qBAAqB,EAAE,KAAK,4BAA4B,EAAE,MAAM,oCAAoC,CAAC"}
@@ -0,0 +1,2 @@
1
+ export { useSurfaceForm, type UseSurfaceFormResult } from "./useSurfaceForm";
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/react/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,KAAK,oBAAoB,EAAE,MAAM,kBAAkB,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=ssr.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ssr.test.d.ts","sourceRoot":"","sources":["../../../src/react/ssr.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,25 @@
1
+ import type { FormEngine, FormEngineState } from "../core/engine/formEngine";
2
+ /**
3
+ * React adapter (forms-sdk-plan.md §2.9): a thin `useSyncExternalStore`
4
+ * subscription over the headless engine's store contract. The host renders
5
+ * the current step from `state` with controlled inputs; every action is the
6
+ * engine's own method, so engine semantics are identical to the `bind/` mode
7
+ * by construction — only who applies visibility differs.
8
+ *
9
+ * Server snapshots reuse `engine.state()`: the engine is SSR-safe to create
10
+ * (no DOM access until interaction), so hydration sees the initial step.
11
+ */
12
+ export type UseSurfaceFormResult = {
13
+ state: FormEngineState;
14
+ setAnswer: FormEngine["setAnswer"];
15
+ next: FormEngine["next"];
16
+ back: FormEngine["back"];
17
+ goToStep: FormEngine["goToStep"];
18
+ submit: FormEngine["submit"];
19
+ disqualify: FormEngine["disqualify"];
20
+ savePartial: FormEngine["savePartial"];
21
+ markViewed: FormEngine["markViewed"];
22
+ on: FormEngine["on"];
23
+ };
24
+ export declare const useSurfaceForm: (engine: FormEngine) => UseSurfaceFormResult;
25
+ //# sourceMappingURL=useSurfaceForm.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useSurfaceForm.d.ts","sourceRoot":"","sources":["../../../src/react/useSurfaceForm.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAE7E;;;;;;;;;GASG;AACH,MAAM,MAAM,oBAAoB,GAAG;IACjC,KAAK,EAAE,eAAe,CAAC;IACvB,SAAS,EAAE,UAAU,CAAC,WAAW,CAAC,CAAC;IACnC,IAAI,EAAE,UAAU,CAAC,MAAM,CAAC,CAAC;IACzB,IAAI,EAAE,UAAU,CAAC,MAAM,CAAC,CAAC;IACzB,QAAQ,EAAE,UAAU,CAAC,UAAU,CAAC,CAAC;IACjC,MAAM,EAAE,UAAU,CAAC,QAAQ,CAAC,CAAC;IAC7B,UAAU,EAAE,UAAU,CAAC,YAAY,CAAC,CAAC;IACrC,WAAW,EAAE,UAAU,CAAC,aAAa,CAAC,CAAC;IACvC,UAAU,EAAE,UAAU,CAAC,YAAY,CAAC,CAAC;IACrC,EAAE,EAAE,UAAU,CAAC,IAAI,CAAC,CAAC;CACtB,CAAC;AAEF,eAAO,MAAM,cAAc,WAAY,UAAU,KAAG,oBAcnD,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=useSurfaceForm.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useSurfaceForm.test.d.ts","sourceRoot":"","sources":["../../../src/react/useSurfaceForm.test.tsx"],"names":[],"mappings":""}
@@ -0,0 +1,120 @@
1
+ import { type EmailValidationResult } from "./core/client/emailValidation";
2
+ import { type RuntimeConfig } from "./core/client/runtimeConfig";
3
+ import { type FormEngine, type ResolveNextStep } from "./core/engine/formEngine";
4
+ import type { LeadSource } from "./core/identity/identify";
5
+ import { type TrackingSettings } from "./tracking/attachTracking";
6
+ /**
7
+ * The public entry point (forms-sdk-plan.md §2.2): composes the boot sequence
8
+ * in the native, load-bearing order — identify before the first write (row
9
+ * 60: attribute sync silently no-ops otherwise) — then wires events, journey,
10
+ * drop-off, and the optional DOM binding around one engine instance.
11
+ *
12
+ * **The form definition boots from the runtime-config endpoint** (§2.3,
13
+ * Decisions #7): when `steps` is omitted, init fetches the published record
14
+ * and derives the step order, the behavioral settings gates, and the expected
15
+ * questionIds for the §4.3 drift warning. Caller-provided `steps`/`settings`/
16
+ * `expectedQuestionIds` still win — offline tests and agents that already
17
+ * hold the record skip the fetch entirely.
18
+ *
19
+ * `preview: true` replicates the native guarantee that previews never pollute
20
+ * data (§2.2): identify, response writes, pushEvents, form-journey, and the
21
+ * journey module are all blocked client-side.
22
+ */
23
+ export type SurfaceFormsInitOptions = {
24
+ environmentId: string;
25
+ formId: string;
26
+ /** Ordered logical steps of the form record; omitted = fetched from runtime-config. */
27
+ steps?: Array<{
28
+ id: string;
29
+ endStepKind?: "thank_you" | "disqualified";
30
+ }>;
31
+ /**
32
+ * Behavioral gates + customer-tag config (rows 51–55). Omitted values fill
33
+ * from runtime-config ONLY when `steps` is also omitted (the record fetch) —
34
+ * caller-provided `steps` skip the fetch entirely, so pass tracking settings
35
+ * explicitly in that offline mode.
36
+ */
37
+ settings?: {
38
+ trackPartialResponses?: boolean;
39
+ trackCookies?: boolean;
40
+ } & TrackingSettings;
41
+ apiBaseUrl?: string;
42
+ /** Enables the bind/ layer + view detection on this root. */
43
+ container?: Element;
44
+ /** Stateful questionIds from the record; unbound ones get the §4.3 runtime warning. */
45
+ expectedQuestionIds?: string[];
46
+ /** Routing evaluation; defaults to linear order until the extracted routing module lands. */
47
+ resolveNextStep?: ResolveNextStep;
48
+ /** Seeds a URL_DATA external-state entry under this id (attribution, row 56). */
49
+ urlDataStateId?: string;
50
+ source?: LeadSource;
51
+ /** Page-view tracking module (tag parity), default off. */
52
+ journey?: boolean;
53
+ /**
54
+ * Automatic waterfall email validation (row 37), default off: watches
55
+ * email answers (debounced, per-address verdicts, fail-open) and annotates
56
+ * the response `meta` with native's `isEmailValid`/`emailValidation`/
57
+ * `emailValidationFailed` keys. Opt-in because verdicts spend the form
58
+ * owner's validator quota. The on-demand `validateEmail` on the handle is
59
+ * always available and shares the same per-address cache.
60
+ */
61
+ emailValidation?: boolean;
62
+ preview?: boolean;
63
+ /**
64
+ * Signed token from the create_form / get_sdk_binding_map replies; with
65
+ * `preview: true` it unlocks the DRAFT config of a never-published form.
66
+ * Without it, preview serves the published config.
67
+ */
68
+ previewToken?: string;
69
+ /**
70
+ * Resume a stored response: pass the `responseId` + `resumeToken` pair a
71
+ * previous session's create returned (`state().resumeToken`, or the `saved`
72
+ * event). Boot fetches the stored answers through the token-gated read-back
73
+ * and seeds the engine — writes become updates and earlier answers are
74
+ * preserved; a failed fetch warns and starts fresh. Ignored in preview.
75
+ */
76
+ resume?: {
77
+ responseId: string;
78
+ resumeToken: string;
79
+ };
80
+ /** Logs every captured answer and warns on states the server would reject (unknown questionId, wrong/missing type, malformed choices). Development aid; never enable in production. */
81
+ debug?: boolean;
82
+ meta?: Record<string, unknown>;
83
+ };
84
+ export type SurfaceForm = Pick<FormEngine, "setAnswer" | "setExternalState" | "next" | "back" | "goToStep" | "submit" | "disqualify" | "savePartial" | "flush" | "markViewed" | "on" | "state" | "subscribe"> & {
85
+ /** Re-runs identify (e.g. after an SPA route change); cache makes it cheap. */
86
+ identify: () => Promise<unknown>;
87
+ /**
88
+ * On-demand waterfall email validation (row 37): resolves a per-address
89
+ * deliverability verdict, cached for the form's lifetime and fail-open on
90
+ * validator outage. Use it to gate your own navigation:
91
+ * `if ((await form.validateEmail(value)).isValid) form.next()`.
92
+ * In preview it resolves a synthetic valid verdict without network.
93
+ */
94
+ validateEmail: (email: string) => Promise<EmailValidationResult>;
95
+ /**
96
+ * Records caller-computed values (a qualification score, an A/B bucket, …)
97
+ * onto the response `meta` — they ride the next save, or amend the stored
98
+ * response when the form already finished. SDK-owned keys
99
+ * (`surfaceTagStatus` and the email-validation verdicts) are dropped with a
100
+ * console warning: dashboards trust those.
101
+ */
102
+ mergeMeta: (partial: Record<string, unknown>) => void;
103
+ /**
104
+ * What actually runs in THIS environment — the record can declare features
105
+ * (an enrichment source field) that the environment does not back with a
106
+ * provider, and nothing else surfaces that.
107
+ */
108
+ capabilities: {
109
+ enrichment: boolean;
110
+ emailValidation: boolean;
111
+ tracking: boolean;
112
+ };
113
+ /** The fetched published record (labels, component types); undefined when `steps` was caller-provided. */
114
+ runtimeConfig?: RuntimeConfig;
115
+ destroy: () => void;
116
+ };
117
+ export declare const SurfaceForms: {
118
+ init: ({ environmentId, formId, steps, settings, apiBaseUrl, container, expectedQuestionIds, resolveNextStep, urlDataStateId, source, journey, emailValidation, preview, previewToken, debug, resume, meta, }: SurfaceFormsInitOptions) => Promise<SurfaceForm>;
119
+ };
120
+ //# sourceMappingURL=surfaceForms.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"surfaceForms.d.ts","sourceRoot":"","sources":["../../src/surfaceForms.ts"],"names":[],"mappings":"AACA,OAAO,EAAwB,KAAK,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;AAEjG,OAAO,EAOL,KAAK,aAAa,EACnB,MAAM,6BAA6B,CAAC;AAGrC,OAAO,EAAoB,KAAK,UAAU,EAAE,KAAK,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAMnG,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,0BAA0B,CA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AI,CAC5B,UAAU,EACR,WAAW,GACX,kBAAkB,GAClB,MAAM,GACN,MAAM,GACN,UAAU,GACV,QAAQ,GACR,YAAY,GACZ,aAAa,GACb,OAAO,GACP,YAAY,GACZ,IAAI,GACJ,OAAO,GACP,WAAW,CACd,GAAG;IACF,+EAA+E;IAC/E,QAAQ,EAAE,MAAM,OAAO,CAAC,OAAO,CAAC,CAAC;IACjC;;;;;;OAMG;IACH,aAAa,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC,qBAAqB,CAAC,CAAC;IACjE;;;;;;OAMG;IACH,SAAS,EAAE,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,IAAI,CAAC;IACtD;;;;OAIG;IACH,YAAY,EAAE;QAAE,UAAU,EAAE,OAAO,CAAC;QAAC,eAAe,EAAE,OAAO,CAAC;QAAC,QAAQ,EAAE,OAAO,CAAA;KAAE,CAAC;IACnF,0GAA0G;IAC1G,aAAa,CAAC,EAAE,aAAa,CAAC;IAC9B,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB,CAAC;AAEF,eAAO,MAAM,YAAY;IACvB,IAAI,2MAkBD,uBAAuB,KAAG,OAAO,CAAC,WAAW,CAAC;CAuPlD,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=surfaceForms.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"surfaceForms.test.d.ts","sourceRoot":"","sources":["../../src/surfaceForms.test.ts"],"names":[],"mappings":""}