@pactosigna/schemas 0.1.0
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/README.md +107 -0
- package/dist/index.d.ts +1654 -0
- package/dist/index.js +1156 -0
- package/package.json +51 -0
package/README.md
ADDED
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
# @pactosigna/schemas
|
|
2
|
+
|
|
3
|
+
Zod schemas, TypeScript types, and constants for validating PactoSigna QMS documents (ISO 13485, IEC 62304, ISO 14971).
|
|
4
|
+
|
|
5
|
+
This package is the public-facing subset of `@pactosigna/shared`. It bundles everything inline via tsup so consumers only need `zod` as a dependency.
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install @pactosigna/schemas
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Usage
|
|
14
|
+
|
|
15
|
+
### Validate document frontmatter
|
|
16
|
+
|
|
17
|
+
Use `getSchemaForDocumentType` to retrieve the Zod schema for a given document type, then validate frontmatter parsed from YAML.
|
|
18
|
+
|
|
19
|
+
```typescript
|
|
20
|
+
import { getSchemaForDocumentType } from '@pactosigna/schemas';
|
|
21
|
+
|
|
22
|
+
const schema = getSchemaForDocumentType('user_need');
|
|
23
|
+
if (schema) {
|
|
24
|
+
const result = schema.safeParse({
|
|
25
|
+
id: 'UN-001',
|
|
26
|
+
title: 'Role-Based Access Control',
|
|
27
|
+
status: 'draft',
|
|
28
|
+
stakeholder: 'Quality Manager',
|
|
29
|
+
priority: 'must_have',
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
if (!result.success) {
|
|
33
|
+
console.error('Validation errors:', result.error.issues);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
### Check required sections
|
|
39
|
+
|
|
40
|
+
Each document type can declare mandatory H2 sections. The sync engine uses this to flag missing content.
|
|
41
|
+
|
|
42
|
+
```typescript
|
|
43
|
+
import { REQUIRED_SECTIONS } from '@pactosigna/schemas';
|
|
44
|
+
|
|
45
|
+
const sections = REQUIRED_SECTIONS.release_plan;
|
|
46
|
+
// ['Scope', 'Applicable Plans', 'Release-Specific Criteria', 'Known Anomalies']
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
### List all document types
|
|
50
|
+
|
|
51
|
+
```typescript
|
|
52
|
+
import { DOCUMENT_TYPES } from '@pactosigna/schemas';
|
|
53
|
+
|
|
54
|
+
for (const [key, label] of Object.entries(DOCUMENT_TYPES)) {
|
|
55
|
+
console.log(`${key}: ${label}`);
|
|
56
|
+
}
|
|
57
|
+
// user_need: User Need
|
|
58
|
+
// requirement: Requirement
|
|
59
|
+
// ...
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
### Use TypeScript types
|
|
63
|
+
|
|
64
|
+
All frontmatter schemas export their inferred types.
|
|
65
|
+
|
|
66
|
+
```typescript
|
|
67
|
+
import type { UserNeedFrontmatter, RequirementFrontmatter } from '@pactosigna/schemas';
|
|
68
|
+
|
|
69
|
+
const need: UserNeedFrontmatter = {
|
|
70
|
+
id: 'UN-001',
|
|
71
|
+
title: 'Audit Trail Visibility',
|
|
72
|
+
status: 'approved',
|
|
73
|
+
stakeholder: 'Quality Manager',
|
|
74
|
+
priority: 'must_have',
|
|
75
|
+
};
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
### Classify document types
|
|
79
|
+
|
|
80
|
+
```typescript
|
|
81
|
+
import {
|
|
82
|
+
isQmsDocumentType,
|
|
83
|
+
isDeviceDocumentType,
|
|
84
|
+
QMS_DOCUMENT_TYPES,
|
|
85
|
+
DEVICE_DOCUMENT_TYPES,
|
|
86
|
+
} from '@pactosigna/schemas';
|
|
87
|
+
|
|
88
|
+
isQmsDocumentType('sop'); // true
|
|
89
|
+
isDeviceDocumentType('user_need'); // true
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
## Exports
|
|
93
|
+
|
|
94
|
+
| Category | Examples |
|
|
95
|
+
| ----------------------- | ----------------------------------------------------------------------------------------------------------------------------------- |
|
|
96
|
+
| **Constants** | `DOCUMENT_TYPES`, `REQUIRED_SECTIONS`, `LINK_TYPES` |
|
|
97
|
+
| **Classification** | `QMS_DOCUMENT_TYPES`, `DEVICE_DOCUMENT_TYPES`, `CHANGE_DOCUMENT_TYPES` |
|
|
98
|
+
| **Predicates** | `isQmsDocumentType`, `isDeviceDocumentType`, `isChangeDocumentType` |
|
|
99
|
+
| **Zod enums** | `DocumentTypeSchema`, `DocumentStatusSchema`, `LinkTypeSchema`, `SafetyClassSchema` |
|
|
100
|
+
| **Frontmatter schemas** | `UserNeedFrontmatterSchema`, `RequirementFrontmatterSchema`, `RiskEntryFrontmatterSchema`, `AnomalyFrontmatterSchema`, and 30+ more |
|
|
101
|
+
| **Schema map** | `SCHEMA_MAP`, `getSchemaForDocumentType` |
|
|
102
|
+
| **Repo config** | `RepoConfigSchema`, `ReleaseReviewConfigSchema` |
|
|
103
|
+
| **Retention** | `RetentionPolicySchema`, `isWithinRetentionPeriod`, `getEffectiveRetentionYears` |
|
|
104
|
+
|
|
105
|
+
## License
|
|
106
|
+
|
|
107
|
+
MIT
|