@react-pakistan/util-functions 1.22.37 → 1.22.38

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.
@@ -0,0 +1,46 @@
1
+ interface ContactBE {
2
+ companyId: string;
3
+ country: string;
4
+ createdAt: string;
5
+ email: string;
6
+ firstName: string;
7
+ id: string;
8
+ lastName: string;
9
+ phone: string;
10
+ updatedAt: string;
11
+ }
12
+ interface GetContactsArgs {
13
+ prisma: any;
14
+ }
15
+ interface GetContactByIdArgs {
16
+ id: string;
17
+ prisma: any;
18
+ }
19
+ interface PostContactsArgs {
20
+ currentPage: number;
21
+ pageLimit: number;
22
+ prisma: any;
23
+ queryWhere: {
24
+ [key: string]: any;
25
+ };
26
+ }
27
+ interface PostContactArgs {
28
+ companyId: string;
29
+ country: string;
30
+ email: string;
31
+ firstName: string;
32
+ id: string;
33
+ lastName: string;
34
+ phone: string;
35
+ prisma: any;
36
+ }
37
+ interface DeleteContactArgs {
38
+ id: string;
39
+ prisma: any;
40
+ }
41
+ export declare const getContacts: ({ prisma }: GetContactsArgs) => Promise<Array<ContactBE>>;
42
+ export declare const getContactById: ({ prisma, id }: GetContactByIdArgs) => Promise<ContactBE>;
43
+ export declare const postContacts: ({ currentPage, pageLimit, prisma, queryWhere, }: PostContactsArgs) => Promise<Array<ContactBE>>;
44
+ export declare const postContact: ({ prisma, id, companyId, country, email, firstName, lastName, phone, }: PostContactArgs) => Promise<Array<ContactBE>>;
45
+ export declare const deleteContact: ({ prisma, id }: DeleteContactArgs) => Promise<ContactBE>;
46
+ export {};
@@ -0,0 +1,91 @@
1
+ "use strict";
2
+ /* eslint-disable @typescript-eslint/no-explicit-any */
3
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
4
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
5
+ return new (P || (P = Promise))(function (resolve, reject) {
6
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
7
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
8
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
9
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
10
+ });
11
+ };
12
+ Object.defineProperty(exports, "__esModule", { value: true });
13
+ exports.deleteContact = exports.postContact = exports.postContacts = exports.getContactById = exports.getContacts = void 0;
14
+ const getContacts = (_a) => __awaiter(void 0, [_a], void 0, function* ({ prisma }) {
15
+ const contacts = yield prisma.stellarContact.findMany({
16
+ orderBy: {
17
+ createdAt: 'desc',
18
+ },
19
+ include: {
20
+ company: true,
21
+ },
22
+ });
23
+ return contacts;
24
+ });
25
+ exports.getContacts = getContacts;
26
+ const getContactById = (_b) => __awaiter(void 0, [_b], void 0, function* ({ prisma, id }) {
27
+ const contact = yield prisma.stellarContact.findUnique({
28
+ where: {
29
+ id,
30
+ },
31
+ include: {
32
+ company: true,
33
+ },
34
+ });
35
+ return contact;
36
+ });
37
+ exports.getContactById = getContactById;
38
+ const postContacts = (_c) => __awaiter(void 0, [_c], void 0, function* ({ currentPage, pageLimit, prisma, queryWhere, }) {
39
+ const contacts = yield prisma.$transaction([
40
+ prisma.stellarContact.count({
41
+ where: queryWhere,
42
+ }),
43
+ prisma.stellarContact.findMany({
44
+ orderBy: {
45
+ createdAt: 'desc',
46
+ },
47
+ include: {
48
+ company: true,
49
+ },
50
+ where: queryWhere,
51
+ take: pageLimit,
52
+ skip: currentPage === 1 ? 0 : currentPage - 1 * pageLimit,
53
+ }),
54
+ ]);
55
+ return contacts;
56
+ });
57
+ exports.postContacts = postContacts;
58
+ const postContact = (_d) => __awaiter(void 0, [_d], void 0, function* ({ prisma, id, companyId, country, email, firstName, lastName, phone, }) {
59
+ const contact = yield prisma.stellarContact.upsert({
60
+ where: {
61
+ id,
62
+ },
63
+ update: {
64
+ companyId,
65
+ country,
66
+ email,
67
+ firstName,
68
+ lastName,
69
+ phone,
70
+ },
71
+ create: {
72
+ companyId,
73
+ country,
74
+ email,
75
+ firstName,
76
+ lastName,
77
+ phone,
78
+ },
79
+ });
80
+ return contact;
81
+ });
82
+ exports.postContact = postContact;
83
+ const deleteContact = (_e) => __awaiter(void 0, [_e], void 0, function* ({ prisma, id }) {
84
+ const contact = yield prisma.stellarContact.delete({
85
+ where: {
86
+ id,
87
+ },
88
+ });
89
+ return contact;
90
+ });
91
+ exports.deleteContact = deleteContact;
@@ -16,6 +16,9 @@ const getCustomers = (_a) => __awaiter(void 0, [_a], void 0, function* ({ prisma
16
16
  orderBy: {
17
17
  createdAt: 'desc',
18
18
  },
19
+ include: {
20
+ contacts: true,
21
+ },
19
22
  });
20
23
  return customers;
21
24
  });
@@ -25,6 +28,9 @@ const getCustomerById = (_b) => __awaiter(void 0, [_b], void 0, function* ({ pri
25
28
  where: {
26
29
  id,
27
30
  },
31
+ include: {
32
+ contacts: true,
33
+ },
28
34
  });
29
35
  return customer;
30
36
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-pakistan/util-functions",
3
- "version": "1.22.37",
3
+ "version": "1.22.38",
4
4
  "description": "A library of all util functions",
5
5
  "main": "index.js",
6
6
  "scripts": {