@surveilr/bootstrap-sql 0.0.1

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,1315 @@
1
+ // models.ts
2
+ import {
3
+ blob,
4
+ check,
5
+ customType,
6
+ foreignKey,
7
+ index,
8
+ integer,
9
+ numeric,
10
+ real,
11
+ sqliteTable as table,
12
+ text,
13
+ unique
14
+ } from "drizzle-orm/sqlite-core";
15
+ import { sql } from "drizzle-orm";
16
+ var timestamptz = customType({
17
+ dataType() {
18
+ return "TIMESTAMPTZ";
19
+ },
20
+ fromDriver(value) {
21
+ return value;
22
+ },
23
+ toDriver(value) {
24
+ return value;
25
+ }
26
+ });
27
+ var date = customType({
28
+ dataType() {
29
+ return "DATE";
30
+ },
31
+ fromDriver(value) {
32
+ return value;
33
+ },
34
+ toDriver(value) {
35
+ return value;
36
+ }
37
+ });
38
+ var ulid = customType({
39
+ dataType() {
40
+ return "ULID";
41
+ },
42
+ fromDriver(value) {
43
+ return value;
44
+ },
45
+ toDriver(value) {
46
+ return value;
47
+ }
48
+ });
49
+ var varchar = customType({
50
+ dataType() {
51
+ return "VARCHAR";
52
+ },
53
+ fromDriver(value) {
54
+ return value;
55
+ },
56
+ toDriver(value) {
57
+ return value;
58
+ }
59
+ });
60
+ var textArray = customType({
61
+ dataType() {
62
+ return "TEXT[]";
63
+ },
64
+ fromDriver(value) {
65
+ return JSON.parse(value);
66
+ },
67
+ toDriver(value) {
68
+ return JSON.stringify(value);
69
+ }
70
+ });
71
+ var housekeeping = {
72
+ createdAt: timestamptz("created_at").default(sql`CURRENT_TIMESTAMP`),
73
+ createdBy: text("created_by").default("UNKNOWN"),
74
+ updatedAt: timestamptz("updated_at"),
75
+ updatedBy: text("updated_by"),
76
+ deletedAt: timestamptz("deleted_at"),
77
+ deletedBy: text("deleted_by"),
78
+ activityLog: text("activity_log")
79
+ };
80
+ var sqleanDefine = table("sqlean_define", {
81
+ name: text().primaryKey(),
82
+ type: text(),
83
+ body: text()
84
+ }, (table2) => []);
85
+ var checkJSON = (c) => check(`${c.name}_check_valid_json`, sql`json_valid(${c}) OR ${c} IS NULL`);
86
+ var assuranceSchema = table("assurance_schema", {
87
+ assuranceSchemaId: varchar("assurance_schema_id").primaryKey().notNull(),
88
+ assuranceType: text("assurance_type").notNull(),
89
+ code: text().notNull(),
90
+ codeJson: text("code_json", { mode: "json" }),
91
+ governance: text(),
92
+ ...housekeeping
93
+ }, (table2) => [
94
+ checkJSON(table2.codeJson),
95
+ checkJSON(table2.governance)
96
+ ]);
97
+ var device = table("device", {
98
+ deviceId: varchar("device_id").primaryKey().notNull(),
99
+ name: text().notNull(),
100
+ state: text().notNull(),
101
+ boundary: text().notNull(),
102
+ segmentation: text(),
103
+ stateSysinfo: text("state_sysinfo"),
104
+ elaboration: text(),
105
+ ...housekeeping
106
+ }, (table2) => [
107
+ index("idx_device__name__state").on(table2.name, table2.state),
108
+ unique().on(table2.name, table2.state, table2.boundary),
109
+ checkJSON(table2.state),
110
+ checkJSON(table2.segmentation),
111
+ checkJSON(table2.stateSysinfo),
112
+ checkJSON(table2.elaboration)
113
+ ]);
114
+ var codeNotebookKernel = table("code_notebook_kernel", {
115
+ codeNotebookKernelId: varchar("code_notebook_kernel_id").primaryKey().notNull(),
116
+ kernelName: text("kernel_name").notNull(),
117
+ description: text(),
118
+ mimeType: text("mime_type"),
119
+ fileExtn: text("file_extn"),
120
+ elaboration: text(),
121
+ governance: text(),
122
+ ...housekeeping
123
+ }, (table2) => [
124
+ unique().on(table2.kernelName),
125
+ checkJSON(table2.elaboration),
126
+ checkJSON(table2.governance)
127
+ ]);
128
+ var codeNotebookCell = table("code_notebook_cell", {
129
+ codeNotebookCellId: varchar("code_notebook_cell_id").primaryKey().notNull(),
130
+ notebookKernelId: varchar("notebook_kernel_id").notNull().references(
131
+ () => codeNotebookKernel.codeNotebookKernelId
132
+ ),
133
+ notebookName: text("notebook_name").notNull(),
134
+ cellName: text("cell_name").notNull(),
135
+ cellGovernance: text("cell_governance"),
136
+ interpretableCode: text("interpretable_code").notNull(),
137
+ interpretableCodeHash: text("interpretable_code_hash").notNull(),
138
+ description: text(),
139
+ arguments: text(),
140
+ ...housekeeping
141
+ }, (table2) => [
142
+ unique().on(table2.notebookName, table2.cellName, table2.interpretableCodeHash),
143
+ checkJSON(table2.cellGovernance),
144
+ checkJSON(table2.arguments)
145
+ ]);
146
+ var codeNotebookState = table("code_notebook_state", {
147
+ codeNotebookStateId: varchar("code_notebook_state_id").primaryKey().notNull(),
148
+ codeNotebookCellId: varchar("code_notebook_cell_id").notNull().references(
149
+ () => codeNotebookCell.codeNotebookCellId
150
+ ),
151
+ fromState: text("from_state").notNull(),
152
+ toState: text("to_state").notNull(),
153
+ transitionResult: text("transition_result"),
154
+ transitionReason: text("transition_reason"),
155
+ transitionedAt: timestamptz("transitioned_at"),
156
+ elaboration: text(),
157
+ ...housekeeping
158
+ }, (table2) => [
159
+ unique().on(table2.codeNotebookCellId, table2.fromState, table2.toState),
160
+ checkJSON(table2.transitionResult),
161
+ checkJSON(table2.elaboration)
162
+ ]);
163
+ var sqlpageFiles = table("sqlpage_files", {
164
+ path: text().primaryKey().notNull(),
165
+ contents: text().notNull(),
166
+ lastModified: numeric("last_modified").default(sql`(CURRENT_TIMESTAMP)`)
167
+ }, (table2) => []);
168
+ var surveilrTableSize = table("surveilr_table_size", {
169
+ tableName: text("table_name").primaryKey(),
170
+ tableSizeMb: real("table_size_mb")
171
+ }, (table2) => []);
172
+ var sqlpageAideNavigation = table("sqlpage_aide_navigation", {
173
+ path: text().notNull(),
174
+ caption: text().notNull(),
175
+ namespace: text().notNull(),
176
+ parentPath: text("parent_path"),
177
+ siblingOrder: integer("sibling_order"),
178
+ url: text(),
179
+ title: text(),
180
+ abbreviatedCaption: text("abbreviated_caption"),
181
+ description: text(),
182
+ elaboration: text()
183
+ }, (table2) => [
184
+ unique("unq_ns_path").on(table2.namespace, table2.parentPath, table2.path)
185
+ ]);
186
+ var partyType = table("party_type", {
187
+ partyTypeId: ulid("party_type_id").primaryKey().notNull(),
188
+ code: text().notNull(),
189
+ value: text().notNull(),
190
+ ...housekeeping
191
+ }, (table2) => [
192
+ unique("unq_party_type_code").on(table2.code)
193
+ ]);
194
+ var party = table("party", {
195
+ partyId: varchar("party_id").primaryKey().notNull(),
196
+ partyTypeId: ulid("party_type_id").notNull().references(
197
+ () => partyType.partyTypeId
198
+ ).$type(),
199
+ // ULID
200
+ partyName: text("party_name").notNull(),
201
+ elaboration: text(),
202
+ ...housekeeping
203
+ }, (table2) => [
204
+ index("idx_party__party_type_id__party_name").on(
205
+ table2.partyTypeId,
206
+ table2.partyName
207
+ )
208
+ ]);
209
+ var partyRelationType = table("party_relation_type", {
210
+ partyRelationTypeId: text("party_relation_type_id").primaryKey().notNull().$type(),
211
+ // ULID
212
+ code: text().notNull(),
213
+ value: text().notNull(),
214
+ ...housekeeping
215
+ }, (table2) => [
216
+ unique().on(table2.code)
217
+ ]);
218
+ var partyRelation = table("party_relation", {
219
+ partyRelationId: varchar("party_relation_id").primaryKey().notNull(),
220
+ partyId: text("party_id").notNull().references(() => party.partyId),
221
+ relatedPartyId: text("related_party_id").notNull().references(
222
+ () => party.partyId
223
+ ),
224
+ relationTypeId: text("relation_type_id").notNull().references(
225
+ () => partyRelationType.partyRelationTypeId
226
+ ).$type(),
227
+ // ULID
228
+ elaboration: text(),
229
+ ...housekeeping
230
+ }, (table2) => [
231
+ index("idx_party_relation__party_id__related_party_id__relation_type_id").on(
232
+ table2.partyId,
233
+ table2.relatedPartyId,
234
+ table2.relationTypeId
235
+ ),
236
+ unique().on(table2.partyId, table2.relatedPartyId, table2.relationTypeId),
237
+ checkJSON(table2.elaboration)
238
+ ]);
239
+ var genderType = table("gender_type", {
240
+ genderTypeId: ulid("gender_type_id").primaryKey().notNull(),
241
+ code: text().notNull(),
242
+ value: text().notNull(),
243
+ ...housekeeping
244
+ }, (table2) => [
245
+ unique().on(table2.code)
246
+ ]);
247
+ var sexType = table("sex_type", {
248
+ sexTypeId: ulid("sex_type_id").primaryKey().notNull(),
249
+ code: text().notNull(),
250
+ value: text().notNull(),
251
+ ...housekeeping
252
+ }, (table2) => [
253
+ unique().on(table2.code)
254
+ ]);
255
+ var personType = table("person_type", {
256
+ personTypeId: ulid("person_type_id").primaryKey().notNull(),
257
+ code: text().notNull(),
258
+ value: text().notNull(),
259
+ ...housekeeping
260
+ }, (table2) => [
261
+ unique().on(table2.code)
262
+ ]);
263
+ var person = table("person", {
264
+ personId: ulid("person_id").primaryKey().notNull(),
265
+ partyId: text("party_id").notNull().references(() => party.partyId),
266
+ personTypeId: ulid("person_type_id").notNull().references(
267
+ () => personType.personTypeId
268
+ ),
269
+ personFirstName: text("person_first_name").notNull(),
270
+ personMiddleName: text("person_middle_name"),
271
+ personLastName: text("person_last_name").notNull(),
272
+ previousName: text("previous_name"),
273
+ honorificPrefix: text("honorific_prefix"),
274
+ honorificSuffix: text("honorific_suffix"),
275
+ genderId: ulid("gender_id").notNull().references(
276
+ () => genderType.genderTypeId
277
+ ),
278
+ sexId: ulid("sex_id").notNull().references(() => sexType.sexTypeId),
279
+ elaboration: text(),
280
+ ...housekeeping
281
+ }, (table2) => [
282
+ checkJSON(table2.elaboration)
283
+ ]);
284
+ var organization = table("organization", {
285
+ organizationId: ulid("organization_id").primaryKey().notNull(),
286
+ partyId: text("party_id").notNull().references(() => party.partyId),
287
+ name: text().notNull(),
288
+ alias: text(),
289
+ description: text(),
290
+ license: text().notNull(),
291
+ federalTaxIdNum: text("federal_tax_id_num"),
292
+ registrationDate: date("registration_date").notNull(),
293
+ elaboration: text(),
294
+ ...housekeeping
295
+ }, (table2) => [
296
+ checkJSON(table2.elaboration)
297
+ ]);
298
+ var organizationRoleType = table("organization_role_type", {
299
+ organizationRoleTypeId: ulid("organization_role_type_id").primaryKey().notNull(),
300
+ code: text().notNull(),
301
+ value: text().notNull(),
302
+ ...housekeeping
303
+ }, (table2) => [
304
+ unique().on(table2.code)
305
+ ]);
306
+ var organizationRole = table("organization_role", {
307
+ organizationRoleId: text("organization_role_id").primaryKey().notNull(),
308
+ personId: text("person_id").notNull().references(() => party.partyId),
309
+ organizationId: text("organization_id").notNull().references(
310
+ () => party.partyId
311
+ ),
312
+ organizationRoleTypeId: ulid("organization_role_type_id").notNull().references(() => organizationRoleType.organizationRoleTypeId),
313
+ elaboration: text(),
314
+ ...housekeeping
315
+ }, (table2) => [
316
+ index(
317
+ "idx_organization_role__person_id__organization_id__organization_role_type_id"
318
+ ).on(table2.personId, table2.organizationId, table2.organizationRoleTypeId),
319
+ unique().on(table2.personId, table2.organizationId, table2.organizationRoleTypeId),
320
+ checkJSON(table2.elaboration)
321
+ ]);
322
+ var devicePartyRelationship = table("device_party_relationship", {
323
+ devicePartyRelationshipId: text("device_party_relationship_id").primaryKey().notNull(),
324
+ deviceId: text("device_id").notNull().references(() => device.deviceId),
325
+ partyId: text("party_id").notNull().references(() => party.partyId),
326
+ elaboration: text(),
327
+ ...housekeeping
328
+ }, (table2) => [
329
+ index("idx_device_party_relationship__device_id__party_id").on(
330
+ table2.deviceId,
331
+ table2.partyId
332
+ ),
333
+ unique().on(table2.deviceId, table2.partyId),
334
+ checkJSON(table2.elaboration)
335
+ ]);
336
+ var behavior = table("behavior", {
337
+ behaviorId: varchar("behavior_id").primaryKey().notNull(),
338
+ deviceId: text("device_id").notNull(),
339
+ behaviorName: text("behavior_name").notNull(),
340
+ behaviorConfJson: text("behavior_conf_json").notNull(),
341
+ assuranceSchemaId: text("assurance_schema_id"),
342
+ governance: text(),
343
+ ...housekeeping
344
+ }, (table2) => [
345
+ unique().on(table2.deviceId, table2.behaviorName),
346
+ checkJSON(table2.behaviorConfJson),
347
+ checkJSON(table2.governance)
348
+ ]);
349
+ var urIngestResourcePathMatchRule = table(
350
+ "ur_ingest_resource_path_match_rule",
351
+ {
352
+ urIngestResourcePathMatchRuleId: text(
353
+ "ur_ingest_resource_path_match_rule_id"
354
+ ).primaryKey().notNull(),
355
+ namespace: text().notNull(),
356
+ regex: text().notNull(),
357
+ flags: text().notNull(),
358
+ nature: text(),
359
+ priority: text(),
360
+ description: text(),
361
+ includeGlobPatterns: textArray("include_glob_patterns"),
362
+ excludeGlobPatterns: textArray("exclude_glob_patterns"),
363
+ elaboration: text(),
364
+ ...housekeeping
365
+ },
366
+ (table2) => [
367
+ checkJSON(table2.elaboration),
368
+ unique("unq_path_match_regex").on(table2.namespace, table2.regex)
369
+ ]
370
+ );
371
+ var urIngestResourcePathRewriteRule = table(
372
+ "ur_ingest_resource_path_rewrite_rule",
373
+ {
374
+ urIngestResourcePathRewriteRuleId: text(
375
+ "ur_ingest_resource_path_rewrite_rule_id"
376
+ ).primaryKey().notNull(),
377
+ namespace: text().notNull(),
378
+ regex: text().notNull(),
379
+ replace: text().notNull(),
380
+ priority: text(),
381
+ description: text(),
382
+ elaboration: text(),
383
+ ...housekeeping
384
+ },
385
+ (table2) => [
386
+ unique().on(table2.namespace, table2.regex, table2.replace),
387
+ checkJSON(table2.elaboration)
388
+ ]
389
+ );
390
+ var urIngestSession = table("ur_ingest_session", {
391
+ urIngestSessionId: text("ur_ingest_session_id").primaryKey().notNull(),
392
+ deviceId: text("device_id").notNull().references(() => device.deviceId),
393
+ behaviorId: text("behavior_id").references(() => behavior.behaviorId),
394
+ behaviorJson: text("behavior_json"),
395
+ ingestStartedAt: timestamptz("ingest_started_at").notNull(),
396
+ ingestFinishedAt: timestamptz("ingest_finished_at"),
397
+ sessionAgent: text("session_agent").notNull(),
398
+ elaboration: text(),
399
+ ...housekeeping
400
+ }, (table2) => [
401
+ unique().on(table2.deviceId, table2.createdAt),
402
+ checkJSON(table2.behaviorJson),
403
+ checkJSON(table2.sessionAgent),
404
+ checkJSON(table2.elaboration)
405
+ ]);
406
+ var urIngestSessionFsPath = table("ur_ingest_session_fs_path", {
407
+ urIngestSessionFsPathId: text("ur_ingest_session_fs_path_id").primaryKey().notNull(),
408
+ ingestSessionId: text("ingest_session_id").notNull().references(
409
+ () => urIngestSession.urIngestSessionId
410
+ ),
411
+ rootPath: text("root_path").notNull(),
412
+ includeGlobPatterns: textArray("include_glob_patterns"),
413
+ excludeGlobPatterns: textArray("exclude_glob_patterns"),
414
+ elaboration: text(),
415
+ ...housekeeping
416
+ }, (table2) => [
417
+ index("idx_ur_ingest_session_fs_path__ingest_session_id__root_path").on(
418
+ table2.ingestSessionId,
419
+ table2.rootPath
420
+ ),
421
+ unique().on(table2.ingestSessionId, table2.rootPath, table2.createdAt),
422
+ checkJSON(table2.elaboration)
423
+ ]);
424
+ var uniformResource = table("uniform_resource", {
425
+ uniformResourceId: text("uniform_resource_id").primaryKey().notNull(),
426
+ deviceId: text("device_id").notNull().references(() => device.deviceId),
427
+ ingestSessionId: text("ingest_session_id").notNull().references(
428
+ () => urIngestSession.urIngestSessionId
429
+ ),
430
+ ingestFsPathId: text("ingest_fs_path_id").references(
431
+ () => urIngestSessionFsPath.urIngestSessionFsPathId
432
+ ),
433
+ ingestSessionImapAcctFolderMessage: text(
434
+ "ingest_session_imap_acct_folder_message"
435
+ ).references(
436
+ () => urIngestSessionImapAcctFolderMessage.urIngestSessionImapAcctFolderMessageId
437
+ ),
438
+ ingestIssueAcctProjectId: text("ingest_issue_acct_project_id").references(
439
+ () => urIngestSessionPlmAcctProject.urIngestSessionPlmAcctProjectId
440
+ ),
441
+ uri: text().notNull(),
442
+ contentDigest: text("content_digest").notNull(),
443
+ content: blob(),
444
+ nature: text(),
445
+ sizeBytes: integer("size_bytes"),
446
+ lastModifiedAt: timestamptz("last_modified_at"),
447
+ contentFmBodyAttrs: text("content_fm_body_attrs"),
448
+ frontmatter: text(),
449
+ elaboration: text(),
450
+ ...housekeeping
451
+ }, (table2) => [
452
+ index("idx_uniform_resource__device_id__uri").on(table2.deviceId, table2.uri),
453
+ unique().on(table2.deviceId, table2.contentDigest, table2.uri, table2.sizeBytes),
454
+ checkJSON(table2.contentFmBodyAttrs),
455
+ checkJSON(table2.frontmatter),
456
+ checkJSON(table2.elaboration)
457
+ ]);
458
+ var uniformResourceTransform = table("uniform_resource_transform", {
459
+ uniformResourceTransformId: text("uniform_resource_transform_id").primaryKey().notNull(),
460
+ uniformResourceId: text("uniform_resource_id").notNull().references(
461
+ () => uniformResource.uniformResourceId
462
+ ),
463
+ uri: text().notNull(),
464
+ contentDigest: text("content_digest").notNull(),
465
+ content: text(),
466
+ nature: text(),
467
+ sizeBytes: integer("size_bytes"),
468
+ elaboration: text(),
469
+ ...housekeeping
470
+ }, (table2) => [
471
+ index("idx_uniform_resource_transform__uniform_resource_id__content_digest").on(table2.uniformResourceId, table2.contentDigest),
472
+ unique().on(table2.uniformResourceId, table2.contentDigest, table2.nature, table2.sizeBytes),
473
+ checkJSON(table2.elaboration)
474
+ ]);
475
+ var urIngestSessionFsPathEntry = table(
476
+ "ur_ingest_session_fs_path_entry",
477
+ {
478
+ urIngestSessionFsPathEntryId: text("ur_ingest_session_fs_path_entry_id").primaryKey().notNull(),
479
+ ingestSessionId: text("ingest_session_id").notNull().references(
480
+ () => urIngestSession.urIngestSessionId
481
+ ),
482
+ ingestFsPathId: text("ingest_fs_path_id").notNull().references(
483
+ () => urIngestSessionFsPath.urIngestSessionFsPathId
484
+ ),
485
+ uniformResourceId: text("uniform_resource_id").references(
486
+ () => uniformResource.uniformResourceId
487
+ ),
488
+ filePathAbs: text("file_path_abs").notNull(),
489
+ filePathRelParent: text("file_path_rel_parent").notNull(),
490
+ filePathRel: text("file_path_rel").notNull(),
491
+ fileBasename: text("file_basename").notNull(),
492
+ fileExtn: text("file_extn"),
493
+ capturedExecutable: text("captured_executable"),
494
+ urStatus: text("ur_status"),
495
+ urDiagnostics: text("ur_diagnostics"),
496
+ urTransformations: text("ur_transformations"),
497
+ elaboration: text(),
498
+ ...housekeeping
499
+ },
500
+ (table2) => [
501
+ index(
502
+ "idx_ur_ingest_session_fs_path_entry__ingest_session_id__file_path_abs"
503
+ ).on(table2.ingestSessionId, table2.filePathAbs),
504
+ unique(
505
+ "uq_ur_ingest_session_fs_path_entry__ingest_session_id__ingest_fs_path_id__file_path_abs"
506
+ ).on(table2.ingestSessionId, table2.ingestFsPathId, table2.filePathAbs),
507
+ checkJSON(table2.capturedExecutable),
508
+ checkJSON(table2.urDiagnostics),
509
+ checkJSON(table2.urTransformations),
510
+ checkJSON(table2.elaboration)
511
+ ]
512
+ );
513
+ var urIngestSessionTask = table("ur_ingest_session_task", {
514
+ urIngestSessionTaskId: text("ur_ingest_session_task_id").primaryKey().notNull(),
515
+ ingestSessionId: text("ingest_session_id").notNull().references(
516
+ () => urIngestSession.urIngestSessionId
517
+ ),
518
+ uniformResourceId: text("uniform_resource_id").references(
519
+ () => uniformResource.uniformResourceId
520
+ ),
521
+ capturedExecutable: text("captured_executable").notNull(),
522
+ urStatus: text("ur_status"),
523
+ urDiagnostics: text("ur_diagnostics"),
524
+ urTransformations: text("ur_transformations"),
525
+ elaboration: text(),
526
+ ...housekeeping
527
+ }, (table2) => [
528
+ index("idx_ur_ingest_session_task__ingest_session_id").on(
529
+ table2.ingestSessionId
530
+ ),
531
+ checkJSON(table2.capturedExecutable),
532
+ checkJSON(table2.urDiagnostics),
533
+ checkJSON(table2.urTransformations),
534
+ checkJSON(table2.elaboration)
535
+ ]);
536
+ var urIngestSessionImapAccount = table(
537
+ "ur_ingest_session_imap_account",
538
+ {
539
+ urIngestSessionImapAccountId: text("ur_ingest_session_imap_account_id").primaryKey().notNull(),
540
+ ingestSessionId: text("ingest_session_id").notNull().references(
541
+ () => urIngestSession.urIngestSessionId
542
+ ),
543
+ email: text(),
544
+ password: text(),
545
+ host: text(),
546
+ elaboration: text(),
547
+ ...housekeeping
548
+ },
549
+ (table2) => [
550
+ index("idx_ur_ingest_session_imap_account__ingest_session_id__email").on(
551
+ table2.ingestSessionId,
552
+ table2.email
553
+ ),
554
+ unique().on(table2.ingestSessionId, table2.email)
555
+ ]
556
+ );
557
+ var urIngestSessionImapAcctFolder = table(
558
+ "ur_ingest_session_imap_acct_folder",
559
+ {
560
+ urIngestSessionImapAcctFolderId: text(
561
+ "ur_ingest_session_imap_acct_folder_id"
562
+ ).primaryKey().notNull(),
563
+ ingestSessionId: text("ingest_session_id").notNull().references(
564
+ () => urIngestSession.urIngestSessionId
565
+ ),
566
+ ingestAccountId: text("ingest_account_id").notNull().references(
567
+ () => urIngestSessionImapAccount.urIngestSessionImapAccountId
568
+ ),
569
+ folderName: text("folder_name").notNull(),
570
+ includeSenders: textArray("include_senders"),
571
+ excludeSenders: textArray("exclude_senders"),
572
+ elaboration: text(),
573
+ ...housekeeping
574
+ },
575
+ (table2) => [
576
+ index(
577
+ "idx_ur_ingest_session_imap_acct_folder__ingest_session_id__folder_name"
578
+ ).on(table2.ingestSessionId, table2.folderName),
579
+ unique().on(table2.ingestAccountId, table2.folderName)
580
+ ]
581
+ );
582
+ var urIngestSessionImapAcctFolderMessage = table(
583
+ "ur_ingest_session_imap_acct_folder_message",
584
+ {
585
+ urIngestSessionImapAcctFolderMessageId: text(
586
+ "ur_ingest_session_imap_acct_folder_message_id"
587
+ ).primaryKey().notNull(),
588
+ ingestSessionId: text("ingest_session_id").notNull().references(
589
+ () => urIngestSession.urIngestSessionId
590
+ ),
591
+ ingestImapAcctFolderId: text("ingest_imap_acct_folder_id").notNull().references(
592
+ () => urIngestSessionImapAcctFolder.urIngestSessionImapAcctFolderId
593
+ ),
594
+ message: text().notNull(),
595
+ messageId: text("message_id").notNull(),
596
+ subject: text().notNull(),
597
+ from: text().notNull(),
598
+ cc: text().notNull(),
599
+ bcc: text().notNull(),
600
+ status: textArray().notNull(),
601
+ date: date(),
602
+ emailReferences: text("email_references").notNull(),
603
+ ...housekeeping
604
+ },
605
+ (table2) => [
606
+ index("idx_ur_ingest_session_imap_acct_folder_message__ingest_session_id").on(table2.ingestSessionId),
607
+ unique().on(table2.message, table2.messageId),
608
+ checkJSON(table2.cc),
609
+ checkJSON(table2.bcc),
610
+ checkJSON(table2.emailReferences)
611
+ ]
612
+ );
613
+ var urIngestSessionPlmAccount = table(
614
+ "ur_ingest_session_plm_account",
615
+ {
616
+ urIngestSessionPlmAccountId: varchar("ur_ingest_session_plm_account_id").primaryKey().notNull(),
617
+ ingestSessionId: text("ingest_session_id").notNull().references(
618
+ () => urIngestSession.urIngestSessionId
619
+ ),
620
+ provider: text().notNull(),
621
+ orgName: text("org_name").notNull(),
622
+ elaboration: text(),
623
+ ...housekeeping
624
+ },
625
+ (table2) => [
626
+ unique().on(table2.provider, table2.orgName),
627
+ checkJSON(table2.elaboration)
628
+ ]
629
+ );
630
+ var urIngestSessionPlmAcctProject = table(
631
+ "ur_ingest_session_plm_acct_project",
632
+ {
633
+ urIngestSessionPlmAcctProjectId: varchar(
634
+ "ur_ingest_session_plm_acct_project_id"
635
+ ).primaryKey().notNull(),
636
+ ingestSessionId: text("ingest_session_id").notNull().references(
637
+ () => urIngestSession.urIngestSessionId
638
+ ),
639
+ ingestAccountId: text("ingest_account_id").notNull().references(
640
+ () => urIngestSessionPlmAccount.urIngestSessionPlmAccountId
641
+ ),
642
+ parentProjectId: text("parent_project_id"),
643
+ name: text().notNull(),
644
+ description: text(),
645
+ id: text(),
646
+ key: text(),
647
+ elaboration: text(),
648
+ ...housekeeping
649
+ },
650
+ (table2) => [
651
+ unique().on(table2.name, table2.description),
652
+ checkJSON(table2.elaboration)
653
+ ]
654
+ );
655
+ var urIngestSessionPlmUser = table("ur_ingest_session_plm_user", {
656
+ urIngestSessionPlmUserId: varchar("ur_ingest_session_plm_user_id").primaryKey().notNull(),
657
+ userId: text("user_id").notNull(),
658
+ login: text().notNull(),
659
+ email: text(),
660
+ name: text(),
661
+ url: text().notNull(),
662
+ elaboration: text(),
663
+ ...housekeeping
664
+ }, (table2) => [
665
+ unique().on(table2.userId, table2.login),
666
+ checkJSON(table2.elaboration)
667
+ ]);
668
+ var urIngestSessionPlmIssueType = table(
669
+ "ur_ingest_session_plm_issue_type",
670
+ {
671
+ urIngestSessionPlmIssueTypeId: varchar("ur_ingest_session_plm_issue_type_id").primaryKey().notNull(),
672
+ avatarId: text("avatar_id"),
673
+ description: text().notNull(),
674
+ iconUrl: text("icon_url").notNull(),
675
+ id: text().notNull(),
676
+ name: text().notNull(),
677
+ subtask: integer().notNull(),
678
+ url: text().notNull(),
679
+ elaboration: text(),
680
+ ...housekeeping
681
+ },
682
+ (table2) => [
683
+ unique().on(table2.id, table2.name),
684
+ checkJSON(table2.elaboration)
685
+ ]
686
+ );
687
+ var urIngestSessionPlmAcctProjectIssue = table(
688
+ "ur_ingest_session_plm_acct_project_issue",
689
+ {
690
+ urIngestSessionPlmAcctProjectIssueId: varchar(
691
+ "ur_ingest_session_plm_acct_project_issue_id"
692
+ ).primaryKey().notNull(),
693
+ ingestSessionId: text("ingest_session_id").notNull().references(
694
+ () => urIngestSession.urIngestSessionId
695
+ ),
696
+ urIngestSessionPlmAcctProjectId: text(
697
+ "ur_ingest_session_plm_acct_project_id"
698
+ ).notNull().references(
699
+ () => urIngestSessionPlmAcctProject.urIngestSessionPlmAcctProjectId
700
+ ),
701
+ uniformResourceId: text("uniform_resource_id").references(
702
+ () => uniformResource.uniformResourceId
703
+ ),
704
+ issueId: text("issue_id").notNull(),
705
+ issueNumber: integer("issue_number"),
706
+ parentIssueId: text("parent_issue_id"),
707
+ title: text().notNull(),
708
+ body: text(),
709
+ bodyText: text("body_text"),
710
+ bodyHtml: text("body_html"),
711
+ state: text().notNull(),
712
+ assignedTo: text("assigned_to"),
713
+ user: text().notNull().references(
714
+ () => urIngestSessionPlmUser.urIngestSessionPlmUserId
715
+ ),
716
+ url: text().notNull(),
717
+ closedAt: text("closed_at"),
718
+ issueTypeId: text("issue_type_id").references(
719
+ () => urIngestSessionPlmIssueType.urIngestSessionPlmIssueTypeId
720
+ ),
721
+ timeEstimate: integer("time_estimate"),
722
+ aggregateTimeEstimate: integer("aggregate_time_estimate"),
723
+ timeOriginalEstimate: integer("time_original_estimate"),
724
+ timeSpent: integer("time_spent"),
725
+ aggregateTimeSpent: integer("aggregate_time_spent"),
726
+ aggregateTimeOriginalEstimate: integer("aggregate_time_original_estimate"),
727
+ workratio: integer(),
728
+ currentProgress: integer("current_progress"),
729
+ totalProgress: integer("total_progress"),
730
+ resolutionName: text("resolution_name"),
731
+ resolutionDate: text("resolution_date"),
732
+ elaboration: text(),
733
+ ...housekeeping
734
+ },
735
+ (table2) => [
736
+ unique().on(table2.title, table2.issueId, table2.state, table2.assignedTo),
737
+ checkJSON(table2.elaboration)
738
+ ]
739
+ );
740
+ var urIngestSessionPlmAcctLabel = table(
741
+ "ur_ingest_session_plm_acct_label",
742
+ {
743
+ urIngestSessionPlmAcctLabelId: varchar("ur_ingest_session_plm_acct_label_id").primaryKey().notNull(),
744
+ urIngestSessionPlmAcctProjectId: text(
745
+ "ur_ingest_session_plm_acct_project_id"
746
+ ).notNull().references(
747
+ () => urIngestSessionPlmAcctProject.urIngestSessionPlmAcctProjectId
748
+ ),
749
+ urIngestSessionPlmAcctProjectIssueId: text(
750
+ "ur_ingest_session_plm_acct_project_issue_id"
751
+ ).notNull().references(
752
+ () => urIngestSessionPlmAcctProjectIssue.urIngestSessionPlmAcctProjectIssueId
753
+ ),
754
+ label: text().notNull(),
755
+ elaboration: text(),
756
+ ...housekeeping
757
+ },
758
+ (table2) => [
759
+ checkJSON(table2.elaboration)
760
+ ]
761
+ );
762
+ var urIngestSessionPlmMilestone = table(
763
+ "ur_ingest_session_plm_milestone",
764
+ {
765
+ urIngestSessionPlmMilestoneId: varchar("ur_ingest_session_plm_milestone_id").primaryKey().notNull(),
766
+ urIngestSessionPlmAcctProjectId: text(
767
+ "ur_ingest_session_plm_acct_project_id"
768
+ ).notNull().references(
769
+ () => urIngestSessionPlmAcctProject.urIngestSessionPlmAcctProjectId
770
+ ),
771
+ title: text().notNull(),
772
+ milestoneId: text("milestone_id").notNull(),
773
+ url: text().notNull(),
774
+ htmlUrl: text("html_url").notNull(),
775
+ openIssues: integer("open_issues"),
776
+ closedIssues: integer("closed_issues"),
777
+ dueOn: timestamptz("due_on"),
778
+ closedAt: timestamptz("closed_at"),
779
+ elaboration: text(),
780
+ ...housekeeping
781
+ },
782
+ (table2) => [
783
+ checkJSON(table2.elaboration)
784
+ ]
785
+ );
786
+ var urIngestSessionPlmAcctRelationship = table(
787
+ "ur_ingest_session_plm_acct_relationship",
788
+ {
789
+ urIngestSessionPlmAcctRelationshipId: varchar(
790
+ "ur_ingest_session_plm_acct_relationship_id"
791
+ ).primaryKey().notNull(),
792
+ urIngestSessionPlmAcctProjectIdPrime: text(
793
+ "ur_ingest_session_plm_acct_project_id_prime"
794
+ ).notNull().references(
795
+ () => urIngestSessionPlmAcctProject.urIngestSessionPlmAcctProjectId
796
+ ),
797
+ urIngestSessionPlmAcctProjectIdRelated: text(
798
+ "ur_ingest_session_plm_acct_project_id_related"
799
+ ).notNull(),
800
+ urIngestSessionPlmAcctProjectIssueIdPrime: text(
801
+ "ur_ingest_session_plm_acct_project_issue_id_prime"
802
+ ).notNull().references(
803
+ () => urIngestSessionPlmAcctProjectIssue.urIngestSessionPlmAcctProjectIssueId
804
+ ),
805
+ urIngestSessionPlmAcctProjectIssueIdRelated: text(
806
+ "ur_ingest_session_plm_acct_project_issue_id_related"
807
+ ).notNull(),
808
+ relationship: text(),
809
+ elaboration: text(),
810
+ ...housekeeping
811
+ },
812
+ (table2) => [
813
+ checkJSON(table2.elaboration)
814
+ ]
815
+ );
816
+ var urIngestSessionPlmComment = table(
817
+ "ur_ingest_session_plm_comment",
818
+ {
819
+ urIngestSessionPlmCommentId: varchar("ur_ingest_session_plm_comment_id").primaryKey().notNull(),
820
+ urIngestSessionPlmAcctProjectIssueId: text(
821
+ "ur_ingest_session_plm_acct_project_issue_id"
822
+ ).notNull().references(
823
+ () => urIngestSessionPlmAcctProjectIssue.urIngestSessionPlmAcctProjectIssueId
824
+ ),
825
+ commentId: text("comment_id").notNull(),
826
+ nodeId: text("node_id").notNull(),
827
+ url: text().notNull(),
828
+ body: text(),
829
+ bodyText: text("body_text"),
830
+ bodyHtml: text("body_html"),
831
+ user: text().notNull().references(
832
+ () => urIngestSessionPlmUser.urIngestSessionPlmUserId
833
+ ),
834
+ elaboration: text(),
835
+ ...housekeeping
836
+ },
837
+ (table2) => [
838
+ unique().on(table2.commentId, table2.url, table2.body),
839
+ checkJSON(table2.elaboration)
840
+ ]
841
+ );
842
+ var urIngestSessionPlmReaction = table(
843
+ "ur_ingest_session_plm_reaction",
844
+ {
845
+ urIngestSessionPlmReactionId: varchar("ur_ingest_session_plm_reaction_id").primaryKey().notNull(),
846
+ reactionId: text("reaction_id").notNull(),
847
+ reactionType: text("reaction_type").notNull(),
848
+ elaboration: text(),
849
+ ...housekeeping
850
+ },
851
+ (table2) => [
852
+ unique().on(table2.reactionType),
853
+ checkJSON(table2.elaboration)
854
+ ]
855
+ );
856
+ var urIngestSessionPlmIssueReaction = table(
857
+ "ur_ingest_session_plm_issue_reaction",
858
+ {
859
+ urIngestSessionPlmIssueReactionId: varchar(
860
+ "ur_ingest_session_plm_issue_reaction_id"
861
+ ).primaryKey().notNull(),
862
+ urIngestPlmReactionId: text("ur_ingest_plm_reaction_id").notNull().references(() => urIngestSessionPlmReaction.urIngestSessionPlmReactionId),
863
+ urIngestPlmIssueId: text("ur_ingest_plm_issue_id").notNull().references(
864
+ () => urIngestSessionPlmAcctProjectIssue.urIngestSessionPlmAcctProjectIssueId
865
+ ),
866
+ count: integer().default(1),
867
+ elaboration: text(),
868
+ ...housekeeping
869
+ },
870
+ (table2) => [
871
+ unique().on(table2.urIngestPlmIssueId, table2.urIngestPlmReactionId),
872
+ checkJSON(table2.elaboration)
873
+ ]
874
+ );
875
+ var urIngestSessionAttachment = table("ur_ingest_session_attachment", {
876
+ urIngestSessionAttachmentId: text("ur_ingest_session_attachment_id").primaryKey().notNull(),
877
+ uniformResourceId: text("uniform_resource_id").references(
878
+ () => uniformResource.uniformResourceId
879
+ ),
880
+ name: text(),
881
+ uri: text().notNull(),
882
+ content: blob(),
883
+ nature: text(),
884
+ size: integer(),
885
+ checksum: text(),
886
+ elaboration: text(),
887
+ ...housekeeping
888
+ }, (table2) => [
889
+ index("idx_ur_ingest_session_attachment__uniform_resource_id__content").on(
890
+ table2.uniformResourceId,
891
+ table2.content
892
+ ),
893
+ unique().on(table2.uniformResourceId, table2.checksum, table2.nature, table2.size)
894
+ ]);
895
+ var urIngestSessionUdiPgpSql = table("ur_ingest_session_udi_pgp_sql", {
896
+ urIngestSessionUdiPgpSqlId: text("ur_ingest_session_udi_pgp_sql_id").primaryKey().notNull(),
897
+ sql: text().notNull(),
898
+ nature: text().notNull(),
899
+ content: blob(),
900
+ behaviour: text(),
901
+ queryError: text("query_error"),
902
+ uniformResourceId: text("uniform_resource_id").references(
903
+ () => uniformResource.uniformResourceId
904
+ ),
905
+ ingestSessionId: text("ingest_session_id").references(
906
+ () => urIngestSession.urIngestSessionId
907
+ ),
908
+ ...housekeeping
909
+ }, (table2) => [
910
+ index("idx_ur_ingest_session_udi_pgp_sql__ingest_session_id").on(
911
+ table2.ingestSessionId
912
+ ),
913
+ unique().on(table2.sql, table2.ingestSessionId),
914
+ checkJSON(table2.behaviour)
915
+ ]);
916
+ var orchestrationNature = table("orchestration_nature", {
917
+ orchestrationNatureId: text("orchestration_nature_id").primaryKey().notNull(),
918
+ nature: text().notNull(),
919
+ elaboration: text(),
920
+ ...housekeeping
921
+ }, (table2) => [
922
+ index("idx_orchestration_nature__orchestration_nature_id__nature").on(
923
+ table2.orchestrationNatureId,
924
+ table2.nature
925
+ ),
926
+ unique().on(table2.orchestrationNatureId, table2.nature)
927
+ ]);
928
+ var orchestrationSession = table("orchestration_session", {
929
+ orchestrationSessionId: text("orchestration_session_id").primaryKey().notNull(),
930
+ deviceId: text("device_id").notNull().references(() => device.deviceId),
931
+ orchestrationNatureId: text("orchestration_nature_id").notNull().references(
932
+ () => orchestrationNature.orchestrationNatureId
933
+ ),
934
+ version: text().notNull(),
935
+ orchStartedAt: timestamptz("orch_started_at"),
936
+ orchFinishedAt: timestamptz("orch_finished_at"),
937
+ elaboration: text(),
938
+ argsJson: text("args_json"),
939
+ diagnosticsJson: text("diagnostics_json"),
940
+ diagnosticsMd: text("diagnostics_md")
941
+ }, (table2) => [
942
+ checkJSON(table2.elaboration),
943
+ checkJSON(table2.argsJson),
944
+ checkJSON(table2.diagnosticsJson)
945
+ ]);
946
+ var orchestrationSessionEntry = table("orchestration_session_entry", {
947
+ orchestrationSessionEntryId: text("orchestration_session_entry_id").primaryKey().notNull(),
948
+ sessionId: text("session_id").notNull().references(
949
+ () => orchestrationSession.orchestrationSessionId
950
+ ),
951
+ ingestSrc: text("ingest_src").notNull(),
952
+ ingestTableName: text("ingest_table_name"),
953
+ elaboration: text()
954
+ }, (table2) => []);
955
+ var orchestrationSessionState = table("orchestration_session_state", {
956
+ orchestrationSessionStateId: text("orchestration_session_state_id").primaryKey().notNull(),
957
+ sessionId: text("session_id").notNull().references(
958
+ () => orchestrationSession.orchestrationSessionId
959
+ ),
960
+ sessionEntryId: text("session_entry_id").references(
961
+ () => orchestrationSessionEntry.orchestrationSessionEntryId
962
+ ),
963
+ fromState: text("from_state").notNull(),
964
+ toState: text("to_state").notNull(),
965
+ transitionResult: text("transition_result"),
966
+ transitionReason: text("transition_reason"),
967
+ transitionedAt: timestamptz("transitioned_at"),
968
+ elaboration: text()
969
+ }, (table2) => [
970
+ unique().on(table2.orchestrationSessionStateId, table2.fromState, table2.toState)
971
+ ]);
972
+ var orchestrationSessionExec = table("orchestration_session_exec", {
973
+ orchestrationSessionExecId: text("orchestration_session_exec_id").primaryKey().notNull(),
974
+ execNature: text("exec_nature").notNull(),
975
+ sessionId: text("session_id").notNull().references(
976
+ () => orchestrationSession.orchestrationSessionId
977
+ ),
978
+ sessionEntryId: text("session_entry_id").references(
979
+ () => orchestrationSessionEntry.orchestrationSessionEntryId
980
+ ),
981
+ parentExecId: text("parent_exec_id"),
982
+ namespace: text(),
983
+ execIdentity: text("exec_identity"),
984
+ execCode: text("exec_code").notNull(),
985
+ execStatus: integer("exec_status").notNull(),
986
+ inputText: text("input_text"),
987
+ execErrorText: text("exec_error_text"),
988
+ outputText: text("output_text"),
989
+ outputNature: text("output_nature"),
990
+ narrativeMd: text("narrative_md"),
991
+ elaboration: text()
992
+ }, (table2) => [
993
+ foreignKey(() => ({
994
+ columns: [table2.parentExecId],
995
+ foreignColumns: [table2.orchestrationSessionExecId],
996
+ name: "orchestration_session_exec_parent_exec_id_orchestration_session_exec_orchestration_session_exec_id_fk"
997
+ }))
998
+ ]);
999
+ var orchestrationSessionIssue = table("orchestration_session_issue", {
1000
+ orchestrationSessionIssueId: numeric("orchestration_session_issue_id").primaryKey().notNull(),
1001
+ sessionId: text("session_id").notNull().references(
1002
+ () => orchestrationSession.orchestrationSessionId
1003
+ ),
1004
+ sessionEntryId: text("session_entry_id").references(
1005
+ () => orchestrationSessionEntry.orchestrationSessionEntryId
1006
+ ),
1007
+ issueType: text("issue_type").notNull(),
1008
+ issueMessage: text("issue_message").notNull(),
1009
+ issueRow: integer("issue_row"),
1010
+ issueColumn: text("issue_column"),
1011
+ invalidValue: text("invalid_value"),
1012
+ remediation: text(),
1013
+ elaboration: text()
1014
+ }, (table2) => []);
1015
+ var orchestrationSessionIssueRelation = table(
1016
+ "orchestration_session_issue_relation",
1017
+ {
1018
+ orchestrationSessionIssueRelationId: numeric(
1019
+ "orchestration_session_issue_relation_id"
1020
+ ).primaryKey().notNull(),
1021
+ issueIdPrime: numeric("issue_id_prime").notNull().references(
1022
+ () => orchestrationSessionIssue.orchestrationSessionIssueId
1023
+ ),
1024
+ issueIdRel: text("issue_id_rel").notNull(),
1025
+ relationshipNature: text("relationship_nature").notNull(),
1026
+ elaboration: text()
1027
+ },
1028
+ (table2) => []
1029
+ );
1030
+ var orchestrationSessionLog = table("orchestration_session_log", {
1031
+ orchestrationSessionLogId: numeric("orchestration_session_log_id").primaryKey().notNull(),
1032
+ category: text(),
1033
+ parentExecId: numeric("parent_exec_id"),
1034
+ content: text().notNull(),
1035
+ siblingOrder: integer("sibling_order"),
1036
+ elaboration: text()
1037
+ }, (table2) => [
1038
+ foreignKey(() => ({
1039
+ columns: [table2.parentExecId],
1040
+ foreignColumns: [table2.orchestrationSessionLogId],
1041
+ name: "orchestration_session_log_parent_exec_id_orchestration_session_log_orchestration_session_log_id_fk"
1042
+ }))
1043
+ ]);
1044
+ var uniformResourceGraph = table("uniform_resource_graph", {
1045
+ name: text().primaryKey().notNull(),
1046
+ elaboration: text()
1047
+ }, (table2) => []);
1048
+ var uniformResourceEdge = table("uniform_resource_edge", {
1049
+ graphName: text("graph_name").notNull().references(
1050
+ () => uniformResourceGraph.name
1051
+ ),
1052
+ nature: text().notNull(),
1053
+ nodeId: text("node_id").notNull(),
1054
+ uniformResourceId: text("uniform_resource_id").notNull().references(
1055
+ () => uniformResource.uniformResourceId
1056
+ ),
1057
+ elaboration: text()
1058
+ }, (table2) => [
1059
+ index("idx_uniform_resource_edge__uniform_resource_id").on(
1060
+ table2.uniformResourceId
1061
+ ),
1062
+ unique().on(table2.graphName, table2.nature, table2.nodeId, table2.uniformResourceId)
1063
+ ]);
1064
+ var surveilrOsqueryMsNode = table("surveilr_osquery_ms_node", {
1065
+ surveilrOsqueryMsNodeId: text("surveilr_osquery_ms_node_id").primaryKey().notNull(),
1066
+ nodeKey: text("node_key").notNull(),
1067
+ hostIdentifier: text("host_identifier").notNull(),
1068
+ tlsCertSubject: text("tls_cert_subject"),
1069
+ osVersion: text("os_version").notNull(),
1070
+ platform: text().notNull(),
1071
+ lastSeen: numeric("last_seen").notNull(),
1072
+ status: text().default("active").notNull(),
1073
+ osqueryVersion: text("osquery_version"),
1074
+ osqueryBuildPlatform: text("osquery_build_platform").notNull(),
1075
+ deviceId: text("device_id").notNull().references(() => device.deviceId),
1076
+ behaviorId: text("behavior_id").references(() => behavior.behaviorId),
1077
+ accelerate: integer().default(60).notNull(),
1078
+ ...housekeeping
1079
+ }, (table2) => [
1080
+ index("idx_surveilr_osquery_ms_node__node_key").on(table2.nodeKey),
1081
+ unique().on(table2.hostIdentifier, table2.osVersion),
1082
+ unique().on(table2.nodeKey)
1083
+ ]);
1084
+ var urIngestSessionOsqueryMsLog = table(
1085
+ "ur_ingest_session_osquery_ms_log",
1086
+ {
1087
+ urIngestSessionOsqueryMsLogId: text("ur_ingest_session_osquery_ms_log_id").primaryKey().notNull(),
1088
+ nodeKey: text("node_key").notNull().references(
1089
+ () => surveilrOsqueryMsNode.nodeKey
1090
+ ),
1091
+ logType: text("log_type").notNull(),
1092
+ logData: text("log_data").notNull(),
1093
+ appliedJqFilters: text("applied_jq_filters"),
1094
+ ...housekeeping
1095
+ },
1096
+ (table2) => [
1097
+ unique().on(table2.nodeKey, table2.logType, table2.logData)
1098
+ ]
1099
+ );
1100
+ var osqueryPolicy = table("osquery_policy", {
1101
+ osqueryPolicyId: text("osquery_policy_id").primaryKey().notNull(),
1102
+ policyGroup: text("policy_group"),
1103
+ policyName: text("policy_name").notNull(),
1104
+ osqueryCode: text("osquery_code").notNull(),
1105
+ policyDescription: text("policy_description").notNull(),
1106
+ policyPassLabel: text("policy_pass_label").default("Pass").notNull(),
1107
+ policyFailLabel: text("policy_fail_label").default("Fail").notNull(),
1108
+ policyPassRemarks: text("policy_pass_remarks"),
1109
+ policyFailRemarks: text("policy_fail_remarks"),
1110
+ osqueryPlatforms: text("osquery_platforms"),
1111
+ ...housekeeping
1112
+ }, (table2) => [
1113
+ unique().on(table2.policyName, table2.osqueryCode)
1114
+ ]);
1115
+ var surveilrOsqueryMsDistributedQuery = table(
1116
+ "surveilr_osquery_ms_distributed_query",
1117
+ {
1118
+ queryId: text("query_id").primaryKey().notNull(),
1119
+ nodeKey: text("node_key").notNull().references(
1120
+ () => surveilrOsqueryMsNode.nodeKey
1121
+ ),
1122
+ queryName: text("query_name").notNull(),
1123
+ querySql: text("query_sql").notNull(),
1124
+ discoveryQuery: text("discovery_query"),
1125
+ status: text().notNull(),
1126
+ elaboration: text(),
1127
+ interval: integer().notNull(),
1128
+ ...housekeeping
1129
+ },
1130
+ (table2) => []
1131
+ );
1132
+ var surveilrOsqueryMsDistributedResult = table(
1133
+ "surveilr_osquery_ms_distributed_result",
1134
+ {
1135
+ surveilrOsqueryMsDistributedResultId: text(
1136
+ "surveilr_osquery_ms_distributed_result_id"
1137
+ ).primaryKey().notNull(),
1138
+ queryId: text("query_id").notNull().references(
1139
+ () => surveilrOsqueryMsDistributedQuery.queryId
1140
+ ),
1141
+ nodeKey: text("node_key").notNull().references(
1142
+ () => surveilrOsqueryMsNode.nodeKey
1143
+ ),
1144
+ results: text().notNull(),
1145
+ statusCode: integer("status_code").notNull(),
1146
+ ...housekeeping
1147
+ },
1148
+ (table2) => []
1149
+ );
1150
+ var surveilrOsqueryMsCarve = table("surveilr_osquery_ms_carve", {
1151
+ surveilrOsqueryMsCarveId: text("surveilr_osquery_ms_carve_id").primaryKey().notNull(),
1152
+ nodeKey: text("node_key").notNull().references(
1153
+ () => surveilrOsqueryMsNode.nodeKey
1154
+ ),
1155
+ sessionId: text("session_id").notNull(),
1156
+ carveGuid: text("carve_guid").notNull(),
1157
+ carveSize: integer("carve_size").notNull(),
1158
+ blockCount: integer("block_count").notNull(),
1159
+ blockSize: integer("block_size").notNull(),
1160
+ receivedBlocks: integer("received_blocks").default(0).notNull(),
1161
+ carvePath: text("carve_path"),
1162
+ status: text().notNull(),
1163
+ startTime: numeric("start_time").notNull(),
1164
+ completionTime: numeric("completion_time"),
1165
+ elaboration: text(),
1166
+ ...housekeeping
1167
+ }, (table2) => [
1168
+ unique().on(table2.sessionId),
1169
+ unique().on(table2.carveGuid)
1170
+ ]);
1171
+ var surveilrOsqueryMsCarvedExtractedFile = table(
1172
+ "surveilr_osquery_ms_carved_extracted_file",
1173
+ {
1174
+ surveilrOsqueryMsCarvedExtractedFileId: text(
1175
+ "surveilr_osquery_ms_carved_extracted_file_id"
1176
+ ).primaryKey().notNull(),
1177
+ carveGuid: text("carve_guid").notNull().references(
1178
+ () => surveilrOsqueryMsCarve.carveGuid
1179
+ ),
1180
+ path: text().notNull(),
1181
+ sizeBytes: integer("size_bytes").notNull(),
1182
+ contentDigest: text("content_digest").notNull(),
1183
+ nature: text(),
1184
+ extractedAt: timestamptz("extracted_at").notNull(),
1185
+ ...housekeeping
1186
+ },
1187
+ (table2) => [
1188
+ index("idx_surveilr_osquery_ms_carved_extracted_file__path__carve_guid").on(
1189
+ table2.path,
1190
+ table2.carveGuid
1191
+ )
1192
+ ]
1193
+ );
1194
+ var surveilrSnmpDevice = table("surveilr_snmp_device", {
1195
+ surveilrSnmpDeviceId: text("surveilr_snmp_device_id").primaryKey().notNull(),
1196
+ deviceKey: text("device_key").notNull(),
1197
+ snmpHost: text("snmp_host").notNull(),
1198
+ snmpPort: integer("snmp_port").default(161).notNull(),
1199
+ snmpCommunity: text("snmp_community").notNull(),
1200
+ snmpVersion: text("snmp_version").default("2c").notNull(),
1201
+ snmpTimeout: integer("snmp_timeout").default(5).notNull(),
1202
+ snmpRetries: integer("snmp_retries").default(3).notNull(),
1203
+ deviceType: text("device_type"),
1204
+ deviceDescription: text("device_description"),
1205
+ lastSeen: numeric("last_seen").notNull(),
1206
+ status: text().default("active").notNull(),
1207
+ deviceId: text("device_id").notNull().references(() => device.deviceId),
1208
+ behaviorId: text("behavior_id").references(() => behavior.behaviorId),
1209
+ elaboration: text(),
1210
+ ...housekeeping
1211
+ }, (table2) => [
1212
+ index("idx_surveilr_snmp_device__device_key").on(table2.deviceKey),
1213
+ unique().on(table2.snmpHost, table2.snmpPort),
1214
+ unique().on(table2.deviceKey),
1215
+ checkJSON(table2.elaboration)
1216
+ ]);
1217
+ var surveilrSnmpCollection = table("surveilr_snmp_collection", {
1218
+ surveilrSnmpCollectionId: text("surveilr_snmp_collection_id").primaryKey().notNull(),
1219
+ deviceKey: text("device_key").notNull().references(
1220
+ () => surveilrSnmpDevice.deviceKey
1221
+ ),
1222
+ oid: text().notNull(),
1223
+ oidValue: text("oid_value").notNull(),
1224
+ oidType: text("oid_type").notNull(),
1225
+ collectedAt: timestamptz("collected_at").notNull(),
1226
+ elaboration: text(),
1227
+ ...housekeeping
1228
+ }, (table2) => [
1229
+ index("idx_surveilr_snmp_collection__device_key__oid").on(
1230
+ table2.deviceKey,
1231
+ table2.oid
1232
+ ),
1233
+ index("idx_surveilr_snmp_collection__collected_at").on(table2.collectedAt),
1234
+ checkJSON(table2.elaboration)
1235
+ ]);
1236
+ var surveilrFunctionDoc = table("surveilr_function_doc", {
1237
+ name: text().primaryKey(),
1238
+ description: text(),
1239
+ parameters: text({ mode: "json" }),
1240
+ returnType: text("return_type"),
1241
+ version: text()
1242
+ }, (table2) => [
1243
+ checkJSON(table2.parameters)
1244
+ ]);
1245
+
1246
+ export {
1247
+ housekeeping,
1248
+ sqleanDefine,
1249
+ checkJSON,
1250
+ assuranceSchema,
1251
+ device,
1252
+ codeNotebookKernel,
1253
+ codeNotebookCell,
1254
+ codeNotebookState,
1255
+ sqlpageFiles,
1256
+ surveilrTableSize,
1257
+ sqlpageAideNavigation,
1258
+ partyType,
1259
+ party,
1260
+ partyRelationType,
1261
+ partyRelation,
1262
+ genderType,
1263
+ sexType,
1264
+ personType,
1265
+ person,
1266
+ organization,
1267
+ organizationRoleType,
1268
+ organizationRole,
1269
+ devicePartyRelationship,
1270
+ behavior,
1271
+ urIngestResourcePathMatchRule,
1272
+ urIngestResourcePathRewriteRule,
1273
+ urIngestSession,
1274
+ urIngestSessionFsPath,
1275
+ uniformResource,
1276
+ uniformResourceTransform,
1277
+ urIngestSessionFsPathEntry,
1278
+ urIngestSessionTask,
1279
+ urIngestSessionImapAccount,
1280
+ urIngestSessionImapAcctFolder,
1281
+ urIngestSessionImapAcctFolderMessage,
1282
+ urIngestSessionPlmAccount,
1283
+ urIngestSessionPlmAcctProject,
1284
+ urIngestSessionPlmUser,
1285
+ urIngestSessionPlmIssueType,
1286
+ urIngestSessionPlmAcctProjectIssue,
1287
+ urIngestSessionPlmAcctLabel,
1288
+ urIngestSessionPlmMilestone,
1289
+ urIngestSessionPlmAcctRelationship,
1290
+ urIngestSessionPlmComment,
1291
+ urIngestSessionPlmReaction,
1292
+ urIngestSessionPlmIssueReaction,
1293
+ urIngestSessionAttachment,
1294
+ urIngestSessionUdiPgpSql,
1295
+ orchestrationNature,
1296
+ orchestrationSession,
1297
+ orchestrationSessionEntry,
1298
+ orchestrationSessionState,
1299
+ orchestrationSessionExec,
1300
+ orchestrationSessionIssue,
1301
+ orchestrationSessionIssueRelation,
1302
+ orchestrationSessionLog,
1303
+ uniformResourceGraph,
1304
+ uniformResourceEdge,
1305
+ surveilrOsqueryMsNode,
1306
+ urIngestSessionOsqueryMsLog,
1307
+ osqueryPolicy,
1308
+ surveilrOsqueryMsDistributedQuery,
1309
+ surveilrOsqueryMsDistributedResult,
1310
+ surveilrOsqueryMsCarve,
1311
+ surveilrOsqueryMsCarvedExtractedFile,
1312
+ surveilrSnmpDevice,
1313
+ surveilrSnmpCollection,
1314
+ surveilrFunctionDoc
1315
+ };