@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.
- package/README.md +9 -4
- package/dist/index.cjs +1 -2737
- package/dist/index.mjs +1 -2714
- package/dist/react/index.cjs +1 -44
- package/dist/react/index.mjs +1 -21
- package/dist/surface-forms-sdk.min.js +21 -2
- package/dist/types/bind/bindForm.d.ts +2 -36
- package/dist/types/bind/bookingWidget.d.ts +29 -17
- package/dist/types/bind/scheduler/embedUtils.d.ts +50 -0
- package/dist/types/bind/scheduler/mountScheduler.d.ts +2 -0
- package/dist/types/bind/scheduler/providers/cal.d.ts +3 -0
- package/dist/types/bind/scheduler/providers/calendly.d.ts +3 -0
- package/dist/types/bind/scheduler/providers/chilical.d.ts +3 -0
- package/dist/types/bind/scheduler/providers/clari.d.ts +3 -0
- package/dist/types/bind/scheduler/providers/hubspot.d.ts +3 -0
- package/dist/types/bind/scheduler/providers/index.d.ts +4 -0
- package/dist/types/bind/scheduler/providers/reclaimai.d.ts +3 -0
- package/dist/types/bind/scheduler/providers/revenuehero.d.ts +3 -0
- package/dist/types/bind/scheduler/providers/savvycal.d.ts +3 -0
- package/dist/types/bind/scheduler/providers/surface.d.ts +3 -0
- package/dist/types/bind/scheduler/providers/zoom.d.ts +3 -0
- package/dist/types/bind/scheduler/styles.d.ts +3 -0
- package/dist/types/bind/scheduler/types.d.ts +65 -0
- package/dist/types/core/client/emailValidation.d.ts +3 -4
- package/dist/types/core/client/responses.d.ts +3 -15
- package/dist/types/core/client/runtimeConfig.d.ts +40 -32
- package/dist/types/core/client/scheduler.d.ts +4 -27
- package/dist/types/core/client/transport.d.ts +4 -28
- package/dist/types/core/engine/answerAudit.d.ts +3 -12
- package/dist/types/core/engine/answerStates.d.ts +4 -17
- package/dist/types/core/engine/formEngine.d.ts +16 -53
- package/dist/types/core/engine/redirect.d.ts +1 -23
- package/dist/types/core/engine/responsePayload.d.ts +4 -28
- package/dist/types/core/engine/schedulerEvents.d.ts +40 -0
- package/dist/types/core/engine/urlData.d.ts +2 -17
- package/dist/types/core/engine/urlPrefill.d.ts +1 -9
- package/dist/types/core/events/dropoffDetection.d.ts +1 -14
- package/dist/types/core/events/emitter.d.ts +1 -17
- package/dist/types/core/events/formJourneyTracker.d.ts +1 -19
- package/dist/types/core/events/pushEvents.d.ts +2 -16
- package/dist/types/core/events/startedDetection.d.ts +1 -10
- package/dist/types/core/events/viewDetection.d.ts +1 -14
- package/dist/types/core/identity/browserFingerprint.d.ts +3 -19
- package/dist/types/core/identity/ensureIdentified.d.ts +1 -16
- package/dist/types/core/identity/identify.d.ts +1 -15
- package/dist/types/core/identity/journey.d.ts +3 -16
- package/dist/types/core/identity/journey.testStubs.d.ts +1 -2
- package/dist/types/core/identity/leadDataCache.d.ts +1 -16
- package/dist/types/enrichment/attachEnrichment.d.ts +1 -21
- package/dist/types/index.d.ts +5 -3
- package/dist/types/react/index.d.ts +0 -1
- package/dist/types/react/useSurfaceForm.d.ts +1 -11
- package/dist/types/surfaceForms.d.ts +28 -73
- package/dist/types/tracking/attachTracking.d.ts +1 -22
- package/dist/types/tracking/conversionRules.d.ts +3 -12
- package/dist/types/tracking/vendors.d.ts +3 -22
- package/dist/types/validation/attachEmailValidation.d.ts +0 -1
- package/docs/api.md +51 -39
- package/docs/reference/binding.md +86 -13
- package/docs/reference/clients.md +21 -1
- package/docs/reference/engine.md +5 -1
- package/docs/reference/events.md +4 -1
- package/docs/reference/identity.md +2 -3
- package/llms.txt +58 -10
- package/package.json +1 -1
- package/skills/surface-forms-sdk/SKILL.md +19 -6
- package/skills/surface-forms-sdk/patterns.md +30 -5
- package/dist/index.cjs.map +0 -7
- package/dist/index.mjs.map +0 -7
- package/dist/react/index.cjs.map +0 -7
- package/dist/react/index.mjs.map +0 -7
- package/dist/surface-forms-sdk.min.js.map +0 -7
- package/dist/types/bind/bindForm.d.ts.map +0 -1
- package/dist/types/bind/bindForm.test.d.ts +0 -2
- package/dist/types/bind/bindForm.test.d.ts.map +0 -1
- package/dist/types/bind/bookingWidget.d.ts.map +0 -1
- package/dist/types/bind/bookingWidget.test.d.ts +0 -2
- package/dist/types/bind/bookingWidget.test.d.ts.map +0 -1
- package/dist/types/core/client/emailValidation.d.ts.map +0 -1
- package/dist/types/core/client/emailValidation.test.d.ts +0 -2
- package/dist/types/core/client/emailValidation.test.d.ts.map +0 -1
- package/dist/types/core/client/responses.d.ts.map +0 -1
- package/dist/types/core/client/responses.test.d.ts +0 -2
- package/dist/types/core/client/responses.test.d.ts.map +0 -1
- package/dist/types/core/client/runtimeConfig.contract.test.d.ts +0 -2
- package/dist/types/core/client/runtimeConfig.contract.test.d.ts.map +0 -1
- package/dist/types/core/client/runtimeConfig.d.ts.map +0 -1
- package/dist/types/core/client/runtimeConfig.test.d.ts +0 -2
- package/dist/types/core/client/runtimeConfig.test.d.ts.map +0 -1
- package/dist/types/core/client/scheduler.contract.test.d.ts +0 -2
- package/dist/types/core/client/scheduler.contract.test.d.ts.map +0 -1
- package/dist/types/core/client/scheduler.d.ts.map +0 -1
- package/dist/types/core/client/scheduler.test.d.ts +0 -2
- package/dist/types/core/client/scheduler.test.d.ts.map +0 -1
- package/dist/types/core/client/transport.d.ts.map +0 -1
- package/dist/types/core/client/transport.test.d.ts +0 -2
- package/dist/types/core/client/transport.test.d.ts.map +0 -1
- package/dist/types/core/engine/answerAudit.d.ts.map +0 -1
- package/dist/types/core/engine/answerAudit.test.d.ts +0 -2
- package/dist/types/core/engine/answerAudit.test.d.ts.map +0 -1
- package/dist/types/core/engine/answerStates.contract.test.d.ts +0 -2
- package/dist/types/core/engine/answerStates.contract.test.d.ts.map +0 -1
- package/dist/types/core/engine/answerStates.d.ts.map +0 -1
- package/dist/types/core/engine/formEngine.d.ts.map +0 -1
- package/dist/types/core/engine/formEngine.test.d.ts +0 -2
- package/dist/types/core/engine/formEngine.test.d.ts.map +0 -1
- package/dist/types/core/engine/redirect.d.ts.map +0 -1
- package/dist/types/core/engine/redirect.test.d.ts +0 -2
- package/dist/types/core/engine/redirect.test.d.ts.map +0 -1
- package/dist/types/core/engine/responsePayload.contract.test.d.ts +0 -2
- package/dist/types/core/engine/responsePayload.contract.test.d.ts.map +0 -1
- package/dist/types/core/engine/responsePayload.d.ts.map +0 -1
- package/dist/types/core/engine/responsePayload.test.d.ts +0 -2
- package/dist/types/core/engine/responsePayload.test.d.ts.map +0 -1
- package/dist/types/core/engine/urlData.contract.test.d.ts +0 -2
- package/dist/types/core/engine/urlData.contract.test.d.ts.map +0 -1
- package/dist/types/core/engine/urlData.d.ts.map +0 -1
- package/dist/types/core/engine/urlData.test.d.ts +0 -2
- package/dist/types/core/engine/urlData.test.d.ts.map +0 -1
- package/dist/types/core/engine/urlPrefill.d.ts.map +0 -1
- package/dist/types/core/engine/urlPrefill.test.d.ts +0 -2
- package/dist/types/core/engine/urlPrefill.test.d.ts.map +0 -1
- package/dist/types/core/events/dropoffDetection.d.ts.map +0 -1
- package/dist/types/core/events/dropoffDetection.test.d.ts +0 -2
- package/dist/types/core/events/dropoffDetection.test.d.ts.map +0 -1
- package/dist/types/core/events/emitter.d.ts.map +0 -1
- package/dist/types/core/events/emitter.test.d.ts +0 -2
- package/dist/types/core/events/emitter.test.d.ts.map +0 -1
- package/dist/types/core/events/formJourneyTracker.contract.test.d.ts +0 -2
- package/dist/types/core/events/formJourneyTracker.contract.test.d.ts.map +0 -1
- package/dist/types/core/events/formJourneyTracker.d.ts.map +0 -1
- package/dist/types/core/events/formJourneyTracker.test.d.ts +0 -2
- package/dist/types/core/events/formJourneyTracker.test.d.ts.map +0 -1
- package/dist/types/core/events/pushEvents.contract.test.d.ts +0 -2
- package/dist/types/core/events/pushEvents.contract.test.d.ts.map +0 -1
- package/dist/types/core/events/pushEvents.d.ts.map +0 -1
- package/dist/types/core/events/pushEvents.test.d.ts +0 -2
- package/dist/types/core/events/pushEvents.test.d.ts.map +0 -1
- package/dist/types/core/events/startedDetection.d.ts.map +0 -1
- package/dist/types/core/events/startedDetection.test.d.ts +0 -2
- package/dist/types/core/events/startedDetection.test.d.ts.map +0 -1
- package/dist/types/core/events/viewDetection.d.ts.map +0 -1
- package/dist/types/core/events/viewDetection.test.d.ts +0 -2
- package/dist/types/core/events/viewDetection.test.d.ts.map +0 -1
- package/dist/types/core/identity/browserFingerprint.d.ts.map +0 -1
- package/dist/types/core/identity/browserFingerprint.test.d.ts +0 -2
- package/dist/types/core/identity/browserFingerprint.test.d.ts.map +0 -1
- package/dist/types/core/identity/ensureIdentified.d.ts.map +0 -1
- package/dist/types/core/identity/ensureIdentified.test.d.ts +0 -2
- package/dist/types/core/identity/ensureIdentified.test.d.ts.map +0 -1
- package/dist/types/core/identity/identify.contract.test.d.ts +0 -2
- package/dist/types/core/identity/identify.contract.test.d.ts.map +0 -1
- package/dist/types/core/identity/identify.d.ts.map +0 -1
- package/dist/types/core/identity/identify.test.d.ts +0 -2
- package/dist/types/core/identity/identify.test.d.ts.map +0 -1
- package/dist/types/core/identity/journey.contract.test.d.ts +0 -2
- package/dist/types/core/identity/journey.contract.test.d.ts.map +0 -1
- package/dist/types/core/identity/journey.d.ts.map +0 -1
- package/dist/types/core/identity/journey.test.d.ts +0 -2
- package/dist/types/core/identity/journey.test.d.ts.map +0 -1
- package/dist/types/core/identity/journey.testStubs.d.ts.map +0 -1
- package/dist/types/core/identity/leadDataCache.d.ts.map +0 -1
- package/dist/types/core/identity/leadDataCache.test.d.ts +0 -2
- package/dist/types/core/identity/leadDataCache.test.d.ts.map +0 -1
- package/dist/types/enrichment/attachEnrichment.d.ts.map +0 -1
- package/dist/types/enrichment/attachEnrichment.test.d.ts +0 -2
- package/dist/types/enrichment/attachEnrichment.test.d.ts.map +0 -1
- package/dist/types/index.d.ts.map +0 -1
- package/dist/types/react/index.d.ts.map +0 -1
- package/dist/types/react/ssr.test.d.ts +0 -2
- package/dist/types/react/ssr.test.d.ts.map +0 -1
- package/dist/types/react/useSurfaceForm.d.ts.map +0 -1
- package/dist/types/react/useSurfaceForm.test.d.ts +0 -2
- package/dist/types/react/useSurfaceForm.test.d.ts.map +0 -1
- package/dist/types/surfaceForms.d.ts.map +0 -1
- package/dist/types/surfaceForms.test.d.ts +0 -2
- package/dist/types/surfaceForms.test.d.ts.map +0 -1
- package/dist/types/tracking/attachTracking.d.ts.map +0 -1
- package/dist/types/tracking/attachTracking.test.d.ts +0 -2
- package/dist/types/tracking/attachTracking.test.d.ts.map +0 -1
- package/dist/types/tracking/conversionRules.contract.test.d.ts +0 -2
- package/dist/types/tracking/conversionRules.contract.test.d.ts.map +0 -1
- package/dist/types/tracking/conversionRules.d.ts.map +0 -1
- package/dist/types/tracking/conversionRules.test.d.ts +0 -2
- package/dist/types/tracking/conversionRules.test.d.ts.map +0 -1
- package/dist/types/tracking/vendors.d.ts.map +0 -1
- package/dist/types/tracking/vendors.test.d.ts +0 -2
- package/dist/types/tracking/vendors.test.d.ts.map +0 -1
- package/dist/types/validation/attachEmailValidation.d.ts.map +0 -1
- package/dist/types/validation/attachEmailValidation.test.d.ts +0 -2
- package/dist/types/validation/attachEmailValidation.test.d.ts.map +0 -1
|
@@ -1,18 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
* Attribution capture (forms-sdk-plan.md row 56): the `URL_DATA`
|
|
3
|
-
* external-state entry that rides every response write and feeds UTM/source
|
|
4
|
-
* attribution. Mirrors the URL-config branch of form-render's
|
|
5
|
-
* `buildExternalStateStore` — same shape (`fullUrl`/`params`/`referrer`/
|
|
6
|
-
* `cookies`, wire-validated against `ZURLData` in the contract test), same
|
|
7
|
-
* `defaultUrl` precedence, same swallow-on-malformed behavior.
|
|
8
|
-
*
|
|
9
|
-
* One structural simplification the self-hosted model earns (plan §4.1): the
|
|
10
|
-
* SDK runs in the page it measures, so `fullUrl`/`referrer`/`cookies` are
|
|
11
|
-
* read directly from `location`/`document` — native needs them relayed
|
|
12
|
-
* through `?url=`/`?referrer=`/`?cookies=` query params by the tag, including
|
|
13
|
-
* cookies as a JSON blob. Cookie capture stays gated by the same
|
|
14
|
-
* `trackCookies` setting.
|
|
15
|
-
*/
|
|
1
|
+
|
|
16
2
|
export type UrlData = {
|
|
17
3
|
type: "URL_DATA";
|
|
18
4
|
fullUrl?: string;
|
|
@@ -23,8 +9,7 @@ export type UrlData = {
|
|
|
23
9
|
export declare const constructUrlParamsObject: (url: string) => Record<string, string>;
|
|
24
10
|
export declare const parseCookiesObject: (cookieString: string) => Record<string, string>;
|
|
25
11
|
export declare const buildUrlData: ({ defaultUrl, trackCookies, }?: {
|
|
26
|
-
|
|
12
|
+
|
|
27
13
|
defaultUrl?: string;
|
|
28
14
|
trackCookies?: boolean;
|
|
29
15
|
}) => UrlData;
|
|
30
|
-
//# sourceMappingURL=urlData.d.ts.map
|
|
@@ -1,11 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
* URL prefill parsing (forms-sdk-plan.md row 19), same syntax as the native
|
|
3
|
-
* runtime's `useFormUrlParameters`/`parseQuestionId`: any
|
|
4
|
-
* `?<questionId>_<fieldName>=value` query param prefills a field. The param
|
|
5
|
-
* name splits on the FIRST underscore (field names may contain more), both
|
|
6
|
-
* sides are trimmed, `url`/`referrer`/`cookies` are reserved for attribution,
|
|
7
|
-
* and params without an underscore are ignored (no field to target).
|
|
8
|
-
*/
|
|
1
|
+
|
|
9
2
|
export type ParsedUrlQuestionId = {
|
|
10
3
|
originalId: string;
|
|
11
4
|
questionId: string;
|
|
@@ -18,4 +11,3 @@ export declare const parseQuestionId: (input: string) => {
|
|
|
18
11
|
fieldName: string | null;
|
|
19
12
|
};
|
|
20
13
|
export declare const parsePrefillParams: (search: string | URLSearchParams) => Record<string, ParsedUrlQuestionId[]> | null;
|
|
21
|
-
//# sourceMappingURL=urlPrefill.d.ts.map
|
|
@@ -1,21 +1,8 @@
|
|
|
1
1
|
import type { PushEventClient } from "./pushEvents";
|
|
2
|
-
|
|
3
|
-
* `form_step_dropoff` beacon (forms-sdk-plan.md row 32), form-render's
|
|
4
|
-
* `useBeforeUnload` semantics without React: on `pagehide` — the only
|
|
5
|
-
* teardown event that still delivers beacons reliably — emit the drop-off
|
|
6
|
-
* event for the step the visitor abandoned, but only after the form was
|
|
7
|
-
* started and never for bfcache suspensions (`event.persisted`), which are
|
|
8
|
-
* not abandonment.
|
|
9
|
-
*
|
|
10
|
-
* State is read through a getter at fire time because the current step and
|
|
11
|
-
* session change after the listener attaches (native reads refs for the same
|
|
12
|
-
* reason). Delivery rides the pushEvent client, whose transport is
|
|
13
|
-
* sendBeacon-first — the property that makes a pagehide send survivable.
|
|
14
|
-
*/
|
|
2
|
+
|
|
15
3
|
export declare const observeDropoff: (pushEventClient: PushEventClient, getState: () => {
|
|
16
4
|
started: boolean;
|
|
17
5
|
formId: string;
|
|
18
6
|
stepId: string;
|
|
19
7
|
sessionId?: string;
|
|
20
8
|
}) => (() => void);
|
|
21
|
-
//# sourceMappingURL=dropoffDetection.d.ts.map
|
|
@@ -1,23 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
* Instance-scoped typed event emitter — the primitive behind the SDK's
|
|
3
|
-
* public `form.on(...)` lifecycle surface (forms-sdk-plan.md §2.2) and the
|
|
4
|
-
* store-subscription contract adapters build on (§2.9).
|
|
5
|
-
*
|
|
6
|
-
* Exists because the SDK cannot use Node's EventEmitter (zero runtime deps,
|
|
7
|
-
* browser bundle) and must not reproduce form-render's module-level
|
|
8
|
-
* singleton listeners, which break multi-form pages (§2.7). Handler
|
|
9
|
-
* exceptions are isolated per handler: a throwing host callback never breaks
|
|
10
|
-
* the engine or sibling handlers — the never-break-the-host-page guarantee
|
|
11
|
-
* applied to the callback boundary.
|
|
12
|
-
*
|
|
13
|
-
* The concrete SDK event map (viewed/started/stepChanged/…) is owned by the
|
|
14
|
-
* step engine, which defines the payload shapes it emits; this module is
|
|
15
|
-
* deliberately payload-agnostic.
|
|
16
|
-
*/
|
|
1
|
+
|
|
17
2
|
export type Unsubscribe = () => void;
|
|
18
3
|
export type Emitter<TEventMap extends Record<string, unknown>> = {
|
|
19
4
|
on: <K extends keyof TEventMap>(event: K, handler: (payload: TEventMap[K]) => void) => Unsubscribe;
|
|
20
5
|
emit: <K extends keyof TEventMap>(event: K, payload: TEventMap[K]) => void;
|
|
21
6
|
};
|
|
22
7
|
export declare const createEmitter: <TEventMap extends Record<string, unknown>>() => Emitter<TEventMap>;
|
|
23
|
-
//# sourceMappingURL=emitter.d.ts.map
|
|
@@ -1,22 +1,5 @@
|
|
|
1
1
|
import type { Transport } from "../client/transport";
|
|
2
|
-
|
|
3
|
-
* Form-journey step telemetry (forms-sdk-plan.md row 30): visits, transitions,
|
|
4
|
-
* and outcomes beaconed to `POST /api/v1/form-journey/track`. A direct port of
|
|
5
|
-
* form-render's `createFormJourneyTracker` — same ordinal bookkeeping, same
|
|
6
|
-
* close-previous-visit timing, same 50-visit cap with `truncated`, same
|
|
7
|
-
* freeze-on-terminal-outcome, same microtask coalescing (a transition
|
|
8
|
-
* immediately followed by a terminal sends one beacon, so an in-progress
|
|
9
|
-
* write can't race the disqualified one), and the same synchronous flush for
|
|
10
|
-
* the `in_progress` terminal, which only fires from pagehide and cannot
|
|
11
|
-
* depend on a microtask racing page teardown.
|
|
12
|
-
*
|
|
13
|
-
* Wire types are local structural mirrors of the Zod schemas in
|
|
14
|
-
* `@surface/types/v1/formJourney` (zero-runtime-deps); the contract test
|
|
15
|
-
* validates them against the real `ZFormJourneyTrackPayload`. The
|
|
16
|
-
* `transitionMeta`/`matched` payloads are typed opaque here — they are
|
|
17
|
-
* constructed by routing evaluation, which lands with the routing extraction,
|
|
18
|
-
* and the tracker only passes them through.
|
|
19
|
-
*/
|
|
2
|
+
|
|
20
3
|
export type FormJourneyOutcome = "in_progress" | "completed" | "partial" | "disqualified" | "dropped_off";
|
|
21
4
|
export type FormJourneyTransitionReason = "initial" | "linear" | "conditional_match" | "default_fallback" | "prefill_jump" | "back_nav" | "auto_skip";
|
|
22
5
|
export type FormJourneyVisit = {
|
|
@@ -66,4 +49,3 @@ export declare const createFormJourneyTracker: ({ transport, preview, }: {
|
|
|
66
49
|
transport: Transport;
|
|
67
50
|
preview?: boolean;
|
|
68
51
|
}) => FormJourneyTracker;
|
|
69
|
-
//# sourceMappingURL=formJourneyTracker.d.ts.map
|
|
@@ -1,18 +1,5 @@
|
|
|
1
1
|
import type { Transport } from "../client/transport";
|
|
2
|
-
|
|
3
|
-
* Client for the internal event pipeline `POST /api/v1/pushEvent`
|
|
4
|
-
* (forms-sdk-plan.md row 33), mirroring form-render's `callPushEventApi`:
|
|
5
|
-
* same wire shapes, same client-side bot filter, same required-field guard
|
|
6
|
-
* (any invalid event drops the whole request), same beacon-first delivery.
|
|
7
|
-
* Two deliberate departures, both decided in the plan: no PostHog mirror
|
|
8
|
-
* (Surface-internal telemetry — §1D row 33) and a `preview` flag that blocks
|
|
9
|
-
* every send so agent preview loops never pollute data (§2.2).
|
|
10
|
-
*
|
|
11
|
-
* The wire types below are structural mirrors of the Zod schemas in
|
|
12
|
-
* `@surface/types/v1/surfaceEvent/model/types.ts` — local because the SDK
|
|
13
|
-
* ships with zero runtime dependencies; the contract test in this directory
|
|
14
|
-
* validates them against the real schemas.
|
|
15
|
-
*/
|
|
2
|
+
|
|
16
3
|
export type SurfaceEventType = "form_viewed" | "form_started" | "form_completed" | "form_step_viewed" | "form_step_submitted" | "form_step_dropoff" | "form_question_submitted" | "response_submission_created" | "response_submission_error" | "script_initiated";
|
|
17
4
|
export type SurfaceEventEntityType = "form" | "form_step" | "response";
|
|
18
5
|
export type PushEventProperty = {
|
|
@@ -29,7 +16,7 @@ export type PushEventPayload = {
|
|
|
29
16
|
leadId?: string;
|
|
30
17
|
environmentId?: string;
|
|
31
18
|
};
|
|
32
|
-
|
|
19
|
+
|
|
33
20
|
export type PushEventBatch = {
|
|
34
21
|
events: [
|
|
35
22
|
PushEventPayload & {
|
|
@@ -59,4 +46,3 @@ export declare const createPushEventClient: ({ transport, preview, }: {
|
|
|
59
46
|
transport: Transport;
|
|
60
47
|
preview?: boolean;
|
|
61
48
|
}) => PushEventClient;
|
|
62
|
-
//# sourceMappingURL=pushEvents.d.ts.map
|
|
@@ -1,11 +1,2 @@
|
|
|
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
|
-
*/
|
|
1
|
+
|
|
10
2
|
export declare const createStartedDetector: <T>(initial: T) => ((current: T) => boolean);
|
|
11
|
-
//# sourceMappingURL=startedDetection.d.ts.map
|
|
@@ -1,15 +1,2 @@
|
|
|
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
|
-
*/
|
|
1
|
+
|
|
14
2
|
export declare const observeFormView: (element: Element, onViewed: () => void) => (() => void);
|
|
15
|
-
//# sourceMappingURL=viewDetection.d.ts.map
|
|
@@ -1,19 +1,4 @@
|
|
|
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
|
-
*/
|
|
1
|
+
|
|
17
2
|
export type Fingerprint = {
|
|
18
3
|
deviceType: "Mobile" | "Desktop";
|
|
19
4
|
screen: {
|
|
@@ -28,13 +13,12 @@ export type Fingerprint = {
|
|
|
28
13
|
}>;
|
|
29
14
|
os: string;
|
|
30
15
|
language: string;
|
|
31
|
-
|
|
16
|
+
|
|
32
17
|
plugins?: string[];
|
|
33
18
|
timezone: string;
|
|
34
19
|
environmentId: string;
|
|
35
|
-
|
|
20
|
+
|
|
36
21
|
id: string;
|
|
37
22
|
};
|
|
38
23
|
export declare function getHash(input: string): Promise<string>;
|
|
39
24
|
export declare const getBrowserFingerprint: (environmentId: string) => Promise<Fingerprint>;
|
|
40
|
-
//# sourceMappingURL=browserFingerprint.d.ts.map
|
|
@@ -1,21 +1,7 @@
|
|
|
1
1
|
import type { Transport } from "../client/transport";
|
|
2
2
|
import { type LeadSource } from "./identify";
|
|
3
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
|
-
*/
|
|
4
|
+
|
|
19
5
|
export declare const ensureIdentified: ({ transport, environmentId, formId, pageUrl, source, preview, }: {
|
|
20
6
|
transport: Transport;
|
|
21
7
|
environmentId: string;
|
|
@@ -24,4 +10,3 @@ export declare const ensureIdentified: ({ transport, environmentId, formId, page
|
|
|
24
10
|
source?: LeadSource;
|
|
25
11
|
preview?: boolean;
|
|
26
12
|
}) => Promise<CachedLeadData | null>;
|
|
27
|
-
//# sourceMappingURL=ensureIdentified.d.ts.map
|
|
@@ -1,18 +1,5 @@
|
|
|
1
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
|
-
*/
|
|
2
|
+
|
|
16
3
|
export type LeadSource = "surfaceForm" | "htmlForm" | "websiteDeAnon" | "webhook" | "website" | "imported" | "scheduler" | "linkedin" | "sdkForm";
|
|
17
4
|
export type IdentifyPayload = {
|
|
18
5
|
environmentId: string;
|
|
@@ -45,4 +32,3 @@ export declare const buildIdentifyPayload: ({ environmentId, fingerprintId, page
|
|
|
45
32
|
referrer?: string | null;
|
|
46
33
|
}) => IdentifyPayload;
|
|
47
34
|
export declare const identifyLead: (transport: Transport, payload: IdentifyPayload) => Promise<IdentifyResult | null>;
|
|
48
|
-
//# sourceMappingURL=identify.d.ts.map
|
|
@@ -1,28 +1,15 @@
|
|
|
1
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
|
-
*/
|
|
2
|
+
|
|
15
3
|
export declare const JOURNEY_COOKIE_NAME = "surface_journey_id";
|
|
16
4
|
export declare const RECENT_VISIT_COOKIE_NAME = "surface_recent_visit";
|
|
17
5
|
export type JourneyTracker = {
|
|
18
6
|
trackPageView: (url?: string) => Promise<void>;
|
|
19
|
-
|
|
7
|
+
|
|
20
8
|
observeRouteChanges: () => () => void;
|
|
21
|
-
|
|
9
|
+
|
|
22
10
|
clear: () => void;
|
|
23
11
|
};
|
|
24
12
|
export declare const createJourneyTracker: ({ transport, environmentId, }: {
|
|
25
13
|
transport: Transport;
|
|
26
14
|
environmentId: string;
|
|
27
15
|
}) => JourneyTracker;
|
|
28
|
-
//# sourceMappingURL=journey.d.ts.map
|
|
@@ -1,18 +1,4 @@
|
|
|
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
|
-
*/
|
|
1
|
+
|
|
16
2
|
export declare const LEAD_DATA_STORAGE_KEY = "surfaceLeadData";
|
|
17
3
|
export declare const LEAD_DATA_TTL_MS: number;
|
|
18
4
|
export type CachedLeadData = {
|
|
@@ -24,4 +10,3 @@ export type CachedLeadData = {
|
|
|
24
10
|
};
|
|
25
11
|
export declare const readLeadData: () => CachedLeadData | null;
|
|
26
12
|
export declare const writeLeadData: (data: Omit<CachedLeadData, "expiry">) => void;
|
|
27
|
-
//# sourceMappingURL=leadDataCache.d.ts.map
|
|
@@ -1,25 +1,6 @@
|
|
|
1
1
|
import type { Transport } from "../core/client/transport";
|
|
2
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
|
-
*/
|
|
3
|
+
|
|
23
4
|
export type EnrichmentSource = {
|
|
24
5
|
questionId: string;
|
|
25
6
|
fieldNames: string[];
|
|
@@ -32,4 +13,3 @@ export type AttachEnrichmentOptions = {
|
|
|
32
13
|
sources: EnrichmentSource[];
|
|
33
14
|
};
|
|
34
15
|
export declare const attachEnrichment: ({ engine, transport, formId, sources, }: AttachEnrichmentOptions) => (() => void);
|
|
35
|
-
//# sourceMappingURL=attachEnrichment.d.ts.map
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
export { bindForm, type BindFormOptions } from "./bind/bindForm";
|
|
2
|
-
export { mountBookingWidget, type BookingWidgetOptions } from "./bind/bookingWidget";
|
|
2
|
+
export { mountBookingWidget, type BookingIdentity, type BookingWidgetEvent, type BookingWidgetOptions, } from "./bind/bookingWidget";
|
|
3
|
+
export { mountScheduler } from "./bind/scheduler/mountScheduler";
|
|
4
|
+
export { type MountSchedulerOptions } from "./bind/scheduler/types";
|
|
3
5
|
export { createEmailValidator, type CreateEmailValidatorOptions, type EmailValidationResult, type EmailValidator, } from "./core/client/emailValidation";
|
|
4
6
|
export { submitResponse, updateResponse, type CreateResponseResult } from "./core/client/responses";
|
|
5
|
-
export { enrichmentSourcesOf, fetchRuntimeConfig, hasEnabledEnrichmentProvider, statefulQuestionIdsOf, statefulQuestionsOf, stepsOf, type RuntimeConfig, } from "./core/client/runtimeConfig";
|
|
7
|
+
export { enrichmentSourcesOf, fetchRuntimeConfig, hasEnabledEnrichmentProvider, schedulerQuestionsOf, statefulQuestionIdsOf, statefulQuestionsOf, stepsOf, type RuntimeConfig, type SchedulerParamRef, type SchedulerQuestion, type SchedulerStateRef, } from "./core/client/runtimeConfig";
|
|
6
8
|
export { createSchedulerClient, toSchedulerAnswerState, type AvailabilitySummary, type Booking, type BookingAttendee, type SchedulerClient, type TimeSlot, } from "./core/client/scheduler";
|
|
7
9
|
export { DEFAULT_API_BASE_URL, createTransport, type Transport, type TransportError, type TransportResult, } from "./core/client/transport";
|
|
8
10
|
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
11
|
export { createFormEngine, type FormEngine, type FormEngineEvents, type FormEngineState, type ResolveNextStep, type ResolvedNextStep, } from "./core/engine/formEngine";
|
|
10
12
|
export { DEFAULT_REDIRECT_TIMEOUT_MS, buildRedirectUrl, performRedirect, type RedirectType, } from "./core/engine/redirect";
|
|
11
13
|
export { buildResponsesArray, createSubmitResponsePayload, createUpdateResponsePayload, type AnswerStates, type ExternalStates, type FormResponsePayload, type FormUpdateResponsePayload, type SingleFormResponse, } from "./core/engine/responsePayload";
|
|
14
|
+
export { type SchedulerBookingSummary, type SchedulerLifecycleEvent, type SchedulerProvider, } from "./core/engine/schedulerEvents";
|
|
12
15
|
export { buildUrlData, constructUrlParamsObject, parseCookiesObject, type UrlData, } from "./core/engine/urlData";
|
|
13
16
|
export { parsePrefillParams, parseQuestionId, type ParsedUrlQuestionId } from "./core/engine/urlPrefill";
|
|
14
17
|
export { observeDropoff } from "./core/events/dropoffDetection";
|
|
@@ -25,4 +28,3 @@ export { LEAD_DATA_STORAGE_KEY, LEAD_DATA_TTL_MS, readLeadData, writeLeadData, t
|
|
|
25
28
|
export { ENRICHMENT_STATE_ID, attachEnrichment, type AttachEnrichmentOptions, type EnrichmentSource, } from "./enrichment/attachEnrichment";
|
|
26
29
|
export { SurfaceForms, type SurfaceForm, type SurfaceFormsInitOptions } from "./surfaceForms";
|
|
27
30
|
export { attachEmailValidation, type AttachEmailValidationOptions } from "./validation/attachEmailValidation";
|
|
28
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1,14 +1,5 @@
|
|
|
1
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
|
-
*/
|
|
2
|
+
|
|
12
3
|
export type UseSurfaceFormResult = {
|
|
13
4
|
state: FormEngineState;
|
|
14
5
|
setAnswer: FormEngine["setAnswer"];
|
|
@@ -22,4 +13,3 @@ export type UseSurfaceFormResult = {
|
|
|
22
13
|
on: FormEngine["on"];
|
|
23
14
|
};
|
|
24
15
|
export declare const useSurfaceForm: (engine: FormEngine) => UseSurfaceFormResult;
|
|
25
|
-
//# sourceMappingURL=useSurfaceForm.d.ts.map
|
|
@@ -1,120 +1,75 @@
|
|
|
1
1
|
import { type EmailValidationResult } from "./core/client/emailValidation";
|
|
2
2
|
import { type RuntimeConfig } from "./core/client/runtimeConfig";
|
|
3
|
+
import { type Transport } from "./core/client/transport";
|
|
3
4
|
import { type FormEngine, type ResolveNextStep } from "./core/engine/formEngine";
|
|
4
5
|
import type { LeadSource } from "./core/identity/identify";
|
|
5
6
|
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
|
-
*/
|
|
7
|
+
|
|
23
8
|
export type SurfaceFormsInitOptions = {
|
|
24
9
|
environmentId: string;
|
|
25
10
|
formId: string;
|
|
26
|
-
|
|
11
|
+
|
|
27
12
|
steps?: Array<{
|
|
28
13
|
id: string;
|
|
29
14
|
endStepKind?: "thank_you" | "disqualified";
|
|
30
15
|
}>;
|
|
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
|
-
*/
|
|
16
|
+
|
|
37
17
|
settings?: {
|
|
38
18
|
trackPartialResponses?: boolean;
|
|
39
19
|
trackCookies?: boolean;
|
|
40
20
|
} & TrackingSettings;
|
|
41
21
|
apiBaseUrl?: string;
|
|
42
|
-
|
|
22
|
+
|
|
43
23
|
container?: Element;
|
|
44
|
-
|
|
24
|
+
|
|
45
25
|
expectedQuestionIds?: string[];
|
|
46
|
-
|
|
26
|
+
|
|
47
27
|
resolveNextStep?: ResolveNextStep;
|
|
48
|
-
|
|
28
|
+
|
|
49
29
|
urlDataStateId?: string;
|
|
50
30
|
source?: LeadSource;
|
|
51
|
-
|
|
31
|
+
|
|
52
32
|
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
|
-
*/
|
|
33
|
+
|
|
61
34
|
emailValidation?: boolean;
|
|
62
35
|
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
|
-
*/
|
|
36
|
+
|
|
68
37
|
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
|
-
*/
|
|
38
|
+
|
|
76
39
|
resume?: {
|
|
77
40
|
responseId: string;
|
|
78
41
|
resumeToken: string;
|
|
79
42
|
};
|
|
80
|
-
|
|
43
|
+
|
|
81
44
|
debug?: boolean;
|
|
82
45
|
meta?: Record<string, unknown>;
|
|
83
46
|
};
|
|
84
|
-
export type SurfaceForm = Pick<FormEngine, "setAnswer" | "setExternalState" | "next" | "back" | "goToStep" | "submit" | "disqualify" | "savePartial" | "flush" | "markViewed" | "on" | "state" | "subscribe"> & {
|
|
85
|
-
|
|
47
|
+
export type SurfaceForm = Pick<FormEngine, "setAnswer" | "setExternalState" | "next" | "back" | "goToStep" | "submit" | "disqualify" | "savePartial" | "notifyScheduler" | "flush" | "markViewed" | "on" | "state" | "subscribe"> & {
|
|
48
|
+
|
|
86
49
|
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
|
-
*/
|
|
50
|
+
|
|
94
51
|
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
|
-
*/
|
|
52
|
+
|
|
102
53
|
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
|
-
*/
|
|
54
|
+
|
|
108
55
|
capabilities: {
|
|
109
56
|
enrichment: boolean;
|
|
110
57
|
emailValidation: boolean;
|
|
111
58
|
tracking: boolean;
|
|
112
59
|
};
|
|
113
|
-
|
|
60
|
+
|
|
114
61
|
runtimeConfig?: RuntimeConfig;
|
|
62
|
+
|
|
63
|
+
transport: Transport;
|
|
64
|
+
|
|
65
|
+
identity: () => {
|
|
66
|
+
fingerprint?: string;
|
|
67
|
+
leadSessionId?: string;
|
|
68
|
+
leadId?: string;
|
|
69
|
+
};
|
|
70
|
+
preview: boolean;
|
|
115
71
|
destroy: () => void;
|
|
116
72
|
};
|
|
117
73
|
export declare const SurfaceForms: {
|
|
118
74
|
init: ({ environmentId, formId, steps, settings, apiBaseUrl, container, expectedQuestionIds, resolveNextStep, urlDataStateId, source, journey, emailValidation, preview, previewToken, debug, resume, meta, }: SurfaceFormsInitOptions) => Promise<SurfaceForm>;
|
|
119
75
|
};
|
|
120
|
-
//# sourceMappingURL=surfaceForms.d.ts.map
|
|
@@ -1,27 +1,7 @@
|
|
|
1
1
|
import type { FormEngine } from "../core/engine/formEngine";
|
|
2
2
|
import { type AdConversionRule } from "./conversionRules";
|
|
3
3
|
import { type VendorSettings } from "./vendors";
|
|
4
|
-
|
|
5
|
-
* Phase-2 tracking runtime (forms-sdk-plan.md rows 51–55): binds one engine
|
|
6
|
-
* instance to the customer-tag lifecycle events and the ad-conversion rule
|
|
7
|
-
* engine. Trigger moments mirror `useConversionRules`' semantics translated
|
|
8
|
-
* from React effects to engine events:
|
|
9
|
-
*
|
|
10
|
-
* - `form_started`: the response row landing (first `saved`) in a session that
|
|
11
|
-
* began without a responseId — a resume never refires.
|
|
12
|
-
* - `step_submitted`: the first `stepCompleted` of the session.
|
|
13
|
-
* - `reached_step`: every step that becomes current (including the initial
|
|
14
|
-
* one), once per step — back-nav never refires.
|
|
15
|
-
* - terminal (`reached_qualified` + `form_submitted` union, deduped by rule):
|
|
16
|
-
* the `completed` event; a disqualified finish never fires.
|
|
17
|
-
* - `email_provided` / `meeting_booked`: first non-empty email answer / first
|
|
18
|
-
* scheduler state with `eventScheduled` — detected via `subscribe`.
|
|
19
|
-
*
|
|
20
|
-
* Every rule fires once per instance; `responseId` stays the platform-side
|
|
21
|
-
* dedupe key, so moments reached before the first write queue and flush when
|
|
22
|
-
* `saved` delivers the id (native's pending-refs, minus the React plumbing).
|
|
23
|
-
* All state is instance-scoped (§2.7) — two forms on one page track separately.
|
|
24
|
-
*/
|
|
4
|
+
|
|
25
5
|
export type TrackingSettings = VendorSettings & {
|
|
26
6
|
adsConversions?: AdConversionRule[];
|
|
27
7
|
};
|
|
@@ -32,4 +12,3 @@ export type AttachTrackingOptions = {
|
|
|
32
12
|
win?: Window;
|
|
33
13
|
};
|
|
34
14
|
export declare const attachTracking: ({ engine, formId, settings, win }: AttachTrackingOptions) => (() => void);
|
|
35
|
-
//# sourceMappingURL=attachTracking.d.ts.map
|