@remyar/tecdoc_client 0.0.1 → 0.0.3
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/index.js +11 -0
- package/lib/api/post.js +116 -0
- package/lib/tecdoc/getAmBrands.js +9 -8
- package/package.json +10 -11
- package/rollup.config.mjs +42 -91
- package/src/api/index.js +5 -0
- package/src/api/post.js +40 -0
- package/src/tecdoc/getAmBrands.js +10 -10
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/index.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault")["default"];
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports["default"] = void 0;
|
|
8
|
+
var _post = _interopRequireDefault(require("./post"));
|
|
9
|
+
var _default = exports["default"] = {
|
|
10
|
+
post: _post["default"]
|
|
11
|
+
};
|
package/lib/api/post.js
ADDED
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault")["default"];
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports["default"] = _default;
|
|
8
|
+
var _regenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/regenerator"));
|
|
9
|
+
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
10
|
+
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
11
|
+
var _nodeFetch = _interopRequireDefault(require("node-fetch"));
|
|
12
|
+
function _default(_x, _x2) {
|
|
13
|
+
return _ref.apply(this, arguments);
|
|
14
|
+
}
|
|
15
|
+
function _ref() {
|
|
16
|
+
_ref = (0, _asyncToGenerator2["default"])(/*#__PURE__*/(0, _regenerator2["default"])().m(function _callee4(url, params) {
|
|
17
|
+
return (0, _regenerator2["default"])().w(function (_context4) {
|
|
18
|
+
while (1) switch (_context4.n) {
|
|
19
|
+
case 0:
|
|
20
|
+
return _context4.a(2, new Promise(/*#__PURE__*/function () {
|
|
21
|
+
var _ref2 = (0, _asyncToGenerator2["default"])(/*#__PURE__*/(0, _regenerator2["default"])().m(function _callee3(resolve, reject) {
|
|
22
|
+
var headers, _retry, _retry2, _t2, _t3, _t4, _t5;
|
|
23
|
+
return (0, _regenerator2["default"])().w(function (_context3) {
|
|
24
|
+
while (1) switch (_context3.p = _context3.n) {
|
|
25
|
+
case 0:
|
|
26
|
+
_retry2 = function _retry4() {
|
|
27
|
+
_retry2 = (0, _asyncToGenerator2["default"])(/*#__PURE__*/(0, _regenerator2["default"])().m(function _callee2() {
|
|
28
|
+
return (0, _regenerator2["default"])().w(function (_context2) {
|
|
29
|
+
while (1) switch (_context2.n) {
|
|
30
|
+
case 0:
|
|
31
|
+
return _context2.a(2, new Promise(/*#__PURE__*/function () {
|
|
32
|
+
var _ref3 = (0, _asyncToGenerator2["default"])(/*#__PURE__*/(0, _regenerator2["default"])().m(function _callee(resolve, reject) {
|
|
33
|
+
var result, r, _t;
|
|
34
|
+
return (0, _regenerator2["default"])().w(function (_context) {
|
|
35
|
+
while (1) switch (_context.p = _context.n) {
|
|
36
|
+
case 0:
|
|
37
|
+
_context.p = 0;
|
|
38
|
+
_context.n = 1;
|
|
39
|
+
return (0, _nodeFetch["default"])(url, {
|
|
40
|
+
method: 'POST',
|
|
41
|
+
body: JSON.stringify(obj),
|
|
42
|
+
headers: headers,
|
|
43
|
+
credentials: "same-origin",
|
|
44
|
+
useSessionCookies: true
|
|
45
|
+
});
|
|
46
|
+
case 1:
|
|
47
|
+
result = _context.v;
|
|
48
|
+
_context.n = 2;
|
|
49
|
+
return result.json();
|
|
50
|
+
case 2:
|
|
51
|
+
r = _context.v;
|
|
52
|
+
resolve(r);
|
|
53
|
+
_context.n = 4;
|
|
54
|
+
break;
|
|
55
|
+
case 3:
|
|
56
|
+
_context.p = 3;
|
|
57
|
+
_t = _context.v;
|
|
58
|
+
reject(_t);
|
|
59
|
+
case 4:
|
|
60
|
+
return _context.a(2);
|
|
61
|
+
}
|
|
62
|
+
}, _callee, null, [[0, 3]]);
|
|
63
|
+
}));
|
|
64
|
+
return function (_x5, _x6) {
|
|
65
|
+
return _ref3.apply(this, arguments);
|
|
66
|
+
};
|
|
67
|
+
}()));
|
|
68
|
+
}
|
|
69
|
+
}, _callee2);
|
|
70
|
+
}));
|
|
71
|
+
return _retry2.apply(this, arguments);
|
|
72
|
+
};
|
|
73
|
+
_retry = function _retry3() {
|
|
74
|
+
return _retry2.apply(this, arguments);
|
|
75
|
+
};
|
|
76
|
+
headers = {};
|
|
77
|
+
if (obj.headers != undefined) {
|
|
78
|
+
headers = (0, _objectSpread2["default"])({}, obj.headers);
|
|
79
|
+
}
|
|
80
|
+
_context3.p = 1;
|
|
81
|
+
_t2 = resolve;
|
|
82
|
+
_context3.n = 2;
|
|
83
|
+
return _retry();
|
|
84
|
+
case 2:
|
|
85
|
+
_t2(_context3.v);
|
|
86
|
+
_context3.n = 7;
|
|
87
|
+
break;
|
|
88
|
+
case 3:
|
|
89
|
+
_context3.p = 3;
|
|
90
|
+
_t3 = _context3.v;
|
|
91
|
+
_context3.p = 4;
|
|
92
|
+
_t4 = resolve;
|
|
93
|
+
_context3.n = 5;
|
|
94
|
+
return _retry();
|
|
95
|
+
case 5:
|
|
96
|
+
_t4(_context3.v);
|
|
97
|
+
_context3.n = 7;
|
|
98
|
+
break;
|
|
99
|
+
case 6:
|
|
100
|
+
_context3.p = 6;
|
|
101
|
+
_t5 = _context3.v;
|
|
102
|
+
reject(_t5);
|
|
103
|
+
case 7:
|
|
104
|
+
return _context3.a(2);
|
|
105
|
+
}
|
|
106
|
+
}, _callee3, null, [[4, 6], [1, 3]]);
|
|
107
|
+
}));
|
|
108
|
+
return function (_x3, _x4) {
|
|
109
|
+
return _ref2.apply(this, arguments);
|
|
110
|
+
};
|
|
111
|
+
}()));
|
|
112
|
+
}
|
|
113
|
+
}, _callee4);
|
|
114
|
+
}));
|
|
115
|
+
return _ref.apply(this, arguments);
|
|
116
|
+
}
|
|
@@ -7,6 +7,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
exports["default"] = _default;
|
|
8
8
|
var _regenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/regenerator"));
|
|
9
9
|
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
10
|
+
var _api = _interopRequireDefault(require("../api"));
|
|
10
11
|
function _default(_x) {
|
|
11
12
|
return _ref.apply(this, arguments);
|
|
12
13
|
}
|
|
@@ -23,15 +24,15 @@ function _ref() {
|
|
|
23
24
|
case 0:
|
|
24
25
|
_context.p = 0;
|
|
25
26
|
_context.n = 1;
|
|
26
|
-
return
|
|
27
|
+
return _api["default"].post(process.env.TECDOC_API_URL, {
|
|
27
28
|
getBrands: {
|
|
28
|
-
"articleCountry":
|
|
29
|
-
"lang":
|
|
30
|
-
"provider":
|
|
31
|
-
"includeAll":
|
|
32
|
-
"includeAddressDetails":
|
|
33
|
-
"includeDataSupplierStatus":
|
|
34
|
-
"includeDataSupplierLogo":
|
|
29
|
+
"articleCountry": params.articleCountry || "FR",
|
|
30
|
+
"lang": params.lang || "FR",
|
|
31
|
+
"provider": params.provider ? params.provider : process.env.TECDOC_PROVIDER_ID,
|
|
32
|
+
"includeAll": params.includeAll || false,
|
|
33
|
+
"includeAddressDetails": params.includeAddressDetails || false,
|
|
34
|
+
"includeDataSupplierStatus": params.includeDataSupplierStatus || false,
|
|
35
|
+
"includeDataSupplierLogo": params.includeDataSupplierLogo || false
|
|
35
36
|
}
|
|
36
37
|
});
|
|
37
38
|
case 1:
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@remyar/tecdoc_client",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.3",
|
|
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
|
+
);
|
package/src/api/index.js
ADDED
package/src/api/post.js
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import fetch from 'node-fetch';
|
|
2
|
+
|
|
3
|
+
export default async function (url, params) {
|
|
4
|
+
return new Promise(async (resolve, reject) => {
|
|
5
|
+
let headers = {};
|
|
6
|
+
if (obj.headers != undefined) {
|
|
7
|
+
headers = { ...obj.headers };
|
|
8
|
+
}
|
|
9
|
+
async function _retry() {
|
|
10
|
+
return new Promise(async (resolve, reject) => {
|
|
11
|
+
try {
|
|
12
|
+
let result = await fetch(url,
|
|
13
|
+
{
|
|
14
|
+
method: 'POST',
|
|
15
|
+
body: JSON.stringify(obj),
|
|
16
|
+
headers,
|
|
17
|
+
credentials: "same-origin",
|
|
18
|
+
useSessionCookies: true
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
const r = await result.json()
|
|
22
|
+
resolve(r);
|
|
23
|
+
} catch (err) {
|
|
24
|
+
reject(err);
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
try {
|
|
31
|
+
resolve(await _retry());
|
|
32
|
+
} catch (err) {
|
|
33
|
+
try {
|
|
34
|
+
resolve(await _retry());
|
|
35
|
+
} catch (err) {
|
|
36
|
+
reject(err);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
}
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
|
|
1
|
+
import api from '../api';
|
|
2
2
|
|
|
3
3
|
export default async function ( params ) {
|
|
4
4
|
return new Promise(async(resolve , reject) => {
|
|
5
5
|
try {
|
|
6
|
-
let result = await api.post(process.env.
|
|
6
|
+
let result = await api.post(process.env.TECDOC_API_URL, {
|
|
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);
|
|
@@ -19,4 +19,4 @@ export default async function ( params ) {
|
|
|
19
19
|
reject(err);
|
|
20
20
|
}
|
|
21
21
|
})
|
|
22
|
-
}
|
|
22
|
+
}
|