From 591c86f8e5990e33e47793318aeedc7872587f75 Mon Sep 17 00:00:00 2001 From: Dessalines Date: Sat, 14 May 2022 11:00:45 -0400 Subject: [PATCH] Testing some option types over the API. --- package.json | 4 ++++ src/interfaces/api/site.ts | 7 ++++--- src/interfaces/source.ts | 6 ++++-- yarn.lock | 5 +++++ 4 files changed, 17 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index 153bbdc..eee893c 100644 --- a/package.json +++ b/package.json @@ -15,6 +15,9 @@ "prepare": "yarn run build && husky install" }, "repository": "https://github.com/LemmyNet/lemmy-js-client", + "dependencies": { + "@sniptt/monads": "^0.5.10" + }, "devDependencies": { "@types/node": "^17.0.10", "@types/node-fetch": "^3.0.3", @@ -32,6 +35,7 @@ "sortpack": "^2.2.0", "typedoc": "^0.21.6", "typedoc-plugin-sourcefile-url": "^1.0.6", + "@sniptt/monads": "^0.5.10", "typescript": "^4.5.4" }, "types": "./dist/index.d.ts", diff --git a/src/interfaces/api/site.ts b/src/interfaces/api/site.ts index c28084b..42cb8a8 100644 --- a/src/interfaces/api/site.ts +++ b/src/interfaces/api/site.ts @@ -1,3 +1,4 @@ +import { Option } from "@sniptt/monads"; import { CommentView, CommunityBlockView, @@ -103,7 +104,7 @@ export interface CreateSite { export interface EditSite { name?: string; - sidebar?: string; + sidebar: Option; description?: string; icon?: string; banner?: string; @@ -131,14 +132,14 @@ export interface GetSiteResponse { /** * Optional, because the site might not be set up yet. */ - site_view?: SiteView; + site_view: Option; admins: PersonViewSafe[]; online: number; version: string; /** * If you're logged in, you'll get back extra user info. */ - my_user?: MyUserInfo; + my_user: Option; federated_instances?: FederatedInstances; } diff --git a/src/interfaces/source.ts b/src/interfaces/source.ts index 8d01aa2..22fd8e7 100644 --- a/src/interfaces/source.ts +++ b/src/interfaces/source.ts @@ -1,3 +1,5 @@ +import { Option } from "@sniptt/monads"; + export interface LocalUserSettings { id: number; person_id: number; @@ -41,14 +43,14 @@ export interface PersonSafe { export interface Site { id: number; name: string; - sidebar?: string; + sidebar: Option; published: string; updated?: string; enable_downvotes: boolean; open_registration: boolean; enable_nsfw: boolean; icon?: string; - banner?: string; + banner: Option; description?: string; community_creation_admin_only: boolean; require_email_verification: boolean; diff --git a/yarn.lock b/yarn.lock index 6ea1438..5e393e3 100644 --- a/yarn.lock +++ b/yarn.lock @@ -251,6 +251,11 @@ "@nodelib/fs.scandir" "2.1.4" fastq "^1.6.0" +"@sniptt/monads@^0.5.10": + version "0.5.10" + resolved "https://registry.yarnpkg.com/@sniptt/monads/-/monads-0.5.10.tgz#a80cd00738bbd682d36d36dd36bdc0bddc96eb76" + integrity sha512-+agDOv9DpDV+9e2zN/Vmdk+XaqGx5Sykl0fqhqgiJ90r18nsBkxe44DmZ2sA1HYK+MSsBeZBiAr6pq4w+5uhfw== + "@types/glob@^7.1.1": version "7.2.0" resolved "https://registry.yarnpkg.com/@types/glob/-/glob-7.2.0.tgz#bc1b5bf3aa92f25bd5dd39f35c57361bdce5b2eb"