@wrelik/jobs 0.1.2 → 2.0.1

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.
@@ -1,23 +1,27 @@
1
1
 
2
- > @wrelik/jobs@0.1.2 build /home/runner/work/wrelik-kit/wrelik-kit/packages/jobs
3
- > tsup src/index.ts src/unsupported.ts --format cjs,esm --dts --clean
2
+ > @wrelik/jobs@2.0.1 build /Users/lee/Projects/wrelik-kit/packages/jobs
3
+ > tsup src/server/index.ts src/client/index.ts src/shared/index.ts --format cjs,esm --dts --clean
4
4
 
5
- CLI Building entry: src/index.ts, src/unsupported.ts
6
- CLI Using tsconfig: tsconfig.json
7
- CLI tsup v8.5.1
8
- CLI Target: es2022
9
- CLI Cleaning output folder
10
- CJS Build start
11
- ESM Build start
12
- CJS dist/index.js 1.60 KB
13
- CJS dist/unsupported.js 192.00 B
14
- CJS ⚡️ Build success in 54ms
15
- ESM dist/index.mjs 537.00 B
16
- ESM dist/unsupported.mjs 177.00 B
17
- ESM ⚡️ Build success in 51ms
18
- DTS Build start
19
- DTS ⚡️ Build success in 2292ms
20
- DTS dist/unsupported.d.ts 13.00 B
21
- DTS dist/index.d.ts 1.18 KB
22
- DTS dist/unsupported.d.mts 13.00 B
23
- DTS dist/index.d.mts 1.18 KB
5
+ CLI Building entry: src/server/index.ts, src/client/index.ts, src/shared/index.ts
6
+ CLI Using tsconfig: tsconfig.json
7
+ CLI tsup v8.5.1
8
+ CLI Target: es2022
9
+ CLI Cleaning output folder
10
+ CJS Build start
11
+ ESM Build start
12
+ DTS Build start
13
+ ESM dist/shared/index.mjs 0 B
14
+ ESM dist/client/index.mjs 272.00 B
15
+ ESM dist/server/index.mjs 1.07 KB
16
+ ESM ⚡️ Build success in 2017ms
17
+ CJS dist/client/index.js 1.27 KB
18
+ CJS dist/server/index.js 2.18 KB
19
+ CJS dist/shared/index.js 767.00 B
20
+ CJS ⚡️ Build success in 2017ms
21
+ DTS ⚡️ Build success in 2631ms
22
+ DTS dist/server/index.d.ts 1.32 KB
23
+ DTS dist/client/index.d.ts 77.00 B
24
+ DTS dist/shared/index.d.ts 95.00 B
25
+ DTS dist/server/index.d.mts 1.32 KB
26
+ DTS dist/client/index.d.mts 77.00 B
27
+ DTS dist/shared/index.d.mts 95.00 B
@@ -0,0 +1,5 @@
1
+
2
+ > @wrelik/jobs@0.1.2 lint /Users/lee/Projects/wrelik-kit/packages/jobs
3
+ > eslint src/
4
+
5
+ Warning: React version was set to "detect" in eslint-plugin-react settings, but the "react" package is not installed. Assuming latest React version for linting.
@@ -0,0 +1,15 @@
1
+
2
+ > @wrelik/jobs@2.0.1 test /Users/lee/Projects/wrelik-kit/packages/jobs
3
+ > vitest run --passWithNoTests
4
+
5
+
6
+  RUN  v4.1.2 /Users/lee/Projects/wrelik-kit/packages/jobs
7
+
8
+ ✓ src/client/index.test.ts (1 test) 25ms
9
+ ✓ src/server/index.test.ts (4 tests) 39ms
10
+
11
+  Test Files  2 passed (2)
12
+  Tests  5 passed (5)
13
+  Start at  20:04:57
14
+  Duration  1.52s (transform 548ms, setup 0ms, import 845ms, tests 65ms, environment 0ms)
15
+
@@ -0,0 +1,4 @@
1
+
2
+ > @wrelik/jobs@2.0.0 typecheck /Users/lee/Projects/wrelik-kit/packages/jobs
3
+ > tsc --noEmit
4
+
package/CHANGELOG.md CHANGED
@@ -1,5 +1,29 @@
1
1
  # @wrelik/jobs
