@react-pakistan/util-functions 1.22.33 → 1.22.35

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/api/cors/index.js CHANGED
@@ -6,7 +6,7 @@ const getCorsHeaders = (origin) => {
6
6
  const headers = {
7
7
  'Access-Control-Allow-Methods': `${process.env.ALLOWED_METHODS}`,
8
8
  'Access-Control-Allow-Headers': `${process.env.ALLOWED_HEADERS}`,
9
- 'Access-Control-Allow-Origin': `${process.env.DOMAIN_URL}`,
9
+ 'Access-Control-Allow-Origin': `${process.env.ALLOWED_ORIGIN}`,
10
10
  };
11
11
  // If no allowed origin is set to default server origin
12
12
  if (!process.env.ALLOWED_ORIGIN || !origin)
@@ -10,7 +10,15 @@ interface CustomerBE {
10
10
  phone: string;
11
11
  updatedAt: string;
12
12
  }
13
- interface GetCustomerArgs {
13
+ interface GetCustomersArgs {
14
+ prisma: any;
15
+ }
16
+ interface GetCustomerByIdArgs {
17
+ id: string;
18
+ prisma: any;
19
+ }
20
+ interface GetCustomerByPhoneArgs {
21
+ phone: string;
14
22
  prisma: any;
15
23
  }
16
24
  interface PostCustomerArgs {
@@ -28,7 +36,9 @@ interface DeleteCustomerArgs {
28
36
  prisma: any;
29
37
  id: string;
30
38
  }
31
- export declare const getCustomer: ({ prisma }: GetCustomerArgs) => Promise<Array<CustomerBE>>;
39
+ export declare const getCustomers: ({ prisma }: GetCustomersArgs) => Promise<Array<CustomerBE>>;
40
+ export declare const getCustomerById: ({ prisma, id }: GetCustomerByIdArgs) => Promise<CustomerBE>;
41
+ export declare const getCustomerByPhone: ({ prisma, phone }: GetCustomerByPhoneArgs) => Promise<CustomerBE>;
32
42
  export declare const postCustomer: ({ prisma, id, address, city, country, email, firstName, lastName, phone, }: PostCustomerArgs) => Promise<Array<CustomerBE>>;
33
43
  export declare const deleteCustomer: ({ prisma, id }: DeleteCustomerArgs) => Promise<CustomerBE>;
34
44
  export {};
@@ -10,8 +10,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
10
10
  });
11
11
  };
12
12
  Object.defineProperty(exports, "__esModule", { value: true });
13
- exports.deleteCustomer = exports.postCustomer = exports.getCustomer = void 0;
14
- const getCustomer = (_a) => __awaiter(void 0, [_a], void 0, function* ({ prisma }) {
13
+ exports.deleteCustomer = exports.postCustomer = exports.getCustomerByPhone = exports.getCustomerById = exports.getCustomers = void 0;
14
+ const getCustomers = (_a) => __awaiter(void 0, [_a], void 0, function* ({ prisma }) {
15
15
  const customers = yield prisma.stellarCustomer.findMany({
16
16
  orderBy: {
17
17
  createdAt: 'desc',
@@ -19,8 +19,26 @@ const getCustomer = (_a) => __awaiter(void 0, [_a], void 0, function* ({ prisma
19
19
  });
20
20
  return customers;
21
21
  });
22
- exports.getCustomer = getCustomer;
23
- const postCustomer = (_b) => __awaiter(void 0, [_b], void 0, function* ({ prisma, id, address, city, country, email, firstName, lastName, phone, }) {
22
+ exports.getCustomers = getCustomers;
23
+ const getCustomerById = (_b) => __awaiter(void 0, [_b], void 0, function* ({ prisma, id }) {
24
+ const customer = yield prisma.stellarCustomer.findUnique({
25
+ where: {
26
+ id,
27
+ },
28
+ });
29
+ return customer;
30
+ });
31
+ exports.getCustomerById = getCustomerById;
32
+ const getCustomerByPhone = (_c) => __awaiter(void 0, [_c], void 0, function* ({ prisma, phone }) {
33
+ const customer = yield prisma.stellarCustomer.findUnique({
34
+ where: {
35
+ phone,
36
+ },
37
+ });
38
+ return customer;
39
+ });
40
+ exports.getCustomerByPhone = getCustomerByPhone;
41
+ const postCustomer = (_d) => __awaiter(void 0, [_d], void 0, function* ({ prisma, id, address, city, country, email, firstName, lastName, phone, }) {
24
42
  const customer = yield prisma.stellarCustomer.upsert({
25
43
  where: {
26
44
  id,
@@ -47,7 +65,7 @@ const postCustomer = (_b) => __awaiter(void 0, [_b], void 0, function* ({ prisma
47
65
  return customer;
48
66
  });
49
67
  exports.postCustomer = postCustomer;
50
- const deleteCustomer = (_c) => __awaiter(void 0, [_c], void 0, function* ({ prisma, id }) {
68
+ const deleteCustomer = (_e) => __awaiter(void 0, [_e], void 0, function* ({ prisma, id }) {
51
69
  const customer = yield prisma.stellarCustomer.delete({
52
70
  where: {
53
71
  id,
File without changes
File without changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-pakistan/util-functions",
3
- "version": "1.22.33",
3
+ "version": "1.22.35",
4
4
  "description": "A library of all util functions",
5
5
  "main": "index.js",
6
6
  "scripts": {