@easyling/sanity-connector 1.3.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 (68) hide show
  1. package/README.md +570 -68
  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 -40
  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/contentExtractor.d.ts +0 -161
  42. package/dist-types/services/dialogService.d.ts +0 -95
  43. package/dist-types/services/dntServiceManager.d.ts +0 -43
  44. package/dist-types/services/dntStorageAdapter.d.ts +0 -72
  45. package/dist-types/services/documentCreationService.d.ts +0 -196
  46. package/dist-types/services/localeService.d.ts +0 -159
  47. package/dist-types/services/localeStorageAdapter.d.ts +0 -41
  48. package/dist-types/services/oauthConfigStorage.d.ts +0 -45
  49. package/dist-types/services/oauthService.d.ts +0 -47
  50. package/dist-types/services/oauthServiceManager.d.ts +0 -195
  51. package/dist-types/services/tokenStorage.d.ts +0 -53
  52. package/dist-types/services/translationService.d.ts +0 -385
  53. package/dist-types/services/unifiedConfigStorage.d.ts +0 -133
  54. package/dist-types/test-utils.d.ts +0 -8
  55. package/dist-types/types/dialog.d.ts +0 -106
  56. package/dist-types/types/dnt.d.ts +0 -83
  57. package/dist-types/types/index.d.ts +0 -11
  58. package/dist-types/types/locale.d.ts +0 -115
  59. package/dist-types/types/oauth.d.ts +0 -89
  60. package/dist-types/types/pluginConfig.d.ts +0 -46
  61. package/dist-types/types/translation.d.ts +0 -121
  62. package/dist-types/utils/dntDefaults.d.ts +0 -101
  63. package/dist-types/utils/htmlFormatter.d.ts +0 -65
  64. package/dist-types/utils/index.d.ts +0 -16
  65. package/dist-types/utils/logger.d.ts +0 -104
  66. package/dist-types/utils/oauthErrorFeedback.d.ts +0 -75
  67. package/dist-types/utils/oauthLogger.d.ts +0 -175
  68. package/dist-types/utils/validator.d.ts +0 -66
