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
+79
View File
@@ -0,0 +1,79 @@
// The handlers of the module's procedures: each takes the service its kind may use and calls one use
// case. No rule lives here.
import { implement } from "@conusai-kit/core"
import {
itemAvailability,
itemCreate,
itemList,
reservationList,
stockRelease,
stockReserve,
} from "../contract/index.js"
import {
itemAvailability as availabilityOf,
createItem,
listItems,
listProjectReservations,
releaseStock,
reserveStock,
} from "../core/inventory.js"
import { inventoryServiceOf } from "./service.js"
const cursorOf = (input: { after?: string | undefined; limit?: number | undefined }) => ({
...(input.after === undefined ? {} : { after: input.after }),
...(input.limit === undefined ? {} : { limit: input.limit }),
})
export const itemListImpl = implement(itemList, ({ input, ctx }) =>
listItems(inventoryServiceOf(ctx.container, ctx.kind), {
...(input.q === undefined ? {} : { q: input.q }),
...cursorOf(input),
}),
)
export const itemCreateImpl = implement(itemCreate, ({ input, ctx }) =>
createItem(inventoryServiceOf(ctx.container, "effect"), {
sku: input.sku,
name: input.name,
unit: input.unit,
...(input.description === undefined ? {} : { description: input.description }),
}),
)
export const itemAvailabilityImpl = implement(itemAvailability, ({ input, ctx }) =>
availabilityOf(inventoryServiceOf(ctx.container, ctx.kind), input.itemId),
)
export const reservationListImpl = implement(reservationList, ({ input, ctx }) =>
listProjectReservations(inventoryServiceOf(ctx.container, ctx.kind), ctx.scope, {
...(input.status === undefined ? {} : { status: input.status }),
...cursorOf(input),
}),
)
export const stockReserveImpl = implement(stockReserve, ({ input, ctx }) =>
reserveStock(inventoryServiceOf(ctx.container, "effect"), ctx.scope, {
itemId: input.itemId,
locationId: input.locationId,
quantity: input.quantity,
requestId: input.requestId,
}),
)
export const stockReleaseImpl = implement(stockRelease, ({ input, ctx }) =>
releaseStock(inventoryServiceOf(ctx.container, "effect"), ctx.scope, {
reservationId: input.reservationId,
...(input.quantity === undefined ? {} : { quantity: input.quantity }),
requestId: input.requestId,
}),
)
export const INVENTORY_PROCEDURES = [
itemListImpl,
itemCreateImpl,
itemAvailabilityImpl,
reservationListImpl,
stockReserveImpl,
stockReleaseImpl,
]