@riverbankcms/sdk 0.7.0 → 0.7.3

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 (184) hide show
  1. package/README.md +229 -0
  2. package/dist/cli/index.js +42 -95
  3. package/dist/cli/index.js.map +1 -1
  4. package/dist/cli/init-docs/content/agents-section.md +50 -0
  5. package/dist/cli/init-docs/content/cli-reference.md +574 -0
  6. package/dist/cli/init-docs/content/content-management.md +384 -0
  7. package/dist/cli/init-docs/content/context-brand.md +125 -0
  8. package/dist/cli/init-docs/content/context-brief.md +77 -0
  9. package/dist/cli/init-docs/content/context-knowledge.md +111 -0
  10. package/dist/cli/init-docs/content/getting-started.md +130 -0
  11. package/dist/cli/init-docs/content/site-workflows-readme.md +96 -0
  12. package/dist/cli/init-docs/content/workflow-add-block.md +228 -0
  13. package/dist/cli/init-docs/content/workflow-create-page.md +193 -0
  14. package/dist/cli/init-docs/content/workflow-publish.md +280 -0
  15. package/dist/client/bookings.d.mts +2 -0
  16. package/dist/client/bookings.d.ts +2 -0
  17. package/dist/client/bookings.js +2956 -104
  18. package/dist/client/bookings.js.map +1 -1
  19. package/dist/client/bookings.mjs +2929 -70
  20. package/dist/client/bookings.mjs.map +1 -1
  21. package/dist/client/client.d.mts +2 -2
  22. package/dist/client/client.d.ts +2 -2
  23. package/dist/client/client.js +602 -68
  24. package/dist/client/client.js.map +1 -1
  25. package/dist/client/client.mjs +602 -68
  26. package/dist/client/client.mjs.map +1 -1
  27. package/dist/client/hooks.d.mts +2 -2
  28. package/dist/client/hooks.d.ts +2 -2
  29. package/dist/client/rendering/client.js +3070 -259
  30. package/dist/client/rendering/client.js.map +1 -1
  31. package/dist/client/rendering/client.mjs +3212 -395
  32. package/dist/client/rendering/client.mjs.map +1 -1
  33. package/dist/client/spam-protection.d.mts +55 -0
  34. package/dist/client/spam-protection.d.ts +55 -0
  35. package/dist/client/spam-protection.js +2915 -0
  36. package/dist/client/spam-protection.js.map +1 -0
  37. package/dist/client/spam-protection.mjs +2893 -0
  38. package/dist/client/spam-protection.mjs.map +1 -0
  39. package/dist/client/{usePage-BiOReg0_.d.ts → usePage-BYmJCCm1.d.ts} +132 -11
  40. package/dist/client/{usePage-BXjk8BhD.d.mts → usePage-DZtrWajy.d.mts} +132 -11
  41. package/dist/server/{Layout-wBtJLTVX.d.ts → Layout-Yluyb6sK.d.ts} +1 -1
  42. package/dist/server/{Layout-B7cvis7r.d.mts → Layout-qWLdVm5-.d.mts} +1 -1
  43. package/dist/server/chunk-2IZ6S225.js +122 -0
  44. package/dist/server/chunk-2IZ6S225.js.map +1 -0
  45. package/dist/server/chunk-4CV4JOE5.js +27 -0
  46. package/dist/server/chunk-4CV4JOE5.js.map +1 -0
  47. package/dist/server/chunk-5LRR64Y6.mjs +72 -0
  48. package/dist/server/chunk-5LRR64Y6.mjs.map +1 -0
  49. package/dist/server/chunk-NBTRDLCM.js +72 -0
  50. package/dist/server/chunk-NBTRDLCM.js.map +1 -0
  51. package/dist/server/chunk-NFEGQTCC.mjs +27 -0
  52. package/dist/server/{chunk-7FIJSGHU.mjs → chunk-NFQLH5IA.mjs} +856 -74
  53. package/dist/server/chunk-NFQLH5IA.mjs.map +1 -0
  54. package/dist/server/chunk-PPHZV6YD.mjs +122 -0
  55. package/dist/server/chunk-PPHZV6YD.mjs.map +1 -0
  56. package/dist/server/{chunk-P7UVAMK6.js → chunk-VLXTNB2C.js} +866 -84
  57. package/dist/server/chunk-VLXTNB2C.js.map +1 -0
  58. package/dist/server/{components-CMMwDXTW.d.mts → components-DNHfSCML.d.mts} +3 -3
  59. package/dist/server/{components-CICSJyp_.d.ts → components-Di5ME6He.d.ts} +3 -3
  60. package/dist/server/components.d.mts +5 -5
  61. package/dist/server/components.d.ts +5 -5
  62. package/dist/server/components.js +1 -1
  63. package/dist/server/components.mjs +1 -1
  64. package/dist/server/config-validation.js +1 -1
  65. package/dist/server/config-validation.mjs +1 -1
  66. package/dist/server/config.js +1 -1
  67. package/dist/server/config.mjs +1 -1
  68. package/dist/server/data.d.mts +2 -2
  69. package/dist/server/data.d.ts +2 -2
  70. package/dist/server/data.js +1 -1
  71. package/dist/server/data.mjs +1 -1
  72. package/dist/server/env.d.mts +109 -0
  73. package/dist/server/env.d.ts +109 -0
  74. package/dist/server/env.js +14 -0
  75. package/dist/server/env.js.map +1 -0
  76. package/dist/server/env.mjs +14 -0
  77. package/dist/server/{index-DI_qlYx3.d.mts → index--Oyunk_B.d.mts} +2 -2
  78. package/dist/server/{index-BTwWvSBu.d.ts → index-C9Ra8dza.d.ts} +2 -2
  79. package/dist/server/{index-Bucs6UqG.d.mts → index-Clm3skz_.d.mts} +1 -1
  80. package/dist/server/{index-Cp7tJuRt.d.ts → index-DLvNddi-.d.ts} +1 -1
  81. package/dist/server/index.d.mts +216 -5
  82. package/dist/server/index.d.ts +216 -5
  83. package/dist/server/index.js +301 -4
  84. package/dist/server/index.js.map +1 -1
  85. package/dist/server/index.mjs +301 -4
  86. package/dist/server/index.mjs.map +1 -1
  87. package/dist/server/{loadContent-DmgpFcFC.d.ts → loadContent-D7LQwI0o.d.ts} +3 -3
  88. package/dist/server/{loadContent-C-YYUKQa.d.mts → loadContent-DVfuBLiZ.d.mts} +3 -3
  89. package/dist/server/{loadPage-IDGVDFBB.js → loadPage-AXNAERDS.js} +2 -2
  90. package/dist/server/{loadPage-IDGVDFBB.js.map → loadPage-AXNAERDS.js.map} +1 -1
  91. package/dist/server/{loadPage-DP3nrHBi.d.ts → loadPage-BmYJCe_V.d.ts} +2 -2
  92. package/dist/server/{loadPage-B8mQUUSo.d.mts → loadPage-BucnLHmE.d.mts} +2 -2
  93. package/dist/server/{loadPage-DNQTTRHL.mjs → loadPage-XR7ORQ2E.mjs} +2 -2
  94. package/dist/server/loadPage-XR7ORQ2E.mjs.map +1 -0
  95. package/dist/server/metadata.d.mts +4 -4
  96. package/dist/server/metadata.d.ts +4 -4
  97. package/dist/server/metadata.js +1 -1
  98. package/dist/server/metadata.mjs +1 -1
  99. package/dist/server/navigation.d.mts +2 -2
  100. package/dist/server/navigation.d.ts +2 -2
  101. package/dist/server/navigation.js +1 -1
  102. package/dist/server/navigation.mjs +1 -1
  103. package/dist/server/next/revalidate.d.mts +66 -0
  104. package/dist/server/next/revalidate.d.ts +66 -0
  105. package/dist/server/next/revalidate.js +60 -0
  106. package/dist/server/next/revalidate.js.map +1 -0
  107. package/dist/server/next/revalidate.mjs +60 -0
  108. package/dist/server/next/revalidate.mjs.map +1 -0
  109. package/dist/server/next/tags.d.mts +81 -0
  110. package/dist/server/next/tags.d.ts +81 -0
  111. package/dist/server/next/tags.js +36 -0
  112. package/dist/server/next/tags.js.map +1 -0
  113. package/dist/server/next/tags.mjs +36 -0
  114. package/dist/server/next/tags.mjs.map +1 -0
  115. package/dist/server/next.d.mts +164 -6
  116. package/dist/server/next.d.ts +164 -6
  117. package/dist/server/next.js +79 -11
  118. package/dist/server/next.js.map +1 -1
  119. package/dist/server/next.mjs +76 -8
  120. package/dist/server/next.mjs.map +1 -1
  121. package/dist/server/rendering/server.d.mts +4 -4
  122. package/dist/server/rendering/server.d.ts +4 -4
  123. package/dist/server/rendering/server.js +1 -1
  124. package/dist/server/rendering/server.mjs +1 -1
  125. package/dist/server/rendering.d.mts +7 -7
  126. package/dist/server/rendering.d.ts +7 -7
  127. package/dist/server/rendering.js +3 -3
  128. package/dist/server/rendering.js.map +1 -1
  129. package/dist/server/rendering.mjs +4 -4
  130. package/dist/server/routing.d.mts +3 -3
  131. package/dist/server/routing.d.ts +3 -3
  132. package/dist/server/routing.js +2 -2
  133. package/dist/server/routing.mjs +2 -2
  134. package/dist/server/server.d.mts +5 -5
  135. package/dist/server/server.d.ts +5 -5
  136. package/dist/server/server.js +5 -5
  137. package/dist/server/server.js.map +1 -1
  138. package/dist/server/server.mjs +5 -5
  139. package/dist/server/theme-bridge.js +1 -1
  140. package/dist/server/theme-bridge.mjs +1 -1
  141. package/dist/server/theme.js +1 -1
  142. package/dist/server/theme.mjs +1 -1
  143. package/dist/server/{types-BvcJU7zk.d.ts → types-BRQyLrQU.d.ts} +132 -11
  144. package/dist/server/{types-Dsu9wsUh.d.mts → types-BSV6Vc-P.d.mts} +2 -2
  145. package/dist/server/{types-1cLz0vnq.d.mts → types-C-LShyIg.d.mts} +132 -11
  146. package/dist/server/{types-CVykEqXN.d.ts → types-Dt98DeYa.d.ts} +2 -2
  147. package/dist/server/webhooks.d.mts +81 -0
  148. package/dist/server/webhooks.d.ts +81 -0
  149. package/dist/server/webhooks.js +12 -0
  150. package/dist/server/webhooks.js.map +1 -0
  151. package/dist/server/webhooks.mjs +12 -0
  152. package/dist/server/webhooks.mjs.map +1 -0
  153. package/package.json +29 -3
  154. package/dist/client/resolver-BhueZVxZ.d.mts +0 -61
  155. package/dist/client/resolver-BhueZVxZ.d.ts +0 -61
  156. package/dist/client/usePage--fGlyrgj.d.mts +0 -6439
  157. package/dist/client/usePage-BBcFCxOU.d.ts +0 -6297
  158. package/dist/client/usePage-BC8Q2E3t.d.mts +0 -6431
  159. package/dist/client/usePage-BTPnCuWC.d.mts +0 -6511
  160. package/dist/client/usePage-BafOS9UT.d.mts +0 -6512
  161. package/dist/client/usePage-BcjWPXvh.d.mts +0 -6388
  162. package/dist/client/usePage-Bnx-kA6x.d.mts +0 -6670
  163. package/dist/client/usePage-BvKAa3Zw.d.mts +0 -366
  164. package/dist/client/usePage-BvKAa3Zw.d.ts +0 -366
  165. package/dist/client/usePage-BydHcMYB.d.mts +0 -6297
  166. package/dist/client/usePage-C3ZKNwY7.d.mts +0 -6393
  167. package/dist/client/usePage-CE7X5NcN.d.ts +0 -6439
  168. package/dist/client/usePage-CHEybPMD.d.ts +0 -6429
  169. package/dist/client/usePage-CrKw1H6Y.d.ts +0 -6338
  170. package/dist/client/usePage-CyYpOJud.d.ts +0 -6388
  171. package/dist/client/usePage-D4fxZbRR.d.mts +0 -6429
  172. package/dist/client/usePage-DMI8ImsU.d.mts +0 -6338
  173. package/dist/client/usePage-DoPI6b8V.d.ts +0 -6511
  174. package/dist/client/usePage-DpRNZUtP.d.ts +0 -6431
  175. package/dist/client/usePage-QNWArrVO.d.ts +0 -6670
  176. package/dist/client/usePage-fBgPB6Oq.d.ts +0 -6512
  177. package/dist/client/usePage-gpVaeWDy.d.ts +0 -6393
  178. package/dist/server/chunk-7FIJSGHU.mjs.map +0 -1
  179. package/dist/server/chunk-BJTO5JO5.mjs +0 -11
  180. package/dist/server/chunk-DGUM43GV.js +0 -11
  181. package/dist/server/chunk-DGUM43GV.js.map +0 -1
  182. package/dist/server/chunk-P7UVAMK6.js.map +0 -1
  183. /package/dist/server/{chunk-BJTO5JO5.mjs.map → chunk-NFEGQTCC.mjs.map} +0 -0
  184. /package/dist/server/{loadPage-DNQTTRHL.mjs.map → env.mjs.map} +0 -0
