@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
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@naisys/erp",
3
- "version": "3.0.2",
3
+ "version": "3.0.3",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "@naisys/erp",
9
- "version": "3.0.2",
9
+ "version": "3.0.3",
10
10
  "dependencies": {
11
11
  "@fastify/cookie": "^11.0.2",
12
12
  "@fastify/cors": "^11.2.0",
@@ -14,11 +14,11 @@
14
14
  "@fastify/rate-limit": "^10.3.0",
15
15
  "@fastify/static": "^9.1.3",
16
16
  "@fastify/swagger": "^9.7.0",
17
- "@naisys/common": "3.0.2",
18
- "@naisys/common-node": "3.0.2",
19
- "@naisys/erp-shared": "3.0.2",
20
- "@naisys/hub-database": "3.0.2",
21
- "@naisys/supervisor-database": "3.0.2",
17
+ "@naisys/common": "3.0.3",
18
+ "@naisys/common-node": "3.0.3",
19
+ "@naisys/erp-shared": "3.0.3",
20
+ "@naisys/hub-database": "3.0.3",
21
+ "@naisys/supervisor-database": "3.0.3",
22
22
  "@prisma/adapter-better-sqlite3": "^7.8.0",
23
23
  "@prisma/client": "^7.8.0",
24
24
  "@scalar/fastify-api-reference": "^1.57.5",
@@ -394,9 +394,9 @@
394
394
  }
395
395
  },
396
396
  "node_modules/@naisys/common": {
397
- "version": "3.0.2",
398
- "resolved": "https://registry.npmjs.org/@naisys/common/-/common-3.0.2.tgz",
399
- "integrity": "sha512-SseLo+QG2xvbFTZm1gMD/kDG84VaZuj2ZRo9nlNuvWYpQH9QaJDNprXh/MI/xLxmFCGNZRbIi9QNydhFDRBy6g==",
397
+ "version": "3.0.3",
398
+ "resolved": "https://registry.npmjs.org/@naisys/common/-/common-3.0.3.tgz",
399
+ "integrity": "sha512-rfmVhXuIzpc71SbD3U6bDdqSuyLq5OUaRonTT8hPzaPhFeHSmJp1z3RCOke2RR4UsqrCT+rbKBSmplqOZjGe3g==",
400
400
  "dependencies": {
401
401
  "cron-parser": "^5.5.0",
402
402
  "semver": "^7.8.1",
@@ -404,32 +404,32 @@
404
404
  }
405
405
  },
406
406
  "node_modules/@naisys/common-node": {
407
- "version": "3.0.2",
408
- "resolved": "https://registry.npmjs.org/@naisys/common-node/-/common-node-3.0.2.tgz",
409
- "integrity": "sha512-fVVqnmnvOdfiEQXH+OFtwlpk+moPlx2OfA9FzCVblIuHsGfB8NKC2tQyUoih+L0AEet04V/DkfarN1SKnCGczQ==",
407
+ "version": "3.0.3",
408
+ "resolved": "https://registry.npmjs.org/@naisys/common-node/-/common-node-3.0.3.tgz",
409
+ "integrity": "sha512-VG6NSHU7bRsUS9nKPcjGaPv2vb+KG+iyFMe40dldQ0O6bQfW3Y6GC9QYAmQM2wJE1SJINSAL5W+xVkYCLrYbBA==",
410
410
  "dependencies": {
411
- "@naisys/common": "3.0.2",
411
+ "@naisys/common": "3.0.3",
412
412
  "better-sqlite3": "^12.10.0",
413
413
  "js-yaml": "^4.1.1",
414
414
  "pino": "^10.3.1"
415
415
  }
416
416
  },
