@shivaedev/jobs 0.23.2 → 0.24.0

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/CHANGELOG.md CHANGED
@@ -1,5 +1,24 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.24.0 - 2026-10-31
4
+
5
+ ### Added
6
+
7
+ - `makePgBoss(identifier, queueNames)` accepts names from a browser-safe module shared with queue definitions and client filters. Each jobs Layer checks that its queue and schedule registrations match the declaration, and fails boot with `PgBossQueueNamesError` listing missing and unexpected names.
8
+
9
+ ### Changed
10
+
11
+ - Generated applications validate server queue registrations against the shared browser-safe declarations used by the admin Jobs page.
12
+
13
+ ### Fixed
14
+
15
+ - `RemoteHttpError` carries a readable message naming the status, method, host and path without query strings, headers or bodies.
16
+ - Failed jobs record the error message or a summary of its fields with sensitive values redacted, beside the error tag.
17
+
18
+ ### Breaking
19
+
20
+ - Jobs Layers include `PgBossQueueNamesError` in their typed startup errors. Consumers with explicit error unions must add this error or handle its tag. Existing services that omit the optional name declaration keep their registration behavior.
21
+
3
22
  ## 0.23.2 - 2026-10-30
4
23
 
5
24
  ### Changed
package/README.md CHANGED
@@ -29,12 +29,40 @@ A **queue definition** names a pg-boss queue and the Schema of its payload. Appl
29
29
 
30
30
  A **schedule definition** describes a queue with a cron trigger. `schedule.run(effect)` pairs it with an Effect that needs no payload. Queue workers and scheduled workers are **registrations**: the values you put in the jobs Layer's `jobs` list.
31
31
 
32
- The application creates one jobs service with `makePgBoss(identifier)`. Its Layer reads the shared `PgBoss` service, registers the job list and captures the services those workers need. One `pgBossLayer` owns the client and pool for the application; feature registrations drain before that Layer closes its client. Callers use the jobs service to enqueue a decoded payload, look up or retry a job, read queue health and live counts, or list failed and dead-lettered jobs.
32
+ The application creates one jobs service with `makePgBoss(identifier, queueNames?)`. Its Layer reads the shared `PgBoss` service, registers the job list and captures the services those workers need. One `pgBossLayer` owns the client and pool for the application; feature registrations drain before that Layer closes its client. Callers use the jobs service to enqueue a decoded payload, look up or retry a job, read queue health and live counts, or list failed and dead-lettered jobs.
33
33
 
34
34
  Use a distinct literal identifier for each jobs service. The service and its Layer keep that identifier in their types, so providing a Layer for a different identifier leaves the required jobs service unprovided at compile time.
35
35
 
36
36
  The work separates naturally: declare the application services once, define a queue and its worker for each feature, provide the complete registration list at the runtime boundary, and enqueue from ordinary application Effects.
37
37
 
38
+ ### Share queue names with the browser
39
+
40
+ Keep names and payload Schemas in a browser-safe module such as `queues.ts`:
41
+
42
+ ```ts
43
+ import { Schema } from "effect";
44
+
45
+ export const emailQueue = { name: "send-email", schema: Schema.Struct({ userId: Schema.Number }) } as const;
46
+ export const cleanupSchedule = { name: "cleanup-mail" } as const;
47
+ export const queueNames = [emailQueue.name, cleanupSchedule.name] as const;
48
+ ```
49
+
50
+ The client imports `queueNames` for its queue filter, or passes `emailQueue` to the admin jobs page. Server definitions reference the same declarations:
51
+
52
+ ```ts
53
+ import { defineQueue, defineSchedule } from "@shivaedev/jobs/server/definition.ts";
54
+ import { makePgBoss } from "@shivaedev/jobs/server/service.ts";
55
+ import { cleanupSchedule, emailQueue, queueNames } from "./queues.ts";
56
+
57
+ export const SendEmail = defineQueue({ ...emailQueue, queue: { retryLimit: 5 } });
58
+ export const Cleanup = defineSchedule({ ...cleanupSchedule, cron: "17 3 * * *" });
59
+ export const Jobs = makePgBoss("@app/Jobs", queueNames);
60
+ ```
61
+
62
+ With the second argument, every `Jobs.layer({ jobs })` checks its registrations against the declared names before registering queues, workers or schedules. A server name absent from the declaration or a declared name absent from the server fails startup with `PgBossQueueNamesError` from `@shivaedev/jobs/server/error.ts`; its `missing` and `unexpected` arrays identify both differences. Order does not matter. Producer queue definitions, queue workers and scheduled workers all contribute their queue names. An empty declaration accepts only an empty registration list. Without the second argument, the service keeps ordinary registration behavior.
63
+
64
+ Declare names per jobs service, so producer and worker Layers share a declaration when they register the same queues. Keep worker-only schedules in their own service when producers do not register them. Import only the browser-safe declaration module from client code; `defineQueue`, `defineSchedule` and `makePgBoss` stay on the server.
65
+
38
66
  ### Once per database: install the schema
