@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.
Files changed (3) hide show
  1. package/dist/index.js +253 -267
  2. package/dist/index.mjs +253 -267
  3. package/package.json +37 -5
package/dist/index.mjs CHANGED
@@ -3,28 +3,29 @@ import { Alert } from "@cloudscape-design/components";
3
3
 
4
4
  // src/types/CSFormProps.ts
5
5
  var FromPropsHelper = class {
6
- static getBasicProps = (props) => {
7
- const localisationObject = props.localiser.localiseField(props.fieldSpec.getLocalisationKey(), props.localisationVariables, props.alternateNs);
8
- const uniqueId = props.fieldSpec.getDataTestId();
9
- return { localisationObject, uniqueId };
10
- };
11
- static usesFormField = (props) => {
12
- const localisation = props.localiser.localiseField(props.fieldSpec.getLocalisationKey(), props.localisationVariables, props.alternateNs);
13
- return props.formField !== void 0 || localisation?.formField !== void 0;
14
- };
15
- static getLocalisedErrorText = (props, value, localiseValidity) => {
16
- if (props.formField?.errorText !== void 0) {
17
- return props.formField?.errorText;
18
- }
19
- const validityLevel = props.fieldSpec.getValueValidityLevel(value);
20
- return localiseValidity(props.fieldSpec, validityLevel);
21
- };
22
- static sanitizeValueToString = (value) => {
23
- if (value === null || value === void 0) {
24
- return "";
25
- }
26
- return value;
27
- };
6
+ };
7
+ FromPropsHelper.getBasicProps = (props) => {
8
+ const localisationObject = props.localiser.localiseField(props.fieldSpec.getLocalisationKey(), props.localisationVariables, props.alternateNs);
9
+ const uniqueId = props.fieldSpec.getDataTestId();
10
+ return { localisationObject, uniqueId };
11
+ };
12
+ FromPropsHelper.usesFormField = (props) => {
13
+ const localisation = props.localiser.localiseField(props.fieldSpec.getLocalisationKey(), props.localisationVariables, props.alternateNs);
14
+ return props.formField !== void 0 || (localisation == null ? void 0 : localisation.formField) !== void 0;
15
+ };
16
+ FromPropsHelper.getLocalisedErrorText = (props, value, localiseValidity) => {
17
+ var _a, _b;
18
+ if (((_a = props.formField) == null ? void 0 : _a.errorText) !== void 0) {
19
+ return (_b = props.formField) == null ? void 0 : _b.errorText;
20
+ }
21
+ const validityLevel = props.fieldSpec.getValueValidityLevel(value);
22
+ return localiseValidity(props.fieldSpec, validityLevel);
23
+ };
24
+ FromPropsHelper.sanitizeValueToString = (value) => {
25
+ if (value === null || value === void 0) {
26
+ return "";
27
+ }
28
+ return value;
28
29
  };
29
30
 
30
31
  // src/components/CSFormField.tsx
@@ -41,35 +42,36 @@ function CSFormField(props) {
41
42
  // IMPORTANT: Order of props determines which one "wins". You can override Elements that are present in the
42
43
  // localisation texts via the additional props. For instance, you can pass in
43
44
  // non-static localisations that require variable values dynamically.
44
- /* @__PURE__ */ jsx(FormField, { "data-testid": formFieldId, ...localisationObject?.formField, ...props.formField, children: props.children })
45
+ /* @__PURE__ */ jsx(FormField, { "data-testid": formFieldId, ...localisationObject == null ? void 0 : localisationObject.formField, ...props.formField, children: props.children })
45
46
  );
46
47
  }
47
48
 
48
49
  // src/components/ChildUtils.tsx
49
50
  import { jsx as jsx2, jsxs } from "react/jsx-runtime";
