@easyling/sanity-connector 1.4.0 → 2.0.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.
Files changed (69) hide show
  1. package/README.md +560 -90
  2. package/dist/index.js +2 -1
  3. package/dist/index.js.map +1 -0
  4. package/package.json +38 -54
  5. package/LICENSE +0 -21
  6. package/dist/.tsbuildinfo +0 -1
  7. package/dist-types/actions/bulkTranslate.d.ts +0 -6
  8. package/dist-types/actions/manageDNTFields.d.ts +0 -11
  9. package/dist-types/actions/translateDocument.d.ts +0 -6
  10. package/dist-types/components/RadioWithDefault.d.ts +0 -16
  11. package/dist-types/components/auth/AuthNavbar.d.ts +0 -17
  12. package/dist-types/components/auth/AuthStatus.d.ts +0 -26
  13. package/dist-types/components/auth/AuthStatusWrapper.d.ts +0 -14
  14. package/dist-types/components/auth/MigrationPrompt.d.ts +0 -19
  15. package/dist-types/components/auth/MigrationPromptWrapper.d.ts +0 -13
  16. package/dist-types/components/auth/OAuthCallback.d.ts +0 -19
  17. package/dist-types/components/auth/index.d.ts +0 -14
  18. package/dist-types/components/config/LocaleConfigTool.d.ts +0 -16
  19. package/dist-types/components/config/LocaleConfigToolWrapper.d.ts +0 -12
  20. package/dist-types/components/config/OAuthConfig.d.ts +0 -25
  21. package/dist-types/components/config/OAuthConfigWrapper.d.ts +0 -12
  22. package/dist-types/components/config/PasswordInput.d.ts +0 -13
  23. package/dist-types/components/config/index.d.ts +0 -8
  24. package/dist-types/components/config/localeConfigToolDefinition.d.ts +0 -12
  25. package/dist-types/components/config/oauthConfigToolDefinition.d.ts +0 -12
  26. package/dist-types/components/dialogs/ConfirmationDialog.d.ts +0 -20
  27. package/dist-types/components/dialogs/ErrorDialog.d.ts +0 -20
  28. package/dist-types/components/dialogs/LocaleSelectionDialog.d.ts +0 -62
  29. package/dist-types/components/dialogs/SuccessDialog.d.ts +0 -18
  30. package/dist-types/components/dialogs/index.d.ts +0 -11
  31. package/dist-types/components/dnt/DNTFieldBadge.d.ts +0 -15
  32. package/dist-types/components/dnt/DNTFieldComponent.d.ts +0 -16
  33. package/dist-types/components/dnt/DNTFieldInput.d.ts +0 -13
  34. package/dist-types/components/dnt/DebugDNTBadge.d.ts +0 -19
  35. package/dist-types/components/dnt/index.d.ts +0 -7
  36. package/dist-types/config/index.d.ts +0 -5
  37. package/dist-types/config/pluginConfig.d.ts +0 -162
  38. package/dist-types/index.d.ts +0 -11
  39. package/dist-types/plugin.d.ts +0 -12
  40. package/dist-types/services/authStateManager.d.ts +0 -93
  41. package/dist-types/services/collisionDetectionService.d.ts +0 -85
  42. package/dist-types/services/contentExtractor.d.ts +0 -161
  43. package/dist-types/services/dialogService.d.ts +0 -95
  44. package/dist-types/services/dntServiceManager.d.ts +0 -43
  45. package/dist-types/services/dntStorageAdapter.d.ts +0 -72
  46. package/dist-types/services/documentCreationService.d.ts +0 -262
  47. package/dist-types/services/localeService.d.ts +0 -159
  48. package/dist-types/services/localeStorageAdapter.d.ts +0 -41
  49. package/dist-types/services/oauthConfigStorage.d.ts +0 -45
  50. package/dist-types/services/oauthService.d.ts +0 -47
  51. package/dist-types/services/oauthServiceManager.d.ts +0 -195
  52. package/dist-types/services/tokenStorage.d.ts +0 -53
  53. package/dist-types/services/translationService.d.ts +0 -385
  54. package/dist-types/services/unifiedConfigStorage.d.ts +0 -158
  55. package/dist-types/test-utils.d.ts +0 -8
  56. package/dist-types/types/dialog.d.ts +0 -118
  57. package/dist-types/types/dnt.d.ts +0 -83
  58. package/dist-types/types/index.d.ts +0 -11
  59. package/dist-types/types/locale.d.ts +0 -115
  60. package/dist-types/types/oauth.d.ts +0 -89
  61. package/dist-types/types/pluginConfig.d.ts +0 -64
  62. package/dist-types/types/translation.d.ts +0 -121
  63. package/dist-types/utils/dntDefaults.d.ts +0 -101
  64. package/dist-types/utils/htmlFormatter.d.ts +0 -65
  65. package/dist-types/utils/index.d.ts +0 -16
  66. package/dist-types/utils/logger.d.ts +0 -104
  67. package/dist-types/utils/oauthErrorFeedback.d.ts +0 -75
  68. package/dist-types/utils/oauthLogger.d.ts +0 -175
  69. package/dist-types/utils/validator.d.ts +0 -66
