@plasius/schema 1.0.8 → 1.0.9
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/CONTRIBUTING.md +201 -0
- package/README.md +0 -2
- package/docs/adrs/adr-0001: schema.md +41 -0
- package/docs/adrs/adr-template.md +65 -0
- package/legal/CORPORATE_CLA.md +2 -0
- package/legal/INDIVIDUAL_CLA.md +2 -2
- package/package.json +1 -1
package/CONTRIBUTING.md
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
# Contributing to @plasius/schema
|
|
2
|
+
|
|
3
|
+
First off: thanks for taking the time to contribute!
|
|
4
|
+
This document explains how to work on the project, how to propose changes, and what we expect in pull requests.
|
|
5
|
+
|
|
6
|
+
> TL;DR
|
|
7
|
+
>
|
|
8
|
+
> - Be respectful and follow the Code of Conduct.
|
|
9
|
+
> - Open an issue before large changes; small fixes can go straight to a PR.
|
|
10
|
+
> - Write tests, keep coverage steady or improving.
|
|
11
|
+
> - Use Conventional Commits.
|
|
12
|
+
> - Don’t include real PII in code, issues, tests, or logs.
|
|
13
|
+
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
## Code of Conduct
|
|
17
|
+
|
|
18
|
+
Participation in this project is governed by our **Code of Conduct** (see `CODE_OF_CONDUCT.md`). By participating, you agree to abide by it.
|
|
19
|
+
|
|
20
|
+
## Licensing & CLA
|
|
21
|
+
|
|
22
|
+
This project is open source (see `LICENSE`). To protect contributors and users, we require contributors to agree to our **Contributor License Agreement (CLA)** before we can merge PRs (see `legal/CLA.md`). You’ll be prompted automatically by the CLA bot on your first PR.
|
|
23
|
+
|
|
24
|
+
> If your company has special legal needs, please contact the maintainers before sending large PRs.
|
|
25
|
+
|
|
26
|
+
## Security
|
|
27
|
+
|
|
28
|
+
**Never** report security issues in public issues or PRs. Instead, follow the process in `SECURITY.md`.
|
|
29
|
+
|
|
30
|
+
---
|
|
31
|
+
|
|
32
|
+
## What this project does
|
|
33
|
+
|
|
34
|
+
`@plasius/schema` provides a small, strongly-typed schema library:
|
|
35
|
+
|
|
36
|
+
- A fluent field builder (e.g. `field().string().required()`),
|
|
37
|
+
- Built-in validators for common standards (ISO/RFC/OWASP, etc.),
|
|
38
|
+
- PII annotations + redaction utilities,
|
|
39
|
+
- Type inference for safe, consistent entities across projects.
|
|
40
|
+
|
|
41
|
+
Contributions typically fall into: new validators, field builder features, type improvements, docs, and tooling quality.
|
|
42
|
+
|
|
43
|
+
---
|
|
44
|
+
|
|
45
|
+
## Getting started (local dev)
|
|
46
|
+
|
|
47
|
+
### Prerequisites
|
|
48
|
+
|
|
49
|
+
- Node.js (use the version specified in `.nvmrc` if present: `nvm use`).
|
|
50
|
+
- npm (we use npm scripts in this repo).
|
|
51
|
+
|
|
52
|
+
### Install
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
npm ci
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
### Build
|
|
59
|
+
|
|
60
|
+
```bash
|
|
61
|
+
npm run build
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
### Test
|
|
65
|
+
|
|
66
|
+
```bash
|
|
67
|
+
npm test
|
|
68
|
+
# or, if using Vitest in watch mode
|
|
69
|
+
npm run test:watch
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
### Lint & format
|
|
73
|
+
|
|
74
|
+
```bash
|
|
75
|
+
npm run lint
|
|
76
|
+
npm run format
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
> Tip: set up your editor to run ESLint and Prettier on save.
|
|
80
|
+
|
|
81
|
+
---
|
|
82
|
+
|
|
83
|
+
## How to propose a change
|
|
84
|
+
|
|
85
|
+
### 1) For bugs
|
|
86
|
+
|
|
87
|
+
- Search existing issues first.
|
|
88
|
+
- Open a new issue with:
|
|
89
|
+
- Clear title, steps to reproduce, expected vs actual behaviour,
|
|
90
|
+
- Minimal repro (code snippet or small repo),
|
|
91
|
+
- Environment info (OS, Node, package version).
|
|
92
|
+
|
|
93
|
+
### 2) For features / refactors
|
|
94
|
+
|
|
95
|
+
- For anything non-trivial, open an issue first and outline the proposal.
|
|
96
|
+
- If the change affects public API or architecture, add an ADR draft (see `docs/adrs/`).
|
|
97
|
+
|
|
98
|
+
### 3) Good first issues
|
|
99
|
+
|
|
100
|
+
We label approachable tasks as **good first issue** and **help wanted**.
|
|
101
|
+
|
|
102
|
+
---
|
|
103
|
+
|
|
104
|
+
## Branch, commit, PR
|
|
105
|
+
|
|
106
|
+
**Branching**
|
|
107
|
+
|
|
108
|
+
- Fork or create a feature branch from `main`: `feat/xyz` or `fix/abc`.
|
|
109
|
+
|
|
110
|
+
**Commit messages** (Conventional Commits)
|
|
111
|
+
|
|
112
|
+
- `feat: add ISO-3166 alpha-3 validator`
|
|
113
|
+
- `fix: correct RFC5322 email regex edge-case`
|
|
114
|
+
- `docs: expand PII redaction examples`
|
|
115
|
+
- `refactor: simplify field builder pipeline`
|
|
116
|
+
- `test: add cases for currency code`
|
|
117
|
+
- `chore: bump dev deps`
|
|
118
|
+
|
|
119
|
+
**Pull Requests**
|
|
120
|
+
|
|
121
|
+
- Keep PRs focused and small when possible.
|
|
122
|
+
- Include tests for new/changed behaviour.
|
|
123
|
+
- Update docs (README, JSDoc, ADRs) as needed.
|
|
124
|
+
- Add a clear description of what & why, with before/after examples if useful.
|
|
125
|
+
- Ensure CI is green (lint, build, tests).
|
|
126
|
+
|
|
127
|
+
**PR checklist**
|
|
128
|
+
|
|
129
|
+
- [ ] Title uses Conventional Commits
|
|
130
|
+
- [ ] Tests added/updated
|
|
131
|
+
- [ ] Lint passes (`npm run lint`)
|
|
132
|
+
- [ ] Build passes (`npm run build`)
|
|
133
|
+
- [ ] Docs updated (README/ADR/CHANGELOG if needed)
|
|
134
|
+
- [ ] No real PII in code, tests, or logs
|
|
135
|
+
|
|
136
|
+
---
|
|
137
|
+
|
|
138
|
+
## Coding standards
|
|
139
|
+
|
|
140
|
+
- **Language:** TypeScript with `strict` types.
|
|
141
|
+
- **Style:** ESLint + Prettier.
|
|
142
|
+
- **Tests:** Prefer Vitest (or Jest) + `@testing-library/*` for React-facing bits.
|
|
143
|
+
- **Public API:** Aim for backward compatibility; use SemVer and mark breaking changes clearly (`feat!:` or `fix!:`).
|
|
144
|
+
- **Performance:** Avoid excessive allocations in hot paths; prefer immutable patterns but mind GC pressure.
|
|
145
|
+
- **Docs:** Add TSDoc comments for exported types/functions.
|
|
146
|
+
|
|
147
|
+
### Validators
|
|
148
|
+
|
|
149
|
+
- Add tests covering common/edge cases.
|
|
150
|
+
- Cite the source/standard (e.g., ISO/RFC) in comments.
|
|
151
|
+
- Keep regexes readable (use `x`/comments where possible) and benchmark if complex.
|
|
152
|
+
|
|
153
|
+
### PII handling
|
|
154
|
+
|
|
155
|
+
- Never include real PII in fixtures or examples.
|
|
156
|
+
- Ensure redaction/cleaning functions operate **before** logging.
|
|
157
|
+
- Add tests confirming no PII leaks to logs or thrown errors.
|
|
158
|
+
|
|
159
|
+
---
|
|
160
|
+
|
|
161
|
+
## Adding dependencies
|
|
162
|
+
|
|
163
|
+
- Minimise runtime dependencies; prefer dev dependencies.
|
|
164
|
+
- Justify any new runtime dependency in the PR description (size, security, maintenance).
|
|
165
|
+
- Avoid transitive heavy deps unless critical.
|
|
166
|
+
|
|
167
|
+
---
|
|
168
|
+
|
|
169
|
+
## Versioning & releases
|
|
170
|
+
|
|
171
|
+
- We follow **SemVer**.
|
|
172
|
+
- Breaking changes require a major bump and migration notes.
|
|
173
|
+
- Keep the `CHANGELOG.md` (or release notes) clear about user-facing changes.
|
|
174
|
+
|
|
175
|
+
---
|
|
176
|
+
|
|
177
|
+
## Documentation
|
|
178
|
+
|
|
179
|
+
- Update `README.md` with new features or setup steps.
|
|
180
|
+
- Add or update ADRs in `docs/adrs/` for architectural decisions.
|
|
181
|
+
- Keep examples minimal, copy-pasteable, and tested when feasible.
|
|
182
|
+
|
|
183
|
+
---
|
|
184
|
+
|
|
185
|
+
## Maintainers’ process (overview)
|
|
186
|
+
|
|
187
|
+
- Triage new issues weekly; label and assign.
|
|
188
|
+
- Review PRs for correctness, tests, and docs.
|
|
189
|
+
- Squash-merge with Conventional Commit titles.
|
|
190
|
+
- Publish from CI when applicable.
|
|
191
|
+
|
|
192
|
+
---
|
|
193
|
+
|
|
194
|
+
## Questions
|
|
195
|
+
|
|
196
|
+
If you have questions or want feedback before building:
|
|
197
|
+
|
|
198
|
+
- Open a discussion or issue with a short proposal,
|
|
199
|
+
- Or draft a PR early (mark as **Draft**) to get directional feedback.
|
|
200
|
+
|
|
201
|
+
Thanks again for contributing 💛
|
package/README.md
CHANGED
|
@@ -9,8 +9,6 @@
|
|
|
9
9
|
|
|
10
10
|
Entity definition & validation helpers for the Plasius ecosystem.
|
|
11
11
|
|
|
12
|
-
This package is part of the **Plasius LTD** selective open-source strategy. For more on our approach, see [ADR-0013: Selective Open Source](https://github.com/plasius/plasius/blob/main/docs/architecture/adr/ADR-0013-selective-open-source.md). This package is maintained as open source to foster community trust and enable integration, while the core Plasius platform remains proprietary.
|
|
13
|
-
|
|
14
12
|
Apache-2.0. ESM + CJS builds. TypeScript types included.
|
|
15
13
|
|
|
16
14
|
---
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# ADR-0001: Schema Library Purpose and Scope
|
|
2
|
+
|
|
3
|
+
## Status
|
|
4
|
+
|
|
5
|
+
- Proposed → Accepted
|
|
6
|
+
- Date: 2025-09-12
|
|
7
|
+
- Version: 1.0
|
|
8
|
+
- Supersedes: N/A
|
|
9
|
+
- Superseded by: N/A
|
|
10
|
+
|
|
11
|
+
## Context
|
|
12
|
+
|
|
13
|
+
Managing consistent data structures across a distributed system is difficult. Without a central schema library, each service or package can diverge in how it defines and validates entities, leading to duplication, mismatches, and security gaps (especially around handling Personally Identifiable Information, or PII).
|
|
14
|
+
|
|
15
|
+
We need a way to:
|
|
16
|
+
|
|
17
|
+
- Define entities and fields in a consistent, strongly-typed way.
|
|
18
|
+
- Provide validation functions for standard data types and codes (ISO, RFC, OWASP, etc).
|
|
19
|
+
- Support annotation of PII fields so they can be masked or cleaned when logged or transmitted.
|
|
20
|
+
- Offer a foundation that other Plasius packages (e.g. entity-types, state, renderer) can depend upon.
|
|
21
|
+
|
|
22
|
+
## Decision
|
|
23
|
+
|
|
24
|
+
We will build a **schema library** (`@plasius/schema`) that:
|
|
25
|
+
|
|
26
|
+
- Provides a fluent builder API (`field().string().required()` etc.).
|
|
27
|
+
- Exposes reusable validators for standards like ISO-3166 country codes, ISO-4217 currency codes, RFC 5322 emails, etc.
|
|
28
|
+
- Implements utilities for PII handling (masking, redaction).
|
|
29
|
+
- Exports TypeScript types that infer entity structures from schema definitions.
|
|
30
|
+
- Is published as an open source package for transparency and reuse.
|
|
31
|
+
|
|
32
|
+
## Consequences
|
|
33
|
+
|
|
34
|
+
- **Positive:** Consistent validation, stronger typing, centralised handling of PII, reduced duplication across Plasius projects, easier onboarding of new developers.
|
|
35
|
+
- **Negative:** Adds a dependency layer that all other packages must import, requiring careful versioning and backward compatibility management.
|
|
36
|
+
- **Neutral:** External adopters may use the library without adopting the full Plasius ecosystem, which is acceptable and encouraged.
|
|
37
|
+
|
|
38
|
+
## Alternatives Considered
|
|
39
|
+
|
|
40
|
+
- **Do nothing:** Continue defining ad-hoc validation in each package. (Rejected: inconsistent and unsafe.)
|
|
41
|
+
- **Use an existing library (e.g. Zod, Yup, Joi):** These provide schema validation but lack PII auditing integration and may not align with our field-builder pattern. (Rejected for core use, though we may draw inspiration.)
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
# Architectural Decision Record (ADR)
|
|
2
|
+
|
|
3
|
+
## Title
|
|
4
|
+
|
|
5
|
+
> _Concise, descriptive title of the decision (e.g., “Use Azure Container Apps for n8n Deployment”)_
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## Status
|
|
10
|
+
|
|
11
|
+
- Proposed | Accepted | Rejected | Superseded | Deprecated
|
|
12
|
+
- Date: YYYY-MM-DD
|
|
13
|
+
- Version: 1.0
|
|
14
|
+
- Supersedes: ADR-XXXX (if applicable)
|
|
15
|
+
- Superseded by: ADR-YYYY (if applicable)
|
|
16
|
+
|
|
17
|
+
---
|
|
18
|
+
|
|
19
|
+
## Tags
|
|
20
|
+
|
|
21
|
+
> _Short keywords to help search and group ADRs (e.g., infra, frontend, security, devops, ai, database)._
|
|
22
|
+
|
|
23
|
+
---
|
|
24
|
+
|
|
25
|
+
## Context
|
|
26
|
+
|
|
27
|
+
> _Describe the problem we are solving, relevant background, and constraints.
|
|
28
|
+
> Why are we making this decision? What triggered it?_
|
|
29
|
+
|
|
30
|
+
---
|
|
31
|
+
|
|
32
|
+
## Decision
|
|
33
|
+
|
|
34
|
+
> _What is the decision we have made? Clear, affirmative statement of the chosen path._
|
|
35
|
+
|
|
36
|
+
---
|
|
37
|
+
|
|
38
|
+
## Alternatives Considered
|
|
39
|
+
|
|
40
|
+
- **Option A**: Description (pros/cons)
|
|
41
|
+
- **Option B**: Description (pros/cons)
|
|
42
|
+
- **Option C**: Description (pros/cons)
|
|
43
|
+
|
|
44
|
+
> _Why were these alternatives not chosen?_
|
|
45
|
+
|
|
46
|
+
---
|
|
47
|
+
|
|
48
|
+
## Consequences
|
|
49
|
+
|
|
50
|
+
- Positive outcomes (benefits, opportunities)
|
|
51
|
+
- Negative outcomes (risks, trade-offs)
|
|
52
|
+
- Any technical debt created or avoided
|
|
53
|
+
- Impact on future decisions
|
|
54
|
+
|
|
55
|
+
---
|
|
56
|
+
|
|
57
|
+
## Related Decisions
|
|
58
|
+
|
|
59
|
+
> _Link to related ADRs (if any)_
|
|
60
|
+
|
|
61
|
+
---
|
|
62
|
+
|
|
63
|
+
## References
|
|
64
|
+
|
|
65
|
+
> _Links to docs, benchmarks, discussions, or external resources that influenced this decision_
|
package/legal/CORPORATE_CLA.md
CHANGED
|
@@ -33,6 +33,8 @@ This Agreement is effective upon signature by the authorized representative of t
|
|
|
33
33
|
|
|
34
34
|
---
|
|
35
35
|
|
|
36
|
+
### **@plasius/schema**
|
|
37
|
+
|
|
36
38
|
**Corporation Legal Name:** \_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_
|
|
37
39
|
|
|
38
40
|
**Authorized Representative:** \_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_
|
package/legal/INDIVIDUAL_CLA.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Individual Contributor License Agreement (CLA)
|
|
2
2
|
|
|
3
|
-
**Project:**
|
|
3
|
+
**Project:** @plasius/schema (Plasius LTD)
|
|
4
4
|
**Version:** 1.0 — 2025‑09‑12
|
|
5
5
|
**Contact:** [contributors@plasius.co.uk](mailto:contributors@plasius.co.uk)
|
|
6
6
|
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
|
|
11
11
|
- **"You"** (or **"Contributor"**) means the individual signing this CLA and submitting Contributions to the Project.
|
|
12
12
|
- **"Contribution"** means any original work of authorship, including code, documentation, data, designs, or feedback that You submit to the Project in any form (e.g., pull request, issue comment, email, file upload).
|
|
13
|
-
- **"Project"** means the
|
|
13
|
+
- **"Project"** means the @plasius/schema repositories and related materials owned or managed by **Plasius LTD**.
|
|
14
14
|
|
|
15
15
|
## 2. Copyright License Grant
|
|
16
16
|
|