@pikku/queue-pg-boss 0.12.8 → 0.12.10

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,3 +1,117 @@
1
+ ## 0.12.10
2
+
3
+ ### Patch Changes
4
+
5
+ - 266e3bc: One door per name: `@pikku/core/ecosystem/*` and the package root are gone
6
+
7
+ `@pikku/core` published every module twice. `ecosystem/http` re-exported
8
+ `./http`, `ecosystem/services` re-exported `./services`, and a name was
9
+ reachable through either — so every addition had to be made in two places, and a
10
+ consumer's import said nothing about what it actually used. The package root was
11
+ the same problem at a larger scale: a single barrel of 206 names that no bundler
12
+ could take apart, and the one specifier that revealed nothing at all.
13
+
14
+ Both are deleted. Every name now lives on the subpath that owns it, and every
15
+ import carries that subpath — `@pikku/core/http`, `@pikku/core/services`,
16
+ `@pikku/core/errors`, `@pikku/core/types`.
17
+
18
+ Deleting the facades meant the raw subpaths had to become a superset of them,
19
+ which they were not: the facade tree had accumulated 25 names with no raw home
20
+ and about 26 more filed under a different area than the module they came from.
21
+ Those names moved to the area that owns them, and three areas were published as
22
+ new entry points rather than left on a root that is going away — `./types` (the
23
+ shared type surface, the largest single destination), `./state` and
24
+ `./classification`.
25
+
26
+ `./classification` is one door onto one subject: what a value is and how it must
27
+ be handled. Its three halves would each have been an entry point — the brands
28
+ and manifest types, the stored-form helpers (`hashToken`, `unsafeAsSealed` and
29
+ friends), and `SecretValue` — split by whether a name happens to be a type or a
30
+ value, which is the same defect as the facades. The duration and versioned-id
31
+ helpers went to `./utils`, which already published, and `PikkuRequest` went to
32
+ `./function`: it is the transport-agnostic request base, not an HTTP one — HTTP
33
+ has `PikkuHTTPAbstractRequest`, and the only thing outside core that extends
34
+ `PikkuRequest` is Azure's timer request.
35
+
36
+ `./types` inherited the root barrel's habit before it inherited its contents, so
37
+ the names with an owner elsewhere were moved off it. The middleware types and the
38
+ five middleware factories — `pikkuMiddleware`, `pikkuMiddlewareFactory`,
39
+ `pikkuChannelMiddleware`, `pikkuChannelMiddlewareFactory` and
40
+ `pikkuAgentMiddleware`, runtime values on a types entry point — are now
41
+ `@pikku/core/middleware`; the function meta types are `@pikku/core/function`;
42
+ `SerializedError` is `@pikku/core/errors`; and the generic TypeScript helpers
43
+ (`MakeRequired`, `PickRequired`, `PickOptional`, `RequireAtLeastOne`,
44
+ `JSONPrimitive`, `JSONValue`) are `@pikku/core/utils`. What is left on `./types`
45
+ is the vocabulary the wirings share, which no single module owns.
46
+
47
+ `pikku` was itself a root barrel — `export * from '@pikku/core'` — and
48
+ now exports only the services it bundles.
49
+
50
+ One module survives at the old specifier, and only for the bootstrap:
51
+ `packages/cli` is generated by the _published_ CLI pinned in its `build.sh`, and
52
+ that CLI still writes a bare `@pikku/core` into the files it generates for the
53
+ CLI itself. `bootstrap-compat/root.ts` carries the eight types it names, a test
54
+ in core fails if that list grows, and it goes when the pin moves to a CLI
55
+ released from this branch. The adapter names the pinned CLI reaches for —
56
+ `pikkuState` and `CreateWireServices` — are rewritten to `@pikku/core/state` and
57
+ `@pikku/core/types` by the same `build.sh` patch pass, so no second shim is
58
+ needed for them.
59
+
60
+ A guard test keeps the root shut: it parses imports and rejects a bare
61
+ `@pikku/core` rather than grepping for it, because several tests hold a user's
62
+ file as a template literal, where `import … from '@pikku/core'` is fixture text
63
+ rather than an import this repo makes.
64
+
65
+ An agent scaffold a project generated under an older CLI is refreshed rather
66
+ than left to fail: `pikku all` already deleted one importing an entry point
67
+ `@pikku/core` no longer publishes, and the `#pikku` hub joins that list.
68
+ Without it a project that scaffolds the agent endpoint but
69
+ declares no agents keeps the old file forever — the generator that would rewrite
70
+ it only runs when agents exist, and the file being present is what stops it
71
+ being regenerated as missing.
72
+
73
+ `pikku new addon` also wrote a tsconfig `paths` map naming only the deleted hub.
74
+ An addon's `imports` map points into `dist`, so `paths` is what resolves
75
+ `#pikku/<leaf>` for the addon's own source build — it now names the two leaf
76
+ patterns, in both the addon and its test harness.
77
+
78
+ - 6eef0a0: Bump every dependency to its latest compatible minor/patch across the monorepo.
79
+ - Updated dependencies [7722ceb]
80
+ - Updated dependencies [375c1ff]
81
+ - Updated dependencies [02a70cd]
82
+ - Updated dependencies [aeef159]
83
+ - Updated dependencies [a281de6]
84
+ - Updated dependencies [266e3bc]
85
+ - Updated dependencies [02a70cd]
86
+ - Updated dependencies [786dae5]
87
+ - Updated dependencies [6eef0a0]
88
+ - Updated dependencies [3561d67]
89
+ - Updated dependencies [a91c433]
90
+ - Updated dependencies [02a70cd]
91
+ - Updated dependencies [9537f74]
92
+ - Updated dependencies [2b57ca8]
93
+ - Updated dependencies [266e3bc]
94
+ - Updated dependencies [9fce0f1]
95
+ - Updated dependencies [83683a0]
96
+ - Updated dependencies [456c88b]
97
+ - Updated dependencies [456c88b]
98
+ - Updated dependencies [c127273]
99
+ - @pikku/core@0.12.85
100
+
101
+ ## 0.12.9
102
+
103
+ ### Patch Changes
104
+
105
+ - 6794681: Publish the ecosystem surface as per-area sub-barrels under `@pikku/core/ecosystem/*`, and point generated code, the CLI, the inspector and the runtime adapters at them.
106
+
107
+ 348 names that only generated code, the toolchain or a runtime adapter ever imports now have a second home on `@pikku/core/ecosystem/<area>` — one sub-barrel per area, matching how core already publishes its entrypoints, so no single barrel grows without bound and a consumer only pulls in the area it uses.
108
+
109
+ This step is additive: every name is still exported from the entrypoint it was published from before, so nothing downstream breaks. Removing them from the app-facing barrels is a later change, and needs a release carrying `./ecosystem/*` first.
110
+
111
+ - Updated dependencies [7406bfe]
112
+ - Updated dependencies [6794681]
113
+ - @pikku/core@0.12.84
114
+
1
115
  ## 0.12.8
