diff --git a/composeApp/schemas/to.curare.compose.database.CurareDatabase/21.json b/composeApp/schemas/to.curare.compose.database.CurareDatabase/21.json
index eedf85cf..c5d05cff 100644
--- a/composeApp/schemas/to.curare.compose.database.CurareDatabase/21.json
+++ b/composeApp/schemas/to.curare.compose.database.CurareDatabase/21.json
@@ -2,7 +2,7 @@
"formatVersion": 1,
"database": {
"version": 21,
- "identityHash": "3aae084382314d5c6c8e7e729cbc8aab",
+ "identityHash": "eb81f06bb966326e318f3b4feb291bc6",
"entities": [
{
"tableName": "BroadcastNostrEventReceipt",
@@ -1184,7 +1184,7 @@
},
{
"tableName": "FrostSigningSession",
- "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `chatRoomId` TEXT NOT NULL, `coordinatorPublicKey` TEXT NOT NULL, `userPublicKey` TEXT NOT NULL, `dkgSessionId` TEXT NOT NULL, `threshold` INTEGER NOT NULL, `participantCount` INTEGER NOT NULL, `signerId` INTEGER NOT NULL, `derivationPath` TEXT, `stage` TEXT NOT NULL, `signerIds` TEXT, `failureReason` TEXT, `signApprovedAt` INTEGER, `approvalRequestedAt` INTEGER, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, `savedAt` INTEGER NOT NULL, PRIMARY KEY(`id`), FOREIGN KEY(`chatRoomId`) REFERENCES `ChatRoom`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `chatRoomId` TEXT NOT NULL, `coordinatorPublicKey` TEXT NOT NULL, `userPublicKey` TEXT NOT NULL, `dkgSessionId` TEXT NOT NULL, `threshold` INTEGER NOT NULL, `participantCount` INTEGER NOT NULL, `signerId` INTEGER NOT NULL, `derivationPath` TEXT, `stage` TEXT NOT NULL, `signerIds` TEXT, `failureReason` TEXT, `signApprovedAt` INTEGER, `signDeclinedAt` INTEGER, `approvalRequestedAt` INTEGER, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, `savedAt` INTEGER NOT NULL, PRIMARY KEY(`id`), FOREIGN KEY(`chatRoomId`) REFERENCES `ChatRoom`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
"fields": [
{
"fieldPath": "id",
@@ -1260,6 +1260,11 @@
"columnName": "signApprovedAt",
"affinity": "INTEGER"
},
+ {
+ "fieldPath": "signDeclinedAt",
+ "columnName": "signDeclinedAt",
+ "affinity": "INTEGER"
+ },
{
"fieldPath": "approvalRequestedAt",
"columnName": "approvalRequestedAt",
@@ -3670,7 +3675,7 @@
},
{
"tableName": "MarmotKeyPackage",
- "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `publicKey` TEXT NOT NULL, `tlsEncodedMarmotKeyPackage` BLOB NOT NULL, `profile` TEXT, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, `savedAt` INTEGER NOT NULL, `deletedAt` INTEGER, `broadcastedAt` INTEGER, PRIMARY KEY(`id`), FOREIGN KEY(`publicKey`) REFERENCES `Profile`(`publicKey`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `publicKey` TEXT NOT NULL, `tlsEncodedMarmotKeyPackage` BLOB NOT NULL, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, `savedAt` INTEGER NOT NULL, `deletedAt` INTEGER, `broadcastedAt` INTEGER, PRIMARY KEY(`id`), FOREIGN KEY(`publicKey`) REFERENCES `Profile`(`publicKey`) ON UPDATE NO ACTION ON DELETE CASCADE )",
"fields": [
{
"fieldPath": "id",
@@ -3690,11 +3695,6 @@
"affinity": "BLOB",
"notNull": true
},
- {
- "fieldPath": "profile",
- "columnName": "profile",
- "affinity": "TEXT"
- },
{
"fieldPath": "createdAt",
"columnName": "createdAt",
@@ -3746,7 +3746,7 @@
},
{
"tableName": "MarmotKeyPackageBundle",
- "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `publicKey` TEXT NOT NULL, `tlsEncodedMarmotKeyPackage` BLOB NOT NULL, `ncryptsecInitPrivateKey` TEXT NOT NULL, `ncryptsecEncryptionPrivateKey` TEXT NOT NULL, `ncryptsecSignaturePrivateKey` TEXT NOT NULL, `consumed` INTEGER NOT NULL, `rotated` INTEGER NOT NULL, `profile` TEXT, `dTag` TEXT, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, `savedAt` INTEGER NOT NULL, `deletedAt` INTEGER, `broadcastedAt` INTEGER, PRIMARY KEY(`id`))",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `publicKey` TEXT NOT NULL, `tlsEncodedMarmotKeyPackage` BLOB NOT NULL, `ncryptsecInitPrivateKey` TEXT NOT NULL, `ncryptsecEncryptionPrivateKey` TEXT NOT NULL, `ncryptsecSignaturePrivateKey` TEXT NOT NULL, `consumed` INTEGER NOT NULL, `rotated` INTEGER NOT NULL, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, `savedAt` INTEGER NOT NULL, `deletedAt` INTEGER, `broadcastedAt` INTEGER, PRIMARY KEY(`id`))",
"fields": [
{
"fieldPath": "id",
@@ -3796,16 +3796,6 @@
"affinity": "INTEGER",
"notNull": true
},
- {
- "fieldPath": "profile",
- "columnName": "profile",
- "affinity": "TEXT"
- },
- {
- "fieldPath": "dTag",
- "columnName": "dTag",
- "affinity": "TEXT"
- },
{
"fieldPath": "createdAt",
"columnName": "createdAt",
@@ -5707,7 +5697,7 @@
],
"setupQueries": [
"CREATE TABLE IF NOT EXISTS room_master_table (id INTEGER PRIMARY KEY,identity_hash TEXT)",
- "INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, '3aae084382314d5c6c8e7e729cbc8aab')"
+ "INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, 'eb81f06bb966326e318f3b4feb291bc6')"
]
}
}
\ No newline at end of file
diff --git a/composeApp/schemas/to.curare.compose.database.CurareDatabase/22.json b/composeApp/schemas/to.curare.compose.database.CurareDatabase/22.json
index 19006c69..fc617c9c 100644
--- a/composeApp/schemas/to.curare.compose.database.CurareDatabase/22.json
+++ b/composeApp/schemas/to.curare.compose.database.CurareDatabase/22.json
@@ -2,7 +2,7 @@
"formatVersion": 1,
"database": {
"version": 22,
- "identityHash": "d553e041af3cf25d70c08389a367cb22",
+ "identityHash": "4f654231a494982f0fa67a5fc6b3aeec",
"entities": [
{
"tableName": "BroadcastNostrEventReceipt",
@@ -1184,7 +1184,7 @@
},
{
"tableName": "FrostSigningSession",
- "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `chatRoomId` TEXT NOT NULL, `coordinatorPublicKey` TEXT NOT NULL, `userPublicKey` TEXT NOT NULL, `dkgSessionId` TEXT NOT NULL, `threshold` INTEGER NOT NULL, `participantCount` INTEGER NOT NULL, `signerId` INTEGER NOT NULL, `derivationPath` TEXT, `stage` TEXT NOT NULL, `signerIds` TEXT, `failureReason` TEXT, `signApprovedAt` INTEGER, `approvalRequestedAt` INTEGER, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, `savedAt` INTEGER NOT NULL, PRIMARY KEY(`id`), FOREIGN KEY(`chatRoomId`) REFERENCES `ChatRoom`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `chatRoomId` TEXT NOT NULL, `coordinatorPublicKey` TEXT NOT NULL, `userPublicKey` TEXT NOT NULL, `dkgSessionId` TEXT NOT NULL, `threshold` INTEGER NOT NULL, `participantCount` INTEGER NOT NULL, `signerId` INTEGER NOT NULL, `derivationPath` TEXT, `stage` TEXT NOT NULL, `signerIds` TEXT, `failureReason` TEXT, `signApprovedAt` INTEGER, `signDeclinedAt` INTEGER, `approvalRequestedAt` INTEGER, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, `savedAt` INTEGER NOT NULL, PRIMARY KEY(`id`), FOREIGN KEY(`chatRoomId`) REFERENCES `ChatRoom`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
"fields": [
{
"fieldPath": "id",
@@ -1260,6 +1260,11 @@
"columnName": "signApprovedAt",
"affinity": "INTEGER"
},
+ {
+ "fieldPath": "signDeclinedAt",
+ "columnName": "signDeclinedAt",
+ "affinity": "INTEGER"
+ },
{
"fieldPath": "approvalRequestedAt",
"columnName": "approvalRequestedAt",
@@ -3853,65 +3858,6 @@
}
]
},
- {
- "tableName": "MarmotRouting",
- "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`routingId` TEXT NOT NULL, `chatRoomId` TEXT NOT NULL, `activeFromEpoch` INTEGER NOT NULL, `retiredAtEpoch` INTEGER, PRIMARY KEY(`routingId`), FOREIGN KEY(`chatRoomId`) REFERENCES `ChatRoom`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
- "fields": [
- {
- "fieldPath": "routingId",
- "columnName": "routingId",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "chatRoomId",
- "columnName": "chatRoomId",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "activeFromEpoch",
- "columnName": "activeFromEpoch",
- "affinity": "INTEGER",
- "notNull": true
- },
- {
- "fieldPath": "retiredAtEpoch",
- "columnName": "retiredAtEpoch",
- "affinity": "INTEGER"
- }
- ],
- "primaryKey": {
- "autoGenerate": false,
- "columnNames": [
- "routingId"
- ]
- },
- "indices": [
- {
- "name": "index_MarmotRouting_chatRoomId",
- "unique": false,
- "columnNames": [
- "chatRoomId"
- ],
- "orders": [],
- "createSql": "CREATE INDEX IF NOT EXISTS `index_MarmotRouting_chatRoomId` ON `${TABLE_NAME}` (`chatRoomId`)"
- }
- ],
- "foreignKeys": [
- {
- "table": "ChatRoom",
- "onDelete": "CASCADE",
- "onUpdate": "NO ACTION",
- "columns": [
- "chatRoomId"
- ],
- "referencedColumns": [
- "id"
- ]
- }
- ]
- },
{
"tableName": "MarmotRetainedEpochSecret",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`chatRoomId` TEXT NOT NULL, `epoch` INTEGER NOT NULL, `senderDataSecret` BLOB NOT NULL, `encryptionSecret` BLOB NOT NULL, `leafCount` INTEGER NOT NULL, `exporterSecret` BLOB NOT NULL, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, `savedAt` INTEGER NOT NULL, PRIMARY KEY(`chatRoomId`, `epoch`), FOREIGN KEY(`chatRoomId`) REFERENCES `ChatRoom`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
@@ -5766,7 +5712,7 @@
],
"setupQueries": [
"CREATE TABLE IF NOT EXISTS room_master_table (id INTEGER PRIMARY KEY,identity_hash TEXT)",
- "INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, 'd553e041af3cf25d70c08389a367cb22')"
+ "INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, '4f654231a494982f0fa67a5fc6b3aeec')"
]
}
}
\ No newline at end of file
diff --git a/composeApp/schemas/to.curare.compose.database.CurareDatabase/23.json b/composeApp/schemas/to.curare.compose.database.CurareDatabase/23.json
index 29bf117a..83f20e55 100644
--- a/composeApp/schemas/to.curare.compose.database.CurareDatabase/23.json
+++ b/composeApp/schemas/to.curare.compose.database.CurareDatabase/23.json
@@ -2,7 +2,7 @@
"formatVersion": 1,
"database": {
"version": 23,
- "identityHash": "1b1bdc13e1be193a593604493c4c2d3b",
+ "identityHash": "f32aeb4f86c7e1ae16eb6ee44384456a",
"entities": [
{
"tableName": "BroadcastNostrEventReceipt",
@@ -1184,7 +1184,7 @@
},
{
"tableName": "FrostSigningSession",
- "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `chatRoomId` TEXT NOT NULL, `coordinatorPublicKey` TEXT NOT NULL, `userPublicKey` TEXT NOT NULL, `dkgSessionId` TEXT NOT NULL, `threshold` INTEGER NOT NULL, `participantCount` INTEGER NOT NULL, `signerId` INTEGER NOT NULL, `derivationPath` TEXT, `stage` TEXT NOT NULL, `signerIds` TEXT, `failureReason` TEXT, `signApprovedAt` INTEGER, `approvalRequestedAt` INTEGER, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, `savedAt` INTEGER NOT NULL, PRIMARY KEY(`id`), FOREIGN KEY(`chatRoomId`) REFERENCES `ChatRoom`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `chatRoomId` TEXT NOT NULL, `coordinatorPublicKey` TEXT NOT NULL, `userPublicKey` TEXT NOT NULL, `dkgSessionId` TEXT NOT NULL, `threshold` INTEGER NOT NULL, `participantCount` INTEGER NOT NULL, `signerId` INTEGER NOT NULL, `derivationPath` TEXT, `stage` TEXT NOT NULL, `signerIds` TEXT, `failureReason` TEXT, `signApprovedAt` INTEGER, `signDeclinedAt` INTEGER, `approvalRequestedAt` INTEGER, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, `savedAt` INTEGER NOT NULL, PRIMARY KEY(`id`), FOREIGN KEY(`chatRoomId`) REFERENCES `ChatRoom`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
"fields": [
{
"fieldPath": "id",
@@ -1260,6 +1260,11 @@
"columnName": "signApprovedAt",
"affinity": "INTEGER"
},
+ {
+ "fieldPath": "signDeclinedAt",
+ "columnName": "signDeclinedAt",
+ "affinity": "INTEGER"
+ },
{
"fieldPath": "approvalRequestedAt",
"columnName": "approvalRequestedAt",
@@ -3369,7 +3374,7 @@
},
{
"tableName": "MarmotCommitResult",
- "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `userPublicKey` TEXT NOT NULL, `peerKeyPackageEventId` TEXT NOT NULL, `chatRoomId` TEXT NOT NULL, `isOneMemberInitialGroupCreation` INTEGER NOT NULL, `commitBytes` BLOB NOT NULL, `welcomeBytes` BLOB, `groupInfoBytes` BLOB, `framedCommitBytes` BLOB NOT NULL, `preCommitExporterSecret` BLOB NOT NULL, `obligationId` TEXT, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, `savedAt` INTEGER NOT NULL, `viewedAt` INTEGER, `deletedAt` INTEGER, PRIMARY KEY(`id`))",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `userPublicKey` TEXT NOT NULL, `peerKeyPackageEventId` TEXT NOT NULL, `chatRoomId` TEXT NOT NULL, `isOneMemberInitialGroupCreation` INTEGER NOT NULL, `commitBytes` BLOB NOT NULL, `welcomeBytes` BLOB, `groupInfoBytes` BLOB, `framedCommitBytes` BLOB NOT NULL, `preCommitExporterSecret` BLOB NOT NULL, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, `savedAt` INTEGER NOT NULL, `viewedAt` INTEGER, `deletedAt` INTEGER, PRIMARY KEY(`id`))",
"fields": [
{
"fieldPath": "id",
@@ -3429,11 +3434,6 @@
"affinity": "BLOB",
"notNull": true
},
- {
- "fieldPath": "obligationId",
- "columnName": "obligationId",
- "affinity": "TEXT"
- },
{
"fieldPath": "createdAt",
"columnName": "createdAt",
@@ -3917,54 +3917,6 @@
}
]
},
- {
- "tableName": "MarmotPublishObligation",
- "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`obligationId` TEXT NOT NULL, `bytes` BLOB NOT NULL, PRIMARY KEY(`obligationId`))",
- "fields": [
- {
- "fieldPath": "obligationId",
- "columnName": "obligationId",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "bytes",
- "columnName": "bytes",
- "affinity": "BLOB",
- "notNull": true
- }
- ],
- "primaryKey": {
- "autoGenerate": false,
- "columnNames": [
- "obligationId"
- ]
- }
- },
- {
- "tableName": "MarmotOutboundGate",
- "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`groupId` TEXT NOT NULL, `gate` TEXT NOT NULL, PRIMARY KEY(`groupId`))",
- "fields": [
- {
- "fieldPath": "groupId",
- "columnName": "groupId",
- "affinity": "TEXT",
- "notNull": true
- },
- {
- "fieldPath": "gate",
- "columnName": "gate",
- "affinity": "TEXT",
- "notNull": true
- }
- ],
- "primaryKey": {
- "autoGenerate": false,
- "columnNames": [
- "groupId"
- ]
- }
- },
{
"tableName": "MarmotRetainedEpochSecret",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`chatRoomId` TEXT NOT NULL, `epoch` INTEGER NOT NULL, `senderDataSecret` BLOB NOT NULL, `encryptionSecret` BLOB NOT NULL, `leafCount` INTEGER NOT NULL, `exporterSecret` BLOB NOT NULL, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, `savedAt` INTEGER NOT NULL, PRIMARY KEY(`chatRoomId`, `epoch`), FOREIGN KEY(`chatRoomId`) REFERENCES `ChatRoom`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
@@ -5819,7 +5771,7 @@
],
"setupQueries": [
"CREATE TABLE IF NOT EXISTS room_master_table (id INTEGER PRIMARY KEY,identity_hash TEXT)",
- "INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, '1b1bdc13e1be193a593604493c4c2d3b')"
+ "INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, 'f32aeb4f86c7e1ae16eb6ee44384456a')"
]
}
}
\ No newline at end of file
diff --git a/composeApp/schemas/to.curare.compose.database.CurareDatabase/24.json b/composeApp/schemas/to.curare.compose.database.CurareDatabase/24.json
new file mode 100644
index 00000000..a15f96e8
--- /dev/null
+++ b/composeApp/schemas/to.curare.compose.database.CurareDatabase/24.json
@@ -0,0 +1,5830 @@
+{
+ "formatVersion": 1,
+ "database": {
+ "version": 24,
+ "identityHash": "2c0a331e83c34052be538e86ab743c87",
+ "entities": [
+ {
+ "tableName": "BroadcastNostrEventReceipt",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `nostrEventId` TEXT NOT NULL, `unsignedNostrEventId` INTEGER, `isAccepted` INTEGER NOT NULL, `isSync` INTEGER NOT NULL, `relayURL` TEXT NOT NULL, `messages` TEXT, FOREIGN KEY(`nostrEventId`) REFERENCES `NostrEvent`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`unsignedNostrEventId`) REFERENCES `UnsignedNostrEvent`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "nostrEventId",
+ "columnName": "nostrEventId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "unsignedNostrEventId",
+ "columnName": "unsignedNostrEventId",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "isAccepted",
+ "columnName": "isAccepted",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "isSync",
+ "columnName": "isSync",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "relayURL",
+ "columnName": "relayURL",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "messages",
+ "columnName": "messages",
+ "affinity": "TEXT"
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": true,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_BroadcastNostrEventReceipt_nostrEventId",
+ "unique": false,
+ "columnNames": [
+ "nostrEventId"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_BroadcastNostrEventReceipt_nostrEventId` ON `${TABLE_NAME}` (`nostrEventId`)"
+ },
+ {
+ "name": "index_BroadcastNostrEventReceipt_isAccepted",
+ "unique": false,
+ "columnNames": [
+ "isAccepted"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_BroadcastNostrEventReceipt_isAccepted` ON `${TABLE_NAME}` (`isAccepted`)"
+ }
+ ],
+ "foreignKeys": [
+ {
+ "table": "NostrEvent",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "nostrEventId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ },
+ {
+ "table": "UnsignedNostrEvent",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "unsignedNostrEventId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "BroadcastNostrEventRequest",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `nostrEventId` TEXT NOT NULL, `unsignedNostrEventId` INTEGER, `status` TEXT NOT NULL, `relayURL` TEXT NOT NULL, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, FOREIGN KEY(`nostrEventId`) REFERENCES `NostrEvent`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`unsignedNostrEventId`) REFERENCES `UnsignedNostrEvent`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "nostrEventId",
+ "columnName": "nostrEventId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "unsignedNostrEventId",
+ "columnName": "unsignedNostrEventId",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "status",
+ "columnName": "status",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "relayURL",
+ "columnName": "relayURL",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "createdAt",
+ "columnName": "createdAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "updatedAt",
+ "columnName": "updatedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": true,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_BroadcastNostrEventRequest_nostrEventId",
+ "unique": false,
+ "columnNames": [
+ "nostrEventId"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_BroadcastNostrEventRequest_nostrEventId` ON `${TABLE_NAME}` (`nostrEventId`)"
+ },
+ {
+ "name": "index_BroadcastNostrEventRequest_status",
+ "unique": false,
+ "columnNames": [
+ "status"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_BroadcastNostrEventRequest_status` ON `${TABLE_NAME}` (`status`)"
+ }
+ ],
+ "foreignKeys": [
+ {
+ "table": "NostrEvent",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "nostrEventId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ },
+ {
+ "table": "UnsignedNostrEvent",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "unsignedNostrEventId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "Connection",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`sourcePublicKey` TEXT NOT NULL, `destinationPublicKey` TEXT NOT NULL, `nostrEventId` TEXT NOT NULL, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, `savedAt` INTEGER NOT NULL, `deletedAt` INTEGER, `broadcastedAt` INTEGER, PRIMARY KEY(`sourcePublicKey`, `destinationPublicKey`), FOREIGN KEY(`sourcePublicKey`) REFERENCES `Profile`(`publicKey`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`destinationPublicKey`) REFERENCES `Profile`(`publicKey`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "sourcePublicKey",
+ "columnName": "sourcePublicKey",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "destinationPublicKey",
+ "columnName": "destinationPublicKey",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "nostrEventId",
+ "columnName": "nostrEventId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "createdAt",
+ "columnName": "createdAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "updatedAt",
+ "columnName": "updatedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "savedAt",
+ "columnName": "savedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "deletedAt",
+ "columnName": "deletedAt",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "broadcastedAt",
+ "columnName": "broadcastedAt",
+ "affinity": "INTEGER"
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "sourcePublicKey",
+ "destinationPublicKey"
+ ]
+ },
+ "foreignKeys": [
+ {
+ "table": "Profile",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "sourcePublicKey"
+ ],
+ "referencedColumns": [
+ "publicKey"
+ ]
+ },
+ {
+ "table": "Profile",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "destinationPublicKey"
+ ],
+ "referencedColumns": [
+ "publicKey"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "ChatMessage",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `senderPublicKey` TEXT NOT NULL, `isUserMessage` INTEGER NOT NULL, `giftWrapPayloadId` TEXT, `marmotGroupEventId` TEXT, `marmotInnerEventId` TEXT, `chatRoomId` TEXT NOT NULL, `replyToMessageId` INTEGER, `quotedMessageId` INTEGER, `content` TEXT NOT NULL, `messageType` TEXT NOT NULL, `directMessageRecipientPublicKey` TEXT, `frostSigningSessionId` TEXT, `dkgSessionId` TEXT, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, `savedAt` INTEGER NOT NULL, `viewedAt` INTEGER, `deletedAt` INTEGER, FOREIGN KEY(`chatRoomId`) REFERENCES `ChatRoom`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`giftWrapPayloadId`) REFERENCES `GiftWrapPayload`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`marmotGroupEventId`) REFERENCES `MarmotGroupEvent`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`marmotInnerEventId`) REFERENCES `MarmotInnerEvent`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "senderPublicKey",
+ "columnName": "senderPublicKey",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "isUserMessage",
+ "columnName": "isUserMessage",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "giftWrapPayloadId",
+ "columnName": "giftWrapPayloadId",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "marmotGroupEventId",
+ "columnName": "marmotGroupEventId",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "marmotInnerEventId",
+ "columnName": "marmotInnerEventId",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "chatRoomId",
+ "columnName": "chatRoomId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "replyToMessageId",
+ "columnName": "replyToMessageId",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "quotedMessageId",
+ "columnName": "quotedMessageId",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "content",
+ "columnName": "content",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "messageType",
+ "columnName": "messageType",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "directMessageRecipientPublicKey",
+ "columnName": "directMessageRecipientPublicKey",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "frostSigningSessionId",
+ "columnName": "frostSigningSessionId",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "dkgSessionId",
+ "columnName": "dkgSessionId",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "createdAt",
+ "columnName": "createdAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "updatedAt",
+ "columnName": "updatedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "savedAt",
+ "columnName": "savedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "viewedAt",
+ "columnName": "viewedAt",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "deletedAt",
+ "columnName": "deletedAt",
+ "affinity": "INTEGER"
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": true,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_ChatMessage_chatRoomId",
+ "unique": false,
+ "columnNames": [
+ "chatRoomId"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_ChatMessage_chatRoomId` ON `${TABLE_NAME}` (`chatRoomId`)"
+ }
+ ],
+ "foreignKeys": [
+ {
+ "table": "ChatRoom",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "chatRoomId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ },
+ {
+ "table": "GiftWrapPayload",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "giftWrapPayloadId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ },
+ {
+ "table": "MarmotGroupEvent",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "marmotGroupEventId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ },
+ {
+ "table": "MarmotInnerEvent",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "marmotInnerEventId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "ChatMessageBroadcastNostrEventRequestRelation",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `chatMessageId` INTEGER NOT NULL, `broadcastNostrEventRequestId` INTEGER NOT NULL, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, `savedAt` INTEGER NOT NULL, FOREIGN KEY(`chatMessageId`) REFERENCES `ChatMessage`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`broadcastNostrEventRequestId`) REFERENCES `BroadcastNostrEventRequest`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "chatMessageId",
+ "columnName": "chatMessageId",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "broadcastNostrEventRequestId",
+ "columnName": "broadcastNostrEventRequestId",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "createdAt",
+ "columnName": "createdAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "updatedAt",
+ "columnName": "updatedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "savedAt",
+ "columnName": "savedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": true,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "foreignKeys": [
+ {
+ "table": "ChatMessage",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "chatMessageId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ },
+ {
+ "table": "BroadcastNostrEventRequest",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "broadcastNostrEventRequestId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "ChatMessageBroadcastNostrEventReceiptRelation",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `chatMessageId` INTEGER NOT NULL, `broadcastNostrEventReceiptId` INTEGER NOT NULL, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, `savedAt` INTEGER NOT NULL, FOREIGN KEY(`chatMessageId`) REFERENCES `ChatMessage`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`broadcastNostrEventReceiptId`) REFERENCES `BroadcastNostrEventReceipt`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "chatMessageId",
+ "columnName": "chatMessageId",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "broadcastNostrEventReceiptId",
+ "columnName": "broadcastNostrEventReceiptId",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "createdAt",
+ "columnName": "createdAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "updatedAt",
+ "columnName": "updatedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "savedAt",
+ "columnName": "savedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": true,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "foreignKeys": [
+ {
+ "table": "ChatMessage",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "chatMessageId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ },
+ {
+ "table": "BroadcastNostrEventReceipt",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "broadcastNostrEventReceiptId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "ChatMessageNostrEventRelation",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `chatMessageId` INTEGER NOT NULL, `nostrEventId` TEXT NOT NULL, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, `savedAt` INTEGER NOT NULL, FOREIGN KEY(`chatMessageId`) REFERENCES `ChatMessage`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`nostrEventId`) REFERENCES `NostrEvent`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "chatMessageId",
+ "columnName": "chatMessageId",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "nostrEventId",
+ "columnName": "nostrEventId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "createdAt",
+ "columnName": "createdAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "updatedAt",
+ "columnName": "updatedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "savedAt",
+ "columnName": "savedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": true,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "foreignKeys": [
+ {
+ "table": "ChatMessage",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "chatMessageId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ },
+ {
+ "table": "NostrEvent",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "nostrEventId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "ChatRoom",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `userPublicKey` TEXT NOT NULL, `subject` TEXT, `description` TEXT, `mlsGroupState` TEXT, `initialGiftWrapPayloadId` TEXT, `leftGroupAt` INTEGER, `joinedGroupAt` INTEGER, `chronicleRequestedAt` INTEGER, `parentChatRoomId` TEXT, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, `savedAt` INTEGER NOT NULL, `viewedAt` INTEGER, `deletedAt` INTEGER, PRIMARY KEY(`id`), FOREIGN KEY(`userPublicKey`) REFERENCES `Profile`(`publicKey`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`initialGiftWrapPayloadId`) REFERENCES `GiftWrapPayload`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "userPublicKey",
+ "columnName": "userPublicKey",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "subject",
+ "columnName": "subject",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "description",
+ "columnName": "description",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "mlsGroupState",
+ "columnName": "mlsGroupState",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "initialGiftWrapPayloadId",
+ "columnName": "initialGiftWrapPayloadId",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "leftGroupAt",
+ "columnName": "leftGroupAt",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "joinedGroupAt",
+ "columnName": "joinedGroupAt",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "chronicleRequestedAt",
+ "columnName": "chronicleRequestedAt",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "parentChatRoomId",
+ "columnName": "parentChatRoomId",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "createdAt",
+ "columnName": "createdAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "updatedAt",
+ "columnName": "updatedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "savedAt",
+ "columnName": "savedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "viewedAt",
+ "columnName": "viewedAt",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "deletedAt",
+ "columnName": "deletedAt",
+ "affinity": "INTEGER"
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "foreignKeys": [
+ {
+ "table": "Profile",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "userPublicKey"
+ ],
+ "referencedColumns": [
+ "publicKey"
+ ]
+ },
+ {
+ "table": "GiftWrapPayload",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "initialGiftWrapPayloadId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "DkgParticipantMessage",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`sessionId` TEXT NOT NULL, `participantPublicKey` TEXT NOT NULL, `kind` INTEGER NOT NULL, `payload` TEXT NOT NULL, `createdAt` INTEGER NOT NULL, PRIMARY KEY(`sessionId`, `participantPublicKey`, `kind`), FOREIGN KEY(`sessionId`) REFERENCES `DkgSession`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "sessionId",
+ "columnName": "sessionId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "participantPublicKey",
+ "columnName": "participantPublicKey",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "kind",
+ "columnName": "kind",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "payload",
+ "columnName": "payload",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "createdAt",
+ "columnName": "createdAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "sessionId",
+ "participantPublicKey",
+ "kind"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_DkgParticipantMessage_sessionId",
+ "unique": false,
+ "columnNames": [
+ "sessionId"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_DkgParticipantMessage_sessionId` ON `${TABLE_NAME}` (`sessionId`)"
+ }
+ ],
+ "foreignKeys": [
+ {
+ "table": "DkgSession",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "sessionId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "DkgSession",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `chatRoomId` TEXT NOT NULL, `coordinatorPublicKey` TEXT NOT NULL, `userPublicKey` TEXT NOT NULL, `threshold` INTEGER NOT NULL, `participantCount` INTEGER NOT NULL, `participantPublicKeys` TEXT, `subject` TEXT, `stage` TEXT NOT NULL, `hostPublicKey` TEXT NOT NULL, `round1Random` TEXT NOT NULL, `round2AuxRandom` TEXT NOT NULL, `coordinatorRound1` TEXT, `certificate` TEXT, `thresholdPublicKey` TEXT, `secretShare` TEXT, `publicShares` TEXT, `recoveryData` TEXT, `failureReason` TEXT, `hostKeyApprovedAt` INTEGER, `round1ApprovedAt` INTEGER, `round2ApprovedAt` INTEGER, `approvalRequestedThrough` TEXT, `parentChatRoomId` TEXT, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, `savedAt` INTEGER NOT NULL, PRIMARY KEY(`id`), FOREIGN KEY(`chatRoomId`) REFERENCES `ChatRoom`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "chatRoomId",
+ "columnName": "chatRoomId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "coordinatorPublicKey",
+ "columnName": "coordinatorPublicKey",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "userPublicKey",
+ "columnName": "userPublicKey",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "threshold",
+ "columnName": "threshold",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "participantCount",
+ "columnName": "participantCount",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "participantPublicKeys",
+ "columnName": "participantPublicKeys",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "subject",
+ "columnName": "subject",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "stage",
+ "columnName": "stage",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "hostPublicKey",
+ "columnName": "hostPublicKey",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "round1Random",
+ "columnName": "round1Random",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "round2AuxRandom",
+ "columnName": "round2AuxRandom",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "coordinatorRound1",
+ "columnName": "coordinatorRound1",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "certificate",
+ "columnName": "certificate",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "thresholdPublicKey",
+ "columnName": "thresholdPublicKey",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "secretShare",
+ "columnName": "secretShare",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "publicShares",
+ "columnName": "publicShares",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "recoveryData",
+ "columnName": "recoveryData",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "failureReason",
+ "columnName": "failureReason",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "hostKeyApprovedAt",
+ "columnName": "hostKeyApprovedAt",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "round1ApprovedAt",
+ "columnName": "round1ApprovedAt",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "round2ApprovedAt",
+ "columnName": "round2ApprovedAt",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "approvalRequestedThrough",
+ "columnName": "approvalRequestedThrough",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "parentChatRoomId",
+ "columnName": "parentChatRoomId",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "createdAt",
+ "columnName": "createdAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "updatedAt",
+ "columnName": "updatedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "savedAt",
+ "columnName": "savedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_DkgSession_chatRoomId",
+ "unique": false,
+ "columnNames": [
+ "chatRoomId"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_DkgSession_chatRoomId` ON `${TABLE_NAME}` (`chatRoomId`)"
+ }
+ ],
+ "foreignKeys": [
+ {
+ "table": "ChatRoom",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "chatRoomId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "FrostSignerMessage",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`sessionId` TEXT NOT NULL, `signerPublicKey` TEXT NOT NULL, `kind` INTEGER NOT NULL, `payload` TEXT NOT NULL, `createdAt` INTEGER NOT NULL, PRIMARY KEY(`sessionId`, `signerPublicKey`, `kind`), FOREIGN KEY(`sessionId`) REFERENCES `FrostSigningSession`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "sessionId",
+ "columnName": "sessionId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "signerPublicKey",
+ "columnName": "signerPublicKey",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "kind",
+ "columnName": "kind",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "payload",
+ "columnName": "payload",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "createdAt",
+ "columnName": "createdAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "sessionId",
+ "signerPublicKey",
+ "kind"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_FrostSignerMessage_sessionId",
+ "unique": false,
+ "columnNames": [
+ "sessionId"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_FrostSignerMessage_sessionId` ON `${TABLE_NAME}` (`sessionId`)"
+ }
+ ],
+ "foreignKeys": [
+ {
+ "table": "FrostSigningSession",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "sessionId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "FrostSigningItem",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`sessionId` TEXT NOT NULL, `itemIndex` INTEGER NOT NULL, `unsignedEventJson` TEXT NOT NULL, `eventId` TEXT NOT NULL, `nonceRandom` TEXT NOT NULL, `aggregatedNonce` TEXT, `signature` TEXT, PRIMARY KEY(`sessionId`, `itemIndex`), FOREIGN KEY(`sessionId`) REFERENCES `FrostSigningSession`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "sessionId",
+ "columnName": "sessionId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "itemIndex",
+ "columnName": "itemIndex",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "unsignedEventJson",
+ "columnName": "unsignedEventJson",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "eventId",
+ "columnName": "eventId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "nonceRandom",
+ "columnName": "nonceRandom",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "aggregatedNonce",
+ "columnName": "aggregatedNonce",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "signature",
+ "columnName": "signature",
+ "affinity": "TEXT"
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "sessionId",
+ "itemIndex"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_FrostSigningItem_sessionId",
+ "unique": false,
+ "columnNames": [
+ "sessionId"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_FrostSigningItem_sessionId` ON `${TABLE_NAME}` (`sessionId`)"
+ }
+ ],
+ "foreignKeys": [
+ {
+ "table": "FrostSigningSession",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "sessionId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "FrostSigningSession",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `chatRoomId` TEXT NOT NULL, `coordinatorPublicKey` TEXT NOT NULL, `userPublicKey` TEXT NOT NULL, `dkgSessionId` TEXT NOT NULL, `threshold` INTEGER NOT NULL, `participantCount` INTEGER NOT NULL, `signerId` INTEGER NOT NULL, `derivationPath` TEXT, `stage` TEXT NOT NULL, `signerIds` TEXT, `failureReason` TEXT, `signApprovedAt` INTEGER, `signDeclinedAt` INTEGER, `approvalRequestedAt` INTEGER, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, `savedAt` INTEGER NOT NULL, PRIMARY KEY(`id`), FOREIGN KEY(`chatRoomId`) REFERENCES `ChatRoom`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "chatRoomId",
+ "columnName": "chatRoomId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "coordinatorPublicKey",
+ "columnName": "coordinatorPublicKey",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "userPublicKey",
+ "columnName": "userPublicKey",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "dkgSessionId",
+ "columnName": "dkgSessionId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "threshold",
+ "columnName": "threshold",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "participantCount",
+ "columnName": "participantCount",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "signerId",
+ "columnName": "signerId",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "derivationPath",
+ "columnName": "derivationPath",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "stage",
+ "columnName": "stage",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "signerIds",
+ "columnName": "signerIds",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "failureReason",
+ "columnName": "failureReason",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "signApprovedAt",
+ "columnName": "signApprovedAt",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "signDeclinedAt",
+ "columnName": "signDeclinedAt",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "approvalRequestedAt",
+ "columnName": "approvalRequestedAt",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "createdAt",
+ "columnName": "createdAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "updatedAt",
+ "columnName": "updatedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "savedAt",
+ "columnName": "savedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_FrostSigningSession_chatRoomId",
+ "unique": false,
+ "columnNames": [
+ "chatRoomId"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_FrostSigningSession_chatRoomId` ON `${TABLE_NAME}` (`chatRoomId`)"
+ },
+ {
+ "name": "index_FrostSigningSession_dkgSessionId",
+ "unique": false,
+ "columnNames": [
+ "dkgSessionId"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_FrostSigningSession_dkgSessionId` ON `${TABLE_NAME}` (`dkgSessionId`)"
+ }
+ ],
+ "foreignKeys": [
+ {
+ "table": "ChatRoom",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "chatRoomId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "GiftWrapMessage",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `publicKey` TEXT NOT NULL, `kind` INTEGER NOT NULL, `receiverPublicKey` TEXT NOT NULL, `receiverRelayHit` TEXT, `content` TEXT NOT NULL, `signature` TEXT NOT NULL, `nostrEventId` TEXT NOT NULL, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, `savedAt` INTEGER NOT NULL, `viewedAt` INTEGER, `deletedAt` INTEGER, PRIMARY KEY(`id`), FOREIGN KEY(`nostrEventId`) REFERENCES `NostrEvent`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "publicKey",
+ "columnName": "publicKey",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "kind",
+ "columnName": "kind",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "receiverPublicKey",
+ "columnName": "receiverPublicKey",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "receiverRelayHit",
+ "columnName": "receiverRelayHit",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "content",
+ "columnName": "content",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "signature",
+ "columnName": "signature",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "nostrEventId",
+ "columnName": "nostrEventId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "createdAt",
+ "columnName": "createdAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "updatedAt",
+ "columnName": "updatedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "savedAt",
+ "columnName": "savedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "viewedAt",
+ "columnName": "viewedAt",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "deletedAt",
+ "columnName": "deletedAt",
+ "affinity": "INTEGER"
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "foreignKeys": [
+ {
+ "table": "NostrEvent",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "nostrEventId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "GiftWrapSeal",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `publicKey` TEXT NOT NULL, `kind` INTEGER NOT NULL, `tags` TEXT NOT NULL, `content` TEXT NOT NULL, `signature` TEXT NOT NULL, `giftWrapMessageId` TEXT, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, `savedAt` INTEGER NOT NULL, `viewedAt` INTEGER, `deletedAt` INTEGER, PRIMARY KEY(`id`), FOREIGN KEY(`giftWrapMessageId`) REFERENCES `GiftWrapMessage`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "publicKey",
+ "columnName": "publicKey",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "kind",
+ "columnName": "kind",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "tags",
+ "columnName": "tags",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "content",
+ "columnName": "content",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "signature",
+ "columnName": "signature",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "giftWrapMessageId",
+ "columnName": "giftWrapMessageId",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "createdAt",
+ "columnName": "createdAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "updatedAt",
+ "columnName": "updatedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "savedAt",
+ "columnName": "savedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "viewedAt",
+ "columnName": "viewedAt",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "deletedAt",
+ "columnName": "deletedAt",
+ "affinity": "INTEGER"
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "foreignKeys": [
+ {
+ "table": "GiftWrapMessage",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "giftWrapMessageId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "GiftWrapPayload",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `publicKey` TEXT NOT NULL, `chatRoomId` TEXT NOT NULL, `kind` INTEGER NOT NULL, `tags` TEXT NOT NULL, `content` TEXT NOT NULL, `quotedEventId` TEXT, `giftWrapSealId` TEXT, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, `savedAt` INTEGER NOT NULL, `viewedAt` INTEGER, `deletedAt` INTEGER, PRIMARY KEY(`id`), FOREIGN KEY(`giftWrapSealId`) REFERENCES `GiftWrapSeal`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "publicKey",
+ "columnName": "publicKey",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "chatRoomId",
+ "columnName": "chatRoomId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "kind",
+ "columnName": "kind",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "tags",
+ "columnName": "tags",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "content",
+ "columnName": "content",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "quotedEventId",
+ "columnName": "quotedEventId",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "giftWrapSealId",
+ "columnName": "giftWrapSealId",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "createdAt",
+ "columnName": "createdAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "updatedAt",
+ "columnName": "updatedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "savedAt",
+ "columnName": "savedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "viewedAt",
+ "columnName": "viewedAt",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "deletedAt",
+ "columnName": "deletedAt",
+ "affinity": "INTEGER"
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "foreignKeys": [
+ {
+ "table": "GiftWrapSeal",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "giftWrapSealId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "GroupKeyState",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`chatRoomId` TEXT NOT NULL, `dkgSessionId` TEXT NOT NULL, `thresholdPublicKey` TEXT NOT NULL, `derivationPath` TEXT NOT NULL, `announcedBy` TEXT NOT NULL, `announcedAt` INTEGER NOT NULL, `parentChatRoomId` TEXT, `birthCertificateJson` TEXT, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, `savedAt` INTEGER NOT NULL, PRIMARY KEY(`chatRoomId`), FOREIGN KEY(`chatRoomId`) REFERENCES `ChatRoom`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "chatRoomId",
+ "columnName": "chatRoomId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "dkgSessionId",
+ "columnName": "dkgSessionId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "thresholdPublicKey",
+ "columnName": "thresholdPublicKey",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "derivationPath",
+ "columnName": "derivationPath",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "announcedBy",
+ "columnName": "announcedBy",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "announcedAt",
+ "columnName": "announcedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "parentChatRoomId",
+ "columnName": "parentChatRoomId",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "birthCertificateJson",
+ "columnName": "birthCertificateJson",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "createdAt",
+ "columnName": "createdAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "updatedAt",
+ "columnName": "updatedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "savedAt",
+ "columnName": "savedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "chatRoomId"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_GroupKeyState_dkgSessionId",
+ "unique": false,
+ "columnNames": [
+ "dkgSessionId"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_GroupKeyState_dkgSessionId` ON `${TABLE_NAME}` (`dkgSessionId`)"
+ }
+ ],
+ "foreignKeys": [
+ {
+ "table": "ChatRoom",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "chatRoomId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "GroupSignedEvent",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `chatRoomId` TEXT NOT NULL, `publicKey` TEXT NOT NULL, `kind` INTEGER NOT NULL, `tags` TEXT NOT NULL, `content` TEXT NOT NULL, `signature` TEXT NOT NULL, `derivationPath` TEXT, `frostSigningSessionId` TEXT, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, `savedAt` INTEGER NOT NULL, PRIMARY KEY(`id`), FOREIGN KEY(`chatRoomId`) REFERENCES `ChatRoom`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "chatRoomId",
+ "columnName": "chatRoomId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "publicKey",
+ "columnName": "publicKey",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "kind",
+ "columnName": "kind",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "tags",
+ "columnName": "tags",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "content",
+ "columnName": "content",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "signature",
+ "columnName": "signature",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "derivationPath",
+ "columnName": "derivationPath",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "frostSigningSessionId",
+ "columnName": "frostSigningSessionId",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "createdAt",
+ "columnName": "createdAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "updatedAt",
+ "columnName": "updatedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "savedAt",
+ "columnName": "savedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_GroupSignedEvent_chatRoomId",
+ "unique": false,
+ "columnNames": [
+ "chatRoomId"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_GroupSignedEvent_chatRoomId` ON `${TABLE_NAME}` (`chatRoomId`)"
+ },
+ {
+ "name": "index_GroupSignedEvent_kind",
+ "unique": false,
+ "columnNames": [
+ "kind"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_GroupSignedEvent_kind` ON `${TABLE_NAME}` (`kind`)"
+ },
+ {
+ "name": "index_GroupSignedEvent_frostSigningSessionId",
+ "unique": false,
+ "columnNames": [
+ "frostSigningSessionId"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_GroupSignedEvent_frostSigningSessionId` ON `${TABLE_NAME}` (`frostSigningSessionId`)"
+ }
+ ],
+ "foreignKeys": [
+ {
+ "table": "ChatRoom",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "chatRoomId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "InReplyToRelation",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`replyingNostrEventId` TEXT NOT NULL, `inReplyToNostrEventId` TEXT NOT NULL, `inReplyToProfilePublicKey` TEXT, `inReplyToRootNostrEventId` TEXT, `inReplyToRootProfilePublicKey` TEXT, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, `savedAt` INTEGER NOT NULL, `viewedAt` INTEGER, `deletedAt` INTEGER, PRIMARY KEY(`replyingNostrEventId`, `inReplyToNostrEventId`), FOREIGN KEY(`inReplyToProfilePublicKey`) REFERENCES `Profile`(`publicKey`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`inReplyToRootProfilePublicKey`) REFERENCES `Profile`(`publicKey`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`replyingNostrEventId`) REFERENCES `NostrEvent`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`inReplyToNostrEventId`) REFERENCES `NostrEvent`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`inReplyToRootNostrEventId`) REFERENCES `NostrEvent`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "replyingNostrEventId",
+ "columnName": "replyingNostrEventId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "inReplyToNostrEventId",
+ "columnName": "inReplyToNostrEventId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "inReplyToProfilePublicKey",
+ "columnName": "inReplyToProfilePublicKey",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "inReplyToRootNostrEventId",
+ "columnName": "inReplyToRootNostrEventId",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "inReplyToRootProfilePublicKey",
+ "columnName": "inReplyToRootProfilePublicKey",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "createdAt",
+ "columnName": "createdAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "updatedAt",
+ "columnName": "updatedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "savedAt",
+ "columnName": "savedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "viewedAt",
+ "columnName": "viewedAt",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "deletedAt",
+ "columnName": "deletedAt",
+ "affinity": "INTEGER"
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "replyingNostrEventId",
+ "inReplyToNostrEventId"
+ ]
+ },
+ "foreignKeys": [
+ {
+ "table": "Profile",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "inReplyToProfilePublicKey"
+ ],
+ "referencedColumns": [
+ "publicKey"
+ ]
+ },
+ {
+ "table": "Profile",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "inReplyToRootProfilePublicKey"
+ ],
+ "referencedColumns": [
+ "publicKey"
+ ]
+ },
+ {
+ "table": "NostrEvent",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "replyingNostrEventId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ },
+ {
+ "table": "NostrEvent",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "inReplyToNostrEventId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ },
+ {
+ "table": "NostrEvent",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "inReplyToRootNostrEventId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "MantraArtifact",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `publicKey` TEXT NOT NULL, `name` TEXT NOT NULL, `url` TEXT NOT NULL, `visibility` TEXT NOT NULL, `dialectId` TEXT NOT NULL, `license` TEXT NOT NULL, `chatRoomId` TEXT NOT NULL, `signature` TEXT NOT NULL, `relayHint` TEXT, `marmotGroupEventId` TEXT, `groupSignedEventId` TEXT, `nostrEventId` TEXT, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, PRIMARY KEY(`id`), FOREIGN KEY(`dialectId`) REFERENCES `MantraDialect`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`chatRoomId`) REFERENCES `ChatRoom`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "publicKey",
+ "columnName": "publicKey",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "name",
+ "columnName": "name",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "url",
+ "columnName": "url",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "visibility",
+ "columnName": "visibility",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "dialectId",
+ "columnName": "dialectId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "license",
+ "columnName": "license",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "chatRoomId",
+ "columnName": "chatRoomId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "signature",
+ "columnName": "signature",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "relayHint",
+ "columnName": "relayHint",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "marmotGroupEventId",
+ "columnName": "marmotGroupEventId",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "groupSignedEventId",
+ "columnName": "groupSignedEventId",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "nostrEventId",
+ "columnName": "nostrEventId",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "createdAt",
+ "columnName": "createdAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "updatedAt",
+ "columnName": "updatedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "foreignKeys": [
+ {
+ "table": "MantraDialect",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "dialectId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ },
+ {
+ "table": "ChatRoom",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "chatRoomId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "MantraArtifactVersion",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `artifactId` TEXT NOT NULL, `publicKey` TEXT NOT NULL, `versionLabel` TEXT NOT NULL, `signature` TEXT NOT NULL, `chatRoomId` TEXT NOT NULL, `relayHint` TEXT, `marmotGroupEventId` TEXT, `groupSignedEventId` TEXT, `nostrEventId` TEXT, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, PRIMARY KEY(`id`), FOREIGN KEY(`artifactId`) REFERENCES `MantraArtifact`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`chatRoomId`) REFERENCES `ChatRoom`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "artifactId",
+ "columnName": "artifactId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "publicKey",
+ "columnName": "publicKey",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "versionLabel",
+ "columnName": "versionLabel",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "signature",
+ "columnName": "signature",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "chatRoomId",
+ "columnName": "chatRoomId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "relayHint",
+ "columnName": "relayHint",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "marmotGroupEventId",
+ "columnName": "marmotGroupEventId",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "groupSignedEventId",
+ "columnName": "groupSignedEventId",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "nostrEventId",
+ "columnName": "nostrEventId",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "createdAt",
+ "columnName": "createdAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "updatedAt",
+ "columnName": "updatedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "foreignKeys": [
+ {
+ "table": "MantraArtifact",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "artifactId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ },
+ {
+ "table": "ChatRoom",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "chatRoomId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "MantraChapter",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `artifactVersionId` TEXT NOT NULL, `publicKey` TEXT NOT NULL, `name` TEXT NOT NULL, `originalText` TEXT NOT NULL, `index` INTEGER NOT NULL, `wordCount` INTEGER NOT NULL, `characterCount` INTEGER NOT NULL, `signature` TEXT NOT NULL, `chatRoomId` TEXT NOT NULL, `relayHint` TEXT, `marmotGroupEventId` TEXT, `groupSignedEventId` TEXT, `nostrEventId` TEXT, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, PRIMARY KEY(`id`), FOREIGN KEY(`artifactVersionId`) REFERENCES `MantraArtifactVersion`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`chatRoomId`) REFERENCES `ChatRoom`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "artifactVersionId",
+ "columnName": "artifactVersionId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "publicKey",
+ "columnName": "publicKey",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "name",
+ "columnName": "name",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "originalText",
+ "columnName": "originalText",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "index",
+ "columnName": "index",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "wordCount",
+ "columnName": "wordCount",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "characterCount",
+ "columnName": "characterCount",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "signature",
+ "columnName": "signature",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "chatRoomId",
+ "columnName": "chatRoomId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "relayHint",
+ "columnName": "relayHint",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "marmotGroupEventId",
+ "columnName": "marmotGroupEventId",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "groupSignedEventId",
+ "columnName": "groupSignedEventId",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "nostrEventId",
+ "columnName": "nostrEventId",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "createdAt",
+ "columnName": "createdAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "updatedAt",
+ "columnName": "updatedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "foreignKeys": [
+ {
+ "table": "MantraArtifactVersion",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "artifactVersionId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ },
+ {
+ "table": "ChatRoom",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "chatRoomId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "MantraChunk",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `chapterId` TEXT NOT NULL, `publicKey` TEXT NOT NULL, `text` TEXT NOT NULL, `index` INTEGER NOT NULL, `wordCount` INTEGER NOT NULL, `characterCount` INTEGER NOT NULL, `signature` TEXT NOT NULL, `chatRoomId` TEXT NOT NULL, `relayHint` TEXT, `marmotGroupEventId` TEXT, `groupSignedEventId` TEXT, `nostrEventId` TEXT, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, PRIMARY KEY(`id`), FOREIGN KEY(`chapterId`) REFERENCES `MantraChapter`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`chatRoomId`) REFERENCES `ChatRoom`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "chapterId",
+ "columnName": "chapterId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "publicKey",
+ "columnName": "publicKey",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "text",
+ "columnName": "text",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "index",
+ "columnName": "index",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "wordCount",
+ "columnName": "wordCount",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "characterCount",
+ "columnName": "characterCount",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "signature",
+ "columnName": "signature",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "chatRoomId",
+ "columnName": "chatRoomId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "relayHint",
+ "columnName": "relayHint",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "marmotGroupEventId",
+ "columnName": "marmotGroupEventId",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "groupSignedEventId",
+ "columnName": "groupSignedEventId",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "nostrEventId",
+ "columnName": "nostrEventId",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "createdAt",
+ "columnName": "createdAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "updatedAt",
+ "columnName": "updatedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "foreignKeys": [
+ {
+ "table": "MantraChapter",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "chapterId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ },
+ {
+ "table": "ChatRoom",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "chatRoomId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "MantraDialect",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `publicKey` TEXT NOT NULL, `name` TEXT NOT NULL, `country` TEXT NOT NULL, `language` TEXT NOT NULL, `signature` TEXT NOT NULL, `chatRoomId` TEXT NOT NULL, `relayHint` TEXT, `marmotGroupEventId` TEXT, `groupSignedEventId` TEXT, `nostrEventId` TEXT, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, PRIMARY KEY(`id`), FOREIGN KEY(`chatRoomId`) REFERENCES `ChatRoom`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "publicKey",
+ "columnName": "publicKey",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "name",
+ "columnName": "name",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "country",
+ "columnName": "country",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "language",
+ "columnName": "language",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "signature",
+ "columnName": "signature",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "chatRoomId",
+ "columnName": "chatRoomId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "relayHint",
+ "columnName": "relayHint",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "marmotGroupEventId",
+ "columnName": "marmotGroupEventId",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "groupSignedEventId",
+ "columnName": "groupSignedEventId",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "nostrEventId",
+ "columnName": "nostrEventId",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "createdAt",
+ "columnName": "createdAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "updatedAt",
+ "columnName": "updatedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "foreignKeys": [
+ {
+ "table": "ChatRoom",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "chatRoomId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "MantraTranslation",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `publicKey` TEXT NOT NULL, `translationChunkId` TEXT NOT NULL, `translationArtifactVersionId` TEXT NOT NULL, `text` TEXT NOT NULL, `signature` TEXT NOT NULL, `chatRoomId` TEXT NOT NULL, `relayHint` TEXT, `marmotGroupEventId` TEXT, `groupSignedEventId` TEXT, `nostrEventId` TEXT, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, PRIMARY KEY(`id`), FOREIGN KEY(`translationChunkId`) REFERENCES `MantraTranslationChunk`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`translationArtifactVersionId`) REFERENCES `MantraTranslationArtifactVersion`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`chatRoomId`) REFERENCES `ChatRoom`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "publicKey",
+ "columnName": "publicKey",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "translationChunkId",
+ "columnName": "translationChunkId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "translationArtifactVersionId",
+ "columnName": "translationArtifactVersionId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "text",
+ "columnName": "text",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "signature",
+ "columnName": "signature",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "chatRoomId",
+ "columnName": "chatRoomId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "relayHint",
+ "columnName": "relayHint",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "marmotGroupEventId",
+ "columnName": "marmotGroupEventId",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "groupSignedEventId",
+ "columnName": "groupSignedEventId",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "nostrEventId",
+ "columnName": "nostrEventId",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "createdAt",
+ "columnName": "createdAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "updatedAt",
+ "columnName": "updatedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "foreignKeys": [
+ {
+ "table": "MantraTranslationChunk",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "translationChunkId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ },
+ {
+ "table": "MantraTranslationArtifactVersion",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "translationArtifactVersionId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ },
+ {
+ "table": "ChatRoom",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "chatRoomId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "MantraTranslationArtifactVersion",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `publicKey` TEXT NOT NULL, `artifactVersionId` TEXT NOT NULL, `dialectId` TEXT NOT NULL, `name` TEXT NOT NULL, `visibility` TEXT NOT NULL, `license` TEXT NOT NULL, `signature` TEXT NOT NULL, `chatRoomId` TEXT NOT NULL, `relayHint` TEXT, `marmotGroupEventId` TEXT, `groupSignedEventId` TEXT, `nostrEventId` TEXT, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, PRIMARY KEY(`id`), FOREIGN KEY(`artifactVersionId`) REFERENCES `MantraArtifactVersion`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`dialectId`) REFERENCES `MantraDialect`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`chatRoomId`) REFERENCES `ChatRoom`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "publicKey",
+ "columnName": "publicKey",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "artifactVersionId",
+ "columnName": "artifactVersionId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "dialectId",
+ "columnName": "dialectId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "name",
+ "columnName": "name",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "visibility",
+ "columnName": "visibility",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "license",
+ "columnName": "license",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "signature",
+ "columnName": "signature",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "chatRoomId",
+ "columnName": "chatRoomId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "relayHint",
+ "columnName": "relayHint",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "marmotGroupEventId",
+ "columnName": "marmotGroupEventId",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "groupSignedEventId",
+ "columnName": "groupSignedEventId",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "nostrEventId",
+ "columnName": "nostrEventId",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "createdAt",
+ "columnName": "createdAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "updatedAt",
+ "columnName": "updatedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "foreignKeys": [
+ {
+ "table": "MantraArtifactVersion",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "artifactVersionId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ },
+ {
+ "table": "MantraDialect",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "dialectId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ },
+ {
+ "table": "ChatRoom",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "chatRoomId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "MantraTranslationArtifactVersionContributor",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `publicKey` TEXT NOT NULL, `translationArtifactVersionId` TEXT NOT NULL, `editorPublicKey` TEXT NOT NULL, `signature` TEXT NOT NULL, `chatRoomId` TEXT NOT NULL, `relayHint` TEXT, `marmotGroupEventId` TEXT, `groupSignedEventId` TEXT, `nostrEventId` TEXT, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, PRIMARY KEY(`id`), FOREIGN KEY(`translationArtifactVersionId`) REFERENCES `MantraTranslationArtifactVersionContributor`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`chatRoomId`) REFERENCES `ChatRoom`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "publicKey",
+ "columnName": "publicKey",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "translationArtifactVersionId",
+ "columnName": "translationArtifactVersionId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "editorPublicKey",
+ "columnName": "editorPublicKey",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "signature",
+ "columnName": "signature",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "chatRoomId",
+ "columnName": "chatRoomId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "relayHint",
+ "columnName": "relayHint",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "marmotGroupEventId",
+ "columnName": "marmotGroupEventId",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "groupSignedEventId",
+ "columnName": "groupSignedEventId",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "nostrEventId",
+ "columnName": "nostrEventId",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "createdAt",
+ "columnName": "createdAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "updatedAt",
+ "columnName": "updatedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "foreignKeys": [
+ {
+ "table": "MantraTranslationArtifactVersionContributor",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "translationArtifactVersionId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ },
+ {
+ "table": "ChatRoom",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "chatRoomId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "MantraTranslationChapter",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `publicKey` TEXT NOT NULL, `chapterId` TEXT NOT NULL, `translationArtifactVersionId` TEXT NOT NULL, `index` INTEGER NOT NULL, `signature` TEXT NOT NULL, `chatRoomId` TEXT NOT NULL, `relayHint` TEXT, `marmotGroupEventId` TEXT, `groupSignedEventId` TEXT, `nostrEventId` TEXT, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, PRIMARY KEY(`id`), FOREIGN KEY(`translationArtifactVersionId`) REFERENCES `MantraTranslationArtifactVersion`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`chapterId`) REFERENCES `MantraChapter`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`chatRoomId`) REFERENCES `ChatRoom`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "publicKey",
+ "columnName": "publicKey",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "chapterId",
+ "columnName": "chapterId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "translationArtifactVersionId",
+ "columnName": "translationArtifactVersionId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "index",
+ "columnName": "index",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "signature",
+ "columnName": "signature",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "chatRoomId",
+ "columnName": "chatRoomId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "relayHint",
+ "columnName": "relayHint",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "marmotGroupEventId",
+ "columnName": "marmotGroupEventId",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "groupSignedEventId",
+ "columnName": "groupSignedEventId",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "nostrEventId",
+ "columnName": "nostrEventId",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "createdAt",
+ "columnName": "createdAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "updatedAt",
+ "columnName": "updatedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "foreignKeys": [
+ {
+ "table": "MantraTranslationArtifactVersion",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "translationArtifactVersionId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ },
+ {
+ "table": "MantraChapter",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "chapterId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ },
+ {
+ "table": "ChatRoom",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "chatRoomId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "MantraTranslationChapterContributor",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `publicKey` TEXT NOT NULL, `translationChapterId` TEXT NOT NULL, `translatorPublicKey` TEXT NOT NULL, `role` TEXT NOT NULL, `signature` TEXT NOT NULL, `chatRoomId` TEXT NOT NULL, `relayHint` TEXT, `marmotGroupEventId` TEXT, `groupSignedEventId` TEXT, `nostrEventId` TEXT, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, PRIMARY KEY(`id`), FOREIGN KEY(`translationChapterId`) REFERENCES `MantraTranslationChapter`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`chatRoomId`) REFERENCES `ChatRoom`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "publicKey",
+ "columnName": "publicKey",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "translationChapterId",
+ "columnName": "translationChapterId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "translatorPublicKey",
+ "columnName": "translatorPublicKey",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "role",
+ "columnName": "role",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "signature",
+ "columnName": "signature",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "chatRoomId",
+ "columnName": "chatRoomId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "relayHint",
+ "columnName": "relayHint",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "marmotGroupEventId",
+ "columnName": "marmotGroupEventId",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "groupSignedEventId",
+ "columnName": "groupSignedEventId",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "nostrEventId",
+ "columnName": "nostrEventId",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "createdAt",
+ "columnName": "createdAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "updatedAt",
+ "columnName": "updatedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "foreignKeys": [
+ {
+ "table": "MantraTranslationChapter",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "translationChapterId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ },
+ {
+ "table": "ChatRoom",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "chatRoomId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "MantraTranslationChunk",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `publicKey` TEXT NOT NULL, `chunkId` TEXT NOT NULL, `translationChapterId` TEXT NOT NULL, `text` TEXT NOT NULL, `index` INTEGER NOT NULL, `signature` TEXT NOT NULL, `chatRoomId` TEXT NOT NULL, `relayHint` TEXT, `marmotGroupEventId` TEXT, `groupSignedEventId` TEXT, `nostrEventId` TEXT, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, PRIMARY KEY(`id`), FOREIGN KEY(`chunkId`) REFERENCES `MantraChunk`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`translationChapterId`) REFERENCES `MantraTranslationChapter`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`chatRoomId`) REFERENCES `ChatRoom`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "publicKey",
+ "columnName": "publicKey",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "chunkId",
+ "columnName": "chunkId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "translationChapterId",
+ "columnName": "translationChapterId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "text",
+ "columnName": "text",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "index",
+ "columnName": "index",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "signature",
+ "columnName": "signature",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "chatRoomId",
+ "columnName": "chatRoomId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "relayHint",
+ "columnName": "relayHint",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "marmotGroupEventId",
+ "columnName": "marmotGroupEventId",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "groupSignedEventId",
+ "columnName": "groupSignedEventId",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "nostrEventId",
+ "columnName": "nostrEventId",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "createdAt",
+ "columnName": "createdAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "updatedAt",
+ "columnName": "updatedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "foreignKeys": [
+ {
+ "table": "MantraChunk",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "chunkId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ },
+ {
+ "table": "MantraTranslationChapter",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "translationChapterId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ },
+ {
+ "table": "ChatRoom",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "chatRoomId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "MantraTranslationContributor",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `dTag` TEXT NOT NULL, `publicKey` TEXT NOT NULL, `translationId` TEXT NOT NULL, `translatorPublicKey` TEXT NOT NULL, `signature` TEXT NOT NULL, `chatRoomId` TEXT NOT NULL, `relayHint` TEXT, `marmotGroupEventId` TEXT, `groupSignedEventId` TEXT, `nostrEventId` TEXT, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, PRIMARY KEY(`id`), FOREIGN KEY(`translationId`) REFERENCES `MantraTranslation`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`chatRoomId`) REFERENCES `ChatRoom`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "dTag",
+ "columnName": "dTag",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "publicKey",
+ "columnName": "publicKey",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "translationId",
+ "columnName": "translationId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "translatorPublicKey",
+ "columnName": "translatorPublicKey",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "signature",
+ "columnName": "signature",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "chatRoomId",
+ "columnName": "chatRoomId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "relayHint",
+ "columnName": "relayHint",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "marmotGroupEventId",
+ "columnName": "marmotGroupEventId",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "groupSignedEventId",
+ "columnName": "groupSignedEventId",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "nostrEventId",
+ "columnName": "nostrEventId",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "createdAt",
+ "columnName": "createdAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "updatedAt",
+ "columnName": "updatedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "foreignKeys": [
+ {
+ "table": "MantraTranslation",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "translationId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ },
+ {
+ "table": "ChatRoom",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "chatRoomId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "MarmotCommitResult",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `userPublicKey` TEXT NOT NULL, `peerKeyPackageEventId` TEXT NOT NULL, `chatRoomId` TEXT NOT NULL, `isOneMemberInitialGroupCreation` INTEGER NOT NULL, `commitBytes` BLOB NOT NULL, `welcomeBytes` BLOB, `groupInfoBytes` BLOB, `framedCommitBytes` BLOB NOT NULL, `preCommitExporterSecret` BLOB NOT NULL, `obligationId` TEXT, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, `savedAt` INTEGER NOT NULL, `viewedAt` INTEGER, `deletedAt` INTEGER, PRIMARY KEY(`id`))",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "userPublicKey",
+ "columnName": "userPublicKey",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "peerKeyPackageEventId",
+ "columnName": "peerKeyPackageEventId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "chatRoomId",
+ "columnName": "chatRoomId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "isOneMemberInitialGroupCreation",
+ "columnName": "isOneMemberInitialGroupCreation",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "commitBytes",
+ "columnName": "commitBytes",
+ "affinity": "BLOB",
+ "notNull": true
+ },
+ {
+ "fieldPath": "welcomeBytes",
+ "columnName": "welcomeBytes",
+ "affinity": "BLOB"
+ },
+ {
+ "fieldPath": "groupInfoBytes",
+ "columnName": "groupInfoBytes",
+ "affinity": "BLOB"
+ },
+ {
+ "fieldPath": "framedCommitBytes",
+ "columnName": "framedCommitBytes",
+ "affinity": "BLOB",
+ "notNull": true
+ },
+ {
+ "fieldPath": "preCommitExporterSecret",
+ "columnName": "preCommitExporterSecret",
+ "affinity": "BLOB",
+ "notNull": true
+ },
+ {
+ "fieldPath": "obligationId",
+ "columnName": "obligationId",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "createdAt",
+ "columnName": "createdAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "updatedAt",
+ "columnName": "updatedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "savedAt",
+ "columnName": "savedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "viewedAt",
+ "columnName": "viewedAt",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "deletedAt",
+ "columnName": "deletedAt",
+ "affinity": "INTEGER"
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "id"
+ ]
+ }
+ },
+ {
+ "tableName": "MarmotGroupEvent",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `userPublicKey` TEXT NOT NULL, `publicKey` TEXT NOT NULL, `chatRoomId` TEXT NOT NULL, `signature` TEXT NOT NULL, `encryptedContent` TEXT NOT NULL, `expiresAt` INTEGER, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, `savedAt` INTEGER NOT NULL, `deletedAt` INTEGER, `broadcastedAt` INTEGER, PRIMARY KEY(`id`), FOREIGN KEY(`id`) REFERENCES `NostrEvent`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "userPublicKey",
+ "columnName": "userPublicKey",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "publicKey",
+ "columnName": "publicKey",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "chatRoomId",
+ "columnName": "chatRoomId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "signature",
+ "columnName": "signature",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "encryptedContent",
+ "columnName": "encryptedContent",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "expiresAt",
+ "columnName": "expiresAt",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "createdAt",
+ "columnName": "createdAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "updatedAt",
+ "columnName": "updatedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "savedAt",
+ "columnName": "savedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "deletedAt",
+ "columnName": "deletedAt",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "broadcastedAt",
+ "columnName": "broadcastedAt",
+ "affinity": "INTEGER"
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "foreignKeys": [
+ {
+ "table": "NostrEvent",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "id"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "MarmotInnerEvent",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `publicKey` TEXT NOT NULL, `chatRoomId` TEXT NOT NULL, `kind` INTEGER NOT NULL, `tags` TEXT NOT NULL, `content` TEXT NOT NULL, `quotedEventId` TEXT, `payloadEventId` TEXT, `marmotGroupEventId` TEXT, `directMessageRecipientPublicKey` TEXT, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, `savedAt` INTEGER NOT NULL, `viewedAt` INTEGER, `deletedAt` INTEGER, PRIMARY KEY(`id`), FOREIGN KEY(`marmotGroupEventId`) REFERENCES `MarmotGroupEvent`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "publicKey",
+ "columnName": "publicKey",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "chatRoomId",
+ "columnName": "chatRoomId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "kind",
+ "columnName": "kind",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "tags",
+ "columnName": "tags",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "content",
+ "columnName": "content",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "quotedEventId",
+ "columnName": "quotedEventId",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "payloadEventId",
+ "columnName": "payloadEventId",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "marmotGroupEventId",
+ "columnName": "marmotGroupEventId",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "directMessageRecipientPublicKey",
+ "columnName": "directMessageRecipientPublicKey",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "createdAt",
+ "columnName": "createdAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "updatedAt",
+ "columnName": "updatedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "savedAt",
+ "columnName": "savedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "viewedAt",
+ "columnName": "viewedAt",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "deletedAt",
+ "columnName": "deletedAt",
+ "affinity": "INTEGER"
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "foreignKeys": [
+ {
+ "table": "MarmotGroupEvent",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "marmotGroupEventId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "MarmotKeyPackage",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `publicKey` TEXT NOT NULL, `tlsEncodedMarmotKeyPackage` BLOB NOT NULL, `profile` TEXT, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, `savedAt` INTEGER NOT NULL, `deletedAt` INTEGER, `broadcastedAt` INTEGER, PRIMARY KEY(`id`), FOREIGN KEY(`publicKey`) REFERENCES `Profile`(`publicKey`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "publicKey",
+ "columnName": "publicKey",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "tlsEncodedMarmotKeyPackage",
+ "columnName": "tlsEncodedMarmotKeyPackage",
+ "affinity": "BLOB",
+ "notNull": true
+ },
+ {
+ "fieldPath": "profile",
+ "columnName": "profile",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "createdAt",
+ "columnName": "createdAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "updatedAt",
+ "columnName": "updatedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "savedAt",
+ "columnName": "savedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "deletedAt",
+ "columnName": "deletedAt",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "broadcastedAt",
+ "columnName": "broadcastedAt",
+ "affinity": "INTEGER"
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "foreignKeys": [
+ {
+ "table": "Profile",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "publicKey"
+ ],
+ "referencedColumns": [
+ "publicKey"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "MarmotKeyPackageBundle",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `publicKey` TEXT NOT NULL, `tlsEncodedMarmotKeyPackage` BLOB NOT NULL, `ncryptsecInitPrivateKey` TEXT NOT NULL, `ncryptsecEncryptionPrivateKey` TEXT NOT NULL, `ncryptsecSignaturePrivateKey` TEXT NOT NULL, `consumed` INTEGER NOT NULL, `rotated` INTEGER NOT NULL, `profile` TEXT, `dTag` TEXT, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, `savedAt` INTEGER NOT NULL, `deletedAt` INTEGER, `broadcastedAt` INTEGER, PRIMARY KEY(`id`))",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "publicKey",
+ "columnName": "publicKey",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "tlsEncodedMarmotKeyPackage",
+ "columnName": "tlsEncodedMarmotKeyPackage",
+ "affinity": "BLOB",
+ "notNull": true
+ },
+ {
+ "fieldPath": "ncryptsecInitPrivateKey",
+ "columnName": "ncryptsecInitPrivateKey",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "ncryptsecEncryptionPrivateKey",
+ "columnName": "ncryptsecEncryptionPrivateKey",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "ncryptsecSignaturePrivateKey",
+ "columnName": "ncryptsecSignaturePrivateKey",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "consumed",
+ "columnName": "consumed",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "rotated",
+ "columnName": "rotated",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "profile",
+ "columnName": "profile",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "dTag",
+ "columnName": "dTag",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "createdAt",
+ "columnName": "createdAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "updatedAt",
+ "columnName": "updatedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "savedAt",
+ "columnName": "savedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "deletedAt",
+ "columnName": "deletedAt",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "broadcastedAt",
+ "columnName": "broadcastedAt",
+ "affinity": "INTEGER"
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_MarmotKeyPackageBundle_publicKey",
+ "unique": false,
+ "columnNames": [
+ "publicKey"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_MarmotKeyPackageBundle_publicKey` ON `${TABLE_NAME}` (`publicKey`)"
+ }
+ ]
+ },
+ {
+ "tableName": "MarmotRouting",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`routingId` TEXT NOT NULL, `chatRoomId` TEXT NOT NULL, `activeFromEpoch` INTEGER NOT NULL, `retiredAtEpoch` INTEGER, PRIMARY KEY(`routingId`), FOREIGN KEY(`chatRoomId`) REFERENCES `ChatRoom`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "routingId",
+ "columnName": "routingId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "chatRoomId",
+ "columnName": "chatRoomId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "activeFromEpoch",
+ "columnName": "activeFromEpoch",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "retiredAtEpoch",
+ "columnName": "retiredAtEpoch",
+ "affinity": "INTEGER"
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "routingId"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_MarmotRouting_chatRoomId",
+ "unique": false,
+ "columnNames": [
+ "chatRoomId"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_MarmotRouting_chatRoomId` ON `${TABLE_NAME}` (`chatRoomId`)"
+ }
+ ],
+ "foreignKeys": [
+ {
+ "table": "ChatRoom",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "chatRoomId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "MarmotPublishObligation",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`obligationId` TEXT NOT NULL, `bytes` BLOB NOT NULL, PRIMARY KEY(`obligationId`))",
+ "fields": [
+ {
+ "fieldPath": "obligationId",
+ "columnName": "obligationId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "bytes",
+ "columnName": "bytes",
+ "affinity": "BLOB",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "obligationId"
+ ]
+ }
+ },
+ {
+ "tableName": "MarmotOutboundGate",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`groupId` TEXT NOT NULL, `gate` TEXT NOT NULL, PRIMARY KEY(`groupId`))",
+ "fields": [
+ {
+ "fieldPath": "groupId",
+ "columnName": "groupId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "gate",
+ "columnName": "gate",
+ "affinity": "TEXT",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "groupId"
+ ]
+ }
+ },
+ {
+ "tableName": "MarmotRetainedEpochSecret",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`chatRoomId` TEXT NOT NULL, `epoch` INTEGER NOT NULL, `senderDataSecret` BLOB NOT NULL, `encryptionSecret` BLOB NOT NULL, `leafCount` INTEGER NOT NULL, `exporterSecret` BLOB NOT NULL, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, `savedAt` INTEGER NOT NULL, PRIMARY KEY(`chatRoomId`, `epoch`), FOREIGN KEY(`chatRoomId`) REFERENCES `ChatRoom`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "chatRoomId",
+ "columnName": "chatRoomId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "epoch",
+ "columnName": "epoch",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "senderDataSecret",
+ "columnName": "senderDataSecret",
+ "affinity": "BLOB",
+ "notNull": true
+ },
+ {
+ "fieldPath": "encryptionSecret",
+ "columnName": "encryptionSecret",
+ "affinity": "BLOB",
+ "notNull": true
+ },
+ {
+ "fieldPath": "leafCount",
+ "columnName": "leafCount",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "exporterSecret",
+ "columnName": "exporterSecret",
+ "affinity": "BLOB",
+ "notNull": true
+ },
+ {
+ "fieldPath": "createdAt",
+ "columnName": "createdAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "updatedAt",
+ "columnName": "updatedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "savedAt",
+ "columnName": "savedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "chatRoomId",
+ "epoch"
+ ]
+ },
+ "foreignKeys": [
+ {
+ "table": "ChatRoom",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "chatRoomId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "Mention",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `mentionedPublicKey` TEXT NOT NULL, `mentioningNostrEventId` TEXT, `relayUrl` TEXT, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, `savedAt` INTEGER NOT NULL, `deletedAt` INTEGER, `broadcastedAt` INTEGER, FOREIGN KEY(`mentionedPublicKey`) REFERENCES `Profile`(`publicKey`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`mentioningNostrEventId`) REFERENCES `NostrEvent`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "mentionedPublicKey",
+ "columnName": "mentionedPublicKey",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "mentioningNostrEventId",
+ "columnName": "mentioningNostrEventId",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "relayUrl",
+ "columnName": "relayUrl",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "createdAt",
+ "columnName": "createdAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "updatedAt",
+ "columnName": "updatedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "savedAt",
+ "columnName": "savedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "deletedAt",
+ "columnName": "deletedAt",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "broadcastedAt",
+ "columnName": "broadcastedAt",
+ "affinity": "INTEGER"
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": true,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "foreignKeys": [
+ {
+ "table": "Profile",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "mentionedPublicKey"
+ ],
+ "referencedColumns": [
+ "publicKey"
+ ]
+ },
+ {
+ "table": "NostrEvent",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "mentioningNostrEventId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "NegentropySynchronizeRequest",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `uuid` TEXT NOT NULL, `purpose` TEXT NOT NULL, `status` TEXT NOT NULL, `relayURL` TEXT NOT NULL, `isRecommendedRelay` INTEGER NOT NULL, `level` INTEGER NOT NULL, `synchronizationFilter` TEXT NOT NULL, `ownerPublicKey` TEXT, `nostrEventId` TEXT, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, PRIMARY KEY(`id`), FOREIGN KEY(`nostrEventId`) REFERENCES `NostrEvent`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "uuid",
+ "columnName": "uuid",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "purpose",
+ "columnName": "purpose",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "status",
+ "columnName": "status",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "relayURL",
+ "columnName": "relayURL",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "isRecommendedRelay",
+ "columnName": "isRecommendedRelay",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "level",
+ "columnName": "level",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "synchronizationFilter",
+ "columnName": "synchronizationFilter",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "ownerPublicKey",
+ "columnName": "ownerPublicKey",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "nostrEventId",
+ "columnName": "nostrEventId",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "createdAt",
+ "columnName": "createdAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "updatedAt",
+ "columnName": "updatedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_NegentropySynchronizeRequest_nostrEventId",
+ "unique": false,
+ "columnNames": [
+ "nostrEventId"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_NegentropySynchronizeRequest_nostrEventId` ON `${TABLE_NAME}` (`nostrEventId`)"
+ },
+ {
+ "name": "index_NegentropySynchronizeRequest_status",
+ "unique": false,
+ "columnNames": [
+ "status"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_NegentropySynchronizeRequest_status` ON `${TABLE_NAME}` (`status`)"
+ }
+ ],
+ "foreignKeys": [
+ {
+ "table": "NostrEvent",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "nostrEventId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "NegentropySynchronizeResult",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `relayURL` TEXT NOT NULL, `status` TEXT NOT NULL, `negentropySynchronizeRequestId` TEXT NOT NULL, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, PRIMARY KEY(`id`), FOREIGN KEY(`negentropySynchronizeRequestId`) REFERENCES `SynchronizeNostrEventResult`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "relayURL",
+ "columnName": "relayURL",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "status",
+ "columnName": "status",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "negentropySynchronizeRequestId",
+ "columnName": "negentropySynchronizeRequestId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "createdAt",
+ "columnName": "createdAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "updatedAt",
+ "columnName": "updatedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "foreignKeys": [
+ {
+ "table": "SynchronizeNostrEventResult",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "negentropySynchronizeRequestId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "NostrEvent",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `pubKey` TEXT NOT NULL, `kind` INTEGER NOT NULL, `tags` TEXT NOT NULL, `content` TEXT NOT NULL, `sig` TEXT NOT NULL, `relayUrl` TEXT, `quotedNostrEventId` TEXT, `quotedAuthorPublicKey` TEXT, `inReplyToNostrEventId` TEXT, `inReplyToAuthorPublicKey` TEXT, `inReplyToRootNostrEventId` TEXT, `inReplyToRootAuthorPublicKey` TEXT, `repostedNostrEventId` TEXT, `repostedAuthorPublicKey` TEXT, `unsignedNostrEventId` INTEGER, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, `savedAt` INTEGER NOT NULL, `deletedAt` INTEGER, `broadcastedAt` INTEGER, PRIMARY KEY(`id`))",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "pubKey",
+ "columnName": "pubKey",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "kind",
+ "columnName": "kind",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "tags",
+ "columnName": "tags",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "content",
+ "columnName": "content",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "sig",
+ "columnName": "sig",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "relayUrl",
+ "columnName": "relayUrl",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "quotedNostrEventId",
+ "columnName": "quotedNostrEventId",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "quotedAuthorPublicKey",
+ "columnName": "quotedAuthorPublicKey",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "inReplyToNostrEventId",
+ "columnName": "inReplyToNostrEventId",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "inReplyToAuthorPublicKey",
+ "columnName": "inReplyToAuthorPublicKey",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "inReplyToRootNostrEventId",
+ "columnName": "inReplyToRootNostrEventId",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "inReplyToRootAuthorPublicKey",
+ "columnName": "inReplyToRootAuthorPublicKey",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "repostedNostrEventId",
+ "columnName": "repostedNostrEventId",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "repostedAuthorPublicKey",
+ "columnName": "repostedAuthorPublicKey",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "unsignedNostrEventId",
+ "columnName": "unsignedNostrEventId",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "createdAt",
+ "columnName": "createdAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "updatedAt",
+ "columnName": "updatedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "savedAt",
+ "columnName": "savedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "deletedAt",
+ "columnName": "deletedAt",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "broadcastedAt",
+ "columnName": "broadcastedAt",
+ "affinity": "INTEGER"
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_NostrEvent_kind",
+ "unique": false,
+ "columnNames": [
+ "kind"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_NostrEvent_kind` ON `${TABLE_NAME}` (`kind`)"
+ },
+ {
+ "name": "index_NostrEvent_pubKey",
+ "unique": false,
+ "columnNames": [
+ "pubKey"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_NostrEvent_pubKey` ON `${TABLE_NAME}` (`pubKey`)"
+ },
+ {
+ "name": "index_NostrEvent_quotedNostrEventId",
+ "unique": false,
+ "columnNames": [
+ "quotedNostrEventId"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_NostrEvent_quotedNostrEventId` ON `${TABLE_NAME}` (`quotedNostrEventId`)"
+ },
+ {
+ "name": "index_NostrEvent_inReplyToNostrEventId",
+ "unique": false,
+ "columnNames": [
+ "inReplyToNostrEventId"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_NostrEvent_inReplyToNostrEventId` ON `${TABLE_NAME}` (`inReplyToNostrEventId`)"
+ },
+ {
+ "name": "index_NostrEvent_inReplyToRootNostrEventId",
+ "unique": false,
+ "columnNames": [
+ "inReplyToRootNostrEventId"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_NostrEvent_inReplyToRootNostrEventId` ON `${TABLE_NAME}` (`inReplyToRootNostrEventId`)"
+ }
+ ]
+ },
+ {
+ "tableName": "NostrEventRelay",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`relayURL` TEXT NOT NULL, `nostrEventId` TEXT NOT NULL, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, PRIMARY KEY(`nostrEventId`, `relayURL`), FOREIGN KEY(`nostrEventId`) REFERENCES `NostrEvent`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "relayURL",
+ "columnName": "relayURL",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "nostrEventId",
+ "columnName": "nostrEventId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "createdAt",
+ "columnName": "createdAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "updatedAt",
+ "columnName": "updatedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "nostrEventId",
+ "relayURL"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_NostrEventRelay_relayURL",
+ "unique": false,
+ "columnNames": [
+ "relayURL"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_NostrEventRelay_relayURL` ON `${TABLE_NAME}` (`relayURL`)"
+ }
+ ],
+ "foreignKeys": [
+ {
+ "table": "NostrEvent",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "nostrEventId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "Participant",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `participantPublicKey` TEXT NOT NULL, `chatRoomId` TEXT NOT NULL, `relayHint` TEXT, `adminAt` INTEGER, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, `savedAt` INTEGER NOT NULL, `deletedAt` INTEGER, `broadcastedAt` INTEGER, FOREIGN KEY(`participantPublicKey`) REFERENCES `Profile`(`publicKey`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`chatRoomId`) REFERENCES `ChatRoom`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "participantPublicKey",
+ "columnName": "participantPublicKey",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "chatRoomId",
+ "columnName": "chatRoomId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "relayHint",
+ "columnName": "relayHint",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "adminAt",
+ "columnName": "adminAt",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "createdAt",
+ "columnName": "createdAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "updatedAt",
+ "columnName": "updatedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "savedAt",
+ "columnName": "savedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "deletedAt",
+ "columnName": "deletedAt",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "broadcastedAt",
+ "columnName": "broadcastedAt",
+ "affinity": "INTEGER"
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": true,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "foreignKeys": [
+ {
+ "table": "Profile",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "participantPublicKey"
+ ],
+ "referencedColumns": [
+ "publicKey"
+ ]
+ },
+ {
+ "table": "ChatRoom",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "chatRoomId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "Post",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `repostId` TEXT, `quote` TEXT, `content` TEXT NOT NULL, `nostrEventId` TEXT NOT NULL, `replyToId` TEXT, `profilePublicKey` TEXT NOT NULL, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, `savedAt` INTEGER NOT NULL, `viewedAt` INTEGER, `deletedAt` INTEGER, `broadcastedAt` INTEGER, PRIMARY KEY(`id`), FOREIGN KEY(`profilePublicKey`) REFERENCES `Profile`(`publicKey`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`nostrEventId`) REFERENCES `NostrEvent`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`replyToId`) REFERENCES `Post`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`repostId`) REFERENCES `Post`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "repostId",
+ "columnName": "repostId",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "quote",
+ "columnName": "quote",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "content",
+ "columnName": "content",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "nostrEventId",
+ "columnName": "nostrEventId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "replyToId",
+ "columnName": "replyToId",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "profilePublicKey",
+ "columnName": "profilePublicKey",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "createdAt",
+ "columnName": "createdAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "updatedAt",
+ "columnName": "updatedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "savedAt",
+ "columnName": "savedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "viewedAt",
+ "columnName": "viewedAt",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "deletedAt",
+ "columnName": "deletedAt",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "broadcastedAt",
+ "columnName": "broadcastedAt",
+ "affinity": "INTEGER"
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_Post_profilePublicKey",
+ "unique": false,
+ "columnNames": [
+ "profilePublicKey"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_Post_profilePublicKey` ON `${TABLE_NAME}` (`profilePublicKey`)"
+ },
+ {
+ "name": "index_Post_nostrEventId",
+ "unique": false,
+ "columnNames": [
+ "nostrEventId"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_Post_nostrEventId` ON `${TABLE_NAME}` (`nostrEventId`)"
+ },
+ {
+ "name": "index_Post_replyToId",
+ "unique": false,
+ "columnNames": [
+ "replyToId"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_Post_replyToId` ON `${TABLE_NAME}` (`replyToId`)"
+ },
+ {
+ "name": "index_Post_repostId",
+ "unique": false,
+ "columnNames": [
+ "repostId"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_Post_repostId` ON `${TABLE_NAME}` (`repostId`)"
+ }
+ ],
+ "foreignKeys": [
+ {
+ "table": "Profile",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "profilePublicKey"
+ ],
+ "referencedColumns": [
+ "publicKey"
+ ]
+ },
+ {
+ "table": "NostrEvent",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "nostrEventId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ },
+ {
+ "table": "Post",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "replyToId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ },
+ {
+ "table": "Post",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "repostId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "Profile",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`publicKey` TEXT NOT NULL, `userName` TEXT, `displayName` TEXT, `picture` TEXT, `banner` TEXT, `website` TEXT, `about` TEXT, `bot` INTEGER, `pronouns` TEXT, `nip05` TEXT, `domain` TEXT, `lud06` TEXT, `lud16` TEXT, `twitter` TEXT, `nostrEventId` TEXT NOT NULL, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, `savedAt` INTEGER NOT NULL, `viewedAt` INTEGER, `deletedAt` INTEGER, `broadcastedAt` INTEGER, PRIMARY KEY(`publicKey`), FOREIGN KEY(`nostrEventId`) REFERENCES `NostrEvent`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "publicKey",
+ "columnName": "publicKey",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "userName",
+ "columnName": "userName",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "displayName",
+ "columnName": "displayName",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "picture",
+ "columnName": "picture",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "banner",
+ "columnName": "banner",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "website",
+ "columnName": "website",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "about",
+ "columnName": "about",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "bot",
+ "columnName": "bot",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "pronouns",
+ "columnName": "pronouns",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "nip05",
+ "columnName": "nip05",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "domain",
+ "columnName": "domain",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "lud06",
+ "columnName": "lud06",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "lud16",
+ "columnName": "lud16",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "twitter",
+ "columnName": "twitter",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "nostrEventId",
+ "columnName": "nostrEventId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "createdAt",
+ "columnName": "createdAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "updatedAt",
+ "columnName": "updatedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "savedAt",
+ "columnName": "savedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "viewedAt",
+ "columnName": "viewedAt",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "deletedAt",
+ "columnName": "deletedAt",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "broadcastedAt",
+ "columnName": "broadcastedAt",
+ "affinity": "INTEGER"
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "publicKey"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_Profile_nostrEventId",
+ "unique": false,
+ "columnNames": [
+ "nostrEventId"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_Profile_nostrEventId` ON `${TABLE_NAME}` (`nostrEventId`)"
+ }
+ ],
+ "foreignKeys": [
+ {
+ "table": "NostrEvent",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "nostrEventId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "QuotedRelation",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`quotingNostrEventId` TEXT NOT NULL, `quotedNostrEventId` TEXT NOT NULL, `quotedProfilePublicKey` TEXT, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, `savedAt` INTEGER NOT NULL, `viewedAt` INTEGER, `deletedAt` INTEGER, `broadcastedAt` INTEGER, PRIMARY KEY(`quotingNostrEventId`, `quotedNostrEventId`), FOREIGN KEY(`quotedProfilePublicKey`) REFERENCES `Profile`(`publicKey`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`quotingNostrEventId`) REFERENCES `NostrEvent`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`quotedNostrEventId`) REFERENCES `NostrEvent`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "quotingNostrEventId",
+ "columnName": "quotingNostrEventId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "quotedNostrEventId",
+ "columnName": "quotedNostrEventId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "quotedProfilePublicKey",
+ "columnName": "quotedProfilePublicKey",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "createdAt",
+ "columnName": "createdAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "updatedAt",
+ "columnName": "updatedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "savedAt",
+ "columnName": "savedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "viewedAt",
+ "columnName": "viewedAt",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "deletedAt",
+ "columnName": "deletedAt",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "broadcastedAt",
+ "columnName": "broadcastedAt",
+ "affinity": "INTEGER"
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "quotingNostrEventId",
+ "quotedNostrEventId"
+ ]
+ },
+ "foreignKeys": [
+ {
+ "table": "Profile",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "quotedProfilePublicKey"
+ ],
+ "referencedColumns": [
+ "publicKey"
+ ]
+ },
+ {
+ "table": "NostrEvent",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "quotingNostrEventId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ },
+ {
+ "table": "NostrEvent",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "quotedNostrEventId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "Reaction",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `content` TEXT NOT NULL, `nostrEventId` TEXT NOT NULL, `replyToId` TEXT NOT NULL, `profilePublicKey` TEXT NOT NULL, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, `savedAt` INTEGER NOT NULL, `viewedAt` INTEGER, `deletedAt` INTEGER, `broadcastedAt` INTEGER, PRIMARY KEY(`id`), FOREIGN KEY(`profilePublicKey`) REFERENCES `Profile`(`publicKey`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`nostrEventId`) REFERENCES `NostrEvent`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`replyToId`) REFERENCES `Post`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "content",
+ "columnName": "content",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "nostrEventId",
+ "columnName": "nostrEventId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "replyToId",
+ "columnName": "replyToId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "profilePublicKey",
+ "columnName": "profilePublicKey",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "createdAt",
+ "columnName": "createdAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "updatedAt",
+ "columnName": "updatedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "savedAt",
+ "columnName": "savedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "viewedAt",
+ "columnName": "viewedAt",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "deletedAt",
+ "columnName": "deletedAt",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "broadcastedAt",
+ "columnName": "broadcastedAt",
+ "affinity": "INTEGER"
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_Reaction_profilePublicKey",
+ "unique": false,
+ "columnNames": [
+ "profilePublicKey"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_Reaction_profilePublicKey` ON `${TABLE_NAME}` (`profilePublicKey`)"
+ },
+ {
+ "name": "index_Reaction_nostrEventId",
+ "unique": false,
+ "columnNames": [
+ "nostrEventId"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_Reaction_nostrEventId` ON `${TABLE_NAME}` (`nostrEventId`)"
+ },
+ {
+ "name": "index_Reaction_replyToId",
+ "unique": false,
+ "columnNames": [
+ "replyToId"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_Reaction_replyToId` ON `${TABLE_NAME}` (`replyToId`)"
+ }
+ ],
+ "foreignKeys": [
+ {
+ "table": "Profile",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "profilePublicKey"
+ ],
+ "referencedColumns": [
+ "publicKey"
+ ]
+ },
+ {
+ "table": "NostrEvent",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "nostrEventId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ },
+ {
+ "table": "Post",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "replyToId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "RecentSearch",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`query` TEXT NOT NULL, `synchronizationFilters` TEXT, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, PRIMARY KEY(`query`))",
+ "fields": [
+ {
+ "fieldPath": "query",
+ "columnName": "query",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "synchronizationFilters",
+ "columnName": "synchronizationFilters",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "createdAt",
+ "columnName": "createdAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "updatedAt",
+ "columnName": "updatedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "query"
+ ]
+ }
+ },
+ {
+ "tableName": "Relay",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`publicKey` TEXT NOT NULL, `type` TEXT NOT NULL, `url` TEXT NOT NULL, `read` INTEGER NOT NULL, `write` INTEGER NOT NULL, PRIMARY KEY(`publicKey`, `type`, `url`))",
+ "fields": [
+ {
+ "fieldPath": "publicKey",
+ "columnName": "publicKey",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "type",
+ "columnName": "type",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "url",
+ "columnName": "url",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "read",
+ "columnName": "read",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "write",
+ "columnName": "write",
+ "affinity": "INTEGER",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "publicKey",
+ "type",
+ "url"
+ ]
+ }
+ },
+ {
+ "tableName": "RepostedRelation",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`repostingNostrEventId` TEXT NOT NULL, `repostedNostrEventId` TEXT NOT NULL, `repostedProfilePublicKey` TEXT, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, `savedAt` INTEGER NOT NULL, `viewedAt` INTEGER, `deletedAt` INTEGER, `broadcastedAt` INTEGER, PRIMARY KEY(`repostingNostrEventId`, `repostedNostrEventId`), FOREIGN KEY(`repostedProfilePublicKey`) REFERENCES `Profile`(`publicKey`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`repostedNostrEventId`) REFERENCES `NostrEvent`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`repostingNostrEventId`) REFERENCES `NostrEvent`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "repostingNostrEventId",
+ "columnName": "repostingNostrEventId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "repostedNostrEventId",
+ "columnName": "repostedNostrEventId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "repostedProfilePublicKey",
+ "columnName": "repostedProfilePublicKey",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "createdAt",
+ "columnName": "createdAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "updatedAt",
+ "columnName": "updatedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "savedAt",
+ "columnName": "savedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "viewedAt",
+ "columnName": "viewedAt",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "deletedAt",
+ "columnName": "deletedAt",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "broadcastedAt",
+ "columnName": "broadcastedAt",
+ "affinity": "INTEGER"
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "repostingNostrEventId",
+ "repostedNostrEventId"
+ ]
+ },
+ "foreignKeys": [
+ {
+ "table": "Profile",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "repostedProfilePublicKey"
+ ],
+ "referencedColumns": [
+ "publicKey"
+ ]
+ },
+ {
+ "table": "NostrEvent",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "repostedNostrEventId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ },
+ {
+ "table": "NostrEvent",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "repostingNostrEventId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "SynchronizeNostrEventRequest",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `purpose` TEXT NOT NULL, `status` TEXT NOT NULL, `relayURL` TEXT NOT NULL, `isRecommendedRelay` INTEGER NOT NULL, `level` INTEGER NOT NULL, `synchronizationFilters` TEXT NOT NULL, `ownerPublicKey` TEXT, `nostrEventId` TEXT, `unsignedNostrEventId` INTEGER, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, PRIMARY KEY(`id`), FOREIGN KEY(`nostrEventId`) REFERENCES `NostrEvent`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`unsignedNostrEventId`) REFERENCES `UnsignedNostrEvent`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "purpose",
+ "columnName": "purpose",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "status",
+ "columnName": "status",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "relayURL",
+ "columnName": "relayURL",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "isRecommendedRelay",
+ "columnName": "isRecommendedRelay",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "level",
+ "columnName": "level",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "synchronizationFilters",
+ "columnName": "synchronizationFilters",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "ownerPublicKey",
+ "columnName": "ownerPublicKey",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "nostrEventId",
+ "columnName": "nostrEventId",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "unsignedNostrEventId",
+ "columnName": "unsignedNostrEventId",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "createdAt",
+ "columnName": "createdAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "updatedAt",
+ "columnName": "updatedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_SynchronizeNostrEventRequest_nostrEventId",
+ "unique": false,
+ "columnNames": [
+ "nostrEventId"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_SynchronizeNostrEventRequest_nostrEventId` ON `${TABLE_NAME}` (`nostrEventId`)"
+ },
+ {
+ "name": "index_SynchronizeNostrEventRequest_status",
+ "unique": false,
+ "columnNames": [
+ "status"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_SynchronizeNostrEventRequest_status` ON `${TABLE_NAME}` (`status`)"
+ }
+ ],
+ "foreignKeys": [
+ {
+ "table": "NostrEvent",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "nostrEventId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ },
+ {
+ "table": "UnsignedNostrEvent",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "unsignedNostrEventId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "SynchronizeNostrEventResult",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `relayURL` TEXT NOT NULL, `nostrEventId` TEXT, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, PRIMARY KEY(`id`), FOREIGN KEY(`nostrEventId`) REFERENCES `NostrEvent`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "relayURL",
+ "columnName": "relayURL",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "nostrEventId",
+ "columnName": "nostrEventId",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "createdAt",
+ "columnName": "createdAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "updatedAt",
+ "columnName": "updatedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_SynchronizeNostrEventResult_nostrEventId",
+ "unique": false,
+ "columnNames": [
+ "nostrEventId"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_SynchronizeNostrEventResult_nostrEventId` ON `${TABLE_NAME}` (`nostrEventId`)"
+ }
+ ],
+ "foreignKeys": [
+ {
+ "table": "NostrEvent",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "nostrEventId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ },
+ {
+ "tableName": "UnsignedNostrEvent",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `pubKey` TEXT NOT NULL, `kind` INTEGER NOT NULL, `tags` TEXT NOT NULL, `privateTags` TEXT, `content` TEXT NOT NULL, `signedAt` INTEGER, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, `savedAt` INTEGER NOT NULL, `deletedAt` INTEGER, `broadcastedAt` INTEGER)",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "pubKey",
+ "columnName": "pubKey",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "kind",
+ "columnName": "kind",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "tags",
+ "columnName": "tags",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "privateTags",
+ "columnName": "privateTags",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "content",
+ "columnName": "content",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "signedAt",
+ "columnName": "signedAt",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "createdAt",
+ "columnName": "createdAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "updatedAt",
+ "columnName": "updatedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "savedAt",
+ "columnName": "savedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "deletedAt",
+ "columnName": "deletedAt",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "broadcastedAt",
+ "columnName": "broadcastedAt",
+ "affinity": "INTEGER"
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": true,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_UnsignedNostrEvent_pubKey",
+ "unique": false,
+ "columnNames": [
+ "pubKey"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_UnsignedNostrEvent_pubKey` ON `${TABLE_NAME}` (`pubKey`)"
+ },
+ {
+ "name": "index_UnsignedNostrEvent_kind",
+ "unique": false,
+ "columnNames": [
+ "kind"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_UnsignedNostrEvent_kind` ON `${TABLE_NAME}` (`kind`)"
+ }
+ ]
+ },
+ {
+ "tableName": "Zap",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `postId` TEXT NOT NULL, `senderPublicKey` TEXT NOT NULL, `receiverPublicKey` TEXT NOT NULL, `message` TEXT, `invoice` TEXT, `amountInMillisatoshis` INTEGER, `nostrEventId` TEXT NOT NULL, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, `savedAt` INTEGER NOT NULL, `viewedAt` INTEGER, `deletedAt` INTEGER, `broadcastedAt` INTEGER, PRIMARY KEY(`id`), FOREIGN KEY(`senderPublicKey`) REFERENCES `Profile`(`publicKey`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`receiverPublicKey`) REFERENCES `Profile`(`publicKey`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`nostrEventId`) REFERENCES `NostrEvent`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`postId`) REFERENCES `Post`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "postId",
+ "columnName": "postId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "senderPublicKey",
+ "columnName": "senderPublicKey",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "receiverPublicKey",
+ "columnName": "receiverPublicKey",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "message",
+ "columnName": "message",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "invoice",
+ "columnName": "invoice",
+ "affinity": "TEXT"
+ },
+ {
+ "fieldPath": "amountInMillisatoshis",
+ "columnName": "amountInMillisatoshis",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "nostrEventId",
+ "columnName": "nostrEventId",
+ "affinity": "TEXT",
+ "notNull": true
+ },
+ {
+ "fieldPath": "createdAt",
+ "columnName": "createdAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "updatedAt",
+ "columnName": "updatedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "savedAt",
+ "columnName": "savedAt",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "viewedAt",
+ "columnName": "viewedAt",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "deletedAt",
+ "columnName": "deletedAt",
+ "affinity": "INTEGER"
+ },
+ {
+ "fieldPath": "broadcastedAt",
+ "columnName": "broadcastedAt",
+ "affinity": "INTEGER"
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": false,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "indices": [
+ {
+ "name": "index_Zap_senderPublicKey",
+ "unique": false,
+ "columnNames": [
+ "senderPublicKey"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_Zap_senderPublicKey` ON `${TABLE_NAME}` (`senderPublicKey`)"
+ },
+ {
+ "name": "index_Zap_nostrEventId",
+ "unique": false,
+ "columnNames": [
+ "nostrEventId"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_Zap_nostrEventId` ON `${TABLE_NAME}` (`nostrEventId`)"
+ },
+ {
+ "name": "index_Zap_postId",
+ "unique": false,
+ "columnNames": [
+ "postId"
+ ],
+ "orders": [],
+ "createSql": "CREATE INDEX IF NOT EXISTS `index_Zap_postId` ON `${TABLE_NAME}` (`postId`)"
+ }
+ ],
+ "foreignKeys": [
+ {
+ "table": "Profile",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "senderPublicKey"
+ ],
+ "referencedColumns": [
+ "publicKey"
+ ]
+ },
+ {
+ "table": "Profile",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "receiverPublicKey"
+ ],
+ "referencedColumns": [
+ "publicKey"
+ ]
+ },
+ {
+ "table": "NostrEvent",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "nostrEventId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ },
+ {
+ "table": "Post",
+ "onDelete": "CASCADE",
+ "onUpdate": "NO ACTION",
+ "columns": [
+ "postId"
+ ],
+ "referencedColumns": [
+ "id"
+ ]
+ }
+ ]
+ }
+ ],
+ "setupQueries": [
+ "CREATE TABLE IF NOT EXISTS room_master_table (id INTEGER PRIMARY KEY,identity_hash TEXT)",
+ "INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, '2c0a331e83c34052be538e86ab743c87')"
+ ]
+ }
+}
\ No newline at end of file
diff --git a/composeApp/src/commonMain/composeResources/values/strings.xml b/composeApp/src/commonMain/composeResources/values/strings.xml
index 9dfa0334..2a695034 100644
--- a/composeApp/src/commonMain/composeResources/values/strings.xml
+++ b/composeApp/src/commonMain/composeResources/values/strings.xml
@@ -65,6 +65,7 @@
Creating new chat.
Currently no contacts. Please search and chat with a few people.
Currently no messages have been shared.\nBreak the ice.
+ Declined to sign
Delete group
Details
Dialect name
@@ -476,6 +477,18 @@
Edit schema
Propose schema
Fields: %1$s
+
+ Start a list
+ A list is a schema: what an entry may contain, who may suggest one, and where it lives. The group signs it with its shared key, and only that key can put an entry on the list.
+ Pick a shape to start from. Everything in it can be changed before the group signs.
+ Links & text
+ Reddit’s default: a title with a link or some text, a picture if you like, and a flair.
+ Discussion
+ Text posts only: a title and a body, with a flair.
+ Catalogue
+ bitcoin.mov’s shape: things with a year, a type, an external id and links — one entry per thing however often it is suggested.
+ Custom
+ Just the two fields every list has — an identifier and a title — and whatever you add.
Public
Closed
Private
diff --git a/composeApp/src/commonMain/kotlin/to/curare/compose/database/CurareDatabase.kt b/composeApp/src/commonMain/kotlin/to/curare/compose/database/CurareDatabase.kt
index f2d2be0c..a4c26a84 100644
--- a/composeApp/src/commonMain/kotlin/to/curare/compose/database/CurareDatabase.kt
+++ b/composeApp/src/commonMain/kotlin/to/curare/compose/database/CurareDatabase.kt
@@ -186,7 +186,7 @@ val GENESIS_AT = Instant.fromEpochMilliseconds(1231006505000L)
UnsignedNostrEvent::class,
Zap::class
],
- version = 23,
+ version = 24,
autoMigrations = [
// v2 only adds the DkgSession/DkgParticipantMessage tables, so Room can
// generate the migration itself — nothing existing changes shape.
@@ -330,28 +330,37 @@ val GENESIS_AT = Instant.fromEpochMilliseconds(1231006505000L)
// which is what they were, and any identity may drain them. The broadcast
// queue deliberately gets no owner: a signed event is anyone's to carry.
AutoMigration(from = 19, to = 20),
- // v21 adds three nullable columns for the Marmot current profile (see
+ // v21 adds the nullable FrostSigningSession.signDeclinedAt, the other
+ // answer to the question signApprovedAt records: a member who refused to
+ // sign, on a session that runs on without them. Refusing used to end the
+ // session outright, so no row written before this can be one where the
+ // owner declined and the session is still open -- every such session is
+ // FAILED, and null reads as "not declined", which is true of all the
+ // rest. A nullable column is a shape Room migrates itself.
+ AutoMigration(from = 20, to = 21),
+ // v22 adds three nullable columns for the Marmot current profile (see
// docs/marmot-v2.md, Phase 3): MarmotKeyPackageBundle.profile and .dTag, and
// MarmotKeyPackage.profile. A bundle's profile decides which shape a rotation
// republishes into which slot, its dTag is the kind:30443 slot it reuses so a
// replacement supersedes rather than accumulates, and a peer package's profile
// is what a room picks by. Rows from before read back null, which every
- // reader takes as legacy -- what they were.
- AutoMigration(from = 20, to = 21),
- // v22 adds MarmotRouting: the address a room's kind:445 traffic is carried
+ // reader takes as legacy -- what they were. (v22-v24 were v21-v23 on the
+ // branch that made them; they moved up one when the branch met v21 above.)
+ AutoMigration(from = 21, to = 22),
+ // v23 adds MarmotRouting: the address a room's kind:445 traffic is carried
// under, separate from the room's id (docs/marmot-v2.md, Phase 4). A
// current-profile room this app creates mints a random routing id -- the
// room's own id is a derived key, which v2's routing component says must
// never be the address -- and every reader keyed on the `h` tag resolves it
// through this table. No rows are backfilled: a room with none is addressed
// by its own id, which is what every room before the table was.
- AutoMigration(from = 21, to = 22),
- // v23 adds MarmotPublishObligation and MarmotOutboundGate: the commits this
+ AutoMigration(from = 22, to = 23),
+ // v24 adds MarmotPublishObligation and MarmotOutboundGate: the commits this
// device prepared and has not yet heard a relay accept, and the gates a room
// is under (docs/marmot-v2.md, Phase 6). Both have to outlive the process --
// an obligation forgotten at a crash is a replacement commit at the next
// start, which forks the group against whoever took the first one.
- AutoMigration(from = 22, to = 23),
+ AutoMigration(from = 23, to = 24),
]
)
@ColumnTypeConverters(CurareConverters::class)
diff --git a/composeApp/src/commonMain/kotlin/to/curare/compose/database/model/ChatMessage.kt b/composeApp/src/commonMain/kotlin/to/curare/compose/database/model/ChatMessage.kt
index 050fad7b..002c673e 100644
--- a/composeApp/src/commonMain/kotlin/to/curare/compose/database/model/ChatMessage.kt
+++ b/composeApp/src/commonMain/kotlin/to/curare/compose/database/model/ChatMessage.kt
@@ -280,6 +280,17 @@ data class ChatMessage(
const val TYPE_FROST_COMPLETE = "frostComplete"
const val TYPE_FROST_FAILED = "frostFailed"
+ /**
+ * A member refused to sign, and the session went on without them.
+ *
+ * Its own type rather than a failure, because it is not one: a t-of-n key
+ * can do without `n - t` members, and this line is one of the refusals
+ * the key can absorb. The refusal that leaves too few to sign is written
+ * as [TYPE_FROST_FAILED] instead, saying both that the member declined
+ * and that it was the one that ended the session.
+ */
+ const val TYPE_FROST_DECLINED = "frostDeclined"
+
/** Addressed to the reader rather than said by anyone -- see [DKG_REQUEST_TYPES]. */
const val TYPE_FROST_APPROVAL_NEEDED = "frostApprovalNeeded"
@@ -301,14 +312,18 @@ data class ChatMessage(
* The signing lines that end a session, whichever way it went.
*
* A request usually stops being one by being answered, but that is not
- * the only way. A member who declines publishes nothing, and a quorum
- * that signs without them asks them for nothing further -- from the
- * transcript both look the same, nothing of the reader's own either
- * side of the request, so the session's own ending is the only thing
- * left to read it from.
+ * the only way. A quorum that signs without the reader asks them for
+ * nothing further, and a session that is abandoned asks nobody for
+ * anything -- in both there is nothing of the reader's own either side
+ * of the request, so the session's own ending is the only thing left to
+ * read it from.
*
* A ceremony has no equivalent because a ceremony step can only be
- * taken or waited for. Signing is the one thing a member can refuse.
+ * taken or waited for. Signing is the one thing a member can refuse --
+ * and a refusal the session survives is the third way a request can be
+ * over, read by [settledRequests] from the reader's own
+ * [TYPE_FROST_DECLINED] line rather than from here: it settles only
+ * the refuser's request, where these settle everybody's.
*/
val FROST_SETTLEMENTS = setOf(TYPE_FROST_COMPLETE, TYPE_FROST_FAILED)
@@ -321,6 +336,7 @@ data class ChatMessage(
TYPE_FROST_SIGNATURE,
TYPE_FROST_COMPLETE,
TYPE_FROST_FAILED,
+ TYPE_FROST_DECLINED,
TYPE_FROST_APPROVAL_NEEDED,
)
@@ -337,6 +353,7 @@ data class ChatMessage(
TYPE_FROST_PARTIAL_SIGNATURE,
TYPE_FROST_SIGNATURE,
TYPE_FROST_FAILED,
+ TYPE_FROST_DECLINED,
)
val DKG_AUTHORED_TYPES = setOf(
@@ -677,17 +694,24 @@ data class ChatMessage(
* earned no tick and claiming otherwise would credit them with a
* signature they refused or were never needed for. What they have run
* out of is a decision to make -- see [FROST_SETTLEMENTS].
+ *
+ * The reader's own refusal settles their request too, and only theirs.
+ * The session is still open -- the others may yet sign it -- so it is
+ * not an ending, and another member's refusal leaves the reader with
+ * exactly the decision they had.
*/
fun settledRequests(messages: List): Set = messages
.filter { request ->
request.messageType in FROST_REQUEST_TYPES &&
- messages.any {
- it.messageType in FROST_SETTLEMENTS && it.isAbout(request)
- }
+ messages.any { it.settles() && it.isAbout(request) }
}
.map { it.id }
.toSet()
+ private fun ChatMessage.settles(): Boolean =
+ messageType in FROST_SETTLEMENTS ||
+ (messageType == TYPE_FROST_DECLINED && isUserMessage)
+
/**
* Files one direct message, from whichever side of it this device is on.
*
diff --git a/composeApp/src/commonMain/kotlin/to/curare/compose/database/model/FrostSignerMessage.kt b/composeApp/src/commonMain/kotlin/to/curare/compose/database/model/FrostSignerMessage.kt
index c248efb3..3c8c2c5f 100644
--- a/composeApp/src/commonMain/kotlin/to/curare/compose/database/model/FrostSignerMessage.kt
+++ b/composeApp/src/commonMain/kotlin/to/curare/compose/database/model/FrostSignerMessage.kt
@@ -13,8 +13,11 @@ import kotlin.time.Instant
* rather than accumulates — relays redeliver, and feeding the same nonce in
* twice would make the coordinator's signer set the wrong length.
*
- * Covers the nonce and the partial signature; the coordinator's own broadcasts
- * live on [FrostSigningSession] because there is only ever one of each.
+ * Covers the nonce, the partial signature and the refusal; the coordinator's
+ * own broadcasts live on [FrostSigningSession] because there is only ever one
+ * of each. A refusal is here rather than on the session for the same reason a
+ * nonce is: there is one per member, and how many there are is what decides
+ * whether the session goes on -- see `FrostSigningSession.declinesThatAbandon`.
*
* Keyed on `(sessionId, signerPublicKey, kind)`, which also means a member
* cannot replace their own nonce once the coordinator has aggregated it — a
@@ -45,7 +48,10 @@ data class FrostSignerMessage(
/** One of the `FrostSigningEvents` kinds. */
val kind: Kind,
- /** Hex of the protocol bytes: a public nonce, or a partial signature. */
+ /**
+ * Hex of the protocol bytes: a public nonce, or a partial signature. For a
+ * refusal there are no bytes, and this is the reason the member gave.
+ */
val payload: HexKey,
val createdAt: Instant = Clock.System.now(),
diff --git a/composeApp/src/commonMain/kotlin/to/curare/compose/database/model/FrostSigningSession.kt b/composeApp/src/commonMain/kotlin/to/curare/compose/database/model/FrostSigningSession.kt
index 5f58e6b3..b0f6df74 100644
--- a/composeApp/src/commonMain/kotlin/to/curare/compose/database/model/FrostSigningSession.kt
+++ b/composeApp/src/commonMain/kotlin/to/curare/compose/database/model/FrostSigningSession.kt
@@ -35,7 +35,7 @@ import to.curare.compose.managers.SharedKeyDerivation
* | ceremony, threshold, participant count | the unsigned event and its id |
* | [signerIds] and the signer set | nonce seed, and the nonce from it |
* | [derivationPath] and its tweak cache | aggregated nonce |
- * | [signApprovedAt] -- one decision | the signature |
+ * | [signApprovedAt] or [signDeclinedAt] -- one decision | the signature |
*
* ### The nonce, and why one item means one message
*
@@ -136,6 +136,19 @@ data class FrostSigningSession(
*/
val signApprovedAt: Instant? = null,
+ /**
+ * When this device's owner refused instead. The other answer to the same
+ * question, and the same shape: a decision, recorded before anything is
+ * published on the strength of it, and never revisited. `advance` publishes
+ * the refusal the way it publishes a nonce for an approval -- whenever the
+ * row says so and no copy of the message is on file yet.
+ *
+ * Refusing does not end the session. A t-of-n key needs t willing members,
+ * so what one refusal does is take one member out of the n; the session is
+ * abandoned only once fewer than t are left -- see [declinesThatAbandon].
+ */
+ val signDeclinedAt: Instant? = null,
+
/** Whether the chat line asking for that approval has been written. */
val approvalRequestedAt: Instant? = null,
@@ -154,6 +167,17 @@ data class FrostSigningSession(
/** Whether this device was picked to sign. A t-of-n key does not need everyone. */
fun isSigner(): Boolean = signerIdList()?.contains(signerId) ?: false
+ /**
+ * How many members have to refuse before the signature cannot be made.
+ *
+ * A t-of-n key can do without `n - t` members, so it is the refusal after
+ * that -- the one leaving fewer than t who could still sign -- that abandons
+ * the session. In a 2-of-3 group one member may decline and the other two
+ * still sign; the second refusal is the one that ends it. In an n-of-n group
+ * every member is needed and a single refusal is enough.
+ */
+ fun declinesThatAbandon(): Int = participantCount - threshold + 1
+
/**
* [derivationPath] as indices, and an empty list when there is none.
*
diff --git a/composeApp/src/commonMain/kotlin/to/curare/compose/database/repository/DatabaseFrostSigningRepository.kt b/composeApp/src/commonMain/kotlin/to/curare/compose/database/repository/DatabaseFrostSigningRepository.kt
index ed728c30..1cb928e8 100644
--- a/composeApp/src/commonMain/kotlin/to/curare/compose/database/repository/DatabaseFrostSigningRepository.kt
+++ b/composeApp/src/commonMain/kotlin/to/curare/compose/database/repository/DatabaseFrostSigningRepository.kt
@@ -7,6 +7,7 @@ import com.vitorpamplona.quartz.nip01Core.core.Kind
import com.vitorpamplona.quartz.nip01Core.signers.EventTemplate
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.flow.Flow
+import kotlinx.coroutines.flow.map
import to.curare.compose.database.CurareDatabase
import to.curare.compose.database.model.FrostSignerMessage
import to.curare.compose.database.model.FrostSigningItem
@@ -14,6 +15,7 @@ import to.curare.compose.database.model.FrostSigningSession
import to.curare.compose.database.model.intermdiate.LocalChatRoom
import to.curare.compose.database.model.intermdiate.LocalFrostSigningSession
import to.curare.compose.managers.FrostSigningManager
+import to.curare.compose.nostr.dkg.DkgRitualEvents
import to.curare.compose.repository.FrostSigningRepository
class DatabaseFrostSigningRepository(
@@ -31,6 +33,14 @@ class DatabaseFrostSigningRepository(
override fun observeMessages(sessionId: String): Flow> =
database.frostSigningSessionDao().observeMessages(sessionId)
+ override fun observeShareHolders(dkgSessionId: String): Flow> =
+ database.dkgSessionDao().observeMessages(dkgSessionId).map { messages ->
+ messages
+ .filter { it.kind == DkgRitualEvents.HOST_KEY }
+ .map { it.participantPublicKey }
+ .toSet()
+ }
+
override fun observeItems(sessionId: String): Flow> =
database.frostSigningSessionDao().observeItems(sessionId)
diff --git a/composeApp/src/commonMain/kotlin/to/curare/compose/managers/FrostSigningManager.kt b/composeApp/src/commonMain/kotlin/to/curare/compose/managers/FrostSigningManager.kt
index b94044c1..36721e62 100644
--- a/composeApp/src/commonMain/kotlin/to/curare/compose/managers/FrostSigningManager.kt
+++ b/composeApp/src/commonMain/kotlin/to/curare/compose/managers/FrostSigningManager.kt
@@ -106,6 +106,12 @@ import to.curare.compose.nostr.frost.FrostSigningEvents
* threshold to be reachable, picks a signer set, and says who is in it. Members
* outside the set do nothing and are not stalling anything.
*
+ * The same arithmetic runs the other way. A member who refuses takes one of
+ * the n away rather than ending the session, and it is abandoned only once
+ * fewer than t are left who could still sign -- see [recordDecline]. In a
+ * 2-of-3 group one refusal is nothing the other two cannot sign around; the
+ * second is the one that ends it.
+ *
* ### Restart-safety is forced, not chosen
*
* `SecretNonce` cannot be serialised and refuses to be used twice. Storing the
@@ -634,6 +640,105 @@ object FrostSigningManager {
)
return false
}
+
+ FrostSigningEvents.DECLINE -> {
+ return recordDecline(
+ database = database,
+ session = session,
+ member = innerEvent.pubKey,
+ reason = innerEvent.content
+ )
+ }
+ }
+
+ return true
+ }
+
+ /**
+ * Files one member's refusal, and ends the session if it is the refusal
+ * that leaves too few members to sign. Returns false when it is, so the
+ * caller stops rather than trying to advance a dead one.
+ *
+ * The count is this device's own, made from the refusals it has received,
+ * and every device makes the same one: the threshold and the participant
+ * count came off the ceremony, and a refusal is a message like any other.
+ * Nobody announces the abandonment, because nobody has to -- each device
+ * reaches it on its own the way each writes its own transcript, and a
+ * FAILURE sent to say so would name one member as the culprit for what was
+ * the group's arithmetic.
+ *
+ * Only a ceremony participant's refusal counts, and only theirs is kept. A
+ * subgroup's ceremony runs in the parent's room over a subset of it, so a
+ * message here can come from a member who holds no share, and a refusal to
+ * sign from somebody who could not have signed takes nobody out of the n.
+ * A member who has already offered a nonce cannot refuse through the app --
+ * the screen offers one answer or the other -- so a refusal is never
+ * counted against a signer.
+ *
+ * The transcript line is written once, on the first delivery; the count is
+ * recomputed on every one, which costs nothing and is idempotent by
+ * [fail]'s own guard.
+ */
+ private suspend fun recordDecline(
+ database: CurareDatabase,
+ session: FrostSigningSession,
+ member: HexKey,
+ reason: String
+ ): Boolean {
+ val key = database.dkgSessionDao().getSessionById(session.dkgSessionId) ?: return true
+ val participants = signerIds(database, key).keys
+
+ if (member !in participants) {
+ logger.w(
+ "Session ${session.id}: refusal from ${member.take(8)}, who holds no share of " +
+ "key ${key.id}; ignoring"
+ )
+ return true
+ }
+
+ val known = database.frostSigningSessionDao()
+ .getMessage(session.id, FrostSigningEvents.DECLINE, member) != null
+
+ database.frostSigningSessionDao().upsert(
+ FrostSignerMessage(
+ sessionId = session.id,
+ signerPublicKey = member,
+ kind = FrostSigningEvents.DECLINE,
+ payload = reason
+ )
+ )
+
+ val declined = database.frostSigningSessionDao()
+ .getMessagesByKind(session.id, FrostSigningEvents.DECLINE)
+ .map { it.signerPublicKey }
+ .filter { it in participants }
+ .toSet()
+ .size
+ val willing = session.participantCount - declined
+
+ if (declined >= session.declinesThatAbandon()) {
+ fail(
+ database = database,
+ session = session,
+ reason = "Abandoned: $declined of ${session.participantCount} members declined " +
+ "to sign, leaving fewer than the ${session.threshold} it takes.",
+ culprit = member,
+ content = "declined to sign. That leaves fewer than the ${session.threshold} of " +
+ "${session.participantCount} members it takes, so the signature is " +
+ "abandoned. Nothing was signed, and it is safe to ask again."
+ )
+ return false
+ }
+
+ if (!known) {
+ announce(
+ database = database,
+ session = session,
+ messageType = ChatMessage.TYPE_FROST_DECLINED,
+ content = "declined to sign. It takes ${session.threshold} of " +
+ "${session.participantCount} members, and $willing could still sign.",
+ actor = member
+ )
}
return true
@@ -690,8 +795,22 @@ object FrostSigningManager {
// Returns rather than throws: the session is not failing, it is waiting
// on a person, and everything received stays stored so it resumes the
// moment they approve.
+ //
+ // A refusal is the other way of having said so, and it returns from
+ // the same place: there is nothing more of this device's to publish,
+ // and the session goes on around it -- the signature arriving is what
+ // closes it, at the top of this pass. What a refusal does publish is
+ // itself, on the same terms as a nonce below: whenever the row says
+ // the owner refused and no copy of the message is on file, so that a
+ // device killed between deciding and sending says it on the next
+ // message rather than leaving the group to wait on a member who has
+ // already answered.
if (session.signApprovedAt == null) {
- announceApprovalNeeded(database, session)
+ if (session.signDeclinedAt == null) {
+ announceApprovalNeeded(database, session)
+ } else if (ownMessage(database, session, FrostSigningEvents.DECLINE) == null) {
+ publishDecline(database, localChatRoom, session)
+ }
return
}
@@ -1550,17 +1669,32 @@ object FrostSigningManager {
if (settled || current.stage.ordinal >= stage.ordinal) current else current.copy(stage = stage)
}
+ /**
+ * Ends the session, and puts the line saying so in the group's chat with
+ * [culprit]'s name in front of it.
+ *
+ * [content] is that line's predicate. The default is the one a fault gets;
+ * a refusal that tips the count writes its own, because what happened there
+ * is that a member declined, and the abandonment is the arithmetic of it.
+ */
private suspend fun fail(
database: CurareDatabase,
session: FrostSigningSession,
reason: String,
- culprit: HexKey = session.userPublicKey
+ culprit: HexKey = session.userPublicKey,
+ content: String = "abandoned the signature. Nothing was signed, and it is safe to ask again."
) {
// Read before writing so the notice goes out once. A session can be failed
// from two directions -- a FAILURE message from a member, and a fault
// raised locally -- and the group does not need to be told twice.
+ //
+ // A signature the group has made is not abandoned by anything that
+ // arrives afterwards. A member who refused before their device had seen
+ // the signature has refused something that no longer needed them, and
+ // marking a signed session failed on their say-so would be reporting
+ // a signature that exists as one that does not.
val current = database.frostSigningSessionDao().getSessionById(session.id) ?: session
- if (current.stage == FrostSigningStage.FAILED) return
+ if (current.stage == FrostSigningStage.FAILED || current.stage == FrostSigningStage.COMPLETE) return
update(database, current) {
it.copy(stage = FrostSigningStage.FAILED, failureReason = reason)
@@ -1569,7 +1703,7 @@ object FrostSigningManager {
database = database,
session = current,
messageType = ChatMessage.TYPE_FROST_FAILED,
- content = "abandoned the signature. Nothing was signed, and it is safe to ask again.",
+ content = content,
actor = culprit
)
}
@@ -1599,10 +1733,13 @@ object FrostSigningManager {
// The group signed it without needing this member, and [advance] closes
// the session on its next pass without asking them anything. Offering the
// decision anyway would be offering two bad answers: a nonce nobody is
- // waiting for, or a refusal that abandons a signature already made.
+ // waiting for, or a refusal nobody is counting.
if (items.isNotEmpty() && items.all { it.isSigned() }) return false
- return session.signApprovedAt == null
+ // Either answer is an answer. A member who refused is not asked again,
+ // even though the session is still open around them: the question was
+ // theirs to answer once, and it has been.
+ return session.signApprovedAt == null && session.signDeclinedAt == null
}
/**
@@ -1639,6 +1776,17 @@ object FrostSigningManager {
* A t-of-n group can sign without this member, so declining is a normal
* outcome and not a failure of the session — but only if it is said out loud.
* Silence is indistinguishable from a phone in a pocket.
+ *
+ * It used to end the session on the spot, which made one member's no into
+ * everybody's. Now it is one refusal among however many the key can do
+ * without: [recordDecline] counts them, on this device as on every other,
+ * and the session is abandoned only once fewer than the threshold could
+ * still sign -- so in a 2-of-3 group the first refusal changes nothing the
+ * other two can do, and the second ends it.
+ *
+ * The same shape as [approve]: the decision is written to the row, and
+ * [advance] does the publishing, so that a device killed in between says
+ * it on the next message rather than never.
*/
suspend fun decline(
database: CurareDatabase,
@@ -1648,20 +1796,46 @@ object FrostSigningManager {
val session = database.frostSigningSessionDao().getSessionById(sessionId) ?: return
val items = database.frostSigningSessionDao().getItems(sessionId)
- if (!isAwaitingApproval(session, items)) return
+ if (!isAwaitingApproval(session, items)) {
+ logger.i("Session $sessionId is not waiting on an approval; ignoring the refusal")
+ return
+ }
+
+ update(database, session) { it.copy(signDeclinedAt = Clock.System.now()) }
+
+ logger.i("Session $sessionId: signing declined")
+
+ advance(database, localChatRoom, sessionId)
+ }
+
+ /**
+ * Broadcasts this device's refusal AND files it, so it is counted here the
+ * way it will be everywhere else.
+ *
+ * Not [publishOwn], although it is the same two steps in the same order,
+ * because the local copy is not just a copy: filing it is what may end the
+ * session, and [recordDecline] is the one place that decides.
+ */
+ private suspend fun publishDecline(
+ database: CurareDatabase,
+ localChatRoom: LocalChatRoom,
+ session: FrostSigningSession
+ ) {
+ val reason = "Declined to sign"
- fail(
- database = database,
- session = session,
- reason = "Declined on this device",
- culprit = session.userPublicKey
- )
broadcast(
database = database,
localChatRoom = localChatRoom,
session = session,
- kind = FrostSigningEvents.FAILURE,
- content = "Declined to sign"
+ kind = FrostSigningEvents.DECLINE,
+ content = reason
+ )
+
+ recordDecline(
+ database = database,
+ session = session,
+ member = session.userPublicKey,
+ reason = reason
)
}
@@ -1746,8 +1920,8 @@ object FrostSigningManager {
"combined the parts into the group's " +
(if (batch) "$count signatures." else "signature.")
- // PROPOSAL and FAILURE are announced by the code that acts on them --
- // both say more than the message itself carries.
+ // PROPOSAL, FAILURE and DECLINE are announced by the code that acts on
+ // them -- each says more than the message itself carries.
else -> return
}
diff --git a/composeApp/src/commonMain/kotlin/to/curare/compose/nostr/curated/CuratedSchemaTemplate.kt b/composeApp/src/commonMain/kotlin/to/curare/compose/nostr/curated/CuratedSchemaTemplate.kt
new file mode 100644
index 00000000..3ed558c7
--- /dev/null
+++ b/composeApp/src/commonMain/kotlin/to/curare/compose/nostr/curated/CuratedSchemaTemplate.kt
@@ -0,0 +1,262 @@
+package to.curare.compose.nostr.curated
+
+/**
+ * How a client works an entry's `d` out of the entry itself.
+ *
+ * The NIP marks the identifier field `derived` and leaves the derivation to the
+ * publishing client, which is fine for a site with one list and one rule --
+ * bitcoin.mov's -- and useless for a list started from a template, whose
+ * entries will be composed by clients that have never seen its code. So
+ * curare.to records the rule *in the schema*: a machine-readable mark,
+ * `[rule:]`, at the end of a human sentence in the identifier field's
+ * hint. A client that knows the rule applies it and one that does not can at
+ * least read what it is; one that finds no mark falls back to [Title].
+ *
+ * This app composes no entries and applies none of these. It writes the mark
+ * so that a list the group starts here is one that site's form can post to
+ * with the right identifier -- the same link one post whoever submits it,
+ * say -- rather than with whatever its fallback happens to be.
+ *
+ * The keys, the wording and the shape of the hint are `lib/protocol/derive.ts`
+ * in the curare.to repository, byte for byte, so that a template started here
+ * and one started there produce the same schema.
+ */
+enum class CuratedDeriveRule(
+ /** The word in the mark. */
+ val key: String,
+ /** The rule as the hint says it, after "Derived by the client — ". */
+ private val phrase: String,
+) {
+ /**
+ * A post with a link is identified by the link, so the same link is one
+ * post whoever submits it; a text post by its title and its author.
+ */
+ LinkOrTitle("link-or-title", "the link, else the title and author"),
+
+ /** Two people's same-titled posts are two posts; one person's is an edit. */
+ TitleAuthor("title-author", "the title and author"),
+
+ /**
+ * A catalogue entry with an external id (`imdb:tt…`) is one entry however
+ * often it is suggested; otherwise the title and year.
+ */
+ ExternalOrTitleYear("external-or-title-year", "the external id, else the title and year"),
+
+ /** The same title is the same post, whoever posts it. */
+ Title("title", "the title"),
+ ;
+
+ /** The hint that records this rule on an identifier field. */
+ fun hint(): String = "Derived by the client — $phrase. [rule:$key]"
+}
+
+/**
+ * The shapes a list can start from: curare.to's templates, the ones its
+ * "Start a list" page offers, so that a list started in this app and one
+ * started on that site are the same kind of thing.
+ *
+ * Every template carries the two fields every list has -- the identifier,
+ * derived and with its [rule] recorded in its hint, and the title -- and
+ * declares no derived `t` field: the hashtag rule is bitcoin.mov's own, and a
+ * list is its own topic. Flair is the sub-topic.
+ *
+ * The field names, labels, placeholders and configs are signed into the
+ * schema and read by other clients, which is why they are plain strings here
+ * rather than resources: they are protocol data, not this app's copy. What
+ * the picker *calls* a template is UI text and lives in the catalogue.
+ *
+ * The fields are `lib/protocol/templates.ts` in the curare.to repository,
+ * field for field. A template added there belongs here too.
+ */
+enum class CuratedSchemaTemplate(
+ /** The stable key, the one curare.to's editor takes as `?template=`. */
+ val key: String,
+ val rule: CuratedDeriveRule,
+ val fields: List,
+ val requireAny: List> = emptyList(),
+) {
+ /** Reddit's default: a title with a link or some text, a picture, and a flair. */
+ Links(
+ key = "links",
+ rule = CuratedDeriveRule.LinkOrTitle,
+ fields = listOf(
+ identifier(CuratedDeriveRule.LinkOrTitle),
+ title(placeholder = "What is it?"),
+ CuratedField(
+ name = "link",
+ type = CuratedFieldType.Url,
+ isRequired = false,
+ placeholder = "https://…",
+ label = "Link",
+ config = CuratedFieldConfig(tag = "r", marker = "link", max = 500),
+ ),
+ CuratedField(
+ name = "body",
+ type = CuratedFieldType.LongText,
+ isRequired = false,
+ placeholder = "Say more, or nothing.",
+ label = "Text",
+ config = CuratedFieldConfig(tag = CuratedFieldConfig.CONTENT_TAG, max = 10_000),
+ ),
+ CuratedField(
+ name = "image",
+ type = CuratedFieldType.Image,
+ isRequired = false,
+ placeholder = "https://…/picture.jpg",
+ label = "Picture",
+ config = CuratedFieldConfig(max = 500, hint = "An https link to an image."),
+ ),
+ flair("discussion", "news", "question"),
+ ),
+ requireAny = listOf(listOf("link", "body")),
+ ),
+
+ /** Text posts only: a title and a body, with a flair. */
+ Discussion(
+ key = "discussion",
+ rule = CuratedDeriveRule.TitleAuthor,
+ fields = listOf(
+ identifier(CuratedDeriveRule.TitleAuthor),
+ title(placeholder = "What do you want to talk about?"),
+ CuratedField(
+ name = "body",
+ type = CuratedFieldType.LongText,
+ isRequired = true,
+ label = "Text",
+ config = CuratedFieldConfig(tag = CuratedFieldConfig.CONTENT_TAG, max = 10_000),
+ ),
+ flair("question", "meta"),
+ ),
+ ),
+
+ /**
+ * bitcoin.mov's shape, generalised: things with a year, a type, an
+ * external id and links, one entry per thing however often it is suggested.
+ */
+ Catalogue(
+ key = "catalogue",
+ rule = CuratedDeriveRule.ExternalOrTitleYear,
+ fields = listOf(
+ identifier(CuratedDeriveRule.ExternalOrTitleYear),
+ title(placeholder = "The thing’s name"),
+ CuratedField(
+ name = "year",
+ type = CuratedFieldType.Year,
+ isRequired = false,
+ placeholder = "2014",
+ label = "Year",
+ config = CuratedFieldConfig(min = 1900, max = 2100),
+ ),
+ CuratedField(
+ name = "type",
+ type = CuratedFieldType.Enum,
+ isRequired = true,
+ label = "Type",
+ config = CuratedFieldConfig(
+ options = listOf("movie", "documentary", "short", "series", "book", "other"),
+ ),
+ ),
+ CuratedField(
+ name = "externalId",
+ type = CuratedFieldType.Token,
+ isRequired = false,
+ placeholder = "imdb:tt2821314",
+ label = "External id",
+ config = CuratedFieldConfig(
+ tag = "i",
+ max = 60,
+ hint = "Helps dedupe, e.g. imdb:tt2821314 or isbn:…",
+ ),
+ ),
+ CuratedField(
+ name = "watchUrl",
+ type = CuratedFieldType.Url,
+ isRequired = false,
+ placeholder = "https://…",
+ label = "Where to see it",
+ config = CuratedFieldConfig(tag = "r", marker = "watch", max = 500, repeat = true),
+ ),
+ CuratedField(
+ name = "referenceUrl",
+ type = CuratedFieldType.Url,
+ isRequired = false,
+ placeholder = "https://…",
+ label = "Reference",
+ config = CuratedFieldConfig(tag = "r", marker = "reference", max = 500),
+ ),
+ CuratedField(
+ name = "image",
+ type = CuratedFieldType.Image,
+ isRequired = false,
+ placeholder = "https://…/poster.jpg",
+ label = "Picture",
+ config = CuratedFieldConfig(max = 500),
+ ),
+ CuratedField(
+ name = "lang",
+ type = CuratedFieldType.Token,
+ isRequired = false,
+ placeholder = "en",
+ label = "Language",
+ config = CuratedFieldConfig(max = 60, pattern = "[A-Za-z]{2,8}([-_][A-Za-z0-9]{2,8})*"),
+ ),
+ CuratedField(
+ name = "description",
+ type = CuratedFieldType.LongText,
+ isRequired = false,
+ placeholder = "Why is it worth a look?",
+ label = "Description",
+ config = CuratedFieldConfig(tag = CuratedFieldConfig.CONTENT_TAG, max = 4000),
+ ),
+ ),
+ requireAny = listOf(listOf("watchUrl", "referenceUrl")),
+ ),
+
+ /** Just the two fields every list has, and whatever the group adds. */
+ Custom(
+ key = "custom",
+ rule = CuratedDeriveRule.Title,
+ fields = listOf(identifier(CuratedDeriveRule.Title), title(placeholder = "")),
+ ),
+ ;
+
+ companion object {
+ /**
+ * The template with [key], or [Custom] for null and for a key this build
+ * does not know.
+ *
+ * Custom rather than the first, which is what curare.to falls back to,
+ * because Custom is the two fields every list has and nothing else: the
+ * one shape that cannot presume anything about a list it was not asked
+ * for. Null is what an edit carries, where the template is meaningless,
+ * and what a screen handed a loaded state without one gets.
+ */
+ fun byKey(key: String?): CuratedSchemaTemplate = entries.firstOrNull { it.key == key } ?: Custom
+ }
+}
+
+// The fields the templates share, as functions of the file rather than of the
+// companion: an enum's entries are built before its companion is, so they
+// cannot call into it.
+
+/**
+ * The identifier field every template starts with: [CuratedField.IDENTIFIER]
+ * with the rule recorded in its hint.
+ */
+private fun identifier(rule: CuratedDeriveRule): CuratedField =
+ CuratedField.IDENTIFIER.copy(
+ config = CuratedField.IDENTIFIER.config.copy(hint = rule.hint()),
+ )
+
+/** The title field every template starts with: [CuratedField.TITLE] with an example. */
+private fun title(placeholder: String): CuratedField =
+ CuratedField.TITLE.copy(placeholder = placeholder)
+
+/** A sub-topic an entry may pick one of. */
+private fun flair(vararg options: String): CuratedField = CuratedField(
+ name = "flair",
+ type = CuratedFieldType.Enum,
+ isRequired = false,
+ label = "Flair",
+ config = CuratedFieldConfig(options = options.toList()),
+)
diff --git a/composeApp/src/commonMain/kotlin/to/curare/compose/nostr/frost/FrostSigningEvents.kt b/composeApp/src/commonMain/kotlin/to/curare/compose/nostr/frost/FrostSigningEvents.kt
index 0fa1107c..1bdfcf97 100644
--- a/composeApp/src/commonMain/kotlin/to/curare/compose/nostr/frost/FrostSigningEvents.kt
+++ b/composeApp/src/commonMain/kotlin/to/curare/compose/nostr/frost/FrostSigningEvents.kt
@@ -29,12 +29,23 @@ import to.curare.compose.nostr.frost.tags.FrostSignerIdsTag
* signer --[ 30323 partial ]-> everyone this device's partial signature
* proposer --[ 30324 signature ]-> everyone the finished 64-byte signature
* anyone --[ 30325 failure ]-> everyone abandon + blame
+ * signer --[ 30330 decline ]-> everyone this member will not sign
* ```
*
- * [GroupKeyStateEvent] sits just past them on 30326. It is not part of a
- * session -- it is the standing fact a session is opened against, saying which
+ * A decline is not a failure, which is why it is a kind of its own. A t-of-n
+ * key needs t willing members, not n, so one member saying no leaves the
+ * session open for the rest -- and every device counts the refusals it has
+ * seen against the same arithmetic, abandoning only once fewer than t members
+ * could still sign. See `FrostSigningManager.recordDecline`. A failure is the
+ * other thing: a fault that no quorum can work around, and it ends the session
+ * wherever it lands.
+ *
+ * [GroupKeyStateEvent] sits just past the first six on 30326. It is not part of
+ * a session -- it is the standing fact a session is opened against, saying which
* key the room signs with -- so it is deliberately outside [ALL], which is what
- * the inbound path dispatches a session message on.
+ * the inbound path dispatches a session message on. 30327-30329 went to the
+ * chronicle and subgroup families before a session needed a seventh kind, which
+ * is why the decline sits at 30330 rather than in the run.
*
* ### Why 3032x
*
@@ -82,6 +93,18 @@ object FrostSigningEvents {
/** Session abandoned. Content is the reason, for showing to the group. */
val FAILURE: Kind = 30325
+ /**
+ * One member will not sign. Content is their reason, for showing to the
+ * group; the session goes on without them unless too few are left.
+ *
+ * A build predating this kind does not route it -- it is not in that build's
+ * [ALL] -- so an old device never learns of a refusal and simply keeps
+ * waiting, which is what it did for a member who said nothing. It still
+ * sends its own refusals as [FAILURE], and a new device honours those as
+ * the abandonment they always were.
+ */
+ val DECLINE: Kind = 30330
+
/** Every kind above, for filtering inbound payloads in one check. */
val ALL: Set = setOf(
PROPOSAL,
@@ -89,7 +112,8 @@ object FrostSigningEvents {
SIGNER_SET,
PARTIAL_SIGNATURE,
SIGNATURE,
- FAILURE
+ FAILURE,
+ DECLINE
)
fun isFrostSigningKind(kind: Kind): Boolean = kind in ALL
diff --git a/composeApp/src/commonMain/kotlin/to/curare/compose/repository/FrostSigningRepository.kt b/composeApp/src/commonMain/kotlin/to/curare/compose/repository/FrostSigningRepository.kt
index f1f3487a..f16c42ba 100644
--- a/composeApp/src/commonMain/kotlin/to/curare/compose/repository/FrostSigningRepository.kt
+++ b/composeApp/src/commonMain/kotlin/to/curare/compose/repository/FrostSigningRepository.kt
@@ -32,6 +32,23 @@ interface FrostSigningRepository {
fun observeMessages(sessionId: String): Flow>
+ /**
+ * Who holds a share of the key a ceremony made, and so can take part in a
+ * session signing with it.
+ *
+ * The members who put a host key into the ceremony -- the same rows
+ * `FrostSigningManager` places signer ids over, so this cannot disagree with
+ * whose nonces, partial signatures and refusals the session counts. A
+ * ceremony cannot complete without every participant's host key, so for a
+ * completed one this is the whole participant set.
+ *
+ * Not the room's roster. A room can hold members who were added after its
+ * ceremony and hold no share, and a subgroup's ceremony runs in the parent's
+ * room, which holds everybody the subgroup is not. A screen listing the room
+ * would show people the session is not waiting on and cannot be answered by.
+ */
+ fun observeShareHolders(dkgSessionId: String): Flow>
+
/**
* The events a session signs, in the order its proposal fixed.
*
@@ -139,6 +156,9 @@ interface FrostSigningRepository {
override fun observeMessages(sessionId: String): Flow> =
flowOf(emptyList())
+ override fun observeShareHolders(dkgSessionId: String): Flow> =
+ flowOf(emptySet())
+
override fun observeItems(sessionId: String): Flow> =
flowOf(emptyList())
diff --git a/composeApp/src/commonMain/kotlin/to/curare/compose/ui/composable/EditGroupCuratedSchemaScreen.kt b/composeApp/src/commonMain/kotlin/to/curare/compose/ui/composable/EditGroupCuratedSchemaScreen.kt
index 84ba4dd9..836dedf2 100644
--- a/composeApp/src/commonMain/kotlin/to/curare/compose/ui/composable/EditGroupCuratedSchemaScreen.kt
+++ b/composeApp/src/commonMain/kotlin/to/curare/compose/ui/composable/EditGroupCuratedSchemaScreen.kt
@@ -92,6 +92,7 @@ import to.curare.compose.nostr.curated.CuratedField
import to.curare.compose.nostr.curated.CuratedFieldType
import to.curare.compose.nostr.curated.CuratedSchemaEvent
import to.curare.compose.nostr.curated.CuratedSchemaProblem
+import to.curare.compose.nostr.curated.CuratedSchemaTemplate
import to.curare.compose.nostr.curated.CuratedVisibility
import to.curare.compose.repository.ChatRepository
import to.curare.compose.repository.FrostSigningRepository
@@ -250,6 +251,12 @@ import org.jetbrains.compose.resources.stringResource
* suggestion to the list replies to, so changing it would not edit the list but
* start a second one and orphan the first's queue. The field is read-only on an
* edit and says why; a new list is "Add schema" on the group's screen.
+ *
+ * **A new list starts from a template.** "Add schema" opens
+ * `SelectCuratedSchemaTemplateScreen` first, and the shape chosen there arrives
+ * as [template] -- the fields and rules the form is seeded with, in place of the
+ * bare two every list has. The form is the same either way: a template is a
+ * starting point, and everything in it can be changed before the group signs.
*/
@OptIn(
ExperimentalMaterial3ExpressiveApi::class,
@@ -262,6 +269,8 @@ fun EditGroupCuratedSchemaScreen(
chatRoomId: String,
relayHint: String?,
identifier: String?,
+ /** The key of the `CuratedSchemaTemplate` a new schema starts from. Ignored on an edit. */
+ template: String? = null,
initialEditGroupCuratedSchemaUIState: EditGroupCuratedSchemaUIState =
EditGroupCuratedSchemaUIState.Loading,
chatRepository: ChatRepository,
@@ -274,6 +283,7 @@ fun EditGroupCuratedSchemaScreen(
chatRoomId = chatRoomId,
relayHint = relayHint,
identifier = identifier,
+ template = template,
initialEditGroupCuratedSchemaUIState = initialEditGroupCuratedSchemaUIState,
activeUserPublicKey = activeUserPublicKey,
chatRepository = chatRepository,
@@ -1472,6 +1482,9 @@ private fun EditGroupCuratedSchemaScreenPreview() {
chatRoomId = "publicKey",
relayHint = null,
identifier = null,
+ // The shape a new list most often starts from, so the preview
+ // shows a templated form rather than the bare two fields.
+ template = CuratedSchemaTemplate.Links.key,
initialEditGroupCuratedSchemaUIState = EditGroupCuratedSchemaUIState.Loaded(
localChatRoom = LocalChatRoom(
chatRoom = ChatRoom(
@@ -1483,9 +1496,9 @@ private fun EditGroupCuratedSchemaScreenPreview() {
mlsGroupState = "state"
),
),
- // A new schema, so the editor seeds the two fields every list
- // has and the preview shows what a group actually starts from
- // rather than an empty form.
+ // A new schema, so the editor seeds the template's fields and
+ // the preview shows what a group actually starts from rather
+ // than an empty form.
defaultRelays = listOf("wss://relay.example.com"),
// A group that can sign, so the form renders in the state a
// member actually meets it in rather than greyed out.
diff --git a/composeApp/src/commonMain/kotlin/to/curare/compose/ui/composable/FrostSigningScreen.kt b/composeApp/src/commonMain/kotlin/to/curare/compose/ui/composable/FrostSigningScreen.kt
index d8c43894..0bf81af2 100644
--- a/composeApp/src/commonMain/kotlin/to/curare/compose/ui/composable/FrostSigningScreen.kt
+++ b/composeApp/src/commonMain/kotlin/to/curare/compose/ui/composable/FrostSigningScreen.kt
@@ -12,6 +12,7 @@ import androidx.compose.foundation.layout.width
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.verticalScroll
import androidx.compose.material.icons.Icons
+import androidx.compose.material.icons.filled.Block
import androidx.compose.material.icons.filled.CheckCircle
import androidx.compose.material.icons.filled.Draw
import androidx.compose.material.icons.filled.ErrorOutline
@@ -57,6 +58,7 @@ import to.curare.compose.ui.theme.spacing
import to.curare.compose.ui.composable.widgets.Decorative
import curare.composeapp.generated.resources.Res
import org.jetbrains.compose.resources.stringResource
+import curare.composeapp.generated.resources.declined_to_sign
import curare.composeapp.generated.resources.don_t_sign
import curare.composeapp.generated.resources.has_not_taken_part_yet
import curare.composeapp.generated.resources.members
@@ -170,7 +172,7 @@ fun FrostSigningScreen(
HorizontalDivider()
Text(
- text = statusOf(session),
+ text = statusOf(session, declined = state.declined.size),
style = MaterialTheme.typography.bodyMedium
)
@@ -192,58 +194,72 @@ fun FrostSigningScreen(
// Named rather than counted, for the same reason the ceremony's
// ladder names people: "1 of 2" does not tell anyone whose door
// to knock on, and a session stalls until somebody knocks.
- state.localChatRoom.localParticipants
- .distinctBy { it.participant.participantPublicKey }
- .forEach { localParticipant ->
- val member = localParticipant.participant.participantPublicKey
+ //
+ // The share holders, not the room. A member added to the room
+ // after its key was made holds no share, and so can neither
+ // sign nor refuse -- listing them would name a door that cannot
+ // answer. See FrostSigningUIState.Loaded.members.
+ state.members.forEach { localParticipant ->
+ val member = localParticipant.participant.participantPublicKey
- Card {
- ListItem(
- leadingContent = {
- ProfileAvatar(
- publicKey = member,
- profile = localParticipant.profile
+ Card {
+ ListItem(
+ leadingContent = {
+ ProfileAvatar(
+ publicKey = member,
+ profile = localParticipant.profile
+ )
+ },
+ trailingContent = {
+ when {
+ member in state.signed -> Icon(
+ Icons.Default.CheckCircle,
+ contentDescription = "Signed",
+ tint = MaterialTheme.colorScheme.primary
)
- },
- trailingContent = {
- when {
- member in state.signed -> Icon(
- Icons.Default.CheckCircle,
- contentDescription = "Signed",
- tint = MaterialTheme.colorScheme.primary
- )
- member in state.offeredNonce -> Icon(
- Icons.Default.HourglassEmpty,
- contentDescription = "Ready to sign"
- )
-
- else -> Icon(
- Icons.Default.RadioButtonUnchecked,
- contentDescription = "Not yet",
- tint = MaterialTheme.colorScheme.onSurfaceVariant
- )
- }
- },
- headlineContent = {
- Text(
- text = localParticipant.profile
- ?.humanReadableNameOrPubkey()
- ?: member
+ member in state.offeredNonce -> Icon(
+ Icons.Default.HourglassEmpty,
+ contentDescription = "Ready to sign"
)
- },
- supportingContent = {
- Text(
- text = when {
- member in state.signed -> stringResource(Res.string.signed_their_part)
- member in state.offeredNonce -> stringResource(Res.string.ready_to_sign)
- else -> stringResource(Res.string.has_not_taken_part_yet)
- }
+
+ // Quiet rather than red: a refusal the
+ // session survives is not an error, and
+ // the one it does not survive ends the
+ // session, which the status line says.
+ member in state.declined -> Icon(
+ Icons.Default.Block,
+ contentDescription = "Declined",
+ tint = MaterialTheme.colorScheme.onSurfaceVariant
+ )
+
+ else -> Icon(
+ Icons.Default.RadioButtonUnchecked,
+ contentDescription = "Not yet",
+ tint = MaterialTheme.colorScheme.onSurfaceVariant
)
}
- )
- }
+ },
+ headlineContent = {
+ Text(
+ text = localParticipant.profile
+ ?.humanReadableNameOrPubkey()
+ ?: member
+ )
+ },
+ supportingContent = {
+ Text(
+ text = when {
+ member in state.signed -> stringResource(Res.string.signed_their_part)
+ member in state.offeredNonce -> stringResource(Res.string.ready_to_sign)
+ member in state.declined -> stringResource(Res.string.declined_to_sign)
+ else -> stringResource(Res.string.has_not_taken_part_yet)
+ }
+ )
+ }
+ )
}
+ }
// Asked rather than re-derived: the manager owns when a session
// is still waiting on its owner, and a second copy of that rule
@@ -386,20 +402,40 @@ private fun OneThingBeingSigned(event: Event) {
}
}
-private fun statusOf(session: FrostSigningSession): String = when (session.stage) {
- FrostSigningStage.COLLECTING_NONCES ->
- "Waiting for ${session.threshold} of ${session.participantCount} members to take part."
+/**
+ * Where the session has got to, and -- once anybody has refused -- how many
+ * refusals it has left in it. A t-of-n session is abandoned only when fewer
+ * than t members could still sign, so "2 could still sign" beside "it takes 2"
+ * is the reader being told the next refusal ends it.
+ */
+private fun statusOf(session: FrostSigningSession, declined: Int): String {
+ val declinedHere = session.signDeclinedAt != null
+ val willing = session.participantCount - declined
- FrostSigningStage.COLLECTING_PARTIAL_SIGNATURES ->
- if (session.isSigner()) {
- "You are one of the signers. Waiting on the rest of them."
- } else {
- "Enough members took part without needing you. Waiting on them to sign."
+ return when (session.stage) {
+ FrostSigningStage.COLLECTING_NONCES -> when {
+ declinedHere ->
+ "You declined to sign. It takes ${session.threshold} of ${session.participantCount} " +
+ "members, and $willing could still sign."
+
+ declined > 0 ->
+ "Waiting for ${session.threshold} of ${session.participantCount} members to take " +
+ "part. $declined declined, and $willing could still sign."
+
+ else ->
+ "Waiting for ${session.threshold} of ${session.participantCount} members to take part."
}
- FrostSigningStage.COMPLETE -> "Signed."
+ FrostSigningStage.COLLECTING_PARTIAL_SIGNATURES -> when {
+ session.isSigner() -> "You are one of the signers. Waiting on the rest of them."
+ declinedHere -> "You declined to sign. Enough members took part without you. Waiting on them to sign."
+ else -> "Enough members took part without needing you. Waiting on them to sign."
+ }
- FrostSigningStage.FAILED -> "Abandoned. Nothing was signed, and it is safe to ask again."
+ FrostSigningStage.COMPLETE -> "Signed."
+
+ FrostSigningStage.FAILED -> "Abandoned. Nothing was signed, and it is safe to ask again."
+ }
}
@ConformancePreviews
diff --git a/composeApp/src/commonMain/kotlin/to/curare/compose/ui/composable/GroupCuratedSchemasScreen.kt b/composeApp/src/commonMain/kotlin/to/curare/compose/ui/composable/GroupCuratedSchemasScreen.kt
index 3eee137b..a5c8c24e 100644
--- a/composeApp/src/commonMain/kotlin/to/curare/compose/ui/composable/GroupCuratedSchemasScreen.kt
+++ b/composeApp/src/commonMain/kotlin/to/curare/compose/ui/composable/GroupCuratedSchemasScreen.kt
@@ -57,6 +57,7 @@ import to.curare.compose.ui.composable.navigation.routes.BroadcastGroupSignedEve
import to.curare.compose.ui.composable.navigation.routes.CuratedSuggestionListRoute
import to.curare.compose.ui.composable.navigation.routes.EditGroupCuratedSchemaRoute
import to.curare.compose.ui.composable.navigation.routes.Route
+import to.curare.compose.ui.composable.navigation.routes.SelectCuratedSchemaTemplateRoute
import to.curare.compose.ui.composable.widgets.Decorative
import to.curare.compose.ui.composable.widgets.EmptyState
import to.curare.compose.ui.composable.widgets.ErrorState
@@ -80,7 +81,9 @@ import kotlin.time.Instant
* nothing more. This is where they are read: one card per list, most recently
* signed first, each with its queue and its broadcast under it, and -- for a
* member holding a share of the key -- the way into the editor, on the card
- * for a revision and at the end for a new list.
+ * for a revision, and at the end the way to a new list, which starts with the
+ * template picker rather than with the editor: a new list has a shape to
+ * choose and a revision has one already.
*
* A schema exists to be read by people who were never in the room, so a member
* without a share reads it like anybody else, and reads its queue, which the
@@ -155,16 +158,28 @@ fun GroupCuratedSchemasScreen(
}
is GroupCuratedSchemasUIState.Loaded -> {
- // The one way into the editor, for a revision and for a new
- // list alike: the editor takes the identifier of the schema
- // to revise, and null for one that does not exist yet.
- val edit: (String?) -> Unit = { identifier ->
+ // A revision opens the editor on the schema to revise, which
+ // needs no template: it starts from the schema itself.
+ val edit: (String) -> Unit = { identifier ->
onNavigateToRoute.invoke(
EditGroupCuratedSchemaRoute(
activeUserPublicKey = activeUserPublicKey,
chatRoomId = chatRoomId,
relayHint = relayHint,
- identifier = identifier
+ identifier = identifier,
+ template = null
+ )
+ )
+ }
+
+ // A new list opens the template picker, which opens the
+ // editor in turn on the shape chosen there.
+ val add: () -> Unit = {
+ onNavigateToRoute.invoke(
+ SelectCuratedSchemaTemplateRoute(
+ activeUserPublicKey = activeUserPublicKey,
+ chatRoomId = chatRoomId,
+ relayHint = relayHint
)
)
}
@@ -182,7 +197,7 @@ fun GroupCuratedSchemasScreen(
Res.string.this_group_has_not_published_a_curated_schema_yet
),
action = if (state.canSign) {
- { AddSchemaButton(onClick = { edit(null) }) }
+ { AddSchemaButton(onClick = add) }
} else {
null
}
@@ -272,7 +287,7 @@ fun GroupCuratedSchemasScreen(
if (state.canSign) {
item {
- AddSchemaButton(onClick = { edit(null) })
+ AddSchemaButton(onClick = add)
}
}
}
@@ -370,8 +385,9 @@ private fun GroupCuratedSchemaCard(
}
/**
- * The way into `EditGroupCuratedSchemaScreen` for a list that does not exist
- * yet. The icon is decorative because the label is beside it.
+ * The way to a list that does not exist yet: `SelectCuratedSchemaTemplateScreen`,
+ * and through it the editor. The icon is decorative because the label is
+ * beside it.
*/
@Composable
private fun AddSchemaButton(onClick: () -> Unit) {
diff --git a/composeApp/src/commonMain/kotlin/to/curare/compose/ui/composable/ProposalListScreen.kt b/composeApp/src/commonMain/kotlin/to/curare/compose/ui/composable/ProposalListScreen.kt
index 2d6da5d6..9454d315 100644
--- a/composeApp/src/commonMain/kotlin/to/curare/compose/ui/composable/ProposalListScreen.kt
+++ b/composeApp/src/commonMain/kotlin/to/curare/compose/ui/composable/ProposalListScreen.kt
@@ -377,8 +377,13 @@ private fun statusOf(proposal: ProposalListUIState.Proposal): String {
if (proposal.awaitsYou) return "Needs your review"
return when (session.stage) {
+ // Not awaiting the reader and still collecting means they answered, one
+ // way or the other. A refusal leaves the session open -- a t-of-n key
+ // can do without this member -- so it is still a session in progress,
+ // and the row has to say which answer was given.
FrostSigningStage.COLLECTING_NONCES ->
- "You agreed. Waiting for ${session.threshold} of " +
+ (if (session.signDeclinedAt != null) "You declined. " else "You agreed. ") +
+ "Waiting for ${session.threshold} of " +
"${session.participantCount} members to take part."
FrostSigningStage.COLLECTING_PARTIAL_SIGNATURES ->
diff --git a/composeApp/src/commonMain/kotlin/to/curare/compose/ui/composable/SelectCuratedSchemaTemplateScreen.kt b/composeApp/src/commonMain/kotlin/to/curare/compose/ui/composable/SelectCuratedSchemaTemplateScreen.kt
new file mode 100644
index 00000000..1bc26fb9
--- /dev/null
+++ b/composeApp/src/commonMain/kotlin/to/curare/compose/ui/composable/SelectCuratedSchemaTemplateScreen.kt
@@ -0,0 +1,248 @@
+package to.curare.compose.ui.composable
+
+import androidx.compose.foundation.layout.Arrangement
+import androidx.compose.foundation.layout.Column
+import androidx.compose.foundation.layout.fillMaxSize
+import androidx.compose.foundation.layout.fillMaxWidth
+import androidx.compose.foundation.layout.padding
+import androidx.compose.foundation.rememberScrollState
+import androidx.compose.foundation.verticalScroll
+import androidx.compose.material.icons.Icons
+import androidx.compose.material.icons.automirrored.filled.ArrowForward
+import androidx.compose.material.icons.automirrored.filled.Chat
+import androidx.compose.material.icons.filled.Category
+import androidx.compose.material.icons.filled.Link
+import androidx.compose.material.icons.filled.Tune
+import androidx.compose.material3.Card
+import androidx.compose.material3.ExperimentalMaterial3Api
+import androidx.compose.material3.Icon
+import androidx.compose.material3.ListItem
+import androidx.compose.material3.MaterialTheme
+import androidx.compose.material3.Scaffold
+import androidx.compose.material3.SnackbarHost
+import androidx.compose.material3.Surface
+import androidx.compose.material3.Text
+import androidx.compose.material3.TopAppBar
+import androidx.compose.runtime.Composable
+import androidx.compose.ui.Modifier
+import androidx.compose.ui.graphics.vector.ImageVector
+import androidx.compose.ui.text.style.TextOverflow
+import com.vitorpamplona.quartz.nip01Core.core.HexKey
+import curare.composeapp.generated.resources.Res
+import curare.composeapp.generated.resources.a_list_is_a_schema_what_an_entry_may_contain
+import curare.composeapp.generated.resources.fields_colon
+import curare.composeapp.generated.resources.pick_a_shape_to_start_from
+import curare.composeapp.generated.resources.start_a_list
+import curare.composeapp.generated.resources.template_catalogue
+import curare.composeapp.generated.resources.template_catalogue_description
+import curare.composeapp.generated.resources.template_custom
+import curare.composeapp.generated.resources.template_custom_description
+import curare.composeapp.generated.resources.template_discussion
+import curare.composeapp.generated.resources.template_discussion_description
+import curare.composeapp.generated.resources.template_links
+import curare.composeapp.generated.resources.template_links_description
+import org.jetbrains.compose.resources.StringResource
+import org.jetbrains.compose.resources.stringResource
+import to.curare.compose.nostr.curated.CuratedSchemaTemplate
+import to.curare.compose.ui.composable.navigation.routes.EditGroupCuratedSchemaRoute
+import to.curare.compose.ui.composable.navigation.routes.Route
+import to.curare.compose.ui.composable.widgets.Decorative
+import to.curare.compose.ui.composable.widgets.LocalSnackbarHostState
+import to.curare.compose.ui.composable.widgets.NavigateBackButton
+import to.curare.compose.ui.theme.ConformancePreviews
+import to.curare.compose.ui.theme.CurareTheme
+import to.curare.compose.ui.theme.readableContent
+import to.curare.compose.ui.theme.spacing
+
+/**
+ * The first step of adding a curated schema: which shape the list starts from.
+ *
+ * curare.to's "Start a list" page, which is what its `/new` shows before a
+ * template is chosen: a line on what a list is, and one card per template
+ * naming it, saying what it is for and listing what an entry in it asks for.
+ * Tapping a card opens the editor seeded from that template, so that a list
+ * started here and one started on that site are the same kind of thing --
+ * and a member who wants none of the shapes takes *Custom*, which is the two
+ * fields every list has and what "Add schema" used to open on directly.
+ *
+ * There is nothing to load and no state to keep: the templates are constants,
+ * and the choice leaves as an argument to `EditGroupCuratedSchemaRoute` rather
+ * than being remembered here. Back from the editor is this screen and another
+ * shape, the way the browser's back is on the site.
+ *
+ * Gated by the screen before it, not here. "Add schema" is offered only to a
+ * member holding a share of the key, and the editor says so again if a screen
+ * ever reaches it another way.
+ */
+@OptIn(ExperimentalMaterial3Api::class)
+@Composable
+fun SelectCuratedSchemaTemplateScreen(
+ activeUserPublicKey: HexKey,
+ chatRoomId: String,
+ relayHint: String?,
+ onNavigateToRoute: (Route) -> Unit,
+ onNavigateBack: () -> Unit,
+) {
+ Scaffold(
+ snackbarHost = { SnackbarHost(LocalSnackbarHostState.current) },
+ topBar = {
+ TopAppBar(
+ title = {
+ Text(
+ text = stringResource(Res.string.start_a_list),
+ maxLines = 1,
+ overflow = TextOverflow.Ellipsis
+ )
+ },
+ navigationIcon = { NavigateBackButton(onNavigateBack) }
+ )
+ }
+ ) { innerPadding ->
+ // A scrolling column rather than a lazy list: four cards, all of them
+ // wanted at once, and nothing under them to page in.
+ Column(
+ modifier = Modifier
+ .padding(innerPadding)
+ .readableContent()
+ .fillMaxSize()
+ .verticalScroll(rememberScrollState())
+ .padding(
+ horizontal = MaterialTheme.spacing.screenMargin,
+ vertical = MaterialTheme.spacing.itemGap
+ ),
+ verticalArrangement = Arrangement.spacedBy(MaterialTheme.spacing.itemGap)
+ ) {
+ // At the leading edge like the cards under it, whose icons and
+ // headlines it lines up with; the editor after this one centres
+ // its lead because nothing on it has an edge to keep.
+ Text(
+ text = stringResource(Res.string.a_list_is_a_schema_what_an_entry_may_contain),
+ style = MaterialTheme.typography.bodyMedium
+ )
+
+ Text(
+ text = stringResource(Res.string.pick_a_shape_to_start_from),
+ style = MaterialTheme.typography.bodySmall,
+ color = MaterialTheme.colorScheme.onSurfaceVariant
+ )
+
+ CuratedSchemaTemplate.entries.forEach { template ->
+ CuratedSchemaTemplateCard(
+ template = template,
+ onClick = {
+ onNavigateToRoute.invoke(
+ EditGroupCuratedSchemaRoute(
+ activeUserPublicKey = activeUserPublicKey,
+ chatRoomId = chatRoomId,
+ relayHint = relayHint,
+ identifier = null,
+ template = template.key
+ )
+ )
+ }
+ )
+ }
+ }
+ }
+}
+
+/**
+ * One shape a list can start from, as a card that opens the editor on it.
+ *
+ * The site's card is the name, the description and a count of fields. The
+ * count is the one thing changed: the fields are listed by label instead, the
+ * way the group's own schema cards list them, because what a member choosing
+ * a shape wants to know is what an entry in it will ask for, and "6 fields"
+ * answers a different question. The identifier is among them although a form
+ * never asks for it: the editor lists it as a row too, marked derived, and the
+ * card shows the rows the editor is about to.
+ */
+@Composable
+private fun CuratedSchemaTemplateCard(
+ template: CuratedSchemaTemplate,
+ onClick: () -> Unit
+) {
+ Card(modifier = Modifier.fillMaxWidth(), onClick = onClick) {
+ ListItem(
+ leadingContent = {
+ // Decorative: the name beside it is the label, and the card is
+ // the target.
+ Icon(template.icon(), contentDescription = Decorative)
+ },
+ trailingContent = {
+ Icon(Icons.AutoMirrored.Filled.ArrowForward, contentDescription = Decorative)
+ },
+ headlineContent = {
+ Text(
+ text = stringResource(template.label()),
+ maxLines = 1,
+ overflow = TextOverflow.Ellipsis
+ )
+ },
+ supportingContent = {
+ Column(
+ verticalArrangement = Arrangement.spacedBy(MaterialTheme.spacing.relatedGap)
+ ) {
+ Text(text = stringResource(template.description()))
+
+ // Unclipped, unlike the group's schema cards: a template's
+ // fields are this build's own and ten at most, and the list
+ // is what the choice is made on.
+ Text(
+ text = stringResource(
+ Res.string.fields_colon,
+ template.fields.joinToString { it.labelOrName() }
+ ),
+ style = MaterialTheme.typography.bodySmall
+ )
+ }
+ }
+ )
+ }
+}
+
+/**
+ * What the picker calls a template.
+ *
+ * A `when` rather than a field on each entry, for the reason `CuratedVisibility`
+ * has one: the enum stays the protocol's four shapes with no copy behind it,
+ * and a fifth is a compile error here rather than a card with no name.
+ */
+private fun CuratedSchemaTemplate.label(): StringResource = when (this) {
+ CuratedSchemaTemplate.Links -> Res.string.template_links
+ CuratedSchemaTemplate.Discussion -> Res.string.template_discussion
+ CuratedSchemaTemplate.Catalogue -> Res.string.template_catalogue
+ CuratedSchemaTemplate.Custom -> Res.string.template_custom
+}
+
+/** What the template is for, in the site's words. */
+private fun CuratedSchemaTemplate.description(): StringResource = when (this) {
+ CuratedSchemaTemplate.Links -> Res.string.template_links_description
+ CuratedSchemaTemplate.Discussion -> Res.string.template_discussion_description
+ CuratedSchemaTemplate.Catalogue -> Res.string.template_catalogue_description
+ CuratedSchemaTemplate.Custom -> Res.string.template_custom_description
+}
+
+/** The picture of the shape: what the entries mostly are, or the sliders for none in particular. */
+private fun CuratedSchemaTemplate.icon(): ImageVector = when (this) {
+ CuratedSchemaTemplate.Links -> Icons.Default.Link
+ CuratedSchemaTemplate.Discussion -> Icons.AutoMirrored.Filled.Chat
+ CuratedSchemaTemplate.Catalogue -> Icons.Default.Category
+ CuratedSchemaTemplate.Custom -> Icons.Default.Tune
+}
+
+@ConformancePreviews
+@Composable
+private fun SelectCuratedSchemaTemplateScreenPreview() {
+ CurareTheme {
+ Surface(modifier = Modifier.fillMaxSize()) {
+ SelectCuratedSchemaTemplateScreen(
+ activeUserPublicKey = "a".repeat(64),
+ chatRoomId = "d".repeat(64),
+ relayHint = null,
+ onNavigateToRoute = {},
+ onNavigateBack = {},
+ )
+ }
+ }
+}
diff --git a/composeApp/src/commonMain/kotlin/to/curare/compose/ui/composable/navigation/CurareNavHost.kt b/composeApp/src/commonMain/kotlin/to/curare/compose/ui/composable/navigation/CurareNavHost.kt
index b7c145e0..cf787d52 100644
--- a/composeApp/src/commonMain/kotlin/to/curare/compose/ui/composable/navigation/CurareNavHost.kt
+++ b/composeApp/src/commonMain/kotlin/to/curare/compose/ui/composable/navigation/CurareNavHost.kt
@@ -45,6 +45,7 @@ import to.curare.compose.ui.composable.EditGroupNostrProfileScreen
import to.curare.compose.ui.composable.AddGroupPostScreen
import to.curare.compose.ui.composable.AcceptCuratedSuggestionScreen
import to.curare.compose.ui.composable.EditGroupCuratedSchemaScreen
+import to.curare.compose.ui.composable.SelectCuratedSchemaTemplateScreen
import to.curare.compose.ui.composable.BroadcastGroupSignedEventScreen
import to.curare.compose.ui.composable.CuratedSuggestionListScreen
import to.curare.compose.ui.composable.ProposeGroupEventScreen
@@ -152,6 +153,7 @@ import to.curare.compose.ui.composable.navigation.routes.EditGroupNostrProfileRo
import to.curare.compose.ui.composable.navigation.routes.AddGroupPostRoute
import to.curare.compose.ui.composable.navigation.routes.AcceptCuratedSuggestionRoute
import to.curare.compose.ui.composable.navigation.routes.EditGroupCuratedSchemaRoute
+import to.curare.compose.ui.composable.navigation.routes.SelectCuratedSchemaTemplateRoute
import to.curare.compose.ui.composable.navigation.routes.BroadcastGroupSignedEventRoute
import to.curare.compose.ui.composable.navigation.routes.CuratedSuggestionListRoute
import to.curare.compose.ui.composable.navigation.routes.ProposeGroupEventRoute
@@ -1330,6 +1332,23 @@ fun CurareNavHost(
}
)
}
+ composable { backStackEntry ->
+ val route = backStackEntry.toRoute()
+
+ SelectCuratedSchemaTemplateScreen(
+ activeUserPublicKey = route.activeUserPublicKey,
+ chatRoomId = route.chatRoomId,
+ relayHint = route.relayHint,
+ // Pushed rather than replaced, so back from the editor is
+ // this screen and another shape.
+ onNavigateToRoute = { editorRoute ->
+ navController.navigate(route = editorRoute)
+ },
+ onNavigateBack = {
+ navController.popBackStack()
+ }
+ )
+ }
composable { backStackEntry ->
val route = backStackEntry.toRoute()
@@ -1338,14 +1357,24 @@ fun CurareNavHost(
chatRoomId = route.chatRoomId,
relayHint = route.relayHint,
identifier = route.identifier,
+ template = route.template,
chatRepository = databaseChatRepository,
frostSigningRepository = databaseFrostSigningRepository,
onNavigateToRouteAndPopUpInclusive = { signingRoute ->
// Replace the editor so back returns to the group rather
- // than to a schema whose proposal has already gone out.
+ // than to a schema whose proposal has already gone out --
+ // and, for a new list, the template picker under it, for
+ // the same reason: the shape has been chosen and signed
+ // for, and offering it again would offer a second list.
navController.navigate(route = signingRoute) {
- popUpTo {
- inclusive = true
+ if (route.identifier == null) {
+ popUpTo {
+ inclusive = true
+ }
+ } else {
+ popUpTo {
+ inclusive = true
+ }
}
}
},
diff --git a/composeApp/src/commonMain/kotlin/to/curare/compose/ui/composable/navigation/routes/EditGroupCuratedSchemaRoute.kt b/composeApp/src/commonMain/kotlin/to/curare/compose/ui/composable/navigation/routes/EditGroupCuratedSchemaRoute.kt
index 93d4f8bd..b3ed19bd 100644
--- a/composeApp/src/commonMain/kotlin/to/curare/compose/ui/composable/navigation/routes/EditGroupCuratedSchemaRoute.kt
+++ b/composeApp/src/commonMain/kotlin/to/curare/compose/ui/composable/navigation/routes/EditGroupCuratedSchemaRoute.kt
@@ -10,11 +10,18 @@ import kotlinx.serialization.Serializable
* an edit replaces the event under the same `d`, and the editor's job is to
* propose that replacement, so the coordinate is what names the thing being
* edited and the event is only its current version.
+ *
+ * [template] is the key of the `CuratedSchemaTemplate` a new schema starts
+ * from -- what `SelectCuratedSchemaTemplateRoute` chose, and the same word
+ * curare.to's editor takes as `?template=`. It means nothing on an edit, which
+ * starts from the schema itself, and null on a new schema is the bare two
+ * fields every list has.
*/
@Serializable
data class EditGroupCuratedSchemaRoute(
val activeUserPublicKey: String,
val chatRoomId: String, // TODO: have this as a publicKey
val relayHint: String?,
- val identifier: String?
+ val identifier: String?,
+ val template: String?
): Route()
diff --git a/composeApp/src/commonMain/kotlin/to/curare/compose/ui/composable/navigation/routes/SelectCuratedSchemaTemplateRoute.kt b/composeApp/src/commonMain/kotlin/to/curare/compose/ui/composable/navigation/routes/SelectCuratedSchemaTemplateRoute.kt
new file mode 100644
index 00000000..5d86e8cb
--- /dev/null
+++ b/composeApp/src/commonMain/kotlin/to/curare/compose/ui/composable/navigation/routes/SelectCuratedSchemaTemplateRoute.kt
@@ -0,0 +1,19 @@
+package to.curare.compose.ui.composable.navigation.routes
+
+import kotlinx.serialization.Serializable
+
+/**
+ * The first step of adding a curated schema: which shape the list starts from.
+ *
+ * Pushed from the group's schemas screen, and pushing the editor in turn with
+ * the chosen template's key -- so that back from the editor is this screen and
+ * a different shape, the way curare.to's `/new` page is under its editor.
+ * There is no template to carry: the choice is made here and leaves as an
+ * argument to `EditGroupCuratedSchemaRoute`.
+ */
+@Serializable
+data class SelectCuratedSchemaTemplateRoute(
+ val activeUserPublicKey: String,
+ val chatRoomId: String, // TODO: have this as a publicKey
+ val relayHint: String?
+): Route()
diff --git a/composeApp/src/commonMain/kotlin/to/curare/compose/ui/composable/widgets/chat/ChatTranscript.kt b/composeApp/src/commonMain/kotlin/to/curare/compose/ui/composable/widgets/chat/ChatTranscript.kt
index b15c129f..c3da195e 100644
--- a/composeApp/src/commonMain/kotlin/to/curare/compose/ui/composable/widgets/chat/ChatTranscript.kt
+++ b/composeApp/src/commonMain/kotlin/to/curare/compose/ui/composable/widgets/chat/ChatTranscript.kt
@@ -27,6 +27,7 @@ import curare.composeapp.generated.resources.the_key_ceremony_needs_you
import curare.composeapp.generated.resources.ceremonies_need_you
import to.curare.compose.database.model.types.DkgApprovalStep
import androidx.compose.material.icons.filled.AccessTime
+import androidx.compose.material.icons.filled.Block
import androidx.compose.material.icons.filled.Check
import androidx.compose.material.icons.filled.CheckCircle
import androidx.compose.material.icons.filled.ChevronRight
@@ -821,6 +822,9 @@ private fun RitualNotice(
ChatMessage.TYPE_FROST_SIGNATURE -> Icons.Default.WorkspacePremium
ChatMessage.TYPE_FROST_COMPLETE -> Icons.Default.CheckCircle
ChatMessage.TYPE_FROST_FAILED -> Icons.Default.ErrorOutline
+ // A refusal the session survived. Quiet on purpose: it is not an error,
+ // and the one that ends a session is written as a failure instead.
+ ChatMessage.TYPE_FROST_DECLINED -> Icons.Default.Block
ChatMessage.TYPE_FROST_APPROVAL_NEEDED -> Icons.Default.Draw
ChatMessage.TYPE_CHRONICLE_REQUESTED -> Icons.Default.History
@@ -844,9 +848,9 @@ private fun RitualNotice(
// quiet; these are not.
// An answered request is history, not a summons: it keeps its stage's icon so
// the step is still recognisable, but drops the colour and the call to action.
- // So is a settled one -- declined, or signed by a quorum that did not need this
- // member. Nothing was answered there, so it gets no tick, but offering to
- // review it would be offering a decision that has already gone by.
+ // So is a settled one -- declined, abandoned, or signed by a quorum that did
+ // not need this member. Nothing was answered there, so it gets no tick, but
+ // offering to review it would be offering a decision that has already gone by.
val isRequest = (
chatMessage.messageType in ChatMessage.DKG_REQUEST_TYPES ||
chatMessage.messageType in ChatMessage.FROST_REQUEST_TYPES
diff --git a/composeApp/src/commonMain/kotlin/to/curare/compose/ui/view/model/EditGroupCuratedSchemaViewModel.kt b/composeApp/src/commonMain/kotlin/to/curare/compose/ui/view/model/EditGroupCuratedSchemaViewModel.kt
index b490fb58..deebe2bc 100644
--- a/composeApp/src/commonMain/kotlin/to/curare/compose/ui/view/model/EditGroupCuratedSchemaViewModel.kt
+++ b/composeApp/src/commonMain/kotlin/to/curare/compose/ui/view/model/EditGroupCuratedSchemaViewModel.kt
@@ -20,6 +20,7 @@ import to.curare.compose.nostr.curated.CuratedFieldType
import to.curare.compose.nostr.curated.CuratedSchema
import to.curare.compose.nostr.curated.CuratedSchemaEvent
import to.curare.compose.nostr.curated.CuratedSchemaProblem
+import to.curare.compose.nostr.curated.CuratedSchemaTemplate
import to.curare.compose.nostr.curated.CuratedVisibility
import to.curare.compose.repository.ChatRepository
import to.curare.compose.repository.FrostSigningRepository
@@ -49,6 +50,16 @@ import kotlinx.coroutines.launch
* identifier is a new list, with a queue of its own, and the group's screen
* offers that as adding a schema rather than as editing this one.
*
+ * ### Starting from a template
+ *
+ * A new schema is seeded from a [CuratedSchemaTemplate] -- curare.to's four
+ * shapes, chosen on the screen before this one and named by [template] -- so
+ * that the form opens on a list's worth of fields rather than on the two every
+ * list has, and so that the identifier field records how a client derives an
+ * entry's `d`, which is what lets that site's form post to a list started here.
+ * The template decides only what the working copy starts as: it is not kept,
+ * and nothing about the schema remembers which one it came from.
+ *
* The comparison for "nothing changed" is against the schema as the group signed
* it, normalized on both sides, because re-signing an identical schema would put
* a second statement on the record with a newer timestamp: harmless, since the
@@ -61,6 +72,12 @@ class EditGroupCuratedSchemaViewModel(
val relayHint: String?,
/** The `d` of the schema being edited, or null for a new one. */
val identifier: String?,
+ /**
+ * The key of the [CuratedSchemaTemplate] a new schema starts from; see
+ * [CuratedSchemaTemplate.byKey] for what null and an unknown key get. Not
+ * read on an edit, which starts from the schema itself.
+ */
+ val template: String? = null,
initialEditGroupCuratedSchemaUIState: EditGroupCuratedSchemaUIState,
val chatRepository: ChatRepository,
val frostSigningRepository: FrostSigningRepository,
@@ -204,10 +221,11 @@ class EditGroupCuratedSchemaViewModel(
/**
* Fills the working copy from the schema the group signed, once.
*
- * An existing schema starts at itself. A new one starts at the two fields
- * every list has -- the identifier and the title, which `CuratedSchema.normalized`
- * would put back anyway, shown up front so that what the member sees is what
- * the group will sign -- and at the group's own relays.
+ * An existing schema starts at itself. A new one starts at its [template]'s
+ * fields and rules -- every template carrying the identifier and the title,
+ * which `CuratedSchema.normalized` would put back anyway, shown up front so
+ * that what the member sees is what the group will sign -- and at the
+ * group's own relays.
*
* Called from the screen rather than from [initiateEditGroupCuratedSchema],
* because the loader is not the only way a loaded state arrives: a preview
@@ -226,8 +244,10 @@ class EditGroupCuratedSchemaViewModel(
suggesters.addAll(schema.suggesters)
relays.addAll(schema.relays)
} else {
+ val shape = CuratedSchemaTemplate.byKey(template)
visibility = CuratedVisibility.Public
- fields.addAll(listOf(CuratedField.IDENTIFIER, CuratedField.TITLE))
+ fields.addAll(shape.fields)
+ requireAny.addAll(shape.requireAny)
relays.addAll(state.defaultRelays)
}
}
@@ -523,6 +543,7 @@ class EditGroupCuratedSchemaViewModel(
chatRoomId: String,
relayHint: String?,
identifier: String?,
+ template: String? = null,
initialEditGroupCuratedSchemaUIState: EditGroupCuratedSchemaUIState =
EditGroupCuratedSchemaUIState.Loading,
chatRepository: ChatRepository,
@@ -534,6 +555,7 @@ class EditGroupCuratedSchemaViewModel(
chatRoomId = chatRoomId,
relayHint = relayHint,
identifier = identifier,
+ template = template,
initialEditGroupCuratedSchemaUIState = initialEditGroupCuratedSchemaUIState,
chatRepository = chatRepository,
frostSigningRepository = frostSigningRepository
diff --git a/composeApp/src/commonMain/kotlin/to/curare/compose/ui/view/model/FrostSigningViewModel.kt b/composeApp/src/commonMain/kotlin/to/curare/compose/ui/view/model/FrostSigningViewModel.kt
index d8f63f36..1f730feb 100644
--- a/composeApp/src/commonMain/kotlin/to/curare/compose/ui/view/model/FrostSigningViewModel.kt
+++ b/composeApp/src/commonMain/kotlin/to/curare/compose/ui/view/model/FrostSigningViewModel.kt
@@ -13,9 +13,13 @@ import co.touchlab.kermit.Logger
import com.vitorpamplona.quartz.nip01Core.core.Event
import com.vitorpamplona.quartz.nip01Core.core.HexKey
import kotlinx.coroutines.Dispatchers
+import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.IO
import kotlinx.coroutines.flow.combine
+import kotlinx.coroutines.flow.flatMapLatest
+import kotlinx.coroutines.flow.flowOf
import kotlinx.coroutines.launch
+import to.curare.compose.database.model.FrostSignerMessage
import to.curare.compose.database.model.FrostSigningItem
import to.curare.compose.database.model.FrostSigningSession
import to.curare.compose.nostr.frost.FrostSigningEvents
@@ -44,7 +48,12 @@ class FrostSigningViewModel(
*
* A session moves on messages arriving from other members, so a screen that
* read it once would sit still while the rest of the group signed around it.
+ *
+ * Who can take part is read off the ceremony the session names, not off the
+ * room: the room can hold members who were added after its key was made and
+ * hold no share of it, and the screen is a list of whose door to knock on.
*/
+ @OptIn(ExperimentalCoroutinesApi::class)
fun initiate() {
viewModelScope.launch(Dispatchers.IO) {
val localChatRoom = chatRepository.getChatRoomByIdentifier(chatRoomId)
@@ -55,16 +64,24 @@ class FrostSigningViewModel(
frostSigningUIState = FrostSigningUIState.Loaded(localChatRoom = localChatRoom)
+ val sessions = frostSigningRepository.observeSessionById(sessionId)
+ val shareHolders = sessions.flatMapLatest { session ->
+ session?.let { frostSigningRepository.observeShareHolders(it.dkgSessionId) }
+ ?: flowOf(emptySet())
+ }
+
combine(
- frostSigningRepository.observeSessionById(sessionId),
+ sessions,
frostSigningRepository.observeMessages(sessionId),
- frostSigningRepository.observeItems(sessionId)
- ) { session, messages, items -> Triple(session, messages, items) }
- .collect { (session, messages, items) ->
+ frostSigningRepository.observeItems(sessionId),
+ shareHolders
+ ) { session, messages, items, holders -> Observed(session, messages, items, holders) }
+ .collect { (session, messages, items, holders) ->
frostSigningUIState = FrostSigningUIState.Loaded(
localChatRoom = localChatRoom,
session = session,
items = items,
+ shareHolders = holders,
offeredNonce = messages
.filter { it.kind == FrostSigningEvents.NONCE }
.map { it.signerPublicKey }
@@ -72,12 +89,24 @@ class FrostSigningViewModel(
signed = messages
.filter { it.kind == FrostSigningEvents.PARTIAL_SIGNATURE }
.map { it.signerPublicKey }
+ .toSet(),
+ declined = messages
+ .filter { it.kind == FrostSigningEvents.DECLINE }
+ .map { it.signerPublicKey }
.toSet()
)
}
}
}
+ /** One emission of everything the screen is drawn from -- the fourth flow outgrew `Triple`. */
+ private data class Observed(
+ val session: FrostSigningSession?,
+ val messages: List,
+ val items: List,
+ val shareHolders: Set,
+ )
+
/** The events the group is being asked to sign, for showing them before they agree. */
fun proposedEvents(items: List): List =
items.mapNotNull { Event.fromJsonOrNull(it.unsignedEventJson) }
diff --git a/composeApp/src/commonMain/kotlin/to/curare/compose/ui/view/state/FrostSigningUIState.kt b/composeApp/src/commonMain/kotlin/to/curare/compose/ui/view/state/FrostSigningUIState.kt
index b659281a..cbcedb3b 100644
--- a/composeApp/src/commonMain/kotlin/to/curare/compose/ui/view/state/FrostSigningUIState.kt
+++ b/composeApp/src/commonMain/kotlin/to/curare/compose/ui/view/state/FrostSigningUIState.kt
@@ -3,7 +3,9 @@ package to.curare.compose.ui.view.state
import com.vitorpamplona.quartz.nip01Core.core.HexKey
import to.curare.compose.database.model.FrostSigningItem
import to.curare.compose.database.model.FrostSigningSession
+import to.curare.compose.database.model.Participant
import to.curare.compose.database.model.intermdiate.LocalChatRoom
+import to.curare.compose.database.model.intermdiate.LocalParticipant
sealed interface FrostSigningUIState {
data class Loaded(
@@ -23,7 +25,58 @@ sealed interface FrostSigningUIState {
/** Who has signed their part. */
val signed: Set = emptySet(),
- ): FrostSigningUIState
+
+ /**
+ * Who has refused. Named for the same reason the other two are: a
+ * t-of-n session survives some number of refusals and not one more, so
+ * which members those are is the difference between a session that is
+ * one refusal from ending and one that is nowhere near.
+ */
+ val declined: Set = emptySet(),
+
+ /**
+ * Who holds a share of the key the session signs with -- the ceremony's
+ * participants, read off the ceremony rather than the room. Empty until
+ * the session has been collected, and so until [members] has anyone in it.
+ */
+ val shareHolders: Set = emptySet(),
+ ): FrostSigningUIState {
+ /**
+ * The members the session can be answered by, as rows to draw.
+ *
+ * The share holders and nobody else. The room's roster is the wrong
+ * list twice over: a room can hold members added after its key was
+ * made, who hold no share and cannot sign or refuse, and a subgroup's
+ * ceremony room is the parent, which holds everybody the subgroup is
+ * not. The list is whose door to knock on, and a door that cannot
+ * answer does not belong on it.
+ *
+ * Profiles still come off the room, since that is where the rows with
+ * names in them are, in the order the room keeps them. A share holder
+ * the room no longer holds -- one who left after the ceremony -- still
+ * has a share and a place in the count, so they get a placeholder row
+ * rather than being dropped.
+ */
+ val members: List get() {
+ val roomMembers = localChatRoom.localParticipants
+ .distinctBy { it.participant.participantPublicKey }
+ .associateBy { it.participant.participantPublicKey }
+
+ val inRoom = roomMembers.values.filter { it.participant.participantPublicKey in shareHolders }
+ val elsewhere = (shareHolders - roomMembers.keys).sorted().map { publicKey ->
+ LocalParticipant(
+ Participant(
+ participantPublicKey = publicKey,
+ chatRoomId = localChatRoom.chatRoom.id,
+ relayHint = null
+ ),
+ null
+ )
+ }
+
+ return inRoom + elsewhere
+ }
+ }
data class Error(
val message: String
diff --git a/composeApp/src/commonTest/kotlin/to/curare/compose/database/model/TranscriptRequestStateTest.kt b/composeApp/src/commonTest/kotlin/to/curare/compose/database/model/TranscriptRequestStateTest.kt
index 399e7359..13f69a31 100644
--- a/composeApp/src/commonTest/kotlin/to/curare/compose/database/model/TranscriptRequestStateTest.kt
+++ b/composeApp/src/commonTest/kotlin/to/curare/compose/database/model/TranscriptRequestStateTest.kt
@@ -77,10 +77,11 @@ class TranscriptRequestStateTest {
}
@Test
- fun `declining settles the request without claiming it was signed`() {
- // Declining publishes nothing, so there is no fulfilment to find. The
- // failure the refusal writes is the only trace, and it has to be enough --
- // otherwise the line goes on offering a decision already made.
+ fun `a refusal that abandons the session settles the request without claiming it was signed`() {
+ // Declining publishes no nonce, so there is no fulfilment to find. When
+ // the refusal is the one that leaves too few members to sign, the failure
+ // it writes is the only trace, and it has to be enough -- otherwise the
+ // line goes on offering a decision already made.
val request = line(ChatMessage.TYPE_FROST_APPROVAL_NEEDED, at = 10)
val transcript = listOf(request, line(ChatMessage.TYPE_FROST_FAILED, at = 11))
@@ -88,6 +89,31 @@ class TranscriptRequestStateTest {
assertEquals(emptySet(), ChatMessage.answeredRequests(transcript))
}
+ @Test
+ fun `a refusal the session survives settles the refuser's request and nothing else`() {
+ // A t-of-n key can do without this member, so their refusal ends nothing
+ // -- the session is still open and the others may sign it. What has gone
+ // is this reader's decision, so their line stops asking, and it earns no
+ // tick: nothing of theirs is in whatever the group goes on to sign.
+ val request = line(ChatMessage.TYPE_FROST_APPROVAL_NEEDED, at = 10)
+ val transcript = listOf(request, line(ChatMessage.TYPE_FROST_DECLINED, at = 11))
+
+ assertEquals(setOf(request.id), ChatMessage.settledRequests(transcript))
+ assertEquals(emptySet(), ChatMessage.answeredRequests(transcript))
+ }
+
+ @Test
+ fun `somebody else's refusal leaves the request asking`() {
+ // Another member declining takes one of the n away and changes nothing
+ // about what this reader is being asked -- if anything the group needs
+ // their answer more.
+ val request = line(ChatMessage.TYPE_FROST_APPROVAL_NEEDED, at = 10)
+ val transcript = listOf(request, line(ChatMessage.TYPE_FROST_DECLINED, at = 11, sender = other))
+
+ assertEquals(emptySet(), ChatMessage.settledRequests(transcript))
+ assertEquals(emptySet(), ChatMessage.answeredRequests(transcript))
+ }
+
@Test
fun `a group that signs without this member settles their request`() {
// A t-of-n key does not need everybody. Nothing of this member's is in the
diff --git a/composeApp/src/commonTest/kotlin/to/curare/compose/managers/FrostSigningRoundTest.kt b/composeApp/src/commonTest/kotlin/to/curare/compose/managers/FrostSigningRoundTest.kt
index c68f2bb0..9626709f 100644
--- a/composeApp/src/commonTest/kotlin/to/curare/compose/managers/FrostSigningRoundTest.kt
+++ b/composeApp/src/commonTest/kotlin/to/curare/compose/managers/FrostSigningRoundTest.kt
@@ -381,6 +381,39 @@ class FrostSigningSessionTest {
)
}
+ @Test
+ fun `a member who declined is not asked again while the session runs on`() {
+ // The other answer to the one question. The session is still open --
+ // a t-of-n key can do without this member -- but the decision was theirs
+ // to make once, and offering it again would be offering a refusal that
+ // has already been counted, or an approval contradicting it.
+ val open = session(signerId = 2, signerIds = null)
+
+ assertFalse(
+ FrostSigningManager.isAwaitingApproval(
+ open.copy(signDeclinedAt = Instant.fromEpochSeconds(1)),
+ items()
+ )
+ )
+ }
+
+ @Test
+ fun `it takes one more refusal than the key can do without to abandon a session`() {
+ // A t-of-n key needs t willing members, so n - t may refuse and the rest
+ // still sign; the refusal after that is the one that ends it. In a 2-of-3
+ // group one member may decline and two still sign, which is the whole
+ // point of a threshold; only the second refusal abandons it.
+ val twoOfThree = session(signerId = 0, signerIds = null)
+ assertEquals(2, twoOfThree.declinesThatAbandon())
+
+ // Every member is needed in an n-of-n group, so any refusal is fatal.
+ assertEquals(1, twoOfThree.copy(threshold = 3, participantCount = 3).declinesThatAbandon())
+ assertEquals(1, twoOfThree.copy(threshold = 2, participantCount = 2).declinesThatAbandon())
+
+ // And a 3-of-5 group can lose two members before a third refusal ends it.
+ assertEquals(3, twoOfThree.copy(threshold = 3, participantCount = 5).declinesThatAbandon())
+ }
+
@Test
fun `a member left out of the signer set is not a signer`() {
assertTrue(session(signerId = 1, signerIds = "0,1").isSigner())
diff --git a/composeApp/src/commonTest/kotlin/to/curare/compose/nostr/curated/CuratedSchemaTemplateTest.kt b/composeApp/src/commonTest/kotlin/to/curare/compose/nostr/curated/CuratedSchemaTemplateTest.kt
new file mode 100644
index 00000000..a4ba9949
--- /dev/null
+++ b/composeApp/src/commonTest/kotlin/to/curare/compose/nostr/curated/CuratedSchemaTemplateTest.kt
@@ -0,0 +1,155 @@
+package to.curare.compose.nostr.curated
+
+import com.vitorpamplona.quartz.nip01Core.core.Event
+import kotlin.test.Test
+import kotlin.test.assertEquals
+import kotlin.test.assertNotNull
+import kotlin.test.assertSame
+import kotlin.test.assertTrue
+
+/**
+ * The shapes a list can start from, held to what curare.to's own test holds
+ * its templates to: each one publishes a schema the module verifies, with its
+ * rule recorded and no derived `t` field.
+ *
+ * The rest is what this app's editor adds on top. A template is seeded
+ * straight into the working copy, so every field has to be one the editor
+ * would have let a member commit, and every rule has to name fields that are
+ * there -- a template that broke either would put the editor in a state the
+ * editor itself refuses to reach.
+ */
+class CuratedSchemaTemplateTest {
+ private val curator = "7c965d8c2acdfd635562da3bcb82596b595be28b008d8b54ec702ed4c67d9d25"
+
+ /** A schema from a template, as the editor would propose it. */
+ private fun schemaFrom(template: CuratedSchemaTemplate) = CuratedSchema(
+ identifier = template.key,
+ title = "${template.key} suggestion",
+ name = template.key,
+ description = "A list started from the ${template.key} template.",
+ visibility = CuratedVisibility.Public,
+ fields = template.fields,
+ requireAny = template.requireAny,
+ relays = listOf("wss://relay.example"),
+ )
+
+ @Test
+ fun `every template publishes a schema a reader accepts, and reads back as itself`() {
+ for (template in CuratedSchemaTemplate.entries) {
+ val schema = schemaFrom(template)
+ assertEquals(emptyList(), schema.problems(), "${template.key} is not a usable schema")
+
+ // The mandatory two are there and required, so the one repair a
+ // reader makes has nothing to do: what the member sees is what the
+ // group signs.
+ assertEquals(schema, schema.normalized(), "${template.key} is changed by normalizing")
+
+ val built = CuratedSchemaEvent.template(schema, createdAt = 1_735_689_600)
+ val read = assertNotNull(CuratedSchemaEvent.parse(event(built.tags, built.content)))
+ assertEquals(schema, read, "${template.key} did not round trip")
+ }
+ }
+
+ @Test
+ fun `every template records its rule on the identifier and declares no hashtag field`() {
+ for (template in CuratedSchemaTemplate.entries) {
+ val identifier = template.fields.single { it.tag() == "d" }
+ assertEquals(true, identifier.config.derived, "${template.key}'s identifier is prompted for")
+ assertTrue(
+ identifier.config.hint.orEmpty().endsWith("[rule:${template.rule.key}]"),
+ "${template.key}'s identifier does not record its rule: ${identifier.config.hint}"
+ )
+
+ // The hashtag rule is bitcoin.mov's own; a list is its own topic.
+ assertTrue(template.fields.none { it.tag() == "t" }, "${template.key} declares a t field")
+ }
+ }
+
+ @Test
+ fun `the hint is the one curare_to writes`() {
+ // Byte for byte, because that site's `ruleOf` reads the mark back with a
+ // regular expression and a template started there and here should
+ // produce the same schema.
+ assertEquals(
+ "Derived by the client — the link, else the title and author. [rule:link-or-title]",
+ CuratedDeriveRule.LinkOrTitle.hint()
+ )
+ assertEquals(
+ "Derived by the client — the title. [rule:title]",
+ CuratedDeriveRule.Title.hint()
+ )
+ }
+
+ @Test
+ fun `every template is one the editor would have let a member build`() {
+ for (template in CuratedSchemaTemplate.entries) {
+ val names = template.fields.map { it.name }
+ assertTrue(
+ names.all { it.isNotBlank() && it.none(Char::isWhitespace) },
+ "${template.key} has a field name the editor refuses: $names"
+ )
+ assertEquals(names.distinct(), names, "${template.key} names a field twice")
+
+ for (group in template.requireAny) {
+ assertTrue(group.size > 1, "${template.key} has a rule that says nothing: $group")
+ assertTrue(
+ group.all { it in names },
+ "${template.key} has a rule naming a field it does not have: $group"
+ )
+ }
+
+ template.fields.filter { it.type == CuratedFieldType.Enum }.forEach { field ->
+ assertTrue(
+ !field.config.options.isNullOrEmpty(),
+ "${template.key}'s ${field.name} is an enum with nothing to choose from"
+ )
+ }
+ }
+ }
+
+ @Test
+ fun `the templates are the site's four, in its order`() {
+ assertEquals(
+ listOf("links", "discussion", "catalogue", "custom"),
+ CuratedSchemaTemplate.entries.map { it.key }
+ )
+
+ // The reddit-shaped default, by name: what an entry asks for and what
+ // it needs one of.
+ val links = CuratedSchemaTemplate.Links
+ assertEquals(
+ listOf("identifier", "title", "link", "body", "image", "flair"),
+ links.fields.map { it.name }
+ )
+ assertEquals(listOf(listOf("link", "body")), links.requireAny)
+ assertEquals("r", links.fields.first { it.name == "link" }.tag())
+ assertEquals(CuratedFieldConfig.CONTENT_TAG, links.fields.first { it.name == "body" }.tag())
+
+ // Custom is the two fields every list has and nothing else.
+ assertEquals(listOf("d", "title"), CuratedSchemaTemplate.Custom.fields.map { it.tag() })
+ assertEquals(emptyList(), CuratedSchemaTemplate.Custom.requireAny)
+ }
+
+ @Test
+ fun `a key finds its template, and anything else is custom`() {
+ for (template in CuratedSchemaTemplate.entries) {
+ assertSame(template, CuratedSchemaTemplate.byKey(template.key))
+ }
+
+ // Custom rather than the first: the one shape that presumes nothing
+ // about a list it was not asked for.
+ assertSame(CuratedSchemaTemplate.Custom, CuratedSchemaTemplate.byKey(null))
+ assertSame(CuratedSchemaTemplate.Custom, CuratedSchemaTemplate.byKey("gallery"))
+ assertSame(CuratedSchemaTemplate.Custom, CuratedSchemaTemplate.byKey("Links"))
+ }
+
+ private fun event(tags: Array>, content: String): Event = Event(
+ id = "a".repeat(64),
+ pubKey = curator,
+ createdAt = 1_735_689_600,
+ kind = CuratedSchemaEvent.KIND,
+ tags = tags,
+ content = content,
+ sig = "b".repeat(128),
+ )
+}
diff --git a/composeApp/src/commonTest/kotlin/to/curare/compose/ui/view/state/FrostSigningMembersTest.kt b/composeApp/src/commonTest/kotlin/to/curare/compose/ui/view/state/FrostSigningMembersTest.kt
new file mode 100644
index 00000000..731226d4
--- /dev/null
+++ b/composeApp/src/commonTest/kotlin/to/curare/compose/ui/view/state/FrostSigningMembersTest.kt
@@ -0,0 +1,112 @@
+package to.curare.compose.ui.view.state
+
+import kotlin.test.Test
+import kotlin.test.assertEquals
+import kotlin.test.assertNull
+import to.curare.compose.database.model.ChatRoom
+import to.curare.compose.database.model.Participant
+import to.curare.compose.database.model.Profile
+import to.curare.compose.database.model.intermdiate.LocalChatRoom
+import to.curare.compose.database.model.intermdiate.LocalParticipant
+
+/**
+ * Who the signing screen lists as able to answer a proposal.
+ *
+ * A room is not the set that can sign with its key. A member added after the
+ * ceremony holds no share, and the proposal they receive is dropped before it
+ * becomes a session on their device -- so they can neither sign nor refuse,
+ * and a row for them names a door that cannot answer. The list is the
+ * ceremony's share holders, with the room supplying names.
+ */
+class FrostSigningMembersTest {
+ private val alice = "a".repeat(64)
+ private val bob = "b".repeat(64)
+ private val carol = "c".repeat(64)
+
+ /** In the room, invited after the key was made, and holding no share of it. */
+ private val newcomer = "d".repeat(64)
+
+ private fun room(vararg members: String) = LocalChatRoom(
+ chatRoom = ChatRoom(
+ id = "11".repeat(32),
+ userPublicKey = alice,
+ subject = "#Ekklesia",
+ description = null,
+ mlsGroupState = null,
+ ),
+ localParticipants = members.map { publicKey ->
+ LocalParticipant(
+ participant = Participant(
+ participantPublicKey = publicKey,
+ chatRoomId = "11".repeat(32),
+ relayHint = null,
+ ),
+ profile = Profile(
+ publicKey = publicKey,
+ userName = publicKey.take(1).uppercase(),
+ nostrEventId = "e".repeat(64),
+ ),
+ )
+ },
+ )
+
+ private fun List.keys() = map { it.participant.participantPublicKey }
+
+ @Test
+ fun `a member who holds no share is not listed`() {
+ val state = FrostSigningUIState.Loaded(
+ localChatRoom = room(alice, bob, newcomer, carol),
+ shareHolders = setOf(alice, bob, carol)
+ )
+
+ // The newcomer is in the room and not in the ceremony. The session is
+ // not waiting on them and cannot be answered by them.
+ assertEquals(listOf(alice, bob, carol), state.members.keys())
+ }
+
+ @Test
+ fun `names come off the room, in the room's order`() {
+ val state = FrostSigningUIState.Loaded(
+ localChatRoom = room(carol, alice, bob),
+ shareHolders = setOf(alice, bob, carol)
+ )
+
+ assertEquals(listOf(carol, alice, bob), state.members.keys())
+ assertEquals(listOf("C", "A", "B"), state.members.map { it.profile?.userName })
+ }
+
+ @Test
+ fun `a share holder the room no longer holds still has a row`() {
+ // They left the room after the ceremony. Their share did not leave with
+ // them: the count still needs them, or needs to know they refused.
+ val state = FrostSigningUIState.Loaded(
+ localChatRoom = room(alice, bob),
+ shareHolders = setOf(alice, bob, carol)
+ )
+
+ assertEquals(listOf(alice, bob, carol), state.members.keys())
+ assertNull(state.members.last().profile)
+ }
+
+ @Test
+ fun `a room that holds a member twice lists them once`() {
+ // Participant rows are keyed on an autogenerated id, so a room can
+ // carry the same person twice; the list is of people.
+ val state = FrostSigningUIState.Loaded(
+ localChatRoom = room(alice, bob, bob),
+ shareHolders = setOf(alice, bob)
+ )
+
+ assertEquals(listOf(alice, bob), state.members.keys())
+ }
+
+ @Test
+ fun `nobody is listed until the ceremony has been read`() {
+ // The first emission has the room and not yet the session it names.
+ // Falling back to the room here would flash the wrong list -- everybody
+ // -- and then correct itself, which is worse than a moment of nobody.
+ val state = FrostSigningUIState.Loaded(localChatRoom = room(alice, bob, newcomer))
+
+ assertEquals(emptyList(), state.members)
+ }
+}
diff --git a/composeApp/src/jvmTest/kotlin/to/curare/compose/managers/FrostSigningDeclineJvmTest.kt b/composeApp/src/jvmTest/kotlin/to/curare/compose/managers/FrostSigningDeclineJvmTest.kt
new file mode 100644
index 00000000..c9e7d254
--- /dev/null
+++ b/composeApp/src/jvmTest/kotlin/to/curare/compose/managers/FrostSigningDeclineJvmTest.kt
@@ -0,0 +1,471 @@
+package to.curare.compose.managers
+
+import androidx.room3.Room
+import com.vitorpamplona.quartz.nip01Core.core.Event
+import com.vitorpamplona.quartz.nip01Core.core.HexKey
+import com.vitorpamplona.quartz.nip01Core.core.Kind
+import fr.acinq.bitcoin.ByteVector32
+import fr.acinq.bitcoin.PrivateKey
+import fr.acinq.bitcoin.crypto.frost.Frost
+import fr.acinq.bitcoin.crypto.frost.KeyMaterial
+import kotlin.test.AfterTest
+import kotlin.test.Test
+import kotlin.test.assertEquals
+import kotlin.test.assertFalse
+import kotlin.test.assertNotNull
+import kotlin.test.assertNull
+import kotlin.test.assertTrue
+import kotlin.time.Clock
+import kotlinx.coroutines.flow.first
+import kotlinx.coroutines.runBlocking
+import to.curare.compose.database.CurareDatabase
+import to.curare.compose.database.builder.getRoomDatabase
+import to.curare.compose.database.model.ChatMessage
+import to.curare.compose.database.model.ChatRoom
+import to.curare.compose.database.model.DkgParticipantMessage
+import to.curare.compose.database.model.DkgSession
+import to.curare.compose.database.model.FrostSigningItem
+import to.curare.compose.database.model.FrostSigningSession
+import to.curare.compose.database.model.NostrEvent
+import to.curare.compose.database.model.Profile
+import to.curare.compose.database.repository.DatabaseFrostSigningRepository
+import to.curare.compose.database.model.intermdiate.LocalChatRoom
+import to.curare.compose.database.model.types.DkgRitualStage
+import to.curare.compose.database.model.types.FrostSigningStage
+import to.curare.compose.extensions.toHex
+import to.curare.compose.nostr.dkg.DkgRitualEvents
+import to.curare.compose.nostr.frost.FrostSigningEvents
+
+/**
+ * What one member's refusal does to a signing session, against a real
+ * database and the real manager.
+ *
+ * A t-of-n key needs t willing members, not n, so a refusal used to do far
+ * more than it should: one member pressing "Don't sign" ended the session for
+ * everybody, in a group whose whole reason for running a ceremony was that no
+ * one member is needed. Now a refusal takes one member out of the n, and the
+ * session is abandoned only once fewer than t are left -- in the 2-of-3 group
+ * here, on the second refusal and not the first.
+ *
+ * Every device counts for itself, from the refusals it has received, and the
+ * count is checked from both sides: refusals arriving from other members, and
+ * this device's own, which is recorded as a decision and published the way an
+ * approval publishes a nonce.
+ */
+class FrostSigningDeclineJvmTest {
+ private val participants = 3
+ private val threshold = 2
+
+ /** Stands in for a completed ceremony; the test is about refusing, not the DKG. */
+ private val keyMaterial: KeyMaterial = Frost.trustedDealerKeygen(
+ thresholdSecretKey = PrivateKey(
+ ByteVector32("1c0ffee0000000000000000000000000000000000000000000000000000000a1")
+ ),
+ nParticipants = participants,
+ threshold = threshold
+ )
+
+ private val thresholdPublicKey = keyMaterial.thresholdPublicKey.value.toHex()
+
+ /** The admin room: the group's key walked to the admin path, which is its id. */
+ private val roomId = SharedKeyDerivation.marmotGroupId(thresholdPublicKey)
+
+ private val ceremonyId = "ceremony".padEnd(64, '0')
+ private val members = listOf("a", "b", "c").map { it.repeat(64) }
+ private val hostKeys = listOf("2a", "2b", "2c").map { it.padEnd(66, '0') }
+
+ private val alice = members[0]
+ private val bob = members[1]
+ private val carol = members[2]
+
+ /** A member of the room who holds no share: never in the ceremony at all. */
+ private val stranger = "d".repeat(64)
+
+ private lateinit var db: CurareDatabase
+ private lateinit var room: LocalChatRoom
+
+ @AfterTest
+ fun closeDatabase() {
+ if (::db.isInitialized) db.close()
+ }
+
+ /**
+ * One member's device: a room it can sign in, and their share to sign with.
+ *
+ * [owner] is whose device this is. The share and host key are theirs, and
+ * the room is theirs; everything else -- the ceremony, the participant
+ * order the signer ids come from -- is the same on every device.
+ */
+ private suspend fun openDevice(owner: HexKey = alice) {
+ db = getRoomDatabase(Room.inMemoryDatabaseBuilder())
+
+ val index = members.indexOf(owner)
+
+ // Profile hangs off a nostr event, and a room off a profile. Neither is
+ // anything this test is about; they are the foreign keys in the way.
+ val nostrEventId = "e$owner".take(64)
+ db.nostrEventDao().upsert(
+ NostrEvent(
+ id = nostrEventId,
+ pubKey = owner,
+ kind = 0,
+ tags = emptyArray(),
+ content = "{}",
+ sig = "0".repeat(128)
+ )
+ )
+ db.profileDao().upsert(Profile(publicKey = owner, nostrEventId = nostrEventId))
+
+ val chatRoom = ChatRoom(
+ id = roomId,
+ userPublicKey = owner,
+ subject = "#Ekklesia",
+ description = SharedKeyDerivation.describe("Admins of the group."),
+ mlsGroupState = null
+ )
+ db.chatRoomDao().upsert(chatRoom)
+
+ db.dkgSessionDao().upsert(
+ DkgSession(
+ id = ceremonyId,
+ chatRoomId = roomId,
+ coordinatorPublicKey = alice,
+ userPublicKey = owner,
+ threshold = threshold,
+ participantCount = participants,
+ stage = DkgRitualStage.COMPLETE,
+ hostPublicKey = hostKeys[index],
+ round1Random = "1".repeat(64),
+ round2AuxRandom = "2".repeat(64),
+ thresholdPublicKey = thresholdPublicKey,
+ secretShare = keyMaterial.secretShares[index].value.toHex(),
+ publicShares = keyMaterial.publicShares.joinToString(",") { it.value.toHex() }
+ )
+ )
+
+ members.forEachIndexed { i, member ->
+ db.dkgSessionDao().upsert(
+ DkgParticipantMessage(
+ sessionId = ceremonyId,
+ participantPublicKey = member,
+ kind = DkgRitualEvents.HOST_KEY,
+ payload = hostKeys[i]
+ )
+ )
+ }
+
+ room = LocalChatRoom(chatRoom = chatRoom)
+ }
+
+ /** Alice proposes, which makes her device the coordinator and agrees on her behalf. */
+ private suspend fun propose(): FrostSigningSession = FrostSigningManager.proposeSigning(
+ database = db,
+ localChatRoom = room,
+ userPublicKey = alice,
+ kind = 1,
+ tags = arrayOf(),
+ content = "Something for the group to say"
+ )
+
+ /**
+ * A session as it sits on a member's device once Alice's proposal has
+ * arrived: recorded, awaiting the owner's answer, and nothing published.
+ * Written straight to the row so the test can put a device in that state
+ * without standing up the inbound path.
+ */
+ private suspend fun proposalArrivedAt(owner: HexKey): FrostSigningSession {
+ val session = FrostSigningSession(
+ id = "s".repeat(64),
+ chatRoomId = roomId,
+ coordinatorPublicKey = alice,
+ userPublicKey = owner,
+ dkgSessionId = ceremonyId,
+ threshold = threshold,
+ participantCount = participants,
+ signerId = members.indexOf(owner),
+ derivationPath = SharedKeyDerivation.formatPath(SharedKeyDerivation.MARMOT_ADMIN_GROUP_PATH)
+ )
+ db.frostSigningSessionDao().upsert(session)
+ db.frostSigningSessionDao().upsertItems(
+ listOf(
+ FrostSigningItem(
+ sessionId = session.id,
+ itemIndex = 0,
+ unsignedEventJson = "{}",
+ eventId = "e".repeat(64),
+ nonceRandom = "f".repeat(64)
+ )
+ )
+ )
+ return session
+ }
+
+ /** One signing message from [member], as the inbound path would hand it over. */
+ private suspend fun receive(sessionId: String, kind: Kind, member: HexKey, content: String = "") {
+ FrostSigningManager.processSigningPayload(
+ database = db,
+ localChatRoom = room,
+ innerEvent = Event(
+ // The id is not read by anything here; the inbound path stores the
+ // event under it before dispatching, which this test does not do.
+ id = "$kind$member".hashCode().toUInt().toString(16).padStart(64, '0'),
+ pubKey = member,
+ createdAt = Clock.System.now().epochSeconds,
+ kind = kind,
+ tags = FrostSigningEvents.assembleTags(sessionId),
+ content = content,
+ sig = ""
+ ),
+ userPublicKey = room.chatRoom.userPublicKey
+ )
+ }
+
+ private suspend fun refusalFrom(sessionId: String, member: HexKey) =
+ receive(sessionId, FrostSigningEvents.DECLINE, member, "Declined to sign")
+
+ private suspend fun session(id: String) = db.frostSigningSessionDao().getSessionById(id)!!
+
+ private suspend fun transcript(type: String) = db.chatMessageDao()
+ .getChatMessagesByChatRoomId(roomId)
+ .map { it.chatMessage }
+ .filter { it.messageType == type }
+
+ /** What this device has queued for the group, of one kind. The room is NIP-17 here. */
+ private suspend fun queued(kind: Kind) = db.giftWrapPayloadDao()
+ .getByChatRoomAndKinds(roomId, listOf(kind))
+ .filter { it.publicKey == room.chatRoom.userPublicKey }
+
+ @Test
+ fun `one refusal in a 2-of-3 group leaves the session open`() = runBlocking {
+ openDevice()
+ val session = propose()
+
+ refusalFrom(session.id, bob)
+
+ // The point of a threshold: Alice and Carol can still sign this without
+ // Bob, so his no ends nothing.
+ val after = session(session.id)
+ assertEquals(FrostSigningStage.COLLECTING_NONCES, after.stage)
+ assertNull(after.failureReason)
+
+ // It is on file, counted, and said in the room -- with the arithmetic,
+ // so the group can see how close to ending the session now is.
+ assertNotNull(db.frostSigningSessionDao().getMessage(session.id, FrostSigningEvents.DECLINE, bob))
+ val declined = transcript(ChatMessage.TYPE_FROST_DECLINED)
+ assertEquals(1, declined.size)
+ assertEquals(bob, declined.single().senderPublicKey)
+ assertTrue(declined.single().content.contains("2 could still sign"), declined.single().content)
+ assertEquals(emptyList(), transcript(ChatMessage.TYPE_FROST_FAILED))
+ }
+
+ @Test
+ fun `the second refusal is the one that abandons it`() = runBlocking {
+ openDevice()
+ val session = propose()
+
+ refusalFrom(session.id, bob)
+ refusalFrom(session.id, carol)
+
+ // Alice alone is fewer than the two it takes.
+ val after = session(session.id)
+ assertEquals(FrostSigningStage.FAILED, after.stage)
+ assertEquals(
+ "Abandoned: 2 of 3 members declined to sign, leaving fewer than the 2 it takes.",
+ after.failureReason
+ )
+
+ // Bob's refusal was one the session survived and reads as one; Carol's
+ // is the one that ended it, and says both things. Nothing is blamed on
+ // a member for what was the group's arithmetic -- there is no FAILURE
+ // on the wire, because every device reaches the same count on its own.
+ val declined = transcript(ChatMessage.TYPE_FROST_DECLINED)
+ assertEquals(listOf(bob), declined.map { it.senderPublicKey })
+
+ val failed = transcript(ChatMessage.TYPE_FROST_FAILED)
+ assertEquals(listOf(carol), failed.map { it.senderPublicKey })
+ assertTrue(failed.single().content.startsWith("declined to sign."), failed.single().content)
+ assertTrue(failed.single().content.contains("abandoned"), failed.single().content)
+ assertEquals(emptyList(), queued(FrostSigningEvents.FAILURE))
+ }
+
+ @Test
+ fun `a redelivered refusal is counted once`() = runBlocking {
+ openDevice()
+ val session = propose()
+
+ // Relays redeliver, and a member catching up replays their backlog.
+ // The same no twice is still one member out of the n.
+ refusalFrom(session.id, bob)
+ refusalFrom(session.id, bob)
+
+ assertEquals(FrostSigningStage.COLLECTING_NONCES, session(session.id).stage)
+ assertEquals(1, transcript(ChatMessage.TYPE_FROST_DECLINED).size)
+ }
+
+ @Test
+ fun `a refusal from somebody who holds no share takes nobody out of the n`() = runBlocking {
+ openDevice()
+ val session = propose()
+
+ // A subgroup's ceremony runs in the parent's room over a subset of it,
+ // so a signing message can come from a member who was never in the
+ // ceremony. They could not have signed, so their refusing to changes
+ // what the key can do by nothing.
+ refusalFrom(session.id, bob)
+ refusalFrom(session.id, stranger)
+
+ assertEquals(FrostSigningStage.COLLECTING_NONCES, session(session.id).stage)
+ assertNull(db.frostSigningSessionDao().getMessage(session.id, FrostSigningEvents.DECLINE, stranger))
+ assertEquals(listOf(bob), transcript(ChatMessage.TYPE_FROST_DECLINED).map { it.senderPublicKey })
+ }
+
+ @Test
+ fun `refusals arriving after the group has signed abandon nothing`() = runBlocking {
+ openDevice()
+ val session = propose()
+ db.frostSigningSessionDao().upsert(session(session.id).copy(stage = FrostSigningStage.COMPLETE))
+
+ // Bob and Carol each said no before their device had seen the
+ // signature. What they refused no longer needed them, and a signature
+ // that exists is not un-made by anything that arrives afterwards.
+ refusalFrom(session.id, bob)
+ refusalFrom(session.id, carol)
+
+ assertEquals(FrostSigningStage.COMPLETE, session(session.id).stage)
+ assertEquals(emptyList(), transcript(ChatMessage.TYPE_FROST_FAILED))
+ }
+
+ @Test
+ fun `a failure arriving after the group has signed abandons nothing either`() = runBlocking {
+ openDevice()
+ val session = propose()
+ db.frostSigningSessionDao().upsert(session(session.id).copy(stage = FrostSigningStage.COMPLETE))
+
+ // The same guard, for the message a build predating the refusal kind
+ // still sends when its owner declines: it used to flip a finished
+ // session to failed, reporting a signature that exists as one that
+ // does not.
+ receive(session.id, FrostSigningEvents.FAILURE, bob, "Declined to sign")
+
+ assertEquals(FrostSigningStage.COMPLETE, session(session.id).stage)
+ assertEquals(emptyList(), transcript(ChatMessage.TYPE_FROST_FAILED))
+ }
+
+ @Test
+ fun `an old build's refusal still ends the session, as it always did`() = runBlocking {
+ openDevice()
+ val session = propose()
+
+ // A device that predates the refusal kind sends a FAILURE when its
+ // owner declines, and there is no telling that apart from a fault.
+ // It is honoured as the abandonment it always was rather than guessed
+ // at; the cost of a mixed-version group is the old behaviour, not a
+ // stall.
+ receive(session.id, FrostSigningEvents.FAILURE, bob, "Declined to sign")
+
+ assertEquals(FrostSigningStage.FAILED, session(session.id).stage)
+ }
+
+ @Test
+ fun `declining on this device says so, and leaves the session open`() = runBlocking {
+ openDevice(owner = bob)
+ val session = proposalArrivedAt(bob)
+
+ FrostSigningManager.decline(db, room, session.id)
+
+ // Bob's answer is on his row, published to the group, and counted on
+ // his own device the way it will be on every other. The session is
+ // still open around him: Alice and Carol can sign it.
+ val after = session(session.id)
+ assertNotNull(after.signDeclinedAt)
+ assertNull(after.signApprovedAt)
+ assertEquals(FrostSigningStage.COLLECTING_NONCES, after.stage)
+ assertNotNull(db.frostSigningSessionDao().getMessage(session.id, FrostSigningEvents.DECLINE, bob))
+ assertEquals(1, queued(FrostSigningEvents.DECLINE).size)
+ assertEquals(emptyList(), queued(FrostSigningEvents.NONCE))
+ assertEquals(emptyList(), queued(FrostSigningEvents.FAILURE))
+
+ // He is not asked again: the decision was his to make once.
+ assertFalse(FrostSigningManager.isAwaitingApproval(after, db.frostSigningSessionDao().getItems(session.id)))
+
+ val declined = transcript(ChatMessage.TYPE_FROST_DECLINED).single()
+ assertTrue(declined.isUserMessage)
+
+ // Carol's refusal, arriving afterwards, is the second of two -- and the
+ // one that ends it, on Bob's device as on everybody's.
+ refusalFrom(session.id, carol)
+ assertEquals(FrostSigningStage.FAILED, session(session.id).stage)
+ assertEquals(listOf(carol), transcript(ChatMessage.TYPE_FROST_FAILED).map { it.senderPublicKey })
+ }
+
+ @Test
+ fun `declining on this device as the last member who could is what abandons it`() = runBlocking {
+ openDevice(owner = bob)
+ val session = proposalArrivedAt(bob)
+
+ refusalFrom(session.id, carol)
+ assertEquals(FrostSigningStage.COLLECTING_NONCES, session(session.id).stage)
+
+ FrostSigningManager.decline(db, room, session.id)
+
+ // The refusal still goes out -- the others count it the same way -- and
+ // the ending is written in Bob's own name, since his was the answer that
+ // settled it.
+ assertEquals(FrostSigningStage.FAILED, session(session.id).stage)
+ assertEquals(1, queued(FrostSigningEvents.DECLINE).size)
+ assertEquals(emptyList(), queued(FrostSigningEvents.FAILURE))
+ assertTrue(transcript(ChatMessage.TYPE_FROST_FAILED).single().isUserMessage)
+ }
+
+ @Test
+ fun `a refusal decided but never sent goes out on the next message`() = runBlocking {
+ openDevice(owner = bob)
+ val session = proposalArrivedAt(bob)
+
+ // The device died between writing the decision and publishing it: the
+ // row says Bob refused and nothing of his is on file or on the wire.
+ db.frostSigningSessionDao().upsert(session.copy(signDeclinedAt = Clock.System.now()))
+ assertEquals(emptyList(), queued(FrostSigningEvents.DECLINE))
+
+ // Any message advancing the session is enough -- the same way a nonce
+ // an approval never got to publish goes out on the next pass.
+ receive(session.id, FrostSigningEvents.NONCE, carol, "00".repeat(66))
+
+ assertEquals(1, queued(FrostSigningEvents.DECLINE).size)
+ assertNotNull(db.frostSigningSessionDao().getMessage(session.id, FrostSigningEvents.DECLINE, bob))
+ assertEquals(FrostSigningStage.COLLECTING_NONCES, session(session.id).stage)
+ }
+
+ @Test
+ fun `who can answer is read off the ceremony, not off the room`() = runBlocking {
+ openDevice()
+ val session = propose()
+
+ // A member invited to the room after the key was made holds no share:
+ // the proposal is dropped before it becomes a session on their device,
+ // and no refusal or nonce of theirs would count. What the screen lists
+ // is who put a host key into the ceremony -- the same rows the manager
+ // places signer ids over -- and the room's roster is never consulted.
+ val shareHolders = DatabaseFrostSigningRepository(db, this)
+ .observeShareHolders(session.dkgSessionId)
+ .first()
+
+ assertEquals(setOf(alice, bob, carol), shareHolders)
+ }
+
+ @Test
+ fun `a refusal after an approval is ignored`() = runBlocking {
+ openDevice(owner = bob)
+ val session = proposalArrivedAt(bob)
+
+ FrostSigningManager.approve(db, room, session.id)
+ FrostSigningManager.decline(db, room, session.id)
+
+ // A stale screen cannot take back a nonce that has gone out. The session
+ // holds one answer from this device, and it is the first one.
+ val after = session(session.id)
+ assertNotNull(after.signApprovedAt)
+ assertNull(after.signDeclinedAt)
+ assertEquals(emptyList(), queued(FrostSigningEvents.DECLINE))
+ }
+}
diff --git a/composeApp/src/jvmTest/kotlin/to/curare/compose/ui/StringCatalogueJvmTest.kt b/composeApp/src/jvmTest/kotlin/to/curare/compose/ui/StringCatalogueJvmTest.kt
index 5ddc7b11..beb1baf2 100644
--- a/composeApp/src/jvmTest/kotlin/to/curare/compose/ui/StringCatalogueJvmTest.kt
+++ b/composeApp/src/jvmTest/kotlin/to/curare/compose/ui/StringCatalogueJvmTest.kt
@@ -8,6 +8,7 @@ import curare.composeapp.generated.resources.something_went_wrong
import curare.composeapp.generated.resources.add_chapter_to
import curare.composeapp.generated.resources.chapter_words_characters
import curare.composeapp.generated.resources.sent_a_private_message_to
+import curare.composeapp.generated.resources.template_links
import org.jetbrains.compose.resources.getString
import kotlin.test.Test
import kotlin.test.assertEquals
@@ -65,6 +66,15 @@ class StringCatalogueJvmTest {
)
}
+ @Test
+ fun `an ampersand entity comes back as an ampersand`() = runBlocking {
+ // `&` is the one character XML itself refuses in text, so it is the entity
+ // `&` in the catalogue -- an escape the parser handles rather than the
+ // resources library, and the first the app has depended on. The failure
+ // mode is a card offering "Links & text".
+ assertEquals("Links & text", getString(Res.string.template_links))
+ }
+
@Test
fun `a unicode escape was decoded into the catalogue`() = runBlocking {
// `·` is Kotlin source syntax with no meaning in XML, so the extractor
diff --git a/composeApp/src/jvmTest/kotlin/to/curare/compose/ui/composable/EditGroupCuratedSchemaScreenJvmTest.kt b/composeApp/src/jvmTest/kotlin/to/curare/compose/ui/composable/EditGroupCuratedSchemaScreenJvmTest.kt
index 5126f678..c1e7211f 100644
--- a/composeApp/src/jvmTest/kotlin/to/curare/compose/ui/composable/EditGroupCuratedSchemaScreenJvmTest.kt
+++ b/composeApp/src/jvmTest/kotlin/to/curare/compose/ui/composable/EditGroupCuratedSchemaScreenJvmTest.kt
@@ -8,7 +8,10 @@ import androidx.compose.ui.test.ExperimentalTestApi
import androidx.compose.ui.test.assertIsDisplayed
import androidx.compose.ui.test.assertIsNotEnabled
import androidx.compose.ui.test.assertIsOn
+import androidx.compose.ui.test.assertCountEquals
+import androidx.compose.ui.test.assertIsNotSelected
import androidx.compose.ui.test.assertIsSelected
+import androidx.compose.ui.test.onAllNodesWithText
import androidx.compose.ui.test.getBoundsInRoot
import androidx.compose.ui.test.onNodeWithContentDescription
import androidx.compose.ui.test.onNodeWithText
@@ -24,6 +27,7 @@ import to.curare.compose.nostr.curated.CuratedFieldConfig
import to.curare.compose.nostr.curated.CuratedFieldType
import to.curare.compose.nostr.curated.CuratedSchema
import to.curare.compose.nostr.curated.CuratedSchemaEvent
+import to.curare.compose.nostr.curated.CuratedSchemaTemplate
import to.curare.compose.nostr.curated.CuratedVisibility
import to.curare.compose.repository.ChatRepository
import to.curare.compose.repository.FrostSigningRepository
@@ -42,7 +46,9 @@ import kotlin.time.Instant
* own relays are on the form before anything is typed, because they are what the
* group will sign whether or not the member adds to them -- and a form that
* showed an empty list and then signed two fields would be lying about what it
- * proposed.
+ * proposed. A new list from a template starts at the template: its fields as
+ * rows and its rules as chips, since the picker before this screen promised
+ * that shape and the form is where the promise is kept.
*
* **An existing list opens as an edit.** Its identifier is locked and the form
* says why, its rules show which fields they name, and the suggesters a closed
@@ -113,6 +119,37 @@ class EditGroupCuratedSchemaScreenJvmTest {
.assertDoesNotExist()
}
+ @Test
+ fun `a new list from a template starts at the template's fields and rules`() = render(
+ state(existing = null, defaultRelays = listOf("wss://relay.one.example/")),
+ template = CuratedSchemaTemplate.Links.key
+ ) {
+ // The template's fields, in its order, the mandatory two included --
+ // and the identifier still marked derived, since the template records
+ // its rule in the hint rather than prompting for the value.
+ onNodeWithText("identifier · Token · Required · Derived").assertIsDisplayed()
+ val title = onNodeWithText("title · Text · Required").getBoundsInRoot().top
+ val link = onNodeWithText("link · Url · Optional").getBoundsInRoot().top
+ val body = onNodeWithText("body · Long text · Optional").getBoundsInRoot().top
+ val image = onNodeWithText("image · Image · Optional").getBoundsInRoot().top
+ val flair = onNodeWithText("flair · One of a list · Optional").getBoundsInRoot().top
+ assertTrue(title < link && link < body && body < image && image < flair, "the fields were drawn out of order")
+
+ // The rule the template carries, as a row of chips with its two fields
+ // selected. The chip is the one node saying exactly "link": the row
+ // above is headed by the label, "Link", and its supporting line says more.
+ onNodeWithText("At least one of").assertIsDisplayed()
+ onAllNodesWithText("link").assertCountEquals(1)
+ onNodeWithText("link").assertIsSelected()
+ onNodeWithText("body").assertIsSelected()
+ onNodeWithText("flair").assertIsNotSelected()
+
+ // Everything else is as a new list is.
+ onNodeWithText("wss://relay.one.example/").assertIsDisplayed()
+ onNodeWithText("Public").assertIsSelected()
+ onNodeWithText("Propose schema").assertIsDisplayed()
+ }
+
@Test
fun `an existing list opens as an edit with its identifier locked`() = render(
state(existing = existing(films))
@@ -210,6 +247,7 @@ class EditGroupCuratedSchemaScreenJvmTest {
*/
private fun render(
uiState: EditGroupCuratedSchemaUIState,
+ template: String? = null,
assertions: ComposeUiTest.() -> Unit
) = runDesktopComposeUiTest(width = 400, height = 3000) {
setContent {
@@ -222,6 +260,7 @@ class EditGroupCuratedSchemaScreenJvmTest {
relayHint = null,
identifier = (uiState as? EditGroupCuratedSchemaUIState.Loaded)
?.existing?.identifier,
+ template = template,
initialEditGroupCuratedSchemaUIState = uiState,
chatRepository = ChatRepository.NO_OP_CHAT_REPOSITORY,
frostSigningRepository =
diff --git a/composeApp/src/jvmTest/kotlin/to/curare/compose/ui/composable/GroupCuratedSchemasScreenJvmTest.kt b/composeApp/src/jvmTest/kotlin/to/curare/compose/ui/composable/GroupCuratedSchemasScreenJvmTest.kt
index f0ec7b3a..a33cbee7 100644
--- a/composeApp/src/jvmTest/kotlin/to/curare/compose/ui/composable/GroupCuratedSchemasScreenJvmTest.kt
+++ b/composeApp/src/jvmTest/kotlin/to/curare/compose/ui/composable/GroupCuratedSchemasScreenJvmTest.kt
@@ -22,6 +22,7 @@ import to.curare.compose.ui.composable.navigation.routes.BroadcastGroupSignedEve
import to.curare.compose.ui.composable.navigation.routes.CuratedSuggestionListRoute
import to.curare.compose.ui.composable.navigation.routes.EditGroupCuratedSchemaRoute
import to.curare.compose.ui.composable.navigation.routes.Route
+import to.curare.compose.ui.composable.navigation.routes.SelectCuratedSchemaTemplateRoute
import to.curare.compose.ui.composable.widgets.ProvideSnackbarHost
import to.curare.compose.ui.theme.CurareTheme
import to.curare.compose.ui.view.state.GroupCuratedSchemasUIState
@@ -33,8 +34,8 @@ import kotlin.test.assertTrue
/**
* The schemas of the lists the group curates on their own screen: one card per
* list, most recently signed first, each with its queue and its broadcast, and
- * two ways into the editor -- the card for a revision, the button for a new
- * list -- for a member holding a share.
+ * two ways on -- the card into the editor for a revision, the button into the
+ * template picker for a new list -- for a member holding a share.
*/
@OptIn(ExperimentalTestApi::class)
class GroupCuratedSchemasScreenJvmTest {
@@ -129,26 +130,29 @@ class GroupCuratedSchemasScreenJvmTest {
activeUserPublicKey = activeUserPublicKey,
chatRoomId = chatRoomId,
relayHint = null,
- identifier = "books"
+ identifier = "books",
+ // A revision starts from the schema itself, not from a shape.
+ template = null
),
opened
)
}
@Test
- fun `the button opens the editor on no schema at all`() {
+ fun `the button opens the template picker, not the editor`() {
var opened: Route? = null
render(state(schemas = listOf(films)), onNavigateToRoute = { opened = it }) {
onNodeWithText("Add schema").performClick()
}
+ // A new list has a shape to choose before it has a form to fill, and
+ // the picker is what opens the editor, on the shape chosen there.
assertEquals(
- EditGroupCuratedSchemaRoute(
+ SelectCuratedSchemaTemplateRoute(
activeUserPublicKey = activeUserPublicKey,
chatRoomId = chatRoomId,
- relayHint = null,
- identifier = null
+ relayHint = null
),
opened
)
@@ -189,7 +193,7 @@ class GroupCuratedSchemasScreenJvmTest {
}
assertEquals(
- EditGroupCuratedSchemaRoute(activeUserPublicKey, chatRoomId, relayHint = null, identifier = null),
+ SelectCuratedSchemaTemplateRoute(activeUserPublicKey, chatRoomId, relayHint = null),
opened
)
}
diff --git a/composeApp/src/jvmTest/kotlin/to/curare/compose/ui/composable/SelectCuratedSchemaTemplateScreenJvmTest.kt b/composeApp/src/jvmTest/kotlin/to/curare/compose/ui/composable/SelectCuratedSchemaTemplateScreenJvmTest.kt
new file mode 100644
index 00000000..a41a5908
--- /dev/null
+++ b/composeApp/src/jvmTest/kotlin/to/curare/compose/ui/composable/SelectCuratedSchemaTemplateScreenJvmTest.kt
@@ -0,0 +1,115 @@
+package to.curare.compose.ui.composable
+
+import androidx.compose.foundation.layout.Box
+import androidx.compose.foundation.layout.fillMaxSize
+import androidx.compose.ui.Modifier
+import androidx.compose.ui.test.ComposeUiTest
+import androidx.compose.ui.test.ExperimentalTestApi
+import androidx.compose.ui.test.assertIsDisplayed
+import androidx.compose.ui.test.getBoundsInRoot
+import androidx.compose.ui.test.onNodeWithContentDescription
+import androidx.compose.ui.test.onNodeWithText
+import androidx.compose.ui.test.performClick
+import androidx.compose.ui.test.runDesktopComposeUiTest
+import to.curare.compose.nostr.curated.CuratedSchemaTemplate
+import to.curare.compose.ui.composable.GroupSignedWorkFixtures.activeUserPublicKey
+import to.curare.compose.ui.composable.GroupSignedWorkFixtures.chatRoomId
+import to.curare.compose.ui.composable.navigation.routes.EditGroupCuratedSchemaRoute
+import to.curare.compose.ui.composable.navigation.routes.Route
+import to.curare.compose.ui.composable.widgets.ProvideSnackbarHost
+import to.curare.compose.ui.theme.CurareTheme
+import kotlin.test.Test
+import kotlin.test.assertEquals
+import kotlin.test.assertTrue
+
+/**
+ * The first step of adding a schema: the shapes a list can start from, one
+ * card each, and the editor opened on the one tapped.
+ *
+ * **Every shape is offered, in the site's order, saying what it asks for.** A
+ * member choosing a shape reads the fields to choose, so the card lists them,
+ * and the list is the template's own -- a card that summarised a template in
+ * its own words could drift from what the editor then opens on.
+ *
+ * **A card opens the editor on its template and nothing else.** The route
+ * carries the key and no identifier, which is the whole of what the picker
+ * decides; the editor seeds from the key, so a wrong one here is a form that
+ * opens on the wrong fields with nothing saying so.
+ */
+@OptIn(ExperimentalTestApi::class)
+class SelectCuratedSchemaTemplateScreenJvmTest {
+
+ @Test
+ fun `every shape is offered, in the site's order, with what an entry in it asks for`() = render {
+ onNodeWithText("Start a list").assertIsDisplayed()
+ onNodeWithText("A list is a schema", substring = true).assertIsDisplayed()
+
+ val links = onNodeWithText("Links & text").assertIsDisplayed().getBoundsInRoot().top
+ val discussion = onNodeWithText("Discussion").assertIsDisplayed().getBoundsInRoot().top
+ val catalogue = onNodeWithText("Catalogue").assertIsDisplayed().getBoundsInRoot().top
+ val custom = onNodeWithText("Custom").assertIsDisplayed().getBoundsInRoot().top
+ assertTrue(
+ links < discussion && discussion < catalogue && catalogue < custom,
+ "the shapes were drawn out of order"
+ )
+
+ // What each asks for, by label, the identifier included: the editor's
+ // row for it is there too and says it is derived.
+ onNodeWithText("Fields: Identifier, Title, Link, Text, Picture, Flair").assertIsDisplayed()
+ onNodeWithText("Fields: Identifier, Title, Text, Flair").assertIsDisplayed()
+ onNodeWithText(
+ "Fields: Identifier, Title, Year, Type, External id, Where to see it, Reference, " +
+ "Picture, Language, Description"
+ ).assertIsDisplayed()
+ onNodeWithText("Fields: Identifier, Title").assertIsDisplayed()
+
+ // And what each is for, in the site's words.
+ onNodeWithText("Reddit’s default", substring = true).assertIsDisplayed()
+ onNodeWithText("bitcoin.mov’s shape", substring = true).assertIsDisplayed()
+
+ onNodeWithContentDescription("Back").assertIsDisplayed()
+ }
+
+ @Test
+ fun `a card opens the editor on its template, and on no schema`() {
+ var opened: Route? = null
+
+ render(onNavigateToRoute = { opened = it }) {
+ onNodeWithText("Catalogue").performClick()
+ }
+
+ assertEquals(
+ EditGroupCuratedSchemaRoute(
+ activeUserPublicKey = activeUserPublicKey,
+ chatRoomId = chatRoomId,
+ relayHint = null,
+ identifier = null,
+ template = CuratedSchemaTemplate.Catalogue.key
+ ),
+ opened
+ )
+ }
+
+ private fun render(
+ onNavigateToRoute: (Route) -> Unit = {},
+ assertions: ComposeUiTest.() -> Unit
+ ) = runDesktopComposeUiTest(width = 400, height = 1600) {
+ setContent {
+ CurareTheme {
+ ProvideSnackbarHost {
+ Box(modifier = Modifier.fillMaxSize()) {
+ SelectCuratedSchemaTemplateScreen(
+ activeUserPublicKey = activeUserPublicKey,
+ chatRoomId = chatRoomId,
+ relayHint = null,
+ onNavigateToRoute = onNavigateToRoute,
+ onNavigateBack = {},
+ )
+ }
+ }
+ }
+ }
+
+ assertions()
+ }
+}
diff --git a/composeApp/src/jvmTest/kotlin/to/curare/compose/ui/view/model/EditGroupCuratedSchemaViewModelJvmTest.kt b/composeApp/src/jvmTest/kotlin/to/curare/compose/ui/view/model/EditGroupCuratedSchemaViewModelJvmTest.kt
index 09ca3683..8f536e85 100644
--- a/composeApp/src/jvmTest/kotlin/to/curare/compose/ui/view/model/EditGroupCuratedSchemaViewModelJvmTest.kt
+++ b/composeApp/src/jvmTest/kotlin/to/curare/compose/ui/view/model/EditGroupCuratedSchemaViewModelJvmTest.kt
@@ -11,6 +11,7 @@ import to.curare.compose.nostr.curated.CuratedFieldType
import to.curare.compose.nostr.curated.CuratedSchema
import to.curare.compose.nostr.curated.CuratedSchemaEvent
import to.curare.compose.nostr.curated.CuratedSchemaProblem
+import to.curare.compose.nostr.curated.CuratedSchemaTemplate
import to.curare.compose.nostr.curated.CuratedVisibility
import to.curare.compose.repository.ChatRepository
import to.curare.compose.repository.FrostSigningRepository
@@ -25,9 +26,10 @@ import kotlin.time.Instant
/**
* The decisions the schema editor makes that nothing else can check.
*
- * **What a new list starts as.** The two fields every list has and the group's
- * own relays, so that what the member sees is what the group will sign rather
- * than what `CuratedSchema.normalized` will quietly add.
+ * **What a new list starts as.** Its template's fields and rules -- the two
+ * fields every list has, when no shape was chosen -- and the group's own relays,
+ * so that what the member sees is what the group will sign rather than what
+ * `CuratedSchema.normalized` will quietly add.
*
* **What cannot be taken away.** A field writing to `d` or `title` cannot be
* removed, because the event would only grow it back -- so the editor has to
@@ -58,11 +60,12 @@ class EditGroupCuratedSchemaViewModelJvmTest {
relays = listOf("wss://relay.one.example"),
)
- private fun viewModel(identifier: String? = null) = EditGroupCuratedSchemaViewModel(
+ private fun viewModel(identifier: String? = null, template: String? = null) = EditGroupCuratedSchemaViewModel(
chatRoomId = chatRoomId,
activeUserPublicKey = "a".repeat(64),
relayHint = null,
identifier = identifier,
+ template = template,
initialEditGroupCuratedSchemaUIState = EditGroupCuratedSchemaUIState.Loading,
chatRepository = ChatRepository.NO_OP_CHAT_REPOSITORY,
frostSigningRepository = FrostSigningRepository.NO_OP_FROST_SIGNING_REPOSITORY,
@@ -122,9 +125,43 @@ class EditGroupCuratedSchemaViewModelJvmTest {
assertEquals(emptyList(), viewModel.suggesters)
}
+ @Test
+ fun `a new schema from a template starts at the template's fields and rules`() {
+ val viewModel = viewModel(template = CuratedSchemaTemplate.Links.key)
+ viewModel.seedWorkingCopy(newSchema())
+
+ assertEquals(CuratedSchemaTemplate.Links.fields, viewModel.fields.toList())
+ assertEquals(CuratedSchemaTemplate.Links.requireAny, viewModel.requireAny.toList())
+ // The identifier is the template's: derived, with its rule in the hint.
+ assertTrue(viewModel.isMandatory(viewModel.fields[0]))
+ assertTrue(viewModel.fields[0].config.hint.orEmpty().endsWith("[rule:link-or-title]"))
+ // What the template does not decide is as any new list's.
+ assertEquals(CuratedVisibility.Public, viewModel.visibility)
+ assertEquals(listOf("wss://relay.one.example"), viewModel.relays)
+ assertEquals(emptyList(), viewModel.suggesters)
+
+ // And the draft it makes is a usable schema as it stands, so a member
+ // who fills in the identity and presses the button proposes the shape.
+ val draft = viewModel.draft("links", "Link suggestion", "Links", "Things worth a look.", "", "")
+ assertTrue(draft.isUsable())
+ assertEquals(listOf(listOf("link", "body")), draft.requireAny)
+ }
+
+ @Test
+ fun `a template key this build does not know starts at the two fields every list has`() {
+ val viewModel = viewModel(template = "gallery")
+ viewModel.seedWorkingCopy(newSchema())
+
+ assertEquals(CuratedSchemaTemplate.Custom.fields, viewModel.fields.toList())
+ assertEquals(listOf("d", "title"), viewModel.fields.map { it.tag() })
+ assertEquals(emptyList(), viewModel.requireAny)
+ }
+
@Test
fun `an existing schema starts as itself, and its relays are its own`() {
- val viewModel = viewModel("films")
+ // A template beside an identifier is ignored: an edit starts from the
+ // schema the group signed, whatever shape the route also names.
+ val viewModel = viewModel("films", template = CuratedSchemaTemplate.Catalogue.key)
viewModel.seedWorkingCopy(editing())
assertEquals(films.fields, viewModel.fields.toList())