@remyar/tecdoc_client 0.0.1

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.
@@ -0,0 +1,28 @@
1
+ #!/usr/bin/env zx
2
+ import isCI from 'is-ci'
3
+ import { usePowerShell } from 'zx'
4
+
5
+ if (process.platform === 'win32') {
6
+ usePowerShell() // now `$.shell` refers to pwsh and `$.postfix` set to '; exit $LastExitCode'
7
+ }
8
+
9
+ const {
10
+ b = isCI, // pass `-b` to build if you want it to run browserslist update outside of CI environment
11
+ } = argv
12
+
13
+ if (b) {
14
+ // Update browserslist
15
+ await $`npx update-browserslist-db@latest`
16
+ }
17
+
18
+ console.log(chalk.blue('[BEGIN BUILD]'))
19
+ console.log(chalk.blue('Building js'))
20
+
21
+ // build distributables
22
+ await $`cross-env NODE_ENV=production rollup -c`
23
+
24
+ console.log(chalk.blue(`Compiling 'lib' js files`))
25
+ // build files used for overrides
26
+ await $`cross-env NODE_ENV=production RBC_CJS_BUILD=true babel src --out-dir lib`
27
+
28
+ console.log(chalk.blue('[BUILD COMPLETE]'))
@@ -0,0 +1,11 @@
1
+ {
2
+ "files.exclude": {
3
+ "**/.git": true,
4
+ "**/.svn": true,
5
+ "**/.hg": true,
6
+ "**/CVS": true,
7
+ "**/.DS_Store": true,
8
+ "**/Thumbs.db": true,
9
+ "**/node_modules": true
10
+ }
11
+ }
package/README.md ADDED
@@ -0,0 +1,2 @@
1
+ # TecDoc_Client
2
+ Client For Tecdoc
@@ -0,0 +1,3 @@
1
+ process.env.RBC_ESM_BUILD = 'true'
2
+
3
+ module.exports = require('./babel.config')
@@ -0,0 +1,52 @@
1
+ module.exports = function (api) {
2
+ //api.cache(false)
3
+
4
+ const isCJSBuild = process.env.RBC_CJS_BUILD === 'true'
5
+ const isESMBuild = process.env.RBC_ESM_BUILD === 'true'
6
+ const optionalPlugins = []
7
+
8
+ if (isESMBuild) {
9
+ optionalPlugins.push([
10
+ 'babel-plugin-transform-rename-import',
11
+ {
12
+ replacements: [{ original: 'lodash', replacement: 'lodash-es' }],
13
+ },
14
+ ])
15
+ }
16
+
17
+ const config = {
18
+ presets: [
19
+ [
20
+ '@babel/preset-env',
21
+ {
22
+ ...(api.env('test') && {
23
+ targets: {
24
+ node: 'current',
25
+ },
26
+ }),
27
+ },
28
+ ],
29
+ // FIXME: Passing `useESModules` to babel-preset-react-app is an
30
+ // undocumented feature. Should be avoided. This option is also deprecated
31
+ // according to
32
+ // https://babeljs.io/docs/en/babel-plugin-transform-runtime#useesmodules
33
+ [
34
+ 'react-app',
35
+ {
36
+ useESModules: !isCJSBuild,
37
+ absoluteRuntime: false,
38
+ },
39
+ ],
40
+ ],
41
+ plugins: [
42
+ ['@babel/plugin-transform-runtime'],
43
+ ['transform-react-remove-prop-types', { mode: 'wrap' }],
44
+ ['@babel/plugin-proposal-class-properties', { loose: true }],
45
+ ['@babel/plugin-proposal-private-property-in-object', { loose: true }],
46
+ ['@babel/plugin-proposal-private-methods', { loose: true }],
47
+ ...optionalPlugins,
48
+ ],
49
+ }
50
+
51
+ return config
52
+ }
package/lib/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 _getAmBrands = _interopRequireDefault(require("./tecdoc/getAmBrands"));
9
+ var _default = exports["default"] = {
10
+ getAmBrands: _getAmBrands["default"]
11
+ };
@@ -0,0 +1,59 @@
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 _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
10
+ function _default(_x) {
11
+ return _ref.apply(this, arguments);
12
+ }
13
+ function _ref() {
14
+ _ref = (0, _asyncToGenerator2["default"])(/*#__PURE__*/(0, _regenerator2["default"])().m(function _callee2(params) {
15
+ return (0, _regenerator2["default"])().w(function (_context2) {
16
+ while (1) switch (_context2.n) {
17
+ case 0:
18
+ return _context2.a(2, new Promise(/*#__PURE__*/function () {
19
+ var _ref2 = (0, _asyncToGenerator2["default"])(/*#__PURE__*/(0, _regenerator2["default"])().m(function _callee(resolve, reject) {
20
+ var result, _t;
21
+ return (0, _regenerator2["default"])().w(function (_context) {
22
+ while (1) switch (_context.p = _context.n) {
23
+ case 0:
24
+ _context.p = 0;
25
+ _context.n = 1;
26
+ return api.post(process.env.REACT_APP_TECDOC_API_URL_3, {
27
+ getBrands: {
28
+ "articleCountry": option.articleCountry || "FR",
29
+ "lang": option.lang || "FR",
30
+ "provider": option.provider ? option.provider : process.env.TECDOC_PROVIDER_ID,
31
+ "includeAll": option.includeAll || false,
32
+ "includeAddressDetails": option.includeAddressDetails || false,
33
+ "includeDataSupplierStatus": option.includeDataSupplierStatus || false,
34
+ "includeDataSupplierLogo": option.includeDataSupplierLogo || false
35
+ }
36
+ });
37
+ case 1:
38
+ result = _context.v;
39
+ resolve(result);
40
+ _context.n = 3;
41
+ break;
42
+ case 2:
43
+ _context.p = 2;
44
+ _t = _context.v;
45
+ reject(_t);
46
+ case 3:
47
+ return _context.a(2);
48
+ }
49
+ }, _callee, null, [[0, 2]]);
50
+ }));
51
+ return function (_x2, _x3) {
52
+ return _ref2.apply(this, arguments);
53
+ };
54
+ }()));
55
+ }
56
+ }, _callee2);
57
+ }));
58
+ return _ref.apply(this, arguments);
59
+ }
package/package.json ADDED
@@ -0,0 +1,44 @@
1
+ {
2
+ "name": "@remyar/tecdoc_client",
3
+ "version": "0.0.1",
4
+ "description": "Client For Tecdoc",
5
+ "main": "lib/index.js",
6
+ "module": "dist/index.esm.js",
7
+ "scripts": {
8
+ "build": "zx .scripts/build.mjs",
9
+ "rollup": "rollup -c"
10
+ },
11
+ "author": "Remy ARNAUDIN <remy.arnaudin@wanadoo.fr>",
12
+ "license": "ISC",
13
+ "repository": {
14
+ "type": "git",
15
+ "url": "git+https://github.com/remyar/TecDoc_Client.git"
16
+ },
17
+ "bugs": {
18
+ "url": "https://github.com/remyar/TecDoc_Client/issues"
19
+ },
20
+ "keywords": [
21
+ "tecdoc",
22
+ "client"
23
+ ],
24
+ "dependencies": {
25
+ "@babel/cli": "^7.28.6",
26
+ "@rollup/plugin-commonjs": "^29.0.0",
27
+ "@rollup/plugin-babel": "^6.1.0",
28
+ "@babel/plugin-proposal-private-methods": "^7.18.6",
29
+ "@babel/plugin-transform-runtime": "^7.28.5",
30
+ "@rollup/plugin-replace": "^6.0.3",
31
+ "@rollup/plugin-node-resolve": "^16.0.3",
32
+ "@babel/preset-env": "^7.28.6",
33
+ "@babel/plugin-proposal-class-properties": "^7.18.6",
34
+ "@babel/plugin-proposal-private-property-in-object": "^7.21.11",
35
+ "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
+ "babel-preset-react-app": "^10.1.0",
39
+ "cross-env": "^10.1.0",
40
+ "is-ci": "^4.1.0",
41
+ "rollup": "^4.57.0",
42
+ "zx": "^8.8.5"
43
+ }
44
+ }
@@ -0,0 +1,94 @@
1
+ import path from 'path';
2
+ import * as url from 'url';
3
+ import nodeResolve from '@rollup/plugin-node-resolve';
4
+ import babel from '@rollup/plugin-babel';
5
+ import commonjs from '@rollup/plugin-commonjs';
6
+ import replace from '@rollup/plugin-replace';
7
+ import clear from 'rollup-plugin-clear';
8
+ // removed sizeSnapshot, as it is not compatible with ESM
9
+ import { terser } from 'rollup-plugin-terser';
10
+ import pkg from './package.json' with { type: 'json' };
11
+
12
+ const __dirname = url.fileURLToPath(new URL('.', import.meta.url))
13
+
14
+ const input = './src/index.js'
15
+ const name = 'TecDoc_Client'
16
+
17
+ const babelOptions = {
18
+ skipPreflightCheck: 'true',
19
+ exclude: /node_modules/,
20
+ babelHelpers: 'runtime',
21
+ }
22
+ const globals = {
23
+ react: 'React',
24
+ 'react-dom': 'ReactDOM',
25
+ }
26
+
27
+ const commonjsOptions = {
28
+ include: /node_modules/,
29
+ }
30
+
31
+ export default [
32
+ {
33
+ input,
34
+ output: {
35
+ file: './dist/index.js',
36
+ format: 'umd',
37
+ name,
38
+ globals,
39
+ interop: 'auto',
40
+ },
41
+ external: Object.keys(globals).push(/@babel\/runtime/),
42
+ plugins: [
43
+ // only use 'clear' on the first target
44
+ clear({
45
+ targets: ['./dist', './lib'],
46
+ watch: true,
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
+ ]
package/src/index.js ADDED
@@ -0,0 +1,6 @@
1
+
2
+ import getAmBrands from "./tecdoc/getAmBrands";
3
+
4
+ export default {
5
+ getAmBrands
6
+ }
@@ -0,0 +1,22 @@
1
+
2
+
3
+ export default async function ( params ) {
4
+ return new Promise(async(resolve , reject) => {
5
+ try {
6
+ let result = await api.post(process.env.REACT_APP_TECDOC_API_URL_3, {
7
+ getBrands: {
8
+ "articleCountry": option.articleCountry || "FR",
9
+ "lang": option.lang || "FR",
10
+ "provider": option.provider ? option.provider : process.env.TECDOC_PROVIDER_ID,
11
+ "includeAll": option.includeAll || false,
12
+ "includeAddressDetails": option.includeAddressDetails || false,
13
+ "includeDataSupplierStatus": option.includeDataSupplierStatus || false,
14
+ "includeDataSupplierLogo": option.includeDataSupplierLogo || false
15
+ }
16
+ });
17
+ resolve(result);
18
+ } catch (err) {
19
+ reject(err);
20
+ }
21
+ })
22
+ }