@optimatech88/titomeet-shared-lib 1.0.8 → 1.0.10

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/dist/index.d.ts CHANGED
@@ -1,11 +1,12 @@
1
1
  export * from './auth/auth.guard';
2
- export { PrismaClient, User, Account, UserRole, Event, EventAccess, EventVisibility, EventStatus, EventPrice, Address, Participant, ParticipantStatus, Provider, ProviderStatus, EventCategory } from '@prisma/client';
2
+ export { PrismaClient, User, Account, UserRole, Event, EventAccess, EventVisibility, EventStatus, EventPrice, Address, Participant, ParticipantStatus, Provider, ProviderStatus, EventCategory, Review, } from '@prisma/client';
3
3
  export * from './auth/auth.guard';
4
4
  export * from './auth/auth.module';
5
5
  export * from './cache/cache.module';
6
6
  export * from './cache/cache.service';
7
7
  export * from './prisma/prisma.module';
8
8
  export * from './prisma/prisma.service';
9
+ export * from './prisma/seed';
9
10
  export * from './types';
10
11
  export * from './utils';
11
12
  export * from './utils/api/endpoints';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,OAAO,EACH,YAAY,EAAE,IAAI,EAAE,OAAO,EACvB,QAAQ,EAAE,KAAK,EAAE,WAAW,EAC5B,eAAe,EAAE,WAAW,EAC5B,UAAU,EAAE,OAAO,EAAE,WAAW,EAChC,iBAAiB,EACjB,QAAQ,EACR,cAAc,EACd,aAAa,EAChB,MAAM,gBAAgB,CAAC;AAG5B,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC;AAGnC,cAAc,sBAAsB,CAAC;AACrC,cAAc,uBAAuB,CAAC;AAGtC,cAAc,wBAAwB,CAAC;AACvC,cAAc,yBAAyB,CAAC;AAExC,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,uBAAuB,CAAC;AACtC,cAAc,gBAAgB,CAAC;AAE/B,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,OAAO,EACH,YAAY,EAAE,IAAI,EAAE,OAAO,EACvB,QAAQ,EAAE,KAAK,EAAE,WAAW,EAC5B,eAAe,EAAE,WAAW,EAC5B,UAAU,EAAE,OAAO,EAAE,WAAW,EAChC,iBAAiB,EACjB,QAAQ,EACR,cAAc,EACd,aAAa,EACb,MAAM,GAET,MAAM,gBAAgB,CAAC;AAG5B,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC;AAGnC,cAAc,sBAAsB,CAAC;AACrC,cAAc,uBAAuB,CAAC;AAGtC,cAAc,wBAAwB,CAAC;AACvC,cAAc,yBAAyB,CAAC;AACxC,cAAc,eAAe,CAAC;AAC9B,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,uBAAuB,CAAC;AACtC,cAAc,gBAAgB,CAAC;AAE/B,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC"}
package/dist/index.js CHANGED
@@ -30,6 +30,7 @@ __exportStar(require("./cache/cache.module"), exports);
30
30
  __exportStar(require("./cache/cache.service"), exports);
31
31
  __exportStar(require("./prisma/prisma.module"), exports);
32
32
  __exportStar(require("./prisma/prisma.service"), exports);
33
+ __exportStar(require("./prisma/seed"), exports);
33
34
  __exportStar(require("./types"), exports);
34
35
  __exportStar(require("./utils"), exports);
