@parag.more.withsurface.com/forms-sdk 0.1.4 → 0.1.6

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 (191) hide show
  1. package/README.md +9 -4
  2. package/dist/index.cjs +1 -2737
  3. package/dist/index.mjs +1 -2714
  4. package/dist/react/index.cjs +1 -44
  5. package/dist/react/index.mjs +1 -21
  6. package/dist/surface-forms-sdk.min.js +21 -2
  7. package/dist/types/bind/bindForm.d.ts +2 -36
  8. package/dist/types/bind/bookingWidget.d.ts +29 -17
  9. package/dist/types/bind/scheduler/embedUtils.d.ts +50 -0
  10. package/dist/types/bind/scheduler/mountScheduler.d.ts +2 -0
  11. package/dist/types/bind/scheduler/providers/cal.d.ts +3 -0
  12. package/dist/types/bind/scheduler/providers/calendly.d.ts +3 -0
  13. package/dist/types/bind/scheduler/providers/chilical.d.ts +3 -0
  14. package/dist/types/bind/scheduler/providers/clari.d.ts +3 -0
  15. package/dist/types/bind/scheduler/providers/hubspot.d.ts +3 -0
  16. package/dist/types/bind/scheduler/providers/index.d.ts +4 -0
  17. package/dist/types/bind/scheduler/providers/reclaimai.d.ts +3 -0
  18. package/dist/types/bind/scheduler/providers/revenuehero.d.ts +3 -0
  19. package/dist/types/bind/scheduler/providers/savvycal.d.ts +3 -0
  20. package/dist/types/bind/scheduler/providers/surface.d.ts +3 -0
  21. package/dist/types/bind/scheduler/providers/zoom.d.ts +3 -0
  22. package/dist/types/bind/scheduler/styles.d.ts +3 -0
  23. package/dist/types/bind/scheduler/types.d.ts +65 -0
  24. package/dist/types/core/client/emailValidation.d.ts +3 -4
  25. package/dist/types/core/client/responses.d.ts +3 -15
  26. package/dist/types/core/client/runtimeConfig.d.ts +40 -32
  27. package/dist/types/core/client/scheduler.d.ts +4 -27
  28. package/dist/types/core/client/transport.d.ts +4 -28
  29. package/dist/types/core/engine/answerAudit.d.ts +3 -12
  30. package/dist/types/core/engine/answerStates.d.ts +4 -17
  31. package/dist/types/core/engine/formEngine.d.ts +16 -53
  32. package/dist/types/core/engine/redirect.d.ts +1 -23
  33. package/dist/types/core/engine/responsePayload.d.ts +4 -28
  34. package/dist/types/core/engine/schedulerEvents.d.ts +40 -0
  35. package/dist/types/core/engine/urlData.d.ts +2 -17
  36. package/dist/types/core/engine/urlPrefill.d.ts +1 -9
  37. package/dist/types/core/events/dropoffDetection.d.ts +1 -14
  38. package/dist/types/core/events/emitter.d.ts +1 -17
  39. package/dist/types/core/events/formJourneyTracker.d.ts +1 -19
  40. package/dist/types/core/events/pushEvents.d.ts +2 -16
  41. package/dist/types/core/events/startedDetection.d.ts +1 -10
  42. package/dist/types/core/events/viewDetection.d.ts +1 -14
  43. package/dist/types/core/identity/browserFingerprint.d.ts +3 -19
  44. package/dist/types/core/identity/ensureIdentified.d.ts +1 -16
  45. package/dist/types/core/identity/identify.d.ts +1 -15
  46. package/dist/types/core/identity/journey.d.ts +3 -16
  47. package/dist/types/core/identity/journey.testStubs.d.ts +1 -2
  48. package/dist/types/core/identity/leadDataCache.d.ts +1 -16
  49. package/dist/types/enrichment/attachEnrichment.d.ts +1 -21
  50. package/dist/types/index.d.ts +5 -3
  51. package/dist/types/react/index.d.ts +0 -1
  52. package/dist/types/react/useSurfaceForm.d.ts +1 -11
  53. package/dist/types/surfaceForms.d.ts +28 -73
  54. package/dist/types/tracking/attachTracking.d.ts +1 -22
  55. package/dist/types/tracking/conversionRules.d.ts +3 -12
  56. package/dist/types/tracking/vendors.d.ts +3 -22
  57. package/dist/types/validation/attachEmailValidation.d.ts +0 -1
  58. package/docs/api.md +51 -39
  59. package/docs/reference/binding.md +86 -13
  60. package/docs/reference/clients.md +21 -1
  61. package/docs/reference/engine.md +5 -1
  62. package/docs/reference/events.md +4 -1
  63. package/docs/reference/identity.md +2 -3
  64. package/llms.txt +58 -10
  65. package/package.json +1 -1
  66. package/skills/surface-forms-sdk/SKILL.md +19 -6
  67. package/skills/surface-forms-sdk/patterns.md +30 -5
  68. package/dist/index.cjs.map +0 -7
  69. package/dist/index.mjs.map +0 -7
  70. package/dist/react/index.cjs.map +0 -7
  71. package/dist/react/index.mjs.map +0 -7
  72. package/dist/surface-forms-sdk.min.js.map +0 -7
  73. package/dist/types/bind/bindForm.d.ts.map +0 -1
  74. package/dist/types/bind/bindForm.test.d.ts +0 -2
  75. package/dist/types/bind/bindForm.test.d.ts.map +0 -1
  76. package/dist/types/bind/bookingWidget.d.ts.map +0 -1
  77. package/dist/types/bind/bookingWidget.test.d.ts +0 -2
  78. package/dist/types/bind/bookingWidget.test.d.ts.map +0 -1
  79. package/dist/types/core/client/emailValidation.d.ts.map +0 -1
  80. package/dist/types/core/client/emailValidation.test.d.ts +0 -2
  81. package/dist/types/core/client/emailValidation.test.d.ts.map +0 -1
  82. package/dist/types/core/client/responses.d.ts.map +0 -1
  83. package/dist/types/core/client/responses.test.d.ts +0 -2
  84. package/dist/types/core/client/responses.test.d.ts.map +0 -1
  85. package/dist/types/core/client/runtimeConfig.contract.test.d.ts +0 -2
  86. package/dist/types/core/client/runtimeConfig.contract.test.d.ts.map +0 -1
  87. package/dist/types/core/client/runtimeConfig.d.ts.map +0 -1
  88. package/dist/types/core/client/runtimeConfig.test.d.ts +0 -2
  89. package/dist/types/core/client/runtimeConfig.test.d.ts.map +0 -1
  90. package/dist/types/core/client/scheduler.contract.test.d.ts +0 -2
  91. package/dist/types/core/client/scheduler.contract.test.d.ts.map +0 -1
  92. package/dist/types/core/client/scheduler.d.ts.map +0 -1
  93. package/dist/types/core/client/scheduler.test.d.ts +0 -2
  94. package/dist/types/core/client/scheduler.test.d.ts.map +0 -1
  95. package/dist/types/core/client/transport.d.ts.map +0 -1
  96. package/dist/types/core/client/transport.test.d.ts +0 -2
  97. package/dist/types/core/client/transport.test.d.ts.map +0 -1
  98. package/dist/types/core/engine/answerAudit.d.ts.map +0 -1
  99. package/dist/types/core/engine/answerAudit.test.d.ts +0 -2
  100. package/dist/types/core/engine/answerAudit.test.d.ts.map +0 -1
  101. package/dist/types/core/engine/answerStates.contract.test.d.ts +0 -2
  102. package/dist/types/core/engine/answerStates.contract.test.d.ts.map +0 -1
  103. package/dist/types/core/engine/answerStates.d.ts.map +0 -1
  104. package/dist/types/core/engine/formEngine.d.ts.map +0 -1
  105. package/dist/types/core/engine/formEngine.test.d.ts +0 -2
  106. package/dist/types/core/engine/formEngine.test.d.ts.map +0 -1
  107. package/dist/types/core/engine/redirect.d.ts.map +0 -1
  108. package/dist/types/core/engine/redirect.test.d.ts +0 -2
  109. package/dist/types/core/engine/redirect.test.d.ts.map +0 -1
  110. package/dist/types/core/engine/responsePayload.contract.test.d.ts +0 -2
  111. package/dist/types/core/engine/responsePayload.contract.test.d.ts.map +0 -1
  112. package/dist/types/core/engine/responsePayload.d.ts.map +0 -1
  113. package/dist/types/core/engine/responsePayload.test.d.ts +0 -2
  114. package/dist/types/core/engine/responsePayload.test.d.ts.map +0 -1
  115. package/dist/types/core/engine/urlData.contract.test.d.ts +0 -2
  116. package/dist/types/core/engine/urlData.contract.test.d.ts.map +0 -1
  117. package/dist/types/core/engine/urlData.d.ts.map +0 -1
  118. package/dist/types/core/engine/urlData.test.d.ts +0 -2
  119. package/dist/types/core/engine/urlData.test.d.ts.map +0 -1
  120. package/dist/types/core/engine/urlPrefill.d.ts.map +0 -1
  121. package/dist/types/core/engine/urlPrefill.test.d.ts +0 -2
  122. package/dist/types/core/engine/urlPrefill.test.d.ts.map +0 -1
  123. package/dist/types/core/events/dropoffDetection.d.ts.map +0 -1
  124. package/dist/types/core/events/dropoffDetection.test.d.ts +0 -2
  125. package/dist/types/core/events/dropoffDetection.test.d.ts.map +0 -1
  126. package/dist/types/core/events/emitter.d.ts.map +0 -1
  127. package/dist/types/core/events/emitter.test.d.ts +0 -2
  128. package/dist/types/core/events/emitter.test.d.ts.map +0 -1
  129. package/dist/types/core/events/formJourneyTracker.contract.test.d.ts +0 -2
  130. package/dist/types/core/events/formJourneyTracker.contract.test.d.ts.map +0 -1
  131. package/dist/types/core/events/formJourneyTracker.d.ts.map +0 -1
  132. package/dist/types/core/events/formJourneyTracker.test.d.ts +0 -2
  133. package/dist/types/core/events/formJourneyTracker.test.d.ts.map +0 -1
  134. package/dist/types/core/events/pushEvents.contract.test.d.ts +0 -2
  135. package/dist/types/core/events/pushEvents.contract.test.d.ts.map +0 -1
  136. package/dist/types/core/events/pushEvents.d.ts.map +0 -1
  137. package/dist/types/core/events/pushEvents.test.d.ts +0 -2
  138. package/dist/types/core/events/pushEvents.test.d.ts.map +0 -1
  139. package/dist/types/core/events/startedDetection.d.ts.map +0 -1
  140. package/dist/types/core/events/startedDetection.test.d.ts +0 -2
  141. package/dist/types/core/events/startedDetection.test.d.ts.map +0 -1
  142. package/dist/types/core/events/viewDetection.d.ts.map +0 -1
  143. package/dist/types/core/events/viewDetection.test.d.ts +0 -2
  144. package/dist/types/core/events/viewDetection.test.d.ts.map +0 -1
  145. package/dist/types/core/identity/browserFingerprint.d.ts.map +0 -1
  146. package/dist/types/core/identity/browserFingerprint.test.d.ts +0 -2
  147. package/dist/types/core/identity/browserFingerprint.test.d.ts.map +0 -1
  148. package/dist/types/core/identity/ensureIdentified.d.ts.map +0 -1
  149. package/dist/types/core/identity/ensureIdentified.test.d.ts +0 -2
  150. package/dist/types/core/identity/ensureIdentified.test.d.ts.map +0 -1
  151. package/dist/types/core/identity/identify.contract.test.d.ts +0 -2
  152. package/dist/types/core/identity/identify.contract.test.d.ts.map +0 -1
  153. package/dist/types/core/identity/identify.d.ts.map +0 -1
  154. package/dist/types/core/identity/identify.test.d.ts +0 -2
  155. package/dist/types/core/identity/identify.test.d.ts.map +0 -1
  156. package/dist/types/core/identity/journey.contract.test.d.ts +0 -2
  157. package/dist/types/core/identity/journey.contract.test.d.ts.map +0 -1
  158. package/dist/types/core/identity/journey.d.ts.map +0 -1
  159. package/dist/types/core/identity/journey.test.d.ts +0 -2
  160. package/dist/types/core/identity/journey.test.d.ts.map +0 -1
  161. package/dist/types/core/identity/journey.testStubs.d.ts.map +0 -1
  162. package/dist/types/core/identity/leadDataCache.d.ts.map +0 -1
  163. package/dist/types/core/identity/leadDataCache.test.d.ts +0 -2
  164. package/dist/types/core/identity/leadDataCache.test.d.ts.map +0 -1
  165. package/dist/types/enrichment/attachEnrichment.d.ts.map +0 -1
  166. package/dist/types/enrichment/attachEnrichment.test.d.ts +0 -2
  167. package/dist/types/enrichment/attachEnrichment.test.d.ts.map +0 -1
  168. package/dist/types/index.d.ts.map +0 -1
  169. package/dist/types/react/index.d.ts.map +0 -1
  170. package/dist/types/react/ssr.test.d.ts +0 -2
  171. package/dist/types/react/ssr.test.d.ts.map +0 -1
  172. package/dist/types/react/useSurfaceForm.d.ts.map +0 -1
  173. package/dist/types/react/useSurfaceForm.test.d.ts +0 -2
  174. package/dist/types/react/useSurfaceForm.test.d.ts.map +0 -1
  175. package/dist/types/surfaceForms.d.ts.map +0 -1
  176. package/dist/types/surfaceForms.test.d.ts +0 -2
  177. package/dist/types/surfaceForms.test.d.ts.map +0 -1
  178. package/dist/types/tracking/attachTracking.d.ts.map +0 -1
  179. package/dist/types/tracking/attachTracking.test.d.ts +0 -2
  180. package/dist/types/tracking/attachTracking.test.d.ts.map +0 -1
  181. package/dist/types/tracking/conversionRules.contract.test.d.ts +0 -2
  182. package/dist/types/tracking/conversionRules.contract.test.d.ts.map +0 -1
  183. package/dist/types/tracking/conversionRules.d.ts.map +0 -1
  184. package/dist/types/tracking/conversionRules.test.d.ts +0 -2
  185. package/dist/types/tracking/conversionRules.test.d.ts.map +0 -1
  186. package/dist/types/tracking/vendors.d.ts.map +0 -1
  187. package/dist/types/tracking/vendors.test.d.ts +0 -2
  188. package/dist/types/tracking/vendors.test.d.ts.map +0 -1
  189. package/dist/types/validation/attachEmailValidation.d.ts.map +0 -1
  190. package/dist/types/validation/attachEmailValidation.test.d.ts +0 -2
  191. package/dist/types/validation/attachEmailValidation.test.d.ts.map +0 -1