50
51
  var ChildUtils = class {
51
- static getChildren = (props, localisationObject) => {
52
- const childrenRaw = props.children ?? localisationObject?.children;
53
- const children = props.childrenWrapper ? props.childrenWrapper(childrenRaw) : childrenRaw;
54
- let finalChildren = props.preventOverflow ? /* @__PURE__ */ jsx2("div", { style: {
55
- whiteSpace: "nowrap",
56
- overflow: "hidden",
57
- textOverflow: "ellipsis"
58
- }, children }) : children;
59
- let formFieldProps = props.formField ?? localisationObject?.formField;
60
- if (props.inlineLabel && FromPropsHelper.usesFormField(props)) {
61
- finalChildren = /* @__PURE__ */ jsxs("div", { style: { display: "flex", flexWrap: "nowrap" }, children: [
62
- /* @__PURE__ */ jsx2("div", { style: {
63
- flex: "none",
64
- fontWeight: "bold",
65
- paddingRight: "5px"
66
- }, children: formFieldProps.label + ":" }),
67
- finalChildren
68
- ] });
69
- formFieldProps = { ...formFieldProps, label: void 0 };
70
- }
71
- return { children: finalChildren, formProps: { ...props, formField: formFieldProps } };
72
- };
52
+ };
53
+ ChildUtils.getChildren = (props, localisationObject) => {
54
+ var _a, _b;
55
+ const childrenRaw = (_a = props.children) != null ? _a : localisationObject == null ? void 0 : localisationObject.children;
56
+ const children = props.childrenWrapper ? props.childrenWrapper(childrenRaw) : childrenRaw;
57
+ let finalChildren = props.preventOverflow ? /* @__PURE__ */ jsx2("div", { style: {
58
+ whiteSpace: "nowrap",
59
+ overflow: "hidden",
60
+ textOverflow: "ellipsis"
61
+ }, children }) : children;
62
+ let formFieldProps = (_b = props.formField) != null ? _b : localisationObject == null ? void 0 : localisationObject.formField;
63
+ if (props.inlineLabel && FromPropsHelper.usesFormField(props)) {
64
+ finalChildren = /* @__PURE__ */ jsxs("div", { style: { display: "flex", flexWrap: "nowrap" }, children: [
65
+ /* @__PURE__ */ jsx2("div", { style: {
66
+ flex: "none",
67
+ fontWeight: "bold",
68
+ paddingRight: "5px"
69
+ }, children: formFieldProps.label + ":" }),
70
+ finalChildren
71
+ ] });
72
+ formFieldProps = { ...formFieldProps, label: void 0 };
73
+ }
74
+ return { children: finalChildren, formProps: { ...props, formField: formFieldProps } };
73
75
  };
74
76
 
75
77
  // src/components/CSAlert.tsx
