@voyant-travel/operator-settings 0.2.17 → 0.2.19
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 +4 -0
- package/dist/hono-module.d.ts.map +1 -1
- package/dist/hono-module.js +7 -2
- package/dist/routes.d.ts +25 -1
- package/dist/routes.d.ts.map +1 -1
- package/dist/routes.js +214 -64
- package/dist/service.d.ts +12 -12
- package/package.json +7 -6
package/dist/hono-module.d.ts
CHANGED
|
@@ -3,6 +3,10 @@
|
|
|
3
3
|
* surface mounted by `@voyant-travel/framework`'s composition. Routes live at
|
|
4
4
|
* stable absolute paths, so the module uses `lazyRoutes` (explicit matchers +
|
|
5
5
|
* a lazily-imported route bundle, cached per isolate).
|
|
6
|
+
*
|
|
7
|
+
* The loaded bundle is an `OpenAPIHono` (carrying the `defaultHook` that shapes
|
|
8
|
+
* request-validation failures) so its `createRoute(...).openapi(...)` operations
|
|
9
|
+
* are visible to the build-time `mergeLazyOpenApiPaths` replay (voyant#2114).
|
|
6
10
|
*/
|
|
7
11
|
import type { HonoModule } from "@voyant-travel/hono/module";
|
|
8
12
|
/** Stable absolute matchers for the operator-settings admin + public routes. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hono-module.d.ts","sourceRoot":"","sources":["../src/hono-module.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"hono-module.d.ts","sourceRoot":"","sources":["../src/hono-module.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAIH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAA;AAE5D,gFAAgF;AAChF,eAAO,MAAM,6BAA6B,kGAIhC,CAAA;AAEV,wBAAgB,gCAAgC,IAAI,UAAU,CAa7D"}
|
package/dist/hono-module.js
CHANGED
|
@@ -3,8 +3,13 @@
|
|
|
3
3
|
* surface mounted by `@voyant-travel/framework`'s composition. Routes live at
|
|
4
4
|
* stable absolute paths, so the module uses `lazyRoutes` (explicit matchers +
|
|
5
5
|
* a lazily-imported route bundle, cached per isolate).
|
|
6
|
+
*
|
|
7
|
+
* The loaded bundle is an `OpenAPIHono` (carrying the `defaultHook` that shapes
|
|
8
|
+
* request-validation failures) so its `createRoute(...).openapi(...)` operations
|
|
9
|
+
* are visible to the build-time `mergeLazyOpenApiPaths` replay (voyant#2114).
|
|
6
10
|
*/
|
|
7
|
-
import {
|
|
11
|
+
import { OpenAPIHono } from "@hono/zod-openapi";
|
|
12
|
+
import { openApiValidationHook } from "@voyant-travel/hono";
|
|
8
13
|
/** Stable absolute matchers for the operator-settings admin + public routes. */
|
|
9
14
|
export const OPERATOR_SETTINGS_ROUTE_PATHS = [
|
|
10
15
|
"/v1/admin/settings/*",
|
|
@@ -17,7 +22,7 @@ export function createOperatorSettingsHonoModule() {
|
|
|
17
22
|
lazyRoutes: {
|
|
18
23
|
paths: OPERATOR_SETTINGS_ROUTE_PATHS,
|
|
19
24
|
load: () => import("./routes.js").then((m) => {
|
|
20
|
-
const app = new
|
|
25
|
+
const app = new OpenAPIHono({ defaultHook: openApiValidationHook });
|
|
21
26
|
m.mountOperatorSettingsRoutes(app);
|
|
22
27
|
return app;
|
|
23
28
|
}),
|
package/dist/routes.d.ts
CHANGED
|
@@ -3,7 +3,31 @@
|
|
|
3
3
|
* settings service. Absolute paths (kept stable from the prior deployment-local
|
|
4
4
|
* routes): `/v1/admin/settings/*`, `/v1/public/operator-profile`,
|
|
5
5
|
* `/v1/public/settings/operator`.
|
|
6
|
+
*
|
|
7
|
+
* Migrated to `@hono/zod-openapi` for the OpenAPI admin backfill (voyant#2114 —
|
|
8
|
+
* operator-settings batch). The legs are authored as `createRoute(...).openapi(...)`
|
|
9
|
+
* on a child `OpenAPIHono<Env>` chain (carrying the shared `openApiValidationHook`),
|
|
10
|
+
* composed onto the supplied mount target via `.route("/", child)`. The module is
|
|
11
|
+
* mounted lazily (see `hono-module.ts`), which builds an `OpenAPIHono` so the
|
|
12
|
+
* build-time `mergeLazyOpenApiPaths` replay reads these `.openapi()` operations
|
|
13
|
+
* and surfaces them in the operator spec.
|
|
14
|
+
*
|
|
15
|
+
* PATCH legs reuse the package's existing `update*Schema` validation as the
|
|
16
|
+
* request body and read the validated patch via `c.req.valid("json")` (the child
|
|
17
|
+
* chain's `defaultHook` shapes invalid input). Response row schemas are authored
|
|
18
|
+
* here from the Drizzle `$inferSelect` shapes (§17: timestamps → ISO strings;
|
|
19
|
+
* opaque jsonb payment-policy blobs are pass-throughs). Single-row readers return
|
|
20
|
+
* `null` when unset, so every `{ data }` envelope is nullable. Business logic is
|
|
21
|
+
* unchanged.
|
|
6
22
|
*/
|
|
7
23
|
import type { Hono } from "hono";
|
|
8
|
-
|
|
24
|
+
/**
|
|
25
|
+
* Structural mount target — just the `.route()` surface this function uses.
|
|
26
|
+
* Decoupled from Hono's full generic signature so the lazy loader can pass its
|
|
27
|
+
* `OpenAPIHono` instance without coupling to its Env/Schema/BasePath params.
|
|
28
|
+
*/
|
|
29
|
+
export interface OpenApiMountTarget {
|
|
30
|
+
route(path: string, app: Hono<any, any, any>): unknown;
|
|
31
|
+
}
|
|
32
|
+
export declare function mountOperatorSettingsRoutes(hono: OpenApiMountTarget): void;
|
|
9
33
|
//# sourceMappingURL=routes.d.ts.map
|
package/dist/routes.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"routes.d.ts","sourceRoot":"","sources":["../src/routes.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"routes.d.ts","sourceRoot":"","sources":["../src/routes.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAKH,OAAO,KAAK,EAAW,IAAI,EAAE,MAAM,MAAM,CAAA;AAqBzC;;;;GAIG;AACH,MAAM,WAAW,kBAAkB;IAEjC,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,IAAI,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,GAAG,OAAO,CAAA;CACvD;AAmOD,wBAAgB,2BAA2B,CAAC,IAAI,EAAE,kBAAkB,GAAG,IAAI,CA4E1E"}
|
package/dist/routes.js
CHANGED
|
@@ -3,77 +3,227 @@
|
|
|
3
3
|
* settings service. Absolute paths (kept stable from the prior deployment-local
|
|
4
4
|
* routes): `/v1/admin/settings/*`, `/v1/public/operator-profile`,
|
|
5
5
|
* `/v1/public/settings/operator`.
|
|
6
|
+
*
|
|
7
|
+
* Migrated to `@hono/zod-openapi` for the OpenAPI admin backfill (voyant#2114 —
|
|
8
|
+
* operator-settings batch). The legs are authored as `createRoute(...).openapi(...)`
|
|
9
|
+
* on a child `OpenAPIHono<Env>` chain (carrying the shared `openApiValidationHook`),
|
|
10
|
+
* composed onto the supplied mount target via `.route("/", child)`. The module is
|
|
11
|
+
* mounted lazily (see `hono-module.ts`), which builds an `OpenAPIHono` so the
|
|
12
|
+
* build-time `mergeLazyOpenApiPaths` replay reads these `.openapi()` operations
|
|
13
|
+
* and surfaces them in the operator spec.
|
|
14
|
+
*
|
|
15
|
+
* PATCH legs reuse the package's existing `update*Schema` validation as the
|
|
16
|
+
* request body and read the validated patch via `c.req.valid("json")` (the child
|
|
17
|
+
* chain's `defaultHook` shapes invalid input). Response row schemas are authored
|
|
18
|
+
* here from the Drizzle `$inferSelect` shapes (§17: timestamps → ISO strings;
|
|
19
|
+
* opaque jsonb payment-policy blobs are pass-throughs). Single-row readers return
|
|
20
|
+
* `null` when unset, so every `{ data }` envelope is nullable. Business logic is
|
|
21
|
+
* unchanged.
|
|
6
22
|
*/
|
|
7
|
-
import {
|
|
23
|
+
import { createRoute, OpenAPIHono, z } from "@hono/zod-openapi";
|
|
24
|
+
import { openApiValidationHook } from "@voyant-travel/hono";
|
|
8
25
|
import { getOperatorPaymentDefaults, getOperatorPaymentInstructions, getOperatorProfile, getOperatorSettings, toPublicOperatorProfile, toPublicOperatorSettings, updateOperatorPaymentDefaultsSchema, updateOperatorPaymentInstructionsSchema, updateOperatorProfileSchema, updateOperatorSettingsSchema, upsertOperatorPaymentDefaults, upsertOperatorPaymentInstructions, upsertOperatorProfile, upsertOperatorSettings, } from "./service.js";
|
|
9
26
|
const PUBLIC_OPERATOR_SETTINGS_CACHE_CONTROL = "public, s-maxage=300, stale-while-revalidate=600";
|
|
10
27
|
function cachePublicOperatorSettings(c) {
|
|
11
28
|
c.header("Cache-Control", PUBLIC_OPERATOR_SETTINGS_CACHE_CONTROL);
|
|
12
29
|
}
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
30
|
+
// ──────────────────────────────────────────────────────────────────
|
|
31
|
+
// Response schemas (Drizzle `$inferSelect` → wire shapes)
|
|
32
|
+
// ──────────────────────────────────────────────────────────────────
|
|
33
|
+
const isoTimestamp = z.string();
|
|
34
|
+
/** Opaque jsonb payment-policy blob (mirrors finance `PaymentPolicy`). */
|
|
35
|
+
const opaqueJson = z.unknown().nullable();
|
|
36
|
+
/** `operator_profile` row. All identity/contact columns are nullable text. */
|
|
37
|
+
const operatorProfileRowSchema = z.object({
|
|
38
|
+
id: z.string(),
|
|
39
|
+
name: z.string().nullable(),
|
|
40
|
+
legalName: z.string().nullable(),
|
|
41
|
+
vatId: z.string().nullable(),
|
|
42
|
+
registrationNumber: z.string().nullable(),
|
|
43
|
+
address: z.string().nullable(),
|
|
44
|
+
phone: z.string().nullable(),
|
|
45
|
+
email: z.string().nullable(),
|
|
46
|
+
website: z.string().nullable(),
|
|
47
|
+
license: z.string().nullable(),
|
|
48
|
+
licenseAuthority: z.string().nullable(),
|
|
49
|
+
signatoryName: z.string().nullable(),
|
|
50
|
+
signatoryRole: z.string().nullable(),
|
|
51
|
+
createdAt: isoTimestamp,
|
|
52
|
+
updatedAt: isoTimestamp,
|
|
53
|
+
});
|
|
54
|
+
/** `operator_payment_instructions` row. */
|
|
55
|
+
const operatorPaymentInstructionsRowSchema = z.object({
|
|
56
|
+
id: z.string(),
|
|
57
|
+
bankTransferBeneficiary: z.string().nullable(),
|
|
58
|
+
iban: z.string().nullable(),
|
|
59
|
+
bank: z.string().nullable(),
|
|
60
|
+
notes: z.string().nullable(),
|
|
61
|
+
createdAt: isoTimestamp,
|
|
62
|
+
updatedAt: isoTimestamp,
|
|
63
|
+
});
|
|
64
|
+
/** `operator_payment_defaults` row. */
|
|
65
|
+
const operatorPaymentDefaultsRowSchema = z.object({
|
|
66
|
+
id: z.string(),
|
|
67
|
+
customerPaymentPolicy: opaqueJson,
|
|
68
|
+
bookingCheckoutUrlTemplate: z.string().nullable(),
|
|
69
|
+
invoicePayUrlTemplate: z.string().nullable(),
|
|
70
|
+
createdAt: isoTimestamp,
|
|
71
|
+
updatedAt: isoTimestamp,
|
|
72
|
+
});
|
|
73
|
+
/**
|
|
74
|
+
* Combined settings — `getOperatorSettings` spreads the profile row and folds in
|
|
75
|
+
* the instruction + defaults columns (or returns `null` when nothing is set).
|
|
76
|
+
* Profile fields are optional because the spread is empty when no profile row
|
|
77
|
+
* exists yet.
|
|
78
|
+
*/
|
|
79
|
+
const combinedOperatorSettingsSchema = operatorProfileRowSchema.partial().extend({
|
|
80
|
+
bankTransferBeneficiary: z.string().nullable(),
|
|
81
|
+
iban: z.string().nullable(),
|
|
82
|
+
bank: z.string().nullable(),
|
|
83
|
+
notes: z.string().nullable(),
|
|
84
|
+
customerPaymentPolicy: opaqueJson,
|
|
85
|
+
bookingCheckoutUrlTemplate: z.string().nullable(),
|
|
86
|
+
invoicePayUrlTemplate: z.string().nullable(),
|
|
87
|
+
});
|
|
88
|
+
/** Public projection — `toPublicOperatorProfile` / `toPublicOperatorSettings`. */
|
|
89
|
+
const publicOperatorProfileSchema = z.object({
|
|
90
|
+
name: z.string(),
|
|
91
|
+
legalName: z.string(),
|
|
92
|
+
address: z.string(),
|
|
93
|
+
phone: z.string(),
|
|
94
|
+
email: z.string(),
|
|
95
|
+
website: z.string(),
|
|
96
|
+
license: z.string(),
|
|
97
|
+
licenseAuthority: z.string(),
|
|
98
|
+
customerPaymentPolicy: opaqueJson,
|
|
99
|
+
bookingCheckoutUrlTemplate: z.string().nullable(),
|
|
100
|
+
invoicePayUrlTemplate: z.string().nullable(),
|
|
101
|
+
});
|
|
102
|
+
function dataEnvelope(schema) {
|
|
103
|
+
return z.object({ data: schema });
|
|
59
104
|
}
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
105
|
+
const jsonContent = (schema, description) => ({
|
|
106
|
+
description,
|
|
107
|
+
content: { "application/json": { schema } },
|
|
108
|
+
});
|
|
109
|
+
const jsonBody = (schema) => ({
|
|
110
|
+
required: true,
|
|
111
|
+
content: { "application/json": { schema } },
|
|
112
|
+
});
|
|
113
|
+
/**
|
|
114
|
+
* Bridges a handler's `{ data: Row | null }` payload (Date-bearing Drizzle rows
|
|
115
|
+
* whose wire shape is the declared `z.string()` timestamp) to the `.openapi()`
|
|
116
|
+
* inferred typed-response union. Runtime payloads honor the declared schemas
|
|
117
|
+
* (asserted by the contract tests); this only relaxes the compile-time check.
|
|
118
|
+
*/
|
|
119
|
+
// biome-ignore lint/suspicious/noExplicitAny: intentional — bridges Date-bearing rows to the inferred typed-response union (voyant#2114)
|
|
120
|
+
function asRouteResponse(response) {
|
|
121
|
+
return response;
|
|
67
122
|
}
|
|
123
|
+
// ──────────────────────────────────────────────────────────────────
|
|
124
|
+
// Route definitions
|
|
125
|
+
// ──────────────────────────────────────────────────────────────────
|
|
126
|
+
const getOperatorProfileRoute = createRoute({
|
|
127
|
+
method: "get",
|
|
128
|
+
path: "/v1/admin/settings/operator-profile",
|
|
129
|
+
responses: {
|
|
130
|
+
200: jsonContent(dataEnvelope(operatorProfileRowSchema.nullable()), "The operator profile"),
|
|
131
|
+
},
|
|
132
|
+
});
|
|
133
|
+
const patchOperatorProfileRoute = createRoute({
|
|
134
|
+
method: "patch",
|
|
135
|
+
path: "/v1/admin/settings/operator-profile",
|
|
136
|
+
request: { body: jsonBody(updateOperatorProfileSchema) },
|
|
137
|
+
responses: {
|
|
138
|
+
200: jsonContent(dataEnvelope(operatorProfileRowSchema.nullable()), "The updated operator profile"),
|
|
139
|
+
},
|
|
140
|
+
});
|
|
141
|
+
const getOperatorPaymentInstructionsRoute = createRoute({
|
|
142
|
+
method: "get",
|
|
143
|
+
path: "/v1/admin/settings/operator-payment-instructions",
|
|
144
|
+
responses: {
|
|
145
|
+
200: jsonContent(dataEnvelope(operatorPaymentInstructionsRowSchema.nullable()), "The operator payment instructions"),
|
|
146
|
+
},
|
|
147
|
+
});
|
|
148
|
+
const patchOperatorPaymentInstructionsRoute = createRoute({
|
|
149
|
+
method: "patch",
|
|
150
|
+
path: "/v1/admin/settings/operator-payment-instructions",
|
|
151
|
+
request: { body: jsonBody(updateOperatorPaymentInstructionsSchema) },
|
|
152
|
+
responses: {
|
|
153
|
+
200: jsonContent(dataEnvelope(operatorPaymentInstructionsRowSchema.nullable()), "The updated operator payment instructions"),
|
|
154
|
+
},
|
|
155
|
+
});
|
|
156
|
+
const getOperatorPaymentDefaultsRoute = createRoute({
|
|
157
|
+
method: "get",
|
|
158
|
+
path: "/v1/admin/settings/operator-payment-defaults",
|
|
159
|
+
responses: {
|
|
160
|
+
200: jsonContent(dataEnvelope(operatorPaymentDefaultsRowSchema.nullable()), "The operator payment defaults"),
|
|
161
|
+
},
|
|
162
|
+
});
|
|
163
|
+
const patchOperatorPaymentDefaultsRoute = createRoute({
|
|
164
|
+
method: "patch",
|
|
165
|
+
path: "/v1/admin/settings/operator-payment-defaults",
|
|
166
|
+
request: { body: jsonBody(updateOperatorPaymentDefaultsSchema) },
|
|
167
|
+
responses: {
|
|
168
|
+
200: jsonContent(dataEnvelope(operatorPaymentDefaultsRowSchema.nullable()), "The updated operator payment defaults"),
|
|
169
|
+
},
|
|
170
|
+
});
|
|
171
|
+
const getPublicOperatorProfileRoute = createRoute({
|
|
172
|
+
method: "get",
|
|
173
|
+
path: "/v1/public/operator-profile",
|
|
174
|
+
responses: {
|
|
175
|
+
200: jsonContent(dataEnvelope(publicOperatorProfileSchema.nullable()), "The public operator profile (null when unset)"),
|
|
176
|
+
},
|
|
177
|
+
});
|
|
178
|
+
const getOperatorSettingsRoute = createRoute({
|
|
179
|
+
method: "get",
|
|
180
|
+
path: "/v1/admin/settings/operator",
|
|
181
|
+
responses: {
|
|
182
|
+
200: jsonContent(dataEnvelope(combinedOperatorSettingsSchema.nullable()), "The combined operator settings"),
|
|
183
|
+
},
|
|
184
|
+
});
|
|
185
|
+
const patchOperatorSettingsRoute = createRoute({
|
|
186
|
+
method: "patch",
|
|
187
|
+
path: "/v1/admin/settings/operator",
|
|
188
|
+
request: { body: jsonBody(updateOperatorSettingsSchema) },
|
|
189
|
+
responses: {
|
|
190
|
+
200: jsonContent(dataEnvelope(combinedOperatorSettingsSchema.nullable()), "The updated combined operator settings"),
|
|
191
|
+
},
|
|
192
|
+
});
|
|
193
|
+
const getPublicOperatorSettingsRoute = createRoute({
|
|
194
|
+
method: "get",
|
|
195
|
+
path: "/v1/public/settings/operator",
|
|
196
|
+
responses: {
|
|
197
|
+
200: jsonContent(dataEnvelope(publicOperatorProfileSchema.nullable()), "The public operator settings (null when unset)"),
|
|
198
|
+
},
|
|
199
|
+
});
|
|
68
200
|
export function mountOperatorSettingsRoutes(hono) {
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
201
|
+
const routes = new OpenAPIHono({ defaultHook: openApiValidationHook })
|
|
202
|
+
.openapi(getOperatorProfileRoute, (c) => asRouteResponse((async () => c.json({ data: await getOperatorProfile(c.get("db")) }, 200))()))
|
|
203
|
+
.openapi(patchOperatorProfileRoute, (c) => asRouteResponse((async () => c.json({ data: await upsertOperatorProfile(c.get("db"), c.req.valid("json")) }, 200))()))
|
|
204
|
+
.openapi(getOperatorPaymentInstructionsRoute, (c) => asRouteResponse((async () => c.json({ data: await getOperatorPaymentInstructions(c.get("db")) }, 200))()))
|
|
205
|
+
.openapi(patchOperatorPaymentInstructionsRoute, (c) => asRouteResponse((async () => c.json({ data: await upsertOperatorPaymentInstructions(c.get("db"), c.req.valid("json")) }, 200))()))
|
|
206
|
+
.openapi(getOperatorPaymentDefaultsRoute, (c) => asRouteResponse((async () => c.json({ data: await getOperatorPaymentDefaults(c.get("db")) }, 200))()))
|
|
207
|
+
.openapi(patchOperatorPaymentDefaultsRoute, (c) => asRouteResponse((async () => c.json({ data: await upsertOperatorPaymentDefaults(c.get("db"), c.req.valid("json")) }, 200))()))
|
|
208
|
+
.openapi(getPublicOperatorProfileRoute, (c) => asRouteResponse((async () => {
|
|
209
|
+
const db = c.get("db");
|
|
210
|
+
const [profile, defaults] = await Promise.all([
|
|
211
|
+
getOperatorProfile(db),
|
|
212
|
+
getOperatorPaymentDefaults(db),
|
|
213
|
+
]);
|
|
214
|
+
cachePublicOperatorSettings(c);
|
|
215
|
+
if (!profile)
|
|
216
|
+
return c.json({ data: null }, 200);
|
|
217
|
+
return c.json({ data: toPublicOperatorProfile(profile, defaults) }, 200);
|
|
218
|
+
})()))
|
|
219
|
+
.openapi(getOperatorSettingsRoute, (c) => asRouteResponse((async () => c.json({ data: await getOperatorSettings(c.get("db")) }, 200))()))
|
|
220
|
+
.openapi(patchOperatorSettingsRoute, (c) => asRouteResponse((async () => c.json({ data: await upsertOperatorSettings(c.get("db"), c.req.valid("json")) }, 200))()))
|
|
221
|
+
.openapi(getPublicOperatorSettingsRoute, (c) => asRouteResponse((async () => {
|
|
222
|
+
const row = await getOperatorSettings(c.get("db"));
|
|
223
|
+
cachePublicOperatorSettings(c);
|
|
224
|
+
if (!row)
|
|
225
|
+
return c.json({ data: null }, 200);
|
|
226
|
+
return c.json({ data: toPublicOperatorSettings(row) }, 200);
|
|
227
|
+
})()));
|
|
228
|
+
hono.route("/", routes);
|
|
79
229
|
}
|
package/dist/service.d.ts
CHANGED
|
@@ -35,8 +35,8 @@ export declare const updateOperatorPaymentDefaultsSchema: z.ZodObject<{
|
|
|
35
35
|
customerPaymentPolicy: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
36
36
|
deposit: z.ZodObject<{
|
|
37
37
|
kind: z.ZodEnum<{
|
|
38
|
-
percent: "percent";
|
|
39
38
|
none: "none";
|
|
39
|
+
percent: "percent";
|
|
40
40
|
fixed_cents: "fixed_cents";
|
|
41
41
|
}>;
|
|
42
42
|
percent: z.ZodOptional<z.ZodNumber>;
|
|
@@ -69,8 +69,8 @@ export declare const updateOperatorSettingsSchema: z.ZodObject<{
|
|
|
69
69
|
customerPaymentPolicy: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
70
70
|
deposit: z.ZodObject<{
|
|
71
71
|
kind: z.ZodEnum<{
|
|
72
|
-
percent: "percent";
|
|
73
72
|
none: "none";
|
|
73
|
+
percent: "percent";
|
|
74
74
|
fixed_cents: "fixed_cents";
|
|
75
75
|
}>;
|
|
76
76
|
percent: z.ZodOptional<z.ZodNumber>;
|
|
@@ -110,19 +110,19 @@ export declare function getOperatorProfile(db: PostgresJsDatabase): Promise<{
|
|
|
110
110
|
export declare function upsertOperatorProfile(db: PostgresJsDatabase, patch: UpdateOperatorProfileInput): Promise<{
|
|
111
111
|
id: string;
|
|
112
112
|
name: string | null;
|
|
113
|
-
createdAt: Date;
|
|
114
|
-
updatedAt: Date;
|
|
115
|
-
email: string | null;
|
|
116
|
-
phone: string | null;
|
|
117
|
-
address: string | null;
|
|
118
|
-
vatId: string | null;
|
|
119
113
|
legalName: string | null;
|
|
114
|
+
vatId: string | null;
|
|
120
115
|
registrationNumber: string | null;
|
|
116
|
+
address: string | null;
|
|
117
|
+
phone: string | null;
|
|
118
|
+
email: string | null;
|
|
121
119
|
website: string | null;
|
|
122
120
|
license: string | null;
|
|
123
121
|
licenseAuthority: string | null;
|
|
124
122
|
signatoryName: string | null;
|
|
125
123
|
signatoryRole: string | null;
|
|
124
|
+
createdAt: Date;
|
|
125
|
+
updatedAt: Date;
|
|
126
126
|
} | null>;
|
|
127
127
|
export declare function getOperatorPaymentInstructions(db: PostgresJsDatabase): Promise<{
|
|
128
128
|
id: string;
|
|
@@ -135,12 +135,12 @@ export declare function getOperatorPaymentInstructions(db: PostgresJsDatabase):
|
|
|
135
135
|
} | null>;
|
|
136
136
|
export declare function upsertOperatorPaymentInstructions(db: PostgresJsDatabase, patch: UpdateOperatorPaymentInstructionsInput): Promise<{
|
|
137
137
|
id: string;
|
|
138
|
-
createdAt: Date;
|
|
139
|
-
updatedAt: Date;
|
|
140
|
-
notes: string | null;
|
|
141
138
|
iban: string | null;
|
|
142
139
|
bank: string | null;
|
|
140
|
+
createdAt: Date;
|
|
141
|
+
updatedAt: Date;
|
|
143
142
|
bankTransferBeneficiary: string | null;
|
|
143
|
+
notes: string | null;
|
|
144
144
|
} | null>;
|
|
145
145
|
export declare function getOperatorPaymentDefaults(db: PostgresJsDatabase): Promise<{
|
|
146
146
|
id: string;
|
|
@@ -152,9 +152,9 @@ export declare function getOperatorPaymentDefaults(db: PostgresJsDatabase): Prom
|
|
|
152
152
|
} | null>;
|
|
153
153
|
export declare function upsertOperatorPaymentDefaults(db: PostgresJsDatabase, patch: UpdateOperatorPaymentDefaultsInput): Promise<{
|
|
154
154
|
id: string;
|
|
155
|
+
customerPaymentPolicy: unknown;
|
|
155
156
|
createdAt: Date;
|
|
156
157
|
updatedAt: Date;
|
|
157
|
-
customerPaymentPolicy: unknown;
|
|
158
158
|
bookingCheckoutUrlTemplate: string | null;
|
|
159
159
|
invoicePayUrlTemplate: string | null;
|
|
160
160
|
} | null>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@voyant-travel/operator-settings",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.19",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -31,12 +31,13 @@
|
|
|
31
31
|
}
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
+
"@hono/zod-openapi": "^1.4.0",
|
|
34
35
|
"drizzle-orm": "^0.45.2",
|
|
35
36
|
"hono": "^4.12.10",
|
|
36
37
|
"zod": "^4.3.6",
|
|
37
|
-
"@voyant-travel/db": "^0.109.
|
|
38
|
-
"@voyant-travel/finance": "^0.
|
|
39
|
-
"@voyant-travel/hono": "^0.
|
|
38
|
+
"@voyant-travel/db": "^0.109.4",
|
|
39
|
+
"@voyant-travel/finance": "^0.137.1",
|
|
40
|
+
"@voyant-travel/hono": "^0.118.0"
|
|
40
41
|
},
|
|
41
42
|
"devDependencies": {
|
|
42
43
|
"drizzle-kit": "^0.31.10",
|
|
@@ -64,10 +65,10 @@
|
|
|
64
65
|
]
|
|
65
66
|
},
|
|
66
67
|
"scripts": {
|
|
67
|
-
"typecheck": "tsc
|
|
68
|
+
"typecheck": "tsc -p tsconfig.typecheck.json",
|
|
68
69
|
"lint": "biome check src/",
|
|
69
70
|
"test": "vitest run",
|
|
70
|
-
"build": "tsc -p tsconfig.json",
|
|
71
|
+
"build": "tsc -p tsconfig.build.json",
|
|
71
72
|
"clean": "rm -rf dist tsconfig.tsbuildinfo",
|
|
72
73
|
"db:generate": "drizzle-kit generate --config=drizzle.migrations.config.ts --name=operator_settings_baseline && node ../../scripts/migrations/guard-create-type.mjs ./migrations && node ../../scripts/migrations/ensure-extensions.mjs ./migrations"
|
|
73
74
|
},
|