chore: effect ts plugin
This commit is contained in:
parent
7ea7fe783c
commit
ad50ec9392
8 changed files with 20 additions and 14 deletions
|
|
@ -1,7 +1,7 @@
|
|||
import { afterEach, expect, mock, spyOn, test } from "bun:test";
|
||||
import { Effect } from "effect";
|
||||
import waitForExpect from "wait-for-expect";
|
||||
import { fromAny } from "@total-typescript/shoehorn";
|
||||
import { fromPartial } from "@total-typescript/shoehorn";
|
||||
import { createControllerMessage, parseAgentMessage } from "@zerobyte/contracts/agent-protocol";
|
||||
import * as resticServer from "@zerobyte/core/restic/server";
|
||||
import { createControllerSession } from "../controller-session";
|
||||
|
|
@ -12,14 +12,14 @@ afterEach(() => {
|
|||
|
||||
test("emits backup.failed when a backup command hits a restic error", async () => {
|
||||
spyOn(resticServer, "createRestic").mockReturnValue(
|
||||
fromAny({
|
||||
backup: () => Effect.fail(new Error("source path missing")),
|
||||
fromPartial({
|
||||
backup: () => Effect.fail("source path missing"),
|
||||
}),
|
||||
);
|
||||
|
||||
const outboundMessages: string[] = [];
|
||||
const session = createControllerSession(
|
||||
fromAny({
|
||||
fromPartial({
|
||||
send: (message: string) => {
|
||||
outboundMessages.push(message);
|
||||
},
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import { Effect } from "effect";
|
||||
import { Effect, Runtime } from "effect";
|
||||
import { createAgentMessage, type BackupRunPayload } from "@zerobyte/contracts/agent-protocol";
|
||||
import { logger } from "@zerobyte/core/node";
|
||||
import { type ResticDeps } from "@zerobyte/core/restic";
|
||||
|
|
@ -52,6 +52,7 @@ export const handleBackupRunCommand = (context: ControllerCommandContext, payloa
|
|||
};
|
||||
|
||||
const restic = createRestic(deps);
|
||||
const runtime = yield* Effect.runtime<never>();
|
||||
|
||||
yield* restic
|
||||
.backup(payload.repositoryConfig, payload.sourcePath, {
|
||||
|
|
@ -59,7 +60,8 @@ export const handleBackupRunCommand = (context: ControllerCommandContext, payloa
|
|||
...payload.options,
|
||||
signal: abortController.signal,
|
||||
onProgress: (progress) => {
|
||||
void Effect.runPromise(
|
||||
void Runtime.runPromise(
|
||||
runtime,
|
||||
context.offerOutbound(
|
||||
createAgentMessage("backup.progress", {
|
||||
jobId: payload.jobId,
|
||||
|
|
|
|||
|
|
@ -1,14 +1,11 @@
|
|||
import { Effect } from "effect";
|
||||
import { createAgentMessage, type ControllerMessage } from "@zerobyte/contracts/agent-protocol";
|
||||
import type { ControllerCommandContext } from "../context";
|
||||
|
||||
type HeartbeatPingPayload = Extract<ControllerMessage, { type: "heartbeat.ping" }>["payload"];
|
||||
|
||||
export const handleHeartbeatPingCommand = (context: ControllerCommandContext, payload: HeartbeatPingPayload) =>
|
||||
Effect.gen(function* () {
|
||||
yield* context.offerOutbound(
|
||||
createAgentMessage("heartbeat.pong", {
|
||||
sentAt: payload.sentAt,
|
||||
}),
|
||||
);
|
||||
});
|
||||
context.offerOutbound(
|
||||
createAgentMessage("heartbeat.pong", {
|
||||
sentAt: payload.sentAt,
|
||||
}),
|
||||
);
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
{
|
||||
"compilerOptions": {
|
||||
"plugins": [{ "name": "@effect/language-service" }],
|
||||
// Environment setup & latest features
|
||||
"lib": ["ESNext"],
|
||||
"target": "ESNext",
|
||||
|
|
|
|||
3
bun.lock
3
bun.lock
|
|
@ -75,6 +75,7 @@
|
|||
},
|
||||
"devDependencies": {
|
||||
"@babel/preset-typescript": "^7.28.5",
|
||||
"@effect/language-service": "^0.84.2",
|
||||
"@faker-js/faker": "^10.3.0",
|
||||
"@happy-dom/global-registrator": "^20.8.4",
|
||||
"@hey-api/openapi-ts": "^0.94.4",
|
||||
|
|
@ -292,6 +293,8 @@
|
|||
|
||||
"@drizzle-team/brocli": ["@drizzle-team/brocli@0.11.0", "", {}, "sha512-hD3pekGiPg0WPCCGAZmusBBJsDqGUR66Y452YgQsZOnkdQ7ViEPKuyP4huUGEZQefp8g34RRodXYmJ2TbCH+tg=="],
|
||||
|
||||
"@effect/language-service": ["@effect/language-service@0.84.2", "", { "bin": { "effect-language-service": "cli.js" } }, "sha512-l04qNxpiA8rY5yXWckRPJ7Mk5MNerXuNymSFf+IdflfI5i8jgL1bpBNLuP6ijg7wgjdHc/KmTnCj2kT0SCntuA=="],
|
||||
|
||||
"@electric-sql/pglite": ["@electric-sql/pglite@0.3.15", "", {}, "sha512-Cj++n1Mekf9ETfdc16TlDi+cDDQF0W7EcbyRHYOAeZdsAe8M/FJg18itDTSwyHfar2WIezawM9o0EKaRGVKygQ=="],
|
||||
|
||||
"@electric-sql/pglite-socket": ["@electric-sql/pglite-socket@0.0.20", "", { "peerDependencies": { "@electric-sql/pglite": "0.3.15" }, "bin": { "pglite-server": "dist/scripts/server.js" } }, "sha512-J5nLGsicnD9wJHnno9r+DGxfcZWh+YJMCe0q/aCgtG6XOm9Z7fKeite8IZSNXgZeGltSigM9U/vAWZQWdgcSFg=="],
|
||||
|
|
|
|||
|
|
@ -100,6 +100,7 @@
|
|||
},
|
||||
"devDependencies": {
|
||||
"@babel/preset-typescript": "^7.28.5",
|
||||
"@effect/language-service": "^0.84.2",
|
||||
"@faker-js/faker": "^10.3.0",
|
||||
"@happy-dom/global-registrator": "^20.8.4",
|
||||
"@hey-api/openapi-ts": "^0.94.4",
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
{
|
||||
"compilerOptions": {
|
||||
"plugins": [{ "name": "@effect/language-service" }],
|
||||
// Environment setup & latest features
|
||||
"lib": ["ESNext"],
|
||||
"target": "ESNext",
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
{
|
||||
"include": ["app/**/*"],
|
||||
"compilerOptions": {
|
||||
"plugins": [{ "name": "@effect/language-service" }],
|
||||
"lib": ["DOM", "DOM.Iterable", "ES2023"],
|
||||
"types": ["bun", "node", "vite/client"],
|
||||
"target": "ES2022",
|
||||
|
|
|
|||
Loading…
Reference in a new issue