@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.
package/dist/index.cjs ADDED
@@ -0,0 +1,2896 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc2) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc2 = __getOwnPropDesc(from, key)) || desc2.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // index.ts
21
+ var index_exports = {};
22
+ __export(index_exports, {
23
+ assuranceSchema: () => assuranceSchema,
24
+ assuranceSchemaRelations: () => assuranceSchemaRelations,
25
+ behavior: () => behavior,
26
+ behaviorRelations: () => behaviorRelations,
27
+ checkJSON: () => checkJSON,
28
+ codeNotebookCell: () => codeNotebookCell,
29
+ codeNotebookCellLatest: () => codeNotebookCellLatest,
30
+ codeNotebookCellRelations: () => codeNotebookCellRelations,
31
+ codeNotebookCellVersions: () => codeNotebookCellVersions,
32
+ codeNotebookKernel: () => codeNotebookKernel,
33
+ codeNotebookKernelRelations: () => codeNotebookKernelRelations,
34
+ codeNotebookMigrationSql: () => codeNotebookMigrationSql,
35
+ codeNotebookSqlCellMigratable: () => codeNotebookSqlCellMigratable,
36
+ codeNotebookSqlCellMigratableNotExecuted: () => codeNotebookSqlCellMigratableNotExecuted,
37
+ codeNotebookSqlCellMigratableState: () => codeNotebookSqlCellMigratableState,
38
+ codeNotebookSqlCellMigratableVersion: () => codeNotebookSqlCellMigratableVersion,
39
+ codeNotebookState: () => codeNotebookState,
40
+ codeNotebookStateRelations: () => codeNotebookStateRelations,
41
+ consoleContentTabular: () => consoleContentTabular,
42
+ consoleInformationSchemaTable: () => consoleInformationSchemaTable,
43
+ consoleInformationSchemaTableColFkey: () => consoleInformationSchemaTableColFkey,
44
+ consoleInformationSchemaTableColIndex: () => consoleInformationSchemaTableColIndex,
45
+ consoleInformationSchemaView: () => consoleInformationSchemaView,
46
+ device: () => device,
47
+ deviceGraphAnalytics: () => deviceGraphAnalytics,
48
+ deviceGraphCorrelations: () => deviceGraphCorrelations,
49
+ deviceGraphOverview: () => deviceGraphOverview,
50
+ devicePartyRelationship: () => devicePartyRelationship,
51
+ devicePartyRelationshipRelations: () => devicePartyRelationshipRelations,
52
+ deviceRelations: () => deviceRelations,
53
+ emailMessagesWithTimezone: () => emailMessagesWithTimezone,
54
+ filesystemGraph: () => filesystemGraph,
55
+ genderType: () => genderType,
56
+ genderTypeRelations: () => genderTypeRelations,
57
+ housekeeping: () => housekeeping,
58
+ imapGraph: () => imapGraph,
59
+ networkDeviceTopology: () => networkDeviceTopology,
60
+ orchestrationExecutionSuccessRateByType: () => orchestrationExecutionSuccessRateByType,
61
+ orchestrationExecutionsByType: () => orchestrationExecutionsByType,
62
+ orchestrationIssueRemediation: () => orchestrationIssueRemediation,
63
+ orchestrationLogsBySession: () => orchestrationLogsBySession,
64
+ orchestrationNature: () => orchestrationNature,
65
+ orchestrationNatureRelations: () => orchestrationNatureRelations,
66
+ orchestrationSession: () => orchestrationSession,
67
+ orchestrationSessionByDevice: () => orchestrationSessionByDevice,
68
+ orchestrationSessionDuration: () => orchestrationSessionDuration,
69
+ orchestrationSessionEntry: () => orchestrationSessionEntry,
70
+ orchestrationSessionEntryRelations: () => orchestrationSessionEntryRelations,
71
+ orchestrationSessionExec: () => orchestrationSessionExec,
72
+ orchestrationSessionExecRelations: () => orchestrationSessionExecRelations,
73
+ orchestrationSessionIssue: () => orchestrationSessionIssue,
74
+ orchestrationSessionIssueRelation: () => orchestrationSessionIssueRelation,
75
+ orchestrationSessionIssueRelationRelations: () => orchestrationSessionIssueRelationRelations,
76
+ orchestrationSessionIssueRelations: () => orchestrationSessionIssueRelations,
77
+ orchestrationSessionLog: () => orchestrationSessionLog,
78
+ orchestrationSessionLogRelations: () => orchestrationSessionLogRelations,
79
+ orchestrationSessionRelations: () => orchestrationSessionRelations,
80
+ orchestrationSessionScript: () => orchestrationSessionScript,
81
+ orchestrationSessionState: () => orchestrationSessionState,
82
+ orchestrationSessionStateRelations: () => orchestrationSessionStateRelations,
83
+ orchestrationSessionSummary: () => orchestrationSessionSummary,
84
+ orchestrationSuccessRate: () => orchestrationSuccessRate,
85
+ organization: () => organization,
86
+ organizationRelations: () => organizationRelations,
87
+ organizationRole: () => organizationRole,
88
+ organizationRoleRelations: () => organizationRoleRelations,
89
+ organizationRoleType: () => organizationRoleType,
90
+ organizationRoleTypeRelations: () => organizationRoleTypeRelations,
91
+ osqueryPolicy: () => osqueryPolicy,
92
+ party: () => party,
93
+ partyRelation: () => partyRelation,
94
+ partyRelationRelations: () => partyRelationRelations,
95
+ partyRelationType: () => partyRelationType,
96
+ partyRelationTypeRelations: () => partyRelationTypeRelations,
97
+ partyRelations: () => partyRelations,
98
+ partyType: () => partyType,
99
+ partyTypeRelations: () => partyTypeRelations,
100
+ person: () => person,
101
+ personRelations: () => personRelations,
102
+ personType: () => personType,
103
+ personTypeRelations: () => personTypeRelations,
104
+ rssdStatisticsOverview: () => rssdStatisticsOverview,
105
+ rssdTableStatistic: () => rssdTableStatistic,
106
+ sexType: () => sexType,
107
+ sexTypeRelations: () => sexTypeRelations,
108
+ snmpCollectionSummary: () => snmpCollectionSummary,
109
+ snmpDeviceInventory: () => snmpDeviceInventory,
110
+ snmpOidPerformance: () => snmpOidPerformance,
111
+ sqleanDefine: () => sqleanDefine,
112
+ sqlpageAideNavigation: () => sqlpageAideNavigation,
113
+ sqlpageFiles: () => sqlpageFiles,
114
+ surveilrFunctionDoc: () => surveilrFunctionDoc,
115
+ surveilrOsqueryMsCarve: () => surveilrOsqueryMsCarve,
116
+ surveilrOsqueryMsCarveRelations: () => surveilrOsqueryMsCarveRelations,
117
+ surveilrOsqueryMsCarvedExtractedFile: () => surveilrOsqueryMsCarvedExtractedFile,
118
+ surveilrOsqueryMsCarvedExtractedFileRelations: () => surveilrOsqueryMsCarvedExtractedFileRelations,
119
+ surveilrOsqueryMsDistributedQuery: () => surveilrOsqueryMsDistributedQuery,
120
+ surveilrOsqueryMsDistributedQueryRelations: () => surveilrOsqueryMsDistributedQueryRelations,
121
+ surveilrOsqueryMsDistributedResult: () => surveilrOsqueryMsDistributedResult,
122
+ surveilrOsqueryMsDistributedResultRelations: () => surveilrOsqueryMsDistributedResultRelations,
123
+ surveilrOsqueryMsNode: () => surveilrOsqueryMsNode,
124
+ surveilrOsqueryMsNodeRelations: () => surveilrOsqueryMsNodeRelations,
125
+ surveilrSnmpCollection: () => surveilrSnmpCollection,
126
+ surveilrSnmpDevice: () => surveilrSnmpDevice,
127
+ surveilrTableSize: () => surveilrTableSize,
128
+ uniformResource: () => uniformResource,
129
+ uniformResourceEdge: () => uniformResourceEdge,
130
+ uniformResourceEdgeRelations: () => uniformResourceEdgeRelations,
131
+ uniformResourceFile: () => uniformResourceFile,
132
+ uniformResourceGraph: () => uniformResourceGraph,
133
+ uniformResourceGraphRelations: () => uniformResourceGraphRelations,
134
+ uniformResourceImap: () => uniformResourceImap,
135
+ uniformResourceImapContent: () => uniformResourceImapContent,
136
+ uniformResourceRelations: () => uniformResourceRelations,
137
+ uniformResourceTransform: () => uniformResourceTransform,
138
+ uniformResourceTransformRelations: () => uniformResourceTransformRelations,
139
+ urIngestResourcePathMatchRule: () => urIngestResourcePathMatchRule,
140
+ urIngestResourcePathRewriteRule: () => urIngestResourcePathRewriteRule,
141
+ urIngestSession: () => urIngestSession,
142
+ urIngestSessionAttachment: () => urIngestSessionAttachment,
143
+ urIngestSessionAttachmentRelations: () => urIngestSessionAttachmentRelations,
144
+ urIngestSessionFileIssue: () => urIngestSessionFileIssue,
145
+ urIngestSessionFilesStats: () => urIngestSessionFilesStats,
146
+ urIngestSessionFilesStatsLatest: () => urIngestSessionFilesStatsLatest,
147
+ urIngestSessionFsPath: () => urIngestSessionFsPath,
148
+ urIngestSessionFsPathEntry: () => urIngestSessionFsPathEntry,
149
+ urIngestSessionFsPathEntryRelations: () => urIngestSessionFsPathEntryRelations,
150
+ urIngestSessionFsPathRelations: () => urIngestSessionFsPathRelations,
151
+ urIngestSessionImapAccount: () => urIngestSessionImapAccount,
152
+ urIngestSessionImapAccountRelations: () => urIngestSessionImapAccountRelations,
153
+ urIngestSessionImapAcctFolder: () => urIngestSessionImapAcctFolder,
154
+ urIngestSessionImapAcctFolderMessage: () => urIngestSessionImapAcctFolderMessage,
155
+ urIngestSessionImapAcctFolderMessageRelations: () => urIngestSessionImapAcctFolderMessageRelations,
156
+ urIngestSessionImapAcctFolderRelations: () => urIngestSessionImapAcctFolderRelations,
157
+ urIngestSessionOsqueryMsLog: () => urIngestSessionOsqueryMsLog,
158
+ urIngestSessionOsqueryMsLogRelations: () => urIngestSessionOsqueryMsLogRelations,
159
+ urIngestSessionPlmAccount: () => urIngestSessionPlmAccount,
160
+ urIngestSessionPlmAccountRelations: () => urIngestSessionPlmAccountRelations,
161
+ urIngestSessionPlmAcctLabel: () => urIngestSessionPlmAcctLabel,
162
+ urIngestSessionPlmAcctLabelRelations: () => urIngestSessionPlmAcctLabelRelations,
163
+ urIngestSessionPlmAcctProject: () => urIngestSessionPlmAcctProject,
164
+ urIngestSessionPlmAcctProjectIssue: () => urIngestSessionPlmAcctProjectIssue,
165
+ urIngestSessionPlmAcctProjectIssueRelations: () => urIngestSessionPlmAcctProjectIssueRelations,
166
+ urIngestSessionPlmAcctProjectRelations: () => urIngestSessionPlmAcctProjectRelations,
167
+ urIngestSessionPlmAcctRelationship: () => urIngestSessionPlmAcctRelationship,
168
+ urIngestSessionPlmAcctRelationshipRelations: () => urIngestSessionPlmAcctRelationshipRelations,
169
+ urIngestSessionPlmComment: () => urIngestSessionPlmComment,
170
+ urIngestSessionPlmCommentRelations: () => urIngestSessionPlmCommentRelations,
171
+ urIngestSessionPlmIssueReaction: () => urIngestSessionPlmIssueReaction,
172
+ urIngestSessionPlmIssueReactionRelations: () => urIngestSessionPlmIssueReactionRelations,
173
+ urIngestSessionPlmIssueType: () => urIngestSessionPlmIssueType,
174
+ urIngestSessionPlmIssueTypeRelations: () => urIngestSessionPlmIssueTypeRelations,
175
+ urIngestSessionPlmMilestone: () => urIngestSessionPlmMilestone,
176
+ urIngestSessionPlmMilestoneRelations: () => urIngestSessionPlmMilestoneRelations,
177
+ urIngestSessionPlmReaction: () => urIngestSessionPlmReaction,
178
+ urIngestSessionPlmReactionRelations: () => urIngestSessionPlmReactionRelations,
179
+ urIngestSessionPlmUser: () => urIngestSessionPlmUser,
180
+ urIngestSessionPlmUserRelations: () => urIngestSessionPlmUserRelations,
181
+ urIngestSessionRelations: () => urIngestSessionRelations,
182
+ urIngestSessionTask: () => urIngestSessionTask,
183
+ urIngestSessionTaskRelations: () => urIngestSessionTaskRelations,
184
+ urIngestSessionTasksStats: () => urIngestSessionTasksStats,
185
+ urIngestSessionTasksStatsLatest: () => urIngestSessionTasksStatsLatest,
186
+ urIngestSessionUdiPgpSql: () => urIngestSessionUdiPgpSql,
187
+ urIngestSessionUdiPgpSqlRelations: () => urIngestSessionUdiPgpSqlRelations
188
+ });
189
+ module.exports = __toCommonJS(index_exports);
190
+
191
+ // models.ts
192
+ var import_sqlite_core = require("drizzle-orm/sqlite-core");
193
+ var import_drizzle_orm = require("drizzle-orm");
194
+ var timestamptz = (0, import_sqlite_core.customType)({
195
+ dataType() {
196
+ return "TIMESTAMPTZ";
197
+ },
198
+ fromDriver(value) {
199
+ return value;
200
+ },
201
+ toDriver(value) {
202
+ return value;
203
+ }
204
+ });
205
+ var date = (0, import_sqlite_core.customType)({
206
+ dataType() {
207
+ return "DATE";
208
+ },
209
+ fromDriver(value) {
210
+ return value;
211
+ },
212
+ toDriver(value) {
213
+ return value;
214
+ }
215
+ });
216
+ var ulid = (0, import_sqlite_core.customType)({
217
+ dataType() {
218
+ return "ULID";
219
+ },
220
+ fromDriver(value) {
221
+ return value;
222
+ },
223
+ toDriver(value) {
224
+ return value;
225
+ }
226
+ });
227
+ var varchar = (0, import_sqlite_core.customType)({
228
+ dataType() {
229
+ return "VARCHAR";
230
+ },
231
+ fromDriver(value) {
232
+ return value;
233
+ },
234
+ toDriver(value) {
235
+ return value;
236
+ }
237
+ });
238
+ var textArray = (0, import_sqlite_core.customType)({
239
+ dataType() {
240
+ return "TEXT[]";
241
+ },
242
+ fromDriver(value) {
243
+ return JSON.parse(value);
244
+ },
245
+ toDriver(value) {
246
+ return JSON.stringify(value);
247
+ }
248
+ });
249
+ var housekeeping = {
250
+ createdAt: timestamptz("created_at").default(import_drizzle_orm.sql`CURRENT_TIMESTAMP`),
251
+ createdBy: (0, import_sqlite_core.text)("created_by").default("UNKNOWN"),
252
+ updatedAt: timestamptz("updated_at"),
253
+ updatedBy: (0, import_sqlite_core.text)("updated_by"),
254
+ deletedAt: timestamptz("deleted_at"),
255
+ deletedBy: (0, import_sqlite_core.text)("deleted_by"),
256
+ activityLog: (0, import_sqlite_core.text)("activity_log")
257
+ };
258
+ var sqleanDefine = (0, import_sqlite_core.sqliteTable)("sqlean_define", {
259
+ name: (0, import_sqlite_core.text)().primaryKey(),
260
+ type: (0, import_sqlite_core.text)(),
261
+ body: (0, import_sqlite_core.text)()
262
+ }, (table2) => []);
263
+ var checkJSON = (c) => (0, import_sqlite_core.check)(`${c.name}_check_valid_json`, import_drizzle_orm.sql`json_valid(${c}) OR ${c} IS NULL`);
264
+ var assuranceSchema = (0, import_sqlite_core.sqliteTable)("assurance_schema", {
265
+ assuranceSchemaId: varchar("assurance_schema_id").primaryKey().notNull(),
266
+ assuranceType: (0, import_sqlite_core.text)("assurance_type").notNull(),
267
+ code: (0, import_sqlite_core.text)().notNull(),
268
+ codeJson: (0, import_sqlite_core.text)("code_json", { mode: "json" }),
269
+ governance: (0, import_sqlite_core.text)(),
270
+ ...housekeeping
271
+ }, (table2) => [
272
+ checkJSON(table2.codeJson),
273
+ checkJSON(table2.governance)
274
+ ]);
275
+ var device = (0, import_sqlite_core.sqliteTable)("device", {
276
+ deviceId: varchar("device_id").primaryKey().notNull(),
277
+ name: (0, import_sqlite_core.text)().notNull(),
278
+ state: (0, import_sqlite_core.text)().notNull(),
279
+ boundary: (0, import_sqlite_core.text)().notNull(),
280
+ segmentation: (0, import_sqlite_core.text)(),
281
+ stateSysinfo: (0, import_sqlite_core.text)("state_sysinfo"),
282
+ elaboration: (0, import_sqlite_core.text)(),
283
+ ...housekeeping
284
+ }, (table2) => [
285
+ (0, import_sqlite_core.index)("idx_device__name__state").on(table2.name, table2.state),
286
+ (0, import_sqlite_core.unique)().on(table2.name, table2.state, table2.boundary),
287
+ checkJSON(table2.state),
288
+ checkJSON(table2.segmentation),
289
+ checkJSON(table2.stateSysinfo),
290
+ checkJSON(table2.elaboration)
291
+ ]);
292
+ var codeNotebookKernel = (0, import_sqlite_core.sqliteTable)("code_notebook_kernel", {
293
+ codeNotebookKernelId: varchar("code_notebook_kernel_id").primaryKey().notNull(),
294
+ kernelName: (0, import_sqlite_core.text)("kernel_name").notNull(),
295
+ description: (0, import_sqlite_core.text)(),
296
+ mimeType: (0, import_sqlite_core.text)("mime_type"),
297
+ fileExtn: (0, import_sqlite_core.text)("file_extn"),
298
+ elaboration: (0, import_sqlite_core.text)(),
299
+ governance: (0, import_sqlite_core.text)(),
300
+ ...housekeeping
301
+ }, (table2) => [
302
+ (0, import_sqlite_core.unique)().on(table2.kernelName),
303
+ checkJSON(table2.elaboration),
304
+ checkJSON(table2.governance)
305
+ ]);
306
+ var codeNotebookCell = (0, import_sqlite_core.sqliteTable)("code_notebook_cell", {
307
+ codeNotebookCellId: varchar("code_notebook_cell_id").primaryKey().notNull(),
308
+ notebookKernelId: varchar("notebook_kernel_id").notNull().references(
309
+ () => codeNotebookKernel.codeNotebookKernelId
310
+ ),
311
+ notebookName: (0, import_sqlite_core.text)("notebook_name").notNull(),
312
+ cellName: (0, import_sqlite_core.text)("cell_name").notNull(),
313
+ cellGovernance: (0, import_sqlite_core.text)("cell_governance"),
314
+ interpretableCode: (0, import_sqlite_core.text)("interpretable_code").notNull(),
315
+ interpretableCodeHash: (0, import_sqlite_core.text)("interpretable_code_hash").notNull(),
316
+ description: (0, import_sqlite_core.text)(),
317
+ arguments: (0, import_sqlite_core.text)(),
318
+ ...housekeeping
319
+ }, (table2) => [
320
+ (0, import_sqlite_core.unique)().on(table2.notebookName, table2.cellName, table2.interpretableCodeHash),
321
+ checkJSON(table2.cellGovernance),
322
+ checkJSON(table2.arguments)
323
+ ]);
324
+ var codeNotebookState = (0, import_sqlite_core.sqliteTable)("code_notebook_state", {
325
+ codeNotebookStateId: varchar("code_notebook_state_id").primaryKey().notNull(),
326
+ codeNotebookCellId: varchar("code_notebook_cell_id").notNull().references(
327
+ () => codeNotebookCell.codeNotebookCellId
328
+ ),
329
+ fromState: (0, import_sqlite_core.text)("from_state").notNull(),
330
+ toState: (0, import_sqlite_core.text)("to_state").notNull(),
331
+ transitionResult: (0, import_sqlite_core.text)("transition_result"),
332
+ transitionReason: (0, import_sqlite_core.text)("transition_reason"),
333
+ transitionedAt: timestamptz("transitioned_at"),
334
+ elaboration: (0, import_sqlite_core.text)(),
335
+ ...housekeeping
336
+ }, (table2) => [
337
+ (0, import_sqlite_core.unique)().on(table2.codeNotebookCellId, table2.fromState, table2.toState),
338
+ checkJSON(table2.transitionResult),
339
+ checkJSON(table2.elaboration)
340
+ ]);
341
+ var sqlpageFiles = (0, import_sqlite_core.sqliteTable)("sqlpage_files", {
342
+ path: (0, import_sqlite_core.text)().primaryKey().notNull(),
343
+ contents: (0, import_sqlite_core.text)().notNull(),
344
+ lastModified: (0, import_sqlite_core.numeric)("last_modified").default(import_drizzle_orm.sql`(CURRENT_TIMESTAMP)`)
345
+ }, (table2) => []);
346
+ var surveilrTableSize = (0, import_sqlite_core.sqliteTable)("surveilr_table_size", {
347
+ tableName: (0, import_sqlite_core.text)("table_name").primaryKey(),
348
+ tableSizeMb: (0, import_sqlite_core.real)("table_size_mb")
349
+ }, (table2) => []);
350
+ var sqlpageAideNavigation = (0, import_sqlite_core.sqliteTable)("sqlpage_aide_navigation", {
351
+ path: (0, import_sqlite_core.text)().notNull(),
352
+ caption: (0, import_sqlite_core.text)().notNull(),
353
+ namespace: (0, import_sqlite_core.text)().notNull(),
354
+ parentPath: (0, import_sqlite_core.text)("parent_path"),
355
+ siblingOrder: (0, import_sqlite_core.integer)("sibling_order"),
356
+ url: (0, import_sqlite_core.text)(),
357
+ title: (0, import_sqlite_core.text)(),
358
+ abbreviatedCaption: (0, import_sqlite_core.text)("abbreviated_caption"),
359
+ description: (0, import_sqlite_core.text)(),
360
+ elaboration: (0, import_sqlite_core.text)()
361
+ }, (table2) => [
362
+ (0, import_sqlite_core.unique)("unq_ns_path").on(table2.namespace, table2.parentPath, table2.path)
363
+ ]);
364
+ var partyType = (0, import_sqlite_core.sqliteTable)("party_type", {
365
+ partyTypeId: ulid("party_type_id").primaryKey().notNull(),
366
+ code: (0, import_sqlite_core.text)().notNull(),
367
+ value: (0, import_sqlite_core.text)().notNull(),
368
+ ...housekeeping
369
+ }, (table2) => [
370
+ (0, import_sqlite_core.unique)("unq_party_type_code").on(table2.code)
371
+ ]);
372
+ var party = (0, import_sqlite_core.sqliteTable)("party", {
373
+ partyId: varchar("party_id").primaryKey().notNull(),
374
+ partyTypeId: ulid("party_type_id").notNull().references(
375
+ () => partyType.partyTypeId
376
+ ).$type(),
377
+ // ULID
378
+ partyName: (0, import_sqlite_core.text)("party_name").notNull(),
379
+ elaboration: (0, import_sqlite_core.text)(),
380
+ ...housekeeping
381
+ }, (table2) => [
382
+ (0, import_sqlite_core.index)("idx_party__party_type_id__party_name").on(
383
+ table2.partyTypeId,
384
+ table2.partyName
385
+ )
386
+ ]);
387
+ var partyRelationType = (0, import_sqlite_core.sqliteTable)("party_relation_type", {
388
+ partyRelationTypeId: (0, import_sqlite_core.text)("party_relation_type_id").primaryKey().notNull().$type(),
389
+ // ULID
390
+ code: (0, import_sqlite_core.text)().notNull(),
391
+ value: (0, import_sqlite_core.text)().notNull(),
392
+ ...housekeeping
393
+ }, (table2) => [
394
+ (0, import_sqlite_core.unique)().on(table2.code)
395
+ ]);
396
+ var partyRelation = (0, import_sqlite_core.sqliteTable)("party_relation", {
397
+ partyRelationId: varchar("party_relation_id").primaryKey().notNull(),
398
+ partyId: (0, import_sqlite_core.text)("party_id").notNull().references(() => party.partyId),
399
+ relatedPartyId: (0, import_sqlite_core.text)("related_party_id").notNull().references(
400
+ () => party.partyId
401
+ ),
402
+ relationTypeId: (0, import_sqlite_core.text)("relation_type_id").notNull().references(
403
+ () => partyRelationType.partyRelationTypeId
404
+ ).$type(),
405
+ // ULID
406
+ elaboration: (0, import_sqlite_core.text)(),
407
+ ...housekeeping
408
+ }, (table2) => [
409
+ (0, import_sqlite_core.index)("idx_party_relation__party_id__related_party_id__relation_type_id").on(
410
+ table2.partyId,
411
+ table2.relatedPartyId,
412
+ table2.relationTypeId
413
+ ),
414
+ (0, import_sqlite_core.unique)().on(table2.partyId, table2.relatedPartyId, table2.relationTypeId),
415
+ checkJSON(table2.elaboration)
416
+ ]);
417
+ var genderType = (0, import_sqlite_core.sqliteTable)("gender_type", {
418
+ genderTypeId: ulid("gender_type_id").primaryKey().notNull(),
419
+ code: (0, import_sqlite_core.text)().notNull(),
420
+ value: (0, import_sqlite_core.text)().notNull(),
421
+ ...housekeeping
422
+ }, (table2) => [
423
+ (0, import_sqlite_core.unique)().on(table2.code)
424
+ ]);
425
+ var sexType = (0, import_sqlite_core.sqliteTable)("sex_type", {
426
+ sexTypeId: ulid("sex_type_id").primaryKey().notNull(),
427
+ code: (0, import_sqlite_core.text)().notNull(),
428
+ value: (0, import_sqlite_core.text)().notNull(),
429
+ ...housekeeping
430
+ }, (table2) => [
431
+ (0, import_sqlite_core.unique)().on(table2.code)
432
+ ]);
433
+ var personType = (0, import_sqlite_core.sqliteTable)("person_type", {
434
+ personTypeId: ulid("person_type_id").primaryKey().notNull(),
435
+ code: (0, import_sqlite_core.text)().notNull(),
436
+ value: (0, import_sqlite_core.text)().notNull(),
437
+ ...housekeeping
438
+ }, (table2) => [
439
+ (0, import_sqlite_core.unique)().on(table2.code)
440
+ ]);
441
+ var person = (0, import_sqlite_core.sqliteTable)("person", {
442
+ personId: ulid("person_id").primaryKey().notNull(),
443
+ partyId: (0, import_sqlite_core.text)("party_id").notNull().references(() => party.partyId),
444
+ personTypeId: ulid("person_type_id").notNull().references(
445
+ () => personType.personTypeId
446
+ ),
447
+ personFirstName: (0, import_sqlite_core.text)("person_first_name").notNull(),
448
+ personMiddleName: (0, import_sqlite_core.text)("person_middle_name"),
449
+ personLastName: (0, import_sqlite_core.text)("person_last_name").notNull(),
450
+ previousName: (0, import_sqlite_core.text)("previous_name"),
451
+ honorificPrefix: (0, import_sqlite_core.text)("honorific_prefix"),
452
+ honorificSuffix: (0, import_sqlite_core.text)("honorific_suffix"),
453
+ genderId: ulid("gender_id").notNull().references(
454
+ () => genderType.genderTypeId
455
+ ),
456
+ sexId: ulid("sex_id").notNull().references(() => sexType.sexTypeId),
457
+ elaboration: (0, import_sqlite_core.text)(),
458
+ ...housekeeping
459
+ }, (table2) => [
460
+ checkJSON(table2.elaboration)
461
+ ]);
462
+ var organization = (0, import_sqlite_core.sqliteTable)("organization", {
463
+ organizationId: ulid("organization_id").primaryKey().notNull(),
464
+ partyId: (0, import_sqlite_core.text)("party_id").notNull().references(() => party.partyId),
465
+ name: (0, import_sqlite_core.text)().notNull(),
466
+ alias: (0, import_sqlite_core.text)(),
467
+ description: (0, import_sqlite_core.text)(),
468
+ license: (0, import_sqlite_core.text)().notNull(),
469
+ federalTaxIdNum: (0, import_sqlite_core.text)("federal_tax_id_num"),
470
+ registrationDate: date("registration_date").notNull(),
471
+ elaboration: (0, import_sqlite_core.text)(),
472
+ ...housekeeping
473
+ }, (table2) => [
474
+ checkJSON(table2.elaboration)
475
+ ]);
476
+ var organizationRoleType = (0, import_sqlite_core.sqliteTable)("organization_role_type", {
477
+ organizationRoleTypeId: ulid("organization_role_type_id").primaryKey().notNull(),
478
+ code: (0, import_sqlite_core.text)().notNull(),
479
+ value: (0, import_sqlite_core.text)().notNull(),
480
+ ...housekeeping
481
+ }, (table2) => [
482
+ (0, import_sqlite_core.unique)().on(table2.code)
483
+ ]);
484
+ var organizationRole = (0, import_sqlite_core.sqliteTable)("organization_role", {
485
+ organizationRoleId: (0, import_sqlite_core.text)("organization_role_id").primaryKey().notNull(),
486
+ personId: (0, import_sqlite_core.text)("person_id").notNull().references(() => party.partyId),
487
+ organizationId: (0, import_sqlite_core.text)("organization_id").notNull().references(
488
+ () => party.partyId
489
+ ),
490
+ organizationRoleTypeId: ulid("organization_role_type_id").notNull().references(() => organizationRoleType.organizationRoleTypeId),
491
+ elaboration: (0, import_sqlite_core.text)(),
492
+ ...housekeeping
493
+ }, (table2) => [
494
+ (0, import_sqlite_core.index)(
495
+ "idx_organization_role__person_id__organization_id__organization_role_type_id"
496
+ ).on(table2.personId, table2.organizationId, table2.organizationRoleTypeId),
497
+ (0, import_sqlite_core.unique)().on(table2.personId, table2.organizationId, table2.organizationRoleTypeId),
498
+ checkJSON(table2.elaboration)
499
+ ]);
500
+ var devicePartyRelationship = (0, import_sqlite_core.sqliteTable)("device_party_relationship", {
501
+ devicePartyRelationshipId: (0, import_sqlite_core.text)("device_party_relationship_id").primaryKey().notNull(),
502
+ deviceId: (0, import_sqlite_core.text)("device_id").notNull().references(() => device.deviceId),
503
+ partyId: (0, import_sqlite_core.text)("party_id").notNull().references(() => party.partyId),
504
+ elaboration: (0, import_sqlite_core.text)(),
505
+ ...housekeeping
506
+ }, (table2) => [
507
+ (0, import_sqlite_core.index)("idx_device_party_relationship__device_id__party_id").on(
508
+ table2.deviceId,
509
+ table2.partyId
510
+ ),
511
+ (0, import_sqlite_core.unique)().on(table2.deviceId, table2.partyId),
512
+ checkJSON(table2.elaboration)
513
+ ]);
514
+ var behavior = (0, import_sqlite_core.sqliteTable)("behavior", {
515
+ behaviorId: varchar("behavior_id").primaryKey().notNull(),
516
+ deviceId: (0, import_sqlite_core.text)("device_id").notNull(),
517
+ behaviorName: (0, import_sqlite_core.text)("behavior_name").notNull(),
518
+ behaviorConfJson: (0, import_sqlite_core.text)("behavior_conf_json").notNull(),
519
+ assuranceSchemaId: (0, import_sqlite_core.text)("assurance_schema_id"),
520
+ governance: (0, import_sqlite_core.text)(),
521
+ ...housekeeping
522
+ }, (table2) => [
523
+ (0, import_sqlite_core.unique)().on(table2.deviceId, table2.behaviorName),
524
+ checkJSON(table2.behaviorConfJson),
525
+ checkJSON(table2.governance)
526
+ ]);
527
+ var urIngestResourcePathMatchRule = (0, import_sqlite_core.sqliteTable)(
528
+ "ur_ingest_resource_path_match_rule",
529
+ {
530
+ urIngestResourcePathMatchRuleId: (0, import_sqlite_core.text)(
531
+ "ur_ingest_resource_path_match_rule_id"
532
+ ).primaryKey().notNull(),
533
+ namespace: (0, import_sqlite_core.text)().notNull(),
534
+ regex: (0, import_sqlite_core.text)().notNull(),
535
+ flags: (0, import_sqlite_core.text)().notNull(),
536
+ nature: (0, import_sqlite_core.text)(),
537
+ priority: (0, import_sqlite_core.text)(),
538
+ description: (0, import_sqlite_core.text)(),
539
+ includeGlobPatterns: textArray("include_glob_patterns"),
540
+ excludeGlobPatterns: textArray("exclude_glob_patterns"),
541
+ elaboration: (0, import_sqlite_core.text)(),
542
+ ...housekeeping
543
+ },
544
+ (table2) => [
545
+ checkJSON(table2.elaboration),
546
+ (0, import_sqlite_core.unique)("unq_path_match_regex").on(table2.namespace, table2.regex)
547
+ ]
548
+ );
549
+ var urIngestResourcePathRewriteRule = (0, import_sqlite_core.sqliteTable)(
550
+ "ur_ingest_resource_path_rewrite_rule",
551
+ {
552
+ urIngestResourcePathRewriteRuleId: (0, import_sqlite_core.text)(
553
+ "ur_ingest_resource_path_rewrite_rule_id"
554
+ ).primaryKey().notNull(),
555
+ namespace: (0, import_sqlite_core.text)().notNull(),
556
+ regex: (0, import_sqlite_core.text)().notNull(),
557
+ replace: (0, import_sqlite_core.text)().notNull(),
558
+ priority: (0, import_sqlite_core.text)(),
559
+ description: (0, import_sqlite_core.text)(),
560
+ elaboration: (0, import_sqlite_core.text)(),
561
+ ...housekeeping
562
+ },
563
+ (table2) => [
564
+ (0, import_sqlite_core.unique)().on(table2.namespace, table2.regex, table2.replace),
565
+ checkJSON(table2.elaboration)
566
+ ]
567
+ );
568
+ var urIngestSession = (0, import_sqlite_core.sqliteTable)("ur_ingest_session", {
569
+ urIngestSessionId: (0, import_sqlite_core.text)("ur_ingest_session_id").primaryKey().notNull(),
570
+ deviceId: (0, import_sqlite_core.text)("device_id").notNull().references(() => device.deviceId),
571
+ behaviorId: (0, import_sqlite_core.text)("behavior_id").references(() => behavior.behaviorId),
572
+ behaviorJson: (0, import_sqlite_core.text)("behavior_json"),
573
+ ingestStartedAt: timestamptz("ingest_started_at").notNull(),
574
+ ingestFinishedAt: timestamptz("ingest_finished_at"),
575
+ sessionAgent: (0, import_sqlite_core.text)("session_agent").notNull(),
576
+ elaboration: (0, import_sqlite_core.text)(),
577
+ ...housekeeping
578
+ }, (table2) => [
579
+ (0, import_sqlite_core.unique)().on(table2.deviceId, table2.createdAt),
580
+ checkJSON(table2.behaviorJson),
581
+ checkJSON(table2.sessionAgent),
582
+ checkJSON(table2.elaboration)
583
+ ]);
584
+ var urIngestSessionFsPath = (0, import_sqlite_core.sqliteTable)("ur_ingest_session_fs_path", {
585
+ urIngestSessionFsPathId: (0, import_sqlite_core.text)("ur_ingest_session_fs_path_id").primaryKey().notNull(),
586
+ ingestSessionId: (0, import_sqlite_core.text)("ingest_session_id").notNull().references(
587
+ () => urIngestSession.urIngestSessionId
588
+ ),
589
+ rootPath: (0, import_sqlite_core.text)("root_path").notNull(),
590
+ includeGlobPatterns: textArray("include_glob_patterns"),
591
+ excludeGlobPatterns: textArray("exclude_glob_patterns"),
592
+ elaboration: (0, import_sqlite_core.text)(),
593
+ ...housekeeping
594
+ }, (table2) => [
595
+ (0, import_sqlite_core.index)("idx_ur_ingest_session_fs_path__ingest_session_id__root_path").on(
596
+ table2.ingestSessionId,
597
+ table2.rootPath
598
+ ),
599
+ (0, import_sqlite_core.unique)().on(table2.ingestSessionId, table2.rootPath, table2.createdAt),
600
+ checkJSON(table2.elaboration)
601
+ ]);
602
+ var uniformResource = (0, import_sqlite_core.sqliteTable)("uniform_resource", {
603
+ uniformResourceId: (0, import_sqlite_core.text)("uniform_resource_id").primaryKey().notNull(),
604
+ deviceId: (0, import_sqlite_core.text)("device_id").notNull().references(() => device.deviceId),
605
+ ingestSessionId: (0, import_sqlite_core.text)("ingest_session_id").notNull().references(
606
+ () => urIngestSession.urIngestSessionId
607
+ ),
608
+ ingestFsPathId: (0, import_sqlite_core.text)("ingest_fs_path_id").references(
609
+ () => urIngestSessionFsPath.urIngestSessionFsPathId
610
+ ),
611
+ ingestSessionImapAcctFolderMessage: (0, import_sqlite_core.text)(
612
+ "ingest_session_imap_acct_folder_message"
613
+ ).references(
614
+ () => urIngestSessionImapAcctFolderMessage.urIngestSessionImapAcctFolderMessageId
615
+ ),
616
+ ingestIssueAcctProjectId: (0, import_sqlite_core.text)("ingest_issue_acct_project_id").references(
617
+ () => urIngestSessionPlmAcctProject.urIngestSessionPlmAcctProjectId
618
+ ),
619
+ uri: (0, import_sqlite_core.text)().notNull(),
620
+ contentDigest: (0, import_sqlite_core.text)("content_digest").notNull(),
621
+ content: (0, import_sqlite_core.blob)(),
622
+ nature: (0, import_sqlite_core.text)(),
623
+ sizeBytes: (0, import_sqlite_core.integer)("size_bytes"),
624
+ lastModifiedAt: timestamptz("last_modified_at"),
625
+ contentFmBodyAttrs: (0, import_sqlite_core.text)("content_fm_body_attrs"),
626
+ frontmatter: (0, import_sqlite_core.text)(),
627
+ elaboration: (0, import_sqlite_core.text)(),
628
+ ...housekeeping
629
+ }, (table2) => [
630
+ (0, import_sqlite_core.index)("idx_uniform_resource__device_id__uri").on(table2.deviceId, table2.uri),
631
+ (0, import_sqlite_core.unique)().on(table2.deviceId, table2.contentDigest, table2.uri, table2.sizeBytes),
632
+ checkJSON(table2.contentFmBodyAttrs),
633
+ checkJSON(table2.frontmatter),
634
+ checkJSON(table2.elaboration)
635
+ ]);
636
+ var uniformResourceTransform = (0, import_sqlite_core.sqliteTable)("uniform_resource_transform", {
637
+ uniformResourceTransformId: (0, import_sqlite_core.text)("uniform_resource_transform_id").primaryKey().notNull(),
638
+ uniformResourceId: (0, import_sqlite_core.text)("uniform_resource_id").notNull().references(
639
+ () => uniformResource.uniformResourceId
640
+ ),
641
+ uri: (0, import_sqlite_core.text)().notNull(),
642
+ contentDigest: (0, import_sqlite_core.text)("content_digest").notNull(),
643
+ content: (0, import_sqlite_core.text)(),
644
+ nature: (0, import_sqlite_core.text)(),
645
+ sizeBytes: (0, import_sqlite_core.integer)("size_bytes"),
646
+ elaboration: (0, import_sqlite_core.text)(),
647
+ ...housekeeping
648
+ }, (table2) => [
649
+ (0, import_sqlite_core.index)("idx_uniform_resource_transform__uniform_resource_id__content_digest").on(table2.uniformResourceId, table2.contentDigest),
650
+ (0, import_sqlite_core.unique)().on(table2.uniformResourceId, table2.contentDigest, table2.nature, table2.sizeBytes),
651
+ checkJSON(table2.elaboration)
652
+ ]);
653
+ var urIngestSessionFsPathEntry = (0, import_sqlite_core.sqliteTable)(
654
+ "ur_ingest_session_fs_path_entry",
655
+ {
656
+ urIngestSessionFsPathEntryId: (0, import_sqlite_core.text)("ur_ingest_session_fs_path_entry_id").primaryKey().notNull(),
657
+ ingestSessionId: (0, import_sqlite_core.text)("ingest_session_id").notNull().references(
658
+ () => urIngestSession.urIngestSessionId
659
+ ),
660
+ ingestFsPathId: (0, import_sqlite_core.text)("ingest_fs_path_id").notNull().references(
661
+ () => urIngestSessionFsPath.urIngestSessionFsPathId
662
+ ),
663
+ uniformResourceId: (0, import_sqlite_core.text)("uniform_resource_id").references(
664
+ () => uniformResource.uniformResourceId
665
+ ),
666
+ filePathAbs: (0, import_sqlite_core.text)("file_path_abs").notNull(),
667
+ filePathRelParent: (0, import_sqlite_core.text)("file_path_rel_parent").notNull(),
668
+ filePathRel: (0, import_sqlite_core.text)("file_path_rel").notNull(),
669
+ fileBasename: (0, import_sqlite_core.text)("file_basename").notNull(),
670
+ fileExtn: (0, import_sqlite_core.text)("file_extn"),
671
+ capturedExecutable: (0, import_sqlite_core.text)("captured_executable"),
672
+ urStatus: (0, import_sqlite_core.text)("ur_status"),
673
+ urDiagnostics: (0, import_sqlite_core.text)("ur_diagnostics"),
674
+ urTransformations: (0, import_sqlite_core.text)("ur_transformations"),
675
+ elaboration: (0, import_sqlite_core.text)(),
676
+ ...housekeeping
677
+ },
678
+ (table2) => [
679
+ (0, import_sqlite_core.index)(
680
+ "idx_ur_ingest_session_fs_path_entry__ingest_session_id__file_path_abs"
681
+ ).on(table2.ingestSessionId, table2.filePathAbs),
682
+ (0, import_sqlite_core.unique)(
683
+ "uq_ur_ingest_session_fs_path_entry__ingest_session_id__ingest_fs_path_id__file_path_abs"
684
+ ).on(table2.ingestSessionId, table2.ingestFsPathId, table2.filePathAbs),
685
+ checkJSON(table2.capturedExecutable),
686
+ checkJSON(table2.urDiagnostics),
687
+ checkJSON(table2.urTransformations),
688
+ checkJSON(table2.elaboration)
689
+ ]
690
+ );
691
+ var urIngestSessionTask = (0, import_sqlite_core.sqliteTable)("ur_ingest_session_task", {
692
+ urIngestSessionTaskId: (0, import_sqlite_core.text)("ur_ingest_session_task_id").primaryKey().notNull(),
693
+ ingestSessionId: (0, import_sqlite_core.text)("ingest_session_id").notNull().references(
694
+ () => urIngestSession.urIngestSessionId
695
+ ),
696
+ uniformResourceId: (0, import_sqlite_core.text)("uniform_resource_id").references(
697
+ () => uniformResource.uniformResourceId
698
+ ),
699
+ capturedExecutable: (0, import_sqlite_core.text)("captured_executable").notNull(),
700
+ urStatus: (0, import_sqlite_core.text)("ur_status"),
701
+ urDiagnostics: (0, import_sqlite_core.text)("ur_diagnostics"),
702
+ urTransformations: (0, import_sqlite_core.text)("ur_transformations"),
703
+ elaboration: (0, import_sqlite_core.text)(),
704
+ ...housekeeping
705
+ }, (table2) => [
706
+ (0, import_sqlite_core.index)("idx_ur_ingest_session_task__ingest_session_id").on(
707
+ table2.ingestSessionId
708
+ ),
709
+ checkJSON(table2.capturedExecutable),
710
+ checkJSON(table2.urDiagnostics),
711
+ checkJSON(table2.urTransformations),
712
+ checkJSON(table2.elaboration)
713
+ ]);
714
+ var urIngestSessionImapAccount = (0, import_sqlite_core.sqliteTable)(
715
+ "ur_ingest_session_imap_account",
716
+ {
717
+ urIngestSessionImapAccountId: (0, import_sqlite_core.text)("ur_ingest_session_imap_account_id").primaryKey().notNull(),
718
+ ingestSessionId: (0, import_sqlite_core.text)("ingest_session_id").notNull().references(
719
+ () => urIngestSession.urIngestSessionId
720
+ ),
721
+ email: (0, import_sqlite_core.text)(),
722
+ password: (0, import_sqlite_core.text)(),
723
+ host: (0, import_sqlite_core.text)(),
724
+ elaboration: (0, import_sqlite_core.text)(),
725
+ ...housekeeping
726
+ },
727
+ (table2) => [
728
+ (0, import_sqlite_core.index)("idx_ur_ingest_session_imap_account__ingest_session_id__email").on(
729
+ table2.ingestSessionId,
730
+ table2.email
731
+ ),
732
+ (0, import_sqlite_core.unique)().on(table2.ingestSessionId, table2.email)
733
+ ]
734
+ );
735
+ var urIngestSessionImapAcctFolder = (0, import_sqlite_core.sqliteTable)(
736
+ "ur_ingest_session_imap_acct_folder",
737
+ {
738
+ urIngestSessionImapAcctFolderId: (0, import_sqlite_core.text)(
739
+ "ur_ingest_session_imap_acct_folder_id"
740
+ ).primaryKey().notNull(),
741
+ ingestSessionId: (0, import_sqlite_core.text)("ingest_session_id").notNull().references(
742
+ () => urIngestSession.urIngestSessionId
743
+ ),
744
+ ingestAccountId: (0, import_sqlite_core.text)("ingest_account_id").notNull().references(
745
+ () => urIngestSessionImapAccount.urIngestSessionImapAccountId
746
+ ),
747
+ folderName: (0, import_sqlite_core.text)("folder_name").notNull(),
748
+ includeSenders: textArray("include_senders"),
749
+ excludeSenders: textArray("exclude_senders"),
750
+ elaboration: (0, import_sqlite_core.text)(),
751
+ ...housekeeping
752
+ },
753
+ (table2) => [
754
+ (0, import_sqlite_core.index)(
755
+ "idx_ur_ingest_session_imap_acct_folder__ingest_session_id__folder_name"
756
+ ).on(table2.ingestSessionId, table2.folderName),
757
+ (0, import_sqlite_core.unique)().on(table2.ingestAccountId, table2.folderName)
758
+ ]
759
+ );
760
+ var urIngestSessionImapAcctFolderMessage = (0, import_sqlite_core.sqliteTable)(
761
+ "ur_ingest_session_imap_acct_folder_message",
762
+ {
763
+ urIngestSessionImapAcctFolderMessageId: (0, import_sqlite_core.text)(
764
+ "ur_ingest_session_imap_acct_folder_message_id"
765
+ ).primaryKey().notNull(),
766
+ ingestSessionId: (0, import_sqlite_core.text)("ingest_session_id").notNull().references(
767
+ () => urIngestSession.urIngestSessionId
768
+ ),
769
+ ingestImapAcctFolderId: (0, import_sqlite_core.text)("ingest_imap_acct_folder_id").notNull().references(
770
+ () => urIngestSessionImapAcctFolder.urIngestSessionImapAcctFolderId
771
+ ),
772
+ message: (0, import_sqlite_core.text)().notNull(),
773
+ messageId: (0, import_sqlite_core.text)("message_id").notNull(),
774
+ subject: (0, import_sqlite_core.text)().notNull(),
775
+ from: (0, import_sqlite_core.text)().notNull(),
776
+ cc: (0, import_sqlite_core.text)().notNull(),
777
+ bcc: (0, import_sqlite_core.text)().notNull(),
778
+ status: textArray().notNull(),
779
+ date: date(),
780
+ emailReferences: (0, import_sqlite_core.text)("email_references").notNull(),
781
+ ...housekeeping
782
+ },
783
+ (table2) => [
784
+ (0, import_sqlite_core.index)("idx_ur_ingest_session_imap_acct_folder_message__ingest_session_id").on(table2.ingestSessionId),
785
+ (0, import_sqlite_core.unique)().on(table2.message, table2.messageId),
786
+ checkJSON(table2.cc),
787
+ checkJSON(table2.bcc),
788
+ checkJSON(table2.emailReferences)
789
+ ]
790
+ );
791
+ var urIngestSessionPlmAccount = (0, import_sqlite_core.sqliteTable)(
792
+ "ur_ingest_session_plm_account",
793
+ {
794
+ urIngestSessionPlmAccountId: varchar("ur_ingest_session_plm_account_id").primaryKey().notNull(),
795
+ ingestSessionId: (0, import_sqlite_core.text)("ingest_session_id").notNull().references(
796
+ () => urIngestSession.urIngestSessionId
797
+ ),
798
+ provider: (0, import_sqlite_core.text)().notNull(),
799
+ orgName: (0, import_sqlite_core.text)("org_name").notNull(),
800
+ elaboration: (0, import_sqlite_core.text)(),
801
+ ...housekeeping
802
+ },
803
+ (table2) => [
804
+ (0, import_sqlite_core.unique)().on(table2.provider, table2.orgName),
805
+ checkJSON(table2.elaboration)
806
+ ]
807
+ );
808
+ var urIngestSessionPlmAcctProject = (0, import_sqlite_core.sqliteTable)(
809
+ "ur_ingest_session_plm_acct_project",
810
+ {
811
+ urIngestSessionPlmAcctProjectId: varchar(
812
+ "ur_ingest_session_plm_acct_project_id"
813
+ ).primaryKey().notNull(),
814
+ ingestSessionId: (0, import_sqlite_core.text)("ingest_session_id").notNull().references(
815
+ () => urIngestSession.urIngestSessionId
816
+ ),
817
+ ingestAccountId: (0, import_sqlite_core.text)("ingest_account_id").notNull().references(
818
+ () => urIngestSessionPlmAccount.urIngestSessionPlmAccountId
819
+ ),
820
+ parentProjectId: (0, import_sqlite_core.text)("parent_project_id"),
821
+ name: (0, import_sqlite_core.text)().notNull(),
822
+ description: (0, import_sqlite_core.text)(),
823
+ id: (0, import_sqlite_core.text)(),
824
+ key: (0, import_sqlite_core.text)(),
825
+ elaboration: (0, import_sqlite_core.text)(),
826
+ ...housekeeping
827
+ },
828
+ (table2) => [
829
+ (0, import_sqlite_core.unique)().on(table2.name, table2.description),
830
+ checkJSON(table2.elaboration)
831
+ ]
832
+ );
833
+ var urIngestSessionPlmUser = (0, import_sqlite_core.sqliteTable)("ur_ingest_session_plm_user", {
834
+ urIngestSessionPlmUserId: varchar("ur_ingest_session_plm_user_id").primaryKey().notNull(),
835
+ userId: (0, import_sqlite_core.text)("user_id").notNull(),
836
+ login: (0, import_sqlite_core.text)().notNull(),
837
+ email: (0, import_sqlite_core.text)(),
838
+ name: (0, import_sqlite_core.text)(),
839
+ url: (0, import_sqlite_core.text)().notNull(),
840
+ elaboration: (0, import_sqlite_core.text)(),
841
+ ...housekeeping
842
+ }, (table2) => [
843
+ (0, import_sqlite_core.unique)().on(table2.userId, table2.login),
844
+ checkJSON(table2.elaboration)
845
+ ]);
846
+ var urIngestSessionPlmIssueType = (0, import_sqlite_core.sqliteTable)(
847
+ "ur_ingest_session_plm_issue_type",
848
+ {
849
+ urIngestSessionPlmIssueTypeId: varchar("ur_ingest_session_plm_issue_type_id").primaryKey().notNull(),
850
+ avatarId: (0, import_sqlite_core.text)("avatar_id"),
851
+ description: (0, import_sqlite_core.text)().notNull(),
852
+ iconUrl: (0, import_sqlite_core.text)("icon_url").notNull(),
853
+ id: (0, import_sqlite_core.text)().notNull(),
854
+ name: (0, import_sqlite_core.text)().notNull(),
855
+ subtask: (0, import_sqlite_core.integer)().notNull(),
856
+ url: (0, import_sqlite_core.text)().notNull(),
857
+ elaboration: (0, import_sqlite_core.text)(),
858
+ ...housekeeping
859
+ },
860
+ (table2) => [
861
+ (0, import_sqlite_core.unique)().on(table2.id, table2.name),
862
+ checkJSON(table2.elaboration)
863
+ ]
864
+ );
865
+ var urIngestSessionPlmAcctProjectIssue = (0, import_sqlite_core.sqliteTable)(
866
+ "ur_ingest_session_plm_acct_project_issue",
867
+ {
868
+ urIngestSessionPlmAcctProjectIssueId: varchar(
869
+ "ur_ingest_session_plm_acct_project_issue_id"
870
+ ).primaryKey().notNull(),
871
+ ingestSessionId: (0, import_sqlite_core.text)("ingest_session_id").notNull().references(
872
+ () => urIngestSession.urIngestSessionId
873
+ ),
874
+ urIngestSessionPlmAcctProjectId: (0, import_sqlite_core.text)(
875
+ "ur_ingest_session_plm_acct_project_id"
876
+ ).notNull().references(
877
+ () => urIngestSessionPlmAcctProject.urIngestSessionPlmAcctProjectId
878
+ ),
879
+ uniformResourceId: (0, import_sqlite_core.text)("uniform_resource_id").references(
880
+ () => uniformResource.uniformResourceId
881
+ ),
882
+ issueId: (0, import_sqlite_core.text)("issue_id").notNull(),
883
+ issueNumber: (0, import_sqlite_core.integer)("issue_number"),
884
+ parentIssueId: (0, import_sqlite_core.text)("parent_issue_id"),
885
+ title: (0, import_sqlite_core.text)().notNull(),
886
+ body: (0, import_sqlite_core.text)(),
887
+ bodyText: (0, import_sqlite_core.text)("body_text"),
888
+ bodyHtml: (0, import_sqlite_core.text)("body_html"),
889
+ state: (0, import_sqlite_core.text)().notNull(),
890
+ assignedTo: (0, import_sqlite_core.text)("assigned_to"),
891
+ user: (0, import_sqlite_core.text)().notNull().references(
892
+ () => urIngestSessionPlmUser.urIngestSessionPlmUserId
893
+ ),
894
+ url: (0, import_sqlite_core.text)().notNull(),
895
+ closedAt: (0, import_sqlite_core.text)("closed_at"),
896
+ issueTypeId: (0, import_sqlite_core.text)("issue_type_id").references(
897
+ () => urIngestSessionPlmIssueType.urIngestSessionPlmIssueTypeId
898
+ ),
899
+ timeEstimate: (0, import_sqlite_core.integer)("time_estimate"),
900
+ aggregateTimeEstimate: (0, import_sqlite_core.integer)("aggregate_time_estimate"),
901
+ timeOriginalEstimate: (0, import_sqlite_core.integer)("time_original_estimate"),
902
+ timeSpent: (0, import_sqlite_core.integer)("time_spent"),
903
+ aggregateTimeSpent: (0, import_sqlite_core.integer)("aggregate_time_spent"),
904
+ aggregateTimeOriginalEstimate: (0, import_sqlite_core.integer)("aggregate_time_original_estimate"),
905
+ workratio: (0, import_sqlite_core.integer)(),
906
+ currentProgress: (0, import_sqlite_core.integer)("current_progress"),
907
+ totalProgress: (0, import_sqlite_core.integer)("total_progress"),
908
+ resolutionName: (0, import_sqlite_core.text)("resolution_name"),
909
+ resolutionDate: (0, import_sqlite_core.text)("resolution_date"),
910
+ elaboration: (0, import_sqlite_core.text)(),
911
+ ...housekeeping
912
+ },
913
+ (table2) => [
914
+ (0, import_sqlite_core.unique)().on(table2.title, table2.issueId, table2.state, table2.assignedTo),
915
+ checkJSON(table2.elaboration)
916
+ ]
917
+ );
918
+ var urIngestSessionPlmAcctLabel = (0, import_sqlite_core.sqliteTable)(
919
+ "ur_ingest_session_plm_acct_label",
920
+ {
921
+ urIngestSessionPlmAcctLabelId: varchar("ur_ingest_session_plm_acct_label_id").primaryKey().notNull(),
922
+ urIngestSessionPlmAcctProjectId: (0, import_sqlite_core.text)(
923
+ "ur_ingest_session_plm_acct_project_id"
924
+ ).notNull().references(
925
+ () => urIngestSessionPlmAcctProject.urIngestSessionPlmAcctProjectId
926
+ ),
927
+ urIngestSessionPlmAcctProjectIssueId: (0, import_sqlite_core.text)(
928
+ "ur_ingest_session_plm_acct_project_issue_id"
929
+ ).notNull().references(
930
+ () => urIngestSessionPlmAcctProjectIssue.urIngestSessionPlmAcctProjectIssueId
931
+ ),
932
+ label: (0, import_sqlite_core.text)().notNull(),
933
+ elaboration: (0, import_sqlite_core.text)(),
934
+ ...housekeeping
935
+ },
936
+ (table2) => [
937
+ checkJSON(table2.elaboration)
938
+ ]
939
+ );
940
+ var urIngestSessionPlmMilestone = (0, import_sqlite_core.sqliteTable)(
941
+ "ur_ingest_session_plm_milestone",
942
+ {
943
+ urIngestSessionPlmMilestoneId: varchar("ur_ingest_session_plm_milestone_id").primaryKey().notNull(),
944
+ urIngestSessionPlmAcctProjectId: (0, import_sqlite_core.text)(
945
+ "ur_ingest_session_plm_acct_project_id"
946
+ ).notNull().references(
947
+ () => urIngestSessionPlmAcctProject.urIngestSessionPlmAcctProjectId
948
+ ),
949
+ title: (0, import_sqlite_core.text)().notNull(),
950
+ milestoneId: (0, import_sqlite_core.text)("milestone_id").notNull(),
951
+ url: (0, import_sqlite_core.text)().notNull(),
952
+ htmlUrl: (0, import_sqlite_core.text)("html_url").notNull(),
953
+ openIssues: (0, import_sqlite_core.integer)("open_issues"),
954
+ closedIssues: (0, import_sqlite_core.integer)("closed_issues"),
955
+ dueOn: timestamptz("due_on"),
956
+ closedAt: timestamptz("closed_at"),
957
+ elaboration: (0, import_sqlite_core.text)(),
958
+ ...housekeeping
959
+ },
960
+ (table2) => [
961
+ checkJSON(table2.elaboration)
962
+ ]
963
+ );
964
+ var urIngestSessionPlmAcctRelationship = (0, import_sqlite_core.sqliteTable)(
965
+ "ur_ingest_session_plm_acct_relationship",
966
+ {
967
+ urIngestSessionPlmAcctRelationshipId: varchar(
968
+ "ur_ingest_session_plm_acct_relationship_id"
969
+ ).primaryKey().notNull(),
970
+ urIngestSessionPlmAcctProjectIdPrime: (0, import_sqlite_core.text)(
971
+ "ur_ingest_session_plm_acct_project_id_prime"
972
+ ).notNull().references(
973
+ () => urIngestSessionPlmAcctProject.urIngestSessionPlmAcctProjectId
974
+ ),
975
+ urIngestSessionPlmAcctProjectIdRelated: (0, import_sqlite_core.text)(
976
+ "ur_ingest_session_plm_acct_project_id_related"
977
+ ).notNull(),
978
+ urIngestSessionPlmAcctProjectIssueIdPrime: (0, import_sqlite_core.text)(
979
+ "ur_ingest_session_plm_acct_project_issue_id_prime"
980
+ ).notNull().references(
981
+ () => urIngestSessionPlmAcctProjectIssue.urIngestSessionPlmAcctProjectIssueId
982
+ ),
983
+ urIngestSessionPlmAcctProjectIssueIdRelated: (0, import_sqlite_core.text)(
984
+ "ur_ingest_session_plm_acct_project_issue_id_related"
985
+ ).notNull(),
986
+ relationship: (0, import_sqlite_core.text)(),
987
+ elaboration: (0, import_sqlite_core.text)(),
988
+ ...housekeeping
989
+ },
990
+ (table2) => [
991
+ checkJSON(table2.elaboration)
992
+ ]
993
+ );
994
+ var urIngestSessionPlmComment = (0, import_sqlite_core.sqliteTable)(
995
+ "ur_ingest_session_plm_comment",
996
+ {
997
+ urIngestSessionPlmCommentId: varchar("ur_ingest_session_plm_comment_id").primaryKey().notNull(),
998
+ urIngestSessionPlmAcctProjectIssueId: (0, import_sqlite_core.text)(
999
+ "ur_ingest_session_plm_acct_project_issue_id"
1000
+ ).notNull().references(
1001
+ () => urIngestSessionPlmAcctProjectIssue.urIngestSessionPlmAcctProjectIssueId
1002
+ ),
1003
+ commentId: (0, import_sqlite_core.text)("comment_id").notNull(),
1004
+ nodeId: (0, import_sqlite_core.text)("node_id").notNull(),
1005
+ url: (0, import_sqlite_core.text)().notNull(),
1006
+ body: (0, import_sqlite_core.text)(),
1007
+ bodyText: (0, import_sqlite_core.text)("body_text"),
1008
+ bodyHtml: (0, import_sqlite_core.text)("body_html"),
1009
+ user: (0, import_sqlite_core.text)().notNull().references(
1010
+ () => urIngestSessionPlmUser.urIngestSessionPlmUserId
1011
+ ),
1012
+ elaboration: (0, import_sqlite_core.text)(),
1013
+ ...housekeeping
1014
+ },
1015
+ (table2) => [
1016
+ (0, import_sqlite_core.unique)().on(table2.commentId, table2.url, table2.body),
1017
+ checkJSON(table2.elaboration)
1018
+ ]
1019
+ );
1020
+ var urIngestSessionPlmReaction = (0, import_sqlite_core.sqliteTable)(
1021
+ "ur_ingest_session_plm_reaction",
1022
+ {
1023
+ urIngestSessionPlmReactionId: varchar("ur_ingest_session_plm_reaction_id").primaryKey().notNull(),
1024
+ reactionId: (0, import_sqlite_core.text)("reaction_id").notNull(),
1025
+ reactionType: (0, import_sqlite_core.text)("reaction_type").notNull(),
1026
+ elaboration: (0, import_sqlite_core.text)(),
1027
+ ...housekeeping
1028
+ },
1029
+ (table2) => [
1030
+ (0, import_sqlite_core.unique)().on(table2.reactionType),
1031
+ checkJSON(table2.elaboration)
1032
+ ]
1033
+ );
1034
+ var urIngestSessionPlmIssueReaction = (0, import_sqlite_core.sqliteTable)(
1035
+ "ur_ingest_session_plm_issue_reaction",
1036
+ {
1037
+ urIngestSessionPlmIssueReactionId: varchar(
1038
+ "ur_ingest_session_plm_issue_reaction_id"
1039
+ ).primaryKey().notNull(),
1040
+ urIngestPlmReactionId: (0, import_sqlite_core.text)("ur_ingest_plm_reaction_id").notNull().references(() => urIngestSessionPlmReaction.urIngestSessionPlmReactionId),
1041
+ urIngestPlmIssueId: (0, import_sqlite_core.text)("ur_ingest_plm_issue_id").notNull().references(
1042
+ () => urIngestSessionPlmAcctProjectIssue.urIngestSessionPlmAcctProjectIssueId
1043
+ ),
1044
+ count: (0, import_sqlite_core.integer)().default(1),
1045
+ elaboration: (0, import_sqlite_core.text)(),
1046
+ ...housekeeping
1047
+ },
1048
+ (table2) => [
1049
+ (0, import_sqlite_core.unique)().on(table2.urIngestPlmIssueId, table2.urIngestPlmReactionId),
1050
+ checkJSON(table2.elaboration)
1051
+ ]
1052
+ );
1053
+ var urIngestSessionAttachment = (0, import_sqlite_core.sqliteTable)("ur_ingest_session_attachment", {
1054
+ urIngestSessionAttachmentId: (0, import_sqlite_core.text)("ur_ingest_session_attachment_id").primaryKey().notNull(),
1055
+ uniformResourceId: (0, import_sqlite_core.text)("uniform_resource_id").references(
1056
+ () => uniformResource.uniformResourceId
1057
+ ),
1058
+ name: (0, import_sqlite_core.text)(),
1059
+ uri: (0, import_sqlite_core.text)().notNull(),
1060
+ content: (0, import_sqlite_core.blob)(),
1061
+ nature: (0, import_sqlite_core.text)(),
1062
+ size: (0, import_sqlite_core.integer)(),
1063
+ checksum: (0, import_sqlite_core.text)(),
1064
+ elaboration: (0, import_sqlite_core.text)(),
1065
+ ...housekeeping
1066
+ }, (table2) => [
1067
+ (0, import_sqlite_core.index)("idx_ur_ingest_session_attachment__uniform_resource_id__content").on(
1068
+ table2.uniformResourceId,
1069
+ table2.content
1070
+ ),
1071
+ (0, import_sqlite_core.unique)().on(table2.uniformResourceId, table2.checksum, table2.nature, table2.size)
1072
+ ]);
1073
+ var urIngestSessionUdiPgpSql = (0, import_sqlite_core.sqliteTable)("ur_ingest_session_udi_pgp_sql", {
1074
+ urIngestSessionUdiPgpSqlId: (0, import_sqlite_core.text)("ur_ingest_session_udi_pgp_sql_id").primaryKey().notNull(),
1075
+ sql: (0, import_sqlite_core.text)().notNull(),
1076
+ nature: (0, import_sqlite_core.text)().notNull(),
1077
+ content: (0, import_sqlite_core.blob)(),
1078
+ behaviour: (0, import_sqlite_core.text)(),
1079
+ queryError: (0, import_sqlite_core.text)("query_error"),
1080
+ uniformResourceId: (0, import_sqlite_core.text)("uniform_resource_id").references(
1081
+ () => uniformResource.uniformResourceId
1082
+ ),
1083
+ ingestSessionId: (0, import_sqlite_core.text)("ingest_session_id").references(
1084
+ () => urIngestSession.urIngestSessionId
1085
+ ),
1086
+ ...housekeeping
1087
+ }, (table2) => [
1088
+ (0, import_sqlite_core.index)("idx_ur_ingest_session_udi_pgp_sql__ingest_session_id").on(
1089
+ table2.ingestSessionId
1090
+ ),
1091
+ (0, import_sqlite_core.unique)().on(table2.sql, table2.ingestSessionId),
1092
+ checkJSON(table2.behaviour)
1093
+ ]);
1094
+ var orchestrationNature = (0, import_sqlite_core.sqliteTable)("orchestration_nature", {
1095
+ orchestrationNatureId: (0, import_sqlite_core.text)("orchestration_nature_id").primaryKey().notNull(),
1096
+ nature: (0, import_sqlite_core.text)().notNull(),
1097
+ elaboration: (0, import_sqlite_core.text)(),
1098
+ ...housekeeping
1099
+ }, (table2) => [
1100
+ (0, import_sqlite_core.index)("idx_orchestration_nature__orchestration_nature_id__nature").on(
1101
+ table2.orchestrationNatureId,
1102
+ table2.nature
1103
+ ),
1104
+ (0, import_sqlite_core.unique)().on(table2.orchestrationNatureId, table2.nature)
1105
+ ]);
1106
+ var orchestrationSession = (0, import_sqlite_core.sqliteTable)("orchestration_session", {
1107
+ orchestrationSessionId: (0, import_sqlite_core.text)("orchestration_session_id").primaryKey().notNull(),
1108
+ deviceId: (0, import_sqlite_core.text)("device_id").notNull().references(() => device.deviceId),
1109
+ orchestrationNatureId: (0, import_sqlite_core.text)("orchestration_nature_id").notNull().references(
1110
+ () => orchestrationNature.orchestrationNatureId
1111
+ ),
1112
+ version: (0, import_sqlite_core.text)().notNull(),
1113
+ orchStartedAt: timestamptz("orch_started_at"),
1114
+ orchFinishedAt: timestamptz("orch_finished_at"),
1115
+ elaboration: (0, import_sqlite_core.text)(),
1116
+ argsJson: (0, import_sqlite_core.text)("args_json"),
1117
+ diagnosticsJson: (0, import_sqlite_core.text)("diagnostics_json"),
1118
+ diagnosticsMd: (0, import_sqlite_core.text)("diagnostics_md")
1119
+ }, (table2) => [
1120
+ checkJSON(table2.elaboration),
1121
+ checkJSON(table2.argsJson),
1122
+ checkJSON(table2.diagnosticsJson)
1123
+ ]);
1124
+ var orchestrationSessionEntry = (0, import_sqlite_core.sqliteTable)("orchestration_session_entry", {
1125
+ orchestrationSessionEntryId: (0, import_sqlite_core.text)("orchestration_session_entry_id").primaryKey().notNull(),
1126
+ sessionId: (0, import_sqlite_core.text)("session_id").notNull().references(
1127
+ () => orchestrationSession.orchestrationSessionId
1128
+ ),
1129
+ ingestSrc: (0, import_sqlite_core.text)("ingest_src").notNull(),
1130
+ ingestTableName: (0, import_sqlite_core.text)("ingest_table_name"),
1131
+ elaboration: (0, import_sqlite_core.text)()
1132
+ }, (table2) => []);
1133
+ var orchestrationSessionState = (0, import_sqlite_core.sqliteTable)("orchestration_session_state", {
1134
+ orchestrationSessionStateId: (0, import_sqlite_core.text)("orchestration_session_state_id").primaryKey().notNull(),
1135
+ sessionId: (0, import_sqlite_core.text)("session_id").notNull().references(
1136
+ () => orchestrationSession.orchestrationSessionId
1137
+ ),
1138
+ sessionEntryId: (0, import_sqlite_core.text)("session_entry_id").references(
1139
+ () => orchestrationSessionEntry.orchestrationSessionEntryId
1140
+ ),
1141
+ fromState: (0, import_sqlite_core.text)("from_state").notNull(),
1142
+ toState: (0, import_sqlite_core.text)("to_state").notNull(),
1143
+ transitionResult: (0, import_sqlite_core.text)("transition_result"),
1144
+ transitionReason: (0, import_sqlite_core.text)("transition_reason"),
1145
+ transitionedAt: timestamptz("transitioned_at"),
1146
+ elaboration: (0, import_sqlite_core.text)()
1147
+ }, (table2) => [
1148
+ (0, import_sqlite_core.unique)().on(table2.orchestrationSessionStateId, table2.fromState, table2.toState)
1149
+ ]);
1150
+ var orchestrationSessionExec = (0, import_sqlite_core.sqliteTable)("orchestration_session_exec", {
1151
+ orchestrationSessionExecId: (0, import_sqlite_core.text)("orchestration_session_exec_id").primaryKey().notNull(),
1152
+ execNature: (0, import_sqlite_core.text)("exec_nature").notNull(),
1153
+ sessionId: (0, import_sqlite_core.text)("session_id").notNull().references(
1154
+ () => orchestrationSession.orchestrationSessionId
1155
+ ),
1156
+ sessionEntryId: (0, import_sqlite_core.text)("session_entry_id").references(
1157
+ () => orchestrationSessionEntry.orchestrationSessionEntryId
1158
+ ),
1159
+ parentExecId: (0, import_sqlite_core.text)("parent_exec_id"),
1160
+ namespace: (0, import_sqlite_core.text)(),
1161
+ execIdentity: (0, import_sqlite_core.text)("exec_identity"),
1162
+ execCode: (0, import_sqlite_core.text)("exec_code").notNull(),
1163
+ execStatus: (0, import_sqlite_core.integer)("exec_status").notNull(),
1164
+ inputText: (0, import_sqlite_core.text)("input_text"),
1165
+ execErrorText: (0, import_sqlite_core.text)("exec_error_text"),
1166
+ outputText: (0, import_sqlite_core.text)("output_text"),
1167
+ outputNature: (0, import_sqlite_core.text)("output_nature"),
1168
+ narrativeMd: (0, import_sqlite_core.text)("narrative_md"),
1169
+ elaboration: (0, import_sqlite_core.text)()
1170
+ }, (table2) => [
1171
+ (0, import_sqlite_core.foreignKey)(() => ({
1172
+ columns: [table2.parentExecId],
1173
+ foreignColumns: [table2.orchestrationSessionExecId],
1174
+ name: "orchestration_session_exec_parent_exec_id_orchestration_session_exec_orchestration_session_exec_id_fk"
1175
+ }))
1176
+ ]);
1177
+ var orchestrationSessionIssue = (0, import_sqlite_core.sqliteTable)("orchestration_session_issue", {
1178
+ orchestrationSessionIssueId: (0, import_sqlite_core.numeric)("orchestration_session_issue_id").primaryKey().notNull(),
1179
+ sessionId: (0, import_sqlite_core.text)("session_id").notNull().references(
1180
+ () => orchestrationSession.orchestrationSessionId
1181
+ ),
1182
+ sessionEntryId: (0, import_sqlite_core.text)("session_entry_id").references(
1183
+ () => orchestrationSessionEntry.orchestrationSessionEntryId
1184
+ ),
1185
+ issueType: (0, import_sqlite_core.text)("issue_type").notNull(),
1186
+ issueMessage: (0, import_sqlite_core.text)("issue_message").notNull(),
1187
+ issueRow: (0, import_sqlite_core.integer)("issue_row"),
1188
+ issueColumn: (0, import_sqlite_core.text)("issue_column"),
1189
+ invalidValue: (0, import_sqlite_core.text)("invalid_value"),
1190
+ remediation: (0, import_sqlite_core.text)(),
1191
+ elaboration: (0, import_sqlite_core.text)()
1192
+ }, (table2) => []);
1193
+ var orchestrationSessionIssueRelation = (0, import_sqlite_core.sqliteTable)(
1194
+ "orchestration_session_issue_relation",
1195
+ {
1196
+ orchestrationSessionIssueRelationId: (0, import_sqlite_core.numeric)(
1197
+ "orchestration_session_issue_relation_id"
1198
+ ).primaryKey().notNull(),
1199
+ issueIdPrime: (0, import_sqlite_core.numeric)("issue_id_prime").notNull().references(
1200
+ () => orchestrationSessionIssue.orchestrationSessionIssueId
1201
+ ),
1202
+ issueIdRel: (0, import_sqlite_core.text)("issue_id_rel").notNull(),
1203
+ relationshipNature: (0, import_sqlite_core.text)("relationship_nature").notNull(),
1204
+ elaboration: (0, import_sqlite_core.text)()
1205
+ },
1206
+ (table2) => []
1207
+ );
1208
+ var orchestrationSessionLog = (0, import_sqlite_core.sqliteTable)("orchestration_session_log", {
1209
+ orchestrationSessionLogId: (0, import_sqlite_core.numeric)("orchestration_session_log_id").primaryKey().notNull(),
1210
+ category: (0, import_sqlite_core.text)(),
1211
+ parentExecId: (0, import_sqlite_core.numeric)("parent_exec_id"),
1212
+ content: (0, import_sqlite_core.text)().notNull(),
1213
+ siblingOrder: (0, import_sqlite_core.integer)("sibling_order"),
1214
+ elaboration: (0, import_sqlite_core.text)()
1215
+ }, (table2) => [
1216
+ (0, import_sqlite_core.foreignKey)(() => ({
1217
+ columns: [table2.parentExecId],
1218
+ foreignColumns: [table2.orchestrationSessionLogId],
1219
+ name: "orchestration_session_log_parent_exec_id_orchestration_session_log_orchestration_session_log_id_fk"
1220
+ }))
1221
+ ]);
1222
+ var uniformResourceGraph = (0, import_sqlite_core.sqliteTable)("uniform_resource_graph", {
1223
+ name: (0, import_sqlite_core.text)().primaryKey().notNull(),
1224
+ elaboration: (0, import_sqlite_core.text)()
1225
+ }, (table2) => []);
1226
+ var uniformResourceEdge = (0, import_sqlite_core.sqliteTable)("uniform_resource_edge", {
1227
+ graphName: (0, import_sqlite_core.text)("graph_name").notNull().references(
1228
+ () => uniformResourceGraph.name
1229
+ ),
1230
+ nature: (0, import_sqlite_core.text)().notNull(),
1231
+ nodeId: (0, import_sqlite_core.text)("node_id").notNull(),
1232
+ uniformResourceId: (0, import_sqlite_core.text)("uniform_resource_id").notNull().references(
1233
+ () => uniformResource.uniformResourceId
1234
+ ),
1235
+ elaboration: (0, import_sqlite_core.text)()
1236
+ }, (table2) => [
1237
+ (0, import_sqlite_core.index)("idx_uniform_resource_edge__uniform_resource_id").on(
1238
+ table2.uniformResourceId
1239
+ ),
1240
+ (0, import_sqlite_core.unique)().on(table2.graphName, table2.nature, table2.nodeId, table2.uniformResourceId)
1241
+ ]);
1242
+ var surveilrOsqueryMsNode = (0, import_sqlite_core.sqliteTable)("surveilr_osquery_ms_node", {
1243
+ surveilrOsqueryMsNodeId: (0, import_sqlite_core.text)("surveilr_osquery_ms_node_id").primaryKey().notNull(),
1244
+ nodeKey: (0, import_sqlite_core.text)("node_key").notNull(),
1245
+ hostIdentifier: (0, import_sqlite_core.text)("host_identifier").notNull(),
1246
+ tlsCertSubject: (0, import_sqlite_core.text)("tls_cert_subject"),
1247
+ osVersion: (0, import_sqlite_core.text)("os_version").notNull(),
1248
+ platform: (0, import_sqlite_core.text)().notNull(),
1249
+ lastSeen: (0, import_sqlite_core.numeric)("last_seen").notNull(),
1250
+ status: (0, import_sqlite_core.text)().default("active").notNull(),
1251
+ osqueryVersion: (0, import_sqlite_core.text)("osquery_version"),
1252
+ osqueryBuildPlatform: (0, import_sqlite_core.text)("osquery_build_platform").notNull(),
1253
+ deviceId: (0, import_sqlite_core.text)("device_id").notNull().references(() => device.deviceId),
1254
+ behaviorId: (0, import_sqlite_core.text)("behavior_id").references(() => behavior.behaviorId),
1255
+ accelerate: (0, import_sqlite_core.integer)().default(60).notNull(),
1256
+ ...housekeeping
1257
+ }, (table2) => [
1258
+ (0, import_sqlite_core.index)("idx_surveilr_osquery_ms_node__node_key").on(table2.nodeKey),
1259
+ (0, import_sqlite_core.unique)().on(table2.hostIdentifier, table2.osVersion),
1260
+ (0, import_sqlite_core.unique)().on(table2.nodeKey)
1261
+ ]);
1262
+ var urIngestSessionOsqueryMsLog = (0, import_sqlite_core.sqliteTable)(
1263
+ "ur_ingest_session_osquery_ms_log",
1264
+ {
1265
+ urIngestSessionOsqueryMsLogId: (0, import_sqlite_core.text)("ur_ingest_session_osquery_ms_log_id").primaryKey().notNull(),
1266
+ nodeKey: (0, import_sqlite_core.text)("node_key").notNull().references(
1267
+ () => surveilrOsqueryMsNode.nodeKey
1268
+ ),
1269
+ logType: (0, import_sqlite_core.text)("log_type").notNull(),
1270
+ logData: (0, import_sqlite_core.text)("log_data").notNull(),
1271
+ appliedJqFilters: (0, import_sqlite_core.text)("applied_jq_filters"),
1272
+ ...housekeeping
1273
+ },
1274
+ (table2) => [
1275
+ (0, import_sqlite_core.unique)().on(table2.nodeKey, table2.logType, table2.logData)
1276
+ ]
1277
+ );
1278
+ var osqueryPolicy = (0, import_sqlite_core.sqliteTable)("osquery_policy", {
1279
+ osqueryPolicyId: (0, import_sqlite_core.text)("osquery_policy_id").primaryKey().notNull(),
1280
+ policyGroup: (0, import_sqlite_core.text)("policy_group"),
1281
+ policyName: (0, import_sqlite_core.text)("policy_name").notNull(),
1282
+ osqueryCode: (0, import_sqlite_core.text)("osquery_code").notNull(),
1283
+ policyDescription: (0, import_sqlite_core.text)("policy_description").notNull(),
1284
+ policyPassLabel: (0, import_sqlite_core.text)("policy_pass_label").default("Pass").notNull(),
1285
+ policyFailLabel: (0, import_sqlite_core.text)("policy_fail_label").default("Fail").notNull(),
1286
+ policyPassRemarks: (0, import_sqlite_core.text)("policy_pass_remarks"),
1287
+ policyFailRemarks: (0, import_sqlite_core.text)("policy_fail_remarks"),
1288
+ osqueryPlatforms: (0, import_sqlite_core.text)("osquery_platforms"),
1289
+ ...housekeeping
1290
+ }, (table2) => [
1291
+ (0, import_sqlite_core.unique)().on(table2.policyName, table2.osqueryCode)
1292
+ ]);
1293
+ var surveilrOsqueryMsDistributedQuery = (0, import_sqlite_core.sqliteTable)(
1294
+ "surveilr_osquery_ms_distributed_query",
1295
+ {
1296
+ queryId: (0, import_sqlite_core.text)("query_id").primaryKey().notNull(),
1297
+ nodeKey: (0, import_sqlite_core.text)("node_key").notNull().references(
1298
+ () => surveilrOsqueryMsNode.nodeKey
1299
+ ),
1300
+ queryName: (0, import_sqlite_core.text)("query_name").notNull(),
1301
+ querySql: (0, import_sqlite_core.text)("query_sql").notNull(),
1302
+ discoveryQuery: (0, import_sqlite_core.text)("discovery_query"),
1303
+ status: (0, import_sqlite_core.text)().notNull(),
1304
+ elaboration: (0, import_sqlite_core.text)(),
1305
+ interval: (0, import_sqlite_core.integer)().notNull(),
1306
+ ...housekeeping
1307
+ },
1308
+ (table2) => []
1309
+ );
1310
+ var surveilrOsqueryMsDistributedResult = (0, import_sqlite_core.sqliteTable)(
1311
+ "surveilr_osquery_ms_distributed_result",
1312
+ {
1313
+ surveilrOsqueryMsDistributedResultId: (0, import_sqlite_core.text)(
1314
+ "surveilr_osquery_ms_distributed_result_id"
1315
+ ).primaryKey().notNull(),
1316
+ queryId: (0, import_sqlite_core.text)("query_id").notNull().references(
1317
+ () => surveilrOsqueryMsDistributedQuery.queryId
1318
+ ),
1319
+ nodeKey: (0, import_sqlite_core.text)("node_key").notNull().references(
1320
+ () => surveilrOsqueryMsNode.nodeKey
1321
+ ),
1322
+ results: (0, import_sqlite_core.text)().notNull(),
1323
+ statusCode: (0, import_sqlite_core.integer)("status_code").notNull(),
1324
+ ...housekeeping
1325
+ },
1326
+ (table2) => []
1327
+ );
1328
+ var surveilrOsqueryMsCarve = (0, import_sqlite_core.sqliteTable)("surveilr_osquery_ms_carve", {
1329
+ surveilrOsqueryMsCarveId: (0, import_sqlite_core.text)("surveilr_osquery_ms_carve_id").primaryKey().notNull(),
1330
+ nodeKey: (0, import_sqlite_core.text)("node_key").notNull().references(
1331
+ () => surveilrOsqueryMsNode.nodeKey
1332
+ ),
1333
+ sessionId: (0, import_sqlite_core.text)("session_id").notNull(),
1334
+ carveGuid: (0, import_sqlite_core.text)("carve_guid").notNull(),
1335
+ carveSize: (0, import_sqlite_core.integer)("carve_size").notNull(),
1336
+ blockCount: (0, import_sqlite_core.integer)("block_count").notNull(),
1337
+ blockSize: (0, import_sqlite_core.integer)("block_size").notNull(),
1338
+ receivedBlocks: (0, import_sqlite_core.integer)("received_blocks").default(0).notNull(),
1339
+ carvePath: (0, import_sqlite_core.text)("carve_path"),
1340
+ status: (0, import_sqlite_core.text)().notNull(),
1341
+ startTime: (0, import_sqlite_core.numeric)("start_time").notNull(),
1342
+ completionTime: (0, import_sqlite_core.numeric)("completion_time"),
1343
+ elaboration: (0, import_sqlite_core.text)(),
1344
+ ...housekeeping
1345
+ }, (table2) => [
1346
+ (0, import_sqlite_core.unique)().on(table2.sessionId),
1347
+ (0, import_sqlite_core.unique)().on(table2.carveGuid)
1348
+ ]);
1349
+ var surveilrOsqueryMsCarvedExtractedFile = (0, import_sqlite_core.sqliteTable)(
1350
+ "surveilr_osquery_ms_carved_extracted_file",
1351
+ {
1352
+ surveilrOsqueryMsCarvedExtractedFileId: (0, import_sqlite_core.text)(
1353
+ "surveilr_osquery_ms_carved_extracted_file_id"
1354
+ ).primaryKey().notNull(),
1355
+ carveGuid: (0, import_sqlite_core.text)("carve_guid").notNull().references(
1356
+ () => surveilrOsqueryMsCarve.carveGuid
1357
+ ),
1358
+ path: (0, import_sqlite_core.text)().notNull(),
1359
+ sizeBytes: (0, import_sqlite_core.integer)("size_bytes").notNull(),
1360
+ contentDigest: (0, import_sqlite_core.text)("content_digest").notNull(),
1361
+ nature: (0, import_sqlite_core.text)(),
1362
+ extractedAt: timestamptz("extracted_at").notNull(),
1363
+ ...housekeeping
1364
+ },
1365
+ (table2) => [
1366
+ (0, import_sqlite_core.index)("idx_surveilr_osquery_ms_carved_extracted_file__path__carve_guid").on(
1367
+ table2.path,
1368
+ table2.carveGuid
1369
+ )
1370
+ ]
1371
+ );
1372
+ var surveilrSnmpDevice = (0, import_sqlite_core.sqliteTable)("surveilr_snmp_device", {
1373
+ surveilrSnmpDeviceId: (0, import_sqlite_core.text)("surveilr_snmp_device_id").primaryKey().notNull(),
1374
+ deviceKey: (0, import_sqlite_core.text)("device_key").notNull(),
1375
+ snmpHost: (0, import_sqlite_core.text)("snmp_host").notNull(),
1376
+ snmpPort: (0, import_sqlite_core.integer)("snmp_port").default(161).notNull(),
1377
+ snmpCommunity: (0, import_sqlite_core.text)("snmp_community").notNull(),
1378
+ snmpVersion: (0, import_sqlite_core.text)("snmp_version").default("2c").notNull(),
1379
+ snmpTimeout: (0, import_sqlite_core.integer)("snmp_timeout").default(5).notNull(),
1380
+ snmpRetries: (0, import_sqlite_core.integer)("snmp_retries").default(3).notNull(),
1381
+ deviceType: (0, import_sqlite_core.text)("device_type"),
1382
+ deviceDescription: (0, import_sqlite_core.text)("device_description"),
1383
+ lastSeen: (0, import_sqlite_core.numeric)("last_seen").notNull(),
1384
+ status: (0, import_sqlite_core.text)().default("active").notNull(),
1385
+ deviceId: (0, import_sqlite_core.text)("device_id").notNull().references(() => device.deviceId),
1386
+ behaviorId: (0, import_sqlite_core.text)("behavior_id").references(() => behavior.behaviorId),
1387
+ elaboration: (0, import_sqlite_core.text)(),
1388
+ ...housekeeping
1389
+ }, (table2) => [
1390
+ (0, import_sqlite_core.index)("idx_surveilr_snmp_device__device_key").on(table2.deviceKey),
1391
+ (0, import_sqlite_core.unique)().on(table2.snmpHost, table2.snmpPort),
1392
+ (0, import_sqlite_core.unique)().on(table2.deviceKey),
1393
+ checkJSON(table2.elaboration)
1394
+ ]);
1395
+ var surveilrSnmpCollection = (0, import_sqlite_core.sqliteTable)("surveilr_snmp_collection", {
1396
+ surveilrSnmpCollectionId: (0, import_sqlite_core.text)("surveilr_snmp_collection_id").primaryKey().notNull(),
1397
+ deviceKey: (0, import_sqlite_core.text)("device_key").notNull().references(
1398
+ () => surveilrSnmpDevice.deviceKey
1399
+ ),
1400
+ oid: (0, import_sqlite_core.text)().notNull(),
1401
+ oidValue: (0, import_sqlite_core.text)("oid_value").notNull(),
1402
+ oidType: (0, import_sqlite_core.text)("oid_type").notNull(),
1403
+ collectedAt: timestamptz("collected_at").notNull(),
1404
+ elaboration: (0, import_sqlite_core.text)(),
1405
+ ...housekeeping
1406
+ }, (table2) => [
1407
+ (0, import_sqlite_core.index)("idx_surveilr_snmp_collection__device_key__oid").on(
1408
+ table2.deviceKey,
1409
+ table2.oid
1410
+ ),
1411
+ (0, import_sqlite_core.index)("idx_surveilr_snmp_collection__collected_at").on(table2.collectedAt),
1412
+ checkJSON(table2.elaboration)
1413
+ ]);
1414
+ var surveilrFunctionDoc = (0, import_sqlite_core.sqliteTable)("surveilr_function_doc", {
1415
+ name: (0, import_sqlite_core.text)().primaryKey(),
1416
+ description: (0, import_sqlite_core.text)(),
1417
+ parameters: (0, import_sqlite_core.text)({ mode: "json" }),
1418
+ returnType: (0, import_sqlite_core.text)("return_type"),
1419
+ version: (0, import_sqlite_core.text)()
1420
+ }, (table2) => [
1421
+ checkJSON(table2.parameters)
1422
+ ]);
1423
+
1424
+ // views.ts
1425
+ var import_sqlite_core2 = require("drizzle-orm/sqlite-core");
1426
+ var import_drizzle_orm2 = require("drizzle-orm");
1427
+ var codeNotebookCellVersions = (0, import_sqlite_core2.sqliteView)("code_notebook_cell_versions").as((qb) => {
1428
+ return qb.select({
1429
+ notebookName: codeNotebookCell.notebookName,
1430
+ notebookKernelId: codeNotebookCell.notebookKernelId,
1431
+ cellName: codeNotebookCell.cellName,
1432
+ versions: import_drizzle_orm2.sql`COUNT(*) OVER(PARTITION BY ${codeNotebookCell.notebookName}, ${codeNotebookCell.cellName})`.as("versions"),
1433
+ codeNotebookCellId: codeNotebookCell.codeNotebookCellId
1434
+ }).from(codeNotebookCell).orderBy(codeNotebookCell.notebookName, codeNotebookCell.cellName);
1435
+ });
1436
+ var codeNotebookCellLatest = (0, import_sqlite_core2.sqliteView)("code_notebook_cell_latest").as((qb) => {
1437
+ return qb.select({
1438
+ codeNotebookCellId: codeNotebookCell.codeNotebookCellId,
1439
+ notebookKernelId: codeNotebookCell.notebookKernelId,
1440
+ notebookName: codeNotebookCell.notebookName,
1441
+ cellName: codeNotebookCell.cellName,
1442
+ interpretableCode: codeNotebookCell.interpretableCode,
1443
+ interpretableCodeHash: codeNotebookCell.interpretableCodeHash,
1444
+ description: codeNotebookCell.description,
1445
+ cellGovernance: codeNotebookCell.cellGovernance,
1446
+ arguments: codeNotebookCell.arguments,
1447
+ activityLog: codeNotebookCell.activityLog,
1448
+ versionTimestamp: import_drizzle_orm2.sql`COALESCE(${codeNotebookCell.updatedAt}, ${codeNotebookCell.createdAt})`.as("version_timestamp")
1449
+ }).from(codeNotebookCell).where(import_drizzle_orm2.sql`${codeNotebookCell.codeNotebookCellId} IN (
1450
+ SELECT code_notebook_cell_id
1451
+ FROM (
1452
+ SELECT code_notebook_cell_id,
1453
+ ROW_NUMBER() OVER (
1454
+ PARTITION BY code_notebook_cell_id
1455
+ ORDER BY COALESCE(updated_at, created_at) DESC
1456
+ ) AS rn
1457
+ FROM code_notebook_cell
1458
+ ) ranked WHERE rn = 1
1459
+ )`);
1460
+ });
1461
+ var codeNotebookSqlCellMigratableVersion = (0, import_sqlite_core2.sqliteView)("code_notebook_sql_cell_migratable_version").as((qb) => {
1462
+ return qb.select({
1463
+ codeNotebookCellId: codeNotebookCell.codeNotebookCellId,
1464
+ notebookName: codeNotebookCell.notebookName,
1465
+ cellName: codeNotebookCell.cellName,
1466
+ interpretableCode: codeNotebookCell.interpretableCode,
1467
+ interpretableCodeHash: codeNotebookCell.interpretableCodeHash,
1468
+ isIdempotent: import_drizzle_orm2.sql`CASE WHEN ${codeNotebookCell.cellName} LIKE '%_once_%' THEN FALSE ELSE TRUE END`.as("is_idempotent"),
1469
+ versionTimestamp: import_drizzle_orm2.sql`COALESCE(${codeNotebookCell.updatedAt}, ${codeNotebookCell.createdAt})`.as("version_timestamp")
1470
+ }).from(codeNotebookCell).where((0, import_drizzle_orm2.eq)(codeNotebookCell.notebookName, "ConstructionSqlNotebook")).orderBy(codeNotebookCell.cellName);
1471
+ });
1472
+ var codeNotebookSqlCellMigratable = (0, import_sqlite_core2.sqliteView)("code_notebook_sql_cell_migratable").as((qb) => {
1473
+ return qb.select({
1474
+ codeNotebookCellId: codeNotebookCell.codeNotebookCellId,
1475
+ notebookKernelId: codeNotebookCell.notebookKernelId,
1476
+ notebookName: codeNotebookCell.notebookName,
1477
+ cellName: codeNotebookCell.cellName,
1478
+ interpretableCode: codeNotebookCell.interpretableCode,
1479
+ interpretableCodeHash: codeNotebookCell.interpretableCodeHash,
1480
+ description: codeNotebookCell.description,
1481
+ cellGovernance: codeNotebookCell.cellGovernance,
1482
+ arguments: codeNotebookCell.arguments,
1483
+ activityLog: codeNotebookCell.activityLog,
1484
+ isIdempotent: import_drizzle_orm2.sql`CASE WHEN ${codeNotebookCell.cellName} LIKE '%_once_%' THEN FALSE ELSE TRUE END`.as("is_idempotent")
1485
+ }).from(codeNotebookCell).where((0, import_drizzle_orm2.eq)(codeNotebookCell.notebookName, "ConstructionSqlNotebook")).orderBy(codeNotebookCell.cellName);
1486
+ });
1487
+ var codeNotebookSqlCellMigratableState = (0, import_sqlite_core2.sqliteView)("code_notebook_sql_cell_migratable_state").as((qb) => {
1488
+ return qb.select({
1489
+ codeNotebookCellId: codeNotebookCell.codeNotebookCellId,
1490
+ notebookKernelId: codeNotebookCell.notebookKernelId,
1491
+ notebookName: codeNotebookCell.notebookName,
1492
+ cellName: codeNotebookCell.cellName,
1493
+ interpretableCode: codeNotebookCell.interpretableCode,
1494
+ interpretableCodeHash: codeNotebookCell.interpretableCodeHash,
1495
+ description: codeNotebookCell.description,
1496
+ cellGovernance: codeNotebookCell.cellGovernance,
1497
+ arguments: codeNotebookCell.arguments,
1498
+ activityLog: codeNotebookCell.activityLog,
1499
+ fromState: codeNotebookState.fromState,
1500
+ toState: codeNotebookState.toState,
1501
+ transitionReason: codeNotebookState.transitionReason,
1502
+ transitionResult: codeNotebookState.transitionResult,
1503
+ transitionedAt: codeNotebookState.transitionedAt
1504
+ }).from(codeNotebookCell).innerJoin(codeNotebookState, (0, import_drizzle_orm2.eq)(codeNotebookCell.codeNotebookCellId, codeNotebookState.codeNotebookCellId)).where((0, import_drizzle_orm2.eq)(codeNotebookCell.notebookName, "ConstructionSqlNotebook")).orderBy(codeNotebookCell.cellName);
1505
+ });
1506
+ var codeNotebookSqlCellMigratableNotExecuted = (0, import_sqlite_core2.sqliteView)("code_notebook_sql_cell_migratable_not_executed").as((qb) => {
1507
+ return qb.select({
1508
+ codeNotebookCellId: codeNotebookCell.codeNotebookCellId,
1509
+ notebookKernelId: codeNotebookCell.notebookKernelId,
1510
+ notebookName: codeNotebookCell.notebookName,
1511
+ cellName: codeNotebookCell.cellName,
1512
+ interpretableCode: codeNotebookCell.interpretableCode,
1513
+ interpretableCodeHash: codeNotebookCell.interpretableCodeHash,
1514
+ description: codeNotebookCell.description,
1515
+ cellGovernance: codeNotebookCell.cellGovernance,
1516
+ arguments: codeNotebookCell.arguments,
1517
+ activityLog: codeNotebookCell.activityLog
1518
+ }).from(codeNotebookCell).leftJoin(codeNotebookState, (0, import_drizzle_orm2.and)(
1519
+ (0, import_drizzle_orm2.eq)(codeNotebookCell.codeNotebookCellId, codeNotebookState.codeNotebookCellId),
1520
+ (0, import_drizzle_orm2.eq)(codeNotebookState.toState, "EXECUTED")
1521
+ )).where(
1522
+ (0, import_drizzle_orm2.and)(
1523
+ (0, import_drizzle_orm2.eq)(codeNotebookCell.notebookName, "ConstructionSqlNotebook"),
1524
+ import_drizzle_orm2.sql`${codeNotebookState.codeNotebookCellId} IS NULL`
1525
+ )
1526
+ ).orderBy(codeNotebookCell.cellName);
1527
+ });
1528
+ var codeNotebookMigrationSql = (0, import_sqlite_core2.sqliteView)("code_notebook_migration_sql", {}).as(import_drizzle_orm2.sql`
1529
+ SELECT 'BEGIN TRANSACTION;
1530
+
1531
+ ' ||
1532
+ 'CREATE TEMP TABLE IF NOT EXISTS "session_state_ephemeral" (
1533
+ "key" TEXT PRIMARY KEY NOT NULL,
1534
+ "value" TEXT NOT NULL
1535
+ );
1536
+
1537
+ ' ||
1538
+ GROUP_CONCAT(
1539
+ CASE
1540
+ -- Case 1: Non-idempotent and already executed
1541
+ WHEN c.is_idempotent = FALSE AND s.code_notebook_cell_id IS NOT NULL THEN
1542
+ '-- ' || c.notebook_name || '.' || c.cell_name || ' not included because it is non-idempotent and was already executed on ' || s.transitioned_at || '
1543
+
1544
+ '
1545
+ -- Case 2: Idempotent and not yet executed, idempotent and being reapplied, or non-idempotent and being run for the first time
1546
+ ELSE
1547
+ '-- ' || c.notebook_name || '.' || c.cell_name || '
1548
+ ' ||
1549
+ CASE
1550
+ -- First execution (non-idempotent or idempotent)
1551
+ WHEN s.code_notebook_cell_id IS NULL THEN
1552
+ '-- Executing for the first time.
1553
+ '
1554
+ -- Reapplying execution (idempotent)
1555
+ ELSE
1556
+ '-- Reapplying execution. Last executed on ' || s.transitioned_at || '
1557
+ '
1558
+ END ||
1559
+ c.interpretable_code || '
1560
+ ' ||
1561
+ 'INSERT INTO code_notebook_state (code_notebook_state_id, code_notebook_cell_id, from_state, to_state, transition_reason, created_at) ' ||
1562
+ 'VALUES (' ||
1563
+ '''' || c.code_notebook_cell_id || '__' || strftime('%Y%m%d%H%M%S', 'now') || '''' || ', ' ||
1564
+ '''' || c.code_notebook_cell_id || '''' || ', ' ||
1565
+ '''MIGRATION_CANDIDATE''' || ', ' ||
1566
+ '''EXECUTED''' || ', ' ||
1567
+ CASE
1568
+ WHEN s.code_notebook_cell_id IS NULL THEN '''Migration'''
1569
+ ELSE '''Reapplication'''
1570
+ END || ', ' ||
1571
+ 'CURRENT_TIMESTAMP' || ')' || '
1572
+ ' ||
1573
+ 'ON CONFLICT(code_notebook_cell_id, from_state, to_state) DO UPDATE SET updated_at = CURRENT_TIMESTAMP, ' ||
1574
+ 'transition_reason = ''Reapplied ' || datetime('now', 'localtime') || ''';' || '
1575
+ '
1576
+ END,
1577
+ '
1578
+ '
1579
+ ) || '
1580
+
1581
+ COMMIT;' as migration_sql
1582
+ FROM code_notebook_sql_cell_migratable c
1583
+ LEFT JOIN code_notebook_state s
1584
+ ON c.code_notebook_cell_id = s.code_notebook_cell_id AND s.to_state = 'EXECUTED'
1585
+ ORDER BY c.cell_name`);
1586
+ var imapGraph = (0, import_sqlite_core2.sqliteView)("imap_graph").as((qb) => {
1587
+ return qb.select({
1588
+ graphName: uniformResourceEdge.graphName,
1589
+ uniformResourceId: uniformResource.uniformResourceId,
1590
+ nature: uniformResource.nature,
1591
+ uri: uniformResource.uri,
1592
+ content: uniformResource.content,
1593
+ urIngestSessionImapAcctFolderMessageId: urIngestSessionImapAcctFolderMessage.urIngestSessionImapAcctFolderMessageId,
1594
+ ingestImapAcctFolderId: urIngestSessionImapAcctFolderMessage.ingestImapAcctFolderId,
1595
+ messageId: urIngestSessionImapAcctFolderMessage.messageId
1596
+ }).from(uniformResourceEdge).innerJoin(uniformResource, (0, import_drizzle_orm2.eq)(uniformResourceEdge.uniformResourceId, uniformResource.uniformResourceId)).innerJoin(urIngestSessionImapAcctFolderMessage, (0, import_drizzle_orm2.eq)(uniformResourceEdge.nodeId, urIngestSessionImapAcctFolderMessage.urIngestSessionImapAcctFolderMessageId)).where((0, import_drizzle_orm2.eq)(uniformResourceEdge.graphName, "imap"));
1597
+ });
1598
+ var filesystemGraph = (0, import_sqlite_core2.sqliteView)("filesystem_graph").as((qb) => {
1599
+ return qb.select({
1600
+ graphName: uniformResourceEdge.graphName,
1601
+ uniformResourceId: uniformResource.uniformResourceId,
1602
+ nature: uniformResource.nature,
1603
+ uri: uniformResource.uri,
1604
+ urIngestSessionFsPathId: urIngestSessionFsPath.urIngestSessionFsPathId,
1605
+ rootPath: urIngestSessionFsPath.rootPath
1606
+ }).from(uniformResourceEdge).innerJoin(uniformResource, (0, import_drizzle_orm2.eq)(uniformResourceEdge.uniformResourceId, uniformResource.uniformResourceId)).innerJoin(urIngestSessionFsPath, (0, import_drizzle_orm2.eq)(uniformResourceEdge.nodeId, urIngestSessionFsPath.urIngestSessionFsPathId)).where((0, import_drizzle_orm2.eq)(uniformResourceEdge.graphName, "filesystem"));
1607
+ });
1608
+ var consoleInformationSchemaTable = (0, import_sqlite_core2.sqliteView)("console_information_schema_table", {}).as(import_drizzle_orm2.sql`
1609
+ SELECT
1610
+ tbl.name AS table_name,
1611
+ col.name AS column_name,
1612
+ col.type AS data_type,
1613
+ CASE WHEN col.pk = 1 THEN 'Yes' ELSE 'No' END AS is_primary_key,
1614
+ CASE WHEN col."notnull" = 1 THEN 'Yes' ELSE 'No' END AS is_not_null,
1615
+ col.dflt_value AS default_value,
1616
+ 'console/info-schema/table.sql?name=' || tbl.name || '&stats=yes' as info_schema_web_ui_path,
1617
+ '[Content](console/info-schema/table.sql?name=' || tbl.name || '&stats=yes)' as info_schema_link_abbrev_md,
1618
+ '[' || tbl.name || ' (table) Schema](console/info-schema/table.sql?name=' || tbl.name || '&stats=yes)' as info_schema_link_full_md,
1619
+ 'console/content/table/' || tbl.name || '.sql?stats=yes' as content_web_ui_path,
1620
+ '[Content]($SITE_PREFIX_URL/console/content/table/' || tbl.name || '.sql?stats=yes)' as content_web_ui_link_abbrev_md,
1621
+ '[' || tbl.name || ' (table) Content](console/content/table/' || tbl.name || '.sql?stats=yes)' as content_web_ui_link_full_md,
1622
+ tbl.sql as sql_ddl
1623
+ FROM sqlite_master tbl
1624
+ JOIN pragma_table_info(tbl.name) col
1625
+ WHERE tbl.type = 'table' AND tbl.name NOT LIKE 'sqlite_%'
1626
+ `);
1627
+ var consoleInformationSchemaView = (0, import_sqlite_core2.sqliteView)("console_information_schema_view", {}).as(import_drizzle_orm2.sql`
1628
+ SELECT
1629
+ vw.name AS view_name,
1630
+ col.name AS column_name,
1631
+ col.type AS data_type,
1632
+ '/console/info-schema/view.sql?name=' || vw.name || '&stats=yes' as info_schema_web_ui_path,
1633
+ '[Content](console/info-schema/view.sql?name=' || vw.name || '&stats=yes)' as info_schema_link_abbrev_md,
1634
+ '[' || vw.name || ' (view) Schema](console/info-schema/view.sql?name=' || vw.name || '&stats=yes)' as info_schema_link_full_md,
1635
+ '/console/content/view/' || vw.name || '.sql?stats=yes' as content_web_ui_path,
1636
+ '[Content]($SITE_PREFIX_URL/console/content/view/' || vw.name || '.sql?stats=yes)' as content_web_ui_link_abbrev_md,
1637
+ '[' || vw.name || ' (view) Content](console/content/view/' || vw.name || '.sql?stats=yes)' as content_web_ui_link_full_md,
1638
+ vw.sql as sql_ddl
1639
+ FROM sqlite_master vw
1640
+ JOIN pragma_table_info(vw.name) col
1641
+ WHERE vw.type = 'view' AND vw.name NOT LIKE 'sqlite_%'
1642
+ `);
1643
+ var consoleContentTabular = (0, import_sqlite_core2.sqliteView)("console_content_tabular").as((qb) => {
1644
+ const tableQuery = qb.select({
1645
+ tabularNature: import_drizzle_orm2.sql`'table'`.as("tabular_nature"),
1646
+ tabularName: import_drizzle_orm2.sql`table_name`.as("tabular_name"),
1647
+ infoSchemaWebUiPath: import_drizzle_orm2.sql`info_schema_web_ui_path`.as("info_schema_web_ui_path"),
1648
+ infoSchemaLinkAbbrevMd: import_drizzle_orm2.sql`info_schema_link_abbrev_md`.as("info_schema_link_abbrev_md"),
1649
+ infoSchemaLinkFullMd: import_drizzle_orm2.sql`info_schema_link_full_md`.as("info_schema_link_full_md"),
1650
+ contentWebUiPath: import_drizzle_orm2.sql`content_web_ui_path`.as("content_web_ui_path"),
1651
+ contentWebUiLinkAbbrevMd: import_drizzle_orm2.sql`content_web_ui_link_abbrev_md`.as("content_web_ui_link_abbrev_md"),
1652
+ contentWebUiLinkFullMd: import_drizzle_orm2.sql`content_web_ui_link_full_md`.as("content_web_ui_link_full_md")
1653
+ }).from(consoleInformationSchemaTable);
1654
+ const viewQuery = qb.select({
1655
+ tabularNature: import_drizzle_orm2.sql`'view'`.as("tabular_nature"),
1656
+ tabularName: import_drizzle_orm2.sql`view_name`.as("tabular_name"),
1657
+ infoSchemaWebUiPath: import_drizzle_orm2.sql`info_schema_web_ui_path`.as("info_schema_web_ui_path"),
1658
+ infoSchemaLinkAbbrevMd: import_drizzle_orm2.sql`info_schema_link_abbrev_md`.as("info_schema_link_abbrev_md"),
1659
+ infoSchemaLinkFullMd: import_drizzle_orm2.sql`info_schema_link_full_md`.as("info_schema_link_full_md"),
1660
+ contentWebUiPath: import_drizzle_orm2.sql`content_web_ui_path`.as("content_web_ui_path"),
1661
+ contentWebUiLinkAbbrevMd: import_drizzle_orm2.sql`content_web_ui_link_abbrev_md`.as("content_web_ui_link_abbrev_md"),
1662
+ contentWebUiLinkFullMd: import_drizzle_orm2.sql`content_web_ui_link_full_md`.as("content_web_ui_link_full_md")
1663
+ }).from(consoleInformationSchemaView);
1664
+ return tableQuery.unionAll(viewQuery);
1665
+ });
1666
+ var consoleInformationSchemaTableColFkey = (0, import_sqlite_core2.sqliteView)("console_information_schema_table_col_fkey", {}).as(import_drizzle_orm2.sql`
1667
+ SELECT
1668
+ tbl.name AS table_name,
1669
+ f."from" AS column_name,
1670
+ f."from" || ' references ' || f."table" || '.' || f."to" AS foreign_key
1671
+ FROM sqlite_master tbl
1672
+ JOIN pragma_foreign_key_list(tbl.name) f
1673
+ WHERE tbl.type = 'table' AND tbl.name NOT LIKE 'sqlite_%'
1674
+ `);
1675
+ var consoleInformationSchemaTableColIndex = (0, import_sqlite_core2.sqliteView)("console_information_schema_table_col_index", {}).as(import_drizzle_orm2.sql`
1676
+ SELECT
1677
+ tbl.name AS table_name,
1678
+ pi.name AS column_name,
1679
+ idx.name AS index_name
1680
+ FROM sqlite_master tbl
1681
+ JOIN pragma_index_list(tbl.name) idx
1682
+ JOIN pragma_index_info(idx.name) pi
1683
+ WHERE tbl.type = 'table' AND tbl.name NOT LIKE 'sqlite_%'
1684
+ `);
1685
+ var rssdStatisticsOverview = (0, import_sqlite_core2.sqliteView)("rssd_statistics_overview").as((qb) => {
1686
+ return qb.select({
1687
+ dbSizeMb: import_drizzle_orm2.sql`(SELECT ROUND(page_count * page_size / (1024.0 * 1024), 2) FROM pragma_page_count(), pragma_page_size())`.as("db_size_mb"),
1688
+ dbSizeGb: import_drizzle_orm2.sql`(SELECT ROUND(page_count * page_size / (1024.0 * 1024 * 1024), 4) FROM pragma_page_count(), pragma_page_size())`.as("db_size_gb"),
1689
+ totalTables: import_drizzle_orm2.sql`(SELECT COUNT(*) FROM sqlite_master WHERE type = 'table')`.as("total_tables"),
1690
+ totalIndexes: import_drizzle_orm2.sql`(SELECT COUNT(*) FROM sqlite_master WHERE type = 'index')`.as("total_indexes"),
1691
+ totalRows: import_drizzle_orm2.sql`(SELECT SUM(tbl_rows) FROM (SELECT name, (SELECT COUNT(*) FROM sqlite_master sm WHERE sm.type='table' AND sm.name=t.name) AS tbl_rows FROM sqlite_master t WHERE type='table'))`.as("total_rows"),
1692
+ pageSize: import_drizzle_orm2.sql`(SELECT page_size FROM pragma_page_size())`.as("page_size"),
1693
+ totalPages: import_drizzle_orm2.sql`(SELECT page_count FROM pragma_page_count())`.as("total_pages")
1694
+ }).from(import_drizzle_orm2.sql`(SELECT 1) AS dummy`);
1695
+ });
1696
+ var rssdTableStatistic = (0, import_sqlite_core2.sqliteView)("rssd_table_statistic", {}).as(import_drizzle_orm2.sql`
1697
+ SELECT
1698
+ m.name AS table_name,
1699
+ (SELECT COUNT(*) FROM pragma_table_info(m.name)) AS total_columns,
1700
+ (SELECT COUNT(*) FROM pragma_index_list(m.name)) AS total_indexes,
1701
+ (SELECT COUNT(*) FROM pragma_foreign_key_list(m.name)) AS foreign_keys,
1702
+ (SELECT COUNT(*) FROM pragma_table_info(m.name) WHERE pk != 0) AS primary_keys,
1703
+ (SELECT table_size_mb FROM surveilr_table_size WHERE table_name = m.name) AS table_size_mb
1704
+ FROM sqlite_master m
1705
+ WHERE m.type = 'table'
1706
+ `);
1707
+ var uniformResourceFile = (0, import_sqlite_core2.sqliteView)("uniform_resource_file").as((qb) => {
1708
+ return qb.select({
1709
+ uniformResourceId: uniformResource.uniformResourceId,
1710
+ nature: uniformResource.nature,
1711
+ sourcePath: urIngestSessionFsPath.rootPath,
1712
+ filePathRel: urIngestSessionFsPathEntry.filePathRel,
1713
+ sizeBytes: uniformResource.sizeBytes
1714
+ }).from(uniformResource).leftJoin(
1715
+ uniformResourceEdge,
1716
+ (0, import_drizzle_orm2.and)(
1717
+ (0, import_drizzle_orm2.eq)(uniformResource.uniformResourceId, uniformResourceEdge.uniformResourceId),
1718
+ (0, import_drizzle_orm2.eq)(uniformResourceEdge.nature, "ingest_fs_path")
1719
+ )
1720
+ ).leftJoin(urIngestSessionFsPath, (0, import_drizzle_orm2.eq)(uniformResourceEdge.nodeId, urIngestSessionFsPath.urIngestSessionFsPathId)).leftJoin(urIngestSessionFsPathEntry, (0, import_drizzle_orm2.eq)(uniformResource.uniformResourceId, urIngestSessionFsPathEntry.uniformResourceId));
1721
+ });
1722
+ var uniformResourceImap = (0, import_sqlite_core2.sqliteView)("uniform_resource_imap").as((qb) => {
1723
+ return qb.select({
1724
+ uniformResourceId: uniformResource.uniformResourceId,
1725
+ graphName: uniformResourceGraph.name,
1726
+ urIngestSessionImapAccountId: urIngestSessionImapAccount.urIngestSessionImapAccountId,
1727
+ email: urIngestSessionImapAccount.email,
1728
+ host: urIngestSessionImapAccount.host,
1729
+ subject: urIngestSessionImapAcctFolderMessage.subject,
1730
+ from: urIngestSessionImapAcctFolderMessage.from,
1731
+ message: urIngestSessionImapAcctFolderMessage.message,
1732
+ date: urIngestSessionImapAcctFolderMessage.date,
1733
+ urIngestSessionImapAcctFolderId: urIngestSessionImapAcctFolder.urIngestSessionImapAcctFolderId,
1734
+ ingestAccountId: urIngestSessionImapAcctFolder.ingestAccountId,
1735
+ folderName: urIngestSessionImapAcctFolder.folderName,
1736
+ sizeBytes: uniformResource.sizeBytes,
1737
+ nature: uniformResource.nature,
1738
+ content: uniformResource.content
1739
+ }).from(uniformResource).innerJoin(uniformResourceEdge, (0, import_drizzle_orm2.eq)(uniformResourceEdge.uniformResourceId, uniformResource.uniformResourceId)).innerJoin(uniformResourceGraph, (0, import_drizzle_orm2.eq)(uniformResourceGraph.name, uniformResourceEdge.graphName)).innerJoin(urIngestSessionImapAcctFolderMessage, (0, import_drizzle_orm2.eq)(urIngestSessionImapAcctFolderMessage.urIngestSessionImapAcctFolderMessageId, uniformResourceEdge.nodeId)).innerJoin(urIngestSessionImapAcctFolder, (0, import_drizzle_orm2.eq)(urIngestSessionImapAcctFolderMessage.ingestImapAcctFolderId, urIngestSessionImapAcctFolder.urIngestSessionImapAcctFolderId)).leftJoin(urIngestSessionImapAccount, (0, import_drizzle_orm2.eq)(urIngestSessionImapAccount.urIngestSessionImapAccountId, urIngestSessionImapAcctFolder.ingestAccountId)).where((0, import_drizzle_orm2.and)(
1740
+ (0, import_drizzle_orm2.eq)(uniformResource.nature, "text"),
1741
+ (0, import_drizzle_orm2.eq)(uniformResourceGraph.name, "imap"),
1742
+ import_drizzle_orm2.sql`${uniformResource.ingestSessionImapAcctFolderMessage} IS NOT NULL`
1743
+ ));
1744
+ });
1745
+ var uniformResourceImapContent = (0, import_sqlite_core2.sqliteView)("uniform_resource_imap_content").as((qb) => {
1746
+ return qb.select({
1747
+ uniformResourceId: uniformResourceImap.uniformResourceId,
1748
+ baseId: import_drizzle_orm2.sql`base_ur.uniform_resource_id`.as("base_id"),
1749
+ extId: import_drizzle_orm2.sql`ext_ur.uniform_resource_id`.as("ext_id"),
1750
+ baseUri: import_drizzle_orm2.sql`base_ur.uri`.as("base_uri"),
1751
+ extUri: import_drizzle_orm2.sql`ext_ur.uri`.as("ext_uri"),
1752
+ baseNature: import_drizzle_orm2.sql`base_ur.nature`.as("base_nature"),
1753
+ extNature: import_drizzle_orm2.sql`ext_ur.nature`.as("ext_nature"),
1754
+ htmlContent: import_drizzle_orm2.sql`json_extract(part.value, '$.body.Html')`.as("html_content")
1755
+ }).from(uniformResourceImap).innerJoin(import_drizzle_orm2.sql`uniform_resource base_ur`, import_drizzle_orm2.sql`base_ur.uniform_resource_id = ${uniformResourceImap.uniformResourceId}`).innerJoin(import_drizzle_orm2.sql`uniform_resource ext_ur`, import_drizzle_orm2.sql`ext_ur.uri = base_ur.uri || '/json' AND ext_ur.nature = 'json'`).crossJoin(import_drizzle_orm2.sql`json_each(ext_ur.content, '$.parts') AS part`).where((0, import_drizzle_orm2.and)(
1756
+ import_drizzle_orm2.sql`ext_ur.nature = 'json'`,
1757
+ import_drizzle_orm2.sql`json_extract(part.value, '$.body.Html') IS NOT NULL`
1758
+ ));
1759
+ });
1760
+ var urIngestSessionFilesStats = (0, import_sqlite_core2.sqliteView)("ur_ingest_session_files_stats").as((qb) => {
1761
+ return qb.select({
1762
+ deviceId: device.deviceId,
1763
+ ingestSessionId: urIngestSession.urIngestSessionId,
1764
+ ingestSessionStartedAt: urIngestSession.ingestStartedAt,
1765
+ ingestSessionFinishedAt: urIngestSession.ingestFinishedAt,
1766
+ fileExtension: import_drizzle_orm2.sql`COALESCE(${urIngestSessionFsPathEntry.fileExtn}, '')`.as("file_extension"),
1767
+ ingestSessionFsPathId: urIngestSessionFsPath.urIngestSessionFsPathId,
1768
+ ingestSessionRootFsPath: urIngestSessionFsPath.rootPath,
1769
+ totalFileCount: (0, import_drizzle_orm2.count)(urIngestSessionFsPathEntry.uniformResourceId).as("total_file_count"),
1770
+ fileCountWithContent: (0, import_drizzle_orm2.sum)(import_drizzle_orm2.sql`CASE WHEN ${uniformResource.content} IS NOT NULL THEN 1 ELSE 0 END`).as("file_count_with_content"),
1771
+ fileCountWithFrontmatter: (0, import_drizzle_orm2.sum)(import_drizzle_orm2.sql`CASE WHEN ${uniformResource.frontmatter} IS NOT NULL THEN 1 ELSE 0 END`).as("file_count_with_frontmatter"),
1772
+ minFileSizeBytes: (0, import_drizzle_orm2.min)(uniformResource.sizeBytes).as("min_file_size_bytes"),
1773
+ averageFileSizeBytes: import_drizzle_orm2.sql`CAST(ROUND(AVG(${uniformResource.sizeBytes})) AS INTEGER)`.as("average_file_size_bytes"),
1774
+ maxFileSizeBytes: (0, import_drizzle_orm2.max)(uniformResource.sizeBytes).as("max_file_size_bytes"),
1775
+ oldestFileLastModifiedDatetime: (0, import_drizzle_orm2.min)(uniformResource.lastModifiedAt).as("oldest_file_last_modified_datetime"),
1776
+ youngestFileLastModifiedDatetime: (0, import_drizzle_orm2.max)(uniformResource.lastModifiedAt).as("youngest_file_last_modified_datetime")
1777
+ }).from(urIngestSession).innerJoin(device, (0, import_drizzle_orm2.eq)(urIngestSession.deviceId, device.deviceId)).leftJoin(urIngestSessionFsPath, (0, import_drizzle_orm2.eq)(urIngestSession.urIngestSessionId, urIngestSessionFsPath.ingestSessionId)).leftJoin(urIngestSessionFsPathEntry, (0, import_drizzle_orm2.eq)(urIngestSessionFsPath.urIngestSessionFsPathId, urIngestSessionFsPathEntry.ingestFsPathId)).leftJoin(uniformResource, (0, import_drizzle_orm2.eq)(urIngestSessionFsPathEntry.uniformResourceId, uniformResource.uniformResourceId)).groupBy(
1778
+ device.deviceId,
1779
+ urIngestSession.urIngestSessionId,
1780
+ urIngestSession.ingestStartedAt,
1781
+ urIngestSession.ingestFinishedAt,
1782
+ urIngestSessionFsPathEntry.fileExtn,
1783
+ urIngestSessionFsPath.rootPath
1784
+ ).orderBy(device.deviceId, urIngestSession.ingestFinishedAt, urIngestSessionFsPathEntry.fileExtn);
1785
+ });
1786
+ var urIngestSessionFilesStatsLatest = (0, import_sqlite_core2.sqliteView)("ur_ingest_session_files_stats_latest").as((qb) => {
1787
+ return qb.select({
1788
+ deviceId: urIngestSessionFilesStats.deviceId,
1789
+ ingestSessionId: urIngestSessionFilesStats.ingestSessionId,
1790
+ ingestSessionStartedAt: urIngestSessionFilesStats.ingestSessionStartedAt,
1791
+ ingestSessionFinishedAt: urIngestSessionFilesStats.ingestSessionFinishedAt,
1792
+ fileExtension: urIngestSessionFilesStats.fileExtension,
1793
+ ingestSessionFsPathId: urIngestSessionFilesStats.ingestSessionFsPathId,
1794
+ ingestSessionRootFsPath: urIngestSessionFilesStats.ingestSessionRootFsPath,
1795
+ totalFileCount: urIngestSessionFilesStats.totalFileCount,
1796
+ fileCountWithContent: urIngestSessionFilesStats.fileCountWithContent,
1797
+ fileCountWithFrontmatter: urIngestSessionFilesStats.fileCountWithFrontmatter,
1798
+ minFileSizeBytes: urIngestSessionFilesStats.minFileSizeBytes,
1799
+ averageFileSizeBytes: urIngestSessionFilesStats.averageFileSizeBytes,
1800
+ maxFileSizeBytes: urIngestSessionFilesStats.maxFileSizeBytes,
1801
+ oldestFileLastModifiedDatetime: urIngestSessionFilesStats.oldestFileLastModifiedDatetime,
1802
+ youngestFileLastModifiedDatetime: urIngestSessionFilesStats.youngestFileLastModifiedDatetime
1803
+ }).from(urIngestSessionFilesStats).where(import_drizzle_orm2.sql`${urIngestSessionFilesStats.ingestSessionId} IN (
1804
+ SELECT ${urIngestSession.urIngestSessionId}
1805
+ FROM ${urIngestSession}
1806
+ ORDER BY ${urIngestSession.ingestFinishedAt} DESC
1807
+ LIMIT 1
1808
+ )`);
1809
+ });
1810
+ var urIngestSessionTasksStats = (0, import_sqlite_core2.sqliteView)("ur_ingest_session_tasks_stats").as((qb) => {
1811
+ return qb.select({
1812
+ deviceId: device.deviceId,
1813
+ ingestSessionId: urIngestSession.urIngestSessionId,
1814
+ ingestSessionStartedAt: urIngestSession.ingestStartedAt,
1815
+ ingestSessionFinishedAt: urIngestSession.ingestFinishedAt,
1816
+ urStatus: import_drizzle_orm2.sql`COALESCE(${urIngestSessionTask.urStatus}, 'Ok')`.as("ur_status"),
1817
+ nature: import_drizzle_orm2.sql`COALESCE(${uniformResource.nature}, 'UNKNOWN')`.as("nature"),
1818
+ totalFileCount: (0, import_drizzle_orm2.count)(urIngestSessionTask.uniformResourceId).as("total_file_count"),
1819
+ fileCountWithContent: (0, import_drizzle_orm2.sum)(import_drizzle_orm2.sql`CASE WHEN ${uniformResource.content} IS NOT NULL THEN 1 ELSE 0 END`).as("file_count_with_content"),
1820
+ fileCountWithFrontmatter: (0, import_drizzle_orm2.sum)(import_drizzle_orm2.sql`CASE WHEN ${uniformResource.frontmatter} IS NOT NULL THEN 1 ELSE 0 END`).as("file_count_with_frontmatter"),
1821
+ minFileSizeBytes: (0, import_drizzle_orm2.min)(uniformResource.sizeBytes).as("min_file_size_bytes"),
1822
+ averageFileSizeBytes: import_drizzle_orm2.sql`CAST(ROUND(AVG(${uniformResource.sizeBytes})) AS INTEGER)`.as("average_file_size_bytes"),
1823
+ maxFileSizeBytes: (0, import_drizzle_orm2.max)(uniformResource.sizeBytes).as("max_file_size_bytes"),
1824
+ oldestFileLastModifiedDatetime: (0, import_drizzle_orm2.min)(uniformResource.lastModifiedAt).as("oldest_file_last_modified_datetime"),
1825
+ youngestFileLastModifiedDatetime: (0, import_drizzle_orm2.max)(uniformResource.lastModifiedAt).as("youngest_file_last_modified_datetime")
1826
+ }).from(urIngestSession).innerJoin(device, (0, import_drizzle_orm2.eq)(urIngestSession.deviceId, device.deviceId)).leftJoin(urIngestSessionTask, (0, import_drizzle_orm2.eq)(urIngestSession.urIngestSessionId, urIngestSessionTask.ingestSessionId)).leftJoin(uniformResource, (0, import_drizzle_orm2.eq)(urIngestSessionTask.uniformResourceId, uniformResource.uniformResourceId)).groupBy(
1827
+ device.deviceId,
1828
+ urIngestSession.urIngestSessionId,
1829
+ urIngestSession.ingestStartedAt,
1830
+ urIngestSession.ingestFinishedAt,
1831
+ urIngestSessionTask.capturedExecutable
1832
+ ).orderBy(device.deviceId, urIngestSession.ingestFinishedAt, urIngestSessionTask.urStatus);
1833
+ });
1834
+ var urIngestSessionTasksStatsLatest = (0, import_sqlite_core2.sqliteView)("ur_ingest_session_tasks_stats_latest").as((qb) => {
1835
+ return qb.select({
1836
+ deviceId: urIngestSessionTasksStats.deviceId,
1837
+ ingestSessionId: urIngestSessionTasksStats.ingestSessionId,
1838
+ ingestSessionStartedAt: urIngestSessionTasksStats.ingestSessionStartedAt,
1839
+ ingestSessionFinishedAt: urIngestSessionTasksStats.ingestSessionFinishedAt,
1840
+ urStatus: urIngestSessionTasksStats.urStatus,
1841
+ nature: urIngestSessionTasksStats.nature,
1842
+ totalFileCount: urIngestSessionTasksStats.totalFileCount,
1843
+ fileCountWithContent: urIngestSessionTasksStats.fileCountWithContent,
1844
+ fileCountWithFrontmatter: urIngestSessionTasksStats.fileCountWithFrontmatter,
1845
+ minFileSizeBytes: urIngestSessionTasksStats.minFileSizeBytes,
1846
+ averageFileSizeBytes: urIngestSessionTasksStats.averageFileSizeBytes,
1847
+ maxFileSizeBytes: urIngestSessionTasksStats.maxFileSizeBytes,
1848
+ oldestFileLastModifiedDatetime: urIngestSessionTasksStats.oldestFileLastModifiedDatetime,
1849
+ youngestFileLastModifiedDatetime: urIngestSessionTasksStats.youngestFileLastModifiedDatetime
1850
+ }).from(urIngestSessionTasksStats).where(import_drizzle_orm2.sql`${urIngestSessionTasksStats.ingestSessionId} IN (
1851
+ SELECT ${urIngestSession.urIngestSessionId}
1852
+ FROM ${urIngestSession}
1853
+ ORDER BY ${urIngestSession.ingestFinishedAt} DESC
1854
+ LIMIT 1
1855
+ )`);
1856
+ });
1857
+ var urIngestSessionFileIssue = (0, import_sqlite_core2.sqliteView)("ur_ingest_session_file_issue").as((qb) => {
1858
+ return qb.select({
1859
+ deviceId: urIngestSession.deviceId,
1860
+ urIngestSessionId: urIngestSession.urIngestSessionId,
1861
+ urIngestSessionFsPathId: urIngestSessionFsPath.urIngestSessionFsPathId,
1862
+ rootPath: urIngestSessionFsPath.rootPath,
1863
+ urIngestSessionFsPathEntryId: urIngestSessionFsPathEntry.urIngestSessionFsPathEntryId,
1864
+ filePathAbs: urIngestSessionFsPathEntry.filePathAbs,
1865
+ urStatus: urIngestSessionFsPathEntry.urStatus,
1866
+ urDiagnostics: urIngestSessionFsPathEntry.urDiagnostics
1867
+ }).from(urIngestSessionFsPathEntry).innerJoin(urIngestSessionFsPath, (0, import_drizzle_orm2.eq)(urIngestSessionFsPathEntry.ingestFsPathId, urIngestSessionFsPath.urIngestSessionFsPathId)).innerJoin(urIngestSession, (0, import_drizzle_orm2.eq)(urIngestSessionFsPath.ingestSessionId, urIngestSession.urIngestSessionId)).where(import_drizzle_orm2.sql`${urIngestSessionFsPathEntry.urStatus} IS NOT NULL`).groupBy(
1868
+ urIngestSession.deviceId,
1869
+ urIngestSession.urIngestSessionId,
1870
+ urIngestSessionFsPath.urIngestSessionFsPathId,
1871
+ urIngestSessionFsPath.rootPath,
1872
+ urIngestSessionFsPathEntry.urIngestSessionFsPathEntryId,
1873
+ urIngestSessionFsPathEntry.filePathAbs,
1874
+ urIngestSessionFsPathEntry.urStatus,
1875
+ urIngestSessionFsPathEntry.urDiagnostics
1876
+ );
1877
+ });
1878
+ var orchestrationSessionByDevice = (0, import_sqlite_core2.sqliteView)("orchestration_session_by_device").as((qb) => {
1879
+ return qb.select({
1880
+ deviceId: device.deviceId,
1881
+ deviceName: device.name,
1882
+ sessionCount: (0, import_drizzle_orm2.count)(orchestrationSession.orchestrationSessionId).as("session_count")
1883
+ }).from(orchestrationSession).innerJoin(device, (0, import_drizzle_orm2.eq)(orchestrationSession.deviceId, device.deviceId)).groupBy(device.deviceId, device.name);
1884
+ });
1885
+ var orchestrationSessionDuration = (0, import_sqlite_core2.sqliteView)("orchestration_session_duration").as((qb) => {
1886
+ return qb.select({
1887
+ orchestrationSessionId: orchestrationSession.orchestrationSessionId,
1888
+ orchestrationNature: orchestrationNature.nature,
1889
+ orchStartedAt: orchestrationSession.orchStartedAt,
1890
+ orchFinishedAt: orchestrationSession.orchFinishedAt,
1891
+ durationSeconds: import_drizzle_orm2.sql`(JULIANDAY(${orchestrationSession.orchFinishedAt}) - JULIANDAY(${orchestrationSession.orchStartedAt})) * 24 * 60 * 60`.as("duration_seconds")
1892
+ }).from(orchestrationSession).innerJoin(orchestrationNature, (0, import_drizzle_orm2.eq)(orchestrationSession.orchestrationNatureId, orchestrationNature.orchestrationNatureId)).where(import_drizzle_orm2.sql`${orchestrationSession.orchFinishedAt} IS NOT NULL`);
1893
+ });
1894
+ var orchestrationSuccessRate = (0, import_sqlite_core2.sqliteView)("orchestration_success_rate").as((qb) => {
1895
+ return qb.select({
1896
+ orchestrationNature: orchestrationNature.nature,
1897
+ totalSessions: (0, import_drizzle_orm2.count)().as("total_sessions"),
1898
+ successfulSessions: (0, import_drizzle_orm2.sum)(import_drizzle_orm2.sql`CASE WHEN ${orchestrationSessionState.toState} = 'surveilr_orch_completed' THEN 1 ELSE 0 END`).as("successful_sessions"),
1899
+ successRate: import_drizzle_orm2.sql`(CAST(SUM(CASE WHEN ${orchestrationSessionState.toState} = 'surveilr_orch_completed' THEN 1 ELSE 0 END) AS FLOAT) / COUNT(*)) * 100`.as("success_rate")
1900
+ }).from(orchestrationSession).innerJoin(orchestrationNature, (0, import_drizzle_orm2.eq)(orchestrationSession.orchestrationNatureId, orchestrationNature.orchestrationNatureId)).innerJoin(orchestrationSessionState, (0, import_drizzle_orm2.eq)(orchestrationSession.orchestrationSessionId, orchestrationSessionState.sessionId)).where(import_drizzle_orm2.sql`${orchestrationSessionState.toState} IN ('surveilr_orch_completed', 'surveilr_orch_failed')`).groupBy(orchestrationNature.nature);
1901
+ });
1902
+ var orchestrationSessionScript = (0, import_sqlite_core2.sqliteView)("orchestration_session_script").as((qb) => {
1903
+ return qb.select({
1904
+ orchestrationSessionId: orchestrationSession.orchestrationSessionId,
1905
+ orchestrationNature: orchestrationNature.nature,
1906
+ scriptCount: (0, import_drizzle_orm2.count)(orchestrationSessionEntry.orchestrationSessionEntryId).as("script_count")
1907
+ }).from(orchestrationSession).innerJoin(orchestrationNature, (0, import_drizzle_orm2.eq)(orchestrationSession.orchestrationNatureId, orchestrationNature.orchestrationNatureId)).innerJoin(orchestrationSessionEntry, (0, import_drizzle_orm2.eq)(orchestrationSession.orchestrationSessionId, orchestrationSessionEntry.sessionId)).groupBy(orchestrationSession.orchestrationSessionId, orchestrationNature.nature);
1908
+ });
1909
+ var orchestrationExecutionsByType = (0, import_sqlite_core2.sqliteView)("orchestration_executions_by_type").as((qb) => {
1910
+ return qb.select({
1911
+ execNature: orchestrationSessionExec.execNature,
1912
+ executionCount: (0, import_drizzle_orm2.count)(orchestrationSessionExec.orchestrationSessionExecId).as("execution_count")
1913
+ }).from(orchestrationSessionExec).groupBy(orchestrationSessionExec.execNature);
1914
+ });
1915
+ var orchestrationExecutionSuccessRateByType = (0, import_sqlite_core2.sqliteView)("orchestration_execution_success_rate_by_type").as((qb) => {
1916
+ return qb.select({
1917
+ execNature: orchestrationSessionExec.execNature,
1918
+ totalExecutions: (0, import_drizzle_orm2.count)().as("total_executions"),
1919
+ successfulExecutions: (0, import_drizzle_orm2.sum)(import_drizzle_orm2.sql`CASE WHEN ${orchestrationSessionExec.execStatus} = 0 THEN 1 ELSE 0 END`).as("successful_executions"),
1920
+ successRate: import_drizzle_orm2.sql`(CAST(SUM(CASE WHEN ${orchestrationSessionExec.execStatus} = 0 THEN 1 ELSE 0 END) AS FLOAT) / COUNT(*)) * 100`.as("success_rate")
1921
+ }).from(orchestrationSessionExec).groupBy(orchestrationSessionExec.execNature);
1922
+ });
1923
+ var orchestrationSessionSummary = (0, import_sqlite_core2.sqliteView)("orchestration_session_summary").as((qb) => {
1924
+ return qb.select({
1925
+ issueType: orchestrationSessionIssue.issueType,
1926
+ issueCount: (0, import_drizzle_orm2.count)(orchestrationSessionIssue.orchestrationSessionIssueId).as("issue_count")
1927
+ }).from(orchestrationSessionIssue).groupBy(orchestrationSessionIssue.issueType);
1928
+ });
1929
+ var orchestrationIssueRemediation = (0, import_sqlite_core2.sqliteView)("orchestration_issue_remediation").as((qb) => {
1930
+ return qb.select({
1931
+ orchestrationSessionIssueId: orchestrationSessionIssue.orchestrationSessionIssueId,
1932
+ issueType: orchestrationSessionIssue.issueType,
1933
+ issueMessage: orchestrationSessionIssue.issueMessage,
1934
+ remediation: orchestrationSessionIssue.remediation
1935
+ }).from(orchestrationSessionIssue).where(import_drizzle_orm2.sql`${orchestrationSessionIssue.remediation} IS NOT NULL`);
1936
+ });
1937
+ var orchestrationLogsBySession = (0, import_sqlite_core2.sqliteView)("orchestration_logs_by_session").as((qb) => {
1938
+ return qb.select({
1939
+ orchestrationSessionId: orchestrationSession.orchestrationSessionId,
1940
+ orchestrationNature: orchestrationNature.nature,
1941
+ category: orchestrationSessionLog.category,
1942
+ logCount: (0, import_drizzle_orm2.count)(orchestrationSessionLog.orchestrationSessionLogId).as("log_count")
1943
+ }).from(orchestrationSession).innerJoin(orchestrationNature, (0, import_drizzle_orm2.eq)(orchestrationSession.orchestrationNatureId, orchestrationNature.orchestrationNatureId)).innerJoin(orchestrationSessionExec, (0, import_drizzle_orm2.eq)(orchestrationSession.orchestrationSessionId, orchestrationSessionExec.sessionId)).innerJoin(orchestrationSessionLog, (0, import_drizzle_orm2.eq)(orchestrationSessionExec.orchestrationSessionExecId, orchestrationSessionLog.parentExecId)).groupBy(orchestrationSession.orchestrationSessionId, orchestrationNature.nature, orchestrationSessionLog.category);
1944
+ });
1945
+ var emailMessagesWithTimezone = (0, import_sqlite_core2.sqliteView)("email_messages_with_timezone", {}).as(import_drizzle_orm2.sql`
1946
+ SELECT
1947
+ m.*,
1948
+ -- Smart timezone conversion based on original timezone
1949
+ CASE
1950
+ -- If already IST (+0530), just extract the time
1951
+ WHEN date LIKE '%+0530%' THEN substr(date, 18, 8)
1952
+ -- If UTC (+0000), convert to IST
1953
+ WHEN date LIKE '%+0000%' THEN time(substr(date, 18, 8), '+5 hours', '+30 minutes')
1954
+ -- If EST (-0500), convert to IST
1955
+ WHEN date LIKE '%-0500%' THEN time(substr(date, 18, 8), '+10 hours', '+30 minutes')
1956
+ -- If PST (-0800), convert to IST
1957
+ WHEN date LIKE '%-0800%' THEN time(substr(date, 18, 8), '+13 hours', '+30 minutes')
1958
+ -- Default: assume UTC and convert
1959
+ ELSE time(substr(date, 18, 8), '+5 hours', '+30 minutes')
1960
+ END as ist_time,
1961
+
1962
+ -- Always show UTC time (convert from any timezone to UTC first)
1963
+ CASE
1964
+ WHEN date LIKE '%+0530%' THEN time(substr(date, 18, 8), '-5 hours', '-30 minutes')
1965
+ WHEN date LIKE '%+0000%' THEN substr(date, 18, 8)
1966
+ WHEN date LIKE '%-0500%' THEN time(substr(date, 18, 8), '+5 hours')
1967
+ WHEN date LIKE '%-0800%' THEN time(substr(date, 18, 8), '+8 hours')
1968
+ ELSE substr(date, 18, 8)
1969
+ END as utc_time,
1970
+
1971
+ -- Detect original timezone more accurately
1972
+ CASE
1973
+ WHEN date LIKE '%+0530%' THEN 'IST'
1974
+ WHEN date LIKE '%+0000%' THEN 'UTC'
1975
+ WHEN date LIKE '%-0500%' THEN 'EST'
1976
+ WHEN date LIKE '%-0800%' THEN 'PST'
1977
+ ELSE 'Unknown'
1978
+ END as detected_timezone
1979
+ FROM ur_ingest_session_imap_acct_folder_message m`);
1980
+ var deviceGraphOverview = (0, import_sqlite_core2.sqliteView)("device_graph_overview", {}).as(import_drizzle_orm2.sql`
1981
+ SELECT
1982
+ 'snmp_device' as device_type,
1983
+ sd.device_key as device_id,
1984
+ sd.snmp_host as primary_identifier,
1985
+ sd.device_type as device_category,
1986
+ sd.device_description as description,
1987
+ sd.status,
1988
+ sd.created_at,
1989
+ sd.updated_at,
1990
+ json_object(
1991
+ 'snmp_port', sd.snmp_port,
1992
+ 'snmp_community', sd.snmp_community,
1993
+ 'snmp_version', sd.snmp_version,
1994
+ 'snmp_timeout', sd.snmp_timeout,
1995
+ 'snmp_retries', sd.snmp_retries
1996
+ ) as device_metadata
1997
+ FROM surveilr_snmp_device sd
1998
+ WHERE sd.status = 'active'
1999
+
2000
+ UNION ALL
2001
+
2002
+ SELECT
2003
+ 'osquery_node' as device_type,
2004
+ osq.node_key as device_id,
2005
+ osq.host_identifier as primary_identifier,
2006
+ 'endpoint' as device_category,
2007
+ osq.os_version as description,
2008
+ osq.status,
2009
+ osq.created_at,
2010
+ osq.updated_at,
2011
+ json_object(
2012
+ 'last_seen', osq.last_seen,
2013
+ 'platform', osq.platform,
2014
+ 'osquery_version', osq.osquery_version,
2015
+ 'device_id', osq.device_id
2016
+ ) as device_metadata
2017
+ FROM surveilr_osquery_ms_node osq
2018
+ WHERE osq.status = 'active'`);
2019
+ var deviceGraphCorrelations = (0, import_sqlite_core2.sqliteView)("device_graph_correlations", {}).as(import_drizzle_orm2.sql`
2020
+ SELECT DISTINCT
2021
+ ure1.node_id as snmp_device_key,
2022
+ ure1.uniform_resource_id as osquery_node_key,
2023
+ CASE
2024
+ WHEN ure1.nature LIKE '%ip_address_match%' THEN 'IP Address Match'
2025
+ WHEN ure1.nature LIKE '%hostname_match%' THEN 'Hostname Match'
2026
+ WHEN ure1.nature LIKE '%mac_address_match%' THEN 'MAC Address Match'
2027
+ WHEN ure1.nature LIKE '%network_topology%' THEN 'Network Topology'
2028
+ WHEN ure1.nature LIKE '%manual%' THEN 'Manual'
2029
+ ELSE 'Unknown'
2030
+ END as correlation_type,
2031
+ CASE
2032
+ WHEN ure1.nature LIKE '%ip_address_match%' THEN 0.95
2033
+ WHEN ure1.nature LIKE '%hostname_match%' THEN 0.85
2034
+ WHEN ure1.nature LIKE '%mac_address_match%' THEN 0.90
2035
+ WHEN ure1.nature LIKE '%network_topology%' THEN 0.70
2036
+ WHEN ure1.nature LIKE '%manual%' THEN 1.0
2037
+ ELSE 0.5
2038
+ END as confidence_score,
2039
+ json_extract(ure1.elaboration, '$.snmp_host') as snmp_host,
2040
+ json_extract(ure1.elaboration, '$.correlation_method') as correlation_method,
2041
+ ure1.elaboration as evidence
2042
+ FROM uniform_resource_edge ure1
2043
+ WHERE ure1.graph_name = 'device_graph'
2044
+ AND ure1.nature LIKE 'snmp_to_osquery_%'
2045
+ ORDER BY ure1.node_id, ure1.uniform_resource_id`);
2046
+ var snmpDeviceInventory = (0, import_sqlite_core2.sqliteView)("snmp_device_inventory", {}).as(import_drizzle_orm2.sql`
2047
+ SELECT
2048
+ sd.device_key,
2049
+ sd.snmp_host,
2050
+ sd.snmp_port,
2051
+ sd.device_type,
2052
+ sd.device_description,
2053
+ sd.status,
2054
+ sd.created_at,
2055
+ COUNT(sc.surveilr_snmp_collection_id) as total_collections,
2056
+ MAX(sc.collected_at) as last_collection_time,
2057
+ COUNT(DISTINCT sc.oid) as unique_oids_collected,
2058
+ AVG(
2059
+ CASE
2060
+ WHEN sc.collected_at > datetime('now', '-1 hour') THEN 1
2061
+ ELSE 0
2062
+ END
2063
+ ) as recent_activity_score
2064
+ FROM surveilr_snmp_device sd
2065
+ LEFT JOIN surveilr_snmp_collection sc ON sd.device_key = sc.device_key
2066
+ GROUP BY sd.device_key, sd.snmp_host, sd.snmp_port, sd.device_type,
2067
+ sd.device_description, sd.status, sd.created_at
2068
+ ORDER BY sd.status, sd.snmp_host`);
2069
+ var snmpCollectionSummary = (0, import_sqlite_core2.sqliteView)("snmp_collection_summary", {}).as(import_drizzle_orm2.sql`
2070
+ SELECT
2071
+ sc.device_key,
2072
+ sd.snmp_host,
2073
+ sc.oid_type,
2074
+ COUNT(*) as collection_count,
2075
+ COUNT(DISTINCT sc.oid) as unique_oids,
2076
+ MIN(sc.collected_at) as first_collection,
2077
+ MAX(sc.collected_at) as latest_collection,
2078
+ COUNT(DISTINCT DATE(sc.collected_at)) as collection_days
2079
+ FROM surveilr_snmp_collection sc
2080
+ JOIN surveilr_snmp_device sd ON sc.device_key = sd.device_key
2081
+ GROUP BY sc.device_key, sd.snmp_host, sc.oid_type
2082
+ ORDER BY sd.snmp_host, sc.oid_type`);
2083
+ var networkDeviceTopology = (0, import_sqlite_core2.sqliteView)("network_device_topology", {}).as(import_drizzle_orm2.sql`
2084
+ SELECT
2085
+ sd.device_key,
2086
+ sd.snmp_host,
2087
+ sd.device_type,
2088
+ -- Extract network information from SNMP collections
2089
+ COALESCE(
2090
+ (SELECT sc.oid_value
2091
+ FROM surveilr_snmp_collection sc
2092
+ WHERE sc.device_key = sd.device_key
2093
+ AND sc.oid LIKE '%.1.3.6.1.2.1.1.1.%'
2094
+ LIMIT 1),
2095
+ 'Unknown'
2096
+ ) as system_description,
2097
+ COALESCE(
2098
+ (SELECT sc.oid_value
2099
+ FROM surveilr_snmp_collection sc
2100
+ WHERE sc.device_key = sd.device_key
2101
+ AND sc.oid LIKE '%.1.3.6.1.2.1.1.5.%'
2102
+ LIMIT 1),
2103
+ 'Unknown'
2104
+ ) as system_name,
2105
+ -- Count correlated devices
2106
+ (SELECT COUNT(*)
2107
+ FROM device_graph_correlations dgc
2108
+ WHERE dgc.snmp_device_key = sd.device_key
2109
+ ) as correlated_devices_count,
2110
+ sd.status,
2111
+ sd.created_at
2112
+ FROM surveilr_snmp_device sd
2113
+ WHERE sd.status = 'active'
2114
+ ORDER BY sd.snmp_host`);
2115
+ var deviceGraphAnalytics = (0, import_sqlite_core2.sqliteView)("device_graph_analytics", {}).as(import_drizzle_orm2.sql`
2116
+ SELECT
2117
+ 'summary' as metric_type,
2118
+ 'total_snmp_devices' as metric_name,
2119
+ COUNT(*) as metric_value,
2120
+ NULL as additional_info
2121
+ FROM surveilr_snmp_device
2122
+ WHERE status = 'active'
2123
+
2124
+ UNION ALL
2125
+
2126
+ SELECT
2127
+ 'summary' as metric_type,
2128
+ 'total_osquery_nodes' as metric_name,
2129
+ COUNT(*) as metric_value,
2130
+ NULL as additional_info
2131
+ FROM surveilr_osquery_ms_node
2132
+ WHERE status = 'active'
2133
+
2134
+ UNION ALL
2135
+
2136
+ SELECT
2137
+ 'summary' as metric_type,
2138
+ 'total_correlations' as metric_name,
2139
+ COUNT(*) as metric_value,
2140
+ NULL as additional_info
2141
+ FROM device_graph_correlations
2142
+
2143
+ UNION ALL
2144
+
2145
+ SELECT
2146
+ 'summary' as metric_type,
2147
+ 'correlation_types' as metric_name,
2148
+ COUNT(DISTINCT correlation_type) as metric_value,
2149
+ GROUP_CONCAT(DISTINCT correlation_type) as additional_info
2150
+ FROM device_graph_correlations
2151
+
2152
+ UNION ALL
2153
+
2154
+ SELECT
2155
+ 'correlation_by_type' as metric_type,
2156
+ correlation_type as metric_name,
2157
+ COUNT(*) as metric_value,
2158
+ printf('avg_confidence: %.2f', AVG(confidence_score)) as additional_info
2159
+ FROM device_graph_correlations
2160
+ GROUP BY correlation_type
2161
+
2162
+ UNION ALL
2163
+
2164
+ SELECT
2165
+ 'collection_stats' as metric_type,
2166
+ 'total_snmp_collections' as metric_name,
2167
+ COUNT(*) as metric_value,
2168
+ printf('unique_devices: %d', COUNT(DISTINCT device_key)) as additional_info
2169
+ FROM surveilr_snmp_collection
2170
+
2171
+ UNION ALL
2172
+
2173
+ SELECT
2174
+ 'collection_stats' as metric_type,
2175
+ 'collection_activity_last_24h' as metric_name,
2176
+ COUNT(*) as metric_value,
2177
+ printf('devices_active: %d', COUNT(DISTINCT device_key)) as additional_info
2178
+ FROM surveilr_snmp_collection
2179
+ WHERE collected_at > datetime('now', '-24 hours')`);
2180
+ var snmpOidPerformance = (0, import_sqlite_core2.sqliteView)("snmp_oid_performance", {}).as(import_drizzle_orm2.sql`
2181
+ SELECT
2182
+ sc.oid,
2183
+ sc.oid_type,
2184
+ COUNT(*) as total_collections,
2185
+ COUNT(DISTINCT sc.device_key) as devices_collecting,
2186
+ COUNT(DISTINCT DATE(sc.collected_at)) as collection_days,
2187
+ MIN(sc.collected_at) as first_seen,
2188
+ MAX(sc.collected_at) as last_seen,
2189
+ -- Calculate collection frequency (avoid nested aggregates)
2190
+ CAST(
2191
+ COUNT(*) * 1.0 /
2192
+ NULLIF(MAX(julianday(sc.collected_at)) - MIN(julianday(sc.collected_at)), 0)
2193
+ AS REAL) as avg_collections_per_day,
2194
+ -- Sample values for diversity analysis
2195
+ COUNT(DISTINCT sc.oid_value) as unique_values_count,
2196
+ GROUP_CONCAT(DISTINCT sc.oid_value) as sample_values
2197
+ FROM surveilr_snmp_collection sc
2198
+ GROUP BY sc.oid, sc.oid_type
2199
+ HAVING COUNT(*) > 0
2200
+ ORDER BY total_collections DESC, devices_collecting DESC`);
2201
+
2202
+ // relations.ts
2203
+ var import_relations = require("drizzle-orm/relations");
2204
+ var codeNotebookCellRelations = (0, import_relations.relations)(codeNotebookCell, ({ one, many }) => ({
2205
+ codeNotebookKernel: one(codeNotebookKernel, {
2206
+ fields: [codeNotebookCell.notebookKernelId],
2207
+ references: [codeNotebookKernel.codeNotebookKernelId]
2208
+ }),
2209
+ codeNotebookStates: many(codeNotebookState)
2210
+ }));
2211
+ var codeNotebookKernelRelations = (0, import_relations.relations)(codeNotebookKernel, ({ many }) => ({
2212
+ codeNotebookCells: many(codeNotebookCell)
2213
+ }));
2214
+ var codeNotebookStateRelations = (0, import_relations.relations)(codeNotebookState, ({ one }) => ({
2215
+ codeNotebookCell: one(codeNotebookCell, {
2216
+ fields: [codeNotebookState.codeNotebookCellId],
2217
+ references: [codeNotebookCell.codeNotebookCellId]
2218
+ })
2219
+ }));
2220
+ var partyRelations = (0, import_relations.relations)(party, ({ one, many }) => ({
2221
+ partyType: one(partyType, {
2222
+ fields: [party.partyTypeId],
2223
+ references: [partyType.partyTypeId]
2224
+ }),
2225
+ partyRelations_relatedPartyId: many(partyRelation, {
2226
+ relationName: "partyRelation_relatedPartyId_party_partyId"
2227
+ }),
2228
+ partyRelations_partyId: many(partyRelation, {
2229
+ relationName: "partyRelation_partyId_party_partyId"
2230
+ }),
2231
+ people: many(person),
2232
+ organizations: many(organization),
2233
+ organizationRoles_organizationId: many(organizationRole, {
2234
+ relationName: "organizationRole_organizationId_party_partyId"
2235
+ }),
2236
+ organizationRoles_personId: many(organizationRole, {
2237
+ relationName: "organizationRole_personId_party_partyId"
2238
+ }),
2239
+ devicePartyRelationships: many(devicePartyRelationship)
2240
+ }));
2241
+ var partyTypeRelations = (0, import_relations.relations)(partyType, ({ many }) => ({
2242
+ parties: many(party)
2243
+ }));
2244
+ var partyRelationRelations = (0, import_relations.relations)(partyRelation, ({ one }) => ({
2245
+ partyRelationType: one(partyRelationType, {
2246
+ fields: [partyRelation.relationTypeId],
2247
+ references: [partyRelationType.partyRelationTypeId]
2248
+ }),
2249
+ party_relatedPartyId: one(party, {
2250
+ fields: [partyRelation.relatedPartyId],
2251
+ references: [party.partyId],
2252
+ relationName: "partyRelation_relatedPartyId_party_partyId"
2253
+ }),
2254
+ party_partyId: one(party, {
2255
+ fields: [partyRelation.partyId],
2256
+ references: [party.partyId],
2257
+ relationName: "partyRelation_partyId_party_partyId"
2258
+ })
2259
+ }));
2260
+ var partyRelationTypeRelations = (0, import_relations.relations)(partyRelationType, ({ many }) => ({
2261
+ partyRelations: many(partyRelation)
2262
+ }));
2263
+ var personRelations = (0, import_relations.relations)(person, ({ one }) => ({
2264
+ sexType: one(sexType, {
2265
+ fields: [person.sexId],
2266
+ references: [sexType.sexTypeId]
2267
+ }),
2268
+ genderType: one(genderType, {
2269
+ fields: [person.genderId],
2270
+ references: [genderType.genderTypeId]
2271
+ }),
2272
+ personType: one(personType, {
2273
+ fields: [person.personTypeId],
2274
+ references: [personType.personTypeId]
2275
+ }),
2276
+ party: one(party, {
2277
+ fields: [person.partyId],
2278
+ references: [party.partyId]
2279
+ })
2280
+ }));
2281
+ var sexTypeRelations = (0, import_relations.relations)(sexType, ({ many }) => ({
2282
+ people: many(person)
2283
+ }));
2284
+ var genderTypeRelations = (0, import_relations.relations)(genderType, ({ many }) => ({
2285
+ people: many(person)
2286
+ }));
2287
+ var personTypeRelations = (0, import_relations.relations)(personType, ({ many }) => ({
2288
+ people: many(person)
2289
+ }));
2290
+ var organizationRelations = (0, import_relations.relations)(organization, ({ one }) => ({
2291
+ party: one(party, {
2292
+ fields: [organization.partyId],
2293
+ references: [party.partyId]
2294
+ })
2295
+ }));
2296
+ var organizationRoleRelations = (0, import_relations.relations)(organizationRole, ({ one }) => ({
2297
+ organizationRoleType: one(organizationRoleType, {
2298
+ fields: [organizationRole.organizationRoleTypeId],
2299
+ references: [organizationRoleType.organizationRoleTypeId]
2300
+ }),
2301
+ party_organizationId: one(party, {
2302
+ fields: [organizationRole.organizationId],
2303
+ references: [party.partyId],
2304
+ relationName: "organizationRole_organizationId_party_partyId"
2305
+ }),
2306
+ party_personId: one(party, {
2307
+ fields: [organizationRole.personId],
2308
+ references: [party.partyId],
2309
+ relationName: "organizationRole_personId_party_partyId"
2310
+ })
2311
+ }));
2312
+ var organizationRoleTypeRelations = (0, import_relations.relations)(organizationRoleType, ({ many }) => ({
2313
+ organizationRoles: many(organizationRole)
2314
+ }));
2315
+ var devicePartyRelationshipRelations = (0, import_relations.relations)(devicePartyRelationship, ({ one }) => ({
2316
+ party: one(party, {
2317
+ fields: [devicePartyRelationship.partyId],
2318
+ references: [party.partyId]
2319
+ }),
2320
+ device: one(device, {
2321
+ fields: [devicePartyRelationship.deviceId],
2322
+ references: [device.deviceId]
2323
+ })
2324
+ }));
2325
+ var deviceRelations = (0, import_relations.relations)(device, ({ many }) => ({
2326
+ devicePartyRelationships: many(devicePartyRelationship),
2327
+ behaviors: many(behavior),
2328
+ urIngestSessions: many(urIngestSession),
2329
+ uniformResources: many(uniformResource),
2330
+ orchestrationSessions: many(orchestrationSession),
2331
+ surveilrOsqueryMsNodes: many(surveilrOsqueryMsNode)
2332
+ }));
2333
+ var behaviorRelations = (0, import_relations.relations)(behavior, ({ one, many }) => ({
2334
+ assuranceSchema: one(assuranceSchema, {
2335
+ fields: [behavior.assuranceSchemaId],
2336
+ references: [assuranceSchema.assuranceSchemaId]
2337
+ }),
2338
+ device: one(device, {
2339
+ fields: [behavior.deviceId],
2340
+ references: [device.deviceId]
2341
+ }),
2342
+ urIngestSessions: many(urIngestSession),
2343
+ surveilrOsqueryMsNodes: many(surveilrOsqueryMsNode)
2344
+ }));
2345
+ var assuranceSchemaRelations = (0, import_relations.relations)(assuranceSchema, ({ many }) => ({
2346
+ behaviors: many(behavior)
2347
+ }));
2348
+ var urIngestSessionRelations = (0, import_relations.relations)(urIngestSession, ({ one, many }) => ({
2349
+ behavior: one(behavior, {
2350
+ fields: [urIngestSession.behaviorId],
2351
+ references: [behavior.behaviorId]
2352
+ }),
2353
+ device: one(device, {
2354
+ fields: [urIngestSession.deviceId],
2355
+ references: [device.deviceId]
2356
+ }),
2357
+ urIngestSessionFsPaths: many(urIngestSessionFsPath),
2358
+ uniformResources: many(uniformResource),
2359
+ urIngestSessionFsPathEntries: many(urIngestSessionFsPathEntry),
2360
+ urIngestSessionTasks: many(urIngestSessionTask),
2361
+ urIngestSessionImapAccounts: many(urIngestSessionImapAccount),
2362
+ urIngestSessionImapAcctFolders: many(urIngestSessionImapAcctFolder),
2363
+ urIngestSessionImapAcctFolderMessages: many(urIngestSessionImapAcctFolderMessage),
2364
+ urIngestSessionPlmAccounts: many(urIngestSessionPlmAccount),
2365
+ urIngestSessionPlmAcctProjects: many(urIngestSessionPlmAcctProject),
2366
+ urIngestSessionPlmAcctProjectIssues: many(urIngestSessionPlmAcctProjectIssue),
2367
+ urIngestSessionUdiPgpSqls: many(urIngestSessionUdiPgpSql)
2368
+ }));
2369
+ var urIngestSessionFsPathRelations = (0, import_relations.relations)(urIngestSessionFsPath, ({ one, many }) => ({
2370
+ urIngestSession: one(urIngestSession, {
2371
+ fields: [urIngestSessionFsPath.ingestSessionId],
2372
+ references: [urIngestSession.urIngestSessionId]
2373
+ }),
2374
+ uniformResources: many(uniformResource),
2375
+ urIngestSessionFsPathEntries: many(urIngestSessionFsPathEntry)
2376
+ }));
2377
+ var uniformResourceRelations = (0, import_relations.relations)(uniformResource, ({ one, many }) => ({
2378
+ urIngestSessionPlmAcctProject: one(urIngestSessionPlmAcctProject, {
2379
+ fields: [uniformResource.ingestIssueAcctProjectId],
2380
+ references: [urIngestSessionPlmAcctProject.urIngestSessionPlmAcctProjectId]
2381
+ }),
2382
+ urIngestSessionImapAcctFolderMessage: one(urIngestSessionImapAcctFolderMessage, {
2383
+ fields: [uniformResource.ingestSessionImapAcctFolderMessage],
2384
+ references: [urIngestSessionImapAcctFolderMessage.urIngestSessionImapAcctFolderMessageId]
2385
+ }),
2386
+ urIngestSessionFsPath: one(urIngestSessionFsPath, {
2387
+ fields: [uniformResource.ingestFsPathId],
2388
+ references: [urIngestSessionFsPath.urIngestSessionFsPathId]
2389
+ }),
2390
+ urIngestSession: one(urIngestSession, {
2391
+ fields: [uniformResource.ingestSessionId],
2392
+ references: [urIngestSession.urIngestSessionId]
2393
+ }),
2394
+ device: one(device, {
2395
+ fields: [uniformResource.deviceId],
2396
+ references: [device.deviceId]
2397
+ }),
2398
+ uniformResourceTransforms: many(uniformResourceTransform),
2399
+ urIngestSessionFsPathEntries: many(urIngestSessionFsPathEntry),
2400
+ urIngestSessionTasks: many(urIngestSessionTask),
2401
+ urIngestSessionPlmAcctProjectIssues: many(urIngestSessionPlmAcctProjectIssue),
2402
+ urIngestSessionAttachments: many(urIngestSessionAttachment),
2403
+ urIngestSessionUdiPgpSqls: many(urIngestSessionUdiPgpSql),
2404
+ uniformResourceEdges: many(uniformResourceEdge)
2405
+ }));
2406
+ var urIngestSessionPlmAcctProjectRelations = (0, import_relations.relations)(urIngestSessionPlmAcctProject, ({ one, many }) => ({
2407
+ uniformResources: many(uniformResource),
2408
+ urIngestSessionPlmAccount: one(urIngestSessionPlmAccount, {
2409
+ fields: [urIngestSessionPlmAcctProject.ingestAccountId],
2410
+ references: [urIngestSessionPlmAccount.urIngestSessionPlmAccountId]
2411
+ }),
2412
+ urIngestSession: one(urIngestSession, {
2413
+ fields: [urIngestSessionPlmAcctProject.ingestSessionId],
2414
+ references: [urIngestSession.urIngestSessionId]
2415
+ }),
2416
+ urIngestSessionPlmAcctProjectIssues: many(urIngestSessionPlmAcctProjectIssue),
2417
+ urIngestSessionPlmAcctLabels: many(urIngestSessionPlmAcctLabel),
2418
+ urIngestSessionPlmMilestones: many(urIngestSessionPlmMilestone),
2419
+ urIngestSessionPlmAcctRelationships: many(urIngestSessionPlmAcctRelationship)
2420
+ }));
2421
+ var urIngestSessionImapAcctFolderMessageRelations = (0, import_relations.relations)(urIngestSessionImapAcctFolderMessage, ({ one, many }) => ({
2422
+ uniformResources: many(uniformResource),
2423
+ urIngestSessionImapAcctFolder: one(urIngestSessionImapAcctFolder, {
2424
+ fields: [urIngestSessionImapAcctFolderMessage.ingestImapAcctFolderId],
2425
+ references: [urIngestSessionImapAcctFolder.urIngestSessionImapAcctFolderId]
2426
+ }),
2427
+ urIngestSession: one(urIngestSession, {
2428
+ fields: [urIngestSessionImapAcctFolderMessage.ingestSessionId],
2429
+ references: [urIngestSession.urIngestSessionId]
2430
+ })
2431
+ }));
2432
+ var uniformResourceTransformRelations = (0, import_relations.relations)(uniformResourceTransform, ({ one }) => ({
2433
+ uniformResource: one(uniformResource, {
2434
+ fields: [uniformResourceTransform.uniformResourceId],
2435
+ references: [uniformResource.uniformResourceId]
2436
+ })
2437
+ }));
2438
+ var urIngestSessionFsPathEntryRelations = (0, import_relations.relations)(urIngestSessionFsPathEntry, ({ one }) => ({
2439
+ uniformResource: one(uniformResource, {
2440
+ fields: [urIngestSessionFsPathEntry.uniformResourceId],
2441
+ references: [uniformResource.uniformResourceId]
2442
+ }),
2443
+ urIngestSessionFsPath: one(urIngestSessionFsPath, {
2444
+ fields: [urIngestSessionFsPathEntry.ingestFsPathId],
2445
+ references: [urIngestSessionFsPath.urIngestSessionFsPathId]
2446
+ }),
2447
+ urIngestSession: one(urIngestSession, {
2448
+ fields: [urIngestSessionFsPathEntry.ingestSessionId],
2449
+ references: [urIngestSession.urIngestSessionId]
2450
+ })
2451
+ }));
2452
+ var urIngestSessionTaskRelations = (0, import_relations.relations)(urIngestSessionTask, ({ one }) => ({
2453
+ uniformResource: one(uniformResource, {
2454
+ fields: [urIngestSessionTask.uniformResourceId],
2455
+ references: [uniformResource.uniformResourceId]
2456
+ }),
2457
+ urIngestSession: one(urIngestSession, {
2458
+ fields: [urIngestSessionTask.ingestSessionId],
2459
+ references: [urIngestSession.urIngestSessionId]
2460
+ })
2461
+ }));
2462
+ var urIngestSessionImapAccountRelations = (0, import_relations.relations)(urIngestSessionImapAccount, ({ one, many }) => ({
2463
+ urIngestSession: one(urIngestSession, {
2464
+ fields: [urIngestSessionImapAccount.ingestSessionId],
2465
+ references: [urIngestSession.urIngestSessionId]
2466
+ }),
2467
+ urIngestSessionImapAcctFolders: many(urIngestSessionImapAcctFolder)
2468
+ }));
2469
+ var urIngestSessionImapAcctFolderRelations = (0, import_relations.relations)(urIngestSessionImapAcctFolder, ({ one, many }) => ({
2470
+ urIngestSessionImapAccount: one(urIngestSessionImapAccount, {
2471
+ fields: [urIngestSessionImapAcctFolder.ingestAccountId],
2472
+ references: [urIngestSessionImapAccount.urIngestSessionImapAccountId]
2473
+ }),
2474
+ urIngestSession: one(urIngestSession, {
2475
+ fields: [urIngestSessionImapAcctFolder.ingestSessionId],
2476
+ references: [urIngestSession.urIngestSessionId]
2477
+ }),
2478
+ urIngestSessionImapAcctFolderMessages: many(urIngestSessionImapAcctFolderMessage)
2479
+ }));
2480
+ var urIngestSessionPlmAccountRelations = (0, import_relations.relations)(urIngestSessionPlmAccount, ({ one, many }) => ({
2481
+ urIngestSession: one(urIngestSession, {
2482
+ fields: [urIngestSessionPlmAccount.ingestSessionId],
2483
+ references: [urIngestSession.urIngestSessionId]
2484
+ }),
2485
+ urIngestSessionPlmAcctProjects: many(urIngestSessionPlmAcctProject)
2486
+ }));
2487
+ var urIngestSessionPlmAcctProjectIssueRelations = (0, import_relations.relations)(urIngestSessionPlmAcctProjectIssue, ({ one, many }) => ({
2488
+ urIngestSessionPlmIssueType: one(urIngestSessionPlmIssueType, {
2489
+ fields: [urIngestSessionPlmAcctProjectIssue.issueTypeId],
2490
+ references: [urIngestSessionPlmIssueType.urIngestSessionPlmIssueTypeId]
2491
+ }),
2492
+ urIngestSessionPlmUser: one(urIngestSessionPlmUser, {
2493
+ fields: [urIngestSessionPlmAcctProjectIssue.user],
2494
+ references: [urIngestSessionPlmUser.urIngestSessionPlmUserId]
2495
+ }),
2496
+ uniformResource: one(uniformResource, {
2497
+ fields: [urIngestSessionPlmAcctProjectIssue.uniformResourceId],
2498
+ references: [uniformResource.uniformResourceId]
2499
+ }),
2500
+ urIngestSessionPlmAcctProject: one(urIngestSessionPlmAcctProject, {
2501
+ fields: [urIngestSessionPlmAcctProjectIssue.urIngestSessionPlmAcctProjectId],
2502
+ references: [urIngestSessionPlmAcctProject.urIngestSessionPlmAcctProjectId]
2503
+ }),
2504
+ urIngestSession: one(urIngestSession, {
2505
+ fields: [urIngestSessionPlmAcctProjectIssue.ingestSessionId],
2506
+ references: [urIngestSession.urIngestSessionId]
2507
+ }),
2508
+ urIngestSessionPlmAcctLabels: many(urIngestSessionPlmAcctLabel),
2509
+ urIngestSessionPlmAcctRelationships: many(urIngestSessionPlmAcctRelationship),
2510
+ urIngestSessionPlmComments: many(urIngestSessionPlmComment),
2511
+ urIngestSessionPlmIssueReactions: many(urIngestSessionPlmIssueReaction)
2512
+ }));
2513
+ var urIngestSessionPlmIssueTypeRelations = (0, import_relations.relations)(urIngestSessionPlmIssueType, ({ many }) => ({
2514
+ urIngestSessionPlmAcctProjectIssues: many(urIngestSessionPlmAcctProjectIssue)
2515
+ }));
2516
+ var urIngestSessionPlmUserRelations = (0, import_relations.relations)(urIngestSessionPlmUser, ({ many }) => ({
2517
+ urIngestSessionPlmAcctProjectIssues: many(urIngestSessionPlmAcctProjectIssue),
2518
+ urIngestSessionPlmComments: many(urIngestSessionPlmComment)
2519
+ }));
2520
+ var urIngestSessionPlmAcctLabelRelations = (0, import_relations.relations)(urIngestSessionPlmAcctLabel, ({ one }) => ({
2521
+ urIngestSessionPlmAcctProjectIssue: one(urIngestSessionPlmAcctProjectIssue, {
2522
+ fields: [urIngestSessionPlmAcctLabel.urIngestSessionPlmAcctProjectIssueId],
2523
+ references: [urIngestSessionPlmAcctProjectIssue.urIngestSessionPlmAcctProjectIssueId]
2524
+ }),
2525
+ urIngestSessionPlmAcctProject: one(urIngestSessionPlmAcctProject, {
2526
+ fields: [urIngestSessionPlmAcctLabel.urIngestSessionPlmAcctProjectId],
2527
+ references: [urIngestSessionPlmAcctProject.urIngestSessionPlmAcctProjectId]
2528
+ })
2529
+ }));
2530
+ var urIngestSessionPlmMilestoneRelations = (0, import_relations.relations)(urIngestSessionPlmMilestone, ({ one }) => ({
2531
+ urIngestSessionPlmAcctProject: one(urIngestSessionPlmAcctProject, {
2532
+ fields: [urIngestSessionPlmMilestone.urIngestSessionPlmAcctProjectId],
2533
+ references: [urIngestSessionPlmAcctProject.urIngestSessionPlmAcctProjectId]
2534
+ })
2535
+ }));
2536
+ var urIngestSessionPlmAcctRelationshipRelations = (0, import_relations.relations)(urIngestSessionPlmAcctRelationship, ({ one }) => ({
2537
+ urIngestSessionPlmAcctProjectIssue: one(urIngestSessionPlmAcctProjectIssue, {
2538
+ fields: [urIngestSessionPlmAcctRelationship.urIngestSessionPlmAcctProjectIssueIdPrime],
2539
+ references: [urIngestSessionPlmAcctProjectIssue.urIngestSessionPlmAcctProjectIssueId]
2540
+ }),
2541
+ urIngestSessionPlmAcctProject: one(urIngestSessionPlmAcctProject, {
2542
+ fields: [urIngestSessionPlmAcctRelationship.urIngestSessionPlmAcctProjectIdPrime],
2543
+ references: [urIngestSessionPlmAcctProject.urIngestSessionPlmAcctProjectId]
2544
+ })
2545
+ }));
2546
+ var urIngestSessionPlmCommentRelations = (0, import_relations.relations)(urIngestSessionPlmComment, ({ one }) => ({
2547
+ urIngestSessionPlmUser: one(urIngestSessionPlmUser, {
2548
+ fields: [urIngestSessionPlmComment.user],
2549
+ references: [urIngestSessionPlmUser.urIngestSessionPlmUserId]
2550
+ }),
2551
+ urIngestSessionPlmAcctProjectIssue: one(urIngestSessionPlmAcctProjectIssue, {
2552
+ fields: [urIngestSessionPlmComment.urIngestSessionPlmAcctProjectIssueId],
2553
+ references: [urIngestSessionPlmAcctProjectIssue.urIngestSessionPlmAcctProjectIssueId]
2554
+ })
2555
+ }));
2556
+ var urIngestSessionPlmIssueReactionRelations = (0, import_relations.relations)(urIngestSessionPlmIssueReaction, ({ one }) => ({
2557
+ urIngestSessionPlmAcctProjectIssue: one(urIngestSessionPlmAcctProjectIssue, {
2558
+ fields: [urIngestSessionPlmIssueReaction.urIngestPlmIssueId],
2559
+ references: [urIngestSessionPlmAcctProjectIssue.urIngestSessionPlmAcctProjectIssueId]
2560
+ }),
2561
+ urIngestSessionPlmReaction: one(urIngestSessionPlmReaction, {
2562
+ fields: [urIngestSessionPlmIssueReaction.urIngestPlmReactionId],
2563
+ references: [urIngestSessionPlmReaction.urIngestSessionPlmReactionId]
2564
+ })
2565
+ }));
2566
+ var urIngestSessionPlmReactionRelations = (0, import_relations.relations)(urIngestSessionPlmReaction, ({ many }) => ({
2567
+ urIngestSessionPlmIssueReactions: many(urIngestSessionPlmIssueReaction)
2568
+ }));
2569
+ var urIngestSessionAttachmentRelations = (0, import_relations.relations)(urIngestSessionAttachment, ({ one }) => ({
2570
+ uniformResource: one(uniformResource, {
2571
+ fields: [urIngestSessionAttachment.uniformResourceId],
2572
+ references: [uniformResource.uniformResourceId]
2573
+ })
2574
+ }));
2575
+ var urIngestSessionUdiPgpSqlRelations = (0, import_relations.relations)(urIngestSessionUdiPgpSql, ({ one }) => ({
2576
+ urIngestSession: one(urIngestSession, {
2577
+ fields: [urIngestSessionUdiPgpSql.ingestSessionId],
2578
+ references: [urIngestSession.urIngestSessionId]
2579
+ }),
2580
+ uniformResource: one(uniformResource, {
2581
+ fields: [urIngestSessionUdiPgpSql.uniformResourceId],
2582
+ references: [uniformResource.uniformResourceId]
2583
+ })
2584
+ }));
2585
+ var orchestrationSessionRelations = (0, import_relations.relations)(orchestrationSession, ({ one, many }) => ({
2586
+ orchestrationNature: one(orchestrationNature, {
2587
+ fields: [orchestrationSession.orchestrationNatureId],
2588
+ references: [orchestrationNature.orchestrationNatureId]
2589
+ }),
2590
+ device: one(device, {
2591
+ fields: [orchestrationSession.deviceId],
2592
+ references: [device.deviceId]
2593
+ }),
2594
+ orchestrationSessionEntries: many(orchestrationSessionEntry),
2595
+ orchestrationSessionStates: many(orchestrationSessionState),
2596
+ orchestrationSessionExecs: many(orchestrationSessionExec),
2597
+ orchestrationSessionIssues: many(orchestrationSessionIssue)
2598
+ }));
2599
+ var orchestrationNatureRelations = (0, import_relations.relations)(orchestrationNature, ({ many }) => ({
2600
+ orchestrationSessions: many(orchestrationSession)
2601
+ }));
2602
+ var orchestrationSessionEntryRelations = (0, import_relations.relations)(orchestrationSessionEntry, ({ one, many }) => ({
2603
+ orchestrationSession: one(orchestrationSession, {
2604
+ fields: [orchestrationSessionEntry.sessionId],
2605
+ references: [orchestrationSession.orchestrationSessionId]
2606
+ }),
2607
+ orchestrationSessionStates: many(orchestrationSessionState),
2608
+ orchestrationSessionExecs: many(orchestrationSessionExec),
2609
+ orchestrationSessionIssues: many(orchestrationSessionIssue)
2610
+ }));
2611
+ var orchestrationSessionStateRelations = (0, import_relations.relations)(orchestrationSessionState, ({ one }) => ({
2612
+ orchestrationSessionEntry: one(orchestrationSessionEntry, {
2613
+ fields: [orchestrationSessionState.sessionEntryId],
2614
+ references: [orchestrationSessionEntry.orchestrationSessionEntryId]
2615
+ }),
2616
+ orchestrationSession: one(orchestrationSession, {
2617
+ fields: [orchestrationSessionState.sessionId],
2618
+ references: [orchestrationSession.orchestrationSessionId]
2619
+ })
2620
+ }));
2621
+ var orchestrationSessionExecRelations = (0, import_relations.relations)(orchestrationSessionExec, ({ one, many }) => ({
2622
+ orchestrationSessionExec: one(orchestrationSessionExec, {
2623
+ fields: [orchestrationSessionExec.parentExecId],
2624
+ references: [orchestrationSessionExec.orchestrationSessionExecId],
2625
+ relationName: "orchestrationSessionExec_parentExecId_orchestrationSessionExec_orchestrationSessionExecId"
2626
+ }),
2627
+ orchestrationSessionExecs: many(orchestrationSessionExec, {
2628
+ relationName: "orchestrationSessionExec_parentExecId_orchestrationSessionExec_orchestrationSessionExecId"
2629
+ }),
2630
+ orchestrationSessionEntry: one(orchestrationSessionEntry, {
2631
+ fields: [orchestrationSessionExec.sessionEntryId],
2632
+ references: [orchestrationSessionEntry.orchestrationSessionEntryId]
2633
+ }),
2634
+ orchestrationSession: one(orchestrationSession, {
2635
+ fields: [orchestrationSessionExec.sessionId],
2636
+ references: [orchestrationSession.orchestrationSessionId]
2637
+ })
2638
+ }));
2639
+ var orchestrationSessionIssueRelations = (0, import_relations.relations)(orchestrationSessionIssue, ({ one, many }) => ({
2640
+ orchestrationSessionEntry: one(orchestrationSessionEntry, {
2641
+ fields: [orchestrationSessionIssue.sessionEntryId],
2642
+ references: [orchestrationSessionEntry.orchestrationSessionEntryId]
2643
+ }),
2644
+ orchestrationSession: one(orchestrationSession, {
2645
+ fields: [orchestrationSessionIssue.sessionId],
2646
+ references: [orchestrationSession.orchestrationSessionId]
2647
+ }),
2648
+ orchestrationSessionIssueRelations: many(orchestrationSessionIssueRelation)
2649
+ }));
2650
+ var orchestrationSessionIssueRelationRelations = (0, import_relations.relations)(orchestrationSessionIssueRelation, ({ one }) => ({
2651
+ orchestrationSessionIssue: one(orchestrationSessionIssue, {
2652
+ fields: [orchestrationSessionIssueRelation.issueIdPrime],
2653
+ references: [orchestrationSessionIssue.orchestrationSessionIssueId]
2654
+ })
2655
+ }));
2656
+ var orchestrationSessionLogRelations = (0, import_relations.relations)(orchestrationSessionLog, ({ one, many }) => ({
2657
+ orchestrationSessionLog: one(orchestrationSessionLog, {
2658
+ fields: [orchestrationSessionLog.parentExecId],
2659
+ references: [orchestrationSessionLog.orchestrationSessionLogId],
2660
+ relationName: "orchestrationSessionLog_parentExecId_orchestrationSessionLog_orchestrationSessionLogId"
2661
+ }),
2662
+ orchestrationSessionLogs: many(orchestrationSessionLog, {
2663
+ relationName: "orchestrationSessionLog_parentExecId_orchestrationSessionLog_orchestrationSessionLogId"
2664
+ })
2665
+ }));
2666
+ var uniformResourceEdgeRelations = (0, import_relations.relations)(uniformResourceEdge, ({ one }) => ({
2667
+ uniformResource: one(uniformResource, {
2668
+ fields: [uniformResourceEdge.uniformResourceId],
2669
+ references: [uniformResource.uniformResourceId]
2670
+ }),
2671
+ uniformResourceGraph: one(uniformResourceGraph, {
2672
+ fields: [uniformResourceEdge.graphName],
2673
+ references: [uniformResourceGraph.name]
2674
+ })
2675
+ }));
2676
+ var uniformResourceGraphRelations = (0, import_relations.relations)(uniformResourceGraph, ({ many }) => ({
2677
+ uniformResourceEdges: many(uniformResourceEdge)
2678
+ }));
2679
+ var surveilrOsqueryMsNodeRelations = (0, import_relations.relations)(surveilrOsqueryMsNode, ({ one, many }) => ({
2680
+ behavior: one(behavior, {
2681
+ fields: [surveilrOsqueryMsNode.behaviorId],
2682
+ references: [behavior.behaviorId]
2683
+ }),
2684
+ device: one(device, {
2685
+ fields: [surveilrOsqueryMsNode.deviceId],
2686
+ references: [device.deviceId]
2687
+ }),
2688
+ urIngestSessionOsqueryMsLogs: many(urIngestSessionOsqueryMsLog),
2689
+ surveilrOsqueryMsDistributedQueries: many(surveilrOsqueryMsDistributedQuery),
2690
+ surveilrOsqueryMsDistributedResults: many(surveilrOsqueryMsDistributedResult),
2691
+ surveilrOsqueryMsCarves: many(surveilrOsqueryMsCarve)
2692
+ }));
2693
+ var urIngestSessionOsqueryMsLogRelations = (0, import_relations.relations)(urIngestSessionOsqueryMsLog, ({ one }) => ({
2694
+ surveilrOsqueryMsNode: one(surveilrOsqueryMsNode, {
2695
+ fields: [urIngestSessionOsqueryMsLog.nodeKey],
2696
+ references: [surveilrOsqueryMsNode.nodeKey]
2697
+ })
2698
+ }));
2699
+ var surveilrOsqueryMsDistributedQueryRelations = (0, import_relations.relations)(surveilrOsqueryMsDistributedQuery, ({ one, many }) => ({
2700
+ surveilrOsqueryMsNode: one(surveilrOsqueryMsNode, {
2701
+ fields: [surveilrOsqueryMsDistributedQuery.nodeKey],
2702
+ references: [surveilrOsqueryMsNode.nodeKey]
2703
+ }),
2704
+ surveilrOsqueryMsDistributedResults: many(surveilrOsqueryMsDistributedResult)
2705
+ }));
2706
+ var surveilrOsqueryMsDistributedResultRelations = (0, import_relations.relations)(surveilrOsqueryMsDistributedResult, ({ one }) => ({
2707
+ surveilrOsqueryMsNode: one(surveilrOsqueryMsNode, {
2708
+ fields: [surveilrOsqueryMsDistributedResult.nodeKey],
2709
+ references: [surveilrOsqueryMsNode.nodeKey]
2710
+ }),
2711
+ surveilrOsqueryMsDistributedQuery: one(surveilrOsqueryMsDistributedQuery, {
2712
+ fields: [surveilrOsqueryMsDistributedResult.queryId],
2713
+ references: [surveilrOsqueryMsDistributedQuery.queryId]
2714
+ })
2715
+ }));
2716
+ var surveilrOsqueryMsCarveRelations = (0, import_relations.relations)(surveilrOsqueryMsCarve, ({ one, many }) => ({
2717
+ surveilrOsqueryMsNode: one(surveilrOsqueryMsNode, {
2718
+ fields: [surveilrOsqueryMsCarve.nodeKey],
2719
+ references: [surveilrOsqueryMsNode.nodeKey]
2720
+ }),
2721
+ surveilrOsqueryMsCarvedExtractedFiles: many(surveilrOsqueryMsCarvedExtractedFile)
2722
+ }));
2723
+ var surveilrOsqueryMsCarvedExtractedFileRelations = (0, import_relations.relations)(surveilrOsqueryMsCarvedExtractedFile, ({ one }) => ({
2724
+ surveilrOsqueryMsCarve: one(surveilrOsqueryMsCarve, {
2725
+ fields: [surveilrOsqueryMsCarvedExtractedFile.carveGuid],
2726
+ references: [surveilrOsqueryMsCarve.carveGuid]
2727
+ })
2728
+ }));
2729
+ // Annotate the CommonJS export names for ESM import in node:
2730
+ 0 && (module.exports = {
2731
+ assuranceSchema,
2732
+ assuranceSchemaRelations,
2733
+ behavior,
2734
+ behaviorRelations,
2735
+ checkJSON,
2736
+ codeNotebookCell,
2737
+ codeNotebookCellLatest,
2738
+ codeNotebookCellRelations,
2739
+ codeNotebookCellVersions,
2740
+ codeNotebookKernel,
2741
+ codeNotebookKernelRelations,
2742
+ codeNotebookMigrationSql,
2743
+ codeNotebookSqlCellMigratable,
2744
+ codeNotebookSqlCellMigratableNotExecuted,
2745
+ codeNotebookSqlCellMigratableState,
2746
+ codeNotebookSqlCellMigratableVersion,
2747
+ codeNotebookState,
2748
+ codeNotebookStateRelations,
2749
+ consoleContentTabular,
2750
+ consoleInformationSchemaTable,
2751
+ consoleInformationSchemaTableColFkey,
2752
+ consoleInformationSchemaTableColIndex,
2753
+ consoleInformationSchemaView,
2754
+ device,
2755
+ deviceGraphAnalytics,
2756
+ deviceGraphCorrelations,
2757
+ deviceGraphOverview,
2758
+ devicePartyRelationship,
2759
+ devicePartyRelationshipRelations,
2760
+ deviceRelations,
2761
+ emailMessagesWithTimezone,
2762
+ filesystemGraph,
2763
+ genderType,
2764
+ genderTypeRelations,
2765
+ housekeeping,
2766
+ imapGraph,
2767
+ networkDeviceTopology,
2768
+ orchestrationExecutionSuccessRateByType,
2769
+ orchestrationExecutionsByType,
2770
+ orchestrationIssueRemediation,
2771
+ orchestrationLogsBySession,
2772
+ orchestrationNature,
2773
+ orchestrationNatureRelations,
2774
+ orchestrationSession,
2775
+ orchestrationSessionByDevice,
2776
+ orchestrationSessionDuration,
2777
+ orchestrationSessionEntry,
2778
+ orchestrationSessionEntryRelations,
2779
+ orchestrationSessionExec,
2780
+ orchestrationSessionExecRelations,
2781
+ orchestrationSessionIssue,
2782
+ orchestrationSessionIssueRelation,
2783
+ orchestrationSessionIssueRelationRelations,
2784
+ orchestrationSessionIssueRelations,
2785
+ orchestrationSessionLog,
2786
+ orchestrationSessionLogRelations,
2787
+ orchestrationSessionRelations,
2788
+ orchestrationSessionScript,
2789
+ orchestrationSessionState,
2790
+ orchestrationSessionStateRelations,
2791
+ orchestrationSessionSummary,
2792
+ orchestrationSuccessRate,
2793
+ organization,
2794
+ organizationRelations,
2795
+ organizationRole,
2796
+ organizationRoleRelations,
2797
+ organizationRoleType,
2798
+ organizationRoleTypeRelations,
2799
+ osqueryPolicy,
2800
+ party,
2801
+ partyRelation,
2802
+ partyRelationRelations,
2803
+ partyRelationType,
2804
+ partyRelationTypeRelations,
2805
+ partyRelations,
2806
+ partyType,
2807
+ partyTypeRelations,
2808
+ person,
2809
+ personRelations,
2810
+ personType,
2811
+ personTypeRelations,
2812
+ rssdStatisticsOverview,
2813
+ rssdTableStatistic,
2814
+ sexType,
2815
+ sexTypeRelations,
2816
+ snmpCollectionSummary,
2817
+ snmpDeviceInventory,
2818
+ snmpOidPerformance,
2819
+ sqleanDefine,
2820
+ sqlpageAideNavigation,
2821
+ sqlpageFiles,
2822
+ surveilrFunctionDoc,
2823
+ surveilrOsqueryMsCarve,
2824
+ surveilrOsqueryMsCarveRelations,
2825
+ surveilrOsqueryMsCarvedExtractedFile,
2826
+ surveilrOsqueryMsCarvedExtractedFileRelations,
2827
+ surveilrOsqueryMsDistributedQuery,
2828
+ surveilrOsqueryMsDistributedQueryRelations,
2829
+ surveilrOsqueryMsDistributedResult,
2830
+ surveilrOsqueryMsDistributedResultRelations,
2831
+ surveilrOsqueryMsNode,
2832
+ surveilrOsqueryMsNodeRelations,
2833
+ surveilrSnmpCollection,
2834
+ surveilrSnmpDevice,
2835
+ surveilrTableSize,
2836
+ uniformResource,
2837
+ uniformResourceEdge,
2838
+ uniformResourceEdgeRelations,
2839
+ uniformResourceFile,
2840
+ uniformResourceGraph,
2841
+ uniformResourceGraphRelations,
2842
+ uniformResourceImap,
2843
+ uniformResourceImapContent,
2844
+ uniformResourceRelations,
2845
+ uniformResourceTransform,
2846
+ uniformResourceTransformRelations,
2847
+ urIngestResourcePathMatchRule,
2848
+ urIngestResourcePathRewriteRule,
2849
+ urIngestSession,
2850
+ urIngestSessionAttachment,
2851
+ urIngestSessionAttachmentRelations,
2852
+ urIngestSessionFileIssue,
2853
+ urIngestSessionFilesStats,
2854
+ urIngestSessionFilesStatsLatest,
2855
+ urIngestSessionFsPath,
2856
+ urIngestSessionFsPathEntry,
2857
+ urIngestSessionFsPathEntryRelations,
2858
+ urIngestSessionFsPathRelations,
2859
+ urIngestSessionImapAccount,
2860
+ urIngestSessionImapAccountRelations,
2861
+ urIngestSessionImapAcctFolder,
2862
+ urIngestSessionImapAcctFolderMessage,
2863
+ urIngestSessionImapAcctFolderMessageRelations,
2864
+ urIngestSessionImapAcctFolderRelations,
2865
+ urIngestSessionOsqueryMsLog,
2866
+ urIngestSessionOsqueryMsLogRelations,
2867
+ urIngestSessionPlmAccount,
2868
+ urIngestSessionPlmAccountRelations,
2869
+ urIngestSessionPlmAcctLabel,
2870
+ urIngestSessionPlmAcctLabelRelations,
2871
+ urIngestSessionPlmAcctProject,
2872
+ urIngestSessionPlmAcctProjectIssue,
2873
+ urIngestSessionPlmAcctProjectIssueRelations,
2874
+ urIngestSessionPlmAcctProjectRelations,
2875
+ urIngestSessionPlmAcctRelationship,
2876
+ urIngestSessionPlmAcctRelationshipRelations,
2877
+ urIngestSessionPlmComment,
2878
+ urIngestSessionPlmCommentRelations,
2879
+ urIngestSessionPlmIssueReaction,
2880
+ urIngestSessionPlmIssueReactionRelations,
2881
+ urIngestSessionPlmIssueType,
2882
+ urIngestSessionPlmIssueTypeRelations,
2883
+ urIngestSessionPlmMilestone,
2884
+ urIngestSessionPlmMilestoneRelations,
2885
+ urIngestSessionPlmReaction,
2886
+ urIngestSessionPlmReactionRelations,
2887
+ urIngestSessionPlmUser,
2888
+ urIngestSessionPlmUserRelations,
2889
+ urIngestSessionRelations,
2890
+ urIngestSessionTask,
2891
+ urIngestSessionTaskRelations,
2892
+ urIngestSessionTasksStats,
2893
+ urIngestSessionTasksStatsLatest,
2894
+ urIngestSessionUdiPgpSql,
2895
+ urIngestSessionUdiPgpSqlRelations
2896
+ });