2
116
 
3
117
  ### Patch Changes
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2021 - present Yasser Fadl and Pikku contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,29 @@
1
+ # @pikku/queue-pg-boss
2
+
3
+ pg-boss queue, worker and scheduler services for Pikku. Backed by Postgres, so
4
+ it needs no extra infrastructure if you already run one.
5
+
6
+ ## Install
7
+
8
+ ```bash
9
+ npm install @pikku/queue-pg-boss
10
+ ```
11
+
12
+ ## Usage
13
+
14
+ ```typescript
15
+ import PgBoss from 'pg-boss'
16
+ import { PgBossQueueService } from '@pikku/queue-pg-boss'
17
+
18
+ const pgBoss = new PgBoss(connectionString)
19
+ await pgBoss.start()
20
+
21
+ const queue = new PgBossQueueService(pgBoss)
22
+ ```
23
+
24
+ Use `PgBossQueueWorkers` to process jobs and `PgBossSchedulerService` for cron
25
+ wirings. For a Redis-backed alternative see `@pikku/queue-bullmq`.
26
+
27
+ ## Docs
28
+
29
+ https://pikku.dev/docs
package/dist/index.d.ts CHANGED
@@ -8,4 +8,5 @@ export { PgBossServiceFactory } from './pg-boss-service-factory.js';
8
8
  export { PgBossQueueService } from './pg-boss-queue-service.js';
9
9
  export { PgBossQueueWorkers } from './pg-boss-queue-worker.js';
10
10
  export { PgBossSchedulerService } from './pg-boss-scheduler-service.js';
11
- export type { QueueService, PikkuWorkerConfig, PikkuJobConfig, QueueJob, JobOptions, } from '@pikku/core/queue';
11
+ export type { QueueJob, QueueService } from '@pikku/core/queue';
12
+ export type { PikkuWorkerConfig, PikkuJobConfig, JobOptions, } from '@pikku/core/queue';
@@ -1,5 +1,6 @@
1
1
  import type { PgBoss, Request as PgBossRequest } from 'pg-boss';
2
- import type { QueueService, QueueJob, JobOptions } from '@pikku/core/queue';
2
+ import type { QueueJob, QueueService } from '@pikku/core/queue';
3
+ import type { JobOptions } from '@pikku/core/queue';
3
4
  export declare const mapPikkuJobToPgBoss: (options?: JobOptions) => PgBossRequest["options"];
