@voyantjs/bookings 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.
- package/dist/schema-core.d.ts +1229 -0
- package/dist/schema-core.d.ts.map +1 -0
- package/dist/schema-core.js +81 -0
- package/dist/schema-items.d.ts +1278 -0
- package/dist/schema-items.d.ts.map +1 -0
- package/dist/schema-items.js +130 -0
- package/dist/schema-operations.d.ts +600 -0
- package/dist/schema-operations.d.ts.map +1 -0
- package/dist/schema-operations.js +61 -0
- package/dist/schema-relations.d.ts +58 -0
- package/dist/schema-relations.d.ts.map +1 -0
- package/dist/schema-relations.js +95 -0
- package/dist/schema-shared.d.ts +19 -0
- package/dist/schema-shared.d.ts.map +1 -0
- package/dist/schema-shared.js +137 -0
- package/dist/schema.d.ts +5 -3179
- package/dist/schema.d.ts.map +1 -1
- package/dist/schema.js +5 -509
- package/package.json +5 -5
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema-items.d.ts","sourceRoot":"","sources":["../src/schema-items.ts"],"names":[],"mappings":"AAiBA,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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M,MAAM,cAAc,GAAG,OAAO,YAAY,CAAC,YAAY,CAAA;AAC7D,MAAM,MAAM,iBAAiB,GAAG,OAAO,kBAAkB,CAAC,YAAY,CAAA;AACtE,MAAM,MAAM,oBAAoB,GAAG,OAAO,kBAAkB,CAAC,YAAY,CAAA;AACzE,MAAM,MAAM,kBAAkB,GAAG,OAAO,mBAAmB,CAAC,YAAY,CAAA;AACxE,MAAM,MAAM,qBAAqB,GAAG,OAAO,mBAAmB,CAAC,YAAY,CAAA;AAC3E,MAAM,MAAM,sBAAsB,GAAG,OAAO,uBAAuB,CAAC,YAAY,CAAA;AAChF,MAAM,MAAM,yBAAyB,GAAG,OAAO,uBAAuB,CAAC,YAAY,CAAA;AACnF,MAAM,MAAM,sBAAsB,GAAG,OAAO,uBAAuB,CAAC,YAAY,CAAA;AAChF,MAAM,MAAM,yBAAyB,GAAG,OAAO,uBAAuB,CAAC,YAAY,CAAA"}
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import { typeId, typeIdRef } from "@voyantjs/db/lib/typeid-column";
|
|
2
|
+
import { boolean, date, index, integer, jsonb, pgTable, text, timestamp } from "drizzle-orm/pg-core";
|
|
3
|
+
import { availabilitySlotsRef } from "./availability-ref.js";
|
|
4
|
+
import { bookingParticipants, bookings } from "./schema-core";
|
|
5
|
+
import { bookingAllocationStatusEnum, bookingAllocationTypeEnum, bookingFulfillmentDeliveryChannelEnum, bookingFulfillmentStatusEnum, bookingFulfillmentTypeEnum, bookingItemParticipantRoleEnum, bookingItemStatusEnum, bookingItemTypeEnum, bookingRedemptionMethodEnum, } from "./schema-shared";
|
|
6
|
+
export const bookingItems = pgTable("booking_items", {
|
|
7
|
+
id: typeId("booking_items"),
|
|
8
|
+
bookingId: typeIdRef("booking_id")
|
|
9
|
+
.notNull()
|
|
10
|
+
.references(() => bookings.id, { onDelete: "cascade" }),
|
|
11
|
+
title: text("title").notNull(),
|
|
12
|
+
description: text("description"),
|
|
13
|
+
itemType: bookingItemTypeEnum("item_type").notNull().default("unit"),
|
|
14
|
+
status: bookingItemStatusEnum("status").notNull().default("draft"),
|
|
15
|
+
serviceDate: date("service_date"),
|
|
16
|
+
startsAt: timestamp("starts_at", { withTimezone: true }),
|
|
17
|
+
endsAt: timestamp("ends_at", { withTimezone: true }),
|
|
18
|
+
quantity: integer("quantity").notNull().default(1),
|
|
19
|
+
sellCurrency: text("sell_currency").notNull(),
|
|
20
|
+
unitSellAmountCents: integer("unit_sell_amount_cents"),
|
|
21
|
+
totalSellAmountCents: integer("total_sell_amount_cents"),
|
|
22
|
+
costCurrency: text("cost_currency"),
|
|
23
|
+
unitCostAmountCents: integer("unit_cost_amount_cents"),
|
|
24
|
+
totalCostAmountCents: integer("total_cost_amount_cents"),
|
|
25
|
+
notes: text("notes"),
|
|
26
|
+
productId: text("product_id"),
|
|
27
|
+
optionId: text("option_id"),
|
|
28
|
+
optionUnitId: text("option_unit_id"),
|
|
29
|
+
pricingCategoryId: text("pricing_category_id"),
|
|
30
|
+
sourceSnapshotId: text("source_snapshot_id"),
|
|
31
|
+
sourceOfferId: text("source_offer_id"),
|
|
32
|
+
metadata: jsonb("metadata").$type(),
|
|
33
|
+
createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow(),
|
|
34
|
+
updatedAt: timestamp("updated_at", { withTimezone: true }).notNull().defaultNow(),
|
|
35
|
+
}, (table) => [
|
|
36
|
+
index("idx_booking_items_booking").on(table.bookingId),
|
|
37
|
+
index("idx_booking_items_status").on(table.status),
|
|
38
|
+
]);
|
|
39
|
+
export const bookingAllocations = pgTable("booking_allocations", {
|
|
40
|
+
id: typeId("booking_allocations"),
|
|
41
|
+
bookingId: typeIdRef("booking_id")
|
|
42
|
+
.notNull()
|
|
43
|
+
.references(() => bookings.id, { onDelete: "cascade" }),
|
|
44
|
+
bookingItemId: typeIdRef("booking_item_id")
|
|
45
|
+
.notNull()
|
|
46
|
+
.references(() => bookingItems.id, { onDelete: "cascade" }),
|
|
47
|
+
productId: text("product_id"),
|
|
48
|
+
optionId: text("option_id"),
|
|
49
|
+
optionUnitId: text("option_unit_id"),
|
|
50
|
+
pricingCategoryId: text("pricing_category_id"),
|
|
51
|
+
availabilitySlotId: typeIdRef("availability_slot_id").references(() => availabilitySlotsRef.id, { onDelete: "set null" }),
|
|
52
|
+
quantity: integer("quantity").notNull().default(1),
|
|
53
|
+
allocationType: bookingAllocationTypeEnum("allocation_type").notNull().default("unit"),
|
|
54
|
+
status: bookingAllocationStatusEnum("status").notNull().default("held"),
|
|
55
|
+
holdExpiresAt: timestamp("hold_expires_at", { withTimezone: true }),
|
|
56
|
+
confirmedAt: timestamp("confirmed_at", { withTimezone: true }),
|
|
57
|
+
releasedAt: timestamp("released_at", { withTimezone: true }),
|
|
58
|
+
metadata: jsonb("metadata").$type(),
|
|
59
|
+
createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow(),
|
|
60
|
+
updatedAt: timestamp("updated_at", { withTimezone: true }).notNull().defaultNow(),
|
|
61
|
+
}, (table) => [
|
|
62
|
+
index("idx_booking_allocations_booking").on(table.bookingId),
|
|
63
|
+
index("idx_booking_allocations_item").on(table.bookingItemId),
|
|
64
|
+
index("idx_booking_allocations_slot").on(table.availabilitySlotId),
|
|
65
|
+
index("idx_booking_allocations_status").on(table.status),
|
|
66
|
+
]);
|
|
67
|
+
export const bookingFulfillments = pgTable("booking_fulfillments", {
|
|
68
|
+
id: typeId("booking_fulfillments"),
|
|
69
|
+
bookingId: typeIdRef("booking_id")
|
|
70
|
+
.notNull()
|
|
71
|
+
.references(() => bookings.id, { onDelete: "cascade" }),
|
|
72
|
+
bookingItemId: typeIdRef("booking_item_id").references(() => bookingItems.id, {
|
|
73
|
+
onDelete: "set null",
|
|
74
|
+
}),
|
|
75
|
+
participantId: typeIdRef("participant_id").references(() => bookingParticipants.id, {
|
|
76
|
+
onDelete: "set null",
|
|
77
|
+
}),
|
|
78
|
+
fulfillmentType: bookingFulfillmentTypeEnum("fulfillment_type").notNull(),
|
|
79
|
+
deliveryChannel: bookingFulfillmentDeliveryChannelEnum("delivery_channel").notNull(),
|
|
80
|
+
status: bookingFulfillmentStatusEnum("status").notNull().default("pending"),
|
|
81
|
+
artifactUrl: text("artifact_url"),
|
|
82
|
+
payload: jsonb("payload").$type(),
|
|
83
|
+
issuedAt: timestamp("issued_at", { withTimezone: true }),
|
|
84
|
+
revokedAt: timestamp("revoked_at", { withTimezone: true }),
|
|
85
|
+
createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow(),
|
|
86
|
+
updatedAt: timestamp("updated_at", { withTimezone: true }).notNull().defaultNow(),
|
|
87
|
+
}, (table) => [
|
|
88
|
+
index("idx_booking_fulfillments_booking").on(table.bookingId),
|
|
89
|
+
index("idx_booking_fulfillments_item").on(table.bookingItemId),
|
|
90
|
+
index("idx_booking_fulfillments_participant").on(table.participantId),
|
|
91
|
+
index("idx_booking_fulfillments_status").on(table.status),
|
|
92
|
+
]);
|
|
93
|
+
export const bookingRedemptionEvents = pgTable("booking_redemption_events", {
|
|
94
|
+
id: typeId("booking_redemption_events"),
|
|
95
|
+
bookingId: typeIdRef("booking_id")
|
|
96
|
+
.notNull()
|
|
97
|
+
.references(() => bookings.id, { onDelete: "cascade" }),
|
|
98
|
+
bookingItemId: typeIdRef("booking_item_id").references(() => bookingItems.id, {
|
|
99
|
+
onDelete: "set null",
|
|
100
|
+
}),
|
|
101
|
+
participantId: typeIdRef("participant_id").references(() => bookingParticipants.id, {
|
|
102
|
+
onDelete: "set null",
|
|
103
|
+
}),
|
|
104
|
+
redeemedAt: timestamp("redeemed_at", { withTimezone: true }).notNull().defaultNow(),
|
|
105
|
+
redeemedBy: text("redeemed_by"),
|
|
106
|
+
location: text("location"),
|
|
107
|
+
method: bookingRedemptionMethodEnum("method").notNull().default("manual"),
|
|
108
|
+
metadata: jsonb("metadata").$type(),
|
|
109
|
+
createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow(),
|
|
110
|
+
}, (table) => [
|
|
111
|
+
index("idx_booking_redemption_events_booking").on(table.bookingId),
|
|
112
|
+
index("idx_booking_redemption_events_item").on(table.bookingItemId),
|
|
113
|
+
index("idx_booking_redemption_events_participant").on(table.participantId),
|
|
114
|
+
index("idx_booking_redemption_events_redeemed_at").on(table.redeemedAt),
|
|
115
|
+
]);
|
|
116
|
+
export const bookingItemParticipants = pgTable("booking_item_participants", {
|
|
117
|
+
id: typeId("booking_item_participants"),
|
|
118
|
+
bookingItemId: typeIdRef("booking_item_id")
|
|
119
|
+
.notNull()
|
|
120
|
+
.references(() => bookingItems.id, { onDelete: "cascade" }),
|
|
121
|
+
participantId: typeIdRef("participant_id")
|
|
122
|
+
.notNull()
|
|
123
|
+
.references(() => bookingParticipants.id, { onDelete: "cascade" }),
|
|
124
|
+
role: bookingItemParticipantRoleEnum("role").notNull().default("traveler"),
|
|
125
|
+
isPrimary: boolean("is_primary").notNull().default(false),
|
|
126
|
+
createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow(),
|
|
127
|
+
}, (table) => [
|
|
128
|
+
index("idx_booking_item_participants_item").on(table.bookingItemId),
|
|
129
|
+
index("idx_booking_item_participants_participant").on(table.participantId),
|
|
130
|
+
]);
|