@shivaedev/effect-pg-boss 0.3.0 → 0.5.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.
Files changed (69) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/README.md +202 -82
  3. package/dist/server/client.d.ts.map +1 -0
  4. package/dist/server/client.js.map +1 -0
  5. package/dist/{definition.d.ts → server/definition.d.ts} +1 -1
  6. package/dist/server/definition.d.ts.map +1 -0
  7. package/dist/server/definition.js.map +1 -0
  8. package/dist/server/error.d.ts.map +1 -0
  9. package/dist/server/error.js.map +1 -0
  10. package/dist/server/health.d.ts.map +1 -0
  11. package/dist/server/health.js.map +1 -0
  12. package/dist/server/internal/health.d.ts.map +1 -0
  13. package/dist/server/internal/health.js.map +1 -0
  14. package/dist/server/internal/lifecycle.d.ts.map +1 -0
  15. package/dist/{internal → server/internal}/lifecycle.js +10 -8
  16. package/dist/server/internal/lifecycle.js.map +1 -0
  17. package/dist/server/internal/register.d.ts.map +1 -0
  18. package/dist/{internal → server/internal}/register.js +40 -22
  19. package/dist/server/internal/register.js.map +1 -0
  20. package/dist/server/internal/service.d.ts.map +1 -0
  21. package/dist/server/internal/service.js.map +1 -0
  22. package/dist/server/service.d.ts +22 -0
  23. package/dist/server/service.d.ts.map +1 -0
  24. package/dist/{service.js → server/service.js} +3 -1
  25. package/dist/server/service.js.map +1 -0
  26. package/docs/north-star.md +48 -0
  27. package/docs/roadmap.md +26 -0
  28. package/package.json +21 -17
  29. package/src/{definition.ts → server/definition.ts} +1 -1
  30. package/src/{internal → server/internal}/lifecycle.ts +12 -9
  31. package/src/{internal → server/internal}/register.ts +44 -21
  32. package/src/{service.ts → server/service.ts} +20 -22
  33. package/dist/client.d.ts.map +0 -1
  34. package/dist/client.js.map +0 -1
  35. package/dist/definition.d.ts.map +0 -1
  36. package/dist/definition.js.map +0 -1
  37. package/dist/error.d.ts.map +0 -1
  38. package/dist/error.js.map +0 -1
  39. package/dist/health.d.ts.map +0 -1
  40. package/dist/health.js.map +0 -1
  41. package/dist/internal/health.d.ts.map +0 -1
  42. package/dist/internal/health.js.map +0 -1
  43. package/dist/internal/lifecycle.d.ts.map +0 -1
  44. package/dist/internal/lifecycle.js.map +0 -1
  45. package/dist/internal/register.d.ts.map +0 -1
  46. package/dist/internal/register.js.map +0 -1
  47. package/dist/internal/service.d.ts.map +0 -1
  48. package/dist/internal/service.js.map +0 -1
  49. package/dist/service.d.ts +0 -26
  50. package/dist/service.d.ts.map +0 -1
  51. package/dist/service.js.map +0 -1
  52. /package/dist/{client.d.ts → server/client.d.ts} +0 -0
  53. /package/dist/{client.js → server/client.js} +0 -0
  54. /package/dist/{definition.js → server/definition.js} +0 -0
  55. /package/dist/{error.d.ts → server/error.d.ts} +0 -0
  56. /package/dist/{error.js → server/error.js} +0 -0
  57. /package/dist/{health.d.ts → server/health.d.ts} +0 -0
  58. /package/dist/{health.js → server/health.js} +0 -0
  59. /package/dist/{internal → server/internal}/health.d.ts +0 -0
  60. /package/dist/{internal → server/internal}/health.js +0 -0
  61. /package/dist/{internal → server/internal}/lifecycle.d.ts +0 -0
  62. /package/dist/{internal → server/internal}/register.d.ts +0 -0
  63. /package/dist/{internal → server/internal}/service.d.ts +0 -0
  64. /package/dist/{internal → server/internal}/service.js +0 -0
  65. /package/src/{client.ts → server/client.ts} +0 -0
  66. /package/src/{error.ts → server/error.ts} +0 -0
  67. /package/src/{health.ts → server/health.ts} +0 -0
  68. /package/src/{internal → server/internal}/health.ts +0 -0
  69. /package/src/{internal → server/internal}/service.ts +0 -0
package/CHANGELOG.md CHANGED
@@ -1,5 +1,26 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.5.0 - 2026-10-13
4
+
5
+ ### Added
6
+
7
+ - `Jobs.layer({ jobs: [Queue] })` registers a queue definition for producers without starting a worker. Its queue appears in health results and uses the same retry and dead-letter settings as a worker registration.
8
+
9
+ ### Breaking
10
+
11
+ - Requires stable Effect 4.0.4 in place of 4.0.0-rc.112. Effect 4.0.4 moves the former `effect/unstable/*` modules to `effect/*` and renames constructors such as `Config.string` to `Config.String`.
12
+
13
+ ## 0.4.0 - 2026-10-12
14
+
15
+ ### Changed
16
+
17
+ - Explain the jobs boundary in a package north star, agent guidance, usage guide and roadmap, and publish the guide and `docs/` with the package.
18
+ - Build package JavaScript, declarations and source maps with TypeScript 7.
19
+
20
+ ### Fixed
21
+
22
+ - Preserve the literal identifier of each `makePgBoss(identifier)` in its service and Layer types, so a Layer for another jobs definition leaves the required service unprovided at compile time. This is breaking only for code that names the shared `PgBossIdentifier` type; use the definition's literal identifier instead.
23
+
3
24
  ## 0.3.0 - 2026-10-04
4
25
 
5
26
  ### Changed
package/README.md CHANGED
@@ -1,119 +1,239 @@
1
- # `@shivaedev/effect-pg-boss`
1
+ # @shivaedev/effect-pg-boss
2
2
 
