@pikku/queue-nats 0.12.2 → 0.12.4

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.
@@ -9,7 +9,7 @@ import { SCHEDULE_HEADER, SCHEDULE_TARGET_HEADER, SCHEDULE_TIMEZONE_HEADER, SCHE
9
9
  /**
10
10
  * Queue recurring cron fires land on.
11
11
  *
12
- * Deliberately separate from `pikku-remote-internal-rpc` (where one-off
12
+ * Deliberately separate from `pikku-mesh-rpc` (where one-off
13
13
  * `scheduleRPC` calls land): that queue is a registered pikku worker whose
14
14
  * consumer is owned by the queue registry, and a recurring task is not an RPC
15
15
  * invocation — it goes through `runScheduledTask`, which resolves the task's
@@ -18,7 +18,7 @@ import { SCHEDULE_HEADER, SCHEDULE_TARGET_HEADER, SCHEDULE_TIMEZONE_HEADER, SCHE
18
18
  */
19
19
  const RECURRING_TASK_QUEUE = 'pikku-recurring-scheduled-task';
20
20
  /** Queue a one-off `scheduleRPC` fires onto — a registered pikku worker. */
21
- const REMOTE_RPC_QUEUE = 'pikku-remote-internal-rpc';
21
+ const MESH_RPC_QUEUE = 'pikku-mesh-rpc';
22
22
  /** Concurrent in-flight scheduled tasks. */
23
23
  const RECURRING_MAX_ACK_PENDING = 5;
24
24
  /** Ack window for a recurring fire. Generous: recurring tasks are batch
@@ -125,12 +125,12 @@ export class NatsSchedulerService extends SchedulerService {
125
125
  */
126
126
  async scheduleRPC(delay, rpcName, data, session) {
127
127
  const delayMs = typeof delay === 'string' ? parseDurationString(delay) : delay;
128
- const subject = scheduleSubjectFor(this.subjectPrefix, REMOTE_RPC_QUEUE);
128
+ const subject = scheduleSubjectFor(this.subjectPrefix, MESH_RPC_QUEUE);
129
129
  const hdrs = headers();
130
130
  // A timestamp already in the past fires immediately rather than erroring,
131
131
  // which matches pg-boss's `startAfter` with an elapsed date.
132
132
  hdrs.set(SCHEDULE_HEADER, `@at ${new Date(Date.now() + delayMs).toISOString()}`);
133
- hdrs.set(SCHEDULE_TARGET_HEADER, subjectForQueue(this.subjectPrefix, REMOTE_RPC_QUEUE));
133
+ hdrs.set(SCHEDULE_TARGET_HEADER, subjectForQueue(this.subjectPrefix, MESH_RPC_QUEUE));
134
134
  await this.js.publish(subject, JSON.stringify({ rpcName, data, session }), { headers: hdrs });
135
135
  return subject;
136
136
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pikku/queue-nats",
3
- "version": "0.12.2",
3
+ "version": "0.12.4",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/pikkujs/pikku.git",
@@ -17,12 +17,13 @@
17
17
  "test": "bash run-tests.sh",
18
18
  "test:coverage": "bash run-tests.sh --coverage",
19
19
  "ncu": "npx npm-check-updates",
20
- "build": "tsc -b",
20
+ "build": "bun run clean && tsc -b",
21
21
  "release": "npm run build && npm test",
22
- "prepublishOnly": "bun run build"
22
+ "prepublishOnly": "bun run build",
23
+ "clean": "rm -rf dist tsconfig.tsbuildinfo"
23
24
  },
24
25
  "peerDependencies": {
25
- "@pikku/core": "^0.12.108"
26
+ "@pikku/core": "^0.12.146"
26
27
  },
27
28
  "dependencies": {
28
29
  "@nats-io/jetstream": "^3.4.0",
@@ -30,6 +31,11 @@
30
31
  "@nats-io/transport-node": "^3.4.0"
31
32
  },
32
33
  "exports": {
33
- ".": "./dist/index.js"
34
- }
34
+ ".": "./dist/index.js",
35
+ "./package.json": "./package.json"
36
+ },
37
+ "files": [
38
+ "dist",
39
+ "!dist/**/*.tsbuildinfo"
40
+ ]
35
41
  }
