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