@mepuka/skygent 0.2.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.
Files changed (114) hide show
  1. package/README.md +59 -0
  2. package/index.ts +146 -0
  3. package/package.json +56 -0
  4. package/src/cli/app.ts +75 -0
  5. package/src/cli/config-command.ts +140 -0
  6. package/src/cli/config.ts +91 -0
  7. package/src/cli/derive.ts +205 -0
  8. package/src/cli/doc/annotation.ts +36 -0
  9. package/src/cli/doc/filter.ts +69 -0
  10. package/src/cli/doc/index.ts +9 -0
  11. package/src/cli/doc/post.ts +155 -0
  12. package/src/cli/doc/primitives.ts +25 -0
  13. package/src/cli/doc/render.ts +18 -0
  14. package/src/cli/doc/table.ts +114 -0
  15. package/src/cli/doc/thread.ts +46 -0
  16. package/src/cli/doc/tree.ts +126 -0
  17. package/src/cli/errors.ts +59 -0
  18. package/src/cli/exit-codes.ts +52 -0
  19. package/src/cli/feed.ts +177 -0
  20. package/src/cli/filter-dsl.ts +1411 -0
  21. package/src/cli/filter-errors.ts +208 -0
  22. package/src/cli/filter-help.ts +70 -0
  23. package/src/cli/filter-input.ts +54 -0
  24. package/src/cli/filter.ts +435 -0
  25. package/src/cli/graph.ts +472 -0
  26. package/src/cli/help.ts +14 -0
  27. package/src/cli/interval.ts +35 -0
  28. package/src/cli/jetstream.ts +173 -0
  29. package/src/cli/layers.ts +180 -0
  30. package/src/cli/logging.ts +136 -0
  31. package/src/cli/output-format.ts +26 -0
  32. package/src/cli/output.ts +82 -0
  33. package/src/cli/parse.ts +80 -0
  34. package/src/cli/post.ts +193 -0
  35. package/src/cli/preferences.ts +11 -0
  36. package/src/cli/query-fields.ts +247 -0
  37. package/src/cli/query.ts +415 -0
  38. package/src/cli/range.ts +44 -0
  39. package/src/cli/search.ts +465 -0
  40. package/src/cli/shared-options.ts +169 -0
  41. package/src/cli/shared.ts +20 -0
  42. package/src/cli/store-errors.ts +80 -0
  43. package/src/cli/store-tree.ts +392 -0
  44. package/src/cli/store.ts +395 -0
  45. package/src/cli/sync-factory.ts +107 -0
  46. package/src/cli/sync.ts +366 -0
  47. package/src/cli/view-thread.ts +196 -0
  48. package/src/cli/view.ts +47 -0
  49. package/src/cli/watch.ts +344 -0
  50. package/src/db/migrations/store-catalog/001_init.ts +14 -0
  51. package/src/db/migrations/store-index/001_init.ts +34 -0
  52. package/src/db/migrations/store-index/002_event_log.ts +24 -0
  53. package/src/db/migrations/store-index/003_fts_and_derived.ts +52 -0
  54. package/src/db/migrations/store-index/004_query_indexes.ts +9 -0
  55. package/src/db/migrations/store-index/005_post_lang.ts +15 -0
  56. package/src/db/migrations/store-index/006_has_embed.ts +10 -0
  57. package/src/db/migrations/store-index/007_event_seq_and_checkpoints.ts +68 -0
  58. package/src/domain/bsky.ts +467 -0
  59. package/src/domain/config.ts +11 -0
  60. package/src/domain/credentials.ts +6 -0
  61. package/src/domain/defaults.ts +8 -0
  62. package/src/domain/derivation.ts +55 -0
  63. package/src/domain/errors.ts +71 -0
  64. package/src/domain/events.ts +55 -0
  65. package/src/domain/extract.ts +64 -0
  66. package/src/domain/filter-describe.ts +551 -0
  67. package/src/domain/filter-explain.ts +9 -0
  68. package/src/domain/filter.ts +797 -0
  69. package/src/domain/format.ts +91 -0
  70. package/src/domain/index.ts +13 -0
  71. package/src/domain/indexes.ts +17 -0
  72. package/src/domain/policies.ts +16 -0
  73. package/src/domain/post.ts +88 -0
  74. package/src/domain/primitives.ts +50 -0
  75. package/src/domain/raw.ts +140 -0
  76. package/src/domain/store.ts +103 -0
  77. package/src/domain/sync.ts +211 -0
  78. package/src/domain/text-width.ts +56 -0
  79. package/src/services/app-config.ts +278 -0
  80. package/src/services/bsky-client.ts +2113 -0
  81. package/src/services/credential-store.ts +408 -0
  82. package/src/services/derivation-engine.ts +502 -0
  83. package/src/services/derivation-settings.ts +61 -0
  84. package/src/services/derivation-validator.ts +68 -0
  85. package/src/services/filter-compiler.ts +269 -0
  86. package/src/services/filter-library.ts +371 -0
  87. package/src/services/filter-runtime.ts +821 -0
  88. package/src/services/filter-settings.ts +30 -0
  89. package/src/services/identity-resolver.ts +563 -0
  90. package/src/services/jetstream-sync.ts +636 -0
  91. package/src/services/lineage-store.ts +89 -0
  92. package/src/services/link-validator.ts +244 -0
  93. package/src/services/output-manager.ts +274 -0
  94. package/src/services/post-parser.ts +62 -0
  95. package/src/services/profile-resolver.ts +223 -0
  96. package/src/services/resource-monitor.ts +106 -0
  97. package/src/services/shared.ts +69 -0
  98. package/src/services/store-cleaner.ts +43 -0
  99. package/src/services/store-commit.ts +168 -0
  100. package/src/services/store-db.ts +248 -0
  101. package/src/services/store-event-log.ts +285 -0
  102. package/src/services/store-index-sql.ts +289 -0
  103. package/src/services/store-index.ts +1152 -0
  104. package/src/services/store-keys.ts +4 -0
  105. package/src/services/store-manager.ts +358 -0
  106. package/src/services/store-stats.ts +522 -0
  107. package/src/services/store-writer.ts +200 -0
  108. package/src/services/sync-checkpoint-store.ts +169 -0
  109. package/src/services/sync-engine.ts +547 -0
  110. package/src/services/sync-reporter.ts +16 -0
  111. package/src/services/sync-settings.ts +72 -0
  112. package/src/services/trending-topics.ts +226 -0
  113. package/src/services/view-checkpoint-store.ts +238 -0
  114. package/src/typeclass/chunk.ts +84 -0