2
2
 
3
+ ## 2.0.1
4
+
5
+ ### Patch Changes
6
+
7
+ - 3262454: Upgrade runtime SDK and workspace tooling dependencies to latest compatible versions, including Clerk, Sentry, AWS SDK, Inngest, Resend, Upstash, Zod, TypeScript, Turbo, Vitest, TSUP, and ESLint.
8
+
9
+ Adopt root ESLint flat config and align wrapper peer ranges for updated SDK majors while preserving package export paths. Also apply a patched transitive Next.js resolution to close audit findings and keep production audit clean.
10
+
11
+ Note: Vite is pinned to the latest 7.x line for runtime compatibility in this environment; this avoids current rolldown native-binding failures seen with Vite 8 under Node 20.18.0.
12
+
13
+ Breaking change: `@wrelik/auth` and `@wrelik/clerk-next` now require `@clerk/nextjs@7.x` via updated peer ranges (`>=7 <8`). Consumers on Clerk v4-v6 must upgrade to Clerk v7 before adopting these versions.
14
+
15
+ ## 2.0.0
16
+
17
+ ### Major Changes
18
+
19
+ - 818ed58: Refactor runtime packages to strict subpath exports (`/server`, `/client`, `/shared`) with side-effect free entrypoints and hard CI/runtime boundary enforcement.
20
+
21
+ ### Minor Changes
22
+
23
+ - Add platform wrapper packages for Clerk (Next/Expo), Next Sentry client instrumentation, and Upstash server SDK access so apps can avoid direct vendor imports while staying inside the `@wrelik/*` boundary.
24
+
25
+ Add temporary deprecated server-side compatibility singleton exports to analytics, email, jobs, and storage to support DRX migration from root-import convenience APIs to runtime subpaths in one cutover.
26
+
3
27
  ## 0.1.2
4
28
 
5
29
  ### Patch Changes
@@ -0,0 +1,3 @@
1
+ declare const serverOnlyClientStub: never;
2
+
3
+ export { serverOnlyClientStub };
@@ -0,0 +1,3 @@
1
+ declare const serverOnlyClientStub: never;
2
+
3
+ export { serverOnlyClientStub };
@@ -17,37 +17,18 @@ var __copyProps = (to, from, except, desc) => {
17
17
  };
18
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
19
 
