@_linked/translation 0.2.2

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 (153) hide show
  1. package/README.md +102 -0
  2. package/lib/cjs/data/translation.json +8 -0
  3. package/lib/esm/archive.d.ts +133 -0
  4. package/lib/esm/archive.js +567 -0
  5. package/lib/esm/archive.js.map +1 -0
  6. package/lib/esm/authorization.d.ts +12 -0
  7. package/lib/esm/authorization.js +10 -0
  8. package/lib/esm/authorization.js.map +1 -0
  9. package/lib/esm/backend.d.ts +1 -0
  10. package/lib/esm/backend.js +3 -0
  11. package/lib/esm/backend.js.map +1 -0
  12. package/lib/esm/cdn-loader.d.ts +40 -0
  13. package/lib/esm/cdn-loader.js +200 -0
  14. package/lib/esm/cdn-loader.js.map +1 -0
  15. package/lib/esm/checks.d.ts +56 -0
  16. package/lib/esm/checks.js +288 -0
  17. package/lib/esm/checks.js.map +1 -0
  18. package/lib/esm/compile.d.ts +64 -0
  19. package/lib/esm/compile.js +99 -0
  20. package/lib/esm/compile.js.map +1 -0
  21. package/lib/esm/core/messages.d.ts +25 -0
  22. package/lib/esm/core/messages.js +76 -0
  23. package/lib/esm/core/messages.js.map +1 -0
  24. package/lib/esm/data/translation.json +8 -0
  25. package/lib/esm/discovery.d.ts +97 -0
  26. package/lib/esm/discovery.js +365 -0
  27. package/lib/esm/discovery.js.map +1 -0
  28. package/lib/esm/exchange.d.ts +100 -0
  29. package/lib/esm/exchange.js +223 -0
  30. package/lib/esm/exchange.js.map +1 -0
  31. package/lib/esm/export.d.ts +28 -0
  32. package/lib/esm/export.js +92 -0
  33. package/lib/esm/export.js.map +1 -0
  34. package/lib/esm/formats/csv.d.ts +8 -0
  35. package/lib/esm/formats/csv.js +397 -0
  36. package/lib/esm/formats/csv.js.map +1 -0
  37. package/lib/esm/formats/json.d.ts +30 -0
  38. package/lib/esm/formats/json.js +459 -0
  39. package/lib/esm/formats/json.js.map +1 -0
  40. package/lib/esm/formats/xliff.d.ts +12 -0
  41. package/lib/esm/formats/xliff.js +577 -0
  42. package/lib/esm/formats/xliff.js.map +1 -0
  43. package/lib/esm/import.d.ts +197 -0
  44. package/lib/esm/import.js +391 -0
  45. package/lib/esm/import.js.map +1 -0
  46. package/lib/esm/index.d.ts +42 -0
  47. package/lib/esm/index.js +34 -0
  48. package/lib/esm/index.js.map +1 -0
  49. package/lib/esm/key-sync-node.d.ts +29 -0
  50. package/lib/esm/key-sync-node.js +174 -0
  51. package/lib/esm/key-sync-node.js.map +1 -0
  52. package/lib/esm/key-sync.d.ts +46 -0
  53. package/lib/esm/key-sync.js +114 -0
  54. package/lib/esm/key-sync.js.map +1 -0
  55. package/lib/esm/key-version.d.ts +50 -0
  56. package/lib/esm/key-version.js +134 -0
  57. package/lib/esm/key-version.js.map +1 -0
  58. package/lib/esm/languages.d.ts +18 -0
  59. package/lib/esm/languages.js +74 -0
  60. package/lib/esm/languages.js.map +1 -0
  61. package/lib/esm/linked-discovery.d.ts +44 -0
  62. package/lib/esm/linked-discovery.js +267 -0
  63. package/lib/esm/linked-discovery.js.map +1 -0
  64. package/lib/esm/message-format.d.ts +41 -0
  65. package/lib/esm/message-format.js +133 -0
  66. package/lib/esm/message-format.js.map +1 -0
  67. package/lib/esm/mt.d.ts +111 -0
  68. package/lib/esm/mt.js +142 -0
  69. package/lib/esm/mt.js.map +1 -0
  70. package/lib/esm/ontologies/translation.d.ts +203 -0
  71. package/lib/esm/ontologies/translation.js +219 -0
  72. package/lib/esm/ontologies/translation.js.map +1 -0
  73. package/lib/esm/package.d.ts +4 -0
  74. package/lib/esm/package.js +11 -0
  75. package/lib/esm/package.js.map +1 -0
  76. package/lib/esm/react.d.ts +55 -0
  77. package/lib/esm/react.js +127 -0
  78. package/lib/esm/react.js.map +1 -0
  79. package/lib/esm/records.d.ts +151 -0
  80. package/lib/esm/records.js +2 -0
  81. package/lib/esm/records.js.map +1 -0
  82. package/lib/esm/release.d.ts +198 -0
  83. package/lib/esm/release.js +435 -0
  84. package/lib/esm/release.js.map +1 -0
  85. package/lib/esm/shape-catalog.d.ts +79 -0
  86. package/lib/esm/shape-catalog.js +118 -0
  87. package/lib/esm/shape-catalog.js.map +1 -0
  88. package/lib/esm/shapes/GlossaryTerm.d.ts +28 -0
  89. package/lib/esm/shapes/GlossaryTerm.js +94 -0
  90. package/lib/esm/shapes/GlossaryTerm.js.map +1 -0
  91. package/lib/esm/shapes/TranslationInventoryOrigin.d.ts +33 -0
  92. package/lib/esm/shapes/TranslationInventoryOrigin.js +209 -0
  93. package/lib/esm/shapes/TranslationInventoryOrigin.js.map +1 -0
  94. package/lib/esm/shapes/TranslationKey.d.ts +92 -0
  95. package/lib/esm/shapes/TranslationKey.js +194 -0
  96. package/lib/esm/shapes/TranslationKey.js.map +1 -0
  97. package/lib/esm/shapes/TranslationKeyVersion.d.ts +19 -0
  98. package/lib/esm/shapes/TranslationKeyVersion.js +125 -0
  99. package/lib/esm/shapes/TranslationKeyVersion.js.map +1 -0
  100. package/lib/esm/shapes/TranslationLanguage.d.ts +15 -0
  101. package/lib/esm/shapes/TranslationLanguage.js +102 -0
  102. package/lib/esm/shapes/TranslationLanguage.js.map +1 -0
  103. package/lib/esm/shapes/TranslationProvider.d.ts +409 -0
  104. package/lib/esm/shapes/TranslationProvider.js +1376 -0
  105. package/lib/esm/shapes/TranslationProvider.js.map +1 -0
  106. package/lib/esm/shapes/TranslationRelease.d.ts +36 -0
  107. package/lib/esm/shapes/TranslationRelease.js +149 -0
  108. package/lib/esm/shapes/TranslationRelease.js.map +1 -0
  109. package/lib/esm/shapes/TranslationRevision.d.ts +39 -0
  110. package/lib/esm/shapes/TranslationRevision.js +159 -0
  111. package/lib/esm/shapes/TranslationRevision.js.map +1 -0
  112. package/lib/esm/shapes/TranslationUnit.d.ts +26 -0
  113. package/lib/esm/shapes/TranslationUnit.js +111 -0
  114. package/lib/esm/shapes/TranslationUnit.js.map +1 -0
  115. package/package.json +134 -0
  116. package/src/archive.ts +894 -0
  117. package/src/authorization.ts +33 -0
  118. package/src/backend.ts +2 -0
  119. package/src/cdn-loader.ts +264 -0
  120. package/src/checks.ts +413 -0
  121. package/src/compile.ts +168 -0
  122. package/src/core/messages.ts +106 -0
  123. package/src/data/translation.json +8 -0
  124. package/src/discovery.ts +594 -0
  125. package/src/exchange.ts +428 -0
  126. package/src/export.ts +135 -0
  127. package/src/formats/csv.ts +459 -0
  128. package/src/formats/json.ts +587 -0
  129. package/src/formats/xliff.ts +708 -0
  130. package/src/import.ts +648 -0
  131. package/src/index.ts +207 -0
  132. package/src/key-sync-node.ts +269 -0
  133. package/src/key-sync.ts +168 -0
  134. package/src/key-version.ts +206 -0
  135. package/src/languages.ts +102 -0
  136. package/src/linked-discovery.ts +385 -0
  137. package/src/message-format.ts +214 -0
  138. package/src/mt.ts +248 -0
  139. package/src/ontologies/translation.ts +234 -0
  140. package/src/package.ts +19 -0
  141. package/src/react.tsx +250 -0
  142. package/src/records.ts +180 -0
  143. package/src/release.ts +726 -0
  144. package/src/shape-catalog.ts +198 -0
  145. package/src/shapes/GlossaryTerm.ts +61 -0
  146. package/src/shapes/TranslationInventoryOrigin.ts +131 -0
  147. package/src/shapes/TranslationKey.ts +174 -0
  148. package/src/shapes/TranslationKeyVersion.ts +77 -0
  149. package/src/shapes/TranslationLanguage.ts +51 -0
  150. package/src/shapes/TranslationProvider.ts +1755 -0
  151. package/src/shapes/TranslationRelease.ts +114 -0
  152. package/src/shapes/TranslationRevision.ts +105 -0
  153. package/src/shapes/TranslationUnit.ts +72 -0
