@voyantjs/availability 0.2.0 → 0.3.1
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/dist/routes-core.d.ts +851 -0
- package/dist/routes-core.d.ts.map +1 -0
- package/dist/routes-core.js +153 -0
- package/dist/routes-pickups.d.ts +1362 -0
- package/dist/routes-pickups.d.ts.map +1 -0
- package/dist/routes-pickups.js +264 -0
- package/dist/routes-shared.d.ts +49 -0
- package/dist/routes-shared.d.ts.map +1 -0
- package/dist/routes-shared.js +45 -0
- package/dist/routes.d.ts +3 -2216
- package/dist/routes.d.ts.map +1 -1
- package/dist/routes.js +5 -540
- package/dist/service-core.d.ts +291 -0
- package/dist/service-core.d.ts.map +1 -0
- package/dist/service-core.js +205 -0
- package/dist/service-pickups.d.ts +407 -0
- package/dist/service-pickups.d.ts.map +1 -0
- package/dist/service-pickups.js +308 -0
- package/dist/service-shared.d.ts +45 -0
- package/dist/service-shared.d.ts.map +1 -0
- package/dist/service-shared.js +12 -0
- package/dist/service.d.ts +57 -729
- package/dist/service.d.ts.map +1 -1
- package/dist/service.js +57 -517
- package/package.json +5 -5
package/dist/service.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../src/service.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../src/service.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EACd,UAAU,EACV,UAAU,EACV,eAAe,EACf,cAAc,EACd,UAAU,EACV,UAAU,EACV,eAAe,EACf,eAAe,EACf,WAAW,EACX,WAAW,EACX,gBAAgB,EAChB,aAAa,EACb,SAAS,EACT,SAAS,EACT,cAAc,EACd,cAAc,EACd,UAAU,EACV,UAAU,EACV,eAAe,EAChB,MAAM,mBAAmB,CAAA;AAC1B,OAAO,EACL,sBAAsB,EACtB,wBAAwB,EACxB,mBAAmB,EACnB,iBAAiB,EACjB,oBAAoB,EACpB,iBAAiB,EACjB,gBAAgB,EAChB,sBAAsB,EACtB,wBAAwB,EACxB,mBAAmB,EACnB,iBAAiB,EACjB,oBAAoB,EACpB,iBAAiB,EACjB,gBAAgB,EAChB,uBAAuB,EACvB,yBAAyB,EACzB,oBAAoB,EACpB,kBAAkB,EAClB,qBAAqB,EACrB,kBAAkB,EAClB,iBAAiB,EACjB,qBAAqB,EACrB,uBAAuB,EACvB,kBAAkB,EAClB,gBAAgB,EAChB,mBAAmB,EACnB,gBAAgB,EAChB,eAAe,EACf,sBAAsB,EACtB,wBAAwB,EACxB,mBAAmB,EACnB,iBAAiB,EACjB,oBAAoB,EACpB,iBAAiB,EACjB,gBAAgB,EACjB,MAAM,sBAAsB,CAAA;AAE7B,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAwD/B,CAAA"}
|
package/dist/service.js
CHANGED
|
@@ -1,519 +1,59 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
async function paginate(rowsQuery, countQuery, limit, offset) {
|
|
4
|
-
const [data, countResult] = await Promise.all([rowsQuery, countQuery]);
|
|
5
|
-
return {
|
|
6
|
-
data,
|
|
7
|
-
total: countResult[0]?.count ?? 0,
|
|
8
|
-
limit,
|
|
9
|
-
offset,
|
|
10
|
-
};
|
|
11
|
-
}
|
|
12
|
-
function toDateOrNull(value) {
|
|
13
|
-
return value ? new Date(value) : null;
|
|
14
|
-
}
|
|
1
|
+
import { createCloseout, createRule, createSlot, createStartTime, deleteCloseout, deleteRule, deleteSlot, deleteStartTime, getCloseoutById, getRuleById, getSlotById, getStartTimeById, listCloseouts, listRules, listSlots, listStartTimes, updateCloseout, updateRule, updateSlot, updateStartTime, } from "./service-core.js";
|
|
2
|
+
import { createCustomPickupArea, createLocationPickupTime, createMeetingConfig, createPickupGroup, createPickupLocation, createPickupPoint, createSlotPickup, deleteCustomPickupArea, deleteLocationPickupTime, deleteMeetingConfig, deletePickupGroup, deletePickupLocation, deletePickupPoint, deleteSlotPickup, getCustomPickupAreaById, getLocationPickupTimeById, getMeetingConfigById, getPickupGroupById, getPickupLocationById, getPickupPointById, getSlotPickupById, listCustomPickupAreas, listLocationPickupTimes, listMeetingConfigs, listPickupGroups, listPickupLocations, listPickupPoints, listSlotPickups, updateCustomPickupArea, updateLocationPickupTime, updateMeetingConfig, updatePickupGroup, updatePickupLocation, updatePickupPoint, updateSlotPickup, } from "./service-pickups.js";
|
|
15
3
|
export const availabilityService = {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
conditions.push(eq(availabilityStartTimes.active, query.active));
|
|
72
|
-
const where = conditions.length ? and(...conditions) : undefined;
|
|
73
|
-
return paginate(db
|
|
74
|
-
.select()
|
|
75
|
-
.from(availabilityStartTimes)
|
|
76
|
-
.where(where)
|
|
77
|
-
.limit(query.limit)
|
|
78
|
-
.offset(query.offset)
|
|
79
|
-
.orderBy(availabilityStartTimes.sortOrder, availabilityStartTimes.createdAt), db.select({ count: sql `count(*)::int` }).from(availabilityStartTimes).where(where), query.limit, query.offset);
|
|
80
|
-
},
|
|
81
|
-
async getStartTimeById(db, id) {
|
|
82
|
-
const [row] = await db
|
|
83
|
-
.select()
|
|
84
|
-
.from(availabilityStartTimes)
|
|
85
|
-
.where(eq(availabilityStartTimes.id, id))
|
|
86
|
-
.limit(1);
|
|
87
|
-
return row ?? null;
|
|
88
|
-
},
|
|
89
|
-
async createStartTime(db, data) {
|
|
90
|
-
const [row] = await db.insert(availabilityStartTimes).values(data).returning();
|
|
91
|
-
return row;
|
|
92
|
-
},
|
|
93
|
-
async updateStartTime(db, id, data) {
|
|
94
|
-
const [row] = await db
|
|
95
|
-
.update(availabilityStartTimes)
|
|
96
|
-
.set({ ...data, updatedAt: new Date() })
|
|
97
|
-
.where(eq(availabilityStartTimes.id, id))
|
|
98
|
-
.returning();
|
|
99
|
-
return row ?? null;
|
|
100
|
-
},
|
|
101
|
-
async deleteStartTime(db, id) {
|
|
102
|
-
const [row] = await db
|
|
103
|
-
.delete(availabilityStartTimes)
|
|
104
|
-
.where(eq(availabilityStartTimes.id, id))
|
|
105
|
-
.returning({ id: availabilityStartTimes.id });
|
|
106
|
-
return row ?? null;
|
|
107
|
-
},
|
|
108
|
-
async listSlots(db, query) {
|
|
109
|
-
const conditions = [];
|
|
110
|
-
if (query.productId)
|
|
111
|
-
conditions.push(eq(availabilitySlots.productId, query.productId));
|
|
112
|
-
if (query.optionId)
|
|
113
|
-
conditions.push(eq(availabilitySlots.optionId, query.optionId));
|
|
114
|
-
if (query.facilityId)
|
|
115
|
-
conditions.push(eq(availabilitySlots.facilityId, query.facilityId));
|
|
116
|
-
if (query.availabilityRuleId)
|
|
117
|
-
conditions.push(eq(availabilitySlots.availabilityRuleId, query.availabilityRuleId));
|
|
118
|
-
if (query.startTimeId)
|
|
119
|
-
conditions.push(eq(availabilitySlots.startTimeId, query.startTimeId));
|
|
120
|
-
if (query.dateLocal)
|
|
121
|
-
conditions.push(eq(availabilitySlots.dateLocal, query.dateLocal));
|
|
122
|
-
if (query.status)
|
|
123
|
-
conditions.push(eq(availabilitySlots.status, query.status));
|
|
124
|
-
const where = conditions.length ? and(...conditions) : undefined;
|
|
125
|
-
return paginate(db
|
|
126
|
-
.select()
|
|
127
|
-
.from(availabilitySlots)
|
|
128
|
-
.where(where)
|
|
129
|
-
.limit(query.limit)
|
|
130
|
-
.offset(query.offset)
|
|
131
|
-
.orderBy(asc(availabilitySlots.startsAt)), db.select({ count: sql `count(*)::int` }).from(availabilitySlots).where(where), query.limit, query.offset);
|
|
132
|
-
},
|
|
133
|
-
async getSlotById(db, id) {
|
|
134
|
-
const [row] = await db
|
|
135
|
-
.select()
|
|
136
|
-
.from(availabilitySlots)
|
|
137
|
-
.where(eq(availabilitySlots.id, id))
|
|
138
|
-
.limit(1);
|
|
139
|
-
return row ?? null;
|
|
140
|
-
},
|
|
141
|
-
async createSlot(db, data) {
|
|
142
|
-
const [row] = await db
|
|
143
|
-
.insert(availabilitySlots)
|
|
144
|
-
.values({
|
|
145
|
-
...data,
|
|
146
|
-
startsAt: new Date(data.startsAt),
|
|
147
|
-
endsAt: toDateOrNull(data.endsAt),
|
|
148
|
-
})
|
|
149
|
-
.returning();
|
|
150
|
-
return row;
|
|
151
|
-
},
|
|
152
|
-
async updateSlot(db, id, data) {
|
|
153
|
-
const patch = {
|
|
154
|
-
...data,
|
|
155
|
-
startsAt: data.startsAt === undefined ? undefined : new Date(data.startsAt),
|
|
156
|
-
endsAt: data.endsAt === undefined ? undefined : toDateOrNull(data.endsAt),
|
|
157
|
-
updatedAt: new Date(),
|
|
158
|
-
};
|
|
159
|
-
const [row] = await db
|
|
160
|
-
.update(availabilitySlots)
|
|
161
|
-
.set(patch)
|
|
162
|
-
.where(eq(availabilitySlots.id, id))
|
|
163
|
-
.returning();
|
|
164
|
-
return row ?? null;
|
|
165
|
-
},
|
|
166
|
-
async deleteSlot(db, id) {
|
|
167
|
-
const [row] = await db
|
|
168
|
-
.delete(availabilitySlots)
|
|
169
|
-
.where(eq(availabilitySlots.id, id))
|
|
170
|
-
.returning({ id: availabilitySlots.id });
|
|
171
|
-
return row ?? null;
|
|
172
|
-
},
|
|
173
|
-
async listCloseouts(db, query) {
|
|
174
|
-
const conditions = [];
|
|
175
|
-
if (query.productId)
|
|
176
|
-
conditions.push(eq(availabilityCloseouts.productId, query.productId));
|
|
177
|
-
if (query.slotId)
|
|
178
|
-
conditions.push(eq(availabilityCloseouts.slotId, query.slotId));
|
|
179
|
-
if (query.dateLocal)
|
|
180
|
-
conditions.push(eq(availabilityCloseouts.dateLocal, query.dateLocal));
|
|
181
|
-
const where = conditions.length ? and(...conditions) : undefined;
|
|
182
|
-
return paginate(db
|
|
183
|
-
.select()
|
|
184
|
-
.from(availabilityCloseouts)
|
|
185
|
-
.where(where)
|
|
186
|
-
.limit(query.limit)
|
|
187
|
-
.offset(query.offset)
|
|
188
|
-
.orderBy(desc(availabilityCloseouts.createdAt)), db.select({ count: sql `count(*)::int` }).from(availabilityCloseouts).where(where), query.limit, query.offset);
|
|
189
|
-
},
|
|
190
|
-
async getCloseoutById(db, id) {
|
|
191
|
-
const [row] = await db
|
|
192
|
-
.select()
|
|
193
|
-
.from(availabilityCloseouts)
|
|
194
|
-
.where(eq(availabilityCloseouts.id, id))
|
|
195
|
-
.limit(1);
|
|
196
|
-
return row ?? null;
|
|
197
|
-
},
|
|
198
|
-
async createCloseout(db, data) {
|
|
199
|
-
const [row] = await db.insert(availabilityCloseouts).values(data).returning();
|
|
200
|
-
return row;
|
|
201
|
-
},
|
|
202
|
-
async updateCloseout(db, id, data) {
|
|
203
|
-
const [row] = await db
|
|
204
|
-
.update(availabilityCloseouts)
|
|
205
|
-
.set(data)
|
|
206
|
-
.where(eq(availabilityCloseouts.id, id))
|
|
207
|
-
.returning();
|
|
208
|
-
return row ?? null;
|
|
209
|
-
},
|
|
210
|
-
async deleteCloseout(db, id) {
|
|
211
|
-
const [row] = await db
|
|
212
|
-
.delete(availabilityCloseouts)
|
|
213
|
-
.where(eq(availabilityCloseouts.id, id))
|
|
214
|
-
.returning({ id: availabilityCloseouts.id });
|
|
215
|
-
return row ?? null;
|
|
216
|
-
},
|
|
217
|
-
async listPickupPoints(db, query) {
|
|
218
|
-
const conditions = [];
|
|
219
|
-
if (query.productId)
|
|
220
|
-
conditions.push(eq(availabilityPickupPoints.productId, query.productId));
|
|
221
|
-
if (query.facilityId)
|
|
222
|
-
conditions.push(eq(availabilityPickupPoints.facilityId, query.facilityId));
|
|
223
|
-
if (query.active !== undefined)
|
|
224
|
-
conditions.push(eq(availabilityPickupPoints.active, query.active));
|
|
225
|
-
const where = conditions.length ? and(...conditions) : undefined;
|
|
226
|
-
return paginate(db
|
|
227
|
-
.select()
|
|
228
|
-
.from(availabilityPickupPoints)
|
|
229
|
-
.where(where)
|
|
230
|
-
.limit(query.limit)
|
|
231
|
-
.offset(query.offset)
|
|
232
|
-
.orderBy(availabilityPickupPoints.createdAt), db.select({ count: sql `count(*)::int` }).from(availabilityPickupPoints).where(where), query.limit, query.offset);
|
|
233
|
-
},
|
|
234
|
-
async getPickupPointById(db, id) {
|
|
235
|
-
const [row] = await db
|
|
236
|
-
.select()
|
|
237
|
-
.from(availabilityPickupPoints)
|
|
238
|
-
.where(eq(availabilityPickupPoints.id, id))
|
|
239
|
-
.limit(1);
|
|
240
|
-
return row ?? null;
|
|
241
|
-
},
|
|
242
|
-
async createPickupPoint(db, data) {
|
|
243
|
-
const [row] = await db.insert(availabilityPickupPoints).values(data).returning();
|
|
244
|
-
return row;
|
|
245
|
-
},
|
|
246
|
-
async updatePickupPoint(db, id, data) {
|
|
247
|
-
const [row] = await db
|
|
248
|
-
.update(availabilityPickupPoints)
|
|
249
|
-
.set({ ...data, updatedAt: new Date() })
|
|
250
|
-
.where(eq(availabilityPickupPoints.id, id))
|
|
251
|
-
.returning();
|
|
252
|
-
return row ?? null;
|
|
253
|
-
},
|
|
254
|
-
async deletePickupPoint(db, id) {
|
|
255
|
-
const [row] = await db
|
|
256
|
-
.delete(availabilityPickupPoints)
|
|
257
|
-
.where(eq(availabilityPickupPoints.id, id))
|
|
258
|
-
.returning({ id: availabilityPickupPoints.id });
|
|
259
|
-
return row ?? null;
|
|
260
|
-
},
|
|
261
|
-
async listSlotPickups(db, query) {
|
|
262
|
-
const conditions = [];
|
|
263
|
-
if (query.slotId)
|
|
264
|
-
conditions.push(eq(availabilitySlotPickups.slotId, query.slotId));
|
|
265
|
-
if (query.pickupPointId)
|
|
266
|
-
conditions.push(eq(availabilitySlotPickups.pickupPointId, query.pickupPointId));
|
|
267
|
-
const where = conditions.length ? and(...conditions) : undefined;
|
|
268
|
-
return paginate(db
|
|
269
|
-
.select()
|
|
270
|
-
.from(availabilitySlotPickups)
|
|
271
|
-
.where(where)
|
|
272
|
-
.limit(query.limit)
|
|
273
|
-
.offset(query.offset)
|
|
274
|
-
.orderBy(availabilitySlotPickups.createdAt), db.select({ count: sql `count(*)::int` }).from(availabilitySlotPickups).where(where), query.limit, query.offset);
|
|
275
|
-
},
|
|
276
|
-
async getSlotPickupById(db, id) {
|
|
277
|
-
const [row] = await db
|
|
278
|
-
.select()
|
|
279
|
-
.from(availabilitySlotPickups)
|
|
280
|
-
.where(eq(availabilitySlotPickups.id, id))
|
|
281
|
-
.limit(1);
|
|
282
|
-
return row ?? null;
|
|
283
|
-
},
|
|
284
|
-
async createSlotPickup(db, data) {
|
|
285
|
-
const [row] = await db.insert(availabilitySlotPickups).values(data).returning();
|
|
286
|
-
return row;
|
|
287
|
-
},
|
|
288
|
-
async updateSlotPickup(db, id, data) {
|
|
289
|
-
const [row] = await db
|
|
290
|
-
.update(availabilitySlotPickups)
|
|
291
|
-
.set({ ...data, updatedAt: new Date() })
|
|
292
|
-
.where(eq(availabilitySlotPickups.id, id))
|
|
293
|
-
.returning();
|
|
294
|
-
return row ?? null;
|
|
295
|
-
},
|
|
296
|
-
async deleteSlotPickup(db, id) {
|
|
297
|
-
const [row] = await db
|
|
298
|
-
.delete(availabilitySlotPickups)
|
|
299
|
-
.where(eq(availabilitySlotPickups.id, id))
|
|
300
|
-
.returning({ id: availabilitySlotPickups.id });
|
|
301
|
-
return row ?? null;
|
|
302
|
-
},
|
|
303
|
-
async listMeetingConfigs(db, query) {
|
|
304
|
-
const conditions = [];
|
|
305
|
-
if (query.productId)
|
|
306
|
-
conditions.push(eq(productMeetingConfigs.productId, query.productId));
|
|
307
|
-
if (query.optionId)
|
|
308
|
-
conditions.push(eq(productMeetingConfigs.optionId, query.optionId));
|
|
309
|
-
if (query.facilityId)
|
|
310
|
-
conditions.push(eq(productMeetingConfigs.facilityId, query.facilityId));
|
|
311
|
-
if (query.mode)
|
|
312
|
-
conditions.push(eq(productMeetingConfigs.mode, query.mode));
|
|
313
|
-
if (query.active !== undefined)
|
|
314
|
-
conditions.push(eq(productMeetingConfigs.active, query.active));
|
|
315
|
-
const where = conditions.length ? and(...conditions) : undefined;
|
|
316
|
-
return paginate(db
|
|
317
|
-
.select()
|
|
318
|
-
.from(productMeetingConfigs)
|
|
319
|
-
.where(where)
|
|
320
|
-
.limit(query.limit)
|
|
321
|
-
.offset(query.offset)
|
|
322
|
-
.orderBy(desc(productMeetingConfigs.updatedAt)), db.select({ count: sql `count(*)::int` }).from(productMeetingConfigs).where(where), query.limit, query.offset);
|
|
323
|
-
},
|
|
324
|
-
async getMeetingConfigById(db, id) {
|
|
325
|
-
const [row] = await db
|
|
326
|
-
.select()
|
|
327
|
-
.from(productMeetingConfigs)
|
|
328
|
-
.where(eq(productMeetingConfigs.id, id))
|
|
329
|
-
.limit(1);
|
|
330
|
-
return row ?? null;
|
|
331
|
-
},
|
|
332
|
-
async createMeetingConfig(db, data) {
|
|
333
|
-
const [row] = await db.insert(productMeetingConfigs).values(data).returning();
|
|
334
|
-
return row;
|
|
335
|
-
},
|
|
336
|
-
async updateMeetingConfig(db, id, data) {
|
|
337
|
-
const [row] = await db
|
|
338
|
-
.update(productMeetingConfigs)
|
|
339
|
-
.set({ ...data, updatedAt: new Date() })
|
|
340
|
-
.where(eq(productMeetingConfigs.id, id))
|
|
341
|
-
.returning();
|
|
342
|
-
return row ?? null;
|
|
343
|
-
},
|
|
344
|
-
async deleteMeetingConfig(db, id) {
|
|
345
|
-
const [row] = await db
|
|
346
|
-
.delete(productMeetingConfigs)
|
|
347
|
-
.where(eq(productMeetingConfigs.id, id))
|
|
348
|
-
.returning({ id: productMeetingConfigs.id });
|
|
349
|
-
return row ?? null;
|
|
350
|
-
},
|
|
351
|
-
async listPickupGroups(db, query) {
|
|
352
|
-
const conditions = [];
|
|
353
|
-
if (query.meetingConfigId)
|
|
354
|
-
conditions.push(eq(pickupGroups.meetingConfigId, query.meetingConfigId));
|
|
355
|
-
if (query.kind)
|
|
356
|
-
conditions.push(eq(pickupGroups.kind, query.kind));
|
|
357
|
-
if (query.active !== undefined)
|
|
358
|
-
conditions.push(eq(pickupGroups.active, query.active));
|
|
359
|
-
const where = conditions.length ? and(...conditions) : undefined;
|
|
360
|
-
return paginate(db
|
|
361
|
-
.select()
|
|
362
|
-
.from(pickupGroups)
|
|
363
|
-
.where(where)
|
|
364
|
-
.limit(query.limit)
|
|
365
|
-
.offset(query.offset)
|
|
366
|
-
.orderBy(asc(pickupGroups.sortOrder), pickupGroups.createdAt), db.select({ count: sql `count(*)::int` }).from(pickupGroups).where(where), query.limit, query.offset);
|
|
367
|
-
},
|
|
368
|
-
async getPickupGroupById(db, id) {
|
|
369
|
-
const [row] = await db.select().from(pickupGroups).where(eq(pickupGroups.id, id)).limit(1);
|
|
370
|
-
return row ?? null;
|
|
371
|
-
},
|
|
372
|
-
async createPickupGroup(db, data) {
|
|
373
|
-
const [row] = await db.insert(pickupGroups).values(data).returning();
|
|
374
|
-
return row;
|
|
375
|
-
},
|
|
376
|
-
async updatePickupGroup(db, id, data) {
|
|
377
|
-
const [row] = await db
|
|
378
|
-
.update(pickupGroups)
|
|
379
|
-
.set({ ...data, updatedAt: new Date() })
|
|
380
|
-
.where(eq(pickupGroups.id, id))
|
|
381
|
-
.returning();
|
|
382
|
-
return row ?? null;
|
|
383
|
-
},
|
|
384
|
-
async deletePickupGroup(db, id) {
|
|
385
|
-
const [row] = await db
|
|
386
|
-
.delete(pickupGroups)
|
|
387
|
-
.where(eq(pickupGroups.id, id))
|
|
388
|
-
.returning({ id: pickupGroups.id });
|
|
389
|
-
return row ?? null;
|
|
390
|
-
},
|
|
391
|
-
async listPickupLocations(db, query) {
|
|
392
|
-
const conditions = [];
|
|
393
|
-
if (query.groupId)
|
|
394
|
-
conditions.push(eq(pickupLocations.groupId, query.groupId));
|
|
395
|
-
if (query.facilityId)
|
|
396
|
-
conditions.push(eq(pickupLocations.facilityId, query.facilityId));
|
|
397
|
-
if (query.active !== undefined)
|
|
398
|
-
conditions.push(eq(pickupLocations.active, query.active));
|
|
399
|
-
const where = conditions.length ? and(...conditions) : undefined;
|
|
400
|
-
return paginate(db
|
|
401
|
-
.select()
|
|
402
|
-
.from(pickupLocations)
|
|
403
|
-
.where(where)
|
|
404
|
-
.limit(query.limit)
|
|
405
|
-
.offset(query.offset)
|
|
406
|
-
.orderBy(asc(pickupLocations.sortOrder), pickupLocations.createdAt), db.select({ count: sql `count(*)::int` }).from(pickupLocations).where(where), query.limit, query.offset);
|
|
407
|
-
},
|
|
408
|
-
async getPickupLocationById(db, id) {
|
|
409
|
-
const [row] = await db.select().from(pickupLocations).where(eq(pickupLocations.id, id)).limit(1);
|
|
410
|
-
return row ?? null;
|
|
411
|
-
},
|
|
412
|
-
async createPickupLocation(db, data) {
|
|
413
|
-
const [row] = await db.insert(pickupLocations).values(data).returning();
|
|
414
|
-
return row;
|
|
415
|
-
},
|
|
416
|
-
async updatePickupLocation(db, id, data) {
|
|
417
|
-
const [row] = await db
|
|
418
|
-
.update(pickupLocations)
|
|
419
|
-
.set({ ...data, updatedAt: new Date() })
|
|
420
|
-
.where(eq(pickupLocations.id, id))
|
|
421
|
-
.returning();
|
|
422
|
-
return row ?? null;
|
|
423
|
-
},
|
|
424
|
-
async deletePickupLocation(db, id) {
|
|
425
|
-
const [row] = await db
|
|
426
|
-
.delete(pickupLocations)
|
|
427
|
-
.where(eq(pickupLocations.id, id))
|
|
428
|
-
.returning({ id: pickupLocations.id });
|
|
429
|
-
return row ?? null;
|
|
430
|
-
},
|
|
431
|
-
async listLocationPickupTimes(db, query) {
|
|
432
|
-
const conditions = [];
|
|
433
|
-
if (query.pickupLocationId)
|
|
434
|
-
conditions.push(eq(locationPickupTimes.pickupLocationId, query.pickupLocationId));
|
|
435
|
-
if (query.slotId)
|
|
436
|
-
conditions.push(eq(locationPickupTimes.slotId, query.slotId));
|
|
437
|
-
if (query.startTimeId)
|
|
438
|
-
conditions.push(eq(locationPickupTimes.startTimeId, query.startTimeId));
|
|
439
|
-
if (query.active !== undefined)
|
|
440
|
-
conditions.push(eq(locationPickupTimes.active, query.active));
|
|
441
|
-
const where = conditions.length ? and(...conditions) : undefined;
|
|
442
|
-
return paginate(db
|
|
443
|
-
.select()
|
|
444
|
-
.from(locationPickupTimes)
|
|
445
|
-
.where(where)
|
|
446
|
-
.limit(query.limit)
|
|
447
|
-
.offset(query.offset)
|
|
448
|
-
.orderBy(locationPickupTimes.createdAt), db.select({ count: sql `count(*)::int` }).from(locationPickupTimes).where(where), query.limit, query.offset);
|
|
449
|
-
},
|
|
450
|
-
async getLocationPickupTimeById(db, id) {
|
|
451
|
-
const [row] = await db
|
|
452
|
-
.select()
|
|
453
|
-
.from(locationPickupTimes)
|
|
454
|
-
.where(eq(locationPickupTimes.id, id))
|
|
455
|
-
.limit(1);
|
|
456
|
-
return row ?? null;
|
|
457
|
-
},
|
|
458
|
-
async createLocationPickupTime(db, data) {
|
|
459
|
-
const [row] = await db.insert(locationPickupTimes).values(data).returning();
|
|
460
|
-
return row;
|
|
461
|
-
},
|
|
462
|
-
async updateLocationPickupTime(db, id, data) {
|
|
463
|
-
const [row] = await db
|
|
464
|
-
.update(locationPickupTimes)
|
|
465
|
-
.set({ ...data, updatedAt: new Date() })
|
|
466
|
-
.where(eq(locationPickupTimes.id, id))
|
|
467
|
-
.returning();
|
|
468
|
-
return row ?? null;
|
|
469
|
-
},
|
|
470
|
-
async deleteLocationPickupTime(db, id) {
|
|
471
|
-
const [row] = await db
|
|
472
|
-
.delete(locationPickupTimes)
|
|
473
|
-
.where(eq(locationPickupTimes.id, id))
|
|
474
|
-
.returning({ id: locationPickupTimes.id });
|
|
475
|
-
return row ?? null;
|
|
476
|
-
},
|
|
477
|
-
async listCustomPickupAreas(db, query) {
|
|
478
|
-
const conditions = [];
|
|
479
|
-
if (query.meetingConfigId)
|
|
480
|
-
conditions.push(eq(customPickupAreas.meetingConfigId, query.meetingConfigId));
|
|
481
|
-
if (query.active !== undefined)
|
|
482
|
-
conditions.push(eq(customPickupAreas.active, query.active));
|
|
483
|
-
const where = conditions.length ? and(...conditions) : undefined;
|
|
484
|
-
return paginate(db
|
|
485
|
-
.select()
|
|
486
|
-
.from(customPickupAreas)
|
|
487
|
-
.where(where)
|
|
488
|
-
.limit(query.limit)
|
|
489
|
-
.offset(query.offset)
|
|
490
|
-
.orderBy(customPickupAreas.createdAt), db.select({ count: sql `count(*)::int` }).from(customPickupAreas).where(where), query.limit, query.offset);
|
|
491
|
-
},
|
|
492
|
-
async getCustomPickupAreaById(db, id) {
|
|
493
|
-
const [row] = await db
|
|
494
|
-
.select()
|
|
495
|
-
.from(customPickupAreas)
|
|
496
|
-
.where(eq(customPickupAreas.id, id))
|
|
497
|
-
.limit(1);
|
|
498
|
-
return row ?? null;
|
|
499
|
-
},
|
|
500
|
-
async createCustomPickupArea(db, data) {
|
|
501
|
-
const [row] = await db.insert(customPickupAreas).values(data).returning();
|
|
502
|
-
return row;
|
|
503
|
-
},
|
|
504
|
-
async updateCustomPickupArea(db, id, data) {
|
|
505
|
-
const [row] = await db
|
|
506
|
-
.update(customPickupAreas)
|
|
507
|
-
.set({ ...data, updatedAt: new Date() })
|
|
508
|
-
.where(eq(customPickupAreas.id, id))
|
|
509
|
-
.returning();
|
|
510
|
-
return row ?? null;
|
|
511
|
-
},
|
|
512
|
-
async deleteCustomPickupArea(db, id) {
|
|
513
|
-
const [row] = await db
|
|
514
|
-
.delete(customPickupAreas)
|
|
515
|
-
.where(eq(customPickupAreas.id, id))
|
|
516
|
-
.returning({ id: customPickupAreas.id });
|
|
517
|
-
return row ?? null;
|
|
518
|
-
},
|
|
4
|
+
listRules,
|
|
5
|
+
getRuleById,
|
|
6
|
+
createRule,
|
|
7
|
+
updateRule,
|
|
8
|
+
deleteRule,
|
|
9
|
+
listStartTimes,
|
|
10
|
+
getStartTimeById,
|
|
11
|
+
createStartTime,
|
|
12
|
+
updateStartTime,
|
|
13
|
+
deleteStartTime,
|
|
14
|
+
listSlots,
|
|
15
|
+
getSlotById,
|
|
16
|
+
createSlot,
|
|
17
|
+
updateSlot,
|
|
18
|
+
deleteSlot,
|
|
19
|
+
listCloseouts,
|
|
20
|
+
getCloseoutById,
|
|
21
|
+
createCloseout,
|
|
22
|
+
updateCloseout,
|
|
23
|
+
deleteCloseout,
|
|
24
|
+
listPickupPoints,
|
|
25
|
+
getPickupPointById,
|
|
26
|
+
createPickupPoint,
|
|
27
|
+
updatePickupPoint,
|
|
28
|
+
deletePickupPoint,
|
|
29
|
+
listSlotPickups,
|
|
30
|
+
getSlotPickupById,
|
|
31
|
+
createSlotPickup,
|
|
32
|
+
updateSlotPickup,
|
|
33
|
+
deleteSlotPickup,
|
|
34
|
+
listMeetingConfigs,
|
|
35
|
+
getMeetingConfigById,
|
|
36
|
+
createMeetingConfig,
|
|
37
|
+
updateMeetingConfig,
|
|
38
|
+
deleteMeetingConfig,
|
|
39
|
+
listPickupGroups,
|
|
40
|
+
getPickupGroupById,
|
|
41
|
+
createPickupGroup,
|
|
42
|
+
updatePickupGroup,
|
|
43
|
+
deletePickupGroup,
|
|
44
|
+
listPickupLocations,
|
|
45
|
+
getPickupLocationById,
|
|
46
|
+
createPickupLocation,
|
|
47
|
+
updatePickupLocation,
|
|
48
|
+
deletePickupLocation,
|
|
49
|
+
listLocationPickupTimes,
|
|
50
|
+
getLocationPickupTimeById,
|
|
51
|
+
createLocationPickupTime,
|
|
52
|
+
updateLocationPickupTime,
|
|
53
|
+
deleteLocationPickupTime,
|
|
54
|
+
listCustomPickupAreas,
|
|
55
|
+
getCustomPickupAreaById,
|
|
56
|
+
createCustomPickupArea,
|
|
57
|
+
updateCustomPickupArea,
|
|
58
|
+
deleteCustomPickupArea,
|
|
519
59
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@voyantjs/availability",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.1",
|
|
4
4
|
"license": "FSL-1.1-Apache-2.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -29,13 +29,13 @@
|
|
|
29
29
|
"drizzle-orm": "^0.45.2",
|
|
30
30
|
"hono": "^4.12.10",
|
|
31
31
|
"zod": "^4.3.6",
|
|
32
|
-
"@voyantjs/core": "0.
|
|
33
|
-
"@voyantjs/db": "0.
|
|
34
|
-
"@voyantjs/hono": "0.
|
|
32
|
+
"@voyantjs/core": "0.3.1",
|
|
33
|
+
"@voyantjs/db": "0.3.1",
|
|
34
|
+
"@voyantjs/hono": "0.3.1"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
37
|
"typescript": "^6.0.2",
|
|
38
|
-
"@voyantjs/products": "0.
|
|
38
|
+
"@voyantjs/products": "0.3.1",
|
|
39
39
|
"@voyantjs/voyant-typescript-config": "0.1.0"
|
|
40
40
|
},
|
|
41
41
|
"files": [
|