Files
sync-server-v2/source/services/storage/tables.ts
T

66 lines
1.8 KiB
TypeScript

import type { ColumnType } from 'kysely';
/** Kysely column type for millisecond epoch timestamps stored as integers. */
export type Timestamp = ColumnType<number, number | undefined, number | undefined>;
/** Kysely column type for binary blobs accepting Buffer or Uint8Array on insert. */
export type BlobColumn = ColumnType<Buffer, Buffer | Uint8Array, Buffer>;
/**
* One row per (resource_id, public_key). Each publicKey owns a slot within a shared resource.
*/
export interface ResourceDataTable {
/** Shared resource identifier grouping related instances. */
resource_id: string;
/** Owner identity for this instance slot within the resource. */
public_key: string;
/** Opaque serialized resource payload. */
blob: BlobColumn;
/** Millisecond timestamp of the last write. */
timestamp: Timestamp;
/** Signature of the write. */
signature: string;
}
export interface AuthedRequestsTable {
/** Signature of the request. */
signature: string;
/** Millisecond timestamp of the request. */
timestamp: Timestamp;
}
// export interface PaymentsTable {
// /** Unique identifier for the payment. */
// payment_id: string;
// /** Public key of the account in the transaction */
// public_key: string;
// /** Amount of the payment. This can be positive or negative.*/
// amount: number;
// /** Timestamp of the payment. */
// timestamp: Timestamp;
// /** Signature of the payment. */
// signature: string;
// /** Hash of the message that was signed. */
// message_hash: string;
// /** Resource ID of the payment. */
// resource_id: string;
// }
/** Complete Kysely schema mapping for the sync server database. */
export interface DatabaseTables {
resource_data: ResourceDataTable;
authed_requests: AuthedRequestsTable;
}