diff --git a/.sqlx/query-03c0a65ec465d513f0c366143ec91c94213a52a6c3cee04df6cb4ed3a01204ac.json b/.sqlx/query-03c0a65ec465d513f0c366143ec91c94213a52a6c3cee04df6cb4ed3a01204ac.json deleted file mode 100644 index 56efbd8..0000000 --- a/.sqlx/query-03c0a65ec465d513f0c366143ec91c94213a52a6c3cee04df6cb4ed3a01204ac.json +++ /dev/null @@ -1,26 +0,0 @@ -{ - "db_name": "SQLite", - "query": "SELECT canonical_path FROM ldraw_manifest_files WHERE resource_uri = ? ORDER BY ordinal", - "describe": { - "columns": [ - { - "name": "canonical_path", - "ordinal": 0, - "type_info": "Text", - "origin": { - "Table": { - "table": "ldraw_manifest_files", - "name": "canonical_path" - } - } - } - ], - "parameters": { - "Right": 1 - }, - "nullable": [ - false - ] - }, - "hash": "03c0a65ec465d513f0c366143ec91c94213a52a6c3cee04df6cb4ed3a01204ac" -} diff --git a/.sqlx/query-0c73a5469315d589306c17a8f9f8291e50b4e4f10d90b195728862de03c7bd1d.json b/.sqlx/query-0c73a5469315d589306c17a8f9f8291e50b4e4f10d90b195728862de03c7bd1d.json deleted file mode 100644 index 515f7a9..0000000 --- a/.sqlx/query-0c73a5469315d589306c17a8f9f8291e50b4e4f10d90b195728862de03c7bd1d.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "db_name": "SQLite", - "query": "UPDATE ldraw_verification SET state = 'rejected', diagnostic = 'integrity-mismatch-v1', attempt_token = NULL, lease_expires_at = NULL, updated_at = ? WHERE resource_uri = ? AND source_identity = ? AND state = 'verifying' AND attempt_token = ? AND lease_expires_at > ?", - "describe": { - "columns": [], - "parameters": { - "Right": 5 - }, - "nullable": [] - }, - "hash": "0c73a5469315d589306c17a8f9f8291e50b4e4f10d90b195728862de03c7bd1d" -} diff --git a/.sqlx/query-12a25657d903219f5be9f92b4ed1fc596f3a4aee26020f9e67906762b4357d83.json b/.sqlx/query-12a25657d903219f5be9f92b4ed1fc596f3a4aee26020f9e67906762b4357d83.json deleted file mode 100644 index b348d34..0000000 --- a/.sqlx/query-12a25657d903219f5be9f92b4ed1fc596f3a4aee26020f9e67906762b4357d83.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "db_name": "SQLite", - "query": "INSERT INTO ldraw_resources (resource_uri, owner_did, project_uri, record_cid, rkey, root, canonical_path, mime_type, byte_length, sha256, ordered_blob_cids, provenance, licence, notices_json, snapshot_id, legacy, revoked_at, created_at, updated_at) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, 0, NULL, ?, ?) ON CONFLICT(resource_uri) DO UPDATE SET owner_did = excluded.owner_did, project_uri = excluded.project_uri, record_cid = excluded.record_cid, rkey = excluded.rkey, root = excluded.root, canonical_path = excluded.canonical_path, mime_type = excluded.mime_type, byte_length = excluded.byte_length, sha256 = excluded.sha256, ordered_blob_cids = excluded.ordered_blob_cids, provenance = excluded.provenance, licence = excluded.licence, notices_json = excluded.notices_json, snapshot_id = excluded.snapshot_id, legacy = 0, revoked_at = NULL, updated_at = excluded.updated_at", - "describe": { - "columns": [], - "parameters": { - "Right": 17 - }, - "nullable": [] - }, - "hash": "12a25657d903219f5be9f92b4ed1fc596f3a4aee26020f9e67906762b4357d83" -} diff --git a/.sqlx/query-1770125c2a78c4541fc0285cc6ad8961c210daa215e7daecc96ec0ed099303c9.json b/.sqlx/query-1770125c2a78c4541fc0285cc6ad8961c210daa215e7daecc96ec0ed099303c9.json deleted file mode 100644 index e11fbe7..0000000 --- a/.sqlx/query-1770125c2a78c4541fc0285cc6ad8961c210daa215e7daecc96ec0ed099303c9.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "db_name": "SQLite", - "query": "DELETE FROM ldraw_verification WHERE resource_uri = ?", - "describe": { - "columns": [], - "parameters": { - "Right": 1 - }, - "nullable": [] - }, - "hash": "1770125c2a78c4541fc0285cc6ad8961c210daa215e7daecc96ec0ed099303c9" -} diff --git a/.sqlx/query-272bebe0a71065b578e43eb6ea762c786dc120d94affe5a89c9348b6c8088d7e.json b/.sqlx/query-272bebe0a71065b578e43eb6ea762c786dc120d94affe5a89c9348b6c8088d7e.json deleted file mode 100644 index e1d0050..0000000 --- a/.sqlx/query-272bebe0a71065b578e43eb6ea762c786dc120d94affe5a89c9348b6c8088d7e.json +++ /dev/null @@ -1,26 +0,0 @@ -{ - "db_name": "SQLite", - "query": "SELECT source_identity FROM ldraw_verification WHERE resource_uri = ?", - "describe": { - "columns": [ - { - "name": "source_identity", - "ordinal": 0, - "type_info": "Text", - "origin": { - "Table": { - "table": "ldraw_verification", - "name": "source_identity" - } - } - } - ], - "parameters": { - "Right": 1 - }, - "nullable": [ - false - ] - }, - "hash": "272bebe0a71065b578e43eb6ea762c786dc120d94affe5a89c9348b6c8088d7e" -} diff --git a/.sqlx/query-3d262dca6464811f937abcdec25c40a422c78da75ffd632c6f4466277fde1326.json b/.sqlx/query-3d262dca6464811f937abcdec25c40a422c78da75ffd632c6f4466277fde1326.json deleted file mode 100644 index 1b57cfb..0000000 --- a/.sqlx/query-3d262dca6464811f937abcdec25c40a422c78da75ffd632c6f4466277fde1326.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "db_name": "SQLite", - "query": "UPDATE ldraw_verification SET state = 'verifying', attempt_token = ?, lease_expires_at = ?, expired_attempts = expired_attempts + CASE WHEN state = 'verifying' AND (lease_expires_at IS NULL OR lease_expires_at <= ?) THEN 1 ELSE 0 END, updated_at = ? WHERE resource_uri = ? AND source_identity = ? AND expired_attempts < ? AND (state = 'unverified' OR (state = 'verifying' AND (lease_expires_at IS NULL OR lease_expires_at <= ?)))", - "describe": { - "columns": [], - "parameters": { - "Right": 8 - }, - "nullable": [] - }, - "hash": "3d262dca6464811f937abcdec25c40a422c78da75ffd632c6f4466277fde1326" -} diff --git a/.sqlx/query-41f9fc023947387af3cfbf1fc38d8bbe9c31409a93f67fe9505885fb2906b306.json b/.sqlx/query-41f9fc023947387af3cfbf1fc38d8bbe9c31409a93f67fe9505885fb2906b306.json deleted file mode 100644 index 410870a..0000000 --- a/.sqlx/query-41f9fc023947387af3cfbf1fc38d8bbe9c31409a93f67fe9505885fb2906b306.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "db_name": "SQLite", - "query": "DELETE FROM ldraw_manifest_files WHERE resource_uri = ?", - "describe": { - "columns": [], - "parameters": { - "Right": 1 - }, - "nullable": [] - }, - "hash": "41f9fc023947387af3cfbf1fc38d8bbe9c31409a93f67fe9505885fb2906b306" -} diff --git a/.sqlx/query-44dcf63108ea15a5eb476ea93af8d8ea027f90cccfec9831f4365fb788bcf572.json b/.sqlx/query-44dcf63108ea15a5eb476ea93af8d8ea027f90cccfec9831f4365fb788bcf572.json deleted file mode 100644 index 775009a..0000000 --- a/.sqlx/query-44dcf63108ea15a5eb476ea93af8d8ea027f90cccfec9831f4365fb788bcf572.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "db_name": "SQLite", - "query": "UPDATE ldraw_verification SET state = 'rejected', diagnostic = ?, attempt_token = NULL, lease_expires_at = NULL, updated_at = ? WHERE resource_uri = ? AND source_identity = ? AND state = 'verifying' AND attempt_token = ? AND (lease_expires_at IS NULL OR lease_expires_at <= ?)", - "describe": { - "columns": [], - "parameters": { - "Right": 6 - }, - "nullable": [] - }, - "hash": "44dcf63108ea15a5eb476ea93af8d8ea027f90cccfec9831f4365fb788bcf572" -} diff --git a/.sqlx/query-5844b01e7fcf3c20487bc56e87f67253c8f2fae989e207eb90deaeac29d3aba7.json b/.sqlx/query-5844b01e7fcf3c20487bc56e87f67253c8f2fae989e207eb90deaeac29d3aba7.json deleted file mode 100644 index ae1999a..0000000 --- a/.sqlx/query-5844b01e7fcf3c20487bc56e87f67253c8f2fae989e207eb90deaeac29d3aba7.json +++ /dev/null @@ -1,74 +0,0 @@ -{ - "db_name": "SQLite", - "query": "SELECT state, attempt_token, lease_expires_at, expired_attempts, revoked_at FROM ldraw_verification WHERE resource_uri = ?", - "describe": { - "columns": [ - { - "name": "state", - "ordinal": 0, - "type_info": "Text", - "origin": { - "Table": { - "table": "ldraw_verification", - "name": "state" - } - } - }, - { - "name": "attempt_token", - "ordinal": 1, - "type_info": "Text", - "origin": { - "Table": { - "table": "ldraw_verification", - "name": "attempt_token" - } - } - }, - { - "name": "lease_expires_at", - "ordinal": 2, - "type_info": "Integer", - "origin": { - "Table": { - "table": "ldraw_verification", - "name": "lease_expires_at" - } - } - }, - { - "name": "expired_attempts", - "ordinal": 3, - "type_info": "Integer", - "origin": { - "Table": { - "table": "ldraw_verification", - "name": "expired_attempts" - } - } - }, - { - "name": "revoked_at", - "ordinal": 4, - "type_info": "Integer", - "origin": { - "Table": { - "table": "ldraw_verification", - "name": "revoked_at" - } - } - } - ], - "parameters": { - "Right": 1 - }, - "nullable": [ - false, - true, - true, - false, - true - ] - }, - "hash": "5844b01e7fcf3c20487bc56e87f67253c8f2fae989e207eb90deaeac29d3aba7" -} diff --git a/.sqlx/query-5d544dae914a0c4b37c629d6e21c2a5a075703f9c7c20f7c6b01503eddb7ad3d.json b/.sqlx/query-5d544dae914a0c4b37c629d6e21c2a5a075703f9c7c20f7c6b01503eddb7ad3d.json deleted file mode 100644 index ae8d051..0000000 --- a/.sqlx/query-5d544dae914a0c4b37c629d6e21c2a5a075703f9c7c20f7c6b01503eddb7ad3d.json +++ /dev/null @@ -1,110 +0,0 @@ -{ - "db_name": "SQLite", - "query": "SELECT resource_uri, owner_did, sha256, ordered_blob_cids, root, canonical_path, mime_type, byte_length\n FROM ldraw_resources\n WHERE project_uri = ? AND revoked_at IS NULL\n AND (owner_did = ? OR owner_did = 'public')", - "describe": { - "columns": [ - { - "name": "resource_uri", - "ordinal": 0, - "type_info": "Text", - "origin": { - "Table": { - "table": "ldraw_resources", - "name": "resource_uri" - } - } - }, - { - "name": "owner_did", - "ordinal": 1, - "type_info": "Text", - "origin": { - "Table": { - "table": "ldraw_resources", - "name": "owner_did" - } - } - }, - { - "name": "sha256", - "ordinal": 2, - "type_info": "Blob", - "origin": { - "Table": { - "table": "ldraw_resources", - "name": "sha256" - } - } - }, - { - "name": "ordered_blob_cids", - "ordinal": 3, - "type_info": "Text", - "origin": { - "Table": { - "table": "ldraw_resources", - "name": "ordered_blob_cids" - } - } - }, - { - "name": "root", - "ordinal": 4, - "type_info": "Text", - "origin": { - "Table": { - "table": "ldraw_resources", - "name": "root" - } - } - }, - { - "name": "canonical_path", - "ordinal": 5, - "type_info": "Text", - "origin": { - "Table": { - "table": "ldraw_resources", - "name": "canonical_path" - } - } - }, - { - "name": "mime_type", - "ordinal": 6, - "type_info": "Text", - "origin": { - "Table": { - "table": "ldraw_resources", - "name": "mime_type" - } - } - }, - { - "name": "byte_length", - "ordinal": 7, - "type_info": "Integer", - "origin": { - "Table": { - "table": "ldraw_resources", - "name": "byte_length" - } - } - } - ], - "parameters": { - "Right": 2 - }, - "nullable": [ - true, - false, - false, - false, - false, - false, - false, - false - ] - }, - "hash": "5d544dae914a0c4b37c629d6e21c2a5a075703f9c7c20f7c6b01503eddb7ad3d" -} diff --git a/.sqlx/query-6060ba495ee11bc99e7413a63d3b84bb1a01d4d3c2cd0255dff055cfc96a2988.json b/.sqlx/query-6060ba495ee11bc99e7413a63d3b84bb1a01d4d3c2cd0255dff055cfc96a2988.json deleted file mode 100644 index 740ab26..0000000 --- a/.sqlx/query-6060ba495ee11bc99e7413a63d3b84bb1a01d4d3c2cd0255dff055cfc96a2988.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "db_name": "SQLite", - "query": "INSERT INTO ldraw_manifest_files (resource_uri, root, canonical_path, target_resource_uri, target_cid, byte_length, sha256, mime_type, ordinal) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)", - "describe": { - "columns": [], - "parameters": { - "Right": 9 - }, - "nullable": [] - }, - "hash": "6060ba495ee11bc99e7413a63d3b84bb1a01d4d3c2cd0255dff055cfc96a2988" -} diff --git a/.sqlx/query-6c4e932e52b026c5b2ec8e4eab38baa9ea3e461c6efd74e4eaad7c9c7f30ab58.json b/.sqlx/query-6c4e932e52b026c5b2ec8e4eab38baa9ea3e461c6efd74e4eaad7c9c7f30ab58.json deleted file mode 100644 index 33352e6..0000000 --- a/.sqlx/query-6c4e932e52b026c5b2ec8e4eab38baa9ea3e461c6efd74e4eaad7c9c7f30ab58.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "db_name": "SQLite", - "query": "DELETE FROM ldraw_routes WHERE resource_uri = ?", - "describe": { - "columns": [], - "parameters": { - "Right": 1 - }, - "nullable": [] - }, - "hash": "6c4e932e52b026c5b2ec8e4eab38baa9ea3e461c6efd74e4eaad7c9c7f30ab58" -} diff --git a/.sqlx/query-7403588ae3949498232f7481cbca588775a2b241ceb79a297bdc6fab569a9632.json b/.sqlx/query-7403588ae3949498232f7481cbca588775a2b241ceb79a297bdc6fab569a9632.json deleted file mode 100644 index 09fcc8c..0000000 --- a/.sqlx/query-7403588ae3949498232f7481cbca588775a2b241ceb79a297bdc6fab569a9632.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "db_name": "SQLite", - "query": "INSERT INTO ldraw_routes (token_digest, principal_did, project_uri, resource_uri, source_identity, root, canonical_path, target_identity, expires_at, revoked_at, created_at) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, NULL, ?)", - "describe": { - "columns": [], - "parameters": { - "Right": 10 - }, - "nullable": [] - }, - "hash": "7403588ae3949498232f7481cbca588775a2b241ceb79a297bdc6fab569a9632" -} diff --git a/.sqlx/query-814fc55f4acca61fd8a2d38aaf0a6bc5b5e293e199b4803a86f970f74a8f0e87.json b/.sqlx/query-814fc55f4acca61fd8a2d38aaf0a6bc5b5e293e199b4803a86f970f74a8f0e87.json deleted file mode 100644 index e0c11d3..0000000 --- a/.sqlx/query-814fc55f4acca61fd8a2d38aaf0a6bc5b5e293e199b4803a86f970f74a8f0e87.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "db_name": "SQLite", - "query": "UPDATE ldraw_verification SET state = 'verified', attempt_token = NULL, lease_expires_at = NULL, diagnostic = NULL, updated_at = ? WHERE resource_uri = ? AND source_identity = ? AND state = 'verifying' AND attempt_token = ? AND lease_expires_at > ?", - "describe": { - "columns": [], - "parameters": { - "Right": 5 - }, - "nullable": [] - }, - "hash": "814fc55f4acca61fd8a2d38aaf0a6bc5b5e293e199b4803a86f970f74a8f0e87" -} diff --git a/.sqlx/query-99c8471612e0ce58357a8e6b1ac562f14478cab8f7ef551cd78dd46707c97975.json b/.sqlx/query-99c8471612e0ce58357a8e6b1ac562f14478cab8f7ef551cd78dd46707c97975.json deleted file mode 100644 index f6e12b2..0000000 --- a/.sqlx/query-99c8471612e0ce58357a8e6b1ac562f14478cab8f7ef551cd78dd46707c97975.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "db_name": "SQLite", - "query": "DELETE FROM ldraw_resources WHERE resource_uri = ?", - "describe": { - "columns": [], - "parameters": { - "Right": 1 - }, - "nullable": [] - }, - "hash": "99c8471612e0ce58357a8e6b1ac562f14478cab8f7ef551cd78dd46707c97975" -} diff --git a/.sqlx/query-ab292cdba60a459dbd285ab15c365b2fc87dafaa3db91cc9521458f1aa81e95b.json b/.sqlx/query-ab292cdba60a459dbd285ab15c365b2fc87dafaa3db91cc9521458f1aa81e95b.json deleted file mode 100644 index c497510..0000000 --- a/.sqlx/query-ab292cdba60a459dbd285ab15c365b2fc87dafaa3db91cc9521458f1aa81e95b.json +++ /dev/null @@ -1,98 +0,0 @@ -{ - "db_name": "SQLite", - "query": "SELECT principal_did, project_uri, resource_uri, source_identity, root, canonical_path, target_identity FROM ldraw_routes WHERE token_digest = ?", - "describe": { - "columns": [ - { - "name": "principal_did", - "ordinal": 0, - "type_info": "Text", - "origin": { - "Table": { - "table": "ldraw_routes", - "name": "principal_did" - } - } - }, - { - "name": "project_uri", - "ordinal": 1, - "type_info": "Text", - "origin": { - "Table": { - "table": "ldraw_routes", - "name": "project_uri" - } - } - }, - { - "name": "resource_uri", - "ordinal": 2, - "type_info": "Text", - "origin": { - "Table": { - "table": "ldraw_routes", - "name": "resource_uri" - } - } - }, - { - "name": "source_identity", - "ordinal": 3, - "type_info": "Text", - "origin": { - "Table": { - "table": "ldraw_routes", - "name": "source_identity" - } - } - }, - { - "name": "root", - "ordinal": 4, - "type_info": "Text", - "origin": { - "Table": { - "table": "ldraw_routes", - "name": "root" - } - } - }, - { - "name": "canonical_path", - "ordinal": 5, - "type_info": "Text", - "origin": { - "Table": { - "table": "ldraw_routes", - "name": "canonical_path" - } - } - }, - { - "name": "target_identity", - "ordinal": 6, - "type_info": "Text", - "origin": { - "Table": { - "table": "ldraw_routes", - "name": "target_identity" - } - } - } - ], - "parameters": { - "Right": 1 - }, - "nullable": [ - true, - false, - false, - false, - false, - false, - false - ] - }, - "hash": "ab292cdba60a459dbd285ab15c365b2fc87dafaa3db91cc9521458f1aa81e95b" -} diff --git a/.sqlx/query-b242c6c0aea579b653e91c6ef026097c717024ca657ece51c39f63beb547858d.json b/.sqlx/query-b242c6c0aea579b653e91c6ef026097c717024ca657ece51c39f63beb547858d.json deleted file mode 100644 index df3c65d..0000000 --- a/.sqlx/query-b242c6c0aea579b653e91c6ef026097c717024ca657ece51c39f63beb547858d.json +++ /dev/null @@ -1,38 +0,0 @@ -{ - "db_name": "SQLite", - "query": "SELECT state, revoked_at FROM ldraw_verification WHERE resource_uri = ?", - "describe": { - "columns": [ - { - "name": "state", - "ordinal": 0, - "type_info": "Text", - "origin": { - "Table": { - "table": "ldraw_verification", - "name": "state" - } - } - }, - { - "name": "revoked_at", - "ordinal": 1, - "type_info": "Integer", - "origin": { - "Table": { - "table": "ldraw_verification", - "name": "revoked_at" - } - } - } - ], - "parameters": { - "Right": 1 - }, - "nullable": [ - false, - true - ] - }, - "hash": "b242c6c0aea579b653e91c6ef026097c717024ca657ece51c39f63beb547858d" -} diff --git a/.sqlx/query-d1c2c011883690c87716026ff79e30478016d095b01a369a93efe539c1236df8.json b/.sqlx/query-d1c2c011883690c87716026ff79e30478016d095b01a369a93efe539c1236df8.json deleted file mode 100644 index 2dcee4a..0000000 --- a/.sqlx/query-d1c2c011883690c87716026ff79e30478016d095b01a369a93efe539c1236df8.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "db_name": "SQLite", - "query": "INSERT INTO ldraw_verification (resource_uri, source_identity, state, attempt_token, lease_expires_at, expired_attempts, diagnostic, revoked_at, updated_at) VALUES (?, ?, 'unverified', NULL, NULL, 0, NULL, NULL, ?) ON CONFLICT(resource_uri) DO UPDATE SET source_identity = excluded.source_identity, state = CASE WHEN ldraw_verification.source_identity = excluded.source_identity THEN ldraw_verification.state ELSE 'unverified' END, attempt_token = CASE WHEN ldraw_verification.source_identity = excluded.source_identity THEN ldraw_verification.attempt_token ELSE NULL END, lease_expires_at = CASE WHEN ldraw_verification.source_identity = excluded.source_identity THEN ldraw_verification.lease_expires_at ELSE NULL END, expired_attempts = CASE WHEN ldraw_verification.source_identity = excluded.source_identity THEN ldraw_verification.expired_attempts ELSE 0 END, diagnostic = CASE WHEN ldraw_verification.source_identity = excluded.source_identity THEN ldraw_verification.diagnostic ELSE NULL END, revoked_at = NULL, updated_at = excluded.updated_at", - "describe": { - "columns": [], - "parameters": { - "Right": 3 - }, - "nullable": [] - }, - "hash": "d1c2c011883690c87716026ff79e30478016d095b01a369a93efe539c1236df8" -} diff --git a/.sqlx/query-faef1e77d7ff7c353af437158b38b44e8df0e40685b185c55a1c4b00e6563638.json b/.sqlx/query-faef1e77d7ff7c353af437158b38b44e8df0e40685b185c55a1c4b00e6563638.json deleted file mode 100644 index b3a8aae..0000000 --- a/.sqlx/query-faef1e77d7ff7c353af437158b38b44e8df0e40685b185c55a1c4b00e6563638.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "db_name": "SQLite", - "query": "UPDATE ldraw_routes SET revoked_at = ? WHERE token_digest = ? AND (principal_did = ? OR principal_did IS NULL) AND revoked_at IS NULL AND expires_at > ?", - "describe": { - "columns": [], - "parameters": { - "Right": 4 - }, - "nullable": [] - }, - "hash": "faef1e77d7ff7c353af437158b38b44e8df0e40685b185c55a1c4b00e6563638" -} diff --git a/migrations/009_ldraw_resources.sql b/migrations/009_ldraw_resources.sql new file mode 100644 index 0000000..7b4c4cd --- /dev/null +++ b/migrations/009_ldraw_resources.sql @@ -0,0 +1,95 @@ +-- PM-76: durable LDraw resource projection, verification, and opaque routes. +-- All dependent cleanup is performed by application transactions; SQLite foreign-key +-- enforcement is intentionally not required by this schema. + +CREATE TABLE ldraw_resources ( + resource_uri TEXT PRIMARY KEY, + owner_did TEXT NOT NULL, + project_uri TEXT NOT NULL, + record_cid TEXT NOT NULL, + rkey TEXT NOT NULL, + root TEXT NOT NULL, + canonical_path TEXT NOT NULL, + mime_type TEXT NOT NULL, + byte_length INTEGER NOT NULL CHECK (byte_length >= 0), + sha256 BLOB NOT NULL CHECK (length(sha256) = 32), + ordered_blob_cids TEXT NOT NULL, + provenance TEXT NOT NULL, + licence TEXT NOT NULL, + notices_json TEXT NOT NULL, + snapshot_id TEXT, + legacy INTEGER NOT NULL DEFAULT 0 CHECK (legacy IN (0, 1)), + revoked_at INTEGER, + created_at INTEGER NOT NULL, + updated_at INTEGER NOT NULL, + UNIQUE (owner_did, project_uri, root, canonical_path), + UNIQUE (resource_uri, sha256, byte_length, ordered_blob_cids) +); +CREATE INDEX idx_ldraw_resources_owner ON ldraw_resources(owner_did); +CREATE INDEX idx_ldraw_resources_project_path ON ldraw_resources(project_uri, root, canonical_path); +CREATE INDEX idx_ldraw_resources_source ON ldraw_resources(resource_uri, sha256, byte_length); + +CREATE TABLE ldraw_manifest_files ( + resource_uri TEXT NOT NULL, + root TEXT NOT NULL, + canonical_path TEXT NOT NULL, + target_resource_uri TEXT NOT NULL, + target_cid TEXT NOT NULL, + byte_length INTEGER NOT NULL CHECK (byte_length >= 0), + sha256 BLOB NOT NULL CHECK (length(sha256) = 32), + mime_type TEXT NOT NULL, + ordinal INTEGER NOT NULL CHECK (ordinal >= 0), + PRIMARY KEY (resource_uri, root, canonical_path), + UNIQUE (resource_uri, ordinal) +); +CREATE INDEX idx_ldraw_manifest_target ON ldraw_manifest_files(target_resource_uri, target_cid); + +CREATE TABLE ldraw_verification ( + resource_uri TEXT PRIMARY KEY, + source_identity TEXT NOT NULL, + state TEXT NOT NULL CHECK (state IN ('unverified', 'verifying', 'verified', 'rejected')), + attempt_token TEXT UNIQUE, + lease_expires_at INTEGER, + expired_attempts INTEGER NOT NULL DEFAULT 0 CHECK (expired_attempts >= 0 AND expired_attempts <= 3), + diagnostic TEXT, + revoked_at INTEGER, + updated_at INTEGER NOT NULL +); +CREATE INDEX idx_ldraw_verification_state ON ldraw_verification(state, lease_expires_at); +CREATE INDEX idx_ldraw_verification_source ON ldraw_verification(source_identity); + +CREATE TABLE ldraw_routes ( + token_digest BLOB PRIMARY KEY CHECK (length(token_digest) = 32), + principal_did TEXT, + project_uri TEXT NOT NULL, + resource_uri TEXT NOT NULL, + source_identity TEXT NOT NULL, + root TEXT NOT NULL, + canonical_path TEXT NOT NULL, + target_identity TEXT NOT NULL, + expires_at INTEGER NOT NULL, + revoked_at INTEGER, + created_at INTEGER NOT NULL, + UNIQUE (principal_did, project_uri, resource_uri, source_identity, root, canonical_path, target_identity) +); +CREATE INDEX idx_ldraw_routes_auth ON ldraw_routes(principal_did, project_uri, expires_at, revoked_at); +CREATE INDEX idx_ldraw_routes_resource ON ldraw_routes(resource_uri, source_identity); + +CREATE TABLE ldraw_official_snapshots ( + snapshot_id TEXT PRIMARY KEY, + digest BLOB NOT NULL CHECK (length(digest) = 32), + licence TEXT NOT NULL, + notices_json TEXT NOT NULL, + loaded_at INTEGER NOT NULL, + UNIQUE (snapshot_id, digest) +); + +-- Legacy rows are represented explicitly and remain unreadable until verified. +CREATE TABLE ldraw_legacy_resources ( + resource_uri TEXT PRIMARY KEY, + owner_did TEXT NOT NULL, + source_record_cid TEXT, + reason TEXT NOT NULL, + classified_at INTEGER NOT NULL +); +CREATE INDEX idx_ldraw_legacy_owner ON ldraw_legacy_resources(owner_did); diff --git a/migrations/010_remove_ldraw_resources.sql b/migrations/010_remove_ldraw_resources.sql new file mode 100644 index 0000000..f8624a3 --- /dev/null +++ b/migrations/010_remove_ldraw_resources.sql @@ -0,0 +1,8 @@ +-- PM-80: retire the historical LDraw projection after the public/API surface was removed. +-- Keep 009 in the migration chain so databases that applied it can upgrade safely. +DROP TABLE IF EXISTS ldraw_manifest_files; +DROP TABLE IF EXISTS ldraw_routes; +DROP TABLE IF EXISTS ldraw_verification; +DROP TABLE IF EXISTS ldraw_legacy_resources; +DROP TABLE IF EXISTS ldraw_official_snapshots; +DROP TABLE IF EXISTS ldraw_resources; diff --git a/src/appview/state.rs b/src/appview/state.rs index 71bcbde..a46eb64 100644 --- a/src/appview/state.rs +++ b/src/appview/state.rs @@ -54,9 +54,21 @@ impl AppState { /// Construct read + OAuth state from the shared SQLite pool and the /// startup-built OAuth bootstrap (keyset, config, cookie key). pub fn new(pool: SqlitePool, bootstrap: OAuthBootstrap) -> Self { + Self::new_with_resolver( + pool, + bootstrap, + jacquard::identity::slingshot_resolver_default(), + ) + } + + pub(crate) fn new_with_resolver( + pool: SqlitePool, + bootstrap: OAuthBootstrap, + resolver: jacquard::identity::PublicResolver, + ) -> Self { Self { pool, - resolver: jacquard::identity::slingshot_resolver_default(), + resolver, bsky: Arc::new(jacquard::client::BasicClient::unauthenticated()), oauth: Arc::new(bootstrap.client), oauth_config: bootstrap.config,