Improve codegen quality (shorter typenames) ()

* Improve lex-cli's generated code (specifically type names)

* Update to use the shorter typenames

Co-authored-by: Devin Ivy <devinivy@gmail.com>
This commit is contained in:
Paul Frazee 2022-10-26 13:45:42 -05:00 committed by GitHub
parent 4a65804db5
commit 07a2bd117d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
37 changed files with 476 additions and 396 deletions

@ -804,12 +804,12 @@ export const methodSchemaDict: Record<string, MethodSchema> = {
feed: {
type: 'array',
items: {
$ref: '#/$defs/appBskyGetAuthorFeedFeedItem',
$ref: '#/$defs/feedItem',
},
},
},
$defs: {
appBskyGetAuthorFeedFeedItem: {
feedItem: {
type: 'object',
required: [
'uri',
@ -829,10 +829,10 @@ export const methodSchemaDict: Record<string, MethodSchema> = {
type: 'string',
},
author: {
$ref: '#/$defs/appBskyGetAuthorFeedUser',
$ref: '#/$defs/user',
},
repostedBy: {
$ref: '#/$defs/appBskyGetAuthorFeedUser',
$ref: '#/$defs/user',
},
record: {
type: 'object',
@ -840,13 +840,13 @@ export const methodSchemaDict: Record<string, MethodSchema> = {
embed: {
oneOf: [
{
$ref: '#/$defs/appBskyGetAuthorFeedRecordEmbed',
$ref: '#/$defs/recordEmbed',
},
{
$ref: '#/$defs/appBskyGetAuthorFeedExternalEmbed',
$ref: '#/$defs/externalEmbed',
},
{
$ref: '#/$defs/appBskyGetAuthorFeedUnknownEmbed',
$ref: '#/$defs/unknownEmbed',
},
],
},
@ -876,7 +876,7 @@ export const methodSchemaDict: Record<string, MethodSchema> = {
},
},
},
appBskyGetAuthorFeedUser: {
user: {
type: 'object',
required: ['did', 'name'],
properties: {
@ -892,7 +892,7 @@ export const methodSchemaDict: Record<string, MethodSchema> = {
},
},
},
appBskyGetAuthorFeedRecordEmbed: {
recordEmbed: {
type: 'object',
required: ['type', 'author', 'record'],
properties: {
@ -900,14 +900,14 @@ export const methodSchemaDict: Record<string, MethodSchema> = {
const: 'record',
},
author: {
$ref: '#/$defs/appBskyGetAuthorFeedUser',
$ref: '#/$defs/user',
},
record: {
type: 'object',
},
},
},
appBskyGetAuthorFeedExternalEmbed: {
externalEmbed: {
type: 'object',
required: ['type', 'uri', 'title', 'description', 'imageUri'],
properties: {
@ -928,7 +928,7 @@ export const methodSchemaDict: Record<string, MethodSchema> = {
},
},
},
appBskyGetAuthorFeedUnknownEmbed: {
unknownEmbed: {
type: 'object',
required: ['type'],
properties: {
@ -964,10 +964,10 @@ export const methodSchemaDict: Record<string, MethodSchema> = {
type: 'string',
},
author: {
$ref: '#/$defs/appBskyGetAuthorFeedUser',
$ref: '#/$defs/user',
},
repostedBy: {
$ref: '#/$defs/appBskyGetAuthorFeedUser',
$ref: '#/$defs/user',
},
record: {
type: 'object',
@ -975,13 +975,13 @@ export const methodSchemaDict: Record<string, MethodSchema> = {
embed: {
oneOf: [
{
$ref: '#/$defs/appBskyGetAuthorFeedRecordEmbed',
$ref: '#/$defs/recordEmbed',
},
{
$ref: '#/$defs/appBskyGetAuthorFeedExternalEmbed',
$ref: '#/$defs/externalEmbed',
},
{
$ref: '#/$defs/appBskyGetAuthorFeedUnknownEmbed',
$ref: '#/$defs/unknownEmbed',
},
],
},
@ -1035,7 +1035,7 @@ export const methodSchemaDict: Record<string, MethodSchema> = {
const: 'record',
},
author: {
$ref: '#/$defs/appBskyGetAuthorFeedUser',
$ref: '#/$defs/user',
},
record: {
type: 'object',
@ -1174,12 +1174,12 @@ export const methodSchemaDict: Record<string, MethodSchema> = {
feed: {
type: 'array',
items: {
$ref: '#/$defs/appBskyGetHomeFeedFeedItem',
$ref: '#/$defs/feedItem',
},
},
},
$defs: {
appBskyGetHomeFeedFeedItem: {
feedItem: {
type: 'object',
required: [
'uri',
@ -1199,10 +1199,10 @@ export const methodSchemaDict: Record<string, MethodSchema> = {
type: 'string',
},
author: {
$ref: '#/$defs/appBskyGetHomeFeedUser',
$ref: '#/$defs/user',
},
repostedBy: {
$ref: '#/$defs/appBskyGetHomeFeedUser',
$ref: '#/$defs/user',
},
record: {
type: 'object',
@ -1210,13 +1210,13 @@ export const methodSchemaDict: Record<string, MethodSchema> = {
embed: {
oneOf: [
{
$ref: '#/$defs/appBskyGetHomeFeedRecordEmbed',
$ref: '#/$defs/recordEmbed',
},
{
$ref: '#/$defs/appBskyGetHomeFeedExternalEmbed',
$ref: '#/$defs/externalEmbed',
},
{
$ref: '#/$defs/appBskyGetHomeFeedUnknownEmbed',
$ref: '#/$defs/unknownEmbed',
},
],
},
@ -1246,7 +1246,7 @@ export const methodSchemaDict: Record<string, MethodSchema> = {
},
},
},
appBskyGetHomeFeedUser: {
user: {
type: 'object',
required: ['did', 'name'],
properties: {
@ -1262,7 +1262,7 @@ export const methodSchemaDict: Record<string, MethodSchema> = {
},
},
},
appBskyGetHomeFeedRecordEmbed: {
recordEmbed: {
type: 'object',
required: ['type', 'author', 'record'],
properties: {
@ -1270,14 +1270,14 @@ export const methodSchemaDict: Record<string, MethodSchema> = {
const: 'record',
},
author: {
$ref: '#/$defs/appBskyGetHomeFeedUser',
$ref: '#/$defs/user',
},
record: {
type: 'object',
},
},
},
appBskyGetHomeFeedExternalEmbed: {
externalEmbed: {
type: 'object',
required: ['type', 'uri', 'title', 'description', 'imageUri'],
properties: {
@ -1298,7 +1298,7 @@ export const methodSchemaDict: Record<string, MethodSchema> = {
},
},
},
appBskyGetHomeFeedUnknownEmbed: {
unknownEmbed: {
type: 'object',
required: ['type'],
properties: {
@ -1334,10 +1334,10 @@ export const methodSchemaDict: Record<string, MethodSchema> = {
type: 'string',
},
author: {
$ref: '#/$defs/appBskyGetHomeFeedUser',
$ref: '#/$defs/user',
},
repostedBy: {
$ref: '#/$defs/appBskyGetHomeFeedUser',
$ref: '#/$defs/user',
},
record: {
type: 'object',
@ -1345,13 +1345,13 @@ export const methodSchemaDict: Record<string, MethodSchema> = {
embed: {
oneOf: [
{
$ref: '#/$defs/appBskyGetHomeFeedRecordEmbed',
$ref: '#/$defs/recordEmbed',
},
{
$ref: '#/$defs/appBskyGetHomeFeedExternalEmbed',
$ref: '#/$defs/externalEmbed',
},
{
$ref: '#/$defs/appBskyGetHomeFeedUnknownEmbed',
$ref: '#/$defs/unknownEmbed',
},
],
},
@ -1405,7 +1405,7 @@ export const methodSchemaDict: Record<string, MethodSchema> = {
const: 'record',
},
author: {
$ref: '#/$defs/appBskyGetHomeFeedUser',
$ref: '#/$defs/user',
},
record: {
type: 'object',
@ -1559,12 +1559,12 @@ export const methodSchemaDict: Record<string, MethodSchema> = {
notifications: {
type: 'array',
items: {
$ref: '#/$defs/appBskyGetNotificationsNotification',
$ref: '#/$defs/notification',
},
},
},
$defs: {
appBskyGetNotificationsNotification: {
notification: {
type: 'object',
required: [
'uri',
@ -1700,11 +1700,11 @@ export const methodSchemaDict: Record<string, MethodSchema> = {
required: ['thread'],
properties: {
thread: {
$ref: '#/$defs/appBskyGetPostThreadPost',
$ref: '#/$defs/post',
},
},
$defs: {
appBskyGetPostThreadPost: {
post: {
type: 'object',
required: [
'uri',
@ -1724,7 +1724,7 @@ export const methodSchemaDict: Record<string, MethodSchema> = {
type: 'string',
},
author: {
$ref: '#/$defs/appBskyGetPostThreadUser',
$ref: '#/$defs/user',
},
record: {
type: 'object',
@ -1732,18 +1732,18 @@ export const methodSchemaDict: Record<string, MethodSchema> = {
embed: {
oneOf: [
{
$ref: '#/$defs/appBskyGetPostThreadRecordEmbed',
$ref: '#/$defs/recordEmbed',
},
{
$ref: '#/$defs/appBskyGetPostThreadExternalEmbed',
$ref: '#/$defs/externalEmbed',
},
{
$ref: '#/$defs/appBskyGetPostThreadUnknownEmbed',
$ref: '#/$defs/unknownEmbed',
},
],
},
parent: {
$ref: '#/$defs/appBskyGetPostThreadPost',
$ref: '#/$defs/post',
},
replyCount: {
type: 'number',
@ -1751,7 +1751,7 @@ export const methodSchemaDict: Record<string, MethodSchema> = {
replies: {
type: 'array',
items: {
$ref: '#/$defs/appBskyGetPostThreadPost',
$ref: '#/$defs/post',
},
},
likeCount: {
@ -1777,7 +1777,7 @@ export const methodSchemaDict: Record<string, MethodSchema> = {
},
},
},
appBskyGetPostThreadUser: {
user: {
type: 'object',
required: ['did', 'name'],
properties: {
@ -1793,7 +1793,7 @@ export const methodSchemaDict: Record<string, MethodSchema> = {
},
},
},
appBskyGetPostThreadRecordEmbed: {
recordEmbed: {
type: 'object',
required: ['type', 'author', 'record'],
properties: {
@ -1801,14 +1801,14 @@ export const methodSchemaDict: Record<string, MethodSchema> = {
const: 'record',
},
author: {
$ref: '#/$defs/appBskyGetPostThreadUser',
$ref: '#/$defs/user',
},
record: {
type: 'object',
},
},
},
appBskyGetPostThreadExternalEmbed: {
externalEmbed: {
type: 'object',
required: ['type', 'uri', 'title', 'description', 'imageUri'],
properties: {
@ -1829,7 +1829,7 @@ export const methodSchemaDict: Record<string, MethodSchema> = {
},
},
},
appBskyGetPostThreadUnknownEmbed: {
unknownEmbed: {
type: 'object',
required: ['type'],
properties: {
@ -1865,7 +1865,7 @@ export const methodSchemaDict: Record<string, MethodSchema> = {
type: 'string',
},
author: {
$ref: '#/$defs/appBskyGetPostThreadUser',
$ref: '#/$defs/user',
},
record: {
type: 'object',
@ -1873,18 +1873,18 @@ export const methodSchemaDict: Record<string, MethodSchema> = {
embed: {
oneOf: [
{
$ref: '#/$defs/appBskyGetPostThreadRecordEmbed',
$ref: '#/$defs/recordEmbed',
},
{
$ref: '#/$defs/appBskyGetPostThreadExternalEmbed',
$ref: '#/$defs/externalEmbed',
},
{
$ref: '#/$defs/appBskyGetPostThreadUnknownEmbed',
$ref: '#/$defs/unknownEmbed',
},
],
},
parent: {
$ref: '#/$defs/appBskyGetPostThreadPost',
$ref: '#/$defs/post',
},
replyCount: {
type: 'number',
@ -1892,7 +1892,7 @@ export const methodSchemaDict: Record<string, MethodSchema> = {
replies: {
type: 'array',
items: {
$ref: '#/$defs/appBskyGetPostThreadPost',
$ref: '#/$defs/post',
},
},
likeCount: {
@ -1942,7 +1942,7 @@ export const methodSchemaDict: Record<string, MethodSchema> = {
const: 'record',
},
author: {
$ref: '#/$defs/appBskyGetPostThreadUser',
$ref: '#/$defs/user',
},
record: {
type: 'object',
@ -2033,7 +2033,7 @@ export const methodSchemaDict: Record<string, MethodSchema> = {
pinnedBadges: {
type: 'array',
items: {
$ref: '#/$defs/appBskyGetProfileBadge',
$ref: '#/$defs/badge',
},
},
myState: {
@ -2046,7 +2046,7 @@ export const methodSchemaDict: Record<string, MethodSchema> = {
},
},
$defs: {
appBskyGetProfileBadge: {
badge: {
type: 'object',
required: ['uri', 'cid'],
properties: {
@ -2523,12 +2523,12 @@ export const methodSchemaDict: Record<string, MethodSchema> = {
pinnedBadges: {
type: 'array',
items: {
$ref: '#/$defs/appBskyProfileBadgeRef',
$ref: '#/$defs/badgeRef',
},
},
},
$defs: {
appBskyProfileBadgeRef: {
badgeRef: {
type: 'object',
required: ['uri', 'cid'],
properties: {
@ -2590,16 +2590,16 @@ export const recordSchemaDict: Record<string, RecordSchema> = {
assertion: {
oneOf: [
{
$ref: '#/$defs/appBskyBadgeInviteAssertion',
$ref: '#/$defs/inviteAssertion',
},
{
$ref: '#/$defs/appBskyBadgeEmployeeAssertion',
$ref: '#/$defs/employeeAssertion',
},
{
$ref: '#/$defs/appBskyBadgeTagAssertion',
$ref: '#/$defs/tagAssertion',
},
{
$ref: '#/$defs/appBskyBadgeUnknownAssertion',
$ref: '#/$defs/unknownAssertion',
},
],
},
@ -2609,7 +2609,7 @@ export const recordSchemaDict: Record<string, RecordSchema> = {
},
},
$defs: {
appBskyBadgeInviteAssertion: {
inviteAssertion: {
type: 'object',
required: ['type'],
properties: {
@ -2618,7 +2618,7 @@ export const recordSchemaDict: Record<string, RecordSchema> = {
},
},
},
appBskyBadgeEmployeeAssertion: {
employeeAssertion: {
type: 'object',
required: ['type'],
properties: {
@ -2627,7 +2627,7 @@ export const recordSchemaDict: Record<string, RecordSchema> = {
},
},
},
appBskyBadgeTagAssertion: {
tagAssertion: {
type: 'object',
required: ['type', 'tag'],
properties: {
@ -2640,7 +2640,7 @@ export const recordSchemaDict: Record<string, RecordSchema> = {
},
},
},
appBskyBadgeUnknownAssertion: {
unknownAssertion: {
type: 'object',
required: ['type'],
properties: {
@ -2710,10 +2710,10 @@ export const recordSchemaDict: Record<string, RecordSchema> = {
required: ['badge', 'offer', 'createdAt'],
properties: {
badge: {
$ref: '#/$defs/appBskyBadgeAcceptSubject',
$ref: '#/$defs/subject',
},
offer: {
$ref: '#/$defs/appBskyBadgeAcceptSubject',
$ref: '#/$defs/subject',
},
createdAt: {
type: 'string',
@ -2721,7 +2721,7 @@ export const recordSchemaDict: Record<string, RecordSchema> = {
},
},
$defs: {
appBskyBadgeAcceptSubject: {
subject: {
type: 'object',
required: ['uri', 'cid'],
properties: {
@ -2760,7 +2760,7 @@ export const recordSchemaDict: Record<string, RecordSchema> = {
required: ['badge', 'subject', 'createdAt'],
properties: {
badge: {
$ref: '#/$defs/appBskyBadgeOfferBadge',
$ref: '#/$defs/badge',
},
subject: {
type: 'string',
@ -2771,7 +2771,7 @@ export const recordSchemaDict: Record<string, RecordSchema> = {
},
},
$defs: {
appBskyBadgeOfferBadge: {
badge: {
type: 'object',
required: ['uri', 'cid'],
properties: {
@ -2831,7 +2831,7 @@ export const recordSchemaDict: Record<string, RecordSchema> = {
required: ['subject', 'createdAt'],
properties: {
subject: {
$ref: '#/$defs/appBskyLikeSubject',
$ref: '#/$defs/subject',
},
createdAt: {
type: 'string',
@ -2839,7 +2839,7 @@ export const recordSchemaDict: Record<string, RecordSchema> = {
},
},
$defs: {
appBskyLikeSubject: {
subject: {
type: 'object',
required: ['uri', 'cid'],
properties: {
@ -2881,12 +2881,12 @@ export const recordSchemaDict: Record<string, RecordSchema> = {
media: {
type: 'array',
items: {
$ref: '#/$defs/appBskyMediaEmbedMediaEmbed',
$ref: '#/$defs/mediaEmbed',
},
},
},
$defs: {
appBskyMediaEmbedMediaEmbed: {
mediaEmbed: {
type: 'object',
required: ['original'],
properties: {
@ -2894,14 +2894,14 @@ export const recordSchemaDict: Record<string, RecordSchema> = {
type: 'string',
},
thumb: {
$ref: '#/$defs/appBskyMediaEmbedMediaEmbedBlob',
$ref: '#/$defs/mediaEmbedBlob',
},
original: {
$ref: '#/$defs/appBskyMediaEmbedMediaEmbedBlob',
$ref: '#/$defs/mediaEmbedBlob',
},
},
},
appBskyMediaEmbedMediaEmbedBlob: {
mediaEmbedBlob: {
type: 'object',
required: ['mimeType', 'blobId'],
properties: {
@ -2924,10 +2924,10 @@ export const recordSchemaDict: Record<string, RecordSchema> = {
type: 'string',
},
thumb: {
$ref: '#/$defs/appBskyMediaEmbedMediaEmbedBlob',
$ref: '#/$defs/mediaEmbedBlob',
},
original: {
$ref: '#/$defs/appBskyMediaEmbedMediaEmbedBlob',
$ref: '#/$defs/mediaEmbedBlob',
},
},
},
@ -2959,17 +2959,17 @@ export const recordSchemaDict: Record<string, RecordSchema> = {
maxLength: 256,
},
entities: {
$ref: '#/$defs/appBskyPostEntity',
$ref: '#/$defs/entity',
},
reply: {
type: 'object',
required: ['root', 'parent'],
properties: {
root: {
$ref: '#/$defs/appBskyPostPostRef',
$ref: '#/$defs/postRef',
},
parent: {
$ref: '#/$defs/appBskyPostPostRef',
$ref: '#/$defs/postRef',
},
},
},
@ -2979,14 +2979,14 @@ export const recordSchemaDict: Record<string, RecordSchema> = {
},
},
$defs: {
appBskyPostEntity: {
entity: {
type: 'array',
items: {
type: 'object',
required: ['index', 'type', 'value'],
properties: {
index: {
$ref: '#/$defs/appBskyPostTextSlice',
$ref: '#/$defs/textSlice',
},
type: {
type: 'string',
@ -2999,7 +2999,7 @@ export const recordSchemaDict: Record<string, RecordSchema> = {
},
},
},
appBskyPostTextSlice: {
textSlice: {
type: 'array',
items: [
{
@ -3012,7 +3012,7 @@ export const recordSchemaDict: Record<string, RecordSchema> = {
minItems: 2,
maxItems: 2,
},
appBskyPostPostRef: {
postRef: {
type: 'object',
required: ['uri', 'cid'],
properties: {
@ -3046,7 +3046,7 @@ export const recordSchemaDict: Record<string, RecordSchema> = {
required: ['index', 'type', 'value'],
properties: {
index: {
$ref: '#/$defs/appBskyPostTextSlice',
$ref: '#/$defs/textSlice',
},
type: {
type: 'string',
@ -3093,12 +3093,12 @@ export const recordSchemaDict: Record<string, RecordSchema> = {
pinnedBadges: {
type: 'array',
items: {
$ref: '#/$defs/appBskyProfileBadgeRef',
$ref: '#/$defs/badgeRef',
},
},
},
$defs: {
appBskyProfileBadgeRef: {
badgeRef: {
type: 'object',
required: ['uri', 'cid'],
properties: {
@ -3137,7 +3137,7 @@ export const recordSchemaDict: Record<string, RecordSchema> = {
required: ['subject', 'createdAt'],
properties: {
subject: {
$ref: '#/$defs/appBskyRepostSubject',
$ref: '#/$defs/subject',
},
createdAt: {
type: 'string',
@ -3145,7 +3145,7 @@ export const recordSchemaDict: Record<string, RecordSchema> = {
},
},
$defs: {
appBskyRepostSubject: {
subject: {
type: 'object',
required: ['uri', 'cid'],
properties: {

@ -3,27 +3,27 @@
*/
export interface Record {
assertion:
| AppBskyBadgeInviteAssertion
| AppBskyBadgeEmployeeAssertion
| AppBskyBadgeTagAssertion
| AppBskyBadgeUnknownAssertion;
| InviteAssertion
| EmployeeAssertion
| TagAssertion
| UnknownAssertion;
createdAt: string;
[k: string]: unknown;
}
export interface AppBskyBadgeInviteAssertion {
export interface InviteAssertion {
type: 'invite';
[k: string]: unknown;
}
export interface AppBskyBadgeEmployeeAssertion {
export interface EmployeeAssertion {
type: 'employee';
[k: string]: unknown;
}
export interface AppBskyBadgeTagAssertion {
export interface TagAssertion {
type: 'tag';
tag: string;
[k: string]: unknown;
}
export interface AppBskyBadgeUnknownAssertion {
export interface UnknownAssertion {
type: string;
[k: string]: unknown;
}

@ -2,12 +2,12 @@
* GENERATED CODE - DO NOT MODIFY
*/
export interface Record {
badge: AppBskyBadgeAcceptSubject;
offer: AppBskyBadgeAcceptSubject;
badge: Subject;
offer: Subject;
createdAt: string;
[k: string]: unknown;
}
export interface AppBskyBadgeAcceptSubject {
export interface Subject {
uri: string;
cid: string;
[k: string]: unknown;

@ -2,12 +2,12 @@
* GENERATED CODE - DO NOT MODIFY
*/
export interface Record {
badge: AppBskyBadgeOfferBadge;
badge: Badge;
subject: string;
createdAt: string;
[k: string]: unknown;
}
export interface AppBskyBadgeOfferBadge {
export interface Badge {
uri: string;
cid: string;
[k: string]: unknown;

@ -17,18 +17,15 @@ export type InputSchema = undefined
export interface OutputSchema {
cursor?: string;
feed: AppBskyGetAuthorFeedFeedItem[];
feed: FeedItem[];
}
export interface AppBskyGetAuthorFeedFeedItem {
export interface FeedItem {
uri: string;
cid: string;
author: AppBskyGetAuthorFeedUser;
repostedBy?: AppBskyGetAuthorFeedUser;
author: User;
repostedBy?: User;
record: {};
embed?:
| AppBskyGetAuthorFeedRecordEmbed
| AppBskyGetAuthorFeedExternalEmbed
| AppBskyGetAuthorFeedUnknownEmbed;
embed?: RecordEmbed | ExternalEmbed | UnknownEmbed;
replyCount: number;
repostCount: number;
likeCount: number;
@ -38,24 +35,24 @@ export interface AppBskyGetAuthorFeedFeedItem {
like?: string,
};
}
export interface AppBskyGetAuthorFeedUser {
export interface User {
did: string;
name: string;
displayName?: string;
}
export interface AppBskyGetAuthorFeedRecordEmbed {
export interface RecordEmbed {
type: 'record';
author: AppBskyGetAuthorFeedUser;
author: User;
record: {};
}
export interface AppBskyGetAuthorFeedExternalEmbed {
export interface ExternalEmbed {
type: 'external';
uri: string;
title: string;
description: string;
imageUri: string;
}
export interface AppBskyGetAuthorFeedUnknownEmbed {
export interface UnknownEmbed {
type: string;
}

@ -17,18 +17,15 @@ export type InputSchema = undefined
export interface OutputSchema {
cursor?: string;
feed: AppBskyGetHomeFeedFeedItem[];
feed: FeedItem[];
}
export interface AppBskyGetHomeFeedFeedItem {
export interface FeedItem {
uri: string;
cid: string;
author: AppBskyGetHomeFeedUser;
repostedBy?: AppBskyGetHomeFeedUser;
author: User;
repostedBy?: User;
record: {};
embed?:
| AppBskyGetHomeFeedRecordEmbed
| AppBskyGetHomeFeedExternalEmbed
| AppBskyGetHomeFeedUnknownEmbed;
embed?: RecordEmbed | ExternalEmbed | UnknownEmbed;
replyCount: number;
repostCount: number;
likeCount: number;
@ -38,24 +35,24 @@ export interface AppBskyGetHomeFeedFeedItem {
like?: string,
};
}
export interface AppBskyGetHomeFeedUser {
export interface User {
did: string;
name: string;
displayName?: string;
}
export interface AppBskyGetHomeFeedRecordEmbed {
export interface RecordEmbed {
type: 'record';
author: AppBskyGetHomeFeedUser;
author: User;
record: {};
}
export interface AppBskyGetHomeFeedExternalEmbed {
export interface ExternalEmbed {
type: 'external';
uri: string;
title: string;
description: string;
imageUri: string;
}
export interface AppBskyGetHomeFeedUnknownEmbed {
export interface UnknownEmbed {
type: string;
}

@ -16,9 +16,9 @@ export type InputSchema = undefined
export interface OutputSchema {
cursor?: string;
notifications: AppBskyGetNotificationsNotification[];
notifications: Notification[];
}
export interface AppBskyGetNotificationsNotification {
export interface Notification {
uri: string;
cid: string;
author: {

@ -15,20 +15,17 @@ export interface CallOptions {
export type InputSchema = undefined
export interface OutputSchema {
thread: AppBskyGetPostThreadPost;
thread: Post;
}
export interface AppBskyGetPostThreadPost {
export interface Post {
uri: string;
cid: string;
author: AppBskyGetPostThreadUser;
author: User;
record: {};
embed?:
| AppBskyGetPostThreadRecordEmbed
| AppBskyGetPostThreadExternalEmbed
| AppBskyGetPostThreadUnknownEmbed;
parent?: AppBskyGetPostThreadPost;
embed?: RecordEmbed | ExternalEmbed | UnknownEmbed;
parent?: Post;
replyCount: number;
replies?: AppBskyGetPostThreadPost[];
replies?: Post[];
likeCount: number;
repostCount: number;
indexedAt: string;
@ -37,24 +34,24 @@ export interface AppBskyGetPostThreadPost {
like?: string,
};
}
export interface AppBskyGetPostThreadUser {
export interface User {
did: string;
name: string;
displayName?: string;
}
export interface AppBskyGetPostThreadRecordEmbed {
export interface RecordEmbed {
type: 'record';
author: AppBskyGetPostThreadUser;
author: User;
record: {};
}
export interface AppBskyGetPostThreadExternalEmbed {
export interface ExternalEmbed {
type: 'external';
uri: string;
title: string;
description: string;
imageUri: string;
}
export interface AppBskyGetPostThreadUnknownEmbed {
export interface UnknownEmbed {
type: string;
}

@ -21,12 +21,12 @@ export interface OutputSchema {
followersCount: number;
followsCount: number;
postsCount: number;
pinnedBadges: AppBskyGetProfileBadge[];
pinnedBadges: Badge[];
myState?: {
follow?: string,
};
}
export interface AppBskyGetProfileBadge {
export interface Badge {
uri: string;
cid: string;
error?: string;

@ -2,11 +2,11 @@
* GENERATED CODE - DO NOT MODIFY
*/
export interface Record {
subject: AppBskyLikeSubject;
subject: Subject;
createdAt: string;
[k: string]: unknown;
}
export interface AppBskyLikeSubject {
export interface Subject {
uri: string;
cid: string;
[k: string]: unknown;

@ -2,16 +2,16 @@
* GENERATED CODE - DO NOT MODIFY
*/
export interface Record {
media: AppBskyMediaEmbedMediaEmbed[];
media: MediaEmbed[];
[k: string]: unknown;
}
export interface AppBskyMediaEmbedMediaEmbed {
export interface MediaEmbed {
alt?: string;
thumb?: AppBskyMediaEmbedMediaEmbedBlob;
original: AppBskyMediaEmbedMediaEmbedBlob;
thumb?: MediaEmbedBlob;
original: MediaEmbedBlob;
[k: string]: unknown;
}
export interface AppBskyMediaEmbedMediaEmbedBlob {
export interface MediaEmbedBlob {
mimeType: string;
blobId: string;
[k: string]: unknown;

@ -5,9 +5,9 @@
* @minItems 2
* @maxItems 2
*/
export type AppBskyPostTextSlice = [number, number]
export type AppBskyPostEntity = {
index: AppBskyPostTextSlice,
export type TextSlice = [number, number]
export type Entity = {
index: TextSlice,
type: string,
value: string,
[k: string]: unknown,
@ -15,16 +15,16 @@ export type AppBskyPostEntity = {
export interface Record {
text: string;
entities?: AppBskyPostEntity;
entities?: Entity;
reply?: {
root: AppBskyPostPostRef,
parent: AppBskyPostPostRef,
root: PostRef,
parent: PostRef,
[k: string]: unknown,
};
createdAt: string;
[k: string]: unknown;
}
export interface AppBskyPostPostRef {
export interface PostRef {
uri: string;
cid: string;
[k: string]: unknown;

@ -4,10 +4,10 @@
export interface Record {
displayName: string;
description?: string;
pinnedBadges?: AppBskyProfileBadgeRef[];
pinnedBadges?: BadgeRef[];
[k: string]: unknown;
}
export interface AppBskyProfileBadgeRef {
export interface BadgeRef {
uri: string;
cid: string;
[k: string]: unknown;

@ -2,11 +2,11 @@
* GENERATED CODE - DO NOT MODIFY
*/
export interface Record {
subject: AppBskyRepostSubject;
subject: Subject;
createdAt: string;
[k: string]: unknown;
}
export interface AppBskyRepostSubject {
export interface Subject {
uri: string;
cid: string;
[k: string]: unknown;

@ -13,9 +13,9 @@ export interface CallOptions {
export interface InputSchema {
displayName?: string;
description?: string;
pinnedBadges?: AppBskyProfileBadgeRef[];
pinnedBadges?: BadgeRef[];
}
export interface AppBskyProfileBadgeRef {
export interface BadgeRef {
uri: string;
cid: string;
}

@ -6,35 +6,84 @@ import {
import pointer from 'json-pointer'
import { toCamelCase } from './codegen/util'
interface NameInfo {
nsid: string
name: string
}
/**
* NOTE
* The goal of this method is to lift all references, including cross-document references,
* into the JSON-Schemas within the lexicon docs (in their $defs key). This solves a few problems:
*
* 1. It enables $refs to go to other documents using lex: URIs
* 2. It correctly anchors $refs against the base of the lexicon document
* rather than against the JSON-schemas within documents
*
* This code isn't the cleanest I've ever written, but it gets the job done for now.
* -prf
*/
export function resolveAllRefs(schemas: Schema[]) {
const keysToNameInfo: Map<string, NameInfo> = new Map()
/**
* Step 1
* Gather all of the referenced definitions into the documents using them.
* These definitions are placed in the $def of each JSON-Schema, and
* they have their keynames normalized using refToKey().
*/
for (const schema of schemas) {
try {
resolveRefs(schema, schemas)
resolveRefs(schema, schemas, keysToNameInfo)
} catch (e) {
console.error('Failed to resolve references in', schema.id)
throw e
}
}
/**
* Step 2
* Find all $ref pointers and update them to point to the local $defs
*/
for (const schema of schemas) {
try {
normalizeRefs(schema)
for (const [$ref, setRef] of findRefs(schema)) {
setRef(`#/$defs/${refToKey($ref, schema.id)}`)
}
} catch (e) {
console.error('Failed to normalize references in', schema.id)
throw e
}
}
}
function normalizeRefs(schema: Schema) {
for (const [$ref, setRef] of findRefs(schema)) {
setRef(`#/$defs/${refToKey($ref, schema.id)}`)
/**
* Step 3
* Simplify the names used in the $defs to improve the quality of the generated code
*/
for (const schema of schemas) {
try {
simplifyDefs(schema, keysToNameInfo)
} catch (e) {
console.error('Failed to simplify references in', schema.id)
throw e
}
}
}
function resolveRefs(doc: Schema, docs: Schema[]) {
function resolveRefs(
doc: Schema,
docs: Schema[],
keysToNameInfo: Map<string, NameInfo>,
) {
if (isValidRecordSchema(doc)) {
if (doc.record) {
doc.record.$defs = resolveJsonSchemaRefs(doc.record, doc, docs)
doc.record.$defs = resolveJsonSchemaRefs(
doc.record,
doc,
docs,
{},
keysToNameInfo,
)
}
} else if (isValidMethodSchema(doc)) {
if (doc.input?.schema) {
@ -42,6 +91,8 @@ function resolveRefs(doc: Schema, docs: Schema[]) {
doc.input.schema,
doc,
docs,
{},
keysToNameInfo,
)
}
if (doc.output?.schema) {
@ -49,6 +100,8 @@ function resolveRefs(doc: Schema, docs: Schema[]) {
doc.output.schema,
doc,
docs,
{},
keysToNameInfo,
)
}
} else {
@ -60,9 +113,11 @@ function resolveJsonSchemaRefs(
jsonSchema: any,
doc: Schema,
docs: Schema[],
$defs = {},
$defs: Record<string, any>,
keysToNameInfo: Map<string, NameInfo>,
): Record<string, any> {
if (!isObj(jsonSchema)) return {}
for (const [$ref] of findRefs(jsonSchema)) {
let targetDoc = doc
if ($ref.startsWith('lex:')) {
@ -71,18 +126,79 @@ function resolveJsonSchemaRefs(
}
let key = refToKey($ref, targetDoc.id)
keysToNameInfo.set(key, {
nsid: targetDoc.id,
name: $ref.split('/').filter(Boolean).pop() || '',
})
if (!(key in $defs)) {
// copy the definition into our dictionary
const def = clone(lookup(targetDoc, $ref))
$defs[key] = def
// recurse into the definition
resolveJsonSchemaRefs(def, targetDoc, docs, $defs)
resolveJsonSchemaRefs(def, targetDoc, docs, $defs, keysToNameInfo)
}
}
return $defs
}
function simplifyDefs(doc: Schema, keysToNameInfo: Map<string, NameInfo>) {
const usedNames: Set<string> = new Set()
const finalNames: Map<string, string> = new Map()
const updateDefs = ($defs: Record<string, any> | undefined) => {
if ($defs) {
for (const oldKey of Object.keys($defs)) {
const newKey = findSimplestKey(
oldKey,
keysToNameInfo.get(oldKey),
usedNames,
)
finalNames.set(oldKey, newKey)
usedNames.add(newKey)
if (newKey !== oldKey) {
$defs[newKey] = $defs[oldKey]
delete $defs[oldKey]
}
}
}
}
if (isValidRecordSchema(doc)) {
updateDefs(doc.record?.$defs)
} else if (isValidMethodSchema(doc)) {
updateDefs(doc.input?.schema?.$defs)
updateDefs(doc.output?.schema?.$defs)
} else {
throw new Error('Unknown lexicon schema')
}
for (const [$ref, setRef] of findRefs(doc)) {
const oldKey = $ref.split('/').pop() || ''
setRef(`#/$defs/${finalNames.get(oldKey) || oldKey}`)
}
}
function findSimplestKey(
oldKey: string,
nameInfo: NameInfo | undefined,
usedNames: Set<string>,
) {
if (nameInfo) {
if (!usedNames.has(nameInfo.name)) {
return nameInfo.name
}
if (
!usedNames.has(
toCamelCase(nameInfo.nsid.split('.').pop() + '.' + nameInfo.name),
)
) {
return toCamelCase(nameInfo.nsid.split('.').pop() + '.' + nameInfo.name)
}
}
return oldKey
}
function clone(v: any): any {
return JSON.parse(JSON.stringify(v))
}
@ -114,21 +230,6 @@ function findInput($ref: string, inputs: Schema[]): Schema {
return input
}
function findAvailableKey($ref: string, $defs: Record<string, any>): string {
const keys = Object.keys($defs)
const name = $ref.split('/').pop() || ''
if (!keys.includes(name)) return name
let i = 2
do {
if (!keys.includes(`${name}${i}`)) return `${name}${i}`
i++
} while (i < 1e3)
throw new Error(`Unable to find a suitable keyname for ${$ref}`)
}
function lookup(obj: any, $ref: string): any {
const res = pointer.get(obj, $ref.split('#').pop() || '')
if (!res) throw new Error(`Unable to resolve $ref: ${$ref}`)
@ -142,7 +243,7 @@ function extractId(v: string): string {
function refToKey(ref: string, id: string): string {
id = extractId(ref) || id
const name = ref.split('/').pop() || ''
const name = ref.split('/').filter(Boolean).pop() || ''
return toCamelCase(`${id}.${name}`)
}

@ -26,11 +26,11 @@ describe('Reference resolution', () => {
type: 'object',
properties: {
subject: {
$ref: '#/$defs/appBskyLikeSubject',
$ref: '#/$defs/subject',
},
},
$defs: {
appBskyLikeSubject: {
subject: {
type: 'string',
},
},
@ -72,15 +72,15 @@ describe('Reference resolution', () => {
type: 'object',
properties: {
subject: {
$ref: '#/$defs/appBskyLikeSubjectArr',
$ref: '#/$defs/subjectArr',
},
},
$defs: {
appBskyLikeSubjectArr: {
subjectArr: {
type: 'array',
items: { type: { $ref: '#/$defs/appBskyLikeSubject' } },
items: { type: { $ref: '#/$defs/subject' } },
},
appBskyLikeSubject: {
subject: {
type: 'string',
},
},
@ -88,7 +88,7 @@ describe('Reference resolution', () => {
$defs: {
subjectArr: {
type: 'array',
items: { type: { $ref: '#/$defs/appBskyLikeSubject' } },
items: { type: { $ref: '#/$defs/subject' } },
},
subject: {
type: 'string',
@ -150,23 +150,23 @@ describe('Reference resolution', () => {
type: 'object',
properties: {
subject: {
$ref: '#/$defs/appBskyLikeSubject',
$ref: '#/$defs/subject',
},
otherSubject: {
$ref: '#/$defs/appBskyRepostSubject',
$ref: '#/$defs/repostSubject',
},
displayName: {
$ref: '#/$defs/appBskyProfileDisplayName',
$ref: '#/$defs/displayName',
},
},
$defs: {
appBskyLikeSubject: {
subject: {
type: 'string',
},
appBskyRepostSubject: {
repostSubject: {
type: 'string',
},
appBskyProfileDisplayName: {
displayName: {
type: 'string',
},
},

@ -46,10 +46,10 @@ export default function (server: Server) {
const getReplies = async (
db: Kysely<DatabaseSchema>,
parent: GetPostThread.AppBskyGetPostThreadPost,
parent: GetPostThread.Post,
depth: number,
requester: string,
): Promise<GetPostThread.AppBskyGetPostThreadPost[]> => {
): Promise<GetPostThread.Post[]> => {
const res = await postInfoBuilder(db, requester)
.where('post.replyParent', '=', parent.uri)
.orderBy('post.createdAt', 'desc')
@ -122,8 +122,8 @@ const postInfoBuilder = (db: Kysely<DatabaseSchema>, requester: string) => {
// unfortunately not type-checked yet, so change with caution!
const rowToPost = (
row: any,
parent?: GetPostThread.AppBskyGetPostThreadPost,
): GetPostThread.AppBskyGetPostThreadPost => {
parent?: GetPostThread.Post,
): GetPostThread.Post => {
return {
uri: row.uri,
cid: row.cid,

@ -35,8 +35,7 @@ export enum FeedAlgorithm {
ReverseChronological = 'reverse-chronological',
}
type FeedItem = GetAuthorFeed.AppBskyGetAuthorFeedFeedItem &
GetHomeFeed.AppBskyGetHomeFeedFeedItem
type FeedItem = GetAuthorFeed.FeedItem & GetHomeFeed.FeedItem
type FeedRow = {
type: 'post' | 'repost'

@ -58,8 +58,7 @@ const insertFn =
cid: cid.toString(),
creator: uri.host,
assertionType: obj.assertion.type,
assertionTag:
(obj.assertion as Badge.AppBskyBadgeTagAssertion).tag || null,
assertionTag: (obj.assertion as Badge.TagAssertion).tag || null,
createdAt: obj.createdAt,
indexedAt: new Date().toISOString(),
}

@ -804,12 +804,12 @@ export const methodSchemaDict: Record<string, MethodSchema> = {
feed: {
type: 'array',
items: {
$ref: '#/$defs/appBskyGetAuthorFeedFeedItem',
$ref: '#/$defs/feedItem',
},
},
},
$defs: {
appBskyGetAuthorFeedFeedItem: {
feedItem: {
type: 'object',
required: [
'uri',
@ -829,10 +829,10 @@ export const methodSchemaDict: Record<string, MethodSchema> = {
type: 'string',
},
author: {
$ref: '#/$defs/appBskyGetAuthorFeedUser',
$ref: '#/$defs/user',
},
repostedBy: {
$ref: '#/$defs/appBskyGetAuthorFeedUser',
$ref: '#/$defs/user',
},
record: {
type: 'object',
@ -840,13 +840,13 @@ export const methodSchemaDict: Record<string, MethodSchema> = {
embed: {
oneOf: [
{
$ref: '#/$defs/appBskyGetAuthorFeedRecordEmbed',
$ref: '#/$defs/recordEmbed',
},
{
$ref: '#/$defs/appBskyGetAuthorFeedExternalEmbed',
$ref: '#/$defs/externalEmbed',
},
{
$ref: '#/$defs/appBskyGetAuthorFeedUnknownEmbed',
$ref: '#/$defs/unknownEmbed',
},
],
},
@ -876,7 +876,7 @@ export const methodSchemaDict: Record<string, MethodSchema> = {
},
},
},
appBskyGetAuthorFeedUser: {
user: {
type: 'object',
required: ['did', 'name'],
properties: {
@ -892,7 +892,7 @@ export const methodSchemaDict: Record<string, MethodSchema> = {
},
},
},
appBskyGetAuthorFeedRecordEmbed: {
recordEmbed: {
type: 'object',
required: ['type', 'author', 'record'],
properties: {
@ -900,14 +900,14 @@ export const methodSchemaDict: Record<string, MethodSchema> = {
const: 'record',
},
author: {
$ref: '#/$defs/appBskyGetAuthorFeedUser',
$ref: '#/$defs/user',
},
record: {
type: 'object',
},
},
},
appBskyGetAuthorFeedExternalEmbed: {
externalEmbed: {
type: 'object',
required: ['type', 'uri', 'title', 'description', 'imageUri'],
properties: {
@ -928,7 +928,7 @@ export const methodSchemaDict: Record<string, MethodSchema> = {
},
},
},
appBskyGetAuthorFeedUnknownEmbed: {
unknownEmbed: {
type: 'object',
required: ['type'],
properties: {
@ -964,10 +964,10 @@ export const methodSchemaDict: Record<string, MethodSchema> = {
type: 'string',
},
author: {
$ref: '#/$defs/appBskyGetAuthorFeedUser',
$ref: '#/$defs/user',
},
repostedBy: {
$ref: '#/$defs/appBskyGetAuthorFeedUser',
$ref: '#/$defs/user',
},
record: {
type: 'object',
@ -975,13 +975,13 @@ export const methodSchemaDict: Record<string, MethodSchema> = {
embed: {
oneOf: [
{
$ref: '#/$defs/appBskyGetAuthorFeedRecordEmbed',
$ref: '#/$defs/recordEmbed',
},
{
$ref: '#/$defs/appBskyGetAuthorFeedExternalEmbed',
$ref: '#/$defs/externalEmbed',
},
{
$ref: '#/$defs/appBskyGetAuthorFeedUnknownEmbed',
$ref: '#/$defs/unknownEmbed',
},
],
},
@ -1035,7 +1035,7 @@ export const methodSchemaDict: Record<string, MethodSchema> = {
const: 'record',
},
author: {
$ref: '#/$defs/appBskyGetAuthorFeedUser',
$ref: '#/$defs/user',
},
record: {
type: 'object',
@ -1174,12 +1174,12 @@ export const methodSchemaDict: Record<string, MethodSchema> = {
feed: {
type: 'array',
items: {
$ref: '#/$defs/appBskyGetHomeFeedFeedItem',
$ref: '#/$defs/feedItem',
},
},
},
$defs: {
appBskyGetHomeFeedFeedItem: {
feedItem: {
type: 'object',
required: [
'uri',
@ -1199,10 +1199,10 @@ export const methodSchemaDict: Record<string, MethodSchema> = {
type: 'string',
},
author: {
$ref: '#/$defs/appBskyGetHomeFeedUser',
$ref: '#/$defs/user',
},
repostedBy: {
$ref: '#/$defs/appBskyGetHomeFeedUser',
$ref: '#/$defs/user',
},
record: {
type: 'object',
@ -1210,13 +1210,13 @@ export const methodSchemaDict: Record<string, MethodSchema> = {
embed: {
oneOf: [
{
$ref: '#/$defs/appBskyGetHomeFeedRecordEmbed',
$ref: '#/$defs/recordEmbed',
},
{
$ref: '#/$defs/appBskyGetHomeFeedExternalEmbed',
$ref: '#/$defs/externalEmbed',
},
{
$ref: '#/$defs/appBskyGetHomeFeedUnknownEmbed',
$ref: '#/$defs/unknownEmbed',
},
],
},
@ -1246,7 +1246,7 @@ export const methodSchemaDict: Record<string, MethodSchema> = {
},
},
},
appBskyGetHomeFeedUser: {
user: {
type: 'object',
required: ['did', 'name'],
properties: {
@ -1262,7 +1262,7 @@ export const methodSchemaDict: Record<string, MethodSchema> = {
},
},
},
appBskyGetHomeFeedRecordEmbed: {
recordEmbed: {
type: 'object',
required: ['type', 'author', 'record'],
properties: {
@ -1270,14 +1270,14 @@ export const methodSchemaDict: Record<string, MethodSchema> = {
const: 'record',
},
author: {
$ref: '#/$defs/appBskyGetHomeFeedUser',
$ref: '#/$defs/user',
},
record: {
type: 'object',
},
},
},
appBskyGetHomeFeedExternalEmbed: {
externalEmbed: {
type: 'object',
required: ['type', 'uri', 'title', 'description', 'imageUri'],
properties: {
@ -1298,7 +1298,7 @@ export const methodSchemaDict: Record<string, MethodSchema> = {
},
},
},
appBskyGetHomeFeedUnknownEmbed: {
unknownEmbed: {
type: 'object',
required: ['type'],
properties: {
@ -1334,10 +1334,10 @@ export const methodSchemaDict: Record<string, MethodSchema> = {
type: 'string',
},
author: {
$ref: '#/$defs/appBskyGetHomeFeedUser',
$ref: '#/$defs/user',
},
repostedBy: {
$ref: '#/$defs/appBskyGetHomeFeedUser',
$ref: '#/$defs/user',
},
record: {
type: 'object',
@ -1345,13 +1345,13 @@ export const methodSchemaDict: Record<string, MethodSchema> = {
embed: {
oneOf: [
{
$ref: '#/$defs/appBskyGetHomeFeedRecordEmbed',
$ref: '#/$defs/recordEmbed',
},
{
$ref: '#/$defs/appBskyGetHomeFeedExternalEmbed',
$ref: '#/$defs/externalEmbed',
},
{
$ref: '#/$defs/appBskyGetHomeFeedUnknownEmbed',
$ref: '#/$defs/unknownEmbed',
},
],
},
@ -1405,7 +1405,7 @@ export const methodSchemaDict: Record<string, MethodSchema> = {
const: 'record',
},
author: {
$ref: '#/$defs/appBskyGetHomeFeedUser',
$ref: '#/$defs/user',
},
record: {
type: 'object',
@ -1559,12 +1559,12 @@ export const methodSchemaDict: Record<string, MethodSchema> = {
notifications: {
type: 'array',
items: {
$ref: '#/$defs/appBskyGetNotificationsNotification',
$ref: '#/$defs/notification',
},
},
},
$defs: {
appBskyGetNotificationsNotification: {
notification: {
type: 'object',
required: [
'uri',
@ -1700,11 +1700,11 @@ export const methodSchemaDict: Record<string, MethodSchema> = {
required: ['thread'],
properties: {
thread: {
$ref: '#/$defs/appBskyGetPostThreadPost',
$ref: '#/$defs/post',
},
},
$defs: {
appBskyGetPostThreadPost: {
post: {
type: 'object',
required: [
'uri',
@ -1724,7 +1724,7 @@ export const methodSchemaDict: Record<string, MethodSchema> = {
type: 'string',
},
author: {
$ref: '#/$defs/appBskyGetPostThreadUser',
$ref: '#/$defs/user',
},
record: {
type: 'object',
@ -1732,18 +1732,18 @@ export const methodSchemaDict: Record<string, MethodSchema> = {
embed: {
oneOf: [
{
$ref: '#/$defs/appBskyGetPostThreadRecordEmbed',
$ref: '#/$defs/recordEmbed',
},
{
$ref: '#/$defs/appBskyGetPostThreadExternalEmbed',
$ref: '#/$defs/externalEmbed',
},
{
$ref: '#/$defs/appBskyGetPostThreadUnknownEmbed',
$ref: '#/$defs/unknownEmbed',
},
],
},
parent: {
$ref: '#/$defs/appBskyGetPostThreadPost',
$ref: '#/$defs/post',
},
replyCount: {
type: 'number',
@ -1751,7 +1751,7 @@ export const methodSchemaDict: Record<string, MethodSchema> = {
replies: {
type: 'array',
items: {
$ref: '#/$defs/appBskyGetPostThreadPost',
$ref: '#/$defs/post',
},
},
likeCount: {
@ -1777,7 +1777,7 @@ export const methodSchemaDict: Record<string, MethodSchema> = {
},
},
},
appBskyGetPostThreadUser: {
user: {
type: 'object',
required: ['did', 'name'],
properties: {
@ -1793,7 +1793,7 @@ export const methodSchemaDict: Record<string, MethodSchema> = {
},
},
},
appBskyGetPostThreadRecordEmbed: {
recordEmbed: {
type: 'object',
required: ['type', 'author', 'record'],
properties: {
@ -1801,14 +1801,14 @@ export const methodSchemaDict: Record<string, MethodSchema> = {
const: 'record',
},
author: {
$ref: '#/$defs/appBskyGetPostThreadUser',
$ref: '#/$defs/user',
},
record: {
type: 'object',
},
},
},
appBskyGetPostThreadExternalEmbed: {
externalEmbed: {
type: 'object',
required: ['type', 'uri', 'title', 'description', 'imageUri'],
properties: {
@ -1829,7 +1829,7 @@ export const methodSchemaDict: Record<string, MethodSchema> = {
},
},
},
appBskyGetPostThreadUnknownEmbed: {
unknownEmbed: {
type: 'object',
required: ['type'],
properties: {
@ -1865,7 +1865,7 @@ export const methodSchemaDict: Record<string, MethodSchema> = {
type: 'string',
},
author: {
$ref: '#/$defs/appBskyGetPostThreadUser',
$ref: '#/$defs/user',
},
record: {
type: 'object',
@ -1873,18 +1873,18 @@ export const methodSchemaDict: Record<string, MethodSchema> = {
embed: {
oneOf: [
{
$ref: '#/$defs/appBskyGetPostThreadRecordEmbed',
$ref: '#/$defs/recordEmbed',
},
{
$ref: '#/$defs/appBskyGetPostThreadExternalEmbed',
$ref: '#/$defs/externalEmbed',
},
{
$ref: '#/$defs/appBskyGetPostThreadUnknownEmbed',
$ref: '#/$defs/unknownEmbed',
},
],
},
parent: {
$ref: '#/$defs/appBskyGetPostThreadPost',
$ref: '#/$defs/post',
},
replyCount: {
type: 'number',
@ -1892,7 +1892,7 @@ export const methodSchemaDict: Record<string, MethodSchema> = {
replies: {
type: 'array',
items: {
$ref: '#/$defs/appBskyGetPostThreadPost',
$ref: '#/$defs/post',
},
},
likeCount: {
@ -1942,7 +1942,7 @@ export const methodSchemaDict: Record<string, MethodSchema> = {
const: 'record',
},
author: {
$ref: '#/$defs/appBskyGetPostThreadUser',
$ref: '#/$defs/user',
},
record: {
type: 'object',
@ -2033,7 +2033,7 @@ export const methodSchemaDict: Record<string, MethodSchema> = {
pinnedBadges: {
type: 'array',
items: {
$ref: '#/$defs/appBskyGetProfileBadge',
$ref: '#/$defs/badge',
},
},
myState: {
@ -2046,7 +2046,7 @@ export const methodSchemaDict: Record<string, MethodSchema> = {
},
},
$defs: {
appBskyGetProfileBadge: {
badge: {
type: 'object',
required: ['uri', 'cid'],
properties: {
@ -2523,12 +2523,12 @@ export const methodSchemaDict: Record<string, MethodSchema> = {
pinnedBadges: {
type: 'array',
items: {
$ref: '#/$defs/appBskyProfileBadgeRef',
$ref: '#/$defs/badgeRef',
},
},
},
$defs: {
appBskyProfileBadgeRef: {
badgeRef: {
type: 'object',
required: ['uri', 'cid'],
properties: {
@ -2590,16 +2590,16 @@ export const recordSchemaDict: Record<string, RecordSchema> = {
assertion: {
oneOf: [
{
$ref: '#/$defs/appBskyBadgeInviteAssertion',
$ref: '#/$defs/inviteAssertion',
},
{
$ref: '#/$defs/appBskyBadgeEmployeeAssertion',
$ref: '#/$defs/employeeAssertion',
},
{
$ref: '#/$defs/appBskyBadgeTagAssertion',
$ref: '#/$defs/tagAssertion',
},
{
$ref: '#/$defs/appBskyBadgeUnknownAssertion',
$ref: '#/$defs/unknownAssertion',
},
],
},
@ -2609,7 +2609,7 @@ export const recordSchemaDict: Record<string, RecordSchema> = {
},
},
$defs: {
appBskyBadgeInviteAssertion: {
inviteAssertion: {
type: 'object',
required: ['type'],
properties: {
@ -2618,7 +2618,7 @@ export const recordSchemaDict: Record<string, RecordSchema> = {
},
},
},
appBskyBadgeEmployeeAssertion: {
employeeAssertion: {
type: 'object',
required: ['type'],
properties: {
@ -2627,7 +2627,7 @@ export const recordSchemaDict: Record<string, RecordSchema> = {
},
},
},
appBskyBadgeTagAssertion: {
tagAssertion: {
type: 'object',
required: ['type', 'tag'],
properties: {
@ -2640,7 +2640,7 @@ export const recordSchemaDict: Record<string, RecordSchema> = {
},
},
},
appBskyBadgeUnknownAssertion: {
unknownAssertion: {
type: 'object',
required: ['type'],
properties: {
@ -2710,10 +2710,10 @@ export const recordSchemaDict: Record<string, RecordSchema> = {
required: ['badge', 'offer', 'createdAt'],
properties: {
badge: {
$ref: '#/$defs/appBskyBadgeAcceptSubject',
$ref: '#/$defs/subject',
},
offer: {
$ref: '#/$defs/appBskyBadgeAcceptSubject',
$ref: '#/$defs/subject',
},
createdAt: {
type: 'string',
@ -2721,7 +2721,7 @@ export const recordSchemaDict: Record<string, RecordSchema> = {
},
},
$defs: {
appBskyBadgeAcceptSubject: {
subject: {
type: 'object',
required: ['uri', 'cid'],
properties: {
@ -2760,7 +2760,7 @@ export const recordSchemaDict: Record<string, RecordSchema> = {
required: ['badge', 'subject', 'createdAt'],
properties: {
badge: {
$ref: '#/$defs/appBskyBadgeOfferBadge',
$ref: '#/$defs/badge',
},
subject: {
type: 'string',
@ -2771,7 +2771,7 @@ export const recordSchemaDict: Record<string, RecordSchema> = {
},
},
$defs: {
appBskyBadgeOfferBadge: {
badge: {
type: 'object',
required: ['uri', 'cid'],
properties: {
@ -2831,7 +2831,7 @@ export const recordSchemaDict: Record<string, RecordSchema> = {
required: ['subject', 'createdAt'],
properties: {
subject: {
$ref: '#/$defs/appBskyLikeSubject',
$ref: '#/$defs/subject',
},
createdAt: {
type: 'string',
@ -2839,7 +2839,7 @@ export const recordSchemaDict: Record<string, RecordSchema> = {
},
},
$defs: {
appBskyLikeSubject: {
subject: {
type: 'object',
required: ['uri', 'cid'],
properties: {
@ -2881,12 +2881,12 @@ export const recordSchemaDict: Record<string, RecordSchema> = {
media: {
type: 'array',
items: {
$ref: '#/$defs/appBskyMediaEmbedMediaEmbed',
$ref: '#/$defs/mediaEmbed',
},
},
},
$defs: {
appBskyMediaEmbedMediaEmbed: {
mediaEmbed: {
type: 'object',
required: ['original'],
properties: {
@ -2894,14 +2894,14 @@ export const recordSchemaDict: Record<string, RecordSchema> = {
type: 'string',
},
thumb: {
$ref: '#/$defs/appBskyMediaEmbedMediaEmbedBlob',
$ref: '#/$defs/mediaEmbedBlob',
},
original: {
$ref: '#/$defs/appBskyMediaEmbedMediaEmbedBlob',
$ref: '#/$defs/mediaEmbedBlob',
},
},
},
appBskyMediaEmbedMediaEmbedBlob: {
mediaEmbedBlob: {
type: 'object',
required: ['mimeType', 'blobId'],
properties: {
@ -2924,10 +2924,10 @@ export const recordSchemaDict: Record<string, RecordSchema> = {
type: 'string',
},
thumb: {
$ref: '#/$defs/appBskyMediaEmbedMediaEmbedBlob',
$ref: '#/$defs/mediaEmbedBlob',
},
original: {
$ref: '#/$defs/appBskyMediaEmbedMediaEmbedBlob',
$ref: '#/$defs/mediaEmbedBlob',
},
},
},
@ -2959,17 +2959,17 @@ export const recordSchemaDict: Record<string, RecordSchema> = {
maxLength: 256,
},
entities: {
$ref: '#/$defs/appBskyPostEntity',
$ref: '#/$defs/entity',
},
reply: {
type: 'object',
required: ['root', 'parent'],
properties: {
root: {
$ref: '#/$defs/appBskyPostPostRef',
$ref: '#/$defs/postRef',
},
parent: {
$ref: '#/$defs/appBskyPostPostRef',
$ref: '#/$defs/postRef',
},
},
},
@ -2979,14 +2979,14 @@ export const recordSchemaDict: Record<string, RecordSchema> = {
},
},
$defs: {
appBskyPostEntity: {
entity: {
type: 'array',
items: {
type: 'object',
required: ['index', 'type', 'value'],
properties: {
index: {
$ref: '#/$defs/appBskyPostTextSlice',
$ref: '#/$defs/textSlice',
},
type: {
type: 'string',
@ -2999,7 +2999,7 @@ export const recordSchemaDict: Record<string, RecordSchema> = {
},
},
},
appBskyPostTextSlice: {
textSlice: {
type: 'array',
items: [
{
@ -3012,7 +3012,7 @@ export const recordSchemaDict: Record<string, RecordSchema> = {
minItems: 2,
maxItems: 2,
},
appBskyPostPostRef: {
postRef: {
type: 'object',
required: ['uri', 'cid'],
properties: {
@ -3046,7 +3046,7 @@ export const recordSchemaDict: Record<string, RecordSchema> = {
required: ['index', 'type', 'value'],
properties: {
index: {
$ref: '#/$defs/appBskyPostTextSlice',
$ref: '#/$defs/textSlice',
},
type: {
type: 'string',
@ -3093,12 +3093,12 @@ export const recordSchemaDict: Record<string, RecordSchema> = {
pinnedBadges: {
type: 'array',
items: {
$ref: '#/$defs/appBskyProfileBadgeRef',
$ref: '#/$defs/badgeRef',
},
},
},
$defs: {
appBskyProfileBadgeRef: {
badgeRef: {
type: 'object',
required: ['uri', 'cid'],
properties: {
@ -3137,7 +3137,7 @@ export const recordSchemaDict: Record<string, RecordSchema> = {
required: ['subject', 'createdAt'],
properties: {
subject: {
$ref: '#/$defs/appBskyRepostSubject',
$ref: '#/$defs/subject',
},
createdAt: {
type: 'string',
@ -3145,7 +3145,7 @@ export const recordSchemaDict: Record<string, RecordSchema> = {
},
},
$defs: {
appBskyRepostSubject: {
subject: {
type: 'object',
required: ['uri', 'cid'],
properties: {

@ -3,27 +3,27 @@
*/
export interface Record {
assertion:
| AppBskyBadgeInviteAssertion
| AppBskyBadgeEmployeeAssertion
| AppBskyBadgeTagAssertion
| AppBskyBadgeUnknownAssertion;
| InviteAssertion
| EmployeeAssertion
| TagAssertion
| UnknownAssertion;
createdAt: string;
[k: string]: unknown;
}
export interface AppBskyBadgeInviteAssertion {
export interface InviteAssertion {
type: 'invite';
[k: string]: unknown;
}
export interface AppBskyBadgeEmployeeAssertion {
export interface EmployeeAssertion {
type: 'employee';
[k: string]: unknown;
}
export interface AppBskyBadgeTagAssertion {
export interface TagAssertion {
type: 'tag';
tag: string;
[k: string]: unknown;
}
export interface AppBskyBadgeUnknownAssertion {
export interface UnknownAssertion {
type: string;
[k: string]: unknown;
}

@ -2,12 +2,12 @@
* GENERATED CODE - DO NOT MODIFY
*/
export interface Record {
badge: AppBskyBadgeAcceptSubject;
offer: AppBskyBadgeAcceptSubject;
badge: Subject;
offer: Subject;
createdAt: string;
[k: string]: unknown;
}
export interface AppBskyBadgeAcceptSubject {
export interface Subject {
uri: string;
cid: string;
[k: string]: unknown;

@ -2,12 +2,12 @@
* GENERATED CODE - DO NOT MODIFY
*/
export interface Record {
badge: AppBskyBadgeOfferBadge;
badge: Badge;
subject: string;
createdAt: string;
[k: string]: unknown;
}
export interface AppBskyBadgeOfferBadge {
export interface Badge {
uri: string;
cid: string;
[k: string]: unknown;

@ -25,18 +25,15 @@ export type HandlerOutput = HandlerError | HandlerSuccess
export interface OutputSchema {
cursor?: string;
feed: AppBskyGetAuthorFeedFeedItem[];
feed: FeedItem[];
}
export interface AppBskyGetAuthorFeedFeedItem {
export interface FeedItem {
uri: string;
cid: string;
author: AppBskyGetAuthorFeedUser;
repostedBy?: AppBskyGetAuthorFeedUser;
author: User;
repostedBy?: User;
record: {};
embed?:
| AppBskyGetAuthorFeedRecordEmbed
| AppBskyGetAuthorFeedExternalEmbed
| AppBskyGetAuthorFeedUnknownEmbed;
embed?: RecordEmbed | ExternalEmbed | UnknownEmbed;
replyCount: number;
repostCount: number;
likeCount: number;
@ -46,24 +43,24 @@ export interface AppBskyGetAuthorFeedFeedItem {
like?: string,
};
}
export interface AppBskyGetAuthorFeedUser {
export interface User {
did: string;
name: string;
displayName?: string;
}
export interface AppBskyGetAuthorFeedRecordEmbed {
export interface RecordEmbed {
type: 'record';
author: AppBskyGetAuthorFeedUser;
author: User;
record: {};
}
export interface AppBskyGetAuthorFeedExternalEmbed {
export interface ExternalEmbed {
type: 'external';
uri: string;
title: string;
description: string;
imageUri: string;
}
export interface AppBskyGetAuthorFeedUnknownEmbed {
export interface UnknownEmbed {
type: string;
}

@ -25,18 +25,15 @@ export type HandlerOutput = HandlerError | HandlerSuccess
export interface OutputSchema {
cursor?: string;
feed: AppBskyGetHomeFeedFeedItem[];
feed: FeedItem[];
}
export interface AppBskyGetHomeFeedFeedItem {
export interface FeedItem {
uri: string;
cid: string;
author: AppBskyGetHomeFeedUser;
repostedBy?: AppBskyGetHomeFeedUser;
author: User;
repostedBy?: User;
record: {};
embed?:
| AppBskyGetHomeFeedRecordEmbed
| AppBskyGetHomeFeedExternalEmbed
| AppBskyGetHomeFeedUnknownEmbed;
embed?: RecordEmbed | ExternalEmbed | UnknownEmbed;
replyCount: number;
repostCount: number;
likeCount: number;
@ -46,24 +43,24 @@ export interface AppBskyGetHomeFeedFeedItem {
like?: string,
};
}
export interface AppBskyGetHomeFeedUser {
export interface User {
did: string;
name: string;
displayName?: string;
}
export interface AppBskyGetHomeFeedRecordEmbed {
export interface RecordEmbed {
type: 'record';
author: AppBskyGetHomeFeedUser;
author: User;
record: {};
}
export interface AppBskyGetHomeFeedExternalEmbed {
export interface ExternalEmbed {
type: 'external';
uri: string;
title: string;
description: string;
imageUri: string;
}
export interface AppBskyGetHomeFeedUnknownEmbed {
export interface UnknownEmbed {
type: string;
}

@ -24,9 +24,9 @@ export type HandlerOutput = HandlerError | HandlerSuccess
export interface OutputSchema {
cursor?: string;
notifications: AppBskyGetNotificationsNotification[];
notifications: Notification[];
}
export interface AppBskyGetNotificationsNotification {
export interface Notification {
uri: string;
cid: string;
author: {

@ -23,20 +23,17 @@ export interface HandlerError {
export type HandlerOutput = HandlerError | HandlerSuccess
export interface OutputSchema {
thread: AppBskyGetPostThreadPost;
thread: Post;
}
export interface AppBskyGetPostThreadPost {
export interface Post {
uri: string;
cid: string;
author: AppBskyGetPostThreadUser;
author: User;
record: {};
embed?:
| AppBskyGetPostThreadRecordEmbed
| AppBskyGetPostThreadExternalEmbed
| AppBskyGetPostThreadUnknownEmbed;
parent?: AppBskyGetPostThreadPost;
embed?: RecordEmbed | ExternalEmbed | UnknownEmbed;
parent?: Post;
replyCount: number;
replies?: AppBskyGetPostThreadPost[];
replies?: Post[];
likeCount: number;
repostCount: number;
indexedAt: string;
@ -45,24 +42,24 @@ export interface AppBskyGetPostThreadPost {
like?: string,
};
}
export interface AppBskyGetPostThreadUser {
export interface User {
did: string;
name: string;
displayName?: string;
}
export interface AppBskyGetPostThreadRecordEmbed {
export interface RecordEmbed {
type: 'record';
author: AppBskyGetPostThreadUser;
author: User;
record: {};
}
export interface AppBskyGetPostThreadExternalEmbed {
export interface ExternalEmbed {
type: 'external';
uri: string;
title: string;
description: string;
imageUri: string;
}
export interface AppBskyGetPostThreadUnknownEmbed {
export interface UnknownEmbed {
type: string;
}

@ -29,12 +29,12 @@ export interface OutputSchema {
followersCount: number;
followsCount: number;
postsCount: number;
pinnedBadges: AppBskyGetProfileBadge[];
pinnedBadges: Badge[];
myState?: {
follow?: string,
};
}
export interface AppBskyGetProfileBadge {
export interface Badge {
uri: string;
cid: string;
error?: string;

@ -2,11 +2,11 @@
* GENERATED CODE - DO NOT MODIFY
*/
export interface Record {
subject: AppBskyLikeSubject;
subject: Subject;
createdAt: string;
[k: string]: unknown;
}
export interface AppBskyLikeSubject {
export interface Subject {
uri: string;
cid: string;
[k: string]: unknown;

@ -2,16 +2,16 @@
* GENERATED CODE - DO NOT MODIFY
*/
export interface Record {
media: AppBskyMediaEmbedMediaEmbed[];
media: MediaEmbed[];
[k: string]: unknown;
}
export interface AppBskyMediaEmbedMediaEmbed {
export interface MediaEmbed {
alt?: string;
thumb?: AppBskyMediaEmbedMediaEmbedBlob;
original: AppBskyMediaEmbedMediaEmbedBlob;
thumb?: MediaEmbedBlob;
original: MediaEmbedBlob;
[k: string]: unknown;
}
export interface AppBskyMediaEmbedMediaEmbedBlob {
export interface MediaEmbedBlob {
mimeType: string;
blobId: string;
[k: string]: unknown;

@ -5,9 +5,9 @@
* @minItems 2
* @maxItems 2
*/
export type AppBskyPostTextSlice = [number, number]
export type AppBskyPostEntity = {
index: AppBskyPostTextSlice,
export type TextSlice = [number, number]
export type Entity = {
index: TextSlice,
type: string,
value: string,
[k: string]: unknown,
@ -15,16 +15,16 @@ export type AppBskyPostEntity = {
export interface Record {
text: string;
entities?: AppBskyPostEntity;
entities?: Entity;
reply?: {
root: AppBskyPostPostRef,
parent: AppBskyPostPostRef,
root: PostRef,
parent: PostRef,
[k: string]: unknown,
};
createdAt: string;
[k: string]: unknown;
}
export interface AppBskyPostPostRef {
export interface PostRef {
uri: string;
cid: string;
[k: string]: unknown;

@ -4,10 +4,10 @@
export interface Record {
displayName: string;
description?: string;
pinnedBadges?: AppBskyProfileBadgeRef[];
pinnedBadges?: BadgeRef[];
[k: string]: unknown;
}
export interface AppBskyProfileBadgeRef {
export interface BadgeRef {
uri: string;
cid: string;
[k: string]: unknown;

@ -2,11 +2,11 @@
* GENERATED CODE - DO NOT MODIFY
*/
export interface Record {
subject: AppBskyRepostSubject;
subject: Subject;
createdAt: string;
[k: string]: unknown;
}
export interface AppBskyRepostSubject {
export interface Subject {
uri: string;
cid: string;
[k: string]: unknown;

@ -13,9 +13,9 @@ export interface HandlerInput {
export interface InputSchema {
displayName?: string;
description?: string;
pinnedBadges?: AppBskyProfileBadgeRef[];
pinnedBadges?: BadgeRef[];
}
export interface AppBskyProfileBadgeRef {
export interface BadgeRef {
uri: string;
cid: string;
}

@ -135,8 +135,7 @@ export const forSnapshot = (obj: unknown) => {
// Feed testing utils
type FeedItem = GetAuthorFeed.AppBskyGetAuthorFeedFeedItem &
GetHomeFeed.AppBskyGetHomeFeedFeedItem
type FeedItem = GetAuthorFeed.FeedItem & GetHomeFeed.FeedItem
export const getOriginator = (item: FeedItem) =>
item.repostedBy ? item.repostedBy.did : item.author.did

@ -9,7 +9,7 @@ import {
import { SeedClient } from '../seeds/client'
import basicSeed from '../seeds/basic'
import { FeedAlgorithm } from '../../src/api/app/bsky/util/feed'
import { AppBskyGetHomeFeedFeedItem as FeedItem } from '@atproto/api/src/types/app/bsky/getHomeFeed'
import { FeedItem } from '@atproto/api/src/types/app/bsky/getHomeFeed'
describe('pds home feed views', () => {
let client: AtpServiceClient