3
- Effect-native queues, workers, schedules, and lifecycle management for
4
- pg-boss.
3
+ Run PostgreSQL jobs through the same Effect services as the rest of your application. A queue has one payload Schema for enqueueing and handling, and an Effect Layer owns the pg-boss client, workers and schedules.
5
4
 
6
- This package currently targets exact early-access versions of Effect v4 and
7
- pg-boss. It is built for ShivaeDev applications and may change without a
8
- deprecation period.
5
+ ## Why you want this
9
6
 
10
- ## Install
7
+ A background worker lives outside the request that queued it. Without a shared boundary, the producer writes one payload shape, the worker assumes another, and every worker rebuilds its dependencies and shutdown plumbing. This package puts those decisions in one place:
11
8
 
12
- ```sh
13
- pnpm add @shivaedev/effect-pg-boss effect pg-boss
9
+ ```ts
10
+ import { defineQueue } from "@shivaedev/effect-pg-boss/definition.ts";
11
+ import { Effect, Schema } from "effect";
12
+ import { Mail } from "./services.ts";
13
+
14
+ const SendEmail = defineQueue({
15
+ name: "send-email",
16
+ schema: Schema.Struct({ userId: Schema.NumberFromString }),
17
+ });
18
+
19
+ const emailWorker = SendEmail.handle(({ userId }) =>
20
+ Effect.flatMap(Mail, (mail) => mail.send(userId)),
21
+ );
14
22
  ```
15
23
 
16
- ## Define jobs
24
+ `Mail` is the application's Effect service, defined in the guide below. The worker receives a number even though the durable payload stores a string. The same Schema encodes the producer's payload and decodes the worker's input; malformed stored data fails before the handler runs. Provide the worker's services when the jobs Layer starts, and the handler uses that captured context when pg-boss calls it later.
25
+
26
+ ## Using it
27
+
28
+ ### How to think about it
29
+
30
+ A **queue definition** names a pg-boss queue and the Schema of its payload. Application code uses the Schema's decoded type; pg-boss receives its encoded type. Both must be objects. Defining a queue describes the contract; `queue.handle(handler)` pairs it with the Effect that performs the work.
31
+
32
+ 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.
33
+
34
+ The application creates one jobs service with `makePgBoss(identifier)`. Its Layer starts a client, registers the job list and captures the services those workers need. The Layer's scope owns its client reference and releases it when the scope ends; the final reference closes the client. Callers use the jobs service to enqueue a decoded payload or read queue health.
17
35
 
18
- A queue pairs its durable wire schema with its Effect handler. The handler only
19
- receives decoded data; malformed stored data fails before domain code runs.
36
+ 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.
37
+
38
+ 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.
39
+
40
+ ### Once per application: the jobs service
41
+
42
+ Define the application's jobs service and worker dependencies in `services.ts`:
20
43
 
21
44
  ```ts
22
- import { defineQueue } from "@shivaedev/effect-pg-boss/definition.ts"
23
- import { Effect, Schema } from "effect"
24
-
25
- export const EmailQueue = defineQueue({
26
- name: "email",
27
- schema: Schema.Struct({
28
- userId: Schema.String,
29
- attempt: Schema.NumberFromString,
30
- }),
31
- queue: {
32
- retryLimit: 5,
33
- retryBackoff: true,
34
- },
35
- })
45
+ import { makePgBoss } from "@shivaedev/effect-pg-boss/service.ts";
46
+ import { Context, Effect, Layer } from "effect";
36
47
 
37
- const emailWorker = EmailQueue.handle(({ userId, attempt }) =>
38
- Effect.gen(function* () {
39
- const email = yield* Email
40
- yield* email.send(userId, attempt)
41
- }),
42
- )
48
+ export const Jobs = makePgBoss("@app/Jobs");
49
+
50
+ export class Mail extends Context.Service<Mail, {
51
+ readonly send: (userId: number) => Effect.Effect<void>;
52
+ readonly removeExpired: Effect.Effect<void>;
53
+ }>()("@app/Mail") {}
54
+
55
+ export const MailLive = Layer.succeed(Mail, {
56
+ send: (userId) => Effect.log({ event: "send_email", userId }),
57
+ removeExpired: Effect.log({ event: "remove_expired_mail" }),
58
+ });
43
59
  ```
44
60
 
45
- Queue payloads are encoded through the same Schema when enqueued, so transforms
46
- such as `NumberFromString` have one contract in both directions.
61
+ `Jobs` is the service that callers yield. `Mail` is a separate domain service that workers use. The example implementation logs calls so the wiring is complete; an application supplies its own implementation of those methods. The jobs package does not need a provider-specific interface.
62
+
63
+ ### Once per feature: the payload and handler
47
64
 
48
- Schedules are queues with a cron trigger and an Effect that takes no payload:
65
+ Define the feature's registrations in `jobs.ts`:
49
66
 
50
67
  ```ts
51
- import { defineSchedule } from "@shivaedev/effect-pg-boss/definition.ts"
68
+ import { defineQueue, defineSchedule } from "@shivaedev/effect-pg-boss/definition.ts";
69
+ import { Effect, Schema } from "effect";
70
+ import { Mail } from "./services.ts";
52
71
 
53
- const Cleanup = defineSchedule({
54
- name: "cleanup",
55
- cron: "17 3 * * *",
56
- })
72
+ export const SendEmail = defineQueue({
73
+ name: "send-email",
74
+ schema: Schema.Struct({ userId: Schema.NumberFromString }),
75
+ queue: { retryLimit: 5 },
76
+ });
57
77
 
