eitri-cli 1.38.0-beta.9 → 1.39.0-beta.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.
Files changed (95) hide show
  1. package/.husky/pre-commit +0 -0
  2. package/eitri-cli-v2/eitri-cli-v2.darwin-arm64.node +0 -0
  3. package/eitri-cli-v2/eitri-cli-v2.darwin-x64.node +0 -0
  4. package/eitri-cli-v2/eitri-cli-v2.linux-x64-gnu.node +0 -0
  5. package/eitri-cli-v2/eitri-cli-v2.win32-x64-msvc.node +0 -0
  6. package/eitri-cli-v2/index.d.ts +11 -1
  7. package/index.js +4 -21
  8. package/package.json +3 -49
  9. package/src/modules/app/AppCommand.js +1 -1
  10. package/src/modules/vegvisir/VegvisirCommand.js +7 -13
  11. package/.eslintrc.json +0 -26
  12. package/.prettierrc +0 -6
  13. package/src/cmd/clean.js +0 -144
  14. package/src/cmd/create.js +0 -332
  15. package/src/cmd/credentials.js +0 -105
  16. package/src/cmd/doctor.js +0 -70
  17. package/src/cmd/invite.js +0 -87
  18. package/src/cmd/list.js +0 -36
  19. package/src/cmd/login.js +0 -70
  20. package/src/cmd/loginV2.js +0 -89
  21. package/src/cmd/manage-env.js +0 -129
  22. package/src/cmd/open-share.js +0 -6
  23. package/src/cmd/order-details.js +0 -6
  24. package/src/cmd/push-version.js +0 -260
  25. package/src/cmd/show-message-if-outdated-package.js +0 -32
  26. package/src/cmd/signup.js +0 -71
  27. package/src/cmd/start.js +0 -181
  28. package/src/cmd/tail-logs.js +0 -26
  29. package/src/cmd/test-initialization-params.js +0 -6
  30. package/src/cmd/validate.js +0 -164
  31. package/src/cmd/version.js +0 -18
  32. package/src/enum/WatcherOpts.js +0 -3
  33. package/src/enum/target.js +0 -6
  34. package/src/helpers/request-listener-helper.js +0 -55
  35. package/src/model/EitriAppType.js +0 -4
  36. package/src/model/Payload.js +0 -45
  37. package/src/model/Target.js +0 -61
  38. package/src/model/User.js +0 -11
  39. package/src/service/AuthConfig.js +0 -85
  40. package/src/service/BlindGuardian.js +0 -131
  41. package/src/service/CliLogin.js +0 -52
  42. package/src/service/ConfigService.js +0 -9
  43. package/src/service/CredentialsService.js +0 -47
  44. package/src/service/EitriAppManager.js +0 -32
  45. package/src/service/EitriAppService.js +0 -49
  46. package/src/service/Emulator/AndroidEmulatorService.js +0 -132
  47. package/src/service/Emulator/IOSEmulatorService.js +0 -71
  48. package/src/service/EmulatorService.js +0 -17
  49. package/src/service/GATrackingStrategy.js +0 -16
  50. package/src/service/HashFolder.js +0 -79
  51. package/src/service/Http.js +0 -300
  52. package/src/service/HuginService.js +0 -38
  53. package/src/service/InviteService.js +0 -45
  54. package/src/service/LibsService.js +0 -191
  55. package/src/service/ManageEnvService.js +0 -10
  56. package/src/service/MiniLog.js +0 -166
  57. package/src/service/PrerequisitesValidator.js +0 -99
  58. package/src/service/QRCodeFactory.js +0 -81
  59. package/src/service/ReleaseService.js +0 -126
  60. package/src/service/Server.js +0 -220
  61. package/src/service/StarterService.js +0 -31
  62. package/src/service/TagTree.js +0 -101
  63. package/src/service/TargetService.js +0 -97
  64. package/src/service/TrackService.js +0 -11
  65. package/src/service/TrackingEitriAnalytics.js +0 -26
  66. package/src/service/TrackingService.js +0 -183
  67. package/src/service/ValidateResult.js +0 -57
  68. package/src/service/Watcher.js +0 -118
  69. package/src/service/Workspace.js +0 -1045
  70. package/src/service/WorkspaceManager.js +0 -76
  71. package/src/service/factories/DoubtsStarterFactory.js +0 -25
  72. package/src/service/factories/MiniWebAppFactory.js +0 -44
  73. package/src/service/factories/QRCodeStarterFactory.js +0 -154
  74. package/src/service/factories/WebStarterFactory.js +0 -88
  75. package/src/service/factories/WoodCoffeeFactory.js +0 -292
  76. package/src/util/AboutTemplate.jsx +0 -14
  77. package/src/util/FileUtils.js +0 -25
  78. package/src/util/GenericUtils.js +0 -41
  79. package/src/util/LibUtil.js +0 -32
  80. package/src/util/LogUtil.js +0 -14
  81. package/src/util/UrlUtils.js +0 -12
  82. package/src/util/UserLocalCredential.js +0 -128
  83. package/src/util/convertKeysToCamelCase.js +0 -26
  84. package/src/util/error-messages/error-messages.js +0 -24
  85. package/src/util/error-messages/invite/invite-error-messages.js +0 -14
  86. package/src/util/getCliVersion.js +0 -13
  87. package/src/util/getCreateFactory.js +0 -9
  88. package/src/util/getWorkspace.js +0 -37
  89. package/src/util/ipv4.js +0 -19
  90. package/src/util/manage-env.js +0 -65
  91. package/src/util/open-docs.js +0 -7
  92. package/src/util/os.js +0 -39
  93. package/src/util/server-url.js +0 -15
  94. package/src/util/template-utils.js +0 -21
  95. package/src/view/index.html +0 -19
