@clyrex-digital/clyrex-controls-dev 0.8.1-dev.20260722101954
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/CopyButton-UPJPMJUB.mjs +57 -0
- package/dist/CopyButton-XONTQQW7.mjs +55 -0
- package/dist/DateTimeViewClient-22GW4AD7.mjs +14 -0
- package/dist/DateTimeViewClient-K5FE5VSN.mjs +14 -0
- package/dist/DateTimeViewClient-M7V35KUW.mjs +16 -0
- package/dist/DateTimeViewClient-R3M6ISVK.mjs +16 -0
- package/dist/DateViewClient-4CTEMOMJ.mjs +7 -0
- package/dist/DateViewClient-ELEHLGWS.mjs +7 -0
- package/dist/DateViewClient-JBS5UXMD.mjs +9 -0
- package/dist/DateViewClient-VLTRN47D.mjs +9 -0
- package/dist/EnterAnimationClient-4OKXLKSA.mjs +45 -0
- package/dist/EnterAnimationClient-ZN3NLFNO.mjs +47 -0
- package/dist/HlsPlayer-57543DTW.mjs +599 -0
- package/dist/HlsPlayer-5AWFZ2P6.mjs +601 -0
- package/dist/IframeClient-J22NMEVY.mjs +96 -0
- package/dist/IframeClient-RGJFZ5P2.mjs +98 -0
- package/dist/InputControlClient-7NS4QUWO.mjs +677 -0
- package/dist/InputControlClient-AZRPSTUZ.mjs +677 -0
- package/dist/InputControlClient-BUOYZNWQ.mjs +675 -0
- package/dist/InputControlClient-HIZOJLKW.mjs +677 -0
- package/dist/LinkNodeButton-AOEDCCL7.mjs +227 -0
- package/dist/LinkNodeButton-BIZA2NPE.mjs +225 -0
- package/dist/LinkNodeButton-LX3KKGZY.mjs +173 -0
- package/dist/LinkNodeButton-U7T2NP22.mjs +374 -0
- package/dist/Pagination-6OFACRMQ.mjs +229 -0
- package/dist/Pagination-NCJCOYHF.mjs +181 -0
- package/dist/Pagination-OQT7Q2XO.mjs +183 -0
- package/dist/Pagination-T7YN2OMV.mjs +183 -0
- package/dist/Slider-554BKC7N.mjs +322 -0
- package/dist/Slider-PEIVH6A5.mjs +320 -0
- package/dist/chunk-23WJE3YB.mjs +253 -0
- package/dist/chunk-3GWLDT7C.mjs +204 -0
- package/dist/chunk-3R4VVVNK.mjs +903 -0
- package/dist/chunk-56HSDML5.mjs +22 -0
- package/dist/chunk-5GHPW7SJ.mjs +111 -0
- package/dist/chunk-7ZFZLN56.mjs +903 -0
- package/dist/chunk-DBHUCH4B.mjs +109 -0
- package/dist/chunk-DKW4DXCU.mjs +120 -0
- package/dist/chunk-FI2KJBK2.mjs +110 -0
- package/dist/chunk-IMNQO57B.mjs +25 -0
- package/dist/chunk-JKP4XOZB.mjs +214 -0
- package/dist/chunk-OGGIS4AN.mjs +201 -0
- package/dist/chunk-RHVNJMS4.mjs +251 -0
- package/dist/chunk-SPRVN5IM.mjs +118 -0
- package/dist/chunk-TVL6KVD5.mjs +229 -0
- package/dist/chunk-UFKPTMM7.mjs +199 -0
- package/dist/chunk-WEV5U33G.mjs +207 -0
- package/dist/chunk-X3YSXTD2.mjs +201 -0
- package/dist/chunk-XG6SXZWP.mjs +115 -0
- package/dist/chunk-YBNWT4TV.mjs +123 -0
- package/dist/chunk-YG6FKKQJ.mjs +900 -0
- package/dist/index.d.mts +456 -0
- package/dist/index.d.ts +456 -0
- package/dist/index.js +8566 -0
- package/dist/index.mjs +4285 -0
- package/dist/server.d.mts +113 -0
- package/dist/server.d.ts +113 -0
- package/dist/server.js +5179 -0
- package/dist/server.mjs +2736 -0
- package/package.json +95 -0
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
import {
|
|
2
|
+
buttonClasses
|
|
3
|
+
} from "./chunk-56HSDML5.mjs";
|
|
4
|
+
|
|
5
|
+
// src/components/dataForm/Hyperlink.tsx
|
|
6
|
+
import Link from "next/link";
|
|
7
|
+
import { Fragment, jsx } from "react/jsx-runtime";
|
|
8
|
+
function Hyperlink(props) {
|
|
9
|
+
let linkClass = props.linkType ? buttonClasses.get(props.linkType) : buttonClasses.get("Link" /* Link */);
|
|
10
|
+
const target = props?.href?.startsWith("http") ? "_blank" : "_self";
|
|
11
|
+
const additionalProps = {};
|
|
12
|
+
if (target == "_blank") {
|
|
13
|
+
additionalProps.rel = "noopener noreferrer";
|
|
14
|
+
}
|
|
15
|
+
return /* @__PURE__ */ jsx(Fragment, { children: props.href ? /* @__PURE__ */ jsx(
|
|
16
|
+
Link,
|
|
17
|
+
{
|
|
18
|
+
href: props.href,
|
|
19
|
+
prefetch: false,
|
|
20
|
+
className: [linkClass, props.className].filter(Boolean).join(" "),
|
|
21
|
+
...additionalProps,
|
|
22
|
+
target,
|
|
23
|
+
children: props.children
|
|
24
|
+
}
|
|
25
|
+
) : props.isHeading ? /* @__PURE__ */ jsx("h5", { className: props.className + "inline-block", children: props.children }) : /* @__PURE__ */ jsx("span", { className: props.className, children: props.children }) });
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// src/components/controls/edit/InputControlType.tsx
|
|
29
|
+
var Constants = {
|
|
30
|
+
pagesize: 10
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
// src/clients/OdataBuilder.tsx
|
|
34
|
+
var OdataBuilder = class {
|
|
35
|
+
constructor(url) {
|
|
36
|
+
this.baseUrl = url;
|
|
37
|
+
this.top = Constants.pagesize.toString();
|
|
38
|
+
this.skip = "0";
|
|
39
|
+
this.keyword = "";
|
|
40
|
+
this.filterBy = "";
|
|
41
|
+
this.orderBy = "";
|
|
42
|
+
}
|
|
43
|
+
// parseSearchParams(ReadonlyUrlSearchParams): DataQuery {
|
|
44
|
+
// this.top = top;
|
|
45
|
+
// return this;
|
|
46
|
+
// }
|
|
47
|
+
setQuery(odata) {
|
|
48
|
+
if (odata) {
|
|
49
|
+
for (const key in odata) {
|
|
50
|
+
if (odata[key] != null && odata[key] != "") {
|
|
51
|
+
if (key == "$skip") {
|
|
52
|
+
this.setSkip(odata[key]);
|
|
53
|
+
}
|
|
54
|
+
if (key == "$filter") {
|
|
55
|
+
this.setFilter(odata[key]);
|
|
56
|
+
}
|
|
57
|
+
if (key == "$top") {
|
|
58
|
+
this.setTop(odata[key]);
|
|
59
|
+
}
|
|
60
|
+
if (key == "$orderby") {
|
|
61
|
+
this.setOrderBy(odata[key]);
|
|
62
|
+
}
|
|
63
|
+
if (key == "searchTerm") {
|
|
64
|
+
this.searchTerm = odata[key];
|
|
65
|
+
}
|
|
66
|
+
if (key == "searchCols") {
|
|
67
|
+
this.searchCols = odata[key];
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
return this;
|
|
73
|
+
}
|
|
74
|
+
// parseKeyValuePairs(inputString: string): { [key: string]: string } {
|
|
75
|
+
// return inputString.split('$')
|
|
76
|
+
// .map((pair) => pair.split('='))
|
|
77
|
+
// .reduce((result: { [key: string]: string }, [key, value]) => {
|
|
78
|
+
// if (key && value) {
|
|
79
|
+
// result[key.trim()] = value.trim();
|
|
80
|
+
// }
|
|
81
|
+
// return result;
|
|
82
|
+
// }, {});
|
|
83
|
+
// }
|
|
84
|
+
static getOdataQueryString(obj, defaultOrder) {
|
|
85
|
+
let queryString = "";
|
|
86
|
+
let skip = (obj && obj["$skip"]) ?? "0";
|
|
87
|
+
let top = (obj && obj["$top"]) ?? Constants.pagesize.toString();
|
|
88
|
+
queryString = `$skip=${skip}&$top=${top}&$count=true`;
|
|
89
|
+
if (obj?.["searchTerm"] && obj["searchTerm"].trim() !== "") {
|
|
90
|
+
queryString += `&searchTerm=${encodeURIComponent(obj["searchTerm"])}`;
|
|
91
|
+
}
|
|
92
|
+
if (obj?.["searchCols"] && obj["searchCols"].trim() !== "") {
|
|
93
|
+
queryString += `&searchCols=${encodeURIComponent(obj["searchCols"])}`;
|
|
94
|
+
}
|
|
95
|
+
if (obj) {
|
|
96
|
+
if (obj["$filter"] && obj["$filter"] !== null && obj["$filter"] !== "") {
|
|
97
|
+
queryString = queryString + `&$filter=${encodeURIComponent(obj["$filter"])}`;
|
|
98
|
+
}
|
|
99
|
+
if (obj["$orderby"] && obj["$orderby"] !== null && obj["$orderby"] !== "") {
|
|
100
|
+
queryString = queryString + `&$orderby=${encodeURIComponent(obj["$orderby"])}`;
|
|
101
|
+
} else if (defaultOrder) {
|
|
102
|
+
queryString = queryString + `&$orderby=${encodeURIComponent(defaultOrder)}`;
|
|
103
|
+
}
|
|
104
|
+
} else {
|
|
105
|
+
if (defaultOrder) {
|
|
106
|
+
queryString = queryString + `&$orderby=${encodeURIComponent(defaultOrder)}`;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
return queryString;
|
|
110
|
+
}
|
|
111
|
+
setTop(top) {
|
|
112
|
+
this.top = top;
|
|
113
|
+
return this;
|
|
114
|
+
}
|
|
115
|
+
setSkip(skip) {
|
|
116
|
+
this.skip = skip;
|
|
117
|
+
return this;
|
|
118
|
+
}
|
|
119
|
+
setKeyword(keyword) {
|
|
120
|
+
this.keyword = keyword;
|
|
121
|
+
return this;
|
|
122
|
+
}
|
|
123
|
+
setFilter(filterBy) {
|
|
124
|
+
this.filterBy = filterBy;
|
|
125
|
+
return this;
|
|
126
|
+
}
|
|
127
|
+
setOrderBy(orderBy) {
|
|
128
|
+
this.orderBy = orderBy;
|
|
129
|
+
return this;
|
|
130
|
+
}
|
|
131
|
+
getPageNumber(pageSize) {
|
|
132
|
+
let pageNumber = 1;
|
|
133
|
+
if (this.skip && this.top) {
|
|
134
|
+
const skip = parseInt(this.skip);
|
|
135
|
+
const top = parseInt(this.top);
|
|
136
|
+
if (!isNaN(skip) && !isNaN(top)) {
|
|
137
|
+
pageNumber = skip / pageSize + 1;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
return pageNumber;
|
|
141
|
+
}
|
|
142
|
+
getUrl() {
|
|
143
|
+
let url = `${this.baseUrl}?$skip=${this.skip}&$top=${this.top}&$count=true`;
|
|
144
|
+
if (this.filterBy !== null && this.filterBy !== "") {
|
|
145
|
+
url = url + `&$filter=${encodeURIComponent(this.filterBy)}`;
|
|
146
|
+
}
|
|
147
|
+
if (this.orderBy !== null && this.orderBy !== "") {
|
|
148
|
+
url = url + `&$orderby=${encodeURIComponent(this.orderBy)}`;
|
|
149
|
+
}
|
|
150
|
+
if (this.searchTerm) {
|
|
151
|
+
url += `&searchTerm=${encodeURIComponent(this.searchTerm)}`;
|
|
152
|
+
}
|
|
153
|
+
if (this.searchCols) {
|
|
154
|
+
url += `&searchCols=${encodeURIComponent(this.searchCols)}`;
|
|
155
|
+
}
|
|
156
|
+
console.log(url);
|
|
157
|
+
return url;
|
|
158
|
+
}
|
|
159
|
+
getNewOrderByUrl(orderBy) {
|
|
160
|
+
let url = `${this.baseUrl}?$skip=${0}&$top=${this.top}&$count=true`;
|
|
161
|
+
if (this.filterBy !== null && this.filterBy !== "") {
|
|
162
|
+
url = url + `&$filter=${encodeURIComponent(this.filterBy)}`;
|
|
163
|
+
}
|
|
164
|
+
if (this.searchTerm) {
|
|
165
|
+
url += `&searchTerm=${encodeURIComponent(this.searchTerm)}`;
|
|
166
|
+
}
|
|
167
|
+
if (this.searchCols) {
|
|
168
|
+
url += `&searchCols=${encodeURIComponent(this.searchCols)}`;
|
|
169
|
+
}
|
|
170
|
+
url = url + `&$orderby=${encodeURIComponent(orderBy)}`;
|
|
171
|
+
return url;
|
|
172
|
+
}
|
|
173
|
+
getNewFilterUrl(filterBy) {
|
|
174
|
+
let url = `${this.baseUrl}?$skip=${0}&$top=${this.top}&$count=true`;
|
|
175
|
+
if (filterBy !== null && filterBy !== "") {
|
|
176
|
+
url = url + `&$filter=${encodeURIComponent(filterBy)}`;
|
|
177
|
+
}
|
|
178
|
+
if (this.orderBy !== null && this.orderBy !== "") {
|
|
179
|
+
url = url + `&$orderby=${encodeURIComponent(this.orderBy)}`;
|
|
180
|
+
}
|
|
181
|
+
if (this.searchTerm) {
|
|
182
|
+
url += `&searchTerm=${encodeURIComponent(this.searchTerm)}`;
|
|
183
|
+
}
|
|
184
|
+
if (this.searchCols) {
|
|
185
|
+
url += `&searchCols=${encodeURIComponent(this.searchCols)}`;
|
|
186
|
+
}
|
|
187
|
+
return url;
|
|
188
|
+
}
|
|
189
|
+
getNewPageUrl(page) {
|
|
190
|
+
let skip = page * Constants.pagesize - Constants.pagesize;
|
|
191
|
+
let url = `${this.baseUrl}?$skip=${skip}&$top=${this.top}&$count=true`;
|
|
192
|
+
if (this.filterBy !== null && this.filterBy !== "") {
|
|
193
|
+
url = url + `&$filter=${encodeURIComponent(this.filterBy)}`;
|
|
194
|
+
}
|
|
195
|
+
if (this.orderBy !== null && this.orderBy !== "") {
|
|
196
|
+
url = url + `&$orderby=${encodeURIComponent(this.orderBy)}`;
|
|
197
|
+
}
|
|
198
|
+
if (this.searchTerm) {
|
|
199
|
+
url += `&searchTerm=${encodeURIComponent(this.searchTerm)}`;
|
|
200
|
+
}
|
|
201
|
+
if (this.searchCols) {
|
|
202
|
+
url += `&searchCols=${encodeURIComponent(this.searchCols)}`;
|
|
203
|
+
}
|
|
204
|
+
return url;
|
|
205
|
+
}
|
|
206
|
+
getNewPageSizeUrl(pageSize) {
|
|
207
|
+
const currentPage = this.getPageNumber(
|
|
208
|
+
parseInt(this.top || Constants.pagesize.toString())
|
|
209
|
+
);
|
|
210
|
+
const skip = (currentPage - 1) * pageSize;
|
|
211
|
+
let url = `${this.baseUrl}?$skip=${skip}&$top=${pageSize}&$count=true`;
|
|
212
|
+
if (this.filterBy !== null && this.filterBy !== "") {
|
|
213
|
+
url = url + `&$filter=${encodeURIComponent(this.filterBy)}`;
|
|
214
|
+
}
|
|
215
|
+
if (this.orderBy !== null && this.orderBy !== "") {
|
|
216
|
+
url = url + `&$orderby=${encodeURIComponent(this.orderBy)}`;
|
|
217
|
+
}
|
|
218
|
+
return url;
|
|
219
|
+
}
|
|
220
|
+
getOrderBy() {
|
|
221
|
+
return this.orderBy;
|
|
222
|
+
}
|
|
223
|
+
};
|
|
224
|
+
|
|
225
|
+
export {
|
|
226
|
+
Hyperlink,
|
|
227
|
+
Constants,
|
|
228
|
+
OdataBuilder
|
|
229
|
+
};
|
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Constants
|
|
3
|
+
} from "./chunk-DBHUCH4B.mjs";
|
|
4
|
+
|
|
5
|
+
// src/clients/OdataBuilder.tsx
|
|
6
|
+
var OdataBuilder = class {
|
|
7
|
+
constructor(url) {
|
|
8
|
+
this.baseUrl = url;
|
|
9
|
+
this.top = Constants.pagesize.toString();
|
|
10
|
+
this.skip = "0";
|
|
11
|
+
this.keyword = "";
|
|
12
|
+
this.filterBy = "";
|
|
13
|
+
this.orderBy = "";
|
|
14
|
+
}
|
|
15
|
+
// parseSearchParams(ReadonlyUrlSearchParams): DataQuery {
|
|
16
|
+
// this.top = top;
|
|
17
|
+
// return this;
|
|
18
|
+
// }
|
|
19
|
+
setQuery(odata) {
|
|
20
|
+
if (odata) {
|
|
21
|
+
for (const key in odata) {
|
|
22
|
+
if (odata[key] != null && odata[key] != "") {
|
|
23
|
+
if (key == "$skip") {
|
|
24
|
+
this.setSkip(odata[key]);
|
|
25
|
+
}
|
|
26
|
+
if (key == "$filter") {
|
|
27
|
+
this.setFilter(odata[key]);
|
|
28
|
+
}
|
|
29
|
+
if (key == "$top") {
|
|
30
|
+
this.setTop(odata[key]);
|
|
31
|
+
}
|
|
32
|
+
if (key == "$orderby") {
|
|
33
|
+
this.setOrderBy(odata[key]);
|
|
34
|
+
}
|
|
35
|
+
if (key == "searchTerm") {
|
|
36
|
+
this.searchTerm = odata[key];
|
|
37
|
+
}
|
|
38
|
+
if (key == "searchCols") {
|
|
39
|
+
this.searchCols = odata[key];
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
return this;
|
|
45
|
+
}
|
|
46
|
+
// parseKeyValuePairs(inputString: string): { [key: string]: string } {
|
|
47
|
+
// return inputString.split('$')
|
|
48
|
+
// .map((pair) => pair.split('='))
|
|
49
|
+
// .reduce((result: { [key: string]: string }, [key, value]) => {
|
|
50
|
+
// if (key && value) {
|
|
51
|
+
// result[key.trim()] = value.trim();
|
|
52
|
+
// }
|
|
53
|
+
// return result;
|
|
54
|
+
// }, {});
|
|
55
|
+
// }
|
|
56
|
+
static getOdataQueryString(obj, defaultOrder) {
|
|
57
|
+
let queryString = "";
|
|
58
|
+
let skip = (obj && obj["$skip"]) ?? "0";
|
|
59
|
+
let top = (obj && obj["$top"]) ?? Constants.pagesize.toString();
|
|
60
|
+
queryString = `$skip=${skip}&$top=${top}&$count=true`;
|
|
61
|
+
if (obj?.["searchTerm"] && obj["searchTerm"].trim() !== "") {
|
|
62
|
+
queryString += `&searchTerm=${encodeURIComponent(obj["searchTerm"])}`;
|
|
63
|
+
}
|
|
64
|
+
if (obj?.["searchCols"] && obj["searchCols"].trim() !== "") {
|
|
65
|
+
queryString += `&searchCols=${encodeURIComponent(obj["searchCols"])}`;
|
|
66
|
+
}
|
|
67
|
+
if (obj) {
|
|
68
|
+
if (obj["$filter"] && obj["$filter"] !== null && obj["$filter"] !== "") {
|
|
69
|
+
queryString = queryString + `&$filter=${encodeURIComponent(obj["$filter"])}`;
|
|
70
|
+
}
|
|
71
|
+
if (obj["$orderby"] && obj["$orderby"] !== null && obj["$orderby"] !== "") {
|
|
72
|
+
queryString = queryString + `&$orderby=${encodeURIComponent(obj["$orderby"])}`;
|
|
73
|
+
} else if (defaultOrder) {
|
|
74
|
+
queryString = queryString + `&$orderby=${encodeURIComponent(defaultOrder)}`;
|
|
75
|
+
}
|
|
76
|
+
} else {
|
|
77
|
+
if (defaultOrder) {
|
|
78
|
+
queryString = queryString + `&$orderby=${encodeURIComponent(defaultOrder)}`;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
return queryString;
|
|
82
|
+
}
|
|
83
|
+
setTop(top) {
|
|
84
|
+
this.top = top;
|
|
85
|
+
return this;
|
|
86
|
+
}
|
|
87
|
+
setSkip(skip) {
|
|
88
|
+
this.skip = skip;
|
|
89
|
+
return this;
|
|
90
|
+
}
|
|
91
|
+
setKeyword(keyword) {
|
|
92
|
+
this.keyword = keyword;
|
|
93
|
+
return this;
|
|
94
|
+
}
|
|
95
|
+
setFilter(filterBy) {
|
|
96
|
+
this.filterBy = filterBy;
|
|
97
|
+
return this;
|
|
98
|
+
}
|
|
99
|
+
setOrderBy(orderBy) {
|
|
100
|
+
this.orderBy = orderBy;
|
|
101
|
+
return this;
|
|
102
|
+
}
|
|
103
|
+
getPageNumber(pageSize) {
|
|
104
|
+
let pageNumber = 1;
|
|
105
|
+
if (this.skip && this.top) {
|
|
106
|
+
const skip = parseInt(this.skip);
|
|
107
|
+
const top = parseInt(this.top);
|
|
108
|
+
if (!isNaN(skip) && !isNaN(top)) {
|
|
109
|
+
pageNumber = skip / pageSize + 1;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
return pageNumber;
|
|
113
|
+
}
|
|
114
|
+
getUrl() {
|
|
115
|
+
let url = `${this.baseUrl}?$skip=${this.skip}&$top=${this.top}&$count=true`;
|
|
116
|
+
if (this.filterBy !== null && this.filterBy !== "") {
|
|
117
|
+
url = url + `&$filter=${encodeURIComponent(this.filterBy)}`;
|
|
118
|
+
}
|
|
119
|
+
if (this.orderBy !== null && this.orderBy !== "") {
|
|
120
|
+
url = url + `&$orderby=${encodeURIComponent(this.orderBy)}`;
|
|
121
|
+
}
|
|
122
|
+
if (this.searchTerm) {
|
|
123
|
+
url += `&searchTerm=${encodeURIComponent(this.searchTerm)}`;
|
|
124
|
+
}
|
|
125
|
+
if (this.searchCols) {
|
|
126
|
+
url += `&searchCols=${encodeURIComponent(this.searchCols)}`;
|
|
127
|
+
}
|
|
128
|
+
console.log(url);
|
|
129
|
+
return url;
|
|
130
|
+
}
|
|
131
|
+
getNewOrderByUrl(orderBy) {
|
|
132
|
+
let url = `${this.baseUrl}?$skip=${0}&$top=${this.top}&$count=true`;
|
|
133
|
+
if (this.filterBy !== null && this.filterBy !== "") {
|
|
134
|
+
url = url + `&$filter=${encodeURIComponent(this.filterBy)}`;
|
|
135
|
+
}
|
|
136
|
+
if (this.searchTerm) {
|
|
137
|
+
url += `&searchTerm=${encodeURIComponent(this.searchTerm)}`;
|
|
138
|
+
}
|
|
139
|
+
if (this.searchCols) {
|
|
140
|
+
url += `&searchCols=${encodeURIComponent(this.searchCols)}`;
|
|
141
|
+
}
|
|
142
|
+
url = url + `&$orderby=${encodeURIComponent(orderBy)}`;
|
|
143
|
+
return url;
|
|
144
|
+
}
|
|
145
|
+
getNewFilterUrl(filterBy) {
|
|
146
|
+
let url = `${this.baseUrl}?$skip=${0}&$top=${this.top}&$count=true`;
|
|
147
|
+
if (filterBy !== null && filterBy !== "") {
|
|
148
|
+
url = url + `&$filter=${encodeURIComponent(filterBy)}`;
|
|
149
|
+
}
|
|
150
|
+
if (this.orderBy !== null && this.orderBy !== "") {
|
|
151
|
+
url = url + `&$orderby=${encodeURIComponent(this.orderBy)}`;
|
|
152
|
+
}
|
|
153
|
+
if (this.searchTerm) {
|
|
154
|
+
url += `&searchTerm=${encodeURIComponent(this.searchTerm)}`;
|
|
155
|
+
}
|
|
156
|
+
if (this.searchCols) {
|
|
157
|
+
url += `&searchCols=${encodeURIComponent(this.searchCols)}`;
|
|
158
|
+
}
|
|
159
|
+
return url;
|
|
160
|
+
}
|
|
161
|
+
getNewPageUrl(page) {
|
|
162
|
+
let skip = page * Constants.pagesize - Constants.pagesize;
|
|
163
|
+
let url = `${this.baseUrl}?$skip=${skip}&$top=${this.top}&$count=true`;
|
|
164
|
+
if (this.filterBy !== null && this.filterBy !== "") {
|
|
165
|
+
url = url + `&$filter=${encodeURIComponent(this.filterBy)}`;
|
|
166
|
+
}
|
|
167
|
+
if (this.orderBy !== null && this.orderBy !== "") {
|
|
168
|
+
url = url + `&$orderby=${encodeURIComponent(this.orderBy)}`;
|
|
169
|
+
}
|
|
170
|
+
if (this.searchTerm) {
|
|
171
|
+
url += `&searchTerm=${encodeURIComponent(this.searchTerm)}`;
|
|
172
|
+
}
|
|
173
|
+
if (this.searchCols) {
|
|
174
|
+
url += `&searchCols=${encodeURIComponent(this.searchCols)}`;
|
|
175
|
+
}
|
|
176
|
+
return url;
|
|
177
|
+
}
|
|
178
|
+
getNewPageSizeUrl(pageSize) {
|
|
179
|
+
const currentPage = this.getPageNumber(
|
|
180
|
+
parseInt(this.top || Constants.pagesize.toString())
|
|
181
|
+
);
|
|
182
|
+
const skip = (currentPage - 1) * pageSize;
|
|
183
|
+
let url = `${this.baseUrl}?$skip=${skip}&$top=${pageSize}&$count=true`;
|
|
184
|
+
if (this.filterBy !== null && this.filterBy !== "") {
|
|
185
|
+
url = url + `&$filter=${encodeURIComponent(this.filterBy)}`;
|
|
186
|
+
}
|
|
187
|
+
if (this.orderBy !== null && this.orderBy !== "") {
|
|
188
|
+
url = url + `&$orderby=${encodeURIComponent(this.orderBy)}`;
|
|
189
|
+
}
|
|
190
|
+
return url;
|
|
191
|
+
}
|
|
192
|
+
getOrderBy() {
|
|
193
|
+
return this.orderBy;
|
|
194
|
+
}
|
|
195
|
+
};
|
|
196
|
+
|
|
197
|
+
export {
|
|
198
|
+
OdataBuilder
|
|
199
|
+
};
|
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
// src/clients/CacheManage.tsx
|
|
5
|
+
import NodeCache from "node-cache";
|
|
6
|
+
var CacheManager = class _CacheManager {
|
|
7
|
+
constructor() {
|
|
8
|
+
this.maxCacheSize = 1e3;
|
|
9
|
+
this.cache = new NodeCache({ stdTTL: 0, checkperiod: 300 });
|
|
10
|
+
}
|
|
11
|
+
static getInstance() {
|
|
12
|
+
if (!_CacheManager.instance) {
|
|
13
|
+
_CacheManager.instance = new _CacheManager();
|
|
14
|
+
}
|
|
15
|
+
return _CacheManager.instance;
|
|
16
|
+
}
|
|
17
|
+
get(key) {
|
|
18
|
+
return null;
|
|
19
|
+
}
|
|
20
|
+
set(key, data, ttl) {
|
|
21
|
+
}
|
|
22
|
+
clear() {
|
|
23
|
+
this.cache.flushAll();
|
|
24
|
+
}
|
|
25
|
+
size() {
|
|
26
|
+
return this.cache.keys().length;
|
|
27
|
+
}
|
|
28
|
+
destroy() {
|
|
29
|
+
this.cache.close();
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
// src/clients/ServiceClient.tsx
|
|
34
|
+
var ServerApiError = class extends Error {
|
|
35
|
+
constructor(data, status) {
|
|
36
|
+
super(data.message || "---");
|
|
37
|
+
this.status = status;
|
|
38
|
+
this.data = data;
|
|
39
|
+
this.data.isSuccessful = false;
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
var ServiceClient = class {
|
|
43
|
+
constructor(apiBaseUrl, session) {
|
|
44
|
+
this.cacheManager = CacheManager.getInstance();
|
|
45
|
+
this.baseUrl = apiBaseUrl;
|
|
46
|
+
this.session = session;
|
|
47
|
+
}
|
|
48
|
+
buildFullPath(path, params) {
|
|
49
|
+
let updatedPath = path;
|
|
50
|
+
if (params) {
|
|
51
|
+
Object.keys(params).forEach((key) => {
|
|
52
|
+
updatedPath = updatedPath.replace(
|
|
53
|
+
`{${key}}`,
|
|
54
|
+
String(params[key])
|
|
55
|
+
);
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
return this.baseUrl + updatedPath;
|
|
59
|
+
}
|
|
60
|
+
getConfig() {
|
|
61
|
+
const config = { headers: {} };
|
|
62
|
+
if (this.session) {
|
|
63
|
+
if (this.session.oAuthToken) {
|
|
64
|
+
config.headers["Authorization"] = "Bearer " + this.session.oAuthToken;
|
|
65
|
+
}
|
|
66
|
+
config.headers["cid"] = this.session.cid || "";
|
|
67
|
+
config.headers["UserCurrencyCode"] = this.session.userCurrencyCode || "INR";
|
|
68
|
+
config.headers["MarketCode"] = this.session?.marketCode || "IND";
|
|
69
|
+
}
|
|
70
|
+
return config;
|
|
71
|
+
}
|
|
72
|
+
handleFetchError(error) {
|
|
73
|
+
console.log(error);
|
|
74
|
+
return {
|
|
75
|
+
message: error.message || "There is some error. Please try after sometime.",
|
|
76
|
+
isSuccessful: false
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
async fetchJsonWithCache(fullPath, config) {
|
|
80
|
+
const cacheKey = fullPath + "--" + (this.session?.marketCode || "IND");
|
|
81
|
+
const cachedData = this.cacheManager.get(cacheKey);
|
|
82
|
+
if (cachedData) {
|
|
83
|
+
return cachedData;
|
|
84
|
+
}
|
|
85
|
+
console.log("*****************CALLING API:", cacheKey, (/* @__PURE__ */ new Date()).toISOString());
|
|
86
|
+
const response = await fetch(fullPath, { headers: config.headers });
|
|
87
|
+
if (!response.ok) {
|
|
88
|
+
const apiErrorData = await response.json();
|
|
89
|
+
throw new ServerApiError(apiErrorData, response.status);
|
|
90
|
+
}
|
|
91
|
+
const cacheControl = response.headers.get("Cache-Control");
|
|
92
|
+
let revalidate = null;
|
|
93
|
+
if (cacheControl) {
|
|
94
|
+
const maxAgeMatch = cacheControl.match(/max-age=(\d+)/);
|
|
95
|
+
if (maxAgeMatch && maxAgeMatch[1]) {
|
|
96
|
+
const maxAge = parseInt(maxAgeMatch[1], 10);
|
|
97
|
+
revalidate = maxAge * 1e3;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
const data = await response.json();
|
|
101
|
+
data.isSuccessful = true;
|
|
102
|
+
if (revalidate !== null && revalidate > 0) {
|
|
103
|
+
console.log("revalidate............I am caching:" + revalidate);
|
|
104
|
+
this.cacheManager.set(cacheKey, data, revalidate);
|
|
105
|
+
}
|
|
106
|
+
return data;
|
|
107
|
+
}
|
|
108
|
+
// private async refreshToken(): Promise<void> {
|
|
109
|
+
// console.log("*******************calling refresh token***********************");
|
|
110
|
+
// try {
|
|
111
|
+
// const response = await fetch(this.baseUrl + "/auth/storefront/login/refreshToken", {
|
|
112
|
+
// method: 'POST',
|
|
113
|
+
// headers: {
|
|
114
|
+
// 'Content-Type': 'application/json'
|
|
115
|
+
// },
|
|
116
|
+
// body: JSON.stringify({ refreshToken: this.session.refreshToken })
|
|
117
|
+
// });
|
|
118
|
+
// if (!response.ok) {
|
|
119
|
+
// throw new Error("Failed to refresh token");
|
|
120
|
+
// }
|
|
121
|
+
// const responseData = await response.json();
|
|
122
|
+
// this.session.oAuthToken = responseData.result.accessToken;
|
|
123
|
+
// if (typeof window === "undefined") {
|
|
124
|
+
// // Running on the server
|
|
125
|
+
// } else {
|
|
126
|
+
// await fetch("/api/login", {
|
|
127
|
+
// method: "post",
|
|
128
|
+
// headers: {
|
|
129
|
+
// "Content-Type": "application/json",
|
|
130
|
+
// },
|
|
131
|
+
// body: JSON.stringify({ session: this.session }),
|
|
132
|
+
// });
|
|
133
|
+
// }
|
|
134
|
+
// } catch (error: any) {
|
|
135
|
+
// throw new Error("Failed to refresh token");
|
|
136
|
+
// }
|
|
137
|
+
// }
|
|
138
|
+
async handleRequest(request) {
|
|
139
|
+
try {
|
|
140
|
+
return await request();
|
|
141
|
+
} catch (error) {
|
|
142
|
+
throw error;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
async post(path, data) {
|
|
146
|
+
const request = async () => {
|
|
147
|
+
const fullPath = this.baseUrl + path;
|
|
148
|
+
const config = this.getConfig();
|
|
149
|
+
const response = await fetch(fullPath, {
|
|
150
|
+
method: "POST",
|
|
151
|
+
headers: {
|
|
152
|
+
...config.headers,
|
|
153
|
+
"Content-Type": "application/json"
|
|
154
|
+
},
|
|
155
|
+
body: JSON.stringify(data)
|
|
156
|
+
});
|
|
157
|
+
if (!response.ok) {
|
|
158
|
+
const apiErrorData = await response.json();
|
|
159
|
+
throw new ServerApiError(apiErrorData, response.status);
|
|
160
|
+
}
|
|
161
|
+
const responseData = await response.json();
|
|
162
|
+
responseData.isSuccessful = true;
|
|
163
|
+
return responseData;
|
|
164
|
+
};
|
|
165
|
+
try {
|
|
166
|
+
return await this.handleRequest(request);
|
|
167
|
+
} catch (error) {
|
|
168
|
+
return this.handleFetchError(error);
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
async getSingle(path, params) {
|
|
172
|
+
const request = async () => {
|
|
173
|
+
const sanitizedParams = params ? Object.fromEntries(
|
|
174
|
+
Object.entries(params).map(([k, v]) => [k, String(v)])
|
|
175
|
+
) : void 0;
|
|
176
|
+
const fullPath = this.buildFullPath(path, sanitizedParams);
|
|
177
|
+
const config = this.getConfig();
|
|
178
|
+
return await this.fetchJsonWithCache(fullPath, config);
|
|
179
|
+
};
|
|
180
|
+
try {
|
|
181
|
+
return await this.handleRequest(request);
|
|
182
|
+
} catch (error) {
|
|
183
|
+
return this.handleFetchError(error);
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
async get(path, params) {
|
|
187
|
+
const request = async () => {
|
|
188
|
+
const sanitizedParams = params ? Object.fromEntries(
|
|
189
|
+
Object.entries(params).map(([k, v]) => [k, String(v)])
|
|
190
|
+
) : void 0;
|
|
191
|
+
const fullPath = this.buildFullPath(path, sanitizedParams);
|
|
192
|
+
const config = this.getConfig();
|
|
193
|
+
console.log(fullPath);
|
|
194
|
+
return await this.fetchJsonWithCache(fullPath, config);
|
|
195
|
+
};
|
|
196
|
+
try {
|
|
197
|
+
return await this.handleRequest(request);
|
|
198
|
+
} catch (error) {
|
|
199
|
+
return this.handleFetchError(error);
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
};
|
|
203
|
+
var ServiceClient_default = ServiceClient;
|
|
204
|
+
|
|
205
|
+
export {
|
|
206
|
+
ServiceClient_default
|
|
207
|
+
};
|