@voyant-travel/inventory 0.4.3 → 0.4.4

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,301 @@
1
+ import type { Env } from "./route-env.js";
2
+ export declare const productItineraryTranslationRoutes: import("hono/hono-base").HonoBase<Env, {
3
+ "/:id/itineraries/:itineraryId/translations": {
4
+ $get: {
5
+ input: {
6
+ param: {
7
+ id: string;
8
+ } & {
9
+ itineraryId: string;
10
+ };
11
+ };
12
+ output: {
13
+ data: {
14
+ id: string;
15
+ itineraryId: string;
16
+ languageTag: string;
17
+ name: string;
18
+ createdAt: string;
19
+ updatedAt: string;
20
+ }[];
21
+ total: number;
22
+ limit: number;
23
+ offset: number;
24
+ };
25
+ outputFormat: "json";
26
+ status: import("hono/utils/http-status").ContentfulStatusCode;
27
+ };
28
+ };
29
+ } & {
30
+ "/:id/itineraries/:itineraryId/translations": {
31
+ $post: {
32
+ input: {
33
+ param: {
34
+ id: string;
35
+ } & {
36
+ itineraryId: string;
37
+ };
38
+ };
39
+ output: {
40
+ error: string;
41
+ };
42
+ outputFormat: "json";
43
+ status: 404;
44
+ } | {
45
+ input: {
46
+ param: {
47
+ id: string;
48
+ } & {
49
+ itineraryId: string;
50
+ };
51
+ };
52
+ output: {
53
+ data: {
54
+ id: string;
55
+ name: string;
56
+ createdAt: string;
57
+ updatedAt: string;
58
+ itineraryId: string;
59
+ languageTag: string;
60
+ };
61
+ };
62
+ outputFormat: "json";
63
+ status: 201;
64
+ };
65
+ };
66
+ } & {
67
+ "/:id/itineraries/:itineraryId/translations/:translationId": {
68
+ $patch: {
69
+ input: {
70
+ param: {
71
+ id: string;
72
+ } & {
73
+ itineraryId: string;
74
+ } & {
75
+ translationId: string;
76
+ };
77
+ };
78
+ output: {
79
+ error: string;
80
+ };
81
+ outputFormat: "json";
82
+ status: 404;
83
+ } | {
84
+ input: {
85
+ param: {
86
+ id: string;
87
+ } & {
88
+ itineraryId: string;
89
+ } & {
90
+ translationId: string;
91
+ };
92
+ };
93
+ output: {
94
+ data: {
95
+ id: string;
96
+ itineraryId: string;
97
+ languageTag: string;
98
+ name: string;
99
+ createdAt: string;
100
+ updatedAt: string;
101
+ };
102
+ };
103
+ outputFormat: "json";
104
+ status: import("hono/utils/http-status").ContentfulStatusCode;
105
+ };
106
+ };
107
+ } & {
108
+ "/:id/itineraries/:itineraryId/translations/:translationId": {
109
+ $delete: {
110
+ input: {
111
+ param: {
112
+ id: string;
113
+ } & {
114
+ itineraryId: string;
115
+ } & {
116
+ translationId: string;
117
+ };
118
+ };
119
+ output: {
120
+ error: string;
121
+ };
122
+ outputFormat: "json";
123
+ status: 404;
124
+ } | {
125
+ input: {
126
+ param: {
127
+ id: string;
128
+ } & {
129
+ itineraryId: string;
130
+ } & {
131
+ translationId: string;
132
+ };
133
+ };
134
+ output: {
135
+ success: true;
136
+ };
137
+ outputFormat: "json";
138
+ status: 200;
139
+ };
140
+ };
141
+ } & {
142
+ "/:id/days/:dayId/services/:serviceId/translations": {
143
+ $get: {
144
+ input: {
145
+ param: {
146
+ id: string;
147
+ } & {
148
+ dayId: string;
149
+ } & {
150
+ serviceId: string;
151
+ };
152
+ };
153
+ output: {
154
+ data: {
155
+ id: string;
156
+ serviceId: string;
157
+ languageTag: string;
158
+ name: string;
159
+ description: string | null;
160
+ notes: string | null;
161
+ createdAt: string;
162
+ updatedAt: string;
163
+ }[];
164
+ total: number;
165
+ limit: number;
166
+ offset: number;
167
+ };
168
+ outputFormat: "json";
169
+ status: import("hono/utils/http-status").ContentfulStatusCode;
170
+ };
171
+ };
172
+ } & {
173
+ "/:id/days/:dayId/services/:serviceId/translations": {
174
+ $post: {
175
+ input: {
176
+ param: {
177
+ id: string;
178
+ } & {
179
+ dayId: string;
180
+ } & {
181
+ serviceId: string;
182
+ };
183
+ };
184
+ output: {
185
+ error: string;
186
+ };
187
+ outputFormat: "json";
188
+ status: 404;
189
+ } | {
190
+ input: {
191
+ param: {
192
+ id: string;
193
+ } & {
194
+ dayId: string;
195
+ } & {
196
+ serviceId: string;
197
+ };
198
+ };
199
+ output: {
200
+ data: {
201
+ id: string;
202
+ name: string;
203
+ createdAt: string;
204
+ description: string | null;
205
+ updatedAt: string;
206
+ languageTag: string;
207
+ notes: string | null;
208
+ serviceId: string;
209
+ };
210
+ };
211
+ outputFormat: "json";
212
+ status: 201;
213
+ };
214
+ };
215
+ } & {
216
+ "/:id/days/:dayId/services/:serviceId/translations/:translationId": {
217
+ $patch: {
218
+ input: {
219
+ param: {
220
+ id: string;
221
+ } & {
222
+ dayId: string;
223
+ } & {
224
+ serviceId: string;
225
+ } & {
226
+ translationId: string;
227
+ };
228
+ };
229
+ output: {
230
+ error: string;
231
+ };
232
+ outputFormat: "json";
233
+ status: 404;
234
+ } | {
235
+ input: {
236
+ param: {
237
+ id: string;
238
+ } & {
239
+ dayId: string;
240
+ } & {
241
+ serviceId: string;
242
+ } & {
243
+ translationId: string;
244
+ };
245
+ };
246
+ output: {
247
+ data: {
248
+ id: string;
249
+ serviceId: string;
250
+ languageTag: string;
251
+ name: string;
252
+ description: string | null;
253
+ notes: string | null;
254
+ createdAt: string;
255
+ updatedAt: string;
256
+ };
257
+ };
258
+ outputFormat: "json";
259
+ status: import("hono/utils/http-status").ContentfulStatusCode;
260
+ };
261
+ };
262
+ } & {
263
+ "/:id/days/:dayId/services/:serviceId/translations/:translationId": {
264
+ $delete: {
265
+ input: {
266
+ param: {
267
+ id: string;
268
+ } & {
269
+ dayId: string;
270
+ } & {
271
+ serviceId: string;
272
+ } & {
273
+ translationId: string;
274
+ };
275
+ };
276
+ output: {
277
+ error: string;
278
+ };
279
+ outputFormat: "json";
280
+ status: 404;
281
+ } | {
282
+ input: {
283
+ param: {
284
+ id: string;
285
+ } & {
286
+ dayId: string;
287
+ } & {
288
+ serviceId: string;
289
+ } & {
290
+ translationId: string;
291
+ };
292
+ };
293
+ output: {
294
+ success: true;
295
+ };
296
+ outputFormat: "json";
297
+ status: 200;
298
+ };
299
+ };
300
+ }, "/", "/:id/days/:dayId/services/:serviceId/translations/:translationId">;
301
+ //# sourceMappingURL=routes-itinerary-translations.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"routes-itinerary-translations.d.ts","sourceRoot":"","sources":["../src/routes-itinerary-translations.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAA;AAIzC,eAAO,MAAM,iCAAiC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;2EA6N1C,CAAA"}
@@ -0,0 +1,168 @@
1
+ import { parseJsonBody } from "@voyant-travel/hono";
2
+ import { Hono } from "hono";
3
+ import { appendProductMutationLedgerEntry, changedMutationFields } from "./action-ledger.js";
4
+ import { emitProductContentChanged } from "./events.js";
5
+ import { productsService } from "./service.js";
6
+ import * as validation from "./validation.js";
7
+ export const productItineraryTranslationRoutes = new Hono()
8
+ // ==========================================================================
9
+ // Itinerary translations
10
+ // ==========================================================================
11
+ .get("/:id/itineraries/:itineraryId/translations", async (c) => {
12
+ return c.json(await productsService.listProductItineraryTranslations(c.get("db"), {
13
+ itineraryId: c.req.param("itineraryId"),
14
+ limit: 100,
15
+ offset: 0,
16
+ }));
17
+ })
18
+ .post("/:id/itineraries/:itineraryId/translations", async (c) => {
19
+ const productId = c.req.param("id");
20
+ const itineraryId = c.req.param("itineraryId");
21
+ const body = await parseJsonBody(c, validation.insertProductItineraryTranslationSchema);
22
+ const row = await productsService.createProductItineraryTranslation(c.get("db"), productId, itineraryId, body);
23
+ if (!row) {
24
+ return c.json({ error: "Itinerary not found" }, 404);
25
+ }
26
+ await appendProductMutationLedgerEntry(c, {
27
+ action: "create",
28
+ productId,
29
+ changedFields: changedMutationFields(body, null, row),
30
+ subject: "product itinerary translation",
31
+ actionName: "product.itinerary_translation.create",
32
+ routeOrToolName: "products.itinerary_translation.create",
33
+ });
34
+ await emitProductContentChanged(c.get("eventBus"), { id: productId, axis: "itinerary" });
35
+ return c.json({ data: row }, 201);
36
+ })
37
+ .patch("/:id/itineraries/:itineraryId/translations/:translationId", async (c) => {
38
+ const productId = c.req.param("id");
39
+ const itineraryId = c.req.param("itineraryId");
40
+ const translationId = c.req.param("translationId");
41
+ const before = await productsService.getItineraryTranslationForProductMutation(c.get("db"), translationId);
42
+ if (!before || before.productId !== productId || before.itineraryId !== itineraryId) {
43
+ return c.json({ error: "Itinerary translation not found" }, 404);
44
+ }
45
+ const body = await parseJsonBody(c, validation.updateProductItineraryTranslationSchema);
46
+ const row = await productsService.updateProductItineraryTranslation(c.get("db"), translationId, body);
47
+ if (!row) {
48
+ return c.json({ error: "Itinerary translation not found" }, 404);
49
+ }
50
+ await appendProductMutationLedgerEntry(c, {
51
+ action: "update",
52
+ productId,
53
+ changedFields: changedMutationFields(body, before, row),
54
+ subject: "product itinerary translation",
55
+ actionName: "product.itinerary_translation.update",
56
+ routeOrToolName: "products.itinerary_translation.update",
57
+ });
58
+ await emitProductContentChanged(c.get("eventBus"), { id: productId, axis: "itinerary" });
59
+ return c.json({ data: row });
60
+ })
61
+ .delete("/:id/itineraries/:itineraryId/translations/:translationId", async (c) => {
62
+ const productId = c.req.param("id");
63
+ const itineraryId = c.req.param("itineraryId");
64
+ const translationId = c.req.param("translationId");
65
+ const before = await productsService.getItineraryTranslationForProductMutation(c.get("db"), translationId);
66
+ if (!before || before.productId !== productId || before.itineraryId !== itineraryId) {
67
+ return c.json({ error: "Itinerary translation not found" }, 404);
68
+ }
69
+ const row = await productsService.deleteProductItineraryTranslation(c.get("db"), translationId);
70
+ if (!row) {
71
+ return c.json({ error: "Itinerary translation not found" }, 404);
72
+ }
73
+ await appendProductMutationLedgerEntry(c, {
74
+ action: "delete",
75
+ productId,
76
+ changedFields: [],
77
+ subject: "product itinerary translation",
78
+ actionName: "product.itinerary_translation.delete",
79
+ routeOrToolName: "products.itinerary_translation.delete",
80
+ });
81
+ await emitProductContentChanged(c.get("eventBus"), { id: productId, axis: "itinerary" });
82
+ return c.json({ success: true }, 200);
83
+ })
84
+ // ==========================================================================
85
+ // Day service translations
86
+ // ==========================================================================
87
+ .get("/:id/days/:dayId/services/:serviceId/translations", async (c) => {
88
+ return c.json(await productsService.listDayServiceTranslations(c.get("db"), {
89
+ serviceId: c.req.param("serviceId"),
90
+ limit: 100,
91
+ offset: 0,
92
+ }));
93
+ })
94
+ .post("/:id/days/:dayId/services/:serviceId/translations", async (c) => {
95
+ const productId = c.req.param("id");
96
+ const dayId = c.req.param("dayId");
97
+ const serviceId = c.req.param("serviceId");
98
+ const body = await parseJsonBody(c, validation.insertDayServiceTranslationSchema);
99
+ const row = await productsService.createDayServiceTranslation(c.get("db"), productId, dayId, serviceId, body);
100
+ if (!row) {
101
+ return c.json({ error: "Service not found" }, 404);
102
+ }
103
+ await appendProductMutationLedgerEntry(c, {
104
+ action: "create",
105
+ productId,
106
+ changedFields: changedMutationFields(body, null, row),
107
+ subject: "product day service translation",
108
+ actionName: "product.day_service_translation.create",
109
+ routeOrToolName: "products.day_service_translation.create",
110
+ });
111
+ await emitProductContentChanged(c.get("eventBus"), { id: productId, axis: "day" });
112
+ return c.json({ data: row }, 201);
113
+ })
114
+ .patch("/:id/days/:dayId/services/:serviceId/translations/:translationId", async (c) => {
115
+ const productId = c.req.param("id");
116
+ const dayId = c.req.param("dayId");
117
+ const serviceId = c.req.param("serviceId");
118
+ const translationId = c.req.param("translationId");
119
+ const before = await productsService.getDayServiceTranslationForProductMutation(c.get("db"), translationId);
120
+ if (!before ||
121
+ before.productId !== productId ||
122
+ before.dayId !== dayId ||
123
+ before.serviceId !== serviceId) {
124
+ return c.json({ error: "Service translation not found" }, 404);
125
+ }
126
+ const body = await parseJsonBody(c, validation.updateDayServiceTranslationSchema);
127
+ const row = await productsService.updateDayServiceTranslation(c.get("db"), translationId, body);
128
+ if (!row) {
129
+ return c.json({ error: "Service translation not found" }, 404);
130
+ }
131
+ await appendProductMutationLedgerEntry(c, {
132
+ action: "update",
133
+ productId,
134
+ changedFields: changedMutationFields(body, before, row),
135
+ subject: "product day service translation",
136
+ actionName: "product.day_service_translation.update",
137
+ routeOrToolName: "products.day_service_translation.update",
138
+ });
139
+ await emitProductContentChanged(c.get("eventBus"), { id: productId, axis: "day" });
140
+ return c.json({ data: row });
141
+ })
142
+ .delete("/:id/days/:dayId/services/:serviceId/translations/:translationId", async (c) => {
143
+ const productId = c.req.param("id");
144
+ const dayId = c.req.param("dayId");
145
+ const serviceId = c.req.param("serviceId");
146
+ const translationId = c.req.param("translationId");
147
+ const before = await productsService.getDayServiceTranslationForProductMutation(c.get("db"), translationId);
148
+ if (!before ||
149
+ before.productId !== productId ||
150
+ before.dayId !== dayId ||
151
+ before.serviceId !== serviceId) {
152
+ return c.json({ error: "Service translation not found" }, 404);
153
+ }
154
+ const row = await productsService.deleteDayServiceTranslation(c.get("db"), translationId);
155
+ if (!row) {
156
+ return c.json({ error: "Service translation not found" }, 404);
157
+ }
158
+ await appendProductMutationLedgerEntry(c, {
159
+ action: "delete",
160
+ productId,
161
+ changedFields: [],
162
+ subject: "product day service translation",
163
+ actionName: "product.day_service_translation.delete",
164
+ routeOrToolName: "products.day_service_translation.delete",
165
+ });
166
+ await emitProductContentChanged(c.get("eventBus"), { id: productId, axis: "day" });
167
+ return c.json({ success: true }, 200);
168
+ });
@@ -558,10 +558,10 @@ export declare const productItineraryRoutes: import("hono/hono-base").HonoBase<E
558
558
  createdAt: string;
559
559
  description: string | null;
560
560
  updatedAt: string;
561
+ languageTag: string;
561
562
  title: string | null;
562
563
  location: string | null;
563
564
  dayId: string;
564
- languageTag: string;
565
565
  };
566
566
  };
567
567
  outputFormat: "json";