From 6d3e0668b0f842093acc426e4521c16fe57174c3 Mon Sep 17 00:00:00 2001 From: Tim Jones Date: Thu, 18 Jul 2024 16:26:06 -0500 Subject: [PATCH] update types --- src/contractor.js | 10 +++++----- types.d.ts | 8 +++++--- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/contractor.js b/src/contractor.js index f3eefbf..e651410 100644 --- a/src/contractor.js +++ b/src/contractor.js @@ -24,26 +24,26 @@ class Contractor { // exported api to index this.functions = [ - this.version, + this.schemaVersion, this.isInstalled ] } - async version () { + async schemaVersion () { const result = await this.db.executeSql(plans.getVersion(this.config.schema)) return result.rows.length ? parseInt(result.rows[0].version) : null } async isInstalled () { const result = await this.db.executeSql(plans.versionTableExists(this.config.schema)) - return result.rows.length ? result.rows[0].name : null + return !!result.rows[0].name } async start () { const installed = await this.isInstalled() if (installed) { - const version = await this.version() + const version = await this.schemaVersion() if (schemaVersion > version) { throw new Error('Migrations are not supported to v10') @@ -61,7 +61,7 @@ class Contractor { throw new Error('pg-boss is not installed') } - const version = await this.version() + const version = await this.schemaVersion() if (schemaVersion !== version) { throw new Error('pg-boss database requires migrations') diff --git a/types.d.ts b/types.d.ts index f127bd8..59376dd 100644 --- a/types.d.ts +++ b/types.d.ts @@ -350,9 +350,9 @@ declare class PgBoss extends EventEmitter { getQueueSize(name: string, options?: object): Promise; getJobById(name: string, id: string, options?: PgBoss.ConnectionOptions): Promise; - createQueue(name: string, options?: Queue): Promise; - getQueue(name: string): Promise; - updateQueue(name: string, options?: QueueUpdateOptions): Promise; + createQueue(name: string, options?: PgBoss.Queue): Promise; + getQueue(name: string): Promise; + updateQueue(name: string, options?: PgBoss.QueueUpdateOptions): Promise; deleteQueue(name: string): Promise; purgeQueue(name: string): Promise; @@ -361,6 +361,8 @@ declare class PgBoss extends EventEmitter { purge(): Promise; expire(): Promise; maintain(): Promise; + isInstalled(): Promise; + schemaVersion(): Promise; schedule(name: string, cron: string, data?: object, options?: PgBoss.ScheduleOptions): Promise; unschedule(name: string): Promise;