@pactosigna/records 0.1.0 → 0.1.2

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/dist/cli.js CHANGED
@@ -76,6 +76,52 @@ function readDocuments(rootDir, folderPath, statusFilter = INCLUDED_STATUSES) {
76
76
  // src/pdf/markdown-to-pdfmake.ts
77
77
  import MarkdownIt from "markdown-it";
78
78
  var md = new MarkdownIt();
79
+ var UNICODE_REPLACEMENTS = {
80
+ "\u2264": "<=",
81
+ // ≤
82
+ "\u2265": ">=",
83
+ // ≥
84
+ "\u2260": "!=",
85
+ // ≠
86
+ "\u2248": "~=",
87
+ // ≈
88
+ "\xB1": "+/-",
89
+ // ±
90
+ "\u2014": "--",
91
+ // — (em dash)
92
+ "\u2013": "-",
93
+ // – (en dash)
94
+ "\u2018": "'",
95
+ // ' (left single quote)
96
+ "\u2019": "'",
97
+ // ' (right single quote)
98
+ "\u201C": '"',
99
+ // " (left double quote)
100
+ "\u201D": '"',
101
+ // " (right double quote)
102
+ "\u2026": "...",
103
+ // … (ellipsis)
104
+ "\u2192": "->",
105
+ // →
106
+ "\u2190": "<-",
107
+ // ←
108
+ "\xD7": "x",
109
+ // × (multiplication sign)
110
+ "\xF7": "/",
111
+ // ÷ (division sign)
112
+ "\u221E": "Inf",
113
+ // ∞
114
+ "\u2211": "Sum",
115
+ // ∑
116
+ "\u0394": "Delta",
117
+ // Δ
118
+ "\u03BC": "u"
119
+ // μ (micro)
120
+ };
121
+ var UNICODE_PATTERN = new RegExp("[" + Object.keys(UNICODE_REPLACEMENTS).join("") + "]", "g");
122
+ function sanitizeUnicode(text) {
123
+ return text.replace(UNICODE_PATTERN, (match) => UNICODE_REPLACEMENTS[match] ?? match);
124
+ }
79
125
  function markdownToPdfmake(markdown) {
80
126
  if (!markdown.trim()) return [];
81
127
  const tokens = md.parse(markdown, {});
@@ -125,7 +171,7 @@ function markdownToPdfmake(markdown) {
125
171
  }
126
172
  if (token.type === "fence") {
127
173
  result.push({
128
- text: token.content,
174
+ text: sanitizeUnicode(token.content),
129
175
  style: "code",
130
176
  margin: [0, 4, 0, 4],
131
177
  background: "#F5F5F5"
@@ -163,7 +209,7 @@ function parseInlineContent(token) {
163
209
  italics = false;
164
210
  break;
165
211
  case "code_inline":
166
- fragments.push({ text: child.content, font: "Courier", fontSize: 9 });
212
+ fragments.push({ text: sanitizeUnicode(child.content), font: "Courier", fontSize: 9 });
167
213
  break;
168
214
  case "softbreak":
169
215
  case "hardbreak":
@@ -171,17 +217,17 @@ function parseInlineContent(token) {
171
217
  break;
172
218
  case "text":
173
219
  if (bold || italics) {
174
- const fragment = { text: child.content };
220
+ const fragment = { text: sanitizeUnicode(child.content) };
175
221
  if (bold) fragment.bold = true;
176
222
  if (italics) fragment.italics = true;
177
223
  fragments.push(fragment);
178
224
  } else {
179
- fragments.push(child.content);
225
+ fragments.push(sanitizeUnicode(child.content));
180
226
  }
181
227
  break;
182
228
  default:
183
229
  if (child.content) {
184
- fragments.push(child.content);
230
+ fragments.push(sanitizeUnicode(child.content));
185
231
  }
186
232
  break;
187
233
  }
@@ -275,6 +321,33 @@ function parseTable(tokens, startIndex) {
275
321
  };
276
322
  }
277
323
 
324
+ // src/pdf/logo.ts
325
+ import { readFileSync as readFileSync3, existsSync as existsSync2 } from "fs";
326
+ import { resolve as resolve3 } from "path";
327
+ var DEFAULT_LOGO_SVG = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="86 33 112 132" fill="none">
328
+ <path d="M 126.660 39.048 C 118.948 40.342, 108.092 43.909, 100.250 47.726 L 93 51.254 93 79.417 C 93 101.290, 93.337 108.873, 94.508 113.369 C 99.124 131.093, 111.353 144.203, 132.521 154.123 L 141.228 158.203 147.482 155.545 C 164.571 148.282, 177.761 137.330, 183.523 125.620 C 185.450 121.704, 187.687 115.350, 188.496 111.500 C 190.017 104.251, 190.622 77.552, 189.250 78.172 C 188.838 78.359, 186.137 79.754, 183.250 81.273 L 178 84.034 177.976 97.767 C 177.955 109.837, 177.670 112.188, 175.617 117.178 C 174.332 120.302, 171.823 124.699, 170.040 126.950 C 166.118 131.901, 156.845 138.641, 147.912 143.031 L 141.324 146.270 133.165 142.025 C 123.422 136.956, 112.066 126.834, 108.987 120.474 C 104.626 111.464, 104.024 106.777, 104.012 81.694 L 104 57.888 108.468 55.911 C 118.291 51.566, 127.969 49.691, 141 49.610 C 154.549 49.525, 161.523 50.879, 172.184 55.663 L 178 58.273 178.015 67.887 C 178.024 73.174, 178.361 78.008, 178.765 78.629 C 179.273 79.409, 181.073 78.866, 184.588 76.874 L 189.677 73.990 189.588 62.811 L 189.500 51.632 182.359 47.990 C 173.984 43.718, 164.090 40.483, 155 39.044 C 147.525 37.861, 133.720 37.863, 126.660 39.048 M 126.500 55.097 C 124.300 55.590, 119.463 56.951, 115.750 58.122 L 109 60.251 109 85.729 L 109 111.207 113.250 117.047 C 115.588 120.259, 117.838 122.912, 118.250 122.943 C 118.662 122.975, 119 116.984, 119 109.630 L 119 96.261 132.250 95.756 C 142.964 95.347, 146.648 94.801, 151.500 92.903 C 167.650 86.582, 173.814 69.996, 163.666 60.161 C 159.792 56.406, 152.831 54, 145.841 54 L 141 54 141 59 L 141 64 145.435 64 C 153.585 64, 158 66.985, 158 72.495 C 158 74.610, 157.079 76.941, 155.504 78.813 C 151.445 83.637, 146.077 85.209, 131.750 85.768 L 119 86.265 119 76.758 L 119 67.250 122.125 66.625 C 123.844 66.281, 125.644 66, 126.125 66 C 126.606 66, 127 69.600, 127 74 L 127 82 132 82 L 137 82 137 68 L 137 54 133.750 54.100 C 131.963 54.156, 128.700 54.604, 126.500 55.097 M 159.103 93.372 C 143.915 101.453, 141 104.415, 141 111.767 C 141 115.024, 141.605 116.696, 143.455 118.545 C 144.805 119.895, 146.717 120.996, 147.705 120.990 C 148.692 120.985, 151.907 119.860, 154.849 118.490 C 160.989 115.632, 162 115.473, 162 117.364 C 162 118.898, 157.383 122.272, 148.500 127.227 C 142.608 130.513, 142.495 130.658, 142.195 135.287 C 142.028 137.879, 142.122 140, 142.406 140 C 142.689 140, 146.800 137.874, 151.541 135.277 C 166.125 127.286, 171 121.968, 171 114.050 C 171 109.325, 168.324 106, 164.522 106 C 163.159 106, 159.572 107.213, 156.550 108.695 C 153.528 110.177, 150.722 111.055, 150.313 110.647 C 148.679 109.012, 152.158 106.229, 162.820 100.641 L 174 94.781 174 90.391 C 174 87.976, 173.662 86.055, 173.250 86.122 C 172.838 86.189, 166.471 89.451, 159.103 93.372 M 127 115.952 L 127 132.904 131.430 135.952 C 133.867 137.628, 136.117 139, 136.430 139 C 136.744 139, 137 130, 137 119 L 137 99 132 99 L 127 99 127 115.952" fill="#0D2D56" fill-rule="evenodd"/>
329
+ <path d="M 159.103 93.372 C 143.915 101.453, 141 104.415, 141 111.767 C 141 115.024, 141.605 116.696, 143.455 118.545 C 144.805 119.895, 146.717 120.996, 147.705 120.990 C 148.692 120.985, 151.907 119.860, 154.849 118.490 C 160.989 115.632, 162 115.473, 162 117.364 C 162 118.898, 157.383 122.272, 148.500 127.227 C 142.608 130.513, 142.495 130.658, 142.195 135.287 C 142.028 137.879, 142.122 140, 142.406 140 C 142.689 140, 146.800 137.874, 151.541 135.277 C 166.125 127.286, 171 121.968, 171 114.050 C 171 109.325, 168.324 106, 164.522 106 C 163.159 106, 159.572 107.213, 156.550 108.695 C 153.528 110.177, 150.722 111.055, 150.313 110.647 C 148.679 109.012, 152.158 106.229, 162.820 100.641 L 174 94.781 174 90.391 C 174 87.976, 173.662 86.055, 173.250 86.122 C 172.838 86.189, 166.471 89.451, 159.103 93.372 M 127 115.952 L 127 132.904 131.430 135.952 C 133.867 137.628, 136.117 139, 136.430 139 C 136.744 139, 137 130, 137 119 L 137 99 132 99 L 127 99 127 115.952" fill="#73C4B0" fill-rule="evenodd"/>
330
+ </svg>`;
331
+ var HEADER_LOGO_HEIGHT = 30;
332
+ function resolveHeaderLogo(rootDir, customLogoPath) {
333
+ if (customLogoPath) {
334
+ const absPath = resolve3(rootDir, customLogoPath);
335
+ if (existsSync2(absPath)) {
336
+ const ext = absPath.toLowerCase();
337
+ if (ext.endsWith(".png") || ext.endsWith(".jpg") || ext.endsWith(".jpeg")) {
338
+ const data = readFileSync3(absPath);
339
+ const mime = ext.endsWith(".png") ? "image/png" : "image/jpeg";
340
+ const base64 = `data:${mime};base64,${data.toString("base64")}`;
341
+ return { image: base64, height: HEADER_LOGO_HEIGHT };
342
+ }
343
+ }
344
+ }
345
+ return {
346
+ svg: DEFAULT_LOGO_SVG,
347
+ height: HEADER_LOGO_HEIGHT
348
+ };
349
+ }
350
+
278
351
  // src/pdf/layout.ts
279
352
  var HEADER_GRAY = "#F0F0F0";
280
353
  var HEADING_COLOR = "#2C3E50";
@@ -331,8 +404,9 @@ function buildCoverPage(options) {
331
404
  return cover;
332
405
  }
333
406
  function buildDocumentDefinition(options) {
334
- const { recordTitle, recordId, version, date, content = [] } = options;
407
+ const { rootDir, config, recordTitle, recordId, version, date, content = [] } = options;
335
408
  const coverPage = buildCoverPage(options);
409
+ const logo = resolveHeaderLogo(rootDir, config.branding.logo);
336
410
  return {
337
411
  pageSize: "A4",
338
412
  pageMargins: [40, 80, 40, 50],
@@ -355,7 +429,7 @@ function buildDocumentDefinition(options) {
355
429
  widths: [usableWidth * 0.2, "*", usableWidth * 0.25],
356
430
  body: [
357
431
  [
358
- { text: "[LOGO]", fontSize: 8, color: "#999999" },
432
+ logo,
359
433
  {
360
434
  stack: [
361
435
  { text: recordTitle, bold: true, fontSize: 10, alignment: "center" },
@@ -438,6 +512,7 @@ function generateUrs(input) {
438
512
  }
439
513
  return buildDocumentDefinition({
440
514
  config: input.config,
515
+ rootDir: input.rootDir,
441
516
  recordTitle: "User Requirements Specification",
442
517
  recordId: "URS",
443
518
  version: input.version,
@@ -474,6 +549,7 @@ function generatePrs(input) {
474
549
  }
475
550
  return buildDocumentDefinition({
476
551
  config: input.config,
552
+ rootDir: input.rootDir,
477
553
  recordTitle: "Product Requirements Specification",
478
554
  recordId: "PRS",
479
555
  version: input.version,
@@ -510,6 +586,7 @@ function generateSrs(input) {
510
586
  }
511
587
  return buildDocumentDefinition({
512
588
  config: input.config,
589
+ rootDir: input.rootDir,
513
590
  recordTitle: "Software Requirements Specification",
514
591
  recordId: "SRS",
515
592
  version: input.version,
@@ -727,6 +804,7 @@ function generatePta(input) {
727
804
  }
728
805
  return buildDocumentDefinition({
729
806
  config: input.config,
807
+ rootDir: input.rootDir,
730
808
  recordTitle: "Product Traceability Analysis",
731
809
  recordId: "PTA",
732
810
  version: input.version,
@@ -806,8 +884,8 @@ import { z as z222 } from "zod";
806
884
  import { z as z4 } from "zod";
807
885
  import { z as z5 } from "zod";
808
886
  import { z as z6 } from "zod";
809
- import { z as z23 } from "zod";
810
887
  import { z as z7 } from "zod";
888
+ import { z as z23 } from "zod";
811
889
  import { z as z8 } from "zod";
812
890
  import { z as z24 } from "zod";
813
891
  import { z as z9 } from "zod";
@@ -991,135 +1069,102 @@ var REVIEW_DATA_SOURCES = [
991
1069
  "releases",
992
1070
  "audits"
993
1071
  ];
994
- var CreateQualityReviewRequestSchema = z2.object({
995
- reviewTypeId: z2.string().min(1),
996
- title: z2.string().min(1).max(200),
997
- scheduledDate: z2.string().datetime(),
998
- reviewPeriod: z2.object({
999
- from: z2.string().datetime(),
1000
- to: z2.string().datetime()
1001
- })
1002
- });
1003
- var AddDecisionRequestSchema = z2.object({
1004
- description: z2.string().min(1).max(2e3),
1005
- decidedBy: z2.string().min(1)
1006
- });
1007
- var AddAttendeeRequestSchema = z2.object({
1008
- memberId: z2.string().min(1),
1009
- name: z2.string().min(1),
1072
+ var AlertRecipientSchema = z2.object({
1010
1073
  department: z2.string().min(1),
1011
- role: z2.string().min(1)
1074
+ departmentRole: z2.enum(["manager", "member"])
1012
1075
  });
1013
- var UpdateReviewNotesRequestSchema = z2.object({
1014
- notes: z2.string().max(1e4)
1015
- });
1016
- var ListQualityReviewsQuerySchema = z2.object({
1017
- reviewTypeId: z2.string().optional(),
1018
- status: z2.enum(REVIEW_STATUSES).optional(),
1076
+ var CreateQualityObjectiveRequestSchema = z2.object({
1077
+ title: z2.string().min(1).max(200),
1078
+ description: z2.string().min(1).max(5e3),
1079
+ type: z2.enum(OBJECTIVE_TYPES),
1080
+ metricSource: z2.enum(AUTO_METRIC_SOURCES).optional(),
1081
+ unit: z2.string().min(1).max(50),
1082
+ target: z2.number(),
1083
+ direction: z2.enum(OBJECTIVE_DIRECTIONS),
1084
+ warningThreshold: z2.number(),
1085
+ ownerDepartment: z2.string().min(1),
1086
+ ownerDepartmentRole: z2.enum(["manager", "member"]),
1087
+ alertRecipients: z2.array(AlertRecipientSchema).default([]),
1088
+ reviewCadence: z2.enum(OBJECTIVE_CADENCES),
1089
+ effectiveDate: z2.string().datetime(),
1090
+ targetDate: z2.string().datetime().optional()
1091
+ });
1092
+ var UpdateQualityObjectiveRequestSchema = z2.object({
1093
+ title: z2.string().min(1).max(200).optional(),
1094
+ description: z2.string().min(1).max(5e3).optional(),
1095
+ unit: z2.string().min(1).max(50).optional(),
1096
+ target: z2.number().optional(),
1097
+ direction: z2.enum(OBJECTIVE_DIRECTIONS).optional(),
1098
+ warningThreshold: z2.number().optional(),
1099
+ ownerDepartment: z2.string().min(1).optional(),
1100
+ ownerDepartmentRole: z2.enum(["manager", "member"]).optional(),
1101
+ alertRecipients: z2.array(AlertRecipientSchema).optional(),
1102
+ reviewCadence: z2.enum(OBJECTIVE_CADENCES).optional(),
1103
+ targetDate: z2.string().datetime().nullable().optional()
1104
+ });
1105
+ var RecordObjectiveValueRequestSchema = z2.object({
1106
+ value: z2.number(),
1107
+ note: z2.string().max(1e3).optional()
1108
+ });
1109
+ var ListQualityObjectivesQuerySchema = z2.object({
1110
+ type: z2.enum(OBJECTIVE_TYPES).optional(),
1111
+ status: z2.enum(OBJECTIVE_STATUSES).optional(),
1112
+ isActive: z2.enum(["true", "false"]).transform((v) => v === "true").optional(),
1019
1113
  page: z2.coerce.number().int().positive().default(1),
1020
1114
  limit: z2.coerce.number().int().positive().max(100).default(20)
1021
1115
  });
1022
- var QmsReviewParamSchema = z2.object({
1116
+ var QmsObjectiveParamSchema = z2.object({
1023
1117
  orgId: z2.string().min(1),
1024
1118
  qmsId: z2.string().min(1)
1025
1119
  });
1026
- var ReviewIdParamSchema = z2.object({
1120
+ var ObjectiveIdParamSchema = z2.object({
1027
1121
  orgId: z2.string().min(1),
1028
1122
  qmsId: z2.string().min(1),
1029
- reviewId: z2.string().min(1)
1030
- });
1031
- var MonthlyTrendSchema = z22.object({
1032
- month: z22.string(),
1033
- opened: z22.number(),
1034
- closed: z22.number()
1035
- });
1036
- var ReviewDataSnapshotSchema = z22.object({
1037
- capas: z22.object({
1038
- total: z22.number(),
1039
- open: z22.number(),
1040
- overdue: z22.number(),
1041
- avgCycleTimeDays: z22.number().nullable(),
1042
- trend: z22.array(MonthlyTrendSchema)
1043
- }).optional(),
1044
- nonconformances: z22.object({
1045
- total: z22.number(),
1046
- open: z22.number(),
1047
- overdue: z22.number(),
1048
- avgCycleTimeDays: z22.number().nullable(),
1049
- bySeverity: z22.record(z22.string(), z22.number()),
1050
- trend: z22.array(MonthlyTrendSchema)
1051
- }).optional(),
1052
- complaints: z22.object({
1053
- total: z22.number(),
1054
- open: z22.number(),
1055
- overdue: z22.number(),
1056
- reportableCount: z22.number(),
1057
- trend: z22.array(MonthlyTrendSchema)
1058
- }).optional(),
1059
- training: z22.object({
1060
- totalTasks: z22.number(),
1061
- complianceRate: z22.number(),
1062
- overdue: z22.number()
1063
- }).optional(),
1064
- releases: z22.object({
1065
- total: z22.number(),
1066
- avgCycleTimeDays: z22.number().nullable()
1067
- }).optional(),
1068
- audits: z22.object({
1069
- totalFindings: z22.number(),
1070
- major: z22.number(),
1071
- minor: z22.number(),
1072
- observations: z22.number()
1073
- }).optional()
1074
- });
1075
- var ReviewObjectiveSnapshotSchema = z22.object({
1076
- objectiveId: z22.string(),
1077
- title: z22.string(),
1078
- target: z22.number(),
1079
- value: z22.number().nullable(),
1080
- status: z22.string(),
1081
- direction: z22.string(),
1082
- unit: z22.string()
1123
+ objectiveId: z2.string().min(1)
1083
1124
  });
1084
- var ReviewDecisionSchema = z22.object({
1085
- description: z22.string(),
1086
- decidedBy: z22.string()
1087
- });
1088
- var ReviewAttendeeSchema = z22.object({
1089
- memberId: z22.string(),
1090
- name: z22.string(),
1091
- department: z22.string(),
1092
- role: z22.string()
1093
- });
1094
- var QualityReviewResponseSchema = z22.object({
1125
+ var QualityObjectiveSnapshotResponseSchema = z22.object({
1095
1126
  id: z22.string(),
1096
- reviewNumber: z22.string(),
1127
+ value: z22.number(),
1128
+ status: z22.enum(OBJECTIVE_STATUSES),
1129
+ source: z22.enum(["auto", "manual", "review"]),
1130
+ reviewId: z22.string().nullable(),
1131
+ capturedAt: z22.string(),
1132
+ capturedBy: z22.string().nullable()
1133
+ });
1134
+ var QualityObjectiveResponseSchema = z22.object({
1135
+ id: z22.string(),
1136
+ objectiveNumber: z22.string(),
1097
1137
  title: z22.string(),
1098
- reviewTypeId: z22.string(),
1099
- reviewTypeName: z22.string(),
1100
- status: z22.enum(REVIEW_STATUSES),
1101
- scheduledDate: z22.string(),
1102
- conductedDate: z22.string().nullable(),
1103
- reviewPeriod: z22.object({
1104
- from: z22.string(),
1105
- to: z22.string()
1106
- }),
1138
+ description: z22.string(),
1139
+ type: z22.enum(OBJECTIVE_TYPES),
1140
+ metricSource: z22.enum(AUTO_METRIC_SOURCES).nullable(),
1141
+ unit: z22.string(),
1142
+ target: z22.number(),
1143
+ direction: z22.enum(OBJECTIVE_DIRECTIONS),
1144
+ warningThreshold: z22.number(),
1145
+ currentValue: z22.number().nullable(),
1146
+ currentValueUpdatedAt: z22.string().nullable(),
1147
+ status: z22.enum(OBJECTIVE_STATUSES),
1107
1148
  ownerDepartment: z22.string(),
1108
1149
  ownerDepartmentRole: z22.enum(["manager", "member"]),
1109
- dataSources: z22.array(z22.enum(REVIEW_DATA_SOURCES)),
1110
- attendees: z22.array(ReviewAttendeeSchema),
1111
- dataSnapshot: ReviewDataSnapshotSchema,
1112
- objectiveSnapshots: z22.array(ReviewObjectiveSnapshotSchema),
1113
- decisions: z22.array(ReviewDecisionSchema),
1114
- notes: z22.string().nullable(),
1115
- completedAt: z22.string().nullable(),
1116
- completedBy: z22.string().nullable(),
1150
+ alertRecipients: z22.array(
1151
+ z22.object({
1152
+ department: z22.string(),
1153
+ departmentRole: z22.enum(["manager", "member"])
1154
+ })
1155
+ ),
1156
+ reviewCadence: z22.enum(OBJECTIVE_CADENCES),
1157
+ effectiveDate: z22.string(),
1158
+ targetDate: z22.string().nullable(),
1159
+ isActive: z22.boolean(),
1117
1160
  createdAt: z22.string(),
1118
1161
  createdBy: z22.string(),
1119
- updatedAt: z22.string()
1162
+ updatedAt: z22.string(),
1163
+ // Optional: included when fetching detail with snapshots
1164
+ recentSnapshots: z22.array(QualityObjectiveSnapshotResponseSchema).optional()
1120
1165
  });
1121
- var ListQualityReviewsResponseSchema = z22.object({
1122
- items: z22.array(QualityReviewResponseSchema),
1166
+ var ListQualityObjectivesResponseSchema = z22.object({
1167
+ items: z22.array(QualityObjectiveResponseSchema),
1123
1168
  total: z22.number(),
1124
1169
  page: z22.number(),
1125
1170
  limit: z22.number(),
@@ -1193,378 +1238,411 @@ var MemberPermissionsSchema = z5.object({
1193
1238
  canViewAuditLog: z5.boolean(),
1194
1239
  canExport: z5.boolean()
1195
1240
  });
1196
- var AlertRecipientSchema = z6.object({
1197
- department: z6.string().min(1),
1198
- departmentRole: z6.enum(["manager", "member"])
1199
- });
1200
- var CreateQualityObjectiveRequestSchema = z6.object({
1201
- title: z6.string().min(1).max(200),
1202
- description: z6.string().min(1).max(5e3),
1203
- type: z6.enum(OBJECTIVE_TYPES),
1204
- metricSource: z6.enum(AUTO_METRIC_SOURCES).optional(),
1205
- unit: z6.string().min(1).max(50),
1206
- target: z6.number(),
1207
- direction: z6.enum(OBJECTIVE_DIRECTIONS),
1208
- warningThreshold: z6.number(),
1209
- ownerDepartment: z6.string().min(1),
1210
- ownerDepartmentRole: z6.enum(["manager", "member"]),
1211
- alertRecipients: z6.array(AlertRecipientSchema).default([]),
1212
- reviewCadence: z6.enum(OBJECTIVE_CADENCES),
1213
- effectiveDate: z6.string().datetime(),
1214
- targetDate: z6.string().datetime().optional()
1215
- });
1216
- var UpdateQualityObjectiveRequestSchema = z6.object({
1217
- title: z6.string().min(1).max(200).optional(),
1218
- description: z6.string().min(1).max(5e3).optional(),
1219
- unit: z6.string().min(1).max(50).optional(),
1220
- target: z6.number().optional(),
1221
- direction: z6.enum(OBJECTIVE_DIRECTIONS).optional(),
1222
- warningThreshold: z6.number().optional(),
1223
- ownerDepartment: z6.string().min(1).optional(),
1224
- ownerDepartmentRole: z6.enum(["manager", "member"]).optional(),
1225
- alertRecipients: z6.array(AlertRecipientSchema).optional(),
1226
- reviewCadence: z6.enum(OBJECTIVE_CADENCES).optional(),
1227
- targetDate: z6.string().datetime().nullable().optional()
1228
- });
1229
- var RecordObjectiveValueRequestSchema = z6.object({
1230
- value: z6.number(),
1231
- note: z6.string().max(1e3).optional()
1232
- });
1233
- var ListQualityObjectivesQuerySchema = z6.object({
1234
- type: z6.enum(OBJECTIVE_TYPES).optional(),
1235
- status: z6.enum(OBJECTIVE_STATUSES).optional(),
1236
- isActive: z6.enum(["true", "false"]).transform((v) => v === "true").optional(),
1237
- page: z6.coerce.number().int().positive().default(1),
1238
- limit: z6.coerce.number().int().positive().max(100).default(20)
1239
- });
1240
- var QmsObjectiveParamSchema = z6.object({
1241
- orgId: z6.string().min(1),
1242
- qmsId: z6.string().min(1)
1243
- });
1244
- var ObjectiveIdParamSchema = z6.object({
1245
- orgId: z6.string().min(1),
1246
- qmsId: z6.string().min(1),
1247
- objectiveId: z6.string().min(1)
1248
- });
1249
- var QualityObjectiveSnapshotResponseSchema = z23.object({
1250
- id: z23.string(),
1251
- value: z23.number(),
1252
- status: z23.enum(OBJECTIVE_STATUSES),
1253
- source: z23.enum(["auto", "manual", "review"]),
1254
- reviewId: z23.string().nullable(),
1255
- capturedAt: z23.string(),
1256
- capturedBy: z23.string().nullable()
1257
- });
1258
- var QualityObjectiveResponseSchema = z23.object({
1241
+ var ErrorResponseSchema = z6.object({
1242
+ error: z6.string(),
1243
+ code: z6.string().optional(),
1244
+ details: z6.record(z6.unknown()).optional()
1245
+ });
1246
+ var PaginationParamsSchema = z6.object({
1247
+ limit: z6.coerce.number().min(1).max(100).optional().default(50),
1248
+ offset: z6.coerce.number().min(0).optional().default(0)
1249
+ });
1250
+ var NcStatusSchema = z7.enum(NC_STATUSES);
1251
+ var NcSeveritySchema = z7.enum(NC_SEVERITIES);
1252
+ var NcDispositionSchema = z7.enum(NC_DISPOSITIONS);
1253
+ var NcSourceTypeSchema = z7.enum(NC_SOURCE_TYPES);
1254
+ var QmsNcParamSchema = z7.object({
1255
+ orgId: z7.string().min(1),
1256
+ qmsId: z7.string().min(1)
1257
+ });
1258
+ var NcIdParamSchema = z7.object({
1259
+ orgId: z7.string().min(1),
1260
+ qmsId: z7.string().min(1),
1261
+ ncId: z7.string().min(1)
1262
+ });
1263
+ var CreateNcRequestSchema = z7.object({
1264
+ severity: NcSeveritySchema,
1265
+ sourceType: NcSourceTypeSchema,
1266
+ title: z7.string().min(1).max(200),
1267
+ description: z7.string().min(1).max(5e3),
1268
+ dueDate: z7.string().datetime().optional(),
1269
+ affectedDocumentIds: z7.array(z7.string().min(1)).default([]),
1270
+ affectedDeviceIds: z7.array(z7.string().min(1)).default([])
1271
+ });
1272
+ var UpdateNcRequestSchema = z7.object({
1273
+ title: z7.string().min(1).max(200).optional(),
1274
+ description: z7.string().min(1).max(5e3).optional(),
1275
+ severity: NcSeveritySchema.optional(),
1276
+ investigationDescription: z7.string().max(5e3).optional(),
1277
+ affectedDocumentIds: z7.array(z7.string().min(1)).optional(),
1278
+ affectedDeviceIds: z7.array(z7.string().min(1)).optional(),
1279
+ dueDate: z7.string().datetime().nullable().optional()
1280
+ });
1281
+ var SetDispositionRequestSchema = z7.object({
1282
+ disposition: NcDispositionSchema,
1283
+ justification: z7.string().min(1).max(5e3)
1284
+ });
1285
+ var ApproveConcessionRequestSchema = z7.object({
1286
+ signatureId: z7.string().min(1)
1287
+ });
1288
+ var NcListQuerySchema = PaginationParamsSchema.extend({
1289
+ status: NcStatusSchema.optional(),
1290
+ severity: NcSeveritySchema.optional(),
1291
+ sourceType: NcSourceTypeSchema.optional()
1292
+ });
1293
+ var NcResponseSchema = z23.object({
1259
1294
  id: z23.string(),
1260
- objectiveNumber: z23.string(),
1295
+ qmsId: z23.string(),
1296
+ organizationId: z23.string(),
1297
+ ncNumber: z23.string(),
1298
+ severity: NcSeveritySchema,
1299
+ sourceType: NcSourceTypeSchema,
1261
1300
  title: z23.string(),
1262
1301
  description: z23.string(),
1263
- type: z23.enum(OBJECTIVE_TYPES),
1264
- metricSource: z23.enum(AUTO_METRIC_SOURCES).nullable(),
1265
- unit: z23.string(),
1266
- target: z23.number(),
1267
- direction: z23.enum(OBJECTIVE_DIRECTIONS),
1268
- warningThreshold: z23.number(),
1269
- currentValue: z23.number().nullable(),
1270
- currentValueUpdatedAt: z23.string().nullable(),
1271
- status: z23.enum(OBJECTIVE_STATUSES),
1272
- ownerDepartment: z23.string(),
1273
- ownerDepartmentRole: z23.enum(["manager", "member"]),
1274
- alertRecipients: z23.array(
1275
- z23.object({
1276
- department: z23.string(),
1277
- departmentRole: z23.enum(["manager", "member"])
1278
- })
1279
- ),
1280
- reviewCadence: z23.enum(OBJECTIVE_CADENCES),
1281
- effectiveDate: z23.string(),
1282
- targetDate: z23.string().nullable(),
1283
- isActive: z23.boolean(),
1302
+ investigationDescription: z23.string().optional(),
1303
+ disposition: NcDispositionSchema.optional(),
1304
+ dispositionJustification: z23.string().optional(),
1305
+ concessionSignatureId: z23.string().optional(),
1306
+ affectedDocumentIds: z23.array(z23.string()),
1307
+ affectedDeviceIds: z23.array(z23.string()),
1308
+ linkedCapaId: z23.string().optional(),
1309
+ status: NcStatusSchema,
1284
1310
  createdAt: z23.string(),
1285
1311
  createdBy: z23.string(),
1286
- updatedAt: z23.string(),
1287
- // Optional: included when fetching detail with snapshots
1288
- recentSnapshots: z23.array(QualityObjectiveSnapshotResponseSchema).optional()
1289
- });
1290
- var ListQualityObjectivesResponseSchema = z23.object({
1291
- items: z23.array(QualityObjectiveResponseSchema),
1312
+ investigationStartedAt: z23.string().optional(),
1313
+ investigationStartedBy: z23.string().optional(),
1314
+ dispositionSetAt: z23.string().optional(),
1315
+ dispositionSetBy: z23.string().optional(),
1316
+ closedAt: z23.string().optional(),
1317
+ closedBy: z23.string().optional(),
1318
+ cancelledAt: z23.string().optional(),
1319
+ cancelledBy: z23.string().optional(),
1320
+ dueDate: z23.string().optional()
1321
+ });
1322
+ var NcListResponseSchema = z23.object({
1323
+ items: z23.array(NcResponseSchema),
1292
1324
  total: z23.number(),
1293
- page: z23.number(),
1294
1325
  limit: z23.number(),
1295
- hasMore: z23.boolean()
1296
- });
1297
- var ErrorResponseSchema = z7.object({
1298
- error: z7.string(),
1299
- code: z7.string().optional(),
1300
- details: z7.record(z7.unknown()).optional()
1301
- });
1302
- var PaginationParamsSchema = z7.object({
1303
- limit: z7.coerce.number().min(1).max(100).optional().default(50),
1304
- offset: z7.coerce.number().min(0).optional().default(0)
1305
- });
1306
- var NcStatusSchema = z8.enum(NC_STATUSES);
1307
- var NcSeveritySchema = z8.enum(NC_SEVERITIES);
1308
- var NcDispositionSchema = z8.enum(NC_DISPOSITIONS);
1309
- var NcSourceTypeSchema = z8.enum(NC_SOURCE_TYPES);
1310
- var QmsNcParamSchema = z8.object({
1326
+ offset: z23.number()
1327
+ });
1328
+ var CreateQualityReviewRequestSchema = z8.object({
1329
+ reviewTypeId: z8.string().min(1),
1330
+ title: z8.string().min(1).max(200),
1331
+ scheduledDate: z8.string().datetime(),
1332
+ reviewPeriod: z8.object({
1333
+ from: z8.string().datetime(),
1334
+ to: z8.string().datetime()
1335
+ })
1336
+ });
1337
+ var AddDecisionRequestSchema = z8.object({
1338
+ description: z8.string().min(1).max(2e3),
1339
+ decidedBy: z8.string().min(1)
1340
+ });
1341
+ var AddAttendeeRequestSchema = z8.object({
1342
+ memberId: z8.string().min(1),
1343
+ name: z8.string().min(1),
1344
+ department: z8.string().min(1),
1345
+ role: z8.string().min(1)
1346
+ });
1347
+ var UpdateReviewNotesRequestSchema = z8.object({
1348
+ notes: z8.string().max(1e4)
1349
+ });
1350
+ var ListQualityReviewsQuerySchema = z8.object({
1351
+ reviewTypeId: z8.string().optional(),
1352
+ status: z8.enum(REVIEW_STATUSES).optional(),
1353
+ page: z8.coerce.number().int().positive().default(1),
1354
+ limit: z8.coerce.number().int().positive().max(100).default(20)
1355
+ });
1356
+ var QmsReviewParamSchema = z8.object({
1311
1357
  orgId: z8.string().min(1),
1312
1358
  qmsId: z8.string().min(1)
1313
1359
  });
1314
- var NcIdParamSchema = z8.object({
1360
+ var ReviewIdParamSchema = z8.object({
1315
1361
  orgId: z8.string().min(1),
1316
1362
  qmsId: z8.string().min(1),
1317
- ncId: z8.string().min(1)
1318
- });
1319
- var CreateNcRequestSchema = z8.object({
1320
- severity: NcSeveritySchema,
1321
- sourceType: NcSourceTypeSchema,
1322
- title: z8.string().min(1).max(200),
1323
- description: z8.string().min(1).max(5e3),
1324
- dueDate: z8.string().datetime().optional(),
1325
- affectedDocumentIds: z8.array(z8.string().min(1)).default([]),
1326
- affectedDeviceIds: z8.array(z8.string().min(1)).default([])
1327
- });
1328
- var UpdateNcRequestSchema = z8.object({
1329
- title: z8.string().min(1).max(200).optional(),
1330
- description: z8.string().min(1).max(5e3).optional(),
1331
- severity: NcSeveritySchema.optional(),
1332
- investigationDescription: z8.string().max(5e3).optional(),
1333
- affectedDocumentIds: z8.array(z8.string().min(1)).optional(),
1334
- affectedDeviceIds: z8.array(z8.string().min(1)).optional(),
1335
- dueDate: z8.string().datetime().nullable().optional()
1363
+ reviewId: z8.string().min(1)
1364
+ });
1365
+ var MonthlyTrendSchema = z24.object({
1366
+ month: z24.string(),
1367
+ opened: z24.number(),
1368
+ closed: z24.number()
1369
+ });
1370
+ var ReviewDataSnapshotSchema = z24.object({
1371
+ capas: z24.object({
1372
+ total: z24.number(),
1373
+ open: z24.number(),
1374
+ overdue: z24.number(),
1375
+ avgCycleTimeDays: z24.number().nullable(),
1376
+ trend: z24.array(MonthlyTrendSchema)
1377
+ }).optional(),
1378
+ nonconformances: z24.object({
1379
+ total: z24.number(),
1380
+ open: z24.number(),
1381
+ overdue: z24.number(),
1382
+ avgCycleTimeDays: z24.number().nullable(),
1383
+ bySeverity: z24.record(z24.string(), z24.number()),
1384
+ trend: z24.array(MonthlyTrendSchema)
1385
+ }).optional(),
1386
+ complaints: z24.object({
1387
+ total: z24.number(),
1388
+ open: z24.number(),
1389
+ overdue: z24.number(),
1390
+ reportableCount: z24.number(),
1391
+ trend: z24.array(MonthlyTrendSchema)
1392
+ }).optional(),
1393
+ training: z24.object({
1394
+ totalTasks: z24.number(),
1395
+ complianceRate: z24.number(),
1396
+ overdue: z24.number()
1397
+ }).optional(),
1398
+ releases: z24.object({
1399
+ total: z24.number(),
1400
+ avgCycleTimeDays: z24.number().nullable()
1401
+ }).optional(),
1402
+ audits: z24.object({
1403
+ totalFindings: z24.number(),
1404
+ major: z24.number(),
1405
+ minor: z24.number(),
1406
+ observations: z24.number()
1407
+ }).optional()
1336
1408
  });
1337
- var SetDispositionRequestSchema = z8.object({
1338
- disposition: NcDispositionSchema,
1339
- justification: z8.string().min(1).max(5e3)
1409
+ var ReviewObjectiveSnapshotSchema = z24.object({
1410
+ objectiveId: z24.string(),
1411
+ title: z24.string(),
1412
+ target: z24.number(),
1413
+ value: z24.number().nullable(),
1414
+ status: z24.string(),
1415
+ direction: z24.string(),
1416
+ unit: z24.string()
1340
1417
  });
1341
- var ApproveConcessionRequestSchema = z8.object({
1342
- signatureId: z8.string().min(1)
1418
+ var ReviewDecisionSchema = z24.object({
1419
+ description: z24.string(),
1420
+ decidedBy: z24.string()
1343
1421
  });
1344
- var NcListQuerySchema = PaginationParamsSchema.extend({
1345
- status: NcStatusSchema.optional(),
1346
- severity: NcSeveritySchema.optional(),
1347
- sourceType: NcSourceTypeSchema.optional()
1422
+ var ReviewAttendeeSchema = z24.object({
1423
+ memberId: z24.string(),
1424
+ name: z24.string(),
1425
+ department: z24.string(),
1426
+ role: z24.string()
1348
1427
  });
1349
- var NcResponseSchema = z24.object({
1428
+ var QualityReviewResponseSchema = z24.object({
1350
1429
  id: z24.string(),
1351
- qmsId: z24.string(),
1352
- organizationId: z24.string(),
1353
- ncNumber: z24.string(),
1354
- severity: NcSeveritySchema,
1355
- sourceType: NcSourceTypeSchema,
1430
+ reviewNumber: z24.string(),
1356
1431
  title: z24.string(),
1357
- description: z24.string(),
1358
- investigationDescription: z24.string().optional(),
1359
- disposition: NcDispositionSchema.optional(),
1360
- dispositionJustification: z24.string().optional(),
1361
- concessionSignatureId: z24.string().optional(),
1362
- affectedDocumentIds: z24.array(z24.string()),
1363
- affectedDeviceIds: z24.array(z24.string()),
1364
- linkedCapaId: z24.string().optional(),
1365
- status: NcStatusSchema,
1432
+ reviewTypeId: z24.string(),
1433
+ reviewTypeName: z24.string(),
1434
+ status: z24.enum(REVIEW_STATUSES),
1435
+ scheduledDate: z24.string(),
1436
+ conductedDate: z24.string().nullable(),
1437
+ reviewPeriod: z24.object({
1438
+ from: z24.string(),
1439
+ to: z24.string()
1440
+ }),
1441
+ ownerDepartment: z24.string(),
1442
+ ownerDepartmentRole: z24.enum(["manager", "member"]),
1443
+ dataSources: z24.array(z24.enum(REVIEW_DATA_SOURCES)),
1444
+ attendees: z24.array(ReviewAttendeeSchema),
1445
+ dataSnapshot: ReviewDataSnapshotSchema,
1446
+ objectiveSnapshots: z24.array(ReviewObjectiveSnapshotSchema),
1447
+ decisions: z24.array(ReviewDecisionSchema),
1448
+ notes: z24.string().nullable(),
1449
+ completedAt: z24.string().nullable(),
1450
+ completedBy: z24.string().nullable(),
1366
1451
  createdAt: z24.string(),
1367
1452
  createdBy: z24.string(),
1368
- investigationStartedAt: z24.string().optional(),
1369
- investigationStartedBy: z24.string().optional(),
1370
- dispositionSetAt: z24.string().optional(),
1371
- dispositionSetBy: z24.string().optional(),
1372
- closedAt: z24.string().optional(),
1373
- closedBy: z24.string().optional(),
1374
- cancelledAt: z24.string().optional(),
1375
- cancelledBy: z24.string().optional(),
1376
- dueDate: z24.string().optional()
1377
- });
1378
- var NcListResponseSchema = z24.object({
1379
- items: z24.array(NcResponseSchema),
1453
+ updatedAt: z24.string()
1454
+ });
1455
+ var ListQualityReviewsResponseSchema = z24.object({
1456
+ items: z24.array(QualityReviewResponseSchema),
1380
1457
  total: z24.number(),
1458
+ page: z24.number(),
1381
1459
  limit: z24.number(),
1382
- offset: z24.number()
1383
- });
1384
- var CapaStatusSchema = z9.enum(CAPA_STATUSES);
1385
- var CapaClassificationSchema = z9.enum(CAPA_CLASSIFICATIONS);
1386
- var CapaPrioritySchema = z9.enum(CAPA_PRIORITIES);
1387
- var CapaSourceTypeSchema = z9.enum(CAPA_SOURCE_TYPES);
1388
- var CapaActionStatusSchema = z9.enum(CAPA_ACTION_STATUSES);
1389
- var QmsCapaParamSchema = z9.object({
1390
- orgId: z9.string().min(1),
1391
- qmsId: z9.string().min(1)
1392
- });
1393
- var CapaIdParamSchema = z9.object({
1394
- orgId: z9.string().min(1),
1395
- qmsId: z9.string().min(1),
1396
- capaId: z9.string().min(1)
1460
+ hasMore: z24.boolean()
1397
1461
  });
1398
- var CapaActionIdParamSchema = z9.object({
1399
- orgId: z9.string().min(1),
1400
- qmsId: z9.string().min(1),
1401
- capaId: z9.string().min(1),
1402
- actionId: z9.string().min(1)
1462
+ var ActionSourceSchema = z9.object({
1463
+ type: z9.enum(ACTION_SOURCE_TYPES),
1464
+ id: z9.string().min(1),
1465
+ displayNumber: z9.string().optional()
1403
1466
  });
1404
- var CreateCapaRequestSchema = z9.object({
1405
- classification: CapaClassificationSchema,
1406
- priority: CapaPrioritySchema,
1467
+ var CreateActionRequestSchema = z9.object({
1407
1468
  title: z9.string().min(1).max(200),
1408
1469
  description: z9.string().min(1).max(5e3),
1409
- sourceType: CapaSourceTypeSchema,
1410
- sourceDescription: z9.string().min(1).max(2e3),
1411
- sourceId: z9.string().max(200).optional(),
1412
- dueDate: z9.string().datetime().optional(),
1413
- affectedDocumentIds: z9.array(z9.string().min(1)).default([]),
1414
- affectedDeviceIds: z9.array(z9.string().min(1)).default([])
1470
+ source: ActionSourceSchema,
1471
+ assigneeDepartment: z9.string().min(1),
1472
+ assigneeDepartmentRole: z9.enum(["manager", "member"]),
1473
+ assigneeId: z9.string().optional(),
1474
+ priority: z9.enum(ACTION_PRIORITIES),
1475
+ dueDate: z9.string().datetime()
1415
1476
  });
1416
- var UpdateCapaRequestSchema = z9.object({
1477
+ var UpdateActionRequestSchema = z9.object({
1417
1478
  title: z9.string().min(1).max(200).optional(),
1418
1479
  description: z9.string().min(1).max(5e3).optional(),
1419
- priority: CapaPrioritySchema.optional(),
1420
- rootCauseDescription: z9.string().max(5e3).optional(),
1421
- verificationDescription: z9.string().max(5e3).optional(),
1422
- affectedDocumentIds: z9.array(z9.string().min(1)).optional(),
1423
- affectedDeviceIds: z9.array(z9.string().min(1)).optional(),
1424
- dueDate: z9.string().datetime().nullable().optional()
1425
- });
1426
- var CloseCapaRequestSchema = z9.object({
1427
- signatureId: z9.string().min(1)
1428
- });
1429
- var AddCapaActionRequestSchema = z9.object({
1430
- description: z9.string().min(1).max(2e3),
1431
- assigneeId: z9.string().min(1),
1432
- dueDate: z9.string().datetime(),
1433
- notes: z9.string().max(2e3).optional()
1434
- });
1435
- var UpdateCapaActionRequestSchema = z9.object({
1436
- description: z9.string().min(1).max(2e3).optional(),
1437
- assigneeId: z9.string().min(1).optional(),
1480
+ assigneeDepartment: z9.string().min(1).optional(),
1481
+ assigneeDepartmentRole: z9.enum(["manager", "member"]).optional(),
1482
+ assigneeId: z9.string().nullable().optional(),
1483
+ priority: z9.enum(ACTION_PRIORITIES).optional(),
1438
1484
  dueDate: z9.string().datetime().optional(),
1439
- status: CapaActionStatusSchema.optional(),
1440
- notes: z9.string().max(2e3).optional()
1485
+ notes: z9.string().max(5e3).optional()
1441
1486
  });
1442
- var CapaListQuerySchema = PaginationParamsSchema.extend({
1443
- status: CapaStatusSchema.optional(),
1444
- classification: CapaClassificationSchema.optional(),
1445
- priority: CapaPrioritySchema.optional()
1487
+ var ListActionsQuerySchema = z9.object({
1488
+ sourceType: z9.enum(ACTION_SOURCE_TYPES).optional(),
1489
+ sourceId: z9.string().optional(),
1490
+ status: z9.enum(ACTION_STATUSES).optional(),
1491
+ assigneeDepartment: z9.string().optional(),
1492
+ priority: z9.enum(ACTION_PRIORITIES).optional(),
1493
+ page: z9.coerce.number().int().positive().default(1),
1494
+ limit: z9.coerce.number().int().positive().max(100).default(20)
1446
1495
  });
1447
- var CapaActionResponseSchema = z25.object({
1448
- id: z25.string(),
1449
- description: z25.string(),
1450
- assigneeId: z25.string(),
1451
- assigneeEmail: z25.string(),
1452
- dueDate: z25.string(),
1453
- status: CapaActionStatusSchema,
1454
- completedAt: z25.string().optional(),
1455
- notes: z25.string().optional()
1496
+ var CompleteActionRequestSchema = z9.object({
1497
+ notes: z9.string().max(5e3).optional()
1498
+ });
1499
+ var QmsActionParamSchema = z9.object({
1500
+ orgId: z9.string().min(1),
1501
+ qmsId: z9.string().min(1)
1456
1502
  });
1457
- var CapaResponseSchema = z25.object({
1503
+ var ActionIdParamSchema = z9.object({
1504
+ orgId: z9.string().min(1),
1505
+ qmsId: z9.string().min(1),
1506
+ actionId: z9.string().min(1)
1507
+ });
1508
+ var ActionResponseSchema = z25.object({
1458
1509
  id: z25.string(),
1459
- qmsId: z25.string(),
1460
- organizationId: z25.string(),
1461
- capaNumber: z25.string(),
1462
- classification: CapaClassificationSchema,
1463
- priority: CapaPrioritySchema,
1510
+ actionNumber: z25.string(),
1464
1511
  title: z25.string(),
1465
1512
  description: z25.string(),
1466
- sourceType: CapaSourceTypeSchema,
1467
- sourceId: z25.string().optional(),
1468
- sourceDescription: z25.string(),
1469
- rootCauseDescription: z25.string().optional(),
1470
- verificationDescription: z25.string().optional(),
1471
- affectedDocumentIds: z25.array(z25.string()),
1472
- affectedDeviceIds: z25.array(z25.string()),
1473
- actions: z25.array(CapaActionResponseSchema),
1474
- status: CapaStatusSchema,
1513
+ source: z25.object({
1514
+ type: z25.enum(ACTION_SOURCE_TYPES),
1515
+ id: z25.string(),
1516
+ displayNumber: z25.string().optional()
1517
+ }),
1518
+ assigneeDepartment: z25.string(),
1519
+ assigneeDepartmentRole: z25.enum(["manager", "member"]),
1520
+ assigneeId: z25.string().nullable(),
1521
+ priority: z25.enum(ACTION_PRIORITIES),
1522
+ dueDate: z25.string(),
1523
+ status: z25.enum(ACTION_STATUSES),
1524
+ isOverdue: z25.boolean(),
1525
+ completedAt: z25.string().nullable(),
1526
+ completedBy: z25.string().nullable(),
1527
+ notes: z25.string().nullable(),
1475
1528
  createdAt: z25.string(),
1476
1529
  createdBy: z25.string(),
1477
- investigationStartedAt: z25.string().optional(),
1478
- implementationStartedAt: z25.string().optional(),
1479
- verificationStartedAt: z25.string().optional(),
1480
- closedAt: z25.string().optional(),
1481
- closedBy: z25.string().optional(),
1482
- cancelledAt: z25.string().optional(),
1483
- cancelledBy: z25.string().optional(),
1484
- dueDate: z25.string().optional()
1485
- });
1486
- var CapaListResponseSchema = z25.object({
1487
- items: z25.array(CapaResponseSchema),
1530
+ updatedAt: z25.string()
1531
+ });
1532
+ var ListActionsResponseSchema = z25.object({
1533
+ items: z25.array(ActionResponseSchema),
1488
1534
  total: z25.number(),
1535
+ page: z25.number(),
1489
1536
  limit: z25.number(),
1490
- offset: z25.number()
1537
+ hasMore: z25.boolean()
1538
+ });
1539
+ var CapaStatusSchema = z10.enum(CAPA_STATUSES);
1540
+ var CapaClassificationSchema = z10.enum(CAPA_CLASSIFICATIONS);
1541
+ var CapaPrioritySchema = z10.enum(CAPA_PRIORITIES);
1542
+ var CapaSourceTypeSchema = z10.enum(CAPA_SOURCE_TYPES);
1543
+ var CapaActionStatusSchema = z10.enum(CAPA_ACTION_STATUSES);
1544
+ var QmsCapaParamSchema = z10.object({
1545
+ orgId: z10.string().min(1),
1546
+ qmsId: z10.string().min(1)
1491
1547
  });
1492
- var ActionSourceSchema = z10.object({
1493
- type: z10.enum(ACTION_SOURCE_TYPES),
1494
- id: z10.string().min(1),
1495
- displayNumber: z10.string().optional()
1548
+ var CapaIdParamSchema = z10.object({
1549
+ orgId: z10.string().min(1),
1550
+ qmsId: z10.string().min(1),
1551
+ capaId: z10.string().min(1)
1496
1552
  });
1497
- var CreateActionRequestSchema = z10.object({
1553
+ var CapaActionIdParamSchema = z10.object({
1554
+ orgId: z10.string().min(1),
1555
+ qmsId: z10.string().min(1),
1556
+ capaId: z10.string().min(1),
1557
+ actionId: z10.string().min(1)
1558
+ });
1559
+ var CreateCapaRequestSchema = z10.object({
1560
+ classification: CapaClassificationSchema,
1561
+ priority: CapaPrioritySchema,
1498
1562
  title: z10.string().min(1).max(200),
1499
1563
  description: z10.string().min(1).max(5e3),
1500
- source: ActionSourceSchema,
1501
- assigneeDepartment: z10.string().min(1),
1502
- assigneeDepartmentRole: z10.enum(["manager", "member"]),
1503
- assigneeId: z10.string().optional(),
1504
- priority: z10.enum(ACTION_PRIORITIES),
1505
- dueDate: z10.string().datetime()
1564
+ sourceType: CapaSourceTypeSchema,
1565
+ sourceDescription: z10.string().min(1).max(2e3),
1566
+ sourceId: z10.string().max(200).optional(),
1567
+ dueDate: z10.string().datetime().optional(),
1568
+ affectedDocumentIds: z10.array(z10.string().min(1)).default([]),
1569
+ affectedDeviceIds: z10.array(z10.string().min(1)).default([])
1506
1570
  });
1507
- var UpdateActionRequestSchema = z10.object({
1571
+ var UpdateCapaRequestSchema = z10.object({
1508
1572
  title: z10.string().min(1).max(200).optional(),
1509
1573
  description: z10.string().min(1).max(5e3).optional(),
1510
- assigneeDepartment: z10.string().min(1).optional(),
1511
- assigneeDepartmentRole: z10.enum(["manager", "member"]).optional(),
1512
- assigneeId: z10.string().nullable().optional(),
1513
- priority: z10.enum(ACTION_PRIORITIES).optional(),
1574
+ priority: CapaPrioritySchema.optional(),
1575
+ rootCauseDescription: z10.string().max(5e3).optional(),
1576
+ verificationDescription: z10.string().max(5e3).optional(),
1577
+ affectedDocumentIds: z10.array(z10.string().min(1)).optional(),
1578
+ affectedDeviceIds: z10.array(z10.string().min(1)).optional(),
1579
+ dueDate: z10.string().datetime().nullable().optional()
1580
+ });
1581
+ var CloseCapaRequestSchema = z10.object({
1582
+ signatureId: z10.string().min(1)
1583
+ });
1584
+ var AddCapaActionRequestSchema = z10.object({
1585
+ description: z10.string().min(1).max(2e3),
1586
+ assigneeId: z10.string().min(1),
1587
+ dueDate: z10.string().datetime(),
1588
+ notes: z10.string().max(2e3).optional()
1589
+ });
1590
+ var UpdateCapaActionRequestSchema = z10.object({
1591
+ description: z10.string().min(1).max(2e3).optional(),
1592
+ assigneeId: z10.string().min(1).optional(),
1514
1593
  dueDate: z10.string().datetime().optional(),
1515
- notes: z10.string().max(5e3).optional()
1516
- });
1517
- var ListActionsQuerySchema = z10.object({
1518
- sourceType: z10.enum(ACTION_SOURCE_TYPES).optional(),
1519
- sourceId: z10.string().optional(),
1520
- status: z10.enum(ACTION_STATUSES).optional(),
1521
- assigneeDepartment: z10.string().optional(),
1522
- priority: z10.enum(ACTION_PRIORITIES).optional(),
1523
- page: z10.coerce.number().int().positive().default(1),
1524
- limit: z10.coerce.number().int().positive().max(100).default(20)
1525
- });
1526
- var CompleteActionRequestSchema = z10.object({
1527
- notes: z10.string().max(5e3).optional()
1594
+ status: CapaActionStatusSchema.optional(),
1595
+ notes: z10.string().max(2e3).optional()
1528
1596
  });
1529
- var QmsActionParamSchema = z10.object({
1530
- orgId: z10.string().min(1),
1531
- qmsId: z10.string().min(1)
1597
+ var CapaListQuerySchema = PaginationParamsSchema.extend({
1598
+ status: CapaStatusSchema.optional(),
1599
+ classification: CapaClassificationSchema.optional(),
1600
+ priority: CapaPrioritySchema.optional()
1532
1601
  });
1533
- var ActionIdParamSchema = z10.object({
1534
- orgId: z10.string().min(1),
1535
- qmsId: z10.string().min(1),
1536
- actionId: z10.string().min(1)
1602
+ var CapaActionResponseSchema = z26.object({
1603
+ id: z26.string(),
1604
+ description: z26.string(),
1605
+ assigneeId: z26.string(),
1606
+ assigneeEmail: z26.string(),
1607
+ dueDate: z26.string(),
1608
+ status: CapaActionStatusSchema,
1609
+ completedAt: z26.string().optional(),
1610
+ notes: z26.string().optional()
1537
1611
  });
1538
- var ActionResponseSchema = z26.object({
1612
+ var CapaResponseSchema = z26.object({
1539
1613
  id: z26.string(),
1540
- actionNumber: z26.string(),
1614
+ qmsId: z26.string(),
1615
+ organizationId: z26.string(),
1616
+ capaNumber: z26.string(),
1617
+ classification: CapaClassificationSchema,
1618
+ priority: CapaPrioritySchema,
1541
1619
  title: z26.string(),
1542
1620
  description: z26.string(),
1543
- source: z26.object({
1544
- type: z26.enum(ACTION_SOURCE_TYPES),
1545
- id: z26.string(),
1546
- displayNumber: z26.string().optional()
1547
- }),
1548
- assigneeDepartment: z26.string(),
1549
- assigneeDepartmentRole: z26.enum(["manager", "member"]),
1550
- assigneeId: z26.string().nullable(),
1551
- priority: z26.enum(ACTION_PRIORITIES),
1552
- dueDate: z26.string(),
1553
- status: z26.enum(ACTION_STATUSES),
1554
- isOverdue: z26.boolean(),
1555
- completedAt: z26.string().nullable(),
1556
- completedBy: z26.string().nullable(),
1557
- notes: z26.string().nullable(),
1621
+ sourceType: CapaSourceTypeSchema,
1622
+ sourceId: z26.string().optional(),
1623
+ sourceDescription: z26.string(),
1624
+ rootCauseDescription: z26.string().optional(),
1625
+ verificationDescription: z26.string().optional(),
1626
+ affectedDocumentIds: z26.array(z26.string()),
1627
+ affectedDeviceIds: z26.array(z26.string()),
1628
+ actions: z26.array(CapaActionResponseSchema),
1629
+ status: CapaStatusSchema,
1558
1630
  createdAt: z26.string(),
1559
1631
  createdBy: z26.string(),
1560
- updatedAt: z26.string()
1561
- });
1562
- var ListActionsResponseSchema = z26.object({
1563
- items: z26.array(ActionResponseSchema),
1632
+ investigationStartedAt: z26.string().optional(),
1633
+ implementationStartedAt: z26.string().optional(),
1634
+ verificationStartedAt: z26.string().optional(),
1635
+ closedAt: z26.string().optional(),
1636
+ closedBy: z26.string().optional(),
1637
+ cancelledAt: z26.string().optional(),
1638
+ cancelledBy: z26.string().optional(),
1639
+ dueDate: z26.string().optional()
1640
+ });
1641
+ var CapaListResponseSchema = z26.object({
1642
+ items: z26.array(CapaResponseSchema),
1564
1643
  total: z26.number(),
1565
- page: z26.number(),
1566
1644
  limit: z26.number(),
1567
- hasMore: z26.boolean()
1645
+ offset: z26.number()
1568
1646
  });
1569
1647
  var ComplaintStatusSchema = z11.enum(COMPLAINT_STATUSES);
1570
1648
  var ComplaintSeveritySchema = z11.enum(COMPLAINT_SEVERITIES);
@@ -4912,8 +4990,8 @@ var FrameworkEvidenceResponseSchema = z38.object({
4912
4990
  });
4913
4991
 
4914
4992
  // src/generators/rmr-generator.ts
4915
- import { readFileSync as readFileSync3, existsSync as existsSync2 } from "fs";
4916
- import { resolve as resolve3 } from "path";
4993
+ import { readFileSync as readFileSync4, existsSync as existsSync3 } from "fs";
4994
+ import { resolve as resolve4 } from "path";
4917
4995
  import { parse as parseYaml2 } from "yaml";
4918
4996
  var HEADER_GRAY3 = "#F0F0F0";
4919
4997
  function isHazard(doc) {
@@ -4924,12 +5002,12 @@ function isRiskEntry(doc) {
4924
5002
  }
4925
5003
  function loadRiskMatrix(rootDir) {
4926
5004
  const candidates = [
4927
- resolve3(rootDir, "risk-matrix.yaml"),
4928
- resolve3(rootDir, "docs/risk/risk-matrix.yaml")
5005
+ resolve4(rootDir, "risk-matrix.yaml"),
5006
+ resolve4(rootDir, "docs/risk/risk-matrix.yaml")
4929
5007
  ];
4930
5008
  for (const candidate of candidates) {
4931
- if (existsSync2(candidate)) {
4932
- const raw = readFileSync3(candidate, "utf-8");
5009
+ if (existsSync3(candidate)) {
5010
+ const raw = readFileSync4(candidate, "utf-8");
4933
5011
  const parsed = parseYaml2(raw);
4934
5012
  const result = RiskMatrixConfigSchema.safeParse(parsed);
4935
5013
  if (result.success) {
@@ -5145,6 +5223,7 @@ function generateRmr(input) {
5145
5223
  }
5146
5224
  return buildDocumentDefinition({
5147
5225
  config: input.config,
5226
+ rootDir: input.rootDir,
5148
5227
  recordTitle: "Risk Management Report",
5149
5228
  recordId: "RMR",
5150
5229
  version: input.version,
@@ -5156,8 +5235,8 @@ function generateRmr(input) {
5156
5235
 
5157
5236
  // src/github/changelog.ts
5158
5237
  import { execFileSync } from "child_process";
5159
- import { resolve as resolve4 } from "path";
5160
- import { readFileSync as readFileSync4 } from "fs";
5238
+ import { resolve as resolve5 } from "path";
5239
+ import { readFileSync as readFileSync5 } from "fs";
5161
5240
  import matter3 from "gray-matter";
5162
5241
  function buildChangelog(rootDir, version, date) {
5163
5242
  let previousTag = null;
@@ -5191,7 +5270,7 @@ function buildChangelog(rootDir, version, date) {
5191
5270
  const descriptions = [];
5192
5271
  for (const file of changedFiles.slice(0, 20)) {
5193
5272
  try {
5194
- const raw = readFileSync4(resolve4(rootDir, file), "utf-8");
5273
+ const raw = readFileSync5(resolve5(rootDir, file), "utf-8");
5195
5274
  const { data } = matter3(raw);
5196
5275
  if (data.id && data.title) {
5197
5276
  descriptions.push(`${data.id}: ${data.title}`);
@@ -5289,10 +5368,10 @@ function getDraftReleaseVersion() {
5289
5368
  // src/github/publish.ts
5290
5369
  import { execFileSync as execFileSync3 } from "child_process";
5291
5370
  import { readdirSync as readdirSync2 } from "fs";
5292
- import { resolve as resolve5 } from "path";
5371
+ import { resolve as resolve6 } from "path";
5293
5372
  function publishDraftRelease(version, outputDir) {
5294
5373
  const tag = `v${version}`;
5295
- const pdfFiles = readdirSync2(outputDir).filter((f) => f.endsWith(".pdf")).map((f) => resolve5(outputDir, f));
5374
+ const pdfFiles = readdirSync2(outputDir).filter((f) => f.endsWith(".pdf")).map((f) => resolve6(outputDir, f));
5296
5375
  if (pdfFiles.length === 0) {
5297
5376
  throw new Error("No PDF files found to upload");
5298
5377
  }