Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions .changeset/34921-system-overview-dataset-words.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
'@objectstack/platform-objects': patch
---

feat(platform-objects): the System Overview datasets give their seven members synonyms and a description

Clause-②: no
Metadata-protocol: none

The five System Overview datasets (`sys_user_metrics`, `sys_organization_metrics`, `sys_session_metrics`, `sys_package_installation_metrics`, `sys_audit_log_metrics`) had no business words on their seven members. A question asked in an administrator's own words therefore found only a member's name or its label in the caller's locale. Each member now declares ADR-0149 D1 `synonyms`, Chinese and English in one array, and a one-sentence `description`:

- measures `user_count`, `org_count`, `session_count`, `package_count`, `event_count`;
- dimensions `action` and `user_id` on `sys_audit_log_metrics`.

Synonyms are match input, so no bundle translates them. Each description has a bundle entry at `datasets.<name>.{measures,dimensions}.<member>.description` in all eleven Setup bundle locales, and a recorded source digest in each translated locale.

`list_datasets` compares a term by equality after normalization. So `list_datasets({ terms: ['用户数'] })` and `list_datasets({ terms: ['how many users'] })` now each match `sys_user_metrics.measures.user_count` on a synonym, and nothing else. A word that no member declares still matches nothing. No synonym is a word of another measure in any of the five datasets, in any locale.
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,13 @@

import { describe, it, expect } from 'vitest';
import { translateDataset } from '@objectstack/spec/system';
import { DatasetSchema, normalizeDatasetTerm } from '@objectstack/spec/ui';
import { SystemOverviewDashboard } from './system_overview.dashboard.js';
import { SystemOverviewDatasets } from './system.datasets.js';
import { SetupAppTranslations } from '../translations/index.js';
import { en } from '../translations/en.js';

type Member = { name: string; label?: unknown };
type Member = { name: string; label?: unknown; description?: unknown; synonyms?: readonly string[] };
type Group = 'measures' | 'dimensions';

const datasetsByName = new Map(SystemOverviewDatasets.map((d) => [d.name, d]));
Expand Down Expand Up @@ -107,3 +108,82 @@ describe('System Overview: every dataset label the board draws is translated', (
});
}
});