417
417
  "node_modules/@naisys/erp-shared": {
418
- "version": "3.0.2",
419
- "resolved": "https://registry.npmjs.org/@naisys/erp-shared/-/erp-shared-3.0.2.tgz",
420
- "integrity": "sha512-rh8y6BrVLfbe+esOcSmiwBNUdBPbyHbTjYXVhAvDSQCQRoOLwCkZ5j8X9YohzSYdTyu/O+Uhifcs6wr7q8Qsgw==",
418
+ "version": "3.0.3",
419
+ "resolved": "https://registry.npmjs.org/@naisys/erp-shared/-/erp-shared-3.0.3.tgz",
420
+ "integrity": "sha512-AaE6eWCS1QkFmqhOfK9N94MUobz1K1tooLGqazFHKvpzvz+VFWlHYTE7zL1bafWmAGubVPmE/om/xRvbuXooLg==",
421
421
  "dependencies": {
422
- "@naisys/common": "3.0.2",
422
+ "@naisys/common": "3.0.3",
423
423
  "zod": "^4.4.3"
424
424
  }
425
425
  },
426
426
  "node_modules/@naisys/hub-database": {
427
- "version": "3.0.2",
428
- "resolved": "https://registry.npmjs.org/@naisys/hub-database/-/hub-database-3.0.2.tgz",
429
- "integrity": "sha512-IjjDzUKAZ7Gfz2PF64Fwlx3s2giz/Cgt8EdPrvOzMo+NdCuO4zo1qDhkREcR/o4skczWyf2wcrLo01pMjonZ9g==",
427
+ "version": "3.0.3",
428
+ "resolved": "https://registry.npmjs.org/@naisys/hub-database/-/hub-database-3.0.3.tgz",
429
+ "integrity": "sha512-41jbghgyyTrehdnsHxkHJPJmbJpTcou+vGxavklfmLpwx1D+D298oY3mLhiWOjccZyIapM8nkqsflkds1Iyxdg==",
430
430
  "dependencies": {
431
- "@naisys/common": "3.0.2",
432
- "@naisys/common-node": "3.0.2",
431
+ "@naisys/common": "3.0.3",
432
+ "@naisys/common-node": "3.0.3",
433
433
  "@prisma/adapter-better-sqlite3": "^7.8.0",
434
434
  "@prisma/client": "^7.8.0",
435
435
  "better-sqlite3": "^12.10.0",
@@ -437,12 +437,12 @@
437
437
  }
438
438
  },