@@ -1,195 +0,0 @@
1
- /**
2
- * OAuth Service Manager
3
- * Requirements: 6.1, 10.1, 9.2
4
- *
5
- * Manages singleton instances of OAuth services and handles initialization.
6
- * Provides centralized access to OAuth services throughout the plugin.
7
- */
8
- import { SanityClient } from 'sanity';
9
- import { OAuthService } from './oauthService';
10
- import { TokenStorage } from './tokenStorage';
11
- import { AuthStateManager } from './authStateManager';
12
- import { TranslationService } from './translationService';
13
- import { OAuthConfigStorage } from './oauthConfigStorage';
14
- /**
15
- * OAuth Service Manager
16
- *
17
- * Singleton manager for OAuth services. Ensures all services are properly
18
- * initialized and provides centralized access throughout the plugin.
19
- */
20
- export declare class OAuthServiceManager {
21
- private static instance;
22
- private oauthService;
23
- private tokenStorage;
24
- private authStateManager;
25
- private translationService;
26
- private oauthConfigStorage;
27
- private unifiedConfigStorage;
28
- private client;
29
- private initialized;
30
- /**
31
- * Private constructor to enforce singleton pattern
32
- * Requirements: 6.1, 10.1
33
- */
34
- private constructor();
35
- /**
36
- * Get or create the singleton instance
37
- * Requirements: 6.1, 10.1
38
- *
39
- * @param client - Sanity client instance
40
- * @returns Singleton instance of OAuthServiceManager
41
- */
42
- static getInstance(client: SanityClient): OAuthServiceManager;
43
- /**
44
- * Reset the singleton instance (useful for testing)
45
- */
46
- static resetInstance(): void;
47
- /**
48
- * Initialize OAuth services
49
- * Requirements: 6.1, 10.1
50
- *
51
- * Loads OAuth configuration, initializes OAuth service if configured,
52
- * initializes authentication state from storage, and sets up translation
53
- * service with authentication if available.
54
- *
55
- * @returns Promise that resolves when initialization is complete
56
- */
57
- initialize(): Promise<void>;
58
- /**
59
- * Set up listener for configuration changes
60
- *
61
- * Monitors the unified configuration document for changes and reloads
62
- * the configuration automatically.
63
- */
64
- private setupConfigListener;
65
- /**
66
- * Load OAuth configuration from storage
67
- * Requirements: 9.1, 9.4
68
- *
69
- * @returns OAuth configuration or null if not configured
70
- */
71
- private loadOAuthConfig;
72
- /**
73
- * Set up translation service with authentication if available
74
- *
75
- * Checks for valid stored authentication and configures the translation
76
- * service to use it.
77
- *
78
- * Supports dual mode operation:
79
- * - If OAuth is configured and authenticated, sets up OAuth authentication
80
- * - If OAuth is not configured, translation service works in legacy mode
81
- *
82
- * IMPORTANT: This method also syncs configuration from Sanity to localStorage
83
- * if configuration exists in Sanity but not in localStorage (migration support).
84
- */
85
- private setupTranslationServiceAuth;
86
- /**
87
- * Set up translation service endpoint and settings from configuration
88
- *
89
- * Loads translation endpoint, content type, and other settings from
90
- * unified configuration with fallback to defaults.
91
- */
92
- private setupTranslationServiceEndpoint;
93
- /**
94
- * Get OAuth service instance
95
- * Requirements: 1.1, 1.2, 1.3
96
- *
97
- * @returns OAuth service instance or null if not configured
98
- */
99
- getOAuthService(): OAuthService | null;
100
- /**
101
- * Get token storage instance
102
- * Requirements: 3.3, 3.4, 3.5
103
- *
104
- * @returns Token storage instance
105
- */
106
- getTokenStorage(): TokenStorage;
107
- /**
108
- * Get authentication state manager instance
109
- * Requirements: 6.1, 6.2, 6.3
110
- *
111
- * @returns Authentication state manager instance
112
- */
113
- getAuthStateManager(): AuthStateManager;
114
- /**
115
- * Get translation service instance
116
- * Requirements: 4.1, 4.2, 4.3
117
- *
118
- * @returns Translation service instance
119
- */
120
- getTranslationService(): TranslationService;
121
- /**
122
- * Get OAuth configuration storage instance
123
- * Requirements: 9.1, 9.4
124
- *
125
- * @returns OAuth configuration storage instance
126
- */
127
- getOAuthConfigStorage(): OAuthConfigStorage;
128
- /**
129
- * Check if OAuth is configured
130
- * Requirements: 10.1, 10.3
131
- *
132
- * @returns True if OAuth service is initialized
133
- */
134
- isOAuthConfigured(): boolean;
135
- /**
136
- * Detect which authentication method should be used
137
- * Requirements: 10.1, 10.3, 10.4
138
- *
139
- * Determines whether to use OAuth or legacy endpoint-based authentication
140
- * based on the presence of OAuth configuration.
141
- *
142
- * @returns 'oauth' if OAuth is configured, 'legacy' otherwise
143
- */
144
- getAuthenticationMode(): 'oauth' | 'legacy';
145
- /**
146
- * Check if user is authenticated with OAuth
147
- * Requirements: 10.1, 10.3
148
- *
149
- * @returns True if OAuth is configured and user has valid authentication
150
- */
151
- isOAuthAuthenticated(): Promise<boolean>;
152
- /**
153
- * Get authentication status information
154
- * Requirements: 10.1, 10.3, 10.4
155
- *
156
- * Provides detailed information about the current authentication mode
157
- * and status for display to users.
158
- *
159
- * @returns Object with authentication mode and status details
160
- */
161
- getAuthenticationStatus(): Promise<{
162
- mode: 'oauth' | 'legacy';
163
- isOAuthConfigured: boolean;
164
- isAuthenticated: boolean;
165
- requiresAuthentication: boolean;
166
- }>;
167
- /**
168
- * Check if services are initialized
169
- * Requirements: 6.1
170
- *
171
- * @returns True if initialization is complete
172
- */
173
- isInitialized(): boolean;
174
- /**
175
- * Save authentication configuration and data
176
- *
177
- * Stores the access token and project ID, and configures the translation service.
178
- *
179
- * @param accessToken - The Easyling access token
180
- * @param projectId - The Easyling project ID
181
- */
182
- saveAuth(accessToken: string, projectId: string): Promise<void>;
183
- /**
184
- * Logout and clear authentication
185
- */
186
- logout(): Promise<void>;
187
- /**
188
- * Refresh configuration from Sanity
189
- *
190
- * Reloads the translation service endpoint and other settings from Sanity.
191
- * This should be called when the configuration has been updated in Sanity
192
- * to ensure the plugin is using the latest settings.
193
- */
194
- refreshConfiguration(): Promise<void>;
195
- }
@@ -1,53 +0,0 @@
1
- /**
2
- * Token Storage Service
3
- *
4
- * Manages secure storage and retrieval of OAuth authentication tokens
5
- * and related data using Sanity Studio's localStorage wrapper.
6
- *
7
- * Requirements: 3.3, 3.4, 3.5, 6.1, 6.4, 8.4
8
- */
9
- import { StoredAuthData } from '../types/oauth';
10
- /**
11
- * Token Storage Service
12
- *
13
- * Provides methods for persisting, retrieving, and managing OAuth authentication data.
14
- * Uses Sanity Studio's localStorage for persistence with JSON serialization.
15
- */
16
- export declare class TokenStorage {
17
- /**
18
- * Store authentication data securely
19
- *
20
- * @param data - Authentication data to store
21
- * @throws {OAuthError} If storage operation fails
22
- */
23
- storeAuthData(data: StoredAuthData): Promise<void>;
24
- /**
25
- * Retrieve stored authentication data
26
- *
27
- * @returns Stored authentication data or null if not found
28
- * @throws {OAuthError} If storage read fails or data is corrupted
29
- */
30
- getAuthData(): Promise<StoredAuthData | null>;
31
- /**
32
- * Clear all stored authentication data
33
- *
34
- * Requirements: 6.4
35
- *
36
- * @throws {OAuthError} If storage clear operation fails
37
- */
38
- clearAuthData(): Promise<void>;
39
- /**
40
- * Check if the stored token is expired
41
- *
42
- * For long-lived tokens, this always returns false if a token exists.
43
- *
44
- * @returns True if token is not found, false if token exists
45
- */
46
- isTokenExpired(): Promise<boolean>;
47
- /**
48
- * Get a valid access token if available
49
- *
50
- * @returns Valid access token or null if not found
51
- */
52
- getValidAccessToken(): Promise<string | null>;
53
- }
@@ -1,385 +0,0 @@
1
- import { ExtendedDocumentContent } from './contentExtractor';
2
- /**
3
- * Field object structure supporting translation-invariant fields
4
- */
5
- export interface TranslatableField {
6
- /** The actual field value (serialized as string for the protobuf) */
7
- value: unknown;
8
- /** Do Not Translate flag - if true, the field should not be translated */
9
- dnt?: boolean;
10
- /** Type of the field value from Sanity (e.g., 'string', 'number', 'date', 'slug', 'array', 'object') */
11
- type?: string;
12
- /**
13
- * GROQ-style path for reconstructing the document structure
14
- * Example: *[_type == "blogPost" && _id == $documentId][0].article.footnotes[_key == "abc123"].footnote
15
- */
16
- path?: string;
17
- }
18
- export interface TranslationRequest {
19
- documentId: string;
20
- endpoint: string;
21
- payload: TranslationRequestPayload;
22
- }
23
- /**
24
- * Request payload sent to the translation service
25
- *
26
- * @example Single locale (backward compatible):
27
- * ```json
28
- * {
29
- * "content": {
30
- * "body": "<h1>Welcome</h1><p>This is sample content.</p>",
31
- * "title": "Welcome Article",
32
- * "slug": "welcome-article",
33
- * "fields": {
34
- * "author": { "value": "John Doe", "dnt": false },
35
- * "category": { "value": "General", "dnt": true }
36
- * }
37
- * },
38
- * "format": "html",
39
- * "metadata": {
40
- * "documentId": "article-123",
41
- * "documentType": "article",
42
- * "title": "Welcome Article",
43
- * "sourceLanguage": "en",
44
- * "targetLanguage": "es"
45
- * }
46
- * }
47
- * ```
48
- *
49
- * @example Multiple locales:
50
- * ```json
51
- * {
52
- * "content": {
53
- * "body": "<h1>Welcome</h1><p>This is sample content.</p>",
54
- * "title": "Welcome Article",
55
- * "slug": "welcome-article",
56
- * "fields": {
57
- * "author": { "value": "John Doe", "dnt": false },
58
- * "category": { "value": "General", "dnt": true }
59
- * }
60
- * },
61
- * "format": "html",
62
- * "metadata": {
63
- * "documentId": "article-123",
64
- * "documentType": "article",
65
- * "title": "Welcome Article",
66
- * "sourceLanguage": "en",
67
- * "targetLocales": ["es", "fr", "de"]
68
- * }
69
- * }
70
- * ```
71
- */
72
- export interface TranslationRequestPayload {
73
- /** Content to be translated */
74
- content: {
75
- /** HTML content extracted from Sanity document */
76
- body: string;
77
- /** Document title */
78
- title: string;
79
- /** Document slug */
80
- slug: string;
81
- /** Additional document fields with translation control via dnt flag */
82
- fields: Record<string, TranslatableField | any>;
83
- };
84
- /** Content format - always 'html' for this plugin */
85
- format: 'html';
86
- /** Metadata about the document and translation request */
87
- metadata: {
88
- /** Unique identifier for the source document */
89
- documentId: string;
90
- /** Sanity document type (e.g., 'article', 'page', 'post') */
91
- documentType: string;
92
- /** Document title (same as content.title) */
93
- title: string;
94
- /** Source language code (optional, e.g., 'en', 'fr', 'es') */
95
- sourceLanguage?: string;
96
- /** Target language code (optional, e.g., 'en', 'fr', 'es') - for backward compatibility */
97
- targetLanguage?: string;
98
- /** Array of target locale codes (e.g., ['es', 'fr', 'de']) - for multi-locale support */
99
- targetLocales?: string[];
100
- /** Whether the title was found at the document's top level (false if extracted from nested fields) */
101
- titleFoundAtTopLevel?: boolean;
102
- };
103
- }
104
- /**
105
- * Translated document structure
106
- */
107
- export interface TranslatedDocument {
108
- /**
109
- * Translated HTML content
110
- * - Must be valid HTML
111
- * - Should preserve original structure
112
- * - Will be converted back to Portable Text by the plugin
113
- */
114
- body: string;
115
- /**
116
- * Translated document title
117
- * - Must be non-empty string
118
- * - No HTML tags allowed
119
- */
120
- title: string;
121
- /**
122
- * Translated/localized slug
123
- * - Must contain only lowercase letters, numbers, hyphens, and underscores
124
- * - Should be URL-friendly and unique
125
- * - Pattern: ^[a-z0-9-_]+$
126
- */
127
- slug: string;
128
- /**
129
- * Additional translated document fields
130
- * - Must be an object (can be empty)
131
- * - Translatable text fields should be translated
132
- * - Non-translatable fields (dates, IDs) should be preserved
133
- * - Fields marked with dnt=true should remain unchanged
134
- */
135
- fields: Record<string, TranslatableField>;
136
- /**
137
- * Target locale code for this translation (e.g., 'es', 'fr', 'de')
138
- */
139
- locale?: string;
140
- /**
141
- * Whether the title was found at the document's top level
142
- * When false, the translated title should not be written as a top-level field
143
- */
144
- titleFoundAtTopLevel?: boolean;
145
- }
146
- /**
147
- * Response format expected from the translation service
148
- *
149
- * @example Single locale success response:
150
- * ```json
151
- * {
152
- * "success": true,
153
- * "translatedDocuments": [
154
- * {
155
- * "body": "<h1>Translated HTML</h1><p>Translated content...</p>",
156
- * "title": "Translated Title",
157
- * "slug": "translated-slug",
158
- * "fields": {
159
- * "author": { "value": "Translated Author", "dnt": false },
160
- * "category": { "value": "General", "dnt": true }
161
- * },
162
- * "locale": "es"
163
- * }
164
- * ],
165
- * "sourceLocale": "en",
166
- * "requestId": "req-123"
167
- * }
168
- * ```
169
- *
170
- * @example Multi-locale success response:
171
- * ```json
172
- * {
173
- * "success": true,
174
- * "translatedDocuments": [
175
- * {
176
- * "body": "<h1>HTML traducido</h1><p>Contenido traducido...</p>",
177
- * "title": "Título traducido",
178
- * "slug": "titulo-traducido",
179
- * "fields": {
180
- * "author": { "value": "Autor traducido", "dnt": false },
181
- * "category": { "value": "General", "dnt": true }
182
- * },
183
- * "locale": "es"
184
- * },
185
- * {
186
- * "body": "<h1>HTML traduit</h1><p>Contenu traduit...</p>",
187
- * "title": "Titre traduit",
188
- * "slug": "titre-traduit",
189
- * "fields": {
190
- * "author": { "value": "Auteur traduit", "dnt": false },
191
- * "category": { "value": "General", "dnt": true }
192
- * },
193
- * "locale": "fr"
194
- * }
195
- * ],
196
- * "sourceLocale": "en",
197
- * "requestId": "req-123"
198
- * }
199
- * ```
200
- *
201
- * @example Error Response:
202
- * ```json
203
- * {
204
- * "success": false,
205
- * "error": "Translation failed: Unsupported language pair",
206
- * "requestId": "req-123"
207
- * }
208
- * ```
209
- */
210
- export interface TranslationResponse {
211
- /** Indicates whether the translation was successful */
212
- success: boolean;
213
- /**
214
- * Array of translated documents (required when success is true)
215
- * Contains one translated document per target locale
216
- */
217
- translatedDocuments?: TranslatedDocument[];
218
- /** Source locale code (e.g., 'en') */
219
- sourceLocale?: string;
220
- /**
221
- * Error message (required when success is false)
222
- * Should provide a clear description of what went wrong
223
- */
224
- error?: string;
225
- /**
226
- * Optional unique request identifier for tracking
227
- * Useful for debugging and request correlation
228
- */
229
- requestId?: string;
230
- /** @deprecated Use translatedDocuments array instead */
231
- translatedContent?: TranslatedDocument;
232
- /** @deprecated Use translatedDocuments array instead */
233
- translations?: {
234
- [localeCode: string]: {
235
- content: TranslatedDocument;
236
- status: 'completed' | 'failed' | 'pending';
237
- error?: string;
238
- };
239
- };
240
- }
241
- export interface BulkTranslationSummary {
242
- totalDocuments: number;
243
- processedDocuments: number;
244
- failedDocuments: number;
245
- requests: TranslationRequest[];
246
- responses: TranslationResponse[];
247
- }
248
- export declare class TranslationService {
249
- private placeholderEndpoint;
250
- private accessToken?;
251
- private projectId?;
252
- private requestContentType;
253
- private responseAcceptHeader;
254
- constructor(placeholderEndpoint?: string, requestContentType?: 'application/json' | 'application/x-protobuf', responseAcceptHeader?: 'application/json' | 'application/x-protobuf');
255
- /**
256
- * Infer the Sanity field type from a value
257
- *
258
- * @param value - The field value to inspect
259
- * @returns The inferred Sanity type string
260
- */
261
- private inferSanityType;
262
- /**
263
- * Set authentication token and project ID
264
- * Requirements: 4.1, 4.2, 4.3
265
- *
266
- * @param token - Access token for API authentication
267
- * @param projectId - Project ID to include in requests
268
- */
269
- setAuthToken(token: string, projectId: string): void;
270
- /**
271
- * Clear authentication data
272
- */
273
- clearAuth(): void;
274
- /**
275
- * Update configuration for content types and endpoint
276
- * Allows partial updates - only provided parameters will be updated
277
- * Requirements: 1.1, 2.3, 3.3
278
- *
279
- * @param endpoint - Optional translation API endpoint URL
280
- * @param requestContentType - Optional request Content-Type header value
281
- * @param responseAcceptHeader - Optional response Accept header value
282
- */
283
- setConfiguration(endpoint?: string, requestContentType?: 'application/json' | 'application/x-protobuf', responseAcceptHeader?: 'application/json' | 'application/x-protobuf'): void;
284
- /**
285
- * Convert internal payload to Protocol Buffer binary format
286
- * Requirements: Uses @easyling/sanity protobuf library
287
- *
288
- * @param payload - Internal translation request payload
289
- * @returns Binary protobuf message
290
- */
291
- private convertPayloadToProtobuf;
292
- /**
293
- * Convert protobuf payload to JSON for logging purposes only
294
- *
295
- * @param payload - Internal translation request payload
296
- * @returns JSON representation for logging
297
- */
298
- private convertPayloadToProtobufJSON;
299
- /**
300
- * Normalize field values to ensure consistency
301
- * Extracts values from TranslatableField objects and handles various formats
302
- */
303
- private normalizeTranslatedFields;
304
- /**
305
- * Convert binary protobuf response to internal format
306
- * Requirements: Uses @easyling/sanity protobuf library
307
- *
308
- * @param binaryData - Binary protobuf response data
309
- * @returns Internal translation response format
310
- */
311
- private convertProtobufBinaryToResponse;
312
- /**
313
- * Convert protobuf JSON response back to internal format (for legacy support)
314
- * Requirements: Uses @easyling/sanity protobuf library
315
- *
316
- * @param jsonData - JSON response data
317
- * @returns Internal translation response format
318
- */
319
- private convertProtobufJSONToResponse;
320
- /**
321
- * Prepare a translation request for a single document
322
- * Requirements: 1.2, 1.3, 3.3, 2.5, 2.7
323
- *
324
- * @param content - Document content to translate
325
- * @param documentType - Type of the document
326
- * @param sourceLanguage - Source language code (optional)
327
- * @param targetLanguage - Single target language code (optional, for backward compatibility)
328
- * @param targetLocales - Array of target locale codes (optional, for multi-locale support)
329
- */
330
- prepareTranslationRequest(content: ExtendedDocumentContent, documentType?: string, sourceLanguage?: string, targetLanguage?: string, targetLocales?: string[]): TranslationRequest;
331
- /**
332
- * Translate a single document
333
- * Requirements: 1.2, 1.3, 3.3, 2.5, 2.7
334
- *
335
- * @param content - Document content to translate
336
- * @param documentType - Type of the document
337
- * @param sourceLanguage - Source language code (optional)
338
- * @param targetLanguage - Single target language code (optional, for backward compatibility)
339
- * @param targetLocales - Array of target locale codes (optional, for multi-locale support)
340
- */
341
- translateDocument(content: ExtendedDocumentContent, documentType?: string, sourceLanguage?: string, targetLanguage?: string, targetLocales?: string[]): Promise<TranslationResponse>;
342
- /**
343
- * Send translation request to the configured endpoint
344
- *
345
- * Uses the @easyling/sanity Protocol Buffer library to format messages as JSON
346
- * (not binary protobuf) for better compatibility with various backends.
347
- * Handles the new array-based response format with backward compatibility.
348
- * The service now expects translatedDocuments as an array, but will convert
349
- * legacy formats (translatedContent or translations object) to the new format.
350
- *
351
- * Supports dual mode operation:
352
- * - Authenticated mode: Uses Bearer token authentication when configured
353
- * - Legacy mode: Works without authentication for backward compatibility
354
- */
355
- sendTranslationRequest(request: TranslationRequest): Promise<TranslationResponse>;
356
- /**
357
- * Log translation request to console for verification
358
- * Requirements: 1.3, 2.4
359
- */
360
- logTranslationRequest(request: TranslationRequest): void;
361
- /**
362
- * Process bulk translation for multiple documents
363
- * Requirements: 2.1, 2.2, 2.3, 2.4, 2.5, 2.7
364
- *
365
- * @param contents - Array of document contents to translate
366
- * @param documentType - Type of the documents
367
- * @param sourceLanguage - Source language code (optional)
368
- * @param targetLanguage - Single target language code (optional, for backward compatibility)
369
- * @param targetLocales - Array of target locale codes (optional, for multi-locale support)
370
- */
371
- processBulkTranslation(contents: ExtendedDocumentContent[], documentType?: string, sourceLanguage?: string, targetLanguage?: string, targetLocales?: string[]): Promise<BulkTranslationSummary>;
372
- /**
373
- * Log bulk translation summary
374
- * Requirements: 2.5
375
- */
376
- private logBulkTranslationSummary;
377
- /**
378
- * Update the placeholder endpoint
379
- */
380
- setEndpoint(endpoint: string): void;
381
- /**
382
- * Get the current endpoint
383
- */
384
- getEndpoint(): string;
385
- }