careerty-prism 1.0.14 → 1.0.16

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/others/seeder.ts CHANGED
@@ -1,12 +1,12 @@
1
- import { PrismaClient } from '@prisma/client';
1
+ import { PlanPerk, PrismaClient } from '@prisma/client';
2
2
  const prisma = new PrismaClient()
3
3
 
4
4
 
5
5
 
6
6
 
7
- async function getDefaultDocTemplte(type: string) {
7
+ async function getDefaultDocTemplte(tx: any, type: string) {
8
8
 
9
- var result = await prisma.template.findFirst({
9
+ var result = await tx.template.findFirst({
10
10
  where: {
11
11
  isPaid: true,
12
12
  isDeleted: false,
@@ -16,14 +16,12 @@ async function getDefaultDocTemplte(type: string) {
16
16
  if (result)
17
17
  return result.id;
18
18
 
19
- return '_'
19
+ return '1'
20
20
 
21
21
  }
22
22
 
23
-
24
-
25
- async function getDefaultUserPlan() {
26
- var result = await prisma.plan.findFirst({
23
+ async function getDefaultUserPlan(tx: any) {
24
+ var result = await tx.plan.findFirst({
27
25
  where: {
28
26
  name: 'Free Plan'
29
27
  }
@@ -35,20 +33,459 @@ async function getDefaultUserPlan() {
35
33
  }
36
34
 
37
35
 
38
- async function getPositions() {
39
- // return await SkillRepoModel.find({}, ['_id']);
36
+ async function plansPerks(tx: any) {
37
+
38
+
39
+ var planPerks = [
40
+ {
41
+ perk: {
42
+ key: 'num_of_cv',
43
+ name: 'num_of_cv',
44
+ description: 'num_of_cv',
45
+ value: '3',
46
+ },
47
+ translation: [
48
+ {
49
+ key: 'name',
50
+ value: "num of cv",
51
+ lang: "en"
52
+ },
53
+ {
54
+ key: 'name',
55
+ value: "عدد مستندات السيرة الذاتية",
56
+ lang: "ar"
57
+ }
58
+ ]
59
+ },
60
+ {
61
+ perk: {
62
+ key: 'gpt_points',
63
+ name: 'gpt_points',
64
+ description: 'gpt_points',
65
+ value: '5',
66
+ },
67
+ translation: [
68
+ {
69
+ key: 'name',
70
+ value: "GPT points",
71
+ lang: "en"
72
+ },
73
+ {
74
+ key: 'name',
75
+ value: "نقاط GPT",
76
+ lang: "ar"
77
+ },
78
+ ]
79
+ },
80
+ {
81
+ perk: {
82
+ key: 'num_of_cv_sections',
83
+ name: 'num_of_cv_sections',
84
+ description: 'num_of_cv_sections',
85
+ value: '3',
86
+ },
87
+ translation: [
88
+ {
89
+ key: 'name',
90
+ value: "Num of cv sections",
91
+ lang: "en"
92
+ },
93
+ {
94
+ key: 'name',
95
+ value: "عدد عناصر السيرة الذاتية",
96
+ lang: "ar"
97
+ },
98
+
99
+
100
+
101
+
102
+ ]
103
+ },
104
+ {
105
+ perk: {
106
+ key: 'price',
107
+ name: 'price',
108
+ description: 'price',
109
+ value: '0',
110
+ },
111
+ translation: [
112
+ {
113
+ key: 'name',
114
+ value: "price",
115
+ lang: "en"
116
+ },
117
+ {
118
+ key: 'name',
119
+ value: "السعر",
120
+ lang: "ar"
121
+ },
122
+ ]
123
+ },
124
+ {
125
+ perk: {
126
+ key: 'duration',
127
+ name: 'duration',
128
+ description: 'duration',
129
+ value: '0',
130
+ },
131
+ translation: [
132
+ {
133
+ key: 'name',
134
+ value: "duration",
135
+ lang: "en"
136
+ },
137
+ {
138
+ key: 'name',
139
+ value: "المدة",
140
+ lang: "ar"
141
+ },
142
+ ]
143
+ },
144
+ {
145
+ perk: {
146
+ key: 'num_of_cv_items',
147
+ name: 'num_of_cv_items',
148
+ description: 'num_of_cv_items',
149
+ value: '3',
150
+ },
151
+ translation: [
152
+ {
153
+ key: 'name',
154
+ value: "num_of_cv_items",
155
+ lang: "en"
156
+ },
157
+ {
158
+ key: 'name',
159
+ value: "عدد عناصر اقسام السيرة الذاتية",
160
+ lang: "ar"
161
+ },
162
+ ]
163
+ },
164
+ ];
165
+
166
+
167
+
168
+
169
+
170
+ planPerks.forEach(async planPerk => {
171
+ var perk = await tx.planPerk.create({
172
+ data: {
173
+ key: planPerk.perk.key,
174
+ name: planPerk.perk.name,
175
+ description: planPerk.perk.description,
176
+ value: planPerk.perk.value,
177
+ status: true
178
+ }
179
+ })
180
+
181
+ planPerk.translation.forEach(async translation => {
182
+ await tx.planPerkTranlation.create({
183
+ data: {
184
+ key: translation.key,
185
+ value: translation.value,
186
+ lang: translation.lang,
187
+ planPerkId: perk.id
188
+ }
189
+ });
190
+
191
+ })
192
+ });
193
+
194
+ }
195
+
196
+
197
+ async function plans(tx: any) {
198
+ var plan = await tx.plan.create({
199
+ data: {
200
+ name: "Free Plan",
201
+ permalink: 'safdsad',
202
+ status: true,
203
+ }
204
+ });
205
+
206
+ await tx.planTranslation.createMany({
207
+ data: [
208
+ {
209
+ key: "name",
210
+ lang: "en",
211
+ planId: plan.id,
212
+ value: "Free plan"
213
+ },
214
+ {
215
+ key: "name",
216
+ lang: "ar",
217
+ planId: plan.id,
218
+ value: "الخطة المجانية"
219
+ },
220
+
221
+ ]
222
+ })
223
+
224
+ var perks: PlanPerk[] = await tx.planPerk.findMany();
225
+ for (const perk of perks) {
226
+ await tx.planPerkValue.create({
227
+ data: {
228
+ planId: plan.id,
229
+ planPerkId: perk.id,
230
+ value: perk.value,
231
+ }
232
+ });
233
+ }
234
+ }
235
+
236
+
237
+ async function mnPrograms() {
238
+
40
239
  }
41
240
 
42
241
 
43
- export const configs = async () => {
242
+ async function mentors() {
44
243
 
45
- const defaultCvTemplate = await getDefaultDocTemplte('cv');
46
- const defaultClTemplate = await getDefaultDocTemplte('cl');
47
- const defaultUserPlan = await getDefaultUserPlan();
244
+ }
48
245
 
246
+ async function skillRepo(tx: any) {
247
+
248
+
249
+ var skills = [
250
+ {
251
+ skill: {
252
+ name: 'Html'
253
+ },
254
+ translation: [
255
+ {
256
+ key: 'name',
257
+ value: 'Html',
258
+ lang: "en"
259
+ },
260
+ {
261
+ key: 'name',
262
+ value: 'Html',
263
+ lang: "ar"
264
+ }
265
+ ]
266
+ },
267
+ {
268
+ skill: {
269
+ name: 'PHP'
270
+ },
271
+ translation: [
272
+ {
273
+ key: 'name',
274
+ value: 'PHP',
275
+ lang: "en"
276
+ },
277
+ {
278
+ key: 'name',
279
+ value: 'PHP',
280
+ lang: "ar"
281
+ }
282
+ ]
283
+ },
284
+ ];
285
+
286
+ for (const skill of skills) {
287
+ var savedSkill = await tx.skillRepo.create({
288
+ data: {
289
+ name: skill.skill.name, status: true,
290
+ }
291
+ });
292
+
293
+
294
+ for (const skillTranslation of skill.translation) {
295
+ await tx.skillRepoTranslation.create({
296
+ data: {
297
+ key: skillTranslation.key,
298
+ value: skillTranslation.value,
299
+ lang: skillTranslation.lang,
300
+ skillRepoId: savedSkill.id
301
+ }
302
+ })
303
+ }
304
+ }
305
+ }
49
306
 
50
307
 
51
- return [
308
+
309
+
310
+
311
+ async function colorRepo(tx: any) {
312
+
313
+ var colors = [
314
+ {
315
+ color: {
316
+ name: 'black',
317
+ hex: '#000000',
318
+ },
319
+ translation: [
320
+ {
321
+ value: 'الاسود',
322
+ lang: 'ar'
323
+ },
324
+ {
325
+ value: "black",
326
+ lang: "en"
327
+ }
328
+ ]
329
+ },
330
+ {
331
+ color: {
332
+ name: 'red',
333
+ hex: '#FF0000',
334
+ },
335
+ translation: [
336
+ {
337
+ value: 'احمر',
338
+ lang: 'ar'
339
+ },
340
+ {
341
+ value: "red",
342
+ lang: "en"
343
+ }
344
+ ]
345
+ },
346
+ ];
347
+
348
+ for (const color of colors) {
349
+ var colorRepoItem = await tx.colorRepo.create({
350
+ data: {
351
+ name: color.color.name,
352
+ hex: color.color.hex,
353
+ status: true
354
+ }
355
+ });
356
+
357
+ for (const colorTranslatopn of color.translation) {
358
+ await tx.colorRepoTranslation.create({
359
+ data: {
360
+ key: 'name',
361
+ lang: colorTranslatopn.lang,
362
+ value: colorTranslatopn.value,
363
+ colorRepoId: colorRepoItem.id
364
+ }
365
+ })
366
+
367
+ }
368
+ }
369
+ }
370
+
371
+
372
+ async function fontsRepo(tx: any) {
373
+
374
+ var fonts = [
375
+ {
376
+ font: {
377
+ name: 'black',
378
+ },
379
+ translation: [
380
+ {
381
+ value: 'الاسود',
382
+ lang: 'ar'
383
+ },
384
+ {
385
+ value: "black",
386
+ lang: "en"
387
+ }
388
+ ]
389
+ },
390
+ ];
391
+
392
+
393
+ for (const font of fonts) {
394
+ var fontRepoItem = await tx.fontRepo.create({
395
+ data: {
396
+ name: font.font.name,
397
+ status: true
398
+ }
399
+ });
400
+
401
+ for (const fontTranslatopn of font.translation) {
402
+ await tx.fontRepoTranslation.create({
403
+ data: {
404
+ key: 'name',
405
+ lang: fontTranslatopn.lang,
406
+ value: fontTranslatopn.value,
407
+ fontRepoId: fontRepoItem.id
408
+ }
409
+ })
410
+ }
411
+ }
412
+ }
413
+
414
+ async function positionRepo(tx: any) {
415
+
416
+
417
+ }
418
+
419
+ async function cvTemplate(tx: any) {
420
+
421
+
422
+ var cvTemplateThumb = await tx.upload.create({
423
+ data: {
424
+ extention: 'png',
425
+ filename: 'test',
426
+ model: 'template',
427
+ modelId: 1,
428
+ path: '/test',
429
+ size: 22,
430
+ }
431
+ })
432
+
433
+ var cvTemplate = await tx.template.create({
434
+ data: {
435
+ name: "james",
436
+ description: 'lorem ipsun',
437
+ for: 'cv',
438
+ thumbnailId: cvTemplateThumb.id,
439
+ isPaid: false,
440
+ status: true,
441
+ }
442
+ });
443
+
444
+
445
+
446
+ var metas = [
447
+ {
448
+ key: 'font_color',
449
+ value: '1',
450
+ templateId: cvTemplate.id,
451
+ model: 'colorRepo'
452
+ },
453
+ {
454
+ key: 'font_type',
455
+ value: '1',
456
+ templateId: cvTemplate.id,
457
+ model: 'fontRepo'
458
+ },
459
+ {
460
+ key: 'background_color',
461
+ value: '1',
462
+ templateId: cvTemplate.id,
463
+ model: 'colorRepo'
464
+ }
465
+ ];
466
+
467
+ await tx.templateMeta.createMany({
468
+ data: metas
469
+ })
470
+
471
+ }
472
+
473
+
474
+ async function clTemplate(tx: any) {
475
+
476
+ }
477
+
478
+
479
+
480
+
481
+
482
+ async function configs(tx: any) {
483
+
484
+ const defaultCvTemplate = await getDefaultDocTemplte(tx, 'cv');
485
+ const defaultClTemplate = await getDefaultDocTemplte(tx, 'cl');
486
+ const defaultUserPlan = await getDefaultUserPlan(tx);
487
+
488
+ var configs = [
52
489
  {
53
490
  configName: 'MaintenanceMode',
54
491
  configValue: '1',
@@ -384,31 +821,49 @@ export const configs = async () => {
384
821
  },
385
822
 
386
823
  ]
824
+
825
+ await tx.config.createMany({
826
+ data: configs
827
+ });
828
+
829
+
387
830
  }
388
831
 
389
832
 
390
833
 
391
834
 
392
835
 
836
+
393
837
  async function main() {
394
838
 
395
839
  //configs seeder
396
- var confs = await configs();
397
- // await prisma.config.createMany({
398
- // data: confs
399
- // })
840
+ try {
841
+
842
+ await prisma.$transaction(async (tx) => {
843
+ await plansPerks(tx);
844
+ await plans(tx);
845
+ await skillRepo(tx);
846
+ await colorRepo(tx);
847
+ await fontsRepo(tx);
848
+ await cvTemplate(tx);
849
+ await configs(tx);
850
+ });
851
+ console.error('done');
852
+
853
+
854
+ } catch (error) {
855
+ console.log(error);
856
+ }
857
+
400
858
 
401
- console.error('done');
402
859
  }
403
860
 
404
- main()
405
- .catch((e) => {
406
- console.error(e);
407
- process.exit(1);
408
- })
409
- .finally(async () => {
410
- await prisma.$disconnect();
411
- });
861
+ main().catch((e) => {
862
+ console.error(e);
863
+ process.exit(1);
864
+ }).finally(async () => {
865
+ await prisma.$disconnect();
866
+ });
412
867
 
413
868
 
414
869
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "careerty-prism",
3
- "version": "1.0.14",
3
+ "version": "1.0.16",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -70,13 +70,13 @@ enum ApprovalRequestModel {
70
70
  MENTOR
71
71
  MNPROGRAM
72
72
  }
73
+
73
74
  enum ApprovalRequestState {
74
75
  PENDING
75
76
  APPROVED
76
77
  REJECTED
77
78
  }
78
79
 
79
-
80
80
  model Config {
81
81
  id Int @id @default(autoincrement())
82
82
  configName String @unique
@@ -319,6 +319,7 @@ model CV {
319
319
  references CvReference[]
320
320
  contacts CvContact[]
321
321
  metas CvMeta[]
322
+ CvCertificate CvCertificate[]
322
323
  createdAt DateTime @default(now())
323
324
  updatedAt DateTime @updatedAt
324
325
  chat AiCvChat?
@@ -327,7 +328,7 @@ model CV {
327
328
  model CvExperience {
328
329
  id Int @id @default(autoincrement())
329
330
  title String?
330
- description String?
331
+ description String? @db.LongText
331
332
  at String?
332
333
  from DateTime?
333
334
  to DateTime?
@@ -340,7 +341,7 @@ model CvExperience {
340
341
  model CvEducation {
341
342
  id Int @id @default(autoincrement())
342
343
  title String?
343
- description String?
344
+ description String? @db.LongText
344
345
  at String?
345
346
  from DateTime?
346
347
  to DateTime?
@@ -364,7 +365,7 @@ model CvContact {
364
365
  model CvSkill {
365
366
  id Int @id @default(autoincrement())
366
367
  title String?
367
- description String?
368
+ description String? @db.LongText
368
369
  value String?
369
370
  color String
370
371
  sort Int
@@ -375,7 +376,7 @@ model CvSkill {
375
376
  model CvProject {
376
377
  id Int @id @default(autoincrement())
377
378
  title String?
378
- description String?
379
+ description String? @db.LongText
379
380
  job String?
380
381
  date DateTime?
381
382
  sort Int
@@ -386,7 +387,7 @@ model CvProject {
386
387
  model CvOrganization {
387
388
  id Int @id @default(autoincrement())
388
389
  title String?
389
- description String?
390
+ description String? @db.LongText
390
391
  job String?
391
392
  from DateTime?
392
393
  to DateTime?
@@ -399,7 +400,7 @@ model CvOrganization {
399
400
  model CvAward {
400
401
  id Int @id @default(autoincrement())
401
402
  title String?
402
- description String?
403
+ description String? @db.LongText
403
404
  job String?
404
405
  date DateTime?
405
406
  sort Int
@@ -421,6 +422,20 @@ model CvReference {
421
422
  cvId Int
422
423
  }
423
424
 
425
+ model CvCertificate {
426
+ id Int @id @default(autoincrement())
427
+ title String?
428
+ issuer String?
429
+ from DateTime?
430
+ to DateTime?
431
+ credentialId String?
432
+ credentialUrl String?
433
+ sort Int
434
+ status Int
435
+ CV CV @relation(fields: [cvId], references: [id])
436
+ cvId Int
437
+ }
438
+
424
439
  model CvMeta {
425
440
  id Int @id @default(autoincrement())
426
441
  key String
@@ -548,7 +563,7 @@ model MentorAvailablitySlot {
548
563
  model Service {
549
564
  id Int @id @default(autoincrement())
550
565
  name String
551
- description String
566
+ description String @db.LongText
552
567
  fullPrice Int
553
568
  commission Int
554
569
  status Boolean @default(false)
@@ -602,7 +617,7 @@ model ServiceRequest {
602
617
  model MnProgram {
603
618
  id Int @id @default(autoincrement())
604
619
  name String
605
- description String
620
+ description String @db.LongText
606
621
  status Boolean @default(false)
607
622
  folder String
608
623
  meetCount Int
@@ -889,11 +904,10 @@ model SkillRepoTranslation {
889
904
  SkillRepo SkillRepo @relation(fields: [skillRepoId], references: [id])
890
905
  }
891
906
 
892
-
893
907
  model ApprovalRequest {
894
- id Int @id @default(autoincrement())
895
- model ApprovalRequestModel
896
- modelId Int?
897
- stautus ApprovalRequestState @default(PENDING)
898
- changes String @db.LongText
899
- }
908
+ id Int @id @default(autoincrement())
909
+ model ApprovalRequestModel
910
+ modelId Int?
911
+ stautus ApprovalRequestState @default(PENDING)
912
+ changes String @db.LongText
913
+ }