ff-effect 0.0.10 → 0.0.12
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.
- package/dist/for/ai/index.cjs +167 -0
- package/dist/for/ai/index.cjs.map +1 -0
- package/dist/for/ai/index.d.cts +47 -0
- package/dist/for/ai/index.d.ts +47 -0
- package/dist/for/ai/index.js +127 -0
- package/dist/for/ai/index.js.map +1 -0
- package/dist/for/drizzle/index.cjs +3 -3
- package/dist/for/drizzle/index.cjs.map +1 -1
- package/dist/for/drizzle/index.d.cts +2 -2
- package/dist/for/drizzle/index.d.ts +2 -2
- package/dist/for/drizzle/index.js +2 -2
- package/dist/for/drizzle/index.js.map +1 -1
- package/dist/for/inngest/index.cjs +3010 -0
- package/dist/for/inngest/index.cjs.map +1 -0
- package/dist/for/inngest/index.d.cts +73 -0
- package/dist/for/inngest/index.d.ts +73 -0
- package/dist/for/inngest/index.js +2976 -0
- package/dist/for/inngest/index.js.map +1 -0
- package/dist/for/orpc/index.cjs.map +1 -1
- package/dist/for/orpc/index.js.map +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +16 -3
- package/src/extract.ts +7 -6
- package/src/for/ai/index.test.ts +244 -0
- package/src/for/ai/index.ts +200 -0
- package/src/for/ai/schema.ts +20 -0
- package/src/for/drizzle/index.test.ts +8 -8
- package/src/for/drizzle/index.ts +2 -1
- package/src/for/inngest/cron.ts +21 -0
- package/src/for/inngest/index.test.ts +177 -0
- package/src/for/inngest/index.ts +187 -0
- package/src/for/inngest/step.ts +79 -0
- package/src/run-promise-unwrapped.ts +2 -2
- package/src/wrap-client.ts +1 -1
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import * as _effect_platform_HttpServerError from '@effect/platform/HttpServerError';
|
|
2
|
+
import * as effect_Scope from 'effect/Scope';
|
|
3
|
+
import * as effect_Cause from 'effect/Cause';
|
|
4
|
+
import * as effect_Types from 'effect/Types';
|
|
5
|
+
import { HttpApp } from '@effect/platform';
|
|
6
|
+
import { Effect, Duration, Layer, Cron } from 'effect';
|
|
7
|
+
import * as Context from 'effect/Context';
|
|
8
|
+
import { Inngest, GetEvents, GetFunctionInput, InngestFunction } from 'inngest';
|
|
9
|
+
|
|
10
|
+
declare function wrapStep<TStep>(step: TStep): {
|
|
11
|
+
run: <A, E, R>(id: string, fn: () => Effect.Effect<A, E, R>) => Effect.Effect<A, InngestError, R | effect_Scope.Scope>;
|
|
12
|
+
sleep: (id: string, duration: Duration.DurationInput) => Effect.Effect<void, InngestError, never>;
|
|
13
|
+
sleepUntil: (id: string, time: Date | string) => Effect.Effect<void, InngestError, never>;
|
|
14
|
+
invoke: <TResult = unknown>(id: string, opts: unknown) => Effect.Effect<TResult, InngestError>;
|
|
15
|
+
waitForEvent: <TEvent = unknown>(id: string, opts: unknown) => Effect.Effect<TEvent | null, InngestError>;
|
|
16
|
+
sendEvent: (id: string, payload: unknown) => Effect.Effect<{
|
|
17
|
+
ids: string[];
|
|
18
|
+
}, InngestError>;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
declare const TagTypeId: symbol;
|
|
22
|
+
declare const NodeInspectSymbol: symbol;
|
|
23
|
+
declare const InngestError_base: new <A extends Record<string, any> = {}>(args: effect_Types.Equals<A, {}> extends true ? void : { readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }) => effect_Cause.YieldableError & {
|
|
24
|
+
readonly _tag: "ff-effect/InngestError";
|
|
25
|
+
} & Readonly<A>;
|
|
26
|
+
declare class InngestError extends InngestError_base<{
|
|
27
|
+
message: string;
|
|
28
|
+
cause?: unknown;
|
|
29
|
+
}> {
|
|
30
|
+
}
|
|
31
|
+
type AnyInngest = Inngest<any>;
|
|
32
|
+
type CreateFunctionParams<TClient extends AnyInngest> = Parameters<TClient['createFunction']>;
|
|
33
|
+
type FunctionConfig<TClient extends AnyInngest> = CreateFunctionParams<TClient>[0];
|
|
34
|
+
type FunctionTrigger<TClient extends AnyInngest> = CreateFunctionParams<TClient>[1];
|
|
35
|
+
type TriggerInput<TClient extends AnyInngest> = FunctionTrigger<TClient> | CronTrigger;
|
|
36
|
+
type ExtractTriggerName<TClient extends AnyInngest, T> = T extends {
|
|
37
|
+
event: infer E extends keyof GetEvents<TClient, true> & string;
|
|
38
|
+
} ? E : keyof GetEvents<TClient, true> & string;
|
|
39
|
+
type CronTrigger = {
|
|
40
|
+
cron: Cron.Cron;
|
|
41
|
+
};
|
|
42
|
+
type EffectHandlerCtx<TClient extends AnyInngest, TTriggerName extends keyof GetEvents<TClient, true> & string = keyof GetEvents<TClient, true> & string> = Omit<GetFunctionInput<TClient, TTriggerName>, 'step'> & {
|
|
43
|
+
step: ReturnType<typeof wrapStep<unknown>>;
|
|
44
|
+
};
|
|
45
|
+
declare const defaultPrefix: "@ff-effect/Inngest";
|
|
46
|
+
declare function createInngest<TClient extends AnyInngest, E, R, T extends string = typeof defaultPrefix>(createClient: Effect.Effect<TClient, E, R>, opts?: {
|
|
47
|
+
tagId?: T;
|
|
48
|
+
}): {
|
|
49
|
+
Tag: Context.TagClass<T, T, TClient>;
|
|
50
|
+
layer: Layer.Layer<T, E, R>;
|
|
51
|
+
createFunction: <TTrigger extends TriggerInput<TClient>, A, EH, RH>(config: FunctionConfig<TClient>, trigger: TTrigger, handler: (ctx: EffectHandlerCtx<TClient, ExtractTriggerName<TClient, TTrigger>>) => Effect.Effect<A, EH, RH>) => Effect.Effect<InngestFunction.Any, never, T | effect_Scope.Scope | Exclude<RH, never>>;
|
|
52
|
+
send: (payload: Parameters<TClient["send"]>[0]) => Effect.Effect<{
|
|
53
|
+
ids: string[];
|
|
54
|
+
}, InngestError, T>;
|
|
55
|
+
fetchHandler: (httpOpts: {
|
|
56
|
+
functions: InngestFunction.Any[];
|
|
57
|
+
servePath?: string;
|
|
58
|
+
signingKey?: string;
|
|
59
|
+
signingKeyFallback?: string;
|
|
60
|
+
logLevel?: "fatal" | "error" | "warn" | "info" | "debug" | "silent";
|
|
61
|
+
streaming?: "allow" | "force" | false;
|
|
62
|
+
}) => Effect.Effect<(req: Request) => Promise<Response>, never, T>;
|
|
63
|
+
httpHandler: (httpOpts: {
|
|
64
|
+
functions: InngestFunction.Any[];
|
|
65
|
+
servePath?: string;
|
|
66
|
+
signingKey?: string;
|
|
67
|
+
signingKeyFallback?: string;
|
|
68
|
+
logLevel?: "fatal" | "error" | "warn" | "info" | "debug" | "silent";
|
|
69
|
+
streaming?: "allow" | "force" | false;
|
|
70
|
+
}) => Effect.Effect<HttpApp.Default<_effect_platform_HttpServerError.HttpServerError, never>, never, T>;
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
export { InngestError, NodeInspectSymbol, TagTypeId, createInngest };
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import * as _effect_platform_HttpServerError from '@effect/platform/HttpServerError';
|
|
2
|
+
import * as effect_Scope from 'effect/Scope';
|
|
3
|
+
import * as effect_Cause from 'effect/Cause';
|
|
4
|
+
import * as effect_Types from 'effect/Types';
|
|
5
|
+
import { HttpApp } from '@effect/platform';
|
|
6
|
+
import { Effect, Duration, Layer, Cron } from 'effect';
|
|
7
|
+
import * as Context from 'effect/Context';
|
|
8
|
+
import { Inngest, GetEvents, GetFunctionInput, InngestFunction } from 'inngest';
|
|
9
|
+
|
|
10
|
+
declare function wrapStep<TStep>(step: TStep): {
|
|
11
|
+
run: <A, E, R>(id: string, fn: () => Effect.Effect<A, E, R>) => Effect.Effect<A, InngestError, R | effect_Scope.Scope>;
|
|
12
|
+
sleep: (id: string, duration: Duration.DurationInput) => Effect.Effect<void, InngestError, never>;
|
|
13
|
+
sleepUntil: (id: string, time: Date | string) => Effect.Effect<void, InngestError, never>;
|
|
14
|
+
invoke: <TResult = unknown>(id: string, opts: unknown) => Effect.Effect<TResult, InngestError>;
|
|
15
|
+
waitForEvent: <TEvent = unknown>(id: string, opts: unknown) => Effect.Effect<TEvent | null, InngestError>;
|
|
16
|
+
sendEvent: (id: string, payload: unknown) => Effect.Effect<{
|
|
17
|
+
ids: string[];
|
|
18
|
+
}, InngestError>;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
declare const TagTypeId: symbol;
|
|
22
|
+
declare const NodeInspectSymbol: symbol;
|
|
23
|
+
declare const InngestError_base: new <A extends Record<string, any> = {}>(args: effect_Types.Equals<A, {}> extends true ? void : { readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }) => effect_Cause.YieldableError & {
|
|
24
|
+
readonly _tag: "ff-effect/InngestError";
|
|
25
|
+
} & Readonly<A>;
|
|
26
|
+
declare class InngestError extends InngestError_base<{
|
|
27
|
+
message: string;
|
|
28
|
+
cause?: unknown;
|
|
29
|
+
}> {
|
|
30
|
+
}
|
|
31
|
+
type AnyInngest = Inngest<any>;
|
|
32
|
+
type CreateFunctionParams<TClient extends AnyInngest> = Parameters<TClient['createFunction']>;
|
|
33
|
+
type FunctionConfig<TClient extends AnyInngest> = CreateFunctionParams<TClient>[0];
|
|
34
|
+
type FunctionTrigger<TClient extends AnyInngest> = CreateFunctionParams<TClient>[1];
|
|
35
|
+
type TriggerInput<TClient extends AnyInngest> = FunctionTrigger<TClient> | CronTrigger;
|
|
36
|
+
type ExtractTriggerName<TClient extends AnyInngest, T> = T extends {
|
|
37
|
+
event: infer E extends keyof GetEvents<TClient, true> & string;
|
|
38
|
+
} ? E : keyof GetEvents<TClient, true> & string;
|
|
39
|
+
type CronTrigger = {
|
|
40
|
+
cron: Cron.Cron;
|
|
41
|
+
};
|
|
42
|
+
type EffectHandlerCtx<TClient extends AnyInngest, TTriggerName extends keyof GetEvents<TClient, true> & string = keyof GetEvents<TClient, true> & string> = Omit<GetFunctionInput<TClient, TTriggerName>, 'step'> & {
|
|
43
|
+
step: ReturnType<typeof wrapStep<unknown>>;
|
|
44
|
+
};
|
|
45
|
+
declare const defaultPrefix: "@ff-effect/Inngest";
|
|
46
|
+
declare function createInngest<TClient extends AnyInngest, E, R, T extends string = typeof defaultPrefix>(createClient: Effect.Effect<TClient, E, R>, opts?: {
|
|
47
|
+
tagId?: T;
|
|
48
|
+
}): {
|
|
49
|
+
Tag: Context.TagClass<T, T, TClient>;
|
|
50
|
+
layer: Layer.Layer<T, E, R>;
|
|
51
|
+
createFunction: <TTrigger extends TriggerInput<TClient>, A, EH, RH>(config: FunctionConfig<TClient>, trigger: TTrigger, handler: (ctx: EffectHandlerCtx<TClient, ExtractTriggerName<TClient, TTrigger>>) => Effect.Effect<A, EH, RH>) => Effect.Effect<InngestFunction.Any, never, T | effect_Scope.Scope | Exclude<RH, never>>;
|
|
52
|
+
send: (payload: Parameters<TClient["send"]>[0]) => Effect.Effect<{
|
|
53
|
+
ids: string[];
|
|
54
|
+
}, InngestError, T>;
|
|
55
|
+
fetchHandler: (httpOpts: {
|
|
56
|
+
functions: InngestFunction.Any[];
|
|
57
|
+
servePath?: string;
|
|
58
|
+
signingKey?: string;
|
|
59
|
+
signingKeyFallback?: string;
|
|
60
|
+
logLevel?: "fatal" | "error" | "warn" | "info" | "debug" | "silent";
|
|
61
|
+
streaming?: "allow" | "force" | false;
|
|
62
|
+
}) => Effect.Effect<(req: Request) => Promise<Response>, never, T>;
|
|
63
|
+
httpHandler: (httpOpts: {
|
|
64
|
+
functions: InngestFunction.Any[];
|
|
65
|
+
servePath?: string;
|
|
66
|
+
signingKey?: string;
|
|
67
|
+
signingKeyFallback?: string;
|
|
68
|
+
logLevel?: "fatal" | "error" | "warn" | "info" | "debug" | "silent";
|
|
69
|
+
streaming?: "allow" | "force" | false;
|
|
70
|
+
}) => Effect.Effect<HttpApp.Default<_effect_platform_HttpServerError.HttpServerError, never>, never, T>;
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
export { InngestError, NodeInspectSymbol, TagTypeId, createInngest };
|