@happyvertical/smrt-facts 0.44.0 → 0.45.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2,7 +2,7 @@
2
2
  "version": "1.0.0",
3
3
  "timestamp": 0,
4
4
  "packageName": "@happyvertical/smrt-facts",
5
- "packageVersion": "0.44.0",
5
+ "packageVersion": "0.45.0",
6
6
  "objects": {
7
7
  "@happyvertical/smrt-facts:FactContent": {
8
8
  "name": "factcontent",
@@ -1056,343 +1056,483 @@
1056
1056
  }
1057
1057
  },
1058
1058
  "methods": {
1059
- "withDatabase": {
1060
- "name": "withDatabase",
1061
- "async": true,
1062
- "parameters": [
1063
- {
1064
- "name": "db",
1065
- "type": "DatabaseInterface",
1066
- "optional": false
1067
- },
1068
- {
1069
- "name": "operation",
1070
- "type": "Function",
1071
- "optional": false
1072
- }
1073
- ],
1074
- "returnType": "Promise<T>",
1075
- "isStatic": false,
1076
- "isPublic": true
1077
- },
1078
- "getAiUsageSnapshot": {
1079
- "name": "getAiUsageSnapshot",
1059
+ "getMetadata": {
1060
+ "name": "getMetadata",
1080
1061
  "async": false,
1081
1062
  "parameters": [],
1082
- "returnType": "AiUsageSnapshot | undefined",
1063
+ "returnType": "Record<string>",
1083
1064
  "isStatic": false,
1084
1065
  "isPublic": true
1085
1066
  },
1086
- "resetAiUsage": {
1087
- "name": "resetAiUsage",
1067
+ "setMetadata": {
1068
+ "name": "setMetadata",
1088
1069
  "async": false,
1089
- "parameters": [],
1090
- "returnType": "void",
1091
- "isStatic": false,
1092
- "isPublic": true
1093
- },
1094
- "listAiUsage": {
1095
- "name": "listAiUsage",
1096
- "async": true,
1097
1070
  "parameters": [
1098
1071
  {
1099
- "name": "options",
1100
- "type": "AiUsageListOptions",
1101
- "optional": true
1072
+ "name": "data",
1073
+ "type": "Record<string>",
1074
+ "optional": false
1102
1075
  }
1103
1076
  ],
1104
- "returnType": "Promise<SmrtAiUsageRecord[]>",
1077
+ "returnType": "void",
1105
1078
  "isStatic": false,
1106
1079
  "isPublic": true
1107
1080
  },
1108
- "summarizeAiUsage": {
1109
- "name": "summarizeAiUsage",
1110
- "async": true,
1081
+ "updateMetadata": {
1082
+ "name": "updateMetadata",
1083
+ "async": false,
1111
1084
  "parameters": [
1112
1085
  {
1113
- "name": "options",
1114
- "type": "AiUsageSummaryOptions",
1115
- "optional": true
1086
+ "name": "updates",
1087
+ "type": "Record<string>",
1088
+ "optional": false
1116
1089
  }
1117
1090
  ],
1118
- "returnType": "Promise<Record<string, AiUsageStats>>",
1119
- "isStatic": false,
1120
- "isPublic": true
1121
- },
1122
- "destroy": {
1123
- "name": "destroy",
1124
- "async": false,
1125
- "parameters": [],
1126
1091
  "returnType": "void",
1127
1092
  "isStatic": false,
1128
1093
  "isPublic": true
1129
1094
  },
1130
- "markAsPersisted": {
1131
- "name": "markAsPersisted",
1132
- "async": false,
1095
+ "getFact": {
1096
+ "name": "getFact",
1097
+ "async": true,
1133
1098
  "parameters": [],
1134
- "returnType": "void",
1099
+ "returnType": "Promise<null>",
1135
1100
  "isStatic": false,
1136
1101
  "isPublic": true
1102
+ }
1103
+ },
1104
+ "decoratorConfig": {
1105
+ "tableStrategy": "sti",
1106
+ "api": {
1107
+ "include": [
1108
+ "list",
1109
+ "get",
1110
+ "create",
1111
+ "delete"
1112
+ ]
1137
1113
  },
1138
- "requireInsertOnSave": {
1139
- "name": "requireInsertOnSave",
1140
- "async": false,
1141
- "parameters": [],
1142
- "returnType": "void",
1143
- "isStatic": false,
1144
- "isPublic": true
1114
+ "mcp": {
1115
+ "include": [
1116
+ "list",
1117
+ "get",
1118
+ "create"
1119
+ ]
1120
+ },
1121
+ "cli": true,
1122
+ "tenantScoped": {
1123
+ "mode": "optional"
1124
+ },
1125
+ "conflictColumns": [
1126
+ "tenant_id",
1127
+ "slug",
1128
+ "context",
1129
+ "_meta_type"
1130
+ ]
1131
+ },
1132
+ "extends": "SmrtObject",
1133
+ "exportName": "FactSource",
1134
+ "collectionExportName": "FactSourceCollection",
1135
+ "validationRules": [
1136
+ {
1137
+ "field": "factId",
1138
+ "rule": "required",
1139
+ "fieldType": "foreignKey"
1140
+ }
1141
+ ],
1142
+ "schema": {
1143
+ "tableName": "fact_sources",
1144
+ "ddl": "CREATE TABLE IF NOT EXISTS \"fact_sources\" (\n \"id\" UUID PRIMARY KEY NOT NULL,\n \"slug\" TEXT NOT NULL,\n \"context\" TEXT NOT NULL DEFAULT '',\n \"_meta_type\" TEXT NOT NULL,\n \"_meta_data\" JSON,\n \"created_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"updated_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"fact_id\" UUID,\n \"source_type\" TEXT DEFAULT '',\n \"source_url\" TEXT DEFAULT '',\n \"source_title\" TEXT DEFAULT '',\n \"credibility\" REAL DEFAULT 0,\n \"extracted_at\" TIMESTAMP,\n \"metadata\" TEXT DEFAULT '',\n \"tenant_id\" UUID\n);",
1145
+ "columns": {
1146
+ "id": {
1147
+ "type": "UUID",
1148
+ "primaryKey": true,
1149
+ "referenceKind": "id",
1150
+ "notNull": true
1151
+ },
1152
+ "slug": {
1153
+ "type": "TEXT",
1154
+ "notNull": true
1155
+ },
1156
+ "context": {
1157
+ "type": "TEXT",
1158
+ "notNull": true,
1159
+ "default": ""
1160
+ },
1161
+ "_meta_type": {
1162
+ "type": "TEXT",
1163
+ "notNull": true
1164
+ },
1165
+ "_meta_data": {
1166
+ "type": "JSON",
1167
+ "notNull": false
1168
+ },
1169
+ "created_at": {
1170
+ "type": "TIMESTAMP",
1171
+ "notNull": true,
1172
+ "default": "current_timestamp"
1173
+ },
1174
+ "updated_at": {
1175
+ "type": "TIMESTAMP",
1176
+ "notNull": true,
1177
+ "default": "current_timestamp"
1178
+ },
1179
+ "fact_id": {
1180
+ "type": "UUID",
1181
+ "referenceKind": "foreignKey",
1182
+ "notNull": false,
1183
+ "foreignKey": {
1184
+ "table": "facts",
1185
+ "column": "id",
1186
+ "onDelete": "NO ACTION",
1187
+ "onUpdate": "CASCADE"
1188
+ }
1189
+ },
1190
+ "source_type": {
1191
+ "type": "TEXT",
1192
+ "notNull": false,
1193
+ "default": ""
1194
+ },
1195
+ "source_url": {
1196
+ "type": "TEXT",
1197
+ "notNull": false,
1198
+ "default": ""
1199
+ },
1200
+ "source_title": {
1201
+ "type": "TEXT",
1202
+ "notNull": false,
1203
+ "default": ""
1204
+ },
1205
+ "credibility": {
1206
+ "type": "REAL",
1207
+ "notNull": false,
1208
+ "default": 0
1209
+ },
1210
+ "extracted_at": {
1211
+ "type": "TIMESTAMP",
1212
+ "notNull": false
1213
+ },
1214
+ "metadata": {
1215
+ "type": "TEXT",
1216
+ "notNull": false,
1217
+ "default": ""
1218
+ },
1219
+ "tenant_id": {
1220
+ "type": "UUID",
1221
+ "referenceKind": "tenantId",
1222
+ "notNull": false
1223
+ }
1145
1224
  },
1146
- "withTransaction": {
1147
- "name": "withTransaction",
1225
+ "indexes": [
1226
+ {
1227
+ "name": "fact_sources_slug_context_meta_type_idx",
1228
+ "columns": [
1229
+ "tenant_id",
1230
+ "slug",
1231
+ "context",
1232
+ "_meta_type"
1233
+ ],
1234
+ "unique": true
1235
+ },
1236
+ {
1237
+ "name": "fact_sources_meta_type_idx",
1238
+ "columns": [
1239
+ "_meta_type"
1240
+ ]
1241
+ },
1242
+ {
1243
+ "name": "fact_sources_tenant_id_created_at_idx",
1244
+ "columns": [
1245
+ "tenant_id",
1246
+ "created_at"
1247
+ ]
1248
+ },
1249
+ {
1250
+ "name": "fact_sources_fact_id_idx",
1251
+ "columns": [
1252
+ "fact_id"
1253
+ ]
1254
+ }
1255
+ ],
1256
+ "version": "9d0f874e"
1257
+ }
1258
+ },
1259
+ "@happyvertical/smrt-facts:FactSourceCollection": {
1260
+ "name": "factsourcecollection",
1261
+ "className": "FactSourceCollection",
1262
+ "qualifiedName": "@happyvertical/smrt-facts:FactSourceCollection",
1263
+ "collection": "factsources",
1264
+ "filePath": "/home/runner/work/smrt/smrt/packages/facts/src/fact-sources.ts",
1265
+ "packageName": "@happyvertical/smrt-facts",
1266
+ "fields": {},
1267
+ "methods": {
1268
+ "getForFact": {
1269
+ "name": "getForFact",
1148
1270
  "async": true,
1149
1271
  "parameters": [
1150
1272
  {
1151
- "name": "operation",
1152
- "type": "Function",
1273
+ "name": "factId",
1274
+ "type": "string",
1153
1275
  "optional": false
1154
1276
  }
1155
1277
  ],
1156
- "returnType": "Promise<T>",
1278
+ "returnType": "Promise<FactSource[]>",
1157
1279
  "isStatic": false,
1158
1280
  "isPublic": true
1159
1281
  },
1160
- "initialize": {
1161
- "name": "initialize",
1282
+ "countForFact": {
1283
+ "name": "countForFact",
1162
1284
  "async": true,
1163
- "parameters": [],
1164
- "returnType": "Promise",
1285
+ "parameters": [
1286
+ {
1287
+ "name": "factId",
1288
+ "type": "string",
1289
+ "optional": false
1290
+ }
1291
+ ],
1292
+ "returnType": "Promise<number>",
1165
1293
  "isStatic": false,
1166
1294
  "isPublic": true
1167
1295
  },
1168
- "loadDataFromDb": {
1169
- "name": "loadDataFromDb",
1296
+ "getByType": {
1297
+ "name": "getByType",
1170
1298
  "async": true,
1171
1299
  "parameters": [
1172
1300
  {
1173
- "name": "data",
1174
- "type": "Record<string>",
1301
+ "name": "sourceType",
1302
+ "type": "string",
1175
1303
  "optional": false
1176
1304
  }
1177
1305
  ],
1178
- "returnType": "any",
1306
+ "returnType": "Promise<FactSource[]>",
1179
1307
  "isStatic": false,
1180
1308
  "isPublic": true
1181
1309
  },
1182
- "getFields": {
1183
- "name": "getFields",
1310
+ "getHighCredibility": {
1311
+ "name": "getHighCredibility",
1184
1312
  "async": true,
1185
- "parameters": [],
1186
- "returnType": "Promise<any>",
1313
+ "parameters": [
1314
+ {
1315
+ "name": "minCredibility",
1316
+ "type": "number",
1317
+ "optional": true
1318
+ }
1319
+ ],
1320
+ "returnType": "Promise<FactSource[]>",
1187
1321
  "isStatic": false,
1188
1322
  "isPublic": true
1189
1323
  },
1190
- "toJSON": {
1191
- "name": "toJSON",
1192
- "async": false,
1193
- "parameters": [],
1194
- "returnType": "any",
1195
- "isStatic": false,
1196
- "isPublic": true
1197
- },
1198
- "toPlainObject": {
1199
- "name": "toPlainObject",
1200
- "async": false,
1201
- "parameters": [],
1202
- "returnType": "Record<string>",
1203
- "isStatic": false,
1204
- "isPublic": true
1205
- },
1206
- "toPublicJSON": {
1207
- "name": "toPublicJSON",
1208
- "async": false,
1209
- "parameters": [
1210
- {
1211
- "name": "options",
1212
- "type": "PublicJsonOptions",
1213
- "optional": true
1214
- }
1215
- ],
1216
- "returnType": "Record<string>",
1217
- "isStatic": false,
1218
- "isPublic": true
1219
- },
1220
- "getId": {
1221
- "name": "getId",
1222
- "async": true,
1223
- "parameters": [],
1224
- "returnType": "any",
1225
- "isStatic": false,
1226
- "isPublic": true
1227
- },
1228
- "getSlug": {
1229
- "name": "getSlug",
1230
- "async": true,
1231
- "parameters": [],
1232
- "returnType": "any",
1233
- "isStatic": false,
1234
- "isPublic": true
1235
- },
1236
- "getSavedId": {
1237
- "name": "getSavedId",
1238
- "async": true,
1239
- "parameters": [],
1240
- "returnType": "any",
1241
- "isStatic": false,
1242
- "isPublic": true
1243
- },
1244
- "isSaved": {
1245
- "name": "isSaved",
1246
- "async": true,
1247
- "parameters": [],
1248
- "returnType": "any",
1249
- "isStatic": false,
1250
- "isPublic": true
1251
- },
1252
- "save": {
1253
- "name": "save",
1254
- "async": true,
1255
- "parameters": [
1256
- {
1257
- "name": "options",
1258
- "type": "SmrtSaveOptions",
1259
- "optional": true
1260
- }
1261
- ],
1262
- "returnType": "any",
1263
- "isStatic": false,
1264
- "isPublic": true
1265
- },
1266
- "claimRevision": {
1267
- "name": "claimRevision",
1324
+ "getAverageCredibility": {
1325
+ "name": "getAverageCredibility",
1268
1326
  "async": true,
1269
1327
  "parameters": [
1270
1328
  {
1271
- "name": "expectedUpdatedAt",
1272
- "type": "Date | string",
1329
+ "name": "factId",
1330
+ "type": "string",
1273
1331
  "optional": false
1274
1332
  }
1275
1333
  ],
1276
- "returnType": "Promise",
1334
+ "returnType": "Promise<number>",
1277
1335
  "isStatic": false,
1278
1336
  "isPublic": true
1279
1337
  },
1280
- "classifyConstraintError": {
1281
- "name": "classifyConstraintError",
1282
- "async": false,
1338
+ "findByTenant": {
1339
+ "name": "findByTenant",
1340
+ "async": true,
1283
1341
  "parameters": [
1284
1342
  {
1285
- "name": "message",
1343
+ "name": "tenantId",
1286
1344
  "type": "string",
1287
1345
  "optional": false
1288
1346
  }
1289
1347
  ],
1290
- "returnType": "'unique' | 'not_null' | null",
1291
- "isStatic": true,
1292
- "isPublic": true
1293
- },
1294
- "loadFromId": {
1295
- "name": "loadFromId",
1296
- "async": true,
1297
- "parameters": [],
1298
- "returnType": "any",
1348
+ "returnType": "Promise<FactSource[]>",
1299
1349
  "isStatic": false,
1300
1350
  "isPublic": true
1301
1351
  },
1302
- "loadFromSlug": {
1303
- "name": "loadFromSlug",
1352
+ "findGlobal": {
1353
+ "name": "findGlobal",
1304
1354
  "async": true,
1305
1355
  "parameters": [],
1306
- "returnType": "any",
1356
+ "returnType": "Promise<FactSource[]>",
1307
1357
  "isStatic": false,
1308
1358
  "isPublic": true
1309
1359
  },
1310
- "is": {
1311
- "name": "is",
1360
+ "findWithGlobals": {
1361
+ "name": "findWithGlobals",
1312
1362
  "async": true,
1313
1363
  "parameters": [
1314
1364
  {
1315
- "name": "criteria",
1365
+ "name": "tenantId",
1316
1366
  "type": "string",
1317
1367
  "optional": false
1318
- },
1319
- {
1320
- "name": "options",
1321
- "type": "AiOperationOptions",
1322
- "optional": true
1323
1368
  }
1324
1369
  ],
1325
- "returnType": "any",
1370
+ "returnType": "Promise<FactSource[]>",
1326
1371
  "isStatic": false,
1327
1372
  "isPublic": true
1373
+ }
1374
+ },
1375
+ "decoratorConfig": {},
1376
+ "extends": "SmrtCollection",
1377
+ "extendsTypeArg": "FactSource",
1378
+ "exportName": "FactSourceCollection",
1379
+ "collectionExportName": "FactSourceCollectionCollection",
1380
+ "schema": {
1381
+ "tableName": "fact_source_collections",
1382
+ "ddl": "CREATE TABLE IF NOT EXISTS \"fact_source_collections\" (\n \"id\" UUID PRIMARY KEY NOT NULL,\n \"slug\" TEXT NOT NULL,\n \"context\" TEXT NOT NULL DEFAULT '',\n \"created_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"updated_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp\n);",
1383
+ "columns": {
1384
+ "id": {
1385
+ "type": "UUID",
1386
+ "primaryKey": true,
1387
+ "referenceKind": "id",
1388
+ "notNull": true
1389
+ },
1390
+ "slug": {
1391
+ "type": "TEXT",
1392
+ "notNull": true
1393
+ },
1394
+ "context": {
1395
+ "type": "TEXT",
1396
+ "notNull": true,
1397
+ "default": ""
1398
+ },
1399
+ "created_at": {
1400
+ "type": "TIMESTAMP",
1401
+ "notNull": true,
1402
+ "default": "current_timestamp"
1403
+ },
1404
+ "updated_at": {
1405
+ "type": "TIMESTAMP",
1406
+ "notNull": true,
1407
+ "default": "current_timestamp"
1408
+ }
1328
1409
  },
1329
- "do": {
1330
- "name": "do",
1331
- "async": true,
1332
- "parameters": [
1333
- {
1334
- "name": "instructions",
1335
- "type": "string",
1336
- "optional": false
1337
- },
1338
- {
1339
- "name": "options",
1340
- "type": "AiOperationOptions",
1341
- "optional": true
1342
- }
1343
- ],
1344
- "returnType": "any",
1345
- "isStatic": false,
1346
- "isPublic": true
1410
+ "indexes": [
1411
+ {
1412
+ "name": "fact_source_collections_slug_context_idx",
1413
+ "columns": [
1414
+ "slug",
1415
+ "context"
1416
+ ],
1417
+ "unique": true
1418
+ },
1419
+ {
1420
+ "name": "fact_source_collections_created_at_idx",
1421
+ "columns": [
1422
+ "created_at"
1423
+ ]
1424
+ }
1425
+ ],
1426
+ "version": "36f4adef"
1427
+ }
1428
+ },
1429
+ "@happyvertical/smrt-facts:FactSubject": {
1430
+ "name": "factsubject",
1431
+ "className": "FactSubject",
1432
+ "qualifiedName": "@happyvertical/smrt-facts:FactSubject",
1433
+ "collection": "factsubjects",
1434
+ "filePath": "/home/runner/work/smrt/smrt/packages/facts/src/fact-subject.ts",
1435
+ "packageName": "@happyvertical/smrt-facts",
1436
+ "fields": {
1437
+ "factId": {
1438
+ "type": "foreignKey",
1439
+ "required": true,
1440
+ "related": "Fact",
1441
+ "_meta": {
1442
+ "required": true
1443
+ }
1347
1444
  },
1348
- "describe": {
1349
- "name": "describe",
1350
- "async": true,
1351
- "parameters": [
1352
- {
1353
- "name": "options",
1354
- "type": "AiOperationOptions",
1355
- "optional": true
1445
+ "entityType": {
1446
+ "type": "text",
1447
+ "required": true,
1448
+ "default": "",
1449
+ "_meta": {
1450
+ "required": true
1451
+ }
1452
+ },
1453
+ "entityId": {
1454
+ "type": "text",
1455
+ "required": true,
1456
+ "default": "",
1457
+ "_meta": {
1458
+ "required": true
1459
+ }
1460
+ },
1461
+ "role": {
1462
+ "type": "text",
1463
+ "required": false,
1464
+ "default": "subject"
1465
+ },
1466
+ "metadata": {
1467
+ "type": "text",
1468
+ "required": false,
1469
+ "default": ""
1470
+ },
1471
+ "tenantId": {
1472
+ "type": "text",
1473
+ "required": false,
1474
+ "_meta": {
1475
+ "sqlType": "UUID",
1476
+ "nullable": true,
1477
+ "__tenancy": {
1478
+ "isTenantIdField": true,
1479
+ "autoFilter": true,
1480
+ "required": false,
1481
+ "autoPopulate": true,
1482
+ "nullable": true,
1483
+ "mode": "optional",
1484
+ "field": "tenantId",
1485
+ "allowSuperAdminBypass": false
1356
1486
  }
1357
- ],
1358
- "returnType": "any",
1487
+ }
1488
+ },
1489
+ "createdAt": {
1490
+ "type": "datetime",
1491
+ "required": false
1492
+ },
1493
+ "updatedAt": {
1494
+ "type": "datetime",
1495
+ "required": false
1496
+ }
1497
+ },
1498
+ "methods": {
1499
+ "getRole": {
1500
+ "name": "getRole",
1501
+ "async": false,
1502
+ "parameters": [],
1503
+ "returnType": "SubjectRole",
1359
1504
  "isStatic": false,
1360
1505
  "isPublic": true
1361
1506
  },
1362
- "delete": {
1363
- "name": "delete",
1364
- "async": true,
1507
+ "getMetadata": {
1508
+ "name": "getMetadata",
1509
+ "async": false,
1365
1510
  "parameters": [],
1366
- "returnType": "Promise<void>",
1511
+ "returnType": "Record<string>",
1367
1512
  "isStatic": false,
1368
1513
  "isPublic": true
1369
1514
  },
1370
- "isRelatedLoaded": {
1371
- "name": "isRelatedLoaded",
1515
+ "setMetadata": {
1516
+ "name": "setMetadata",
1372
1517
  "async": false,
1373
1518
  "parameters": [
1374
1519
  {
1375
- "name": "fieldName",
1376
- "type": "string",
1520
+ "name": "data",
1521
+ "type": "Record<string>",
1377
1522
  "optional": false
1378
1523
  }
1379
1524
  ],
1380
- "returnType": "boolean",
1525
+ "returnType": "void",
1381
1526
  "isStatic": false,
1382
1527
  "isPublic": true
1383
1528
  },
1384
- "_setLoadedRelationship": {
1385
- "name": "_setLoadedRelationship",
1529
+ "updateMetadata": {
1530
+ "name": "updateMetadata",
1386
1531
  "async": false,
1387
1532
  "parameters": [
1388
1533
  {
1389
- "name": "fieldName",
1390
- "type": "string",
1391
- "optional": false
1392
- },
1393
- {
1394
- "name": "value",
1395
- "type": "any",
1534
+ "name": "updates",
1535
+ "type": "Record<string>",
1396
1536
  "optional": false
1397
1537
  }
1398
1538
  ],
@@ -1400,242 +1540,8 @@
1400
1540
  "isStatic": false,
1401
1541
  "isPublic": true
1402
1542
  },
1403
- "loadRelated": {
1404
- "name": "loadRelated",
1405
- "async": true,
1406
- "parameters": [
1407
- {
1408
- "name": "fieldName",
1409
- "type": "string",
1410
- "optional": false
1411
- },
1412
- {
1413
- "name": "opts",
1414
- "type": "LoadRelatedOptions",
1415
- "optional": true
1416
- }
1417
- ],
1418
- "returnType": "Promise<any>",
1419
- "isStatic": false,
1420
- "isPublic": true
1421
- },
1422
- "loadRelatedMany": {
1423
- "name": "loadRelatedMany",
1424
- "async": true,
1425
- "parameters": [
1426
- {
1427
- "name": "fieldName",
1428
- "type": "string",
1429
- "optional": false
1430
- },
1431
- {
1432
- "name": "opts",
1433
- "type": "LoadRelatedOptions",
1434
- "optional": true
1435
- }
1436
- ],
1437
- "returnType": "Promise<any[]>",
1438
- "isStatic": false,
1439
- "isPublic": true
1440
- },
1441
- "getRelated": {
1442
- "name": "getRelated",
1443
- "async": true,
1444
- "parameters": [
1445
- {
1446
- "name": "fieldName",
1447
- "type": "string",
1448
- "optional": false
1449
- },
1450
- {
1451
- "name": "opts",
1452
- "type": "LoadRelatedOptions",
1453
- "optional": true
1454
- }
1455
- ],
1456
- "returnType": "Promise<any>",
1457
- "isStatic": false,
1458
- "isPublic": true
1459
- },
1460
- "getAvailableTools": {
1461
- "name": "getAvailableTools",
1462
- "async": false,
1463
- "parameters": [],
1464
- "returnType": "AITool[]",
1465
- "isStatic": false,
1466
- "isPublic": true
1467
- },
1468
- "executeToolCall": {
1469
- "name": "executeToolCall",
1470
- "async": true,
1471
- "parameters": [
1472
- {
1473
- "name": "toolCall",
1474
- "type": "ToolCall",
1475
- "optional": false
1476
- }
1477
- ],
1478
- "returnType": "Promise<ToolCallResult>",
1479
- "isStatic": false,
1480
- "isPublic": true
1481
- },
1482
- "remember": {
1483
- "name": "remember",
1484
- "async": true,
1485
- "parameters": [
1486
- {
1487
- "name": "options",
1488
- "type": "object",
1489
- "optional": false
1490
- }
1491
- ],
1492
- "returnType": "Promise<void>",
1493
- "isStatic": false,
1494
- "isPublic": true
1495
- },
1496
- "recall": {
1497
- "name": "recall",
1498
- "async": true,
1499
- "parameters": [
1500
- {
1501
- "name": "options",
1502
- "type": "object",
1503
- "optional": false
1504
- }
1505
- ],
1506
- "returnType": "Promise",
1507
- "isStatic": false,
1508
- "isPublic": true
1509
- },
1510
- "recallAll": {
1511
- "name": "recallAll",
1512
- "async": true,
1513
- "parameters": [
1514
- {
1515
- "name": "options",
1516
- "type": "object",
1517
- "optional": true
1518
- }
1519
- ],
1520
- "returnType": "Promise<Map<string>>",
1521
- "isStatic": false,
1522
- "isPublic": true
1523
- },
1524
- "forget": {
1525
- "name": "forget",
1526
- "async": true,
1527
- "parameters": [
1528
- {
1529
- "name": "options",
1530
- "type": "object",
1531
- "optional": false
1532
- }
1533
- ],
1534
- "returnType": "Promise<void>",
1535
- "isStatic": false,
1536
- "isPublic": true
1537
- },
1538
- "forgetScope": {
1539
- "name": "forgetScope",
1540
- "async": true,
1541
- "parameters": [
1542
- {
1543
- "name": "options",
1544
- "type": "object",
1545
- "optional": false
1546
- }
1547
- ],
1548
- "returnType": "Promise<number>",
1549
- "isStatic": false,
1550
- "isPublic": true
1551
- },
1552
- "generateEmbeddings": {
1553
- "name": "generateEmbeddings",
1554
- "async": true,
1555
- "parameters": [
1556
- {
1557
- "name": "options",
1558
- "type": "GenerateEmbeddingsOptions",
1559
- "optional": true
1560
- }
1561
- ],
1562
- "returnType": "Promise<void>",
1563
- "isStatic": false,
1564
- "isPublic": true
1565
- },
1566
- "getEmbedding": {
1567
- "name": "getEmbedding",
1568
- "async": true,
1569
- "parameters": [
1570
- {
1571
- "name": "fieldName",
1572
- "type": "string",
1573
- "optional": false
1574
- },
1575
- {
1576
- "name": "model",
1577
- "type": "string",
1578
- "optional": true
1579
- }
1580
- ],
1581
- "returnType": "Promise<number[] | null>",
1582
- "isStatic": false,
1583
- "isPublic": true
1584
- },
1585
- "hasStaleEmbeddings": {
1586
- "name": "hasStaleEmbeddings",
1587
- "async": true,
1588
- "parameters": [],
1589
- "returnType": "Promise<boolean>",
1590
- "isStatic": false,
1591
- "isPublic": true
1592
- },
1593
- "clearEmbeddings": {
1594
- "name": "clearEmbeddings",
1595
- "async": true,
1596
- "parameters": [],
1597
- "returnType": "Promise<void>",
1598
- "isStatic": false,
1599
- "isPublic": true
1600
- },
1601
- "getMetadata": {
1602
- "name": "getMetadata",
1603
- "async": false,
1604
- "parameters": [],
1605
- "returnType": "Record<string>",
1606
- "isStatic": false,
1607
- "isPublic": true
1608
- },
1609
- "setMetadata": {
1610
- "name": "setMetadata",
1611
- "async": false,
1612
- "parameters": [
1613
- {
1614
- "name": "data",
1615
- "type": "Record<string>",
1616
- "optional": false
1617
- }
1618
- ],
1619
- "returnType": "void",
1620
- "isStatic": false,
1621
- "isPublic": true
1622
- },
1623
- "updateMetadata": {
1624
- "name": "updateMetadata",
1625
- "async": false,
1626
- "parameters": [
1627
- {
1628
- "name": "updates",
1629
- "type": "Record<string>",
1630
- "optional": false
1631
- }
1632
- ],
1633
- "returnType": "void",
1634
- "isStatic": false,
1635
- "isPublic": true
1636
- },
1637
- "getFact": {
1638
- "name": "getFact",
1543
+ "getFact": {
1544
+ "name": "getFact",
1639
1545
  "async": true,
1640
1546
  "parameters": [],
1641
1547
  "returnType": "Promise<null>",
@@ -1644,7 +1550,11 @@
1644
1550
  }
1645
1551
  },
1646
1552
  "decoratorConfig": {
1647
- "tableStrategy": "sti",
1553
+ "conflictColumns": [
1554
+ "fact_id",
1555
+ "entity_type",
1556
+ "entity_id"
1557
+ ],
1648
1558
  "api": {
1649
1559
  "include": [
1650
1560
  "list",
@@ -1663,27 +1573,31 @@
1663
1573
  "cli": true,
1664
1574
  "tenantScoped": {
1665
1575
  "mode": "optional"
1666
- },
1667
- "conflictColumns": [
1668
- "tenant_id",
1669
- "slug",
1670
- "context",
1671
- "_meta_type"
1672
- ]
1576
+ }
1673
1577
  },
1674
1578
  "extends": "SmrtObject",
1675
- "exportName": "FactSource",
1676
- "collectionExportName": "FactSourceCollection",
1579
+ "exportName": "FactSubject",
1580
+ "collectionExportName": "FactSubjectCollection",
1677
1581
  "validationRules": [
1678
1582
  {
1679
1583
  "field": "factId",
1680
1584
  "rule": "required",
1681
1585
  "fieldType": "foreignKey"
1586
+ },
1587
+ {
1588
+ "field": "entityType",
1589
+ "rule": "required",
1590
+ "fieldType": "text"
1591
+ },
1592
+ {
1593
+ "field": "entityId",
1594
+ "rule": "required",
1595
+ "fieldType": "text"
1682
1596
  }
1683
1597
  ],
1684
1598
  "schema": {
1685
- "tableName": "fact_sources",
1686
- "ddl": "CREATE TABLE IF NOT EXISTS \"fact_sources\" (\n \"id\" UUID PRIMARY KEY NOT NULL,\n \"slug\" TEXT NOT NULL,\n \"context\" TEXT NOT NULL DEFAULT '',\n \"_meta_type\" TEXT NOT NULL,\n \"_meta_data\" JSON,\n \"created_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"updated_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"fact_id\" UUID,\n \"source_type\" TEXT DEFAULT '',\n \"source_url\" TEXT DEFAULT '',\n \"source_title\" TEXT DEFAULT '',\n \"credibility\" REAL DEFAULT 0,\n \"extracted_at\" TIMESTAMP,\n \"metadata\" TEXT DEFAULT '',\n \"tenant_id\" UUID\n);",
1599
+ "tableName": "fact_subjects",
1600
+ "ddl": "CREATE TABLE IF NOT EXISTS \"fact_subjects\" (\n \"id\" UUID PRIMARY KEY NOT NULL,\n \"slug\" TEXT NOT NULL,\n \"context\" TEXT NOT NULL DEFAULT '',\n \"created_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"updated_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"fact_id\" UUID NOT NULL,\n \"entity_type\" TEXT NOT NULL DEFAULT '',\n \"entity_id\" TEXT NOT NULL DEFAULT '',\n \"role\" TEXT DEFAULT 'subject',\n \"metadata\" TEXT DEFAULT '',\n \"tenant_id\" UUID\n);",
1687
1601
  "columns": {
1688
1602
  "id": {
1689
1603
  "type": "UUID",
@@ -1700,14 +1614,6 @@
1700
1614
  "notNull": true,
1701
1615
  "default": ""
1702
1616
  },
1703
- "_meta_type": {
1704
- "type": "TEXT",
1705
- "notNull": true
1706
- },
1707
- "_meta_data": {
1708
- "type": "JSON",
1709
- "notNull": false
1710
- },
1711
1617
  "created_at": {
1712
1618
  "type": "TIMESTAMP",
1713
1619
  "notNull": true,
@@ -1721,89 +1627,80 @@
1721
1627
  "fact_id": {
1722
1628
  "type": "UUID",
1723
1629
  "referenceKind": "foreignKey",
1724
- "notNull": false,
1630
+ "notNull": true,
1631
+ "unique": false,
1725
1632
  "foreignKey": {
1726
1633
  "table": "facts",
1727
1634
  "column": "id",
1728
- "onDelete": "NO ACTION",
1635
+ "onDelete": "CASCADE",
1729
1636
  "onUpdate": "CASCADE"
1730
1637
  }
1731
1638
  },
1732
- "source_type": {
1639
+ "entity_type": {
1733
1640
  "type": "TEXT",
1734
- "notNull": false,
1641
+ "notNull": true,
1642
+ "unique": false,
1735
1643
  "default": ""
1736
1644
  },
1737
- "source_url": {
1645
+ "entity_id": {
1738
1646
  "type": "TEXT",
1739
- "notNull": false,
1647
+ "notNull": true,
1648
+ "unique": false,
1740
1649
  "default": ""
1741
1650
  },
1742
- "source_title": {
1651
+ "role": {
1743
1652
  "type": "TEXT",
1744
1653
  "notNull": false,
1745
- "default": ""
1746
- },
1747
- "credibility": {
1748
- "type": "REAL",
1749
- "notNull": false,
1750
- "default": 0
1751
- },
1752
- "extracted_at": {
1753
- "type": "TIMESTAMP",
1754
- "notNull": false
1654
+ "unique": false,
1655
+ "default": "subject"
1755
1656
  },
1756
1657
  "metadata": {
1757
1658
  "type": "TEXT",
1758
1659
  "notNull": false,
1660
+ "unique": false,
1759
1661
  "default": ""
1760
1662
  },
1761
1663
  "tenant_id": {
1762
1664
  "type": "UUID",
1763
1665
  "referenceKind": "tenantId",
1764
- "notNull": false
1666
+ "notNull": false,
1667
+ "unique": false
1765
1668
  }
1766
1669
  },
1767
1670
  "indexes": [
1768
1671
  {
1769
- "name": "fact_sources_slug_context_meta_type_idx",
1672
+ "name": "fact_subjects_fact_id_entity_type_idx",
1770
1673
  "columns": [
1771
- "tenant_id",
1772
- "slug",
1773
- "context",
1774
- "_meta_type"
1674
+ "fact_id",
1675
+ "entity_type",
1676
+ "entity_id"
1775
1677
  ],
1776
1678
  "unique": true
1777
1679
  },
1778
1680
  {
1779
- "name": "fact_sources_meta_type_idx",
1681
+ "name": "fact_subjects_slug_context_idx",
1780
1682
  "columns": [
1781
- "_meta_type"
1683
+ "slug",
1684
+ "context"
1782
1685
  ]
1783
1686
  },
1784
1687
  {
1785
- "name": "fact_sources_tenant_id_created_at_idx",
1688
+ "name": "fact_subjects_tenant_id_created_at_idx",
1786
1689
  "columns": [
1787
1690
  "tenant_id",
1788
1691
  "created_at"
1789
1692
  ]
1790
- },
1791
- {
1792
- "name": "fact_sources_fact_id_idx",
1793
- "columns": [
1794
- "fact_id"
1795
- ]
1796
1693
  }
1797
1694
  ],
1798
- "version": "9d0f874e"
1695
+ "version": "cb6eca71"
1799
1696
  }
1800
1697
  },
1801
- "@happyvertical/smrt-facts:FactSourceCollection": {
1802
- "name": "factsourcecollection",
1803
- "className": "FactSourceCollection",
1804
- "qualifiedName": "@happyvertical/smrt-facts:FactSourceCollection",
1805
- "collection": "factsources",
1806
- "filePath": "/home/runner/work/smrt/smrt/packages/facts/src/fact-sources.ts",
1698
+ "@happyvertical/smrt-facts:FactSubjectCollection": {
1699
+ "name": "factsubjectcollection",
1700
+ "className": "FactSubjectCollection",
1701
+ "qualifiedName": "@happyvertical/smrt-facts:FactSubjectCollection",
1702
+ "collection": "factsubjects",
1703
+ "filePath": "/home/runner/work/smrt/smrt/packages/facts/src/fact-subjects.ts",
1807
1704
  "packageName": "@happyvertical/smrt-facts",
1808
1705
  "fields": {},
1809
1706
  "methods": {
@@ -1817,54 +1714,104 @@
1817
1714
  "optional": false
1818
1715
  }
1819
1716
  ],
1820
- "returnType": "Promise<FactSource[]>",
1717
+ "returnType": "Promise<FactSubject[]>",
1821
1718
  "isStatic": false,
1822
1719
  "isPublic": true
1823
1720
  },
1824
- "countForFact": {
1825
- "name": "countForFact",
1721
+ "getForEntity": {
1722
+ "name": "getForEntity",
1723
+ "async": true,
1724
+ "parameters": [
1725
+ {
1726
+ "name": "entityType",
1727
+ "type": "string",
1728
+ "optional": false
1729
+ },
1730
+ {
1731
+ "name": "entityId",
1732
+ "type": "string",
1733
+ "optional": false
1734
+ }
1735
+ ],
1736
+ "returnType": "Promise<FactSubject[]>",
1737
+ "isStatic": false,
1738
+ "isPublic": true
1739
+ },
1740
+ "linkEntity": {
1741
+ "name": "linkEntity",
1826
1742
  "async": true,
1827
1743
  "parameters": [
1828
1744
  {
1829
1745
  "name": "factId",
1830
1746
  "type": "string",
1831
1747
  "optional": false
1748
+ },
1749
+ {
1750
+ "name": "entityType",
1751
+ "type": "string",
1752
+ "optional": false
1753
+ },
1754
+ {
1755
+ "name": "entityId",
1756
+ "type": "string",
1757
+ "optional": false
1758
+ },
1759
+ {
1760
+ "name": "role",
1761
+ "type": "SubjectRole",
1762
+ "optional": true,
1763
+ "default": "subject"
1832
1764
  }
1833
1765
  ],
1834
- "returnType": "Promise<number>",
1766
+ "returnType": "Promise<FactSubject>",
1835
1767
  "isStatic": false,
1836
1768
  "isPublic": true
1837
1769
  },
1838
- "getByType": {
1839
- "name": "getByType",
1770
+ "unlinkEntity": {
1771
+ "name": "unlinkEntity",
1840
1772
  "async": true,
1841
1773
  "parameters": [
1842
1774
  {
1843
- "name": "sourceType",
1775
+ "name": "factId",
1776
+ "type": "string",
1777
+ "optional": false
1778
+ },
1779
+ {
1780
+ "name": "entityType",
1781
+ "type": "string",
1782
+ "optional": false
1783
+ },
1784
+ {
1785
+ "name": "entityId",
1844
1786
  "type": "string",
1845
1787
  "optional": false
1846
1788
  }
1847
1789
  ],
1848
- "returnType": "Promise<FactSource[]>",
1790
+ "returnType": "Promise<void>",
1849
1791
  "isStatic": false,
1850
1792
  "isPublic": true
1851
1793
  },
1852
- "getHighCredibility": {
1853
- "name": "getHighCredibility",
1794
+ "getByRole": {
1795
+ "name": "getByRole",
1854
1796
  "async": true,
1855
1797
  "parameters": [
1856
1798
  {
1857
- "name": "minCredibility",
1858
- "type": "number",
1859
- "optional": true
1799
+ "name": "factId",
1800
+ "type": "string",
1801
+ "optional": false
1802
+ },
1803
+ {
1804
+ "name": "role",
1805
+ "type": "SubjectRole",
1806
+ "optional": false
1860
1807
  }
1861
1808
  ],
1862
- "returnType": "Promise<FactSource[]>",
1809
+ "returnType": "Promise<FactSubject[]>",
1863
1810
  "isStatic": false,
1864
1811
  "isPublic": true
1865
1812
  },
1866
- "getAverageCredibility": {
1867
- "name": "getAverageCredibility",
1813
+ "countForFact": {
1814
+ "name": "countForFact",
1868
1815
  "async": true,
1869
1816
  "parameters": [
1870
1817
  {
@@ -1887,7 +1834,7 @@
1887
1834
  "optional": false
1888
1835
  }
1889
1836
  ],
1890
- "returnType": "Promise<FactSource[]>",
1837
+ "returnType": "Promise<FactSubject[]>",
1891
1838
  "isStatic": false,
1892
1839
  "isPublic": true
1893
1840
  },
@@ -1895,7 +1842,7 @@
1895
1842
  "name": "findGlobal",
1896
1843
  "async": true,
1897
1844
  "parameters": [],
1898
- "returnType": "Promise<FactSource[]>",
1845
+ "returnType": "Promise<FactSubject[]>",
1899
1846
  "isStatic": false,
1900
1847
  "isPublic": true
1901
1848
  },
@@ -1909,19 +1856,19 @@
1909
1856
  "optional": false
1910
1857
  }
1911
1858
  ],
1912
- "returnType": "Promise<FactSource[]>",
1859
+ "returnType": "Promise<FactSubject[]>",
1913
1860
  "isStatic": false,
1914
1861
  "isPublic": true
1915
1862
  }
1916
1863
  },
1917
1864
  "decoratorConfig": {},
1918
1865
  "extends": "SmrtCollection",
1919
- "extendsTypeArg": "FactSource",
1920
- "exportName": "FactSourceCollection",
1921
- "collectionExportName": "FactSourceCollectionCollection",
1866
+ "extendsTypeArg": "FactSubject",
1867
+ "exportName": "FactSubjectCollection",
1868
+ "collectionExportName": "FactSubjectCollectionCollection",
1922
1869
  "schema": {
1923
- "tableName": "fact_source_collections",
1924
- "ddl": "CREATE TABLE IF NOT EXISTS \"fact_source_collections\" (\n \"id\" UUID PRIMARY KEY NOT NULL,\n \"slug\" TEXT NOT NULL,\n \"context\" TEXT NOT NULL DEFAULT '',\n \"created_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"updated_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp\n);",
1870
+ "tableName": "fact_subject_collections",
1871
+ "ddl": "CREATE TABLE IF NOT EXISTS \"fact_subject_collections\" (\n \"id\" UUID PRIMARY KEY NOT NULL,\n \"slug\" TEXT NOT NULL,\n \"context\" TEXT NOT NULL DEFAULT '',\n \"created_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"updated_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp\n);",
1925
1872
  "columns": {
1926
1873
  "id": {
1927
1874
  "type": "UUID",
@@ -1951,7 +1898,7 @@
1951
1898
  },
1952
1899
  "indexes": [
1953
1900
  {
1954
- "name": "fact_source_collections_slug_context_idx",
1901
+ "name": "fact_subject_collections_slug_context_idx",
1955
1902
  "columns": [
1956
1903
  "slug",
1957
1904
  "context"
@@ -1959,21 +1906,21 @@
1959
1906
  "unique": true
1960
1907
  },
1961
1908
  {
1962
- "name": "fact_source_collections_created_at_idx",
1909
+ "name": "fact_subject_collections_created_at_idx",
1963
1910
  "columns": [
1964
1911
  "created_at"
1965
1912
  ]
1966
1913
  }
1967
1914
  ],
1968
- "version": "36f4adef"
1915
+ "version": "0ce73db4"
1969
1916
  }
1970
1917
  },
1971
- "@happyvertical/smrt-facts:FactSubject": {
1972
- "name": "factsubject",
1973
- "className": "FactSubject",
1974
- "qualifiedName": "@happyvertical/smrt-facts:FactSubject",
1975
- "collection": "factsubjects",
1976
- "filePath": "/home/runner/work/smrt/smrt/packages/facts/src/fact-subject.ts",
1918
+ "@happyvertical/smrt-facts:FactTag": {
1919
+ "name": "facttag",
1920
+ "className": "FactTag",
1921
+ "qualifiedName": "@happyvertical/smrt-facts:FactTag",
1922
+ "collection": "facttags",
1923
+ "filePath": "/home/runner/work/smrt/smrt/packages/facts/src/fact-tag.ts",
1977
1924
  "packageName": "@happyvertical/smrt-facts",
1978
1925
  "fields": {
1979
1926
  "factId": {
@@ -1984,15 +1931,7 @@
1984
1931
  "required": true
1985
1932
  }
1986
1933
  },
1987
- "entityType": {
1988
- "type": "text",
1989
- "required": true,
1990
- "default": "",
1991
- "_meta": {
1992
- "required": true
1993
- }
1994
- },
1995
- "entityId": {
1934
+ "tagSlug": {
1996
1935
  "type": "text",
1997
1936
  "required": true,
1998
1937
  "default": "",
@@ -2000,11 +1939,6 @@
2000
1939
  "required": true
2001
1940
  }
2002
1941
  },
2003
- "role": {
2004
- "type": "text",
2005
- "required": false,
2006
- "default": "subject"
2007
- },
2008
1942
  "metadata": {
2009
1943
  "type": "text",
2010
1944
  "required": false,
@@ -2038,14 +1972,6 @@
2038
1972
  }
2039
1973
  },
2040
1974
  "methods": {
2041
- "getRole": {
2042
- "name": "getRole",
2043
- "async": false,
2044
- "parameters": [],
2045
- "returnType": "SubjectRole",
2046
- "isStatic": false,
2047
- "isPublic": true
2048
- },
2049
1975
  "getMetadata": {
2050
1976
  "name": "getMetadata",
2051
1977
  "async": false,
@@ -2094,8 +2020,7 @@
2094
2020
  "decoratorConfig": {
2095
2021
  "conflictColumns": [
2096
2022
  "fact_id",
2097
- "entity_type",
2098
- "entity_id"
2023
+ "tag_slug"
2099
2024
  ],
2100
2025
  "api": {
2101
2026
  "include": [
@@ -2118,8 +2043,8 @@
2118
2043
  }
2119
2044
  },
2120
2045
  "extends": "SmrtObject",
2121
- "exportName": "FactSubject",
2122
- "collectionExportName": "FactSubjectCollection",
2046
+ "exportName": "FactTag",
2047
+ "collectionExportName": "FactTagCollection",
2123
2048
  "validationRules": [
2124
2049
  {
2125
2050
  "field": "factId",
@@ -2127,19 +2052,14 @@
2127
2052
  "fieldType": "foreignKey"
2128
2053
  },
2129
2054
  {
2130
- "field": "entityType",
2131
- "rule": "required",
2132
- "fieldType": "text"
2133
- },
2134
- {
2135
- "field": "entityId",
2055
+ "field": "tagSlug",
2136
2056
  "rule": "required",
2137
2057
  "fieldType": "text"
2138
2058
  }
2139
2059
  ],
2140
2060
  "schema": {
2141
- "tableName": "fact_subjects",
2142
- "ddl": "CREATE TABLE IF NOT EXISTS \"fact_subjects\" (\n \"id\" UUID PRIMARY KEY NOT NULL,\n \"slug\" TEXT NOT NULL,\n \"context\" TEXT NOT NULL DEFAULT '',\n \"created_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"updated_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"fact_id\" UUID NOT NULL,\n \"entity_type\" TEXT NOT NULL DEFAULT '',\n \"entity_id\" TEXT NOT NULL DEFAULT '',\n \"role\" TEXT DEFAULT 'subject',\n \"metadata\" TEXT DEFAULT '',\n \"tenant_id\" UUID\n);",
2061
+ "tableName": "fact_tags",
2062
+ "ddl": "CREATE TABLE IF NOT EXISTS \"fact_tags\" (\n \"id\" UUID PRIMARY KEY NOT NULL,\n \"slug\" TEXT NOT NULL,\n \"context\" TEXT NOT NULL DEFAULT '',\n \"created_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"updated_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"fact_id\" UUID NOT NULL,\n \"tag_slug\" TEXT NOT NULL DEFAULT '',\n \"metadata\" TEXT DEFAULT '',\n \"tenant_id\" UUID\n);",
2143
2063
  "columns": {
2144
2064
  "id": {
2145
2065
  "type": "UUID",
@@ -2178,24 +2098,12 @@
2178
2098
  "onUpdate": "CASCADE"
2179
2099
  }
2180
2100
  },
2181
- "entity_type": {
2182
- "type": "TEXT",
2183
- "notNull": true,
2184
- "unique": false,
2185
- "default": ""
2186
- },
2187
- "entity_id": {
2101
+ "tag_slug": {
2188
2102
  "type": "TEXT",
2189
2103
  "notNull": true,
2190
2104
  "unique": false,
2191
2105
  "default": ""
2192
2106
  },
2193
- "role": {
2194
- "type": "TEXT",
2195
- "notNull": false,
2196
- "unique": false,
2197
- "default": "subject"
2198
- },
2199
2107
  "metadata": {
2200
2108
  "type": "TEXT",
2201
2109
  "notNull": false,
@@ -2211,1306 +2119,314 @@
2211
2119
  },
2212
2120
  "indexes": [
2213
2121
  {
2214
- "name": "fact_subjects_fact_id_entity_type_idx",
2122
+ "name": "fact_tags_fact_id_tag_slug_idx",
2215
2123
  "columns": [
2216
2124
  "fact_id",
2217
- "entity_type",
2218
- "entity_id"
2125
+ "tag_slug"
2219
2126
  ],
2220
2127
  "unique": true
2221
2128
  },
2222
2129
  {
2223
- "name": "fact_subjects_slug_context_idx",
2130
+ "name": "fact_tags_slug_context_idx",
2224
2131
  "columns": [
2225
2132
  "slug",
2226
2133
  "context"
2227
2134
  ]
2228
2135
  },
2229
2136
  {
2230
- "name": "fact_subjects_tenant_id_created_at_idx",
2137
+ "name": "fact_tags_tenant_id_created_at_idx",
2231
2138
  "columns": [
2232
2139
  "tenant_id",
2233
2140
  "created_at"
2234
2141
  ]
2235
2142
  }
2236
2143
  ],
2237
- "version": "cb6eca71"
2144
+ "version": "79df8b59"
2238
2145
  }
2239
2146
  },
2240
- "@happyvertical/smrt-facts:FactSubjectCollection": {
2241
- "name": "factsubjectcollection",
2242
- "className": "FactSubjectCollection",
2243
- "qualifiedName": "@happyvertical/smrt-facts:FactSubjectCollection",
2244
- "collection": "factsubjects",
2245
- "filePath": "/home/runner/work/smrt/smrt/packages/facts/src/fact-subjects.ts",
2246
- "packageName": "@happyvertical/smrt-facts",
2247
- "fields": {},
2248
- "methods": {
2249
- "getForFact": {
2250
- "name": "getForFact",
2251
- "async": true,
2252
- "parameters": [
2253
- {
2254
- "name": "factId",
2255
- "type": "string",
2256
- "optional": false
2257
- }
2258
- ],
2259
- "returnType": "Promise<FactSubject[]>",
2260
- "isStatic": false,
2261
- "isPublic": true
2262
- },
2263
- "getForEntity": {
2264
- "name": "getForEntity",
2265
- "async": true,
2266
- "parameters": [
2267
- {
2268
- "name": "entityType",
2269
- "type": "string",
2270
- "optional": false
2271
- },
2272
- {
2273
- "name": "entityId",
2274
- "type": "string",
2275
- "optional": false
2276
- }
2277
- ],
2278
- "returnType": "Promise<FactSubject[]>",
2279
- "isStatic": false,
2280
- "isPublic": true
2281
- },
2282
- "linkEntity": {
2283
- "name": "linkEntity",
2284
- "async": true,
2285
- "parameters": [
2286
- {
2287
- "name": "factId",
2288
- "type": "string",
2289
- "optional": false
2290
- },
2291
- {
2292
- "name": "entityType",
2293
- "type": "string",
2294
- "optional": false
2295
- },
2296
- {
2297
- "name": "entityId",
2298
- "type": "string",
2299
- "optional": false
2300
- },
2301
- {
2302
- "name": "role",
2303
- "type": "SubjectRole",
2304
- "optional": true,
2305
- "default": "subject"
2306
- }
2307
- ],
2308
- "returnType": "Promise<FactSubject>",
2309
- "isStatic": false,
2310
- "isPublic": true
2311
- },
2312
- "unlinkEntity": {
2313
- "name": "unlinkEntity",
2314
- "async": true,
2315
- "parameters": [
2316
- {
2317
- "name": "factId",
2318
- "type": "string",
2319
- "optional": false
2320
- },
2321
- {
2322
- "name": "entityType",
2323
- "type": "string",
2324
- "optional": false
2325
- },
2326
- {
2327
- "name": "entityId",
2328
- "type": "string",
2329
- "optional": false
2330
- }
2331
- ],
2332
- "returnType": "Promise<void>",
2333
- "isStatic": false,
2334
- "isPublic": true
2335
- },
2336
- "getByRole": {
2337
- "name": "getByRole",
2338
- "async": true,
2339
- "parameters": [
2340
- {
2341
- "name": "factId",
2342
- "type": "string",
2343
- "optional": false
2344
- },
2345
- {
2346
- "name": "role",
2347
- "type": "SubjectRole",
2348
- "optional": false
2349
- }
2350
- ],
2351
- "returnType": "Promise<FactSubject[]>",
2352
- "isStatic": false,
2353
- "isPublic": true
2354
- },
2355
- "countForFact": {
2356
- "name": "countForFact",
2357
- "async": true,
2358
- "parameters": [
2359
- {
2360
- "name": "factId",
2361
- "type": "string",
2362
- "optional": false
2363
- }
2364
- ],
2365
- "returnType": "Promise<number>",
2366
- "isStatic": false,
2367
- "isPublic": true
2368
- },
2369
- "findByTenant": {
2370
- "name": "findByTenant",
2371
- "async": true,
2372
- "parameters": [
2373
- {
2374
- "name": "tenantId",
2375
- "type": "string",
2376
- "optional": false
2377
- }
2378
- ],
2379
- "returnType": "Promise<FactSubject[]>",
2380
- "isStatic": false,
2381
- "isPublic": true
2382
- },
2383
- "findGlobal": {
2384
- "name": "findGlobal",
2385
- "async": true,
2386
- "parameters": [],
2387
- "returnType": "Promise<FactSubject[]>",
2388
- "isStatic": false,
2389
- "isPublic": true
2390
- },
2391
- "findWithGlobals": {
2392
- "name": "findWithGlobals",
2393
- "async": true,
2394
- "parameters": [
2395
- {
2396
- "name": "tenantId",
2397
- "type": "string",
2398
- "optional": false
2399
- }
2400
- ],
2401
- "returnType": "Promise<FactSubject[]>",
2402
- "isStatic": false,
2403
- "isPublic": true
2404
- }
2405
- },
2406
- "decoratorConfig": {},
2407
- "extends": "SmrtCollection",
2408
- "extendsTypeArg": "FactSubject",
2409
- "exportName": "FactSubjectCollection",
2410
- "collectionExportName": "FactSubjectCollectionCollection",
2411
- "schema": {
2412
- "tableName": "fact_subject_collections",
2413
- "ddl": "CREATE TABLE IF NOT EXISTS \"fact_subject_collections\" (\n \"id\" UUID PRIMARY KEY NOT NULL,\n \"slug\" TEXT NOT NULL,\n \"context\" TEXT NOT NULL DEFAULT '',\n \"created_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"updated_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp\n);",
2414
- "columns": {
2415
- "id": {
2416
- "type": "UUID",
2417
- "primaryKey": true,
2418
- "referenceKind": "id",
2419
- "notNull": true
2420
- },
2421
- "slug": {
2422
- "type": "TEXT",
2423
- "notNull": true
2424
- },
2425
- "context": {
2426
- "type": "TEXT",
2427
- "notNull": true,
2428
- "default": ""
2429
- },
2430
- "created_at": {
2431
- "type": "TIMESTAMP",
2432
- "notNull": true,
2433
- "default": "current_timestamp"
2434
- },
2435
- "updated_at": {
2436
- "type": "TIMESTAMP",
2437
- "notNull": true,
2438
- "default": "current_timestamp"
2439
- }
2440
- },
2441
- "indexes": [
2442
- {
2443
- "name": "fact_subject_collections_slug_context_idx",
2444
- "columns": [
2445
- "slug",
2446
- "context"
2447
- ],
2448
- "unique": true
2449
- },
2450
- {
2451
- "name": "fact_subject_collections_created_at_idx",
2452
- "columns": [
2453
- "created_at"
2454
- ]
2455
- }
2456
- ],
2457
- "version": "0ce73db4"
2458
- }
2459
- },
2460
- "@happyvertical/smrt-facts:FactTag": {
2461
- "name": "facttag",
2462
- "className": "FactTag",
2463
- "qualifiedName": "@happyvertical/smrt-facts:FactTag",
2464
- "collection": "facttags",
2465
- "filePath": "/home/runner/work/smrt/smrt/packages/facts/src/fact-tag.ts",
2466
- "packageName": "@happyvertical/smrt-facts",
2467
- "fields": {
2468
- "factId": {
2469
- "type": "foreignKey",
2470
- "required": true,
2471
- "related": "Fact",
2472
- "_meta": {
2473
- "required": true
2474
- }
2475
- },
2476
- "tagSlug": {
2477
- "type": "text",
2478
- "required": true,
2479
- "default": "",
2480
- "_meta": {
2481
- "required": true
2482
- }
2483
- },
2484
- "metadata": {
2485
- "type": "text",
2486
- "required": false,
2487
- "default": ""
2488
- },
2489
- "tenantId": {
2490
- "type": "text",
2491
- "required": false,
2492
- "_meta": {
2493
- "sqlType": "UUID",
2494
- "nullable": true,
2495
- "__tenancy": {
2496
- "isTenantIdField": true,
2497
- "autoFilter": true,
2498
- "required": false,
2499
- "autoPopulate": true,
2500
- "nullable": true,
2501
- "mode": "optional",
2502
- "field": "tenantId",
2503
- "allowSuperAdminBypass": false
2504
- }
2505
- }
2506
- },
2507
- "createdAt": {
2508
- "type": "datetime",
2509
- "required": false
2510
- },
2511
- "updatedAt": {
2512
- "type": "datetime",
2513
- "required": false
2514
- }
2515
- },
2516
- "methods": {
2517
- "getMetadata": {
2518
- "name": "getMetadata",
2519
- "async": false,
2520
- "parameters": [],
2521
- "returnType": "Record<string>",
2522
- "isStatic": false,
2523
- "isPublic": true
2524
- },
2525
- "setMetadata": {
2526
- "name": "setMetadata",
2527
- "async": false,
2528
- "parameters": [
2529
- {
2530
- "name": "data",
2531
- "type": "Record<string>",
2532
- "optional": false
2533
- }
2534
- ],
2535
- "returnType": "void",
2536
- "isStatic": false,
2537
- "isPublic": true
2538
- },
2539
- "updateMetadata": {
2540
- "name": "updateMetadata",
2541
- "async": false,
2542
- "parameters": [
2543
- {
2544
- "name": "updates",
2545
- "type": "Record<string>",
2546
- "optional": false
2547
- }
2548
- ],
2549
- "returnType": "void",
2550
- "isStatic": false,
2551
- "isPublic": true
2552
- },
2553
- "getFact": {
2554
- "name": "getFact",
2555
- "async": true,
2556
- "parameters": [],
2557
- "returnType": "Promise<null>",
2558
- "isStatic": false,
2559
- "isPublic": true
2560
- }
2561
- },
2562
- "decoratorConfig": {
2563
- "conflictColumns": [
2564
- "fact_id",
2565
- "tag_slug"
2566
- ],
2567
- "api": {
2568
- "include": [
2569
- "list",
2570
- "get",
2571
- "create",
2572
- "delete"
2573
- ]
2574
- },
2575
- "mcp": {
2576
- "include": [
2577
- "list",
2578
- "get",
2579
- "create"
2580
- ]
2581
- },
2582
- "cli": true,
2583
- "tenantScoped": {
2584
- "mode": "optional"
2585
- }
2586
- },
2587
- "extends": "SmrtObject",
2588
- "exportName": "FactTag",
2589
- "collectionExportName": "FactTagCollection",
2590
- "validationRules": [
2591
- {
2592
- "field": "factId",
2593
- "rule": "required",
2594
- "fieldType": "foreignKey"
2595
- },
2596
- {
2597
- "field": "tagSlug",
2598
- "rule": "required",
2599
- "fieldType": "text"
2600
- }
2601
- ],
2602
- "schema": {
2603
- "tableName": "fact_tags",
2604
- "ddl": "CREATE TABLE IF NOT EXISTS \"fact_tags\" (\n \"id\" UUID PRIMARY KEY NOT NULL,\n \"slug\" TEXT NOT NULL,\n \"context\" TEXT NOT NULL DEFAULT '',\n \"created_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"updated_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"fact_id\" UUID NOT NULL,\n \"tag_slug\" TEXT NOT NULL DEFAULT '',\n \"metadata\" TEXT DEFAULT '',\n \"tenant_id\" UUID\n);",
2605
- "columns": {
2606
- "id": {
2607
- "type": "UUID",
2608
- "primaryKey": true,
2609
- "referenceKind": "id",
2610
- "notNull": true
2611
- },
2612
- "slug": {
2613
- "type": "TEXT",
2614
- "notNull": true
2615
- },
2616
- "context": {
2617
- "type": "TEXT",
2618
- "notNull": true,
2619
- "default": ""
2620
- },
2621
- "created_at": {
2622
- "type": "TIMESTAMP",
2623
- "notNull": true,
2624
- "default": "current_timestamp"
2625
- },
2626
- "updated_at": {
2627
- "type": "TIMESTAMP",
2628
- "notNull": true,
2629
- "default": "current_timestamp"
2630
- },
2631
- "fact_id": {
2632
- "type": "UUID",
2633
- "referenceKind": "foreignKey",
2634
- "notNull": true,
2635
- "unique": false,
2636
- "foreignKey": {
2637
- "table": "facts",
2638
- "column": "id",
2639
- "onDelete": "CASCADE",
2640
- "onUpdate": "CASCADE"
2641
- }
2642
- },
2643
- "tag_slug": {
2644
- "type": "TEXT",
2645
- "notNull": true,
2646
- "unique": false,
2647
- "default": ""
2648
- },
2649
- "metadata": {
2650
- "type": "TEXT",
2651
- "notNull": false,
2652
- "unique": false,
2653
- "default": ""
2654
- },
2655
- "tenant_id": {
2656
- "type": "UUID",
2657
- "referenceKind": "tenantId",
2658
- "notNull": false,
2659
- "unique": false
2660
- }
2661
- },
2662
- "indexes": [
2663
- {
2664
- "name": "fact_tags_fact_id_tag_slug_idx",
2665
- "columns": [
2666
- "fact_id",
2667
- "tag_slug"
2668
- ],
2669
- "unique": true
2670
- },
2671
- {
2672
- "name": "fact_tags_slug_context_idx",
2673
- "columns": [
2674
- "slug",
2675
- "context"
2676
- ]
2677
- },
2678
- {
2679
- "name": "fact_tags_tenant_id_created_at_idx",
2680
- "columns": [
2681
- "tenant_id",
2682
- "created_at"
2683
- ]
2684
- }
2685
- ],
2686
- "version": "79df8b59"
2687
- }
2688
- },
2689
- "@happyvertical/smrt-facts:FactTagCollection": {
2690
- "name": "facttagcollection",
2691
- "className": "FactTagCollection",
2692
- "qualifiedName": "@happyvertical/smrt-facts:FactTagCollection",
2147
+ "@happyvertical/smrt-facts:FactTagCollection": {
2148
+ "name": "facttagcollection",
2149
+ "className": "FactTagCollection",
2150
+ "qualifiedName": "@happyvertical/smrt-facts:FactTagCollection",
2693
2151
  "collection": "facttags",
2694
2152
  "filePath": "/home/runner/work/smrt/smrt/packages/facts/src/fact-tags.ts",
2695
- "packageName": "@happyvertical/smrt-facts",
2696
- "fields": {},
2697
- "methods": {
2698
- "getForFact": {
2699
- "name": "getForFact",
2700
- "async": true,
2701
- "parameters": [
2702
- {
2703
- "name": "factId",
2704
- "type": "string",
2705
- "optional": false
2706
- }
2707
- ],
2708
- "returnType": "Promise<FactTag[]>",
2709
- "isStatic": false,
2710
- "isPublic": true
2711
- },
2712
- "getForTag": {
2713
- "name": "getForTag",
2714
- "async": true,
2715
- "parameters": [
2716
- {
2717
- "name": "tagSlug",
2718
- "type": "string",
2719
- "optional": false
2720
- }
2721
- ],
2722
- "returnType": "Promise<FactTag[]>",
2723
- "isStatic": false,
2724
- "isPublic": true
2725
- },
2726
- "addTag": {
2727
- "name": "addTag",
2728
- "async": true,
2729
- "parameters": [
2730
- {
2731
- "name": "factId",
2732
- "type": "string",
2733
- "optional": false
2734
- },
2735
- {
2736
- "name": "tagSlug",
2737
- "type": "string",
2738
- "optional": false
2739
- }
2740
- ],
2741
- "returnType": "Promise<FactTag>",
2742
- "isStatic": false,
2743
- "isPublic": true
2744
- },
2745
- "removeTag": {
2746
- "name": "removeTag",
2747
- "async": true,
2748
- "parameters": [
2749
- {
2750
- "name": "factId",
2751
- "type": "string",
2752
- "optional": false
2753
- },
2754
- {
2755
- "name": "tagSlug",
2756
- "type": "string",
2757
- "optional": false
2758
- }
2759
- ],
2760
- "returnType": "Promise<void>",
2761
- "isStatic": false,
2762
- "isPublic": true
2763
- },
2764
- "getTagSlugs": {
2765
- "name": "getTagSlugs",
2766
- "async": true,
2767
- "parameters": [
2768
- {
2769
- "name": "factId",
2770
- "type": "string",
2771
- "optional": false
2772
- }
2773
- ],
2774
- "returnType": "Promise<string[]>",
2775
- "isStatic": false,
2776
- "isPublic": true
2777
- },
2778
- "findByTenant": {
2779
- "name": "findByTenant",
2780
- "async": true,
2781
- "parameters": [
2782
- {
2783
- "name": "tenantId",
2784
- "type": "string",
2785
- "optional": false
2786
- }
2787
- ],
2788
- "returnType": "Promise<FactTag[]>",
2789
- "isStatic": false,
2790
- "isPublic": true
2791
- },
2792
- "findGlobal": {
2793
- "name": "findGlobal",
2794
- "async": true,
2795
- "parameters": [],
2796
- "returnType": "Promise<FactTag[]>",
2797
- "isStatic": false,
2798
- "isPublic": true
2799
- },
2800
- "findWithGlobals": {
2801
- "name": "findWithGlobals",
2802
- "async": true,
2803
- "parameters": [
2804
- {
2805
- "name": "tenantId",
2806
- "type": "string",
2807
- "optional": false
2808
- }
2809
- ],
2810
- "returnType": "Promise<FactTag[]>",
2811
- "isStatic": false,
2812
- "isPublic": true
2813
- }
2814
- },
2815
- "decoratorConfig": {},
2816
- "extends": "SmrtCollection",
2817
- "extendsTypeArg": "FactTag",
2818
- "exportName": "FactTagCollection",
2819
- "collectionExportName": "FactTagCollectionCollection",
2820
- "schema": {
2821
- "tableName": "fact_tag_collections",
2822
- "ddl": "CREATE TABLE IF NOT EXISTS \"fact_tag_collections\" (\n \"id\" UUID PRIMARY KEY NOT NULL,\n \"slug\" TEXT NOT NULL,\n \"context\" TEXT NOT NULL DEFAULT '',\n \"created_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"updated_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp\n);",
2823
- "columns": {
2824
- "id": {
2825
- "type": "UUID",
2826
- "primaryKey": true,
2827
- "referenceKind": "id",
2828
- "notNull": true
2829
- },
2830
- "slug": {
2831
- "type": "TEXT",
2832
- "notNull": true
2833
- },
2834
- "context": {
2835
- "type": "TEXT",
2836
- "notNull": true,
2837
- "default": ""
2838
- },
2839
- "created_at": {
2840
- "type": "TIMESTAMP",
2841
- "notNull": true,
2842
- "default": "current_timestamp"
2843
- },
2844
- "updated_at": {
2845
- "type": "TIMESTAMP",
2846
- "notNull": true,
2847
- "default": "current_timestamp"
2848
- }
2849
- },
2850
- "indexes": [
2851
- {
2852
- "name": "fact_tag_collections_slug_context_idx",
2853
- "columns": [
2854
- "slug",
2855
- "context"
2856
- ],
2857
- "unique": true
2858
- },
2859
- {
2860
- "name": "fact_tag_collections_created_at_idx",
2861
- "columns": [
2862
- "created_at"
2863
- ]
2864
- }
2865
- ],
2866
- "version": "4bac3c1d"
2867
- }
2868
- },
2869
- "@happyvertical/smrt-facts:Fact": {
2870
- "name": "fact",
2871
- "className": "Fact",
2872
- "qualifiedName": "@happyvertical/smrt-facts:Fact",
2873
- "collection": "facts",
2874
- "filePath": "/home/runner/work/smrt/smrt/packages/facts/src/fact.ts",
2875
- "packageName": "@happyvertical/smrt-facts",
2876
- "fields": {
2877
- "created_at": {
2878
- "type": "datetime",
2879
- "required": false
2880
- },
2881
- "updated_at": {
2882
- "type": "datetime",
2883
- "required": false
2884
- },
2885
- "textRefined": {
2886
- "type": "text",
2887
- "required": true,
2888
- "default": "",
2889
- "_meta": {
2890
- "required": true
2891
- }
2892
- },
2893
- "textRaw": {
2894
- "type": "text",
2895
- "required": false,
2896
- "default": ""
2897
- },
2898
- "type": {
2899
- "type": "text",
2900
- "required": true,
2901
- "default": "assertion",
2902
- "_meta": {
2903
- "required": true
2904
- }
2905
- },
2906
- "status": {
2907
- "type": "text",
2908
- "required": true,
2909
- "default": "pending",
2910
- "_meta": {
2911
- "required": true
2912
- }
2913
- },
2914
- "domain": {
2915
- "type": "text",
2916
- "required": false,
2917
- "default": ""
2918
- },
2919
- "previousFactId": {
2920
- "type": "foreignKey",
2921
- "required": false,
2922
- "related": "Fact"
2923
- },
2924
- "evolutionType": {
2925
- "type": "text",
2926
- "required": false,
2927
- "default": "original"
2928
- },
2929
- "sourceCount": {
2930
- "type": "integer",
2931
- "required": false,
2932
- "default": 0
2933
- },
2934
- "confidence": {
2935
- "type": "decimal",
2936
- "required": false,
2937
- "default": 0
2938
- },
2939
- "metadata": {
2940
- "type": "text",
2941
- "required": false,
2942
- "default": ""
2943
- },
2944
- "tenantId": {
2945
- "type": "text",
2946
- "required": false,
2947
- "_meta": {
2948
- "sqlType": "UUID",
2949
- "nullable": true,
2950
- "__tenancy": {
2951
- "isTenantIdField": true,
2952
- "autoFilter": true,
2953
- "required": false,
2954
- "autoPopulate": true,
2955
- "nullable": true,
2956
- "mode": "optional",
2957
- "field": "tenantId",
2958
- "allowSuperAdminBypass": false
2959
- }
2960
- }
2961
- },
2962
- "createdAt": {
2963
- "type": "datetime",
2964
- "required": false
2965
- },
2966
- "updatedAt": {
2967
- "type": "datetime",
2968
- "required": false
2969
- }
2970
- },
2971
- "methods": {
2972
- "withDatabase": {
2973
- "name": "withDatabase",
2974
- "async": true,
2975
- "parameters": [
2976
- {
2977
- "name": "db",
2978
- "type": "DatabaseInterface",
2979
- "optional": false
2980
- },
2981
- {
2982
- "name": "operation",
2983
- "type": "Function",
2984
- "optional": false
2985
- }
2986
- ],
2987
- "returnType": "Promise<T>",
2988
- "isStatic": false,
2989
- "isPublic": true
2990
- },
2991
- "getAiUsageSnapshot": {
2992
- "name": "getAiUsageSnapshot",
2993
- "async": false,
2994
- "parameters": [],
2995
- "returnType": "AiUsageSnapshot | undefined",
2996
- "isStatic": false,
2997
- "isPublic": true
2998
- },
2999
- "resetAiUsage": {
3000
- "name": "resetAiUsage",
3001
- "async": false,
3002
- "parameters": [],
3003
- "returnType": "void",
3004
- "isStatic": false,
3005
- "isPublic": true
3006
- },
3007
- "listAiUsage": {
3008
- "name": "listAiUsage",
3009
- "async": true,
3010
- "parameters": [
3011
- {
3012
- "name": "options",
3013
- "type": "AiUsageListOptions",
3014
- "optional": true
3015
- }
3016
- ],
3017
- "returnType": "Promise<SmrtAiUsageRecord[]>",
3018
- "isStatic": false,
3019
- "isPublic": true
3020
- },
3021
- "summarizeAiUsage": {
3022
- "name": "summarizeAiUsage",
3023
- "async": true,
3024
- "parameters": [
3025
- {
3026
- "name": "options",
3027
- "type": "AiUsageSummaryOptions",
3028
- "optional": true
3029
- }
3030
- ],
3031
- "returnType": "Promise<Record<string, AiUsageStats>>",
3032
- "isStatic": false,
3033
- "isPublic": true
3034
- },
3035
- "destroy": {
3036
- "name": "destroy",
3037
- "async": false,
3038
- "parameters": [],
3039
- "returnType": "void",
3040
- "isStatic": false,
3041
- "isPublic": true
3042
- },
3043
- "markAsPersisted": {
3044
- "name": "markAsPersisted",
3045
- "async": false,
3046
- "parameters": [],
3047
- "returnType": "void",
3048
- "isStatic": false,
3049
- "isPublic": true
3050
- },
3051
- "requireInsertOnSave": {
3052
- "name": "requireInsertOnSave",
3053
- "async": false,
3054
- "parameters": [],
3055
- "returnType": "void",
3056
- "isStatic": false,
3057
- "isPublic": true
3058
- },
3059
- "withTransaction": {
3060
- "name": "withTransaction",
3061
- "async": true,
3062
- "parameters": [
3063
- {
3064
- "name": "operation",
3065
- "type": "Function",
3066
- "optional": false
3067
- }
3068
- ],
3069
- "returnType": "Promise<T>",
3070
- "isStatic": false,
3071
- "isPublic": true
3072
- },
3073
- "initialize": {
3074
- "name": "initialize",
3075
- "async": true,
3076
- "parameters": [],
3077
- "returnType": "Promise",
3078
- "isStatic": false,
3079
- "isPublic": true
3080
- },
3081
- "loadDataFromDb": {
3082
- "name": "loadDataFromDb",
3083
- "async": true,
3084
- "parameters": [
3085
- {
3086
- "name": "data",
3087
- "type": "Record<string>",
3088
- "optional": false
3089
- }
3090
- ],
3091
- "returnType": "any",
3092
- "isStatic": false,
3093
- "isPublic": true
3094
- },
3095
- "getFields": {
3096
- "name": "getFields",
3097
- "async": true,
3098
- "parameters": [],
3099
- "returnType": "Promise<any>",
3100
- "isStatic": false,
3101
- "isPublic": true
3102
- },
3103
- "toJSON": {
3104
- "name": "toJSON",
3105
- "async": false,
3106
- "parameters": [],
3107
- "returnType": "any",
3108
- "isStatic": false,
3109
- "isPublic": true
3110
- },
3111
- "toPlainObject": {
3112
- "name": "toPlainObject",
3113
- "async": false,
3114
- "parameters": [],
3115
- "returnType": "Record<string>",
3116
- "isStatic": false,
3117
- "isPublic": true
3118
- },
3119
- "toPublicJSON": {
3120
- "name": "toPublicJSON",
3121
- "async": false,
3122
- "parameters": [
3123
- {
3124
- "name": "options",
3125
- "type": "PublicJsonOptions",
3126
- "optional": true
3127
- }
3128
- ],
3129
- "returnType": "Record<string>",
3130
- "isStatic": false,
3131
- "isPublic": true
3132
- },
3133
- "getId": {
3134
- "name": "getId",
3135
- "async": true,
3136
- "parameters": [],
3137
- "returnType": "any",
3138
- "isStatic": false,
3139
- "isPublic": true
3140
- },
3141
- "getSlug": {
3142
- "name": "getSlug",
3143
- "async": true,
3144
- "parameters": [],
3145
- "returnType": "any",
3146
- "isStatic": false,
3147
- "isPublic": true
3148
- },
3149
- "getSavedId": {
3150
- "name": "getSavedId",
3151
- "async": true,
3152
- "parameters": [],
3153
- "returnType": "any",
3154
- "isStatic": false,
3155
- "isPublic": true
3156
- },
3157
- "isSaved": {
3158
- "name": "isSaved",
3159
- "async": true,
3160
- "parameters": [],
3161
- "returnType": "any",
3162
- "isStatic": false,
3163
- "isPublic": true
3164
- },
3165
- "save": {
3166
- "name": "save",
3167
- "async": true,
3168
- "parameters": [
3169
- {
3170
- "name": "options",
3171
- "type": "SmrtSaveOptions",
3172
- "optional": true
3173
- }
3174
- ],
3175
- "returnType": "any",
3176
- "isStatic": false,
3177
- "isPublic": true
3178
- },
3179
- "claimRevision": {
3180
- "name": "claimRevision",
3181
- "async": true,
3182
- "parameters": [
3183
- {
3184
- "name": "expectedUpdatedAt",
3185
- "type": "Date | string",
3186
- "optional": false
3187
- }
3188
- ],
3189
- "returnType": "Promise",
3190
- "isStatic": false,
3191
- "isPublic": true
3192
- },
3193
- "classifyConstraintError": {
3194
- "name": "classifyConstraintError",
3195
- "async": false,
3196
- "parameters": [
3197
- {
3198
- "name": "message",
3199
- "type": "string",
3200
- "optional": false
3201
- }
3202
- ],
3203
- "returnType": "'unique' | 'not_null' | null",
3204
- "isStatic": true,
3205
- "isPublic": true
3206
- },
3207
- "loadFromId": {
3208
- "name": "loadFromId",
3209
- "async": true,
3210
- "parameters": [],
3211
- "returnType": "any",
3212
- "isStatic": false,
3213
- "isPublic": true
3214
- },
3215
- "loadFromSlug": {
3216
- "name": "loadFromSlug",
3217
- "async": true,
3218
- "parameters": [],
3219
- "returnType": "any",
3220
- "isStatic": false,
3221
- "isPublic": true
3222
- },
3223
- "is": {
3224
- "name": "is",
3225
- "async": true,
3226
- "parameters": [
3227
- {
3228
- "name": "criteria",
3229
- "type": "string",
3230
- "optional": false
3231
- },
3232
- {
3233
- "name": "options",
3234
- "type": "AiOperationOptions",
3235
- "optional": true
3236
- }
3237
- ],
3238
- "returnType": "any",
3239
- "isStatic": false,
3240
- "isPublic": true
3241
- },
3242
- "do": {
3243
- "name": "do",
3244
- "async": true,
3245
- "parameters": [
3246
- {
3247
- "name": "instructions",
3248
- "type": "string",
3249
- "optional": false
3250
- },
3251
- {
3252
- "name": "options",
3253
- "type": "AiOperationOptions",
3254
- "optional": true
3255
- }
3256
- ],
3257
- "returnType": "any",
3258
- "isStatic": false,
3259
- "isPublic": true
3260
- },
3261
- "describe": {
3262
- "name": "describe",
3263
- "async": true,
3264
- "parameters": [
3265
- {
3266
- "name": "options",
3267
- "type": "AiOperationOptions",
3268
- "optional": true
3269
- }
3270
- ],
3271
- "returnType": "any",
3272
- "isStatic": false,
3273
- "isPublic": true
3274
- },
3275
- "delete": {
3276
- "name": "delete",
3277
- "async": true,
3278
- "parameters": [],
3279
- "returnType": "Promise<void>",
3280
- "isStatic": false,
3281
- "isPublic": true
3282
- },
3283
- "isRelatedLoaded": {
3284
- "name": "isRelatedLoaded",
3285
- "async": false,
3286
- "parameters": [
3287
- {
3288
- "name": "fieldName",
3289
- "type": "string",
3290
- "optional": false
3291
- }
3292
- ],
3293
- "returnType": "boolean",
3294
- "isStatic": false,
3295
- "isPublic": true
3296
- },
3297
- "_setLoadedRelationship": {
3298
- "name": "_setLoadedRelationship",
3299
- "async": false,
3300
- "parameters": [
3301
- {
3302
- "name": "fieldName",
3303
- "type": "string",
3304
- "optional": false
3305
- },
3306
- {
3307
- "name": "value",
3308
- "type": "any",
3309
- "optional": false
3310
- }
3311
- ],
3312
- "returnType": "void",
3313
- "isStatic": false,
3314
- "isPublic": true
3315
- },
3316
- "loadRelated": {
3317
- "name": "loadRelated",
3318
- "async": true,
3319
- "parameters": [
3320
- {
3321
- "name": "fieldName",
3322
- "type": "string",
3323
- "optional": false
3324
- },
3325
- {
3326
- "name": "opts",
3327
- "type": "LoadRelatedOptions",
3328
- "optional": true
3329
- }
3330
- ],
3331
- "returnType": "Promise<any>",
3332
- "isStatic": false,
3333
- "isPublic": true
3334
- },
3335
- "loadRelatedMany": {
3336
- "name": "loadRelatedMany",
3337
- "async": true,
3338
- "parameters": [
3339
- {
3340
- "name": "fieldName",
3341
- "type": "string",
3342
- "optional": false
3343
- },
3344
- {
3345
- "name": "opts",
3346
- "type": "LoadRelatedOptions",
3347
- "optional": true
3348
- }
3349
- ],
3350
- "returnType": "Promise<any[]>",
3351
- "isStatic": false,
3352
- "isPublic": true
3353
- },
3354
- "getRelated": {
3355
- "name": "getRelated",
2153
+ "packageName": "@happyvertical/smrt-facts",
2154
+ "fields": {},
2155
+ "methods": {
2156
+ "getForFact": {
2157
+ "name": "getForFact",
3356
2158
  "async": true,
3357
2159
  "parameters": [
3358
2160
  {
3359
- "name": "fieldName",
2161
+ "name": "factId",
3360
2162
  "type": "string",
3361
2163
  "optional": false
3362
- },
3363
- {
3364
- "name": "opts",
3365
- "type": "LoadRelatedOptions",
3366
- "optional": true
3367
2164
  }
3368
2165
  ],
3369
- "returnType": "Promise<any>",
3370
- "isStatic": false,
3371
- "isPublic": true
3372
- },
3373
- "getAvailableTools": {
3374
- "name": "getAvailableTools",
3375
- "async": false,
3376
- "parameters": [],
3377
- "returnType": "AITool[]",
2166
+ "returnType": "Promise<FactTag[]>",
3378
2167
  "isStatic": false,
3379
2168
  "isPublic": true
3380
2169
  },
3381
- "executeToolCall": {
3382
- "name": "executeToolCall",
2170
+ "getForTag": {
2171
+ "name": "getForTag",
3383
2172
  "async": true,
3384
2173
  "parameters": [
3385
2174
  {
3386
- "name": "toolCall",
3387
- "type": "ToolCall",
2175
+ "name": "tagSlug",
2176
+ "type": "string",
3388
2177
  "optional": false
3389
2178
  }
3390
2179
  ],
3391
- "returnType": "Promise<ToolCallResult>",
2180
+ "returnType": "Promise<FactTag[]>",
3392
2181
  "isStatic": false,
3393
2182
  "isPublic": true
3394
2183
  },
3395
- "remember": {
3396
- "name": "remember",
2184
+ "addTag": {
2185
+ "name": "addTag",
3397
2186
  "async": true,
3398
2187
  "parameters": [
3399
2188
  {
3400
- "name": "options",
3401
- "type": "object",
2189
+ "name": "factId",
2190
+ "type": "string",
3402
2191
  "optional": false
3403
- }
3404
- ],
3405
- "returnType": "Promise<void>",
3406
- "isStatic": false,
3407
- "isPublic": true
3408
- },
3409
- "recall": {
3410
- "name": "recall",
3411
- "async": true,
3412
- "parameters": [
2192
+ },
3413
2193
  {
3414
- "name": "options",
3415
- "type": "object",
2194
+ "name": "tagSlug",
2195
+ "type": "string",
3416
2196
  "optional": false
3417
2197
  }
3418
2198
  ],
3419
- "returnType": "Promise",
2199
+ "returnType": "Promise<FactTag>",
3420
2200
  "isStatic": false,
3421
2201
  "isPublic": true
3422
2202
  },
3423
- "recallAll": {
3424
- "name": "recallAll",
2203
+ "removeTag": {
2204
+ "name": "removeTag",
3425
2205
  "async": true,
3426
2206
  "parameters": [
3427
2207
  {
3428
- "name": "options",
3429
- "type": "object",
3430
- "optional": true
2208
+ "name": "factId",
2209
+ "type": "string",
2210
+ "optional": false
2211
+ },
2212
+ {
2213
+ "name": "tagSlug",
2214
+ "type": "string",
2215
+ "optional": false
3431
2216
  }
3432
2217
  ],
3433
- "returnType": "Promise<Map<string>>",
2218
+ "returnType": "Promise<void>",
3434
2219
  "isStatic": false,
3435
2220
  "isPublic": true
3436
2221
  },
3437
- "forget": {
3438
- "name": "forget",
2222
+ "getTagSlugs": {
2223
+ "name": "getTagSlugs",
3439
2224
  "async": true,
3440
2225
  "parameters": [
3441
2226
  {
3442
- "name": "options",
3443
- "type": "object",
2227
+ "name": "factId",
2228
+ "type": "string",
3444
2229
  "optional": false
3445
2230
  }
3446
2231
  ],
3447
- "returnType": "Promise<void>",
2232
+ "returnType": "Promise<string[]>",
3448
2233
  "isStatic": false,
3449
2234
  "isPublic": true
3450
2235
  },
3451
- "forgetScope": {
3452
- "name": "forgetScope",
2236
+ "findByTenant": {
2237
+ "name": "findByTenant",
3453
2238
  "async": true,
3454
2239
  "parameters": [
3455
2240
  {
3456
- "name": "options",
3457
- "type": "object",
2241
+ "name": "tenantId",
2242
+ "type": "string",
3458
2243
  "optional": false
3459
2244
  }
3460
2245
  ],
3461
- "returnType": "Promise<number>",
2246
+ "returnType": "Promise<FactTag[]>",
3462
2247
  "isStatic": false,
3463
2248
  "isPublic": true
3464
2249
  },
3465
- "generateEmbeddings": {
3466
- "name": "generateEmbeddings",
2250
+ "findGlobal": {
2251
+ "name": "findGlobal",
3467
2252
  "async": true,
3468
- "parameters": [
3469
- {
3470
- "name": "options",
3471
- "type": "GenerateEmbeddingsOptions",
3472
- "optional": true
3473
- }
3474
- ],
3475
- "returnType": "Promise<void>",
2253
+ "parameters": [],
2254
+ "returnType": "Promise<FactTag[]>",
3476
2255
  "isStatic": false,
3477
2256
  "isPublic": true
3478
2257
  },
3479
- "getEmbedding": {
3480
- "name": "getEmbedding",
2258
+ "findWithGlobals": {
2259
+ "name": "findWithGlobals",
3481
2260
  "async": true,
3482
2261
  "parameters": [
3483
2262
  {
3484
- "name": "fieldName",
2263
+ "name": "tenantId",
3485
2264
  "type": "string",
3486
2265
  "optional": false
3487
- },
3488
- {
3489
- "name": "model",
3490
- "type": "string",
3491
- "optional": true
3492
2266
  }
3493
2267
  ],
3494
- "returnType": "Promise<number[] | null>",
2268
+ "returnType": "Promise<FactTag[]>",
3495
2269
  "isStatic": false,
3496
2270
  "isPublic": true
2271
+ }
2272
+ },
2273
+ "decoratorConfig": {},
2274
+ "extends": "SmrtCollection",
2275
+ "extendsTypeArg": "FactTag",
2276
+ "exportName": "FactTagCollection",
2277
+ "collectionExportName": "FactTagCollectionCollection",
2278
+ "schema": {
2279
+ "tableName": "fact_tag_collections",
2280
+ "ddl": "CREATE TABLE IF NOT EXISTS \"fact_tag_collections\" (\n \"id\" UUID PRIMARY KEY NOT NULL,\n \"slug\" TEXT NOT NULL,\n \"context\" TEXT NOT NULL DEFAULT '',\n \"created_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"updated_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp\n);",
2281
+ "columns": {
2282
+ "id": {
2283
+ "type": "UUID",
2284
+ "primaryKey": true,
2285
+ "referenceKind": "id",
2286
+ "notNull": true
2287
+ },
2288
+ "slug": {
2289
+ "type": "TEXT",
2290
+ "notNull": true
2291
+ },
2292
+ "context": {
2293
+ "type": "TEXT",
2294
+ "notNull": true,
2295
+ "default": ""
2296
+ },
2297
+ "created_at": {
2298
+ "type": "TIMESTAMP",
2299
+ "notNull": true,
2300
+ "default": "current_timestamp"
2301
+ },
2302
+ "updated_at": {
2303
+ "type": "TIMESTAMP",
2304
+ "notNull": true,
2305
+ "default": "current_timestamp"
2306
+ }
3497
2307
  },
3498
- "hasStaleEmbeddings": {
3499
- "name": "hasStaleEmbeddings",
3500
- "async": true,
3501
- "parameters": [],
3502
- "returnType": "Promise<boolean>",
3503
- "isStatic": false,
3504
- "isPublic": true
2308
+ "indexes": [
2309
+ {
2310
+ "name": "fact_tag_collections_slug_context_idx",
2311
+ "columns": [
2312
+ "slug",
2313
+ "context"
2314
+ ],
2315
+ "unique": true
2316
+ },
2317
+ {
2318
+ "name": "fact_tag_collections_created_at_idx",
2319
+ "columns": [
2320
+ "created_at"
2321
+ ]
2322
+ }
2323
+ ],
2324
+ "version": "4bac3c1d"
2325
+ }
2326
+ },
2327
+ "@happyvertical/smrt-facts:Fact": {
2328
+ "name": "fact",
2329
+ "className": "Fact",
2330
+ "qualifiedName": "@happyvertical/smrt-facts:Fact",
2331
+ "collection": "facts",
2332
+ "filePath": "/home/runner/work/smrt/smrt/packages/facts/src/fact.ts",
2333
+ "packageName": "@happyvertical/smrt-facts",
2334
+ "fields": {
2335
+ "created_at": {
2336
+ "type": "datetime",
2337
+ "required": false
3505
2338
  },
3506
- "clearEmbeddings": {
3507
- "name": "clearEmbeddings",
3508
- "async": true,
3509
- "parameters": [],
3510
- "returnType": "Promise<void>",
3511
- "isStatic": false,
3512
- "isPublic": true
2339
+ "updated_at": {
2340
+ "type": "datetime",
2341
+ "required": false
2342
+ },
2343
+ "textRefined": {
2344
+ "type": "text",
2345
+ "required": true,
2346
+ "default": "",
2347
+ "_meta": {
2348
+ "required": true
2349
+ }
2350
+ },
2351
+ "textRaw": {
2352
+ "type": "text",
2353
+ "required": false,
2354
+ "default": ""
2355
+ },
2356
+ "type": {
2357
+ "type": "text",
2358
+ "required": true,
2359
+ "default": "assertion",
2360
+ "_meta": {
2361
+ "required": true
2362
+ }
2363
+ },
2364
+ "status": {
2365
+ "type": "text",
2366
+ "required": true,
2367
+ "default": "pending",
2368
+ "_meta": {
2369
+ "required": true
2370
+ }
2371
+ },
2372
+ "domain": {
2373
+ "type": "text",
2374
+ "required": false,
2375
+ "default": ""
2376
+ },
2377
+ "previousFactId": {
2378
+ "type": "foreignKey",
2379
+ "required": false,
2380
+ "related": "Fact"
2381
+ },
2382
+ "evolutionType": {
2383
+ "type": "text",
2384
+ "required": false,
2385
+ "default": "original"
2386
+ },
2387
+ "sourceCount": {
2388
+ "type": "integer",
2389
+ "required": false,
2390
+ "default": 0
2391
+ },
2392
+ "confidence": {
2393
+ "type": "decimal",
2394
+ "required": false,
2395
+ "default": 0
2396
+ },
2397
+ "metadata": {
2398
+ "type": "text",
2399
+ "required": false,
2400
+ "default": ""
2401
+ },
2402
+ "tenantId": {
2403
+ "type": "text",
2404
+ "required": false,
2405
+ "_meta": {
2406
+ "sqlType": "UUID",
2407
+ "nullable": true,
2408
+ "__tenancy": {
2409
+ "isTenantIdField": true,
2410
+ "autoFilter": true,
2411
+ "required": false,
2412
+ "autoPopulate": true,
2413
+ "nullable": true,
2414
+ "mode": "optional",
2415
+ "field": "tenantId",
2416
+ "allowSuperAdminBypass": false
2417
+ }
2418
+ }
2419
+ },
2420
+ "createdAt": {
2421
+ "type": "datetime",
2422
+ "required": false
3513
2423
  },
2424
+ "updatedAt": {
2425
+ "type": "datetime",
2426
+ "required": false
2427
+ }
2428
+ },
2429
+ "methods": {
3514
2430
  "getMetadata": {
3515
2431
  "name": "getMetadata",
3516
2432
  "async": false,