@campus-labs/prisma-client 0.10.0 → 0.11.0

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@campus-labs/prisma-client",
3
- "version": "0.10.0",
3
+ "version": "0.11.0",
4
4
  "description": "",
5
5
  "license": "ISC",
6
6
  "author": "",
@@ -337,7 +337,7 @@ model users {
337
337
  role_platform_id Int @default(2)
338
338
  is_notifications_active Boolean @default(false)
339
339
  is_email_active Boolean @default(true)
340
- is_global_ranking_active Boolean @default(false)
340
+ is_global_ranking_active Boolean @default(true)
341
341
  created_at DateTime @default(now()) @db.Timestamp(6)
342
342
  updated_at DateTime @default(now()) @db.Timestamp(6)
343
343
  deleted_at DateTime? @db.Timestamp(6)
@@ -368,6 +368,7 @@ model users {
368
368
  roleUserInitiativeUpdates_inviter role_user_initiative_update[] @relation("RoleUserInitiativeUpdateInviter")
369
369
  wallet_passes wallet_passes[]
370
370
  feedbackInitiatives feedback_initiative[]
371
+ power_up_instances power_up_instances[]
371
372
 
372
373
  @@index([role_platform_id], map: "idx_users_role")
373
374
  @@index([points(sort: Desc)], map: "idx_users_points")
@@ -399,6 +400,7 @@ model user_initiative {
399
400
  created_at DateTime @default(now()) @db.Timestamp(6)
400
401
  updated_at DateTime @default(now()) @db.Timestamp(6)
401
402
  deleted_at DateTime? @db.Timestamp(6)
403
+ points Int @default(0)
402
404
  initiatives initiatives @relation(fields: [initiative_id], references: [id], onDelete: Cascade, onUpdate: Cascade)
403
405
  roles_initiatives roles_initiatives @relation(fields: [role_initiative_id], references: [id], onDelete: Restrict, onUpdate: Cascade)
404
406
  users users @relation(fields: [user_id], references: [id], onDelete: Cascade, onUpdate: Cascade)
@@ -406,6 +408,7 @@ model user_initiative {
406
408
  @@id([user_id, initiative_id])
407
409
  @@index([user_id, role_initiative_id], map: "idx_user_initiative_user_role")
408
410
  @@index([initiative_id, role_initiative_id], map: "idx_user_initiative_initiative_role")
411
+ @@index([points(sort: Desc)], map: "idx_user_initiative_points")
409
412
  }
410
413
 
411
414
  model user_saved_initiatives {
@@ -551,15 +554,62 @@ model wallet_passes {
551
554
  model feedback_initiative {
552
555
  user_id String @db.VarChar(50)
553
556
  initiative_id Int
554
- feedback_number Int?
557
+ feedback_number Int?
555
558
  feedback_text String? @db.VarChar(1000)
556
559
  created_at DateTime @default(now()) @db.Timestamp(6)
557
560
  updated_at DateTime @default(now()) @db.Timestamp(6)
558
561
  deleted_at DateTime? @db.Timestamp(6)
559
562
 
560
- users users @relation(fields: [user_id], references: [id], onDelete: Cascade, onUpdate: Cascade)
561
- initiatives initiatives @relation(fields: [initiative_id], references: [id], onDelete: Cascade, onUpdate: Cascade)
562
-
563
+ users users @relation(fields: [user_id], references: [id], onDelete: Cascade, onUpdate: Cascade)
564
+ initiatives initiatives @relation(fields: [initiative_id], references: [id], onDelete: Cascade, onUpdate: Cascade)
565
+
563
566
  @@id([user_id, initiative_id])
564
567
  @@index([user_id, initiative_id], map: "idx_feedback_initiative_user_initiative")
565
568
  }
569
+
570
+ model power_up_definitions {
571
+ id Int @id @default(autoincrement())
572
+ slug String @unique @db.VarChar(50)
573
+ title String @db.VarChar(100)
574
+ description String @db.VarChar(3000)
575
+ img Json
576
+ base_percentage Float
577
+ duration_days Int?
578
+ duration_type String @default("FIXED_DAYS") @db.VarChar(20)
579
+ conditions Json
580
+ bonus_rule Json?
581
+ is_active Boolean @default(true)
582
+ created_at DateTime @default(now()) @db.Timestamp(6)
583
+ updated_at DateTime @default(now()) @db.Timestamp(6)
584
+ deleted_at DateTime? @db.Timestamp(6)
585
+
586
+ instances power_up_instances[]
587
+
588
+ @@index([is_active], map: "idx_pud_active")
589
+ @@index([slug], map: "idx_pud_slug")
590
+ }
591
+
592
+ model power_up_instances {
593
+ id Int @id @default(autoincrement())
594
+ user_id String @db.VarChar(50)
595
+ power_up_definition_id Int
596
+ status String @default("TRACKING") @db.VarChar(20)
597
+ progress Json @default("{}")
598
+ bonus_value Float @default(0)
599
+ effective_percentage Float @default(0)
600
+ redeemed_at DateTime? @db.Timestamp(6)
601
+ activated_at DateTime? @db.Timestamp(6)
602
+ expires_at DateTime? @db.Timestamp(6)
603
+ expired_at DateTime? @db.Timestamp(6)
604
+ created_at DateTime @default(now()) @db.Timestamp(6)
605
+ updated_at DateTime @default(now()) @db.Timestamp(6)
606
+ deleted_at DateTime? @db.Timestamp(6)
607
+
608
+ users users @relation(fields: [user_id], references: [id], onDelete: Cascade, onUpdate: Cascade)
609
+ power_up_definition power_up_definitions @relation(fields: [power_up_definition_id], references: [id], onDelete: Restrict, onUpdate: Cascade)
610
+
611
+ @@index([user_id, status], map: "idx_pui_user_status")
612
+ @@index([user_id, power_up_definition_id, status], map: "idx_pui_user_def_status")
613
+ @@index([status, expires_at], map: "idx_pui_expiration")
614
+ @@index([user_id, activated_at, expires_at], map: "idx_pui_user_active_window")
615
+ }
@@ -0,0 +1,147 @@
1
+ import { PrismaClient } from '@prisma/client';
2
+
3
+ const prisma = new PrismaClient();
4
+
5
+ async function main() {
6
+ console.log('🚀 Seeding power-up definitions...');
7
+
8
+ // 1. Altruísta — Reconhecer e ser reconhecido
9
+ const altruista = await prisma.power_up_definitions.upsert({
10
+ where: { slug: 'altruista' },
11
+ update: {},
12
+ create: {
13
+ slug: 'altruista',
14
+ title: 'Altruísta',
15
+ description: 'Demonstra o teu espírito de equipa! Reconhece 5 pessoas diferentes pelas suas soft skills e recebe reconhecimento de 5 pessoas diferentes. Quando ativo, ganha +5% de pontos em cada badge.',
16
+ img: { url: 'powerups/altruista.png', alt: 'Power-Up Altruísta' },
17
+ base_percentage: 5.0,
18
+ duration_days: 30,
19
+ duration_type: 'FIXED_DAYS',
20
+ conditions: [
21
+ { type: 'RECOGNITION_RECEIVED', target: 5, unique_recognizers: true },
22
+ { type: 'RECOGNITION_GIVEN', target: 5, unique_recipients: true },
23
+ ],
24
+ bonus_rule: null,
25
+ is_active: true,
26
+ },
27
+ });
28
+ console.log(` ✅ Altruísta (id: ${altruista.id})`);
29
+
30
+ // 2. Mensageiro — Convidar pessoas que ganham badges
31
+ const mensageiro = await prisma.power_up_definitions.upsert({
32
+ where: { slug: 'mensageiro' },
33
+ update: {},
34
+ create: {
35
+ slug: 'mensageiro',
36
+ title: 'Mensageiro',
37
+ description: 'Traz novos talentos para as iniciativas! Convida alguém para uma iniciativa e essa pessoa ganha um badge. Quando ativo, ganha +5% de pontos em cada badge.',
38
+ img: { url: 'powerups/mensageiro.png', alt: 'Power-Up Mensageiro' },
39
+ base_percentage: 5.0,
40
+ duration_days: 30,
41
+ duration_type: 'FIXED_DAYS',
42
+ conditions: [
43
+ { type: 'INVITATION_BADGE', target: 1 },
44
+ ],
45
+ bonus_rule: null,
46
+ is_active: true,
47
+ },
48
+ });
49
+ console.log(` ✅ Mensageiro (id: ${mensageiro.id})`);
50
+
51
+ // 3. Colecionador — Acumular badges
52
+ const colecionador = await prisma.power_up_definitions.upsert({
53
+ where: { slug: 'colecionador' },
54
+ update: {},
55
+ create: {
56
+ slug: 'colecionador',
57
+ title: 'Colecionador',
58
+ description: 'Torna-te um mestre da plataforma! Ganha 10 badges aprovados para desbloquear este power-up. Quando ativo, ganha +5% de pontos em cada badge.',
59
+ img: { url: 'powerups/colecionador.png', alt: 'Power-Up Colecionador' },
60
+ base_percentage: 5.0,
61
+ duration_days: 30,
62
+ duration_type: 'FIXED_DAYS',
63
+ conditions: [
64
+ { type: 'BADGE_COUNT', target: 10 },
65
+ ],
66
+ bonus_rule: null,
67
+ is_active: true,
68
+ },
69
+ });
70
+ console.log(` ✅ Colecionador (id: ${colecionador.id})`);
71
+
72
+ // 4. Multi-facetado — Diversidade de papéis
73
+ // Role IDs: 1 = ORGANIZATOR, 2 = VOLUNTEER, 3 = PARTICIPANT
74
+ const multiFacetado = await prisma.power_up_definitions.upsert({
75
+ where: { slug: 'multi-facetado' },
76
+ update: {},
77
+ create: {
78
+ slug: 'multi-facetado',
79
+ title: 'Multi-facetado',
80
+ description: 'Mostra a tua versatilidade! Ganha badges como organizador, voluntário e participante. Quando ativo, ganha +5% de pontos em cada badge.',
81
+ img: { url: 'powerups/multi-facetado.png', alt: 'Power-Up Multi-facetado' },
82
+ base_percentage: 5.0,
83
+ duration_days: 30,
84
+ duration_type: 'FIXED_DAYS',
85
+ conditions: [
86
+ { type: 'ROLE_DIVERSITY', roles: [1, 2, 3], min_badges_per_role: 1 },
87
+ ],
88
+ bonus_rule: null,
89
+ is_active: true,
90
+ },
91
+ });
92
+ console.log(` ✅ Multi-facetado (id: ${multiFacetado.id})`);
93
+
94
+ // 5. Explorador de Áreas — Diversidade de áreas (com bónus progressivo)
95
+ const exploradorAreas = await prisma.power_up_definitions.upsert({
96
+ where: { slug: 'explorador-de-areas' },
97
+ update: {},
98
+ create: {
99
+ slug: 'explorador-de-areas',
100
+ title: 'Explorador de Áreas',
101
+ description: 'Descobre novos horizontes! Ganha badges em pelo menos 2 áreas diferentes. Cada área adicional dá +1% extra de bónus. Quando ativo, ganha +5% (base) + bónus de pontos em cada badge.',
102
+ img: { url: 'powerups/explorador-de-areas.png', alt: 'Power-Up Explorador de Áreas' },
103
+ base_percentage: 5.0,
104
+ duration_days: 30,
105
+ duration_type: 'FIXED_DAYS',
106
+ conditions: [
107
+ { type: 'AREA_DIVERSITY', min_areas: 2 },
108
+ ],
109
+ bonus_rule: { type: 'PER_AREA', percentage_per_unit: 1.0 },
110
+ is_active: true,
111
+ },
112
+ });
113
+ console.log(` ✅ Explorador de Áreas (id: ${exploradorAreas.id})`);
114
+
115
+ // 6. Consistente — Streak mensal de badges
116
+ const consistente = await prisma.power_up_definitions.upsert({
117
+ where: { slug: 'consistente' },
118
+ update: {},
119
+ create: {
120
+ slug: 'consistente',
121
+ title: 'Consistente',
122
+ description: 'A consistência compensa! Ganha pelo menos 1 badge por mês consecutivo. Cada mês adicional dá +1% extra de bónus. Ativo durante o mês corrente.',
123
+ img: { url: 'powerups/consistente.png', alt: 'Power-Up Consistente' },
124
+ base_percentage: 5.0,
125
+ duration_days: null,
126
+ duration_type: 'CURRENT_MONTH',
127
+ conditions: [
128
+ { type: 'MONTHLY_STREAK', min_months: 1 },
129
+ ],
130
+ bonus_rule: { type: 'PER_STREAK_MONTH', percentage_per_unit: 1.0 },
131
+ is_active: true,
132
+ },
133
+ });
134
+ console.log(` ✅ Consistente (id: ${consistente.id})`);
135
+
136
+ console.log('\n🎉 Power-up definitions seeded successfully!');
137
+ console.log(` Total: 6 power-ups created/verified`);
138
+ }
139
+
140
+ main()
141
+ .catch((e) => {
142
+ console.error('❌ Error seeding power-ups:', e);
143
+ process.exit(1);
144
+ })
145
+ .finally(async () => {
146
+ await prisma.$disconnect();
147
+ });
package/prisma/seed2.ts CHANGED
@@ -261,10 +261,10 @@ async function main() {
261
261
  }),
262
262
  prisma.soft_skills.create({
263
263
  data: {
264
- title: 'Pensamento Crítico',
265
- img_active: { url: "https://576wibblum.ufs.sh/f/l7y45I6Co8dLLVjE0qgcDHxWfulkaytOqz3SVegmLwobGJs8", alt: "Pensamento Crítico" },
266
- img_achieved: { url: "https://576wibblum.ufs.sh/f/l7y45I6Co8dLLVjE0qgcDHxWfulkaytOqz3SVegmLwobGJs8", alt: "Pensamento Crítico" },
267
- img_inactive: { url: "https://576wibblum.ufs.sh/f/l7y45I6Co8dLLVjE0qgcDHxWfulkaytOqz3SVegmLwobGJs8", alt: "Pensamento Crítico" },
264
+ title: 'Pensamento Analítico',
265
+ img_active: { url: "https://576wibblum.ufs.sh/f/l7y45I6Co8dLLVjE0qgcDHxWfulkaytOqz3SVegmLwobGJs8", alt: "Pensamento Analítico" },
266
+ img_achieved: { url: "https://576wibblum.ufs.sh/f/l7y45I6Co8dLLVjE0qgcDHxWfulkaytOqz3SVegmLwobGJs8", alt: "Pensamento Analítico" },
267
+ img_inactive: { url: "https://576wibblum.ufs.sh/f/l7y45I6Co8dLLVjE0qgcDHxWfulkaytOqz3SVegmLwobGJs8", alt: "Pensamento Analítico" },
268
268
  description: 'Analisar informação de forma lógica e estruturada, interpretando dados, identificando padrões e estabelecendo relações relevantes para apoiar a tomada de decisões.',
269
269
  }
270
270
  }),