@mokronos/wfkit 0.1.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/LICENSE +21 -0
- package/README.md +57 -0
- package/dist/authoring.d.ts +7 -0
- package/dist/authoring.d.ts.map +1 -0
- package/dist/authoring.js +8 -0
- package/dist/authoring.js.map +1 -0
- package/dist/cli/integrations.d.ts +3 -0
- package/dist/cli/integrations.d.ts.map +1 -0
- package/dist/cli/integrations.js +40 -0
- package/dist/cli/integrations.js.map +1 -0
- package/dist/cli/main.d.ts +3 -0
- package/dist/cli/main.d.ts.map +1 -0
- package/dist/cli/main.js +591 -0
- package/dist/cli/main.js.map +1 -0
- package/dist/core.d.ts +198 -0
- package/dist/core.d.ts.map +1 -0
- package/dist/core.js +1061 -0
- package/dist/core.js.map +1 -0
- package/dist/errors.d.ts +3 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +13 -0
- package/dist/errors.js.map +1 -0
- package/dist/events.d.ts +154 -0
- package/dist/events.d.ts.map +1 -0
- package/dist/events.js +24 -0
- package/dist/events.js.map +1 -0
- package/dist/index.d.ts +15 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +11 -0
- package/dist/index.js.map +1 -0
- package/dist/replay.d.ts +3 -0
- package/dist/replay.d.ts.map +1 -0
- package/dist/replay.js +28 -0
- package/dist/replay.js.map +1 -0
- package/dist/runtime.d.ts +70 -0
- package/dist/runtime.d.ts.map +1 -0
- package/dist/runtime.js +183 -0
- package/dist/runtime.js.map +1 -0
- package/dist/schema.d.ts +18 -0
- package/dist/schema.d.ts.map +1 -0
- package/dist/schema.js +19 -0
- package/dist/schema.js.map +1 -0
- package/dist/schemas.d.ts +1198 -0
- package/dist/schemas.d.ts.map +1 -0
- package/dist/schemas.js +383 -0
- package/dist/schemas.js.map +1 -0
- package/dist/sdk/artifact.d.ts +41 -0
- package/dist/sdk/artifact.d.ts.map +1 -0
- package/dist/sdk/artifact.js +94 -0
- package/dist/sdk/artifact.js.map +1 -0
- package/dist/sdk/graph.d.ts +15 -0
- package/dist/sdk/graph.d.ts.map +1 -0
- package/dist/sdk/graph.js +388 -0
- package/dist/sdk/graph.js.map +1 -0
- package/dist/sdk/index.d.ts +14 -0
- package/dist/sdk/index.d.ts.map +1 -0
- package/dist/sdk/index.js +8 -0
- package/dist/sdk/index.js.map +1 -0
- package/dist/sdk/integrations.d.ts +18 -0
- package/dist/sdk/integrations.d.ts.map +1 -0
- package/dist/sdk/integrations.js +20 -0
- package/dist/sdk/integrations.js.map +1 -0
- package/dist/sdk/json.d.ts +4 -0
- package/dist/sdk/json.d.ts.map +1 -0
- package/dist/sdk/json.js +31 -0
- package/dist/sdk/json.js.map +1 -0
- package/dist/sdk/loader.d.ts +10 -0
- package/dist/sdk/loader.d.ts.map +1 -0
- package/dist/sdk/loader.js +75 -0
- package/dist/sdk/loader.js.map +1 -0
- package/dist/sdk/sdk.d.ts +102 -0
- package/dist/sdk/sdk.d.ts.map +1 -0
- package/dist/sdk/sdk.js +669 -0
- package/dist/sdk/sdk.js.map +1 -0
- package/dist/sdk/sqlite.d.ts +8 -0
- package/dist/sdk/sqlite.d.ts.map +1 -0
- package/dist/sdk/sqlite.js +288 -0
- package/dist/sdk/sqlite.js.map +1 -0
- package/dist/signal.d.ts +17 -0
- package/dist/signal.d.ts.map +1 -0
- package/dist/signal.js +78 -0
- package/dist/signal.js.map +1 -0
- package/dist/testing/index.d.ts +35 -0
- package/dist/testing/index.d.ts.map +1 -0
- package/dist/testing/index.js +244 -0
- package/dist/testing/index.js.map +1 -0
- package/package.json +67 -0
- package/src/authoring.ts +32 -0
- package/src/cli/integrations.ts +75 -0
- package/src/cli/main.ts +793 -0
- package/src/core.ts +1515 -0
- package/src/errors.ts +19 -0
- package/src/events.ts +37 -0
- package/src/index.ts +109 -0
- package/src/replay.ts +29 -0
- package/src/runtime.ts +314 -0
- package/src/schema.ts +34 -0
- package/src/schemas.ts +473 -0
- package/src/sdk/artifact.ts +176 -0
- package/src/sdk/graph.ts +486 -0
- package/src/sdk/index.ts +64 -0
- package/src/sdk/integrations.ts +49 -0
- package/src/sdk/json.ts +40 -0
- package/src/sdk/loader.ts +99 -0
- package/src/sdk/sdk.ts +911 -0
- package/src/sdk/sqlite.ts +405 -0
- package/src/signal.ts +116 -0
- package/src/testing/index.ts +341 -0
package/dist/runtime.js
ADDED
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
import { mkdirSync } from "node:fs";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { NodeRuntime } from "@effect/platform-node";
|
|
4
|
+
import { SqliteClient } from "@effect/sql-sqlite-bun";
|
|
5
|
+
import { Effect, Exit, Layer, ManagedRuntime, Schema } from "effect";
|
|
6
|
+
import { ClusterWorkflowEngine, SingleRunner } from "effect/unstable/cluster";
|
|
7
|
+
import { SqlClient } from "effect/unstable/sql";
|
|
8
|
+
import { DurableDeferred, WorkflowEngine } from "effect/unstable/workflow";
|
|
9
|
+
import { currentSecretResolver, removeExecutionSecretResolver, setExecutionSecretResolver } from "./core.js";
|
|
10
|
+
import { currentWorkflowEventSink, emitWorkflowEvent, removeExecutionEventSink, setExecutionEventSink } from "./events.js";
|
|
11
|
+
export class WorkflowVersionConflictError extends Error {
|
|
12
|
+
_tag = "WorkflowVersionConflictError";
|
|
13
|
+
constructor(options) {
|
|
14
|
+
super(`Workflow ${options.name}@v${options.version} is already registered with different source; register a new version instead`);
|
|
15
|
+
this.name = "WorkflowVersionConflictError";
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
const defaultEngineDatabasePath = () => path.join(process.cwd(), ".wf", "engine.sqlite");
|
|
19
|
+
// All durable-execution plumbing lives here so authored workflows never touch
|
|
20
|
+
// the cluster engine, the runner, or the backing store.
|
|
21
|
+
export const makeEngineLayer = (options = {}) => {
|
|
22
|
+
const databasePath = path.resolve(options.databasePath ?? defaultEngineDatabasePath());
|
|
23
|
+
const sqliteBusyTimeoutMs = Math.max(0, Math.trunc(options.sqliteBusyTimeoutMs ?? 5000));
|
|
24
|
+
// The cluster default is 10 seconds, which delays every durable timer
|
|
25
|
+
// (signal timeout, long sleep) by up to that long on a single-node engine.
|
|
26
|
+
const timerPollIntervalMs = Math.max(10, Math.trunc(options.timerPollIntervalMs ?? 250));
|
|
27
|
+
mkdirSync(path.dirname(databasePath), { recursive: true });
|
|
28
|
+
const sqliteLayer = SqliteClient.layer({ filename: databasePath });
|
|
29
|
+
const configuredSqliteLayer = Layer.effectDiscard(Effect.gen(function* () {
|
|
30
|
+
const sql = yield* SqlClient.SqlClient;
|
|
31
|
+
yield* sql.unsafe(`PRAGMA busy_timeout = ${sqliteBusyTimeoutMs}`);
|
|
32
|
+
})).pipe(Layer.provideMerge(sqliteLayer));
|
|
33
|
+
return ClusterWorkflowEngine.layer.pipe(Layer.provideMerge(SingleRunner.layer({
|
|
34
|
+
shardingConfig: { entityMessagePollInterval: timerPollIntervalMs }
|
|
35
|
+
})), Layer.provide(configuredSqliteLayer));
|
|
36
|
+
};
|
|
37
|
+
export const engineLayer = makeEngineLayer();
|
|
38
|
+
export const createWorkflowRuntime = (options) => {
|
|
39
|
+
const workflows = new Map();
|
|
40
|
+
const databasePath = options.databasePath;
|
|
41
|
+
const env = () => {
|
|
42
|
+
const workflowLayers = Array.from(workflows.values()).map((workflow) => workflow.layer);
|
|
43
|
+
const base = options.backend === "sqlite"
|
|
44
|
+
? makeEngineLayer({
|
|
45
|
+
...(databasePath === undefined ? {} : { databasePath }),
|
|
46
|
+
...(options.sqliteBusyTimeoutMs === undefined ? {} : { sqliteBusyTimeoutMs: options.sqliteBusyTimeoutMs }),
|
|
47
|
+
...(options.timerPollIntervalMs === undefined ? {} : { timerPollIntervalMs: options.timerPollIntervalMs })
|
|
48
|
+
})
|
|
49
|
+
: WorkflowEngine.layerMemory;
|
|
50
|
+
return workflowLayers.reduce((layer, workflowLayer) => Layer.provideMerge(workflowLayer, layer), base);
|
|
51
|
+
};
|
|
52
|
+
// ONE engine per runtime. Building a fresh cluster node per call (execute,
|
|
53
|
+
// signal, ...) puts several SingleRunner nodes on the same store, and they
|
|
54
|
+
// fight over shard ownership — message processing becomes arbitrarily late.
|
|
55
|
+
// Rebuilt only when the registered workflow set changes.
|
|
56
|
+
let managed;
|
|
57
|
+
const getManagedRuntime = () => {
|
|
58
|
+
const signature = Array.from(workflows.keys()).sort().join(",");
|
|
59
|
+
if (managed === undefined || managed.signature !== signature) {
|
|
60
|
+
if (managed !== undefined) {
|
|
61
|
+
void managed.runtime.dispose();
|
|
62
|
+
}
|
|
63
|
+
managed = { signature, runtime: ManagedRuntime.make(env()) };
|
|
64
|
+
}
|
|
65
|
+
return managed.runtime;
|
|
66
|
+
};
|
|
67
|
+
const runEffect = (effect, onEvent) => getManagedRuntime().runPromise(effect.pipe(Effect.provideService(currentWorkflowEventSink, onEvent), Effect.provideService(currentSecretResolver, options.secrets)));
|
|
68
|
+
return {
|
|
69
|
+
backend: options.backend,
|
|
70
|
+
...(databasePath === undefined ? {} : { databasePath }),
|
|
71
|
+
...(options.secrets === undefined ? {} : { secrets: options.secrets }),
|
|
72
|
+
register(registered) {
|
|
73
|
+
for (const workflow of registered) {
|
|
74
|
+
const key = `${workflow.name}@${workflow.version}`;
|
|
75
|
+
const existing = workflows.get(key);
|
|
76
|
+
if (existing !== undefined && existing.sourceHash !== workflow.sourceHash) {
|
|
77
|
+
throw new WorkflowVersionConflictError({
|
|
78
|
+
name: workflow.name,
|
|
79
|
+
version: workflow.version
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
workflows.set(key, workflow);
|
|
83
|
+
}
|
|
84
|
+
},
|
|
85
|
+
getWorkflow(name, version) {
|
|
86
|
+
return workflows.get(`${name}@${version}`);
|
|
87
|
+
},
|
|
88
|
+
getLatestWorkflow(name) {
|
|
89
|
+
return Array.from(workflows.values())
|
|
90
|
+
.filter((workflow) => workflow.name === name)
|
|
91
|
+
.sort((left, right) => right.version - left.version)[0];
|
|
92
|
+
},
|
|
93
|
+
listWorkflows(name) {
|
|
94
|
+
return Array.from(workflows.values())
|
|
95
|
+
.filter((workflow) => name === undefined || workflow.name === name)
|
|
96
|
+
.sort((left, right) => left.name.localeCompare(right.name) || left.version - right.version);
|
|
97
|
+
},
|
|
98
|
+
execute({ workflow, payload, executionId, onEvent }) {
|
|
99
|
+
const workflowName = String(workflow.workflow._tag ?? workflow.engineName);
|
|
100
|
+
if (onEvent !== undefined) {
|
|
101
|
+
setExecutionEventSink(executionId, onEvent);
|
|
102
|
+
}
|
|
103
|
+
if (options.secrets !== undefined) {
|
|
104
|
+
setExecutionSecretResolver(executionId, options.secrets);
|
|
105
|
+
}
|
|
106
|
+
const effect = Effect.gen(function* () {
|
|
107
|
+
const engine = yield* WorkflowEngine.WorkflowEngine;
|
|
108
|
+
yield* emitWorkflowEvent({ type: "workflow.started", workflowName, payload });
|
|
109
|
+
const result = yield* engine.execute(workflow.workflow, {
|
|
110
|
+
executionId,
|
|
111
|
+
payload: payload
|
|
112
|
+
}).pipe(Effect.tap((result) => emitWorkflowEvent({ type: "workflow.completed", workflowName, result })), Effect.tapError((error) => emitWorkflowEvent({ type: "workflow.failed", workflowName, error })));
|
|
113
|
+
return result;
|
|
114
|
+
});
|
|
115
|
+
return runEffect(effect, onEvent).finally(() => {
|
|
116
|
+
removeExecutionEventSink(executionId);
|
|
117
|
+
removeExecutionSecretResolver(executionId);
|
|
118
|
+
});
|
|
119
|
+
},
|
|
120
|
+
deliverSignal({ workflow, executionId, deferredName, payload, onEvent }) {
|
|
121
|
+
if (onEvent !== undefined) {
|
|
122
|
+
setExecutionEventSink(executionId, onEvent);
|
|
123
|
+
}
|
|
124
|
+
// The resumed replay may execute steps in THIS process (see the resume
|
|
125
|
+
// note below), so it needs the secret resolver just like execute().
|
|
126
|
+
if (options.secrets !== undefined) {
|
|
127
|
+
setExecutionSecretResolver(executionId, options.secrets);
|
|
128
|
+
}
|
|
129
|
+
const effect = Effect.gen(function* () {
|
|
130
|
+
const engine = yield* WorkflowEngine.WorkflowEngine;
|
|
131
|
+
const deferred = DurableDeferred.make(deferredName, { success: Schema.Unknown });
|
|
132
|
+
yield* engine.deferredDone(deferred, {
|
|
133
|
+
workflowName: workflow.workflow._tag,
|
|
134
|
+
executionId,
|
|
135
|
+
deferredName,
|
|
136
|
+
exit: Exit.succeed(payload)
|
|
137
|
+
});
|
|
138
|
+
// deferredDone only resumes a run whose Suspended reply is already
|
|
139
|
+
// persisted. A delivery racing the suspension write would otherwise
|
|
140
|
+
// sit unnoticed until another wake-up, so nudge resume a few times
|
|
141
|
+
// (resume is a no-op unless the run is recorded as suspended).
|
|
142
|
+
for (let attempt = 0; attempt < 5; attempt++) {
|
|
143
|
+
yield* Effect.sleep("100 millis");
|
|
144
|
+
yield* engine.resume(workflow.workflow, executionId);
|
|
145
|
+
}
|
|
146
|
+
});
|
|
147
|
+
// The resumed replay may run inside THIS call's engine environment, so
|
|
148
|
+
// it needs the same event sink as the original execute to record
|
|
149
|
+
// history (compensations, cancellation, signal receipt).
|
|
150
|
+
return runEffect(effect, onEvent);
|
|
151
|
+
},
|
|
152
|
+
interrupt({ workflow, executionId }) {
|
|
153
|
+
const effect = Effect.gen(function* () {
|
|
154
|
+
const engine = yield* WorkflowEngine.WorkflowEngine;
|
|
155
|
+
yield* engine.interrupt(workflow.workflow, executionId);
|
|
156
|
+
});
|
|
157
|
+
return runEffect(effect);
|
|
158
|
+
},
|
|
159
|
+
resume({ workflow, executionId }) {
|
|
160
|
+
const effect = Effect.gen(function* () {
|
|
161
|
+
const engine = yield* WorkflowEngine.WorkflowEngine;
|
|
162
|
+
yield* engine.resume(workflow.workflow, executionId);
|
|
163
|
+
});
|
|
164
|
+
return runEffect(effect);
|
|
165
|
+
}
|
|
166
|
+
};
|
|
167
|
+
};
|
|
168
|
+
export const makeWorkflowEffect = (wf, payload, options = {}) => {
|
|
169
|
+
const env = wf.layer.pipe(Layer.provideMerge(makeEngineLayer(options.engineDatabasePath === undefined ? {} : { databasePath: options.engineDatabasePath })));
|
|
170
|
+
const workflowName = String(wf.workflow._tag ?? wf.engineName ?? "Workflow");
|
|
171
|
+
const execution = Effect.gen(function* () {
|
|
172
|
+
yield* emitWorkflowEvent({ type: "workflow.started", workflowName, payload });
|
|
173
|
+
const result = yield* wf.workflow.execute(payload).pipe(Effect.tap((result) => emitWorkflowEvent({ type: "workflow.completed", workflowName, result })), Effect.tapError((error) => emitWorkflowEvent({ type: "workflow.failed", workflowName, error })));
|
|
174
|
+
return result;
|
|
175
|
+
});
|
|
176
|
+
return execution.pipe(Effect.provide(env), Effect.provideService(currentWorkflowEventSink, options.onEvent));
|
|
177
|
+
};
|
|
178
|
+
export const executeWorkflow = (wf, payload, options = {}) => Effect.runPromise(makeWorkflowEffect(wf, payload, options));
|
|
179
|
+
// Execute a workflow to completion as a standalone program.
|
|
180
|
+
export const run = (wf, payload) => {
|
|
181
|
+
return makeWorkflowEffect(wf, payload).pipe(NodeRuntime.runMain);
|
|
182
|
+
};
|
|
183
|
+
//# sourceMappingURL=runtime.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtime.js","sourceRoot":"","sources":["../src/runtime.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAA;AACnC,OAAO,IAAI,MAAM,WAAW,CAAA;AAC5B,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAA;AACnD,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAA;AACrD,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,cAAc,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AACpE,OAAO,EAAE,qBAAqB,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAA;AAC7E,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAA;AAC/C,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAA;AAC1E,OAAO,EAAE,qBAAqB,EAAE,6B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AA;IACf,CAAC,CAAC,CAAA;IAEF,OAAO,SAAS,CAAC,IAAI,CACnB,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,EACnB,MAAM,CAAC,cAAc,CAAC,wBAAwB,EAAE,OAAO,CAAC,OAAO,CAAC,CACjE,CAAA;AACH,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,eAAe,GAAG,CAC7B,EAAmB,EACnB,OAAgB,EAChB,UAAkC,EAAE,EACpC,EAAE,CACF,MAAM,CAAC,UAAU,CACf,kBAAkB,CAAC,EAAE,EAAE,OAAO,EAAE,OAAO,CAA2C,CACnF,CAAA;AAEH,4DAA4D;AAC5D,MAAM,CAAC,MAAM,GAAG,GAAG,CAAC,EAAmB,EAAE,OAAgB,EAAE,EAAE;IAC3D,OAAQ,kBAAkB,CAAC,EAAE,EAAE,OAAO,CAA4C,CAAC,IAAI,CACrF,WAAW,CAAC,OAAO,CACpB,CAAA;AACH,CAAC,CAAA"}
|
package/dist/schema.d.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Schema } from "effect";
|
|
2
|
+
interface SchemaVocabulary {
|
|
3
|
+
readonly string: typeof Schema.String;
|
|
4
|
+
readonly number: typeof Schema.Number;
|
|
5
|
+
readonly boolean: typeof Schema.Boolean;
|
|
6
|
+
readonly void: typeof Schema.Void;
|
|
7
|
+
readonly date: typeof Schema.Date;
|
|
8
|
+
readonly struct: typeof Schema.Struct;
|
|
9
|
+
readonly array: <S extends Schema.Constraint>(schema: S) => Schema.$Array<S>;
|
|
10
|
+
readonly literal: typeof Schema.Literal;
|
|
11
|
+
readonly taggedStruct: typeof Schema.TaggedStruct;
|
|
12
|
+
readonly optional: <S extends Schema.Constraint>(schema: S) => Schema.optional<S>;
|
|
13
|
+
readonly union: typeof Schema.Union;
|
|
14
|
+
readonly unknown: typeof Schema.Unknown;
|
|
15
|
+
}
|
|
16
|
+
export declare const t: SchemaVocabulary;
|
|
17
|
+
export {};
|
|
18
|
+
//# sourceMappingURL=schema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../src/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAE/B,UAAU,gBAAgB;IACxB,QAAQ,CAAC,MAAM,EAAE,OAAO,MAAM,CAAC,MAAM,CAAA;IACrC,QAAQ,CAAC,MAAM,EAAE,OAAO,MAAM,CAAC,MAAM,CAAA;IACrC,QAAQ,CAAC,OAAO,EAAE,OAAO,MAAM,CAAC,OAAO,CAAA;IACvC,QAAQ,CAAC,IAAI,EAAE,OAAO,MAAM,CAAC,IAAI,CAAA;IACjC,QAAQ,CAAC,IAAI,EAAE,OAAO,MAAM,CAAC,IAAI,CAAA;IACjC,QAAQ,CAAC,MAAM,EAAE,OAAO,MAAM,CAAC,MAAM,CAAA;IACrC,QAAQ,CAAC,KAAK,EAAE,CAAC,CAAC,SAAS,MAAM,CAAC,UAAU,EAAE,MAAM,EAAE,CAAC,KAAK,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAA;IAC5E,QAAQ,CAAC,OAAO,EAAE,OAAO,MAAM,CAAC,OAAO,CAAA;IACvC,QAAQ,CAAC,YAAY,EAAE,OAAO,MAAM,CAAC,YAAY,CAAA;IACjD,QAAQ,CAAC,QAAQ,EAAE,CAAC,CAAC,SAAS,MAAM,CAAC,UAAU,EAAE,MAAM,EAAE,CAAC,KAAK,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAA;IACjF,QAAQ,CAAC,KAAK,EAAE,OAAO,MAAM,CAAC,KAAK,CAAA;IACnC,QAAQ,CAAC,OAAO,EAAE,OAAO,MAAM,CAAC,OAAO,CAAA;CACxC;AAKD,eAAO,MAAM,CAAC,EAAE,gBAaN,CAAA"}
|
package/dist/schema.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Schema } from "effect";
|
|
2
|
+
// `t` is the LLM-facing schema vocabulary. We re-export a small, lowercase
|
|
3
|
+
// subset of Effect's `Schema` so authored workflows never import `effect`
|
|
4
|
+
// directly. Add primitives here as workflows need them — keep it small.
|
|
5
|
+
export const t = {
|
|
6
|
+
string: Schema.String,
|
|
7
|
+
number: Schema.Number,
|
|
8
|
+
boolean: Schema.Boolean,
|
|
9
|
+
void: Schema.Void,
|
|
10
|
+
date: Schema.Date,
|
|
11
|
+
struct: Schema.Struct,
|
|
12
|
+
array: Schema.Array,
|
|
13
|
+
literal: Schema.Literal,
|
|
14
|
+
taggedStruct: Schema.TaggedStruct,
|
|
15
|
+
optional: Schema.optional,
|
|
16
|
+
union: Schema.Union,
|
|
17
|
+
unknown: Schema.Unknown
|
|
18
|
+
};
|
|
19
|
+
//# sourceMappingURL=schema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.js","sourceRoot":"","sources":["../src/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAiB/B,2EAA2E;AAC3E,0EAA0E;AAC1E,wEAAwE;AACxE,MAAM,CAAC,MAAM,CAAC,GAAqB;IACjC,MAAM,EAAE,MAAM,CAAC,MAAM;IACrB,MAAM,EAAE,MAAM,CAAC,MAAM;IACrB,OAAO,EAAE,MAAM,CAAC,OAAO;IACvB,IAAI,EAAE,MAAM,CAAC,IAAI;IACjB,IAAI,EAAE,MAAM,CAAC,IAAI;IACjB,MAAM,EAAE,MAAM,CAAC,MAAM;IACrB,KAAK,EAAE,MAAM,CAAC,KAAK;IACnB,OAAO,EAAE,MAAM,CAAC,OAAO;IACvB,YAAY,EAAE,MAAM,CAAC,YAAY;IACjC,QAAQ,EAAE,MAAM,CAAC,QAAQ;IACzB,KAAK,EAAE,MAAM,CAAC,KAAK;IACnB,OAAO,EAAE,MAAM,CAAC,OAAO;CACf,CAAA"}
|