20
- // src/index.ts
21
- var index_exports = {};
22
- __export(index_exports, {
23
- createFunction: () => createFunction,
24
- emit: () => emit,
25
- initJobs: () => initJobs,
26
- inngest: () => client
20
+ // src/client/index.ts
21
+ var client_exports = {};
22
+ __export(client_exports, {
23
+ serverOnlyClientStub: () => serverOnlyClientStub
27
24
  });
28
- module.exports = __toCommonJS(index_exports);
29
- var import_inngest = require("inngest");
30
- var client;
31
- function initJobs(appId) {
32
- client = new import_inngest.Inngest({ id: appId });
33
- }
34
- function getClient() {
35
- if (!client) throw new Error("Jobs not initialized");
36
- return client;
37
- }
38
- async function emit(eventName, payload) {
39
- return getClient().send({
40
- name: eventName,
41
- data: payload
42
- });
43
- }
44
- function createFunction(name, trigger, handler) {
45
- return getClient().createFunction({ id: name }, trigger, handler);
46
- }
25
+ module.exports = __toCommonJS(client_exports);
26
+ var serverOnlyClientStub = (() => {
27
+ throw new Error(
28
+ "@wrelik/jobs/client is a server-only adapter stub. Use @wrelik/jobs/server on the backend and call your backend API from client or Expo apps."
29
+ );
30
+ })();
47
31
  // Annotate the CommonJS export names for ESM import in node:
48
32
  0 && (module.exports = {
49
- createFunction,
50
- emit,
51
- initJobs,
52
- inngest
33
+ serverOnlyClientStub
53
34
  });
@@ -0,0 +1,9 @@
1
+ // src/client/index.ts
2
+ var serverOnlyClientStub = (() => {
3
+ throw new Error(
4
+ "@wrelik/jobs/client is a server-only adapter stub. Use @wrelik/jobs/server on the backend and call your backend API from client or Expo apps."
5
+ );
6
+ })();
7
+ export {
8
+ serverOnlyClientStub
9
+ };
@@ -0,0 +1,32 @@
1
+ import { JobTrigger } from '../shared/index.mjs';
2
+
3
+ interface JobsClient {
4
+ send: (payload: {
5
+ name: string;
6
+ data: unknown;
7
+ }) => Promise<unknown>;
8
+ createFunction: (config: {
9
+ id: string;
10
+ }, trigger: JobTrigger, handler: (args: unknown) => Promise<unknown>) => unknown;
11
+ }
12
+ declare function createJobsServer(appId: string, options?: {
13
+ client?: JobsClient;
14
+ createClient?: (appId: string) => JobsClient;
15
+ }): {
16
+ emit(eventName: string, payload: unknown): Promise<unknown>;
17
+ createFunction(name: string, trigger: JobTrigger, handler: (args: unknown) => Promise<unknown>): unknown;
18
+ };
19
+ /**
20
+ * @deprecated Temporary DRX compatibility singleton. Prefer createJobsServer(...) and explicit dependency wiring.
21
+ */
22
+ declare function initJobs(appId: string, options?: Parameters<typeof createJobsServer>[1]): void;
23
+ /**
24
+ * @deprecated Temporary DRX compatibility singleton. Prefer createJobsServer(...).emit(...)
25
+ */
26
+ declare function emit(eventName: string, payload: unknown): Promise<unknown>;
27
+ /**
28
+ * @deprecated Temporary DRX compatibility singleton. Prefer createJobsServer(...).createFunction(...)
29
+ */
30
+ declare function createFunction(name: string, trigger: JobTrigger, handler: (args: unknown) => Promise<unknown>): unknown;
31
+
32
+ export { JobTrigger, type JobsClient, createFunction, createJobsServer, emit, initJobs };
@@ -0,0 +1,32 @@
1
+ import { JobTrigger } from '../shared/index.js';
2
+
3
+ interface JobsClient {
4
+ send: (payload: {
5
+ name: string;
6
+ data: unknown;
7
+ }) => Promise<unknown>;
8
+ createFunction: (config: {
9
+ id: string;
10
+ }, trigger: JobTrigger, handler: (args: unknown) => Promise<unknown>) => unknown;
11
+ }
12
+ declare function createJobsServer(appId: string, options?: {
13
+ client?: JobsClient;
14
+ createClient?: (appId: string) => JobsClient;
15
+ }): {
16
+ emit(eventName: string, payload: unknown): Promise<unknown>;
17
+ createFunction(name: string, trigger: JobTrigger, handler: (args: unknown) => Promise<unknown>): unknown;
18
+ };
19
+ /**
20
+ * @deprecated Temporary DRX compatibility singleton. Prefer createJobsServer(...) and explicit dependency wiring.
21
+ */
22
+ declare function initJobs(appId: string, options?: Parameters<typeof createJobsServer>[1]): void;
23
+ /**
24
+ * @deprecated Temporary DRX compatibility singleton. Prefer createJobsServer(...).emit(...)
25
+ */
26
+ declare function emit(eventName: string, payload: unknown): Promise<unknown>;
27
+ /**
28
+ * @deprecated Temporary DRX compatibility singleton. Prefer createJobsServer(...).createFunction(...)
29
+ */
30
+ declare function createFunction(name: string, trigger: JobTrigger, handler: (args: unknown) => Promise<unknown>): unknown;
31
+
32
+ export { JobTrigger, type JobsClient, createFunction, createJobsServer, emit, initJobs };
@@ -0,0 +1,68 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/server/index.ts
21
+ var server_exports = {};
22
+ __export(server_exports, {
23
+ createFunction: () => createFunction,
24
+ createJobsServer: () => createJobsServer,
25
+ emit: () => emit,
26
+ initJobs: () => initJobs
27
+ });
28
+ module.exports = __toCommonJS(server_exports);
29
+ var import_inngest = require("inngest");
30
+ function createJobsServer(appId, options) {
31
+ const client = options?.client ?? options?.createClient?.(appId) ?? new import_inngest.Inngest({ id: appId });
32
+ return {
33
+ emit(eventName, payload) {
34
+ return client.send({
35
+ name: eventName,
36
+ data: payload
37
+ });
38
+ },
39
+ createFunction(name, trigger, handler) {
40
+ return client.createFunction({ id: name }, trigger, handler);
41
+ }
42
+ };
43
+ }
44
+ var jobsSingleton = null;
45
+ function requireJobsSingleton() {
46
+ if (!jobsSingleton) {
47
+ throw new Error(
48
+ "@wrelik/jobs/server compatibility API is not initialized. Call initJobs(appId) before emit/createFunction."
49
+ );
50
+ }
51
+ return jobsSingleton;
52
+ }
53
+ function initJobs(appId, options) {
54
+ jobsSingleton = createJobsServer(appId, options);
55
+ }
56
+ function emit(eventName, payload) {
57
+ return requireJobsSingleton().emit(eventName, payload);
58
+ }
59
+ function createFunction(name, trigger, handler) {
60
+ return requireJobsSingleton().createFunction(name, trigger, handler);
61
+ }
62
+ // Annotate the CommonJS export names for ESM import in node:
63
+ 0 && (module.exports = {
64
+ createFunction,
65
+ createJobsServer,
66
+ emit,
67
+ initJobs
68
+ });
@@ -0,0 +1,40 @@
1
+ // src/server/index.ts
2
+ import { Inngest } from "inngest";
3
+ function createJobsServer(appId, options) {
4
+ const client = options?.client ?? options?.createClient?.(appId) ?? new Inngest({ id: appId });
5
+ return {
6
+ emit(eventName, payload) {
7
+ return client.send({
8
+ name: eventName,
9
+ data: payload
10
+ });
11
+ },
12
+ createFunction(name, trigger, handler) {
13
+ return client.createFunction({ id: name }, trigger, handler);
14
+ }
15
+ };
16
+ }
17
+ var jobsSingleton = null;
18
+ function requireJobsSingleton() {
19
+ if (!jobsSingleton) {
20
+ throw new Error(
21
+ "@wrelik/jobs/server compatibility API is not initialized. Call initJobs(appId) before emit/createFunction."
22
+ );
23
+ }
24
+ return jobsSingleton;
25
+ }
26
+ function initJobs(appId, options) {
27
+ jobsSingleton = createJobsServer(appId, options);
28
+ }
29
+ function emit(eventName, payload) {
30
+ return requireJobsSingleton().emit(eventName, payload);
31
+ }
32
+ function createFunction(name, trigger, handler) {
33
+ return requireJobsSingleton().createFunction(name, trigger, handler);
34
+ }
35
+ export {
36
+ createFunction,
37
+ createJobsServer,
38
+ emit,
39
+ initJobs
40
+ };
@@ -0,0 +1,7 @@
1
+ type JobTrigger = {
2
+ event: string;
3
+ } | {
4
+ cron: string;
5
+ };
6
+
7
+ export type { JobTrigger };
@@ -0,0 +1,7 @@
1
+ type JobTrigger = {
2
+ event: string;
3
+ } | {
4
+ cron: string;
5
+ };
6
+
7
+ export type { JobTrigger };
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __copyProps = (to, from, except, desc) => {
7
+ if (from && typeof from === "object" || typeof from === "function") {
8
+ for (let key of __getOwnPropNames(from))
9
+ if (!__hasOwnProp.call(to, key) && key !== except)
10
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
11
+ }
12
+ return to;
13
+ };
14
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
15
+
16
+ // src/shared/index.ts
17
+ var shared_exports = {};
18
+ module.exports = __toCommonJS(shared_exports);
File without changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wrelik/jobs",
3
- "version": "0.1.2",
3
+ "version": "2.0.1",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -9,21 +9,47 @@
9
9
  "url": "https://github.com/lwhite702/wrelik-kit.git",
10
10
  "directory": "packages/jobs"
11
11
  },
12
- "main": "./dist/index.js",
13
- "types": "./dist/index.d.ts",
14
- "react-native": "./dist/unsupported.js",
12
+ "sideEffects": false,
13
+ "exports": {
14
+ "./server": {
15
+ "types": "./dist/server/index.d.ts",
16
+ "import": "./dist/server/index.mjs",
17
+ "require": "./dist/server/index.js"
18
+ },
19
+ "./client": {
20
+ "types": "./dist/client/index.d.ts",
21
+ "import": "./dist/client/index.mjs",
22
+ "require": "./dist/client/index.js"
23
+ },
24
+ "./shared": {
25
+ "types": "./dist/shared/index.d.ts",
26
+ "import": "./dist/shared/index.mjs",
27
+ "require": "./dist/shared/index.js"
28
+ },
29
+ "./package.json": "./package.json"
30
+ },
15
31
  "dependencies": {
16
- "inngest": "^3.11.0"
32
+ "inngest": "^4.1.2"
17
33
  },
18
34
  "devDependencies": {
19
- "tsup": "^8.0.1",
20
- "vitest": "^1.2.2",
21
- "@wrelik/eslint-config": "0.1.1",
22
- "@wrelik/tsconfig": "0.1.1"
35
+ "next": "15.5.14",
36
+ "tsup": "^8.5.1",
37
+ "vite": "^7.3.1",
38
+ "vitest": "^4.1.2",
39
+ "@wrelik/eslint-config": "0.1.2",
40
+ "@wrelik/tsconfig": "0.1.2"
41
+ },
42
+ "wrelik": {
43
+ "runtimes": [
44
+ "server",
45
+ "client",
46
+ "shared"
47
+ ]
23
48
  },
24
49
  "scripts": {
25
- "build": "tsup src/index.ts src/unsupported.ts --format cjs,esm --dts --clean",
50
+ "build": "tsup src/server/index.ts src/client/index.ts src/shared/index.ts --format cjs,esm --dts --clean",
26
51
  "lint": "eslint src/",
52
+ "typecheck": "tsc --noEmit",
27
53
  "test": "vitest run --passWithNoTests"
28
54
  }
29
55
  }