@@ -0,0 +1,65 @@
1
+ import type { SchedulerQuestion } from "../../core/client/runtimeConfig";
2
+ import type { SchedulerBookingSummary, SchedulerLifecycleEvent } from "../../core/engine/schedulerEvents";
3
+ import type { SurfaceForm } from "../../surfaceForms";
4
+ import type { BookingWidgetOptions } from "../bookingWidget";
5
+ export type MountSchedulerOptions = {
6
+ form: SurfaceForm;
7
+ container: Element;
8
+
9
+ questionId?: string;
10
+
11
+ stepId?: string;
12
+
13
+ styled?: boolean;
14
+
15
+ persist?: boolean;
16
+
17
+ prefill?: {
18
+ name?: string;
19
+ lastName?: string;
20
+ email?: string;
21
+ };
22
+
23
+ formatters?: BookingWidgetOptions["formatters"];
24
+
25
+ calendarId?: string;
26
+ onEvent?: (event: SchedulerLifecycleEvent) => void;
27
+
28
+ onComplete?: (booking: SchedulerBookingSummary) => void;
29
+ };
30
+
31
+ export type ProviderEvent = SchedulerLifecycleEvent extends infer T ? T extends {
32
+ questionId: string;
33
+ stepId: string;
34
+ provider: unknown;
35
+ } ? Omit<T, "questionId" | "stepId" | "provider"> : never : never;
36
+
37
+ export type ProviderContext = {
38
+ form: SurfaceForm;
39
+ container: Element;
40
+ question: SchedulerQuestion;
41
+
42
+ content: SchedulerQuestion["content"];
43
+ prefill: {
44
+ name?: string;
45
+ lastName?: string;
46
+ email?: string;
47
+ };
48
+
49
+ urlParams: Record<string, string>;
50
+ formatters?: BookingWidgetOptions["formatters"];
51
+ styled: boolean;
52
+ emit: (event: ProviderEvent) => void;
53
+
54
+ confirmBooking: (booking: Omit<SchedulerBookingSummary, "provider">, extraAnswer?: Record<string, unknown>) => void;
55
+
56
+ cancelBooking: (reason?: string) => void;
57
+
58
+ mergeAnswer: (partial: Record<string, unknown>, opts?: {
59
+ save?: boolean;
60
+ }) => void;
61
+
62
+ ensureResponseId: () => Promise<string | null>;
63
+ };
64
+
65
+ export type ProviderMount = (ctx: ProviderContext) => () => void;
@@ -1,12 +1,12 @@
1
1
  import type { Transport } from "./transport";
