diff --git a/lexicons/feed/subscription.json b/lexicons/feed/subscription.json --- a/lexicons/feed/subscription.json +++ b/lexicons/feed/subscription.json @@ -14,13 +14,8 @@ "properties": { "subject": { "type": "union", - "refs": ["#uri", "#repo"], + "refs": ["#record", "#repo"], "closed": true - }, - "collections": { - "type": "array", - "items": { "type": "string" }, - "description": "Optional collection NSIDs to filter which notifications are sent. Empty or absent means all collections." }, "createdAt": { "type": "string", @@ -29,7 +24,7 @@ } } }, - "uri": { + "record": { "type": "object", "required": ["uri"], "properties": { diff --git a/bobbin/crates/types/src/edges.rs b/bobbin/crates/types/src/edges.rs --- a/bobbin/crates/types/src/edges.rs +++ b/bobbin/crates/types/src/edges.rs @@ -419,7 +419,7 @@ ) -> Result, ExtractError> { use crate::sh_tangled::feed::subscription::SubscriptionSubject; let subject = match &record.subject { - SubscriptionSubject::Uri(v) => { + SubscriptionSubject::Record(v) => { let Some(subject) = uri_subject_for_record(&v.uri) else { return Ok(Vec::new()); }; diff --git a/web/src/lib/api/lexicons/index.ts b/web/src/lib/api/lexicons/index.ts --- a/web/src/lib/api/lexicons/index.ts +++ b/web/src/lib/api/lexicons/index.ts @@ -30,6 +30,7 @@ export * as ShTangledFeedListStarsBy from "./types/sh/tangled/feed/listStarsBy.js"; export * as ShTangledFeedReaction from "./types/sh/tangled/feed/reaction.js"; export * as ShTangledFeedStar from "./types/sh/tangled/feed/star.js"; +export * as ShTangledFeedSubscription from "./types/sh/tangled/feed/subscription.js"; export * as ShTangledGitCountRefUpdates from "./types/sh/tangled/git/countRefUpdates.js"; export * as ShTangledGitCountRefUpdatesBy from "./types/sh/tangled/git/countRefUpdatesBy.js"; export * as ShTangledGitDefs from "./types/sh/tangled/git/defs.js"; diff --git a/web/src/lib/api/lexicons/types/sh/tangled/feed/subscription.ts b/web/src/lib/api/lexicons/types/sh/tangled/feed/subscription.ts new file mode 100644 --- /dev/null +++ b/web/src/lib/api/lexicons/types/sh/tangled/feed/subscription.ts @@ -0,0 +1,48 @@ +import type {} from "@atcute/lexicons"; +import * as v from "@atcute/lexicons/validations"; +import type {} from "@atcute/lexicons/ambient"; + +const _mainSchema = /*#__PURE__*/ v.record( + /*#__PURE__*/ v.tidString(), + /*#__PURE__*/ v.object({ + $type: /*#__PURE__*/ v.literal("sh.tangled.feed.subscription"), + createdAt: /*#__PURE__*/ v.datetimeString(), + get subject() { + return /*#__PURE__*/ v.variant([recordSchema, repoSchema], true); + }, + }), +); +const _recordSchema = /*#__PURE__*/ v.object({ + $type: /*#__PURE__*/ v.optional( + /*#__PURE__*/ v.literal("sh.tangled.feed.subscription#record"), + ), + uri: /*#__PURE__*/ v.resourceUriString(), +}); +const _repoSchema = /*#__PURE__*/ v.object({ + $type: /*#__PURE__*/ v.optional( + /*#__PURE__*/ v.literal("sh.tangled.feed.subscription#repo"), + ), + did: /*#__PURE__*/ v.didString(), +}); + +type main$schematype = typeof _mainSchema; +type record$schematype = typeof _recordSchema; +type repo$schematype = typeof _repoSchema; + +export interface mainSchema extends main$schematype {} +export interface recordSchema extends record$schematype {} +export interface repoSchema extends repo$schematype {} + +export const mainSchema = _mainSchema as mainSchema; +export const recordSchema = _recordSchema as recordSchema; +export const repoSchema = _repoSchema as repoSchema; + +export interface Main extends v.InferInput {} +export interface Record extends v.InferInput {} +export interface Repo extends v.InferInput {} + +declare module "@atcute/lexicons/ambient" { + interface Records { + "sh.tangled.feed.subscription": mainSchema; + } +}