@plasius/react-state 1.0.1 → 1.0.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.
@@ -0,0 +1,201 @@
1
+ # Contributing to @plasius/react-state
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/react-state` 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
@@ -1,20 +1,20 @@
1
1
  # @plasius/react-store
2
2
 
3
- [![npm version](https://img.shields.io/npm/v/@plasius/react-store.svg)](https://www.npmjs.com/package/@plasius/react-store)
4
- [![Build Status](https://img.shields.io/github/actions/workflow/status/Plasius-LTD/react-store/ci.yml?branch=main&label=build&style=flat)](https://github.com/plasius/react-store/actions/workflows/ci.yml)
5
- [![License](https://img.shields.io/github/license/Plasius-LTD/react-store)](./LICENSE)
3
+ [![npm version](https://img.shields.io/npm/v/@plasius/react-state.svg)](https://www.npmjs.com/package/@plasius/react-state)
4
+ [![Build Status](https://img.shields.io/github/actions/workflow/status/Plasius-LTD/react-state/ci.yml?branch=main&label=build&style=flat)](https://github.com/plasius/react-state/actions/workflows/ci.yml)
5
+ [![License](https://img.shields.io/github/license/Plasius-LTD/react-state)](./LICENSE)
6
6
  [![Code of Conduct](https://img.shields.io/badge/code%20of%20conduct-yes-blue.svg)](./CODE_OF_CONDUCT.md)
7
7
  [![Security Policy](https://img.shields.io/badge/security%20policy-yes-orange.svg)](./SECURITY.md)
8
8
  [![Changelog](https://img.shields.io/badge/changelog-md-blue.svg)](./CHANGELOG.md)
9
9
 
10
10
  ## Overview
11
11
 
12
- `@plasius/react-store` provides a scoped state management solution for React applications. It allows developers to create isolated, testable, and composable stores without introducing heavy dependencies.
12
+ `@plasius/react-state` provides a scoped state management solution for React applications. It allows developers to create isolated, testable, and composable stores without introducing heavy dependencies.
13
13
 
14
14
  ## Installation
15
15
 
16
16
  ```bash
