@hypercerts-org/lexicon 0.8.0-beta.0 → 0.10.0-beta.0
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 +249 -180
- package/README.md.orig +267 -0
- package/lexicons/app/certified/badge/award.json +36 -0
- package/lexicons/app/certified/badge/definition.json +53 -0
- package/lexicons/app/certified/badge/response.json +36 -0
- package/lexicons/app/certified/defs.json +4 -16
- package/lexicons/app/certified/location.json +5 -8
- package/lexicons/com/atproto/repo/strongRef.json +1 -1
- package/lexicons/org/hypercerts/claim/activity.json +135 -0
- package/lexicons/org/hypercerts/claim/collection.json +54 -0
- package/lexicons/org/hypercerts/claim/contribution.json +4 -11
- package/lexicons/org/hypercerts/claim/evaluation.json +50 -9
- package/lexicons/org/hypercerts/claim/evidence.json +29 -16
- package/lexicons/org/hypercerts/claim/measurement.json +18 -8
- package/lexicons/org/hypercerts/claim/project.json +64 -0
- package/lexicons/org/hypercerts/claim/rights.json +16 -3
- package/lexicons/org/hypercerts/defs.json +71 -0
- package/lexicons/org/hypercerts/funding/receipt.json +66 -0
- package/package.json +31 -38
- package/types/index.ts +1257 -0
- package/types/lexicons.ts +1071 -0
- package/types/types/app/certified/badge/award.ts +48 -0
- package/types/types/app/certified/badge/definition.ts +49 -0
- package/types/types/app/certified/badge/response.ts +44 -0
- package/types/types/app/certified/defs.ts +14 -0
- package/types/types/app/certified/location.ts +49 -0
- package/types/types/com/atproto/repo/strongRef.ts +31 -0
- package/types/types/org/hypercerts/claim/activity.ts +99 -0
- package/types/types/org/hypercerts/claim/collection.ts +49 -0
- package/types/types/org/hypercerts/claim/contribution.ts +48 -0
- package/types/types/org/hypercerts/claim/evaluation.ts +77 -0
- package/types/types/org/hypercerts/claim/evidence.ts +53 -0
- package/types/types/org/hypercerts/claim/measurement.ts +54 -0
- package/types/types/org/hypercerts/claim/project.ts +53 -0
- package/types/types/org/hypercerts/claim/rights.ts +49 -0
- package/types/types/org/hypercerts/defs.ts +96 -0
- package/types/types/org/hypercerts/funding/receipt.ts +58 -0
- package/types/util.ts +82 -0
- package/dist/index.cjs +0 -1472
- package/dist/index.cjs.map +0 -1
- package/dist/index.d.ts +0 -2094
- package/dist/index.mjs +0 -1441
- package/dist/index.mjs.map +0 -1
- package/lexicons/org/hypercerts/claim.json +0 -95
- package/lexicons/org/hypercerts/collection.json +0 -62
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* GENERATED CODE - DO NOT MODIFY
|
|
3
|
+
*/
|
|
4
|
+
import { type ValidationResult, BlobRef } from '@atproto/lexicon'
|
|
5
|
+
import { CID } from 'multiformats/cid'
|
|
6
|
+
import { validate as _validate } from '../../../../lexicons'
|
|
7
|
+
import {
|
|
8
|
+
type $Typed,
|
|
9
|
+
is$typed as _is$typed,
|
|
10
|
+
type OmitKey,
|
|
11
|
+
} from '../../../../util'
|
|
12
|
+
import type * as OrgHypercertsDefs from '../defs.js'
|
|
13
|
+
|
|
14
|
+
const is$typed = _is$typed,
|
|
15
|
+
validate = _validate
|
|
16
|
+
const id = 'org.hypercerts.claim.rights'
|
|
17
|
+
|
|
18
|
+
export interface Main {
|
|
19
|
+
$type: 'org.hypercerts.claim.rights'
|
|
20
|
+
/** Full name of the rights */
|
|
21
|
+
rightsName: string
|
|
22
|
+
/** Short rights identifier for easier search */
|
|
23
|
+
rightsType: string
|
|
24
|
+
/** Description of the rights of this hypercert */
|
|
25
|
+
rightsDescription: string
|
|
26
|
+
attachment?:
|
|
27
|
+
| $Typed<OrgHypercertsDefs.Uri>
|
|
28
|
+
| $Typed<OrgHypercertsDefs.SmallBlob>
|
|
29
|
+
| { $type: string }
|
|
30
|
+
/** Client-declared timestamp when this record was originally created */
|
|
31
|
+
createdAt: string
|
|
32
|
+
[k: string]: unknown
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const hashMain = 'main'
|
|
36
|
+
|
|
37
|
+
export function isMain<V>(v: V) {
|
|
38
|
+
return is$typed(v, id, hashMain)
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export function validateMain<V>(v: V) {
|
|
42
|
+
return validate<Main & V>(v, id, hashMain, true)
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export {
|
|
46
|
+
type Main as Record,
|
|
47
|
+
isMain as isRecord,
|
|
48
|
+
validateMain as validateRecord,
|
|
49
|
+
}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* GENERATED CODE - DO NOT MODIFY
|
|
3
|
+
*/
|
|
4
|
+
import { type ValidationResult, BlobRef } from '@atproto/lexicon'
|
|
5
|
+
import { CID } from 'multiformats/cid'
|
|
6
|
+
import { validate as _validate } from '../../../lexicons'
|
|
7
|
+
import { type $Typed, is$typed as _is$typed, type OmitKey } from '../../../util'
|
|
8
|
+
|
|
9
|
+
const is$typed = _is$typed,
|
|
10
|
+
validate = _validate
|
|
11
|
+
const id = 'org.hypercerts.defs'
|
|
12
|
+
|
|
13
|
+
/** Object containing a URI to external data */
|
|
14
|
+
export interface Uri {
|
|
15
|
+
$type?: 'org.hypercerts.defs#uri'
|
|
16
|
+
/** URI to external data */
|
|
17
|
+
uri: string
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const hashUri = 'uri'
|
|
21
|
+
|
|
22
|
+
export function isUri<V>(v: V) {
|
|
23
|
+
return is$typed(v, id, hashUri)
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export function validateUri<V>(v: V) {
|
|
27
|
+
return validate<Uri & V>(v, id, hashUri)
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/** Object containing a blob to external data */
|
|
31
|
+
export interface SmallBlob {
|
|
32
|
+
$type?: 'org.hypercerts.defs#smallBlob'
|
|
33
|
+
/** Blob to external data (up to 10MB) */
|
|
34
|
+
blob: BlobRef
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const hashSmallBlob = 'smallBlob'
|
|
38
|
+
|
|
39
|
+
export function isSmallBlob<V>(v: V) {
|
|
40
|
+
return is$typed(v, id, hashSmallBlob)
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export function validateSmallBlob<V>(v: V) {
|
|
44
|
+
return validate<SmallBlob & V>(v, id, hashSmallBlob)
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/** Object containing a blob to external data */
|
|
48
|
+
export interface LargeBlob {
|
|
49
|
+
$type?: 'org.hypercerts.defs#largeBlob'
|
|
50
|
+
/** Blob to external data (up to 100MB) */
|
|
51
|
+
blob: BlobRef
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
const hashLargeBlob = 'largeBlob'
|
|
55
|
+
|
|
56
|
+
export function isLargeBlob<V>(v: V) {
|
|
57
|
+
return is$typed(v, id, hashLargeBlob)
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export function validateLargeBlob<V>(v: V) {
|
|
61
|
+
return validate<LargeBlob & V>(v, id, hashLargeBlob)
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/** Object containing a small image */
|
|
65
|
+
export interface SmallImage {
|
|
66
|
+
$type?: 'org.hypercerts.defs#smallImage'
|
|
67
|
+
/** Image (up to 5MB) */
|
|
68
|
+
image: BlobRef
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
const hashSmallImage = 'smallImage'
|
|
72
|
+
|
|
73
|
+
export function isSmallImage<V>(v: V) {
|
|
74
|
+
return is$typed(v, id, hashSmallImage)
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export function validateSmallImage<V>(v: V) {
|
|
78
|
+
return validate<SmallImage & V>(v, id, hashSmallImage)
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/** Object containing a large image */
|
|
82
|
+
export interface LargeImage {
|
|
83
|
+
$type?: 'org.hypercerts.defs#largeImage'
|
|
84
|
+
/** Image (up to 10MB) */
|
|
85
|
+
image: BlobRef
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
const hashLargeImage = 'largeImage'
|
|
89
|
+
|
|
90
|
+
export function isLargeImage<V>(v: V) {
|
|
91
|
+
return is$typed(v, id, hashLargeImage)
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
export function validateLargeImage<V>(v: V) {
|
|
95
|
+
return validate<LargeImage & V>(v, id, hashLargeImage)
|
|
96
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* GENERATED CODE - DO NOT MODIFY
|
|
3
|
+
*/
|
|
4
|
+
import { type ValidationResult, BlobRef } from '@atproto/lexicon'
|
|
5
|
+
import { CID } from 'multiformats/cid'
|
|
6
|
+
import { validate as _validate } from '../../../../lexicons'
|
|
7
|
+
import {
|
|
8
|
+
type $Typed,
|
|
9
|
+
is$typed as _is$typed,
|
|
10
|
+
type OmitKey,
|
|
11
|
+
} from '../../../../util'
|
|
12
|
+
import type * as AppCertifiedDefs from '../../../app/certified/defs.js'
|
|
13
|
+
|
|
14
|
+
const is$typed = _is$typed,
|
|
15
|
+
validate = _validate
|
|
16
|
+
const id = 'org.hypercerts.funding.receipt'
|
|
17
|
+
|
|
18
|
+
export interface Main {
|
|
19
|
+
$type: 'org.hypercerts.funding.receipt'
|
|
20
|
+
from: AppCertifiedDefs.Did
|
|
21
|
+
/** The recipient of the funds. Can be identified by DID or a clear-text name. */
|
|
22
|
+
to: string
|
|
23
|
+
/** Amount of funding received. */
|
|
24
|
+
amount: string
|
|
25
|
+
/** Currency of the payment (e.g. EUR, USD, ETH). */
|
|
26
|
+
currency: string
|
|
27
|
+
/** How the funds were transferred (e.g. bank_transfer, credit_card, onchain, cash, check, payment_processor). */
|
|
28
|
+
paymentRail?: string
|
|
29
|
+
/** Optional network within the payment rail (e.g. arbitrum, ethereum, sepa, visa, paypal). */
|
|
30
|
+
paymentNetwork?: string
|
|
31
|
+
/** Identifier of the underlying payment transaction (e.g. bank reference, onchain transaction hash, or processor-specific ID). Use paymentNetwork to specify the network where applicable. */
|
|
32
|
+
transactionId?: string
|
|
33
|
+
/** Optional reference to the activity, project, or organization this funding relates to. */
|
|
34
|
+
for?: string
|
|
35
|
+
/** Optional notes or additional context for this funding receipt. */
|
|
36
|
+
notes?: string
|
|
37
|
+
/** Timestamp when the payment occurred. */
|
|
38
|
+
occurredAt?: string
|
|
39
|
+
/** Client-declared timestamp when this receipt record was created. */
|
|
40
|
+
createdAt: string
|
|
41
|
+
[k: string]: unknown
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const hashMain = 'main'
|
|
45
|
+
|
|
46
|
+
export function isMain<V>(v: V) {
|
|
47
|
+
return is$typed(v, id, hashMain)
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export function validateMain<V>(v: V) {
|
|
51
|
+
return validate<Main & V>(v, id, hashMain, true)
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export {
|
|
55
|
+
type Main as Record,
|
|
56
|
+
isMain as isRecord,
|
|
57
|
+
validateMain as validateRecord,
|
|
58
|
+
}
|
package/types/util.ts
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* GENERATED CODE - DO NOT MODIFY
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { type ValidationResult } from '@atproto/lexicon'
|
|
6
|
+
|
|
7
|
+
export type OmitKey<T, K extends keyof T> = {
|
|
8
|
+
[K2 in keyof T as K2 extends K ? never : K2]: T[K2]
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export type $Typed<V, T extends string = string> = V & { $type: T }
|
|
12
|
+
export type Un$Typed<V extends { $type?: string }> = OmitKey<V, '$type'>
|
|
13
|
+
|
|
14
|
+
export type $Type<Id extends string, Hash extends string> = Hash extends 'main'
|
|
15
|
+
? Id
|
|
16
|
+
: `${Id}#${Hash}`
|
|
17
|
+
|
|
18
|
+
function isObject<V>(v: V): v is V & object {
|
|
19
|
+
return v != null && typeof v === 'object'
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function is$type<Id extends string, Hash extends string>(
|
|
23
|
+
$type: unknown,
|
|
24
|
+
id: Id,
|
|
25
|
+
hash: Hash,
|
|
26
|
+
): $type is $Type<Id, Hash> {
|
|
27
|
+
return hash === 'main'
|
|
28
|
+
? $type === id
|
|
29
|
+
: // $type === `${id}#${hash}`
|
|
30
|
+
typeof $type === 'string' &&
|
|
31
|
+
$type.length === id.length + 1 + hash.length &&
|
|
32
|
+
$type.charCodeAt(id.length) === 35 /* '#' */ &&
|
|
33
|
+
$type.startsWith(id) &&
|
|
34
|
+
$type.endsWith(hash)
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export type $TypedObject<
|
|
38
|
+
V,
|
|
39
|
+
Id extends string,
|
|
40
|
+
Hash extends string,
|
|
41
|
+
> = V extends {
|
|
42
|
+
$type: $Type<Id, Hash>
|
|
43
|
+
}
|
|
44
|
+
? V
|
|
45
|
+
: V extends { $type?: string }
|
|
46
|
+
? V extends { $type?: infer T extends $Type<Id, Hash> }
|
|
47
|
+
? V & { $type: T }
|
|
48
|
+
: never
|
|
49
|
+
: V & { $type: $Type<Id, Hash> }
|
|
50
|
+
|
|
51
|
+
export function is$typed<V, Id extends string, Hash extends string>(
|
|
52
|
+
v: V,
|
|
53
|
+
id: Id,
|
|
54
|
+
hash: Hash,
|
|
55
|
+
): v is $TypedObject<V, Id, Hash> {
|
|
56
|
+
return isObject(v) && '$type' in v && is$type(v.$type, id, hash)
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export function maybe$typed<V, Id extends string, Hash extends string>(
|
|
60
|
+
v: V,
|
|
61
|
+
id: Id,
|
|
62
|
+
hash: Hash,
|
|
63
|
+
): v is V & object & { $type?: $Type<Id, Hash> } {
|
|
64
|
+
return (
|
|
65
|
+
isObject(v) &&
|
|
66
|
+
('$type' in v ? v.$type === undefined || is$type(v.$type, id, hash) : true)
|
|
67
|
+
)
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export type Validator<R = unknown> = (v: unknown) => ValidationResult<R>
|
|
71
|
+
export type ValidatorParam<V extends Validator> =
|
|
72
|
+
V extends Validator<infer R> ? R : never
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Utility function that allows to convert a "validate*" utility function into a
|
|
76
|
+
* type predicate.
|
|
77
|
+
*/
|
|
78
|
+
export function asPredicate<V extends Validator>(validate: V) {
|
|
79
|
+
return function <T>(v: T): v is T & ValidatorParam<V> {
|
|
80
|
+
return validate(v).success
|
|
81
|
+
}
|
|
82
|
+
}
|