@hypercerts-org/lexicon 0.10.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/README.md +126 -13
- package/dist/exports.d.ts +1018 -0
- package/dist/exports.d.ts.map +1 -0
- package/dist/generated/exports.d.ts +1018 -0
- package/dist/generated/exports.d.ts.map +1 -0
- package/dist/generated/lexicons.d.ts +1805 -0
- package/dist/generated/lexicons.d.ts.map +1 -0
- package/dist/generated/types/app/certified/badge/award.d.ts +24 -0
- package/dist/generated/types/app/certified/badge/award.d.ts.map +1 -0
- package/dist/generated/types/app/certified/badge/definition.d.ts +25 -0
- package/dist/generated/types/app/certified/badge/definition.d.ts.map +1 -0
- package/dist/generated/types/app/certified/badge/response.d.ts +20 -0
- package/dist/generated/types/app/certified/badge/response.d.ts.map +1 -0
- package/dist/generated/types/app/certified/defs.d.ts +3 -0
- package/dist/generated/types/app/certified/defs.d.ts.map +1 -0
- package/dist/generated/types/app/certified/location.d.ts +29 -0
- package/dist/generated/types/app/certified/location.d.ts.map +1 -0
- package/dist/generated/types/com/atproto/repo/strongRef.d.ts +12 -0
- package/dist/generated/types/com/atproto/repo/strongRef.d.ts.map +1 -0
- package/dist/generated/types/org/hypercerts/claim/activity.d.ts +57 -0
- package/dist/generated/types/org/hypercerts/claim/activity.d.ts.map +1 -0
- package/dist/generated/types/org/hypercerts/claim/collection.d.ts +25 -0
- package/dist/generated/types/org/hypercerts/claim/collection.d.ts.map +1 -0
- package/dist/generated/types/org/hypercerts/claim/contribution.d.ts +24 -0
- package/dist/generated/types/org/hypercerts/claim/contribution.d.ts.map +1 -0
- package/dist/generated/types/org/hypercerts/claim/evaluation.d.ts +43 -0
- package/dist/generated/types/org/hypercerts/claim/evaluation.d.ts.map +1 -0
- package/dist/generated/types/org/hypercerts/claim/evidence.d.ts +29 -0
- package/dist/generated/types/org/hypercerts/claim/evidence.d.ts.map +1 -0
- package/dist/generated/types/org/hypercerts/claim/measurement.d.ts +30 -0
- package/dist/generated/types/org/hypercerts/claim/measurement.d.ts.map +1 -0
- package/dist/generated/types/org/hypercerts/claim/project.d.ts +29 -0
- package/dist/generated/types/org/hypercerts/claim/project.d.ts.map +1 -0
- package/dist/generated/types/org/hypercerts/claim/rights.d.ts +25 -0
- package/dist/generated/types/org/hypercerts/claim/rights.d.ts.map +1 -0
- package/dist/generated/types/org/hypercerts/defs.d.ts +45 -0
- package/dist/generated/types/org/hypercerts/defs.d.ts.map +1 -0
- package/dist/generated/types/org/hypercerts/funding/receipt.d.ts +34 -0
- package/dist/generated/types/org/hypercerts/funding/receipt.d.ts.map +1 -0
- package/dist/generated/types/pub/leaflet/pages/linearDocument.d.ts +2 -0
- package/dist/generated/types/pub/leaflet/pages/linearDocument.d.ts.map +1 -0
- package/dist/generated/util.d.ts +37 -0
- package/dist/generated/util.d.ts.map +1 -0
- package/dist/index.cjs +2636 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.mjs +2560 -0
- package/dist/index.mjs.map +1 -0
- package/dist/lexicons.cjs +1002 -0
- package/dist/lexicons.cjs.map +1 -0
- package/dist/lexicons.d.ts +1805 -0
- package/dist/lexicons.d.ts.map +1 -0
- package/dist/lexicons.mjs +996 -0
- package/dist/lexicons.mjs.map +1 -0
- package/dist/types/app/certified/badge/award.d.ts +24 -0
- package/dist/types/app/certified/badge/award.d.ts.map +1 -0
- package/dist/types/app/certified/badge/definition.d.ts +25 -0
- package/dist/types/app/certified/badge/definition.d.ts.map +1 -0
- package/dist/types/app/certified/badge/response.d.ts +20 -0
- package/dist/types/app/certified/badge/response.d.ts.map +1 -0
- package/dist/types/app/certified/defs.d.ts +3 -0
- package/dist/types/app/certified/defs.d.ts.map +1 -0
- package/dist/types/app/certified/location.d.ts +29 -0
- package/dist/types/app/certified/location.d.ts.map +1 -0
- package/dist/types/com/atproto/repo/strongRef.d.ts +12 -0
- package/dist/types/com/atproto/repo/strongRef.d.ts.map +1 -0
- package/dist/types/org/hypercerts/claim/activity.d.ts +57 -0
- package/dist/types/org/hypercerts/claim/activity.d.ts.map +1 -0
- package/dist/types/org/hypercerts/claim/collection.d.ts +25 -0
- package/dist/types/org/hypercerts/claim/collection.d.ts.map +1 -0
- package/dist/types/org/hypercerts/claim/contribution.d.ts +24 -0
- package/dist/types/org/hypercerts/claim/contribution.d.ts.map +1 -0
- package/dist/types/org/hypercerts/claim/evaluation.d.ts +43 -0
- package/dist/types/org/hypercerts/claim/evaluation.d.ts.map +1 -0
- package/dist/types/org/hypercerts/claim/evidence.d.ts +29 -0
- package/dist/types/org/hypercerts/claim/evidence.d.ts.map +1 -0
- package/dist/types/org/hypercerts/claim/measurement.d.ts +30 -0
- package/dist/types/org/hypercerts/claim/measurement.d.ts.map +1 -0
- package/dist/types/org/hypercerts/claim/project.d.ts +29 -0
- package/dist/types/org/hypercerts/claim/project.d.ts.map +1 -0
- package/dist/types/org/hypercerts/claim/rights.d.ts +25 -0
- package/dist/types/org/hypercerts/claim/rights.d.ts.map +1 -0
- package/dist/types/org/hypercerts/defs.d.ts +45 -0
- package/dist/types/org/hypercerts/defs.d.ts.map +1 -0
- package/dist/types/org/hypercerts/funding/receipt.d.ts +34 -0
- package/dist/types/org/hypercerts/funding/receipt.d.ts.map +1 -0
- package/dist/types/pub/leaflet/pages/linearDocument.d.ts +2 -0
- package/dist/types/pub/leaflet/pages/linearDocument.d.ts.map +1 -0
- package/dist/util.d.ts +37 -0
- package/dist/util.d.ts.map +1 -0
- package/package.json +48 -21
- package/README.md.orig +0 -267
- package/types/index.ts +0 -1257
- package/types/lexicons.ts +0 -1071
- package/types/types/app/certified/badge/award.ts +0 -48
- package/types/types/app/certified/badge/definition.ts +0 -49
- package/types/types/app/certified/badge/response.ts +0 -44
- package/types/types/app/certified/defs.ts +0 -14
- package/types/types/app/certified/location.ts +0 -49
- package/types/types/com/atproto/repo/strongRef.ts +0 -31
- package/types/types/org/hypercerts/claim/activity.ts +0 -99
- package/types/types/org/hypercerts/claim/collection.ts +0 -49
- package/types/types/org/hypercerts/claim/contribution.ts +0 -48
- package/types/types/org/hypercerts/claim/evaluation.ts +0 -77
- package/types/types/org/hypercerts/claim/evidence.ts +0 -53
- package/types/types/org/hypercerts/claim/measurement.ts +0 -54
- package/types/types/org/hypercerts/claim/project.ts +0 -53
- package/types/types/org/hypercerts/claim/rights.ts +0 -49
- package/types/types/org/hypercerts/defs.ts +0 -96
- package/types/types/org/hypercerts/funding/receipt.ts +0 -58
- package/types/util.ts +0 -82
package/README.md
CHANGED
|
@@ -38,22 +38,31 @@ following icons:
|
|
|
38
38
|
## Installation
|
|
39
39
|
|
|
40
40
|
```bash
|
|
41
|
-
npm
|
|
41
|
+
npm install @hypercerts-org/lexicon
|
|
42
42
|
```
|
|
43
43
|
|
|
44
44
|
## Usage
|
|
45
45
|
|
|
46
|
+
### Basic Import
|
|
47
|
+
|
|
46
48
|
```typescript
|
|
47
|
-
import {
|
|
48
|
-
|
|
49
|
+
import {
|
|
50
|
+
HYPERCERTS_SCHEMAS,
|
|
51
|
+
ACTIVITY_NSID,
|
|
52
|
+
validate,
|
|
53
|
+
} from "@hypercerts-org/lexicon";
|
|
49
54
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
headers: { Authorization: `Bearer ${token}` },
|
|
53
|
-
});
|
|
55
|
+
// Use with AT Protocol Agent
|
|
56
|
+
import { Agent } from "@atproto/api";
|
|
54
57
|
|
|
55
|
-
const
|
|
56
|
-
|
|
58
|
+
const agent = new Agent({ service: "https://bsky.social" });
|
|
59
|
+
|
|
60
|
+
// Register lexicons with the agent
|
|
61
|
+
agent.api.lex.add(...HYPERCERTS_SCHEMAS);
|
|
62
|
+
|
|
63
|
+
// Create a record
|
|
64
|
+
const activityRecord = {
|
|
65
|
+
$type: ACTIVITY_NSID,
|
|
57
66
|
title: "My Impact Work",
|
|
58
67
|
shortDescription: "Description here",
|
|
59
68
|
workScope: "Scope of work",
|
|
@@ -62,10 +71,114 @@ const hypercert: HypercertClaim = {
|
|
|
62
71
|
createdAt: new Date().toISOString(),
|
|
63
72
|
};
|
|
64
73
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
);
|
|
74
|
+
// Validate before creating
|
|
75
|
+
const validation = validate(ACTIVITY_NSID, activityRecord);
|
|
76
|
+
if (!validation.valid) {
|
|
77
|
+
console.error("Validation failed:", validation.errors);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
await agent.api.com.atproto.repo.createRecord({
|
|
81
|
+
repo: agent.session?.did,
|
|
82
|
+
collection: ACTIVITY_NSID,
|
|
83
|
+
record: activityRecord,
|
|
84
|
+
});
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
### Accessing NSIDs (Lexicon IDs)
|
|
88
|
+
|
|
89
|
+
**Recommended**: Use individual NSID constants for cleaner, more readable code:
|
|
90
|
+
|
|
91
|
+
```typescript
|
|
92
|
+
import { ACTIVITY_NSID, COLLECTION_NSID } from "@hypercerts-org/lexicon";
|
|
93
|
+
|
|
94
|
+
// Clean and explicit
|
|
95
|
+
const record = {
|
|
96
|
+
$type: ACTIVITY_NSID,
|
|
97
|
+
// ...
|
|
98
|
+
};
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
**Alternative**: Use the semantic NSID object when you need multiple NSIDs:
|
|
102
|
+
|
|
103
|
+
```typescript
|
|
104
|
+
import { HYPERCERTS_NSIDS } from "@hypercerts-org/lexicon";
|
|
105
|
+
|
|
106
|
+
// Access via semantic keys
|
|
107
|
+
const activityId = HYPERCERTS_NSIDS.ACTIVITY;
|
|
108
|
+
const collectionId = HYPERCERTS_NSIDS.COLLECTION;
|
|
109
|
+
const rightsId = HYPERCERTS_NSIDS.RIGHTS;
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
**Type-based mapping**: If you need to map TypeScript type namespaces to NSIDs:
|
|
113
|
+
|
|
114
|
+
```typescript
|
|
115
|
+
import { HYPERCERTS_NSIDS_BY_TYPE } from "@hypercerts-org/lexicon";
|
|
116
|
+
|
|
117
|
+
// Access via type namespace names
|
|
118
|
+
const activityId = HYPERCERTS_NSIDS_BY_TYPE.OrgHypercertsClaimActivity;
|
|
119
|
+
const collectionId = HYPERCERTS_NSIDS_BY_TYPE.OrgHypercertsClaimCollection;
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
**Lightweight Bundle**: Import from `/lexicons` for runtime validation without TypeScript types (smaller bundle size):
|
|
123
|
+
|
|
124
|
+
```typescript
|
|
125
|
+
import { schemas, validate, ids } from "@hypercerts-org/lexicon/lexicons";
|
|
126
|
+
|
|
127
|
+
// Lighter bundle, type-based namespace access
|
|
128
|
+
const result = validate(ids.OrgHypercertsClaimActivity, record);
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
**Note**: Individual constants (e.g., `ACTIVITY_NSID`) are the recommended approach for most use cases as they provide the best developer experience with clear, concise naming.
|
|
132
|
+
|
|
133
|
+
### TypeScript Types
|
|
134
|
+
|
|
135
|
+
All lexicon types are exported as namespaces:
|
|
136
|
+
|
|
137
|
+
```typescript
|
|
138
|
+
import { OrgHypercertsClaimActivity } from "@hypercerts-org/lexicon";
|
|
139
|
+
|
|
140
|
+
// Use the Main type
|
|
141
|
+
const activity: OrgHypercertsClaimActivity.Main = {
|
|
142
|
+
$type: "org.hypercerts.claim.activity",
|
|
143
|
+
title: "My Impact Work",
|
|
144
|
+
// ... other fields
|
|
145
|
+
};
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
### Individual Lexicon Imports
|
|
149
|
+
|
|
150
|
+
Each lexicon is available in two forms as individual constants:
|
|
151
|
+
|
|
152
|
+
```typescript
|
|
153
|
+
import {
|
|
154
|
+
// Raw JSON (untyped) - direct import from JSON files
|
|
155
|
+
ACTIVITY_LEXICON_JSON,
|
|
156
|
+
RIGHTS_LEXICON_JSON,
|
|
157
|
+
|
|
158
|
+
// Typed LexiconDoc - from lexicons.get() at module initialization
|
|
159
|
+
ACTIVITY_LEXICON_DOC,
|
|
160
|
+
RIGHTS_LEXICON_DOC,
|
|
161
|
+
} from "@hypercerts-org/lexicon";
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
| Suffix | Type | Source | Use Case |
|
|
165
|
+
| ------- | -------------------- | ------------------------- | ------------------------------ |
|
|
166
|
+
| `_JSON` | Untyped JSON | Direct JSON import | Raw schema data |
|
|
167
|
+
| `_DOC` | `LexiconDoc` (typed) | `lexicons.get()` instance | Type-safe lexicon manipulation |
|
|
168
|
+
|
|
169
|
+
Or access all lexicons via semantic mapping objects:
|
|
170
|
+
|
|
171
|
+
```typescript
|
|
172
|
+
import {
|
|
173
|
+
HYPERCERTS_LEXICON_JSON,
|
|
174
|
+
HYPERCERTS_LEXICON_DOC,
|
|
175
|
+
} from "@hypercerts-org/lexicon";
|
|
176
|
+
|
|
177
|
+
// Access via semantic keys (same keys as HYPERCERTS_NSIDS)
|
|
178
|
+
const activityJSON = HYPERCERTS_LEXICON_JSON.ACTIVITY;
|
|
179
|
+
const activityDoc = HYPERCERTS_LEXICON_DOC.ACTIVITY;
|
|
180
|
+
const rightsJSON = HYPERCERTS_LEXICON_JSON.RIGHTS;
|
|
181
|
+
const rightsDoc = HYPERCERTS_LEXICON_DOC.RIGHTS;
|
|
69
182
|
```
|
|
70
183
|
|
|
71
184
|
## Certified Lexicons
|