@things-factory/i18n-base 10.1.278 → 10.1.279

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (31) hide show
  1. package/package.json +21 -5
  2. package/CHANGELOG.md +0 -8
  3. package/dist-client/bootstrap.js.map +0 -1
  4. package/dist-client/index.js.map +0 -1
  5. package/dist-client/page/terminology-page.js.map +0 -1
  6. package/dist-client/route.js.map +0 -1
  7. package/dist-client/tsconfig.tsbuildinfo +0 -1
  8. package/dist-server/ai-entry/entry-target-shape.js.map +0 -1
  9. package/dist-server/ai-entry/terminology-entry-rules.js.map +0 -1
  10. package/dist-server/ai-entry/terminology-entry-targets.js.map +0 -1
  11. package/dist-server/apis/index.js.map +0 -1
  12. package/dist-server/apis/t.js.map +0 -1
  13. package/dist-server/controllers/clear-cache-for-translation.js.map +0 -1
  14. package/dist-server/index.js.map +0 -1
  15. package/dist-server/middlewares/index.js.map +0 -1
  16. package/dist-server/middlewares/koa-i18next/detect.js.map +0 -1
  17. package/dist-server/middlewares/koa-i18next/index.js.map +0 -1
  18. package/dist-server/role-tasks.js.map +0 -1
  19. package/dist-server/routers/translations-router.js.map +0 -1
  20. package/dist-server/routes.js.map +0 -1
  21. package/dist-server/service/index.js.map +0 -1
  22. package/dist-server/service/terminology/index.js.map +0 -1
  23. package/dist-server/service/terminology/terminology-mutation.js.map +0 -1
  24. package/dist-server/service/terminology/terminology-query.js.map +0 -1
  25. package/dist-server/service/terminology/terminology-type.js.map +0 -1
  26. package/dist-server/service/terminology/terminology.js.map +0 -1
  27. package/dist-server/translator.js.map +0 -1
  28. package/dist-server/tsconfig.tsbuildinfo +0 -1
  29. package/tests/preload.test.ts +0 -23
  30. package/tests/terminology-categories.test.ts +0 -14
  31. package/tests/terminology-entry-targets.test.ts +0 -136