package/src/cmd/start.js DELETED
@@ -1,181 +0,0 @@
1
- const path = require('path')
2
- const Watcher = require('../service/Watcher')
3
- const { workspace } = require('../service/Workspace')
4
- const MiniLog = require('../service/MiniLog')
5
- const validator = require('./validate')
6
- const TrackingService = require('../service/TrackingService')
7
- const fs = require('fs')
8
- const config = require('../service/ConfigService')
9
- const handleStartServer = require('../service/StarterService')
10
- const TrackingEitriAnalytics = require('../service/TrackingEitriAnalytics')
11
- const VegvisirService = require('../modules/vegvisir/VegvisirService')
12
- const PrerequisitesValidator = require('../service/PrerequisitesValidator')
13
- const { LogVerbose } = require('../util/LogUtil')
14
-
15
- const blindGuardian = workspace.blindGuardian
16
- const hashFolder = workspace.hashFolder
17
- const trackingService = new TrackingService(blindGuardian, { ignoreCredentialError: true })
18
- const watcher = new Watcher(workspace, hashFolder, trackingService)
19
- const vegvisirService = new VegvisirService(workspace)
20
- const prerequisitesValidator = new PrerequisitesValidator(workspace)
21
- const debug = require('debug')('eitri:start')
22
-
23
- module.exports = async function start(args) {
24
- debug("Iniciando start()")
25
-
26
- TrackingEitriAnalytics.sendEvent({
27
- eventName: "init.start",
28
- userId: workspace?.userEmail || "",
29
- data: {
30
- args
31
- }
32
- })
33
-
34
- let miniConf
35
- try {
36
- miniConf = workspace.getMiniConf()
37
- if(!miniConf || !miniConf.slug){
38
- throw new Error('Não foi possível encontrar o arquivo eitri-app.conf')
39
- }
40
- } catch (error) {
41
- console.log(`\n\x1b[1m\x1b[31m${error.message}\x1b[0m\n`);
42
- process.exit(1);
43
- }
44
-
45
- await vegvisirService.isCurrentWorkspaceOwnedByUser(miniConf.slug)
46
-
47
- const separator = '======================================================================='
48
- let displayFriendlyErrorAtEnd = ""
49
-
50
- await prerequisitesValidator.checkAll(args)
51
-
52
- try {
53
- if (!args.force) {
54
- await validator.assertCommandNotRunning('start')
55
- }
56
-
57
- const miniLog = new MiniLog(config.get('miniLog'))
58
- debug("Obtendo informações do MiniLog", miniLog)
59
-
60
- const resourceFolders2watch = [path.join(process.cwd(), 'public')]
61
- if (fs.existsSync(resourceFolders2watch)) {
62
- workspace.setResourceFolder2Watch(resourceFolders2watch)
63
- }
64
-
65
- await vegvisirService.check(miniConf.slug)
66
- debug("Fim da busca e validação do EitriAppConf", { miniConf })
67
-
68
- const url = config.get('workspace').url
69
- const setupResult = await workspace.setup(args)
70
- debug("Informações do setupResult do workspace", { setupResult })
71
-
72
- const applicationName = setupResult?.application?.name
73
-
74
- blindGuardian.readConf()
75
- let qrCodeUrl = setupResult?.eitriAppBootstrapURL
76
- if(args.playground){
77
- qrCodeUrl = config.get('qrCode').url
78
- }
79
- if (args.verbose) {
80
- blindGuardian.verbose = true
81
- miniLog.verbose = true
82
- console.log('WS url', url)
83
- }
84
- workspace.setServerUrl(url)
85
- workspace.setQrCodeUrl(qrCodeUrl)
86
-
87
- debug("Iniciando workspace", { workspace })
88
- await workspace.init()
89
- debug("Workspace iniciado", { workspace })
90
-
91
- const silentOnConnect = args.verbose ? false : true
92
- const userWorkspace = await vegvisirService.getWorkspace()
93
- console.log(`Construindo para o Workspace [${userWorkspace.id}]`)
94
- if (!args.skipMiniLog) {
95
- await miniLog.connect(userWorkspace.id, silentOnConnect)
96
- }
97
-
98
- LogVerbose(args.verbose, "Construindo...");
99
- const isDevMode = true
100
- try {
101
- debug("Iniciando workspace.uploadZip", { isDevMode, workspace })
102
- await workspace.uploadZip(isDevMode);
103
- } catch (error) {
104
- debug("Erro no workspace.uploadZip", { isDevMode, workspace, error })
105
- if (args.verbose) {
106
- console.error("::uploadZip::", error?.message)
107
- console.error(":::uploadZip::: ", error)
108
- }
109
-
110
- const friendlyMessage1 = "Desculpe, não foi possível realizar a sincronização dos arquivos."
111
- const friendlyMessage2 = "Recomendamos que verifique eventuais erros no código. Para mais informações, consulte nossa documentação em: https://docs.eitri.tech/."
112
- const friendlyMessage3 = "Se o problema persistir, por favor, entre em contato com o suporte técnico do Eitri."
113
- const friendlyMessage4 = "Você pode continuar o desenvolvimento localmente, mesmo que a sincronização não esteja disponível no momento."
114
- displayFriendlyErrorAtEnd = `\x1b[1m\x1b[31m\n${friendlyMessage1}\n${friendlyMessage2} \x1b[0m` + "\n" + `\n${friendlyMessage3}\n${friendlyMessage4}\n\x1b[0m`
115
-
116
- const errorData = error.response.data
117
- const commonStartErrors = ['CodeCompileError', 'TagNotFound']
118
- if (commonStartErrors.includes(errorData.name)) {
119
- displayFriendlyErrorAtEnd += `\n\x1b[1m\x1b[31mMotivo: ${errorData.friendlyMessage}\x1b[0m\n`;
120
- }
121
- }
122
- console.log("Pronto!\n");
123
-
124
- const loadedTarget = await workspace.getTarget()
125
- debug("Target carregado do workspace", { loadedTarget })
126
-
127
- const platform = loadedTarget.platform
128
- const argsWithDeeplinks = {
129
- ...args,
130
- deepLinks: loadedTarget?.deepLinks || []
131
- }
132
- debug("Iniciando servidor", { argsWithDeeplinks, trackingService, watcher, workspace, applicationName, setupResult, platform })
133
- await handleStartServer(argsWithDeeplinks, trackingService, watcher, workspace, applicationName, setupResult, platform)
134
- debug("Servidor iniciado", { loadedTarget })
135
-
136
- TrackingEitriAnalytics.sendEvent({
137
- eventName: "start",
138
- userId: workspace?.userEmail,
139
- data: {
140
- workspaceId: userWorkspace.id,
141
- miniConf,
142
- args
143
- }
144
- })
145
- } catch (e) {
146
- debug("Erro no processo de start", { message: e?.message, error: e })
147
- TrackingEitriAnalytics.sendEvent({
148
- eventName: "start.error",
149
- userId: workspace?.userEmail,
150
- data: {
151
- errorMessage: e?.message || "start.error"
152
- }
153
- })
154
-
155
- if (args.verbose) console.error(e)
156
-
157
- if (e.response && e.response.data && e.response.data.friendlyMessage) {
158
- const { name, friendlyMessage } = e.response.data
159
-
160
- console.error(`ERRO: ${friendlyMessage}`)
161
-
162
- if (name === 'NameCharacterLimitExceed') {
163
- process.exit(1)
164
- }
165
- } else if (e && e.message) {
166
- console.log(`\x1b[1m\x1b[31m${e.message}\x1b[0m`);
167
- } else {
168
- console.log(`\x1b[1m\x1b[31mEitri encontrou um erro e por isso parou, tente novamente mais tarde.\x1b[0m`);
169
- }
170
-
171
- await trackingService.sendError(e)
172
-
173
- process.exit(1)
174
- } finally {
175
- if (displayFriendlyErrorAtEnd) {
176
- const folderHash = workspace.getFolderHashPath()
177
- await workspace.transpile([folderHash])
178
- console.log("\n\n" + separator + "\n" + displayFriendlyErrorAtEnd + "\n" + separator + "\n\n")
179
- }
180
- }
181
- }
@@ -1,26 +0,0 @@
1
- const path = require('path')
2
- const {Workspace} = require('../service/Workspace')
3
- const BlindGuardian = require('../service/BlindGuardian')
4
- const MiniLog = require('../service/MiniLog')
5
- const version = require('./version')
6
- const HashFolder = require('../service/HashFolder')
7
- const blindGuardian = new BlindGuardian()
8
- const hashFolder = new HashFolder()
9
- const workspace = new Workspace(blindGuardian, hashFolder)
10
-
11
- module.exports = async function tailLogs(clientEmail) {
12
- const configService = require('../service/ConfigService')
13
- const miniLog = new MiniLog(configService.get('miniLog'))
14
- version()
15
- const folder2watch = path.join(process.cwd(), 'src')
16
- workspace.setFolder2Watch(folder2watch)
17
- blindGuardian.readConf()
18
-
19
- const url = configService.get('workspace').url
20
- workspace.setServerUrl(url)
21
- await workspace.init()
22
- await miniLog.connect(workspace.userEmail)
23
- let miniConf = await workspace.getMiniConf()
24
- let fullUrl = `https://miniapps.eitri.com/open/${miniConf.slug}?logsFrom=${clientEmail}&logsTo=${workspace.userEmail}`
25
- console.log(fullUrl)
26
- }
@@ -1,6 +0,0 @@
1
- const start = require('./start')
2
-
3
- module.exports = async function testInitializationParams(initializationParams, cmdObj) {
4
- let args = {...cmdObj, initializationParams: initializationParams}
5
- await start(args)
6
- }
@@ -1,164 +0,0 @@
1
- const ValidateResult = require('../service/ValidateResult')
2
- const ps = require('ps-node')
3
-
4
- const NAME_TITLE_REGEX = /^([a-zA-ZÀ-ú0-9\s]|-|\+|&|!)+$/
5
- const SLUG_REGEX = /^(\.|[a-z0-9]|-)+$/i
6
-
7
- module.exports.NAME_TITLE_REGEX = NAME_TITLE_REGEX
8
- module.exports.SLUG_REGEX = SLUG_REGEX
9
-
10
- module.exports.assertCommandNotRunning = function (commandName) {
11
- return new Promise((resolve, reject) => {
12
- ps.lookup({ command: 'node' }, (err, processes) => {
13
- if (err) throw new Error('erro ao executar comando')
14
-
15
- console.log('\x1b[1m\x1b[34mIniciando Eitri builder\x1b[0m');
16
-
17
- const runningProcesses = processes.filter((process) => {
18
- let isAmeToolsRunning = false
19
- let isCommandRunning = false
20
-
21
- for (var argument of process.arguments) {
22
- if (argument.includes('eitri')) {
23
- isAmeToolsRunning = true
24
- continue
25
- }
26
- if (argument === commandName) isCommandRunning = true
27
- }
28
-
29
- return isAmeToolsRunning && isCommandRunning
30
- })
31
-
32
- // if (runningProcesses && runningProcesses.length > 1) {
33
- // console.error('EITRI: o comando ' + commandName + ' já está sendo executado')
34
- // reject()
35
- // process.exit(1)
36
- // } else {
37
- resolve()
38
- // }
39
- })
40
- })
41
- }
42
-
43
- //TODO: ESSE MÓDULO DEVE SER APAGADO, QUANDO NÃO EXISTIR MAIS O COMANDO PUBLISH
44
- module.exports.assertPublishMessage = function (publishMessage) {
45
- if (publishMessage) {
46
- if (publishMessage.length > 255) {
47
- console.error(`Se fornecida, a mensagem de publicação precisa ter menos de 255 caracteres. Tamanho atual: ${publishMessage.length}`)
48
- process.exit(1)
49
- }
50
- }
51
- }
52
-
53
- module.exports.assertBuildMessage = function (buildMessage) {
54
- if (buildMessage) {
55
- if (buildMessage.length > 255) {
56
- console.error(`Se fornecida, a mensagem de build precisa ter menos de 255 caracteres. Tamanho atual: ${buildMessage.length}`)
57
- process.exit(1)
58
- }
59
- }
60
- }
61
-
62
- module.exports.assertPushVersionMessage = function (buildMessage) {
63
- if (buildMessage) {
64
- if (buildMessage.length > 255) {
65
- console.error(`Se fornecida, a mensagem de push-version precisa ter menos de 255 caracteres. Tamanho atual: ${buildMessage.length}`)
66
- process.exit(1)
67
- }
68
- }
69
- }
70
-
71
- module.exports.validate = function (miniConf) {
72
- let validateResult = new ValidateResult([])
73
- let isversionvalid = checkAmeVersion(miniConf)
74
-
75
-
76
- if (!miniConf.name) {
77
- validateResult.addError(
78
- 'Por Favor, preencha o campo \'name\' (Utilize apenas caracteres maiusculo, minusculo e espaco. Ex: \'Meu Mini App\').'
79
- )
80
- } else if (!miniConf.name.match(NAME_TITLE_REGEX)) {
81
- validateResult.addError(
82
- 'Por Favor, preencha o campo \'name\' corretamente antes de publicar'
83
- )
84
- }
85
-
86
- if (!miniConf.title) {
87
- validateResult.addError(
88
- 'Por Favor, preencha o campo \'title\' (Utilize apenas caracteres maiusculo, minusculo e espaco. Ex: \'Meu super mini app\').'
89
- )
90
- } else if (!miniConf.title.match(NAME_TITLE_REGEX)) {
91
- validateResult.addError(
92
- 'Por Favor, preencha o campo \'title\' corretamente antes de publicar'
93
- )
94
- }
95
-
96
- if (!miniConf.slug) {
97
- validateResult.addError(
98
- 'Por Favor, preencha o campo \'slug\' (Utilize apenas caracteres minusculo e ponto. Ex: \'com.eitri.loja\').'
99
- )
100
- } else if (!miniConf.slug.match(SLUG_REGEX)) {
101
- validateResult.addError(
102
- 'Por Favor, preencha o campo \'slug\' corretamente antes de publicar'
103
- )
104
- }
105
-
106
- if (!isversionvalid) {
107
- validateResult.addError(
108
- 'Por Favor, preencha o campo \'version\' (Utilize esse formato X.Y.Z. Ex: \'1.0.0\').'
109
- )
110
- }
111
-
112
- // Se houver objeto privacy, onboarding eh obrigatorio. Mode eh opcional.
113
- if (miniConf.privacy) {
114
- if (miniConf.privacy.onBoarding) {
115
- const onBoarding = miniConf.privacy.onBoarding
116
- const onBoardingItems = onBoarding.items
117
- if (!Array.isArray(onBoardingItems)) {
118
- validateResult.addError(
119
- 'Objeto de configuração "privacy.onBoarding.items" deve ser um array de {img, title, description}'
120
- )
121
- } else {
122
- onBoardingItems.forEach((item, index) => {
123
- if (!(item.img && item.title && item.description)) {
124
- validateResult.addError(
125
- `Um ou mais itens do objeto de "onBoarding" nao possui as propriedades {img, title, description}: ${JSON.stringify(item)}`
126
- )
127
- }
128
-
129
- try {
130
- new URL(item.img)
131
- } catch (e) {
132
- if (e.code === 'ERR_INVALID_URL') {
133
- validateResult.addError(
134
- `onBoarding.Item[${index}] invalido. Atributo "img" nao eh uma URL: ${item.img}`
135
- )
136
- }
137
- }
138
- })
139
- }
140
- } else {
141
- validateResult.addError(
142
- 'Objeto "privacy" nao possui atributo "onBoarding"'
143
- )
144
- }
145
- }
146
- return validateResult
147
- }
148
-
149
- function checkAmeVersion(miniConf) {
150
- if (!miniConf.version) {
151
- return false
152
- }
153
- let value = typeof miniConf.version
154
- if (!(value === 'string')) {
155
- return false
156
- }
157
-
158
- const digit = miniConf.version.match(/^(\d+\.)(\d+\.)(\d+)$/)
159
- if (!digit) {
160
- return false
161
- }
162
-
163
- return true
164
- }
@@ -1,18 +0,0 @@
1
- const path = require('path')
2
- const { execSync } = require('child_process')
3
-
4
- /**
5
- * Loga a versao de um pacote npm
6
- */
7
- function version() {
8
- const packageJson = require(path.resolve(__dirname, '..', '..', 'package.json'))
9
- console.log(`${packageJson?.version}`)
10
- }
11
-
12
- function getVersion(npmPackage) {
13
- return execSync(`npm show ${npmPackage} version`)
14
- .toString()
15
- .trim()
16
- }
17
-
18
- module.exports = {version, getVersion}
@@ -1,3 +0,0 @@
1
- module.exports = {
2
- SAVE: 'save'
3
- }
@@ -1,6 +0,0 @@
1
- module.exports = {
2
- AME_DIGITAL_MOBILE: 'AME_DIGITAL_MOBILE',
3
- AME_EMPRESAS_WEB: 'AME_EMPRESAS_WEB',
4
- AME_MINHA_CONTA_WEB: 'AME_MINHA_CONTA_WEB',
5
-
6
- }
@@ -1,55 +0,0 @@
1
- const IMAGES_FORMAT = ['.png', '.jpg', '.jpeg', '.gif']
2
- const SVG_FORMAT = '.svg'
3
-
4
- /**
5
- * @param {*} workspaceHttp
6
- * @param {string} requestUrl
7
- * @param {Express.Response} response
8
- * @param {string} workspaceUrl
9
- * @param {boolean} verbose
10
- */
11
- function requestListenerHelper(workspaceHttp, requestUrl, response, workspaceUrl, verbose) {
12
- const isImage = IMAGES_FORMAT.find(fmt => requestUrl.endsWith(fmt))
13
- if(isImage) {
14
- workspaceHttp
15
- .get(workspaceUrl, {
16
- responseType: 'arraybuffer'
17
- })
18
- .then((workspaceRes) => {
19
- return response.send(workspaceRes)
20
- })
21
- .catch((e) => {
22
- if(verbose) {
23
- console.log(e)
24
- }
25
- })
26
- }
27
- else if(requestUrl.endsWith(SVG_FORMAT)) {
28
- workspaceHttp
29
- .get(workspaceUrl)
30
- .then((workspaceRes) => {
31
- response.type('image/svg+xml').send(workspaceRes)
32
-
33
- })
34
- .catch((e) => {
35
- if(verbose) {
36
- console.log(e)
37
- }
38
- })
39
- }
40
- else {
41
- workspaceHttp
42
- .get(workspaceUrl)
43
- .then((workspaceRes) => {
44
- response.send(workspaceRes)
45
-
46
- })
47
- .catch((e) => {
48
- if(verbose) {
49
- console.log(e)
50
- }
51
- })
52
- }
53
- }
54
-
55
- module.exports = requestListenerHelper
@@ -1,4 +0,0 @@
1
- module.exports = {
2
- 'SHARED' : 'SHARED',
3
- 'APPLICATION': 'APPLICATION'
4
- }
@@ -1,45 +0,0 @@
1
- class Payload {
2
- /**
3
- * Create a Eitri-App payload.
4
- * @param {string} workspaceUrl
5
- * @param {string} shareId
6
- * @param {string} shareEnvironment
7
- */
8
- constructor(shareId, shareEnvironment){
9
- this.shareId = shareId
10
- this.shareEnvironment = shareEnvironment
11
- }
12
-
13
- /**
14
- * @param {string} shareId
15
- */
16
- setShareId(shareId) {
17
- this.shareId = shareId
18
- }
19
-
20
- /**
21
- * Get shareId.
22
- * @return {string}
23
- */
24
- getShareId() {
25
- return this.shareId
26
- }
27
-
28
- /**
29
- * @param {string} shareEnvironment
30
- */
31
- setShareEnvironment(shareEnvironment) {
32
- this.shareEnvironment = shareEnvironment
33
- }
34
-
35
-
36
- /**
37
- * Get shareEnvironment.
38
- * @return {string}
39
- */
40
- getShareEnvironment() {
41
- return this.shareEnvironment
42
- }
43
- }
44
-
45
- module.exports = Payload
@@ -1,61 +0,0 @@
1
- /* eslint-disable no-unused-vars */
2
- class MiniAppBoilerplateList {
3
- constructor() {
4
- this.name = ''
5
- this.boilerplateUrl = ''
6
- this.description = ''
7
- }
8
- }
9
-
10
- module.exports = class Target {
11
- constructor() {
12
- /**
13
- * @type {number}
14
- */
15
- this.id= ''
16
- /**
17
- * @type {string}
18
- */
19
- this.name= ''
20
- /**
21
- * @type {string}
22
- */
23
- this.minimumCliVersion= ''
24
- /**
25
- * @type {string}
26
- */
27
- this.boilerplateUrl= ''
28
- /**
29
- * @type {string}
30
- */
31
- this.superAppClientLibName= ''
32
- /**
33
- * @type {string}
34
- */
35
- this.componentsLibName= ''
36
- /**
37
- * @type {string}
38
- */
39
- this.description= ''
40
- /**
41
- * @type {boolean}
42
- */
43
- this.status= false
44
- /**
45
- * @type {string}
46
- */
47
- this.platform= ''
48
- /**
49
- * @type {string}
50
- */
51
- this.sdkSupport= ''
52
- /**
53
- * @type {string}
54
- */
55
- this.default= ''
56
- /**
57
- * @type {MiniAppBoilerplateList[]}
58
- */
59
- this.miniAppBoilerplateList= ''
60
- }
61
- }
package/src/model/User.js DELETED
@@ -1,11 +0,0 @@
1
- class User {
2
- constructor(name, email, roleid = 3, redefinepwd = false, password = '') {
3
- this.name = name
4
- this.email = email
5
- this.roleid = roleid
6
- this.redefinepwd = redefinepwd
7
- this.password = password
8
- }
9
- }
10
-
11
- module.exports = User
@@ -1,85 +0,0 @@
1
- const axios = require('axios')
2
- const configService = require('../service/ConfigService')
3
- const { exit } = require('process')
4
-
5
- const DEFAULT_ENV = 'hml'
6
-
7
- class AuthConfig { // abastract
8
-
9
- constructor() {
10
- this.blindGuardianUrl = configService.get('blindGuardian').url
11
- }
12
-
13
- getConfPath() {}
14
-
15
- readConf() {}
16
-
17
- readClientCredentials() {
18
- const credentialConfig = this.readConf()
19
- let data
20
- if (this._isOldProfileVersion(credentialConfig)) {
21
- data = {
22
- client_id: credentialConfig.devUser,
23
- client_secret: credentialConfig.devKey,
24
- grant_type: 'client_credentials'
25
- }
26
- }
27
- else {
28
- const env = process.env.NODE_ENV || DEFAULT_ENV
29
- try {
30
- data = {
31
- client_id: credentialConfig[env].devUser,
32
- client_secret: credentialConfig[env].devKey,
33
- grant_type: 'client_credentials'
34
- }
35
- }
36
- catch (e) {
37
-
38
- const errorMessage = `Configurações do ambiente (NODE_ENV=${env}) não definidas`
39
- if(process.env.LOG_LEVEL === 'full') {
40
- console.error(errorMessage, e)
41
- } else {
42
- console.error(errorMessage)
43
- }
44
-
45
- exit(1)
46
- }
47
- }
48
-
49
- return data
50
- }
51
-
52
- async getToken() {
53
- if(this.token)
54
- return this.token
55
-
56
- const clientCredentials = this.readClientCredentials()
57
- try {
58
- const url = `${this.blindGuardianUrl}/v1/o/auth`
59
- const options = {
60
- headers : {
61
- 'User-Agent': configService.get('userAgent')
62
- }
63
- }
64
- const auth = await axios.post(url, clientCredentials, options)
65
- this.token = auth.data
66
- return this.token
67
- } catch (e) {
68
- if (this.verbose) {
69
- console.log(e)
70
- }
71
- if (e.isAxiosError) {
72
- if (e.response && e.response.status === 403) {
73
- throw new Error('Credencial inválida')
74
- }
75
- throw new Error('Por favor tente novamente mais tarde.')
76
- }
77
- }
78
- }
79
-
80
- _isOldProfileVersion(credentialConfig) {
81
- return (credentialConfig.devKey || credentialConfig.devUser) ? true : false
82
- }
83
- }
84
-
85
- module.exports = AuthConfig