@_linked/translation 0.7.0 → 0.8.1
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.
- package/README.md +15 -16
- package/lib/esm/archive.d.ts +2 -2
- package/lib/esm/archive.js +2 -2
- package/lib/esm/archive.js.map +1 -1
- package/lib/esm/authorization.d.ts +1 -1
- package/lib/esm/authorization.js +1 -1
- package/lib/esm/authorization.js.map +1 -1
- package/lib/esm/cdn-loader.d.ts +1 -1
- package/lib/esm/cdn-loader.js.map +1 -1
- package/lib/esm/core/messages.d.ts +14 -1
- package/lib/esm/core/messages.js +33 -2
- package/lib/esm/core/messages.js.map +1 -1
- package/lib/esm/exchange.d.ts +1 -1
- package/lib/esm/exchange.js +1 -1
- package/lib/esm/exchange.js.map +1 -1
- package/lib/esm/export.js +4 -1
- package/lib/esm/export.js.map +1 -1
- package/lib/esm/formats/xliff.js +1 -1
- package/lib/esm/formats/xliff.js.map +1 -1
- package/lib/esm/key-sync.d.ts +12 -0
- package/lib/esm/key-sync.js +32 -7
- package/lib/esm/key-sync.js.map +1 -1
- package/lib/esm/mt.js +1 -1
- package/lib/esm/mt.js.map +1 -1
- package/lib/esm/ontologies/translation.d.ts +193 -191
- package/lib/esm/ontologies/translation.js +4 -2
- package/lib/esm/ontologies/translation.js.map +1 -1
- package/lib/esm/package.d.ts +3 -3
- package/lib/esm/react.d.ts +38 -2
- package/lib/esm/react.js +98 -15
- package/lib/esm/react.js.map +1 -1
- package/lib/esm/records.d.ts +2 -1
- package/lib/esm/records.js.map +1 -1
- package/lib/esm/release.d.ts +3 -1
- package/lib/esm/release.js +21 -4
- package/lib/esm/release.js.map +1 -1
- package/lib/esm/shape-catalog.d.ts +1 -1
- package/lib/esm/shape-catalog.js.map +1 -1
- package/lib/esm/shapes/GlossaryTerm.d.ts +1 -1
- package/lib/esm/shapes/TranslationInventoryOrigin.d.ts +1 -1
- package/lib/esm/shapes/TranslationKey.d.ts +11 -6
- package/lib/esm/shapes/TranslationKey.js +16 -5
- package/lib/esm/shapes/TranslationKey.js.map +1 -1
- package/lib/esm/shapes/TranslationKeyVersion.d.ts +1 -1
- package/lib/esm/shapes/TranslationLanguage.d.ts +1 -1
- package/lib/esm/shapes/TranslationProvider.d.ts +25 -8
- package/lib/esm/shapes/TranslationProvider.js +69 -38
- package/lib/esm/shapes/TranslationProvider.js.map +1 -1
- package/lib/esm/shapes/TranslationRelease.d.ts +1 -1
- package/lib/esm/shapes/TranslationRevision.d.ts +1 -1
- package/lib/esm/shapes/TranslationUnit.d.ts +1 -1
- package/package.json +7 -7
- package/src/archive.ts +2 -2
- package/src/authorization.ts +1 -1
- package/src/cdn-loader.ts +1 -1
- package/src/core/messages.ts +35 -2
- package/src/exchange.ts +1 -1
- package/src/export.ts +4 -1
- package/src/formats/xliff.ts +1 -1
- package/src/key-sync.ts +46 -6
- package/src/mt.ts +1 -1
- package/src/ontologies/translation.ts +4 -2
- package/src/react.tsx +158 -35
- package/src/records.ts +2 -1
- package/src/release.ts +31 -3
- package/src/shape-catalog.ts +1 -1
- package/src/shapes/TranslationKey.ts +14 -5
- package/src/shapes/TranslationProvider.ts +92 -32
|
@@ -208,6 +208,7 @@ export function groupTranslationEntries(keyRows = [], unitRows = [], versionRows
|
|
|
208
208
|
format: row.format === 'icu' ? 'icu' : 'simple',
|
|
209
209
|
ofShape: iri(row.ofShape),
|
|
210
210
|
ofProperty: iri(row.ofProperty),
|
|
211
|
+
ofResource: iri(row.ofResource),
|
|
211
212
|
fromPackage: row.fromPackage || undefined,
|
|
212
213
|
overridden: row.overridden === true || row.overridden === 'true'
|
|
213
214
|
? true
|
|
@@ -287,6 +288,7 @@ export async function listTranslationKeys(data) {
|
|
|
287
288
|
k.ofField,
|
|
288
289
|
k.ofShape,
|
|
289
290
|
k.ofProperty,
|
|
291
|
+
k.ofResource,
|
|
290
292
|
k.fromPackage,
|
|
291
293
|
k.overridden,
|
|
292
294
|
k.format,
|
|
@@ -310,6 +312,7 @@ export async function listTranslationEntries(data) {
|
|
|
310
312
|
k.format,
|
|
311
313
|
k.ofShape,
|
|
312
314
|
k.ofProperty,
|
|
315
|
+
k.ofResource,
|
|
313
316
|
k.fromPackage,
|
|
314
317
|
k.overridden,
|
|
315
318
|
k.currentVersion,
|
|
@@ -846,7 +849,7 @@ export async function decideTranslationProposal(data, reviewer) {
|
|
|
846
849
|
* Source drift marks every existing language unit stale before returning.
|
|
847
850
|
*/
|
|
848
851
|
export async function upsertTranslationKey(data, authorship = {}) {
|
|
849
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
852
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
|
|
850
853
|
const appId = requireText(data.appId, 'appId');
|
|
851
854
|
const key = requireText(data.key, 'key');
|
|
852
855
|
requireText(data.sourceText, 'sourceText');
|
|
@@ -862,29 +865,52 @@ export async function upsertTranslationKey(data, authorship = {}) {
|
|
|
862
865
|
ofField: data.ofField,
|
|
863
866
|
ofShape: data.ofShape ? { id: data.ofShape } : undefined,
|
|
864
867
|
ofProperty: data.ofProperty ? { id: data.ofProperty } : undefined,
|
|
868
|
+
ofResource: data.ofResource ? { id: data.ofResource } : undefined,
|
|
865
869
|
fromPackage: data.fromPackage,
|
|
866
|
-
overridden: data.overridden
|
|
870
|
+
overridden: data.overridden,
|
|
867
871
|
format: (_c = data.format) !== null && _c !== void 0 ? _c : 'simple',
|
|
868
872
|
};
|
|
873
|
+
// No catch: a failed read is not permission to create or overwrite the key.
|
|
869
874
|
const existing = await TranslationKey.select((k) => [
|
|
870
875
|
k.sourceText,
|
|
871
876
|
k.format,
|
|
872
877
|
k.ofShape,
|
|
878
|
+
k.ofProperty,
|
|
879
|
+
k.ofResource,
|
|
880
|
+
k.fromPackage,
|
|
873
881
|
k.overridden,
|
|
874
882
|
k.currentVersion,
|
|
875
883
|
])
|
|
876
884
|
.where((k) => k.equals({ id }))
|
|
877
|
-
.one()
|
|
878
|
-
.catch(() => null);
|
|
885
|
+
.one();
|
|
879
886
|
if (existing) {
|
|
880
887
|
const sourceChanged = existing.sourceText !== data.sourceText;
|
|
888
|
+
const formatChanged = ((_d = existing.format) !== null && _d !== void 0 ? _d : 'simple') !== ((_e = data.format) !== null && _e !== void 0 ? _e : 'simple');
|
|
881
889
|
const wasOverridden = existing.overridden === true;
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
890
|
+
if (authorship.source === 'declaration-sync' && wasOverridden) {
|
|
891
|
+
const versionId = iri(existing.currentVersion);
|
|
892
|
+
if (!versionId)
|
|
893
|
+
throw new Error(`Translation override ${id} has no current version; refresh refused without changing its source.`);
|
|
894
|
+
// No key write, version creation or unit invalidation. The declaration
|
|
895
|
+
// inventory still records the package's current source independently.
|
|
896
|
+
return { id, versionId, versionCreated: false, preservedOverride: true };
|
|
897
|
+
}
|
|
898
|
+
// AD-N ownership also covers property/resource/package declarations (help,
|
|
899
|
+
// actions, groups), not only shapes. App edits preserve the first canonical
|
|
900
|
+
// wording in the existing shapeSource carrier. Only an explicit app edit
|
|
901
|
+
// may clear the override; automatic discovery cannot clear it by payload.
|
|
902
|
+
const isDeclaredKey = !!(existing.ofShape ||
|
|
903
|
+
existing.ofProperty ||
|
|
904
|
+
existing.ofResource ||
|
|
905
|
+
existing.fromPackage ||
|
|
906
|
+
data.ofShape ||
|
|
907
|
+
data.ofProperty ||
|
|
908
|
+
data.ofResource ||
|
|
909
|
+
data.fromPackage);
|
|
910
|
+
if (authorship.source !== 'declaration-sync' &&
|
|
911
|
+
data.overridden === undefined &&
|
|
912
|
+
isDeclaredKey &&
|
|
913
|
+
(sourceChanged || formatChanged)) {
|
|
888
914
|
values.overridden = true;
|
|
889
915
|
// Snapshot the canonical at FIRST divergence so "clear override" has a
|
|
890
916
|
// value to revert to even for a single-app project. Later edits keep the
|
|
@@ -896,28 +922,33 @@ export async function upsertTranslationKey(data, authorship = {}) {
|
|
|
896
922
|
appId,
|
|
897
923
|
keyId: id,
|
|
898
924
|
currentVersion: existing.currentVersion,
|
|
899
|
-
sourceLanguage: (
|
|
900
|
-
sourceText: (
|
|
925
|
+
sourceLanguage: (_f = data.sourceLanguage) !== null && _f !== void 0 ? _f : 'en',
|
|
926
|
+
sourceText: (_g = existing.sourceText) !== null && _g !== void 0 ? _g : '',
|
|
901
927
|
format: existing.format === 'icu' ? 'icu' : 'simple',
|
|
902
928
|
createdBy: authorship.createdBy,
|
|
903
929
|
});
|
|
904
930
|
const decision = classifyKeyVersion(currentVersion, {
|
|
905
931
|
sourceText: data.sourceText,
|
|
906
|
-
format: (
|
|
932
|
+
format: (_h = data.format) !== null && _h !== void 0 ? _h : 'simple',
|
|
907
933
|
});
|
|
908
934
|
const nextVersion = decision.action === 'create-version'
|
|
909
935
|
? await createTranslationKeyVersion({
|
|
910
936
|
appId,
|
|
911
937
|
keyId: id,
|
|
912
|
-
sourceLanguage: (
|
|
938
|
+
sourceLanguage: (_k = (_j = data.sourceLanguage) !== null && _j !== void 0 ? _j : currentVersion.sourceLanguage) !== null && _k !== void 0 ? _k : 'en',
|
|
913
939
|
sourceText: data.sourceText,
|
|
914
|
-
format: (
|
|
940
|
+
format: (_l = data.format) !== null && _l !== void 0 ? _l : 'simple',
|
|
915
941
|
supersedes: currentVersion.id,
|
|
916
942
|
createdBy: authorship.createdBy,
|
|
917
943
|
})
|
|
918
944
|
: currentVersion;
|
|
919
945
|
values.currentVersion = { id: nextVersion.id };
|
|
920
|
-
|
|
946
|
+
// In the Linked mutation DSL an explicitly present `undefined` removes
|
|
947
|
+
// that predicate. A partial source edit has not requested removal of the
|
|
948
|
+
// declaration owner, help description, or existing override flag. Omit
|
|
949
|
+
// untouched fields; an explicit false (reset) remains a real write.
|
|
950
|
+
const patch = Object.fromEntries(Object.entries(values).filter(([, value]) => value !== undefined));
|
|
951
|
+
await TranslationKey.update(patch).for({ id });
|
|
921
952
|
if (decision.action === 'create-version') {
|
|
922
953
|
await TranslationUnit.update({ state: 'stale' }).where((u) => u.ofKey.equals({ id }));
|
|
923
954
|
}
|
|
@@ -931,9 +962,9 @@ export async function upsertTranslationKey(data, authorship = {}) {
|
|
|
931
962
|
const firstVersion = await createTranslationKeyVersion({
|
|
932
963
|
appId,
|
|
933
964
|
keyId: id,
|
|
934
|
-
sourceLanguage: (
|
|
965
|
+
sourceLanguage: (_m = data.sourceLanguage) !== null && _m !== void 0 ? _m : 'en',
|
|
935
966
|
sourceText: data.sourceText,
|
|
936
|
-
format: (
|
|
967
|
+
format: (_o = data.format) !== null && _o !== void 0 ? _o : 'simple',
|
|
937
968
|
createdBy: authorship.createdBy,
|
|
938
969
|
});
|
|
939
970
|
await TranslationKey.update({
|
|
@@ -1215,7 +1246,7 @@ export class TranslationProvider extends ShapeProvider {
|
|
|
1215
1246
|
}
|
|
1216
1247
|
/**
|
|
1217
1248
|
* Authoring gate. Reads `linkedAuth` off the request the LINKED server already
|
|
1218
|
-
* populates, so this stays portable (no
|
|
1249
|
+
* populates, so this stays portable (no host-application import, AD-G).
|
|
1219
1250
|
*
|
|
1220
1251
|
* Every method except `getMessages` resolves the caller once, synchronously,
|
|
1221
1252
|
* before its first `await`, and uses that value for both the permission check
|
|
@@ -1474,115 +1505,115 @@ __decorate([
|
|
|
1474
1505
|
__metadata("design:returntype", Promise)
|
|
1475
1506
|
], TranslationProvider.prototype, "requireAccess", null);
|
|
1476
1507
|
__decorate([
|
|
1477
|
-
callable('
|
|
1508
|
+
callable('signed-in'),
|
|
1478
1509
|
__metadata("design:type", Function),
|
|
1479
1510
|
__metadata("design:paramtypes", [Object]),
|
|
1480
1511
|
__metadata("design:returntype", Promise)
|
|
1481
1512
|
], TranslationProvider.prototype, "listKeys", null);
|
|
1482
1513
|
__decorate([
|
|
1483
|
-
callable('
|
|
1514
|
+
callable('signed-in'),
|
|
1484
1515
|
__metadata("design:type", Function),
|
|
1485
1516
|
__metadata("design:paramtypes", [Object]),
|
|
1486
1517
|
__metadata("design:returntype", Promise)
|
|
1487
1518
|
], TranslationProvider.prototype, "listEntries", null);
|
|
1488
1519
|
__decorate([
|
|
1489
|
-
callable('
|
|
1520
|
+
callable('signed-in'),
|
|
1490
1521
|
__metadata("design:type", Function),
|
|
1491
1522
|
__metadata("design:paramtypes", [Object]),
|
|
1492
1523
|
__metadata("design:returntype", Promise)
|
|
1493
1524
|
], TranslationProvider.prototype, "listKeyVersions", null);
|
|
1494
1525
|
__decorate([
|
|
1495
|
-
callable('
|
|
1526
|
+
callable('signed-in'),
|
|
1496
1527
|
__metadata("design:type", Function),
|
|
1497
1528
|
__metadata("design:paramtypes", [Object]),
|
|
1498
1529
|
__metadata("design:returntype", Promise)
|
|
1499
1530
|
], TranslationProvider.prototype, "listMemoryMatches", null);
|
|
1500
1531
|
__decorate([
|
|
1501
|
-
callable('
|
|
1532
|
+
callable('signed-in'),
|
|
1502
1533
|
__metadata("design:type", Function),
|
|
1503
1534
|
__metadata("design:paramtypes", [Object]),
|
|
1504
1535
|
__metadata("design:returntype", Promise)
|
|
1505
1536
|
], TranslationProvider.prototype, "proposeRevision", null);
|
|
1506
1537
|
__decorate([
|
|
1507
|
-
callable('
|
|
1538
|
+
callable('signed-in'),
|
|
1508
1539
|
__metadata("design:type", Function),
|
|
1509
1540
|
__metadata("design:paramtypes", [Object]),
|
|
1510
1541
|
__metadata("design:returntype", Promise)
|
|
1511
1542
|
], TranslationProvider.prototype, "listProposals", null);
|
|
1512
1543
|
__decorate([
|
|
1513
|
-
callable('
|
|
1544
|
+
callable('signed-in'),
|
|
1514
1545
|
__metadata("design:type", Function),
|
|
1515
1546
|
__metadata("design:paramtypes", [Object]),
|
|
1516
1547
|
__metadata("design:returntype", Promise)
|
|
1517
1548
|
], TranslationProvider.prototype, "decideProposal", null);
|
|
1518
1549
|
__decorate([
|
|
1519
|
-
callable('
|
|
1550
|
+
callable('signed-in'),
|
|
1520
1551
|
__metadata("design:type", Function),
|
|
1521
1552
|
__metadata("design:paramtypes", [Object]),
|
|
1522
1553
|
__metadata("design:returntype", Promise)
|
|
1523
1554
|
], TranslationProvider.prototype, "listMemory", null);
|
|
1524
1555
|
__decorate([
|
|
1525
|
-
callable('
|
|
1556
|
+
callable('signed-in'),
|
|
1526
1557
|
__metadata("design:type", Function),
|
|
1527
1558
|
__metadata("design:paramtypes", [Object]),
|
|
1528
1559
|
__metadata("design:returntype", Promise)
|
|
1529
1560
|
], TranslationProvider.prototype, "pretranslateMemory", null);
|
|
1530
1561
|
__decorate([
|
|
1531
|
-
callable('
|
|
1562
|
+
callable('signed-in'),
|
|
1532
1563
|
__metadata("design:type", Function),
|
|
1533
1564
|
__metadata("design:paramtypes", [Object]),
|
|
1534
1565
|
__metadata("design:returntype", Promise)
|
|
1535
1566
|
], TranslationProvider.prototype, "applyMemoryMatch", null);
|
|
1536
1567
|
__decorate([
|
|
1537
|
-
callable('
|
|
1568
|
+
callable('signed-in'),
|
|
1538
1569
|
__metadata("design:type", Function),
|
|
1539
1570
|
__metadata("design:paramtypes", [Object]),
|
|
1540
1571
|
__metadata("design:returntype", Promise)
|
|
1541
1572
|
], TranslationProvider.prototype, "listReleases", null);
|
|
1542
1573
|
__decorate([
|
|
1543
|
-
callable('
|
|
1574
|
+
callable('signed-in'),
|
|
1544
1575
|
__metadata("design:type", Function),
|
|
1545
1576
|
__metadata("design:paramtypes", [Object]),
|
|
1546
1577
|
__metadata("design:returntype", Promise)
|
|
1547
1578
|
], TranslationProvider.prototype, "createRelease", null);
|
|
1548
1579
|
__decorate([
|
|
1549
|
-
callable('
|
|
1580
|
+
callable('signed-in'),
|
|
1550
1581
|
__metadata("design:type", Function),
|
|
1551
1582
|
__metadata("design:paramtypes", [Object]),
|
|
1552
1583
|
__metadata("design:returntype", Promise)
|
|
1553
1584
|
], TranslationProvider.prototype, "advanceReleaseHotfix", null);
|
|
1554
1585
|
__decorate([
|
|
1555
|
-
callable('
|
|
1586
|
+
callable('signed-in'),
|
|
1556
1587
|
__metadata("design:type", Function),
|
|
1557
1588
|
__metadata("design:paramtypes", [Object]),
|
|
1558
1589
|
__metadata("design:returntype", Promise)
|
|
1559
1590
|
], TranslationProvider.prototype, "upsertKey", null);
|
|
1560
1591
|
__decorate([
|
|
1561
|
-
callable('
|
|
1592
|
+
callable('signed-in'),
|
|
1562
1593
|
__metadata("design:type", Function),
|
|
1563
1594
|
__metadata("design:paramtypes", [Object]),
|
|
1564
1595
|
__metadata("design:returntype", Promise)
|
|
1565
1596
|
], TranslationProvider.prototype, "upsertUnit", null);
|
|
1566
1597
|
__decorate([
|
|
1567
|
-
callable('
|
|
1598
|
+
callable('signed-in'),
|
|
1568
1599
|
__metadata("design:type", Function),
|
|
1569
1600
|
__metadata("design:paramtypes", [Object]),
|
|
1570
1601
|
__metadata("design:returntype", Promise)
|
|
1571
1602
|
], TranslationProvider.prototype, "listGlossary", null);
|
|
1572
1603
|
__decorate([
|
|
1573
|
-
callable('
|
|
1604
|
+
callable('signed-in'),
|
|
1574
1605
|
__metadata("design:type", Function),
|
|
1575
1606
|
__metadata("design:paramtypes", [Object]),
|
|
1576
1607
|
__metadata("design:returntype", Promise)
|
|
1577
1608
|
], TranslationProvider.prototype, "upsertGlossaryTerm", null);
|
|
1578
1609
|
__decorate([
|
|
1579
|
-
callable('
|
|
1610
|
+
callable('signed-in'),
|
|
1580
1611
|
__metadata("design:type", Function),
|
|
1581
1612
|
__metadata("design:paramtypes", [Object]),
|
|
1582
1613
|
__metadata("design:returntype", Promise)
|
|
1583
1614
|
], TranslationProvider.prototype, "deleteGlossaryTerm", null);
|
|
1584
1615
|
__decorate([
|
|
1585
|
-
callable('
|
|
1616
|
+
callable('signed-in'),
|
|
1586
1617
|
__metadata("design:type", Function),
|
|
1587
1618
|
__metadata("design:paramtypes", [Object]),
|
|
1588
1619
|
__metadata("design:returntype", Promise)
|