effect-inngest 0.1.3 → 0.3.0-beta.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.
- package/README.md +89 -67
- package/dist/Client.d.ts +76 -28
- package/dist/Client.js +92 -30
- package/dist/Event.d.ts +43 -0
- package/dist/Event.js +46 -0
- package/dist/Events.d.ts +48 -76
- package/dist/Events.js +18 -23
- package/dist/Function.d.ts +46 -19
- package/dist/Function.js +32 -22
- package/dist/Group.d.ts +19 -8
- package/dist/Group.js +30 -72
- package/dist/HttpApi.d.ts +51 -56
- package/dist/HttpApi.js +38 -21
- package/dist/_virtual/_rolldown/runtime.js +13 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.js +3 -3
- package/dist/internal/checkpoint/Config.d.ts +10 -0
- package/dist/internal/checkpoint/Config.js +29 -0
- package/dist/internal/checkpoint/Error.d.ts +11 -0
- package/dist/internal/checkpoint/Error.js +8 -0
- package/dist/internal/checkpoint/State.d.ts +1 -0
- package/dist/internal/checkpoint/State.js +54 -0
- package/dist/internal/checkpoint.d.ts +2 -0
- package/dist/internal/codec/EventPayload.d.ts +6 -0
- package/dist/internal/codec/EventPayload.js +60 -0
- package/dist/internal/codec/StepResult.js +55 -0
- package/dist/internal/domain/ExecutionInput.d.ts +40 -0
- package/dist/internal/domain/ExecutionInput.js +57 -0
- package/dist/internal/domain/ExecutionSuspension.d.ts +34 -0
- package/dist/internal/domain/ExecutionSuspension.js +64 -0
- package/dist/internal/domain/FunctionDefinition.js +13 -0
- package/dist/internal/domain/Memo.d.ts +22 -0
- package/dist/internal/domain/Memo.js +18 -0
- package/dist/internal/domain/StepCommand.d.ts +79 -0
- package/dist/internal/domain/StepCommand.js +124 -0
- package/dist/internal/domain/StepInfo.d.ts +12 -0
- package/dist/internal/domain/StepInfo.js +10 -0
- package/dist/internal/domain/StepInput.d.ts +10 -0
- package/dist/internal/driver.js +15 -114
- package/dist/internal/errors.d.ts +21 -48
- package/dist/internal/errors.js +9 -44
- package/dist/internal/execution/CheckpointRun.js +25 -0
- package/dist/internal/execution/ExecutionFailure.js +19 -0
- package/dist/internal/execution/ExecutionHeaders.js +58 -0
- package/dist/internal/execution/ExecutionResponse.js +68 -0
- package/dist/internal/execution/ExecutionResult.js +56 -0
- package/dist/internal/execution/ExecutionScope.js +30 -0
- package/dist/internal/execution/HandlerRun.js +16 -0
- package/dist/internal/handler.d.ts +5 -16
- package/dist/internal/handler.js +128 -96
- package/dist/internal/protocol.d.ts +143 -1
- package/dist/internal/protocol.js +333 -138
- package/dist/internal/runtime/CheckpointContext.js +5 -0
- package/dist/internal/runtime/HandlerContext.d.ts +13 -0
- package/dist/internal/runtime/HandlerContext.js +19 -0
- package/dist/internal/runtime/HandlerFiberScope.d.ts +10 -0
- package/dist/internal/runtime/HandlerFiberScope.js +5 -0
- package/dist/internal/runtime/StepCommandBus.d.ts +27 -0
- package/dist/internal/runtime/StepCommandBus.js +76 -0
- package/dist/internal/runtime/StepIdentity.d.ts +27 -0
- package/dist/internal/runtime/StepIdentity.js +46 -0
- package/dist/internal/runtime/StepTools.d.ts +83 -0
- package/dist/internal/runtime/StepTools.js +76 -0
- package/dist/internal/runtime/steps/InvokeStep.js +43 -0
- package/dist/internal/runtime/steps/SendEventStep.js +46 -0
- package/dist/internal/runtime/steps/SleepStep.js +22 -0
- package/dist/internal/runtime/steps/SleepUntilStep.js +22 -0
- package/dist/internal/runtime/steps/StepRun.js +48 -0
- package/dist/internal/runtime/steps/WaitForEventStep.js +27 -0
- package/dist/internal/serve/HttpApp.js +71 -0
- package/dist/internal/serve/Request.js +23 -0
- package/dist/internal/serve/Signature.d.ts +11 -0
- package/dist/internal/serve/Signature.js +123 -0
- package/dist/internal/wire/Duration.js +19 -0
- package/dist/internal/wire/Timestamp.js +14 -0
- package/package.json +34 -22
- package/src/Client.ts +269 -91
- package/src/Event.ts +107 -0
- package/src/Events.ts +50 -30
- package/src/Function.ts +102 -46
- package/src/Group.ts +56 -108
- package/src/HttpApi.ts +40 -30
- package/src/index.ts +21 -11
- package/src/internal/checkpoint/Config.ts +74 -0
- package/src/internal/checkpoint/Error.ts +6 -0
- package/src/internal/checkpoint/State.ts +107 -0
- package/src/internal/checkpoint.ts +3 -0
- package/src/internal/codec/EventPayload.ts +98 -0
- package/src/internal/codec/StepResult.ts +95 -0
- package/src/internal/domain/ExecutionInput.ts +66 -0
- package/src/internal/domain/ExecutionSuspension.ts +79 -0
- package/src/internal/domain/FunctionDefinition.ts +30 -0
- package/src/internal/domain/Memo.ts +28 -0
- package/src/internal/domain/StepCommand.ts +166 -0
- package/src/internal/domain/StepInfo.ts +8 -0
- package/src/internal/domain/StepInput.ts +10 -0
- package/src/internal/driver.ts +27 -185
- package/src/internal/errors.ts +14 -108
- package/src/internal/execution/CheckpointRun.ts +33 -0
- package/src/internal/execution/ExecutionFailure.ts +19 -0
- package/src/internal/execution/ExecutionHeaders.ts +86 -0
- package/src/internal/execution/ExecutionResponse.ts +79 -0
- package/src/internal/execution/ExecutionResult.ts +57 -0
- package/src/internal/execution/ExecutionScope.ts +41 -0
- package/src/internal/execution/HandlerRun.ts +38 -0
- package/src/internal/handler.ts +222 -172
- package/src/internal/protocol.ts +289 -78
- package/src/internal/runtime/CheckpointContext.ts +7 -0
- package/src/internal/runtime/HandlerContext.ts +21 -0
- package/src/internal/runtime/HandlerFiberScope.ts +9 -0
- package/src/internal/runtime/StepCommandBus.ts +129 -0
- package/src/internal/runtime/StepIdentity.ts +67 -0
- package/src/internal/runtime/StepTools.ts +161 -0
- package/src/internal/runtime/steps/InvokeStep.ts +71 -0
- package/src/internal/runtime/steps/SendEventStep.ts +67 -0
- package/src/internal/runtime/steps/SleepStep.ts +34 -0
- package/src/internal/runtime/steps/SleepUntilStep.ts +34 -0
- package/src/internal/runtime/steps/StepRun.ts +95 -0
- package/src/internal/runtime/steps/WaitForEventStep.ts +55 -0
- package/src/internal/serve/HttpApp.ts +123 -0
- package/src/internal/serve/Request.ts +27 -0
- package/src/internal/serve/Signature.ts +170 -0
- package/src/internal/wire/Duration.ts +31 -0
- package/src/internal/wire/Timestamp.ts +11 -0
- package/dist/_virtual/rolldown_runtime.js +0 -18
- package/dist/internal/constants.js +0 -15
- package/dist/internal/driver.d.ts +0 -5
- package/dist/internal/helpers.js +0 -44
- package/dist/internal/interrupts.d.ts +0 -2
- package/dist/internal/interrupts.js +0 -45
- package/dist/internal/memo.js +0 -56
- package/dist/internal/signature.d.ts +0 -18
- package/dist/internal/signature.js +0 -97
- package/dist/internal/step.d.ts +0 -59
- package/dist/internal/step.js +0 -192
- package/src/internal/constants.ts +0 -11
- package/src/internal/helpers.ts +0 -58
- package/src/internal/interrupts.ts +0 -62
- package/src/internal/memo.ts +0 -73
- package/src/internal/signature.ts +0 -158
- package/src/internal/step.ts +0 -394
package/dist/internal/handler.js
CHANGED
|
@@ -1,145 +1,177 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { resolveConfig } from "./checkpoint/Config.js";
|
|
2
|
+
import { Headers, RegisterServerResponse, SDKRequestBody, SDKRequestContext, UserError } from "./protocol.js";
|
|
3
|
+
import "./serve/Signature.js";
|
|
2
4
|
import { InngestClient } from "../Client.js";
|
|
3
|
-
import {
|
|
5
|
+
import { schemaBodyJson, verifySignature } from "./serve/Request.js";
|
|
4
6
|
import { execute } from "./driver.js";
|
|
5
|
-
import
|
|
6
|
-
import "
|
|
7
|
-
import "effect/
|
|
8
|
-
import * as
|
|
9
|
-
import
|
|
10
|
-
import * as HttpClientRequest from "@effect/platform/HttpClientRequest";
|
|
11
|
-
import * as HttpClientResponse from "@effect/platform/HttpClientResponse";
|
|
12
|
-
import * as Predicate from "effect/Predicate";
|
|
13
|
-
|
|
7
|
+
import { Cause, Effect, Option, Predicate, Schema } from "effect";
|
|
8
|
+
import * as HttpClient from "effect/unstable/http/HttpClient";
|
|
9
|
+
import * as HttpClientRequest from "effect/unstable/http/HttpClientRequest";
|
|
10
|
+
import * as HttpClientResponse from "effect/unstable/http/HttpClientResponse";
|
|
11
|
+
import "effect/unstable/http/HttpServerRequest";
|
|
14
12
|
//#region src/internal/handler.ts
|
|
15
|
-
|
|
16
|
-
* Internal handler implementation.
|
|
17
|
-
* @internal
|
|
18
|
-
*/
|
|
19
|
-
var InvalidRequestError = class extends Schema.TaggedError()("InvalidRequestError", { message: Schema.String }) {};
|
|
13
|
+
var InvalidRequestError = class extends Schema.TaggedErrorClass()("InvalidRequestError", { message: Schema.String }) {};
|
|
20
14
|
const SDK_VERSION = "2.0.0";
|
|
21
|
-
const baseHeaders = () => ({
|
|
15
|
+
const baseHeaders = (framework) => ({
|
|
22
16
|
"Content-Type": "application/json",
|
|
17
|
+
"User-Agent": `effect-inngest:v${SDK_VERSION}`,
|
|
23
18
|
[Headers.SDK]: `effect-inngest:v${SDK_VERSION}`,
|
|
24
|
-
[Headers.
|
|
19
|
+
[Headers.SDKHandled]: "true",
|
|
20
|
+
[Headers.RequestVersion]: "2",
|
|
21
|
+
...framework ? { [Headers.Framework]: framework } : {}
|
|
25
22
|
});
|
|
26
|
-
const buildServeUrl = (
|
|
27
|
-
const url = new URL(requestUrl);
|
|
28
|
-
if (servePath) url.pathname = servePath;
|
|
29
|
-
if (serveHost) return new URL(url.pathname + url.search, serveHost);
|
|
23
|
+
const buildServeUrl = (args) => {
|
|
24
|
+
const url = new URL(args.requestUrl);
|
|
25
|
+
if (args.servePath) url.pathname = args.servePath;
|
|
26
|
+
if (args.serveHost) return new URL(url.pathname + url.search, args.serveHost);
|
|
30
27
|
return url;
|
|
31
28
|
};
|
|
32
|
-
const verifyAndParseRequestBody =
|
|
33
|
-
const
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
yield* sig.verify({
|
|
39
|
-
body: new TextEncoder().encode(bodyText),
|
|
40
|
-
signatureHeader: request.headers[Headers.Signature.toLowerCase()],
|
|
41
|
-
signingKey: config.signingKey,
|
|
42
|
-
signingKeyFallback: config.signingKeyFallback,
|
|
43
|
-
isDev
|
|
44
|
-
});
|
|
45
|
-
return yield* Schema.decodeUnknown(Schema.parseJson(SDKRequestBody))(bodyText).pipe(Effect.mapError((error) => new InvalidRequestError({ message: `Invalid request body: ${String(error)}` })));
|
|
29
|
+
const verifyAndParseRequestBody = Effect.fn("effect-inngest/handler/verifyAndParseRequestBody")(function* (request) {
|
|
30
|
+
const body = yield* request.arrayBuffer.pipe(Effect.map((buffer) => new Uint8Array(buffer)), Effect.mapError((error) => {
|
|
31
|
+
return new InvalidRequestError({ message: `Failed to read request body: ${Predicate.hasProperty(error, "message") && Predicate.isString(error.message) ? error.message : "unknown"}` });
|
|
32
|
+
}));
|
|
33
|
+
yield* verifySignature(body, request);
|
|
34
|
+
return yield* schemaBodyJson(SDKRequestBody)(body).pipe(Effect.mapError((error) => new InvalidRequestError({ message: `Invalid request body: ${String(error)}` })));
|
|
46
35
|
});
|
|
47
|
-
const handleIntrospection =
|
|
36
|
+
const handleIntrospection = Effect.fn("effect-inngest/handler/handleIntrospection")(function* (group, _requestUrl) {
|
|
48
37
|
const client = yield* InngestClient;
|
|
49
38
|
const config = client.config;
|
|
50
39
|
const body = {
|
|
40
|
+
extra: { native_crypto: globalThis.crypto?.subtle ? true : false },
|
|
41
|
+
has_event_key: Predicate.isNotUndefined(config.eventKey),
|
|
42
|
+
has_signing_key: Predicate.isNotUndefined(config.signingKey),
|
|
51
43
|
function_count: group.functions.size,
|
|
52
|
-
has_event_key: config.eventKey !== void 0,
|
|
53
|
-
has_signing_key: config.signingKey !== void 0,
|
|
54
|
-
has_signing_key_fallback: config.signingKeyFallback !== void 0,
|
|
55
44
|
mode: client.mode === "dev" ? "dev" : "cloud",
|
|
56
|
-
schema_version: "2024-05-24"
|
|
57
|
-
authentication_succeeded: null
|
|
45
|
+
schema_version: "2024-05-24"
|
|
58
46
|
};
|
|
59
47
|
return {
|
|
60
48
|
status: 200,
|
|
61
|
-
headers: baseHeaders(),
|
|
49
|
+
headers: baseHeaders(config.framework),
|
|
62
50
|
body
|
|
63
51
|
};
|
|
64
52
|
});
|
|
65
|
-
const
|
|
66
|
-
url: Schema.String,
|
|
67
|
-
v: Schema.String,
|
|
68
|
-
deployType: Schema.Literal("ping"),
|
|
69
|
-
sdk: Schema.String,
|
|
70
|
-
appName: Schema.String,
|
|
71
|
-
framework: Schema.String,
|
|
72
|
-
functions: Schema.Array(Schema.Unknown)
|
|
73
|
-
});
|
|
74
|
-
const handleRegistration = (group, requestUrl) => Effect.gen(function* () {
|
|
53
|
+
const handleRegistration = Effect.fn("effect-inngest/handler/handleRegistration")(function* (group, requestUrl) {
|
|
75
54
|
const client = yield* InngestClient;
|
|
76
55
|
const httpClient = yield* HttpClient.HttpClient;
|
|
77
56
|
const config = client.config;
|
|
78
|
-
const url = buildServeUrl(
|
|
57
|
+
const url = buildServeUrl({
|
|
58
|
+
requestUrl,
|
|
59
|
+
serveHost: config.serveHost,
|
|
60
|
+
servePath: config.servePath
|
|
61
|
+
});
|
|
79
62
|
const functions = Array.from(group.functions.values()).map((fn) => fn.toRegistration({
|
|
80
63
|
appId: config.id,
|
|
81
64
|
url: url.href
|
|
82
65
|
}));
|
|
66
|
+
const framework = config.framework;
|
|
83
67
|
const registerUrl = new URL("fn/register", client.apiBaseUrl).toString();
|
|
84
|
-
const
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
68
|
+
const registerHeaders = baseHeaders(framework);
|
|
69
|
+
delete registerHeaders[Headers.RequestVersion];
|
|
70
|
+
const request = HttpClientRequest.post(registerUrl).pipe(HttpClientRequest.setHeaders({
|
|
71
|
+
...registerHeaders,
|
|
72
|
+
Authorization: `Bearer ${config.signingKey ?? ""}`,
|
|
73
|
+
[Headers.SyncKind]: "out_of_band"
|
|
74
|
+
}), HttpClientRequest.bodyJsonUnsafe({
|
|
88
75
|
url: url.href,
|
|
89
|
-
v: "0.1",
|
|
90
76
|
deployType: "ping",
|
|
91
|
-
|
|
77
|
+
...framework ? { framework } : {},
|
|
92
78
|
appName: config.id,
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
};
|
|
79
|
+
functions,
|
|
80
|
+
sdk: `effect-inngest:v${SDK_VERSION}`,
|
|
81
|
+
v: "0.1",
|
|
82
|
+
capabilities: {
|
|
83
|
+
trust_probe: "v1",
|
|
84
|
+
connect: "v1"
|
|
85
|
+
}
|
|
86
|
+
}));
|
|
87
|
+
return yield* Effect.gen(function* () {
|
|
88
|
+
const response = yield* httpClient.execute(request).pipe(Effect.scoped);
|
|
89
|
+
const responseBody = yield* HttpClientResponse.schemaBodyJson(RegisterServerResponse)(response).pipe(Effect.catch((error) => Effect.succeed({ error: `Invalid registration response: ${String(error)}` })));
|
|
90
|
+
if (response.status !== 200 || !Predicate.hasProperty(responseBody, "ok")) return {
|
|
91
|
+
status: 500,
|
|
92
|
+
headers: baseHeaders(config.framework),
|
|
93
|
+
body: {
|
|
94
|
+
message: Predicate.hasProperty(responseBody, "error") && responseBody.error ? responseBody.error : `Registration failed with status ${response.status}`,
|
|
95
|
+
modified: false
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
return {
|
|
99
|
+
status: 200,
|
|
100
|
+
headers: {
|
|
101
|
+
...baseHeaders(config.framework),
|
|
102
|
+
[Headers.SyncKind]: "out_of_band"
|
|
103
|
+
},
|
|
104
|
+
body: {
|
|
105
|
+
message: "Successfully registered",
|
|
106
|
+
modified: responseBody.modified ?? false
|
|
107
|
+
}
|
|
108
|
+
};
|
|
109
|
+
}).pipe(Effect.catchCause((cause) => {
|
|
110
|
+
const errorOpt = Cause.findErrorOption(cause);
|
|
111
|
+
const dieReason = cause.reasons.find(Cause.isDieReason);
|
|
112
|
+
const message = Option.isSome(errorOpt) ? Predicate.hasProperty(errorOpt.value, "message") && Predicate.isString(errorOpt.value.message) ? errorOpt.value.message : "Registration failed" : dieReason ? Predicate.hasProperty(dieReason.defect, "message") && Predicate.isString(dieReason.defect.message) ? dieReason.defect.message : "Registration failed" : "Registration failed";
|
|
113
|
+
return Effect.succeed({
|
|
114
|
+
status: 500,
|
|
115
|
+
headers: baseHeaders(config.framework),
|
|
116
|
+
body: {
|
|
117
|
+
message,
|
|
118
|
+
modified: false
|
|
119
|
+
}
|
|
120
|
+
});
|
|
121
|
+
}));
|
|
101
122
|
});
|
|
102
|
-
const handleExecution =
|
|
123
|
+
const handleExecution = Effect.fn("effect-inngest/handler/handleExecution")(function* (args) {
|
|
103
124
|
const client = yield* InngestClient;
|
|
104
125
|
const context = yield* Effect.context();
|
|
105
|
-
const
|
|
106
|
-
const
|
|
107
|
-
const
|
|
108
|
-
const
|
|
109
|
-
const entry = fn ? context.unsafeMap.get(fn.key) : void 0;
|
|
126
|
+
const prefix = `${client.config.id}-`;
|
|
127
|
+
const fnTag = args.fnId.startsWith(prefix) ? args.fnId.slice(prefix.length) : args.fnId;
|
|
128
|
+
const fn = args.group.functions.get(fnTag);
|
|
129
|
+
const entry = fn ? context.mapUnsafe.get(fn.key) : void 0;
|
|
110
130
|
if (!fn || !entry) return {
|
|
111
|
-
status:
|
|
131
|
+
status: 500,
|
|
112
132
|
headers: {
|
|
113
|
-
...baseHeaders(),
|
|
114
|
-
[Headers.NoRetry]: "
|
|
133
|
+
...baseHeaders(client.config.framework),
|
|
134
|
+
[Headers.NoRetry]: "false"
|
|
115
135
|
},
|
|
116
|
-
body:
|
|
136
|
+
body: UserError.make({
|
|
117
137
|
name: "FunctionNotFoundError",
|
|
118
|
-
message: `Unknown function: ${fnId}`
|
|
119
|
-
})
|
|
138
|
+
message: `Unknown function: ${args.fnId}`
|
|
139
|
+
})
|
|
120
140
|
};
|
|
121
|
-
const
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
141
|
+
const requestedStepId = args.urlStepId === "step" ? void 0 : args.urlStepId;
|
|
142
|
+
const effectiveBody = requestedStepId && requestedStepId !== args.body.ctx.step_id ? SDKRequestBody.make({
|
|
143
|
+
event: args.body.event,
|
|
144
|
+
events: args.body.events,
|
|
145
|
+
steps: args.body.steps,
|
|
125
146
|
ctx: SDKRequestContext.make({
|
|
126
|
-
fn_id: body.ctx.fn_id,
|
|
127
|
-
run_id: body.ctx.run_id,
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
147
|
+
fn_id: args.body.ctx.fn_id,
|
|
148
|
+
run_id: args.body.ctx.run_id,
|
|
149
|
+
env: args.body.ctx.env,
|
|
150
|
+
step_id: requestedStepId,
|
|
151
|
+
attempt: args.body.ctx.attempt,
|
|
152
|
+
max_attempts: args.body.ctx.max_attempts,
|
|
153
|
+
qi_id: args.body.ctx.qi_id,
|
|
154
|
+
...Predicate.isNotUndefined(args.body.ctx.request_id) ? { request_id: args.body.ctx.request_id } : {},
|
|
155
|
+
...Predicate.isNotUndefined(args.body.ctx.generation_id) ? { generation_id: args.body.ctx.generation_id } : {},
|
|
156
|
+
disable_immediate_execution: args.body.ctx.disable_immediate_execution,
|
|
157
|
+
use_api: args.body.ctx.use_api,
|
|
158
|
+
stack: args.body.ctx.stack
|
|
133
159
|
}),
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
160
|
+
version: args.body.version,
|
|
161
|
+
use_api: args.body.use_api
|
|
162
|
+
}) : args.body;
|
|
163
|
+
const checkpointConfig = !requestedStepId && effectiveBody.ctx.fn_id !== "" && !effectiveBody.ctx.disable_immediate_execution && effectiveBody.ctx.attempt === 0 ? Option.fromNullishOr(resolveConfig(fn.options.checkpointing, client.config.checkpointing)) : Option.none();
|
|
164
|
+
const result = yield* Effect.provide(execute({
|
|
165
|
+
fn,
|
|
166
|
+
handler: entry.handler,
|
|
167
|
+
request: effectiveBody,
|
|
168
|
+
checkpointConfig
|
|
169
|
+
}), entry.context);
|
|
137
170
|
return {
|
|
138
171
|
status: result.status,
|
|
139
172
|
headers: result.headers,
|
|
140
173
|
body: result.body
|
|
141
174
|
};
|
|
142
175
|
});
|
|
143
|
-
|
|
144
176
|
//#endregion
|
|
145
|
-
export { InvalidRequestError, handleExecution, handleIntrospection, handleRegistration, verifyAndParseRequestBody };
|
|
177
|
+
export { InvalidRequestError, handleExecution, handleIntrospection, handleRegistration, verifyAndParseRequestBody };
|
|
@@ -1 +1,143 @@
|
|
|
1
|
-
import "
|
|
1
|
+
import { StepInfo } from "./domain/StepInfo.js";
|
|
2
|
+
import { Schema } from "effect";
|
|
3
|
+
|
|
4
|
+
//#region src/internal/protocol.d.ts
|
|
5
|
+
declare const Opcode: {
|
|
6
|
+
readonly None: "None";
|
|
7
|
+
readonly Step: "Step";
|
|
8
|
+
readonly StepRun: "StepRun";
|
|
9
|
+
readonly StepError: "StepError";
|
|
10
|
+
readonly StepPlanned: "StepPlanned";
|
|
11
|
+
readonly Sleep: "Sleep";
|
|
12
|
+
readonly WaitForEvent: "WaitForEvent";
|
|
13
|
+
readonly InvokeFunction: "InvokeFunction";
|
|
14
|
+
readonly AIGateway: "AIGateway";
|
|
15
|
+
readonly Gateway: "Gateway";
|
|
16
|
+
readonly WaitForSignal: "WaitForSignal";
|
|
17
|
+
readonly RunComplete: "RunComplete";
|
|
18
|
+
readonly StepFailed: "StepFailed";
|
|
19
|
+
readonly SyncRunComplete: "SyncRunComplete";
|
|
20
|
+
readonly DiscoveryRequest: "DiscoveryRequest";
|
|
21
|
+
};
|
|
22
|
+
type OpcodeValue = (typeof Opcode)[keyof typeof Opcode];
|
|
23
|
+
declare const UserError_base: Schema.Class<UserError, Schema.Struct<{
|
|
24
|
+
readonly name: Schema.String;
|
|
25
|
+
readonly message: Schema.String;
|
|
26
|
+
readonly stack: Schema.optional<Schema.String>;
|
|
27
|
+
readonly data: Schema.optional<Schema.Unknown>;
|
|
28
|
+
readonly noRetry: Schema.optional<Schema.Boolean>;
|
|
29
|
+
readonly cause: Schema.optional<Schema.Unknown>;
|
|
30
|
+
}>, {}>;
|
|
31
|
+
declare class UserError extends UserError_base {
|
|
32
|
+
static fromUnknown(error: unknown): UserError;
|
|
33
|
+
}
|
|
34
|
+
declare const FunctionStack_base: Schema.Class<FunctionStack, Schema.Struct<{
|
|
35
|
+
readonly stack: Schema.$Array<Schema.String>;
|
|
36
|
+
readonly current: Schema.Number;
|
|
37
|
+
}>, {}>;
|
|
38
|
+
declare class FunctionStack extends FunctionStack_base {}
|
|
39
|
+
declare const InngestEvent_base: Schema.Class<InngestEvent, Schema.Struct<{
|
|
40
|
+
readonly id: Schema.optional<Schema.String>;
|
|
41
|
+
readonly name: Schema.String;
|
|
42
|
+
readonly data: Schema.withDecodingDefaultType<Schema.NullOr<Schema.$Record<Schema.String, Schema.Unknown>>, never>;
|
|
43
|
+
readonly ts: Schema.optional<Schema.Number>;
|
|
44
|
+
readonly user: Schema.optional<Schema.$Record<Schema.String, Schema.Unknown>>;
|
|
45
|
+
readonly v: Schema.optional<Schema.String>;
|
|
46
|
+
}>, {}>;
|
|
47
|
+
declare class InngestEvent extends InngestEvent_base {}
|
|
48
|
+
declare const SDKRequestContext_base: Schema.Class<SDKRequestContext, Schema.Struct<{
|
|
49
|
+
readonly fn_id: Schema.String;
|
|
50
|
+
readonly run_id: Schema.String;
|
|
51
|
+
readonly env: Schema.withDecodingDefault<Schema.String, never>;
|
|
52
|
+
readonly step_id: Schema.withDecodingDefault<Schema.String, never>;
|
|
53
|
+
readonly attempt: Schema.withDecodingDefault<Schema.Number, never>;
|
|
54
|
+
readonly max_attempts: Schema.withDecodingDefault<Schema.Number, never>;
|
|
55
|
+
readonly stack: Schema.withDecodingDefaultType<typeof FunctionStack, never>;
|
|
56
|
+
readonly qi_id: Schema.withDecodingDefault<Schema.String, never>;
|
|
57
|
+
readonly request_id: Schema.optionalKey<Schema.String>;
|
|
58
|
+
readonly generation_id: Schema.optionalKey<Schema.Number>;
|
|
59
|
+
readonly disable_immediate_execution: Schema.withDecodingDefault<Schema.Boolean, never>;
|
|
60
|
+
readonly use_api: Schema.withDecodingDefault<Schema.Boolean, never>;
|
|
61
|
+
}>, {}>;
|
|
62
|
+
declare class SDKRequestContext extends SDKRequestContext_base {}
|
|
63
|
+
declare const SDKRequestBody_base: Schema.Class<SDKRequestBody, Schema.Struct<{
|
|
64
|
+
readonly event: typeof InngestEvent;
|
|
65
|
+
readonly events: Schema.$Array<typeof InngestEvent>;
|
|
66
|
+
readonly steps: Schema.withDecodingDefault<Schema.$Record<Schema.String, Schema.NullOr<Schema.$Record<Schema.String, Schema.Unknown>>>, never>;
|
|
67
|
+
readonly ctx: typeof SDKRequestContext;
|
|
68
|
+
readonly version: Schema.withDecodingDefault<Schema.Number, never>;
|
|
69
|
+
readonly use_api: Schema.withDecodingDefault<Schema.Boolean, never>;
|
|
70
|
+
}>, {}>;
|
|
71
|
+
declare class SDKRequestBody extends SDKRequestBody_base {}
|
|
72
|
+
declare const GeneratorOpcode_base: Schema.Class<GeneratorOpcode, Schema.Struct<{
|
|
73
|
+
readonly op: Schema.Literals<readonly ["None", "Step", "StepRun", "StepError", "StepPlanned", "Sleep", "WaitForEvent", "InvokeFunction", "AIGateway", "Gateway", "WaitForSignal", "RunComplete", "StepFailed", "SyncRunComplete", "DiscoveryRequest"]>;
|
|
74
|
+
readonly id: Schema.String;
|
|
75
|
+
readonly name: Schema.optional<Schema.String>;
|
|
76
|
+
readonly mode: Schema.optional<Schema.Literals<readonly ["sync", "async"]>>;
|
|
77
|
+
readonly opts: Schema.optional<Schema.decodeTo<Schema.Unknown, Schema.Unknown, never, never>>;
|
|
78
|
+
readonly data: Schema.optional<Schema.decodeTo<Schema.Unknown, Schema.Unknown, never, never>>;
|
|
79
|
+
readonly error: Schema.optional<typeof UserError>;
|
|
80
|
+
readonly displayName: Schema.optional<Schema.String>;
|
|
81
|
+
readonly userland: Schema.optional<Schema.Struct<{
|
|
82
|
+
readonly id: Schema.String;
|
|
83
|
+
}>>;
|
|
84
|
+
readonly timing: Schema.optional<Schema.Struct<{
|
|
85
|
+
readonly a: Schema.Number;
|
|
86
|
+
readonly b: Schema.Number;
|
|
87
|
+
}>>;
|
|
88
|
+
}>, {}>;
|
|
89
|
+
declare class GeneratorOpcode extends GeneratorOpcode_base {
|
|
90
|
+
static makeStep(args: {
|
|
91
|
+
readonly info: StepInfo;
|
|
92
|
+
readonly op: OpcodeValue;
|
|
93
|
+
readonly extra?: object;
|
|
94
|
+
}): GeneratorOpcode;
|
|
95
|
+
static stepPlanned(info: StepInfo): GeneratorOpcode;
|
|
96
|
+
static sendEventStepPlanned(info: StepInfo): GeneratorOpcode;
|
|
97
|
+
static stepRun(args: {
|
|
98
|
+
readonly info: StepInfo;
|
|
99
|
+
readonly data: unknown;
|
|
100
|
+
}): GeneratorOpcode;
|
|
101
|
+
static sendEventStepRun(args: {
|
|
102
|
+
readonly info: StepInfo;
|
|
103
|
+
readonly data: unknown;
|
|
104
|
+
readonly rawPayload: unknown;
|
|
105
|
+
}): GeneratorOpcode;
|
|
106
|
+
static stepRunResponse(args: {
|
|
107
|
+
readonly info: StepInfo;
|
|
108
|
+
readonly data: unknown;
|
|
109
|
+
}): GeneratorOpcode;
|
|
110
|
+
static sendEventStepRunResponse(args: {
|
|
111
|
+
readonly info: StepInfo;
|
|
112
|
+
readonly data: unknown;
|
|
113
|
+
}): GeneratorOpcode;
|
|
114
|
+
static stepError(args: {
|
|
115
|
+
readonly info: StepInfo;
|
|
116
|
+
readonly error: UserError;
|
|
117
|
+
readonly noRetry?: boolean;
|
|
118
|
+
}): GeneratorOpcode;
|
|
119
|
+
static stepFailed(args: {
|
|
120
|
+
readonly info: StepInfo;
|
|
121
|
+
readonly error: UserError;
|
|
122
|
+
}): GeneratorOpcode;
|
|
123
|
+
static sleep(args: {
|
|
124
|
+
readonly info: StepInfo;
|
|
125
|
+
readonly duration: string;
|
|
126
|
+
}): GeneratorOpcode;
|
|
127
|
+
static waitForEvent(args: {
|
|
128
|
+
readonly info: StepInfo;
|
|
129
|
+
readonly event: string;
|
|
130
|
+
readonly timeout: string;
|
|
131
|
+
readonly if?: string;
|
|
132
|
+
}): GeneratorOpcode;
|
|
133
|
+
static invokeFunction(args: {
|
|
134
|
+
readonly info: StepInfo;
|
|
135
|
+
readonly functionId: string;
|
|
136
|
+
readonly payload: unknown;
|
|
137
|
+
readonly timeout?: string;
|
|
138
|
+
}): GeneratorOpcode;
|
|
139
|
+
static runComplete(data: unknown): GeneratorOpcode;
|
|
140
|
+
static discoveryRequest(): GeneratorOpcode;
|
|
141
|
+
}
|
|
142
|
+
//#endregion
|
|
143
|
+
export { GeneratorOpcode, SDKRequestBody };
|