39
67
 
40
68
  For an application on the app host of `@shivaedev/server`, register `pgBossSchema` beside the migration loader. The host's `migrate` mode installs or upgrades it after committing the application ledger. Its `check` and `wait` modes include pg-boss readiness in the same check as the numbered migrations.
@@ -253,7 +281,7 @@ export const jobsLayer = (databaseUrl: Redacted.Redacted<string>) =>
253
281
  );
254
282
  ```
255
283
 
256
- The redacted connection string is unwrapped only at the pg-boss adapter. Put connection, pool size, client factory, schema, migration and stop settings in `pgBossLayer`. Provide the same Layer to the merged registration, worker and producer services so native Layer memoization starts one client. `jobs` is the complete list of registrations for this Layer. The Layer captures `MailLive` for both the queue handler and the scheduled Effect. A startup or registration failure fails Layer acquisition with `PgBossError` or `PgBossQueueOptionsError` and closes its registrations. The owning app Layer releases the client. Registration creates a queue again, up to six times with a short backoff, when PostgreSQL rolls the creation back as a deadlock victim (SQLSTATE `40P01`), which a partitioned queue can meet when other queues in the schema have traffic. A shared client stays running while another scope still owns a reference.
284
+ The redacted connection string is unwrapped only at the pg-boss adapter. Put connection, pool size, client factory, schema, migration and stop settings in `pgBossLayer`. Provide the same Layer to the merged registration, worker and producer services so native Layer memoization starts one client. `jobs` is the complete list of registrations for this Layer. The Layer captures `MailLive` for both the queue handler and the scheduled Effect. A client startup or queue registration failure fails Layer acquisition with `PgBossError` or `PgBossQueueOptionsError` and closes its registrations. A name declaration mismatch fails with `PgBossQueueNamesError`. The owning app Layer releases the client. Registration creates a queue again, up to six times with a short backoff, when PostgreSQL rolls the creation back as a deadlock victim (SQLSTATE `40P01`), which a partitioned queue can meet when other queues in the schema have traffic. A shared client stays running while another scope still owns a reference.
257
285
 
258
286
  Keep the Layer in the application's worker runtime scope. A short scope is useful for an acquisition or health check; a worker process needs its scope to remain open while it handles jobs.
259
287
 
@@ -500,7 +528,7 @@ Import the module that defines the name; the package has no root entry.
500
528
  | `@shivaedev/jobs/server/PgBoss.ts` | `PgBoss`: the shared client Context service. |
501
529
  | `@shivaedev/jobs/server/schema.ts` | `installPgBossSchema`, `pgBossSchema`; `PgBossSchemaOptions` |
502
530
  | `@shivaedev/jobs/server/health.ts` | `deadLetterQueueName`; `DeadLetteredJob`, `JobPage`, `JobPageOptions`, `JobsHealth`, `ListedJob`, `QueueCounts`, `QueueHealth` |
503
- | `@shivaedev/jobs/server/error.ts` | `PgBossError`, `PgBossPayloadError`, `PgBossQueueOptionsError`, `PgBossClientOptionsError`, `PgBossTestingError`, `toPgBossError`; `PgBossOperation` |
531
+ | `@shivaedev/jobs/server/error.ts` | `PgBossError`, `PgBossPayloadError`, `PgBossQueueNamesError`, `PgBossQueueOptionsError`, `PgBossClientOptionsError`, `PgBossTestingError`, `toPgBossError`; `PgBossOperation` |
504
532
  | `@shivaedev/jobs/server/client.ts` | `defaultClientFactory`; `PgBossClient`, `PgBossClientFactory` |
505
533
  | `@shivaedev/jobs/server/testing.ts` | `makePgBossTesting`, `testRetryPolicy`; `PgBossTesting`, `PgBossTestingOptions`, `SnapshotQueue`, `UnfinishedJob` |
506
534
 
@@ -19,6 +19,15 @@ export declare class PgBossQueueOptionsError extends PgBossQueueOptionsError_bas
19
19
  }> {
20
20
  get message(): string;
21
21
  }
22
+ declare const PgBossQueueNamesError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => import("effect/Cause").YieldableError & {
23
+ readonly _tag: "PgBossQueueNamesError";
24
+ } & Readonly<A>;
25
+ export declare class PgBossQueueNamesError extends PgBossQueueNamesError_base<{
26
+ readonly missing: readonly string[];
27
+ readonly unexpected: readonly string[];
28
+ }> {
29
+ get message(): string;
30
+ }
22
31
  declare const PgBossClientOptionsError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => import("effect/Cause").YieldableError & {
23
32
  readonly _tag: "PgBossClientOptionsError";
24
33
  } &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AAE,SAAS,MAAM,EAAE,CAAC;IACpC,QAAQ,CAAC,UAAU,EAAE,SAAS,MAAM,EAAE,CAAC;CACvC,CAAC;IACD,IAAa,OAAO,IAAI,MAAM,CAE7B;CACD;;;;AAED,qBAAa,wBAAyB,SAAQ,8BAA6C;IAC1F,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAC;IAC9B,QAAQ,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,CAAC;CACpC,CAAC;IACD,IAAa,OAAO,IAAI,MAAM,CAE7B;CACD;;;;AAED,qBAAa,kBAAmB,SAAQ,wBAAuC;IAC9E,QAAQ,CAAC,SAAS,EAAE,QAAQ,GAAG,QAAQ,CAAC;IACxC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;CAC9C,CAAC;CAAG;;;;AAEL,qBAAa,kBAAmB,SAAQ,wBAAuC;IAC9E,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;IAC9C,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CACpC,CAAC;CAAG;AAEL,wBAAgB,aAAa,CAAC,SAAS,EAAE,eAAe,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,WAAW,CAMrG"}
@@ -18,6 +18,11 @@ export class PgBossQueueOptionsError extends Data.TaggedError("PgBossQueueOption
18
18
  return `Queue ${this.queue} cannot change options after creation: ${this.options.join(", ")}`;
19
19
  }
20
20
  }
21
+ export class PgBossQueueNamesError extends Data.TaggedError("PgBossQueueNamesError") {
22
+ get message() {
23
+ return `Queue names differ from their declaration: missing [${this.missing.join(", ")}], unexpected [${this.unexpected.join(", ")}]`;
24
+ }
25
+ }
21
26
  export class PgBossClientOptionsError extends Data.TaggedError("PgBossClientOptionsError") {
22
27
  get message() {
23
28
  return `Shared pg-boss client ${String(this.key)} has different constructor settings: ${this.options.join(", ")}`;
@@ -1 +1 @@
1
- {"version":3,"file":"error.js","sourceRoot":"","sources":["../../src/server/error.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAgBxC,MAAM,OAAO,WAAY,SAAQ,IAAI,CAAC,WAAW,CAAC,aAAa,CAI7D;IACD,yGAAyG;IACzG,IAAa,OAAO;QACnB,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,cAAc,IAAI,CAAC,KAAK,EAAE,CAAC;QAC1E,OAAO,WAAW,IAAI,CAAC,SAAS,GAAG,MAAM,YAAY,YAAY,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,EAAE,CAAC;IACpG,CAAC;CACD;AAED,SAAS,YAAY,CAAC,QAAiB;IACtC,IAAI,CAAC,CAAC,QAAQ,YAAY,KAAK,CAAC,EAAE,CAAC;QAClC,OAAO,OAAO,QAAQ,CAAC;IACxB,CAAC;IACD,MAAM,IAAI,GAAY,OAAO,CAAC,GAAG,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;IACpD,OAAO,OAAO,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,GAAG,QAAQ,CAAC,WAAW,CAAC,IAAI,IAAI,IAAI,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,WAAW,CAAC,IAAI,CAAC;AACtG,CAAC;AAED,MAAM,OAAO,uBAAwB,SAAQ,IAAI,CAAC,WAAW,CAAC,yBAAyB,CAGrF;IACD,IAAa,OAAO;QACnB,OAAO,SAAS,IAAI,CAAC,KAAK,0CAA0C,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;IAC/F,CAAC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AAE,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC;QAC9B,KAAK;KACL,CAAC,CAAC;AACJ,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"failureOutput.d.ts","sourceRoot":"","sources":["../../../src/server/internal/failureOutput.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAqB,MAAM,QAAQ,CAAC;AAClD,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAE5C,wBAAgB,aAAa,CAAC,KAAK,EAAE,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,GAAG,OAAO,UAAU,CAAC,OAAO,CAKpF"}
1
+ {"version":3,"file":"failureOutput.d.ts","sourceRoot":"","sources":["../../../src/server/internal/failureOutput.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAqB,MAAM,QAAQ,CAAC;AAElD,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAa5C,wBAAgB,aAAa,CAAC,KAAK,EAAE,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,GAAG,OAAO,UAAU,CAAC,OAAO,CAIpF"}
@@ -1,9 +1,19 @@
1
1
  import { Cause, Predicate, Schema } from "effect";
2
+ import { redact } from "@shivaedev/errors/redact.ts";
2
3
  import { JobFailure } from "#JobFailure.ts";
4
+ function summary(error) {
5
+ if (Predicate.hasProperty(error, "message") && typeof error.message === "string" && error.message.trim() !== "") {
6
+ return error.message;
7
+ }
8
+ if (Predicate.hasProperty(error, "_tag")) {
9
+ const fields = Object.fromEntries(Object.entries(error).filter(([key]) => !["_tag", "message", "name", "stack", "cause"].includes(key)));
10
+ return JSON.stringify(redact(fields));
11
+ }
12
+ return String(error);
13
+ }
3
14
  export function failureOutput(cause) {
4
15
  const error = Cause.squash(cause);
5
16
  const tag = Predicate.hasProperty(error, "_tag") && typeof error._tag === "string" ? error._tag : "Error";
6
- const message = Predicate.hasProperty(error, "message") && typeof error.message === "string" ? error.message : String(error);
7
- return Schema.encodeSync(JobFailure)({ _tag: tag, message });
17
+ return Schema.encodeSync(JobFailure)({ _tag: tag, message: summary(error) });
8
18
  }
9
19
  //# sourceMappingURL=failureOutput.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"failureOutput.js","sourceRoot":"","sources":["../../../src/server/internal/failureOutput.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAClD,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAE5C,MAAM,UAAU,aAAa,CAAC,KAA2B;IACxD,MAAM,KAAK,GAAG,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IAClC,MAAM,GAAG,GAAG,SAAS,CAAC,WAAW,CAAC,KAAK,EAAE,MAAM,CAAC,IAAI,OAAO,KAAK,CAAC,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC;IAC1G,MAAM,OAAO,GAAG,SAAS,CAAC,WAAW,CAAC,KAAK,EAAE,SAAS,CAAC,IAAI,OAAO,KAAK,CAAC,OAAO,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IAC7H,OAAO,MAAM,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC,EAAE,IAAI,EAAE,GAAG,EAAE,OAAO,EAAE,CAAC,CAAC;AAC9D,CAAC"}
1
+ {"version":3,"file":"failureOutput.js","sourceRoot":"","sources":["../../../src/server/internal/failureOutput.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAClD,OAAO,EAAE,MAAM,EAAE,MAAM,6BAA6B,CAAC;AACrD,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAE5C,SAAS,OAAO,CAAC,KAAc;IAC9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 export declare const validateQueueNames: (jobs: readonly JobRegistration[], declared: readonly string[] | undefined) => Effect.Effect<undefined, PgBossQueueNamesError, never>;
5
+ //# sourceMappingURL=validateQueueNames.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validateQueueNames.d.ts","sourceRoot":"","sources":["../../../src/server/internal/validateQueueNames.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACtD,OAAO,EAAE,qBAAqB,EAAE,MAAM,WAAW,CAAC;AAGlD,eAAO,MAAM,kBAAkB,uIAW7B,CAAC"}
@@ -0,0 +1,16 @@
1
+ import { Effect } from "effect";
2
+ import { PgBossQueueNamesError } from "#error.ts";
3
+ import { registrationName } from "./register.js";
4
+ export const validateQueueNames = Effect.fnUntraced(function* (jobs, declared) {
5
+ if (declared === undefined) {
6
+ return;
7
+ }
8
+ const registered = new Set(jobs.map(registrationName));
9
+ const expected = new Set(declared);
10
+ const missing = [...expected].filter((name) => !registered.has(name));
11
+ const unexpected = [...registered].filter((name) => !expected.has(name));
12
+ if (missing.length > 0 || unexpected.length > 0) {
13
+ return yield* Effect.fail(new PgBossQueueNamesError({ missing, unexpected }));
14
+ }
15
+ });
16
+ //# sourceMappingURL=validateQueueNames.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validateQueueNames.js","sourceRoot":"","sources":["../../../src/server/internal/validateQueueNames.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,OAAO,EAAE,qBAAqB,EAAE,MAAM,WAAW,CAAC;AAClD,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAEjD,MAAM,CAAC,MAAM,kBAAkB,GAAG,MAAM,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE,IAAgC,EAAE,QAAuC;IACvI,IAAI,QAAQ,KAAK,SAAS,EAAE,CAAC;QAC5B,OAAO;IACR,CAAC;IACD,MAAM,UAAU,GAAG,IAAI,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,gBAAgB,CAAC,CAAC,CAAC;IACvD,MAAM,QAAQ,GAAG,IAAI,GAAG,CAAC,QAAQ,CAAC,CAAC;IACnC,MAAM,OAAO,GAAG,CAAC,GAAG,QAAQ,CAAC,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC;IACtE,MAAM,UAAU,GAAG,CAAC,GAAG,UAAU,CAAC,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC;IACzE,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,IAAI,UAAU,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACjD,OAAO,KAAK,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,qBAAqB,CAAC,EAAE,OAAO,EAAE,UAAU,EAAE,CAAC,CAAC,CAAC;IAC/E,CAAC;AACF,CAAC,CAAC,CAAC"}
@@ -2,7 +2,7 @@ import { Context, Effect, Layer, type Option, Redacted, type Schema } from "effe
2
2
  import type { ConstructorOptions, JobWithMetadata, SendOptions, StopOptions } from "pg-boss";
3
3
  import type { PgBossClientFactory } from "#client.ts";
4
4
  import type { JobPayloadSchema, JobRegistration, QueueDefinition, RegistrationRequirements } from "#definition.ts";
5
- import type { PgBossClientOptionsError, PgBossError, PgBossPayloadError, PgBossQueueOptionsError } from "#error.ts";
5
+ import type { PgBossClientOptionsError, PgBossError, PgBossPayloadError, PgBossQueueNamesError, PgBossQueueOptionsError } from "#error.ts";
6
6
  import type { DeadLetteredJob, JobPage, JobPageOptions, JobsHealth, ListedJob, QueueCounts } from "#health.ts";
7
7
  import { PgBoss } from "#PgBoss.ts";
8
8
  export interface PgBossService {
@@ -37,7 +37,7 @@ export interface PgBossLayerOptions<TRegistrations extends readonly JobRegistrat
37
37
  readonly onError?: (error: Error) => Effect.Effect<unknown, never, TErrorRequirements>;
38
38
  }
39
39
  export interface PgBossDefinition<TIdentifier extends string = string> extends Context.Service<TIdentifier, PgBossService> {
40
- readonly layer: <const TRegistrations extends readonly JobRegistration[], TErrorRequirements = never>(options: PgBossLayerOptions<TRegistrations, TErrorRequirements>) => Layer.Layer<TIdentifier, PgBossError | PgBossQueueOptionsError, PgBoss | Exclude<RegistrationRequirements<TRegistrations>, TIdentifier> | TErrorRequirements>;
40
+ readonly layer: <const TRegistrations extends readonly JobRegistration[], TErrorRequirements = never>(options: PgBossLayerOptions<TRegistrations, TErrorRequirements>) => Layer.Layer<TIdentifier, PgBossError | PgBossQueueNamesError | PgBossQueueOptionsError, PgBoss | Exclude<RegistrationRequirements<TRegistrations>, TIdentifier> | TErrorRequirements>;
41
41
  }
42
- export declare function makePgBoss<const TIdentifier extends string>(identifier: TIdentifier): PgBossDefinition<TIdentifier>;
42
+ export declare function makePgBoss<const TIdentifier extends string>(identifier: TIdentifier, queueNames?: readonly string[]): PgBossDefinition<TIdentifier>;
43
43
  //# sourceMappingURL=service.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../../src/server/service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,EAAQ,KAAK,EAAE,KAAK,MAAM,EAAE,QAAQ,EAAE,KAAK,MAAM,EAAS,MAAM,QAAQ,CAAC;AACjG,OAAO,KAAK,EAAE,kBAAkB,EAAE,eAAe,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAG7F,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AACtD,OAAO,KAAK,EAAE,gBAAgB,EAAE,eAAe,EAAE,eAAe,EAAE,wBAAwB,EAAE,MAAM,gBAAgB,CAAC;AACnH,OAAO,KAAK,EAAE,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acquireClient, releaseClient } from "#internal/lifecycle.ts";
6
6
  import { makeService } from "#internal/makeService.ts";
7
7
  import { registrationName } from "#internal/register.ts";
8
8
  import { registerReleasedJobs } from "#internal/registerReleasedJobs.ts";
9
+ import { validateQueueNames } from "#internal/validateQueueNames.ts";
9
10
  import { PgBoss } from "#PgBoss.ts";
10
11
  export function pgBossLayer(options) {
11
12
  const { connectionString, clientFactory, clientCacheKey, stop, ...settings } = options;
@@ -25,11 +26,12 @@ export function pgBossLayer(options) {
25
26
  return { ...acquired, schema: settings.schema, stop };
26
27
  }));
27
28
  }
28
- export function makePgBoss(identifier) {
29
+ export function makePgBoss(identifier, queueNames) {
29
30
  function definition(options, dependencies) {
30
31
  return defineService({
31
32
  id: identifier,
32
33
  initialize: Effect.gen(function* () {
34
+ yield* validateQueueNames(options.jobs, queueNames);
33
35
  const acquired = yield* PgBoss;
34
36
  const execute = Effect.runPromiseWith(dependencies);
35
37
  const workerScope = yield* Scope.make();
@@ -1 +1 @@
1
- {"version":3,"file":"service.js","sourceRoot":"","sources":["../../src/server/service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAe,QAAQ,EAAe,KAAK,EAAE,MAAM,QAAQ,CAAC;AAEjG,OAAO,EAAE,aAAa,EAAE,MAAM,qCAAqC,CAAC;AACpE,OAAO,EAAE,aAAa,EAAE,MAAM,qCAAqC,CAAC;AAKpE,OAAO,EAAE,cAAc,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAC;AAClF,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACtE,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AACvD,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,oBAAoB,EAAE,MAAM,mCAAmC,CAAC;AACzE,OAAO,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AAgCpC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CAAC,KAAK,EAAE,CAAC,CAAC;IACvG,SAAS,KAAK,CACb,OAA+D;QAG/D,OAAO,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC,OAAO,EAAgB,EAAE,CAAC,YAAY,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,YAAY,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC;IAC5H,CAAC;IACD,OAAO,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC;AAC1C,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shivaedev/jobs",
3
- "version": "0.23.2",
3
+ "version": "0.24.0",
4
4
  "description": "Effect-native jobs and lifecycle management for pg-boss",
5
5
  "keywords": [
6
6
  "effect"
@@ -48,15 +48,16 @@
48
48
  "README.md"
49
49
  ],
50
50
  "dependencies": {
51
- "@shivaedev/errors": "0.1.2",
51
+ "@shivaedev/errors": "0.1.3",
52
52
  "@shivaedev/service": "0.6.0",
53
53
  "@shivaedev/sql": "0.27.0"
54
54
  },
55
55
  "devDependencies": {
56
- "@shivaedev/quality": "0.48.0",
56
+ "@shivaedev/http": "0.3.1",
57
+ "@shivaedev/quality": "0.48.1",
57
58
  "@shivaedev/test": "0.12.0",
58
59
  "@shivaedev/test-sql": "0.15.0",
59
- "@shivaedev/test-story": "0.26.2",
60
+ "@shivaedev/test-story": "0.27.0",
60
61
  "@types/node": "24.19.2",
61
62
  "effect": "4.0.6",
62
63
  "pg-boss": "12.38.0",
@@ -43,6 +43,15 @@ export class PgBossQueueOptionsError extends Data.TaggedError("PgBossQueueOption
43
43
  }
44
44
  }
45
45
 
46
+ export class PgBossQueueNamesError extends Data.TaggedError("PgBossQueueNamesError")<{
47
+ readonly missing: readonly string[];
48
+ readonly unexpected: readonly string[];
49
+ }> {
50
+ override get message(): string {
51
+ return `Queue names differ from their declaration: missing [${this.missing.join(", ")}], unexpected [${this.unexpected.join(", ")}]`;
52
+ }
53
+ }
54
+
46
55
  export class PgBossClientOptionsError extends Data.TaggedError("PgBossClientOptionsError")<{
47
56
  readonly key: string | symbol;
48
57
  readonly options: readonly string[];
@@ -1,9 +1,20 @@
1
1
  import { Cause, Predicate, Schema } from "effect";
2
+ import { redact } from "@shivaedev/errors/redact.ts";
2
3
  import { JobFailure } from "#JobFailure.ts";
3
4
 
5
+ function summary(error: unknown): string {
6
+ if (Predicate.hasProperty(error, "message") && typeof error.message === "string" && error.message.trim() !== "") {
7
+ return error.message;
8
+ }
9
+ if (Predicate.hasProperty(error, "_tag")) {
10
+ const fields = Object.fromEntries(Object.entries(error).filter(([key]) => !["_tag", "message", "name", "stack", "cause"].includes(key)));
11
+ return JSON.stringify(redact(fields));
12
+ }
13
+ return String(error);
14
+ }
15
+
4
16
  export function failureOutput(cause: Cause.Cause<unknown>): typeof JobFailure.Encoded {
5
17
  const error = Cause.squash(cause);
6
18
  const tag = Predicate.hasProperty(error, "_tag") && typeof error._tag === "string" ? error._tag : "Error";
7
- const message = Predicate.hasProperty(error, "message") && typeof error.message === "string" ? error.message : String(error);
8
- return Schema.encodeSync(JobFailure)({ _tag: tag, message });
19
+ return Schema.encodeSync(JobFailure)({ _tag: tag, message: summary(error) });
9
20
  }
@@ -0,0 +1,17 @@
1
+ import { Effect } from "effect";
2
+ import type { JobRegistration } from "#definition.ts";
3
+ import { PgBossQueueNamesError } from "#error.ts";
4
+ import { registrationName } from "./register.ts";
5
+
6
+ export const validateQueueNames = Effect.fnUntraced(function* (jobs: readonly JobRegistration[], declared: readonly string[] | undefined) {
7
+ if (declared === undefined) {
8
+ return;
9
+ }
10
+ const registered = new Set(jobs.map(registrationName));
11
+ const expected = new Set(declared);
12
+ const missing = [...expected].filter((name) => !registered.has(name));
13
+ const unexpected = [...registered].filter((name) => !expected.has(name));
14
+ if (missing.length > 0 || unexpected.length > 0) {
15
+ return yield* Effect.fail(new PgBossQueueNamesError({ missing, unexpected }));
16
+ }
17
+ });
@@ -4,13 +4,14 @@ import { defineService } from "@shivaedev/service/defineService.ts";
4
4
  import { genericMethod } from "@shivaedev/service/genericMethod.ts";
5
5
  import type { PgBossClientFactory } from "#client.ts";
6
6
  import type { JobPayloadSchema, JobRegistration, QueueDefinition, RegistrationRequirements } from "#definition.ts";
7
- import type { PgBossClientOptionsError, PgBossError, PgBossPayloadError, PgBossQueueOptionsError } from "#error.ts";
7
+ import type { PgBossClientOptionsError, PgBossError, PgBossPayloadError, PgBossQueueNamesError, PgBossQueueOptionsError } from "#error.ts";
8
8
  import type { DeadLetteredJob, JobPage, JobPageOptions, JobsHealth, ListedJob, QueueCounts } from "#health.ts";
9
9
  import { logClientError, subscribeClientErrors } from "#internal/clientErrors.ts";
10
10
  import { acquireClient, releaseClient } from "#internal/lifecycle.ts";
11
11
  import { makeService } from "#internal/makeService.ts";
12
12
  import { registrationName } from "#internal/register.ts";
13
13
  import { registerReleasedJobs } from "#internal/registerReleasedJobs.ts";
14
+ import { validateQueueNames } from "#internal/validateQueueNames.ts";
14
15
  import { PgBoss } from "#PgBoss.ts";
15
16
 
16
17
  export interface PgBossService {
@@ -81,16 +82,17 @@ export interface PgBossDefinition<TIdentifier extends string = string> extends C
81
82
  options: PgBossLayerOptions<TRegistrations, TErrorRequirements>,
82
83
  ) => Layer.Layer<
83
84
  TIdentifier,
84
- PgBossError | PgBossQueueOptionsError,
85
+ PgBossError | PgBossQueueNamesError | PgBossQueueOptionsError,
85
86
  PgBoss | Exclude<RegistrationRequirements<TRegistrations>, TIdentifier> | TErrorRequirements
86
87
  >;
87
88
  }
88
89
 
89
- export function makePgBoss<const TIdentifier extends string>(identifier: TIdentifier): PgBossDefinition<TIdentifier> {
90
+ export function makePgBoss<const TIdentifier extends string>(identifier: TIdentifier, queueNames?: readonly string[]): PgBossDefinition<TIdentifier> {
90
91
  function definition<R>(options: PgBossLayerOptions<readonly JobRegistration[], R>, dependencies: Context.Context<R>) {
91
92
  return defineService({
92
93
  id: identifier,
93
94
  initialize: Effect.gen(function* () {
95
+ yield* validateQueueNames(options.jobs, queueNames);
94
96
  const acquired = yield* PgBoss;
95
97
  const execute = Effect.runPromiseWith(dependencies);
96
98
  const workerScope = yield* Scope.make();