@remyar/tecdoc_client 0.0.2 → 0.0.4
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/.scripts/build.mjs +1 -0
- package/lib/api/post.js +2 -1
- package/lib/tecdoc/getAmBrands.js +13 -10
- package/package.json +10 -11
- package/rollup.config.mjs +42 -91
- package/src/api/config.js +10 -0
- package/src/api/post.js +10 -6
- package/src/index.js +5 -1
- package/src/tecdoc/getAmBrands.js +11 -11
- package/src/tecdoc/getVersion.js +16 -0
package/.scripts/build.mjs
CHANGED
|
@@ -22,6 +22,7 @@ console.log(chalk.blue('Building js'))
|
|
|
22
22
|
await $`cross-env NODE_ENV=production rollup -c`
|
|
23
23
|
|
|
24
24
|
console.log(chalk.blue(`Compiling 'lib' js files`))
|
|
25
|
+
|
|
25
26
|
// build files used for overrides
|
|
26
27
|
await $`cross-env NODE_ENV=production RBC_CJS_BUILD=true babel src --out-dir lib`
|
|
27
28
|
|
package/lib/api/post.js
CHANGED
|
@@ -8,6 +8,7 @@ exports["default"] = _default;
|
|
|
8
8
|
var _regenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/regenerator"));
|
|
9
9
|
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
10
10
|
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
11
|
+
var _nodeFetch = _interopRequireDefault(require("node-fetch"));
|
|
11
12
|
function _default(_x, _x2) {
|
|
12
13
|
return _ref.apply(this, arguments);
|
|
13
14
|
}
|
|
@@ -35,7 +36,7 @@ function _ref() {
|
|
|
35
36
|
case 0:
|
|
36
37
|
_context.p = 0;
|
|
37
38
|
_context.n = 1;
|
|
38
|
-
return
|
|
39
|
+
return (0, _nodeFetch["default"])(url, {
|
|
39
40
|
method: 'POST',
|
|
40
41
|
body: JSON.stringify(obj),
|
|
41
42
|
headers: headers,
|
|
@@ -8,14 +8,17 @@ exports["default"] = _default;
|
|
|
8
8
|
var _regenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/regenerator"));
|
|
9
9
|
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
10
10
|
var _api = _interopRequireDefault(require("../api"));
|
|
11
|
-
function _default(
|
|
11
|
+
function _default() {
|
|
12
12
|
return _ref.apply(this, arguments);
|
|
13
13
|
}
|
|
14
14
|
function _ref() {
|
|
15
|
-
_ref = (0, _asyncToGenerator2["default"])(/*#__PURE__*/(0, _regenerator2["default"])().m(function _callee2(
|
|
15
|
+
_ref = (0, _asyncToGenerator2["default"])(/*#__PURE__*/(0, _regenerator2["default"])().m(function _callee2() {
|
|
16
|
+
var params,
|
|
17
|
+
_args2 = arguments;
|
|
16
18
|
return (0, _regenerator2["default"])().w(function (_context2) {
|
|
17
19
|
while (1) switch (_context2.n) {
|
|
18
20
|
case 0:
|
|
21
|
+
params = _args2.length > 0 && _args2[0] !== undefined ? _args2[0] : {};
|
|
19
22
|
return _context2.a(2, new Promise(/*#__PURE__*/function () {
|
|
20
23
|
var _ref2 = (0, _asyncToGenerator2["default"])(/*#__PURE__*/(0, _regenerator2["default"])().m(function _callee(resolve, reject) {
|
|
21
24
|
var result, _t;
|
|
@@ -26,13 +29,13 @@ function _ref() {
|
|
|
26
29
|
_context.n = 1;
|
|
27
30
|
return _api["default"].post(process.env.TECDOC_API_URL, {
|
|
28
31
|
getBrands: {
|
|
29
|
-
"articleCountry":
|
|
30
|
-
"lang":
|
|
31
|
-
"provider":
|
|
32
|
-
"includeAll":
|
|
33
|
-
"includeAddressDetails":
|
|
34
|
-
"includeDataSupplierStatus":
|
|
35
|
-
"includeDataSupplierLogo":
|
|
32
|
+
"articleCountry": (params === null || params === void 0 ? void 0 : params.articleCountry) || "FR",
|
|
33
|
+
"lang": (params === null || params === void 0 ? void 0 : params.lang) || "FR",
|
|
34
|
+
"provider": params !== null && params !== void 0 && params.provider ? params === null || params === void 0 ? void 0 : params.provider : process.env.TECDOC_PROVIDER_ID,
|
|
35
|
+
"includeAll": (params === null || params === void 0 ? void 0 : params.includeAll) || false,
|
|
36
|
+
"includeAddressDetails": (params === null || params === void 0 ? void 0 : params.includeAddressDetails) || false,
|
|
37
|
+
"includeDataSupplierStatus": (params === null || params === void 0 ? void 0 : params.includeDataSupplierStatus) || false,
|
|
38
|
+
"includeDataSupplierLogo": (params === null || params === void 0 ? void 0 : params.includeDataSupplierLogo) || false
|
|
36
39
|
}
|
|
37
40
|
});
|
|
38
41
|
case 1:
|
|
@@ -49,7 +52,7 @@ function _ref() {
|
|
|
49
52
|
}
|
|
50
53
|
}, _callee, null, [[0, 2]]);
|
|
51
54
|
}));
|
|
52
|
-
return function (
|
|
55
|
+
return function (_x, _x2) {
|
|
53
56
|
return _ref2.apply(this, arguments);
|
|
54
57
|
};
|
|
55
58
|
}()));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@remyar/tecdoc_client",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.4",
|
|
4
4
|
"description": "Client For Tecdoc",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"module": "dist/index.esm.js",
|
|
@@ -22,23 +22,22 @@
|
|
|
22
22
|
"client"
|
|
23
23
|
],
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@babel/cli": "^7.28.6",
|
|
26
|
-
"@rollup/plugin-commonjs": "^29.0.0",
|
|
27
25
|
"@rollup/plugin-babel": "^6.1.0",
|
|
28
|
-
"@
|
|
29
|
-
"@babel/plugin-transform-runtime": "^7.28.5",
|
|
30
|
-
"@rollup/plugin-replace": "^6.0.3",
|
|
26
|
+
"@rollup/plugin-commonjs": "^29.0.0",
|
|
31
27
|
"@rollup/plugin-node-resolve": "^16.0.3",
|
|
32
|
-
"@
|
|
33
|
-
"@babel/plugin-proposal-class-properties": "^7.18.6",
|
|
34
|
-
"@babel/plugin-proposal-private-property-in-object": "^7.21.11",
|
|
28
|
+
"@rollup/plugin-replace": "^6.0.3",
|
|
35
29
|
"babel-plugin-transform-react-remove-prop-types": "^0.4.24",
|
|
36
|
-
"rollup-plugin-clear": "^2.0.7",
|
|
37
|
-
"rollup-plugin-terser": "^7.0.2",
|
|
38
30
|
"babel-preset-react-app": "^10.1.0",
|
|
39
31
|
"cross-env": "^10.1.0",
|
|
40
32
|
"is-ci": "^4.1.0",
|
|
33
|
+
"node-fetch": "^3.3.2",
|
|
41
34
|
"rollup": "^4.57.0",
|
|
35
|
+
"rollup-plugin-clear": "^2.0.7",
|
|
36
|
+
"rollup-plugin-peer-deps-external": "^2.2.4",
|
|
37
|
+
"rollup-plugin-terser": "^7.0.2",
|
|
42
38
|
"zx": "^8.8.5"
|
|
39
|
+
},
|
|
40
|
+
"devDependencies": {
|
|
41
|
+
"@babel/cli": "^7.28.6"
|
|
43
42
|
}
|
|
44
43
|
}
|
package/rollup.config.mjs
CHANGED
|
@@ -1,94 +1,45 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import babel from '@rollup/plugin-babel';
|
|
1
|
+
import { readFileSync } from 'fs';
|
|
2
|
+
import { defineConfig } from 'rollup';
|
|
3
|
+
import resolve from '@rollup/plugin-node-resolve';
|
|
5
4
|
import commonjs from '@rollup/plugin-commonjs';
|
|
6
|
-
import
|
|
7
|
-
import clear from 'rollup-plugin-clear'
|
|
8
|
-
|
|
9
|
-
import
|
|
10
|
-
import
|
|
5
|
+
import external from 'rollup-plugin-peer-deps-external';
|
|
6
|
+
import clear from 'rollup-plugin-clear' // Cleans the `dist` folder before each build
|
|
7
|
+
import { nodeResolve } from '@rollup/plugin-node-resolve' // Allows Rollup to resolve modules from node_modules
|
|
8
|
+
import babel from '@rollup/plugin-babel' // Transpiles modern JavaScript code
|
|
9
|
+
import { terser } from 'rollup-plugin-terser' // Minifies the final output
|
|
11
10
|
|
|
12
|
-
const
|
|
11
|
+
const packageJson = JSON.parse(readFileSync('./package.json'));
|
|
13
12
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
}),
|
|
48
|
-
replace({
|
|
49
|
-
'process.env.NODE_ENV': JSON.stringify('development'),
|
|
50
|
-
preventAssignment: true,
|
|
51
|
-
}),
|
|
52
|
-
nodeResolve(),
|
|
53
|
-
commonjs(commonjsOptions),
|
|
54
|
-
babel(babelOptions),
|
|
55
|
-
],
|
|
56
|
-
},
|
|
57
|
-
{
|
|
58
|
-
input,
|
|
59
|
-
output: {
|
|
60
|
-
file: './dist/index.min.js',
|
|
61
|
-
format: 'umd',
|
|
62
|
-
name,
|
|
63
|
-
globals,
|
|
64
|
-
interop: 'auto',
|
|
65
|
-
},
|
|
66
|
-
external: Object.keys(globals).push(/@babel\/runtime/),
|
|
67
|
-
plugins: [
|
|
68
|
-
replace({
|
|
69
|
-
'process.env.NODE_ENV': JSON.stringify('production'),
|
|
70
|
-
preventAssignment: true,
|
|
71
|
-
}),
|
|
72
|
-
nodeResolve(),
|
|
73
|
-
commonjs(commonjsOptions),
|
|
74
|
-
babel(babelOptions),
|
|
75
|
-
terser(),
|
|
76
|
-
],
|
|
77
|
-
},
|
|
78
|
-
{
|
|
79
|
-
input,
|
|
80
|
-
output: {
|
|
81
|
-
file: pkg.module,
|
|
82
|
-
format: 'esm',
|
|
83
|
-
interop: 'auto',
|
|
84
|
-
},
|
|
85
|
-
// prevent bundling all dependencies
|
|
86
|
-
external: (id) => !id.startsWith('.') && !id.startsWith('/'),
|
|
87
|
-
plugins: [
|
|
88
|
-
babel({
|
|
89
|
-
...babelOptions,
|
|
90
|
-
configFile: path.join(__dirname, 'babel.config.esm.js'),
|
|
91
|
-
}),
|
|
92
|
-
],
|
|
93
|
-
},
|
|
94
|
-
]
|
|
13
|
+
export default defineConfig(
|
|
14
|
+
{
|
|
15
|
+
// CJS & ESM Bundle Configuration
|
|
16
|
+
input: 'src/index.js', // Entry point for CommonJS and ESM builds
|
|
17
|
+
output: [
|
|
18
|
+
{
|
|
19
|
+
dir: 'dist/cjs', // Output directory for CommonJS format
|
|
20
|
+
format: 'cjs', // CommonJS format (for Node.js)
|
|
21
|
+
preserveModules: true, // Keep the original module structure
|
|
22
|
+
exports: 'auto', // Auto-detect export style
|
|
23
|
+
sourcemap: true // Enable sourcemap
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
dir: 'dist/esm', // Output directory for ESM format
|
|
27
|
+
format: 'es', // ES Module format
|
|
28
|
+
preserveModules: true, // Keep the original module structure
|
|
29
|
+
exports: 'auto', // Auto-detect export style
|
|
30
|
+
sourcemap: true // Enable sourcemap
|
|
31
|
+
}
|
|
32
|
+
],
|
|
33
|
+
plugins: [
|
|
34
|
+
clear({ targets: ['dist/cjs', 'dist/esm'] }),
|
|
35
|
+
nodeResolve(),
|
|
36
|
+
commonjs(),
|
|
37
|
+
babel({
|
|
38
|
+
exclude: 'node_modules/**',
|
|
39
|
+
babelHelpers: 'runtime',
|
|
40
|
+
plugins: ['@babel/plugin-transform-runtime']
|
|
41
|
+
}),
|
|
42
|
+
terser()
|
|
43
|
+
]
|
|
44
|
+
}
|
|
45
|
+
);
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
|
|
2
|
+
let _provider_ = undefined;
|
|
3
|
+
|
|
4
|
+
export default {
|
|
5
|
+
apiUrl: () => { return "https://webservice.tecalliance.services/pegasus-3-0/info/proxy/services/TecdocToCatDLW.jsonEndpoint" },
|
|
6
|
+
setProvider: (_provider) => {
|
|
7
|
+
_provider_ = _provider;
|
|
8
|
+
},
|
|
9
|
+
getProvider: () => { return _provider_ }
|
|
10
|
+
}
|
package/src/api/post.js
CHANGED
|
@@ -1,16 +1,20 @@
|
|
|
1
|
-
|
|
1
|
+
import fetch from 'node-fetch';
|
|
2
|
+
import config from './config';
|
|
3
|
+
|
|
4
|
+
export default async function ( params) {
|
|
2
5
|
return new Promise(async (resolve, reject) => {
|
|
3
|
-
|
|
4
|
-
if (
|
|
5
|
-
|
|
6
|
+
|
|
7
|
+
if ( config.getProvider() != undefined){
|
|
8
|
+
params.provider = config.getProvider();
|
|
6
9
|
}
|
|
10
|
+
|
|
7
11
|
async function _retry() {
|
|
8
12
|
return new Promise(async (resolve, reject) => {
|
|
9
13
|
try {
|
|
10
|
-
let result = await fetch(
|
|
14
|
+
let result = await fetch(config.apiUrl(),
|
|
11
15
|
{
|
|
12
16
|
method: 'POST',
|
|
13
|
-
body: JSON.stringify(
|
|
17
|
+
body: JSON.stringify(params),
|
|
14
18
|
headers,
|
|
15
19
|
credentials: "same-origin",
|
|
16
20
|
useSessionCookies: true
|
package/src/index.js
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
import api from '../api';
|
|
2
2
|
|
|
3
|
-
export default async function (
|
|
4
|
-
return new Promise(async(resolve
|
|
3
|
+
export default async function (params = {}) {
|
|
4
|
+
return new Promise(async (resolve, reject) => {
|
|
5
5
|
try {
|
|
6
|
-
let result = await api.post(
|
|
6
|
+
let result = await api.post({
|
|
7
7
|
getBrands: {
|
|
8
|
-
"articleCountry":
|
|
9
|
-
"lang":
|
|
10
|
-
"provider":
|
|
11
|
-
"includeAll":
|
|
12
|
-
"includeAddressDetails":
|
|
13
|
-
"includeDataSupplierStatus":
|
|
14
|
-
"includeDataSupplierLogo":
|
|
8
|
+
"articleCountry": params?.articleCountry || "FR",
|
|
9
|
+
"lang": params?.lang || "FR",
|
|
10
|
+
"provider": params?.provider ? params?.provider : process.env.TECDOC_PROVIDER_ID,
|
|
11
|
+
"includeAll": params?.includeAll || false,
|
|
12
|
+
"includeAddressDetails": params?.includeAddressDetails || false,
|
|
13
|
+
"includeDataSupplierStatus": params?.includeDataSupplierStatus || false,
|
|
14
|
+
"includeDataSupplierLogo": params?.includeDataSupplierLogo || false
|
|
15
15
|
}
|
|
16
16
|
});
|
|
17
17
|
resolve(result);
|
|
18
18
|
} catch (err) {
|
|
19
19
|
reject(err);
|
|
20
20
|
}
|
|
21
|
-
})
|
|
21
|
+
})
|
|
22
22
|
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import api from '../api';
|
|
2
|
+
|
|
3
|
+
export default async function ( params = {} ) {
|
|
4
|
+
return new Promise(async(resolve , reject) => {
|
|
5
|
+
try {
|
|
6
|
+
let result = await api.post({
|
|
7
|
+
getVersion: {
|
|
8
|
+
"provider": params?.provider ? params?.provider : process.env.TECDOC_PROVIDER_ID,
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
resolve(result);
|
|
12
|
+
} catch (err) {
|
|
13
|
+
reject(err);
|
|
14
|
+
}
|
|
15
|
+
})
|
|
16
|
+
}
|