@@ -1,4 +1,4 @@
1
- import { A as APIEndpoints } from './types-CVykEqXN.js';
1
+ import { A as APIEndpoints } from './types-Dt98DeYa.js';
2
2
  import './schema-Z6-afHJG.js';
3
3
 
4
4
  type SiteResponse = NonNullable<APIEndpoints['getSite']['response']>;
@@ -33,10 +33,17 @@ interface PaginationMeta {
33
33
  type EntriesResponseWithMeta = {
34
34
  entries: EntriesResponse['entries'];
35
35
  } & PaginationMeta;
36
+ /**
37
+ * Common options for all SDK methods
38
+ */
39
+ interface SdkMethodOptions {
40
+ /** AbortSignal for cancelling the request */
41
+ signal?: AbortSignal;
42
+ }
36
43
  /**
37
44
  * Base parameters for getEntries - shared across all overloads
38
45
  */
39
- interface GetEntriesBaseParams {
46
+ interface GetEntriesBaseParams extends SdkMethodOptions {
40
47
  /** The site ID */
41
48
  siteId: string;
42
49
  /** The content type key (e.g., 'blog-post', 'product') */
@@ -54,6 +61,104 @@ interface GetEntriesBaseParams {
54
61
  /** Entry IDs to fetch when mode is 'manual' */
55
62
  entryIds?: string[];
56
63
  }
64
+ /**
65
+ * Source of the data returned by a resilient fetch
66
+ */
67
+ type ResilienceSource = 'live' | 'cache' | 'stale' | 'prebuild' | 'error';
68
+ /**
69
+ * Status information from a resilient fetch operation
70
+ */
71
+ interface ResilienceStatus {
72
+ /** Where the data came from */
73
+ source: ResilienceSource;
74
+ /** Whether this was a preview request */
75
+ isPreview: boolean;
76
+ /** Cache key used for this request */
77
+ cacheKey?: string;
78
+ /** Error details if fetch failed */
79
+ error?: {
80
+ code?: string;
81
+ message: string;
82
+ };
83
+ /** Seconds since cache TTL expired (when source='stale') */
84
+ staleAgeSec?: number;
85
+ /** Seconds since prebuild was generated (when source='prebuild') */
86
+ prebuildAgeSec?: number;
87
+ /** Circuit breaker state at time of request */
88
+ circuit: CircuitState;
89
+ /** Correlation ID for debugging */
90
+ requestId?: string;
91
+ /** Total request duration including retries (ms) */
92
+ durationMs?: number;
93
+ }
94
+ /**
95
+ * Circuit breaker state information
96
+ */
97
+ interface CircuitState {
98
+ state: 'closed' | 'open' | 'half-open';
99
+ failureCount: number;
100
+ /** Timestamp when circuit will transition from open to half-open */
101
+ openUntil?: number;
102
+ }
103
+ /**
104
+ * Retry configuration
105
+ */
106
+ interface RetryConfig {
107
+ /** Maximum number of attempts (including initial) */
108
+ maxAttempts?: number;
109
+ /** Base delay between retries in ms */
110
+ baseDelayMs?: number;
111
+ /** Maximum delay between retries in ms */
112
+ maxDelayMs?: number;
113
+ /** Jitter strategy: 'full' adds randomization, 'none' uses exact delays */
114
+ jitter?: 'full' | 'none';
115
+ /** Custom function to determine if an error should be retried */
116
+ retryOn?: (error: Error, statusCode?: number) => boolean;
117
+ }
118
+ /**
119
+ * Circuit breaker configuration
120
+ */
121
+ interface CircuitBreakerConfig {
122
+ /** Number of failures before opening circuit */
123
+ failureThreshold?: number;
124
+ /** Time in ms before attempting to close circuit */
125
+ resetTimeoutMs?: number;
126
+ /** Number of successful requests needed to close from half-open */
127
+ halfOpenMaxRequests?: number;
128
+ }
129
+ /**
130
+ * Resilience configuration for the SDK client
131
+ */
132
+ interface ResilienceConfig {
133
+ /** Enable resilience features (default: true) */
134
+ enabled?: boolean;
135
+ /** Serve stale data on fetch failure (default: true) */
136
+ staleIfError?: boolean;
137
+ /** Seconds AFTER cache TTL expires that stale data remains valid (default: 300) */
138
+ staleTtlSec?: number;
139
+ /** Request timeout in ms (default: 8000 server, 5000 browser) */
140
+ requestTimeoutMs?: number;
141
+ /** Retry configuration */
142
+ retry?: RetryConfig;
143
+ /** Circuit breaker configuration */
144
+ circuitBreaker?: CircuitBreakerConfig;
145
+ /**
146
+ * Path to prebuild cache directory.
147
+ * If set, enables prebuild fallback when live + stale cache both fail.
148
+ * @example '.riverbank-cache'
149
+ */
150
+ prebuildDir?: string;
151
+ /**
152
+ * Maximum age in seconds for prebuild cache.
153
+ * Prebuilds older than this are rejected.
154
+ * @default 86400 (24 hours)
155
+ */
156
+ maxPrebuildAgeSec?: number;
157
+ /** Callback fired on every request with status information */
158
+ onStatusChange?: (status: ResilienceStatus) => void;
159
+ /** Callback fired only when transitioning into/out of degraded mode */
160
+ onDegradedMode?: (degraded: boolean, status: ResilienceStatus) => void;
161
+ }
57
162
  /**
58
163
  * Configuration for creating a Riverbank CMS client
59
164
  */
@@ -85,6 +190,10 @@ interface RiverbankClientConfig {
85
190
  */
86
191
  maxSize?: number;
87
192
  };
193
+ /**
194
+ * Resilience configuration for error handling, retries, and fallbacks
195
+ */
196
+ resilience?: ResilienceConfig;
88
197
  }
89
198
  /**
90
199
  * Riverbank CMS client interface
@@ -97,7 +206,7 @@ interface RiverbankClient {
97
206
  slug?: string;
98
207
  domain?: string;
99
208
  id?: string;
100
- }): Promise<SiteResponse>;
209
+ } & SdkMethodOptions): Promise<SiteResponse>;
101
210
  /**
102
211
  * Fetch a specific page by path
103
212
  *
@@ -107,7 +216,7 @@ interface RiverbankClient {
107
216
  siteId: string;
108
217
  path: string;
109
218
  preview?: boolean;
110
- }): Promise<PageResponse>;
219
+ } & SdkMethodOptions): Promise<PageResponse>;
111
220
  /**
112
221
  * Fetch published content entries with optional pagination, sorting, and preview mode
113
222
  *
@@ -168,20 +277,20 @@ interface RiverbankClient {
168
277
  siteId: string;
169
278
  contentType: string;
170
279
  slug: string;
171
- }): Promise<EntryResponse>;
280
+ } & SdkMethodOptions): Promise<EntryResponse>;
172
281
  /**
173
282
  * Fetch a public form definition by ID
174
283
  */
175
284
  getPublicFormById(params: {
176
285
  formId: string;
177
- }): Promise<PublicFormResponse>;
286
+ } & SdkMethodOptions): Promise<PublicFormResponse>;
178
287
  /**
179
288
  * Fetch public booking services for a site
180
289
  */
