@voyant-travel/relationships 0.119.2

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.
Files changed (96) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +36 -0
  3. package/dist/action-ledger-capabilities.d.ts +20 -0
  4. package/dist/action-ledger-capabilities.d.ts.map +1 -0
  5. package/dist/action-ledger-capabilities.js +16 -0
  6. package/dist/events.d.ts +23 -0
  7. package/dist/events.d.ts.map +1 -0
  8. package/dist/events.js +9 -0
  9. package/dist/index.d.ts +32 -0
  10. package/dist/index.d.ts.map +1 -0
  11. package/dist/index.js +49 -0
  12. package/dist/route-runtime.d.ts +21 -0
  13. package/dist/route-runtime.d.ts.map +1 -0
  14. package/dist/route-runtime.js +28 -0
  15. package/dist/routes/accounts.d.ts +1460 -0
  16. package/dist/routes/accounts.d.ts.map +1 -0
  17. package/dist/routes/accounts.js +274 -0
  18. package/dist/routes/activities.d.ts +299 -0
  19. package/dist/routes/activities.d.ts.map +1 -0
  20. package/dist/routes/activities.js +64 -0
  21. package/dist/routes/custom-fields.d.ts +256 -0
  22. package/dist/routes/custom-fields.d.ts.map +1 -0
  23. package/dist/routes/custom-fields.js +47 -0
  24. package/dist/routes/customer-signals.d.ts +281 -0
  25. package/dist/routes/customer-signals.d.ts.map +1 -0
  26. package/dist/routes/customer-signals.js +45 -0
  27. package/dist/routes/index.d.ts +2945 -0
  28. package/dist/routes/index.d.ts.map +1 -0
  29. package/dist/routes/index.js +14 -0
  30. package/dist/routes/person-documents.d.ts +519 -0
  31. package/dist/routes/person-documents.d.ts.map +1 -0
  32. package/dist/routes/person-documents.js +240 -0
  33. package/dist/routes/person-relationships.d.ts +189 -0
  34. package/dist/routes/person-relationships.d.ts.map +1 -0
  35. package/dist/routes/person-relationships.js +36 -0
  36. package/dist/schema-accounts.d.ts +2099 -0
  37. package/dist/schema-accounts.d.ts.map +1 -0
  38. package/dist/schema-accounts.js +312 -0
  39. package/dist/schema-activities.d.ts +821 -0
  40. package/dist/schema-activities.d.ts.map +1 -0
  41. package/dist/schema-activities.js +92 -0
  42. package/dist/schema-relations.d.ts +47 -0
  43. package/dist/schema-relations.d.ts.map +1 -0
  44. package/dist/schema-relations.js +70 -0
  45. package/dist/schema-shared.d.ts +10 -0
  46. package/dist/schema-shared.d.ts.map +1 -0
  47. package/dist/schema-shared.js +36 -0
  48. package/dist/schema-signals.d.ts +324 -0
  49. package/dist/schema-signals.d.ts.map +1 -0
  50. package/dist/schema-signals.js +80 -0
  51. package/dist/schema.d.ts +6 -0
  52. package/dist/schema.d.ts.map +1 -0
  53. package/dist/schema.js +5 -0
  54. package/dist/service/accounts-merge.d.ts +63 -0
  55. package/dist/service/accounts-merge.d.ts.map +1 -0
  56. package/dist/service/accounts-merge.js +382 -0
  57. package/dist/service/accounts-organizations.d.ts +97 -0
  58. package/dist/service/accounts-organizations.d.ts.map +1 -0
  59. package/dist/service/accounts-organizations.js +70 -0
  60. package/dist/service/accounts-people.d.ts +1315 -0
  61. package/dist/service/accounts-people.d.ts.map +1 -0
  62. package/dist/service/accounts-people.js +409 -0
  63. package/dist/service/accounts-resolve.d.ts +76 -0
  64. package/dist/service/accounts-resolve.d.ts.map +1 -0
  65. package/dist/service/accounts-resolve.js +103 -0
  66. package/dist/service/accounts-shared.d.ts +68 -0
  67. package/dist/service/accounts-shared.d.ts.map +1 -0
  68. package/dist/service/accounts-shared.js +149 -0
  69. package/dist/service/accounts.d.ts +1465 -0
  70. package/dist/service/accounts.d.ts.map +1 -0
  71. package/dist/service/accounts.js +13 -0
  72. package/dist/service/activities.d.ts +486 -0
  73. package/dist/service/activities.d.ts.map +1 -0
  74. package/dist/service/activities.js +114 -0
  75. package/dist/service/custom-fields.d.ts +118 -0
  76. package/dist/service/custom-fields.d.ts.map +1 -0
  77. package/dist/service/custom-fields.js +88 -0
  78. package/dist/service/customer-signals.d.ts +733 -0
  79. package/dist/service/customer-signals.d.ts.map +1 -0
  80. package/dist/service/customer-signals.js +112 -0
  81. package/dist/service/helpers.d.ts +22 -0
  82. package/dist/service/helpers.d.ts.map +1 -0
  83. package/dist/service/helpers.js +39 -0
  84. package/dist/service/index.d.ts +4434 -0
  85. package/dist/service/index.d.ts.map +1 -0
  86. package/dist/service/index.js +17 -0
  87. package/dist/service/person-documents.d.ts +1201 -0
  88. package/dist/service/person-documents.d.ts.map +1 -0
  89. package/dist/service/person-documents.js +240 -0
  90. package/dist/service/person-relationships.d.ts +502 -0
  91. package/dist/service/person-relationships.d.ts.map +1 -0
  92. package/dist/service/person-relationships.js +121 -0
  93. package/dist/validation.d.ts +3 -0
  94. package/dist/validation.d.ts.map +1 -0
  95. package/dist/validation.js +1 -0
  96. package/package.json +80 -0
