@naisys/erp-shared 3.0.0-beta.10

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.
@@ -0,0 +1,79 @@
1
+ import { z } from "zod/v4";
2
+ import { HateoasActionSchema, HateoasLinkSchema, HateoasLinkTemplateSchema, } from "./hateoas-types.js";
3
+ // Work center user assignment (embedded in detail response)
4
+ export const WorkCenterUserSchema = z.object({
5
+ userId: z.number(),
6
+ username: z.string(),
7
+ createdAt: z.string(),
8
+ createdBy: z.string().nullable(),
9
+ _actions: z.array(HateoasActionSchema).optional(),
10
+ });
11
+ // Full work center response
12
+ export const WorkCenterSchema = z.object({
13
+ id: z.number(),
14
+ key: z.string(),
15
+ description: z.string(),
16
+ userAssignments: z.array(WorkCenterUserSchema),
17
+ createdAt: z.iso.datetime(),
18
+ createdBy: z.string(),
19
+ updatedAt: z.iso.datetime(),
20
+ updatedBy: z.string(),
21
+ _links: z.array(HateoasLinkSchema),
22
+ _actions: z.array(HateoasActionSchema).optional(),
23
+ });
24
+ // Input for creating a work center
25
+ export const CreateWorkCenterSchema = z
26
+ .object({
27
+ key: z
28
+ .string()
29
+ .min(1)
30
+ .max(100)
31
+ .regex(/^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*$/, "Key must be alphanumeric with hyphens"),
32
+ description: z.string().max(2000).optional().default(""),
33
+ })
34
+ .strict();
35
+ // Input for updating a work center
36
+ export const UpdateWorkCenterSchema = z
37
+ .object({
38
+ key: z
39
+ .string()
40
+ .min(1)
41
+ .max(100)
42
+ .regex(/^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*$/, "Key must be alphanumeric with hyphens")
43
+ .optional(),
44
+ description: z.string().max(2000).optional(),
45
+ })
46
+ .strict();
47
+ // Input for assigning a user to a work center
48
+ export const AssignWorkCenterUserSchema = z
49
+ .object({
50
+ username: z.string().min(1),
51
+ })
52
+ .strict();
53
+ // Query params for listing work centers
54
+ export const WorkCenterListQuerySchema = z.object({
55
+ page: z.coerce.number().int().min(1).optional().default(1),
56
+ pageSize: z.coerce.number().int().min(1).max(100).optional().default(20),
57
+ search: z.string().optional(),
58
+ });
59
+ // Work center list item (lighter response)
60
+ export const WorkCenterListItemSchema = z.object({
61
+ id: z.number(),
62
+ key: z.string(),
63
+ description: z.string(),
64
+ userCount: z.number(),
65
+ createdAt: z.iso.datetime(),
66
+ createdBy: z.string(),
67
+ updatedAt: z.iso.datetime(),
68
+ updatedBy: z.string(),
69
+ });
70
+ // List response
71
+ export const WorkCenterListResponseSchema = z.object({
72
+ items: z.array(WorkCenterListItemSchema),
73
+ total: z.number(),
74
+ page: z.number(),
75
+ pageSize: z.number(),
76
+ _links: z.array(HateoasLinkSchema),
77
+ _linkTemplates: z.array(HateoasLinkTemplateSchema).optional(),
78
+ _actions: z.array(HateoasActionSchema).optional(),
79
+ });
package/package.json ADDED
@@ -0,0 +1,32 @@
1
+ {
2
+ "name": "@naisys/erp-shared",
3
+ "version": "3.0.0-beta.10",
4
+ "description": "[internal] NAISYS ERP shared types and validation schemas",
5
+ "type": "module",
6
+ "files": [
7
+ "dist",
8
+ "!dist/**/*.map",
9
+ "!dist/**/*.d.ts",
10
+ "!dist/**/*.d.ts.map"
11
+ ],
12
+ "scripts": {
13
+ "clean": "rimraf dist",
14
+ "build": "tsc",
15
+ "type-check": "tsc --noEmit",
16
+ "npm:publish:dryrun": "npm publish --dry-run",
17
+ "npm:publish": "npm publish --access public"
18
+ },
19
+ "devDependencies": {
20
+ "typescript": "^5.9.3"
21
+ },
22
+ "dependencies": {
23
+ "@naisys/common": "3.0.0-beta.10",
24
+ "zod": "^4.3.6"
25
+ },
26
+ "exports": {
27
+ ".": {
28
+ "types": "./dist/index.d.ts",
29
+ "default": "./dist/index.js"
30
+ }
31
+ }
32
+ }