@@ -0,0 +1,114 @@
1
+ import { Shape } from '@_linked/core/shapes/Shape';
2
+ import { literalProperty, objectProperty } from '@_linked/core/shapes/SHACL';
3
+ import { xsd } from '@_linked/core/ontologies/xsd';
4
+ import { Server } from '@_linked/server-utils/utils/Server';
5
+ import { tr } from '../ontologies/translation.js';
6
+ import { linkedShape } from '../package.js';
7
+ import type { TranslationReleaseRecord } from '../records.js';
8
+
9
+ /**
10
+ * Graph metadata for an immutable translation release. Key/language selections
11
+ * live in the content-addressed manifest rather than repeated RDF predicates.
12
+ */
13
+ @linkedShape
14
+ export class TranslationRelease extends Shape {
15
+ static targetClass = tr.TranslationRelease;
16
+
17
+ @objectProperty({ path: tr.ofApplication, maxCount: 1 })
18
+ get ofApplication(): string {
19
+ return '';
20
+ }
21
+
22
+ @objectProperty({ path: tr.branch, maxCount: 1 })
23
+ get branch(): string {
24
+ return '';
25
+ }
26
+
27
+ @literalProperty({ path: tr.releaseId, maxCount: 1 })
28
+ get releaseId(): string {
29
+ return '';
30
+ }
31
+
32
+ @literalProperty({ path: tr.buildId, maxCount: 1 })
33
+ get buildId(): string {
34
+ return '';
35
+ }
36
+
37
+ @literalProperty({ path: tr.channel, maxCount: 1 })
38
+ get channel(): string {
39
+ return 'preview';
40
+ }
41
+
42
+ @literalProperty({ path: tr.status, maxCount: 1 })
43
+ get status(): string {
44
+ return 'draft';
45
+ }
46
+
47
+ @literalProperty({ path: tr.contractSetHash, maxCount: 1 })
48
+ get contractSetHash(): string {
49
+ return '';
50
+ }
51
+
52
+ @literalProperty({ path: tr.manifestHash, maxCount: 1 })
53
+ get manifestHash(): string {
54
+ return '';
55
+ }
56
+
57
+ @literalProperty({ path: tr.hotfixSequence, datatype: xsd.integer, maxCount: 1 })
58
+ get hotfixSequence(): number {
59
+ return 0;
60
+ }
61
+
62
+ @literalProperty({ path: tr.createdAt, datatype: xsd.dateTime, maxCount: 1 })
63
+ get createdAt(): Date {
64
+ return new Date(0);
65
+ }
66
+
67
+ @literalProperty({ path: tr.publishedAt, datatype: xsd.dateTime, maxCount: 1 })
68
+ get publishedAt(): Date {
69
+ return new Date(0);
70
+ }
71
+
72
+ @literalProperty({ path: tr.supportedUntil, datatype: xsd.dateTime, maxCount: 1 })
73
+ get supportedUntil(): Date {
74
+ return new Date(0);
75
+ }
76
+
77
+ /** Canonical JSON summary; the full per-language detail also lives in the manifest. */
78
+ @literalProperty({ path: tr.qualitySummary, maxCount: 1 })
79
+ get qualitySummary(): string {
80
+ return '';
81
+ }
82
+
83
+ @objectProperty({ path: tr.supersedes, shape: TranslationRelease, maxCount: 1 })
84
+ get supersedes(): TranslationRelease {
85
+ return undefined as any;
86
+ }
87
+
88
+ static list(data: { appId: string }) {
89
+ return Server.call(this, 'listReleases', data) as Promise<
90
+ TranslationReleaseRecord[]
91
+ >;
92
+ }
93
+
94
+ static createRelease(
95
+ data: Omit<TranslationReleaseRecord, 'id' | 'createdAt'> & {
96
+ createdAt?: string;
97
+ },
98
+ ) {
99
+ return Server.call(this, 'createRelease', data) as Promise<
100
+ TranslationReleaseRecord
101
+ >;
102
+ }
103
+
104
+ static advanceHotfix(data: {
105
+ id: string;
106
+ expectedSequence: number;
107
+ hotfixSequence: number;
108
+ manifestHash: string;
109
+ }) {
110
+ return Server.call(this, 'advanceReleaseHotfix', data) as Promise<
111
+ TranslationReleaseRecord
112
+ >;
113
+ }
114
+ }
@@ -0,0 +1,105 @@
1
+ import { Shape } from '@_linked/core/shapes/Shape';
2
+ import { literalProperty, objectProperty } from '@_linked/core/shapes/SHACL';
3
+ import { xsd } from '@_linked/core/ontologies/xsd';
4
+ import { tr } from '../ontologies/translation.js';
5
+ import { linkedShape } from '../package.js';
6
+ import { TranslationKey } from './TranslationKey.js';
7
+ import { TranslationKeyVersion } from './TranslationKeyVersion.js';
8
+
9
+ /**
10
+ * One authored value for a (key, language) cell — append-only (Plan 017 AD-P).
11
+ * A single primitive powers three workflows: change HISTORY (every direct edit
12
+ * records a `status:'applied'` revision), translator PROPOSALS (`proposed`,
13
+ * decided by a reviewer), and MT SUGGESTIONS (`suggested`, authorKind
14
+ * `machine`). The {@link TranslationUnit} stays the fast runtime/grid read
15
+ * path; revisions are never updated in place except their decision fields
16
+ * (`status`, `decidedAt`, `decidedBy`).
17
+ */
18
+ @linkedShape
19
+ export class TranslationRevision extends Shape {
20
+ static targetClass = tr.TranslationRevision;
21
+
22
+ /** IRI of the owning Application (same app-scoping law as Key/Unit). */
23
+ @objectProperty({ path: tr.ofApplication, maxCount: 1 })
24
+ get ofApplication(): string {
25
+ return '';
26
+ }
27
+
28
+ /** The key, NOT the unit — revisions can exist before any unit does. */
29
+ @objectProperty({ path: tr.ofKey, shape: TranslationKey, maxCount: 1 })
30
+ get ofKey(): TranslationKey {
31
+ return undefined as any;
32
+ }
33
+
34
+ @objectProperty({
35
+ path: tr.ofKeyVersion,
36
+ shape: TranslationKeyVersion,
37
+ maxCount: 1,
38
+ })
39
+ get ofKeyVersion(): TranslationKeyVersion {
40
+ return undefined as any;
41
+ }
42
+
43
+ /** BCP-47 language tag, e.g. "es", "zh-Hans". */
44
+ @literalProperty({ path: tr.language, maxCount: 1 })
45
+ get language(): string {
46
+ return '';
47
+ }
48
+
49
+ @literalProperty({ path: tr.text, maxCount: 1 })
50
+ get text(): string {
51
+ return '';
52
+ }
53
+
54
+ /** applied | proposed | suggested | accepted | rejected | superseded. */
55
+ @literalProperty({ path: tr.status, maxCount: 1 })
56
+ get status(): string {
57
+ return 'applied';
58
+ }
59
+
60
+ /** WebID of the human author, or the MT provider IRI. */
61
+ @objectProperty({ path: tr.author, maxCount: 1 })
62
+ get author(): string {
63
+ return '';
64
+ }
65
+
66
+ /** 'human' | 'machine'. */
67
+ @literalProperty({ path: tr.authorKind, maxCount: 1 })
68
+ get authorKind(): string {
69
+ return 'human';
70
+ }
71
+
72
+ /** MT provider key ('claude', 'deepl', …) when authorKind is 'machine'. */
73
+ @literalProperty({ path: tr.mtProvider, maxCount: 1 })
74
+ get mtProvider(): string {
75
+ return '';
76
+ }
77
+
78
+ /** The unit's text when this revision was authored (conflict detection). */
79
+ @literalProperty({ path: tr.basedOnText, maxCount: 1 })
80
+ get basedOnText(): string {
81
+ return '';
82
+ }
83
+
84
+ /** Free-text translator/reviewer comment. */
85
+ @literalProperty({ path: tr.note, maxCount: 1 })
86
+ get note(): string {
87
+ return '';
88
+ }
89
+
90
+ @literalProperty({ path: tr.createdAt, datatype: xsd.dateTime, maxCount: 1 })
91
+ get createdAt(): Date {
92
+ return new Date(0);
93
+ }
94
+
95
+ @literalProperty({ path: tr.decidedAt, datatype: xsd.dateTime, maxCount: 1 })
96
+ get decidedAt(): Date {
97
+ return new Date(0);
98
+ }
99
+
100
+ /** WebID of the reviewer who accepted/rejected a pending revision. */
101
+ @objectProperty({ path: tr.decidedBy, maxCount: 1 })
102
+ get decidedBy(): string {
103
+ return '';
104
+ }
105
+ }
@@ -0,0 +1,72 @@
1
+ import { Shape } from '@_linked/core/shapes/Shape';
2
+ import { literalProperty, objectProperty } from '@_linked/core/shapes/SHACL';
3
+ import { xsd } from '@_linked/core/ontologies/xsd';
4
+ import { tr } from '../ontologies/translation.js';
5
+ import { linkedShape } from '../package.js';
6
+ import { TranslationKey } from './TranslationKey.js';
7
+ import { TranslationKeyVersion } from './TranslationKeyVersion.js';
8
+
9
+ /**
10
+ * One language's value for a {@link TranslationKey} (Plan 014 AD-H). Explicit
11
+ * per-language node (not `rdf:langString`) so it can be filtered per-language
12
+ * through the LINKED DSL AND carry management metadata — review `state` and
13
+ * provenance — that a bare literal cannot hold.
14
+ */
15
+ @linkedShape
16
+ export class TranslationUnit extends Shape {
17
+ static targetClass = tr.TranslationUnit;
18
+
19
+ /** IRI of the owning Application (explicitly app-scoped per Plan 014 AD-I). */
20
+ @objectProperty({ path: tr.ofApplication, maxCount: 1 })
21
+ get ofApplication(): string {
22
+ return '';
23
+ }
24
+
25
+ @objectProperty({ path: tr.ofKey, shape: TranslationKey, maxCount: 1 })
26
+ get ofKey(): TranslationKey {
27
+ return undefined as any;
28
+ }
29
+
30
+ @objectProperty({
31
+ path: tr.ofKeyVersion,
32
+ shape: TranslationKeyVersion,
33
+ maxCount: 1,
34
+ })
35
+ get ofKeyVersion(): TranslationKeyVersion {
36
+ return undefined as any;
37
+ }
38
+
39
+ /** BCP-47 language tag, e.g. "es", "zh-Hans". */
40
+ @literalProperty({ path: tr.language, maxCount: 1 })
41
+ get language(): string {
42
+ return '';
43
+ }
44
+
45
+ @literalProperty({ path: tr.text, maxCount: 1 })
46
+ get text(): string {
47
+ return '';
48
+ }
49
+
50
+ /** untranslated | machine | reviewed | stale. */
51
+ @literalProperty({ path: tr.state, maxCount: 1 })
52
+ get state(): string {
53
+ return 'untranslated';
54
+ }
55
+
56
+ @literalProperty({ path: tr.updatedAt, datatype: xsd.dateTime, maxCount: 1 })
57
+ get updatedAt(): Date {
58
+ return new Date(0);
59
+ }
60
+
61
+ /** WebID (IRI) of the last editor. */
62
+ @objectProperty({ path: tr.updatedBy, maxCount: 1 })
63
+ get updatedBy(): string {
64
+ return '';
65
+ }
66
+
67
+ /** Current-value provenance (`tm` for exact translation-memory reuse). */
68
+ @literalProperty({ path: tr.origin, maxCount: 1 })
69
+ get origin(): string {
70
+ return '';
71
+ }
72
+ }