Skip to content

Commit 8ae4ad6

Browse files
fix: more translations
1 parent 45c2d7e commit 8ae4ad6

File tree

10 files changed

+208
-208
lines changed

10 files changed

+208
-208
lines changed

src/plugins/examples/audit-plugin.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ export class AuditPlugin<P = unknown> implements RBACPlugin<P> {
3737
metadata: PluginMetadata = {
3838
name: 'rbac-audit',
3939
version: '1.0.0',
40-
description: 'Plugin de auditoria para rastrear atividades de segurança e compliance',
40+
description: 'Audit plugin to track security activities and compliance',
4141
author: 'RBAC Team',
4242
license: 'MIT',
4343
keywords: ['audit', 'logging', 'compliance', 'security', 'tracking']
@@ -186,7 +186,7 @@ export class AuditPlugin<P = unknown> implements RBACPlugin<P> {
186186
console.log('[AUDIT] Audit plugin finished');
187187
}
188188

189-
// Métodos públicos para auditoria
189+
// Public methods for auditing
190190

191191
async logEvent(event: Omit<AuditEvent, 'id' | 'timestamp'>): Promise<void> {
192192
const auditEvent: AuditEvent = {
@@ -309,7 +309,7 @@ export class AuditPlugin<P = unknown> implements RBACPlugin<P> {
309309
return stats;
310310
}
311311

312-
// Métodos privados
312+
// Private methods
313313

314314
private setupFlushTimer(): void {
315315
this.flushTimer = setInterval(async () => {
@@ -410,7 +410,7 @@ export class AuditPlugin<P = unknown> implements RBACPlugin<P> {
410410
return `${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
411411
}
412412

413-
// Métodos de estatísticas
413+
// Statistics methods
414414

415415
getQueueStats(): {
416416
queueSize: number;

src/plugins/examples/cache-plugin.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { RBACPlugin, PluginContext, PluginConfig, PluginMetadata, HookData } from '../types';
22

33
interface CacheConfig {
4-
ttl: number; // Time to live em segundos
5-
maxSize: number; // Tamanho máximo do cache
4+
ttl: number; // Time to live in seconds
5+
maxSize: number; // Maximum cache size
66
strategy: 'lru' | 'fifo' | 'ttl';
77
}
88

@@ -13,13 +13,13 @@ interface CacheEntry {
1313
}
1414

1515
/**
16-
* Plugin de cache para otimizar verificações de permissão
16+
* Cache plugin to optimize permission checks
1717
*/
1818
export class CachePlugin<P = unknown> implements RBACPlugin<P> {
1919
metadata: PluginMetadata = {
2020
name: 'rbac-cache',
2121
version: '1.0.0',
22-
description: 'Plugin de cache para otimizar verificações de permissão',
22+
description: 'Cache plugin to optimize permission checks',
2323
author: 'RBAC Team',
2424
license: 'MIT',
2525
keywords: ['cache', 'performance', 'optimization']
@@ -131,7 +131,7 @@ export class CachePlugin<P = unknown> implements RBACPlugin<P> {
131131
console.log('[CACHE] Cache plugin finished');
132132
}
133133

134-
// Métodos públicos para gerenciamento do cache
134+
// Public methods for cache management
135135

136136
get(key: string): any {
137137
const entry = this.cache.get(key);
@@ -178,7 +178,7 @@ export class CachePlugin<P = unknown> implements RBACPlugin<P> {
178178
return Array.from(this.cache.keys());
179179
}
180180

181-
// Métodos privados
181+
// Private methods
182182

183183
private generateCacheKey(role: string, operation: string | RegExp, params?: P): string {
184184
const operationStr = typeof operation === 'string' ? operation : operation.source;
@@ -254,7 +254,7 @@ export class CachePlugin<P = unknown> implements RBACPlugin<P> {
254254
keysToDelete.forEach(key => this.cache.delete(key));
255255
}
256256

257-
// Métodos de estatísticas
257+
// Statistics methods
258258

259259
getStats(): {
260260
size: number;

src/plugins/examples/middleware-plugin.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,9 @@ export class MiddlewarePlugin<P = unknown> implements IMiddlewarePlugin<P> {
3636
enableSecurityHeaders: true,
3737
enableRequestLogging: true,
3838
rateLimitConfig: {
39-
windowMs: 15 * 60 * 1000, // 15 minutos
40-
max: 100, // máximo 100 requests por IP
41-
message: 'Muitas tentativas, tente novamente mais tarde'
39+
windowMs: 15 * 60 * 1000, // 15 minutes
40+
max: 100, // maximum 100 requests per IP
41+
message: 'Too many attempts, try again later'
4242
},
4343
corsConfig: {
4444
origin: '*',

src/plugins/examples/notification-plugin.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,13 @@ interface NotificationEvent {
2323
}
2424

2525
/**
26-
* Plugin de notificações para eventos do RBAC
26+
* Notification plugin for RBAC events
2727
*/
2828
export class NotificationPlugin<P = unknown> implements RBACPlugin<P> {
2929
metadata: PluginMetadata = {
3030
name: 'rbac-notifications',
3131
version: '1.0.0',
32-
description: 'Plugin de notificações para eventos de segurança e auditoria',
32+
description: 'Notification plugin for security and audit events',
3333
author: 'RBAC Team',
3434
license: 'MIT',
3535
keywords: ['notifications', 'alerts', 'security', 'audit']
@@ -93,7 +93,7 @@ export class NotificationPlugin<P = unknown> implements RBACPlugin<P> {
9393
}
9494

9595
private async afterPermissionCheck(data: HookData<P>, context: PluginContext<P>): Promise<void> {
96-
// Notificar sobre verificações de permissão negadas
96+
// Notify about denied permission checks
9797
if (data.result === false) {
9898
this.notify('permission.denied', {
9999
role: data.role,
@@ -103,7 +103,7 @@ export class NotificationPlugin<P = unknown> implements RBACPlugin<P> {
103103
}, 'medium');
104104
}
105105

106-
// Notificar sobre verificações suspeitas
106+
// Notify about suspicious checks
107107
if (this.isSuspiciousActivity(data)) {
108108
this.notify('suspicious.activity', {
109109
role: data.role,
@@ -165,7 +165,7 @@ export class NotificationPlugin<P = unknown> implements RBACPlugin<P> {
165165
console.log('[NOTIFICATION] Notification plugin finished');
166166
}
167167

168-
// Métodos públicos para notificações
168+
// Public methods for notifications
169169

170170
async notify(type: string, data: any, severity: 'low' | 'medium' | 'high' | 'critical' = 'medium'): Promise<void> {
171171
const notification: NotificationEvent = {

src/plugins/examples/validation-plugin.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,13 @@ interface ValidationRule {
1616
}
1717

1818
/**
19-
* Plugin de validação para roles, operações e parâmetros
19+
* Validation plugin for roles, operations and parameters
2020
*/
2121
export class ValidationPlugin<P = unknown> implements RBACPlugin<P> {
2222
metadata: PluginMetadata = {
2323
name: 'rbac-validation',
2424
version: '1.0.0',
25-
description: 'Plugin de validação para roles, operações e parâmetros do RBAC',
25+
description: 'Validation plugin for RBAC roles, operations and parameters',
2626
author: 'RBAC Team',
2727
license: 'MIT',
2828
keywords: ['validation', 'security', 'data-integrity']
@@ -380,13 +380,13 @@ export class ValidationPlugin<P = unknown> implements RBACPlugin<P> {
380380
});
381381
}
382382

383-
// Métodos privados
383+
// Private methods
384384

385385
private setupDefaultRules(): void {
386-
// Regras padrão podem ser adicionadas aqui
386+
// Default rules can be added here
387387
}
388388

389-
// Métodos de estatísticas
389+
// Statistics methods
390390

391391
getValidationStats(): {
392392
totalRules: number;

src/plugins/functional-examples/usage-example.ts

Lines changed: 43 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ import { createCachePlugin } from './cache-plugin';
44
import { createNotificationPlugin } from './notification-plugin';
55
import { createValidationPlugin } from './validation-plugin';
66

7-
// Exemplo de uso do sistema de plugins funcional
7+
// Example of using the functional plugin system
88

9-
async function exemploUso() {
10-
// 1. Criar instância RBAC básica
9+
async function usageExample() {
10+
// 1. Create basic RBAC instance
1111
const rbac = RBAC()({
1212
user: {
1313
can: ['products:read']
@@ -18,10 +18,10 @@ async function exemploUso() {
1818
}
1919
});
2020

21-
// 2. Adicionar sistema de plugins
21+
// 2. Add plugin system
2222
const rbacWithPlugins = createRBACWithPlugins(rbac);
2323

24-
// 3. Instalar plugins
24+
// 3. Install plugins
2525
await rbacWithPlugins.plugins.install(
2626
createCachePlugin({
2727
enabled: true,
@@ -65,126 +65,126 @@ async function exemploUso() {
6565
);
6666

6767
// 4. Usar RBAC com plugins
68-
console.log('Testando verificação de permissão com plugins...');
68+
console.log('Testing permission check with plugins...');
6969

7070
const result1 = await rbacWithPlugins.can('user', 'products:read');
71-
console.log('User pode ler produtos:', result1); // true
71+
console.log('User can read products:', result1); // true
7272

7373
const result2 = await rbacWithPlugins.can('user', 'products:write');
74-
console.log('User pode escrever produtos:', result2); // false
74+
console.log('User can write products:', result2); // false
7575

7676
const result3 = await rbacWithPlugins.can('admin', 'products:delete');
77-
console.log('Admin pode deletar produtos:', result3); // true
77+
console.log('Admin can delete products:', result3); // true
7878

79-
// 5. Listar plugins instalados
79+
// 5. List installed plugins
8080
const plugins = rbacWithPlugins.plugins.getPlugins();
81-
console.log('Plugins instalados:', plugins.map((p: any) => p.name));
81+
console.log('Installed plugins:', plugins.map((p: any) => p.name));
8282

83-
// 6. Usar hooks utilitários
83+
// 6. Use utility hooks
8484
const businessHoursFilter = rbacWithPlugins.hooks.createBusinessHoursFilter();
8585
const userFilter = rbacWithPlugins.hooks.createUserFilter(['user1', 'user2']);
8686
const logger = rbacWithPlugins.hooks.createLogger('info');
8787

88-
// 7. Exemplo de plugin customizado
88+
// 7. Custom plugin example
8989
const customPlugin = {
9090
metadata: {
9191
name: 'custom-logger',
9292
version: '1.0.0',
93-
description: 'Plugin customizado para logging detalhado',
94-
author: 'Desenvolvedor',
93+
description: 'Custom plugin for detailed logging',
94+
author: 'Developer',
9595
keywords: ['logging', 'custom']
9696
},
9797

9898
install: async (context: any) => {
99-
context.logger('Plugin customizado instalado!', 'info');
99+
context.logger('Custom plugin installed!', 'info');
100100
},
101101

102102
uninstall: () => {
103-
console.log('Plugin customizado desinstalado!');
103+
console.log('Custom plugin uninstalled!');
104104
},
105105

106106
getHooks: () => ({
107107
beforePermissionCheck: async (data: any, context: any) => {
108-
context.logger(`Verificando permissão: ${data.role} -> ${data.operation}`, 'info');
108+
context.logger(`Checking permission: ${data.role} -> ${data.operation}`, 'info');
109109
return data;
110110
},
111111

112112
afterPermissionCheck: async (data: any, context: any) => {
113-
context.logger(`Resultado: ${data.result ? 'PERMITIDO' : 'NEGADO'}`, 'info');
113+
context.logger(`Result: ${data.result ? 'ALLOWED' : 'DENIED'}`, 'info');
114114
return data;
115115
}
116116
})
117117
};
118118

119119
await rbacWithPlugins.plugins.install(customPlugin);
120120

121-
// 8. Testar com plugin customizado
122-
console.log('\nTestando com plugin customizado...');
121+
// 8. Test with custom plugin
122+
console.log('\nTesting with custom plugin...');
123123
await rbacWithPlugins.can('user', 'products:read');
124124

125-
// 9. Desabilitar plugin
125+
// 9. Disable plugin
126126
await rbacWithPlugins.plugins.disable('custom-logger');
127-
console.log('Plugin customizado desabilitado');
127+
console.log('Custom plugin disabled');
128128

129-
// 10. Reabilitar plugin
129+
// 10. Re-enable plugin
130130
await rbacWithPlugins.plugins.enable('custom-logger');
131-
console.log('Plugin customizado reabilitado');
131+
console.log('Custom plugin re-enabled');
132132

133-
// 11. Desinstalar plugin
133+
// 11. Uninstall plugin
134134
await rbacWithPlugins.plugins.uninstall('custom-logger');
135-
console.log('Plugin customizado desinstalado');
135+
console.log('Custom plugin uninstalled');
136136
}
137137

138-
// Exemplo de plugin de middleware
138+
// Middleware plugin example
139139
export const createExpressMiddlewarePlugin = (app: any) => ({
140140
metadata: {
141141
name: 'express-middleware',
142142
version: '1.0.0',
143-
description: 'Plugin para integração com Express.js',
143+
description: 'Plugin for Express.js integration',
144144
author: 'RBAC Team',
145145
keywords: ['express', 'middleware', 'http']
146146
},
147147

148148
install: async (context: any) => {
149-
context.logger('Express middleware plugin instalado', 'info');
149+
context.logger('Express middleware plugin installed', 'info');
150150
},
151151

152152
uninstall: () => {
153-
console.log('Express middleware plugin desinstalado');
153+
console.log('Express middleware plugin uninstalled');
154154
},
155155

156156
getHooks: () => ({
157157
beforePermissionCheck: async (data: any, context: any) => {
158-
// Adicionar informações da requisição HTTP
158+
// Add HTTP request information
159159
return {
160160
...data,
161161
metadata: {
162162
...data.metadata,
163-
httpMethod: 'GET', // Exemplo
164-
userAgent: 'Mozilla/5.0...', // Exemplo
165-
ipAddress: '192.168.1.1' // Exemplo
163+
httpMethod: 'GET', // Example
164+
userAgent: 'Mozilla/5.0...', // Example
165+
ipAddress: '192.168.1.1' // Example
166166
}
167167
};
168168
}
169169
})
170170
});
171171

172-
// Exemplo de plugin de cache Redis
172+
// Redis cache plugin example
173173
export const createRedisCachePlugin = (redisClient: any) => ({
174174
metadata: {
175175
name: 'redis-cache',
176176
version: '1.0.0',
177-
description: 'Plugin de cache usando Redis',
177+
description: 'Cache plugin using Redis',
178178
author: 'RBAC Team',
179179
keywords: ['redis', 'cache', 'performance']
180180
},
181181

182182
install: async (context: any) => {
183-
context.logger('Redis cache plugin instalado', 'info');
183+
context.logger('Redis cache plugin installed', 'info');
184184
},
185185

186186
uninstall: () => {
187-
console.log('Redis cache plugin desinstalado');
187+
console.log('Redis cache plugin uninstalled');
188188
},
189189

190190
getHooks: () => ({
@@ -210,16 +210,16 @@ export const createRedisCachePlugin = (redisClient: any) => ({
210210
afterPermissionCheck: async (data: any, context: any) => {
211211
if (data.result !== undefined) {
212212
const cacheKey = `rbac:${data.role}:${data.operation}`;
213-
await redisClient.setex(cacheKey, 300, JSON.stringify(data.result)); // 5 minutos
214-
context.logger(`Resultado armazenado no Redis: ${cacheKey}`, 'info');
213+
await redisClient.setex(cacheKey, 300, JSON.stringify(data.result)); // 5 minutes
214+
context.logger(`Result stored in Redis: ${cacheKey}`, 'info');
215215
}
216216

217217
return data;
218218
}
219219
})
220220
});
221221

222-
// Executar exemplo
222+
// Run example
223223
if (require.main === module) {
224-
exemploUso().catch(console.error);
224+
usageExample().catch(console.error);
225225
}

0 commit comments

Comments
 (0)