181
290
  getPublicBookingServices(params: {
182
291
  siteId: string;
183
292
  ids?: string;
184
- }): Promise<PublicBookingServicesResponse>;
293
+ } & SdkMethodOptions): Promise<PublicBookingServicesResponse>;
185
294
  /**
186
295
  * List public events for a site (optionally time-filtered)
187
296
  */
@@ -191,7 +300,7 @@ interface RiverbankClient {
191
300
  from?: string;
192
301
  to?: string;
193
302
  stage?: string;
194
- }): Promise<PublicEventsResponse>;
303
+ } & SdkMethodOptions): Promise<PublicEventsResponse>;
195
304
  /**
196
305
  * Resolve an event occurrence by URL segment (date or UUID)
197
306
  *
@@ -220,7 +329,7 @@ interface RiverbankClient {
220
329
  siteId: string;
221
330
  entryId: string;
222
331
  segment: string;
223
- }): Promise<ResolveEventOccurrenceResponse>;
332
+ } & SdkMethodOptions): Promise<ResolveEventOccurrenceResponse>;
224
333
  /**
225
334
  * Check if a path has a configured redirect rule
226
335
  *
@@ -241,11 +350,23 @@ interface RiverbankClient {
241
350
  checkRedirect(params: {
242
351
  siteId: string;
243
352
  path: string;
244
- }): Promise<CheckRedirectResponse>;
353
+ } & SdkMethodOptions): Promise<CheckRedirectResponse>;
245
354
  /**
246
355
  * Force clear the cache
247
356
  */
