@riverbankcms/sdk 0.7.0 → 0.7.2
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 +175 -0
- package/dist/cli/index.js +42 -95
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/init-docs/content/agents-section.md +50 -0
- package/dist/cli/init-docs/content/cli-reference.md +574 -0
- package/dist/cli/init-docs/content/content-management.md +384 -0
- package/dist/cli/init-docs/content/context-brand.md +125 -0
- package/dist/cli/init-docs/content/context-brief.md +77 -0
- package/dist/cli/init-docs/content/context-knowledge.md +111 -0
- package/dist/cli/init-docs/content/getting-started.md +130 -0
- package/dist/cli/init-docs/content/site-workflows-readme.md +96 -0
- package/dist/cli/init-docs/content/workflow-add-block.md +228 -0
- package/dist/cli/init-docs/content/workflow-create-page.md +193 -0
- package/dist/cli/init-docs/content/workflow-publish.md +280 -0
- package/dist/client/client.d.mts +2 -2
- package/dist/client/client.d.ts +2 -2
- package/dist/client/client.js +536 -71
- package/dist/client/client.js.map +1 -1
- package/dist/client/client.mjs +536 -78
- package/dist/client/client.mjs.map +1 -1
- package/dist/client/hooks.d.mts +2 -2
- package/dist/client/hooks.d.ts +2 -2
- package/dist/client/usePage-C9tJpuKa.d.mts +6813 -0
- package/dist/client/usePage-Db9kzA41.d.ts +6813 -0
- package/dist/server/{Layout-wBtJLTVX.d.ts → Layout-Ce7PU9I5.d.ts} +1 -1
- package/dist/server/{Layout-B7cvis7r.d.mts → Layout-WllR8Zug.d.mts} +1 -1
- package/dist/server/{chunk-7FIJSGHU.mjs → chunk-5JT452F2.mjs} +537 -76
- package/dist/server/chunk-5JT452F2.mjs.map +1 -0
- package/dist/server/chunk-AET56TQX.mjs +45 -0
- package/dist/server/chunk-AET56TQX.mjs.map +1 -0
- package/dist/server/{chunk-P7UVAMK6.js → chunk-HMENX4Y7.js} +543 -82
- package/dist/server/chunk-HMENX4Y7.js.map +1 -0
- package/dist/server/chunk-LQUKXIW7.mjs +13 -0
- package/dist/server/chunk-LQUKXIW7.mjs.map +1 -0
- package/dist/server/chunk-VODFQMUW.js +45 -0
- package/dist/server/chunk-VODFQMUW.js.map +1 -0
- package/dist/server/chunk-WYNEYDXO.js +13 -0
- package/dist/server/chunk-WYNEYDXO.js.map +1 -0
- package/dist/server/{components-CICSJyp_.d.ts → components--LT61IKp.d.ts} +2 -2
- package/dist/server/{components-CMMwDXTW.d.mts → components-RPzRQve6.d.mts} +2 -2
- package/dist/server/components.d.mts +4 -4
- package/dist/server/components.d.ts +4 -4
- package/dist/server/components.js +0 -1
- package/dist/server/components.js.map +1 -1
- package/dist/server/components.mjs +0 -1
- package/dist/server/config-validation.js +0 -1
- package/dist/server/config-validation.js.map +1 -1
- package/dist/server/config-validation.mjs +0 -1
- package/dist/server/config.js +0 -1
- package/dist/server/config.js.map +1 -1
- package/dist/server/config.mjs +0 -1
- package/dist/server/config.mjs.map +1 -1
- package/dist/server/data.d.mts +1 -1
- package/dist/server/data.d.ts +1 -1
- package/dist/server/data.js +0 -1
- package/dist/server/data.js.map +1 -1
- package/dist/server/data.mjs +0 -1
- package/dist/server/env.d.mts +23 -0
- package/dist/server/env.d.ts +23 -0
- package/dist/server/env.js +7 -0
- package/dist/server/env.js.map +1 -0
- package/dist/server/env.mjs +7 -0
- package/dist/server/{index-DI_qlYx3.d.mts → index-BL66CU6d.d.mts} +2 -2
- package/dist/server/{index-Bucs6UqG.d.mts → index-Bkva0WAj.d.mts} +1 -1
- package/dist/server/{index-BTwWvSBu.d.ts → index-CJk9iQQW.d.ts} +2 -2
- package/dist/server/{index-Cp7tJuRt.d.ts → index-CSBWKA3r.d.ts} +1 -1
- package/dist/server/index.d.mts +3 -3
- package/dist/server/index.d.ts +3 -3
- package/dist/server/index.js +2 -3
- package/dist/server/index.js.map +1 -1
- package/dist/server/index.mjs +1 -2
- package/dist/server/index.mjs.map +1 -1
- package/dist/server/{loadContent-DmgpFcFC.d.ts → loadContent-CXUWMuzY.d.ts} +2 -2
- package/dist/server/{loadContent-C-YYUKQa.d.mts → loadContent-F_tAS0Nl.d.mts} +2 -2
- package/dist/server/{loadPage-IDGVDFBB.js → loadPage-6I7F6GRF.js} +1 -2
- package/dist/server/loadPage-6I7F6GRF.js.map +1 -0
- package/dist/server/{loadPage-B8mQUUSo.d.mts → loadPage-CxlYLe5K.d.mts} +1 -1
- package/dist/server/{loadPage-DNQTTRHL.mjs → loadPage-JI2SML4M.mjs} +1 -2
- package/dist/server/{loadPage-DP3nrHBi.d.ts → loadPage-i2r-X5b9.d.ts} +1 -1
- package/dist/server/metadata.d.mts +3 -3
- package/dist/server/metadata.d.ts +3 -3
- package/dist/server/metadata.js +0 -1
- package/dist/server/metadata.js.map +1 -1
- package/dist/server/metadata.mjs +0 -1
- package/dist/server/navigation.js +0 -1
- package/dist/server/navigation.js.map +1 -1
- package/dist/server/navigation.mjs +0 -1
- package/dist/server/next/revalidate.d.mts +66 -0
- package/dist/server/next/revalidate.d.ts +66 -0
- package/dist/server/next/revalidate.js +59 -0
- package/dist/server/next/revalidate.js.map +1 -0
- package/dist/server/next/revalidate.mjs +59 -0
- package/dist/server/next/revalidate.mjs.map +1 -0
- package/dist/server/next/tags.d.mts +78 -0
- package/dist/server/next/tags.d.ts +78 -0
- package/dist/server/next/tags.js +34 -0
- package/dist/server/next/tags.js.map +1 -0
- package/dist/server/next/tags.mjs +34 -0
- package/dist/server/next/tags.mjs.map +1 -0
- package/dist/server/next.d.mts +163 -5
- package/dist/server/next.d.ts +163 -5
- package/dist/server/next.js +78 -11
- package/dist/server/next.js.map +1 -1
- package/dist/server/next.mjs +75 -8
- package/dist/server/next.mjs.map +1 -1
- package/dist/server/rendering/server.d.mts +3 -3
- package/dist/server/rendering/server.d.ts +3 -3
- package/dist/server/rendering/server.js +0 -1
- package/dist/server/rendering/server.js.map +1 -1
- package/dist/server/rendering/server.mjs +0 -1
- package/dist/server/rendering.d.mts +6 -6
- package/dist/server/rendering.d.ts +6 -6
- package/dist/server/rendering.js +2 -3
- package/dist/server/rendering.js.map +1 -1
- package/dist/server/rendering.mjs +3 -4
- package/dist/server/routing.d.mts +2 -2
- package/dist/server/routing.d.ts +2 -2
- package/dist/server/routing.js +2 -4
- package/dist/server/routing.js.map +1 -1
- package/dist/server/routing.mjs +1 -3
- package/dist/server/routing.mjs.map +1 -1
- package/dist/server/server.d.mts +4 -4
- package/dist/server/server.d.ts +4 -4
- package/dist/server/server.js +4 -5
- package/dist/server/server.js.map +1 -1
- package/dist/server/server.mjs +4 -5
- package/dist/server/theme-bridge.js +0 -1
- package/dist/server/theme-bridge.js.map +1 -1
- package/dist/server/theme-bridge.mjs +0 -1
- package/dist/server/theme-bridge.mjs.map +1 -1
- package/dist/server/theme.js +1 -3
- package/dist/server/theme.js.map +1 -1
- package/dist/server/theme.mjs +0 -2
- package/dist/server/theme.mjs.map +1 -1
- package/dist/server/{types-BvcJU7zk.d.ts → types-DnkRh0UL.d.ts} +118 -9
- package/dist/server/{types-1cLz0vnq.d.mts → types-MF2AWoKv.d.mts} +118 -9
- package/dist/server/webhooks.d.mts +75 -0
- package/dist/server/webhooks.d.ts +75 -0
- package/dist/server/webhooks.js +11 -0
- package/dist/server/webhooks.js.map +1 -0
- package/dist/server/webhooks.mjs +11 -0
- package/dist/server/webhooks.mjs.map +1 -0
- package/package.json +23 -3
- package/dist/server/chunk-7FIJSGHU.mjs.map +0 -1
- package/dist/server/chunk-BJTO5JO5.mjs +0 -11
- package/dist/server/chunk-DGUM43GV.js +0 -11
- package/dist/server/chunk-DGUM43GV.js.map +0 -1
- package/dist/server/chunk-P7UVAMK6.js.map +0 -1
- package/dist/server/loadPage-IDGVDFBB.js.map +0 -1
- /package/dist/server/{chunk-BJTO5JO5.mjs.map → env.mjs.map} +0 -0
- /package/dist/server/{loadPage-DNQTTRHL.mjs.map → loadPage-JI2SML4M.mjs.map} +0 -0
|
@@ -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,92 @@ 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
|
+
/** Callback fired on every request with status information */
|
|
146
|
+
onStatusChange?: (status: ResilienceStatus) => void;
|
|
147
|
+
/** Callback fired only when transitioning into/out of degraded mode */
|
|
148
|
+
onDegradedMode?: (degraded: boolean, status: ResilienceStatus) => void;
|
|
149
|
+
}
|
|
57
150
|
/**
|
|
58
151
|
* Configuration for creating a Riverbank CMS client
|
|
59
152
|
*/
|
|
@@ -85,6 +178,10 @@ interface RiverbankClientConfig {
|
|
|
85
178
|
*/
|
|
86
179
|
maxSize?: number;
|
|
87
180
|
};
|
|
181
|
+
/**
|
|
182
|
+
* Resilience configuration for error handling, retries, and fallbacks
|
|
183
|
+
*/
|
|
184
|
+
resilience?: ResilienceConfig;
|
|
88
185
|
}
|
|
89
186
|
/**
|
|
90
187
|
* Riverbank CMS client interface
|
|
@@ -97,7 +194,7 @@ interface RiverbankClient {
|
|
|
97
194
|
slug?: string;
|
|
98
195
|
domain?: string;
|
|
99
196
|
id?: string;
|
|
100
|
-
}): Promise<SiteResponse>;
|
|
197
|
+
} & SdkMethodOptions): Promise<SiteResponse>;
|
|
101
198
|
/**
|
|
102
199
|
* Fetch a specific page by path
|
|
103
200
|
*
|
|
@@ -107,7 +204,7 @@ interface RiverbankClient {
|
|
|
107
204
|
siteId: string;
|
|
108
205
|
path: string;
|
|
109
206
|
preview?: boolean;
|
|
110
|
-
}): Promise<PageResponse>;
|
|
207
|
+
} & SdkMethodOptions): Promise<PageResponse>;
|
|
111
208
|
/**
|
|
112
209
|
* Fetch published content entries with optional pagination, sorting, and preview mode
|
|
113
210
|
*
|
|
@@ -168,20 +265,20 @@ interface RiverbankClient {
|
|
|
168
265
|
siteId: string;
|
|
169
266
|
contentType: string;
|
|
170
267
|
slug: string;
|
|
171
|
-
}): Promise<EntryResponse>;
|
|
268
|
+
} & SdkMethodOptions): Promise<EntryResponse>;
|
|
172
269
|
/**
|
|
173
270
|
* Fetch a public form definition by ID
|
|
174
271
|
*/
|
|
175
272
|
getPublicFormById(params: {
|
|
176
273
|
formId: string;
|
|
177
|
-
}): Promise<PublicFormResponse>;
|
|
274
|
+
} & SdkMethodOptions): Promise<PublicFormResponse>;
|
|
178
275
|
/**
|
|
179
276
|
* Fetch public booking services for a site
|
|
180
277
|
*/
|
|
181
278
|
getPublicBookingServices(params: {
|
|
182
279
|
siteId: string;
|
|
183
280
|
ids?: string;
|
|
184
|
-
}): Promise<PublicBookingServicesResponse>;
|
|
281
|
+
} & SdkMethodOptions): Promise<PublicBookingServicesResponse>;
|
|
185
282
|
/**
|
|
186
283
|
* List public events for a site (optionally time-filtered)
|
|
187
284
|
*/
|
|
@@ -191,7 +288,7 @@ interface RiverbankClient {
|
|
|
191
288
|
from?: string;
|
|
192
289
|
to?: string;
|
|
193
290
|
stage?: string;
|
|
194
|
-
}): Promise<PublicEventsResponse>;
|
|
291
|
+
} & SdkMethodOptions): Promise<PublicEventsResponse>;
|
|
195
292
|
/**
|
|
196
293
|
* Resolve an event occurrence by URL segment (date or UUID)
|
|
197
294
|
*
|
|
@@ -220,7 +317,7 @@ interface RiverbankClient {
|
|
|
220
317
|
siteId: string;
|
|
221
318
|
entryId: string;
|
|
222
319
|
segment: string;
|
|
223
|
-
}): Promise<ResolveEventOccurrenceResponse>;
|
|
320
|
+
} & SdkMethodOptions): Promise<ResolveEventOccurrenceResponse>;
|
|
224
321
|
/**
|
|
225
322
|
* Check if a path has a configured redirect rule
|
|
226
323
|
*
|
|
@@ -241,11 +338,23 @@ interface RiverbankClient {
|
|
|
241
338
|
checkRedirect(params: {
|
|
242
339
|
siteId: string;
|
|
243
340
|
path: string;
|
|
244
|
-
}): Promise<CheckRedirectResponse>;
|
|
341
|
+
} & SdkMethodOptions): Promise<CheckRedirectResponse>;
|
|
245
342
|
/**
|
|
246
343
|
* Force clear the cache
|
|
247
344
|
*/
|
|
248
345
|
clearCache(): void;
|
|
346
|
+
/**
|
|
347
|
+
* Get the status from the most recently emitted request
|
|
348
|
+
*
|
|
349
|
+
* Note: With concurrent requests, this returns the last status emitted,
|
|
350
|
+
* which may not be from the request you're interested in. For reliable
|
|
351
|
+
* per-request status, use the onStatusChange callback instead.
|
|
352
|
+
*/
|
|
353
|
+
getLastEmittedStatus(): ResilienceStatus | null;
|
|
354
|
+
/**
|
|
355
|
+
* Get the current circuit breaker state
|
|
356
|
+
*/
|
|
357
|
+
getCircuitState(): CircuitState;
|
|
249
358
|
}
|
|
250
359
|
|
|
251
360
|
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 };
|
|
@@ -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,92 @@ 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
|
+
/** Callback fired on every request with status information */
|
|
146
|
+
onStatusChange?: (status: ResilienceStatus) => void;
|
|
147
|
+
/** Callback fired only when transitioning into/out of degraded mode */
|
|
148
|
+
onDegradedMode?: (degraded: boolean, status: ResilienceStatus) => void;
|
|
149
|
+
}
|
|
57
150
|
/**
|
|
58
151
|
* Configuration for creating a Riverbank CMS client
|
|
59
152
|
*/
|
|
@@ -85,6 +178,10 @@ interface RiverbankClientConfig {
|
|
|
85
178
|
*/
|
|
86
179
|
maxSize?: number;
|
|
87
180
|
};
|
|
181
|
+
/**
|
|
182
|
+
* Resilience configuration for error handling, retries, and fallbacks
|
|
183
|
+
*/
|
|
184
|
+
resilience?: ResilienceConfig;
|
|
88
185
|
}
|
|
89
186
|
/**
|
|
90
187
|
* Riverbank CMS client interface
|
|
@@ -97,7 +194,7 @@ interface RiverbankClient {
|
|
|
97
194
|
slug?: string;
|
|
98
195
|
domain?: string;
|
|
99
196
|
id?: string;
|
|
100
|
-
}): Promise<SiteResponse>;
|
|
197
|
+
} & SdkMethodOptions): Promise<SiteResponse>;
|
|
101
198
|
/**
|
|
102
199
|
* Fetch a specific page by path
|
|
103
200
|
*
|
|
@@ -107,7 +204,7 @@ interface RiverbankClient {
|
|
|
107
204
|
siteId: string;
|
|
108
205
|
path: string;
|
|
109
206
|
preview?: boolean;
|
|
110
|
-
}): Promise<PageResponse>;
|
|
207
|
+
} & SdkMethodOptions): Promise<PageResponse>;
|
|
111
208
|
/**
|
|
112
209
|
* Fetch published content entries with optional pagination, sorting, and preview mode
|
|
113
210
|
*
|
|
@@ -168,20 +265,20 @@ interface RiverbankClient {
|
|
|
168
265
|
siteId: string;
|
|
169
266
|
contentType: string;
|
|
170
267
|
slug: string;
|
|
171
|
-
}): Promise<EntryResponse>;
|
|
268
|
+
} & SdkMethodOptions): Promise<EntryResponse>;
|
|
172
269
|
/**
|
|
173
270
|
* Fetch a public form definition by ID
|
|
174
271
|
*/
|
|
175
272
|
getPublicFormById(params: {
|
|
176
273
|
formId: string;
|
|
177
|
-
}): Promise<PublicFormResponse>;
|
|
274
|
+
} & SdkMethodOptions): Promise<PublicFormResponse>;
|
|
178
275
|
/**
|
|
179
276
|
* Fetch public booking services for a site
|
|
180
277
|
*/
|
|
181
278
|
getPublicBookingServices(params: {
|
|
182
279
|
siteId: string;
|
|
183
280
|
ids?: string;
|
|
184
|
-
}): Promise<PublicBookingServicesResponse>;
|
|
281
|
+
} & SdkMethodOptions): Promise<PublicBookingServicesResponse>;
|
|
185
282
|
/**
|
|
186
283
|
* List public events for a site (optionally time-filtered)
|
|
187
284
|
*/
|
|
@@ -191,7 +288,7 @@ interface RiverbankClient {
|
|
|
191
288
|
from?: string;
|
|
192
289
|
to?: string;
|
|
193
290
|
stage?: string;
|
|
194
|
-
}): Promise<PublicEventsResponse>;
|
|
291
|
+
} & SdkMethodOptions): Promise<PublicEventsResponse>;
|
|
195
292
|
/**
|
|
196
293
|
* Resolve an event occurrence by URL segment (date or UUID)
|
|
197
294
|
*
|
|
@@ -220,7 +317,7 @@ interface RiverbankClient {
|
|
|
220
317
|
siteId: string;
|
|
221
318
|
entryId: string;
|
|
222
319
|
segment: string;
|
|
223
|
-
}): Promise<ResolveEventOccurrenceResponse>;
|
|
320
|
+
} & SdkMethodOptions): Promise<ResolveEventOccurrenceResponse>;
|
|
224
321
|
/**
|
|
225
322
|
* Check if a path has a configured redirect rule
|
|
226
323
|
*
|
|
@@ -241,11 +338,23 @@ interface RiverbankClient {
|
|
|
241
338
|
checkRedirect(params: {
|
|
242
339
|
siteId: string;
|
|
243
340
|
path: string;
|
|
244
|
-
}): Promise<CheckRedirectResponse>;
|
|
341
|
+
} & SdkMethodOptions): Promise<CheckRedirectResponse>;
|
|
245
342
|
/**
|
|
246
343
|
* Force clear the cache
|
|
247
344
|
*/
|
|
248
345
|
clearCache(): void;
|
|
346
|
+
/**
|
|
347
|
+
* Get the status from the most recently emitted request
|
|
348
|
+
*
|
|
349
|
+
* Note: With concurrent requests, this returns the last status emitted,
|
|
350
|
+
* which may not be from the request you're interested in. For reliable
|
|
351
|
+
* per-request status, use the onStatusChange callback instead.
|
|
352
|
+
*/
|
|
353
|
+
getLastEmittedStatus(): ResilienceStatus | null;
|
|
354
|
+
/**
|
|
355
|
+
* Get the current circuit breaker state
|
|
356
|
+
*/
|
|
357
|
+
getCircuitState(): CircuitState;
|
|
249
358
|
}
|
|
250
359
|
|
|
251
360
|
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 };
|
|
@@ -0,0 +1,75 @@
|
|
|
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.ZodString;
|
|
14
|
+
timestamp: z.ZodString;
|
|
15
|
+
siteId: z.ZodString;
|
|
16
|
+
data: z.ZodRecord<z.ZodString, z.ZodAny>;
|
|
17
|
+
tags: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
18
|
+
}, z.core.$strip>;
|
|
19
|
+
/**
|
|
20
|
+
* Webhook payload structure sent by the CMS.
|
|
21
|
+
*/
|
|
22
|
+
type WebhookPayload = z.infer<typeof WebhookPayloadSchema>;
|
|
23
|
+
/**
|
|
24
|
+
* Verify a webhook signature using HMAC-SHA256.
|
|
25
|
+
*
|
|
26
|
+
* Uses timing-safe comparison to prevent timing attacks.
|
|
27
|
+
*
|
|
28
|
+
* @param payload - The raw request body as a string
|
|
29
|
+
* @param signature - The X-Riverbank-Signature header value
|
|
30
|
+
* @param secret - The webhook signing secret (RIVERBANK_WEBHOOK_SECRET)
|
|
31
|
+
* @returns true if signature is valid, false otherwise
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* ```ts
|
|
35
|
+
* const body = await request.text();
|
|
36
|
+
* const signature = request.headers.get('x-riverbank-signature');
|
|
37
|
+
* const secret = process.env.RIVERBANK_WEBHOOK_SECRET;
|
|
38
|
+
*
|
|
39
|
+
* if (!verifyWebhookSignature(body, signature, secret)) {
|
|
40
|
+
* return new Response('Invalid signature', { status: 401 });
|
|
41
|
+
* }
|
|
42
|
+
* ```
|
|
43
|
+
*/
|
|
44
|
+
declare function verifyWebhookSignature(payload: string, signature: string, secret: string): boolean;
|
|
45
|
+
/**
|
|
46
|
+
* Result type for webhook payload parsing.
|
|
47
|
+
*/
|
|
48
|
+
type ParseWebhookResult = {
|
|
49
|
+
success: true;
|
|
50
|
+
payload: WebhookPayload;
|
|
51
|
+
} | {
|
|
52
|
+
success: false;
|
|
53
|
+
error: string;
|
|
54
|
+
};
|
|
55
|
+
/**
|
|
56
|
+
* Parse and validate a webhook payload from the request body.
|
|
57
|
+
*
|
|
58
|
+
* Uses Zod schema validation to ensure the payload has the expected structure.
|
|
59
|
+
*
|
|
60
|
+
* @param body - The raw request body as a string
|
|
61
|
+
* @returns A result object with either the validated payload or an error message
|
|
62
|
+
*
|
|
63
|
+
* @example
|
|
64
|
+
* ```ts
|
|
65
|
+
* const body = await request.text();
|
|
66
|
+
* const result = parseWebhookPayload(body);
|
|
67
|
+
* if (!result.success) {
|
|
68
|
+
* return new Response(result.error, { status: 400 });
|
|
69
|
+
* }
|
|
70
|
+
* console.log(`Received ${result.payload.event} for site ${result.payload.siteId}`);
|
|
71
|
+
* ```
|
|
72
|
+
*/
|
|
73
|
+
declare function parseWebhookPayload(body: string): ParseWebhookResult;
|
|
74
|
+
|
|
75
|
+
export { type ParseWebhookResult, type WebhookPayload, WebhookPayloadSchema, parseWebhookPayload, verifyWebhookSignature };
|
|
@@ -0,0 +1,75 @@
|
|
|
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.ZodString;
|
|
14
|
+
timestamp: z.ZodString;
|
|
15
|
+
siteId: z.ZodString;
|
|
16
|
+
data: z.ZodRecord<z.ZodString, z.ZodAny>;
|
|
17
|
+
tags: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
18
|
+
}, z.core.$strip>;
|
|
19
|
+
/**
|
|
20
|
+
* Webhook payload structure sent by the CMS.
|
|
21
|
+
*/
|
|
22
|
+
type WebhookPayload = z.infer<typeof WebhookPayloadSchema>;
|
|
23
|
+
/**
|
|
24
|
+
* Verify a webhook signature using HMAC-SHA256.
|
|
25
|
+
*
|
|
26
|
+
* Uses timing-safe comparison to prevent timing attacks.
|
|
27
|
+
*
|
|
28
|
+
* @param payload - The raw request body as a string
|
|
29
|
+
* @param signature - The X-Riverbank-Signature header value
|
|
30
|
+
* @param secret - The webhook signing secret (RIVERBANK_WEBHOOK_SECRET)
|
|
31
|
+
* @returns true if signature is valid, false otherwise
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* ```ts
|
|
35
|
+
* const body = await request.text();
|
|
36
|
+
* const signature = request.headers.get('x-riverbank-signature');
|
|
37
|
+
* const secret = process.env.RIVERBANK_WEBHOOK_SECRET;
|
|
38
|
+
*
|
|
39
|
+
* if (!verifyWebhookSignature(body, signature, secret)) {
|
|
40
|
+
* return new Response('Invalid signature', { status: 401 });
|
|
41
|
+
* }
|
|
42
|
+
* ```
|
|
43
|
+
*/
|
|
44
|
+
declare function verifyWebhookSignature(payload: string, signature: string, secret: string): boolean;
|
|
45
|
+
/**
|
|
46
|
+
* Result type for webhook payload parsing.
|
|
47
|
+
*/
|
|
48
|
+
type ParseWebhookResult = {
|
|
49
|
+
success: true;
|
|
50
|
+
payload: WebhookPayload;
|
|
51
|
+
} | {
|
|
52
|
+
success: false;
|
|
53
|
+
error: string;
|
|
54
|
+
};
|
|
55
|
+
/**
|
|
56
|
+
* Parse and validate a webhook payload from the request body.
|
|
57
|
+
*
|
|
58
|
+
* Uses Zod schema validation to ensure the payload has the expected structure.
|
|
59
|
+
*
|
|
60
|
+
* @param body - The raw request body as a string
|
|
61
|
+
* @returns A result object with either the validated payload or an error message
|
|
62
|
+
*
|
|
63
|
+
* @example
|
|
64
|
+
* ```ts
|
|
65
|
+
* const body = await request.text();
|
|
66
|
+
* const result = parseWebhookPayload(body);
|
|
67
|
+
* if (!result.success) {
|
|
68
|
+
* return new Response(result.error, { status: 400 });
|
|
69
|
+
* }
|
|
70
|
+
* console.log(`Received ${result.payload.event} for site ${result.payload.siteId}`);
|
|
71
|
+
* ```
|
|
72
|
+
*/
|
|
73
|
+
declare function parseWebhookPayload(body: string): ParseWebhookResult;
|
|
74
|
+
|
|
75
|
+
export { type ParseWebhookResult, type WebhookPayload, WebhookPayloadSchema, parseWebhookPayload, verifyWebhookSignature };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
var _chunkVODFQMUWjs = require('./chunk-VODFQMUW.js');
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
exports.WebhookPayloadSchema = _chunkVODFQMUWjs.WebhookPayloadSchema; exports.parseWebhookPayload = _chunkVODFQMUWjs.parseWebhookPayload; exports.verifyWebhookSignature = _chunkVODFQMUWjs.verifyWebhookSignature;
|
|
11
|
+
//# 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;AACE;AACA;AACA;AACF,mNAAC","file":"/Users/will/Projects/Business/cms/builder/packages/sdk/dist/server/webhooks.js"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@riverbankcms/sdk",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.2",
|
|
4
4
|
"description": "Riverbank CMS SDK for headless content consumption",
|
|
5
5
|
"main": "./dist/server/index.js",
|
|
6
6
|
"module": "./dist/server/index.mjs",
|
|
@@ -104,6 +104,26 @@
|
|
|
104
104
|
"import": "./dist/server/theme-bridge.mjs",
|
|
105
105
|
"require": "./dist/server/theme-bridge.js"
|
|
106
106
|
},
|
|
107
|
+
"./env": {
|
|
108
|
+
"types": "./dist/server/env.d.ts",
|
|
109
|
+
"import": "./dist/server/env.mjs",
|
|
110
|
+
"require": "./dist/server/env.js"
|
|
111
|
+
},
|
|
112
|
+
"./next/revalidate": {
|
|
113
|
+
"types": "./dist/server/next/revalidate.d.ts",
|
|
114
|
+
"import": "./dist/server/next/revalidate.mjs",
|
|
115
|
+
"require": "./dist/server/next/revalidate.js"
|
|
116
|
+
},
|
|
117
|
+
"./next/tags": {
|
|
118
|
+
"types": "./dist/server/next/tags.d.ts",
|
|
119
|
+
"import": "./dist/server/next/tags.mjs",
|
|
120
|
+
"require": "./dist/server/next/tags.js"
|
|
121
|
+
},
|
|
122
|
+
"./webhooks": {
|
|
123
|
+
"types": "./dist/server/webhooks.d.ts",
|
|
124
|
+
"import": "./dist/server/webhooks.mjs",
|
|
125
|
+
"require": "./dist/server/webhooks.js"
|
|
126
|
+
},
|
|
107
127
|
"./styles.css": "./src/styles/index.css"
|
|
108
128
|
},
|
|
109
129
|
"files": [
|
|
@@ -128,7 +148,7 @@
|
|
|
128
148
|
"zod": "^4.1.1"
|
|
129
149
|
},
|
|
130
150
|
"peerDependencies": {
|
|
131
|
-
"next": "
|
|
151
|
+
"next": ">=14.0.0",
|
|
132
152
|
"react": "^19.2.1",
|
|
133
153
|
"react-dom": "^19.2.1"
|
|
134
154
|
},
|
|
@@ -147,7 +167,7 @@
|
|
|
147
167
|
"@types/react": "^19.1.0",
|
|
148
168
|
"@types/react-dom": "^19.1.0",
|
|
149
169
|
"eslint": "^9.15.0",
|
|
150
|
-
"next": "^15.
|
|
170
|
+
"next": "^15.5.0",
|
|
151
171
|
"tsup": "^8.3.5",
|
|
152
172
|
"typescript": "^5.6.3",
|
|
153
173
|
"vitest": "^1.6.1"
|