@agentuity/schema 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.
Files changed (2) hide show
  1. package/AGENTS.md +84 -30
  2. package/package.json +3 -3
package/AGENTS.md CHANGED
@@ -21,36 +21,92 @@ Lightweight schema validation library with StandardSchema v1 support. Provides t
21
21
 
22
22
  ```text
23
23
  src/
24
- ├── index.ts # Main entry point, exports all schemas
25
- ├── base.ts # Base schema class and types
24
+ ├── index.ts # Main entry point, exports all schemas and `s` builder
25
+ ├── base.ts # Base schema class, types (Schema, Infer, ValidationError)
26
+ ├── json-schema.ts # toJSONSchema, fromJSONSchema conversion utilities
26
27
  ├── primitives/ # Primitive type schemas
27
- │ ├── string.ts
28
- │ ├── number.ts
29
- │ ├── boolean.ts
30
- │ ├── null.ts
31
- └── undefined.ts
28
+ │ ├── string.ts # StringSchema, string()
29
+ │ ├── number.ts # NumberSchema, number()
30
+ │ ├── boolean.ts # BooleanSchema, boolean()
31
+ │ ├── null.ts # NullSchema, null_()
32
+ ├── undefined.ts # UndefinedSchema, undefined_()
33
+ │ ├── unknown.ts # UnknownSchema, unknown()
34
+ │ └── any.ts # AnySchema, any()
32
35
  ├── complex/ # Complex type schemas
33
- │ ├── object.ts
34
- └── array.ts
36
+ │ ├── object.ts # ObjectSchema, object()
37
+ ├── array.ts # ArraySchema, array()
38
+ │ └── record.ts # RecordSchema, record()
35
39
  ├── utils/ # Utility schemas
36
- │ ├── optional.ts
37
- │ ├── nullable.ts
38
- │ ├── union.ts
39
- │ └── literal.ts
40
- ├── coerce/ # Type coercion schemas
41
- ├── string.ts
42
- ├── number.ts
43
- ├── boolean.ts
44
- └── date.ts
45
- ├── json-schema.ts # JSON Schema conversion utilities
46
- └── __tests__/ # Bun unit tests
47
- ├── primitives.test.ts
48
- ├── complex.test.ts
49
- ├── utils.test.ts
50
- ├── coerce.test.ts
51
- ├── type-inference.test.ts
52
- ├── json-schema.test.ts
53
- └── errors.test.ts
40
+ │ ├── optional.ts # OptionalSchema, optional()
41
+ │ ├── nullable.ts # NullableSchema, nullable()
42
+ │ ├── union.ts # UnionSchema, union()
43
+ │ └── literal.ts # LiteralSchema, literal()
44
+ └── coerce/ # Type coercion schemas
45
+ ├── string.ts # CoerceStringSchema, coerceString()
46
+ ├── number.ts # CoerceNumberSchema, coerceNumber()
47
+ ├── boolean.ts # CoerceBooleanSchema, coerceBoolean()
48
+ └── date.ts # CoerceDateSchema, coerceDate()
49
+ ```
50
+
51
+ ## Key Exports
52
+
53
+ ### Schema Builder (`s`)
54
+
55
+ ```typescript
56
+ import { s } from '@agentuity/schema';
57
+
58
+ // Define schemas
59
+ const UserSchema = s.object({
60
+ name: s.string(),
61
+ age: s.number(),
62
+ role: s.enum(['admin', 'user', 'guest']),
63
+ email: s.optional(s.string()),
64
+ });
65
+
66
+ // Extract TypeScript type from schema
67
+ type User = s.infer<typeof UserSchema>;
68
+
69
+ // Parse/validate data
70
+ const user = UserSchema.parse(data); // throws on invalid
71
+ const result = UserSchema.safeParse(data); // returns { success, data/issues }
72
+ ```
73
+
74
+ **Note on `s.enum`:** Implemented as `enumSchema()` in `index.ts`, it's a thin wrapper around `union()` and `literal()`. Example: `s.enum(['a', 'b'])` is equivalent to `s.union(s.literal('a'), s.literal('b'))`.
75
+
76
+ ### Individual Schema Exports
77
+
78
+ ```typescript
79
+ import {
80
+ // Primitives
81
+ string,
82
+ number,
83
+ boolean,
84
+ null_,
85
+ undefined_,
86
+ unknown,
87
+ any,
88
+ // Complex
89
+ object,
90
+ array,
91
+ record,
92
+ // Utils
93
+ literal,
94
+ optional,
95
+ nullable,
96
+ union,
97
+ // Coercion
98
+ coerceString,
99
+ coerceNumber,
100
+ coerceBoolean,
101
+ coerceDate,
102
+ // JSON Schema
103
+ toJSONSchema,
104
+ fromJSONSchema,
105
+ // Types
106
+ type Schema,
107
+ type Infer,
108
+ type ValidationError,
109
+ } from '@agentuity/schema';
54
110
  ```
55
111
 
56
112
  ## Code Style
@@ -67,15 +123,13 @@ src/
67
123
  - Use `'~standard'` property for StandardSchema interface
68
124
  - Export main builder as `s` (e.g., `s.string()`, `s.object()`)
69
125
  - Error messages should be clear and actionable
70
- - Support type inference via `Infer<T>` utility type
126
+ - Support type inference via `s.infer<T>` utility type
71
127
 
72
128
  ## Testing
73
129
 
74
130
  - **Test Framework**: Bun's built-in test runner
75
- - **Test Count**: 72 tests across 7 test files
76
131
  - **Command**: `bun test` (run from package directory)
77
132
  - **Coverage**: Primitives, complex types, utilities, coercion, type inference, JSON Schema, error handling
78
- - **CI**: Tests run automatically on PR builds
79
133
  - All tests must pass before merging
80
134
  - When running tests, prefer using a subagent (Task tool) to avoid context bloat from test output
81
135
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agentuity/schema",
3
- "version": "1.0.1",
3
+ "version": "1.0.2",
4
4
  "license": "Apache-2.0",
5
5
  "author": "Agentuity employees and contributors",
6
6
  "type": "module",
@@ -26,10 +26,10 @@
26
26
  "prepublishOnly": "bun run clean && bun run build"
27
27
  },
28
28
  "dependencies": {
29
- "@agentuity/core": "1.0.1"
29
+ "@agentuity/core": "1.0.2"
30
30
  },
31
31
  "devDependencies": {
32
- "@agentuity/test-utils": "1.0.1",
32
+ "@agentuity/test-utils": "1.0.2",
33
33
  "@types/bun": "latest",
34
34
  "bun-types": "latest",
35
35
  "typescript": "^5.9.0"