From afc6ea27faee2019578d711573f906384722c96b Mon Sep 17 00:00:00 2001 From: kattsushi Date: Thu, 27 Aug 2026 13:22:58 -0600 Subject: [PATCH] style(format): normalize master promotion range --- .../app/routes/api.hatchet.runs.ts | 24 +- .../app/routes/hatchet-crons.tsx | 104 ++--- .../app/routes/todo-app.tsx | 132 ++---- .../tests/routes/api.hatchet.runs.test.ts | 57 ++- .../tests/routes/app-shell.test.tsx | 10 +- .../tests/routes/hatchet-crons.test.tsx | 142 +++---- .../better-auth-options-contract.test.ts | 38 +- .../config/hatchet-example-contract.test.ts | 90 ++-- .../config/nx-cypress-target-contract.test.ts | 19 +- .../tests/unit/lib/hatchet-runtime.test.ts | 20 +- .../tests/unit/lib/hatchet-task.test.ts | 12 +- .../tests/unit/lib/runtime.server.test.ts | 33 +- apps/react-router-example/tsconfig.test.json | 9 +- packages/hatchet/project.json | 26 +- packages/hatchet/scripts/test-cron.ts | 2 +- packages/hatchet/scripts/test-schedule.ts | 8 +- packages/hatchet/scripts/test-workflow.ts | 2 +- packages/hatchet/src/CronExpression.ts | 31 +- packages/hatchet/src/Hatchet.ts | 395 +++++------------- packages/hatchet/src/HatchetConfig.ts | 58 +-- packages/hatchet/src/Model.ts | 16 +- packages/hatchet/src/RateLimit.ts | 17 +- packages/hatchet/src/Task.ts | 84 +--- packages/hatchet/src/clients/workflows.ts | 10 +- .../hatchet/src/internal/cron-validation.ts | 20 +- .../src/internal/declaration-validation.ts | 21 +- packages/hatchet/src/internal/registry.ts | 52 +-- .../hatchet/src/internal/sdk-declaration.ts | 19 +- packages/hatchet/src/testing/mock-context.ts | 31 +- .../tests/types/declarative-task-api.ts | 11 +- packages/hatchet/tests/types/run-no-wait.ts | 19 +- .../hatchet/tests/types/task-schema-free.ts | 14 +- packages/hatchet/tests/unit/cron.test.ts | 68 +-- packages/hatchet/tests/unit/events.test.ts | 12 +- .../hatchet/tests/unit/hatchet-config.test.ts | 22 +- .../tests/unit/hatchet-runtime.test.ts | 35 +- .../hatchet/tests/unit/live-sdk-port.test.ts | 293 ++++--------- .../tests/unit/package-contract.test.ts | 8 +- .../unit/public-api-source-contract.test.ts | 10 +- .../hatchet/tests/unit/rate-limit.test.ts | 76 ++-- .../hatchet/tests/unit/run-no-wait.test.ts | 51 +-- packages/hatchet/tests/unit/schedule.test.ts | 57 +-- packages/hatchet/tests/unit/task-core.test.ts | 104 ++--- .../tests/unit/time-capabilities.test.ts | 22 +- packages/hatchet/tests/unit/trigger.test.ts | 10 +- .../router-better-auth/src/lib/handlers.ts | 16 +- .../tests/auth-guard.test.ts | 29 +- .../router-better-auth/tsconfig.no-build.json | 6 +- .../react/router-better-auth/vitest.config.ts | 5 +- packages/react/router/src/lib/runtime.ts | 130 +++--- packages/react/router/tests/runtime.test.ts | 65 +-- 51 files changed, 759 insertions(+), 1786 deletions(-) diff --git a/apps/react-router-example/app/routes/api.hatchet.runs.ts b/apps/react-router-example/app/routes/api.hatchet.runs.ts index 82a23599..326a21a2 100644 --- a/apps/react-router-example/app/routes/api.hatchet.runs.ts +++ b/apps/react-router-example/app/routes/api.hatchet.runs.ts @@ -7,34 +7,20 @@ import { greetingInput, greetingTask } from "../lib/hatchet/greeting-task.server import { withActionEffect } from "../lib/runtime.server.js" const invalidRequest = () => - Response.json( - { ok: false, errors: ["Request body must contain a non-empty name"] }, - { status: 400 }, - ) + Response.json({ ok: false, errors: ["Request body must contain a non-empty name"] }, { status: 400 }) const decodeInput = (request: Request) => Effect.tryPromise({ try: async (): Promise => request.json(), catch: invalidRequest, - }).pipe( - Effect.flatMap(Schema.decodeUnknownEffect(greetingInput)), - Effect.mapError(invalidRequest), - ) + }).pipe(Effect.flatMap(Schema.decodeUnknownEffect(greetingInput)), Effect.mapError(invalidRequest)) -export const action = Effect.gen(function*() { +export const action = Effect.gen(function* () { const { request } = yield* ActionArgsContext if (request.method !== "POST") { - return yield* Effect.fail( - Response.json( - { ok: false, errors: ["Only POST is supported"] }, - { status: 405 }, - ), - ) + return yield* Effect.fail(Response.json({ ok: false, errors: ["Only POST is supported"] }, { status: 405 })) } const input = yield* decodeInput(request) const handle = yield* Hatchet.runNoWait(greetingTask, input) return Response.json({ ok: true, runId: handle.id }, { status: 202 }) -}).pipe( - withBetterAuthGuardAction.with({ redirectOnFail: "/login" }), - withActionEffect, -) +}).pipe(withBetterAuthGuardAction.with({ redirectOnFail: "/login" }), withActionEffect) diff --git a/apps/react-router-example/app/routes/hatchet-crons.tsx b/apps/react-router-example/app/routes/hatchet-crons.tsx index 2a6f617f..4783445a 100644 --- a/apps/react-router-example/app/routes/hatchet-crons.tsx +++ b/apps/react-router-example/app/routes/hatchet-crons.tsx @@ -30,35 +30,26 @@ export const actionErrorFromData = (data: unknown): string | undefined => { return decoded.success.errors[0] } -export const loader = Effect.gen(function*() { +export const loader = Effect.gen(function* () { const crons = yield* Hatchet.listCrons({ taskName: greetingTask.name }) return yield* httpSuccess({ crons }) -}).pipe( - withBetterAuthGuard.with({ redirectOnFail: "/login" }), - withLoaderEffect, -) +}).pipe(withBetterAuthGuard.with({ redirectOnFail: "/login" }), withLoaderEffect) -export const action = Effect.gen(function*() { +export const action = Effect.gen(function* () { const { request } = yield* ActionArgsContext - const formData = yield* Effect.result( - Effect.tryPromise(() => request.formData()), - ) + const formData = yield* Effect.result(Effect.tryPromise(() => request.formData())) if (Result.isFailure(formData)) { return yield* httpFailure("Invalid cron form") } const decoded = yield* Effect.result( - Schema.decodeUnknownEffect(cronForm)( - Object.fromEntries(formData.success.entries()), - ), + Schema.decodeUnknownEffect(cronForm)(Object.fromEntries(formData.success.entries())), ) if (Result.isFailure(decoded)) { return yield* httpFailure("Invalid cron form") } - const schedule = yield* Effect.result( - CronExpression.parse(decoded.success.expression), - ) + const schedule = yield* Effect.result(CronExpression.parse(decoded.success.expression)) if (Result.isFailure(schedule)) { return yield* httpFailure("Invalid cron expression") } @@ -69,50 +60,32 @@ export const action = Effect.gen(function*() { input: { name: decoded.success.greetingName }, }) return yield* httpRedirect("/hatchet-crons") -}).pipe( - withBetterAuthGuardAction.with({ redirectOnFail: "/login" }), - withActionEffect, -) +}).pipe(withBetterAuthGuardAction.with({ redirectOnFail: "/login" }), withActionEffect) interface HatchetCronsScreenProps { readonly crons: ReadonlyArray readonly actionError?: string } -export function HatchetCronsScreen({ - crons, - actionError, -}: HatchetCronsScreenProps) { +export function HatchetCronsScreen({ crons, actionError }: HatchetCronsScreenProps) { const [expression, setExpression] = useState(defaultCronSource) const schedule = CronExpression.parseResult(expression) - const upcoming = Result.isSuccess(schedule) - ? CronExpression.nextRuns(schedule.success, 3) - : [] + const upcoming = Result.isSuccess(schedule) ? CronExpression.nextRuns(schedule.success, 3) : [] return (

