Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .changeset/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@
"linked": [],
"access": "public",
"baseBranch": "main",
"updateInternalDependencies": "patch"
"updateInternalDependencies": "patch",
"ignore": ["@btravstack/start-*", "@btravstack-examples/*"]
}
5 changes: 1 addition & 4 deletions .oxfmtrc.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
{
"$schema": "./node_modules/oxfmt/configuration_schema.json",
"ignorePatterns": ["pnpm-lock.yaml", "packages/*/docs/**", "**/generated/**"],
"organizeImports": {
"sortImports": true,
"separateGroups": true
}
"sortImports": true
}
7 changes: 2 additions & 5 deletions .oxlintrc.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
{
"$schema": "./node_modules/oxlint/configuration_schema.json",
"ignorePatterns": ["**/*.test-d.ts", "**/generated/**"],
"rules": {
"@typescript-eslint/no-explicit-any": "error",
"typescript/consistent-type-definitions": ["error", "type"]
}
"extends": ["./node_modules/@btravstack/oxlint/base.json"],
"ignorePatterns": ["**/*.test-d.ts", "**/generated/**"]
}
2 changes: 1 addition & 1 deletion commitlint.config.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export default { extends: ["@commitlint/config-conventional"] };
export default { extends: ["@btravstack/commitlint"] };
1 change: 1 addition & 0 deletions docs/.vitepress/theme/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import Theme from "@btravstack/theme";

import "./custom.css";

export default Theme;
2 changes: 1 addition & 1 deletion examples/start-amqp-worker/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"zod": "catalog:"
},
"devDependencies": {
"@btravstack/tsconfig": "workspace:*",
"@btravstack/tsconfig": "catalog:",
"@testcontainers/rabbitmq": "catalog:",
"@types/node": "catalog:",
"tsx": "catalog:",
Expand Down
2 changes: 1 addition & 1 deletion examples/start-amqp-worker/src/infra/logger.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Layer } from "demesne";

import { Config } from "../config.js";
import { Logger } from "../application/ports.js";
import { Config } from "../config.js";

