From 8f83265f9785df7bc7c0767d92f0a422a57acc20 Mon Sep 17 00:00:00 2001 From: Jack Williams <1736957+jpwilliams@users.noreply.github.com> Date: Mon, 25 Sep 2023 15:21:13 +0000 Subject: [PATCH 1/4] Export `ProxyLogger` directly --- packages/inngest/etc/inngest.api.md | 21 +++++++++++++++++++++ packages/inngest/src/index.ts | 1 + packages/inngest/src/middleware/logger.ts | 2 ++ 3 files changed, 24 insertions(+) diff --git a/packages/inngest/etc/inngest.api.md b/packages/inngest/etc/inngest.api.md index a945366cd..12c170478 100644 --- a/packages/inngest/etc/inngest.api.md +++ b/packages/inngest/etc/inngest.api.md @@ -286,6 +286,27 @@ export class NonRetriableError extends Error { readonly cause?: unknown; } +// @public +export class ProxyLogger implements Logger { + constructor(logger: Logger); + // (undocumented) + debug(...args: LogArg[]): void; + // (undocumented) + disable(): void; + // (undocumented) + enable(): void; + // (undocumented) + error(...args: LogArg[]): void; + // (undocumented) + flush(): Promise; + // Warning: (ae-forgotten-export) The symbol "LogArg" needs to be exported by the entry point index.d.ts + // + // (undocumented) + info(...args: LogArg[]): void; + // (undocumented) + warn(...args: LogArg[]): void; +} + // @public export enum queryKeys { // (undocumented) diff --git a/packages/inngest/src/index.ts b/packages/inngest/src/index.ts index 20d4aa596..c54f03363 100644 --- a/packages/inngest/src/index.ts +++ b/packages/inngest/src/index.ts @@ -19,6 +19,7 @@ export type { export { NonRetriableError } from "./components/NonRetriableError"; export { headerKeys, internalEvents, queryKeys } from "./helpers/consts"; export type { IsStringLiteral } from "./helpers/types"; +export { ProxyLogger } from "./middleware/logger"; export type { ClientOptions, EventNameFromTrigger, diff --git a/packages/inngest/src/middleware/logger.ts b/packages/inngest/src/middleware/logger.ts index 12fe3cdf1..193fda9c1 100644 --- a/packages/inngest/src/middleware/logger.ts +++ b/packages/inngest/src/middleware/logger.ts @@ -46,6 +46,8 @@ export class DefaultLogger implements Logger { * context, so it doesn't result in duplicated logging. * * And also attempt to allow enough time for the logger to flush all logs. + * + * @public */ export class ProxyLogger implements Logger { readonly #logger: Logger; From 3d1007f151e739e735f4362883d3532eb4211c96 Mon Sep 17 00:00:00 2001 From: Jack Williams <1736957+jpwilliams@users.noreply.github.com> Date: Mon, 25 Sep 2023 15:51:58 +0000 Subject: [PATCH 2/4] Add wildcard exports for v2 that allow directly accessing paths Types are automatically inferred as sibling `.d.ts` files here. See microsoft/TypeScript#53116 for extra pre-latest info --- packages/inngest/package.json | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/inngest/package.json b/packages/inngest/package.json index 41f871ce9..76d8e84c1 100644 --- a/packages/inngest/package.json +++ b/packages/inngest/package.json @@ -93,7 +93,12 @@ "require": "./deno/fresh.js", "import": "./deno/fresh.js", "types": "./deno/fresh.d.ts" - } + }, + "./api/*": "./api/*.js", + "./components": "./components/*.js", + "./deno/*": "./deno/*.js", + "./helpers/*": "./helpers/*.js", + "./middleware/*": "./middleware/*.js" }, "homepage": "https://github.com/inngest/inngest-js#readme", "repository": { From 77208a447f91206656e4a09d09ae7941499d2cbe Mon Sep 17 00:00:00 2001 From: Jack Williams <1736957+jpwilliams@users.noreply.github.com> Date: Mon, 25 Sep 2023 15:55:24 +0000 Subject: [PATCH 3/4] Export `LogArg` required by `ProxyLogger` --- packages/inngest/etc/inngest.api.md | 5 +++-- packages/inngest/src/index.ts | 1 + packages/inngest/src/middleware/logger.ts | 4 +++- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/packages/inngest/etc/inngest.api.md b/packages/inngest/etc/inngest.api.md index 12c170478..5d9c898c0 100644 --- a/packages/inngest/etc/inngest.api.md +++ b/packages/inngest/etc/inngest.api.md @@ -244,6 +244,9 @@ export type LiteralZodEventSchema = z.ZodObject<{ user?: z.AnyZodObject | z.ZodAny; }>; +// @public +export type LogArg = unknown; + // @public export type LogLevel = "fatal" | "error" | "warn" | "info" | "debug" | "silent"; @@ -299,8 +302,6 @@ export class ProxyLogger implements Logger { error(...args: LogArg[]): void; // (undocumented) flush(): Promise; - // Warning: (ae-forgotten-export) The symbol "LogArg" needs to be exported by the entry point index.d.ts - // // (undocumented) info(...args: LogArg[]): void; // (undocumented) diff --git a/packages/inngest/src/index.ts b/packages/inngest/src/index.ts index c54f03363..42d704a25 100644 --- a/packages/inngest/src/index.ts +++ b/packages/inngest/src/index.ts @@ -20,6 +20,7 @@ export { NonRetriableError } from "./components/NonRetriableError"; export { headerKeys, internalEvents, queryKeys } from "./helpers/consts"; export type { IsStringLiteral } from "./helpers/types"; export { ProxyLogger } from "./middleware/logger"; +export type { LogArg } from "./middleware/logger"; export type { ClientOptions, EventNameFromTrigger, diff --git a/packages/inngest/src/middleware/logger.ts b/packages/inngest/src/middleware/logger.ts index 193fda9c1..be2a4f6d7 100644 --- a/packages/inngest/src/middleware/logger.ts +++ b/packages/inngest/src/middleware/logger.ts @@ -7,8 +7,10 @@ * - values used for string interpolation, basically anything * * See https://linear.app/inngest/issue/INN-1342/flush-logs-on-function-exitreturns for more details + * + * @public */ -type LogArg = unknown; +export type LogArg = unknown; /** * Based on https://datatracker.ietf.org/doc/html/rfc5424#autoid-11 From 46ea570ff9ec947e2119643aa63ef2a0787475d9 Mon Sep 17 00:00:00 2001 From: Jack Williams <1736957+jpwilliams@users.noreply.github.com> Date: Mon, 25 Sep 2023 15:58:30 +0000 Subject: [PATCH 4/4] Export `TriggerOptions` from `"inngest"` import --- packages/inngest/etc/inngest.api.md | 21 ++++++++++++++++++--- packages/inngest/src/helpers/types.ts | 10 ++++++++-- packages/inngest/src/index.ts | 8 +++++++- packages/inngest/src/types.ts | 2 ++ 4 files changed, 35 insertions(+), 6 deletions(-) diff --git a/packages/inngest/etc/inngest.api.md b/packages/inngest/etc/inngest.api.md index 5d9c898c0..634e85343 100644 --- a/packages/inngest/etc/inngest.api.md +++ b/packages/inngest/etc/inngest.api.md @@ -29,8 +29,6 @@ export interface ClientOptions { // @public export type Combine, TInc extends StandardEventSchemas> = IsStringLiteral extends true ? Simplify> & StandardEventSchemaToPayload> : StandardEventSchemaToPayload; -// Warning: (ae-forgotten-export) The symbol "TriggerOptions" needs to be exported by the entry point index.d.ts -// // @public export type EventNameFromTrigger, T extends TriggerOptions> = T extends string ? T : T extends { event: string; @@ -366,9 +364,26 @@ export type StandardEventSchemaToPayload = Simplify<{ }; }>; +// @public +export type StrictUnion = StrictUnionHelper; + +// @public +export type StrictUnionHelper = T extends any ? T & Partial, keyof T>, never>> : never; + // @public export type TimeStr = `${`${number}w` | ""}${`${number}d` | ""}${`${number}h` | ""}${`${number}m` | ""}${`${number}s` | ""}`; +// @public +export type TriggerOptions = T | StrictUnion<{ + event: T; + if?: string; +} | { + cron: string; +}>; + +// @public +export type UnionKeys = T extends T ? keyof T : never; + // @public export type ZodEventSchemas = Record = { /** * Returns all keys from objects in the union `T`. + * + * @public */ -type UnionKeys = T extends T ? keyof T : never; +export type UnionKeys = T extends T ? keyof T : never; /** * Enforces strict union comformity by ensuring that all potential keys in a * union of objects are accounted for in every object. * * Requires two generics to be used, so is abstracted by {@link StrictUnion}. + * + * @public */ // eslint-disable-next-line @typescript-eslint/no-explicit-any -type StrictUnionHelper = T extends any +export type StrictUnionHelper = T extends any ? T & Partial, keyof T>, never>> : never; /** * Enforces strict union comformity by ensuring that all potential keys in a * union of objects are accounted for in every object. + * + * @public */ export type StrictUnion = StrictUnionHelper; diff --git a/packages/inngest/src/index.ts b/packages/inngest/src/index.ts index 42d704a25..35f0510c3 100644 --- a/packages/inngest/src/index.ts +++ b/packages/inngest/src/index.ts @@ -18,7 +18,12 @@ export type { } from "./components/InngestMiddleware"; export { NonRetriableError } from "./components/NonRetriableError"; export { headerKeys, internalEvents, queryKeys } from "./helpers/consts"; -export type { IsStringLiteral } from "./helpers/types"; +export type { + IsStringLiteral, + StrictUnion, + StrictUnionHelper, + UnionKeys, +} from "./helpers/types"; export { ProxyLogger } from "./middleware/logger"; export type { LogArg } from "./middleware/logger"; export type { @@ -32,4 +37,5 @@ export type { LogLevel, RegisterOptions, TimeStr, + TriggerOptions, } from "./types"; diff --git a/packages/inngest/src/types.ts b/packages/inngest/src/types.ts index f2186aaa7..868778f0c 100644 --- a/packages/inngest/src/types.ts +++ b/packages/inngest/src/types.ts @@ -615,6 +615,8 @@ export interface InternalRegisterOptions extends RegisterOptions { /** * A user-friendly method of specifying a trigger for an Inngest function. + * + * @public */ export type TriggerOptions = | T