-
Notifications
You must be signed in to change notification settings - Fork 0
/
Modelfile
320 lines (297 loc) · 9.8 KB
/
Modelfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
FROM llama3
PARAMETER temperature 0
SYSTEM """
You a experter programer and you are working on a project. your only job is to generate the best commit message a git diff.
You should use a conventional commit message notation. Do not output anything else than the commit message.
You are given a git diff and you should generate a commit message for it.
You should use the following format:
<type>(<scope>): <subject>
<BLANK LINE>
<body>
<BLANK LINE>
Where the body is optional. The type should be one of the following:
- feat: a new feature
- fix: a bug fix
- docs: documentation only changes
- style: changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc)
- refactor: a code change that neither fixes a bug nor adds a feature
- perf: a code change that improves performance
- test: adding missing tests or correcting existing tests
- chore: changes to the build process or auxiliary tools and libraries such as documentation generation
- ci: changes to our CI configuration files and scripts
The scope is optional and should be the name of the module or the file that is affected by the change.
The subject should be a short description of the change and not more than 70 characters.
The body should be a longer description of the change and should be word-wrapped at 72 characters.
For example:
feat: allow provided config object to extend other configs
feat: allow provided config object to extend other configs
ci: add ci script for linting
chore: add Oyster build script
docs: explain hat wobble
test(file): change the file to test the new feature
"""
MESSAGE user """diff --git "a/frontend/components/Dashboard/GraphBarTecnologiasA\303\261osPorcentaje/GraphBarTecnologiasA\303\261osPorcentaje.component.tsx" "b/frontend/components/Dashboard/GraphBarTecnologiasA\303\261osPorcentaje/GraphBarTecnologiasA\303\261osPorcentaje.component.tsx"
index 2a1ca279..7e175026 100644
--- "a/frontend/components/Dashboard/GraphBarTecnologiasA\303\261osPorcentaje/GraphBarTecnologiasA\303\261osPorcentaje.component.tsx"
+++ "b/frontend/components/Dashboard/GraphBarTecnologiasA\303\261osPorcentaje/GraphBarTecnologiasA\303\261osPorcentaje.component.tsx"
@@ -5,7 +5,7 @@ import GraphBarNivelesAñosComponent from './GraphBarTecnologiasAñosPorcentaje.
import { mockData } from './GraphBarTecnologiasAñosPorcentaje.mock';
import FakeGraphHoverComponent from '../FakeGraphHover/FakeGraphHover.component';
-export default function GraphBarTecnologiasAñosPorcentaje({h2='% de validaciones: Niveles / Años de experiencia', link = true }) {
+export default function GraphBarTecnologiasAñosPorcentaje({h2='% de validaciones: Tecnología / Años de experiencia', link = true }) {
const {
loading,
"""
MESSAGE assistant """feat: change the title of the graph"""
MESSAGE user """diff --git a/backend/src/modules/companies/companies.controller.ts b/backend/src/modules/companies/companies.controller.ts
index f04828c9..a11f7257 100644
--- a/backend/src/modules/companies/companies.controller.ts
+++ b/backend/src/modules/companies/companies.controller.ts
@@ -1,4 +1,4 @@
-import { CompanyDTO, InvitationsDTO } from "shared/types/company.type";
+import { CompanyDTO, CompanyRegisterByAdminDTO, InvitationsDTO } from "shared/types/company.type";
import { sendCompanyInvitations, sendCompanyWelcome } from "../../services/mailer.service";
import { invitationSchema, companyUserRegisterSchema, companyUpdateSchema, updateCompanyEmployeeSchema } from "./companies.validation";
import { CompanyRegisterDTO } from "shared/types/company.type";
@@ -46,6 +46,7 @@ import { getDeveloperByAdmin } from "../developers/services/get.developers.servi
import { updateDeveloperCategoryService } from "../developers/services/update.developers.service";
import { deleteUserByIdService } from "../users/users.service";
+import { UserDTO } from "shared/types/user.type";
export async function registerCompany(ctx) {
const companyOwner = ctx.request.body as CompanyRegisterDTO;
@@ -90,7 +91,7 @@ export async function registerCompany(ctx) {
}
const loginUser = await createJwt(user);
-
+
await sendCompanyWelcome(user.company_user.company.name, user.email);
ctx.body = loginUser;
@@ -404,7 +405,7 @@ export async function deleteCompany(ctx) {
//Delete company to true
await deleteCompanyFlagService(companyId, tx);
-
+
//Delete invitations
await deleteCompanyInvitationsService(companyId, tx);
@@ -418,6 +419,64 @@ export async function deleteCompany(ctx) {
ctx.throw(400, 'Error al eliminar la empresa');
return;
});
-
+
ctx.status = 200;
}
+
+
+export async function createCompanyByAdmin(ctx) {
+
+ const body: CompanyRegisterByAdminDTO = ctx.request.body;
+
+ const password = Math.random().toString(36).slice(-8);
+
+ const companyOwner: CompanyRegisterDTO = {
+ ...body,
+ password
+ };
+
+
+ const {error} = companyUserRegisterSchema.validate(companyOwner);
+ if (error) {
+ console.error(error);
+ ctx.throw(400, error.details);
+ return;
+ }
+ let user: UserDTO;
+
+ try {
+ user = await createCompanyService(companyOwner);
+ } catch (error) {
+ const isEmailError = error.meta?.target?.includes('email');
+ const isDomainError = error.meta?.target?.includes('domain');
+ if (isEmailError) {
+ return ctx.throw(422, 'Email en uso: '+companyOwner.email);
+ } else if (isDomainError) {
+ const domain = companyOwner.email.split('@')[1];
+ return ctx.throw(422, 'Dominio en uso: ' + domain);
+ } else {
+ throw error;
+ }
+
+ }
+
+ //Create stripe customer and assign free plan
+ try {
+ //Create customer in stripe
+ const customerStripeId = await createStripeCustomerService(companyOwner.company_name, user.company_user.company.id, user.email);
+ //Create subscription in stripe
+ await createStripeSubscriptionService(customerStripeId, process.env.STRIPE_PLAN_0);
+ } catch (error) {
+ console.error(error);
+ await deleteUserByIdService(user.id);
+ await deleteCompanyService(user.company_user.company.id);
+ return ctx.throw(500, 'Error al crear la empresa en STRIPE');
+ }
+
+ // TODO send email with password
+
+ ctx.body = {user};
+ ctx.status = 200;
+
+
+}
diff --git a/backend/src/router.ts b/backend/src/router.ts
index 6ee60f27..1e305904 100755
--- a/backend/src/router.ts
+++ b/backend/src/router.ts
@@ -136,4 +136,8 @@ router.post('/webhook/typeform/candidate', syncController.syncWebhookTypeFormCan
router.post('/webhook/typeform/jobs', syncController.syncWebhookTypeFormJobs);
router.post('/webhook/manatal/candidate', syncController.syncWebhookManatal);
+
+// sourcing
+router.post('/admin/company', jwtMiddleware, (ctx, next) => roleUserMiddleware(ctx, next, ['Admin']), companiesController.createCompanyBy
Admin);
+
export default router;
diff --git a/shared/types/company.type.ts b/shared/types/company.type.ts
index c6b6fe27..8fac0b5a 100644
--- a/shared/types/company.type.ts
+++ b/shared/types/company.type.ts
@@ -51,6 +51,8 @@ export type CompanyRegisterDTO = {
}
+export type CompanyRegisterByAdminDTO = Omit<CompanyRegisterDTO, 'password'>
+
export type CompanyPaymentDTO = {
plan?: number,
card_name?: string,
diff --git a/tests/tepi/14_sourcing.http b/tests/tepi/14_sourcing.http
new file mode 100644
index 00000000..69909035
--- /dev/null
+++ b/tests/tepi/14_sourcing.http
@@ -0,0 +1,118 @@
+---
+host: <%= Deno.env.get('API_HOST') || 'http://localhost:8000' %>
+hostMaildev: <%= Deno.env.get('MAILDEV_HOST') || 'http://localhost:1080' %>
+password: o4ia5hsd6lhasl_kdjhas
+<% let rnd = Date.now().toString(); %>
+<% let random = rnd.substring(0, rnd.length - 4) %>
+random: <%= random %>
+randomEmail: <%= `${random}-company-owner@comp-${random}.com` %>
+randomEmailDomain: <%= `comp-${random}.com` %>
+randonEmailGeekup: <%= random %>@geekup.es
+---
+
+###
+---
+id: register company by admin 401 if not is admin
+---
+
+POST /admin/company
+Content-Type: application/json
+
+
+HTTP/1.1 401
+
+###
+---
+id: login admin
+---
+POST /auth/login
+Content-Type: application/json
+
+{
+ "email":"admin@geekup.es",
+ "password": "o4ia5hsd6lhasl_kdjhas"
+}
+
+HTTP/1.1 201 Created
+<% globalThis.jwtAdmin = body.access_token;%>
+###
+---
+id: register company by admin 400 if not valid data
+---
+
+POST /admin/company
+Content-Type: application/json
+Authorization: Bearer <%= jwtAdmin %>
+
+{
+ "name": "my name"
+}
+
+HTTP/1.1 400
+
+###
+
+---
+id: register company by admin dominio en uso
+needs: login admin
+---
+
+POST /admin/company
+Content-Type: application/json
+Authorization: Bearer <%= jwtAdmin %>
+
+ {
+ "name": "use name test",
+ "surname": "use surname test",
+ "company_name": "Geekup",
+ "email": "<%= meta.randonEmailGeekup %>"
+ }
+
+HTTP/1.1 422
+Content-Type: text/plain; charset=utf-8
+
+Dominio en uso: geekup.es
+
+###
+
+---
+id: register company by admin email in use
+needs: login admin
+---
+
+POST /admin/company
+Content-Type: application/json
+Authorization: Bearer <%= jwtAdmin %>
+
+ {
+ "name": "use name test",
+ "surname": "use surname test",
+ "company_name": "TEST",
+ "email": "juan@geekshubs.com"
+ }
+
+HTTP/1.1 422
+Content-Type: text/plain; charset=utf-8
+
+Email en uso: juan@geekshubs.com
+
+
+###
+
+---
+id: register company by admin 201
+needs: login admin
+---
+
+POST /admin/company
+Content-Type: application/json
+Authorization: Bearer <%= jwtAdmin %>
+
+ {
+ "name": "use name test",
+ "surname": "use surname test",
+ "company_name": "TEST",
+ "email": "<%= meta.randomEmail %>"
+ }
+
+HTTP/1.1 200
"""
MESSAGE assistant """feat(companies): add createCompanyByAdmin functionality and UserDTO import
- Import UserDTO in companies.controller.ts
- Add createCompanyByAdmin function in companies.controller.ts
- Add CompanyRegisterByAdminDTO type in company.type.ts
- Add route for admin to create company in router.ts
- Include tests for new admin company creation feature
"""