@naisys/erp 3.0.0-beta.46 → 3.0.0-beta.47
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.
- package/client-dist/assets/{index-BWVp_WEm.js → index-Bu_bS_Vd.js} +723 -698
- package/client-dist/index.html +1 -1
- package/dist/{erpDb.js → database/erpDb.js} +1 -1
- package/dist/erpRoutes.js +28 -28
- package/dist/erpServer.js +7 -7
- package/dist/{auth-middleware.js → middleware/auth-middleware.js} +1 -1
- package/dist/route-helpers.js +2 -2
- package/dist/routes/admin.js +3 -3
- package/dist/routes/audit.js +1 -1
- package/dist/routes/{item-fields.js → items/item-fields.js} +7 -7
- package/dist/routes/{item-instances.js → items/item-instances.js} +7 -7
- package/dist/routes/{items.js → items/items.js} +5 -5
- package/dist/routes/{operation-dependencies.js → operations/operation-dependencies.js} +6 -6
- package/dist/routes/{operation-field-refs.js → operations/operation-field-refs.js} +6 -6
- package/dist/routes/{operation-run-comments.js → operations/operation-run-comments.js} +5 -5
- package/dist/routes/{operation-run-transitions.js → operations/operation-run-transitions.js} +6 -6
- package/dist/routes/{operation-runs.js → operations/operation-runs.js} +5 -5
- package/dist/routes/{operations.js → operations/operations.js} +6 -6
- package/dist/routes/{order-revision-transitions.js → orders/order-revision-transitions.js} +4 -4
- package/dist/routes/{order-revisions.js → orders/order-revisions.js} +6 -6
- package/dist/routes/{order-run-transitions.js → orders/order-run-transitions.js} +4 -4
- package/dist/routes/{order-runs.js → orders/order-runs.js} +5 -5
- package/dist/routes/{orders.js → orders/orders.js} +5 -5
- package/dist/routes/{dispatch.js → production/dispatch.js} +3 -3
- package/dist/routes/{inventory.js → production/inventory.js} +3 -3
- package/dist/routes/{labor-tickets.js → production/labor-tickets.js} +5 -5
- package/dist/routes/{work-centers.js → production/work-centers.js} +5 -5
- package/dist/routes/root.js +1 -1
- package/dist/routes/{step-field-attachments.js → steps/step-field-attachments.js} +8 -8
- package/dist/routes/{step-fields.js → steps/step-fields.js} +6 -6
- package/dist/routes/{step-run-fields.js → steps/step-run-fields.js} +9 -9
- package/dist/routes/{step-run-transitions.js → steps/step-run-transitions.js} +6 -6
- package/dist/routes/{step-runs.js → steps/step-runs.js} +7 -7
- package/dist/routes/{steps.js → steps/steps.js} +5 -5
- package/dist/routes/{auth.js → users/auth.js} +4 -4
- package/dist/routes/{user-permissions.js → users/user-permissions.js} +4 -4
- package/dist/routes/{users.js → users/users.js} +5 -5
- package/dist/services/attachment-service.js +1 -1
- package/dist/services/{item-instance-service.js → inventory/item-instance-service.js} +2 -2
- package/dist/services/{item-service.js → inventory/item-service.js} +2 -2
- package/dist/services/{operation-dependency-service.js → operations/operation-dependency-service.js} +1 -1
- package/dist/services/{operation-run-comment-service.js → operations/operation-run-comment-service.js} +1 -1
- package/dist/services/{operation-run-service.js → operations/operation-run-service.js} +3 -3
- package/dist/services/{operation-service.js → operations/operation-service.js} +2 -2
- package/dist/services/{step-run-service.js → operations/step-run-service.js} +1 -1
- package/dist/services/{step-service.js → operations/step-service.js} +2 -2
- package/dist/services/{order-revision-service.js → orders/order-revision-service.js} +2 -2
- package/dist/services/{order-run-service.js → orders/order-run-service.js} +2 -2
- package/dist/services/{order-service.js → orders/order-service.js} +2 -2
- package/dist/services/{revision-diff-service.js → orders/revision-diff-service.js} +1 -1
- package/dist/services/{field-ref-service.js → production/field-ref-service.js} +1 -1
- package/dist/services/{field-service.js → production/field-service.js} +2 -2
- package/dist/services/{field-value-service.js → production/field-value-service.js} +1 -1
- package/dist/services/{labor-ticket-service.js → production/labor-ticket-service.js} +1 -1
- package/dist/services/{work-center-service.js → production/work-center-service.js} +2 -2
- package/dist/services/user-service.js +84 -1
- package/npm-shrinkwrap.json +28 -28
- package/package.json +6 -6
- package/dist/userService.js +0 -87
- /package/dist/{dbConfig.js → database/dbConfig.js} +0 -0
- /package/dist/{supervisorAuth.js → middleware/supervisorAuth.js} +0 -0
- /package/dist/{audit.js → services/audit.js} +0 -0
package/client-dist/index.html
CHANGED
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
<meta name="format-detection" content="telephone=no" />
|
|
46
46
|
|
|
47
47
|
<title>NAISYS ERP</title>
|
|
48
|
-
<script type="module" crossorigin src="/erp/assets/index-
|
|
48
|
+
<script type="module" crossorigin src="/erp/assets/index-Bu_bS_Vd.js"></script>
|
|
49
49
|
<link rel="modulepreload" crossorigin href="/erp/assets/rolldown-runtime-CvHMtSRF.js">
|
|
50
50
|
<link rel="modulepreload" crossorigin href="/erp/assets/vendor-Co7ZCNxO.js">
|
|
51
51
|
<link rel="stylesheet" crossorigin href="/erp/assets/vendor-CLUPjUnv.css">
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { PrismaBetterSqlite3 } from "@prisma/adapter-better-sqlite3";
|
|
2
|
+
import { PrismaClient } from "../generated/prisma/client.js";
|
|
2
3
|
import { erpDbUrl } from "./dbConfig.js";
|
|
3
|
-
import { PrismaClient } from "./generated/prisma/client.js";
|
|
4
4
|
let _db;
|
|
5
5
|
/**
|
|
6
6
|
* Initialize the ERP database connection and run SQLite pragmas.
|
package/dist/erpRoutes.js
CHANGED
|
@@ -1,35 +1,35 @@
|
|
|
1
|
+
import { isSupervisorAuth } from "./middleware/supervisorAuth.js";
|
|
1
2
|
import adminRoutes from "./routes/admin.js";
|
|
2
3
|
import auditRoutes from "./routes/audit.js";
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
import
|
|
12
|
-
import
|
|
13
|
-
import
|
|
14
|
-
import
|
|
15
|
-
import
|
|
16
|
-
import
|
|
17
|
-
import
|
|
18
|
-
import
|
|
19
|
-
import
|
|
20
|
-
import
|
|
4
|
+
import itemFieldRoutes from "./routes/items/item-fields.js";
|
|
5
|
+
import itemInstanceRoutes from "./routes/items/item-instances.js";
|
|
6
|
+
import itemRoutes from "./routes/items/items.js";
|
|
7
|
+
import operationDependencyRoutes from "./routes/operations/operation-dependencies.js";
|
|
8
|
+
import operationFieldRefRoutes from "./routes/operations/operation-field-refs.js";
|
|
9
|
+
import operationRunCommentRoutes from "./routes/operations/operation-run-comments.js";
|
|
10
|
+
import operationRunTransitionRoutes from "./routes/operations/operation-run-transitions.js";
|
|
11
|
+
import operationRunRoutes from "./routes/operations/operation-runs.js";
|
|
12
|
+
import operationRoutes from "./routes/operations/operations.js";
|
|
13
|
+
import orderRevisionTransitionRoutes from "./routes/orders/order-revision-transitions.js";
|
|
14
|
+
import orderRevisionRoutes from "./routes/orders/order-revisions.js";
|
|
15
|
+
import orderRunTransitionRoutes from "./routes/orders/order-run-transitions.js";
|
|
16
|
+
import orderRunRoutes from "./routes/orders/order-runs.js";
|
|
17
|
+
import orderRoutes from "./routes/orders/orders.js";
|
|
18
|
+
import dispatchRoutes from "./routes/production/dispatch.js";
|
|
19
|
+
import inventoryRoutes from "./routes/production/inventory.js";
|
|
20
|
+
import laborTicketRoutes from "./routes/production/labor-tickets.js";
|
|
21
|
+
import workCenterRoutes from "./routes/production/work-centers.js";
|
|
21
22
|
import rootRoute from "./routes/root.js";
|
|
22
23
|
import schemaRoutes from "./routes/schemas.js";
|
|
23
|
-
import stepFieldAttachmentRoutes from "./routes/step-field-attachments.js";
|
|
24
|
-
import stepFieldRoutes from "./routes/step-fields.js";
|
|
25
|
-
import stepRunFieldRoutes from "./routes/step-run-fields.js";
|
|
26
|
-
import stepRunTransitionRoutes from "./routes/step-run-transitions.js";
|
|
27
|
-
import stepRunRoutes from "./routes/step-runs.js";
|
|
28
|
-
import stepRoutes from "./routes/steps.js";
|
|
29
|
-
import
|
|
30
|
-
import
|
|
31
|
-
import
|
|
32
|
-
import { isSupervisorAuth } from "./supervisorAuth.js";
|
|
24
|
+
import stepFieldAttachmentRoutes from "./routes/steps/step-field-attachments.js";
|
|
25
|
+
import stepFieldRoutes from "./routes/steps/step-fields.js";
|
|
26
|
+
import stepRunFieldRoutes from "./routes/steps/step-run-fields.js";
|
|
27
|
+
import stepRunTransitionRoutes from "./routes/steps/step-run-transitions.js";
|
|
28
|
+
import stepRunRoutes from "./routes/steps/step-runs.js";
|
|
29
|
+
import stepRoutes from "./routes/steps/steps.js";
|
|
30
|
+
import authRoutes from "./routes/users/auth.js";
|
|
31
|
+
import userPermissionRoutes from "./routes/users/user-permissions.js";
|
|
32
|
+
import userRoutes from "./routes/users/users.js";
|
|
33
33
|
export const erpRoutes = (fastify) => {
|
|
34
34
|
fastify.register(adminRoutes, { prefix: "/erp/api/admin" });
|
|
35
35
|
fastify.register(auditRoutes, { prefix: "/erp/api/audit" });
|
package/dist/erpServer.js
CHANGED
|
@@ -19,13 +19,13 @@ import path from "path";
|
|
|
19
19
|
import { fileURLToPath } from "url";
|
|
20
20
|
import { takeCoverage } from "v8";
|
|
21
21
|
import { registerApiReference } from "./api-reference.js";
|
|
22
|
-
import {
|
|
23
|
-
import {
|
|
24
|
-
import { initErpDb } from "./erpDb.js";
|
|
22
|
+
import { ERP_DB_VERSION, erpDbPath } from "./database/dbConfig.js";
|
|
23
|
+
import { initErpDb } from "./database/erpDb.js";
|
|
25
24
|
import { erpRoutes } from "./erpRoutes.js";
|
|
26
|
-
import {
|
|
27
|
-
import {
|
|
28
|
-
|
|
25
|
+
import { registerAuthMiddleware } from "./middleware/auth-middleware.js";
|
|
26
|
+
import { isSupervisorAuth } from "./middleware/supervisorAuth.js";
|
|
27
|
+
import { ensureLocalSuperAdmin, ensureSupervisorSuperAdmin, } from "./services/user-service.js";
|
|
28
|
+
export { enableSupervisorAuth } from "./middleware/supervisorAuth.js";
|
|
29
29
|
const __filename = fileURLToPath(import.meta.url);
|
|
30
30
|
const __dirname = path.dirname(__filename);
|
|
31
31
|
/**
|
|
@@ -44,7 +44,7 @@ export const erpPlugin = async (fastify, opts) => {
|
|
|
44
44
|
}
|
|
45
45
|
// Rate limiting — moderate global default, strict overrides on sensitive routes
|
|
46
46
|
await fastify.register(rateLimit, {
|
|
47
|
-
max: 500,
|
|
47
|
+
max: Number(process.env.ERP_API_RATE_LIMIT) || 500,
|
|
48
48
|
timeWindow: "1 minute",
|
|
49
49
|
allowList: (request) => !request.url.match(/^\/(supervisor|erp)\/api\//),
|
|
50
50
|
});
|
|
@@ -2,7 +2,7 @@ import { AuthCache, urlMatchesPrefix } from "@naisys/common";
|
|
|
2
2
|
import { extractBearerToken, hashToken, SESSION_COOKIE_NAME, } from "@naisys/common-node";
|
|
3
3
|
import { findAgentByApiKey } from "@naisys/hub-database";
|
|
4
4
|
import { findSession, findUserByApiKey } from "@naisys/supervisor-database";
|
|
5
|
-
import erpDb from "
|
|
5
|
+
import erpDb from "../database/erpDb.js";
|
|
6
6
|
import { isSupervisorAuth } from "./supervisorAuth.js";
|
|
7
7
|
const PUBLIC_PREFIXES = ["/erp/api/auth/login", "/erp/api/client-config"];
|
|
8
8
|
export const authCache = new AuthCache();
|
package/dist/route-helpers.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { permGate, resolveActions as resolveActionsBase, } from "@naisys/common";
|
|
2
2
|
import { OperationRunStatus, OrderRunStatus, RevisionStatus, } from "@naisys/erp-shared";
|
|
3
|
-
import
|
|
4
|
-
import erpDb from "./erpDb.js";
|
|
3
|
+
import erpDb from "./database/erpDb.js";
|
|
5
4
|
import { API_PREFIX, schemaLink, selfLink } from "./hateoas.js";
|
|
5
|
+
import { hasPermission } from "./middleware/auth-middleware.js";
|
|
6
6
|
// --- Prefer: return=representation (RFC 7240) ---
|
|
7
7
|
/**
|
|
8
8
|
* Returns true when the caller wants the full entity in the mutation response.
|
package/dist/routes/admin.js
CHANGED
|
@@ -3,11 +3,11 @@ import fs from "node:fs/promises";
|
|
|
3
3
|
import { AdminAttachmentListRequestSchema, AdminAttachmentListResponseSchema, AdminInfoResponseSchema, ErrorResponseSchema, ServerLogRequestSchema, ServerLogResponseSchema, } from "@naisys/erp-shared";
|
|
4
4
|
import { getHubVariable } from "@naisys/hub-database";
|
|
5
5
|
import { z } from "zod/v4";
|
|
6
|
-
import {
|
|
7
|
-
import
|
|
8
|
-
import erpDb from "../erpDb.js";
|
|
6
|
+
import { ERP_DB_VERSION, erpDbPath } from "../database/dbConfig.js";
|
|
7
|
+
import erpDb from "../database/erpDb.js";
|
|
9
8
|
import { notFound } from "../error-handler.js";
|
|
10
9
|
import { paginationLinks } from "../hateoas.js";
|
|
10
|
+
import { hasPermission, requirePermission, } from "../middleware/auth-middleware.js";
|
|
11
11
|
import { getErpLogPath, tailLogFile } from "../services/log-file-service.js";
|
|
12
12
|
import { getPackageVersion } from "../version.js";
|
|
13
13
|
const API_PREFIX = "/erp/api";
|
package/dist/routes/audit.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { CreateFieldSchema, ErrorResponseSchema, FieldListResponseSchema, FieldSchema, MutateResponseSchema, SeqNoCreateResponseSchema, UpdateFieldSchema, } from "@naisys/erp-shared";
|
|
2
2
|
import { z } from "zod/v4";
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import { calcNextSeqNo, childItemLinks, formatAuditFields, mutationResult, permGate, } from "
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
3
|
+
import erpDb from "../../database/erpDb.js";
|
|
4
|
+
import { notFound } from "../../error-handler.js";
|
|
5
|
+
import { API_PREFIX, selfLink } from "../../hateoas.js";
|
|
6
|
+
import { hasPermission, requirePermission, } from "../../middleware/auth-middleware.js";
|
|
7
|
+
import { calcNextSeqNo, childItemLinks, formatAuditFields, mutationResult, permGate, } from "../../route-helpers.js";
|
|
8
|
+
import { findExisting as findExistingItem } from "../../services/inventory/item-service.js";
|
|
9
|
+
import { createField, deleteField, ensureFieldSet, findExistingField, getField, listFields, updateField, } from "../../services/production/field-service.js";
|
|
10
10
|
const ParamsSchema = z.object({ key: z.string() });
|
|
11
11
|
const FieldParamsSchema = z.object({
|
|
12
12
|
key: z.string(),
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { CreateItemInstanceSchema, DeleteSetMutateResponseSchema, ErrorResponseSchema, fieldTypeString, FieldValueMutateResponseSchema, getValueFormatHint, ItemInstanceListQuerySchema, ItemInstanceListResponseSchema, ItemInstanceSchema, KeyCreateResponseSchema, MutateResponseSchema, UpdateFieldValueSchema, UpdateItemInstanceSchema, } from "@naisys/erp-shared";
|
|
2
2
|
import { z } from "zod/v4";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import { formatAuditFields, mutationResult, permGate, useFullSerializer, wantsFullResponse, } from "
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
3
|
+
import { notFound, unprocessable } from "../../error-handler.js";
|
|
4
|
+
import { API_PREFIX, paginationLinks, schemaLink, selfLink, } from "../../hateoas.js";
|
|
5
|
+
import { hasPermission, requirePermission, } from "../../middleware/auth-middleware.js";
|
|
6
|
+
import { formatAuditFields, mutationResult, permGate, useFullSerializer, wantsFullResponse, } from "../../route-helpers.js";
|
|
7
|
+
import { createItemInstance, deleteItemInstance, ensureItemInstanceFieldRecord, findItemInstance, findItemInstanceWithField, listItemInstances, updateItemInstance, } from "../../services/inventory/item-instance-service.js";
|
|
8
|
+
import { findExisting as findItem } from "../../services/inventory/item-service.js";
|
|
9
|
+
import { checkFieldValueShape, deleteFieldValueSet, deserializeFieldValue, serializeFieldValue, upsertFieldValue, validateFieldValue, } from "../../services/production/field-value-service.js";
|
|
10
10
|
const ParamsSchema = z.object({
|
|
11
11
|
key: z.string(),
|
|
12
12
|
});
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { CreateItemSchema, ErrorResponseSchema, ItemListQuerySchema, ItemListResponseSchema, ItemSchema, KeyCreateResponseSchema, MutateResponseSchema, UpdateItemSchema, } from "@naisys/erp-shared";
|
|
2
2
|
import { z } from "zod/v4";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import { calcNextSeqNo, childItemLinks, formatAuditFields, mutationResult, permGate, } from "
|
|
7
|
-
import { createItem, deleteItem, findExisting, listItems, updateItem, } from "
|
|
3
|
+
import { notFound } from "../../error-handler.js";
|
|
4
|
+
import { API_PREFIX, collectionLink, paginationLinks, schemaLink, selfLink, } from "../../hateoas.js";
|
|
5
|
+
import { hasPermission, requirePermission, } from "../../middleware/auth-middleware.js";
|
|
6
|
+
import { calcNextSeqNo, childItemLinks, formatAuditFields, mutationResult, permGate, } from "../../route-helpers.js";
|
|
7
|
+
import { createItem, deleteItem, findExisting, listItems, updateItem, } from "../../services/inventory/item-service.js";
|
|
8
8
|
const RESOURCE = "items";
|
|
9
9
|
const KeyParamsSchema = z.object({
|
|
10
10
|
key: z.string(),
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { CreateOperationDependencySchema, CreateResponseSchema, ErrorResponseSchema, OperationDependencyListResponseSchema, RevisionStatus, } from "@naisys/erp-shared";
|
|
2
2
|
import { z } from "zod/v4";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import { mutationResult, resolveRevision } from "
|
|
7
|
-
import { createDependency, deleteDependency, listDependencies, } from "
|
|
8
|
-
import { findExisting } from "
|
|
3
|
+
import { conflict, notFound } from "../../error-handler.js";
|
|
4
|
+
import { API_PREFIX, selfLink } from "../../hateoas.js";
|
|
5
|
+
import { hasPermission, requirePermission, } from "../../middleware/auth-middleware.js";
|
|
6
|
+
import { mutationResult, resolveRevision } from "../../route-helpers.js";
|
|
7
|
+
import { createDependency, deleteDependency, listDependencies, } from "../../services/operations/operation-dependency-service.js";
|
|
8
|
+
import { findExisting } from "../../services/operations/operation-service.js";
|
|
9
9
|
const ParamsSchema = z.object({
|
|
10
10
|
orderKey: z.string(),
|
|
11
11
|
revNo: z.coerce.number().int(),
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { CreateFieldRefSchema, ErrorResponseSchema, FieldRefListResponseSchema, RevisionStatus, SeqNoCreateResponseSchema, } from "@naisys/erp-shared";
|
|
2
2
|
import { z } from "zod/v4";
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import { calcNextSeqNo, childItemLinks, mutationResult, resolveActions, resolveOperation, } from "
|
|
8
|
-
import { checkDuplicateSource, createFieldRef, deleteFieldRef, findExistingFieldRef, listFieldRefs, } from "
|
|
3
|
+
import erpDb from "../../database/erpDb.js";
|
|
4
|
+
import { conflict, notFound } from "../../error-handler.js";
|
|
5
|
+
import { API_PREFIX, selfLink } from "../../hateoas.js";
|
|
6
|
+
import { requirePermission } from "../../middleware/auth-middleware.js";
|
|
7
|
+
import { calcNextSeqNo, childItemLinks, mutationResult, resolveActions, resolveOperation, } from "../../route-helpers.js";
|
|
8
|
+
import { checkDuplicateSource, createFieldRef, deleteFieldRef, findExistingFieldRef, listFieldRefs, } from "../../services/production/field-ref-service.js";
|
|
9
9
|
const ParamsSchema = z.object({
|
|
10
10
|
orderKey: z.string(),
|
|
11
11
|
revNo: z.coerce.number().int(),
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { CreateOperationRunCommentSchema, CreateResponseSchema, ErrorResponseSchema, OperationRunCommentListResponseSchema, OperationRunCommentType, } from "@naisys/erp-shared";
|
|
2
2
|
import { z } from "zod/v4";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import { mutationResult, resolveActions, resolveOpRun, } from "
|
|
7
|
-
import { createComment, listComments, } from "
|
|
3
|
+
import { notFound } from "../../error-handler.js";
|
|
4
|
+
import { API_PREFIX, selfLink } from "../../hateoas.js";
|
|
5
|
+
import { requirePermission } from "../../middleware/auth-middleware.js";
|
|
6
|
+
import { mutationResult, resolveActions, resolveOpRun, } from "../../route-helpers.js";
|
|
7
|
+
import { createComment, listComments, } from "../../services/operations/operation-run-comment-service.js";
|
|
8
8
|
function commentResource(orderKey, runNo, seqNo) {
|
|
9
9
|
return `orders/${orderKey}/runs/${runNo}/ops/${seqNo}/comments`;
|
|
10
10
|
}
|
package/dist/routes/{operation-run-transitions.js → operations/operation-run-transitions.js}
RENAMED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { ErrorResponseSchema, OperationRunStatus, OperationRunTransitionSlimSchema, OrderRunStatus, TransitionNoteSchema, } from "@naisys/erp-shared";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { checkOrderRunStarted, checkWorkCenterAccess, mutationResult, resolveOpRun, } from "
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
2
|
+
import { conflict, notFound, unprocessable } from "../../error-handler.js";
|
|
3
|
+
import { requirePermission } from "../../middleware/auth-middleware.js";
|
|
4
|
+
import { checkOrderRunStarted, checkWorkCenterAccess, mutationResult, resolveOpRun, } from "../../route-helpers.js";
|
|
5
|
+
import { checkPredecessorsComplete, checkStepsComplete, reblockSuccessors, transitionStatus, unblockSuccessors, validateStatusFor, } from "../../services/operations/operation-run-service.js";
|
|
6
|
+
import { transitionStatus as transitionOrderRunStatus } from "../../services/orders/order-run-service.js";
|
|
7
|
+
import { clockIn, clockOutAllForOpRun, isUserClockedIn, sumLaborTicketCosts, } from "../../services/production/labor-ticket-service.js";
|
|
8
8
|
import { formatOpRunTransition, SeqNoParamsSchema } from "./operation-runs.js";
|
|
9
9
|
export default function operationRunTransitionRoutes(fastify) {
|
|
10
10
|
const app = fastify.withTypeProvider();
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { ErrorResponseSchema, MutateResponseSchema, OperationRunListResponseSchema, OperationRunSchema, OperationRunStatus, UpdateOperationRunSchema, } from "@naisys/erp-shared";
|
|
2
2
|
import { z } from "zod/v4";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import { checkOrderRunStarted, checkWorkCenterAccess, childItemLinks, formatAuditFields, formatDate, resolveActions, resolveOpRun, resolveOrderRun, useFullSerializer, wantsFullResponse, } from "
|
|
7
|
-
import { checkStepsComplete, getOpRun, getOpRunFieldRefSummary, getOpRunStepSummary, listOpRuns, updateOpRun, validateStatusFor, } from "
|
|
3
|
+
import { conflict, notFound } from "../../error-handler.js";
|
|
4
|
+
import { API_PREFIX, selfLink } from "../../hateoas.js";
|
|
5
|
+
import { hasPermission, requirePermission, } from "../../middleware/auth-middleware.js";
|
|
6
|
+
import { checkOrderRunStarted, checkWorkCenterAccess, childItemLinks, formatAuditFields, formatDate, resolveActions, resolveOpRun, resolveOrderRun, useFullSerializer, wantsFullResponse, } from "../../route-helpers.js";
|
|
7
|
+
import { checkStepsComplete, getOpRun, getOpRunFieldRefSummary, getOpRunStepSummary, listOpRuns, updateOpRun, validateStatusFor, } from "../../services/operations/operation-run-service.js";
|
|
8
8
|
function opRunResource(orderKey, runNo) {
|
|
9
9
|
return `orders/${orderKey}/runs/${runNo}/ops`;
|
|
10
10
|
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { CreateOperationSchema, ErrorResponseSchema, MutateResponseSchema, OperationListResponseSchema, OperationSchema, RevisionStatus, SeqNoCreateResponseSchema, UpdateOperationSchema, } from "@naisys/erp-shared";
|
|
2
2
|
import { z } from "zod/v4";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import { calcNextSeqNo, childItemLinks, draftCrudActions, formatAuditFields, mutationResult, permGate, resolveRevision, } from "
|
|
7
|
-
import { createOperation, deleteOperation, findExisting, getOperation, listOperations, updateOperation, } from "
|
|
8
|
-
import { findWorkCenterByKey } from "
|
|
3
|
+
import { conflict, notFound } from "../../error-handler.js";
|
|
4
|
+
import { API_PREFIX, selfLink } from "../../hateoas.js";
|
|
5
|
+
import { hasPermission, requirePermission, } from "../../middleware/auth-middleware.js";
|
|
6
|
+
import { calcNextSeqNo, childItemLinks, draftCrudActions, formatAuditFields, mutationResult, permGate, resolveRevision, } from "../../route-helpers.js";
|
|
7
|
+
import { createOperation, deleteOperation, findExisting, getOperation, listOperations, updateOperation, } from "../../services/operations/operation-service.js";
|
|
8
|
+
import { findWorkCenterByKey } from "../../services/production/work-center-service.js";
|
|
9
9
|
/** Resolve an optional workCenterKey to a workCenterId. Returns undefined (skip), null (clear), or the ID. */
|
|
10
10
|
async function resolveWorkCenterId(workCenterKey) {
|
|
11
11
|
if (workCenterKey === undefined)
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { ErrorResponseSchema, OrderRevisionTransitionSchema, RevisionStatus, } from "@naisys/erp-shared";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { resolveOrder, useFullSerializer, wantsFullResponse, } from "
|
|
5
|
-
import { findExisting, transitionStatus, } from "
|
|
2
|
+
import { conflict, notFound } from "../../error-handler.js";
|
|
3
|
+
import { requirePermission } from "../../middleware/auth-middleware.js";
|
|
4
|
+
import { resolveOrder, useFullSerializer, wantsFullResponse, } from "../../route-helpers.js";
|
|
5
|
+
import { findExisting, transitionStatus, } from "../../services/orders/order-revision-service.js";
|
|
6
6
|
import { formatRevision, revisionItemActions, RevNoParamsSchema, } from "./order-revisions.js";
|
|
7
7
|
export default function orderRevisionTransitionRoutes(fastify) {
|
|
8
8
|
const app = fastify.withTypeProvider();
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { CreateOrderRevisionSchema, ErrorResponseSchema, MutateResponseSchema, OrderRevisionListQuerySchema, OrderRevisionListResponseSchema, OrderRevisionSchema, RevisionCreateResponseSchema, RevisionDiffQuerySchema, RevisionDiffResponseSchema, RevisionStatus, UpdateOrderRevisionSchema, } from "@naisys/erp-shared";
|
|
2
2
|
import { z } from "zod/v4";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import { childItemLinks, formatAuditFields, mutationResult, permGate, resolveActions, resolveOrder, } from "
|
|
7
|
-
import { checkHasOrderRuns, createRevision, deleteRevision, findExisting, getRevision, getRevisionOpSummary, listRevisions, updateRevision, validateDraftStatus, } from "
|
|
8
|
-
import { diffRevisions } from "
|
|
3
|
+
import { conflict, notFound } from "../../error-handler.js";
|
|
4
|
+
import { API_PREFIX, paginationLinks } from "../../hateoas.js";
|
|
5
|
+
import { hasPermission, requirePermission, } from "../../middleware/auth-middleware.js";
|
|
6
|
+
import { childItemLinks, formatAuditFields, mutationResult, permGate, resolveActions, resolveOrder, } from "../../route-helpers.js";
|
|
7
|
+
import { checkHasOrderRuns, createRevision, deleteRevision, findExisting, getRevision, getRevisionOpSummary, listRevisions, updateRevision, validateDraftStatus, } from "../../services/orders/order-revision-service.js";
|
|
8
|
+
import { diffRevisions } from "../../services/orders/revision-diff-service.js";
|
|
9
9
|
export function revisionItemActions(parentResource, orderKey, revNo, status, user) {
|
|
10
10
|
const href = `${API_PREFIX}/${parentResource}/${orderKey}/revs/${revNo}`;
|
|
11
11
|
return resolveActions([
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { CompleteOrderRunSchema, ErrorResponseSchema, OrderRunStatus, OrderRunTransitionSchema, } from "@naisys/erp-shared";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { resolveOrderRun, useFullSerializer, wantsFullResponse, } from "
|
|
5
|
-
import { checkOpsComplete, completeOrderRun, getReopenTarget, sumOpRunCosts, transitionStatus, validateStatusFor, } from "
|
|
2
|
+
import { badRequest, conflict, notFound, unprocessable, } from "../../error-handler.js";
|
|
3
|
+
import { requirePermission } from "../../middleware/auth-middleware.js";
|
|
4
|
+
import { resolveOrderRun, useFullSerializer, wantsFullResponse, } from "../../route-helpers.js";
|
|
5
|
+
import { checkOpsComplete, completeOrderRun, getReopenTarget, sumOpRunCosts, transitionStatus, validateStatusFor, } from "../../services/orders/order-run-service.js";
|
|
6
6
|
import { formatRun, orderRunItemActions, RunNoParamsSchema, } from "./order-runs.js";
|
|
7
7
|
export default function orderRunTransitionRoutes(fastify) {
|
|
8
8
|
const app = fastify.withTypeProvider();
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { CreateOrderRunSchema, ErrorResponseSchema, MutateResponseSchema, OrderRunListQuerySchema, OrderRunListResponseSchema, OrderRunSchema, OrderRunStatus, RunCreateResponseSchema, UpdateOrderRunSchema, } from "@naisys/erp-shared";
|
|
2
2
|
import { z } from "zod/v4";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import { childItemLinks, formatAuditFields, mutationResult, resolveActions, resolveOrder, resolveOrderRun, } from "
|
|
7
|
-
import { checkOpsComplete, createOrderRun, deleteOrderRun, findLatestApprovedRevision, findOrderRevision, getOrderRun, getOrderRunOpSummary, listOrderRuns, updateOrderRun, validateStatusFor, } from "
|
|
3
|
+
import { conflict, notFound } from "../../error-handler.js";
|
|
4
|
+
import { API_PREFIX, paginationLinks } from "../../hateoas.js";
|
|
5
|
+
import { hasPermission, requirePermission, } from "../../middleware/auth-middleware.js";
|
|
6
|
+
import { childItemLinks, formatAuditFields, mutationResult, resolveActions, resolveOrder, resolveOrderRun, } from "../../route-helpers.js";
|
|
7
|
+
import { checkOpsComplete, createOrderRun, deleteOrderRun, findLatestApprovedRevision, findOrderRevision, getOrderRun, getOrderRunOpSummary, listOrderRuns, updateOrderRun, validateStatusFor, } from "../../services/orders/order-run-service.js";
|
|
8
8
|
function runResource(orderKey) {
|
|
9
9
|
return `orders/${orderKey}/runs`;
|
|
10
10
|
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { CreateOrderSchema, ErrorResponseSchema, KeyCreateResponseSchema, MutateResponseSchema, OrderListQuerySchema, OrderListResponseSchema, OrderSchema, OrderStatus, UpdateOrderSchema, } from "@naisys/erp-shared";
|
|
2
2
|
import { z } from "zod/v4";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import { formatAuditFields, mutationResult, permGate, resolveActions, } from "
|
|
7
|
-
import { checkHasRevisions, createOrder, deleteOrder, findExisting, getLatestApprovedRevNo, listOrders, resolveItemKey, updateOrder, } from "
|
|
3
|
+
import { conflict, notFound } from "../../error-handler.js";
|
|
4
|
+
import { API_PREFIX, collectionLink, paginationLinks, schemaLink, selfLink, } from "../../hateoas.js";
|
|
5
|
+
import { hasPermission, requirePermission, } from "../../middleware/auth-middleware.js";
|
|
6
|
+
import { formatAuditFields, mutationResult, permGate, resolveActions, } from "../../route-helpers.js";
|
|
7
|
+
import { checkHasRevisions, createOrder, deleteOrder, findExisting, getLatestApprovedRevNo, listOrders, resolveItemKey, updateOrder, } from "../../services/orders/order-service.js";
|
|
8
8
|
function orderLinks(resource, key, schemaName) {
|
|
9
9
|
return [
|
|
10
10
|
selfLink(`/${resource}/${key}`),
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { DispatchListQuerySchema, DispatchListResponseSchema, OperationRunStatus, OrderRunStatus, ReadyToCloseListQuerySchema, ReadyToCloseListResponseSchema, } from "@naisys/erp-shared";
|
|
2
|
-
import erpDb from "
|
|
3
|
-
import { API_PREFIX, paginationLinks } from "
|
|
4
|
-
import { getUserWorkCenterIds } from "
|
|
2
|
+
import erpDb from "../../database/erpDb.js";
|
|
3
|
+
import { API_PREFIX, paginationLinks } from "../../hateoas.js";
|
|
4
|
+
import { getUserWorkCenterIds } from "../../services/production/work-center-service.js";
|
|
5
5
|
const OPEN_ORDER_STATUSES = [OrderRunStatus.released, OrderRunStatus.started];
|
|
6
6
|
const DEFAULT_OP_STATUSES = [
|
|
7
7
|
OperationRunStatus.pending,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { InventoryListQuerySchema, InventoryListResponseSchema, } from "@naisys/erp-shared";
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
2
|
+
import erpDb from "../../database/erpDb.js";
|
|
3
|
+
import { API_PREFIX, paginationLinks } from "../../hateoas.js";
|
|
4
|
+
import { hasPermission } from "../../middleware/auth-middleware.js";
|
|
5
5
|
function buildInventoryActionTemplates(user) {
|
|
6
6
|
const templates = [
|
|
7
7
|
{
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { ClockOutLaborTicketSchema, CreateResponseSchema, ErrorResponseSchema, LaborTicketListResponseSchema, MutateResponseSchema, OperationRunStatus, } from "@naisys/erp-shared";
|
|
2
2
|
import { z } from "zod/v4";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import { checkOpRunInProgress, formatAuditFields, formatDate, mutationResult, permGate, resolveOpRun, } from "
|
|
7
|
-
import { clockIn, clockOut, deleteLaborTicket, listLaborTickets, } from "
|
|
3
|
+
import { notFound } from "../../error-handler.js";
|
|
4
|
+
import { API_PREFIX, selfLink } from "../../hateoas.js";
|
|
5
|
+
import { hasPermission, requirePermission, } from "../../middleware/auth-middleware.js";
|
|
6
|
+
import { checkOpRunInProgress, formatAuditFields, formatDate, mutationResult, permGate, resolveOpRun, } from "../../route-helpers.js";
|
|
7
|
+
import { clockIn, clockOut, deleteLaborTicket, listLaborTickets, } from "../../services/production/labor-ticket-service.js";
|
|
8
8
|
function laborResource(orderKey, runNo, seqNo) {
|
|
9
9
|
return `orders/${orderKey}/runs/${runNo}/ops/${seqNo}/labor`;
|
|
10
10
|
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { AssignWorkCenterUserSchema, CreateWorkCenterSchema, ErrorResponseSchema, KeyCreateResponseSchema, MutateResponseSchema, UpdateWorkCenterSchema, WorkCenterListQuerySchema, WorkCenterListResponseSchema, WorkCenterSchema, } from "@naisys/erp-shared";
|
|
2
2
|
import { z } from "zod/v4";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import { formatAuditFields, mutationResult, permGate, } from "
|
|
7
|
-
import { assignUser, createWorkCenter, deleteWorkCenter, findExisting, listWorkCenters, removeUser, updateWorkCenter, } from "
|
|
3
|
+
import { notFound } from "../../error-handler.js";
|
|
4
|
+
import { API_PREFIX, collectionLink, paginationLinks, schemaLink, selfLink, } from "../../hateoas.js";
|
|
5
|
+
import { hasPermission, requirePermission, } from "../../middleware/auth-middleware.js";
|
|
6
|
+
import { formatAuditFields, mutationResult, permGate, } from "../../route-helpers.js";
|
|
7
|
+
import { assignUser, createWorkCenter, deleteWorkCenter, findExisting, listWorkCenters, removeUser, updateWorkCenter, } from "../../services/production/work-center-service.js";
|
|
8
8
|
const RESOURCE = "work-centers";
|
|
9
9
|
const KeyParamsSchema = z.object({
|
|
10
10
|
key: z.string(),
|
package/dist/routes/root.js
CHANGED
|
@@ -2,14 +2,14 @@ import { mimeFromFilename } from "@naisys/common";
|
|
|
2
2
|
import { ErrorResponseSchema, UploadAttachmentResponseSchema, } from "@naisys/erp-shared";
|
|
3
3
|
import { createReadStream, existsSync, statSync } from "fs";
|
|
4
4
|
import { z } from "zod/v4";
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import {
|
|
8
|
-
import { checkOpRunInProgress, checkOrderRunStarted, checkWorkCenterAccess, resolveStepRun, } from "
|
|
9
|
-
import { deleteFieldAttachment, getAttachmentFilePath, uploadAttachment, } from "
|
|
10
|
-
import { ensureStepRunFieldRecord } from "
|
|
11
|
-
import { findStepRunWithField, rebuildAttachmentFieldValue, upsertFieldValue, } from "
|
|
12
|
-
import { isUserClockedIn } from "
|
|
5
|
+
import erpDb from "../../database/erpDb.js";
|
|
6
|
+
import { conflict, notFound } from "../../error-handler.js";
|
|
7
|
+
import { requirePermission } from "../../middleware/auth-middleware.js";
|
|
8
|
+
import { checkOpRunInProgress, checkOrderRunStarted, checkWorkCenterAccess, resolveStepRun, } from "../../route-helpers.js";
|
|
9
|
+
import { deleteFieldAttachment, getAttachmentFilePath, uploadAttachment, } from "../../services/attachment-service.js";
|
|
10
|
+
import { ensureStepRunFieldRecord } from "../../services/production/field-service.js";
|
|
11
|
+
import { findStepRunWithField, rebuildAttachmentFieldValue, upsertFieldValue, } from "../../services/production/field-value-service.js";
|
|
12
|
+
import { isUserClockedIn } from "../../services/production/labor-ticket-service.js";
|
|
13
13
|
const FieldSeqNoParamsSchema = z.object({
|
|
14
14
|
orderKey: z.string(),
|
|
15
15
|
runNo: z.coerce.number().int(),
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { BatchCreateFieldSchema, BatchSeqNoCreateResponseSchema, CreateFieldSchema, ErrorResponseSchema, FieldListResponseSchema, FieldSchema, MutateResponseSchema, RevisionStatus, SeqNoCreateResponseSchema, UpdateFieldSchema, } from "@naisys/erp-shared";
|
|
2
2
|
import { z } from "zod/v4";
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import { calcNextSeqNo, childItemLinks, draftCrudActions, formatAuditFields, mutationResult, resolveActions, resolveStep, } from "
|
|
8
|
-
import { createField, createFields, deleteField, ensureFieldSet, findExistingField, getField, listFields, updateField, } from "
|
|
3
|
+
import erpDb from "../../database/erpDb.js";
|
|
4
|
+
import { conflict, notFound } from "../../error-handler.js";
|
|
5
|
+
import { API_PREFIX, selfLink } from "../../hateoas.js";
|
|
6
|
+
import { requirePermission } from "../../middleware/auth-middleware.js";
|
|
7
|
+
import { calcNextSeqNo, childItemLinks, draftCrudActions, formatAuditFields, mutationResult, resolveActions, resolveStep, } from "../../route-helpers.js";
|
|
8
|
+
import { createField, createFields, deleteField, ensureFieldSet, findExistingField, getField, listFields, updateField, } from "../../services/production/field-service.js";
|
|
9
9
|
const ParamsSchema = z.object({
|
|
10
10
|
orderKey: z.string(),
|
|
11
11
|
revNo: z.coerce.number().int(),
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { BatchFieldValueMutateResponseSchema, BatchFieldValueUpdateResponseSchema, BatchUpdateFieldValuesSchema, DeleteSetMutateResponseSchema, ErrorResponseSchema, fieldTypeString, FieldValueMutateResponseSchema, getValueFormatHint, UpdateFieldValueSchema, } from "@naisys/erp-shared";
|
|
2
2
|
import { z } from "zod/v4";
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import { checkOpRunInProgress, checkOrderRunStarted, checkWorkCenterAccess, mutationResult, resolveStepRun, } from "
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
3
|
+
import erpDb from "../../database/erpDb.js";
|
|
4
|
+
import { conflict, notFound, unprocessable } from "../../error-handler.js";
|
|
5
|
+
import { API_PREFIX } from "../../hateoas.js";
|
|
6
|
+
import { requirePermission } from "../../middleware/auth-middleware.js";
|
|
7
|
+
import { checkOpRunInProgress, checkOrderRunStarted, checkWorkCenterAccess, mutationResult, resolveStepRun, } from "../../route-helpers.js";
|
|
8
|
+
import { getStepRunWithFields } from "../../services/operations/step-run-service.js";
|
|
9
|
+
import { ensureStepRunFieldRecord } from "../../services/production/field-service.js";
|
|
10
|
+
import { checkFieldValueShape, clearAttachmentFieldValue, deleteFieldValueSet, deserializeFieldValue, findStepRunWithField, serializeFieldValue, upsertFieldValue, validateFieldValue, } from "../../services/production/field-value-service.js";
|
|
11
|
+
import { isUserClockedIn } from "../../services/production/labor-ticket-service.js";
|
|
12
12
|
import { computeStepRunHateoas, stepRunResource } from "./step-runs.js";
|
|
13
13
|
const FieldSeqNoParamsSchema = z.object({
|
|
14
14
|
orderKey: z.string(),
|