@b10cks/client 1.2.2 → 1.4.0
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 +228 -40
- package/dist/index.d.ts +242 -9
- package/dist/index.js +7 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +253 -75
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -16,68 +16,256 @@ import { ApiClient, createB10cksDataApi } from '@b10cks/client'
|
|
|
16
16
|
const client = new ApiClient({
|
|
17
17
|
baseUrl: 'https://api.b10cks.com/api',
|
|
18
18
|
token: 'your-access-token',
|
|
19
|
-
|
|
19
|
+
version: 'published', // 'published' (default) or 'draft'
|
|
20
|
+
rv: 0, // revision token — pass Date.now() to bypass CDN cache
|
|
20
21
|
})
|
|
21
22
|
|
|
23
|
+
// Factory function — equivalent to new B10cksDataApi(client)
|
|
22
24
|
const dataApi = createB10cksDataApi(client)
|
|
25
|
+
// or: import { B10cksDataApi } from '@b10cks/client'; const dataApi = new B10cksDataApi(client)
|
|
23
26
|
|
|
24
|
-
// Fetch
|
|
25
|
-
const blocks = await dataApi.getBlocks()
|
|
26
|
-
|
|
27
|
-
// Fetch the first page of contents
|
|
27
|
+
// Fetch a page of contents
|
|
28
28
|
const contents = await dataApi.getContents({ vid: 'published', page: 1, per_page: 20 })
|
|
29
29
|
|
|
30
30
|
// Fetch all contents across all pages
|
|
31
|
-
const allContents = await dataApi.getContents(
|
|
32
|
-
{ vid: 'published', per_page: 100 },
|
|
33
|
-
{ allPages: true }
|
|
34
|
-
)
|
|
31
|
+
const allContents = await dataApi.getContents({ vid: 'published' }, { allPages: true })
|
|
35
32
|
|
|
36
|
-
// Fetch a
|
|
33
|
+
// Fetch a single content entry by slug
|
|
37
34
|
const content = await dataApi.getContent('home', { vid: 'draft' })
|
|
38
35
|
|
|
39
|
-
// Fetch
|
|
40
|
-
const
|
|
36
|
+
// Fetch a single block by ID
|
|
37
|
+
const block = await dataApi.getBlock('block-id')
|
|
38
|
+
|
|
39
|
+
// Full-text search
|
|
40
|
+
const results = await dataApi.search({ q: 'hello world', language: 'en' })
|
|
41
41
|
|
|
42
|
-
//
|
|
43
|
-
const
|
|
42
|
+
// Redirect lookup (POST)
|
|
43
|
+
const redirect = await dataApi.lookupRedirect('/old-path')
|
|
44
|
+
if (redirect) {
|
|
45
|
+
console.log(redirect.target, redirect.status_code)
|
|
46
|
+
}
|
|
44
47
|
```
|
|
45
48
|
|
|
46
|
-
##
|
|
49
|
+
## Typed Filters
|
|
47
50
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
- **Flexible Fetch**: Use browser fetch, Node fetch, or a custom fetch implementation
|
|
51
|
+
`getContents`, `getBlocks`, and `getRedirects` accept a `filter` object whose fields map directly to the Laravel AdvancedFilter query-param scheme. Filter values can be plain values, operator objects, or date ranges — they are serialized to the wire format (`op:value`) automatically.
|
|
52
|
+
|
|
53
|
+
```typescript
|
|
54
|
+
import { serializeFilter } from '@b10cks/client'
|
|
53
55
|
|
|
54
|
-
|
|
56
|
+
// Typed filter on getContents
|
|
57
|
+
const contents = await dataApi.getContents({
|
|
58
|
+
filter: {
|
|
59
|
+
language: 'en',
|
|
60
|
+
content_type: 'article',
|
|
61
|
+
published_at: { gte: '2024-01-01T00:00:00Z' },
|
|
62
|
+
parent_id: { in: ['id-1', 'id-2'] },
|
|
63
|
+
include_fallback: true,
|
|
64
|
+
},
|
|
65
|
+
sort: ['-published_at', 'content.title'],
|
|
66
|
+
})
|
|
55
67
|
|
|
56
|
-
|
|
57
|
-
|
|
68
|
+
// Typed filter on getBlocks
|
|
69
|
+
const blocks = await dataApi.getBlocks({
|
|
70
|
+
filter: {
|
|
71
|
+
is_nestable: true,
|
|
72
|
+
tags: ['hero', 'banner'],
|
|
73
|
+
updated_at: { between: ['2024-01-01T00:00:00Z', '2024-12-31T23:59:59Z'] },
|
|
74
|
+
},
|
|
75
|
+
})
|
|
76
|
+
|
|
77
|
+
// Typed filter on getRedirects
|
|
78
|
+
const redirectMap = await dataApi.getRedirects({
|
|
79
|
+
filter: { source: { '^like': '/blog' } },
|
|
80
|
+
})
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
### Filter operators
|
|
84
|
+
|
|
85
|
+
| Operator object | Wire format | Meaning |
|
|
86
|
+
|---|---|---|
|
|
87
|
+
| `'value'` | `value` | Exact match |
|
|
88
|
+
| `{ eq: 'v' }` | `eq:v` | Exact match |
|
|
89
|
+
| `{ neq: 'v' }` | `neq:v` | Not equal |
|
|
90
|
+
| `{ in: ['a','b'] }` | `in:a,b` | One of |
|
|
91
|
+
| `{ '!in': ['a','b'] }` | `!in:a,b` | None of |
|
|
92
|
+
| `{ like: 'v' }` | `like:v` | Contains |
|
|
93
|
+
| `{ '!like': 'v' }` | `!like:v` | Does not contain |
|
|
94
|
+
| `{ '^like': 'v' }` | `^like:v` | Starts with |
|
|
95
|
+
| `{ 'like$': 'v' }` | `like$:v` | Ends with |
|
|
96
|
+
| `{ gte: 'v' }` | `gte:v` | Greater than or equal |
|
|
97
|
+
| `{ gt: 'v' }` | `gt:v` | Greater than |
|
|
98
|
+
| `{ lte: 'v' }` | `lte:v` | Less than or equal |
|
|
99
|
+
| `{ lt: 'v' }` | `lt:v` | Less than |
|
|
100
|
+
| `{ between: ['a','b'] }` | `a...b` | Range (dates) |
|
|
101
|
+
| `{ null: true }` | `null:` | Is null |
|
|
102
|
+
| `{ '!null': true }` | `!null:` | Is not null |
|
|
103
|
+
|
|
104
|
+
### Content sort
|
|
105
|
+
|
|
106
|
+
`sort` accepts a string or a typed array of `ContentSortItem` values. Prefix with `-` for descending order. JSON content fields are supported via `content.{field}`.
|
|
107
|
+
|
|
108
|
+
```typescript
|
|
109
|
+
sort: '-published_at' // single field, descending
|
|
110
|
+
sort: ['updated_at', '-created_at']
|
|
111
|
+
sort: ['content.title', '-published_at']
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
### `serializeFilter` utility
|
|
115
|
+
|
|
116
|
+
If you need the flat query params for your own requests, `serializeFilter` is exported:
|
|
117
|
+
|
|
118
|
+
```typescript
|
|
119
|
+
import { serializeFilter } from '@b10cks/client'
|
|
120
|
+
|
|
121
|
+
const params = serializeFilter({
|
|
122
|
+
language: 'en',
|
|
123
|
+
published_at: { gte: '2024-01-01T00:00:00Z' },
|
|
124
|
+
id: { in: ['a', 'b'] },
|
|
125
|
+
})
|
|
126
|
+
// → { language: 'en', published_at: 'gte:2024-01-01T00:00:00Z', id: 'in:a,b' }
|
|
127
|
+
```
|
|
58
128
|
|
|
59
129
|
## Data API Methods
|
|
60
130
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
131
|
+
| Method | Description |
|
|
132
|
+
|---|---|
|
|
133
|
+
| `getContent(slug, params)` | Single content entry by full slug |
|
|
134
|
+
| `getContents(params, options)` | List of content entries |
|
|
135
|
+
| `getBlock(blockId, params)` | Single block by ID |
|
|
136
|
+
| `getBlocks(params, options)` | List of blocks |
|
|
137
|
+
| `search(params)` | Full-text content search (`q`, `limit`, `offset`, `language`) |
|
|
138
|
+
| `lookupRedirect(source)` | POST redirect lookup for a given source path |
|
|
139
|
+
| `getRedirects(params, options)` | Redirect map (cached when `allPages: true`) |
|
|
140
|
+
| `getDataEntries(source, params, options)` | Entries for a data source slug |
|
|
141
|
+
| `getDataSources(params, options)` | List of data sources |
|
|
142
|
+
| `getSitemap(params, options)` | Sitemap entries |
|
|
143
|
+
| `getSpace(params)` | Current space info |
|
|
144
|
+
| `getConfig(options)` | Config content entry (cached) |
|
|
145
|
+
| `syncRevision(fallbackRv)` | Sync local RV from the space |
|
|
146
|
+
| `clearCache()` | Clear redirect and config caches |
|
|
147
|
+
|
|
148
|
+
Pass `{ allPages: true }` as the second argument to any collection method to fetch every page automatically.
|
|
149
|
+
|
|
150
|
+
## `ApiClient` configuration
|
|
151
|
+
|
|
152
|
+
```typescript
|
|
153
|
+
interface B10cksApiClientOptions {
|
|
154
|
+
baseUrl: string // Base URL of the b10cks data API (include `/api`)
|
|
155
|
+
token: string // Space access token
|
|
156
|
+
version?: 'published' | 'draft' // Content version to fetch (default: 'published')
|
|
157
|
+
rv?: string | number // Revision token; use Date.now() to bypass CDN cache
|
|
158
|
+
fetchClient?: FetchClient // Custom fetch implementation (required in environments without globalThis.fetch)
|
|
159
|
+
getRv?: () => string | number // Custom getter for the shared revision token
|
|
160
|
+
setRv?: (value: string | number) => void // Custom setter for the shared revision token
|
|
161
|
+
}
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
## Low-level `ApiClient`
|
|
165
|
+
|
|
166
|
+
`ApiClient` implements the `DataApiClient` interface and can be used directly for one-off requests:
|
|
167
|
+
|
|
168
|
+
```typescript
|
|
169
|
+
const client = new ApiClient({ baseUrl, token })
|
|
170
|
+
|
|
171
|
+
// GET with custom params — all extra keys are forwarded as query params as-is
|
|
172
|
+
const data = await client.get('contents', { page: 1, language_iso: 'de', vid: 'published' })
|
|
173
|
+
|
|
174
|
+
// Per-request rv override — pass rv in params to override the instance-level revision token
|
|
175
|
+
// (useful to bypass CDN cache for a single request without affecting other calls)
|
|
176
|
+
const fresh = await client.get('contents', { rv: Date.now() })
|
|
177
|
+
|
|
178
|
+
// GET all pages
|
|
179
|
+
const all = await client.getAll('blocks')
|
|
180
|
+
|
|
181
|
+
// POST (e.g. redirects/lookup)
|
|
182
|
+
const result = await client.post('redirects/lookup', { source: '/old' })
|
|
183
|
+
```
|
|
71
184
|
|
|
72
185
|
## Supported Endpoints
|
|
73
186
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
187
|
+
| Endpoint | Methods |
|
|
188
|
+
|---|---|
|
|
189
|
+
| `blocks` | GET (list) |
|
|
190
|
+
| `blocks/{id}` | GET (single) |
|
|
191
|
+
| `contents` | GET (list) |
|
|
192
|
+
| `contents/{slug}` | GET (single) |
|
|
193
|
+
| `datasources` | GET (list) |
|
|
194
|
+
| `datasources/{slug}/entries` | GET (list) |
|
|
195
|
+
| `redirects` | GET (list) |
|
|
196
|
+
| `redirects/lookup` | POST |
|
|
197
|
+
| `search` | GET |
|
|
198
|
+
| `sitemap` | GET (list) |
|
|
199
|
+
| `spaces/me` | GET |
|
|
200
|
+
|
|
201
|
+
## Link resolution
|
|
202
|
+
|
|
203
|
+
`resolveB10cksLink` converts a `B10cksLink` value (the union type emitted by the type generator for `link`-type fields) into a plain `{ href, target }` object. Locale prefixing and router integration are left to the caller.
|
|
204
|
+
|
|
205
|
+
```typescript
|
|
206
|
+
import { resolveB10cksLink } from '@b10cks/client'
|
|
207
|
+
|
|
208
|
+
const resolved = resolveB10cksLink(block.ctaLink)
|
|
209
|
+
// resolved: { href: 'https://example.com', target: '_blank' }
|
|
210
|
+
// or: { href: 'mailto:hi@example.com', target: '_self' }
|
|
211
|
+
// or: undefined (when link is nullish or type === 'asset')
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
## Sitemap utilities
|
|
215
|
+
|
|
216
|
+
Framework-agnostic helpers for building multilingual sitemaps from `IBSitemapEntry[]`.
|
|
217
|
+
|
|
218
|
+
```typescript
|
|
219
|
+
import {
|
|
220
|
+
buildLocalizedPath,
|
|
221
|
+
filterSitemapEntries,
|
|
222
|
+
renderSitemapXml,
|
|
223
|
+
renderSitemapIndex,
|
|
224
|
+
} from '@b10cks/client'
|
|
225
|
+
|
|
226
|
+
// Build a rooted locale-prefixed path from a content entry
|
|
227
|
+
buildLocalizedPath('about', 'en') // → '/en/about'
|
|
228
|
+
buildLocalizedPath('home', 'en') // → '/en'
|
|
229
|
+
buildLocalizedPath('de/uber-uns', 'de') // → '/de/uber-uns' (no double prefix)
|
|
230
|
+
|
|
231
|
+
// Filter: deduplicate, drop noindex, optionally restrict to one locale
|
|
232
|
+
const filtered = filterSitemapEntries(entries, {
|
|
233
|
+
siteUrl: 'https://example.com',
|
|
234
|
+
locale: 'en',
|
|
235
|
+
})
|
|
236
|
+
|
|
237
|
+
// Render <urlset> XML
|
|
238
|
+
const xml = renderSitemapXml(filtered, 'https://example.com')
|
|
239
|
+
|
|
240
|
+
// Render <sitemapindex> XML for multi-sitemap setups
|
|
241
|
+
const index = renderSitemapIndex(['/sitemap-en.xml', '/sitemap-de.xml'], 'https://example.com')
|
|
242
|
+
```
|
|
243
|
+
|
|
244
|
+
## TypeScript
|
|
245
|
+
|
|
246
|
+
Common types exported from the package root:
|
|
247
|
+
|
|
248
|
+
```typescript
|
|
249
|
+
import type {
|
|
250
|
+
B10cksLink, // Union type for link fields (url | email | internal | asset)
|
|
251
|
+
B10cksLinkResolved, // Return type of resolveB10cksLink
|
|
252
|
+
IBContent, // A content entry (generic: IBContent<YourContentShape>)
|
|
253
|
+
IBContentBlock, // Base block shape with id and block fields
|
|
254
|
+
IBBlock, // A block schema
|
|
255
|
+
IBDataEntry, // A data source entry (key/value)
|
|
256
|
+
IBDataSource, // A data source definition
|
|
257
|
+
IBSitemapEntry, // Sitemap entry with full_slug, language_iso, meta, published_at
|
|
258
|
+
IBSeoMeta, // robots and canonical fields
|
|
259
|
+
IBSpace, // Space info
|
|
260
|
+
IBRedirect, // Redirect rule (source, target, status_code)
|
|
261
|
+
IBSearchResult, // Search result extending IBContent with relevance_score
|
|
262
|
+
IBSearchResponse, // Wrapper around IBSearchResult[]
|
|
263
|
+
IBCollectionResponse,// Paginated list envelope
|
|
264
|
+
IBMeta, // Pagination metadata (total, last_page, per_page, …)
|
|
265
|
+
IBResponse, // Single-item envelope { data, rv }
|
|
266
|
+
B10cksApiClientOptions,
|
|
267
|
+
} from '@b10cks/client'
|
|
268
|
+
```
|
|
81
269
|
|
|
82
270
|
## License
|
|
83
271
|
|
package/dist/index.d.ts
CHANGED
|
@@ -6,8 +6,9 @@ export declare class ApiClient {
|
|
|
6
6
|
private readonly getRvFn?;
|
|
7
7
|
private readonly setRvFn?;
|
|
8
8
|
constructor(options: B10cksApiClientOptions, requestUrl?: URL | string);
|
|
9
|
-
get<T>(endpoint: Endpoint, params?: Omit<IBBaseQueryParams, 'token'>): Promise<ApiResourceResponse<T>>;
|
|
10
|
-
|
|
9
|
+
get<T>(endpoint: Endpoint, params?: Omit<IBBaseQueryParams, 'token'> & Record<string, unknown>): Promise<ApiResourceResponse<T>>;
|
|
10
|
+
post<T>(endpoint: string, body?: unknown, params?: Omit<IBBaseQueryParams, 'token'> & Record<string, unknown>): Promise<T>;
|
|
11
|
+
getAll<T>(endpoint: Endpoint, params?: Omit<IBBaseQueryParams, 'token'> & Record<string, unknown>): Promise<T[]>;
|
|
11
12
|
setRv(value: string | number): void;
|
|
12
13
|
getRv(): string | number;
|
|
13
14
|
private parseResponse;
|
|
@@ -19,7 +20,7 @@ export declare class ApiClient {
|
|
|
19
20
|
private isCollectionResponseEnvelope;
|
|
20
21
|
}
|
|
21
22
|
|
|
22
|
-
declare type ApiQueryParams = Omit<IBBaseQueryParams, 'token'>;
|
|
23
|
+
declare type ApiQueryParams = Omit<IBBaseQueryParams, 'token'> & Record<string, unknown>;
|
|
23
24
|
|
|
24
25
|
declare type ApiResourceResponse<T> = IBResponse<T> | T;
|
|
25
26
|
|
|
@@ -46,14 +47,17 @@ export declare class B10cksDataApi {
|
|
|
46
47
|
getResource<T>(endpoint: Endpoint, params?: ApiQueryParams): Promise<T>;
|
|
47
48
|
getCollection<T>(endpoint: Endpoint, params?: ApiQueryParams, options?: CollectionFetchOptions): Promise<T[]>;
|
|
48
49
|
getContent<T = Record<string, unknown>>(fullSlug: string, params?: Omit<IBContentQueryParams, 'token' | 'full_slug'>): Promise<IBContent<T>>;
|
|
49
|
-
getContents<T = Record<string, unknown>>(params?:
|
|
50
|
-
|
|
50
|
+
getContents<T = Record<string, unknown>>(params?: IBGetContentsParams, options?: CollectionFetchOptions): Promise<IBContent<T>[]>;
|
|
51
|
+
getBlock(blockId: string, params?: ApiQueryParams): Promise<IBBlock>;
|
|
52
|
+
getBlocks(params?: IBGetBlocksParams, options?: CollectionFetchOptions): Promise<IBBlock[]>;
|
|
53
|
+
search<T = Record<string, unknown>>(params: IBSearchParams): Promise<IBSearchResponse<T>>;
|
|
51
54
|
getSitemap(params?: Omit<IBContentQueryParams, 'token'>, options?: CollectionFetchOptions): Promise<IBSitemapEntry[]>;
|
|
52
55
|
getDataEntries(source: string, params?: ApiQueryParams, options?: CollectionFetchOptions): Promise<IBDataEntry[]>;
|
|
53
56
|
getDataSources(params?: ApiQueryParams, options?: CollectionFetchOptions): Promise<IBDataSource[]>;
|
|
54
57
|
getSpace(params?: ApiQueryParams): Promise<IBSpace>;
|
|
55
|
-
|
|
56
|
-
getRedirects(params?:
|
|
58
|
+
lookupRedirect(source: string): Promise<IBRedirectLookupResult | false>;
|
|
59
|
+
getRedirects(params?: IBGetRedirectsParams, forceRefresh?: boolean): Promise<RedirectMap>;
|
|
60
|
+
getRedirects(params?: IBGetRedirectsParams, options?: RedirectFetchOptions): Promise<RedirectMap>;
|
|
57
61
|
getConfig<T = Record<string, unknown>>({ slug, language_iso, language, bypassCache, ...params }?: GetConfigOptions): Promise<T>;
|
|
58
62
|
syncRevision(fallbackRv?: number): Promise<string | number>;
|
|
59
63
|
clearCache(): void;
|
|
@@ -61,16 +65,59 @@ export declare class B10cksDataApi {
|
|
|
61
65
|
private unwrapCollection;
|
|
62
66
|
}
|
|
63
67
|
|
|
68
|
+
export declare type B10cksLink = {
|
|
69
|
+
type: 'url';
|
|
70
|
+
url: string;
|
|
71
|
+
anchor?: string;
|
|
72
|
+
target?: '_self' | '_blank' | '_parent' | '_top';
|
|
73
|
+
rel?: string;
|
|
74
|
+
} | {
|
|
75
|
+
type: 'email';
|
|
76
|
+
email: string;
|
|
77
|
+
subject?: string;
|
|
78
|
+
body?: string;
|
|
79
|
+
cc?: string;
|
|
80
|
+
bcc?: string;
|
|
81
|
+
} | {
|
|
82
|
+
type: 'internal';
|
|
83
|
+
url: string;
|
|
84
|
+
title: string;
|
|
85
|
+
content: string;
|
|
86
|
+
params?: string;
|
|
87
|
+
anchor?: string;
|
|
88
|
+
target?: '_self' | '_blank' | '_parent' | '_top';
|
|
89
|
+
} | {
|
|
90
|
+
type: 'asset';
|
|
91
|
+
id: string;
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
export declare interface B10cksLinkResolved {
|
|
95
|
+
href: string;
|
|
96
|
+
target: string;
|
|
97
|
+
}
|
|
98
|
+
|
|
64
99
|
export declare type BridgeEvent = {
|
|
65
100
|
type: EventType;
|
|
66
101
|
payload: EventPayloadMap[EventType];
|
|
67
102
|
b10cksId?: string;
|
|
68
103
|
};
|
|
69
104
|
|
|
105
|
+
/**
|
|
106
|
+
* Combines a b10cks `full_slug` and `language_iso` into a rooted, locale-prefixed path.
|
|
107
|
+
*
|
|
108
|
+
* - The slug `home` is treated as the root (`/` or `/<locale>`).
|
|
109
|
+
* - Slugs that already start with the locale prefix are not double-prefixed.
|
|
110
|
+
*/
|
|
111
|
+
export declare function buildLocalizedPath(fullSlug: string | null | undefined, languageIso: string | null | undefined): string;
|
|
112
|
+
|
|
70
113
|
export declare interface CollectionFetchOptions {
|
|
71
114
|
allPages?: boolean;
|
|
72
115
|
}
|
|
73
116
|
|
|
117
|
+
export declare type ContentSortField = 'published_at' | 'updated_at' | 'created_at' | `content.${string}`;
|
|
118
|
+
|
|
119
|
+
export declare type ContentSortItem = ContentSortField | `-${ContentSortField}`;
|
|
120
|
+
|
|
74
121
|
export declare type ContentUpdateEvent = {
|
|
75
122
|
content: Record<string, unknown>;
|
|
76
123
|
};
|
|
@@ -83,10 +130,31 @@ export declare interface DataApiClient {
|
|
|
83
130
|
rv?: string | number;
|
|
84
131
|
}>;
|
|
85
132
|
getAll<T>(endpoint: Endpoint, params?: ApiQueryParams): Promise<T[]>;
|
|
133
|
+
post?<T>(endpoint: string, body?: unknown, params?: ApiQueryParams): Promise<T>;
|
|
86
134
|
setRv(value: string | number): void;
|
|
87
135
|
}
|
|
88
136
|
|
|
89
|
-
export declare type
|
|
137
|
+
export declare type DateFilter = string | {
|
|
138
|
+
eq: string;
|
|
139
|
+
} | {
|
|
140
|
+
neq: string;
|
|
141
|
+
} | {
|
|
142
|
+
gte: string;
|
|
143
|
+
} | {
|
|
144
|
+
gt: string;
|
|
145
|
+
} | {
|
|
146
|
+
lte: string;
|
|
147
|
+
} | {
|
|
148
|
+
lt: string;
|
|
149
|
+
} | {
|
|
150
|
+
between: [string, string];
|
|
151
|
+
} | {
|
|
152
|
+
null: true;
|
|
153
|
+
} | {
|
|
154
|
+
'!null': true;
|
|
155
|
+
};
|
|
156
|
+
|
|
157
|
+
export declare type Endpoint = 'blocks' | `blocks/${string}` | 'contents' | `contents/${string}` | `datasources/${string}/entries` | 'datasources' | 'redirects' | 'search' | 'sitemap' | 'spaces/me';
|
|
90
158
|
|
|
91
159
|
declare type EventCallback<T> = (payload: T) => void;
|
|
92
160
|
|
|
@@ -107,6 +175,11 @@ export declare type FieldUpdateEvent = {
|
|
|
107
175
|
value: string;
|
|
108
176
|
};
|
|
109
177
|
|
|
178
|
+
/**
|
|
179
|
+
* Filters sitemap entries by locale, deduplicates by resolved URL, and drops `noindex` entries.
|
|
180
|
+
*/
|
|
181
|
+
export declare function filterSitemapEntries(entries: IBSitemapEntry[], options?: SitemapFilterOptions): IBSitemapEntry[];
|
|
182
|
+
|
|
110
183
|
export declare interface GetConfigOptions extends Omit<IBContentQueryParams, 'token' | 'full_slug'> {
|
|
111
184
|
slug?: string;
|
|
112
185
|
language?: string;
|
|
@@ -129,6 +202,17 @@ export declare interface IBBlock {
|
|
|
129
202
|
updated_at: string;
|
|
130
203
|
}
|
|
131
204
|
|
|
205
|
+
export declare interface IBBlockFilter {
|
|
206
|
+
name?: string;
|
|
207
|
+
slug?: string;
|
|
208
|
+
folder_id?: string;
|
|
209
|
+
is_nestable?: boolean;
|
|
210
|
+
is_root?: boolean;
|
|
211
|
+
tags?: string | string[];
|
|
212
|
+
created_at?: DateFilter;
|
|
213
|
+
updated_at?: DateFilter;
|
|
214
|
+
}
|
|
215
|
+
|
|
132
216
|
export declare interface IBCollectionResponse<T> {
|
|
133
217
|
data: T[];
|
|
134
218
|
rv?: string | number;
|
|
@@ -163,6 +247,20 @@ export declare interface IBContentBlock<T extends string> {
|
|
|
163
247
|
block?: T;
|
|
164
248
|
}
|
|
165
249
|
|
|
250
|
+
export declare interface IBContentFilter {
|
|
251
|
+
language?: string;
|
|
252
|
+
language_iso?: string;
|
|
253
|
+
content_type?: string;
|
|
254
|
+
parent_id?: IdFilter;
|
|
255
|
+
id?: IdFilter;
|
|
256
|
+
canonical_id?: IdFilter;
|
|
257
|
+
canonical_parent_id?: IdFilter;
|
|
258
|
+
include_fallback?: boolean;
|
|
259
|
+
published_at?: DateFilter;
|
|
260
|
+
updated_at?: DateFilter;
|
|
261
|
+
created_at?: DateFilter;
|
|
262
|
+
}
|
|
263
|
+
|
|
166
264
|
export declare interface IBContentQueryParams extends IBBaseQueryParams {
|
|
167
265
|
slug?: string;
|
|
168
266
|
full_slug?: string;
|
|
@@ -198,6 +296,19 @@ export declare interface IBDataSource {
|
|
|
198
296
|
updated_at: string;
|
|
199
297
|
}
|
|
200
298
|
|
|
299
|
+
export declare interface IBGetBlocksParams extends Omit<IBBaseQueryParams, 'token'> {
|
|
300
|
+
filter?: IBBlockFilter;
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
export declare interface IBGetContentsParams extends Omit<IBContentQueryParams, 'token' | 'sort'> {
|
|
304
|
+
filter?: IBContentFilter;
|
|
305
|
+
sort?: string | ContentSortItem[];
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
export declare interface IBGetRedirectsParams extends Omit<IBBaseQueryParams, 'token'> {
|
|
309
|
+
filter?: IBRedirectFilter;
|
|
310
|
+
}
|
|
311
|
+
|
|
201
312
|
export declare interface IBMeta {
|
|
202
313
|
current_page: number;
|
|
203
314
|
from: number;
|
|
@@ -226,11 +337,48 @@ export declare interface IBRedirect {
|
|
|
226
337
|
status_code: number;
|
|
227
338
|
}
|
|
228
339
|
|
|
340
|
+
export declare interface IBRedirectFilter {
|
|
341
|
+
source?: StringFilter;
|
|
342
|
+
target?: StringFilter;
|
|
343
|
+
status_code?: string | number;
|
|
344
|
+
q?: string;
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
export declare interface IBRedirectLookupResult {
|
|
348
|
+
target: string;
|
|
349
|
+
status_code: number;
|
|
350
|
+
}
|
|
351
|
+
|
|
229
352
|
export declare interface IBResponse<T> {
|
|
230
353
|
data: T;
|
|
231
354
|
rv?: string | number;
|
|
232
355
|
}
|
|
233
356
|
|
|
357
|
+
export declare interface IBSearchParams {
|
|
358
|
+
q: string;
|
|
359
|
+
limit?: number;
|
|
360
|
+
offset?: number;
|
|
361
|
+
language?: string;
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
export declare interface IBSearchResponse<Content = IBContentBlock<string> & {
|
|
365
|
+
[index: string]: unknown;
|
|
366
|
+
}> {
|
|
367
|
+
meta: {
|
|
368
|
+
query: string;
|
|
369
|
+
total: number;
|
|
370
|
+
limit: number;
|
|
371
|
+
offset: number;
|
|
372
|
+
};
|
|
373
|
+
data: IBSearchResult<Content>[];
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
export declare interface IBSearchResult<Content = IBContentBlock<string> & {
|
|
377
|
+
[index: string]: unknown;
|
|
378
|
+
}> extends IBContent<Content> {
|
|
379
|
+
relevance_score: number;
|
|
380
|
+
}
|
|
381
|
+
|
|
234
382
|
export declare interface IBSeoMeta {
|
|
235
383
|
robots: string | null;
|
|
236
384
|
canonical: string | null;
|
|
@@ -256,6 +404,22 @@ export declare interface IBSpace {
|
|
|
256
404
|
updated_at: string;
|
|
257
405
|
}
|
|
258
406
|
|
|
407
|
+
export declare type IdFilter = string | {
|
|
408
|
+
eq: string;
|
|
409
|
+
} | {
|
|
410
|
+
neq: string;
|
|
411
|
+
} | {
|
|
412
|
+
in: string[];
|
|
413
|
+
} | {
|
|
414
|
+
'!in': string[];
|
|
415
|
+
} | {
|
|
416
|
+
null: true;
|
|
417
|
+
} | {
|
|
418
|
+
'!null': true;
|
|
419
|
+
};
|
|
420
|
+
|
|
421
|
+
export declare function normalizePathSegment(value: string | null | undefined): string;
|
|
422
|
+
|
|
259
423
|
export declare class PreviewBridge {
|
|
260
424
|
private static instance;
|
|
261
425
|
private readonly listeners;
|
|
@@ -283,10 +447,63 @@ export declare type RedirectMap = Record<string, {
|
|
|
283
447
|
status_code: number;
|
|
284
448
|
}>;
|
|
285
449
|
|
|
450
|
+
/**
|
|
451
|
+
* Renders a list of sitemap paths as a `<sitemapindex>` XML string.
|
|
452
|
+
*/
|
|
453
|
+
export declare function renderSitemapIndex(paths: string[], siteUrl?: string): string;
|
|
454
|
+
|
|
455
|
+
/**
|
|
456
|
+
* Renders `IBSitemapEntry[]` as a `<urlset>` XML string.
|
|
457
|
+
* Pass `siteUrl` to emit absolute `<loc>` values; without it, relative paths are used.
|
|
458
|
+
*/
|
|
459
|
+
export declare function renderSitemapXml(entries: IBSitemapEntry[], siteUrl?: string): string;
|
|
460
|
+
|
|
461
|
+
/**
|
|
462
|
+
* Resolves a B10cksLink value to a plain { href, target } object.
|
|
463
|
+
*
|
|
464
|
+
* - `'email'` links produce a `mailto:` href with optional subject/body/cc/bcc query params.
|
|
465
|
+
* - `'url'` and `'internal'` links use the stored `url` field; an `anchor` is appended as a
|
|
466
|
+
* hash fragment when present.
|
|
467
|
+
* - `'asset'` links cannot be resolved to a URL without the asset record — returns `undefined`.
|
|
468
|
+
* - Locale prefixing and router integration are intentionally left to the caller.
|
|
469
|
+
*/
|
|
470
|
+
export declare function resolveB10cksLink(link: B10cksLink | undefined | null): B10cksLinkResolved | undefined;
|
|
471
|
+
|
|
286
472
|
export declare type SelectUpdateEvent = {
|
|
287
473
|
selectedItem: string;
|
|
288
474
|
};
|
|
289
475
|
|
|
476
|
+
export declare function serializeFilter(filter: Record<string, unknown>): Record<string, string>;
|
|
477
|
+
|
|
478
|
+
export declare interface SitemapFilterOptions {
|
|
479
|
+
/** Absolute base URL used for deduplication. Without it, paths are compared as strings. */
|
|
480
|
+
siteUrl?: string;
|
|
481
|
+
/** Only include entries for this locale (ISO code). */
|
|
482
|
+
locale?: string;
|
|
483
|
+
}
|
|
484
|
+
|
|
485
|
+
export declare type StringFilter = string | {
|
|
486
|
+
eq: string;
|
|
487
|
+
} | {
|
|
488
|
+
neq: string;
|
|
489
|
+
} | {
|
|
490
|
+
in: string[];
|
|
491
|
+
} | {
|
|
492
|
+
'!in': string[];
|
|
493
|
+
} | {
|
|
494
|
+
like: string;
|
|
495
|
+
} | {
|
|
496
|
+
'!like': string;
|
|
497
|
+
} | {
|
|
498
|
+
'^like': string;
|
|
499
|
+
} | {
|
|
500
|
+
'like$': string;
|
|
501
|
+
} | {
|
|
502
|
+
null: true;
|
|
503
|
+
} | {
|
|
504
|
+
'!null': true;
|
|
505
|
+
};
|
|
506
|
+
|
|
290
507
|
export declare namespace types {
|
|
291
508
|
export {
|
|
292
509
|
FetchClient,
|
|
@@ -309,7 +526,23 @@ export declare namespace types {
|
|
|
309
526
|
IBSpace,
|
|
310
527
|
IBRedirect,
|
|
311
528
|
IBContentQueryParams,
|
|
312
|
-
|
|
529
|
+
B10cksLink,
|
|
530
|
+
B10cksApiClientOptions,
|
|
531
|
+
StringFilter,
|
|
532
|
+
IdFilter,
|
|
533
|
+
DateFilter,
|
|
534
|
+
IBContentFilter,
|
|
535
|
+
ContentSortField,
|
|
536
|
+
ContentSortItem,
|
|
537
|
+
IBGetContentsParams,
|
|
538
|
+
IBBlockFilter,
|
|
539
|
+
IBGetBlocksParams,
|
|
540
|
+
IBRedirectFilter,
|
|
541
|
+
IBGetRedirectsParams,
|
|
542
|
+
IBSearchResult,
|
|
543
|
+
IBSearchParams,
|
|
544
|
+
IBSearchResponse,
|
|
545
|
+
IBRedirectLookupResult
|
|
313
546
|
}
|
|
314
547
|
}
|
|
315
548
|
|