4
5
  /**
5
6
  * pg-boss/PostgreSQL queue service implementation
@@ -21,7 +21,9 @@ export const mapPikkuJobToPgBoss = (options) => {
21
21
  pgBossOptions.retryLimit = options.attempts - 1;
22
22
  }
23
23
  if (options?.backoff !== undefined) {
24
- const type = typeof options.backoff === 'string' ? options.backoff : options.backoff.type;
24
+ const type = typeof options.backoff === 'string'
25
+ ? options.backoff
26
+ : options.backoff.type;
25
27
  const delay = typeof options.backoff === 'object' ? options.backoff.delay : undefined;
26
28
  pgBossOptions.retryBackoff = type === 'exponential';
27
29
  if (delay !== undefined) {
@@ -1,5 +1,6 @@
1
- import { registerQueueWorkers, runQueueJob, QueueJobFailedError, QueueJobDiscardedError, } from '@pikku/core/queue';
2
- import { pikkuState } from '@pikku/core/internal';
1
+ import { runQueueJob } from '@pikku/core/queue';
2
+ import { registerQueueWorkers, QueueJobFailedError, QueueJobDiscardedError, } from '@pikku/core/queue';
3
+ import { pikkuState } from '@pikku/core/state';
3
4
  import { mapPgBossJobToQueueJob } from './utils.js';
4
5
  export const mapPikkuWorkerToPgBoss = (workerConfig) => {
5
6
  // Map the requested parallelism to pg-boss `localConcurrency` (independent
@@ -1,6 +1,7 @@
1
1
  import type { PgBoss } from 'pg-boss';
2
- import type { ScheduledTaskInfo, ScheduledTaskSummary, CoreUserSession } from '@pikku/core';
3
- import { SchedulerService } from '@pikku/core';
2
+ import { SchedulerService } from '@pikku/core/services';
3
+ import type { CoreUserSession } from '@pikku/core/types';
4
+ import type { ScheduledTaskInfo, ScheduledTaskSummary } from '@pikku/core/services';
4
5
  /**
5
6
  * pg-boss scheduler service implementation
6
7
  * Uses pg-boss's schedule() API to store recurring jobs in PostgreSQL.
@@ -1,6 +1,8 @@
1
- import { SchedulerService, parseDurationString } from '@pikku/core';
2
- import { pikkuState } from '@pikku/core/internal';
3
- import { runScheduledTask, getScheduledTasks } from '@pikku/core/scheduler';
1
+ import { runScheduledTask } from '@pikku/core/scheduler';
2
+ import { SchedulerService } from '@pikku/core/services';
3
+ import { parseDurationString } from '@pikku/core/utils';
4
+ import { pikkuState } from '@pikku/core/state';
5
+ import { getScheduledTasks } from '@pikku/core/scheduler';
4
6
  /** Prefix for pg-boss queues/schedules backing recurring scheduled tasks. */
5
7
  const RECURRING_TASK_PREFIX = 'pikku-recurring-scheduled-task_';
