@docbrasil/api-systemmanager 1.0.48 → 1.0.52
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/api/user/document.js +2 -2
- package/api/user/organization.js +0 -10
- package/api/utils/promises.js +2 -2
- package/bundleRollup.js +158 -0
- package/dist/bundle.cjs +6707 -17
- package/dist/bundle.mjs +1 -4004
- package/doc/api.md +4 -9
- package/package.json +15 -9
- package/rollup.config.js +0 -24
package/api/user/document.js
CHANGED
|
@@ -499,7 +499,7 @@ class Documents {
|
|
|
499
499
|
/**
|
|
500
500
|
* Uploads the file
|
|
501
501
|
* @param {object} params Params to upload document
|
|
502
|
-
* @param {
|
|
502
|
+
* @param {buffer} params.content The content of the file (Buffer)
|
|
503
503
|
* @param {string} params.signedUrl The signed URL
|
|
504
504
|
* @param {string} params.type The file mime type
|
|
505
505
|
* @return {Promise<boolean>} True if success
|
|
@@ -522,7 +522,7 @@ class Documents {
|
|
|
522
522
|
async uploadSignedDocument(params) {
|
|
523
523
|
const { content, signedUrl, type } = params;
|
|
524
524
|
Joi.assert(params, Joi.object().required());
|
|
525
|
-
Joi.assert(params.content, Joi.
|
|
525
|
+
Joi.assert(params.content, Joi.required());
|
|
526
526
|
Joi.assert(params.signedUrl, Joi.string().required());
|
|
527
527
|
Joi.assert(params.type, Joi.string().required());
|
|
528
528
|
|
package/api/user/organization.js
CHANGED
|
@@ -174,16 +174,6 @@ class Organization {
|
|
|
174
174
|
}
|
|
175
175
|
|
|
176
176
|
/**
|
|
177
|
-
* @author Augusto Pissarra <abernardo.br@gmail.com>
|
|
178
|
-
* @description Call URL internal
|
|
179
|
-
* @param {!object} params Params to call fectch (URL internal)
|
|
180
|
-
* @param {!string} params.url URL to call
|
|
181
|
-
* @param {!string} [params.method=POST] Fetch Method
|
|
182
|
-
* @param {string} params.payload Payload to send
|
|
183
|
-
* @returns {promise}
|
|
184
|
-
* @public
|
|
185
|
-
* @async
|
|
186
|
-
/**
|
|
187
177
|
* @author Thiago Anselmo <thiagoo.anselmoo@gmail.com>
|
|
188
178
|
* @description Call URL internal, need auth JWT (session)
|
|
189
179
|
* @param {!object} params Params to call fectch (URL internal)
|
package/api/utils/promises.js
CHANGED
package/bundleRollup.js
ADDED
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
import * as rollup from 'rollup';
|
|
2
|
+
|
|
3
|
+
import nodePolyfills from 'rollup-plugin-node-polyfills';
|
|
4
|
+
import cleanup from 'rollup-plugin-cleanup';
|
|
5
|
+
import {uglify} from "rollup-plugin-uglify";
|
|
6
|
+
|
|
7
|
+
import json from '@rollup/plugin-json';
|
|
8
|
+
import commonjs from '@rollup/plugin-commonjs';
|
|
9
|
+
import alias from '@rollup/plugin-alias';
|
|
10
|
+
import {nodeResolve} from '@rollup/plugin-node-resolve';
|
|
11
|
+
|
|
12
|
+
import moment from 'moment';
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* @description Class to bukld munti file type (CJS and MJS)
|
|
16
|
+
*/
|
|
17
|
+
class BuildRollup {
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* @description Alist to change modules to esm for use in frontend
|
|
21
|
+
* @type {({find: string, replacement: string}|{find: string, replacement: string}|{find: string, replacement: string}|{find: string, replacement: string})[]}
|
|
22
|
+
*/
|
|
23
|
+
#aliasList = [
|
|
24
|
+
{
|
|
25
|
+
find: 'lodash',
|
|
26
|
+
replacement: 'lodash-es'
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
find: 'moment',
|
|
30
|
+
replacement: 'dayjs/esm'
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
find: 'axios',
|
|
34
|
+
replacement: 'axios-esm'
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
find: 'joi',
|
|
38
|
+
replacement: 'joi/dist/joi-browser.min.js'
|
|
39
|
+
}
|
|
40
|
+
];
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* @description Not add in bundle bellow module, install external to use.
|
|
44
|
+
* @type {string[]}
|
|
45
|
+
*/
|
|
46
|
+
#externalPlugins = ['lodash', 'axios', '@hapi/boom', 'joi', 'moment'];
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* @description Mount list of plugin backend and frontend
|
|
50
|
+
* @type {{mjs: (*)[], cjs: [*, *, *, *]}}
|
|
51
|
+
*/
|
|
52
|
+
#pluginList = {
|
|
53
|
+
cjs: [
|
|
54
|
+
commonjs(),
|
|
55
|
+
nodePolyfills(),
|
|
56
|
+
json(),
|
|
57
|
+
nodeResolve(),
|
|
58
|
+
],
|
|
59
|
+
|
|
60
|
+
mjs: [
|
|
61
|
+
alias({entries: this.#aliasList}),
|
|
62
|
+
|
|
63
|
+
commonjs(),
|
|
64
|
+
nodePolyfills(),
|
|
65
|
+
json(),
|
|
66
|
+
nodeResolve(),
|
|
67
|
+
cleanup(),
|
|
68
|
+
uglify()
|
|
69
|
+
]
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* @description Mount configuration to build
|
|
74
|
+
* @type {{mjs: {output: {file: string, format: string}, entry: {input: string, plugins: *[]}}, cjs: {output: {file: string, format: string}, entry: {input: string, external: [], plugins: (*)[]}}}}
|
|
75
|
+
*/
|
|
76
|
+
#rollupConfig = {
|
|
77
|
+
cjs: {
|
|
78
|
+
entry: {
|
|
79
|
+
input: './index.js',
|
|
80
|
+
external: this.#externalPlugins,
|
|
81
|
+
plugins: this.#pluginList.cjs,
|
|
82
|
+
},
|
|
83
|
+
output: {
|
|
84
|
+
file: 'dist/bundle.cjs',
|
|
85
|
+
format: 'cjs'
|
|
86
|
+
}
|
|
87
|
+
},
|
|
88
|
+
|
|
89
|
+
mjs: {
|
|
90
|
+
entry: {
|
|
91
|
+
input: './index.js',
|
|
92
|
+
plugins: this.#pluginList.mjs,
|
|
93
|
+
},
|
|
94
|
+
output: {
|
|
95
|
+
file: 'dist/bundle.mjs',
|
|
96
|
+
format: 'esm'
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* @see https://rollupjs.org/guide/en/#rolluprollup
|
|
103
|
+
* @description Build all types (CJS backend 'require' | MJS Frontend 'import')
|
|
104
|
+
*/
|
|
105
|
+
async #rollupBuild(config) {
|
|
106
|
+
const self = this;
|
|
107
|
+
|
|
108
|
+
try {
|
|
109
|
+
const bundle = await rollup.rollup(config.entry);
|
|
110
|
+
self.log('Bundle generated');
|
|
111
|
+
|
|
112
|
+
await bundle.write(config.output);
|
|
113
|
+
self.log('Bundle writen');
|
|
114
|
+
|
|
115
|
+
await bundle.close();
|
|
116
|
+
self.log('Bundle finished\n');
|
|
117
|
+
|
|
118
|
+
} catch (ex) {
|
|
119
|
+
throw ex;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* @description Log in terminal process
|
|
125
|
+
* @param {string} text - text to log in terminal
|
|
126
|
+
*/
|
|
127
|
+
log(text, type = 'log') {
|
|
128
|
+
const dateNow = moment().format('DD/MM/YYYY HH:mm:ss');
|
|
129
|
+
console[type](`${dateNow}\t ${text}`);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
async init() {
|
|
133
|
+
const self = this;
|
|
134
|
+
|
|
135
|
+
try {
|
|
136
|
+
self.log('Start process to bundle files');
|
|
137
|
+
|
|
138
|
+
for await (const bundleType of Object.keys(self.#rollupConfig)) {
|
|
139
|
+
self.log(`Start process to bundle type ${bundleType}`);
|
|
140
|
+
|
|
141
|
+
const bundleConfig = self.#rollupConfig[bundleType];
|
|
142
|
+
await self.#rollupBuild(bundleConfig);
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
self.log('Done! All to bundle generated with success');
|
|
146
|
+
|
|
147
|
+
} catch (ex) {
|
|
148
|
+
throw ex;
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
// ------------ //
|
|
154
|
+
// START BUNDLE //
|
|
155
|
+
// ------------ //
|
|
156
|
+
|
|
157
|
+
const buildRollup = new BuildRollup();
|
|
158
|
+
buildRollup.init();
|