π₯ π₯ π₯ A Free & Self-hostable Airtable Alternative
TypeScript airtableairtable-alternativeautomatic-apihacktoberfestlow-codeno-codeno-code-databaseno-code-platformpostgresqlrest-apirestful-apispreadsheetsqliteswagger
feat: make dashboard and widgets realtime
DarkPhoenix27041e973dc6b4a0
diff --git a/packages/nocodb-sdk/src/lib/realtime/index.ts b/packages/nocodb-sdk/src/lib/realtime/index.tsindex d0680317df..da6ecd2e3e 100644--- a/packages/nocodb-sdk/src/lib/realtime/index.ts+++ b/packages/nocodb-sdk/src/lib/realtime/index.ts@@ -1,4 +1,5 @@import { UserType } from '~/lib/Api';+import { DashboardType, WidgetType } from '~/lib';export enum EventType {HANDSHAKE = 'handshake',@@ -6,12 +7,15 @@ export enum EventType {CONNECTION_ERROR = 'connection-error',NOTIFICATION = 'notification',DATA_EVENT = 'event-data',+ DASHBOARD_EVENT = 'event-dashboard',+ WIDGET_EVENT = 'event-widget',}// Base payload interface for all socket eventsexport interface BaseSocketPayload {timestamp: number;socketId?: string;+ eventType?: EventType;}// Connection event payloads@@ -39,17 +43,34 @@ export interface DataPayload extends BaseSocketPayload {before?: string;}+export interface DashboardPayload extends BaseSocketPayload {+ id: string;+ action: 'create' | 'update' | 'delete';+ payload: DashboardType;+}++export interface WidgetPayload extends BaseSocketPayload {+ id: string;+ dashboardId: string;+ action: 'create' | 'update' | 'delete';+ payload: WidgetType;+}+// Union type for all socket event payloadsexport type SocketEventPayload =| ConnectionWelcomePayload| ConnectionErrorPayload- | DataPayload;+ | DataPayload+ | DashboardPayload+ | WidgetPayload;// Type mapping for event types to their corresponding payloadsexport type SocketEventPayloadMap = {[EventType.CONNECTION_WELCOME]: ConnectionWelcomePayload;[EventType.CONNECTION_ERROR]: ConnectionErrorPayload;[EventType.DATA_EVENT]: DataPayload;+ [EventType.DASHBOARD_EVENT]: DashboardPayload;+ [EventType.WIDGET_EVENT]: WidgetPayload;[key: string]: BaseSocketPayload;};diff --git a/packages/nocodb/src/types/utils.ts b/packages/nocodb/src/types/utils.tsnew file mode 100644index 0000000000..2b51d3f756--- /dev/null+++ b/packages/nocodb/src/types/utils.ts@@ -0,0 +1,3 @@+export type Prettify<T> = {+ [K in keyof T]: T[K];+} & {};