@businessdash/sdk 0.9.60

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 (268) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +899 -0
  3. package/dist/adapters-revalidate.d.ts +44 -0
  4. package/dist/adapters-revalidate.d.ts.map +1 -0
  5. package/dist/adapters-revalidate.js +68 -0
  6. package/dist/adapters-revalidate.js.map +1 -0
  7. package/dist/alpha.d.ts +21 -0
  8. package/dist/alpha.d.ts.map +1 -0
  9. package/dist/alpha.js +21 -0
  10. package/dist/alpha.js.map +1 -0
  11. package/dist/analytics-core.d.ts +34 -0
  12. package/dist/analytics-core.d.ts.map +1 -0
  13. package/dist/analytics-core.js +138 -0
  14. package/dist/analytics-core.js.map +1 -0
  15. package/dist/analytics-server.d.ts +54 -0
  16. package/dist/analytics-server.d.ts.map +1 -0
  17. package/dist/analytics-server.js +78 -0
  18. package/dist/analytics-server.js.map +1 -0
  19. package/dist/attribution-logo.d.ts +2 -0
  20. package/dist/attribution-logo.d.ts.map +1 -0
  21. package/dist/attribution-logo.js +5 -0
  22. package/dist/attribution-logo.js.map +1 -0
  23. package/dist/auth-handler.d.ts +92 -0
  24. package/dist/auth-handler.d.ts.map +1 -0
  25. package/dist/auth-handler.js +277 -0
  26. package/dist/auth-handler.js.map +1 -0
  27. package/dist/biab-forms.css +484 -0
  28. package/dist/cli.d.ts +46 -0
  29. package/dist/cli.d.ts.map +1 -0
  30. package/dist/cli.js +1824 -0
  31. package/dist/cli.js.map +1 -0
  32. package/dist/client.d.ts +1681 -0
  33. package/dist/client.d.ts.map +1 -0
  34. package/dist/client.js +2845 -0
  35. package/dist/client.js.map +1 -0
  36. package/dist/collections.d.ts +13 -0
  37. package/dist/collections.d.ts.map +1 -0
  38. package/dist/collections.js +13 -0
  39. package/dist/collections.js.map +1 -0
  40. package/dist/contracts.d.ts +14609 -0
  41. package/dist/contracts.d.ts.map +1 -0
  42. package/dist/contracts.js +2428 -0
  43. package/dist/contracts.js.map +1 -0
  44. package/dist/data-model-schema.d.ts +962 -0
  45. package/dist/data-model-schema.d.ts.map +1 -0
  46. package/dist/data-model-schema.js +2295 -0
  47. package/dist/data-model-schema.js.map +1 -0
  48. package/dist/distribution.d.ts +38 -0
  49. package/dist/distribution.d.ts.map +1 -0
  50. package/dist/distribution.js +61 -0
  51. package/dist/distribution.js.map +1 -0
  52. package/dist/element.d.ts +121 -0
  53. package/dist/element.d.ts.map +1 -0
  54. package/dist/element.js +276 -0
  55. package/dist/element.js.map +1 -0
  56. package/dist/enums.d.ts +25 -0
  57. package/dist/enums.d.ts.map +1 -0
  58. package/dist/enums.js +38 -0
  59. package/dist/enums.js.map +1 -0
  60. package/dist/errors.d.ts +195 -0
  61. package/dist/errors.d.ts.map +1 -0
  62. package/dist/errors.js +188 -0
  63. package/dist/errors.js.map +1 -0
  64. package/dist/forms-core/autocomplete.d.ts +37 -0
  65. package/dist/forms-core/autocomplete.d.ts.map +1 -0
  66. package/dist/forms-core/autocomplete.js +82 -0
  67. package/dist/forms-core/autocomplete.js.map +1 -0
  68. package/dist/forms-core/business-function.d.ts +61 -0
  69. package/dist/forms-core/business-function.d.ts.map +1 -0
  70. package/dist/forms-core/business-function.js +149 -0
  71. package/dist/forms-core/business-function.js.map +1 -0
  72. package/dist/forms-core/calculation.d.ts +72 -0
  73. package/dist/forms-core/calculation.d.ts.map +1 -0
  74. package/dist/forms-core/calculation.js +103 -0
  75. package/dist/forms-core/calculation.js.map +1 -0
  76. package/dist/forms-core/controller.d.ts +249 -0
  77. package/dist/forms-core/controller.d.ts.map +1 -0
  78. package/dist/forms-core/controller.js +590 -0
  79. package/dist/forms-core/controller.js.map +1 -0
  80. package/dist/forms-core/elements.d.ts +44 -0
  81. package/dist/forms-core/elements.d.ts.map +1 -0
  82. package/dist/forms-core/elements.js +68 -0
  83. package/dist/forms-core/elements.js.map +1 -0
  84. package/dist/forms-core/email-domains.d.ts +10 -0
  85. package/dist/forms-core/email-domains.d.ts.map +1 -0
  86. package/dist/forms-core/email-domains.js +69 -0
  87. package/dist/forms-core/email-domains.js.map +1 -0
  88. package/dist/forms-core/file-rules.d.ts +51 -0
  89. package/dist/forms-core/file-rules.d.ts.map +1 -0
  90. package/dist/forms-core/file-rules.js +105 -0
  91. package/dist/forms-core/file-rules.js.map +1 -0
  92. package/dist/forms-core/formula.d.ts +114 -0
  93. package/dist/forms-core/formula.d.ts.map +1 -0
  94. package/dist/forms-core/formula.js +1170 -0
  95. package/dist/forms-core/formula.js.map +1 -0
  96. package/dist/forms-core/index.d.ts +24 -0
  97. package/dist/forms-core/index.d.ts.map +1 -0
  98. package/dist/forms-core/index.js +28 -0
  99. package/dist/forms-core/index.js.map +1 -0
  100. package/dist/forms-core/units.d.ts +49 -0
  101. package/dist/forms-core/units.d.ts.map +1 -0
  102. package/dist/forms-core/units.js +255 -0
  103. package/dist/forms-core/units.js.map +1 -0
  104. package/dist/forms-core/us-states.d.ts +14 -0
  105. package/dist/forms-core/us-states.d.ts.map +1 -0
  106. package/dist/forms-core/us-states.js +66 -0
  107. package/dist/forms-core/us-states.js.map +1 -0
  108. package/dist/forms-core/validation.d.ts +266 -0
  109. package/dist/forms-core/validation.d.ts.map +1 -0
  110. package/dist/forms-core/validation.js +850 -0
  111. package/dist/forms-core/validation.js.map +1 -0
  112. package/dist/forms.d.ts +19 -0
  113. package/dist/forms.d.ts.map +1 -0
  114. package/dist/forms.js +29 -0
  115. package/dist/forms.js.map +1 -0
  116. package/dist/gallery-types.d.ts +32 -0
  117. package/dist/gallery-types.d.ts.map +1 -0
  118. package/dist/gallery-types.js +2 -0
  119. package/dist/gallery-types.js.map +1 -0
  120. package/dist/graphql.d.ts +97 -0
  121. package/dist/graphql.d.ts.map +1 -0
  122. package/dist/graphql.js +212 -0
  123. package/dist/graphql.js.map +1 -0
  124. package/dist/index.cjs +19448 -0
  125. package/dist/index.d.cts +19 -0
  126. package/dist/index.d.mts +19 -0
  127. package/dist/index.d.ts +19 -0
  128. package/dist/index.d.ts.map +1 -0
  129. package/dist/index.js +20 -0
  130. package/dist/index.js.map +1 -0
  131. package/dist/marketing-schema.d.ts +216 -0
  132. package/dist/marketing-schema.d.ts.map +1 -0
  133. package/dist/marketing-schema.js +200 -0
  134. package/dist/marketing-schema.js.map +1 -0
  135. package/dist/mcp.d.ts +42 -0
  136. package/dist/mcp.d.ts.map +1 -0
  137. package/dist/mcp.js +87 -0
  138. package/dist/mcp.js.map +1 -0
  139. package/dist/native.d.ts +45 -0
  140. package/dist/native.d.ts.map +1 -0
  141. package/dist/native.js +43 -0
  142. package/dist/native.js.map +1 -0
  143. package/dist/next-revalidate.d.ts +43 -0
  144. package/dist/next-revalidate.d.ts.map +1 -0
  145. package/dist/next-revalidate.js +84 -0
  146. package/dist/next-revalidate.js.map +1 -0
  147. package/dist/parallel-pages.d.ts +102 -0
  148. package/dist/parallel-pages.d.ts.map +1 -0
  149. package/dist/parallel-pages.js +108 -0
  150. package/dist/parallel-pages.js.map +1 -0
  151. package/dist/payment-icons.d.ts +66 -0
  152. package/dist/payment-icons.d.ts.map +1 -0
  153. package/dist/payment-icons.js +160 -0
  154. package/dist/payment-icons.js.map +1 -0
  155. package/dist/proxy.d.ts +67 -0
  156. package/dist/proxy.d.ts.map +1 -0
  157. package/dist/proxy.js +97 -0
  158. package/dist/proxy.js.map +1 -0
  159. package/dist/react-analytics.d.ts +39 -0
  160. package/dist/react-analytics.d.ts.map +1 -0
  161. package/dist/react-analytics.js +59 -0
  162. package/dist/react-analytics.js.map +1 -0
  163. package/dist/react-attribution.d.ts +99 -0
  164. package/dist/react-attribution.d.ts.map +1 -0
  165. package/dist/react-attribution.js +52 -0
  166. package/dist/react-attribution.js.map +1 -0
  167. package/dist/react-marketing.d.ts +181 -0
  168. package/dist/react-marketing.d.ts.map +1 -0
  169. package/dist/react-marketing.js +215 -0
  170. package/dist/react-marketing.js.map +1 -0
  171. package/dist/react.d.ts +727 -0
  172. package/dist/react.d.ts.map +1 -0
  173. package/dist/react.js +2418 -0
  174. package/dist/react.js.map +1 -0
  175. package/dist/reserved-paths.d.ts +24 -0
  176. package/dist/reserved-paths.d.ts.map +1 -0
  177. package/dist/reserved-paths.js +60 -0
  178. package/dist/reserved-paths.js.map +1 -0
  179. package/dist/revalidate-verify.d.ts +30 -0
  180. package/dist/revalidate-verify.d.ts.map +1 -0
  181. package/dist/revalidate-verify.js +74 -0
  182. package/dist/revalidate-verify.js.map +1 -0
  183. package/dist/sdk.d.ts +678 -0
  184. package/dist/sdk.d.ts.map +1 -0
  185. package/dist/sdk.js +801 -0
  186. package/dist/sdk.js.map +1 -0
  187. package/dist/seo.d.ts +218 -0
  188. package/dist/seo.d.ts.map +1 -0
  189. package/dist/seo.js +309 -0
  190. package/dist/seo.js.map +1 -0
  191. package/dist/socials.d.ts +47 -0
  192. package/dist/socials.d.ts.map +1 -0
  193. package/dist/socials.js +172 -0
  194. package/dist/socials.js.map +1 -0
  195. package/dist/static.d.ts +14 -0
  196. package/dist/static.d.ts.map +1 -0
  197. package/dist/static.js +14 -0
  198. package/dist/static.js.map +1 -0
  199. package/dist/url-pattern.d.ts +47 -0
  200. package/dist/url-pattern.d.ts.map +1 -0
  201. package/dist/url-pattern.js +124 -0
  202. package/dist/url-pattern.js.map +1 -0
  203. package/dist/vanilla.d.ts +77 -0
  204. package/dist/vanilla.d.ts.map +1 -0
  205. package/dist/vanilla.js +903 -0
  206. package/dist/vanilla.js.map +1 -0
  207. package/openapi.json +13779 -0
  208. package/package.json +204 -0
  209. package/src/adapters-revalidate.ts +88 -0
  210. package/src/alpha.ts +89 -0
  211. package/src/analytics-core.ts +175 -0
  212. package/src/analytics-server.ts +99 -0
  213. package/src/angular/biab-form.component.ts +1443 -0
  214. package/src/angular/index.ts +26 -0
  215. package/src/attribution-logo.ts +5 -0
  216. package/src/auth-handler.ts +352 -0
  217. package/src/cli.ts +2517 -0
  218. package/src/client.ts +3578 -0
  219. package/src/collections.ts +101 -0
  220. package/src/contracts.ts +3390 -0
  221. package/src/data-model-schema.ts +4042 -0
  222. package/src/distribution.ts +73 -0
  223. package/src/element.ts +321 -0
  224. package/src/enums.ts +65 -0
  225. package/src/errors.ts +338 -0
  226. package/src/forms-core/autocomplete.ts +97 -0
  227. package/src/forms-core/business-function.ts +209 -0
  228. package/src/forms-core/calculation.ts +167 -0
  229. package/src/forms-core/controller.ts +922 -0
  230. package/src/forms-core/elements.ts +86 -0
  231. package/src/forms-core/email-domains.ts +68 -0
  232. package/src/forms-core/file-rules.ts +123 -0
  233. package/src/forms-core/formula.ts +1339 -0
  234. package/src/forms-core/index.ts +122 -0
  235. package/src/forms-core/units.ts +308 -0
  236. package/src/forms-core/us-states.ts +68 -0
  237. package/src/forms-core/validation.ts +1037 -0
  238. package/src/forms.ts +63 -0
  239. package/src/gallery-types.ts +31 -0
  240. package/src/graphql.ts +295 -0
  241. package/src/index.ts +505 -0
  242. package/src/marketing-schema.ts +395 -0
  243. package/src/mcp.ts +108 -0
  244. package/src/native.ts +73 -0
  245. package/src/next-revalidate.ts +124 -0
  246. package/src/parallel-pages.ts +192 -0
  247. package/src/payment-icons.ts +205 -0
  248. package/src/proxy.ts +173 -0
  249. package/src/qwik.tsx +1234 -0
  250. package/src/react-analytics.tsx +76 -0
  251. package/src/react-attribution.tsx +192 -0
  252. package/src/react-marketing.tsx +338 -0
  253. package/src/react.tsx +5495 -0
  254. package/src/reserved-paths.ts +65 -0
  255. package/src/revalidate-verify.ts +98 -0
  256. package/src/sdk.ts +1671 -0
  257. package/src/seo.ts +488 -0
  258. package/src/socials.ts +230 -0
  259. package/src/solid.tsx +1466 -0
  260. package/src/static.ts +21 -0
  261. package/src/styles/biab-forms.css +484 -0
  262. package/src/svelte/BiabForm.svelte +1069 -0
  263. package/src/svelte/context.ts +57 -0
  264. package/src/svelte/index.ts +79 -0
  265. package/src/url-pattern.ts +153 -0
  266. package/src/vanilla.ts +1290 -0
  267. package/src/vue/BiabForm.vue +1538 -0
  268. package/src/vue/index.ts +119 -0
