Skip to content

Commit

Permalink
feat(i18n): add auth help codes & more connectors i18n
Browse files Browse the repository at this point in the history
  • Loading branch information
0721Betty authored and ysfscream committed Jan 17, 2024
1 parent 41fd338 commit f702283
Show file tree
Hide file tree
Showing 6 changed files with 167 additions and 13 deletions.
6 changes: 6 additions & 0 deletions packages/i18n/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# @emqx/shared-ui-i18n

## 0.0.7

### Patch Changes

- add auth code help files & adapt more connectors i18n

## 0.0.6

### Patch Changes
Expand Down
18 changes: 18 additions & 0 deletions packages/i18n/lib/__test__/authHelpCodeMap.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { authHelpCodeMap } from '../authHelpCodeMap'
import { describe, it, expect } from 'vitest'

describe('sqlTemplate', () => {
it('contains expected auth code map keys', () => {
const expectedKeys = ['authn', 'authz']
expectedKeys.forEach((key) => {
expect(authHelpCodeMap).toHaveProperty(key)
})

const expectedSubKeys = ['mysql', 'postgresql', 'mongodb', 'redis']
Object.values(authHelpCodeMap).forEach((value) => {
expectedSubKeys.forEach((subKey) => {
expect(value).toHaveProperty(subKey)
})
})
})
})
86 changes: 86 additions & 0 deletions packages/i18n/lib/authHelpCodeMap.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
export const authHelpCodeMap = {
authn: {
mysql: `CREATE TABLE IF NOT EXISTS \`mqtt_user\` (
\`id\` int(11) unsigned NOT NULL AUTO_INCREMENT,
\`username\` varchar(100) DEFAULT NULL,
\`password_hash\` varchar(100) DEFAULT NULL,
\`salt\` varchar(35) DEFAULT NULL,
\`is_superuser\` tinyint(1) DEFAULT 0,
\`created\` datetime DEFAULT NULL,
PRIMARY KEY (\`id\`),
UNIQUE KEY \`mqtt_username\` (\`username\`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;`,
postgresql: `CREATE TABLE mqtt_user (
id SERIAL primary key,
is_superuser boolean,
username character varying(100),
password_hash character varying(100),
salt character varying(40)
)`,
mongodb: `{
username: "emqx_user",
password_hash: "******",
salt: "foo+bar",
is_superuser: false,
created: "2021-01-01 12:00:01"
}
db.mqtt_user.findOne({"username": "emqx_user"})`,
redis: `# sample data
HMSET mqtt_user:emqx_u password_hash *** salt foo+bar is_superuser 1
# sample cmd
# HMGET mqtt_user:\${username}
## only password
HMGET mqtt_user:emqx_u password_hash
## password + salt
HMGET mqtt_user:emqx_u password_hash salt
## password + salt, enable superuser
HMGET mqtt_user:emqx_u password_hash salt is_superuser
## only password, enable superuser
HMGET mqtt_user:emqx_u password_hash is_superuser`,
},
authz: {
mysql: `CREATE TABLE \`mqtt_acl\` (
\`id\` int(11) unsigned NOT NULL AUTO_INCREMENT,
\`ipaddress\` VARCHAR(60) NOT NULL DEFAULT '',
\`username\` VARCHAR(255) NOT NULL DEFAULT '',
\`clientid\` VARCHAR(255) NOT NULL DEFAULT '',
\`action\` ENUM('publish', 'subscribe', 'all') NOT NULL,
\`permission\` ENUM('allow', 'deny') NOT NULL,
\`topic\` VARCHAR(255) NOT NULL DEFAULT '',
PRIMARY KEY (\`id\`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;`,
postgresql: `CREATE TYPE ACTION AS ENUM('publish','subscribe','all');
CREATE TYPE PERMISSION AS ENUM('allow','deny');
CREATE TABLE mqtt_acl (
id SERIAL PRIMARY KEY,
ipaddress CHARACTER VARYING(60) NOT NULL DEFAULT '',
username CHARACTER VARYING(255) NOT NULL DEFAULT '',
clientid CHARACTER VARYING(255) NOT NULL DEFAULT '',
action ACTION,
permission PERMISSION,
topic CHARACTER VARYING(255) NOT NULL
);`,
mongodb: `{
username: "emqx_u",
clientid: "emqx_c",
ipaddress: "127.0.0.1",
permission: "allow",
action: "all",
topics: ["#"]
}
db.mqtt_acl.findOne({"username": "emqx_user"})`,
redis: `# sample data
HSET mqtt_acl:emqx_u 't/#' subscribe
# sample cmd
HGETALL mqtt_acl:\${username}`,
},
}
34 changes: 28 additions & 6 deletions packages/i18n/lib/enConnectorsLabel.ts
Original file line number Diff line number Diff line change
@@ -1,26 +1,48 @@
export const enConnectorsLabel: Record<string, Record<string, string>> = {
common: {
connect_timeout: 'Connect Timeout',
},
kafka_producer: {
bootstrap_hosts: 'Bootstrap Hosts',
min_metadata_refresh_interval: 'Min Metadata Refresh Interval',
metadata_request_timeout: 'Metadata Request Timeout',
tcp_keepalive: 'TCP Keepalive',
sndbuf: 'Socket Send Buffer Size',
recbuf: 'Socket Receive Buffer Size',
nodelay: 'No Delay',
username: 'Username',
password: 'Password',
pool_size: 'Connection Pool Size',
pool_type: 'Pool Type',
server: 'Server Host',
database: 'Database Name',
health_check_interval: 'Health Check Interval',
start_timeout: 'Start Timeout',
max_retries: 'Max Retries',
worker_pool_size: 'Buffer Pool Size',
request_ttl: 'Request TTL',
max_buffer_bytes: 'Max Buffer Queue Size',
inflight_window: 'Inflight Window',
},
kafka_producer: {
kerberos_principal: 'Kerberos Principal',
kerberos_keytab_file: 'Kerberos keytab file',
mechanism: 'Mechanism',
username: 'Username',
password: 'Password',
},
http: {
url: 'URL',
headers: 'Headers',
enable_pipelining: 'HTTP Pipelining',
pool_size: 'Connection Pool Size',
pool_type: 'Pool Type',
},
gcp_pubsub_producer: {
pipelining: 'HTTP Pipelining',
service_account_json: 'GCP Service Account Credentials',
query_mode: 'Query Mode',
batch_size: 'Batch Size',
},
azure_event_hub_producer: {
bootstrap_hosts: 'Bootstrap Hosts',
},
syskeeper_forwarder: {
ack_mode: 'ACK Mode',
ack_timeout: 'ACK Timeout',
},
}
34 changes: 28 additions & 6 deletions packages/i18n/lib/zhConnectorsLabel.ts
Original file line number Diff line number Diff line change
@@ -1,26 +1,48 @@
export const zhConnectorsLabel: Record<string, Record<string, string>> = {
common: {
connect_timeout: '连接超时',
},
kafka_producer: {
bootstrap_hosts: '主机列表',
min_metadata_refresh_interval: '元数据刷新最小间隔',
metadata_request_timeout: '元数据请求超时',
tcp_keepalive: 'TCP Keepalive',
sndbuf: 'Socket 发送缓存大小',
recbuf: 'Socket 收包缓存大小',
nodelay: '是否关闭延迟发送',
username: '用户名',
password: '密码',
pool_size: '连接池大小',
pool_type: '连接池类型',
server: '服务器地址',
database: '数据库名字',
health_check_interval: '健康检查间隔',
start_timeout: '启动超时时间',
max_retries: '最大重试次数',
worker_pool_size: '缓存池大小',
request_ttl: '请求超期',
max_buffer_bytes: '缓存队列最大长度',
inflight_window: '请求飞行队列窗口',
},
kafka_producer: {
kerberos_principal: 'Kerberos Principal',
kerberos_keytab_file: 'Kerberos keytab 文件',
mechanism: '认证方法',
username: '用户名',
password: '密码',
},
http: {
url: 'URL',
headers: '请求头',
enable_pipelining: 'HTTP 管道',
pool_size: '连接池大小',
pool_type: '连接池类型',
},
gcp_pubsub_producer: {
pipelining: 'HTTP 流水线',
service_account_json: 'GCP 服务账户凭证',
query_mode: '请求模式',
batch_size: '最大批量请求大小',
},
azure_event_hub_producer: {
bootstrap_hosts: '引导主机',
},
syskeeper_forwarder: {
ack_mode: 'ACK 模式',
ack_timeout: 'ACK 超时',
},
}
2 changes: 1 addition & 1 deletion packages/i18n/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@emqx/shared-ui-i18n",
"version": "0.0.6",
"version": "0.0.7",
"homepage": "https://emqx.io",
"license": "Apache-2.0",
"repository": {
Expand Down

0 comments on commit f702283

Please sign in to comment.