@voyant-travel/operator-settings 0.1.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/hono-module.d.ts +11 -0
- package/dist/hono-module.d.ts.map +1 -0
- package/dist/hono-module.js +26 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +11 -0
- package/dist/routes.d.ts +9 -0
- package/dist/routes.d.ts.map +1 -0
- package/dist/routes.js +79 -0
- package/dist/schema.d.ts +984 -0
- package/dist/schema.d.ts.map +1 -0
- package/dist/schema.js +124 -0
- package/dist/service.d.ts +187 -0
- package/dist/service.d.ts.map +1 -0
- package/dist/service.js +265 -0
- package/dist/service.test.d.ts +2 -0
- package/dist/service.test.d.ts.map +1 -0
- package/dist/service.test.js +71 -0
- package/package.json +80 -0
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `@voyant-travel/operator-settings` HonoModule — the standard settings
|
|
3
|
+
* surface mounted by `@voyant-travel/framework`'s composition. Routes live at
|
|
4
|
+
* stable absolute paths, so the module uses `lazyRoutes` (explicit matchers +
|
|
5
|
+
* a lazily-imported route bundle, cached per isolate).
|
|
6
|
+
*/
|
|
7
|
+
import type { HonoModule } from "@voyant-travel/hono/module";
|
|
8
|
+
/** Stable absolute matchers for the operator-settings admin + public routes. */
|
|
9
|
+
export declare const OPERATOR_SETTINGS_ROUTE_PATHS: readonly ["/v1/admin/settings/*", "/v1/public/operator-profile", "/v1/public/settings/operator"];
|
|
10
|
+
export declare function createOperatorSettingsHonoModule(): HonoModule;
|
|
11
|
+
//# sourceMappingURL=hono-module.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hono-module.d.ts","sourceRoot":"","sources":["../src/hono-module.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAA;AAG5D,gFAAgF;AAChF,eAAO,MAAM,6BAA6B,kGAIhC,CAAA;AAEV,wBAAgB,gCAAgC,IAAI,UAAU,CAa7D"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `@voyant-travel/operator-settings` HonoModule — the standard settings
|
|
3
|
+
* surface mounted by `@voyant-travel/framework`'s composition. Routes live at
|
|
4
|
+
* stable absolute paths, so the module uses `lazyRoutes` (explicit matchers +
|
|
5
|
+
* a lazily-imported route bundle, cached per isolate).
|
|
6
|
+
*/
|
|
7
|
+
import { Hono } from "hono";
|
|
8
|
+
/** Stable absolute matchers for the operator-settings admin + public routes. */
|
|
9
|
+
export const OPERATOR_SETTINGS_ROUTE_PATHS = [
|
|
10
|
+
"/v1/admin/settings/*",
|
|
11
|
+
"/v1/public/operator-profile",
|
|
12
|
+
"/v1/public/settings/operator",
|
|
13
|
+
];
|
|
14
|
+
export function createOperatorSettingsHonoModule() {
|
|
15
|
+
return {
|
|
16
|
+
module: { name: "operator-settings" },
|
|
17
|
+
lazyRoutes: {
|
|
18
|
+
paths: OPERATOR_SETTINGS_ROUTE_PATHS,
|
|
19
|
+
load: () => import("./routes.js").then((m) => {
|
|
20
|
+
const app = new Hono();
|
|
21
|
+
m.mountOperatorSettingsRoutes(app);
|
|
22
|
+
return app;
|
|
23
|
+
}),
|
|
24
|
+
},
|
|
25
|
+
};
|
|
26
|
+
}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@voyant-travel/operator-settings` — the operator-tenant settings domain:
|
|
3
|
+
* profile + payment instructions/defaults + booking-tax configuration.
|
|
4
|
+
*
|
|
5
|
+
* Schema (`./schema`) + transport-agnostic readers/writers (`./service`). A
|
|
6
|
+
* deployment lists this in `voyant.config` `additionalSchemas`, mounts HTTP
|
|
7
|
+
* routes over the service, and injects the readers into the standard modules
|
|
8
|
+
* that consume operator settings.
|
|
9
|
+
*/
|
|
10
|
+
export * from "./schema.js";
|
|
11
|
+
export * from "./service.js";
|
|
12
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,cAAc,aAAa,CAAA;AAC3B,cAAc,cAAc,CAAA"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@voyant-travel/operator-settings` — the operator-tenant settings domain:
|
|
3
|
+
* profile + payment instructions/defaults + booking-tax configuration.
|
|
4
|
+
*
|
|
5
|
+
* Schema (`./schema`) + transport-agnostic readers/writers (`./service`). A
|
|
6
|
+
* deployment lists this in `voyant.config` `additionalSchemas`, mounts HTTP
|
|
7
|
+
* routes over the service, and injects the readers into the standard modules
|
|
8
|
+
* that consume operator settings.
|
|
9
|
+
*/
|
|
10
|
+
export * from "./schema.js";
|
|
11
|
+
export * from "./service.js";
|
package/dist/routes.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Operator settings HTTP routes — the admin/public CRUD surface over the
|
|
3
|
+
* settings service. Absolute paths (kept stable from the prior deployment-local
|
|
4
|
+
* routes): `/v1/admin/settings/*`, `/v1/public/operator-profile`,
|
|
5
|
+
* `/v1/public/settings/operator`.
|
|
6
|
+
*/
|
|
7
|
+
import type { Hono } from "hono";
|
|
8
|
+
export declare function mountOperatorSettingsRoutes(hono: Hono): void;
|
|
9
|
+
//# sourceMappingURL=routes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"routes.d.ts","sourceRoot":"","sources":["../src/routes.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,KAAK,EAAW,IAAI,EAAE,MAAM,MAAM,CAAA;AAwFzC,wBAAgB,2BAA2B,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI,CAe5D"}
|
package/dist/routes.js
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Operator settings HTTP routes — the admin/public CRUD surface over the
|
|
3
|
+
* settings service. Absolute paths (kept stable from the prior deployment-local
|
|
4
|
+
* routes): `/v1/admin/settings/*`, `/v1/public/operator-profile`,
|
|
5
|
+
* `/v1/public/settings/operator`.
|
|
6
|
+
*/
|
|
7
|
+
import { parseJsonBody } from "@voyant-travel/hono";
|
|
8
|
+
import { getOperatorPaymentDefaults, getOperatorPaymentInstructions, getOperatorProfile, getOperatorSettings, toPublicOperatorProfile, toPublicOperatorSettings, updateOperatorPaymentDefaultsSchema, updateOperatorPaymentInstructionsSchema, updateOperatorProfileSchema, updateOperatorSettingsSchema, upsertOperatorPaymentDefaults, upsertOperatorPaymentInstructions, upsertOperatorProfile, upsertOperatorSettings, } from "./service.js";
|
|
9
|
+
const PUBLIC_OPERATOR_SETTINGS_CACHE_CONTROL = "public, s-maxage=300, stale-while-revalidate=600";
|
|
10
|
+
function cachePublicOperatorSettings(c) {
|
|
11
|
+
c.header("Cache-Control", PUBLIC_OPERATOR_SETTINGS_CACHE_CONTROL);
|
|
12
|
+
}
|
|
13
|
+
async function handleGetOperatorProfile(c) {
|
|
14
|
+
const db = c.get("db");
|
|
15
|
+
return c.json({ data: await getOperatorProfile(db) });
|
|
16
|
+
}
|
|
17
|
+
async function handlePatchOperatorProfile(c) {
|
|
18
|
+
const db = c.get("db");
|
|
19
|
+
const patch = await parseJsonBody(c, updateOperatorProfileSchema);
|
|
20
|
+
return c.json({ data: await upsertOperatorProfile(db, patch) });
|
|
21
|
+
}
|
|
22
|
+
async function handleGetOperatorPaymentInstructions(c) {
|
|
23
|
+
const db = c.get("db");
|
|
24
|
+
return c.json({ data: await getOperatorPaymentInstructions(db) });
|
|
25
|
+
}
|
|
26
|
+
async function handlePatchOperatorPaymentInstructions(c) {
|
|
27
|
+
const db = c.get("db");
|
|
28
|
+
const patch = await parseJsonBody(c, updateOperatorPaymentInstructionsSchema);
|
|
29
|
+
return c.json({ data: await upsertOperatorPaymentInstructions(db, patch) });
|
|
30
|
+
}
|
|
31
|
+
async function handleGetOperatorPaymentDefaults(c) {
|
|
32
|
+
const db = c.get("db");
|
|
33
|
+
return c.json({ data: await getOperatorPaymentDefaults(db) });
|
|
34
|
+
}
|
|
35
|
+
async function handlePatchOperatorPaymentDefaults(c) {
|
|
36
|
+
const db = c.get("db");
|
|
37
|
+
const patch = await parseJsonBody(c, updateOperatorPaymentDefaultsSchema);
|
|
38
|
+
return c.json({ data: await upsertOperatorPaymentDefaults(db, patch) });
|
|
39
|
+
}
|
|
40
|
+
async function handleGetPublicOperatorProfile(c) {
|
|
41
|
+
const db = c.get("db");
|
|
42
|
+
const [profile, defaults] = await Promise.all([
|
|
43
|
+
getOperatorProfile(db),
|
|
44
|
+
getOperatorPaymentDefaults(db),
|
|
45
|
+
]);
|
|
46
|
+
cachePublicOperatorSettings(c);
|
|
47
|
+
if (!profile)
|
|
48
|
+
return c.json({ data: null });
|
|
49
|
+
return c.json({ data: toPublicOperatorProfile(profile, defaults) });
|
|
50
|
+
}
|
|
51
|
+
async function handleGetOperatorSettings(c) {
|
|
52
|
+
const db = c.get("db");
|
|
53
|
+
return c.json({ data: await getOperatorSettings(db) });
|
|
54
|
+
}
|
|
55
|
+
async function handlePatchOperatorSettings(c) {
|
|
56
|
+
const db = c.get("db");
|
|
57
|
+
const patch = await parseJsonBody(c, updateOperatorSettingsSchema);
|
|
58
|
+
return c.json({ data: await upsertOperatorSettings(db, patch) });
|
|
59
|
+
}
|
|
60
|
+
async function handleGetPublicOperatorSettings(c) {
|
|
61
|
+
const db = c.get("db");
|
|
62
|
+
const row = await getOperatorSettings(db);
|
|
63
|
+
cachePublicOperatorSettings(c);
|
|
64
|
+
if (!row)
|
|
65
|
+
return c.json({ data: null });
|
|
66
|
+
return c.json({ data: toPublicOperatorSettings(row) });
|
|
67
|
+
}
|
|
68
|
+
export function mountOperatorSettingsRoutes(hono) {
|
|
69
|
+
hono.get("/v1/admin/settings/operator-profile", handleGetOperatorProfile);
|
|
70
|
+
hono.patch("/v1/admin/settings/operator-profile", handlePatchOperatorProfile);
|
|
71
|
+
hono.get("/v1/admin/settings/operator-payment-instructions", handleGetOperatorPaymentInstructions);
|
|
72
|
+
hono.patch("/v1/admin/settings/operator-payment-instructions", handlePatchOperatorPaymentInstructions);
|
|
73
|
+
hono.get("/v1/admin/settings/operator-payment-defaults", handleGetOperatorPaymentDefaults);
|
|
74
|
+
hono.patch("/v1/admin/settings/operator-payment-defaults", handlePatchOperatorPaymentDefaults);
|
|
75
|
+
hono.get("/v1/public/operator-profile", handleGetPublicOperatorProfile);
|
|
76
|
+
hono.get("/v1/admin/settings/operator", handleGetOperatorSettings);
|
|
77
|
+
hono.patch("/v1/admin/settings/operator", handlePatchOperatorSettings);
|
|
78
|
+
hono.get("/v1/public/settings/operator", handleGetPublicOperatorSettings);
|
|
79
|
+
}
|