@kiminix/tp-client 1.0.0 → 1.2.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.
Files changed (85) hide show
  1. package/dist/business/apis.d.ts +6 -0
  2. package/dist/business/apis.js +82 -0
  3. package/dist/business/get-all/cache/client.d.ts +2 -0
  4. package/dist/business/get-all/cache/client.js +58 -0
  5. package/dist/business/get-all/client.d.ts +2 -0
  6. package/dist/business/get-all/client.js +53 -0
  7. package/dist/business/get-all/no-cache/client.d.ts +7 -0
  8. package/dist/business/get-all/no-cache/client.js +64 -0
  9. package/dist/business/get-all/types.d.ts +13 -0
  10. package/dist/business/get-all/types.js +1 -0
  11. package/dist/business/types/get-all.d.ts +13 -0
  12. package/dist/business/types/get-all.js +1 -0
  13. package/dist/business/types/get-id.d.ts +28 -0
  14. package/dist/business/types/get-id.js +1 -0
  15. package/dist/constants.d.ts +2 -0
  16. package/dist/constants.js +3 -0
  17. package/dist/contants.d.ts +2 -0
  18. package/dist/contants.js +3 -0
  19. package/dist/deals/apis.d.ts +7 -0
  20. package/dist/deals/apis.js +96 -0
  21. package/dist/deals/types/get-id.d.ts +49 -0
  22. package/dist/deals/types/get-id.js +1 -0
  23. package/dist/deals/types/get-pages.d.ts +40 -0
  24. package/dist/deals/types/get-pages.js +1 -0
  25. package/dist/enum.d.ts +15 -0
  26. package/dist/enum.js +18 -0
  27. package/dist/iam/admin-apis.d.ts +4 -0
  28. package/dist/iam/admin-apis.js +66 -0
  29. package/dist/iam/types/business-signin.d.ts +11 -0
  30. package/dist/iam/types/business-signin.js +1 -0
  31. package/dist/iam/types/me.d.ts +12 -0
  32. package/dist/iam/types/me.js +1 -0
  33. package/dist/iam/types/reset-password.d.ts +5 -0
  34. package/dist/iam/types/reset-password.js +1 -0
  35. package/dist/iam/types/update-profile.d.ts +29 -0
  36. package/dist/iam/types/update-profile.js +1 -0
  37. package/dist/iam/types/user-signin.d.ts +12 -0
  38. package/dist/iam/types/user-signin.js +1 -0
  39. package/dist/iam/types/user-signup-validate.d.ts +5 -0
  40. package/dist/iam/types/user-signup-validate.js +1 -0
  41. package/dist/iam/types/user-signup.d.ts +20 -0
  42. package/dist/iam/types/user-signup.js +1 -0
  43. package/dist/iam/user-apis.d.ts +16 -0
  44. package/dist/iam/user-apis.js +279 -0
  45. package/dist/index.d.ts +14 -0
  46. package/dist/index.js +15 -0
  47. package/dist/menus/apis.d.ts +4 -0
  48. package/dist/menus/apis.js +61 -0
  49. package/dist/menus/types/get-menus.d.ts +20 -0
  50. package/dist/menus/types/get-menus.js +1 -0
  51. package/dist/notify/apis.d.ts +4 -0
  52. package/dist/notify/apis.js +80 -0
  53. package/dist/others/apis.d.ts +3 -0
  54. package/dist/others/apis.js +58 -0
  55. package/dist/reservations/admin-apis.d.ts +12 -0
  56. package/dist/reservations/admin-apis.js +145 -0
  57. package/dist/reservations/types/admin/get-available-transitions.d.ts +4 -0
  58. package/dist/reservations/types/admin/get-available-transitions.js +1 -0
  59. package/dist/reservations/types/admin/get-id.d.ts +4 -0
  60. package/dist/reservations/types/admin/get-id.js +1 -0
  61. package/dist/reservations/types/admin/get-page.d.ts +7 -0
  62. package/dist/reservations/types/admin/get-page.js +1 -0
  63. package/dist/reservations/types/admin/patch-status.d.ts +6 -0
  64. package/dist/reservations/types/admin/patch-status.js +1 -0
  65. package/dist/reservations/types/get-id.d.ts +4 -0
  66. package/dist/reservations/types/get-id.js +1 -0
  67. package/dist/reservations/types/shared.d.ts +46 -0
  68. package/dist/reservations/types/shared.js +1 -0
  69. package/dist/reservations/types/user/get-id.d.ts +4 -0
  70. package/dist/reservations/types/user/get-id.js +1 -0
  71. package/dist/reservations/types/user/get-page.d.ts +7 -0
  72. package/dist/reservations/types/user/get-page.js +1 -0
  73. package/dist/reservations/types/user/reserve-onmenu.d.ts +13 -0
  74. package/dist/reservations/types/user/reserve-onmenu.js +1 -0
  75. package/dist/reservations/user-apis.d.ts +10 -0
  76. package/dist/reservations/user-apis.js +170 -0
  77. package/dist/sitemap/apis.d.ts +3 -0
  78. package/dist/sitemap/apis.js +58 -0
  79. package/dist/types.d.ts +4 -0
  80. package/dist/types.js +1 -0
  81. package/dist/utils/date-utils.d.ts +29 -0
  82. package/dist/utils/date-utils.js +101 -0
  83. package/dist/utils/menu-utils.d.ts +10 -0
  84. package/dist/utils/menu-utils.js +76 -0
  85. package/package.json +20 -3
