@protobase/server 0.8.0 → 0.8.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/batch/run-batch.js +2 -1
- package/dist/changes/actor.js +12 -0
- package/dist/changes/capture-plan.js +62 -0
- package/dist/changes/capture-schema.d.ts +18 -0
- package/dist/changes/capture-schema.js +65 -0
- package/dist/changes/capture-sql.js +108 -0
- package/dist/changes/coalesce.d.ts +38 -0
- package/dist/changes/coalesce.js +69 -0
- package/dist/changes/events-options.d.ts +10 -0
- package/dist/changes/events-options.js +10 -0
- package/dist/changes/match-events.d.ts +9 -0
- package/dist/changes/match-events.js +55 -0
- package/dist/changes/resource-change.d.ts +27 -0
- package/dist/changes/resource-change.js +43 -0
- package/dist/create-admin.d.ts +7 -1
- package/dist/create-admin.js +7 -2
- package/dist/functions/require-env.d.ts +1 -1
- package/dist/index.d.ts +13 -2
- package/dist/index.js +10 -1
- package/dist/jobs/current.d.ts +8 -0
- package/dist/jobs/current.js +18 -0
- package/dist/jobs/database.js +36 -0
- package/dist/jobs/define-job.d.ts +8 -0
- package/dist/jobs/define-job.js +38 -0
- package/dist/jobs/drain-route.d.ts +21 -0
- package/dist/jobs/drain-route.js +28 -0
- package/dist/jobs/failed-jobs.js +67 -0
- package/dist/jobs/functions-sql.js +126 -0
- package/dist/jobs/job-types.d.ts +73 -0
- package/dist/jobs/options.js +44 -0
- package/dist/jobs/run-job.d.ts +9 -0
- package/dist/jobs/run-job.js +78 -0
- package/dist/jobs/runtime.d.ts +46 -0
- package/dist/jobs/runtime.js +156 -0
- package/dist/jobs/schedule.js +25 -0
- package/dist/jobs/schedules.js +41 -0
- package/dist/jobs/schema.d.ts +15 -0
- package/dist/jobs/schema.js +63 -0
- package/dist/project-config.d.ts +6 -1
- package/dist/project-config.js +18 -3
- package/dist/transactions.js +10 -3
- package/dist/write-pipeline.js +2 -1
- package/package.json +6 -4
package/dist/index.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ import { OrganizationRole, StoredMember, StoredOrganization } from "./better-aut
|
|
|
6
6
|
import { OrganizationsOptions } from "./better-auth/organizations/options.js";
|
|
7
7
|
import { PlatformSignIn, readPlatformSignIn } from "./better-auth/platform-sign-in.js";
|
|
8
8
|
import { AdminAuth, CreateAuthOptions, UserCreatedHook, createAuth, normalizeRoles } from "./better-auth/create-auth.js";
|
|
9
|
+
import { EventsOptions } from "./changes/events-options.js";
|
|
9
10
|
import { FileProvider, FileStore, StoredObject } from "./files/store.js";
|
|
10
11
|
import { FilesOptions } from "./files/options.js";
|
|
11
12
|
import { Admin, AuditEvent, AuditQueue, Authenticator, PipelineHook, ScanGuardMode, Session, SessionOrganization, TenantValue, User, ViewSource, WriteEvent, WriteOperation } from "./types.js";
|
|
@@ -23,6 +24,8 @@ import { AssistantTool, ToolContext, defineTool } from "./assistant/tools.js";
|
|
|
23
24
|
import { AssistantOptions, AssistantSettings, assistantRoles, assistantSettings, assistantVariables, seesAssistant } from "./assistant/assistant-settings.js";
|
|
24
25
|
import { RuntimeOptions, runtimeUrl, runtimeVariable, seesRuntime } from "./runtime/runtime-settings.js";
|
|
25
26
|
import { AdminOptions } from "./admin-options.js";
|
|
27
|
+
import { StandardSchema, readJson } from "./functions/read-json.js";
|
|
28
|
+
import { EnqueueOptions, JobContext, JobDefinition, JobOptions } from "./jobs/job-types.js";
|
|
26
29
|
import { CreateAdminInput, createAdmin } from "./create-admin.js";
|
|
27
30
|
import { ProjectConfig, defineConfig, mergeConfig } from "./project-config.js";
|
|
28
31
|
import { consoleAuditQueue } from "./audit/console-queue.js";
|
|
@@ -33,6 +36,10 @@ import { parseRoles } from "./better-auth/parse-roles.js";
|
|
|
33
36
|
import { LinkedAccount, NewUser, StoredUser, createUser, deleteUser, hasUsers, listUsers, roleChoices, setUserBanned, setUserRole } from "./better-auth/users.js";
|
|
34
37
|
import { IssueTokenOptions, issueToken, maxTokenTtlSeconds } from "./better-auth/tokens.js";
|
|
35
38
|
import { authSchemaMigration, checkAuthSchema } from "./better-auth/auth-schema.js";
|
|
39
|
+
import { changesMigration, checkChanges, migrationCommand } from "./changes/capture-schema.js";
|
|
40
|
+
import { CapturedRow, CoalescedChange, coalesce } from "./changes/coalesce.js";
|
|
41
|
+
import { ResourceChange, recordOf, resourceChange } from "./changes/resource-change.js";
|
|
42
|
+
import { eventMatcher } from "./changes/match-events.js";
|
|
36
43
|
import { MemberInput, NewOrganization, addAppRoleToOwners, addMember, createOrganization, listOrganizations, removeMember, setMemberRoles } from "./better-auth/organizations/host.js";
|
|
37
44
|
import { AssistantBackend, assistantProtocolRoutes } from "./assistant/protocol-routes.js";
|
|
38
45
|
import { fileConversationStore } from "./assistant/file-conversation-store.js";
|
|
@@ -42,11 +49,15 @@ import { WidgetOptions, maxWidgetPropsBytes, widget } from "./assistant/widget.j
|
|
|
42
49
|
import { QueryOptions, QueryResult, runReadOnlyQuery, runReadWriteQuery } from "./assistant/run-query.js";
|
|
43
50
|
import { readOnlyQueryTool, readWriteQueryTool } from "./assistant/query-tools.js";
|
|
44
51
|
import { FunctionEnv, PublicFunctionEnv, functionApp } from "./functions/function-app.js";
|
|
45
|
-
import { StandardSchema, readJson } from "./functions/read-json.js";
|
|
46
52
|
import { SignatureOptions, StandardWebhookOptions, verifySignature, verifyStandardWebhook } from "./functions/verify-signature.js";
|
|
47
53
|
import { requireEnv } from "./functions/require-env.js";
|
|
48
54
|
import { LocalFilesOptions, localFileStore, localFiles } from "./files/local-files.js";
|
|
49
55
|
import { FileCleanupInput, createFileCleanup } from "./files/file-cleanup.js";
|
|
50
56
|
import { FileObject } from "./files/present.js";
|
|
51
57
|
import { aspectRatio, fileSize, fileType, imageSize, processor } from "./files/processors.js";
|
|
52
|
-
|
|
58
|
+
import { defineJob, isJobDefinition, jobDefinitions } from "./jobs/define-job.js";
|
|
59
|
+
import { FatalJobError } from "./jobs/run-job.js";
|
|
60
|
+
import { DrainResult, JobsRuntime, StartJobsOptions, startJobs } from "./jobs/runtime.js";
|
|
61
|
+
import { jobsDrainApp } from "./jobs/drain-route.js";
|
|
62
|
+
import { checkJobsSchema, jobsSchema, jobsSchemaMigration } from "./jobs/schema.js";
|
|
63
|
+
export { type Admin, type AdminAuth, type AdminOptions, type ApiFunction, type ApprovalAnswer, type ApprovalRequest, type AssistantBackend, type AssistantOptions, type AssistantSettings, type AssistantTool, type AuditEvent, type AuditQueue, type Authenticator, type BetterAuthAuthenticatorOptions, type CapturedRow, type ChatMessage, type ChatTextPart, type CleanupEntry, type CleanupReport, type CleanupSchedule, type CoalescedChange, type Completion, type CompletionOptions, type Conversation, type ConversationRecord, type ConversationStore, type ConversationsOptions, type CorsOptions, type CreateAdminInput, type CreateAuthOptions, type DrainResult, type EnqueueOptions, type EventsOptions, FatalJobError, type FileCleanupInput, type FileObject, type FileProvider, type FileStore, type FilesOptions, type FunctionApp, type FunctionCaller, type FunctionContext, type FunctionEnv, type FunctionHandler, type FunctionOptions, type FunctionRecords, type FunctionSource, HttpProblem, type IssueTokenOptions, type JobContext, type JobDefinition, type JobOptions, type JobsRuntime, type JwtOptions, type LinkedAccount, type ListParams, type LocalFilesOptions, type MemberInput, ModelError, type ModelSettings, type NewOrganization, type NewUser, type OperatorProvider, type OrganizationRole, type OrganizationsOptions, type PipelineHook, type PlatformSignIn, type ProjectConfig, type ProtectedFunctionOptions, type PublicFunctionContext, type PublicFunctionEnv, type PublicFunctionHandler, type PublicFunctionOptions, type QueryOptions, type QueryResult, type ReasoningDetail, type ReasoningEffort, type RecordKeyInput, type RecordPage, type ResourceChange, type ResourceSource, type RoleDefinition, type RolesInput, type RuntimeOptions, type ScanGuardMode, type ScheduledDelete, type Session, type SessionOrganization, type SignInPolicy, type SignInRule, type SignatureOptions, type StaffAccessRule, type StaffSignIn, type StandardSchema, type StandardWebhookOptions, type StartJobsOptions, type StoredMember, type StoredObject, type StoredOrganization, type StoredUser, type TenantValue, type ToolCall, type ToolContext, type ToolRecord, type ToolRecords, type ToolSpec, type TurnOptions, type User, type UserCreatedHook, type ViewSource, type WidgetOptions, type WriteEvent, type WriteOperation, addAppRoleToOwners, addMember, aspectRatio, assistantProtocolRoutes, assistantRoles, assistantSettings, assistantVariables, authSchemaMigration, badRequest, betterAuthAuthenticator, changesMigration, checkAuthSchema, checkChanges, checkJobsSchema, coalesce, configExports, consoleAuditQueue, conversationKey, createAdmin, createAuth, createConversations, createFileCleanup, createOrganization, createUser, defaultSignInPolicy, defineConfig, defineFunction, defineJob, defineTool, deleteUser, eventMatcher, fileConversationStore, fileSize, fileType, forbidden, functionApp, hasUsers, imageSize, isJobDefinition, issueToken, jobDefinitions, jobsDrainApp, jobsSchema, jobsSchemaMigration, jwtAuthenticator, listOrganizations, listUsers, localFileStore, localFiles, maxTokenTtlSeconds, maxWidgetPropsBytes, mergeConfig, migrationCommand, normalizeRoles, notFound, parseRoles, processor, readJson, readOnlyQueryTool, readOperatorSettings, readPlatformSignIn, readWriteQueryTool, recordOf, removeMember, requestApproval, requireEnv, resourceChange, roleChoices, runReadOnlyQuery, runReadWriteQuery, runTurn, runtimeUrl, runtimeVariable, seesAssistant, seesRuntime, setMemberRoles, setUserBanned, setUserRole, signInPolicyMethods, startJobs, storageCleanupSchedule, streamChatCompletion, unauthorized, verifySignature, verifyStandardWebhook, widget, withCacheBreakpoints };
|
package/dist/index.js
CHANGED
|
@@ -22,13 +22,19 @@ import { storageCleanupSchedule } from "./files/cleanup-schedule.js";
|
|
|
22
22
|
import { localFileStore, localFiles } from "./files/local-files.js";
|
|
23
23
|
import { defineFunction } from "./functions/define-function.js";
|
|
24
24
|
import { runtimeUrl, runtimeVariable, seesRuntime } from "./runtime/runtime-settings.js";
|
|
25
|
+
import { checkJobsSchema, jobsSchema, jobsSchemaMigration } from "./jobs/schema.js";
|
|
25
26
|
import { createAdmin } from "./create-admin.js";
|
|
26
27
|
import { configExports } from "./resource-source.js";
|
|
28
|
+
import { defineJob, isJobDefinition, jobDefinitions } from "./jobs/define-job.js";
|
|
27
29
|
import { defineConfig, mergeConfig } from "./project-config.js";
|
|
28
30
|
import { jwtAuthenticator } from "./auth/jwt.js";
|
|
29
31
|
import { betterAuthAuthenticator } from "./better-auth/authenticator.js";
|
|
30
32
|
import { issueToken, maxTokenTtlSeconds } from "./better-auth/tokens.js";
|
|
31
33
|
import { authSchemaMigration, checkAuthSchema } from "./better-auth/auth-schema.js";
|
|
34
|
+
import { changesMigration, checkChanges, migrationCommand } from "./changes/capture-schema.js";
|
|
35
|
+
import { coalesce } from "./changes/coalesce.js";
|
|
36
|
+
import { recordOf, resourceChange } from "./changes/resource-change.js";
|
|
37
|
+
import { eventMatcher } from "./changes/match-events.js";
|
|
32
38
|
import { maxWidgetPropsBytes, widget } from "./assistant/widget.js";
|
|
33
39
|
import { functionApp } from "./functions/function-app.js";
|
|
34
40
|
import { readJson } from "./functions/read-json.js";
|
|
@@ -36,4 +42,7 @@ import { verifySignature, verifyStandardWebhook } from "./functions/verify-signa
|
|
|
36
42
|
import { requireEnv } from "./functions/require-env.js";
|
|
37
43
|
import { createFileCleanup } from "./files/file-cleanup.js";
|
|
38
44
|
import { aspectRatio, fileSize, fileType, imageSize, processor } from "./files/processors.js";
|
|
39
|
-
|
|
45
|
+
import { FatalJobError } from "./jobs/run-job.js";
|
|
46
|
+
import { startJobs } from "./jobs/runtime.js";
|
|
47
|
+
import { jobsDrainApp } from "./jobs/drain-route.js";
|
|
48
|
+
export { FatalJobError, HttpProblem, ModelError, addAppRoleToOwners, addMember, aspectRatio, assistantProtocolRoutes, assistantRoles, assistantSettings, assistantVariables, authSchemaMigration, badRequest, betterAuthAuthenticator, changesMigration, checkAuthSchema, checkChanges, checkJobsSchema, coalesce, configExports, consoleAuditQueue, conversationKey, createAdmin, createAuth, createConversations, createFileCleanup, createOrganization, createUser, defaultSignInPolicy, defineConfig, defineFunction, defineJob, defineTool, deleteUser, eventMatcher, fileConversationStore, fileSize, fileType, forbidden, functionApp, hasUsers, imageSize, isJobDefinition, issueToken, jobDefinitions, jobsDrainApp, jobsSchema, jobsSchemaMigration, jwtAuthenticator, listOrganizations, listUsers, localFileStore, localFiles, maxTokenTtlSeconds, maxWidgetPropsBytes, mergeConfig, migrationCommand, normalizeRoles, notFound, parseRoles, processor, readJson, readOnlyQueryTool, readOperatorSettings, readPlatformSignIn, readWriteQueryTool, recordOf, removeMember, requestApproval, requireEnv, resourceChange, roleChoices, runReadOnlyQuery, runReadWriteQuery, runTurn, runtimeUrl, runtimeVariable, seesAssistant, seesRuntime, setMemberRoles, setUserBanned, setUserRole, signInPolicyMethods, startJobs, storageCleanupSchedule, streamChatCompletion, unauthorized, verifySignature, verifyStandardWebhook, widget, withCacheBreakpoints };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { EnqueueOptions, JobDefinition } from "./job-types.js";
|
|
2
|
+
import { Db } from "@protobase/query";
|
|
3
|
+
//#region src/jobs/current.d.ts
|
|
4
|
+
/** What `defineJob(...).enqueue` reaches: the jobs runtime this process started. */
|
|
5
|
+
export type JobsEnqueuer = {
|
|
6
|
+
enqueue(definition: JobDefinition, db: Db, payload: unknown, options?: EnqueueOptions): Promise<string>;
|
|
7
|
+
};
|
|
8
|
+
//#endregion
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
//#region src/jobs/current.ts
|
|
2
|
+
const key = Symbol.for("protobase.jobs");
|
|
3
|
+
const holder = globalThis;
|
|
4
|
+
/** The running jobs runtime; enqueueing needs one, started by `protobase dev`, `serve` and `worker`, or by `startJobs`. */
|
|
5
|
+
const currentJobs = () => {
|
|
6
|
+
const runtime = holder[key];
|
|
7
|
+
if (!runtime) throw new Error("Jobs are not running in this process: start them with startJobs(), as protobase dev, serve and worker do");
|
|
8
|
+
return runtime;
|
|
9
|
+
};
|
|
10
|
+
const setCurrentJobs = (runtime) => {
|
|
11
|
+
if (holder[key]) throw new Error("Jobs are already running in this process; stop them before starting them again");
|
|
12
|
+
holder[key] = runtime;
|
|
13
|
+
};
|
|
14
|
+
const clearCurrentJobs = (runtime) => {
|
|
15
|
+
if (holder[key] === runtime) delete holder[key];
|
|
16
|
+
};
|
|
17
|
+
//#endregion
|
|
18
|
+
export { clearCurrentJobs, currentJobs, setCurrentJobs };
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { CompiledQuery } from "kysely";
|
|
2
|
+
//#region src/jobs/database.ts
|
|
3
|
+
const block = /^\s*BEGIN;\s*(SET LOCAL lock_timeout = \d+);\s*(SET LOCAL idle_in_transaction_session_timeout = \d+);\s*(SELECT pg_advisory_xact_lock\([^;]*\);\s*)?([\s\S]+?);\s*COMMIT;\s*$/;
|
|
4
|
+
/**
|
|
5
|
+
* The statements of one of pg-boss's transaction texts, in order, or `undefined` for any other text. A text that
|
|
6
|
+
* starts a transaction and is not in that shape is an error, so a pg-boss upgrade that changes it fails loudly.
|
|
7
|
+
*/
|
|
8
|
+
const transactionStatements = (text) => {
|
|
9
|
+
if (!/^\s*BEGIN;/.test(text)) return void 0;
|
|
10
|
+
const match = block.exec(text);
|
|
11
|
+
if (!match) throw new Error(`Unexpected pg-boss transaction:\n${text}`);
|
|
12
|
+
const [, lockTimeout, idleTimeout, lock, statement] = match;
|
|
13
|
+
return [
|
|
14
|
+
lockTimeout,
|
|
15
|
+
idleTimeout,
|
|
16
|
+
...lock ? [lock.trim().replace(/;$/, "")] : [],
|
|
17
|
+
statement
|
|
18
|
+
];
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* pg-boss's database over the app's own Kysely pool or transaction: one connection pool for the app and its jobs, the
|
|
22
|
+
* same driver on Node, Bun and PGlite. Every statement runs on its own, or inside one transaction for pg-boss's
|
|
23
|
+
* transaction texts, which works through a pooler in transaction mode: pg-boss takes only transaction-scoped locks.
|
|
24
|
+
*/
|
|
25
|
+
const jobsDatabase = (db) => ({ executeSql: async (text, values) => {
|
|
26
|
+
if (values && values.length > 0) return { rows: [...(await db.executeQuery(CompiledQuery.raw(text, values))).rows] };
|
|
27
|
+
const statements = transactionStatements(text);
|
|
28
|
+
if (!statements) return { rows: [...(await db.executeQuery(CompiledQuery.raw(text))).rows] };
|
|
29
|
+
return db.transaction().execute(async (trx) => {
|
|
30
|
+
let rows = [];
|
|
31
|
+
for (const statement of statements) rows = [...(await trx.executeQuery(CompiledQuery.raw(statement))).rows];
|
|
32
|
+
return { rows };
|
|
33
|
+
});
|
|
34
|
+
} });
|
|
35
|
+
//#endregion
|
|
36
|
+
export { jobsDatabase, transactionStatements };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { JobDefinition, JobOptions } from "./job-types.js";
|
|
2
|
+
//#region src/jobs/define-job.d.ts
|
|
3
|
+
/** A job the app's workers run: export it from the module that `protobase.config.ts` passes as `jobs`. */
|
|
4
|
+
export declare const defineJob: <Payload = undefined>(options: JobOptions<Payload>) => JobDefinition<Payload>;
|
|
5
|
+
export declare const isJobDefinition: (value: unknown) => value is JobDefinition;
|
|
6
|
+
/** The job definitions among a module's exports, such as `import * as jobs from './config/jobs'`, each name once. */
|
|
7
|
+
export declare const jobDefinitions: (module: Record<string, unknown>) => JobDefinition[];
|
|
8
|
+
//#endregion
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { currentJobs } from "./current.js";
|
|
2
|
+
import { nextRun } from "./schedule.js";
|
|
3
|
+
//#region src/jobs/define-job.ts
|
|
4
|
+
const namePattern = /^[\w.\-/]+$/;
|
|
5
|
+
const checkSchedule = (name, schedule, timezone) => {
|
|
6
|
+
try {
|
|
7
|
+
nextRun(schedule, timezone, /* @__PURE__ */ new Date());
|
|
8
|
+
} catch (error) {
|
|
9
|
+
if (!(error instanceof Error)) throw error;
|
|
10
|
+
throw new Error(`Job "${name}" has the schedule "${schedule}" in ${timezone}, which is not a cron schedule there: ${error.message}`, { cause: error });
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
/** A job the app's workers run: export it from the module that `protobase.config.ts` passes as `jobs`. */
|
|
14
|
+
const defineJob = (options) => {
|
|
15
|
+
if (!namePattern.test(options.name)) throw new Error(`Job name "${options.name}" may only hold letters, digits, "_", "-", "." and "/"`);
|
|
16
|
+
if (options.schedule !== void 0) checkSchedule(options.name, options.schedule, options.timezone ?? "UTC");
|
|
17
|
+
const definition = {
|
|
18
|
+
kind: "job",
|
|
19
|
+
name: options.name,
|
|
20
|
+
options,
|
|
21
|
+
enqueue: async (db, payload, enqueueOptions) => currentJobs().enqueue(definition, db, payload, enqueueOptions)
|
|
22
|
+
};
|
|
23
|
+
return definition;
|
|
24
|
+
};
|
|
25
|
+
const isJobDefinition = (value) => typeof value === "object" && value !== null && value.kind === "job" && typeof value.enqueue === "function";
|
|
26
|
+
/** The job definitions among a module's exports, such as `import * as jobs from './config/jobs'`, each name once. */
|
|
27
|
+
const jobDefinitions = (module) => {
|
|
28
|
+
const byName = /* @__PURE__ */ new Map();
|
|
29
|
+
for (const value of Object.values(module)) {
|
|
30
|
+
if (!isJobDefinition(value)) continue;
|
|
31
|
+
const known = byName.get(value.name);
|
|
32
|
+
if (known && known !== value) throw new Error(`Two jobs are named "${value.name}"; rename one of them`);
|
|
33
|
+
byName.set(value.name, value);
|
|
34
|
+
}
|
|
35
|
+
return [...byName.values()];
|
|
36
|
+
};
|
|
37
|
+
//#endregion
|
|
38
|
+
export { defineJob, isJobDefinition, jobDefinitions };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { JobsRuntime } from "./runtime.js";
|
|
2
|
+
//#region src/jobs/drain-route.d.ts
|
|
3
|
+
/**
|
|
4
|
+
* `POST /api/jobs/drain?seconds=25`: runs the app's due jobs until none is left or `seconds` have passed, and answers
|
|
5
|
+
* `{ drained, remaining, nextDue }`. For the operator of a host that lets the app sleep and wakes it for its jobs: it
|
|
6
|
+
* takes the operator's `token` as a bearer token, never a user's.
|
|
7
|
+
*/
|
|
8
|
+
export declare const jobsDrainApp: ({ runtime, token }: {
|
|
9
|
+
runtime: JobsRuntime;
|
|
10
|
+
token: string;
|
|
11
|
+
}) => import("hono/hono-base").HonoBase<import("hono/types").BlankEnv, {
|
|
12
|
+
"/api/jobs/drain": {
|
|
13
|
+
$post: {
|
|
14
|
+
input: {};
|
|
15
|
+
output: {};
|
|
16
|
+
outputFormat: string;
|
|
17
|
+
status: import("hono/utils/http-status").StatusCode;
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
}, "/", "/api/jobs/drain">;
|
|
21
|
+
//#endregion
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { HttpProblem, badRequest, problemResponse, unauthorized } from "../problem.js";
|
|
2
|
+
import { Hono } from "hono";
|
|
3
|
+
import { createHash, timingSafeEqual } from "node:crypto";
|
|
4
|
+
//#region src/jobs/drain-route.ts
|
|
5
|
+
const drainPath = "/api/jobs/drain";
|
|
6
|
+
const digest = (text) => createHash("sha256").update(text).digest();
|
|
7
|
+
const sameToken = (given, token) => given !== void 0 && timingSafeEqual(digest(given), digest(token));
|
|
8
|
+
const maxSeconds = 300;
|
|
9
|
+
/**
|
|
10
|
+
* `POST /api/jobs/drain?seconds=25`: runs the app's due jobs until none is left or `seconds` have passed, and answers
|
|
11
|
+
* `{ drained, remaining, nextDue }`. For the operator of a host that lets the app sleep and wakes it for its jobs: it
|
|
12
|
+
* takes the operator's `token` as a bearer token, never a user's.
|
|
13
|
+
*/
|
|
14
|
+
const jobsDrainApp = ({ runtime, token }) => new Hono().post(drainPath, async (c) => {
|
|
15
|
+
const problem = (error) => problemResponse(error, c.req.path);
|
|
16
|
+
if (!sameToken(c.req.header("authorization")?.replace(/^Bearer /, ""), token)) return problem(unauthorized("Send the operator token as a bearer token"));
|
|
17
|
+
const seconds = Number(c.req.query("seconds") ?? 25);
|
|
18
|
+
if (!Number.isFinite(seconds) || seconds <= 0 || seconds > maxSeconds) return problem(badRequest("invalid-seconds", `seconds must be more than 0 and at most ${maxSeconds}`));
|
|
19
|
+
if (!runtime.works) return problem(new HttpProblem(409, "jobs-elsewhere", "Conflict", "This process runs no jobs (PROTOBASE_JOBS=off); drain the one that does"));
|
|
20
|
+
const { drained, remaining, nextDue } = await runtime.drain(seconds);
|
|
21
|
+
return c.json({
|
|
22
|
+
drained,
|
|
23
|
+
remaining,
|
|
24
|
+
nextDue: nextDue?.toISOString() ?? null
|
|
25
|
+
});
|
|
26
|
+
});
|
|
27
|
+
//#endregion
|
|
28
|
+
export { drainPath, jobsDrainApp };
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { jobsSchema } from "./schema.js";
|
|
2
|
+
import { f, l, resource, view } from "@protobase/schema";
|
|
3
|
+
//#region src/jobs/failed-jobs.ts
|
|
4
|
+
const admins = ({ user }) => user?.roles?.includes("admin") ?? false;
|
|
5
|
+
/**
|
|
6
|
+
* The failed jobs, over the `jobs.failed` view: the admin app lists them with their last error, and retries or deletes
|
|
7
|
+
* one through the view's triggers. Admins only, whatever the project's roles say.
|
|
8
|
+
*/
|
|
9
|
+
const failedJobs = resource("failedJobs").table(`${jobsSchema}.failed`).fields({
|
|
10
|
+
id: f.uuid().readOnly().filterable(),
|
|
11
|
+
name: f.text().readOnly().filterable().sortable(),
|
|
12
|
+
error: f.text().optional().readOnly(),
|
|
13
|
+
attempts: f.integer().readOnly(),
|
|
14
|
+
failedAt: f.timestamp().readOnly().filterable().sortable(),
|
|
15
|
+
createdAt: f.timestamp().readOnly().sortable(),
|
|
16
|
+
key: f.text().optional().readOnly().filterable(),
|
|
17
|
+
payload: f.json().optional().readOnly(),
|
|
18
|
+
output: f.json().optional().readOnly(),
|
|
19
|
+
retry: f.boolean()
|
|
20
|
+
}).primaryKey((r) => r.id).access({
|
|
21
|
+
list: admins,
|
|
22
|
+
read: admins,
|
|
23
|
+
update: admins,
|
|
24
|
+
delete: admins,
|
|
25
|
+
create: () => false
|
|
26
|
+
});
|
|
27
|
+
const failedJobsView = view("failedJobs").names({
|
|
28
|
+
singular: "Failed job",
|
|
29
|
+
plural: "Failed jobs"
|
|
30
|
+
}).icon("triangle-alert").title((r) => r.name).help("Jobs that used up their attempts, or failed for good. Retry one once its cause is fixed: it gets one more attempt.").fields((r) => ({
|
|
31
|
+
name: r.name.label("Job"),
|
|
32
|
+
error: r.error.label("Last error"),
|
|
33
|
+
failedAt: r.failedAt.label("Failed"),
|
|
34
|
+
createdAt: r.createdAt.label("Enqueued"),
|
|
35
|
+
output: r.output.label("Error details")
|
|
36
|
+
})).list((r) => ({
|
|
37
|
+
columns: [
|
|
38
|
+
r.name,
|
|
39
|
+
r.error,
|
|
40
|
+
r.attempts,
|
|
41
|
+
r.failedAt
|
|
42
|
+
],
|
|
43
|
+
sort: [[r.failedAt, "desc"]]
|
|
44
|
+
})).layout((r) => [
|
|
45
|
+
l.section("Failure", [r.error, r.output]),
|
|
46
|
+
l.section("Job", [
|
|
47
|
+
r.name,
|
|
48
|
+
r.key,
|
|
49
|
+
r.payload
|
|
50
|
+
]),
|
|
51
|
+
l.sidebar([
|
|
52
|
+
r.attempts,
|
|
53
|
+
r.failedAt,
|
|
54
|
+
r.createdAt
|
|
55
|
+
])
|
|
56
|
+
]).actions((a) => [a.update("retry", {
|
|
57
|
+
label: "Retry",
|
|
58
|
+
icon: "rotate-ccw",
|
|
59
|
+
set: { retry: true },
|
|
60
|
+
confirm: "Run this job once more, from now?"
|
|
61
|
+
}), a.remove("delete", {
|
|
62
|
+
label: "Delete",
|
|
63
|
+
icon: "trash-2",
|
|
64
|
+
confirm: "Delete this job? It will not run again."
|
|
65
|
+
})]);
|
|
66
|
+
//#endregion
|
|
67
|
+
export { failedJobs, failedJobsView };
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
/** The comment each Protobase function in the jobs schema carries, which the startup check reads. */
|
|
2
|
+
const functionsComment = `Protobase jobs 2`;
|
|
3
|
+
/** Protobase's own functions beside pg-boss's tables, by name; each carries `functionsComment`. */
|
|
4
|
+
const functionNames = [
|
|
5
|
+
"enqueue",
|
|
6
|
+
"next_due",
|
|
7
|
+
"failed_retry",
|
|
8
|
+
"failed_delete"
|
|
9
|
+
];
|
|
10
|
+
/**
|
|
11
|
+
* `jobs.enqueue(name, payload, run_at, key, group_key, priority)`: a job from SQL, such as a trigger, in the caller's
|
|
12
|
+
* transaction. It inserts what pg-boss's `send()` does, with the queue's retry settings; it creates a queue that no
|
|
13
|
+
* worker has created yet. A `key` keeps one waiting job, as `mode: 'dedupe'` does, and an ordered job takes its group
|
|
14
|
+
* as `group_key`. Tied to the pg-boss schema version, which the startup check pins.
|
|
15
|
+
*/
|
|
16
|
+
const enqueue = (schema) => `create or replace function ${schema}.enqueue(
|
|
17
|
+
job_name text,
|
|
18
|
+
payload jsonb default null,
|
|
19
|
+
run_at timestamptz default null,
|
|
20
|
+
key text default null,
|
|
21
|
+
group_key text default null,
|
|
22
|
+
priority integer default 0
|
|
23
|
+
) returns uuid
|
|
24
|
+
language plpgsql as $$
|
|
25
|
+
declare
|
|
26
|
+
queue ${schema}.queue;
|
|
27
|
+
start timestamptz := coalesce(run_at, ${schema}.job_now());
|
|
28
|
+
job_id uuid;
|
|
29
|
+
begin
|
|
30
|
+
if key is not null and group_key is not null then
|
|
31
|
+
raise exception 'Job "%": an ordered job takes a group_key and no key', job_name;
|
|
32
|
+
end if;
|
|
33
|
+
perform ${schema}.create_queue(job_name, jsonb_build_object('policy', case when group_key is null then 'standard' else 'key_strict_fifo' end));
|
|
34
|
+
select * into queue from ${schema}.queue where name = job_name;
|
|
35
|
+
if (queue.policy = 'key_strict_fifo') <> (group_key is not null) then
|
|
36
|
+
raise exception 'Job "%" %', job_name, case when group_key is null then 'is ordered: pass its group_key' else 'is not ordered: it takes no group_key' end;
|
|
37
|
+
end if;
|
|
38
|
+
if key is not null then
|
|
39
|
+
select id into job_id from ${schema}.job
|
|
40
|
+
where name = job_name and singleton_key = key and state < 'active'
|
|
41
|
+
order by created_on desc limit 1;
|
|
42
|
+
if found then
|
|
43
|
+
return job_id;
|
|
44
|
+
end if;
|
|
45
|
+
end if;
|
|
46
|
+
execute format(
|
|
47
|
+
'insert into ${schema}.%I (name, data, priority, start_after, singleton_key, retry_limit, retry_delay, retry_backoff,
|
|
48
|
+
retry_delay_max, expire_seconds, deletion_seconds, keep_until, policy, dead_letter, heartbeat_seconds, upsert_by_key)
|
|
49
|
+
values ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $4 + $12 * interval ''1s'', $13, $14, $15, $16)
|
|
50
|
+
on conflict do nothing
|
|
51
|
+
returning id',
|
|
52
|
+
queue.table_name)
|
|
53
|
+
using job_name, payload, priority, start, coalesce(key, group_key), queue.retry_limit, queue.retry_delay,
|
|
54
|
+
queue.retry_backoff, queue.retry_delay_max, queue.expire_seconds, queue.deletion_seconds, queue.retention_seconds,
|
|
55
|
+
queue.policy, queue.dead_letter, queue.heartbeat_seconds, key is not null
|
|
56
|
+
into job_id;
|
|
57
|
+
-- A concurrent enqueue of the same key inserted first: its job is the one waiting.
|
|
58
|
+
if job_id is null and key is not null then
|
|
59
|
+
select id into job_id from ${schema}.job
|
|
60
|
+
where name = job_name and singleton_key = key and state < 'active'
|
|
61
|
+
order by created_on desc limit 1;
|
|
62
|
+
end if;
|
|
63
|
+
return job_id;
|
|
64
|
+
end
|
|
65
|
+
$$;
|
|
66
|
+
comment on function ${schema}.enqueue(text, jsonb, timestamptz, text, text, integer) is '${functionsComment}';`;
|
|
67
|
+
/**
|
|
68
|
+
* `jobs.next_due()`: when the next job is due, or `null` when none waits: what a host that sleeps reads to know when to
|
|
69
|
+
* wake the app, through any pooler. A waiting job counts from its start time, unless a failed job holds back its ordered
|
|
70
|
+
* group; a running one from when its try times out, since its worker may have died with the app. Recurring jobs wait
|
|
71
|
+
* as their next run, so they count too.
|
|
72
|
+
*/
|
|
73
|
+
const nextDue = (schema) => `create or replace function ${schema}.next_due() returns timestamptz
|
|
74
|
+
language sql stable as $$
|
|
75
|
+
select min(due) from (
|
|
76
|
+
select j.start_after as due from ${schema}.job j
|
|
77
|
+
where j.state < 'active' and not j.blocked
|
|
78
|
+
and not (j.policy = 'key_strict_fifo' and exists (
|
|
79
|
+
select 1 from ${schema}.job h where h.name = j.name and h.singleton_key = j.singleton_key and h.state = 'failed'))
|
|
80
|
+
union all
|
|
81
|
+
select started_on + expire_seconds * interval '1s' from ${schema}.job where state = 'active'
|
|
82
|
+
) jobs
|
|
83
|
+
$$;
|
|
84
|
+
comment on function ${schema}.next_due() is '${functionsComment}';`;
|
|
85
|
+
/**
|
|
86
|
+
* `jobs.failed`: the failed jobs, for the admin app's page, with their last error. Updating `retry` to true retries a
|
|
87
|
+
* job, as pg-boss's `retry()` does: one more attempt, from now; deleting a row deletes the job.
|
|
88
|
+
*/
|
|
89
|
+
const failed = (schema) => `create index if not exists job_failed_i on ${schema}.job (completed_on) where state = 'failed';
|
|
90
|
+
drop view if exists ${schema}.failed;
|
|
91
|
+
create view ${schema}.failed as
|
|
92
|
+
select id, name, data as payload, retry_count + 1 as attempts,
|
|
93
|
+
coalesce(output ->> 'message', output -> 'value' ->> 'message', output ->> 'value') as error,
|
|
94
|
+
output, completed_on as failed_at, created_on as created_at, singleton_key as key, false as retry
|
|
95
|
+
from ${schema}.job where state = 'failed';
|
|
96
|
+
create or replace function ${schema}.failed_retry() returns trigger
|
|
97
|
+
language plpgsql as $$
|
|
98
|
+
begin
|
|
99
|
+
if new.retry then
|
|
100
|
+
update ${schema}.job
|
|
101
|
+
set state = 'retry', retry_limit = retry_limit + 1, completed_on = null,
|
|
102
|
+
start_after = greatest(start_after, ${schema}.job_now()), keep_until = greatest(keep_until, ${schema}.job_now() + interval '14 days')
|
|
103
|
+
where name = old.name and id = old.id and state = 'failed';
|
|
104
|
+
end if;
|
|
105
|
+
return new;
|
|
106
|
+
end
|
|
107
|
+
$$;
|
|
108
|
+
comment on function ${schema}.failed_retry() is '${functionsComment}';
|
|
109
|
+
create or replace function ${schema}.failed_delete() returns trigger
|
|
110
|
+
language plpgsql as $$
|
|
111
|
+
begin
|
|
112
|
+
delete from ${schema}.job where name = old.name and id = old.id and state = 'failed';
|
|
113
|
+
return old;
|
|
114
|
+
end
|
|
115
|
+
$$;
|
|
116
|
+
comment on function ${schema}.failed_delete() is '${functionsComment}';
|
|
117
|
+
create trigger failed_retry instead of update on ${schema}.failed for each row execute function ${schema}.failed_retry();
|
|
118
|
+
create trigger failed_delete instead of delete on ${schema}.failed for each row execute function ${schema}.failed_delete();`;
|
|
119
|
+
/** The statements that create or replace every Protobase object in `schema`. */
|
|
120
|
+
const functionsSql = (schema) => [
|
|
121
|
+
enqueue(schema),
|
|
122
|
+
nextDue(schema),
|
|
123
|
+
failed(schema)
|
|
124
|
+
].join("\n\n");
|
|
125
|
+
//#endregion
|
|
126
|
+
export { functionNames, functionsComment, functionsSql };
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { StandardSchema } from "../functions/read-json.js";
|
|
2
|
+
import { Db } from "@protobase/query";
|
|
3
|
+
//#region src/jobs/job-types.d.ts
|
|
4
|
+
/** What `run` gets beside the payload. */
|
|
5
|
+
export type JobContext = {
|
|
6
|
+
/** The database pool. The enqueuer's transaction has committed by the time a job runs. */
|
|
7
|
+
db: Db;
|
|
8
|
+
job: {
|
|
9
|
+
id: string;
|
|
10
|
+
name: string;
|
|
11
|
+
attempt: number;
|
|
12
|
+
maxAttempts: number;
|
|
13
|
+
};
|
|
14
|
+
/** Aborted when the job's timeout passes, or when the worker shuts down and its grace period ends. */
|
|
15
|
+
signal: AbortSignal;
|
|
16
|
+
};
|
|
17
|
+
export type JobOptions<Payload> = {
|
|
18
|
+
/** Letters, digits, `_`, `-`, `.` and `/`; the job's queue in the `jobs` schema. */
|
|
19
|
+
name: string;
|
|
20
|
+
/** Checks the payload when it is enqueued and again before it runs, such as a zod schema. */
|
|
21
|
+
payload?: StandardSchema<Payload>;
|
|
22
|
+
run: (payload: Payload, context: JobContext) => Promise<void> | void;
|
|
23
|
+
/** Tries before the job is kept as failed, listed in the admin app. Default 10. */
|
|
24
|
+
maxAttempts?: number;
|
|
25
|
+
/** The wait before the first retry, doubling with each one: milliseconds or text such as `30 seconds`. Default `2s`. */
|
|
26
|
+
retryDelay?: number | string;
|
|
27
|
+
/** The longest wait between two tries. Default `1 hour`. */
|
|
28
|
+
maxRetryDelay?: number | string;
|
|
29
|
+
/** How long one try may run before it counts as failed. Default `15 minutes`. */
|
|
30
|
+
timeout?: number | string;
|
|
31
|
+
/** Jobs of this name running at once in each worker process. Default 1. */
|
|
32
|
+
concurrency?: number;
|
|
33
|
+
/**
|
|
34
|
+
* Jobs run one at a time per group, in the order they were enqueued, and every enqueue names its group. A job that is
|
|
35
|
+
* retrying or failed holds back the rest of its group until it succeeds, or is retried or deleted in the admin app.
|
|
36
|
+
*/
|
|
37
|
+
ordered?: boolean;
|
|
38
|
+
/**
|
|
39
|
+
* Runs the job on this cron schedule, such as `0 7 * * *` (with an optional seconds field first), with no payload: one
|
|
40
|
+
* run per time, however many workers run. A run missed while no worker ran happens once, as soon as one does.
|
|
41
|
+
*/
|
|
42
|
+
schedule?: string;
|
|
43
|
+
/** The time zone `schedule` is read in, such as `Europe/Amsterdam`. Default `UTC`. */
|
|
44
|
+
timezone?: string;
|
|
45
|
+
};
|
|
46
|
+
/** Where and how one enqueue lands; a job runs as soon as possible by default. */
|
|
47
|
+
export type EnqueueOptions = {
|
|
48
|
+
/** When the job may run first. */
|
|
49
|
+
runAt?: Date;
|
|
50
|
+
/** How long from now before the job may run first: milliseconds or text such as `5 minutes`. */
|
|
51
|
+
delay?: number | string;
|
|
52
|
+
/**
|
|
53
|
+
* Keeps one waiting job per key; a running job does not count. With `mode: 'dedupe'` (the default) an enqueue while
|
|
54
|
+
* one waits leaves it as it is, with `'replace'` it takes this payload and these options. Not for ordered jobs.
|
|
55
|
+
*/
|
|
56
|
+
key?: string;
|
|
57
|
+
mode?: 'dedupe' | 'replace';
|
|
58
|
+
/** The group of an ordered job; required there, refused elsewhere. */
|
|
59
|
+
group?: string;
|
|
60
|
+
/** Higher runs first. Default 0. */
|
|
61
|
+
priority?: number;
|
|
62
|
+
};
|
|
63
|
+
export type JobDefinition<Payload = any> = {
|
|
64
|
+
readonly kind: 'job';
|
|
65
|
+
readonly name: string;
|
|
66
|
+
readonly options: JobOptions<Payload>;
|
|
67
|
+
/**
|
|
68
|
+
* Adds a job and returns its id: in `db`'s own transaction when it is one, so the job commits with the caller's
|
|
69
|
+
* writes or not at all. With a `key` it returns the waiting job's id when that one is kept.
|
|
70
|
+
*/
|
|
71
|
+
enqueue(db: Db, ...args: Payload extends undefined ? [payload?: Payload, options?: EnqueueOptions] : [payload: Payload, options?: EnqueueOptions]): Promise<string>;
|
|
72
|
+
};
|
|
73
|
+
//#endregion
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { parseDuration } from "../files/duration.js";
|
|
2
|
+
//#region src/jobs/options.ts
|
|
3
|
+
/** pg-boss counts in whole seconds; a duration rounds up, so a wait is never shorter than asked. */
|
|
4
|
+
const seconds = (value, label) => Math.ceil(parseDuration(value, label) / 1e3);
|
|
5
|
+
const positive = (value, label) => {
|
|
6
|
+
if (!Number.isSafeInteger(value) || value < 1) throw new Error(`${label} must be a whole number of at least 1, not ${value}`);
|
|
7
|
+
return value;
|
|
8
|
+
};
|
|
9
|
+
/** The pg-boss queue a job definition runs in: its policy, retries with backoff and timeout. */
|
|
10
|
+
const queueOptions = (options) => {
|
|
11
|
+
const label = `Job "${options.name}"`;
|
|
12
|
+
return {
|
|
13
|
+
policy: options.ordered ? "key_strict_fifo" : "standard",
|
|
14
|
+
retryLimit: positive(options.maxAttempts ?? 10, `${label} maxAttempts`) - 1,
|
|
15
|
+
retryDelay: positive(seconds(options.retryDelay ?? "2s", `${label} retryDelay`), `${label} retryDelay in seconds`),
|
|
16
|
+
retryBackoff: true,
|
|
17
|
+
retryDelayMax: positive(seconds(options.maxRetryDelay ?? "1 hour", `${label} maxRetryDelay`), `${label} maxRetryDelay in seconds`),
|
|
18
|
+
expireInSeconds: positive(seconds(options.timeout ?? "15 minutes", `${label} timeout`), `${label} timeout in seconds`)
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
/** The queue settings `queueOptions` sets, as `getQueue` reads them back, so a changed definition is noticed. */
|
|
22
|
+
const queueSettingsDiffer = (wanted, stored) => Object.keys(wanted).some((key) => key !== "policy" && stored[key] !== wanted[key]);
|
|
23
|
+
/**
|
|
24
|
+
* The pg-boss send options of one enqueue: when, how urgent, and the key a waiting job is found by. An ordered job's
|
|
25
|
+
* group is its key in pg-boss, which keeps one group's jobs in order.
|
|
26
|
+
*/
|
|
27
|
+
const sendOptions = (options, enqueue = {}) => {
|
|
28
|
+
const label = `Job "${options.name}"`;
|
|
29
|
+
if (enqueue.runAt && enqueue.delay !== void 0) throw new Error(`${label}: pass runAt or delay, not both`);
|
|
30
|
+
if (options.ordered && enqueue.group === void 0) throw new Error(`${label} is ordered: name the group each job runs in with { group }`);
|
|
31
|
+
if (options.ordered && enqueue.key !== void 0) throw new Error(`${label} is ordered: its jobs are found by their group, so it takes no key`);
|
|
32
|
+
if (!options.ordered && enqueue.group !== void 0) throw new Error(`${label} is not ordered: a group needs ordered: true in defineJob`);
|
|
33
|
+
if (enqueue.mode && enqueue.key === void 0) throw new Error(`${label}: mode needs a key`);
|
|
34
|
+
if (enqueue.priority !== void 0 && !Number.isSafeInteger(enqueue.priority)) throw new Error(`${label}: priority must be a whole number`);
|
|
35
|
+
const startAfter = enqueue.runAt ?? (enqueue.delay === void 0 ? void 0 : seconds(enqueue.delay, `${label} delay`));
|
|
36
|
+
const singletonKey = options.ordered ? enqueue.group : enqueue.key;
|
|
37
|
+
return {
|
|
38
|
+
...startAfter !== void 0 && { startAfter },
|
|
39
|
+
...enqueue.priority !== void 0 && { priority: enqueue.priority },
|
|
40
|
+
...singletonKey !== void 0 && { singletonKey }
|
|
41
|
+
};
|
|
42
|
+
};
|
|
43
|
+
//#endregion
|
|
44
|
+
export { queueOptions, queueSettingsDiffer, sendOptions };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import "./job-types.js";
|
|
2
|
+
import { Db } from "@protobase/query";
|
|
3
|
+
import "pg-boss";
|
|
4
|
+
//#region src/jobs/run-job.d.ts
|
|
5
|
+
/** Thrown from a job's `run`, it fails the job now: the attempts it has left are not used. */
|
|
6
|
+
export declare class FatalJobError extends Error {
|
|
7
|
+
name: string;
|
|
8
|
+
}
|
|
9
|
+
//#endregion
|