Hatchet Crons

-

- Create authenticated cron triggers for the registered greeting task. -

+

Create authenticated cron triggers for the registered greeting task.

Create cron

- + - + setExpression(event.currentTarget.value)} /> - {Result.isFailure(schedule) ? - ( - - Enter a valid five-field cron expression. - - ) : - null} + {Result.isFailure(schedule) ? ( + Enter a valid five-field cron expression. + ) : null} - +

Next three local occurrences

- {upcoming.length === 0 ?

Enter a valid expression to preview upcoming runs.

: ( + {upcoming.length === 0 ? ( +

Enter a valid expression to preview upcoming runs.

+ ) : (
    {upcoming.map((date) => (
  1. - +
  2. ))}
)}
- {actionError ? - ( - - {actionError} - - ) : - null} + {actionError ? ( + + {actionError} + + ) : null} @@ -173,7 +130,9 @@ export function HatchetCronsScreen({

Cron list

- {crons.length === 0 ?

No crons found.

: ( + {crons.length === 0 ? ( +

No crons found.

+ ) : (
    {crons.map((cron) => (
  • @@ -208,10 +167,5 @@ export default function HatchetCrons({ loaderData }: Route.ComponentProps) { ) } - return ( - - ) + return } diff --git a/apps/react-router-example/app/routes/todo-app.tsx b/apps/react-router-example/app/routes/todo-app.tsx index 00e476e8..b029d121 100644 --- a/apps/react-router-example/app/routes/todo-app.tsx +++ b/apps/react-router-example/app/routes/todo-app.tsx @@ -10,19 +10,16 @@ import { AuthService, withBetterAuthGuard, withBetterAuthGuardAction } from "@ef import * as PrismaRepository from "./../../prisma/generated/effect/prisma-repository.js" import { TodoId, TodoModel } from "./../../prisma/generated/effect/index.js" -export const loader = Effect.gen(function*() { +export const loader = Effect.gen(function* () { const TodoRepo = yield* PrismaRepository.make(TodoModel, { modelName: "todo", spanPrefix: "Todo", }) const todos = yield* TodoRepo.findMany() return yield* httpSuccess({ todos: todos }) -}).pipe( - withBetterAuthGuard.with({ redirectOnFail: "/login" }), - withLoaderEffect, -) +}).pipe(withBetterAuthGuard.with({ redirectOnFail: "/login" }), withLoaderEffect) -export const action = Effect.gen(function*() { +export const action = Effect.gen(function* () { const { request } = yield* ActionArgsContext const formData = yield* Effect.tryPromise(() => request.formData()) const intent = String(formData.get("intent") ?? "create") @@ -87,10 +84,7 @@ export const action = Effect.gen(function*() { }, }) return yield* httpRedirect("/todo-app") -}).pipe( - withBetterAuthGuardAction.with({ redirectOnFail: "/login" }), - withActionEffect, -) +}).pipe(withBetterAuthGuardAction.with({ redirectOnFail: "/login" }), withActionEffect) export default function TodoApp({ loaderData }: Route.ComponentProps) { const actionData = useActionData() @@ -105,35 +99,16 @@ export default function TodoApp({ loaderData }: Route.ComponentProps) {
    - + -