@hypercerts-org/sdk-core 0.9.0-beta.0 → 0.10.0-beta.1

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.
package/CHANGELOG.md ADDED
@@ -0,0 +1,273 @@
1
+ # @hypercerts-org/sdk-core
2
+
3
+ ## 1.0.0-beta.0
4
+
5
+ ### Major Changes
6
+
7
+ - [#66](https://github.com/hypercerts-org/hypercerts-sdk/pull/66)
8
+ [`7c33673`](https://github.com/hypercerts-org/hypercerts-sdk/commit/7c33673fd5f53d92ba160ced1d1582178fa7c455) Thanks
9
+ [@aspiers](https://github.com/aspiers)! - feat: migrate to published @hypercerts-org/lexicon package
10
+
11
+ This release migrates the SDK from using a local `packages/lexicon` workspace to consuming the published
12
+ `@hypercerts-org/lexicon` package from npm.
13
+
14
+ **Benefits:**
15
+ - **Single source of truth**: Lexicon definitions now come from a dedicated, independently versioned package
16
+ - **Reduced codebase**: Removes ~3,000 lines of duplicated lexicon code from this repository
17
+ - **Better versioning**: Lexicon can be updated independently via semver dependency updates
18
+ - **Simplified architecture**: No longer maintaining duplicate lexicon tooling in monorepo
19
+ - **Improved maintainability**: Clearer separation of concerns between SDK and lexicon definitions
20
+
21
+ **Breaking Changes:**
22
+ 1. **Removed `LexiconRegistry` class**: Use the `validate()` function instead
23
+ 2. **Removed `ValidationResult` type**: Validation functions now throw errors on validation failure
24
+ 3. **Renamed type exports** to match lexicon package conventions:
25
+ - `OrgHypercertsClaim` → `OrgHypercertsClaimActivity`
26
+ - `OrgHypercertsCollection` → `OrgHypercertsClaimCollection`
27
+ 4. **Renamed constant exports** to use consistent naming:
28
+ - `schemas` → `HYPERCERTS_SCHEMAS`
29
+ - `schemaDict` → `HYPERCERTS_SCHEMA_DICT`
30
+ - `ids` → `HYPERCERTS_NSIDS`
31
+ - `lexicons` now exported as type-only (use `HYPERCERTS_LEXICON_JSON` or `HYPERCERTS_LEXICON_DOC` for runtime
32
+ values)
33
+
34
+ **Migration Guide:**
35
+
36
+ **Validation:**
37
+
38
+ ```typescript
39
+ // Before
40
+ import { LexiconRegistry, HYPERCERT_LEXICONS, HYPERCERT_COLLECTIONS } from "@hypercerts-org/sdk-core";
41
+ const registry = new LexiconRegistry();
42
+ registry.registerLexicons(HYPERCERT_LEXICONS);
43
+ const result = registry.validate(HYPERCERT_COLLECTIONS.CLAIM, claimData);
44
+ if (!result.valid) {
45
+ console.error("Invalid record:", result.error);
46
+ }
47
+
48
+ // After
49
+ import { validate, HYPERCERT_COLLECTIONS } from "@hypercerts-org/sdk-core";
50
+ try {
51
+ validate(HYPERCERT_COLLECTIONS.CLAIM, claimData);
52
+ } catch (error) {
53
+ console.error("Invalid record:", error);
54
+ }
55
+ ```
56
+
57
+ **Type imports:**
58
+
59
+ ```typescript
60
+ // Before
61
+ import { OrgHypercertsClaim, OrgHypercertsCollection } from "@hypercerts-org/sdk-core";
62
+
63
+ // After
64
+ import { OrgHypercertsClaimActivity, OrgHypercertsClaimCollection } from "@hypercerts-org/sdk-core";
65
+ ```
66
+
67
+ **Constant imports:**
68
+
69
+ ```typescript
70
+ // Before
71
+ import { schemas, schemaDict, ids } from "@hypercerts-org/sdk-core";
72
+
73
+ // After
74
+ import { HYPERCERTS_SCHEMAS, HYPERCERTS_SCHEMA_DICT, HYPERCERTS_NSIDS } from "@hypercerts-org/sdk-core";
75
+ ```
76
+
77
+ **Other Changes:**
78
+ - Added dependency on `@hypercerts-org/lexicon@0.10.0-beta.3`
79
+ - Updated all lexicon type exports to use namespaced imports from lexicon package
80
+ - Improved hypercert validation with new test coverage
81
+ - Enhanced test mocks and fixtures for better testability
82
+
83
+ **For SDK users**: If you're using `LexiconRegistry`, follow the migration guide above. If you're only using the
84
+ high-level Repository API, no changes are required.
85
+
86
+ ### Minor Changes
87
+
88
+ - [#60](https://github.com/hypercerts-org/hypercerts-sdk/pull/60)
89
+ [`f7594f8`](https://github.com/hypercerts-org/hypercerts-sdk/commit/f7594f838fd7e64837da702f7498e84a49b28bf5) Thanks
90
+ [@bitbeckers](https://github.com/bitbeckers)! - Implement ConfigurableAgent for proper multi-server routing
91
+
92
+ This release introduces the `ConfigurableAgent` class that enables proper routing of AT Protocol requests to different
93
+ servers (PDS, SDS, or custom instances) while maintaining OAuth authentication from a single session.
94
+
95
+ **Breaking Changes:**
96
+ - Repository now uses `ConfigurableAgent` internally instead of standard `Agent`
97
+ - This fixes the issue where invalid `agent.service` and `agent.api.xrpc.uri` property assignments were causing
98
+ TypeScript errors
99
+
100
+ **New Features:**
101
+ - `ConfigurableAgent` class exported from `@hypercerts-org/sdk-core`
102
+ - Support for simultaneous connections to multiple SDS instances with one OAuth session
103
+ - Proper request routing based on configured service URL rather than session defaults
104
+
105
+ **Bug Fixes:**
106
+ - Remove invalid Agent property assignments that caused TypeScript compilation errors (TS2339)
107
+ - Replace all `any` types in test files with proper type annotations
108
+ - Eliminate build warnings from missing type declarations
109
+
110
+ **Architecture:** The new routing system wraps the OAuth session's fetch handler to prepend the target server URL,
111
+ ensuring requests go to the intended destination while maintaining full authentication (DPoP, access tokens, etc.).
112
+ This enables use cases like:
113
+ - Routing to SDS while authenticated via PDS
114
+ - Accessing multiple organization SDS instances simultaneously
115
+ - Testing against different server environments
116
+ - Dynamic switching between PDS and SDS operations
117
+
118
+ **Migration:** No action required - the change is transparent to existing code. The Repository API remains unchanged.
119
+
120
+ - [#46](https://github.com/hypercerts-org/hypercerts-sdk/pull/46)
121
+ [`eda4ac2`](https://github.com/hypercerts-org/hypercerts-sdk/commit/eda4ac233e09764d83f042ba7df94d4c9884cc01) Thanks
122
+ [@bitbeckers](https://github.com/bitbeckers)! - Initial release of sdk-core package with ATProto SDK for
123
+ authentication, repository operations, and lexicon management
124
+
125
+ - [#65](https://github.com/hypercerts-org/hypercerts-sdk/pull/65)
126
+ [`826b50c`](https://github.com/hypercerts-org/hypercerts-sdk/commit/826b50c140a56fee4feeb6b6c83d1123e44c5118) Thanks
127
+ [@bitbeckers](https://github.com/bitbeckers)! - feat(auth): add OAuth scopes and granular permissions system
128
+
129
+ Add comprehensive OAuth permissions system with support for granular permissions and easy email access:
130
+
131
+ **Permission System**
132
+ - Zod schemas for all ATProto permission types (account, repo, blob, rpc, identity, include)
133
+ - Support for both transitional (legacy) and granular permission models
134
+ - Type-safe permission builder with fluent API
135
+ - 14 pre-built scope presets (EMAIL_READ, POSTING_APP, FULL_ACCESS, etc.)
136
+ - 8 utility functions for working with scopes
137
+
138
+ **Email Access**
139
+ - New `getAccountEmail()` method to retrieve user email from authenticated session
140
+ - Returns null when permission not granted
141
+ - Comprehensive error handling
142
+
143
+ **Enhanced OAuth Integration**
144
+ - Automatic scope validation with helpful warnings
145
+ - Migration suggestions from transitional to granular permissions
146
+ - Improved documentation with comprehensive examples
147
+
148
+ **Breaking Changes**: None - fully backward compatible
149
+
150
+ **New Exports**:
151
+ - `PermissionBuilder` - Fluent API for building type-safe scopes
152
+ - `ScopePresets` - 14 ready-to-use permission presets
153
+ - Utility functions: `buildScope()`, `parseScope()`, `hasPermission()`, `validateScope()`, etc.
154
+ - Permission schemas and types for TypeScript consumers
155
+
156
+ See README for usage examples and migration guide.
157
+
158
+ - [#56](https://github.com/hypercerts-org/hypercerts-sdk/pull/56)
159
+ [`caceacb`](https://github.com/hypercerts-org/hypercerts-sdk/commit/caceacbc5572a590c750a95ccfda23fff2dd0c61) Thanks
160
+ [@bitbeckers](https://github.com/bitbeckers)! - Add pagination support and fix React hooks for SDS operations
161
+
162
+ **Breaking Changes (sdk-core):**
163
+ - `CollaboratorOperations.list()` now returns `{ collaborators: RepositoryAccessGrant[], cursor?: string }` instead of
164
+ `RepositoryAccessGrant[]`
165
+ - `OrganizationOperations.list()` now returns `{ organizations: OrganizationInfo[], cursor?: string }` instead of
166
+ `OrganizationInfo[]`
167
+
168
+ **Features:**
169
+ - Add cursor-based pagination support to collaborator and organization list operations
170
+ - Support optional `limit` and `cursor` parameters for paginated queries
171
+ - Update internal methods (`hasAccess`, `getRole`, `get`) to handle new pagination structure
172
+
173
+ **Bug Fixes (sdk-core):**
174
+ - Fix permissions parsing in `CollaboratorOperationsImpl.list()` to match actual SDS API format (object with boolean
175
+ flags)
176
+ - Prevent `TypeError: permissionArray.includes is not a function` by correctly handling permissions as objects
177
+ - Fix Agent service URL configuration to route queries to the correct server (PDS or SDS)
178
+ - Resolve "Could not find repo" errors when querying SDS repositories by ensuring Agent uses SDS service endpoint
179
+ - Update test mocks to use the actual SDS API response format
180
+
181
+ **Bug Fixes (sdk-react):**
182
+ - Fix `useCollaborators` hook to correctly destructure paginated response
183
+ - Fix `useOrganizations` hook to correctly destructure paginated response
184
+ - All React hooks now properly handle the new pagination structure
185
+
186
+ **Documentation:**
187
+ - Comprehensive README updates with clear examples for all SDK operations
188
+ - Added pagination examples throughout documentation
189
+ - Improved code samples with realistic use cases
190
+
191
+ **Tests:**
192
+ - All 317 tests passing (181 sdk-core + 136 sdk-react)
193
+ - Updated test mocks to match new pagination response structure
194
+ - Build completes with zero warnings
195
+
196
+ ### Patch Changes
197
+
198
+ - [#58](https://github.com/hypercerts-org/hypercerts-sdk/pull/58)
199
+ [`bcde5fa`](https://github.com/hypercerts-org/hypercerts-sdk/commit/bcde5faeb11dba6d99967a434e8ec32d67b3aca5) Thanks
200
+ [@bitbeckers](https://github.com/bitbeckers)! - Fix collaborator permissions parsing to align with SDS API response
201
+ format. The SDS API returns permissions as objects with boolean flags (`{ read: true, create: true, ... }`) rather
202
+ than string arrays. This fix simplifies the permissions parser to handle only the actual format returned by the API.
203
+
204
+ - [#64](https://github.com/hypercerts-org/hypercerts-sdk/pull/64)
205
+ [`f83f03a`](https://github.com/hypercerts-org/hypercerts-sdk/commit/f83f03a8e505d57d38b45f3a50213ca1035c1229) Thanks
206
+ [@bitbeckers](https://github.com/bitbeckers)! - fix(lexicon): correct field names and types to match lexicon schema
207
+ - Fix `workTimeframeFrom/To` -> `workTimeFrameFrom/To` (capital 'F' in Frame)
208
+ - Make `shortDescription` required for hypercert claims per lexicon schema
209
+ - Update all interfaces, implementations, and tests to use correct field names
210
+ - Add comprehensive lexicon documentation to README
211
+
212
+ - [#62](https://github.com/hypercerts-org/hypercerts-sdk/pull/62)
213
+ [`4b80edc`](https://github.com/hypercerts-org/hypercerts-sdk/commit/4b80edca4162c4ce929edb28ffffa3f99f21cb74) Thanks
214
+ [@bitbeckers](https://github.com/bitbeckers)! - fix(sdk-core): add required $type field to all record creation
215
+ operations
216
+
217
+ The AT Protocol requires all records to include a `$type` field, but the SDK was omitting it during record creation,
218
+ causing validation errors like "Record/$type must be a string". This fix:
219
+ - Adds `$type` field to all record types (rights, claims, locations, contributions, measurements, evaluations,
220
+ collections)
221
+ - Fixes location record implementation to match `app.certified.location` lexicon schema
222
+ - Makes `srs` (Spatial Reference System) field required for location records with proper validation
223
+ - Updates interfaces and documentation to reflect required fields
224
+
225
+ Breaking change: `location.srs` is now required when creating locations (use "EPSG:4326" for standard WGS84
226
+ coordinates).
227
+
228
+ - [#59](https://github.com/hypercerts-org/hypercerts-sdk/pull/59)
229
+ [`7020fcc`](https://github.com/hypercerts-org/hypercerts-sdk/commit/7020fcc9845a4d4c2f792536611fc3bb5e3c4fe3) Thanks
230
+ [@bitbeckers](https://github.com/bitbeckers)! - Configure npm publishing to exclude source code and development files.
231
+ Packages now only include the compiled `dist/` folder, README, and necessary runtime files (lexicon schemas). This
232
+ reduces package sizes and prevents unnecessary files from being published to npm.
233
+
234
+ - [#60](https://github.com/hypercerts-org/hypercerts-sdk/pull/60)
235
+ [`39accd9`](https://github.com/hypercerts-org/hypercerts-sdk/commit/39accd954422c901b7faf93e08be88e68a4f849a) Thanks
236
+ [@bitbeckers](https://github.com/bitbeckers)! - fix(sdk-core): ensure repository operations route to correct server
237
+ (PDS/SDS)
238
+
239
+ **Problem:** When using OAuth authentication to access organization repositories on SDS via
240
+ `repo.repo(organizationDid)`, all operations like `hypercerts.list()` and `hypercerts.listCollections()` were
241
+ incorrectly routing to the user's PDS instead of the SDS server, causing "Could not find repo" errors.
242
+
243
+ **Root Cause:** The AT Protocol Agent was created from the OAuth session but only had its `api.xrpc.uri` property
244
+ configured. Without setting the Agent's `service` property, it continued using the session's default PDS URL for all
245
+ requests, even when switched to organization repositories.
246
+
247
+ **Solution:** Set both `agent.service` and `agent.api.xrpc.uri` to the specified server URL in the Repository
248
+ constructor. This ensures that:
249
+ - Initial repository creation routes to the correct server (PDS or SDS)
250
+ - Repository switching via `.repo(did)` maintains the same server routing
251
+ - All operation implementations (HypercertOperationsImpl, RecordOperationsImpl, ProfileOperationsImpl,
252
+ BlobOperationsImpl) now route correctly
253
+
254
+ **Documentation:** Added comprehensive PDS/SDS orchestration explanation to README covering:
255
+ - Server type comparison and use cases
256
+ - How repository routing works internally
257
+ - Common patterns for personal vs organization hypercerts
258
+ - Key implementation details about Agent configuration
259
+
260
+ - [#56](https://github.com/hypercerts-org/hypercerts-sdk/pull/56)
261
+ [`cb3268d`](https://github.com/hypercerts-org/hypercerts-sdk/commit/cb3268d78614efaf15aecc57a5dc3bce8313f3ca) Thanks
262
+ [@bitbeckers](https://github.com/bitbeckers)! - Fix SDS organization and collaborator operations to match API
263
+ contracts
264
+ - Add required creatorDid parameter to organization.create endpoint
265
+ - Fix organization.list to parse organizations field instead of repositories
266
+ - Update accessType values to match SDS API: owner|shared|none (was owner|collaborator)
267
+ - Add permission string array parser for collaborator.list endpoint
268
+ - Update type definitions to match actual SDS API response formats
269
+
270
+ - [#55](https://github.com/hypercerts-org/hypercerts-sdk/pull/55)
271
+ [`23c3d9a`](https://github.com/hypercerts-org/hypercerts-sdk/commit/23c3d9a3b71f326df68b65420c83f7ae42c2432d) Thanks
272
+ [@bitbeckers](https://github.com/bitbeckers)! - Fix endpoints and NSIDs for SDS operations in CollaboratorOperations
273
+ and OrganizationOperations