@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/dist/lexicons.cjs CHANGED
@@ -1,420 +1,149 @@
1
1
  'use strict';
2
2
 
3
- var lexicon$1 = require('@atproto/lexicon');
4
3
  var lexicon = require('@hypercerts-org/lexicon');
5
4
 
6
5
  /**
7
- * Base error class for all SDK errors.
6
+ * Lexicons entrypoint - Lexicon definitions and registry.
8
7
  *
9
- * All errors thrown by the Hypercerts SDK extend this class, making it easy
10
- * to catch and handle SDK-specific errors.
8
+ * This sub-entrypoint exports the lexicon registry and hypercert
9
+ * lexicon constants for working with AT Protocol record schemas.
11
10
  *
12
- * @example Catching all SDK errors
13
- * ```typescript
14
- * try {
15
- * await sdk.authorize("user.bsky.social");
16
- * } catch (error) {
17
- * if (error instanceof ATProtoSDKError) {
18
- * console.error(`SDK Error [${error.code}]: ${error.message}`);
19
- * console.error(`HTTP Status: ${error.status}`);
20
- * }
21
- * }
22
- * ```
11
+ * @remarks
12
+ * Import from `@hypercerts-org/sdk/lexicons`:
23
13
  *
24
- * @example Checking error codes
25
14
  * ```typescript
26
- * try {
27
- * await repo.records.get(collection, rkey);
28
- * } catch (error) {
29
- * if (error instanceof ATProtoSDKError) {
30
- * switch (error.code) {
31
- * case "AUTHENTICATION_ERROR":
32
- * // Redirect to login
33
- * break;
34
- * case "VALIDATION_ERROR":
35
- * // Show form errors
36
- * break;
37
- * case "NETWORK_ERROR":
38
- * // Retry or show offline message
39
- * break;
40
- * }
41
- * }
42
- * }
15
+ * import {
16
+ * LexiconRegistry,
17
+ * HYPERCERT_LEXICONS,
18
+ * HYPERCERT_COLLECTIONS,
19
+ * } from "@hypercerts-org/sdk/lexicons";
43
20
  * ```
44
- */
45
- class ATProtoSDKError extends Error {
46
- /**
47
- * Creates a new SDK error.
48
- *
49
- * @param message - Human-readable error description
50
- * @param code - Machine-readable error code for programmatic handling
51
- * @param status - HTTP status code associated with this error type
52
- * @param cause - The underlying error that caused this error, if any
53
- */
54
- constructor(message, code, status, cause) {
55
- super(message);
56
- this.code = code;
57
- this.status = status;
58
- this.cause = cause;
59
- this.name = "ATProtoSDKError";
60
- Error.captureStackTrace?.(this, this.constructor);
61
- }
62
- }
63
- /**
64
- * Error thrown when input validation fails.
65
21
  *
66
- * This error indicates that provided data doesn't meet the required format
67
- * or constraints. Common causes:
68
- * - Missing required fields
69
- * - Invalid URL formats
70
- * - Invalid DID format
71
- * - Schema validation failures for records
72
- * - Invalid configuration values
73
- *
74
- * @example
75
- * ```typescript
76
- * try {
77
- * await sdk.authorize(""); // Empty identifier
78
- * } catch (error) {
79
- * if (error instanceof ValidationError) {
80
- * console.error("Invalid input:", error.message);
81
- * // Show validation error to user
82
- * }
83
- * }
84
- * ```
22
+ * **Exports**:
23
+ * - {@link LexiconRegistry} - Registry for managing and validating lexicons
24
+ * - {@link HYPERCERT_LEXICONS} - Array of all hypercert lexicon documents
25
+ * - {@link HYPERCERT_COLLECTIONS} - Constants for collection NSIDs
85
26
  *
86
- * @example With Zod validation cause
27
+ * @example Using collection constants
87
28
  * ```typescript
88
- * try {
89
- * await repo.records.create(collection, record);
90
- * } catch (error) {
91
- * if (error instanceof ValidationError && error.cause) {
92
- * // error.cause may be a ZodError with detailed field errors
93
- * const zodError = error.cause as ZodError;
94
- * zodError.errors.forEach(e => {
95
- * console.error(`Field ${e.path.join(".")}: ${e.message}`);
96
- * });
97
- * }
98
- * }
99
- * ```
100
- */
101
- class ValidationError extends ATProtoSDKError {
102
- /**
103
- * Creates a validation error.
104
- *
105
- * @param message - Description of what validation failed
106
- * @param cause - The underlying validation error (e.g., ZodError)
107
- */
108
- constructor(message, cause) {
109
- super(message, "VALIDATION_ERROR", 400, cause);
110
- this.name = "ValidationError";
111
- }
112
- }
113
-
114
- /**
115
- * Registry for managing and validating AT Protocol lexicon schemas.
116
- *
117
- * Lexicons are schema definitions that describe the structure of records
118
- * in the AT Protocol. This registry allows you to:
29
+ * import { HYPERCERT_COLLECTIONS } from "@hypercerts-org/sdk/lexicons";
119
30
  *
120
- * - Register custom lexicons for your application's record types
121
- * - Validate records against their lexicon schemas
122
- * - Extend the AT Protocol Agent with custom lexicon support
123
- *
124
- * @remarks
125
- * The SDK automatically registers hypercert lexicons when creating a Repository.
126
- * You only need to use this class directly if you're working with custom
127
- * record types.
31
+ * // List hypercerts using the correct collection name
32
+ * const records = await repo.records.list({
33
+ * collection: HYPERCERT_COLLECTIONS.RECORD,
34
+ * });
128
35
  *
129
- * **Lexicon IDs** follow the NSID (Namespaced Identifier) format:
130
- * `{authority}.{name}` (e.g., `org.hypercerts.hypercert`)
36
+ * // List contributions
37
+ * const contributions = await repo.records.list({
38
+ * collection: HYPERCERT_COLLECTIONS.CONTRIBUTION,
39
+ * });
40
+ * ```
131
41
  *
132
- * @example Registering custom lexicons
42
+ * @example Custom lexicon registration
133
43
  * ```typescript
44
+ * import { LexiconRegistry } from "@hypercerts-org/sdk/lexicons";
45
+ *
134
46
  * const registry = sdk.getLexiconRegistry();
135
47
  *
136
- * // Register a single lexicon
48
+ * // Register custom lexicon
137
49
  * registry.register({
138
50
  * lexicon: 1,
139
- * id: "org.example.myRecord",
140
- * defs: {
141
- * main: {
142
- * type: "record",
143
- * key: "tid",
144
- * record: {
145
- * type: "object",
146
- * required: ["title", "createdAt"],
147
- * properties: {
148
- * title: { type: "string" },
149
- * description: { type: "string" },
150
- * createdAt: { type: "string", format: "datetime" },
151
- * },
152
- * },
153
- * },
154
- * },
155
- * });
156
- *
157
- * // Register multiple lexicons at once
158
- * registry.registerMany([lexicon1, lexicon2, lexicon3]);
159
- * ```
160
- *
161
- * @example Validating records
162
- * ```typescript
163
- * const result = registry.validate("org.example.myRecord", {
164
- * title: "Test",
165
- * createdAt: new Date().toISOString(),
51
+ * id: "org.myapp.customRecord",
52
+ * defs: { ... },
166
53
  * });
167
54
  *
55
+ * // Validate a record
56
+ * const result = registry.validate("org.myapp.customRecord", record);
168
57
  * if (!result.valid) {
169
- * console.error(`Validation failed: ${result.error}`);
58
+ * console.error(result.error);
170
59
  * }
171
60
  * ```
172
61
  *
173
- * @see https://atproto.com/specs/lexicon for the Lexicon specification
62
+ * @packageDocumentation
63
+ */
64
+ /**
65
+ * All hypercert-related lexicons for registration with AT Protocol Agent.
66
+ * This array contains all lexicon documents from the published package.
174
67
  */
