Skip to content

Commit

Permalink
typescript-resolver-filesの制約に対応するためのワークアラウンドをやめた
Browse files Browse the repository at this point in the history
  • Loading branch information
kgtkr committed Mar 25, 2024
1 parent 48f1843 commit ecb7611
Show file tree
Hide file tree
Showing 6 changed files with 105 additions and 78 deletions.
73 changes: 55 additions & 18 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"name": "@anontown-backend/root",
"private": true,
"devDependencies": {
"@eddeee888/gcg-typescript-resolver-files": "^0.0.0-pr242-run423-1-20240323110222",
"@lerna-lite/cli": "^1.11.2",
"@lerna-lite/run": "^1.11.2",
"@typescript-eslint/eslint-plugin": "^5.36.1",
Expand Down
2 changes: 1 addition & 1 deletion packages/server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"zod": "^3.18.0"
},
"devDependencies": {
"@eddeee888/gcg-typescript-resolver-files": "^0.7.2",
"@eddeee888/gcg-typescript-resolver-files": "pr242-run423-1",
"@graphql-codegen/cli": "^5.0.0",
"@graphql-codegen/core": "^4.0.0",
"@graphql-codegen/typescript": "^4.0.1",
Expand Down
52 changes: 24 additions & 28 deletions packages/server/src/entities/res/res.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,45 +41,41 @@ export type IResAPI =
| IResForkAPI
| IResDeleteAPI;

// --
// typescript-resolver-files がinterfaceのextendsをサポートしていないので、classとして定義するがinterfaceとして使う
export class IResBaseAPI<T extends ResAPIType> {
readonly id!: string;
readonly topicID!: string;
readonly date!: Date;
readonly self!: boolean | null;
readonly uv!: number;
readonly dv!: number;
readonly hash!: string;
readonly replyCount!: number;
readonly voteFlag!: VoteFlag | null;
readonly type!: T;
export interface IResBaseAPI<T extends ResAPIType> {
readonly id: string;
readonly topicID: string;
readonly date: Date;
readonly self: boolean | null;
readonly uv: number;
readonly dv: number;
readonly hash: string;
readonly replyCount: number;
readonly voteFlag: VoteFlag | null;
readonly type: T;
}

export class IResNormalAPI extends IResBaseAPI<"normal"> {
readonly name!: string | null;
readonly text!: string;
readonly replyID!: string | null;
readonly profileID!: string | null;
readonly isReply!: boolean | null;
export interface IResNormalAPI extends IResBaseAPI<"normal"> {
readonly name: string | null;
readonly text: string;
readonly replyID: string | null;
readonly profileID: string | null;
readonly isReply: boolean | null;
}

export class IResHistoryAPI extends IResBaseAPI<"history"> {
readonly historyID!: string;
export interface IResHistoryAPI extends IResBaseAPI<"history"> {
readonly historyID: string;
}

export class IResTopicAPI extends IResBaseAPI<"topic"> {}
export type IResTopicAPI = IResBaseAPI<"topic">;

export class IResForkAPI extends IResBaseAPI<"fork"> {
readonly forkID!: string;
export interface IResForkAPI extends IResBaseAPI<"fork"> {
readonly forkID: string;
}

export class IResDeleteAPI extends IResBaseAPI<"delete"> {
readonly flag!: "self" | "freeze";
export interface IResDeleteAPI extends IResBaseAPI<"delete"> {
readonly flag: "self" | "freeze";
}

// --

export type VoteFlag = "uv" | "dv" | "not";
export type ResDeleteFlag = "active" | "self" | "freeze";
export interface IReply {
Expand Down
19 changes: 8 additions & 11 deletions packages/server/src/entities/token/token.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,18 @@ export type TokenType = "master" | "general";

export type ITokenAPI = ITokenGeneralAPI | ITokenMasterAPI;

// --
// typescript-resolver-files がinterfaceのextendsをサポートしていないので、classとして定義するがinterfaceとして使う
export class ITokenBaseAPI<T extends TokenType> {
readonly id!: string;
readonly key!: string;
readonly date!: string;
readonly type!: T;
export interface ITokenBaseAPI<T extends TokenType> {
readonly id: string;
readonly key: string;
readonly date: string;
readonly type: T;
}

export class ITokenMasterAPI extends ITokenBaseAPI<"master"> {}
export type ITokenMasterAPI = ITokenBaseAPI<"master">;

export class ITokenGeneralAPI extends ITokenBaseAPI<"general"> {
readonly clientID!: string;
export interface ITokenGeneralAPI extends ITokenBaseAPI<"general"> {
readonly clientID: string;
}
// --

export type Token = TokenMaster | TokenGeneral;

Expand Down
36 changes: 16 additions & 20 deletions packages/server/src/entities/topic/topic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,33 +18,29 @@ export interface ITagsAPI {
export type ITopicAPI = ITopicOneAPI | ITopicNormalAPI | ITopicForkAPI;
export type ITopicSearchAPI = ITopicOneAPI | ITopicNormalAPI;

// --
// typescript-resolver-files がinterfaceのextendsをサポートしていないので、classとして定義するがinterfaceとして使う
export class ITopicBaseAPI<T extends TopicType> {
readonly id!: string;
readonly title!: string;
readonly update!: string;
readonly date!: string;
readonly resCount!: number;
readonly type!: T;
readonly active!: boolean;
export interface ITopicBaseAPI<T extends TopicType> {
readonly id: string;
readonly title: string;
readonly update: string;
readonly date: string;
readonly resCount: number;
readonly type: T;
readonly active: boolean;
}

export class ITopicSearchBaseAPI<
T extends TopicSearchType
> extends ITopicBaseAPI<T> {
readonly tags!: Array<string>;
readonly text!: string;
export interface ITopicSearchBaseAPI<T extends TopicSearchType>
extends ITopicBaseAPI<T> {
readonly tags: Array<string>;
readonly text: string;
}

export class ITopicNormalAPI extends ITopicSearchBaseAPI<"normal"> {}
export type ITopicNormalAPI = ITopicSearchBaseAPI<"normal">;

export class ITopicOneAPI extends ITopicSearchBaseAPI<"one"> {}
export type ITopicOneAPI = ITopicSearchBaseAPI<"one">;

export class ITopicForkAPI extends ITopicBaseAPI<"fork"> {
readonly parentID!: string;
export interface ITopicForkAPI extends ITopicBaseAPI<"fork"> {
readonly parentID: string;
}
// --

export type TopicSearchType = "one" | "normal";
export type TopicType = TopicSearchType | "fork";
Expand Down

0 comments on commit ecb7611

Please sign in to comment.