6
8
  /**
package/package.json CHANGED
@@ -1,6 +1,7 @@
1
1
  {
2
2
  "name": "@pikku/queue-pg-boss",
3
- "version": "0.12.8",
3
+ "version": "0.12.10",
4
+ "description": "pg-boss queue, worker and scheduler services for Pikku, backed by Postgres",
4
5
  "author": "yasser.fadl@gmail.com",
5
6
  "license": "MIT",
6
7
  "module": "dist/index.js",
@@ -15,10 +16,10 @@
15
16
  "prepublishOnly": "yarn build"
16
17
  },
17
18
  "peerDependencies": {
18
- "@pikku/core": "^0.12.69"
19
+ "@pikku/core": "^0.12.85"
19
20
  },
20
21
  "dependencies": {
21
- "pg-boss": "^12.14.0"
22
+ "pg-boss": "^12.27.0"
22
23
  },
23
24
  "devDependencies": {
24
25
  "typescript": "^6.0.3"
@@ -26,4 +27,4 @@
26
27
  "exports": {
27
28
  ".": "./dist/index.js"
28
29
  }
29
- }
30
+ }
package/run-tests.sh CHANGED
File without changes
package/src/index.ts CHANGED
@@ -11,10 +11,9 @@ export { PgBossQueueWorkers } from './pg-boss-queue-worker.js'
11
11
  export { PgBossSchedulerService } from './pg-boss-scheduler-service.js'
12
12
 
13
13
  // Re-export core queue types for convenience
14
+ export type { QueueJob, QueueService } from '@pikku/core/queue'
14
15
  export type {
15
- QueueService,
16
16
  PikkuWorkerConfig,
17
17
  PikkuJobConfig,
18
- QueueJob,
19
18
  JobOptions,
20
19
  } from '@pikku/core/queue'
@@ -60,8 +60,10 @@ describe('mapPikkuJobToPgBoss — retry mapping', () => {
60
60
 
61
61
  describe('mapPikkuJobToPgBoss — group mapping', () => {
62
62
  test('group id is forwarded so the worker can enforce a per-group limit', () => {
63
- assert.deepEqual(mapPikkuJobToPgBoss({ group: { id: 'deployWorkflow' } })
64
- .group, { id: 'deployWorkflow' })
63
+ assert.deepEqual(
64
+ mapPikkuJobToPgBoss({ group: { id: 'deployWorkflow' } }).group,
65
+ { id: 'deployWorkflow' }
66
+ )
65
67
  })
66
68
 
67
69
  test('tier is only set when provided', () => {
@@ -69,7 +71,10 @@ describe('mapPikkuJobToPgBoss — group mapping', () => {
69
71
  group: { id: 'deployWorkflow', tier: 'slow' },
70
72
  })
71
73
  assert.deepEqual(opts.group, { id: 'deployWorkflow', tier: 'slow' })
72
- assert.equal('tier' in mapPikkuJobToPgBoss({ group: { id: 'a' } }).group!, false)
74
+ assert.equal(
75
+ 'tier' in mapPikkuJobToPgBoss({ group: { id: 'a' } }).group!,
76
+ false
77
+ )
73
78
  })
74
79
 
75
80
  test('no group → no group field', () => {
@@ -1,5 +1,6 @@
1
1
  import type { PgBoss, Request as PgBossRequest } from 'pg-boss'
2
- import type { QueueService, QueueJob, JobOptions } from '@pikku/core/queue'
2
+ import type { QueueJob, QueueService } from '@pikku/core/queue'
3
+ import type { JobOptions } from '@pikku/core/queue'
3
4
  import { mapPgBossJobToQueueJob } from './utils.js'
4
5
 
5
6
  export const mapPikkuJobToPgBoss = (
@@ -33,7 +34,9 @@ export const mapPikkuJobToPgBoss = (
33
34
 
34
35
  if (options?.backoff !== undefined) {
35
36
  const type =
36
- typeof options.backoff === 'string' ? options.backoff : options.backoff.type
37
+ typeof options.backoff === 'string'
38
+ ? options.backoff
39
+ : options.backoff.type
37
40
  const delay =
38
41
  typeof options.backoff === 'object' ? options.backoff.delay : undefined
39
42
  pgBossOptions.retryBackoff = type === 'exponential'
@@ -5,14 +5,14 @@ import type {
5
5
  QueueConfigMapping,
6
6
  ConfigValidationResult,
7
7
  } from '@pikku/core/queue'
8
+ import { runQueueJob } from '@pikku/core/queue'
9
+ import type { Logger } from '@pikku/core/services'
8
10
  import {
9
11
  registerQueueWorkers,
10
- runQueueJob,
11
12
  QueueJobFailedError,
12
13
  QueueJobDiscardedError,
13
14
  } from '@pikku/core/queue'
14
- import { pikkuState } from '@pikku/core/internal'
15
- import type { Logger } from '@pikku/core/services'
15
+ import { pikkuState } from '@pikku/core/state'
16
16
  import { mapPgBossJobToQueueJob } from './utils.js'
17
17
 
18
18
  export const mapPikkuWorkerToPgBoss = (
@@ -180,7 +180,7 @@ export class PgBossQueueWorkers implements QueueWorkers {
180
180
  logger,
181
181
  async (queueName, processor) => {
182
182
  await this.pgBoss.createQueue(queueName)
183
- const workerId = await this.pgBoss.work<any>(
183
+ const workerId = await this.pgBoss.work(
184
184
  processor.name,
185
185
  {
186
186
  ...mapPikkuWorkerToPgBoss(processor.config),
@@ -1,12 +1,14 @@
1
1
  import type { PgBoss } from 'pg-boss'
2
+ import { runScheduledTask } from '@pikku/core/scheduler'
3
+ import { SchedulerService } from '@pikku/core/services'
4
+ import type { CoreUserSession } from '@pikku/core/types'
2
5
  import type {
3
6
  ScheduledTaskInfo,
4
7
  ScheduledTaskSummary,
5
- CoreUserSession,
6
- } from '@pikku/core'
7
- import { SchedulerService, parseDurationString } from '@pikku/core'
8
- import { pikkuState } from '@pikku/core/internal'
9
- import { runScheduledTask, getScheduledTasks } from '@pikku/core/scheduler'
8
+ } from '@pikku/core/services'
9
+ import { parseDurationString } from '@pikku/core/utils'
10
+ import { pikkuState } from '@pikku/core/state'
11
+ import { getScheduledTasks } from '@pikku/core/scheduler'
10
12
 
11
13
  /**
12
14
  * Data stored in scheduled job