@voyantjs/crm 0.26.2 → 0.26.3

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.
@@ -4,6 +4,15 @@
4
4
  * variant; the structured fields cover the international shape.
5
5
  */
6
6
  export declare const personDocumentTypeEnum: import("drizzle-orm/pg-core").PgEnum<["passport", "id_card", "driver_license", "visa", "other"]>;
7
+ /**
8
+ * Person-to-person relationship kinds. Directed: each row records a
9
+ * single edge `from → to` of a specific kind. The optional inverse
10
+ * edge (e.g. parent ↔ child) is kept as a separate row so list
11
+ * queries against either side return the same shape; the service
12
+ * layer auto-writes the inverse on insert when an `inverseKind` is
13
+ * provided.
14
+ */
15
+ export declare const personRelationshipKindEnum: import("drizzle-orm/pg-core").PgEnum<["spouse", "partner", "parent", "child", "sibling", "guardian", "ward", "emergency_contact", "friend", "travel_companion", "other"]>;
7
16
  export declare const organizations: import("drizzle-orm/pg-core").PgTableWithColumns<{
8
17
  name: "organizations";
9
18
  schema: undefined;
@@ -1232,6 +1241,234 @@ export declare const personDocuments: import("drizzle-orm/pg-core").PgTableWithC
1232
1241
  }>;
1233
1242
  export type PersonDocument = typeof personDocuments.$inferSelect;
1234
1243
  export type NewPersonDocument = typeof personDocuments.$inferInsert;
