Mirror of https://github.com/roostorg/coop github.com/roostorg/coop
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

at main 70 lines 3.0 kB view raw
1import type { 2 ScyllaItemIdentifier, 3 ScyllaRealItemIdentifier, 4} from '../../scylla/index.js'; 5import { type JsonOf } from '../../utils/encoding.js'; 6import { 7 type NormalizedItemData, 8 type SubmissionId, 9} from '../itemProcessingService/index.js'; 10import { 11 type ItemSchema, 12 type SchemaFieldRoles, 13} from '../moderationConfigService/index.js'; 14 15/** 16 * This type matches the definition of the item_submissions_by_thread table in 17 * ScyllaDB. Data going into or out of the item_investigation_service namescpace 18 * in Scylla should have this shape. 19 * 20 * The `synthetic_thread_id` field is a generated value which is used to ensure 21 * that all items submitted to the itemsInvestigationService are organizable by 22 * some "thread". In the case that an Item has associated thread information, 23 * the synthetic thread id just encodes the thread's item id and item type id. 24 * In the case that there is no thread associated with a submitted item, the 25 * synthetic_thread_id is generated from the items typeIdentifier information. 26 * This allows the item to be stored and organized in the initial 27 * item_submissions_by_thread table as well as any and all materialized views 28 * generated from that table, even if it does not have a thread of its own. The 29 * record of that item in the primary `item_submissions_by_thread` table is 30 * essentially useless, but its presence in materialized views allows it to be 31 * accessed in queries by creator, by time, and by item identifier. 32 * 33 * On item submission, we record both the item's creation time in the user's 34 * system via the Schema Field Roles, as we all it's submission time to Coop. 35 * In the event of an edited item, it will likely be re-submitted to Coop but 36 * it's creation time should not change. In this case, we will have multiple 37 * item submissions with the same item identifier and same creation time, so 38 * the submission time field can be used to distinguish which copy of it is the 39 * most up-to-date. 40 */ 41export type ScyllaItemSubmissionsRow = { 42 org_id: string; 43 request_id: string | null; 44 submission_id: SubmissionId; 45 item_identifier: ScyllaRealItemIdentifier; 46 item_type_name: string | null; 47 item_type_version: string; 48 item_creator_identifier: ScyllaItemIdentifier; 49 item_data: JsonOf<NormalizedItemData>; 50 item_submission_time: Date; 51 item_synthetic_created_at: Date; 52 synthetic_thread_id: string; 53 parent_identifier: ScyllaItemIdentifier; 54 thread_identifier: ScyllaItemIdentifier; 55 item_type_schema_field_roles: JsonOf<SchemaFieldRoles>; 56 item_type_schema: JsonOf<ItemSchema>; 57 item_type_schema_variant: 'original' | 'partial'; 58}; 59 60export type ScyllaTables = { 61 item_submission_by_thread: ScyllaItemSubmissionsRow; 62}; 63 64export type ScyllaViews = { 65 item_submission_by_item_id: ScyllaItemSubmissionsRow; 66 item_submission_by_thread_and_time: ScyllaItemSubmissionsRow; 67 item_submission_by_creator: ScyllaItemSubmissionsRow; 68}; 69 70export type ScyllaRelations = ScyllaTables & ScyllaViews;