@headroom-cms/admin-api 0.1.1

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/dist/index.cjs ADDED
@@ -0,0 +1,640 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/index.ts
21
+ var src_exports = {};
22
+ __export(src_exports, {
23
+ HeadroomAdminClient: () => HeadroomAdminClient,
24
+ HeadroomApiError: () => HeadroomApiError,
25
+ StaticTokenProvider: () => StaticTokenProvider,
26
+ block: () => block,
27
+ bulletItem: () => bulletItem,
28
+ checkItem: () => checkItem,
29
+ codeBlock: () => codeBlock,
30
+ heading: () => heading,
31
+ image: () => image,
32
+ link: () => link,
33
+ numberedItem: () => numberedItem,
34
+ paragraph: () => paragraph,
35
+ text: () => text
36
+ });
37
+ module.exports = __toCommonJS(src_exports);
38
+
39
+ // src/error.ts
40
+ var HeadroomApiError = class extends Error {
41
+ status;
42
+ code;
43
+ constructor(status, code, message) {
44
+ super(message || code);
45
+ this.name = "HeadroomApiError";
46
+ this.status = status;
47
+ this.code = code;
48
+ }
49
+ /** Alias for `message` — eases migration from admin's ApiError which used `detail`. */
50
+ get detail() {
51
+ return this.message;
52
+ }
53
+ };
54
+
55
+ // src/mime.ts
56
+ var MIME_MAP = {
57
+ ".jpg": "image/jpeg",
58
+ ".jpeg": "image/jpeg",
59
+ ".png": "image/png",
60
+ ".gif": "image/gif",
61
+ ".webp": "image/webp",
62
+ ".svg": "image/svg+xml",
63
+ ".mp4": "video/mp4",
64
+ ".pdf": "application/pdf"
65
+ };
66
+ function mimeFromFilename(filename) {
67
+ const ext = filename.includes(".") ? "." + filename.split(".").pop().toLowerCase() : "";
68
+ return MIME_MAP[ext] || "application/octet-stream";
69
+ }
70
+
71
+ // src/client.ts
72
+ var HeadroomAdminClient = class {
73
+ baseUrl;
74
+ tokenProvider;
75
+ constructor(baseUrl, tokenProvider) {
76
+ this.baseUrl = baseUrl.replace(/\/+$/, "");
77
+ this.tokenProvider = tokenProvider;
78
+ }
79
+ /**
80
+ * Low-level fetch — public so admin UI hooks can migrate incrementally.
81
+ * Prefer typed methods (listSites, createContent, etc.) in new code.
82
+ */
83
+ async apiFetch(path, options) {
84
+ const token = await this.tokenProvider.getToken();
85
+ const headers = {
86
+ "Content-Type": "application/json",
87
+ Authorization: `Bearer ${token}`,
88
+ ...options?.headers
89
+ };
90
+ const res = await fetch(`${this.baseUrl}${path}`, {
91
+ ...options,
92
+ headers
93
+ });
94
+ if (res.status === 401 && this.tokenProvider.onUnauthorized) {
95
+ const newToken = await this.tokenProvider.onUnauthorized();
96
+ headers["Authorization"] = `Bearer ${newToken}`;
97
+ const retry = await fetch(`${this.baseUrl}${path}`, {
98
+ ...options,
99
+ headers
100
+ });
101
+ return this.handleResponse(retry);
102
+ }
103
+ return this.handleResponse(res);
104
+ }
105
+ async handleResponse(res) {
106
+ if (!res.ok) {
107
+ let code = "UNKNOWN";
108
+ let message = `HTTP ${res.status}`;
109
+ try {
110
+ const body = await res.json();
111
+ code = body.code || body.error || code;
112
+ message = body.message || body.error || message;
113
+ } catch {
114
+ }
115
+ throw new HeadroomApiError(res.status, code, message);
116
+ }
117
+ if (res.status === 204) return void 0;
118
+ return res.json();
119
+ }
120
+ // ── Sites ──────────────────────────────────────────
121
+ async listSites(includeArchived = false) {
122
+ const qs = includeArchived ? "?includeArchived=true" : "";
123
+ const res = await this.apiFetch(
124
+ `/v1/admin/sites${qs}`
125
+ );
126
+ return res.items;
127
+ }
128
+ async createSite(host, name) {
129
+ return this.apiFetch("/v1/admin/sites", {
130
+ method: "POST",
131
+ body: JSON.stringify({ host, name })
132
+ });
133
+ }
134
+ async getSite(host) {
135
+ return this.apiFetch(
136
+ `/v1/admin/sites/${encodeURIComponent(host)}`
137
+ );
138
+ }
139
+ async updateSite(host, data) {
140
+ return this.apiFetch(
141
+ `/v1/admin/sites/${encodeURIComponent(host)}`,
142
+ { method: "PUT", body: JSON.stringify(data) }
143
+ );
144
+ }
145
+ async deleteSite(host) {
146
+ await this.apiFetch(
147
+ `/v1/admin/sites/${encodeURIComponent(host)}`,
148
+ { method: "DELETE" }
149
+ );
150
+ }
151
+ async updateSiteAdmins(host, admins) {
152
+ await this.apiFetch(
153
+ `/v1/admin/sites/${encodeURIComponent(host)}/admins`,
154
+ { method: "PUT", body: JSON.stringify({ admins }) }
155
+ );
156
+ }
157
+ async purgeSite(host) {
158
+ await this.apiFetch(
159
+ `/v1/admin/sites/${encodeURIComponent(host)}/purge`,
160
+ { method: "POST" }
161
+ );
162
+ }
163
+ async inviteToSite(host, email, adminUrl) {
164
+ return this.apiFetch(
165
+ `/v1/admin/sites/${encodeURIComponent(host)}/invite`,
166
+ { method: "POST", body: JSON.stringify({ email, adminUrl }) }
167
+ );
168
+ }
169
+ // ── Collections ────────────────────────────────────
170
+ async listCollections(host) {
171
+ const res = await this.apiFetch(
172
+ `/v1/admin/sites/${encodeURIComponent(host)}/collections`
173
+ );
174
+ return res.collections;
175
+ }
176
+ async createCollection(host, input) {
177
+ return this.apiFetch(
178
+ `/v1/admin/sites/${encodeURIComponent(host)}/collections`,
179
+ { method: "POST", body: JSON.stringify(input) }
180
+ );
181
+ }
182
+ async getCollection(host, name) {
183
+ return this.apiFetch(
184
+ `/v1/admin/sites/${encodeURIComponent(host)}/collections/${encodeURIComponent(name)}`
185
+ );
186
+ }
187
+ async updateCollection(host, name, input) {
188
+ return this.apiFetch(
189
+ `/v1/admin/sites/${encodeURIComponent(host)}/collections/${encodeURIComponent(name)}`,
190
+ { method: "PUT", body: JSON.stringify(input) }
191
+ );
192
+ }
193
+ async deleteCollection(host, name) {
194
+ await this.apiFetch(
195
+ `/v1/admin/sites/${encodeURIComponent(host)}/collections/${encodeURIComponent(name)}`,
196
+ { method: "DELETE" }
197
+ );
198
+ }
199
+ // ── Block Types ────────────────────────────────────
200
+ async listBlockTypes(host) {
201
+ const res = await this.apiFetch(
202
+ `/v1/admin/sites/${encodeURIComponent(host)}/block-types`
203
+ );
204
+ return res.blockTypes;
205
+ }
206
+ async createBlockType(host, input) {
207
+ return this.apiFetch(
208
+ `/v1/admin/sites/${encodeURIComponent(host)}/block-types`,
209
+ { method: "POST", body: JSON.stringify(input) }
210
+ );
211
+ }
212
+ async getBlockType(host, name) {
213
+ return this.apiFetch(
214
+ `/v1/admin/sites/${encodeURIComponent(host)}/block-types/${encodeURIComponent(name)}`
215
+ );
216
+ }
217
+ async updateBlockType(host, name, input) {
218
+ return this.apiFetch(
219
+ `/v1/admin/sites/${encodeURIComponent(host)}/block-types/${encodeURIComponent(name)}`,
220
+ { method: "PUT", body: JSON.stringify(input) }
221
+ );
222
+ }
223
+ async deleteBlockType(host, name) {
224
+ await this.apiFetch(
225
+ `/v1/admin/sites/${encodeURIComponent(host)}/block-types/${encodeURIComponent(name)}`,
226
+ { method: "DELETE" }
227
+ );
228
+ }
229
+ // ── Content ────────────────────────────────────────
230
+ async listContent(host, params) {
231
+ const qs = new URLSearchParams();
232
+ if (params?.collection) qs.set("collection", params.collection);
233
+ if (params?.q) qs.set("q", params.q);
234
+ if (params?.search) qs.set("search", params.search);
235
+ if (params?.tag) qs.set("tag", params.tag);
236
+ if (params?.status) qs.set("status", params.status);
237
+ if (params?.sort) qs.set("sort", params.sort);
238
+ if (params?.relatedTo) qs.set("relatedTo", params.relatedTo);
239
+ if (params?.limit) qs.set("limit", String(params.limit));
240
+ if (params?.cursor) qs.set("cursor", params.cursor);
241
+ const q = qs.toString();
242
+ return this.apiFetch(
243
+ `/v1/admin/sites/${encodeURIComponent(host)}/content${q ? `?${q}` : ""}`
244
+ );
245
+ }
246
+ async createContent(host, params) {
247
+ return this.apiFetch(
248
+ `/v1/admin/sites/${encodeURIComponent(host)}/content`,
249
+ { method: "POST", body: JSON.stringify(params) }
250
+ );
251
+ }
252
+ async getContent(host, contentId) {
253
+ return this.apiFetch(
254
+ `/v1/admin/sites/${encodeURIComponent(host)}/content/${contentId}`
255
+ );
256
+ }
257
+ async deleteContent(host, contentId) {
258
+ await this.apiFetch(
259
+ `/v1/admin/sites/${encodeURIComponent(host)}/content/${contentId}`,
260
+ { method: "DELETE" }
261
+ );
262
+ }
263
+ async saveDraft(host, contentId, draft) {
264
+ return this.apiFetch(
265
+ `/v1/admin/sites/${encodeURIComponent(host)}/content/${contentId}/draft`,
266
+ { method: "PUT", body: JSON.stringify(draft) }
267
+ );
268
+ }
269
+ async publishContent(host, contentId) {
270
+ return this.apiFetch(
271
+ `/v1/admin/sites/${encodeURIComponent(host)}/content/${contentId}/publish`,
272
+ { method: "POST" }
273
+ );
274
+ }
275
+ async unpublishContent(host, contentId) {
276
+ await this.apiFetch(
277
+ `/v1/admin/sites/${encodeURIComponent(host)}/content/${contentId}/unpublish`,
278
+ { method: "POST" }
279
+ );
280
+ }
281
+ async discardDraft(host, contentId) {
282
+ await this.apiFetch(
283
+ `/v1/admin/sites/${encodeURIComponent(host)}/content/${contentId}/discard`,
284
+ { method: "POST" }
285
+ );
286
+ }
287
+ async getPublishedContent(host, contentId) {
288
+ return this.apiFetch(
289
+ `/v1/admin/sites/${encodeURIComponent(host)}/content/${contentId}/published`
290
+ );
291
+ }
292
+ async listVersions(host, contentId) {
293
+ return this.apiFetch(
294
+ `/v1/admin/sites/${encodeURIComponent(host)}/content/${contentId}/versions`
295
+ );
296
+ }
297
+ async getVersion(host, contentId, blockId) {
298
+ return this.apiFetch(
299
+ `/v1/admin/sites/${encodeURIComponent(host)}/content/${contentId}/versions/${blockId}`
300
+ );
301
+ }
302
+ async getReferences(host, contentId) {
303
+ return this.apiFetch(
304
+ `/v1/admin/sites/${encodeURIComponent(host)}/content/${contentId}/references`
305
+ );
306
+ }
307
+ // ── Media ──────────────────────────────────────────
308
+ async listMedia(host, params) {
309
+ const qs = new URLSearchParams();
310
+ if (params?.tag) qs.set("tag", params.tag);
311
+ if (params?.folderId) qs.set("folderId", params.folderId);
312
+ if (params?.q) qs.set("q", params.q);
313
+ if (params?.sort) qs.set("sort", params.sort);
314
+ if (params?.limit) qs.set("limit", String(params.limit));
315
+ if (params?.cursor) qs.set("cursor", params.cursor);
316
+ const q = qs.toString();
317
+ return this.apiFetch(
318
+ `/v1/admin/sites/${encodeURIComponent(host)}/media${q ? `?${q}` : ""}`
319
+ );
320
+ }
321
+ async getMedia(host, mediaId) {
322
+ return this.apiFetch(
323
+ `/v1/admin/sites/${encodeURIComponent(host)}/media/${mediaId}`
324
+ );
325
+ }
326
+ async updateMedia(host, mediaId, data) {
327
+ return this.apiFetch(
328
+ `/v1/admin/sites/${encodeURIComponent(host)}/media/${mediaId}`,
329
+ { method: "PUT", body: JSON.stringify(data) }
330
+ );
331
+ }
332
+ async deleteMedia(host, mediaId) {
333
+ await this.apiFetch(
334
+ `/v1/admin/sites/${encodeURIComponent(host)}/media/${mediaId}`,
335
+ { method: "DELETE" }
336
+ );
337
+ }
338
+ async getUploadUrl(host, params) {
339
+ return this.apiFetch(
340
+ `/v1/admin/sites/${encodeURIComponent(host)}/media/upload-url`,
341
+ { method: "POST", body: JSON.stringify(params) }
342
+ );
343
+ }
344
+ async completeUpload(host, mediaId, params) {
345
+ return this.apiFetch(
346
+ `/v1/admin/sites/${encodeURIComponent(host)}/media/${mediaId}/complete`,
347
+ { method: "POST", body: JSON.stringify(params) }
348
+ );
349
+ }
350
+ /**
351
+ * Convenience: download from URL and upload through the media pipeline.
352
+ * Works in both Node.js and browsers (uses fetch + Uint8Array, no Node APIs).
353
+ */
354
+ async uploadFromUrl(host, url, filename, alt) {
355
+ const res = await fetch(url);
356
+ if (!res.ok) throw new Error(`Failed to fetch ${url}: ${res.status}`);
357
+ const buffer = new Uint8Array(await res.arrayBuffer());
358
+ let contentType = res.headers.get("content-type")?.split(";")[0]?.trim() || "";
359
+ if (!contentType || contentType === "application/octet-stream") {
360
+ contentType = mimeFromFilename(filename);
361
+ }
362
+ const { mediaId, uploadUrl } = await this.getUploadUrl(host, {
363
+ filename,
364
+ contentType,
365
+ size: buffer.length
366
+ });
367
+ const uploadRes = await fetch(uploadUrl, {
368
+ method: "PUT",
369
+ body: buffer,
370
+ headers: { "Content-Type": contentType }
371
+ });
372
+ if (!uploadRes.ok)
373
+ throw new Error(`S3 upload failed: ${uploadRes.status}`);
374
+ return this.completeUpload(host, mediaId, { filename, alt });
375
+ }
376
+ // Media folders
377
+ async listMediaFolders(host) {
378
+ const res = await this.apiFetch(
379
+ `/v1/admin/sites/${encodeURIComponent(host)}/media/folders`
380
+ );
381
+ return res.items;
382
+ }
383
+ async createMediaFolder(host, name) {
384
+ return this.apiFetch(
385
+ `/v1/admin/sites/${encodeURIComponent(host)}/media/folders`,
386
+ { method: "POST", body: JSON.stringify({ name }) }
387
+ );
388
+ }
389
+ async updateMediaFolder(host, folderId, name) {
390
+ return this.apiFetch(
391
+ `/v1/admin/sites/${encodeURIComponent(host)}/media/folders/${folderId}`,
392
+ { method: "PUT", body: JSON.stringify({ name }) }
393
+ );
394
+ }
395
+ async deleteMediaFolder(host, folderId) {
396
+ await this.apiFetch(
397
+ `/v1/admin/sites/${encodeURIComponent(host)}/media/folders/${folderId}`,
398
+ { method: "DELETE" }
399
+ );
400
+ }
401
+ async bulkMediaOperation(host, params) {
402
+ return this.apiFetch(
403
+ `/v1/admin/sites/${encodeURIComponent(host)}/media/bulk`,
404
+ { method: "POST", body: JSON.stringify(params) }
405
+ );
406
+ }
407
+ async checkDuplicate(host, filename, size) {
408
+ const qs = new URLSearchParams({ filename, size: String(size) });
409
+ return this.apiFetch(
410
+ `/v1/admin/sites/${encodeURIComponent(host)}/media/check-duplicate?${qs}`
411
+ );
412
+ }
413
+ async getTransformUrl(host, mediaId, params) {
414
+ const qs = new URLSearchParams();
415
+ for (const [k, v] of Object.entries(params)) {
416
+ if (v !== void 0) qs.set(k, String(v));
417
+ }
418
+ return this.apiFetch(
419
+ `/v1/admin/sites/${encodeURIComponent(host)}/media/${mediaId}/transform-url?${qs}`
420
+ );
421
+ }
422
+ async saveTransform(host, mediaId, params) {
423
+ return this.apiFetch(
424
+ `/v1/admin/sites/${encodeURIComponent(host)}/media/${mediaId}/save-transform`,
425
+ { method: "POST", body: JSON.stringify(params) }
426
+ );
427
+ }
428
+ async getMediaUsage(host, mediaId) {
429
+ return this.apiFetch(
430
+ `/v1/admin/sites/${encodeURIComponent(host)}/media/${mediaId}/usage`
431
+ );
432
+ }
433
+ // ── API Keys ───────────────────────────────────────
434
+ async listApiKeys(host) {
435
+ const res = await this.apiFetch(
436
+ `/v1/admin/sites/${encodeURIComponent(host)}/api-keys`
437
+ );
438
+ return res.keys;
439
+ }
440
+ async createApiKey(host, label) {
441
+ return this.apiFetch(
442
+ `/v1/admin/sites/${encodeURIComponent(host)}/api-keys`,
443
+ { method: "POST", body: JSON.stringify({ label }) }
444
+ );
445
+ }
446
+ async updateApiKey(host, keyId, label) {
447
+ return this.apiFetch(
448
+ `/v1/admin/sites/${encodeURIComponent(host)}/api-keys/${keyId}`,
449
+ { method: "PUT", body: JSON.stringify({ label }) }
450
+ );
451
+ }
452
+ async deleteApiKey(host, keyId) {
453
+ await this.apiFetch(
454
+ `/v1/admin/sites/${encodeURIComponent(host)}/api-keys/${keyId}`,
455
+ { method: "DELETE" }
456
+ );
457
+ }
458
+ // ── Webhooks ───────────────────────────────────────
459
+ async listWebhooks(host) {
460
+ const res = await this.apiFetch(
461
+ `/v1/admin/sites/${encodeURIComponent(host)}/webhooks`
462
+ );
463
+ return res.webhooks;
464
+ }
465
+ async createWebhook(host, data) {
466
+ return this.apiFetch(
467
+ `/v1/admin/sites/${encodeURIComponent(host)}/webhooks`,
468
+ { method: "POST", body: JSON.stringify(data) }
469
+ );
470
+ }
471
+ async getWebhook(host, webhookId) {
472
+ return this.apiFetch(
473
+ `/v1/admin/sites/${encodeURIComponent(host)}/webhooks/${webhookId}`
474
+ );
475
+ }
476
+ async updateWebhook(host, webhookId, data) {
477
+ return this.apiFetch(
478
+ `/v1/admin/sites/${encodeURIComponent(host)}/webhooks/${webhookId}`,
479
+ { method: "PUT", body: JSON.stringify(data) }
480
+ );
481
+ }
482
+ async deleteWebhook(host, webhookId) {
483
+ await this.apiFetch(
484
+ `/v1/admin/sites/${encodeURIComponent(host)}/webhooks/${webhookId}`,
485
+ { method: "DELETE" }
486
+ );
487
+ }
488
+ async testWebhook(host, webhookId) {
489
+ await this.apiFetch(
490
+ `/v1/admin/sites/${encodeURIComponent(host)}/webhooks/${webhookId}/test`,
491
+ { method: "POST" }
492
+ );
493
+ }
494
+ async rotateWebhookSecret(host, webhookId) {
495
+ return this.apiFetch(
496
+ `/v1/admin/sites/${encodeURIComponent(host)}/webhooks/${webhookId}/rotate-secret`,
497
+ { method: "POST" }
498
+ );
499
+ }
500
+ async listWebhookDeliveries(host, webhookId) {
501
+ return this.apiFetch(
502
+ `/v1/admin/sites/${encodeURIComponent(host)}/webhooks/${webhookId}/deliveries`
503
+ );
504
+ }
505
+ async getWebhookDelivery(host, webhookId, deliveryId) {
506
+ return this.apiFetch(
507
+ `/v1/admin/sites/${encodeURIComponent(host)}/webhooks/${webhookId}/deliveries/${deliveryId}`
508
+ );
509
+ }
510
+ async retryDelivery(host, webhookId, deliveryId) {
511
+ await this.apiFetch(
512
+ `/v1/admin/sites/${encodeURIComponent(host)}/webhooks/${webhookId}/deliveries/${deliveryId}/retry`,
513
+ { method: "POST" }
514
+ );
515
+ }
516
+ // ── Tags ───────────────────────────────────────────
517
+ async listTags(host) {
518
+ return this.apiFetch(
519
+ `/v1/admin/sites/${encodeURIComponent(host)}/tags`
520
+ );
521
+ }
522
+ async createTag(host, tag) {
523
+ await this.apiFetch(
524
+ `/v1/admin/sites/${encodeURIComponent(host)}/tags`,
525
+ { method: "POST", body: JSON.stringify({ tag }) }
526
+ );
527
+ }
528
+ async deleteTag(host, tag) {
529
+ await this.apiFetch(
530
+ `/v1/admin/sites/${encodeURIComponent(host)}/tags/${encodeURIComponent(tag)}`,
531
+ { method: "DELETE" }
532
+ );
533
+ }
534
+ // ── Audit ──────────────────────────────────────────
535
+ async listAuditEvents(host, params) {
536
+ const qs = new URLSearchParams();
537
+ if (params?.action) qs.set("action", params.action);
538
+ if (params?.before) qs.set("before", String(params.before));
539
+ const q = qs.toString();
540
+ return this.apiFetch(
541
+ `/v1/admin/sites/${encodeURIComponent(host)}/audit${q ? `?${q}` : ""}`
542
+ );
543
+ }
544
+ // ── Users (global, not site-scoped) ────────────────
545
+ async listUsers() {
546
+ return this.apiFetch("/v1/admin/users");
547
+ }
548
+ async deleteUser(sub) {
549
+ await this.apiFetch(`/v1/admin/users/${sub}`, {
550
+ method: "DELETE"
551
+ });
552
+ }
553
+ async disableUserMfa(sub) {
554
+ await this.apiFetch(`/v1/admin/users/${sub}/mfa`, {
555
+ method: "DELETE"
556
+ });
557
+ }
558
+ async resolveAdmins(subs) {
559
+ return this.apiFetch("/v1/admin/users/resolve", {
560
+ method: "POST",
561
+ body: JSON.stringify({ subs })
562
+ });
563
+ }
564
+ async listSuperAdmins() {
565
+ return this.apiFetch("/v1/admin/super-admins");
566
+ }
567
+ async updateSuperAdmins(superAdminIds) {
568
+ await this.apiFetch("/v1/admin/super-admins", {
569
+ method: "PUT",
570
+ body: JSON.stringify({ superAdminIds })
571
+ });
572
+ }
573
+ };
574
+
575
+ // src/token-provider.ts
576
+ var StaticTokenProvider = class {
577
+ constructor(token) {
578
+ this.token = token;
579
+ }
580
+ async getToken() {
581
+ return this.token;
582
+ }
583
+ };
584
+
585
+ // src/blocks.ts
586
+ function text(t, styles) {
587
+ return { type: "text", text: t, styles: styles || {} };
588
+ }
589
+ function link(href, label) {
590
+ return { type: "link", href, content: [text(label)] };
591
+ }
592
+ function block(type, content, props, children) {
593
+ return {
594
+ id: crypto.randomUUID().slice(0, 8),
595
+ type,
596
+ props: { textAlignment: "left", ...props },
597
+ content: content || [],
598
+ children: children || []
599
+ };
600
+ }
601
+ function heading(level, ...content) {
602
+ return block("heading", content, { level });
603
+ }
604
+ function paragraph(...content) {
605
+ return block("paragraph", content);
606
+ }
607
+ function bulletItem(...content) {
608
+ return block("bulletListItem", content);
609
+ }
610
+ function numberedItem(...content) {
611
+ return block("numberedListItem", content);
612
+ }
613
+ function checkItem(checked, ...content) {
614
+ return block("checkListItem", content, { checked });
615
+ }
616
+ function codeBlock(language, code) {
617
+ return block("codeBlock", [text(code)], { language });
618
+ }
619
+ function image(props) {
620
+ return block("image", void 0, {
621
+ ...props,
622
+ textAlignment: "center"
623
+ });
624
+ }
625
+ // Annotate the CommonJS export names for ESM import in node:
626
+ 0 && (module.exports = {
627
+ HeadroomAdminClient,
628
+ HeadroomApiError,
629
+ StaticTokenProvider,
630
+ block,
631
+ bulletItem,
632
+ checkItem,
633
+ codeBlock,
634
+ heading,
635
+ image,
636
+ link,
637
+ numberedItem,
638
+ paragraph,
639
+ text
640
+ });