@@ -1,23 +0,0 @@
1
- import { readFileSync } from 'fs'
2
- import path from 'path'
3
-
4
- /*
5
- * The server preloads the languages the framework speaks, by the language part of each configured code.
6
- * It said 'jp' for Japanese until 2026-10-10 - i18next loaded nothing under that name, so a Japanese
7
- * server-side message fell back to English.
8
- */
9
- const root = path.resolve(__dirname, '..')
10
-
11
- const preloaded = () => {
12
- const source = readFileSync(path.join(root, 'server', 'translator.ts'), 'utf-8')
13
- const list = source.match(/preload:\s*\[([^\]]*)\]/)![1]
14
- return [...list.matchAll(/'([^']+)'/g)].map(([, code]) => code).sort()
15
- }
16
-
17
- describe('the languages the server preloads', () => {
18
- it.each(['config.development.js', 'config.production.js'])('are the languages %s lists', file => {
19
- const { i18n } = require(path.join(root, 'config', file))
20
- const configured = i18n.languages.map(({ code }: { code: string }) => code.split('-')[0]).sort()
21
- expect(preloaded()).toEqual(configured)
22
- })
23
- })
@@ -1,14 +0,0 @@
1
- /* Inline help audit 2026-10-30: the terminology grid offered its categories as the raw prefixes button, field, label. */
2
- import { readFileSync } from 'fs'
3
- import { join } from 'path'
4
-
5
- const ROOT = join(__dirname, '..')
6
- const read = (file: string) => readFileSync(join(ROOT, file), 'utf8')
7
-
8
- test('★ a category is offered by its name in the reader’s language, the stored value unchanged', () => {
9
- expect(read('client/page/terminology-page.ts')).not.toMatch(/options: \['', 'button', 'field'/)
10
- for (const lang of ['ko', 'en', 'ja', 'zh', 'es', 'ms']) {
11
- const words = JSON.parse(read(`translations/${lang}.json`))
12
- for (const category of ['button', 'field', 'label', 'menu', 'text', 'title']) expect([lang, category, !!words[`label.term-category-${category}`]]).toEqual([lang, category, true])
13
- }
14
- })
@@ -1,136 +0,0 @@
1
- /*
2
- * The terminology's AI 입력 declaration. The assistant's own validation is asked through its source file,
3
- * which needs only `graphql` - the package keeps no run-time dependency on the assistant.
4
- */
5
- import { parse } from 'graphql'
6
-
7
- import { clearEntryTargets, declareEntryTarget } from '../../ai-assistant/server/service/data-entry/entry-target'
8
- import { terminologyChangeIssues, terminologyIssues } from '../server/ai-entry/terminology-entry-rules'
9
- import { TERMINOLOGY_CATEGORIES, terminologyEntryTarget, terminologyEntryTargets } from '../server/ai-entry/terminology-entry-targets'
10
-
11
- import en from '../translations/en.json'
12
- import es from '../translations/es.json'
13
- import ja from '../translations/ja.json'
14
- import ko from '../translations/ko.json'
15
- import ms from '../translations/ms.json'
16
- import zh from '../translations/zh.json'
17
-
18
- const LANGUAGES: Record<string, Record<string, string>> = { en, es, ja, ko, ms, zh }
19
-
20
- const rootFields = (document: string) => {
21
- const operations = parse(document).definitions.filter((one: any) => one.kind === 'OperationDefinition') as any[]
22
- expect(operations).toHaveLength(1)
23
- return operations[0].selectionSet.selections.map((one: any) => one.name.value)
24
- }
25
-
26
- const row = (values: Record<string, unknown>, index = 0) => ({ index, values, sources: [], issues: [] })
27
- const term = (locale: string, category: string, name: string, display = 'x') => row({ locale, category, name, display })
28
-
29
- describe('terminology entry target', () => {
30
- afterEach(() => clearEntryTargets())
31
-
32
- it('is accepted by the assistant as it is declared', () => {
33
- const [target] = terminologyEntryTargets({ locales: ['ko-KR', 'en-US'] })
34
- expect(target.key).toBe('i18n-base.terminology')
35
- expect(() => declareEntryTarget(target as any)).not.toThrow()
36
- })
37
-
38
- it('without a list given, the locales are the configured languages (or the framework six)', () => {
39
- const locale = terminologyEntryTarget().fields.find(field => field.name === 'locale')!
40
- expect(locale.type).toBe('enum')
41
- expect(locale.values!.length).toBeGreaterThan(0)
42
- expect(terminologyEntryTarget().fields.find(field => field.name === 'category')!.values).toEqual(TERMINOLOGY_CATEGORIES)
43
- })
44
-
45
- it('every document has one root field', () => {
46
- const target = terminologyEntryTarget({ locales: ['ko-KR'] })
47
- expect(rootFields(target.mutation)).toEqual(['createTerminology'])
48
- expect(rootFields(target.update!.mutation)).toEqual(['updateTerminology'])
49
- expect(rootFields(target.update!.read.query)).toEqual(['terminologies'])
50
- expect(rootFields(target.update!.find!.query)).toEqual(['terminologies'])
51
- })
52
-
53
- it('create and patch carry the declared fields only', () => {
54
- const target = terminologyEntryTarget({ locales: ['ko-KR'] })
55
- expect(target.variables(row({ locale: 'ko-KR', category: 'label', name: 'department', display: '부서', domain: 'x', id: 'y' }))).toEqual({
56
- terminology: { locale: 'ko-KR', category: 'label', name: 'department', display: '부서' }
57
- })
58
- const { patch } = target.update!.variables({ id: 't-1', record: { id: 't-1' }, values: { display: '부문', cuFlag: 'M', creator: { id: 'u' } } }) as any
59
- expect(patch).toEqual({ display: '부문' })
60
- expect(Object.keys(patch).every(name => target.update!.fields!.includes(name))).toBe(true)
61
- })
62
- })
63
-
64
- describe('terminology checks', () => {
65
- it('a (locale, category, name) the domain has keeps the row out; another locale or category does not', () => {
66
- const issues = terminologyIssues([term('ko-KR', 'label', 'dept'), term('en-US', 'label', 'dept'), term('ko-KR', 'field', 'dept')], [
67
- { locale: 'ko-KR', category: 'label', name: 'dept' }
68
- ])
69
- expect(issues[0]).toEqual([expect.objectContaining({ code: 'duplicate', blocking: true })])
70
- expect(issues[1]).toEqual([])
71
- expect(issues[2]).toEqual([])
72
- })
73
-
74
- it('a row repeating an earlier row of the proposal is kept out - the later one', () => {
75
- const issues = terminologyIssues([term('ko-KR', 'label', 'dept', '부서'), term('ko-KR', 'label', 'dept', '부문')], [])
76
- expect(issues[0]).toEqual([])
77
- expect(issues[1]).toEqual([expect.objectContaining({ code: 'duplicate-in-proposal', blocking: true })])
78
- })
79
- })
80
-
81
- describe('terminology change checks', () => {
82
- const existing = [
83
- { id: 't1', locale: 'ko-KR', category: 'label', name: 'dept' },
84
- { id: 't2', locale: 'ko-KR', category: 'label', name: 'team' }
85
- ]
86
- const record = (id: string) => existing.find(one => one.id === id)!
87
-
88
- it('a changed (locale, category, name) another term has keeps the change out; the term itself does not', () => {
89
- const issues = terminologyChangeIssues(
90
- [
91
- { id: 't2', record: record('t2'), values: { name: 'dept' } },
92
- { id: 't2', record: record('t2'), values: { locale: 'en-US', name: 'dept' } },
93
- { id: 't2', record: record('t2'), values: { display: '팀' } }
94
- ],
95
- existing
96
- )
97
- expect(issues[0]).toEqual([expect.objectContaining({ code: 'duplicate', blocking: true })])
98
- expect(issues[1]).toEqual([])
99
- expect(issues[2]).toEqual([])
100
- expect(terminologyChangeIssues([{ id: 't1', record: record('t1'), values: { category: 'label', display: 'x' } }], existing)).toEqual([[]])
101
- })
102
-
103
- it('two changes landing on the same key - the later one is kept out', () => {
104
- const issues = terminologyChangeIssues(
105
- [
106
- { id: 't1', record: record('t1'), values: { name: 'new' } },
107
- { id: 't2', record: record('t2'), values: { name: 'new' } }
108
- ],
109
- existing
110
- )
111
- expect(issues[0]).toEqual([])
112
- expect(issues[1]).toEqual([expect.objectContaining({ code: 'duplicate-in-proposal', blocking: true })])
113
- })
114
-
115
- it('the update declares its check', () => {
116
- expect(typeof terminologyEntryTarget({ locales: ['ko-KR'] }).update!.check).toBe('function')
117
- })
118
- })
119
-
120
- describe('translations', () => {
121
- it('the five languages have the same keys', () => {
122
- const reference = Object.keys(en).sort()
123
- for (const [language, table] of Object.entries(LANGUAGES)) expect({ language, keys: Object.keys(table).sort() }).toEqual({ language, keys: reference })
124
- })
125
-
126
- it('the label and messages the target names are translated in every language', () => {
127
- const keys = [
128
- terminologyEntryTarget({ locales: ['ko-KR'] }).labelKey,
129
- ...terminologyIssues([term('ko-KR', 'label', 'a'), term('ko-KR', 'label', 'b'), term('ko-KR', 'label', 'b')], [{ locale: 'ko-KR', category: 'label', name: 'a' }])
130
- .flat()
131
- .map(issue => issue.messageKey!)
132
- ]
133
- expect(keys).toHaveLength(3)
134
- for (const key of keys) for (const [language, table] of Object.entries(LANGUAGES)) expect({ language, key, has: key in table }).toEqual({ language, key, has: true })
135
- })
136
- })