sysone-api-mapper 1.0.148 → 1.0.149

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 (46) hide show
  1. package/{axiosInstance.js → dist/axiosInstance.js} +5 -7
  2. package/dist/index.d.ts +2 -2
  3. package/{index.ts → dist/index.js} +7 -20
  4. package/dist/services.js +92 -0
  5. package/dist/servicesData.js +996 -0
  6. package/dist/src/adapters/createApiAdapter.js +8 -0
  7. package/{src → dist/src}/adapters/financeAdapter.js +4 -5
  8. package/{src → dist/src}/adapters/locationAdapter.js +5 -6
  9. package/{src → dist/src}/adapters/partyAdapter.js +7 -8
  10. package/{src → dist/src}/components/notificationToast.js +35 -37
  11. package/dist/src/contexts/actionsContext.js +43 -0
  12. package/{src → dist/src}/contexts/apiContext.js +8 -9
  13. package/dist/src/contexts/translationContext.js +19 -0
  14. package/dist/src/mapper/Mapper.js +98 -0
  15. package/{src → dist/src}/mapper/endpointsConfig.js +821 -915
  16. package/{src → dist/src}/mapper/helpers/mappingHelpers.js +24 -26
  17. package/{src → dist/src}/mapper/modules/billing/index.js +128 -131
  18. package/{src → dist/src}/mapper/modules/claim/index.js +15 -17
  19. package/{src → dist/src}/mapper/modules/general/index.js +6 -7
  20. package/{src → dist/src}/mapper/modules/party/index.js +119 -128
  21. package/dist/src/mapper/modules/policy/index.js +573 -0
  22. package/dist/src/mapper/modules/quotation/index.js +477 -0
  23. package/{src → dist/src}/mapper/modules/request/index.js +60 -67
  24. package/dist/src/public/index.js +7 -0
  25. package/{src → dist/src}/server.js +18 -23
  26. package/package.json +3 -3
  27. package/.babelrc +0 -4
  28. package/.gitlab-ci.yml +0 -42
  29. package/config/dist/index.js +0 -307
  30. package/config/dist/index.js.LICENSE.txt +0 -1
  31. package/config/dist/index.ts +0 -319
  32. package/config/webpack.dev.js +0 -63
  33. package/config/webpack.prod.js +0 -63
  34. package/index.d.ts +0 -5
  35. package/services.js +0 -105
  36. package/servicesData.js +0 -1013
  37. package/src/adapters/createApiAdapter.ts +0 -29
  38. package/src/contexts/actionsContext.js +0 -54
  39. package/src/contexts/translationContext.js +0 -29
  40. package/src/mapper/Mapper.js +0 -141
  41. package/src/mapper/modules/policy/index.js +0 -613
  42. package/src/mapper/modules/quotation/index.js +0 -480
  43. package/src/public/index.html +0 -15
  44. package/src/public/index.js +0 -9
  45. package/test/script.js +0 -0
  46. package/tsconfig.json +0 -9