17
- npm install @plasius/react-store
17
+ npm install @plasius/react-state
18
18
  ```
19
19
 
20
20
  ## Usage Example
@@ -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_
@@ -0,0 +1,2 @@
1
+ type,github_handle,full_name,company,email,date,approver
2
+ corporate,Zephod111r,Phillip Hounslow,Plasius LTD,zephod@plasius.co.uk,2025-09-12,Phillip Hounslow (Maintainer)
package/legal/CLA.md ADDED
@@ -0,0 +1,22 @@
1
+ # Contributor License Agreements (CLA)
2
+
3
+ To protect the intellectual property of this project and ensure clarity of rights, all contributors must sign a Contributor License Agreement (CLA) before their first contribution.
4
+
5
+ ## Which CLA should I sign?
6
+
7
+ - **Individual CLA**: If you are contributing personally and not on behalf of an employer, sign the [Individual CLA](INDIVIDUAL_CLA.md).
8
+ - **Corporate CLA**: If you are contributing as part of your work for a company, the company should sign the [Corporate CLA](CORPORATE_CLA.md).
9
+
10
+ ## How to sign
11
+
12
+ 1. Download the appropriate CLA file (Individual or Corporate).
13
+ 2. Fill in the required details, sign, and date it.
14
+ 3. Email a PDF copy of the signed document to **[contributors@plasius.co.uk](mailto:contributors@plasius.co.uk)** with subject: `CLA – Individual` or `CLA – Corporate`.
15
+
16
+ ## Registry
17
+
18
+ All signed CLAs are logged internally in the CLA registry (`CLA-REGISTRY.csv`).
19
+
20
+ ## Questions?
21
+
22
+ If you have any questions about which CLA to sign or how the process works, please email **[contributors@plasius.co.uk](mailtocontributors@plasius.co.uk)**.
@@ -0,0 +1,57 @@
1
+ # Corporate Contributor License Agreement (CLA)
2
+
3
+ ## Purpose
4
+
5
+ This Corporate Contributor License Agreement ("Agreement") is intended to protect the intellectual property rights of the contributors and the project, ensure clear licensing terms for contributions, and maintain trust within the community. By signing this Agreement, the corporation agrees to the terms that facilitate the use, distribution, and modification of contributions under the project's licensing framework.
6
+
7
+ ## Agreement
8
+
9
+ 1. **Representation of Authority**
10
+ The undersigned individual represents and warrants that they have the full legal authority to enter into this Agreement on behalf of the corporation named below ("Corporation") and to grant the rights contained herein.
11
+
12
+ 2. **Grant of Copyright License**
13
+ The Corporation hereby grants to the project maintainers and users a perpetual, worldwide, non-exclusive, royalty-free, irrevocable copyright license to use, reproduce, prepare derivative works of, publicly display, publicly perform, sublicense, and distribute the contributions submitted to the project.
14
+
15
+ 3. **Grant of Patent License**
16
+ The Corporation hereby grants to the project maintainers and users a perpetual, worldwide, non-exclusive, royalty-free, irrevocable license under any patent claims that are necessarily infringed by the contributions to make, use, sell, offer for sale, import, and otherwise dispose of the contributions or derivative works thereof.
17
+
18
+ 4. **Warranties and Representations**
19
+ The Corporation represents and warrants that:
20
+
21
+ - The contributions are the original work of the Corporation or that the Corporation has sufficient rights to grant the licenses herein.
22
+ - The submission of the contributions does not violate any agreements or rights of third parties.
23
+
24
+ 5. **No Revocation**
25
+ This license is granted on a perpetual basis and cannot be revoked, provided that the terms of this Agreement are met.
26
+
27
+ 6. **Governing Law**
28
+ This Agreement shall be governed by and construed in accordance with the laws of the United Kingdom, without regard to its conflict of laws principles.
29
+
30
+ 7. **Execution**
31
+
32
+ This Agreement is effective upon signature by the authorized representative of the Corporation. Please sign and date this document, then email a scanned PDF copy to [contributors@plasius.co.uk](mailto:contributors@plasius.co.uk).
33
+
34
+ ---
35
+
36
+ **@plasius/react-state**
37
+
38
+ **Corporation Legal Name:** \_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_
39
+
40
+ **Authorized Representative:** \_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_
41
+
42
+ **Title:** \_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_
43
+
44
+ **Email:** \_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_
45
+
46
+ **Date:** \_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_
47
+
48
+ **Signature:** \_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_
49
+
50
+ ---
51
+
52
+ ## How to Sign
53
+
54
+ - Download this file as a template.
55
+ - Fill in the Corporation’s legal name, authorized representative, title, email, date, and provide a signature.
56
+ - Sign and date the document.
57
+ - Send a scanned copy of the signed Agreement to [contributors@plasius.co.uk](mailto:contributors@plasius.co.uk).
@@ -0,0 +1,91 @@
1
+ # Individual Contributor License Agreement (CLA)
2
+
3
+ **Project:** @plasius/react-state (Plasius LTD)
4
+ **Version:** 1.0 — 2025‑09‑12
5
+ **Contact:** [contributors@plasius.co.uk](mailto:contributors@plasius.co.uk)
6
+
7
+ ---
8
+
9
+ ## 1. Definitions
10
+
11
+ - **"You"** (or **"Contributor"**) means the individual signing this CLA and submitting Contributions to the Project.
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 Intuitive Purchases repositories and related materials owned or managed by **Plasius LTD**.
14
+
15
+ ## 2. Copyright License Grant
16
+
17
+ You hereby grant to Plasius LTD a **perpetual, worldwide, non‑exclusive, transferable, sublicensable, royalty‑free, irrevocable** copyright license to:
18
+
19
+ - use, reproduce, publicly display, publicly perform, modify, create derivative works of, and
20
+ - distribute Contributions in source and object form,
21
+ - and to **sublicense** these rights under any terms Plasius LTD chooses, including proprietary or open‑source licenses.
22
+
23
+ ## 3. Patent License Grant
24
+
25
+ You hereby grant to Plasius LTD and its sublicensees a **perpetual, worldwide, non‑exclusive, transferable, royalty‑free, irrevocable** patent license to **make, have made, use, offer to sell, sell, import, and otherwise transfer** the Contribution and derivative works thereof, where such license applies only to patent claims that You **own or control** and that would be infringed by Your Contribution or its combination with the Project.
26
+
27
+ ## 4. Moral Rights & Attribution
28
+
29
+ To the maximum extent permitted by applicable law, You **waive** and agree not to assert any moral rights (e.g., rights of attribution or integrity) in or to the Contribution against Plasius LTD. Plasius LTD may, but is not required to, credit You.
30
+
31
+ ## 5. Representations & Warranties
32
+
33
+ You represent that:
34
+
35
+ 1. **Originality / Rights:** Each Contribution is Your original creation, or You have sufficient rights to submit it and grant the licenses above.
36
+ 2. **No Confidential Info:** Contributions **do not** include confidential information or trade secrets of any third party.
37
+ 3. **No Infringement:** To the best of Your knowledge, Contributions do not infringe any third‑party IP rights.
38
+ 4. **Employment / Contractor Status:** If Your employer or a third party might claim rights in Your Contribution, You have obtained **written permission** to make the Contribution and grant these licenses (attach or reference below), or Your Contribution is made **outside the scope** of your employment and without using your employer’s confidential information or resources.
39
+ 5. **Compliance:** You will follow the Project’s policies (e.g., Code of Conduct, Security Policy) and applicable laws.
40
+
41
+ ## 6. Third‑Party Code
42
+
43
+ If Your Contribution includes code, data, or other material from a third party, You will **identify the material and its license** in the pull request or submission, and ensure it is **compatible** with the Project’s licensing model. You will not submit material subject to terms that require the Project to disclose proprietary source code (e.g., certain copyleft obligations) unless the Project has **pre‑approved** such inclusion in writing.
44
+
45
+ ## 7. Scope & Duration
46
+
47
+ - This CLA covers **all past and future** Contributions You submit to the Project, unless and until You provide written notice to **revoke** it.
48
+ - Revocation is **not retroactive**: rights granted for prior Contributions remain in effect.
49
+
50
+ ## 8. Disclaimer
51
+
52
+ THE CONTRIBUTION IS PROVIDED “AS IS” WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON‑INFRINGEMENT.
53
+
54
+ ## 9. Governing Law & Jurisdiction
55
+
56
+ This CLA is governed by the **laws of England and Wales**, and the courts of England and Wales shall have **exclusive jurisdiction** over any dispute arising out of or relating to it.
57
+
58
+ ## 10. Entire Agreement
59
+
60
+ This CLA is the entire agreement between You and Plasius LTD regarding Contributions. It supersedes any prior discussions relating to Contributions. If any provision is held unenforceable, the remaining provisions remain in full force.
61
+
62
+ ---
63
+
64
+ ## 11. Contributor Information & Signature
65
+
66
+ By signing below, You agree to the terms of this CLA for Your Contributions to the Project.
67
+
68
+ **Full Name:** \_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_
69
+
70
+ **Email:** \_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_
71
+
72
+ **GitHub Handle:** \_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_
73
+
74
+ **Address (optional):** \_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_
75
+
76
+ **Employer (if applicable):** \_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_
77
+
78
+ **If employed:** ☐ I confirm Contributions are made outside the scope of employment **or** ☐ I have attached my employer’s written permission.
79
+
80
+ **Signature:** \_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_
81
+
82
+ **Date (YYYY‑MM‑DD):** \_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_
83
+
84
+ _Electronic signatures are accepted. You may type your name in the Signature field and email a PDF copy._
85
+
86
+ **Submission:** Please email the signed CLA to **[contributors@plasius.co.uk](mailto:contributors@plasius.co.uk)** with subject line: `CLA – Individual – <GitHubHandle>`.
87
+
88
+ **(Optional) Attachments / Notes:**
89
+
90
+ - Employer permission letter (if required)
91
+ - Third‑party license disclosures (if any)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plasius/react-state",
3
- "version": "1.0.1",
3
+ "version": "1.0.2",
4
4
  "description": "Tiny, testable, typesafe React Scoped Store helper.",
5
5
  "keywords": [
6
6
  "react",