58
- const cleanupWorker = Cleanup.run(
78
+ export const emailWorker = SendEmail.handle(({ userId }, job) =>
59
79
  Effect.gen(function* () {
60
- const sessions = yield* Sessions
61
- yield* sessions.removeExpired()
80
+ const mail = yield* Mail;
81
+ yield* mail.send(userId);
82
+ yield* Effect.log({ jobId: job.id });
62
83
  }),
63
- )
84
+ );
85
+
86
+ export const Cleanup = defineSchedule({
87
+ name: "cleanup-mail",
88
+ cron: "17 3 * * *",
89
+ });
90
+
91
+ export const cleanupWorker = Cleanup.run(
92
+ Effect.flatMap(Mail, (mail) => mail.removeExpired),
93
+ );
64
94
  ```
65
95
 
66
- Schedules default to UTC. Every job defaults to three retries with exponential
67
- backoff and a `<name>-dlq` dead-letter queue. Ordinary pg-boss queue, worker,
68
- and schedule options can override those defaults.
96
+ The queue takes `{ userId: number }` in application code and stores `{ userId: string }`. Its handler receives the decoded number and a job context, including the job's `id`. Keep the queue definition available to producers; the runtime registers the worker created by `handle`.
97
+
98
+ The schedule runs a payload-free Effect. This schedule registers its cron expression with `tz: "UTC"`. The package creates a `<name>-dlq` dead-letter queue for both kinds of worker and supplies `retryLimit: 3` and `retryBackoff: true` by default. The email queue above overrides the retry limit to five. These are pg-boss registration settings; pg-boss runs the retry and scheduling engine.
69
99
 
70
- ## Provide the service
100
+ The Layer requires the workers' Effect services. Leaving `Mail` unprovided leaves that requirement in the resulting Effect's type. A primitive Schema such as `Schema.String` is rejected as a queue definition because the durable contract must be an object.
71
101
 
72
- Create one service identifier, then provide its scoped Layer. The Layer starts
73
- pg-boss, registers workers and schedules, captures their Effect services, and
74
- stops pg-boss when its scope closes.
102
+ ### Once per runtime: provide the workers
103
+
104
+ Build the jobs Layer in `runtime.ts`:
75
105
 
76
106
  ```ts
77
- import { makePgBoss } from "@shivaedev/effect-pg-boss/service.ts"
107
+ import { Layer } from "effect";
108
+ import { cleanupWorker, emailWorker } from "./jobs.ts";
109
+ import { Jobs, MailLive } from "./services.ts";
110
+
111
+ export const jobsLayer = (databaseUrl: string) =>
112
+ Jobs.layer({
113
+ connectionString: databaseUrl,
114
+ schema: "app_jobs",
115
+ jobs: [emailWorker, cleanupWorker],
116
+ }).pipe(Layer.provide(MailLive));
117
+ ```
78
118
 
79
- export const Jobs = makePgBoss("@app/Jobs")
119
+ The constructor options belong to pg-boss. `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` and releases its acquired client reference. A shared client stays running while another scope still owns a reference.
80
120
 
81
- export const JobsLive = Jobs.layer({
82
- connectionString: databaseUrl,
83
- schema: "app_jobs",
84
- jobs: [emailWorker, cleanupWorker],
85
- clientCacheKey: isDevelopment ? "app-jobs" : undefined,
86
- })
121
+ 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.
122
+
123
+ ```ts
124
+ import { Effect } from "effect";
125
+ import { jobsLayer } from "./runtime.ts";
126
+ import { Jobs } from "./services.ts";
127
+
128
+ const inspectJobs = (databaseUrl: string) =>
129
+ Effect.scoped(
130
+ Effect.gen(function* () {
131
+ const jobs = yield* Jobs;
132
+ return yield* jobs.health;
133
+ }).pipe(Effect.provide(jobsLayer(databaseUrl))),
134
+ );
87
135
  ```
88
136
 
89
- `clientCacheKey` reuses and reference-counts one started client across Layer
90
- builds that share the key, such as development module reloads. The package does
91
- not inspect `NODE_ENV`; without a key every build starts its own client.
92
- Applications decide which key and registrations are passed to the Layer, so
93
- environment rules such as development caching and production-only schedules
94
- remain application policy.
137
+ This Effect starts the jobs Layer, reads health and closes the scope. The client stops when that scope closes.
95
138
 
96
- An `onError` Effect can route pg-boss background errors through application
97
- logging or telemetry. Without one, errors use Effect logging.
139
+ ### In application code: enqueue
98
140
 
99
- ## Enqueue and inspect health
141
+ ```ts
142
+ import { Effect } from "effect";
143
+ import { SendEmail } from "./jobs.ts";
144
+ import { Jobs } from "./services.ts";
145
+
146
+ export const enqueueEmail = (userId: number) =>
147
+ Effect.gen(function* () {
148
+ const jobs = yield* Jobs;
149
+ return yield* jobs.enqueue(SendEmail, { userId });
150
+ });
151
+ ```
152
+
153
+ Provide `Jobs` through the application's existing runtime. `enqueue` takes the decoded payload, so passing a string `userId` is a type error. It encodes the number to a string before calling pg-boss. The result type is `Option.Option<string>`: a job identifier becomes `Some`, and a `null` send result becomes `None`.
154
+
155
+ `PgBossPayloadError` names a payload boundary failure; malformed durable input is rejected before the worker's domain code runs. The PostgreSQL test also checks that invalid data sent directly to pg-boss reaches the dead-letter queue without reaching the handler.
156
+
157
+ ### Read health
100
158
 
101
159
  ```ts