@@ -1,63 +0,0 @@
1
- const path = require("path");
2
- const pkg = require("../package.json");
3
- const nodeExternals = require("webpack-node-externals");
4
- const Dotenv = require("dotenv-webpack");
5
- const webpack = require("webpack");
6
-
7
- module.exports = {
8
- mode: "development",
9
- entry: "./index.ts",
10
- output: {
11
- path: path.resolve(__dirname, "dist"),
12
- filename: "index.ts",
13
- libraryTarget: "commonjs2",
14
- },
15
- resolve: {
16
- extensions: [".tsx", ".ts", ".jsx", ".js", ".json"],
17
- fallback: {
18
- path: require.resolve("path-browserify"),
19
- os: require.resolve("os-browserify/browser"),
20
- fs: false,
21
- crypto: false,
22
- process: require.resolve("process/browser.js"),
23
- },
24
- },
25
- module: {
26
- rules: [
27
- {
28
- test: /\.(js|jsx)$/,
29
- exclude: /node_modules/,
30
- use: {
31
- loader: "babel-loader",
32
- },
33
- },
34
- {
35
- test: /\.css$/i,
36
- use: ["style-loader", "css-loader"],
37
- },
38
- {
39
- test: /\.svg$/i,
40
- use: {
41
- loader: "svg-url-loader",
42
- },
43
- },
44
- {
45
- test: /\.ts$/,
46
- use: 'ts-loader',
47
- exclude: /node_modules/,
48
- },
49
- ],
50
- },
51
- plugins: [
52
- new Dotenv({
53
- path: path.resolve(__dirname, "../.env"),
54
- systemvars: true,
55
- safe: true,
56
- }),
57
- new webpack.ProvidePlugin({
58
- process: "process/browser",
59
- }),
60
- ],
61
- target: "web",
62
- externals: [nodeExternals()],
63
- };
@@ -1,63 +0,0 @@
1
- const path = require("path");
2
- const pkg = require("../package.json");
3
- const nodeExternals = require("webpack-node-externals");
4
- const Dotenv = require("dotenv-webpack");
5
- const webpack = require("webpack");
6
-
7
- module.exports = {
8
- mode: "production",
9
- entry: "./index.ts",
10
- output: {
11
- path: path.resolve(__dirname, "dist"),
12
- filename: "index.ts",
13
- libraryTarget: "commonjs2",
14
- },
15
- resolve: {
16
- extensions: [".tsx", ".ts", ".jsx", ".js", ".json"],
17
- fallback: {
18
- path: require.resolve("path-browserify"),
19
- os: require.resolve("os-browserify/browser"),
20
- fs: false,
21
- crypto: false,
22
- process: require.resolve("process/browser"),
23
- },
24
- },
25
- module: {
26
- rules: [
27
- {
28
- test: /\.(js|jsx)$/,
29
- exclude: /node_modules/,
30
- use: {
31
- loader: "babel-loader",
32
- },
33
- },
34
- {
35
- test: /\.css$/i,
36
- use: ["style-loader", "css-loader"],
37
- },
38
- {
39
- test: /\.svg$/i,
40
- use: {
41
- loader: "svg-url-loader",
42
- },
43
- },
44
- {
45
- test: /\.ts$/,
46
- use: 'ts-loader',
47
- exclude: /node_modules/,
48
- },
49
- ],
50
- },
51
- plugins: [
52
- new Dotenv({
53
- path: path.resolve(__dirname, "../.env"),
54
- systemvars: true,
55
- safe: true,
56
- }),
57
- new webpack.ProvidePlugin({
58
- process: "process/browser",
59
- }),
60
- ],
61
- target: "node",
62
- externals: [nodeExternals()],
63
- };
package/index.d.ts DELETED
@@ -1,5 +0,0 @@
1
- import type { Api } from './src/adapters/createApiAdapter';
2
-
3
- export {
4
- Api
5
- };
package/services.js DELETED
@@ -1,105 +0,0 @@
1
- import { AxiosError } from "axios";
2
- import axiosInstance from "./axiosInstance";
3
- import { methods, services } from "./servicesData";
4
- // import {
5
- // openNotificationWithIcon,
6
- // TYPE,
7
- // } from "./src/components/notificationToast";
8
-
9
- const handleApiError = (service, e) => {
10
- try {
11
- const errorToDisplay = {
12
- title: "",
13
- errors: [],
14
- };
15
-
16
- if (!(e instanceof AxiosError)) {
17
- errorToDisplay.title = e.message;
18
- } else {
19
- const error = e.response;
20
- const statusError = error.status;
21
- const modulesInfo = JSON.parse(localStorage.getItem("modules_info"));
22
-
23
- var translationInfo = modulesInfo
24
- .find((m) => m.code === service.module)
25
- ?.services?.find(
26
- (s) =>
27
- s.name.toUpperCase() === service.serviceName.toUpperCase() &&
28
- s.httpMethod.toUpperCase() === service.method.toUpperCase()
29
- )
30
- ?.errors.find((e) => e.httpStatus === statusError);
31
-
32
- errorToDisplay.title = translationInfo?.content || error.data.message;
33
-
34
- const subErrorTranslations = error.data.errorMessages?.map((err) => {
35
- const translatedSubError = translationInfo?.subErrors?.find(
36
- (s) => s.errorType === err.fieldError && s.fieldName === err.fieldName
37
- );
38
- return translatedSubError?.content || err?.error;
39
- });
40
- errorToDisplay.errors = subErrorTranslations || [];
41
- }
42
-
43
- // openNotificationWithIcon(
44
- // TYPE.ERROR,
45
- // "",
46
- // errorToDisplay.title,
47
- // errorToDisplay.errors
48
- // );
49
- } catch (e) {
50
- console.error(e);
51
- throw e;
52
- }
53
- };
54
-
55
- const getUrl = (serviceUrl, routeParams) => {
56
- if (!routeParams) return serviceUrl;
57
- return serviceUrl.replace(/{(\d+)}/g, function (match, routeParamNumber) {
58
- return routeParams[routeParamNumber]
59
- ? routeParams[routeParamNumber]
60
- : match;
61
- });
62
- };
63
-
64
- export const formatNumberES = (n, d = 0) => {
65
- n = new Intl.NumberFormat("de-DE").format(parseFloat(n)?.toFixed(d));
66
- if (d > 0) {
67
- const decimals = n.indexOf(",") > -1 ? n.length - 1 - n.indexOf(",") : 0;
68
-
69
- n = decimals == 0 ? n + "," + "0".repeat(d) : n + "0".repeat(d - decimals);
70
- }
71
- return n;
72
- };
73
-
74
- export const apiCall = async (endpoint, routeParams, params = null) => {
75
- const service = services.find((s) => s.endpoint === endpoint);
76
- try {
77
- if (!service) throw new Error("Service does not exists");
78
-
79
- const url = getUrl(service.url, routeParams);
80
-
81
- let response;
82
- switch (service.method) {
83
- case methods.GET:
84
- response = await axiosInstance.get(url, { params });
85
- return response.data;
86
- case methods.POST:
87
- response = await axiosInstance.post(url, params);
88
- return response.data;
89
- case methods.PUT:
90
- response = await axiosInstance.put(url, params);
91
- return response.data;
92
- case methods.DELETE:
93
- response = await axiosInstance.delete(url, params);
94
- return response.data;
95
- default:
96
- response = null;
97
- throw new Error(
98
- "Request error: Method not allowed. Only use GET, POST, PUT, DELETE"
99
- );
100
- }
101
- } catch (e) {
102
- handleApiError(service, e);
103
- throw e;
104
- }
105
- };