kirby-types 1.0.0 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +259 -40
- package/index.d.ts +18 -1
- package/package.json +37 -8
- package/src/api.d.ts +40 -0
- package/src/blocks.d.ts +254 -16
- package/src/kql.d.ts +127 -1
- package/src/layout.d.ts +96 -29
- package/src/panel/api.d.ts +1003 -0
- package/src/panel/base.d.ts +789 -0
- package/src/panel/features.d.ts +1543 -0
- package/src/panel/helpers.d.ts +1030 -0
- package/src/panel/index.d.ts +1008 -0
- package/src/panel/libraries.d.ts +456 -0
- package/src/panel/writer.d.ts +280 -0
- package/src/query.d.ts +4 -4
|
@@ -0,0 +1,1003 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* API type definitions for Kirby Panel.
|
|
3
|
+
*
|
|
4
|
+
* Provides types for the Panel API client and its resource modules.
|
|
5
|
+
*
|
|
6
|
+
* @see https://github.com/getkirby/kirby/tree/main/panel/src/api
|
|
7
|
+
* @since 4.0.0
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import type { PanelRequestOptions } from "./base";
|
|
11
|
+
|
|
12
|
+
// -----------------------------------------------------------------------------
|
|
13
|
+
// Request Types
|
|
14
|
+
// -----------------------------------------------------------------------------
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* API request options.
|
|
18
|
+
*/
|
|
19
|
+
export interface PanelApiRequestOptions extends PanelRequestOptions {
|
|
20
|
+
/** Whether to skip loading indicator */
|
|
21
|
+
silent?: boolean;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Pagination query parameters.
|
|
26
|
+
*/
|
|
27
|
+
export interface PanelApiPagination {
|
|
28
|
+
/** Page number */
|
|
29
|
+
page?: number;
|
|
30
|
+
/** Items per page */
|
|
31
|
+
limit?: number;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Search query parameters.
|
|
36
|
+
*/
|
|
37
|
+
export interface PanelApiSearchQuery extends PanelApiPagination {
|
|
38
|
+
/** Search query string */
|
|
39
|
+
query?: string;
|
|
40
|
+
/** Field selection */
|
|
41
|
+
select?: string;
|
|
42
|
+
/** Sort field and direction */
|
|
43
|
+
sort?: string;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// -----------------------------------------------------------------------------
|
|
47
|
+
// Auth API
|
|
48
|
+
// -----------------------------------------------------------------------------
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* User authentication data.
|
|
52
|
+
*/
|
|
53
|
+
export interface PanelApiLoginData {
|
|
54
|
+
/** User email */
|
|
55
|
+
email: string;
|
|
56
|
+
/** User password */
|
|
57
|
+
password: string;
|
|
58
|
+
/** Remember login */
|
|
59
|
+
remember?: boolean;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Authentication API methods.
|
|
64
|
+
*
|
|
65
|
+
* @see https://github.com/getkirby/kirby/blob/main/panel/src/api/auth.js
|
|
66
|
+
*/
|
|
67
|
+
export interface PanelApiAuth {
|
|
68
|
+
/**
|
|
69
|
+
* Logs in a user.
|
|
70
|
+
*
|
|
71
|
+
* @param data - Login credentials
|
|
72
|
+
* @returns User data
|
|
73
|
+
*/
|
|
74
|
+
login: (data: PanelApiLoginData) => Promise<unknown>;
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Logs out the current user.
|
|
78
|
+
*/
|
|
79
|
+
logout: () => Promise<void>;
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Pings the server to keep session alive.
|
|
83
|
+
*/
|
|
84
|
+
ping: () => Promise<void>;
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Gets the current user.
|
|
88
|
+
*
|
|
89
|
+
* @param query - Query parameters
|
|
90
|
+
* @param options - Request options
|
|
91
|
+
* @returns User data
|
|
92
|
+
*/
|
|
93
|
+
user: (
|
|
94
|
+
query?: Record<string, unknown>,
|
|
95
|
+
options?: PanelApiRequestOptions,
|
|
96
|
+
) => Promise<unknown>;
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Verifies a 2FA code.
|
|
100
|
+
*
|
|
101
|
+
* @param code - Verification code
|
|
102
|
+
* @param data - Additional data
|
|
103
|
+
* @returns Verification result
|
|
104
|
+
*/
|
|
105
|
+
verifyCode: (
|
|
106
|
+
code: string,
|
|
107
|
+
data?: Record<string, unknown>,
|
|
108
|
+
) => Promise<unknown>;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
// -----------------------------------------------------------------------------
|
|
112
|
+
// Files API
|
|
113
|
+
// -----------------------------------------------------------------------------
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* Files API methods.
|
|
117
|
+
*
|
|
118
|
+
* @see https://github.com/getkirby/kirby/blob/main/panel/src/api/files.js
|
|
119
|
+
*/
|
|
120
|
+
export interface PanelApiFiles {
|
|
121
|
+
/**
|
|
122
|
+
* Changes a file's name.
|
|
123
|
+
*
|
|
124
|
+
* @param parent - Parent page/site path
|
|
125
|
+
* @param filename - Current filename
|
|
126
|
+
* @param to - New name (without extension)
|
|
127
|
+
* @returns Updated file data
|
|
128
|
+
*/
|
|
129
|
+
changeName: (
|
|
130
|
+
parent: string | null,
|
|
131
|
+
filename: string,
|
|
132
|
+
to: string,
|
|
133
|
+
) => Promise<unknown>;
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* Deletes a file.
|
|
137
|
+
*
|
|
138
|
+
* @param parent - Parent page/site path
|
|
139
|
+
* @param filename - Filename to delete
|
|
140
|
+
*/
|
|
141
|
+
delete: (parent: string | null, filename: string) => Promise<void>;
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* Gets a file.
|
|
145
|
+
*
|
|
146
|
+
* @param parent - Parent page/site path
|
|
147
|
+
* @param filename - Filename
|
|
148
|
+
* @param query - Query parameters
|
|
149
|
+
* @returns File data
|
|
150
|
+
*/
|
|
151
|
+
get: (
|
|
152
|
+
parent: string | null,
|
|
153
|
+
filename: string,
|
|
154
|
+
query?: Record<string, unknown>,
|
|
155
|
+
) => Promise<unknown>;
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* Converts file ID/UUID to API format.
|
|
159
|
+
*
|
|
160
|
+
* @param id - File ID or UUID
|
|
161
|
+
* @returns API-formatted ID
|
|
162
|
+
*/
|
|
163
|
+
id: (id: string) => string;
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* Gets Panel link for a file.
|
|
167
|
+
*
|
|
168
|
+
* @param parent - Parent path
|
|
169
|
+
* @param filename - Filename
|
|
170
|
+
* @param path - Additional path
|
|
171
|
+
* @returns Panel link
|
|
172
|
+
*/
|
|
173
|
+
link: (parent: string | null, filename: string, path?: string) => string;
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* Updates a file's content.
|
|
177
|
+
*
|
|
178
|
+
* @param parent - Parent path
|
|
179
|
+
* @param filename - Filename
|
|
180
|
+
* @param data - Content data
|
|
181
|
+
* @returns Updated file data
|
|
182
|
+
*/
|
|
183
|
+
update: (
|
|
184
|
+
parent: string | null,
|
|
185
|
+
filename: string,
|
|
186
|
+
data: Record<string, unknown>,
|
|
187
|
+
) => Promise<unknown>;
|
|
188
|
+
|
|
189
|
+
/**
|
|
190
|
+
* Gets API URL for a file.
|
|
191
|
+
*
|
|
192
|
+
* @param parent - Parent path
|
|
193
|
+
* @param filename - Filename
|
|
194
|
+
* @param path - Additional path
|
|
195
|
+
* @returns API URL
|
|
196
|
+
*/
|
|
197
|
+
url: (parent: string | null, filename: string, path?: string) => string;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
// -----------------------------------------------------------------------------
|
|
201
|
+
// Languages API
|
|
202
|
+
// -----------------------------------------------------------------------------
|
|
203
|
+
|
|
204
|
+
/**
|
|
205
|
+
* Language data for create/update.
|
|
206
|
+
*/
|
|
207
|
+
export interface PanelApiLanguageData {
|
|
208
|
+
/** Language code */
|
|
209
|
+
code: string;
|
|
210
|
+
/** Language name */
|
|
211
|
+
name?: string;
|
|
212
|
+
/** Text direction */
|
|
213
|
+
direction?: "ltr" | "rtl";
|
|
214
|
+
/** Whether default language */
|
|
215
|
+
default?: boolean;
|
|
216
|
+
/** Locale code */
|
|
217
|
+
locale?: string;
|
|
218
|
+
/** Slug conversion rules */
|
|
219
|
+
rules?: Record<string, string>;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
/**
|
|
223
|
+
* Languages API methods.
|
|
224
|
+
*
|
|
225
|
+
* @see https://github.com/getkirby/kirby/blob/main/panel/src/api/languages.js
|
|
226
|
+
*/
|
|
227
|
+
export interface PanelApiLanguages {
|
|
228
|
+
/**
|
|
229
|
+
* Creates a new language.
|
|
230
|
+
*
|
|
231
|
+
* @param code - Language code
|
|
232
|
+
* @param data - Language data
|
|
233
|
+
* @returns Created language
|
|
234
|
+
*/
|
|
235
|
+
create: (code: string, data: PanelApiLanguageData) => Promise<unknown>;
|
|
236
|
+
|
|
237
|
+
/**
|
|
238
|
+
* Deletes a language.
|
|
239
|
+
*
|
|
240
|
+
* @param code - Language code
|
|
241
|
+
*/
|
|
242
|
+
delete: (code: string) => Promise<void>;
|
|
243
|
+
|
|
244
|
+
/**
|
|
245
|
+
* Gets a language.
|
|
246
|
+
*
|
|
247
|
+
* @param code - Language code
|
|
248
|
+
* @returns Language data
|
|
249
|
+
*/
|
|
250
|
+
get: (code: string) => Promise<unknown>;
|
|
251
|
+
|
|
252
|
+
/**
|
|
253
|
+
* Lists all languages.
|
|
254
|
+
*
|
|
255
|
+
* @returns Array of languages
|
|
256
|
+
*/
|
|
257
|
+
list: () => Promise<unknown[]>;
|
|
258
|
+
|
|
259
|
+
/**
|
|
260
|
+
* Updates a language.
|
|
261
|
+
*
|
|
262
|
+
* @param code - Language code
|
|
263
|
+
* @param data - Updated data
|
|
264
|
+
* @returns Updated language
|
|
265
|
+
*/
|
|
266
|
+
update: (
|
|
267
|
+
code: string,
|
|
268
|
+
data: Partial<PanelApiLanguageData>,
|
|
269
|
+
) => Promise<unknown>;
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
// -----------------------------------------------------------------------------
|
|
273
|
+
// Pages API
|
|
274
|
+
// -----------------------------------------------------------------------------
|
|
275
|
+
|
|
276
|
+
/**
|
|
277
|
+
* Page creation data.
|
|
278
|
+
*/
|
|
279
|
+
export interface PanelApiPageCreateData {
|
|
280
|
+
/** Page slug */
|
|
281
|
+
slug: string;
|
|
282
|
+
/** Page title */
|
|
283
|
+
title?: string;
|
|
284
|
+
/** Page template */
|
|
285
|
+
template?: string;
|
|
286
|
+
/** Initial content */
|
|
287
|
+
content?: Record<string, unknown>;
|
|
288
|
+
/** Initial status */
|
|
289
|
+
status?: "draft" | "unlisted" | "listed";
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
/**
|
|
293
|
+
* Page duplicate options.
|
|
294
|
+
*/
|
|
295
|
+
export interface PanelApiPageDuplicateOptions {
|
|
296
|
+
/** Copy children pages */
|
|
297
|
+
children?: boolean;
|
|
298
|
+
/** Copy files */
|
|
299
|
+
files?: boolean;
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
/**
|
|
303
|
+
* Pages API methods.
|
|
304
|
+
*
|
|
305
|
+
* @see https://github.com/getkirby/kirby/blob/main/panel/src/api/pages.js
|
|
306
|
+
*/
|
|
307
|
+
export interface PanelApiPages {
|
|
308
|
+
/**
|
|
309
|
+
* Gets a page's blueprint.
|
|
310
|
+
*
|
|
311
|
+
* @param parent - Page ID
|
|
312
|
+
* @returns Blueprint data
|
|
313
|
+
*/
|
|
314
|
+
blueprint: (parent: string) => Promise<unknown>;
|
|
315
|
+
|
|
316
|
+
/**
|
|
317
|
+
* Gets available blueprints for a page.
|
|
318
|
+
*
|
|
319
|
+
* @param parent - Page ID
|
|
320
|
+
* @param section - Section name
|
|
321
|
+
* @returns Array of blueprints
|
|
322
|
+
*/
|
|
323
|
+
blueprints: (parent: string, section?: string) => Promise<unknown[]>;
|
|
324
|
+
|
|
325
|
+
/**
|
|
326
|
+
* Changes a page's slug.
|
|
327
|
+
*
|
|
328
|
+
* @param id - Page ID
|
|
329
|
+
* @param slug - New slug
|
|
330
|
+
* @returns Updated page
|
|
331
|
+
*/
|
|
332
|
+
changeSlug: (id: string, slug: string) => Promise<unknown>;
|
|
333
|
+
|
|
334
|
+
/**
|
|
335
|
+
* Changes a page's status.
|
|
336
|
+
*
|
|
337
|
+
* @param id - Page ID
|
|
338
|
+
* @param status - New status
|
|
339
|
+
* @param position - Sort position (for listed)
|
|
340
|
+
* @returns Updated page
|
|
341
|
+
*/
|
|
342
|
+
changeStatus: (
|
|
343
|
+
id: string,
|
|
344
|
+
status: "draft" | "unlisted" | "listed",
|
|
345
|
+
position?: number,
|
|
346
|
+
) => Promise<unknown>;
|
|
347
|
+
|
|
348
|
+
/**
|
|
349
|
+
* Changes a page's template.
|
|
350
|
+
*
|
|
351
|
+
* @param id - Page ID
|
|
352
|
+
* @param template - New template
|
|
353
|
+
* @returns Updated page
|
|
354
|
+
*/
|
|
355
|
+
changeTemplate: (id: string, template: string) => Promise<unknown>;
|
|
356
|
+
|
|
357
|
+
/**
|
|
358
|
+
* Changes a page's title.
|
|
359
|
+
*
|
|
360
|
+
* @param id - Page ID
|
|
361
|
+
* @param title - New title
|
|
362
|
+
* @returns Updated page
|
|
363
|
+
*/
|
|
364
|
+
changeTitle: (id: string, title: string) => Promise<unknown>;
|
|
365
|
+
|
|
366
|
+
/**
|
|
367
|
+
* Searches children pages.
|
|
368
|
+
*
|
|
369
|
+
* @param id - Parent page ID
|
|
370
|
+
* @param query - Search query
|
|
371
|
+
* @returns Search results
|
|
372
|
+
*/
|
|
373
|
+
children: (id: string, query?: PanelApiSearchQuery) => Promise<unknown>;
|
|
374
|
+
|
|
375
|
+
/**
|
|
376
|
+
* Creates a new page.
|
|
377
|
+
*
|
|
378
|
+
* @param parent - Parent page ID (null for root)
|
|
379
|
+
* @param data - Page data
|
|
380
|
+
* @returns Created page
|
|
381
|
+
*/
|
|
382
|
+
create: (
|
|
383
|
+
parent: string | null,
|
|
384
|
+
data: PanelApiPageCreateData,
|
|
385
|
+
) => Promise<unknown>;
|
|
386
|
+
|
|
387
|
+
/**
|
|
388
|
+
* Deletes a page.
|
|
389
|
+
*
|
|
390
|
+
* @param id - Page ID
|
|
391
|
+
* @param data - Delete options
|
|
392
|
+
*/
|
|
393
|
+
delete: (id: string, data?: { force?: boolean }) => Promise<void>;
|
|
394
|
+
|
|
395
|
+
/**
|
|
396
|
+
* Duplicates a page.
|
|
397
|
+
*
|
|
398
|
+
* @param id - Page ID
|
|
399
|
+
* @param slug - New slug
|
|
400
|
+
* @param options - Duplicate options
|
|
401
|
+
* @returns Duplicated page
|
|
402
|
+
*/
|
|
403
|
+
duplicate: (
|
|
404
|
+
id: string,
|
|
405
|
+
slug: string,
|
|
406
|
+
options?: PanelApiPageDuplicateOptions,
|
|
407
|
+
) => Promise<unknown>;
|
|
408
|
+
|
|
409
|
+
/**
|
|
410
|
+
* Gets a page.
|
|
411
|
+
*
|
|
412
|
+
* @param id - Page ID
|
|
413
|
+
* @param query - Query parameters
|
|
414
|
+
* @returns Page data
|
|
415
|
+
*/
|
|
416
|
+
get: (id: string, query?: Record<string, unknown>) => Promise<unknown>;
|
|
417
|
+
|
|
418
|
+
/**
|
|
419
|
+
* Converts page ID/UUID to API format.
|
|
420
|
+
*
|
|
421
|
+
* @param id - Page ID or UUID
|
|
422
|
+
* @returns API-formatted ID
|
|
423
|
+
*/
|
|
424
|
+
id: (id: string) => string;
|
|
425
|
+
|
|
426
|
+
/**
|
|
427
|
+
* Searches files in a page.
|
|
428
|
+
*
|
|
429
|
+
* @param id - Page ID
|
|
430
|
+
* @param query - Search query
|
|
431
|
+
* @returns Search results
|
|
432
|
+
*/
|
|
433
|
+
files: (id: string, query?: PanelApiSearchQuery) => Promise<unknown>;
|
|
434
|
+
|
|
435
|
+
/**
|
|
436
|
+
* Gets Panel link for a page.
|
|
437
|
+
*
|
|
438
|
+
* @param id - Page ID
|
|
439
|
+
* @returns Panel link
|
|
440
|
+
*/
|
|
441
|
+
link: (id: string) => string;
|
|
442
|
+
|
|
443
|
+
/**
|
|
444
|
+
* Gets a page's preview URL.
|
|
445
|
+
*
|
|
446
|
+
* @param id - Page ID
|
|
447
|
+
* @returns Preview URL
|
|
448
|
+
*/
|
|
449
|
+
preview: (id: string) => Promise<string>;
|
|
450
|
+
|
|
451
|
+
/**
|
|
452
|
+
* Searches pages.
|
|
453
|
+
*
|
|
454
|
+
* @param parent - Parent page ID (null for root)
|
|
455
|
+
* @param query - Search query
|
|
456
|
+
* @returns Search results
|
|
457
|
+
*/
|
|
458
|
+
search: (
|
|
459
|
+
parent: string | null,
|
|
460
|
+
query?: PanelApiSearchQuery,
|
|
461
|
+
) => Promise<unknown>;
|
|
462
|
+
|
|
463
|
+
/**
|
|
464
|
+
* Updates a page's content.
|
|
465
|
+
*
|
|
466
|
+
* @param id - Page ID
|
|
467
|
+
* @param data - Content data
|
|
468
|
+
* @returns Updated page
|
|
469
|
+
*/
|
|
470
|
+
update: (id: string, data: Record<string, unknown>) => Promise<unknown>;
|
|
471
|
+
|
|
472
|
+
/**
|
|
473
|
+
* Gets API URL for a page.
|
|
474
|
+
*
|
|
475
|
+
* @param id - Page ID
|
|
476
|
+
* @param path - Additional path
|
|
477
|
+
* @returns API URL
|
|
478
|
+
*/
|
|
479
|
+
url: (id: string | null, path?: string) => string;
|
|
480
|
+
}
|
|
481
|
+
|
|
482
|
+
// -----------------------------------------------------------------------------
|
|
483
|
+
// Roles API
|
|
484
|
+
// -----------------------------------------------------------------------------
|
|
485
|
+
|
|
486
|
+
/**
|
|
487
|
+
* Roles API methods.
|
|
488
|
+
*
|
|
489
|
+
* @see https://github.com/getkirby/kirby/blob/main/panel/src/api/roles.js
|
|
490
|
+
*/
|
|
491
|
+
export interface PanelApiRoles {
|
|
492
|
+
/**
|
|
493
|
+
* Gets a role.
|
|
494
|
+
*
|
|
495
|
+
* @param name - Role name
|
|
496
|
+
* @returns Role data
|
|
497
|
+
*/
|
|
498
|
+
get: (name: string) => Promise<unknown>;
|
|
499
|
+
|
|
500
|
+
/**
|
|
501
|
+
* Lists available roles.
|
|
502
|
+
*
|
|
503
|
+
* @param user - User ID for context
|
|
504
|
+
* @param query - Query parameters
|
|
505
|
+
* @returns Array of roles
|
|
506
|
+
*/
|
|
507
|
+
list: (user?: string, query?: Record<string, unknown>) => Promise<unknown[]>;
|
|
508
|
+
}
|
|
509
|
+
|
|
510
|
+
// -----------------------------------------------------------------------------
|
|
511
|
+
// Site API
|
|
512
|
+
// -----------------------------------------------------------------------------
|
|
513
|
+
|
|
514
|
+
/**
|
|
515
|
+
* Site API methods.
|
|
516
|
+
*
|
|
517
|
+
* @see https://github.com/getkirby/kirby/blob/main/panel/src/api/site.js
|
|
518
|
+
*/
|
|
519
|
+
export interface PanelApiSite {
|
|
520
|
+
/**
|
|
521
|
+
* Gets the site blueprint.
|
|
522
|
+
*
|
|
523
|
+
* @returns Blueprint data
|
|
524
|
+
*/
|
|
525
|
+
blueprint: () => Promise<unknown>;
|
|
526
|
+
|
|
527
|
+
/**
|
|
528
|
+
* Gets available blueprints for the site.
|
|
529
|
+
*
|
|
530
|
+
* @returns Array of blueprints
|
|
531
|
+
*/
|
|
532
|
+
blueprints: () => Promise<unknown[]>;
|
|
533
|
+
|
|
534
|
+
/**
|
|
535
|
+
* Changes the site title.
|
|
536
|
+
*
|
|
537
|
+
* @param title - New title
|
|
538
|
+
* @param language - Language code
|
|
539
|
+
* @returns Updated site
|
|
540
|
+
*/
|
|
541
|
+
changeTitle: (title: string, language?: string) => Promise<unknown>;
|
|
542
|
+
|
|
543
|
+
/**
|
|
544
|
+
* Searches site children.
|
|
545
|
+
*
|
|
546
|
+
* @param query - Search query
|
|
547
|
+
* @param options - Query options
|
|
548
|
+
* @returns Search results
|
|
549
|
+
*/
|
|
550
|
+
children: (
|
|
551
|
+
query?: PanelApiSearchQuery,
|
|
552
|
+
options?: Record<string, unknown>,
|
|
553
|
+
) => Promise<unknown>;
|
|
554
|
+
|
|
555
|
+
/**
|
|
556
|
+
* Gets the site.
|
|
557
|
+
*
|
|
558
|
+
* @param query - Query parameters
|
|
559
|
+
* @returns Site data
|
|
560
|
+
*/
|
|
561
|
+
get: (query?: Record<string, unknown>) => Promise<unknown>;
|
|
562
|
+
|
|
563
|
+
/**
|
|
564
|
+
* Updates the site content.
|
|
565
|
+
*
|
|
566
|
+
* @param data - Content data
|
|
567
|
+
* @param language - Language code
|
|
568
|
+
* @returns Updated site
|
|
569
|
+
*/
|
|
570
|
+
update: (
|
|
571
|
+
data: Record<string, unknown>,
|
|
572
|
+
language?: string,
|
|
573
|
+
) => Promise<unknown>;
|
|
574
|
+
}
|
|
575
|
+
|
|
576
|
+
// -----------------------------------------------------------------------------
|
|
577
|
+
// System API
|
|
578
|
+
// -----------------------------------------------------------------------------
|
|
579
|
+
|
|
580
|
+
/**
|
|
581
|
+
* System installation data.
|
|
582
|
+
*/
|
|
583
|
+
export interface PanelApiSystemInstallData {
|
|
584
|
+
/** Admin email */
|
|
585
|
+
email: string;
|
|
586
|
+
/** Admin password */
|
|
587
|
+
password: string;
|
|
588
|
+
/** Admin language */
|
|
589
|
+
language?: string;
|
|
590
|
+
}
|
|
591
|
+
|
|
592
|
+
/**
|
|
593
|
+
* License registration data.
|
|
594
|
+
*/
|
|
595
|
+
export interface PanelApiSystemRegisterData {
|
|
596
|
+
/** License key */
|
|
597
|
+
license: string;
|
|
598
|
+
/** Licensee email */
|
|
599
|
+
email: string;
|
|
600
|
+
}
|
|
601
|
+
|
|
602
|
+
/**
|
|
603
|
+
* System API methods.
|
|
604
|
+
*
|
|
605
|
+
* @see https://github.com/getkirby/kirby/blob/main/panel/src/api/system.js
|
|
606
|
+
*/
|
|
607
|
+
export interface PanelApiSystem {
|
|
608
|
+
/**
|
|
609
|
+
* Gets system information.
|
|
610
|
+
*
|
|
611
|
+
* @param query - Query parameters
|
|
612
|
+
* @returns System data
|
|
613
|
+
*/
|
|
614
|
+
get: (query?: Record<string, unknown>) => Promise<unknown>;
|
|
615
|
+
|
|
616
|
+
/**
|
|
617
|
+
* Installs Kirby with initial user.
|
|
618
|
+
*
|
|
619
|
+
* @param data - Installation data
|
|
620
|
+
* @param query - Query parameters
|
|
621
|
+
* @returns Installation result
|
|
622
|
+
*/
|
|
623
|
+
install: (
|
|
624
|
+
data: PanelApiSystemInstallData,
|
|
625
|
+
query?: Record<string, unknown>,
|
|
626
|
+
) => Promise<unknown>;
|
|
627
|
+
|
|
628
|
+
/**
|
|
629
|
+
* Registers a license.
|
|
630
|
+
*
|
|
631
|
+
* @param data - Registration data
|
|
632
|
+
* @param query - Query parameters
|
|
633
|
+
* @returns Registration result
|
|
634
|
+
*/
|
|
635
|
+
register: (
|
|
636
|
+
data: PanelApiSystemRegisterData,
|
|
637
|
+
query?: Record<string, unknown>,
|
|
638
|
+
) => Promise<unknown>;
|
|
639
|
+
}
|
|
640
|
+
|
|
641
|
+
// -----------------------------------------------------------------------------
|
|
642
|
+
// Translations API
|
|
643
|
+
// -----------------------------------------------------------------------------
|
|
644
|
+
|
|
645
|
+
/**
|
|
646
|
+
* Translations API methods.
|
|
647
|
+
*
|
|
648
|
+
* @see https://github.com/getkirby/kirby/blob/main/panel/src/api/translations.js
|
|
649
|
+
*/
|
|
650
|
+
export interface PanelApiTranslations {
|
|
651
|
+
/**
|
|
652
|
+
* Gets a translation.
|
|
653
|
+
*
|
|
654
|
+
* @param code - Translation code
|
|
655
|
+
* @returns Translation data
|
|
656
|
+
*/
|
|
657
|
+
get: (code: string) => Promise<unknown>;
|
|
658
|
+
|
|
659
|
+
/**
|
|
660
|
+
* Lists all translations.
|
|
661
|
+
*
|
|
662
|
+
* @returns Array of translations
|
|
663
|
+
*/
|
|
664
|
+
list: () => Promise<unknown[]>;
|
|
665
|
+
}
|
|
666
|
+
|
|
667
|
+
// -----------------------------------------------------------------------------
|
|
668
|
+
// Users API
|
|
669
|
+
// -----------------------------------------------------------------------------
|
|
670
|
+
|
|
671
|
+
/**
|
|
672
|
+
* User creation data.
|
|
673
|
+
*/
|
|
674
|
+
export interface PanelApiUserCreateData {
|
|
675
|
+
/** User email */
|
|
676
|
+
email: string;
|
|
677
|
+
/** User password */
|
|
678
|
+
password?: string;
|
|
679
|
+
/** User name */
|
|
680
|
+
name?: string;
|
|
681
|
+
/** User role */
|
|
682
|
+
role?: string;
|
|
683
|
+
/** User language */
|
|
684
|
+
language?: string;
|
|
685
|
+
}
|
|
686
|
+
|
|
687
|
+
/**
|
|
688
|
+
* Users API methods.
|
|
689
|
+
*
|
|
690
|
+
* @see https://github.com/getkirby/kirby/blob/main/panel/src/api/users.js
|
|
691
|
+
*/
|
|
692
|
+
export interface PanelApiUsers {
|
|
693
|
+
/**
|
|
694
|
+
* Gets a user's blueprint.
|
|
695
|
+
*
|
|
696
|
+
* @param id - User ID
|
|
697
|
+
* @returns Blueprint data
|
|
698
|
+
*/
|
|
699
|
+
blueprint: (id: string) => Promise<unknown>;
|
|
700
|
+
|
|
701
|
+
/**
|
|
702
|
+
* Gets available blueprints for users.
|
|
703
|
+
*
|
|
704
|
+
* @param user - User ID for context
|
|
705
|
+
* @param query - Query parameters
|
|
706
|
+
* @returns Array of blueprints
|
|
707
|
+
*/
|
|
708
|
+
blueprints: (
|
|
709
|
+
user?: string,
|
|
710
|
+
query?: Record<string, unknown>,
|
|
711
|
+
) => Promise<unknown[]>;
|
|
712
|
+
|
|
713
|
+
/**
|
|
714
|
+
* Changes a user's email.
|
|
715
|
+
*
|
|
716
|
+
* @param id - User ID
|
|
717
|
+
* @param email - New email
|
|
718
|
+
* @returns Updated user
|
|
719
|
+
*/
|
|
720
|
+
changeEmail: (id: string, email: string) => Promise<unknown>;
|
|
721
|
+
|
|
722
|
+
/**
|
|
723
|
+
* Changes a user's language.
|
|
724
|
+
*
|
|
725
|
+
* @param id - User ID
|
|
726
|
+
* @param language - New language code
|
|
727
|
+
* @returns Updated user
|
|
728
|
+
*/
|
|
729
|
+
changeLanguage: (id: string, language: string) => Promise<unknown>;
|
|
730
|
+
|
|
731
|
+
/**
|
|
732
|
+
* Changes a user's name.
|
|
733
|
+
*
|
|
734
|
+
* @param id - User ID
|
|
735
|
+
* @param name - New name
|
|
736
|
+
* @returns Updated user
|
|
737
|
+
*/
|
|
738
|
+
changeName: (id: string, name: string) => Promise<unknown>;
|
|
739
|
+
|
|
740
|
+
/**
|
|
741
|
+
* Changes a user's password.
|
|
742
|
+
*
|
|
743
|
+
* @param id - User ID
|
|
744
|
+
* @param password - New password
|
|
745
|
+
* @param confirmation - Password confirmation
|
|
746
|
+
* @returns Updated user
|
|
747
|
+
*/
|
|
748
|
+
changePassword: (
|
|
749
|
+
id: string,
|
|
750
|
+
password: string,
|
|
751
|
+
confirmation: string,
|
|
752
|
+
) => Promise<unknown>;
|
|
753
|
+
|
|
754
|
+
/**
|
|
755
|
+
* Changes a user's role.
|
|
756
|
+
*
|
|
757
|
+
* @param id - User ID
|
|
758
|
+
* @param role - New role
|
|
759
|
+
* @returns Updated user
|
|
760
|
+
*/
|
|
761
|
+
changeRole: (id: string, role: string) => Promise<unknown>;
|
|
762
|
+
|
|
763
|
+
/**
|
|
764
|
+
* Creates a new user.
|
|
765
|
+
*
|
|
766
|
+
* @param id - User ID (usually email)
|
|
767
|
+
* @param data - User data
|
|
768
|
+
* @returns Created user
|
|
769
|
+
*/
|
|
770
|
+
create: (id: string, data: PanelApiUserCreateData) => Promise<unknown>;
|
|
771
|
+
|
|
772
|
+
/**
|
|
773
|
+
* Deletes a user.
|
|
774
|
+
*
|
|
775
|
+
* @param id - User ID
|
|
776
|
+
*/
|
|
777
|
+
delete: (id: string) => Promise<void>;
|
|
778
|
+
|
|
779
|
+
/**
|
|
780
|
+
* Deletes a user's avatar.
|
|
781
|
+
*
|
|
782
|
+
* @param id - User ID
|
|
783
|
+
*/
|
|
784
|
+
deleteAvatar: (id: string) => Promise<void>;
|
|
785
|
+
|
|
786
|
+
/**
|
|
787
|
+
* Gets a user.
|
|
788
|
+
*
|
|
789
|
+
* @param id - User ID
|
|
790
|
+
* @param query - Query parameters
|
|
791
|
+
* @returns User data
|
|
792
|
+
*/
|
|
793
|
+
get: (id: string, query?: Record<string, unknown>) => Promise<unknown>;
|
|
794
|
+
|
|
795
|
+
/**
|
|
796
|
+
* Gets Panel link for a user.
|
|
797
|
+
*
|
|
798
|
+
* @param id - User ID
|
|
799
|
+
* @param path - Additional path
|
|
800
|
+
* @returns Panel link
|
|
801
|
+
*/
|
|
802
|
+
link: (id: string, path?: string) => string;
|
|
803
|
+
|
|
804
|
+
/**
|
|
805
|
+
* Lists all users.
|
|
806
|
+
*
|
|
807
|
+
* @param query - Query parameters
|
|
808
|
+
* @returns Array of users
|
|
809
|
+
*/
|
|
810
|
+
list: (query?: Record<string, unknown>) => Promise<unknown[]>;
|
|
811
|
+
|
|
812
|
+
/**
|
|
813
|
+
* Gets roles available to a user.
|
|
814
|
+
*
|
|
815
|
+
* @param id - User ID
|
|
816
|
+
* @returns Array of roles
|
|
817
|
+
*/
|
|
818
|
+
roles: (id: string) => Promise<unknown[]>;
|
|
819
|
+
|
|
820
|
+
/**
|
|
821
|
+
* Searches users.
|
|
822
|
+
*
|
|
823
|
+
* @param query - Search query
|
|
824
|
+
* @param options - Query options
|
|
825
|
+
* @returns Search results
|
|
826
|
+
*/
|
|
827
|
+
search: (
|
|
828
|
+
query?: PanelApiSearchQuery,
|
|
829
|
+
options?: Record<string, unknown>,
|
|
830
|
+
) => Promise<unknown>;
|
|
831
|
+
|
|
832
|
+
/**
|
|
833
|
+
* Updates a user's content.
|
|
834
|
+
*
|
|
835
|
+
* @param id - User ID
|
|
836
|
+
* @param data - Content data
|
|
837
|
+
* @returns Updated user
|
|
838
|
+
*/
|
|
839
|
+
update: (id: string, data: Record<string, unknown>) => Promise<unknown>;
|
|
840
|
+
|
|
841
|
+
/**
|
|
842
|
+
* Gets API URL for a user.
|
|
843
|
+
*
|
|
844
|
+
* @param id - User ID
|
|
845
|
+
* @param path - Additional path
|
|
846
|
+
* @returns API URL
|
|
847
|
+
*/
|
|
848
|
+
url: (id: string, path?: string) => string;
|
|
849
|
+
}
|
|
850
|
+
|
|
851
|
+
// -----------------------------------------------------------------------------
|
|
852
|
+
// Main API Interface
|
|
853
|
+
// -----------------------------------------------------------------------------
|
|
854
|
+
|
|
855
|
+
/**
|
|
856
|
+
* Panel API client.
|
|
857
|
+
*
|
|
858
|
+
* Provides typed access to all Kirby API endpoints.
|
|
859
|
+
*
|
|
860
|
+
* @example
|
|
861
|
+
* ```ts
|
|
862
|
+
* // Get a page
|
|
863
|
+
* const page = await panel.api.pages.get('home');
|
|
864
|
+
*
|
|
865
|
+
* // Create a new page
|
|
866
|
+
* await panel.api.pages.create('blog', {
|
|
867
|
+
* slug: 'new-post',
|
|
868
|
+
* title: 'New Post',
|
|
869
|
+
* template: 'article'
|
|
870
|
+
* });
|
|
871
|
+
* ```
|
|
872
|
+
*
|
|
873
|
+
* @see https://github.com/getkirby/kirby/blob/main/panel/src/api/index.js
|
|
874
|
+
*/
|
|
875
|
+
export interface PanelApi {
|
|
876
|
+
/** CSRF token for requests */
|
|
877
|
+
csrf: string;
|
|
878
|
+
|
|
879
|
+
/** API base endpoint */
|
|
880
|
+
endpoint: string;
|
|
881
|
+
|
|
882
|
+
/** Whether to use method override */
|
|
883
|
+
methodOverride: boolean;
|
|
884
|
+
|
|
885
|
+
/** Ping interval ID */
|
|
886
|
+
ping: ReturnType<typeof setInterval> | null;
|
|
887
|
+
|
|
888
|
+
/** Active request IDs */
|
|
889
|
+
requests: string[];
|
|
890
|
+
|
|
891
|
+
/** Number of running requests */
|
|
892
|
+
running: number;
|
|
893
|
+
|
|
894
|
+
/** Current language code */
|
|
895
|
+
language: string;
|
|
896
|
+
|
|
897
|
+
/**
|
|
898
|
+
* Makes a raw API request.
|
|
899
|
+
*
|
|
900
|
+
* @param path - API path
|
|
901
|
+
* @param options - Request options
|
|
902
|
+
* @param silent - Skip loading indicator
|
|
903
|
+
* @returns Response data
|
|
904
|
+
*/
|
|
905
|
+
request: (
|
|
906
|
+
path: string,
|
|
907
|
+
options?: PanelApiRequestOptions,
|
|
908
|
+
silent?: boolean,
|
|
909
|
+
) => Promise<unknown>;
|
|
910
|
+
|
|
911
|
+
/**
|
|
912
|
+
* Makes a GET request.
|
|
913
|
+
*
|
|
914
|
+
* @param path - API path
|
|
915
|
+
* @param query - Query parameters
|
|
916
|
+
* @param options - Request options
|
|
917
|
+
* @param silent - Skip loading indicator
|
|
918
|
+
* @returns Response data
|
|
919
|
+
*/
|
|
920
|
+
get: (
|
|
921
|
+
path: string,
|
|
922
|
+
query?: Record<string, unknown>,
|
|
923
|
+
options?: PanelApiRequestOptions,
|
|
924
|
+
silent?: boolean,
|
|
925
|
+
) => Promise<unknown>;
|
|
926
|
+
|
|
927
|
+
/**
|
|
928
|
+
* Makes a POST request.
|
|
929
|
+
*
|
|
930
|
+
* @param path - API path
|
|
931
|
+
* @param data - Request body
|
|
932
|
+
* @param options - Request options
|
|
933
|
+
* @param silent - Skip loading indicator
|
|
934
|
+
* @param upload - Whether uploading file
|
|
935
|
+
* @returns Response data
|
|
936
|
+
*/
|
|
937
|
+
post: (
|
|
938
|
+
path: string,
|
|
939
|
+
data?: unknown,
|
|
940
|
+
options?: PanelApiRequestOptions,
|
|
941
|
+
silent?: boolean,
|
|
942
|
+
upload?: boolean,
|
|
943
|
+
) => Promise<unknown>;
|
|
944
|
+
|
|
945
|
+
/**
|
|
946
|
+
* Makes a PATCH request.
|
|
947
|
+
*
|
|
948
|
+
* @param path - API path
|
|
949
|
+
* @param data - Request body
|
|
950
|
+
* @param options - Request options
|
|
951
|
+
* @param silent - Skip loading indicator
|
|
952
|
+
* @returns Response data
|
|
953
|
+
*/
|
|
954
|
+
patch: (
|
|
955
|
+
path: string,
|
|
956
|
+
data?: unknown,
|
|
957
|
+
options?: PanelApiRequestOptions,
|
|
958
|
+
silent?: boolean,
|
|
959
|
+
) => Promise<unknown>;
|
|
960
|
+
|
|
961
|
+
/**
|
|
962
|
+
* Makes a DELETE request.
|
|
963
|
+
*
|
|
964
|
+
* @param path - API path
|
|
965
|
+
* @param data - Request body
|
|
966
|
+
* @param options - Request options
|
|
967
|
+
* @param silent - Skip loading indicator
|
|
968
|
+
* @returns Response data
|
|
969
|
+
*/
|
|
970
|
+
delete: (
|
|
971
|
+
path: string,
|
|
972
|
+
data?: unknown,
|
|
973
|
+
options?: PanelApiRequestOptions,
|
|
974
|
+
silent?: boolean,
|
|
975
|
+
) => Promise<unknown>;
|
|
976
|
+
|
|
977
|
+
/** Authentication methods */
|
|
978
|
+
auth: PanelApiAuth;
|
|
979
|
+
|
|
980
|
+
/** Files API */
|
|
981
|
+
files: PanelApiFiles;
|
|
982
|
+
|
|
983
|
+
/** Languages API */
|
|
984
|
+
languages: PanelApiLanguages;
|
|
985
|
+
|
|
986
|
+
/** Pages API */
|
|
987
|
+
pages: PanelApiPages;
|
|
988
|
+
|
|
989
|
+
/** Roles API */
|
|
990
|
+
roles: PanelApiRoles;
|
|
991
|
+
|
|
992
|
+
/** Site API */
|
|
993
|
+
site: PanelApiSite;
|
|
994
|
+
|
|
995
|
+
/** System API */
|
|
996
|
+
system: PanelApiSystem;
|
|
997
|
+
|
|
998
|
+
/** Translations API */
|
|
999
|
+
translations: PanelApiTranslations;
|
|
1000
|
+
|
|
1001
|
+
/** Users API */
|
|
1002
|
+
users: PanelApiUsers;
|
|
1003
|
+
}
|