@@ -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
- }
@@ -1,133 +0,0 @@
1
- /**
2
- * Unified Configuration Storage Adapter
3
- *
4
- * Provides centralized persistence for all plugin configuration using Sanity's document storage.
5
- * This replaces separate OAuth and Locale storage adapters with a single unified configuration.
6
- *
7
- * Stores in a single EL_PluginConfiguration document:
8
- * - OAuth configuration (projectId, accessToken)
9
- * - Locale definitions and settings
10
- * - DNT field mappings by document type
11
- */
12
- import { SanityClient } from 'sanity';
13
- import { OAuthConfig } from '../types/oauth';
14
- import { LocaleConfig } from '../types/locale';
15
- /**
16
- * Unified plugin configuration structure
17
- */
18
- export interface UnifiedPluginConfig {
19
- /** OAuth/authentication settings */
20
- projectId?: string;
21
- accessToken?: string;
22
- /** Translation settings */
23
- translationApiEndpoint?: string;
24
- requestContentType?: 'application/json' | 'application/x-protobuf';
25
- responseAcceptHeader?: 'application/json' | 'application/x-protobuf';
26
- defaultDocumentCreationMode?: 'draft' | 'published';
27
- /** Locale configuration */
28
- locales?: LocaleConfig['locales'];
29
- defaultLocale?: string;
30
- /** DNT field map: { [documentType]: { [fieldPath]: boolean } } */
31
- dntFieldMap?: Record<string, Record<string, boolean>>;
32
- /** Debug mode - when enabled, shows additional DNT badges on all fields */
33
- debugMode?: boolean;
34
- /** Configuration version for migrations */
35
- version?: string;
36
- /** Last updated timestamp */
37
- lastUpdated?: string;
38
- }
39
- /**
40
- * Unified configuration storage adapter for Sanity
41
- */
42
- export declare class UnifiedConfigStorage {
43
- private client;
44
- constructor(client: SanityClient);
45
- /**
46
- * Convert array-based DNT configuration (schema format) to map format (internal use)
47
- */
48
- private convertDNTArrayToMap;
49
- /**
50
- * Convert map-based DNT configuration (internal format) to array format (schema format)
51
- */
52
- private convertDNTMapToArray;
53
- /**
54
- * Load complete unified configuration from Sanity
55
- */
56
- load(): Promise<UnifiedPluginConfig | null>;
57
- /**
58
- * Save complete unified configuration to Sanity
59
- */
60
- save(config: UnifiedPluginConfig): Promise<void>;
61
- /**
62
- * Update only specific fields without overwriting entire config
63
- */
64
- update(updates: Partial<UnifiedPluginConfig>): Promise<void>;
65
- /**
66
- * Delete the unified configuration document
67
- */
68
- delete(): Promise<void>;
69
- /**
70
- * Load only OAuth configuration
71
- */
72
- loadOAuth(): Promise<OAuthConfig | null>;
73
- /**
74
- * Save OAuth configuration
75
- */
76
- saveOAuth(oauthConfig: OAuthConfig): Promise<void>;
77
- /**
78
- * Load only locale configuration
79
- */
80
- loadLocale(): Promise<LocaleConfig | null>;
81
- /**
82
- * Save locale configuration
83
- */
84
- saveLocale(localeConfig: LocaleConfig): Promise<void>;
85
- /**
86
- * Get DNT field map for a specific document type
87
- */
88
- getDNTFieldsForType(documentType: string): Promise<Record<string, boolean>>;
89
- /**
90
- * Set DNT status for a field in a document type
91
- */
92
- setDNTField(documentType: string, fieldPath: string, dnt: boolean): Promise<void>;
93
- /**
94
- * Toggle DNT status for a field in a document type
95
- */
96
- toggleDNTField(documentType: string, fieldPath: string): Promise<boolean>;
97
- /**
98
- * Get DNT status for a specific field in a document type
99
- */
100
- getDNTFieldStatus(documentType: string, fieldPath: string): Promise<boolean>;
101
- /**
102
- * Clear all DNT fields for a document type
103
- */
104
- clearDNTFieldsForType(documentType: string): Promise<void>;
105
- /**
106
- * Get all DNT field mappings
107
- */
108
- getAllDNTFields(): Promise<Record<string, Record<string, boolean>>>;
109
- /**
110
- * Get translation API endpoint with fallback to default
111
- */
112
- getTranslationEndpoint(): Promise<string>;
113
- /**
114
- * Get request content type with fallback to default
115
- */
116
- getRequestContentType(): Promise<'application/json' | 'application/x-protobuf'>;
117
- /**
118
- * Get response accept header with fallback to default
119
- */
120
- getResponseAcceptHeader(): Promise<'application/json' | 'application/x-protobuf'>;
121
- /**
122
- * Get default document creation mode with fallback to default
123
- */
124
- getDefaultDocumentCreationMode(): Promise<'draft' | 'published'>;
125
- /**
126
- * Get debug mode status
127
- */
128
- getDebugMode(): Promise<boolean>;
129
- /**
130
- * Set debug mode status
131
- */
132
- setDebugMode(enabled: boolean): Promise<void>;
133
- }
@@ -1,8 +0,0 @@
1
- /**
2
- * Test utilities for component testing
3
- */
4
- import { ReactElement } from 'react';
5
- import { RenderOptions } from '@testing-library/react';
6
- declare const customRender: (ui: ReactElement, options?: Omit<RenderOptions, "wrapper">) => import("@testing-library/react").RenderResult<typeof import("@testing-library/dom/types/queries"), HTMLElement, HTMLElement>;
7
- export * from '@testing-library/react';
8
- export { customRender as render };
@@ -1,106 +0,0 @@
1
- /**
2
- * Dialog system type definitions
3
- * Requirements: 5.1, 5.2, 5.3
4
- */
5
- /**
6
- * Base dialog configuration options
7
- */
8
- export interface BaseDialogOptions {
9
- /** Dialog title */
10
- title: string;
11
- /** Dialog message or content */
12
- message: string;
13
- /** Whether the dialog can be closed by clicking outside */
14
- closable?: boolean;
15
- /** Custom CSS class for styling */
16
- className?: string;
17
- }
18
- /**
19
- * Confirmation dialog options
20
- */
21
- export interface ConfirmationDialogOptions extends BaseDialogOptions {
22
- /** Text for the confirm button */
23
- confirmText?: string;
24
- /** Text for the cancel button */
25
- cancelText?: string;
26
- /** Visual tone of the dialog */
27
- tone?: 'primary' | 'critical' | 'caution';
28
- /** Additional details to display */
29
- details?: string;
30
- }
31
- /**
32
- * Success dialog options
33
- */
34
- export interface SuccessDialogOptions extends BaseDialogOptions {
35
- /** Additional details about the success */
36
- details?: string;
37
- /** Auto-close timeout in milliseconds */
38
- autoCloseTimeout?: number;
39
- }
40
- /**
41
- * Error dialog options
42
- */
43
- export interface ErrorDialogOptions extends BaseDialogOptions {
44
- /** Error object for detailed information */
45
- error?: Error;
46
- /** Whether to show a retry button */
47
- showRetry?: boolean;
48
- /** Text for the retry button */
49
- retryText?: string;
50
- }
51
- /**
52
- * Locale selection dialog options
53
- */
54
- export interface LocaleSelectionDialogOptions extends BaseDialogOptions {
55
- /** Available locales to choose from */
56
- availableLocales: LocaleDefinition[];
57
- /** Currently selected locale codes */
58
- selectedLocales: string[];
59
- /** Documents being translated (for context) */
60
- selectedDocuments: any[];
61
- /** Translation mode */
62
- mode: 'single' | 'bulk';
63
- /** Whether multiple locales can be selected */
64
- allowMultiple?: boolean;
65
- /** Whether locale selection is required */
66
- required?: boolean;
67
- /** Whether to show creation mode option in the dialog */
68
- showCreationModeOption?: boolean;
69
- /** Default creation mode to pre-select */
70
- defaultCreationMode?: 'draft' | 'published';
71
- }
72
- /**
73
- * Locale selection result
74
- */
75
- export interface LocaleSelectionResult {
76
- /** Selected locale codes */
77
- locales: string[];
78
- /** Selected creation mode (if showCreationModeOption was true) */
79
- creationMode?: 'draft' | 'published';
80
- }
81
- /**
82
- * Dialog result types
83
- */
84
- export type DialogResult<T = unknown> = {
85
- /** Whether the dialog was confirmed or cancelled */
86
- confirmed: boolean;
87
- /** Result data from the dialog */
88
- data?: T;
89
- };
90
- /**
91
- * Dialog manager interface for centralized dialog handling
92
- */
93
- export interface DialogManager {
94
- /** Show a confirmation dialog */
95
- showConfirmation(options: ConfirmationDialogOptions): Promise<boolean>;
96
- /** Show a locale selection dialog */
97
- showLocaleSelection(options: LocaleSelectionDialogOptions): Promise<LocaleSelectionResult>;
98
- /** Show a success notification */
99
- showSuccess(options: SuccessDialogOptions): void;
100
- /** Show an error dialog */
101
- showError(options: ErrorDialogOptions): Promise<boolean>;
102
- /** Close all open dialogs */
103
- closeAll(): void;
104
- }
105
- import type { LocaleDefinition } from './locale';
106
- export type { LocaleDefinition } from './locale';