@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,261 @@
|
|
|
1
|
+
import type { PostgresJsDatabase } from "drizzle-orm/postgres-js";
|
|
2
|
+
import type { z } from "zod";
|
|
3
|
+
import type { insertProductActivationSettingSchema, insertProductCapabilitySchema, insertProductTicketSettingSchema, insertProductVisibilitySettingSchema, productActivationSettingListQuerySchema, productCapabilityListQuerySchema, productTicketSettingListQuerySchema, productVisibilitySettingListQuerySchema, updateProductActivationSettingSchema, updateProductCapabilitySchema, updateProductTicketSettingSchema, updateProductVisibilitySettingSchema } from "./validation.js";
|
|
4
|
+
type ProductActivationSettingListQuery = z.infer<typeof productActivationSettingListQuerySchema>;
|
|
5
|
+
type CreateProductActivationSettingInput = z.infer<typeof insertProductActivationSettingSchema>;
|
|
6
|
+
type UpdateProductActivationSettingInput = z.infer<typeof updateProductActivationSettingSchema>;
|
|
7
|
+
type ProductTicketSettingListQuery = z.infer<typeof productTicketSettingListQuerySchema>;
|
|
8
|
+
type CreateProductTicketSettingInput = z.infer<typeof insertProductTicketSettingSchema>;
|
|
9
|
+
type UpdateProductTicketSettingInput = z.infer<typeof updateProductTicketSettingSchema>;
|
|
10
|
+
type ProductVisibilitySettingListQuery = z.infer<typeof productVisibilitySettingListQuerySchema>;
|
|
11
|
+
type CreateProductVisibilitySettingInput = z.infer<typeof insertProductVisibilitySettingSchema>;
|
|
12
|
+
type UpdateProductVisibilitySettingInput = z.infer<typeof updateProductVisibilitySettingSchema>;
|
|
13
|
+
type ProductCapabilityListQuery = z.infer<typeof productCapabilityListQuerySchema>;
|
|
14
|
+
type CreateProductCapabilityInput = z.infer<typeof insertProductCapabilitySchema>;
|
|
15
|
+
type UpdateProductCapabilityInput = z.infer<typeof updateProductCapabilitySchema>;
|
|
16
|
+
export declare const configurationProductsService: {
|
|
17
|
+
listActivationSettings(db: PostgresJsDatabase, query: ProductActivationSettingListQuery): Promise<{
|
|
18
|
+
data: {
|
|
19
|
+
id: string;
|
|
20
|
+
productId: string;
|
|
21
|
+
activationMode: "manual" | "scheduled" | "channel_controlled";
|
|
22
|
+
activateAt: Date | null;
|
|
23
|
+
deactivateAt: Date | null;
|
|
24
|
+
sellAt: Date | null;
|
|
25
|
+
stopSellAt: Date | null;
|
|
26
|
+
createdAt: Date;
|
|
27
|
+
updatedAt: Date;
|
|
28
|
+
}[];
|
|
29
|
+
total: number;
|
|
30
|
+
limit: number;
|
|
31
|
+
offset: number;
|
|
32
|
+
}>;
|
|
33
|
+
getActivationSettingById(db: PostgresJsDatabase, id: string): Promise<{
|
|
34
|
+
id: string;
|
|
35
|
+
productId: string;
|
|
36
|
+
activationMode: "manual" | "scheduled" | "channel_controlled";
|
|
37
|
+
activateAt: Date | null;
|
|
38
|
+
deactivateAt: Date | null;
|
|
39
|
+
sellAt: Date | null;
|
|
40
|
+
stopSellAt: Date | null;
|
|
41
|
+
createdAt: Date;
|
|
42
|
+
updatedAt: Date;
|
|
43
|
+
} | null>;
|
|
44
|
+
getActivationSettingByProductId(db: PostgresJsDatabase, productId: string): Promise<{
|
|
45
|
+
id: string;
|
|
46
|
+
productId: string;
|
|
47
|
+
activationMode: "manual" | "scheduled" | "channel_controlled";
|
|
48
|
+
activateAt: Date | null;
|
|
49
|
+
deactivateAt: Date | null;
|
|
50
|
+
sellAt: Date | null;
|
|
51
|
+
stopSellAt: Date | null;
|
|
52
|
+
createdAt: Date;
|
|
53
|
+
updatedAt: Date;
|
|
54
|
+
} | null>;
|
|
55
|
+
upsertActivationSetting(db: PostgresJsDatabase, productId: string, data: CreateProductActivationSettingInput): Promise<{
|
|
56
|
+
id: string;
|
|
57
|
+
createdAt: Date;
|
|
58
|
+
updatedAt: Date;
|
|
59
|
+
productId: string;
|
|
60
|
+
activationMode: "manual" | "scheduled" | "channel_controlled";
|
|
61
|
+
activateAt: Date | null;
|
|
62
|
+
deactivateAt: Date | null;
|
|
63
|
+
sellAt: Date | null;
|
|
64
|
+
stopSellAt: Date | null;
|
|
65
|
+
} | null>;
|
|
66
|
+
updateActivationSetting(db: PostgresJsDatabase, id: string, data: UpdateProductActivationSettingInput): Promise<{
|
|
67
|
+
id: string;
|
|
68
|
+
productId: string;
|
|
69
|
+
activationMode: "manual" | "scheduled" | "channel_controlled";
|
|
70
|
+
activateAt: Date | null;
|
|
71
|
+
deactivateAt: Date | null;
|
|
72
|
+
sellAt: Date | null;
|
|
73
|
+
stopSellAt: Date | null;
|
|
74
|
+
createdAt: Date;
|
|
75
|
+
updatedAt: Date;
|
|
76
|
+
} | null>;
|
|
77
|
+
deleteActivationSetting(db: PostgresJsDatabase, id: string): Promise<{
|
|
78
|
+
id: string;
|
|
79
|
+
} | null>;
|
|
80
|
+
listTicketSettings(db: PostgresJsDatabase, query: ProductTicketSettingListQuery): Promise<{
|
|
81
|
+
data: {
|
|
82
|
+
id: string;
|
|
83
|
+
productId: string;
|
|
84
|
+
fulfillmentMode: "none" | "per_booking" | "per_participant" | "per_item";
|
|
85
|
+
defaultDeliveryFormat: "none" | "voucher" | "ticket" | "pdf" | "qr_code" | "barcode" | "email" | "mobile";
|
|
86
|
+
ticketPerUnit: boolean;
|
|
87
|
+
barcodeFormat: string | null;
|
|
88
|
+
voucherMessage: string | null;
|
|
89
|
+
ticketMessage: string | null;
|
|
90
|
+
createdAt: Date;
|
|
91
|
+
updatedAt: Date;
|
|
92
|
+
}[];
|
|
93
|
+
total: number;
|
|
94
|
+
limit: number;
|
|
95
|
+
offset: number;
|
|
96
|
+
}>;
|
|
97
|
+
getTicketSettingById(db: PostgresJsDatabase, id: string): Promise<{
|
|
98
|
+
id: string;
|
|
99
|
+
productId: string;
|
|
100
|
+
fulfillmentMode: "none" | "per_booking" | "per_participant" | "per_item";
|
|
101
|
+
defaultDeliveryFormat: "none" | "voucher" | "ticket" | "pdf" | "qr_code" | "barcode" | "email" | "mobile";
|
|
102
|
+
ticketPerUnit: boolean;
|
|
103
|
+
barcodeFormat: string | null;
|
|
104
|
+
voucherMessage: string | null;
|
|
105
|
+
ticketMessage: string | null;
|
|
106
|
+
createdAt: Date;
|
|
107
|
+
updatedAt: Date;
|
|
108
|
+
} | null>;
|
|
109
|
+
getTicketSettingByProductId(db: PostgresJsDatabase, productId: string): Promise<{
|
|
110
|
+
id: string;
|
|
111
|
+
productId: string;
|
|
112
|
+
fulfillmentMode: "none" | "per_booking" | "per_participant" | "per_item";
|
|
113
|
+
defaultDeliveryFormat: "none" | "voucher" | "ticket" | "pdf" | "qr_code" | "barcode" | "email" | "mobile";
|
|
114
|
+
ticketPerUnit: boolean;
|
|
115
|
+
barcodeFormat: string | null;
|
|
116
|
+
voucherMessage: string | null;
|
|
117
|
+
ticketMessage: string | null;
|
|
118
|
+
createdAt: Date;
|
|
119
|
+
updatedAt: Date;
|
|
120
|
+
} | null>;
|
|
121
|
+
upsertTicketSetting(db: PostgresJsDatabase, productId: string, data: CreateProductTicketSettingInput): Promise<{
|
|
122
|
+
id: string;
|
|
123
|
+
createdAt: Date;
|
|
124
|
+
updatedAt: Date;
|
|
125
|
+
productId: string;
|
|
126
|
+
fulfillmentMode: "none" | "per_booking" | "per_participant" | "per_item";
|
|
127
|
+
defaultDeliveryFormat: "none" | "voucher" | "ticket" | "pdf" | "qr_code" | "barcode" | "email" | "mobile";
|
|
128
|
+
ticketPerUnit: boolean;
|
|
129
|
+
barcodeFormat: string | null;
|
|
130
|
+
voucherMessage: string | null;
|
|
131
|
+
ticketMessage: string | null;
|
|
132
|
+
} | null>;
|
|
133
|
+
updateTicketSetting(db: PostgresJsDatabase, id: string, data: UpdateProductTicketSettingInput): Promise<{
|
|
134
|
+
id: string;
|
|
135
|
+
productId: string;
|
|
136
|
+
fulfillmentMode: "none" | "per_booking" | "per_participant" | "per_item";
|
|
137
|
+
defaultDeliveryFormat: "none" | "voucher" | "ticket" | "pdf" | "qr_code" | "barcode" | "email" | "mobile";
|
|
138
|
+
ticketPerUnit: boolean;
|
|
139
|
+
barcodeFormat: string | null;
|
|
140
|
+
voucherMessage: string | null;
|
|
141
|
+
ticketMessage: string | null;
|
|
142
|
+
createdAt: Date;
|
|
143
|
+
updatedAt: Date;
|
|
144
|
+
} | null>;
|
|
145
|
+
deleteTicketSetting(db: PostgresJsDatabase, id: string): Promise<{
|
|
146
|
+
id: string;
|
|
147
|
+
} | null>;
|
|
148
|
+
listVisibilitySettings(db: PostgresJsDatabase, query: ProductVisibilitySettingListQuery): Promise<{
|
|
149
|
+
data: {
|
|
150
|
+
id: string;
|
|
151
|
+
productId: string;
|
|
152
|
+
isSearchable: boolean;
|
|
153
|
+
isBookable: boolean;
|
|
154
|
+
isFeatured: boolean;
|
|
155
|
+
requiresAuthentication: boolean;
|
|
156
|
+
createdAt: Date;
|
|
157
|
+
updatedAt: Date;
|
|
158
|
+
}[];
|
|
159
|
+
total: number;
|
|
160
|
+
limit: number;
|
|
161
|
+
offset: number;
|
|
162
|
+
}>;
|
|
163
|
+
getVisibilitySettingById(db: PostgresJsDatabase, id: string): Promise<{
|
|
164
|
+
id: string;
|
|
165
|
+
productId: string;
|
|
166
|
+
isSearchable: boolean;
|
|
167
|
+
isBookable: boolean;
|
|
168
|
+
isFeatured: boolean;
|
|
169
|
+
requiresAuthentication: boolean;
|
|
170
|
+
createdAt: Date;
|
|
171
|
+
updatedAt: Date;
|
|
172
|
+
} | null>;
|
|
173
|
+
getVisibilitySettingByProductId(db: PostgresJsDatabase, productId: string): Promise<{
|
|
174
|
+
id: string;
|
|
175
|
+
productId: string;
|
|
176
|
+
isSearchable: boolean;
|
|
177
|
+
isBookable: boolean;
|
|
178
|
+
isFeatured: boolean;
|
|
179
|
+
requiresAuthentication: boolean;
|
|
180
|
+
createdAt: Date;
|
|
181
|
+
updatedAt: Date;
|
|
182
|
+
} | null>;
|
|
183
|
+
upsertVisibilitySetting(db: PostgresJsDatabase, productId: string, data: CreateProductVisibilitySettingInput): Promise<{
|
|
184
|
+
id: string;
|
|
185
|
+
createdAt: Date;
|
|
186
|
+
updatedAt: Date;
|
|
187
|
+
productId: string;
|
|
188
|
+
isSearchable: boolean;
|
|
189
|
+
isBookable: boolean;
|
|
190
|
+
isFeatured: boolean;
|
|
191
|
+
requiresAuthentication: boolean;
|
|
192
|
+
} | null>;
|
|
193
|
+
updateVisibilitySetting(db: PostgresJsDatabase, id: string, data: UpdateProductVisibilitySettingInput): Promise<{
|
|
194
|
+
id: string;
|
|
195
|
+
productId: string;
|
|
196
|
+
isSearchable: boolean;
|
|
197
|
+
isBookable: boolean;
|
|
198
|
+
isFeatured: boolean;
|
|
199
|
+
requiresAuthentication: boolean;
|
|
200
|
+
createdAt: Date;
|
|
201
|
+
updatedAt: Date;
|
|
202
|
+
} | null>;
|
|
203
|
+
deleteVisibilitySetting(db: PostgresJsDatabase, id: string): Promise<{
|
|
204
|
+
id: string;
|
|
205
|
+
} | null>;
|
|
206
|
+
listCapabilities(db: PostgresJsDatabase, query: ProductCapabilityListQuery): Promise<{
|
|
207
|
+
data: {
|
|
208
|
+
id: string;
|
|
209
|
+
productId: string;
|
|
210
|
+
capability: "on_request" | "private" | "instant_confirmation" | "pickup_available" | "dropoff_available" | "guided" | "shared" | "digital_ticket" | "voucher_required" | "external_inventory" | "multi_day" | "accommodation" | "transport";
|
|
211
|
+
enabled: boolean;
|
|
212
|
+
notes: string | null;
|
|
213
|
+
createdAt: Date;
|
|
214
|
+
updatedAt: Date;
|
|
215
|
+
}[];
|
|
216
|
+
total: number;
|
|
217
|
+
limit: number;
|
|
218
|
+
offset: number;
|
|
219
|
+
}>;
|
|
220
|
+
getCapabilityById(db: PostgresJsDatabase, id: string): Promise<{
|
|
221
|
+
id: string;
|
|
222
|
+
productId: string;
|
|
223
|
+
capability: "on_request" | "private" | "instant_confirmation" | "pickup_available" | "dropoff_available" | "guided" | "shared" | "digital_ticket" | "voucher_required" | "external_inventory" | "multi_day" | "accommodation" | "transport";
|
|
224
|
+
enabled: boolean;
|
|
225
|
+
notes: string | null;
|
|
226
|
+
createdAt: Date;
|
|
227
|
+
updatedAt: Date;
|
|
228
|
+
} | null>;
|
|
229
|
+
getCapabilityByProductAndName(db: PostgresJsDatabase, productId: string, capability: CreateProductCapabilityInput["capability"]): Promise<{
|
|
230
|
+
id: string;
|
|
231
|
+
productId: string;
|
|
232
|
+
capability: "on_request" | "private" | "instant_confirmation" | "pickup_available" | "dropoff_available" | "guided" | "shared" | "digital_ticket" | "voucher_required" | "external_inventory" | "multi_day" | "accommodation" | "transport";
|
|
233
|
+
enabled: boolean;
|
|
234
|
+
notes: string | null;
|
|
235
|
+
createdAt: Date;
|
|
236
|
+
updatedAt: Date;
|
|
237
|
+
} | null>;
|
|
238
|
+
createCapability(db: PostgresJsDatabase, productId: string, data: CreateProductCapabilityInput): Promise<{
|
|
239
|
+
id: string;
|
|
240
|
+
createdAt: Date;
|
|
241
|
+
updatedAt: Date;
|
|
242
|
+
productId: string;
|
|
243
|
+
capability: "on_request" | "private" | "instant_confirmation" | "pickup_available" | "dropoff_available" | "guided" | "shared" | "digital_ticket" | "voucher_required" | "external_inventory" | "multi_day" | "accommodation" | "transport";
|
|
244
|
+
enabled: boolean;
|
|
245
|
+
notes: string | null;
|
|
246
|
+
} | null>;
|
|
247
|
+
updateCapability(db: PostgresJsDatabase, id: string, data: UpdateProductCapabilityInput): Promise<{
|
|
248
|
+
id: string;
|
|
249
|
+
productId: string;
|
|
250
|
+
capability: "on_request" | "private" | "instant_confirmation" | "pickup_available" | "dropoff_available" | "guided" | "shared" | "digital_ticket" | "voucher_required" | "external_inventory" | "multi_day" | "accommodation" | "transport";
|
|
251
|
+
enabled: boolean;
|
|
252
|
+
notes: string | null;
|
|
253
|
+
createdAt: Date;
|
|
254
|
+
updatedAt: Date;
|
|
255
|
+
} | null>;
|
|
256
|
+
deleteCapability(db: PostgresJsDatabase, id: string): Promise<{
|
|
257
|
+
id: string;
|
|
258
|
+
} | null>;
|
|
259
|
+
};
|
|
260
|
+
export {};
|
|
261
|
+
//# sourceMappingURL=service-configuration.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"service-configuration.d.ts","sourceRoot":"","sources":["../src/service-configuration.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,343 @@
|
|
|
1
|
+
import { and, asc, eq, sql } from "drizzle-orm";
|
|
2
|
+
import { productActivationSettings, productCapabilities, products, productTicketSettings, productVisibilitySettings, } from "./schema.js";
|
|
3
|
+
async function ensureProductExists(db, productId) {
|
|
4
|
+
const [product] = await db
|
|
5
|
+
.select({ id: products.id })
|
|
6
|
+
.from(products)
|
|
7
|
+
.where(eq(products.id, productId))
|
|
8
|
+
.limit(1);
|
|
9
|
+
return product ?? null;
|
|
10
|
+
}
|
|
11
|
+
export const configurationProductsService = {
|
|
12
|
+
async listActivationSettings(db, query) {
|
|
13
|
+
const conditions = [];
|
|
14
|
+
if (query.productId) {
|
|
15
|
+
conditions.push(eq(productActivationSettings.productId, query.productId));
|
|
16
|
+
}
|
|
17
|
+
if (query.activationMode) {
|
|
18
|
+
conditions.push(eq(productActivationSettings.activationMode, query.activationMode));
|
|
19
|
+
}
|
|
20
|
+
const where = conditions.length > 0 ? and(...conditions) : undefined;
|
|
21
|
+
const [rows, countResult] = await Promise.all([
|
|
22
|
+
db
|
|
23
|
+
.select()
|
|
24
|
+
.from(productActivationSettings)
|
|
25
|
+
.where(where)
|
|
26
|
+
.limit(query.limit)
|
|
27
|
+
.offset(query.offset)
|
|
28
|
+
.orderBy(asc(productActivationSettings.createdAt)),
|
|
29
|
+
db.select({ count: sql `count(*)::int` }).from(productActivationSettings).where(where),
|
|
30
|
+
]);
|
|
31
|
+
return {
|
|
32
|
+
data: rows,
|
|
33
|
+
total: countResult[0]?.count ?? 0,
|
|
34
|
+
limit: query.limit,
|
|
35
|
+
offset: query.offset,
|
|
36
|
+
};
|
|
37
|
+
},
|
|
38
|
+
async getActivationSettingById(db, id) {
|
|
39
|
+
const [row] = await db
|
|
40
|
+
.select()
|
|
41
|
+
.from(productActivationSettings)
|
|
42
|
+
.where(eq(productActivationSettings.id, id))
|
|
43
|
+
.limit(1);
|
|
44
|
+
return row ?? null;
|
|
45
|
+
},
|
|
46
|
+
async getActivationSettingByProductId(db, productId) {
|
|
47
|
+
const [row] = await db
|
|
48
|
+
.select()
|
|
49
|
+
.from(productActivationSettings)
|
|
50
|
+
.where(eq(productActivationSettings.productId, productId))
|
|
51
|
+
.limit(1);
|
|
52
|
+
return row ?? null;
|
|
53
|
+
},
|
|
54
|
+
async upsertActivationSetting(db, productId, data) {
|
|
55
|
+
const product = await ensureProductExists(db, productId);
|
|
56
|
+
if (!product) {
|
|
57
|
+
return null;
|
|
58
|
+
}
|
|
59
|
+
const [row] = await db
|
|
60
|
+
.insert(productActivationSettings)
|
|
61
|
+
.values({
|
|
62
|
+
productId,
|
|
63
|
+
...data,
|
|
64
|
+
activateAt: data.activateAt ? new Date(data.activateAt) : null,
|
|
65
|
+
deactivateAt: data.deactivateAt ? new Date(data.deactivateAt) : null,
|
|
66
|
+
sellAt: data.sellAt ? new Date(data.sellAt) : null,
|
|
67
|
+
stopSellAt: data.stopSellAt ? new Date(data.stopSellAt) : null,
|
|
68
|
+
})
|
|
69
|
+
.onConflictDoUpdate({
|
|
70
|
+
target: productActivationSettings.productId,
|
|
71
|
+
set: {
|
|
72
|
+
...data,
|
|
73
|
+
activateAt: data.activateAt ? new Date(data.activateAt) : null,
|
|
74
|
+
deactivateAt: data.deactivateAt ? new Date(data.deactivateAt) : null,
|
|
75
|
+
sellAt: data.sellAt ? new Date(data.sellAt) : null,
|
|
76
|
+
stopSellAt: data.stopSellAt ? new Date(data.stopSellAt) : null,
|
|
77
|
+
updatedAt: new Date(),
|
|
78
|
+
},
|
|
79
|
+
})
|
|
80
|
+
.returning();
|
|
81
|
+
return row ?? null;
|
|
82
|
+
},
|
|
83
|
+
async updateActivationSetting(db, id, data) {
|
|
84
|
+
const [row] = await db
|
|
85
|
+
.update(productActivationSettings)
|
|
86
|
+
.set({
|
|
87
|
+
...data,
|
|
88
|
+
activateAt: data.activateAt === undefined
|
|
89
|
+
? undefined
|
|
90
|
+
: data.activateAt
|
|
91
|
+
? new Date(data.activateAt)
|
|
92
|
+
: null,
|
|
93
|
+
deactivateAt: data.deactivateAt === undefined
|
|
94
|
+
? undefined
|
|
95
|
+
: data.deactivateAt
|
|
96
|
+
? new Date(data.deactivateAt)
|
|
97
|
+
: null,
|
|
98
|
+
sellAt: data.sellAt === undefined ? undefined : data.sellAt ? new Date(data.sellAt) : null,
|
|
99
|
+
stopSellAt: data.stopSellAt === undefined
|
|
100
|
+
? undefined
|
|
101
|
+
: data.stopSellAt
|
|
102
|
+
? new Date(data.stopSellAt)
|
|
103
|
+
: null,
|
|
104
|
+
updatedAt: new Date(),
|
|
105
|
+
})
|
|
106
|
+
.where(eq(productActivationSettings.id, id))
|
|
107
|
+
.returning();
|
|
108
|
+
return row ?? null;
|
|
109
|
+
},
|
|
110
|
+
async deleteActivationSetting(db, id) {
|
|
111
|
+
const [row] = await db
|
|
112
|
+
.delete(productActivationSettings)
|
|
113
|
+
.where(eq(productActivationSettings.id, id))
|
|
114
|
+
.returning({ id: productActivationSettings.id });
|
|
115
|
+
return row ?? null;
|
|
116
|
+
},
|
|
117
|
+
async listTicketSettings(db, query) {
|
|
118
|
+
const conditions = [];
|
|
119
|
+
if (query.productId) {
|
|
120
|
+
conditions.push(eq(productTicketSettings.productId, query.productId));
|
|
121
|
+
}
|
|
122
|
+
if (query.fulfillmentMode) {
|
|
123
|
+
conditions.push(eq(productTicketSettings.fulfillmentMode, query.fulfillmentMode));
|
|
124
|
+
}
|
|
125
|
+
const where = conditions.length > 0 ? and(...conditions) : undefined;
|
|
126
|
+
const [rows, countResult] = await Promise.all([
|
|
127
|
+
db
|
|
128
|
+
.select()
|
|
129
|
+
.from(productTicketSettings)
|
|
130
|
+
.where(where)
|
|
131
|
+
.limit(query.limit)
|
|
132
|
+
.offset(query.offset)
|
|
133
|
+
.orderBy(asc(productTicketSettings.createdAt)),
|
|
134
|
+
db.select({ count: sql `count(*)::int` }).from(productTicketSettings).where(where),
|
|
135
|
+
]);
|
|
136
|
+
return {
|
|
137
|
+
data: rows,
|
|
138
|
+
total: countResult[0]?.count ?? 0,
|
|
139
|
+
limit: query.limit,
|
|
140
|
+
offset: query.offset,
|
|
141
|
+
};
|
|
142
|
+
},
|
|
143
|
+
async getTicketSettingById(db, id) {
|
|
144
|
+
const [row] = await db
|
|
145
|
+
.select()
|
|
146
|
+
.from(productTicketSettings)
|
|
147
|
+
.where(eq(productTicketSettings.id, id))
|
|
148
|
+
.limit(1);
|
|
149
|
+
return row ?? null;
|
|
150
|
+
},
|
|
151
|
+
async getTicketSettingByProductId(db, productId) {
|
|
152
|
+
const [row] = await db
|
|
153
|
+
.select()
|
|
154
|
+
.from(productTicketSettings)
|
|
155
|
+
.where(eq(productTicketSettings.productId, productId))
|
|
156
|
+
.limit(1);
|
|
157
|
+
return row ?? null;
|
|
158
|
+
},
|
|
159
|
+
async upsertTicketSetting(db, productId, data) {
|
|
160
|
+
const product = await ensureProductExists(db, productId);
|
|
161
|
+
if (!product) {
|
|
162
|
+
return null;
|
|
163
|
+
}
|
|
164
|
+
const [row] = await db
|
|
165
|
+
.insert(productTicketSettings)
|
|
166
|
+
.values({ productId, ...data })
|
|
167
|
+
.onConflictDoUpdate({
|
|
168
|
+
target: productTicketSettings.productId,
|
|
169
|
+
set: { ...data, updatedAt: new Date() },
|
|
170
|
+
})
|
|
171
|
+
.returning();
|
|
172
|
+
return row ?? null;
|
|
173
|
+
},
|
|
174
|
+
async updateTicketSetting(db, id, data) {
|
|
175
|
+
const [row] = await db
|
|
176
|
+
.update(productTicketSettings)
|
|
177
|
+
.set({ ...data, updatedAt: new Date() })
|
|
178
|
+
.where(eq(productTicketSettings.id, id))
|
|
179
|
+
.returning();
|
|
180
|
+
return row ?? null;
|
|
181
|
+
},
|
|
182
|
+
async deleteTicketSetting(db, id) {
|
|
183
|
+
const [row] = await db
|
|
184
|
+
.delete(productTicketSettings)
|
|
185
|
+
.where(eq(productTicketSettings.id, id))
|
|
186
|
+
.returning({ id: productTicketSettings.id });
|
|
187
|
+
return row ?? null;
|
|
188
|
+
},
|
|
189
|
+
async listVisibilitySettings(db, query) {
|
|
190
|
+
const conditions = [];
|
|
191
|
+
if (query.productId) {
|
|
192
|
+
conditions.push(eq(productVisibilitySettings.productId, query.productId));
|
|
193
|
+
}
|
|
194
|
+
if (query.isSearchable !== undefined) {
|
|
195
|
+
conditions.push(eq(productVisibilitySettings.isSearchable, query.isSearchable));
|
|
196
|
+
}
|
|
197
|
+
if (query.isBookable !== undefined) {
|
|
198
|
+
conditions.push(eq(productVisibilitySettings.isBookable, query.isBookable));
|
|
199
|
+
}
|
|
200
|
+
const where = conditions.length > 0 ? and(...conditions) : undefined;
|
|
201
|
+
const [rows, countResult] = await Promise.all([
|
|
202
|
+
db
|
|
203
|
+
.select()
|
|
204
|
+
.from(productVisibilitySettings)
|
|
205
|
+
.where(where)
|
|
206
|
+
.limit(query.limit)
|
|
207
|
+
.offset(query.offset)
|
|
208
|
+
.orderBy(asc(productVisibilitySettings.createdAt)),
|
|
209
|
+
db.select({ count: sql `count(*)::int` }).from(productVisibilitySettings).where(where),
|
|
210
|
+
]);
|
|
211
|
+
return {
|
|
212
|
+
data: rows,
|
|
213
|
+
total: countResult[0]?.count ?? 0,
|
|
214
|
+
limit: query.limit,
|
|
215
|
+
offset: query.offset,
|
|
216
|
+
};
|
|
217
|
+
},
|
|
218
|
+
async getVisibilitySettingById(db, id) {
|
|
219
|
+
const [row] = await db
|
|
220
|
+
.select()
|
|
221
|
+
.from(productVisibilitySettings)
|
|
222
|
+
.where(eq(productVisibilitySettings.id, id))
|
|
223
|
+
.limit(1);
|
|
224
|
+
return row ?? null;
|
|
225
|
+
},
|
|
226
|
+
async getVisibilitySettingByProductId(db, productId) {
|
|
227
|
+
const [row] = await db
|
|
228
|
+
.select()
|
|
229
|
+
.from(productVisibilitySettings)
|
|
230
|
+
.where(eq(productVisibilitySettings.productId, productId))
|
|
231
|
+
.limit(1);
|
|
232
|
+
return row ?? null;
|
|
233
|
+
},
|
|
234
|
+
async upsertVisibilitySetting(db, productId, data) {
|
|
235
|
+
const product = await ensureProductExists(db, productId);
|
|
236
|
+
if (!product) {
|
|
237
|
+
return null;
|
|
238
|
+
}
|
|
239
|
+
const [row] = await db
|
|
240
|
+
.insert(productVisibilitySettings)
|
|
241
|
+
.values({ productId, ...data })
|
|
242
|
+
.onConflictDoUpdate({
|
|
243
|
+
target: productVisibilitySettings.productId,
|
|
244
|
+
set: { ...data, updatedAt: new Date() },
|
|
245
|
+
})
|
|
246
|
+
.returning();
|
|
247
|
+
return row ?? null;
|
|
248
|
+
},
|
|
249
|
+
async updateVisibilitySetting(db, id, data) {
|
|
250
|
+
const [row] = await db
|
|
251
|
+
.update(productVisibilitySettings)
|
|
252
|
+
.set({ ...data, updatedAt: new Date() })
|
|
253
|
+
.where(eq(productVisibilitySettings.id, id))
|
|
254
|
+
.returning();
|
|
255
|
+
return row ?? null;
|
|
256
|
+
},
|
|
257
|
+
async deleteVisibilitySetting(db, id) {
|
|
258
|
+
const [row] = await db
|
|
259
|
+
.delete(productVisibilitySettings)
|
|
260
|
+
.where(eq(productVisibilitySettings.id, id))
|
|
261
|
+
.returning({ id: productVisibilitySettings.id });
|
|
262
|
+
return row ?? null;
|
|
263
|
+
},
|
|
264
|
+
async listCapabilities(db, query) {
|
|
265
|
+
const conditions = [];
|
|
266
|
+
if (query.productId) {
|
|
267
|
+
conditions.push(eq(productCapabilities.productId, query.productId));
|
|
268
|
+
}
|
|
269
|
+
if (query.capability) {
|
|
270
|
+
conditions.push(eq(productCapabilities.capability, query.capability));
|
|
271
|
+
}
|
|
272
|
+
if (query.enabled !== undefined) {
|
|
273
|
+
conditions.push(eq(productCapabilities.enabled, query.enabled));
|
|
274
|
+
}
|
|
275
|
+
const where = conditions.length > 0 ? and(...conditions) : undefined;
|
|
276
|
+
const [rows, countResult] = await Promise.all([
|
|
277
|
+
db
|
|
278
|
+
.select()
|
|
279
|
+
.from(productCapabilities)
|
|
280
|
+
.where(where)
|
|
281
|
+
.limit(query.limit)
|
|
282
|
+
.offset(query.offset)
|
|
283
|
+
.orderBy(asc(productCapabilities.capability), asc(productCapabilities.createdAt)),
|
|
284
|
+
db.select({ count: sql `count(*)::int` }).from(productCapabilities).where(where),
|
|
285
|
+
]);
|
|
286
|
+
return {
|
|
287
|
+
data: rows,
|
|
288
|
+
total: countResult[0]?.count ?? 0,
|
|
289
|
+
limit: query.limit,
|
|
290
|
+
offset: query.offset,
|
|
291
|
+
};
|
|
292
|
+
},
|
|
293
|
+
async getCapabilityById(db, id) {
|
|
294
|
+
const [row] = await db
|
|
295
|
+
.select()
|
|
296
|
+
.from(productCapabilities)
|
|
297
|
+
.where(eq(productCapabilities.id, id))
|
|
298
|
+
.limit(1);
|
|
299
|
+
return row ?? null;
|
|
300
|
+
},
|
|
301
|
+
async getCapabilityByProductAndName(db, productId, capability) {
|
|
302
|
+
const [row] = await db
|
|
303
|
+
.select()
|
|
304
|
+
.from(productCapabilities)
|
|
305
|
+
.where(and(eq(productCapabilities.productId, productId), eq(productCapabilities.capability, capability)))
|
|
306
|
+
.limit(1);
|
|
307
|
+
return row ?? null;
|
|
308
|
+
},
|
|
309
|
+
async createCapability(db, productId, data) {
|
|
310
|
+
const product = await ensureProductExists(db, productId);
|
|
311
|
+
if (!product) {
|
|
312
|
+
return null;
|
|
313
|
+
}
|
|
314
|
+
const [row] = await db
|
|
315
|
+
.insert(productCapabilities)
|
|
316
|
+
.values({ productId, ...data })
|
|
317
|
+
.onConflictDoUpdate({
|
|
318
|
+
target: [productCapabilities.productId, productCapabilities.capability],
|
|
319
|
+
set: {
|
|
320
|
+
enabled: data.enabled,
|
|
321
|
+
notes: data.notes ?? null,
|
|
322
|
+
updatedAt: new Date(),
|
|
323
|
+
},
|
|
324
|
+
})
|
|
325
|
+
.returning();
|
|
326
|
+
return row ?? null;
|
|
327
|
+
},
|
|
328
|
+
async updateCapability(db, id, data) {
|
|
329
|
+
const [row] = await db
|
|
330
|
+
.update(productCapabilities)
|
|
331
|
+
.set({ ...data, updatedAt: new Date() })
|
|
332
|
+
.where(eq(productCapabilities.id, id))
|
|
333
|
+
.returning();
|
|
334
|
+
return row ?? null;
|
|
335
|
+
},
|
|
336
|
+
async deleteCapability(db, id) {
|
|
337
|
+
const [row] = await db
|
|
338
|
+
.delete(productCapabilities)
|
|
339
|
+
.where(eq(productCapabilities.id, id))
|
|
340
|
+
.returning({ id: productCapabilities.id });
|
|
341
|
+
return row ?? null;
|
|
342
|
+
},
|
|
343
|
+
};
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Owned-product content builder.
|
|
3
|
+
*
|
|
4
|
+
* Projects an owned product (the products module's own tables) into the
|
|
5
|
+
* vertical-shared `ProductContent` shape so the catalog content service
|
|
6
|
+
* can return rich detail for owned products via the same API that
|
|
7
|
+
* sourced products go through (`getProductContent`).
|
|
8
|
+
*
|
|
9
|
+
* Per sourced-content §3.3: `getProductContent` is the unified read
|
|
10
|
+
* surface for owned + sourced. v1 of service-content.ts only handled
|
|
11
|
+
* sourced (returning null for owned); this helper closes that gap.
|
|
12
|
+
*
|
|
13
|
+
* Locale resolution uses the catalog plane's standard
|
|
14
|
+
* `pickBestCachedLocale` against `product_translations` and
|
|
15
|
+
* `product_option_translations` rows — exact > language-match >
|
|
16
|
+
* fallback-chain > any. Matches the same scoring semantics the sourced
|
|
17
|
+
* cache reads use, so the same `BookingDraft.scope.locale` chain works
|
|
18
|
+
* for both owned and sourced products.
|
|
19
|
+
*
|
|
20
|
+
* The projection reads in parallel:
|
|
21
|
+
* - `products` row → product summary + tags + supplier
|
|
22
|
+
* - `product_translations` → localized name + description per locale
|
|
23
|
+
* - `product_itineraries` + `product_days` → itinerary days (no
|
|
24
|
+
* translation table today; falls back to source)
|
|
25
|
+
* - `product_options` + `product_option_translations` → options +
|
|
26
|
+
* localized labels
|
|
27
|
+
* - `product_media` → hero + gallery
|
|
28
|
+
*
|
|
29
|
+
* Day translations don't exist in the schema yet — when
|
|
30
|
+
* `product_day_translations` lands, this function picks them up the
|
|
31
|
+
* same way.
|
|
32
|
+
*/
|
|
33
|
+
import type { ContentLocaleMatchKind } from "@voyant-travel/catalog";
|
|
34
|
+
import type { AnyDrizzleDb } from "@voyant-travel/db";
|
|
35
|
+
import { type ProductContent } from "./content-shape.js";
|
|
36
|
+
export interface BuildOwnedProductContentOptions {
|
|
37
|
+
/**
|
|
38
|
+
* Ordered locale preference chain — most-preferred first. Same shape
|
|
39
|
+
* the catalog plane's `pickBestCachedLocale` consumes. Pass-through
|
|
40
|
+
* from the caller's `BookingDraft.scope.locale` (storefront /
|
|
41
|
+
* operator UI).
|
|
42
|
+
*/
|
|
43
|
+
preferredLocales: ReadonlyArray<string>;
|
|
44
|
+
}
|
|
45
|
+
export interface BuildOwnedProductContentResult {
|
|
46
|
+
/** The owned product projected to ProductContent. */
|
|
47
|
+
content: ProductContent;
|
|
48
|
+
/**
|
|
49
|
+
* The locale we actually served — may differ from
|
|
50
|
+
* `preferredLocales[0]` when a fallback was used. Per-product;
|
|
51
|
+
* options that fell back to a different locale don't override this
|
|
52
|
+
* (storefront UI hints at the product level).
|
|
53
|
+
*/
|
|
54
|
+
servedLocale: string;
|
|
55
|
+
/**
|
|
56
|
+
* How well the served locale matched the chain. Surfaces in the UI
|
|
57
|
+
* as a "served in English" hint when content was served in a
|
|
58
|
+
* non-preferred language.
|
|
59
|
+
*/
|
|
60
|
+
matchKind: ContentLocaleMatchKind;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Read the owned product + related rows and project to `ProductContent`,
|
|
64
|
+
* resolving translations against the supplied locale-preference chain.
|
|
65
|
+
* Returns null when the product doesn't exist.
|
|
66
|
+
*/
|
|
67
|
+
export declare function buildOwnedProductContent(db: AnyDrizzleDb, entityId: string, options: BuildOwnedProductContentOptions): Promise<BuildOwnedProductContentResult | null>;
|
|
68
|
+
//# sourceMappingURL=service-content-owned.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"service-content-owned.d.ts","sourceRoot":"","sources":["../src/service-content-owned.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAEH,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAA;AAEpE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAGrD,OAAO,EACL,KAAK,cAAc,EAGpB,MAAM,oBAAoB,CAAA;AAW3B,MAAM,WAAW,+BAA+B;IAC9C;;;;;OAKG;IACH,gBAAgB,EAAE,aAAa,CAAC,MAAM,CAAC,CAAA;CACxC;AAED,MAAM,WAAW,8BAA8B;IAC7C,qDAAqD;IACrD,OAAO,EAAE,cAAc,CAAA;IACvB;;;;;OAKG;IACH,YAAY,EAAE,MAAM,CAAA;IACpB;;;;OAIG;IACH,SAAS,EAAE,sBAAsB,CAAA;CAClC;AAED;;;;GAIG;AACH,wBAAsB,wBAAwB,CAC5C,EAAE,EAAE,YAAY,EAChB,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,+BAA+B,GACvC,OAAO,CAAC,8BAA8B,GAAG,IAAI,CAAC,CAkJhD"}
|