11import * as Schema from "effect/Schema"
2- import type * as SchemaAST from "effect/SchemaAST"
32
43import {
54 activityStreamsJsonLdContext ,
6- forgeFedJsonLdContext ,
7- securityJsonLdContext ,
8- socialWebWebfingerJsonLdContext
5+ forgeFedJsonLdContext
96} from "./contracts.js"
107
118export type JsonPrimitive = boolean | number | string | null
129export type JsonValue = JsonPrimitive | JsonObject | ReadonlyArray < JsonValue >
1310export type JsonObject = Readonly < { [ key : string ] : JsonValue } >
1411
15- export const exactActivityPubParseOptions : SchemaAST . ParseOptions = {
16- onExcessProperty : "error"
17- }
18-
1912export const JsonValueSchema : Schema . Schema < JsonValue > = Schema . suspend ( ( ) =>
2013 Schema . Union (
2114 Schema . Null ,
@@ -28,67 +21,12 @@ export const JsonValueSchema: Schema.Schema<JsonValue> = Schema.suspend(() =>
2821)
2922
3023const OptionalString = Schema . optional ( Schema . String )
31- const JsonObjectSchema = Schema . Record ( { key : Schema . String , value : JsonValueSchema } )
32- const JsonLdContextEntrySchema = Schema . Union ( Schema . String , JsonObjectSchema )
33- const JsonLdIdMappingSchema = Schema . Struct ( {
34- "@id" : Schema . String ,
35- "@type" : Schema . Literal ( "@id" )
36- } )
3724
3825export const ActivityForgeFedJsonLdContextSchema = Schema . Tuple (
3926 Schema . Literal ( activityStreamsJsonLdContext ) ,
4027 Schema . Literal ( forgeFedJsonLdContext )
4128)
4229
43- export const LocalActorJsonLdContextSchema = Schema . Tuple (
44- Schema . Literal ( activityStreamsJsonLdContext ) ,
45- Schema . Literal ( securityJsonLdContext ) ,
46- Schema . Literal ( forgeFedJsonLdContext )
47- )
48-
49- export const MastodonActorContextExtensionsSchema = Schema . Struct ( {
50- manuallyApprovesFollowers : Schema . String ,
51- toot : Schema . String ,
52- featured : JsonLdIdMappingSchema ,
53- featuredTags : JsonLdIdMappingSchema ,
54- alsoKnownAs : JsonLdIdMappingSchema ,
55- movedTo : JsonLdIdMappingSchema ,
56- schema : Schema . String ,
57- PropertyValue : Schema . String ,
58- value : Schema . String ,
59- discoverable : Schema . String ,
60- suspended : Schema . String ,
61- memorial : Schema . String ,
62- indexable : Schema . String ,
63- attributionDomains : JsonLdIdMappingSchema ,
64- showFeatured : Schema . String ,
65- showMedia : Schema . String ,
66- showRepliesInMedia : Schema . String ,
67- gts : Schema . String ,
68- interactionPolicy : JsonLdIdMappingSchema ,
69- canQuote : JsonLdIdMappingSchema ,
70- automaticApproval : JsonLdIdMappingSchema ,
71- manualApproval : JsonLdIdMappingSchema
72- } )
73-
74- export const MastodonActorJsonLdContextSchema = Schema . Tuple (
75- Schema . Literal ( activityStreamsJsonLdContext ) ,
76- Schema . Literal ( securityJsonLdContext ) ,
77- Schema . Literal ( socialWebWebfingerJsonLdContext ) ,
78- MastodonActorContextExtensionsSchema
79- )
80-
81- export const ActorJsonLdContextSchema = Schema . Union (
82- LocalActorJsonLdContextSchema ,
83- MastodonActorJsonLdContextSchema
84- )
85-
86- export const JsonLdContextSchema = Schema . Union (
87- Schema . String ,
88- JsonObjectSchema ,
89- Schema . Array ( JsonLdContextEntrySchema )
90- )
91-
9230export const ForgeFedTicketSourceSchema = Schema . Struct ( {
9331 content : OptionalString ,
9432 mediaType : OptionalString
@@ -110,118 +48,6 @@ export const ForgeFedTicketSchema = Schema.Struct({
11048 raw : Schema . optional ( JsonValueSchema )
11149} )
11250
113- export const ActivityPubPublicKeySchema = Schema . Struct ( {
114- id : Schema . String ,
115- owner : Schema . String ,
116- publicKeyPem : Schema . String
117- } )
118-
119- const ActivityPubEndpointsSchema = Schema . Struct ( {
120- sharedInbox : Schema . String
121- } )
122-
123- const ActivityPubImageSchema = Schema . Struct ( {
124- type : Schema . Literal ( "Image" ) ,
125- mediaType : OptionalString ,
126- url : Schema . String ,
127- name : OptionalString
128- } )
129-
130- const ActivityPubActorAttachmentSchema = Schema . Struct ( {
131- type : Schema . Literal ( "PropertyValue" ) ,
132- name : Schema . String ,
133- value : Schema . String
134- } )
135-
136- const ActivityPubHashtagTagSchema = Schema . Struct ( {
137- type : Schema . Literal ( "Hashtag" ) ,
138- name : Schema . String ,
139- href : Schema . String
140- } )
141-
142- const ActivityPubEmojiTagSchema = Schema . Struct ( {
143- type : Schema . Literal ( "Emoji" ) ,
144- id : Schema . String ,
145- name : Schema . String ,
146- icon : ActivityPubImageSchema ,
147- updated : OptionalString
148- } )
149-
150- const ActivityPubActorTagSchema = Schema . Union (
151- ActivityPubHashtagTagSchema ,
152- ActivityPubEmojiTagSchema
153- )
154-
155- const ActivityPubInteractionApprovalSchema = Schema . Struct ( {
156- automaticApproval : Schema . optional ( Schema . Array ( Schema . String ) ) ,
157- manualApproval : Schema . optional ( Schema . Array ( Schema . String ) )
158- } ) . pipe (
159- Schema . filter ( ( approval ) =>
160- approval . automaticApproval !== undefined ||
161- approval . manualApproval !== undefined )
162- )
163-
164- const MastodonInteractionPolicySchema = Schema . Struct ( {
165- canFeature : Schema . optional ( ActivityPubInteractionApprovalSchema ) ,
166- canQuote : Schema . optional ( ActivityPubInteractionApprovalSchema )
167- } ) . pipe (
168- Schema . filter ( ( policy ) =>
169- policy . canFeature !== undefined ||
170- policy . canQuote !== undefined )
171- )
172-
173- export const LocalActivityPubPersonSchema = Schema . Struct ( {
174- "@context" : LocalActorJsonLdContextSchema ,
175- type : Schema . Literal ( "Person" ) ,
176- id : Schema . String ,
177- name : Schema . String ,
178- preferredUsername : Schema . String ,
179- summary : Schema . String ,
180- inbox : Schema . String ,
181- outbox : Schema . String ,
182- followers : Schema . String ,
183- following : Schema . String ,
184- liked : Schema . String ,
185- publicKey : ActivityPubPublicKeySchema ,
186- endpoints : ActivityPubEndpointsSchema
187- } )
188-
189- export const MastodonIssueActivityPubPersonSchema = Schema . Struct ( {
190- "@context" : MastodonActorJsonLdContextSchema ,
191- id : Schema . String ,
192- webfinger : Schema . String ,
193- type : Schema . Literal ( "Person" ) ,
194- following : Schema . String ,
195- followers : Schema . String ,
196- inbox : Schema . String ,
197- outbox : Schema . String ,
198- featured : Schema . String ,
199- featuredTags : Schema . String ,
200- preferredUsername : Schema . String ,
201- name : Schema . String ,
202- summary : Schema . String ,
203- url : Schema . String ,
204- manuallyApprovesFollowers : Schema . Boolean ,
205- discoverable : Schema . Boolean ,
206- indexable : Schema . Boolean ,
207- published : Schema . String ,
208- memorial : Schema . Boolean ,
209- showFeatured : Schema . Boolean ,
210- showMedia : Schema . Boolean ,
211- showRepliesInMedia : Schema . Boolean ,
212- interactionPolicy : MastodonInteractionPolicySchema ,
213- featuredCollections : Schema . String ,
214- publicKey : ActivityPubPublicKeySchema ,
215- tag : Schema . Array ( ActivityPubActorTagSchema ) ,
216- attachment : Schema . Array ( ActivityPubActorAttachmentSchema ) ,
217- endpoints : ActivityPubEndpointsSchema
218- } )
219-
220- export const ActivityPubPersonSchema = Schema . Union (
221- LocalActivityPubPersonSchema ,
222- MastodonIssueActivityPubPersonSchema
223- )
224-
22551export const ActivityPubFollowActivitySchema = Schema . Struct ( {
22652 "@context" : ActivityForgeFedJsonLdContextSchema ,
22753 id : Schema . String ,
@@ -239,50 +65,3 @@ export const LocalActivityPubOrderedCollectionSchema = Schema.Struct({
23965 totalItems : Schema . Number ,
24066 orderedItems : Schema . Array ( JsonValueSchema )
24167} )
242-
243- export const LocalActivityPubFollowersCollectionSchema = Schema . Struct ( {
244- "@context" : ActivityForgeFedJsonLdContextSchema ,
245- type : Schema . Literal ( "OrderedCollection" ) ,
246- id : Schema . String ,
247- totalItems : Schema . Number ,
248- first : Schema . String ,
249- orderedItems : Schema . Array ( JsonValueSchema )
250- } )
251-
252- export const MastodonFollowersOrderedCollectionSchema = Schema . Struct ( {
253- "@context" : Schema . Literal ( activityStreamsJsonLdContext ) ,
254- id : Schema . String ,
255- type : Schema . Literal ( "OrderedCollection" ) ,
256- totalItems : Schema . Number ,
257- first : Schema . String
258- } )
259-
260- export const ActivityPubOrderedCollectionSchema = Schema . Union (
261- LocalActivityPubOrderedCollectionSchema ,
262- LocalActivityPubFollowersCollectionSchema ,
263- MastodonFollowersOrderedCollectionSchema
264- )
265-
266- export const LocalActivityPubOrderedCollectionPageSchema = Schema . Struct ( {
267- "@context" : ActivityForgeFedJsonLdContextSchema ,
268- type : Schema . Literal ( "OrderedCollectionPage" ) ,
269- id : Schema . String ,
270- totalItems : Schema . Number ,
271- partOf : Schema . String ,
272- orderedItems : Schema . Array ( JsonValueSchema )
273- } )
274-
275- export const MastodonFollowersOrderedCollectionPageSchema = Schema . Struct ( {
276- "@context" : Schema . Literal ( activityStreamsJsonLdContext ) ,
277- id : Schema . String ,
278- type : Schema . Literal ( "OrderedCollectionPage" ) ,
279- totalItems : Schema . Number ,
280- partOf : Schema . String ,
281- next : Schema . String ,
282- orderedItems : Schema . Array ( Schema . String )
283- } )
284-
285- export const ActivityPubOrderedCollectionPageSchema = Schema . Union (
286- LocalActivityPubOrderedCollectionPageSchema ,
287- MastodonFollowersOrderedCollectionPageSchema
288- )
0 commit comments