@voyantjs/products 0.52.1 → 0.52.3
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/action-ledger-drift.d.ts +29 -0
- package/dist/action-ledger-drift.d.ts.map +1 -0
- package/dist/action-ledger-drift.js +335 -0
- package/dist/action-ledger.d.ts +104 -0
- package/dist/action-ledger.d.ts.map +1 -0
- package/dist/action-ledger.js +100 -0
- package/dist/booking-extension.d.ts +3 -3
- package/dist/catalog-policy.d.ts.map +1 -1
- package/dist/catalog-policy.js +18 -0
- package/dist/content-shape.d.ts +2 -0
- package/dist/content-shape.d.ts.map +1 -1
- package/dist/content-shape.js +2 -0
- package/dist/events.d.ts +1 -1
- package/dist/events.d.ts.map +1 -1
- package/dist/route-env.d.ts +22 -0
- package/dist/route-env.d.ts.map +1 -0
- package/dist/route-env.js +1 -0
- package/dist/routes-associations.d.ts +164 -0
- package/dist/routes-associations.d.ts.map +1 -0
- package/dist/routes-associations.js +100 -0
- package/dist/routes-catalog.d.ts +436 -0
- package/dist/routes-catalog.d.ts.map +1 -0
- package/dist/routes-catalog.js +104 -0
- package/dist/routes-configuration.d.ts +773 -0
- package/dist/routes-configuration.d.ts.map +1 -0
- package/dist/routes-configuration.js +364 -0
- package/dist/routes-core.d.ts +302 -0
- package/dist/routes-core.d.ts.map +1 -0
- package/dist/routes-core.js +79 -0
- package/dist/routes-itinerary.d.ts +614 -0
- package/dist/routes-itinerary.d.ts.map +1 -0
- package/dist/routes-itinerary.js +309 -0
- package/dist/routes-maintenance.d.ts +32 -0
- package/dist/routes-maintenance.d.ts.map +1 -0
- package/dist/routes-maintenance.js +14 -0
- package/dist/routes-media.d.ts +634 -0
- package/dist/routes-media.d.ts.map +1 -0
- package/dist/routes-media.js +245 -0
- package/dist/routes-merchandising.d.ts +1108 -0
- package/dist/routes-merchandising.d.ts.map +1 -0
- package/dist/routes-merchandising.js +376 -0
- package/dist/routes-options.d.ts +363 -0
- package/dist/routes-options.d.ts.map +1 -0
- package/dist/routes-options.js +173 -0
- package/dist/routes-public.d.ts +4 -4
- package/dist/routes-translations.d.ts +477 -0
- package/dist/routes-translations.d.ts.map +1 -0
- package/dist/routes-translations.js +258 -0
- package/dist/routes.d.ts +417 -355
- package/dist/routes.d.ts.map +1 -1
- package/dist/routes.js +21 -1133
- package/dist/schema-core.d.ts +3 -3
- package/dist/schema-itinerary.d.ts +1 -1
- package/dist/schema-settings.d.ts +4 -4
- package/dist/service-catalog-plane.d.ts.map +1 -1
- package/dist/service-catalog-plane.js +48 -1
- package/dist/service-catalog.d.ts +2 -2
- package/dist/service-content-owned.d.ts.map +1 -1
- package/dist/service-content-owned.js +98 -4
- package/dist/service-public.d.ts +4 -4
- package/dist/service.d.ts +225 -97
- package/dist/service.d.ts.map +1 -1
- package/dist/service.js +91 -0
- package/dist/tasks/brochures.d.ts +1 -1
- package/dist/validation-catalog.d.ts +10 -10
- package/dist/validation-config.d.ts +17 -17
- package/dist/validation-content.d.ts +26 -26
- package/dist/validation-core.d.ts +46 -46
- package/dist/validation-core.d.ts.map +1 -1
- package/dist/validation-core.js +17 -1
- package/dist/validation-public.d.ts +25 -25
- package/dist/validation-shared.d.ts +11 -11
- package/package.json +13 -7
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
import { parseJsonBody, parseQuery } from "@voyantjs/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 productTranslationRoutes = new Hono()
|
|
8
|
+
// ==========================================================================
|
|
9
|
+
// Translations
|
|
10
|
+
// ==========================================================================
|
|
11
|
+
.get("/translations", async (c) => {
|
|
12
|
+
const query = parseQuery(c, validation.productTranslationListQuerySchema);
|
|
13
|
+
return c.json(await productsService.listProductTranslations(c.get("db"), query));
|
|
14
|
+
})
|
|
15
|
+
.get("/translations/:translationId", async (c) => {
|
|
16
|
+
const row = await productsService.getProductTranslationById(c.get("db"), c.req.param("translationId"));
|
|
17
|
+
if (!row) {
|
|
18
|
+
return c.json({ error: "Product translation not found" }, 404);
|
|
19
|
+
}
|
|
20
|
+
return c.json({ data: row });
|
|
21
|
+
})
|
|
22
|
+
.post("/:id/translations", async (c) => {
|
|
23
|
+
const productId = c.req.param("id");
|
|
24
|
+
const body = await parseJsonBody(c, validation.insertProductTranslationSchema);
|
|
25
|
+
const row = await productsService.createProductTranslation(c.get("db"), productId, body);
|
|
26
|
+
if (!row) {
|
|
27
|
+
return c.json({ error: "Product not found" }, 404);
|
|
28
|
+
}
|
|
29
|
+
await appendProductMutationLedgerEntry(c, {
|
|
30
|
+
action: "create",
|
|
31
|
+
productId,
|
|
32
|
+
changedFields: changedMutationFields(body, null, row),
|
|
33
|
+
subject: "product translation",
|
|
34
|
+
actionName: "product.translation.create",
|
|
35
|
+
routeOrToolName: "products.translation.create",
|
|
36
|
+
});
|
|
37
|
+
await emitProductContentChanged(c.get("eventBus"), { id: productId, axis: "translation" });
|
|
38
|
+
return c.json({ data: row }, 201);
|
|
39
|
+
})
|
|
40
|
+
.patch("/translations/:translationId", async (c) => {
|
|
41
|
+
const translationId = c.req.param("translationId");
|
|
42
|
+
const body = await parseJsonBody(c, validation.updateProductTranslationSchema);
|
|
43
|
+
const before = await productsService.getProductTranslationById(c.get("db"), translationId);
|
|
44
|
+
if (!before) {
|
|
45
|
+
return c.json({ error: "Product translation not found" }, 404);
|
|
46
|
+
}
|
|
47
|
+
const row = await productsService.updateProductTranslation(c.get("db"), translationId, body);
|
|
48
|
+
if (!row) {
|
|
49
|
+
return c.json({ error: "Product translation not found" }, 404);
|
|
50
|
+
}
|
|
51
|
+
await appendProductMutationLedgerEntry(c, {
|
|
52
|
+
action: "update",
|
|
53
|
+
productId: row.productId,
|
|
54
|
+
changedFields: changedMutationFields(body, before, row),
|
|
55
|
+
subject: "product translation",
|
|
56
|
+
actionName: "product.translation.update",
|
|
57
|
+
routeOrToolName: "products.translation.update",
|
|
58
|
+
});
|
|
59
|
+
await emitProductContentChanged(c.get("eventBus"), {
|
|
60
|
+
id: row.productId,
|
|
61
|
+
axis: "translation",
|
|
62
|
+
});
|
|
63
|
+
return c.json({ data: row });
|
|
64
|
+
})
|
|
65
|
+
.delete("/translations/:translationId", async (c) => {
|
|
66
|
+
const translationId = c.req.param("translationId");
|
|
67
|
+
const before = await productsService.getProductTranslationById(c.get("db"), translationId);
|
|
68
|
+
if (!before) {
|
|
69
|
+
return c.json({ error: "Product translation not found" }, 404);
|
|
70
|
+
}
|
|
71
|
+
const row = await productsService.deleteProductTranslation(c.get("db"), translationId);
|
|
72
|
+
if (!row) {
|
|
73
|
+
return c.json({ error: "Product translation not found" }, 404);
|
|
74
|
+
}
|
|
75
|
+
await appendProductMutationLedgerEntry(c, {
|
|
76
|
+
action: "delete",
|
|
77
|
+
productId: before.productId,
|
|
78
|
+
changedFields: [],
|
|
79
|
+
subject: "product translation",
|
|
80
|
+
actionName: "product.translation.delete",
|
|
81
|
+
routeOrToolName: "products.translation.delete",
|
|
82
|
+
});
|
|
83
|
+
await emitProductContentChanged(c.get("eventBus"), {
|
|
84
|
+
id: before.productId,
|
|
85
|
+
axis: "translation",
|
|
86
|
+
});
|
|
87
|
+
return c.json({ success: true }, 200);
|
|
88
|
+
})
|
|
89
|
+
.get("/option-translations", async (c) => {
|
|
90
|
+
const query = parseQuery(c, validation.productOptionTranslationListQuerySchema);
|
|
91
|
+
return c.json(await productsService.listOptionTranslations(c.get("db"), query));
|
|
92
|
+
})
|
|
93
|
+
.get("/option-translations/:translationId", async (c) => {
|
|
94
|
+
const row = await productsService.getOptionTranslationById(c.get("db"), c.req.param("translationId"));
|
|
95
|
+
if (!row) {
|
|
96
|
+
return c.json({ error: "Option translation not found" }, 404);
|
|
97
|
+
}
|
|
98
|
+
return c.json({ data: row });
|
|
99
|
+
})
|
|
100
|
+
.post("/options/:optionId/translations", async (c) => {
|
|
101
|
+
const optionId = c.req.param("optionId");
|
|
102
|
+
const body = await parseJsonBody(c, validation.insertProductOptionTranslationSchema);
|
|
103
|
+
const option = await productsService.getOptionById(c.get("db"), optionId);
|
|
104
|
+
if (!option) {
|
|
105
|
+
return c.json({ error: "Product option not found" }, 404);
|
|
106
|
+
}
|
|
107
|
+
const row = await productsService.createOptionTranslation(c.get("db"), optionId, body);
|
|
108
|
+
if (!row) {
|
|
109
|
+
return c.json({ error: "Product option not found" }, 404);
|
|
110
|
+
}
|
|
111
|
+
await appendProductMutationLedgerEntry(c, {
|
|
112
|
+
action: "create",
|
|
113
|
+
productId: option.productId,
|
|
114
|
+
changedFields: changedMutationFields(body, null, row),
|
|
115
|
+
subject: "product option translation",
|
|
116
|
+
actionName: "product.option_translation.create",
|
|
117
|
+
routeOrToolName: "products.option_translation.create",
|
|
118
|
+
});
|
|
119
|
+
await emitProductContentChanged(c.get("eventBus"), {
|
|
120
|
+
id: option.productId,
|
|
121
|
+
axis: "translation",
|
|
122
|
+
});
|
|
123
|
+
return c.json({ data: row }, 201);
|
|
124
|
+
})
|
|
125
|
+
.patch("/option-translations/:translationId", async (c) => {
|
|
126
|
+
const translationId = c.req.param("translationId");
|
|
127
|
+
const body = await parseJsonBody(c, validation.updateProductOptionTranslationSchema);
|
|
128
|
+
const before = await productsService.getOptionTranslationForProductMutation(c.get("db"), translationId);
|
|
129
|
+
if (!before) {
|
|
130
|
+
return c.json({ error: "Option translation not found" }, 404);
|
|
131
|
+
}
|
|
132
|
+
const row = await productsService.updateOptionTranslation(c.get("db"), translationId, body);
|
|
133
|
+
if (!row) {
|
|
134
|
+
return c.json({ error: "Option translation not found" }, 404);
|
|
135
|
+
}
|
|
136
|
+
await appendProductMutationLedgerEntry(c, {
|
|
137
|
+
action: "update",
|
|
138
|
+
productId: before.productId,
|
|
139
|
+
changedFields: changedMutationFields(body, before, row),
|
|
140
|
+
subject: "product option translation",
|
|
141
|
+
actionName: "product.option_translation.update",
|
|
142
|
+
routeOrToolName: "products.option_translation.update",
|
|
143
|
+
});
|
|
144
|
+
await emitProductContentChanged(c.get("eventBus"), {
|
|
145
|
+
id: before.productId,
|
|
146
|
+
axis: "translation",
|
|
147
|
+
});
|
|
148
|
+
return c.json({ data: row });
|
|
149
|
+
})
|
|
150
|
+
.delete("/option-translations/:translationId", async (c) => {
|
|
151
|
+
const translationId = c.req.param("translationId");
|
|
152
|
+
const before = await productsService.getOptionTranslationForProductMutation(c.get("db"), translationId);
|
|
153
|
+
if (!before) {
|
|
154
|
+
return c.json({ error: "Option translation not found" }, 404);
|
|
155
|
+
}
|
|
156
|
+
const row = await productsService.deleteOptionTranslation(c.get("db"), translationId);
|
|
157
|
+
if (!row) {
|
|
158
|
+
return c.json({ error: "Option translation not found" }, 404);
|
|
159
|
+
}
|
|
160
|
+
await appendProductMutationLedgerEntry(c, {
|
|
161
|
+
action: "delete",
|
|
162
|
+
productId: before.productId,
|
|
163
|
+
changedFields: [],
|
|
164
|
+
subject: "product option translation",
|
|
165
|
+
actionName: "product.option_translation.delete",
|
|
166
|
+
routeOrToolName: "products.option_translation.delete",
|
|
167
|
+
});
|
|
168
|
+
await emitProductContentChanged(c.get("eventBus"), {
|
|
169
|
+
id: before.productId,
|
|
170
|
+
axis: "translation",
|
|
171
|
+
});
|
|
172
|
+
return c.json({ success: true }, 200);
|
|
173
|
+
})
|
|
174
|
+
.get("/unit-translations", async (c) => {
|
|
175
|
+
const query = parseQuery(c, validation.optionUnitTranslationListQuerySchema);
|
|
176
|
+
return c.json(await productsService.listUnitTranslations(c.get("db"), query));
|
|
177
|
+
})
|
|
178
|
+
.get("/unit-translations/:translationId", async (c) => {
|
|
179
|
+
const row = await productsService.getUnitTranslationById(c.get("db"), c.req.param("translationId"));
|
|
180
|
+
if (!row) {
|
|
181
|
+
return c.json({ error: "Unit translation not found" }, 404);
|
|
182
|
+
}
|
|
183
|
+
return c.json({ data: row });
|
|
184
|
+
})
|
|
185
|
+
.post("/units/:unitId/translations", async (c) => {
|
|
186
|
+
const unitId = c.req.param("unitId");
|
|
187
|
+
const body = await parseJsonBody(c, validation.insertOptionUnitTranslationSchema);
|
|
188
|
+
const unit = await productsService.getUnitForProductMutation(c.get("db"), unitId);
|
|
189
|
+
if (!unit) {
|
|
190
|
+
return c.json({ error: "Option unit not found" }, 404);
|
|
191
|
+
}
|
|
192
|
+
const row = await productsService.createUnitTranslation(c.get("db"), unitId, body);
|
|
193
|
+
if (!row) {
|
|
194
|
+
return c.json({ error: "Option unit not found" }, 404);
|
|
195
|
+
}
|
|
196
|
+
await appendProductMutationLedgerEntry(c, {
|
|
197
|
+
action: "create",
|
|
198
|
+
productId: unit.productId,
|
|
199
|
+
changedFields: changedMutationFields(body, null, row),
|
|
200
|
+
subject: "product option unit translation",
|
|
201
|
+
actionName: "product.option_unit_translation.create",
|
|
202
|
+
routeOrToolName: "products.option_unit_translation.create",
|
|
203
|
+
});
|
|
204
|
+
await emitProductContentChanged(c.get("eventBus"), {
|
|
205
|
+
id: unit.productId,
|
|
206
|
+
axis: "translation",
|
|
207
|
+
});
|
|
208
|
+
return c.json({ data: row }, 201);
|
|
209
|
+
})
|
|
210
|
+
.patch("/unit-translations/:translationId", async (c) => {
|
|
211
|
+
const translationId = c.req.param("translationId");
|
|
212
|
+
const body = await parseJsonBody(c, validation.updateOptionUnitTranslationSchema);
|
|
213
|
+
const before = await productsService.getUnitTranslationForProductMutation(c.get("db"), translationId);
|
|
214
|
+
if (!before) {
|
|
215
|
+
return c.json({ error: "Unit translation not found" }, 404);
|
|
216
|
+
}
|
|
217
|
+
const row = await productsService.updateUnitTranslation(c.get("db"), translationId, body);
|
|
218
|
+
if (!row) {
|
|
219
|
+
return c.json({ error: "Unit translation not found" }, 404);
|
|
220
|
+
}
|
|
221
|
+
await appendProductMutationLedgerEntry(c, {
|
|
222
|
+
action: "update",
|
|
223
|
+
productId: before.productId,
|
|
224
|
+
changedFields: changedMutationFields(body, before, row),
|
|
225
|
+
subject: "product option unit translation",
|
|
226
|
+
actionName: "product.option_unit_translation.update",
|
|
227
|
+
routeOrToolName: "products.option_unit_translation.update",
|
|
228
|
+
});
|
|
229
|
+
await emitProductContentChanged(c.get("eventBus"), {
|
|
230
|
+
id: before.productId,
|
|
231
|
+
axis: "translation",
|
|
232
|
+
});
|
|
233
|
+
return c.json({ data: row });
|
|
234
|
+
})
|
|
235
|
+
.delete("/unit-translations/:translationId", async (c) => {
|
|
236
|
+
const translationId = c.req.param("translationId");
|
|
237
|
+
const before = await productsService.getUnitTranslationForProductMutation(c.get("db"), translationId);
|
|
238
|
+
if (!before) {
|
|
239
|
+
return c.json({ error: "Unit translation not found" }, 404);
|
|
240
|
+
}
|
|
241
|
+
const row = await productsService.deleteUnitTranslation(c.get("db"), translationId);
|
|
242
|
+
if (!row) {
|
|
243
|
+
return c.json({ error: "Unit translation not found" }, 404);
|
|
244
|
+
}
|
|
245
|
+
await appendProductMutationLedgerEntry(c, {
|
|
246
|
+
action: "delete",
|
|
247
|
+
productId: before.productId,
|
|
248
|
+
changedFields: [],
|
|
249
|
+
subject: "product option unit translation",
|
|
250
|
+
actionName: "product.option_unit_translation.delete",
|
|
251
|
+
routeOrToolName: "products.option_unit_translation.delete",
|
|
252
|
+
});
|
|
253
|
+
await emitProductContentChanged(c.get("eventBus"), {
|
|
254
|
+
id: before.productId,
|
|
255
|
+
axis: "translation",
|
|
256
|
+
});
|
|
257
|
+
return c.json({ success: true }, 200);
|
|
258
|
+
});
|