@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,58 @@
1
+ /**
2
+ * The package report: which `@uln/*` packages a site was built with, at which versions. The site's build writes it
3
+ * (`ulnPackages()` from `@uln/manage/vite`) and serves it as a static file at {@link PACKAGE_REPORT_PATH}; Manage
4
+ * reads it from the live site, so what it shows is what is deployed. It names only package versions: nothing secret.
5
+ *
6
+ * It's also what an upgrade is planned from ({@link upgradePlan}): enough to tell which packages to bump, to which
7
+ * version, with which package manager and range style, and whether the bump may break.
8
+ *
9
+ * A contract with every site's build: change it only by adding optional fields. A breaking change gets a new `schema`.
10
+ */
11
+ export declare const PACKAGE_REPORT_PATH = "/.well-known/uln-packages.json";
12
+ export declare const ULN_SCOPE = "@uln/";
13
+ export type DependencyType = "dependencies" | "devDependencies" | "peerDependencies" | "optionalDependencies";
14
+ export declare const DEPENDENCY_TYPES: readonly DependencyType[];
15
+ export interface ReportedPackage {
16
+ /** The version installed when the site was built (from the package's own `package.json`). */
17
+ version: string;
18
+ /** The range the site's `package.json` asks for (`^0.3.5`). */
19
+ range: string;
20
+ /** Which section of the site's `package.json` names it. */
21
+ type: DependencyType;
22
+ }
23
+ export interface PackageReport {
24
+ schema: 1;
25
+ /** When the site was built (ISO 8601). */
26
+ builtAt: string;
27
+ /** The site's `packageManager` field (`pnpm@10.4.0`), when it has one. */
28
+ packageManager?: string;
29
+ /** Every `@uln/*` package the site's `package.json` depends on directly, by name. */
30
+ packages: Record<string, ReportedPackage>;
31
+ }
32
+ export declare function isVersion(value: unknown): value is string;
33
+ /** Negative if `a` is older than `b`, 0 if equal, positive if newer. Pre-release tags are ignored. */
34
+ export declare function compareVersions(a: string, b: string): number;
35
+ /**
36
+ * A report as a site serves it, checked field by field: anything malformed is dropped, so a site's file can't put
37
+ * arbitrary data on Manage's page. Null when it isn't a report at all.
38
+ */
39
+ export declare function parsePackageReport(value: unknown): PackageReport | null;
40
+ /** One package to bump. */
41
+ export interface PackageUpgrade {
42
+ name: string;
43
+ from: string;
44
+ to: string;
45
+ /** May need code changes: a new major, or before 1.0 a new minor (semver's rule for 0.x). */
46
+ breaking: boolean;
47
+ /** The range to write in `package.json`, keeping the site's style (`^0.3.2` → `^0.3.6`). */
48
+ range: string;
49
+ type: DependencyType;
50
+ }
51
+ /** The range for `to` in the style of `range`: its `^` or `~`, or an exact version. */
52
+ export declare function bumpedRange(range: string, to: string): string;
53
+ export declare function isBreaking(from: string, to: string): boolean;
54
+ /**
55
+ * What to bump to bring a site to the latest of every `@uln/*` package it reports, by name. What a future
56
+ * "upgrade with an agent" action runs from: each bump, its target range, and whether it may need code changes.
57
+ */
58
+ export declare function upgradePlan(report: PackageReport, latest: ReadonlyMap<string, string>): PackageUpgrade[];
@@ -0,0 +1,38 @@
1
+ /**
2
+ * What a website receives: ready-to-display records with direct provider URLs, and no storage or workflow details.
3
+ * The one projection from Manage's content to these shapes, shared by the SDK's service-binding client
4
+ * (`sdk/index.ts`) and the HTTP content API (`worker/content-api.ts`). Client-safe: no Workers runtime, no database.
5
+ * Part of the public contract: only grows.
6
+ */
7
+ import type { FilmContent, ShootContent } from "./content-types.ts";
8
+ import type { Film, Photo, Shoot } from "./schema.ts";
9
+ /** Ready to display: metadata and direct provider URLs, with no storage/workflow details. */
10
+ export type PublicFilm = Omit<Film, "previewAsset" | "previewPreparation" | "frameImages" | "cachedFrames" | "processing" | "hidden"> & {
11
+ playbackUrl: string;
12
+ posterUrl: string;
13
+ /** The poster at each width the site asked for (`MediaSizes.posterWidths`), keyed by width, e.g. `["640"]`. */
14
+ posterVariants?: Record<string, string>;
15
+ /** The preview clip as one progressive MP4 (540p, silent). */
16
+ previewUrl?: string;
17
+ /**
18
+ * The same preview as an adaptive stream (HLS), encoded from the film at full quality, so the player picks the
19
+ * rendition that fits the card. Present for previews made since adaptive previews; may carry the film's audio.
20
+ */
21
+ previewPlaybackUrl?: string;
22
+ /** The preview clip's size in bytes, when known: lets a site choose to load it whole or stream it before asking. */
23
+ previewBytes?: number;
24
+ /** Unix milliseconds. Refresh this item before its earliest media URL expires. */
25
+ expiresAt: number | null;
26
+ };
27
+ export type PublicPhoto = Photo & {
28
+ /** The photo at its stored size. */
29
+ url: string;
30
+ /** The photo scaled down to each width the site asked for (`MediaSizes.photoWidths`), keyed by width. */
31
+ variants?: Record<string, string>;
32
+ expiresAt: number | null;
33
+ };
34
+ export type PublicShoot = Omit<Shoot, "photos" | "hidden"> & {
35
+ photos: PublicPhoto[];
36
+ };
37
+ export declare function publicFilm({ film, playback, poster, posterVariants, preview, previewPlayback, }: FilmContent): PublicFilm;
38
+ export declare function publicShoot({ shoot, photos }: ShootContent): PublicShoot;
@@ -0,0 +1,43 @@
1
+ /**
2
+ * The contract between Manage and client sites: how a site reads its catalog (its content). A site binds the catalog's `PublicCatalog` entrypoint with
3
+ * its site in the binding's props, and types the binding with this interface:
4
+ *
5
+ * ```jsonc
6
+ * // the site's wrangler.jsonc
7
+ * "services": [{ "binding": "CATALOG", "service": "manage", "entrypoint": "PublicCatalog", "props": { "site": "erikhe" } }]
8
+ * ```
9
+ *
10
+ * ```ts
11
+ * import type { PublicCatalogRpc } from "@uln/manage/rpc";
12
+ * const gallery = await (env.CATALOG as Service<PublicCatalogRpc>).filmsGallery();
13
+ * ```
14
+ *
15
+ * Change it only by adding: a new method or a new optional field. Removing or retyping anything breaks
16
+ * every site that reads it, and sites upgrade on their own schedule.
17
+ */
18
+ import type { FilmContent, FilmsContent, ShootContent, StillsContent } from "./content-types.ts";
19
+ import type { MediaSizes } from "./media-sizes.ts";
20
+ import type { PublicFilmsGallery, PublicStillsGallery, SiteContact } from "./schema.ts";
21
+ /** Set on the site's service binding; Manage never takes the site from a call's arguments. */
22
+ export interface PublicCatalogProps {
23
+ site: string;
24
+ /** Required by the signed-content methods; must exactly match this site's current origin in auth. */
25
+ origin?: string;
26
+ }
27
+ export interface PublicCatalogRpc {
28
+ /**
29
+ * Presentation metadata and direct provider URLs; refresh before `expiresAt`. `sizes` names the photo and poster
30
+ * widths the site's layout needs; each comes back signed under its width.
31
+ */
32
+ filmsContent(sizes?: MediaSizes): Promise<FilmsContent>;
33
+ stillsContent(sizes?: MediaSizes): Promise<StillsContent>;
34
+ contactsContent(): Promise<SiteContact[]>;
35
+ filmContent(id: string, sizes?: MediaSizes): Promise<FilmContent | undefined>;
36
+ shootContent(id: string, sizes?: MediaSizes): Promise<ShootContent | undefined>;
37
+ /** Playable films in visible categories, in the site's category order. */
38
+ filmsGallery(): Promise<PublicFilmsGallery>;
39
+ /** Visible shoots that have photos, grouped by category. */
40
+ stillsGallery(): Promise<PublicStillsGallery>;
41
+ /** Contact lines, in their saved order. */
42
+ siteContacts(): Promise<SiteContact[]>;
43
+ }
@@ -0,0 +1,145 @@
1
+ /**
2
+ * The catalog's record shapes, shared by the Manage Worker and every client site. Client-safe: no Workers
3
+ * runtime, no database. Sites import these types to read what the RPC returns.
4
+ */
5
+ import { type PreviewPreparation } from "@uln/hls/cloudflare";
6
+ import { z } from "zod";
7
+ import { type CategoryIndexGroup, type FilmCategory } from "./lib/category-order.ts";
8
+ export declare const creditSchema: z.ZodObject<{
9
+ role: z.ZodString;
10
+ name: z.ZodString;
11
+ url: z.ZodOptional<z.ZodString>;
12
+ }, z.core.$strip>;
13
+ export type Credit = z.infer<typeof creditSchema>;
14
+ /**
15
+ * A film's preview: the progressive MP4 `@uln/hls` describes (`key`), and, for previews made since adaptive previews,
16
+ * the video backend's id of the same clip at full quality, played as an adaptive stream (`playbackKey`).
17
+ */
18
+ export declare const filmPreviewAssetSchema: z.ZodObject<{
19
+ key: z.ZodString;
20
+ version: z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>;
21
+ contentType: z.ZodLiteral<"video/mp4">;
22
+ size: z.ZodNumber;
23
+ duration: z.ZodNumber;
24
+ sourceStart: z.ZodNumber;
25
+ source: z.ZodOptional<z.ZodEnum<{
26
+ automatic: "automatic";
27
+ manual: "manual";
28
+ }>>;
29
+ playbackKey: z.ZodOptional<z.ZodString>;
30
+ }, z.core.$strip>;
31
+ export type FilmPreviewAsset = z.infer<typeof filmPreviewAssetSchema>;
32
+ export declare const filmPreviewPreparationSchema: z.ZodObject<{
33
+ workflowId: z.ZodString;
34
+ status: z.ZodEnum<{
35
+ failed: "failed";
36
+ processing: "processing";
37
+ queued: "queued";
38
+ }>;
39
+ sourceStart: z.ZodNumber;
40
+ requestedDuration: z.ZodNumber;
41
+ updatedAt: z.ZodString;
42
+ error: z.ZodOptional<z.ZodString>;
43
+ }, z.core.$strip>;
44
+ export type FilmPreviewPreparation = PreviewPreparation;
45
+ export declare const filmSchema: z.ZodObject<{
46
+ id: z.ZodString;
47
+ title: z.ZodString;
48
+ role: z.ZodString;
49
+ category: z.ZodString;
50
+ year: z.ZodOptional<z.ZodString>;
51
+ client: z.ZodOptional<z.ZodString>;
52
+ clientUrl: z.ZodOptional<z.ZodString>;
53
+ description: z.ZodOptional<z.ZodString>;
54
+ playbackUrl: z.ZodOptional<z.ZodURL>;
55
+ posterUrl: z.ZodOptional<z.ZodString>;
56
+ credits: z.ZodOptional<z.ZodArray<z.ZodObject<{
57
+ role: z.ZodString;
58
+ name: z.ZodString;
59
+ url: z.ZodOptional<z.ZodString>;
60
+ }, z.core.$strip>>>;
61
+ aspectRatio: z.ZodOptional<z.ZodNumber>;
62
+ frameImages: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
63
+ cachedFrames: z.ZodOptional<z.ZodArray<z.ZodNumber>>;
64
+ hidden: z.ZodOptional<z.ZodBoolean>;
65
+ processing: z.ZodOptional<z.ZodBoolean>;
66
+ previewStart: z.ZodOptional<z.ZodNumber>;
67
+ previewEnd: z.ZodOptional<z.ZodNumber>;
68
+ previewAsset: z.ZodOptional<z.ZodObject<{
69
+ key: z.ZodString;
70
+ version: z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>;
71
+ contentType: z.ZodLiteral<"video/mp4">;
72
+ size: z.ZodNumber;
73
+ duration: z.ZodNumber;
74
+ sourceStart: z.ZodNumber;
75
+ source: z.ZodOptional<z.ZodEnum<{
76
+ automatic: "automatic";
77
+ manual: "manual";
78
+ }>>;
79
+ playbackKey: z.ZodOptional<z.ZodString>;
80
+ }, z.core.$strip>>;
81
+ previewPreparation: z.ZodOptional<z.ZodObject<{
82
+ workflowId: z.ZodString;
83
+ status: z.ZodEnum<{
84
+ failed: "failed";
85
+ processing: "processing";
86
+ queued: "queued";
87
+ }>;
88
+ sourceStart: z.ZodNumber;
89
+ requestedDuration: z.ZodNumber;
90
+ updatedAt: z.ZodString;
91
+ error: z.ZodOptional<z.ZodString>;
92
+ }, z.core.$strip>>;
93
+ }, z.core.$strip>;
94
+ export type Film = z.infer<typeof filmSchema>;
95
+ export declare const photoSchema: z.ZodObject<{
96
+ id: z.ZodString;
97
+ width: z.ZodNumber;
98
+ height: z.ZodNumber;
99
+ alt: z.ZodOptional<z.ZodString>;
100
+ }, z.core.$strip>;
101
+ export type Photo = z.infer<typeof photoSchema>;
102
+ export declare const shootSchema: z.ZodObject<{
103
+ id: z.ZodString;
104
+ title: z.ZodString;
105
+ category: z.ZodOptional<z.ZodString>;
106
+ year: z.ZodOptional<z.ZodString>;
107
+ role: z.ZodOptional<z.ZodString>;
108
+ description: z.ZodOptional<z.ZodString>;
109
+ credits: z.ZodOptional<z.ZodArray<z.ZodObject<{
110
+ role: z.ZodString;
111
+ name: z.ZodString;
112
+ url: z.ZodOptional<z.ZodString>;
113
+ }, z.core.$strip>>>;
114
+ tags: z.ZodOptional<z.ZodArray<z.ZodString>>;
115
+ url: z.ZodOptional<z.ZodString>;
116
+ client: z.ZodOptional<z.ZodString>;
117
+ clientUrl: z.ZodOptional<z.ZodString>;
118
+ photos: z.ZodArray<z.ZodObject<{
119
+ id: z.ZodString;
120
+ width: z.ZodNumber;
121
+ height: z.ZodNumber;
122
+ alt: z.ZodOptional<z.ZodString>;
123
+ }, z.core.$strip>>;
124
+ hidden: z.ZodOptional<z.ZodBoolean>;
125
+ }, z.core.$strip>;
126
+ export type Shoot = z.infer<typeof shootSchema>;
127
+ /** A contact line (`<label>: <email>`), e.g. representation by region. */
128
+ export interface SiteContact {
129
+ id: string;
130
+ label: string;
131
+ email: string;
132
+ }
133
+ export type { CategoryIndexGroup, FilmCategory } from "./lib/category-order.ts";
134
+ export type PublicFilmsGallery = {
135
+ films: Film[];
136
+ indexGroups: CategoryIndexGroup[];
137
+ };
138
+ export type PublicStillsGallery = {
139
+ shoots: Shoot[];
140
+ indexGroups: CategoryIndexGroup[];
141
+ };
142
+ /** The public films gallery: playable films in the visible categories, in category order. */
143
+ export declare function createPublicFilmsGallery(films: Film[], categories: FilmCategory[]): PublicFilmsGallery;
144
+ /** The public stills gallery: shoots that have photos, grouped by category. */
145
+ export declare function createPublicStillsGallery(shoots: Shoot[]): PublicStillsGallery;
package/dist/vite.js ADDED
@@ -0,0 +1,85 @@
1
+ import { readFileSync as e } from "node:fs";
2
+ import { dirname as t, join as n, resolve as r } from "node:path";
3
+ // src/package-report.ts
4
+ var i = "/.well-known/uln-packages.json", a = [
5
+ "dependencies",
6
+ "devDependencies",
7
+ "peerDependencies",
8
+ "optionalDependencies"
9
+ ], o = /^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?$/;
10
+ function s(e) {
11
+ return typeof e == "string" && e.length <= 64 && o.test(e);
12
+ }
13
+ // sdk/vite.ts
14
+ function c(t) {
15
+ try {
16
+ let n = JSON.parse(e(t, "utf8"));
17
+ return typeof n == "object" && n ? n : null;
18
+ } catch {
19
+ return null;
20
+ }
21
+ }
22
+ function l(e, r) {
23
+ let i = r;
24
+ for (;;) {
25
+ let r = c(n(i, "node_modules", e, "package.json")), a = r ? Reflect.get(r, "version") : void 0;
26
+ if (s(a)) return a;
27
+ let o = t(i);
28
+ if (o === i) return null;
29
+ i = o;
30
+ }
31
+ }
32
+ function u(e, t = /* @__PURE__ */ new Date()) {
33
+ let r = c(n(e, "package.json"));
34
+ if (!r) throw Error(`ulnPackages: no package.json in ${e}`);
35
+ let i = {};
36
+ for (let t of a) {
37
+ let n = Reflect.get(r, t);
38
+ if (typeof n == "object" && n) for (let [r, a] of Object.entries(n)) {
39
+ if (!r.startsWith("@uln/") || typeof a != "string" || r in i) continue;
40
+ let n = l(r, e);
41
+ n && (i[r] = {
42
+ version: n,
43
+ range: a,
44
+ type: t
45
+ });
46
+ }
47
+ }
48
+ let o = Reflect.get(r, "packageManager");
49
+ return {
50
+ schema: 1,
51
+ builtAt: t.toISOString(),
52
+ ...typeof o == "string" ? { packageManager: o } : {},
53
+ packages: Object.fromEntries(Object.entries(i).sort(([e], [t]) => e.localeCompare(t)))
54
+ };
55
+ }
56
+ var d = "virtual:uln-packages", f = `\0${d}`;
57
+ function p(e = {}) {
58
+ let t = process.cwd();
59
+ return {
60
+ name: "uln-packages",
61
+ resolveId(e) {
62
+ return e === "virtual:uln-packages" ? f : void 0;
63
+ },
64
+ load(e) {
65
+ return e === f ? `export const report = ${JSON.stringify(u(t))};` : void 0;
66
+ },
67
+ configResolved(n) {
68
+ t = r(n.root, e.root ?? ".");
69
+ },
70
+ configureServer(e) {
71
+ e.middlewares.use(i, (e, n) => {
72
+ n.setHeader("Content-Type", "application/json"), n.end(JSON.stringify(u(t), null, 2));
73
+ });
74
+ },
75
+ generateBundle() {
76
+ let e = Reflect.get(this, "environment");
77
+ (e ? Reflect.get(Reflect.get(e, "config") ?? {}, "consumer") : void 0) !== "server" && this.emitFile({
78
+ type: "asset",
79
+ fileName: i.slice(1),
80
+ source: `${JSON.stringify(u(t), null, 2)}\n`
81
+ });
82
+ }
83
+ };
84
+ }
85
+ export { i as PACKAGE_REPORT_PATH, d as VIRTUAL_MODULE, u as packageReport, p as ulnPackages };
package/package.json CHANGED
@@ -1,6 +1,49 @@
1
1
  {
2
2
  "name": "@uln/manage",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.3.1",
4
+ "description": "Typed public catalog client and Manage links for ULN sites.",
5
+ "type": "module",
6
+ "sideEffects": false,
7
+ "license": "UNLICENSED",
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "git+https://github.com/ulnd/manage.git",
11
+ "directory": "sdk"
12
+ },
13
+ "files": [
14
+ "dist",
15
+ "CHANGELOG.md"
16
+ ],
17
+ "exports": {
18
+ ".": {
19
+ "types": "./dist/types/sdk/index.d.ts",
20
+ "import": "./dist/index.js"
21
+ },
22
+ "./rpc": {
23
+ "types": "./dist/types/sdk/rpc.d.ts",
24
+ "import": "./dist/rpc.js"
25
+ },
26
+ "./vite": {
27
+ "types": "./dist/types/sdk/vite.d.ts",
28
+ "import": "./dist/vite.js"
29
+ }
30
+ },
31
+ "publishConfig": {
32
+ "access": "public"
33
+ },
34
+ "scripts": {
35
+ "prepack": "pnpm --dir .. build:sdk"
36
+ },
37
+ "dependencies": {
38
+ "@uln/hls": "^0.3.5",
39
+ "zod": "^4.6.7"
40
+ },
41
+ "peerDependencies": {
42
+ "vite": ">=6"
43
+ },
44
+ "peerDependenciesMeta": {
45
+ "vite": {
46
+ "optional": true
47
+ }
48
+ }
49
+ }