tangled
alpha
login
or
join now
zzstoatzz.io
/
zat
1
fork
atom
atproto tools in zig
zat.dev
sdk
atproto
zig
1
fork
atom
overview
issues
pulls
pipelines
docs: simplify changelog
zzstoatzz.io
2 months ago
b37f0da2
e4d0a4f1
2/2
ci.yml
success
6s
deploy-docs.yml
success
7s
+2
-73
1 changed file
expand all
collapse all
unified
split
CHANGELOG.md
+2
-73
CHANGELOG.md
···
2
2
3
3
## 0.1.0
4
4
5
5
-
first feature release. adds protocol-level enums for firehose consumption.
6
6
-
7
7
-
### what's new
8
8
-
9
9
-
**sync types** - enums from `com.atproto.sync.subscribeRepos` lexicon:
5
5
+
sync types for firehose consumption:
10
6
11
7
- `CommitAction` - `.create`, `.update`, `.delete`
12
8
- `EventKind` - `.commit`, `.sync`, `.identity`, `.account`, `.info`
13
9
- `AccountStatus` - `.takendown`, `.suspended`, `.deleted`, `.deactivated`, `.desynchronized`, `.throttled`
14
10
15
15
-
these integrate with zig's `std.json` for automatic parsing. define struct fields as enums instead of strings, and get exhaustive switch checking.
16
16
-
17
17
-
### migration
18
18
-
19
19
-
if you're currently doing string comparisons:
20
20
-
21
21
-
```zig
22
22
-
// before: string comparisons everywhere
23
23
-
const TapRecord = struct {
24
24
-
action: []const u8,
25
25
-
collection: []const u8,
26
26
-
// ...
27
27
-
};
28
28
-
29
29
-
if (mem.eql(u8, rec.action, "create") or mem.eql(u8, rec.action, "update")) {
30
30
-
// handle upsert
31
31
-
} else if (mem.eql(u8, rec.action, "delete")) {
32
32
-
// handle delete
33
33
-
}
34
34
-
```
35
35
-
36
36
-
switch to enum fields:
37
37
-
38
38
-
```zig
39
39
-
// after: type-safe enums
40
40
-
const TapRecord = struct {
41
41
-
action: zat.CommitAction, // parsed automatically by std.json
42
42
-
collection: []const u8,
43
43
-
// ...
44
44
-
};
45
45
-
46
46
-
switch (rec.action) {
47
47
-
.create, .update => processUpsert(rec),
48
48
-
.delete => processDelete(rec),
49
49
-
}
50
50
-
```
51
51
-
52
52
-
the compiler enforces exhaustive handling - if AT Protocol adds a new action, your code won't compile until you handle it.
53
53
-
54
54
-
**this is backwards compatible.** your existing code continues to work. adopt the new types when you're ready.
55
55
-
56
56
-
### library overview
57
57
-
58
58
-
zat provides zig primitives for AT Protocol:
59
59
-
60
60
-
| feature | description |
61
61
-
|---------|-------------|
62
62
-
| string primitives | `Tid`, `Did`, `Handle`, `Nsid`, `Rkey`, `AtUri` - parsing and validation |
63
63
-
| did resolution | resolve `did:plc` and `did:web` to documents |
64
64
-
| handle resolution | resolve handles to DIDs via HTTP well-known |
65
65
-
| xrpc client | call AT Protocol endpoints (queries and procedures) |
66
66
-
| sync types | enums for firehose consumption |
67
67
-
| json helpers | navigate nested json without verbose if-chains |
68
68
-
| jwt verification | verify service auth tokens (ES256, ES256K) |
69
69
-
| multibase/multicodec | decode public keys from DID documents |
70
70
-
71
71
-
### install
72
72
-
73
73
-
```bash
74
74
-
zig fetch --save https://tangled.sh/zzstoatzz.io/zat/archive/main
75
75
-
```
76
76
-
77
77
-
```zig
78
78
-
// build.zig
79
79
-
const zat = b.dependency("zat", .{}).module("zat");
80
80
-
exe.root_module.addImport("zat", zat);
81
81
-
```
11
11
+
these integrate with `std.json` for automatic parsing.
82
12
83
13
## 0.0.2
84
14
···
87
17
88
18
## 0.0.1
89
19
90
90
-
- initial release
91
20
- string primitives (Tid, Did, Handle, Nsid, Rkey, AtUri)
92
21
- did/handle resolution
93
22
- json helpers