From 5aa5344f2edab33d348f55d585e9a5acd6eea991 Mon Sep 17 00:00:00 2001 From: Johann150 Date: Fri, 3 Mar 2023 20:50:55 +0100 Subject: [PATCH] docs: fix schema definitions --- packages/backend/src/misc/schema.ts | 2 ++ packages/backend/src/models/schema/note.ts | 6 +++++- .../backend/src/models/schema/notification.ts | 1 + .../src/models/schema/user-group-invitation.ts | 16 ++++++++++++++++ packages/backend/src/models/schema/user.ts | 18 ++++++++++++++++++ .../src/server/api/endpoints/admin/meta.ts | 2 +- .../backend/src/server/api/endpoints/meta.ts | 2 +- 7 files changed, 44 insertions(+), 3 deletions(-) create mode 100644 packages/backend/src/models/schema/user-group-invitation.ts diff --git a/packages/backend/src/misc/schema.ts b/packages/backend/src/misc/schema.ts index bad291b4a..1bb07d14e 100644 --- a/packages/backend/src/misc/schema.ts +++ b/packages/backend/src/misc/schema.ts @@ -22,6 +22,7 @@ import { packedNoteReactionSchema } from '@/models/schema/note-reaction.js'; import { packedHashtagSchema } from '@/models/schema/hashtag.js'; import { packedPageSchema } from '@/models/schema/page.js'; import { packedUserGroupSchema } from '@/models/schema/user-group.js'; +import { packedUserGroupInvitationSchema } from '@/models/schema/user-group-invitation.js'; import { packedNoteFavoriteSchema } from '@/models/schema/note-favorite.js'; import { packedChannelSchema } from '@/models/schema/channel.js'; import { packedAntennaSchema } from '@/models/schema/antenna.js'; @@ -41,6 +42,7 @@ export const refs = { UserList: packedUserListSchema, UserGroup: packedUserGroupSchema, + UserGroupInvitation: packedUserGroupInvitationSchema, App: packedAppSchema, MessagingMessage: packedMessagingMessageSchema, Note: packedNoteSchema, diff --git a/packages/backend/src/models/schema/note.ts b/packages/backend/src/models/schema/note.ts index 292bbb82f..ab0ae05b0 100644 --- a/packages/backend/src/models/schema/note.ts +++ b/packages/backend/src/models/schema/note.ts @@ -163,16 +163,20 @@ export const packedNoteSchema = { optional: false, nullable: false, }, uri: { + description: 'ActivityPub `id` of this Note', type: 'string', optional: true, nullable: false, }, url: { + description: 'URL to a presentation form intended for humans, if available', type: 'string', optional: true, nullable: false, }, myReaction: { - type: 'object', + description: 'Textual representation of the authenticated users reaction, if they reacted.', + example: ':blobfox@.:', + type: 'string', optional: true, nullable: true, }, }, diff --git a/packages/backend/src/models/schema/notification.ts b/packages/backend/src/models/schema/notification.ts index 75634dc56..fd54c4105 100644 --- a/packages/backend/src/models/schema/notification.ts +++ b/packages/backend/src/models/schema/notification.ts @@ -48,6 +48,7 @@ export const packedNotificationSchema = { }, invitation: { type: 'object', + ref: 'UserGroupInvitation', optional: true, nullable: true, }, body: { diff --git a/packages/backend/src/models/schema/user-group-invitation.ts b/packages/backend/src/models/schema/user-group-invitation.ts new file mode 100644 index 000000000..a71956d8a --- /dev/null +++ b/packages/backend/src/models/schema/user-group-invitation.ts @@ -0,0 +1,16 @@ +export const packedUserGroupInvitationSchema = { + type: 'object', + properties: { + id: { + type: 'string', + optional: false, nullable: false, + format: 'id', + example: 'xxxxxxxxxx', + }, + group: { + type: 'object', + optional: false, nullable: false, + ref: 'UserGroup', + }, + }, +} as const; diff --git a/packages/backend/src/models/schema/user.ts b/packages/backend/src/models/schema/user.ts index fcb61f918..ec871addb 100644 --- a/packages/backend/src/models/schema/user.ts +++ b/packages/backend/src/models/schema/user.ts @@ -403,6 +403,24 @@ export const packedMeDetailedOnlySchema = { items: { type: 'object', nullable: false, optional: false, + properties: { + id: { + type: 'string', + optional: false, + nullable: false, + }, + name: { + type: 'string', + optional: false, + nullable: false, + }, + lastUsed: { + type: 'string', + optional: false, + nullable: false, + example: '1970-01-01T00:00:00Z', + }, + }, }, }, //#endregion diff --git a/packages/backend/src/server/api/endpoints/admin/meta.ts b/packages/backend/src/server/api/endpoints/admin/meta.ts index e87822b51..175e90206 100644 --- a/packages/backend/src/server/api/endpoints/admin/meta.ts +++ b/packages/backend/src/server/api/endpoints/admin/meta.ts @@ -52,7 +52,7 @@ export const meta = { }, bannerUrl: { type: 'string', - optional: false, nullable: false, + optional: false, nullable: true, }, iconUrl: { type: 'string', diff --git a/packages/backend/src/server/api/endpoints/meta.ts b/packages/backend/src/server/api/endpoints/meta.ts index d9f0da106..2a05602f5 100644 --- a/packages/backend/src/server/api/endpoints/meta.ts +++ b/packages/backend/src/server/api/endpoints/meta.ts @@ -114,7 +114,7 @@ export const meta = { }, bannerUrl: { type: 'string', - optional: false, nullable: false, + optional: false, nullable: true, }, iconUrl: { type: 'string',