2
2
  export type EmailValidationResult = {
3
3
  email: string;
4
- /** Deliverable per the waterfall + blacklist; fail-open true when validation could not run. */
4
+
5
5
  isValid: boolean;
6
6
  status?: string;
7
7
  reason?: string;
8
8
  blacklistEntryIds?: string[];
9
- /** Validation did not actually run (network/server failure) — `isValid` is the fail-open default. */
9
+
10
10
  failed?: boolean;
11
11
  };
12
12
  export type EmailValidator = {
@@ -16,8 +16,7 @@ export type EmailValidator = {
16
16
  export type CreateEmailValidatorOptions = {
17
17
  transport: Transport;
18
18
  environmentId: string;
19
- /** Preview never spends validator quota: every email reports a synthetic valid result. */
19
+
20
20
  preview?: boolean;
21
21
  };
22
22
  export declare const createEmailValidator: ({ transport, environmentId, preview, }: CreateEmailValidatorOptions) => EmailValidator;
23
- //# sourceMappingURL=emailValidation.d.ts.map
@@ -3,33 +3,21 @@ import type { Transport, TransportResult } from "./transport";
3
3
  export type CreateResponseResult = {
4
4
  responseId: string;
5
5
  leadId: string | null;
6
- /** Authorizes the token-gated read-back (resume); persist alongside the responseId. */
6
+
7
7
  resumeToken: string | null;
8
8
  };
9
9
  export declare const submitResponse: (transport: Transport, payload: FormResponsePayload) => Promise<TransportResult<CreateResponseResult>>;
10
10
  export declare const updateResponse: (transport: Transport, payload: FormUpdateResponsePayload) => void;
11
- /**
12
- * Awaited delivery for the FINISHING update (the 2026-08 field run measured
13
- * the beacon path silently dropping the terminal write on fast page close:
14
- * `submit()` resolved, `saved` fired, and the server kept a step-1 partial).
15
- * `keepalive` lets the request survive an immediate navigation; credentials
16
- * match the beacon path's `${formId}_pa` cookie round-trip.
17
- */
11
+
18
12
  export declare const updateResponseConfirmed: (transport: Transport, payload: FormUpdateResponsePayload) => Promise<TransportResult<unknown>>;
19
13
  export type StoredAnswerRow = {
20
14
  questionId: string;
21
15
  response: Record<string, unknown>;
22
16
  };
23
- /**
24
- * Read-back of a stored response for resume (Decisions #11: the route is
25
- * token-gated; the create reply issued the token). External-state
26
- * pseudo-answers (URL_DATA) are stripped — they are attribution snapshots the
27
- * engine re-derives from its own page context, not visitor answers.
28
- */
17
+
29
18
  export declare const fetchStoredResponse: (transport: Transport, { responseId, resumeToken }: {
30
19
  responseId: string;
31
20
  resumeToken: string;
32
21
  }) => Promise<TransportResult<{
33
22
  answers: StoredAnswerRow[];
34
23
  }>>;
35
- //# sourceMappingURL=responses.d.ts.map
@@ -1,19 +1,5 @@
1
1
  import type { Transport, TransportResult } from "./transport";
2
- /**
3
- * Boot-time fetch of the published form record (forms-sdk-plan.md §2.3,
4
- * Decisions #7): `GET /api/v1/public/forms/[formId]/runtime-config` serves the
5
- * same `TCachedForm` payload the hosted `/s/[formId]` page reads — config
6
- * (steps + components, the data contract) and settings (behavioral gates like
7
- * `trackPartialResponses`; tracking ids for the Phase-2 tracking module).
8
- * `settings.password` never arrives — the server strips it and the SDK
9
- * validates gated forms through `/api/v1/check-password`.
10
- *
11
- * The step/question extraction mirrors `extractFlatComponentsFromStep`
12
- * (form-render gridLayoutUtils): a step's `components` is either a flat
13
- * component array or a ComponentGridLayout whose rows hold components or
14
- * `GridLayoutRowItem` wrappers; stateful components carry `state.questionId` —
15
- * the same discriminator the MCP validator's `collectQuestionIds` uses.
16
- */
2
+
17
3
  type RuntimeStep = {
18
4
  id: string;
19
5
  endStepKind?: "thank_you" | "disqualified";
@@ -31,14 +17,14 @@ export type RuntimeConfig = {
31
17
  trackCookie?: boolean;
32
18
  } & Record<string, unknown>) | null;
33
19
  };
34
- /** `preview` asks the server for the draft config of a never-published form (authoring loop); published forms serve live either way. */
20
+
35
21
  export declare const fetchRuntimeConfig: (transport: Transport, formId: string, { preview, previewToken }?: {
36
22
  preview?: boolean;
37
23
  previewToken?: string;
38
24
  }) => Promise<TransportResult<{
39
25
  data?: RuntimeConfig;
40
26
  }>>;
41
- /** Step order + ending kinds — the engine's traversal contract, including where submit/disqualify land. */
27
+
42
28
  export declare const stepsOf: (config: RuntimeConfig["config"]) => Array<{
43
29
  id: string;
44
30
  endStepKind?: "thank_you" | "disqualified";
@@ -48,25 +34,47 @@ export declare const statefulQuestionsOf: (config: RuntimeConfig["config"]) => A
48
34
  componentType?: string;
49
35
  }>;
50
36
  export declare const statefulQuestionIdsOf: (config: RuntimeConfig["config"]) => string[];
51
- /**
52
- * Questions whose answers can trigger real-time enrichment, with the state
53
- * keys to watch — the native renderer's blur triggers translated to data
54
- * (identityInfo.tsx handleOnBlur): IdentityInfo fires on its configured
55
- * `enrichmentSourceField` (default emailAddress) and always on `websiteUrl`;
56
- * EmailForm fires on its email.
57
- */
37
+
58
38
  export declare const enrichmentSourcesOf: (config: RuntimeConfig["config"]) => Array<{
59
39
  questionId: string;
60
40
  fieldNames: string[];
61
41
  }>;
62
- /**
63
- * True when a component EXPLICITLY declares `enrichmentSourceField` — the
64
- * authoring-time signal that the owner expects enrichment to run. Implicit
65
- * sources (every EmailForm / IdentityInfo default) don't count: they make any
66
- * form with an email question look enrichment-configured.
67
- */
42
+
43
+ export type SchedulerStateRef = {
44
+ stepId: string;
45
+ questionId: string;
46
+ };
47
+
48
+ export type SchedulerParamRef = SchedulerStateRef & {
49
+ variable: string;
50
+ };
51
+ export type SchedulerQuestion = {
52
+ questionId: string;
53
+ stepId: string;
54
+
55
+ componentType: "CalendlyScreen" | "DynamicScheduler";
56
+
57
+ calendarType: string;
58
+ content: {
59
+ dataUrl?: string;
60
+ eventTypeId?: string;
61
+ savvyCalLinkId?: string;
62
+ revenueHeroRouterId?: string;
63
+ dataUrlParams?: Record<string, SchedulerParamRef>;
64
+ linkNameToStep?: SchedulerStateRef;
65
+ linkLastNameToStep?: SchedulerStateRef;
66
+ linkEmailToStep?: SchedulerStateRef;
67
+ addSchedulerQueryParams?: boolean;
68
+ skipFormIfPrefilled?: boolean;
69
+
70
+ calendars?: unknown[];
71
+ defaultCalendar?: unknown;
72
+ };
73
+ };
74
+
75
+ export declare const schedulerQuestionsOf: (config: RuntimeConfig["config"]) => SchedulerQuestion[];
76
+
68
77
  export declare const hasDeclaredEnrichmentSource: (config: RuntimeConfig["config"]) => boolean;
69
- /** Mirrors form-render's provider gate (buildExternalStateStore): v2 config with at least one enabled provider exposing fields. */
78
+
70
79
  export declare const hasEnabledEnrichmentProvider: (settings: RuntimeConfig["settings"]) => boolean;
71
80
  export {};
72
- //# sourceMappingURL=runtimeConfig.d.ts.map
@@ -1,22 +1,5 @@
1
1
  import type { Transport, TransportResult } from "./transport";
2
- /**
3
- * Thin wrap of the public Surface-native scheduler endpoints (forms-sdk-plan.md
4
- * row 46 — Phase-1 MVP scope by product decision). Query and payload shapes
5
- * mirror `@surface/scheduler-ui`'s hooks byte-for-byte (that package is
6
- * AGPL-tree and cannot ship in the MIT SDK — plan §2.9), including the split
7
- * of `YYYY-MM` into numeric month/year params and the booking `meta` block
8
- * that drives server-side booking↔response linkage.
9
- *
10
- * `preview: true` mirrors the native BookingForm exactly: queries carry
11
- * `preview=true`, and `book()` resolves a fabricated preview booking without
12
- * any network call — draft interactions never create real bookings.
13
- *
14
- * `toSchedulerAnswerState` reproduces `SurfaceScheduler.handleBookingComplete`:
15
- * the persisted DynamicScheduler component state whose `eventScheduled`/`uri`
16
- * pair the payload builder's bookingId detection and the server's booking
17
- * meta injection key on. `googleMeetLink` is the frozen persisted key even
18
- * though the API field is `meetingJoinLink`.
19
- */
2
+
20
3
  export type BookingAttendee = {
21
4
  name: string;
22
5
  email: string;
@@ -62,7 +45,7 @@ export type SchedulerClient = {
62
45
  }>>;
63
46
  getMonthAvailability: (args: {
64
47
  eventTypeId: string;
65
- /** Calendar month as `YYYY-MM`; split into numeric month/year params like native. */
48
+
66
49
  month: string;
67
50
  timezone: string;
68
51
  duration?: number;
@@ -85,12 +68,7 @@ export type SchedulerClient = {
85
68
  book: (args: {
86
69
  eventTypeId: string;
87
70
  startTime: string;
88
- /**
89
- * The selected slot's end. Required — every booking comes from a picked
90
- * slot, and a fallback would fabricate zero-length preview meetings. Only
91
- * preview fabrication reads it (the server derives real end times); it is
92
- * never sent on the wire.
93
- */
71
+
94
72
  endTime: string;
95
73
  timezone: string;
96
74
  inviteeName: string;
@@ -115,7 +93,6 @@ export declare const createSchedulerClient: ({ transport, preview, }: {
115
93
  transport: Transport;
116
94
  preview?: boolean;
117
95
  }) => SchedulerClient;
118
- /** The persisted DynamicScheduler component state for a completed booking. */
96
+
119
97
  export declare const toSchedulerAnswerState: (booking: Booking) => Record<string, unknown>;
120
98
  export {};
121
- //# sourceMappingURL=scheduler.d.ts.map
@@ -1,30 +1,7 @@
1
- /**
2
- * Delivery layer for the SDK's first-party requests, mirroring the native
3
- * runtime's two transports (forms-sdk-plan.md §2.4):
4
- *
5
- * - `post` — plain `fetch` for calls whose response body the engine needs
6
- * (response create returns `responseId`/`meta`, identify returns
7
- * `leadId`/`sessionId`). Never throws: resolves to a typed result so
8
- * callers keep the never-break-the-host-page guarantee (§2.6).
9
- * - `beacon` — `sendBeacon`-first with `fetch(keepalive)` fallback for
10
- * fire-and-forget writes (response updates, events, journey), the same
11
- * semantics as form-render's `updateResponse.ts` / `sendPushEventRequest.ts`.
12
- * Failures are swallowed by design: the server's drop-off sweep reconciles
13
- * missed updates, and events are best-effort.
14
- *
15
- * Unlike form-render (relative paths, same-origin only), every request is
16
- * absolute against a configurable base URL — SDK pages are customer-hosted
17
- * and always cross-origin (§4.1).
18
- */
19
- /** The host the public tag already targets (scripts:src/constants.ts). */
1
+
2
+
20
3
  export declare const DEFAULT_API_BASE_URL = "https://forms.withsurface.com";
21
- /**
22
- * Sent as `X-Surface-Sdk-Version` on every fetch-path request (Decisions #14:
23
- * SDK 429s must be measurable before rate limits are revisited). `sendBeacon`
24
- * cannot carry headers, so beacon deliveries carry the version as the `sdv`
25
- * query param instead — the server reads both. Bumped manually until
26
- * extraction wires it to package.json at build time.
27
- */
4
+
28
5
  export declare const SDK_VERSION = "0.1.0";
29
6
  export type TransportResult<TData> = {
30
7
  ok: true;
@@ -47,10 +24,9 @@ export type Transport = {
47
24
  keepalive?: boolean;
48
25
  credentials?: boolean;
49
26
  }) => Promise<TransportResult<TData>>;
50
- /** Returns true only when `sendBeacon` queued the payload; the fire-and-forget fetch fallback reports false. */
27
+
51
28
  beacon: (path: string, payload: unknown) => boolean;
52
29
  };
53
30
  export declare const createTransport: ({ apiBaseUrl, }?: {
54
31
  apiBaseUrl?: string;
55
32
  }) => Transport;
56
- //# sourceMappingURL=transport.d.ts.map
@@ -1,21 +1,12 @@
1
- /**
2
- * `init({ debug: true })` answer auditing: the bind layer always produces
3
- * valid shapes, but headless `setAnswer` callers are one label-string away
4
- * from the ingest 400 that static gates cannot see (2026-08 field run). The
5
- * auditor checks only facts that cannot false-positive — unknown questionId,
6
- * wrong `type` discriminator, a merged state with no `type` at all, and a
7
- * choice-list answer whose `choices` is not an array — and logs every
8
- * captured answer so a session is replayable from the console.
9
- */
1
+
10
2
  export type AuditedQuestion = {
11
3
  questionId: string;
12
4
  componentType?: string;
13
5
  };
14
6
  export declare const auditAnswer: ({ questions, questionId, merged, }: {
15
- /** Stateful questions of the record; empty when the record wasn't fetched (caller-provided steps). */
7
+
16
8
  questions: Map<string, AuditedQuestion>;
17
9
  questionId: string;
18
- /** The post-merge state (setAnswer patches accumulate per question). */
10
+
19
11
  merged: Record<string, unknown>;
20
12
  }) => void;
21
- //# sourceMappingURL=answerAudit.d.ts.map
@@ -1,16 +1,4 @@
1
- /**
2
- * Typed answer states for headless callers (plan §2.9): the bind layer builds
3
- * these automatically, but React/headless code hands them to `setAnswer` by
4
- * hand — and shipping a bare label string where a structured state belongs is
5
- * the classic production 400 (2026-08 field run). These local types mirror
6
- * each component's wire schema and are contract-tested against
7
- * `@surface/types` (dev dependency only — the SDK ships zero runtime deps).
8
- *
9
- * `setAnswer` itself stays structurally typed (`Record<string, unknown>`):
10
- * legacy component types not listed here remain settable, and answers merge
11
- * per question, so partial patches are legal. Annotate call sites with these
12
- * types to get the compiler's help.
13
- */
1
+
14
2
  export type ShortInputAnswer = {
15
3
  type: "ShortInput";
16
4
  input: string;
@@ -36,7 +24,7 @@ export type FileUploaderAnswer = {
36
24
  type: "FileUploader";
37
25
  fileUrl?: string;
38
26
  };
39
- /** The ENTIRE option list, one entry per record option — never only the picked one. */
27
+
40
28
  export type MultipleOptionsAnswer = {
41
29
  type: "MultipleOptionsQuestion";
42
30
  choices: Array<{
@@ -70,13 +58,13 @@ export type MultipleChoiceSingleAnswerAnswer = {
70
58
  value: string;
71
59
  index: number;
72
60
  };
73
- /** Canonical IdentityInfo answer keys (mirrors IdentityInfoKeysArray; contract-tested). */
61
+
74
62
  export declare const IDENTITY_INFO_ANSWER_KEYS: readonly ["firstName", "lastName", "fullName", "emailAddress", "workEmailAddress", "phoneNumber", "companyName", "numberOfEmployees", "websiteUrl", "title", "streetAddress", "aptSuiteEtc", "city", "state", "country", "zipCode", "companyRevenue", "profilePictureUrl"];
75
63
  export type IdentityInfoAnswerKey = (typeof IDENTITY_INFO_ANSWER_KEYS)[number];
76
64
  export type IdentityInfoAnswer = {
77
65
  type: "IdentityInfo";
78
66
  } & Partial<Record<IdentityInfoAnswerKey, string>>;
79
- /** Booking answers; `toSchedulerAnswerState` produces this — override `type` to the record's component type. */
67
+
80
68
  export type SchedulerAnswer = {
81
69
  type: "CalendlyScreen" | "DynamicScheduler";
82
70
  eventScheduled: boolean;
@@ -89,4 +77,3 @@ export type SchedulerAnswer = {
89
77
  googleMeetLink?: string;
90
78
  };
91
79
  export type KnownAnswerState = ShortInputAnswer | LongInputAnswer | EmailFormAnswer | DropdownAnswer | DisclaimerAnswer | FileUploaderAnswer | MultipleOptionsAnswer | MMChoiceAnswer | MultipleChoiceAnswer | GraphicOptionsAnswer | MultipleChoiceSingleAnswerAnswer | IdentityInfoAnswer | SchedulerAnswer;
92
- //# sourceMappingURL=answerStates.d.ts.map
@@ -3,37 +3,8 @@ import { type Unsubscribe } from "../events/emitter";
3
3
  import type { FormJourneyTracker, FormJourneyTransitionReason } from "../events/formJourneyTracker";
4
4
  import { type PushEventClient } from "../events/pushEvents";
5
5
  import { type AnswerStates, type ExternalStates } from "./responsePayload";
6
- /**
7
- * The headless step engine (forms-sdk-plan.md §2.2): answers, traversal,
8
- * response writes, and lifecycle events over the modules this stack built.
9
- * Native semantics preserved:
10
- *
11
- * - **Partial saves on forward step change only** (row 23): first forward
12
- * move creates the response, later moves update it, and every write sends
13
- * the id of the step being *left* — all gated by
14
- * `settings.trackPartialResponses` except the finishing write, which always
15
- * happens.
16
- * - **Finished/invalid derivation** (row 27): a resolved next step of
17
- * `"END"`/`"INVALID"`/`undefined` finishes the form; `"INVALID"`
18
- * disqualifies.
19
- * - **Step transition events** (row 31): the `form_step_submitted` +
20
- * `form_step_viewed` batch with `stepCompletionTime` in seconds since the
21
- * engine was created (native's `initialRenderTime`), skipped when the form
22
- * finishes (native returns before emitting on `"END"`).
23
- * - `markViewed` mirrors native's view actions: `form_viewed` + first-step
24
- * `form_step_viewed`, once.
25
- * - Backward navigation never writes (native only re-arms `stepIdToSubmit`).
26
- *
27
- * **The engine does not evaluate routing** (Decisions #6): the customer's own
28
- * code owns navigation. `next()`/`back()` are linear conveniences,
29
- * `goToStep()` is the explicit move — forward jumps carry full forward
30
- * semantics (step events, journey transition, partial write), jumps to an
31
- * already-visited step rewind like `back()` (no write). Disqualification is
32
- * the explicit `disqualify()` verb — in native it was a routing outcome (the
33
- * `INVALID` sentinel), so without routing it needs its own API. The pluggable
34
- * `resolveNextStep` remains as the headless hook for callers who express
35
- * their routing as a resolver instead of imperative `goToStep` calls.
36
- */
6
+ import type { SchedulerLifecycleEvent } from "./schedulerEvents";
7
+
37
8
  export type ResolvedNextStep = {
38
9
  stepId: string;
39
10
  reason?: FormJourneyTransitionReason;
@@ -68,34 +39,37 @@ export type FormEngineEvents = {
68
39
  scope: "submit";
69
40
  error: unknown;
70
41
  };
42
+ scheduler: SchedulerLifecycleEvent;
71
43
  };
72
44
  export type FormEngineState = {
73
45
  currentStepId: string;
74
46
  answers: AnswerStates;
75
- /** Pseudo-answer states riding every write (URL_DATA attribution, enrichment results, …). */
47
+
76
48
  externalStates: ExternalStates;
77
49
  responseId: string | null;
78
- /** From the create reply; with the responseId it authorizes a later resume (persist both). */
50
+
79
51
  resumeToken: string | null;
80
52
  finished: boolean;
81
53
  };
82
54
  export type FormEngine = {
83
55
  setAnswer: (questionId: string, state: Record<string, unknown>) => void;
84
- /** Writes a pseudo-answer external state (enrichment results, custom attribution) that rides every subsequent save. */
56
+
85
57
  setExternalState: (id: string, state: {
86
58
  type: string;
87
59
  } & Record<string, unknown>) => void;
88
- /** Merges keys into the response `meta` object carried by every subsequent save (post-finish it amends the stored response). */
60
+
89
61
  mergeMeta: (partial: Record<string, unknown>) => void;
90
62
  next: () => Promise<void>;
91
63
  back: () => void;
92
- /** Customer-owned navigation (Decisions #6): forward jumps save like next(), visited-step jumps rewind like back(). */
64
+
93
65
  goToStep: (stepId: string) => Promise<void>;
94
66
  submit: () => Promise<void>;
95
- /** Finishes the form as disqualified (`invalidResponse: true`) — the explicit replacement for native's INVALID routing outcome. */
67
+
96
68
  disqualify: () => Promise<void>;
97
69
  savePartial: () => Promise<void>;
98
- /** Resolves when every write queued so far has settled — await it before tearing the page down (test harnesses, SPA unmounts). */
70
+
71
+ notifyScheduler: (event: SchedulerLifecycleEvent) => void;
72
+
99
73
  flush: () => Promise<void>;
100
74
  markViewed: () => void;
101
75
  on: <K extends keyof FormEngineEvents>(event: K, handler: (payload: FormEngineEvents[K]) => void) => Unsubscribe;
@@ -105,7 +79,7 @@ export type FormEngine = {
105
79
  export declare const createFormEngine: ({ formId, environmentId, steps, transport, resolveNextStep, trackPartialResponses, trackCookies, externalStates, meta, identity, pushEvents, formJourney, preview, resume, }: {
106
80
  formId: string;
107
81
  environmentId?: string;
108
- /** Ordered logical steps of the form record (the data contract). */
82
+
109
83
  steps: Array<{
110
84
  id: string;
111
85
  endStepKind?: "thank_you" | "disqualified";
@@ -116,11 +90,7 @@ export declare const createFormEngine: ({ formId, environmentId, steps, transpor
116
90
  trackCookies?: boolean;
117
91
  externalStates?: ExternalStates;
118
92
  meta?: Record<string, unknown>;
119
- /**
120
- * Read at every write/event, not captured at construction — a re-identify
121
- * (SurfaceForm.identify after cache expiry) must attribute subsequent
122
- * responses and events to the current visitor, not the boot-time one.
123
- */
93
+
124
94
  identity?: () => {
125
95
  fingerprint?: string;
126
96
  leadSessionId?: string;
@@ -128,18 +98,11 @@ export declare const createFormEngine: ({ formId, environmentId, steps, transpor
128
98
  };
129
99
  pushEvents?: PushEventClient;
130
100
  formJourney?: FormJourneyTracker;
131
- /** Preview mode never writes (§2.2): traversal and events run, responses are never created. */
101
+
132
102
  preview?: boolean;
133
- /**
134
- * Resume a stored response (row 28): the seeded responseId turns every write
135
- * into an update (no duplicate row), and the seeded answers ride along in
136
- * the full-answer-set resend. Answers are keyed by questionId and seeded
137
- * under the first step — the wire flattens steps, and presentation (which
138
- * step to show) is the caller's own navigation.
139
- */
103
+
140
104
  resume?: {
141
105
  responseId: string;
142
106
  answers?: Record<string, Record<string, unknown>>;
143
107
  };
144
108
  }) => FormEngine;
145
- //# sourceMappingURL=formEngine.d.ts.map
@@ -1,25 +1,4 @@
1
- /**
2
- * Redirect handling (forms-sdk-plan.md rows 17/48), mirroring form-render's
3
- * `handleRedirect.ts`:
4
- *
5
- * - Identity handoff: `leadId` and `sessionId` are appended as query params so
6
- * the destination page's tag/SDK resolves the same visitor (row 17).
7
- * - Protocol default matches `addProtocolToUrl` verbatim, including its quirk:
8
- * the check is `startsWith("https")`, so an explicit `http://` URL gets
9
- * double-prefixed. Replicated, not fixed — it's on the plan's
10
- * replicate-then-review list territory (Phase 0 item 5); the parity harness
11
- * compares against native.
12
- * - Unparseable URLs pass through unchanged, blank URLs redirect nowhere.
13
- * - `CurrentWindow` navigates `window.location` — the SDK runs first-party,
14
- * which is exactly what native's `window.parent.location` resolves to on a
15
- * top-level page. `NewTab` opens `_blank`.
16
- * - Preview never navigates (native gates on preview/editing screens).
17
- *
18
- * The step engine owns *when* to redirect (per-step + thank-you triggers and
19
- * the `redirectTimeout ?? 400 ms` delay — the default is exported here);
20
- * parent-param forwarding via `redirectUrlParams` templating lands with the
21
- * external-state store work (row 56).
22
- */
1
+
23
2
  export type RedirectType = "NewTab" | "CurrentWindow";
24
3
  export declare const DEFAULT_REDIRECT_TIMEOUT_MS = 400;
25
4
  export declare const buildRedirectUrl: (url: string, { leadId, sessionId }?: {
@@ -33,4 +12,3 @@ export declare const performRedirect: ({ url, redirectType, leadId, sessionId, p
33
12
  sessionId?: string;
34
13
  preview?: boolean;
35
14
  }) => void;
36
- //# sourceMappingURL=redirect.d.ts.map
@@ -1,34 +1,11 @@
1
- /**
2
- * Response payload builders (forms-sdk-plan.md rows 24-26), mirroring
3
- * form-render's `createResponseApiPayload` exactly — the semantics here are
4
- * load-bearing server contracts:
5
- *
6
- * - **Full answer-set resend on every write** (row 26): all steps' answers
7
- * plus every external-state entry as a pseudo-answer keyed by its stateId.
8
- * Server-side UTM preservation depends on the URL_DATA entry riding every
9
- * update.
10
- * - `SCHEDULER_AVAILABILITY_DATA` entries are transient client-only data and
11
- * are never persisted.
12
- * - Surface-native booking detection: the first answer with
13
- * `eventScheduled: true` and a non-Calendly/Cal.com `uri` stamps
14
- * `meta.bookingId`.
15
- * - `enrichedFields` precedence: person-attribute enrichment wins over the
16
- * processed APOLLO_EMAIL_ENRICHMENT external state, `{}` as the floor.
17
- * - `meta.cookies` is stripped when `trackCookies` is off.
18
- * - Creates pin `responseShapeVersion: "2.0"`; updates carry `responseId`.
19
- *
20
- * Types are local structural mirrors of `ZFormResponseData` /
21
- * `ZFormUpdateResponseData` (zero-runtime-deps); the contract test validates
22
- * built payloads against the real schemas. Answer/external-state entry shapes
23
- * are pass-through records — component state shapes belong to the engine.
24
- */
1
+
25
2
  export type SingleFormResponse = {
26
3
  questionId: string;
27
4
  response: Record<string, unknown>;
28
5
  };
29
- /** Answers grouped per step, keyed stepId → questionId → component state. */
6
+
30
7
  export type AnswerStates = Record<string, Record<string, Record<string, unknown>>>;
31
- /** External state entries keyed by stateId; `type` discriminates (URL_DATA, enrichment, …). */
8
+
32
9
  export type ExternalStates = Record<string, {
33
10
  type: string;
34
11
  } & Record<string, unknown>>;
@@ -61,7 +38,7 @@ type BuildPayloadOptions = {
61
38
  invalidResponse: boolean;
62
39
  trackCookies: boolean;
63
40
  meta?: Record<string, unknown>;
64
- /** Person-attribute enrichment; wins over external-state enrichment like native. */
41
+
65
42
  personAttributeEnrichedFields?: Record<string, unknown>;
66
43
  fingerprint?: string;
67
44
  leadSessionId?: string;
@@ -71,4 +48,3 @@ export declare const createUpdateResponsePayload: (options: BuildPayloadOptions
71
48
  responseId: string;
72
49
  }) => FormUpdateResponsePayload;
73
50
  export {};
74
- //# sourceMappingURL=responsePayload.d.ts.map
@@ -0,0 +1,40 @@
1
+
2
+
3
+ export type SchedulerProvider = "Surface" | "Calendly" | "Hubspot" | "Cal" | "SavvyCal" | "RevenueHero" | "ReclaimAI" | "Clari" | "ChiliCal" | "Zoom";
4
+ export type SchedulerBookingSummary = {
5
+ provider: SchedulerProvider;
6
+
7
+ uri: string;
8
+ meetingTime?: string;
9
+ meetingEndTime?: string;
10
+ inviteeName?: string;
11
+ guestEmails?: string;
12
+ ownerEmails?: string;
13
+ joinLink?: string;
14
+
15
+ raw?: unknown;
16
+ };
17
+ export type SchedulerLifecycleEvent = {
18
+ questionId: string;
19
+ stepId: string;
20
+ provider: SchedulerProvider;
21
+ } & ({
22
+ type: "viewed";
23
+ } | {
24
+ type: "date_selected";
25
+ date?: string;
26
+ } | {
27
+ type: "slot_selected";
28
+ slot?: {
29
+ start: string;
30
+ end?: string;
31
+ };
32
+ } | {
33
+ type: "form_opened";
34
+ } | {
35
+ type: "booking_confirmed";
36
+ booking: SchedulerBookingSummary;
37
+ } | {
38
+ type: "booking_cancelled";
39
+ reason?: string;
40
+ });