@voyantjs/facilities 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,OAAO,KAAK,EACV,oBAAoB,EACpB,uBAAuB,EACxB,MAAM,2BAA2B,CAAA;AAgBlC,eAAO,MAAM,gBAAgB,iNAgB3B,CAAA;AAEF,eAAO,MAAM,kBAAkB,0EAAgE,CAAA;AAE/F,eAAO,MAAM,qBAAqB,yFAKhC,CAAA;AAEF,eAAO,MAAM,2BAA2B,8GAOtC,CAAA;AAEF,eAAO,MAAM,qBAAqB,sHAQhC,CAAA;AAEF,eAAO,MAAM,gBAAgB,qHAS3B,CAAA;AAEF,eAAO,MAAM,qBAAqB,+HAQhC,CAAA;AAEF,eAAO,MAAM,uBAAuB,0EAIlC,CAAA;AAEF,eAAO,MAAM,+BAA+B,+FAM1C,CAAA;AAEF,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA0BtB,CAAA;AAED,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAqB5B,CAAA;AAED,eAAO,MAAM,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,YAAY,CAAA;AACxD,MAAM,MAAM,eAAe,GAAG,oBAAoB,CAAA;AAClD,MAAM,MAAM,kBAAkB,GAAG,uBAAuB,CAAA;AACxD,MAAM,MAAM,eAAe,GAAG,OAAO,gBAAgB,CAAC,YAAY,CAAA;AAClE,MAAM,MAAM,kBAAkB,GAAG,OAAO,gBAAgB,CAAC,YAAY,CAAA;AACrE,MAAM,MAAM,yBAAyB,GAAG,OAAO,0BAA0B,CAAC,YAAY,CAAA;AACtF,MAAM,MAAM,4BAA4B,GAAG,OAAO,0BAA0B,CAAC,YAAY,CAAA;AACzF,MAAM,MAAM,QAAQ,GAAG,OAAO,UAAU,CAAC,YAAY,CAAA;AACrD,MAAM,MAAM,WAAW,GAAG,OAAO,UAAU,CAAC,YAAY,CAAA;AACxD,MAAM,MAAM,aAAa,GAAG,OAAO,cAAc,CAAC,YAAY,CAAA;AAC9D,MAAM,MAAM,gBAAgB,GAAG,OAAO,cAAc,CAAC,YAAY,CAAA;AACjE,MAAM,MAAM,mBAAmB,GAAG,OAAO,oBAAoB,CAAC,YAAY,CAAA;AAC1E,MAAM,MAAM,sBAAsB,GAAG,OAAO,oBAAoB,CAAC,YAAY,CAAA;AAE7E,eAAO,MAAM,mBAAmB;;;;;;EAa7B,CAAA;AAEH,eAAO,MAAM,yBAAyB;;EAKnC,CAAA;AAEH,eAAO,MAAM,mCAAmC;;EAQ/C,CAAA;AAED,eAAO,MAAM,mBAAmB;;EAK7B,CAAA;AAEH,eAAO,MAAM,uBAAuB;;;;EAQjC,CAAA;AAEH,eAAO,MAAM,6BAA6B;;;EASvC,CAAA"}
package/dist/schema.js ADDED
@@ -0,0 +1,249 @@
1
+ import { typeId, typeIdRef } from "@voyantjs/db/lib/typeid-column";
2
+ import { relations } from "drizzle-orm";
3
+ import { boolean, date, index, integer, jsonb, pgEnum, pgTable, text, timestamp, uniqueIndex, } from "drizzle-orm/pg-core";
4
+ export const facilityKindEnum = pgEnum("facility_kind", [
5
+ "property",
6
+ "hotel",
7
+ "resort",
8
+ "venue",
9
+ "meeting_point",
10
+ "transfer_hub",
11
+ "airport",
12
+ "station",
13
+ "marina",
14
+ "camp",
15
+ "lodge",
16
+ "office",
17
+ "attraction",
18
+ "restaurant",
19
+ "other",
20
+ ]);
21
+ export const facilityStatusEnum = pgEnum("facility_status", ["active", "inactive", "archived"]);
22
+ export const facilityOwnerTypeEnum = pgEnum("facility_owner_type", [
23
+ "supplier",
24
+ "organization",
25
+ "internal",
26
+ "other",
27
+ ]);
28
+ export const facilityFeatureCategoryEnum = pgEnum("facility_feature_category", [
29
+ "amenity",
30
+ "accessibility",
31
+ "security",
32
+ "service",
33
+ "policy",
34
+ "other",
35
+ ]);
36
+ export const facilityDayOfWeekEnum = pgEnum("facility_day_of_week", [
37
+ "monday",
38
+ "tuesday",
39
+ "wednesday",
40
+ "thursday",
41
+ "friday",
42
+ "saturday",
43
+ "sunday",
44
+ ]);
45
+ export const propertyTypeEnum = pgEnum("property_type", [
46
+ "hotel",
47
+ "resort",
48
+ "villa",
49
+ "apartment",
50
+ "hostel",
51
+ "lodge",
52
+ "camp",
53
+ "other",
54
+ ]);
55
+ export const propertyGroupTypeEnum = pgEnum("property_group_type", [
56
+ "chain",
57
+ "brand",
58
+ "management_company",
59
+ "collection",
60
+ "portfolio",
61
+ "cluster",
62
+ "other",
63
+ ]);
64
+ export const propertyGroupStatusEnum = pgEnum("property_group_status", [
65
+ "active",
66
+ "inactive",
67
+ "archived",
68
+ ]);
69
+ export const propertyGroupMembershipRoleEnum = pgEnum("property_group_membership_role", [
70
+ "member",
71
+ "flagship",
72
+ "managed",
73
+ "franchise",
74
+ "other",
75
+ ]);
76
+ export const facilities = pgTable("facilities", {
77
+ id: typeId("facilities"),
78
+ parentFacilityId: typeIdRef("parent_facility_id").references(() => facilities.id, {
79
+ onDelete: "set null",
80
+ }),
81
+ ownerType: facilityOwnerTypeEnum("owner_type"),
82
+ ownerId: text("owner_id"),
83
+ kind: facilityKindEnum("kind").notNull(),
84
+ status: facilityStatusEnum("status").notNull().default("active"),
85
+ name: text("name").notNull(),
86
+ code: text("code"),
87
+ description: text("description"),
88
+ timezone: text("timezone"),
89
+ tags: jsonb("tags").$type().notNull().default([]),
90
+ createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow(),
91
+ updatedAt: timestamp("updated_at", { withTimezone: true }).notNull().defaultNow(),
92
+ }, (table) => [
93
+ index("idx_facilities_parent").on(table.parentFacilityId),
94
+ index("idx_facilities_owner").on(table.ownerType, table.ownerId),
95
+ index("idx_facilities_kind").on(table.kind),
96
+ index("idx_facilities_status").on(table.status),
97
+ uniqueIndex("uidx_facilities_code").on(table.code),
98
+ ]);
99
+ export const facilityFeatures = pgTable("facility_features", {
100
+ id: typeId("facility_features"),
101
+ facilityId: typeIdRef("facility_id")
102
+ .notNull()
103
+ .references(() => facilities.id, { onDelete: "cascade" }),
104
+ category: facilityFeatureCategoryEnum("category").notNull().default("amenity"),
105
+ code: text("code"),
106
+ name: text("name").notNull(),
107
+ description: text("description"),
108
+ valueText: text("value_text"),
109
+ highlighted: boolean("highlighted").notNull().default(false),
110
+ sortOrder: integer("sort_order").notNull().default(0),
111
+ createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow(),
112
+ updatedAt: timestamp("updated_at", { withTimezone: true }).notNull().defaultNow(),
113
+ }, (table) => [
114
+ index("idx_facility_features_facility").on(table.facilityId),
115
+ index("idx_facility_features_category").on(table.category),
116
+ ]);
117
+ export const facilityOperationSchedules = pgTable("facility_operation_schedules", {
118
+ id: typeId("facility_operation_schedules"),
119
+ facilityId: typeIdRef("facility_id")
120
+ .notNull()
121
+ .references(() => facilities.id, { onDelete: "cascade" }),
122
+ dayOfWeek: facilityDayOfWeekEnum("day_of_week"),
123
+ validFrom: date("valid_from"),
124
+ validTo: date("valid_to"),
125
+ opensAt: text("opens_at"),
126
+ closesAt: text("closes_at"),
127
+ closed: boolean("closed").notNull().default(false),
128
+ notes: text("notes"),
129
+ createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow(),
130
+ updatedAt: timestamp("updated_at", { withTimezone: true }).notNull().defaultNow(),
131
+ }, (table) => [
132
+ index("idx_facility_operation_schedules_facility").on(table.facilityId),
133
+ index("idx_facility_operation_schedules_day").on(table.dayOfWeek),
134
+ ]);
135
+ export const properties = pgTable("properties", {
136
+ id: typeId("properties"),
137
+ facilityId: typeIdRef("facility_id")
138
+ .notNull()
139
+ .references(() => facilities.id, { onDelete: "cascade" }),
140
+ propertyType: propertyTypeEnum("property_type").notNull().default("hotel"),
141
+ brandName: text("brand_name"),
142
+ groupName: text("group_name"),
143
+ rating: integer("rating"),
144
+ ratingScale: integer("rating_scale"),
145
+ checkInTime: text("check_in_time"),
146
+ checkOutTime: text("check_out_time"),
147
+ policyNotes: text("policy_notes"),
148
+ amenityNotes: text("amenity_notes"),
149
+ createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow(),
150
+ updatedAt: timestamp("updated_at", { withTimezone: true }).notNull().defaultNow(),
151
+ }, (table) => [
152
+ uniqueIndex("uidx_properties_facility").on(table.facilityId),
153
+ index("idx_properties_type").on(table.propertyType),
154
+ index("idx_properties_group").on(table.groupName),
155
+ ]);
156
+ export const propertyGroups = pgTable("property_groups", {
157
+ id: typeId("property_groups"),
158
+ parentGroupId: typeIdRef("parent_group_id").references(() => propertyGroups.id, {
159
+ onDelete: "set null",
160
+ }),
161
+ groupType: propertyGroupTypeEnum("group_type").notNull().default("chain"),
162
+ status: propertyGroupStatusEnum("status").notNull().default("active"),
163
+ name: text("name").notNull(),
164
+ code: text("code"),
165
+ brandName: text("brand_name"),
166
+ legalName: text("legal_name"),
167
+ website: text("website"),
168
+ notes: text("notes"),
169
+ metadata: jsonb("metadata").$type(),
170
+ createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow(),
171
+ updatedAt: timestamp("updated_at", { withTimezone: true }).notNull().defaultNow(),
172
+ }, (table) => [
173
+ index("idx_property_groups_parent").on(table.parentGroupId),
174
+ index("idx_property_groups_type").on(table.groupType),
175
+ index("idx_property_groups_status").on(table.status),
176
+ uniqueIndex("uidx_property_groups_code").on(table.code),
177
+ ]);
178
+ export const propertyGroupMembers = pgTable("property_group_members", {
179
+ id: typeId("property_group_members"),
180
+ groupId: typeIdRef("group_id")
181
+ .notNull()
182
+ .references(() => propertyGroups.id, { onDelete: "cascade" }),
183
+ propertyId: typeIdRef("property_id")
184
+ .notNull()
185
+ .references(() => properties.id, { onDelete: "cascade" }),
186
+ membershipRole: propertyGroupMembershipRoleEnum("membership_role").notNull().default("member"),
187
+ isPrimary: boolean("is_primary").notNull().default(false),
188
+ validFrom: date("valid_from"),
189
+ validTo: date("valid_to"),
190
+ notes: text("notes"),
191
+ createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow(),
192
+ updatedAt: timestamp("updated_at", { withTimezone: true }).notNull().defaultNow(),
193
+ }, (table) => [
194
+ index("idx_property_group_members_group").on(table.groupId),
195
+ index("idx_property_group_members_property").on(table.propertyId),
196
+ index("idx_property_group_members_role").on(table.membershipRole),
197
+ uniqueIndex("uidx_property_group_members_pair").on(table.groupId, table.propertyId),
198
+ ]);
199
+ export const facilitiesRelations = relations(facilities, ({ one, many }) => ({
200
+ parentFacility: one(facilities, {
201
+ fields: [facilities.parentFacilityId],
202
+ references: [facilities.id],
203
+ relationName: "facility_parent",
204
+ }),
205
+ childFacilities: many(facilities, { relationName: "facility_parent" }),
206
+ features: many(facilityFeatures),
207
+ operationSchedules: many(facilityOperationSchedules),
208
+ property: one(properties, {
209
+ fields: [facilities.id],
210
+ references: [properties.facilityId],
211
+ }),
212
+ }));
213
+ export const facilityFeaturesRelations = relations(facilityFeatures, ({ one }) => ({
214
+ facility: one(facilities, {
215
+ fields: [facilityFeatures.facilityId],
216
+ references: [facilities.id],
217
+ }),
218
+ }));
219
+ export const facilityOperationSchedulesRelations = relations(facilityOperationSchedules, ({ one }) => ({
220
+ facility: one(facilities, {
221
+ fields: [facilityOperationSchedules.facilityId],
222
+ references: [facilities.id],
223
+ }),
224
+ }));
225
+ export const propertiesRelations = relations(properties, ({ one }) => ({
226
+ facility: one(facilities, {
227
+ fields: [properties.facilityId],
228
+ references: [facilities.id],
229
+ }),
230
+ }));
231
+ export const propertyGroupsRelations = relations(propertyGroups, ({ one, many }) => ({
232
+ parentGroup: one(propertyGroups, {
233
+ fields: [propertyGroups.parentGroupId],
234
+ references: [propertyGroups.id],
235
+ relationName: "property_group_parent",
236
+ }),
237
+ childGroups: many(propertyGroups, { relationName: "property_group_parent" }),
238
+ members: many(propertyGroupMembers),
239
+ }));
240
+ export const propertyGroupMembersRelations = relations(propertyGroupMembers, ({ one }) => ({
241
+ group: one(propertyGroups, {
242
+ fields: [propertyGroupMembers.groupId],
243
+ references: [propertyGroups.id],
244
+ }),
245
+ property: one(properties, {
246
+ fields: [propertyGroupMembers.propertyId],
247
+ references: [properties.id],
248
+ }),
249
+ }));