/** Types generated for queries found in "sql/queries.sql" */ import { PreparedQuery } from '@pgtyped/runtime'; export type config_type = 'future_intervals_to_create' | 'partition_interval' | 'partition_retention_period' | 'pg_cron_partition_maintenance_cron' | 'pg_cron_poll_for_events_cron' | 'plugin_version' | 'poll_chunk_size' | 'use_pg_cron'; export type DateOrString = Date | string; export type DateOrStringArray = (DateOrString)[]; export type stringArray = (string)[]; export type unknownArray = (unknown)[]; /** 'AssertGroup' parameters type */ export interface IAssertGroupParams { id: string; } /** 'AssertGroup' return type */ export type IAssertGroupResult = void; /** 'AssertGroup' query type */ export interface IAssertGroupQuery { params: IAssertGroupParams; result: IAssertGroupResult; } /** * Query generated from SQL: * ``` * INSERT INTO pgmb.subscription_groups (id) * VALUES (:id!) * ON CONFLICT DO NOTHING * ``` */ export declare const assertGroup: PreparedQuery; /** 'AssertSubscription' parameters type */ export interface IAssertSubscriptionParams { conditionsSql?: string | null | void; expiryInterval?: DateOrString | null | void; groupId: string; params?: unknown | null | void; } /** 'AssertSubscription' return type */ export interface IAssertSubscriptionResult { id: string; } /** 'AssertSubscription' query type */ export interface IAssertSubscriptionQuery { params: IAssertSubscriptionParams; result: IAssertSubscriptionResult; } /** * Query generated from SQL: * ``` * INSERT INTO pgmb.subscriptions * AS s(group_id, conditions_sql, params, expiry_interval) * VALUES ( * :groupId!, * COALESCE(:conditionsSql, 'TRUE'), * COALESCE(:params::jsonb, '{}'), * :expiryInterval::interval * ) * ON CONFLICT (identity) DO UPDATE * SET * -- set expiry_interval to the new value only if it's greater than the existing one * -- or if the new value is NULL (indicating no expiration) * expiry_interval = CASE * WHEN EXCLUDED.expiry_interval IS NULL OR s.expiry_interval IS NULL * THEN NULL * ELSE * GREATEST(s.expiry_interval, EXCLUDED.expiry_interval) * END, * last_active_at = NOW() * RETURNING id AS "id!" * ``` */ export declare const assertSubscription: PreparedQuery; /** 'DeleteSubscriptions' parameters type */ export interface IDeleteSubscriptionsParams { ids: readonly (string)[]; } /** 'DeleteSubscriptions' return type */ export type IDeleteSubscriptionsResult = void; /** 'DeleteSubscriptions' query type */ export interface IDeleteSubscriptionsQuery { params: IDeleteSubscriptionsParams; result: IDeleteSubscriptionsResult; } /** * Query generated from SQL: * ``` * DELETE FROM pgmb.subscriptions * WHERE id IN :ids! * ``` */ export declare const deleteSubscriptions: PreparedQuery; /** 'MarkSubscriptionsActive' parameters type */ export interface IMarkSubscriptionsActiveParams { ids: stringArray; } /** 'MarkSubscriptionsActive' return type */ export type IMarkSubscriptionsActiveResult = void; /** 'MarkSubscriptionsActive' query type */ export interface IMarkSubscriptionsActiveQuery { params: IMarkSubscriptionsActiveParams; result: IMarkSubscriptionsActiveResult; } /** * Query generated from SQL: * ``` * UPDATE pgmb.subscriptions * SET * last_active_at = NOW() * WHERE id IN (SELECT * FROM unnest(:ids!::text[])) * ``` */ export declare const markSubscriptionsActive: PreparedQuery; /** 'PollForEvents' parameters type */ export type IPollForEventsParams = void; /** 'PollForEvents' return type */ export interface IPollForEventsResult { count: number; } /** 'PollForEvents' query type */ export interface IPollForEventsQuery { params: IPollForEventsParams; result: IPollForEventsResult; } /** * Query generated from SQL: * ``` * SELECT count AS "count!" FROM pgmb.poll_for_events() AS count * ``` */ export declare const pollForEvents: PreparedQuery; /** 'ReadNextEvents' parameters type */ export interface IReadNextEventsParams { chunkSize: number; cursor?: string | null | void; groupId: string; } /** 'ReadNextEvents' return type */ export interface IReadNextEventsResult { id: string; metadata: unknown; nextCursor: string; payload: unknown; subscriptionIds: stringArray; topic: string; } /** 'ReadNextEvents' query type */ export interface IReadNextEventsQuery { params: IReadNextEventsParams; result: IReadNextEventsResult; } /** * Query generated from SQL: * ``` * SELECT * id AS "id!", * topic AS "topic!", * payload AS "payload!", * metadata AS "metadata!", * subscription_ids::text[] AS "subscriptionIds!", * next_cursor AS "nextCursor!" * FROM pgmb.read_next_events(:groupId!, :cursor, :chunkSize!) * ``` */ export declare const readNextEvents: PreparedQuery; /** 'ReadNextEventsText' parameters type */ export interface IReadNextEventsTextParams { chunkSize: number; cursor?: string | null | void; groupId: string; } /** 'ReadNextEventsText' return type */ export interface IReadNextEventsTextResult { id: string; payload: string; topic: string; } /** 'ReadNextEventsText' query type */ export interface IReadNextEventsTextQuery { params: IReadNextEventsTextParams; result: IReadNextEventsTextResult; } /** * Query generated from SQL: * ``` * SELECT * id AS "id!", * topic AS "topic!", * payload::text AS "payload!" * FROM pgmb.read_next_events(:groupId!, :cursor, :chunkSize!) * ``` */ export declare const readNextEventsText: PreparedQuery; /** 'ReplayEvents' parameters type */ export interface IReplayEventsParams { fromEventId: string; groupId: string; maxEvents: number; subscriptionId: string; } /** 'ReplayEvents' return type */ export interface IReplayEventsResult { id: string; metadata: unknown; payload: unknown; topic: string; } /** 'ReplayEvents' query type */ export interface IReplayEventsQuery { params: IReplayEventsParams; result: IReplayEventsResult; } /** * Query generated from SQL: * ``` * SELECT * id AS "id!", * topic AS "topic!", * payload AS "payload!", * metadata AS "metadata!" * FROM pgmb.replay_events( * :groupId!, * :subscriptionId!, * :fromEventId!::pgmb.event_id, * :maxEvents! * ) * ``` */ export declare const replayEvents: PreparedQuery; /** 'SetGroupCursor' parameters type */ export interface ISetGroupCursorParams { cursor: string; groupId: string; releaseLock?: boolean | null | void; } /** 'SetGroupCursor' return type */ export interface ISetGroupCursorResult { success: undefined; } /** 'SetGroupCursor' query type */ export interface ISetGroupCursorQuery { params: ISetGroupCursorParams; result: ISetGroupCursorResult; } /** * Query generated from SQL: * ``` * SELECT pgmb.set_group_cursor( * :groupId!, * :cursor!::pgmb.event_id, * :releaseLock::boolean * ) AS "success!" * ``` */ export declare const setGroupCursor: PreparedQuery; /** 'ReleaseGroupLock' parameters type */ export interface IReleaseGroupLockParams { groupId: string; } /** 'ReleaseGroupLock' return type */ export interface IReleaseGroupLockResult { success: undefined; } /** 'ReleaseGroupLock' query type */ export interface IReleaseGroupLockQuery { params: IReleaseGroupLockParams; result: IReleaseGroupLockResult; } /** * Query generated from SQL: * ``` * SELECT pgmb.release_group_lock(:groupId!) AS "success!" * ``` */ export declare const releaseGroupLock: PreparedQuery; /** 'WriteEvents' parameters type */ export interface IWriteEventsParams { metadatas: unknownArray; payloads: unknownArray; topics: stringArray; } /** 'WriteEvents' return type */ export interface IWriteEventsResult { id: string; } /** 'WriteEvents' query type */ export interface IWriteEventsQuery { params: IWriteEventsParams; result: IWriteEventsResult; } /** * Query generated from SQL: * ``` * INSERT INTO pgmb.events (topic, payload, metadata) * SELECT * topic, * payload, * metadata * FROM unnest( * :topics!::TEXT[], * :payloads!::JSONB[], * :metadatas!::JSONB[] * ) AS t(topic, payload, metadata) * RETURNING id AS "id!" * ``` */ export declare const writeEvents: PreparedQuery; /** 'WriteScheduledEvents' parameters type */ export interface IWriteScheduledEventsParams { metadatas: unknownArray; payloads: unknownArray; topics: stringArray; ts: DateOrStringArray; } /** 'WriteScheduledEvents' return type */ export interface IWriteScheduledEventsResult { id: string; } /** 'WriteScheduledEvents' query type */ export interface IWriteScheduledEventsQuery { params: IWriteScheduledEventsParams; result: IWriteScheduledEventsResult; } /** * Query generated from SQL: * ``` * INSERT INTO pgmb.events (id, topic, payload, metadata) * SELECT * pgmb.create_event_id(COALESCE(ts, clock_timestamp()), pgmb.create_random_bigint()), * topic, * payload, * metadata * FROM unnest( * :ts!::TIMESTAMPTZ[], * :topics!::TEXT[], * :payloads!::JSONB[], * :metadatas!::JSONB[] * ) AS t(ts, topic, payload, metadata) * RETURNING id AS "id!" * ``` */ export declare const writeScheduledEvents: PreparedQuery; /** 'ScheduleEventRetry' parameters type */ export interface IScheduleEventRetryParams { delayInterval: DateOrString; handlerName: string; ids: stringArray; retryNumber: number; subscriptionId: string; } /** 'ScheduleEventRetry' return type */ export interface IScheduleEventRetryResult { id: string; } /** 'ScheduleEventRetry' query type */ export interface IScheduleEventRetryQuery { params: IScheduleEventRetryParams; result: IScheduleEventRetryResult; } /** * Query generated from SQL: * ``` * INSERT INTO pgmb.events (id, topic, payload, subscription_id) * SELECT * pgmb.create_event_id( * NOW() + (:delayInterval!::INTERVAL), * pgmb.create_random_bigint() * ), * 'pgmb-retry', * jsonb_build_object( * 'ids', * :ids!::pgmb.event_id[], * 'retryNumber', * :retryNumber!::int, * 'handlerName', * :handlerName!::text * ), * :subscriptionId!::pgmb.subscription_id * RETURNING id AS "id!" * ``` */ export declare const scheduleEventRetry: PreparedQuery; /** 'FindEvents' parameters type */ export interface IFindEventsParams { ids: stringArray; } /** 'FindEvents' return type */ export interface IFindEventsResult { id: string; metadata: unknown; payload: unknown; topic: string; } /** 'FindEvents' query type */ export interface IFindEventsQuery { params: IFindEventsParams; result: IFindEventsResult; } /** * Query generated from SQL: * ``` * SELECT * id AS "id!", * topic AS "topic!", * payload AS "payload!", * metadata AS "metadata!" * FROM pgmb.events * WHERE id = ANY(:ids!::pgmb.event_id[]) * ``` */ export declare const findEvents: PreparedQuery; /** 'RemoveExpiredSubscriptions' parameters type */ export interface IRemoveExpiredSubscriptionsParams { activeIds: stringArray; groupId: string; } /** 'RemoveExpiredSubscriptions' return type */ export interface IRemoveExpiredSubscriptionsResult { deleted: string; } /** 'RemoveExpiredSubscriptions' query type */ export interface IRemoveExpiredSubscriptionsQuery { params: IRemoveExpiredSubscriptionsParams; result: IRemoveExpiredSubscriptionsResult; } /** * Query generated from SQL: * ``` * WITH deleted AS ( * DELETE FROM pgmb.subscriptions * WHERE group_id = :groupId! * AND expiry_interval IS NOT NULL * AND pgmb.add_interval_imm(last_active_at, expiry_interval) < NOW() * AND id NOT IN (select * from unnest(:activeIds!::text[])) * RETURNING id * ) * SELECT COUNT(*) AS "deleted!" FROM deleted * ``` */ export declare const removeExpiredSubscriptions: PreparedQuery; /** 'GetConfigValue' parameters type */ export interface IGetConfigValueParams { key: config_type; } /** 'GetConfigValue' return type */ export interface IGetConfigValueResult { value: string | null; } /** 'GetConfigValue' query type */ export interface IGetConfigValueQuery { params: IGetConfigValueParams; result: IGetConfigValueResult; } /** * Query generated from SQL: * ``` * SELECT pgmb.get_config_value(:key!::pgmb.config_type) AS "value" * ``` */ export declare const getConfigValue: PreparedQuery; /** 'UpdateConfigValue' parameters type */ export interface IUpdateConfigValueParams { key: config_type; value: string; } /** 'UpdateConfigValue' return type */ export interface IUpdateConfigValueResult { updated: number; } /** 'UpdateConfigValue' query type */ export interface IUpdateConfigValueQuery { params: IUpdateConfigValueParams; result: IUpdateConfigValueResult; } /** * Query generated from SQL: * ``` * UPDATE pgmb.config * SET value = :value!::TEXT * WHERE id = :key!::pgmb.config_type * RETURNING 1 AS "updated!" * ``` */ export declare const updateConfigValue: PreparedQuery; /** 'MaintainEventsTable' parameters type */ export interface IMaintainEventsTableParams { ts?: DateOrString | null | void; } /** 'MaintainEventsTable' return type */ export type IMaintainEventsTableResult = void; /** 'MaintainEventsTable' query type */ export interface IMaintainEventsTableQuery { params: IMaintainEventsTableParams; result: IMaintainEventsTableResult; } /** * Query generated from SQL: * ``` * CALL pgmb.maintain_events_table(COALESCE(:ts, NOW())) * ``` */ export declare const maintainEventsTable: PreparedQuery;