-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
19 changed files
with
160 additions
and
139 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,5 +8,5 @@ export const History: HistoryResolvers = { | |
throw new Error(); | ||
} | ||
return topic; | ||
}, | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import type { Resolvers } from "./types.generated"; | ||
|
||
export const resolveTypes: Resolvers = { | ||
Token: { | ||
__resolveType(obj) { | ||
switch (obj.type) { | ||
case "general": | ||
return "TokenGeneral"; | ||
case "master": | ||
return "TokenMaster"; | ||
} | ||
}, | ||
}, | ||
Res: { | ||
__resolveType(obj) { | ||
switch (obj.type) { | ||
case "normal": | ||
return "ResNormal"; | ||
case "history": | ||
return "ResHistory"; | ||
case "topic": | ||
return "ResTopic"; | ||
case "fork": | ||
return "ResFork"; | ||
case "delete": | ||
return "ResDelete"; | ||
} | ||
}, | ||
}, | ||
}; |
3 changes: 2 additions & 1 deletion
3
packages/server/src/schema/token/resolvers/CreateTokenGeneralResponse.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
import type { CreateTokenGeneralResponseResolvers } from "./../../types.generated"; | ||
export const CreateTokenGeneralResponse: CreateTokenGeneralResponseResolvers = | ||
{}; | ||
{ | ||
}; |
13 changes: 11 additions & 2 deletions
13
packages/server/src/schema/token/resolvers/Mutation/authTokenReq.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,11 @@ | ||
import type { MutationResolvers } from './../../../types.generated'; | ||
export const authTokenReq: NonNullable<MutationResolvers['authTokenReq']> = async (_parent, _arg, _ctx) => { /* Implement Mutation.authTokenReq resolver logic here */ }; | ||
import { AtNotFoundError } from "../../../../at-error"; | ||
import type { MutationResolvers } from "./../../../types.generated"; | ||
|
||
export const authTokenReq: NonNullable<MutationResolvers['authTokenReq']> = async (_obj, args, context, _info) => { | ||
const token = await context.ports.tokenRepo.findOne(args.id); | ||
if (token.type !== "general") { | ||
throw new AtNotFoundError("トークンが見つかりません"); | ||
} | ||
token.authReq(args.key, context.ports.clock.now()); | ||
return token.toAPI(); | ||
}; |
29 changes: 27 additions & 2 deletions
29
packages/server/src/schema/token/resolvers/Mutation/createTokenGeneral.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,27 @@ | ||
import type { MutationResolvers } from './../../../types.generated'; | ||
export const createTokenGeneral: NonNullable<MutationResolvers['createTokenGeneral']> = async (_parent, _arg, _ctx) => { /* Implement Mutation.createTokenGeneral resolver logic here */ }; | ||
import { TokenGeneral } from "../../../../entities"; | ||
import type { MutationResolvers } from "./../../../types.generated"; | ||
|
||
export const createTokenGeneral: NonNullable< | ||
MutationResolvers["createTokenGeneral"] | ||
> = async (_obj, args, context, _info) => { | ||
const client = await context.ports.clientRepo.findOne(args.client); | ||
const token = TokenGeneral.create( | ||
context.ports.objectIdGenerator, | ||
context.ports.authContainer.getTokenMaster(), | ||
client, | ||
context.ports.clock.now(), | ||
context.ports.safeIdGenerator | ||
); | ||
|
||
const { req, token: newToken } = token.createReq( | ||
context.ports.clock.now(), | ||
context.ports.safeIdGenerator | ||
); | ||
|
||
await context.ports.tokenRepo.insert(newToken); | ||
|
||
return { | ||
token: token.toAPI(), | ||
req, | ||
}; | ||
}; |
23 changes: 21 additions & 2 deletions
23
packages/server/src/schema/token/resolvers/Mutation/createTokenMaster.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,21 @@ | ||
import type { MutationResolvers } from './../../../types.generated'; | ||
export const createTokenMaster: NonNullable<MutationResolvers['createTokenMaster']> = async (_parent, _arg, _ctx) => { /* Implement Mutation.createTokenMaster resolver logic here */ }; | ||
import { TokenMaster } from "../../../../entities"; | ||
import type { MutationResolvers } from "./../../../types.generated"; | ||
import * as authFromApiParam from "../../../../server/auth-from-api-param"; | ||
|
||
export const createTokenMaster: NonNullable< | ||
MutationResolvers["createTokenMaster"] | ||
> = async (_obj, args, context, _info) => { | ||
const authUser = await authFromApiParam.authUserRequestToUser( | ||
context.ports.userRepo, | ||
args.auth | ||
); | ||
const token = TokenMaster.create( | ||
context.ports.objectIdGenerator, | ||
authUser, | ||
context.ports.clock.now(), | ||
context.ports.safeIdGenerator | ||
); | ||
await context.ports.tokenRepo.insert(token); | ||
|
||
return token.toAPI(); | ||
}; |
22 changes: 20 additions & 2 deletions
22
packages/server/src/schema/token/resolvers/Mutation/createTokenReq.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,20 @@ | ||
import type { MutationResolvers } from './../../../types.generated'; | ||
export const createTokenReq: NonNullable<MutationResolvers['createTokenReq']> = async (_parent, _arg, _ctx) => { /* Implement Mutation.createTokenReq resolver logic here */ }; | ||
import { AtNotFoundError } from "../../../../at-error"; | ||
import type { MutationResolvers } from "./../../../types.generated"; | ||
export const createTokenReq: NonNullable< | ||
MutationResolvers["createTokenReq"] | ||
> = async (_obj, _args, context, _info) => { | ||
const token = await context.ports.tokenRepo.findOne( | ||
context.ports.authContainer.getToken().id | ||
); | ||
if (token.type !== "general") { | ||
throw new AtNotFoundError("トークンが見つかりません"); | ||
} | ||
const { req, token: newToken } = token.createReq( | ||
context.ports.clock.now(), | ||
context.ports.safeIdGenerator | ||
); | ||
|
||
await context.ports.tokenRepo.update(newToken); | ||
|
||
return req; | ||
}; |
13 changes: 11 additions & 2 deletions
13
packages/server/src/schema/token/resolvers/Mutation/delTokenClient.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,11 @@ | ||
import type { MutationResolvers } from './../../../types.generated'; | ||
export const delTokenClient: NonNullable<MutationResolvers['delTokenClient']> = async (_parent, _arg, _ctx) => { /* Implement Mutation.delTokenClient resolver logic here */ }; | ||
import type { MutationResolvers } from "./../../../types.generated"; | ||
export const delTokenClient: NonNullable< | ||
MutationResolvers["delTokenClient"] | ||
> = async (_obj, args, context, _info) => { | ||
const client = await context.ports.clientRepo.findOne(args.client); | ||
await context.ports.tokenRepo.delClientToken( | ||
context.ports.authContainer.getTokenMaster(), | ||
client.id | ||
); | ||
return null; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,12 @@ | ||
import type { QueryResolvers } from "./../../../types.generated"; | ||
export const token: NonNullable<QueryResolvers["token"]> = async ( | ||
_parent, | ||
_arg, | ||
_ctx | ||
export const token: NonNullable<QueryResolvers['token']> = async ( | ||
_obj, | ||
_args, | ||
context, | ||
_info | ||
) => { | ||
/* Implement Query.token resolver logic here */ | ||
const token = await context.ports.tokenRepo.findOne( | ||
context.ports.authContainer.getToken().id | ||
); | ||
return token.toAPI(); | ||
}; |
14 changes: 12 additions & 2 deletions
14
packages/server/src/schema/token/resolvers/Query/tokens.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,12 @@ | ||
import type { QueryResolvers } from './../../../types.generated'; | ||
export const tokens: NonNullable<QueryResolvers['tokens']> = async (_parent, _arg, _ctx) => { /* Implement Query.tokens resolver logic here */ }; | ||
import type { QueryResolvers } from "./../../../types.generated"; | ||
export const tokens: NonNullable<QueryResolvers['tokens']> = async ( | ||
_obj, | ||
_args, | ||
context, | ||
_info | ||
) => { | ||
const tokens = await context.ports.tokenRepo.findAll( | ||
context.ports.authContainer.getTokenMaster() | ||
); | ||
return tokens.map((t) => t.toAPI()); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
import type { TokenMasterResolvers } from "./../../types.generated"; | ||
export const TokenMaster: TokenMasterResolvers = {}; | ||
export const TokenMaster: TokenMasterResolvers = { | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
import type { TokenReqResolvers } from "./../../types.generated"; | ||
export const TokenReq: TokenReqResolvers = {}; | ||
export const TokenReq: TokenReqResolvers = { | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters