@voyantjs/booking-requirements 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.
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../src/schema.ts"],"names":[],"mappings":"AAcA,eAAO,MAAM,2BAA2B,kPActC,CAAA;AAEF,eAAO,MAAM,2BAA2B,6FAKtC,CAAA;AAEF,eAAO,MAAM,yBAAyB,iHAOpC,CAAA;AAEF,eAAO,MAAM,4BAA4B,oLAcvC,CAAA;AAEF,eAAO,MAAM,8BAA8B,0EAIzC,CAAA;AAEF,eAAO,MAAM,uBAAuB,2EAIlC,CAAA;AAEF,eAAO,MAAM,0BAA0B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA0BtC,CAAA;AAED,eAAO,MAAM,uBAAuB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAwBnC,CAAA;AAED,eAAO,MAAM,sBAAsB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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eAAO,MAAM,oCAAoC;;EAQhD,CAAA;AAED,eAAO,MAAM,sCAAsC;;EAQlD,CAAA;AAED,eAAO,MAAM,qCAAqC;;EAQjD,CAAA;AAED,eAAO,MAAM,uBAAuB;;EAKjC,CAAA"}
package/dist/schema.js ADDED
@@ -0,0 +1,244 @@
1
+ import { typeId, typeIdRef } from "@voyantjs/db/lib/typeid-column";
2
+ import { relations } from "drizzle-orm";
3
+ import { boolean, index, integer, jsonb, pgEnum, pgTable, text, timestamp, uniqueIndex, } from "drizzle-orm/pg-core";
4
+ export const contactRequirementFieldEnum = pgEnum("contact_requirement_field", [
5
+ "first_name",
6
+ "last_name",
7
+ "email",
8
+ "phone",
9
+ "date_of_birth",
10
+ "nationality",
11
+ "passport_number",
12
+ "passport_expiry",
13
+ "dietary_requirements",
14
+ "accessibility_needs",
15
+ "special_requests",
16
+ "address",
17
+ "other",
18
+ ]);
19
+ export const contactRequirementScopeEnum = pgEnum("contact_requirement_scope", [
20
+ "booking",
21
+ "lead_traveler",
22
+ "participant",
23
+ "booker",
24
+ ]);
25
+ export const bookingQuestionTargetEnum = pgEnum("booking_question_target", [
26
+ "booking",
27
+ "participant",
28
+ "lead_traveler",
29
+ "booker",
30
+ "extra",
31
+ "service",
32
+ ]);
33
+ export const bookingQuestionFieldTypeEnum = pgEnum("booking_question_field_type", [
34
+ "text",
35
+ "textarea",
36
+ "number",
37
+ "email",
38
+ "phone",
39
+ "date",
40
+ "datetime",
41
+ "boolean",
42
+ "single_select",
43
+ "multi_select",
44
+ "file",
45
+ "country",
46
+ "other",
47
+ ]);
48
+ export const bookingQuestionTriggerModeEnum = pgEnum("booking_question_trigger_mode", [
49
+ "required",
50
+ "optional",
51
+ "hidden",
52
+ ]);
53
+ export const bookingAnswerTargetEnum = pgEnum("booking_answer_target", [
54
+ "booking",
55
+ "participant",
56
+ "extra",
57
+ ]);
58
+ export const productContactRequirements = pgTable("product_contact_requirements", {
59
+ id: typeId("product_contact_requirements"),
60
+ productId: text("product_id").notNull(),
61
+ optionId: text("option_id"),
62
+ fieldKey: contactRequirementFieldEnum("field_key").notNull(),
63
+ scope: contactRequirementScopeEnum("scope").notNull().default("participant"),
64
+ isRequired: boolean("is_required").notNull().default(false),
65
+ perParticipant: boolean("per_participant").notNull().default(false),
66
+ active: boolean("active").notNull().default(true),
67
+ sortOrder: integer("sort_order").notNull().default(0),
68
+ notes: text("notes"),
69
+ createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow(),
70
+ updatedAt: timestamp("updated_at", { withTimezone: true }).notNull().defaultNow(),
71
+ }, (table) => [
72
+ index("idx_product_contact_requirements_product").on(table.productId),
73
+ index("idx_product_contact_requirements_option").on(table.optionId),
74
+ uniqueIndex("uidx_product_contact_requirements_scope_field").on(table.productId, table.optionId, table.scope, table.fieldKey),
75
+ ]);
76
+ export const productBookingQuestions = pgTable("product_booking_questions", {
77
+ id: typeId("product_booking_questions"),
78
+ productId: text("product_id").notNull(),
79
+ code: text("code"),
80
+ label: text("label").notNull(),
81
+ description: text("description"),
82
+ target: bookingQuestionTargetEnum("target").notNull().default("booking"),
83
+ fieldType: bookingQuestionFieldTypeEnum("field_type").notNull().default("text"),
84
+ placeholder: text("placeholder"),
85
+ helpText: text("help_text"),
86
+ isRequired: boolean("is_required").notNull().default(false),
87
+ active: boolean("active").notNull().default(true),
88
+ sortOrder: integer("sort_order").notNull().default(0),
89
+ metadata: jsonb("metadata").$type(),
90
+ createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow(),
91
+ updatedAt: timestamp("updated_at", { withTimezone: true }).notNull().defaultNow(),
92
+ }, (table) => [
93
+ index("idx_product_booking_questions_product").on(table.productId),
94
+ index("idx_product_booking_questions_active").on(table.active),
95
+ uniqueIndex("uidx_product_booking_questions_product_code").on(table.productId, table.code),
96
+ ]);
97
+ export const optionBookingQuestions = pgTable("option_booking_questions", {
98
+ id: typeId("option_booking_questions"),
99
+ optionId: text("option_id").notNull(),
100
+ productBookingQuestionId: typeIdRef("product_booking_question_id")
101
+ .notNull()
102
+ .references(() => productBookingQuestions.id, { onDelete: "cascade" }),
103
+ isRequiredOverride: boolean("is_required_override"),
104
+ active: boolean("active").notNull().default(true),
105
+ sortOrder: integer("sort_order").notNull().default(0),
106
+ notes: text("notes"),
107
+ createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow(),
108
+ updatedAt: timestamp("updated_at", { withTimezone: true }).notNull().defaultNow(),
109
+ }, (table) => [
110
+ index("idx_option_booking_questions_option").on(table.optionId),
111
+ index("idx_option_booking_questions_question").on(table.productBookingQuestionId),
112
+ uniqueIndex("uidx_option_booking_questions_option_question").on(table.optionId, table.productBookingQuestionId),
113
+ ]);
114
+ export const bookingQuestionOptions = pgTable("booking_question_options", {
115
+ id: typeId("booking_question_options"),
116
+ productBookingQuestionId: typeIdRef("product_booking_question_id")
117
+ .notNull()
118
+ .references(() => productBookingQuestions.id, { onDelete: "cascade" }),
119
+ value: text("value").notNull(),
120
+ label: text("label").notNull(),
121
+ sortOrder: integer("sort_order").notNull().default(0),
122
+ isDefault: boolean("is_default").notNull().default(false),
123
+ active: boolean("active").notNull().default(true),
124
+ createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow(),
125
+ updatedAt: timestamp("updated_at", { withTimezone: true }).notNull().defaultNow(),
126
+ }, (table) => [
127
+ index("idx_booking_question_options_question").on(table.productBookingQuestionId),
128
+ uniqueIndex("uidx_booking_question_options_question_value").on(table.productBookingQuestionId, table.value),
129
+ ]);
130
+ export const bookingQuestionUnitTriggers = pgTable("booking_question_unit_triggers", {
131
+ id: typeId("booking_question_unit_triggers"),
132
+ productBookingQuestionId: typeIdRef("product_booking_question_id")
133
+ .notNull()
134
+ .references(() => productBookingQuestions.id, { onDelete: "cascade" }),
135
+ unitId: text("unit_id").notNull(),
136
+ triggerMode: bookingQuestionTriggerModeEnum("trigger_mode").notNull().default("required"),
137
+ minQuantity: integer("min_quantity"),
138
+ active: boolean("active").notNull().default(true),
139
+ createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow(),
140
+ updatedAt: timestamp("updated_at", { withTimezone: true }).notNull().defaultNow(),
141
+ }, (table) => [
142
+ index("idx_booking_question_unit_triggers_question").on(table.productBookingQuestionId),
143
+ index("idx_booking_question_unit_triggers_unit").on(table.unitId),
144
+ uniqueIndex("uidx_booking_question_unit_triggers_question_unit").on(table.productBookingQuestionId, table.unitId),
145
+ ]);
146
+ export const bookingQuestionOptionTriggers = pgTable("booking_question_option_triggers", {
147
+ id: typeId("booking_question_option_triggers"),
148
+ productBookingQuestionId: typeIdRef("product_booking_question_id")
149
+ .notNull()
150
+ .references(() => productBookingQuestions.id, { onDelete: "cascade" }),
151
+ optionId: text("option_id").notNull(),
152
+ triggerMode: bookingQuestionTriggerModeEnum("trigger_mode").notNull().default("required"),
153
+ active: boolean("active").notNull().default(true),
154
+ createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow(),
155
+ updatedAt: timestamp("updated_at", { withTimezone: true }).notNull().defaultNow(),
156
+ }, (table) => [
157
+ index("idx_booking_question_option_triggers_question").on(table.productBookingQuestionId),
158
+ index("idx_booking_question_option_triggers_option").on(table.optionId),
159
+ uniqueIndex("uidx_booking_question_option_triggers_question_option").on(table.productBookingQuestionId, table.optionId),
160
+ ]);
161
+ export const bookingQuestionExtraTriggers = pgTable("booking_question_extra_triggers", {
162
+ id: typeId("booking_question_extra_triggers"),
163
+ productBookingQuestionId: typeIdRef("product_booking_question_id")
164
+ .notNull()
165
+ .references(() => productBookingQuestions.id, { onDelete: "cascade" }),
166
+ productExtraId: text("product_extra_id"),
167
+ optionExtraConfigId: text("option_extra_config_id"),
168
+ triggerMode: bookingQuestionTriggerModeEnum("trigger_mode").notNull().default("required"),
169
+ minQuantity: integer("min_quantity"),
170
+ active: boolean("active").notNull().default(true),
171
+ createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow(),
172
+ updatedAt: timestamp("updated_at", { withTimezone: true }).notNull().defaultNow(),
173
+ }, (table) => [
174
+ index("idx_booking_question_extra_triggers_question").on(table.productBookingQuestionId),
175
+ index("idx_booking_question_extra_triggers_product_extra").on(table.productExtraId),
176
+ index("idx_booking_question_extra_triggers_option_extra_config").on(table.optionExtraConfigId),
177
+ ]);
178
+ export const bookingAnswers = pgTable("booking_answers", {
179
+ id: typeId("booking_answers"),
180
+ bookingId: text("booking_id").notNull(),
181
+ productBookingQuestionId: typeIdRef("product_booking_question_id")
182
+ .notNull()
183
+ .references(() => productBookingQuestions.id, { onDelete: "cascade" }),
184
+ bookingParticipantId: text("booking_participant_id"),
185
+ bookingExtraId: text("booking_extra_id"),
186
+ target: bookingAnswerTargetEnum("target").notNull().default("booking"),
187
+ valueText: text("value_text"),
188
+ valueNumber: integer("value_number"),
189
+ valueBoolean: boolean("value_boolean"),
190
+ valueJson: jsonb("value_json").$type(),
191
+ notes: text("notes"),
192
+ createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow(),
193
+ updatedAt: timestamp("updated_at", { withTimezone: true }).notNull().defaultNow(),
194
+ }, (table) => [
195
+ index("idx_booking_answers_booking").on(table.bookingId),
196
+ index("idx_booking_answers_question").on(table.productBookingQuestionId),
197
+ index("idx_booking_answers_participant").on(table.bookingParticipantId),
198
+ index("idx_booking_answers_booking_extra").on(table.bookingExtraId),
199
+ ]);
200
+ export const productContactRequirementsRelations = relations(productContactRequirements, () => ({}));
201
+ export const productBookingQuestionsRelations = relations(productBookingQuestions, ({ many }) => ({
202
+ optionQuestions: many(optionBookingQuestions),
203
+ options: many(bookingQuestionOptions),
204
+ unitTriggers: many(bookingQuestionUnitTriggers),
205
+ optionTriggers: many(bookingQuestionOptionTriggers),
206
+ extraTriggers: many(bookingQuestionExtraTriggers),
207
+ answers: many(bookingAnswers),
208
+ }));
209
+ export const optionBookingQuestionsRelations = relations(optionBookingQuestions, ({ one }) => ({
210
+ productBookingQuestion: one(productBookingQuestions, {
211
+ fields: [optionBookingQuestions.productBookingQuestionId],
212
+ references: [productBookingQuestions.id],
213
+ }),
214
+ }));
215
+ export const bookingQuestionOptionsRelations = relations(bookingQuestionOptions, ({ one }) => ({
216
+ productBookingQuestion: one(productBookingQuestions, {
217
+ fields: [bookingQuestionOptions.productBookingQuestionId],
218
+ references: [productBookingQuestions.id],
219
+ }),
220
+ }));
221
+ export const bookingQuestionUnitTriggersRelations = relations(bookingQuestionUnitTriggers, ({ one }) => ({
222
+ productBookingQuestion: one(productBookingQuestions, {
223
+ fields: [bookingQuestionUnitTriggers.productBookingQuestionId],
224
+ references: [productBookingQuestions.id],
225
+ }),
226
+ }));
227
+ export const bookingQuestionOptionTriggersRelations = relations(bookingQuestionOptionTriggers, ({ one }) => ({
228
+ productBookingQuestion: one(productBookingQuestions, {
229
+ fields: [bookingQuestionOptionTriggers.productBookingQuestionId],
230
+ references: [productBookingQuestions.id],
231
+ }),
232
+ }));
233
+ export const bookingQuestionExtraTriggersRelations = relations(bookingQuestionExtraTriggers, ({ one }) => ({
234
+ productBookingQuestion: one(productBookingQuestions, {
235
+ fields: [bookingQuestionExtraTriggers.productBookingQuestionId],
236
+ references: [productBookingQuestions.id],
237
+ }),
238
+ }));
239
+ export const bookingAnswersRelations = relations(bookingAnswers, ({ one }) => ({
240
+ productBookingQuestion: one(productBookingQuestions, {
241
+ fields: [bookingAnswers.productBookingQuestionId],
242
+ references: [productBookingQuestions.id],
243
+ }),
244
+ }));