export const LoggerLive = Layer.inject(Logger, { config: Config }, ({ config }) => ({
info: (msg) => {
Expand Down
2 changes: 1 addition & 1 deletion examples/start-amqp-worker/src/infra/payments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
import { Layer } from "demesne";
import { Err, Ok } from "unthrown";

import { Payments } from "../application/ports.js";
import { Config } from "../config.js";
import { PaymentDeclined } from "../domain.js";
import { Payments } from "../application/ports.js";

let counter = 0;

Expand Down
4 changes: 2 additions & 2 deletions examples/start-amqp-worker/src/server.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import { runConsumer } from "@btravstack/start-amqp";
// Entry point — connect to the broker (the URL is a deployment endpoint, read at process
// bootstrap), assemble the graph with the real Payments adapter, and run the consume loop under
// `runHost`: it subscribes on build and, on SIGINT/SIGTERM, closes the scope (cancelling
// subscriptions) before the connection is closed. Startup failures are a static union.
import { runHost } from "@btravstack/start-kernel";
import { runConsumer } from "@btravstack/start-amqp";
import { Layer } from "demesne";

import { Logger } from "./application/ports.js";
import { bootstrap } from "./bootstrap.js";
import { ConfigLive } from "./config.js";
import { CHARGE_QUEUE } from "./consumer.js";
import { createAmqpDriver } from "./infra/amqp-driver.js";
import { PaymentsLive } from "./infra/payments.js";
import { ConfigLive } from "./config.js";

const driver = await createAmqpDriver(process.env["AMQP_URL"] ?? "amqp://localhost");

Expand Down
8 changes: 4 additions & 4 deletions examples/start-amqp-worker/src/worker.integration.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { runConsumer } from "@btravstack/start-amqp";
import { runHost } from "@btravstack/start-kernel";
// Integration: the WHOLE consumer against a real RabbitMQ (testcontainers), through the REAL
// amqplib driver — the exact wiring `server.ts` runs. A publisher connection pushes messages onto
// the queue; the consumer must pick them up, run the demesne-wired handler, and settle them:
Expand All @@ -6,16 +8,14 @@
// • a malformed body → ContractError → dead-letter (poison message, no loop)
// A requeue-loop bug would keep messageCount > 0 — the drain assertions are the regression net.
import { RabbitMQContainer, type StartedRabbitMQContainer } from "@testcontainers/rabbitmq";
import { runHost } from "@btravstack/start-kernel";
import { runConsumer } from "@btravstack/start-amqp";
import { Layer } from "demesne";
import * as amqplib from "amqplib";
import { Layer } from "demesne";
import { fromSafePromise } from "unthrown";
import { afterAll, beforeAll, describe, expect, it, vi } from "vitest";

import { bootstrap } from "./bootstrap.js";
import { CHARGE_QUEUE } from "./consumer.js";
import { ConfigLive } from "./config.js";
import { CHARGE_QUEUE } from "./consumer.js";
import { type AmqpConnection, createAmqpDriver } from "./infra/amqp-driver.js";
import { PaymentsLive } from "./infra/payments.js";

Expand Down
2 changes: 1 addition & 1 deletion examples/start-api-todo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"zod": "catalog:"
},
"devDependencies": {
"@btravstack/tsconfig": "workspace:*",
"@btravstack/tsconfig": "catalog:",
"@types/node": "catalog:",
"tsx": "catalog:",
"typescript": "catalog:",
Expand Down
2 changes: 1 addition & 1 deletion examples/start-api-todo/src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
import { httpListener, ListenConfig } from "@btravstack/start-api";
import { Layer } from "demesne";

import { Config, ConfigLive } from "./config.js";
import { bootstrap } from "./bootstrap.js";
import { Config, ConfigLive } from "./config.js";
import { TodoRepoLive } from "./infra/adapters.js";

const ListenConfigLive = Layer.inject(ListenConfig, { config: Config }, ({ config }) => ({
Expand Down
2 changes: 1 addition & 1 deletion examples/start-api-todo/src/infra/adapters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
import { Layer } from "demesne";
import { Err, Ok } from "unthrown";

import { Logger, TodoRepository } from "../application/ports.js";
import { Config } from "../config.js";
import { type Todo, TodoNotFound } from "../domain.js";
import { Logger, TodoRepository } from "../application/ports.js";

export const LoggerLive = Layer.inject(Logger, { config: Config }, ({ config }) => ({
info: (msg) => {
Expand Down
2 changes: 1 addition & 1 deletion examples/start-orpc-prisma/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"zod": "catalog:"
},
"devDependencies": {
"@btravstack/tsconfig": "workspace:*",
"@btravstack/tsconfig": "catalog:",
"@orpc/client": "catalog:",
"@testcontainers/postgresql": "catalog:",
"@types/node": "catalog:",
Expand Down
2 changes: 1 addition & 1 deletion examples/start-orpc-prisma/src/app.integration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
// closes, Prisma disconnects and the port stops accepting.
import { execFileSync } from "node:child_process";

import { PostgreSqlContainer, type StartedPostgreSqlContainer } from "@testcontainers/postgresql";
import { HttpServer } from "@btravstack/start-api";
import { runHost } from "@btravstack/start-kernel";
import { createORPCClient } from "@orpc/client";
import { RPCLink } from "@orpc/client/fetch";
import type { RouterClient } from "@orpc/server";
import { PostgreSqlContainer, type StartedPostgreSqlContainer } from "@testcontainers/postgresql";
import { createResultClient } from "@unthrown/orpc/client";
import { fromSafePromise } from "unthrown";
import { afterAll, beforeAll, describe, expect, it } from "vitest";
Expand Down
16 changes: 7 additions & 9 deletions examples/start-orpc-prisma/src/app.test.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,18 @@
// End-to-end test with NO database. It goes through the SAME `bootstrap` as the server, swapping
// only the repository for an in-memory fake (the port drops in without Prisma/Postgres). It drives
// the real app through a TYPED oRPC client whose fetch loops straight back into the Hono app — a
// genuine request/response cycle, JSON serialization and typed-error inference included, without a
// socket.
import { describe, expect, it } from "vitest";

import { HttpApp } from "@btravstack/start-api";
// Registers the Result / AsyncResult matchers.
import "@unthrown/vitest";

import { HttpApp } from "@btravstack/start-api";
import { createORPCClient } from "@orpc/client";
import { RPCLink } from "@orpc/client/fetch";
import type { RouterClient } from "@orpc/server";
import { createResultClient } from "@unthrown/orpc/client";
import { Layer, type ServiceOf } from "demesne";
import { Err, Ok } from "unthrown";
// End-to-end test with NO database. It goes through the SAME `bootstrap` as the server, swapping
// only the repository for an in-memory fake (the port drops in without Prisma/Postgres). It drives
// the real app through a TYPED oRPC client whose fetch loops straight back into the Hono app — a
// genuine request/response cycle, JSON serialization and typed-error inference included, without a
// socket.
import { describe, expect, it } from "vitest";

import { TodoRepository } from "./application/ports.js";
import { bootstrap } from "./bootstrap.js";
Expand Down
2 changes: 1 addition & 1 deletion examples/start-orpc-prisma/src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
import { httpListener, ListenConfig } from "@btravstack/start-api";
import { Layer } from "demesne";

import { Config, ConfigLive } from "./config.js";
import { bootstrap } from "./bootstrap.js";
import { Config, ConfigLive } from "./config.js";
import { DatabaseLive } from "./infra/prisma.js";
import { TodoRepoLive } from "./infra/todo-repository.js";

Expand Down
2 changes: 1 addition & 1 deletion examples/start-orpc-prisma/src/http/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
// domain→transport triage lives in one `mapErr` per procedure — the oRPC-native form of the
// disposition map.
import { HttpApp } from "@btravstack/start-api";
import { type Context as DemesneContext, Layer, type ServiceOf } from "demesne";
import { os } from "@orpc/server";
import { RPCHandler } from "@orpc/server/fetch";
import { handlerResult } from "@unthrown/orpc/server";
import { type Context as DemesneContext, Layer, type ServiceOf } from "demesne";
import { Hono } from "hono";
import { fromPromise, TaggedError } from "unthrown";
import { z } from "zod";
Expand Down
2 changes: 1 addition & 1 deletion examples/start-orpc-prisma/src/infra/prisma.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
// `$extends`ed with `@unthrown/prisma` so every query returns an `AsyncResult` (the `try*` methods)
// whose error channel is the P-codes it can hit.
import { PrismaPg } from "@prisma/adapter-pg";
import { unthrownPrisma } from "@unthrown/prisma";
import { type Context, Layer, Tag } from "demesne";
import { fromPromise, TaggedError } from "unthrown";
import { unthrownPrisma } from "@unthrown/prisma";

import { Config, type ConfigId } from "../config.js";
import { PrismaClient } from "../generated/prisma/client.ts";
Expand Down
2 changes: 1 addition & 1 deletion examples/start-temporal-worker/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"zod": "catalog:"
},
"devDependencies": {
"@btravstack/tsconfig": "workspace:*",
"@btravstack/tsconfig": "catalog:",
"@temporalio/client": "catalog:",
"@types/node": "catalog:",
"testcontainers": "catalog:",
Expand Down
2 changes: 1 addition & 1 deletion examples/start-temporal-worker/src/infra/logger.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Layer } from "demesne";

import { Config } from "../config.js";
import { Logger } from "../application/ports.js";
import { Config } from "../config.js";

export const LoggerLive = Layer.inject(Logger, { config: Config }, ({ config }) => ({
info: (msg) => {
Expand Down
2 changes: 1 addition & 1 deletion examples/start-temporal-worker/src/infra/payments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
import { Layer } from "demesne";
import { Err, Ok } from "unthrown";

import { Payments } from "../application/ports.js";
import { Config } from "../config.js";
import { PaymentDeclined } from "../domain.js";
import { Payments } from "../application/ports.js";

let counter = 0;

Expand Down
10 changes: 5 additions & 5 deletions examples/start-temporal-worker/src/worker.integration.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
import { ActivityRegistry } from "@btravstack/start-temporal";
import { Client, Connection } from "@temporalio/client";
import { NativeConnection, Worker } from "@temporalio/worker";
import { Layer } from "demesne";
// Integration: the WHOLE worker against a real Temporal dev server (testcontainers, the
// `temporalio/temporal` CLI image running `server start-dev`). The REAL @temporalio Worker is
// created exactly as `worker.ts` does — demesne-built activity registry, ApplicationFailure
Expand All @@ -7,17 +11,13 @@
// • an over-limit → PaymentDeclined → non-retryable ApplicationFailure → workflow FAILS
// immediately (no retry storm), surfacing the domain reason
import { GenericContainer, type StartedTestContainer } from "testcontainers";
import { Client, Connection } from "@temporalio/client";
import { NativeConnection, Worker } from "@temporalio/worker";
import { Layer } from "demesne";
import { afterAll, beforeAll, describe, expect, it } from "vitest";

import { ActivityRegistry } from "@btravstack/start-temporal";
import { bootstrap } from "./bootstrap.js";
import { ConfigLive } from "./config.js";
import type { ChargeCommand, Receipt } from "./domain.js";
import { toApplicationFailures } from "./infra/temporal.js";
import { PaymentsLive } from "./infra/payments.js";
import { toApplicationFailures } from "./infra/temporal.js";
import { workflowsPath } from "./workflows-path.js";

type OrderWorkflow = (command: ChargeCommand) => Promise<Receipt>;
Expand Down
2 changes: 1 addition & 1 deletion examples/start-temporal-worker/src/worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import { Layer } from "demesne";

import { bootstrap } from "./bootstrap.js";
import { ConfigLive } from "./config.js";
import { toApplicationFailures } from "./infra/temporal.js";
import { PaymentsLive } from "./infra/payments.js";
import { toApplicationFailures } from "./infra/temporal.js";
import { workflowsPath } from "./workflows-path.js";

const built = await Layer.build(Layer.provideTo(bootstrap(PaymentsLive), ConfigLive));
Expand Down
1 change: 1 addition & 0 deletions knip.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"$schema": "https://unpkg.com/knip@6/schema.json",
"ignoreExportsUsedInFile": true,
"ignore": ["**/*.test-d.ts"],
"ignoreDependencies": ["@btravstack/oxlint"],
"workspaces": {
"packages/*": {
"project": ["src/**/*.ts"],
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,10 @@
"version": "changeset version"
},
"devDependencies": {
"@btravstack/commitlint": "catalog:",
"@btravstack/oxlint": "catalog:",
"@changesets/cli": "catalog:",
"@commitlint/cli": "catalog:",
"@commitlint/config-conventional": "catalog:",
"knip": "catalog:",
"lefthook": "catalog:",
"oxfmt": "catalog:",
Expand Down
4 changes: 2 additions & 2 deletions packages/start-amqp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@
"devDependencies": {
"@arethetypeswrong/cli": "catalog:",
"@btravstack/start-kernel": "workspace:*",
"@btravstack/tsconfig": "workspace:*",
"@btravstack/typedoc": "workspace:*",
"@btravstack/tsconfig": "catalog:",
"@btravstack/typedoc": "catalog:",
"@types/node": "catalog:",
"@vitest/coverage-v8": "catalog:",
"demesne": "catalog:",
Expand Down
4 changes: 2 additions & 2 deletions packages/start-api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@
"devDependencies": {
"@arethetypeswrong/cli": "catalog:",
"@btravstack/start-kernel": "workspace:*",
"@btravstack/tsconfig": "workspace:*",
"@btravstack/typedoc": "workspace:*",
"@btravstack/tsconfig": "catalog:",
"@btravstack/typedoc": "catalog:",
"@types/node": "catalog:",
"@vitest/coverage-v8": "catalog:",
"demesne": "catalog:",
Expand Down
4 changes: 2 additions & 2 deletions packages/start-kernel/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@
},
"devDependencies": {
"@arethetypeswrong/cli": "catalog:",
"@btravstack/tsconfig": "workspace:*",
"@btravstack/typedoc": "workspace:*",
"@btravstack/tsconfig": "catalog:",
"@btravstack/typedoc": "catalog:",
"@types/node": "catalog:",
"@unthrown/vitest": "catalog:",
"@vitest/coverage-v8": "catalog:",
Expand Down
1 change: 0 additions & 1 deletion packages/start-kernel/src/config.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import "@unthrown/vitest";

import { Layer } from "demesne";
import { describe, expect, it } from "vitest";
import { z } from "zod";
Expand Down
1 change: 0 additions & 1 deletion packages/start-kernel/src/contract.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import "@unthrown/vitest";

import { describe, expect, it } from "vitest";
import { z } from "zod";

Expand Down
1 change: 0 additions & 1 deletion packages/start-kernel/src/handler.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import "@unthrown/vitest";

import { type Context, Layer, Tag } from "demesne";
import { type AsyncResult, Err, Ok, TaggedError } from "unthrown";
import { describe, expect, it } from "vitest";
Expand Down
1 change: 0 additions & 1 deletion packages/start-kernel/src/host.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import "@unthrown/vitest";

import { Layer, Tag } from "demesne";
import { Ok } from "unthrown";
import { describe, expect, it } from "vitest";
Expand Down
4 changes: 2 additions & 2 deletions packages/start-temporal/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@
"devDependencies": {
"@arethetypeswrong/cli": "catalog:",
"@btravstack/start-kernel": "workspace:*",
"@btravstack/tsconfig": "workspace:*",
"@btravstack/typedoc": "workspace:*",
"@btravstack/tsconfig": "catalog:",
"@btravstack/typedoc": "catalog:",
"@types/node": "catalog:",
"@vitest/coverage-v8": "catalog:",
"demesne": "catalog:",
Expand Down
Loading
Loading