175
- class LexiconRegistry {
68
+ const HYPERCERT_LEXICONS = [
69
+ lexicon.CERTIFIED_DEFS_LEXICON_JSON,
70
+ lexicon.LOCATION_LEXICON_JSON,
71
+ lexicon.STRONGREF_LEXICON_JSON,
72
+ lexicon.HYPERCERTS_DEFS_LEXICON_JSON,
73
+ lexicon.ACTIVITY_LEXICON_JSON,
74
+ lexicon.COLLECTION_LEXICON_JSON,
75
+ lexicon.CONTRIBUTION_LEXICON_JSON,
76
+ lexicon.EVALUATION_LEXICON_JSON,
77
+ lexicon.EVIDENCE_LEXICON_JSON,
78
+ lexicon.MEASUREMENT_LEXICON_JSON,
79
+ lexicon.RIGHTS_LEXICON_JSON,
80
+ lexicon.PROJECT_LEXICON_JSON,
81
+ lexicon.BADGE_AWARD_LEXICON_JSON,
82
+ lexicon.BADGE_DEFINITION_LEXICON_JSON,
83
+ lexicon.BADGE_RESPONSE_LEXICON_JSON,
84
+ lexicon.FUNDING_RECEIPT_LEXICON_JSON,
85
+ ];
86
+ /**
87
+ * Collection NSIDs (Namespaced Identifiers) for hypercert records.
88
+ *
89
+ * Use these constants when performing record operations to ensure
90
+ * correct collection names.
91
+ */
92
+ const HYPERCERT_COLLECTIONS = {
93
+ /**
94
+ * Main hypercert claim record collection.
95
+ */
96
+ CLAIM: lexicon.ACTIVITY_NSID,
97
+ /**
98
+ * Rights record collection.
99
+ */
100
+ RIGHTS: lexicon.RIGHTS_NSID,
101
+ /**
102
+ * Location record collection (shared certified lexicon).
103
+ */
104
+ LOCATION: lexicon.LOCATION_NSID,
105
+ /**
106
+ * Contribution record collection.
107
+ */
108
+ CONTRIBUTION: lexicon.CONTRIBUTION_NSID,
109
+ /**
110
+ * Measurement record collection.
111
+ */
112
+ MEASUREMENT: lexicon.MEASUREMENT_NSID,
176
113
  /**
177
- * Creates a new LexiconRegistry.
178
- *
179
- * The registry starts empty. Use {@link register} or {@link registerMany}
180
- * to add lexicons.
114
+ * Evaluation record collection.
181
115
  */
182
- constructor() {
183
- /** Map of lexicon ID to lexicon document */
184
- this.lexicons = new Map();
185
- this.lexiconsCollection = new lexicon$1.Lexicons();
186
- }
116
+ EVALUATION: lexicon.EVALUATION_NSID,
187
117
  /**
188
- * Registers a single lexicon schema.
189
- *
190
- * @param lexicon - The lexicon document to register
191
- * @throws {@link ValidationError} if the lexicon doesn't have an `id` field
192
- *
193
- * @remarks
194
- * If a lexicon with the same ID is already registered, it will be
195
- * replaced with the new definition. This is useful for testing but
196
- * should generally be avoided in production.
197
- *
198
- * @example
199
- * ```typescript
200
- * registry.register({
201
- * lexicon: 1,
202
- * id: "org.example.post",
203
- * defs: {
204
- * main: {
205
- * type: "record",
206
- * key: "tid",
207
- * record: {
208
- * type: "object",
209
- * required: ["text", "createdAt"],
210
- * properties: {
211
- * text: { type: "string", maxLength: 300 },
212
- * createdAt: { type: "string", format: "datetime" },
213
- * },
214
- * },
215
- * },
216
- * },
217
- * });
218
- * ```
118
+ * Evidence record collection.
219
119
  */
220
- register(lexicon) {
221
- if (!lexicon.id) {
222
- throw new ValidationError("Lexicon must have an 'id' field");
223
- }
224
- // Remove existing lexicon if present (to allow overwriting)
225
- if (this.lexicons.has(lexicon.id)) {
226
- // Lexicons collection doesn't support removal, so we create a new one
227
- // This is a limitation - in practice, lexicons shouldn't be overwritten
228
- // But we allow it for testing and flexibility
229
- const existingLexicon = this.lexicons.get(lexicon.id);
230
- if (existingLexicon) {
231
- // Try to remove from collection (may fail if not supported)
232
- try {
233
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
234
- this.lexiconsCollection.remove?.(lexicon.id);
235
- }
236
- catch {
237
- // If removal fails, create a new collection
238
- this.lexiconsCollection = new lexicon$1.Lexicons();
239
- // Re-register all other lexicons
240
- for (const [id, lex] of this.lexicons.entries()) {
241
- if (id !== lexicon.id) {
242
- this.lexiconsCollection.add(lex);
243
- }
244
- }
245
- }
246
- }
247
- }
248
- this.lexicons.set(lexicon.id, lexicon);
249
- this.lexiconsCollection.add(lexicon);
250
- }
120
+ EVIDENCE: lexicon.EVIDENCE_NSID,
251
121
  /**
252
- * Registers multiple lexicons at once.
253
- *
254
- * @param lexicons - Array of lexicon documents to register
255
- *
256
- * @example
257
- * ```typescript
258
- * import { HYPERCERT_LEXICONS } from "@hypercerts-org/sdk/lexicons";
259
- *
260
- * registry.registerMany(HYPERCERT_LEXICONS);
261
- * ```
122
+ * Collection record collection (groups of hypercerts).
262
123
  */
263
- registerMany(lexicons) {
264
- for (const lexicon of lexicons) {
265
- this.register(lexicon);
266
- }
267
- }
124
+ COLLECTION: lexicon.COLLECTION_NSID,
268
125
  /**
269
- * Gets a lexicon document by ID.
270
- *
271
- * @param id - The lexicon NSID (e.g., "org.hypercerts.hypercert")
272
- * @returns The lexicon document, or `undefined` if not registered
273
- *
274
- * @example
275
- * ```typescript
276
- * const lexicon = registry.get("org.hypercerts.hypercert");
277
- * if (lexicon) {
278
- * console.log(`Found lexicon: ${lexicon.id}`);
279
- * }
280
- * ```
126
+ * Project record collection.
281
127
  */
282
- get(id) {
283
- return this.lexicons.get(id);
284
- }
128
+ PROJECT: lexicon.PROJECT_NSID,
285
129
  /**
286
- * Validates a record against a collection's lexicon schema.
287
- *
288
- * @param collection - The collection NSID (same as lexicon ID)
289
- * @param record - The record data to validate
290
- * @returns Validation result with `valid` boolean and optional `error` message
291
- *
292
- * @remarks
293
- * - If no lexicon is registered for the collection, validation passes
294
- * (we can't validate against unknown schemas)
295
- * - Validation checks required fields and type constraints defined
296
- * in the lexicon schema
297
- *
298
- * @example
299
- * ```typescript
300
- * const result = registry.validate("org.hypercerts.hypercert", {
301
- * title: "My Hypercert",
302
- * description: "Description...",
303
- * // ... other fields
304
- * });
305
- *
306
- * if (!result.valid) {
307
- * throw new Error(`Invalid record: ${result.error}`);
308
- * }
309
- * ```
130
+ * Badge award record collection.
310
131
  */
311
- validate(collection, record) {
312
- // Check if we have a lexicon registered for this collection
313
- // Collection format is typically "namespace.collection" (e.g., "app.bsky.feed.post")
314
- // Lexicon ID format is the same
315
- const lexiconId = collection;
316
- const lexicon = this.lexicons.get(lexiconId);
317
- if (!lexicon) {
318
- // No lexicon registered - validation passes (can't validate unknown schemas)
319
- return { valid: true };
320
- }
321
- // Check required fields if the lexicon defines them
322
- const recordDef = lexicon.defs?.record;
323
- if (recordDef && typeof recordDef === "object" && "record" in recordDef) {
324
- const recordSchema = recordDef.record;
325
- if (typeof recordSchema === "object" && "required" in recordSchema && Array.isArray(recordSchema.required)) {
326
- const recordObj = record;
327
- for (const requiredField of recordSchema.required) {
328
- if (typeof requiredField === "string" && !(requiredField in recordObj)) {
329
- return {
330
- valid: false,
331
- error: `Missing required field: ${requiredField}`,
332
- };
333
- }
334
- }
335
- }
336
- }
337
- try {
338
- this.lexiconsCollection.assertValidRecord(collection, record);
339
- return { valid: true };
340
- }
341
- catch (error) {
342
- // If error indicates lexicon not found, treat as validation pass
343
- // (the lexicon might exist in Agent's collection but not ours)
344
- const errorMessage = error instanceof Error ? error.message : String(error);
345
- if (errorMessage.includes("not found") || errorMessage.includes("Lexicon not found")) {
346
- return { valid: true };
347
- }
348
- return {
349
- valid: false,
350
- error: errorMessage,
351
- };
352
- }
353
- }
132
+ BADGE_AWARD: lexicon.BADGE_AWARD_NSID,
354
133
  /**
355
- * Adds all registered lexicons to an AT Protocol Agent instance.
356
- *
357
- * This allows the Agent to understand custom lexicon types when making
358
- * API requests.
359
- *
360
- * @param agent - The Agent instance to extend
361
- *
362
- * @remarks
363
- * This is called automatically when creating a Repository. You typically
364
- * don't need to call this directly unless you're using the Agent
365
- * independently.
366
- *
367
- * @internal
134
+ * Badge definition record collection.
368
135
  */
369
- addToAgent(agent) {
370
- // Access the internal lexicons collection and merge our lexicons
371
- // The Agent's lex property is a Lexicons instance
372
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
373
- const agentLex = agent.lex;
374
- // Add each registered lexicon to the agent
375
- for (const lexicon of this.lexicons.values()) {
376
- agentLex.add(lexicon);
377
- }
378
- }
136
+ BADGE_DEFINITION: lexicon.BADGE_DEFINITION_NSID,
379
137
  /**
380
- * Gets all registered lexicon IDs.
381
- *
382
- * @returns Array of lexicon NSIDs
383
- *
384
- * @example
385
- * ```typescript
386
- * const ids = registry.getRegisteredIds();
387
- * console.log(`Registered lexicons: ${ids.join(", ")}`);
388
- * ```
138
+ * Badge response record collection.
389
139
  */
390
- getRegisteredIds() {
391
- return Array.from(this.lexicons.keys());
392
- }
140
+ BADGE_RESPONSE: lexicon.BADGE_RESPONSE_NSID,
393
141
  /**
394
- * Checks if a lexicon is registered.
395
- *
396
- * @param id - The lexicon NSID to check
397
- * @returns `true` if the lexicon is registered
398
- *
399
- * @example
400
- * ```typescript
401
- * if (registry.has("org.hypercerts.hypercert")) {
402
- * // Hypercert lexicon is available
403
- * }
404
- * ```
142
+ * Funding receipt record collection.
405
143
  */
406
- has(id) {
407
- return this.lexicons.has(id);
408
- }
409
- }
144
+ FUNDING_RECEIPT: lexicon.FUNDING_RECEIPT_NSID,
145
+ };
410
146
 
