@better-i18n/mcp-types 0.3.1 → 0.5.0
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/package.json +1 -1
- package/src/client-types.ts +12 -0
- package/src/schemas.ts +85 -1
- package/src/types.ts +143 -4
package/package.json
CHANGED
package/src/client-types.ts
CHANGED
|
@@ -16,6 +16,8 @@ import type {
|
|
|
16
16
|
AddLanguageInput,
|
|
17
17
|
GetSyncsInput,
|
|
18
18
|
GetSyncInput,
|
|
19
|
+
GetPendingChangesInput,
|
|
20
|
+
PublishInput,
|
|
19
21
|
} from "./schemas";
|
|
20
22
|
|
|
21
23
|
import type {
|
|
@@ -29,6 +31,8 @@ import type {
|
|
|
29
31
|
AddLanguageResponse,
|
|
30
32
|
GetSyncsResponse,
|
|
31
33
|
GetSyncResponse,
|
|
34
|
+
GetPendingChangesResponse,
|
|
35
|
+
PublishResponse,
|
|
32
36
|
} from "./types";
|
|
33
37
|
|
|
34
38
|
/**
|
|
@@ -70,6 +74,14 @@ export interface MCPClient {
|
|
|
70
74
|
getSync: {
|
|
71
75
|
query: (input: GetSyncInput) => Promise<GetSyncResponse>;
|
|
72
76
|
};
|
|
77
|
+
getPendingChanges: {
|
|
78
|
+
query: (
|
|
79
|
+
input: GetPendingChangesInput,
|
|
80
|
+
) => Promise<GetPendingChangesResponse>;
|
|
81
|
+
};
|
|
82
|
+
publish: {
|
|
83
|
+
mutate: (input: PublishInput) => Promise<PublishResponse>;
|
|
84
|
+
};
|
|
73
85
|
}
|
|
74
86
|
|
|
75
87
|
/**
|
package/src/schemas.ts
CHANGED
|
@@ -124,6 +124,39 @@ export type GetAllTranslationsInput = z.input<typeof getAllTranslationsInput>;
|
|
|
124
124
|
// Write Endpoint Schemas - COMPACT FORMAT
|
|
125
125
|
// ============================================================================
|
|
126
126
|
|
|
127
|
+
/**
|
|
128
|
+
* Namespace context object for enriching namespace metadata.
|
|
129
|
+
* Provide this on any key to set context on its namespace.
|
|
130
|
+
* If multiple keys share a namespace, the last context wins.
|
|
131
|
+
*/
|
|
132
|
+
const namespaceContextSchema = z.object({
|
|
133
|
+
/** Human-readable description of the namespace */
|
|
134
|
+
description: z
|
|
135
|
+
.string()
|
|
136
|
+
.optional()
|
|
137
|
+
.describe("What this namespace contains (e.g., 'Authentication flow strings')"),
|
|
138
|
+
/** Owning team */
|
|
139
|
+
team: z
|
|
140
|
+
.string()
|
|
141
|
+
.optional()
|
|
142
|
+
.describe("Team responsible (e.g., 'auth-team')"),
|
|
143
|
+
/** Business domain */
|
|
144
|
+
domain: z
|
|
145
|
+
.string()
|
|
146
|
+
.optional()
|
|
147
|
+
.describe("Business domain (e.g., 'authentication', 'payments')"),
|
|
148
|
+
/** AI translation guidance specific to this namespace */
|
|
149
|
+
aiPrompt: z
|
|
150
|
+
.string()
|
|
151
|
+
.optional()
|
|
152
|
+
.describe("Extra AI translation instructions for this namespace"),
|
|
153
|
+
/** Organizational tags */
|
|
154
|
+
tags: z
|
|
155
|
+
.array(z.string())
|
|
156
|
+
.optional()
|
|
157
|
+
.describe("Tags for categorization (e.g., ['critical', 'user-facing'])"),
|
|
158
|
+
});
|
|
159
|
+
|
|
127
160
|
/**
|
|
128
161
|
* Compact key item for createKeys endpoint.
|
|
129
162
|
*
|
|
@@ -132,6 +165,7 @@ export type GetAllTranslationsInput = z.input<typeof getAllTranslationsInput>;
|
|
|
132
165
|
* - ns: namespace (default: "default")
|
|
133
166
|
* - v: source value (source language text)
|
|
134
167
|
* - t: translations object { langCode: text }
|
|
168
|
+
* - nc: namespace context (optional, enriches the namespace)
|
|
135
169
|
*/
|
|
136
170
|
const compactCreateKeyItem = z.object({
|
|
137
171
|
/** Key name (e.g., "submit_button", "nav.home") */
|
|
@@ -145,6 +179,12 @@ const compactCreateKeyItem = z.object({
|
|
|
145
179
|
.record(z.string(), z.string())
|
|
146
180
|
.optional()
|
|
147
181
|
.describe("Target translations object"),
|
|
182
|
+
/** Namespace context - enriches the namespace with metadata */
|
|
183
|
+
nc: namespaceContextSchema
|
|
184
|
+
.optional()
|
|
185
|
+
.describe(
|
|
186
|
+
"Namespace context: description, team, domain, aiPrompt, tags. Sets metadata on the namespace.",
|
|
187
|
+
),
|
|
148
188
|
});
|
|
149
189
|
|
|
150
190
|
/**
|
|
@@ -187,6 +227,12 @@ const compactUpdateItem = z.object({
|
|
|
187
227
|
s: z.boolean().optional().describe("Is source language"),
|
|
188
228
|
/** Status */
|
|
189
229
|
st: z.string().optional().describe("Translation status"),
|
|
230
|
+
/** Namespace context - enriches the namespace with metadata */
|
|
231
|
+
nc: namespaceContextSchema
|
|
232
|
+
.optional()
|
|
233
|
+
.describe(
|
|
234
|
+
"Namespace context: description, team, domain, aiPrompt, tags. Sets metadata on the namespace.",
|
|
235
|
+
),
|
|
190
236
|
});
|
|
191
237
|
|
|
192
238
|
/**
|
|
@@ -244,7 +290,7 @@ export const getSyncsInput = projectIdentifierSchema.extend({
|
|
|
244
290
|
.describe("Filter syncs by status"),
|
|
245
291
|
/** Filter by job type */
|
|
246
292
|
type: z
|
|
247
|
-
.enum(["initial_import", "source_sync", "cdn_upload", "
|
|
293
|
+
.enum(["initial_import", "source_sync", "cdn_upload", "batch_publish"])
|
|
248
294
|
.optional()
|
|
249
295
|
.describe("Filter syncs by job type"),
|
|
250
296
|
});
|
|
@@ -260,3 +306,41 @@ export const getSyncInput = z.object({
|
|
|
260
306
|
syncId: z.string().describe("The sync job ID to retrieve details for"),
|
|
261
307
|
});
|
|
262
308
|
export type GetSyncInput = z.input<typeof getSyncInput>;
|
|
309
|
+
|
|
310
|
+
// ============================================================================
|
|
311
|
+
// Publish Endpoint Schemas
|
|
312
|
+
// ============================================================================
|
|
313
|
+
|
|
314
|
+
/**
|
|
315
|
+
* Input schema for getPendingChanges endpoint.
|
|
316
|
+
* Returns what's ready to be published (translations, deleted keys, language changes).
|
|
317
|
+
*/
|
|
318
|
+
export const getPendingChangesInput = projectIdentifierSchema;
|
|
319
|
+
export type GetPendingChangesInput = z.input<typeof getPendingChangesInput>;
|
|
320
|
+
|
|
321
|
+
/**
|
|
322
|
+
* Input schema for publish endpoint.
|
|
323
|
+
* Publishes pending changes to CDN or GitHub.
|
|
324
|
+
*
|
|
325
|
+
* If translations array is omitted, ALL pending changes are published.
|
|
326
|
+
* If translations array is provided, only those specific translations are published.
|
|
327
|
+
*/
|
|
328
|
+
export const publishInput = projectIdentifierSchema.extend({
|
|
329
|
+
/**
|
|
330
|
+
* Optional: specific translations to publish.
|
|
331
|
+
* If omitted, all pending changes (translations + deleted keys + language changes) are published.
|
|
332
|
+
*/
|
|
333
|
+
translations: z
|
|
334
|
+
.array(
|
|
335
|
+
z.object({
|
|
336
|
+
keyId: z.string().uuid(),
|
|
337
|
+
languageCode: z.string(),
|
|
338
|
+
}),
|
|
339
|
+
)
|
|
340
|
+
.optional()
|
|
341
|
+
.describe(
|
|
342
|
+
"Specific translations to publish. If omitted, all pending changes are published.",
|
|
343
|
+
),
|
|
344
|
+
});
|
|
345
|
+
export type PublishOutput = z.infer<typeof publishInput>;
|
|
346
|
+
export type PublishInput = z.input<typeof publishInput>;
|
package/src/types.ts
CHANGED
|
@@ -42,6 +42,25 @@ export interface LanguageCoverage {
|
|
|
42
42
|
percentage: number;
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
+
/**
|
|
46
|
+
* Namespace metadata returned from read endpoints.
|
|
47
|
+
*/
|
|
48
|
+
export interface NamespaceInfo {
|
|
49
|
+
/** Namespace name ("default" for root keys) */
|
|
50
|
+
name: string;
|
|
51
|
+
/** Number of keys in this namespace */
|
|
52
|
+
keyCount: number;
|
|
53
|
+
/** Human-readable description */
|
|
54
|
+
description: string | null;
|
|
55
|
+
/** Structured context (team, domain, aiPrompt, tags) */
|
|
56
|
+
context: {
|
|
57
|
+
team?: string;
|
|
58
|
+
domain?: string;
|
|
59
|
+
aiPrompt?: string;
|
|
60
|
+
tags?: string[];
|
|
61
|
+
} | null;
|
|
62
|
+
}
|
|
63
|
+
|
|
45
64
|
/**
|
|
46
65
|
* Response from getProject endpoint.
|
|
47
66
|
*/
|
|
@@ -50,8 +69,8 @@ export interface GetProjectResponse {
|
|
|
50
69
|
project: string;
|
|
51
70
|
/** Source language code */
|
|
52
71
|
sourceLanguage: string;
|
|
53
|
-
/** Available namespaces */
|
|
54
|
-
namespaces:
|
|
72
|
+
/** Available namespaces with metadata */
|
|
73
|
+
namespaces: NamespaceInfo[];
|
|
55
74
|
/** Available target languages */
|
|
56
75
|
languages: string[];
|
|
57
76
|
/** Total number of translation keys */
|
|
@@ -112,6 +131,8 @@ export interface GetAllTranslationsResponse {
|
|
|
112
131
|
status?: string;
|
|
113
132
|
/** Translation keys with their translations */
|
|
114
133
|
keys: KeyWithFullTranslations[];
|
|
134
|
+
/** Namespace metadata for namespaces present in results */
|
|
135
|
+
namespaceDetails?: Record<string, NamespaceInfo>;
|
|
115
136
|
}
|
|
116
137
|
|
|
117
138
|
/**
|
|
@@ -140,6 +161,8 @@ export interface ListKeysResponse {
|
|
|
140
161
|
page: number;
|
|
141
162
|
limit: number;
|
|
142
163
|
keys: KeyWithTranslations[];
|
|
164
|
+
/** Namespace metadata for namespaces present in results */
|
|
165
|
+
namespaceDetails?: Record<string, NamespaceInfo>;
|
|
143
166
|
}
|
|
144
167
|
|
|
145
168
|
// ============================================================================
|
|
@@ -164,12 +187,20 @@ export interface CreateKeyResultItem {
|
|
|
164
187
|
export interface CreateKeysResponse {
|
|
165
188
|
/** Operation success */
|
|
166
189
|
success: boolean;
|
|
167
|
-
/**
|
|
190
|
+
/** Total keys created */
|
|
168
191
|
keysCreated: number;
|
|
192
|
+
/** Number of new keys inserted */
|
|
193
|
+
created: number;
|
|
194
|
+
/** Number of soft-deleted keys renamed to free up key names */
|
|
195
|
+
renamed: number;
|
|
196
|
+
/** Number of duplicate keys skipped */
|
|
197
|
+
duplicates: number;
|
|
169
198
|
/** Created key details */
|
|
170
199
|
keys: CreateKeyResultItem[];
|
|
171
200
|
/** Skipped keys (duplicates) */
|
|
172
201
|
skipped?: Array<{ key: string; reason: string }>;
|
|
202
|
+
/** Pending publish hint - reminds AI to call publish */
|
|
203
|
+
pendingPublish?: PendingPublishHint;
|
|
173
204
|
}
|
|
174
205
|
|
|
175
206
|
/**
|
|
@@ -194,6 +225,8 @@ export interface UpdateKeysResponse {
|
|
|
194
225
|
keysUpdated: number;
|
|
195
226
|
/** Updated key details */
|
|
196
227
|
updates: UpdateKeyResultItem[];
|
|
228
|
+
/** Pending publish hint - reminds AI to call publish */
|
|
229
|
+
pendingPublish?: PendingPublishHint;
|
|
197
230
|
}
|
|
198
231
|
|
|
199
232
|
/**
|
|
@@ -245,7 +278,7 @@ export type SyncJobType =
|
|
|
245
278
|
| "initial_import"
|
|
246
279
|
| "source_sync"
|
|
247
280
|
| "cdn_upload"
|
|
248
|
-
| "
|
|
281
|
+
| "batch_publish";
|
|
249
282
|
|
|
250
283
|
/**
|
|
251
284
|
* Sync job status.
|
|
@@ -321,3 +354,109 @@ export interface GetSyncResponse {
|
|
|
321
354
|
/** Affected keys */
|
|
322
355
|
affectedKeys: AffectedKey[];
|
|
323
356
|
}
|
|
357
|
+
|
|
358
|
+
// ============================================================================
|
|
359
|
+
// Publish Types
|
|
360
|
+
// ============================================================================
|
|
361
|
+
|
|
362
|
+
/**
|
|
363
|
+
* Preview item for pending translation.
|
|
364
|
+
*/
|
|
365
|
+
export interface PendingTranslationPreview {
|
|
366
|
+
/** Key UUID */
|
|
367
|
+
keyId: string;
|
|
368
|
+
/** Key name */
|
|
369
|
+
key: string;
|
|
370
|
+
/** Namespace */
|
|
371
|
+
namespace: string | null;
|
|
372
|
+
/** Translation text */
|
|
373
|
+
text: string;
|
|
374
|
+
/** Translation status */
|
|
375
|
+
status: string;
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
/**
|
|
379
|
+
* Pending changes by language.
|
|
380
|
+
*/
|
|
381
|
+
export interface PendingChangesByLanguage {
|
|
382
|
+
/** Number of pending translations */
|
|
383
|
+
count: number;
|
|
384
|
+
/** Preview of first few translations */
|
|
385
|
+
preview: PendingTranslationPreview[];
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
/**
|
|
389
|
+
* Deleted key info.
|
|
390
|
+
*/
|
|
391
|
+
export interface PendingDeletedKey {
|
|
392
|
+
/** Key UUID */
|
|
393
|
+
keyId: string;
|
|
394
|
+
/** Key name */
|
|
395
|
+
key: string;
|
|
396
|
+
/** Namespace */
|
|
397
|
+
namespace: string | null;
|
|
398
|
+
/** Source text */
|
|
399
|
+
sourceText: string | null;
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
/**
|
|
403
|
+
* Response from getPendingChanges endpoint.
|
|
404
|
+
*/
|
|
405
|
+
export interface GetPendingChangesResponse {
|
|
406
|
+
/** Project identifier */
|
|
407
|
+
project: string;
|
|
408
|
+
/** Whether there are any pending changes */
|
|
409
|
+
hasPendingChanges: boolean;
|
|
410
|
+
/** Summary counts */
|
|
411
|
+
summary: {
|
|
412
|
+
/** Total pending translations */
|
|
413
|
+
translations: number;
|
|
414
|
+
/** Keys marked for deletion */
|
|
415
|
+
deletedKeys: number;
|
|
416
|
+
/** Language status changes */
|
|
417
|
+
languageChanges: number;
|
|
418
|
+
/** Total changes */
|
|
419
|
+
total: number;
|
|
420
|
+
};
|
|
421
|
+
/** Breakdown by language code */
|
|
422
|
+
byLanguage: Record<string, PendingChangesByLanguage>;
|
|
423
|
+
/** Deleted keys awaiting publish */
|
|
424
|
+
deletedKeys: PendingDeletedKey[];
|
|
425
|
+
/** Publish destination */
|
|
426
|
+
publishDestination: "github" | "cdn" | "none";
|
|
427
|
+
/** Reason if cannot publish */
|
|
428
|
+
cannotPublishReason?: string;
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
/**
|
|
432
|
+
* Response from publish endpoint.
|
|
433
|
+
*/
|
|
434
|
+
export interface PublishResponse {
|
|
435
|
+
/** Operation success */
|
|
436
|
+
success: boolean;
|
|
437
|
+
/** Number of translations published */
|
|
438
|
+
published: number;
|
|
439
|
+
/** Number of repositories updated */
|
|
440
|
+
repositories: number;
|
|
441
|
+
/** Created sync job IDs */
|
|
442
|
+
syncJobIds: string[];
|
|
443
|
+
/** Number of deleted keys processed */
|
|
444
|
+
deletedKeysProcessed?: number;
|
|
445
|
+
/** Number of language changes processed */
|
|
446
|
+
languageChangesProcessed?: number;
|
|
447
|
+
/** Human-readable message */
|
|
448
|
+
message: string;
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
/**
|
|
452
|
+
* Pending publish hint included in write operation responses.
|
|
453
|
+
* Helps AI model know when to call publish.
|
|
454
|
+
*/
|
|
455
|
+
export interface PendingPublishHint {
|
|
456
|
+
/** Whether there are unpublished changes */
|
|
457
|
+
hasChanges: boolean;
|
|
458
|
+
/** Number of pending changes from this operation */
|
|
459
|
+
count: number;
|
|
460
|
+
/** Hint message for AI */
|
|
461
|
+
hint: string;
|
|
462
|
+
}
|