aimeat 1.4.7 → 1.5.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.
- package/dist/locales/en.json +62 -4
- package/dist/locales/fi.json +62 -4
- package/dist/public/css/views/profile.css +37 -0
- package/dist/public/js/services/admin.js +6 -0
- package/dist/public/js/services/boards.js +6 -3
- package/dist/public/js/services/memory.js +10 -0
- package/dist/public/views/admin/federation-tab.js +93 -7
- package/dist/public/views/admin/ghii-tab.js +2 -0
- package/dist/public/views/admin.js +5 -9
- package/dist/public/views/profile/access-tab.js +160 -58
- package/dist/public/views/profile/agents-tab.js +13 -1
- package/dist/public/views/profile/boards-tab.js +12 -0
- package/dist/public/views/profile/data-wallet-tab.js +29 -2
- package/dist/public/views/profile/knowledge-tab.js +64 -2
- package/dist/public/views/profile/landing-page.js +9 -6
- package/dist/public/views/profile/memory-tab.js +92 -4
- package/dist/src/auth/jwt.d.ts +6 -0
- package/dist/src/auth/jwt.d.ts.map +1 -1
- package/dist/src/auth/jwt.js +6 -0
- package/dist/src/auth/jwt.js.map +1 -1
- package/dist/src/auth/middleware.d.ts +7 -0
- package/dist/src/auth/middleware.d.ts.map +1 -1
- package/dist/src/auth/middleware.js +20 -0
- package/dist/src/auth/middleware.js.map +1 -1
- package/dist/src/middleware/federation-proxy.d.ts +35 -0
- package/dist/src/middleware/federation-proxy.d.ts.map +1 -0
- package/dist/src/middleware/federation-proxy.js +92 -0
- package/dist/src/middleware/federation-proxy.js.map +1 -0
- package/dist/src/routes/actions.d.ts.map +1 -1
- package/dist/src/routes/actions.js +7 -2
- package/dist/src/routes/actions.js.map +1 -1
- package/dist/src/routes/admin-agents.d.ts.map +1 -1
- package/dist/src/routes/admin-agents.js +1 -0
- package/dist/src/routes/admin-agents.js.map +1 -1
- package/dist/src/routes/admin-features.d.ts.map +1 -1
- package/dist/src/routes/admin-features.js +2 -0
- package/dist/src/routes/admin-features.js.map +1 -1
- package/dist/src/routes/admin-monitoring.d.ts.map +1 -1
- package/dist/src/routes/admin-monitoring.js +12 -1
- package/dist/src/routes/admin-monitoring.js.map +1 -1
- package/dist/src/routes/admin.d.ts.map +1 -1
- package/dist/src/routes/admin.js +16 -0
- package/dist/src/routes/admin.js.map +1 -1
- package/dist/src/routes/agents.d.ts.map +1 -1
- package/dist/src/routes/agents.js +36 -3
- package/dist/src/routes/agents.js.map +1 -1
- package/dist/src/routes/boards.d.ts.map +1 -1
- package/dist/src/routes/boards.js +12 -5
- package/dist/src/routes/boards.js.map +1 -1
- package/dist/src/routes/federation-auth.d.ts +15 -0
- package/dist/src/routes/federation-auth.d.ts.map +1 -0
- package/dist/src/routes/federation-auth.js +182 -0
- package/dist/src/routes/federation-auth.js.map +1 -0
- package/dist/src/routes/federation-genesis.d.ts +2 -1
- package/dist/src/routes/federation-genesis.d.ts.map +1 -1
- package/dist/src/routes/federation-genesis.js +58 -2
- package/dist/src/routes/federation-genesis.js.map +1 -1
- package/dist/src/routes/federation-peer.d.ts.map +1 -1
- package/dist/src/routes/federation-peer.js +124 -15
- package/dist/src/routes/federation-peer.js.map +1 -1
- package/dist/src/routes/federation-sync.d.ts.map +1 -1
- package/dist/src/routes/federation-sync.js +14 -1
- package/dist/src/routes/federation-sync.js.map +1 -1
- package/dist/src/routes/federation.d.ts +2 -1
- package/dist/src/routes/federation.d.ts.map +1 -1
- package/dist/src/routes/federation.js +4 -2
- package/dist/src/routes/federation.js.map +1 -1
- package/dist/src/routes/ghii.d.ts +2 -1
- package/dist/src/routes/ghii.d.ts.map +1 -1
- package/dist/src/routes/ghii.js +88 -4
- package/dist/src/routes/ghii.js.map +1 -1
- package/dist/src/routes/libs.js +49 -7
- package/dist/src/routes/libs.js.map +1 -1
- package/dist/src/routes/memory.d.ts.map +1 -1
- package/dist/src/routes/memory.js +162 -0
- package/dist/src/routes/memory.js.map +1 -1
- package/dist/src/routes/owners.d.ts.map +1 -1
- package/dist/src/routes/owners.js +1 -0
- package/dist/src/routes/owners.js.map +1 -1
- package/dist/src/server-bootstrap/routes-loader.d.ts +2 -0
- package/dist/src/server-bootstrap/routes-loader.d.ts.map +1 -1
- package/dist/src/server-bootstrap/routes-loader.js +7 -4
- package/dist/src/server-bootstrap/routes-loader.js.map +1 -1
- package/dist/src/server-bootstrap/service-init.d.ts +2 -0
- package/dist/src/server-bootstrap/service-init.d.ts.map +1 -1
- package/dist/src/server-bootstrap/service-init.js +28 -1
- package/dist/src/server-bootstrap/service-init.js.map +1 -1
- package/dist/src/server.d.ts.map +1 -1
- package/dist/src/server.js +1 -0
- package/dist/src/server.js.map +1 -1
- package/dist/src/services/federation-helpers.d.ts.map +1 -1
- package/dist/src/services/federation-helpers.js +1 -0
- package/dist/src/services/federation-helpers.js.map +1 -1
- package/dist/src/services/federation.d.ts +6 -6
- package/dist/src/services/federation.d.ts.map +1 -1
- package/dist/src/services/federation.js +57 -1
- package/dist/src/services/federation.js.map +1 -1
- package/dist/src/services/memory-replication.d.ts.map +1 -1
- package/dist/src/services/memory-replication.js +3 -0
- package/dist/src/services/memory-replication.js.map +1 -1
- package/dist/src/storage/interface.d.ts +17 -1
- package/dist/src/storage/interface.d.ts.map +1 -1
- package/dist/src/storage/providers/mongodb/index.d.ts +6 -3
- package/dist/src/storage/providers/mongodb/index.d.ts.map +1 -1
- package/dist/src/storage/providers/mongodb/index.js +109 -48
- package/dist/src/storage/providers/mongodb/index.js.map +1 -1
- package/dist/src/storage/providers/sqlite/index.d.ts +6 -2
- package/dist/src/storage/providers/sqlite/index.d.ts.map +1 -1
- package/dist/src/storage/providers/sqlite/index.js +58 -16
- package/dist/src/storage/providers/sqlite/index.js.map +1 -1
- package/dist/src/storage/providers/sqlite/repos/action.d.ts.map +1 -1
- package/dist/src/storage/providers/sqlite/repos/action.js +5 -4
- package/dist/src/storage/providers/sqlite/repos/action.js.map +1 -1
- package/dist/src/storage/providers/sqlite/repos/agent.d.ts.map +1 -1
- package/dist/src/storage/providers/sqlite/repos/agent.js +5 -4
- package/dist/src/storage/providers/sqlite/repos/agent.js.map +1 -1
- package/dist/src/storage/providers/sqlite/repos/board.d.ts.map +1 -1
- package/dist/src/storage/providers/sqlite/repos/board.js +3 -2
- package/dist/src/storage/providers/sqlite/repos/board.js.map +1 -1
- package/dist/src/storage/providers/sqlite/repos/storage-file.d.ts.map +1 -1
- package/dist/src/storage/providers/sqlite/repos/storage-file.js +4 -2
- package/dist/src/storage/providers/sqlite/repos/storage-file.js.map +1 -1
- package/dist/src/storage/providers/sqlite/schema.d.ts.map +1 -1
- package/dist/src/storage/providers/sqlite/schema.js +20 -0
- package/dist/src/storage/providers/sqlite/schema.js.map +1 -1
- package/dist/src/storage/repositories/board.repository.d.ts +1 -1
- package/dist/src/storage/repositories/board.repository.d.ts.map +1 -1
- package/dist/src/storage/repositories/federation.repository.d.ts +5 -1
- package/dist/src/storage/repositories/federation.repository.d.ts.map +1 -1
- package/dist/src/utils/service-summary.d.ts +65 -0
- package/dist/src/utils/service-summary.d.ts.map +1 -0
- package/dist/src/utils/service-summary.js +100 -0
- package/dist/src/utils/service-summary.js.map +1 -0
- package/package.json +3 -1
- package/prisma/schema.prisma +33 -0
|
@@ -122,6 +122,7 @@ export class MongoStorage {
|
|
|
122
122
|
morselBalance: agent.morselBalance,
|
|
123
123
|
allowedOrigins: agent.allowedOrigins ?? [],
|
|
124
124
|
defaultScopes: agent.defaultScopes ?? ['*'],
|
|
125
|
+
federate: agent.federate ?? false,
|
|
125
126
|
createdAt: new Date(agent.createdAt),
|
|
126
127
|
lastSeen: new Date(agent.lastSeen),
|
|
127
128
|
},
|
|
@@ -531,6 +532,7 @@ export class MongoStorage {
|
|
|
531
532
|
tags: action.tags,
|
|
532
533
|
webhookUrl: action.webhookUrl ?? null,
|
|
533
534
|
semantic: action.semantic ?? null,
|
|
535
|
+
federate: action.federate ?? false,
|
|
534
536
|
createdAt: new Date(action.createdAt),
|
|
535
537
|
updatedAt: new Date(action.updatedAt),
|
|
536
538
|
},
|
|
@@ -731,6 +733,7 @@ export class MongoStorage {
|
|
|
731
733
|
visibility: board.visibility,
|
|
732
734
|
ownerGaii: board.ownerGaii,
|
|
733
735
|
allowedGaiis: board.allowedGaiis,
|
|
736
|
+
federate: board.federate ?? false,
|
|
734
737
|
createdAt: new Date(board.createdAt),
|
|
735
738
|
},
|
|
736
739
|
});
|
|
@@ -751,10 +754,13 @@ export class MongoStorage {
|
|
|
751
754
|
const rows = await this.prisma.board.findMany({ where });
|
|
752
755
|
return rows.map((r) => this.toBoardRecord(r));
|
|
753
756
|
}
|
|
754
|
-
async updateBoardVisibility(id, visibility) {
|
|
757
|
+
async updateBoardVisibility(id, visibility, federate) {
|
|
755
758
|
this.ensureReady();
|
|
756
759
|
try {
|
|
757
|
-
const
|
|
760
|
+
const data = { visibility };
|
|
761
|
+
if (federate !== undefined)
|
|
762
|
+
data.federate = federate;
|
|
763
|
+
const row = await this.prisma.board.update({ where: { boardId: id }, data });
|
|
758
764
|
return this.toBoardRecord(row);
|
|
759
765
|
}
|
|
760
766
|
catch {
|
|
@@ -1143,6 +1149,7 @@ export class MongoStorage {
|
|
|
1143
1149
|
size: file.size,
|
|
1144
1150
|
data: file.data,
|
|
1145
1151
|
tags: file.tags || [],
|
|
1152
|
+
federate: file.federate ?? false,
|
|
1146
1153
|
createdAt: new Date(file.createdAt),
|
|
1147
1154
|
},
|
|
1148
1155
|
});
|
|
@@ -1155,16 +1162,16 @@ export class MongoStorage {
|
|
|
1155
1162
|
});
|
|
1156
1163
|
if (!row)
|
|
1157
1164
|
return null;
|
|
1158
|
-
return { key: row.key, ownerGaii: row.ownerGaii, visibility: row.visibility, mimeType: row.mimeType, size: row.size, data: Buffer.from(row.data), tags: row.tags || [], createdAt: row.createdAt.toISOString() };
|
|
1165
|
+
return { key: row.key, ownerGaii: row.ownerGaii, visibility: row.visibility, mimeType: row.mimeType, size: row.size, data: Buffer.from(row.data), tags: row.tags || [], federate: row.federate ?? false, createdAt: row.createdAt.toISOString() };
|
|
1159
1166
|
}
|
|
1160
1167
|
async listStorageFiles(ownerGaii) {
|
|
1161
1168
|
this.ensureReady();
|
|
1162
1169
|
const rows = await this.prisma.storageFile.findMany({
|
|
1163
1170
|
where: { ownerGaii },
|
|
1164
|
-
select: { key: true, ownerGaii: true, visibility: true, mimeType: true, size: true, tags: true, createdAt: true },
|
|
1171
|
+
select: { key: true, ownerGaii: true, visibility: true, mimeType: true, size: true, tags: true, federate: true, createdAt: true },
|
|
1165
1172
|
});
|
|
1166
1173
|
return rows.map((r) => ({
|
|
1167
|
-
key: r.key, ownerGaii: r.ownerGaii, visibility: r.visibility, mimeType: r.mimeType, size: r.size, data: Buffer.alloc(0), tags: r.tags || [], createdAt: r.createdAt.toISOString(),
|
|
1174
|
+
key: r.key, ownerGaii: r.ownerGaii, visibility: r.visibility, mimeType: r.mimeType, size: r.size, data: Buffer.alloc(0), tags: r.tags || [], federate: r.federate ?? false, createdAt: r.createdAt.toISOString(),
|
|
1168
1175
|
}));
|
|
1169
1176
|
}
|
|
1170
1177
|
async deleteStorageFile(ownerGaii, key) {
|
|
@@ -1244,6 +1251,16 @@ export class MongoStorage {
|
|
|
1244
1251
|
return null;
|
|
1245
1252
|
}
|
|
1246
1253
|
}
|
|
1254
|
+
async deletePeeringRequest(id) {
|
|
1255
|
+
this.ensureReady();
|
|
1256
|
+
try {
|
|
1257
|
+
await this.prisma.peeringRequest.delete({ where: { requestId: id } });
|
|
1258
|
+
return true;
|
|
1259
|
+
}
|
|
1260
|
+
catch {
|
|
1261
|
+
return false;
|
|
1262
|
+
}
|
|
1263
|
+
}
|
|
1247
1264
|
// ── Chunked Uploads (kept in-memory — transient) ───────────
|
|
1248
1265
|
async createChunkedUpload(record) {
|
|
1249
1266
|
this.chunkedUploads.set(record.uploadId, record);
|
|
@@ -1283,19 +1300,19 @@ export class MongoStorage {
|
|
|
1283
1300
|
return { name: row.name, displayName: row.displayName ?? undefined, publicKey: row.publicKey, roles: row.roles, createdAt: row.createdAt.toISOString() };
|
|
1284
1301
|
}
|
|
1285
1302
|
toAgentRecord(row) {
|
|
1286
|
-
return { name: row.name, owner: row.owner, gaii: row.gaii, displayName: row.displayName ?? undefined, description: row.description ?? undefined, capabilities: row.capabilities, publicKey: row.publicKey, trustScore: row.trustScore, morselBalance: row.morselBalance, defaultScopes: row.defaultScopes?.length ? row.defaultScopes : undefined, allowedOrigins: row.allowedOrigins?.length ? row.allowedOrigins : undefined, createdAt: row.createdAt.toISOString(), lastSeen: row.lastSeen.toISOString() };
|
|
1303
|
+
return { name: row.name, owner: row.owner, gaii: row.gaii, displayName: row.displayName ?? undefined, description: row.description ?? undefined, capabilities: row.capabilities, publicKey: row.publicKey, trustScore: row.trustScore, morselBalance: row.morselBalance, defaultScopes: row.defaultScopes?.length ? row.defaultScopes : undefined, allowedOrigins: row.allowedOrigins?.length ? row.allowedOrigins : undefined, federate: row.federate ?? false, createdAt: row.createdAt.toISOString(), lastSeen: row.lastSeen.toISOString() };
|
|
1287
1304
|
}
|
|
1288
1305
|
toMemoryRecord(row) {
|
|
1289
1306
|
return { key: row.key, ownerGaii: row.ownerGaii, value: row.value, visibility: row.visibility, tags: row.tags, ttlHours: row.ttlHours, version: row.version, createdAt: row.createdAt.toISOString(), updatedAt: row.updatedAt.toISOString(), flagCount: row.flagCount ?? undefined, allowedOrigins: row.allowedOrigins?.length ? row.allowedOrigins : undefined };
|
|
1290
1307
|
}
|
|
1291
1308
|
toActionRecord(row) {
|
|
1292
|
-
return { id: row.actionId, providerGaii: row.providerGaii, displayName: row.displayName, description: row.description, category: row.category ?? undefined, inputSchema: row.inputSchema, outputSchema: row.outputSchema, pricing: { baseMorsels: row.pricingBaseMorsels, perUnit: row.pricingPerUnit }, estimatedTimeSeconds: row.estimatedTimeSeconds ?? undefined, maxInputSizeBytes: row.maxInputSizeBytes ?? undefined, tags: row.tags, webhookUrl: row.webhookUrl ?? undefined, semantic: row.semantic ?? undefined, createdAt: row.createdAt.toISOString(), updatedAt: row.updatedAt.toISOString() };
|
|
1309
|
+
return { id: row.actionId, providerGaii: row.providerGaii, displayName: row.displayName, description: row.description, category: row.category ?? undefined, inputSchema: row.inputSchema, outputSchema: row.outputSchema, pricing: { baseMorsels: row.pricingBaseMorsels, perUnit: row.pricingPerUnit }, estimatedTimeSeconds: row.estimatedTimeSeconds ?? undefined, maxInputSizeBytes: row.maxInputSizeBytes ?? undefined, tags: row.tags, webhookUrl: row.webhookUrl ?? undefined, semantic: row.semantic ?? undefined, federate: row.federate ?? false, createdAt: row.createdAt.toISOString(), updatedAt: row.updatedAt.toISOString() };
|
|
1293
1310
|
}
|
|
1294
1311
|
toWorkRecord(row) {
|
|
1295
1312
|
return { trackingCode: row.trackingCode, status: row.status, actionId: row.actionId, providerGaii: row.providerGaii, requesterGaii: row.requesterGaii, input: row.input, output: row.output, cost: { basePrice: row.costBasePrice, networkFee: row.costNetworkFee, total: row.costTotal, inEscrow: row.costInEscrow }, ttlExpiresAt: row.ttlExpiresAt.toISOString(), callbackUrl: row.callbackUrl ?? undefined, rating: row.ratingScore != null ? { score: row.ratingScore, comment: row.ratingComment ?? undefined } : undefined, createdAt: row.createdAt.toISOString(), updatedAt: row.updatedAt.toISOString() };
|
|
1296
1313
|
}
|
|
1297
1314
|
toBoardRecord(row) {
|
|
1298
|
-
return { id: row.boardId, name: row.name, description: row.description ?? undefined, visibility: row.visibility, ownerGaii: row.ownerGaii, allowedGaiis: row.allowedGaiis, createdAt: row.createdAt.toISOString() };
|
|
1315
|
+
return { id: row.boardId, name: row.name, description: row.description ?? undefined, visibility: row.visibility, ownerGaii: row.ownerGaii, allowedGaiis: row.allowedGaiis, federate: row.federate ?? false, createdAt: row.createdAt.toISOString() };
|
|
1299
1316
|
}
|
|
1300
1317
|
toPostRecord(row) {
|
|
1301
1318
|
return { id: row.postId, boardId: row.boardId, authorGaii: row.authorGaii, title: row.title, body: row.body, category: row.category ?? undefined, tags: row.tags, ttlExpiresAt: row.ttlExpiresAt?.toISOString(), reactions: row.reactions, replyTo: row.replyTo ?? undefined, createdAt: row.createdAt.toISOString() };
|
|
@@ -3916,62 +3933,106 @@ export class MongoStorage {
|
|
|
3916
3933
|
}
|
|
3917
3934
|
}
|
|
3918
3935
|
// ══════════════════════════════════════════════════════════
|
|
3919
|
-
// ──
|
|
3936
|
+
// ── Federation Peers (persisted active peer connections) ──
|
|
3937
|
+
// ══════════════════════════════════════════════════════════
|
|
3938
|
+
async saveFederationPeer(peer) {
|
|
3939
|
+
this.ensureReady();
|
|
3940
|
+
await this.prisma.federationPeer.upsert({
|
|
3941
|
+
where: { nodeId: peer.nodeId },
|
|
3942
|
+
create: { nodeId: peer.nodeId, url: peer.url, publicKey: peer.publicKey, status: peer.status, addedAt: new Date(peer.addedAt), lastSeen: new Date(peer.lastSeen), shareCatalogue: peer.shareCatalogue, replicateMemory: peer.replicateMemory, allowRouting: peer.allowRouting, peerMode: peer.peerMode || 'federation' },
|
|
3943
|
+
update: { url: peer.url, publicKey: peer.publicKey, status: peer.status, lastSeen: new Date(peer.lastSeen), shareCatalogue: peer.shareCatalogue, replicateMemory: peer.replicateMemory, allowRouting: peer.allowRouting, peerMode: peer.peerMode || 'federation' },
|
|
3944
|
+
});
|
|
3945
|
+
}
|
|
3946
|
+
async listFederationPeers() {
|
|
3947
|
+
this.ensureReady();
|
|
3948
|
+
const rows = await this.prisma.federationPeer.findMany();
|
|
3949
|
+
return rows.map((r) => ({
|
|
3950
|
+
nodeId: r.nodeId,
|
|
3951
|
+
url: r.url,
|
|
3952
|
+
publicKey: r.publicKey,
|
|
3953
|
+
status: r.status,
|
|
3954
|
+
addedAt: r.addedAt instanceof Date ? r.addedAt.toISOString() : r.addedAt,
|
|
3955
|
+
lastSeen: r.lastSeen instanceof Date ? r.lastSeen.toISOString() : r.lastSeen,
|
|
3956
|
+
shareCatalogue: r.shareCatalogue ?? true,
|
|
3957
|
+
replicateMemory: r.replicateMemory ?? true,
|
|
3958
|
+
allowRouting: r.allowRouting ?? true,
|
|
3959
|
+
peerMode: r.peerMode || 'federation',
|
|
3960
|
+
}));
|
|
3961
|
+
}
|
|
3962
|
+
async deleteFederationPeer(nodeId) {
|
|
3963
|
+
this.ensureReady();
|
|
3964
|
+
try {
|
|
3965
|
+
await this.prisma.federationPeer.delete({ where: { nodeId } });
|
|
3966
|
+
return true;
|
|
3967
|
+
}
|
|
3968
|
+
catch {
|
|
3969
|
+
return false;
|
|
3970
|
+
}
|
|
3971
|
+
}
|
|
3972
|
+
// ══════════════════════════════════════════════════════════
|
|
3973
|
+
// ── Replication Queue (B.1) — persisted to MongoDB
|
|
3920
3974
|
// ══════════════════════════════════════════════════════════
|
|
3921
|
-
replicationQueue = new Map();
|
|
3922
3975
|
async enqueueReplication(entry) {
|
|
3976
|
+
this.ensureReady();
|
|
3923
3977
|
const id = randomUUID();
|
|
3924
|
-
|
|
3925
|
-
|
|
3926
|
-
|
|
3927
|
-
|
|
3928
|
-
|
|
3929
|
-
|
|
3930
|
-
|
|
3931
|
-
|
|
3978
|
+
await this.prisma.replicationQueue.create({
|
|
3979
|
+
data: {
|
|
3980
|
+
id,
|
|
3981
|
+
type: entry.type,
|
|
3982
|
+
targetPeers: entry.targetPeers,
|
|
3983
|
+
payload: entry.payload != null ? JSON.stringify(entry.payload) : null,
|
|
3984
|
+
createdAt: new Date(entry.createdAt),
|
|
3985
|
+
attempts: 0,
|
|
3986
|
+
lastAttemptAt: null,
|
|
3987
|
+
status: 'pending',
|
|
3988
|
+
},
|
|
3989
|
+
});
|
|
3932
3990
|
return id;
|
|
3933
3991
|
}
|
|
3934
3992
|
async dequeueReplication(peerId, limit) {
|
|
3935
|
-
|
|
3936
|
-
|
|
3937
|
-
|
|
3938
|
-
|
|
3939
|
-
|
|
3940
|
-
|
|
3941
|
-
|
|
3942
|
-
|
|
3943
|
-
|
|
3944
|
-
|
|
3993
|
+
this.ensureReady();
|
|
3994
|
+
const rows = await this.prisma.replicationQueue.findMany({
|
|
3995
|
+
where: { status: 'pending', targetPeers: { has: peerId } },
|
|
3996
|
+
orderBy: { createdAt: 'asc' },
|
|
3997
|
+
take: limit,
|
|
3998
|
+
});
|
|
3999
|
+
return rows.map((r) => ({
|
|
4000
|
+
id: r.id,
|
|
4001
|
+
type: r.type,
|
|
4002
|
+
targetPeers: r.targetPeers,
|
|
4003
|
+
payload: r.payload ? JSON.parse(r.payload) : null,
|
|
4004
|
+
createdAt: r.createdAt instanceof Date ? r.createdAt.toISOString() : r.createdAt,
|
|
4005
|
+
attempts: r.attempts,
|
|
4006
|
+
lastAttemptAt: r.lastAttemptAt instanceof Date ? r.lastAttemptAt.toISOString() : r.lastAttemptAt,
|
|
4007
|
+
status: r.status,
|
|
4008
|
+
}));
|
|
3945
4009
|
}
|
|
3946
4010
|
async markReplicationSent(ids) {
|
|
3947
|
-
|
|
3948
|
-
|
|
3949
|
-
|
|
3950
|
-
|
|
3951
|
-
}
|
|
4011
|
+
this.ensureReady();
|
|
4012
|
+
await this.prisma.replicationQueue.updateMany({
|
|
4013
|
+
where: { id: { in: ids } },
|
|
4014
|
+
data: { status: 'sent' },
|
|
4015
|
+
});
|
|
3952
4016
|
}
|
|
3953
4017
|
async markReplicationFailed(ids) {
|
|
4018
|
+
this.ensureReady();
|
|
3954
4019
|
for (const id of ids) {
|
|
3955
|
-
|
|
3956
|
-
|
|
3957
|
-
|
|
3958
|
-
|
|
3959
|
-
entry.lastAttemptAt = new Date().toISOString();
|
|
3960
|
-
}
|
|
4020
|
+
await this.prisma.replicationQueue.update({
|
|
4021
|
+
where: { id },
|
|
4022
|
+
data: { status: 'failed', attempts: { increment: 1 }, lastAttemptAt: new Date() },
|
|
4023
|
+
}).catch(() => { });
|
|
3961
4024
|
}
|
|
3962
4025
|
}
|
|
3963
4026
|
async pruneReplicationQueue(maxAge) {
|
|
3964
|
-
|
|
3965
|
-
|
|
3966
|
-
|
|
3967
|
-
|
|
3968
|
-
|
|
3969
|
-
}
|
|
3970
|
-
}
|
|
3971
|
-
return pruned;
|
|
4027
|
+
this.ensureReady();
|
|
4028
|
+
const result = await this.prisma.replicationQueue.deleteMany({
|
|
4029
|
+
where: { OR: [{ createdAt: { lt: maxAge } }, { status: 'sent' }] },
|
|
4030
|
+
});
|
|
4031
|
+
return result.count;
|
|
3972
4032
|
}
|
|
3973
4033
|
async replicationQueueSize() {
|
|
3974
|
-
|
|
4034
|
+
this.ensureReady();
|
|
4035
|
+
return this.prisma.replicationQueue.count();
|
|
3975
4036
|
}
|
|
3976
4037
|
// ── Device Authorization (RFC 8628) ──
|
|
3977
4038
|
async createDeviceAuth(req) {
|