248
357
  clearCache(): void;
358
+ /**
359
+ * Get the status from the most recently emitted request
360
+ *
361
+ * Note: With concurrent requests, this returns the last status emitted,
362
+ * which may not be from the request you're interested in. For reliable
363
+ * per-request status, use the onStatusChange callback instead.
364
+ */
365
+ getLastEmittedStatus(): ResilienceStatus | null;
366
+ /**
367
+ * Get the current circuit breaker state
368
+ */
369
+ getCircuitState(): CircuitState;
249
370
  }
250
371
 
251
- export type { EntriesResponse as E, PageResponse as P, RiverbankClient as R, SiteResponse as S, RiverbankClientConfig as a, EntryResponse as b, EntriesResponseWithMeta as c, PaginationMeta as d, ResolveEventOccurrenceResponse as e };
372
+ export type { CircuitState as C, EntriesResponse as E, GetEntriesBaseParams as G, PageResponse as P, RiverbankClient as R, SiteResponse as S, RiverbankClientConfig as a, EntryResponse as b, ResolveEventOccurrenceResponse as c, EntriesResponseWithMeta as d, PaginationMeta as e, ResilienceConfig as f, ResilienceStatus as g, ResilienceSource as h, RetryConfig as i, CircuitBreakerConfig as j };
@@ -1363,7 +1363,7 @@ type ListSiteMembersResponse = {
1363
1363
  plan: SitePlanSummaryResponse;
1364
1364
  };
