@stackbilt/core 0.1.1 → 0.1.3

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.
Files changed (2) hide show
  1. package/README.md +86 -0
  2. package/package.json +1 -1
package/README.md ADDED
@@ -0,0 +1,86 @@
1
+ # @stackbilt/core
2
+
3
+ Zod schemas and sanitization helpers for [Charter Kit](https://github.com/Stackbilt-dev/charter) -- a local-first governance toolkit for software repos.
4
+
5
+ > **Want the full toolkit?** Just install the CLI — it includes everything:
6
+ > ```bash
7
+ > npm install -g @stackbilt/cli
8
+ > ```
9
+ > Only install this package directly if you need schemas and sanitizers without the CLI.
10
+
11
+ ## Install
12
+
13
+ ```bash
14
+ npm install @stackbilt/core
15
+ ```
16
+
17
+ Requires Node >= 18. The only runtime dependency is [zod](https://github.com/colinhacks/zod).
18
+
19
+ ## Usage
20
+
21
+ ### Sanitize user input
22
+
23
+ ```ts
24
+ import { sanitizeInput } from '@stackbilt/core';
25
+
26
+ const clean = sanitizeInput(rawUserInput);
27
+ ```
28
+
29
+ ### Safe error messages
30
+
31
+ `sanitizeErrorMessage` maps known error patterns (database, network, auth) to user-friendly messages and returns a generic fallback for anything unrecognized. Internal details are never exposed to callers.
32
+
33
+ ```ts
34
+ import { sanitizeErrorMessage } from '@stackbilt/core';
35
+
36
+ try {
37
+ await riskyOperation();
38
+ } catch (err) {
39
+ const message = sanitizeErrorMessage(err);
40
+ // "Database constraint violated", "Network error - please retry", etc.
41
+ }
42
+ ```
43
+
44
+ ### Validate governance data with Zod schemas
45
+
46
+ ```ts
47
+ import { CreateLedgerEntrySchema, CreatePatternSchema } from '@stackbilt/core';
48
+
49
+ const result = CreateLedgerEntrySchema.safeParse(payload);
50
+ if (!result.success) {
51
+ console.error(result.error.issues);
52
+ }
53
+ ```
54
+
55
+ ## API Reference
56
+
57
+ ### Functions
58
+
59
+ | Export | Signature | Description |
60
+ |---|---|---|
61
+ | `sanitizeInput` | `(input: string) => string` | Strip control characters and enforce length limit |
62
+ | `sanitizeErrorMessage` | `(error: unknown) => string` | Return a safe, user-facing error message |
63
+
64
+ ### Schemas
65
+
66
+ | Schema | Purpose |
67
+ |---|---|
68
+ | `CreateLedgerEntrySchema` | Validate new ledger entries (rulings, ADRs, policies, notary stamps) |
69
+ | `UpdateLedgerStatusSchema` | Validate status transitions (`ACTIVE`, `SUPERSEDED`, `ARCHIVED`) |
70
+ | `CreatePatternSchema` | Validate new blessed-stack patterns |
71
+ | `UpdatePatternSchema` | Validate pattern updates |
72
+ | `CreateProtocolSchema` | Validate governance protocols |
73
+ | `CreateGovernanceRequestSchema` | Validate governance requests |
74
+ | `ResolveGovernanceRequestSchema` | Validate request resolutions |
75
+ | `CreateProjectSchema` | Validate new project definitions |
76
+
77
+ Each schema also exports an inferred TypeScript type (e.g., `CreateLedgerEntryRequest`, `CreatePatternRequest`).
78
+
79
+ ## License
80
+
81
+ Apache-2.0
82
+
83
+ ## Links
84
+
85
+ - [Repository](https://github.com/Stackbilt-dev/charter)
86
+ - [Issues](https://github.com/Stackbilt-dev/charter/issues)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stackbilt/core",
3
- "version": "0.1.1",
3
+ "version": "0.1.3",
4
4
  "description": "Core schemas, sanitization, and error handling for Charter Kit",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",