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
use pub.leaflet.graph instead of pub.leaflet.publication
awarm.space
9 months ago
17ce1f5e
299c3bfe
+49
-51
6 changed files
expand all
collapse all
unified
split
appview
index.ts
lexicons
api
index.ts
lexicons.ts
types
pub
leaflet
graph
subscription.ts
pub
leaflet
graph
subscription.json
src
publication.ts
+3
-5
appview/index.ts
···
6
6
import { ids } from "lexicons/api/lexicons";
7
7
import {
8
8
PubLeafletDocument,
9
9
+
PubLeafletGraphSubscription,
9
10
PubLeafletPublication,
10
10
-
PubLeafletPublicationSubscription,
11
11
} from "lexicons/api";
12
12
import { AtUri } from "@atproto/syntax";
13
13
import { writeFile, readFile } from "fs/promises";
···
38
38
filterCollections: [
39
39
ids.PubLeafletDocument,
40
40
ids.PubLeafletPublication,
41
41
-
ids.PubLeafletPublicationSubscription,
41
41
+
ids.PubLeafletGraphSubscription,
42
42
],
43
43
handleEvent: async (evt) => {
44
44
if (
···
96
96
}
97
97
if (evt.collection === ids.PubLeafletPublication) {
98
98
if (evt.event === "create" || evt.event === "update") {
99
99
-
let record = PubLeafletPublicationSubscription.validateRecord(
100
100
-
evt.record,
101
101
-
);
99
99
+
let record = PubLeafletGraphSubscription.validateRecord(evt.record);
102
100
if (!record.success) return;
103
101
await supabase.from("publication_subscriptions").upsert({
104
102
uri: evt.uri.toString(),
+20
-20
lexicons/api/index.ts
···
11
11
import * as PubLeafletBlocksImage from './types/pub/leaflet/blocks/image'
12
12
import * as PubLeafletBlocksText from './types/pub/leaflet/blocks/text'
13
13
import * as PubLeafletBlocksUnorderedList from './types/pub/leaflet/blocks/unorderedList'
14
14
+
import * as PubLeafletGraphSubscription from './types/pub/leaflet/graph/subscription'
14
15
import * as PubLeafletPagesLinearDocument from './types/pub/leaflet/pages/linearDocument'
15
15
-
import * as PubLeafletPublicationSubscription from './types/pub/leaflet/publication/subscription'
16
16
import * as PubLeafletRichtextFacet from './types/pub/leaflet/richtext/facet'
17
17
import * as ComAtprotoLabelDefs from './types/com/atproto/label/defs'
18
18
import * as ComAtprotoRepoApplyWrites from './types/com/atproto/repo/applyWrites'
···
34
34
export * as PubLeafletBlocksImage from './types/pub/leaflet/blocks/image'
35
35
export * as PubLeafletBlocksText from './types/pub/leaflet/blocks/text'
36
36
export * as PubLeafletBlocksUnorderedList from './types/pub/leaflet/blocks/unorderedList'
37
37
+
export * as PubLeafletGraphSubscription from './types/pub/leaflet/graph/subscription'
37
38
export * as PubLeafletPagesLinearDocument from './types/pub/leaflet/pages/linearDocument'
38
38
-
export * as PubLeafletPublicationSubscription from './types/pub/leaflet/publication/subscription'
39
39
export * as PubLeafletRichtextFacet from './types/pub/leaflet/richtext/facet'
40
40
export * as ComAtprotoLabelDefs from './types/com/atproto/label/defs'
41
41
export * as ComAtprotoRepoApplyWrites from './types/com/atproto/repo/applyWrites'
···
90
90
document: DocumentRecord
91
91
publication: PublicationRecord
92
92
blocks: PubLeafletBlocksNS
93
93
+
graph: PubLeafletGraphNS
93
94
pages: PubLeafletPagesNS
94
94
-
publication: PubLeafletPublicationNS
95
95
richtext: PubLeafletRichtextNS
96
96
97
97
constructor(client: XrpcClient) {
98
98
this._client = client
99
99
this.blocks = new PubLeafletBlocksNS(client)
100
100
+
this.graph = new PubLeafletGraphNS(client)
100
101
this.pages = new PubLeafletPagesNS(client)
101
101
-
this.publication = new PubLeafletPublicationNS(client)
102
102
this.richtext = new PubLeafletRichtextNS(client)
103
103
this.document = new DocumentRecord(client)
104
104
this.publication = new PublicationRecord(client)
···
113
113
}
114
114
}
115
115
116
116
-
export class PubLeafletPagesNS {
117
117
-
_client: XrpcClient
118
118
-
119
119
-
constructor(client: XrpcClient) {
120
120
-
this._client = client
121
121
-
}
122
122
-
}
123
123
-
124
124
-
export class PubLeafletPublicationNS {
116
116
+
export class PubLeafletGraphNS {
125
117
_client: XrpcClient
126
118
subscription: SubscriptionRecord
127
119
···
142
134
params: OmitKey<ComAtprotoRepoListRecords.QueryParams, 'collection'>,
143
135
): Promise<{
144
136
cursor?: string
145
145
-
records: { uri: string; value: PubLeafletPublicationSubscription.Record }[]
137
137
+
records: { uri: string; value: PubLeafletGraphSubscription.Record }[]
146
138
}> {
147
139
const res = await this._client.call('com.atproto.repo.listRecords', {
148
148
-
collection: 'pub.leaflet.publication.subscription',
140
140
+
collection: 'pub.leaflet.graph.subscription',
149
141
...params,
150
142
})
151
143
return res.data
···
156
148
): Promise<{
157
149
uri: string
158
150
cid: string
159
159
-
value: PubLeafletPublicationSubscription.Record
151
151
+
value: PubLeafletGraphSubscription.Record
160
152
}> {
161
153
const res = await this._client.call('com.atproto.repo.getRecord', {
162
162
-
collection: 'pub.leaflet.publication.subscription',
154
154
+
collection: 'pub.leaflet.graph.subscription',
163
155
...params,
164
156
})
165
157
return res.data
···
170
162
ComAtprotoRepoCreateRecord.InputSchema,
171
163
'collection' | 'record'
172
164
>,
173
173
-
record: Un$Typed<PubLeafletPublicationSubscription.Record>,
165
165
+
record: Un$Typed<PubLeafletGraphSubscription.Record>,
174
166
headers?: Record<string, string>,
175
167
): Promise<{ uri: string; cid: string }> {
176
176
-
const collection = 'pub.leaflet.publication.subscription'
168
168
+
const collection = 'pub.leaflet.graph.subscription'
177
169
const res = await this._client.call(
178
170
'com.atproto.repo.createRecord',
179
171
undefined,
···
190
182
await this._client.call(
191
183
'com.atproto.repo.deleteRecord',
192
184
undefined,
193
193
-
{ collection: 'pub.leaflet.publication.subscription', ...params },
185
185
+
{ collection: 'pub.leaflet.graph.subscription', ...params },
194
186
{ headers },
195
187
)
188
188
+
}
189
189
+
}
190
190
+
191
191
+
export class PubLeafletPagesNS {
192
192
+
_client: XrpcClient
193
193
+
194
194
+
constructor(client: XrpcClient) {
195
195
+
this._client = client
196
196
}
197
197
}
198
198
+22
-22
lexicons/api/lexicons.ts
···
223
223
},
224
224
},
225
225
},
226
226
+
PubLeafletGraphSubscription: {
227
227
+
lexicon: 1,
228
228
+
id: 'pub.leaflet.graph.subscription',
229
229
+
defs: {
230
230
+
main: {
231
231
+
type: 'record',
232
232
+
key: 'tid',
233
233
+
description: 'Record declaring a subscription to a publication',
234
234
+
record: {
235
235
+
type: 'object',
236
236
+
required: ['publication'],
237
237
+
properties: {
238
238
+
publication: {
239
239
+
type: 'string',
240
240
+
format: 'at-uri',
241
241
+
},
242
242
+
},
243
243
+
},
244
244
+
},
245
245
+
},
246
246
+
},
226
247
PubLeafletPagesLinearDocument: {
227
248
lexicon: 1,
228
249
id: 'pub.leaflet.pages.linearDocument',
···
270
291
},
271
292
textAlignRight: {
272
293
type: 'token',
273
273
-
},
274
274
-
},
275
275
-
},
276
276
-
PubLeafletPublicationSubscription: {
277
277
-
lexicon: 1,
278
278
-
id: 'pub.leaflet.publication.subscription',
279
279
-
defs: {
280
280
-
main: {
281
281
-
type: 'record',
282
282
-
key: 'tid',
283
283
-
description: 'Record declaring a subscription to a publication',
284
284
-
record: {
285
285
-
type: 'object',
286
286
-
required: ['publication'],
287
287
-
properties: {
288
288
-
publication: {
289
289
-
type: 'string',
290
290
-
format: 'at-uri',
291
291
-
},
292
292
-
},
293
293
-
},
294
294
},
295
295
},
296
296
},
···
1368
1368
PubLeafletBlocksImage: 'pub.leaflet.blocks.image',
1369
1369
PubLeafletBlocksText: 'pub.leaflet.blocks.text',
1370
1370
PubLeafletBlocksUnorderedList: 'pub.leaflet.blocks.unorderedList',
1371
1371
+
PubLeafletGraphSubscription: 'pub.leaflet.graph.subscription',
1371
1372
PubLeafletPagesLinearDocument: 'pub.leaflet.pages.linearDocument',
1372
1372
-
PubLeafletPublicationSubscription: 'pub.leaflet.publication.subscription',
1373
1373
PubLeafletRichtextFacet: 'pub.leaflet.richtext.facet',
1374
1374
ComAtprotoLabelDefs: 'com.atproto.label.defs',
1375
1375
ComAtprotoRepoApplyWrites: 'com.atproto.repo.applyWrites',
+2
-2
lexicons/api/types/pub/leaflet/publication/subscription.ts
lexicons/api/types/pub/leaflet/graph/subscription.ts
···
8
8
9
9
const is$typed = _is$typed,
10
10
validate = _validate
11
11
-
const id = 'pub.leaflet.publication.subscription'
11
11
+
const id = 'pub.leaflet.graph.subscription'
12
12
13
13
export interface Record {
14
14
-
$type: 'pub.leaflet.publication.subscription'
14
14
+
$type: 'pub.leaflet.graph.subscription'
15
15
publication: string
16
16
[k: string]: unknown
17
17
}
+1
-1
lexicons/pub/leaflet/publication/subscription.json
lexicons/pub/leaflet/graph/subscription.json
···
1
1
{
2
2
"lexicon": 1,
3
3
-
"id": "pub.leaflet.publication.subscription",
3
3
+
"id": "pub.leaflet.graph.subscription",
4
4
"defs": {
5
5
"main": {
6
6
"type": "record",
+1
-1
lexicons/src/publication.ts
···
24
24
25
25
export const PubLeafletPublicationSubscription: LexiconDoc = {
26
26
lexicon: 1,
27
27
-
id: "pub.leaflet.publication.subscription",
27
27
+
id: "pub.leaflet.graph.subscription",
28
28
defs: {
29
29
main: {
30
30
type: "record",