@8ux-co/eelzap 0.0.0-stage → 0.10.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/CHANGELOG.md +145 -0
- package/LICENSE +21 -0
- package/README.md +1061 -2
- package/dist/chunk-2IUU53QA.js +283 -0
- package/dist/chunk-2IUU53QA.js.map +1 -0
- package/dist/chunk-QN53G5P7.js +64 -0
- package/dist/chunk-QN53G5P7.js.map +1 -0
- package/dist/chunk-VW4EH7NY.js +1162 -0
- package/dist/chunk-VW4EH7NY.js.map +1 -0
- package/dist/fields.cjs +132 -0
- package/dist/fields.cjs.map +1 -0
- package/dist/fields.d.cts +116 -0
- package/dist/fields.d.ts +116 -0
- package/dist/fields.js +105 -0
- package/dist/fields.js.map +1 -0
- package/dist/index.cjs +2055 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +2409 -0
- package/dist/index.d.ts +2409 -0
- package/dist/index.js +1998 -0
- package/dist/index.js.map +1 -0
- package/dist/next.d.ts +281 -0
- package/dist/next.js +214 -0
- package/dist/next.js.map +1 -0
- package/dist/preview.d.ts +932 -0
- package/dist/preview.js +885 -0
- package/dist/preview.js.map +1 -0
- package/dist/react.d.ts +181 -0
- package/dist/react.js +225 -0
- package/dist/react.js.map +1 -0
- package/dist/signin-2QOSWZFK.js +305 -0
- package/dist/signin-2QOSWZFK.js.map +1 -0
- package/dist/suggest-5RHURHED.js +1256 -0
- package/dist/suggest-5RHURHED.js.map +1 -0
- package/package.json +109 -4
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,2409 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pluggable storage interface for last-known-good caching.
|
|
3
|
+
*
|
|
4
|
+
* Implement this to persist content to any backend (KV, Redis,
|
|
5
|
+
* filesystem, IndexedDB, etc.). The SDK ships a built-in
|
|
6
|
+
* {@link MemoryCacheAdapter} for processes that stay alive.
|
|
7
|
+
*/
|
|
8
|
+
interface CacheAdapter<T = unknown> {
|
|
9
|
+
get(key: string): Promise<T | undefined> | T | undefined;
|
|
10
|
+
set(key: string, value: T): Promise<void> | void;
|
|
11
|
+
}
|
|
12
|
+
type CacheStrategy = 'network-first' | 'cache-first';
|
|
13
|
+
interface CachedFetchOptions<T = unknown> {
|
|
14
|
+
key: string;
|
|
15
|
+
fetcher: () => Promise<T>;
|
|
16
|
+
adapter: CacheAdapter<T>;
|
|
17
|
+
strategy?: CacheStrategy;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Simple in-memory adapter. Suitable for long-lived server processes
|
|
21
|
+
* or development. Data is lost when the process restarts.
|
|
22
|
+
*/
|
|
23
|
+
declare class MemoryCacheAdapter implements CacheAdapter {
|
|
24
|
+
#private;
|
|
25
|
+
get(key: string): unknown;
|
|
26
|
+
set(key: string, value: unknown): void;
|
|
27
|
+
/** Returns the number of cached entries. */
|
|
28
|
+
get size(): number;
|
|
29
|
+
/** Removes a specific key from the cache. */
|
|
30
|
+
delete(key: string): boolean;
|
|
31
|
+
/** Removes all cached entries. */
|
|
32
|
+
clear(): void;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Caches content fetched from the CMS, with one of two strategies:
|
|
36
|
+
*
|
|
37
|
+
* - `network-first` (the default, and the only one the positional form
|
|
38
|
+
* uses): runs `fetcher`, caches the result on success, and falls back to
|
|
39
|
+
* the last cached value on failure.
|
|
40
|
+
* - `cache-first` (options form): returns the cached value when there is
|
|
41
|
+
* one, and fetches and caches only on a miss.
|
|
42
|
+
*
|
|
43
|
+
* If no cached value exists and the fetch fails, the original error is
|
|
44
|
+
* re-thrown — there are no hardcoded fallbacks.
|
|
45
|
+
*
|
|
46
|
+
* A preview response (a read with `preview: true`, or any read with a `zpt_`
|
|
47
|
+
* preview token) is returned but NEVER stored, under either strategy
|
|
48
|
+
* (zap-cms-v2 §7.5): it carries drafts and stega markers, and a cache entry
|
|
49
|
+
* would hand them to the next visitor.
|
|
50
|
+
*
|
|
51
|
+
* @param key - Stable cache key (e.g. `"homepage"`, `"blog-posts:page-1"`).
|
|
52
|
+
* @param fetcher - An async function that fetches fresh content from the CMS.
|
|
53
|
+
* @param adapter - Storage backend that persists last-known-good values.
|
|
54
|
+
* @returns The fresh result or the last successfully cached value.
|
|
55
|
+
*
|
|
56
|
+
* @example
|
|
57
|
+
* ```ts
|
|
58
|
+
* const cache = new MemoryCacheAdapter();
|
|
59
|
+
*
|
|
60
|
+
* const homepage = await cachedFetch(
|
|
61
|
+
* 'homepage',
|
|
62
|
+
* () => cms.documents.get('homepage'),
|
|
63
|
+
* cache,
|
|
64
|
+
* );
|
|
65
|
+
* ```
|
|
66
|
+
*/
|
|
67
|
+
declare function cachedFetch<T>(key: string, fetcher: () => Promise<T>, adapter: CacheAdapter<T>): Promise<T>;
|
|
68
|
+
declare function cachedFetch<T>(options: CachedFetchOptions<T>): Promise<T>;
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Supported delivery status filters.
|
|
72
|
+
*/
|
|
73
|
+
type DeliveryStatus = 'published' | 'draft' | 'all';
|
|
74
|
+
/**
|
|
75
|
+
* A primitive value accepted in query parameters.
|
|
76
|
+
*/
|
|
77
|
+
type QueryPrimitive = string | number | boolean;
|
|
78
|
+
/**
|
|
79
|
+
* Pagination metadata returned by list endpoints.
|
|
80
|
+
*/
|
|
81
|
+
interface Pagination {
|
|
82
|
+
page: number;
|
|
83
|
+
pageSize: number;
|
|
84
|
+
pageCount: number;
|
|
85
|
+
total: number;
|
|
86
|
+
}
|
|
87
|
+
type JsonObject = {
|
|
88
|
+
[key: string]: string | number | boolean | null | JsonObject | JsonObject[];
|
|
89
|
+
};
|
|
90
|
+
/**
|
|
91
|
+
* Site metadata resolved from the authenticated API key.
|
|
92
|
+
*/
|
|
93
|
+
interface SiteInfo {
|
|
94
|
+
id: string;
|
|
95
|
+
name: string;
|
|
96
|
+
key: string;
|
|
97
|
+
/** The site's address (https; http only on a development host); null until set. */
|
|
98
|
+
url?: string | null;
|
|
99
|
+
defaultLocale: string;
|
|
100
|
+
locales: string[];
|
|
101
|
+
/**
|
|
102
|
+
* «Otros dominios»: origins beyond `url`'s own where drafts may be shown
|
|
103
|
+
* (a staging host, `http://localhost:3000`). Answered by `GET /site`.
|
|
104
|
+
*/
|
|
105
|
+
previewOrigins?: string[];
|
|
106
|
+
createdAt: string;
|
|
107
|
+
updatedAt: string;
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* `site.update()`: where the site lives. Send at least one. Needs a `secret_`
|
|
111
|
+
* key, or a suite credential with `zap:schema:write` and an ADMIN seat.
|
|
112
|
+
*/
|
|
113
|
+
interface UpdateSiteInput {
|
|
114
|
+
/** https, or http on a development host such as `localhost`; `null` clears it. */
|
|
115
|
+
url?: string | null;
|
|
116
|
+
/**
|
|
117
|
+
* Replaces the stored list. Each entry is an origin: https, or
|
|
118
|
+
* `http://localhost` / `http://127.0.0.1` with any port; never a Zap or
|
|
119
|
+
* `eel.software` host. Normalised to its origin and deduplicated.
|
|
120
|
+
*/
|
|
121
|
+
previewOrigins?: string[];
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* One of the workspace's sites (`GET /sites`): `GET /site`'s body plus `url`.
|
|
125
|
+
* Its `key` or its `id` is a valid `X-Eel-Site` for every other route.
|
|
126
|
+
*/
|
|
127
|
+
interface SiteListEntry extends SiteInfo {
|
|
128
|
+
url: string | null;
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* `GET /preview/token`: the preview token is live and was minted for the site
|
|
132
|
+
* the given site API key belongs to.
|
|
133
|
+
*/
|
|
134
|
+
interface PreviewTokenValidation {
|
|
135
|
+
site: {
|
|
136
|
+
key: string;
|
|
137
|
+
};
|
|
138
|
+
/** ISO 8601: when the token stops working. */
|
|
139
|
+
expiresAt?: string;
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* SEO metadata resolved for the current locale.
|
|
143
|
+
*/
|
|
144
|
+
interface SeoImage {
|
|
145
|
+
url: string;
|
|
146
|
+
alt: string | null;
|
|
147
|
+
width: number | null;
|
|
148
|
+
height: number | null;
|
|
149
|
+
type: string | null;
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* SEO metadata resolved for the current locale.
|
|
153
|
+
*/
|
|
154
|
+
interface Seo {
|
|
155
|
+
metaTitle: string | null;
|
|
156
|
+
metaDescription: string | null;
|
|
157
|
+
canonicalUrl: string | null;
|
|
158
|
+
ogUrl: string | null;
|
|
159
|
+
ogType: string | null;
|
|
160
|
+
ogLocale: string;
|
|
161
|
+
ogImage: SeoImage | null;
|
|
162
|
+
articlePublishedTime: string | null;
|
|
163
|
+
articleModifiedTime: string | null;
|
|
164
|
+
twitterCard: string;
|
|
165
|
+
noIndex: boolean;
|
|
166
|
+
noFollow: boolean;
|
|
167
|
+
keywords: string | null;
|
|
168
|
+
structuredData: JsonObject | null;
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* Collection item timestamps.
|
|
172
|
+
*/
|
|
173
|
+
interface ItemMeta {
|
|
174
|
+
createdAt: string;
|
|
175
|
+
updatedAt: string;
|
|
176
|
+
publishedAt: string | null;
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* Document timestamps.
|
|
180
|
+
*/
|
|
181
|
+
interface DocumentMeta {
|
|
182
|
+
updatedAt: string;
|
|
183
|
+
publishedAt: string | null;
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* Section metadata embedded in sectioned content groups.
|
|
187
|
+
*/
|
|
188
|
+
interface SectionMeta {
|
|
189
|
+
name: string;
|
|
190
|
+
key: string;
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* Enum values returned by the API.
|
|
194
|
+
*/
|
|
195
|
+
interface EnumValue {
|
|
196
|
+
value: string;
|
|
197
|
+
label: string;
|
|
198
|
+
}
|
|
199
|
+
/**
|
|
200
|
+
* A CURRENCY field's value, read and written in this one shape.
|
|
201
|
+
*
|
|
202
|
+
* `amountMinor` is in the currency's minor unit (cents: `4800000` is
|
|
203
|
+
* COP 48.000,00), an integer. `currency` is the ISO 4217 code.
|
|
204
|
+
*/
|
|
205
|
+
interface CurrencyValue {
|
|
206
|
+
amountMinor: number;
|
|
207
|
+
currency: string;
|
|
208
|
+
}
|
|
209
|
+
/**
|
|
210
|
+
* Access mode for a media value.
|
|
211
|
+
*/
|
|
212
|
+
type MediaAccess = 'public' | 'signed' | 'none';
|
|
213
|
+
/**
|
|
214
|
+
* Media value returned by the delivery API.
|
|
215
|
+
*/
|
|
216
|
+
interface MediaValue {
|
|
217
|
+
id: string;
|
|
218
|
+
filename: string;
|
|
219
|
+
type: string;
|
|
220
|
+
mimeType: string;
|
|
221
|
+
size: number;
|
|
222
|
+
width: number | null;
|
|
223
|
+
height: number | null;
|
|
224
|
+
alt: string | null;
|
|
225
|
+
title: string | null;
|
|
226
|
+
description: string | null;
|
|
227
|
+
status: string;
|
|
228
|
+
mediaAccess: MediaAccess;
|
|
229
|
+
url: string | null;
|
|
230
|
+
signedUrl: string | null;
|
|
231
|
+
signedUrlExpiresAt: string | null;
|
|
232
|
+
}
|
|
233
|
+
/**
|
|
234
|
+
* Gallery entry values returned by the API.
|
|
235
|
+
*/
|
|
236
|
+
interface GalleryItemValue {
|
|
237
|
+
position: number;
|
|
238
|
+
caption: string | null;
|
|
239
|
+
description: string | null;
|
|
240
|
+
media: MediaValue | null;
|
|
241
|
+
}
|
|
242
|
+
/**
|
|
243
|
+
* Shared request options supported by most endpoints.
|
|
244
|
+
*/
|
|
245
|
+
interface CommonRequestOptions {
|
|
246
|
+
locale?: string;
|
|
247
|
+
status?: DeliveryStatus;
|
|
248
|
+
fields?: string[];
|
|
249
|
+
}
|
|
250
|
+
/**
|
|
251
|
+
* JSON error payload returned by the delivery API.
|
|
252
|
+
*/
|
|
253
|
+
interface ApiErrorPayload {
|
|
254
|
+
error: {
|
|
255
|
+
code: string;
|
|
256
|
+
message: string;
|
|
257
|
+
status: number;
|
|
258
|
+
/** Per-field problems on a validation refusal. */
|
|
259
|
+
details?: ApiErrorDetail[];
|
|
260
|
+
};
|
|
261
|
+
}
|
|
262
|
+
/**
|
|
263
|
+
* One problem in a validation refusal: where, what, and the rule's code.
|
|
264
|
+
*/
|
|
265
|
+
interface ApiErrorDetail {
|
|
266
|
+
path: string;
|
|
267
|
+
message: string;
|
|
268
|
+
code: string;
|
|
269
|
+
}
|
|
270
|
+
/**
|
|
271
|
+
* Client-level defaults applied to every request unless overridden.
|
|
272
|
+
*/
|
|
273
|
+
interface ClientDefaults {
|
|
274
|
+
locale?: string;
|
|
275
|
+
status?: DeliveryStatus;
|
|
276
|
+
preview?: boolean;
|
|
277
|
+
}
|
|
278
|
+
/**
|
|
279
|
+
* Draft preview for the item and document reads.
|
|
280
|
+
*/
|
|
281
|
+
interface PreviewOption {
|
|
282
|
+
/**
|
|
283
|
+
* Sends `preview=1`: every entry is returned whatever its status, and an entry
|
|
284
|
+
* with an unpublished draft comes back with the draft's content. Responses
|
|
285
|
+
* are `private, no-store`, and `cachedFetch` never stores them. Needs a
|
|
286
|
+
* secret key that can read drafts, a preview token (`zpt_…`), or a suite
|
|
287
|
+
* bearer with `zap:content:read` or `zap:preview:read`; a public key is
|
|
288
|
+
* refused with `DRAFT_ACCESS_DENIED`.
|
|
289
|
+
*/
|
|
290
|
+
preview?: boolean;
|
|
291
|
+
/**
|
|
292
|
+
* Only matters with `preview`: `false` sends `stega=0`, which turns off the
|
|
293
|
+
* invisible stega markers a preview response carries on prose fields (TEXT,
|
|
294
|
+
* LONG_TEXT, the last text node of each RICH_TEXT block) for this one
|
|
295
|
+
* request. Use it for server code that compares or keys on text, `<title>`
|
|
296
|
+
* and meta tags. Without `preview` a response never carries markers and
|
|
297
|
+
* nothing is sent.
|
|
298
|
+
*/
|
|
299
|
+
stega?: boolean;
|
|
300
|
+
}
|
|
301
|
+
/**
|
|
302
|
+
* SEO input accepted by the public write API.
|
|
303
|
+
*/
|
|
304
|
+
interface SeoInput {
|
|
305
|
+
metaTitle?: string | null;
|
|
306
|
+
metaDescription?: string | null;
|
|
307
|
+
ogType?: string | null;
|
|
308
|
+
ogImageId?: string | null;
|
|
309
|
+
ogImageAlt?: string | null;
|
|
310
|
+
canonicalUrl?: string | null;
|
|
311
|
+
twitterCard?: 'SUMMARY' | 'SUMMARY_LARGE_IMAGE';
|
|
312
|
+
noIndex?: boolean;
|
|
313
|
+
noFollow?: boolean;
|
|
314
|
+
keywords?: string | null;
|
|
315
|
+
structuredData?: JsonObject | null;
|
|
316
|
+
locale?: string;
|
|
317
|
+
}
|
|
318
|
+
/**
|
|
319
|
+
* Delete operations can optionally remove linked media.
|
|
320
|
+
*/
|
|
321
|
+
interface DeleteOptions {
|
|
322
|
+
deleteMediaIds?: string[];
|
|
323
|
+
}
|
|
324
|
+
/** Options of a write the API deduplicates by `Idempotency-Key`. */
|
|
325
|
+
interface IdempotencyOptions {
|
|
326
|
+
/** Defaults to a fresh random key per call; pass your own to make retries safe. */
|
|
327
|
+
idempotencyKey?: string;
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
/**
|
|
331
|
+
* The field types of the Zap API, exactly as its field routes accept and
|
|
332
|
+
* answer them (`collections.fields` and `documents.fields`: `create`, `list`,
|
|
333
|
+
* `update`, `restore`, `listDeleted`) and as the delivery schema reads publish
|
|
334
|
+
* them (`collections.list`, `collections.get`, `documents.list`).
|
|
335
|
+
*/
|
|
336
|
+
type FieldType = 'TEXT' | 'LONG_TEXT' | 'RICH_TEXT' | 'NUMBER' | 'INTEGER' | 'BOOLEAN' | 'DATE' | 'DATETIME' | 'CURRENCY' | 'ENUM' | 'GALLERY' | 'IMAGE' | 'VIDEO' | 'FILE' | 'URL' | 'EMAIL';
|
|
337
|
+
/**
|
|
338
|
+
* Enum option payload for field creation and updates.
|
|
339
|
+
*/
|
|
340
|
+
interface FieldOptionInput {
|
|
341
|
+
label: string;
|
|
342
|
+
value: string;
|
|
343
|
+
color?: string | null;
|
|
344
|
+
}
|
|
345
|
+
/**
|
|
346
|
+
* Shared field constraints returned by the management API.
|
|
347
|
+
*/
|
|
348
|
+
interface FieldConstraints {
|
|
349
|
+
min?: number;
|
|
350
|
+
max?: number;
|
|
351
|
+
minLength?: number;
|
|
352
|
+
maxLength?: number;
|
|
353
|
+
regex?: string;
|
|
354
|
+
currencies?: string[];
|
|
355
|
+
[key: string]: unknown;
|
|
356
|
+
}
|
|
357
|
+
/**
|
|
358
|
+
* A field as the field routes answer it (`collections.fields`,
|
|
359
|
+
* `documents.fields`) and as the delivery schema reads describe it.
|
|
360
|
+
*/
|
|
361
|
+
interface FieldInfo {
|
|
362
|
+
id?: string;
|
|
363
|
+
key: string;
|
|
364
|
+
label: string;
|
|
365
|
+
type: FieldType;
|
|
366
|
+
required?: boolean;
|
|
367
|
+
isLocalized: boolean;
|
|
368
|
+
isSortable?: boolean;
|
|
369
|
+
isFilterable?: boolean;
|
|
370
|
+
isUnique?: boolean;
|
|
371
|
+
description?: string | null;
|
|
372
|
+
defaultValue?: string | null;
|
|
373
|
+
sectionId?: string | null;
|
|
374
|
+
galleryMinItems?: number | null;
|
|
375
|
+
galleryMaxItems?: number | null;
|
|
376
|
+
galleryAllowedTypes?: 'IMAGE' | 'VIDEO' | 'IMAGE,VIDEO' | null;
|
|
377
|
+
constraints?: FieldConstraints | null;
|
|
378
|
+
options?: EnumValue[];
|
|
379
|
+
}
|
|
380
|
+
/**
|
|
381
|
+
* Collection section schema information.
|
|
382
|
+
*/
|
|
383
|
+
interface SectionInfo {
|
|
384
|
+
id?: string;
|
|
385
|
+
key: string;
|
|
386
|
+
name: string;
|
|
387
|
+
description?: string | null;
|
|
388
|
+
order: number;
|
|
389
|
+
fields?: string[];
|
|
390
|
+
}
|
|
391
|
+
/**
|
|
392
|
+
* Collection summary returned in collection lists and item responses.
|
|
393
|
+
*/
|
|
394
|
+
interface CollectionSummary {
|
|
395
|
+
key: string;
|
|
396
|
+
name: string;
|
|
397
|
+
description: string | null;
|
|
398
|
+
itemCount: number;
|
|
399
|
+
fields?: FieldInfo[];
|
|
400
|
+
sections?: SectionInfo[];
|
|
401
|
+
}
|
|
402
|
+
/**
|
|
403
|
+
* Full collection schema details.
|
|
404
|
+
*/
|
|
405
|
+
interface CollectionDetail extends CollectionSummary {
|
|
406
|
+
fields: FieldInfo[];
|
|
407
|
+
sections: SectionInfo[];
|
|
408
|
+
sortableFields: string[];
|
|
409
|
+
filterableFields: string[];
|
|
410
|
+
}
|
|
411
|
+
/**
|
|
412
|
+
* Response shape for the collections list endpoint.
|
|
413
|
+
*/
|
|
414
|
+
interface CollectionListResponse {
|
|
415
|
+
data: CollectionSummary[];
|
|
416
|
+
}
|
|
417
|
+
/**
|
|
418
|
+
* Input for creating a collection.
|
|
419
|
+
*/
|
|
420
|
+
interface CreateCollectionInput {
|
|
421
|
+
name: string;
|
|
422
|
+
key: string;
|
|
423
|
+
description?: string;
|
|
424
|
+
}
|
|
425
|
+
/**
|
|
426
|
+
* Input for updating a collection.
|
|
427
|
+
*/
|
|
428
|
+
interface UpdateCollectionInput {
|
|
429
|
+
name?: string;
|
|
430
|
+
description?: string | null;
|
|
431
|
+
/**
|
|
432
|
+
* «Ruta en tu sitio»: the page an entry appears on, for the editor's
|
|
433
|
+
* preview — `/blog/{slug}`, `/{locale}/productos/{slug}`. `''` or `null`
|
|
434
|
+
* clears it. Starts with `/`; only `{slug}` and `{locale}`.
|
|
435
|
+
*/
|
|
436
|
+
previewPath?: string | null;
|
|
437
|
+
}
|
|
438
|
+
/**
|
|
439
|
+
* Input for creating a collection field.
|
|
440
|
+
*/
|
|
441
|
+
interface CreateFieldInput {
|
|
442
|
+
key: string;
|
|
443
|
+
label?: string;
|
|
444
|
+
name?: string;
|
|
445
|
+
type: FieldType;
|
|
446
|
+
required?: boolean;
|
|
447
|
+
isLocalized?: boolean;
|
|
448
|
+
isUnique?: boolean;
|
|
449
|
+
isFilterable?: boolean;
|
|
450
|
+
isSortable?: boolean;
|
|
451
|
+
galleryMinItems?: number | null;
|
|
452
|
+
galleryMaxItems?: number | null;
|
|
453
|
+
galleryAllowedTypes?: 'IMAGE' | 'VIDEO' | 'IMAGE,VIDEO' | null;
|
|
454
|
+
description?: string | null;
|
|
455
|
+
constraints?: FieldConstraints | null;
|
|
456
|
+
defaultValue?: string | null;
|
|
457
|
+
sectionId?: string | null;
|
|
458
|
+
options?: FieldOptionInput[] | null;
|
|
459
|
+
}
|
|
460
|
+
/**
|
|
461
|
+
* Input for updating a collection field.
|
|
462
|
+
*/
|
|
463
|
+
interface UpdateFieldInput {
|
|
464
|
+
label?: string;
|
|
465
|
+
name?: string;
|
|
466
|
+
required?: boolean;
|
|
467
|
+
isLocalized?: boolean;
|
|
468
|
+
isUnique?: boolean;
|
|
469
|
+
isFilterable?: boolean;
|
|
470
|
+
isSortable?: boolean;
|
|
471
|
+
galleryMinItems?: number | null;
|
|
472
|
+
galleryMaxItems?: number | null;
|
|
473
|
+
galleryAllowedTypes?: 'IMAGE' | 'VIDEO' | 'IMAGE,VIDEO' | null;
|
|
474
|
+
description?: string | null;
|
|
475
|
+
constraints?: FieldConstraints | null;
|
|
476
|
+
defaultValue?: string | null;
|
|
477
|
+
sectionId?: string | null;
|
|
478
|
+
options?: FieldOptionInput[] | null;
|
|
479
|
+
}
|
|
480
|
+
/**
|
|
481
|
+
* Response payload for collection field list operations.
|
|
482
|
+
*/
|
|
483
|
+
interface CollectionFieldListResponse {
|
|
484
|
+
fields: FieldInfo[];
|
|
485
|
+
}
|
|
486
|
+
/**
|
|
487
|
+
* Input for creating a collection section.
|
|
488
|
+
*/
|
|
489
|
+
interface CreateSectionInput {
|
|
490
|
+
name: string;
|
|
491
|
+
description?: string | null;
|
|
492
|
+
}
|
|
493
|
+
/**
|
|
494
|
+
* Input for updating a collection section.
|
|
495
|
+
*/
|
|
496
|
+
interface UpdateSectionInput {
|
|
497
|
+
name?: string;
|
|
498
|
+
description?: string | null;
|
|
499
|
+
order?: number;
|
|
500
|
+
}
|
|
501
|
+
/**
|
|
502
|
+
* Response payload for collection section list operations.
|
|
503
|
+
*/
|
|
504
|
+
interface CollectionSectionListResponse {
|
|
505
|
+
sections: SectionInfo[];
|
|
506
|
+
}
|
|
507
|
+
|
|
508
|
+
/**
|
|
509
|
+
* Retries of a refused request: `429 Too Many Requests` always, and `503
|
|
510
|
+
* Service Unavailable` when it says when to come back (`Retry-After`).
|
|
511
|
+
*
|
|
512
|
+
* Only a request that is safe to repeat is retried: a read (`GET`, `HEAD`), or
|
|
513
|
+
* a write that carries an `Idempotency-Key`, which the API deduplicates. Any
|
|
514
|
+
* other write is never repeated, so a create can never land twice.
|
|
515
|
+
*/
|
|
516
|
+
interface RetryOptions {
|
|
517
|
+
/** Retries after the first attempt. Default `3`; `0` turns retrying off. */
|
|
518
|
+
retries?: number;
|
|
519
|
+
/**
|
|
520
|
+
* The longest single wait, in ms. Default `60000`, the API's rate window. A
|
|
521
|
+
* `Retry-After` longer than this is not waited out: the refusal is thrown.
|
|
522
|
+
*/
|
|
523
|
+
maxDelayMs?: number;
|
|
524
|
+
/** The first backoff step when the answer has no `Retry-After`, in ms. Default `500`. */
|
|
525
|
+
baseDelayMs?: number;
|
|
526
|
+
/** Called before each wait, for logging. */
|
|
527
|
+
onRetry?: (event: RetryEvent) => void;
|
|
528
|
+
}
|
|
529
|
+
/** What {@link RetryOptions.onRetry} is told before a wait. */
|
|
530
|
+
interface RetryEvent {
|
|
531
|
+
/** The retry about to happen: `1` for the first. */
|
|
532
|
+
attempt: number;
|
|
533
|
+
/** How long the client waits first, in ms. */
|
|
534
|
+
delayMs: number;
|
|
535
|
+
/** The refused answer's status: `429` or `503`. */
|
|
536
|
+
status: number;
|
|
537
|
+
method: string;
|
|
538
|
+
url: string;
|
|
539
|
+
}
|
|
540
|
+
/** @internal */
|
|
541
|
+
type ResolvedRetry = Required<Omit<RetryOptions, 'onRetry'>> & Pick<RetryOptions, 'onRetry'>;
|
|
542
|
+
|
|
543
|
+
interface HttpClientConfig {
|
|
544
|
+
apiKey: string;
|
|
545
|
+
baseUrl: string;
|
|
546
|
+
pathPrefix: string;
|
|
547
|
+
fetch: typeof globalThis.fetch;
|
|
548
|
+
defaultHeaders?: HeadersInit;
|
|
549
|
+
timeout: number;
|
|
550
|
+
/** Retries of a `429`/`503`; `null` or absent turns them off. */
|
|
551
|
+
retry?: ResolvedRetry | null;
|
|
552
|
+
}
|
|
553
|
+
interface HttpRequestOptions {
|
|
554
|
+
params?: Record<string, QueryPrimitive | undefined>;
|
|
555
|
+
headers?: HeadersInit;
|
|
556
|
+
body?: BodyInit | null;
|
|
557
|
+
contentType?: string;
|
|
558
|
+
}
|
|
559
|
+
/**
|
|
560
|
+
* Minimal fetch-based HTTP client for the delivery API.
|
|
561
|
+
*
|
|
562
|
+
* @internal
|
|
563
|
+
*/
|
|
564
|
+
declare class HttpClient {
|
|
565
|
+
#private;
|
|
566
|
+
constructor(config: HttpClientConfig);
|
|
567
|
+
get<T>(path: string, options?: Omit<HttpRequestOptions, 'body' | 'contentType'>): Promise<T>;
|
|
568
|
+
post<T>(path: string, body?: unknown, options?: Omit<HttpRequestOptions, 'body'>): Promise<T>;
|
|
569
|
+
patch<T>(path: string, body?: unknown, options?: Omit<HttpRequestOptions, 'body'>): Promise<T>;
|
|
570
|
+
put<T>(path: string, body?: unknown, options?: Omit<HttpRequestOptions, 'body'>): Promise<T>;
|
|
571
|
+
delete<T>(path: string, body?: unknown, options?: Omit<HttpRequestOptions, 'body'>): Promise<T>;
|
|
572
|
+
upload(url: string, body: BodyInit, headers?: HeadersInit): Promise<void>;
|
|
573
|
+
request<T>(path: string, options?: HttpRequestOptions): Promise<T>;
|
|
574
|
+
private toEelZapError;
|
|
575
|
+
}
|
|
576
|
+
|
|
577
|
+
/**
|
|
578
|
+
* Collection field management endpoints.
|
|
579
|
+
*/
|
|
580
|
+
declare class CollectionFieldsResource {
|
|
581
|
+
#private;
|
|
582
|
+
/**
|
|
583
|
+
* @internal
|
|
584
|
+
*/
|
|
585
|
+
constructor(http: HttpClient);
|
|
586
|
+
/**
|
|
587
|
+
* Lists all fields in a collection.
|
|
588
|
+
*/
|
|
589
|
+
list(collectionKey: string): Promise<FieldInfo[]>;
|
|
590
|
+
/**
|
|
591
|
+
* Creates a field in a collection.
|
|
592
|
+
*
|
|
593
|
+
* Sends an `Idempotency-Key` (required of suite bearers): a fresh one per
|
|
594
|
+
* call, or `options.idempotencyKey` to make your own retry safe.
|
|
595
|
+
*/
|
|
596
|
+
create(collectionKey: string, input: CreateFieldInput, options?: IdempotencyOptions): Promise<FieldInfo>;
|
|
597
|
+
/**
|
|
598
|
+
* Updates a field in a collection.
|
|
599
|
+
*/
|
|
600
|
+
update(collectionKey: string, fieldId: string, input: UpdateFieldInput): Promise<FieldInfo>;
|
|
601
|
+
/**
|
|
602
|
+
* Deletes a field from a collection.
|
|
603
|
+
*/
|
|
604
|
+
delete(collectionKey: string, fieldId: string): Promise<{
|
|
605
|
+
success: true;
|
|
606
|
+
}>;
|
|
607
|
+
/**
|
|
608
|
+
* Lists the collection's archived (soft-deleted) fields, most recently
|
|
609
|
+
* deleted first. Their values are kept, which is what makes `restore` work.
|
|
610
|
+
*
|
|
611
|
+
* `GET /collections/{collectionKey}/fields/deleted`. Secret key, or suite
|
|
612
|
+
* bearer with `zap:content:read`.
|
|
613
|
+
*/
|
|
614
|
+
listDeleted(collectionKey: string): Promise<FieldInfo[]>;
|
|
615
|
+
/**
|
|
616
|
+
* Brings an archived field back with every value it held, at the end of the
|
|
617
|
+
* root list (outside any section).
|
|
618
|
+
*
|
|
619
|
+
* `POST /collections/{collectionKey}/fields/{fieldId}/restore`. Secret key,
|
|
620
|
+
* or suite bearer with `zap:schema:write` and the Zap ADMIN role.
|
|
621
|
+
*/
|
|
622
|
+
restore(collectionKey: string, fieldId: string): Promise<FieldInfo>;
|
|
623
|
+
/**
|
|
624
|
+
* Reorders collection fields.
|
|
625
|
+
*/
|
|
626
|
+
reorder(collectionKey: string, fieldIds: string[]): Promise<{
|
|
627
|
+
success: true;
|
|
628
|
+
}>;
|
|
629
|
+
}
|
|
630
|
+
|
|
631
|
+
/**
|
|
632
|
+
* Collection section management endpoints.
|
|
633
|
+
*/
|
|
634
|
+
declare class CollectionSectionsResource {
|
|
635
|
+
#private;
|
|
636
|
+
/**
|
|
637
|
+
* @internal
|
|
638
|
+
*/
|
|
639
|
+
constructor(http: HttpClient);
|
|
640
|
+
/**
|
|
641
|
+
* Lists all sections in a collection.
|
|
642
|
+
*/
|
|
643
|
+
list(collectionKey: string): Promise<SectionInfo[]>;
|
|
644
|
+
/**
|
|
645
|
+
* Gets a single section from a collection.
|
|
646
|
+
*/
|
|
647
|
+
get(collectionKey: string, sectionId: string): Promise<SectionInfo>;
|
|
648
|
+
/**
|
|
649
|
+
* Creates a section in a collection.
|
|
650
|
+
*
|
|
651
|
+
* Sends an `Idempotency-Key` (required of suite bearers): a fresh one per
|
|
652
|
+
* call, or `options.idempotencyKey` to make your own retry safe.
|
|
653
|
+
*/
|
|
654
|
+
create(collectionKey: string, input: CreateSectionInput, options?: IdempotencyOptions): Promise<SectionInfo>;
|
|
655
|
+
/**
|
|
656
|
+
* Updates a section in a collection.
|
|
657
|
+
*/
|
|
658
|
+
update(collectionKey: string, sectionId: string, input: UpdateSectionInput): Promise<SectionInfo>;
|
|
659
|
+
/**
|
|
660
|
+
* Deletes a section from a collection.
|
|
661
|
+
*/
|
|
662
|
+
delete(collectionKey: string, sectionId: string): Promise<{
|
|
663
|
+
success: true;
|
|
664
|
+
}>;
|
|
665
|
+
}
|
|
666
|
+
|
|
667
|
+
/**
|
|
668
|
+
* Read-only collection endpoints.
|
|
669
|
+
*/
|
|
670
|
+
declare class CollectionsResource {
|
|
671
|
+
#private;
|
|
672
|
+
readonly fields: CollectionFieldsResource;
|
|
673
|
+
readonly sections: CollectionSectionsResource;
|
|
674
|
+
/**
|
|
675
|
+
* @internal
|
|
676
|
+
*/
|
|
677
|
+
constructor(http: HttpClient, defaults: ClientDefaults);
|
|
678
|
+
/**
|
|
679
|
+
* Lists all collections available to the current API key.
|
|
680
|
+
*/
|
|
681
|
+
list(options?: {
|
|
682
|
+
status?: DeliveryStatus;
|
|
683
|
+
}): Promise<CollectionListResponse>;
|
|
684
|
+
/**
|
|
685
|
+
* Retrieves the schema for a single collection.
|
|
686
|
+
*/
|
|
687
|
+
get(collectionKey: string, options?: {
|
|
688
|
+
status?: DeliveryStatus;
|
|
689
|
+
}): Promise<CollectionDetail>;
|
|
690
|
+
/**
|
|
691
|
+
* Creates a collection.
|
|
692
|
+
*
|
|
693
|
+
* Sends an `Idempotency-Key` (required of suite bearers): a fresh one per
|
|
694
|
+
* call, or `options.idempotencyKey` to make your own retry safe.
|
|
695
|
+
*/
|
|
696
|
+
create(input: CreateCollectionInput, options?: IdempotencyOptions): Promise<CollectionDetail>;
|
|
697
|
+
/**
|
|
698
|
+
* Updates a collection.
|
|
699
|
+
*/
|
|
700
|
+
update(collectionKey: string, input: UpdateCollectionInput): Promise<CollectionDetail>;
|
|
701
|
+
/**
|
|
702
|
+
* Deletes a collection.
|
|
703
|
+
*/
|
|
704
|
+
delete(collectionKey: string, options?: DeleteOptions): Promise<{
|
|
705
|
+
success: true;
|
|
706
|
+
}>;
|
|
707
|
+
}
|
|
708
|
+
|
|
709
|
+
/**
|
|
710
|
+
* «Comentarios»: comment threads on an entry or a document, as the public
|
|
711
|
+
* API's `/comments` routes take and answer them. A thread flagged
|
|
712
|
+
* `isChangeRequest` may carry an assignee, proposed values and, once
|
|
713
|
+
* resolved, a resolution; a plain comment carries none of them.
|
|
714
|
+
*
|
|
715
|
+
* The public API speaks KEYS: a record by `collection` + `slug` or by
|
|
716
|
+
* `document`, a field by its key. Every date is an ISO string.
|
|
717
|
+
*/
|
|
718
|
+
type CommentStatus = 'OPEN' | 'RESOLVED';
|
|
719
|
+
/** How a change request was resolved; APPLIED also covers "changed by hand". */
|
|
720
|
+
type CommentResolution = 'APPLIED' | 'DISMISSED';
|
|
721
|
+
/** Where the thread was made. The API derives it from the credential. */
|
|
722
|
+
type CommentSource = 'EDITOR' | 'PREVIEW' | 'SITE' | 'API' | 'MCP';
|
|
723
|
+
type CommentAnchorKind = 'field' | 'dom' | 'spot';
|
|
724
|
+
/** A page-normalised rectangle: every value between 0 and 1. */
|
|
725
|
+
interface CommentRect {
|
|
726
|
+
x: number;
|
|
727
|
+
y: number;
|
|
728
|
+
w: number;
|
|
729
|
+
h: number;
|
|
730
|
+
}
|
|
731
|
+
interface CommentViewport {
|
|
732
|
+
w: number;
|
|
733
|
+
h: number;
|
|
734
|
+
}
|
|
735
|
+
/**
|
|
736
|
+
* An element on a page: tag, then selector, then the W3C text quote, then the
|
|
737
|
+
* rectangle. `selector` at most 1 KB, `textQuote.exact` at most 500 characters.
|
|
738
|
+
*/
|
|
739
|
+
interface CommentDomAnchor {
|
|
740
|
+
tag?: string;
|
|
741
|
+
selector?: string;
|
|
742
|
+
textQuote?: {
|
|
743
|
+
exact: string;
|
|
744
|
+
prefix?: string;
|
|
745
|
+
suffix?: string;
|
|
746
|
+
};
|
|
747
|
+
rect?: CommentRect;
|
|
748
|
+
viewport?: CommentViewport;
|
|
749
|
+
}
|
|
750
|
+
/** A pin placed on the page, in page-normalised coordinates. */
|
|
751
|
+
interface CommentSpotAnchor {
|
|
752
|
+
spot: {
|
|
753
|
+
x: number;
|
|
754
|
+
y: number;
|
|
755
|
+
};
|
|
756
|
+
viewport?: CommentViewport;
|
|
757
|
+
}
|
|
758
|
+
/** A field anchor as the public API takes it: by key. */
|
|
759
|
+
interface CommentFieldAnchorInput {
|
|
760
|
+
key: string;
|
|
761
|
+
locale?: string | null;
|
|
762
|
+
/** A gallery index or a rich-text block, when the field alone is too coarse. */
|
|
763
|
+
path?: string | null;
|
|
764
|
+
}
|
|
765
|
+
/**
|
|
766
|
+
* One anchor of a new thread: a field, an element on the page, or both (at
|
|
767
|
+
* least one); or a spot. `dom` and `spot` anchors need the thread's `pageUrl`.
|
|
768
|
+
*/
|
|
769
|
+
type CommentAnchorInput = {
|
|
770
|
+
field?: CommentFieldAnchorInput;
|
|
771
|
+
dom?: CommentDomAnchor;
|
|
772
|
+
} | CommentSpotAnchor;
|
|
773
|
+
/** An anchor as stored: the field layer carries the field's id and real key. */
|
|
774
|
+
type CommentAnchor = {
|
|
775
|
+
field?: {
|
|
776
|
+
id: string;
|
|
777
|
+
key: string;
|
|
778
|
+
locale: string | null;
|
|
779
|
+
path: string | null;
|
|
780
|
+
};
|
|
781
|
+
dom?: CommentDomAnchor;
|
|
782
|
+
} | CommentSpotAnchor;
|
|
783
|
+
interface CommentPersonRef {
|
|
784
|
+
id: string;
|
|
785
|
+
name: string | null;
|
|
786
|
+
avatarUrl: string | null;
|
|
787
|
+
}
|
|
788
|
+
interface CommentVersionRef {
|
|
789
|
+
id: string;
|
|
790
|
+
/** The version's number, or null when it no longer exists (discarded, pruned). */
|
|
791
|
+
number: number | null;
|
|
792
|
+
/** Whether the record still sits on this version (its open draft, else its published one). */
|
|
793
|
+
current: boolean;
|
|
794
|
+
}
|
|
795
|
+
type CommentTarget = {
|
|
796
|
+
type: 'item';
|
|
797
|
+
id: string;
|
|
798
|
+
collectionId: string;
|
|
799
|
+
slug: string;
|
|
800
|
+
} | {
|
|
801
|
+
type: 'document';
|
|
802
|
+
id: string;
|
|
803
|
+
key: string;
|
|
804
|
+
};
|
|
805
|
+
interface CommentProposedValue {
|
|
806
|
+
fieldId: string;
|
|
807
|
+
fieldKey: string;
|
|
808
|
+
locale: string | null;
|
|
809
|
+
value: string | number | null;
|
|
810
|
+
}
|
|
811
|
+
/** A thread, without its comments. */
|
|
812
|
+
interface CommentThread {
|
|
813
|
+
id: string;
|
|
814
|
+
siteId: string;
|
|
815
|
+
target: CommentTarget;
|
|
816
|
+
isChangeRequest: boolean;
|
|
817
|
+
status: CommentStatus;
|
|
818
|
+
/** Set on a RESOLVED change request only. */
|
|
819
|
+
resolution: CommentResolution | null;
|
|
820
|
+
source: CommentSource;
|
|
821
|
+
locale: string | null;
|
|
822
|
+
/** The page it was made on (origin and path), or null when made in the editor. */
|
|
823
|
+
pageUrl: string | null;
|
|
824
|
+
anchors: CommentAnchor[];
|
|
825
|
+
anchorKinds: CommentAnchorKind[];
|
|
826
|
+
/** The fields the anchors point at, deduplicated, in anchor order. */
|
|
827
|
+
fieldIds: string[];
|
|
828
|
+
fieldKeys: string[];
|
|
829
|
+
proposedValues: CommentProposedValue[] | null;
|
|
830
|
+
baseVersion: CommentVersionRef | null;
|
|
831
|
+
resolvedInVersion: CommentVersionRef | null;
|
|
832
|
+
assignee: CommentPersonRef | null;
|
|
833
|
+
createdBy: CommentPersonRef | null;
|
|
834
|
+
resolvedBy: CommentPersonRef | null;
|
|
835
|
+
resolvedAt: string | null;
|
|
836
|
+
createdAt: string;
|
|
837
|
+
updatedAt: string;
|
|
838
|
+
/** The first comment, shortened. */
|
|
839
|
+
excerpt: string | null;
|
|
840
|
+
replyCount: number;
|
|
841
|
+
permissions: {
|
|
842
|
+
canEdit: boolean;
|
|
843
|
+
canDelete: boolean;
|
|
844
|
+
};
|
|
845
|
+
}
|
|
846
|
+
/** One comment of a thread. */
|
|
847
|
+
interface ThreadComment {
|
|
848
|
+
id: string;
|
|
849
|
+
author: CommentPersonRef | null;
|
|
850
|
+
/** Null on a system line. */
|
|
851
|
+
body: string | null;
|
|
852
|
+
system: boolean;
|
|
853
|
+
systemCode: 'draft_discarded' | null;
|
|
854
|
+
/** The thread's opening comment. */
|
|
855
|
+
isFirst: boolean;
|
|
856
|
+
edited: boolean;
|
|
857
|
+
createdAt: string;
|
|
858
|
+
updatedAt: string;
|
|
859
|
+
}
|
|
860
|
+
/** `get`, `create` and `update`: the thread and every comment, oldest first. */
|
|
861
|
+
interface CommentThreadAnswer {
|
|
862
|
+
thread: CommentThread;
|
|
863
|
+
comments: ThreadComment[];
|
|
864
|
+
}
|
|
865
|
+
/** `apply` and `saveToDraft`: the resolved thread and the draft the values went into. */
|
|
866
|
+
interface CommentDraftAnswer extends CommentThreadAnswer {
|
|
867
|
+
draftVersionId: string;
|
|
868
|
+
}
|
|
869
|
+
/**
|
|
870
|
+
* `reply`: the new comment and the thread. Under `zap:suggest:write` alone the
|
|
871
|
+
* thread is only `{ id, status }`, with no comments.
|
|
872
|
+
*/
|
|
873
|
+
type CommentReplyAnswer = {
|
|
874
|
+
comment: ThreadComment;
|
|
875
|
+
thread: CommentThread;
|
|
876
|
+
comments: ThreadComment[];
|
|
877
|
+
} | {
|
|
878
|
+
comment: ThreadComment;
|
|
879
|
+
thread: {
|
|
880
|
+
id: string;
|
|
881
|
+
status: CommentStatus;
|
|
882
|
+
};
|
|
883
|
+
comments?: undefined;
|
|
884
|
+
};
|
|
885
|
+
interface CommentListResponse {
|
|
886
|
+
items: CommentThread[];
|
|
887
|
+
/** Across both statuses, whatever `status` filters. */
|
|
888
|
+
counts: Record<CommentStatus, number>;
|
|
889
|
+
page: number;
|
|
890
|
+
pageSize: number;
|
|
891
|
+
total: number;
|
|
892
|
+
hasMore: boolean;
|
|
893
|
+
}
|
|
894
|
+
/** A record: an entry (`collection` + `slug`) or a document (`document`). */
|
|
895
|
+
type CommentRecord = {
|
|
896
|
+
collection: string;
|
|
897
|
+
slug: string;
|
|
898
|
+
document?: never;
|
|
899
|
+
} | {
|
|
900
|
+
document: string;
|
|
901
|
+
collection?: never;
|
|
902
|
+
slug?: never;
|
|
903
|
+
};
|
|
904
|
+
interface CommentListOptions {
|
|
905
|
+
/** With `slug`: the threads of one entry. */
|
|
906
|
+
collection?: string;
|
|
907
|
+
slug?: string;
|
|
908
|
+
/** The threads of one document. */
|
|
909
|
+
document?: string;
|
|
910
|
+
isChangeRequest?: boolean;
|
|
911
|
+
status?: CommentStatus;
|
|
912
|
+
resolution?: CommentResolution;
|
|
913
|
+
/** The page the threads were made on; normalised before it is compared. */
|
|
914
|
+
pageUrl?: string;
|
|
915
|
+
/** `me`, `none`, or a user id. */
|
|
916
|
+
assignee?: 'me' | 'none' | (string & {});
|
|
917
|
+
page?: number;
|
|
918
|
+
/** 1 to 100, default 50. */
|
|
919
|
+
pageSize?: number;
|
|
920
|
+
}
|
|
921
|
+
interface CommentProposedValueInput {
|
|
922
|
+
fieldKey: string;
|
|
923
|
+
locale?: string | null;
|
|
924
|
+
value: string | number | null;
|
|
925
|
+
}
|
|
926
|
+
interface CommentWriteBase {
|
|
927
|
+
locale?: string | null;
|
|
928
|
+
/** An http(s) URL; needed by `dom` and `spot` anchors. */
|
|
929
|
+
pageUrl?: string;
|
|
930
|
+
/** 0 to 20; none means the whole page (with a `pageUrl`) or the whole record. */
|
|
931
|
+
anchors?: CommentAnchorInput[];
|
|
932
|
+
/** The first comment, 1 to 10,000 characters. */
|
|
933
|
+
body: string;
|
|
934
|
+
}
|
|
935
|
+
/**
|
|
936
|
+
* `create`. `assigneeId` and `proposedValues` go with a change request only.
|
|
937
|
+
* Without `assigneeId`, a change request goes to the record's Responsable when
|
|
938
|
+
* they hold Zap; `null` assigns nobody.
|
|
939
|
+
*/
|
|
940
|
+
type CreateCommentInput = CommentRecord & CommentWriteBase & {
|
|
941
|
+
isChangeRequest?: boolean;
|
|
942
|
+
assigneeId?: string | null;
|
|
943
|
+
/** At most 20; TEXT, LONG_TEXT, NUMBER and URL fields. */
|
|
944
|
+
proposedValues?: CommentProposedValueInput[];
|
|
945
|
+
};
|
|
946
|
+
/** `saveToDraft`: always a change request, no assignee, at least one proposed value. */
|
|
947
|
+
type SaveCommentToDraftInput = CommentRecord & CommentWriteBase & {
|
|
948
|
+
proposedValues: CommentProposedValueInput[];
|
|
949
|
+
};
|
|
950
|
+
/** `update`: at least one. */
|
|
951
|
+
interface UpdateCommentInput {
|
|
952
|
+
status?: CommentStatus;
|
|
953
|
+
/** A change request's; given with `status: 'OPEN'` it is 409 `INVALID_TRANSITION`. */
|
|
954
|
+
resolution?: CommentResolution;
|
|
955
|
+
/**
|
|
956
|
+
* Turning it off is 409 `HAS_PROPOSAL` on a thread with proposed values, and
|
|
957
|
+
* 422 `HAS_LINKED_TASKS` while any Swarm task is linked to it.
|
|
958
|
+
*/
|
|
959
|
+
isChangeRequest?: boolean;
|
|
960
|
+
assigneeId?: string | null;
|
|
961
|
+
/** The first comment's text (its author or an ADMIN). */
|
|
962
|
+
body?: string;
|
|
963
|
+
}
|
|
964
|
+
interface ReplyCommentInput {
|
|
965
|
+
body: string;
|
|
966
|
+
}
|
|
967
|
+
/** The field types `onPage` describes, per record ref and field key. */
|
|
968
|
+
interface OnPageField {
|
|
969
|
+
type: string;
|
|
970
|
+
label: string;
|
|
971
|
+
}
|
|
972
|
+
interface OnPageCommentAnchor {
|
|
973
|
+
fieldKey: string | null;
|
|
974
|
+
tag: string | null;
|
|
975
|
+
selector: string | null;
|
|
976
|
+
rect: CommentRect | null;
|
|
977
|
+
spot: {
|
|
978
|
+
x: number;
|
|
979
|
+
y: number;
|
|
980
|
+
} | null;
|
|
981
|
+
}
|
|
982
|
+
interface OnPageComment {
|
|
983
|
+
id: string;
|
|
984
|
+
status: 'OPEN';
|
|
985
|
+
isChangeRequest: boolean;
|
|
986
|
+
createdAt: string;
|
|
987
|
+
author: {
|
|
988
|
+
name: string | null;
|
|
989
|
+
} | null;
|
|
990
|
+
excerpt: string | null;
|
|
991
|
+
anchors: OnPageCommentAnchor[];
|
|
992
|
+
}
|
|
993
|
+
/** `onPage`: what the site's suggestion client needs on one page. */
|
|
994
|
+
interface OnPageComments {
|
|
995
|
+
viewer: {
|
|
996
|
+
name: string | null;
|
|
997
|
+
};
|
|
998
|
+
/** Whether the site lets people save straight to the draft. */
|
|
999
|
+
liveEditing: boolean;
|
|
1000
|
+
/** Record ref → field key → field. */
|
|
1001
|
+
fields: Record<string, Record<string, OnPageField>>;
|
|
1002
|
+
/** The page's open threads. */
|
|
1003
|
+
comments: OnPageComment[];
|
|
1004
|
+
truncated: boolean;
|
|
1005
|
+
}
|
|
1006
|
+
|
|
1007
|
+
/**
|
|
1008
|
+
* «Comentarios» (`/comments`): comment threads on an entry or a document, a
|
|
1009
|
+
* thread flagged `isChangeRequest` carrying an assignee and proposed values.
|
|
1010
|
+
*
|
|
1011
|
+
* Suite bearers only (`eel_sk_…` / `eel_at_…`, with `X-Eel-Site`): a comment
|
|
1012
|
+
* has a person behind it, so site keys are refused. Reads need
|
|
1013
|
+
* `zap:content:read`; writes `zap:content:write`, and `create`, `reply` and
|
|
1014
|
+
* `saveToDraft` also take `zap:suggest:write`.
|
|
1015
|
+
*/
|
|
1016
|
+
declare class CommentsResource {
|
|
1017
|
+
#private;
|
|
1018
|
+
/**
|
|
1019
|
+
* @internal
|
|
1020
|
+
*/
|
|
1021
|
+
constructor(http: HttpClient);
|
|
1022
|
+
/**
|
|
1023
|
+
* Lists the site's threads, newest first, optionally on one record (an
|
|
1024
|
+
* entry by `collection` + `slug`, or a `document`). `counts` covers both
|
|
1025
|
+
* statuses whatever `status` filters.
|
|
1026
|
+
*
|
|
1027
|
+
* `GET /comments`.
|
|
1028
|
+
*/
|
|
1029
|
+
list(options?: CommentListOptions): Promise<CommentListResponse>;
|
|
1030
|
+
/**
|
|
1031
|
+
* Retrieves a thread and its comments, oldest first.
|
|
1032
|
+
*
|
|
1033
|
+
* `GET /comments/{id}`.
|
|
1034
|
+
*/
|
|
1035
|
+
get(id: string): Promise<CommentThreadAnswer>;
|
|
1036
|
+
/**
|
|
1037
|
+
* Opens a thread with its first comment. Anchors and proposed values name
|
|
1038
|
+
* fields by key. Sends an `Idempotency-Key`. 404 for an unknown record, 422
|
|
1039
|
+
* `INVALID_ANCHOR` / `INVALID_PROPOSED_VALUE` / `ASSIGNEE_NO_SEAT`, 429
|
|
1040
|
+
* `RATE_LIMITED`.
|
|
1041
|
+
*
|
|
1042
|
+
* `POST /comments`.
|
|
1043
|
+
*
|
|
1044
|
+
* @example
|
|
1045
|
+
* ```ts
|
|
1046
|
+
* await zap.comments.create({
|
|
1047
|
+
* collection: 'blog',
|
|
1048
|
+
* slug: 'hello-world',
|
|
1049
|
+
* isChangeRequest: true,
|
|
1050
|
+
* body: 'Shorter title?',
|
|
1051
|
+
* proposedValues: [{ fieldKey: 'title', value: 'Hello' }],
|
|
1052
|
+
* })
|
|
1053
|
+
* ```
|
|
1054
|
+
*/
|
|
1055
|
+
create(input: CreateCommentInput, options?: IdempotencyOptions): Promise<CommentThreadAnswer>;
|
|
1056
|
+
/**
|
|
1057
|
+
* Changes a thread: `status` (resolve, reopen), a change request's
|
|
1058
|
+
* `resolution`, the `isChangeRequest` flag, the assignee, or the first
|
|
1059
|
+
* comment's text. 409 `STATUS_CONFLICT`, `INVALID_TRANSITION`,
|
|
1060
|
+
* `HAS_PROPOSAL`; 422 `NOT_A_CHANGE_REQUEST`, `HAS_LINKED_TASKS` (turning
|
|
1061
|
+
* the flag off while a Swarm task is linked).
|
|
1062
|
+
*
|
|
1063
|
+
* `PATCH /comments/{id}`.
|
|
1064
|
+
*/
|
|
1065
|
+
update(id: string, input: UpdateCommentInput): Promise<CommentThreadAnswer>;
|
|
1066
|
+
/**
|
|
1067
|
+
* Replies on a thread. Sends an `Idempotency-Key`.
|
|
1068
|
+
*
|
|
1069
|
+
* `POST /comments/{id}/replies`.
|
|
1070
|
+
*/
|
|
1071
|
+
reply(id: string, input: ReplyCommentInput, options?: IdempotencyOptions): Promise<CommentReplyAnswer>;
|
|
1072
|
+
/**
|
|
1073
|
+
* «Aplicar al borrador»: writes an open change request's proposed values
|
|
1074
|
+
* into the record's draft and resolves it as APPLIED. 409 `NO_PROPOSAL` /
|
|
1075
|
+
* `NOT_OPEN`.
|
|
1076
|
+
*
|
|
1077
|
+
* `POST /comments/{id}/apply`.
|
|
1078
|
+
*/
|
|
1079
|
+
apply(id: string): Promise<CommentDraftAnswer>;
|
|
1080
|
+
/**
|
|
1081
|
+
* Writes proposed values straight into the record's draft, recorded as a
|
|
1082
|
+
* change request already resolved as APPLIED; nobody is notified. 403 when
|
|
1083
|
+
* the site has live editing off. Sends an `Idempotency-Key`.
|
|
1084
|
+
*
|
|
1085
|
+
* `POST /comments/save-to-draft`.
|
|
1086
|
+
*/
|
|
1087
|
+
saveToDraft(input: SaveCommentToDraftInput, options?: IdempotencyOptions): Promise<CommentDraftAnswer>;
|
|
1088
|
+
/**
|
|
1089
|
+
* What the site's suggestion client shows on one page: the viewer, whether
|
|
1090
|
+
* live editing is on, the field types of the records tagged there and the
|
|
1091
|
+
* page's open threads. `refs` are `data-zap-ref` values (`collection/slug`
|
|
1092
|
+
* or `doc:key`); at most 20 are read.
|
|
1093
|
+
*
|
|
1094
|
+
* `GET /comments/on-page`. Answers only the site's own suggestion client.
|
|
1095
|
+
*/
|
|
1096
|
+
onPage(url: string, refs?: readonly string[]): Promise<OnPageComments>;
|
|
1097
|
+
}
|
|
1098
|
+
|
|
1099
|
+
/**
|
|
1100
|
+
* Content versioning: the shapes the `…/versions` routes of the public API
|
|
1101
|
+
* answer with. Field names are the API's (camelCase), and every date is an ISO
|
|
1102
|
+
* string.
|
|
1103
|
+
*/
|
|
1104
|
+
type VersionStatus = 'DRAFT' | 'PUBLISHED' | 'ARCHIVED';
|
|
1105
|
+
/**
|
|
1106
|
+
* One row of an entry's history. What `list`, `createDraft`, `publishDraft`
|
|
1107
|
+
* and `rollback` answer with: no values.
|
|
1108
|
+
*/
|
|
1109
|
+
interface VersionSummary {
|
|
1110
|
+
id: string;
|
|
1111
|
+
number: number;
|
|
1112
|
+
status: VersionStatus;
|
|
1113
|
+
/** The account that made the version, or null for an API key or a deleted account. */
|
|
1114
|
+
createdById: string | null;
|
|
1115
|
+
/** The author's display name, or null when the account is gone. */
|
|
1116
|
+
authorName: string | null;
|
|
1117
|
+
authorAvatarUrl: string | null;
|
|
1118
|
+
note: string | null;
|
|
1119
|
+
/** Set when the version was produced by a rollback from that version number. */
|
|
1120
|
+
restoredFromVersionNumber: number | null;
|
|
1121
|
+
createdAt: string;
|
|
1122
|
+
publishedAt: string | null;
|
|
1123
|
+
}
|
|
1124
|
+
interface ItemVersionSummary extends VersionSummary {
|
|
1125
|
+
itemId: string;
|
|
1126
|
+
/** The item's default-locale slug as of this version. */
|
|
1127
|
+
slug: string | null;
|
|
1128
|
+
}
|
|
1129
|
+
interface DocumentVersionSummary extends VersionSummary {
|
|
1130
|
+
documentId: string;
|
|
1131
|
+
}
|
|
1132
|
+
interface VersionGalleryItem {
|
|
1133
|
+
id: string;
|
|
1134
|
+
mediaId: string;
|
|
1135
|
+
position: number;
|
|
1136
|
+
caption: string | null;
|
|
1137
|
+
description: string | null;
|
|
1138
|
+
}
|
|
1139
|
+
/**
|
|
1140
|
+
* A stored value in a version snapshot. It is the raw column form, not the
|
|
1141
|
+
* delivery API's resolved value: one `value*` column is set according to
|
|
1142
|
+
* `fieldType`. `fieldKey` and `fieldType` are copies, so a version still reads
|
|
1143
|
+
* correctly after the field it came from was deleted.
|
|
1144
|
+
*/
|
|
1145
|
+
interface VersionValue {
|
|
1146
|
+
id: string;
|
|
1147
|
+
fieldKey: string | null;
|
|
1148
|
+
fieldType: string | null;
|
|
1149
|
+
locale: string | null;
|
|
1150
|
+
valueText: string | null;
|
|
1151
|
+
valueNumber: number | null;
|
|
1152
|
+
valueInt: number | null;
|
|
1153
|
+
valueBool: boolean | null;
|
|
1154
|
+
valueDate: string | null;
|
|
1155
|
+
valueDateTime: string | null;
|
|
1156
|
+
valueAmountMinor: number | null;
|
|
1157
|
+
valueCurrency: string | null;
|
|
1158
|
+
valueEnumOptionId: string | null;
|
|
1159
|
+
valueMediaId: string | null;
|
|
1160
|
+
/** Present only on GALLERY values. */
|
|
1161
|
+
galleryItems?: VersionGalleryItem[];
|
|
1162
|
+
}
|
|
1163
|
+
interface ItemVersionValue extends VersionValue {
|
|
1164
|
+
itemVersionId: string;
|
|
1165
|
+
fieldId: string | null;
|
|
1166
|
+
}
|
|
1167
|
+
interface DocumentVersionValue extends VersionValue {
|
|
1168
|
+
documentVersionId: string;
|
|
1169
|
+
documentFieldId: string | null;
|
|
1170
|
+
}
|
|
1171
|
+
/** SEO as stored in a version snapshot, one row per locale. */
|
|
1172
|
+
interface VersionSeo {
|
|
1173
|
+
id: string;
|
|
1174
|
+
locale: string | null;
|
|
1175
|
+
metaTitle: string | null;
|
|
1176
|
+
metaDescription: string | null;
|
|
1177
|
+
ogType: string | null;
|
|
1178
|
+
ogImageId: string | null;
|
|
1179
|
+
ogImageAlt: string | null;
|
|
1180
|
+
canonicalUrl: string | null;
|
|
1181
|
+
twitterCard: string;
|
|
1182
|
+
noIndex: boolean;
|
|
1183
|
+
noFollow: boolean;
|
|
1184
|
+
keywords: string | null;
|
|
1185
|
+
structuredData: Record<string, unknown> | null;
|
|
1186
|
+
}
|
|
1187
|
+
interface ItemVersionSeo extends VersionSeo {
|
|
1188
|
+
itemVersionId: string;
|
|
1189
|
+
}
|
|
1190
|
+
interface DocumentVersionSeo extends VersionSeo {
|
|
1191
|
+
documentVersionId: string;
|
|
1192
|
+
}
|
|
1193
|
+
interface ItemVersionSlug {
|
|
1194
|
+
id: string;
|
|
1195
|
+
itemVersionId: string;
|
|
1196
|
+
locale: string;
|
|
1197
|
+
slug: string;
|
|
1198
|
+
}
|
|
1199
|
+
/**
|
|
1200
|
+
* One version with its snapshot. What `get` and `updateDraft` answer with.
|
|
1201
|
+
*/
|
|
1202
|
+
interface VersionDetail extends VersionSummary {
|
|
1203
|
+
values: VersionValue[];
|
|
1204
|
+
seo: VersionSeo[];
|
|
1205
|
+
}
|
|
1206
|
+
interface ItemVersionDetail extends ItemVersionSummary {
|
|
1207
|
+
values: ItemVersionValue[];
|
|
1208
|
+
seo: ItemVersionSeo[];
|
|
1209
|
+
slugs: ItemVersionSlug[];
|
|
1210
|
+
}
|
|
1211
|
+
interface DocumentVersionDetail extends DocumentVersionSummary {
|
|
1212
|
+
values: DocumentVersionValue[];
|
|
1213
|
+
seo: DocumentVersionSeo[];
|
|
1214
|
+
}
|
|
1215
|
+
interface VersionListResponse<TVersion extends VersionSummary = VersionSummary> {
|
|
1216
|
+
/** Newest first. */
|
|
1217
|
+
versions: TVersion[];
|
|
1218
|
+
}
|
|
1219
|
+
interface CreateDraftInput {
|
|
1220
|
+
/** Up to 200 characters. */
|
|
1221
|
+
note?: string;
|
|
1222
|
+
}
|
|
1223
|
+
interface UpdateItemDraftInput {
|
|
1224
|
+
slug?: string;
|
|
1225
|
+
locale?: string;
|
|
1226
|
+
values?: Record<string, unknown>;
|
|
1227
|
+
}
|
|
1228
|
+
interface UpdateDocumentDraftInput {
|
|
1229
|
+
locale?: string;
|
|
1230
|
+
values?: Record<string, unknown>;
|
|
1231
|
+
}
|
|
1232
|
+
|
|
1233
|
+
/**
|
|
1234
|
+
* Version history, drafts and rollbacks for documents
|
|
1235
|
+
* (`/documents/{documentKey}/versions…`).
|
|
1236
|
+
*
|
|
1237
|
+
* A document has at most one open draft. Writing needs a secret key;
|
|
1238
|
+
* publishing and rolling back need one with publish rights.
|
|
1239
|
+
*/
|
|
1240
|
+
declare class DocumentVersionsResource {
|
|
1241
|
+
#private;
|
|
1242
|
+
/** @internal */
|
|
1243
|
+
constructor(http: HttpClient);
|
|
1244
|
+
/**
|
|
1245
|
+
* Lists a document's versions, newest first.
|
|
1246
|
+
*/
|
|
1247
|
+
list(documentKey: string): Promise<VersionListResponse<DocumentVersionSummary>>;
|
|
1248
|
+
/**
|
|
1249
|
+
* Gets one version with its snapshot (values and SEO).
|
|
1250
|
+
*/
|
|
1251
|
+
get(documentKey: string, versionId: string): Promise<DocumentVersionDetail>;
|
|
1252
|
+
/**
|
|
1253
|
+
* Opens a draft from the document's live state. Fails with `DUPLICATE_KEY`
|
|
1254
|
+
* (409) when the document already has one.
|
|
1255
|
+
*/
|
|
1256
|
+
createDraft(documentKey: string, input?: CreateDraftInput): Promise<DocumentVersionSummary>;
|
|
1257
|
+
/**
|
|
1258
|
+
* Stages values on the open draft without touching the live document.
|
|
1259
|
+
* Fails with `VALIDATION_ERROR` (400) when there is no open draft.
|
|
1260
|
+
*/
|
|
1261
|
+
updateDraft(documentKey: string, input: UpdateDocumentDraftInput): Promise<DocumentVersionDetail>;
|
|
1262
|
+
/**
|
|
1263
|
+
* Discards the open draft. Fails with `NOT_FOUND` (404) when there is none.
|
|
1264
|
+
*/
|
|
1265
|
+
discardDraft(documentKey: string): Promise<void>;
|
|
1266
|
+
/**
|
|
1267
|
+
* Publishes the open draft: its values go live and it becomes the
|
|
1268
|
+
* document's published version. Fails with `NOT_FOUND` (404) when there is
|
|
1269
|
+
* no draft.
|
|
1270
|
+
*/
|
|
1271
|
+
publishDraft(documentKey: string): Promise<DocumentVersionSummary>;
|
|
1272
|
+
/**
|
|
1273
|
+
* Restores a past version over the live document and records the restore
|
|
1274
|
+
* as a NEW published version (history is never rewritten). Refused (409)
|
|
1275
|
+
* for a draft version, or while the document has an open draft.
|
|
1276
|
+
*/
|
|
1277
|
+
rollback(documentKey: string, versionId: string): Promise<DocumentVersionSummary>;
|
|
1278
|
+
}
|
|
1279
|
+
|
|
1280
|
+
/**
|
|
1281
|
+
* Document list entry returned by the list endpoint.
|
|
1282
|
+
*/
|
|
1283
|
+
interface DocumentListEntry {
|
|
1284
|
+
key: string;
|
|
1285
|
+
name: string;
|
|
1286
|
+
description: string | null;
|
|
1287
|
+
status: string;
|
|
1288
|
+
updatedAt: string;
|
|
1289
|
+
publishedAt: string | null;
|
|
1290
|
+
fields: FieldInfo[];
|
|
1291
|
+
sections: SectionInfo[];
|
|
1292
|
+
}
|
|
1293
|
+
/**
|
|
1294
|
+
* Document detail payload.
|
|
1295
|
+
*/
|
|
1296
|
+
interface DocumentDetail<TContent = Record<string, unknown>> {
|
|
1297
|
+
key: string;
|
|
1298
|
+
name: string;
|
|
1299
|
+
status: string;
|
|
1300
|
+
locale: string;
|
|
1301
|
+
meta: DocumentMeta;
|
|
1302
|
+
content: TContent;
|
|
1303
|
+
seo: Seo | null;
|
|
1304
|
+
}
|
|
1305
|
+
/**
|
|
1306
|
+
* Response shape for document lists.
|
|
1307
|
+
*/
|
|
1308
|
+
interface DocumentListResponse {
|
|
1309
|
+
data: DocumentListEntry[];
|
|
1310
|
+
}
|
|
1311
|
+
/**
|
|
1312
|
+
* Options for listing documents.
|
|
1313
|
+
*/
|
|
1314
|
+
type DocumentListOptions = Omit<CommonRequestOptions, 'fields'> & PreviewOption;
|
|
1315
|
+
/**
|
|
1316
|
+
* Options for retrieving a single document.
|
|
1317
|
+
*/
|
|
1318
|
+
type DocumentGetOptions = CommonRequestOptions & PreviewOption;
|
|
1319
|
+
/**
|
|
1320
|
+
* Input for creating a document.
|
|
1321
|
+
*/
|
|
1322
|
+
interface CreateDocumentInput {
|
|
1323
|
+
name: string;
|
|
1324
|
+
key: string;
|
|
1325
|
+
description?: string;
|
|
1326
|
+
}
|
|
1327
|
+
/**
|
|
1328
|
+
* Input for updating a document.
|
|
1329
|
+
*/
|
|
1330
|
+
interface UpdateDocumentInput {
|
|
1331
|
+
name?: string;
|
|
1332
|
+
key?: string;
|
|
1333
|
+
description?: string | null;
|
|
1334
|
+
/**
|
|
1335
|
+
* «Ruta en tu sitio»: the page this document is — `/nosotros`,
|
|
1336
|
+
* `/{locale}/nosotros`. `''` or `null` clears it. Starts with `/`; only
|
|
1337
|
+
* `{locale}`.
|
|
1338
|
+
*/
|
|
1339
|
+
previewPath?: string | null;
|
|
1340
|
+
}
|
|
1341
|
+
/**
|
|
1342
|
+
* Response payload for document mutation routes.
|
|
1343
|
+
*/
|
|
1344
|
+
interface DocumentMutationResponse<TContent = Record<string, unknown>> {
|
|
1345
|
+
document: DocumentDetail<TContent>;
|
|
1346
|
+
}
|
|
1347
|
+
/**
|
|
1348
|
+
* Response payload for document delete routes.
|
|
1349
|
+
*/
|
|
1350
|
+
interface DocumentDeleteResponse {
|
|
1351
|
+
success: true;
|
|
1352
|
+
}
|
|
1353
|
+
/**
|
|
1354
|
+
* Extra options for document deletion.
|
|
1355
|
+
*/
|
|
1356
|
+
type DeleteDocumentOptions = DeleteOptions;
|
|
1357
|
+
/**
|
|
1358
|
+
* Document field inputs mirror collection field inputs.
|
|
1359
|
+
*/
|
|
1360
|
+
type CreateDocumentFieldInput = CreateFieldInput;
|
|
1361
|
+
/**
|
|
1362
|
+
* Document field update inputs mirror collection field inputs.
|
|
1363
|
+
*/
|
|
1364
|
+
type UpdateDocumentFieldInput = UpdateFieldInput;
|
|
1365
|
+
/**
|
|
1366
|
+
* Response payload for document field list operations.
|
|
1367
|
+
*/
|
|
1368
|
+
type DocumentFieldListResponse = CollectionFieldListResponse;
|
|
1369
|
+
/**
|
|
1370
|
+
* Response payload for document section list operations.
|
|
1371
|
+
*/
|
|
1372
|
+
type DocumentSectionListResponse = CollectionSectionListResponse;
|
|
1373
|
+
/**
|
|
1374
|
+
* Response payload for document values routes.
|
|
1375
|
+
*/
|
|
1376
|
+
interface DocumentValuesResponse {
|
|
1377
|
+
values: Record<string, unknown>;
|
|
1378
|
+
}
|
|
1379
|
+
/**
|
|
1380
|
+
* SEO payload for document management routes.
|
|
1381
|
+
*/
|
|
1382
|
+
type DocumentSeo = Seo | SeoInput | Record<string, unknown> | null;
|
|
1383
|
+
/**
|
|
1384
|
+
* Response payload for document SEO routes.
|
|
1385
|
+
*/
|
|
1386
|
+
interface DocumentSeoResponse {
|
|
1387
|
+
seo: DocumentSeo;
|
|
1388
|
+
}
|
|
1389
|
+
|
|
1390
|
+
/**
|
|
1391
|
+
* Document field management endpoints.
|
|
1392
|
+
*/
|
|
1393
|
+
declare class DocumentFieldsResource {
|
|
1394
|
+
#private;
|
|
1395
|
+
/**
|
|
1396
|
+
* @internal
|
|
1397
|
+
*/
|
|
1398
|
+
constructor(http: HttpClient);
|
|
1399
|
+
/**
|
|
1400
|
+
* Lists all fields in a document.
|
|
1401
|
+
*/
|
|
1402
|
+
list(documentKey: string): Promise<FieldInfo[]>;
|
|
1403
|
+
/**
|
|
1404
|
+
* Gets a single field in a document.
|
|
1405
|
+
*/
|
|
1406
|
+
get(documentKey: string, fieldId: string): Promise<FieldInfo>;
|
|
1407
|
+
/**
|
|
1408
|
+
* Creates a field in a document.
|
|
1409
|
+
*
|
|
1410
|
+
* Sends an `Idempotency-Key` (required of suite bearers): a fresh one per
|
|
1411
|
+
* call, or `options.idempotencyKey` to make your own retry safe.
|
|
1412
|
+
*/
|
|
1413
|
+
create(documentKey: string, input: CreateDocumentFieldInput, options?: IdempotencyOptions): Promise<FieldInfo>;
|
|
1414
|
+
/**
|
|
1415
|
+
* Updates a field in a document.
|
|
1416
|
+
*/
|
|
1417
|
+
update(documentKey: string, fieldId: string, input: UpdateDocumentFieldInput): Promise<FieldInfo>;
|
|
1418
|
+
/**
|
|
1419
|
+
* Deletes a field from a document.
|
|
1420
|
+
*/
|
|
1421
|
+
delete(documentKey: string, fieldId: string): Promise<{
|
|
1422
|
+
success: true;
|
|
1423
|
+
}>;
|
|
1424
|
+
/**
|
|
1425
|
+
* Lists the document's archived (soft-deleted) fields, most recently
|
|
1426
|
+
* deleted first. Their values are kept, which is what makes `restore` work.
|
|
1427
|
+
*
|
|
1428
|
+
* `GET /documents/{documentKey}/fields/deleted`. Secret key, or suite bearer
|
|
1429
|
+
* with `zap:content:read`.
|
|
1430
|
+
*/
|
|
1431
|
+
listDeleted(documentKey: string): Promise<FieldInfo[]>;
|
|
1432
|
+
/**
|
|
1433
|
+
* Brings an archived field back with every value it held, at the end of the
|
|
1434
|
+
* root list (outside any section).
|
|
1435
|
+
*
|
|
1436
|
+
* `POST /documents/{documentKey}/fields/{fieldId}/restore`. Secret key, or
|
|
1437
|
+
* suite bearer with `zap:schema:write` and the Zap ADMIN role.
|
|
1438
|
+
*/
|
|
1439
|
+
restore(documentKey: string, fieldId: string): Promise<FieldInfo>;
|
|
1440
|
+
/**
|
|
1441
|
+
* Reorders document fields.
|
|
1442
|
+
*/
|
|
1443
|
+
reorder(documentKey: string, fieldIds: string[]): Promise<{
|
|
1444
|
+
success: true;
|
|
1445
|
+
}>;
|
|
1446
|
+
}
|
|
1447
|
+
|
|
1448
|
+
/**
|
|
1449
|
+
* Document section management endpoints.
|
|
1450
|
+
*/
|
|
1451
|
+
declare class DocumentSectionsResource {
|
|
1452
|
+
#private;
|
|
1453
|
+
/**
|
|
1454
|
+
* @internal
|
|
1455
|
+
*/
|
|
1456
|
+
constructor(http: HttpClient);
|
|
1457
|
+
/**
|
|
1458
|
+
* Lists all sections in a document.
|
|
1459
|
+
*/
|
|
1460
|
+
list(documentKey: string): Promise<SectionInfo[]>;
|
|
1461
|
+
/**
|
|
1462
|
+
* Gets a single section from a document.
|
|
1463
|
+
*/
|
|
1464
|
+
get(documentKey: string, sectionId: string): Promise<SectionInfo>;
|
|
1465
|
+
/**
|
|
1466
|
+
* Creates a section in a document.
|
|
1467
|
+
*
|
|
1468
|
+
* Sends an `Idempotency-Key` (required of suite bearers): a fresh one per
|
|
1469
|
+
* call, or `options.idempotencyKey` to make your own retry safe.
|
|
1470
|
+
*/
|
|
1471
|
+
create(documentKey: string, input: CreateSectionInput, options?: IdempotencyOptions): Promise<SectionInfo>;
|
|
1472
|
+
/**
|
|
1473
|
+
* Updates a section in a document.
|
|
1474
|
+
*/
|
|
1475
|
+
update(documentKey: string, sectionId: string, input: UpdateSectionInput): Promise<SectionInfo>;
|
|
1476
|
+
/**
|
|
1477
|
+
* Deletes a section from a document.
|
|
1478
|
+
*/
|
|
1479
|
+
delete(documentKey: string, sectionId: string): Promise<{
|
|
1480
|
+
success: true;
|
|
1481
|
+
}>;
|
|
1482
|
+
}
|
|
1483
|
+
|
|
1484
|
+
/**
|
|
1485
|
+
* Document SEO management endpoints.
|
|
1486
|
+
*/
|
|
1487
|
+
declare class DocumentSeoResource {
|
|
1488
|
+
#private;
|
|
1489
|
+
/**
|
|
1490
|
+
* @internal
|
|
1491
|
+
*/
|
|
1492
|
+
constructor(http: HttpClient);
|
|
1493
|
+
/**
|
|
1494
|
+
* Gets SEO metadata for a document.
|
|
1495
|
+
*/
|
|
1496
|
+
get(documentKey: string, options?: {
|
|
1497
|
+
locale?: string;
|
|
1498
|
+
}): Promise<DocumentSeo>;
|
|
1499
|
+
/**
|
|
1500
|
+
* Updates SEO metadata for a document.
|
|
1501
|
+
*/
|
|
1502
|
+
update(documentKey: string, input: SeoInput): Promise<DocumentSeo>;
|
|
1503
|
+
}
|
|
1504
|
+
|
|
1505
|
+
/**
|
|
1506
|
+
* Document value management endpoints.
|
|
1507
|
+
*/
|
|
1508
|
+
declare class DocumentValuesResource {
|
|
1509
|
+
#private;
|
|
1510
|
+
/**
|
|
1511
|
+
* @internal
|
|
1512
|
+
*/
|
|
1513
|
+
constructor(http: HttpClient);
|
|
1514
|
+
/**
|
|
1515
|
+
* Gets all document values.
|
|
1516
|
+
*/
|
|
1517
|
+
get(documentKey: string): Promise<Record<string, unknown>>;
|
|
1518
|
+
/**
|
|
1519
|
+
* Updates document values by field key.
|
|
1520
|
+
*/
|
|
1521
|
+
update(documentKey: string, values: Record<string, unknown>, options?: {
|
|
1522
|
+
locale?: string;
|
|
1523
|
+
}): Promise<Record<string, unknown>>;
|
|
1524
|
+
}
|
|
1525
|
+
|
|
1526
|
+
/**
|
|
1527
|
+
* Read-only document endpoints.
|
|
1528
|
+
*/
|
|
1529
|
+
declare class DocumentsResource {
|
|
1530
|
+
#private;
|
|
1531
|
+
readonly fields: DocumentFieldsResource;
|
|
1532
|
+
readonly sections: DocumentSectionsResource;
|
|
1533
|
+
readonly values: DocumentValuesResource;
|
|
1534
|
+
readonly seo: DocumentSeoResource;
|
|
1535
|
+
/**
|
|
1536
|
+
* @internal
|
|
1537
|
+
*/
|
|
1538
|
+
constructor(http: HttpClient, defaults: ClientDefaults);
|
|
1539
|
+
/**
|
|
1540
|
+
* Lists all documents available to the current API key.
|
|
1541
|
+
*/
|
|
1542
|
+
list(options?: DocumentListOptions): Promise<DocumentListResponse>;
|
|
1543
|
+
/**
|
|
1544
|
+
* Retrieves a single document by key.
|
|
1545
|
+
*/
|
|
1546
|
+
get<TContent = Record<string, unknown>>(documentKey: string, options?: DocumentGetOptions): Promise<DocumentDetail<TContent>>;
|
|
1547
|
+
/**
|
|
1548
|
+
* Creates a document.
|
|
1549
|
+
*
|
|
1550
|
+
* Sends an `Idempotency-Key` (required of suite bearers): a fresh one per
|
|
1551
|
+
* call, or `options.idempotencyKey` to make your own retry safe.
|
|
1552
|
+
*/
|
|
1553
|
+
create<TContent = Record<string, unknown>>(input: CreateDocumentInput, options?: IdempotencyOptions): Promise<DocumentDetail<TContent>>;
|
|
1554
|
+
/**
|
|
1555
|
+
* Updates a document.
|
|
1556
|
+
*/
|
|
1557
|
+
update<TContent = Record<string, unknown>>(documentKey: string, input: UpdateDocumentInput): Promise<DocumentDetail<TContent>>;
|
|
1558
|
+
/**
|
|
1559
|
+
* Deletes a document.
|
|
1560
|
+
*/
|
|
1561
|
+
delete(documentKey: string, options?: DeleteDocumentOptions): Promise<{
|
|
1562
|
+
success: true;
|
|
1563
|
+
}>;
|
|
1564
|
+
/**
|
|
1565
|
+
* Publishes a document.
|
|
1566
|
+
*/
|
|
1567
|
+
publish<TContent = Record<string, unknown>>(documentKey: string): Promise<DocumentDetail<TContent>>;
|
|
1568
|
+
/**
|
|
1569
|
+
* Unpublishes a document.
|
|
1570
|
+
*/
|
|
1571
|
+
unpublish<TContent = Record<string, unknown>>(documentKey: string): Promise<DocumentDetail<TContent>>;
|
|
1572
|
+
}
|
|
1573
|
+
|
|
1574
|
+
/**
|
|
1575
|
+
* Version history, drafts and rollbacks for collection items
|
|
1576
|
+
* (`/collections/{collectionKey}/items/{slug}/versions…`).
|
|
1577
|
+
*
|
|
1578
|
+
* An item has at most one open draft. Writing needs a secret key; publishing
|
|
1579
|
+
* and rolling back need one with publish rights.
|
|
1580
|
+
*/
|
|
1581
|
+
declare class ItemVersionsResource {
|
|
1582
|
+
#private;
|
|
1583
|
+
/** @internal */
|
|
1584
|
+
constructor(http: HttpClient);
|
|
1585
|
+
/**
|
|
1586
|
+
* Lists an item's versions, newest first.
|
|
1587
|
+
*/
|
|
1588
|
+
list(collectionKey: string, slug: string): Promise<VersionListResponse<ItemVersionSummary>>;
|
|
1589
|
+
/**
|
|
1590
|
+
* Gets one version with its snapshot (values, SEO and slugs).
|
|
1591
|
+
*/
|
|
1592
|
+
get(collectionKey: string, slug: string, versionId: string): Promise<ItemVersionDetail>;
|
|
1593
|
+
/**
|
|
1594
|
+
* Opens a draft from the item's live state. Fails with `DUPLICATE_KEY` (409)
|
|
1595
|
+
* when the item already has one.
|
|
1596
|
+
*/
|
|
1597
|
+
createDraft(collectionKey: string, slug: string, input?: CreateDraftInput): Promise<ItemVersionSummary>;
|
|
1598
|
+
/**
|
|
1599
|
+
* Stages values (and optionally a new slug) on the open draft without
|
|
1600
|
+
* touching the live item. Fails with `VALIDATION_ERROR` (400) when there is
|
|
1601
|
+
* no open draft.
|
|
1602
|
+
*/
|
|
1603
|
+
updateDraft(collectionKey: string, slug: string, input: UpdateItemDraftInput): Promise<ItemVersionDetail>;
|
|
1604
|
+
/**
|
|
1605
|
+
* Discards the open draft. Fails with `NOT_FOUND` (404) when there is none.
|
|
1606
|
+
*/
|
|
1607
|
+
discardDraft(collectionKey: string, slug: string): Promise<void>;
|
|
1608
|
+
/**
|
|
1609
|
+
* Publishes the open draft: its values go live and it becomes the item's
|
|
1610
|
+
* published version. Fails with `NOT_FOUND` (404) when there is no draft.
|
|
1611
|
+
*/
|
|
1612
|
+
publishDraft(collectionKey: string, slug: string): Promise<ItemVersionSummary>;
|
|
1613
|
+
/**
|
|
1614
|
+
* Restores a past version over the live item and records the restore as a
|
|
1615
|
+
* NEW published version (history is never rewritten). Refused (409) for a
|
|
1616
|
+
* draft version, or while the item has an open draft.
|
|
1617
|
+
*/
|
|
1618
|
+
rollback(collectionKey: string, slug: string, versionId: string): Promise<ItemVersionSummary>;
|
|
1619
|
+
}
|
|
1620
|
+
|
|
1621
|
+
/**
|
|
1622
|
+
* Operators supported by item filters.
|
|
1623
|
+
*/
|
|
1624
|
+
interface FilterOperatorMap {
|
|
1625
|
+
eq?: QueryPrimitive;
|
|
1626
|
+
ne?: QueryPrimitive;
|
|
1627
|
+
gt?: QueryPrimitive;
|
|
1628
|
+
gte?: QueryPrimitive;
|
|
1629
|
+
lt?: QueryPrimitive;
|
|
1630
|
+
lte?: QueryPrimitive;
|
|
1631
|
+
in?: QueryPrimitive[] | string;
|
|
1632
|
+
contains?: string;
|
|
1633
|
+
}
|
|
1634
|
+
/**
|
|
1635
|
+
* Single filter value accepted by the SDK.
|
|
1636
|
+
*/
|
|
1637
|
+
type FilterValue = QueryPrimitive | FilterOperatorMap;
|
|
1638
|
+
/**
|
|
1639
|
+
* Item list filter object keyed by field name.
|
|
1640
|
+
*/
|
|
1641
|
+
type ItemFilters = Record<string, FilterValue>;
|
|
1642
|
+
/**
|
|
1643
|
+
* Options for the item list endpoint.
|
|
1644
|
+
*/
|
|
1645
|
+
interface ItemListOptions extends CommonRequestOptions, PreviewOption {
|
|
1646
|
+
page?: number;
|
|
1647
|
+
pageSize?: number;
|
|
1648
|
+
sort?: string;
|
|
1649
|
+
filter?: ItemFilters;
|
|
1650
|
+
}
|
|
1651
|
+
/**
|
|
1652
|
+
* Options for the item detail endpoint.
|
|
1653
|
+
*/
|
|
1654
|
+
type ItemGetOptions = CommonRequestOptions & PreviewOption;
|
|
1655
|
+
/**
|
|
1656
|
+
* Single item payload.
|
|
1657
|
+
*/
|
|
1658
|
+
interface ItemDetail<TContent = Record<string, unknown>> {
|
|
1659
|
+
slug: string;
|
|
1660
|
+
status: string;
|
|
1661
|
+
locale: string;
|
|
1662
|
+
localizedSlugs: Record<string, string>;
|
|
1663
|
+
meta: ItemMeta;
|
|
1664
|
+
content: TContent;
|
|
1665
|
+
seo: Seo | null;
|
|
1666
|
+
collection: {
|
|
1667
|
+
key: string;
|
|
1668
|
+
name: string;
|
|
1669
|
+
};
|
|
1670
|
+
}
|
|
1671
|
+
/**
|
|
1672
|
+
* Item list response payload.
|
|
1673
|
+
*/
|
|
1674
|
+
interface ItemListResponse<TContent = Record<string, unknown>> {
|
|
1675
|
+
data: ItemDetail<TContent>[];
|
|
1676
|
+
pagination: Pagination;
|
|
1677
|
+
collection: CollectionSummary;
|
|
1678
|
+
}
|
|
1679
|
+
/**
|
|
1680
|
+
* Input for creating a collection item.
|
|
1681
|
+
*/
|
|
1682
|
+
interface CreateItemInput {
|
|
1683
|
+
slug: string;
|
|
1684
|
+
locale?: string;
|
|
1685
|
+
values: Record<string, unknown>;
|
|
1686
|
+
}
|
|
1687
|
+
/**
|
|
1688
|
+
* Input for updating a collection item.
|
|
1689
|
+
*/
|
|
1690
|
+
interface UpdateItemInput {
|
|
1691
|
+
slug?: string;
|
|
1692
|
+
locale?: string;
|
|
1693
|
+
values?: Record<string, unknown>;
|
|
1694
|
+
}
|
|
1695
|
+
/**
|
|
1696
|
+
* Response payload for item mutation routes.
|
|
1697
|
+
*/
|
|
1698
|
+
interface ItemMutationResponse<TContent = Record<string, unknown>> {
|
|
1699
|
+
item: ItemDetail<TContent>;
|
|
1700
|
+
}
|
|
1701
|
+
/**
|
|
1702
|
+
* Response payload for item delete routes.
|
|
1703
|
+
*/
|
|
1704
|
+
interface ItemDeleteResponse {
|
|
1705
|
+
success: true;
|
|
1706
|
+
}
|
|
1707
|
+
/**
|
|
1708
|
+
* Extra options for item deletion.
|
|
1709
|
+
*/
|
|
1710
|
+
type DeleteItemOptions = DeleteOptions;
|
|
1711
|
+
/**
|
|
1712
|
+
* SEO payload for item management routes.
|
|
1713
|
+
*/
|
|
1714
|
+
type ItemSeo = Seo | SeoInput | Record<string, unknown> | null;
|
|
1715
|
+
/**
|
|
1716
|
+
* Response payload for item SEO routes.
|
|
1717
|
+
*/
|
|
1718
|
+
interface ItemSeoResponse {
|
|
1719
|
+
seo: ItemSeo;
|
|
1720
|
+
}
|
|
1721
|
+
|
|
1722
|
+
/**
|
|
1723
|
+
* Lazy fluent query builder for item list requests.
|
|
1724
|
+
*/
|
|
1725
|
+
declare class ItemQueryBuilder {
|
|
1726
|
+
#private;
|
|
1727
|
+
/**
|
|
1728
|
+
* @internal
|
|
1729
|
+
*/
|
|
1730
|
+
constructor(http: HttpClient, defaults: ClientDefaults, collectionKey: string, options?: ItemListOptions);
|
|
1731
|
+
/**
|
|
1732
|
+
* Overrides the request locale.
|
|
1733
|
+
*/
|
|
1734
|
+
locale(locale: string): ItemQueryBuilder;
|
|
1735
|
+
/**
|
|
1736
|
+
* Overrides the delivery status filter.
|
|
1737
|
+
*/
|
|
1738
|
+
status(status: NonNullable<ItemListOptions['status']>): ItemQueryBuilder;
|
|
1739
|
+
/**
|
|
1740
|
+
* Adds or replaces a field filter.
|
|
1741
|
+
*/
|
|
1742
|
+
filter(field: string, value: FilterValue): ItemQueryBuilder;
|
|
1743
|
+
/**
|
|
1744
|
+
* Sets the sort expression.
|
|
1745
|
+
*/
|
|
1746
|
+
sort(sort: string): ItemQueryBuilder;
|
|
1747
|
+
/**
|
|
1748
|
+
* Selects a sparse set of content fields.
|
|
1749
|
+
*/
|
|
1750
|
+
fields(fields: string[]): ItemQueryBuilder;
|
|
1751
|
+
/**
|
|
1752
|
+
* Sets the current page.
|
|
1753
|
+
*/
|
|
1754
|
+
page(page: number): ItemQueryBuilder;
|
|
1755
|
+
/**
|
|
1756
|
+
* Sets the page size.
|
|
1757
|
+
*/
|
|
1758
|
+
pageSize(pageSize: number): ItemQueryBuilder;
|
|
1759
|
+
/**
|
|
1760
|
+
* Executes the built request.
|
|
1761
|
+
*/
|
|
1762
|
+
get<TContent = Record<string, unknown>>(): Promise<ItemListResponse<TContent>>;
|
|
1763
|
+
/**
|
|
1764
|
+
* Returns the current request options as a plain object.
|
|
1765
|
+
*/
|
|
1766
|
+
toJSON(): ItemListOptions;
|
|
1767
|
+
private clone;
|
|
1768
|
+
}
|
|
1769
|
+
|
|
1770
|
+
/**
|
|
1771
|
+
* Item SEO management endpoints.
|
|
1772
|
+
*/
|
|
1773
|
+
declare class ItemSeoResource {
|
|
1774
|
+
#private;
|
|
1775
|
+
/**
|
|
1776
|
+
* @internal
|
|
1777
|
+
*/
|
|
1778
|
+
constructor(http: HttpClient);
|
|
1779
|
+
/**
|
|
1780
|
+
* Gets SEO metadata for an item.
|
|
1781
|
+
*/
|
|
1782
|
+
get(collectionKey: string, slug: string, options?: {
|
|
1783
|
+
locale?: string;
|
|
1784
|
+
}): Promise<ItemSeo>;
|
|
1785
|
+
/**
|
|
1786
|
+
* Updates SEO metadata for an item.
|
|
1787
|
+
*/
|
|
1788
|
+
update(collectionKey: string, slug: string, input: SeoInput): Promise<ItemSeo>;
|
|
1789
|
+
}
|
|
1790
|
+
|
|
1791
|
+
/**
|
|
1792
|
+
* Read-only collection item endpoints.
|
|
1793
|
+
*/
|
|
1794
|
+
declare class ItemsResource {
|
|
1795
|
+
#private;
|
|
1796
|
+
readonly seo: ItemSeoResource;
|
|
1797
|
+
/**
|
|
1798
|
+
* @internal
|
|
1799
|
+
*/
|
|
1800
|
+
constructor(http: HttpClient, defaults: ClientDefaults);
|
|
1801
|
+
/**
|
|
1802
|
+
* Lists items in a collection.
|
|
1803
|
+
*/
|
|
1804
|
+
list<TContent = Record<string, unknown>>(collectionKey: string, options?: ItemListOptions): Promise<ItemListResponse<TContent>>;
|
|
1805
|
+
/**
|
|
1806
|
+
* Retrieves a single item by slug.
|
|
1807
|
+
*/
|
|
1808
|
+
get<TContent = Record<string, unknown>>(collectionKey: string, slug: string, options?: ItemGetOptions): Promise<ItemDetail<TContent>>;
|
|
1809
|
+
/**
|
|
1810
|
+
* Starts a lazy fluent query builder for a collection.
|
|
1811
|
+
*/
|
|
1812
|
+
collection(collectionKey: string): ItemQueryBuilder;
|
|
1813
|
+
/**
|
|
1814
|
+
* Creates an item in a collection.
|
|
1815
|
+
*
|
|
1816
|
+
* Sends an `Idempotency-Key` (required of suite bearers): a fresh one per
|
|
1817
|
+
* call, or `options.idempotencyKey` to make your own retry safe.
|
|
1818
|
+
*/
|
|
1819
|
+
create<TContent = Record<string, unknown>>(collectionKey: string, input: CreateItemInput, options?: IdempotencyOptions): Promise<ItemDetail<TContent>>;
|
|
1820
|
+
/**
|
|
1821
|
+
* Updates an item by slug.
|
|
1822
|
+
*/
|
|
1823
|
+
update<TContent = Record<string, unknown>>(collectionKey: string, slug: string, input: UpdateItemInput): Promise<ItemDetail<TContent>>;
|
|
1824
|
+
/**
|
|
1825
|
+
* Deletes an item by slug.
|
|
1826
|
+
*/
|
|
1827
|
+
delete(collectionKey: string, slug: string, options?: DeleteItemOptions): Promise<{
|
|
1828
|
+
success: true;
|
|
1829
|
+
}>;
|
|
1830
|
+
/**
|
|
1831
|
+
* Publishes an item by slug.
|
|
1832
|
+
*/
|
|
1833
|
+
publish<TContent = Record<string, unknown>>(collectionKey: string, slug: string): Promise<ItemDetail<TContent>>;
|
|
1834
|
+
/**
|
|
1835
|
+
* Unpublishes an item by slug.
|
|
1836
|
+
*/
|
|
1837
|
+
unpublish<TContent = Record<string, unknown>>(collectionKey: string, slug: string): Promise<ItemDetail<TContent>>;
|
|
1838
|
+
}
|
|
1839
|
+
|
|
1840
|
+
/**
|
|
1841
|
+
* Media types supported by the public management API.
|
|
1842
|
+
*/
|
|
1843
|
+
type MediaType = 'IMAGE' | 'VIDEO' | 'AUDIO' | 'DOCUMENT' | 'OTHER' | (string & {});
|
|
1844
|
+
/**
|
|
1845
|
+
* Sort expressions supported by the media list route.
|
|
1846
|
+
*/
|
|
1847
|
+
type MediaSort = 'createdAt:desc' | 'createdAt:asc' | 'filename:asc' | 'filename:desc' | 'size:desc' | 'size:asc';
|
|
1848
|
+
/**
|
|
1849
|
+
* Usage filter supported by the media list route.
|
|
1850
|
+
*/
|
|
1851
|
+
type MediaUsage = 'all' | 'linked' | 'unlinked';
|
|
1852
|
+
/**
|
|
1853
|
+
* Media list params accepted by the public API.
|
|
1854
|
+
*/
|
|
1855
|
+
interface MediaListParams {
|
|
1856
|
+
search?: string;
|
|
1857
|
+
page?: number;
|
|
1858
|
+
pageSize?: number;
|
|
1859
|
+
sort?: MediaSort;
|
|
1860
|
+
type?: MediaType;
|
|
1861
|
+
status?: Uppercase<DeliveryStatus> | DeliveryStatus;
|
|
1862
|
+
usage?: MediaUsage;
|
|
1863
|
+
}
|
|
1864
|
+
/**
|
|
1865
|
+
* Media payload returned by management routes.
|
|
1866
|
+
*/
|
|
1867
|
+
interface MediaDetail {
|
|
1868
|
+
id: string;
|
|
1869
|
+
filename?: string;
|
|
1870
|
+
type: MediaType;
|
|
1871
|
+
mimeType?: string;
|
|
1872
|
+
contentType?: string;
|
|
1873
|
+
size?: number;
|
|
1874
|
+
width: number | null;
|
|
1875
|
+
height: number | null;
|
|
1876
|
+
alt?: string | null;
|
|
1877
|
+
title?: string | null;
|
|
1878
|
+
description?: string | null;
|
|
1879
|
+
url: string | null;
|
|
1880
|
+
status: string;
|
|
1881
|
+
mediaAccess?: string;
|
|
1882
|
+
signedUrl?: string | null;
|
|
1883
|
+
signedUrlExpiresAt?: string | null;
|
|
1884
|
+
createdAt?: string;
|
|
1885
|
+
updatedAt?: string;
|
|
1886
|
+
}
|
|
1887
|
+
/**
|
|
1888
|
+
* Response payload for media list routes.
|
|
1889
|
+
*/
|
|
1890
|
+
interface MediaListResponse {
|
|
1891
|
+
items: MediaDetail[];
|
|
1892
|
+
page: number;
|
|
1893
|
+
pageSize: number;
|
|
1894
|
+
total?: number;
|
|
1895
|
+
pageCount?: number;
|
|
1896
|
+
pagination?: Pagination;
|
|
1897
|
+
}
|
|
1898
|
+
/**
|
|
1899
|
+
* Response payload for a single media detail route.
|
|
1900
|
+
*/
|
|
1901
|
+
type MediaDetailResponse = MediaDetail;
|
|
1902
|
+
/**
|
|
1903
|
+
* Input for updating media metadata.
|
|
1904
|
+
*/
|
|
1905
|
+
interface UpdateMediaInput {
|
|
1906
|
+
alt?: string | null;
|
|
1907
|
+
title?: string | null;
|
|
1908
|
+
description?: string | null;
|
|
1909
|
+
}
|
|
1910
|
+
/**
|
|
1911
|
+
* Input for `POST /media/from-url`: Zap downloads the file server-side.
|
|
1912
|
+
*/
|
|
1913
|
+
interface MediaFromUrlInput {
|
|
1914
|
+
/** An absolute http(s) URL on port 80 or 443, at most 2048 characters. */
|
|
1915
|
+
url: string;
|
|
1916
|
+
/** Defaults to the URL's last path segment. At most 255 characters. */
|
|
1917
|
+
filename?: string;
|
|
1918
|
+
/** `''` or `null` mean none; at most 2000 characters. */
|
|
1919
|
+
title?: string | null;
|
|
1920
|
+
alt?: string | null;
|
|
1921
|
+
}
|
|
1922
|
+
/**
|
|
1923
|
+
* Input for requesting a presigned upload URL.
|
|
1924
|
+
*/
|
|
1925
|
+
interface CreateUploadUrlInput {
|
|
1926
|
+
filename: string;
|
|
1927
|
+
contentType: string;
|
|
1928
|
+
size: number;
|
|
1929
|
+
width?: number;
|
|
1930
|
+
height?: number;
|
|
1931
|
+
}
|
|
1932
|
+
/**
|
|
1933
|
+
* Response payload for the upload URL route.
|
|
1934
|
+
*/
|
|
1935
|
+
interface UploadUrlResponse {
|
|
1936
|
+
uploadUrl: string;
|
|
1937
|
+
mediaId: string;
|
|
1938
|
+
key: string;
|
|
1939
|
+
}
|
|
1940
|
+
/**
|
|
1941
|
+
* Input for confirming an upload.
|
|
1942
|
+
*/
|
|
1943
|
+
interface ConfirmUploadInput {
|
|
1944
|
+
mediaId: string;
|
|
1945
|
+
key: string;
|
|
1946
|
+
filename: string;
|
|
1947
|
+
contentType: string;
|
|
1948
|
+
size: number;
|
|
1949
|
+
width?: number;
|
|
1950
|
+
height?: number;
|
|
1951
|
+
}
|
|
1952
|
+
/**
|
|
1953
|
+
* Accepted binary sources for high-level uploads.
|
|
1954
|
+
*/
|
|
1955
|
+
type UploadFile = ArrayBuffer | ArrayBufferView | Blob;
|
|
1956
|
+
/**
|
|
1957
|
+
* High-level media upload input.
|
|
1958
|
+
*/
|
|
1959
|
+
interface MediaUploadInput {
|
|
1960
|
+
file: UploadFile;
|
|
1961
|
+
filename: string;
|
|
1962
|
+
contentType: string;
|
|
1963
|
+
width?: number;
|
|
1964
|
+
height?: number;
|
|
1965
|
+
alt?: string | null;
|
|
1966
|
+
title?: string | null;
|
|
1967
|
+
description?: string | null;
|
|
1968
|
+
}
|
|
1969
|
+
|
|
1970
|
+
/**
|
|
1971
|
+
* Media management endpoints.
|
|
1972
|
+
*/
|
|
1973
|
+
declare class MediaResource {
|
|
1974
|
+
#private;
|
|
1975
|
+
/**
|
|
1976
|
+
* @internal
|
|
1977
|
+
*/
|
|
1978
|
+
constructor(http: HttpClient);
|
|
1979
|
+
/**
|
|
1980
|
+
* Lists media for the current site.
|
|
1981
|
+
*/
|
|
1982
|
+
list(params?: MediaListParams): Promise<MediaListResponse>;
|
|
1983
|
+
/**
|
|
1984
|
+
* Gets a single media item.
|
|
1985
|
+
*/
|
|
1986
|
+
get(id: string): Promise<MediaDetail>;
|
|
1987
|
+
/**
|
|
1988
|
+
* Updates media metadata.
|
|
1989
|
+
*/
|
|
1990
|
+
update(id: string, input: UpdateMediaInput): Promise<MediaDetail>;
|
|
1991
|
+
/**
|
|
1992
|
+
* Deletes media.
|
|
1993
|
+
*/
|
|
1994
|
+
delete(id: string): Promise<{
|
|
1995
|
+
success: true;
|
|
1996
|
+
}>;
|
|
1997
|
+
/**
|
|
1998
|
+
* Publishes media.
|
|
1999
|
+
*/
|
|
2000
|
+
publish(id: string): Promise<MediaDetail>;
|
|
2001
|
+
/**
|
|
2002
|
+
* Unpublishes media.
|
|
2003
|
+
*/
|
|
2004
|
+
unpublish(id: string): Promise<MediaDetail>;
|
|
2005
|
+
/**
|
|
2006
|
+
* Requests a presigned upload URL.
|
|
2007
|
+
*/
|
|
2008
|
+
createUploadUrl(input: CreateUploadUrlInput): Promise<UploadUrlResponse>;
|
|
2009
|
+
/**
|
|
2010
|
+
* Confirms a completed upload.
|
|
2011
|
+
*/
|
|
2012
|
+
confirmUpload(input: ConfirmUploadInput): Promise<MediaDetail>;
|
|
2013
|
+
/**
|
|
2014
|
+
* Fetches a file from a URL into the media library, server-side (SSRF
|
|
2015
|
+
* guarded, type allowlist, size ceiling). The file starts private (`DRAFT`):
|
|
2016
|
+
* the answer carries a 15-minute `signedUrl` and no `url` until `publish`.
|
|
2017
|
+
*
|
|
2018
|
+
* `POST /media/from-url`. Secret key, or suite bearer with
|
|
2019
|
+
* `zap:media:write`. Sends an `Idempotency-Key` (required of suite bearers;
|
|
2020
|
+
* a retry with the same key replays the first answer without downloading
|
|
2021
|
+
* again). Server-side only: the API's general CORS does not allow that
|
|
2022
|
+
* header from a browser.
|
|
2023
|
+
*/
|
|
2024
|
+
fromUrl(input: MediaFromUrlInput, options?: IdempotencyOptions): Promise<MediaDetail>;
|
|
2025
|
+
/**
|
|
2026
|
+
* Uploads media using the public presigned URL flow.
|
|
2027
|
+
*/
|
|
2028
|
+
upload(input: MediaUploadInput): Promise<MediaDetail>;
|
|
2029
|
+
}
|
|
2030
|
+
|
|
2031
|
+
/**
|
|
2032
|
+
* Preview tokens (`zpt_…`, zap-cms-v2 §3.5): ten minutes, one site, read-only.
|
|
2033
|
+
*/
|
|
2034
|
+
declare class PreviewTokensResource {
|
|
2035
|
+
#private;
|
|
2036
|
+
/**
|
|
2037
|
+
* @internal
|
|
2038
|
+
*/
|
|
2039
|
+
constructor(http: HttpClient);
|
|
2040
|
+
/**
|
|
2041
|
+
* Checks that the client's preview token is live AND was minted for the
|
|
2042
|
+
* site `siteApiKey` belongs to, before trusting it (what a draft-mode route
|
|
2043
|
+
* does before turning draft mode on). Rejects with `EelZapError` 401 for an
|
|
2044
|
+
* unknown, revoked or expired token, 403 `WRONG_SITE` for another site's.
|
|
2045
|
+
*
|
|
2046
|
+
* `GET /preview/token`. The client's `apiKey` must be the `zpt_` token
|
|
2047
|
+
* itself (any other bearer is 403); `siteApiKey` is one of the site's own
|
|
2048
|
+
* API keys (public or secret), sent as `X-Zap-Site-Api-Key`.
|
|
2049
|
+
*
|
|
2050
|
+
* @example
|
|
2051
|
+
* ```ts
|
|
2052
|
+
* const zap = createClient({ apiKey: token })
|
|
2053
|
+
* const { site, expiresAt } = await zap.previewTokens.validate(process.env.ZAP_PUBLIC_KEY!)
|
|
2054
|
+
* ```
|
|
2055
|
+
*/
|
|
2056
|
+
validate(siteApiKey: string): Promise<PreviewTokenValidation>;
|
|
2057
|
+
}
|
|
2058
|
+
|
|
2059
|
+
/**
|
|
2060
|
+
* The site the API key belongs to: read it, and set where it lives.
|
|
2061
|
+
*/
|
|
2062
|
+
declare class SiteResource {
|
|
2063
|
+
#private;
|
|
2064
|
+
/**
|
|
2065
|
+
* @internal
|
|
2066
|
+
*/
|
|
2067
|
+
constructor(http: HttpClient);
|
|
2068
|
+
/**
|
|
2069
|
+
* Resolves the current site from the authenticated API key.
|
|
2070
|
+
*/
|
|
2071
|
+
get(): Promise<SiteInfo>;
|
|
2072
|
+
/**
|
|
2073
|
+
* Sets the site's URL and «Otros dominios» (`PATCH /site`), under the same
|
|
2074
|
+
* rules as the site's settings page, and resolves to the updated site.
|
|
2075
|
+
* Server code only: it needs a `secret_` key or an ADMIN suite credential.
|
|
2076
|
+
*/
|
|
2077
|
+
update(input: UpdateSiteInput): Promise<SiteInfo>;
|
|
2078
|
+
}
|
|
2079
|
+
|
|
2080
|
+
/**
|
|
2081
|
+
* The credential's workspace's sites.
|
|
2082
|
+
*/
|
|
2083
|
+
declare class SitesResource {
|
|
2084
|
+
#private;
|
|
2085
|
+
/**
|
|
2086
|
+
* @internal
|
|
2087
|
+
*/
|
|
2088
|
+
constructor(http: HttpClient);
|
|
2089
|
+
/**
|
|
2090
|
+
* Lists the workspace's sites, newest first. Each one's `key` or `id` is a
|
|
2091
|
+
* valid `X-Eel-Site` for every other call; this is how a suite client
|
|
2092
|
+
* learns which sites it can address.
|
|
2093
|
+
*
|
|
2094
|
+
* `GET /sites`. Suite bearer only (`eel_sk_` / `eel_at_`), `zap:sites:read`;
|
|
2095
|
+
* needs no `X-Eel-Site`. Site keys are refused: a site key is one site.
|
|
2096
|
+
*/
|
|
2097
|
+
list(): Promise<SiteListEntry[]>;
|
|
2098
|
+
}
|
|
2099
|
+
|
|
2100
|
+
interface ClientConfig {
|
|
2101
|
+
/**
|
|
2102
|
+
* The bearer: a site API key (`secret_…` / `public_…`), or a preview token
|
|
2103
|
+
* (`zpt_…`) from a draft-mode URL — which turns `preview` on by default.
|
|
2104
|
+
*/
|
|
2105
|
+
apiKey: string;
|
|
2106
|
+
baseUrl?: string;
|
|
2107
|
+
pathPrefix?: string;
|
|
2108
|
+
locale?: string;
|
|
2109
|
+
status?: DeliveryStatus;
|
|
2110
|
+
/** Default for the item and document reads' `preview` option. */
|
|
2111
|
+
preview?: boolean;
|
|
2112
|
+
fetch?: typeof globalThis.fetch;
|
|
2113
|
+
defaultHeaders?: HeadersInit;
|
|
2114
|
+
/** Per attempt, in ms. Default `30000`. */
|
|
2115
|
+
timeout?: number;
|
|
2116
|
+
/**
|
|
2117
|
+
* Retries of a `429`, and of a `503` with `Retry-After`, honouring
|
|
2118
|
+
* `Retry-After` with exponential backoff and jitter. On by default for reads
|
|
2119
|
+
* and for writes that carry an `Idempotency-Key`; other writes are never
|
|
2120
|
+
* retried. `false` turns it off.
|
|
2121
|
+
*/
|
|
2122
|
+
retry?: boolean | RetryOptions;
|
|
2123
|
+
}
|
|
2124
|
+
/**
|
|
2125
|
+
* Main SDK client for the EelZap Content Delivery API.
|
|
2126
|
+
*/
|
|
2127
|
+
declare class EelZapClient {
|
|
2128
|
+
#private;
|
|
2129
|
+
readonly site: SiteResource;
|
|
2130
|
+
readonly sites: SitesResource;
|
|
2131
|
+
readonly collections: CollectionsResource;
|
|
2132
|
+
readonly items: ItemsResource;
|
|
2133
|
+
readonly documents: DocumentsResource;
|
|
2134
|
+
readonly media: MediaResource;
|
|
2135
|
+
readonly itemVersions: ItemVersionsResource;
|
|
2136
|
+
readonly documentVersions: DocumentVersionsResource;
|
|
2137
|
+
readonly previewTokens: PreviewTokensResource;
|
|
2138
|
+
readonly comments: CommentsResource;
|
|
2139
|
+
constructor(config: ClientConfig);
|
|
2140
|
+
/**
|
|
2141
|
+
* Returns a masked string representation safe for logs.
|
|
2142
|
+
*/
|
|
2143
|
+
toString(): string;
|
|
2144
|
+
}
|
|
2145
|
+
/**
|
|
2146
|
+
* Creates a configured EelZap Delivery SDK client.
|
|
2147
|
+
*/
|
|
2148
|
+
declare function createClient(config: ClientConfig): EelZapClient;
|
|
2149
|
+
|
|
2150
|
+
/**
|
|
2151
|
+
* API error codes documented by the delivery API.
|
|
2152
|
+
*/
|
|
2153
|
+
type EelZapErrorCode = 'UNAUTHORIZED' | 'KEY_EXPIRED' | 'ORIGIN_NOT_ALLOWED' | 'DRAFT_ACCESS_DENIED' | 'NOT_FOUND' | 'INVALID_FILTER' | 'INVALID_SORT' | 'INVALID_LOCALE' | 'INVALID_PARAMS' | 'RATE_LIMITED' | 'INTERNAL_ERROR' | 'NETWORK_ERROR' | (string & {});
|
|
2154
|
+
|
|
2155
|
+
/**
|
|
2156
|
+
* Base error thrown by the SDK for API and transport failures.
|
|
2157
|
+
*/
|
|
2158
|
+
declare class EelZapError extends Error {
|
|
2159
|
+
readonly code: EelZapErrorCode;
|
|
2160
|
+
readonly status: number;
|
|
2161
|
+
/** Per-field problems when the API refused the input; empty otherwise. */
|
|
2162
|
+
readonly details: readonly ApiErrorDetail[];
|
|
2163
|
+
constructor(code: EelZapErrorCode, message: string, status: number, details?: readonly ApiErrorDetail[]);
|
|
2164
|
+
}
|
|
2165
|
+
/**
|
|
2166
|
+
* Error thrown when a network failure or timeout prevents a response.
|
|
2167
|
+
*/
|
|
2168
|
+
declare class EelZapNetworkError extends EelZapError {
|
|
2169
|
+
readonly cause: unknown;
|
|
2170
|
+
constructor(cause: unknown, message?: string);
|
|
2171
|
+
}
|
|
2172
|
+
/**
|
|
2173
|
+
* Type guard for SDK errors.
|
|
2174
|
+
*/
|
|
2175
|
+
declare function isEelZapError(error: unknown): error is EelZapError;
|
|
2176
|
+
|
|
2177
|
+
/**
|
|
2178
|
+
* The URL to render a media value with: the public `url` of a published file,
|
|
2179
|
+
* else the short-lived `signedUrl` a draft carries when the key may read
|
|
2180
|
+
* drafts. `null` when there is neither — an unpublished file read with a key
|
|
2181
|
+
* that cannot see drafts (`mediaAccess: 'none'`), or no media at all.
|
|
2182
|
+
*
|
|
2183
|
+
* A signed URL expires (`signedUrlExpiresAt`), so never cache it in a page
|
|
2184
|
+
* that outlives that time.
|
|
2185
|
+
*/
|
|
2186
|
+
declare function getMediaUrl(media: Pick<MediaValue, 'url' | 'signedUrl'> | null | undefined): string | null;
|
|
2187
|
+
|
|
2188
|
+
/** True when `value` is a string carrying at least one marker. */
|
|
2189
|
+
declare function hasStega(value: unknown): boolean;
|
|
2190
|
+
/**
|
|
2191
|
+
* `value` with every stega marker removed: a string is cleaned, an array or a
|
|
2192
|
+
* plain object is cleaned deeply (into new objects), anything else is
|
|
2193
|
+
* returned as is. Use it where a preview value is compared, parsed or put in
|
|
2194
|
+
* an attribute, a URL or `<head>`; outside preview it changes nothing.
|
|
2195
|
+
*/
|
|
2196
|
+
declare function cleanStega<T>(value: T): T;
|
|
2197
|
+
|
|
2198
|
+
/**
|
|
2199
|
+
* Outbound webhooks, as the Eel suite sends them (ADR 031): a workspace
|
|
2200
|
+
* endpoint subscribes to `zap.*` events, and every delivery is a JSON envelope
|
|
2201
|
+
* signed with the endpoint's `whsec_…` secret. See `verifyWebhookSignature`.
|
|
2202
|
+
*
|
|
2203
|
+
* Payloads are minimal by design: ids, keys, slugs, links, version numbers and
|
|
2204
|
+
* the NAMES of what changed — never a field value. Read the content itself
|
|
2205
|
+
* with the delivery API.
|
|
2206
|
+
*/
|
|
2207
|
+
/** Every Zap event an endpoint can receive, plus `ping` (the test button). */
|
|
2208
|
+
type WebhookEventName = 'ping' | 'zap.item.created' | 'zap.item.updated' | 'zap.item.draft_updated' | 'zap.item.published' | 'zap.item.unpublished' | 'zap.item.deleted' | 'zap.item.rolled_back' | 'zap.item.assigned' | 'zap.document.created' | 'zap.document.updated' | 'zap.document.draft_updated' | 'zap.document.published' | 'zap.document.unpublished' | 'zap.document.deleted' | 'zap.document.rolled_back' | 'zap.document.assigned' | 'zap.seo.updated' | 'zap.comment.created' | 'zap.comment.replied' | 'zap.comment.resolved' | 'zap.comment.reopened' | 'zap.comment.updated' | 'zap.media.uploaded' | 'zap.media.updated' | 'zap.media.published' | 'zap.media.unpublished' | 'zap.media.deleted' | 'zap.collection.created' | 'zap.collection.updated' | 'zap.collection.deleted' | 'zap.schema.field_changed' | 'zap.site.created' | 'zap.site.updated' | 'zap.site.deleted' | 'zap.site.api_key.created' | 'zap.site.api_key.revoked';
|
|
2209
|
+
/** Who made the change. `user_id` is null for an API key or system work. */
|
|
2210
|
+
interface WebhookActor {
|
|
2211
|
+
user_id: string | null;
|
|
2212
|
+
display_name: string;
|
|
2213
|
+
kind: 'USER' | 'SYSTEM' | 'API_KEY';
|
|
2214
|
+
}
|
|
2215
|
+
/** What the event is about, at the id level. Zap events carry `site_id`, and `collection_id` for collection-scoped events. */
|
|
2216
|
+
interface WebhookSubject {
|
|
2217
|
+
workspace_id: string;
|
|
2218
|
+
site_id?: string;
|
|
2219
|
+
collection_id?: string;
|
|
2220
|
+
}
|
|
2221
|
+
/**
|
|
2222
|
+
* The delivery body. `id` is the idempotency key: it is the same across
|
|
2223
|
+
* retries and across endpoints, so dedupe on it (not on `X-Eel-Delivery`).
|
|
2224
|
+
* `type` is a {@link WebhookEventName}; it is typed as a string too because an
|
|
2225
|
+
* endpoint can also subscribe to other suite apps' events.
|
|
2226
|
+
*/
|
|
2227
|
+
interface WebhookPayload<TData = unknown> {
|
|
2228
|
+
id: string;
|
|
2229
|
+
type: WebhookEventName | (string & {});
|
|
2230
|
+
/** Payload contract version. 2 today. */
|
|
2231
|
+
version: number;
|
|
2232
|
+
app: string;
|
|
2233
|
+
workspace_id: string;
|
|
2234
|
+
/** ISO timestamp of the change. */
|
|
2235
|
+
occurred_at: string;
|
|
2236
|
+
actor: WebhookActor;
|
|
2237
|
+
subject: WebhookSubject;
|
|
2238
|
+
data: TData;
|
|
2239
|
+
}
|
|
2240
|
+
/** A link into Zap. Null when it cannot be built. */
|
|
2241
|
+
type ZapLink = string | null;
|
|
2242
|
+
interface WebhookSiteRef {
|
|
2243
|
+
id: string;
|
|
2244
|
+
key: string;
|
|
2245
|
+
url: ZapLink;
|
|
2246
|
+
}
|
|
2247
|
+
interface WebhookCollectionRef {
|
|
2248
|
+
id: string;
|
|
2249
|
+
key: string;
|
|
2250
|
+
}
|
|
2251
|
+
/** `data` of the `zap.item.*` content events (not `zap.item.assigned`). */
|
|
2252
|
+
interface WebhookItemEventData {
|
|
2253
|
+
site: WebhookSiteRef;
|
|
2254
|
+
collection: WebhookCollectionRef;
|
|
2255
|
+
items: Array<{
|
|
2256
|
+
id: string;
|
|
2257
|
+
slug: string;
|
|
2258
|
+
url: ZapLink;
|
|
2259
|
+
/** The version the event is about; null after a discarded draft. */
|
|
2260
|
+
version?: number | null;
|
|
2261
|
+
/** Names of the fields or properties that changed. */
|
|
2262
|
+
changed?: string[];
|
|
2263
|
+
/** On a rollback: the version number that was restored. */
|
|
2264
|
+
restored_from?: number | null;
|
|
2265
|
+
}>;
|
|
2266
|
+
}
|
|
2267
|
+
/** `data` of the `zap.document.*` content events (not `zap.document.assigned`). */
|
|
2268
|
+
interface WebhookDocumentEventData {
|
|
2269
|
+
site: WebhookSiteRef;
|
|
2270
|
+
documents: Array<{
|
|
2271
|
+
id: string;
|
|
2272
|
+
key: string;
|
|
2273
|
+
url: ZapLink;
|
|
2274
|
+
version?: number | null;
|
|
2275
|
+
changed?: string[];
|
|
2276
|
+
restored_from?: number | null;
|
|
2277
|
+
}>;
|
|
2278
|
+
}
|
|
2279
|
+
/** `data` of the `zap.media.*` events. */
|
|
2280
|
+
interface WebhookMediaEventData {
|
|
2281
|
+
site: WebhookSiteRef;
|
|
2282
|
+
media: Array<{
|
|
2283
|
+
id: string;
|
|
2284
|
+
url: ZapLink;
|
|
2285
|
+
filename?: string;
|
|
2286
|
+
}>;
|
|
2287
|
+
}
|
|
2288
|
+
/** The kind of content a {@link WebhookChange} is about. */
|
|
2289
|
+
type WebhookEventType = 'item' | 'document' | 'media';
|
|
2290
|
+
/** What happened to it: the verb of the event name. */
|
|
2291
|
+
type WebhookAction = 'created' | 'updated' | 'draft_updated' | 'published' | 'unpublished' | 'deleted' | 'rolled_back' | 'uploaded';
|
|
2292
|
+
/**
|
|
2293
|
+
* One changed item, document or file, flattened out of a payload by
|
|
2294
|
+
* `webhookChanges` — the unit a site invalidates its cache by.
|
|
2295
|
+
*/
|
|
2296
|
+
interface WebhookChange {
|
|
2297
|
+
type: WebhookEventType;
|
|
2298
|
+
action: WebhookAction;
|
|
2299
|
+
id: string;
|
|
2300
|
+
/** The item's slug, the document's key, or the file's id. */
|
|
2301
|
+
resourceKey: string;
|
|
2302
|
+
/** The item's collection. Items only. */
|
|
2303
|
+
collectionKey?: string;
|
|
2304
|
+
siteKey: string;
|
|
2305
|
+
}
|
|
2306
|
+
/** A comment thread's record: the entry (`slug`) or the document (`key`) it is on. */
|
|
2307
|
+
interface WebhookCommentTarget {
|
|
2308
|
+
type: 'item' | 'document';
|
|
2309
|
+
id: string;
|
|
2310
|
+
key: string;
|
|
2311
|
+
}
|
|
2312
|
+
/** The fields every comment entry carries. Never the comment text. */
|
|
2313
|
+
interface WebhookCommentRef {
|
|
2314
|
+
id: string;
|
|
2315
|
+
/** The record page, opened on the thread. */
|
|
2316
|
+
url: string;
|
|
2317
|
+
target: WebhookCommentTarget;
|
|
2318
|
+
}
|
|
2319
|
+
/** The `data` of every `zap.comment.*` event: one envelope per (event, site, collection). */
|
|
2320
|
+
interface WebhookCommentData<TEntry extends WebhookCommentRef = WebhookCommentRef> {
|
|
2321
|
+
site: {
|
|
2322
|
+
id: string;
|
|
2323
|
+
key: string;
|
|
2324
|
+
url: string;
|
|
2325
|
+
};
|
|
2326
|
+
/** Null for events on documents. */
|
|
2327
|
+
collection: {
|
|
2328
|
+
id: string;
|
|
2329
|
+
key: string;
|
|
2330
|
+
} | null;
|
|
2331
|
+
comments: TEntry[];
|
|
2332
|
+
}
|
|
2333
|
+
type WebhookCommentSource = 'EDITOR' | 'PREVIEW' | 'SITE' | 'API' | 'MCP';
|
|
2334
|
+
/** `data` of `zap.comment.created`. */
|
|
2335
|
+
type WebhookCommentCreatedData = WebhookCommentData<WebhookCommentRef & {
|
|
2336
|
+
is_change_request: boolean;
|
|
2337
|
+
source: WebhookCommentSource;
|
|
2338
|
+
anchor_kinds: ('field' | 'dom' | 'spot')[];
|
|
2339
|
+
/** Field keys, never values. */
|
|
2340
|
+
field_keys: string[];
|
|
2341
|
+
}>;
|
|
2342
|
+
/** `data` of `zap.comment.replied`. */
|
|
2343
|
+
type WebhookCommentRepliedData = WebhookCommentData<WebhookCommentRef & {
|
|
2344
|
+
comment_id: string;
|
|
2345
|
+
}>;
|
|
2346
|
+
/** `data` of `zap.comment.resolved`. */
|
|
2347
|
+
type WebhookCommentResolvedData = WebhookCommentData<WebhookCommentRef & {
|
|
2348
|
+
is_change_request: boolean;
|
|
2349
|
+
resolution: 'APPLIED' | 'DISMISSED' | null;
|
|
2350
|
+
resolved_in_version_id: string | null;
|
|
2351
|
+
}>;
|
|
2352
|
+
/** `data` of `zap.comment.reopened`. */
|
|
2353
|
+
type WebhookCommentReopenedData = WebhookCommentData<WebhookCommentRef & {
|
|
2354
|
+
cause: 'manual' | 'draft_discarded';
|
|
2355
|
+
resolved_in_version_id: string | null;
|
|
2356
|
+
}>;
|
|
2357
|
+
/** `data` of `zap.comment.updated`. */
|
|
2358
|
+
type WebhookCommentUpdatedData = WebhookCommentData<WebhookCommentRef & {
|
|
2359
|
+
changed: ('assignee' | 'is_change_request' | 'resolution')[];
|
|
2360
|
+
is_change_request: boolean;
|
|
2361
|
+
assignee_id: string | null;
|
|
2362
|
+
}>;
|
|
2363
|
+
|
|
2364
|
+
/** Header carrying `v1=<hex>`. Header lookups are case-insensitive. */
|
|
2365
|
+
declare const WEBHOOK_SIGNATURE_HEADER = "X-Eel-Signature";
|
|
2366
|
+
/** Header carrying the unix-second timestamp that is part of the signed content. */
|
|
2367
|
+
declare const WEBHOOK_TIMESTAMP_HEADER = "X-Eel-Timestamp";
|
|
2368
|
+
/** Deliveries older or newer than this, in seconds, are refused: 5 minutes. */
|
|
2369
|
+
declare const WEBHOOK_TOLERANCE_SECONDS = 300;
|
|
2370
|
+
/**
|
|
2371
|
+
* The request headers: a Fetch `Headers` (Next.js route handlers, workers), or
|
|
2372
|
+
* a plain object such as Node's `IncomingHttpHeaders` (Express).
|
|
2373
|
+
*/
|
|
2374
|
+
type WebhookHeaders = Pick<Headers, 'get'> | Record<string, string | readonly string[] | undefined>;
|
|
2375
|
+
interface VerifyWebhookOptions {
|
|
2376
|
+
/** Maximum clock difference in seconds. Default {@link WEBHOOK_TOLERANCE_SECONDS}. */
|
|
2377
|
+
toleranceSeconds?: number;
|
|
2378
|
+
/** The current time. Default `new Date()`. */
|
|
2379
|
+
now?: Date;
|
|
2380
|
+
}
|
|
2381
|
+
/**
|
|
2382
|
+
* Verifies a webhook delivery: the signature over the raw body and the
|
|
2383
|
+
* timestamp, and that the timestamp is within the tolerance window.
|
|
2384
|
+
*
|
|
2385
|
+
* Pass the body exactly as received (`await request.text()`), never a
|
|
2386
|
+
* re-serialised parse: the MAC covers the bytes that were sent.
|
|
2387
|
+
*
|
|
2388
|
+
* @returns `true` only for an authentic, fresh delivery. Any missing or
|
|
2389
|
+
* malformed header, wrong secret, altered body or stale timestamp is `false`.
|
|
2390
|
+
* @throws When the runtime has no WebCrypto.
|
|
2391
|
+
*
|
|
2392
|
+
* @example
|
|
2393
|
+
* ```ts
|
|
2394
|
+
* const payload = await request.text()
|
|
2395
|
+
* if (!(await verifyWebhookSignature(payload, request.headers, process.env.EELZAP_WEBHOOK_SECRET!))) {
|
|
2396
|
+
* return new Response('Invalid signature', { status: 401 })
|
|
2397
|
+
* }
|
|
2398
|
+
* ```
|
|
2399
|
+
*/
|
|
2400
|
+
declare function verifyWebhookSignature(payload: string, headers: WebhookHeaders, secret: string, options?: VerifyWebhookOptions): Promise<boolean>;
|
|
2401
|
+
/**
|
|
2402
|
+
* Flattens a Zap content event into one {@link WebhookChange} per item,
|
|
2403
|
+
* document or file it names — what a site walks to invalidate its cache.
|
|
2404
|
+
* Every other event (`ping`, schema, site, SEO, assignment, comment
|
|
2405
|
+
* events) yields an empty list.
|
|
2406
|
+
*/
|
|
2407
|
+
declare function webhookChanges(payload: WebhookPayload): WebhookChange[];
|
|
2408
|
+
|
|
2409
|
+
export { type ApiErrorDetail, type ApiErrorPayload, type CacheAdapter, type CacheStrategy, type CachedFetchOptions, type ClientConfig, type ClientDefaults, type CollectionDetail, type CollectionFieldListResponse, CollectionFieldsResource, type CollectionListResponse, type CollectionSectionListResponse, CollectionSectionsResource, type CollectionSummary, CollectionsResource, type CommentAnchor, type CommentAnchorInput, type CommentAnchorKind, type CommentDomAnchor, type CommentDraftAnswer, type CommentFieldAnchorInput, type CommentListOptions, type CommentListResponse, type CommentPersonRef, type CommentProposedValue, type CommentProposedValueInput, type CommentRecord, type CommentRect, type CommentReplyAnswer, type CommentResolution, type CommentSource, type CommentSpotAnchor, type CommentStatus, type CommentTarget, type CommentThread, type CommentThreadAnswer, type CommentVersionRef, type CommentViewport, CommentsResource, type CommonRequestOptions, type ConfirmUploadInput, type CreateCollectionInput, type CreateCommentInput, type CreateDocumentFieldInput, type CreateDocumentInput, type CreateDraftInput, type CreateFieldInput, type CreateItemInput, type CreateSectionInput, type CreateUploadUrlInput, type CurrencyValue, type DeleteDocumentOptions, type DeleteItemOptions, type DeleteOptions, type DeliveryStatus, type DocumentDeleteResponse, type DocumentDetail, type DocumentFieldListResponse, DocumentFieldsResource, type DocumentGetOptions, type DocumentListEntry, type DocumentListOptions, type DocumentListResponse, type DocumentMeta, type DocumentMutationResponse, type DocumentSectionListResponse, DocumentSectionsResource, type DocumentSeo, DocumentSeoResource, type DocumentSeoResponse, DocumentValuesResource, type DocumentValuesResponse, type DocumentVersionDetail, type DocumentVersionSeo, type DocumentVersionSummary, type DocumentVersionValue, DocumentVersionsResource, DocumentsResource, EelZapClient, EelZapError, type EelZapErrorCode, EelZapNetworkError, type EnumValue, type FieldConstraints, type FieldInfo, type FieldOptionInput, type FieldType, type FilterOperatorMap, type FilterValue, type GalleryItemValue, type IdempotencyOptions, type ItemDeleteResponse, type ItemDetail, type ItemFilters, type ItemGetOptions, type ItemListOptions, type ItemListResponse, type ItemMeta, type ItemMutationResponse, ItemQueryBuilder, type ItemSeo, ItemSeoResource, type ItemSeoResponse, type ItemVersionDetail, type ItemVersionSeo, type ItemVersionSlug, type ItemVersionSummary, type ItemVersionValue, ItemVersionsResource, ItemsResource, type JsonObject, type MediaAccess, type MediaDetail, type MediaDetailResponse, type MediaFromUrlInput, type MediaListParams, type MediaListResponse, MediaResource, type MediaSort, type MediaType, type MediaUploadInput, type MediaUsage, type MediaValue, MemoryCacheAdapter, type OnPageComment, type OnPageCommentAnchor, type OnPageComments, type OnPageField, type Pagination, type PreviewOption, type PreviewTokenValidation, PreviewTokensResource, type QueryPrimitive, type ReplyCommentInput, type RetryEvent, type RetryOptions, type SaveCommentToDraftInput, type SectionInfo, type SectionMeta, type Seo, type SeoImage, type SeoInput, type SiteInfo, type SiteListEntry, SiteResource, SitesResource, type ThreadComment, type UpdateCollectionInput, type UpdateCommentInput, type UpdateDocumentDraftInput, type UpdateDocumentFieldInput, type UpdateDocumentInput, type UpdateFieldInput, type UpdateItemDraftInput, type UpdateItemInput, type UpdateMediaInput, type UpdateSectionInput, type UpdateSiteInput, type UploadFile, type UploadUrlResponse, type VerifyWebhookOptions, type VersionDetail, type VersionGalleryItem, type VersionListResponse, type VersionSeo, type VersionStatus, type VersionSummary, type VersionValue, WEBHOOK_SIGNATURE_HEADER, WEBHOOK_TIMESTAMP_HEADER, WEBHOOK_TOLERANCE_SECONDS, type WebhookAction, type WebhookActor, type WebhookChange, type WebhookCollectionRef, type WebhookCommentCreatedData, type WebhookCommentData, type WebhookCommentRef, type WebhookCommentReopenedData, type WebhookCommentRepliedData, type WebhookCommentResolvedData, type WebhookCommentSource, type WebhookCommentTarget, type WebhookCommentUpdatedData, type WebhookDocumentEventData, type WebhookEventName, type WebhookEventType, type WebhookHeaders, type WebhookItemEventData, type WebhookMediaEventData, type WebhookPayload, type WebhookSiteRef, type WebhookSubject, cachedFetch, cleanStega, createClient, getMediaUrl, hasStega, isEelZapError, verifyWebhookSignature, webhookChanges };
|