@stacksjs/queue 0.75.13 → 0.75.14

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 (2) hide show
  1. package/dist/job.d.ts +20 -3
  2. package/package.json +11 -11
package/dist/job.d.ts CHANGED
@@ -155,7 +155,19 @@ declare type TransactionMode = 'auto' | 'after' | 'immediate';
155
155
  * `job('SendWelcomeEmial')` is a compile error rather than a dispatch that
156
156
  * resolves to nothing.
157
157
  */
158
- export type JobName = keyof Jobs extends never ? string : keyof Jobs & string;
158
+ export type JobName = keyof Jobs extends never ? string : RegisteredJobName | WithoutJobSuffix<RegisteredJobName>;
159
+ declare type RegisteredJobName = keyof Jobs & string;
160
+ /**
161
+ * `'SendEmailJob'` → `'SendEmail'`, the other spelling {@link resolveJobFile}
162
+ * finds a job under.
163
+ *
164
+ * The runtime tries `<name>.ts` and then `<name>Job.ts`, because the mailer
165
+ * dispatches `SendEmail` while the framework ships `SendEmailJob.ts`. The type
166
+ * only knew the file names, so `job('SendEmail')` - what `mail.queue()` does,
167
+ * and what the framework's own tests call - was a compile error in every app
168
+ * whose registry had been filled. A generic, so it distributes over the union.
169
+ */
170
+ declare type WithoutJobSuffix<T> = T extends `${infer Base}Job` ? (Base extends '' ? never : Base) : never;
159
171
  /**
160
172
  * The payload the named job's handler declares.
161
173
  *
@@ -169,8 +181,13 @@ export type JobName = keyof Jobs extends never ? string : keyof Jobs & string;
169
181
  * while the registry is empty.
170
182
  */
171
183
  export type JobPayload<N extends JobName> = N extends keyof Jobs
172
- ? (Jobs[N] extends Job<infer P> ? P : unknown)
173
- : unknown;
184
+ ? PayloadOf<Jobs[N]>
185
+ // The suffix-less spelling, resolved the way the runtime does: `<name>.ts`
186
+ // first (the branch above), then `<name>Job.ts`.
187
+ : `${N}Job` extends keyof Jobs
188
+ ? PayloadOf<Jobs[`${N}Job`]>
189
+ : unknown;
190
+ declare type PayloadOf<J> = J extends Job<infer P> ? P : unknown;
174
191
  /**
175
192
  * Fluent job builder for file-based jobs
176
193
  */
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@stacksjs/queue",
3
3
  "type": "module",
4
4
  "sideEffects": false,
5
- "version": "0.75.13",
5
+ "version": "0.75.14",
6
6
  "description": "The Stacks Queue system powered by bun-queue.",
7
7
  "author": "Chris Breuer",
8
8
  "contributors": [
@@ -63,22 +63,22 @@
63
63
  "prepublishOnly": "bun run build"
64
64
  },
65
65
  "dependencies": {
66
- "@stacksjs/action-runner": "0.75.13",
66
+ "@stacksjs/action-runner": "0.75.14",
67
67
  "@stacksjs/bun-queue": "^0.1.8",
68
- "@stacksjs/cache": "0.75.13",
69
- "@stacksjs/config": "0.75.13",
70
- "@stacksjs/database": "0.75.13",
71
- "@stacksjs/env": "0.75.13",
72
- "@stacksjs/error-handling": "0.75.13",
73
- "@stacksjs/logging": "0.75.13",
74
- "@stacksjs/path": "0.75.13"
68
+ "@stacksjs/cache": "0.75.14",
69
+ "@stacksjs/config": "0.75.14",
70
+ "@stacksjs/database": "0.75.14",
71
+ "@stacksjs/env": "0.75.14",
72
+ "@stacksjs/error-handling": "0.75.14",
73
+ "@stacksjs/logging": "0.75.14",
74
+ "@stacksjs/path": "0.75.14"
75
75
  },
76
76
  "devDependencies": {
77
77
  "better-dx": "^0.2.24"
78
78
  },
79
79
  "peerDependencies": {
80
- "@stacksjs/email": "0.75.13",
81
- "@stacksjs/router": "0.75.13"
80
+ "@stacksjs/email": "0.75.14",
81
+ "@stacksjs/router": "0.75.14"
82
82
  },
83
83
  "peerDependenciesMeta": {
84
84
  "@stacksjs/email": {