@uln/manage 0.0.0-stage → 0.3.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.
@@ -0,0 +1,569 @@
1
+ /**
2
+ * The HTTP content API's contract (OpenAPI 3.1), served at `/api/content/v1/openapi.json`. It describes the shapes in
3
+ * `src/public-content.ts`; `test/content-api.test.ts` checks real responses against it. Like the RPC contract, it only
4
+ * grows: new paths and new optional fields.
5
+ */
6
+ export declare const CONTENT_API_BASE = "/api/content/v1";
7
+ /** The OpenAPI document, with `server` as its base URL (Manage's own origin). */
8
+ export declare function contentApiSpec(server: string): {
9
+ openapi: string;
10
+ info: {
11
+ title: string;
12
+ version: string;
13
+ description: string;
14
+ };
15
+ servers: {
16
+ url: string;
17
+ }[];
18
+ security: {
19
+ apiKey: never[];
20
+ }[];
21
+ paths: {
22
+ "/films": {
23
+ get: {
24
+ operationId: string;
25
+ summary: string;
26
+ parameters: {
27
+ name: string;
28
+ in: string;
29
+ required: boolean;
30
+ schema: {
31
+ type: string;
32
+ pattern: string;
33
+ };
34
+ description: string;
35
+ }[];
36
+ responses: {
37
+ "401": {
38
+ description: string;
39
+ content: {
40
+ "application/json": {
41
+ schema: {
42
+ $ref: string;
43
+ };
44
+ };
45
+ };
46
+ };
47
+ "503": {
48
+ description: string;
49
+ content: {
50
+ "application/json": {
51
+ schema: {
52
+ $ref: string;
53
+ };
54
+ };
55
+ };
56
+ };
57
+ "400": {
58
+ description: string;
59
+ content: {
60
+ "application/json": {
61
+ schema: {
62
+ $ref: string;
63
+ };
64
+ };
65
+ };
66
+ };
67
+ "200": {
68
+ description: string;
69
+ content: {
70
+ "application/json": {
71
+ schema: {
72
+ type: string;
73
+ required: string[];
74
+ properties: {
75
+ [x: string]: object;
76
+ };
77
+ };
78
+ };
79
+ };
80
+ };
81
+ };
82
+ };
83
+ };
84
+ "/films/{id}": {
85
+ get: {
86
+ operationId: string;
87
+ summary: string;
88
+ parameters: ({
89
+ name: string;
90
+ in: string;
91
+ required: boolean;
92
+ schema: {
93
+ type: string;
94
+ pattern: string;
95
+ };
96
+ description: string;
97
+ } | {
98
+ name: string;
99
+ in: string;
100
+ required: boolean;
101
+ schema: {
102
+ readonly type: "string";
103
+ };
104
+ description: string;
105
+ })[];
106
+ responses: {
107
+ "401": {
108
+ description: string;
109
+ content: {
110
+ "application/json": {
111
+ schema: {
112
+ $ref: string;
113
+ };
114
+ };
115
+ };
116
+ };
117
+ "503": {
118
+ description: string;
119
+ content: {
120
+ "application/json": {
121
+ schema: {
122
+ $ref: string;
123
+ };
124
+ };
125
+ };
126
+ };
127
+ "400": {
128
+ description: string;
129
+ content: {
130
+ "application/json": {
131
+ schema: {
132
+ $ref: string;
133
+ };
134
+ };
135
+ };
136
+ };
137
+ "200": {
138
+ description: string;
139
+ content: {
140
+ "application/json": {
141
+ schema: {
142
+ type: string;
143
+ required: string[];
144
+ properties: {
145
+ [x: string]: object;
146
+ };
147
+ };
148
+ };
149
+ };
150
+ };
151
+ "404": {
152
+ description: string;
153
+ content: {
154
+ "application/json": {
155
+ schema: {
156
+ $ref: string;
157
+ };
158
+ };
159
+ };
160
+ };
161
+ };
162
+ };
163
+ };
164
+ "/shoots": {
165
+ get: {
166
+ operationId: string;
167
+ summary: string;
168
+ parameters: {
169
+ name: string;
170
+ in: string;
171
+ required: boolean;
172
+ schema: {
173
+ type: string;
174
+ pattern: string;
175
+ };
176
+ description: string;
177
+ }[];
178
+ responses: {
179
+ "401": {
180
+ description: string;
181
+ content: {
182
+ "application/json": {
183
+ schema: {
184
+ $ref: string;
185
+ };
186
+ };
187
+ };
188
+ };
189
+ "503": {
190
+ description: string;
191
+ content: {
192
+ "application/json": {
193
+ schema: {
194
+ $ref: string;
195
+ };
196
+ };
197
+ };
198
+ };
199
+ "400": {
200
+ description: string;
201
+ content: {
202
+ "application/json": {
203
+ schema: {
204
+ $ref: string;
205
+ };
206
+ };
207
+ };
208
+ };
209
+ "200": {
210
+ description: string;
211
+ content: {
212
+ "application/json": {
213
+ schema: {
214
+ type: string;
215
+ required: string[];
216
+ properties: {
217
+ [x: string]: object;
218
+ };
219
+ };
220
+ };
221
+ };
222
+ };
223
+ };
224
+ };
225
+ };
226
+ "/shoots/{id}": {
227
+ get: {
228
+ operationId: string;
229
+ summary: string;
230
+ parameters: ({
231
+ name: string;
232
+ in: string;
233
+ required: boolean;
234
+ schema: {
235
+ type: string;
236
+ pattern: string;
237
+ };
238
+ description: string;
239
+ } | {
240
+ name: string;
241
+ in: string;
242
+ required: boolean;
243
+ schema: {
244
+ readonly type: "string";
245
+ };
246
+ description: string;
247
+ })[];
248
+ responses: {
249
+ "401": {
250
+ description: string;
251
+ content: {
252
+ "application/json": {
253
+ schema: {
254
+ $ref: string;
255
+ };
256
+ };
257
+ };
258
+ };
259
+ "503": {
260
+ description: string;
261
+ content: {
262
+ "application/json": {
263
+ schema: {
264
+ $ref: string;
265
+ };
266
+ };
267
+ };
268
+ };
269
+ "400": {
270
+ description: string;
271
+ content: {
272
+ "application/json": {
273
+ schema: {
274
+ $ref: string;
275
+ };
276
+ };
277
+ };
278
+ };
279
+ "200": {
280
+ description: string;
281
+ content: {
282
+ "application/json": {
283
+ schema: {
284
+ type: string;
285
+ required: string[];
286
+ properties: {
287
+ [x: string]: object;
288
+ };
289
+ };
290
+ };
291
+ };
292
+ };
293
+ "404": {
294
+ description: string;
295
+ content: {
296
+ "application/json": {
297
+ schema: {
298
+ $ref: string;
299
+ };
300
+ };
301
+ };
302
+ };
303
+ };
304
+ };
305
+ };
306
+ "/contacts": {
307
+ get: {
308
+ operationId: string;
309
+ summary: string;
310
+ responses: {
311
+ "401": {
312
+ description: string;
313
+ content: {
314
+ "application/json": {
315
+ schema: {
316
+ $ref: string;
317
+ };
318
+ };
319
+ };
320
+ };
321
+ "503": {
322
+ description: string;
323
+ content: {
324
+ "application/json": {
325
+ schema: {
326
+ $ref: string;
327
+ };
328
+ };
329
+ };
330
+ };
331
+ "200": {
332
+ description: string;
333
+ content: {
334
+ "application/json": {
335
+ schema: {
336
+ type: string;
337
+ required: string[];
338
+ properties: {
339
+ [x: string]: object;
340
+ };
341
+ };
342
+ };
343
+ };
344
+ };
345
+ };
346
+ };
347
+ };
348
+ };
349
+ components: {
350
+ securitySchemes: {
351
+ apiKey: {
352
+ type: string;
353
+ scheme: string;
354
+ description: string;
355
+ };
356
+ };
357
+ schemas: {
358
+ Film: {
359
+ readonly type: "object";
360
+ readonly description: "A published film: metadata and signed provider URLs, ready to display.";
361
+ readonly required: readonly ["id", "title", "role", "category", "playbackUrl", "posterUrl", "expiresAt"];
362
+ readonly properties: {
363
+ readonly id: {
364
+ readonly type: "string";
365
+ };
366
+ readonly title: {
367
+ readonly type: "string";
368
+ };
369
+ readonly role: {
370
+ readonly type: "string";
371
+ };
372
+ readonly category: {
373
+ readonly type: "string";
374
+ };
375
+ readonly year: {
376
+ readonly type: "string";
377
+ };
378
+ readonly client: {
379
+ readonly type: "string";
380
+ };
381
+ readonly clientUrl: {
382
+ readonly type: "string";
383
+ };
384
+ readonly description: {
385
+ readonly type: "string";
386
+ };
387
+ readonly credits: {
388
+ readonly type: "array";
389
+ readonly items: {
390
+ readonly $ref: "#/components/schemas/Credit";
391
+ };
392
+ };
393
+ readonly aspectRatio: {
394
+ readonly type: "number";
395
+ readonly description: "Width / height.";
396
+ };
397
+ readonly previewStart: {
398
+ readonly type: "number";
399
+ readonly description: "Film time, in seconds, that the preview clip starts at.";
400
+ };
401
+ readonly previewEnd: {
402
+ readonly type: "number";
403
+ };
404
+ readonly playbackUrl: {
405
+ readonly type: "string";
406
+ readonly format: "uri";
407
+ readonly description: "HLS manifest for the full film.";
408
+ };
409
+ readonly posterUrl: {
410
+ readonly type: "string";
411
+ readonly format: "uri";
412
+ };
413
+ readonly posterVariants: {
414
+ readonly type: "object";
415
+ readonly description: string;
416
+ readonly additionalProperties: {
417
+ readonly type: "string";
418
+ readonly format: "uri";
419
+ };
420
+ };
421
+ readonly previewUrl: {
422
+ readonly type: "string";
423
+ readonly format: "uri";
424
+ readonly description: "Silent MP4 preview clip, when the film has one.";
425
+ };
426
+ readonly previewPlaybackUrl: {
427
+ readonly type: "string";
428
+ readonly format: "uri";
429
+ readonly description: string;
430
+ };
431
+ readonly previewBytes: {
432
+ readonly type: "integer";
433
+ readonly description: "The preview clip's size in bytes, when known.";
434
+ };
435
+ readonly expiresAt: {
436
+ readonly type: readonly ["integer", "null"];
437
+ readonly description: "Unix milliseconds when the earliest signed URL in this record expires; null when nothing expires. Refresh before then.";
438
+ };
439
+ };
440
+ };
441
+ Shoot: {
442
+ readonly type: "object";
443
+ readonly description: "A published shoot with its photos in order.";
444
+ readonly required: readonly ["id", "title", "photos"];
445
+ readonly properties: {
446
+ readonly id: {
447
+ readonly type: "string";
448
+ };
449
+ readonly title: {
450
+ readonly type: "string";
451
+ };
452
+ readonly category: {
453
+ readonly type: "string";
454
+ };
455
+ readonly year: {
456
+ readonly type: "string";
457
+ };
458
+ readonly role: {
459
+ readonly type: "string";
460
+ };
461
+ readonly description: {
462
+ readonly type: "string";
463
+ };
464
+ readonly credits: {
465
+ readonly type: "array";
466
+ readonly items: {
467
+ readonly $ref: "#/components/schemas/Credit";
468
+ };
469
+ };
470
+ readonly tags: {
471
+ readonly type: "array";
472
+ readonly items: {
473
+ readonly type: "string";
474
+ };
475
+ };
476
+ readonly url: {
477
+ readonly type: "string";
478
+ };
479
+ readonly client: {
480
+ readonly type: "string";
481
+ };
482
+ readonly clientUrl: {
483
+ readonly type: "string";
484
+ };
485
+ readonly photos: {
486
+ readonly type: "array";
487
+ readonly items: {
488
+ readonly $ref: "#/components/schemas/Photo";
489
+ };
490
+ };
491
+ };
492
+ };
493
+ Photo: {
494
+ readonly type: "object";
495
+ readonly required: readonly ["id", "width", "height", "url", "expiresAt"];
496
+ readonly properties: {
497
+ readonly id: {
498
+ readonly type: "string";
499
+ };
500
+ readonly width: {
501
+ readonly type: "number";
502
+ };
503
+ readonly height: {
504
+ readonly type: "number";
505
+ };
506
+ readonly alt: {
507
+ readonly type: "string";
508
+ };
509
+ readonly url: {
510
+ readonly type: "string";
511
+ readonly format: "uri";
512
+ readonly description: "The photo at its stored size.";
513
+ };
514
+ readonly variants: {
515
+ readonly type: "object";
516
+ readonly description: string;
517
+ readonly additionalProperties: {
518
+ readonly type: "string";
519
+ readonly format: "uri";
520
+ };
521
+ };
522
+ readonly expiresAt: {
523
+ readonly type: readonly ["integer", "null"];
524
+ readonly description: "Unix milliseconds when the earliest signed URL in this record expires; null when nothing expires. Refresh before then.";
525
+ };
526
+ };
527
+ };
528
+ Credit: {
529
+ readonly type: "object";
530
+ readonly required: readonly ["role", "name"];
531
+ readonly properties: {
532
+ readonly role: {
533
+ readonly type: "string";
534
+ };
535
+ readonly name: {
536
+ readonly type: "string";
537
+ };
538
+ readonly url: {
539
+ readonly type: "string";
540
+ };
541
+ };
542
+ };
543
+ Contact: {
544
+ readonly type: "object";
545
+ readonly required: readonly ["id", "label", "email"];
546
+ readonly properties: {
547
+ readonly id: {
548
+ readonly type: "string";
549
+ };
550
+ readonly label: {
551
+ readonly type: "string";
552
+ };
553
+ readonly email: {
554
+ readonly type: "string";
555
+ };
556
+ };
557
+ };
558
+ Error: {
559
+ readonly type: "object";
560
+ readonly required: readonly ["error"];
561
+ readonly properties: {
562
+ readonly error: {
563
+ readonly type: "string";
564
+ };
565
+ };
566
+ };
567
+ };
568
+ };
569
+ };
@@ -0,0 +1,38 @@
1
+ import type { CategoryIndexGroup, Film, Photo, Shoot } from "./schema.ts";
2
+ /** Direct provider URL. `expiresAt` is Unix milliseconds, or null for an existing public source URL. */
3
+ export interface MediaUrl {
4
+ url: string;
5
+ expiresAt: number | null;
6
+ }
7
+ export interface FilmContent {
8
+ film: Film;
9
+ playback: MediaUrl;
10
+ poster: MediaUrl;
11
+ /** The poster at each width the site asked for, keyed by width. */
12
+ posterVariants?: Record<string, MediaUrl>;
13
+ preview?: MediaUrl;
14
+ /** The preview as an adaptive stream (HLS), when it was made with one. */
15
+ previewPlayback?: MediaUrl;
16
+ }
17
+ export interface PhotoContent {
18
+ photo: Photo;
19
+ image: MediaUrl;
20
+ /** The photo scaled down to each width the site asked for (`MediaSizes.photoWidths`), keyed by width. */
21
+ variants?: Record<string, MediaUrl>;
22
+ }
23
+ export interface ShootContent {
24
+ shoot: Shoot;
25
+ photos: PhotoContent[];
26
+ }
27
+ /** Keep rendering metadata and order intact; delivery URLs are resolved by Manage. */
28
+ export interface FilmsContent {
29
+ films: FilmContent[];
30
+ indexGroups: CategoryIndexGroup[];
31
+ /** Refresh before this time; null when no expiring URLs were issued. */
32
+ expiresAt: number | null;
33
+ }
34
+ export interface StillsContent {
35
+ shoots: ShootContent[];
36
+ indexGroups: CategoryIndexGroup[];
37
+ expiresAt: number | null;
38
+ }
@@ -0,0 +1,35 @@
1
+ export type CategoryIndexGroup = {
2
+ category: string;
3
+ indices: number[];
4
+ };
5
+ export interface FilmCategory {
6
+ name: string;
7
+ hidden: boolean;
8
+ }
9
+ /** Label for category index sections — matches {@link buildIndexGroupsFromCategoryOrderedItems} section headings. */
10
+ export declare function categoryIndexLabel(category: string | undefined): string;
11
+ /**
12
+ * Build sidebar/drawer section metadata from a list already ordered in category blocks
13
+ * (e.g. after {@link groupItemsByCategory}).
14
+ */
15
+ export declare function buildIndexGroupsFromCategoryOrderedItems<T extends {
16
+ category?: string | undefined;
17
+ }>(items: T[]): CategoryIndexGroup[];
18
+ export declare function groupItemsByCategory<T extends {
19
+ category?: string | undefined;
20
+ }>(items: T[]): T[];
21
+ /** Apply the explicit public category order and omit categories hidden by the site owner. */
22
+ export declare function organizeFilmsByCategory<T extends {
23
+ category: string;
24
+ }>(items: T[], categories: FilmCategory[]): T[];
25
+ /**
26
+ * Films in the blocks the site shows them in: by the category order (hidden categories included, and categories not
27
+ * listed yet last), each block keeping the films' saved order.
28
+ */
29
+ export declare function groupFilmsByCategoryOrder<T extends {
30
+ category: string;
31
+ }>(items: T[], categories: FilmCategory[]): {
32
+ category: string;
33
+ hidden: boolean;
34
+ items: T[];
35
+ }[];
@@ -0,0 +1,22 @@
1
+ /**
2
+ * The sizes a site asks Manage to sign. Manage holds no site's size preferences: each site names the widths its
3
+ * layout needs and gets a signed URL per width (`PublicPhoto.variants`, `PublicFilm.posterVariants`). Client-safe:
4
+ * shared by the SDK, the HTTP content API and the service binding. Part of the public contract: only grows.
5
+ */
6
+ export interface MediaSizes {
7
+ /** Photo widths in pixels. Each becomes `photo.variants[String(width)]`, scaled down to fit that width. */
8
+ photoWidths?: readonly number[];
9
+ /** Film poster widths in pixels. Each becomes `film.posterVariants[String(width)]`. */
10
+ posterWidths?: readonly number[];
11
+ }
12
+ /** Largest width a site may ask for (Cloudflare's output limit is higher; nothing on a page needs more). */
13
+ export declare const MAX_MEDIA_WIDTH = 8192;
14
+ /** Most widths per list, so one request can't mint an unbounded number of URLs (or Images variants). */
15
+ export declare const MAX_MEDIA_WIDTHS = 12;
16
+ /** Sorted, de-duplicated widths; throws a message a site developer can act on for anything out of range. */
17
+ export declare function normalizeWidths(widths: readonly unknown[] | undefined, label: string): number[] | undefined;
18
+ export declare function normalizeMediaSizes(sizes: MediaSizes | undefined): MediaSizes;
19
+ /** As HTTP content API query parameters (`?photoWidths=480,960&posterWidths=640`). */
20
+ export declare function mediaSizesQuery(sizes: MediaSizes | undefined): string;
21
+ /** Read the HTTP content API's query parameters; throws a `RangeError` for a malformed value. */
22
+ export declare function parseMediaSizesQuery(params: URLSearchParams): MediaSizes;