@wrelik/jobs 0.1.2 → 2.0.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.
@@ -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.0 build /home/runner/work/wrelik-kit/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
5
+ CLI Building entry: src/client/index.ts, src/server/index.ts, src/shared/index.ts
6
6
  CLI Using tsconfig: tsconfig.json
7
7
  CLI tsup v8.5.1
8
8
  CLI Target: es2022
9
9
  CLI Cleaning output folder
10
10
  CJS Build start
11
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
12
+ ESM dist/shared/index.mjs 0 B
13
+ ESM dist/client/index.mjs 272.00 B
14
+ ESM dist/server/index.mjs 1.07 KB
15
+ ESM ⚡️ Build success in 76ms
16
+ CJS dist/client/index.js 1.27 KB
17
+ CJS dist/server/index.js 2.18 KB
18
+ CJS dist/shared/index.js 767.00 B
19
+ CJS ⚡️ Build success in 77ms
18
20
  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
21
+ DTS ⚡️ Build success in 5028ms
22
+ DTS dist/client/index.d.ts 77.00 B
23
+ DTS dist/server/index.d.ts 1.32 KB
24
+ DTS dist/shared/index.d.ts 95.00 B
25
+ DTS dist/client/index.d.mts 77.00 B
26
+ DTS dist/server/index.d.mts 1.32 KB
27
+ DTS dist/shared/index.d.mts 95.00 B
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @wrelik/jobs
2
2
 
3
+ ## 2.0.0
4
+
5
+ ### Major Changes
6
+
7
+ - 818ed58: Refactor runtime packages to strict subpath exports (`/server`, `/client`, `/shared`) with side-effect free entrypoints and hard CI/runtime boundary enforcement.
8
+
9
+ ### Minor Changes
10
+
11
+ - 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.
12
+
13
+ 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.
14
+
3
15
  ## 0.1.2
4
16
 
5
17
  ### 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.0",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -9,9 +9,25 @@
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
32
  "inngest": "^3.11.0"
17
33
  },
@@ -21,9 +37,17 @@
21
37
  "@wrelik/eslint-config": "0.1.1",
22
38
  "@wrelik/tsconfig": "0.1.1"
23
39
  },
40
+ "wrelik": {
41
+ "runtimes": [
42
+ "server",
43
+ "client",
44
+ "shared"
45
+ ]
46
+ },
24
47
  "scripts": {
25
- "build": "tsup src/index.ts src/unsupported.ts --format cjs,esm --dts --clean",
48
+ "build": "tsup src/server/index.ts src/client/index.ts src/shared/index.ts --format cjs,esm --dts --clean",
26
49
  "lint": "eslint src/",
50
+ "typecheck": "tsc --noEmit",
27
51
  "test": "vitest run --passWithNoTests"
28
52
  }
29
53
  }
@@ -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,71 @@
1
+ /* eslint-disable no-restricted-imports */
2
+ import { Inngest } from 'inngest';
3
+ import type { JobTrigger } from '../shared';
4
+ export type { JobTrigger } from '../shared';
5
+
6
+ export interface JobsClient {
7
+ send: (payload: { name: string; data: unknown }) => Promise<unknown>;
8
+ createFunction: (config: { id: string }, trigger: JobTrigger, handler: (args: unknown) => Promise<unknown>) => unknown;
9
+ }
10
+
11
+ export function createJobsServer(
12
+ appId: string,
13
+ options?: { client?: JobsClient; createClient?: (appId: string) => JobsClient },
14
+ ) {
15
+ const client =
16
+ options?.client ??
17
+ options?.createClient?.(appId) ??
18
+ ((new Inngest({ id: appId }) as unknown) as JobsClient);
19
+
20
+ return {
21
+ emit(eventName: string, payload: unknown) {
22
+ return client.send({
23
+ name: eventName,
24
+ data: payload,
25
+ });
26
+ },
27
+
28
+ createFunction(name: string, trigger: JobTrigger, handler: (args: unknown) => Promise<unknown>) {
29
+ return client.createFunction({ id: name }, trigger, handler);
30
+ },
31
+ };
32
+ }
33
+
34
+ type JobsServerCompat = ReturnType<typeof createJobsServer>;
35
+
36
+ let jobsSingleton: JobsServerCompat | null = null;
37
+
38
+ function requireJobsSingleton(): JobsServerCompat {
39
+ if (!jobsSingleton) {
40
+ throw new Error(
41
+ '@wrelik/jobs/server compatibility API is not initialized. Call initJobs(appId) before emit/createFunction.',
42
+ );
43
+ }
44
+
45
+ return jobsSingleton;
46
+ }
47
+
48
+ /**
49
+ * @deprecated Temporary DRX compatibility singleton. Prefer createJobsServer(...) and explicit dependency wiring.
50
+ */
51
+ export function initJobs(appId: string, options?: Parameters<typeof createJobsServer>[1]): void {
52
+ jobsSingleton = createJobsServer(appId, options);
53
+ }
54
+
55
+ /**
56
+ * @deprecated Temporary DRX compatibility singleton. Prefer createJobsServer(...).emit(...)
57
+ */
58
+ export function emit(eventName: string, payload: unknown): Promise<unknown> {
59
+ return requireJobsSingleton().emit(eventName, payload);
60
+ }
61
+
62
+ /**
63
+ * @deprecated Temporary DRX compatibility singleton. Prefer createJobsServer(...).createFunction(...)
64
+ */
65
+ export function createFunction(
66
+ name: string,
67
+ trigger: JobTrigger,
68
+ handler: (args: unknown) => Promise<unknown>,
69
+ ): unknown {
70
+ return requireJobsSingleton().createFunction(name, trigger, handler);
71
+ }
@@ -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
- );