1365
1365
  type AuthFieldKey = 'email' | 'password' | 'confirmPassword' | 'name' | 'terms' | 'magicLink';
1366
- type AuthSubmissionErrorReason = 'validation' | 'turnstile' | 'supabase' | 'already_registered' | 'rate_limited' | 'email' | 'closed' | 'invalid_credentials' | 'not_confirmed' | 'not_allowed';
1366
+ type AuthSubmissionErrorReason = 'validation' | 'spam_protection' | 'supabase' | 'already_registered' | 'rate_limited' | 'email' | 'closed' | 'invalid_credentials' | 'not_confirmed' | 'not_allowed';
1367
1367
  type AuthSubmissionSuccess = {
1368
1368
  status: 'success';
1369
1369
  message: string;
@@ -2935,7 +2935,7 @@ type APIEndpoints = {
2935
2935
  referer?: string;
2936
2936
  path?: string;
2937
2937
  honeypot?: string;
2938
- turnstileToken?: string | null;
2938
+ altchaSolution?: string | null;
2939
2939
  };
2940
2940
  }, never, {
2941
2941
  ok: boolean;
@@ -1,4 +1,4 @@
1
- import { A as APIEndpoints } from './types-Dsu9wsUh.mjs';
1
+ import { A as APIEndpoints } from './types-BSV6Vc-P.mjs';
2
2
  import './schema-Z6-afHJG.mjs';
3
3
 
4
4
  type SiteResponse = NonNullable<APIEndpoints['getSite']['response']>;
@@ -33,10 +33,17 @@ interface PaginationMeta {
33
33
  type EntriesResponseWithMeta = {
34
34
  entries: EntriesResponse['entries'];
35
35
  } & PaginationMeta;
36
+ /**
37
+ * Common options for all SDK methods
38
+ */
39
+ interface SdkMethodOptions {
40
+ /** AbortSignal for cancelling the request */
41
+ signal?: AbortSignal;
42
+ }
36
43
  /**
37
44
  * Base parameters for getEntries - shared across all overloads
38
45
  */
39
- interface GetEntriesBaseParams {
46
+ interface GetEntriesBaseParams extends SdkMethodOptions {
40
47
  /** The site ID */
41
48
  siteId: string;
42
49
  /** The content type key (e.g., 'blog-post', 'product') */
@@ -54,6 +61,104 @@ interface GetEntriesBaseParams {
54
61
  /** Entry IDs to fetch when mode is 'manual' */
55
62
  entryIds?: string[];
56
63
  }
64
+ /**
65
+ * Source of the data returned by a resilient fetch
66
+ */
67
+ type ResilienceSource = 'live' | 'cache' | 'stale' | 'prebuild' | 'error';
68
+ /**
69
+ * Status information from a resilient fetch operation
70
+ */
71
+ interface ResilienceStatus {
72
+ /** Where the data came from */
73
+ source: ResilienceSource;
74
+ /** Whether this was a preview request */
75
+ isPreview: boolean;
76
+ /** Cache key used for this request */
77
+ cacheKey?: string;
78
+ /** Error details if fetch failed */
79
+ error?: {
80
+ code?: string;
81
+ message: string;
82
+ };
83
+ /** Seconds since cache TTL expired (when source='stale') */
84
+ staleAgeSec?: number;
85
+ /** Seconds since prebuild was generated (when source='prebuild') */
86
+ prebuildAgeSec?: number;
87
+ /** Circuit breaker state at time of request */
88
+ circuit: CircuitState;
89
+ /** Correlation ID for debugging */
90
+ requestId?: string;
91
+ /** Total request duration including retries (ms) */
92
+ durationMs?: number;
93
+ }
94
+ /**
95
+ * Circuit breaker state information
96
+ */
97
+ interface CircuitState {
98
+ state: 'closed' | 'open' | 'half-open';
99
+ failureCount: number;
100
+ /** Timestamp when circuit will transition from open to half-open */
101
+ openUntil?: number;
102
+ }
103
+ /**
104
+ * Retry configuration
105
+ */
106
+ interface RetryConfig {
107
+ /** Maximum number of attempts (including initial) */
108
+ maxAttempts?: number;
109
+ /** Base delay between retries in ms */
110
+ baseDelayMs?: number;
111
+ /** Maximum delay between retries in ms */
112
+ maxDelayMs?: number;
113
+ /** Jitter strategy: 'full' adds randomization, 'none' uses exact delays */
114
+ jitter?: 'full' | 'none';
115
+ /** Custom function to determine if an error should be retried */
116
+ retryOn?: (error: Error, statusCode?: number) => boolean;
117
+ }
118
+ /**
119
+ * Circuit breaker configuration
120
+ */
121
+ interface CircuitBreakerConfig {
122
+ /** Number of failures before opening circuit */
123
+ failureThreshold?: number;
124
+ /** Time in ms before attempting to close circuit */
125
+ resetTimeoutMs?: number;
126
+ /** Number of successful requests needed to close from half-open */
127
+ halfOpenMaxRequests?: number;
128
+ }
129
+ /**
130
+ * Resilience configuration for the SDK client
131
+ */
132
+ interface ResilienceConfig {
133
+ /** Enable resilience features (default: true) */
134
+ enabled?: boolean;
135
+ /** Serve stale data on fetch failure (default: true) */
136
+ staleIfError?: boolean;
137
+ /** Seconds AFTER cache TTL expires that stale data remains valid (default: 300) */
138
+ staleTtlSec?: number;
139
+ /** Request timeout in ms (default: 8000 server, 5000 browser) */
140
+ requestTimeoutMs?: number;
141
+ /** Retry configuration */
142
+ retry?: RetryConfig;
143
+ /** Circuit breaker configuration */
144
+ circuitBreaker?: CircuitBreakerConfig;
145
+ /**
146
+ * Path to prebuild cache directory.
147
+ * If set, enables prebuild fallback when live + stale cache both fail.
148
+ * @example '.riverbank-cache'
149
+ */
150
+ prebuildDir?: string;
151
+ /**
152
+ * Maximum age in seconds for prebuild cache.
153
+ * Prebuilds older than this are rejected.
154
+ * @default 86400 (24 hours)
155
+ */
156
+ maxPrebuildAgeSec?: number;
157
+ /** Callback fired on every request with status information */
158
+ onStatusChange?: (status: ResilienceStatus) => void;
159
+ /** Callback fired only when transitioning into/out of degraded mode */
160
+ onDegradedMode?: (degraded: boolean, status: ResilienceStatus) => void;
161
+ }
57
162
  /**
58
163
  * Configuration for creating a Riverbank CMS client
59
164
  */
@@ -85,6 +190,10 @@ interface RiverbankClientConfig {
85
190
  */
86
191
  maxSize?: number;
87
192
  };
193
+ /**
194
+ * Resilience configuration for error handling, retries, and fallbacks
195
+ */
196
+ resilience?: ResilienceConfig;
88
197
  }
89
198
  /**
90
199
  * Riverbank CMS client interface
@@ -97,7 +206,7 @@ interface RiverbankClient {
97
206
  slug?: string;
98
207
  domain?: string;
99
208
  id?: string;
100
- }): Promise<SiteResponse>;
209
+ } & SdkMethodOptions): Promise<SiteResponse>;
101
210
  /**
102
211
  * Fetch a specific page by path
103
212
  *
@@ -107,7 +216,7 @@ interface RiverbankClient {
107
216
  siteId: string;
108
217
  path: string;
109
218
  preview?: boolean;
110
- }): Promise<PageResponse>;
219
+ } & SdkMethodOptions): Promise<PageResponse>;
111
220
  /**
112
221
  * Fetch published content entries with optional pagination, sorting, and preview mode
113
222
  *
@@ -168,20 +277,20 @@ interface RiverbankClient {
168
277
  siteId: string;
169
278
  contentType: string;
170
279
  slug: string;
171
- }): Promise<EntryResponse>;
280
+ } & SdkMethodOptions): Promise<EntryResponse>;
172
281
  /**
173
282
  * Fetch a public form definition by ID
174
283
  */
175
284
  getPublicFormById(params: {
176
285
  formId: string;
177
- }): Promise<PublicFormResponse>;
286
+ } & SdkMethodOptions): Promise<PublicFormResponse>;
178
287
  /**
179
288
  * Fetch public booking services for a site
180
289
  */
181
290
  getPublicBookingServices(params: {
182
291
  siteId: string;
183
292
  ids?: string;
184
- }): Promise<PublicBookingServicesResponse>;
293
+ } & SdkMethodOptions): Promise<PublicBookingServicesResponse>;
185
294
  /**
186
295
  * List public events for a site (optionally time-filtered)
187
296
  */