// ADR-0149 D1: each of the seven members carries the words an administrator
// asks for it in (`synonyms`, every language in one authored array, never
// bundled) and a one-sentence business definition (`description`, display
// copy, translated beside the label). What `list_datasets` then answers for
// those words is pinned where these datasets meet the dataset tools:
// `packages/rest/src/system-overview-dataset-vocabulary.test.ts`.
describe('System Overview: every dataset member carries its business vocabulary', () => {
const members = SystemOverviewDatasets.flatMap((d) =>
(['dimensions', 'measures'] as const).flatMap((group) =>
((d[group] ?? []) as Member[]).map((m) => ({ dataset: d.name, group, member: m }))));

it('the seven members each declare synonyms in Chinese and English, and a description', () => {
expect(members.map(({ dataset, group, member }) => `${dataset}.${group}.${member.name}`)).toHaveLength(7);
for (const { dataset, group, member } of members) {
const at = `${dataset}.${group}.${member.name}`;
expect(member.description, at).toBeTypeOf('string');
const synonyms = member.synonyms ?? [];
expect(synonyms.some((s) => /\p{Script=Han}/u.test(s)), `${at}: a Chinese synonym`).toBe(true);
expect(synonyms.some((s) => /^[a-z ]+$/.test(s)), `${at}: an English synonym`).toBe(true);
}
});

it('each dataset survives a full parse, vocabulary rules included', () => {
for (const dataset of SystemOverviewDatasets) {
const parsed = DatasetSchema.safeParse(dataset);
expect(parsed.success, `${dataset.name}: ${parsed.success ? '' : parsed.error.message}`).toBe(true);
}
});

it('no synonym is a word of another measure in any of the five datasets, in any locale', () => {
// Two measures answering to one word make the tools ask which one is meant.
// The schema judges collisions within one dataset; this holds the five
// together, against the label each locale serves.
const collisions: string[] = [];
for (const locale of Object.keys(SetupAppTranslations)) {
const served = SystemOverviewDatasets.map((d) => translateDataset(d, SetupAppTranslations, { locale }));
const measureWords = served.flatMap((d) => ((d.measures ?? []) as Member[]).map((m) => ({
owner: `${d.name}.measures.${m.name}`,
words: [m.name, ...(typeof m.label === 'string' ? [m.label] : []), ...(m.synonyms ?? [])].map(normalizeDatasetTerm),
})));
for (const { dataset, group, member } of members) {
const owner = `${dataset}.${group}.${member.name}`;
for (const synonym of member.synonyms ?? []) {
for (const other of measureWords) {
if (other.owner !== owner && other.words.includes(normalizeDatasetTerm(synonym))) {
collisions.push(`${locale}: "${synonym}" of ${owner} is a word of ${other.owner}`);
}
}
}
}
}
expect(collisions).toEqual([]);
});

it('en: the bundle copies each member description from the declared source verbatim', () => {
const drift: string[] = [];
for (const { dataset, group, member } of members) {
const served = (en.datasets?.[dataset]?.[group] as Record<string, { description?: string }> | undefined)?.[member.name]?.description;
if (served !== member.description) {
drift.push(`datasets.${dataset}.${group}.${member.name}.description: ${JSON.stringify(served)} ≠ ${JSON.stringify(member.description)}`);
}
}
expect(drift).toEqual([]);
});

for (const locale of TRANSLATED_LOCALES) {
it(`${locale}: no member description resolves to the English source`, () => {
const english: string[] = [];
for (const { dataset, group, member } of members) {
const doc = datasetsByName.get(dataset)!;
const served = translateDataset(doc, SetupAppTranslations, { locale });
const description = ((served[group] ?? []) as Member[]).find((m) => m.name === member.name)?.description;
if (description === member.description) english.push(`datasets.${dataset}.${group}.${member.name}.description`);
}
expect(english, `untranslated dataset member descriptions under ${locale}`).toEqual([]);
});
}
});
89 changes: 83 additions & 6 deletions packages/platform-objects/src/apps/dashboards/system.datasets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,46 +9,110 @@ import { defineDataset } from '@objectstack/spec/ui';
* datasets reference objects BY NAME, so co-locating them with the dashboard
* (registered by plugin-auth) is fine; the widgets that target absent objects
* are runtime-gated via `requiresObject`.
*
* Each member carries its business vocabulary (ADR-0149 D1): `synonyms`, the
* words an administrator types for it in a question, Chinese and English in
* the one authored array (a synonym is match input, never translated, so no
* bundle carries it), and a one-sentence `description`, which is display copy
* and is translated at `datasets.<name>.{measures,dimensions}.<member>.description`.
* These datasets reach the dataset AI tools through plugin-auth's runtime
* manifest, where the vocabulary advisory never reads them, so nothing but
* this file gives them words.
*
* The dataset tools match a term by EQUALITY after `normalizeDatasetTerm`, so
* a phrase an administrator asks in ("how many users", 「有多少用户」) answers
* only where it is written as one synonym. No synonym below is a word of
* another measure in any of the five datasets, in any locale: a word on two
* measures makes the tools ask which one is meant. The other language's label
* is listed too (`users` beside 「用户」), because the label a caller is matched
* against is the one served in the caller's locale. 「用户」 is also the zh-CN
* label of the audit log's `user_id` dimension; a dimension match alone picks
* no number, so the word still answers with `user_count`.
*/

export const SysUserDataset = defineDataset({
name: 'sys_user_metrics',
label: 'User Metrics',
object: 'sys_user',
dimensions: [],
measures: [{ name: 'user_count', label: 'Users', aggregate: 'count' }],
measures: [{
name: 'user_count',
label: 'Users',
aggregate: 'count',
description: 'The number of user accounts on record, active or not.',
synonyms: [
'用户', '用户数', '用户数量', '用户总数', '有多少用户',
'users', 'user count', 'number of users', 'total users', 'how many users',
],
}],
});

export const SysOrganizationDataset = defineDataset({
name: 'sys_organization_metrics',
label: 'Organization Metrics',
object: 'sys_organization',
dimensions: [],
measures: [{ name: 'org_count', label: 'Organizations', aggregate: 'count' }],
measures: [{
name: 'org_count',
label: 'Organizations',
aggregate: 'count',
description: 'The number of organizations on record; each one keeps its own members, data and settings.',
synonyms: [
'组织', '组织数', '组织数量', '组织总数', '有多少组织',
'organizations', 'orgs', 'organization count', 'number of organizations', 'how many organizations',
],
}],
});

export const SysSessionDataset = defineDataset({
name: 'sys_session_metrics',
label: 'Session Metrics',
object: 'sys_session',
dimensions: [],
measures: [{ name: 'session_count', label: 'Sessions', aggregate: 'count' }],
measures: [{
name: 'session_count',
label: 'Sessions',
aggregate: 'count',
description: 'The number of sign-in sessions on record, one per sign-in from a browser or device.',
synonyms: [
'会话', '会话数', '会话数量', '登录会话', '有多少会话',
'sessions', 'session count', 'number of sessions', 'login sessions', 'how many sessions',
],
}],
});

