mirror of
https://github.com/dadosfera/maestro.git
synced 2026-09-01 20:28:17 +00:00
Compare commits
15
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
099476f618 | ||
|
|
db78494b1a | ||
|
|
e7ad6e5a7b | ||
|
|
3d7d051df2 | ||
|
|
8e827dc934 | ||
|
|
12b764710a | ||
|
|
b5c95874bb | ||
|
|
b896b1a9b8 | ||
|
|
cf99acc682 | ||
|
|
7fb20964dc | ||
|
|
8751117946 | ||
|
|
8e13541b24 | ||
|
|
4f6a9d4b66 | ||
|
|
56411496c2 | ||
|
|
1626d85d31 |
+9
-5
@@ -5619,6 +5619,9 @@
|
|||||||
"items": {
|
"items": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"themeEnabled": {
|
||||||
|
"type": "boolean"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"required": [
|
"required": [
|
||||||
@@ -5627,7 +5630,8 @@
|
|||||||
"name",
|
"name",
|
||||||
"tier",
|
"tier",
|
||||||
"scheduleLimit",
|
"scheduleLimit",
|
||||||
"links"
|
"links",
|
||||||
|
"themeEnabled"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"AuthUser": {
|
"AuthUser": {
|
||||||
@@ -8374,18 +8378,18 @@
|
|||||||
"textColor": {
|
"textColor": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
"logoWhite": {
|
"logo": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
"logoBlack": {
|
"logoLogin": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"required": [
|
"required": [
|
||||||
"backgroundColor",
|
"backgroundColor",
|
||||||
"textColor",
|
"textColor",
|
||||||
"logoWhite",
|
"logo",
|
||||||
"logoBlack"
|
"logoLogin"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"CustomerThemeResponse": {
|
"CustomerThemeResponse": {
|
||||||
|
|||||||
@@ -95,6 +95,10 @@ spec:
|
|||||||
value: {{ .Values.maestro.tr_factory_url }}
|
value: {{ .Values.maestro.tr_factory_url }}
|
||||||
- name: UPLOAD_FILE_AGENT_CONNECTION
|
- name: UPLOAD_FILE_AGENT_CONNECTION
|
||||||
value: {{ .Values.maestro.upload_file_agent_connection }}
|
value: {{ .Values.maestro.upload_file_agent_connection }}
|
||||||
|
- name: OPEN_CUSTOMER_ID
|
||||||
|
value: {{ .Values.maestro.open_customer_id }}
|
||||||
|
- name: OPEN_GROUP_ID
|
||||||
|
value: {{ .Values.maestro.open_group_id }}
|
||||||
- name: JWT_PRIVATE_KEY
|
- name: JWT_PRIVATE_KEY
|
||||||
valueFrom:
|
valueFrom:
|
||||||
secretKeyRef:
|
secretKeyRef:
|
||||||
|
|||||||
Generated
+4
-4
@@ -12,7 +12,7 @@
|
|||||||
"@aws-sdk/client-secrets-manager": "^3.414.0",
|
"@aws-sdk/client-secrets-manager": "^3.414.0",
|
||||||
"@dadosfera/dadosfera-logs": "^1.0.0-beta.4",
|
"@dadosfera/dadosfera-logs": "^1.0.0-beta.4",
|
||||||
"@dadosfera/protospack": "2.5.3",
|
"@dadosfera/protospack": "2.5.3",
|
||||||
"@dadosfera/protospack-v2": "3.37.0-beta.3",
|
"@dadosfera/protospack-v2": "3.37.0-beta.5",
|
||||||
"@grpc/grpc-js": "^1.9.3",
|
"@grpc/grpc-js": "^1.9.3",
|
||||||
"@grpc/proto-loader": "^0.7.9",
|
"@grpc/proto-loader": "^0.7.9",
|
||||||
"@nestjs/cli": "^9.5.0",
|
"@nestjs/cli": "^9.5.0",
|
||||||
@@ -1403,9 +1403,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@dadosfera/protospack-v2": {
|
"node_modules/@dadosfera/protospack-v2": {
|
||||||
"version": "3.37.0-beta.3",
|
"version": "3.37.0-beta.5",
|
||||||
"resolved": "https://dadosfera-611330257153.d.codeartifact.us-east-1.amazonaws.com/npm/dadosfera-npm/@dadosfera/protospack-v2/-/protospack-v2-3.37.0-beta.3.tgz",
|
"resolved": "https://dadosfera-611330257153.d.codeartifact.us-east-1.amazonaws.com/npm/dadosfera-npm/@dadosfera/protospack-v2/-/protospack-v2-3.37.0-beta.5.tgz",
|
||||||
"integrity": "sha512-9YSgzkXVqe9QsBxJjfxYxttAiyCXxgq49Xjs3OvnTLCXRDn3XtTlPaC+yHrTEUgCkQyhlDZuswe6f6oBImqIRQ==",
|
"integrity": "sha512-dtHMzMU2Qa9c6DpygWr7fib19l1zqbYgBi2wGkiJ6uMAvl1CGu9V0p+JA1FwGTQ0QRy7EkkRVi6X6sH5u/ICpA==",
|
||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@grpc/grpc-js": "^1.9.3",
|
"@grpc/grpc-js": "^1.9.3",
|
||||||
|
|||||||
+1
-1
@@ -30,7 +30,7 @@
|
|||||||
"@aws-sdk/client-secrets-manager": "^3.414.0",
|
"@aws-sdk/client-secrets-manager": "^3.414.0",
|
||||||
"@dadosfera/dadosfera-logs": "^1.0.0-beta.4",
|
"@dadosfera/dadosfera-logs": "^1.0.0-beta.4",
|
||||||
"@dadosfera/protospack": "2.5.3",
|
"@dadosfera/protospack": "2.5.3",
|
||||||
"@dadosfera/protospack-v2": "3.37.0-beta.3",
|
"@dadosfera/protospack-v2": "3.37.0-beta.5",
|
||||||
"@grpc/grpc-js": "^1.9.3",
|
"@grpc/grpc-js": "^1.9.3",
|
||||||
"@grpc/proto-loader": "^0.7.9",
|
"@grpc/proto-loader": "^0.7.9",
|
||||||
"@nestjs/cli": "^9.5.0",
|
"@nestjs/cli": "^9.5.0",
|
||||||
|
|||||||
@@ -77,6 +77,8 @@ export class AuthCustomer {
|
|||||||
scheduleLimit: string;
|
scheduleLimit: string;
|
||||||
@ApiProperty()
|
@ApiProperty()
|
||||||
links: Link[];
|
links: Link[];
|
||||||
|
@ApiProperty()
|
||||||
|
themeEnabled: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export class AuthSignInReq implements AuthSignInRequest {
|
export class AuthSignInReq implements AuthSignInRequest {
|
||||||
|
|||||||
@@ -46,11 +46,15 @@ export class OpenDataController {
|
|||||||
) {
|
) {
|
||||||
this.logger.info('createUser for open data'
|
this.logger.info('createUser for open data'
|
||||||
+ JSON.stringify({
|
+ JSON.stringify({
|
||||||
origin: request.headers.origin,
|
|
||||||
language,
|
language,
|
||||||
body
|
body
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
this.logger.info('headers'
|
||||||
|
+ JSON.stringify({
|
||||||
|
headers: request.headers
|
||||||
|
}));
|
||||||
|
|
||||||
// "401573bb-334f-44b2-b30e-88d4cea31ae9"
|
// "401573bb-334f-44b2-b30e-88d4cea31ae9"
|
||||||
// const OPENDATA_PUBLIC_USERS_GROUP_ID = process.env.OPEN_GROUP_ID;
|
// const OPENDATA_PUBLIC_USERS_GROUP_ID = process.env.OPEN_GROUP_ID;
|
||||||
// ""f239718a-a271-4ef9-ae7e-02a2f0f3aa6e""
|
// ""f239718a-a271-4ef9-ae7e-02a2f0f3aa6e""
|
||||||
|
|||||||
@@ -27,9 +27,9 @@ export class CustomerTheme implements Theme {
|
|||||||
@ApiProperty()
|
@ApiProperty()
|
||||||
textColor: string;
|
textColor: string;
|
||||||
@ApiProperty()
|
@ApiProperty()
|
||||||
logoWhite: string;
|
logo: string;
|
||||||
@ApiProperty()
|
@ApiProperty()
|
||||||
logoBlack: string;
|
logoLogin: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export class CustomerThemeResponse {
|
export class CustomerThemeResponse {
|
||||||
|
|||||||
@@ -59,22 +59,22 @@ export class ThemeController {
|
|||||||
id,
|
id,
|
||||||
}));
|
}));
|
||||||
|
|
||||||
const logoWhite = files.find(file => file.fieldname === 'logoWhite');
|
const logo = files.find(file => file.fieldname === 'logo');
|
||||||
const logoBlack = files.find(file => file.fieldname === 'logoBlack');
|
const logoLogin = files.find(file => file.fieldname === 'logoLogin');
|
||||||
|
|
||||||
this.validFileSize(logoWhite);
|
this.validFileSize(logo);
|
||||||
this.validFileSize(logoBlack);
|
this.validFileSize(logoLogin);
|
||||||
this.validMimeType(logoWhite);
|
this.validMimeType(logo);
|
||||||
this.validMimeType(logoBlack);
|
this.validMimeType(logoLogin);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const theme = await this.themeService.createThemeByCustomer(id, {
|
const theme = await this.themeService.createThemeByCustomer(id, {
|
||||||
...data,
|
...data,
|
||||||
logoWhite,
|
logo,
|
||||||
logoBlack
|
logoLogin
|
||||||
});
|
});
|
||||||
this.logger.info('saveCustomertheme' + JSON.stringify(theme));
|
this.logger.info('saveCustomertheme' + JSON.stringify(theme));
|
||||||
return { theme: theme };
|
return theme;
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
if (err.details === ErrorCodes.CUSTOMER.NOT_FOUND) {
|
if (err.details === ErrorCodes.CUSTOMER.NOT_FOUND) {
|
||||||
this.logger.error('Error - saveCustomertheme - Expect CUSTOMER.NOT_FOUND');
|
this.logger.error('Error - saveCustomertheme - Expect CUSTOMER.NOT_FOUND');
|
||||||
|
|||||||
@@ -21,11 +21,10 @@ import { resolve } from 'path';
|
|||||||
import { Readable } from 'stream';
|
import { Readable } from 'stream';
|
||||||
|
|
||||||
type Files = {
|
type Files = {
|
||||||
logoWhite: Express.Multer.File,
|
logo: Express.Multer.File,
|
||||||
logoBlack: Express.Multer.File,
|
logoLogin: Express.Multer.File,
|
||||||
}
|
}
|
||||||
|
|
||||||
// This function will accept any string, which may result in a bug.
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class ThemeService implements OnModuleInit {
|
export class ThemeService implements OnModuleInit {
|
||||||
private themeService: ThemeProtoService;
|
private themeService: ThemeProtoService;
|
||||||
@@ -63,12 +62,12 @@ export class ThemeService implements OnModuleInit {
|
|||||||
chunk: Buffer.alloc(0)
|
chunk: Buffer.alloc(0)
|
||||||
})
|
})
|
||||||
|
|
||||||
if(theme.logoBlack) {
|
if(theme.logo) {
|
||||||
await this.sendFile(theme.logoBlack, customerThemeRequest$);
|
await this.sendFile(theme.logo, customerThemeRequest$);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(theme.logoWhite) {
|
if(theme.logoLogin) {
|
||||||
await this.sendFile(theme.logoWhite, customerThemeRequest$);
|
await this.sendFile(theme.logoLogin, customerThemeRequest$);
|
||||||
}
|
}
|
||||||
customerThemeRequest$.complete();
|
customerThemeRequest$.complete();
|
||||||
|
|
||||||
@@ -95,16 +94,11 @@ export class ThemeService implements OnModuleInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private async sendFile(file: Express.Multer.File, stream$: ReplaySubject<ThemeRequest>) {
|
private async sendFile(file: Express.Multer.File, stream$: ReplaySubject<ThemeRequest>) {
|
||||||
const bufferStream = new Readable({
|
const chunkSize = 4 * 1024 * 1024;
|
||||||
highWaterMark: 1024 * 1024, // 1 MB por chunk
|
const bufferStream = new CustomBufferStream(file.buffer, chunkSize);
|
||||||
read() {}
|
|
||||||
});
|
|
||||||
bufferStream.push(file.buffer);
|
|
||||||
bufferStream.push(null);
|
|
||||||
|
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
bufferStream.on('data', (chunk) => {
|
bufferStream.on('data', (chunk) => {
|
||||||
console.log('enviando chunk', file.fieldname)
|
|
||||||
const mimetype = file.mimetype.split('/')[1]; // example image/jpeg
|
const mimetype = file.mimetype.split('/')[1]; // example image/jpeg
|
||||||
const filename = file.fieldname.concat(".", mimetype);
|
const filename = file.fieldname.concat(".", mimetype);
|
||||||
stream$.next({
|
stream$.next({
|
||||||
@@ -119,15 +113,39 @@ export class ThemeService implements OnModuleInit {
|
|||||||
});
|
});
|
||||||
|
|
||||||
bufferStream.on('end', () => {
|
bufferStream.on('end', () => {
|
||||||
console.log('terminou de enviar')
|
|
||||||
resolve(file.filename)
|
resolve(file.filename)
|
||||||
});
|
});
|
||||||
|
|
||||||
bufferStream.on('error', (err) => {
|
bufferStream.on('error', (err) => {
|
||||||
console.error('Erro no stream:', err);
|
|
||||||
reject(err);
|
reject(err);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class CustomBufferStream extends Readable {
|
||||||
|
buffer: Buffer;
|
||||||
|
offset: number;
|
||||||
|
chunkSize: number;
|
||||||
|
|
||||||
|
constructor(buffer: Buffer, chunkSize: number) {
|
||||||
|
super({ highWaterMark: chunkSize }); // Configura o tamanho do chunk
|
||||||
|
this.buffer = buffer;
|
||||||
|
this.offset = 0;
|
||||||
|
this.chunkSize = chunkSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
_read() {
|
||||||
|
if (this.offset < this.buffer.length) {
|
||||||
|
const end = Math.min(this.offset + this.chunkSize, this.buffer.length);
|
||||||
|
|
||||||
|
const copiedBuf = Uint8Array.prototype.slice.call(this.buffer);
|
||||||
|
const chunk = copiedBuf.slice(this.offset, end);
|
||||||
|
this.offset = end;
|
||||||
|
this.push(chunk);
|
||||||
|
} else {
|
||||||
|
this.push(null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user