1244
+ /**
1245
+ * Directed person-to-person edges (kinship, emergency contacts,
1246
+ * travel companions). Each row is a single edge `fromPerson → toPerson`
1247
+ * of one `kind`; the reverse edge — when meaningful — is a separate
1248
+ * row written by the service layer's auto-inverse helper. Self-edges
1249
+ * are rejected via a CHECK constraint; the unique index on
1250
+ * `(from, to, kind)` prevents the same directional edge from being
1251
+ * recorded twice.
1252
+ *
1253
+ * `metadata` is a free-form jsonb bag for module-specific extensions
1254
+ * (e.g. emergency-contact relationship to traveler). Operators that
1255
+ * need richer structure should add their own typed columns.
1256
+ */
1257
+ export declare const personRelationships: import("drizzle-orm/pg-core").PgTableWithColumns<{
1258
+ name: "person_relationships";
1259
+ schema: undefined;
1260
+ columns: {
1261
+ id: import("drizzle-orm/pg-core").PgColumn<{
1262
+ name: string;
1263
+ tableName: "person_relationships";
1264
+ dataType: "string";
1265
+ columnType: "PgText";
1266
+ data: string;
1267
+ driverParam: string;
1268
+ notNull: true;
1269
+ hasDefault: true;
1270
+ isPrimaryKey: true;
1271
+ isAutoincrement: false;
1272
+ hasRuntimeDefault: true;
1273
+ enumValues: [string, ...string[]];
1274
+ baseColumn: never;
1275
+ identity: undefined;
1276
+ generated: undefined;
1277
+ }, {}, {}>;
1278
+ fromPersonId: import("drizzle-orm/pg-core").PgColumn<{
1279
+ name: string;
1280
+ tableName: "person_relationships";
1281
+ dataType: "string";
1282
+ columnType: "PgText";
1283
+ data: string;
1284
+ driverParam: string;
1285
+ notNull: true;
1286
+ hasDefault: false;
1287
+ isPrimaryKey: false;
1288
+ isAutoincrement: false;
1289
+ hasRuntimeDefault: false;
1290
+ enumValues: [string, ...string[]];
1291
+ baseColumn: never;
1292
+ identity: undefined;
1293
+ generated: undefined;
1294
+ }, {}, {}>;
1295
+ toPersonId: import("drizzle-orm/pg-core").PgColumn<{
1296
+ name: string;
1297
+ tableName: "person_relationships";
1298
+ dataType: "string";
1299
+ columnType: "PgText";
1300
+ data: string;
1301
+ driverParam: string;
1302
+ notNull: true;
1303
+ hasDefault: false;
1304
+ isPrimaryKey: false;
1305
+ isAutoincrement: false;
1306
+ hasRuntimeDefault: false;
1307
+ enumValues: [string, ...string[]];
1308
+ baseColumn: never;
1309
+ identity: undefined;
1310
+ generated: undefined;
1311
+ }, {}, {}>;
1312
+ kind: import("drizzle-orm/pg-core").PgColumn<{
1313
+ name: "kind";
1314
+ tableName: "person_relationships";
1315
+ dataType: "string";
1316
+ columnType: "PgEnumColumn";
1317
+ data: "partner" | "other" | "spouse" | "parent" | "child" | "sibling" | "guardian" | "ward" | "emergency_contact" | "friend" | "travel_companion";
1318
+ driverParam: string;
1319
+ notNull: true;
1320
+ hasDefault: false;
1321
+ isPrimaryKey: false;
1322
+ isAutoincrement: false;
1323
+ hasRuntimeDefault: false;
1324
+ enumValues: ["spouse", "partner", "parent", "child", "sibling", "guardian", "ward", "emergency_contact", "friend", "travel_companion", "other"];
1325
+ baseColumn: never;
1326
+ identity: undefined;
1327
+ generated: undefined;
1328
+ }, {}, {}>;
1329
+ inverseKind: import("drizzle-orm/pg-core").PgColumn<{
1330
+ name: "inverse_kind";
1331
+ tableName: "person_relationships";
1332
+ dataType: "string";
1333
+ columnType: "PgEnumColumn";
1334
+ data: "partner" | "other" | "spouse" | "parent" | "child" | "sibling" | "guardian" | "ward" | "emergency_contact" | "friend" | "travel_companion";
1335
+ driverParam: string;
1336
+ notNull: false;
1337
+ hasDefault: false;
1338
+ isPrimaryKey: false;
1339
+ isAutoincrement: false;
1340
+ hasRuntimeDefault: false;
1341
+ enumValues: ["spouse", "partner", "parent", "child", "sibling", "guardian", "ward", "emergency_contact", "friend", "travel_companion", "other"];
1342
+ baseColumn: never;
1343
+ identity: undefined;
1344
+ generated: undefined;
1345
+ }, {}, {}>;
1346
+ startDate: import("drizzle-orm/pg-core").PgColumn<{
1347
+ name: "start_date";
1348
+ tableName: "person_relationships";
1349
+ dataType: "string";
1350
+ columnType: "PgDateString";
1351
+ data: string;
1352
+ driverParam: string;
1353
+ notNull: false;
1354
+ hasDefault: false;
1355
+ isPrimaryKey: false;
1356
+ isAutoincrement: false;
1357
+ hasRuntimeDefault: false;
1358
+ enumValues: undefined;
1359
+ baseColumn: never;
1360
+ identity: undefined;
1361
+ generated: undefined;
1362
+ }, {}, {}>;
1363
+ endDate: import("drizzle-orm/pg-core").PgColumn<{
1364
+ name: "end_date";
1365
+ tableName: "person_relationships";
1366
+ dataType: "string";
1367
+ columnType: "PgDateString";
1368
+ data: string;
1369
+ driverParam: string;
1370
+ notNull: false;
1371
+ hasDefault: false;
1372
+ isPrimaryKey: false;
1373
+ isAutoincrement: false;
1374
+ hasRuntimeDefault: false;
1375
+ enumValues: undefined;
1376
+ baseColumn: never;
1377
+ identity: undefined;
1378
+ generated: undefined;
1379
+ }, {}, {}>;
1380
+ isPrimary: import("drizzle-orm/pg-core").PgColumn<{
1381
+ name: "is_primary";
1382
+ tableName: "person_relationships";
1383
+ dataType: "boolean";
1384
+ columnType: "PgBoolean";
1385
+ data: boolean;
1386
+ driverParam: boolean;
1387
+ notNull: true;
1388
+ hasDefault: true;
1389
+ isPrimaryKey: false;
1390
+ isAutoincrement: false;
1391
+ hasRuntimeDefault: false;
1392
+ enumValues: undefined;
1393
+ baseColumn: never;
1394
+ identity: undefined;
1395
+ generated: undefined;
1396
+ }, {}, {}>;
1397
+ notes: import("drizzle-orm/pg-core").PgColumn<{
1398
+ name: "notes";
1399
+ tableName: "person_relationships";
1400
+ dataType: "string";
1401
+ columnType: "PgText";
1402
+ data: string;
1403
+ driverParam: string;
1404
+ notNull: false;
1405
+ hasDefault: false;
1406
+ isPrimaryKey: false;
1407
+ isAutoincrement: false;
1408
+ hasRuntimeDefault: false;
1409
+ enumValues: [string, ...string[]];
1410
+ baseColumn: never;
1411
+ identity: undefined;
1412
+ generated: undefined;
1413
+ }, {}, {}>;
1414
+ metadata: import("drizzle-orm/pg-core").PgColumn<{
1415
+ name: "metadata";
1416
+ tableName: "person_relationships";
1417
+ dataType: "json";
1418
+ columnType: "PgJsonb";
1419
+ data: Record<string, unknown>;
1420
+ driverParam: unknown;
1421
+ notNull: false;
1422
+ hasDefault: false;
1423
+ isPrimaryKey: false;
1424
+ isAutoincrement: false;
1425
+ hasRuntimeDefault: false;
1426
+ enumValues: undefined;
1427
+ baseColumn: never;
1428
+ identity: undefined;
1429
+ generated: undefined;
1430
+ }, {}, {
1431
+ $type: Record<string, unknown>;
1432
+ }>;
1433
+ createdAt: import("drizzle-orm/pg-core").PgColumn<{
1434
+ name: "created_at";
1435
+ tableName: "person_relationships";
1436
+ dataType: "date";
1437
+ columnType: "PgTimestamp";
1438
+ data: Date;
1439
+ driverParam: string;
1440
+ notNull: true;
1441
+ hasDefault: true;
1442
+ isPrimaryKey: false;
1443
+ isAutoincrement: false;
1444
+ hasRuntimeDefault: false;
1445
+ enumValues: undefined;
1446
+ baseColumn: never;
1447
+ identity: undefined;
1448
+ generated: undefined;
1449
+ }, {}, {}>;
1450
+ updatedAt: import("drizzle-orm/pg-core").PgColumn<{
1451
+ name: "updated_at";
1452
+ tableName: "person_relationships";
1453
+ dataType: "date";
1454
+ columnType: "PgTimestamp";
1455
+ data: Date;
1456
+ driverParam: string;
1457
+ notNull: true;
1458
+ hasDefault: true;
1459
+ isPrimaryKey: false;
1460
+ isAutoincrement: false;
1461
+ hasRuntimeDefault: false;
1462
+ enumValues: undefined;
1463
+ baseColumn: never;
1464
+ identity: undefined;
1465
+ generated: undefined;
1466
+ }, {}, {}>;
1467
+ };
1468
+ dialect: "pg";
1469
+ }>;
1470
+ export type PersonRelationship = typeof personRelationships.$inferSelect;
1471
+ export type NewPersonRelationship = typeof personRelationships.$inferInsert;
1235
1472
  /**
1236
1473
  * Saved payment methods on file for a person. Stores processor-issued
1237
1474
  * tokens (never raw card numbers) so the booking flow can charge the
@@ -1 +1 @@
1
- {"version":3,"file":"schema-accounts.d.ts","sourceRoot":"","sources":["../src/schema-accounts.ts"],"names":[],"mappings":"AAuBA;;;;GAIG;AACH,eAAO,MAAM,sBAAsB,kGAMjC,CAAA;AAEF,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAgCzB,CA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;;;;;;;;;;;;EAgB1B,CAAA;AAED,MAAM,MAAM,aAAa,GAAG,OAAO,cAAc,CAAC,YAAY,CAAA;AAC9D,MAAM,MAAM,gBAAgB,GAAG,OAAO,cAAc,CAAC,YAAY,CAAA;AAEjE,MAAM,MAAM,YAAY,GAAG,OAAO,aAAa,CAAC,YAAY,CAAA;AAC5D,MAAM,MAAM,eAAe,GAAG,OAAO,aAAa,CAAC,YAAY,CAAA;AAC/D,MAAM,MAAM,MAAM,GAAG,OAAO,MAAM,CAAC,YAAY,CAAA;AAC/C,MAAM,MAAM,SAAS,GAAG,OAAO,MAAM,CAAC,YAAY,CAAA;AAClD,MAAM,MAAM,yBAAyB,GAAG,OAAO,0BAA0B,CAAC,YAAY,CAAA;AACtF,MAAM,MAAM,4BAA4B,GAAG,OAAO,0BAA0B,CAAC,YAAY,CAAA"}
@@ -1,6 +1,6 @@
1
1
  import { typeId, typeIdRef } from "@voyantjs/db/lib/typeid-column";
2
2
  import { sql } from "drizzle-orm";
3
- import { boolean, date, index, integer, jsonb, pgEnum, pgTable, text, timestamp, uniqueIndex, } from "drizzle-orm/pg-core";
3
+ import { boolean, check, date, index, integer, jsonb, pgEnum, pgTable, text, timestamp, uniqueIndex, } from "drizzle-orm/pg-core";
4
4
  import { communicationChannelEnum, communicationDirectionEnum, recordStatusEnum, relationTypeEnum, } from "./schema-shared.js";
5
5
  /**
6
6
  * Identity-document types stored on `person_documents`. Open-ended via
@@ -14,6 +14,27 @@ export const personDocumentTypeEnum = pgEnum("person_document_type", [
14
14
  "visa",
15
15
  "other",
16
16
  ]);
17
+ /**
18
+ * Person-to-person relationship kinds. Directed: each row records a
19
+ * single edge `from → to` of a specific kind. The optional inverse
20
+ * edge (e.g. parent ↔ child) is kept as a separate row so list
21
+ * queries against either side return the same shape; the service
22
+ * layer auto-writes the inverse on insert when an `inverseKind` is
23
+ * provided.
24
+ */
25
+ export const personRelationshipKindEnum = pgEnum("person_relationship_kind", [
26
+ "spouse",
27
+ "partner",
28
+ "parent",
29
+ "child",
30
+ "sibling",
31
+ "guardian",
32
+ "ward",
33
+ "emergency_contact",
34
+ "friend",
35
+ "travel_companion",
36
+ "other",
37
+ ]);
17
38
  export const organizations = pgTable("organizations", {
18
39
  id: typeId("organizations"),
19
40
  name: text("name").notNull(),
@@ -151,6 +172,48 @@ export const personDocuments = pgTable("person_documents", {
151
172
  .on(table.personId, table.type)
152
173
  .where(sql `${table.isPrimary} = true`),
153
174
  ]);
175
+ /**
176
+ * Directed person-to-person edges (kinship, emergency contacts,
177
+ * travel companions). Each row is a single edge `fromPerson → toPerson`
178
+ * of one `kind`; the reverse edge — when meaningful — is a separate
179
+ * row written by the service layer's auto-inverse helper. Self-edges
180
+ * are rejected via a CHECK constraint; the unique index on
181
+ * `(from, to, kind)` prevents the same directional edge from being
182
+ * recorded twice.
183
+ *
184
+ * `metadata` is a free-form jsonb bag for module-specific extensions
185
+ * (e.g. emergency-contact relationship to traveler). Operators that
186
+ * need richer structure should add their own typed columns.
187
+ */
188
+ export const personRelationships = pgTable("person_relationships", {
189
+ id: typeId("person_relationships"),
190
+ fromPersonId: typeIdRef("from_person_id")
191
+ .notNull()
192
+ .references(() => people.id, { onDelete: "cascade" }),
193
+ toPersonId: typeIdRef("to_person_id")
194
+ .notNull()
195
+ .references(() => people.id, { onDelete: "cascade" }),
196
+ kind: personRelationshipKindEnum("kind").notNull(),
197
+ /**
198
+ * The kind that should label the reverse edge (e.g. parent ↔
199
+ * child). When set on insert, the service layer writes the
200
+ * inverse edge in the same transaction unless `autoInverse` is
201
+ * explicitly disabled.
202
+ */
203
+ inverseKind: personRelationshipKindEnum("inverse_kind"),
204
+ startDate: date("start_date"),
205
+ endDate: date("end_date"),
206
+ isPrimary: boolean("is_primary").notNull().default(false),
207
+ notes: text("notes"),
208
+ metadata: jsonb("metadata").$type(),
209
+ createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow(),
210
+ updatedAt: timestamp("updated_at", { withTimezone: true }).notNull().defaultNow(),
211
+ }, (table) => [
212
+ index("idx_person_relationships_from").on(table.fromPersonId),
213
+ index("idx_person_relationships_to").on(table.toPersonId),
214
+ uniqueIndex("uidx_person_relationships_pair_kind").on(table.fromPersonId, table.toPersonId, table.kind),
215
+ check("person_relationships_no_self", sql `${table.fromPersonId} <> ${table.toPersonId}`),
216
+ ]);
154
217
  /**
155
218
  * Saved payment methods on file for a person. Stores processor-issued
156
219
  * tokens (never raw card numbers) so the booking flow can charge the