@voyant-travel/hono 0.114.0 → 0.115.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/dist/anonymous-paths.d.ts +15 -0
- package/dist/anonymous-paths.d.ts.map +1 -0
- package/dist/anonymous-paths.js +35 -0
- package/dist/app.d.ts.map +1 -1
- package/dist/app.js +9 -13
- package/dist/composition.d.ts +32 -0
- package/dist/composition.d.ts.map +1 -1
- package/dist/composition.js +28 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/module.d.ts +19 -0
- package/dist/module.d.ts.map +1 -1
- package/dist/mount-paths.d.ts +11 -0
- package/dist/mount-paths.d.ts.map +1 -0
- package/dist/mount-paths.js +19 -0
- package/package.json +5 -5
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { HonoExtension, HonoModule } from "./module.js";
|
|
2
|
+
/**
|
|
3
|
+
* Assemble the anonymous-access allow-list (ADR-0008) from module/extension
|
|
4
|
+
* `anonymous` declarations, unioned with any explicit `publicPaths` the
|
|
5
|
+
* deployment still passes (the escape hatch — e.g. plugin/webhook routes that
|
|
6
|
+
* aren't owned by a module, like a payment-processor callback).
|
|
7
|
+
*
|
|
8
|
+
* For each declaring unit the public mount is `resolveSurfaceMountPath` of its
|
|
9
|
+
* `publicPath`/name under `/v1/public`. `anonymous: true` opens the whole mount;
|
|
10
|
+
* a string array opens specific sub-paths relative to it. Pure and sorted for a
|
|
11
|
+
* deterministic, snapshot-auditable result; the global list is what `requireAuth`
|
|
12
|
+
* matches to skip auth (and stamp `actor: "customer"`).
|
|
13
|
+
*/
|
|
14
|
+
export declare function assembleAnonymousPaths(modules: readonly HonoModule[], extensions: readonly HonoExtension[], explicit?: readonly string[]): string[];
|
|
15
|
+
//# sourceMappingURL=anonymous-paths.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"anonymous-paths.d.ts","sourceRoot":"","sources":["../src/anonymous-paths.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAG5D;;;;;;;;;;;GAWG;AACH,wBAAgB,sBAAsB,CACpC,OAAO,EAAE,SAAS,UAAU,EAAE,EAC9B,UAAU,EAAE,SAAS,aAAa,EAAE,EACpC,QAAQ,GAAE,SAAS,MAAM,EAAO,GAC/B,MAAM,EAAE,CAuBV"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { resolveSurfaceMountPath } from "./mount-paths.js";
|
|
2
|
+
/**
|
|
3
|
+
* Assemble the anonymous-access allow-list (ADR-0008) from module/extension
|
|
4
|
+
* `anonymous` declarations, unioned with any explicit `publicPaths` the
|
|
5
|
+
* deployment still passes (the escape hatch — e.g. plugin/webhook routes that
|
|
6
|
+
* aren't owned by a module, like a payment-processor callback).
|
|
7
|
+
*
|
|
8
|
+
* For each declaring unit the public mount is `resolveSurfaceMountPath` of its
|
|
9
|
+
* `publicPath`/name under `/v1/public`. `anonymous: true` opens the whole mount;
|
|
10
|
+
* a string array opens specific sub-paths relative to it. Pure and sorted for a
|
|
11
|
+
* deterministic, snapshot-auditable result; the global list is what `requireAuth`
|
|
12
|
+
* matches to skip auth (and stamp `actor: "customer"`).
|
|
13
|
+
*/
|
|
14
|
+
export function assembleAnonymousPaths(modules, extensions, explicit = []) {
|
|
15
|
+
const paths = new Set(explicit);
|
|
16
|
+
const add = (mount, anonymous) => {
|
|
17
|
+
if (!anonymous)
|
|
18
|
+
return;
|
|
19
|
+
if (anonymous === true) {
|
|
20
|
+
paths.add(mount);
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
for (const sub of anonymous) {
|
|
24
|
+
const trimmed = sub.trim().replace(/^\/+|\/+$/g, "");
|
|
25
|
+
paths.add(trimmed ? `${mount}/${trimmed}` : mount);
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
for (const m of modules) {
|
|
29
|
+
add(resolveSurfaceMountPath("/v1/public", m.publicPath, m.module.name), m.anonymous);
|
|
30
|
+
}
|
|
31
|
+
for (const e of extensions) {
|
|
32
|
+
add(resolveSurfaceMountPath("/v1/public", e.publicPath, e.extension.module), e.anonymous);
|
|
33
|
+
}
|
|
34
|
+
return [...paths].sort();
|
|
35
|
+
}
|
package/dist/app.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app.d.ts","sourceRoot":"","sources":["../src/app.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAA;
|
|
1
|
+
{"version":3,"file":"app.d.ts","sourceRoot":"","sources":["../src/app.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAA;AAkC3B,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAY,eAAe,EAAE,MAAM,YAAY,CAAA;AAyB5F;;;;;;;;;;GAUG;AACH,MAAM,WAAW,mBAAmB,CAAC,SAAS,GAAG,OAAO;IACtD;;;;;;;;;;;OAWG;IACH,KAAK,CAAC,QAAQ,CAAC,EAAE,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IAC1C;;;;;;;;OAQG;IACH,QAAQ,EAAE,OAAO,qBAAqB,EAAE,QAAQ,CAAA;CACjD;AAED;;;;;;GAMG;AACH,wBAAgB,QAAQ,CAAC,SAAS,SAAS,cAAc,EACvD,MAAM,EAAE,eAAe,CAAC,SAAS,CAAC,GACjC,IAAI,CAAC;IAAE,QAAQ,EAAE,SAAS,CAAC;IAAC,SAAS,EAAE,eAAe,CAAA;CAAE,CAAC,GAAG,mBAAmB,CAAC,SAAS,CAAC,CAyc5F"}
|
package/dist/app.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { createContainer, createEventBus, createQueryRunner, } from "@voyant-travel/core";
|
|
2
2
|
import { createOutboxEventStore } from "@voyant-travel/db/outbox";
|
|
3
3
|
import { Hono } from "hono";
|
|
4
|
+
import { assembleAnonymousPaths } from "./anonymous-paths.js";
|
|
4
5
|
import { containerToServiceResolver, makeFrameworkLogger, wireWorkflowRuntime, } from "./app-workflows.js";
|
|
5
6
|
import { mountLazyRoutePaths, mountLazyRoutesAt } from "./lazy-routes.js";
|
|
6
7
|
import { mountAuthForwarding } from "./lib/auth-forward.js";
|
|
@@ -19,19 +20,10 @@ import { publicResponseCache } from "./middleware/public-cache.js";
|
|
|
19
20
|
import { rateLimit, resolveRateLimitStore, } from "./middleware/rate-limit.js";
|
|
20
21
|
import { requireActor } from "./middleware/require-actor.js";
|
|
21
22
|
import { securityHeaders } from "./middleware/security-headers.js";
|
|
23
|
+
import { resolveSurfaceMountPath } from "./mount-paths.js";
|
|
22
24
|
import { noopReporter, safeCaptureException } from "./observability/reporter.js";
|
|
23
25
|
import { getRequestId } from "./observability/request-context.js";
|
|
24
26
|
import { expandHonoPlugins } from "./plugin.js";
|
|
25
|
-
function resolveSurfaceMountPath(prefix, path, fallback) {
|
|
26
|
-
const normalized = path?.trim();
|
|
27
|
-
if (!normalized) {
|
|
28
|
-
return `${prefix}/${fallback}`;
|
|
29
|
-
}
|
|
30
|
-
if (normalized === "/") {
|
|
31
|
-
return prefix;
|
|
32
|
-
}
|
|
33
|
-
return `${prefix}/${normalized.replace(/^\/+|\/+$/g, "")}`;
|
|
34
|
-
}
|
|
35
27
|
const WRITE_METHODS = new Set(["POST", "PUT", "PATCH", "DELETE"]);
|
|
36
28
|
function resolveConfiguredRateLimitStore(config, env) {
|
|
37
29
|
if (!config?.store)
|
|
@@ -63,6 +55,11 @@ export function mountApp(config) {
|
|
|
63
55
|
const expanded = config.plugins ? expandHonoPlugins(config.plugins) : null;
|
|
64
56
|
const allModules = [...(config.modules ?? []), ...(expanded?.modules ?? [])];
|
|
65
57
|
const allExtensions = [...(config.extensions ?? []), ...(expanded?.extensions ?? [])];
|
|
58
|
+
// Anonymous-access allow-list (ADR-0008): assembled from module/extension
|
|
59
|
+
// `anonymous` declarations + any explicit `publicPaths` escape-hatch entries.
|
|
60
|
+
// Used by both the auth middleware (skip auth / stamp customer actor) and the
|
|
61
|
+
// public-write rate-limit matcher below, so the two never diverge.
|
|
62
|
+
const anonymousPaths = assembleAnonymousPaths(allModules, allExtensions, config.publicPaths);
|
|
66
63
|
// When the framework owns the bus, route subscriber-dispatch failures
|
|
67
64
|
// (including the workflow forwarder) to the reporter — they're otherwise
|
|
68
65
|
// only console-logged per the fire-and-forget EventBus contract (RFC #1553).
|
|
@@ -235,8 +232,7 @@ export function mountApp(config) {
|
|
|
235
232
|
if (!WRITE_METHODS.has(c.req.method))
|
|
236
233
|
return next();
|
|
237
234
|
const pathname = normalizePathname(new URL(c.req.url).pathname);
|
|
238
|
-
const isPublicWrite = pathname.startsWith("/v1/public/") ||
|
|
239
|
-
matchesPublicPath(pathname, config.publicPaths ?? []);
|
|
235
|
+
const isPublicWrite = pathname.startsWith("/v1/public/") || matchesPublicPath(pathname, anonymousPaths);
|
|
240
236
|
if (!isPublicWrite)
|
|
241
237
|
return next();
|
|
242
238
|
return rateLimit(buildRateLimitPolicy(rateLimitConfig, c.env, "public-write", publicWriteRule))(c, next);
|
|
@@ -356,7 +352,7 @@ export function mountApp(config) {
|
|
|
356
352
|
})
|
|
357
353
|
: config.db;
|
|
358
354
|
// Auth middleware for all other routes
|
|
359
|
-
app.use("*", requireAuth(dbSource, { publicPaths:
|
|
355
|
+
app.use("*", requireAuth(dbSource, { publicPaths: anonymousPaths, auth: config.auth }));
|
|
360
356
|
// DB middleware — sets c.var.db for all downstream handlers.
|
|
361
357
|
// Pass the list of modules that need interactive transactions so the
|
|
362
358
|
// middleware can throw a clear startup-style error on first request if
|
package/dist/composition.d.ts
CHANGED
|
@@ -52,6 +52,38 @@ export interface ComposedApp {
|
|
|
52
52
|
* wired" fails loudly at boot rather than silently dropping a module.
|
|
53
53
|
*/
|
|
54
54
|
export declare function composeFromManifest<TCapabilities>(manifest: CompositionManifest, registry: CompositionRegistry<TCapabilities>, capabilities: TCapabilities): ComposedApp;
|
|
55
|
+
/**
|
|
56
|
+
* A module's place in the capability dependency graph (ADR-0007). `provides`
|
|
57
|
+
* are capability tokens the module supplies (e.g. `"people-directory"`);
|
|
58
|
+
* `requires` are tokens it depends on another mounted module — or an injected
|
|
59
|
+
* substitute — to supply. Tokens are opaque strings; the graph is the contract
|
|
60
|
+
* between modules, decoupled from concrete service shapes.
|
|
61
|
+
*
|
|
62
|
+
* `isRequired` marks a module the platform cannot run without: it can be
|
|
63
|
+
* *overridden* by a substitute (a future capability) but never `exclude`d.
|
|
64
|
+
*/
|
|
65
|
+
export interface CapabilityDeclaration {
|
|
66
|
+
provides?: readonly string[];
|
|
67
|
+
requires?: readonly string[];
|
|
68
|
+
isRequired?: boolean;
|
|
69
|
+
}
|
|
70
|
+
/** Maps a module specifier to its capability declaration. */
|
|
71
|
+
export type CapabilityGraph = Record<string, CapabilityDeclaration>;
|
|
72
|
+
/** An unmet `requires`: a capability no mounted module (nor a substitute) provides. */
|
|
73
|
+
export interface CapabilityGap {
|
|
74
|
+
capability: string;
|
|
75
|
+
/** Specifiers of the still-mounted modules that require the missing capability. */
|
|
76
|
+
requiredBy: string[];
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Pure dependency-graph check for module subsetting (ADR-0007). Given the
|
|
80
|
+
* specifiers that will actually mount (after any `exclude`) and the capability
|
|
81
|
+
* graph, return the gaps: required capabilities that nothing still-mounted
|
|
82
|
+
* provides. An empty array means the subset is safe to compose. Callers turn a
|
|
83
|
+
* non-empty result into a build/boot error so dropping a depended-on module
|
|
84
|
+
* fails loudly here rather than as a runtime 500.
|
|
85
|
+
*/
|
|
86
|
+
export declare function findCapabilityGaps(mountedSpecifiers: readonly string[], graph: CapabilityGraph): CapabilityGap[];
|
|
55
87
|
export interface ManifestRegistryDiff {
|
|
56
88
|
/** In the manifest but with no registered factory. */
|
|
57
89
|
missingFactories: string[];
|
|
@@ -1 +1 @@
|
|
|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EAAE,gBAAgB,EAAE,EACnC,YAAY,EAAE,MAAM,EAAE,GACrB,oBAAoB,CAOtB"}
|
package/dist/composition.js
CHANGED
|
@@ -31,6 +31,34 @@ export function composeFromManifest(manifest, registry, capabilities) {
|
|
|
31
31
|
});
|
|
32
32
|
return { modules, extensions };
|
|
33
33
|
}
|
|
34
|
+
/**
|
|
35
|
+
* Pure dependency-graph check for module subsetting (ADR-0007). Given the
|
|
36
|
+
* specifiers that will actually mount (after any `exclude`) and the capability
|
|
37
|
+
* graph, return the gaps: required capabilities that nothing still-mounted
|
|
38
|
+
* provides. An empty array means the subset is safe to compose. Callers turn a
|
|
39
|
+
* non-empty result into a build/boot error so dropping a depended-on module
|
|
40
|
+
* fails loudly here rather than as a runtime 500.
|
|
41
|
+
*/
|
|
42
|
+
export function findCapabilityGaps(mountedSpecifiers, graph) {
|
|
43
|
+
const provided = new Set();
|
|
44
|
+
for (const spec of mountedSpecifiers) {
|
|
45
|
+
for (const cap of graph[spec]?.provides ?? [])
|
|
46
|
+
provided.add(cap);
|
|
47
|
+
}
|
|
48
|
+
const gaps = new Map();
|
|
49
|
+
for (const spec of mountedSpecifiers) {
|
|
50
|
+
for (const cap of graph[spec]?.requires ?? []) {
|
|
51
|
+
if (provided.has(cap))
|
|
52
|
+
continue;
|
|
53
|
+
const by = gaps.get(cap) ?? new Set();
|
|
54
|
+
by.add(spec);
|
|
55
|
+
gaps.set(cap, by);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
return [...gaps.entries()]
|
|
59
|
+
.map(([capability, by]) => ({ capability, requiredBy: [...by].sort() }))
|
|
60
|
+
.sort((a, b) => a.capability.localeCompare(b.capability));
|
|
61
|
+
}
|
|
34
62
|
/**
|
|
35
63
|
* Pure parity check between a manifest's entries and a registry's keys, for
|
|
36
64
|
* tooling (`voyant db doctor`). Reports manifest entries with no factory and
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export type { VoyantPermission } from "@voyant-travel/core";
|
|
2
|
+
export { assembleAnonymousPaths } from "./anonymous-paths.js";
|
|
2
3
|
export { mountApp } from "./app.js";
|
|
3
4
|
export type { SessionAuthContext } from "./auth/index.js";
|
|
4
5
|
export { constantTimeEqual, extractBearerToken, generateNumericCode, randomBytesHex, requireUserId, sha256Base64Url, sha256Hex, unsignCookie, verifySession, } from "./auth/index.js";
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAA;AAC3D,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAA;AACnC,YAAY,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAA;AACzD,OAAO,EACL,iBAAiB,EACjB,kBAAkB,EAClB,mBAAmB,EACnB,cAAc,EACd,aAAa,EACb,eAAe,EACf,SAAS,EACT,YAAY,EACZ,aAAa,GACd,MAAM,iBAAiB,CAAA;AACxB,OAAO,EAAE,KAAK,eAAe,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AACjE,YAAY,EACV,wBAAwB,EACxB,0BAA0B,EAC1B,wBAAwB,EACxB,8BAA8B,EAC9B,uBAAuB,GACxB,MAAM,wBAAwB,CAAA;AAC/B,OAAO,EAAE,6BAA6B,EAAE,MAAM,wBAAwB,CAAA;AACtE,OAAO,EACL,sBAAsB,EACtB,KAAK,cAAc,EACnB,KAAK,gBAAgB,EACrB,mBAAmB,EACnB,iBAAiB,GAClB,MAAM,kBAAkB,CAAA;AACzB,OAAO,EAAE,oBAAoB,EAAE,KAAK,qBAAqB,EAAE,MAAM,sBAAsB,CAAA;AACvF,OAAO,EACL,WAAW,EACX,qBAAqB,EACrB,IAAI,EACJ,0BAA0B,EAC1B,EAAE,EACF,gBAAgB,EAChB,aAAa,EACb,cAAc,EACd,KAAK,qBAAqB,EAC1B,cAAc,EACd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EACxB,eAAe,GAChB,MAAM,YAAY,CAAA;AACnB,OAAO,EACL,YAAY,EACZ,iBAAiB,EACjB,wBAAwB,EACxB,aAAa,EACb,qBAAqB,EACrB,UAAU,EACV,sBAAsB,EACtB,oBAAoB,GACrB,MAAM,iBAAiB,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
export { assembleAnonymousPaths } from "./anonymous-paths.js";
|
|
1
2
|
export { mountApp } from "./app.js";
|
|
2
3
|
export { constantTimeEqual, extractBearerToken, generateNumericCode, randomBytesHex, requireUserId, sha256Base64Url, sha256Hex, unsignCookie, verifySession, } from "./auth/index.js";
|
|
3
4
|
export { createApp } from "./create-app.js";
|
package/dist/module.d.ts
CHANGED
|
@@ -38,6 +38,19 @@ export interface HonoModule {
|
|
|
38
38
|
* public root and omit the extra module segment.
|
|
39
39
|
*/
|
|
40
40
|
publicPath?: string;
|
|
41
|
+
/**
|
|
42
|
+
* Declares which of this module's PUBLIC routes are reachable without a
|
|
43
|
+
* session (ADR-0008). `true` = the whole public mount is anonymous; a string
|
|
44
|
+
* array = specific sub-paths relative to the public mount (e.g.
|
|
45
|
+
* `["/contact-exists"]` on a module mounted at `/v1/public/customer-portal`
|
|
46
|
+
* opens `/v1/public/customer-portal/contact-exists`). The framework assembles
|
|
47
|
+
* the global anonymous allow-list from these declarations, so the
|
|
48
|
+
* "reachable-without-auth" decision lives next to the route rather than in a
|
|
49
|
+
* hand-maintained `publicPaths` list. Anonymous public requests are stamped
|
|
50
|
+
* `actor: "customer"`. Only affects the public surface — admin routes always
|
|
51
|
+
* require a `staff` actor.
|
|
52
|
+
*/
|
|
53
|
+
anonymous?: boolean | readonly string[];
|
|
41
54
|
}
|
|
42
55
|
export interface HonoExtension {
|
|
43
56
|
extension: Extension;
|
|
@@ -60,5 +73,11 @@ export interface HonoExtension {
|
|
|
60
73
|
* at the public root and omit the extra module segment.
|
|
61
74
|
*/
|
|
62
75
|
publicPath?: string;
|
|
76
|
+
/**
|
|
77
|
+
* Declares which of this extension's PUBLIC routes are reachable without a
|
|
78
|
+
* session (ADR-0008). Same semantics as {@link HonoModule.anonymous}, relative
|
|
79
|
+
* to the extension's public mount.
|
|
80
|
+
*/
|
|
81
|
+
anonymous?: boolean | readonly string[];
|
|
63
82
|
}
|
|
64
83
|
//# sourceMappingURL=module.d.ts.map
|
package/dist/module.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"module.d.ts","sourceRoot":"","sources":["../src/module.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAA;AAC5D,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,MAAM,CAAA;AAEhC,OAAO,KAAK,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAA;AAExE,MAAM,WAAW,UAAU;IACzB,MAAM,EAAE,MAAM,CAAA;IACd;;;;;;OAMG;IAEH,MAAM,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,CAAA;IAClB,kEAAkE;IAElE,WAAW,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,CAAA;IACvB,uFAAuF;IAEvF,YAAY,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,CAAA;IACxB;;;;;OAKG;IACH,eAAe,CAAC,EAAE,gBAAgB,CAAA;IAClC,4FAA4F;IAC5F,gBAAgB,CAAC,EAAE,gBAAgB,CAAA;IACnC;;;;;OAKG;IACH,UAAU,CAAC,EAAE,cAAc,CAAA;IAC3B;;;;;OAKG;IACH,UAAU,CAAC,EAAE,MAAM,CAAA;
|
|
1
|
+
{"version":3,"file":"module.d.ts","sourceRoot":"","sources":["../src/module.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAA;AAC5D,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,MAAM,CAAA;AAEhC,OAAO,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2
|
+
* Resolve a route family's mount path under a surface prefix (`/v1/admin`,
|
|
3
|
+
* `/v1/public`). `path` is the optional `publicPath` override: empty →
|
|
4
|
+
* `{prefix}/{fallback}` (the module/extension name); `"/"` → the surface root
|
|
5
|
+
* (`prefix`); otherwise `{prefix}/{trimmed path}`.
|
|
6
|
+
*
|
|
7
|
+
* Shared by the route mounting in `app.ts` and the anonymous-path assembly in
|
|
8
|
+
* `anonymous-paths.ts` so both compute the same mount.
|
|
9
|
+
*/
|
|
10
|
+
export declare function resolveSurfaceMountPath(prefix: string, path: string | undefined, fallback: string): string;
|
|
11
|
+
//# sourceMappingURL=mount-paths.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mount-paths.d.ts","sourceRoot":"","sources":["../src/mount-paths.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,wBAAgB,uBAAuB,CACrC,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,GAAG,SAAS,EACxB,QAAQ,EAAE,MAAM,GACf,MAAM,CAYR"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Resolve a route family's mount path under a surface prefix (`/v1/admin`,
|
|
3
|
+
* `/v1/public`). `path` is the optional `publicPath` override: empty →
|
|
4
|
+
* `{prefix}/{fallback}` (the module/extension name); `"/"` → the surface root
|
|
5
|
+
* (`prefix`); otherwise `{prefix}/{trimmed path}`.
|
|
6
|
+
*
|
|
7
|
+
* Shared by the route mounting in `app.ts` and the anonymous-path assembly in
|
|
8
|
+
* `anonymous-paths.ts` so both compute the same mount.
|
|
9
|
+
*/
|
|
10
|
+
export function resolveSurfaceMountPath(prefix, path, fallback) {
|
|
11
|
+
const normalized = path?.trim();
|
|
12
|
+
if (!normalized) {
|
|
13
|
+
return `${prefix}/${fallback}`;
|
|
14
|
+
}
|
|
15
|
+
if (normalized === "/") {
|
|
16
|
+
return prefix;
|
|
17
|
+
}
|
|
18
|
+
return `${prefix}/${normalized.replace(/^\/+|\/+$/g, "")}`;
|
|
19
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@voyant-travel/hono",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.115.0",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -127,16 +127,16 @@
|
|
|
127
127
|
"@voyant-travel/core": "^0.111.0",
|
|
128
128
|
"@voyant-travel/db": "^0.109.0",
|
|
129
129
|
"@voyant-travel/storage": "^0.105.0",
|
|
130
|
-
"@voyant-travel/types": "^0.
|
|
131
|
-
"@voyant-travel/utils": "^0.105.
|
|
132
|
-
"@voyant-travel/workflows": "^0.111.
|
|
130
|
+
"@voyant-travel/types": "^0.106.0",
|
|
131
|
+
"@voyant-travel/utils": "^0.105.4",
|
|
132
|
+
"@voyant-travel/workflows": "^0.111.5"
|
|
133
133
|
},
|
|
134
134
|
"devDependencies": {
|
|
135
135
|
"@cloudflare/workers-types": "^4.20260426.1",
|
|
136
136
|
"typescript": "^6.0.2",
|
|
137
137
|
"vitest": "^4.1.2",
|
|
138
138
|
"@voyant-travel/voyant-typescript-config": "^0.1.0",
|
|
139
|
-
"@voyant-travel/workflows-orchestrator": "^0.111.
|
|
139
|
+
"@voyant-travel/workflows-orchestrator": "^0.111.5"
|
|
140
140
|
},
|
|
141
141
|
"files": [
|
|
142
142
|
"dist"
|