Skip to content

Commit 6e73995

Browse files
authored
chore: prepare for 1.0 release (docs overhaul + remove deprecated APIs) (#119)
1 parent 9819869 commit 6e73995

34 files changed

Lines changed: 808 additions & 896 deletions

README.md

Lines changed: 86 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -5,31 +5,31 @@
55
[![pub package](https://img.shields.io/pub/v/ack.svg)](https://pub.dev/packages/ack)
66
[![llms.txt](https://img.shields.io/badge/llms.txt-available-8A2BE2)](https://docs.page/btwld/ack/llms.txt)
77

8-
Ack is a schema validation library for Dart and Flutter that helps you validate data with a simple, fluent API. Ack is short for "acknowledge".
8+
Ack is a schema validation library for Dart and Flutter. It validates data with a fluent API. Ack is short for "acknowledge".
99

1010
For AI agents: start at [`/llms.txt`](https://docs.page/btwld/ack/llms.txt).
1111

12-
## Why Use Ack?
12+
## Why use Ack?
1313

14-
- **Simplify Validation**: Easily handle complex data validation logic
15-
- **Validate external payloads**: Guard API and user inputs by validating
16-
required fields, types, and constraints at boundaries
17-
- **Single Source of Truth**: Define data structures and rules in one place
18-
- **Reduce Boilerplate**: Minimize repetitive code for validation and JSON conversion
19-
- **Type Safety**: Generate typed wrappers for hand-written Ack schemas with `@AckType()`
14+
- **Validate external payloads**: Guard API and user inputs by validating required fields, types, and constraints at boundaries
15+
- **Single source of truth**: Define data structures and rules in one place
16+
- **Less boilerplate**: Minimize repetitive validation and JSON conversion code
17+
- **Type safety**: Generate typed wrappers for hand-written Ack schemas with `@AckType()`
2018

2119
## Packages
2220

2321
This repository is a monorepo containing:
2422

25-
- **[ack](./packages/ack)**: Core validation library with fluent schema building API
26-
- **[ack_generator](./packages/ack_generator)**: Code generator for `@AckType()` extension-type wrappers
27-
- **[ack_firebase_ai](./packages/ack_firebase_ai)**: Firebase AI (Gemini) schema converter for structured output generation
23+
- **[ack](./packages/ack)**: Core validation library with a fluent schema-building API, codecs, and JSON Schema export
24+
- **[ack_annotations](./packages/ack_annotations)**: The `@AckType()` annotation that marks schemas for code generation
25+
- **[ack_generator](./packages/ack_generator)**: Code generator that turns `@AckType()` schemas into type-safe extension types
26+
- **[ack_firebase_ai](./packages/ack_firebase_ai)**: Firebase AI (Gemini) schema converter for structured-output generation
27+
- **[ack_json_schema_builder](./packages/ack_json_schema_builder)**: Converter to `json_schema_builder` schemas
2828
- **[example](./example)**: Example projects demonstrating usage of all packages
2929

30-
## Quick Start
30+
## Quick start
3131

32-
### Core Library (ack)
32+
### Core library (ack)
3333

3434
Add Ack to your project:
3535

@@ -42,21 +42,18 @@ Define and use a schema:
4242
```dart
4343
import 'package:ack/ack.dart';
4444
45-
// Define a schema for a user object
4645
final userSchema = Ack.object({
4746
'name': Ack.string().minLength(2).maxLength(50),
4847
'email': Ack.string().email(),
4948
'age': Ack.integer().min(0).max(120).optional(),
5049
});
5150
52-
// Validate data against the schema
5351
final result = userSchema.safeParse({
5452
'name': 'John Doe',
5553
'email': 'john@example.com',
5654
'age': 30
5755
});
5856
59-
// Check if validation passed
6057
if (result.isOk) {
6158
final validData = result.getOrThrow();
6259
print('Valid user: $validData');
@@ -68,9 +65,9 @@ if (result.isOk) {
6865

6966
Use `.optional()` when a field may be omitted entirely. Chain `.nullable()` if a present field may hold `null`, or combine both for an optional-and-nullable value.
7067

71-
### Advanced Usage
68+
### Advanced usage
7269

73-
For more complex validation scenarios:
70+
For complex validation:
7471

7572
```dart
7673
import 'package:ack/ack.dart';
@@ -114,11 +111,71 @@ if (result.isOk) {
114111
}
115112
```
116113

114+
## Code generation
115+
116+
Generate type-safe wrappers for hand-written schemas with `@AckType()`. Add
117+
`ack_annotations` to `dependencies` and `ack_generator` + `build_runner` to
118+
`dev_dependencies`, then annotate a top-level schema:
119+
120+
```dart
121+
import 'package:ack/ack.dart';
122+
import 'package:ack_annotations/ack_annotations.dart';
123+
124+
part 'user.g.dart';
125+
126+
@AckType()
127+
final userSchema = Ack.object({
128+
'name': Ack.string().minLength(2),
129+
'email': Ack.string().email(),
130+
});
131+
```
132+
133+
Run the generator:
134+
135+
```bash
136+
dart run build_runner build --delete-conflicting-outputs
137+
```
138+
139+
This emits a `UserType` extension type with `parse`/`safeParse` and typed
140+
getters — no manual casting:
141+
142+
```dart
143+
final user = UserType.parse({'name': 'Alice', 'email': 'alice@example.com'});
144+
print(user.name); // typed String getter
145+
```
146+
147+
`@AckType()` supports objects, primitives, lists, enums, explicit transforms, and discriminated unions. See the [TypeSafe Schemas guide](https://docs.page/btwld/ack/core-concepts/typesafe-schemas).
148+
149+
## Codecs
150+
151+
Codecs decode boundary values (the JSON you receive) into rich Dart runtime types and encode them back. Ack ships built-in codecs and lets you define your own:
152+
153+
```dart
154+
// Built-in codec: ISO 8601 String boundary <-> UTC DateTime runtime
155+
final when = Ack.datetime();
156+
final dt = when.parse('2026-01-01T00:00:00Z'); // DateTime
157+
final iso = when.encode(dt); // back to an ISO 8601 String
158+
159+
// Other built-ins: Ack.date(), Ack.uri(), Ack.duration(), Ack.enumCodec(...)
160+
161+
// Custom bidirectional codec
162+
final csv = Ack.codec<String, String, List<String>>(
163+
input: Ack.string(),
164+
decode: (s) => s.split(','),
165+
encode: (list) => list.join(','),
166+
);
167+
168+
csv.parse('a,b,c'); // ['a', 'b', 'c']
169+
csv.encode(['a', 'b', 'c']); // 'a,b,c'
170+
```
171+
172+
Use `.transform<R>(...)` for one-way (parse-only) conversions. See the
173+
[Codecs guide](https://docs.page/btwld/ack/core-concepts/codecs).
174+
117175
## Documentation
118176

119-
Documentation endpoints:
120177
- Human docs: [docs.page/btwld/ack](https://docs.page/btwld/ack)
121-
- AI agent index (stable URL): [docs.page/btwld/ack/llms.txt](https://docs.page/btwld/ack/llms.txt)
178+
- AI agent index: [docs.page/btwld/ack/llms.txt](https://docs.page/btwld/ack/llms.txt)
122179
- Canonical plaintext source: [raw.githubusercontent.com/btwld/ack/main/llms.txt](https://raw.githubusercontent.com/btwld/ack/main/llms.txt)
123180

124181
## Development
@@ -135,7 +192,7 @@ dart pub global activate melos
135192
melos bootstrap
136193
```
137194

138-
### Common Commands (run from root)
195+
### Common commands (run from root)
139196

140197
```bash
141198
# Run tests across all packages
@@ -166,35 +223,32 @@ melos version
166223
melos run publish
167224
```
168225

169-
### Development Tools
170-
171-
The project includes additional development tools for maintainers:
226+
### Development tools
172227

173228
```bash
174-
# JSON Schema validation (ensures compatibility with JSON Schema Draft-7)
229+
# JSON Schema validation (JSON Schema Draft-7 compatibility)
175230
melos validate-jsonschema
176231

177-
# API compatibility checking using Dart script (for semantic versioning)
232+
# API compatibility check (for semantic versioning)
178233
melos api-check v0.2.0
179234

180235
# See all available scripts
181236
melos list-scripts
182237
```
183238

184-
> **Note**: Additional development documentation is available in the `tools/` directory for project maintainers.
239+
Additional development documentation is available in the `tools/` directory.
185240

186-
## Versioning and Publishing
241+
## Versioning and publishing
187242

188-
This project uses GitHub Releases to manage versioning and publishing. For detailed instructions on how to create releases and publish packages, see [PUBLISHING.md](./PUBLISHING.md).
243+
This project uses GitHub Releases to manage versioning and publishing. See [PUBLISHING.md](./PUBLISHING.md) for instructions.
189244

190245
## Contributing
191246

192-
Contributions are welcome! A detailed CONTRIBUTING.md file will be added soon with specific guidelines.
247+
Contributions are welcome. Follow these steps:
193248

194-
In the meantime, please follow these basic steps:
195249
1. Fork the repository
196250
2. Create a feature branch
197251
3. Add your changes
198252
4. Run tests with `melos test`
199-
5. Make sure to follow [Conventional Commits](https://www.conventionalcommits.org/) in your commit messages
253+
5. Follow [Conventional Commits](https://www.conventionalcommits.org/) in your commit messages
200254
6. Submit a pull request

docs.json

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -31,34 +31,41 @@
3131
]
3232
},
3333
{
34-
"group": "Core Concepts",
34+
"group": "Essentials",
3535
"pages": [
3636
{ "title": "Schema Types", "href": "/core-concepts/schemas" },
3737
{ "title": "Validation Rules", "href": "/core-concepts/validation" },
38-
{
39-
"title": "TypeSafe Schemas",
40-
"href": "/core-concepts/typesafe-schemas"
41-
},
4238
{ "title": "Error Handling", "href": "/core-concepts/error-handling" },
4339
{
4440
"title": "JSON Serialization",
4541
"href": "/core-concepts/json-serialization"
42+
}
43+
]
44+
},
45+
{
46+
"group": "How-To Guides",
47+
"pages": [
48+
{
49+
"title": "Flutter Form Validation",
50+
"href": "/guides/flutter-form-validation"
4651
},
47-
{ "title": "Configuration", "href": "/core-concepts/configuration" }
52+
{ "title": "Common Recipes", "href": "/guides/common-recipes" },
53+
{ "title": "Custom Validation", "href": "/guides/custom-validation" }
4854
]
4955
},
5056
{
51-
"group": "Guides",
57+
"group": "Advanced",
5258
"pages": [
53-
{ "title": "Custom Validation", "href": "/guides/custom-validation" },
59+
{ "title": "Codecs", "href": "/core-concepts/codecs" },
60+
{
61+
"title": "TypeSafe Schemas",
62+
"href": "/core-concepts/typesafe-schemas"
63+
},
5464
{
5565
"title": "JSON Schema Integration",
5666
"href": "/guides/json-schema-integration"
5767
},
58-
{
59-
"title": "Flutter Form Validation",
60-
"href": "/guides/flutter-form-validation"
61-
}
68+
{ "title": "Configuration", "href": "/core-concepts/configuration" }
6269
]
6370
},
6471
{

0 commit comments

Comments
 (0)