@@ -191,7 +300,7 @@ interface RiverbankClient {
191
300
  from?: string;
192
301
  to?: string;
193
302
  stage?: string;
194
- }): Promise<PublicEventsResponse>;
303
+ } & SdkMethodOptions): Promise<PublicEventsResponse>;
195
304
  /**
196
305
  * Resolve an event occurrence by URL segment (date or UUID)
197
306
  *
@@ -220,7 +329,7 @@ interface RiverbankClient {
220
329
  siteId: string;
221
330
  entryId: string;
222
331
  segment: string;
223
- }): Promise<ResolveEventOccurrenceResponse>;
332
+ } & SdkMethodOptions): Promise<ResolveEventOccurrenceResponse>;
224
333
  /**
225
334
  * Check if a path has a configured redirect rule
226
335
  *
@@ -241,11 +350,23 @@ interface RiverbankClient {
241
350
  checkRedirect(params: {
242
351
  siteId: string;
243
352
  path: string;
244
- }): Promise<CheckRedirectResponse>;
353
+ } & SdkMethodOptions): Promise<CheckRedirectResponse>;
245
354
  /**
246
355
  * Force clear the cache
247
356
  */
248
357
  clearCache(): void;
358
+ /**
359
+ * Get the status from the most recently emitted request
360
+ *
361
+ * Note: With concurrent requests, this returns the last status emitted,
362
+ * which may not be from the request you're interested in. For reliable
363
+ * per-request status, use the onStatusChange callback instead.
364
+ */
365
+ getLastEmittedStatus(): ResilienceStatus | null;
366
+ /**
367
+ * Get the current circuit breaker state
368
+ */
369
+ getCircuitState(): CircuitState;
249
370
  }
