@voyant-travel/mice 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,330 @@
1
+ /**
2
+ * The MICE group-program spine (Phase 1: the minimal umbrella). A Program is a
3
+ * group engagement a buyer org runs over a date range; room blocks (owned by
4
+ * accommodations) link to it via `programId`. Sessions, delegates, rooming, and
5
+ * RFP/bid land in later phases. See RFC voyant#1489.
6
+ *
7
+ * Cross-package associations (`organizationId`, `primaryContactPersonId`) are
8
+ * loose `typeIdRef` columns linked via `defineLink` at the deployment.
9
+ */
10
+ export declare const programTypeEnum: import("drizzle-orm/pg-core").PgEnum<["meeting", "incentive", "conference", "exhibition", "other"]>;
11
+ export declare const programStatusEnum: import("drizzle-orm/pg-core").PgEnum<["lead", "planning", "contracted", "operating", "completed", "cancelled"]>;
12
+ export declare const programs: import("drizzle-orm/pg-core").PgTableWithColumns<{
13
+ name: "mice_programs";
14
+ schema: undefined;
15
+ columns: {
16
+ id: import("drizzle-orm/pg-core").PgColumn<{
17
+ name: string;
18
+ tableName: "mice_programs";
19
+ dataType: "string";
20
+ columnType: "PgText";
21
+ data: string;
22
+ driverParam: string;
23
+ notNull: true;
24
+ hasDefault: true;
25
+ isPrimaryKey: true;
26
+ isAutoincrement: false;
27
+ hasRuntimeDefault: true;
28
+ enumValues: [string, ...string[]];
29
+ baseColumn: never;
30
+ identity: undefined;
31
+ generated: undefined;
32
+ }, {}, {}>;
33
+ organizationId: import("drizzle-orm/pg-core").PgColumn<{
34
+ name: string;
35
+ tableName: "mice_programs";
36
+ dataType: "string";
37
+ columnType: "PgText";
38
+ data: string;
39
+ driverParam: string;
40
+ notNull: false;
41
+ hasDefault: false;
42
+ isPrimaryKey: false;
43
+ isAutoincrement: false;
44
+ hasRuntimeDefault: false;
45
+ enumValues: [string, ...string[]];
46
+ baseColumn: never;
47
+ identity: undefined;
48
+ generated: undefined;
49
+ }, {}, {}>;
50
+ primaryContactPersonId: import("drizzle-orm/pg-core").PgColumn<{
51
+ name: string;
52
+ tableName: "mice_programs";
53
+ dataType: "string";
54
+ columnType: "PgText";
55
+ data: string;
56
+ driverParam: string;
57
+ notNull: false;
58
+ hasDefault: false;
59
+ isPrimaryKey: false;
60
+ isAutoincrement: false;
61
+ hasRuntimeDefault: false;
62
+ enumValues: [string, ...string[]];
63
+ baseColumn: never;
64
+ identity: undefined;
65
+ generated: undefined;
66
+ }, {}, {}>;
67
+ accountManagerId: import("drizzle-orm/pg-core").PgColumn<{
68
+ name: "account_manager_id";
69
+ tableName: "mice_programs";
70
+ dataType: "string";
71
+ columnType: "PgText";
72
+ data: string;
73
+ driverParam: string;
74
+ notNull: false;
75
+ hasDefault: false;
76
+ isPrimaryKey: false;
77
+ isAutoincrement: false;
78
+ hasRuntimeDefault: false;
79
+ enumValues: [string, ...string[]];
80
+ baseColumn: never;
81
+ identity: undefined;
82
+ generated: undefined;
83
+ }, {}, {}>;
84
+ name: import("drizzle-orm/pg-core").PgColumn<{
85
+ name: "name";
86
+ tableName: "mice_programs";
87
+ dataType: "string";
88
+ columnType: "PgText";
89
+ data: string;
90
+ driverParam: string;
91
+ notNull: true;
92
+ hasDefault: false;
93
+ isPrimaryKey: false;
94
+ isAutoincrement: false;
95
+ hasRuntimeDefault: false;
96
+ enumValues: [string, ...string[]];
97
+ baseColumn: never;
98
+ identity: undefined;
99
+ generated: undefined;
100
+ }, {}, {}>;
101
+ code: import("drizzle-orm/pg-core").PgColumn<{
102
+ name: "code";
103
+ tableName: "mice_programs";
104
+ dataType: "string";
105
+ columnType: "PgText";
106
+ data: string;
107
+ driverParam: string;
108
+ notNull: false;
109
+ hasDefault: false;
110
+ isPrimaryKey: false;
111
+ isAutoincrement: false;
112
+ hasRuntimeDefault: false;
113
+ enumValues: [string, ...string[]];
114
+ baseColumn: never;
115
+ identity: undefined;
116
+ generated: undefined;
117
+ }, {}, {}>;
118
+ type: import("drizzle-orm/pg-core").PgColumn<{
119
+ name: "type";
120
+ tableName: "mice_programs";
121
+ dataType: "string";
122
+ columnType: "PgEnumColumn";
123
+ data: "meeting" | "incentive" | "conference" | "exhibition" | "other";
124
+ driverParam: string;
125
+ notNull: true;
126
+ hasDefault: true;
127
+ isPrimaryKey: false;
128
+ isAutoincrement: false;
129
+ hasRuntimeDefault: false;
130
+ enumValues: ["meeting", "incentive", "conference", "exhibition", "other"];
131
+ baseColumn: never;
132
+ identity: undefined;
133
+ generated: undefined;
134
+ }, {}, {}>;
135
+ status: import("drizzle-orm/pg-core").PgColumn<{
136
+ name: "status";
137
+ tableName: "mice_programs";
138
+ dataType: "string";
139
+ columnType: "PgEnumColumn";
140
+ data: "lead" | "planning" | "contracted" | "operating" | "completed" | "cancelled";
141
+ driverParam: string;
142
+ notNull: true;
143
+ hasDefault: true;
144
+ isPrimaryKey: false;
145
+ isAutoincrement: false;
146
+ hasRuntimeDefault: false;
147
+ enumValues: ["lead", "planning", "contracted", "operating", "completed", "cancelled"];
148
+ baseColumn: never;
149
+ identity: undefined;
150
+ generated: undefined;
151
+ }, {}, {}>;
152
+ destination: import("drizzle-orm/pg-core").PgColumn<{
153
+ name: "destination";
154
+ tableName: "mice_programs";
155
+ dataType: "string";
156
+ columnType: "PgText";
157
+ data: string;
158
+ driverParam: string;
159
+ notNull: false;
160
+ hasDefault: false;
161
+ isPrimaryKey: false;
162
+ isAutoincrement: false;
163
+ hasRuntimeDefault: false;
164
+ enumValues: [string, ...string[]];
165
+ baseColumn: never;
166
+ identity: undefined;
167
+ generated: undefined;
168
+ }, {}, {}>;
169
+ startDate: import("drizzle-orm/pg-core").PgColumn<{
170
+ name: "start_date";
171
+ tableName: "mice_programs";
172
+ dataType: "string";
173
+ columnType: "PgDateString";
174
+ data: string;
175
+ driverParam: string;
176
+ notNull: false;
177
+ hasDefault: false;
178
+ isPrimaryKey: false;
179
+ isAutoincrement: false;
180
+ hasRuntimeDefault: false;
181
+ enumValues: undefined;
182
+ baseColumn: never;
183
+ identity: undefined;
184
+ generated: undefined;
185
+ }, {}, {}>;
186
+ endDate: import("drizzle-orm/pg-core").PgColumn<{
187
+ name: "end_date";
188
+ tableName: "mice_programs";
189
+ dataType: "string";
190
+ columnType: "PgDateString";
191
+ data: string;
192
+ driverParam: string;
193
+ notNull: false;
194
+ hasDefault: false;
195
+ isPrimaryKey: false;
196
+ isAutoincrement: false;
197
+ hasRuntimeDefault: false;
198
+ enumValues: undefined;
199
+ baseColumn: never;
200
+ identity: undefined;
201
+ generated: undefined;
202
+ }, {}, {}>;
203
+ estimatedPax: import("drizzle-orm/pg-core").PgColumn<{
204
+ name: "estimated_pax";
205
+ tableName: "mice_programs";
206
+ dataType: "number";
207
+ columnType: "PgInteger";
208
+ data: number;
209
+ driverParam: string | number;
210
+ notNull: false;
211
+ hasDefault: false;
212
+ isPrimaryKey: false;
213
+ isAutoincrement: false;
214
+ hasRuntimeDefault: false;
215
+ enumValues: undefined;
216
+ baseColumn: never;
217
+ identity: undefined;
218
+ generated: undefined;
219
+ }, {}, {}>;
220
+ confirmedPax: import("drizzle-orm/pg-core").PgColumn<{
221
+ name: "confirmed_pax";
222
+ tableName: "mice_programs";
223
+ dataType: "number";
224
+ columnType: "PgInteger";
225
+ data: number;
226
+ driverParam: string | number;
227
+ notNull: false;
228
+ hasDefault: false;
229
+ isPrimaryKey: false;
230
+ isAutoincrement: false;
231
+ hasRuntimeDefault: false;
232
+ enumValues: undefined;
233
+ baseColumn: never;
234
+ identity: undefined;
235
+ generated: undefined;
236
+ }, {}, {}>;
237
+ currency: import("drizzle-orm/pg-core").PgColumn<{
238
+ name: "currency";
239
+ tableName: "mice_programs";
240
+ dataType: "string";
241
+ columnType: "PgText";
242
+ data: string;
243
+ driverParam: string;
244
+ notNull: false;
245
+ hasDefault: false;
246
+ isPrimaryKey: false;
247
+ isAutoincrement: false;
248
+ hasRuntimeDefault: false;
249
+ enumValues: [string, ...string[]];
250
+ baseColumn: never;
251
+ identity: undefined;
252
+ generated: undefined;
253
+ }, {}, {}>;
254
+ budgetAmountCents: import("drizzle-orm/pg-core").PgColumn<{
255
+ name: "budget_amount_cents";
256
+ tableName: "mice_programs";
257
+ dataType: "number";
258
+ columnType: "PgInteger";
259
+ data: number;
260
+ driverParam: string | number;
261
+ notNull: false;
262
+ hasDefault: false;
263
+ isPrimaryKey: false;
264
+ isAutoincrement: false;
265
+ hasRuntimeDefault: false;
266
+ enumValues: undefined;
267
+ baseColumn: never;
268
+ identity: undefined;
269
+ generated: undefined;
270
+ }, {}, {}>;
271
+ metadata: import("drizzle-orm/pg-core").PgColumn<{
272
+ name: "metadata";
273
+ tableName: "mice_programs";
274
+ dataType: "json";
275
+ columnType: "PgJsonb";
276
+ data: Record<string, unknown>;
277
+ driverParam: unknown;
278
+ notNull: false;
279
+ hasDefault: false;
280
+ isPrimaryKey: false;
281
+ isAutoincrement: false;
282
+ hasRuntimeDefault: false;
283
+ enumValues: undefined;
284
+ baseColumn: never;
285
+ identity: undefined;
286
+ generated: undefined;
287
+ }, {}, {
288
+ $type: Record<string, unknown>;
289
+ }>;
290
+ createdAt: import("drizzle-orm/pg-core").PgColumn<{
291
+ name: "created_at";
292
+ tableName: "mice_programs";
293
+ dataType: "date";
294
+ columnType: "PgTimestamp";
295
+ data: Date;
296
+ driverParam: string;
297
+ notNull: true;
298
+ hasDefault: true;
299
+ isPrimaryKey: false;
300
+ isAutoincrement: false;
301
+ hasRuntimeDefault: false;
302
+ enumValues: undefined;
303
+ baseColumn: never;
304
+ identity: undefined;
305
+ generated: undefined;
306
+ }, {}, {}>;
307
+ updatedAt: import("drizzle-orm/pg-core").PgColumn<{
308
+ name: "updated_at";
309
+ tableName: "mice_programs";
310
+ dataType: "date";
311
+ columnType: "PgTimestamp";
312
+ data: Date;
313
+ driverParam: string;
314
+ notNull: true;
315
+ hasDefault: true;
316
+ isPrimaryKey: false;
317
+ isAutoincrement: false;
318
+ hasRuntimeDefault: false;
319
+ enumValues: undefined;
320
+ baseColumn: never;
321
+ identity: undefined;
322
+ generated: undefined;
323
+ }, {}, {}>;
324
+ };
325
+ dialect: "pg";
326
+ }>;
327
+ export type Program = typeof programs.$inferSelect;
328
+ export type NewProgram = typeof programs.$inferInsert;
329
+ export * from "./schema-sessions.js";
330
+ //# sourceMappingURL=schema.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../src/schema.ts"],"names":[],"mappings":"AAGA;;;;;;;;GAQG;AACH,eAAO,MAAM,eAAe,qGAM1B,CAAA;AAEF,eAAO,MAAM,iBAAiB,iHAO5B,CAAA;AAEF,eAAO,MAAM,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA2BpB,CAAA;AAED,MAAM,MAAM,OAAO,GAAG,OAAO,QAAQ,CAAC,YAAY,CAAA;AAClD,MAAM,MAAM,UAAU,GAAG,OAAO,QAAQ,CAAC,YAAY,CAAA;AAErD,cAAc,sBAAsB,CAAA"}
package/dist/schema.js ADDED
@@ -0,0 +1,51 @@
1
+ import { typeId, typeIdRef } from "@voyant-travel/db/lib/typeid-column";
2
+ import { date, index, integer, jsonb, pgEnum, pgTable, text, timestamp } from "drizzle-orm/pg-core";
3
+ /**
4
+ * The MICE group-program spine (Phase 1: the minimal umbrella). A Program is a
5
+ * group engagement a buyer org runs over a date range; room blocks (owned by
6
+ * accommodations) link to it via `programId`. Sessions, delegates, rooming, and
7
+ * RFP/bid land in later phases. See RFC voyant#1489.
8
+ *
9
+ * Cross-package associations (`organizationId`, `primaryContactPersonId`) are
10
+ * loose `typeIdRef` columns linked via `defineLink` at the deployment.
11
+ */
12
+ export const programTypeEnum = pgEnum("mice_program_type", [
13
+ "meeting",
14
+ "incentive",
15
+ "conference",
16
+ "exhibition",
17
+ "other",
18
+ ]);
19
+ export const programStatusEnum = pgEnum("mice_program_status", [
20
+ "lead",
21
+ "planning",
22
+ "contracted",
23
+ "operating",
24
+ "completed",
25
+ "cancelled",
26
+ ]);
27
+ export const programs = pgTable("mice_programs", {
28
+ id: typeId("mice_programs"),
29
+ organizationId: typeIdRef("organization_id"), // → relationships.organizations (buyer)
30
+ primaryContactPersonId: typeIdRef("primary_contact_person_id"), // → relationships.people
31
+ accountManagerId: text("account_manager_id"), // owning staff user (auth)
32
+ name: text("name").notNull(),
33
+ code: text("code"),
34
+ type: programTypeEnum("type").notNull().default("conference"),
35
+ status: programStatusEnum("status").notNull().default("lead"),
36
+ destination: text("destination"),
37
+ startDate: date("start_date"),
38
+ endDate: date("end_date"),
39
+ estimatedPax: integer("estimated_pax"),
40
+ confirmedPax: integer("confirmed_pax"),
41
+ currency: text("currency"),
42
+ budgetAmountCents: integer("budget_amount_cents"),
43
+ metadata: jsonb("metadata").$type(),
44
+ createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow(),
45
+ updatedAt: timestamp("updated_at", { withTimezone: true }).notNull().defaultNow(),
46
+ }, (table) => [
47
+ index("idx_mice_programs_org").on(table.organizationId),
48
+ index("idx_mice_programs_status").on(table.status),
49
+ index("idx_mice_programs_dates").on(table.startDate, table.endDate),
50
+ ]);
51
+ export * from "./schema-sessions.js";
@@ -0,0 +1,25 @@
1
+ import type { PostgresJsDatabase } from "drizzle-orm/postgres-js";
2
+ import { type ProgramSession, type SessionInclusion } from "./schema-sessions.js";
3
+ import type { CreateSessionBody, SessionInclusionInput, SessionListQuery, UpdateSessionBody } from "./validation-sessions.js";
4
+ export declare function createSession(db: PostgresJsDatabase, input: CreateSessionBody): Promise<ProgramSession>;
5
+ export declare function getSession(db: PostgresJsDatabase, id: string): Promise<(ProgramSession & {
6
+ inclusions: SessionInclusion[];
7
+ }) | null>;
8
+ export declare function listSessions(db: PostgresJsDatabase, query: SessionListQuery): Promise<{
9
+ data: ProgramSession[];
10
+ limit: number;
11
+ offset: number;
12
+ }>;
13
+ export declare function updateSession(db: PostgresJsDatabase, id: string, input: UpdateSessionBody): Promise<ProgramSession | null>;
14
+ export declare function deleteSession(db: PostgresJsDatabase, id: string): Promise<boolean>;
15
+ /** Replace a session's inclusions (delete-all + insert) in one transaction. */
16
+ export declare function setSessionInclusions(db: PostgresJsDatabase, sessionId: string, inclusions: SessionInclusionInput[]): Promise<SessionInclusion[]>;
17
+ export declare const sessionService: {
18
+ createSession: typeof createSession;
19
+ getSession: typeof getSession;
20
+ listSessions: typeof listSessions;
21
+ updateSession: typeof updateSession;
22
+ deleteSession: typeof deleteSession;
23
+ setSessionInclusions: typeof setSessionInclusions;
24
+ };
25
+ //# sourceMappingURL=service-sessions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"service-sessions.d.ts","sourceRoot":"","sources":["../src/service-sessions.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAA;AAEjE,OAAO,EACL,KAAK,cAAc,EAEnB,KAAK,gBAAgB,EAEtB,MAAM,sBAAsB,CAAA;AAC7B,OAAO,KAAK,EACV,iBAAiB,EACjB,qBAAqB,EACrB,gBAAgB,EAChB,iBAAiB,EAClB,MAAM,0BAA0B,CAAA;AAYjC,wBAAsB,aAAa,CACjC,EAAE,EAAE,kBAAkB,EACtB,KAAK,EAAE,iBAAiB,GACvB,OAAO,CAAC,cAAc,CAAC,CAIzB;AAED,wBAAsB,UAAU,CAC9B,EAAE,EAAE,kBAAkB,EACtB,EAAE,EAAE,MAAM,GACT,OAAO,CAAC,CAAC,cAAc,GAAG;IAAE,UAAU,EAAE,gBAAgB,EAAE,CAAA;CAAE,CAAC,GAAG,IAAI,CAAC,CAYvE;AAED,wBAAsB,YAAY,CAChC,EAAE,EAAE,kBAAkB,EACtB,KAAK,EAAE,gBAAgB,GACtB,OAAO,CAAC;IAAE,IAAI,EAAE,cAAc,EAAE,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC,CAWpE;AAED,wBAAsB,aAAa,CACjC,EAAE,EAAE,kBAAkB,EACtB,EAAE,EAAE,MAAM,EACV,KAAK,EAAE,iBAAiB,GACvB,OAAO,CAAC,cAAc,GAAG,IAAI,CAAC,CAOhC;AAED,wBAAsB,aAAa,CAAC,EAAE,EAAE,kBAAkB,EAAE,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAGxF;AAED,+EAA+E;AAC/E,wBAAsB,oBAAoB,CACxC,EAAE,EAAE,kBAAkB,EACtB,SAAS,EAAE,MAAM,EACjB,UAAU,EAAE,qBAAqB,EAAE,GAClC,OAAO,CAAC,gBAAgB,EAAE,CAAC,CAS7B;AAED,eAAO,MAAM,cAAc;;;;;;;CAO1B,CAAA"}
@@ -0,0 +1,76 @@
1
+ import { and, asc, eq } from "drizzle-orm";
2
+ import { programSessions, sessionInclusions, } from "./schema-sessions.js";
3
+ /** Coerce ISO datetime strings (from validation) into Date for timestamp columns. */
4
+ function withTimestamps(input) {
5
+ const { startsAt, endsAt, ...rest } = input;
6
+ return {
7
+ ...rest,
8
+ ...(startsAt !== undefined ? { startsAt: new Date(startsAt) } : {}),
9
+ ...(endsAt !== undefined ? { endsAt: new Date(endsAt) } : {}),
10
+ };
11
+ }
12
+ export async function createSession(db, input) {
13
+ const [session] = await db.insert(programSessions).values(withTimestamps(input)).returning();
14
+ if (!session)
15
+ throw new Error("createSession: insert returned no rows");
16
+ return session;
17
+ }
18
+ export async function getSession(db, id) {
19
+ const [session] = await db
20
+ .select()
21
+ .from(programSessions)
22
+ .where(eq(programSessions.id, id))
23
+ .limit(1);
24
+ if (!session)
25
+ return null;
26
+ const inclusions = await db
27
+ .select()
28
+ .from(sessionInclusions)
29
+ .where(eq(sessionInclusions.sessionId, id));
30
+ return { ...session, inclusions };
31
+ }
32
+ export async function listSessions(db, query) {
33
+ const conditions = [eq(programSessions.programId, query.programId)];
34
+ if (query.sessionType)
35
+ conditions.push(eq(programSessions.sessionType, query.sessionType));
36
+ const data = await db
37
+ .select()
38
+ .from(programSessions)
39
+ .where(and(...conditions))
40
+ .orderBy(asc(programSessions.dayDate), asc(programSessions.startsAt))
41
+ .limit(query.limit)
42
+ .offset(query.offset);
43
+ return { data, limit: query.limit, offset: query.offset };
44
+ }
45
+ export async function updateSession(db, id, input) {
46
+ const [session] = await db
47
+ .update(programSessions)
48
+ .set({ ...withTimestamps(input), updatedAt: new Date() })
49
+ .where(eq(programSessions.id, id))
50
+ .returning();
51
+ return session ?? null;
52
+ }
53
+ export async function deleteSession(db, id) {
54
+ const [row] = await db.delete(programSessions).where(eq(programSessions.id, id)).returning();
55
+ return !!row;
56
+ }
57
+ /** Replace a session's inclusions (delete-all + insert) in one transaction. */
58
+ export async function setSessionInclusions(db, sessionId, inclusions) {
59
+ return db.transaction(async (tx) => {
60
+ await tx.delete(sessionInclusions).where(eq(sessionInclusions.sessionId, sessionId));
61
+ if (inclusions.length === 0)
62
+ return [];
63
+ return tx
64
+ .insert(sessionInclusions)
65
+ .values(inclusions.map((i) => ({ sessionId, ...i })))
66
+ .returning();
67
+ });
68
+ }
69
+ export const sessionService = {
70
+ createSession,
71
+ getSession,
72
+ listSessions,
73
+ updateSession,
74
+ deleteSession,
75
+ setSessionInclusions,
76
+ };
@@ -0,0 +1,18 @@
1
+ import type { PostgresJsDatabase } from "drizzle-orm/postgres-js";
2
+ import { type Program } from "./schema.js";
3
+ import type { CreateProgramBody, ProgramListQuery, UpdateProgramBody } from "./validation.js";
4
+ export declare function createProgram(db: PostgresJsDatabase, input: CreateProgramBody): Promise<Program>;
5
+ export declare function getProgram(db: PostgresJsDatabase, id: string): Promise<Program | null>;
6
+ export declare function listPrograms(db: PostgresJsDatabase, query: ProgramListQuery): Promise<{
7
+ data: Program[];
8
+ limit: number;
9
+ offset: number;
10
+ }>;
11
+ export declare function updateProgram(db: PostgresJsDatabase, id: string, input: UpdateProgramBody): Promise<Program | null>;
12
+ export declare const miceService: {
13
+ createProgram: typeof createProgram;
14
+ getProgram: typeof getProgram;
15
+ listPrograms: typeof listPrograms;
16
+ updateProgram: typeof updateProgram;
17
+ };
18
+ //# sourceMappingURL=service.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../src/service.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAA;AAEjE,OAAO,EAAE,KAAK,OAAO,EAAY,MAAM,aAAa,CAAA;AACpD,OAAO,KAAK,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAA;AAE7F,wBAAsB,aAAa,CACjC,EAAE,EAAE,kBAAkB,EACtB,KAAK,EAAE,iBAAiB,GACvB,OAAO,CAAC,OAAO,CAAC,CAIlB;AAED,wBAAsB,UAAU,CAAC,EAAE,EAAE,kBAAkB,EAAE,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC,CAG5F;AAED,wBAAsB,YAAY,CAChC,EAAE,EAAE,kBAAkB,EACtB,KAAK,EAAE,gBAAgB,GACtB,OAAO,CAAC;IAAE,IAAI,EAAE,OAAO,EAAE,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC,CAe7D;AAED,wBAAsB,aAAa,CACjC,EAAE,EAAE,kBAAkB,EACtB,EAAE,EAAE,MAAM,EACV,KAAK,EAAE,iBAAiB,GACvB,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC,CAOzB;AAED,eAAO,MAAM,WAAW;;;;;CAKvB,CAAA"}
@@ -0,0 +1,44 @@
1
+ import { and, desc, eq } from "drizzle-orm";
2
+ import { programs } from "./schema.js";
3
+ export async function createProgram(db, input) {
4
+ const [program] = await db.insert(programs).values(input).returning();
5
+ if (!program)
6
+ throw new Error("createProgram: insert returned no rows");
7
+ return program;
8
+ }
9
+ export async function getProgram(db, id) {
10
+ const [program] = await db.select().from(programs).where(eq(programs.id, id)).limit(1);
11
+ return program ?? null;
12
+ }
13
+ export async function listPrograms(db, query) {
14
+ const conditions = [];
15
+ if (query.status)
16
+ conditions.push(eq(programs.status, query.status));
17
+ if (query.type)
18
+ conditions.push(eq(programs.type, query.type));
19
+ if (query.organizationId)
20
+ conditions.push(eq(programs.organizationId, query.organizationId));
21
+ const where = conditions.length ? and(...conditions) : undefined;
22
+ const data = await db
23
+ .select()
24
+ .from(programs)
25
+ .where(where)
26
+ .orderBy(desc(programs.createdAt))
27
+ .limit(query.limit)
28
+ .offset(query.offset);
29
+ return { data, limit: query.limit, offset: query.offset };
30
+ }
31
+ export async function updateProgram(db, id, input) {
32
+ const [program] = await db
33
+ .update(programs)
34
+ .set({ ...input, updatedAt: new Date() })
35
+ .where(eq(programs.id, id))
36
+ .returning();
37
+ return program ?? null;
38
+ }
39
+ export const miceService = {
40
+ createProgram,
41
+ getProgram,
42
+ listPrograms,
43
+ updateProgram,
44
+ };
@@ -0,0 +1,92 @@
1
+ import { z } from "zod";
2
+ export declare const sessionTypeSchema: z.ZodEnum<{
3
+ keynote: "keynote";
4
+ breakout: "breakout";
5
+ meal: "meal";
6
+ networking: "networking";
7
+ gala: "gala";
8
+ excursion: "excursion";
9
+ free: "free";
10
+ }>;
11
+ export declare const sessionInclusionKindSchema: z.ZodEnum<{
12
+ other: "other";
13
+ fnb: "fnb";
14
+ av: "av";
15
+ materials: "materials";
16
+ signage: "signage";
17
+ }>;
18
+ export declare const createSessionSchema: z.ZodObject<{
19
+ programId: z.ZodString;
20
+ title: z.ZodString;
21
+ sessionType: z.ZodDefault<z.ZodEnum<{
22
+ keynote: "keynote";
23
+ breakout: "breakout";
24
+ meal: "meal";
25
+ networking: "networking";
26
+ gala: "gala";
27
+ excursion: "excursion";
28
+ free: "free";
29
+ }>>;
30
+ functionSpaceId: z.ZodOptional<z.ZodString>;
31
+ dayDate: z.ZodOptional<z.ZodString>;
32
+ startsAt: z.ZodOptional<z.ZodString>;
33
+ endsAt: z.ZodOptional<z.ZodString>;
34
+ track: z.ZodOptional<z.ZodString>;
35
+ capacity: z.ZodOptional<z.ZodNumber>;
36
+ requiresRegistration: z.ZodOptional<z.ZodBoolean>;
37
+ notes: z.ZodOptional<z.ZodString>;
38
+ }, z.core.$strip>;
39
+ export declare const updateSessionSchema: z.ZodObject<{
40
+ title: z.ZodOptional<z.ZodString>;
41
+ sessionType: z.ZodOptional<z.ZodDefault<z.ZodEnum<{
42
+ keynote: "keynote";
43
+ breakout: "breakout";
44
+ meal: "meal";
45
+ networking: "networking";
46
+ gala: "gala";
47
+ excursion: "excursion";
48
+ free: "free";
49
+ }>>>;
50
+ functionSpaceId: z.ZodOptional<z.ZodOptional<z.ZodString>>;
51
+ dayDate: z.ZodOptional<z.ZodOptional<z.ZodString>>;
52
+ startsAt: z.ZodOptional<z.ZodOptional<z.ZodString>>;
53
+ endsAt: z.ZodOptional<z.ZodOptional<z.ZodString>>;
54
+ track: z.ZodOptional<z.ZodOptional<z.ZodString>>;
55
+ capacity: z.ZodOptional<z.ZodOptional<z.ZodNumber>>;
56
+ requiresRegistration: z.ZodOptional<z.ZodOptional<z.ZodBoolean>>;
57
+ notes: z.ZodOptional<z.ZodOptional<z.ZodString>>;
58
+ }, z.core.$strip>;
59
+ export declare const sessionListQuerySchema: z.ZodObject<{
60
+ programId: z.ZodString;
61
+ sessionType: z.ZodOptional<z.ZodEnum<{
62
+ keynote: "keynote";
63
+ breakout: "breakout";
64
+ meal: "meal";
65
+ networking: "networking";
66
+ gala: "gala";
67
+ excursion: "excursion";
68
+ free: "free";
69
+ }>>;
70
+ limit: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
71
+ offset: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
72
+ }, z.core.$strip>;
73
+ export declare const setSessionInclusionsSchema: z.ZodObject<{
74
+ inclusions: z.ZodArray<z.ZodObject<{
75
+ kind: z.ZodEnum<{
76
+ other: "other";
77
+ fnb: "fnb";
78
+ av: "av";
79
+ materials: "materials";
80
+ signage: "signage";
81
+ }>;
82
+ description: z.ZodOptional<z.ZodString>;
83
+ quantity: z.ZodDefault<z.ZodNumber>;
84
+ costAmountCents: z.ZodOptional<z.ZodNumber>;
85
+ currency: z.ZodOptional<z.ZodString>;
86
+ }, z.core.$strip>>;
87
+ }, z.core.$strip>;
88
+ export type CreateSessionBody = z.infer<typeof createSessionSchema>;
89
+ export type UpdateSessionBody = z.infer<typeof updateSessionSchema>;
90
+ export type SessionListQuery = z.infer<typeof sessionListQuerySchema>;
91
+ export type SessionInclusionInput = z.infer<typeof setSessionInclusionsSchema>["inclusions"][number];
92
+ //# sourceMappingURL=validation-sessions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validation-sessions.d.ts","sourceRoot":"","sources":["../src/validation-sessions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAIvB,eAAO,MAAM,iBAAiB;;;;;;;;EAQ5B,CAAA;AAEF,eAAO,MAAM,0BAA0B;;;;;;EAAyD,CAAA;AAEhG,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;iBAY9B,CAAA;AAEF,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;iBAA0D,CAAA;AAE1F,eAAO,MAAM,sBAAsB;;;;;;;;;;;;;iBAKjC,CAAA;AAEF,eAAO,MAAM,0BAA0B;;;;;;;;;;;;;;iBAUrC,CAAA;AAEF,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAA;AACnE,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAA;AACnE,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,sBAAsB,CAAC,CAAA;AACrE,MAAM,MAAM,qBAAqB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,0BAA0B,CAAC,CAAC,YAAY,CAAC,CAAC,MAAM,CAAC,CAAA"}