@acoustte-digital-services/digitalstore-controls-dev 0.8.1-dev.20260704091052 → 0.8.1-dev.20260706114046
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/DateTimeViewClient-R3M6ISVK.mjs +16 -0
- package/dist/DateViewClient-VLTRN47D.mjs +9 -0
- package/dist/{chunk-SDNYBQSI.mjs → HlsPlayer-57543DTW.mjs} +3 -2
- package/dist/HlsPlayer-5AWFZ2P6.mjs +601 -0
- package/dist/IframeClient-RGJFZ5P2.mjs +98 -0
- package/dist/InputControlClient-NJV6B65M.mjs +604 -0
- package/dist/InputControlClient-OQDLYA4S.mjs +604 -0
- package/dist/InputControlClient-TW664WIJ.mjs +602 -0
- package/dist/{LinkNodeButton-WDDPNYWI.mjs → LinkNodeButton-FUL3J5HR.mjs} +6 -5
- package/dist/LinkNodeButton-IGJOGOKI.mjs +362 -0
- package/dist/LinkNodeButton-ZONM74OO.mjs +174 -0
- package/dist/Pagination-6OFACRMQ.mjs +229 -0
- package/dist/Pagination-FSYLYKUA.mjs +181 -0
- package/dist/Pagination-YCD5CU2L.mjs +183 -0
- package/dist/Slider-554BKC7N.mjs +322 -0
- package/dist/Slider-PEIVH6A5.mjs +320 -0
- package/dist/chunk-2GSYECIS.mjs +109 -0
- package/dist/chunk-3GWLDT7C.mjs +204 -0
- package/dist/chunk-3R4VVVNK.mjs +903 -0
- package/dist/chunk-47HD7QP7.mjs +199 -0
- package/dist/chunk-56HSDML5.mjs +22 -0
- package/dist/chunk-67IG5NBU.mjs +200 -0
- package/dist/chunk-7ZFZLN56.mjs +903 -0
- package/dist/chunk-CM7LUGCH.mjs +107 -0
- package/dist/chunk-IKIXEQPV.mjs +198 -0
- package/dist/chunk-IMNQO57B.mjs +25 -0
- package/dist/chunk-R2HV35IB.mjs +201 -0
- package/dist/chunk-SPRVN5IM.mjs +118 -0
- package/dist/chunk-TVL6KVD5.mjs +229 -0
- package/dist/chunk-WEV5U33G.mjs +207 -0
- package/dist/chunk-YG6FKKQJ.mjs +900 -0
- package/dist/index.d.mts +56 -169
- package/dist/index.d.ts +56 -169
- package/dist/index.js +3940 -3807
- package/dist/index.mjs +591 -2923
- package/dist/server.d.mts +72 -0
- package/dist/server.d.ts +72 -0
- package/dist/server.js +5126 -0
- package/dist/server.mjs +2698 -0
- package/package.json +18 -4
- package/dist/HlsPlayer-DZNDKG2P.mjs +0 -7
- package/dist/chunk-DOKQUUH3.mjs +0 -414
package/package.json
CHANGED
|
@@ -1,15 +1,29 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@acoustte-digital-services/digitalstore-controls-dev",
|
|
3
|
-
"version": "0.8.1-dev.
|
|
3
|
+
"version": "0.8.1-dev.20260706114046",
|
|
4
4
|
"description": "Reusable React components",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
7
7
|
"types": "dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"import": "./dist/index.mjs",
|
|
12
|
+
"require": "./dist/index.js"
|
|
13
|
+
},
|
|
14
|
+
"./server": {
|
|
15
|
+
"types": "./dist/server.d.ts",
|
|
16
|
+
"import": "./dist/server.mjs",
|
|
17
|
+
"require": "./dist/server.js"
|
|
18
|
+
}
|
|
19
|
+
},
|
|
8
20
|
"files": [
|
|
9
21
|
"dist"
|
|
10
22
|
],
|
|
11
23
|
"scripts": {
|
|
12
|
-
"build": "tsup"
|
|
24
|
+
"build": "tsup",
|
|
25
|
+
"build:clean": "node -e \"require('fs').rmSync('dist',{ recursive:true, force:true })\" && tsup",
|
|
26
|
+
"dev": "tsup --watch"
|
|
13
27
|
},
|
|
14
28
|
"peerDependencies": {
|
|
15
29
|
"katex": "^0.16.0",
|
|
@@ -23,8 +37,8 @@
|
|
|
23
37
|
},
|
|
24
38
|
"devDependencies": {
|
|
25
39
|
"@types/node": "^26.1.0",
|
|
26
|
-
"@types/react": "^19",
|
|
27
|
-
"@types/react-dom": "^19",
|
|
40
|
+
"@types/react": "^19.2.17",
|
|
41
|
+
"@types/react-dom": "^19.2.3",
|
|
28
42
|
"tsup": "^8.5.1",
|
|
29
43
|
"typescript": "^5.9.3"
|
|
30
44
|
},
|
package/dist/chunk-DOKQUUH3.mjs
DELETED
|
@@ -1,414 +0,0 @@
|
|
|
1
|
-
// src/components/ToastService.tsx
|
|
2
|
-
var ToastService = class _ToastService {
|
|
3
|
-
static initialize(showToast, closeToast) {
|
|
4
|
-
_ToastService.showToast = showToast;
|
|
5
|
-
_ToastService.closeToast = closeToast;
|
|
6
|
-
}
|
|
7
|
-
static showError(message) {
|
|
8
|
-
if (_ToastService.showToast) {
|
|
9
|
-
_ToastService.showToast(message, "error");
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
static showInfo(message) {
|
|
13
|
-
if (_ToastService.showToast) {
|
|
14
|
-
_ToastService.showToast(message, "info");
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
static showWarning(message) {
|
|
18
|
-
if (_ToastService.showToast) {
|
|
19
|
-
_ToastService.showToast(message, "warning");
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
static showSuccess(message) {
|
|
23
|
-
if (_ToastService.showToast) {
|
|
24
|
-
_ToastService.showToast(message, "success");
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
static close() {
|
|
28
|
-
if (_ToastService.closeToast) {
|
|
29
|
-
_ToastService.closeToast();
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
};
|
|
33
|
-
var ToastService_default = ToastService;
|
|
34
|
-
|
|
35
|
-
// src/components/Button.tsx
|
|
36
|
-
import React3, { useState as useState2 } from "react";
|
|
37
|
-
|
|
38
|
-
// src/components/StyleTypes.tsx
|
|
39
|
-
var buttonClasses = /* @__PURE__ */ new Map([
|
|
40
|
-
[
|
|
41
|
-
"Primary" /* Solid */,
|
|
42
|
-
"btn-solid relative inline-flex items-center justify-center rounded px-4 py-3 lg:py-2 font-medium shadow-sm hover:shadow-lg focus:outline-none active:scale-95 disabled:opacity-50 disabled:cursor-not-allowed transition duration-150 ease-in-out"
|
|
43
|
-
],
|
|
44
|
-
[
|
|
45
|
-
"PrimaryHollow" /* Hollow */,
|
|
46
|
-
"btn-hollow inline-flex font-medium items-center justify-center px-4 py-3 lg:py-2 rounded hover:shadow-md focus:outline-none transition duration-150 ease-in-out active:scale-95"
|
|
47
|
-
],
|
|
48
|
-
["Link" /* Link */, "btn-link"]
|
|
49
|
-
]);
|
|
50
|
-
var progressClasses = /* @__PURE__ */ new Map([
|
|
51
|
-
["Primary" /* Solid */, ""],
|
|
52
|
-
["PrimaryHollow" /* Hollow */, ""],
|
|
53
|
-
["Link" /* Link */, ""]
|
|
54
|
-
]);
|
|
55
|
-
|
|
56
|
-
// src/components/Confirm.tsx
|
|
57
|
-
import { useState } from "react";
|
|
58
|
-
|
|
59
|
-
// src/components/ClientButton.tsx
|
|
60
|
-
import React from "react";
|
|
61
|
-
import { jsx } from "react/jsx-runtime";
|
|
62
|
-
var ClientButton = (props) => {
|
|
63
|
-
const execute = async (event) => {
|
|
64
|
-
if (props.onClick !== void 0) {
|
|
65
|
-
props.onClick();
|
|
66
|
-
} else {
|
|
67
|
-
ToastService_default.showError("No action defined.");
|
|
68
|
-
}
|
|
69
|
-
};
|
|
70
|
-
let buttonClass = props.ButtonType ? buttonClasses.get(props.ButtonType) : buttonClasses.get("Primary" /* Solid */);
|
|
71
|
-
return /* @__PURE__ */ jsx(React.Fragment, { children: /* @__PURE__ */ jsx(
|
|
72
|
-
"button",
|
|
73
|
-
{
|
|
74
|
-
type: "button",
|
|
75
|
-
onClick: execute,
|
|
76
|
-
className: buttonClass + " " + props.className,
|
|
77
|
-
children: props.children
|
|
78
|
-
}
|
|
79
|
-
) });
|
|
80
|
-
};
|
|
81
|
-
var ClientButton_default = ClientButton;
|
|
82
|
-
|
|
83
|
-
// src/components/Confirm.tsx
|
|
84
|
-
import { Fragment, jsx as jsx2, jsxs } from "react/jsx-runtime";
|
|
85
|
-
var Confirm = ({ message, onConfirm, onCancel }) => {
|
|
86
|
-
const [showModal, setShowModal] = useState(true);
|
|
87
|
-
const handleConfirmAction = () => {
|
|
88
|
-
setShowModal(false);
|
|
89
|
-
if (onConfirm) {
|
|
90
|
-
onConfirm();
|
|
91
|
-
}
|
|
92
|
-
};
|
|
93
|
-
const handleCancelAction = () => {
|
|
94
|
-
setShowModal(false);
|
|
95
|
-
if (onCancel) {
|
|
96
|
-
onCancel();
|
|
97
|
-
}
|
|
98
|
-
};
|
|
99
|
-
return /* @__PURE__ */ jsx2(Fragment, { children: showModal && /* @__PURE__ */ jsxs("div", { className: "fixed inset-0 flex items-center justify-center z-50", children: [
|
|
100
|
-
/* @__PURE__ */ jsx2("div", { className: "absolute inset-0 bg-black opacity-70" }),
|
|
101
|
-
/* @__PURE__ */ jsxs("div", { className: "bg-white rounded-md p-6 w-2/6 shadow border z-50", children: [
|
|
102
|
-
/* @__PURE__ */ jsx2("p", { className: "text-xl font-medium mb-4", children: "Confirmation" }),
|
|
103
|
-
/* @__PURE__ */ jsx2("p", { className: "mb-4", children: message }),
|
|
104
|
-
/* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-8", children: [
|
|
105
|
-
/* @__PURE__ */ jsx2(
|
|
106
|
-
ClientButton_default,
|
|
107
|
-
{
|
|
108
|
-
onClick: handleCancelAction,
|
|
109
|
-
ButtonType: "PrimaryHollow" /* Hollow */,
|
|
110
|
-
children: "Cancel"
|
|
111
|
-
}
|
|
112
|
-
),
|
|
113
|
-
/* @__PURE__ */ jsx2(
|
|
114
|
-
ClientButton_default,
|
|
115
|
-
{
|
|
116
|
-
onClick: handleConfirmAction,
|
|
117
|
-
children: "Confirm"
|
|
118
|
-
}
|
|
119
|
-
)
|
|
120
|
-
] })
|
|
121
|
-
] })
|
|
122
|
-
] }) });
|
|
123
|
-
};
|
|
124
|
-
var Confirm_default = Confirm;
|
|
125
|
-
{
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
// src/components/Button.tsx
|
|
129
|
-
import { jsx as jsx3, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
130
|
-
var Button = (props) => {
|
|
131
|
-
const [inProgress, setInProgress] = useState2(false);
|
|
132
|
-
const [isActionPerformed, setIsActionPerformed] = useState2(false);
|
|
133
|
-
const [responseMessage, setResponseMessage] = useState2(null);
|
|
134
|
-
const [showModal, setShowModal] = useState2(null);
|
|
135
|
-
const execute = async (event) => {
|
|
136
|
-
event.preventDefault();
|
|
137
|
-
event.stopPropagation();
|
|
138
|
-
if (props.confirm) {
|
|
139
|
-
const confirmed = await showConfirmation("Are you sure you want to delete this item?");
|
|
140
|
-
setShowModal(null);
|
|
141
|
-
if (!confirmed) {
|
|
142
|
-
return;
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
if (props.oneTimeAction && isActionPerformed) {
|
|
146
|
-
return;
|
|
147
|
-
}
|
|
148
|
-
setInProgress(true);
|
|
149
|
-
let isValid = true;
|
|
150
|
-
if (props.onValidate !== void 0) {
|
|
151
|
-
isValid = await props.onValidate();
|
|
152
|
-
if (!isValid) {
|
|
153
|
-
setInProgress(false);
|
|
154
|
-
ToastService_default.showError("There are errors in the form. Please fix them before proceeding.");
|
|
155
|
-
return;
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
if (props.onClick !== void 0) {
|
|
159
|
-
let response = await props.onClick();
|
|
160
|
-
if (response.isSuccessful) {
|
|
161
|
-
setIsActionPerformed(true);
|
|
162
|
-
setResponseMessage(response.message);
|
|
163
|
-
if (props.showToast) {
|
|
164
|
-
ToastService_default.showInfo(response.message || "");
|
|
165
|
-
}
|
|
166
|
-
} else {
|
|
167
|
-
ToastService_default.showError(response.message || "");
|
|
168
|
-
}
|
|
169
|
-
} else {
|
|
170
|
-
ToastService_default.showError("No action defined.");
|
|
171
|
-
}
|
|
172
|
-
setInProgress(false);
|
|
173
|
-
};
|
|
174
|
-
const showConfirmation = (message) => {
|
|
175
|
-
return new Promise((resolve) => {
|
|
176
|
-
const onConfirm = () => resolve(true);
|
|
177
|
-
const onCancel = () => resolve(false);
|
|
178
|
-
setShowModal(/* @__PURE__ */ jsx3(Confirm_default, { message: props.confirmationMessage, onConfirm, onCancel }));
|
|
179
|
-
});
|
|
180
|
-
};
|
|
181
|
-
let buttonClass = props.ButtonType ? buttonClasses.get(props.ButtonType) : buttonClasses.get("Primary" /* Solid */);
|
|
182
|
-
let progressClass = props.ButtonType ? progressClasses.get(props.ButtonType) : progressClasses.get("Primary" /* Solid */);
|
|
183
|
-
const isDisabled = inProgress || isActionPerformed && props.oneTimeAction;
|
|
184
|
-
return /* @__PURE__ */ jsxs2(React3.Fragment, { children: [
|
|
185
|
-
/* @__PURE__ */ jsxs2(
|
|
186
|
-
"button",
|
|
187
|
-
{
|
|
188
|
-
type: "submit",
|
|
189
|
-
onClick: execute,
|
|
190
|
-
disabled: props.disabled,
|
|
191
|
-
title: isDisabled ? "The button is disabled to prevent any action" : "",
|
|
192
|
-
className: buttonClass + " relative " + props.className,
|
|
193
|
-
children: [
|
|
194
|
-
isActionPerformed && props.oneTimeAction && responseMessage ? responseMessage : props.children,
|
|
195
|
-
inProgress && /* @__PURE__ */ jsx3(React3.Fragment, { children: props.hideProgressIndicator === true ? /* @__PURE__ */ jsx3("div", { className: "absolute bottom-0 left-0 h-0.5 bg-gray-400 rounded animate-progress" }) : /* @__PURE__ */ jsxs2("svg", { className: "animate-spin ml-2 mr-3 h-5 w-5 " + progressClass, xmlns: "http://www.w3.org/2000/svg", fill: "none", viewBox: "0 0 24 24", children: [
|
|
196
|
-
/* @__PURE__ */ jsx3("circle", { className: "opacity-25", cx: "12", cy: "12", r: "10", stroke: "currentColor", strokeWidth: "4" }),
|
|
197
|
-
/* @__PURE__ */ jsx3("path", { className: "opacity-75", fill: "currentColor", d: "M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z" })
|
|
198
|
-
] }) })
|
|
199
|
-
]
|
|
200
|
-
}
|
|
201
|
-
),
|
|
202
|
-
showModal
|
|
203
|
-
] });
|
|
204
|
-
};
|
|
205
|
-
var Button_default = Button;
|
|
206
|
-
|
|
207
|
-
// src/clients/CacheManage.tsx
|
|
208
|
-
import NodeCache from "node-cache";
|
|
209
|
-
var CacheManager = class _CacheManager {
|
|
210
|
-
constructor() {
|
|
211
|
-
this.maxCacheSize = 1e3;
|
|
212
|
-
this.cache = new NodeCache({ stdTTL: 0, checkperiod: 300 });
|
|
213
|
-
}
|
|
214
|
-
static getInstance() {
|
|
215
|
-
if (!_CacheManager.instance) {
|
|
216
|
-
_CacheManager.instance = new _CacheManager();
|
|
217
|
-
}
|
|
218
|
-
return _CacheManager.instance;
|
|
219
|
-
}
|
|
220
|
-
get(key) {
|
|
221
|
-
return null;
|
|
222
|
-
}
|
|
223
|
-
set(key, data, ttl) {
|
|
224
|
-
}
|
|
225
|
-
clear() {
|
|
226
|
-
this.cache.flushAll();
|
|
227
|
-
}
|
|
228
|
-
size() {
|
|
229
|
-
return this.cache.keys().length;
|
|
230
|
-
}
|
|
231
|
-
destroy() {
|
|
232
|
-
this.cache.close();
|
|
233
|
-
}
|
|
234
|
-
};
|
|
235
|
-
|
|
236
|
-
// src/clients/ServiceClient.tsx
|
|
237
|
-
var ServerApiError = class extends Error {
|
|
238
|
-
constructor(data, status) {
|
|
239
|
-
super(data.message || "---");
|
|
240
|
-
this.status = status;
|
|
241
|
-
this.data = data;
|
|
242
|
-
this.data.isSuccessful = false;
|
|
243
|
-
}
|
|
244
|
-
};
|
|
245
|
-
var ServiceClient = class {
|
|
246
|
-
constructor(apiBaseUrl, session) {
|
|
247
|
-
this.cacheManager = CacheManager.getInstance();
|
|
248
|
-
this.baseUrl = apiBaseUrl;
|
|
249
|
-
this.session = session;
|
|
250
|
-
}
|
|
251
|
-
buildFullPath(path, params) {
|
|
252
|
-
let updatedPath = path;
|
|
253
|
-
if (params) {
|
|
254
|
-
Object.keys(params).forEach((key) => {
|
|
255
|
-
updatedPath = updatedPath.replace(
|
|
256
|
-
`{${key}}`,
|
|
257
|
-
String(params[key])
|
|
258
|
-
);
|
|
259
|
-
});
|
|
260
|
-
}
|
|
261
|
-
return this.baseUrl + updatedPath;
|
|
262
|
-
}
|
|
263
|
-
getConfig() {
|
|
264
|
-
const config = { headers: {} };
|
|
265
|
-
if (this.session) {
|
|
266
|
-
if (this.session.oAuthToken) {
|
|
267
|
-
config.headers["Authorization"] = "Bearer " + this.session.oAuthToken;
|
|
268
|
-
}
|
|
269
|
-
config.headers["cid"] = this.session.cid || "";
|
|
270
|
-
config.headers["UserCurrencyCode"] = this.session.userCurrencyCode || "INR";
|
|
271
|
-
config.headers["MarketCode"] = this.session?.marketCode || "IND";
|
|
272
|
-
}
|
|
273
|
-
return config;
|
|
274
|
-
}
|
|
275
|
-
handleFetchError(error) {
|
|
276
|
-
console.log(error);
|
|
277
|
-
return {
|
|
278
|
-
message: error.message || "There is some error. Please try after sometime.",
|
|
279
|
-
isSuccessful: false
|
|
280
|
-
};
|
|
281
|
-
}
|
|
282
|
-
async fetchJsonWithCache(fullPath, config) {
|
|
283
|
-
const cacheKey = fullPath + "--" + (this.session?.marketCode || "IND");
|
|
284
|
-
const cachedData = this.cacheManager.get(cacheKey);
|
|
285
|
-
if (cachedData) {
|
|
286
|
-
return cachedData;
|
|
287
|
-
}
|
|
288
|
-
console.log("*****************CALLING API:", cacheKey, (/* @__PURE__ */ new Date()).toISOString());
|
|
289
|
-
const response = await fetch(fullPath, { headers: config.headers });
|
|
290
|
-
if (!response.ok) {
|
|
291
|
-
const apiErrorData = await response.json();
|
|
292
|
-
throw new ServerApiError(apiErrorData, response.status);
|
|
293
|
-
}
|
|
294
|
-
const cacheControl = response.headers.get("Cache-Control");
|
|
295
|
-
let revalidate = null;
|
|
296
|
-
if (cacheControl) {
|
|
297
|
-
const maxAgeMatch = cacheControl.match(/max-age=(\d+)/);
|
|
298
|
-
if (maxAgeMatch && maxAgeMatch[1]) {
|
|
299
|
-
const maxAge = parseInt(maxAgeMatch[1], 10);
|
|
300
|
-
revalidate = maxAge * 1e3;
|
|
301
|
-
}
|
|
302
|
-
}
|
|
303
|
-
const data = await response.json();
|
|
304
|
-
data.isSuccessful = true;
|
|
305
|
-
if (revalidate !== null && revalidate > 0) {
|
|
306
|
-
console.log("revalidate............I am caching:" + revalidate);
|
|
307
|
-
this.cacheManager.set(cacheKey, data, revalidate);
|
|
308
|
-
}
|
|
309
|
-
return data;
|
|
310
|
-
}
|
|
311
|
-
// private async refreshToken(): Promise<void> {
|
|
312
|
-
// console.log("*******************calling refresh token***********************");
|
|
313
|
-
// try {
|
|
314
|
-
// const response = await fetch(this.baseUrl + "/auth/storefront/login/refreshToken", {
|
|
315
|
-
// method: 'POST',
|
|
316
|
-
// headers: {
|
|
317
|
-
// 'Content-Type': 'application/json'
|
|
318
|
-
// },
|
|
319
|
-
// body: JSON.stringify({ refreshToken: this.session.refreshToken })
|
|
320
|
-
// });
|
|
321
|
-
// if (!response.ok) {
|
|
322
|
-
// throw new Error("Failed to refresh token");
|
|
323
|
-
// }
|
|
324
|
-
// const responseData = await response.json();
|
|
325
|
-
// this.session.oAuthToken = responseData.result.accessToken;
|
|
326
|
-
// if (typeof window === "undefined") {
|
|
327
|
-
// // Running on the server
|
|
328
|
-
// } else {
|
|
329
|
-
// await fetch("/api/login", {
|
|
330
|
-
// method: "post",
|
|
331
|
-
// headers: {
|
|
332
|
-
// "Content-Type": "application/json",
|
|
333
|
-
// },
|
|
334
|
-
// body: JSON.stringify({ session: this.session }),
|
|
335
|
-
// });
|
|
336
|
-
// }
|
|
337
|
-
// } catch (error: any) {
|
|
338
|
-
// throw new Error("Failed to refresh token");
|
|
339
|
-
// }
|
|
340
|
-
// }
|
|
341
|
-
async handleRequest(request) {
|
|
342
|
-
try {
|
|
343
|
-
return await request();
|
|
344
|
-
} catch (error) {
|
|
345
|
-
throw error;
|
|
346
|
-
}
|
|
347
|
-
}
|
|
348
|
-
async post(path, data) {
|
|
349
|
-
const request = async () => {
|
|
350
|
-
const fullPath = this.baseUrl + path;
|
|
351
|
-
const config = this.getConfig();
|
|
352
|
-
const response = await fetch(fullPath, {
|
|
353
|
-
method: "POST",
|
|
354
|
-
headers: {
|
|
355
|
-
...config.headers,
|
|
356
|
-
"Content-Type": "application/json"
|
|
357
|
-
},
|
|
358
|
-
body: JSON.stringify(data)
|
|
359
|
-
});
|
|
360
|
-
if (!response.ok) {
|
|
361
|
-
const apiErrorData = await response.json();
|
|
362
|
-
throw new ServerApiError(apiErrorData, response.status);
|
|
363
|
-
}
|
|
364
|
-
const responseData = await response.json();
|
|
365
|
-
responseData.isSuccessful = true;
|
|
366
|
-
return responseData;
|
|
367
|
-
};
|
|
368
|
-
try {
|
|
369
|
-
return await this.handleRequest(request);
|
|
370
|
-
} catch (error) {
|
|
371
|
-
return this.handleFetchError(error);
|
|
372
|
-
}
|
|
373
|
-
}
|
|
374
|
-
async getSingle(path, params) {
|
|
375
|
-
const request = async () => {
|
|
376
|
-
const sanitizedParams = params ? Object.fromEntries(
|
|
377
|
-
Object.entries(params).map(([k, v]) => [k, String(v)])
|
|
378
|
-
) : void 0;
|
|
379
|
-
const fullPath = this.buildFullPath(path, sanitizedParams);
|
|
380
|
-
const config = this.getConfig();
|
|
381
|
-
return await this.fetchJsonWithCache(fullPath, config);
|
|
382
|
-
};
|
|
383
|
-
try {
|
|
384
|
-
return await this.handleRequest(request);
|
|
385
|
-
} catch (error) {
|
|
386
|
-
return this.handleFetchError(error);
|
|
387
|
-
}
|
|
388
|
-
}
|
|
389
|
-
async get(path, params) {
|
|
390
|
-
const request = async () => {
|
|
391
|
-
const sanitizedParams = params ? Object.fromEntries(
|
|
392
|
-
Object.entries(params).map(([k, v]) => [k, String(v)])
|
|
393
|
-
) : void 0;
|
|
394
|
-
const fullPath = this.buildFullPath(path, sanitizedParams);
|
|
395
|
-
const config = this.getConfig();
|
|
396
|
-
console.log(fullPath);
|
|
397
|
-
return await this.fetchJsonWithCache(fullPath, config);
|
|
398
|
-
};
|
|
399
|
-
try {
|
|
400
|
-
return await this.handleRequest(request);
|
|
401
|
-
} catch (error) {
|
|
402
|
-
return this.handleFetchError(error);
|
|
403
|
-
}
|
|
404
|
-
}
|
|
405
|
-
};
|
|
406
|
-
var ServiceClient_default = ServiceClient;
|
|
407
|
-
|
|
408
|
-
export {
|
|
409
|
-
ToastService_default,
|
|
410
|
-
buttonClasses,
|
|
411
|
-
ClientButton_default,
|
|
412
|
-
Button_default,
|
|
413
|
-
ServiceClient_default
|
|
414
|
-
};
|