@voyant-travel/inventory 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/LICENSE +201 -0
- 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 +338 -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/authoring/builder.d.ts +37 -0
- package/dist/authoring/builder.d.ts.map +1 -0
- package/dist/authoring/builder.js +248 -0
- package/dist/authoring/clone-content.d.ts +38 -0
- package/dist/authoring/clone-content.d.ts.map +1 -0
- package/dist/authoring/clone-content.js +367 -0
- package/dist/authoring/clone-pricing.d.ts +9 -0
- package/dist/authoring/clone-pricing.d.ts.map +1 -0
- package/dist/authoring/clone-pricing.js +242 -0
- package/dist/authoring/clone.d.ts +45 -0
- package/dist/authoring/clone.d.ts.map +1 -0
- package/dist/authoring/clone.js +142 -0
- package/dist/authoring/errors.d.ts +21 -0
- package/dist/authoring/errors.d.ts.map +1 -0
- package/dist/authoring/errors.js +13 -0
- package/dist/authoring/extension.d.ts +248 -0
- package/dist/authoring/extension.d.ts.map +1 -0
- package/dist/authoring/extension.js +116 -0
- package/dist/authoring/index.d.ts +12 -0
- package/dist/authoring/index.d.ts.map +1 -0
- package/dist/authoring/index.js +11 -0
- package/dist/authoring/schema.d.ts +85 -0
- package/dist/authoring/schema.d.ts.map +1 -0
- package/dist/authoring/schema.js +16 -0
- package/dist/authoring/service.d.ts +28 -0
- package/dist/authoring/service.d.ts.map +1 -0
- package/dist/authoring/service.js +66 -0
- package/dist/authoring/spec.d.ts +524 -0
- package/dist/authoring/spec.d.ts.map +1 -0
- package/dist/authoring/spec.js +167 -0
- package/dist/authoring/validate.d.ts +17 -0
- package/dist/authoring/validate.d.ts.map +1 -0
- package/dist/authoring/validate.js +83 -0
- package/dist/authoring.d.ts +2 -0
- package/dist/authoring.d.ts.map +1 -0
- package/dist/authoring.js +1 -0
- package/dist/booking-engine/handler-support.d.ts +91 -0
- package/dist/booking-engine/handler-support.d.ts.map +1 -0
- package/dist/booking-engine/handler-support.js +355 -0
- package/dist/booking-engine/handler.d.ts +404 -0
- package/dist/booking-engine/handler.d.ts.map +1 -0
- package/dist/booking-engine/handler.js +398 -0
- package/dist/booking-engine/index.d.ts +8 -0
- package/dist/booking-engine/index.d.ts.map +1 -0
- package/dist/booking-engine/index.js +7 -0
- package/dist/booking-engine.d.ts +2 -0
- package/dist/booking-engine.d.ts.map +1 -0
- package/dist/booking-engine.js +1 -0
- package/dist/booking-extension.d.ts +278 -0
- package/dist/booking-extension.d.ts.map +1 -0
- package/dist/booking-extension.js +161 -0
- package/dist/catalog-policy-departures.d.ts +52 -0
- package/dist/catalog-policy-departures.d.ts.map +1 -0
- package/dist/catalog-policy-departures.js +169 -0
- package/dist/catalog-policy-destinations.d.ts +43 -0
- package/dist/catalog-policy-destinations.d.ts.map +1 -0
- package/dist/catalog-policy-destinations.js +165 -0
- package/dist/catalog-policy-pricing.d.ts +55 -0
- package/dist/catalog-policy-pricing.d.ts.map +1 -0
- package/dist/catalog-policy-pricing.js +109 -0
- package/dist/catalog-policy-promotions.d.ts +52 -0
- package/dist/catalog-policy-promotions.d.ts.map +1 -0
- package/dist/catalog-policy-promotions.js +270 -0
- package/dist/catalog-policy-taxonomy.d.ts +51 -0
- package/dist/catalog-policy-taxonomy.d.ts.map +1 -0
- package/dist/catalog-policy-taxonomy.js +191 -0
- package/dist/catalog-policy.d.ts +33 -0
- package/dist/catalog-policy.d.ts.map +1 -0
- package/dist/catalog-policy.js +733 -0
- package/dist/content-shape.d.ts +15 -0
- package/dist/content-shape.d.ts.map +1 -0
- package/dist/content-shape.js +28 -0
- package/dist/draft-shape.d.ts +43 -0
- package/dist/draft-shape.d.ts.map +1 -0
- package/dist/draft-shape.js +48 -0
- package/dist/events.d.ts +37 -0
- package/dist/events.d.ts.map +1 -0
- package/dist/events.js +32 -0
- package/dist/extras/catalog-policy.d.ts +30 -0
- package/dist/extras/catalog-policy.d.ts.map +1 -0
- package/dist/extras/catalog-policy.js +319 -0
- package/dist/extras/content-shape.d.ts +5 -0
- package/dist/extras/content-shape.d.ts.map +1 -0
- package/dist/extras/content-shape.js +13 -0
- package/dist/extras/draft-shape.d.ts +34 -0
- package/dist/extras/draft-shape.d.ts.map +1 -0
- package/dist/extras/draft-shape.js +69 -0
- package/dist/extras/routes.d.ts +380 -0
- package/dist/extras/routes.d.ts.map +1 -0
- package/dist/extras/routes.js +59 -0
- package/dist/extras/schema-sourced-content.d.ts +254 -0
- package/dist/extras/schema-sourced-content.d.ts.map +1 -0
- package/dist/extras/schema-sourced-content.js +45 -0
- package/dist/extras/schema.d.ts +628 -0
- package/dist/extras/schema.d.ts.map +1 -0
- package/dist/extras/schema.js +87 -0
- package/dist/extras/service-catalog-plane.d.ts +77 -0
- package/dist/extras/service-catalog-plane.d.ts.map +1 -0
- package/dist/extras/service-catalog-plane.js +219 -0
- package/dist/extras/service-content-synthesizer.d.ts +41 -0
- package/dist/extras/service-content-synthesizer.d.ts.map +1 -0
- package/dist/extras/service-content-synthesizer.js +138 -0
- package/dist/extras/service-content.d.ts +48 -0
- package/dist/extras/service-content.d.ts.map +1 -0
- package/dist/extras/service-content.js +253 -0
- package/dist/extras/service.d.ts +185 -0
- package/dist/extras/service.d.ts.map +1 -0
- package/dist/extras/service.js +96 -0
- package/dist/extras/validation.d.ts +437 -0
- package/dist/extras/validation.d.ts.map +1 -0
- package/dist/extras/validation.js +149 -0
- package/dist/extras.d.ts +267 -0
- package/dist/extras.d.ts.map +1 -0
- package/dist/extras.js +19 -0
- package/dist/index.d.ts +22 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +32 -0
- package/dist/interface.d.ts +5869 -0
- package/dist/interface.d.ts.map +1 -0
- package/dist/interface.js +54 -0
- package/dist/public-routes.d.ts +2 -0
- package/dist/public-routes.d.ts.map +1 -0
- package/dist/public-routes.js +1 -0
- package/dist/public-validation.d.ts +2 -0
- package/dist/public-validation.d.ts.map +1 -0
- package/dist/public-validation.js +1 -0
- package/dist/read-model.d.ts +25 -0
- package/dist/read-model.d.ts.map +1 -0
- package/dist/read-model.js +99 -0
- 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-content.d.ts +74 -0
- package/dist/routes-content.d.ts.map +1 -0
- package/dist/routes-content.js +117 -0
- package/dist/routes-core.d.ts +331 -0
- package/dist/routes-core.d.ts.map +1 -0
- package/dist/routes-core.js +95 -0
- package/dist/routes-itinerary.d.ts +759 -0
- package/dist/routes-itinerary.d.ts.map +1 -0
- package/dist/routes-itinerary.js +387 -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 +1120 -0
- package/dist/routes-merchandising.d.ts.map +1 -0
- package/dist/routes-merchandising.js +377 -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 +776 -0
- package/dist/routes-public.d.ts.map +1 -0
- package/dist/routes-public.js +119 -0
- package/dist/routes-translations.d.ts +489 -0
- package/dist/routes-translations.d.ts.map +1 -0
- package/dist/routes-translations.js +258 -0
- package/dist/routes.d.ts +5097 -0
- package/dist/routes.d.ts.map +1 -0
- package/dist/routes.js +64 -0
- package/dist/schema-core.d.ts +1238 -0
- package/dist/schema-core.d.ts.map +1 -0
- package/dist/schema-core.js +157 -0
- package/dist/schema-itinerary.d.ts +1169 -0
- package/dist/schema-itinerary.d.ts.map +1 -0
- package/dist/schema-itinerary.js +130 -0
- package/dist/schema-relations.d.ts +117 -0
- package/dist/schema-relations.d.ts.map +1 -0
- package/dist/schema-relations.js +192 -0
- package/dist/schema-settings.d.ts +1800 -0
- package/dist/schema-settings.d.ts.map +1 -0
- package/dist/schema-settings.js +220 -0
- package/dist/schema-shared.d.ts +15 -0
- package/dist/schema-shared.d.ts.map +1 -0
- package/dist/schema-shared.js +91 -0
- package/dist/schema-sourced-content.d.ts +262 -0
- package/dist/schema-sourced-content.d.ts.map +1 -0
- package/dist/schema-sourced-content.js +69 -0
- package/dist/schema-taxonomy.d.ts +1363 -0
- package/dist/schema-taxonomy.d.ts.map +1 -0
- package/dist/schema-taxonomy.js +203 -0
- package/dist/schema.d.ts +10 -0
- package/dist/schema.d.ts.map +1 -0
- package/dist/schema.js +9 -0
- package/dist/service-aggregates.d.ts +29 -0
- package/dist/service-aggregates.d.ts.map +1 -0
- package/dist/service-aggregates.js +56 -0
- package/dist/service-catalog-plane-destinations.d.ts +30 -0
- package/dist/service-catalog-plane-destinations.d.ts.map +1 -0
- package/dist/service-catalog-plane-destinations.js +143 -0
- package/dist/service-catalog-plane-taxonomy.d.ts +73 -0
- package/dist/service-catalog-plane-taxonomy.d.ts.map +1 -0
- package/dist/service-catalog-plane-taxonomy.js +242 -0
- package/dist/service-catalog-plane.d.ts +179 -0
- package/dist/service-catalog-plane.d.ts.map +1 -0
- package/dist/service-catalog-plane.js +431 -0
- package/dist/service-catalog.d.ts +251 -0
- package/dist/service-catalog.d.ts.map +1 -0
- package/dist/service-catalog.js +517 -0
- package/dist/service-configuration.d.ts +261 -0
- package/dist/service-configuration.d.ts.map +1 -0
- package/dist/service-configuration.js +343 -0
- package/dist/service-content-owned.d.ts +68 -0
- package/dist/service-content-owned.d.ts.map +1 -0
- package/dist/service-content-owned.js +329 -0
- package/dist/service-content-synthesizer.d.ts +90 -0
- package/dist/service-content-synthesizer.d.ts.map +1 -0
- package/dist/service-content-synthesizer.js +178 -0
- package/dist/service-content.d.ts +106 -0
- package/dist/service-content.d.ts.map +1 -0
- package/dist/service-content.js +388 -0
- package/dist/service-core.d.ts +194 -0
- package/dist/service-core.d.ts.map +1 -0
- package/dist/service-core.js +213 -0
- package/dist/service-delivery-formats.d.ts +58 -0
- package/dist/service-delivery-formats.d.ts.map +1 -0
- package/dist/service-delivery-formats.js +107 -0
- package/dist/service-destinations.d.ts +223 -0
- package/dist/service-destinations.d.ts.map +1 -0
- package/dist/service-destinations.js +310 -0
- package/dist/service-itinerary-history.d.ts +457 -0
- package/dist/service-itinerary-history.d.ts.map +1 -0
- package/dist/service-itinerary-history.js +135 -0
- package/dist/service-itinerary.d.ts +1149 -0
- package/dist/service-itinerary.d.ts.map +1 -0
- package/dist/service-itinerary.js +419 -0
- package/dist/service-media.d.ts +272 -0
- package/dist/service-media.d.ts.map +1 -0
- package/dist/service-media.js +320 -0
- package/dist/service-merchandising.d.ts +184 -0
- package/dist/service-merchandising.d.ts.map +1 -0
- package/dist/service-merchandising.js +181 -0
- package/dist/service-option-translations.d.ts +268 -0
- package/dist/service-option-translations.d.ts.map +1 -0
- package/dist/service-option-translations.js +300 -0
- package/dist/service-options.d.ts +181 -0
- package/dist/service-options.d.ts.map +1 -0
- package/dist/service-options.js +179 -0
- package/dist/service-product-destinations.d.ts +37 -0
- package/dist/service-product-destinations.d.ts.map +1 -0
- package/dist/service-product-destinations.js +94 -0
- package/dist/service-public.d.ts +664 -0
- package/dist/service-public.d.ts.map +1 -0
- package/dist/service-public.js +374 -0
- package/dist/service-taxonomy.d.ts +197 -0
- package/dist/service-taxonomy.d.ts.map +1 -0
- package/dist/service-taxonomy.js +221 -0
- package/dist/service.d.ts +3929 -0
- package/dist/service.d.ts.map +1 -0
- package/dist/service.js +28 -0
- package/dist/tasks/brochure-printers.d.ts +31 -0
- package/dist/tasks/brochure-printers.d.ts.map +1 -0
- package/dist/tasks/brochure-printers.js +149 -0
- package/dist/tasks/brochure-templates.d.ts +36 -0
- package/dist/tasks/brochure-templates.d.ts.map +1 -0
- package/dist/tasks/brochure-templates.js +110 -0
- package/dist/tasks/brochures.d.ts +43 -0
- package/dist/tasks/brochures.d.ts.map +1 -0
- package/dist/tasks/brochures.js +72 -0
- package/dist/tasks/generate-pdf.d.ts +8 -0
- package/dist/tasks/generate-pdf.d.ts.map +1 -0
- package/dist/tasks/generate-pdf.js +106 -0
- package/dist/tasks/index.d.ts +5 -0
- package/dist/tasks/index.d.ts.map +1 -0
- package/dist/tasks/index.js +4 -0
- package/dist/tasks/pdf-text.d.ts +2 -0
- package/dist/tasks/pdf-text.d.ts.map +1 -0
- package/dist/tasks/pdf-text.js +40 -0
- package/dist/tasks.d.ts +2 -0
- package/dist/tasks.d.ts.map +1 -0
- package/dist/tasks.js +1 -0
- package/dist/validation-catalog.d.ts +2 -0
- package/dist/validation-catalog.d.ts.map +1 -0
- package/dist/validation-catalog.js +3 -0
- package/dist/validation-config.d.ts +2 -0
- package/dist/validation-config.d.ts.map +1 -0
- package/dist/validation-config.js +3 -0
- package/dist/validation-content.d.ts +2 -0
- package/dist/validation-content.d.ts.map +1 -0
- package/dist/validation-content.js +3 -0
- package/dist/validation-core.d.ts +2 -0
- package/dist/validation-core.d.ts.map +1 -0
- package/dist/validation-core.js +3 -0
- package/dist/validation-public.d.ts +2 -0
- package/dist/validation-public.d.ts.map +1 -0
- package/dist/validation-public.js +3 -0
- package/dist/validation-shared.d.ts +2 -0
- package/dist/validation-shared.d.ts.map +1 -0
- package/dist/validation-shared.js +3 -0
- package/dist/validation.d.ts +2 -0
- package/dist/validation.d.ts.map +1 -0
- package/dist/validation.js +3 -0
- package/package.json +204 -0
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
import type { PostgresJsDatabase } from "drizzle-orm/postgres-js";
|
|
2
|
+
import type { z } from "zod";
|
|
3
|
+
import type { destinationListQuerySchema, destinationTranslationListQuerySchema, insertDestinationSchema, insertDestinationTranslationSchema, insertProductCategoryTranslationSchema, insertProductTagTranslationSchema, productCategoryTranslationListQuerySchema, productTagTranslationListQuerySchema, updateDestinationSchema, updateDestinationTranslationSchema, updateProductCategoryTranslationSchema, updateProductTagTranslationSchema } from "./validation.js";
|
|
4
|
+
type DestinationListQuery = z.infer<typeof destinationListQuerySchema>;
|
|
5
|
+
type CreateDestinationInput = z.infer<typeof insertDestinationSchema>;
|
|
6
|
+
type UpdateDestinationInput = z.infer<typeof updateDestinationSchema>;
|
|
7
|
+
type DestinationTranslationListQuery = z.infer<typeof destinationTranslationListQuerySchema>;
|
|
8
|
+
type CreateDestinationTranslationInput = z.infer<typeof insertDestinationTranslationSchema>;
|
|
9
|
+
type UpdateDestinationTranslationInput = z.infer<typeof updateDestinationTranslationSchema>;
|
|
10
|
+
type ProductCategoryTranslationListQuery = z.infer<typeof productCategoryTranslationListQuerySchema>;
|
|
11
|
+
type CreateProductCategoryTranslationInput = z.infer<typeof insertProductCategoryTranslationSchema>;
|
|
12
|
+
type UpdateProductCategoryTranslationInput = z.infer<typeof updateProductCategoryTranslationSchema>;
|
|
13
|
+
type ProductTagTranslationListQuery = z.infer<typeof productTagTranslationListQuerySchema>;
|
|
14
|
+
type CreateProductTagTranslationInput = z.infer<typeof insertProductTagTranslationSchema>;
|
|
15
|
+
type UpdateProductTagTranslationInput = z.infer<typeof updateProductTagTranslationSchema>;
|
|
16
|
+
export declare const destinationProductsService: {
|
|
17
|
+
listDestinations(db: PostgresJsDatabase, query: DestinationListQuery): Promise<{
|
|
18
|
+
data: {
|
|
19
|
+
translation: {
|
|
20
|
+
id: string;
|
|
21
|
+
destinationId: string;
|
|
22
|
+
languageTag: string;
|
|
23
|
+
name: string;
|
|
24
|
+
description: string | null;
|
|
25
|
+
seoTitle: string | null;
|
|
26
|
+
seoDescription: string | null;
|
|
27
|
+
createdAt: Date;
|
|
28
|
+
updatedAt: Date;
|
|
29
|
+
} | null;
|
|
30
|
+
id: string;
|
|
31
|
+
parentId: string | null;
|
|
32
|
+
slug: string;
|
|
33
|
+
code: string | null;
|
|
34
|
+
canonicalPlaceId: string | null;
|
|
35
|
+
destinationType: string;
|
|
36
|
+
latitude: number | null;
|
|
37
|
+
longitude: number | null;
|
|
38
|
+
sortOrder: number;
|
|
39
|
+
active: boolean;
|
|
40
|
+
metadata: Record<string, unknown> | null;
|
|
41
|
+
createdAt: Date;
|
|
42
|
+
updatedAt: Date;
|
|
43
|
+
}[];
|
|
44
|
+
total: number;
|
|
45
|
+
limit: number;
|
|
46
|
+
offset: number;
|
|
47
|
+
}>;
|
|
48
|
+
getDestinationById(db: PostgresJsDatabase, id: string): Promise<{
|
|
49
|
+
translations: {
|
|
50
|
+
id: string;
|
|
51
|
+
destinationId: string;
|
|
52
|
+
languageTag: string;
|
|
53
|
+
name: string;
|
|
54
|
+
description: string | null;
|
|
55
|
+
seoTitle: string | null;
|
|
56
|
+
seoDescription: string | null;
|
|
57
|
+
createdAt: Date;
|
|
58
|
+
updatedAt: Date;
|
|
59
|
+
}[];
|
|
60
|
+
id: string;
|
|
61
|
+
parentId: string | null;
|
|
62
|
+
slug: string;
|
|
63
|
+
code: string | null;
|
|
64
|
+
canonicalPlaceId: string | null;
|
|
65
|
+
destinationType: string;
|
|
66
|
+
latitude: number | null;
|
|
67
|
+
longitude: number | null;
|
|
68
|
+
sortOrder: number;
|
|
69
|
+
active: boolean;
|
|
70
|
+
metadata: Record<string, unknown> | null;
|
|
71
|
+
createdAt: Date;
|
|
72
|
+
updatedAt: Date;
|
|
73
|
+
} | null>;
|
|
74
|
+
createDestination(db: PostgresJsDatabase, data: CreateDestinationInput): Promise<{
|
|
75
|
+
id: string;
|
|
76
|
+
active: boolean;
|
|
77
|
+
createdAt: Date;
|
|
78
|
+
updatedAt: Date;
|
|
79
|
+
metadata: Record<string, unknown> | null;
|
|
80
|
+
code: string | null;
|
|
81
|
+
sortOrder: number;
|
|
82
|
+
latitude: number | null;
|
|
83
|
+
longitude: number | null;
|
|
84
|
+
parentId: string | null;
|
|
85
|
+
destinationType: string;
|
|
86
|
+
canonicalPlaceId: string | null;
|
|
87
|
+
slug: string;
|
|
88
|
+
} | null>;
|
|
89
|
+
updateDestination(db: PostgresJsDatabase, id: string, data: UpdateDestinationInput): Promise<{
|
|
90
|
+
id: string;
|
|
91
|
+
parentId: string | null;
|
|
92
|
+
slug: string;
|
|
93
|
+
code: string | null;
|
|
94
|
+
canonicalPlaceId: string | null;
|
|
95
|
+
destinationType: string;
|
|
96
|
+
latitude: number | null;
|
|
97
|
+
longitude: number | null;
|
|
98
|
+
sortOrder: number;
|
|
99
|
+
active: boolean;
|
|
100
|
+
metadata: Record<string, unknown> | null;
|
|
101
|
+
createdAt: Date;
|
|
102
|
+
updatedAt: Date;
|
|
103
|
+
} | null>;
|
|
104
|
+
deleteDestination(db: PostgresJsDatabase, id: string): Promise<{
|
|
105
|
+
id: string;
|
|
106
|
+
} | null>;
|
|
107
|
+
listDestinationTranslations(db: PostgresJsDatabase, query: DestinationTranslationListQuery): Promise<{
|
|
108
|
+
data: {
|
|
109
|
+
id: string;
|
|
110
|
+
destinationId: string;
|
|
111
|
+
languageTag: string;
|
|
112
|
+
name: string;
|
|
113
|
+
description: string | null;
|
|
114
|
+
seoTitle: string | null;
|
|
115
|
+
seoDescription: string | null;
|
|
116
|
+
createdAt: Date;
|
|
117
|
+
updatedAt: Date;
|
|
118
|
+
}[];
|
|
119
|
+
total: number;
|
|
120
|
+
limit: number;
|
|
121
|
+
offset: number;
|
|
122
|
+
}>;
|
|
123
|
+
upsertDestinationTranslation(db: PostgresJsDatabase, destinationId: string, data: CreateDestinationTranslationInput): Promise<{
|
|
124
|
+
id: string;
|
|
125
|
+
name: string;
|
|
126
|
+
description: string | null;
|
|
127
|
+
createdAt: Date;
|
|
128
|
+
updatedAt: Date;
|
|
129
|
+
languageTag: string;
|
|
130
|
+
destinationId: string;
|
|
131
|
+
seoTitle: string | null;
|
|
132
|
+
seoDescription: string | null;
|
|
133
|
+
} | null>;
|
|
134
|
+
updateDestinationTranslation(db: PostgresJsDatabase, id: string, data: UpdateDestinationTranslationInput): Promise<{
|
|
135
|
+
id: string;
|
|
136
|
+
destinationId: string;
|
|
137
|
+
languageTag: string;
|
|
138
|
+
name: string;
|
|
139
|
+
description: string | null;
|
|
140
|
+
seoTitle: string | null;
|
|
141
|
+
seoDescription: string | null;
|
|
142
|
+
createdAt: Date;
|
|
143
|
+
updatedAt: Date;
|
|
144
|
+
} | null>;
|
|
145
|
+
deleteDestinationTranslation(db: PostgresJsDatabase, id: string): Promise<{
|
|
146
|
+
id: string;
|
|
147
|
+
} | null>;
|
|
148
|
+
listProductCategoryTranslations(db: PostgresJsDatabase, query: ProductCategoryTranslationListQuery): Promise<{
|
|
149
|
+
data: {
|
|
150
|
+
id: string;
|
|
151
|
+
categoryId: string;
|
|
152
|
+
languageTag: string;
|
|
153
|
+
name: string;
|
|
154
|
+
description: string | null;
|
|
155
|
+
seoTitle: string | null;
|
|
156
|
+
seoDescription: string | null;
|
|
157
|
+
createdAt: Date;
|
|
158
|
+
updatedAt: Date;
|
|
159
|
+
}[];
|
|
160
|
+
total: number;
|
|
161
|
+
limit: number;
|
|
162
|
+
offset: number;
|
|
163
|
+
}>;
|
|
164
|
+
upsertProductCategoryTranslation(db: PostgresJsDatabase, categoryId: string, data: CreateProductCategoryTranslationInput): Promise<{
|
|
165
|
+
id: string;
|
|
166
|
+
name: string;
|
|
167
|
+
description: string | null;
|
|
168
|
+
createdAt: Date;
|
|
169
|
+
updatedAt: Date;
|
|
170
|
+
categoryId: string;
|
|
171
|
+
languageTag: string;
|
|
172
|
+
seoTitle: string | null;
|
|
173
|
+
seoDescription: string | null;
|
|
174
|
+
} | null>;
|
|
175
|
+
updateProductCategoryTranslation(db: PostgresJsDatabase, id: string, data: UpdateProductCategoryTranslationInput): Promise<{
|
|
176
|
+
id: string;
|
|
177
|
+
categoryId: string;
|
|
178
|
+
languageTag: string;
|
|
179
|
+
name: string;
|
|
180
|
+
description: string | null;
|
|
181
|
+
seoTitle: string | null;
|
|
182
|
+
seoDescription: string | null;
|
|
183
|
+
createdAt: Date;
|
|
184
|
+
updatedAt: Date;
|
|
185
|
+
} | null>;
|
|
186
|
+
deleteProductCategoryTranslation(db: PostgresJsDatabase, id: string): Promise<{
|
|
187
|
+
id: string;
|
|
188
|
+
} | null>;
|
|
189
|
+
listProductTagTranslations(db: PostgresJsDatabase, query: ProductTagTranslationListQuery): Promise<{
|
|
190
|
+
data: {
|
|
191
|
+
id: string;
|
|
192
|
+
tagId: string;
|
|
193
|
+
languageTag: string;
|
|
194
|
+
name: string;
|
|
195
|
+
createdAt: Date;
|
|
196
|
+
updatedAt: Date;
|
|
197
|
+
}[];
|
|
198
|
+
total: number;
|
|
199
|
+
limit: number;
|
|
200
|
+
offset: number;
|
|
201
|
+
}>;
|
|
202
|
+
upsertProductTagTranslation(db: PostgresJsDatabase, tagId: string, data: CreateProductTagTranslationInput): Promise<{
|
|
203
|
+
id: string;
|
|
204
|
+
name: string;
|
|
205
|
+
createdAt: Date;
|
|
206
|
+
updatedAt: Date;
|
|
207
|
+
languageTag: string;
|
|
208
|
+
tagId: string;
|
|
209
|
+
} | null>;
|
|
210
|
+
updateProductTagTranslation(db: PostgresJsDatabase, id: string, data: UpdateProductTagTranslationInput): Promise<{
|
|
211
|
+
id: string;
|
|
212
|
+
tagId: string;
|
|
213
|
+
languageTag: string;
|
|
214
|
+
name: string;
|
|
215
|
+
createdAt: Date;
|
|
216
|
+
updatedAt: Date;
|
|
217
|
+
} | null>;
|
|
218
|
+
deleteProductTagTranslation(db: PostgresJsDatabase, id: string): Promise<{
|
|
219
|
+
id: string;
|
|
220
|
+
} | null>;
|
|
221
|
+
};
|
|
222
|
+
export {};
|
|
223
|
+
//# sourceMappingURL=service-destinations.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"service-destinations.d.ts","sourceRoot":"","sources":["../src/service-destinations.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAA;AACjE,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAS5B,OAAO,KAAK,EACV,0BAA0B,EAC1B,qCAAqC,EACrC,uBAAuB,EACvB,kCAAkC,EAClC,sCAAsC,EACtC,iCAAiC,EACjC,yCAAyC,EACzC,oCAAoC,EACpC,uBAAuB,EACvB,kCAAkC,EAClC,sCAAsC,EACtC,iCAAiC,EAClC,MAAM,iBAAiB,CAAA;AAExB,KAAK,oBAAoB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,0BAA0B,CAAC,CAAA;AACtE,KAAK,sBAAsB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,uBAAuB,CAAC,CAAA;AACrE,KAAK,sBAAsB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,uBAAuB,CAAC,CAAA;AACrE,KAAK,+BAA+B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qCAAqC,CAAC,CAAA;AAC5F,KAAK,iCAAiC,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kCAAkC,CAAC,CAAA;AAC3F,KAAK,iCAAiC,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kCAAkC,CAAC,CAAA;AAC3F,KAAK,mCAAmC,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,yCAAyC,CAAC,CAAA;AACpG,KAAK,qCAAqC,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,sCAAsC,CAAC,CAAA;AACnG,KAAK,qCAAqC,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,sCAAsC,CAAC,CAAA;AACnG,KAAK,8BAA8B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oCAAoC,CAAC,CAAA;AAC1F,KAAK,gCAAgC,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,iCAAiC,CAAC,CAAA;AACzF,KAAK,gCAAgC,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,iCAAiC,CAAC,CAAA;AAEzF,eAAO,MAAM,0BAA0B;yBACV,kBAAkB,SAAS,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;2BA6F7C,kBAAkB,MAAM,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;0BAkB/B,kBAAkB,QAAQ,sBAAsB;;;;;;;;;;;;;;;0BAKhD,kBAAkB,MAAM,MAAM,QAAQ,sBAAsB;;;;;;;;;;;;;;;0BAU5D,kBAAkB,MAAM,MAAM;;;oCAUpD,kBAAkB,SACf,+BAA+B;;;;;;;;;;;;;;;;qCAkClC,kBAAkB,iBACP,MAAM,QACf,iCAAiC;;;;;;;;;;;qCAwCnC,kBAAkB,MAClB,MAAM,QACJ,iCAAiC;;;;;;;;;;;qCAWF,kBAAkB,MAAM,MAAM;;;wCAU/D,kBAAkB,SACf,mCAAmC;;;;;;;;;;;;;;;;yCAwCtC,kBAAkB,cACV,MAAM,QACZ,qCAAqC;;;;;;;;;;;yCAwCvC,kBAAkB,MAClB,MAAM,QACJ,qCAAqC;;;;;;;;;;;yCAWF,kBAAkB,MAAM,MAAM;;;mCASpC,kBAAkB,SAAS,8BAA8B;;;;;;;;;;;;;oCAiCxF,kBAAkB,SACf,MAAM,QACP,gCAAgC;;;;;;;;oCAwClC,kBAAkB,MAClB,MAAM,QACJ,gCAAgC;;;;;;;;oCAWF,kBAAkB,MAAM,MAAM;;;CAQrE,CAAA"}
|
|
@@ -0,0 +1,310 @@
|
|
|
1
|
+
import { and, asc, eq, ilike, inArray, or, sql } from "drizzle-orm";
|
|
2
|
+
import { destinations, destinationTranslations, productCategories, productCategoryTranslations, productTags, productTagTranslations, } from "./schema.js";
|
|
3
|
+
export const destinationProductsService = {
|
|
4
|
+
async listDestinations(db, query) {
|
|
5
|
+
const conditions = [];
|
|
6
|
+
if (query.parentId) {
|
|
7
|
+
conditions.push(eq(destinations.parentId, query.parentId));
|
|
8
|
+
}
|
|
9
|
+
if (query.active !== undefined) {
|
|
10
|
+
conditions.push(eq(destinations.active, query.active));
|
|
11
|
+
}
|
|
12
|
+
if (query.destinationType) {
|
|
13
|
+
conditions.push(eq(destinations.destinationType, query.destinationType));
|
|
14
|
+
}
|
|
15
|
+
if (query.canonicalPlaceId) {
|
|
16
|
+
conditions.push(eq(destinations.canonicalPlaceId, query.canonicalPlaceId));
|
|
17
|
+
}
|
|
18
|
+
if (query.search) {
|
|
19
|
+
const term = `%${query.search}%`;
|
|
20
|
+
const translationRows = await db
|
|
21
|
+
.select({ destinationId: destinationTranslations.destinationId })
|
|
22
|
+
.from(destinationTranslations)
|
|
23
|
+
.where(and(query.languageTag
|
|
24
|
+
? eq(destinationTranslations.languageTag, query.languageTag)
|
|
25
|
+
: undefined, or(ilike(destinationTranslations.name, term), ilike(destinationTranslations.description, term))));
|
|
26
|
+
const destinationIds = translationRows.map((row) => row.destinationId);
|
|
27
|
+
conditions.push(destinationIds.length > 0 ? inArray(destinations.id, destinationIds) : sql `1 = 0`);
|
|
28
|
+
}
|
|
29
|
+
const where = conditions.length > 0 ? and(...conditions) : undefined;
|
|
30
|
+
const [rows, countResult] = await Promise.all([
|
|
31
|
+
db
|
|
32
|
+
.select()
|
|
33
|
+
.from(destinations)
|
|
34
|
+
.where(where)
|
|
35
|
+
.limit(query.limit)
|
|
36
|
+
.offset(query.offset)
|
|
37
|
+
.orderBy(asc(destinations.sortOrder), asc(destinations.slug)),
|
|
38
|
+
db.select({ count: sql `count(*)::int` }).from(destinations).where(where),
|
|
39
|
+
]);
|
|
40
|
+
const destinationIds = rows.map((row) => row.id);
|
|
41
|
+
const translations = destinationIds.length > 0
|
|
42
|
+
? await db
|
|
43
|
+
.select()
|
|
44
|
+
.from(destinationTranslations)
|
|
45
|
+
.where(and(inArray(destinationTranslations.destinationId, destinationIds), ...(query.languageTag
|
|
46
|
+
? [eq(destinationTranslations.languageTag, query.languageTag)]
|
|
47
|
+
: [])))
|
|
48
|
+
.orderBy(asc(destinationTranslations.languageTag), asc(destinationTranslations.createdAt))
|
|
49
|
+
: [];
|
|
50
|
+
const translationsByDestination = new Map();
|
|
51
|
+
for (const row of translations) {
|
|
52
|
+
const existing = translationsByDestination.get(row.destinationId) ?? [];
|
|
53
|
+
existing.push(row);
|
|
54
|
+
translationsByDestination.set(row.destinationId, existing);
|
|
55
|
+
}
|
|
56
|
+
return {
|
|
57
|
+
data: rows.map((row) => ({
|
|
58
|
+
...row,
|
|
59
|
+
translation: (translationsByDestination.get(row.id) ?? [])[0] ?? null,
|
|
60
|
+
})),
|
|
61
|
+
total: countResult[0]?.count ?? 0,
|
|
62
|
+
limit: query.limit,
|
|
63
|
+
offset: query.offset,
|
|
64
|
+
};
|
|
65
|
+
},
|
|
66
|
+
async getDestinationById(db, id) {
|
|
67
|
+
const [row] = await db.select().from(destinations).where(eq(destinations.id, id)).limit(1);
|
|
68
|
+
if (!row) {
|
|
69
|
+
return null;
|
|
70
|
+
}
|
|
71
|
+
const translations = await db
|
|
72
|
+
.select()
|
|
73
|
+
.from(destinationTranslations)
|
|
74
|
+
.where(eq(destinationTranslations.destinationId, id))
|
|
75
|
+
.orderBy(asc(destinationTranslations.languageTag), asc(destinationTranslations.createdAt));
|
|
76
|
+
return {
|
|
77
|
+
...row,
|
|
78
|
+
translations,
|
|
79
|
+
};
|
|
80
|
+
},
|
|
81
|
+
async createDestination(db, data) {
|
|
82
|
+
const [row] = await db.insert(destinations).values(data).returning();
|
|
83
|
+
return row ?? null;
|
|
84
|
+
},
|
|
85
|
+
async updateDestination(db, id, data) {
|
|
86
|
+
const [row] = await db
|
|
87
|
+
.update(destinations)
|
|
88
|
+
.set({ ...data, updatedAt: new Date() })
|
|
89
|
+
.where(eq(destinations.id, id))
|
|
90
|
+
.returning();
|
|
91
|
+
return row ?? null;
|
|
92
|
+
},
|
|
93
|
+
async deleteDestination(db, id) {
|
|
94
|
+
const [row] = await db
|
|
95
|
+
.delete(destinations)
|
|
96
|
+
.where(eq(destinations.id, id))
|
|
97
|
+
.returning({ id: destinations.id });
|
|
98
|
+
return row ?? null;
|
|
99
|
+
},
|
|
100
|
+
async listDestinationTranslations(db, query) {
|
|
101
|
+
const conditions = [];
|
|
102
|
+
if (query.destinationId) {
|
|
103
|
+
conditions.push(eq(destinationTranslations.destinationId, query.destinationId));
|
|
104
|
+
}
|
|
105
|
+
if (query.languageTag) {
|
|
106
|
+
conditions.push(eq(destinationTranslations.languageTag, query.languageTag));
|
|
107
|
+
}
|
|
108
|
+
const where = conditions.length > 0 ? and(...conditions) : undefined;
|
|
109
|
+
const [rows, countResult] = await Promise.all([
|
|
110
|
+
db
|
|
111
|
+
.select()
|
|
112
|
+
.from(destinationTranslations)
|
|
113
|
+
.where(where)
|
|
114
|
+
.limit(query.limit)
|
|
115
|
+
.offset(query.offset)
|
|
116
|
+
.orderBy(asc(destinationTranslations.languageTag), asc(destinationTranslations.createdAt)),
|
|
117
|
+
db.select({ count: sql `count(*)::int` }).from(destinationTranslations).where(where),
|
|
118
|
+
]);
|
|
119
|
+
return {
|
|
120
|
+
data: rows,
|
|
121
|
+
total: countResult[0]?.count ?? 0,
|
|
122
|
+
limit: query.limit,
|
|
123
|
+
offset: query.offset,
|
|
124
|
+
};
|
|
125
|
+
},
|
|
126
|
+
async upsertDestinationTranslation(db, destinationId, data) {
|
|
127
|
+
const [destination] = await db
|
|
128
|
+
.select({ id: destinations.id })
|
|
129
|
+
.from(destinations)
|
|
130
|
+
.where(eq(destinations.id, destinationId))
|
|
131
|
+
.limit(1);
|
|
132
|
+
if (!destination) {
|
|
133
|
+
return null;
|
|
134
|
+
}
|
|
135
|
+
const [existing] = await db
|
|
136
|
+
.select()
|
|
137
|
+
.from(destinationTranslations)
|
|
138
|
+
.where(and(eq(destinationTranslations.destinationId, destinationId), eq(destinationTranslations.languageTag, data.languageTag)))
|
|
139
|
+
.limit(1);
|
|
140
|
+
if (existing) {
|
|
141
|
+
const [row] = await db
|
|
142
|
+
.update(destinationTranslations)
|
|
143
|
+
.set({ ...data, updatedAt: new Date() })
|
|
144
|
+
.where(eq(destinationTranslations.id, existing.id))
|
|
145
|
+
.returning();
|
|
146
|
+
return row ?? null;
|
|
147
|
+
}
|
|
148
|
+
const [row] = await db
|
|
149
|
+
.insert(destinationTranslations)
|
|
150
|
+
.values({ destinationId, ...data })
|
|
151
|
+
.returning();
|
|
152
|
+
return row ?? null;
|
|
153
|
+
},
|
|
154
|
+
async updateDestinationTranslation(db, id, data) {
|
|
155
|
+
const [row] = await db
|
|
156
|
+
.update(destinationTranslations)
|
|
157
|
+
.set({ ...data, updatedAt: new Date() })
|
|
158
|
+
.where(eq(destinationTranslations.id, id))
|
|
159
|
+
.returning();
|
|
160
|
+
return row ?? null;
|
|
161
|
+
},
|
|
162
|
+
async deleteDestinationTranslation(db, id) {
|
|
163
|
+
const [row] = await db
|
|
164
|
+
.delete(destinationTranslations)
|
|
165
|
+
.where(eq(destinationTranslations.id, id))
|
|
166
|
+
.returning({ id: destinationTranslations.id });
|
|
167
|
+
return row ?? null;
|
|
168
|
+
},
|
|
169
|
+
async listProductCategoryTranslations(db, query) {
|
|
170
|
+
const conditions = [];
|
|
171
|
+
if (query.categoryId) {
|
|
172
|
+
conditions.push(eq(productCategoryTranslations.categoryId, query.categoryId));
|
|
173
|
+
}
|
|
174
|
+
if (query.languageTag) {
|
|
175
|
+
conditions.push(eq(productCategoryTranslations.languageTag, query.languageTag));
|
|
176
|
+
}
|
|
177
|
+
const where = conditions.length > 0 ? and(...conditions) : undefined;
|
|
178
|
+
const [rows, countResult] = await Promise.all([
|
|
179
|
+
db
|
|
180
|
+
.select()
|
|
181
|
+
.from(productCategoryTranslations)
|
|
182
|
+
.where(where)
|
|
183
|
+
.limit(query.limit)
|
|
184
|
+
.offset(query.offset)
|
|
185
|
+
.orderBy(asc(productCategoryTranslations.languageTag), asc(productCategoryTranslations.createdAt)),
|
|
186
|
+
db
|
|
187
|
+
.select({ count: sql `count(*)::int` })
|
|
188
|
+
.from(productCategoryTranslations)
|
|
189
|
+
.where(where),
|
|
190
|
+
]);
|
|
191
|
+
return {
|
|
192
|
+
data: rows,
|
|
193
|
+
total: countResult[0]?.count ?? 0,
|
|
194
|
+
limit: query.limit,
|
|
195
|
+
offset: query.offset,
|
|
196
|
+
};
|
|
197
|
+
},
|
|
198
|
+
async upsertProductCategoryTranslation(db, categoryId, data) {
|
|
199
|
+
const [category] = await db
|
|
200
|
+
.select({ id: productCategories.id })
|
|
201
|
+
.from(productCategories)
|
|
202
|
+
.where(eq(productCategories.id, categoryId))
|
|
203
|
+
.limit(1);
|
|
204
|
+
if (!category) {
|
|
205
|
+
return null;
|
|
206
|
+
}
|
|
207
|
+
const [existing] = await db
|
|
208
|
+
.select()
|
|
209
|
+
.from(productCategoryTranslations)
|
|
210
|
+
.where(and(eq(productCategoryTranslations.categoryId, categoryId), eq(productCategoryTranslations.languageTag, data.languageTag)))
|
|
211
|
+
.limit(1);
|
|
212
|
+
if (existing) {
|
|
213
|
+
const [row] = await db
|
|
214
|
+
.update(productCategoryTranslations)
|
|
215
|
+
.set({ ...data, updatedAt: new Date() })
|
|
216
|
+
.where(eq(productCategoryTranslations.id, existing.id))
|
|
217
|
+
.returning();
|
|
218
|
+
return row ?? null;
|
|
219
|
+
}
|
|
220
|
+
const [row] = await db
|
|
221
|
+
.insert(productCategoryTranslations)
|
|
222
|
+
.values({ categoryId, ...data })
|
|
223
|
+
.returning();
|
|
224
|
+
return row ?? null;
|
|
225
|
+
},
|
|
226
|
+
async updateProductCategoryTranslation(db, id, data) {
|
|
227
|
+
const [row] = await db
|
|
228
|
+
.update(productCategoryTranslations)
|
|
229
|
+
.set({ ...data, updatedAt: new Date() })
|
|
230
|
+
.where(eq(productCategoryTranslations.id, id))
|
|
231
|
+
.returning();
|
|
232
|
+
return row ?? null;
|
|
233
|
+
},
|
|
234
|
+
async deleteProductCategoryTranslation(db, id) {
|
|
235
|
+
const [row] = await db
|
|
236
|
+
.delete(productCategoryTranslations)
|
|
237
|
+
.where(eq(productCategoryTranslations.id, id))
|
|
238
|
+
.returning({ id: productCategoryTranslations.id });
|
|
239
|
+
return row ?? null;
|
|
240
|
+
},
|
|
241
|
+
async listProductTagTranslations(db, query) {
|
|
242
|
+
const conditions = [];
|
|
243
|
+
if (query.tagId) {
|
|
244
|
+
conditions.push(eq(productTagTranslations.tagId, query.tagId));
|
|
245
|
+
}
|
|
246
|
+
if (query.languageTag) {
|
|
247
|
+
conditions.push(eq(productTagTranslations.languageTag, query.languageTag));
|
|
248
|
+
}
|
|
249
|
+
const where = conditions.length > 0 ? and(...conditions) : undefined;
|
|
250
|
+
const [rows, countResult] = await Promise.all([
|
|
251
|
+
db
|
|
252
|
+
.select()
|
|
253
|
+
.from(productTagTranslations)
|
|
254
|
+
.where(where)
|
|
255
|
+
.limit(query.limit)
|
|
256
|
+
.offset(query.offset)
|
|
257
|
+
.orderBy(asc(productTagTranslations.languageTag), asc(productTagTranslations.createdAt)),
|
|
258
|
+
db.select({ count: sql `count(*)::int` }).from(productTagTranslations).where(where),
|
|
259
|
+
]);
|
|
260
|
+
return {
|
|
261
|
+
data: rows,
|
|
262
|
+
total: countResult[0]?.count ?? 0,
|
|
263
|
+
limit: query.limit,
|
|
264
|
+
offset: query.offset,
|
|
265
|
+
};
|
|
266
|
+
},
|
|
267
|
+
async upsertProductTagTranslation(db, tagId, data) {
|
|
268
|
+
const [tag] = await db
|
|
269
|
+
.select({ id: productTags.id })
|
|
270
|
+
.from(productTags)
|
|
271
|
+
.where(eq(productTags.id, tagId))
|
|
272
|
+
.limit(1);
|
|
273
|
+
if (!tag) {
|
|
274
|
+
return null;
|
|
275
|
+
}
|
|
276
|
+
const [existing] = await db
|
|
277
|
+
.select()
|
|
278
|
+
.from(productTagTranslations)
|
|
279
|
+
.where(and(eq(productTagTranslations.tagId, tagId), eq(productTagTranslations.languageTag, data.languageTag)))
|
|
280
|
+
.limit(1);
|
|
281
|
+
if (existing) {
|
|
282
|
+
const [row] = await db
|
|
283
|
+
.update(productTagTranslations)
|
|
284
|
+
.set({ ...data, updatedAt: new Date() })
|
|
285
|
+
.where(eq(productTagTranslations.id, existing.id))
|
|
286
|
+
.returning();
|
|
287
|
+
return row ?? null;
|
|
288
|
+
}
|
|
289
|
+
const [row] = await db
|
|
290
|
+
.insert(productTagTranslations)
|
|
291
|
+
.values({ tagId, ...data })
|
|
292
|
+
.returning();
|
|
293
|
+
return row ?? null;
|
|
294
|
+
},
|
|
295
|
+
async updateProductTagTranslation(db, id, data) {
|
|
296
|
+
const [row] = await db
|
|
297
|
+
.update(productTagTranslations)
|
|
298
|
+
.set({ ...data, updatedAt: new Date() })
|
|
299
|
+
.where(eq(productTagTranslations.id, id))
|
|
300
|
+
.returning();
|
|
301
|
+
return row ?? null;
|
|
302
|
+
},
|
|
303
|
+
async deleteProductTagTranslation(db, id) {
|
|
304
|
+
const [row] = await db
|
|
305
|
+
.delete(productTagTranslations)
|
|
306
|
+
.where(eq(productTagTranslations.id, id))
|
|
307
|
+
.returning({ id: productTagTranslations.id });
|
|
308
|
+
return row ?? null;
|
|
309
|
+
},
|
|
310
|
+
};
|