@@ -167,6 +169,7 @@ function CSDatePicker(props) {
167
169
  import { Multiselect } from "@cloudscape-design/components";
168
170
  import { jsx as jsx8 } from "react/jsx-runtime";
169
171
  function CSMultiselect(props) {
172
+ var _a, _b;
170
173
  const { localisationObject, uniqueId } = FromPropsHelper.getBasicProps(props);
171
174
  const { formProps } = ChildUtils.getChildren(props, localisationObject);
172
175
  const adaptedOnChange = ({ detail }) => {
@@ -180,13 +183,13 @@ function CSMultiselect(props) {
180
183
  props.onChangeValue(props.fieldSpec.key, detail.selectedOptions.map((sel) => sel.value));
181
184
  }
182
185
  };
183
- const hideTokens = props.hideTokens ?? (props.tokenLimit !== void 0 && props.tokenLimit === 0);
186
+ const hideTokens = (_a = props.hideTokens) != null ? _a : props.tokenLimit !== void 0 && props.tokenLimit === 0;
184
187
  return /* @__PURE__ */ jsx8(CSFormField, { ...formProps, children: /* @__PURE__ */ jsx8(
185
188
  Multiselect,
186
189
  {
187
190
  "data-testid": uniqueId,
188
191
  controlId: uniqueId,
189
- filteringType: props.filteringType ?? "auto",
192
+ filteringType: (_b = props.filteringType) != null ? _b : "auto",
190
193
  onChange: adaptedOnChange,
191
194
  enableSelectAll: true,
192
195
  ...props,
@@ -199,86 +202,86 @@ function CSMultiselect(props) {
199
202
 
200
203
  // src/types/ObjectWithId.ts
201
204
  var ObjectWithId = class {
202
- id;
203
- static idToString = (objectWithId) => {
204
- return objectWithId.id ? objectWithId.id.toString() : "<N/A>";
205
- };
206
- static toObjectWithId = (array, idExtractor) => {
207
- return array.map((object) => ({
208
- ...object,
209
- id: idExtractor(object)
210
- }));
211
- };
205
+ };
206
+ ObjectWithId.idToString = (objectWithId) => {
207
+ return objectWithId.id ? objectWithId.id.toString() : "<N/A>";
208
+ };
209
+ ObjectWithId.toObjectWithId = (array, idExtractor) => {
210
+ return array.map((object) => ({
211
+ ...object,
212
+ id: idExtractor(object)
213
+ }));
212
214
  };
213
215
 
214
216
  // src/utils/SelectHelper.ts
215
- var SelectHelper = class _SelectHelper {
216
- static singleSelectOptionWithId = (objects, selectedObjectId, toOptionDefinition) => {
217
- return this.singleSelectOption(objects, objects.find((importObject) => ObjectWithId.idToString(importObject) === selectedObjectId?.toString()), toOptionDefinition);
218
- };
219
- static singleSelectOption = (objects, selectedObject, toOptionDefinition) => {
220
- const options = objects.map((object) => ({
221
- value: ObjectWithId.idToString(object),
222
- ...toOptionDefinition(object)
223
- }));
224
- const selectedOption = selectedObject === void 0 ? null : _SelectHelper.getSelectedOptions(options, [selectedObject.id])[0];
225
- return {
226
- options,
227
- selectedOption
228
- };
217
+ var _SelectHelper = class _SelectHelper {
218
+ };
219
+ _SelectHelper.singleSelectOptionWithId = (objects, selectedObjectId, toOptionDefinition) => {
220
+ return _SelectHelper.singleSelectOption(objects, objects.find((importObject) => ObjectWithId.idToString(importObject) === (selectedObjectId == null ? void 0 : selectedObjectId.toString())), toOptionDefinition);
221
+ };
222
+ _SelectHelper.singleSelectOption = (objects, selectedObject, toOptionDefinition) => {
223
+ const options = objects.map((object) => ({
224
+ value: ObjectWithId.idToString(object),
225
+ ...toOptionDefinition(object)
226
+ }));
227
+ const selectedOption = selectedObject === void 0 ? null : _SelectHelper.getSelectedOptions(options, [selectedObject.id])[0];
228
+ return {
229
+ options,
230
+ selectedOption
229
231
  };
230
- static singleSelectEnum = (enumFactory, selectedEnum, localiser, exclude) => {
231
- const options = enumFactory.values.filter((enumInstance) => exclude === void 0 || !exclude.includes(enumInstance)).map((enumInstance) => {
232
- const enumTranslation = localiser.getEnumLocalisation(enumFactory, enumInstance);
233
- return {
234
- value: enumInstance.toString(),
235
- label: enumTranslation.label,
236
- description: enumTranslation.description
237
- };
238
- });
239
- const selectedOption = selectedEnum === void 0 ? null : _SelectHelper.getSelectedEnumOptions(options, [selectedEnum.toString()])[0];
232
+ };
233
+ _SelectHelper.singleSelectEnum = (enumFactory, selectedEnum, localiser, exclude) => {
234
+ const options = enumFactory.values.filter((enumInstance) => exclude === void 0 || !exclude.includes(enumInstance)).map((enumInstance) => {
235
+ const enumTranslation = localiser.getEnumLocalisation(enumFactory, enumInstance);
240
236
  return {
241
- options,
242
- selectedOption
237
+ value: enumInstance.toString(),
238
+ label: enumTranslation.label,
239
+ description: enumTranslation.description
243
240
  };
241
+ });
242
+ const selectedOption = selectedEnum === void 0 ? null : _SelectHelper.getSelectedEnumOptions(options, [selectedEnum.toString()])[0];
243
+ return {
244
+ options,
245
+ selectedOption
244
246
  };
245
- static multiSelectOptions = (objects, selectedObjects, toOptionDefinition) => {
246
- const options = objects.map((object) => ({
247
- value: ObjectWithId.idToString(object),
248
- ...toOptionDefinition(object)
249
- }));
250
- const selectedOptions = _SelectHelper.getSelectedOptions(options, selectedObjects.map((s) => s.id));
251
- return {
252
- options,
253
- selectedOptions
254
- };
247
+ };
248
+ _SelectHelper.multiSelectOptions = (objects, selectedObjects, toOptionDefinition) => {
249
+ const options = objects.map((object) => ({
250
+ value: ObjectWithId.idToString(object),
251
+ ...toOptionDefinition(object)
252
+ }));
253
+ const selectedOptions = _SelectHelper.getSelectedOptions(options, selectedObjects.map((s) => s.id));
254
+ return {
255
+ options,
256
+ selectedOptions
255
257
  };
256
- static multiSelectEnums = (enumFactory, selectedEnums, localiser) => {
257
- const options = enumFactory.values.map((enumInstance) => {
258
- const enumTranslation = localiser.getEnumLocalisation(enumFactory, enumInstance);
259
- return {
260
- value: enumInstance.toString(),
261
- label: enumTranslation.label,
262
- description: enumTranslation.description
263
- };
264
- });
265
- const selectedOptions = _SelectHelper.getSelectedEnumOptions(options, selectedEnums);
258
+ };
259
+ _SelectHelper.multiSelectEnums = (enumFactory, selectedEnums, localiser) => {
260
+ const options = enumFactory.values.map((enumInstance) => {
261
+ const enumTranslation = localiser.getEnumLocalisation(enumFactory, enumInstance);
266
262
  return {
267
- options,
268
- selectedOptions
263
+ value: enumInstance.toString(),
264
+ label: enumTranslation.label,
265
+ description: enumTranslation.description
269
266
  };
267
+ });
268
+ const selectedOptions = _SelectHelper.getSelectedEnumOptions(options, selectedEnums);
269
+ return {
270
+ options,
271
+ selectedOptions
270
272
  };
271
- static getSelectedOptions = (options, selectedIds) => {
272
- const selectedIdsSet = {};
273
- selectedIds.forEach((selId) => selId !== void 0 ? selectedIdsSet[selId] = true : null);
274
- return options.filter((option) => option.value && selectedIdsSet[parseInt(option.value)]);
275
- };
276
- static getSelectedEnumOptions = (options, selectedEnums) => {
277
- const selectedIdsSet = {};
278
- selectedEnums.forEach((selId) => selId !== void 0 ? selectedIdsSet[selId.toString()] = true : null);
279
- return options.filter((option) => option.value && selectedIdsSet[option.value]);
280
- };
281
273
  };
274
+ _SelectHelper.getSelectedOptions = (options, selectedIds) => {
275
+ const selectedIdsSet = {};
276
+ selectedIds.forEach((selId) => selId !== void 0 ? selectedIdsSet[selId] = true : null);
277
+ return options.filter((option) => option.value && selectedIdsSet[parseInt(option.value)]);
278
+ };
279
+ _SelectHelper.getSelectedEnumOptions = (options, selectedEnums) => {
280
+ const selectedIdsSet = {};
281
+ selectedEnums.forEach((selId) => selId !== void 0 ? selectedIdsSet[selId.toString()] = true : null);
282
+ return options.filter((option) => option.value && selectedIdsSet[option.value]);
283
+ };
284
+ var SelectHelper = _SelectHelper;
282
285
 
283
286
  // src/components/CSEnumMultiselect.tsx
284
287
  import { jsx as jsx9 } from "react/jsx-runtime";
@@ -624,8 +627,6 @@ var ELEMENT_VALIDITY_LEVEL_FACTORY = new EnumFactory("ElementValidityLevel", Obj
624
627
  // src/logging/Log.ts
625
628
  var DISABLE_LOGGING = false;
626
629
  var Log = class _Log {
627
- prefix;
628
- debugLogging;
629
630
  constructor(prefix) {
630
631
  this.prefix = prefix ? "[" + prefix + "] " : "";
631
632
  this.debugLogging = true;
@@ -728,11 +729,6 @@ var ViewElementSpec = class {
728
729
  this.key = key;
729
730
  this.instanceId = instanceId;
730
731
  }
731
- parent;
732
- ns;
733
- dataTestId;
734
- localisationKey;
735
- keyHierarchy;
736
732
  getDataTestId() {
737
733
  if (this.dataTestId === void 0) {
738
734
  const parentDataTestId = this.parent ? this.parent.getDataTestId() : "";
@@ -831,8 +827,6 @@ var ViewSpec = class _ViewSpec extends ViewElementSpec {
831
827
  this.viewValidator = customViewValidator;
832
828
  }
833
829
  }
834
- elements;
835
- viewValidator;
836
830
  static create(key, ns, elementDefinition, instanceId, parent, customViewValidator) {
837
831
  const viewSpec = new _ViewSpec(key, ns, instanceId, customViewValidator);
838
832
  viewSpec.parent = parent;
@@ -960,62 +954,63 @@ import { Grid } from "@cloudscape-design/components";
960
954
 
961
955
  // src/utils/PriceUtils.ts
962
956
  var LOGGER2 = new Log("PriceUtils");
963
- var PriceUtils = class {
964
- static getFormattedPrice = (locale, price) => {
965
- if (isNaN(price.priceInCents)) {
966
- return "-";
967
- }
968
- return new Intl.NumberFormat(locale, {
969
- style: "currency",
970
- currency: price.currency.toString()
971
- }).format(price.priceInCents / 100);
972
- };
973
- static sumPrices = (prices, defaultCurrency) => {
974
- if (prices.length === 0) {
975
- return { priceInCents: 0, currency: defaultCurrency };
976
- }
977
- const currencySet = this.getCurrenciesFromPrices(prices);
978
- if (currencySet.size > 1) {
979
- LOGGER2.warn("Different currencies found in price array to be summed - the final price is incorrect!", currencySet);
980
- }
981
- const summedPrice = prices.map((pr) => pr.priceInCents).reduce((sum, current) => sum + current);
982
- return { priceInCents: summedPrice, currency: prices[0].currency };
983
- };
984
- static getCurrenciesFromPrices = (prices) => {
985
- const currencySet = /* @__PURE__ */ new Set();
986
- prices.forEach((pr) => currencySet.add(pr.currency));
987
- return currencySet;
988
- };
989
- static getPriceValidityLevel = (spec, value) => {
990
- const centsValidity = spec.elements.inputPrice.getValueValidityLevel(value.priceInCents);
991
- if (centsValidity !== "VALID" /* VALID */) {
992
- return centsValidity;
993
- }
994
- return spec.elements.selectCurrency.getValueValidityLevel(value.currency);
995
- };
996
- static parseFormattedPrice = (locale, formattedPrice, currency) => {
997
- const thousandSeparator = Intl.NumberFormat(locale).format(11111).replace(/\p{Number}/gu, "");
998
- const decimalSeparator = Intl.NumberFormat(locale).format(1.1).replace(/\p{Number}/gu, "");
999
- const sanitizedPrice = formattedPrice.replace(new RegExp("\\" + thousandSeparator, "g"), "").replace(new RegExp("\\" + decimalSeparator), ".").replace(new RegExp("[^0-9.]", "g"), "").trim();
1000
- const parsedPriceCents = Math.round(100 * parseFloat(sanitizedPrice));
1001
- return { priceInCents: parsedPriceCents, currency };
1002
- };
1003
- static parseFormattedPriceWithCurrency = (locale, formattedPrice, currencySymbolMapping) => {
1004
- const thousandSeparator = Intl.NumberFormat(locale).format(11111).replace(/\p{Number}/gu, "");
1005
- const decimalSeparator = Intl.NumberFormat(locale).format(1.1).replace(/\p{Number}/gu, "");
1006
- const sanitizedPrice = formattedPrice.replace(new RegExp("\\" + thousandSeparator, "g"), "").replace(new RegExp("\\" + decimalSeparator), ".").replace(new RegExp("[^0-9.]", "g"), "").trim();
1007
- const parsedPriceCents = Math.round(100 * parseFloat(sanitizedPrice));
1008
- const supportedCurrencies = Object.keys(currencySymbolMapping);
1009
- const currencySymbolsFound = supportedCurrencies.filter((symbol) => formattedPrice.includes(symbol));
1010
- if (currencySymbolsFound.length > 1) {
1011
- throw new Error(`Multiple currency symbols found in formatter price string ${formattedPrice}, here are the supported currencies: ${supportedCurrencies}`);
1012
- }
1013
- return {
1014
- priceInCents: parsedPriceCents,
1015
- currency: currencySymbolMapping[currencySymbolsFound[0]]
1016
- };
957
+ var _PriceUtils = class _PriceUtils {
958
+ };
959
+ _PriceUtils.getFormattedPrice = (locale, price) => {
960
+ if (isNaN(price.priceInCents)) {
961
+ return "-";
962
+ }
963
+ return new Intl.NumberFormat(locale, {
964
+ style: "currency",
965
+ currency: price.currency.toString()
966
+ }).format(price.priceInCents / 100);
967
+ };
968
+ _PriceUtils.sumPrices = (prices, defaultCurrency) => {
969
+ if (prices.length === 0) {
970
+ return { priceInCents: 0, currency: defaultCurrency };
971
+ }
972
+ const currencySet = _PriceUtils.getCurrenciesFromPrices(prices);
973
+ if (currencySet.size > 1) {
974
+ LOGGER2.warn("Different currencies found in price array to be summed - the final price is incorrect!", currencySet);
975
+ }
976
+ const summedPrice = prices.map((pr) => pr.priceInCents).reduce((sum, current) => sum + current);
977
+ return { priceInCents: summedPrice, currency: prices[0].currency };
978
+ };
979
+ _PriceUtils.getCurrenciesFromPrices = (prices) => {
980
+ const currencySet = /* @__PURE__ */ new Set();
981
+ prices.forEach((pr) => currencySet.add(pr.currency));
982
+ return currencySet;
983
+ };
984
+ _PriceUtils.getPriceValidityLevel = (spec, value) => {
985
+ const centsValidity = spec.elements.inputPrice.getValueValidityLevel(value.priceInCents);
986
+ if (centsValidity !== "VALID" /* VALID */) {
987
+ return centsValidity;
988
+ }
989
+ return spec.elements.selectCurrency.getValueValidityLevel(value.currency);
990
+ };
991
+ _PriceUtils.parseFormattedPrice = (locale, formattedPrice, currency) => {
992
+ const thousandSeparator = Intl.NumberFormat(locale).format(11111).replace(/\p{Number}/gu, "");
993
+ const decimalSeparator = Intl.NumberFormat(locale).format(1.1).replace(/\p{Number}/gu, "");
994
+ const sanitizedPrice = formattedPrice.replace(new RegExp("\\" + thousandSeparator, "g"), "").replace(new RegExp("\\" + decimalSeparator), ".").replace(new RegExp("[^0-9.]", "g"), "").trim();
995
+ const parsedPriceCents = Math.round(100 * parseFloat(sanitizedPrice));
996
+ return { priceInCents: parsedPriceCents, currency };
997
+ };
998
+ _PriceUtils.parseFormattedPriceWithCurrency = (locale, formattedPrice, currencySymbolMapping) => {
999
+ const thousandSeparator = Intl.NumberFormat(locale).format(11111).replace(/\p{Number}/gu, "");
1000
+ const decimalSeparator = Intl.NumberFormat(locale).format(1.1).replace(/\p{Number}/gu, "");
1001
+ const sanitizedPrice = formattedPrice.replace(new RegExp("\\" + thousandSeparator, "g"), "").replace(new RegExp("\\" + decimalSeparator), ".").replace(new RegExp("[^0-9.]", "g"), "").trim();
1002
+ const parsedPriceCents = Math.round(100 * parseFloat(sanitizedPrice));
1003
+ const supportedCurrencies = Object.keys(currencySymbolMapping);
1004
+ const currencySymbolsFound = supportedCurrencies.filter((symbol) => formattedPrice.includes(symbol));
1005
+ if (currencySymbolsFound.length > 1) {
1006
+ throw new Error(`Multiple currency symbols found in formatter price string ${formattedPrice}, here are the supported currencies: ${supportedCurrencies}`);
1007
+ }
1008
+ return {
1009
+ priceInCents: parsedPriceCents,
1010
+ currency: currencySymbolMapping[currencySymbolsFound[0]]
1017
1011
  };
1018
1012
  };
1013
+ var PriceUtils = _PriceUtils;
1019
1014
 
1020
1015
  // src/views/CSVPriceInputView.tsx
1021
1016
  import { jsx as jsx26, jsxs as jsxs4 } from "react/jsx-runtime";
@@ -1362,35 +1357,25 @@ var MESSAGE_SEVERITY_FACTORY = new EnumFactory("MessageSeverity", Object.values(
1362
1357
 
1363
1358
  // src/types/messaging/MessageCTO.ts
1364
1359
  var MessageCTO = class {
1365
- static TIMESTAMP_PROPS = new FieldProperties("timestamp", true);
1366
- static DETAIL_MESSAGE_PROPS = new FieldProperties("detailMessage", true);
1367
- static CORRELATION_ID_PROPS = new FieldProperties("correlationId", true);
1368
- static OPERATION_PROPS = new FieldProperties("operation", true);
1369
- code;
1370
- timestamp;
1371
- detailMessage;
1372
- correlationId;
1373
- operation;
1374
1360
  };
1361
+ MessageCTO.TIMESTAMP_PROPS = new FieldProperties("timestamp", true);
1362
+ MessageCTO.DETAIL_MESSAGE_PROPS = new FieldProperties("detailMessage", true);
1363
+ MessageCTO.CORRELATION_ID_PROPS = new FieldProperties("correlationId", true);
1364
+ MessageCTO.OPERATION_PROPS = new FieldProperties("operation", true);
1375
1365
 
1376
1366
  // src/types/messaging/MessageCodeTO.ts
1377
1367
  var MessageCodeTO = class {
1378
- static CONTROLLER_ID_PROPS = new FieldProperties("componentId", true);
1379
- static HTTP_STATUS_CODE_PROPS = new FieldProperties("httpStatusCode", true);
1380
- static LOCAL_CODE_PROPS = new FieldProperties("localCode", true);
1381
- static MESSAGE_SEVERITY_PROPS = new FieldProperties("messageSeverity", true);
1382
- static UNIQUE_CODE_PROPS = new FieldProperties("uniqueCode", true);
1383
- componentId;
1384
- httpStatusCode;
1385
- localCode;
1386
- messageSeverity;
1387
- uniqueCode;
1388
1368
  };
1369
+ MessageCodeTO.CONTROLLER_ID_PROPS = new FieldProperties("componentId", true);
1370
+ MessageCodeTO.HTTP_STATUS_CODE_PROPS = new FieldProperties("httpStatusCode", true);
1371
+ MessageCodeTO.LOCAL_CODE_PROPS = new FieldProperties("localCode", true);
1372
+ MessageCodeTO.MESSAGE_SEVERITY_PROPS = new FieldProperties("messageSeverity", true);
1373
+ MessageCodeTO.UNIQUE_CODE_PROPS = new FieldProperties("uniqueCode", true);
1389
1374
 
1390
1375
  // src/types/messaging/MessageService.ts
1391
1376
  var TECHNICAL_CONTROLLER_ID = "T";
1392
1377
  var NO_HTTP_CODE = 0;
1393
- var MessageService = class _MessageService {
1378
+ var _MessageService = class _MessageService {
1394
1379
  static getResponseTOWithMessagesFromUnknownResponse(json, op, status) {
1395
1380
  const response = json !== void 0 && json !== null && json.hasOwnProperty("messages") ? json : _MessageService.createGenericErrorMessageTO(status, op);
1396
1381
  response.messages.forEach((m) => m.operation = op);
@@ -1407,71 +1392,72 @@ var MessageService = class _MessageService {
1407
1392
  result.messages.forEach((m) => m.operation = op);
1408
1393
  return result;
1409
1394
  }
1410
- static createContentWithSuccessMessage = (operation, message) => {
1411
- return this.createContentWithMessage(this.createMessageTO(
1412
- TECHNICAL_CONTROLLER_ID,
1413
- NO_HTTP_CODE.toString(),
1414
- 0,
1415
- message,
1416
- operation,
1417
- "SUCCESS" /* SUCCESS */
1418
- ));
1419
- };
1420
- static createContentWithoutMessages = (content) => {
1421
- return {
1422
- messages: [],
1423
- content
1424
- };
1425
- };
1426
- static createContentWithInfoMessage = (operation, message) => {
1427
- return this.createContentWithMessage(this.createMessageTO(
1428
- TECHNICAL_CONTROLLER_ID,
1429
- NO_HTTP_CODE.toString(),
1430
- 0,
1431
- message,
1432
- operation,
1433
- "INFO" /* INFO */
1434
- ));
1435
- };
1436
- static createGenericErrorMessageTO = (httpStatusCode, operation) => {
1437
- if (this.isAPIClientCallError(httpStatusCode)) {
1438
- return this.createContentWithMessage(this.createMessageTO(TECHNICAL_CONTROLLER_ID, "998", httpStatusCode, "Generic API call client error", operation));
1439
- } else if (this.isBackendError(httpStatusCode)) {
1440
- return this.createContentWithMessage(this.createMessageTO(TECHNICAL_CONTROLLER_ID, "999", httpStatusCode, "Generic backend error", operation));
1441
- } else {
1442
- throw new Error("Calling this methods with any http status code outside 400-599 is not allowed.");
1443
- }
1444
- };
1445
- static createCriticalErrorFrontendProcessingMessageTO = (operation, message) => {
1446
- return this.createMessageTO(TECHNICAL_CONTROLLER_ID, "997", -1, message, operation);
1447
- };
1448
- static isAPIClientCallError = (httpStatusCode) => {
1449
- return httpStatusCode >= 400 && httpStatusCode <= 499;
1450
- };
1451
- static isBackendError = (httpStatusCode) => {
1452
- return httpStatusCode >= 500 && httpStatusCode <= 599;
1453
- };
1454
1395
  static createContentWithMessage(message) {
1455
1396
  return {
1456
1397
  messages: [message],
1457
1398
  content: void 0
1458
1399
  };
1459
1400
  }
1460
- static createMessageTO = (componentId, localCode, httpStatusCode, detailMessage, operation, severity) => {
1461
- const message = new MessageCTO();
1462
- message.code = new MessageCodeTO();
1463
- message.code.httpStatusCode = httpStatusCode;
1464
- message.code.componentId = componentId;
1465
- message.code.localCode = localCode;
1466
- message.code.uniqueCode = componentId + localCode;
1467
- message.code.messageSeverity = severity ? severity : "ERR" /* ERR */;
1468
- message.operation = operation;
1469
- message.correlationId = "N/A";
1470
- message.timestamp = DateUtils.currentDateTimeAsUTCISO8601String();
1471
- message.detailMessage = detailMessage;
1472
- return message;
1401
+ };
1402
+ _MessageService.createContentWithSuccessMessage = (operation, message) => {
1403
+ return _MessageService.createContentWithMessage(_MessageService.createMessageTO(
1404
+ TECHNICAL_CONTROLLER_ID,
1405
+ NO_HTTP_CODE.toString(),
1406
+ 0,
1407
+ message,
1408
+ operation,
1409
+ "SUCCESS" /* SUCCESS */
1410
+ ));
1411
+ };
1412
+ _MessageService.createContentWithoutMessages = (content) => {
1413
+ return {
1414
+ messages: [],
1415
+ content
1473
1416
  };
1474
1417
  };
1418
+ _MessageService.createContentWithInfoMessage = (operation, message) => {
1419
+ return _MessageService.createContentWithMessage(_MessageService.createMessageTO(
1420
+ TECHNICAL_CONTROLLER_ID,
1421
+ NO_HTTP_CODE.toString(),
1422
+ 0,
1423
+ message,
1424
+ operation,
1425
+ "INFO" /* INFO */
1426
+ ));
1427
+ };
1428
+ _MessageService.createGenericErrorMessageTO = (httpStatusCode, operation) => {
1429
+ if (_MessageService.isAPIClientCallError(httpStatusCode)) {
1430
+ return _MessageService.createContentWithMessage(_MessageService.createMessageTO(TECHNICAL_CONTROLLER_ID, "998", httpStatusCode, "Generic API call client error", operation));
1431
+ } else if (_MessageService.isBackendError(httpStatusCode)) {
1432
+ return _MessageService.createContentWithMessage(_MessageService.createMessageTO(TECHNICAL_CONTROLLER_ID, "999", httpStatusCode, "Generic backend error", operation));
1433
+ } else {
1434
+ throw new Error("Calling this methods with any http status code outside 400-599 is not allowed.");
1435
+ }
1436
+ };
1437
+ _MessageService.createCriticalErrorFrontendProcessingMessageTO = (operation, message) => {
1438
+ return _MessageService.createMessageTO(TECHNICAL_CONTROLLER_ID, "997", -1, message, operation);
1439
+ };
1440
+ _MessageService.isAPIClientCallError = (httpStatusCode) => {
1441
+ return httpStatusCode >= 400 && httpStatusCode <= 499;
1442
+ };
1443
+ _MessageService.isBackendError = (httpStatusCode) => {
1444
+ return httpStatusCode >= 500 && httpStatusCode <= 599;
1445
+ };
1446
+ _MessageService.createMessageTO = (componentId, localCode, httpStatusCode, detailMessage, operation, severity) => {
1447
+ const message = new MessageCTO();
1448
+ message.code = new MessageCodeTO();
1449
+ message.code.httpStatusCode = httpStatusCode;
1450
+ message.code.componentId = componentId;
1451
+ message.code.localCode = localCode;
1452
+ message.code.uniqueCode = componentId + localCode;
1453
+ message.code.messageSeverity = severity ? severity : "ERR" /* ERR */;
1454
+ message.operation = operation;
1455
+ message.correlationId = "N/A";
1456
+ message.timestamp = DateUtils.currentDateTimeAsUTCISO8601String();
1457
+ message.detailMessage = detailMessage;
1458
+ return message;
1459
+ };
1460
+ var MessageService = _MessageService;
1475
1461
 
1476
1462
  // src/utils/QueryParamHelper.ts
1477
1463
  var QUERY_START = "?";
@@ -1524,8 +1510,17 @@ function createRestClient() {
1524
1510
  return new RestClient("");
1525
1511
  }
1526
1512
  var RestClient = class {
1527
- // Base URL. May be empty.
1528
- baseUrl = "";
1513
+ /**
1514
+ * Creates a new REST client.
1515
+ * @param baseUrl base URL, so client can be called with relative URLs.
1516
+ */
1517
+ constructor(baseUrl) {
1518
+ // Base URL. May be empty.
1519
+ this.baseUrl = "";
1520
+ if (baseUrl != null) {
1521
+ this.baseUrl = baseUrl;
1522
+ }
1523
+ }
1529
1524
  prepareFetchConfig(method, payload, header = {}) {
1530
1525
  let headers = {
1531
1526
  Accept: "application/json",
@@ -1547,15 +1542,6 @@ var RestClient = class {
1547
1542
  }
1548
1543
  return config;
1549
1544
  }
1550
- /**
1551
- * Creates a new REST client.
1552
- * @param baseUrl base URL, so client can be called with relative URLs.
1553
- */
1554
- constructor(baseUrl) {
1555
- if (baseUrl != null) {
1556
- this.baseUrl = baseUrl;
1557
- }
1558
- }
1559
1545
  /**
1560
1546
  * Make a GET request on the specified endpoint
1561
1547
  *
@@ -1904,7 +1890,7 @@ var useHotkey = (key, shift, ctrl, alt, callback, node = null) => {
1904
1890
  [alt, ctrl, key, shift]
1905
1891
  );
1906
1892
  useEffect2(() => {
1907
- const targetNode = node ?? document;
1893
+ const targetNode = node != null ? node : document;
1908
1894
  targetNode && targetNode.addEventListener("keydown", handleKeyPress);
1909
1895
  return () => targetNode && targetNode.removeEventListener("keydown", handleKeyPress);
1910
1896
  }, [handleKeyPress, node]);