@things-factory/operato-codelingua 8.0.0-beta.0 → 8.0.0-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +26 -26
- package/client/bootstrap.ts +0 -206
- package/client/icons/menu-icons.ts +0 -91
- package/client/index.ts +0 -0
- package/client/pages/git-project/git-project-list-page.ts +0 -427
- package/client/route.ts +0 -8
- package/client/themes/dark.css +0 -51
- package/client/themes/light.css +0 -51
- package/client/tsconfig.json +0 -12
- package/client/viewparts/menu-tools.ts +0 -170
- package/client/viewparts/user-circle.ts +0 -24
- package/db.sqlite +0 -0
- package/installer/config.production.js +0 -40
- package/installer/docker-compose.yml +0 -42
- package/installer/install.sh +0 -54
- package/installer/migrate.sh +0 -1
- package/installer/start.sh +0 -18
- package/installer/stop.sh +0 -1
- package/installer/upgrade.sh +0 -1
- package/logs/.08636eb59927f12972f6774f5947c8507b3564c2-audit.json +0 -25
- package/logs/.5e5d741d8b7784a2fbad65eedc0fd46946aaf6f2-audit.json +0 -50
- package/logs/application-2024-07-12-23.log +0 -81
- package/logs/application-2024-07-13-00.log +0 -1
- package/logs/application-2024-07-13-01.log +0 -168
- package/logs/connections-2024-07-07-17.log +0 -41
- package/logs/connections-2024-07-07-20.log +0 -41
- package/logs/connections-2024-07-08-00.log +0 -41
- package/logs/connections-2024-07-08-01.log +0 -41
- package/logs/connections-2024-07-08-02.log +0 -41
- package/logs/connections-2024-07-08-19.log +0 -41
- package/logs/connections-2024-07-12-23.log +0 -41
- package/logs/connections-2024-07-13-01.log +0 -82
- package/server/controllers/github-controller.ts +0 -98
- package/server/controllers/index.ts +0 -0
- package/server/index.ts +0 -7
- package/server/middlewares/index.ts +0 -3
- package/server/migrations/index.ts +0 -9
- package/server/routers/github-webhook-router.ts +0 -45
- package/server/routes.ts +0 -30
- package/server/service/git-project/git-project-mutation.ts +0 -179
- package/server/service/git-project/git-project-query.ts +0 -48
- package/server/service/git-project/git-project-type.ts +0 -76
- package/server/service/git-project/git-project.ts +0 -114
- package/server/service/git-project/index.ts +0 -7
- package/server/service/index.ts +0 -21
- package/server/tsconfig.json +0 -9
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
import fetch, { Response } from 'node-fetch'
|
|
2
|
-
|
|
3
|
-
const GITHUB_API_URL = 'https://api.github.com'
|
|
4
|
-
|
|
5
|
-
const fetchOptions = (token: string) => ({
|
|
6
|
-
headers: {
|
|
7
|
-
'Content-Type': 'application/json',
|
|
8
|
-
Authorization: `token ${token}`
|
|
9
|
-
}
|
|
10
|
-
})
|
|
11
|
-
|
|
12
|
-
const handleFetchError = (response: Response, action: string) => {
|
|
13
|
-
if (!response.ok) {
|
|
14
|
-
console.error(`Failed to ${action}:`, response.statusText)
|
|
15
|
-
throw new Error(`Failed to ${action}`)
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
const getWebhooks = async (repoFullName: string, token: string): Promise<any[]> => {
|
|
20
|
-
const response: Response = await fetch(`${GITHUB_API_URL}/repos/${repoFullName}/hooks`, fetchOptions(token))
|
|
21
|
-
handleFetchError(response, 'fetch webhooks')
|
|
22
|
-
return response.json()
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
const webhookExists = async (
|
|
26
|
-
repoFullName: string,
|
|
27
|
-
webhookUrl: string,
|
|
28
|
-
token: string
|
|
29
|
-
): Promise<{ exists: boolean; id?: number }> => {
|
|
30
|
-
try {
|
|
31
|
-
const hooks: any[] = await getWebhooks(repoFullName, token)
|
|
32
|
-
const hook = hooks.find((hook: any) => hook.config.url === webhookUrl)
|
|
33
|
-
return hook ? { exists: true, id: hook.id } : { exists: false }
|
|
34
|
-
} catch (error) {
|
|
35
|
-
console.error('Error checking webhook existence:', error)
|
|
36
|
-
return { exists: false }
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
export const postGitHubComment = async (repoFullName: string, commitId: string, comment: string): Promise<void> => {
|
|
41
|
-
try {
|
|
42
|
-
const response: Response = await fetch(`${GITHUB_API_URL}/repos/${repoFullName}/commits/${commitId}/comments`, {
|
|
43
|
-
method: 'POST',
|
|
44
|
-
...fetchOptions(process.env.GITHUB_API_KEY!),
|
|
45
|
-
body: JSON.stringify({ body: comment })
|
|
46
|
-
})
|
|
47
|
-
handleFetchError(response, 'post GitHub comment')
|
|
48
|
-
} catch (error) {
|
|
49
|
-
console.error('Error posting GitHub comment:', error)
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
export const registerWebhook = async (accessToken: string, repoFullName: string, webhookUrl: string) => {
|
|
54
|
-
const { exists } = await webhookExists(repoFullName, webhookUrl, accessToken)
|
|
55
|
-
if (exists) {
|
|
56
|
-
console.log('Webhook already registered.')
|
|
57
|
-
return
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
try {
|
|
61
|
-
const response: Response = await fetch(`${GITHUB_API_URL}/repos/${repoFullName}/hooks`, {
|
|
62
|
-
method: 'POST',
|
|
63
|
-
...fetchOptions(accessToken),
|
|
64
|
-
body: JSON.stringify({
|
|
65
|
-
name: 'web',
|
|
66
|
-
active: true,
|
|
67
|
-
events: ['push'],
|
|
68
|
-
config: {
|
|
69
|
-
url: webhookUrl,
|
|
70
|
-
content_type: 'json'
|
|
71
|
-
}
|
|
72
|
-
})
|
|
73
|
-
})
|
|
74
|
-
handleFetchError(response, 'register webhook')
|
|
75
|
-
console.log('Webhook registered successfully.')
|
|
76
|
-
} catch (error) {
|
|
77
|
-
console.error('Error registering webhook:', error)
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
export const unregisterWebhook = async (accessToken: string, repoFullName: string, webhookUrl: string) => {
|
|
82
|
-
const { exists, id } = await webhookExists(repoFullName, webhookUrl, accessToken)
|
|
83
|
-
if (!exists || !id) {
|
|
84
|
-
console.log('Webhook not found.')
|
|
85
|
-
return
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
try {
|
|
89
|
-
const deleteResponse: Response = await fetch(`${GITHUB_API_URL}/repos/${repoFullName}/hooks/${id}`, {
|
|
90
|
-
method: 'DELETE',
|
|
91
|
-
...fetchOptions(accessToken)
|
|
92
|
-
})
|
|
93
|
-
handleFetchError(deleteResponse, 'unregister webhook')
|
|
94
|
-
console.log('Webhook unregistered successfully.')
|
|
95
|
-
} catch (error) {
|
|
96
|
-
console.error('Error unregistering webhook:', error)
|
|
97
|
-
}
|
|
98
|
-
}
|
|
File without changes
|
package/server/index.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
const glob = require('glob')
|
|
2
|
-
const path = require('path')
|
|
3
|
-
|
|
4
|
-
export var migrations = []
|
|
5
|
-
|
|
6
|
-
glob.sync(path.resolve(__dirname, '.', '**', '*.js')).forEach(function(file) {
|
|
7
|
-
if (file.indexOf('index.js') !== -1) return
|
|
8
|
-
migrations = migrations.concat(Object.values(require(path.resolve(file))) || [])
|
|
9
|
-
})
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import Router from 'koa-router'
|
|
2
|
-
import { codereviewCompletion } from '@things-factory/codelingua'
|
|
3
|
-
|
|
4
|
-
import { postGitHubComment } from '../controllers/github-controller'
|
|
5
|
-
import { getRepository } from '@things-factory/shell'
|
|
6
|
-
import { GitProject } from '../service/git-project/git-project'
|
|
7
|
-
|
|
8
|
-
export const githubWebhookRouter = new Router()
|
|
9
|
-
|
|
10
|
-
githubWebhookRouter.post('/github-webhook/:projectId', async (context, next) => {
|
|
11
|
-
const { payload, head_commit } = context.request.body
|
|
12
|
-
const { commitDiff } = head_commit.diff
|
|
13
|
-
// const { commits, pull_request } = payload
|
|
14
|
-
const projectId = context.params.projectId
|
|
15
|
-
|
|
16
|
-
const project = await getRepository(GitProject).findOne({
|
|
17
|
-
where: {
|
|
18
|
-
id: projectId
|
|
19
|
-
}
|
|
20
|
-
})
|
|
21
|
-
|
|
22
|
-
if (!project) {
|
|
23
|
-
context.status = 404
|
|
24
|
-
context.body = 'Project not found'
|
|
25
|
-
return
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
// for (const commit of commits) {
|
|
29
|
-
// const codeDiff = `diff of the changed code here` // 실제 diff 데이터를 가져오는 로직 필요
|
|
30
|
-
// const reviewFeedback = await codereviewCompletion(codeDiff)
|
|
31
|
-
// const pullNumber = pull_request.number // 풀 리퀘스트 번호를 받아옴
|
|
32
|
-
// await postGitHubComment(project.repositoryUrl, pullNumber, reviewFeedback)
|
|
33
|
-
// }
|
|
34
|
-
|
|
35
|
-
const reviewFeedback = await codereviewCompletion(commitDiff)
|
|
36
|
-
|
|
37
|
-
await postGitHubComment(
|
|
38
|
-
context.request.body.repository.full_name,
|
|
39
|
-
context.request.body.head_commit.id,
|
|
40
|
-
reviewFeedback
|
|
41
|
-
)
|
|
42
|
-
|
|
43
|
-
context.status = 200
|
|
44
|
-
context.body = 'Success'
|
|
45
|
-
})
|
package/server/routes.ts
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { githubWebhookRouter } from './routers/github-webhook-router'
|
|
2
|
-
|
|
3
|
-
process.on('bootstrap-module-global-public-route' as any, (app, globalPublicRouter) => {
|
|
4
|
-
/*
|
|
5
|
-
* can add global public routes to application (auth not required, tenancy not required)
|
|
6
|
-
*
|
|
7
|
-
* ex) routes.get('/path', async(context, next) => {})
|
|
8
|
-
* ex) routes.post('/path', async(context, next) => {})
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
globalPublicRouter.use('', githubWebhookRouter.routes(), githubWebhookRouter.allowedMethods())
|
|
12
|
-
})
|
|
13
|
-
|
|
14
|
-
process.on('bootstrap-module-global-private-route' as any, (app, globalPrivateRouter) => {
|
|
15
|
-
/*
|
|
16
|
-
* can add global private routes to application (auth required, tenancy not required)
|
|
17
|
-
*/
|
|
18
|
-
})
|
|
19
|
-
|
|
20
|
-
process.on('bootstrap-module-domain-public-route' as any, (app, domainPublicRouter) => {
|
|
21
|
-
/*
|
|
22
|
-
* can add domain public routes to application (auth not required, tenancy required)
|
|
23
|
-
*/
|
|
24
|
-
})
|
|
25
|
-
|
|
26
|
-
process.on('bootstrap-module-domain-private-route' as any, (app, domainPrivateRouter) => {
|
|
27
|
-
/*
|
|
28
|
-
* can add domain private routes to application (auth required, tenancy required)
|
|
29
|
-
*/
|
|
30
|
-
})
|
|
@@ -1,179 +0,0 @@
|
|
|
1
|
-
import { Resolver, Mutation, Arg, Ctx, Directive } from 'type-graphql'
|
|
2
|
-
import { In } from 'typeorm'
|
|
3
|
-
|
|
4
|
-
import { GitProject, GitProjectStatus } from './git-project'
|
|
5
|
-
import { NewGitProject, GitProjectPatch } from './git-project-type'
|
|
6
|
-
import { registerWebhook, unregisterWebhook } from '../../controllers/github-controller'
|
|
7
|
-
|
|
8
|
-
@Resolver(GitProject)
|
|
9
|
-
export class GitProjectMutation {
|
|
10
|
-
@Directive('@transaction')
|
|
11
|
-
@Mutation(returns => GitProject, { description: 'To create new GitProject' })
|
|
12
|
-
async createGitProject(
|
|
13
|
-
@Arg('gitProject') gitProject: NewGitProject,
|
|
14
|
-
@Ctx() context: ResolverContext
|
|
15
|
-
): Promise<GitProject> {
|
|
16
|
-
const { domain, user, tx } = context.state
|
|
17
|
-
|
|
18
|
-
const result = await tx.getRepository(GitProject).save({
|
|
19
|
-
...gitProject,
|
|
20
|
-
domain,
|
|
21
|
-
creator: user,
|
|
22
|
-
updater: user
|
|
23
|
-
})
|
|
24
|
-
|
|
25
|
-
return result
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
@Directive('@transaction')
|
|
29
|
-
@Mutation(returns => GitProject, { description: 'To modify GitProject information' })
|
|
30
|
-
async updateGitProject(
|
|
31
|
-
@Arg('id') id: string,
|
|
32
|
-
@Arg('patch') patch: GitProjectPatch,
|
|
33
|
-
@Ctx() context: ResolverContext
|
|
34
|
-
): Promise<GitProject> {
|
|
35
|
-
const { domain, user, tx } = context.state
|
|
36
|
-
|
|
37
|
-
const repository = tx.getRepository(GitProject)
|
|
38
|
-
const gitProject = await repository.findOne({
|
|
39
|
-
where: { domain: { id: domain.id }, id }
|
|
40
|
-
})
|
|
41
|
-
|
|
42
|
-
const result = await repository.save({
|
|
43
|
-
...gitProject,
|
|
44
|
-
...patch,
|
|
45
|
-
updater: user
|
|
46
|
-
})
|
|
47
|
-
|
|
48
|
-
return result
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
@Directive('@transaction')
|
|
52
|
-
@Mutation(returns => [GitProject], { description: "To modify multiple GitProjects' information" })
|
|
53
|
-
async updateMultipleGitProject(
|
|
54
|
-
@Arg('patches', type => [GitProjectPatch]) patches: GitProjectPatch[],
|
|
55
|
-
@Ctx() context: ResolverContext
|
|
56
|
-
): Promise<GitProject[]> {
|
|
57
|
-
const { domain, user, tx } = context.state
|
|
58
|
-
|
|
59
|
-
let results = []
|
|
60
|
-
const _createRecords = patches.filter((patch: any) => patch.cuFlag.toUpperCase() === '+')
|
|
61
|
-
const _updateRecords = patches.filter((patch: any) => patch.cuFlag.toUpperCase() === 'M')
|
|
62
|
-
const gitProjectRepo = tx.getRepository(GitProject)
|
|
63
|
-
|
|
64
|
-
if (_createRecords.length > 0) {
|
|
65
|
-
for (let i = 0; i < _createRecords.length; i++) {
|
|
66
|
-
const newRecord = _createRecords[i]
|
|
67
|
-
|
|
68
|
-
const result = await gitProjectRepo.save({
|
|
69
|
-
...newRecord,
|
|
70
|
-
domain,
|
|
71
|
-
creator: user,
|
|
72
|
-
updater: user
|
|
73
|
-
})
|
|
74
|
-
|
|
75
|
-
results.push({ ...result, cuFlag: '+' })
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
if (_updateRecords.length > 0) {
|
|
80
|
-
for (let i = 0; i < _updateRecords.length; i++) {
|
|
81
|
-
const updateRecord = _updateRecords[i]
|
|
82
|
-
const gitProject = await gitProjectRepo.findOneBy({ id: updateRecord.id })
|
|
83
|
-
|
|
84
|
-
const result = await gitProjectRepo.save({
|
|
85
|
-
...gitProject,
|
|
86
|
-
...updateRecord,
|
|
87
|
-
updater: user
|
|
88
|
-
})
|
|
89
|
-
|
|
90
|
-
results.push({ ...result, cuFlag: 'M' })
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
return results
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
@Directive('@transaction')
|
|
98
|
-
@Mutation(returns => Boolean, { description: 'To delete GitProject' })
|
|
99
|
-
async deleteGitProject(@Arg('id') id: string, @Ctx() context: ResolverContext): Promise<boolean> {
|
|
100
|
-
const { domain, tx } = context.state
|
|
101
|
-
|
|
102
|
-
await tx.getRepository(GitProject).delete({ domain: { id: domain.id }, id })
|
|
103
|
-
|
|
104
|
-
return true
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
@Directive('@transaction')
|
|
108
|
-
@Mutation(returns => Boolean, { description: 'To delete multiple GitProjects' })
|
|
109
|
-
async deleteGitProjects(
|
|
110
|
-
@Arg('ids', type => [String]) ids: string[],
|
|
111
|
-
@Ctx() context: ResolverContext
|
|
112
|
-
): Promise<boolean> {
|
|
113
|
-
const { domain, tx } = context.state
|
|
114
|
-
|
|
115
|
-
await tx.getRepository(GitProject).delete({
|
|
116
|
-
domain: { id: domain.id },
|
|
117
|
-
id: In(ids)
|
|
118
|
-
})
|
|
119
|
-
|
|
120
|
-
return true
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
@Directive('@transaction')
|
|
124
|
-
@Mutation(returns => Boolean, { description: 'To import multiple GitProjects' })
|
|
125
|
-
async importGitProjects(
|
|
126
|
-
@Arg('gitProjects', type => [GitProjectPatch]) gitProjects: GitProjectPatch[],
|
|
127
|
-
@Ctx() context: ResolverContext
|
|
128
|
-
): Promise<boolean> {
|
|
129
|
-
const { domain, tx } = context.state
|
|
130
|
-
|
|
131
|
-
await Promise.all(
|
|
132
|
-
gitProjects.map(async (gitProject: GitProjectPatch) => {
|
|
133
|
-
const createdGitProject: GitProject = await tx.getRepository(GitProject).save({ domain, ...gitProject })
|
|
134
|
-
})
|
|
135
|
-
)
|
|
136
|
-
|
|
137
|
-
return true
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
@Directive('@transaction')
|
|
141
|
-
@Mutation(returns => Boolean, { description: 'To register GitHub webhook' })
|
|
142
|
-
async registerGithubWebhook(@Arg('id') id: string, @Ctx() context: ResolverContext): Promise<boolean> {
|
|
143
|
-
const { domain, tx } = context.state
|
|
144
|
-
|
|
145
|
-
const repository = tx.getRepository(GitProject)
|
|
146
|
-
const gitProject = await repository.findOne({ where: { domain: { id: domain.id }, id } })
|
|
147
|
-
|
|
148
|
-
if (!gitProject) {
|
|
149
|
-
throw new Error('GitProject not found')
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
const webhook = await registerWebhook(gitProject.apiKey, gitProject.name, gitProject.webhookUrl)
|
|
153
|
-
|
|
154
|
-
gitProject.state = GitProjectStatus.REGISTERED
|
|
155
|
-
await repository.save(gitProject)
|
|
156
|
-
|
|
157
|
-
return true
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
@Directive('@transaction')
|
|
161
|
-
@Mutation(returns => Boolean, { description: 'To unregister GitHub webhook' })
|
|
162
|
-
async unregisterGithubWebhook(@Arg('id') id: string, @Ctx() context: ResolverContext): Promise<boolean> {
|
|
163
|
-
const { domain, tx } = context.state
|
|
164
|
-
|
|
165
|
-
const repository = tx.getRepository(GitProject)
|
|
166
|
-
const gitProject = await repository.findOne({ where: { domain: { id: domain.id }, id } })
|
|
167
|
-
|
|
168
|
-
if (!gitProject) {
|
|
169
|
-
throw new Error('GitProject not found')
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
await unregisterWebhook(gitProject.apiKey, gitProject.name, gitProject.webhookUrl)
|
|
173
|
-
|
|
174
|
-
gitProject.state = GitProjectStatus.READY
|
|
175
|
-
await repository.save(gitProject)
|
|
176
|
-
|
|
177
|
-
return true
|
|
178
|
-
}
|
|
179
|
-
}
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import { Resolver, Query, FieldResolver, Root, Args, Arg, Ctx, Directive } from 'type-graphql'
|
|
2
|
-
import { Domain, getQueryBuilderFromListParams, getRepository, ListParam } from '@things-factory/shell'
|
|
3
|
-
import { User } from '@things-factory/auth-base'
|
|
4
|
-
import { GitProject } from './git-project'
|
|
5
|
-
import { GitProjectList } from './git-project-type'
|
|
6
|
-
|
|
7
|
-
@Resolver(GitProject)
|
|
8
|
-
export class GitProjectQuery {
|
|
9
|
-
@Query(returns => GitProject!, { nullable: true, description: 'To fetch a GitProject' })
|
|
10
|
-
async gitProject(@Arg('id') id: string, @Ctx() context: ResolverContext): Promise<GitProject> {
|
|
11
|
-
const { domain } = context.state
|
|
12
|
-
|
|
13
|
-
return await getRepository(GitProject).findOne({
|
|
14
|
-
where: { domain: { id: domain.id }, id }
|
|
15
|
-
})
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
@Query(returns => GitProjectList, { description: 'To fetch multiple GitProjects' })
|
|
19
|
-
async gitProjects(@Args(type => ListParam) params: ListParam, @Ctx() context: ResolverContext): Promise<GitProjectList> {
|
|
20
|
-
const { domain } = context.state
|
|
21
|
-
|
|
22
|
-
const queryBuilder = getQueryBuilderFromListParams({
|
|
23
|
-
domain,
|
|
24
|
-
params,
|
|
25
|
-
repository: await getRepository(GitProject),
|
|
26
|
-
searchables: ['name', 'description']
|
|
27
|
-
})
|
|
28
|
-
|
|
29
|
-
const [items, total] = await queryBuilder.getManyAndCount()
|
|
30
|
-
|
|
31
|
-
return { items, total }
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
@FieldResolver(type => Domain)
|
|
35
|
-
async domain(@Root() gitProject: GitProject): Promise<Domain> {
|
|
36
|
-
return gitProject.domainId && (await getRepository(Domain).findOneBy({ id: gitProject.domainId }))
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
@FieldResolver(type => User)
|
|
40
|
-
async updater(@Root() gitProject: GitProject): Promise<User> {
|
|
41
|
-
return gitProject.updaterId && (await getRepository(User).findOneBy({ id: gitProject.updaterId }))
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
@FieldResolver(type => User)
|
|
45
|
-
async creator(@Root() gitProject: GitProject): Promise<User> {
|
|
46
|
-
return gitProject.creatorId && (await getRepository(User).findOneBy({ id: gitProject.creatorId }))
|
|
47
|
-
}
|
|
48
|
-
}
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
import type { FileUpload } from 'graphql-upload/GraphQLUpload.js'
|
|
2
|
-
import GraphQLUpload from 'graphql-upload/GraphQLUpload.js'
|
|
3
|
-
import { ObjectType, Field, InputType, Int, ID, registerEnumType } from 'type-graphql'
|
|
4
|
-
|
|
5
|
-
import { ObjectRef, ScalarObject } from '@things-factory/shell'
|
|
6
|
-
|
|
7
|
-
import { GitProject, GitProjectStatus, GitProjectLanguage } from './git-project'
|
|
8
|
-
|
|
9
|
-
@InputType()
|
|
10
|
-
export class NewGitProject {
|
|
11
|
-
@Field()
|
|
12
|
-
name: string
|
|
13
|
-
|
|
14
|
-
@Field({ nullable: true })
|
|
15
|
-
description?: string
|
|
16
|
-
|
|
17
|
-
@Field({ nullable: true })
|
|
18
|
-
repositoryUrl?: string
|
|
19
|
-
|
|
20
|
-
@Field({ nullable: true })
|
|
21
|
-
apiKey?: string
|
|
22
|
-
|
|
23
|
-
@Field(type => GitProjectLanguage, { nullable: true })
|
|
24
|
-
language?: GitProjectLanguage
|
|
25
|
-
|
|
26
|
-
@Field(type => GitProjectStatus, { nullable: true })
|
|
27
|
-
state?: GitProjectStatus
|
|
28
|
-
|
|
29
|
-
@Field({ nullable: true })
|
|
30
|
-
active?: boolean
|
|
31
|
-
|
|
32
|
-
@Field({ nullable: true })
|
|
33
|
-
params?: string
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
@InputType()
|
|
37
|
-
export class GitProjectPatch {
|
|
38
|
-
@Field(type => ID, { nullable: true })
|
|
39
|
-
id?: string
|
|
40
|
-
|
|
41
|
-
@Field({ nullable: true })
|
|
42
|
-
name?: string
|
|
43
|
-
|
|
44
|
-
@Field({ nullable: true })
|
|
45
|
-
description?: string
|
|
46
|
-
|
|
47
|
-
@Field({ nullable: true })
|
|
48
|
-
repositoryUrl?: string
|
|
49
|
-
|
|
50
|
-
@Field({ nullable: true })
|
|
51
|
-
webhookUrl?: string
|
|
52
|
-
|
|
53
|
-
@Field({ nullable: true })
|
|
54
|
-
apiKey?: string
|
|
55
|
-
|
|
56
|
-
@Field(type => GitProjectLanguage, { nullable: true })
|
|
57
|
-
language?: GitProjectLanguage
|
|
58
|
-
|
|
59
|
-
@Field(type => GitProjectStatus, { nullable: true })
|
|
60
|
-
state?: GitProjectStatus
|
|
61
|
-
|
|
62
|
-
@Field({ nullable: true })
|
|
63
|
-
active?: boolean
|
|
64
|
-
|
|
65
|
-
@Field({ nullable: true })
|
|
66
|
-
cuFlag?: string
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
@ObjectType()
|
|
70
|
-
export class GitProjectList {
|
|
71
|
-
@Field(type => [GitProject])
|
|
72
|
-
items: GitProject[]
|
|
73
|
-
|
|
74
|
-
@Field(type => Int)
|
|
75
|
-
total: number
|
|
76
|
-
}
|
|
@@ -1,114 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
CreateDateColumn,
|
|
3
|
-
UpdateDateColumn,
|
|
4
|
-
Entity,
|
|
5
|
-
Index,
|
|
6
|
-
Column,
|
|
7
|
-
RelationId,
|
|
8
|
-
ManyToOne,
|
|
9
|
-
PrimaryGeneratedColumn
|
|
10
|
-
} from 'typeorm'
|
|
11
|
-
import { ObjectType, Field, Int, ID, registerEnumType } from 'type-graphql'
|
|
12
|
-
|
|
13
|
-
import { Domain } from '@things-factory/shell'
|
|
14
|
-
import { User } from '@things-factory/auth-base'
|
|
15
|
-
|
|
16
|
-
export enum GitProjectStatus {
|
|
17
|
-
REGISTERED = 'REGISTERED',
|
|
18
|
-
READY = 'READY'
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
registerEnumType(GitProjectStatus, {
|
|
22
|
-
name: 'GitProjectStatus',
|
|
23
|
-
description: 'state enumeration of a gitProject'
|
|
24
|
-
})
|
|
25
|
-
|
|
26
|
-
export enum GitProjectLanguage {
|
|
27
|
-
javascript = 'javascript',
|
|
28
|
-
typescript = 'typescript',
|
|
29
|
-
java = 'java',
|
|
30
|
-
python = 'python',
|
|
31
|
-
c = 'c',
|
|
32
|
-
cpp = 'cpp'
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
registerEnumType(GitProjectLanguage, {
|
|
36
|
-
name: 'GitProjectLanguage',
|
|
37
|
-
description: 'language enumeration of a gitProject'
|
|
38
|
-
})
|
|
39
|
-
|
|
40
|
-
@Entity()
|
|
41
|
-
@Index('ix_git_project_0', (gitProject: GitProject) => [gitProject.domain, gitProject.name], {
|
|
42
|
-
unique: true
|
|
43
|
-
})
|
|
44
|
-
@ObjectType({ description: 'Entity for GitProject' })
|
|
45
|
-
export class GitProject {
|
|
46
|
-
@PrimaryGeneratedColumn('uuid')
|
|
47
|
-
@Field(type => ID)
|
|
48
|
-
readonly id: string
|
|
49
|
-
|
|
50
|
-
@ManyToOne(type => Domain)
|
|
51
|
-
@Field({ nullable: true })
|
|
52
|
-
domain?: Domain
|
|
53
|
-
|
|
54
|
-
@RelationId((gitProject: GitProject) => gitProject.domain)
|
|
55
|
-
domainId?: string
|
|
56
|
-
|
|
57
|
-
@Column()
|
|
58
|
-
@Field({ nullable: true })
|
|
59
|
-
name?: string
|
|
60
|
-
|
|
61
|
-
@Column({ nullable: true })
|
|
62
|
-
@Field({ nullable: true })
|
|
63
|
-
description?: string
|
|
64
|
-
|
|
65
|
-
@Column({ nullable: true })
|
|
66
|
-
@Field({ nullable: true })
|
|
67
|
-
repositoryUrl?: string
|
|
68
|
-
|
|
69
|
-
@Column({ nullable: true })
|
|
70
|
-
@Field({ nullable: true })
|
|
71
|
-
language?: GitProjectLanguage
|
|
72
|
-
|
|
73
|
-
@Column({ nullable: true })
|
|
74
|
-
@Field({ nullable: true })
|
|
75
|
-
apiKey?: string
|
|
76
|
-
|
|
77
|
-
@Column({ nullable: true })
|
|
78
|
-
@Field({ nullable: true })
|
|
79
|
-
active?: boolean
|
|
80
|
-
|
|
81
|
-
@Column({ nullable: true })
|
|
82
|
-
@Field({ nullable: true })
|
|
83
|
-
state?: GitProjectStatus
|
|
84
|
-
|
|
85
|
-
@Column({ nullable: true })
|
|
86
|
-
@Field({ nullable: true })
|
|
87
|
-
params?: string
|
|
88
|
-
|
|
89
|
-
@CreateDateColumn()
|
|
90
|
-
@Field({ nullable: true })
|
|
91
|
-
createdAt?: Date
|
|
92
|
-
|
|
93
|
-
@UpdateDateColumn()
|
|
94
|
-
@Field({ nullable: true })
|
|
95
|
-
updatedAt?: Date
|
|
96
|
-
|
|
97
|
-
@ManyToOne(type => User, { nullable: true })
|
|
98
|
-
@Field(type => User, { nullable: true })
|
|
99
|
-
creator?: User
|
|
100
|
-
|
|
101
|
-
@RelationId((gitProject: GitProject) => gitProject.creator)
|
|
102
|
-
creatorId?: string
|
|
103
|
-
|
|
104
|
-
@ManyToOne(type => User, { nullable: true })
|
|
105
|
-
@Field(type => User, { nullable: true })
|
|
106
|
-
updater?: User
|
|
107
|
-
|
|
108
|
-
@RelationId((gitProject: GitProject) => gitProject.updater)
|
|
109
|
-
updaterId?: string
|
|
110
|
-
|
|
111
|
-
get webhookUrl(): string {
|
|
112
|
-
return `https://codelingua.hatiolab.com/github-webhook/${this.id}`
|
|
113
|
-
}
|
|
114
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { GitProject } from './git-project'
|
|
2
|
-
import { GitProjectQuery } from './git-project-query'
|
|
3
|
-
import { GitProjectMutation } from './git-project-mutation'
|
|
4
|
-
|
|
5
|
-
export const entities = [GitProject]
|
|
6
|
-
export const resolvers = [GitProjectQuery, GitProjectMutation]
|
|
7
|
-
export const subscribers = []
|
package/server/service/index.ts
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
/* EXPORT ENTITY TYPES */
|
|
2
|
-
export * from './git-project/git-project'
|
|
3
|
-
|
|
4
|
-
/* IMPORT ENTITIES AND RESOLVERS */
|
|
5
|
-
import {
|
|
6
|
-
entities as GitProjectEntities,
|
|
7
|
-
resolvers as GitProjectResolvers,
|
|
8
|
-
subscribers as GitProjectSubscribers
|
|
9
|
-
} from './git-project'
|
|
10
|
-
|
|
11
|
-
export const entities = [
|
|
12
|
-
/* ENTITIES */
|
|
13
|
-
...GitProjectEntities
|
|
14
|
-
]
|
|
15
|
-
|
|
16
|
-
export const schema = {
|
|
17
|
-
resolverClasses: [
|
|
18
|
-
/* RESOLVER CLASSES */
|
|
19
|
-
...GitProjectResolvers
|
|
20
|
-
]
|
|
21
|
-
}
|