411
- Object.defineProperty(exports, "HYPERCERT_COLLECTIONS", {
412
- enumerable: true,
413
- get: function () { return lexicon.HYPERCERT_COLLECTIONS; }
414
- });
415
- Object.defineProperty(exports, "HYPERCERT_LEXICONS", {
416
- enumerable: true,
417
- get: function () { return lexicon.HYPERCERT_LEXICONS; }
418
- });
419
- exports.LexiconRegistry = LexiconRegistry;
147
+ exports.HYPERCERT_COLLECTIONS = HYPERCERT_COLLECTIONS;
148
+ exports.HYPERCERT_LEXICONS = HYPERCERT_LEXICONS;
420
149
  //# sourceMappingURL=lexicons.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"lexicons.cjs","sources":["../src/core/errors.ts","../src/repository/LexiconRegistry.ts"],"sourcesContent":["/**\n * Base error class for all SDK errors.\n *\n * All errors thrown by the Hypercerts SDK extend this class, making it easy\n * to catch and handle SDK-specific errors.\n *\n * @example Catching all SDK errors\n * ```typescript\n * try {\n * await sdk.authorize(\"user.bsky.social\");\n * } catch (error) {\n * if (error instanceof ATProtoSDKError) {\n * console.error(`SDK Error [${error.code}]: ${error.message}`);\n * console.error(`HTTP Status: ${error.status}`);\n * }\n * }\n * ```\n *\n * @example Checking error codes\n * ```typescript\n * try {\n * await repo.records.get(collection, rkey);\n * } catch (error) {\n * if (error instanceof ATProtoSDKError) {\n * switch (error.code) {\n * case \"AUTHENTICATION_ERROR\":\n * // Redirect to login\n * break;\n * case \"VALIDATION_ERROR\":\n * // Show form errors\n * break;\n * case \"NETWORK_ERROR\":\n * // Retry or show offline message\n * break;\n * }\n * }\n * }\n * ```\n */\nexport class ATProtoSDKError extends Error {\n /**\n * Creates a new SDK error.\n *\n * @param message - Human-readable error description\n * @param code - Machine-readable error code for programmatic handling\n * @param status - HTTP status code associated with this error type\n * @param cause - The underlying error that caused this error, if any\n */\n constructor(\n message: string,\n public code: string,\n public status?: number,\n public cause?: unknown,\n ) {\n super(message);\n this.name = \"ATProtoSDKError\";\n Error.captureStackTrace?.(this, this.constructor);\n }\n}\n\n/**\n * Error thrown when authentication fails.\n *\n * This error indicates problems with the OAuth flow, invalid credentials,\n * or failed token exchanges. Common causes:\n * - Invalid authorization code\n * - Expired or invalid state parameter\n * - Revoked or invalid tokens\n * - User denied authorization\n *\n * @example\n * ```typescript\n * try {\n * const session = await sdk.callback(params);\n * } catch (error) {\n * if (error instanceof AuthenticationError) {\n * // Clear any stored state and redirect to login\n * console.error(\"Authentication failed:\", error.message);\n * }\n * }\n * ```\n */\nexport class AuthenticationError extends ATProtoSDKError {\n /**\n * Creates an authentication error.\n *\n * @param message - Description of what went wrong during authentication\n * @param cause - The underlying error (e.g., from the OAuth client)\n */\n constructor(message: string, cause?: unknown) {\n super(message, \"AUTHENTICATION_ERROR\", 401, cause);\n this.name = \"AuthenticationError\";\n }\n}\n\n/**\n * Error thrown when a session has expired and cannot be refreshed.\n *\n * This typically occurs when:\n * - The refresh token has expired (usually after extended inactivity)\n * - The user has revoked access to your application\n * - The PDS has invalidated all sessions for the user\n *\n * When this error occurs, the user must re-authenticate.\n *\n * @example\n * ```typescript\n * try {\n * const session = await sdk.restoreSession(did);\n * } catch (error) {\n * if (error instanceof SessionExpiredError) {\n * // Clear stored session and prompt user to log in again\n * localStorage.removeItem(\"userDid\");\n * window.location.href = \"/login\";\n * }\n * }\n * ```\n */\nexport class SessionExpiredError extends ATProtoSDKError {\n /**\n * Creates a session expired error.\n *\n * @param message - Description of why the session expired\n * @param cause - The underlying error from the token refresh attempt\n */\n constructor(message: string = \"Session expired\", cause?: unknown) {\n super(message, \"SESSION_EXPIRED\", 401, cause);\n this.name = \"SessionExpiredError\";\n }\n}\n\n/**\n * Error thrown when input validation fails.\n *\n * This error indicates that provided data doesn't meet the required format\n * or constraints. Common causes:\n * - Missing required fields\n * - Invalid URL formats\n * - Invalid DID format\n * - Schema validation failures for records\n * - Invalid configuration values\n *\n * @example\n * ```typescript\n * try {\n * await sdk.authorize(\"\"); // Empty identifier\n * } catch (error) {\n * if (error instanceof ValidationError) {\n * console.error(\"Invalid input:\", error.message);\n * // Show validation error to user\n * }\n * }\n * ```\n *\n * @example With Zod validation cause\n * ```typescript\n * try {\n * await repo.records.create(collection, record);\n * } catch (error) {\n * if (error instanceof ValidationError && error.cause) {\n * // error.cause may be a ZodError with detailed field errors\n * const zodError = error.cause as ZodError;\n * zodError.errors.forEach(e => {\n * console.error(`Field ${e.path.join(\".\")}: ${e.message}`);\n * });\n * }\n * }\n * ```\n */\nexport class ValidationError extends ATProtoSDKError {\n /**\n * Creates a validation error.\n *\n * @param message - Description of what validation failed\n * @param cause - The underlying validation error (e.g., ZodError)\n */\n constructor(message: string, cause?: unknown) {\n super(message, \"VALIDATION_ERROR\", 400, cause);\n this.name = \"ValidationError\";\n }\n}\n\n/**\n * Error thrown when a network request fails.\n *\n * This error indicates connectivity issues or server unavailability.\n * Common causes:\n * - No internet connection\n * - DNS resolution failure\n * - Server timeout\n * - Server returned 5xx error\n * - TLS/SSL errors\n *\n * These errors are typically transient and may succeed on retry.\n *\n * @example\n * ```typescript\n * try {\n * await repo.records.list(collection);\n * } catch (error) {\n * if (error instanceof NetworkError) {\n * // Implement retry logic or show offline indicator\n * console.error(\"Network error:\", error.message);\n * await retryWithBackoff(() => repo.records.list(collection));\n * }\n * }\n * ```\n */\nexport class NetworkError extends ATProtoSDKError {\n /**\n * Creates a network error.\n *\n * @param message - Description of the network failure\n * @param cause - The underlying error (e.g., fetch error, timeout)\n */\n constructor(message: string, cause?: unknown) {\n super(message, \"NETWORK_ERROR\", 503, cause);\n this.name = \"NetworkError\";\n }\n}\n\n/**\n * Error thrown when an SDS-only operation is attempted on a PDS.\n *\n * Certain operations are only available on Shared Data Servers (SDS),\n * such as collaborator management and organization operations.\n * This error is thrown when these operations are attempted on a\n * Personal Data Server (PDS).\n *\n * @example\n * ```typescript\n * const pdsRepo = sdk.repository(session); // Default is PDS\n *\n * try {\n * // This will throw SDSRequiredError\n * await pdsRepo.collaborators.list();\n * } catch (error) {\n * if (error instanceof SDSRequiredError) {\n * // Switch to SDS for this operation\n * const sdsRepo = sdk.repository(session, { server: \"sds\" });\n * const collaborators = await sdsRepo.collaborators.list();\n * }\n * }\n * ```\n */\nexport class SDSRequiredError extends ATProtoSDKError {\n /**\n * Creates an SDS required error.\n *\n * @param message - Description of which operation requires SDS\n * @param cause - Any underlying error\n */\n constructor(message: string = \"This operation requires a Shared Data Server (SDS)\", cause?: unknown) {\n super(message, \"SDS_REQUIRED\", 400, cause);\n this.name = \"SDSRequiredError\";\n }\n}\n","import type { Agent } from \"@atproto/api\";\nimport type { LexiconDoc } from \"@atproto/lexicon\";\nimport { Lexicons } from \"@atproto/lexicon\";\nimport { ValidationError } from \"../core/errors.js\";\n\n/**\n * Result of validating a record against a lexicon schema.\n */\nexport interface ValidationResult {\n /**\n * Whether the record is valid according to the lexicon schema.\n */\n valid: boolean;\n\n /**\n * Error message if validation failed.\n *\n * Only present when `valid` is `false`.\n */\n error?: string;\n}\n\n/**\n * Registry for managing and validating AT Protocol lexicon schemas.\n *\n * Lexicons are schema definitions that describe the structure of records\n * in the AT Protocol. This registry allows you to:\n *\n * - Register custom lexicons for your application's record types\n * - Validate records against their lexicon schemas\n * - Extend the AT Protocol Agent with custom lexicon support\n *\n * @remarks\n * The SDK automatically registers hypercert lexicons when creating a Repository.\n * You only need to use this class directly if you're working with custom\n * record types.\n *\n * **Lexicon IDs** follow the NSID (Namespaced Identifier) format:\n * `{authority}.{name}` (e.g., `org.hypercerts.hypercert`)\n *\n * @example Registering custom lexicons\n * ```typescript\n * const registry = sdk.getLexiconRegistry();\n *\n * // Register a single lexicon\n * registry.register({\n * lexicon: 1,\n * id: \"org.example.myRecord\",\n * defs: {\n * main: {\n * type: \"record\",\n * key: \"tid\",\n * record: {\n * type: \"object\",\n * required: [\"title\", \"createdAt\"],\n * properties: {\n * title: { type: \"string\" },\n * description: { type: \"string\" },\n * createdAt: { type: \"string\", format: \"datetime\" },\n * },\n * },\n * },\n * },\n * });\n *\n * // Register multiple lexicons at once\n * registry.registerMany([lexicon1, lexicon2, lexicon3]);\n * ```\n *\n * @example Validating records\n * ```typescript\n * const result = registry.validate(\"org.example.myRecord\", {\n * title: \"Test\",\n * createdAt: new Date().toISOString(),\n * });\n *\n * if (!result.valid) {\n * console.error(`Validation failed: ${result.error}`);\n * }\n * ```\n *\n * @see https://atproto.com/specs/lexicon for the Lexicon specification\n */\nexport class LexiconRegistry {\n /** Map of lexicon ID to lexicon document */\n private lexicons = new Map<string, LexiconDoc>();\n\n /** Lexicons collection for validation */\n private lexiconsCollection: Lexicons;\n\n /**\n * Creates a new LexiconRegistry.\n *\n * The registry starts empty. Use {@link register} or {@link registerMany}\n * to add lexicons.\n */\n constructor() {\n this.lexiconsCollection = new Lexicons();\n }\n\n /**\n * Registers a single lexicon schema.\n *\n * @param lexicon - The lexicon document to register\n * @throws {@link ValidationError} if the lexicon doesn't have an `id` field\n *\n * @remarks\n * If a lexicon with the same ID is already registered, it will be\n * replaced with the new definition. This is useful for testing but\n * should generally be avoided in production.\n *\n * @example\n * ```typescript\n * registry.register({\n * lexicon: 1,\n * id: \"org.example.post\",\n * defs: {\n * main: {\n * type: \"record\",\n * key: \"tid\",\n * record: {\n * type: \"object\",\n * required: [\"text\", \"createdAt\"],\n * properties: {\n * text: { type: \"string\", maxLength: 300 },\n * createdAt: { type: \"string\", format: \"datetime\" },\n * },\n * },\n * },\n * },\n * });\n * ```\n */\n register(lexicon: LexiconDoc): void {\n if (!lexicon.id) {\n throw new ValidationError(\"Lexicon must have an 'id' field\");\n }\n\n // Remove existing lexicon if present (to allow overwriting)\n if (this.lexicons.has(lexicon.id)) {\n // Lexicons collection doesn't support removal, so we create a new one\n // This is a limitation - in practice, lexicons shouldn't be overwritten\n // But we allow it for testing and flexibility\n const existingLexicon = this.lexicons.get(lexicon.id);\n if (existingLexicon) {\n // Try to remove from collection (may fail if not supported)\n try {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n (this.lexiconsCollection as any).remove?.(lexicon.id);\n } catch {\n // If removal fails, create a new collection\n this.lexiconsCollection = new Lexicons();\n // Re-register all other lexicons\n for (const [id, lex] of this.lexicons.entries()) {\n if (id !== lexicon.id) {\n this.lexiconsCollection.add(lex);\n }\n }\n }\n }\n }\n\n this.lexicons.set(lexicon.id, lexicon);\n this.lexiconsCollection.add(lexicon);\n }\n\n /**\n * Registers multiple lexicons at once.\n *\n * @param lexicons - Array of lexicon documents to register\n *\n * @example\n * ```typescript\n * import { HYPERCERT_LEXICONS } from \"@hypercerts-org/sdk/lexicons\";\n *\n * registry.registerMany(HYPERCERT_LEXICONS);\n * ```\n */\n registerMany(lexicons: LexiconDoc[]): void {\n for (const lexicon of lexicons) {\n this.register(lexicon);\n }\n }\n\n /**\n * Gets a lexicon document by ID.\n *\n * @param id - The lexicon NSID (e.g., \"org.hypercerts.hypercert\")\n * @returns The lexicon document, or `undefined` if not registered\n *\n * @example\n * ```typescript\n * const lexicon = registry.get(\"org.hypercerts.hypercert\");\n * if (lexicon) {\n * console.log(`Found lexicon: ${lexicon.id}`);\n * }\n * ```\n */\n get(id: string): LexiconDoc | undefined {\n return this.lexicons.get(id);\n }\n\n /**\n * Validates a record against a collection's lexicon schema.\n *\n * @param collection - The collection NSID (same as lexicon ID)\n * @param record - The record data to validate\n * @returns Validation result with `valid` boolean and optional `error` message\n *\n * @remarks\n * - If no lexicon is registered for the collection, validation passes\n * (we can't validate against unknown schemas)\n * - Validation checks required fields and type constraints defined\n * in the lexicon schema\n *\n * @example\n * ```typescript\n * const result = registry.validate(\"org.hypercerts.hypercert\", {\n * title: \"My Hypercert\",\n * description: \"Description...\",\n * // ... other fields\n * });\n *\n * if (!result.valid) {\n * throw new Error(`Invalid record: ${result.error}`);\n * }\n * ```\n */\n validate(collection: string, record: unknown): ValidationResult {\n // Check if we have a lexicon registered for this collection\n // Collection format is typically \"namespace.collection\" (e.g., \"app.bsky.feed.post\")\n // Lexicon ID format is the same\n const lexiconId = collection;\n const lexicon = this.lexicons.get(lexiconId);\n if (!lexicon) {\n // No lexicon registered - validation passes (can't validate unknown schemas)\n return { valid: true };\n }\n\n // Check required fields if the lexicon defines them\n const recordDef = lexicon.defs?.record;\n if (recordDef && typeof recordDef === \"object\" && \"record\" in recordDef) {\n const recordSchema = recordDef.record;\n if (typeof recordSchema === \"object\" && \"required\" in recordSchema && Array.isArray(recordSchema.required)) {\n const recordObj = record as Record<string, unknown>;\n for (const requiredField of recordSchema.required) {\n if (typeof requiredField === \"string\" && !(requiredField in recordObj)) {\n return {\n valid: false,\n error: `Missing required field: ${requiredField}`,\n };\n }\n }\n }\n }\n\n try {\n this.lexiconsCollection.assertValidRecord(collection, record);\n return { valid: true };\n } catch (error) {\n // If error indicates lexicon not found, treat as validation pass\n // (the lexicon might exist in Agent's collection but not ours)\n const errorMessage = error instanceof Error ? error.message : String(error);\n if (errorMessage.includes(\"not found\") || errorMessage.includes(\"Lexicon not found\")) {\n return { valid: true };\n }\n return {\n valid: false,\n error: errorMessage,\n };\n }\n }\n\n /**\n * Adds all registered lexicons to an AT Protocol Agent instance.\n *\n * This allows the Agent to understand custom lexicon types when making\n * API requests.\n *\n * @param agent - The Agent instance to extend\n *\n * @remarks\n * This is called automatically when creating a Repository. You typically\n * don't need to call this directly unless you're using the Agent\n * independently.\n *\n * @internal\n */\n addToAgent(agent: Agent): void {\n // Access the internal lexicons collection and merge our lexicons\n // The Agent's lex property is a Lexicons instance\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const agentLex = (agent as any).lex as Lexicons;\n\n // Add each registered lexicon to the agent\n for (const lexicon of this.lexicons.values()) {\n agentLex.add(lexicon);\n }\n }\n\n /**\n * Gets all registered lexicon IDs.\n *\n * @returns Array of lexicon NSIDs\n *\n * @example\n * ```typescript\n * const ids = registry.getRegisteredIds();\n * console.log(`Registered lexicons: ${ids.join(\", \")}`);\n * ```\n */\n getRegisteredIds(): string[] {\n return Array.from(this.lexicons.keys());\n }\n\n /**\n * Checks if a lexicon is registered.\n *\n * @param id - The lexicon NSID to check\n * @returns `true` if the lexicon is registered\n *\n * @example\n * ```typescript\n * if (registry.has(\"org.hypercerts.hypercert\")) {\n * // Hypercert lexicon is available\n * }\n * ```\n */\n has(id: string): boolean {\n return this.lexicons.has(id);\n }\n}\n"],"names":["Lexicons"],"mappings":";;;;;AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsCG;AACG,MAAO,eAAgB,SAAQ,KAAK,CAAA;AACxC;;;;;;;AAOG;AACH,IAAA,WAAA,CACE,OAAe,EACR,IAAY,EACZ,MAAe,EACf,KAAe,EAAA;QAEtB,KAAK,CAAC,OAAO,CAAC;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AC5C,YAAA,QAAQ,CAAC,GAAG,CAAC,OAAO,CAAC;QACvB;IACF;AAEA;;;;;;;;;;AAUG;IACH,gBAAgB,GAAA;QACd,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC;IACzC;AAEA;;;;;;;;;;;;AAYG;AACH,IAAA,GAAG,CAAC,EAAU,EAAA;QACZ,OAAO,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;IAC9B;AACD;;;;;;;;;;;;"}