package/dist/sdk.d.ts ADDED
@@ -0,0 +1,678 @@
1
+ /**
2
+ * High-level SDK surface — what the consumer actually writes against.
3
+ *
4
+ * The principle: the consumer authors design + granular data requests,
5
+ * and that's it. Auth, caching, revalidation, tagging, retries — all
6
+ * handled inside this module so the consumer code reads as:
7
+ *
8
+ * const items = await biab.gallery.list({
9
+ * limit: 12,
10
+ * fields: ["src", "title", "category", "blurDataURL"],
11
+ * });
12
+ *
13
+ * Auto-applied per request:
14
+ * • `Authorization: Bearer <apiKey>`
15
+ * • `next: { tags: ["biab:<resource>", "biab:site:<orgId-when-known>"],
16
+ * revalidate: <longBackstop> }` — invisible on non-Next
17
+ * runtimes that ignore the `next` key
18
+ * • Field selection forwarded as `?fields=…` so the platform
19
+ * SELECTs only what's needed.
20
+ *
21
+ * The companion `@businessdash/sdk/next/revalidate` route export closes
22
+ * the loop: when BIAB POSTs `content.published`, the route handler
23
+ * verifies the HMAC and calls `revalidateTag(...)` to bust the local
24
+ * Next cache. End-to-end, the consumer wrote ~5 lines.
25
+ */
26
+ import { BiabDevAddressClient, BiabDevBlogClient, BiabDevCartClient, BiabDevCheckoutClient, BiabDevCouponsClient, BiabDevCustomerPortalClient, BiabDevFollowersClient, BiabDevMarketingClient, BiabDevMarketingPagesClient, BiabDevNotificationsClient, BiabDevParallelPagesClient, BiabDevReviewsClient, BiabDevShippingClient, BiabDevStorefrontClient, BiabDevSubscriptionsClient } from "./client.js";
27
+ import type { BundleGalleryItem } from "./gallery-types.js";
28
+ export interface CreateBiabClientOptions {
29
+ apiKey: string;
30
+ siteId: string;
31
+ baseUrl?: string;
32
+ /** Override the default 24h ISR backstop. */
33
+ revalidateSeconds?: number;
34
+ /** Custom fetch (testing, instrumentation, edge runtimes). */
35
+ fetch?: typeof fetch;
36
+ /**
37
+ * Optional `Origin` to forward — required when the API key has an
38
+ * Allowed Host configured on the platform (server-to-server fetch
39
+ * does not send `Origin` automatically).
40
+ */
41
+ siteOrigin?: string;
42
+ }
43
+ export type GalleryField = keyof BundleGalleryItem;
44
+ export interface GalleryListParams<F extends readonly GalleryField[]> {
45
+ limit?: number;
46
+ fields?: F;
47
+ }
48
+ export type GalleryItemFor<F extends readonly GalleryField[]> = {
49
+ [K in F[number]]: BundleGalleryItem[K];
50
+ };
51
+ export interface GalleryResource {
52
+ list<const F extends readonly GalleryField[]>(params?: GalleryListParams<F>): Promise<GalleryItemFor<F>[]>;
53
+ }
54
+ /**
55
+ * Public-facing shape of an event type the consumer renders into a
56
+ * "book a meeting" page. Matches `/sites/{siteId}/scheduling/event-types`.
57
+ */
58
+ export interface SchedulingEventType {
59
+ id: string;
60
+ name: string;
61
+ slug: string;
62
+ description: string | null;
63
+ durationMinutes: number;
64
+ locationType: string;
65
+ meetingProvider: string | null;
66
+ color: string | null;
67
+ requiresApproval: boolean;
68
+ }
69
+ export interface SchedulingQuestion {
70
+ id: string;
71
+ label: string;
72
+ fieldType: string;
73
+ optionsJson: unknown;
74
+ isRequired: boolean;
75
+ sortOrder: number;
76
+ }
77
+ /**
78
+ * A booking as returned by `getBookingByToken`.
79
+ *
80
+ * Timestamps are ISO-8601 **strings**. The server holds them as `Date` and
81
+ * they cross the wire as JSON, so typing them `Date` here would compile and
82
+ * then fail at runtime on the first `.getTime()`.
83
+ */
84
+ export interface SchedulingBookingView {
85
+ booking: {
86
+ id: string;
87
+ startAt: string;
88
+ endAt: string;
89
+ status: SchedulingBookingStatus;
90
+ title: string;
91
+ notes: string | null;
92
+ conferenceLink: string | null;
93
+ };
94
+ invitee: {
95
+ name: string;
96
+ email: string;
97
+ timezone: string;
98
+ } | null;
99
+ eventType: {
100
+ name: string;
101
+ slug: string;
102
+ durationMinutes: number;
103
+ locationType: string;
104
+ } | null;
105
+ }
106
+ /** What `rescheduleBooking` echoes back — the booking's new window. */
107
+ export interface SchedulingRescheduleResult {
108
+ bookingId: string;
109
+ startAt: string;
110
+ endAt: string;
111
+ }
112
+ export interface SchedulingSlot {
113
+ startAt: string;
114
+ endAt: string;
115
+ }
116
+ export interface SchedulingInvitee {
117
+ email: string;
118
+ name: string;
119
+ phone?: string | null;
120
+ timezone: string;
121
+ }
122
+ export interface SchedulingAnswer {
123
+ questionId: string;
124
+ valueText: string;
125
+ }
126
+ /**
127
+ * Booking lifecycle states, mirroring the `booking_status` pg enum.
128
+ *
129
+ * Note the spelling: the platform stores **`canceled`** (one L). This type
130
+ * previously read `"pending" | "confirmed" | "cancelled" | string`, which was
131
+ * wrong twice over — the two-L spelling matches nothing the server ever
132
+ * sends, and the trailing `| string` widened the union back to `string` so
133
+ * neither the typo nor the missing `no_show` could ever surface. Keep this
134
+ * closed; a new state should land here as a deliberate edit.
135
+ */
136
+ export type SchedulingBookingStatus = "confirmed" | "pending" | "canceled" | "no_show";
137
+ export interface SchedulingBookingResult {
138
+ bookingId: string;
139
+ status: SchedulingBookingStatus;
140
+ manageToken: string;
141
+ rescheduleToken: string;
142
+ cancelToken: string;
143
+ payment: {
144
+ clientSecret: string;
145
+ amountCents: number;
146
+ currency: string;
147
+ } | null;
148
+ }
149
+ export interface SchedulingResource {
150
+ listEventTypes(): Promise<SchedulingEventType[]>;
151
+ getEventType(slug: string): Promise<{
152
+ eventType: SchedulingEventType;
153
+ questions: SchedulingQuestion[];
154
+ }>;
155
+ getAvailableSlots(slug: string, params: {
156
+ from: Date;
157
+ to: Date;
158
+ }): Promise<SchedulingSlot[]>;
159
+ confirmBooking(input: {
160
+ eventTypeSlug: string;
161
+ startAt: Date;
162
+ invitee: SchedulingInvitee;
163
+ answers?: SchedulingAnswer[];
164
+ notes?: string | null;
165
+ schedulingLinkId?: string;
166
+ holderKey?: string | null;
167
+ }): Promise<SchedulingBookingResult>;
168
+ getBookingByToken(token: string, type?: "manage" | "cancel" | "reschedule"): Promise<SchedulingBookingView>;
169
+ rescheduleBooking(input: {
170
+ token: string;
171
+ newStartAt: Date;
172
+ reason?: string | null;
173
+ }): Promise<SchedulingRescheduleResult>;
174
+ cancelBooking(input: {
175
+ token: string;
176
+ reason?: string | null;
177
+ }): Promise<{
178
+ ok: true;
179
+ }>;
180
+ }
181
+ /**
182
+ * Public-facing description of one form field. Mirrors BIAB's
183
+ * `FormField` type so the consumer can type their submission payload
184
+ * against the schema fetched at runtime.
185
+ */
186
+ export interface FormFieldDef {
187
+ id: string;
188
+ /**
189
+ * Stable, human-readable output key for this field's value (camelCase or
190
+ * snake_case, per the form's configuration). Prefer this when building the
191
+ * submission payload. The server also accepts the UUID `id` for back-compat,
192
+ * so older integrations keep working.
193
+ */
194
+ key?: string;
195
+ label: string;
196
+ type: string;
197
+ required: boolean;
198
+ /**
199
+ * Consent semantic for `type === "boolean"`: the value must be `true` to
200
+ * submit (e.g. "I agree"). Independent of `display`. When false/unset, an
201
+ * optional/required boolean accepts true OR false.
202
+ */
203
+ mustBeTrue?: boolean;
204
+ /** Boolean UI variant: "toggle" (default switch) or "checkbox". */
205
+ display?: "toggle" | "checkbox";
206
+ /**
207
+ * select / radio / checkbox: an "Other…" free-text value outside `options`
208
+ * is allowed. When true, the value may be any string (single) or include a
209
+ * non-option string (checkbox array); the options whitelist isn't enforced.
210
+ */
211
+ allowCustom?: boolean;
212
+ placeholder?: string;
213
+ helpText?: string;
214
+ options?: string[];
215
+ regexPattern?: string;
216
+ validation?: {
217
+ min?: number;
218
+ max?: number;
219
+ };
220
+ /**
221
+ * Set on file-type fields (`type === "file_upload"`). The SDK
222
+ * uploader enforces these client-side as a UX nicety; the
223
+ * server is the source of truth and re-enforces them when
224
+ * minting the upload URL.
225
+ */
226
+ fileConfig?: {
227
+ allowedTypes?: string[];
228
+ maxFiles?: number;
229
+ maxSize?: number;
230
+ };
231
+ /** Phone-field config — `international` switches the digit-count rule. */
232
+ phoneConfig?: {
233
+ international?: boolean;
234
+ };
235
+ /**
236
+ * choice_cards config: a set of selectable cards. `single` = radio semantics
237
+ * (value is the chosen option `label`); `multi` = checkbox semantics (value is
238
+ * a `string[]` of chosen labels). Options may carry richer card content
239
+ * (image/price/description/etc.) for showcasing a product or service — that
240
+ * content is display + metadata only; the submitted value is always the
241
+ * `label`, so validation is unaffected by the extra fields.
242
+ */
243
+ choiceConfig?: {
244
+ mode?: "single" | "multi";
245
+ options?: Array<{
246
+ label: string;
247
+ /** Lucide icon name (kebab-case, e.g. "phone"). */
248
+ icon?: string;
249
+ /** Image to show on the card (URL). */
250
+ imageUrl?: string;
251
+ /** Display price string (e.g. "$49/mo"). */
252
+ price?: string;
253
+ /** Short supporting description shown under the label. */
254
+ description?: string;
255
+ /** Your catalog id for this option (product/service) — metadata only. */
256
+ productId?: string;
257
+ /** Optional link for the card (e.g. a product detail page). */
258
+ href?: string;
259
+ }>;
260
+ };
261
+ /**
262
+ * Display content for static elements. For `richtext` this is
263
+ * server-sanitized HTML; for `body_text` it is plain text. Carries no
264
+ * submitted value.
265
+ */
266
+ content?: string;
267
+ /**
268
+ * `bullet_list` display element. `variant: "bullets"` → optional `title` +
269
+ * plain bullet `items[].text`; `variant: "details"` → one row per point with
270
+ * an optional Lucide `icon`, a `text` heading, and a `description`. Display
271
+ * only — carries no submitted value.
272
+ */
273
+ listConfig?: {
274
+ variant?: "bullets" | "details";
275
+ title?: string;
276
+ items?: Array<{
277
+ text: string;
278
+ description?: string;
279
+ icon?: string;
280
+ }>;
281
+ };
282
+ /**
283
+ * `table` display element. `columns` (header / `type` "text"|"check" / align)
284
+ * + `rows[].cells` aligned to columns by index; a "check" column renders ✓/–
285
+ * from a truthy/falsy cell. `highlightColumn` emphasizes one column. Display
286
+ * only — carries no submitted value.
287
+ */
288
+ tableConfig?: {
289
+ columns?: Array<{
290
+ header: string;
291
+ type?: "text" | "check";
292
+ align?: "left" | "center" | "right";
293
+ }>;
294
+ rows?: Array<{
295
+ cells: string[];
296
+ }>;
297
+ highlightColumn?: number;
298
+ };
299
+ /**
300
+ * `multi_populator` repeater: the submitted value is an ARRAY of instance
301
+ * records, each keyed by the child field ids/keys (same shape as a scoped
302
+ * submission). `maxInstances` caps the count. The template fields live on
303
+ * `children` in the rendered schema tree.
304
+ */
305
+ populatorConfig?: {
306
+ maxInstances?: number;
307
+ minInstances?: number;
308
+ addButtonLabel?: string;
309
+ itemLabel?: string;
310
+ };
311
+ /**
312
+ * `measurement` field: a number + unit. The submitted value is
313
+ * `{ value, unit, base, baseUnit }` — `base` is `value` in the category's base
314
+ * unit (server-computed, for downstream sorting). `outputUnit` is the org's
315
+ * preferred unit (convert `base` → `outputUnit` to resolve internally).
316
+ */
317
+ unitConfig?: {
318
+ category?: string;
319
+ units?: string[];
320
+ mode?: "select" | "fixed";
321
+ defaultUnit?: string;
322
+ outputUnit?: string;
323
+ allowDecimal?: boolean;
324
+ };
325
+ /** `number` field: when false, only whole numbers are accepted. */
326
+ allowDecimal?: boolean;
327
+ /** `number` field: when false, negatives are rejected (enforce >= 0). */
328
+ allowNegative?: boolean;
329
+ /** `currency` field: ISO code / symbol + whether negatives are allowed. */
330
+ currencyConfig?: {
331
+ currency?: string;
332
+ symbol?: string;
333
+ allowNegative?: boolean;
334
+ allowDecimal?: boolean;
335
+ };
336
+ /**
337
+ * `calculation` (Math) element: a value computed from other fields via an
338
+ * inline `formula` or a referenced business `functionId` (pick `outputKey`).
339
+ * `inputMap` binds variable / function-input names to source field ids.
340
+ * Non-sensitive calcs compute live client-side (using `schema.businessFunctions`
341
+ * for function refs); `sensitive` ones compute server-side on submit and are
342
+ * published WITHOUT their formula/def — the field shows a placeholder until
343
+ * the submitted value comes back.
344
+ */
345
+ calculationConfig?: {
346
+ mode?: "formula" | "function";
347
+ formula?: string;
348
+ functionId?: string;
349
+ outputKey?: string;
350
+ inputMap?: Array<{
351
+ variable: string;
352
+ fieldId: string;
353
+ }>;
354
+ display?: {
355
+ show?: boolean;
356
+ prefix?: string;
357
+ suffix?: string;
358
+ decimals?: number;
359
+ };
360
+ sensitive?: boolean;
361
+ };
362
+ /**
363
+ * `credit_card` element — collect a card via Stripe Elements (`<BiabForm/>`
364
+ * only). `card_on_file` saves the card (SetupIntent); `deposit` charges
365
+ * `amountCents` now (PaymentIntent). The card is created on the org's Stripe
366
+ * connected account via `forms.paymentIntent(slug, fieldId)`; the submission
367
+ * stores only the opaque intent id + brand/last4 (PCI-safe). Added in 0.9.9.
368
+ */
369
+ paymentConfig?: {
370
+ mode?: "card_on_file" | "deposit";
371
+ amountCents?: number;
372
+ currency?: string;
373
+ buttonLabel?: string;
374
+ description?: string;
375
+ };
376
+ /**
377
+ * `schedule` element (availability v1). The visitor states when they're free;
378
+ * the submitted value is `{ asap?, days?: string[], times?: string[], notes? }`.
379
+ * `<BiabForm/>` renders day + time-window chips, an ASAP toggle, and notes.
380
+ * Added in 0.9.9.
381
+ */
382
+ scheduleConfig?: {
383
+ mode?: "availability";
384
+ allowAsap?: boolean;
385
+ days?: string[];
386
+ timeWindows?: string[];
387
+ allowNotes?: boolean;
388
+ };
389
+ }
390
+ /**
391
+ * Value shape stored in `data` for a file field after the upload
392
+ * completes. The hiring mirror at `src/server/forms/hiring-mirror.ts`
393
+ * reads these exact fields to populate `job_application_files` — the
394
+ * SDK keeps the contract honest.
395
+ */
396
+ export interface FormFileValue {
397
+ storageId: string;
398
+ url: string;
399
+ name: string;
400
+ mimeType: string;
401
+ size: number;
402
+ }
403
+ /** How the org configured the form to render — apply these for a 1:1 match. */
404
+ export interface FormRenderSettings {
405
+ animation?: "none" | "fade" | "slide" | "scale" | "scroll";
406
+ isConsecutive?: boolean;
407
+ showProgress?: boolean;
408
+ progressStyle?: "bar" | "steps";
409
+ /**
410
+ * Warn before the visitor abandons a dirty, unsubmitted form. `<BiabForm/>`
411
+ * attaches a `beforeunload` guard when `enabled` (the browser shows a generic
412
+ * prompt); `message` is provided so you can show it in your own modal too.
413
+ */
414
+ exitConfirm?: {
415
+ enabled?: boolean;
416
+ message?: string;
417
+ };
418
+ /**
419
+ * Present (true) only when the org's subscription (or platform-admin access)
420
+ * grants link-safety checking AND the form has url fields. When absent, the
421
+ * org hasn't paid for it — do no extra URL verification. The reputation scan
422
+ * runs server-side on submit (it needs the platform's API key); this flag just
423
+ * tells the form the feature is active so you can surface it.
424
+ */
425
+ urlSafety?: boolean;
426
+ }
427
+ /** Action types a form can run on submit (see {@link FormActionPreview}). */
428
+ export type FormActionType = "add_follower" | "unsubscribe" | "send_webhook" | "autoresponder_email" | "grant_coupon";
429
+ /**
430
+ * Sanitized preview of an on-submit action — `type` + the optional condition
431
+ * that gates it. The action's wiring (URLs, secrets, email bodies, field
432
+ * mapping) stays server-side; execution happens automatically on submit. Use
433
+ * this to preview to the user what submitting will do (e.g. "you'll be added
434
+ * to the list"). Added in 0.9.7.
435
+ */
436
+ export interface FormActionPreview {
437
+ type: FormActionType;
438
+ condition?: {
439
+ fieldId: string;
440
+ operator: string;
441
+ value?: string;
442
+ } | null;
443
+ /**
444
+ * `grant_coupon` only: the display-safe coupon notice to show before submit
445
+ * (e.g. "{code} will be applied to this inquiry"). `<BiabForm/>` renders it
446
+ * above the submit button. The coupon id / field mapping never leave the
447
+ * server. Added in 0.9.9.
448
+ */
449
+ coupon?: {
450
+ code?: string;
451
+ notice?: string;
452
+ finePrint?: string;
453
+ };
454
+ }
455
+ export interface FormSchema {
456
+ id: string;
457
+ slug: string;
458
+ title?: string;
459
+ description?: string | null;
460
+ fields: FormFieldDef[];
461
+ /** Render settings (animation, multi-step, progress). Added in 0.9.7. */
462
+ settings?: FormRenderSettings;
463
+ /** Org icon URL when the form opts into `showOrgIcon`. Added in 0.9.7. */
464
+ orgIcon?: string;
465
+ /** On-submit actions this form will run (sanitized). Added in 0.9.7. */
466
+ actions?: FormActionPreview[];
467
+ /**
468
+ * NON-sensitive business functions referenced by this form's `calculation`
469
+ * fields, so the SDK can compute them live in the browser. Sensitive
470
+ * functions are NEVER included — they run server-side on submit. Added in
471
+ * 0.9.9.
472
+ */
473
+ businessFunctions?: Array<{
474
+ id: string;
475
+ slug: string;
476
+ inputs: Array<{
477
+ key: string;
478
+ label?: string;
479
+ type: string;
480
+ required?: boolean;
481
+ default?: unknown;
482
+ }>;
483
+ outputs: Array<{
484
+ key: string;
485
+ label?: string;
486
+ type: string;
487
+ formula: string;
488
+ fallback?: unknown;
489
+ }>;
490
+ }>;
491
+ }
492
+ export type FormSubmissionData = Record<string, unknown>;
493
+ export interface FormValidationIssue {
494
+ fieldId: string;
495
+ label: string;
496
+ reason: "required" | "type" | "min" | "max" | "regex" | "options" | "format" | "unknown_field" | "invalid_payload" | "too_many_fields" | (string & {});
497
+ message: string;
498
+ }
499
+ export interface FormValidationResult {
500
+ ok: boolean;
501
+ issues: FormValidationIssue[];
502
+ }
503
+ /**
504
+ * Runtime validate a submission against the fetched form schema.
505
+ * Returns `ok: true` only when every required field is present and
506
+ * every supplied value passes its type / min / max / regex /
507
+ * options check. Designed to mirror what BIAB's server enforces so
508
+ * the consumer can show inline errors before round-tripping.
509
+ *
510
+ * For build-time type safety, the future `biab-dev codegen forms`
511
+ * CLI emits a `.d.ts` per form so TypeScript can also enforce
512
+ * shape at compile time. Until that ships, this runtime check is
513
+ * the safety net.
514
+ */
515
+ /**
516
+ * Narrow check for the shape `biab.forms.uploadFile` returns —
517
+ * mirrors what the BIAB hiring mirror reads (storageId, url, name,
518
+ * mimeType, size). Used by both `validateFormSubmission` and any
519
+ * caller that wants to assert "this value is a successful upload."
520
+ */
521
+ export declare function isFormFileValue(value: unknown): value is FormFileValue;
522
+ export declare function validateFormSubmission(schema: FormSchema, data: FormSubmissionData): FormValidationResult;
523
+ /**
524
+ * Why a `forms.submit` call didn't succeed. Lets the consumer branch the UI
525
+ * without parsing error strings.
526
+ *
527
+ * - `client_validation_failed` — the local `validateFormSubmission` caught it
528
+ * before any network call (see `issues`).
529
+ * - `validation_failed` — the server rejected the payload against the live form
530
+ * schema (unknown field, wrong type/format, failed required, oversized, …).
531
+ * This is also what a value the validator considers unsafe surfaces as. See
532
+ * `issues`.
533
+ * - `unauthorized` — missing / invalid / expired package API key (401).
534
+ * - `forbidden` — the key lacks the scope/permission, or the request origin
535
+ * isn't on the key's allowed-host list (403).
536
+ * - `plan_required` — the org's plan doesn't include forms (entitlement gate).
537
+ * - `payment_required` — the org's BIAB billing is past due.
538
+ * - `service_suspended` — the org's BIAB billing has lapsed 60+ days.
539
+ * - `rate_limited` — too many submissions too fast (429).
540
+ * - `not_found` — the form doesn't exist, is inactive, or isn't accepting
541
+ * external submissions (404).
542
+ * - `invalid_request` — the request body was malformed (400).
543
+ * - `server_error` — BIAB failed to process the submission (5xx).
544
+ * - `network_error` — the request never reached BIAB (offline, DNS, CORS, …).
545
+ */
546
+ export type FormSubmitFailureReason = "client_validation_failed" | "validation_failed" | "unauthorized" | "forbidden" | "plan_required" | "payment_required" | "service_suspended" | "rate_limited" | "not_found" | "invalid_request" | "server_error" | "network_error";
547
+ /**
548
+ * Result of `forms.submit`. Always resolves (never throws for an expected
549
+ * failure) so the consumer can render success or the exact problem inline.
550
+ * Discriminate on `ok`.
551
+ */
552
+ export type FormSubmitResult = {
553
+ ok: true;
554
+ /** HTTP status of the accepted submission (200). */
555
+ status: number;
556
+ /** Present on a real submit; null/absent on a `dryRun`. */
557
+ submissionId?: string | null;
558
+ slug?: string;
559
+ /** True when this was a `dryRun` — validated but not stored. */
560
+ dryRun?: boolean;
561
+ /** Any additional fields BIAB returned (forward-compat). */
562
+ [key: string]: unknown;
563
+ } | {
564
+ ok: false;
565
+ /** HTTP status, or 0 when the request never reached BIAB. */
566
+ status: number;
567
+ reason: FormSubmitFailureReason;
568
+ /** Human-readable summary, safe to surface to the consumer. */
569
+ message: string;
570
+ /** Field-level detail when `reason` is a validation failure. */
571
+ issues?: FormValidationIssue[];
572
+ };
573
+ export interface FormsResource {
574
+ /**
575
+ * Fetch the form's field definitions. Cached via `biab:forms`
576
+ * + `biab:forms:<slug>` tags so admin edits invalidate via the
577
+ * webhook layer.
578
+ */
579
+ schema(slug: string): Promise<FormSchema>;
580
+ /**
581
+ * Submit a form. Validates against the schema client-side (via
582
+ * `validateFormSubmission`) before round-tripping, then posts to BIAB.
583
+ *
584
+ * Always resolves to a {@link FormSubmitResult} — it does NOT throw for an
585
+ * expected failure. Check `result.ok`; on failure, `result.reason` says what
586
+ * went wrong (bad API key, plan gate, schema mismatch, rate limit, network,
587
+ * …) and `result.issues` carries field-level detail for validation failures.
588
+ */
589
+ submit(slug: string, data: FormSubmissionData, opts?: {
590
+ submitterEmail?: string;
591
+ submitterName?: string;
592
+ /** Skip client-side validation. Use sparingly. */
593
+ skipValidate?: boolean;
594
+ /** Test mode: validate against the live schema on the server but store
595
+ * nothing and skip all CRM/notification side effects. The result has
596
+ * `dryRun: true` and no `submissionId`. Ideal for Postman/CI checks. */
597
+ dryRun?: boolean;
598
+ /** Provenance — how/where the form was filled (e.g. "facebook",
599
+ * "google-ads:summer"), an optional referrer, and free-form metadata.
600
+ * Drives lead-source reporting. Added in 0.9.7. */
601
+ source?: string;
602
+ referrer?: string;
603
+ metadata?: Record<string, unknown>;
604
+ }): Promise<FormSubmitResult>;
605
+ /**
606
+ * Upload a single file for a file-type field on the form.
607
+ *
608
+ * 1. Calls the BIAB upload-url endpoint to get a presigned PUT
609
+ * URL + storageId (the server validates the form, field,
610
+ * MIME type, and size cap against the org's plan).
611
+ * 2. PUTs the file bytes directly to R2 — BIAB never sees the
612
+ * bytes, only the metadata.
613
+ * 3. Returns a `FormFileValue` to drop into the form's `data`
614
+ * payload when calling `submit`.
615
+ *
616
+ * Throws on plan-gate (`forms.file_uploads` entitlement
617
+ * missing), field/file mismatch, or transfer failure.
618
+ */
619
+ uploadFile(slug: string, fieldId: string, file: File | Blob, opts?: {
620
+ filename?: string;
621
+ }): Promise<FormFileValue>;
622
+ /**
623
+ * Mint a Stripe intent for a `credit_card` field so `<BiabForm/>` can mount
624
+ * Stripe Elements. `card_on_file` → a SetupIntent; `deposit` → a PaymentIntent
625
+ * for the configured amount. The intent is created on the org's connected
626
+ * account; initialize Stripe with `{ stripeAccount: connectedAccountId }` and
627
+ * the returned `publishableKey`, then confirm with `clientSecret`. The card
628
+ * never touches BIAB — only the opaque intent id flows back in the submission.
629
+ */
630
+ paymentIntent(slug: string, fieldId: string): Promise<FormPaymentIntent>;
631
+ /**
632
+ * Open booking slots for an auto-mode `schedule` field — the form's assigned
633
+ * staff's combined real availability over [from, to]. `<BiabForm/>` renders
634
+ * the instant-booking picker from these; the visitor picks one and the
635
+ * meeting books on submit. Returns absolute UTC instants (`startAt`); host
636
+ * identities stay server-side. Empty when the org lacks the scheduling
637
+ * add-on or the field has no assignees.
638
+ */
639
+ scheduleSlots(slug: string, input: {
640
+ fieldId: string;
641
+ from: Date;
642
+ to: Date;
643
+ }): Promise<{
644
+ slots: Array<{
645
+ startAt: string;
646
+ }>;
647
+ }>;
648
+ }
649
+ /** Stripe intent details for mounting Elements on a `credit_card` field. */
650
+ export interface FormPaymentIntent {
651
+ mode: "card_on_file" | "deposit";
652
+ clientSecret: string;
653
+ intentId: string;
654
+ publishableKey: string;
655
+ connectedAccountId: string;
656
+ }
657
+ export interface BiabClient {
658
+ gallery: GalleryResource;
659
+ scheduling: SchedulingResource;
660
+ forms: FormsResource;
661
+ blog: BiabDevBlogClient;
662
+ reviews: BiabDevReviewsClient;
663
+ storefront: BiabDevStorefrontClient;
664
+ cart: BiabDevCartClient;
665
+ checkout: BiabDevCheckoutClient;
666
+ coupons: BiabDevCouponsClient;
667
+ subscriptions: BiabDevSubscriptionsClient;
668
+ shipping: BiabDevShippingClient;
669
+ address: BiabDevAddressClient;
670
+ customerPortal: BiabDevCustomerPortalClient;
671
+ notifications: BiabDevNotificationsClient;
672
+ followers: BiabDevFollowersClient;
673
+ marketing: BiabDevMarketingClient;
674
+ marketingPages: BiabDevMarketingPagesClient;
675
+ parallelPages: BiabDevParallelPagesClient;
676
+ }
677
+ export declare function createBiabClient(opts: CreateBiabClientOptions): BiabClient;
678
+ //# sourceMappingURL=sdk.d.ts.map