@naisys/erp 3.0.2 → 3.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (32) hide show
  1. package/README.md +60 -0
  2. package/client-dist/assets/{index-D5R6NBeW.js → index-CiuQ3CYv.js} +192 -87
  3. package/client-dist/index.html +1 -1
  4. package/dist/database/dbConfig.js +1 -1
  5. package/dist/erpServer.js +2 -3
  6. package/dist/generated/prisma/internal/class.js +4 -4
  7. package/dist/generated/prisma/internal/prismaNamespace.js +1 -0
  8. package/dist/middleware/auth-middleware.js +39 -7
  9. package/dist/route-helpers.js +4 -2
  10. package/dist/routes/operations/operation-dependencies.js +1 -0
  11. package/dist/routes/operations/operation-field-refs.js +1 -0
  12. package/dist/routes/operations/operation-run-comments.js +1 -0
  13. package/dist/routes/operations/operation-runs.js +3 -0
  14. package/dist/routes/production/dispatch.js +15 -9
  15. package/dist/routes/production/labor-tickets.js +1 -0
  16. package/dist/routes/production/work-centers.js +2 -0
  17. package/dist/routes/users/auth.js +4 -1
  18. package/dist/routes/users/users.js +28 -16
  19. package/dist/services/operations/operation-dependency-service.js +1 -1
  20. package/dist/services/operations/operation-run-comment-service.js +1 -1
  21. package/dist/services/operations/operation-run-service.js +6 -6
  22. package/dist/services/operations/step-run-service.js +4 -4
  23. package/dist/services/orders/order-run-service.js +2 -2
  24. package/dist/services/production/field-ref-service.js +1 -1
  25. package/dist/services/production/labor-ticket-service.js +3 -3
  26. package/dist/services/production/work-center-service.js +2 -2
  27. package/dist/services/user-service.js +58 -9
  28. package/npm-shrinkwrap.json +28 -28
  29. package/package.json +11 -6
  30. package/prisma/migrations/20260528000000_add_user_title/migration.sql +1 -0
  31. package/prisma/schema.prisma +1 -0
  32. package/dist/services/production/labor-ticket-backfill.js +0 -67
package/README.md ADDED
@@ -0,0 +1,60 @@
1
+ # @naisys/erp (server)
2
+
3
+ [← Back to ERP](../README.md) | [← Back to main README](../../../README.md)
4
+
5
+ Fastify server for the NAISYS ERP. Owns the ERP database (Prisma + SQLite), serves the REST API, hosts the bundled React client, and exposes an agent-facing HATEOAS API discoverable at runtime.
6
+
7
+ This is the npm-published half of `@naisys/erp` — the bundled client lives in `../client/` at dev time and gets copied into `client-dist/` for publish.
8
+
9
+ ## Running
10
+
11
+ Standalone:
12
+
13
+ ```bash
14
+ npm install @naisys/erp
15
+ npx naisys-erp
16
+ ```
17
+
18
+ See the [ERP README](../README.md) for the full configuration (`NAISYS_FOLDER`, `SERVER_PORT`, `SUPERVISOR_AUTH`, `PUBLIC_READ`) and feature list.
19
+
20
+ Dev mode (from monorepo):
21
+
22
+ ```bash
23
+ npm run dev --workspace=@naisys/erp
24
+ ```
25
+
26
+ ## Structure
27
+
28
+ - **`erpServer.ts`** — Fastify bootstrap (cookies, CORS, multipart, rate limit, static client, swagger/scalar API ref)
29
+ - **`erpRoutes.ts`** — route registration entry point
30
+ - **`routes/`** — per-resource routes (orders, operations, steps, fields, items, etc.) with co-located HATEOAS action/link builders
31
+ - **`services/`** — business logic kept out of routes
32
+ - **`database/`** — Prisma client wiring, schema-version check, migration deploy
33
+ - **`hateoas.ts`** / **`schemaRegistry.ts`** / **`route-helpers.ts`** — generic HATEOAS helpers, per-endpoint schema discovery, slim-response helpers
34
+ - **`middleware/`** — auth, permission gating
35
+ - **`tests/`** — Vitest API tests and Playwright UI E2E
36
+
37
+ ## API design
38
+
39
+ - HATEOAS-driven discoverable REST API — see [doc 012](../../../docs/012-hateoas.md)
40
+ - Disabled actions include a reason so agents understand the gate
41
+ - Batch endpoints, slim responses on mutations, per-endpoint schema (not bulk OpenAPI)
42
+ - Zod-validated multipart input with type coercion and hints
43
+ - Hash-based attachment storage for step fields
44
+
45
+ ## Auth
46
+
47
+ - Local ERP auth, or shared session/passkey auth with supervisor when `SUPERVISOR_AUTH=true` (see [doc 007](../../../docs/007-web-auth.md))
48
+ - Agent API keys for cross-app calls
49
+
50
+ ## Scripts
51
+
52
+ - `npm run dev` — `tsx watch` against `src/erpServer.ts`
53
+ - `npm run build` — Prisma generate + tsc
54
+ - `npm run bundle` — copy the built client into `client-dist/` for publish
55
+ - `npm run start` — run `dist/erpServer.js`
56
+ - `npm test` — Vitest + Playwright
57
+
58
+ ## License
59
+
60
+ MIT