export const SysPackageInstallationDataset = defineDataset({
name: 'sys_package_installation_metrics',
label: 'Package Installation Metrics',
object: 'sys_package_installation',
dimensions: [],
measures: [{ name: 'package_count', label: 'Installations', aggregate: 'count' }],
measures: [{
name: 'package_count',
label: 'Installations',
aggregate: 'count',
description: 'The number of package installations on record, one per package installed.',
synonyms: [
'已安装的包', '安装的包数', '包安装数', '装了多少包',
'installations', 'installed packages', 'package installations', 'package count',
'number of installed packages', 'how many packages are installed',
],
}],
});

export const SysAuditLogDataset = defineDataset({
name: 'sys_audit_log_metrics',
label: 'Audit Log Metrics',
object: 'sys_audit_log',
dimensions: [
{ name: 'action', label: 'Action', field: 'action', type: 'string' },
{
name: 'action',
label: 'Action',
field: 'action',
type: 'string',
description:
'The kind of action an audit log entry records, such as create, update, delete, login or a configuration change.',
synonyms: ['操作类型', '动作', '审计动作', 'action type', 'operation', 'audit action'],
},
// Rows the platform writes itself carry no `user_id`; their bucket reads
// "System", not the renderer's default "(None)". An inline locale map:
// the translation bundles have no slot for a dimension's null label.
Expand All @@ -57,10 +121,23 @@ export const SysAuditLogDataset = defineDataset({
label: 'User',
field: 'user_id',
type: 'lookup',
description:
'The user who performed the audited action; entries the platform writes itself are grouped under System.',
synonyms: ['操作人', '操作者', '执行人', '操作用户', 'actor', 'performed by', 'acting user'],
nullLabel: { en: 'System', 'zh-CN': '系统', 'ja-JP': 'システム', 'es-ES': 'Sistema', 'zh-Hant': '系統', ar: 'النظام', fr: 'Système', 'pt-BR': 'Sistema', ru: 'Система', de: 'System', ko: '시스템' },
},
],
measures: [{ name: 'event_count', label: 'Events', aggregate: 'count' }],
measures: [{
name: 'event_count',
label: 'Events',
aggregate: 'count',
description:
'The number of audit log entries; each records one action taken in the system, by a user or by the platform itself.',
synonyms: [
'事件', '事件数', '审计事件', '审计事件数', '审计日志条数', '有多少审计事件',
'events', 'event count', 'audit events', 'audit log entries', 'how many audit events',
],
}],
});

export const SystemOverviewDatasets = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,12 +182,19 @@ export const arSourceHashes: Readonly<Record<string, string>> = {
'dashboards.system_overview.widgets.widget_recent_events.description': '5b9ce7479f6c178c',
'dashboards.system_overview.globalFilters.created_at.label': 'dcba3619736cb533',
'datasets.sys_user_metrics.measures.user_count.label': 'eee81f7307a66c40',
'datasets.sys_user_metrics.measures.user_count.description': '51488331523a478a',
'datasets.sys_organization_metrics.measures.org_count.label': '07488357631b973d',
'datasets.sys_organization_metrics.measures.org_count.description': 'bccb13ceedcde9a6',
'datasets.sys_session_metrics.measures.session_count.label': '673bde6e0c8a3ef9',
'datasets.sys_session_metrics.measures.session_count.description': '2f16ee1a53845763',
'datasets.sys_package_installation_metrics.measures.package_count.label': 'bd7a67c9d5b3ac44',
'datasets.sys_package_installation_metrics.measures.package_count.description': 'a7df1b2983457515',
'datasets.sys_audit_log_metrics.dimensions.action.label': 'a36bba313a7aa9ab',
'datasets.sys_audit_log_metrics.dimensions.action.description': '427e65dc65d1ec06',
'datasets.sys_audit_log_metrics.dimensions.user_id.label': '6c0d22a931e235bd',
'datasets.sys_audit_log_metrics.dimensions.user_id.description': '6e107d34eb914730',
'datasets.sys_audit_log_metrics.measures.event_count.label': '41e7c95aaa871569',
'datasets.sys_audit_log_metrics.measures.event_count.description': '9d8081ef53838a60',
'pages.cloud_connection_settings.label': '3a7caad0cb98e71d',
'pages.cloud_connection_settings.subtitle': 'f5cdd253e8ffef9f',
'pages.connect_agent.label': 'a4542422fb5e8a68',
Expand Down
54 changes: 48 additions & 6 deletions packages/platform-objects/src/apps/translations/ar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -187,13 +187,55 @@ export const ar: TranslationData = {
},

datasets: {
sys_user_metrics: { measures: { user_count: { label: 'المستخدمون' } } },
sys_organization_metrics: { measures: { org_count: { label: 'المؤسسات' } } },
sys_session_metrics: { measures: { session_count: { label: 'الجلسات' } } },
sys_package_installation_metrics: { measures: { package_count: { label: 'عمليات التثبيت' } } },
sys_user_metrics: {
measures: {
user_count: {
label: 'المستخدمون',
description: 'عدد حسابات المستخدمين المسجلة، النشطة وغير النشطة.',
},
},
},
sys_organization_metrics: {
measures: {
org_count: {
label: 'المؤسسات',
description: 'عدد المؤسسات المسجلة؛ لكل مؤسسة أعضاؤها وبياناتها وإعداداتها الخاصة.',
},
},
},
sys_session_metrics: {
measures: {
session_count: {
label: 'الجلسات',
description: 'عدد جلسات تسجيل الدخول المسجلة، جلسة واحدة لكل تسجيل دخول من متصفح أو جهاز.',
},
},
},
sys_package_installation_metrics: {
measures: {
package_count: {
label: 'عمليات التثبيت',
description: 'عدد عمليات تثبيت الحزم المسجلة، عملية واحدة لكل حزمة مثبتة.',
},
},
},
sys_audit_log_metrics: {
dimensions: { action: { label: 'الإجراء' }, user_id: { label: 'المستخدم' } },
measures: { event_count: { label: 'الأحداث' } },
dimensions: {
action: {
label: 'الإجراء',
description: 'نوع الإجراء الذي يسجله إدخال سجل التدقيق، مثل الإنشاء أو التحديث أو الحذف أو تسجيل الدخول أو تغيير الإعدادات.',
},
user_id: {
label: 'المستخدم',
description: 'المستخدم الذي نفّذ الإجراء الخاضع للتدقيق؛ تُجمع الإدخالات التي تكتبها المنصة بنفسها تحت «النظام».',
},
},
measures: {
event_count: {
label: 'الأحداث',
description: 'عدد إدخالات سجل التدقيق؛ يسجل كل إدخال إجراءً واحدًا نُفّذ في النظام من قِبل مستخدم أو من قِبل المنصة نفسها.',
},
},
},
},

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,12 +183,19 @@ export const deSourceHashes: Readonly<Record<string, string>> = {
'dashboards.system_overview.widgets.widget_recent_events.description': '5b9ce7479f6c178c',
'dashboards.system_overview.globalFilters.created_at.label': 'dcba3619736cb533',
'datasets.sys_user_metrics.measures.user_count.label': 'eee81f7307a66c40',
'datasets.sys_user_metrics.measures.user_count.description': '51488331523a478a',
'datasets.sys_organization_metrics.measures.org_count.label': '07488357631b973d',
'datasets.sys_organization_metrics.measures.org_count.description': 'bccb13ceedcde9a6',
'datasets.sys_session_metrics.measures.session_count.label': '673bde6e0c8a3ef9',
'datasets.sys_session_metrics.measures.session_count.description': '2f16ee1a53845763',
'datasets.sys_package_installation_metrics.measures.package_count.label': 'bd7a67c9d5b3ac44',
'datasets.sys_package_installation_metrics.measures.package_count.description': 'a7df1b2983457515',
'datasets.sys_audit_log_metrics.dimensions.action.label': 'a36bba313a7aa9ab',
'datasets.sys_audit_log_metrics.dimensions.action.description': '427e65dc65d1ec06',
'datasets.sys_audit_log_metrics.dimensions.user_id.label': '6c0d22a931e235bd',
'datasets.sys_audit_log_metrics.dimensions.user_id.description': '6e107d34eb914730',
'datasets.sys_audit_log_metrics.measures.event_count.label': '41e7c95aaa871569',
'datasets.sys_audit_log_metrics.measures.event_count.description': '9d8081ef53838a60',
'pages.cloud_connection_settings.label': '3a7caad0cb98e71d',
'pages.cloud_connection_settings.subtitle': 'f5cdd253e8ffef9f',
'pages.connect_agent.label': 'a4542422fb5e8a68',
Expand Down
Loading
Loading