From ecb7611b04a557f1c8a24cb558461a749146fc4d Mon Sep 17 00:00:00 2001 From: kgtkr Date: Mon, 25 Mar 2024 20:57:16 +0900 Subject: [PATCH] =?UTF-8?q?typescript-resolver-files=E3=81=AE=E5=88=B6?= =?UTF-8?q?=E7=B4=84=E3=81=AB=E5=AF=BE=E5=BF=9C=E3=81=99=E3=82=8B=E3=81=9F?= =?UTF-8?q?=E3=82=81=E3=81=AE=E3=83=AF=E3=83=BC=E3=82=AF=E3=82=A2=E3=83=A9?= =?UTF-8?q?=E3=82=A6=E3=83=B3=E3=83=89=E3=82=92=E3=82=84=E3=82=81=E3=81=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit https://github.com/eddeee888/graphql-code-generator-plugins/pull/242 --- package-lock.json | 73 ++++++++++++++++----- package.json | 1 + packages/server/package.json | 2 +- packages/server/src/entities/res/res.ts | 52 +++++++-------- packages/server/src/entities/token/token.ts | 19 +++--- packages/server/src/entities/topic/topic.ts | 36 +++++----- 6 files changed, 105 insertions(+), 78 deletions(-) diff --git a/package-lock.json b/package-lock.json index c4cea51..572a29a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,6 +9,7 @@ "packages/server" ], "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", @@ -1733,26 +1734,28 @@ } }, "node_modules/@eddeee888/gcg-server-config": { - "version": "0.1.0", - "resolved": "https://registry.npmjs.org/@eddeee888/gcg-server-config/-/gcg-server-config-0.1.0.tgz", - "integrity": "sha512-ZM4Cfem3FWelpz5sdCfJ+fZTCyY1WDdcT6K5GZ/UZpr7JjMApSMKnf+o9VMT2T+BB91Hffr0AH8W4oLEWUEWuw==", + "version": "0.0.0-pr242-run423-1-20240323110222", + "resolved": "https://registry.npmjs.org/@eddeee888/gcg-server-config/-/gcg-server-config-0.0.0-pr242-run423-1-20240323110222.tgz", + "integrity": "sha512-9env4xmrWxVTjWyHMP2rh/ydL+0LapfgeK0sTDD6TQm/0/GW7+OpbSX8i91kqr81YuHKHU0CQCSzaVPb04vDIw==", "dev": true, "dependencies": { "@graphql-codegen/typescript": "^4.0.0", - "@graphql-codegen/typescript-resolvers": "^4.0.0" + "@graphql-codegen/typescript-resolvers": "^4.0.0", + "tslib": "^2.3.0" } }, "node_modules/@eddeee888/gcg-typescript-resolver-files": { - "version": "0.7.2", - "resolved": "https://registry.npmjs.org/@eddeee888/gcg-typescript-resolver-files/-/gcg-typescript-resolver-files-0.7.2.tgz", - "integrity": "sha512-9LBkn6pGtXSQmH9rLoF/CkUUlsNwX4A539pRolr/yS++arGN871IptmZ89ezM4iGbbW/OPwp+Zp7AmNTgBExmA==", + "version": "0.0.0-pr242-run423-1-20240323110222", + "resolved": "https://registry.npmjs.org/@eddeee888/gcg-typescript-resolver-files/-/gcg-typescript-resolver-files-0.0.0-pr242-run423-1-20240323110222.tgz", + "integrity": "sha512-euraGJ+8AOZsL8hh7eR/RDEAx59rUtfdjntwpwSQR32LK+vBVBZwP+bOGRroLN9lCJzcDS4t7AjcYJl/atAjAA==", "dev": true, "dependencies": { - "@eddeee888/gcg-server-config": "0.1.0", + "@eddeee888/gcg-server-config": "0.0.0-pr242-run423-1-20240323110222", "@graphql-codegen/add": "^5.0.0", "@graphql-codegen/plugin-helpers": "^5.0.0", "@graphql-codegen/typescript": "^4.0.0", "@graphql-codegen/typescript-resolvers": "^4.0.0", + "@graphql-tools/utils": "^10.0.0", "ts-morph": "^19.0.0", "tslib": "^2.3.0" }, @@ -1760,6 +1763,24 @@ "graphql": "^15.0.0 || ^16.0.0" } }, + "node_modules/@eddeee888/gcg-typescript-resolver-files/node_modules/@graphql-tools/utils": { + "version": "10.1.2", + "resolved": "https://registry.npmjs.org/@graphql-tools/utils/-/utils-10.1.2.tgz", + "integrity": "sha512-fX13CYsDnX4yifIyNdiN0cVygz/muvkreWWem6BBw130+ODbRRgfiVveL0NizCEnKXkpvdeTy9Bxvo9LIKlhrw==", + "dev": true, + "dependencies": { + "@graphql-typed-document-node/core": "^3.1.1", + "cross-inspect": "1.0.0", + "dset": "^3.1.2", + "tslib": "^2.4.0" + }, + "engines": { + "node": ">=16.0.0" + }, + "peerDependencies": { + "graphql": "^14.0.0 || ^15.0.0 || ^16.0.0 || ^17.0.0" + } + }, "node_modules/@eslint/eslintrc": { "version": "1.3.1", "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-1.3.1.tgz", @@ -17424,7 +17445,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", @@ -17537,7 +17558,7 @@ "requires": { "@apollo/server": "^4.10.0", "@as-integrations/koa": "^1.1.1", - "@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", @@ -18854,28 +18875,44 @@ } }, "@eddeee888/gcg-server-config": { - "version": "0.1.0", - "resolved": "https://registry.npmjs.org/@eddeee888/gcg-server-config/-/gcg-server-config-0.1.0.tgz", - "integrity": "sha512-ZM4Cfem3FWelpz5sdCfJ+fZTCyY1WDdcT6K5GZ/UZpr7JjMApSMKnf+o9VMT2T+BB91Hffr0AH8W4oLEWUEWuw==", + "version": "0.0.0-pr242-run423-1-20240323110222", + "resolved": "https://registry.npmjs.org/@eddeee888/gcg-server-config/-/gcg-server-config-0.0.0-pr242-run423-1-20240323110222.tgz", + "integrity": "sha512-9env4xmrWxVTjWyHMP2rh/ydL+0LapfgeK0sTDD6TQm/0/GW7+OpbSX8i91kqr81YuHKHU0CQCSzaVPb04vDIw==", "dev": true, "requires": { "@graphql-codegen/typescript": "^4.0.0", - "@graphql-codegen/typescript-resolvers": "^4.0.0" + "@graphql-codegen/typescript-resolvers": "^4.0.0", + "tslib": "^2.3.0" } }, "@eddeee888/gcg-typescript-resolver-files": { - "version": "0.7.2", - "resolved": "https://registry.npmjs.org/@eddeee888/gcg-typescript-resolver-files/-/gcg-typescript-resolver-files-0.7.2.tgz", - "integrity": "sha512-9LBkn6pGtXSQmH9rLoF/CkUUlsNwX4A539pRolr/yS++arGN871IptmZ89ezM4iGbbW/OPwp+Zp7AmNTgBExmA==", + "version": "0.0.0-pr242-run423-1-20240323110222", + "resolved": "https://registry.npmjs.org/@eddeee888/gcg-typescript-resolver-files/-/gcg-typescript-resolver-files-0.0.0-pr242-run423-1-20240323110222.tgz", + "integrity": "sha512-euraGJ+8AOZsL8hh7eR/RDEAx59rUtfdjntwpwSQR32LK+vBVBZwP+bOGRroLN9lCJzcDS4t7AjcYJl/atAjAA==", "dev": true, "requires": { - "@eddeee888/gcg-server-config": "0.1.0", + "@eddeee888/gcg-server-config": "0.0.0-pr242-run423-1-20240323110222", "@graphql-codegen/add": "^5.0.0", "@graphql-codegen/plugin-helpers": "^5.0.0", "@graphql-codegen/typescript": "^4.0.0", "@graphql-codegen/typescript-resolvers": "^4.0.0", + "@graphql-tools/utils": "^10.0.0", "ts-morph": "^19.0.0", "tslib": "^2.3.0" + }, + "dependencies": { + "@graphql-tools/utils": { + "version": "10.1.2", + "resolved": "https://registry.npmjs.org/@graphql-tools/utils/-/utils-10.1.2.tgz", + "integrity": "sha512-fX13CYsDnX4yifIyNdiN0cVygz/muvkreWWem6BBw130+ODbRRgfiVveL0NizCEnKXkpvdeTy9Bxvo9LIKlhrw==", + "dev": true, + "requires": { + "@graphql-typed-document-node/core": "^3.1.1", + "cross-inspect": "1.0.0", + "dset": "^3.1.2", + "tslib": "^2.4.0" + } + } } }, "@eslint/eslintrc": { diff --git a/package.json b/package.json index 1dfdc23..bcdde96 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/packages/server/package.json b/packages/server/package.json index 6d94f67..6c9f0c8 100644 --- a/packages/server/package.json +++ b/packages/server/package.json @@ -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", diff --git a/packages/server/src/entities/res/res.ts b/packages/server/src/entities/res/res.ts index d513455..3977f64 100644 --- a/packages/server/src/entities/res/res.ts +++ b/packages/server/src/entities/res/res.ts @@ -41,45 +41,41 @@ export type IResAPI = | IResForkAPI | IResDeleteAPI; -// -- -// typescript-resolver-files がinterfaceのextendsをサポートしていないので、classとして定義するがinterfaceとして使う -export class IResBaseAPI { - 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 { + 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 { diff --git a/packages/server/src/entities/token/token.ts b/packages/server/src/entities/token/token.ts index 661831e..b31e662 100644 --- a/packages/server/src/entities/token/token.ts +++ b/packages/server/src/entities/token/token.ts @@ -22,21 +22,18 @@ export type TokenType = "master" | "general"; export type ITokenAPI = ITokenGeneralAPI | ITokenMasterAPI; -// -- -// typescript-resolver-files がinterfaceのextendsをサポートしていないので、classとして定義するがinterfaceとして使う -export class ITokenBaseAPI { - readonly id!: string; - readonly key!: string; - readonly date!: string; - readonly type!: T; +export interface ITokenBaseAPI { + 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; diff --git a/packages/server/src/entities/topic/topic.ts b/packages/server/src/entities/topic/topic.ts index b65ec2c..da73a94 100644 --- a/packages/server/src/entities/topic/topic.ts +++ b/packages/server/src/entities/topic/topic.ts @@ -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 { - readonly id!: string; - readonly title!: string; - readonly update!: string; - readonly date!: string; - readonly resCount!: number; - readonly type!: T; - readonly active!: boolean; +export interface ITopicBaseAPI { + 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 { - readonly tags!: Array; - readonly text!: string; +export interface ITopicSearchBaseAPI + extends ITopicBaseAPI { + readonly tags: Array; + 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";