@optimatech88/titomeet-shared-lib 1.0.8 → 1.0.9

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
@@ -6,6 +6,7 @@ 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,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;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,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;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,OAAO;gBACb,WAAW,EAAE,cAAc;aAC9B;YACD;gBACI,IAAI,EAAE,OAAO;gBACb,WAAW,EAAE,cAAc;aAC9B;YACD;gBACI,IAAI,EAAE,SAAS;gBACf,WAAW,EAAE,gBAAgB;aAChC;YACD;gBACI,IAAI,EAAE,MAAM;gBACZ,WAAW,EAAE,mBAAmB;aACnC;YACD;gBACI,IAAI,EAAE,SAAS;gBACf,WAAW,EAAE,gBAAgB;aAChC;SAEA,CAAC;QAEF,MAAM,iBAAiB,G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4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "scripts": {
@@ -77,12 +77,14 @@ enum EventVisibility {
77
77
 
78
78
  enum EventStatus {
79
79
  DRAFT
80
+ PENDING
80
81
  PUBLISHED
82
+ CANCELLED
81
83
  }
82
84
 
83
85
  model EventCategory {
84
86
  id String @id @default(cuid())
85
- name String
87
+ name String @unique
86
88
  description String?
87
89
  events Event[]
88
90
 
package/src/index.ts CHANGED
@@ -21,7 +21,7 @@ export * from './cache/cache.service';
21
21
  //prisma
22
22
  export * from './prisma/prisma.module';
23
23
  export * from './prisma/prisma.service';
24
-
24
+ export * from './prisma/seed';
25
25
  export * from './types';
26
26
  export * from './utils';
27
27
  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
+ });