tangled
alpha
login
or
join now
leaflet.pub
/
leaflet
289
fork
atom
a tool for shared writing and social publishing
289
fork
atom
overview
issues
28
pulls
pipelines
update lexicons
awarm.space
10 months ago
fd7b6caa
fb6d9d79
+30
-197
11 changed files
expand all
collapse all
unified
split
appview
index.ts
lexicons
api
index.ts
lexicons.ts
types
pub
leaflet
document.ts
post.ts
publication.ts
pub
leaflet
document.json
post.json
publication.json
src
document.ts
publication.ts
+3
-16
appview/index.ts
···
4
4
const idResolver = new IdResolver();
5
5
import { Firehose, MemoryRunner } from "@atproto/sync";
6
6
import { ids } from "lexicons/api/lexicons";
7
7
-
import {
8
8
-
PubLeafletDocument,
9
9
-
PubLeafletPost,
10
10
-
PubLeafletPublication,
11
11
-
} from "lexicons/api";
7
7
+
import { PubLeafletDocument, PubLeafletPublication } from "lexicons/api";
12
8
import { AtUri } from "@atproto/syntax";
13
9
import { writeFile, readFile } from "fs/promises";
14
10
···
35
31
excludeIdentity: true,
36
32
runner,
37
33
idResolver,
38
38
-
filterCollections: [
39
39
-
ids.PubLeafletDocument,
40
40
-
ids.PubLeafletPublication,
41
41
-
ids.PubLeafletPost,
42
42
-
],
34
34
+
filterCollections: [ids.PubLeafletDocument, ids.PubLeafletPublication],
43
35
handleEvent: async (evt) => {
44
36
if (
45
37
evt.event == "account" ||
···
84
76
uri: evt.uri.toString(),
85
77
identity_did: evt.did,
86
78
name: record.value.name,
79
79
+
record: record.value as Json,
87
80
});
88
81
}
89
82
if (evt.event === "delete") {
···
91
84
.from("publications")
92
85
.delete()
93
86
.eq("uri", evt.uri.toString());
94
94
-
}
95
95
-
}
96
96
-
if (evt.collection === ids.PubLeafletPost) {
97
97
-
if (evt.event === "create" || evt.event === "update") {
98
98
-
let record = PubLeafletPost.validateRecord(evt.record);
99
99
-
if (!record.success) return;
100
87
}
101
88
}
102
89
},
-65
lexicons/api/index.ts
···
6
6
import { CID } from 'multiformats/cid'
7
7
import { OmitKey, Un$Typed } from './util'
8
8
import * as PubLeafletDocument from './types/pub/leaflet/document'
9
9
-
import * as PubLeafletPost from './types/pub/leaflet/post'
10
9
import * as PubLeafletPublication from './types/pub/leaflet/publication'
11
10
import * as PubLeafletBlocksHeader from './types/pub/leaflet/blocks/header'
12
11
import * as PubLeafletBlocksImage from './types/pub/leaflet/blocks/image'
···
27
26
import * as ComAtprotoRepoUploadBlob from './types/com/atproto/repo/uploadBlob'
28
27
29
28
export * as PubLeafletDocument from './types/pub/leaflet/document'
30
30
-
export * as PubLeafletPost from './types/pub/leaflet/post'
31
29
export * as PubLeafletPublication from './types/pub/leaflet/publication'
32
30
export * as PubLeafletBlocksHeader from './types/pub/leaflet/blocks/header'
33
31
export * as PubLeafletBlocksImage from './types/pub/leaflet/blocks/image'
···
84
82
export class PubLeafletNS {
85
83
_client: XrpcClient
86
84
document: DocumentRecord
87
87
-
post: PostRecord
88
85
publication: PublicationRecord
89
86
blocks: PubLeafletBlocksNS
90
87
pages: PubLeafletPagesNS
···
94
91
this.blocks = new PubLeafletBlocksNS(client)
95
92
this.pages = new PubLeafletPagesNS(client)
96
93
this.document = new DocumentRecord(client)
97
97
-
this.post = new PostRecord(client)
98
94
this.publication = new PublicationRecord(client)
99
95
}
100
96
}
···
171
167
'com.atproto.repo.deleteRecord',
172
168
undefined,
173
169
{ collection: 'pub.leaflet.document', ...params },
174
174
-
{ headers },
175
175
-
)
176
176
-
}
177
177
-
}
178
178
-
179
179
-
export class PostRecord {
180
180
-
_client: XrpcClient
181
181
-
182
182
-
constructor(client: XrpcClient) {
183
183
-
this._client = client
184
184
-
}
185
185
-
186
186
-
async list(
187
187
-
params: OmitKey<ComAtprotoRepoListRecords.QueryParams, 'collection'>,
188
188
-
): Promise<{
189
189
-
cursor?: string
190
190
-
records: { uri: string; value: PubLeafletPost.Record }[]
191
191
-
}> {
192
192
-
const res = await this._client.call('com.atproto.repo.listRecords', {
193
193
-
collection: 'pub.leaflet.post',
194
194
-
...params,
195
195
-
})
196
196
-
return res.data
197
197
-
}
198
198
-
199
199
-
async get(
200
200
-
params: OmitKey<ComAtprotoRepoGetRecord.QueryParams, 'collection'>,
201
201
-
): Promise<{ uri: string; cid: string; value: PubLeafletPost.Record }> {
202
202
-
const res = await this._client.call('com.atproto.repo.getRecord', {
203
203
-
collection: 'pub.leaflet.post',
204
204
-
...params,
205
205
-
})
206
206
-
return res.data
207
207
-
}
208
208
-
209
209
-
async create(
210
210
-
params: OmitKey<
211
211
-
ComAtprotoRepoCreateRecord.InputSchema,
212
212
-
'collection' | 'record'
213
213
-
>,
214
214
-
record: Un$Typed<PubLeafletPost.Record>,
215
215
-
headers?: Record<string, string>,
216
216
-
): Promise<{ uri: string; cid: string }> {
217
217
-
const collection = 'pub.leaflet.post'
218
218
-
const res = await this._client.call(
219
219
-
'com.atproto.repo.createRecord',
220
220
-
undefined,
221
221
-
{ collection, ...params, record: { ...record, $type: collection } },
222
222
-
{ encoding: 'application/json', headers },
223
223
-
)
224
224
-
return res.data
225
225
-
}
226
226
-
227
227
-
async delete(
228
228
-
params: OmitKey<ComAtprotoRepoDeleteRecord.InputSchema, 'collection'>,
229
229
-
headers?: Record<string, string>,
230
230
-
): Promise<void> {
231
231
-
await this._client.call(
232
232
-
'com.atproto.repo.deleteRecord',
233
233
-
undefined,
234
234
-
{ collection: 'pub.leaflet.post', ...params },
235
170
{ headers },
236
171
)
237
172
}
+11
-31
lexicons/api/lexicons.ts
···
26
26
properties: {
27
27
title: {
28
28
type: 'string',
29
29
-
maxLength: 128,
29
29
+
maxLength: 1280,
30
30
+
maxGraphemes: 128,
31
31
+
},
32
32
+
description: {
33
33
+
type: 'string',
34
34
+
maxLength: 3000,
35
35
+
maxGraphemes: 300,
30
36
},
31
37
publishedAt: {
32
38
type: 'string',
···
52
58
},
53
59
},
54
60
},
55
55
-
PubLeafletPost: {
56
56
-
lexicon: 1,
57
57
-
id: 'pub.leaflet.post',
58
58
-
defs: {
59
59
-
main: {
60
60
-
type: 'record',
61
61
-
key: 'tid',
62
62
-
description: 'Record putting a post in a document',
63
63
-
record: {
64
64
-
type: 'object',
65
65
-
required: ['post', 'publishedAt'],
66
66
-
properties: {
67
67
-
publication: {
68
68
-
type: 'string',
69
69
-
format: 'at-uri',
70
70
-
},
71
71
-
post: {
72
72
-
type: 'ref',
73
73
-
ref: 'lex:com.atproto.repo.strongRef',
74
74
-
},
75
75
-
publishedAt: {
76
76
-
type: 'string',
77
77
-
format: 'datetime',
78
78
-
},
79
79
-
},
80
80
-
},
81
81
-
},
82
82
-
},
83
83
-
},
84
61
PubLeafletPublication: {
85
62
lexicon: 1,
86
63
id: 'pub.leaflet.publication',
···
96
73
name: {
97
74
type: 'string',
98
75
maxLength: 2000,
76
76
+
},
77
77
+
domain: {
78
78
+
type: 'string',
79
79
+
format: 'uri',
99
80
},
100
81
description: {
101
82
type: 'string',
···
1213
1194
1214
1195
export const ids = {
1215
1196
PubLeafletDocument: 'pub.leaflet.document',
1216
1216
-
PubLeafletPost: 'pub.leaflet.post',
1217
1197
PubLeafletPublication: 'pub.leaflet.publication',
1218
1198
PubLeafletBlocksHeader: 'pub.leaflet.blocks.header',
1219
1199
PubLeafletBlocksImage: 'pub.leaflet.blocks.image',
+1
lexicons/api/types/pub/leaflet/document.ts
···
14
14
export interface Record {
15
15
$type: 'pub.leaflet.document'
16
16
title: string
17
17
+
description?: string
17
18
publishedAt?: string
18
19
publication: string
19
20
author: string
-30
lexicons/api/types/pub/leaflet/post.ts
···
1
1
-
/**
2
2
-
* GENERATED CODE - DO NOT MODIFY
3
3
-
*/
4
4
-
import { ValidationResult, BlobRef } from '@atproto/lexicon'
5
5
-
import { CID } from 'multiformats/cid'
6
6
-
import { validate as _validate } from '../../../lexicons'
7
7
-
import { $Typed, is$typed as _is$typed, OmitKey } from '../../../util'
8
8
-
import type * as ComAtprotoRepoStrongRef from '../../com/atproto/repo/strongRef'
9
9
-
10
10
-
const is$typed = _is$typed,
11
11
-
validate = _validate
12
12
-
const id = 'pub.leaflet.post'
13
13
-
14
14
-
export interface Record {
15
15
-
$type: 'pub.leaflet.post'
16
16
-
publication?: string
17
17
-
post: ComAtprotoRepoStrongRef.Main
18
18
-
publishedAt: string
19
19
-
[k: string]: unknown
20
20
-
}
21
21
-
22
22
-
const hashRecord = 'main'
23
23
-
24
24
-
export function isRecord<V>(v: V) {
25
25
-
return is$typed(v, id, hashRecord)
26
26
-
}
27
27
-
28
28
-
export function validateRecord<V>(v: V) {
29
29
-
return validate<Record & V>(v, id, hashRecord, true)
30
30
-
}
+1
lexicons/api/types/pub/leaflet/publication.ts
···
13
13
export interface Record {
14
14
$type: 'pub.leaflet.publication'
15
15
name: string
16
16
+
domain?: string
16
17
description?: string
17
18
icon?: BlobRef
18
19
[k: string]: unknown
+7
-1
lexicons/pub/leaflet/document.json
···
19
19
"properties": {
20
20
"title": {
21
21
"type": "string",
22
22
-
"maxLength": 128
22
22
+
"maxLength": 1280,
23
23
+
"maxGraphemes": 128
24
24
+
},
25
25
+
"description": {
26
26
+
"type": "string",
27
27
+
"maxLength": 3000,
28
28
+
"maxGraphemes": 300
23
29
},
24
30
"publishedAt": {
25
31
"type": "string",
-32
lexicons/pub/leaflet/post.json
···
1
1
-
{
2
2
-
"lexicon": 1,
3
3
-
"id": "pub.leaflet.post",
4
4
-
"defs": {
5
5
-
"main": {
6
6
-
"type": "record",
7
7
-
"key": "tid",
8
8
-
"description": "Record putting a post in a document",
9
9
-
"record": {
10
10
-
"type": "object",
11
11
-
"required": [
12
12
-
"post",
13
13
-
"publishedAt"
14
14
-
],
15
15
-
"properties": {
16
16
-
"publication": {
17
17
-
"type": "string",
18
18
-
"format": "at-uri"
19
19
-
},
20
20
-
"post": {
21
21
-
"type": "ref",
22
22
-
"ref": "com.atproto.repo.strongRef"
23
23
-
},
24
24
-
"publishedAt": {
25
25
-
"type": "string",
26
26
-
"format": "datetime"
27
27
-
}
28
28
-
}
29
29
-
}
30
30
-
}
31
31
-
}
32
32
-
}
+4
lexicons/pub/leaflet/publication.json
···
16
16
"type": "string",
17
17
"maxLength": 2000
18
18
},
19
19
+
"domain": {
20
20
+
"type": "string",
21
21
+
"format": "uri"
22
22
+
},
19
23
"description": {
20
24
"type": "string",
21
25
"maxLength": 2000
+2
-1
lexicons/src/document.ts
···
15
15
type: "object",
16
16
required: ["pages", "author", "title", "publication"],
17
17
properties: {
18
18
-
title: { type: "string", maxLength: 128 },
18
18
+
title: { type: "string", maxLength: 1280, maxGraphemes: 128 },
19
19
+
description: { type: "string", maxLength: 3000, maxGraphemes: 300 },
19
20
publishedAt: { type: "string", format: "datetime" },
20
21
publication: { type: "string", format: "at-uri" },
21
22
author: { type: "string", format: "at-identifier" },
+1
-21
lexicons/src/publication.ts
···
13
13
required: ["name"],
14
14
properties: {
15
15
name: { type: "string", maxLength: 2000 },
16
16
+
domain: { type: "string", format: "uri" },
16
17
description: { type: "string", maxLength: 2000 },
17
18
icon: { type: "blob", accept: ["image/*"], maxSize: 1000000 },
18
19
},
···
20
21
},
21
22
},
22
23
};
23
23
-
24
24
-
export const PubLeafletPublicationPost: LexiconDoc = {
25
25
-
lexicon: 1,
26
26
-
id: "pub.leaflet.post",
27
27
-
defs: {
28
28
-
main: {
29
29
-
type: "record",
30
30
-
key: "tid",
31
31
-
description: "Record putting a post in a document",
32
32
-
record: {
33
33
-
type: "object",
34
34
-
required: ["post", "publishedAt"],
35
35
-
properties: {
36
36
-
publication: { type: "string", format: "at-uri" },
37
37
-
post: { type: "ref", ref: "com.atproto.repo.strongRef" },
38
38
-
publishedAt: { type: "string", format: "datetime" },
39
39
-
},
40
40
-
},
41
41
-
},
42
42
-
},
43
43
-
};