Skip to content

Commit

Permalink
Hotfix: Export ProxyLogger directly (#324)
Browse files Browse the repository at this point in the history
## Summary
<!-- Succinctly describe your change, providing context, what you've
changed, and why. -->

Export various types and calsses directly to ensure those adhering to
ESM `exports` can use it.

Also add wildcard exports, though in v3 we track all explicit exports to
ensure API breakages don't occur with API Extractor.

## Checklist
<!-- Tick these items off as you progress. -->
<!-- If an item isn't applicable, ideally please strikeout the item by
wrapping it in "~~"" and suffix it with "N/A My reason for skipping
this." -->
<!-- e.g. "- [ ] ~~Added tests~~ N/A Only touches docs" -->

- [ ] ~~Added a [docs PR](https://github.com/inngest/website) that
references this PR~~ N/A Hotfix
- [ ] ~~Added unit/integration tests~~ N/A
- [ ] Added changesets if applicable
  • Loading branch information
jpwilliams authored Sep 25, 2023
1 parent f35922a commit e816d80
Show file tree
Hide file tree
Showing 6 changed files with 70 additions and 8 deletions.
43 changes: 40 additions & 3 deletions packages/inngest/etc/inngest.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@ export interface ClientOptions {
// @public
export type Combine<TCurr extends Record<string, EventPayload>, TInc extends StandardEventSchemas> = IsStringLiteral<keyof TCurr & string> extends true ? Simplify<Omit<TCurr, keyof StandardEventSchemaToPayload<TInc>> & StandardEventSchemaToPayload<TInc>> : StandardEventSchemaToPayload<TInc>;

// Warning: (ae-forgotten-export) The symbol "TriggerOptions" needs to be exported by the entry point index.d.ts
//
// @public
export type EventNameFromTrigger<Events extends Record<string, EventPayload>, T extends TriggerOptions<keyof Events & string>> = T extends string ? T : T extends {
event: string;
Expand Down Expand Up @@ -244,6 +242,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";

Expand Down Expand Up @@ -286,6 +287,25 @@ 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<void>;
// (undocumented)
info(...args: LogArg[]): void;
// (undocumented)
warn(...args: LogArg[]): void;
}

// @public
export enum queryKeys {
// (undocumented)
Expand Down Expand Up @@ -344,9 +364,26 @@ export type StandardEventSchemaToPayload<T> = Simplify<{
};
}>;

// @public
export type StrictUnion<T> = StrictUnionHelper<T, T>;

// @public
export type StrictUnionHelper<T, TAll> = T extends any ? T & Partial<Record<Exclude<UnionKeys<TAll>, keyof T>, never>> : never;

// @public
export type TimeStr = `${`${number}w` | ""}${`${number}d` | ""}${`${number}h` | ""}${`${number}m` | ""}${`${number}s` | ""}`;

// @public
export type TriggerOptions<T extends string> = T | StrictUnion<{
event: T;
if?: string;
} | {
cron: string;
}>;

// @public
export type UnionKeys<T> = T extends T ? keyof T : never;

// @public
export type ZodEventSchemas = Record<string, {
data?: z.AnyZodObject | z.ZodAny;
Expand All @@ -362,7 +399,7 @@ export type ZodEventSchemas = Record<string, {
// src/components/InngestMiddleware.ts:332:5 - (ae-forgotten-export) The symbol "MiddlewareSendEventInput" needs to be exported by the entry point index.d.ts
// src/components/InngestMiddleware.ts:342:5 - (ae-forgotten-export) The symbol "MiddlewareSendEventOutput" needs to be exported by the entry point index.d.ts
// src/types.ts:51:5 - (ae-forgotten-export) The symbol "failureEventErrorSchema" needs to be exported by the entry point index.d.ts
// src/types.ts:693:5 - (ae-forgotten-export) The symbol "TimeStrBatch" needs to be exported by the entry point index.d.ts
// src/types.ts:695:5 - (ae-forgotten-export) The symbol "TimeStrBatch" needs to be exported by the entry point index.d.ts

// (No @packageDocumentation comment for this package)

Expand Down
7 changes: 6 additions & 1 deletion packages/inngest/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
10 changes: 8 additions & 2 deletions packages/inngest/src/helpers/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,23 +91,29 @@ export type KeysNotOfType<T, U> = {

/**
* Returns all keys from objects in the union `T`.
*
* @public
*/
type UnionKeys<T> = T extends T ? keyof T : never;
export type UnionKeys<T> = 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, TAll> = T extends any
export type StrictUnionHelper<T, TAll> = T extends any
? T & Partial<Record<Exclude<UnionKeys<TAll>, 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<T> = StrictUnionHelper<T, T>;

Expand Down
10 changes: 9 additions & 1 deletion packages/inngest/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,14 @@ 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 {
ClientOptions,
EventNameFromTrigger,
Expand All @@ -30,4 +37,5 @@ export type {
LogLevel,
RegisterOptions,
TimeStr,
TriggerOptions,
} from "./types";
6 changes: 5 additions & 1 deletion packages/inngest/src/middleware/logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -46,6 +48,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;
Expand Down
2 changes: 2 additions & 0 deletions packages/inngest/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 extends string> =
| T
Expand Down

0 comments on commit e816d80

Please sign in to comment.