@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.
Files changed (110) hide show
  1. package/README.md +126 -13
  2. package/dist/exports.d.ts +1018 -0
  3. package/dist/exports.d.ts.map +1 -0
  4. package/dist/generated/exports.d.ts +1018 -0
  5. package/dist/generated/exports.d.ts.map +1 -0
  6. package/dist/generated/lexicons.d.ts +1805 -0
  7. package/dist/generated/lexicons.d.ts.map +1 -0
  8. package/dist/generated/types/app/certified/badge/award.d.ts +24 -0
  9. package/dist/generated/types/app/certified/badge/award.d.ts.map +1 -0
  10. package/dist/generated/types/app/certified/badge/definition.d.ts +25 -0
  11. package/dist/generated/types/app/certified/badge/definition.d.ts.map +1 -0
  12. package/dist/generated/types/app/certified/badge/response.d.ts +20 -0
  13. package/dist/generated/types/app/certified/badge/response.d.ts.map +1 -0
  14. package/dist/generated/types/app/certified/defs.d.ts +3 -0
  15. package/dist/generated/types/app/certified/defs.d.ts.map +1 -0
  16. package/dist/generated/types/app/certified/location.d.ts +29 -0
  17. package/dist/generated/types/app/certified/location.d.ts.map +1 -0
  18. package/dist/generated/types/com/atproto/repo/strongRef.d.ts +12 -0
  19. package/dist/generated/types/com/atproto/repo/strongRef.d.ts.map +1 -0
  20. package/dist/generated/types/org/hypercerts/claim/activity.d.ts +57 -0
  21. package/dist/generated/types/org/hypercerts/claim/activity.d.ts.map +1 -0
  22. package/dist/generated/types/org/hypercerts/claim/collection.d.ts +25 -0
  23. package/dist/generated/types/org/hypercerts/claim/collection.d.ts.map +1 -0
  24. package/dist/generated/types/org/hypercerts/claim/contribution.d.ts +24 -0
  25. package/dist/generated/types/org/hypercerts/claim/contribution.d.ts.map +1 -0
  26. package/dist/generated/types/org/hypercerts/claim/evaluation.d.ts +43 -0
  27. package/dist/generated/types/org/hypercerts/claim/evaluation.d.ts.map +1 -0
  28. package/dist/generated/types/org/hypercerts/claim/evidence.d.ts +29 -0
  29. package/dist/generated/types/org/hypercerts/claim/evidence.d.ts.map +1 -0
  30. package/dist/generated/types/org/hypercerts/claim/measurement.d.ts +30 -0
  31. package/dist/generated/types/org/hypercerts/claim/measurement.d.ts.map +1 -0
  32. package/dist/generated/types/org/hypercerts/claim/project.d.ts +29 -0
  33. package/dist/generated/types/org/hypercerts/claim/project.d.ts.map +1 -0
  34. package/dist/generated/types/org/hypercerts/claim/rights.d.ts +25 -0
  35. package/dist/generated/types/org/hypercerts/claim/rights.d.ts.map +1 -0
  36. package/dist/generated/types/org/hypercerts/defs.d.ts +45 -0
  37. package/dist/generated/types/org/hypercerts/defs.d.ts.map +1 -0
  38. package/dist/generated/types/org/hypercerts/funding/receipt.d.ts +34 -0
  39. package/dist/generated/types/org/hypercerts/funding/receipt.d.ts.map +1 -0
  40. package/dist/generated/types/pub/leaflet/pages/linearDocument.d.ts +2 -0
  41. package/dist/generated/types/pub/leaflet/pages/linearDocument.d.ts.map +1 -0
  42. package/dist/generated/util.d.ts +37 -0
  43. package/dist/generated/util.d.ts.map +1 -0
  44. package/dist/index.cjs +2636 -0
  45. package/dist/index.cjs.map +1 -0
  46. package/dist/index.mjs +2560 -0
  47. package/dist/index.mjs.map +1 -0
  48. package/dist/lexicons.cjs +1002 -0
  49. package/dist/lexicons.cjs.map +1 -0
  50. package/dist/lexicons.d.ts +1805 -0
  51. package/dist/lexicons.d.ts.map +1 -0
  52. package/dist/lexicons.mjs +996 -0
  53. package/dist/lexicons.mjs.map +1 -0
  54. package/dist/types/app/certified/badge/award.d.ts +24 -0
  55. package/dist/types/app/certified/badge/award.d.ts.map +1 -0
  56. package/dist/types/app/certified/badge/definition.d.ts +25 -0
  57. package/dist/types/app/certified/badge/definition.d.ts.map +1 -0
  58. package/dist/types/app/certified/badge/response.d.ts +20 -0
  59. package/dist/types/app/certified/badge/response.d.ts.map +1 -0
  60. package/dist/types/app/certified/defs.d.ts +3 -0
  61. package/dist/types/app/certified/defs.d.ts.map +1 -0
  62. package/dist/types/app/certified/location.d.ts +29 -0
  63. package/dist/types/app/certified/location.d.ts.map +1 -0
  64. package/dist/types/com/atproto/repo/strongRef.d.ts +12 -0
  65. package/dist/types/com/atproto/repo/strongRef.d.ts.map +1 -0
  66. package/dist/types/org/hypercerts/claim/activity.d.ts +57 -0
  67. package/dist/types/org/hypercerts/claim/activity.d.ts.map +1 -0
  68. package/dist/types/org/hypercerts/claim/collection.d.ts +25 -0
  69. package/dist/types/org/hypercerts/claim/collection.d.ts.map +1 -0
  70. package/dist/types/org/hypercerts/claim/contribution.d.ts +24 -0
  71. package/dist/types/org/hypercerts/claim/contribution.d.ts.map +1 -0
  72. package/dist/types/org/hypercerts/claim/evaluation.d.ts +43 -0
  73. package/dist/types/org/hypercerts/claim/evaluation.d.ts.map +1 -0
  74. package/dist/types/org/hypercerts/claim/evidence.d.ts +29 -0
  75. package/dist/types/org/hypercerts/claim/evidence.d.ts.map +1 -0
  76. package/dist/types/org/hypercerts/claim/measurement.d.ts +30 -0
  77. package/dist/types/org/hypercerts/claim/measurement.d.ts.map +1 -0
  78. package/dist/types/org/hypercerts/claim/project.d.ts +29 -0
  79. package/dist/types/org/hypercerts/claim/project.d.ts.map +1 -0
  80. package/dist/types/org/hypercerts/claim/rights.d.ts +25 -0
  81. package/dist/types/org/hypercerts/claim/rights.d.ts.map +1 -0
  82. package/dist/types/org/hypercerts/defs.d.ts +45 -0
  83. package/dist/types/org/hypercerts/defs.d.ts.map +1 -0
  84. package/dist/types/org/hypercerts/funding/receipt.d.ts +34 -0
  85. package/dist/types/org/hypercerts/funding/receipt.d.ts.map +1 -0
  86. package/dist/types/pub/leaflet/pages/linearDocument.d.ts +2 -0
  87. package/dist/types/pub/leaflet/pages/linearDocument.d.ts.map +1 -0
  88. package/dist/util.d.ts +37 -0
  89. package/dist/util.d.ts.map +1 -0
  90. package/package.json +48 -21
  91. package/README.md.orig +0 -267
  92. package/types/index.ts +0 -1257
  93. package/types/lexicons.ts +0 -1071
  94. package/types/types/app/certified/badge/award.ts +0 -48
  95. package/types/types/app/certified/badge/definition.ts +0 -49
  96. package/types/types/app/certified/badge/response.ts +0 -44
  97. package/types/types/app/certified/defs.ts +0 -14
  98. package/types/types/app/certified/location.ts +0 -49
  99. package/types/types/com/atproto/repo/strongRef.ts +0 -31
  100. package/types/types/org/hypercerts/claim/activity.ts +0 -99
  101. package/types/types/org/hypercerts/claim/collection.ts +0 -49
  102. package/types/types/org/hypercerts/claim/contribution.ts +0 -48
  103. package/types/types/org/hypercerts/claim/evaluation.ts +0 -77
  104. package/types/types/org/hypercerts/claim/evidence.ts +0 -53
  105. package/types/types/org/hypercerts/claim/measurement.ts +0 -54
  106. package/types/types/org/hypercerts/claim/project.ts +0 -53
  107. package/types/types/org/hypercerts/claim/rights.ts +0 -49
  108. package/types/types/org/hypercerts/defs.ts +0 -96
  109. package/types/types/org/hypercerts/funding/receipt.ts +0 -58
  110. 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 i @hypercerts-org/lexicon
41
+ npm install @hypercerts-org/lexicon
42
42
  ```
43
43
 
44
44
  ## Usage
45
45
 
46
+ ### Basic Import
47
+
46
48
  ```typescript
47
- import { AtpBaseClient } from "@hypercerts-org/lexicon";
48
- import type { HypercertClaim } from "@hypercerts-org/lexicon";
49
+ import {
50
+ HYPERCERTS_SCHEMAS,
51
+ ACTIVITY_NSID,
52
+ validate,
53
+ } from "@hypercerts-org/lexicon";
49
54
 
50
- const client = new AtpBaseClient({
51
- service: "https://bsky.social",
52
- headers: { Authorization: `Bearer ${token}` },
53
- });
55
+ // Use with AT Protocol Agent
56
+ import { Agent } from "@atproto/api";
54
57
 
55
- const hypercert: HypercertClaim = {
56
- $type: "org.hypercerts.claim.activity",
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
- await client.org.hypercerts.claim.activity.create(
66
- { repo: "did:plc:example" },
67
- hypercert,
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