Chg: exactOptionalPropertyTypesをfalseに変更 / Chg(Security): トークンが不正な場合のエラーを全てtoken_invalidに変更 / New: channelテーブル・リポジトリ / Chg: configテーブルのvalueをstringに / Chg: configテーブルのlengthを4096に / New: messageテーブル / Chg: 安全のためuserテーブルのOptionalPropsにidを追加 / New: channel/createエンドポイント / New: channel/listエンドポイント / New: channel/editエンドポイント / Enhance: primary/signupエンドポイントの重複エラーの実装で末尾カンマなどの改善 / Chg: setup/initializationのdescriptionに最大文字数4096を制定 / Chg: serverInfoをdefault exportからexportに変更 / New: フロントエンドでmeを読み込み / New: フロントエンドでchannelを読み込み / New: client.tsでトークンがある場合はトークンを指定 / Chg: clientをrefに / Del: IndexedDBからserverテーブルを削除 / Fix: Dexieのclassに命名 / Feat: フロントエンドでのサインインページ / Fix: L.jsで任意のbodyがあるエンドポイントが定義できない問題を修正 / Del: L.jsのserver-infoでの不要なimportを削除 / Fix: L.jsでトークンのエラーを追加 / Fix: L.jsのUserSchemaにlastUsedAtを追加

This commit is contained in:
2026-03-30 11:37:57 +09:00
parent 6b54ae4306
commit d129c95aa4
33 changed files with 683 additions and 39 deletions
@@ -0,0 +1,17 @@
import InputError from "../../modules/error/input";
import ErrorBase from "../../modules/error";
import DatabaseError from "../../modules/error/database";
import UnknownError from "../../modules/error/unknown";
import Success from "../../modules/response/success";
import Channel from "../../modules/channel";
import YetInitializationError from "../../modules/error/yet_init";
import AuthError from "../..//modules/error/auth";
export default interface ChannelCreate {
"channel/create": {
body: Omit<Channel, "userid">;
response: (Success & {
id: string;
}) | InputError | AuthError | DatabaseError | YetInitializationError | UnknownError;
};
}
@@ -0,0 +1,22 @@
import InputError from "../../modules/error/input";
import ErrorBase from "../../modules/error";
import DatabaseError from "../../modules/error/database";
import UnknownError from "../../modules/error/unknown";
import Success from "../../modules/response/success";
import Channel from "../../modules/channel";
import YetInitializationError from "../../modules/error/yet_init";
import AuthError from "../..//modules/error/auth";
type RequireAtLeastOne<T, Keys extends keyof T = keyof T> =
Keys extends keyof T
? Required<Pick<T, Keys>> & Partial<Omit<T, Keys>>
: never;
export default interface ChannelEdit {
"channel/edit": {
body: RequireAtLeastOne<Omit<Channel, "userid">>;
response: (Success & {
id: string;
}) | InputError | AuthError | DatabaseError | YetInitializationError | UnknownError;
};
}
@@ -0,0 +1,24 @@
import InputError from "../../modules/error/input";
import ErrorBase from "../../modules/error";
import DatabaseError from "../../modules/error/database";
import UnknownError from "../../modules/error/unknown";
import Success from "../../modules/response/success";
import Channel from "../../modules/channel";
import YetInitializationError from "../../modules/error/yet_init";
import AuthError from "../..//modules/error/auth";
export default interface ChannelList {
"channel/list": {
body?: {
limit?: number;
since?: string | Date;
};
response: (Success & {
channels: (Omit<Channel, "userid"> & {
id: string;
createdBy: string;
createdAt: string;
})[];
}) | InputError | AuthError | DatabaseError | YetInitializationError | UnknownError;
};
}
+2 -1
View File
@@ -5,11 +5,12 @@ import Success from "../../modules/response/success";
import YetInitializationError from "../../modules/error/yet_init";
import UserSchema from "../../modules/user";
import UnknownError from "../../modules/error/unknown";
import AuthError from "../../modules/error/auth";
export default interface Me {
"me": {
body: never;
response: (Success & Omit<UserSchema, "password" | "email">)
| DatabaseError | InputError | YetInitializationError | UnknownError;
| DatabaseError | InputError | AuthError | YetInitializationError | UnknownError;
};
}
@@ -1,4 +1,3 @@
import { InputError, InputNoneError } from "../modules/error/input";
import ErrorBase from "../modules/error";
import DatabaseError from "../modules/error/database";
import UnknownError from "../modules/error/unknown";
+7 -1
View File
@@ -1,3 +1,6 @@
import ChannelCreate from "./api/channel/create";
import ChannelEdit from "./api/channel/edit";
import ChannelList from "./api/channel/list";
import Me from "./api/me";
import PrimarySignin from "./api/primary/signin";
import PrimarySignup from "./api/primary/signup";
@@ -11,6 +14,9 @@ type ApiMap =
ServerInfo &
PrimarySignin &
PrimarySignup &
Me;
Me &
ChannelCreate &
ChannelEdit &
ChannelList;
export default ApiMap;
@@ -0,0 +1,5 @@
export default interface Channel {
name: string;
description: string;
userid: string;
}
@@ -0,0 +1,9 @@
import ErrorBase from ".";
type AuthError = ErrorBase<{
bad: "client",
code: "token_invalid",
message: "トークンが不正です。",
}>;
export default AuthError;
@@ -7,4 +7,5 @@ export default interface UserSchema {
isSuspended: boolean;
isAdmin: boolean;
createdAt: string;
lastUsedAt: string;
}
+11 -2
View File
@@ -14,7 +14,7 @@ type BodyArgs<M, E extends keyof M> =
[];
export default class LynqChat<
M extends { [K in keyof M]: { body: any; response: any } }
M extends { [K in keyof M]: { body?: any; response: any } }
> {
readonly origin: string;
readonly retry: number;
@@ -37,7 +37,13 @@ export default class LynqChat<
}
set token(token: string) {
if (token.length !== 64) throw new lynqError("Invalid token.");
const tokenArr = token.split("_");
if (
tokenArr[0]?.length !== 64 ||
tokenArr[1]?.length !== 64
)
throw new lynqError("Invalid token.");
this._token = token;
}
@@ -59,6 +65,9 @@ export default class LynqChat<
cache: "no-store",
headers: {
"Content-Type": "application/json",
...(this._token ? {
Authorization: `Bearer ${this._token}`
} : {}),
},
body,
}