@@ -0,0 +1,6 @@
1
+ import { AllBusiness } from "./types/get-all";
2
+ import { Business } from "./types/get-id";
3
+ export declare class BusinessAPIs {
4
+ static getAll(timestamp: number, page?: number, size?: number): Promise<AllBusiness[]>;
5
+ static get(identifier: string): Promise<Business | undefined>;
6
+ }
@@ -0,0 +1,82 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ var __generator = (this && this.__generator) || function (thisArg, body) {
11
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
12
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
13
+ function verb(n) { return function (v) { return step([n, v]); }; }
14
+ function step(op) {
15
+ if (f) throw new TypeError("Generator is already executing.");
16
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
17
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
18
+ if (y = 0, t) op = [op[0] & 2, t.value];
19
+ switch (op[0]) {
20
+ case 0: case 1: t = op; break;
21
+ case 4: _.label++; return { value: op[1], done: false };
22
+ case 5: _.label++; y = op[1]; op = [0]; continue;
23
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
24
+ default:
25
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
26
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
27
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
28
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
29
+ if (t[2]) _.ops.pop();
30
+ _.trys.pop(); continue;
31
+ }
32
+ op = body.call(thisArg, _);
33
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
34
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
35
+ }
36
+ };
37
+ import axios from "axios";
38
+ import { base } from "../constants";
39
+ // business module APIs
40
+ var BusinessAPIs = /** @class */ (function () {
41
+ function BusinessAPIs() {
42
+ }
43
+ BusinessAPIs.getAll = function (timestamp, page, size) {
44
+ if (page === void 0) { page = 1; }
45
+ if (size === void 0) { size = 12; }
46
+ return __awaiter(this, void 0, void 0, function () {
47
+ var response;
48
+ return __generator(this, function (_a) {
49
+ switch (_a.label) {
50
+ case 0: return [4 /*yield*/, axios.get(base + "/business?timestamp=".concat(timestamp, "&page=").concat(page, "&size=").concat(size))];
51
+ case 1:
52
+ response = _a.sent();
53
+ return [2 /*return*/, response.data];
54
+ }
55
+ });
56
+ });
57
+ };
58
+ BusinessAPIs.get = function (identifier) {
59
+ return __awaiter(this, void 0, void 0, function () {
60
+ var _a;
61
+ return __generator(this, function (_b) {
62
+ switch (_b.label) {
63
+ case 0:
64
+ _b.trys.push([0, 2, , 3]);
65
+ return [4 /*yield*/, axios.get(base + "/business/".concat(identifier))
66
+ .then(function (response) {
67
+ var data = response.data;
68
+ data.createdAt = new Date(data.createdAt);
69
+ return data;
70
+ })];
71
+ case 1: return [2 /*return*/, _b.sent()];
72
+ case 2:
73
+ _a = _b.sent();
74
+ throw new Error("internal_error");
75
+ case 3: return [2 /*return*/];
76
+ }
77
+ });
78
+ });
79
+ };
80
+ return BusinessAPIs;
81
+ }());
82
+ export { BusinessAPIs };
@@ -0,0 +1,2 @@
1
+ import { AllBusiness } from "../types";
2
+ export declare function getAllBusiness(timestamp: number, page?: number, size?: number): Promise<AllBusiness[]>;
@@ -0,0 +1,58 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ var __generator = (this && this.__generator) || function (thisArg, body) {
11
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
12
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
13
+ function verb(n) { return function (v) { return step([n, v]); }; }
14
+ function step(op) {
15
+ if (f) throw new TypeError("Generator is already executing.");
16
+ while (_) try {
17
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
18
+ if (y = 0, t) op = [op[0] & 2, t.value];
19
+ switch (op[0]) {
20
+ case 0: case 1: t = op; break;
21
+ case 4: _.label++; return { value: op[1], done: false };
22
+ case 5: _.label++; y = op[1]; op = [0]; continue;
23
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
24
+ default:
25
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
26
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
27
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
28
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
29
+ if (t[2]) _.ops.pop();
30
+ _.trys.pop(); continue;
31
+ }
32
+ op = body.call(thisArg, _);
33
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
34
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
35
+ }
36
+ };
37
+ import { API_CACHE_TIMOUT, base } from "../../../contants";
38
+ export function getAllBusiness(timestamp, page, size) {
39
+ if (page === void 0) { page = 1; }
40
+ if (size === void 0) { size = 12; }
41
+ return __awaiter(this, void 0, void 0, function () {
42
+ var response;
43
+ return __generator(this, function (_a) {
44
+ switch (_a.label) {
45
+ case 0: return [4 /*yield*/, fetch(base + "/business?timestamp=".concat(timestamp, "&page=").concat(page, "&size=").concat(size), { next: { revalidate: API_CACHE_TIMOUT } })];
46
+ case 1:
47
+ response = _a.sent();
48
+ // Recommendation: handle errors
49
+ if (!response.ok) {
50
+ // This will activate the closest `error.js` Error Boundary
51
+ throw new Error('Failed to fetch all business');
52
+ }
53
+ return [4 /*yield*/, response.json()];
54
+ case 2: return [2 /*return*/, _a.sent()];
55
+ }
56
+ });
57
+ });
58
+ }
@@ -0,0 +1,2 @@
1
+ import { AllBusiness } from "./types";
2
+ export declare function getAllBusiness(timestamp: number, page?: number, size?: number): Promise<AllBusiness[]>;
@@ -0,0 +1,53 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ var __generator = (this && this.__generator) || function (thisArg, body) {
11
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
12
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
13
+ function verb(n) { return function (v) { return step([n, v]); }; }
14
+ function step(op) {
15
+ if (f) throw new TypeError("Generator is already executing.");
16
+ while (_) try {
17
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
18
+ if (y = 0, t) op = [op[0] & 2, t.value];
19
+ switch (op[0]) {
20
+ case 0: case 1: t = op; break;
21
+ case 4: _.label++; return { value: op[1], done: false };
22
+ case 5: _.label++; y = op[1]; op = [0]; continue;
23
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
24
+ default:
25
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
26
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
27
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
28
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
29
+ if (t[2]) _.ops.pop();
30
+ _.trys.pop(); continue;
31
+ }
32
+ op = body.call(thisArg, _);
33
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
34
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
35
+ }
36
+ };
37
+ import axios from "axios";
38
+ import { base } from "../../contants";
39
+ export function getAllBusiness(timestamp, page, size) {
40
+ if (page === void 0) { page = 1; }
41
+ if (size === void 0) { size = 12; }
42
+ return __awaiter(this, void 0, void 0, function () {
43
+ var response;
44
+ return __generator(this, function (_a) {
45
+ switch (_a.label) {
46
+ case 0: return [4 /*yield*/, axios.get(base + "/business?timestamp=".concat(timestamp, "&page=").concat(page, "&size=").concat(size))];
47
+ case 1:
48
+ response = _a.sent();
49
+ return [2 /*return*/, response.data];
50
+ }
51
+ });
52
+ });
53
+ }
@@ -0,0 +1,7 @@
1
+ import { AllBusiness } from "../types";
2
+ export declare function getAllBusiness(timestamp: number, page?: number, size?: number): Promise<AllBusiness[]>;
3
+ export declare function useGetAllBusiness(timestamp: number, index: number, size: number): {
4
+ data: AllBusiness[];
5
+ error: any;
6
+ isLoading: boolean;
7
+ };
@@ -0,0 +1,64 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ var __generator = (this && this.__generator) || function (thisArg, body) {
11
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
12
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
13
+ function verb(n) { return function (v) { return step([n, v]); }; }
14
+ function step(op) {
15
+ if (f) throw new TypeError("Generator is already executing.");
16
+ while (_) try {
17
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
18
+ if (y = 0, t) op = [op[0] & 2, t.value];
19
+ switch (op[0]) {
20
+ case 0: case 1: t = op; break;
21
+ case 4: _.label++; return { value: op[1], done: false };
22
+ case 5: _.label++; y = op[1]; op = [0]; continue;
23
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
24
+ default:
25
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
26
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
27
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
28
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
29
+ if (t[2]) _.ops.pop();
30
+ _.trys.pop(); continue;
31
+ }
32
+ op = body.call(thisArg, _);
33
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
34
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
35
+ }
36
+ };
37
+ import axios from "../../../../node_modules/axios/index";
38
+ import useSWR from "../../../../node_modules/swr/core/dist/index";
39
+ import { base } from "../../../contants";
40
+ export function getAllBusiness(timestamp, page, size) {
41
+ if (page === void 0) { page = 1; }
42
+ if (size === void 0) { size = 12; }
43
+ return __awaiter(this, void 0, void 0, function () {
44
+ var response;
45
+ return __generator(this, function (_a) {
46
+ switch (_a.label) {
47
+ case 0: return [4 /*yield*/, axios.get(base + "/business?timestamp=".concat(timestamp, "&page=").concat(page, "&size=").concat(size))];
48
+ case 1:
49
+ response = _a.sent();
50
+ return [2 /*return*/, response.data];
51
+ }
52
+ });
53
+ });
54
+ }
55
+ export function useGetAllBusiness(timestamp, index, size) {
56
+ var _a = useSWR("/swr/business?page=".concat(index, "&size=").concat(size, "&timestamp=").concat(timestamp), function () { return getAllBusiness(timestamp, index, size); }, {
57
+ revalidateOnFocus: false
58
+ }), data = _a.data, error = _a.error, isLoading = _a.isLoading;
59
+ return {
60
+ data: data,
61
+ error: error,
62
+ isLoading: isLoading
63
+ };
64
+ }
@@ -0,0 +1,13 @@
1
+ export interface Review {
2
+ stars: number;
3
+ count: number;
4
+ link?: string;
5
+ }
6
+ export interface AllBusiness {
7
+ id: string;
8
+ identifier: string;
9
+ name: string;
10
+ address: string;
11
+ review: Review;
12
+ images: string[];
13
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,13 @@
1
+ export interface Review {
2
+ stars: number;
3
+ count: number;
4
+ link?: string;
5
+ }
6
+ export interface AllBusiness {
7
+ id: string;
8
+ identifier: string;
9
+ name: string;
10
+ address: string;
11
+ review: Review;
12
+ images: string[];
13
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,28 @@
1
+ export interface GoogleMap {
2
+ link: string;
3
+ image: string;
4
+ }
5
+ export interface Review {
6
+ stars: number;
7
+ count: number;
8
+ link?: string;
9
+ }
10
+ export interface SocialNetworks {
11
+ facebook?: string;
12
+ instagram?: string;
13
+ twitter?: string;
14
+ }
15
+ export interface Business {
16
+ id: string;
17
+ identifier: string;
18
+ name: string;
19
+ createdAt: Date;
20
+ address: string;
21
+ googleMap?: GoogleMap;
22
+ review: Review;
23
+ phones: string[];
24
+ socialNetworks?: SocialNetworks;
25
+ images: string[];
26
+ email?: string;
27
+ description?: string;
28
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,2 @@
1
+ export declare const base: string | undefined;
2
+ export declare const API_CACHE_TIMOUT: number;
@@ -0,0 +1,3 @@
1
+ //https://beta.nextjs.org/docs/api-reference/segment-config#fetchcache
2
+ export var base = process.env.NEXT_PUBLIC_BACKEND_URL;
3
+ export var API_CACHE_TIMOUT = Number(process.env.API_CACHE_TIMOUT);
@@ -0,0 +1,2 @@
1
+ export declare const base: string | undefined;
2
+ export declare const API_CACHE_TIMOUT: number;
@@ -0,0 +1,3 @@
1
+ //https://beta.nextjs.org/docs/api-reference/segment-config#fetchcache
2
+ export var base = process.env.NEXT_PUBLIC_BACKEND_URL;
3
+ export var API_CACHE_TIMOUT = Number(process.env.API_CACHE_TIMOUT);
@@ -0,0 +1,7 @@
1
+ import { Deal } from "./types/get-id";
2
+ import { Deal as DealPage } from "./types/get-pages";
3
+ import { GetPage } from "./types/get-pages";
4
+ export declare class DealsAPIs {
5
+ static getPage({ timestamp, page, size, tags, businessId }: GetPage): Promise<DealPage[]>;
6
+ static get(identifier: string): Promise<Deal | undefined>;
7
+ }
@@ -0,0 +1,96 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ var __generator = (this && this.__generator) || function (thisArg, body) {
11
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
12
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
13
+ function verb(n) { return function (v) { return step([n, v]); }; }
14
+ function step(op) {
15
+ if (f) throw new TypeError("Generator is already executing.");
16
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
17
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
18
+ if (y = 0, t) op = [op[0] & 2, t.value];
19
+ switch (op[0]) {
20
+ case 0: case 1: t = op; break;
21
+ case 4: _.label++; return { value: op[1], done: false };
22
+ case 5: _.label++; y = op[1]; op = [0]; continue;
23
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
24
+ default:
25
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
26
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
27
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
28
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
29
+ if (t[2]) _.ops.pop();
30
+ _.trys.pop(); continue;
31
+ }
32
+ op = body.call(thisArg, _);
33
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
34
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
35
+ }
36
+ };
37
+ import axios from "axios";
38
+ import { base } from "../constants";
39
+ // deals module APIs
40
+ var DealsAPIs = /** @class */ (function () {
41
+ function DealsAPIs() {
42
+ }
43
+ DealsAPIs.getPage = function (_a) {
44
+ var timestamp = _a.timestamp, _b = _a.page, page = _b === void 0 ? 1 : _b, _c = _a.size, size = _c === void 0 ? 12 : _c, _d = _a.tags, tags = _d === void 0 ? [] : _d, businessId = _a.businessId;
45
+ return __awaiter(this, void 0, void 0, function () {
46
+ var queryParams;
47
+ return __generator(this, function (_e) {
48
+ switch (_e.label) {
49
+ case 0:
50
+ queryParams = [
51
+ "timestamp=".concat(timestamp),
52
+ "page=".concat(page),
53
+ "size=".concat(size),
54
+ ((tags === null || tags === void 0 ? void 0 : tags.length) > 0) ? "tags=".concat(tags.join(',')) : undefined,
55
+ businessId ? "business=".concat(businessId) : undefined
56
+ ]
57
+ .filter(function (value) { return value; })
58
+ .join("&");
59
+ return [4 /*yield*/, axios.get(base + "/deals?".concat(queryParams))
60
+ .then(function (response) { return response.data; })
61
+ .catch(function (error) {
62
+ throw new Error('internal_error', error);
63
+ })];
64
+ case 1: return [2 /*return*/, _e.sent()];
65
+ }
66
+ });
67
+ });
68
+ };
69
+ DealsAPIs.get = function (identifier) {
70
+ return __awaiter(this, void 0, void 0, function () {
71
+ return __generator(this, function (_a) {
72
+ switch (_a.label) {
73
+ case 0: return [4 /*yield*/, axios.get(base + "/deals/".concat(identifier))
74
+ .then(function (response) {
75
+ var data = response.data;
76
+ data.startAt = new Date(data.startAt);
77
+ data.endAt = new Date(data.endAt);
78
+ data.createdAt = new Date(data.createdAt);
79
+ return data;
80
+ })
81
+ .catch(function (error) {
82
+ // not fount
83
+ if (error.response.status == 404) {
84
+ return (undefined);
85
+ }
86
+ else
87
+ throw new Error('internal_error', error);
88
+ })];
89
+ case 1: return [2 /*return*/, _a.sent()];
90
+ }
91
+ });
92
+ });
93
+ };
94
+ return DealsAPIs;
95
+ }());
96
+ export { DealsAPIs };
@@ -0,0 +1,49 @@
1
+ export interface Price {
2
+ reduced: number;
3
+ current: number;
4
+ weekend: number;
5
+ }
6
+ export interface Review {
7
+ stars: number;
8
+ count: number;
9
+ link?: string;
10
+ }
11
+ export interface SocialNetworks {
12
+ facebook?: string;
13
+ instagram?: string;
14
+ twitter?: string;
15
+ }
16
+ export interface GoogleMap {
17
+ link: string;
18
+ image: string;
19
+ }
20
+ export interface Business {
21
+ id: string;
22
+ identifier: string;
23
+ name: string;
24
+ createdAt: string;
25
+ address: string;
26
+ googleMap?: GoogleMap;
27
+ review: Review;
28
+ phones: string[];
29
+ socialNetworks?: SocialNetworks;
30
+ images: string[];
31
+ }
32
+ export interface Deal {
33
+ id: string;
34
+ identifier: string;
35
+ title: string;
36
+ images: string[];
37
+ adultPrice: Price;
38
+ childPrice: Price;
39
+ createdAt: Date;
40
+ startAt: Date;
41
+ endAt: Date;
42
+ isExpired: boolean;
43
+ discount: number;
44
+ maxGuests: number;
45
+ minBookingAmount: number;
46
+ maxCoupons: number;
47
+ aboutSection: string;
48
+ business: Business;
49
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,40 @@
1
+ export interface Price {
2
+ reduced: number;
3
+ current: number;
4
+ weekend: number;
5
+ }
6
+ export interface Review {
7
+ stars: number;
8
+ count: number;
9
+ link?: string;
10
+ }
11
+ export interface Business {
12
+ id: string;
13
+ identifier: string;
14
+ name: string;
15
+ createdAt: Date;
16
+ address: string;
17
+ images: string[];
18
+ review?: Review;
19
+ }
20
+ export interface Deal {
21
+ id: string;
22
+ identifier: string;
23
+ title: string;
24
+ images: string[];
25
+ adultPrice: Price;
26
+ childPrice: Price;
27
+ createdAt: Date;
28
+ startAt: Date;
29
+ endAt: Date;
30
+ isExpired: boolean;
31
+ discount: number;
32
+ business: Business;
33
+ }
34
+ export type GetPage = {
35
+ timestamp: number;
36
+ page?: number;
37
+ size?: number;
38
+ tags?: string[];
39
+ businessId?: string;
40
+ };
@@ -0,0 +1 @@
1
+ export {};
package/dist/enum.d.ts ADDED
@@ -0,0 +1,15 @@
1
+ export declare enum ReservationStatus {
2
+ Pending = "pending",
3
+ Confirmed = "confirmed",
4
+ Missed = "missed",
5
+ CanceledUser = "canceled_user",
6
+ CanceledBusiness = "canceled_business"
7
+ }
8
+ export declare enum DealKind {
9
+ Discount = "discount",
10
+ Cashback = "cashback"
11
+ }
12
+ export declare enum TimelineDirection {
13
+ Past = "past",
14
+ Next = "next"
15
+ }
package/dist/enum.js ADDED
@@ -0,0 +1,18 @@
1
+ export var ReservationStatus;
2
+ (function (ReservationStatus) {
3
+ ReservationStatus["Pending"] = "pending";
4
+ ReservationStatus["Confirmed"] = "confirmed";
5
+ ReservationStatus["Missed"] = "missed";
6
+ ReservationStatus["CanceledUser"] = "canceled_user";
7
+ ReservationStatus["CanceledBusiness"] = "canceled_business";
8
+ })(ReservationStatus || (ReservationStatus = {}));
9
+ export var DealKind;
10
+ (function (DealKind) {
11
+ DealKind["Discount"] = "discount";
12
+ DealKind["Cashback"] = "cashback";
13
+ })(DealKind || (DealKind = {}));
14
+ export var TimelineDirection;
15
+ (function (TimelineDirection) {
16
+ TimelineDirection["Past"] = "past";
17
+ TimelineDirection["Next"] = "next";
18
+ })(TimelineDirection || (TimelineDirection = {}));
@@ -0,0 +1,4 @@
1
+ import { Response } from "./types/business-signin";
2
+ export declare class IamAdminAPIs {
3
+ static signIn(identifier: string, password: string): Promise<Response>;
4
+ }