35
36
  __exportStar(require("./utils/api/endpoints"), exports);
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,oDAAkC;AAClC,yCAS4B;AARxB,sGAAA,YAAY,OAAA;AACR,kGAAA,QAAQ,OAAA;AAAS,qGAAA,WAAW,OAAA;AAC5B,yGAAA,eAAe,OAAA;AAAE,qGAAA,WAAW,OAAA;AAE5B,2GAAA,iBAAiB,OAAA;AAEjB,wGAAA,cAAc,OAAA;AAKtB,oDAAkC;AAClC,qDAAmC;AAGnC,uDAAqC;AACrC,wDAAsC;AAGtC,yDAAuC;AACvC,0DAAwC;AAExC,0CAAwB;AACxB,0CAAwB;AACxB,wDAAsC;AACtC,iDAA+B;AAE/B,mCAAyC;AAAhC,iGAAA,UAAU,OAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,oDAAkC;AAClC,yCAW4B;AAVxB,sGAAA,YAAY,OAAA;AACR,kGAAA,QAAQ,OAAA;AAAS,qGAAA,WAAW,OAAA;AAC5B,yGAAA,eAAe,OAAA;AAAE,qGAAA,WAAW,OAAA;AAE5B,2GAAA,iBAAiB,OAAA;AAEjB,wGAAA,cAAc,OAAA;AAOtB,oDAAkC;AAClC,qDAAmC;AAGnC,uDAAqC;AACrC,wDAAsC;AAGtC,yDAAuC;AACvC,0DAAwC;AACxC,gDAA8B;AAC9B,0CAAwB;AACxB,0CAAwB;AACxB,wDAAsC;AACtC,iDAA+B;AAE/B,mCAAyC;AAAhC,iGAAA,UAAU,OAAA"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=seed.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"seed.d.ts","sourceRoot":"","sources":["../../src/prisma/seed.ts"],"names":[],"mappings":""}
@@ -0,0 +1,73 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const client_1 = require("@prisma/client");
4
+ const prisma = new client_1.PrismaClient();
5
+ async function main() {
6
+ try {
7
+ const categories = [
8
+ {
9
+ name: 'Music',
10
+ description: 'Music events',
11
+ },
12
+ {
13
+ name: 'Food',
14
+ description: 'Food events',
15
+ },
16
+ {
17
+ name: 'Art',
18
+ description: 'Art events',
19
+ },
20
+ {
21
+ name: 'Sports',
22
+ description: 'Sports events',
23
+ },
24
+ {
25
+ name: 'Games',
26
+ description: 'Games events',
27
+ },
28
+ {
29
+ name: 'Dance',
30
+ description: 'Dance events',
31
+ },
32
+ {
33
+ name: 'Fashion',
34
+ description: 'Fashion events',
35
+ },
36
+ {
37
+ name: 'Tech',
38
+ description: 'Technology events',
39
+ },
40
+ {
41
+ name: 'Science',
42
+ description: 'Science events',
43
+ },
44
+ ];
45
+ const categoriesCreated = await prisma.eventCategory.findMany({
46
+ where: {
47
+ name: {
48
+ in: categories.map((category) => category.name),
49
+ },
50
+ },
51
+ });
52
+ const categoriesNotCreated = categories.filter((category) => !categoriesCreated.some((c) => c.name === category.name));
53
+ if (categoriesNotCreated.length > 0) {
54
+ console.log(`Creating ${categoriesNotCreated.length} categories`);
55
+ await prisma.eventCategory.createMany({
56
+ data: categoriesNotCreated,
57
+ });
58
+ console.log(`Created ${categoriesNotCreated.length} categories`);
59
+ }
60
+ }
61
+ catch (error) {
62
+ console.error(error);
63
+ }
64
+ }
65
+ main()
66
+ .catch((error) => {
67
+ console.error(error);
68
+ process.exit(1);
69
+ })
70
+ .finally(async () => {
71
+ await prisma.$disconnect();
72
+ });
73
+ //# sourceMappingURL=seed.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"seed.js","sourceRoot":"","sources":["../../src/prisma/seed.ts"],"names":[],"mappings":";;AAEA,2CAA8C;AAE9C,MAAM,MAAM,GAAG,IAAI,qBAAY,EAAE,CAAC;AAElC,KAAK,UAAU,IAAI;IACf,IAAI,CAAC;QACD,MAAM,UAAU,GAAG;YACnB;gBACI,IAAI,EAAE,OAAO;gBACb,WAAW,EAAE,cAAc;aAC9B;YACD;gBACI,IAAI,EAAE,MAAM;gBACZ,WAAW,EAAE,aAAa;aAC7B;YACD;gBACI,IAAI,EAAE,KAAK;gBACX,WAAW,EAAE,YAAY;aAC5B;YACD;gBACI,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,eAAe;aAC/B;YACD;gBACI,IAAI,EAAE,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CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IACrB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AACpB,CAAC,CAAC;KACD,OAAO,CAAC,KAAK,IAAI,EAAE;IAChB,MAAM,MAAM,CAAC,WAAW,EAAE,CAAC;AAC/B,CAAC,CAAC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@optimatech88/titomeet-shared-lib",
3
- "version": "1.0.8",
3
+ "version": "1.0.10",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "scripts": {
@@ -41,6 +41,7 @@ model User {
41
41
  notificationsReceived Notification[] @relation("NotificationRecipient")
42
42
  notificationsSent Notification[] @relation("NotificationSender")
43
43
  providers Provider[]
44
+ reviews Review[]
44
45
  }
45
46
 
46
47
  model Account {
@@ -75,14 +76,9 @@ enum EventVisibility {
75
76
  PRIVATE
76
77
  }
77
78
 
78
- enum EventStatus {
79
- DRAFT
80
- PUBLISHED
81
- }
82
-
83
79
  model EventCategory {
84
80
  id String @id @default(cuid())
85
- name String
81
+ name String @unique
86
82
  description String?
87
83
  events Event[]
88
84
 
@@ -90,6 +86,13 @@ model EventCategory {
90
86
  updatedAt DateTime @updatedAt
91
87
  }
92
88
 
89
+ enum EventStatus {
90
+ DRAFT
91
+ PENDING
92
+ PUBLISHED
93
+ CANCELLED
94
+ }
95
+
93
96
  model Event {
94
97
  id String @id @default(cuid())
95
98
  name String
@@ -213,6 +216,8 @@ model Provider {
213
216
  name String
214
217
  description String?
215
218
  image String?
219
+ rating Float?
220
+ reviews Review[]
216
221
 
217
222
  user User @relation(fields: [userId], references: [id])
218
223
  userId String
@@ -223,4 +228,18 @@ model Provider {
223
228
 
224
229
  createdAt DateTime @default(now())
225
230
  updatedAt DateTime @updatedAt
231
+ }
232
+
233
+ model Review {
234
+ id String @id @default(cuid())
235
+ rating Float
236
+ comment String?
237
+ provider Provider @relation(fields: [providerId], references: [id])
238
+ providerId String
239
+
240
+ user User @relation(fields: [userId], references: [id])
241
+ userId String
242
+
243
+ createdAt DateTime @default(now())
244
+ updatedAt DateTime @updatedAt
226
245
  }
package/src/index.ts CHANGED
@@ -7,7 +7,9 @@ export {
7
7
  ParticipantStatus,
8
8
  Provider,
9
9
  ProviderStatus,
10
- EventCategory
10
+ EventCategory,
11
+ Review,
12
+
11
13
  } from '@prisma/client';
12
14
 
13
15
  //auth
@@ -21,7 +23,7 @@ export * from './cache/cache.service';
21
23
  //prisma
22
24
  export * from './prisma/prisma.module';
23
25
  export * from './prisma/prisma.service';
24
-
26
+ export * from './prisma/seed';
25
27
  export * from './types';
26
28
  export * from './utils';
27
29
  export * from './utils/api/endpoints';
@@ -0,0 +1,82 @@
1
+ //create a seed for the prisma client
2
+
3
+ import { PrismaClient } from '@prisma/client';
4
+
5
+ const prisma = new PrismaClient();
6
+
7
+ async function main() {
8
+ try {
9
+ const categories = [
10
+ {
11
+ name: 'Music',
12
+ description: 'Music events',
13
+ },
14
+ {
15
+ name: 'Food',
16
+ description: 'Food events',
17
+ },
18
+ {
19
+ name: 'Art',
20
+ description: 'Art events',
21
+ },
22
+ {
23
+ name: 'Sports',
24
+ description: 'Sports events',
25
+ },
26
+ {
27
+ name: 'Games',
28
+ description: 'Games events',
29
+ },
30
+ {
31
+ name: 'Dance',
32
+ description: 'Dance events',
33
+ },
34
+ {
35
+ name: 'Fashion',
36
+ description: 'Fashion events',
37
+ },
38
+ {
39
+ name: 'Tech',
40
+ description: 'Technology events',
41
+ },
42
+ {
43
+ name: 'Science',
44
+ description: 'Science events',
45
+ },
46
+
47
+ ];
48
+
49
+ const categoriesCreated = await prisma.eventCategory.findMany({
50
+ where: {
51
+ name: {
52
+ in: categories.map((category) => category.name),
53
+ },
54
+ },
55
+ });
56
+
57
+ const categoriesNotCreated = categories.filter((category) => !categoriesCreated.some((c) => c.name === category.name));
58
+
59
+ if(categoriesNotCreated.length > 0) {
60
+ console.log(`Creating ${categoriesNotCreated.length} categories`);
61
+ await prisma.eventCategory.createMany({
62
+ data: categoriesNotCreated,
63
+ });
64
+ console.log(`Created ${categoriesNotCreated.length} categories`);
65
+ }
66
+
67
+
68
+ } catch (error) {
69
+ console.error(error);
70
+ }
71
+
72
+
73
+ }
74
+
75
+ main()
76
+ .catch((error) => {
77
+ console.error(error);
78
+ process.exit(1);
79
+ })
80
+ .finally(async () => {
81
+ await prisma.$disconnect();
82
+ });