Skip to content

Commit

Permalink
Export TriggerOptions from "inngest" import
Browse files Browse the repository at this point in the history
  • Loading branch information
jpwilliams committed Sep 25, 2023
1 parent 77208a4 commit 46ea570
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 6 deletions.
21 changes: 18 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 @@ -366,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 @@ -384,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
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
8 changes: 7 additions & 1 deletion packages/inngest/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -32,4 +37,5 @@ export type {
LogLevel,
RegisterOptions,
TimeStr,
TriggerOptions,
} from "./types";
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 46ea570

Please sign in to comment.