250
371
 
251
- export type { EntriesResponse as E, PageResponse as P, RiverbankClient as R, SiteResponse as S, RiverbankClientConfig as a, EntryResponse as b, EntriesResponseWithMeta as c, PaginationMeta as d, ResolveEventOccurrenceResponse as e };
372
+ export type { CircuitState as C, EntriesResponse as E, GetEntriesBaseParams as G, PageResponse as P, RiverbankClient as R, SiteResponse as S, RiverbankClientConfig as a, EntryResponse as b, ResolveEventOccurrenceResponse as c, EntriesResponseWithMeta as d, PaginationMeta as e, ResilienceConfig as f, ResilienceStatus as g, ResilienceSource as h, RetryConfig as i, CircuitBreakerConfig as j };
@@ -1363,7 +1363,7 @@ type ListSiteMembersResponse = {
1363
1363
  plan: SitePlanSummaryResponse;
1364
1364
  };
1365
1365
  type AuthFieldKey = 'email' | 'password' | 'confirmPassword' | 'name' | 'terms' | 'magicLink';
1366
- type AuthSubmissionErrorReason = 'validation' | 'turnstile' | 'supabase' | 'already_registered' | 'rate_limited' | 'email' | 'closed' | 'invalid_credentials' | 'not_confirmed' | 'not_allowed';
1366
+ type AuthSubmissionErrorReason = 'validation' | 'spam_protection' | 'supabase' | 'already_registered' | 'rate_limited' | 'email' | 'closed' | 'invalid_credentials' | 'not_confirmed' | 'not_allowed';
1367
1367
  type AuthSubmissionSuccess = {
1368
1368
  status: 'success';
1369
1369
  message: string;
@@ -2935,7 +2935,7 @@ type APIEndpoints = {
2935
2935
  referer?: string;
2936
2936
  path?: string;
2937
2937
  honeypot?: string;
2938
- turnstileToken?: string | null;
2938
+ altchaSolution?: string | null;
2939
2939
  };
2940
2940
  }, never, {
2941
2941
  ok: boolean;
@@ -0,0 +1,81 @@
1
+ import { z } from 'zod';
2
+
3
+ /**
4
+ * Webhook verification utilities for Riverbank SDK
5
+ *
6
+ * Provides framework-agnostic webhook signature verification and payload parsing.
7
+ */
8
+
9
+ /**
10
+ * Zod schema for webhook payload validation.
11
+ */
12
+ declare const WebhookPayloadSchema: z.ZodObject<{
13
+ event: z.ZodEnum<{
14
+ "page.published": "page.published";
15
+ "entry.published": "entry.published";
16
+ "navigation.updated": "navigation.updated";
17
+ "theme.updated": "theme.updated";
18
+ "site.settings_updated": "site.settings_updated";
19
+ }>;
20
+ timestamp: z.ZodString;
21
+ siteId: z.ZodString;
22
+ data: z.ZodRecord<z.ZodString, z.ZodUnknown>;
23
+ tags: z.ZodOptional<z.ZodArray<z.ZodString>>;
24
+ }, z.core.$strip>;
25
+ /**
26
+ * Webhook payload structure sent by the CMS.
27
+ */
28
+ type WebhookPayload = z.infer<typeof WebhookPayloadSchema>;
29
+ /**
30
+ * Verify a webhook signature using HMAC-SHA256.
31
+ *
32
+ * Uses timing-safe comparison to prevent timing attacks.
33
+ *
34
+ * @param payload - The raw request body as a string
35
+ * @param signature - The X-Riverbank-Signature header value
36
+ * @param secret - The webhook signing secret (RIVERBANK_WEBHOOK_SECRET)
37
+ * @returns true if signature is valid, false otherwise
38
+ *
39
+ * @example
40
+ * ```ts
41
+ * const body = await request.text();
42
+ * const signature = request.headers.get('x-riverbank-signature');
43
+ * const secret = process.env.RIVERBANK_WEBHOOK_SECRET;
44
+ *
45
+ * if (!verifyWebhookSignature(body, signature, secret)) {
46
+ * return new Response('Invalid signature', { status: 401 });
47
+ * }
48
+ * ```
49
+ */
50
+ declare function verifyWebhookSignature(payload: string, signature: string, secret: string): boolean;
51
+ /**
52
+ * Result type for webhook payload parsing.
53
+ */
54
+ type ParseWebhookResult = {
55
+ success: true;
56
+ payload: WebhookPayload;
57
+ } | {
58
+ success: false;
59
+ error: string;
60
+ };
61
+ /**
62
+ * Parse and validate a webhook payload from the request body.
63
+ *
64
+ * Uses Zod schema validation to ensure the payload has the expected structure.
65
+ *
66
+ * @param body - The raw request body as a string
67
+ * @returns A result object with either the validated payload or an error message
68
+ *
69
+ * @example
70
+ * ```ts
71
+ * const body = await request.text();
72
+ * const result = parseWebhookPayload(body);
73
+ * if (!result.success) {
74
+ * return new Response(result.error, { status: 400 });
75
+ * }
76
+ * console.log(`Received ${result.payload.event} for site ${result.payload.siteId}`);
77
+ * ```
78
+ */
79
+ declare function parseWebhookPayload(body: string): ParseWebhookResult;
80
+
81
+ export { type ParseWebhookResult, type WebhookPayload, WebhookPayloadSchema, parseWebhookPayload, verifyWebhookSignature };
@@ -0,0 +1,81 @@
1
+ import { z } from 'zod';
2
+
3
+ /**
4
+ * Webhook verification utilities for Riverbank SDK
5
+ *
6
+ * Provides framework-agnostic webhook signature verification and payload parsing.
7
+ */
8
+
9
+ /**
10
+ * Zod schema for webhook payload validation.
11
+ */
12
+ declare const WebhookPayloadSchema: z.ZodObject<{
13
+ event: z.ZodEnum<{
14
+ "page.published": "page.published";
15
+ "entry.published": "entry.published";
16
+ "navigation.updated": "navigation.updated";
17
+ "theme.updated": "theme.updated";
18
+ "site.settings_updated": "site.settings_updated";
19
+ }>;
20
+ timestamp: z.ZodString;
21
+ siteId: z.ZodString;
22
+ data: z.ZodRecord<z.ZodString, z.ZodUnknown>;
23
+ tags: z.ZodOptional<z.ZodArray<z.ZodString>>;
24
+ }, z.core.$strip>;
25
+ /**
26
+ * Webhook payload structure sent by the CMS.
27
+ */
28
+ type WebhookPayload = z.infer<typeof WebhookPayloadSchema>;
29
+ /**
30
+ * Verify a webhook signature using HMAC-SHA256.
31
+ *
32
+ * Uses timing-safe comparison to prevent timing attacks.
33
+ *
34
+ * @param payload - The raw request body as a string
35
+ * @param signature - The X-Riverbank-Signature header value
36
+ * @param secret - The webhook signing secret (RIVERBANK_WEBHOOK_SECRET)
37
+ * @returns true if signature is valid, false otherwise
38
+ *
39
+ * @example
40
+ * ```ts
41
+ * const body = await request.text();
42
+ * const signature = request.headers.get('x-riverbank-signature');
43
+ * const secret = process.env.RIVERBANK_WEBHOOK_SECRET;
44
+ *
45
+ * if (!verifyWebhookSignature(body, signature, secret)) {
46
+ * return new Response('Invalid signature', { status: 401 });
47
+ * }
48
+ * ```
49
+ */
50
+ declare function verifyWebhookSignature(payload: string, signature: string, secret: string): boolean;
51
+ /**
52
+ * Result type for webhook payload parsing.
53
+ */
54
+ type ParseWebhookResult = {
55
+ success: true;
56
+ payload: WebhookPayload;
57
+ } | {
58
+ success: false;
59
+ error: string;
60
+ };
61
+ /**
62
+ * Parse and validate a webhook payload from the request body.
63
+ *
64
+ * Uses Zod schema validation to ensure the payload has the expected structure.
65
+ *
66
+ * @param body - The raw request body as a string
67
+ * @returns A result object with either the validated payload or an error message
68
+ *
69
+ * @example
70
+ * ```ts
71
+ * const body = await request.text();
72
+ * const result = parseWebhookPayload(body);
73
+ * if (!result.success) {
74
+ * return new Response(result.error, { status: 400 });
75
+ * }
76
+ * console.log(`Received ${result.payload.event} for site ${result.payload.siteId}`);
77
+ * ```
78
+ */
79
+ declare function parseWebhookPayload(body: string): ParseWebhookResult;
80
+
81
+ export { type ParseWebhookResult, type WebhookPayload, WebhookPayloadSchema, parseWebhookPayload, verifyWebhookSignature };
@@ -0,0 +1,12 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
+
3
+
4
+
5
+ var _chunkNBTRDLCMjs = require('./chunk-NBTRDLCM.js');
6
+ require('./chunk-4CV4JOE5.js');
7
+
8
+
9
+
10
+
11
+ exports.WebhookPayloadSchema = _chunkNBTRDLCMjs.WebhookPayloadSchema; exports.parseWebhookPayload = _chunkNBTRDLCMjs.parseWebhookPayload; exports.verifyWebhookSignature = _chunkNBTRDLCMjs.verifyWebhookSignature;
12
+ //# sourceMappingURL=webhooks.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["/Users/will/Projects/Business/cms/builder/packages/sdk/dist/server/webhooks.js"],"names":[],"mappings":"AAAA;AACE;AACA;AACA;AACF,sDAA4B;AAC5B,+BAA4B;AAC5B;AACE;AACA;AACA;AACF,mNAAC","file":"/Users/will/Projects/Business/cms/builder/packages/sdk/dist/server/webhooks.js"}
@@ -0,0 +1,12 @@
1
+ import {
2
+ WebhookPayloadSchema,
3
+ parseWebhookPayload,
4
+ verifyWebhookSignature
5
+ } from "./chunk-5LRR64Y6.mjs";
6
+ import "./chunk-NFEGQTCC.mjs";
7
+ export {
8
+ WebhookPayloadSchema,
9
+ parseWebhookPayload,
10
+ verifyWebhookSignature
11
+ };
12
+ //# sourceMappingURL=webhooks.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}