1
+ {"version":3,"file":"lexicons.cjs","sources":["../src/lexicons.ts"],"sourcesContent":["/**\n * Lexicons entrypoint - Lexicon definitions and registry.\n *\n * This sub-entrypoint exports the lexicon registry and hypercert\n * lexicon constants for working with AT Protocol record schemas.\n *\n * @remarks\n * Import from `@hypercerts-org/sdk/lexicons`:\n *\n * ```typescript\n * import {\n * LexiconRegistry,\n * HYPERCERT_LEXICONS,\n * HYPERCERT_COLLECTIONS,\n * } from \"@hypercerts-org/sdk/lexicons\";\n * ```\n *\n * **Exports**:\n * - {@link LexiconRegistry} - Registry for managing and validating lexicons\n * - {@link HYPERCERT_LEXICONS} - Array of all hypercert lexicon documents\n * - {@link HYPERCERT_COLLECTIONS} - Constants for collection NSIDs\n *\n * @example Using collection constants\n * ```typescript\n * import { HYPERCERT_COLLECTIONS } from \"@hypercerts-org/sdk/lexicons\";\n *\n * // List hypercerts using the correct collection name\n * const records = await repo.records.list({\n * collection: HYPERCERT_COLLECTIONS.RECORD,\n * });\n *\n * // List contributions\n * const contributions = await repo.records.list({\n * collection: HYPERCERT_COLLECTIONS.CONTRIBUTION,\n * });\n * ```\n *\n * @example Custom lexicon registration\n * ```typescript\n * import { LexiconRegistry } from \"@hypercerts-org/sdk/lexicons\";\n *\n * const registry = sdk.getLexiconRegistry();\n *\n * // Register custom lexicon\n * registry.register({\n * lexicon: 1,\n * id: \"org.myapp.customRecord\",\n * defs: { ... },\n * });\n *\n * // Validate a record\n * const result = registry.validate(\"org.myapp.customRecord\", record);\n * if (!result.valid) {\n * console.error(result.error);\n * }\n * ```\n *\n * @packageDocumentation\n */\n\n// Import lexicon JSON files and constants from the published package\nimport type { LexiconDoc } from \"@atproto/lexicon\";\nimport {\n CERTIFIED_DEFS_LEXICON_JSON,\n LOCATION_LEXICON_JSON,\n STRONGREF_LEXICON_JSON,\n HYPERCERTS_DEFS_LEXICON_JSON,\n ACTIVITY_LEXICON_JSON,\n COLLECTION_LEXICON_JSON,\n CONTRIBUTION_LEXICON_JSON,\n EVALUATION_LEXICON_JSON,\n EVIDENCE_LEXICON_JSON,\n MEASUREMENT_LEXICON_JSON,\n RIGHTS_LEXICON_JSON,\n PROJECT_LEXICON_JSON,\n BADGE_AWARD_LEXICON_JSON,\n BADGE_DEFINITION_LEXICON_JSON,\n BADGE_RESPONSE_LEXICON_JSON,\n FUNDING_RECEIPT_LEXICON_JSON,\n // NSID constants\n ACTIVITY_NSID,\n RIGHTS_NSID,\n LOCATION_NSID,\n CONTRIBUTION_NSID,\n MEASUREMENT_NSID,\n EVALUATION_NSID,\n EVIDENCE_NSID,\n COLLECTION_NSID,\n PROJECT_NSID,\n BADGE_AWARD_NSID,\n BADGE_DEFINITION_NSID,\n BADGE_RESPONSE_NSID,\n FUNDING_RECEIPT_NSID,\n} from \"@hypercerts-org/lexicon\";\n\n/**\n * All hypercert-related lexicons for registration with AT Protocol Agent.\n * This array contains all lexicon documents from the published package.\n */\nexport const HYPERCERT_LEXICONS: LexiconDoc[] = [\n CERTIFIED_DEFS_LEXICON_JSON as LexiconDoc,\n LOCATION_LEXICON_JSON as LexiconDoc,\n STRONGREF_LEXICON_JSON as LexiconDoc,\n HYPERCERTS_DEFS_LEXICON_JSON as LexiconDoc,\n ACTIVITY_LEXICON_JSON as LexiconDoc,\n COLLECTION_LEXICON_JSON as LexiconDoc,\n CONTRIBUTION_LEXICON_JSON as LexiconDoc,\n EVALUATION_LEXICON_JSON as LexiconDoc,\n EVIDENCE_LEXICON_JSON as LexiconDoc,\n MEASUREMENT_LEXICON_JSON as LexiconDoc,\n RIGHTS_LEXICON_JSON as LexiconDoc,\n PROJECT_LEXICON_JSON as LexiconDoc,\n BADGE_AWARD_LEXICON_JSON as LexiconDoc,\n BADGE_DEFINITION_LEXICON_JSON as LexiconDoc,\n BADGE_RESPONSE_LEXICON_JSON as LexiconDoc,\n FUNDING_RECEIPT_LEXICON_JSON as LexiconDoc,\n];\n\n/**\n * Collection NSIDs (Namespaced Identifiers) for hypercert records.\n *\n * Use these constants when performing record operations to ensure\n * correct collection names.\n */\nexport const HYPERCERT_COLLECTIONS = {\n /**\n * Main hypercert claim record collection.\n */\n CLAIM: ACTIVITY_NSID,\n\n /**\n * Rights record collection.\n */\n RIGHTS: RIGHTS_NSID,\n\n /**\n * Location record collection (shared certified lexicon).\n */\n LOCATION: LOCATION_NSID,\n\n /**\n * Contribution record collection.\n */\n CONTRIBUTION: CONTRIBUTION_NSID,\n\n /**\n * Measurement record collection.\n */\n MEASUREMENT: MEASUREMENT_NSID,\n\n /**\n * Evaluation record collection.\n */\n EVALUATION: EVALUATION_NSID,\n\n /**\n * Evidence record collection.\n */\n EVIDENCE: EVIDENCE_NSID,\n\n /**\n * Collection record collection (groups of hypercerts).\n */\n COLLECTION: COLLECTION_NSID,\n\n /**\n * Project record collection.\n */\n PROJECT: PROJECT_NSID,\n\n /**\n * Badge award record collection.\n */\n BADGE_AWARD: BADGE_AWARD_NSID,\n\n /**\n * Badge definition record collection.\n */\n BADGE_DEFINITION: BADGE_DEFINITION_NSID,\n\n /**\n * Badge response record collection.\n */\n BADGE_RESPONSE: BADGE_RESPONSE_NSID,\n\n /**\n * Funding receipt record collection.\n */\n FUNDING_RECEIPT: FUNDING_RECEIPT_NSID,\n} as const;\n"],"names":["CERTIFIED_DEFS_LEXICON_JSON","LOCATION_LEXICON_JSON","STRONGREF_LEXICON_JSON","HYPERCERTS_DEFS_LEXICON_JSON","ACTIVITY_LEXICON_JSON","COLLECTION_LEXICON_JSON","CONTRIBUTION_LEXICON_JSON","EVALUATION_LEXICON_JSON","EVIDENCE_LEXICON_JSON","MEASUREMENT_LEXICON_JSON","RIGHTS_LEXICON_JSON","PROJECT_LEXICON_JSON","BADGE_AWARD_LEXICON_JSON","BADGE_DEFINITION_LEXICON_JSON","BADGE_RESPONSE_LEXICON_JSON","FUNDING_RECEIPT_LEXICON_JSON","ACTIVITY_NSID","RIGHTS_NSID","LOCATION_NSID","CONTRIBUTION_NSID","MEASUREMENT_NSID","EVALUATION_NSID","EVIDENCE_NSID","COLLECTION_NSID","PROJECT_NSID","BADGE_AWARD_NSID","BADGE_DEFINITION_NSID","BADGE_RESPONSE_NSID","FUNDING_RECEIPT_NSID"],"mappings":";;;;AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0DG;AAqCH;;;AAGG;AACI,MAAM,kBAAkB,GAAiB;IAC9CA,mCAAyC;IACzCC,6BAAmC;IACnCC,8BAAoC;IACpCC,oCAA0C;IAC1CC,6BAAmC;IACnCC,+BAAqC;IACrCC,iCAAuC;IACvCC,+BAAqC;IACrCC,6BAAmC;IACnCC,gCAAsC;IACtCC,2BAAiC;IACjCC,4BAAkC;IAClCC,gCAAsC;IACtCC,qCAA2C;IAC3CC,mCAAyC;IACzCC,oCAA0C;;AAG5C;;;;;AAKG;AACI,MAAM,qBAAqB,GAAG;AACnC;;AAEG;AACH,IAAA,KAAK,EAAEC,qBAAa;AAEpB;;AAEG;AACH,IAAA,MAAM,EAAEC,mBAAW;AAEnB;;AAEG;AACH,IAAA,QAAQ,EAAEC,qBAAa;AAEvB;;AAEG;AACH,IAAA,YAAY,EAAEC,yBAAiB;AAE/B;;AAEG;AACH,IAAA,WAAW,EAAEC,wBAAgB;AAE7B;;AAEG;AACH,IAAA,UAAU,EAAEC,uBAAe;AAE3B;;AAEG;AACH,IAAA,QAAQ,EAAEC,qBAAa;AAEvB;;AAEG;AACH,IAAA,UAAU,EAAEC,uBAAe;AAE3B;;AAEG;AACH,IAAA,OAAO,EAAEC,oBAAY;AAErB;;AAEG;AACH,IAAA,WAAW,EAAEC,wBAAgB;AAE7B;;AAEG;AACH,IAAA,gBAAgB,EAAEC,6BAAqB;AAEvC;;AAEG;AACH,IAAA,cAAc,EAAEC,2BAAmB;AAEnC;;AAEG;AACH,IAAA,eAAe,EAAEC,4BAAoB;;;;;;"}