@proveanything/smartlinks 2.1.30 → 2.1.32
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/dist/api/translations.d.ts +26 -1
- package/dist/api/translations.js +74 -1
- package/dist/docs/API_SUMMARY.md +42 -2
- package/dist/docs/translations.md +41 -0
- package/dist/http.js +3 -0
- package/dist/index.d.ts +1 -1
- package/dist/openapi.yaml +138 -0
- package/dist/types/translations.d.ts +33 -0
- package/docs/API_SUMMARY.md +42 -2
- package/docs/translations.md +41 -0
- package/openapi.yaml +138 -0
- package/package.json +1 -1
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import type { TranslationActivity } from '../translationActivity.js';
|
|
2
|
-
import type { ResolvedTranslationResponse, TranslationHashOptions, TranslationListParams, TranslationListResponse, TranslationLookupRequest, TranslationLookupResponse, TranslationRecord, TranslationResolveOptions, TranslationUpdateRequest } from '../types/translations.js';
|
|
2
|
+
import type { ResolvedTranslationResponse, TranslationHashOptions, TranslationListParams, TranslationListResponse, TranslationLookupRequest, TranslationLookupResponse, TranslationRecord, TranslationResolveOptions, TranslationRules, TranslationUpdateRequest } from '../types/translations.js';
|
|
3
|
+
/** @internal tests only */
|
|
4
|
+
export declare function _resetRevisionChecks(): void;
|
|
3
5
|
export declare namespace translations {
|
|
4
6
|
function hashText(text: string, options?: TranslationHashOptions): Promise<string>;
|
|
5
7
|
function hashTexts(texts: string[], options?: TranslationHashOptions): Promise<string[]>;
|
|
@@ -23,5 +25,28 @@ export declare namespace translations {
|
|
|
23
25
|
function list(collectionId: string, params?: TranslationListParams): Promise<TranslationListResponse>;
|
|
24
26
|
function get(collectionId: string, translationId: string): Promise<TranslationRecord>;
|
|
25
27
|
function update(collectionId: string, translationId: string, body: TranslationUpdateRequest): Promise<TranslationRecord>;
|
|
28
|
+
/** Admin: how many translations exist per language, and how many a person has edited. */
|
|
29
|
+
function summary(collectionId: string): Promise<{
|
|
30
|
+
languages: Array<{
|
|
31
|
+
language: string;
|
|
32
|
+
total: number;
|
|
33
|
+
edited: number;
|
|
34
|
+
issues?: number;
|
|
35
|
+
}>;
|
|
36
|
+
}>;
|
|
37
|
+
/** Admin: where translated text appears for one language (context keys), with counts. */
|
|
38
|
+
function places(collectionId: string, targetLanguage: string): Promise<{
|
|
39
|
+
places: Array<{
|
|
40
|
+
contextKey: string;
|
|
41
|
+
total: number;
|
|
42
|
+
edited: number;
|
|
43
|
+
}>;
|
|
44
|
+
}>;
|
|
45
|
+
/** Admin: undo a person's edit with a fresh machine translation. */
|
|
46
|
+
function reset(collectionId: string, translationId: string): Promise<TranslationRecord>;
|
|
47
|
+
/** Admin: the site's translation rules (brief, notes per language, required terms). */
|
|
48
|
+
function rules(collectionId: string): Promise<TranslationRules>;
|
|
49
|
+
/** Admin: replace the site's translation rules. They apply to new translations from now on. */
|
|
50
|
+
function saveRules(collectionId: string, body: Pick<TranslationRules, 'guidance' | 'languages' | 'terms'>): Promise<TranslationRules>;
|
|
26
51
|
function clearLocalCache(collectionId?: string): Promise<void>;
|
|
27
52
|
}
|
package/dist/api/translations.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { isProxyEnabled, patch, post, request } from '../http.js';
|
|
1
|
+
import { isProxyEnabled, patch, post, put, request } from '../http.js';
|
|
2
2
|
import { clearCachedTranslations, deriveTranslationContextKey, getCachedTranslations, getDefaultTranslationCacheTtlMs, hashTranslationText, normalizeTranslationText, setCachedTranslations, } from '../translationCache.js';
|
|
3
3
|
import { trackTranslation, onActivity as onTranslationActivity, activity as translationActivity, translatingMessage as translatingLine } from '../translationActivity.js';
|
|
4
4
|
function normalizeLookupRequest(body) {
|
|
@@ -49,6 +49,52 @@ function toResolvedItem(item, index, cacheSource) {
|
|
|
49
49
|
return Object.assign(Object.assign({}, item), { index,
|
|
50
50
|
cacheSource });
|
|
51
51
|
}
|
|
52
|
+
// A person can correct a translation in Studio. Visitors' browsers keep translations for weeks, so
|
|
53
|
+
// once per page per collection we ask the server when its translations were last edited, and drop
|
|
54
|
+
// the local copies if that changed since we last looked. The answer is cheap (no AI) and never
|
|
55
|
+
// blocks for long: on a slow or failed answer the local copies are used as before.
|
|
56
|
+
const REVISION_KEY = 'smartlinks:translations:revision:';
|
|
57
|
+
const REVISION_WAIT_MS = 1500;
|
|
58
|
+
const revisionChecks = new Map();
|
|
59
|
+
function readStoredRevision(collectionId) {
|
|
60
|
+
try {
|
|
61
|
+
return typeof localStorage !== 'undefined' ? localStorage.getItem(REVISION_KEY + collectionId) : null;
|
|
62
|
+
}
|
|
63
|
+
catch (_a) {
|
|
64
|
+
return null;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
function storeRevision(collectionId, revision) {
|
|
68
|
+
try {
|
|
69
|
+
if (typeof localStorage !== 'undefined')
|
|
70
|
+
localStorage.setItem(REVISION_KEY + collectionId, revision);
|
|
71
|
+
}
|
|
72
|
+
catch ( /* ignore */_a) { /* ignore */ }
|
|
73
|
+
}
|
|
74
|
+
async function checkRevision(collectionId) {
|
|
75
|
+
const res = await request(`/public/collection/${encodeURIComponent(collectionId)}/translations/revision`);
|
|
76
|
+
const revision = typeof (res === null || res === void 0 ? void 0 : res.revision) === 'string' ? res.revision : null;
|
|
77
|
+
if (!revision)
|
|
78
|
+
return;
|
|
79
|
+
const stored = readStoredRevision(collectionId);
|
|
80
|
+
// First look ever: copies saved before this check existed may predate an edit, unless nothing was ever edited.
|
|
81
|
+
const changed = stored === null ? revision !== '0' : stored !== revision;
|
|
82
|
+
if (changed)
|
|
83
|
+
await clearCachedTranslations(collectionId);
|
|
84
|
+
storeRevision(collectionId, revision);
|
|
85
|
+
}
|
|
86
|
+
function refreshIfEdited(collectionId) {
|
|
87
|
+
let check = revisionChecks.get(collectionId);
|
|
88
|
+
if (!check) {
|
|
89
|
+
check = checkRevision(collectionId).catch(() => undefined);
|
|
90
|
+
revisionChecks.set(collectionId, check);
|
|
91
|
+
}
|
|
92
|
+
return Promise.race([check, new Promise((resolve) => setTimeout(resolve, REVISION_WAIT_MS))]);
|
|
93
|
+
}
|
|
94
|
+
/** @internal tests only */
|
|
95
|
+
export function _resetRevisionChecks() {
|
|
96
|
+
revisionChecks.clear();
|
|
97
|
+
}
|
|
52
98
|
export var translations;
|
|
53
99
|
(function (translations) {
|
|
54
100
|
async function hashText(text, options) {
|
|
@@ -135,6 +181,8 @@ export var translations;
|
|
|
135
181
|
items: passthroughItems,
|
|
136
182
|
};
|
|
137
183
|
}
|
|
184
|
+
if (useLocalCache && !refreshLocalCache)
|
|
185
|
+
await refreshIfEdited(collectionId);
|
|
138
186
|
const cachedByHash = useLocalCache && !refreshLocalCache
|
|
139
187
|
? await getCachedTranslations({
|
|
140
188
|
collectionId,
|
|
@@ -242,6 +290,31 @@ export var translations;
|
|
|
242
290
|
return patch(path, body);
|
|
243
291
|
}
|
|
244
292
|
translations.update = update;
|
|
293
|
+
/** Admin: how many translations exist per language, and how many a person has edited. */
|
|
294
|
+
async function summary(collectionId) {
|
|
295
|
+
return request(`/admin/collection/${encodeURIComponent(collectionId)}/translations/summary`);
|
|
296
|
+
}
|
|
297
|
+
translations.summary = summary;
|
|
298
|
+
/** Admin: where translated text appears for one language (context keys), with counts. */
|
|
299
|
+
async function places(collectionId, targetLanguage) {
|
|
300
|
+
return request(`/admin/collection/${encodeURIComponent(collectionId)}/translations/places?targetLanguage=${encodeURIComponent(targetLanguage)}`);
|
|
301
|
+
}
|
|
302
|
+
translations.places = places;
|
|
303
|
+
/** Admin: undo a person's edit with a fresh machine translation. */
|
|
304
|
+
async function reset(collectionId, translationId) {
|
|
305
|
+
return post(`/admin/collection/${encodeURIComponent(collectionId)}/translations/${encodeURIComponent(translationId)}/reset`, {});
|
|
306
|
+
}
|
|
307
|
+
translations.reset = reset;
|
|
308
|
+
/** Admin: the site's translation rules (brief, notes per language, required terms). */
|
|
309
|
+
async function rules(collectionId) {
|
|
310
|
+
return request(`/admin/collection/${encodeURIComponent(collectionId)}/translations/rules`);
|
|
311
|
+
}
|
|
312
|
+
translations.rules = rules;
|
|
313
|
+
/** Admin: replace the site's translation rules. They apply to new translations from now on. */
|
|
314
|
+
async function saveRules(collectionId, body) {
|
|
315
|
+
return put(`/admin/collection/${encodeURIComponent(collectionId)}/translations/rules`, body);
|
|
316
|
+
}
|
|
317
|
+
translations.saveRules = saveRules;
|
|
245
318
|
async function clearLocalCache(collectionId) {
|
|
246
319
|
await clearCachedTranslations(collectionId);
|
|
247
320
|
}
|
package/dist/docs/API_SUMMARY.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Smartlinks API Summary
|
|
2
2
|
|
|
3
|
-
Version: 2.1.
|
|
3
|
+
Version: 2.1.32 | Generated: 2026-11-20T14:23:37.441Z
|
|
4
4
|
|
|
5
5
|
This is a concise summary of all available API functions and types.
|
|
6
6
|
|
|
@@ -12079,6 +12079,7 @@ interface TranslationListParams {
|
|
|
12079
12079
|
contextKey?: string
|
|
12080
12080
|
q?: string
|
|
12081
12081
|
isOverride?: boolean
|
|
12082
|
+
termIssues?: boolean
|
|
12082
12083
|
limit?: number
|
|
12083
12084
|
offset?: number
|
|
12084
12085
|
}
|
|
@@ -12104,6 +12105,28 @@ interface TranslationUpdateRequest {
|
|
|
12104
12105
|
}
|
|
12105
12106
|
```
|
|
12106
12107
|
|
|
12108
|
+
**TranslationTerm** (interface)
|
|
12109
|
+
```typescript
|
|
12110
|
+
interface TranslationTerm {
|
|
12111
|
+
source: string
|
|
12112
|
+
keep?: boolean
|
|
12113
|
+
translations?: Record<string, string>
|
|
12114
|
+
note?: string
|
|
12115
|
+
}
|
|
12116
|
+
```
|
|
12117
|
+
|
|
12118
|
+
**TranslationRules** (interface)
|
|
12119
|
+
```typescript
|
|
12120
|
+
interface TranslationRules {
|
|
12121
|
+
guidance: string
|
|
12122
|
+
languages: Record<string, { guidance: string }>
|
|
12123
|
+
terms: TranslationTerm[]
|
|
12124
|
+
version?: string | null
|
|
12125
|
+
updatedAt?: string | null
|
|
12126
|
+
limits?: { guidance: number; languageGuidance: number; terms: number; term: number; note: number }
|
|
12127
|
+
}
|
|
12128
|
+
```
|
|
12129
|
+
|
|
12107
12130
|
**TranslationLookupMode** = `'cache-fill' | 'cache-only'`
|
|
12108
12131
|
|
|
12109
12132
|
**TranslationContentType** = `'text/plain' | 'text/html' | 'text/x-liquid' | (string & {})`
|
|
@@ -15491,6 +15514,8 @@ Invoke ONE built-in server tool directly — no model in the loop. This is the "
|
|
|
15491
15514
|
|
|
15492
15515
|
### translations
|
|
15493
15516
|
|
|
15517
|
+
**_resetRevisionChecks**() → `void`
|
|
15518
|
+
|
|
15494
15519
|
**hashText**(text: string, options?: TranslationHashOptions) → `Promise<string>`
|
|
15495
15520
|
|
|
15496
15521
|
**hashTexts**(texts: string[], options?: TranslationHashOptions) → `Promise<string[]>`
|
|
@@ -15527,8 +15552,23 @@ Whether a first-time translation is under way right now (see onActivity).
|
|
|
15527
15552
|
body: TranslationUpdateRequest) → `Promise<TranslationRecord>`
|
|
15528
15553
|
Whether a first-time translation is under way right now (see onActivity).
|
|
15529
15554
|
|
|
15555
|
+
**summary**(collectionId: string) → `Promise<`
|
|
15556
|
+
Admin: how many translations exist per language, and how many a person has edited.
|
|
15557
|
+
|
|
15558
|
+
**places**(collectionId: string, targetLanguage: string) → `Promise<`
|
|
15559
|
+
Admin: where translated text appears for one language (context keys), with counts.
|
|
15560
|
+
|
|
15561
|
+
**reset**(collectionId: string, translationId: string) → `Promise<TranslationRecord>`
|
|
15562
|
+
Admin: undo a person's edit with a fresh machine translation.
|
|
15563
|
+
|
|
15564
|
+
**rules**(collectionId: string) → `Promise<TranslationRules>`
|
|
15565
|
+
Admin: the site's translation rules (brief, notes per language, required terms).
|
|
15566
|
+
|
|
15567
|
+
**saveRules**(collectionId: string, body: Pick<TranslationRules, 'guidance' | 'languages' | 'terms'>) → `Promise<TranslationRules>`
|
|
15568
|
+
Admin: replace the site's translation rules. They apply to new translations from now on.
|
|
15569
|
+
|
|
15530
15570
|
**clearLocalCache**(collectionId?: string) → `Promise<void>`
|
|
15531
|
-
|
|
15571
|
+
Admin: replace the site's translation rules. They apply to new translations from now on.
|
|
15532
15572
|
|
|
15533
15573
|
### tts
|
|
15534
15574
|
|
|
@@ -340,6 +340,47 @@ const updated = await translations.update('collection-123', 'translation-id', {
|
|
|
340
340
|
})
|
|
341
341
|
```
|
|
342
342
|
|
|
343
|
+
### Summary, places and reset (Studio's Translations screen)
|
|
344
|
+
|
|
345
|
+
```ts
|
|
346
|
+
await translations.summary(collectionId) // { languages: [{ language, total, edited }] }
|
|
347
|
+
await translations.places(collectionId, 'de') // { places: [{ contextKey, total, edited }] }
|
|
348
|
+
await translations.update(collectionId, id, { translatedText: 'Zum Warenkorb' }) // a person's edit: kept, never overwritten
|
|
349
|
+
await translations.reset(collectionId, id) // put a fresh machine translation back
|
|
350
|
+
```
|
|
351
|
+
|
|
352
|
+
### Corrections reach returning visitors
|
|
353
|
+
|
|
354
|
+
`resolve()` keeps translations in the browser for weeks. Once per page per collection it asks
|
|
355
|
+
`GET /public/collection/:id/translations/revision`, which changes only when a person edits a
|
|
356
|
+
translation or puts a machine one back. When it has changed, that collection's saved translations are
|
|
357
|
+
dropped and fetched again (from the server's store, no AI). A slow or failed answer never holds the
|
|
358
|
+
page for more than 1.5 s, and the saved copies are used as before.
|
|
359
|
+
|
|
360
|
+
### Translation rules (a site's own terminology)
|
|
361
|
+
|
|
362
|
+
A site can give the AI a brief, notes per language and a list of required terms, for example a
|
|
363
|
+
pharmaceutical company whose leaflets must use regulatory wording. They apply to every new machine
|
|
364
|
+
translation for that collection; existing translations are not changed.
|
|
365
|
+
|
|
366
|
+
```ts
|
|
367
|
+
await translations.saveRules(collectionId, {
|
|
368
|
+
guidance: 'Patient information for prescription medicines. Formal register.',
|
|
369
|
+
languages: { de: { guidance: 'Address the reader with Sie.' } },
|
|
370
|
+
terms: [
|
|
371
|
+
{ source: 'tablet', translations: { de: 'Tablette', 'zh-Hans': '片剂' } },
|
|
372
|
+
{ source: 'Lumora', keep: true, note: 'brand name' }, // never translated
|
|
373
|
+
],
|
|
374
|
+
})
|
|
375
|
+
await translations.rules(collectionId) // what is saved, with its version
|
|
376
|
+
await translations.list(collectionId, { targetLanguage: 'de', termIssues: true }) // translations missing a required term
|
|
377
|
+
```
|
|
378
|
+
|
|
379
|
+
Only the terms a text mentions are sent with it. After translating, each result is checked: if the
|
|
380
|
+
source mentions a term and the translation doesn't contain the required wording (any case, endings
|
|
381
|
+
allowed), its `metadata.termIssues` lists the term and `summary()` counts it under `issues`. A person's
|
|
382
|
+
edit is checked the same way. Each machine translation records `metadata.rulesVersion`.
|
|
383
|
+
|
|
343
384
|
## Recommended Usage Pattern
|
|
344
385
|
|
|
345
386
|
For front-end rendering:
|
package/dist/http.js
CHANGED
|
@@ -219,6 +219,9 @@ function shouldSkipCache(path) {
|
|
|
219
219
|
// Bookings change by the second (places left, busy times, a booking's status) — never serve them stale.
|
|
220
220
|
if (/\/app\/[^/]+\/bookings(\/|\?|$)/i.test(path))
|
|
221
221
|
return true;
|
|
222
|
+
// A collection's translation revision is how visitors' browsers learn of a correction — never stale.
|
|
223
|
+
if (/\/translations\/revision(\?|$)/i.test(path))
|
|
224
|
+
return true;
|
|
222
225
|
// Tag ranges change as tags are programmed, and carry the tags' keys — never cached, never persisted.
|
|
223
226
|
if (/\/claimSet\/[^/]+\/ranges(\/|\?|$)/i.test(path))
|
|
224
227
|
return true;
|
package/dist/index.d.ts
CHANGED
|
@@ -35,7 +35,7 @@ export type { VariantResponse, VariantCreateRequest, VariantUpdateRequest, } fro
|
|
|
35
35
|
export type { BroadcastSendRequest } from "./types/broadcasts.js";
|
|
36
36
|
export type { AppConfigOptions } from "./api/appConfiguration.js";
|
|
37
37
|
export type { AdditionalGtin, ISODateString, JsonPrimitive, JsonValue, ProductCreateRequest, ProductClaimCreateInput, ProductClaimCreateRequestBody, ProductClaimLookupInput, ProductFacetMap, ProductFacetValue, ProductImageUrlInput, ProductKey, ProductQueryRequest, ProductQueryResponse, ProductUpdateRequest, Product, ProductWriteInput, PublicProduct, } from "./types/product.js";
|
|
38
|
-
export type { TranslationLookupMode, TranslationContentType, TranslationQuality, TranslationItemStatus, TranslationContextValue, TranslationContext, TranslationLookupRequestBase, TranslationLookupSingleRequest, TranslationLookupBatchRequest, TranslationLookupRequest, TranslationLookupItem, TranslationLookupResponse, ResolvedTranslationItem, ResolvedTranslationResponse, TranslationHashOptions, TranslationResolveOptions, TranslationRecord, TranslationListParams, TranslationListResponse, TranslationUpdateRequest, } from "./types/translations.js";
|
|
38
|
+
export type { TranslationLookupMode, TranslationContentType, TranslationQuality, TranslationItemStatus, TranslationContextValue, TranslationContext, TranslationLookupRequestBase, TranslationLookupSingleRequest, TranslationLookupBatchRequest, TranslationLookupRequest, TranslationLookupItem, TranslationLookupResponse, ResolvedTranslationItem, ResolvedTranslationResponse, TranslationHashOptions, TranslationResolveOptions, TranslationRecord, TranslationListParams, TranslationListResponse, TranslationUpdateRequest, TranslationRules, TranslationTerm, } from "./types/translations.js";
|
|
39
39
|
export type { TranslationActivity } from "./translationActivity.js";
|
|
40
40
|
export type { FacetBucket, FacetDefinition, FacetDefinitionWriteInput, FacetGetParams, FacetListParams, FacetListResponse, FacetNamespaceListResponse, FacetQueryRequest, FacetQueryResponse, FacetValue, FacetValueDefinition, FacetValueGetParams, FacetValueListParams, FacetValueListResponse, FacetValueResponse, FacetValueWriteInput, PublicFacetListParams, } from "./types/facets.js";
|
|
41
41
|
export type { Collection, CollectionResponse, CollectionCreateRequest, CollectionUpdateRequest, DomainTarget, HubAvailabilityResponse, } from "./types/collection.js";
|
package/dist/openapi.yaml
CHANGED
|
@@ -9380,6 +9380,11 @@ paths:
|
|
|
9380
9380
|
required: false
|
|
9381
9381
|
schema:
|
|
9382
9382
|
type: boolean
|
|
9383
|
+
- name: termIssues
|
|
9384
|
+
in: query
|
|
9385
|
+
required: false
|
|
9386
|
+
schema:
|
|
9387
|
+
type: boolean
|
|
9383
9388
|
- name: limit
|
|
9384
9389
|
in: query
|
|
9385
9390
|
required: false
|
|
@@ -9403,6 +9408,65 @@ paths:
|
|
|
9403
9408
|
description: Unauthorized
|
|
9404
9409
|
404:
|
|
9405
9410
|
description: Not found
|
|
9411
|
+
/admin/collection/{collectionId}/translations/rules:
|
|
9412
|
+
get:
|
|
9413
|
+
tags:
|
|
9414
|
+
- translations
|
|
9415
|
+
summary: "Admin: the site's translation rules (brief, notes per language, required terms)."
|
|
9416
|
+
operationId: translations_rules
|
|
9417
|
+
security:
|
|
9418
|
+
- bearerAuth: []
|
|
9419
|
+
parameters:
|
|
9420
|
+
- name: collectionId
|
|
9421
|
+
in: path
|
|
9422
|
+
required: true
|
|
9423
|
+
schema:
|
|
9424
|
+
type: string
|
|
9425
|
+
responses:
|
|
9426
|
+
200:
|
|
9427
|
+
description: Success
|
|
9428
|
+
content:
|
|
9429
|
+
application/json:
|
|
9430
|
+
schema:
|
|
9431
|
+
$ref: "#/components/schemas/TranslationRules"
|
|
9432
|
+
400:
|
|
9433
|
+
description: Bad request
|
|
9434
|
+
401:
|
|
9435
|
+
description: Unauthorized
|
|
9436
|
+
404:
|
|
9437
|
+
description: Not found
|
|
9438
|
+
put:
|
|
9439
|
+
tags:
|
|
9440
|
+
- translations
|
|
9441
|
+
summary: "Admin: replace the site's translation rules."
|
|
9442
|
+
operationId: translations_saveRules
|
|
9443
|
+
security:
|
|
9444
|
+
- bearerAuth: []
|
|
9445
|
+
parameters:
|
|
9446
|
+
- name: collectionId
|
|
9447
|
+
in: path
|
|
9448
|
+
required: true
|
|
9449
|
+
schema:
|
|
9450
|
+
type: string
|
|
9451
|
+
responses:
|
|
9452
|
+
200:
|
|
9453
|
+
description: Success
|
|
9454
|
+
content:
|
|
9455
|
+
application/json:
|
|
9456
|
+
schema:
|
|
9457
|
+
$ref: "#/components/schemas/TranslationRules"
|
|
9458
|
+
400:
|
|
9459
|
+
description: Bad request
|
|
9460
|
+
401:
|
|
9461
|
+
description: Unauthorized
|
|
9462
|
+
404:
|
|
9463
|
+
description: Not found
|
|
9464
|
+
requestBody:
|
|
9465
|
+
required: true
|
|
9466
|
+
content:
|
|
9467
|
+
application/json:
|
|
9468
|
+
schema:
|
|
9469
|
+
$ref: "#/components/schemas/TranslationRules"
|
|
9406
9470
|
/admin/collection/{collectionId}/translations/{translationId}:
|
|
9407
9471
|
get:
|
|
9408
9472
|
tags:
|
|
@@ -9472,6 +9536,38 @@ paths:
|
|
|
9472
9536
|
application/json:
|
|
9473
9537
|
schema:
|
|
9474
9538
|
$ref: "#/components/schemas/TranslationUpdateRequest"
|
|
9539
|
+
/admin/collection/{collectionId}/translations/{translationId}/reset:
|
|
9540
|
+
post:
|
|
9541
|
+
tags:
|
|
9542
|
+
- translations
|
|
9543
|
+
summary: "Admin: undo a person's edit with a fresh machine translation."
|
|
9544
|
+
operationId: translations_reset
|
|
9545
|
+
security:
|
|
9546
|
+
- bearerAuth: []
|
|
9547
|
+
parameters:
|
|
9548
|
+
- name: collectionId
|
|
9549
|
+
in: path
|
|
9550
|
+
required: true
|
|
9551
|
+
schema:
|
|
9552
|
+
type: string
|
|
9553
|
+
- name: translationId
|
|
9554
|
+
in: path
|
|
9555
|
+
required: true
|
|
9556
|
+
schema:
|
|
9557
|
+
type: string
|
|
9558
|
+
responses:
|
|
9559
|
+
200:
|
|
9560
|
+
description: Success
|
|
9561
|
+
content:
|
|
9562
|
+
application/json:
|
|
9563
|
+
schema:
|
|
9564
|
+
$ref: "#/components/schemas/TranslationRecord"
|
|
9565
|
+
400:
|
|
9566
|
+
description: Bad request
|
|
9567
|
+
401:
|
|
9568
|
+
description: Unauthorized
|
|
9569
|
+
404:
|
|
9570
|
+
description: Not found
|
|
9475
9571
|
/admin/collection/{collectionId}/updateUserAccess:
|
|
9476
9572
|
post:
|
|
9477
9573
|
tags:
|
|
@@ -37113,6 +37209,8 @@ components:
|
|
|
37113
37209
|
type: string
|
|
37114
37210
|
isOverride:
|
|
37115
37211
|
type: boolean
|
|
37212
|
+
termIssues:
|
|
37213
|
+
type: boolean
|
|
37116
37214
|
limit:
|
|
37117
37215
|
type: number
|
|
37118
37216
|
offset:
|
|
@@ -37144,6 +37242,46 @@ components:
|
|
|
37144
37242
|
metadata:
|
|
37145
37243
|
type: object
|
|
37146
37244
|
additionalProperties: true
|
|
37245
|
+
TranslationTerm:
|
|
37246
|
+
type: object
|
|
37247
|
+
properties:
|
|
37248
|
+
source:
|
|
37249
|
+
type: string
|
|
37250
|
+
keep:
|
|
37251
|
+
type: boolean
|
|
37252
|
+
translations:
|
|
37253
|
+
type: object
|
|
37254
|
+
additionalProperties:
|
|
37255
|
+
type: string
|
|
37256
|
+
note:
|
|
37257
|
+
type: string
|
|
37258
|
+
required:
|
|
37259
|
+
- source
|
|
37260
|
+
TranslationRules:
|
|
37261
|
+
type: object
|
|
37262
|
+
properties:
|
|
37263
|
+
guidance:
|
|
37264
|
+
type: string
|
|
37265
|
+
languages:
|
|
37266
|
+
type: object
|
|
37267
|
+
additionalProperties:
|
|
37268
|
+
type: object
|
|
37269
|
+
additionalProperties: true
|
|
37270
|
+
terms:
|
|
37271
|
+
type: array
|
|
37272
|
+
items:
|
|
37273
|
+
$ref: "#/components/schemas/TranslationTerm"
|
|
37274
|
+
version:
|
|
37275
|
+
type: string
|
|
37276
|
+
updatedAt:
|
|
37277
|
+
type: string
|
|
37278
|
+
limits:
|
|
37279
|
+
type: object
|
|
37280
|
+
additionalProperties: true
|
|
37281
|
+
required:
|
|
37282
|
+
- guidance
|
|
37283
|
+
- languages
|
|
37284
|
+
- terms
|
|
37147
37285
|
TranslationLookupMode:
|
|
37148
37286
|
type: string
|
|
37149
37287
|
enum:
|
|
@@ -90,6 +90,8 @@ export interface TranslationListParams {
|
|
|
90
90
|
contextKey?: string;
|
|
91
91
|
q?: string;
|
|
92
92
|
isOverride?: boolean;
|
|
93
|
+
/** Only translations that don't use the site's required wording (see TranslationRules). */
|
|
94
|
+
termIssues?: boolean;
|
|
93
95
|
limit?: number;
|
|
94
96
|
offset?: number;
|
|
95
97
|
}
|
|
@@ -105,3 +107,34 @@ export interface TranslationUpdateRequest {
|
|
|
105
107
|
quality?: TranslationQuality;
|
|
106
108
|
metadata?: Record<string, any>;
|
|
107
109
|
}
|
|
110
|
+
/** One required term: the English wording and what each language must use, or kept as written. */
|
|
111
|
+
export interface TranslationTerm {
|
|
112
|
+
source: string;
|
|
113
|
+
/** Keep exactly as written in every language (brand names, drug names, units). */
|
|
114
|
+
keep?: boolean;
|
|
115
|
+
/** Language code -> required wording. */
|
|
116
|
+
translations?: Record<string, string>;
|
|
117
|
+
note?: string;
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* A site's own rules for its machine translations: a brief for the whole site, notes per language, and
|
|
121
|
+
* required terms. Used for every new translation; translations missing a required term are flagged
|
|
122
|
+
* (record metadata.termIssues / termIssueCount).
|
|
123
|
+
*/
|
|
124
|
+
export interface TranslationRules {
|
|
125
|
+
guidance: string;
|
|
126
|
+
languages: Record<string, {
|
|
127
|
+
guidance: string;
|
|
128
|
+
}>;
|
|
129
|
+
terms: TranslationTerm[];
|
|
130
|
+
/** Fingerprint of these rules; each machine translation stores the one it was made under (metadata.rulesVersion). */
|
|
131
|
+
version?: string | null;
|
|
132
|
+
updatedAt?: string | null;
|
|
133
|
+
limits?: {
|
|
134
|
+
guidance: number;
|
|
135
|
+
languageGuidance: number;
|
|
136
|
+
terms: number;
|
|
137
|
+
term: number;
|
|
138
|
+
note: number;
|
|
139
|
+
};
|
|
140
|
+
}
|
package/docs/API_SUMMARY.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Smartlinks API Summary
|
|
2
2
|
|
|
3
|
-
Version: 2.1.
|
|
3
|
+
Version: 2.1.32 | Generated: 2026-11-20T14:23:37.441Z
|
|
4
4
|
|
|
5
5
|
This is a concise summary of all available API functions and types.
|
|
6
6
|
|
|
@@ -12079,6 +12079,7 @@ interface TranslationListParams {
|
|
|
12079
12079
|
contextKey?: string
|
|
12080
12080
|
q?: string
|
|
12081
12081
|
isOverride?: boolean
|
|
12082
|
+
termIssues?: boolean
|
|
12082
12083
|
limit?: number
|
|
12083
12084
|
offset?: number
|
|
12084
12085
|
}
|
|
@@ -12104,6 +12105,28 @@ interface TranslationUpdateRequest {
|
|
|
12104
12105
|
}
|
|
12105
12106
|
```
|
|
12106
12107
|
|
|
12108
|
+
**TranslationTerm** (interface)
|
|
12109
|
+
```typescript
|
|
12110
|
+
interface TranslationTerm {
|
|
12111
|
+
source: string
|
|
12112
|
+
keep?: boolean
|
|
12113
|
+
translations?: Record<string, string>
|
|
12114
|
+
note?: string
|
|
12115
|
+
}
|
|
12116
|
+
```
|
|
12117
|
+
|
|
12118
|
+
**TranslationRules** (interface)
|
|
12119
|
+
```typescript
|
|
12120
|
+
interface TranslationRules {
|
|
12121
|
+
guidance: string
|
|
12122
|
+
languages: Record<string, { guidance: string }>
|
|
12123
|
+
terms: TranslationTerm[]
|
|
12124
|
+
version?: string | null
|
|
12125
|
+
updatedAt?: string | null
|
|
12126
|
+
limits?: { guidance: number; languageGuidance: number; terms: number; term: number; note: number }
|
|
12127
|
+
}
|
|
12128
|
+
```
|
|
12129
|
+
|
|
12107
12130
|
**TranslationLookupMode** = `'cache-fill' | 'cache-only'`
|
|
12108
12131
|
|
|
12109
12132
|
**TranslationContentType** = `'text/plain' | 'text/html' | 'text/x-liquid' | (string & {})`
|
|
@@ -15491,6 +15514,8 @@ Invoke ONE built-in server tool directly — no model in the loop. This is the "
|
|
|
15491
15514
|
|
|
15492
15515
|
### translations
|
|
15493
15516
|
|
|
15517
|
+
**_resetRevisionChecks**() → `void`
|
|
15518
|
+
|
|
15494
15519
|
**hashText**(text: string, options?: TranslationHashOptions) → `Promise<string>`
|
|
15495
15520
|
|
|
15496
15521
|
**hashTexts**(texts: string[], options?: TranslationHashOptions) → `Promise<string[]>`
|
|
@@ -15527,8 +15552,23 @@ Whether a first-time translation is under way right now (see onActivity).
|
|
|
15527
15552
|
body: TranslationUpdateRequest) → `Promise<TranslationRecord>`
|
|
15528
15553
|
Whether a first-time translation is under way right now (see onActivity).
|
|
15529
15554
|
|
|
15555
|
+
**summary**(collectionId: string) → `Promise<`
|
|
15556
|
+
Admin: how many translations exist per language, and how many a person has edited.
|
|
15557
|
+
|
|
15558
|
+
**places**(collectionId: string, targetLanguage: string) → `Promise<`
|
|
15559
|
+
Admin: where translated text appears for one language (context keys), with counts.
|
|
15560
|
+
|
|
15561
|
+
**reset**(collectionId: string, translationId: string) → `Promise<TranslationRecord>`
|
|
15562
|
+
Admin: undo a person's edit with a fresh machine translation.
|
|
15563
|
+
|
|
15564
|
+
**rules**(collectionId: string) → `Promise<TranslationRules>`
|
|
15565
|
+
Admin: the site's translation rules (brief, notes per language, required terms).
|
|
15566
|
+
|
|
15567
|
+
**saveRules**(collectionId: string, body: Pick<TranslationRules, 'guidance' | 'languages' | 'terms'>) → `Promise<TranslationRules>`
|
|
15568
|
+
Admin: replace the site's translation rules. They apply to new translations from now on.
|
|
15569
|
+
|
|
15530
15570
|
**clearLocalCache**(collectionId?: string) → `Promise<void>`
|
|
15531
|
-
|
|
15571
|
+
Admin: replace the site's translation rules. They apply to new translations from now on.
|
|
15532
15572
|
|
|
15533
15573
|
### tts
|
|
15534
15574
|
|
package/docs/translations.md
CHANGED
|
@@ -340,6 +340,47 @@ const updated = await translations.update('collection-123', 'translation-id', {
|
|
|
340
340
|
})
|
|
341
341
|
```
|
|
342
342
|
|
|
343
|
+
### Summary, places and reset (Studio's Translations screen)
|
|
344
|
+
|
|
345
|
+
```ts
|
|
346
|
+
await translations.summary(collectionId) // { languages: [{ language, total, edited }] }
|
|
347
|
+
await translations.places(collectionId, 'de') // { places: [{ contextKey, total, edited }] }
|
|
348
|
+
await translations.update(collectionId, id, { translatedText: 'Zum Warenkorb' }) // a person's edit: kept, never overwritten
|
|
349
|
+
await translations.reset(collectionId, id) // put a fresh machine translation back
|
|
350
|
+
```
|
|
351
|
+
|
|
352
|
+
### Corrections reach returning visitors
|
|
353
|
+
|
|
354
|
+
`resolve()` keeps translations in the browser for weeks. Once per page per collection it asks
|
|
355
|
+
`GET /public/collection/:id/translations/revision`, which changes only when a person edits a
|
|
356
|
+
translation or puts a machine one back. When it has changed, that collection's saved translations are
|
|
357
|
+
dropped and fetched again (from the server's store, no AI). A slow or failed answer never holds the
|
|
358
|
+
page for more than 1.5 s, and the saved copies are used as before.
|
|
359
|
+
|
|
360
|
+
### Translation rules (a site's own terminology)
|
|
361
|
+
|
|
362
|
+
A site can give the AI a brief, notes per language and a list of required terms, for example a
|
|
363
|
+
pharmaceutical company whose leaflets must use regulatory wording. They apply to every new machine
|
|
364
|
+
translation for that collection; existing translations are not changed.
|
|
365
|
+
|
|
366
|
+
```ts
|
|
367
|
+
await translations.saveRules(collectionId, {
|
|
368
|
+
guidance: 'Patient information for prescription medicines. Formal register.',
|
|
369
|
+
languages: { de: { guidance: 'Address the reader with Sie.' } },
|
|
370
|
+
terms: [
|
|
371
|
+
{ source: 'tablet', translations: { de: 'Tablette', 'zh-Hans': '片剂' } },
|
|
372
|
+
{ source: 'Lumora', keep: true, note: 'brand name' }, // never translated
|
|
373
|
+
],
|
|
374
|
+
})
|
|
375
|
+
await translations.rules(collectionId) // what is saved, with its version
|
|
376
|
+
await translations.list(collectionId, { targetLanguage: 'de', termIssues: true }) // translations missing a required term
|
|
377
|
+
```
|
|
378
|
+
|
|
379
|
+
Only the terms a text mentions are sent with it. After translating, each result is checked: if the
|
|
380
|
+
source mentions a term and the translation doesn't contain the required wording (any case, endings
|
|
381
|
+
allowed), its `metadata.termIssues` lists the term and `summary()` counts it under `issues`. A person's
|
|
382
|
+
edit is checked the same way. Each machine translation records `metadata.rulesVersion`.
|
|
383
|
+
|
|
343
384
|
## Recommended Usage Pattern
|
|
344
385
|
|
|
345
386
|
For front-end rendering:
|
package/openapi.yaml
CHANGED
|
@@ -9380,6 +9380,11 @@ paths:
|
|
|
9380
9380
|
required: false
|
|
9381
9381
|
schema:
|
|
9382
9382
|
type: boolean
|
|
9383
|
+
- name: termIssues
|
|
9384
|
+
in: query
|
|
9385
|
+
required: false
|
|
9386
|
+
schema:
|
|
9387
|
+
type: boolean
|
|
9383
9388
|
- name: limit
|
|
9384
9389
|
in: query
|
|
9385
9390
|
required: false
|
|
@@ -9403,6 +9408,65 @@ paths:
|
|
|
9403
9408
|
description: Unauthorized
|
|
9404
9409
|
404:
|
|
9405
9410
|
description: Not found
|
|
9411
|
+
/admin/collection/{collectionId}/translations/rules:
|
|
9412
|
+
get:
|
|
9413
|
+
tags:
|
|
9414
|
+
- translations
|
|
9415
|
+
summary: "Admin: the site's translation rules (brief, notes per language, required terms)."
|
|
9416
|
+
operationId: translations_rules
|
|
9417
|
+
security:
|
|
9418
|
+
- bearerAuth: []
|
|
9419
|
+
parameters:
|
|
9420
|
+
- name: collectionId
|
|
9421
|
+
in: path
|
|
9422
|
+
required: true
|
|
9423
|
+
schema:
|
|
9424
|
+
type: string
|
|
9425
|
+
responses:
|
|
9426
|
+
200:
|
|
9427
|
+
description: Success
|
|
9428
|
+
content:
|
|
9429
|
+
application/json:
|
|
9430
|
+
schema:
|
|
9431
|
+
$ref: "#/components/schemas/TranslationRules"
|
|
9432
|
+
400:
|
|
9433
|
+
description: Bad request
|
|
9434
|
+
401:
|
|
9435
|
+
description: Unauthorized
|
|
9436
|
+
404:
|
|
9437
|
+
description: Not found
|
|
9438
|
+
put:
|
|
9439
|
+
tags:
|
|
9440
|
+
- translations
|
|
9441
|
+
summary: "Admin: replace the site's translation rules."
|
|
9442
|
+
operationId: translations_saveRules
|
|
9443
|
+
security:
|
|
9444
|
+
- bearerAuth: []
|
|
9445
|
+
parameters:
|
|
9446
|
+
- name: collectionId
|
|
9447
|
+
in: path
|
|
9448
|
+
required: true
|
|
9449
|
+
schema:
|
|
9450
|
+
type: string
|
|
9451
|
+
responses:
|
|
9452
|
+
200:
|
|
9453
|
+
description: Success
|
|
9454
|
+
content:
|
|
9455
|
+
application/json:
|
|
9456
|
+
schema:
|
|
9457
|
+
$ref: "#/components/schemas/TranslationRules"
|
|
9458
|
+
400:
|
|
9459
|
+
description: Bad request
|
|
9460
|
+
401:
|
|
9461
|
+
description: Unauthorized
|
|
9462
|
+
404:
|
|
9463
|
+
description: Not found
|
|
9464
|
+
requestBody:
|
|
9465
|
+
required: true
|
|
9466
|
+
content:
|
|
9467
|
+
application/json:
|
|
9468
|
+
schema:
|
|
9469
|
+
$ref: "#/components/schemas/TranslationRules"
|
|
9406
9470
|
/admin/collection/{collectionId}/translations/{translationId}:
|
|
9407
9471
|
get:
|
|
9408
9472
|
tags:
|
|
@@ -9472,6 +9536,38 @@ paths:
|
|
|
9472
9536
|
application/json:
|
|
9473
9537
|
schema:
|
|
9474
9538
|
$ref: "#/components/schemas/TranslationUpdateRequest"
|
|
9539
|
+
/admin/collection/{collectionId}/translations/{translationId}/reset:
|
|
9540
|
+
post:
|
|
9541
|
+
tags:
|
|
9542
|
+
- translations
|
|
9543
|
+
summary: "Admin: undo a person's edit with a fresh machine translation."
|
|
9544
|
+
operationId: translations_reset
|
|
9545
|
+
security:
|
|
9546
|
+
- bearerAuth: []
|
|
9547
|
+
parameters:
|
|
9548
|
+
- name: collectionId
|
|
9549
|
+
in: path
|
|
9550
|
+
required: true
|
|
9551
|
+
schema:
|
|
9552
|
+
type: string
|
|
9553
|
+
- name: translationId
|
|
9554
|
+
in: path
|
|
9555
|
+
required: true
|
|
9556
|
+
schema:
|
|
9557
|
+
type: string
|
|
9558
|
+
responses:
|
|
9559
|
+
200:
|
|
9560
|
+
description: Success
|
|
9561
|
+
content:
|
|
9562
|
+
application/json:
|
|
9563
|
+
schema:
|
|
9564
|
+
$ref: "#/components/schemas/TranslationRecord"
|
|
9565
|
+
400:
|
|
9566
|
+
description: Bad request
|
|
9567
|
+
401:
|
|
9568
|
+
description: Unauthorized
|
|
9569
|
+
404:
|
|
9570
|
+
description: Not found
|
|
9475
9571
|
/admin/collection/{collectionId}/updateUserAccess:
|
|
9476
9572
|
post:
|
|
9477
9573
|
tags:
|
|
@@ -37113,6 +37209,8 @@ components:
|
|
|
37113
37209
|
type: string
|
|
37114
37210
|
isOverride:
|
|
37115
37211
|
type: boolean
|
|
37212
|
+
termIssues:
|
|
37213
|
+
type: boolean
|
|
37116
37214
|
limit:
|
|
37117
37215
|
type: number
|
|
37118
37216
|
offset:
|
|
@@ -37144,6 +37242,46 @@ components:
|
|
|
37144
37242
|
metadata:
|
|
37145
37243
|
type: object
|
|
37146
37244
|
additionalProperties: true
|
|
37245
|
+
TranslationTerm:
|
|
37246
|
+
type: object
|
|
37247
|
+
properties:
|
|
37248
|
+
source:
|
|
37249
|
+
type: string
|
|
37250
|
+
keep:
|
|
37251
|
+
type: boolean
|
|
37252
|
+
translations:
|
|
37253
|
+
type: object
|
|
37254
|
+
additionalProperties:
|
|
37255
|
+
type: string
|
|
37256
|
+
note:
|
|
37257
|
+
type: string
|
|
37258
|
+
required:
|
|
37259
|
+
- source
|
|
37260
|
+
TranslationRules:
|
|
37261
|
+
type: object
|
|
37262
|
+
properties:
|
|
37263
|
+
guidance:
|
|
37264
|
+
type: string
|
|
37265
|
+
languages:
|
|
37266
|
+
type: object
|
|
37267
|
+
additionalProperties:
|
|
37268
|
+
type: object
|
|
37269
|
+
additionalProperties: true
|
|
37270
|
+
terms:
|
|
37271
|
+
type: array
|
|
37272
|
+
items:
|
|
37273
|
+
$ref: "#/components/schemas/TranslationTerm"
|
|
37274
|
+
version:
|
|
37275
|
+
type: string
|
|
37276
|
+
updatedAt:
|
|
37277
|
+
type: string
|
|
37278
|
+
limits:
|
|
37279
|
+
type: object
|
|
37280
|
+
additionalProperties: true
|
|
37281
|
+
required:
|
|
37282
|
+
- guidance
|
|
37283
|
+
- languages
|
|
37284
|
+
- terms
|
|
37147
37285
|
TranslationLookupMode:
|
|
37148
37286
|
type: string
|
|
37149
37287
|
enum:
|