ConusAI vendor v0.1.0-beta.114
ci / gate (push) Waiting to run

This commit is contained in:
ConusAI vendor v0.1.0-beta.114
2026-11-14 09:56:45 +00:00
commit 1ce8d23c35
867 changed files with 122104 additions and 0 deletions
@@ -0,0 +1,36 @@
// Prepared request binding is required; injected test ports preserve kind capabilities.
import { AppError, Container } from "@conusai-kit/core"
import { describe, expect, it } from "vitest"
import { inventoryServiceOf } from "../adapters/service.js"
import { INVENTORY_SERVICE, type InventoryService } from "../core/ports.js"
const service = {
bindingId: "01900000-0000-7000-8000-000000000001",
createItem: async () => {
throw new Error("not called")
},
} as unknown as InventoryService
describe("inventoryServiceOf", () => {
it("hands a read handler the bound service's reads only, and an effect handler all of it", () => {
const root = new Container()
root.value(INVENTORY_SERVICE, service)
const read = inventoryServiceOf(root.restrict("read"), "read") as unknown as Record<string, unknown>
expect(read.createItem).toBeUndefined()
expect(read.bindingId).toBe("01900000-0000-7000-8000-000000000001")
expect(inventoryServiceOf(root.restrict("effect"), "effect").createItem).toBe(service.createItem)
})
it("refuses a request without a prepared partition binding", () => {
let thrown: unknown
try {
inventoryServiceOf(new Container(), "read")
} catch (error) {
thrown = error
}
expect(thrown).toBeInstanceOf(AppError)
expect((thrown as AppError).problem).toMatchObject({ status: 409, code: "service_partition_missing" })
expect((thrown as AppError).problem.detail).not.toContain("token")
})
})