102
- const program = Effect.gen(function* () {
103
- const jobs = yield* Jobs
160
+ import { Effect } from "effect";
161
+ import { Jobs } from "./services.ts";
162
+
163
+ export const readJobCounts = Effect.gen(function* () {
164
+ const jobs = yield* Jobs;
165
+ const health = yield* jobs.health;
166
+ return {
167
+ active: health.activeTotal,
168
+ deadLettered: health.deadLetteredTotal,
169
+ failed: health.failedTotal,
170
+ queued: health.queuedTotal,
171
+ ready: health.readyTotal,
172
+ };
173
+ });
174
+ ```
175
+
176
+ `health` exposes pg-boss queue counts as data. Its total fields include the registered queue's active, failed, queued and ready counts, plus the dead-letter queue's queued count. Decide in the application which values affect an HTTP health response or an alert.
104
177
 
105
- const id = yield* jobs.enqueue(EmailQueue, {
106
- userId: "user-1",
107
- attempt: 1,
108
- })
178
+ ### Share a client between Layer builds
109
179
 
110
- const health = yield* jobs.health
111
- return { id, health }
112
- })
180
+ ```ts
181
+ import { Layer } from "effect";
182
+ import { cleanupWorker, emailWorker } from "./jobs.ts";
183
+ import { Jobs, MailLive } from "./services.ts";
184
+
185
+ const sharedJobsLayer = (databaseUrl: string) =>
186
+ Jobs.layer({
187
+ connectionString: databaseUrl,
188
+ schema: "app_jobs",
189
+ clientCacheKey: "app-jobs",
190
+ jobs: [emailWorker, cleanupWorker],
191
+ }).pipe(Layer.provide(MailLive));
113
192
  ```
114
193
 
115
- `enqueue` returns `Option<string>` because pg-boss can decline a job under a
116
- queue policy. Its payload stays fully typed from the queue Schema. `health`
117
- reports queued, ready, active, failed, and dead-letter counts for every
118
- registered job without choosing an HTTP response shape or application health
119
- policy.
194
+ Overlapping Layer builds with the same `clientCacheKey` share one started client. The later build replaces the registered worker, and the final scope release stops the shared client. A later build after that release starts a new client. Without a key, each build creates its own client. The application chooses whether to pass a key.
195
+
196
+ ### Separate producers and workers
197
+
198
+ Pass a queue definition directly in `Jobs.layer({ jobs: [SendEmail] })` to create its queue and dead-letter queue without starting a consumer. A separate worker process registers `SendEmail.handle(...)` against the same database. Producer queues use the same retry options and appear in `health`; only worker registrations capture handler services.
199
+
200
+ ### API
201
+
202
+ Import the module that defines the name; the package has no root entry.
203
+
204
+ | Module | Public names |
205
+ | --- | --- |
206
+ | `@shivaedev/effect-pg-boss/definition.ts` | `defineQueue`, `defineSchedule`, `jobContext`; `DefineQueueOptions`, `DefineScheduleOptions`, `JobContext`, `JobPayloadSchema`, `JobRegistration`, `QueueDefinition`, `QueueWorker`, `RegistrationRequirements`, `ScheduleDefinition`, `ScheduledWorker` |
207
+ | `@shivaedev/effect-pg-boss/service.ts` | `makePgBoss`; `PgBossDefinition`, `PgBossLayerOptions`, `PgBossService` |
208
+ | `@shivaedev/effect-pg-boss/health.ts` | `deadLetterQueueName`; `JobsHealth`, `QueueHealth` |
209
+ | `@shivaedev/effect-pg-boss/error.ts` | `PgBossError`, `PgBossPayloadError`, `toPgBossError`; `PgBossOperation` |
210
+ | `@shivaedev/effect-pg-boss/client.ts` | `defaultClientFactory`; `PgBossClient`, `PgBossClientFactory` |
211
+
212
+ The definition options keep the pg-boss names: `queue` uses `QueueOptions` except `deadLetter`, `worker` uses `WorkOptions`, and a schedule's `schedule` uses `ScheduleOptions`. A queue also requires `name` and `schema`; a schedule requires `name` and `cron`.
213
+
214
+ The application's service has two operations:
215
+
216
+ - `enqueue(queue, payload, options?)`: an Effect returning `Option.Option<string>`, with `PgBossError | PgBossPayloadError` in its error type. Its options use pg-boss `SendOptions`.
217
+ - `health`: an Effect returning `JobsHealth`, with `PgBossError` in its error type.
218
+
219
+ `Jobs.layer(options)` accepts pg-boss `ConstructorOptions` plus `jobs`, optional `clientCacheKey`, optional `clientFactory`, optional `onError` and optional `stop`. The factory type accepts constructor options and returns `PgBossClient`; `onError` has the type `(error: Error) => Effect.Effect<unknown, never, R>`; `stop` uses pg-boss `StopOptions`.
220
+
221
+ `onError` handles pg-boss client `error` events using the services captured by the Layer. The Layer's requirement type includes the workers' services, the workers' payload Schemas' `DecodingServices` and the callback's services. `enqueue` includes the payload Schema's `EncodingServices` in its requirement type.
222
+
223
+ `JobContext` has `id`, `name`, `signal`, `expireInSeconds` and `heartbeatSeconds`. `QueueHealth` has `name`, `activeCount`, `deadLetteredCount`, `failedCount`, `queuedCount` and `readyCount`. `JobsHealth` has `jobs` and the corresponding `activeTotal`, `deadLetteredTotal`, `failedTotal`, `queuedTotal` and `readyTotal` fields.
224
+
225
+ `PgBossError` has `operation`, optional `queue` and a `Redacted` `original`. `PgBossPayloadError` has `direction`, `queue` and a `Redacted` `original`. Those fields distinguish the pg-boss operation from the payload boundary.
226
+
227
+ ### Install, setup and limits
228
+
229
+ ```sh
230
+ pnpm add @shivaedev/effect-pg-boss effect@4.0.4 pg-boss@12.23.1
231
+ ```
232
+
233
+ The package requires Node.js 24 or later and PostgreSQL. `effect` and `pg-boss` are peers; use versions that satisfy the package's published peer ranges.
234
+
235
+ Provide the database connection and job registrations at the application runtime boundary. Application services own the domain work and provider calls; pg-boss owns queue execution. Treat enqueueing and an application database transaction as separate operations, and choose any required transaction or outbox policy in the application.
236
+
237
+ For package development, the real PostgreSQL test uses `PLATFORM_EFFECT_PG_BOSS_TEST_DATABASE_URL` and skips when the variable is absent. A skipped test does not establish durable queue behavior. Fake-client tests cover registration and lifecycle calls; they do not establish real cron execution, retry timing or deployment behavior. The package is built for ShivaeDev applications and may change without a deprecation period.
238
+
239
+ The [north star](./docs/north-star.md) explains the design trade-offs; the [roadmap](./docs/roadmap.md) owns package work and open choices.
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/server/client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,GAAG,EAAE,KAAK,EAAE,WAAW,EAAE,eAAe,EAAE,WAAW,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAGnI,MAA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EAAE,OAAO,EAAE,CAAC,IAAI,EAAE,SAAS,GAAG,CAAC,OAAO,CAAC,EAAE,KAAK,OAAO,CAAC,OAAO,CAAC,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;CACrI;AAED,MAAM,MAAM,mBAAmB,GAAG,CAAC,OAAO,EAAE,kBAAkB,KAAK,YAAY,CAAC;AAEhF,eAAO,MAAM,oBAAoB,EAAE,mBAAsD,CAAC"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.js","sourceRoot":"","sources":["../../src/server/client.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAiBjC,MAAM,CAAC,MAAM,oBAAoB,GAAwB,CAAC,OAAO,EAAE,EAAE,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,CAAC"}
@@ -25,7 +25,7 @@ export interface QueueWorker<Payload extends JobPayloadSchema = JobPayloadSchema
25
25
  readonly queue: QueueDefinition<string, Payload>;
26
26
  }
27
27
  export interface JobRegistration {
28
- readonly _tag: "QueueWorker" | "ScheduledWorker";
28
+ readonly _tag: "QueueDefinition" | "QueueWorker" | "ScheduledWorker";
29
29
  }
30
30
  export interface ScheduleDefinition<Name extends string = string> {
31
31
  readonly _tag: "ScheduleDefinition";
@@ -0,0 +1 @@
1
+ {"version":3,"file":"definition.d.ts","sourceRoot":"","sources":["../../src/server/definition.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAC7C,OAAO,KAAK,EAAE,GAAG,EAAE,YAAY,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAE/E,MAAM,WAAW,gBAAiB,SAAQ,MAAM,CAAC,GAAG;IACnD,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,UAAU;IAC1B,QAAQ,CAAC,eAAe,EA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AAE,CAAC,CAAC;IAC7D,eAAe,EAAE,GAAG,CAAC,eAAe;IACpC,gBAAgB,EAAE,GAAG,CAAC,gBAAgB;IACtC,EAAE,EAAE,GAAG,CAAC,EAAE;IACV,IAAI,EAAE,GAAG,CAAC,IAAI;IACd,MAAM,EAAE,GAAG,CAAC,MAAM;CAClB,CAAC,CAAC"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"error.d.ts","sourceRoot":"","sources":["../../src/server/error.ts"],"names":[],"mappings":"AAAA,OAAO,EAAQ,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAExC,MAAM,MAAM,eAAe,GAAG,SAAS,GAAG,QAAQ,GAAG,UAAU,GAAG,OAAO,GAAG,MAAM,CAAC;;;;AAEnF,qBAAa,WAAY,SAAQ,iBAAgC;IAChE,QAAQ,CAAC,SAAS,EAAE,eAAe,CAAC;IACpC,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACpC,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;CAC9C,CAAC;CAAG;;;;AAEL,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,eAAO,MAAM,aAAa,cAAe,eAAe,SAAS,OAAO,UAAU,MAAM,KAAG,WAKxF,CAAC"}
@@ -0,0 +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;AAIxC,MAAM,OAAO,WAAY,SAAQ,IAAI,CAAC,WAAW,CAAC,aAAa,CAI7D;CAAG;AAEL,MAAM,OAAO,kBAAmB,SAAQ,IAAI,CAAC,WAAW,CAAC,oBAAoB,CAI3E;CAAG;AAEL,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,SAA0B,EAAE,KAAc,EAAE,KAAc,EAAe,EAAE,CACxG,IAAI,WAAW,CAAC;IACf,SAAS;IACT,QAAQ,EAAE,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC;IAC9B,KAAK;CACL,CAAC,CAAC"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"health.d.ts","sourceRoot":"","sources":["../../src/server/health.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,WAAW;IAC3B,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,iBAAiB,EAAE,MAAM,CAAC;IACnC,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;CAC5B;AAED,MAAM,WAAW,UAAU;IAC1B,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,iBAAiB,EAAE,MAAM,CAAC;IACnC,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,IAAI,EAAE,SAAS,WAAW,EAAE,CAAC;IACtC,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;CAC5B;AAED,eAAO,MAAM,mBAAmB,cAAe,MAAM,KAAG,MAA4B,CAAC"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"health.js","sourceRoot":"","sources":["../../src/server/health.ts"],"names":[],"mappings":"AAkBA,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,SAAiB,EAAU,EAAE,CAAC,GAAG,SAAS,MAAM,CAAC"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"health.d.ts","sourceRoot":"","sources":["../../../src/server/internal/health.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE/C,OAAO,EAAuB,KAAK,UAAU,EAAoB,MAAM,YAAY,CAAC;AAEpF,eAAO,MAAM,SAAS,WAAY,YAAY,SAAS,SAAS,MAAM,EAAE,KAAG,MAAM,CAAC,MAAM,CAAC,UAAU,EAAE,OAAO,WAAW,EAAE,WAAW,CA4BlI,CAAC"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"health.js","sourceRoot":"","sources":["../../../src/server/internal/health.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,mBAAmB,EAAqC,MAAM,YAAY,CAAC;AAEpF,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,MAAoB,EAAE,KAAwB,EAA8D,EAAE,CACvI,MAAM,CAAC,OAAO,CACb,KAAK,EACL,CAAC,IAAI,EAAE,EAAE,CACR,MAAM,CAAC,UAAU,CAAC;IACjB,KAAK,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,aAAa,CAAC,QAAQ,EAAE,KAAK,EAAE,IAAI,CAAC;IACtD,GAAG,EAAE,KAAK,IAA0B,EAAE;QACrC,MAAM,CAAC,KAAK,EAAE,UAAU,CAAC,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC,QAAQ,CAAC,mBAAmB,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;QACnH,OAAO;YACN,WAAW,EAAE,KAAK,EAAE,WAAW,IAAI,CAAC;YACpC,iBAAiB,EAAE,UAAU,EAAE,WAAW,IAAI,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M,SAAS,CAAC;AAC/D,OAAO,EAAwB,KAAK,YAAY,EAAE,KAAK,mBAAmB,EAAE,MAAM,YAAY,CAAC;AA2B/F,MAAM,WAAW,oBAAoB;IACpC,QAAQ,CAAC,cAAc,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC;IACtD,QAAQ,CAAC,aAAa,CAAC,EAAE,mBAAmB,GAAG,SAAS,CAAC;IACzD,QAAQ,CAAC,WAAW,EAAE,kBAAkB,CAAC;CACzC;AAED,MAAM,WAAW,cAAc;IAC9B,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACpC,QAAQ,CAAC,MAAM,EAAE,YAAY,CAAC;IAC9B,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;CACzB;AAiBD,eAAO,MAAM,aAAa,YAAa,oBAAoB,KAAG,MAAM,CAAC,MAAM,CAAC,cAAc,EAAE,OAAO,WAAW,EAAE,WAAW,CA6CxH,CAAC;AAEJ,eAAO,MAAM,aAAa,aAAc,cAAc,gBAAgB,WAAW,KAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAoB7C,CAAC"}
@@ -5,15 +5,17 @@ const CacheKey = Symbol.for("@shivaedev/effect-pg-boss/client-cache");
5
5
  const sharedCache = Reflect.get(globalThis, CacheKey);
6
6
  const clientCache = sharedCache instanceof Map ? sharedCache : new Map();
7
7
  Reflect.set(globalThis, CacheKey, clientCache);
8
- const isCachedClient = (value) => typeof value === "object"
9
- && value !== null
10
- && Reflect.get(value, "client") instanceof Promise
11
- && typeof Reflect.get(value, "references") === "number";
12
- const cachedClient = (key) => {
8
+ function isCachedClient(value) {
9
+ return (typeof value === "object"
10
+ && value !== null
11
+ && Reflect.get(value, "client") instanceof Promise
12
+ && typeof Reflect.get(value, "references") === "number");
13
+ }
14
+ function cachedClient(key) {
13
15
  const entry = clientCache.get(key);
14
16
  return isCachedClient(entry) ? entry : undefined;
15
- };
16
- const startClient = (options) => {
17
+ }
18
+ function startClient(options) {
17
19
  const client = (options.clientFactory ?? defaultClientFactory)(options.constructor);
18
20
  return client.start().then(() => client, async (error) => {
19
21
  try {
@@ -24,7 +26,7 @@ const startClient = (options) => {
24
26
  }
25
27
  throw error;
26
28
  });
27
- };
29
+ }
28
30
  export const acquireClient = (options) => Effect.tryPromise({
29
31
  catch: (error) => toPgBossError("start", error),
30
32
  try: async () => {
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lifecycle.js","sourceRoot":"","sources":["../../../src/server/internal/lifecycle.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,OAAO,EAAE,oBAAoB,EAA+C,MAAM,YAAY,CAAC;AAC/F,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAO1C,MAAM,QAAQ,GAAG,MAAM,CAAC,GAAG,CAAC,wCAAwC,CAAC,CAAC;AACtE,MAAM,WAAW,GAAY,OAAO,CAAC,GAAG,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC;AAC/D,MAAM,WAAW,GAAkC,WAAW,YAAY,GAAG,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,IAAI,GAAG,EAA4B,CAAC;AAClI,OAAO,CAAC,GAAG,CAAC,UAAU,EAAE,QAAQ,EAAE,WAAW,CAAC,CAAC;AAE/C,SAAS,cAAc,CAAC,KAAc;IACrC,OAAO,CACN,OAAO,KAAK,KAAK,QAAQ;WACtB,KAAK,KAAK,IAAI;WACd,OAAO,CAAC,GAAG,CAAC,KAAK,EAAE,QAAQ,CAAC,YAAY,OAAO;WAC/C,OAAO,OAAO,CAAC,GAAG,CAAC,KAAK,EAAE,YAAY,CAAC,KAAK,QAAQ,CACvD,CAAC;AACH,CAAC;AAED,SAAS,YAAY,CAAC,GAAoB;IACzC,MAAM,KAAK,GAAG,WAAW,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IACnC,OAAO,cAAc,CAAC,KAAK,CAAC,CAAC,CAAC,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AM,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;QACtC,MAAM,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;IACzC,CAAC;CACD,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"register.d.ts","sourceRoot":"","sources":["../../../src/server/internal/register.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,OAAO,EAAE,MAAM,EAAoB,MAAM,QAAQ,CAAC;AAEhE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC/C,OAAO,EAAE,KAAK,eAAe,EAA4E,MAAM,gBAAgB,CAAC;AAwBhI,eAAO,MAAM,gBAAgB,iBAAkB,eAAe,KAAG,MAWhE,CAAC;AA+EF,eAAO,MAAM,iBAAiB,kBAAmB,SAAS,eAAe,EAAE,KAAG,SAAS,MAAM,EAM5F,CAAC;AAEF,eAAO,MAAM,YAAY,GAAI,CAAC,UACrB,YAAY,iBACL,SAAS,eAAe,EAAE,WAChC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,kBACX,OAAO,KACrB,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,OAAO,WAAW,EAAE,WAAW,CAcnD,CAAC"}
@@ -2,14 +2,26 @@ import { Effect, Redacted, Schema } from "effect";
2
2
  import { jobContext } from "#definition.ts";
3
3
  import { PgBossPayloadError, toPgBossError } from "#error.ts";
4
4
  import { deadLetterQueueName } from "#health.ts";
5
- const queueOptions = (options) => ({
6
- retryBackoff: true,
7
- retryLimit: 3,
8
- ...options,
9
- });
10
- const isQueueWorker = (registration) => registration._tag === "QueueWorker";
11
- const isScheduledWorker = (registration) => registration._tag === "ScheduledWorker";
5
+ function queueOptions(options) {
6
+ return {
7
+ retryBackoff: true,
8
+ retryLimit: 3,
9
+ ...options,
10
+ };
11
+ }
12
+ function isQueueWorker(registration) {
13
+ return registration._tag === "QueueWorker";
14
+ }
15
+ function isScheduledWorker(registration) {
16
+ return registration._tag === "ScheduledWorker";
17
+ }
18
+ function isQueueDefinition(registration) {
19
+ return registration._tag === "QueueDefinition";
20
+ }
12
21
  export const registrationName = (registration) => {
22
+ if (isQueueDefinition(registration)) {
23
+ return registration.name;
24
+ }
13
25
  if (isQueueWorker(registration)) {
14
26
  return registration.queue.name;
15
27
  }
@@ -21,29 +33,35 @@ export const registrationName = (registration) => {
21
33
  function workerContext(context) {
22
34
  return context;
23
35
  }
24
- const runQueueWorker = (worker, job, context) => Effect.runPromise(Schema.decodeUnknownEffect(worker.queue.schema)(job.data).pipe(Effect.mapError((error) => new PgBossPayloadError({
25
- direction: "decode",
26
- original: Redacted.make(error),
27
- queue: worker.queue.name,
28
- })), Effect.flatMap((payload) => worker.handler(payload, jobContext(job))), Effect.provide(context)), { signal: job.signal });
29
- const registerQueue = async (client, worker, context, replaceWorker) => {
30
- const name = worker.queue.name;
36
+ function runQueueWorker(worker, job, context) {
37
+ return Effect.runPromise(Schema.decodeUnknownEffect(worker.queue.schema)(job.data).pipe(Effect.mapError((error) => new PgBossPayloadError({
38
+ direction: "decode",
39
+ original: Redacted.make(error),
40
+ queue: worker.queue.name,
41
+ })), Effect.flatMap((payload) => worker.handler(payload, jobContext(job))), Effect.provide(context)), { signal: job.signal });
42
+ }
43
+ async function registerQueue(client, registration, context, replaceWorker) {
44
+ const queue = registration._tag === "QueueWorker" ? registration.queue : registration;
45
+ const name = queue.name;
31
46
  const deadLetter = deadLetterQueueName(name);
32
- if (replaceWorker) {
47
+ if (replaceWorker && registration._tag === "QueueWorker") {
33
48
  await client.offWork(name);
34
49
  }
35
50
  await client.createQueue(deadLetter);
36
51
  await client.createQueue(name, {
37
- ...queueOptions(worker.queue.queueOptions),
52
+ ...queueOptions(queue.queueOptions),
38
53
  deadLetter,
39
54
  });
40
- await client.work(name, worker.queue.workerOptions, async (jobs) => {
55
+ if (registration._tag === "QueueDefinition") {
56
+ return;
57
+ }
58
+ await client.work(name, queue.workerOptions, async (jobs) => {
41
59
  for (const job of jobs) {
42
- await runQueueWorker(worker, job, context);
60
+ await runQueueWorker(registration, job, context);
43
61
  }
44
62
  });
45
- };
46
- const registerSchedule = async (client, worker, context, replaceWorker) => {
63
+ }
64
+ async function registerSchedule(client, worker, context, replaceWorker) {
47
65
  const { schedule } = worker;
48
66
  const deadLetter = deadLetterQueueName(schedule.name);
49
67
  if (replaceWorker) {
@@ -62,7 +80,7 @@ const registerSchedule = async (client, worker, context, replaceWorker) => {
62
80
  }
63
81
  });
64
82
  await client.schedule(schedule.name, schedule.cron, null, schedule.scheduleOptions);
65
- };
83
+ }
66
84
  export const registrationNames = (registrations) => {
67
85
  const names = registrations.map(registrationName);
68
86
  if (new Set(names).size !== names.length) {
@@ -76,7 +94,7 @@ export const registerJobs = (client, registrations, context, replaceWorkers) =>
76
94
  registrationNames(registrations);
77
95
  const provided = workerContext(context);
78
96
  for (const registration of registrations) {
79
- if (isQueueWorker(registration)) {
97
+ if (isQueueWorker(registration) || isQueueDefinition(registration)) {
80
98
  await registerQueue(client, registration, provided, replaceWorkers);
81
99
  }
82
100
  else if (isScheduledWorker(registration)) {
@@ -0,0 +1 @@
1
+ {"version":3,"file":"register.js","sourceRoot":"","sources":["../../../src/server/internal/register.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAGhE,OAAO,EAAwB,UAAU,EAAgE,MAAM,gBAAgB,CAAC;AAChI,OAAO,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC9D,OAAO,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAEjD,SAAS,YAAY,CAAC,OAA0C;IAC/D,OAAO;QACN,YAAY,EAAE,IAAI;QAClB,UAAU,EAAE,CAAC;QACb,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AAC,MAAM,EAAE,CAAC;QAC1C,MAAM,IAAI,SAAS,CAAC,kCAAkC,CAAC,CAAC;IACzD,CAAC;IACD,OAAO,KAAK,CAAC;AACd,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,YAAY,GAAG,CAC3B,MAAoB,EACpB,aAAyC,EACzC,OAA2B,EAC3B,cAAuB,EACgC,EAAE,CACzD,MAAM,CAAC,UAAU,CAAC;IACjB,KAAK,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,aAAa,CAAC,UAAU,EAAE,KAAK,CAAC;IAClD,GAAG,EAAE,KAAK,IAAI,EAAE;QACf,iBAAiB,CAAC,aAAa,CAAC,CAAC;QACjC,MAAM,QAAQ,GAAG,aAAa,CAAC,OAAO,CAAC,CAAC;QACxC,KAAK,MAAM,YAAY,IAAI,aAAa,EAAE,CAAC;YAC1C,IAAI,aAAa,CAAC,YAAY,CAAC,IAAI,iBAAiB,CAAC,YAAY,CAAC,EAAE,CAAC;gBACpE,MAAM,aAAa,CAAC,MAAM,EAAE,YAAY,EAAE,QAAQ,EAAE,cAAc,CAAC,CAAC;YACrE,CAAC;iBAAM,IAAI,iBAAiB,CAAC,YAAY,CAAC,EAAE,CAAC;gBAC5C,MAAM,gBAAgB,CAAC,MAAM,EAAE,YAAY,EAAE,QAAQ,EAAE,cAAc,CAAC,CAAC;YACxE,CAAC;QACF,CAAC;IACF,CAAC;CACD,CAAC,CAAC"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../../../src/server/internal/service.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE/C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAGjD,eAAO,MAAM,WAAW,WAAY,YAAY,SAAS,SAAS,MAAM,EAAE,KAAG,aA4B3E,CAAC"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"service.js","sourceRoot":"","sources":["../../../src/server/internal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CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,OAAO,EAAE,OAAO,CAAC;SACpD,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC,CAAC;IAC3C,CAAC,CAAC,CACF;IACF,MAAM,EAAE,SAAS,CAAC,MAAM,EAAE,KAAK,CAAC;CAChC,CAAC,CAAC"}
@@ -0,0 +1,22 @@
1
+ import { Context, Effect, Layer, type Option, type Schema } from "effect";
2
+ import type { ConstructorOptions, SendOptions, StopOptions } from "pg-boss";
3
+ import type { PgBossClientFactory } from "#client.ts";
4
+ import type { JobPayloadSchema, JobRegistration, QueueDefinition, RegistrationRequirements } from "./definition.ts";
5
+ import type { PgBossError, PgBossPayloadError } from "./error.ts";
6
+ import type { JobsHealth } from "./health.ts";
7
+ export interface PgBossService {
8
+ readonly enqueue: <const TName extends string, const TPayload extends JobPayloadSchema>(queue: QueueDefinition<TName, TPayload>, payload: Schema.Schema.Type<TPayload>, options?: SendOptions) => Effect.Effect<Option.Option<string>, PgBossError | PgBossPayloadError, TPayload["EncodingServices"]>;
9
+ readonly health: Effect.Effect<JobsHealth, PgBossError>;
10
+ }
11
+ export type PgBossLayerOptions<TRegistrations extends readonly JobRegistration[], TErrorRequirements> = ConstructorOptions & {
12
+ readonly clientFactory?: PgBossClientFactory;
13
+ readonly clientCacheKey?: string | symbol | undefined;
14
+ readonly jobs: TRegistrations;
15
+ readonly onError?: (error: Error) => Effect.Effect<unknown, never, TErrorRequirements>;
16
+ readonly stop?: StopOptions;
17
+ };
18
+ export interface PgBossDefinition<TIdentifier extends string = string> extends Context.Service<TIdentifier, PgBossService> {
19
+ readonly layer: <const TRegistrations extends readonly JobRegistration[], TErrorRequirements = never>(options: PgBossLayerOptions<TRegistrations, TErrorRequirements>) => Layer.Layer<TIdentifier, PgBossError, RegistrationRequirements<TRegistrations> | TErrorRequirements>;
20
+ }
21
+ export declare const makePgBoss: <const TIdentifier extends string>(identifier: TIdentifier) => PgBossDefinition<TIdentifier>;
22
+ //# sourceMappingURL=service.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../../src/server/service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,MAAM,EAAE,KAAK,MAAM,EAAE,MAAM,QAAQ,CAAC;AAC1E,OAAO,KAAK,EAAE,kBAAkB,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAC5E,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAItD,OAAO,KAAK,EAAE,gBAAgB,EAAE,eAAe,EAAE,eAAe,EAAE,wBAAwB,EAAE,MAAM,iBAAiB,CAAC;AACpH,OAAO,KAAK,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAClE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAE9C,MAAM,WAAW,aAAa;IAC7B,QAAQ,CAAC,OAAO,EAAE,CAAC,KAAK,CAAC,KAAK,SAAS,MAAM,EAAE,KAAK,CAAC,QAAQ,SAAS,gBAAgB,EACrF,KAAK,EAAE,eAAe,CAAC,KAAK,EAAE,QAAQ,CAAC,EACvC,OAAO,EAAE,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,EACrC,OAAO,CAAC,EAAE,WAAW,KACjB,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,WAAW,GAAG,kBAAkB,EAAE,QAAQ,CAAC,kBAAkB,CAAC,CAAC,CAAC;IAC1G,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,UAAU,EAAE,WAAW,CAAC,CAAC;CACxD;AAED,MAAM,MAAM,kBAAkB,CAAC,cAAc,SAAS,SAAS,eAAe,EAAE,EAAE,kBAAkB,IAAI,kBAAkB,GAAG;I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