@@ -0,0 +1,502 @@
1
+ import type { PostgresJsDatabase } from "drizzle-orm/postgres-js";
2
+ import type { z } from "zod";
3
+ import type { insertPersonRelationshipSchema, personRelationshipListQuerySchema, updatePersonRelationshipSchema } from "../validation.js";
4
+ export type CreatePersonRelationshipInput = z.infer<typeof insertPersonRelationshipSchema>;
5
+ export type UpdatePersonRelationshipInput = z.infer<typeof updatePersonRelationshipSchema>;
6
+ export type PersonRelationshipListQuery = z.infer<typeof personRelationshipListQuerySchema>;
7
+ export type PersonRelationshipKind = CreatePersonRelationshipInput["kind"];
8
+ export declare const personRelationshipsService: {
9
+ /**
10
+ * Lists relationships for a person. Default `direction: "both"`
11
+ * returns the union of outgoing and incoming edges — the typical
12
+ * "Jane's family" UI shape. Use `from` / `to` for one-sided lists.
13
+ */
14
+ listPersonRelationships(db: PostgresJsDatabase, personId: string, query?: PersonRelationshipListQuery): Omit<import("drizzle-orm/pg-core").PgSelectBase<"person_relationships", {
15
+ id: import("drizzle-orm/pg-core").PgColumn<{
16
+ name: string;
17
+ tableName: "person_relationships";
18
+ dataType: "string";
19
+ columnType: "PgText";
20
+ data: string;
21
+ driverParam: string;
22
+ notNull: true;
23
+ hasDefault: true;
24
+ isPrimaryKey: true;
25
+ isAutoincrement: false;
26
+ hasRuntimeDefault: true;
27
+ enumValues: [string, ...string[]];
28
+ baseColumn: never;
29
+ identity: undefined;
30
+ generated: undefined;
31
+ }, {}, {}>;
32
+ fromPersonId: import("drizzle-orm/pg-core").PgColumn<{
33
+ name: string;
34
+ tableName: "person_relationships";
35
+ dataType: "string";
36
+ columnType: "PgText";
37
+ data: string;
38
+ driverParam: string;
39
+ notNull: true;
40
+ hasDefault: false;
41
+ isPrimaryKey: false;
42
+ isAutoincrement: false;
43
+ hasRuntimeDefault: false;
44
+ enumValues: [string, ...string[]];
45
+ baseColumn: never;
46
+ identity: undefined;
47
+ generated: undefined;
48
+ }, {}, {}>;
49
+ toPersonId: import("drizzle-orm/pg-core").PgColumn<{
50
+ name: string;
51
+ tableName: "person_relationships";
52
+ dataType: "string";
53
+ columnType: "PgText";
54
+ data: string;
55
+ driverParam: string;
56
+ notNull: true;
57
+ hasDefault: false;
58
+ isPrimaryKey: false;
59
+ isAutoincrement: false;
60
+ hasRuntimeDefault: false;
61
+ enumValues: [string, ...string[]];
62
+ baseColumn: never;
63
+ identity: undefined;
64
+ generated: undefined;
65
+ }, {}, {}>;
66
+ kind: import("drizzle-orm/pg-core").PgColumn<{
67
+ name: "kind";
68
+ tableName: "person_relationships";
69
+ dataType: "string";
70
+ columnType: "PgEnumColumn";
71
+ data: "other" | "partner" | "spouse" | "parent" | "child" | "sibling" | "guardian" | "ward" | "emergency_contact" | "friend" | "travel_companion";
72
+ driverParam: string;
73
+ notNull: true;
74
+ hasDefault: false;
75
+ isPrimaryKey: false;
76
+ isAutoincrement: false;
77
+ hasRuntimeDefault: false;
78
+ enumValues: ["spouse", "partner", "parent", "child", "sibling", "guardian", "ward", "emergency_contact", "friend", "travel_companion", "other"];
79
+ baseColumn: never;
80
+ identity: undefined;
81
+ generated: undefined;
82
+ }, {}, {}>;
83
+ inverseKind: import("drizzle-orm/pg-core").PgColumn<{
84
+ name: "inverse_kind";
85
+ tableName: "person_relationships";
86
+ dataType: "string";
87
+ columnType: "PgEnumColumn";
88
+ data: "other" | "partner" | "spouse" | "parent" | "child" | "sibling" | "guardian" | "ward" | "emergency_contact" | "friend" | "travel_companion";
89
+ driverParam: string;
90
+ notNull: false;
91
+ hasDefault: false;
92
+ isPrimaryKey: false;
93
+ isAutoincrement: false;
94
+ hasRuntimeDefault: false;
95
+ enumValues: ["spouse", "partner", "parent", "child", "sibling", "guardian", "ward", "emergency_contact", "friend", "travel_companion", "other"];
96
+ baseColumn: never;
97
+ identity: undefined;
98
+ generated: undefined;
99
+ }, {}, {}>;
100
+ startDate: import("drizzle-orm/pg-core").PgColumn<{
101
+ name: "start_date";
102
+ tableName: "person_relationships";
103
+ dataType: "string";
104
+ columnType: "PgDateString";
105
+ data: string;
106
+ driverParam: string;
107
+ notNull: false;
108
+ hasDefault: false;
109
+ isPrimaryKey: false;
110
+ isAutoincrement: false;
111
+ hasRuntimeDefault: false;
112
+ enumValues: undefined;
113
+ baseColumn: never;
114
+ identity: undefined;
115
+ generated: undefined;
116
+ }, {}, {}>;
117
+ endDate: import("drizzle-orm/pg-core").PgColumn<{
118
+ name: "end_date";
119
+ tableName: "person_relationships";
120
+ dataType: "string";
121
+ columnType: "PgDateString";
122
+ data: string;
123
+ driverParam: string;
124
+ notNull: false;
125
+ hasDefault: false;
126
+ isPrimaryKey: false;
127
+ isAutoincrement: false;
128
+ hasRuntimeDefault: false;
129
+ enumValues: undefined;
130
+ baseColumn: never;
131
+ identity: undefined;
132
+ generated: undefined;
133
+ }, {}, {}>;
134
+ isPrimary: import("drizzle-orm/pg-core").PgColumn<{
135
+ name: "is_primary";
136
+ tableName: "person_relationships";
137
+ dataType: "boolean";
138
+ columnType: "PgBoolean";
139
+ data: boolean;
140
+ driverParam: boolean;
141
+ notNull: true;
142
+ hasDefault: true;
143
+ isPrimaryKey: false;
144
+ isAutoincrement: false;
145
+ hasRuntimeDefault: false;
146
+ enumValues: undefined;
147
+ baseColumn: never;
148
+ identity: undefined;
149
+ generated: undefined;
150
+ }, {}, {}>;
151
+ notes: import("drizzle-orm/pg-core").PgColumn<{
152
+ name: "notes";
153
+ tableName: "person_relationships";
154
+ dataType: "string";
155
+ columnType: "PgText";
156
+ data: string;
157
+ driverParam: string;
158
+ notNull: false;
159
+ hasDefault: false;
160
+ isPrimaryKey: false;
161
+ isAutoincrement: false;
162
+ hasRuntimeDefault: false;
163
+ enumValues: [string, ...string[]];
164
+ baseColumn: never;
165
+ identity: undefined;
166
+ generated: undefined;
167
+ }, {}, {}>;
168
+ metadata: import("drizzle-orm/pg-core").PgColumn<{
169
+ name: "metadata";
170
+ tableName: "person_relationships";
171
+ dataType: "json";
172
+ columnType: "PgJsonb";
173
+ data: Record<string, unknown>;
174
+ driverParam: unknown;
175
+ notNull: false;
176
+ hasDefault: false;
177
+ isPrimaryKey: false;
178
+ isAutoincrement: false;
179
+ hasRuntimeDefault: false;
180
+ enumValues: undefined;
181
+ baseColumn: never;
182
+ identity: undefined;
183
+ generated: undefined;
184
+ }, {}, {
185
+ $type: Record<string, unknown>;
186
+ }>;
187
+ createdAt: import("drizzle-orm/pg-core").PgColumn<{
188
+ name: "created_at";
189
+ tableName: "person_relationships";
190
+ dataType: "date";
191
+ columnType: "PgTimestamp";
192
+ data: Date;
193
+ driverParam: string;
194
+ notNull: true;
195
+ hasDefault: true;
196
+ isPrimaryKey: false;
197
+ isAutoincrement: false;
198
+ hasRuntimeDefault: false;
199
+ enumValues: undefined;
200
+ baseColumn: never;
201
+ identity: undefined;
202
+ generated: undefined;
203
+ }, {}, {}>;
204
+ updatedAt: import("drizzle-orm/pg-core").PgColumn<{
205
+ name: "updated_at";
206
+ tableName: "person_relationships";
207
+ dataType: "date";
208
+ columnType: "PgTimestamp";
209
+ data: Date;
210
+ driverParam: string;
211
+ notNull: true;
212
+ hasDefault: true;
213
+ isPrimaryKey: false;
214
+ isAutoincrement: false;
215
+ hasRuntimeDefault: false;
216
+ enumValues: undefined;
217
+ baseColumn: never;
218
+ identity: undefined;
219
+ generated: undefined;
220
+ }, {}, {}>;
221
+ }, "single", Record<"person_relationships", "not-null">, false, "where" | "orderBy" | "limit" | "offset", {
222
+ id: string;
223
+ fromPersonId: string;
224
+ toPersonId: string;
225
+ kind: "other" | "partner" | "spouse" | "parent" | "child" | "sibling" | "guardian" | "ward" | "emergency_contact" | "friend" | "travel_companion";
226
+ inverseKind: "other" | "partner" | "spouse" | "parent" | "child" | "sibling" | "guardian" | "ward" | "emergency_contact" | "friend" | "travel_companion" | null;
227
+ startDate: string | null;
228
+ endDate: string | null;
229
+ isPrimary: boolean;
230
+ notes: string | null;
231
+ metadata: Record<string, unknown> | null;
232
+ createdAt: Date;
233
+ updatedAt: Date;
234
+ }[], {
235
+ id: import("drizzle-orm/pg-core").PgColumn<{
236
+ name: string;
237
+ tableName: "person_relationships";
238
+ dataType: "string";
239
+ columnType: "PgText";
240
+ data: string;
241
+ driverParam: string;
242
+ notNull: true;
243
+ hasDefault: true;
244
+ isPrimaryKey: true;
245
+ isAutoincrement: false;
246
+ hasRuntimeDefault: true;
247
+ enumValues: [string, ...string[]];
248
+ baseColumn: never;
249
+ identity: undefined;
250
+ generated: undefined;
251
+ }, {}, {}>;
252
+ fromPersonId: import("drizzle-orm/pg-core").PgColumn<{
253
+ name: string;
254
+ tableName: "person_relationships";
255
+ dataType: "string";
256
+ columnType: "PgText";
257
+ data: string;
258
+ driverParam: string;
259
+ notNull: true;
260
+ hasDefault: false;
261
+ isPrimaryKey: false;
262
+ isAutoincrement: false;
263
+ hasRuntimeDefault: false;
264
+ enumValues: [string, ...string[]];
265
+ baseColumn: never;
266
+ identity: undefined;
267
+ generated: undefined;
268
+ }, {}, {}>;
269
+ toPersonId: import("drizzle-orm/pg-core").PgColumn<{
270
+ name: string;
271
+ tableName: "person_relationships";
272
+ dataType: "string";
273
+ columnType: "PgText";
274
+ data: string;
275
+ driverParam: string;
276
+ notNull: true;
277
+ hasDefault: false;
278
+ isPrimaryKey: false;
279
+ isAutoincrement: false;
280
+ hasRuntimeDefault: false;
281
+ enumValues: [string, ...string[]];
282
+ baseColumn: never;
283
+ identity: undefined;
284
+ generated: undefined;
285
+ }, {}, {}>;
286
+ kind: import("drizzle-orm/pg-core").PgColumn<{
287
+ name: "kind";
288
+ tableName: "person_relationships";
289
+ dataType: "string";
290
+ columnType: "PgEnumColumn";
291
+ data: "other" | "partner" | "spouse" | "parent" | "child" | "sibling" | "guardian" | "ward" | "emergency_contact" | "friend" | "travel_companion";
292
+ driverParam: string;
293
+ notNull: true;
294
+ hasDefault: false;
295
+ isPrimaryKey: false;
296
+ isAutoincrement: false;
297
+ hasRuntimeDefault: false;
298
+ enumValues: ["spouse", "partner", "parent", "child", "sibling", "guardian", "ward", "emergency_contact", "friend", "travel_companion", "other"];
299
+ baseColumn: never;
300
+ identity: undefined;
301
+ generated: undefined;
302
+ }, {}, {}>;
303
+ inverseKind: import("drizzle-orm/pg-core").PgColumn<{
304
+ name: "inverse_kind";
305
+ tableName: "person_relationships";
306
+ dataType: "string";
307
+ columnType: "PgEnumColumn";
308
+ data: "other" | "partner" | "spouse" | "parent" | "child" | "sibling" | "guardian" | "ward" | "emergency_contact" | "friend" | "travel_companion";
309
+ driverParam: string;
310
+ notNull: false;
311
+ hasDefault: false;
312
+ isPrimaryKey: false;
313
+ isAutoincrement: false;
314
+ hasRuntimeDefault: false;
315
+ enumValues: ["spouse", "partner", "parent", "child", "sibling", "guardian", "ward", "emergency_contact", "friend", "travel_companion", "other"];
316
+ baseColumn: never;
317
+ identity: undefined;
318
+ generated: undefined;
319
+ }, {}, {}>;
320
+ startDate: import("drizzle-orm/pg-core").PgColumn<{
321
+ name: "start_date";
322
+ tableName: "person_relationships";
323
+ dataType: "string";
324
+ columnType: "PgDateString";
325
+ data: string;
326
+ driverParam: string;
327
+ notNull: false;
328
+ hasDefault: false;
329
+ isPrimaryKey: false;
330
+ isAutoincrement: false;
331
+ hasRuntimeDefault: false;
332
+ enumValues: undefined;
333
+ baseColumn: never;
334
+ identity: undefined;
335
+ generated: undefined;
336
+ }, {}, {}>;
337
+ endDate: import("drizzle-orm/pg-core").PgColumn<{
338
+ name: "end_date";
339
+ tableName: "person_relationships";
340
+ dataType: "string";
341
+ columnType: "PgDateString";
342
+ data: string;
343
+ driverParam: string;
344
+ notNull: false;
345
+ hasDefault: false;
346
+ isPrimaryKey: false;
347
+ isAutoincrement: false;
348
+ hasRuntimeDefault: false;
349
+ enumValues: undefined;
350
+ baseColumn: never;
351
+ identity: undefined;
352
+ generated: undefined;
353
+ }, {}, {}>;
354
+ isPrimary: import("drizzle-orm/pg-core").PgColumn<{
355
+ name: "is_primary";
356
+ tableName: "person_relationships";
357
+ dataType: "boolean";
358
+ columnType: "PgBoolean";
359
+ data: boolean;
360
+ driverParam: boolean;
361
+ notNull: true;
362
+ hasDefault: true;
363
+ isPrimaryKey: false;
364
+ isAutoincrement: false;
365
+ hasRuntimeDefault: false;
366
+ enumValues: undefined;
367
+ baseColumn: never;
368
+ identity: undefined;
369
+ generated: undefined;
370
+ }, {}, {}>;
371
+ notes: import("drizzle-orm/pg-core").PgColumn<{
372
+ name: "notes";
373
+ tableName: "person_relationships";
374
+ dataType: "string";
375
+ columnType: "PgText";
376
+ data: string;
377
+ driverParam: string;
378
+ notNull: false;
379
+ hasDefault: false;
380
+ isPrimaryKey: false;
381
+ isAutoincrement: false;
382
+ hasRuntimeDefault: false;
383
+ enumValues: [string, ...string[]];
384
+ baseColumn: never;
385
+ identity: undefined;
386
+ generated: undefined;
387
+ }, {}, {}>;
388
+ metadata: import("drizzle-orm/pg-core").PgColumn<{
389
+ name: "metadata";
390
+ tableName: "person_relationships";
391
+ dataType: "json";
392
+ columnType: "PgJsonb";
393
+ data: Record<string, unknown>;
394
+ driverParam: unknown;
395
+ notNull: false;
396
+ hasDefault: false;
397
+ isPrimaryKey: false;
398
+ isAutoincrement: false;
399
+ hasRuntimeDefault: false;
400
+ enumValues: undefined;
401
+ baseColumn: never;
402
+ identity: undefined;
403
+ generated: undefined;
404
+ }, {}, {
405
+ $type: Record<string, unknown>;
406
+ }>;
407
+ createdAt: import("drizzle-orm/pg-core").PgColumn<{
408
+ name: "created_at";
409
+ tableName: "person_relationships";
410
+ dataType: "date";
411
+ columnType: "PgTimestamp";
412
+ data: Date;
413
+ driverParam: string;
414
+ notNull: true;
415
+ hasDefault: true;
416
+ isPrimaryKey: false;
417
+ isAutoincrement: false;
418
+ hasRuntimeDefault: false;
419
+ enumValues: undefined;
420
+ baseColumn: never;
421
+ identity: undefined;
422
+ generated: undefined;
423
+ }, {}, {}>;
424
+ updatedAt: import("drizzle-orm/pg-core").PgColumn<{
425
+ name: "updated_at";
426
+ tableName: "person_relationships";
427
+ dataType: "date";
428
+ columnType: "PgTimestamp";
429
+ data: Date;
430
+ driverParam: string;
431
+ notNull: true;
432
+ hasDefault: true;
433
+ isPrimaryKey: false;
434
+ isAutoincrement: false;
435
+ hasRuntimeDefault: false;
436
+ enumValues: undefined;
437
+ baseColumn: never;
438
+ identity: undefined;
439
+ generated: undefined;
440
+ }, {}, {}>;
441
+ }>, "where" | "orderBy" | "limit" | "offset">;
442
+ getPersonRelationship(db: PostgresJsDatabase, id: string): Promise<{
443
+ id: string;
444
+ fromPersonId: string;
445
+ toPersonId: string;
446
+ kind: "other" | "partner" | "spouse" | "parent" | "child" | "sibling" | "guardian" | "ward" | "emergency_contact" | "friend" | "travel_companion";
447
+ inverseKind: "other" | "partner" | "spouse" | "parent" | "child" | "sibling" | "guardian" | "ward" | "emergency_contact" | "friend" | "travel_companion" | null;
448
+ startDate: string | null;
449
+ endDate: string | null;
450
+ isPrimary: boolean;
451
+ notes: string | null;
452
+ metadata: Record<string, unknown> | null;
453
+ createdAt: Date;
454
+ updatedAt: Date;
455
+ } | null>;
456
+ /**
457
+ * Inserts a directed edge `fromPerson → toPerson` of `data.kind`.
458
+ * When `data.inverseKind` is provided AND `data.autoInverse` is
459
+ * not explicitly false, also inserts the symmetric
460
+ * `toPerson → fromPerson` edge with `kind = inverseKind` (and
461
+ * `inverseKind` swapped back). The pair is written in a single
462
+ * transaction so a failed inverse rolls the primary back.
463
+ *
464
+ * The inverse insert is idempotent — if the symmetric edge
465
+ * already exists, the `(from, to, kind)` unique index would
466
+ * normally throw; we suppress that case so retrying a partially
467
+ * applied operation doesn't fail. Any other DB error still
468
+ * propagates.
469
+ */
470
+ createPersonRelationship(db: PostgresJsDatabase, fromPersonId: string, data: CreatePersonRelationshipInput): Promise<{
471
+ id: string;
472
+ createdAt: Date;
473
+ metadata: Record<string, unknown> | null;
474
+ startDate: string | null;
475
+ endDate: string | null;
476
+ notes: string | null;
477
+ updatedAt: Date;
478
+ kind: "other" | "partner" | "spouse" | "parent" | "child" | "sibling" | "guardian" | "ward" | "emergency_contact" | "friend" | "travel_companion";
479
+ isPrimary: boolean;
480
+ fromPersonId: string;
481
+ toPersonId: string;
482
+ inverseKind: "other" | "partner" | "spouse" | "parent" | "child" | "sibling" | "guardian" | "ward" | "emergency_contact" | "friend" | "travel_companion" | null;
483
+ } | null>;
484
+ updatePersonRelationship(db: PostgresJsDatabase, id: string, data: UpdatePersonRelationshipInput): Promise<{
485
+ id: string;
486
+ fromPersonId: string;
487
+ toPersonId: string;
488
+ kind: "other" | "partner" | "spouse" | "parent" | "child" | "sibling" | "guardian" | "ward" | "emergency_contact" | "friend" | "travel_companion";
489
+ inverseKind: "other" | "partner" | "spouse" | "parent" | "child" | "sibling" | "guardian" | "ward" | "emergency_contact" | "friend" | "travel_companion" | null;
490
+ startDate: string | null;
491
+ endDate: string | null;
492
+ isPrimary: boolean;
493
+ notes: string | null;
494
+ metadata: Record<string, unknown> | null;
495
+ createdAt: Date;
496
+ updatedAt: Date;
497
+ } | null>;
498
+ deletePersonRelationship(db: PostgresJsDatabase, id: string): Promise<{
499
+ id: string;
500
+ } | null>;
501
+ };
502
+ //# sourceMappingURL=person-relationships.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"person-relationships.d.ts","sourceRoot":"","sources":["../../src/service/person-relationships.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAA;AACjE,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAG5B,OAAO,KAAK,EACV,8BAA8B,EAC9B,iCAAiC,EACjC,8BAA8B,EAC/B,MAAM,kBAAkB,CAAA;AAEzB,MAAM,MAAM,6BAA6B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,8BAA8B,CAAC,CAAA;AAC1F,MAAM,MAAM,6BAA6B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,8BAA8B,CAAC,CAAA;AAC1F,MAAM,MAAM,2BAA2B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,iCAAiC,CAAC,CAAA;AAC3F,MAAM,MAAM,sBAAsB,GAAG,6BAA6B,CAAC,MAAM,CAAC,CAAA;AAW1E,eAAO,MAAM,0BAA0B;IACrC;;;;OAIG;gCAEG,kBAAkB,YACZ,MAAM,UACR,2BAA2B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;8BA8BL,kBAAkB,MAAM,MAAM;;;;;;;;;;;;;;IAS9D;;;;;;;;;;;;;OAaG;iCAEG,kBAAkB,gBACR,MAAM,QACd,6BAA6B;;;;;;;;;;;;;;iCAiD/B,kBAAkB,MAClB,MAAM,QACJ,6BAA6B;;;;;;;;;;;;;;iCAUF,kBAAkB,MAAM,MAAM;;;CAOlE,CAAA"}
@@ -0,0 +1,121 @@
1
+ import { and, asc, eq, or } from "drizzle-orm";
2
+ import { people, personRelationships } from "../schema.js";
3
+ async function personExists(db, personId) {
4
+ const [row] = await db
5
+ .select({ id: people.id })
6
+ .from(people)
7
+ .where(eq(people.id, personId))
8
+ .limit(1);
9
+ return Boolean(row);
10
+ }
11
+ export const personRelationshipsService = {
12
+ /**
13
+ * Lists relationships for a person. Default `direction: "both"`
14
+ * returns the union of outgoing and incoming edges — the typical
15
+ * "Jane's family" UI shape. Use `from` / `to` for one-sided lists.
16
+ */
17
+ listPersonRelationships(db, personId, query) {
18
+ const direction = query?.direction ?? "both";
19
+ const directionFilter = direction === "from"
20
+ ? eq(personRelationships.fromPersonId, personId)
21
+ : direction === "to"
22
+ ? eq(personRelationships.toPersonId, personId)
23
+ : or(eq(personRelationships.fromPersonId, personId), eq(personRelationships.toPersonId, personId));
24
+ const conditions = [directionFilter];
25
+ if (query?.kind) {
26
+ conditions.push(eq(personRelationships.kind, query.kind));
27
+ }
28
+ const limit = query?.limit ?? 50;
29
+ const offset = query?.offset ?? 0;
30
+ return db
31
+ .select()
32
+ .from(personRelationships)
33
+ .where(and(...conditions))
34
+ .orderBy(asc(personRelationships.createdAt))
35
+ .limit(limit)
36
+ .offset(offset);
37
+ },
38
+ async getPersonRelationship(db, id) {
39
+ const [row] = await db
40
+ .select()
41
+ .from(personRelationships)
42
+ .where(eq(personRelationships.id, id))
43
+ .limit(1);
44
+ return row ?? null;
45
+ },
46
+ /**
47
+ * Inserts a directed edge `fromPerson → toPerson` of `data.kind`.
48
+ * When `data.inverseKind` is provided AND `data.autoInverse` is
49
+ * not explicitly false, also inserts the symmetric
50
+ * `toPerson → fromPerson` edge with `kind = inverseKind` (and
51
+ * `inverseKind` swapped back). The pair is written in a single
52
+ * transaction so a failed inverse rolls the primary back.
53
+ *
54
+ * The inverse insert is idempotent — if the symmetric edge
55
+ * already exists, the `(from, to, kind)` unique index would
56
+ * normally throw; we suppress that case so retrying a partially
57
+ * applied operation doesn't fail. Any other DB error still
58
+ * propagates.
59
+ */
60
+ async createPersonRelationship(db, fromPersonId, data) {
61
+ if (fromPersonId === data.toPersonId)
62
+ return null;
63
+ if (!(await personExists(db, fromPersonId)))
64
+ return null;
65
+ if (!(await personExists(db, data.toPersonId)))
66
+ return null;
67
+ const { toPersonId, autoInverse: autoInverseInput, inverseKind, ...rest } = data;
68
+ const autoInverse = autoInverseInput !== false;
69
+ return db.transaction(async (tx) => {
70
+ const [primary] = await tx
71
+ .insert(personRelationships)
72
+ .values({
73
+ ...rest,
74
+ inverseKind: inverseKind ?? null,
75
+ fromPersonId,
76
+ toPersonId,
77
+ })
78
+ .returning();
79
+ if (!primary)
80
+ return null;
81
+ if (autoInverse && inverseKind) {
82
+ await tx
83
+ .insert(personRelationships)
84
+ .values({
85
+ fromPersonId: toPersonId,
86
+ toPersonId: fromPersonId,
87
+ kind: inverseKind,
88
+ inverseKind: rest.kind,
89
+ startDate: rest.startDate ?? null,
90
+ endDate: rest.endDate ?? null,
91
+ isPrimary: rest.isPrimary,
92
+ notes: rest.notes ?? null,
93
+ metadata: rest.metadata ?? null,
94
+ })
95
+ .onConflictDoNothing({
96
+ target: [
97
+ personRelationships.fromPersonId,
98
+ personRelationships.toPersonId,
99
+ personRelationships.kind,
100
+ ],
101
+ });
102
+ }
103
+ return primary;
104
+ });
105
+ },
106
+ async updatePersonRelationship(db, id, data) {
107
+ const [row] = await db
108
+ .update(personRelationships)
109
+ .set({ ...data, updatedAt: new Date() })
110
+ .where(eq(personRelationships.id, id))
111
+ .returning();
112
+ return row ?? null;
113
+ },
114
+ async deletePersonRelationship(db, id) {
115
+ const [row] = await db
116
+ .delete(personRelationships)
117
+ .where(eq(personRelationships.id, id))
118
+ .returning({ id: personRelationships.id });
119
+ return row ?? null;
120
+ },
121
+ };
@@ -0,0 +1,3 @@
1
+ export type { CustomerSignalInput, CustomerSignalListQueryInput, CustomerSignalUpdate, InsertPersonPaymentMethodInput, PersonDocumentInput, PersonDocumentPlaintextInput, PersonDocumentPlaintextUpdate, PersonDocumentUpdate, PersonRelationshipInput, PersonRelationshipListQueryInput, PersonRelationshipUpdate, ResolveCustomerSignalInput, UpdatePersonPaymentMethodInput, UpdatePersonProfilePiiInput, } from "@voyant-travel/crm-contracts";
2
+ export { activityCoreSchema, activityLinkRoleSchema, activityListQuerySchema, activityStatusSchema, activityTypeSchema, communicationChannelSchema, communicationDirectionSchema, communicationListQuerySchema, customerSignalKindSchema, customerSignalListQuerySchema, customerSignalPrioritySchema, customerSignalSourceSchema, customerSignalStatusSchema, customFieldDefinitionCoreSchema, customFieldDefinitionListQuerySchema, customFieldTypeSchema, customFieldValueListQuerySchema, entityTypeSchema, insertActivityLinkSchema, insertActivityParticipantSchema, insertActivitySchema, insertCommunicationLogSchema, insertCustomerSignalSchema, insertCustomFieldDefinitionSchema, insertOrganizationNoteSchema, insertOrganizationSchema, insertPersonDocumentFromPlaintextSchema, insertPersonDocumentSchema, insertPersonNoteSchema, insertPersonPaymentMethodSchema, insertPersonRelationshipSchema, insertPersonSchema, insertSegmentSchema, mergeOrganizationSchema, mergePersonSchema, organizationCoreSchema, organizationListQuerySchema, organizationListSortDirSchema, organizationListSortFieldSchema, paymentMethodBrandSchema, personCoreSchema, personDocumentCoreSchema, personDocumentListQuerySchema, personDocumentTypeSchema, personListQuerySchema, personListSortDirSchema, personListSortFieldSchema, personRelationshipKindSchema, personRelationshipListQuerySchema, recordStatusSchema, relationTypeSchema, resolveCustomerSignalSchema, updateActivitySchema, updateCustomerSignalSchema, updateCustomFieldDefinitionSchema, updateOrganizationNoteSchema, updateOrganizationSchema, updatePersonDocumentFromPlaintextSchema, updatePersonDocumentSchema, updatePersonNoteSchema, updatePersonPaymentMethodSchema, updatePersonProfilePiiSchema, updatePersonRelationshipSchema, updatePersonSchema, upsertCustomFieldValueSchema, } from "@voyant-travel/crm-contracts";
3
+ //# sourceMappingURL=validation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validation.d.ts","sourceRoot":"","sources":["../src/validation.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,mBAAmB,EACnB,4BAA4B,EAC5B,oBAAoB,EACpB,8BAA8B,EAC9B,mBAAmB,EACnB,4BAA4B,EAC5B,6BAA6B,EAC7B,oBAAoB,EACpB,uBAAuB,EACvB,gCAAgC,EAChC,wBAAwB,EACxB,0BAA0B,EAC1B,8BAA8B,EAC9B,2BAA2B,GAC5B,MAAM,8BAA8B,CAAA;AACrC,OAAO,EACL,kBAAkB,EAClB,sBAAsB,EACtB,uBAAuB,EACvB,oBAAoB,EACpB,kBAAkB,EAClB,0BAA0B,EAC1B,4BAA4B,EAC5B,4BAA4B,EAC5B,wBAAwB,EACxB,6BAA6B,EAC7B,4BAA4B,EAC5B,0BAA0B,EAC1B,0BAA0B,EAC1B,+BAA+B,EAC/B,oCAAoC,EACpC,qBAAqB,EACrB,+BAA+B,EAC/B,gBAAgB,EAChB,wBAAwB,EACxB,+BAA+B,EAC/B,oBAAoB,EACpB,4BAA4B,EAC5B,0BAA0B,EAC1B,iCAAiC,EACjC,4BAA4B,EAC5B,wBAAwB,EACxB,uCAAuC,EACvC,0BAA0B,EAC1B,sBAAsB,EACtB,+BAA+B,EAC/B,8BAA8B,EAC9B,kBAAkB,EAClB,mBAAmB,EACnB,uBAAuB,EACvB,iBAAiB,EACjB,sBAAsB,EACtB,2BAA2B,EAC3B,6BAA6B,EAC7B,+BAA+B,EAC/B,wBAAwB,EACxB,gBAAgB,EAChB,wBAAwB,EACxB,6BAA6B,EAC7B,wBAAwB,EACxB,qBAAqB,EACrB,uBAAuB,EACvB,yBAAyB,EACzB,4BAA4B,EAC5B,iCAAiC,EACjC,kBAAkB,EAClB,kBAAkB,EAClB,2BAA2B,EAC3B,oBAAoB,EACpB,0BAA0B,EAC1B,iCAAiC,EACjC,4BAA4B,EAC5B,wBAAwB,EACxB,uCAAuC,EACvC,0BAA0B,EAC1B,sBAAsB,EACtB,+BAA+B,EAC/B,4BAA4B,EAC5B,8BAA8B,EAC9B,kBAAkB,EAClB,4BAA4B,GAC7B,MAAM,8BAA8B,CAAA"}
@@ -0,0 +1 @@
1
+ export { activityCoreSchema, activityLinkRoleSchema, activityListQuerySchema, activityStatusSchema, activityTypeSchema, communicationChannelSchema, communicationDirectionSchema, communicationListQuerySchema, customerSignalKindSchema, customerSignalListQuerySchema, customerSignalPrioritySchema, customerSignalSourceSchema, customerSignalStatusSchema, customFieldDefinitionCoreSchema, customFieldDefinitionListQuerySchema, customFieldTypeSchema, customFieldValueListQuerySchema, entityTypeSchema, insertActivityLinkSchema, insertActivityParticipantSchema, insertActivitySchema, insertCommunicationLogSchema, insertCustomerSignalSchema, insertCustomFieldDefinitionSchema, insertOrganizationNoteSchema, insertOrganizationSchema, insertPersonDocumentFromPlaintextSchema, insertPersonDocumentSchema, insertPersonNoteSchema, insertPersonPaymentMethodSchema, insertPersonRelationshipSchema, insertPersonSchema, insertSegmentSchema, mergeOrganizationSchema, mergePersonSchema, organizationCoreSchema, organizationListQuerySchema, organizationListSortDirSchema, organizationListSortFieldSchema, paymentMethodBrandSchema, personCoreSchema, personDocumentCoreSchema, personDocumentListQuerySchema, personDocumentTypeSchema, personListQuerySchema, personListSortDirSchema, personListSortFieldSchema, personRelationshipKindSchema, personRelationshipListQuerySchema, recordStatusSchema, relationTypeSchema, resolveCustomerSignalSchema, updateActivitySchema, updateCustomerSignalSchema, updateCustomFieldDefinitionSchema, updateOrganizationNoteSchema, updateOrganizationSchema, updatePersonDocumentFromPlaintextSchema, updatePersonDocumentSchema, updatePersonNoteSchema, updatePersonPaymentMethodSchema, updatePersonProfilePiiSchema, updatePersonRelationshipSchema, updatePersonSchema, upsertCustomFieldValueSchema, } from "@voyant-travel/crm-contracts";