package/CHANGELOG.md DELETED
@@ -1,37 +0,0 @@
1
- # @pikku/queue-nats
2
-
3
- ## 0.12.2
4
-
5
- ### Patch Changes
6
-
7
- - 4c7a1b5: Run the monorepo's own scripts through bun instead of yarn. What moves is the
8
- package manager each package's `prepublishOnly` and build scripts invoke, plus
9
- the two manifest fixes bun needs to resolve the tree: `uWebSockets.js` is
10
- declared with an explicit `github:` specifier, and `@pikku/uws-handler` marks
11
- its `uWebSockets.js` peer optional so a bun install of a consumer that brings
12
- its own uWS app does not try to fetch it from the registry.
13
-
14
- Three published behaviours change, all of them cases where an isolated
15
- `node_modules` or bun as the runtime had been papered over by yarn's hoisting:
16
-
17
- - `@pikku/migrator-sql` turns foreign keys on when it opens a sqlite database
18
- through bun. `node:sqlite` enforces them by default and `bun:sqlite` does not,
19
- which silently turned every `ON DELETE CASCADE` into a no-op under
20
- `bunx --bun pikku`.
21
- - `@pikku/cli` resolves a deploy provider against the project being deployed
22
- rather than against wherever the CLI itself is installed, which is what its
23
- own "is not installed" error asks the user to arrange.
24
- - `@pikku/cli` treats a specifier a runtime hands straight back — bun does this
25
- for the modules it implements itself — as not resolved from the project, so
26
- it falls back rather than loading the runtime's own copy.
27
-
28
- - Updated dependencies [4c7a1b5]
29
- - @pikku/core@0.12.108
30
-
31
- ## 0.12.1
32
-
33
- ### Patch Changes
34
-
35
- - 427c4fe: **`@pikku/queue-nats`** — NATS JetStream queue, worker and scheduler services, alongside the pg-boss and bullmq adapters. Jobs publish to a work-queue stream, each queue gets its own durable pull consumer, and `max_ack_pending` is real per-message concurrency rather than a batch size, so a slow job occupies one slot instead of holding its batch siblings. The per-job retry policy travels in headers because JetStream's `max_deliver` is per-consumer and cannot express a step marked "never retry", and `ack_wait` is always set to pg-boss's 900s parity rather than left to the server's 30s default — unset, any job running longer than 30s is redelivered while it is still running and executed twice. Cron and one-shot delays use the server's own message scheduler, so a schedule is a retained message on a reserved subject: publishing registers it, republishing replaces it, purging cancels it. That needs a server on 2.14+, and `NatsServiceFactory` refuses to start against anything older rather than silently not scheduling. `supportsResults` is `false`, deliberately — a work-queue stream deletes a message on ack, so there is nowhere for a job result or any job history to live, and per-job outcomes come from telemetry instead.
36
- - Updated dependencies [1ab831e]
37
- - @pikku/core@0.12.105
package/run-tests.sh DELETED
@@ -1,68 +0,0 @@
1
- #!/bin/bash
2
-
3
- # Enable nullglob to handle cases where no files match the pattern
4
- shopt -s nullglob
5
-
6
- # Initialize variables for options
7
- watch_mode=false
8
- coverage_mode=false
9
-
10
- # Parse command-line options
11
- while [[ $# -gt 0 ]]; do
12
- case $1 in
13
- --watch)
14
- watch_mode=true
15
- shift
16
- ;;
17
- --coverage)
18
- coverage_mode=true
19
- shift
20
- ;;
21
- *)
22
- echo "Unknown option: $1"
23
- exit 1
24
- ;;
25
- esac
26
- done
27
-
28
- # Define the pattern to match your test files
29
- pattern="src/*.test.ts"
30
-
31
- # Expand the pattern into an array of files
32
- files=($(find src -type f -name "*.test.ts"))
33
-
34
- # Check if any files matched the pattern
35
- if [ ${#files[@]} -eq 0 ]; then
36
- echo "No test files found matching pattern: $pattern"
37
- if [ "${STRICT_TEST_DISCOVERY}" = "1" ]; then
38
- exit 1
39
- fi
40
- exit 0
41
- fi
42
-
43
- # Construct the bun command
44
- #
45
- # --parallel gives every test file its own worker process, which is what node's
46
- # `--test` did. Several suites keep module-level caches (a TypeScript program, a
47
- # temp fixture directory) that a shared process would leak between files.
48
- #
49
- # --timeout because bun caps a test at 5s by default where node had no cap, and
50
- # the suites that build real TypeScript programs run well past that.
51
- bun_cmd=(bun test --parallel --timeout 120000)
52
-
53
- # Append options based on flags
54
- if [ "$watch_mode" = true ]; then
55
- # --watch reruns in one process; parallel workers have nothing to watch.
56
- bun_cmd=(bun test --watch --timeout 120000)
57
- fi
58
-
59
- if [ "$coverage_mode" = true ]; then
60
- # --coverage-dir=. keeps lcov.info at the package root: CI merges every
61
- # package's report by prefixing its SF paths with the file's own directory,
62
- # so a nested coverage/ directory would re-root them one level too deep.
63
- bun_cmd+=(--coverage --coverage-reporter=lcov --coverage-reporter=text --coverage-dir=.)
64
- export PIKKU_TEST_COVERAGE=1
65
- fi
66
-
67
- # Execute the bun command with the expanded list of files
68
- "${bun_cmd[@]}" "${files[@]}"