@@ -0,0 +1,467 @@
1
+ import { Schema } from "effect";
2
+ import { AtUri, Did, Handle, PostCid, PostUri, Timestamp } from "./primitives.js";
3
+
4
+ export const AuthorFeedFilter = Schema.Literal(
5
+ "posts_with_replies",
6
+ "posts_no_replies",
7
+ "posts_with_media",
8
+ "posts_and_author_threads"
9
+ );
10
+ export type AuthorFeedFilter = typeof AuthorFeedFilter.Type;
11
+
12
+ export class StrongRef extends Schema.Class<StrongRef>("StrongRef")({
13
+ uri: AtUri,
14
+ cid: PostCid
15
+ }) {}
16
+
17
+ export class ReplyRef extends Schema.Class<ReplyRef>("ReplyRef")({
18
+ root: StrongRef,
19
+ parent: StrongRef
20
+ }) {}
21
+
22
+ export const FacetIndex = Schema.Struct({
23
+ byteStart: Schema.Int,
24
+ byteEnd: Schema.Int
25
+ });
26
+ export type FacetIndex = typeof FacetIndex.Type;
27
+
28
+ export const FacetMentionFeature = Schema.Struct({
29
+ $type: Schema.Literal("app.bsky.richtext.facet#mention"),
30
+ did: Did
31
+ });
32
+ export type FacetMentionFeature = typeof FacetMentionFeature.Type;
33
+
34
+ export const FacetLinkFeature = Schema.Struct({
35
+ $type: Schema.Literal("app.bsky.richtext.facet#link"),
36
+ uri: Schema.String
37
+ });
38
+ export type FacetLinkFeature = typeof FacetLinkFeature.Type;
39
+
40
+ export const FacetTagFeature = Schema.Struct({
41
+ $type: Schema.Literal("app.bsky.richtext.facet#tag"),
42
+ tag: Schema.String
43
+ });
44
+ export type FacetTagFeature = typeof FacetTagFeature.Type;
45
+
46
+ export const FacetUnknownFeature = Schema.Struct({
47
+ $type: Schema.String
48
+ });
49
+ export type FacetUnknownFeature = typeof FacetUnknownFeature.Type;
50
+
51
+ export const FacetFeature = Schema.Union(
52
+ FacetMentionFeature,
53
+ FacetLinkFeature,
54
+ FacetTagFeature,
55
+ FacetUnknownFeature
56
+ );
57
+ export type FacetFeature = typeof FacetFeature.Type;
58
+
59
+ export const RichTextFacet = Schema.Struct({
60
+ index: FacetIndex,
61
+ features: Schema.Array(FacetFeature)
62
+ });
63
+ export type RichTextFacet = typeof RichTextFacet.Type;
64
+
65
+ export const LegacyFacetIndex = Schema.Struct({
66
+ start: Schema.Int,
67
+ end: Schema.Int
68
+ });
69
+ export type LegacyFacetIndex = typeof LegacyFacetIndex.Type;
70
+
71
+ export const LegacyEntity = Schema.Struct({
72
+ index: LegacyFacetIndex,
73
+ type: Schema.String,
74
+ value: Schema.String
75
+ });
76
+ export type LegacyEntity = typeof LegacyEntity.Type;
77
+
78
+ export const SelfLabel = Schema.Struct({
79
+ $type: Schema.optional(Schema.Literal("com.atproto.label.defs#selfLabel")),
80
+ val: Schema.String
81
+ });
82
+ export type SelfLabel = typeof SelfLabel.Type;
83
+
84
+ export const SelfLabels = Schema.Struct({
85
+ $type: Schema.optional(Schema.Literal("com.atproto.label.defs#selfLabels")),
86
+ values: Schema.Array(SelfLabel)
87
+ });
88
+ export type SelfLabels = typeof SelfLabels.Type;
89
+
90
+ export class Label extends Schema.Class<Label>("Label")({
91
+ $type: Schema.optional(Schema.Literal("com.atproto.label.defs#label")),
92
+ ver: Schema.optional(Schema.Int),
93
+ src: Did,
94
+ uri: AtUri,
95
+ cid: Schema.optional(Schema.String),
96
+ val: Schema.String,
97
+ neg: Schema.optional(Schema.Boolean),
98
+ cts: Timestamp,
99
+ exp: Schema.optional(Timestamp),
100
+ sig: Schema.optional(
101
+ Schema.Union(Schema.Uint8ArrayFromSelf, Schema.Uint8ArrayFromBase64)
102
+ )
103
+ }) {}
104
+
105
+ const NonNegativeInt = Schema.Int.pipe(
106
+ Schema.finite(),
107
+ Schema.nonNegative()
108
+ );
109
+
110
+ export class PostMetrics extends Schema.Class<PostMetrics>("PostMetrics")({
111
+ replyCount: Schema.optional(NonNegativeInt),
112
+ repostCount: Schema.optional(NonNegativeInt),
113
+ likeCount: Schema.optional(NonNegativeInt),
114
+ quoteCount: Schema.optional(NonNegativeInt),
115
+ bookmarkCount: Schema.optional(NonNegativeInt)
116
+ }) {}
117
+
118
+ export class EmbedAspectRatio extends Schema.Class<EmbedAspectRatio>("EmbedAspectRatio")({
119
+ width: Schema.Int,
120
+ height: Schema.Int
121
+ }) {}
122
+
123
+ export class EmbedImage extends Schema.Class<EmbedImage>("EmbedImage")({
124
+ thumb: Schema.String,
125
+ fullsize: Schema.String,
126
+ alt: Schema.String,
127
+ aspectRatio: Schema.optional(EmbedAspectRatio)
128
+ }) {}
129
+
130
+ export class EmbedImages extends Schema.TaggedClass<EmbedImages>()("Images", {
131
+ images: Schema.Array(EmbedImage)
132
+ }) {}
133
+
134
+ export class EmbedExternal extends Schema.TaggedClass<EmbedExternal>()("External", {
135
+ uri: Schema.String,
136
+ title: Schema.String,
137
+ description: Schema.String,
138
+ thumb: Schema.optional(Schema.String)
139
+ }) {}
140
+
141
+ export class EmbedVideo extends Schema.TaggedClass<EmbedVideo>()("Video", {
142
+ cid: Schema.String,
143
+ playlist: Schema.String,
144
+ thumbnail: Schema.optional(Schema.String),
145
+ alt: Schema.optional(Schema.String),
146
+ aspectRatio: Schema.optional(EmbedAspectRatio)
147
+ }) {}
148
+
149
+ export class ProfileBasic extends Schema.Class<ProfileBasic>("ProfileBasic")({
150
+ did: Did,
151
+ handle: Handle,
152
+ displayName: Schema.optional(Schema.String),
153
+ pronouns: Schema.optional(Schema.String),
154
+ avatar: Schema.optional(Schema.String),
155
+ associated: Schema.optional(Schema.Unknown),
156
+ viewer: Schema.optional(Schema.Unknown),
157
+ labels: Schema.optional(Schema.Array(Schema.encodedSchema(Label))),
158
+ createdAt: Schema.optional(Schema.String),
159
+ verification: Schema.optional(Schema.Unknown),
160
+ status: Schema.optional(Schema.Unknown),
161
+ debug: Schema.optional(Schema.Unknown)
162
+ }) {}
163
+
164
+ export class ProfileView extends Schema.Class<ProfileView>("ProfileView")({
165
+ did: Did,
166
+ handle: Handle,
167
+ displayName: Schema.optional(Schema.String),
168
+ pronouns: Schema.optional(Schema.String),
169
+ description: Schema.optional(Schema.String),
170
+ avatar: Schema.optional(Schema.String),
171
+ associated: Schema.optional(Schema.Unknown),
172
+ indexedAt: Schema.optional(Schema.String),
173
+ createdAt: Schema.optional(Schema.String),
174
+ viewer: Schema.optional(Schema.Unknown),
175
+ labels: Schema.optional(Schema.Array(Schema.encodedSchema(Label))),
176
+ verification: Schema.optional(Schema.Unknown),
177
+ status: Schema.optional(Schema.Unknown),
178
+ debug: Schema.optional(Schema.Unknown)
179
+ }) {}
180
+
181
+ export class IdentityInfo extends Schema.Class<IdentityInfo>("IdentityInfo")({
182
+ did: Did,
183
+ handle: Handle,
184
+ didDoc: Schema.Unknown
185
+ }) {}
186
+
187
+ export class EmbedRecordView extends Schema.TaggedClass<EmbedRecordView>()(
188
+ "RecordView",
189
+ {
190
+ uri: PostUri,
191
+ cid: PostCid,
192
+ author: ProfileBasic,
193
+ value: Schema.Unknown,
194
+ labels: Schema.optional(Schema.Array(Label)),
195
+ metrics: Schema.optional(PostMetrics),
196
+ embeds: Schema.optional(Schema.Array(Schema.Unknown)),
197
+ indexedAt: Timestamp
198
+ }
199
+ ) {}
200
+
201
+ export class EmbedRecordNotFound extends Schema.TaggedClass<EmbedRecordNotFound>()(
202
+ "RecordNotFound",
203
+ {
204
+ uri: PostUri,
205
+ notFound: Schema.Literal(true)
206
+ }
207
+ ) {}
208
+
209
+ export class BlockedAuthor extends Schema.Class<BlockedAuthor>("BlockedAuthor")({
210
+ did: Did,
211
+ viewer: Schema.optional(Schema.Unknown)
212
+ }) {}
213
+
214
+ export class EmbedRecordBlocked extends Schema.TaggedClass<EmbedRecordBlocked>()(
215
+ "RecordBlocked",
216
+ {
217
+ uri: PostUri,
218
+ blocked: Schema.Literal(true),
219
+ author: BlockedAuthor
220
+ }
221
+ ) {}
222
+
223
+ export class EmbedRecordDetached extends Schema.TaggedClass<EmbedRecordDetached>()(
224
+ "RecordDetached",
225
+ {
226
+ uri: PostUri,
227
+ detached: Schema.Literal(true)
228
+ }
229
+ ) {}
230
+
231
+ export class EmbedRecordUnknown extends Schema.TaggedClass<EmbedRecordUnknown>()(
232
+ "RecordUnknown",
233
+ {
234
+ rawType: Schema.String,
235
+ data: Schema.Unknown
236
+ }
237
+ ) {}
238
+
239
+ export const EmbedRecordTarget = Schema.Union(
240
+ EmbedRecordView,
241
+ EmbedRecordNotFound,
242
+ EmbedRecordBlocked,
243
+ EmbedRecordDetached,
244
+ EmbedRecordUnknown
245
+ );
246
+ export type EmbedRecordTarget = typeof EmbedRecordTarget.Type;
247
+
248
+ export class EmbedRecord extends Schema.TaggedClass<EmbedRecord>()("Record", {
249
+ recordType: Schema.optional(Schema.String),
250
+ record: Schema.suspend(() => EmbedRecordTarget)
251
+ }) {}
252
+
253
+ export class EmbedRecordWithMedia extends Schema.TaggedClass<EmbedRecordWithMedia>()(
254
+ "RecordWithMedia",
255
+ {
256
+ recordType: Schema.optional(Schema.String),
257
+ record: Schema.suspend(() => EmbedRecordTarget),
258
+ media: Schema.Union(EmbedImages, EmbedExternal, EmbedVideo, Schema.Unknown)
259
+ }
260
+ ) {}
261
+
262
+ export class EmbedUnknown extends Schema.TaggedClass<EmbedUnknown>()("Unknown", {
263
+ rawType: Schema.String,
264
+ data: Schema.Unknown
265
+ }) {}
266
+
267
+ export const PostEmbed = Schema.Union(
268
+ EmbedImages,
269
+ EmbedExternal,
270
+ EmbedVideo,
271
+ EmbedRecord,
272
+ EmbedRecordWithMedia,
273
+ EmbedUnknown
274
+ );
275
+ export type PostEmbed = typeof PostEmbed.Type;
276
+
277
+ export const PostViewerState = Schema.Struct({
278
+ repost: Schema.optional(AtUri),
279
+ like: Schema.optional(AtUri),
280
+ bookmarked: Schema.optional(Schema.Boolean),
281
+ threadMuted: Schema.optional(Schema.Boolean),
282
+ replyDisabled: Schema.optional(Schema.Boolean),
283
+ embeddingDisabled: Schema.optional(Schema.Boolean),
284
+ pinned: Schema.optional(Schema.Boolean)
285
+ });
286
+ export type PostViewerState = typeof PostViewerState.Type;
287
+
288
+ export const ThreadgateView = Schema.Struct({
289
+ uri: Schema.optional(AtUri),
290
+ cid: Schema.optional(Schema.String),
291
+ record: Schema.optional(Schema.Unknown),
292
+ lists: Schema.optional(Schema.Array(Schema.Unknown))
293
+ });
294
+ export type ThreadgateView = typeof ThreadgateView.Type;
295
+
296
+ export class FeedPostViewRef extends Schema.Class<FeedPostViewRef>("FeedPostViewRef")({
297
+ uri: PostUri,
298
+ cid: PostCid,
299
+ author: ProfileBasic,
300
+ indexedAt: Timestamp,
301
+ labels: Schema.optional(Schema.Array(Label)),
302
+ viewer: Schema.optional(PostViewerState)
303
+ }) {}
304
+
305
+ export class FeedPostNotFound extends Schema.TaggedClass<FeedPostNotFound>()(
306
+ "FeedPostNotFound",
307
+ {
308
+ uri: PostUri,
309
+ notFound: Schema.Literal(true)
310
+ }
311
+ ) {}
312
+
313
+ export class FeedPostBlocked extends Schema.TaggedClass<FeedPostBlocked>()(
314
+ "FeedPostBlocked",
315
+ {
316
+ uri: PostUri,
317
+ blocked: Schema.Literal(true),
318
+ author: BlockedAuthor
319
+ }
320
+ ) {}
321
+
322
+ export class FeedPostUnknown extends Schema.TaggedClass<FeedPostUnknown>()(
323
+ "FeedPostUnknown",
324
+ {
325
+ rawType: Schema.String,
326
+ data: Schema.Unknown
327
+ }
328
+ ) {}
329
+
330
+ export const FeedPostReference = Schema.Union(
331
+ FeedPostViewRef,
332
+ FeedPostNotFound,
333
+ FeedPostBlocked,
334
+ FeedPostUnknown
335
+ );
336
+ export type FeedPostReference = typeof FeedPostReference.Type;
337
+
338
+ export class FeedReplyRef extends Schema.Class<FeedReplyRef>("FeedReplyRef")({
339
+ root: FeedPostReference,
340
+ parent: FeedPostReference,
341
+ grandparentAuthor: Schema.optional(ProfileBasic)
342
+ }) {}
343
+
344
+ export class FeedReasonRepost extends Schema.TaggedClass<FeedReasonRepost>()(
345
+ "ReasonRepost",
346
+ {
347
+ by: ProfileBasic,
348
+ uri: Schema.optional(PostUri),
349
+ cid: Schema.optional(PostCid),
350
+ indexedAt: Timestamp
351
+ }
352
+ ) {}
353
+
354
+ export class FeedReasonPin extends Schema.TaggedClass<FeedReasonPin>()("ReasonPin", {}) {}
355
+
356
+ export class FeedReasonUnknown extends Schema.TaggedClass<FeedReasonUnknown>()(
357
+ "ReasonUnknown",
358
+ {
359
+ rawType: Schema.String,
360
+ data: Schema.Unknown
361
+ }
362
+ ) {}
363
+
364
+ export const FeedReason = Schema.Union(
365
+ FeedReasonRepost,
366
+ FeedReasonPin,
367
+ FeedReasonUnknown
368
+ );
369
+ export type FeedReason = typeof FeedReason.Type;
370
+
371
+ export class FeedContext extends Schema.Class<FeedContext>("FeedContext")({
372
+ reply: Schema.optional(FeedReplyRef),
373
+ reason: Schema.optional(FeedReason),
374
+ feedContext: Schema.optional(Schema.String),
375
+ reqId: Schema.optional(Schema.String)
376
+ }) {}
377
+
378
+ export class FeedGeneratorViewerState extends Schema.Class<FeedGeneratorViewerState>(
379
+ "FeedGeneratorViewerState"
380
+ )({
381
+ like: Schema.optional(AtUri)
382
+ }) {}
383
+
384
+ export class FeedGeneratorView extends Schema.Class<FeedGeneratorView>("FeedGeneratorView")({
385
+ uri: AtUri,
386
+ cid: PostCid,
387
+ did: Did,
388
+ creator: ProfileView,
389
+ displayName: Schema.String,
390
+ description: Schema.optional(Schema.String),
391
+ descriptionFacets: Schema.optional(Schema.Array(Schema.Unknown)),
392
+ avatar: Schema.optional(Schema.String),
393
+ likeCount: Schema.optional(NonNegativeInt),
394
+ acceptsInteractions: Schema.optional(Schema.Boolean),
395
+ labels: Schema.optional(Schema.Array(Label)),
396
+ viewer: Schema.optional(FeedGeneratorViewerState),
397
+ contentMode: Schema.optional(Schema.String),
398
+ indexedAt: Timestamp
399
+ }) {}
400
+
401
+ export class PostLike extends Schema.Class<PostLike>("PostLike")({
402
+ actor: ProfileView,
403
+ createdAt: Timestamp,
404
+ indexedAt: Timestamp
405
+ }) {}
406
+
407
+ export const ListPurpose = Schema.Literal(
408
+ "app.bsky.graph.defs#modlist",
409
+ "app.bsky.graph.defs#curatelist",
410
+ "app.bsky.graph.defs#referencelist"
411
+ );
412
+ export type ListPurpose = typeof ListPurpose.Type;
413
+
414
+ export class ListViewerState extends Schema.Class<ListViewerState>("ListViewerState")({
415
+ muted: Schema.optional(Schema.Boolean),
416
+ blocked: Schema.optional(AtUri)
417
+ }) {}
418
+
419
+ export class ListViewBasic extends Schema.Class<ListViewBasic>("ListViewBasic")({
420
+ uri: AtUri,
421
+ cid: PostCid,
422
+ name: Schema.String,
423
+ purpose: ListPurpose,
424
+ avatar: Schema.optional(Schema.String),
425
+ listItemCount: Schema.optional(NonNegativeInt),
426
+ labels: Schema.optional(Schema.Array(Label)),
427
+ viewer: Schema.optional(ListViewerState),
428
+ indexedAt: Schema.optional(Timestamp)
429
+ }) {}
430
+
431
+ export class ListView extends Schema.Class<ListView>("ListView")({
432
+ uri: AtUri,
433
+ cid: PostCid,
434
+ creator: ProfileView,
435
+ name: Schema.String,
436
+ purpose: ListPurpose,
437
+ description: Schema.optional(Schema.String),
438
+ descriptionFacets: Schema.optional(Schema.Array(RichTextFacet)),
439
+ avatar: Schema.optional(Schema.String),
440
+ listItemCount: Schema.optional(NonNegativeInt),
441
+ labels: Schema.optional(Schema.Array(Label)),
442
+ viewer: Schema.optional(ListViewerState),
443
+ indexedAt: Timestamp
444
+ }) {}
445
+
446
+ export class ListItemView extends Schema.Class<ListItemView>("ListItemView")({
447
+ uri: AtUri,
448
+ subject: ProfileView
449
+ }) {}
450
+
451
+ export class Relationship extends Schema.Class<Relationship>("Relationship")({
452
+ did: Did,
453
+ following: Schema.optional(AtUri),
454
+ followedBy: Schema.optional(AtUri),
455
+ blocking: Schema.optional(AtUri),
456
+ blockedBy: Schema.optional(AtUri),
457
+ blockingByList: Schema.optional(AtUri),
458
+ blockedByList: Schema.optional(AtUri)
459
+ }) {}
460
+
461
+ export class NotFoundActor extends Schema.Class<NotFoundActor>("NotFoundActor")({
462
+ actor: Schema.String,
463
+ notFound: Schema.Literal(true)
464
+ }) {}
465
+
466
+ export const RelationshipView = Schema.Union(Relationship, NotFoundActor);
467
+ export type RelationshipView = typeof RelationshipView.Type;
@@ -0,0 +1,11 @@
1
+ import { Schema } from "effect";
2
+
3
+ export const OutputFormat = Schema.Literal("json", "ndjson", "markdown", "table");
4
+ export type OutputFormat = typeof OutputFormat.Type;
5
+
6
+ export class AppConfig extends Schema.Class<AppConfig>("AppConfig")({
7
+ service: Schema.String,
8
+ storeRoot: Schema.String,
9
+ outputFormat: OutputFormat,
10
+ identifier: Schema.optional(Schema.String)
11
+ }) {}
@@ -0,0 +1,6 @@
1
+ import { Schema } from "effect";
2
+
3
+ export class BskyCredentials extends Schema.Class<BskyCredentials>("BskyCredentials")({
4
+ identifier: Schema.String,
5
+ password: Schema.Redacted(Schema.String)
6
+ }) {}
@@ -0,0 +1,8 @@
1
+ import { StoreConfig } from "./store.js";
2
+
3
+ export const defaultStoreConfig = StoreConfig.make({
4
+ format: { json: true, markdown: false },
5
+ autoSync: false,
6
+ syncPolicy: "dedupe",
7
+ filters: []
8
+ });
@@ -0,0 +1,55 @@
1
+ import { Schema } from "effect";
2
+ import { StoreName, Timestamp, EventSeq } from "./primitives.js";
3
+ import { FilterExprSchema } from "./filter.js";
4
+
5
+ export const FilterEvaluationMode = Schema.Literal("EventTime", "DeriveTime");
6
+ export type FilterEvaluationMode = typeof FilterEvaluationMode.Type;
7
+
8
+ export class StoreSource extends Schema.Class<StoreSource>("StoreSource")({
9
+ storeName: StoreName,
10
+ filter: FilterExprSchema,
11
+ filterHash: Schema.String,
12
+ evaluationMode: FilterEvaluationMode,
13
+ derivedAt: Timestamp
14
+ }) {}
15
+
16
+ export class DerivationResult extends Schema.Class<DerivationResult>(
17
+ "DerivationResult"
18
+ )({
19
+ eventsProcessed: Schema.NonNegativeInt,
20
+ eventsMatched: Schema.NonNegativeInt,
21
+ eventsSkipped: Schema.NonNegativeInt,
22
+ deletesPropagated: Schema.NonNegativeInt,
23
+ durationMs: Schema.Number
24
+ }) {}
25
+
26
+ export class DerivationCheckpoint extends Schema.Class<DerivationCheckpoint>(
27
+ "DerivationCheckpoint"
28
+ )({
29
+ viewName: StoreName,
30
+ sourceStore: StoreName,
31
+ targetStore: StoreName,
32
+ filterHash: Schema.String,
33
+ evaluationMode: FilterEvaluationMode,
34
+ lastSourceEventSeq: Schema.optional(EventSeq),
35
+ eventsProcessed: Schema.NonNegativeInt,
36
+ eventsMatched: Schema.NonNegativeInt,
37
+ deletesPropagated: Schema.NonNegativeInt,
38
+ updatedAt: Timestamp
39
+ }) {}
40
+
41
+ export class StoreLineage extends Schema.Class<StoreLineage>("StoreLineage")({
42
+ storeName: StoreName,
43
+ isDerived: Schema.Boolean,
44
+ sources: Schema.Array(StoreSource),
45
+ updatedAt: Timestamp
46
+ }) {}
47
+
48
+ export class DerivationError extends Schema.TaggedError<DerivationError>()(
49
+ "DerivationError",
50
+ {
51
+ reason: Schema.String,
52
+ sourceStore: Schema.optional(StoreName),
53
+ targetStore: Schema.optional(StoreName)
54
+ }
55
+ ) {}
@@ -0,0 +1,71 @@
1
+ import { Schema } from "effect";
2
+ import { StoreName, StorePath } from "./primitives.js";
3
+
4
+ export class FilterCompileError extends Schema.TaggedError<FilterCompileError>()(
5
+ "FilterCompileError",
6
+ { message: Schema.String }
7
+ ) {}
8
+
9
+ export class FilterEvalError extends Schema.TaggedError<FilterEvalError>()(
10
+ "FilterEvalError",
11
+ { message: Schema.String, cause: Schema.optional(Schema.Unknown) }
12
+ ) {}
13
+
14
+ export class BskyError extends Schema.TaggedError<BskyError>()(
15
+ "BskyError",
16
+ {
17
+ message: Schema.String,
18
+ cause: Schema.optional(Schema.Unknown),
19
+ operation: Schema.optional(Schema.String),
20
+ status: Schema.optional(Schema.Number),
21
+ error: Schema.optional(Schema.String),
22
+ detail: Schema.optional(Schema.String)
23
+ }
24
+ ) {}
25
+
26
+ export class ConfigError extends Schema.TaggedError<ConfigError>()(
27
+ "ConfigError",
28
+ {
29
+ message: Schema.String,
30
+ path: Schema.optional(Schema.String),
31
+ cause: Schema.optional(Schema.Unknown)
32
+ }
33
+ ) {}
34
+
35
+ export class CredentialError extends Schema.TaggedError<CredentialError>()(
36
+ "CredentialError",
37
+ { message: Schema.String, cause: Schema.optional(Schema.Unknown) }
38
+ ) {}
39
+
40
+ export class StoreNotFound extends Schema.TaggedError<StoreNotFound>()(
41
+ "StoreNotFound",
42
+ { name: StoreName }
43
+ ) {}
44
+
45
+ export class StoreIoError extends Schema.TaggedError<StoreIoError>()(
46
+ "StoreIoError",
47
+ { path: StorePath, cause: Schema.Unknown }
48
+ ) {}
49
+
50
+ export class StoreIndexError extends Schema.TaggedError<StoreIndexError>()(
51
+ "StoreIndexError",
52
+ { message: Schema.String, cause: Schema.optional(Schema.Unknown) }
53
+ ) {}
54
+
55
+
56
+ export class FilterNotFound extends Schema.TaggedError<FilterNotFound>()(
57
+ "FilterNotFound",
58
+ { name: Schema.String }
59
+ ) {}
60
+
61
+ export class FilterLibraryError extends Schema.TaggedError<FilterLibraryError>()(
62
+ "FilterLibraryError",
63
+ {
64
+ message: Schema.String,
65
+ name: Schema.optional(Schema.String),
66
+ path: Schema.optional(Schema.String),
67
+ cause: Schema.optional(Schema.Unknown)
68
+ }
69
+ ) {}
70
+
71
+ export type StoreError = StoreNotFound | StoreIoError | StoreIndexError;
@@ -0,0 +1,55 @@
1
+ import { Schema } from "effect";
2
+ import { Post } from "./post.js";
3
+ import { EventId, EventSeq, PostCid, PostUri, Timestamp, StoreName } from "./primitives.js";
4
+ import { FilterExprSchema } from "./filter.js";
5
+
6
+ export const StoreQueryOrder = Schema.Literal("asc", "desc");
7
+ export type StoreQueryOrder = typeof StoreQueryOrder.Type;
8
+
9
+ export class EventMeta extends Schema.Class<EventMeta>("EventMeta")({
10
+ source: Schema.Literal(
11
+ "timeline",
12
+ "notifications",
13
+ "jetstream",
14
+ "feed",
15
+ "list",
16
+ "author",
17
+ "thread"
18
+ ),
19
+ command: Schema.String,
20
+ filterExprHash: Schema.optional(Schema.String),
21
+ createdAt: Timestamp,
22
+ sourceStore: Schema.optional(StoreName)
23
+ }) {}
24
+
25
+ export class PostUpsert extends Schema.TaggedClass<PostUpsert>()("PostUpsert", {
26
+ post: Post,
27
+ meta: EventMeta
28
+ }) {}
29
+
30
+ export class PostDelete extends Schema.TaggedClass<PostDelete>()("PostDelete", {
31
+ uri: PostUri,
32
+ cid: Schema.optional(PostCid),
33
+ meta: EventMeta
34
+ }) {}
35
+
36
+ export const PostEvent = Schema.Union(PostUpsert, PostDelete);
37
+ export type PostEvent = typeof PostEvent.Type;
38
+
39
+ export class PostEventRecord extends Schema.Class<PostEventRecord>("PostEventRecord")({
40
+ id: EventId,
41
+ version: Schema.Literal(1),
42
+ event: PostEvent
43
+ }) {}
44
+
45
+ export type EventLogEntry = {
46
+ readonly seq: EventSeq;
47
+ readonly record: PostEventRecord;
48
+ };
49
+
50
+ export class StoreQuery extends Schema.Class<StoreQuery>("StoreQuery")({
51
+ range: Schema.optional(Schema.Struct({ start: Timestamp, end: Timestamp })),
52
+ filter: Schema.optional(FilterExprSchema),
53
+ scanLimit: Schema.optional(Schema.NonNegativeInt),
54
+ order: Schema.optional(StoreQueryOrder)
55
+ }) {}