@ebertjendustries/cswrapper 1.0.0 → 1.0.2
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/index.js +253 -267
- package/dist/index.mjs +253 -267
- package/package.json +37 -5
package/dist/index.js
CHANGED
|
@@ -112,28 +112,29 @@ var import_components2 = require("@cloudscape-design/components");
|
|
|
112
112
|
|
|
113
113
|
// src/types/CSFormProps.ts
|
|
114
114
|
var FromPropsHelper = class {
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
};
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
return
|
|
136
|
-
}
|
|
115
|
+
};
|
|
116
|
+
FromPropsHelper.getBasicProps = (props) => {
|
|
117
|
+
const localisationObject = props.localiser.localiseField(props.fieldSpec.getLocalisationKey(), props.localisationVariables, props.alternateNs);
|
|
118
|
+
const uniqueId = props.fieldSpec.getDataTestId();
|
|
119
|
+
return { localisationObject, uniqueId };
|
|
120
|
+
};
|
|
121
|
+
FromPropsHelper.usesFormField = (props) => {
|
|
122
|
+
const localisation = props.localiser.localiseField(props.fieldSpec.getLocalisationKey(), props.localisationVariables, props.alternateNs);
|
|
123
|
+
return props.formField !== void 0 || (localisation == null ? void 0 : localisation.formField) !== void 0;
|
|
124
|
+
};
|
|
125
|
+
FromPropsHelper.getLocalisedErrorText = (props, value, localiseValidity) => {
|
|
126
|
+
var _a, _b;
|
|
127
|
+
if (((_a = props.formField) == null ? void 0 : _a.errorText) !== void 0) {
|
|
128
|
+
return (_b = props.formField) == null ? void 0 : _b.errorText;
|
|
129
|
+
}
|
|
130
|
+
const validityLevel = props.fieldSpec.getValueValidityLevel(value);
|
|
131
|
+
return localiseValidity(props.fieldSpec, validityLevel);
|
|
132
|
+
};
|
|
133
|
+
FromPropsHelper.sanitizeValueToString = (value) => {
|
|
134
|
+
if (value === null || value === void 0) {
|
|
135
|
+
return "";
|
|
136
|
+
}
|
|
137
|
+
return value;
|
|
137
138
|
};
|
|
138
139
|
|
|
139
140
|
// src/components/CSFormField.tsx
|
|
@@ -151,34 +152,35 @@ function CSFormField(props) {
|
|
|
151
152
|
if (!FromPropsHelper.usesFormField(props)) {
|
|
152
153
|
return props.children;
|
|
153
154
|
}
|
|
154
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_components.FormField, { "data-testid": formFieldId, ...localisationObject
|
|
155
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_components.FormField, { "data-testid": formFieldId, ...localisationObject == null ? void 0 : localisationObject.formField, ...props.formField, children: props.children });
|
|
155
156
|
}
|
|
156
157
|
|
|
157
158
|
// src/components/ChildUtils.tsx
|
|
158
159
|
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
159
160
|
var ChildUtils = class {
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
}
|
|
161
|
+
};
|
|
162
|
+
ChildUtils.getChildren = (props, localisationObject) => {
|
|
163
|
+
var _a, _b;
|
|
164
|
+
const childrenRaw = (_a = props.children) != null ? _a : localisationObject == null ? void 0 : localisationObject.children;
|
|
165
|
+
const children = props.childrenWrapper ? props.childrenWrapper(childrenRaw) : childrenRaw;
|
|
166
|
+
let finalChildren = props.preventOverflow ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { style: {
|
|
167
|
+
whiteSpace: "nowrap",
|
|
168
|
+
overflow: "hidden",
|
|
169
|
+
textOverflow: "ellipsis"
|
|
170
|
+
}, children }) : children;
|
|
171
|
+
let formFieldProps = (_b = props.formField) != null ? _b : localisationObject == null ? void 0 : localisationObject.formField;
|
|
172
|
+
if (props.inlineLabel && FromPropsHelper.usesFormField(props)) {
|
|
173
|
+
finalChildren = /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { style: { display: "flex", flexWrap: "nowrap" }, children: [
|
|
174
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { style: {
|
|
175
|
+
flex: "none",
|
|
176
|
+
fontWeight: "bold",
|
|
177
|
+
paddingRight: "5px"
|
|
178
|
+
}, children: formFieldProps.label + ":" }),
|
|
179
|
+
finalChildren
|
|
180
|
+
] });
|
|
181
|
+
formFieldProps = { ...formFieldProps, label: void 0 };
|
|
182
|
+
}
|
|
183
|
+
return { children: finalChildren, formProps: { ...props, formField: formFieldProps } };
|
|
182
184
|
};
|
|
183
185
|
|
|
184
186
|
// src/components/CSAlert.tsx
|
|
@@ -276,6 +278,7 @@ function CSDatePicker(props) {
|
|
|
276
278
|
var import_components7 = require("@cloudscape-design/components");
|
|
277
279
|
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
278
280
|
function CSMultiselect(props) {
|
|
281
|
+
var _a, _b;
|
|
279
282
|
const { localisationObject, uniqueId } = FromPropsHelper.getBasicProps(props);
|
|
280
283
|
const { formProps } = ChildUtils.getChildren(props, localisationObject);
|
|
281
284
|
const adaptedOnChange = ({ detail }) => {
|
|
@@ -289,13 +292,13 @@ function CSMultiselect(props) {
|
|
|
289
292
|
props.onChangeValue(props.fieldSpec.key, detail.selectedOptions.map((sel) => sel.value));
|
|
290
293
|
}
|
|
291
294
|
};
|
|
292
|
-
const hideTokens = props.hideTokens
|
|
295
|
+
const hideTokens = (_a = props.hideTokens) != null ? _a : props.tokenLimit !== void 0 && props.tokenLimit === 0;
|
|
293
296
|
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(CSFormField, { ...formProps, children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
294
297
|
import_components7.Multiselect,
|
|
295
298
|
{
|
|
296
299
|
"data-testid": uniqueId,
|
|
297
300
|
controlId: uniqueId,
|
|
298
|
-
filteringType: props.filteringType
|
|
301
|
+
filteringType: (_b = props.filteringType) != null ? _b : "auto",
|
|
299
302
|
onChange: adaptedOnChange,
|
|
300
303
|
enableSelectAll: true,
|
|
301
304
|
...props,
|
|
@@ -308,86 +311,86 @@ function CSMultiselect(props) {
|
|
|
308
311
|
|
|
309
312
|
// src/types/ObjectWithId.ts
|
|
310
313
|
var ObjectWithId = class {
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
};
|
|
314
|
+
};
|
|
315
|
+
ObjectWithId.idToString = (objectWithId) => {
|
|
316
|
+
return objectWithId.id ? objectWithId.id.toString() : "<N/A>";
|
|
317
|
+
};
|
|
318
|
+
ObjectWithId.toObjectWithId = (array, idExtractor) => {
|
|
319
|
+
return array.map((object) => ({
|
|
320
|
+
...object,
|
|
321
|
+
id: idExtractor(object)
|
|
322
|
+
}));
|
|
321
323
|
};
|
|
322
324
|
|
|
323
325
|
// src/utils/SelectHelper.ts
|
|
324
|
-
var
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
326
|
+
var _SelectHelper = class _SelectHelper {
|
|
327
|
+
};
|
|
328
|
+
_SelectHelper.singleSelectOptionWithId = (objects, selectedObjectId, toOptionDefinition) => {
|
|
329
|
+
return _SelectHelper.singleSelectOption(objects, objects.find((importObject) => ObjectWithId.idToString(importObject) === (selectedObjectId == null ? void 0 : selectedObjectId.toString())), toOptionDefinition);
|
|
330
|
+
};
|
|
331
|
+
_SelectHelper.singleSelectOption = (objects, selectedObject, toOptionDefinition) => {
|
|
332
|
+
const options = objects.map((object) => ({
|
|
333
|
+
value: ObjectWithId.idToString(object),
|
|
334
|
+
...toOptionDefinition(object)
|
|
335
|
+
}));
|
|
336
|
+
const selectedOption = selectedObject === void 0 ? null : _SelectHelper.getSelectedOptions(options, [selectedObject.id])[0];
|
|
337
|
+
return {
|
|
338
|
+
options,
|
|
339
|
+
selectedOption
|
|
338
340
|
};
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
value: enumInstance.toString(),
|
|
344
|
-
label: enumTranslation.label,
|
|
345
|
-
description: enumTranslation.description
|
|
346
|
-
};
|
|
347
|
-
});
|
|
348
|
-
const selectedOption = selectedEnum === void 0 ? null : _SelectHelper.getSelectedEnumOptions(options, [selectedEnum.toString()])[0];
|
|
341
|
+
};
|
|
342
|
+
_SelectHelper.singleSelectEnum = (enumFactory, selectedEnum, localiser, exclude) => {
|
|
343
|
+
const options = enumFactory.values.filter((enumInstance) => exclude === void 0 || !exclude.includes(enumInstance)).map((enumInstance) => {
|
|
344
|
+
const enumTranslation = localiser.getEnumLocalisation(enumFactory, enumInstance);
|
|
349
345
|
return {
|
|
350
|
-
|
|
351
|
-
|
|
346
|
+
value: enumInstance.toString(),
|
|
347
|
+
label: enumTranslation.label,
|
|
348
|
+
description: enumTranslation.description
|
|
352
349
|
};
|
|
350
|
+
});
|
|
351
|
+
const selectedOption = selectedEnum === void 0 ? null : _SelectHelper.getSelectedEnumOptions(options, [selectedEnum.toString()])[0];
|
|
352
|
+
return {
|
|
353
|
+
options,
|
|
354
|
+
selectedOption
|
|
353
355
|
};
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
356
|
+
};
|
|
357
|
+
_SelectHelper.multiSelectOptions = (objects, selectedObjects, toOptionDefinition) => {
|
|
358
|
+
const options = objects.map((object) => ({
|
|
359
|
+
value: ObjectWithId.idToString(object),
|
|
360
|
+
...toOptionDefinition(object)
|
|
361
|
+
}));
|
|
362
|
+
const selectedOptions = _SelectHelper.getSelectedOptions(options, selectedObjects.map((s) => s.id));
|
|
363
|
+
return {
|
|
364
|
+
options,
|
|
365
|
+
selectedOptions
|
|
364
366
|
};
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
value: enumInstance.toString(),
|
|
370
|
-
label: enumTranslation.label,
|
|
371
|
-
description: enumTranslation.description
|
|
372
|
-
};
|
|
373
|
-
});
|
|
374
|
-
const selectedOptions = _SelectHelper.getSelectedEnumOptions(options, selectedEnums);
|
|
367
|
+
};
|
|
368
|
+
_SelectHelper.multiSelectEnums = (enumFactory, selectedEnums, localiser) => {
|
|
369
|
+
const options = enumFactory.values.map((enumInstance) => {
|
|
370
|
+
const enumTranslation = localiser.getEnumLocalisation(enumFactory, enumInstance);
|
|
375
371
|
return {
|
|
376
|
-
|
|
377
|
-
|
|
372
|
+
value: enumInstance.toString(),
|
|
373
|
+
label: enumTranslation.label,
|
|
374
|
+
description: enumTranslation.description
|
|
378
375
|
};
|
|
376
|
+
});
|
|
377
|
+
const selectedOptions = _SelectHelper.getSelectedEnumOptions(options, selectedEnums);
|
|
378
|
+
return {
|
|
379
|
+
options,
|
|
380
|
+
selectedOptions
|
|
379
381
|
};
|
|
380
|
-
static getSelectedOptions = (options, selectedIds) => {
|
|
381
|
-
const selectedIdsSet = {};
|
|
382
|
-
selectedIds.forEach((selId) => selId !== void 0 ? selectedIdsSet[selId] = true : null);
|
|
383
|
-
return options.filter((option) => option.value && selectedIdsSet[parseInt(option.value)]);
|
|
384
|
-
};
|
|
385
|
-
static getSelectedEnumOptions = (options, selectedEnums) => {
|
|
386
|
-
const selectedIdsSet = {};
|
|
387
|
-
selectedEnums.forEach((selId) => selId !== void 0 ? selectedIdsSet[selId.toString()] = true : null);
|
|
388
|
-
return options.filter((option) => option.value && selectedIdsSet[option.value]);
|
|
389
|
-
};
|
|
390
382
|
};
|
|
383
|
+
_SelectHelper.getSelectedOptions = (options, selectedIds) => {
|
|
384
|
+
const selectedIdsSet = {};
|
|
385
|
+
selectedIds.forEach((selId) => selId !== void 0 ? selectedIdsSet[selId] = true : null);
|
|
386
|
+
return options.filter((option) => option.value && selectedIdsSet[parseInt(option.value)]);
|
|
387
|
+
};
|
|
388
|
+
_SelectHelper.getSelectedEnumOptions = (options, selectedEnums) => {
|
|
389
|
+
const selectedIdsSet = {};
|
|
390
|
+
selectedEnums.forEach((selId) => selId !== void 0 ? selectedIdsSet[selId.toString()] = true : null);
|
|
391
|
+
return options.filter((option) => option.value && selectedIdsSet[option.value]);
|
|
392
|
+
};
|
|
393
|
+
var SelectHelper = _SelectHelper;
|
|
391
394
|
|
|
392
395
|
// src/components/CSEnumMultiselect.tsx
|
|
393
396
|
var import_jsx_runtime9 = require("react/jsx-runtime");
|
|
@@ -733,8 +736,6 @@ var ELEMENT_VALIDITY_LEVEL_FACTORY = new EnumFactory("ElementValidityLevel", Obj
|
|
|
733
736
|
// src/logging/Log.ts
|
|
734
737
|
var DISABLE_LOGGING = false;
|
|
735
738
|
var Log = class _Log {
|
|
736
|
-
prefix;
|
|
737
|
-
debugLogging;
|
|
738
739
|
constructor(prefix) {
|
|
739
740
|
this.prefix = prefix ? "[" + prefix + "] " : "";
|
|
740
741
|
this.debugLogging = true;
|
|
@@ -837,11 +838,6 @@ var ViewElementSpec = class {
|
|
|
837
838
|
this.key = key;
|
|
838
839
|
this.instanceId = instanceId;
|
|
839
840
|
}
|
|
840
|
-
parent;
|
|
841
|
-
ns;
|
|
842
|
-
dataTestId;
|
|
843
|
-
localisationKey;
|
|
844
|
-
keyHierarchy;
|
|
845
841
|
getDataTestId() {
|
|
846
842
|
if (this.dataTestId === void 0) {
|
|
847
843
|
const parentDataTestId = this.parent ? this.parent.getDataTestId() : "";
|
|
@@ -940,8 +936,6 @@ var ViewSpec = class _ViewSpec extends ViewElementSpec {
|
|
|
940
936
|
this.viewValidator = customViewValidator;
|
|
941
937
|
}
|
|
942
938
|
}
|
|
943
|
-
elements;
|
|
944
|
-
viewValidator;
|
|
945
939
|
static create(key, ns, elementDefinition, instanceId, parent, customViewValidator) {
|
|
946
940
|
const viewSpec = new _ViewSpec(key, ns, instanceId, customViewValidator);
|
|
947
941
|
viewSpec.parent = parent;
|
|
@@ -1069,62 +1063,63 @@ var import_components21 = require("@cloudscape-design/components");
|
|
|
1069
1063
|
|
|
1070
1064
|
// src/utils/PriceUtils.ts
|
|
1071
1065
|
var LOGGER2 = new Log("PriceUtils");
|
|
1072
|
-
var
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
};
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
}
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
};
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
};
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
}
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1066
|
+
var _PriceUtils = class _PriceUtils {
|
|
1067
|
+
};
|
|
1068
|
+
_PriceUtils.getFormattedPrice = (locale, price) => {
|
|
1069
|
+
if (isNaN(price.priceInCents)) {
|
|
1070
|
+
return "-";
|
|
1071
|
+
}
|
|
1072
|
+
return new Intl.NumberFormat(locale, {
|
|
1073
|
+
style: "currency",
|
|
1074
|
+
currency: price.currency.toString()
|
|
1075
|
+
}).format(price.priceInCents / 100);
|
|
1076
|
+
};
|
|
1077
|
+
_PriceUtils.sumPrices = (prices, defaultCurrency) => {
|
|
1078
|
+
if (prices.length === 0) {
|
|
1079
|
+
return { priceInCents: 0, currency: defaultCurrency };
|
|
1080
|
+
}
|
|
1081
|
+
const currencySet = _PriceUtils.getCurrenciesFromPrices(prices);
|
|
1082
|
+
if (currencySet.size > 1) {
|
|
1083
|
+
LOGGER2.warn("Different currencies found in price array to be summed - the final price is incorrect!", currencySet);
|
|
1084
|
+
}
|
|
1085
|
+
const summedPrice = prices.map((pr) => pr.priceInCents).reduce((sum, current) => sum + current);
|
|
1086
|
+
return { priceInCents: summedPrice, currency: prices[0].currency };
|
|
1087
|
+
};
|
|
1088
|
+
_PriceUtils.getCurrenciesFromPrices = (prices) => {
|
|
1089
|
+
const currencySet = /* @__PURE__ */ new Set();
|
|
1090
|
+
prices.forEach((pr) => currencySet.add(pr.currency));
|
|
1091
|
+
return currencySet;
|
|
1092
|
+
};
|
|
1093
|
+
_PriceUtils.getPriceValidityLevel = (spec, value) => {
|
|
1094
|
+
const centsValidity = spec.elements.inputPrice.getValueValidityLevel(value.priceInCents);
|
|
1095
|
+
if (centsValidity !== "VALID" /* VALID */) {
|
|
1096
|
+
return centsValidity;
|
|
1097
|
+
}
|
|
1098
|
+
return spec.elements.selectCurrency.getValueValidityLevel(value.currency);
|
|
1099
|
+
};
|
|
1100
|
+
_PriceUtils.parseFormattedPrice = (locale, formattedPrice, currency) => {
|
|
1101
|
+
const thousandSeparator = Intl.NumberFormat(locale).format(11111).replace(/\p{Number}/gu, "");
|
|
1102
|
+
const decimalSeparator = Intl.NumberFormat(locale).format(1.1).replace(/\p{Number}/gu, "");
|
|
1103
|
+
const sanitizedPrice = formattedPrice.replace(new RegExp("\\" + thousandSeparator, "g"), "").replace(new RegExp("\\" + decimalSeparator), ".").replace(new RegExp("[^0-9.]", "g"), "").trim();
|
|
1104
|
+
const parsedPriceCents = Math.round(100 * parseFloat(sanitizedPrice));
|
|
1105
|
+
return { priceInCents: parsedPriceCents, currency };
|
|
1106
|
+
};
|
|
1107
|
+
_PriceUtils.parseFormattedPriceWithCurrency = (locale, formattedPrice, currencySymbolMapping) => {
|
|
1108
|
+
const thousandSeparator = Intl.NumberFormat(locale).format(11111).replace(/\p{Number}/gu, "");
|
|
1109
|
+
const decimalSeparator = Intl.NumberFormat(locale).format(1.1).replace(/\p{Number}/gu, "");
|
|
1110
|
+
const sanitizedPrice = formattedPrice.replace(new RegExp("\\" + thousandSeparator, "g"), "").replace(new RegExp("\\" + decimalSeparator), ".").replace(new RegExp("[^0-9.]", "g"), "").trim();
|
|
1111
|
+
const parsedPriceCents = Math.round(100 * parseFloat(sanitizedPrice));
|
|
1112
|
+
const supportedCurrencies = Object.keys(currencySymbolMapping);
|
|
1113
|
+
const currencySymbolsFound = supportedCurrencies.filter((symbol) => formattedPrice.includes(symbol));
|
|
1114
|
+
if (currencySymbolsFound.length > 1) {
|
|
1115
|
+
throw new Error(`Multiple currency symbols found in formatter price string ${formattedPrice}, here are the supported currencies: ${supportedCurrencies}`);
|
|
1116
|
+
}
|
|
1117
|
+
return {
|
|
1118
|
+
priceInCents: parsedPriceCents,
|
|
1119
|
+
currency: currencySymbolMapping[currencySymbolsFound[0]]
|
|
1126
1120
|
};
|
|
1127
1121
|
};
|
|
1122
|
+
var PriceUtils = _PriceUtils;
|
|
1128
1123
|
|
|
1129
1124
|
// src/views/CSVPriceInputView.tsx
|
|
1130
1125
|
var import_jsx_runtime26 = require("react/jsx-runtime");
|
|
@@ -1471,35 +1466,25 @@ var MESSAGE_SEVERITY_FACTORY = new EnumFactory("MessageSeverity", Object.values(
|
|
|
1471
1466
|
|
|
1472
1467
|
// src/types/messaging/MessageCTO.ts
|
|
1473
1468
|
var MessageCTO = class {
|
|
1474
|
-
static TIMESTAMP_PROPS = new FieldProperties("timestamp", true);
|
|
1475
|
-
static DETAIL_MESSAGE_PROPS = new FieldProperties("detailMessage", true);
|
|
1476
|
-
static CORRELATION_ID_PROPS = new FieldProperties("correlationId", true);
|
|
1477
|
-
static OPERATION_PROPS = new FieldProperties("operation", true);
|
|
1478
|
-
code;
|
|
1479
|
-
timestamp;
|
|
1480
|
-
detailMessage;
|
|
1481
|
-
correlationId;
|
|
1482
|
-
operation;
|
|
1483
1469
|
};
|
|
1470
|
+
MessageCTO.TIMESTAMP_PROPS = new FieldProperties("timestamp", true);
|
|
1471
|
+
MessageCTO.DETAIL_MESSAGE_PROPS = new FieldProperties("detailMessage", true);
|
|
1472
|
+
MessageCTO.CORRELATION_ID_PROPS = new FieldProperties("correlationId", true);
|
|
1473
|
+
MessageCTO.OPERATION_PROPS = new FieldProperties("operation", true);
|
|
1484
1474
|
|
|
1485
1475
|
// src/types/messaging/MessageCodeTO.ts
|
|
1486
1476
|
var MessageCodeTO = class {
|
|
1487
|
-
static CONTROLLER_ID_PROPS = new FieldProperties("componentId", true);
|
|
1488
|
-
static HTTP_STATUS_CODE_PROPS = new FieldProperties("httpStatusCode", true);
|
|
1489
|
-
static LOCAL_CODE_PROPS = new FieldProperties("localCode", true);
|
|
1490
|
-
static MESSAGE_SEVERITY_PROPS = new FieldProperties("messageSeverity", true);
|
|
1491
|
-
static UNIQUE_CODE_PROPS = new FieldProperties("uniqueCode", true);
|
|
1492
|
-
componentId;
|
|
1493
|
-
httpStatusCode;
|
|
1494
|
-
localCode;
|
|
1495
|
-
messageSeverity;
|
|
1496
|
-
uniqueCode;
|
|
1497
1477
|
};
|
|
1478
|
+
MessageCodeTO.CONTROLLER_ID_PROPS = new FieldProperties("componentId", true);
|
|
1479
|
+
MessageCodeTO.HTTP_STATUS_CODE_PROPS = new FieldProperties("httpStatusCode", true);
|
|
1480
|
+
MessageCodeTO.LOCAL_CODE_PROPS = new FieldProperties("localCode", true);
|
|
1481
|
+
MessageCodeTO.MESSAGE_SEVERITY_PROPS = new FieldProperties("messageSeverity", true);
|
|
1482
|
+
MessageCodeTO.UNIQUE_CODE_PROPS = new FieldProperties("uniqueCode", true);
|
|
1498
1483
|
|
|
1499
1484
|
// src/types/messaging/MessageService.ts
|
|
1500
1485
|
var TECHNICAL_CONTROLLER_ID = "T";
|
|
1501
1486
|
var NO_HTTP_CODE = 0;
|
|
1502
|
-
var
|
|
1487
|
+
var _MessageService = class _MessageService {
|
|
1503
1488
|
static getResponseTOWithMessagesFromUnknownResponse(json, op, status) {
|
|
1504
1489
|
const response = json !== void 0 && json !== null && json.hasOwnProperty("messages") ? json : _MessageService.createGenericErrorMessageTO(status, op);
|
|
1505
1490
|
response.messages.forEach((m) => m.operation = op);
|
|
@@ -1516,71 +1501,72 @@ var MessageService = class _MessageService {
|
|
|
1516
1501
|
result.messages.forEach((m) => m.operation = op);
|
|
1517
1502
|
return result;
|
|
1518
1503
|
}
|
|
1519
|
-
static createContentWithSuccessMessage = (operation, message) => {
|
|
1520
|
-
return this.createContentWithMessage(this.createMessageTO(
|
|
1521
|
-
TECHNICAL_CONTROLLER_ID,
|
|
1522
|
-
NO_HTTP_CODE.toString(),
|
|
1523
|
-
0,
|
|
1524
|
-
message,
|
|
1525
|
-
operation,
|
|
1526
|
-
"SUCCESS" /* SUCCESS */
|
|
1527
|
-
));
|
|
1528
|
-
};
|
|
1529
|
-
static createContentWithoutMessages = (content) => {
|
|
1530
|
-
return {
|
|
1531
|
-
messages: [],
|
|
1532
|
-
content
|
|
1533
|
-
};
|
|
1534
|
-
};
|
|
1535
|
-
static createContentWithInfoMessage = (operation, message) => {
|
|
1536
|
-
return this.createContentWithMessage(this.createMessageTO(
|
|
1537
|
-
TECHNICAL_CONTROLLER_ID,
|
|
1538
|
-
NO_HTTP_CODE.toString(),
|
|
1539
|
-
0,
|
|
1540
|
-
message,
|
|
1541
|
-
operation,
|
|
1542
|
-
"INFO" /* INFO */
|
|
1543
|
-
));
|
|
1544
|
-
};
|
|
1545
|
-
static createGenericErrorMessageTO = (httpStatusCode, operation) => {
|
|
1546
|
-
if (this.isAPIClientCallError(httpStatusCode)) {
|
|
1547
|
-
return this.createContentWithMessage(this.createMessageTO(TECHNICAL_CONTROLLER_ID, "998", httpStatusCode, "Generic API call client error", operation));
|
|
1548
|
-
} else if (this.isBackendError(httpStatusCode)) {
|
|
1549
|
-
return this.createContentWithMessage(this.createMessageTO(TECHNICAL_CONTROLLER_ID, "999", httpStatusCode, "Generic backend error", operation));
|
|
1550
|
-
} else {
|
|
1551
|
-
throw new Error("Calling this methods with any http status code outside 400-599 is not allowed.");
|
|
1552
|
-
}
|
|
1553
|
-
};
|
|
1554
|
-
static createCriticalErrorFrontendProcessingMessageTO = (operation, message) => {
|
|
1555
|
-
return this.createMessageTO(TECHNICAL_CONTROLLER_ID, "997", -1, message, operation);
|
|
1556
|
-
};
|
|
1557
|
-
static isAPIClientCallError = (httpStatusCode) => {
|
|
1558
|
-
return httpStatusCode >= 400 && httpStatusCode <= 499;
|
|
1559
|
-
};
|
|
1560
|
-
static isBackendError = (httpStatusCode) => {
|
|
1561
|
-
return httpStatusCode >= 500 && httpStatusCode <= 599;
|
|
1562
|
-
};
|
|
1563
1504
|
static createContentWithMessage(message) {
|
|
1564
1505
|
return {
|
|
1565
1506
|
messages: [message],
|
|
1566
1507
|
content: void 0
|
|
1567
1508
|
};
|
|
1568
1509
|
}
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
message
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
|
|
1510
|
+
};
|
|
1511
|
+
_MessageService.createContentWithSuccessMessage = (operation, message) => {
|
|
1512
|
+
return _MessageService.createContentWithMessage(_MessageService.createMessageTO(
|
|
1513
|
+
TECHNICAL_CONTROLLER_ID,
|
|
1514
|
+
NO_HTTP_CODE.toString(),
|
|
1515
|
+
0,
|
|
1516
|
+
message,
|
|
1517
|
+
operation,
|
|
1518
|
+
"SUCCESS" /* SUCCESS */
|
|
1519
|
+
));
|
|
1520
|
+
};
|
|
1521
|
+
_MessageService.createContentWithoutMessages = (content) => {
|
|
1522
|
+
return {
|
|
1523
|
+
messages: [],
|
|
1524
|
+
content
|
|
1582
1525
|
};
|
|
1583
1526
|
};
|
|
1527
|
+
_MessageService.createContentWithInfoMessage = (operation, message) => {
|
|
1528
|
+
return _MessageService.createContentWithMessage(_MessageService.createMessageTO(
|
|
1529
|
+
TECHNICAL_CONTROLLER_ID,
|
|
1530
|
+
NO_HTTP_CODE.toString(),
|
|
1531
|
+
0,
|
|
1532
|
+
message,
|
|
1533
|
+
operation,
|
|
1534
|
+
"INFO" /* INFO */
|
|
1535
|
+
));
|
|
1536
|
+
};
|
|
1537
|
+
_MessageService.createGenericErrorMessageTO = (httpStatusCode, operation) => {
|
|
1538
|
+
if (_MessageService.isAPIClientCallError(httpStatusCode)) {
|
|
1539
|
+
return _MessageService.createContentWithMessage(_MessageService.createMessageTO(TECHNICAL_CONTROLLER_ID, "998", httpStatusCode, "Generic API call client error", operation));
|
|
1540
|
+
} else if (_MessageService.isBackendError(httpStatusCode)) {
|
|
1541
|
+
return _MessageService.createContentWithMessage(_MessageService.createMessageTO(TECHNICAL_CONTROLLER_ID, "999", httpStatusCode, "Generic backend error", operation));
|
|
1542
|
+
} else {
|
|
1543
|
+
throw new Error("Calling this methods with any http status code outside 400-599 is not allowed.");
|
|
1544
|
+
}
|
|
1545
|
+
};
|
|
1546
|
+
_MessageService.createCriticalErrorFrontendProcessingMessageTO = (operation, message) => {
|
|
1547
|
+
return _MessageService.createMessageTO(TECHNICAL_CONTROLLER_ID, "997", -1, message, operation);
|
|
1548
|
+
};
|
|
1549
|
+
_MessageService.isAPIClientCallError = (httpStatusCode) => {
|
|
1550
|
+
return httpStatusCode >= 400 && httpStatusCode <= 499;
|
|
1551
|
+
};
|
|
1552
|
+
_MessageService.isBackendError = (httpStatusCode) => {
|
|
1553
|
+
return httpStatusCode >= 500 && httpStatusCode <= 599;
|
|
1554
|
+
};
|
|
1555
|
+
_MessageService.createMessageTO = (componentId, localCode, httpStatusCode, detailMessage, operation, severity) => {
|
|
1556
|
+
const message = new MessageCTO();
|
|
1557
|
+
message.code = new MessageCodeTO();
|
|
1558
|
+
message.code.httpStatusCode = httpStatusCode;
|
|
1559
|
+
message.code.componentId = componentId;
|
|
1560
|
+
message.code.localCode = localCode;
|
|
1561
|
+
message.code.uniqueCode = componentId + localCode;
|
|
1562
|
+
message.code.messageSeverity = severity ? severity : "ERR" /* ERR */;
|
|
1563
|
+
message.operation = operation;
|
|
1564
|
+
message.correlationId = "N/A";
|
|
1565
|
+
message.timestamp = DateUtils.currentDateTimeAsUTCISO8601String();
|
|
1566
|
+
message.detailMessage = detailMessage;
|
|
1567
|
+
return message;
|
|
1568
|
+
};
|
|
1569
|
+
var MessageService = _MessageService;
|
|
1584
1570
|
|
|
1585
1571
|
// src/utils/QueryParamHelper.ts
|
|
1586
1572
|
var QUERY_START = "?";
|
|
@@ -1633,8 +1619,17 @@ function createRestClient() {
|
|
|
1633
1619
|
return new RestClient("");
|
|
1634
1620
|
}
|
|
1635
1621
|
var RestClient = class {
|
|
1636
|
-
|
|
1637
|
-
|
|
1622
|
+
/**
|
|
1623
|
+
* Creates a new REST client.
|
|
1624
|
+
* @param baseUrl base URL, so client can be called with relative URLs.
|
|
1625
|
+
*/
|
|
1626
|
+
constructor(baseUrl) {
|
|
1627
|
+
// Base URL. May be empty.
|
|
1628
|
+
this.baseUrl = "";
|
|
1629
|
+
if (baseUrl != null) {
|
|
1630
|
+
this.baseUrl = baseUrl;
|
|
1631
|
+
}
|
|
1632
|
+
}
|
|
1638
1633
|
prepareFetchConfig(method, payload, header = {}) {
|
|
1639
1634
|
let headers = {
|
|
1640
1635
|
Accept: "application/json",
|
|
@@ -1656,15 +1651,6 @@ var RestClient = class {
|
|
|
1656
1651
|
}
|
|
1657
1652
|
return config;
|
|
1658
1653
|
}
|
|
1659
|
-
/**
|
|
1660
|
-
* Creates a new REST client.
|
|
1661
|
-
* @param baseUrl base URL, so client can be called with relative URLs.
|
|
1662
|
-
*/
|
|
1663
|
-
constructor(baseUrl) {
|
|
1664
|
-
if (baseUrl != null) {
|
|
1665
|
-
this.baseUrl = baseUrl;
|
|
1666
|
-
}
|
|
1667
|
-
}
|
|
1668
1654
|
/**
|
|
1669
1655
|
* Make a GET request on the specified endpoint
|
|
1670
1656
|
*
|
|
@@ -2013,7 +1999,7 @@ var useHotkey = (key, shift, ctrl, alt, callback, node = null) => {
|
|
|
2013
1999
|
[alt, ctrl, key, shift]
|
|
2014
2000
|
);
|
|
2015
2001
|
(0, import_react5.useEffect)(() => {
|
|
2016
|
-
const targetNode = node
|
|
2002
|
+
const targetNode = node != null ? node : document;
|
|
2017
2003
|
targetNode && targetNode.addEventListener("keydown", handleKeyPress);
|
|
2018
2004
|
return () => targetNode && targetNode.removeEventListener("keydown", handleKeyPress);
|
|
2019
2005
|
}, [handleKeyPress, node]);
|