@@ -0,0 +1,7 @@
1
+ import { describe, expect, it } from 'vitest';
2
+
3
+ describe('@wrelik/jobs/client', () => {
4
+ it('fails fast with a server-only adapter message', async () => {
5
+ await expect(import('./index.js')).rejects.toThrow(/server-only adapter stub/i);
6
+ });
7
+ });
@@ -0,0 +1,5 @@
1
+ export const serverOnlyClientStub = (() => {
2
+ throw new Error(
3
+ '@wrelik/jobs/client is a server-only adapter stub. Use @wrelik/jobs/server on the backend and call your backend API from client or Expo apps.',
4
+ );
5
+ })();
@@ -0,0 +1,66 @@
1
+ import { afterEach, describe, expect, it, vi } from 'vitest';
2
+ import { createJobsServer } from './index';
3
+
4
+ afterEach(() => {
5
+ vi.resetModules();
6
+ vi.clearAllMocks();
7
+ });
8
+
9
+ describe('@wrelik/jobs/server', () => {
10
+ it('registers functions with the wrapped client and preserves handler signature', async () => {
11
+ const createFunction = vi.fn((_config, _trigger, handler) => handler({ event: { data: { ok: true } } }));
12
+ const send = vi.fn(async () => ({ ids: ['evt_1'] }));
13
+ const jobs = createJobsServer('drx', {
14
+ client: {
15
+ send,
16
+ createFunction,
17
+ },
18
+ });
19
+
20
+ const handler = vi.fn(async (args: unknown) => args);
21
+ const result = await jobs.createFunction('sync-user', { event: 'user/sync' }, handler);
22
+
23
+ expect(createFunction).toHaveBeenCalledWith({ id: 'sync-user' }, { event: 'user/sync' }, handler);
24
+ expect(handler).toHaveBeenCalledWith({ event: { data: { ok: true } } });
25
+ expect(result).toEqual({ event: { data: { ok: true } } });
26
+ });
27
+
28
+ it('sends events through the wrapped client', async () => {
29
+ const send = vi.fn(async () => ({ ids: ['evt_1'] }));
30
+ const jobs = createJobsServer('drx', {
31
+ client: {
32
+ send,
33
+ createFunction: vi.fn(),
34
+ },
35
+ });
36
+
37
+ await jobs.emit('user.created', { userId: 'u1' });
38
+ expect(send).toHaveBeenCalledWith({ name: 'user.created', data: { userId: 'u1' } });
39
+ });
40
+
41
+ it('compatibility singleton throws before initJobs', async () => {
42
+ const mod = await import('./index.js');
43
+ expect(() => mod.emit('user.created', { userId: 'u1' })).toThrow(/initJobs/i);
44
+ });
45
+
46
+ it('compatibility singleton delegates after initJobs', async () => {
47
+ const send = vi.fn(async () => ({ ids: ['evt_99'] }));
48
+ const createFunction = vi.fn((_config, _trigger, handler) => handler({ event: { data: { ok: true } } }));
49
+ const mod = await import('./index.js');
50
+
51
+ mod.initJobs('drx-primary', {
52
+ client: {
53
+ send,
54
+ createFunction,
55
+ },
56
+ });
57
+
58
+ const handler = vi.fn(async (args: unknown) => args);
59
+ await mod.emit('user.created', { userId: 'u1' });
60
+ const result = await mod.createFunction('sync-user', { event: 'user/sync' }, handler);
61
+
62
+ expect(send).toHaveBeenCalledWith({ name: 'user.created', data: { userId: 'u1' } });
63
+ expect(createFunction).toHaveBeenCalledWith({ id: 'sync-user' }, { event: 'user/sync' }, handler);
64
+ expect(result).toEqual({ event: { data: { ok: true } } });
65
+ });
66
+ });
@@ -0,0 +1,70 @@
1
+ import { Inngest } from 'inngest';
2
+ import type { JobTrigger } from '../shared';
3
+ export type { JobTrigger } from '../shared';
4
+
5
+ export interface JobsClient {
6
+ send: (payload: { name: string; data: unknown }) => Promise<unknown>;
7
+ createFunction: (config: { id: string }, trigger: JobTrigger, handler: (args: unknown) => Promise<unknown>) => unknown;
8
+ }
9
+
10
+ export function createJobsServer(
11
+ appId: string,
12
+ options?: { client?: JobsClient; createClient?: (appId: string) => JobsClient },
13
+ ) {
14
+ const client =
15
+ options?.client ??
16
+ options?.createClient?.(appId) ??
17
+ ((new Inngest({ id: appId }) as unknown) as JobsClient);
18
+
19
+ return {
20
+ emit(eventName: string, payload: unknown) {
21
+ return client.send({
22
+ name: eventName,
23
+ data: payload,
24
+ });
25
+ },
26
+
27
+ createFunction(name: string, trigger: JobTrigger, handler: (args: unknown) => Promise<unknown>) {
28
+ return client.createFunction({ id: name }, trigger, handler);
29
+ },
30
+ };
31
+ }
32
+
33
+ type JobsServerCompat = ReturnType<typeof createJobsServer>;
34
+
35
+ let jobsSingleton: JobsServerCompat | null = null;
36
+
37
+ function requireJobsSingleton(): JobsServerCompat {
38
+ if (!jobsSingleton) {
39
+ throw new Error(
40
+ '@wrelik/jobs/server compatibility API is not initialized. Call initJobs(appId) before emit/createFunction.',
41
+ );
42
+ }
43
+
44
+ return jobsSingleton;
45
+ }
46
+
47
+ /**
48
+ * @deprecated Temporary DRX compatibility singleton. Prefer createJobsServer(...) and explicit dependency wiring.
49
+ */
50
+ export function initJobs(appId: string, options?: Parameters<typeof createJobsServer>[1]): void {
51
+ jobsSingleton = createJobsServer(appId, options);
52
+ }
53
+
54
+ /**
55
+ * @deprecated Temporary DRX compatibility singleton. Prefer createJobsServer(...).emit(...)
56
+ */
57
+ export function emit(eventName: string, payload: unknown): Promise<unknown> {
58
+ return requireJobsSingleton().emit(eventName, payload);
59
+ }
60
+
61
+ /**
62
+ * @deprecated Temporary DRX compatibility singleton. Prefer createJobsServer(...).createFunction(...)
63
+ */
64
+ export function createFunction(
65
+ name: string,
66
+ trigger: JobTrigger,
67
+ handler: (args: unknown) => Promise<unknown>,
68
+ ): unknown {
69
+ return requireJobsSingleton().createFunction(name, trigger, handler);
70
+ }
@@ -0,0 +1 @@
1
+ export type { JobTrigger } from './types';
@@ -0,0 +1 @@
1
+ export type JobTrigger = { event: string } | { cron: string };
package/dist/index.d.mts DELETED
@@ -1,30 +0,0 @@
1
- import * as inngest_types from 'inngest/types';
2
- import * as inngest from 'inngest';
3
- import { Inngest } from 'inngest';
4
-
5
- declare let client: Inngest;
6
- declare function initJobs(appId: string): void;
7
- declare function emit(eventName: string, payload: any): Promise<inngest_types.SendEventOutput<inngest.ClientOptions>>;
8
- declare function createFunction(name: string, trigger: {
9
- event: string;
10
- } | {
11
- cron: string;
12
- }, handler: (args: any) => Promise<any>): inngest.InngestFunction<Omit<inngest.InngestFunction.Options<Inngest<inngest.ClientOptions>, inngest.InngestMiddleware.Stack, [{
13
- event: string;
14
- }] | [{
15
- cron: string;
16
- }], inngest.Handler<Inngest<inngest.ClientOptions>, string, {
17
- event: inngest.FailureEventPayload<inngest.EventPayload<any>>;
18
- logger: inngest.Logger;
19
- error: Error;
20
- }>>, "triggers">, (args: any) => Promise<any>, inngest.Handler<Inngest<inngest.ClientOptions>, string, {
21
- event: inngest.FailureEventPayload<inngest.EventPayload<any>>;
22
- logger: inngest.Logger;
23
- error: Error;
24
- }>, Inngest<inngest.ClientOptions>, inngest.InngestMiddleware.Stack, [{
25
- event: string;
26
- }] | [{
27
- cron: string;
28
- }]>;
29
-
30
- export { createFunction, emit, initJobs, client as inngest };
package/dist/index.d.ts DELETED
@@ -1,30 +0,0 @@
1
- import * as inngest_types from 'inngest/types';
2
- import * as inngest from 'inngest';
3
- import { Inngest } from 'inngest';
4
-
5
- declare let client: Inngest;
6
- declare function initJobs(appId: string): void;
7
- declare function emit(eventName: string, payload: any): Promise<inngest_types.SendEventOutput<inngest.ClientOptions>>;
8
- declare function createFunction(name: string, trigger: {
9
- event: string;
10
- } | {
11
- cron: string;
12
- }, handler: (args: any) => Promise<any>): inngest.InngestFunction<Omit<inngest.InngestFunction.Options<Inngest<inngest.ClientOptions>, inngest.InngestMiddleware.Stack, [{
13
- event: string;
14
- }] | [{
15
- cron: string;
16
- }], inngest.Handler<Inngest<inngest.ClientOptions>, string, {
17
- event: inngest.FailureEventPayload<inngest.EventPayload<any>>;
18
- logger: inngest.Logger;
19
- error: Error;
20
- }>>, "triggers">, (args: any) => Promise<any>, inngest.Handler<Inngest<inngest.ClientOptions>, string, {
21
- event: inngest.FailureEventPayload<inngest.EventPayload<any>>;
22
- logger: inngest.Logger;
23
- error: Error;
24
- }>, Inngest<inngest.ClientOptions>, inngest.InngestMiddleware.Stack, [{
25
- event: string;
26
- }] | [{
27
- cron: string;
28
- }]>;
29
-
30
- export { createFunction, emit, initJobs, client as inngest };
package/dist/index.mjs DELETED
@@ -1,25 +0,0 @@
1
- // src/index.ts
2
- import { Inngest } from "inngest";
3
- var client;
4
- function initJobs(appId) {
5
- client = new Inngest({ id: appId });
6
- }
7
- function getClient() {
8
- if (!client) throw new Error("Jobs not initialized");
9
- return client;
10
- }
11
- async function emit(eventName, payload) {
12
- return getClient().send({
13
- name: eventName,
14
- data: payload
15
- });
16
- }
17
- function createFunction(name, trigger, handler) {
18
- return getClient().createFunction({ id: name }, trigger, handler);
19
- }
20
- export {
21
- createFunction,
22
- emit,
23
- initJobs,
24
- client as inngest
25
- };
@@ -1,2 +0,0 @@
1
-
2
- export { }
@@ -1,2 +0,0 @@
1
-
2
- export { }
@@ -1,6 +0,0 @@
1
- "use strict";
2
-
3
- // src/unsupported.ts
4
- throw new Error(
5
- "This package is server-only and cannot be used in client/mobile environments. Access this functionality via a backend API instead."
6
- );
@@ -1,4 +0,0 @@
1
- // src/unsupported.ts
2
- throw new Error(
3
- "This package is server-only and cannot be used in client/mobile environments. Access this functionality via a backend API instead."
4
- );
package/src/index.ts DELETED
@@ -1,41 +0,0 @@
1
- // eslint-disable-next-line no-restricted-imports
2
- import { Inngest } from 'inngest';
3
-
4
- // Define the event types map that apps can extend via module augmentation?
5
- // For now, we use a generic approach or require strict schemas.
6
- // The user requirement says "Enforce event naming convention" was for analytics.
7
- // For jobs: emit(eventName, payload), createFunction(name, trigger, handler).
8
-
9
- let client: Inngest;
10
-
11
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
12
- export function initJobs(appId: string) {
13
- // We can pass schemas if we want strict typing
14
- client = new Inngest({ id: appId });
15
- }
16
-
17
- function getClient() {
18
- if (!client) throw new Error('Jobs not initialized');
19
- return client;
20
- }
21
-
22
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
23
- export async function emit(eventName: string, payload: any) {
24
- return getClient().send({
25
- name: eventName,
26
- data: payload,
27
- });
28
- }
29
-
30
- // Wrapper for createFunction to lock down options if needed
31
- export function createFunction(
32
- name: string,
33
- trigger: { event: string } | { cron: string },
34
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
35
- handler: (args: any) => Promise<any>,
36
- ) {
37
- return getClient().createFunction({ id: name }, trigger, handler);
38
- }
39
-
40
- // Export the client for advance usage if necessary
41
- export { client as inngest };
@@ -1,4 +0,0 @@
1
- throw new Error(
2
- 'This package is server-only and cannot be used in client/mobile environments. ' +
3
- 'Access this functionality via a backend API instead.',
4
- );