@norskvideo/ctl-sdk 0.1.21 → 0.1.22
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/docs-router.d.ts +21 -0
- package/docs-router.js +35 -0
- package/index.d.ts +1 -0
- package/index.js +1 -0
- package/package.json +1 -1
package/docs-router.d.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { type Express } from "express";
|
|
2
|
+
/**
|
|
3
|
+
* Where a product's docs bundle (dev-kit doc-guide `buildBundle`) is, given the
|
|
4
|
+
* backend's own directory — or null when the product shipped none.
|
|
5
|
+
*
|
|
6
|
+
* Two layouts, one relative path: the image bakes the bundle at `<app>/docs`
|
|
7
|
+
* beside `backend/` (Dockerfile.bundle), a repo checkout has it at
|
|
8
|
+
* `<repo>/docs/generated/bundle`; from `backend/dist` and `backend/src`
|
|
9
|
+
* respectively both are `../../docs`. The image's `docs/` exists even when
|
|
10
|
+
* empty, so presence is judged by `bundle.json`, not the directory.
|
|
11
|
+
*/
|
|
12
|
+
export declare function docsBundleDir(fromDir: string): string | null;
|
|
13
|
+
/**
|
|
14
|
+
* Mount the docs bundle at `/docs`: `manual.html` as the index, `bundle.json`,
|
|
15
|
+
* `pages/*.md` and `captures/*` by path. Returns whether anything was mounted,
|
|
16
|
+
* so a product without a bundle boots exactly as before. `/docs` redirects to
|
|
17
|
+
* `/docs/` with a root-absolute Location, which the daemon's product proxy
|
|
18
|
+
* rewrites under `/products/<name>` — so the manual's hash routing works
|
|
19
|
+
* through the daemon too.
|
|
20
|
+
*/
|
|
21
|
+
export declare function serveDocs(app: Express, dir: string | null): boolean;
|
package/docs-router.js
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { existsSync } from "node:fs";
|
|
2
|
+
import { resolve } from "node:path";
|
|
3
|
+
import express from "express";
|
|
4
|
+
/**
|
|
5
|
+
* Where a product's docs bundle (dev-kit doc-guide `buildBundle`) is, given the
|
|
6
|
+
* backend's own directory — or null when the product shipped none.
|
|
7
|
+
*
|
|
8
|
+
* Two layouts, one relative path: the image bakes the bundle at `<app>/docs`
|
|
9
|
+
* beside `backend/` (Dockerfile.bundle), a repo checkout has it at
|
|
10
|
+
* `<repo>/docs/generated/bundle`; from `backend/dist` and `backend/src`
|
|
11
|
+
* respectively both are `../../docs`. The image's `docs/` exists even when
|
|
12
|
+
* empty, so presence is judged by `bundle.json`, not the directory.
|
|
13
|
+
*/
|
|
14
|
+
export function docsBundleDir(fromDir) {
|
|
15
|
+
const docs = resolve(fromDir, "../../docs");
|
|
16
|
+
for (const candidate of [docs, resolve(docs, "generated/bundle")]) {
|
|
17
|
+
if (existsSync(resolve(candidate, "bundle.json")))
|
|
18
|
+
return candidate;
|
|
19
|
+
}
|
|
20
|
+
return null;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Mount the docs bundle at `/docs`: `manual.html` as the index, `bundle.json`,
|
|
24
|
+
* `pages/*.md` and `captures/*` by path. Returns whether anything was mounted,
|
|
25
|
+
* so a product without a bundle boots exactly as before. `/docs` redirects to
|
|
26
|
+
* `/docs/` with a root-absolute Location, which the daemon's product proxy
|
|
27
|
+
* rewrites under `/products/<name>` — so the manual's hash routing works
|
|
28
|
+
* through the daemon too.
|
|
29
|
+
*/
|
|
30
|
+
export function serveDocs(app, dir) {
|
|
31
|
+
if (!dir)
|
|
32
|
+
return false;
|
|
33
|
+
app.use("/docs", express.static(dir, { index: "manual.html" }));
|
|
34
|
+
return true;
|
|
35
|
+
}
|
package/index.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ export * from "./capabilities-router.js";
|
|
|
3
3
|
export * from "./cjs-interop.js";
|
|
4
4
|
export * from "./dev-url.js";
|
|
5
5
|
export * from "./docker-runner.js";
|
|
6
|
+
export * from "./docs-router.js";
|
|
6
7
|
export * from "./http-proxy.js";
|
|
7
8
|
export * from "./license-registration.js";
|
|
8
9
|
export * from "./license-staged.js";
|
package/index.js
CHANGED
|
@@ -5,6 +5,7 @@ export * from "./capabilities-router.js";
|
|
|
5
5
|
export * from "./cjs-interop.js";
|
|
6
6
|
export * from "./dev-url.js";
|
|
7
7
|
export * from "./docker-runner.js";
|
|
8
|
+
export * from "./docs-router.js";
|
|
8
9
|
export * from "./http-proxy.js";
|
|
9
10
|
export * from "./license-registration.js";
|
|
10
11
|
export * from "./license-staged.js";
|