@voyantjs/booking-requirements 0.2.0 → 0.3.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,319 @@
1
+ import { and, asc, desc, eq, sql } from "drizzle-orm";
2
+ import { bookingQuestionExtraTriggers, bookingQuestionOptions, bookingQuestionOptionTriggers, bookingQuestionUnitTriggers, optionBookingQuestions, productBookingQuestions, productContactRequirements, } from "./schema.js";
3
+ import { paginate } from "./service-shared.js";
4
+ export async function listProductContactRequirements(db, query) {
5
+ const conditions = [];
6
+ if (query.productId)
7
+ conditions.push(eq(productContactRequirements.productId, query.productId));
8
+ if (query.optionId)
9
+ conditions.push(eq(productContactRequirements.optionId, query.optionId));
10
+ if (query.active !== undefined)
11
+ conditions.push(eq(productContactRequirements.active, query.active));
12
+ const where = conditions.length ? and(...conditions) : undefined;
13
+ return paginate(db
14
+ .select()
15
+ .from(productContactRequirements)
16
+ .where(where)
17
+ .limit(query.limit)
18
+ .offset(query.offset)
19
+ .orderBy(asc(productContactRequirements.sortOrder)), db.select({ count: sql `count(*)::int` }).from(productContactRequirements).where(where), query.limit, query.offset);
20
+ }
21
+ export async function getProductContactRequirementById(db, id) {
22
+ const [row] = await db
23
+ .select()
24
+ .from(productContactRequirements)
25
+ .where(eq(productContactRequirements.id, id))
26
+ .limit(1);
27
+ return row ?? null;
28
+ }
29
+ export async function createProductContactRequirement(db, data) {
30
+ const [row] = await db.insert(productContactRequirements).values(data).returning();
31
+ return row ?? null;
32
+ }
33
+ export async function updateProductContactRequirement(db, id, data) {
34
+ const [row] = await db
35
+ .update(productContactRequirements)
36
+ .set({ ...data, updatedAt: new Date() })
37
+ .where(eq(productContactRequirements.id, id))
38
+ .returning();
39
+ return row ?? null;
40
+ }
41
+ export async function deleteProductContactRequirement(db, id) {
42
+ const [row] = await db
43
+ .delete(productContactRequirements)
44
+ .where(eq(productContactRequirements.id, id))
45
+ .returning({ id: productContactRequirements.id });
46
+ return row ?? null;
47
+ }
48
+ export async function listProductBookingQuestions(db, query) {
49
+ const conditions = [];
50
+ if (query.productId)
51
+ conditions.push(eq(productBookingQuestions.productId, query.productId));
52
+ if (query.target)
53
+ conditions.push(eq(productBookingQuestions.target, query.target));
54
+ if (query.fieldType)
55
+ conditions.push(eq(productBookingQuestions.fieldType, query.fieldType));
56
+ if (query.active !== undefined)
57
+ conditions.push(eq(productBookingQuestions.active, query.active));
58
+ const where = conditions.length ? and(...conditions) : undefined;
59
+ return paginate(db
60
+ .select()
61
+ .from(productBookingQuestions)
62
+ .where(where)
63
+ .limit(query.limit)
64
+ .offset(query.offset)
65
+ .orderBy(asc(productBookingQuestions.sortOrder)), db.select({ count: sql `count(*)::int` }).from(productBookingQuestions).where(where), query.limit, query.offset);
66
+ }
67
+ export async function getProductBookingQuestionById(db, id) {
68
+ const [row] = await db
69
+ .select()
70
+ .from(productBookingQuestions)
71
+ .where(eq(productBookingQuestions.id, id))
72
+ .limit(1);
73
+ return row ?? null;
74
+ }
75
+ export async function createProductBookingQuestion(db, data) {
76
+ const [row] = await db.insert(productBookingQuestions).values(data).returning();
77
+ return row ?? null;
78
+ }
79
+ export async function updateProductBookingQuestion(db, id, data) {
80
+ const [row] = await db
81
+ .update(productBookingQuestions)
82
+ .set({ ...data, updatedAt: new Date() })
83
+ .where(eq(productBookingQuestions.id, id))
84
+ .returning();
85
+ return row ?? null;
86
+ }
87
+ export async function deleteProductBookingQuestion(db, id) {
88
+ const [row] = await db
89
+ .delete(productBookingQuestions)
90
+ .where(eq(productBookingQuestions.id, id))
91
+ .returning({ id: productBookingQuestions.id });
92
+ return row ?? null;
93
+ }
94
+ export async function listOptionBookingQuestions(db, query) {
95
+ const conditions = [];
96
+ if (query.optionId)
97
+ conditions.push(eq(optionBookingQuestions.optionId, query.optionId));
98
+ if (query.productBookingQuestionId)
99
+ conditions.push(eq(optionBookingQuestions.productBookingQuestionId, query.productBookingQuestionId));
100
+ if (query.active !== undefined)
101
+ conditions.push(eq(optionBookingQuestions.active, query.active));
102
+ const where = conditions.length ? and(...conditions) : undefined;
103
+ return paginate(db
104
+ .select()
105
+ .from(optionBookingQuestions)
106
+ .where(where)
107
+ .limit(query.limit)
108
+ .offset(query.offset)
109
+ .orderBy(asc(optionBookingQuestions.sortOrder)), db.select({ count: sql `count(*)::int` }).from(optionBookingQuestions).where(where), query.limit, query.offset);
110
+ }
111
+ export async function getOptionBookingQuestionById(db, id) {
112
+ const [row] = await db
113
+ .select()
114
+ .from(optionBookingQuestions)
115
+ .where(eq(optionBookingQuestions.id, id))
116
+ .limit(1);
117
+ return row ?? null;
118
+ }
119
+ export async function createOptionBookingQuestion(db, data) {
120
+ const [row] = await db.insert(optionBookingQuestions).values(data).returning();
121
+ return row ?? null;
122
+ }
123
+ export async function updateOptionBookingQuestion(db, id, data) {
124
+ const [row] = await db
125
+ .update(optionBookingQuestions)
126
+ .set({ ...data, updatedAt: new Date() })
127
+ .where(eq(optionBookingQuestions.id, id))
128
+ .returning();
129
+ return row ?? null;
130
+ }
131
+ export async function deleteOptionBookingQuestion(db, id) {
132
+ const [row] = await db
133
+ .delete(optionBookingQuestions)
134
+ .where(eq(optionBookingQuestions.id, id))
135
+ .returning({ id: optionBookingQuestions.id });
136
+ return row ?? null;
137
+ }
138
+ export async function listBookingQuestionOptions(db, query) {
139
+ const conditions = [];
140
+ if (query.productBookingQuestionId)
141
+ conditions.push(eq(bookingQuestionOptions.productBookingQuestionId, query.productBookingQuestionId));
142
+ if (query.active !== undefined)
143
+ conditions.push(eq(bookingQuestionOptions.active, query.active));
144
+ const where = conditions.length ? and(...conditions) : undefined;
145
+ return paginate(db
146
+ .select()
147
+ .from(bookingQuestionOptions)
148
+ .where(where)
149
+ .limit(query.limit)
150
+ .offset(query.offset)
151
+ .orderBy(asc(bookingQuestionOptions.sortOrder)), db.select({ count: sql `count(*)::int` }).from(bookingQuestionOptions).where(where), query.limit, query.offset);
152
+ }
153
+ export async function getBookingQuestionOptionById(db, id) {
154
+ const [row] = await db
155
+ .select()
156
+ .from(bookingQuestionOptions)
157
+ .where(eq(bookingQuestionOptions.id, id))
158
+ .limit(1);
159
+ return row ?? null;
160
+ }
161
+ export async function createBookingQuestionOption(db, data) {
162
+ const [row] = await db.insert(bookingQuestionOptions).values(data).returning();
163
+ return row ?? null;
164
+ }
165
+ export async function updateBookingQuestionOption(db, id, data) {
166
+ const [row] = await db
167
+ .update(bookingQuestionOptions)
168
+ .set({ ...data, updatedAt: new Date() })
169
+ .where(eq(bookingQuestionOptions.id, id))
170
+ .returning();
171
+ return row ?? null;
172
+ }
173
+ export async function deleteBookingQuestionOption(db, id) {
174
+ const [row] = await db
175
+ .delete(bookingQuestionOptions)
176
+ .where(eq(bookingQuestionOptions.id, id))
177
+ .returning({ id: bookingQuestionOptions.id });
178
+ return row ?? null;
179
+ }
180
+ export async function listBookingQuestionUnitTriggers(db, query) {
181
+ const conditions = [];
182
+ if (query.productBookingQuestionId)
183
+ conditions.push(eq(bookingQuestionUnitTriggers.productBookingQuestionId, query.productBookingQuestionId));
184
+ if (query.unitId)
185
+ conditions.push(eq(bookingQuestionUnitTriggers.unitId, query.unitId));
186
+ if (query.active !== undefined)
187
+ conditions.push(eq(bookingQuestionUnitTriggers.active, query.active));
188
+ const where = conditions.length ? and(...conditions) : undefined;
189
+ return paginate(db
190
+ .select()
191
+ .from(bookingQuestionUnitTriggers)
192
+ .where(where)
193
+ .limit(query.limit)
194
+ .offset(query.offset)
195
+ .orderBy(desc(bookingQuestionUnitTriggers.createdAt)), db.select({ count: sql `count(*)::int` }).from(bookingQuestionUnitTriggers).where(where), query.limit, query.offset);
196
+ }
197
+ export async function getBookingQuestionUnitTriggerById(db, id) {
198
+ const [row] = await db
199
+ .select()
200
+ .from(bookingQuestionUnitTriggers)
201
+ .where(eq(bookingQuestionUnitTriggers.id, id))
202
+ .limit(1);
203
+ return row ?? null;
204
+ }
205
+ export async function createBookingQuestionUnitTrigger(db, data) {
206
+ const [row] = await db.insert(bookingQuestionUnitTriggers).values(data).returning();
207
+ return row ?? null;
208
+ }
209
+ export async function updateBookingQuestionUnitTrigger(db, id, data) {
210
+ const [row] = await db
211
+ .update(bookingQuestionUnitTriggers)
212
+ .set({ ...data, updatedAt: new Date() })
213
+ .where(eq(bookingQuestionUnitTriggers.id, id))
214
+ .returning();
215
+ return row ?? null;
216
+ }
217
+ export async function deleteBookingQuestionUnitTrigger(db, id) {
218
+ const [row] = await db
219
+ .delete(bookingQuestionUnitTriggers)
220
+ .where(eq(bookingQuestionUnitTriggers.id, id))
221
+ .returning({ id: bookingQuestionUnitTriggers.id });
222
+ return row ?? null;
223
+ }
224
+ export async function listBookingQuestionOptionTriggers(db, query) {
225
+ const conditions = [];
226
+ if (query.productBookingQuestionId)
227
+ conditions.push(eq(bookingQuestionOptionTriggers.productBookingQuestionId, query.productBookingQuestionId));
228
+ if (query.optionId)
229
+ conditions.push(eq(bookingQuestionOptionTriggers.optionId, query.optionId));
230
+ if (query.active !== undefined)
231
+ conditions.push(eq(bookingQuestionOptionTriggers.active, query.active));
232
+ const where = conditions.length ? and(...conditions) : undefined;
233
+ return paginate(db
234
+ .select()
235
+ .from(bookingQuestionOptionTriggers)
236
+ .where(where)
237
+ .limit(query.limit)
238
+ .offset(query.offset)
239
+ .orderBy(desc(bookingQuestionOptionTriggers.createdAt)), db
240
+ .select({ count: sql `count(*)::int` })
241
+ .from(bookingQuestionOptionTriggers)
242
+ .where(where), query.limit, query.offset);
243
+ }
244
+ export async function getBookingQuestionOptionTriggerById(db, id) {
245
+ const [row] = await db
246
+ .select()
247
+ .from(bookingQuestionOptionTriggers)
248
+ .where(eq(bookingQuestionOptionTriggers.id, id))
249
+ .limit(1);
250
+ return row ?? null;
251
+ }
252
+ export async function createBookingQuestionOptionTrigger(db, data) {
253
+ const [row] = await db.insert(bookingQuestionOptionTriggers).values(data).returning();
254
+ return row ?? null;
255
+ }
256
+ export async function updateBookingQuestionOptionTrigger(db, id, data) {
257
+ const [row] = await db
258
+ .update(bookingQuestionOptionTriggers)
259
+ .set({ ...data, updatedAt: new Date() })
260
+ .where(eq(bookingQuestionOptionTriggers.id, id))
261
+ .returning();
262
+ return row ?? null;
263
+ }
264
+ export async function deleteBookingQuestionOptionTrigger(db, id) {
265
+ const [row] = await db
266
+ .delete(bookingQuestionOptionTriggers)
267
+ .where(eq(bookingQuestionOptionTriggers.id, id))
268
+ .returning({ id: bookingQuestionOptionTriggers.id });
269
+ return row ?? null;
270
+ }
271
+ export async function listBookingQuestionExtraTriggers(db, query) {
272
+ const conditions = [];
273
+ if (query.productBookingQuestionId)
274
+ conditions.push(eq(bookingQuestionExtraTriggers.productBookingQuestionId, query.productBookingQuestionId));
275
+ if (query.productExtraId)
276
+ conditions.push(eq(bookingQuestionExtraTriggers.productExtraId, query.productExtraId));
277
+ if (query.optionExtraConfigId)
278
+ conditions.push(eq(bookingQuestionExtraTriggers.optionExtraConfigId, query.optionExtraConfigId));
279
+ if (query.active !== undefined)
280
+ conditions.push(eq(bookingQuestionExtraTriggers.active, query.active));
281
+ const where = conditions.length ? and(...conditions) : undefined;
282
+ return paginate(db
283
+ .select()
284
+ .from(bookingQuestionExtraTriggers)
285
+ .where(where)
286
+ .limit(query.limit)
287
+ .offset(query.offset)
288
+ .orderBy(desc(bookingQuestionExtraTriggers.createdAt)), db
289
+ .select({ count: sql `count(*)::int` })
290
+ .from(bookingQuestionExtraTriggers)
291
+ .where(where), query.limit, query.offset);
292
+ }
293
+ export async function getBookingQuestionExtraTriggerById(db, id) {
294
+ const [row] = await db
295
+ .select()
296
+ .from(bookingQuestionExtraTriggers)
297
+ .where(eq(bookingQuestionExtraTriggers.id, id))
298
+ .limit(1);
299
+ return row ?? null;
300
+ }
301
+ export async function createBookingQuestionExtraTrigger(db, data) {
302
+ const [row] = await db.insert(bookingQuestionExtraTriggers).values(data).returning();
303
+ return row ?? null;
304
+ }
305
+ export async function updateBookingQuestionExtraTrigger(db, id, data) {
306
+ const [row] = await db
307
+ .update(bookingQuestionExtraTriggers)
308
+ .set({ ...data, updatedAt: new Date() })
309
+ .where(eq(bookingQuestionExtraTriggers.id, id))
310
+ .returning();
311
+ return row ?? null;
312
+ }
313
+ export async function deleteBookingQuestionExtraTrigger(db, id) {
314
+ const [row] = await db
315
+ .delete(bookingQuestionExtraTriggers)
316
+ .where(eq(bookingQuestionExtraTriggers.id, id))
317
+ .returning({ id: bookingQuestionExtraTriggers.id });
318
+ return row ?? null;
319
+ }
@@ -0,0 +1,35 @@
1
+ import type { z } from "zod";
2
+ import type { bookingAnswerListQuerySchema, bookingQuestionExtraTriggerListQuerySchema, bookingQuestionOptionListQuerySchema, bookingQuestionOptionTriggerListQuerySchema, bookingQuestionUnitTriggerListQuerySchema, insertBookingAnswerSchema, insertBookingQuestionExtraTriggerSchema, insertBookingQuestionOptionSchema, insertBookingQuestionOptionTriggerSchema, insertBookingQuestionUnitTriggerSchema, insertOptionBookingQuestionSchema, insertProductBookingQuestionSchema, insertProductContactRequirementSchema, optionBookingQuestionListQuerySchema, productBookingQuestionListQuerySchema, productContactRequirementListQuerySchema, updateBookingAnswerSchema, updateBookingQuestionExtraTriggerSchema, updateBookingQuestionOptionSchema, updateBookingQuestionOptionTriggerSchema, updateBookingQuestionUnitTriggerSchema, updateOptionBookingQuestionSchema, updateProductBookingQuestionSchema, updateProductContactRequirementSchema } from "./validation.js";
3
+ export type ProductContactRequirementListQuery = z.infer<typeof productContactRequirementListQuerySchema>;
4
+ export type ProductBookingQuestionListQuery = z.infer<typeof productBookingQuestionListQuerySchema>;
5
+ export type OptionBookingQuestionListQuery = z.infer<typeof optionBookingQuestionListQuerySchema>;
6
+ export type BookingQuestionOptionListQuery = z.infer<typeof bookingQuestionOptionListQuerySchema>;
7
+ export type BookingQuestionUnitTriggerListQuery = z.infer<typeof bookingQuestionUnitTriggerListQuerySchema>;
8
+ export type BookingQuestionOptionTriggerListQuery = z.infer<typeof bookingQuestionOptionTriggerListQuerySchema>;
9
+ export type BookingQuestionExtraTriggerListQuery = z.infer<typeof bookingQuestionExtraTriggerListQuerySchema>;
10
+ export type BookingAnswerListQuery = z.infer<typeof bookingAnswerListQuerySchema>;
11
+ export type CreateProductContactRequirementInput = z.infer<typeof insertProductContactRequirementSchema>;
12
+ export type UpdateProductContactRequirementInput = z.infer<typeof updateProductContactRequirementSchema>;
13
+ export type CreateProductBookingQuestionInput = z.infer<typeof insertProductBookingQuestionSchema>;
14
+ export type UpdateProductBookingQuestionInput = z.infer<typeof updateProductBookingQuestionSchema>;
15
+ export type CreateOptionBookingQuestionInput = z.infer<typeof insertOptionBookingQuestionSchema>;
16
+ export type UpdateOptionBookingQuestionInput = z.infer<typeof updateOptionBookingQuestionSchema>;
17
+ export type CreateBookingQuestionOptionInput = z.infer<typeof insertBookingQuestionOptionSchema>;
18
+ export type UpdateBookingQuestionOptionInput = z.infer<typeof updateBookingQuestionOptionSchema>;
19
+ export type CreateBookingQuestionUnitTriggerInput = z.infer<typeof insertBookingQuestionUnitTriggerSchema>;
20
+ export type UpdateBookingQuestionUnitTriggerInput = z.infer<typeof updateBookingQuestionUnitTriggerSchema>;
21
+ export type CreateBookingQuestionOptionTriggerInput = z.infer<typeof insertBookingQuestionOptionTriggerSchema>;
22
+ export type UpdateBookingQuestionOptionTriggerInput = z.infer<typeof updateBookingQuestionOptionTriggerSchema>;
23
+ export type CreateBookingQuestionExtraTriggerInput = z.infer<typeof insertBookingQuestionExtraTriggerSchema>;
24
+ export type UpdateBookingQuestionExtraTriggerInput = z.infer<typeof updateBookingQuestionExtraTriggerSchema>;
25
+ export type CreateBookingAnswerInput = z.infer<typeof insertBookingAnswerSchema>;
26
+ export type UpdateBookingAnswerInput = z.infer<typeof updateBookingAnswerSchema>;
27
+ export declare function paginate<T extends object>(rowsQuery: Promise<T[]>, countQuery: Promise<Array<{
28
+ count: number;
29
+ }>>, limit: number, offset: number): Promise<{
30
+ data: T[];
31
+ total: number;
32
+ limit: number;
33
+ offset: number;
34
+ }>;
35
+ //# sourceMappingURL=service-shared.d.ts.map
@@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AAwB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,yBAAyB,CAAC,CAAA;AAEhF,wBAAsB,QAAQ,CAAC,CAAC,SAAS,MAAM,EAC7C,SAAS,EAAE,OAAO,CAAC,CAAC,EAAE,CAAC,EACvB,UAAU,EAAE,OAAO,CAAC,KAAK,CAAC;IAAE,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC,CAAC,EAC7C,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM;;;;;GAIf"}
@@ -0,0 +1,4 @@
1
+ export async function paginate(rowsQuery, countQuery, limit, offset) {
2
+ const [data, countResult] = await Promise.all([rowsQuery, countQuery]);
3
+ return { data, total: countResult[0]?.count ?? 0, limit, offset };
4
+ }