Compare commits

...
Author SHA1 Message Date
Marcos Rodrigues Silva 099476f618 Merge pull request #246 from dadosfera/feature/white-label-app
Feature/white label app
2025-01-27 15:07:22 -03:00
marcos-silva-rodrigues db78494b1a FIX: test log headers 2025-01-27 14:39:12 -03:00
marcos-silva-rodrigues e7ad6e5a7b CHORE: update env 2025-01-27 14:12:38 -03:00
Marcos Rodrigues Silva 3d7d051df2 Merge pull request #245 from dadosfera/feature/white-label-app
chore: update stg values
2025-01-27 11:50:43 -03:00
marcos-silva-rodrigues 8e827dc934 chore: update stg values 2025-01-27 11:47:23 -03:00
Marcos Rodrigues Silva 12b764710a Merge pull request #244 from dadosfera/feature/white-label-app
Feature/white label app
2025-01-27 09:49:29 -03:00
marcos-silva-rodrigues b5c95874bb chore: updated package 2025-01-27 09:14:42 -03:00
marcos-silva-rodrigues b896b1a9b8 REFACTOR: rename props 2025-01-26 16:44:31 -03:00
marcos-silva-rodrigues cf99acc682 FEAT: send images in stream 2025-01-26 16:37:37 -03:00
Marcos Rodrigues Silva 7fb20964dc Merge pull request #243 from dadosfera/feature/white-label-app
Feature/white label app
2025-01-23 08:39:26 -03:00
Rafael Santana 8751117946 Merge pull request #242 from dadosfera/decrease-replica-count-maestro
UPDATE: add toleration for spot instances
2025-01-22 11:24:35 -03:00
marcos-silva-rodrigues 8e13541b24 FEAT: update protospack 2025-01-21 17:28:13 -03:00
marcos-silva-rodrigues 4f6a9d4b66 FEAT: new property in customer obj 2025-01-21 17:00:34 -03:00
Rafael Santana 56411496c2 Merge pull request #241 from dadosfera/decrease-replica-count-maestro
Decrease replica count maestro
2025-01-20 18:50:14 -03:00
Rafael Santana 1626d85d31 Merge pull request #240 from dadosfera/decrease-replica-count-maestro
UPDATE: decrease the number of replicas for stg environment
2025-01-20 18:41:54 -03:00
9 changed files with 70 additions and 38 deletions
+9 -5
View File
@@ -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": {
+4
View File
@@ -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:
+4 -4
View File
@@ -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
View File
@@ -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",
+2
View File
@@ -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""
+2 -2
View File
@@ -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 {
+9 -9
View File
@@ -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');
+34 -16
View File
@@ -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);
}
}
}