sysone-api-mapper 1.0.148 → 1.0.150

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 (60) hide show
  1. package/dist/axiosInstance.d.ts +2 -1
  2. package/dist/axiosInstance.js +10 -0
  3. package/dist/index.d.ts +2 -2
  4. package/dist/index.js +20 -0
  5. package/dist/services.js +100 -0
  6. package/dist/servicesData.js +999 -0
  7. package/dist/src/adapters/createApiAdapter.d.ts +1 -0
  8. package/dist/src/adapters/createApiAdapter.js +12 -0
  9. package/dist/src/adapters/financeAdapter.d.ts +1 -0
  10. package/dist/src/adapters/financeAdapter.js +9 -0
  11. package/dist/src/adapters/locationAdapter.js +9 -0
  12. package/dist/src/adapters/partyAdapter.js +11 -0
  13. package/{src → dist/src}/components/notificationToast.js +35 -37
  14. package/dist/src/contexts/actionsContext.js +80 -0
  15. package/dist/src/contexts/apiContext.js +12 -0
  16. package/dist/src/contexts/translationContext.js +56 -0
  17. package/dist/src/mapper/Mapper.js +106 -0
  18. package/{src → dist/src}/mapper/endpointsConfig.js +824 -915
  19. package/dist/src/mapper/helpers/mappingHelpers.js +30 -0
  20. package/dist/src/mapper/modules/billing/index.js +136 -0
  21. package/dist/src/mapper/modules/claim/index.js +19 -0
  22. package/dist/src/mapper/modules/general/index.js +11 -0
  23. package/dist/src/mapper/modules/party/index.js +131 -0
  24. package/dist/src/mapper/modules/policy/index.js +592 -0
  25. package/dist/src/mapper/modules/quotation/index.js +494 -0
  26. package/{src → dist/src}/mapper/modules/request/index.js +65 -67
  27. package/dist/src/public/index.js +7 -0
  28. package/{src → dist/src}/server.js +18 -23
  29. package/package.json +3 -3
  30. package/.babelrc +0 -4
  31. package/.gitlab-ci.yml +0 -42
  32. package/axiosInstance.js +0 -7
  33. package/config/dist/index.js +0 -307
  34. package/config/dist/index.js.LICENSE.txt +0 -1
  35. package/config/dist/index.ts +0 -319
  36. package/config/webpack.dev.js +0 -63
  37. package/config/webpack.prod.js +0 -63
  38. package/index.d.ts +0 -5
  39. package/index.ts +0 -20
  40. package/services.js +0 -105
  41. package/servicesData.js +0 -1013
  42. package/src/adapters/createApiAdapter.ts +0 -29
  43. package/src/adapters/financeAdapter.js +0 -5
  44. package/src/adapters/locationAdapter.js +0 -6
  45. package/src/adapters/partyAdapter.js +0 -8
  46. package/src/contexts/actionsContext.js +0 -54
  47. package/src/contexts/apiContext.js +0 -9
  48. package/src/contexts/translationContext.js +0 -29
  49. package/src/mapper/Mapper.js +0 -141
  50. package/src/mapper/helpers/mappingHelpers.js +0 -26
  51. package/src/mapper/modules/billing/index.js +0 -131
  52. package/src/mapper/modules/claim/index.js +0 -17
  53. package/src/mapper/modules/general/index.js +0 -7
  54. package/src/mapper/modules/party/index.js +0 -128
  55. package/src/mapper/modules/policy/index.js +0 -613
  56. package/src/mapper/modules/quotation/index.js +0 -480
  57. package/src/public/index.html +0 -15
  58. package/src/public/index.js +0 -9
  59. package/test/script.js +0 -0
  60. 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/index.ts DELETED
@@ -1,20 +0,0 @@
1
- import { apiCall } from "./services";
2
- import { endpoints } from "./servicesData";
3
- import axiosInstance from "./axiosInstance";
4
- import { configureApiMapper, apiMapper } from "./src/mapper/Mapper";
5
- import { ApiContext, useApi } from "./src/contexts/apiContext";
6
- import { createApiAdapter } from "./src/adapters/createApiAdapter"
7
- import type { Api } from './src/adapters/createApiAdapter';
8
-
9
-
10
- export {
11
- apiCall,
12
- apiMapper,
13
- endpoints,
14
- axiosInstance,
15
- configureApiMapper,
16
- ApiContext,
17
- useApi,
18
- createApiAdapter,
19
- Api
20
- };
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
- };