439
439
  "node_modules/@naisys/supervisor-database": {
440
- "version": "3.0.2",
441
- "resolved": "https://registry.npmjs.org/@naisys/supervisor-database/-/supervisor-database-3.0.2.tgz",
442
- "integrity": "sha512-F+4AoNgILgqTTnlIP01vazWsqfo7cMtiJdO6zGDcNNA+qUT8MMOy0W7+dkjbXE46FY7qGJ3ZYmJ4uoMlIqkikQ==",
440
+ "version": "3.0.3",
441
+ "resolved": "https://registry.npmjs.org/@naisys/supervisor-database/-/supervisor-database-3.0.3.tgz",
442
+ "integrity": "sha512-jCAVIx1EwU9vaUXD1hvx3eoVVVkuf5l5CUlgvSKdeyBvXsebhcYuT2/pygpoi8V3hQJdoCU65GQk7mOAJjwKFQ==",
443
443
  "dependencies": {
444
- "@naisys/common": "3.0.2",
445
- "@naisys/common-node": "3.0.2",
444
+ "@naisys/common": "3.0.3",
445
+ "@naisys/common-node": "3.0.3",
446
446
  "@prisma/adapter-better-sqlite3": "^7.8.0",
447
447
  "@prisma/client": "^7.8.0",
448
448
  "bcryptjs": "^3.0.3",
package/package.json CHANGED
@@ -1,7 +1,12 @@
1
1
  {
2
2
  "name": "@naisys/erp",
3
- "version": "3.0.2",
3
+ "version": "3.0.3",
4
4
  "description": "NAISYS ERP - Web UI for AI-driven order and work management",
5
+ "repository": {
6
+ "type": "git",
7
+ "url": "git+https://github.com/swax/NAISYS.git",
8
+ "directory": "apps/erp/server"
9
+ },
5
10
  "type": "module",
6
11
  "main": "dist/erpServer.js",
7
12
  "bin": {
@@ -46,11 +51,11 @@
46
51
  "@fastify/rate-limit": "^10.3.0",
47
52
  "@fastify/static": "^9.1.3",
48
53
  "@fastify/swagger": "^9.7.0",
49
- "@naisys/common": "3.0.2",
50
- "@naisys/common-node": "3.0.2",
51
- "@naisys/erp-shared": "3.0.2",
52
- "@naisys/hub-database": "3.0.2",
53
- "@naisys/supervisor-database": "3.0.2",
54
+ "@naisys/common": "3.0.3",
55
+ "@naisys/common-node": "3.0.3",
56
+ "@naisys/erp-shared": "3.0.3",
57
+ "@naisys/hub-database": "3.0.3",
58
+ "@naisys/supervisor-database": "3.0.3",
54
59
  "@prisma/adapter-better-sqlite3": "^7.8.0",
55
60
  "@prisma/client": "^7.8.0",
56
61
  "@scalar/fastify-api-reference": "^1.57.5",
@@ -0,0 +1 @@
1
+ ALTER TABLE "users" ADD COLUMN "title" TEXT NOT NULL DEFAULT '';
@@ -419,6 +419,7 @@ model User {
419
419
  id Int @id @default(autoincrement())
420
420
  uuid String @unique
421
421
  username String @unique
422
+ title String @default("")
422
423
  passwordHash String? @map("password_hash")
423
424
  apiKeyHash String? @unique @map("api_key_hash")
424
425
  isAgent Boolean @default(false) @map("is_agent")
@@ -1,67 +0,0 @@
1
- import { OperationRunStatus } from "@naisys/erp-shared";
2
- import { sumAgentMetricsByUuid } from "@naisys/hub-database";
3
- import erpDb from "../../database/erpDb.js";
4
- /**
5
- * Populate `tokens` on labor tickets and operation runs finalized before the
6
- * column existed. Idempotent — only touches rows where `tokens IS NULL`, and
7
- * only for agent users (others can't have tokens, so their rows stay NULL
8
- * and the next startup ignores them too). Requires the hub DB client.
9
- */
10
- export async function backfillOpRunTokens() {
11
- const tickets = await erpDb.laborTicket.findMany({
12
- where: {
13
- tokens: null,
14
- clockOut: { not: null },
15
- operationRun: {
16
- status: {
17
- in: [
18
- OperationRunStatus.completed,
19
- OperationRunStatus.skipped,
20
- OperationRunStatus.failed,
21
- ],
22
- },
23
- },
24
- user: { isAgent: true },
25
- },
26
- select: {
27
- id: true,
28
- operationRunId: true,
29
- clockIn: true,
30
- clockOut: true,
31
- user: { select: { uuid: true } },
32
- },
33
- });
34
- if (tickets.length === 0)
35
- return;
36
- const dirtyOpRunIds = new Set();
37
- for (const ticket of tickets) {
38
- const { tokens } = await sumAgentMetricsByUuid(ticket.user.uuid, ticket.clockIn, ticket.clockOut);
39
- await erpDb.laborTicket.update({
40
- where: { id: ticket.id },
41
- data: { tokens: Math.round(tokens) },
42
- });
43
- dirtyOpRunIds.add(ticket.operationRunId);
44
- }
45
- // Re-aggregate touched op_runs. Skip rows that already have a snapshot so
46
- // we never clobber a value set by the normal transition path.
47
- for (const opRunId of dirtyOpRunIds) {
48
- const opRun = await erpDb.operationRun.findUnique({
49
- where: { id: opRunId },
50
- select: { tokens: true },
51
- });
52
- if (!opRun || opRun.tokens !== null)
53
- continue;
54
- const agg = await erpDb.laborTicket.aggregate({
55
- where: { operationRunId: opRunId },
56
- _sum: { tokens: true },
57
- });
58
- const total = agg._sum.tokens ?? 0;
59
- if (total > 0) {
60
- await erpDb.operationRun.update({
61
- where: { id: opRunId },
62
- data: { tokens: total },
63
- });
64
- }
65
- }
66
- }
67
- //# sourceMappingURL=labor-ticket-backfill.js.map