@spinekit/inventory
WMS / inventory — the Flow kernel (quants, moves, reservations, lots) as an arc resource fleet.
Part of Spine, Classytic's ERP — the arc-module layer that composes the
framework-agnostic @classytic/flow kernel into an @classytic/arc
application via createApp({ modules }).
Install
npm install @spinekit/inventory @classytic/flow @classytic/arc @classytic/mongokit mongoose zod
Kernels and the framework are peer dependencies — the host installs a single copy; this module bundles nothing.
Usage
The module is a composition SHELL: the host initializes the WMS engine
(BYO — e.g. @classytic/flow's, which carries app bridges + FLOW_MODE
gating) and hands it in together with a factory that builds the resource
fleet. createInventoryModule takes exactly:
createInventoryModule({
engine, // your initialized WMS engine — exported at arc.modules.inventory
resources, // () => ResourceLike[] — invoked post-bootstrap, engine live
afterResources?, // (fastify) => void | Promise<void> — post-registration wiring
onClose?, // (fastify) => void | Promise<void> — teardown
})
A working composition (mirrors be-prod's inventory-module.wiring.ts):
import { createApp } from '@classytic/arc/factory';
import {
createInventoryModule,
createFlowModeGate,
createLandedCostResource,
createLotResource,
} from '@spinekit/inventory';
// 1. Host initializes the engine (flow: models/repositories/services bags).
const engine = await initFlowEngine();
// 2. Host-owned seams: mode gate + auth → WMS-context guard.
const modeGate = createFlowModeGate({ getMode: () => engine.services.mode as string });
const ctxGuard = myFlowCtxGuard; // arc defineGuard shape: { preHandler, from(req) }
// 3. Factories close over the engine; permissions are host role gates.
const wmsDeps = { engine, ctxGuard, modeGate };
const app = await createApp({
modules: [
createInventoryModule({
engine,
resources: () => [
createLotResource({
...wmsDeps,
permissions: { view: perms.lotView, manage: perms.lotManage },
}),
createLandedCostResource({
...wmsDeps,
publishEvent: publish, // host event bus — accounting bridges consume
permissions: { view: perms.lcView, manage: perms.lcManage, apply: perms.lcApply },
}),
// ...the rest of the fleet, plus any host-side resources
],
}),
],
});
The module's bootstrap return (the engine) is recorded at
fastify.arc.modules['inventory'] for container-free cross-module wiring
(COGS bridges, supplier-performance, sync capture).
Every factory follows the standardized WmsFactoryDeps contract:
{ engine, ctxGuard, modeGate, permissions, publishEvent? } — see
src/resources/shared.ts. Branch bootstrap (org → default warehouse node +
locations) stays host-side by design.
Roadmap
- Engine-owning construction (the module initializes the WMS engine from config instead of BYO) is a planned extraction.
The core stock resources — nodes, locations, quants, moves, reservations, reports, trace — are currently host-side.Done (0.4.0): nodes, locations, availability/quants, reservations, movements/move-groups, adjustments, reports, trace, cost, and scan are package factories, lifted at exact wire parity from be-prod (the composition point never changed).
License
MIT Classytic