@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,181 @@
|
|
|
1
|
+
import type { PostgresJsDatabase } from "drizzle-orm/postgres-js";
|
|
2
|
+
import type { z } from "zod";
|
|
3
|
+
import type { insertOptionUnitSchema, insertProductOptionSchema, optionUnitListQuerySchema, productOptionListQuerySchema, updateOptionUnitSchema, updateProductOptionSchema } from "./validation.js";
|
|
4
|
+
type ProductOptionListQuery = z.infer<typeof productOptionListQuerySchema>;
|
|
5
|
+
type CreateProductOptionInput = z.infer<typeof insertProductOptionSchema>;
|
|
6
|
+
type UpdateProductOptionInput = z.infer<typeof updateProductOptionSchema>;
|
|
7
|
+
type OptionUnitListQuery = z.infer<typeof optionUnitListQuerySchema>;
|
|
8
|
+
type CreateOptionUnitInput = z.infer<typeof insertOptionUnitSchema>;
|
|
9
|
+
type UpdateOptionUnitInput = z.infer<typeof updateOptionUnitSchema>;
|
|
10
|
+
export declare const optionProductsService: {
|
|
11
|
+
listOptions(db: PostgresJsDatabase, query: ProductOptionListQuery): Promise<{
|
|
12
|
+
data: {
|
|
13
|
+
id: string;
|
|
14
|
+
productId: string;
|
|
15
|
+
name: string;
|
|
16
|
+
code: string | null;
|
|
17
|
+
description: string | null;
|
|
18
|
+
status: "draft" | "active" | "archived";
|
|
19
|
+
isDefault: boolean;
|
|
20
|
+
sortOrder: number;
|
|
21
|
+
availableFrom: string | null;
|
|
22
|
+
availableTo: string | null;
|
|
23
|
+
createdAt: Date;
|
|
24
|
+
updatedAt: Date;
|
|
25
|
+
}[];
|
|
26
|
+
total: number;
|
|
27
|
+
limit: number;
|
|
28
|
+
offset: number;
|
|
29
|
+
}>;
|
|
30
|
+
getOptionById(db: PostgresJsDatabase, id: string): Promise<{
|
|
31
|
+
id: string;
|
|
32
|
+
productId: string;
|
|
33
|
+
name: string;
|
|
34
|
+
code: string | null;
|
|
35
|
+
description: string | null;
|
|
36
|
+
status: "draft" | "active" | "archived";
|
|
37
|
+
isDefault: boolean;
|
|
38
|
+
sortOrder: number;
|
|
39
|
+
availableFrom: string | null;
|
|
40
|
+
availableTo: string | null;
|
|
41
|
+
createdAt: Date;
|
|
42
|
+
updatedAt: Date;
|
|
43
|
+
} | null>;
|
|
44
|
+
createOption(db: PostgresJsDatabase, productId: string, data: CreateProductOptionInput): Promise<{
|
|
45
|
+
id: string;
|
|
46
|
+
name: string;
|
|
47
|
+
status: "draft" | "active" | "archived";
|
|
48
|
+
description: string | null;
|
|
49
|
+
createdAt: Date;
|
|
50
|
+
updatedAt: Date;
|
|
51
|
+
code: string | null;
|
|
52
|
+
productId: string;
|
|
53
|
+
isDefault: boolean;
|
|
54
|
+
sortOrder: number;
|
|
55
|
+
availableFrom: string | null;
|
|
56
|
+
availableTo: string | null;
|
|
57
|
+
} | null | undefined>;
|
|
58
|
+
updateOption(db: PostgresJsDatabase, id: string, data: UpdateProductOptionInput): Promise<{
|
|
59
|
+
id: string;
|
|
60
|
+
productId: string;
|
|
61
|
+
name: string;
|
|
62
|
+
code: string | null;
|
|
63
|
+
description: string | null;
|
|
64
|
+
status: "draft" | "active" | "archived";
|
|
65
|
+
isDefault: boolean;
|
|
66
|
+
sortOrder: number;
|
|
67
|
+
availableFrom: string | null;
|
|
68
|
+
availableTo: string | null;
|
|
69
|
+
createdAt: Date;
|
|
70
|
+
updatedAt: Date;
|
|
71
|
+
} | null>;
|
|
72
|
+
deleteOption(db: PostgresJsDatabase, id: string): Promise<{
|
|
73
|
+
id: string;
|
|
74
|
+
} | null>;
|
|
75
|
+
listUnits(db: PostgresJsDatabase, query: OptionUnitListQuery): Promise<{
|
|
76
|
+
data: {
|
|
77
|
+
id: string;
|
|
78
|
+
optionId: string;
|
|
79
|
+
name: string;
|
|
80
|
+
code: string | null;
|
|
81
|
+
description: string | null;
|
|
82
|
+
unitType: "other" | "person" | "group" | "room" | "vehicle" | "service";
|
|
83
|
+
minQuantity: number | null;
|
|
84
|
+
maxQuantity: number | null;
|
|
85
|
+
minAge: number | null;
|
|
86
|
+
maxAge: number | null;
|
|
87
|
+
occupancyMin: number | null;
|
|
88
|
+
occupancyMax: number | null;
|
|
89
|
+
isRequired: boolean;
|
|
90
|
+
isHidden: boolean;
|
|
91
|
+
sortOrder: number;
|
|
92
|
+
createdAt: Date;
|
|
93
|
+
updatedAt: Date;
|
|
94
|
+
}[];
|
|
95
|
+
total: number;
|
|
96
|
+
limit: number;
|
|
97
|
+
offset: number;
|
|
98
|
+
}>;
|
|
99
|
+
getUnitById(db: PostgresJsDatabase, id: string): Promise<{
|
|
100
|
+
id: string;
|
|
101
|
+
optionId: string;
|
|
102
|
+
name: string;
|
|
103
|
+
code: string | null;
|
|
104
|
+
description: string | null;
|
|
105
|
+
unitType: "other" | "person" | "group" | "room" | "vehicle" | "service";
|
|
106
|
+
minQuantity: number | null;
|
|
107
|
+
maxQuantity: number | null;
|
|
108
|
+
minAge: number | null;
|
|
109
|
+
maxAge: number | null;
|
|
110
|
+
occupancyMin: number | null;
|
|
111
|
+
occupancyMax: number | null;
|
|
112
|
+
isRequired: boolean;
|
|
113
|
+
isHidden: boolean;
|
|
114
|
+
sortOrder: number;
|
|
115
|
+
createdAt: Date;
|
|
116
|
+
updatedAt: Date;
|
|
117
|
+
} | null>;
|
|
118
|
+
getUnitForProductMutation(db: PostgresJsDatabase, id: string): Promise<{
|
|
119
|
+
productId: string;
|
|
120
|
+
id: string;
|
|
121
|
+
optionId: string;
|
|
122
|
+
name: string;
|
|
123
|
+
code: string | null;
|
|
124
|
+
description: string | null;
|
|
125
|
+
unitType: "other" | "person" | "group" | "room" | "vehicle" | "service";
|
|
126
|
+
minQuantity: number | null;
|
|
127
|
+
maxQuantity: number | null;
|
|
128
|
+
minAge: number | null;
|
|
129
|
+
maxAge: number | null;
|
|
130
|
+
occupancyMin: number | null;
|
|
131
|
+
occupancyMax: number | null;
|
|
132
|
+
isRequired: boolean;
|
|
133
|
+
isHidden: boolean;
|
|
134
|
+
sortOrder: number;
|
|
135
|
+
createdAt: Date;
|
|
136
|
+
updatedAt: Date;
|
|
137
|
+
} | null>;
|
|
138
|
+
createUnit(db: PostgresJsDatabase, optionId: string, data: CreateOptionUnitInput): Promise<{
|
|
139
|
+
id: string;
|
|
140
|
+
name: string;
|
|
141
|
+
description: string | null;
|
|
142
|
+
createdAt: Date;
|
|
143
|
+
updatedAt: Date;
|
|
144
|
+
code: string | null;
|
|
145
|
+
sortOrder: number;
|
|
146
|
+
optionId: string;
|
|
147
|
+
unitType: "other" | "person" | "group" | "room" | "vehicle" | "service";
|
|
148
|
+
minQuantity: number | null;
|
|
149
|
+
maxQuantity: number | null;
|
|
150
|
+
minAge: number | null;
|
|
151
|
+
maxAge: number | null;
|
|
152
|
+
occupancyMin: number | null;
|
|
153
|
+
occupancyMax: number | null;
|
|
154
|
+
isRequired: boolean;
|
|
155
|
+
isHidden: boolean;
|
|
156
|
+
} | null | undefined>;
|
|
157
|
+
updateUnit(db: PostgresJsDatabase, id: string, data: UpdateOptionUnitInput): Promise<{
|
|
158
|
+
id: string;
|
|
159
|
+
optionId: string;
|
|
160
|
+
name: string;
|
|
161
|
+
code: string | null;
|
|
162
|
+
description: string | null;
|
|
163
|
+
unitType: "other" | "person" | "group" | "room" | "vehicle" | "service";
|
|
164
|
+
minQuantity: number | null;
|
|
165
|
+
maxQuantity: number | null;
|
|
166
|
+
minAge: number | null;
|
|
167
|
+
maxAge: number | null;
|
|
168
|
+
occupancyMin: number | null;
|
|
169
|
+
occupancyMax: number | null;
|
|
170
|
+
isRequired: boolean;
|
|
171
|
+
isHidden: boolean;
|
|
172
|
+
sortOrder: number;
|
|
173
|
+
createdAt: Date;
|
|
174
|
+
updatedAt: Date;
|
|
175
|
+
} | null>;
|
|
176
|
+
deleteUnit(db: PostgresJsDatabase, id: string): Promise<{
|
|
177
|
+
id: string;
|
|
178
|
+
} | null>;
|
|
179
|
+
};
|
|
180
|
+
export {};
|
|
181
|
+
//# sourceMappingURL=service-options.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"service-options.d.ts","sourceRoot":"","sources":["../src/service-options.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAA;AACjE,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAE5B,OAAO,KAAK,EACV,sBAAsB,EACtB,yBAAyB,EACzB,yBAAyB,EACzB,4BAA4B,EAC5B,sBAAsB,EACtB,yBAAyB,EAC1B,MAAM,iBAAiB,CAAA;AAGxB,KAAK,sBAAsB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,4BAA4B,CAAC,CAAA;AAC1E,KAAK,wBAAwB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,yBAAyB,CAAC,CAAA;AACzE,KAAK,wBAAwB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,yBAAyB,CAAC,CAAA;AACzE,KAAK,mBAAmB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,yBAAyB,CAAC,CAAA;AACpE,KAAK,qBAAqB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,sBAAsB,CAAC,CAAA;AACnE,KAAK,qBAAqB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,sBAAsB,CAAC,CAAA;AAEnE,eAAO,MAAM,qBAAqB;oBACV,kBAAkB,SAAS,sBAAsB;;;;;;;;;;;;;;;;;;;sBAgC/C,kBAAkB,MAAM,MAAM;;;;;;;;;;;;;;qBAK/B,kBAAkB,aAAa,MAAM,QAAQ,wBAAwB;;;;;;;;;;;;;;qBA0BrE,kBAAkB,MAAM,MAAM,QAAQ,wBAAwB;;;;;;;;;;;;;;qBA2B9D,kBAAkB,MAAM,MAAM;;;kBASjC,kBAAkB,SAAS,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;oBAgC5C,kBAAkB,MAAM,MAAM;;;;;;;;;;;;;;;;;;;kCAKhB,kBAAkB,MAAM,MAAM;;;;;;;;;;;;;;;;;;;;mBAW7C,kBAAkB,YAAY,MAAM,QAAQ,qBAAqB;;;;;;;;;;;;;;;;;;;mBAmBjE,kBAAkB,MAAM,MAAM,QAAQ,qBAAqB;;;;;;;;;;;;;;;;;;;mBAsC3D,kBAAkB,MAAM,MAAM;;;CAQpD,CAAA"}
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
import { RequestValidationError } from "@voyant-travel/hono";
|
|
2
|
+
import { and, asc, eq, sql } from "drizzle-orm";
|
|
3
|
+
import { optionUnits, productOptions, products } from "./schema.js";
|
|
4
|
+
import { validateMergedOptionUnit } from "./validation-core.js";
|
|
5
|
+
export const optionProductsService = {
|
|
6
|
+
async listOptions(db, query) {
|
|
7
|
+
const conditions = [];
|
|
8
|
+
if (query.productId) {
|
|
9
|
+
conditions.push(eq(productOptions.productId, query.productId));
|
|
10
|
+
}
|
|
11
|
+
if (query.status) {
|
|
12
|
+
conditions.push(eq(productOptions.status, query.status));
|
|
13
|
+
}
|
|
14
|
+
const where = conditions.length > 0 ? and(...conditions) : undefined;
|
|
15
|
+
const [rows, countResult] = await Promise.all([
|
|
16
|
+
db
|
|
17
|
+
.select()
|
|
18
|
+
.from(productOptions)
|
|
19
|
+
.where(where)
|
|
20
|
+
.limit(query.limit)
|
|
21
|
+
.offset(query.offset)
|
|
22
|
+
.orderBy(asc(productOptions.sortOrder), asc(productOptions.createdAt)),
|
|
23
|
+
db.select({ count: sql `count(*)::int` }).from(productOptions).where(where),
|
|
24
|
+
]);
|
|
25
|
+
return {
|
|
26
|
+
data: rows,
|
|
27
|
+
total: countResult[0]?.count ?? 0,
|
|
28
|
+
limit: query.limit,
|
|
29
|
+
offset: query.offset,
|
|
30
|
+
};
|
|
31
|
+
},
|
|
32
|
+
async getOptionById(db, id) {
|
|
33
|
+
const [row] = await db.select().from(productOptions).where(eq(productOptions.id, id)).limit(1);
|
|
34
|
+
return row ?? null;
|
|
35
|
+
},
|
|
36
|
+
async createOption(db, productId, data) {
|
|
37
|
+
const [product] = await db
|
|
38
|
+
.select({ id: products.id })
|
|
39
|
+
.from(products)
|
|
40
|
+
.where(eq(products.id, productId))
|
|
41
|
+
.limit(1);
|
|
42
|
+
if (!product) {
|
|
43
|
+
return null;
|
|
44
|
+
}
|
|
45
|
+
if (data.isDefault) {
|
|
46
|
+
await db
|
|
47
|
+
.update(productOptions)
|
|
48
|
+
.set({ isDefault: false, updatedAt: new Date() })
|
|
49
|
+
.where(eq(productOptions.productId, productId));
|
|
50
|
+
}
|
|
51
|
+
const [row] = await db
|
|
52
|
+
.insert(productOptions)
|
|
53
|
+
.values({ ...data, productId })
|
|
54
|
+
.returning();
|
|
55
|
+
return row;
|
|
56
|
+
},
|
|
57
|
+
async updateOption(db, id, data) {
|
|
58
|
+
const [current] = await db
|
|
59
|
+
.select({ id: productOptions.id, productId: productOptions.productId })
|
|
60
|
+
.from(productOptions)
|
|
61
|
+
.where(eq(productOptions.id, id))
|
|
62
|
+
.limit(1);
|
|
63
|
+
if (!current) {
|
|
64
|
+
return null;
|
|
65
|
+
}
|
|
66
|
+
if (data.isDefault) {
|
|
67
|
+
await db
|
|
68
|
+
.update(productOptions)
|
|
69
|
+
.set({ isDefault: false, updatedAt: new Date() })
|
|
70
|
+
.where(eq(productOptions.productId, current.productId));
|
|
71
|
+
}
|
|
72
|
+
const [row] = await db
|
|
73
|
+
.update(productOptions)
|
|
74
|
+
.set({ ...data, updatedAt: new Date() })
|
|
75
|
+
.where(eq(productOptions.id, id))
|
|
76
|
+
.returning();
|
|
77
|
+
return row ?? null;
|
|
78
|
+
},
|
|
79
|
+
async deleteOption(db, id) {
|
|
80
|
+
const [row] = await db
|
|
81
|
+
.delete(productOptions)
|
|
82
|
+
.where(eq(productOptions.id, id))
|
|
83
|
+
.returning({ id: productOptions.id });
|
|
84
|
+
return row ?? null;
|
|
85
|
+
},
|
|
86
|
+
async listUnits(db, query) {
|
|
87
|
+
const conditions = [];
|
|
88
|
+
if (query.optionId) {
|
|
89
|
+
conditions.push(eq(optionUnits.optionId, query.optionId));
|
|
90
|
+
}
|
|
91
|
+
if (query.unitType) {
|
|
92
|
+
conditions.push(eq(optionUnits.unitType, query.unitType));
|
|
93
|
+
}
|
|
94
|
+
const where = conditions.length > 0 ? and(...conditions) : undefined;
|
|
95
|
+
const [rows, countResult] = await Promise.all([
|
|
96
|
+
db
|
|
97
|
+
.select()
|
|
98
|
+
.from(optionUnits)
|
|
99
|
+
.where(where)
|
|
100
|
+
.limit(query.limit)
|
|
101
|
+
.offset(query.offset)
|
|
102
|
+
.orderBy(asc(optionUnits.sortOrder), asc(optionUnits.createdAt)),
|
|
103
|
+
db.select({ count: sql `count(*)::int` }).from(optionUnits).where(where),
|
|
104
|
+
]);
|
|
105
|
+
return {
|
|
106
|
+
data: rows,
|
|
107
|
+
total: countResult[0]?.count ?? 0,
|
|
108
|
+
limit: query.limit,
|
|
109
|
+
offset: query.offset,
|
|
110
|
+
};
|
|
111
|
+
},
|
|
112
|
+
async getUnitById(db, id) {
|
|
113
|
+
const [row] = await db.select().from(optionUnits).where(eq(optionUnits.id, id)).limit(1);
|
|
114
|
+
return row ?? null;
|
|
115
|
+
},
|
|
116
|
+
async getUnitForProductMutation(db, id) {
|
|
117
|
+
const [row] = await db
|
|
118
|
+
.select({ unit: optionUnits, productId: productOptions.productId })
|
|
119
|
+
.from(optionUnits)
|
|
120
|
+
.innerJoin(productOptions, eq(optionUnits.optionId, productOptions.id))
|
|
121
|
+
.where(eq(optionUnits.id, id))
|
|
122
|
+
.limit(1);
|
|
123
|
+
return row ? { ...row.unit, productId: row.productId } : null;
|
|
124
|
+
},
|
|
125
|
+
async createUnit(db, optionId, data) {
|
|
126
|
+
const [option] = await db
|
|
127
|
+
.select({ id: productOptions.id })
|
|
128
|
+
.from(productOptions)
|
|
129
|
+
.where(eq(productOptions.id, optionId))
|
|
130
|
+
.limit(1);
|
|
131
|
+
if (!option) {
|
|
132
|
+
return null;
|
|
133
|
+
}
|
|
134
|
+
const [row] = await db
|
|
135
|
+
.insert(optionUnits)
|
|
136
|
+
.values({ ...data, optionId })
|
|
137
|
+
.returning();
|
|
138
|
+
return row;
|
|
139
|
+
},
|
|
140
|
+
async updateUnit(db, id, data) {
|
|
141
|
+
const [existing] = await db
|
|
142
|
+
.select({
|
|
143
|
+
unitType: optionUnits.unitType,
|
|
144
|
+
occupancyMin: optionUnits.occupancyMin,
|
|
145
|
+
occupancyMax: optionUnits.occupancyMax,
|
|
146
|
+
})
|
|
147
|
+
.from(optionUnits)
|
|
148
|
+
.where(eq(optionUnits.id, id))
|
|
149
|
+
.limit(1);
|
|
150
|
+
if (!existing) {
|
|
151
|
+
return null;
|
|
152
|
+
}
|
|
153
|
+
const merged = {
|
|
154
|
+
unitType: "unitType" in data ? data.unitType : existing.unitType,
|
|
155
|
+
occupancyMin: "occupancyMin" in data ? data.occupancyMin : existing.occupancyMin,
|
|
156
|
+
occupancyMax: "occupancyMax" in data ? data.occupancyMax : existing.occupancyMax,
|
|
157
|
+
};
|
|
158
|
+
const validation = validateMergedOptionUnit(merged);
|
|
159
|
+
if (!validation.ok) {
|
|
160
|
+
const first = validation.issues[0];
|
|
161
|
+
throw new RequestValidationError(first?.message ?? "Invalid option unit", {
|
|
162
|
+
issues: validation.issues,
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
const [row] = await db
|
|
166
|
+
.update(optionUnits)
|
|
167
|
+
.set({ ...data, updatedAt: new Date() })
|
|
168
|
+
.where(eq(optionUnits.id, id))
|
|
169
|
+
.returning();
|
|
170
|
+
return row ?? null;
|
|
171
|
+
},
|
|
172
|
+
async deleteUnit(db, id) {
|
|
173
|
+
const [row] = await db
|
|
174
|
+
.delete(optionUnits)
|
|
175
|
+
.where(eq(optionUnits.id, id))
|
|
176
|
+
.returning({ id: optionUnits.id });
|
|
177
|
+
return row ?? null;
|
|
178
|
+
},
|
|
179
|
+
};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { PostgresJsDatabase } from "drizzle-orm/postgres-js";
|
|
2
|
+
import type { z } from "zod";
|
|
3
|
+
import type { productDestinationListQuerySchema } from "./validation.js";
|
|
4
|
+
type ProductDestinationListQuery = z.infer<typeof productDestinationListQuerySchema>;
|
|
5
|
+
export declare const productDestinationProductsService: {
|
|
6
|
+
listProductDestinations(db: PostgresJsDatabase, query: ProductDestinationListQuery): Promise<{
|
|
7
|
+
data: {
|
|
8
|
+
productId: string;
|
|
9
|
+
destinationId: string;
|
|
10
|
+
sortOrder: number;
|
|
11
|
+
createdAt: Date;
|
|
12
|
+
updatedAt: Date;
|
|
13
|
+
destinationSlug: string;
|
|
14
|
+
destinationType: string;
|
|
15
|
+
destinationActive: boolean;
|
|
16
|
+
}[];
|
|
17
|
+
total: number;
|
|
18
|
+
limit: number;
|
|
19
|
+
offset: number;
|
|
20
|
+
}>;
|
|
21
|
+
assignProductDestination(db: PostgresJsDatabase, productId: string, input: {
|
|
22
|
+
destinationId: string;
|
|
23
|
+
sortOrder?: number;
|
|
24
|
+
}): Promise<{
|
|
25
|
+
createdAt: Date;
|
|
26
|
+
updatedAt: Date;
|
|
27
|
+
productId: string;
|
|
28
|
+
sortOrder: number;
|
|
29
|
+
destinationId: string;
|
|
30
|
+
} | null>;
|
|
31
|
+
removeProductDestination(db: PostgresJsDatabase, productId: string, destinationId: string): Promise<{
|
|
32
|
+
productId: string;
|
|
33
|
+
destinationId: string;
|
|
34
|
+
} | null>;
|
|
35
|
+
};
|
|
36
|
+
export {};
|
|
37
|
+
//# sourceMappingURL=service-product-destinations.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"service-product-destinations.d.ts","sourceRoot":"","sources":["../src/service-product-destinations.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAA;AACjE,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAE5B,OAAO,KAAK,EAAE,iCAAiC,EAAE,MAAM,iBAAiB,CAAA;AAExE,KAAK,2BAA2B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,iCAAiC,CAAC,CAAA;AAYpF,eAAO,MAAM,iCAAiC;gCACV,kBAAkB,SAAS,2BAA2B;;;;;;;;;;;;;;;iCA2ClF,kBAAkB,aACX,MAAM,SACV;QAAE,aAAa,EAAE,MAAM,CAAC;QAAC,SAAS,CAAC,EAAE,MAAM,CAAA;KAAE;;;;;;;iCAqDnB,kBAAkB,aAAa,MAAM,iBAAiB,MAAM;;;;CAgBhG,CAAA"}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { and, asc, eq, sql } from "drizzle-orm";
|
|
2
|
+
import { destinations, productDestinations, products } 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 productDestinationProductsService = {
|
|
12
|
+
async listProductDestinations(db, query) {
|
|
13
|
+
const conditions = [];
|
|
14
|
+
if (query.productId) {
|
|
15
|
+
conditions.push(eq(productDestinations.productId, query.productId));
|
|
16
|
+
}
|
|
17
|
+
if (query.destinationId) {
|
|
18
|
+
conditions.push(eq(productDestinations.destinationId, query.destinationId));
|
|
19
|
+
}
|
|
20
|
+
const where = conditions.length > 0 ? and(...conditions) : undefined;
|
|
21
|
+
const [rows, countResult] = await Promise.all([
|
|
22
|
+
db
|
|
23
|
+
.select({
|
|
24
|
+
productId: productDestinations.productId,
|
|
25
|
+
destinationId: productDestinations.destinationId,
|
|
26
|
+
sortOrder: productDestinations.sortOrder,
|
|
27
|
+
createdAt: productDestinations.createdAt,
|
|
28
|
+
updatedAt: productDestinations.updatedAt,
|
|
29
|
+
destinationSlug: destinations.slug,
|
|
30
|
+
destinationType: destinations.destinationType,
|
|
31
|
+
destinationActive: destinations.active,
|
|
32
|
+
})
|
|
33
|
+
.from(productDestinations)
|
|
34
|
+
.innerJoin(destinations, eq(destinations.id, productDestinations.destinationId))
|
|
35
|
+
.where(where)
|
|
36
|
+
.limit(query.limit)
|
|
37
|
+
.offset(query.offset)
|
|
38
|
+
.orderBy(asc(productDestinations.sortOrder), asc(destinations.slug)),
|
|
39
|
+
db.select({ count: sql `count(*)::int` }).from(productDestinations).where(where),
|
|
40
|
+
]);
|
|
41
|
+
return {
|
|
42
|
+
data: rows,
|
|
43
|
+
total: countResult[0]?.count ?? 0,
|
|
44
|
+
limit: query.limit,
|
|
45
|
+
offset: query.offset,
|
|
46
|
+
};
|
|
47
|
+
},
|
|
48
|
+
async assignProductDestination(db, productId, input) {
|
|
49
|
+
const product = await ensureProductExists(db, productId);
|
|
50
|
+
if (!product) {
|
|
51
|
+
return null;
|
|
52
|
+
}
|
|
53
|
+
const [destination] = await db
|
|
54
|
+
.select({ id: destinations.id })
|
|
55
|
+
.from(destinations)
|
|
56
|
+
.where(eq(destinations.id, input.destinationId))
|
|
57
|
+
.limit(1);
|
|
58
|
+
if (!destination) {
|
|
59
|
+
return null;
|
|
60
|
+
}
|
|
61
|
+
const [existing] = await db
|
|
62
|
+
.select()
|
|
63
|
+
.from(productDestinations)
|
|
64
|
+
.where(and(eq(productDestinations.productId, productId), eq(productDestinations.destinationId, input.destinationId)))
|
|
65
|
+
.limit(1);
|
|
66
|
+
if (existing) {
|
|
67
|
+
const [row] = await db
|
|
68
|
+
.update(productDestinations)
|
|
69
|
+
.set({ sortOrder: input.sortOrder ?? existing.sortOrder, updatedAt: new Date() })
|
|
70
|
+
.where(and(eq(productDestinations.productId, productId), eq(productDestinations.destinationId, input.destinationId)))
|
|
71
|
+
.returning();
|
|
72
|
+
return row ?? null;
|
|
73
|
+
}
|
|
74
|
+
const [row] = await db
|
|
75
|
+
.insert(productDestinations)
|
|
76
|
+
.values({
|
|
77
|
+
productId,
|
|
78
|
+
destinationId: input.destinationId,
|
|
79
|
+
sortOrder: input.sortOrder ?? 0,
|
|
80
|
+
})
|
|
81
|
+
.returning();
|
|
82
|
+
return row ?? null;
|
|
83
|
+
},
|
|
84
|
+
async removeProductDestination(db, productId, destinationId) {
|
|
85
|
+
const [row] = await db
|
|
86
|
+
.delete(productDestinations)
|
|
87
|
+
.where(and(eq(productDestinations.productId, productId), eq(productDestinations.destinationId, destinationId)))
|
|
88
|
+
.returning({
|
|
89
|
+
productId: productDestinations.productId,
|
|
90
|
+
destinationId: productDestinations.destinationId,
|
|
91
|
+
});
|
|
92
|
+
return row ?? null;
|
|
93
|
+
},
|
|
94
|
+
};
|