diff --git a/packages/sdk/src/getEventMessages.ts b/packages/sdk/src/getEventMessages.ts index c3aaad02..ba8977c7 100644 --- a/packages/sdk/src/getEventMessages.ts +++ b/packages/sdk/src/getEventMessages.ts @@ -38,7 +38,8 @@ export async function getEventMessages( entityModels: string[] = [], limit: number = 100, // Default limit offset: number = 0, // Default offset - options?: { logging?: boolean } // Logging option + options?: { logging?: boolean }, // Logging option + historical?: boolean ): Promise> { const clause = convertQueryToClause(query, schema); @@ -58,7 +59,10 @@ export async function getEventMessages( }; try { - const entities = await client.getEventMessages(toriiQuery, true); + const entities = await client.getEventMessages( + toriiQuery, + historical ?? true + ); if (options?.logging) { console.log(`Fetched entities at offset ${cursor}:`, entities); diff --git a/packages/sdk/src/index.ts b/packages/sdk/src/index.ts index 1bb2c3e1..99926bab 100644 --- a/packages/sdk/src/index.ts +++ b/packages/sdk/src/index.ts @@ -53,8 +53,15 @@ export async function init( * @param {SubscribeParams} params - Parameters object * @returns {Promise} - A promise that resolves when the subscription is set up. */ - subscribeEventQuery: ({ query, callback, options }) => - subscribeEventQuery(client, query, schema, callback, options), + subscribeEventQuery: ({ query, callback, options, historical }) => + subscribeEventQuery( + client, + query, + schema, + callback, + options, + historical + ), /** * Fetches entities based on the provided query. * @@ -95,6 +102,7 @@ export async function init( limit, offset, options, + historical, }) => getEventMessages( client, @@ -105,7 +113,8 @@ export async function init( entityModels, limit, offset, - options + options, + historical ), /** diff --git a/packages/sdk/src/subscribeEventQuery.ts b/packages/sdk/src/subscribeEventQuery.ts index 59e90682..c994797b 100644 --- a/packages/sdk/src/subscribeEventQuery.ts +++ b/packages/sdk/src/subscribeEventQuery.ts @@ -36,11 +36,12 @@ export async function subscribeEventQuery( data?: StandardizedQueryResult; error?: Error; }) => void, - options?: { logging?: boolean } + options?: { logging?: boolean }, + historical?: boolean ): Promise { return client.onEventMessageUpdated( convertQueryToEntityKeyClauses(query, schema), - true, + historical ?? true, (entityId: string, entityData: any) => { try { if (callback) { diff --git a/packages/sdk/src/types.ts b/packages/sdk/src/types.ts index 9c773025..c29349eb 100644 --- a/packages/sdk/src/types.ts +++ b/packages/sdk/src/types.ts @@ -392,6 +392,8 @@ export interface SubscribeParams { }) => void; // Optional settings. options?: SDKFunctionOptions; + // historical events + historical?: boolean; } export interface GetParams { @@ -412,4 +414,6 @@ export interface GetParams { offset?: number; // Optional settings. options?: SDKFunctionOptions; + // historical events + historical?: boolean; }